Skip to content

Commit a607d1d

Browse files
committed
Document GRB and COPT
1 parent ef92404 commit a607d1d

File tree

2 files changed

+39
-0
lines changed

2 files changed

+39
-0
lines changed

Diff for: docs/source/copt.md

+17
Original file line numberDiff line numberDiff line change
@@ -68,3 +68,20 @@ COPT provides [information](https://guide.coap.online/copt/en-doc/information.ht
6868

6969
- Information of variable: `model.get_variable_info(variable, name: str)`
7070
- Information of constraint: `model.get_constraint_info(constraint, name: str)`
71+
72+
We also provide `copt.COPT` to contain all the constants in `coptpy.COPT`.
73+
74+
For number of variables (columns) in the problem:
75+
```python
76+
cols = model.get_raw_attribute(copt.COPT.Attr.Cols)
77+
```
78+
79+
For reduced cost of a variable:
80+
```python
81+
rc = model.get_variable_info(variable, copt.COPT.Info.RedCost)
82+
```
83+
84+
For upper bound of a constraint:
85+
```python
86+
ub = model.get_constraint_info(constraint, copt.COPT.Info.UB)
87+
```

Diff for: docs/source/gurobi.md

+22
Original file line numberDiff line numberDiff line change
@@ -76,3 +76,25 @@ Gurobi supports a lot of [attributes](https://www.gurobi.com/documentation/curre
7676
- Model attribute: `model.get_model_raw_attribute(name: str)` and `model.set_model_raw_attribute(name: str, value: Any)`
7777
- Variable attribute: `model.get_variable_raw_attribute(variable, name: str)` and `model.set_variable_raw_attribute(variable, name: str, value: Any)`
7878
- Constraint attribute: `model.get_constraint_raw_attribute(constraint, name: str)` and `model.set_constraint_raw_attribute(constraint, name: str, value: Any)`
79+
80+
We also provide `gurobi.GRB` to contain all the constants in `gurobipy.GRB`.
81+
82+
For model status:
83+
```python
84+
status = model.get_model_raw_attribute(gurobi.GRB.Attr.Status)
85+
86+
if status == gurobi.GRB.OPTIMAL:
87+
...
88+
elif status == gurobi.GRB.INFEASIBLE:
89+
...
90+
```
91+
92+
For reduced cost of a variable:
93+
```python
94+
rc = model.get_variable_raw_attribute(variable, gurobi.GRB.Attr.RC)
95+
```
96+
97+
For right-hand side value of a constraint:
98+
```python
99+
rhs = model.get_constraint_raw_attribute(constraint, gurobi.GRB.Attr.RHS)
100+
```

0 commit comments

Comments
 (0)