Skip to content

Commit 6a131c7

Browse files
tquatmannsjunges
andauthored
Improved LpMinMaxLinearEquationSolver, set relevant values in topo solvers (#568)
* Added options to tweak the LP encoding * Use RawMode instead of storm::expressions * Add ViToLp Method to warm-start the procedure * Topological solvers can now (optionally, if enabled) set relevant values for each SCC --------- Co-authored-by: Sebastian Junges <[email protected]>
1 parent f8983f2 commit 6a131c7

24 files changed

+486
-93
lines changed

src/storm/environment/SubEnvironment.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ template class SubEnvironment<NativeSolverEnvironment>;
5858
template class SubEnvironment<LongRunAverageSolverEnvironment>;
5959
template class SubEnvironment<TimeBoundedSolverEnvironment>;
6060
template class SubEnvironment<MinMaxSolverEnvironment>;
61+
template class SubEnvironment<MinMaxLpSolverEnvironment>;
6162
template class SubEnvironment<MultiplierEnvironment>;
6263
template class SubEnvironment<OviSolverEnvironment>;
6364
template class SubEnvironment<GameSolverEnvironment>;

src/storm/environment/solver/AllSolverEnvironments.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
#include "storm/environment/solver/GameSolverEnvironment.h"
55
#include "storm/environment/solver/GmmxxSolverEnvironment.h"
66
#include "storm/environment/solver/LongRunAverageSolverEnvironment.h"
7+
#include "storm/environment/solver/MinMaxLpSolverEnvironment.h"
78
#include "storm/environment/solver/MinMaxSolverEnvironment.h"
89
#include "storm/environment/solver/MultiplierEnvironment.h"
910
#include "storm/environment/solver/NativeSolverEnvironment.h"
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#include "storm/environment/solver/MinMaxLpSolverEnvironment.h"
2+
#include "storm/settings/SettingsManager.h"
3+
#include "storm/settings/modules/MinMaxEquationSolverSettings.h"
4+
5+
namespace storm {
6+
7+
MinMaxLpSolverEnvironment::MinMaxLpSolverEnvironment() {
8+
auto const& minMaxSettings = storm::settings::getModule<storm::settings::modules::MinMaxEquationSolverSettings>();
9+
useNonTrivialBounds = minMaxSettings.getLpUseNonTrivialBounds();
10+
optimizeOnlyForInitialState = minMaxSettings.getLpUseOnlyInitialStateAsObjective();
11+
useEqualityForSingleActions = minMaxSettings.getLpUseEqualityForTrivialActions();
12+
}
13+
14+
void MinMaxLpSolverEnvironment::setUseEqualityForSingleActions(bool newValue) {
15+
useEqualityForSingleActions = newValue;
16+
}
17+
void MinMaxLpSolverEnvironment::setOptimizeOnlyForInitialState(bool newValue) {
18+
optimizeOnlyForInitialState = newValue;
19+
}
20+
void MinMaxLpSolverEnvironment::setUseNonTrivialBounds(bool newValue) {
21+
useNonTrivialBounds = newValue;
22+
}
23+
24+
bool MinMaxLpSolverEnvironment::getUseEqualityForSingleActions() const {
25+
return useEqualityForSingleActions;
26+
}
27+
bool MinMaxLpSolverEnvironment::getOptimizeOnlyForInitialState() const {
28+
return optimizeOnlyForInitialState;
29+
}
30+
bool MinMaxLpSolverEnvironment::getUseNonTrivialBounds() const {
31+
return useNonTrivialBounds;
32+
}
33+
} // namespace storm
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#pragma once
2+
3+
namespace storm {
4+
class MinMaxLpSolverEnvironment {
5+
public:
6+
MinMaxLpSolverEnvironment();
7+
virtual ~MinMaxLpSolverEnvironment() = default;
8+
9+
void setUseEqualityForSingleActions(bool newValue);
10+
void setOptimizeOnlyForInitialState(bool newValue);
11+
void setUseNonTrivialBounds(bool newValue);
12+
13+
bool getUseEqualityForSingleActions() const;
14+
bool getOptimizeOnlyForInitialState() const;
15+
bool getUseNonTrivialBounds() const;
16+
17+
private:
18+
bool useEqualityForSingleActions;
19+
bool optimizeOnlyForInitialState;
20+
bool useNonTrivialBounds;
21+
};
22+
} // namespace storm

src/storm/environment/solver/MinMaxSolverEnvironment.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#include "storm/environment/solver/MinMaxSolverEnvironment.h"
22

3+
#include "storm/environment/solver/MinMaxLpSolverEnvironment.h"
34
#include "storm/settings/SettingsManager.h"
45
#include "storm/settings/modules/MinMaxEquationSolverSettings.h"
56
#include "storm/utility/constants.h"
@@ -76,6 +77,13 @@ void MinMaxSolverEnvironment::setMultiplicationStyle(storm::solver::Multiplicati
7677
multiplicationStyle = value;
7778
}
7879

80+
MinMaxLpSolverEnvironment const& MinMaxSolverEnvironment::lp() const {
81+
return lpEnvironment.get();
82+
}
83+
MinMaxLpSolverEnvironment& MinMaxSolverEnvironment::lp() {
84+
return lpEnvironment.get();
85+
}
86+
7987
bool MinMaxSolverEnvironment::isForceRequireUnique() const {
8088
return forceRequireUnique;
8189
}

src/storm/environment/solver/MinMaxSolverEnvironment.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88

99
namespace storm {
1010

11+
class MinMaxLpSolverEnvironment;
12+
1113
class MinMaxSolverEnvironment {
1214
public:
1315
MinMaxSolverEnvironment();
@@ -26,6 +28,8 @@ class MinMaxSolverEnvironment {
2628
void setMultiplicationStyle(storm::solver::MultiplicationStyle value);
2729
bool isForceRequireUnique() const;
2830
void setForceRequireUnique(bool value);
31+
MinMaxLpSolverEnvironment const& lp() const;
32+
MinMaxLpSolverEnvironment& lp();
2933

3034
private:
3135
storm::solver::MinMaxMethod minMaxMethod;
@@ -35,5 +39,6 @@ class MinMaxSolverEnvironment {
3539
bool considerRelativeTerminationCriterion;
3640
storm::solver::MultiplicationStyle multiplicationStyle;
3741
bool forceRequireUnique;
42+
SubEnvironment<MinMaxLpSolverEnvironment> lpEnvironment;
3843
};
3944
} // namespace storm

src/storm/environment/solver/TopologicalSolverEnvironment.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ TopologicalSolverEnvironment::TopologicalSolverEnvironment() {
1515

1616
underlyingMinMaxMethod = topologicalSettings.getUnderlyingMinMaxMethod();
1717
underlyingMinMaxMethodSetFromDefault = topologicalSettings.isUnderlyingMinMaxMethodSetFromDefaultValue();
18+
extendRelevantValues = topologicalSettings.isExtendRelevantValues();
1819
}
1920

2021
TopologicalSolverEnvironment::~TopologicalSolverEnvironment() {
@@ -51,4 +52,12 @@ void TopologicalSolverEnvironment::setUnderlyingMinMaxMethod(storm::solver::MinM
5152
underlyingMinMaxMethod = value;
5253
}
5354

55+
bool TopologicalSolverEnvironment::isExtendRelevantValues() const {
56+
return extendRelevantValues;
57+
}
58+
59+
void TopologicalSolverEnvironment::setExtendRelevantValues(bool value) {
60+
extendRelevantValues = value;
61+
}
62+
5463
} // namespace storm

src/storm/environment/solver/TopologicalSolverEnvironment.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,15 @@ class TopologicalSolverEnvironment {
1919
bool const& isUnderlyingMinMaxMethodSetFromDefault() const;
2020
void setUnderlyingMinMaxMethod(storm::solver::MinMaxMethod value);
2121

22+
bool isExtendRelevantValues() const;
23+
void setExtendRelevantValues(bool value);
24+
2225
private:
2326
storm::solver::EquationSolverType underlyingEquationSolverType;
2427
bool underlyingEquationSolverTypeSetFromDefault;
2528

2629
storm::solver::MinMaxMethod underlyingMinMaxMethod;
2730
bool underlyingMinMaxMethodSetFromDefault;
31+
bool extendRelevantValues;
2832
};
2933
} // namespace storm

src/storm/settings/modules/MinMaxEquationSolverSettings.cpp

Lines changed: 45 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,20 @@ const std::string precisionOptionName = "precision";
1919
const std::string absoluteOptionName = "absolute";
2020
const std::string valueIterationMultiplicationStyleOptionName = "vimult";
2121
const std::string forceUniqueSolutionRequirementOptionName = "force-require-unique";
22+
const std::string lpEqualityForUniqueActionsOptionName = "lp-eq-unique-actions";
23+
const std::string lpUseNonTrivialBoundsOptionName = "lp-use-nontrivial-bounds";
24+
const std::string lpOptimizeOnlyInitialStateOptionName = "lp-objective-type";
2225

2326
MinMaxEquationSolverSettings::MinMaxEquationSolverSettings() : ModuleSettings(moduleName) {
24-
std::vector<std::string> minMaxSolvingTechniques = {
25-
"vi", "value-iteration", "pi", "policy-iteration", "lp", "linear-programming", "rs", "ratsearch",
26-
"ii", "interval-iteration", "svi", "sound-value-iteration", "ovi", "optimistic-value-iteration", "topological", "vi-to-pi",
27-
"acyclic"};
27+
std::vector<std::string> minMaxSolvingTechniques = {"vi", "value-iteration",
28+
"pi", "policy-iteration",
29+
"lp", "linear-programming",
30+
"rs", "ratsearch",
31+
"ii", "interval-iteration",
32+
"svi", "sound-value-iteration",
33+
"ovi", "optimistic-value-iteration",
34+
"topological", "vi-to-pi",
35+
"vi-to-lp", "acyclic"};
2836
this->addOption(
2937
storm::settings::OptionBuilder(moduleName, solvingMethodOptionName, false, "Sets which min/max linear equation solving technique is preferred.")
3038
.setIsAdvanced()
@@ -69,6 +77,25 @@ MinMaxEquationSolverSettings::MinMaxEquationSolverSettings() : ModuleSettings(mo
6977
"simplify solving but causes some overhead.")
7078
.setIsAdvanced()
7179
.build());
80+
81+
this->addOption(storm::settings::OptionBuilder(moduleName, lpEqualityForUniqueActionsOptionName, false,
82+
"If set, enforce equality in the LP encoding for actions with a unique state.")
83+
.setIsAdvanced()
84+
.build());
85+
86+
this->addOption(storm::settings::OptionBuilder(moduleName, lpUseNonTrivialBoundsOptionName, false, "If set, use nontrivial bounds in the LP encoding")
87+
.setIsAdvanced()
88+
.build());
89+
90+
std::vector<std::string> optimizationObjectiveTypes = {"all", "onlyinitial"};
91+
this->addOption(
92+
storm::settings::OptionBuilder(moduleName, lpOptimizeOnlyInitialStateOptionName, false, "What objective to prefer")
93+
.setIsAdvanced()
94+
.addArgument(storm::settings::ArgumentBuilder::createStringArgument("optimization-type", "What kind of optimization objective to prefer.")
95+
.addValidatorString(ArgumentValidatorFactory::createMultipleChoiceValidator(optimizationObjectiveTypes))
96+
.setDefaultValueString("all")
97+
.build())
98+
.build());
7299
}
73100

74101
storm::solver::MinMaxMethod MinMaxEquationSolverSettings::getMinMaxEquationSolvingMethod() const {
@@ -91,6 +118,8 @@ storm::solver::MinMaxMethod MinMaxEquationSolverSettings::getMinMaxEquationSolvi
91118
return storm::solver::MinMaxMethod::Topological;
92119
} else if (minMaxEquationSolvingTechnique == "vi-to-pi") {
93120
return storm::solver::MinMaxMethod::ViToPi;
121+
} else if (minMaxEquationSolvingTechnique == "vi-to-lp") {
122+
return storm::solver::MinMaxMethod::ViToLp;
94123
} else if (minMaxEquationSolvingTechnique == "acyclic") {
95124
return storm::solver::MinMaxMethod::Acyclic;
96125
}
@@ -147,6 +176,18 @@ bool MinMaxEquationSolverSettings::isForceUniqueSolutionRequirementSet() const {
147176
return this->getOption(forceUniqueSolutionRequirementOptionName).getHasOptionBeenSet();
148177
}
149178

179+
bool MinMaxEquationSolverSettings::getLpUseOnlyInitialStateAsObjective() const {
180+
return this->getOption(lpOptimizeOnlyInitialStateOptionName).getArgumentByName("optimization-type").getValueAsString() == "onlyinitial";
181+
}
182+
183+
bool MinMaxEquationSolverSettings::getLpUseNonTrivialBounds() const {
184+
return this->getOption(lpUseNonTrivialBoundsOptionName).getHasOptionBeenSet();
185+
}
186+
187+
bool MinMaxEquationSolverSettings::getLpUseEqualityForTrivialActions() const {
188+
return this->getOption(lpEqualityForUniqueActionsOptionName).getHasOptionBeenSet();
189+
}
190+
150191
} // namespace modules
151192
} // namespace settings
152193
} // namespace storm

src/storm/settings/modules/MinMaxEquationSolverSettings.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,19 @@ class MinMaxEquationSolverSettings : public ModuleSettings {
9595
*/
9696
bool isForceUniqueSolutionRequirementSet() const;
9797

98+
/*!
99+
* Retrieves whether only initial states should occur in the optimization objective.
100+
*/
101+
bool getLpUseOnlyInitialStateAsObjective() const;
102+
/*!
103+
* Retrieves whether additional bounds should be used when constructing the LP.
104+
*/
105+
bool getLpUseNonTrivialBounds() const;
106+
/*!
107+
* Retrieves whether equality should be enforced where possible
108+
*/
109+
bool getLpUseEqualityForTrivialActions() const;
110+
98111
// The name of the module.
99112
static const std::string moduleName;
100113
};

0 commit comments

Comments
 (0)