Hot answers tagged

10

One problem you might encounter is that the many solvers are either not available for M1 like CPLEX[1] or at best experimental like Gurobi[2] so i doubt there will be any guarantees for correctness. Apple support for Gurobi might be mixed in general due to issue like "Only use single-threaded BLAS on Mac to avoid overshooting the thread limit" [3] ...


7

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 should be param filename symbolic := "instance.txt"; Then you can use the string expression ("output" & filename) to specify a file that receives the output from a ...


6

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 limited to the vehicle's capacity. When dealing with constraints linked to time, you need an extra resource for this. Each of these resources can be delt with ...


6

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: print k > (OutputFile); This deletes the file and then opens a new, empty file with the same name. Note that once the file is open, > and >> both append to it. A complete description of ...


5

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


4

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


3

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, j) combinations (which is what your example here would do if it worked). You might want to look at Chapter 12 of the AMPL book, which discusses various ways ...


1

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 take effective in the 'solve' process while the second explicit way works.


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