Decision Optimization

Decision Optimization

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


#Analytics
#DecisionOptimization
#DecisionOptimization
 View Only
Expand all | Collapse all

Initial MIP gap in CPLEX

  • 1.  Initial MIP gap in CPLEX

    Posted 07/17/19 12:49 PM

    Originally posted by: story_


    Hi,

    Is there a way to get the initial MIP gap (the first entry under Gap* in the log file)?

    Thanks.


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 2.  Re: Initial MIP gap in CPLEX Java API

    Posted 07/18/19 03:14 AM

    Hi,

    you could stop at first integer solution and ask for obj values.

    For instance if I use scalablewarehouse example, I can write

    int Fixed        = 10;
    int NbWarehouses = 50;
    int NbStores     = 200;

    assert( NbStores > NbWarehouses );

    range Warehouses = 1..NbWarehouses;
    range Stores     = 1..NbStores;
    int Capacity[w in Warehouses] =
      NbStores div NbWarehouses +
      w % ( NbStores div NbWarehouses );
    int SupplyCost[s in Stores][w in Warehouses] =
      1 + ( ( s + 10 * w ) % 100 );
    dvar int Open[Warehouses] in 0..1;
    dvar float Supply[Stores][Warehouses] in 0..1;
    dexpr int TotalFixedCost = sum( w in Warehouses ) Fixed * Open[w];
    dexpr float TotalSupplyCost = sum( w in Warehouses, s in Stores )  SupplyCost[s][w] * Supply[s][w];
    minimize TotalFixedCost + TotalSupplyCost;

    subject to {
      forall( s in Stores )
        ctStoreHasOneWarehouse:
          sum( w in Warehouses )
            Supply[s][w] == 1;
      forall( w in Warehouses )
        ctOpen:
          sum( s in Stores )
            Supply[s][w] <= Open[w] * Capacity[w];
    }

    main
    {
    thisOplModel.generate();
    cplex.intsollim=1;
    cplex.solve();
    writeln("objValue : ",cplex.getObjValue());
    writeln("bestObjValue : ",cplex.getBestObjValue());
    writeln("gap : ",(cplex.getObjValue()-cplex.getBestObjValue())/cplex.getObjValue());
    cplex.solve();

    }

     

    and get

     

    objValue : 1490
    bestObjValue : 1438.142857143
    gap : 0.034803452

    in the log I see

     

       Node  Left     Objective  IInf  Best Integer    Best Bound    ItCnt     Gap

          0     0     1438,1429     9     1490,0000       Cuts: 3      153    3,48%
          0     0     1438,1429    10     1490,0000      Cuts: 44      181    3,48%
    *     0+    0                         1480,0000     1438,1429             2,83%

    regards


    #DecisionOptimization
    #OPLusingCPLEXOptimizer