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

InitialSolution #31

Merged
merged 14 commits into from
Jan 10, 2025
Prev Previous commit
Next Next commit
Don't use SCIP_Var in InitialSolution
hedtke committed Jan 9, 2025

Verified

This commit was signed with the committer’s verified signature.
bestbeforetoday Mark S. Lewis
commit 3a4ef7b2c3af9e79f82a9d4577acb2bbd188f5d9
5 changes: 1 addition & 4 deletions include/scippp/initial_solution.hpp
Original file line number Diff line number Diff line change
@@ -2,9 +2,6 @@

#include <map>

// forward declare
struct SCIP_Var;

namespace scippp {

// forward declare
@@ -18,7 +15,7 @@ class Var;
class InitialSolution {
friend class Model;
//! Variable assignment in the initial solution.
std::map<SCIP_Var*, double> m_values {};
std::map<const Var*, double> m_values {};

public:
/**
6 changes: 2 additions & 4 deletions source/initial_solution.cpp
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
#include "scippp/initial_solution.hpp"

#include <scippp/var.hpp>

namespace scippp {

void InitialSolution::setValue(const Var& var, double value)
{
// maybe add scip pointer to var and check this here
m_values[var.var] = value;
m_values[&var] = value;
}

double& InitialSolution::operator()(const Var& var)
{
return m_values[var.var];
return m_values[&var];
}

}
2 changes: 1 addition & 1 deletion source/model.cpp
Original file line number Diff line number Diff line change
@@ -161,7 +161,7 @@ bool Model::addSolution(
SCIP_Sol* sol { nullptr };
m_scipCallWrapper(SCIPcreateSol(m_scip, &sol, nullptr));
for (const auto& [var, value] : initialSolution.m_values) {
m_scipCallWrapper(SCIPsetSolVal(m_scip, sol, var, value));
m_scipCallWrapper(SCIPsetSolVal(m_scip, sol, var->getVar(), value));
}
SCIP_Bool isFeasible { false };
m_scipCallWrapper(SCIPcheckSol(