# Naming variables in Cplex (concert Api c++)

 2 Hi, Im adding variables to a problem using IloNumVarArrays, i.e. IloNumVarArray x(env); x.add(IloNumVar);  when I use the cplex.exportModel("solver.lp") to write to file all the variables are named id### in the resulting lp file. Is there any way I can get the x variables to be called x1,x2,x3... in the lp file? asked 30 Sep '10, 12:17 Buxley 564●1●6●14 accept rate: 9%

 7 I think it depends on which constructor definition of IloNumVar you are using, when u are defining the variable. You can use the following to state the name explicitly.  IloNumVar(const IloEnv env, IloNum lb=0, IloNum ub=IloInfinity, IloNumVar::Type type=Float, const char * name=0)  or If you are using cplex.numVar method, you can use the definition like in the following example,  IloNumVar x = cplex.numVar(lb, ub, IloNumVarType.Float, "xname");  answered 30 Sep '10, 15:21 Venky 768●1●2●19 accept rate: 15% Thanks, this has been bugging me for months... (01 Oct '10, 07:12) Buxley Is there a way to name them using a for loop and the setname method? (01 Oct '10, 15:15) Berk Ustun 1 Yes you can. Check the below link, [in the purpose column, check for "Changes name of a variable or constraint"] http://publib.boulder.ibm.com/infocenter/cosinfoc/v12r2/index.jsp?topic=/ilog.odms.cplex.help/Content/Optimization/Documentation/CPLEX/_pubskel/CPLEX1093.html (01 Oct '10, 18:43) Venky
 4 Just if somebody else wants to name them using a for loop, here is one example! IloBoolVarArray x(env); IloNumVarArray s(env); int i; char VarName[24]; for(i= 0; i
 toggle preview community wiki

By Email:

Markdown Basics

• *italic* or _italic_
• **bold** or __bold__
• image?![alt text](/path/img.jpg "Title")
• numbered list: 1. Foo 2. Bar
• to add a line break simply add two spaces to where you would like the new line to be.
• basic HTML tags are also supported

Tags:

×191