# Tag Info

Accepted

### Is Apple's M1 suitable for Operations Research?

One problem you might encounter is that the many solvers are either not available for M1 like CPLEX[1]. M1 support for Gurobi might be mixed in general due to issue like "Only use single-threaded ...
• 3,349

### Is Apple's M1 suitable for Operations Research?

We at Mosek has started porting Mosek to the Apple M1 CPU so the upcoming version 10 will support it. Here is an initial thought. Normally optimization software links to a BLAS/LAPACK library such as ...
• 2,403

### Comparison of Algebraic modelling languages and general programming languages

GAMS and AMPL are general purpose modelling languages and can he used to describe any type of nonlinear function, including some niche stuff like floor, ceil, max, etc (AMPL). I don't have experience ...
• 11.1k

### Add robustness of AMPL code through file name

AMPL assumes that a parameter takes only numerical values, unless you add the keyword symbolic to say that string values are also permitted. So your first statement ...
• 466
Accepted

### Find a particular optimal solution

I don't think there is anything special in AMPL for doing this, but it can be done. Option 1 is to add a term to the objective that penalizes the sum of all variables. (I'm assuming that all variables ...
• 28.8k
Accepted

### VRPTW implementation

Before implementing anything, you need to understand the equations. A good approach is to think in terms of resources. When handling capacity constraints, you are dealing with a load resource which is ...
• 10.1k

### Overwrite on a txt file from AMPL

To overwrite a file that you have previously been writing in an AMPL session, first close the file: close (OutputFile); Then use > to overwrite the file: ...
• 466
Accepted

### Overwrite on a txt file from AMPL

This should overwrite : k > (OutputFile); While this appends : k >> (OutputFile);
• 10.1k

### Constraint that checks for an undirected graph whether it is connected?

I am aware of models that model such constraints using a network-flow-type approach. The basic idea is to create a source node that send "flow" of an imaginary product for which all nodes have a ...
• 12.5k
Accepted

...
• 8,185

### Matrix in ampl: constraint that the values ​are all different

I'm not sure if this helps you, but here is a "pure" IP model for the magic square problem, i.e. no all_different. However it's in MiniZinc (not AMPL), but it ...
• 834
Accepted

### Declare numerical-sequence set in AMPL .dat file

The .. operator cannot be used in the data section (i.e. it won't be expanded, see the AMPL FAQ). What you can do is to declare the limits in the model, e.g. ...
• 2,665
Accepted

### Obtaining the intermediate solutions in AMPL

Yes it is reasonable. For problems where closing the optimality gap is difficult, you may want to save e.g. the 10 best solutions found before termination. This is called a solution pool and it is a ...
• 11.1k
Accepted

### How do I get the first and last item of a set in GLPK

I'm not familiar with GLPK, but since it's based on AMPL, the following AMPL implementation might be of some help: ...
• 466

### Handy way to index set of tuples in AMPL

Try sum{(i,j) in ARCS} blablabla[i,j]
• 21.7k

### Error defining a binary parameter in AMPL

Using the assignment operator := inside the loop is redefining h for each combination of k and j, which is an error. I assume that your actual data set will not have the same 2D data matrix for all (k,...
• 28.8k
Accepted

### How to formulate case distinctions in AMPLs objective function?

Let $\rho$ be some small value. \begin{align}M \times f(x) &\geq x - 1 + \rho\\M \times (1 - f(x)) &\geq 1 - x - \rho\end{align} Here is the small working code in Python ...
• 1,579

### Matrix in ampl: constraint that the values ​are all different

Please check this link to my answer to your previous question. I included a link in which without using alldiff, Sudoku problem (where the magic constant is equal ...
• 8,185
Accepted

### Matrix in ampl: constraint that the values ​are all different

Outside an exam scenario, the correct answer is "switch to a solver that supports alldiff", but I'm assuming you are required to solve this in Gurobi. One way to ...
• 1,767

### Matrix in ampl: constraint that the values ​are all different

In AMPL's website, there is a code for solving sudoku which is very similar to your problem. In their code they also used alldiff. The only thing that you need to ...
• 8,185

### Understanding the AMPL Solver LIbrary within Pyomo

The AMPL Solver Library (or ASL) is an open-source interface between solvers and modelling languages. As long as a solver can (i) read an .nl file and (ii) produce a .sol file, it will work out of the ...
• 11.1k

### Combinatorial Optimization using AMPL

Here is the AMPL interpretation of @RobPratt's answer which works perfectly using the gurobi in my local pc: ...
• 8,185

### Combinatorial Optimization using AMPL

Here is the SAS code that I used to obtain the results in the linked thread. Maybe it will help you correct your AMPL errors. In particular, note that you should declare each variable only once. <...
• 21.7k
Accepted

### How to define hybrid variables without using additional binary variables?

An alternative approach to binary variables or semicontinuous variables is the following cubic polynomial inequality: $$x(x-L_B)(U_B-x)\ge 0$$ Because $x \ge 0$, this constraint enforces (x = 0) \...
• 21.7k
Accepted

### How to set combined stop condition in AMPL/CPLEX?

Your ratio current/best possible is not itself a gap; it is part of what you would use to compute the relative gap. The relative gap defined by CPLEX is the absolute difference between the objective ...
• 28.8k

### Constraint that checks for an undirected graph whether it is connected?

One possible solution (not necessarily quick or efficient) is a lazy constraint approach: Solve your problem, ignoring the connection requirement Examine the solution and find the subgraph $H$ that ...
• 1,767

### AMPL implement constraint

This looks most like the math (and avoids checking for every $(i,j,t)$ a logical condition that depends only on $i$ and $j$): {i in PP, j in PP diff {i}, t in TT}
• 21.7k

### Why is the value negative? AMPL

You are not bounding $Y_{i,j,s}$ from below and hence have to add a nonnegativity constraint similar to the one for $X_{i,j}$. As long as $\sum_{s \in S} Y_{i,j,s}$ is larger or equal to zero (...
1 vote

### AMPL Gurobi Define Variables Bounds

I am going to answer my own question. After I made the post, I realized the variable pi actually don't show up in the model though declared. It looks like this is the reason why the first way doesn't ...
• 159
1 vote

### Constraint that checks for an undirected graph whether it is connected?

You may have a look at this presentation about network flows implementations in AMPL. In the presentation, the authors talked about new AMPL implementations of "arc" and "node" especially on page 8 ...
• 8,185

Only top scored, non community-wiki answers of a minimum length are eligible