fallbacks: add a test to use fallbacks *per state*

The current implementation will not fall back for each state
independently, but is meant to stay with the first child producing
a solution. For propagators, this is problematic though
as the picked child depends on the (arbitrary) first received state.

Instead, fallbacks should pass each state to each child separately
until one produces a solution for it (or all are exhausted).
This commit is contained in:
v4hn 2021-08-18 12:40:27 +02:00
parent 2bee9d5f66
commit f75a498f55

View File

@ -55,6 +55,24 @@ TEST_F(FallbacksFixturePropagate, ComputeFirstSuccessfulStageOnly) {
EXPECT_EQ(t.numSolutions(), 1u);
}
TEST_F(FallbacksFixturePropagate, ComputeFirstSuccessfulStagePerSolutionOnly) {
t.add(std::make_unique<GeneratorMockup>(std::list<double>{ 0.0, 1.0 }));
auto fallbacks = std::make_unique<Fallbacks>("Fallbacks");
fallbacks->add(std::make_unique<ForwardMockup>(std::list<double>{ INF, 0.0 }));
fallbacks->add(std::make_unique<ForwardMockup>(std::list<double>{ 0.0, INF }));
auto fwd1 = fallbacks->findChild("FWD1");
auto fwd2 = fallbacks->findChild("FWD2");
t.add(std::move(fallbacks));
EXPECT_TRUE(t.plan());
EXPECT_EQ(t.numSolutions(), 2u);
ASSERT_EQ(fwd1->solutions().size(), 1u);
EXPECT_EQ(fwd1->solutions().front()->cost(), 1.0);
ASSERT_EQ(fwd2->solutions().size(), 1u);
EXPECT_EQ(fwd2->solutions().front()->cost(), 0.0);
}
TEST_F(FallbacksFixturePropagate, ActiveChildReset) {
t.add(std::make_unique<GeneratorMockup>(PredefinedCosts{ { 0.0, INF, 0.0 } }));