Google OR-Tools v9.9
a fast and portable software suite for combinatorial optimization
Loading...
Searching...
No Matches
Google.OrTools.ModelBuilder.Model Class Reference

Main modeling class. More...

Public Member Functions

 Model ()
 Main constructor.
 
Model Clone ()
 Returns a cloned model.
 
Variable NewVar (double lb, double ub, bool isIntegral, String name)
 Integer variables.
 
Variable NewNumVar (double lb, double ub, String name)
 Creates a continuous variable with domain [lb, ub].
 
Variable NewIntVar (double lb, double ub, String name)
 Creates an integer variable with domain [lb, ub].
 
Variable NewBoolVar (String name)
 Creates a bool variable with the given name.
 
Variable NewConstant (double value)
 Creates a constant variable.
 
Variable VarFromIndex (int index)
 Rebuilds a variable from its index.
 
LinearConstraint Add (BoundedLinearExpression lin)
 Adds a Linear constraint to the model.
 
LinearConstraint AddLinearConstraint (LinearExpr expr, double lb, double ub)
 Adds the constraint expr in [lb, ub].
 
LinearConstraint ConstraintFromIndex (int index)
 Rebuilds a linear constraint from its index.
 
EnforcedLinearConstraint AddEnforced (BoundedLinearExpression lin, Variable iVar, bool iValue)
 Adds an enforced Linear constraint to the model.
 
EnforcedLinearConstraint AddEnforcedLinearConstraint (LinearExpr expr, double lb, double ub, Variable iVar, bool iValue)
 Adds the constraint iVar == iValue => expr in [lb, ub].
 
EnforcedLinearConstraint EnforcedConstraintFromIndex (int index)
 Rebuilds a linear constraint from its index.
 
void Minimize (LinearExpr obj)
 Objective.
 
void Maximize (LinearExpr obj)
 Maximize expression.
 
void Optimize (LinearExpr obj, bool maximize)
 Sets the objective expression.
 
void ClearHints ()
 Remove all hints from the model.
 
void AddHint (Variable var, double value)
 Adds var == value as a hint to the model. Note that variables must not appear more than once in the list of hints.
 
int VariablesCount ()
 Returns the number of variables in the model.
 
int ConstraintsCount ()
 Returns the number of constraints in the model.
 
bool ExportToFile (String file)
 Write the model as a protocol buffer to 'file'.
 
bool ImportFromFile (String file)
 load the model as a protocol buffer from 'file'.
 
String ExportToMpsString (bool obfuscate)
 
String ExportToLpString (bool obfuscate)
 
bool ImportFromMpsString (String mpsString)
 
bool ImportFromMpsFile (String mpsFile)
 
bool ImportFromLpString (String lpString)
 
bool ImportFromLpFile (String lpFile)
 

Properties

double ObjectiveOffset [get, set]
 The offset of the objective.
 
String Name [get, set]
 The name of the model.
 
ModelBuilderHelper Helper [get]
 The model builder helper.
 

Detailed Description

Main modeling class.

Proposes a factory to create all modeling objects understood by the Solver.

Definition at line 31 of file ModelBuilder.cs.

Constructor & Destructor Documentation

◆ Model()

Google.OrTools.ModelBuilder.Model.Model ( )
inline

Main constructor.

Definition at line 36 of file ModelBuilder.cs.

Member Function Documentation

◆ Add()

LinearConstraint Google.OrTools.ModelBuilder.Model.Add ( BoundedLinearExpression lin)
inline

Adds a Linear constraint to the model.

Parameters
linA bounded linear expression
Returns
A linear expression
Exceptions
ArgumentExceptionThrow when the constraint is not supported by the linear solver

Definition at line 136 of file ModelBuilder.cs.

◆ AddEnforced()

EnforcedLinearConstraint Google.OrTools.ModelBuilder.Model.AddEnforced ( BoundedLinearExpression lin,
Variable iVar,
bool iValue )
inline

Adds an enforced Linear constraint to the model.

Parameters
linA bounded linear expression
iVarThe indicator variable of the constraint.
iValueThe indicator value of the constraint.
Returns
A linear expression
Exceptions
ArgumentExceptionThrow when the constraint is not supported by the linear solver

Definition at line 205 of file ModelBuilder.cs.

◆ AddEnforcedLinearConstraint()

EnforcedLinearConstraint Google.OrTools.ModelBuilder.Model.AddEnforcedLinearConstraint ( LinearExpr expr,
double lb,
double ub,
Variable iVar,
bool iValue )
inline

Adds the constraint iVar == iValue => expr in [lb, ub].

Parameters
exprThe constrained expression
lbthe lower bound of the constraint
ubthe upper bound of the constraint
iVarthe indicator variable of the constraint
iValuethe indicator value of the constraint
Returns
the enforced linear constraint

Definition at line 233 of file ModelBuilder.cs.

◆ AddHint()

void Google.OrTools.ModelBuilder.Model.AddHint ( Variable var,
double value )
inline

Adds var == value as a hint to the model. Note that variables must not appear more than once in the list of hints.

Definition at line 338 of file ModelBuilder.cs.

◆ AddLinearConstraint()

LinearConstraint Google.OrTools.ModelBuilder.Model.AddLinearConstraint ( LinearExpr expr,
double lb,
double ub )
inline

Adds the constraint expr in [lb, ub].

Parameters
exprThe constrained expression
lbthe constrained lower bound of the expression
ubthe constrained upper bound of the expression
Returns
the linear constraint

Definition at line 162 of file ModelBuilder.cs.

◆ ClearHints()

void Google.OrTools.ModelBuilder.Model.ClearHints ( )
inline

Remove all hints from the model.

Definition at line 329 of file ModelBuilder.cs.

◆ Clone()

Model Google.OrTools.ModelBuilder.Model.Clone ( )
inline

Returns a cloned model.

Returns
A deep copy of the model.

Definition at line 48 of file ModelBuilder.cs.

◆ ConstraintFromIndex()

LinearConstraint Google.OrTools.ModelBuilder.Model.ConstraintFromIndex ( int index)
inline

Rebuilds a linear constraint from its index.

Definition at line 192 of file ModelBuilder.cs.

◆ ConstraintsCount()

int Google.OrTools.ModelBuilder.Model.ConstraintsCount ( )
inline

Returns the number of constraints in the model.

Definition at line 354 of file ModelBuilder.cs.

◆ EnforcedConstraintFromIndex()

EnforcedLinearConstraint Google.OrTools.ModelBuilder.Model.EnforcedConstraintFromIndex ( int index)
inline

Rebuilds a linear constraint from its index.

Definition at line 266 of file ModelBuilder.cs.

◆ ExportToFile()

bool Google.OrTools.ModelBuilder.Model.ExportToFile ( String file)
inline

Write the model as a protocol buffer to 'file'.

Parameters
filefile to write the model to. If the filename ends with 'txt', the model will be written as a text file, otherwise, the binary format will be used.
Returns
true if the model was correctly written.

Definition at line 378 of file ModelBuilder.cs.

◆ ExportToLpString()

String Google.OrTools.ModelBuilder.Model.ExportToLpString ( bool obfuscate)
inline

Definition at line 398 of file ModelBuilder.cs.

◆ ExportToMpsString()

String Google.OrTools.ModelBuilder.Model.ExportToMpsString ( bool obfuscate)
inline

Definition at line 393 of file ModelBuilder.cs.

◆ ImportFromFile()

bool Google.OrTools.ModelBuilder.Model.ImportFromFile ( String file)
inline

load the model as a protocol buffer from 'file'.

Parameters
filefile to read the model from.
Returns
true if the model was correctly loaded.

Definition at line 388 of file ModelBuilder.cs.

◆ ImportFromLpFile()

bool Google.OrTools.ModelBuilder.Model.ImportFromLpFile ( String lpFile)
inline

Definition at line 418 of file ModelBuilder.cs.

◆ ImportFromLpString()

bool Google.OrTools.ModelBuilder.Model.ImportFromLpString ( String lpString)
inline

Definition at line 413 of file ModelBuilder.cs.

◆ ImportFromMpsFile()

bool Google.OrTools.ModelBuilder.Model.ImportFromMpsFile ( String mpsFile)
inline

Definition at line 408 of file ModelBuilder.cs.

◆ ImportFromMpsString()

bool Google.OrTools.ModelBuilder.Model.ImportFromMpsString ( String mpsString)
inline

Definition at line 403 of file ModelBuilder.cs.

◆ Maximize()

void Google.OrTools.ModelBuilder.Model.Maximize ( LinearExpr obj)
inline

Maximize expression.

Parameters
objthe linear expression to maximize

Definition at line 286 of file ModelBuilder.cs.

◆ Minimize()

void Google.OrTools.ModelBuilder.Model.Minimize ( LinearExpr obj)
inline

Objective.

Minimize expression.

Parameters
objthe linear expression to minimize

Definition at line 277 of file ModelBuilder.cs.

◆ NewBoolVar()

Variable Google.OrTools.ModelBuilder.Model.NewBoolVar ( String name)
inline

Creates a bool variable with the given name.

Parameters
nameThe name of the variable
Returns
The new Boolean variable

Definition at line 103 of file ModelBuilder.cs.

◆ NewConstant()

Variable Google.OrTools.ModelBuilder.Model.NewConstant ( double value)
inline

Creates a constant variable.

Parameters
valuethe value of the constant variable
Returns
A new variable with a fixed value

Definition at line 113 of file ModelBuilder.cs.

◆ NewIntVar()

Variable Google.OrTools.ModelBuilder.Model.NewIntVar ( double lb,
double ub,
String name )
inline

Creates an integer variable with domain [lb, ub].

Parameters
lbThe lower bound of the variable
ubThe upper bound of the variable
nameThe name of the variable
Returns
The new integer variable

Definition at line 93 of file ModelBuilder.cs.

◆ NewNumVar()

Variable Google.OrTools.ModelBuilder.Model.NewNumVar ( double lb,
double ub,
String name )
inline

Creates a continuous variable with domain [lb, ub].

Parameters
lbThe lower bound of the variable
ubThe upper bound of the variable
nameThe name of the variable
Returns
The new continuous variable

Definition at line 81 of file ModelBuilder.cs.

◆ NewVar()

Variable Google.OrTools.ModelBuilder.Model.NewVar ( double lb,
double ub,
bool isIntegral,
String name )
inline

Integer variables.

reates a variable with domain [lb, ub].

Parameters
lbThe lower bound of the variable
ubThe upper bound of the variable
isIntegralIndicates if the variable is restricted to take only integral values
nameThe name of the variable
Returns
The new variable

Definition at line 69 of file ModelBuilder.cs.

◆ Optimize()

void Google.OrTools.ModelBuilder.Model.Optimize ( LinearExpr obj,
bool maximize )
inline

Sets the objective expression.

Parameters
objthe linear expression to optimize
maximizethe direction of the optimization

Definition at line 296 of file ModelBuilder.cs.

◆ VarFromIndex()

Variable Google.OrTools.ModelBuilder.Model.VarFromIndex ( int index)
inline

Rebuilds a variable from its index.

Definition at line 125 of file ModelBuilder.cs.

◆ VariablesCount()

int Google.OrTools.ModelBuilder.Model.VariablesCount ( )
inline

Returns the number of variables in the model.

Definition at line 346 of file ModelBuilder.cs.

Property Documentation

◆ Helper

ModelBuilderHelper Google.OrTools.ModelBuilder.Model.Helper
get

The model builder helper.

Definition at line 426 of file ModelBuilder.cs.

◆ Name

String Google.OrTools.ModelBuilder.Model.Name
getset

The name of the model.

Definition at line 362 of file ModelBuilder.cs.

◆ ObjectiveOffset

double Google.OrTools.ModelBuilder.Model.ObjectiveOffset
getset

The offset of the objective.

Definition at line 316 of file ModelBuilder.cs.


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