4 #include "instance/instance.hpp"
5 #include "instance/solution.hpp"
6 #include "manager/timer.hpp"
7 #include "datastructures/maybe.hpp"
8 #include "db/storage.hpp"
9 #include "util/solverconfig.hpp"
10 #include "util/log.hpp"
11 #include "../manager/solvers.hpp"
12 #include "../datastructures/skyline.hpp"
13 #include "../instance/resource.hpp"
14 #include "../algorithms/graphalgos.hpp"
25 GraspRandom(
const Instance& instance,
const SolverConfig& sconf);
27 std::vector<const Job*> operator()();
29 static std::string getName();
33 std::vector<const Job*> jobs;
38 GraspSorted(
const Instance& instance,
const SolverConfig& sconf);
40 std::vector<const Job*> operator()();
42 static std::string getName();
45 std::vector<const Job*> jobs;
49 namespace implementation {
52 GraspArray(
const Instance& in,
const SolverConfig& sconf,
const Timer & timer_in);
54 void operator()(std::vector<const Job*>& jobs, std::vector<unsigned int>& starts);
56 static std::string getName();
63 const unsigned int graspSelection;
64 const unsigned int graspSamples;
67 std::vector<ResVec> usage;
69 void updateUsage(std::vector<unsigned int>& s);
74 GraspSkyline(
const Instance& in,
const SolverConfig& sconf,
const Timer & timer_in);
76 void operator()(std::vector<const Job*>& jobs, std::vector<unsigned int>& starts);
78 static std::string getName();
85 const unsigned int graspSelection;
86 const unsigned int graspSamples;
91 void updateUsage(std::vector<unsigned int>& s);
95 template<
typename GraspAlgorithm = detail::GraspRandom,
typename GraspImplementation = implementation::GraspArray>
99 AdditionalResultStorage& storage;
101 std::vector<unsigned int> bestStarts;
102 std::vector<unsigned int> starts;
107 static const Traits required_traits;
109 GraspAlgorithm graspAlgorithm;
110 GraspImplementation graspImplementation;
112 const unsigned int weightedSelections;
113 const unsigned int weightedIterations;
114 const unsigned int uniformSelections;
115 const unsigned int uniformIterations;
117 const unsigned int graspSelection;
118 const unsigned int graspSamples;
120 const unsigned int resetCount;
121 unsigned int nextReset;
124 const double writeIntermediateInterval;
125 double lastIntermediateTime;
126 const bool writeTempResult;
129 std::vector<unsigned int> permutation;
147 GRASP(
const Instance& instance_in, AdditionalResultStorage& additional,
const SolverConfig& sconf);
166 static std::string get_id();
173 Maybe<double> get_lower_bound();
180 static const Traits &get_requirements();
185 double hillClimber();
186 std::vector<ResVec> resourceUsage(std::vector<unsigned int>& s);
190 template<
typename GraspAlgorithm,
typename GraspImplementation>
191 const Traits GRASP<GraspAlgorithm, GraspImplementation>::required_traits = Traits(
192 Traits::LAGS_ONLY_POSITIVE | Traits::LAGS_DAG | Traits::NO_WINDOW_EXTENSION |
193 Traits::NO_DRAIN | Traits::FLAT_AVAILABILITY,
194 std::numeric_limits<unsigned int>::max(),
205 struct registry_hook<solvers::get_free_N<grasp::GRASP<grasp::detail::GraspRandom, grasp::implementation::GraspArray>>()>
207 constexpr
static unsigned int my_N = solvers::get_free_N<grasp::GRASP<grasp::detail::GraspRandom, grasp::implementation::GraspArray>>();
212 return solvers::register_class < grasp::GRASP<grasp::detail::GraspRandom, grasp::implementation::GraspArray>, my_N > {}();
218 struct registry_hook<solvers::get_free_N<grasp::GRASP<grasp::detail::GraspSorted, grasp::implementation::GraspArray>>()>
220 constexpr
static unsigned int my_N = solvers::get_free_N<grasp::GRASP<grasp::detail::GraspSorted, grasp::implementation::GraspArray>>();
225 return solvers::register_class < grasp::GRASP<grasp::detail::GraspSorted, grasp::implementation::GraspArray>, my_N > {}();
231 struct registry_hook<solvers::get_free_N<grasp::GRASP<grasp::detail::GraspRandom, grasp::implementation::GraspSkyline>>()>
233 constexpr
static unsigned int my_N = solvers::get_free_N<grasp::GRASP<grasp::detail::GraspRandom, grasp::implementation::GraspSkyline>>();
238 return solvers::register_class < grasp::GRASP<grasp::detail::GraspRandom, grasp::implementation::GraspSkyline>, my_N > {}();
244 struct registry_hook<solvers::get_free_N<grasp::GRASP<grasp::detail::GraspSorted, grasp::implementation::GraspSkyline>>()>
246 constexpr
static unsigned int my_N = solvers::get_free_N<grasp::GRASP<grasp::detail::GraspSorted, grasp::implementation::GraspSkyline>>();
251 return solvers::register_class < grasp::GRASP<grasp::detail::GraspSorted, grasp::implementation::GraspSkyline>, my_N > {}();