Skip to main content

Component-based systems modelling library.

Project description

SysOpt - Systems Modelling and Optimisation

Overview

sysopt is a python3 framework for component based modelling, simulation and optimisation of continuous time dynamic and control systems.

It allows users to design modular plant and control systems, simulate the trajectory of closed loop systems, and run joint parameter/path optimisation studies.

A Minimal Example

Test problem 3 from Herber and Allison[^1] provides a minimal example of sysopt usage. First, we define some components (plant, and controller), assemble a composite model then setup a optimsation problem for that model and solve it.

from sysopt import Metadata, Composite, SolverContext, PiecewiseConstantSignal, Parameter
from sysopt.modelling.builders import FullStateOutput
from sysopt.blocks import ConstantSignal

k_star = 0.8543 # Known optimal gain. 
t_f = 10

# Define the plant    
def dxdt(t, x, u, p):
    return [x[1], - p[0] * x[0]  + u[0]]

def x0(p):
    return [0, 0]

plant_metadata = Metadata(inputs=['u'], states=['x', 'v'], parameters=['k'])
plant = FullStateOutput(plant_metadata, dxdt, x0)

# Define the controller
controller = ConstantSignal(['u'], name='Controller')

# Define the Composite system via components and wires
model = Composite(name='Model', components=[plant, controller])
model.declare_outputs(['x', 'v', 'u'])
model.wires = [(controller.outputs, plant.inputs),
               (plant.outputs, model.outputs[0:2]),
               (controller.outputs, model.outputs[2])]

k = Parameter('k'')
u = PiecewiseConstantSignal('u', 100)
parameters = {
    plant.parameters['k']: k,
    controller.parameters['u']:u
}
# Setup the joint optimisation problem. 
with SolverContext(model=model, t_final=t_f, parameters=parameters) as solver:

    
    y_final = model.outputs(solver.t_final)
    
    cost = -y_final[0]

    constraints = [u <= 1, u >= -1,
                   y_final[1] >= 0, y_final[1] <= 0]

    problem = solver.problem(arguments=[k, u],  
                             cost=cost,
                             subject_to=constraints)
    
    soln = problem.solve(guess=[0, 0])
    k_min, u_min = soln.argmin
    assert abs(k_min - k_star) < 1e-2

[^1]: Herber, Daniel R., and James T. Allison. "Nested and simultaneous solution strategies for general combined plant and control design problems." Journal of Mechanical Design 141.1 (2019).

Project details


Download files

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

Source Distribution

sysopt-0.6.1.tar.gz (56.2 kB view details)

Uploaded Source

Built Distribution

sysopt-0.6.1-py3-none-any.whl (66.5 kB view details)

Uploaded Python 3

File details

Details for the file sysopt-0.6.1.tar.gz.

File metadata

  • Download URL: sysopt-0.6.1.tar.gz
  • Upload date:
  • Size: 56.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.63.0 importlib-metadata/4.10.1 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.9.13

File hashes

Hashes for sysopt-0.6.1.tar.gz
Algorithm Hash digest
SHA256 cfebb2894df35922f31df1e6ad6933080dec9f6e42d65c4a057cb4928326886f
MD5 80a55380684bb5bd89a441f41b8cb72b
BLAKE2b-256 8f088c6b9721091d2caab7f28d88b09f1fe0fed2ec4cb80f09a1893fa40cf8d5

See more details on using hashes here.

File details

Details for the file sysopt-0.6.1-py3-none-any.whl.

File metadata

  • Download URL: sysopt-0.6.1-py3-none-any.whl
  • Upload date:
  • Size: 66.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.63.0 importlib-metadata/4.10.1 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.9.13

File hashes

Hashes for sysopt-0.6.1-py3-none-any.whl
Algorithm Hash digest
SHA256 1320bed57021e15228b0780e1fe627b31452bec46d6031a9fe76f4840db440e6
MD5 f69641923bc4123be3f2bfaf14fcaa6b
BLAKE2b-256 0bd5d2946690024700c5dfd98f4e11be8d80f1d67cd45fa8f821537c7d487d47

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page