Decision Optimization

Decision Optimization

Delivers prescriptive analytics capabilities and decision intelligence to improve decision-making.


#Analytics
#DecisionOptimization
#DecisionOptimization
 View Only

Memory problems with warm start in a flow control script

  • 1.  Memory problems with warm start in a flow control script

    Posted 05/04/12 05:28 PM

    Originally posted by: SystemAdmin


    Hi All,

    I am trying to solve a MIP model once, save its vectors to use as a warm start, then modify some problem data and solve it again. I implemented this using a flow control script, based on the warmstart example. I am running into memory problems when trying to solve the second model: the warm start succeeds but pre solve fails due to an out of memory error. This is particularly strange because this exact problem solves without any memory issues when I run it without a flow control script. I wondered if the problem was a memory management issue, and I am using end() (with mainEndEnabled() on) as often as I can, but this has not changed the memory problem, so either I am not doing this properly or memory management is not the issue. I have included a sample of the code below. Ideas would be very much appreciated!

    Thanks!

    main {

    // get an instance of the main data file
    var mainDataFile = new IloOplDataSource("Data_form6_data9.dat");

    // create a new scalar data element and add data for first run
    var newScalarData = new IloOplDataElements();
    newScalarData.TotalWtDelivered_PrevIter = 2046; // add the value for the first iteration

    // create a new model for the first run, and add the data
    var myOriginalModelDef = thisOplModel.modelDefinition; // get the definition of the existing model
    var model1 = new IloOplModel(myOriginalModelDef,cplex); // create a new model
    model1.addDataSource(mainDataFile); // add data
    model1.addDataSource(newScalarData);

    // solve the model
    model1.generate();
    model1.settings.mainEndEnabled = true;
    if ( cplex.solve() ) {
    writeln("Running with D' = ",model1.TotalWtDelivered_PrevIter);
    writeln("OBJECTIVE: ",cplex.getObjValue());
    writeln("Status: ",cplex.getCplexStatus()," (101=optimal,102=opt in tol)");
    }
    else {
    writeln("No solution!");
    //break;
    }

    // save vectors for warm start
    var vectors = new IloOplCplexVectors();
    if ( vectors.getVectors(cplex) ) {
    writeln();
    writeln("warm start preparation successful");
    } else {
    writeln("warm start preparation unsuccessful: ",vectors.status);
    }

    // update the value for the second run
    newScalarData.TotalWtDelivered_PrevIter = model1.TotalWtDelivered

    // create a new model to use and add the data
    var myNewModel = new IloOplModel(myOriginalModelDef,cplex); // automatically starts from previous basis?
    myNewModel.addDataSource(mainDataFile);
    myNewModel.addDataSource(newScalarData);

    // end the old model
    model1.end();

    // generate new model
    myNewModel.generate();

    // try to use warm start
    if( vectors.setVectors(cplex) ) {
    writeln("warm start ",vectors.Nrows,"x",vectors.Ncols," succeeded ");
    } else {
    writeln("warm start ",vectors.Nrows,"x",vectors.Ncols," failed: ",vectors.status);
    }

    // end the vectors
    vectors.end();

    // solve new model
    if ( cplex.solve() ) {
    writeln("OBJECTIVE: ",currentObjective);
    myNewModel.postProcess();
    }
    else {
    writeln("No solution!");
    //break;
    }

    myNewModel.end();
    newScalarData.end();
    mainDataFile.end();
    cplex.end();
    }
    #DecisionOptimization
    #OPLusingCPLEXOptimizer