Research
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
Go Back   Web Development Archives FAQs Research

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Web Development Archives Sponsor:
  #1  
Old July 19th, 2008, 08:40 AM
arush
Guest
Dev Archives Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
HELP.

Hello ,
I need to check if this program in cplex is correct. There is a
quadratic constraint. CPLEX prints out the ERRR message after
execution.

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);
}

// Formula

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


Reply With Quote
Reply

Viewing: Web Development Archives FAQs Research > HELP.


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are Off
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2009 by Developer Shed. All rights reserved. DS Cluster 2 Hosted by Hostway
For more Enterprise Application Development news, visit eWeek