MineLink
 All Data Structures Functions Variables Pages
bz.h
1 #ifndef __BZ_H__
2 #define __BZ_H__
3 #include <algorithm>
4 #include "../../../finalpit/pseudoflowfp.h"
5 #include "../fractional_scheduler.h"
6 
7 namespace delphos{
14 class BZ : public FractionalScheduler {
15 
16 private:
17  virtual void ComputeExpectedTime(const string column);
18 
19 protected:
20 
21  SchedulingInstance* _temp_si;
22  BlockModel* _fullpit_bm;
23  BlockModel* _bm_var;
24  Precedence* _fullpit_prec;
25  Precedence* _reduced_prec;
26 
27  FinalPitSolver* _pitsolver;
28  unsigned int _cont;
29 
30  //bool _use_lp_as_pitsolver;
31  //GurobiFractionalScheduler* _lpsolver;
32 
33  unsigned int _nb_iterations_bz;
34  double _relobjvalue;
35  double* _reldecsol;
36  double* _relsol;
37 
38  vector<double> _exptime;
39  unsigned int* _tmin;
40  //BlockIndexType _nb_blk_with_exptime_in_horizon;
41  //Schedule* _schedule;
42 
43  bool _stocks;
44 
45  double _time_finalpit_compute;
46  double _time_lp_compute;
47 
48  unsigned int _K;
49  float _delta;
50  unsigned int _eps;
51  bool _TEIncParameterIsSet;
52  CallBackPtr _fp;
53 
54  unsigned int _emph;
55  double _gap;
56  int _sense;
57  string _logfile;
58 
59  map<string,double> _duals;
60  double _max_cost;
61 
62  virtual const bool IsStock();
63  void init_pitsolver(FinalPitSolver* fps);
64  void ChangePenalties(vector<double>, vector<double> );
65  //virtual void SetRelaxedSol(GRBModel*,const vector<BlockSelection>&,const bool&);
66 
67  typedef struct node {
68  set<BlockIndexType> precedenceSet;
69  set<BlockIndexType> succSet;
70  BlockIndexType number;
71  float w;
72  }Node;
73 
74  typedef struct ress{
75  set<unsigned int> index;
76  string attr;
77  float min;
78  float max;
79  unsigned int period;
80  }Ress;
81 
82  vector<Node>* CreateGraph(const bool& TE=true);
83  BlockIndexType* TopoSort(const bool& TE=true);
84 
85  class Slack:public Stock{
86  private:
87  unsigned int _period;
88  public:
89  Slack(const string & slack_name, const string & tname, const double & tonnage,const unsigned int& period);
90  const unsigned int& GetPeriod() const;
91  };
92  vector<Slack> _slacks;
93 
94  map<BlockIndexType,bool> _assigned_vars;
95  BlockSelection* _bs_to1;
96  BlockSelection* _bs_to0;
97  BlockSelection* _bs_to;
98  BlockSelection* _bs_var;
99  bool _feasible;
100  void UpdatePitSolver();
101  bool _bGeometric;
102  bool _optimized;
103  virtual bool SetFractionalSchedule();
104 
105 public:
106 
112 
116  virtual ~BZ();
117 
122  virtual bool Run();
123 
127  virtual double* GetRelaxedSol();
128 
132  virtual double* GetRelaxedDecisionSol();
133 
139  virtual bool RelaxedSolToTextFile(const char * relsol_file, const char* stocks_file="") ;
140 
144  virtual bool CheckRelaxedSol();
145 
149  vector<double> GetExpectedTime() const;
150 
155  virtual bool SetExpectedTime(const string& column);
156 
161  virtual void StoreExpectedTimeAsAttribute(const string column);
162 
167  virtual bool ExpectedTimeToTextFile(const char * exptime_file) const;
168 
169 
170 
171  //virtual void SetSense(const int & emph);
172  //const int GetSense() const;
173 
178  virtual void SetLogFile(const string& name);
179 
183  double GetRelaxedObj();
184 
188  unsigned int GetNBIterationsBZ();
189 
193  const map<string,double>& GetBZDuals();
194 
198  bool IsFeasible();
199 
203  const bool Optimized();
204 
208  virtual SchedulingInstance & GetInstance();
209 };
210 }
211 #endif
212 
Dummy class that define required methods for a Bienstock Zuckerberg solver of a scheduling instance...
Definition: bz.h:14
Abstracts a set of blocks (subset of a blockmodel).
Definition: blocksel.h:33
virtual SchedulingInstance & GetInstance()
Returns the scheduling instance.
Definition: bz.cpp:1636
bool IsFeasible()
Returns true only if BZ run correctly.
Definition: bz.cpp:1641
virtual bool ExpectedTimeToTextFile(const char *exptime_file) const
Writes the expected times in given file.
Definition: bz.cpp:1593
virtual ~BZ()
The destructor.
Definition: bz.cpp:189
Defines a scheduling instance to be solved.
Definition: instance.h:41
virtual bool Run()
Creates the model and run the BZ algorithm. This implementation is a dummy version that always return...
Definition: bz.cpp:724
virtual bool SetExpectedTime(const string &column)
Sets the expected times from a block model attribute with given name.
Definition: bz.cpp:1606
double GetRelaxedObj()
Get the relaxed objective.
Definition: bz.cpp:1536
virtual double * GetRelaxedSol()
Returns the relaxed solution for the real variables.
Definition: bz.cpp:1210
Abstracts a container of blocks as a table with arbitrary number of attributes that can be accessed b...
Definition: blockmodel.h:62
Implements a precedence as an explicit set of arcs between blocks. Provides utility functions...
Definition: precs.h:22
unsigned int GetNBIterationsBZ()
Return the number of iterations of BZ run.
Definition: bz.cpp:1539
virtual double * GetRelaxedDecisionSol()
Returns the relaxed solution for the decision variables.
Definition: bz.cpp:1214
const map< string, double > & GetBZDuals()
Returns the dual values encountered by BZ.
Definition: bz.cpp:1528
virtual bool CheckRelaxedSol()
Check If the relaxed solution respect the constraints defined in the scheduling instance.
Definition: bz.cpp:1226
A dummy class that specifies the methods of an algorithm that can solve a final pit instance...
Definition: fp.h:57
const bool Optimized()
Returns true only if BZ run correctly.
Definition: bz.cpp:229
BZ(delphos::SchedulingInstance &si, delphos::FinalPitSolver *fps=NULL)
Creates a new scheduler.
Definition: bz.cpp:6
virtual void StoreExpectedTimeAsAttribute(const string column)
Stores the expected times for each block in given column in the block model.
Definition: bz.cpp:1618
vector< double > GetExpectedTime() const
Returns the expected times for the blocks.
Definition: bz.cpp:1219
virtual void SetLogFile(const string &name)
Set the use of the log with given file name.
Definition: bz.cpp:1532
Defines a pre-existing stock.
Definition: stock.h:20
Dummy class that define required methods for a solver of a scheduling instance.
Definition: fractional_scheduler.h:14
virtual bool RelaxedSolToTextFile(const char *relsol_file, const char *stocks_file="")
Writes the relaxed solution in given text files.
Definition: bz.cpp:1543