Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| personal:blog:2014:0904_pyomo_for_gams_users [2015/01/12 14:34] – [Complete script] antonello | personal:blog:2014:0904_pyomo_for_gams_users [2025/05/02 09:41] (current) – external edit 127.0.0.1 | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| ====== A Pyomo tutorial for GAMS users ====== | ====== A Pyomo tutorial for GAMS users ====== | ||
| + | |||
| + | **Updates: | ||
| + | |||
| + | * **2015.01.12: | ||
| + | |||
| + | |||
| [[https:// | [[https:// | ||
| Line 22: | Line 28: | ||
| ===== Installation ===== | ===== Installation ===== | ||
| - | **Important: | + | **<del>Important: Pyomo requires python 2.x. While python 3.x support is work in progress, at the moment only python 2.x is supported.</ |
| + | |||
| + | //This isn't true any more with Pyomo 4, where support for Python 3.x has been added..// | ||
| ==== Ubuntu ==== | ==== Ubuntu ==== | ||
| Line 47: | Line 55: | ||
| <code python> | <code python> | ||
| # Import of the pyomo module | # Import of the pyomo module | ||
| - | from coopr.pyomo import * | + | from pyomo.environ |
| | | ||
| # Creation of a Concrete Model | # Creation of a Concrete Model | ||
| Line 129: | Line 137: | ||
| def demand_rule(model, | def demand_rule(model, | ||
| return sum(model.x[i, | return sum(model.x[i, | ||
| - | model.demand = Constraint(model.j, | + | model.demand = Constraint(model.j, rule=demand_rule, doc=' |
| </ | </ | ||
| The above code take advantage of [[https:// | The above code take advantage of [[https:// | ||
| Line 180: | Line 188: | ||
| If you want advanced features and debugging capabilities you can use a dedicated Python IDE, like e.g. [[https:// | If you want advanced features and debugging capabilities you can use a dedicated Python IDE, like e.g. [[https:// | ||
| - | You will normally run the script as '' | + | You will normally run the script as '' |
| If you want to run the script as '' | If you want to run the script as '' | ||
| <code python> | <code python> | ||
| Line 187: | Line 195: | ||
| if __name__ == ' | if __name__ == ' | ||
| #This replicates what the pyomo command-line tools does | #This replicates what the pyomo command-line tools does | ||
| - | from coopr.opt import SolverFactory | + | from pyomo.opt import SolverFactory |
| - | import | + | import |
| opt = SolverFactory(" | opt = SolverFactory(" | ||
| instance = model.create() | instance = model.create() | ||
