Code Monkey home page Code Monkey logo

pyomo_simplemodel's Introduction

Actions Status Documentation Status

Pyomo Checks - GitHub Master Pyomo Checks - PyPI Pyomo Checks - Conda

GitHub contributors Merged PRs Issue stats Project Status: Active โ€“ The project has reached a stable, usable state and is being actively developed.

Overview

News

  • (5/2020) The pyomo_simplemodel package has moved to the or-fusion organization (previously the pyomocommunity organization). This package was renamed from pyomocontrib_simplemodel to pyomo_simplemodel, and this capability is no longer available as the Pyomo subpackage pyomo.contrib.simplemodel. In the future, pyomo_simplemodel will be distributed with pyomo_community package.

Description

The pyomo_simplemodel package is software for modeling and solving optimization problems. This package is derived from Pyomo, and it defines the class SimpleModel that illustrates how Pyomo can be used in a simple, less object-oriented manner. Specifically, this class mimics the modeling style supported by PuLP:

Feature PuLP SimpleModel
LP/MILP YES YES
NLP/MINLP NO YES
Column-wise YES NO

See the online documentation for further details.

This software is available under the BSD License.

Installation

PyPI PyPI

pip install pyomo_simplemodel

Getting Help

Developers

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.

pyomo_simplemodel's People

Contributors

amarvin avatar whart222 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

pyomo_simplemodel's Issues

Omitted or dummy objectives aren't allowed in 1.0.2

Both of these seem to produce an error in v1.0.2

Not defining the objective function:

from pyomo.contrib.simplemodel import SimpleModel

m = SimpleModel()
x = m.var('x')
m += x == 1
m.solve('glpk')

results in this error traceback:

  File "/usr/local/lib/python3.6/dist-packages/pyomocontrib_simplemodel/core.py", line 177, in solve
    return solver.solve(self.model, *args, **kwargs)
  File "/usr/local/lib/python3.6/dist-packages/pyomo/opt/base/solvers.py", line 569, in solve
    self._presolve(*args, **kwds)
  File "/usr/local/lib/python3.6/dist-packages/pyomo/opt/solver/shellcmd.py", line 200, in _presolve
    OptSolver._presolve(self, *args, **kwds)
  File "/usr/local/lib/python3.6/dist-packages/pyomo/opt/base/solvers.py", line 669, in _presolve
    **kwds)
  File "/usr/local/lib/python3.6/dist-packages/pyomo/opt/base/solvers.py", line 740, in _convert_problem
    **kwds)
  File "/usr/local/lib/python3.6/dist-packages/pyomo/opt/base/convert.py", line 105, in convert_problem
    problem_files, symbol_map = converter.apply(*tmp, **tmpkw)
  File "/usr/local/lib/python3.6/dist-packages/pyomo/solvers/plugins/converter/model.py", line 88, in apply
    io_options=io_options)
  File "/usr/local/lib/python3.6/dist-packages/pyomo/core/base/block.py", line 1716, in write
    io_options)
  File "/usr/local/lib/python3.6/dist-packages/pyomo/repn/plugins/cpxlp.py", line 175, in __call__
    include_all_variable_bounds=include_all_variable_bounds)
  File "/usr/local/lib/python3.6/dist-packages/pyomo/repn/plugins/cpxlp.py", line 553, in _print_model_LP
    "ERROR: No objectives defined for input model. "
ValueError: ERROR: No objectives defined for input model. Cannot write legal LP file.

Dummy objective functions

from pyomo.contrib.simplemodel import SimpleModel

m = SimpleModel()
m += 1.0
x = m.var('x')
m += x == 1
m.solve('glpk')

results in this error traceback:

    prob += 1.0  # dummy objective
  File "/usr/local/lib/python3.6/dist-packages/pyomocontrib_simplemodel/core.py", line 147, in __iadd__
    elif expr.is_relational():
AttributeError: 'float' object has no attribute 'is_relational'

Only binary vars working

Hi,
I am toying around with the SimpleModel and I cannot solve a super simple example with real vars.

from pyomo.contrib.simplemodel import *

# Create model
model = SimpleModel(maximize=True)

# Variables
x = model.var('x', [1, 2], within=NonNegativeReals)

# Objective
model += x[1] + 2 * x[2]

# Constraint
model += (3 * x[1] + 4 * x[2]) >= 1
model += (2 * x[1] + 5 * x[2]) >= 2

# Optimize
status = model.solve('xpress')

# Print the status of the solved LP
print("Status = %s" % status.solver.termination_condition)

# Print the value of the variables at the optimum
for i in [1, 2]:
    print("%s = %f" % (x[i], x[i].value))

# Print the value of the objective
print("Objective = %f" % model.objective().expr())

model.display()

Fails on "from pyomo.contrib.simplemodel import *"

I used pip to install pyomo and pyomocontrib_simplemodel into a Docker container, but then import statement

from pyomo.contrib.simplemodel import *

fails with this partial trace:

Installing collected packages: pyparsing, pulp, appdirs, nose, PyUtilib, ply, pyomo, pyomocontrib-simplemodel
Successfully installed PyUtilib-5.6.5 appdirs-1.4.3 nose-1.3.7 ply-3.11 pulp-1.6.9 pyomo-5.6.1 pyomocontrib-simplemodel-1.0.1 pyparsing-2.3.1

ImportError: Failed to import test module: sudoku
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/dist-packages/pyomo/contrib/simplemodel/__init__.py", line 2, in <module>
    from pyomocontrib_simplemodel import *
  File "/usr/local/lib/python3.6/dist-packages/pyomocontrib_simplemodel/__init__.py", line 1, in <module>
    from pyomo.util.plugin import PluginGlobals
ModuleNotFoundError: No module named 'pyomo.util.plugin'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3.6/unittest/loader.py", line 462, in _find_test_path
    package = self._get_module_from_name(name)
  File "/usr/lib/python3.6/unittest/loader.py", line 369, in _get_module_from_name
    __import__(name)
  File "/builds/SudermN/SudokuTeaching/sudoku/__init__.py", line 1, in <module>
    from sudoku.sudoku import *
  File "/builds/SudermN/SudokuTeaching/sudoku/sudoku.py", line 2, in <module>
    from pyomo.contrib.simplemodel import Binary, SimpleModel, value
  File "/usr/local/lib/python3.6/dist-packages/pyomo/contrib/simplemodel/__init__.py", line 8, in <module>
    "The pyomocontrib_simplemodel package is not installed.")
RuntimeError: The pyomocontrib_simplemodel package is not installed.

Am I missing a dependency or using the wrong versions?

sodacan example gives: No value for uninitialized NumericValue object r

Hello,
I was trying to run the example of non-linear problem in this page:

http://pyomocontrib-simplemodel.readthedocs.io/en/latest/sodacan.html#simplemodel-formulation

But after running it I got the following error:

WARNING: Loading a SolverResults object with a warning status into model=unknown;
message from solver=
Status = other

ValueError Traceback (most recent call last)
in ()
16 print("Status = %s" % status.solver.termination_condition)
17
---> 18 print("%s = %f" % (r, value(r)))
19 print("%s = %f" % (h, value(h)))
20 print("Objective = %f" % value(m.objective()))

/home/mohanad/anaconda2/lib/python2.7/site-packages/pyomo/core/kernel/numvalue.pyc in value(obj, exception)
168 if exception and (tmp is None):
169 raise ValueError("No value for uninitialized NumericValue object %s"
--> 170 % (obj.name,))
171 return tmp
172

ValueError: No value for uninitialized NumericValue object r

What is the problem?

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.