Skip to main content

Comments

4 comments

  • Ru Xin Chua
    • Gurobi-versary
    • First Question
    • First Comment

    variable t is tupledict while arrivaltime is timedate64. that is why subtraction not possible. any idea how to convert

    0
  • Jaromił Najman
    • Gurobi Staff Gurobi Staff

    Could you please generate a minimal reproducible example showing the issue? Currently, it is not possible to execute your code, because all data is missing.

    Other than that, it does not seem to be a Gurobi issue but rather a data type issue. You should try to track down which subtraction exactly is responsible for the error.

    Best regards, 
    Jaromił

    0
  • Ru Xin Chua
    • Gurobi-versary
    • First Question
    • First Comment
    This variable gives a datatype of datetime64[ns]
    arrival=np.array(data["Vessel Arrival Time"])
     
    This variable gives a datatype of gurobi.var
    t=model.addVars(vessel_number,vtype=GRB.CONTINUOUS ,name="t")
     
    I get this when I check the first index of t
    t[0]
    <gurobi.Var *Awaiting Model Update*>
     
    The subtraction that caused the error is 
    constraint5=model.addConstrs(w[i]>=arrival[i]-t[i]for i in range(vessel_number) )
    0
  • Jaromił Najman
    • Gurobi Staff Gurobi Staff

    The error occurs because it is not possible to subtract/add Gurobi optimization variables from/to a datetime64[ns] object. You have to somehow convert your arrival values to numerical values. This stackoverflow thread should be helpful.

    Best regards, 
    Jaromił

    0

Please sign in to leave a comment.