25 #include "../population.h"
28 #include "base_stochastic.h"
29 #include "inventory.h"
31 namespace pagmo {
namespace problem {
34 m_weeks(weeks),m_sample_size(sample_size)
48 const double c=1.0,b=1.5,h=0.1;
51 for (
size_t i = 0; i<m_sample_size; ++i) {
53 for (decision_vector::size_type j = 0; j<x.size(); ++j) {
55 retval += c * x[j] + b * std::max<double>(d-I-x[j],0) + h * std::max<double>(I+x[j]-d,0);
56 I = std::max<double>(0, I + x[j] - d);
59 f[0] = retval / m_sample_size;
68 std::ostringstream oss;
69 oss <<
"\n\tWeeks: " << m_weeks <<
'\n';
70 oss <<
"\tSample Size: " << m_sample_size <<
'\n';
71 oss <<
"\tSeed: " <<
m_seed <<
'\n';
boost::shared_ptr< base > base_ptr
Alias for shared pointer to base problem.
std::vector< double > decision_vector
Decision vector type.
void objfun_impl(fitness_vector &, const decision_vector &) const
Objective function implementation.
rng_double m_drng
Random number generator for double-precision floating point values.
Stochastic Programming Test Problem: Inventory Model.
void set_lb(const decision_vector &)
Set lower bounds from pagmo::decision_vector.
unsigned int m_seed
Seed of the random number generator.
std::string get_name() const
Get problem's name.
void set_ub(const decision_vector &)
Set upper bounds from pagmo::decision_vector.
base_ptr clone() const
Clone method.
std::vector< double > fitness_vector
Fitness vector type.
Base Stochastic Optimization Problem.
std::string human_readable_extra() const
Extra human readable info for the problem.
inventory(int weeks=4, int sample_size=10, unsigned int seed=0)
Constructor from weeks, sample size and random seed.