MineLink
 All Data Structures Functions Variables Pages
cbcmipscheduler.h
1 
2 #ifndef __CBCMIPSCHEDULER_H__
3 #define __CBCMIPSCHEDULER_H__
4 
5 #include <string>
6 #include <sstream>
7 #include <map>
8 #include <typeinfo>
9 #include "mip_scheduler.h"
10 #include "cbc_model.h"
11 #include "../../../problems/scheduling/filtering.h"
12 #include <iostream>
13 
14 namespace delphos{
18 class CBCMIPScheduler : public MIPScheduler {
19 private:
20  CBCModel* _cmodel;
21  unsigned int _loglevel;
22 
23  bool CreateGoalFunction();
24  bool CreateCoreConstraints();
25 
26  bool _bmodelcreated;
27  bool _buser_constraintscreated;
28 
29  void ApplyPrecedenceConstraint(const PrecedenceConstraint& pc);
30  void ApplyAttributeSumConstraint(const AttributeSumConstraint& asc);
31  void ApplyAttributeAvgConstraint(const AttributeAvgConstraint& asc);
32  void ApplyDoNotMineBeforeConstraint(const DoNotMineBeforeConstraint& dc);
33  void ApplyForceMiningByConstraint(const ForceMiningByConstraint& fc);
34  void ApplyDoNotSendToConstraint(const DoNotSendToConstraint& dnsc);
35  void ApplyGeometricConstraint(const GeometricConstraint& gc);
36  void ApplyMinExtractPeriodConstraint(const MinExtractPeriodConstraint& mepc);
37  void ApplyBlockSelectionPrecedenceConstraint(const BlockSelectionPrecedenceConstraint& bsprc);
38 
39  delphos::Variable& ProcVar(
40  const delphos::BlockIndexType& block_index,
41  const unsigned int& period,
42  const unsigned int& destination);
43  vector<BlockIndexType> _index_in_bs;
44  unsigned long _nb_prec;
45 
46 public:
47 
48  #ifndef DOXYGEN
49  delphos::Variable& StockVar(
50  const unsigned int& stock_index,
51  const unsigned int& period,
52  const unsigned int& destination);
53 
54  delphos::LinearExpr RealProcVar(
55  const BlockIndexType& block_index,
56  const unsigned int& period,
57  const unsigned int& destination);
58  #endif
59 
63  bool SetSchedule();
64 
71 
75  virtual ~CBCMIPScheduler();
76 
82  virtual bool Run();
83 
84  #ifndef DOXYGEN
85 
91  void Optimize();
92  #endif
93 
98 
104  bool CreateModel();
105 
109  bool CreateVariables();
110 
114  bool CreateUserConstraints();
115 
123  void WriteLP(const string outfile);
124 
132  void WriteSol(const string outfile);
133  //void WriteInfeasibleLP(const string outfile);
134 
138  CBCModel& GetMathematicalModel();
139 
143  double GetObjValue();
144 
149  void AddSetting(const string& setting);
150 
158  const double GetDual(const string& cname);
159 
164  void SetLogLevel(const unsigned int& level);
165 
169  double GetMIPGap();
170 
171 };
172 
173 
174 
175 
176 }
177 #endif
178 
bool SetSchedule()
Set The result schedule This method put the result from the CBC optimization into a schedule...
Definition: cbcmipscheduler.cpp:1012
void WriteLP(const string outfile)
Writes the LP model in given file.
Definition: cbcmipscheduler.cpp:1131
double GetMIPGap()
Returns the relative integer gap.
Definition: cbcmipscheduler.cpp:1191
bool CreateModel()
Inits the solver and load the model in CBC.
Definition: cbcmipscheduler.cpp:334
A constraint on the addition of the attributes of a block.
Definition: constraint.h:264
A constraint limiting the period at which a block should be mined.
Definition: filtering.h:62
bool CreateVariables()
Creates the variables of the model.
Definition: cbcmipscheduler.cpp:58
Defines a scheduling instance to be solved.
Definition: instance.h:41
A constraint that prevents certain blocks to be sent to given processes.
Definition: filtering.h:107
void WriteSol(const string outfile)
Writes the solution in given file.
Definition: cbcmipscheduler.cpp:1138
virtual void Optimize()
Optimizes the model.
Definition: mip_scheduler.cpp:61
CBCModel & GetMathematicalModel()
Returns the mathematical model.
Definition: cbcmipscheduler.cpp:396
A constraint on the average values of attributes of blocks.
Definition: constraint.h:426
bool CreateUserConstraints()
Creates the user constraints.
Definition: cbcmipscheduler.cpp:288
double GetObjValue()
Returns the objective value of the optimized model.
Definition: cbcmipscheduler.cpp:401
A geometric constraint.
Definition: constraint.h:632
A constraint that forces a block to be mined before or at some period.
Definition: filtering.h:19
virtual bool Run()
Generates the model in CBC and optimize it.
Definition: cbcmipscheduler.cpp:300
A constraint that prevents certain blocks that can't be extracted before a period due to capacities c...
Definition: filtering.h:178
CBCMIPScheduler(delphos::SchedulingInstance &si)
Creates a CBC MIP scheduler with given scheduling instance.
Definition: cbcmipscheduler.cpp:5
const double GetDual(const string &cname)
Returns the dual value of given constraint.
Definition: cbcmipscheduler.cpp:1146
Abstracts a CBC MIP solver that can solve a scheduling instance.
Definition: cbcmipscheduler.h:18
Dummy class that define required methods for a MIP solver of a scheduling instance.
Definition: mip_scheduler.h:24
void SetLogLevel(const unsigned int &level)
Set the nivel of log.
Definition: cbcmipscheduler.cpp:1181
A precedence constraint.
Definition: constraint.h:513
A block selection precedence constraint.
Definition: constraint.h:572
Defines a scheduling of blocks.
Definition: schedule.h:23
const delphos::Schedule & GetSchedule()
Returns the result schedule.
Definition: cbcmipscheduler.cpp:1176
virtual ~CBCMIPScheduler()
The destructor.
Definition: cbcmipscheduler.cpp:16
void AddSetting(const string &setting)
Adds a setting for the solve process.
Definition: cbcmipscheduler.cpp:1186