|
|
|
|
|||||||||||||||||||||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Help with Cplex.
Hello ,
I need to check if this program in cplex is correct. There is a quadratic constraint. Cplex prints out the ERRR message. The code is : #include <ilcplex/ilocplex.h> ILSTLBEGIN typedef IloArray<IloNumVarArrayNumVarMatrix; int main() { IloEnv env; try { IloInt i, j; IloModel model(env); IloInt D = 4; IloInt M = 10; IloInt K = 2; IloNumVarArray d(env, D, 1, M-1,ILINT); IloNumVarArray b(env, M-1, 0, 1 ,ILINT); NumVarMatrix a(env, M-1); for(i = 0; i < M-1; i++) { a[i] = IloNumVarArray(env, D, 0, K, ILINT); } // Formulas for(i = 0; i < M-1; i++) { model.add( i+1 == a[i][0]*d[0] + a[i][1]*d[1] + a[i] [2]*d[2] +a[i][3]*d[3] ); } //Constraint for(i = 0; i < M-1; i++) { model.add(a[i][0] + a[i][1] +a[i][2] +a[i][3] <= K); } for(i = 0; i < M-1; i++) { model.add(b[i]<= a[i][0] + a[i][1] +a[i][2] +a[i][3]); } IloExpr obj(env); for(i = 0; i < M-1; i++) { obj = b[0] + b[1] + b[3] + b[4] + b[5] + b[6] + b[7] + b[8] + b[9] ; } model.add(IloMaximize(env, obj)); IloCplex cplex(env); cplex.extract(model); cplex.solve(); env.out() << " Solution: " << endl; env.out() << " " << Value() << endl; } catch(IloException& e) { cerr << "ERRR: " << e.getMessage() << endl; } catch () { cerr << "Error" << endl; } env.end(); return 0; } // END main |
![]() |
| Viewing: Web Development Archives > FAQs > Research > Help with Cplex. |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|