Decision Optimization

Decision Optimization

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

 View Only
  • 1.  Sensitivity Analyis for MILP model in C++

    Posted Tue October 25, 2022 06:19 AM
    Hello everyone, 
    I have coded  my MILP model in Visual studio c++ and solving it by calling cplex. Now, I would like to perform a sensitivity analysis but I could not understand exact syntax that I need to use. In the documents of cplex I found that :

    They are analyzed by methods IloCplex::getBoundSA,
    IloCplex::getRHSSA, and IloCplex::getObjSA, respectively.

    However, I could not understand how to do that. Is there any obvious example for cplex,  as gurobi provided in the following link ? 
    Thank  you so much for all your help in advance 


    sensitivity_c++.cpp
    Gurobi remove preview
    sensitivity_c++.cpp
    Copyright 2022, Gurobi Optimization, LLC // A simple sensitivity analysis example which reads a MIP model from a // file and solves it. Then uses the scenario feature to analyze the impact // w.r.t. the objective function of each binary variable if it is set to // 1-X, where X is its value in the optimal solution.
    View this on Gurobi >



    ------------------------------
    milena kafka
    ------------------------------

    #DecisionOptimization


  • 2.  RE: Sensitivity Analyis for MILP model in C++

    Posted Wed October 26, 2022 07:43 AM
    Hi,

    small example at https://community.ibm.com/community/user/datascience/discussion/question-about-sensitivity-analysis-with-cplex

    regards

    ------------------------------
    [Alex] [Fleischer]
    [Data and AI Technical Sales]
    [IBM]
    ------------------------------



  • 3.  RE: Sensitivity Analyis for MILP model in C++

    Posted Thu October 27, 2022 06:34 PM
    Thank you so much Alex for your quick response.
    Actually, I had seen that post but I have  really a problem with syntax. For example I have variable like this:

    O,P,Per,M are constant values . 

    char varName[1000];
    NumVar3Matrix X(env, P);
    for (IloInt i = 0; i < P; i++) {
    X[i] = NumVarMatrix(env, M);
    for (IloInt j = 0; j < M; j++) {
    X[i][j] = IloNumVarArray(env, Per);
    for (IloInt k = 0; k < Per; k++) {
    X[i][j][k] = IloNumVar(env, 0.0, INFINITY, ILOFLOAT);
    X[i][j][k].setName(varName);
    }
    }


    and other variable

    char varNameS[100];
    NumVarMatrix S(env,O);
    for (IloInt o = 0; o < O; ++o) {
    S[o] = IloNumVarArray(env,Per, 0, 1, ILOINT);
    for (IloInt t = 0; t < Per; t++) {
    S[o][t].setName(varNameS);
    }
    }
    I have model here
    ...
    ...
    ...

    and finally I solve it by :
    IloCplex cplex(env);
    cplex.extract(model);
    cplex.solve()
    There is no problem until here, when I want to perform sensitivity analysis for variable X or S ,as in the post , I say 
    IloNumArray objLB(env);
    IloNumArray objUB(env);
    cplex.getObjSA(objLB, objUB, X);
     and I debug and I receive an error:

    Erreur C2664 'void IloCplex::getObjSA(IloNumArray,IloNumArray,const IloIntVarArray) const' : impossible de convertir l'argument 3 de 'NumVar3Matrix' en 'const IloNumVarArray' 

    What can I correct it to perform SA for those variables ? 
    Thank you so much 


    ------------------------------
    milena kafka
    ------------------------------



  • 4.  RE: Sensitivity Analyis for MILP model in C++

    Posted Tue November 01, 2022 02:47 PM
    You need to flatten X into a one-dimensional array XX and use that as the same argument. So if X is P x M x Per than XX will be a vector (IloNumVarArray) of dimension P*M*Per, and the arrays (vectors) objLB and objUB will have dimension P*M*Per when returned. (I have no idea why the error message refers to the third argument as IloIntVarArray rather than IloNumVarArray, which is what it should be expecting.)

    ------------------------------
    Paul Rubin
    Professor Emeritus
    Michigan State University
    ------------------------------