Skip to content

Commit 1297ea7

Browse files
dchetelatAntoinePrv
authored andcommitted
Changed pseudocosts to return a vector of variables, not columns
1 parent 61f1239 commit 1297ea7

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

libecole/src/observation/pseudocosts.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,13 @@ std::optional<xt::xtensor<double, 1>> Pseudocosts::extract(scip::Model& model, b
3939
auto const [cands, lp_values] = scip_get_lp_branch_cands(scip);
4040

4141
/* Store pseudocosts in tensor */
42-
auto const nb_lp_columns = static_cast<std::size_t>(SCIPgetNLPCols(scip));
43-
xt::xtensor<double, 1> pseudocosts({nb_lp_columns}, std::nan(""));
42+
auto const nb_vars = static_cast<std::size_t>(SCIPgetNVars(scip));
43+
xt::xtensor<double, 1> pseudocosts({nb_vars}, std::nan(""));
4444

4545
for (auto const [var, lp_val] : views::zip(cands, lp_values)) {
46-
auto const lp_index = static_cast<std::size_t>(SCIPcolGetLPPos(SCIPvarGetCol(var)));
46+
auto const var_index = static_cast<std::size_t>(SCIPvarGetProbindex(var));
4747
auto const score = SCIPgetVarPseudocostScore(scip, var, lp_val);
48-
pseudocosts[lp_index] = static_cast<double>(score);
48+
pseudocosts[var_index] = static_cast<double>(score);
4949
}
5050

5151
return pseudocosts;

libecole/tests/src/observation/test-pseudocosts.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,12 @@ TEST_CASE("Pseudocosts return pseudo costs array", "[obs]") {
2323

2424
REQUIRE(obs.has_value());
2525
auto const& costs = obs.value();
26-
REQUIRE(costs.size() == model.lp_columns().size());
26+
REQUIRE(costs.size() == model.variables().size());
2727

2828
// All branching candidates have a positive pseudocost
2929
for (auto* const var : model.lp_branch_cands()) {
30-
auto const lp_index = static_cast<std::size_t>(SCIPcolGetLPPos(SCIPvarGetCol(var)));
31-
auto const pseudocost = costs[lp_index];
30+
auto const var_index = static_cast<std::size_t>(SCIPvarGetProbindex(var));
31+
auto const pseudocost = costs[var_index];
3232
REQUIRE(!std::isnan(pseudocost));
3333
REQUIRE(pseudocost > 0);
3434
}

0 commit comments

Comments
 (0)