Skip to main content
engratepy is Engrate’s Python SDK for Cost of Energy.
pip install engratepy
Use it to:
  • calculate tariff cost from your own time-series data
  • discover which input datasets a tariff needs
  • embed tariff cost into optimisation models (HiGHS and Gurobi)

Authenticate

Create a client with your API key:
from engratepy import Engrate

engrate = Engrate(api_key="YOUR_API_KEY")

Discover Required Input Datasets

Before calculating or optimising, you can ask the SDK which datasets the tariff requires for the calculation period:
datasets = await engrate.get_input_datasets(
    tariff_id=tariff_id,
    start_time=...,
    end_time=...,
)

Calculate Cost

Run a cost calculation over a period:
costs_per_tariff_component = await engrate.calculate_cost(
    tariff_id=tariff_id,
    start_time=...,
    end_time=...,
    data={dataset: {timestamp: value, ...}},  # dataset from get_input_datasets
)

Use in Optimisation Models

engratepy can even add tariff costs directly to solver models:
import highspy

model = highspy.Highs()

costs_per_tariff_component = await engrate.add_to_highs_model(
    tariff_id=tariff_id,
    start_time=...,
    end_time=...,
    data={dataset: {timestamp: value, ...}},     # fixed inputs, e.g. spot prices
    variables={dataset: {timestamp: variable, ...}},  # your decision variables
    model=model,
)
import gurobipy

model = gurobipy.Model()

costs_per_tariff_component = await engrate.add_to_gurobi_model(
    tariff_id=tariff_id,
    start_time=...,
    end_time=...,
    data={dataset: {timestamp: value, ...}},     # fixed inputs, e.g. spot prices
    variables={dataset: {timestamp: variable, ...}},  # your decision variables
    model=model,
)
The model is extended in place, and cost is returned per component, either as a variable into the model, with constraints tying it to your decision variables, or as plain numbers where it is fixed. Need support for another solver? We would love to hear from you - contact support@engrate.io and we can discuss your use case.

Cookbook

For full working examples, take a look at our cookbook.

License

engratepy is available under an evaluation license. You are welcome to use it for internal evaluation, testing, learning, and prototyping in non-production environments. Production or commercial use requires a separate signed commercial license with Engrate. To discuss commercial licensing, contact support@engrate.io.