当前位置:网站首页>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
边栏推荐
- Google Chrome reversecaptcha ad blocking
- OpenCV(二)——图像基本处理
- 收藏!0基础开源数据可视化平台FlyFish大屏开发指南
- 大数相加
- pdf 提取文字
- 插入word中的图片保持高dpi方法
- (二)动态卷积之Dynamic Convolution
- Your password does not satisfy the current policy requirements (modify MySQL password policy setting simple password)
- Install MySQL using CentOS yum
- Boolean value
猜你喜欢

DRF learning notes (I): Data Serialization

(2) Dynamic convolution of dynamic convolution

Rotate the whole model in ADAMS

codis集群部署

低代码是开发的未来吗?浅谈低代码平台

Rotate string left

Leetcode234 question - simple method to judge palindrome linked list

Opencv (IV) -- image features and target detection

Matlab legend usage

201403-1
随机推荐
Replication of complex linked list
Flowable process custom attribute
Use of arrow function
solidwork装配体导入到Adams中出现多个Part重名和Part丢失的情况处理
Codeforces Round #100 E. New Year Garland & 2021 CCPC Subpermutation
Json数据的格式使用
The method of inserting degree in word
Embedded interview
gpt-2 文本生成
Bean: Model: Entity的区别
指针总结
Collection! 0 basic open source data visualization platform flyfish large screen development guide
C language output string in reverse order
Unable to enter the function definition after transferring the IAR project folder to the directory
最大子段和 Go 四种的四种求解
Reduce PDF document size (Reprint)
CCF-201312-1
Exe program encryption lock
[cqoi2012] local minima & Mike and foam
获取当前时间的前N天和前后天的数组列表循环遍历每一天