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 ...
worldsmithhelper's user avatar
10 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 ...
Nikos Kazazakis's 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 ...
ErlingMOSEK's user avatar
  • 3,046
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 ...
4er's user avatar
  • 618
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 ...
prubin's user avatar
  • 37.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 ...
Kuifje's user avatar
  • 12.9k
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: ...
4er's user avatar
  • 618
5 votes
Accepted

Overwrite on a txt file from AMPL

This should overwrite : k > (OutputFile); While this appends : k >> (OutputFile);
Kuifje's user avatar
  • 12.9k
5 votes

Handy way to index set of tuples in AMPL

Try sum{(i,j) in ARCS} blablabla[i,j]
RobPratt's user avatar
  • 30.3k
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 ...
LarrySnyder610's user avatar
5 votes
Accepted

Unexpected runtime error

I don't think you want ==> here, since Free_Day[p,d] = 1 ==> Free_Day[p,next(d,Days)] = 1 is satisfied anytime ...
4er's user avatar
  • 618
4 votes
Accepted

Issue interpreting sets of constraints in AMPL

...
Oguz Toragay's user avatar
  • 8,622
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 ...
hakank's user avatar
  • 914
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. ...
Marcus Ritt's user avatar
  • 2,705
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 ...
Nikos Kazazakis's 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: ...
4er's user avatar
  • 618
4 votes
Accepted

it is possible to have a constraint that does not contain any decision variables

Constraints define your feasibility region; bounds your search space. A constraint with no dv (decision or optimization variable) simply becomes a testing condition. If parameter value satisfies the ...
Sutanu Majumdar's user avatar
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,...
prubin's user avatar
  • 37.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 ...
ooo's user avatar
  • 1,589
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 ...
Oguz Toragay's user avatar
  • 8,622
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 ...
GB supports the mod strike's 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 ...
Oguz Toragay's user avatar
  • 8,622
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 ...
Nikos Kazazakis's 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: ...
Oguz Toragay's user avatar
  • 8,622
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. <...
RobPratt's user avatar
  • 30.3k
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) \...
RobPratt's user avatar
  • 30.3k
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 ...
prubin's user avatar
  • 37.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 ...
GB supports the mod strike's user avatar
3 votes
Accepted

Constrained shift assignment problem using ilogcp solver can´t find an optimal solution

There's an experimental version of "Gurobi for AMPL" that should accept your constraint DL just as you have written it. It uses AMPL's new "MP" ...
4er's user avatar
  • 618
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}
RobPratt's user avatar
  • 30.3k

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