Originally posted by: SystemAdmin
[sharangi said:]
Hi All,
I need some guidance in implementing Lagrangian Relaxation using CPLEX.
I am using CPLEX 9 with java(Concert) on a x86_64 platform.
For a given model I'll like to do the following:
//1. copy locally constraint C from model and delete it from the model
//2. get objective function from model
//3. construct new objective function by doing new_obj = old_obj - U*C here u is a vector of lagrange multipliers
//4. replace the old obj function in the model with the new one
I am struck at step 3. I have the objective function as an IloNumExpr. but my U and C are both in array form.
Now I need some way of converting IloNumExpr to array and back. Could not find any API for this.
Following is the code snippet:
=====================================================================
////1. copy locally constraint C from model and delete it from the model
IloLPMatrix mat = (IloLPMatrix)cplex.LPMatrixIterator().next();
mat.getRows(start, num,lb,ub,ind,val);
mat.removeRows(24,76);
////2. get objective function from model
IloNumExpr old_obj = cplex.getObjective().getExpr();
//TODO: 3.dualize the constraint. Struck here
////4.replace the old obj function in the model with the new one
cplex.delete(old_obj);
cplex.addMinimize(new_obj);
=====================================================================
Please help.
#CPLEXOptimizers#DecisionOptimization