Skip to content

Commit

Permalink
Code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
AntoinePrv committed Sep 9, 2021
1 parent f264f41 commit a002e38
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 18 deletions.
12 changes: 4 additions & 8 deletions libecole/tests/src/observation/test-nodebipartite.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,16 +44,12 @@ TEST_CASE("NodeBipartite return correct observation", "[obs]") {
}

SECTION("Variable features are not all nan") {
auto const& var_feat = optional_obs.value().variable_features;
for (std::size_t i = 0; i < var_feat.shape()[1]; ++i) {
REQUIRE_FALSE(xt::all(xt::isnan(xt::col(var_feat, static_cast<std::ptrdiff_t>(i)))));
}
auto const& obs = optional_obs.value();
REQUIRE_FALSE(xt::all(xt::isnan(obs.variable_features)));
}

SECTION("Row features are not all nan") {
auto const& row_feat = optional_obs.value().row_features;
for (std::size_t i = 0; i < row_feat.shape()[1]; ++i) {
REQUIRE_FALSE(xt::all(xt::isnan(xt::col(row_feat, static_cast<std::ptrdiff_t>(i)))));
}
auto const& obs = optional_obs.value();
REQUIRE_FALSE(xt::all(xt::isnan(obs.row_features)));
}
}
20 changes: 10 additions & 10 deletions python/src/ecole/core/observation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ void bind_submodule(py::module_ const& m) {
The optimization problem is represented as an heterogenous bipartite graph.
On one side, a node is associated with one variable, on the other side a node is
associated with one constraint.
associated with one LP row.
There exist an edge between a variable and a constraint if the variable exists in the
constraint with a non-zero coefficient.
Expand Down Expand Up @@ -236,13 +236,13 @@ void bind_submodule(py::module_ const& m) {
Strong branching score observation function on branch-and bound node.
This observation obtains scores for all LP or pseudo candidate variables at a
branch-and-bound node. The strong branching score measures the quality of branching
for each variable. This observation can be used as an expert for imitation
learning algorithms.
branch-and-bound node.
The strong branching score measures the quality of branching for each variable.
This observation can be used as an expert for imitation learning algorithms.
This observation function extracts an array containing the strong branching score for
each variable in the problem which can be indexed by the action set. Variables for which
a strong branching score is not applicable are filled with NaN.
each variable in the problem which can be indexed by the action set.
Variables for which a strong branching score is not applicable are filled with ``NaN``.
)");
strong_branching_scores.def(py::init<bool>(), py::arg("pseudo_candidates") = true, R"(
Constructor for StrongBranchingScores.
Expand All @@ -269,8 +269,8 @@ void bind_submodule(py::module_ const& m) {
pseudocost branching (also known as hybrid branching).
This observation function extracts an array containing the pseudocost for
each variable in the problem which can be indexed by the action set. Variables for which
a pseudocost is not applicable are filled with NaN.
each variable in the problem which can be indexed by the action set.
Variables for which a pseudocost is not applicable are filled with ``NaN``.
)");
pseudocosts.def(py::init<>());
def_before_reset(pseudocosts, R"(Do nothing.)");
Expand All @@ -283,8 +283,8 @@ void bind_submodule(py::module_ const& m) {
The observation is a matrix where rows represent all variables and columns represent features related
to these variables.
Only rows representing pseudo branching candidate contain meaningful observation, other rows are filled with
``NaN``.
Only rows representing pseudo branching candidate contain meaningful observation, other rows are filled
with ``NaN``.
See [Khalil2016]_ for a complete reference on this observation function.
The first :py:attr:`Khalil2016Obs.n_static_features` are static (they do not change through the solving
Expand Down

0 comments on commit a002e38

Please sign in to comment.