当前位置:网站首页>Gurobi——GRBModel
Gurobi——GRBModel
2022-07-27 16:40:00 【An audience who doesn't understand music】
List of articles
GRBModel
Gurobi Model object . Common methods include addVar( Add a new decision variable to the model )、addConstr( Add a new constraint to the model )、optimize( Optimize the current model )、get( Retrieve the value of a property ).
GRBModel GRBModel(const GRBEnv& env)
Model constructor .
| Parameters | Detailed explanation |
|---|---|
| env | The environment of the new model . |
| Return value | New model object . The model does not initially contain variables or constraints . |
GRBModel GRBModel(const GRBEnv& env,
const string& filename)
Read the model from the file . Please note that , The type code of the file is in the suffix of the file name . Valid suffixes are .mps、.rew、.lp、.rlp、.dua、.dlp、.ilp or .opb. These files can be compressed , Therefore, additional .zip、.gz、.bz2 or .7z suffix .
| Parameters | Detailed explanation |
|---|---|
| env | The environment of the new model . |
| modelname | The name of the file containing the model . |
| Return value | New model object . |
GRBModel GRBModel(const GRBModel& model)
Create a copy of an existing model . Please note that , because Gurobi Lazy update method in , You must call before copying. update .
| Parameters | Detailed explanation |
|---|---|
| model: Models that need to be copied . | |
| Return value | New model object . A model is a clone of an input model . |
GRBModel::addConstr()
Add a single linear constraint to the model . Multiple signatures (signatures) You can use .
GRBConstr addConstr(const GRBLinExpr& lhsExpr, char sense, const GRBLinExpr& rhsExpr, string name="" )Add a single linear constraint to the model .
Parameters Detailed explanation lhsExpr Left expression of the new linear constraint . sense New linear perceptual constraints (GRB_LESS_EQUAL、GRB_EQUAL or GRB_GREATER_EQUAL). rhsExpr Right expression of the new linear constraint . names( Optional ) The name of the new constraint . Return value New constraint object . GRBConstr addConstr(const GRBLinExpr& lhsExpr, char sense, GRBVar rhsVar, string name="" )Add a single linear constraint to the model .
Parameters Detailed explanation lhsExpr Left expression of the new linear constraint . sense New linear perceptual constraints (GRB_LESS_EQUAL、GRB_EQUAL or GRB_GREATER_EQUAL). rhsVar Right variable of the new linear constraint . name( Optional ) The name of the new constraint . Return value New constraint object . GRBConstr addConstr (const GRBLinExpr& lhsExpr, char sense, double rhsVal, string name="")Add a single linear constraint to the model .
Parameters Detailed explanation lhsExpr Left expression of the new linear constraint . sense New linear perceptual constraints (GRB_LESS_EQUAL、GRB_EQUAL or GRB_GREATER_EQUAL). rhsVal The right value of the new linear constraint . name( Optional ) The name of the new constraint . Return value New constraint object . GRBConstr addConstr(GRBVar lhsVar, char sense, GRBVar rhsVar, string name="" )Add a single linear constraint to the model .
Parameters Detailed explanation lhsVar Left variable of the new linear constraint . sense New linear perceptual constraints (GRB_LESS_EQUAL、GRB_EQUAL or GRB_GREATER_EQUAL). rhsVar Right variable of the new linear constraint . name( Optional ) The name of the new constraint . Return value New constraint object . GRBConstr addConstr(GRBVar lhsVar, char sense, double rhsVal, string name="")Add a single linear constraint to the model .
Parameters Detailed explanation lhsVar Left variable of the new linear constraint . sense New linear perceptual constraints (GRB_LESS_EQUAL、GRB_EQUAL or GRB_GREATER_EQUAL). rhsVal The right value of the new linear constraint . name( Optional ) The name of the new constraint . Return value New constraint object . GRBConstr addConstr(GRBTempConstr& tc, string name="")Add a single linear constraint to the model .
Parameters Detailed explanation tc Temporary constraint object , Create using overloaded comparison operators . For more information , see also GRBTempConstr. name( Optional ) The name of the new constraint . Return value New constraint object .
GRBModel::addVar()
Add a single decision variable to the model .
Templates 1
GRBVar addVar (double lb,
double ub,
double obj,
char type,
string name="" )
Add a variable ; Non zero entries will be added later .
| Parameters | Detailed explanation |
|---|---|
| lb | The lower bound of the new variable . |
| ub | The upper limit of the new variable . |
| obj | The objective coefficient of the new variable . |
| type | The variable type of the new variable (GRB_CONTINUOUS、GRB_BINARY、GRB_INTEGER、GRB_SEMICONT or GRB_SEMIINT). |
| names( Optional ) | The name of the new variable . |
| Return value | New variable object . |
Templates 2
GRBVar addVar (double lb,
double ub,
double obj,
char type,
int numnz,
const GRBConstr* constrs,
const double* coeffs,
string name="" )
Add a variable , And the associated non-zero coefficient .
| Parameters | Detailed explanation |
|---|---|
| lb | The lower bound of the new variable . |
| ub | The upper limit of the new variable . |
| obj | The objective coefficient of the new variable . |
| type | The variable type of the new variable (GRB_CONTINUOUS、GRB_BINARY、GRB_INTEGER、GRB_SEMICONT or GRB_SEMIINT). |
| numnz | The number of constraints this new variable participates in . |
| constrs | Constraint array with variable participation . |
| coeffs | An array of coefficients for each constraint in which the variable participates . |
| names( Optional ) | The name of the new variable . |
| Return value | New variable object . |
Templates 3
GRBVar addVar (double lb,
double ub,
double obj,
char type,
const GRBColumn& col,
string name="" )
Add a variable , And the associated non-zero coefficient .
| Parameters | Detailed explanation |
|---|---|
| lb | The lower bound of the new variable . |
| ub | The upper limit of the new variable . |
| obj | The objective coefficient of the new variable . |
| type | The variable type of the new variable (GRB_CONTINUOUS、GRB_BINARY、GRB_INTEGER、GRB_SEMICONT or GRB_SEMIINT). |
| col | GRBColumn object , Specifies the set of constraints to which the new variable belongs . |
| names( Optional ) | The name of the new variable . |
| Return value | New variable object . |
GRBModel::addVars()
Add new decision variables to the model .
Templates 1
GRBVar* addVars(int count,
char type=GRB_CONTINUOUS)
Add to model count A new decision variable . All associated properties adopt their default values , Except for variable types , It is specified as a parameter .
| Parameters | Detailed explanation |
|---|---|
| count | Number of variables to add |
| type ( Optional ) | Type of newly added variable , optional type : GRB_CONTINUOUS, GRB_BINARY, GRB_INTEGER, GRB_SEMICONT, or GRB_SEMIINT |
| Return value | Array of new variable objects . Please note that , The result is heap allocated , And must be returned to the heap by the user . |
Templates 2
GRBVar* addVars(const double* lb,
const double* ub,
const double* obj,
const char* type,
const string* names,
int count )
Add a new decision variable to the model . This function name allows the use of arrays to hold various variable properties ( For example, lower limit 、 Upper limit, etc ).
| Parameters | Detailed explanation |
|---|---|
| lb | The lower bound of the new variable . It can be for NULL, under these circumstances , The lower bound of the variable is 0.0. |
| ub | The upper limit of the new variable . It can be for NULL, under these circumstances , Variable gets an infinite upper bound . |
| obj | The objective coefficient of the new variable (Objective coefficients). It can be for NULL, under these circumstances , The objective coefficient of the variable is 0.0. |
| type | The variable type of the new variable (GRB_CONTINUOUS、GRB_BINARY、GRB_INTEGER、GRB_SEMICONT or GRB_SEMIINT). It can be for NULL, In this case, the variables are assumed to be continuous . |
| names | The name of the new variable . It can be for NULL, under these circumstances , All variables are given default names . |
| count | Number of variables to add . |
| Return value | Array of new variable objects . Please note that , The result is heap allocated , And must be returned to the heap by the user . |
Templates 3
GRBVar* addVars(const double* lb,
const double* ub,
const double* obj,
const char* type,
const string* names,
const GRBColumn* cols,
int count )
Add new decision variables to the model . This function allows the use of GRBColumn Object array specifies the set of constraints to which each new variable belongs .
| Parameters | Detailed explanation |
|---|---|
| lb | The lower bound of the new variable . It can be for NULL, under these circumstances , The lower bound of the variable is 0.0. |
| ub | The upper limit of the new variable . It can be for NULL, under these circumstances , Variable gets an infinite upper bound . |
| obj | The objective coefficient of the new variable . It can be for NULL, under these circumstances , The objective coefficient of the variable is 0.0. |
| type | The variable type of the new variable (GRB_CONTINUOUS、GRB_BINARY、GRB_INTEGER、GRB_SEMICONT or GRB_SEMIINT). It can be for NULL, In this case, the variables are assumed to be continuous . |
| names | The name of the new variable . It can be for NULL, under these circumstances , All variables are given default names . |
| cols | GRBColumn object , Specifies the set of constraints to which each new column belongs . |
| count | Number of variables to add . |
| Return value | Array of new variable objects . Please note that , The result is heap allocated , And must be returned to the heap by the user . |
Reference resources
边栏推荐
- Snowflake ID (go Implementation)
- mvc和mvp和mvvm的区别
- 大数相加
- 【论文阅读】Single- and Cross-Modality Near Duplicate Image PairsDetection via Spatial Transformer Compar
- my_ Ls summary
- Cubemx联合IAR工程移植
- Json数据的格式使用
- Pointer summary
- Rotate the whole model in ADAMS
- Leetcode234 question - simple method to judge palindrome linked list
猜你喜欢

Handling of multiple parts with duplicate names and missing parts when importing SOLIDWORK assemblies into Adams

Solve the problem that Flink cannot be closed normally after startup

【论文阅读】Transformer with Transfer CNN for Remote-Sensing-ImageObject Detection

Draw circuit diagram according to Verilog code

201403-1

插入word中的图片保持高dpi方法

TP5 paging some small points

减小PDF文档大小(转载)

Snowflake ID (go Implementation)

Collection! 0 basic open source data visualization platform flyfish large screen development guide
随机推荐
The class declared by the scala object keyword directly calls methods and associated objects
What is ti's calculation for successively canceling the agency rights of anfuli / Wenye / Shiping?
Json数据的格式使用
【论文阅读】Single- and Cross-Modality Near Duplicate Image PairsDetection via Spatial Transformer Compar
Implementation of ByteDance service grid based on Hertz framework
2021-06-02
Chuanyin holdings disclosed that it was prosecuted by Huawei: a case has been filed, involving an amount of 20million yuan
Mysql5.7 master-slave hot standby settings on CentOS
Pointer summary
TSMC's 6-nanometer manufacturing process will enter trial production in the first quarter of next year
OpenCV(三)——图像分割
2021-03-09
Segment tree beats~
MySQL high version report SQL_ mode=only_ full_ group_ By exception
Four solutions of maximum sub segment and go
TP5 -- query field contains a certain --find of search criteria_ IN_ SET
Script file ‘D:\programs\anaconda3\Scripts\pip-script.py‘ is not present.
The whereor method of TP5 has many conditions
const小结
雪花ID(Go 实现)