在利用Python+Gurobi建模一个数学规划时, 通常会依照此顺序進行设定变量、目标函数、限制式等。

常用的三大函数和属性
三大函数
- 决策变量函数

- 目标函数

- 限制式函数

Gurobi attributes
-
model attributes
| Attribute Name | Description |
|NumVars| Number of variables|
| NumConstrs | Number of linear constraints|
| ObjVal | objective value for current solution| -
Variable attributes
| Attribute Name | Description |
| LB | Lower bound
| Obj | Linear objective coefficient
| VarName | Variable name
| X | Value in the current solution -
linear constraint attributes
| Attribute Name | Description |
| ConstrName | Constraint name
| Pi | Dual value (also known as the shadow price)
| Slack | Slack in the current solution
本文详细介绍如何使用Python配合Gurobi进行数学规划,涵盖决策变量、目标函数设置、限制式定义,以及关键函数和属性详解。理解Variable、Objective和Constraint的Gurobi API,掌握模型和变量属性,为优化问题求解提供实践指导。
1万+

被折叠的 条评论
为什么被折叠?



