#include //t
#include
#include
#include
#include
#include //vs03fstream、iostreamh,using namespace std;
using namespace std;
ILOSTLBEGIN
typedef IloArray BoolVarMatrix;
typedef IloArray NumVarMatrix;
typedef IloArray NumVarMatrix3;
typedef IloArray NumVarMatrix4;
typedef IloArray NumVarMatrix5;
class Data{
public:
int T,M,A,B,V,CD,C;
int d[2][10];//ai
int dw[2][10];//bi
int asp[2][10];//ai
int tA[10][10];//ij
int vsp[2][10];//vi
int P[2];//a
int Pw[2];//b
int wa[2];//a
int wb;//b
int cap[2];//v
};
int main (int argc, char **argv)
{
IloInt i,j,a,v,b,q=0;
IloInt an,bn,vn,cn;
int I,II,III,IIII;
an=2;bn=2;vn=2;cn=10;
IloNumExpr z=NULL,x1=NULL,y1=NULL,z1=NULL;//obj1=NULL,obj2=NULL,obj;
IloEnv env;
Data data;
ifstream infile1("single.txt");//txt。
infile1>>data.T>>data.A>>data.B>>data.V>>data.CD>>data.C;// 6
infile1.close();
ifstream infile2("invendem.txt");//
for(a=0; a>data.d[a][i];}}//ai
infile2.close();
ifstream infile3("woundem.txt");//
for(b=0; b>data.dw[b][i];}}//bit
infile3.close();
ifstream infile4("number.txt");//、、
for(a=0; a>data.asp[a][i];}}
for(v=0; v>data.vsp[v][i];}}
for(i=0; i>data.tA[i][j];}}
infile4.close();
ifstream infile5("weight.txt");//、、V
for(a=0; a>data.P[a];
for(b=0; b>data.Pw[b];
for(a=0; a>data.wa[a];
infile5>>data.wb;//kg
for(v=0; v>data.cap[v];
infile5.close();
IloNumVarArray dew(env,bn);
dew=IloNumVarArray(env,bn,0,IloInfinity);
NumVarMatrix dev(env,an);
for(I=0;Itm_year + 1900,
t->tm_mon + 1,
t->tm_mday,
t->tm_hour,
t->tm_min,
t->tm_sec);
try {
IloModel model(env);
// the capacity variable of the warehouse. model.add(IloSum(assignVars[w]) == capVars[w]);
// for(i = 0; i =y1,IloInfinity);
model.add(temp_range4);}//
x1=0;y1=0;z1=0;
for(i=0;i=y1+z1,IloInfinity);
model.add(temp_range7);}}//
for(i=0; i for(v=0;v x1=0;y1=0;z1=0;
for(j=0; j x1 += ( Z[i][j][v]-Z[j][i][v]);}
IloRange temp_range8(env,x1<=data.vsp[v][i],IloInfinity);
model.add(temp_range8);}}//
x1=0;y1=0;z1=0;
for(a=0; a for(i=0; i env.out()< IloCplex cplex(model);
cplex.extract(model);
cplex.setParam(IloCplex::MIPEmphasis, 1);//,
cplex.solve();
if (cplex.getStatus() == IloAlgorithm::Infeasible)
env.out() << "No Solution" << endl;
// Print results
env.out() << "MIN unsatisfied:" << cplex.getObjValue() << endl;
for(b=0;b env.out()<
for(b=0;b for(i=0; i for(v=0;v for(j=0; j env.out()<< "("<}//try{
catch (IloException ex) {
cerr << "Error: " << ex << endl;
}
catch (...) {
cerr << "Error" << endl;
}
env.end();
system ("PAUSE");
return 0;
}