4 #include "generated_config.hpp"
6 #include <boost/container/small_vector.hpp>
12 typedef std::pair<double, double> poly_term;
16 typedef std::vector<poly_term> polynomial;
18 double apply_polynomial(
const polynomial & poly,
double x);
20 polynomial add_poly(
const polynomial & lhs,
const polynomial & rhs);
27 Availability(
double start_amount);
28 Availability(
const Availability & other) =
default;
30 void set(std::vector<std::pair<unsigned int, double>> && new_points);
31 double get_at(
unsigned int point)
const noexcept;
33 double get_flat_available()
const;
35 std::vector<std::pair<unsigned int, double>>::const_iterator begin()
const;
36 std::vector<std::pair<unsigned int, double>>::const_iterator end()
const;
45 std::vector<std::pair<unsigned int, double>> points;
50 FlexCost(polynomial base);
53 set_flexible(std::vector<std::pair<unsigned int, polynomial>> && new_points);
55 const polynomial & get_at(
unsigned int point)
const noexcept;
56 const polynomial & get_base() const noexcept;
60 std::vector<std::pair<
unsigned int, polynomial>>::const_iterator
62 std::vector<std::pair<
unsigned int, polynomial>>::const_iterator end() const;
67 std::vector<std::pair<
unsigned int, polynomial>> points;
72 explicit Resource(
unsigned int id);
74 void set_availability(Availability && availability);
75 void set_overshoot_costs(FlexCost && cost);
76 void set_investment_costs(polynomial costs);
78 const Availability & get_availability()
const;
80 const FlexCost & get_flex_overshoot()
const;
81 const polynomial & get_overshoot_costs(
unsigned int pos)
const;
84 const polynomial & get_overshoot_costs()
const;
85 bool is_overshoot_flat()
const;
87 const polynomial & get_investment_costs()
const;
89 unsigned int get_rid();
90 void set_id(
unsigned int id);
93 operator==(
const Resource & other)
const
95 return other.rid == this->rid;
100 Resource clone()
const;
104 Availability availability;
105 polynomial investment_costs;
106 FlexCost overshoot_costs;
110 :
public boost::container::small_vector<double, OPTIMAL_RESOURCE_COUNT> {
112 using boost::container::small_vector<double,
113 OPTIMAL_RESOURCE_COUNT>::small_vector;
119 Resources(
double usage);
120 Resources(
const Instance * instance,
const ResVec & usage);
121 Resources(
const Instance * instance,
const std::vector<double> & usage);
122 Resources(
const Instance * instance, ResVec && usage);
123 Resources(
const Instance * instance);
125 const ResVec & getUsage()
const;
128 Resources operator+(
const Resources & other)
const;
129 Resources operator-(
const Resources & other)
const;
130 Resources operator*(
const Resources & other)
const;
131 Resources operator/(
const Resources & other)
const;
132 void operator+=(
const Resources & other);
133 void operator-=(
const Resources & other);
134 void operator*=(
const Resources & other);
135 void operator/=(
const Resources & other);
137 bool operator<(
const Resources & other)
const;
138 bool operator>(
const Resources & other)
const;
139 bool operator<=(
const Resources & other)
const;
140 bool operator>=(
const Resources & other)
const;
141 bool operator!=(
const Resources & other)
const;
142 bool operator==(
const Resources & other)
const;
144 template <
typename T>
145 inline friend std::enable_if_t<std::is_integral_v<T>, Resources>
146 operator*(
const T & scalar,
const Resources & resource);
151 mutable double cache;
155 double getCosts()
const;
158 template <
typename T>
159 inline std::enable_if_t<std::is_integral_v<T>, Resources>
160 operator*(
const T & scalar,
const Resources & resource)
162 Resources res(resource.instance, resource.usage);
163 for (
size_t i = 0; i < resource.usage.size(); i++) {
164 res.usage[i] *= scalar;
169 template <
typename T,
typename = std::enable_if_t<std::is_
integral_v<T>>>
171 operator*(
const Resources & resource,
const T & scalar)
173 return scalar * resource;