Giter VIP home page Giter VIP logo

pyomogallery's Introduction

Github Actions Status Jenkins Status codecov Documentation Status Build services GitHub contributors Merged PRs

a COIN-OR project

Pyomo Overview

Pyomo is a Python-based open-source software package that supports a diverse set of optimization capabilities for formulating and analyzing optimization models. Pyomo can be used to define symbolic problems, create concrete problem instances, and solve these instances with standard solvers. Pyomo supports a wide range of problem types, including:

  • Linear programming
  • Quadratic programming
  • Nonlinear programming
  • Mixed-integer linear programming
  • Mixed-integer quadratic programming
  • Mixed-integer nonlinear programming
  • Mixed-integer stochastic programming
  • Generalized disjunctive programming
  • Differential algebraic equations
  • Mathematical programming with equilibrium constraints
  • Constraint programming

Pyomo supports analysis and scripting within a full-featured programming language. Further, Pyomo has also proven an effective framework for developing high-level optimization and analysis tools. For example, the mpi-sppy package provides generic solvers for stochastic programming. mpi-sppy leverages the fact that Pyomo's modeling objects are embedded within a full-featured high-level programming language, which allows for transparent parallelization of subproblems using Python parallel communication libraries.

Pyomo was formerly released as the Coopr software library.

Pyomo is available under the BSD License - see the LICENSE.md file.

Pyomo is currently tested with the following Python implementations:

  • CPython: 3.8, 3.9, 3.10, 3.11, 3.12
  • PyPy: 3.9

Testing and support policy:

At the time of the first Pyomo release after the end-of-life of a minor Python version, we will remove testing for that Python version.

Installation

PyPI PyPI version PyPI downloads

pip install pyomo

Anaconda Anaconda version Anaconda downloads

conda install -c conda-forge pyomo

Tutorials and Examples

Getting Help

To get help from the Pyomo community ask a question on one of the following:

Developers

Pyomo development moved to this repository in June 2016 from Sandia National Laboratories. Developer discussions are hosted by Google Groups.

The Pyomo Development team holds weekly coordination meetings on Tuesdays 12:30 - 14:00 (MT). Please contact [email protected] to request call-in information.

By contributing to this software project, you are agreeing to the following terms and conditions for your contributions:

  1. You agree your contributions are submitted under the BSD license.
  2. You represent you are authorized to make the contributions and grant the license. If your employer has rights to intellectual property that includes your contributions, you represent that you have received permission to make contributions and grant the required license on behalf of that employer.

Related Packages

See https://pyomo.readthedocs.io/en/latest/related_packages.html.

pyomogallery's People

Contributors

blnicho avatar dlwoodruff avatar ghackebeil avatar japita-se avatar jsiirola avatar mrmundt avatar neddimitrov avatar sylvaticus avatar viktornordling avatar whart222 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pyomogallery's Issues

Conclusion in transport.ipynb

Hello Pyomos!

where do you take the 50 cases from Seattle to New-York from in your conlusion?

Solution Information Variable: x[seattle,chicago]: Value: 300 x[san-diego,topeka]: Value: 275 x[san-diego,new-york]: Value: 325 Constraint: No values

This solution shows that the minimum transport costs is attained when 300 cases are sent from the Seattle plant to the Chicago market, 50 cases from Seattle to New-York and 275 cases each are sent from San-Diego plant to New-York and Topeka markets.

Network interdiction problems are broken

I get the following error when I try to run, e.g., the min_cost_flow_interdict example:

`MultiIndex([( 'B', 'End'),
( 'C', 'B'),
( 'C', 'D'),
( 'D', 'End'),
('Start', 'B'),
('Start', 'C')],
names=['StartNode', 'EndNode'])
ERROR: Constructing component 'edge_set' from data=None failed: ValueError:
The truth value of a MultiIndex is ambiguous. Use a.empty, a.bool(),
a.item(), a.any() or a.all().

ValueError Traceback (most recent call last)
in
227
228 if name == 'main':
--> 229 m = MinCostFlowInterdiction('sample_nodes_data.csv', 'sample_arcs_data.csv')
230 m.solve()
231 m.printSolution()

in init(self, nodefile, arcfile, attacks)
44 self.nCmax = len(self.node_set) * self.arc_data['Cost'].max()
45
---> 46 self.createPrimal()
47 self.createInterdictionDual()
48

in createPrimal(self)
59 # Add the sets
60 model.node_set = pe.Set( initialize=self.node_set )
---> 61 model.edge_set = pe.Set( initialize=self.arc_set, dimen=2)
62
63 # Create the variables

C:\Program Files (x86)\Microsoft Visual Studio\Shared\Anaconda3_64\lib\site-packages\pyomo\core\base\block.py in setattr(self, name, val)
541 # Pyomo components are added with the add_component method.
542 #
--> 543 self.add_component(name, val)
544 else:
545 #

C:\Program Files (x86)\Microsoft Visual Studio\Shared\Anaconda3_64\lib\site-packages\pyomo\core\base\block.py in add_component(self, name, val)
1079 _blockName, str(data))
1080 try:
-> 1081 val.construct(data)
1082 except:
1083 err = sys.exc_info()[1]

C:\Program Files (x86)\Microsoft Visual Studio\Shared\Anaconda3_64\lib\site-packages\pyomo\core\base\util.py in construct(self, data)
123 self._name = base.name
124 self.class = base
--> 125 return base.construct(self, data)
126 construct.doc = base.construct.doc
127 cls.construct = construct

C:\Program Files (x86)\Microsoft Visual Studio\Shared\Anaconda3_64\lib\site-packages\pyomo\core\base\set.py in construct(self, data)
1987 # Bypass the index validation and create the member directly
1988 for index in self.index_set():
-> 1989 self._getitem_when_not_present(index)
1990 finally:
1991 # Restore the original initializer (if overridden by data argument)

C:\Program Files (x86)\Microsoft Visual Studio\Shared\Anaconda3_64\lib\site-packages\pyomo\core\base\set.py in _getitem_when_not_present(self, index)
2030 self._init_values._dimen = _d
2031 try:
-> 2032 _values = self._init_values(_block, index)
2033 except TuplizeError as e:
2034 raise ValueError( str(e) % (

C:\Program Files (x86)\Microsoft Visual Studio\Shared\Anaconda3_64\lib\site-packages\pyomo\core\base\set.py in call(self, parent, index)
412 elif _val is Set.Skip:
413 return _val
--> 414 elif not _val:
415 return _val
416

C:\Program Files (x86)\Microsoft Visual Studio\Shared\Anaconda3_64\lib\site-packages\pandas\core\indexes\base.py in nonzero(self)
2148 def nonzero(self):
2149 raise ValueError(
-> 2150 f"The truth value of a {type(self).name} is ambiguous. "
2151 "Use a.empty, a.bool(), a.item(), a.any() or a.all()."
2152 )

ValueError: The truth value of a MultiIndex is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all().`

unable to write complex constraint in pyomo

I am trying to write the following constraint in pyomo:

Screenshot 2022-06-28 at 16 10 08

The description is as follows:

ū ∈ Nf=Nodes from a set Gf

u ∈ Ns=Nodes from a set Gs

Φf=binary variable indicating 1 if the node ū from Nf can be deployed on u from Ns, otherwise 0.

Df cpu ū = demand (CPU parameter) of node ū.

a cpu u = available ratio of node u (ratio = capacity-demand).

C cpu u = capacity (CPU parameter) of node u.

model = ConcreteModel() 
model.nf = (['VNF1', 'VNF2', 'VNF3'])
model.ns = (['S1', 'S2', 'S3'])

model.fi = Var(model.nf, model.ns, within=Binary)

model.Dcpu = Param(model.nf, within=NonNegativeReals, initialize=1)

model.Ccpu = Param(model.ns, within=NonNegativeReals, initialize=5)

def acpu_rule(model, ns, nf): 
      return (model.Ccpu[ns]/model.Dcpu[nf])
model.acp=Param(model.ns, model.nf, initialize=acpu_rule)

model.c1 = Constraint(sum(model.fi[ub, u] for ub in model.nf for u in model.ns * model.Dcpu[ub] for ub in model.nf) <= model.Ccpu[u] for u in model.ns) * model.acp[ub] for ub in model.nf)

For a long, I am receiving different errors and I am unable to locate the problem.

Currently, I am getting the 'TypeError: unhashable type: 'InequalityExpression' ' error.

Please help me to get out of this.

Regards

Gams $ convert to Pyomo

There is any effective way to convert right dollar of gams to pyomo?
For example
vr(t) = tr*sr*sum(a$(ord(t)+ord(a) gt card(t)), yv(a)*delta(a));
thx

Question on the Flow Example

Hi, I am not sure why you included (or multiplies) the arc capacity by the flow in the objective function of the flow network example.

image

Requirements

Hello there !

I've tried to run some examples here ... and I think that by now a requirements.txt file is necessary.
Looks like there are things outdated in pandas and also pyomo.

The following command seem to work, but you need to change all pandas .ix methods to .loc

pip3 install wheel pandas "pyomo<6" ipykernel

After adding this requirements and fixing the pandas issues ... maybe updating the codes to the new pyomo would be interesting as well.

Error with symbol_map creation in asl_io.write.write_nl

On attempt to run simplest example in asl_io.write I have an error
AttributeError: 'float' object has no attribute 'model'
The error occurs in line #28 of write.py in preparing symbol_cuid_pairs .
I use Python 3.11.4 (miniconda) and Pyomo 6.7.1
It is the first time when I see this error on using Pyomo and your excellent asl_io functions. Bad news is that I have got the same error and with other Pyomo models...

diet.py example seems to be broken

When I run the diet.py example I get an error:

$ pyomo solve --solver=glpk diet.py diet.dat || echo fail
[    0.00] Setting up Pyomo environment
[    0.00] Applying Pyomo preprocessing actions
[    0.00] Creating model
ERROR: Rule failed when generating expression for constraint nutrient_limit
    with index Cal: PyomoException: Cannot convert non-constant expression to
    bool. This error is usually caused by using an expression in a boolean
    context such as an if statement. For example,
        m.x = Var() if m.x <= 0:
            ...
    would cause this exception.
ERROR: Constructing component 'nutrient_limit' from data=None failed:
        PyomoException: Cannot convert non-constant expression to bool. This
        error is usually caused by using an expression in a boolean context
        such as an if statement. For example, m.x = Var() if m.x <= 0:
            ...
    would cause this exception.
[    0.02] Pyomo Finished
ERROR: Unexpected exception while running model:
        Cannot convert non-constant expression to bool. This error is usually
        caused by using an expression in a boolean context such as an if
        statement. For example, m.x = Var() if m.x <= 0:
            ...
    would cause this exception.
errorcode: 1
$ pyomo --version
Pyomo 6.0.1 (CPython 3.7.10 on Darwin 18.7.0)

Add a test script

I think we should add a simple test script that executes each of the examples and makes sure that no error occurs during execution. IMO, attempting to test anything beyond this (e.g., an output baseline) would require too much work on the part of contributors.

There are two issues that I can think of that complicate this:

  1. How do we execute an example?

    I think the answer is that for each example, we convert the .ipynb file into a temporary script using the the commnd: jupyter nbconvert --to script [filename].ipynb. As long is we can install jupyter on Travis, this seems like a straightforward thing to do.

  2. When do these tests get executed?

    Obviously, when someone pushes a new example to this repo. However, we really want to be testing after pushes to the Pyomo/pyomo master branch, just like we should be testing Pyomo/pyomo after pushes to Pyutilib/pyutilib master. It looks like we are currently not doing this (with Travis / Appveyor at least), so it makes me think it is not currently possible. @whart222, @jsiirola : Do either of you know if this is possible?

    I suppose it's also reasonable that we only test examples against the latest Pyomo release. Thoughts?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.