Decision Optimization

Decision Optimization

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


#Analytics
#DecisionOptimization
#DecisionOptimization
 View Only
  • 1.  Name 2D Variables [Concert Technology C++]

    Posted 09/12/14 07:27 PM

    Originally posted by: rNeo


    Hello, I have a straightforward (I hope) issue that I have been grappling with all day. I am trying to name a 2D decision variable in C++ using concert technology. My model is a real life assignment problem - so I need to index my variables with the actual resource and task names in order to provide the solution to the decision makers. This is easy with OPL using tuples. However, I am confused with concert technology. I have 2 decision variables (a) a 2D variable boolean variable that indicates which resource has been assigned to which task, and (b) a 1D boolean indicator variable that indicates if a particular resource has been selected in the assignment solution.

    It has been straightforward to name the 1D variable. I have the following Map which holds the name of the resources and their experience levels. I use this Map to iterate the variable and name it as follows:

    map<string, string> Map;       // The first string holds the name and the second string the experience level

    IloNumVarArray Y(env);       // My 1D variable
     
    map<string, string>::iterator Name;      // Iterator for the Map

     

    for (Name = Map.begin(); Name != Map.end(); Name++)
    {
                    string getName = Name->first;
                    char convertedName[100];
                    strcpy_s(convertedName, getName.c_str());

                   Y.add(IloNumVar(env, 0, 1, ILOINT, convertedName));

    }

    So how do I do the following for the 2D variable. It is of the form Xij where i is the Resource Name and j is the Task Name. I have declared the variable as follows:

    IloArray<IloNumVarArray> X;

    I have another Map which indicates the fit between i & j. It is:

    Map<string, map<string, float>> fitMap; //first string is the resource name, second string is the task name and the float is the fit value.

    Any ideas will be very appreciated!


    #CPLEXOptimizers
    #DecisionOptimization


  • 2.  Re: Name 2D Variables [Concert Technology C++]

    Posted 09/15/14 02:35 AM

    Something like this should do the trick:

    for (map<string,map<string,float> >::const_iterator it = fitMap.being(); it != fitMap.end(); ++it) {
       IloNumVarArray tmp(env);
       X.add(tmp);
       for (map<string,float>::const_iterator jt = it->second.begin(); jt != it->second.end(); ++jt) {
          char convertedName[...];
          // Create the convertedName
          ...
          tmp.add(IloNumVar(env, 0, 1, ILOINT, convertedName));
       }
    }

    Also note that the instantiation of X in your code lacks an 'env' argument. It should be

    IloArray<IloNumVarArray> X(env);

     


    #CPLEXOptimizers
    #DecisionOptimization


  • 3.  Re: Name 2D Variables [Concert Technology C++]

    Posted 09/22/14 11:57 AM

    Originally posted by: rNeo


    Thank you very much, Daniel! My apologies for the late reply. I tried it out and it works perfectly. Thanks again!


    #CPLEXOptimizers
    #DecisionOptimization