Storm 2.0.0.3
A Modern Probabilistic Model Checker
Loading...
Searching...
No Matches
HighsLpSolver.cpp
Go to the documentation of this file.
2
3#include <cmath>
4#include <limits>
5
18
19namespace storm {
20namespace solver {
21
22#ifdef STORM_HAVE_HIGHS
23
24namespace {
25
26constexpr double highInfinity = std::numeric_limits<double>::infinity();
27
28// LP solvers cannot represent strict inequalities. As for GLPK and Gurobi, they are approximated by shifting the right-hand side by this margin.
29constexpr double strictInequalityMargin = 1e-06;
30
31struct HighsConstraintData {
32 std::vector<HighsInt> variableIndices;
33 std::vector<double> coefficients;
34 double rhs;
36};
37
38template<typename ValueType, bool RawMode>
39HighsConstraintData createConstraintData(typename HighsLpSolver<ValueType, RawMode>::Constraint const& constraint,
40 std::map<storm::expressions::Variable, uint64_t> const& variableToIndexMap) {
41 HighsConstraintData result;
42 if constexpr (RawMode) {
43 result.rhs = storm::utility::convertNumber<double>(constraint.rhs);
44 result.relationType = constraint.relationType;
45 result.variableIndices.reserve(constraint.lhsVariableIndices.size());
46 result.coefficients.reserve(constraint.lhsCoefficients.size());
47 for (auto const& variable : constraint.lhsVariableIndices) {
48 result.variableIndices.push_back(static_cast<HighsInt>(variable));
49 }
50 for (auto const& coefficient : constraint.lhsCoefficients) {
51 result.coefficients.push_back(storm::utility::convertNumber<double>(coefficient));
52 }
53 } else {
54 STORM_LOG_THROW(constraint.isRelationalExpression(), storm::exceptions::InvalidArgumentException, "Illegal constraint is not a relational expression.");
55 storm::expressions::LinearCoefficientVisitor<double>::VariableCoefficients leftCoefficients =
56 storm::expressions::LinearCoefficientVisitor<double>().getLinearCoefficients(constraint.getOperand(0));
57 storm::expressions::LinearCoefficientVisitor<double>::VariableCoefficients rightCoefficients =
58 storm::expressions::LinearCoefficientVisitor<double>().getLinearCoefficients(constraint.getOperand(1));
59 leftCoefficients.separateVariablesFromConstantPart(rightCoefficients);
60 result.rhs = storm::utility::convertNumber<double>(rightCoefficients.getConstantPart());
61 result.relationType = constraint.getBaseExpression().asBinaryRelationExpression().getRelationType();
62 result.variableIndices.reserve(leftCoefficients.size());
63 result.coefficients.reserve(leftCoefficients.size());
64 for (auto const& variableCoefficientPair : leftCoefficients) {
65 auto variableIndexPair = variableToIndexMap.find(variableCoefficientPair.first);
66 result.variableIndices.push_back(static_cast<HighsInt>(variableIndexPair->second));
67 result.coefficients.push_back(storm::utility::convertNumber<double>(variableCoefficientPair.second));
68 }
69 }
70 if (result.relationType == storm::expressions::RelationType::Less) {
72 result.rhs -= strictInequalityMargin;
73 } else if (result.relationType == storm::expressions::RelationType::Greater) {
75 result.rhs += strictInequalityMargin;
76 }
77 return result;
78}
79
80} // namespace
81
82template<typename ValueType, bool RawMode>
84 : LpSolver<ValueType, RawMode>(optDir), nextVariableIndex(0) {
85 // By default, HiGHS prints its log to the command line. We disable this as storm provides its own logging.
86 highs.setOptionValue("output_flag", false);
87 // The MIP feasibility tolerance must be below the strictInequalityMargin, otherwise strict and non-strict constraints become indistinguishable.
88 highs.setOptionValue("mip_feasibility_tolerance", strictInequalityMargin / 10);
89}
90
91template<typename ValueType, bool RawMode>
92HighsLpSolver<ValueType, RawMode>::HighsLpSolver(std::string const& name) : HighsLpSolver(name, OptimizationDirection::Minimize) {}
93
94template<typename ValueType, bool RawMode>
95HighsLpSolver<ValueType, RawMode>::HighsLpSolver(OptimizationDirection const& optDir) : HighsLpSolver("", optDir) {}
96
97template<typename ValueType, bool RawMode>
98HighsLpSolver<ValueType, RawMode>::HighsLpSolver() : HighsLpSolver("", OptimizationDirection::Minimize) {}
99
100template<typename ValueType, bool RawMode>
101HighsLpSolver<ValueType, RawMode>::~HighsLpSolver() {}
102
103template<typename ValueType, bool RawMode>
104double HighsLpSolver<ValueType, RawMode>::toHighsBound(double value) const {
105 if (!std::isfinite(value)) {
106 return value > 0 ? highs.getInfinity() : -highs.getInfinity();
107 }
108 return value;
109}
110
111template<typename ValueType, bool RawMode>
112typename HighsLpSolver<ValueType, RawMode>::Variable HighsLpSolver<ValueType, RawMode>::addVariable(std::string const& name, VariableType const& type,
113 std::optional<ValueType> const& lowerBound,
114 std::optional<ValueType> const& upperBound,
115 ValueType objectiveFunctionCoefficient) {
116 Variable resultVar;
117 if constexpr (RawMode) {
118 resultVar = nextVariableIndex;
119 } else {
120 resultVar = this->declareOrGetExpressionVariable(name, type);
121 STORM_LOG_ASSERT(variableToIndexMap.count(resultVar) == 0, "Variable " << resultVar.getName() << " exists already in the model.");
122 this->variableToIndexMap.emplace(resultVar, nextVariableIndex);
123 }
124
125 double lower = lowerBound.has_value() ? storm::utility::convertNumber<double>(*lowerBound) : -highInfinity;
126 double upper = upperBound.has_value() ? storm::utility::convertNumber<double>(*upperBound) : highInfinity;
127 if (type == VariableType::Binary) {
128 lower = 0.0;
129 upper = 1.0;
130 }
131
132 HighsStatus addColStatus =
133 highs.addCol(storm::utility::convertNumber<double>(objectiveFunctionCoefficient), toHighsBound(lower), toHighsBound(upper), 0, nullptr, nullptr);
134 STORM_LOG_THROW(addColStatus != HighsStatus::kError, storm::exceptions::InvalidStateException, "Unable to add variable to HiGHS model.");
135 HighsInt column = static_cast<HighsInt>(nextVariableIndex);
136
137 if (type != VariableType::Continuous) {
138 HighsStatus integralityStatus = highs.changeColIntegrality(column, HighsVarType::kInteger);
139 STORM_LOG_THROW(integralityStatus != HighsStatus::kError, storm::exceptions::InvalidStateException, "Unable to set integrality of HiGHS variable.");
140 }
141 if (!name.empty()) {
142 highs.passColName(column, name);
143 }
144
145 variableBounds.emplace_back(lower, upper);
146 ++nextVariableIndex;
147 return resultVar;
148}
149
150template<typename ValueType, bool RawMode>
151void HighsLpSolver<ValueType, RawMode>::update() const {
152 // HiGHS accepts incremental changes to the model at any point in time, so there is nothing to do here.
153}
154
155template<typename ValueType, bool RawMode>
156void HighsLpSolver<ValueType, RawMode>::addConstraint(std::string const&, Constraint const& constraint) {
157 if constexpr (!RawMode) {
158 STORM_LOG_ASSERT(constraint.getManager() == this->getManager(), "Constraint was not built over the proper variables.");
159 }
160
161 auto constraintData = createConstraintData<ValueType, RawMode>(constraint, this->variableToIndexMap);
162
163 double lower, upper;
164 switch (constraintData.relationType) {
166 lower = -highInfinity;
167 upper = constraintData.rhs;
168 break;
170 lower = constraintData.rhs;
171 upper = highInfinity;
172 break;
174 lower = constraintData.rhs;
175 upper = constraintData.rhs;
176 break;
177 default:
178 STORM_LOG_ASSERT(false, "Illegal operator in LP solver constraint.");
179 }
180 highs.addRow(toHighsBound(lower), toHighsBound(upper), constraintData.variableIndices.size(), constraintData.variableIndices.data(),
181 constraintData.coefficients.data());
182}
183
184template<typename ValueType, bool RawMode>
185void HighsLpSolver<ValueType, RawMode>::addIndicatorConstraint(std::string const&, Variable indicatorVariable, bool indicatorValue,
186 Constraint const& constraint) {
187 if constexpr (RawMode) {
188 STORM_LOG_THROW(false, storm::exceptions::NotImplementedException, "Indicator constraints not implemented in RawMode.");
189 } else {
190 STORM_LOG_ASSERT(this->variableToIndexMap.count(indicatorVariable) > 0, "Indicator Variable " << indicatorVariable.getName() << " unknown to solver.");
191 STORM_LOG_ASSERT(indicatorVariable.hasIntegerType(), "Indicator Variable " << indicatorVariable.getName() << " has unexpected type.");
192 STORM_LOG_ASSERT(constraint.getManager() == this->getManager(), "Constraint was not built over the proper variables.");
193
194 auto constraintData = createConstraintData<ValueType, RawMode>(constraint, this->variableToIndexMap);
195
196 // HiGHS does not support indicator constraints natively. Instead, we apply a big-M reformulation that reuses the binary indicator variable.
197 // To this end, we compute bounds on the activity of the constraint's linear expression over the box given by the variable bounds.
198 double minActivity = 0.0;
199 double maxActivity = 0.0;
200 for (std::size_t i = 0; i < constraintData.variableIndices.size(); ++i) {
201 double coefficient = constraintData.coefficients[i];
202 auto const& bounds = variableBounds[constraintData.variableIndices[i]];
203 double lowerBound = bounds.first;
204 double upperBound = bounds.second;
205 if (coefficient > 0) {
206 maxActivity += coefficient * (std::isfinite(upperBound) ? upperBound : highInfinity);
207 minActivity += coefficient * (std::isfinite(lowerBound) ? lowerBound : -highInfinity);
208 } else if (coefficient < 0) {
209 maxActivity += coefficient * (std::isfinite(lowerBound) ? lowerBound : -highInfinity);
210 minActivity += coefficient * (std::isfinite(upperBound) ? upperBound : highInfinity);
211 }
212 }
213
214 HighsInt indicatorIndex = static_cast<HighsInt>(this->variableToIndexMap.at(indicatorVariable));
215
216 auto addIndicatorRow = [this, &constraintData, indicatorIndex](double mCoefficient, double newRhs, bool isLessEqual) {
217 std::vector<HighsInt> variableIndices = constraintData.variableIndices;
218 std::vector<double> coefficients = constraintData.coefficients;
219 variableIndices.push_back(indicatorIndex);
220 coefficients.push_back(mCoefficient);
221 double lower = -highInfinity;
222 double upper = highInfinity;
223 if (isLessEqual) {
224 upper = newRhs;
225 } else {
226 lower = newRhs;
227 }
228 highs.addRow(toHighsBound(lower), toHighsBound(upper), variableIndices.size(), variableIndices.data(), coefficients.data());
229 };
230
231 auto addSingleIndicatorConstraint = [&](bool isLessEqual, bool indicatorValue) {
232 double m;
233 if (isLessEqual) {
234 m = maxActivity - constraintData.rhs;
235 } else {
236 m = constraintData.rhs - minActivity;
237 }
238 STORM_LOG_THROW(std::isfinite(m), storm::exceptions::NotSupportedException,
239 "Indicator constraints over unbounded variables are not supported by the HiGHS solver.");
240 double mCoefficient = (indicatorValue == isLessEqual) ? m : -m;
241 double newRhs = constraintData.rhs;
242 if (indicatorValue) {
243 newRhs += isLessEqual ? m : -m;
244 }
245 addIndicatorRow(mCoefficient, newRhs, isLessEqual);
246 };
247
248 switch (constraintData.relationType) {
250 addSingleIndicatorConstraint(true, indicatorValue);
251 break;
253 addSingleIndicatorConstraint(false, indicatorValue);
254 break;
256 addSingleIndicatorConstraint(true, indicatorValue);
257 addSingleIndicatorConstraint(false, indicatorValue);
258 break;
259 default:
260 STORM_LOG_ASSERT(false, "Illegal operator in LP solver constraint.");
261 }
262 }
263}
264
265template<typename ValueType, bool RawMode>
266void HighsLpSolver<ValueType, RawMode>::optimize() const {
267 // First incorporate all recent changes.
268 this->update();
269
270 // Set the model sense.
271 highs.changeObjectiveSense(this->getOptimizationDirection() == OptimizationDirection::Minimize ? ObjSense::kMinimize : ObjSense::kMaximize);
272
273 // Then we actually optimize the model.
274 HighsStatus status = highs.run();
275 STORM_LOG_THROW(status != HighsStatus::kError, storm::exceptions::InvalidStateException,
276 "Unable to optimize the model with HiGHS (model status: " << highs.modelStatusToString(highs.getModelStatus()) << ").");
277
278 this->currentModelHasBeenOptimized = true;
279 modelStatus = highs.getModelStatus();
280}
281
282template<typename ValueType, bool RawMode>
283bool HighsLpSolver<ValueType, RawMode>::isInfeasible() const {
284 STORM_LOG_THROW(this->currentModelHasBeenOptimized, storm::exceptions::InvalidStateException,
285 "Illegal call to HighsLpSolver<ValueType, RawMode>::isInfeasible: model has not been optimized.");
286 return modelStatus == HighsModelStatus::kInfeasible;
287}
288
289template<typename ValueType, bool RawMode>
290bool HighsLpSolver<ValueType, RawMode>::isUnbounded() const {
291 STORM_LOG_THROW(this->currentModelHasBeenOptimized, storm::exceptions::InvalidStateException,
292 "Illegal call to HighsLpSolver<ValueType, RawMode>::isUnbounded: model has not been optimized.");
293 return modelStatus == HighsModelStatus::kUnbounded || modelStatus == HighsModelStatus::kUnboundedOrInfeasible;
294}
295
296template<typename ValueType, bool RawMode>
297bool HighsLpSolver<ValueType, RawMode>::isOptimal() const {
298 if (!this->currentModelHasBeenOptimized) {
299 return false;
300 }
301 return modelStatus == HighsModelStatus::kOptimal;
302}
303
304template<typename ValueType, bool RawMode>
305ValueType HighsLpSolver<ValueType, RawMode>::getContinuousValue(Variable const& variable) const {
306 STORM_LOG_THROW(this->isOptimal(), storm::exceptions::InvalidAccessException,
307 "Unable to get HiGHS solution from a model that has not been solved optimally.");
308
309 uint64_t variableIndex;
310 if constexpr (RawMode) {
311 variableIndex = variable;
312 } else {
313 STORM_LOG_THROW(variableToIndexMap.count(variable) != 0, storm::exceptions::InvalidAccessException,
314 "Accessing value of unknown variable '" << variable.getName() << "'.");
315 variableIndex = variableToIndexMap.at(variable);
316 }
317 STORM_LOG_ASSERT(variableIndex < nextVariableIndex, "Variable Index exceeds highest value.");
318
319 return storm::utility::convertNumber<ValueType>(highs.getSolution().col_value[variableIndex]);
320}
321
322template<typename ValueType, bool RawMode>
323int_fast64_t HighsLpSolver<ValueType, RawMode>::getIntegerValue(Variable const& variable) const {
324 STORM_LOG_THROW(this->isOptimal(), storm::exceptions::InvalidAccessException,
325 "Unable to get HiGHS solution from a model that has not been solved optimally.");
326
327 uint64_t variableIndex;
328 if constexpr (RawMode) {
329 variableIndex = variable;
330 } else {
331 STORM_LOG_THROW(variableToIndexMap.count(variable) != 0, storm::exceptions::InvalidAccessException,
332 "Accessing value of unknown variable '" << variable.getName() << "'.");
333 variableIndex = variableToIndexMap.at(variable);
334 }
335 STORM_LOG_ASSERT(variableIndex < nextVariableIndex, "Variable Index exceeds highest value.");
336
337 return std::llround(highs.getSolution().col_value[variableIndex]);
338}
339
340template<typename ValueType, bool RawMode>
341bool HighsLpSolver<ValueType, RawMode>::getBinaryValue(Variable const& variable) const {
342 STORM_LOG_THROW(this->isOptimal(), storm::exceptions::InvalidAccessException,
343 "Unable to get HiGHS solution from a model that has not been solved optimally.");
344
345 uint64_t variableIndex;
346 if constexpr (RawMode) {
347 variableIndex = variable;
348 } else {
349 STORM_LOG_THROW(variableToIndexMap.count(variable) != 0, storm::exceptions::InvalidAccessException,
350 "Accessing value of unknown variable '" << variable.getName() << "'.");
351 variableIndex = variableToIndexMap.at(variable);
352 }
353 STORM_LOG_ASSERT(variableIndex < nextVariableIndex, "Variable Index exceeds highest value.");
354
355 return highs.getSolution().col_value[variableIndex] > 0.5;
356}
357
358template<typename ValueType, bool RawMode>
359ValueType HighsLpSolver<ValueType, RawMode>::getObjectiveValue() const {
360 STORM_LOG_THROW(this->isOptimal(), storm::exceptions::InvalidAccessException,
361 "Unable to get HiGHS solution from a model that has not been solved optimally.");
362 return storm::utility::convertNumber<ValueType>(highs.getObjectiveValue());
363}
364
365template<typename ValueType, bool RawMode>
366void HighsLpSolver<ValueType, RawMode>::writeModelToFile(std::string const& filename) const {
367 HighsStatus status = highs.writeModel(filename);
368 STORM_LOG_THROW(status != HighsStatus::kError, storm::exceptions::InvalidStateException, "Unable to write HiGHS model to file '" << filename << "'.");
369}
370
371template<typename ValueType, bool RawMode>
372void HighsLpSolver<ValueType, RawMode>::push() {
373 if constexpr (RawMode) {
374 STORM_LOG_THROW(false, storm::exceptions::InvalidOperationException, "Incremental LP solving not supported in raw mode.");
375 } else {
376 IncrementalLevel lvl;
377 lvl.firstRowIndex = highs.getNumRow();
378 lvl.firstVariableIndex = nextVariableIndex;
379 incrementalData.push_back(lvl);
380 }
381}
382
383template<typename ValueType, bool RawMode>
384void HighsLpSolver<ValueType, RawMode>::pop() {
385 if constexpr (RawMode) {
386 STORM_LOG_THROW(false, storm::exceptions::InvalidOperationException, "Incremental LP solving not supported in raw mode.");
387 } else {
388 if (incrementalData.empty()) {
389 STORM_LOG_ERROR("Tried to pop from a solver without pushing before.");
390 return;
391 }
392 IncrementalLevel const lvl = incrementalData.back();
393 incrementalData.pop_back();
394 this->currentModelHasBeenOptimized = false;
395 // Remove the rows (including those encoding indicator constraints) added since the matching push.
396 // Rows must be removed before columns, as removing columns would otherwise shrink rows that refer to them.
397 HighsInt const numRows = highs.getNumRow();
398 if (numRows > lvl.firstRowIndex) {
399 HighsStatus status = highs.deleteRows(lvl.firstRowIndex, numRows - 1);
400 STORM_LOG_THROW(status != HighsStatus::kError, storm::exceptions::InvalidStateException, "Unable to delete constraints from HiGHS model.");
401 }
402 // Remove the variables added since the matching push.
403 if (nextVariableIndex > lvl.firstVariableIndex) {
404 HighsStatus status = highs.deleteCols(static_cast<HighsInt>(lvl.firstVariableIndex), static_cast<HighsInt>(nextVariableIndex - 1));
405 STORM_LOG_THROW(status != HighsStatus::kError, storm::exceptions::InvalidStateException, "Unable to delete variables from HiGHS model.");
406 for (auto it = variableToIndexMap.begin(); it != variableToIndexMap.end();) {
407 if (it->second >= lvl.firstVariableIndex) {
408 it = variableToIndexMap.erase(it);
409 } else {
410 ++it;
411 }
412 }
413 variableBounds.resize(lvl.firstVariableIndex);
414 nextVariableIndex = lvl.firstVariableIndex;
415 }
416 }
417}
418
419template<typename ValueType, bool RawMode>
420void HighsLpSolver<ValueType, RawMode>::setMaximalMILPGap(ValueType const& gap, bool relative) {
421 double gapAsDouble = storm::utility::convertNumber<double>(gap);
422 HighsStatus status = relative ? highs.setOptionValue("mip_rel_gap", gapAsDouble) : highs.setOptionValue("mip_abs_gap", gapAsDouble);
423 STORM_LOG_THROW(status != HighsStatus::kError, storm::exceptions::InvalidStateException, "Unable to set HiGHS MILP gap.");
424}
425
426template<typename ValueType, bool RawMode>
427ValueType HighsLpSolver<ValueType, RawMode>::getMILPGap(bool relative) const {
428 auto const& info = highs.getInfo();
429 // HiGHS reports the relative MILP gap as a percentage.
430 double relativeGap = info.mip_gap / 100.0;
431 auto result = storm::utility::convertNumber<ValueType>(relativeGap);
432 if (relative) {
433 return result;
434 } else {
435 return storm::utility::abs<ValueType>(result * getObjectiveValue());
436 }
437}
438
439#else
440
441template<typename ValueType, bool RawMode>
443 STORM_LOG_THROW(false, storm::exceptions::MissingLibraryException,
444 "This version of storm was compiled without support for HiGHS. Yet, a method was called that requires this support. Please choose a "
445 "version of storm with HiGHS support.");
446}
447
448template<typename ValueType, bool RawMode>
450 STORM_LOG_THROW(false, storm::exceptions::MissingLibraryException,
451 "This version of storm was compiled without support for HiGHS. Yet, a method was called that requires this support. Please choose a "
452 "version of storm with HiGHS support.");
453}
454
455template<typename ValueType, bool RawMode>
457 STORM_LOG_THROW(false, storm::exceptions::MissingLibraryException,
458 "This version of storm was compiled without support for HiGHS. Yet, a method was called that requires this support. Please choose a "
459 "version of storm with HiGHS support.");
460}
461
462template<typename ValueType, bool RawMode>
464 STORM_LOG_THROW(false, storm::exceptions::MissingLibraryException,
465 "This version of storm was compiled without support for HiGHS. Yet, a method was called that requires this support. Please choose a "
466 "version of storm with HiGHS support.");
467}
468
469template<typename ValueType, bool RawMode>
471
472template<typename ValueType, bool RawMode>
474 std::optional<ValueType> const&,
475 std::optional<ValueType> const&, ValueType) {
476 STORM_LOG_THROW(false, storm::exceptions::MissingLibraryException,
477 "This version of storm was compiled without support for HiGHS. Yet, a method was called that requires this support. Please choose a "
478 "version of storm with HiGHS support.");
479}
480
481template<typename ValueType, bool RawMode>
483 STORM_LOG_THROW(false, storm::exceptions::MissingLibraryException,
484 "This version of storm was compiled without support for HiGHS. Yet, a method was called that requires this support. Please choose a "
485 "version of storm with HiGHS support.");
486}
487
488template<typename ValueType, bool RawMode>
490 STORM_LOG_THROW(false, storm::exceptions::MissingLibraryException,
491 "This version of storm was compiled without support for HiGHS. Yet, a method was called that requires this support. Please choose a "
492 "version of storm with HiGHS support.");
493}
494
495template<typename ValueType, bool RawMode>
497 STORM_LOG_THROW(false, storm::exceptions::MissingLibraryException,
498 "This version of storm was compiled without support for HiGHS. Yet, a method was called that requires this support. Please choose a "
499 "version of storm with HiGHS support.");
500}
501
502template<typename ValueType, bool RawMode>
504 STORM_LOG_THROW(false, storm::exceptions::MissingLibraryException,
505 "This version of storm was compiled without support for HiGHS. Yet, a method was called that requires this support. Please choose a "
506 "version of storm with HiGHS support.");
507}
508
509template<typename ValueType, bool RawMode>
511 STORM_LOG_THROW(false, storm::exceptions::MissingLibraryException,
512 "This version of storm was compiled without support for HiGHS. Yet, a method was called that requires this support. Please choose a "
513 "version of storm with HiGHS support.");
514}
515
516template<typename ValueType, bool RawMode>
518 STORM_LOG_THROW(false, storm::exceptions::MissingLibraryException,
519 "This version of storm was compiled without support for HiGHS. Yet, a method was called that requires this support. Please choose a "
520 "version of storm with HiGHS support.");
521}
522
523template<typename ValueType, bool RawMode>
525 STORM_LOG_THROW(false, storm::exceptions::MissingLibraryException,
526 "This version of storm was compiled without support for HiGHS. Yet, a method was called that requires this support. Please choose a "
527 "version of storm with HiGHS support.");
528}
529
530template<typename ValueType, bool RawMode>
532 STORM_LOG_THROW(false, storm::exceptions::MissingLibraryException,
533 "This version of storm was compiled without support for HiGHS. Yet, a method was called that requires this support. Please choose a "
534 "version of storm with HiGHS support.");
535}
536
537template<typename ValueType, bool RawMode>
539 STORM_LOG_THROW(false, storm::exceptions::MissingLibraryException,
540 "This version of storm was compiled without support for HiGHS. Yet, a method was called that requires this support. Please choose a "
541 "version of storm with HiGHS support.");
542}
543
544template<typename ValueType, bool RawMode>
546 STORM_LOG_THROW(false, storm::exceptions::MissingLibraryException,
547 "This version of storm was compiled without support for HiGHS. Yet, a method was called that requires this support. Please choose a "
548 "version of storm with HiGHS support.");
549}
550
551template<typename ValueType, bool RawMode>
553 STORM_LOG_THROW(false, storm::exceptions::MissingLibraryException,
554 "This version of storm was compiled without support for HiGHS. Yet, a method was called that requires this support. Please choose a "
555 "version of storm with HiGHS support.");
556}
557
558template<typename ValueType, bool RawMode>
560 STORM_LOG_THROW(false, storm::exceptions::MissingLibraryException,
561 "This version of storm was compiled without support for HiGHS. Yet, a method was called that requires this support. Please choose a "
562 "version of storm with HiGHS support.");
563}
564
565template<typename ValueType, bool RawMode>
567 STORM_LOG_THROW(false, storm::exceptions::MissingLibraryException,
568 "This version of storm was compiled without support for HiGHS. Yet, a method was called that requires this support. Please choose a "
569 "version of storm with HiGHS support.");
570}
571
572template<typename ValueType, bool RawMode>
574 STORM_LOG_THROW(false, storm::exceptions::MissingLibraryException,
575 "This version of storm was compiled without support for HiGHS. Yet, a method was called that requires this support. Please choose a "
576 "version of storm with HiGHS support.");
577}
578
579template<typename ValueType, bool RawMode>
581 STORM_LOG_THROW(false, storm::exceptions::MissingLibraryException,
582 "This version of storm was compiled without support for HiGHS. Yet, a method was called that requires this support. Please choose a "
583 "version of storm with HiGHS support.");
584}
585
586template<typename ValueType, bool RawMode>
588 STORM_LOG_THROW(false, storm::exceptions::MissingLibraryException,
589 "This version of storm was compiled without support for HiGHS. Yet, a method was called that requires this support. Please choose a "
590 "version of storm with HiGHS support.");
591}
592
593#endif
594
595template class HighsLpSolver<double, true>;
596template class HighsLpSolver<double, false>;
597
598} // namespace solver
599} // namespace storm
A class that implements the LpSolver interface using HiGHS.
virtual void optimize() const override
Optimizes the LP problem previously constructed.
virtual void update() const override
Updates the model to make the variables that have been declared since the last call to update usable.
HighsLpSolver(std::string const &name, OptimizationDirection const &optDir)
Constructs a solver with the given name and model sense.
virtual void addConstraint(std::string const &name, Constraint const &constraint) override
Adds a the given constraint to the LP problem.
virtual void setMaximalMILPGap(ValueType const &gap, bool relative) override
Specifies the maximum difference between lower- and upper objective bounds that triggers termination.
typename LpSolver< ValueType, RawMode >::Constraint Constraint
virtual void pop() override
Pops a backtracking point from the solver's stack.
virtual int_fast64_t getIntegerValue(Variable const &variable) const override
Retrieves the value of the integer variable with the given name.
virtual Variable addVariable(std::string const &name, VariableType const &type, std::optional< ValueType > const &lowerBound=std::nullopt, std::optional< ValueType > const &upperBound=std::nullopt, ValueType objectiveFunctionCoefficient=0) override
typename LpSolver< ValueType, RawMode >::Variable Variable
virtual ValueType getMILPGap(bool relative) const override
Returns the obtained gap after a call to optimize().
virtual void writeModelToFile(std::string const &filename) const override
Writes the current LP problem to the given file.
virtual void addIndicatorConstraint(std::string const &name, Variable indicatorVariable, bool indicatorValue, Constraint const &constraint) override
Adds the given indicator constraint to the LP problem: "If indicatorVariable == indicatorValue,...
HighsLpSolver()
Constructs a solver without a name.
virtual void push() override
Pushes a backtracking point on the solver's stack.
typename LpSolver< ValueType, RawMode >::VariableType VariableType
virtual bool isOptimal() const override
Retrieves whether the model was found to be optimal, i.e.
virtual bool getBinaryValue(Variable const &variable) const override
Retrieves the value of the binary variable with the given name.
virtual bool isInfeasible() const override
Retrieves whether the model was found to be infeasible.
virtual ValueType getContinuousValue(Variable const &variable) const override
Retrieves the value of the continuous variable with the given name.
virtual ValueType getObjectiveValue() const override
Retrieves the value of the objective function.
virtual bool isUnbounded() const override
Retrieves whether the model was found to be infeasible.
An interface that captures the functionality of an LP solver.
Definition LpSolver.h:50
#define STORM_LOG_ERROR(message)
Definition logging.h:36
#define STORM_LOG_ASSERT(cond, message)
Definition macros.h:9
#define STORM_LOG_THROW(cond, exception, message)
Definition macros.h:39
SFTBDDChecker::ValueType ValueType
RelationType
An enum type specifying the different relations applicable.
ValueType abs(ValueType const &number)
TargetType convertNumber(SourceType const &number)
The contract of a DD backend.
void separateVariablesFromConstantPart(VariableCoefficients &rhs)
Brings all variables of the right-hand side coefficients to the left-hand side by negating them and m...