ampl

AMPL: "Bad suffix .npool for Initial" error with poolstub


I need to find a pool of solutions with AMPL (I am relatively new to it) using the option "poolstub" but I get an error when I try to retrive them. I will try to explain everything step by step. This is my code:

option solver cplex;
model my_model.mod;
data my_data.dat;
option cplex_options 'poolstub=multmip poolcapacity=10 populate=1 poolintensity=4 poolreplace=1';
solve;

At this point AMPLE gives me this:

CPLEX 20.1.0.0: poolstub=multmip
poolcapacity=10
populate=1
poolintensity=4
poolreplace=1
CPLEX 20.1.0.0: optimal solution; objective 4.153846154
66 dual simplex iterations (0 in phase I)

It seems like AMPL has not stored the solutions in the pool. And in fact, if I try to retrive them with this code

for {i in 1..Current.npool} {
    solution ('multmip' & i & '.sol');
    display  _varname, _var;
}

I get this error:

Bad suffix .npool for Initial
context:  for {i in  >>> 1..Current.npool} <<<  {
Possible suffix values for Initial.suffix:
    astatus   exitcode   message   relax
    result    sstatus    stage  
for{...} { ? ampl: for{...} { ? ampl: 

I have no integer variables, only real ones and I read that CPLEX doesn't support the populate method for linear programs. Could this be the problem or is something else missing? Thank you in advance


Solution

  • You have identified your problem correctly. Entity Initial does not have the npool suffix, which means the solver (in your case CPLEX) did not return one.

    Gurobi can return that information for linear programs, but it seems to be identical to the optimal solution, so it would not give you any extra information (more info on AMPL-Gurobi options).

    Here is an example AMPL script:

    model net1.mod;                                                                 
    data net1.dat;                                                                  
                                                                                    
    option solver gurobi;                                                           
    option gurobi_options 'ams_stub=allopt ams_mode=1';              
    solve;                                                                          
                                                                                    
    for {n in 1..Total_Cost.npool} {                                                
       solution ("allopt" & n & ".sol");                                            
       display Ship;                                                                
    } 
    

    Output (on my machine):

    Gurobi 9.1.1: ams_stub=allopt
    ams_mode=2
    ams_epsabs=0.5
    Gurobi 9.1.1: optimal solution; objective 1819
    1 simplex iterations
    Alternative MIP solution 1, objective = 1819
    1 alternative MIP solutions written to "allopt1.sol"
    ... "allopt1.sol".
    Alternative solutions do not include dual variable values.
    Best solution is available in "allopt1.sol".
    
    suffix npool OUT;
    Alternative MIP solution 1, objective = 1819
    Ship :=
    NE   BOS    90
    NE   BWI    60
    NE   EWR   100
    PITT NE    250
    PITT SE    200
    SE   ATL    70
    SE   BWI    60
    SE   EWR    20
    SE   MCO    50
    ;
    

    The files net1.mod and net1.dat are from the AMPL book.

    When solving a MIP the solver can store sub-optimal solutions that it found along the way as they might be interesting for some reason to the modeler. In terms of your LP, are you interested in the vertices the simplex algorithm visits?