Problem when generating .sol files

Hi!

I’m running some MILP problems in AMPL, using cplex as solver. For some reason my write commands do not properly work, generating only the .nl file but without any associated .sol file. It’s weird because this doesn’t happen for another model of mine which is almost an exact copy of the current one, although the instances I’m solving in that one are trivial (they finish running in seconds), so maybe this has to do something with the size of the problem instance state?

In case it helps, I’m pasting below the commands I execute from the command line:

reset;
model /somepath/somemodel.mod;
data ‘/somepath/output_1.data’;
option solver cplex;
option cplex_options ‘mipdisplay=1 mipgap=0.1 absmipgap=0.1’;
write g/somepath/output_1_6;
solve;

The only thing I get, even after the run is finished, is the .nl file at the directory specified in the write command. I have also tried the write command without a path (so it’s relative to the current directory), and using the b flag instead of g, to no avail (same results, it only generates the .nl file).

Does anyone know what might be amiss, or how could I research this further?

Many thanks!

1 Like

The write command creates the .nl file when you give the solve command. But the solver creates the .sol file — containing the best solution it found — only after it has finished its computations. So the usual reason you do not see a .sol file is that the solver algorithm failed to find any solution at all.

Thus the first thing I would check is whether CPLEX reported finding an optimal solution. If it didn’t, then that would explain why there was no .sol file. If it did, then to get more help, change the option to mipdisplay=2, run again, and post all of CPLEX’s output here.

1 Like

In the instances I have run, CPLEX did find an optimal solution. Interestingly enough, as soon as I increased mipdisplay to 2, following your suggestion, a .sol file was generated! This makes very little sense to me, but I’ll run my other instances to double-check it is working in general.

Many thanks! :slight_smile:

Seems it was just a fortunate coincidence, because .sol files are no longer being generated anymore :confused:

As suggested I’m attaching here all of CPLEX’s output for the run that didn’t generate a .sol file (couldn’t paste it here due to a character limit in posts, and had to zip it due to a limitation of the types to upload)

Another thing I did, in this case, was to set some parameters using let, before running solve. Doesn’t sound like it has anything to do with the issue, but mentioning just in case. All of the commands I ran can also be found in the attached file.

outputampl.zip (10.2 KB)

This does appear to be a run that found a solution:

CPLEX 22.1.1.0: optimal (non-)integer solution; objective 350.90175
3056775 MIP simplex iterations
105110 branch-and-bound nodes
256 integer variables rounded (maxerr = 5.50169e-08).

There were 256 integer variables whose values in the solution were slightly non-integer, by as much as 5.50169e-08. But since the deviation of these variables from integrality was less than the default integrality tolerance of 1e-05, these variables were simply rounded to integer values.

The next step of troubleshooting would be to see whether CPLEX is returning a solution to AMPL. After the CPLEX solve is finished and the ampl prompt returns, use AMPL’s display command to check whether a nontrivial solution was returned. You can use display to show the values of any of the variables; also try displaying the objective function to see whether it is 350.90175 as CPLEX reports. (The default for display is 6 significant digits, so you will see 350.902.)

If a solution did get returned to AMPL, then a .sol file had to be written somewhere, since that is the only way that solvers return solutions to AMPL. In that case, can you share your whole AMPL session output, or your run file?

If a solution did not get returned to AMPL, then it will be necessary to look for something that’s wrong in the CPLEX interface. In that case, it will be helpful to see the output from your display of the objective function and a few of the variables.