-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmodelePartiel.h
135 lines (91 loc) · 2.95 KB
/
modelePartiel.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
#pragma once
#include <ilopl/iloopl.h>
#include <vector>
#include <map>
#include "types.h"
typedef IloArray<IloNumVarArray> NumVarMatrix;
typedef IloArray<IloNumArray> NumMatrix;
typedef IloArray<IloIntArray> IntMatrix;
typedef std::vector<IloInt> Orders;
typedef std::map <IloInt, std::map <IloInt, IloNumVar> > VarMatrix;
typedef std::map <IloInt, IloNumVar> VarArray;
class ModelePartiel
{
static const char* s_params;
private:
IloModel _model;
IloOplRunConfiguration _dat;
SETUP _setup;
IloInt _a;
IloInt _b;
Orders _nonProcessed;
IloInt _precOrder;
// starting time of precOrder
IloInt _tt;
VarMatrix _x;
VarMatrix _u;
VarArray _alpha;
VarArray _omega;
VarArray _CES;
static IloOplRunConfiguration loadRC(IloEnv& env, const char* datfile);
void initVars(IloEnv& env);
void initObj(IloEnv& env);
void initConstraints(IloEnv& env);
public:
ModelePartiel
(
IloEnv& env,
const IloOplRunConfiguration& dat,
SETUP setup,
const IloInt & a,
const IloInt & b ,
const Orders & nonProcessed,
const IloInt & precOrder,
const IloInt & tt
) :
_model(env),
_dat(dat),
_setup(setup),
_a(a),
_b(b),
_nonProcessed(nonProcessed),
_precOrder(precOrder),
_tt(tt),
_x(),
_u(),
_alpha(),
_omega(),
_CES()
{
//std::cout << "initVars" << std::endl;
initVars(env);
//std::cout << "initObj" << std::endl;
initObj(env);
//std::cout << "initConstraints" << std::endl;
initConstraints(env);
}
// get the number of released orders between a and b
std::vector<IloInt> getNumberOfReleasedOrders(IloInt a, IloInt b, const std::vector <IloInt> & nonProc);
std::vector<IloInt> getNumberOfDeadlineOrders(IloInt a, IloInt b, const std::vector <IloInt>& nonProc);
static ModelePartiel* load(IloEnv& env, IloOplRunConfiguration& rc, SETUP setup, const IloInt& a, const IloInt& b, const Orders & nonProcessed, const IloInt & precOrder, const IloInt & tt);
static void relaxAndFix(IloEnv & env, const char * datfile, const IloInt& sigma, const IloInt & delta, SETUP setup);
static void relaxAndFixLoop(IloOplRunConfiguration& rc, SETUP setup, const IloInt& k, const IloInt& a, const IloInt& b, const IloInt& delta, IloInt& prec, Orders& nonProc, IloInt& tt, IntMatrix & vals);
void fix(IloEnv& env, const IntMatrix & vals, const IloInt & from, const IloInt & to);
void get(IloCplex& cplx, IntMatrix & vals, const IloInt& from, const IloInt& to, std::vector<IloInt> & orders, IloInt& precOrder, IloInt & tt);
static double computeObj(IloOplRunConfiguration& opl, const IntMatrix & vals, const Orders & sequence);
void printSol(std::ostream & os, const IntMatrix & vals);
~ModelePartiel()
{
IloOplModel opl(_dat.getOplModel());
IloInt n(opl.getElement("n").asInt());
for (IloInt i : _nonProcessed)
{
_x[i].clear();
_u[i].clear();
}
_x[_precOrder].clear();
_u[_precOrder].clear();
_alpha.clear();
_omega.clear();
}
};