Google OR-Tools v9.11
a fast and portable software suite for combinatorial optimization
Loading...
Searching...
No Matches
operations_research::lp_format::LpModel Class Reference

#include <lp_model.h>

Public Member Functions

 LpModel ()=default
 
absl::StatusOr< VariableIndex > AddVariable (absl::string_view name)
 
absl::StatusOr< ConstraintIndex > AddConstraint (Constraint constraint)
 
const absl::flat_hash_map< std::string, VariableIndex > & variable_names () const
 
const util_intops::StrongVector< VariableIndex, std::string > & variables () const
 
const util_intops::StrongVector< ConstraintIndex, Constraint > & constraints () const
 

Detailed Description

The contents of an optimization model in LP file format.

You can convert this to a string in the LP file format using <<, and read from a string in the LP file format using ParseLp from parse_lp.h.

Definition at line 49 of file lp_model.h.

Constructor & Destructor Documentation

◆ LpModel()

operations_research::lp_format::LpModel::LpModel ( )
default

Member Function Documentation

◆ AddConstraint()

absl::StatusOr< ConstraintIndex > operations_research::lp_format::LpModel::AddConstraint ( Constraint constraint)

Adds a new constraint to the model and returns its index.

Errors if:

  • a variable id from constraint.bounds is out of bounds
  • constraint.relation is an invalid enum
  • a coefficient on constraint.terms is Inf or NaN
  • the name has invalid characters
  • there are no terms in the constraint

Constraint names can be repeated but this is not recommended.

Definition at line 77 of file lp_model.cc.

◆ AddVariable()

absl::StatusOr< VariableIndex > operations_research::lp_format::LpModel::AddVariable ( absl::string_view name)

Adds a new variable to the model and returns it. Errors if name:

  • is empty
  • is the same as any existing variable name
  • has invalid characters for the LP file format

Variable names are case sensitive.

Definition at line 106 of file lp_model.cc.

◆ constraints()

const util_intops::StrongVector< ConstraintIndex, Constraint > & operations_research::lp_format::LpModel::constraints ( ) const
inline

Definition at line 81 of file lp_model.h.

◆ variable_names()

const absl::flat_hash_map< std::string, VariableIndex > & operations_research::lp_format::LpModel::variable_names ( ) const
inline

Definition at line 73 of file lp_model.h.

◆ variables()

const util_intops::StrongVector< VariableIndex, std::string > & operations_research::lp_format::LpModel::variables ( ) const
inline

Definition at line 77 of file lp_model.h.


The documentation for this class was generated from the following files: