Solvers

Submodules

pywr.solvers.cython_glpk module

class pywr.solvers.cython_glpk.AbstractNodeData

Bases: object

Helper class for caching node data for the solver.

id

id: ‘int’

in_edges

in_edges: list

is_link: ‘bool’

out_edges

out_edges: list

row

row: ‘int’

class pywr.solvers.cython_glpk.AggNodeFactorData

Bases: object

Helper class for caching data for Aggregated Nodes that have factors defined by parameters.

ind_ptr

ind_ptr: View.MemoryView.array

inds

inds: View.MemoryView.array

node_ind

node_ind: ‘int’

row

row: ‘int’

vals

vals: View.MemoryView.array

class pywr.solvers.cython_glpk.BasisManager

Bases: object

class pywr.solvers.cython_glpk.CythonGLPKEdgeSolver(use_presolve=False, time_limit=None, iteration_limit=None, message_level='error', save_routes_flows=False, retry_solve=False, **kwargs)

Bases: GLPKSolver

reset(self)
retry_solve

retry_solve: ‘bool’

route_flows_arr

route_flows_arr: View.MemoryView.array

setup(self, model)
solve(self, model)
stats

stats: object

class pywr.solvers.cython_glpk.CythonGLPKSolver(use_presolve=False, time_limit=None, iteration_limit=None, message_level='error', save_routes_flows=False, retry_solve=False, **kwargs)

Bases: GLPKSolver

reset(self)
retry_solve

retry_solve: ‘bool’

route_flows_arr

route_flows_arr: View.MemoryView.array

routes

routes: list

save_routes_flows

save_routes_flows: ‘bool’

setup(self, model)
solve(self, model)
stats

stats: object

exception pywr.solvers.cython_glpk.GLPKError

Bases: Exception

exception pywr.solvers.cython_glpk.GLPKInternalError

Bases: Exception

class pywr.solvers.cython_glpk.GLPKSolver(use_presolve=False, time_limit=None, iteration_limit=None, message_level='error', set_fixed_flows_once=False, set_fixed_costs_once=False, set_fixed_factors_once=False, use_unsafe_api=False)

Bases: object

dump_glpk(self, filename)
dump_lp(self, filename)
dump_mps(self, filename)
reset(self)
set_fixed_costs_once

set_fixed_costs_once: ‘bool’

set_fixed_factors_once

set_fixed_factors_once: ‘bool’

set_fixed_flows_once

set_fixed_flows_once: ‘bool’

set_solver_options(self, time_limit, iteration_limit, message_level)
setup(self, model)
solve(self, model)
use_presolve

use_presolve: ‘bool’

use_unsafe_api

use_unsafe_api: ‘bool’

pywr.solvers.cython_lpsolve module

Module contents

This module contains a Solver baseclass and several implemented subclasses.

Solvers are used to with pywr.core.Model classes to solve the network allocation problem every time step.

Currently there are only linear programme based solvers using,
  • GLPK

  • LPSolve55

class pywr.solvers.CythonGLPKEdgeSolver(*args, **kwargs)

Bases: Solver

Python wrapper of Cython GLPK solver.

This is required to subclass Solver and get the metaclass magic.

dump_glpk(filename)
dump_lp(filename)
dump_mps(filename)
name = 'glpk-edge'
reset()
property retry_solve
property set_fixed_costs_once
property set_fixed_factors_once
property set_fixed_flows_once
property settings
setup(model)
solve(model)
property stats
property use_presolve
property use_unsafe_api
class pywr.solvers.CythonGLPKSolver(*args, **kwargs)

Bases: Solver

Python wrapper of Cython GLPK solver.

This is required to subclass Solver and get the metaclass magic.

dump_glpk(filename)
dump_lp(filename)
dump_mps(filename)
name = 'glpk'
reset()
property retry_solve
property routes
property routes_flows_array
property save_routes_flows
property set_fixed_costs_once
property set_fixed_factors_once
property set_fixed_flows_once
property settings
setup(model)
solve(model)
property stats
property use_presolve
property use_unsafe_api
class pywr.solvers.NullSolver(*args, **kwargs)

Bases: Solver

A null solver that performs no allocation routine.

This solver does no allocation and is mainly useful for debugging purposes.

name = 'null'
reset()
setup(model)
solve(model)
class pywr.solvers.Solver(*args, **kwargs)

Bases: object

Solver base class from which all solvers should inherit

name = 'default'
reset()
property settings
setup(model)
solve(model)
property stats