134#ifndef ORTOOLS_LINEAR_SOLVER_LINEAR_SOLVER_H_
135#define ORTOOLS_LINEAR_SOLVER_LINEAR_SOLVER_H_
149#include "absl/base/attributes.h"
150#include "absl/base/port.h"
151#include "absl/base/thread_annotations.h"
152#include "absl/container/flat_hash_map.h"
153#include "absl/flags/declare.h"
154#include "absl/log/check.h"
155#include "absl/log/log.h"
156#include "absl/status/status.h"
157#include "absl/strings/str_format.h"
158#include "absl/strings/string_view.h"
159#include "absl/time/clock.h"
160#include "absl/time/time.h"
305 const std::string& solver_id);
310 const std::string&
Name()
const {
316 return problem_type_;
333 const std::vector<MPVariable*>&
variables()
const {
return variables_; }
355 const std::string& name);
380 void MakeVarArray(
int nb,
double lb,
double ub,
bool integer,
381 const std::string& name_prefix,
382 std::vector<MPVariable*>* vars);
385 void MakeNumVarArray(
int nb,
double lb,
double ub,
const std::string& name,
386 std::vector<MPVariable*>* vars);
389 void MakeIntVarArray(
int nb,
double lb,
double ub,
const std::string& name,
390 std::vector<MPVariable*>* vars);
394 std::vector<MPVariable*>* vars);
404 const std::vector<MPConstraint*>&
constraints()
const {
return constraints_; }
417 const std::string& constraint_name)
const;
434 const std::string& name);
447 const std::string& name);
493 void Write(
const std::string& file_name);
554 std::string* error_message,
555 bool clear_names =
true);
564 const MPModelProto& input_model, std::string* error_message);
590 std::atomic<
bool>* interrupt =
nullptr);
604 std::atomic<
bool>* interrupt =
nullptr);
607 "Prefer SolverTypeSupportsInterruption() from solve_mp_model.h.")
658 double tolerance = std::numeric_limits<double>::infinity());
674 std::string* model_str)
const;
699 return solver_specific_parameter_string_;
717 void SetHint(std::vector<std::pair<const MPVariable*, double> > hint);
721 ABSL_DEPRECATED(
"Prefer MPModelRequestLoggingInfo() from solve_mp_model.h.")
749 const std::vector<MPSolver::BasisStatus>& variable_statuses,
750 const std::vector<MPSolver::BasisStatus>& constraint_statuses);
757 static double infinity() {
return std::numeric_limits<double>::infinity(); }
776 absl::Duration
TimeLimit()
const {
return time_limit_; }
783 return absl::Now() - construction_time_;
794 int64_t
nodes()
const;
873 return time_limit_ == absl::InfiniteDuration()
875 : absl::ToInt64Milliseconds(time_limit_);
879 ? absl::InfiniteDuration()
880 : absl::Milliseconds(time_limit_milliseconds));
883 return static_cast<double>(
time_limit()) / 1000.0;
914 int ComputeMaxConstraintSize(
int min_constraint_index,
915 int max_constraint_index)
const;
918 bool HasInfeasibleConstraints()
const;
921 bool HasIntegerVariables()
const;
924 void GenerateVariableNameIndex()
const;
927 void GenerateConstraintNameIndex()
const;
930 const std::string name_;
936 std::unique_ptr<MPSolverInterface> interface_;
939 std::vector<MPVariable*> variables_;
941 mutable std::optional<absl::flat_hash_map<std::string, int> >
942 variable_name_to_index_;
944 std::vector<bool> variable_is_extracted_;
947 std::vector<MPConstraint*> constraints_;
949 mutable std::optional<absl::flat_hash_map<std::string, int> >
950 constraint_name_to_index_;
952 std::vector<bool> constraint_is_extracted_;
955 std::unique_ptr<MPObjective> objective_;
964 std::vector<std::pair<const MPVariable*, double> > solution_hint_;
966 absl::Duration time_limit_ = absl::InfiniteDuration();
968 const absl::Time construction_time_;
971 int num_threads_ = 1;
974 std::string solver_specific_parameter_string_;
976 static absl::Mutex global_count_mutex_;
978 static int64_t global_num_variables_ ABSL_GUARDED_BY(global_count_mutex_);
979 static int64_t global_num_constraints_ ABSL_GUARDED_BY(global_count_mutex_);
982 enum ModelProtoNamesPolicy {
983 DEFAULT_CLEAR_NAMES = 0,
984 INVALID_MODEL_ON_DUPLICATE_NONEMPTY_NAMES = 1,
985 DIE_ON_DUPLICATE_NONEMPTY_NAMES = 2,
988 const MPModelProto& input_model, ModelProtoNamesPolicy name_policy,
989 bool check_model_validity, std::string* error_message);
1002 return os <<
ToString(optimization_problem_type);
1005inline std::ostream&
operator<<(std::ostream& os,
1007 return os << ProtoEnumToString<MPSolverResponseStatus>(
1013 std::string* error);
1055 const absl::flat_hash_map<const MPVariable*, double>&
terms()
const {
1056 return coefficients_;
1063 double offset()
const {
return offset_; }
1109 double Value()
const;
1143 : interface_(interface_in), coefficients_(1), offset_(0.0) {}
1148 absl::flat_hash_map<const MPVariable*, double> coefficients_;
1163 const std::string&
name()
const {
return name_; }
1169 bool integer()
const {
return integer_; }
1181 int index()
const {
return index_; }
1184 double lb()
const {
return lb_; }
1187 double ub()
const {
return ub_; }
1262 solution_value_(0.0),
1264 interface_(interface_in) {}
1274 const std::string name_;
1275 double solution_value_;
1276 double reduced_cost_;
1277 int branching_priority_ = 0;
1295 const std::string&
name()
const {
return name_; }
1319 const absl::flat_hash_map<const MPVariable*, double>&
terms()
const {
1320 return coefficients_;
1324 double lb()
const {
return lb_; }
1327 double ub()
const {
return ub_; }
1339 bool is_lazy()
const {
return is_lazy_; }
1354 void set_is_lazy(
bool laziness) { is_lazy_ = laziness; }
1360 int index()
const {
return index_; }
1411 indicator_variable_(nullptr),
1413 interface_(interface_in) {}
1420 bool ContainsNewVariables();
1423 absl::flat_hash_map<const MPVariable*, double> coefficients_;
1434 const std::string name_;
1444 bool indicator_value_;
1610 double relative_mip_gap_value_;
1611 double primal_tolerance_value_;
1612 double dual_tolerance_value_;
1613 int presolve_value_;
1615 int lp_algorithm_value_;
1616 int incrementality_value_;
1621 bool lp_algorithm_is_default_;
1679 std::atomic<bool>* )
const {
1686 std::atomic<bool>* ) {
1687 LOG(DFATAL) <<
"Default implementation should never be called.";
1693 virtual void Write(
const std::string& filename);
1697 virtual void Reset() = 0;
1717 LOG(ERROR) <<
"Solver doesn't support indicator constraints.";
1726 const MPVariable* variable,
double new_value,
1727 double old_value) = 0;
1734 double coefficient) = 0;
1749 virtual int64_t
nodes()
const = 0;
1790 return solver_->variable_is_extracted_[var_index];
1793 solver_->variable_is_extracted_[var_index] = extracted;
1796 return solver_->constraint_is_extracted_[ct_index];
1799 solver_->constraint_is_extracted_[ct_index] = extracted;
1825 const std::vector<MPSolver::BasisStatus>& ,
1826 const std::vector<MPSolver::BasisStatus>& ) {
1827 LOG(FATAL) <<
"Not supported by this solver.";
1830 virtual double infinity() {
return std::numeric_limits<double>::infinity(); }
1839 LOG(FATAL) <<
"Callbacks not supported for this solver.";
1925 const std::string& parameters);
1968 std::function<
bool()> is_runtime_ready = {});
1997 mutable absl::Mutex mutex_;
2000 std::function<bool()> is_runtime_ready;
2002 std::map<MPSolver::OptimizationProblemType, Entry> map_;
bool is_lazy() const
Advanced usage: returns true if the constraint is "lazy" (see below).
friend class SCIPInterface
void set_dual_value(double dual_value)
void Clear()
Clears all variables and coefficients. Does not clear the bounds.
void SetCoefficient(const MPVariable *var, double coeff)
double lb() const
Returns the lower bound.
friend class SLMInterface
friend class CLPInterface
const absl::flat_hash_map< const MPVariable *, double > & terms() const
friend class GLOPInterface
friend class BopInterface
double ub() const
Returns the upper bound.
void SetUB(double ub)
Sets the upper bound.
void SetLB(double lb)
Sets the lower bound.
MPSolver::BasisStatus basis_status() const
MPConstraint(const MPConstraint &)=delete
friend class PdlpInterface
const MPVariable * indicator_variable() const
void set_is_lazy(bool laziness)
MPConstraint & operator=(const MPConstraint &)=delete
double GetCoefficient(const MPVariable *var) const
const std::string & name() const
Returns the name of the constraint.
friend class XpressInterface
int index() const
Returns the index of the constraint in the MPSolver::constraints_.
void SetBounds(double lb, double ub)
Sets both the lower and upper bounds.
friend class MPSolverInterface
friend class GurobiInterface
friend class SatInterface
bool indicator_value() const
double dual_value() const
friend class GLPKInterface
friend class CplexInterface
friend class HighsInterface
friend class KnapsackInterface
friend class CBCInterface
MPModelRequest_SolverType SolverType
static constexpr SolverType SAT_INTEGER_PROGRAMMING
static constexpr SolverType GUROBI_MIXED_INTEGER_PROGRAMMING
static constexpr SolverType PDLP_LINEAR_PROGRAMMING
static constexpr SolverType GUROBI_LINEAR_PROGRAMMING
static constexpr SolverType GLOP_LINEAR_PROGRAMMING
A class to express a linear objective.
void MinimizeLinearExpr(const LinearExpr &linear_expr)
Resets the current objective to minimize linear_expr.
void SetCoefficient(const MPVariable *var, double coeff)
double GetCoefficient(const MPVariable *var) const
friend class SCIPInterface
void SetOffset(double value)
Sets the constant term in the objective.
MPObjective(const MPObjective &)=delete
const absl::flat_hash_map< const MPVariable *, double > & terms() const
friend class SLMInterface
friend class CLPInterface
void MaximizeLinearExpr(const LinearExpr &linear_expr)
Resets the current objective to maximize linear_expr.
friend class GLOPInterface
bool minimization() const
Is the optimization direction set to minimize?
friend class BopInterface
void SetMaximization()
Sets the optimization direction to maximize.
bool maximization() const
Is the optimization direction set to maximize?
double offset() const
Gets the constant term in the objective.
friend class PdlpInterface
void AddLinearExpr(const LinearExpr &linear_expr)
Adds linear_expr to the current objective, does not change the direction.
void OptimizeLinearExpr(const LinearExpr &linear_expr, bool is_maximization)
friend class XpressInterface
friend class MPSolverInterface
friend class GurobiInterface
friend class SatInterface
void SetOptimizationDirection(bool maximize)
Sets the optimization direction (maximize: true or minimize: false).
friend class GLPKInterface
friend class CplexInterface
friend class HighsInterface
MPObjective & operator=(const MPObjective &)=delete
friend class KnapsackInterface
friend class CBCInterface
void SetMinimization()
Sets the optimization direction to minimize.
std::string PrettyPrintAllRegisteredProblemTypes() const
MPSolverInterface * Create(MPSolver *solver) const
std::vector< MPSolver::OptimizationProblemType > ListAllRegisteredProblemTypes() const
static MPSolverInterfaceFactoryRepository * GetInstance()
bool Unregister(MPSolver::OptimizationProblemType problem_type)
bool Supports(MPSolver::OptimizationProblemType problem_type) const
void Register(MPSolverInterfaceFactory factory, MPSolver::OptimizationProblemType problem_type, std::function< bool()> is_runtime_ready={})
void set_variable_as_extracted(int var_index, bool extracted)
virtual void AddVariable(MPVariable *var)=0
MPSolver::ResultStatus result_status() const
double best_objective_bound() const
virtual void SetCallback(MPCallback *)
bool CheckSolutionIsSynchronized() const
virtual void SetPrimalTolerance(double value)=0
virtual void ExtractNewConstraints()=0
virtual bool SupportsCallbacks() const
virtual void ClearObjective()=0
static constexpr int64_t kUnknownNumberOfIterations
virtual void ExtractObjective()=0
friend class MPConstraint
void InvalidateSolutionSynchronization()
virtual void SetRelativeMipGap(double value)=0
virtual void SetObjectiveCoefficient(const MPVariable *variable, double coefficient)=0
virtual void SetStartingLpBasis(const std::vector< MPSolver::BasisStatus > &, const std::vector< MPSolver::BasisStatus > &)
void set_constraint_as_extracted(int ct_index, bool extracted)
virtual bool IsMIP() const =0
virtual int64_t nodes() const =0
void ResetExtractionInformation()
virtual void SetIntegerParamToUnsupportedValue(MPSolverParameters::IntegerParam param, int value)
int last_variable_index() const
virtual void SetPresolveMode(int value)=0
int last_constraint_index_
virtual MPSolver::BasisStatus column_status(int variable_index) const =0
virtual void SetCoefficient(MPConstraint *constraint, const MPVariable *variable, double new_value, double old_value)=0
virtual std::string SolverVersion() const =0
virtual void SetVariableInteger(int index, bool integer)=0
virtual absl::Status SetNumThreads(int num_threads)
virtual int64_t iterations() const =0
virtual bool InterruptSolve()
virtual void BranchingPriorityChangedForVariable(int)
virtual bool SetSolverSpecificParametersAsString(const std::string ¶meters)
static const int kDummyVariableIndex
virtual void SetObjectiveOffset(double value)=0
virtual void SetParameters(const MPSolverParameters ¶m)=0
virtual bool CheckSolutionExists() const
virtual bool IsContinuous() const =0
virtual void SetLpAlgorithm(int value)=0
virtual void SetUnsupportedIntegerParam(MPSolverParameters::IntegerParam param)
virtual bool NextSolution()
bool variable_is_extracted(int var_index) const
virtual bool IsLP() const =0
void SetUnsupportedDoubleParam(MPSolverParameters::DoubleParam param)
virtual void * underlying_solver()=0
virtual bool SupportsDirectlySolveProto(std::atomic< bool > *) const
bool constraint_is_extracted(int ct_index) const
static constexpr int64_t kUnknownNumberOfNodes
virtual void ExtractNewVariables()=0
virtual MPSolver::ResultStatus Solve(const MPSolverParameters ¶m)=0
double objective_value() const
double best_objective_bound_
void SetDoubleParamToUnsupportedValue(MPSolverParameters::DoubleParam param, double value)
virtual void SetScalingMode(int value)=0
virtual double ComputeExactConditionNumber() const
virtual MPSolver::BasisStatus row_status(int constraint_index) const =0
virtual void AddRowConstraint(MPConstraint *ct)=0
virtual MPSolutionResponse DirectlySolveProto(LazyMutableCopy< MPModelRequest >, std::atomic< bool > *)
virtual void Write(const std::string &filename)
void SetMIPParameters(const MPSolverParameters ¶m)
virtual ~MPSolverInterface()
virtual void SetDualTolerance(double value)=0
MPSolverInterface(MPSolver *solver)
virtual bool AddIndicatorConstraint(MPConstraint *const)
virtual void SetOptimizationDirection(bool maximize)=0
virtual double infinity()
void SetCommonParameters(const MPSolverParameters ¶m)
virtual void ClearConstraint(MPConstraint *constraint)=0
bool CheckSolutionIsSynchronizedAndExists() const
void set_quiet(bool quiet_value)
MPSolver::ResultStatus result_status_
virtual void SetConstraintBounds(int index, double lb, double ub)=0
SynchronizationStatus sync_status_
virtual void SetVariableBounds(int index, double lb, double ub)=0
static const PresolveValues kDefaultPresolve
void ResetIntegerParam(MPSolverParameters::IntegerParam param)
static const double kDefaultDualTolerance
MPSolverParameters & operator=(const MPSolverParameters &)=delete
static const double kDefaultPrimalTolerance
DoubleParam
Enumeration of parameters that take continuous values.
@ DUAL_TOLERANCE
Advanced usage: tolerance for dual feasibility of basic solutions.
@ RELATIVE_MIP_GAP
Limit for relative MIP gap.
double GetDoubleParam(MPSolverParameters::DoubleParam param) const
Returns the value of a double parameter.
PresolveValues
For each categorical parameter, enumeration of possible values.
@ PRESOLVE_OFF
Presolve is off.
@ PRESOLVE_ON
Presolve is on.
static const double kUnknownDoubleParamValue
static const int kUnknownIntegerParamValue
void ResetDoubleParam(MPSolverParameters::DoubleParam param)
static const int kDefaultIntegerParamValue
LpAlgorithmValues
LP algorithm to use.
@ BARRIER
Barrier algorithm.
void SetDoubleParam(MPSolverParameters::DoubleParam param, double value)
Sets a double parameter to a specific value.
IntegerParam
Enumeration of parameters that take integer or categorical values.
@ INCREMENTALITY
Advanced usage: incrementality from one solve to the next.
@ PRESOLVE
Advanced usage: presolve mode.
@ LP_ALGORITHM
Algorithm to solve linear programs.
@ SCALING
Advanced usage: enable or disable matrix scaling.
MPSolverParameters()
The constructor sets all parameters to their default value.
static const IncrementalityValues kDefaultIncrementality
IncrementalityValues
Advanced usage: Incrementality options.
@ INCREMENTALITY_OFF
Start solve from scratch.
static const double kDefaultRelativeMipGap
void Reset()
Sets all parameters to their default value.
ScalingValues
Advanced usage: Scaling options.
@ SCALING_ON
Scaling is on.
@ SCALING_OFF
Scaling is off.
int GetIntegerParam(MPSolverParameters::IntegerParam param) const
Returns the value of an integer parameter.
static const double kDefaultDoubleParamValue
void SetIntegerParam(MPSolverParameters::IntegerParam param, int value)
Sets a integer parameter to a specific value.
int64_t time_limit() const
static void SolveLazyMutableRequest(LazyMutableCopy< MPModelRequest > request, MPSolutionResponse *response, std::atomic< bool > *interrupt=nullptr)
double time_limit_in_secs() const
int64_t iterations() const
Returns the number of simplex iterations.
int NumVariables() const
Returns the number of variables.
static MPSolver * CreateSolver(const std::string &solver_id)
void SetStartingLpBasis(const std::vector< MPSolver::BasisStatus > &variable_statuses, const std::vector< MPSolver::BasisStatus > &constraint_statuses)
MPVariable * MakeVar(double lb, double ub, bool integer, const std::string &name)
const std::vector< MPVariable * > & variables() const
MPVariable * MakeIntVar(double lb, double ub, const std::string &name)
Creates an integer variable.
int NumConstraints() const
Returns the number of constraints.
@ MODEL_INVALID
the model is trivially invalid (NaN coefficients, etc).
@ FEASIBLE
feasible, or stopped by limit.
@ NOT_SOLVED
not been solved yet.
@ INFEASIBLE
proven infeasible.
@ UNBOUNDED
proven unbounded.
@ ABNORMAL
abnormal, i.e., error of some kind.
ABSL_DEPRECATED("Prefer SolverTypeSupportsInterruption() from solve_mp_model.h.") static bool SolverTypeSupportsInterruption(const MPModelRequest
ResultStatus Solve()
Solves the problem using the default parameter values.
MPSolverResponseStatus LoadModelFromProto(const MPModelProto &input_model, std::string *error_message, bool clear_names=true)
friend class SCIPInterface
bool VerifySolution(double tolerance, bool log_errors) const
void MakeVarArray(int nb, double lb, double ub, bool integer, const std::string &name_prefix, std::vector< MPVariable * > *vars)
bool ExportModelAsLpFormat(bool obfuscate, std::string *model_str) const
const MPObjective & Objective() const
void SetCallback(MPCallback *mp_callback)
@ GLPK_MIXED_INTEGER_PROGRAMMING
@ GLOP_LINEAR_PROGRAMMING
@ SCIP_MIXED_INTEGER_PROGRAMMING
@ CPLEX_LINEAR_PROGRAMMING
@ SAT_INTEGER_PROGRAMMING
@ XPRESS_MIXED_INTEGER_PROGRAMMING
@ CBC_MIXED_INTEGER_PROGRAMMING
@ HIGHS_MIXED_INTEGER_PROGRAMMING
@ GUROBI_MIXED_INTEGER_PROGRAMMING
@ COPT_LINEAR_PROGRAMMING
@ XPRESS_LINEAR_PROGRAMMING
@ PDLP_LINEAR_PROGRAMMING
@ COPT_MIXED_INTEGER_PROGRAMMING
@ HIGHS_LINEAR_PROGRAMMING
@ BOP_INTEGER_PROGRAMMING
@ GLPK_LINEAR_PROGRAMMING
@ CPLEX_MIXED_INTEGER_PROGRAMMING
@ KNAPSACK_MIXED_INTEGER_PROGRAMMING
@ GUROBI_LINEAR_PROGRAMMING
void SetTimeLimit(absl::Duration time_limit)
MPSolverResponseStatus LoadModelFromProtoWithUniqueNamesOrDie(const MPModelProto &input_model, std::string *error_message)
bool SetSolverSpecificParametersAsString(const std::string ¶meters)
MPVariable * MakeBoolVar(const std::string &name)
Creates a boolean variable.
virtual OptimizationProblemType ProblemType() const
Returns the optimization problem type set at construction.
ABSL_MUST_USE_RESULT bool NextSolution()
static bool SupportsProblemType(OptimizationProblemType problem_type)
friend class SLMInterface
void MakeIntVarArray(int nb, double lb, double ub, const std::string &name, std::vector< MPVariable * > *vars)
Creates an array of integer variables.
double ComputeExactConditionNumber() const
std::string GetSolverSpecificParametersAsString() const
absl::Duration DurationSinceConstruction() const
friend class GLOPInterface
absl::Status SetNumThreads(int num_threads)
MPVariable * variable(int index) const
friend class BopInterface
absl::Status ClampSolutionWithinBounds()
bool OwnsVariable(const MPVariable *var) const
void MakeNumVarArray(int nb, double lb, double ub, const std::string &name, std::vector< MPVariable * > *vars)
Creates an array of continuous variables.
std::vector< double > ComputeConstraintActivities() const
int GetNumThreads() const
Returns the number of threads to be used during solve.
bool SupportsCallbacks() const
void FillSolutionResponseProto(MPSolutionResponse *response) const
Encodes the current solution in a solution response protocol buffer.
int64_t wall_time() const
friend class PdlpInterface
void ExportModelToProto(MPModelProto *output_model) const
Exports model to protocol buffer.
static std::string GetMPModelRequestLoggingInfo(const MPModelRequest &request)
MPConstraint * MakeRowConstraint()
Creates a constraint with -infinity and +infinity bounds.
const std::vector< MPConstraint * > & constraints() const
MPObjective * MutableObjective()
Returns the mutable objective object.
bool OutputIsEnabled() const
static OptimizationProblemType ParseSolverTypeOrDie(const std::string &solver_id)
absl::Status LoadSolutionFromProto(const MPSolutionResponse &response, double tolerance=std::numeric_limits< double >::infinity())
absl::Duration TimeLimit() const
MPVariable * MakeNumVar(double lb, double ub, const std::string &name)
Creates a continuous variable.
MPSolver(const std::string &name, OptimizationProblemType problem_type)
Create a solver with the given name and underlying solver backend.
MPConstraint * LookupConstraintOrNull(const std::string &constraint_name) const
MPConstraint * constraint(int index) const
void EnableOutput()
Enables solver logging.
friend class XpressInterface
static int64_t global_num_variables()
MPSolver & operator=(const MPSolver &)=delete
void SetHint(std::vector< std::pair< const MPVariable *, double > > hint)
void SuppressOutput()
Suppresses solver logging.
friend class MPSolverInterface
friend class GurobiInterface
void * underlying_solver()
MPVariable * LookupVariableOrNull(const std::string &var_name) const
friend class SatInterface
void Write(const std::string &file_name)
static int64_t global_num_constraints()
const std::string & Name() const
Returns the name of the model set at construction.
bool ExportModelAsMpsFormat(bool fixed_format, bool obfuscate, std::string *model_str) const
static bool ParseSolverType(absl::string_view solver_id, OptimizationProblemType *type)
friend class CplexInterface
friend class HighsInterface
static void SolveWithProto(const MPModelRequest &model_request, MPSolutionResponse *response, std::atomic< bool > *interrupt=nullptr)
friend class KnapsackInterface
std::string SolverVersion() const
Returns a string describing the underlying solver and its version.
friend class CBCInterface
void MakeBoolVarArray(int nb, const std::string &name, std::vector< MPVariable * > *vars)
Creates an array of boolean variables.
void set_time_limit(int64_t time_limit_milliseconds)
The class for variables of a Mathematical Programming (MP) model.
double reduced_cost() const
void SetInteger(bool integer)
Sets the integrality requirement of the variable.
bool integer() const
Returns the integrality requirement of the variable.
void SetBranchingPriority(int priority)
void SetLB(double lb)
Sets the lower bound.
double lb() const
Returns the lower bound.
double ub() const
Returns the upper bound.
friend class SCIPInterface
MPVariable(const MPVariable &)=delete
void SetUB(double ub)
Sets the upper bound.
void SetBounds(double lb, double ub)
Sets both the lower and upper bounds.
const std::string & name() const
Returns the name of the variable.
friend class SLMInterface
friend class CLPInterface
MPVariable & operator=(const MPVariable &)=delete
friend class GLOPInterface
int branching_priority() const
friend class BopInterface
void set_reduced_cost(double reduced_cost)
friend class MPVariableSolutionValueTest
void set_solution_value(double value)
friend class PdlpInterface
double solution_value() const
MPSolver::BasisStatus basis_status() const
friend class XpressInterface
friend class MPSolverInterface
friend class GurobiInterface
int index() const
Returns the index of the variable in the MPSolver::variables_.
friend class SatInterface
friend class GLPKInterface
friend class CplexInterface
friend class HighsInterface
friend class KnapsackInterface
double unrounded_solution_value() const
friend class CBCInterface
OR_DLL ABSL_DECLARE_FLAG(bool, linear_solver_enable_verbose_output)
constexpr double kDefaultPrimalTolerance
std::function< MPSolverInterface *(MPSolver *)> MPSolverInterfaceFactory
bool SolverTypeSupportsInterruption(const MPModelRequest::SolverType solver)
bool MPSolverResponseStatusIsRpcError(MPSolverResponseStatus status)
bool SolverTypeIsMip(MPModelRequest::SolverType solver_type)
std::ostream & operator<<(std::ostream &out, const Assignment &assignment)
bool AbslParseFlag(const absl::string_view text, MPSolver::OptimizationProblemType *solver_type, std::string *error)
absl::string_view ToString(MPSolver::OptimizationProblemType optimization_problem_type)
std::string AbslUnparseFlag(MPSolver::OptimizationProblemType solver_type)