idol
A C++ Framework for Optimization
Loading...
Searching...
No Matches
idol::Model Class Reference

#include <Model.h>

Collaboration diagram for idol::Model:
Collaboration graph

Public Types

enum  Storage { ColumnOriented , RowOriented , Both }
 

Public Member Functions

 Model (Env &t_env, Storage t_storage=Both)
 
 Model (Model &&) noexcept
 
Modeloperator= (const Model &)=delete
 
Modeloperator= (Model &&) noexcept=delete
 
Var add_var (double t_lb, double t_ub, VarType t_type, double t_obj=0., std::string t_name="")
 
Var add_var (double t_lb, double t_ub, VarType t_type, double t_obj, LinExpr< Ctr > t_column, std::string t_name="")
 
template<unsigned int N>
Vector< Var, N > add_vars (Dim< N > t_dim, double t_lb, double t_ub, VarType t_type, double t_obj=0., const std::string &t_name="")
 
void add (const Var &t_var)
 
void add (const Var &t_var, TempVar t_temp_var)
 
bool has (const Var &t_var) const
 
void remove (const Var &t_var)
 
ConstIteratorForward< std::vector< Var > > vars () const
 
Ctr add_ctr (TempCtr t_temp_ctr, std::string t_name="")
 
Ctr add_ctr (LinExpr< Var > &&t_lhs, CtrType t_type, double t_rhs, std::string t_name="")
 
template<unsigned int N>
Vector< Ctr, N > add_ctrs (Dim< N > t_dim, CtrType t_type, double t_rhs, const std::string &t_name="")
 
void add (const Ctr &t_ctr)
 
void add (const Ctr &t_ctr, TempCtr t_temp_ctr)
 
bool has (const Ctr &t_ctr) const
 
void remove (const Ctr &t_ctr)
 
ConstIteratorForward< std::vector< Ctr > > ctrs () const
 
QCtr add_qctr (TempQCtr t_temp_ctr, std::string t_name="")
 
QCtr add_qctr (QuadExpr< Var > &&t_expr, CtrType t_type, std::string t_name="")
 
template<unsigned int N>
Vector< QCtr, N > add_qctrs (Dim< N > t_dim, CtrType t_type, const std::string &t_name="")
 
void add (const QCtr &t_ctr)
 
void add (const QCtr &t_ctr, TempQCtr t_temp_ctr)
 
bool has (const QCtr &t_ctr) const
 
void remove (const QCtr &t_ctr)
 
ConstIteratorForward< std::vector< QCtr > > qctrs () const
 
SOSCtr add_sosctr (bool t_is_sos1, std::vector< Var > t_vars, std::vector< double > t_weights, std::string t_name="")
 
void add (const SOSCtr &t_ctr, bool t_is_sos1, const std::vector< Var > &t_vars, const std::vector< double > &t_weights)
 
void add (const SOSCtr &t_ctr)
 
void remove (const SOSCtr &t_ctr)
 
ConstIteratorForward< std::vector< SOSCtr > > sosctrs () const
 
bool has (const SOSCtr &t_ctr) const
 
unsigned int id () const
 
Modelclone () const
 
Model copy () const
 
void reserve_vars (unsigned int t_size)
 
void reserve_ctrs (unsigned int t_size)
 
void reserve_qctrs (unsigned int t_size)
 
void reserve_sos_ctrs (unsigned int t_size)
 
Envenv () const
 
void use (const OptimizerFactory &t_optimizer_factory)
 
bool has_optimizer () const
 
bool has_optimizer_factory () const
 
const OptimizerFactoryoptimizer_factory () const
 
void unuse ()
 
template<class T , unsigned int N>
void add_vector (const Vector< T, N > &t_vector)
 
Optimizeroptimizer ()
 
const Optimizeroptimizer () const
 
void optimize ()
 
void write (const std::string &t_name)
 
void update ()
 
ObjectiveSense get_obj_sense () const
 
const QuadExpr< Var > & get_obj_expr () const
 
const LinExpr< Ctr > & get_rhs_expr () const
 
double get_mat_coeff (const Ctr &t_ctr, const Var &t_var) const
 
SolutionStatus get_status () const
 
SolutionReason get_reason () const
 
double get_best_obj () const
 
double get_best_bound () const
 
void set_obj_sense (ObjectiveSense t_value)
 
void set_obj_expr (const QuadExpr< Var > &t_objective)
 
void set_obj_expr (QuadExpr< Var > &&t_objective)
 
void set_rhs_expr (LinExpr< Ctr > &&t_rhs)
 
void set_rhs_expr (const LinExpr< Ctr > &t_rhs)
 
void set_obj_const (double t_constant)
 
void set_mat_coeff (const Ctr &t_ctr, const Var &t_var, double t_coeff)
 
QCtr get_qctr_by_index (unsigned int t_index) const
 
Ctr get_ctr_by_index (unsigned int t_index) const
 
Var get_var_by_index (unsigned int t_index) const
 
SOSCtr get_sosctr_by_index (unsigned int t_index) const
 
unsigned int get_ctr_index (const Ctr &t_ctr) const
 
unsigned int get_qctr_index (const QCtr &tctr) const
 
unsigned int get_sosctr_index (const SOSCtr &t_ctr) const
 
CtrType get_ctr_type (const Ctr &t_ctr) const
 
double get_ctr_rhs (const Ctr &t_ctr) const
 
const LinExpr< Var > & get_ctr_row (const Ctr &t_ctr) const
 
const QuadExpr< Var > & get_qctr_expr (const QCtr &t_ctr) const
 
CtrType get_qctr_type (const QCtr &t_ctr) const
 
double get_ctr_dual (const Ctr &t_ctr) const
 
double get_ctr_farkas (const Ctr &t_ctr) const
 
void set_ctr_rhs (const Ctr &t_ctr, double t_rhs)
 
void set_ctr_type (const Ctr &t_ctr, CtrType t_type)
 
void set_ctr_row (const Ctr &t_ctr, const LinExpr< Var > &t_row)
 
void set_ctr_row (const Ctr &t_ctr, LinExpr< Var > &&t_row)
 
unsigned int get_var_index (const Var &t_var) const
 
VarType get_var_type (const Var &t_var) const
 
double get_var_lb (const Var &t_var) const
 
double get_var_ub (const Var &t_var) const
 
double get_var_primal (const Var &t_var) const
 
double get_var_reduced_cost (const Var &t_var) const
 
double get_var_ray (const Var &t_var) const
 
const LinExpr< Ctr > & get_var_column (const Var &t_var) const
 
double get_var_obj (const Var &t_var) const
 
void set_var_type (const Var &t_var, VarType t_type)
 
void set_var_lb (const Var &t_var, double t_lb)
 
void set_var_ub (const Var &t_var, double t_ub)
 
void set_var_obj (const Var &t_var, double t_obj)
 
void set_var_column (const Var &t_var, const LinExpr< Ctr > &t_column)
 
void set_var_column (const Var &t_var, LinExpr< Ctr > &&t_column)
 
const std::vector< Var > & get_sosctr_vars (const SOSCtr &t_ctr) const
 
const std::vector< double > & get_sosctr_weights (const SOSCtr &t_ctr) const
 
bool is_sos1 (const SOSCtr &t_ctr) const
 
unsigned int get_n_solutions () const
 
unsigned int get_solution_index () const
 
void set_solution_index (unsigned int t_index)
 
void dump (std::ostream &t_os=std::cout) const
 
Storage storage () const
 
void set_storage (Storage t_storage, bool t_reset_minor_representation=false)
 
void reset_minor_representation ()
 
template<unsigned int N>
idol::Vector< idol::Var, N > add_vars (Dim< N > t_dim, double t_lb, double t_ub, VarType t_type, double t_obj, const std::string &t_name)
 
template<unsigned int N>
idol::Vector< idol::Ctr, N > add_ctrs (Dim< N > t_dim, CtrType t_type, double t_rhs, const std::string &t_name)
 

Detailed Description

This class is used to represent a mathematical optimization model.

Definition at line 43 of file Model.h.

Member Enumeration Documentation

◆ Storage

enum idol::Model::Storage

Definition at line 45 of file Model.h.

Member Function Documentation

◆ add_ctrs()

template<unsigned int N>
idol::Vector< idol::Ctr, N > idol::Model::add_ctrs ( Dim< N >  t_dim,
CtrType  t_type,
double  t_rhs,
const std::string &  t_name 
)

Definition at line 327 of file Model.h.

◆ add_vars()

template<unsigned int N>
idol::Vector< idol::Var, N > idol::Model::add_vars ( Dim< N >  t_dim,
double  t_lb,
double  t_ub,
VarType  t_type,
double  t_obj,
const std::string &  t_name 
)

Definition at line 320 of file Model.h.

◆ add_vector()

template<class T , unsigned int N>
void idol::Model::add_vector ( const Vector< T, N > &  t_vector)

Definition at line 307 of file Model.h.

◆ ctrs()

ConstIteratorForward< std::vector< Ctr > > idol::Model::ctrs ( ) const
inline

Definition at line 121 of file Model.h.

◆ env()

Env & idol::Model::env ( ) const
inline

Definition at line 165 of file Model.h.

◆ has_optimizer_factory()

bool idol::Model::has_optimizer_factory ( ) const
inline

Definition at line 171 of file Model.h.

◆ id()

unsigned int idol::Model::id ( ) const
inline

Definition at line 151 of file Model.h.

◆ optimizer() [1/2]

Optimizer & idol::Model::optimizer ( )
inline

Definition at line 179 of file Model.h.

◆ optimizer() [2/2]

const Optimizer & idol::Model::optimizer ( ) const
inline

Definition at line 181 of file Model.h.

◆ optimizer_factory()

const OptimizerFactory & idol::Model::optimizer_factory ( ) const
inline

Definition at line 173 of file Model.h.

◆ qctrs()

ConstIteratorForward< std::vector< QCtr > > idol::Model::qctrs ( ) const
inline

Definition at line 137 of file Model.h.

◆ sosctrs()

ConstIteratorForward< std::vector< SOSCtr > > idol::Model::sosctrs ( ) const
inline

Definition at line 147 of file Model.h.

◆ storage()

Storage idol::Model::storage ( ) const
inline

Definition at line 299 of file Model.h.

◆ vars()

ConstIteratorForward< std::vector< Var > > idol::Model::vars ( ) const
inline

Definition at line 105 of file Model.h.