Categories

See More
Popular Forum

MBA (4887) B.Tech (1769) Engineering (1486) Class 12 (1030) Study Abroad (1004) Computer Science and Engineering (988) Business Management Studies (865) BBA (846) Diploma (746) CAT (651) B.Com (648) B.Sc (643) JEE Mains (618) Mechanical Engineering (574) Exam (525) India (462) Career (452) All Time Q&A (439) Mass Communication (427) BCA (417) Science (384) Computers & IT (Non-Engg) (383) Medicine & Health Sciences (381) Hotel Management (373) Civil Engineering (353) MCA (349) Tuteehub Top Questions (348) Distance (340) Colleges in India (334)
See More

Name 2D Variables CPLEX Concert Technology C++

General Tech Technology & Software

Max. 2000 characters
Replies

usr_profile.png

User

( 3 months ago )


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!

usr_profile.png

User

( 3 months ago )


I have often found it easiest to just do the naming in a separate loop over all the variables in an array, so something like (apologies for the approximate syntax):

for (i=0; i<M; i++)
    for (j=0; j<N; j++)
        X[i][j].setName(resourceName[i] + "_" + taskName[j]);

Obviously the setName() calls could be folded into the loop(s) where you actually create the variables if that is more convenient

But I never use the naming of the variables to convey useful information other than for my own debugging etc. I would usually walk over the variables in my code and use the values from CPLEX to decide what to draw in a user interface, create reports etc. based on the solution

what's your interest


forum_ban8_5d8c5fd7cf6f7.gif