1 #if !defined(_COST_COMPONENT_HH_)
2 #define _COST_COMPONENT_HH_
20 template <
class Input,
class State,
typename CFtype =
int>
23 static size_t last_index;
27 virtual void Print(std::ostream& os = std::cout)
const;
33 virtual CFtype
ComputeCost(
const State& st)
const = 0;
46 virtual void PrintViolations(
const State& st, std::ostream& os = std::cout)
const = 0;
137 template <
class Input,
class State,
typename CFtype>
139 : name(name), in(in), weight(weight), is_hard(is_hard), index(last_index++)
144 template <
class Input,
class State,
typename CFtype>
147 os <<
"Cost Component " << name <<
": weight " << weight << (is_hard ?
"*" :
"") << std::endl;
150 template <
class Input,
class State,
typename CFtype>
153 template <
class Input,
class State,
typename CFtype>
158 #endif // _COST_COMPONENT_HH_
CFtype Cost(const State &st) const
virtual CFtype ComputeCost(const State &st) const =0
static const size_t CostComponents()
static std::vector< CostComponent< Input, State, CFtype > * > cost_components
The class CostComponent manages one single component of the cost, either hard or soft.
virtual void Print(std::ostream &os=std::cout) const
CostComponent(const Input &in, const CFtype &weight, bool is_hard, std::string name)
void SetWeight(const CFtype &w)
static const CostComponent< Input, State, CFtype > & Component(size_t i)
virtual void PrintViolations(const State &st, std::ostream &os=std::cout) const =0