Beginner's Guide to Pyomo for Abstract Linear Programs - Sets Parameters and Data Files (Part 1)

Sdílet
Vložit
  • čas přidán 29. 06. 2022
  • This video tutorial is the first of a four part series that introduces the novice linear programmer to writing abstract linear programs using the Pyomo library. This video will cover:
    1. A Review of the CSL concrete model and its abstract formulation
    2. Coding the sets and parameters in the model file
    3. Creating a data file to hold the values of the parameters and sets.
    This video was originally designed for 3rd year Industrial Engineering students. It is best for students new to linear programming with minimal to no coding experience.

Komentáře • 13

  • @hoangdinh9595
    @hoangdinh9595 Před 8 měsíci +1

    Thank you for this video! It really helps!

  • @baturaykus4438
    @baturaykus4438 Před 7 měsíci

    Thank you Dr. Katie. You're the best.

  • @davidavornyo128
    @davidavornyo128 Před rokem +1

    Just what I've been looking for. This is awesome. Thanks

  • @roehlanobriones3179
    @roehlanobriones3179 Před rokem

    Thank you for this Dr. Katie. Maximally helpful.

  • @boruicui8213
    @boruicui8213 Před měsícem

    Hi Katie. Thanks a lot for your kind lectures. I have a question about the 'set' in .dat file. In your case, 'month' is simple which is sort of a list just including 5 elements. But how about I tend to use/introduce timeindex (e.g., Pandaframe index) values to be a set variable 'time'? It could be very long since there will be 1440 elements if the time interval is one minute for one day (24*60). how could I realize that? do I need to type them into a .dat file manually?

    • @DrKatieRIT
      @DrKatieRIT  Před měsícem

      I would recommend within your model file using a range set. So you could do something like: model.MONTHS = RangeSet(1,timeindex.length(),1) This would create a set with the numbers 1 through the length of the number of elements in your panda data frame, then just leave the set definition out of the data file.

  • @jamesong6208
    @jamesong6208 Před rokem

    This is beautiful. Any chance a copy of the files can be provided as it just shortens definition time and avoids syntax errors

    • @DrKatieRIT
      @DrKatieRIT  Před rokem +2

      Hi James! Making those syntax mistakes and fixing them is part of the learning process. If you ever get too stuck just reach out and I'd be happy to help.

  • @MuhammadWAQAS-pq5jb
    @MuhammadWAQAS-pq5jb Před rokem

    Content like this is highly appreciated. Thank You, Professor Katie.
    I am trying to reproduce the same and
    With
    data=DataPortal()
    data.load(filename='abstractmodelcreation.dat', model=model)
    instance = model.create_instance(data)
    the error is:
    AttributeError: 'DataPortal' object has no attribute 'is_constructed'
    while with,
    data=DataPortal()
    data.load(filename='abstractmodelcreation.dat', set=model.MONTHS)
    instance = model.create_instance(data)
    the error is
    ValueError: Parameter 'salaryExp' defined with '1' dimensions, but data has '1' values: [2000]. Are you missing a value for a 1-dimensional index?

    • @katiemcconky938
      @katiemcconky938 Před rokem +1

      Errors in these models can be finicky and hard to find. The error messages are often not particularly helpful either. Check the parameter for salaryExp matches in both your model and data file. Make sure salaryExp has no sets listed in its declaration. Finally, I’d be happy to take a look at your files if you use Google colab and share them with me.

    • @DrKatieRIT
      @DrKatieRIT  Před rokem +1

      All set! You were missing the () after model = AbstractModel, is should say model=AbstractModel(). Assuming your data file is correct (I had to use my own), everything will work fine once you add in those (). If it doesn't work, take a look at your data file.

    • @MuhammadWAQAS-pq5jb
      @MuhammadWAQAS-pq5jb Před rokem

      @@DrKatieRIT I really appreciate your prompt solution. Yeah, it is working now. You are awesome.