Hi,
I'm using c++ api for cplex, and I have a function:
void build_model(IloEnv &env, IloModel &model, IloCplex &cplex, int nships) {
int i;
IloNumVarArray waiting(env, nships);
for(i = 0; i < nships; ++i)
{
sprintf(_name, "%s_%03d", "w", i + 1);
wait_variable[i] = IloNumVar(env, 0, 1, ILOINT, _name);
}
objective_function = IloSum(wait_variable);
for(i = 0; i < nships; ++i)
{
objective_function += sbta.get_rejection_cost() * sbta.service_time(i) * (1 - served_variable[i]);
}
model.add(IloObjective(IloMinimize(env, objective_function, "obj")));
}
}
Another function is calling it:
#include <ilcplex/ilocplex.h>
int main()
{
// Initialize cplex environment
int nships = 10;
IloEnv env;
IloModel model(env);
IloCplex cplex(env);
// Build generic model
build_model(env, model, cplex, nships);
// Customize the model
exit(1);
}
I want to modify the model in main function:
How can I define a new objective function?
If build_model includes a constraint in the model "wait_3" how can I delete it in main function.
Thanks, in advance.
#AI and DS Skills
#Decision Optimization
------------------------------
Manuel Munoz-Marquez
------------------------------