Hot answers tagged

15 votes
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 ...
user avatar
10 votes

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 ...
user avatar
  • 2,403
9 votes

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 ...
user avatar
7 votes

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 ...
user avatar
  • 466
6 votes
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 ...
user avatar
  • 28.8k
6 votes
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 ...
user avatar
  • 10.1k
6 votes

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: ...
user avatar
  • 466
5 votes
Accepted

Overwrite on a txt file from AMPL

This should overwrite : k > (OutputFile); While this appends : k >> (OutputFile);
user avatar
  • 10.1k
5 votes

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 ...
user avatar
4 votes
Accepted

Issue interpreting sets of constraints in AMPL

...
user avatar
  • 8,185
4 votes

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 ...
user avatar
  • 834
4 votes
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. ...
user avatar
  • 2,665
4 votes
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 ...
user avatar
4 votes
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: ...
user avatar
  • 466
4 votes

Handy way to index set of tuples in AMPL

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

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,...
user avatar
  • 28.8k
3 votes
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 ...
user avatar
  • 1,579
3 votes

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 ...
user avatar
  • 8,185
3 votes
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 ...
user avatar
3 votes

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 ...
user avatar
  • 8,185
3 votes

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 ...
user avatar
3 votes

Combinatorial Optimization using AMPL

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

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. <...
user avatar
  • 21.7k
3 votes
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) \...
user avatar
  • 21.7k
3 votes
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 ...
user avatar
  • 28.8k
3 votes

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 ...
user avatar
2 votes

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}
user avatar
  • 21.7k
2 votes

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 (...
user avatar
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 ...
user avatar
  • 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 ...
user avatar
  • 8,185

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