Skip to content

Create your first tradespace

You’ll run the workshop backup study, plot the choice between installation cost and remaining energy, and publish the same chart with a table in HTML and PDF. You don't need to write a model or know Altair for this tutorial.

For a preview, open the companion workshop report in interactive HTML or PDF. It shows the short-outage scenario and a parameter atlas; this tutorial builds the long-outage chart.

1. Run and summarize the workshop study

Follow the installation guide to set up Python and get the examples. In the folder containing studies/, install the visualization extra:

python -m pip install "paretorium[visualization]"

Create first_visualization.py in the same folder. Add these lines to run 100 draws per design and scenario with a fixed seed:

from pathlib import Path

from studies.example_backup import study
from paretorium import summarize
from paretorium.visualization import (
    Figure,
    Report,
    Section,
    TradespaceOverlays,
    export_chart,
    export_html,
    export_pdf,
    tradespace,
    tradespace_table,
)

result = study.run(samples=100, seed=42)
summaries = summarize(result.evaluations)
metrics = {metric.id: metric for metric in study.metrics}

The run covers two outage scenarios. The next step selects the 3.5-hour outage so that every design on the chart is compared under the same conditions.

2. Draw and inspect the chart

Append this code to the file. Cost is an objective to minimize, and reserve energy is an objective to maximize. The chart shows median outcomes and requires all sampled draws to meet the hard limits for Pareto eligibility.

comparison = dict(
    scenario="long_outage",
    x=metrics["cost_usd"],
    y=metrics["reserve_wh"],
    statistic="p50",
    min_feasibility=1.0,
    limit_metrics=study.metrics,
)

chart = tradespace(
    summaries,
    **comparison,
    overlays=TradespaceOverlays(show_limits=True),
)
output = Path("runs/first-visualization")
export_chart(chart, output, name="tradespace")

Run the script:

python first_visualization.py

Open runs/first-visualization/tradespace.html. You should see three dots, one per compatible design. The dashed line at 0 Wh marks the reserve limit. Hover over D-004 (small battery, regulated charger): its median reserve is about −44 Wh, and 67 of 100 draws failed the reserve limit. D-002 (large battery, regulated charger) passes in every draw and is the only eligible design, so the front is a single point. D-001 isn't plotted: it was rejected by a compatibility rule before any evaluations.

The same command wrote tradespace.svg, shown below. In the static chart, use the legend to find the only Pareto design. The shaded region below 0 Wh marks negative reserve.

Long-outage tradespace: one brown Pareto point above 0 Wh and two gray points below it.

Workshop example: 100 draws per design, seed 42. Each dot is a median.

3. Publish the chart and table together

Append a companion table using the same summaries and comparison settings. Wrap the chart in a Figure so you can give it a caption. A Section puts that figure and the table in reading order.

table = tradespace_table(summaries, **comparison)
report = Report(
    "Workshop backup review",
    (
        Section(
            "Long outage",
            (Figure(chart, "Installation cost versus median energy reserve."), table),
        ),
    ),
)
export_html(report, output / "report.html")
export_pdf(report, output / "report.pdf")

Run the same command again and open report.html in the output directory. Filter the table for D-004 and match the row to the chart by its design ID. You should see a row like this (only a few columns are shown here):

Design ID Concept reserve_wh (Wh) Feasible
D-004 battery=small,charger=regulated −43.82 33.0%

Filtering the table does not change the chart. Open report.pdf to see the chart and table in a static, paginated document.

You've taken one run from raw evaluations to a chart, a table, and a report. For a larger example with multiple metrics and views, go to Review a satellite tradespace. For an overview of what else you can build, see How visualization is organized.