46TEST(NoiseGeneratorTest, testGetCostFunctionAllValidStates)
49 auto state_validator_fn = [](
const Eigen::VectorXd& ) {
return 0.0; };
55 const int last_timestep = values.cols() - 1;
56 for (
int timestep = 0; timestep <= last_timestep; ++timestep)
58 values.col(timestep).fill(
static_cast<double>(timestep) / last_timestep);
64 ASSERT_TRUE(cost_fn(values, costs, validity));
67 EXPECT_TRUE(validity);
68 EXPECT_EQ(costs.sum(), 0.0);
71TEST(NoiseGeneratorTest, testGetCostFunctionInvalidStates)
76 static const std::set<int> INVALID_TIMESTEPS(
77 { 0, 10, 11, 12, 25, 26, 27, 46, 63, 64, 65, 66, 67, 68, 69, 97, 98, 99 });
78 size_t timestep_counter = 0;
79 auto state_validator_fn = [&](
const Eigen::VectorXd& ) {
80 return PENALTY * INVALID_TIMESTEPS.count(timestep_counter++);
87 const int last_timestep = values.cols() - 1;
88 for (
int timestep = 0; timestep <= last_timestep; ++timestep)
90 values.col(timestep).fill(
static_cast<double>(timestep) / last_timestep);
96 ASSERT_TRUE(cost_fn(values, costs, validity));
99 EXPECT_FALSE(validity);
100 EXPECT_EQ(timestep_counter, 100u);
101 EXPECT_LE(costs.maxCoeff(),
PENALTY);
102 EXPECT_GE(costs.minCoeff(), 0.0);
105 EXPECT_DOUBLE_EQ(costs.sum(),
PENALTY * INVALID_TIMESTEPS.size());
109 const std::vector<int> invalid_timesteps_vec(INVALID_TIMESTEPS.begin(), INVALID_TIMESTEPS.end());
110 EXPECT_GE(costs(invalid_timesteps_vec).sum(), 0.681 *
PENALTY);