Skip to main content

result not correct

Answered

Comments

3 comments

  • Jaromił Najman
    • Gurobi Staff

    Hi Ghada,

    You should try to hard-code the excel database as lists in your code snippet to see what the lists should actually look like. This way you can compare the results of the lists you are currently generating from your excel files and what they actually should look like and then appropriately adjust your code.

    Note that you are writing the data from table \(\texttt{initial stock.xlsx}\) to object \(\texttt{S1}\) which you later override by optimization variables

    S1=m.addVars(products,weeks,name='S1')

    I am not sure what you want to achieve with the data from table \(\texttt{initial stock.xlsx}\) but if you want to use it afterwards, you should save it into a differently named object, e.g., \(\texttt{S1_table_data}\). You can then use it for whatever you need.

    Please note that in your code snippet you are reading 4 excel files but you provide only a screenshot of 2 tables. Moreover, providing screenshots of excel sheets is not helpful, because one cannot copy paste the data. If you want to share any excel table, you should either provide them in a format that can be easily copy pasted or upload the files somewhere as discussed in Posting to the Community Forum.

    Best regards, 
    Jaromił

    0
  • ghada ouerfelli
    • Gurobi-versary
    • Curious
    • Conversationalist

    hello by Initial stock I wanna say the S1 in my week zero , it is my initial stock , like this but i have a lot of products that is why I need an excel database 

    S1[1,0].lb=1
    S1[1,0].ub=1
    S1[2,0].lb=2
    S1[2,0].ub=2
    0
  • Matthias Miltenberger
    • Gurobi Staff

    Maybe you should try out Gurobi/gurobipy-pandas: Convenience wrapper for building optimization models from pandas data (github.com) to directly translate those tables into Gurobi data structures. Here's the documentation: Welcome to gurobipy-pandas’s documentation! — gurobipy-pandas 1.0.0 documentation (readthedocs-hosted.com)

    In any case, it's often not that easy to translate data tables into a correct mathematical formulation. You may need to iterate the process a few times to find all mistakes.

    Cheers,
    Matthias

    0

Please sign in to leave a comment.