Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improved LpMinMaxLinearEquationSolver, set relevant values in topo solvers #568

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/storm/environment/SubEnvironment.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ template class SubEnvironment<NativeSolverEnvironment>;
template class SubEnvironment<LongRunAverageSolverEnvironment>;
template class SubEnvironment<TimeBoundedSolverEnvironment>;
template class SubEnvironment<MinMaxSolverEnvironment>;
template class SubEnvironment<MinMaxLpSolverEnvironment>;
template class SubEnvironment<MultiplierEnvironment>;
template class SubEnvironment<OviSolverEnvironment>;
template class SubEnvironment<GameSolverEnvironment>;
Expand Down
1 change: 1 addition & 0 deletions src/storm/environment/solver/AllSolverEnvironments.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include "storm/environment/solver/GameSolverEnvironment.h"
#include "storm/environment/solver/GmmxxSolverEnvironment.h"
#include "storm/environment/solver/LongRunAverageSolverEnvironment.h"
#include "storm/environment/solver/MinMaxLpSolverEnvironment.h"
#include "storm/environment/solver/MinMaxSolverEnvironment.h"
#include "storm/environment/solver/MultiplierEnvironment.h"
#include "storm/environment/solver/NativeSolverEnvironment.h"
Expand Down
33 changes: 33 additions & 0 deletions src/storm/environment/solver/MinMaxLpSolverEnvironment.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#include "storm/environment/solver/MinMaxLpSolverEnvironment.h"
#include "storm/settings/SettingsManager.h"
#include "storm/settings/modules/MinMaxEquationSolverSettings.h"

namespace storm {

MinMaxLpSolverEnvironment::MinMaxLpSolverEnvironment() {
auto const& minMaxSettings = storm::settings::getModule<storm::settings::modules::MinMaxEquationSolverSettings>();
useNonTrivialBounds = minMaxSettings.getLpUseNonTrivialBounds();
optimizeOnlyForInitialState = minMaxSettings.getLpUseOnlyInitialStateAsObjective();
useEqualityForSingleActions = minMaxSettings.getLpUseEqualityForTrivialActions();
}

void MinMaxLpSolverEnvironment::setUseEqualityForSingleActions(bool newValue) {
useEqualityForSingleActions = newValue;
}
void MinMaxLpSolverEnvironment::setOptimizeOnlyForInitialState(bool newValue) {
optimizeOnlyForInitialState = newValue;
}
void MinMaxLpSolverEnvironment::setUseNonTrivialBounds(bool newValue) {
useNonTrivialBounds = newValue;
}

bool MinMaxLpSolverEnvironment::getUseEqualityForSingleActions() const {
return useEqualityForSingleActions;
}
bool MinMaxLpSolverEnvironment::getOptimizeOnlyForInitialState() const {
return optimizeOnlyForInitialState;
}
bool MinMaxLpSolverEnvironment::getUseNonTrivialBounds() const {
return useNonTrivialBounds;
}
} // namespace storm
22 changes: 22 additions & 0 deletions src/storm/environment/solver/MinMaxLpSolverEnvironment.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#pragma once

namespace storm {
class MinMaxLpSolverEnvironment {
public:
MinMaxLpSolverEnvironment();
virtual ~MinMaxLpSolverEnvironment() = default;

void setUseEqualityForSingleActions(bool newValue);
void setOptimizeOnlyForInitialState(bool newValue);
void setUseNonTrivialBounds(bool newValue);

bool getUseEqualityForSingleActions() const;
bool getOptimizeOnlyForInitialState() const;
bool getUseNonTrivialBounds() const;

private:
bool useEqualityForSingleActions;
bool optimizeOnlyForInitialState;
bool useNonTrivialBounds;
};
} // namespace storm
8 changes: 8 additions & 0 deletions src/storm/environment/solver/MinMaxSolverEnvironment.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include "storm/environment/solver/MinMaxSolverEnvironment.h"

#include "storm/environment/solver/MinMaxLpSolverEnvironment.h"
#include "storm/settings/SettingsManager.h"
#include "storm/settings/modules/MinMaxEquationSolverSettings.h"
#include "storm/utility/constants.h"
Expand Down Expand Up @@ -76,6 +77,13 @@ void MinMaxSolverEnvironment::setMultiplicationStyle(storm::solver::Multiplicati
multiplicationStyle = value;
}

MinMaxLpSolverEnvironment const& MinMaxSolverEnvironment::lp() const {
return lpEnvironment.get();
}
MinMaxLpSolverEnvironment& MinMaxSolverEnvironment::lp() {
return lpEnvironment.get();
}

bool MinMaxSolverEnvironment::isForceRequireUnique() const {
return forceRequireUnique;
}
Expand Down
5 changes: 5 additions & 0 deletions src/storm/environment/solver/MinMaxSolverEnvironment.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@

namespace storm {

class MinMaxLpSolverEnvironment;

class MinMaxSolverEnvironment {
public:
MinMaxSolverEnvironment();
Expand All @@ -26,6 +28,8 @@ class MinMaxSolverEnvironment {
void setMultiplicationStyle(storm::solver::MultiplicationStyle value);
bool isForceRequireUnique() const;
void setForceRequireUnique(bool value);
MinMaxLpSolverEnvironment const& lp() const;
MinMaxLpSolverEnvironment& lp();

private:
storm::solver::MinMaxMethod minMaxMethod;
Expand All @@ -35,5 +39,6 @@ class MinMaxSolverEnvironment {
bool considerRelativeTerminationCriterion;
storm::solver::MultiplicationStyle multiplicationStyle;
bool forceRequireUnique;
SubEnvironment<MinMaxLpSolverEnvironment> lpEnvironment;
};
} // namespace storm
9 changes: 9 additions & 0 deletions src/storm/environment/solver/TopologicalSolverEnvironment.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ TopologicalSolverEnvironment::TopologicalSolverEnvironment() {

underlyingMinMaxMethod = topologicalSettings.getUnderlyingMinMaxMethod();
underlyingMinMaxMethodSetFromDefault = topologicalSettings.isUnderlyingMinMaxMethodSetFromDefaultValue();
extendRelevantValues = topologicalSettings.isExtendRelevantValues();
}

TopologicalSolverEnvironment::~TopologicalSolverEnvironment() {
Expand Down Expand Up @@ -51,4 +52,12 @@ void TopologicalSolverEnvironment::setUnderlyingMinMaxMethod(storm::solver::MinM
underlyingMinMaxMethod = value;
}

bool TopologicalSolverEnvironment::isExtendRelevantValues() const {
return extendRelevantValues;
}

void TopologicalSolverEnvironment::setExtendRelevantValues(bool value) {
extendRelevantValues = value;
}

} // namespace storm
4 changes: 4 additions & 0 deletions src/storm/environment/solver/TopologicalSolverEnvironment.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,15 @@ class TopologicalSolverEnvironment {
bool const& isUnderlyingMinMaxMethodSetFromDefault() const;
void setUnderlyingMinMaxMethod(storm::solver::MinMaxMethod value);

bool isExtendRelevantValues() const;
void setExtendRelevantValues(bool value);

private:
storm::solver::EquationSolverType underlyingEquationSolverType;
bool underlyingEquationSolverTypeSetFromDefault;

storm::solver::MinMaxMethod underlyingMinMaxMethod;
bool underlyingMinMaxMethodSetFromDefault;
bool extendRelevantValues;
};
} // namespace storm
49 changes: 45 additions & 4 deletions src/storm/settings/modules/MinMaxEquationSolverSettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,20 @@ const std::string precisionOptionName = "precision";
const std::string absoluteOptionName = "absolute";
const std::string valueIterationMultiplicationStyleOptionName = "vimult";
const std::string forceUniqueSolutionRequirementOptionName = "force-require-unique";
const std::string lpEqualityForUniqueActionsOptionName = "lp-eq-unique-actions";
const std::string lpUseNonTrivialBoundsOptionName = "lp-use-nontrivial-bounds";
const std::string lpOptimizeOnlyInitialStateOptionName = "lp-objective-type";

MinMaxEquationSolverSettings::MinMaxEquationSolverSettings() : ModuleSettings(moduleName) {
std::vector<std::string> minMaxSolvingTechniques = {
"vi", "value-iteration", "pi", "policy-iteration", "lp", "linear-programming", "rs", "ratsearch",
"ii", "interval-iteration", "svi", "sound-value-iteration", "ovi", "optimistic-value-iteration", "topological", "vi-to-pi",
"acyclic"};
std::vector<std::string> minMaxSolvingTechniques = {"vi", "value-iteration",
"pi", "policy-iteration",
"lp", "linear-programming",
"rs", "ratsearch",
"ii", "interval-iteration",
"svi", "sound-value-iteration",
"ovi", "optimistic-value-iteration",
"topological", "vi-to-pi",
"vi-to-lp", "acyclic"};
this->addOption(
storm::settings::OptionBuilder(moduleName, solvingMethodOptionName, false, "Sets which min/max linear equation solving technique is preferred.")
.setIsAdvanced()
Expand Down Expand Up @@ -69,6 +77,25 @@ MinMaxEquationSolverSettings::MinMaxEquationSolverSettings() : ModuleSettings(mo
"simplify solving but causes some overhead.")
.setIsAdvanced()
.build());

this->addOption(storm::settings::OptionBuilder(moduleName, lpEqualityForUniqueActionsOptionName, false,
"If set, enforce equality in the LP encoding for actions with a unique state.")
.setIsAdvanced()
.build());

this->addOption(storm::settings::OptionBuilder(moduleName, lpUseNonTrivialBoundsOptionName, false, "If set, use nontrivial bounds in the LP encoding")
.setIsAdvanced()
.build());

std::vector<std::string> optimizationObjectiveTypes = {"all", "onlyinitial"};
this->addOption(
storm::settings::OptionBuilder(moduleName, lpOptimizeOnlyInitialStateOptionName, false, "What objective to prefer")
.setIsAdvanced()
.addArgument(storm::settings::ArgumentBuilder::createStringArgument("optimization-type", "What kind of optimization objective to prefer.")
.addValidatorString(ArgumentValidatorFactory::createMultipleChoiceValidator(optimizationObjectiveTypes))
.setDefaultValueString("all")
.build())
.build());
}

storm::solver::MinMaxMethod MinMaxEquationSolverSettings::getMinMaxEquationSolvingMethod() const {
Expand All @@ -91,6 +118,8 @@ storm::solver::MinMaxMethod MinMaxEquationSolverSettings::getMinMaxEquationSolvi
return storm::solver::MinMaxMethod::Topological;
} else if (minMaxEquationSolvingTechnique == "vi-to-pi") {
return storm::solver::MinMaxMethod::ViToPi;
} else if (minMaxEquationSolvingTechnique == "vi-to-lp") {
return storm::solver::MinMaxMethod::ViToLp;
} else if (minMaxEquationSolvingTechnique == "acyclic") {
return storm::solver::MinMaxMethod::Acyclic;
}
Expand Down Expand Up @@ -147,6 +176,18 @@ bool MinMaxEquationSolverSettings::isForceUniqueSolutionRequirementSet() const {
return this->getOption(forceUniqueSolutionRequirementOptionName).getHasOptionBeenSet();
}

bool MinMaxEquationSolverSettings::getLpUseOnlyInitialStateAsObjective() const {
return this->getOption(lpOptimizeOnlyInitialStateOptionName).getArgumentByName("optimization-type").getValueAsString() == "onlyinitial";
}

bool MinMaxEquationSolverSettings::getLpUseNonTrivialBounds() const {
return this->getOption(lpUseNonTrivialBoundsOptionName).getHasOptionBeenSet();
}

bool MinMaxEquationSolverSettings::getLpUseEqualityForTrivialActions() const {
return this->getOption(lpEqualityForUniqueActionsOptionName).getHasOptionBeenSet();
}

} // namespace modules
} // namespace settings
} // namespace storm
13 changes: 13 additions & 0 deletions src/storm/settings/modules/MinMaxEquationSolverSettings.h
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,19 @@ class MinMaxEquationSolverSettings : public ModuleSettings {
*/
bool isForceUniqueSolutionRequirementSet() const;

/*!
* Retrieves whether only initial states should occur in the optimization objective.
*/
bool getLpUseOnlyInitialStateAsObjective() const;
/*!
* Retrieves whether additional bounds should be used when constructing the LP.
*/
bool getLpUseNonTrivialBounds() const;
/*!
* Retrieves whether equality should be enforced where possible
*/
bool getLpUseEqualityForTrivialActions() const;

// The name of the module.
static const std::string moduleName;
};
Expand Down
16 changes: 14 additions & 2 deletions src/storm/settings/modules/TopologicalEquationSolverSettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ namespace modules {
const std::string TopologicalEquationSolverSettings::moduleName = "topological";
const std::string TopologicalEquationSolverSettings::underlyingEquationSolverOptionName = "eqsolver";
const std::string TopologicalEquationSolverSettings::underlyingMinMaxMethodOptionName = "minmax";
const std::string TopologicalEquationSolverSettings::extendRelevantValuesOptionName = "relevant-values";

TopologicalEquationSolverSettings::TopologicalEquationSolverSettings() : ModuleSettings(moduleName) {
std::vector<std::string> linearEquationSolver = {"gmm++", "native", "eigen", "elimination"};
Expand All @@ -35,8 +36,8 @@ TopologicalEquationSolverSettings::TopologicalEquationSolverSettings() : ModuleS
.build())
.build());
std::vector<std::string> minMaxSolvingTechniques = {
"vi", "value-iteration", "pi", "policy-iteration", "lp", "linear-programming", "rs", "ratsearch",
"ii", "interval-iteration", "svi", "sound-value-iteration", "ovi", "optimistic-value-iteration", "vi-to-pi"};
"vi", "value-iteration", "pi", "policy-iteration", "lp", "linear-programming", "rs", "ratsearch",
"ii", "interval-iteration", "svi", "sound-value-iteration", "ovi", "optimistic-value-iteration", "vi-to-pi", "vi-to-lp"};
this->addOption(storm::settings::OptionBuilder(moduleName, underlyingMinMaxMethodOptionName, true,
"Sets which minmax method is considered for solving the underlying minmax equation systems.")
.setIsAdvanced()
Expand All @@ -45,6 +46,11 @@ TopologicalEquationSolverSettings::TopologicalEquationSolverSettings() : ModuleS
.setDefaultValueString("value-iteration")
.build())
.build());

this->addOption(
storm::settings::OptionBuilder(moduleName, extendRelevantValuesOptionName, true, "Sets whether relevant values are set to the underlying solver.")
.setIsAdvanced()
.build());
}

bool TopologicalEquationSolverSettings::isUnderlyingEquationSolverTypeSet() const {
Expand Down Expand Up @@ -97,11 +103,17 @@ storm::solver::MinMaxMethod TopologicalEquationSolverSettings::getUnderlyingMinM
return storm::solver::MinMaxMethod::OptimisticValueIteration;
} else if (minMaxEquationSolvingTechnique == "vi-to-pi") {
return storm::solver::MinMaxMethod::ViToPi;
} else if (minMaxEquationSolvingTechnique == "vi-to-lp") {
return storm::solver::MinMaxMethod::ViToLp;
}

STORM_LOG_THROW(false, storm::exceptions::IllegalArgumentValueException, "Unknown underlying equation solver '" << minMaxEquationSolvingTechnique << "'.");
}

bool TopologicalEquationSolverSettings::isExtendRelevantValues() const {
return this->getOption(extendRelevantValuesOptionName).getHasOptionBeenSet();
}

bool TopologicalEquationSolverSettings::check() const {
if (this->isUnderlyingEquationSolverTypeSet() && getUnderlyingEquationSolverType() == storm::solver::EquationSolverType::Topological) {
STORM_LOG_WARN("Underlying solver type of the topological solver can not be the topological solver.");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,11 @@ class TopologicalEquationSolverSettings : public ModuleSettings {
*/
storm::solver::MinMaxMethod getUnderlyingMinMaxMethod() const;

/*!
* If true, the relevant states of each SCC are computed and passed to the underlying equation solver.
*/
bool isExtendRelevantValues() const;

bool check() const override;

// The name of the module.
Expand All @@ -69,6 +74,7 @@ class TopologicalEquationSolverSettings : public ModuleSettings {
// Define the string names of the options as constants.
static const std::string underlyingEquationSolverOptionName;
static const std::string underlyingMinMaxMethodOptionName;
static const std::string extendRelevantValuesOptionName;
};

} // namespace modules
Expand Down
5 changes: 5 additions & 0 deletions src/storm/solver/AbstractEquationSolver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,11 @@ void AbstractEquationSolver<ValueType>::setRelevantValues(storm::storage::BitVec
this->relevantValues = std::move(relevantValues);
}

template<typename ValueType>
void AbstractEquationSolver<ValueType>::setRelevantValues(storm::storage::BitVector const& relevantValues) {
this->relevantValues = relevantValues;
}

template<typename ValueType>
void AbstractEquationSolver<ValueType>::clearRelevantValues() {
relevantValues = boost::none;
Expand Down
5 changes: 5 additions & 0 deletions src/storm/solver/AbstractEquationSolver.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,11 @@ class AbstractEquationSolver {
*/
void setRelevantValues(storm::storage::BitVector&& valuesOfInterest);

/*!
* Sets the relevant values.
*/
void setRelevantValues(storm::storage::BitVector const& valuesOfInterest);

/*!
* Removes the values of interest (if there were any).
*/
Expand Down
Loading
Loading