Skip to content

Commit

Permalink
Indices of basic and non-basic variables are now available in State a…
Browse files Browse the repository at this point in the history
…nd MasterState
  • Loading branch information
allanleal committed Sep 5, 2022
1 parent 7a6e9f7 commit 2000ccc
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 1 deletion.
5 changes: 4 additions & 1 deletion Optima/MasterSolver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -194,12 +194,15 @@ struct MasterSolver::Impl
result.succeeded = convergence.converged();
outputCurrentState();
outputHeaderBottom();
auto ss = F.result().stabilitystatus;
auto const& Fresult = F.result();
auto const& ss = Fresult.stabilitystatus;
state.s = ss.s;
state.js = ss.js;
state.ju = ss.ju;
state.jlu = ss.jlu;
state.juu = ss.juu;
state.jb = Fresult.Jc.jb;
state.jn = Fresult.Jc.jn;
}

auto sanitycheck(const MasterProblem& problem, MasterVectorRef u) -> void
Expand Down
2 changes: 2 additions & 0 deletions Optima/MasterState.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ struct MasterState
Indices ju; ///< The indices of the unstable variables in *x*.
Indices jlu; ///< The indices of the lower unstable variables in *x*.
Indices juu; ///< The indices of the upper unstable variables in *x*.
Indices jb; ///< The indices of the basic variables in *x*.
Indices jn; ///< The indices of the non-basic variables in *x*.

/// Construct a default MasterState object.
MasterState();
Expand Down
2 changes: 2 additions & 0 deletions Optima/Solver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,8 @@ struct Solver::Impl
state.ze = mstate.u.w.tail(nz).head(dims.he);
state.zg = mstate.u.w.tail(nz).tail(dims.hg);
state.p = mstate.u.p;
state.jb = mstate.jb;
state.jn = mstate.jn;
}

/// Update the given Sensitivity object with computed MasterSensitivity object `msensitivity`.
Expand Down
2 changes: 2 additions & 0 deletions Optima/State.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ class State
FixedVector xbg; ///< The variables \eq{x_{b_{\mathrm{g}}}} in \eq{(x,x_{\mathrm{b_{g}}},x_{\mathrm{h_{g}}})} of the basic optimization problem.
FixedVector xhg; ///< The variables \eq{x_{h_{\mathrm{g}}}} in \eq{(x,x_{\mathrm{b_{g}}},x_{\mathrm{h_{g}}})} of the basic optimization problem.
Stability stability; ///< The stability state of the primal variables *x*.
Indices jb; ///< The indices of the basic variables in *x*.
Indices jn; ///< The indices of the non-basic variables in *x*.

/// Construct a default State object.
State();
Expand Down
2 changes: 2 additions & 0 deletions python/bindings/MasterState.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ void exportMasterState(py::module& m)
.def_readwrite("ju", &MasterState::ju)
.def_readwrite("jlu", &MasterState::jlu)
.def_readwrite("juu", &MasterState::juu)
.def_readwrite("jb", &MasterState::jb)
.def_readwrite("jn", &MasterState::jn)
.def("resize", &MasterState::resize)
;
}
2 changes: 2 additions & 0 deletions python/bindings/State.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,7 @@ void exportState(py::module& m)
.def_readwrite("xbg", &State::xbg)
.def_readwrite("xhg", &State::xhg)
.def_readwrite("stability", &State::stability)
.def_readwrite("jb", &State::jb)
.def_readwrite("jn", &State::jn)
;
}

0 comments on commit 2000ccc

Please sign in to comment.