Originally posted by: MarcosThomaz
Ok... this is my code:
#include "ilcplex/cplex.h"
#include "ilcplex/ilocplex.h"
ILOSTLBEGIN
using namespace std;
int main(){
char *filename = "myfile.txt";
ifstream fin(filename);
IloInt n, i;
if (!fin.is_open())
exit(1);
fin >> n;
IloEnv env;
try{
IloModel model(env);
IloIntArray ciw(env, n), cip(env, n), cid(env, n);
for (i = 0; i < n; i++){
fin >> cip[i];
}
for (i = 0; i < n; i++){
fin >> ciw[i];
}
for (i = 0; i < n; i++){
fin >> cid[i];
}
fin.close();
IloIntervalVarArray interv(env, n);
for (i = 0; i < n; ++i){
interv[i] = IloIntervalVar(env, cip[i]);
}
IloIntervalSequenceVar seq(env, interv);
IloIntExpr f(env);
for (i = 0; i < n; i++){
f += IloMax(0, (IloEndOf(interv[i]) - cid[i])) * ciw[i];
}
IloNum ob = 0;
IloObjective obj = IloMinimize(env, f);
model.add(obj);
model.add(IloNoOverlap(env, seq));
IloCplex cplex(model);
cplex.solve();
cout << cplex.getObjValue() << endl;
}
catch (IloAlgorithm::CannotExtractException& e)
{
std::cerr <<
"CannoExtractException: " << e << std::endl; IloExtractableArray failed = e.getExtractables();
for (IloInt i = 0; i < failed.getSize() && i<10; ++i) std::cerr <<
"\t" << failed[i] << std::endl;
}
catch (IloException& ex) {
env.out() << "Error CPLEX: " << ex << std::endl;
}
catch (...){
cerr << Other Error!" << endl;
}
env.end();
getch();
return 0;
}
The myfile.txt is:
10
99 100 93 85 15 97 47 38 29 35
2 2 8 4 8 9 7 7 3 7
382 155 444 127 332 562 375 663 699 252
This instance has the number of jobs, processing time (for each job, line 2), weight (for each job) and due date (for each job).
The complete log error is:
CannoExtractException: IloAlgorithm cannot extract extractables 54, 14, 18, 22, 26, 30, 34, 38, 42, 46, 50, 56 and 56
obj54 = (max(IloEndOf(14)[IloIntervalVar(1)[1: 0..1073741822 -- (99)0..1073741822 --> -1073741822..1073741822]:0] + -382 , 0) * 2 + max(IloEndOf(18)[IloIntervalVar(3)[1: 0..1073741822 -- (100)0..1073741822 --> -1073741822..1073741822]:0] + -155 , 0) * 2 + max(IloEndOf(22)[IloIntervalVar(4)[1: 0..1073741822 -- (93)0..1073741822 --> -1073741822..1073741822]:0] + -444 , 0) * 8 + max(IloEndOf(26)[IloIntervalVar(5)[1: 0..1073741822 -- (85)0..1073741822 --> -1073741822..1073741822]:0] + -127 , 0) * 4 + max(IloEndOf(30)[IloIntervalVar(6)[1: 0..1073741822 -- (15)0..1073741822 --> -1073741822..1073741822]:0] + -332 , 0) * 8 + max(IloEndOf(34)[IloIntervalVar(7)[1: 0..1073741822 -- (97)0..1073741822 --> -1073741822..1073741822]:0] + -562 , 0) * 9 + max(IloEndOf(38)[IloIntervalVar(8)[1: 0..1073741822 -- (47)0..1073741822 --> -1073741822..1073741822]:0] + -375 , 0) * 7 + max(IloEndOf(42)[IloIntervalVar(9)[1: 0..1073741822 -- (38)0..1073741822 --> -1073741822..1073741822]:0] + -663 , 0) * 7 + max(IloEndOf(46)[IloIntervalVar(10)[1: 0..1073741822 -- (29)0..1073741822 --> -1073741822..1073741822]:0] + -699 , 0) * 3 + max(IloEndOf(50)[IloIntervalVar(11)[1: 0..1073741822 -- (35)0..1073741822 --> -1073741822..1073741822]:0] + -252 , 0) * 7, IloObjective, Minimize);
IloEndOf(14)[IloIntervalVar(1)[1: 0..1073741822 -- (99)0..1073741822 --> -1073741822..1073741822]:0]
IloEndOf(18)[IloIntervalVar(3)[1: 0..1073741822 -- (100)0..1073741822 --> -1073741822..1073741822]:0]
IloEndOf(22)[IloIntervalVar(4)[1: 0..1073741822 -- (93)0..1073741822 --> -1073741822..1073741822]:0]
IloEndOf(26)[IloIntervalVar(5)[1: 0..1073741822 -- (85)0..1073741822 --> -1073741822..1073741822]:0]
IloEndOf(30)[IloIntervalVar(6)[1: 0..1073741822 -- (15)0..1073741822 --> -1073741822..1073741822]:0]
IloEndOf(34)[IloIntervalVar(7)[1: 0..1073741822 -- (97)0..1073741822 --> -1073741822..1073741822]:0]
IloEndOf(38)[IloIntervalVar(8)[1: 0..1073741822 -- (47)0..1073741822 --> -1073741822..1073741822]:0]
IloEndOf(42)[IloIntervalVar(9)[1: 0..1073741822 -- (38)0..1073741822 --> -1073741822..1073741822]:0]
IloEndOf(46)[IloIntervalVar(10)[1: 0..1073741822 -- (29)0..1073741822 --> -1073741822..1073741822]:0]
#DecisionOptimization#OPLusingCPOptimizer