Skip to content

Commit

Permalink
Allow clearing of SolverModel.
Browse files Browse the repository at this point in the history
  • Loading branch information
sukritkalra committed Oct 23, 2023
1 parent 9d1527f commit 8b2b7f7
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 0 deletions.
3 changes: 3 additions & 0 deletions schedulers/tetrisched/include/tetrisched/SolverModel.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -375,6 +375,9 @@ class SolverModelT {
/// Throws an error if the model was not solved first.
T getObjectiveValue() const;

/// Clears all the Variables and Constraints from this Model.
void clear();

/// All the Solver implementations should be a friend of the SolverModel.
/// This allows Solver implementations to construct the model to pass
/// back to the user.
Expand Down
3 changes: 3 additions & 0 deletions schedulers/tetrisched/src/Scheduler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ Scheduler::Scheduler(Time discretization, SolverBackendType solverBackend)

void Scheduler::registerSTRL(ExpressionPtr expression,
Partitions availablePartitions, Time currentTime) {
// Clear the previously saved expressions in the SolverModel.
// solverModel->clear();

// Check if the expression is an objective function.
if (expression->getType() != ExpressionType::EXPR_OBJECTIVE) {
throw exceptions::ExpressionConstructionException(
Expand Down
7 changes: 7 additions & 0 deletions schedulers/tetrisched/src/SolverModel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -404,4 +404,11 @@ template <typename T>
T SolverModelT<T>::getObjectiveValue() const {
return objectiveFunction->getValue();
}

template <typename T>
void SolverModelT<T>::clear() {
variables.clear();
constraints.clear();
objectiveFunction.reset();
}
} // namespace tetrisched

0 comments on commit 8b2b7f7

Please sign in to comment.