Skip to main content

Wrapper for Pyomo solve method

Project description

Pyomo Solver Wrapper

Introduction

A third-party python-based solver wrapper for Pyomo.

Requirements

  1. Python v3.5+

Installation

The package can be installed directly by downloading an appropriate release or cloning the main development repository from GitHub:

git clone https://github.com/judejeh/PyomoSolverWrapper.git

Change into the "PyomoSolverWrapper" directory created by Git or extracted from the downloaded zip file and run:

python setup.py install

Usage

Import the solve wrapper:

from PyoSolveWrapper import SolverWrapper as slw 

This package solely aids the optimisation model solve process. Hence, having created an appropriate pyomo model object (further referred to as 'model'), an instance of the solver wrapper is first created:

Solver = slw.SolverWrapper()

Basic solver options can be changed where appropriate:

Solver.solver_name = 'cbc'
Solver.threads = 2
Solver.time_limit = 1200
Solver.rel_gap = 0.1
Solver.solver_progress = True

The package attempts to find the appropriate solver executable from the system PATH. However, should the solver path be in a different location, this path may be included as:

Solver.solver_path = '<PATH_TO_SOLVER>'

Note that whatever solver supplied should be compatible with Pyomo.

Where solvers are not locally installed, optimisation models may be solved using the NEOS server if doing so for non-commercial purposes. Note that for now, results are not post-processed.

Finally, the model can be solved as:

Solver.solve_model(model)

Results obtained from the model solution is automatically post-processed and saved with 'Solver' and can be accessed via the dictionary:

Solver.final_results[<type>][<name>]

where <type> is one of of 'sets', 'parameters' or 'variables'; and <name> is the actual model component name used in 'model'.

For e.g., a parameter and variable name 'A' and 'y' in the Pyomo model object 'model' can be accessed after successful model solution via:

Solver.final_results['parameters']['A']

and

Solver.final_results['variables']['y']

respectively.

Where parameters or variables are index of set(s), they can be accessed in the order of the sets they were declared by when creating the model component.

Disclaimer

At the time of writing, the authors of this package have no affiliation with Pyomo or NEOS server. The package was written to simplify an optimisation model solving process using Pyomo, especially relating to post-processing results and dealing with multiple solvers.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for PyoSolveWrapper, version 0.3.1
Filename, size File type Python version Upload date Hashes
Filename, size PyoSolveWrapper-0.3.1-py3-none-any.whl (10.9 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size PyoSolveWrapper-0.3.1.tar.gz (11.9 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page