当前位置:网站首页>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
边栏推荐
- string数字类型转换为千分位
- my_ls小结
- ADAMS中转动整个模型
- Opencv (IV) -- image features and target detection
- my_ Ls summary
- OpenCV(三)——图像分割
- Crmeb Pro v1.4 makes the user experience more brilliant!
- 闲聊技巧
- What is ti's calculation for successively canceling the agency rights of anfuli / Wenye / Shiping?
- Opencv (V) -- moving target recognition
猜你喜欢

字节跳动服务网格基于 Hertz 框架的落地实践

Clear understanding of torchvision (mind map)

OpenCV(三)——图像分割

OpenCV(四)——图像特征与目标检测

The 21st - -- the 30th time

201403-1

Your password does not satisfy the current policy requirements (modify MySQL password policy setting simple password)

Implementation of filler creator material editing tool

Notes on implementation and acquisition of flowable custom attributes

DRF learning notes (V): viewset
随机推荐
大数相加
Cubemx combined with IAR engineering transplantation
my_ Ls summary
重新配置cubemx后,生成的代码用IAR打开不成功
How PHP changes a two-dimensional array into a one-dimensional array
OpenCV(二)——图像基本处理
DRF learning notes (V): viewset
codis集群部署
[cqoi2012] local minima & Mike and foam
Rotate the whole model in ADAMS
TP5 query empty two cases
Chuanyin holdings disclosed that it was prosecuted by Huawei: a case has been filed, involving an amount of 20million yuan
Find active SQL connections in SQL Server
将IAR工程文件夹转移目录后无法进入函数定义解决
Solve the problem that ${pagecontext.request.contextpath} is invalid
收藏!0基础开源数据可视化平台FlyFish大屏开发指南
Insert pictures in word to maintain high DPI method
DRF learning notes (preparation)
Chat skills
CCF-201312-1