Originally posted by: sanchit_singh
In the code below, the line in the bold, represents clear cut violation of integer bounds for x4 variable, logically status returned should have been infeasible, but if you compile the code, x4 takes value as 3!! Can someone explain how are these arguments processed in CPLEX, and what is the make sure way of enforcing cplex to stricltly take care of fractional bounds!
// -------------------------------------------------------------- -*- C++ -*-
// File: ilomipex1.cpp
// Version 12.5
// --------------------------------------------------------------------------
// Licensed Materials - Property of IBM
// 5725-A06 5725-A29 5724-Y48 5724-Y49 5724-Y54 5724-Y55 5655-Y21
// Copyright IBM Corporation 2000, 2012. All Rights Reserved.
//
// US Government Users Restricted Rights - Use, duplication or
// disclosure restricted by GSA ADP Schedule Contract with
// IBM Corp.
// --------------------------------------------------------------------------
//
// ilomipex1.cpp - Entering and optimizing a MIP problem
#include <ilcplex/ilocplex.h>
ILOSTLBEGIN
static void
populatebyrow(IloModel model, IloNumVarArray var, IloRangeArray con);
int
main (void) {
IloEnv env;
try {
IloModel model(env);
IloNumVarArray var(env);
IloRangeArray con(env);
populatebyrow (model, var, con);
IloCplex cplex(model);
cplex.solve();
env.out() << "Solution status = " << cplex.getStatus() << endl;
env.out() << "Solution value = " << cplex.getObjValue() << endl;
IloNumArray vals(env);
cplex.getValues(vals, var);
env.out() << "Values = " << vals << endl;
cplex.getSlacks(vals, con);
env.out() << "Slacks = " << vals << endl;
cplex.exportModel("mipex1.lp");
}
catch (IloException& e) {
cerr << "Concert exception caught: " << e << endl;
}
catch (...) {
cerr << "Unknown exception caught" << endl;
}
env.end();
getchar();
return 0;
} // END main
static void
populatebyrow (IloModel model, IloNumVarArray x, IloRangeArray c)
{
IloEnv env = model.getEnv();
x.add(IloNumVar(env, 0.0, 40.0));
x.add(IloNumVar(env));
x.add(IloNumVar(env));
x.add(IloNumVar(env, 2.3, 2.4, ILOINT));
model.add(IloMaximize(env, x[0] + 2 * x[1] + 3 * x[2] + x[3]));
c.add( - x[0] + x[1] + x[2] + 10 * x[3] <= 20);
c.add( x[0] - 3 * x[1] + x[2] <= 30);
c.add( x[1] - 3.5* x[3] == 0);
model.add(c);
} // END populatebyrow
#CPLEXOptimizers#DecisionOptimization