A SCIP optimization model. More...
#include <model.hpp>
Public Member Functions | |
| Model (const std::string &name, SCIP *scip=nullptr, bool includeDefaultPlugins=true) | |
| Creates an empty problem and sets the optimization goal to Sense::MINIMIZE.   | |
| ~Model () | |
| Releases the variables and constraints.   | |
| void | addConstr (const LinIneq &ineq, const std::string &name) | 
| Adds a constraint to the model.   | |
| bool | addSolution (const InitialSolution &initialSolution, bool printReason=true, bool completely=true, bool checkBounds=true, bool checkIntegrality=true, bool checkLpRows=true) | 
| Adds a solution to SCIP's solution pool.   | |
| Var & | addVar (const std::string &name, SCIP_Real coeff=0.0, VarType varType=VarType::CONTINUOUS, std::optional< SCIP_Real > lb=0.0, std::optional< SCIP_Real > ub=1.0) | 
| Adds a variable to the model.   | |
| template<size_t NumVars, typename CoeffType = ConstantCoefficient> | |
| std::array< Var, NumVars > | addVars (const std::string &prefix, const CoeffType &coeffs=COEFF_ZERO, VarType varType=VarType::CONTINUOUS, std::optional< SCIP_Real > lb=0.0, std::optional< SCIP_Real > ub=1.0) | 
| Adds multiple variables to the model.   | |
| template<typename CoeffType = ConstantCoefficient> | |
| std::vector< Var > | addVars (const std::string &prefix, size_t numVars, const CoeffType &coeffs=COEFF_ZERO, VarType varType=VarType::CONTINUOUS, std::optional< SCIP_Real > lb=0.0, std::optional< SCIP_Real > ub=1.0) | 
| Adds multiple variables to the model.   | |
| SCIP_Real | epsilon () const | 
| Value treated as zero.   | |
| Solution | getBestSol () const | 
| Returns the best feasible primal solution found so far or best solution candidate.   | |
| SCIP_Retcode | getLastReturnCode () const | 
| Gets the return code of the last call to SCIP's C API when the default call wrapper is used.   | |
| int | getNSols () const | 
| Returns the number of feasible primal solutions stored in the solution storage.   | |
| double | getPrimalbound () const | 
| Returns the objective value of best solution.   | |
| template<typename T > | |
| T | getSolvingStatistic (const statistics::Statistic< T > &statistic) const | 
| Query statistics about the solving process.   | |
| SCIP_Status | getStatus () const | 
| Returns the solution status.   | |
| SCIP_Real | infinity () const | 
| Infinity according the SCIP config.   | |
| bool | isZero (SCIP_Real value) const | 
| Checks, if value is in range epsilon of 0.0.   | |
| SCIP_Real | round (SCIP_Real value) const | 
| Rounds value to the nearest integer with epsilon tolerance.   | |
| Scip * | scip () const | 
| Returns a pointer to the underlying SCIP object.   | |
| void | setObjsense (Sense objsense) | 
| Set objective goal.   | |
| template<typename T , typename PT > | |
| void | setParam (params::Param< PT > parameter, T value) | 
| Sets a parameter.   | |
| void | setScipCallWrapper (std::function< void(SCIP_Retcode)> wrapper) | 
| Replace the current wrapper for every call to SCIP's C API.   | |
| void | solve () | 
| Solve the model.   | |
| void | writeOrigProblem (const std::filesystem::directory_entry &filename, bool genericNames=false) const | 
| Writes original problem to file.   | |
| void | writeOrigProblem (const std::string &extension, bool genericNames=false) const | 
| Writes original problem to standard output.   | |
A SCIP optimization model.
Variables and constraints are automatically released when the model is destructed.
      
  | 
  explicit | 
Creates an empty problem and sets the optimization goal to Sense::MINIMIZE.
By default, all calls to the underlying C API are wrapped and the last return code is stored.
| name | for the problem. | 
| scip | to create the problem in. If nullptr, a new SCIP data structure will be created.  | 
| includeDefaultPlugins | if true, the default plugins are added to scip.  | 
| scippp::Model::~Model | ( | ) | 
Releases the variables and constraints.
| void scippp::Model::addConstr | ( | const LinIneq & | ineq, | 
| const std::string & | name ) | 
Adds a constraint to the model.
| ineq | linear inequality to add. | 
| name | for the constraint when the model is written. | 
| bool scippp::Model::addSolution | ( | const InitialSolution & | initialSolution, | 
| bool | printReason = true, | ||
| bool | completely = true, | ||
| bool | checkBounds = true, | ||
| bool | checkIntegrality = true, | ||
| bool | checkLpRows = true ) | 
Adds a solution to SCIP's solution pool.
| initialSolution | to add to the solution pool. | 
| printReason | Should all reasons of violations be printed? | 
| completely | Should all violations be checked if printReason is true?  | 
| checkBounds | Should the bounds of the variables be checked? | 
| checkIntegrality | Should integrality be checked? | 
| checkLpRows | Do constraints represented by rows in the current LP have to be checked? | 
true iff the solution was feasible and stored in the solution storage (i.e, good enough to keep). | Var & scippp::Model::addVar | ( | const std::string & | name, | 
| SCIP_Real | coeff = 0.0, | ||
| VarType | varType = VarType::CONTINUOUS, | ||
| std::optional< SCIP_Real > | lb = 0.0, | ||
| std::optional< SCIP_Real > | ub = 1.0 ) | 
Adds a variable to the model.
| name | of the variable when the model is written. | 
| coeff | Coefficient in the objective function. | 
| varType | variable type. | 
| lb | lower bound. std::nullopt is interpreted as -infinity.  | 
| ub | upper bound. std::nullopt is interpreted as infinity.  | 
      
  | 
  inline | 
Adds multiple variables to the model.
This method can be used when the number of variables to add is known at compile time. The result can be used in a structured binding.
| NumVars | Number of variables to add. | 
| CoeffType | Type of the object holding the coefficients. They are accessed via [i] where i goes from 0 to NumVars - 1.  | 
| prefix | to construct variable names from: prefix + index. | 
| coeffs | Object holding the coefficients for the objective function. | 
| varType | variable type. | 
| lb | lower bound. | 
| ub | upper bound. | 
Definition at line 152 of file model.hpp.
References addVars().
      
  | 
  inline | 
Adds multiple variables to the model.
| CoeffType | Type of the object holding the coefficients. They are accessed via [i] where i goes from 0 to numVars - 1.  | 
| prefix | to construct variable names from: prefix + index. | 
| numVars | number of variables to create. | 
| coeffs | Object holding the coefficients for the objective function. | 
| varType | variable type. | 
| lb | lower bound. std::nullopt is interpreted as -infinity.  | 
| ub | upper bound. std::nullopt is interpreted as infinity.  | 
Definition at line 118 of file model.hpp.
References addVar().
      
  | 
  nodiscard | 
Value treated as zero.
      
  | 
  nodiscard | 
Returns the best feasible primal solution found so far or best solution candidate.
      
  | 
  nodiscard | 
Gets the return code of the last call to SCIP's C API when the default call wrapper is used.
      
  | 
  nodiscard | 
Returns the number of feasible primal solutions stored in the solution storage.
      
  | 
  nodiscard | 
Returns the objective value of best solution.
      
  | 
  inlinenodiscard | 
      
  | 
  nodiscard | 
Returns the solution status.
      
  | 
  nodiscard | 
Infinity according the SCIP config.
To be used in variable bounds and constants in constraints.
      
  | 
  nodiscard | 
Checks, if value is in range epsilon of 0.0.
| value | to check | 
true iff the value is in range epsilon of 0.0. 
      
  | 
  nodiscard | 
Rounds value to the nearest integer with epsilon tolerance.
| value | to round | 
      
  | 
  nodiscard | 
Returns a pointer to the underlying SCIP object.
| void scippp::Model::setObjsense | ( | Sense | objsense | ) | 
Set objective goal.
| objsense | Minimize or Maximize. | 
      
  | 
  inline | 
Sets a parameter.
See the namespace scippp::params for a list of parameters, or create new ones using params::Param.
| T | Type of the value. | 
| PT | Value type the parameter expects | 
| parameter | to set. | 
| value | to set the parameter to. | 
Definition at line 273 of file model.hpp.
References scippp::params::Param< baseType >::scipName.
| void scippp::Model::setScipCallWrapper | ( | std::function< void(SCIP_Retcode)> | wrapper | ) | 
Replace the current wrapper for every call to SCIP's C API.
| wrapper | New wrapper tp use. | 
| void scippp::Model::solve | ( | ) | 
Solve the model.
| void scippp::Model::writeOrigProblem | ( | const std::filesystem::directory_entry & | filename, | 
| bool | genericNames = false ) const | 
Writes original problem to file.
| filename | output file name including extension | 
| genericNames | using generic variable (x0, x1, ...) and constraint names (c0, c1, ...) instead of the user-given names? | 
filename, as this will call the other overload instead! | void scippp::Model::writeOrigProblem | ( | const std::string & | extension, | 
| bool | genericNames = false ) const | 
Writes original problem to standard output.
| extension | file extension to derive the output format from | 
| genericNames | using generic variable (x0, x1, ...) and constraint names (c0, c1, ...) instead of the user-given names? |