Skip to main content

how to define the decission variable if we are having 2 variable in one table onw is binary variable, 2nd is integer variable.

Answered

Comments

3 comments

  • Eli Towle
    Gurobi Staff Gurobi Staff

    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
  • Mohd Munasib
    Curious
    Conversationalist

    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 this
     
    i am trying to get the output like this table 
    origin destination km flow unit_flow
    chennai
    chennai 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
  • Riley Clement
    Gurobi Staff Gurobi Staff

    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

Please sign in to leave a comment.