Camargue
|
Class for storing an lp relaxation via interface to an lp solver. More...
#include <lp_interface.hpp>
Classes | |
struct | solver_impl |
Public Member Functions | |
void | init_mir_data (Sep::MIRgroup &mir_data) |
Construct a Sep::MirGroup. | |
Constructors, destructor, and assignment operators. | |
Relaxation () | |
Default construct with empty, valid resource handles. | |
Relaxation (Relaxation &&lp) noexcept | |
Move construct. | |
Relaxation & | operator= (Relaxation &&lp) noexcept |
Move assign. | |
Relaxation (const Relaxation &lp)=delete | |
Relaxation & | operator= (const Relaxation &lp)=delete |
~Relaxation () | |
Destruct and free resource handles. | |
Methods for querying the relaxation. | |
bool | primal_feas () const |
Is the resident basis primal feasible. | |
bool | dual_feas () const |
Is the resident basis dual feasible. | |
int | num_rows () const |
Number of rows in the model. | |
int | num_cols () const |
Number of columsn in the model. | |
int | it_count () const |
Number of iterations from last optimization. | |
double | get_coeff (int row, int col) const |
Get constraint matrix entry. | |
void | get_rhs (std::vector< double > &rhs, int begin, int end) const |
Get a ranged vector of righthand sides. | |
std::vector< double > | lower_bds (int begin, int end) const |
Get the lower bounds for a range of variables. | |
std::vector< double > | upper_bds (int begin, int end) const |
Get the upper bounds for a range of variables. | |
std::vector< char > | senses (int begin, int end) const |
Get the senses of a range of constraints. | |
void | get_col (int col, std::vector< int > &cmatind, std::vector< double > &cmatval) const |
Get a sparse coefficient column. | |
void | get_row (int row, std::vector< int > &rmatind, std::vector< double > &rmatval) const |
Get a sparse coefficient row. | |
SparseRow | get_row (int row) const |
Return a sparse coefficient row. | |
void | get_row_infeas (const std::vector< double > &x, std::vector< double > &feas_stat, int begin, int end) const |
Feasibility status of a given solution with respect to rows. | |
void | get_col_infeas (const std::vector< double > &x, std::vector< double > &feas_stat, int begin, int end) const |
Feasibility status of a given solution with respect to column bounds. | |
double | get_objval () const |
Objective value for resident solution. | |
SolStat | get_stat () const |
Get the SolStat from last optimization. | |
double | condition_num () const |
Condition number for resident solution. | |
void | get_x (std::vector< double > &x) const |
Get current solution. | |
std::vector< double > | lp_vec () const |
Return current solution. | |
void | get_base (std::vector< int > &colstat, std::vector< int > &rowstat) const |
Get the resident basis. | |
Basis | basis_obj () const |
Return the resident basis. | |
std::vector< int > | col_stat () const |
Return the column basis. | |
std::vector< int > | row_stat () const |
Return the row basis. | |
void | get_row_slacks (std::vector< double > &slack, int begin, int end) const |
Get constraint slacks for resident solution. | |
std::vector< double > | row_slacks (int begin, int end) const |
Return constraint slacks for the resident solution. | |
void | get_pi (std::vector< double > &pi, int begin, int end) const |
Get a range of dual values. | |
std::vector< double > | pi (int begin, int end) const |
Return a range of dual values. | |
void | get_redcosts (std::vector< double > &redcosts, int begin, int end) const |
Get a range of reduced costs. | |
std::vector< double > | redcosts (int begin, int end) const |
Return a range of reduced costs. | |
Branching methods. | |
void | primal_strong_branch (const std::vector< double > &tour_vec, const std::vector< int > &colstat, const std::vector< int > &rowstat, const std::vector< int > &indices, std::vector< Estimate > &down_est, std::vector< Estimate > &up_est, std::vector< Basis > &contra_bases, int itlim, double upperbound) |
Get strong branching style estimates for variables. More... | |
void | tighten_bound (int index, char sense, double val) |
Tighten the bound on a variable. More... | |
void | change_obj (int index, double val) |
Change an objective function coefficient. | |
Row and column operations. | |
void | new_row (char sense, double rhs) |
Create a new empty row. | |
void | new_rows (const std::vector< char > &sense, const std::vector< double > &rhs) |
Create new empty rows. | |
void | add_cut (double rhs, char sense, const std::vector< int > &rmatind, const std::vector< double > &rmatval) |
Add constraint row. | |
void | add_cut (const SparseRow &sp_row) |
Add constraint row struct. | |
void | add_cuts (const std::vector< double > &rhs, const std::vector< char > &sense, const std::vector< int > &rmatbeg, const std::vector< int > &rmatind, const std::vector< double > &rmatval) |
Add constraint rows. | |
void | del_set_rows (std::vector< int > &delstat) |
Delete a not-necessarily-contiguous set of rows. | |
void | add_col (const double objval, const std::vector< int > &indices, const std::vector< double > &coeffs, const double lb, const double ub) |
Add a column. | |
void | del_set_cols (std::vector< int > &delstat) |
Delete a not-necessarily-contiguous set of columns. | |
Basis operations. | |
void | copy_start (const std::vector< double > &x) |
Instate a basis in the problem corresponding to a solution. | |
void | copy_start (const std::vector< double > &x, const std::vector< int > &col_stat, const std::vector< int > &row_stat) |
Instate a specified basis in the problem, with specified solution. | |
void | copy_base (const std::vector< int > &col_stat, const std::vector< int > &row_stat) |
Instate a basis without explicitly specifying a solution. More... | |
void | copy_base (const Basis &base) |
Overload of copy_base for basis struct. More... | |
void | factor_basis () |
Make the current basis resident in the problem. | |
Pivoting and optimizing. | |
void | switch_steepest () |
Permanent switch to steepest edge pivots. | |
void | primal_opt () |
Optimize the Relaxation with primal simplex. | |
void | dual_opt () |
Optimize the relaxation with dual simplex. | |
void | nondegen_pivot (double upper_bound) |
Primal non-degenerate pivot. More... | |
void | cb_nondegen_pivot (double upper_bound, Basis &base, int bas_freq) |
Do a primal non-degenerate pivot with a callback to record a basis. More... | |
void | one_primal_pivot () |
Perform exactly one primal simplex pivot. | |
void | one_dual_pivot () |
Perform exactly one dual simplex pivot. | |
void | primal_recover () |
Pivot until the basis is primal feasible. More... | |
Private Attributes | |
std::unique_ptr< solver_impl > | simpl_p |
Implementation hiding for solver. More... | |
Class for storing an lp relaxation via interface to an lp solver.
This structure stores the environment and lp data structures of the lp solver, and contains methods for modifying the relaxation in the sense of adding/removing constraints and variables.
void CMR::LP::Relaxation::cb_nondegen_pivot | ( | double | upper_bound, |
Basis & | base, | ||
int | bas_freq | ||
) |
Do a primal non-degenerate pivot with a callback to record a basis.
This method computes a non-degenerate pivot with a callback that copies the tour basis at each degenerate pivot.
void CMR::LP::Relaxation::copy_base | ( | const std::vector< int > & | col_stat, |
const std::vector< int > & | row_stat | ||
) |
Instate a basis without explicitly specifying a solution.
[in] | col_stat | the basic statuses for the columns. |
[in] | row_stat | the basic statuses for the rows. |
void CMR::LP::Relaxation::copy_base | ( | const Basis & | base | ) |
Overload of copy_base for basis struct.
[in] | base | the Basis structure containing the row and column statuses to be copied. |
void CMR::LP::Relaxation::nondegen_pivot | ( | double | upper_bound | ) |
Primal non-degenerate pivot.
This function computes a primal non-degenerate pivot by setting an objective value lower limit.
upper_bound | the objective value of the solution to be pivoted from; should be the objective value of the resident solution. |
void CMR::LP::Relaxation::primal_recover | ( | ) |
Pivot until the basis is primal feasible.
Using the resident basis as a starting point, this function will invoke the primal simplex optimizer, stopping just as soon as a pivot renders the basis primal feasible.
void CMR::LP::Relaxation::primal_strong_branch | ( | const std::vector< double > & | tour_vec, |
const std::vector< int > & | colstat, | ||
const std::vector< int > & | rowstat, | ||
const std::vector< int > & | indices, | ||
std::vector< Estimate > & | down_est, | ||
std::vector< Estimate > & | up_est, | ||
std::vector< Basis > & | contra_bases, | ||
int | itlim, | ||
double | upperbound | ||
) |
Get strong branching style estimates for variables.
[in] | tour_vec | the resident best tour |
[in] | colstat | the column basis for tour_vec |
[in] | rowstat | the row basis for tour_vec |
[in] | indices | the column indices of edges to examine |
[out] | downobj | estimates for clamping a variable to zero. |
[out] | upobj | estimates for clamping a variable to one. |
void CMR::LP::Relaxation::tighten_bound | ( | int | index, |
char | sense, | ||
double | val | ||
) |
Tighten the bound on a variable.
index | the column number on which to change the bound. |
sense | 'L' for <=, 'G' for >=, 'B' for ==. |
val | the value to set the bound to. |
|
private |
Implementation hiding for solver.
Pointer to solver implementation.