Decision Optimization

Decision Optimization

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

 View Only
Expand all | Collapse all

what's the difference between IloCplex() and cplex

  • 1.  what's the difference between IloCplex() and cplex

    Posted Fri September 18, 2015 10:55 AM

    Originally posted by: yipingfang


    Hello, guys, does anybody know what's the difference between the following two declaration codes:

     

    Part One:

    var masterDef = thisOplModel.modelDefinition;

    var masterData = thisOplModel.dataElements;

    var masterOpl = new IloOplModel(masterDef, cplex);

    masterOpl.addDataSource(masterData);

    masterOpl.generate();

    var subSource = new IloOplModelSource("sub_MP.mod");

    var subDef = new IloOplModelDefinition(subSource);

    var subData = new IloOplDataSource("test_subMP.dat");

    var subCplex = new IloCplex();

    var subOpl = new IloOplModel(subDef, subCplex);

    subOpl.addDataSource(subData);

    subOpl.generate();

     

    Part Two:

    var masterDef = thisOplModel.modelDefinition;

    var masterData = thisOplModel.dataElements;

    var masterOpl = new IloOplModel(masterDef, cplex);

    masterOpl.addDataSource(masterData);

    masterOpl.generate();

    var subSource = new IloOplModelSource("sub_MP.mod");

    var subDef = new IloOplModelDefinition(subSource);

    var subData = new IloOplDataSource("test_subMP.dat");

    var subOpl = new IloOplModel(subDef, cplex);

    subOpl.addDataSource(subData);

    subOpl.generate();

     

    The only difference is the definition of IloCplex() for subModel. I find that this difference can lead to completely different result. Is anyone know why? Thanks!


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 2.  Re: what's the difference between IloCplex() and cplex

    Posted Mon September 21, 2015 02:57 AM

    Hi

    they are two different instances of IloCplex class.

    cplex is the default one.

    Let me give you a small example:

    execute
    {
    cplex.tilim=20;
    }

    main
    {
    thisOplModel.generate();
    writeln("cplex.tilim=",cplex.tilim);
    var engine=new IloCplex();
    writeln("engine.tilim=",engine.tilim);
    writeln("cplex.tilim=",cplex.tilim);

    }

    gives

    cplex.tilim=20
    engine.tilim=9.999999999999999e+074
    cplex.tilim=20

    regards

     


    #DecisionOptimization
    #OPLusingCPLEXOptimizer