-
Notifications
You must be signed in to change notification settings - Fork 0
/
ProjectWithOvertime.h
138 lines (102 loc) · 7 KB
/
ProjectWithOvertime.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
135
136
137
138
//
// Created by André Schnabel on 23.10.15.
//
#pragma once
#include <map>
#include <boost/algorithm/string/join.hpp>
#include "Project.h"
class ProjectCharacteristics {
std::string instanceName;
std::map<std::string, float> characteristics;
std::list<std::string> orderedKeys;
public:
ProjectCharacteristics(const std::string _instanceName, const std::map<std::string, float> _characteristics);
std::string csvHeaderLine() const;
std::string toCsvLine() const;
float getCharacteristic(std::string charName) const;
std::list<std::string> getOrderedKeys() const { return orderedKeys; }
};
class ProjectWithOvertime : public Project {
public:
std::vector<int> zmax, zzero;
std::vector<float> kappa, revenue;
std::vector<float> revenueExtrapolated;
explicit ProjectWithOvertime(const std::string &filename);
explicit ProjectWithOvertime(JsonWrap obj);
ProjectWithOvertime(const std::string& projectName, const std::string& contents);
ProjectWithOvertime(const std::string& projectName, const std::vector<std::string> &lines);
~ProjectWithOvertime() final = default;
float calcProfit(int makespan, const Matrix<int> &resRem) const;
float calcProfit(const SGSResult& result) const;
float calcProfit(const std::vector<int> &sts) const;
float calcProfitForPartial(const std::vector<int> &sts) const;
float totalCosts(const Matrix<int> & resRem) const;
float totalCosts(const std::vector<int> &sts) const;
float totalCosts(const SGSResult& result) const;
float totalCostsForPartial(const std::vector<int> &sts) const;
SGSResult serialSGSWithOvertime(const std::vector<int> &order, bool robust = false) const;
SGSResult serialSGSWithOvertimeWithForwardBackwardImprovement(const std::vector<int>& order, bool robust = false) const;
// START (lambda|beta)
struct BorderSchedulingOptions {
bool separateCrossover, assocIndex, upper;
BorderSchedulingOptions();
BorderSchedulingOptions(bool _separateCrossover, bool _assocIndex, bool _upper);
explicit BorderSchedulingOptions(int ix);
void setFromIndex(int ix);
};
struct PartialScheduleData {
Matrix<int> resRem;
std::vector<int> sts, fts;
explicit PartialScheduleData(ProjectWithOvertime const* p);
};
struct ResidualData {
Matrix<int> normal, overtime;
explicit ResidualData(ProjectWithOvertime const* p);
};
void scheduleJobSeparateResiduals(int job, int t, int bval, PartialScheduleData& data, ResidualData& residuals) const;
void scheduleJobBorderLower(int job, int lastPredFinished, int bval, PartialScheduleData& data) const;
void scheduleJobBorderUpper(int job, int lastPredFinished, int bval, PartialScheduleData& data, ResidualData& residuals) const;
SGSResult serialSGSTimeWindowBorders(const std::vector<int> &order, const std::vector<int> &beta, const BorderSchedulingOptions &options, bool robust = false) const;
SGSResult serialSGSTimeWindowBordersWithForwardBackwardImprovement(const std::vector<int> &order, const std::vector<int> &beta, const BorderSchedulingOptions &options, bool robust = false) const;
// END (lambda|beta)
SGSResult serialSGSWithForwardBackwardImprovement(const std::vector<int>& order, const std::vector<int>& z, bool robust = false) const;
SGSResult serialSGSWithForwardBackwardImprovement(const std::vector<int>& order, const Matrix<int>& z, bool robust = false) const;
SGSResult serialSGSWithRandomKeyAndFBI(const std::vector<float> &rk, const Matrix<int>& z) const;
SGSResult serialSGSWithRandomKeyAndFBI(const std::vector<float> &rk, const std::vector<int>& z) const;
SGSResult serialSGSTimeWindowArbitrary(const std::vector<int> &order, const std::vector<float> &tau, bool robust = false) const;
SGSResult serialSGSTimeWindowArbitraryWithForwardBackwardImprovement(const std::vector<int> &order, const std::vector<float> &tau, bool robust = false) const;
std::vector<int> earliestStartingTimesForPartialRespectZmax(const std::vector<int> &sts, const Matrix<int> &resRem) const;
int heuristicMakespanUpperBound() const;
SGSResult forwardBackwardDeadlineOffsetSGS(const std::vector<int> &order, int deadlineOffset, bool robust = false) const;
SGSResult delayWithoutOvertimeIncrease(const std::vector<int>& order, const std::vector<int>& baseSts, const Matrix<int>& baseResRem, int deadline, bool robust = false) const;
SGSResult earlierWithoutOvertimeIncrease(const std::vector<int>& order, const std::vector<int>& baseSts, const Matrix<int>& baseResRem, bool robust = false) const;
boost::optional<float> costsAndFeasibilityCausedByActivity(int j, int stj, const Matrix<int>& resRem) const;
int latestCheapestFeasiblePeriod(int j, int baseStj, int lstj, const Matrix<int>& resRem) const;
int earliestCheapestFeasiblePeriod(int j, int baseStj, int estj, const Matrix<int>& resRem) const;
SGSResult goldenSectionSearchBasedOptimization(const std::vector<int>& order, bool robust = false) const;
SGSResult forwardBackwardIterations(const std::vector<int> &order, SGSResult result, int deadline, boost::optional<int> numIterations = boost::optional<int>(), bool robust = false) const;
bool isScheduleResourceFeasible(const std::vector<int>& sts) const override;
std::map<int, std::pair<int, float>> heuristicProfitsAndActualMakespanForRelevantDeadlines(const std::vector<int> &order) const;
json11::Json to_json() const override;
void from_json(const json11::Json& obj) override;
std::vector<int> serialOptimalSubSGS(const std::vector<int>& orderInducedPartitions, int partitionSize) const;
std::vector<int> serialOptimalSubSGSWithPartitionList(const std::vector<int>& partitionList) const;
bool isPartitionListFeasible(const std::vector<int> &partitionList, int partitionSize) const;
SGSResult serialOptimalSubSGSAndFBI(const std::vector<int>& orderInducedPartitions, int partitionSize, bool robust = false) const;
SGSResult serialOptimalSubSGSWithPartitionListAndFBI(const std::vector<int>& partitionList) const;
SGSResult parallelSGSWithForwardBackwardImprovement(const std::vector<int> &order, const Matrix<int> &z) const;
SGSResult parallelSGSWithForwardBackwardImprovement(const std::vector<int> &order, const std::vector<int> &z) const;
SGSResult parallelSGSWithForwardBackwardImprovement(const std::vector<int> &order) const;
ProjectCharacteristics collectCharacteristics(const boost::optional<std::map<std::string, float>> additionalCharacteristics = boost::optional<std::map<std::string, float>>()) const;
std::string plotAsAscii(const std::vector<int> &sts, int r) const;
std::map<std::string, float> scheduleStatistics(const std::vector<int> &sts) const;
void printScheduleInformation(const std::vector<int> &sts) const;
void computeRevenueFunction();
void computeExtrapolatedRevenueFunction();
void updateDerivedParameters() override;
std::pair<std::vector<std::string>, std::vector<float>> flattenedRepresentation(const boost::optional<const ProjectCharacteristics&> chars = boost::optional<const ProjectCharacteristics&>()) const;
std::map<std::string, float> collectMesselisStats() const;
private:
int computeTKappa() const;
bool enoughCapacityForJobWithOvertime(int job, int t, const Matrix<int> & resRem) const;
};