how to define the decission variable if we are having 2 variable in one table onw is binary variable, 2nd is integer variable.
AnsweredHi Team,
Hope you are doing well.
This is an table in which i am having 2 variable, 'flow' and 'unit_flow' how to define it but it should be in one table and i have set the 2 index(origin, destination)
| origin | destination | kms |
| chennai | chennai | 100 |
| chennai | bhopal | 1170.1 |
| chennai | bhubaneshwar | 994.8 |
| chennai | jaipur | 1605.6 |
| chennai | kochi | 556.1 |
| chennai | kolkata | 1358.1 |
| chennai | lucknow | 1532.6 |
| chennai | mumbai | 1033.5 |
| chennai | nasik | 1034.6 |
| chennai | new delhi | 1756 |
Out put should be like this
| origin | destination | kms | flow | units_flow |
| chennai | chennai | 100 | flow variable | units_flow variable |
| chennai | bhopal | 1170.1 | flow variable | units_flow variable |
| chennai | bhubaneshwar | 994.8 | flow variable | units_flow variable |
| chennai | jaipur | 1605.6 | flow variable | units_flow variable |
| chennai | kochi | 556.1 | flow variable | units_flow variable |
| chennai | kolkata | 1358.1 | flow variable | units_flow variable |
| chennai | lucknow | 1532.6 | flow variable | units_flow variable |
| chennai | mumbai | 1033.5 | flow variable | units_flow variable |
| chennai | nasik | 1034.6 | flow variable | units_flow variable |
| chennai | new delhi | 1756 | flow variable | units_flow variable |
0
-
Official comment
This post is more than two years old. Some information may not be up to date. For current information, please check the Gurobi Documentation or Knowledge Base. If you need more help, please create a new post in the community forum, or try Gurobot, our chatbot interface offering instant, expert-level support. -
Can you clarify what you mean by "it should be in one table"? You will have to define the \(\texttt{flow}\) variables and \(\texttt{units_flow}\) variables separately. Can you share what code you have so far?
0 -
Hi Team,
Hope you are doing well.
i am usibg these code to define the variable.
units_flow = (Orig_Dest.gppd.add_vars(model, vtype=GRB.INTEGER, name="units_flow"))units_flow.set_index(['origin', 'destination'], inplace=True)origin destination km units_flow chennai chennai 100.0 <gurobi.Var *Awaiting Model Update*> bhopal 1170.1 <gurobi.Var *Awaiting Model Update*> bhubaneshwar 994.8 <gurobi.Var *Awaiting Model Update*> jaipur 1605.6 <gurobi.Var *Awaiting Model Update*> kochi 556.1 <gurobi.Var *Awaiting Model Update*> flow = (Orig_Dest.gppd.add_vars(model, vtype=GRB.BINARY, name="flow"))flow.set_index(['origin', 'destination'], inplace=True)origin destination km flow chennai chennai 100.0 <gurobi.Var *Awaiting Model Update*> bhopal 1170.1 <gurobi.Var *Awaiting Model Update*> bhubaneshwar 994.8 <gurobi.Var *Awaiting Model Update*> jaipur 1605.6 <gurobi.Var *Awaiting Model Update*> kochi 556.1 <gurobi.Var *Awaiting Model Update*> however i am getting 2 table but i want to defin both variable in one table like thisi am trying to get the output like this tableorigin destination km flow unit_flow chennaichennai 100 <gurobi.Var *Awaiting Model Update*> <gurobi.Var *Awaiting Model Update*> bhopal 1170.1 <gurobi.Var *Awaiting Model Update*> <gurobi.Var *Awaiting Model Update*> bhubaneshwar 994.8 <gurobi.Var *Awaiting Model Update*> <gurobi.Var *Awaiting Model Update*> jaipur 1605.6 <gurobi.Var *Awaiting Model Update*> <gurobi.Var *Awaiting Model Update*> kochi 556.1 <gurobi.Var *Awaiting Model Update*> <gurobi.Var *Awaiting Model Update*> 0 -
Hi Mohd,
You can use the following
flow_vars = (
Orig_Dest
.gppd.add_vars(model, vtype=GRB.BINARY, name="flow")
.gppd.add_vars(model, vtype=GRB.INTEGER, name="units_flow")
.set_index(["origin", "destination"])
)I would avoid using the inplace=True argument.
- Riley
0
Post is closed for comments.
Comments
4 comments