Skip to content

Commit

Permalink
Document GRB and COPT
Browse files Browse the repository at this point in the history
  • Loading branch information
metab0t committed Jun 12, 2024
1 parent ef92404 commit a607d1d
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 0 deletions.
17 changes: 17 additions & 0 deletions docs/source/copt.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,3 +68,20 @@ COPT provides [information](https://guide.coap.online/copt/en-doc/information.ht

- Information of variable: `model.get_variable_info(variable, name: str)`
- Information of constraint: `model.get_constraint_info(constraint, name: str)`

We also provide `copt.COPT` to contain all the constants in `coptpy.COPT`.

For number of variables (columns) in the problem:
```python
cols = model.get_raw_attribute(copt.COPT.Attr.Cols)
```

For reduced cost of a variable:
```python
rc = model.get_variable_info(variable, copt.COPT.Info.RedCost)
```

For upper bound of a constraint:
```python
ub = model.get_constraint_info(constraint, copt.COPT.Info.UB)
```
22 changes: 22 additions & 0 deletions docs/source/gurobi.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,3 +76,25 @@ Gurobi supports a lot of [attributes](https://www.gurobi.com/documentation/curre
- Model attribute: `model.get_model_raw_attribute(name: str)` and `model.set_model_raw_attribute(name: str, value: Any)`
- Variable attribute: `model.get_variable_raw_attribute(variable, name: str)` and `model.set_variable_raw_attribute(variable, name: str, value: Any)`
- Constraint attribute: `model.get_constraint_raw_attribute(constraint, name: str)` and `model.set_constraint_raw_attribute(constraint, name: str, value: Any)`

We also provide `gurobi.GRB` to contain all the constants in `gurobipy.GRB`.

For model status:
```python
status = model.get_model_raw_attribute(gurobi.GRB.Attr.Status)

if status == gurobi.GRB.OPTIMAL:
...
elif status == gurobi.GRB.INFEASIBLE:
...
```

For reduced cost of a variable:
```python
rc = model.get_variable_raw_attribute(variable, gurobi.GRB.Attr.RC)
```

For right-hand side value of a constraint:
```python
rhs = model.get_constraint_raw_attribute(constraint, gurobi.GRB.Attr.RHS)
```

0 comments on commit a607d1d

Please sign in to comment.