メインコンテンツへスキップ

Can't get the results

進行中

コメント

7件のコメント

  • 正式なコメント
    Simranjit Kaur
    • Gurobi Staff Gurobi Staff
    This post is more than three 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 why not try our AI Gurobot?.
  • Alison Cozad
    • Gurobi Staff Gurobi Staff

    When I look at your log output screen, it appears that there were 0 constraints and 0 variables added to the model:

    Optimize a model with 0 rows, 0 columns, and 0 nonzeros

    It looks like you may not be specifying \(\texttt{Arcs}\), \(\texttt{Vertex}\), and \(\texttt{Commodities}\) after initializing them.  Once you set these, your variable and constraint loops should populate your model.

    0
  • Rithika Jaiswal
    • Gurobi-versary
    • First Question
    • Conversationalist

    Thank you for answering, could you like give  an example to help me understand more as I am new to this.

     

    0
  • Alison Cozad
    • Gurobi Staff Gurobi Staff

    I think I see a good example from your code.  In lines 12-14, you create \(\texttt{Arcs}\), \(\texttt{Nodes}\), and \(\texttt{Commodities}\):

    Arcs = []
    Nodes = [] # I assume Nodes/Vertex should be the same
    Commodities = []

    As we discussed, the challenge is that these variables are never defined before being used to define your \(\texttt{for}\) loops later in the code.  Therefore, you could use the code you commented out to give these variables values instead of or after initializing them:

    Arcs = [(1,2,1,20),(1,3,1,10),(2,3,2,10),(2,4,4,20),(3,4,8,40),(3,5,5,10),(4,5,3,30)]
    Nodes = [1,2,3,4,5]
    Commodities = [(1,4,15),(1,5,5),(2,5,10),(3,5,5)]

    Alternatively, it looks like your data may be stored in "C:\Users\rithi\Downloads\Input_lecct.xlsx". So, it may be best to pull the data out of this.  While I do not know quite what your data looks like, my best guess is that the data you want for \(\texttt{Arcs}\) is stored in \(\texttt{List_arcs}\) in your code. And the data you want to \(\texttt{Commodities}\) is stored in \(\texttt{List_commo}\) in your code.

    0
  • Rithika Jaiswal
    • Gurobi-versary
    • First Question
    • Conversationalist

    Thank you, also our input data is from the spreadsheet not from the code itself, could you guide us on how to iterate the data?

    0
  • Alison Cozad
    • Gurobi Staff Gurobi Staff

    You can read from an excel spreadsheet in Python using the pandas.read_excel() function.  There is a good tutorial on how to use this function here: Read Excel with Python Pandas - Python Tutorial.

    Here is an example of reading a column named 'vertex' from a worksheet 'Vertex' in an excel file called 'MyExcelFile.xslx':

    import pandas as pd

    df = pd.read_excel('MyExcelFile.xlsx',sheet_name="Vertex") # read in data from your excel spreadsheet
    data_from_column_vertex = df['vertex'].tolist() # get a list from the column vertex
    print(data_from_column_vertex) # Review the column that you pulled in

    I will leave it to you to read the rest of your data from your spreadsheets then define \(\texttt{Arcs}\), \(\texttt{Nodes}\), and \(\texttt{Commodoties}\). Once you have populated these variables, the loops you wrote (e.g., \(\texttt{for j in range(len(Nodes)):}\) ) will have something to loop over.

    0
  • Alison Cozad
    • Gurobi Staff Gurobi Staff

    See Code not working – Gurobi Support Portal for the remainder of the conversation.

    0

投稿コメントは受け付けていません。