pymscada-milp
Base MILP operation
Provides a python module to frame and solve MILP problems.
from pymscada_milp import LpModel
# See https://www.homepages.ed.ac.uk/jwp/newMSOcopy/section5/milp.html
#
# max: 20 x1 + 6 x2 + 8 x3;
# 0.8 x1 + 0.2 x2 + 0.3 x3 <=20;
# 0.4 x1 + 0.3 x2 <= 10;
# 0.2 x1 + 0.1 x3 <= 5;
# int x1, x2, x3;
#
# and crucially, on the earlier page and not copied :(
# x3<=20;
m = LpModel()
m.add_row(-20, 'x1', -6, 'x2', -8, 'x3', 'N') # Negate as default minimizes
m.add_row(0.8, 'x1', 0.2, 'x2', 0.3, 'x3', 'L', 20)
m.add_row(0.4, 'x1', 0.3, 'x2', 'L', 10)
m.add_row(0.2, 'x1', 0.1, 'x3', 'L', 5)
m.add_limit('x1', 'LI', 0)
m.add_limit('x2', 'LI', 0)
m.add_limit('x3', 'UI', 20)
m.write_mps()
m.solve_mps()
print([f'{x} {m.results[x]}' for x in ['x1', 'x2', 'x3']])
m.remove_result()
Hydraulic Model
The LP model (above) was intended to provide a way to model generators, gates and reservoirs with a procedural representation. i.e.
from pymscada_milp import HydraulicModel, TimeSeries, State
inflow = TimeSeries(9.0) # Provides inflow present value and history
outflow = TimeSeries(1.0)
tank = TimeSeries(0.5)
model = {
'name': 'test',
'actual_time': 1522494300,
'time_step': 600,
'duration': 1200,
'tempdir': 'tmp',
'model': {
'Inflow': {
'type': 'valve',
'time_series': inflow,
'dstnode': 'Tank',
'state': State.FIXED # Use State.FREE to solve optimally
},
'Tank': {
'type': 'storage',
'time_series': tank,
'LV': [
[0.00, 0],
[1.00, 1000000]
],
'costs': [
[0.0, 0.2, 0.4, 0.6, 0.8, 1.0],
[
[10000, 10000], # expensive low cost
[50, 10], # soft low cost
[1, 0], # slightly favour filling
[0, 50], # soft high cost
[5000, 5000] # expensive high cost
]
]
},
'Outflow': {
'type': 'valve',
'time_series': outflow,
'srcnode': 'Tank',
'state': State.FIXED
}
}
}
m = HydraulicModel(model)
m.solve_lp()
print(inflow.values()) # The solver adds inflow predictions / setpoints.
print(tank.values())
print(outflow.values())
m.remove_result()
Metadata
Release files for pymscada-milp 0.0.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| pymscada_milp-0.0.3.tar.gz | 42.9 kB | Without provenance | Details for pymscada_milp-0.0.3.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| pymscada_milp-0.0.3-py3-none-any.whl | Python 3 | none | any | Details for pymscada_milp-0.0.3-py3-none-any.whl |
Total release size: 76.9 kB
Release files / pymscada_milp-0.0.3.tar.gz
| Download URL | pymscada_milp-0.0.3.tar.gz |
|---|---|
| Size | 42.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
5a3b9b910fd3fc91615c0019c9c1c2b61d211116fb453abe3aaab975cd2026a0
|
|
BLAKE2b-256 checksum How to use checksums |
07385e28187b6f8b973e138d3437d39ef7f135aaa9f2bff7119f93284249be50
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
pdm/2.16.1 CPython/3.11.2 Linux/6.1.0-22-amd64
|
Release files / pymscada_milp-0.0.3-py3-none-any.whl
| Download URL | pymscada_milp-0.0.3-py3-none-any.whl |
|---|---|
| Size | 34.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
e58589b1f188acda600cfce8fc4beda5fb171cc9af5714b6778eb15d6ed0e82b
|
|
BLAKE2b-256 checksum How to use checksums |
78aec662d1fa27e4a5c2843c72018f1f128ec760015f0196636f29bd6140f11b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
pdm/2.16.1 CPython/3.11.2 Linux/6.1.0-22-amd64
|
Security for pymscada-milp 0.0.3
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.