Decision Optimization

Decision Optimization

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


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

Column Generation - Artificial Slack Variables Problem

  • 1.  Column Generation - Artificial Slack Variables Problem

    Posted 11/05/14 01:35 PM

    Originally posted by: gorkemyencak


    Hi all,

    I have got a problem with column generation part. The problem in my code is the following. The size of A-Matrix, which was costructed to generate a feasible solution to my model, is a  (a+b) by (a) matrix. So the number of variables needs to be (a+b), but the code creates artificial slack variables, which I even do not know why and I try to get rid of those artificial variables in order to execute the column generation algorithm properly. Here is my code, I will skip unnecessary details as much as possible, but there must be a logical mistake relevant to those costructing arrays or public functions. I will appreciate any suggestions about my code..

    //define Cplex model
    IloEnv env;
    IloModel masterproblem(env);
     
    IloIntArray lhs(env, a+b);
    for (unsigned int i = 0; i<a+b; i++)
    {
    lhs[i] = 0;
    }
    IloIntArray rhs(env, a+b);
    for (unsigned int i = 0; i<a; i++)
    {
    rhs[i] = 1;
    }
     
    for (unsigned int i = a; i<a+b; i++)
    {
    rhs[i] = capacity*nb_of_gateways;
    }
    IloObjective  ObjectiveFunction = IloAdd(masterproblem, IloMaximize(env));
    IloRangeArray  A_matrix = IloAdd(masterproblem, IloRangeArray(env, 0, rhs));

    IloNumVarArray paths(env);

    for (int i = 0; i < Origin_Destination_Pair.size(); i++) {
    IloNumColumn column = ObjectiveFunction(saving*demand[i]*weight[i]);
    column += A_matrix[i](1);
    for(int k=1; k < Creating_Binary_Sub_Routes[i][j].size(); k++)
    {
    string temporary_gateway=Creating_Binary_Sub_Routes[i][j][k];
    unsigned int ind=temporary_gateway.find("'");
    string temporary_gateway2;
    if(ind<=4)
    {
    temporary_gateway2 = Creating_Binary_Sub_Routes[i][j][k-1].substr(0,3);
    int c=0;
    for(set<string>::iterator iterator=gateways.begin();iterator!=gateways.end();iterator++)
    {
    if(*iterator==temporary_gateway2)
    {
    column += A_matrix[Origin_Destination_Pair.size()+c](demand[i]*weight[i]);
    }
    c++;
    }
    }
    }
    IloNumVar var(column, 0, 1);
    paths.add(var);
    }
    IloCplex model(masterproblem);
    model.exportModel("RMP.lp");
    model.solve();
    IloNumArray dual_variables(env,Origin_Destination_Pair.size()+b);
    model.getSlacks(dual_variables,A_matrix);
    IloNumArray t(env,Origin_Destination_Pair.size());
    IloNumArray w(env,b);
     
    for(int y=0; y<Origin_Destination_Pair.size(); y++)
    {
    t[y]=dual_variables[y];
    }
    for(int y=0; y<b; y++)
    {
    w[y]=dual_variables[y+a];
    }

    #CPLEXOptimizers
    #DecisionOptimization


  • 2.  Re: Column Generation - Artificial Slack Variables Problem

    Posted 11/10/14 02:44 AM

    Could you detail what/where those unexpected slack variables are?


    #CPLEXOptimizers
    #DecisionOptimization