Originally posted by: khan49
Hi Alex!
Thanks for the reply , Basically I am writing my code using C++ concert technology . While doing different experiments I found out that the value of variable can only be changed only one time using the engine variables corresponding to a decision variable.
so then I thought there might be some way by using which I can remove a constraint and add a new constraint without extracting the whole model again and again by using the engine constraint .
IloModel mod(env);
// 1D Array of Variables
IloNumVarArray B(env,Nblocks,0,1, ILOINT);
IloExpr total_blocks(env);
int i = 0;
for(InputIterator current = start; current!= end ; current ++,i++){
total_blocks += B[i]*BLOCK_TONNAGE;
}
mod.add(total_blocks <= upper_limmit);
mod.add(total_blocks >= lower_limmit);
// Slope Constraint
for(int i = 0; i<Nblocks;i++){
for(int j = 0; j < max_successor ; j++){
if((Pre_deccessor_Matrix [i][j]!= -1)){
mod.add(B[i] - B[j] <= 0);
}
}
}
IloCP cp(env);
cp.extract(mod);
cp.setParameter(IloCP::LogVerbosity, IloCP::Quiet);
int sol = 0;
int t = 1;
cp.startNewSearch();
while(cp.next() && sol < N_Solutions && t < 3){
for(int i = 0; i<Nblocks; i++){
if (cp.getValue(B[i])>0){
initial_solutions[sol][i] = t;
(cp.getIntVar(B[i])).setValue(1);
}
}
t++;
}
after getting each solution I want to modify the RHS of capacity constraints to accommodate the variables already fixed to 1.
Kindly let me know if there is any way to change the value of a variable multiple time using the engine variable if not
is there any procedure to delete a constraint or modify it using IlcConstraint .
Kind regards
#CPOptimizer#DecisionOptimization