Battery Open Ended Capacity Max

Source: examples/optimization/battery_open_ended_capacity_max.py

Introduction

Inspect the packaged open-ended battery capacity benchmark.

Technical Implementation

This page is generated from the top-of-file module docstring and the example source code. The full script is included below for direct inspection.

 1from __future__ import annotations
 2
 3import design_research_problems as derp
 4
 5
 6def main() -> None:
 7    """Print a seeded start and a baseline solved explicit battery design."""
 8    problem = derp.get_problem("battery_pack_18650_open_ended_capacity_max")
 9    initial = problem.generate_initial_solution(seed=1)
10
11    print("Open-ended battery packaged benchmark")
12    print(problem.metadata.title)
13
14    try:
15        initial_components = problem.objective_components(initial)
16        initial_violation = problem.max_constraint_violation(initial)
17        result = problem.solve(maxiter=0)
18        solved_components = problem.objective_components(result.x)
19        solved_violation = problem.max_constraint_violation(result.x)
20    except derp.MissingOptionalDependencyError as exc:
21        print(exc)
22        return
23
24    print(
25        "initial",
26        f"cell_count={int(initial_components['cell_count'])}",
27        f"connection_count={int(initial_components['connection_count'])}",
28        f"delivered_capacity_ah={initial_components['delivered_capacity_ah']:.3f}",
29        f"end_voltage_v={initial_components['end_voltage_v']:.3f}",
30        f"design_volume_mm3={initial_components['design_volume_mm3']:.2f}",
31        f"violation={initial_violation:.3g}",
32    )
33    print("solve", result.message)
34    print(
35        "solved",
36        f"cell_count={int(solved_components['cell_count'])}",
37        f"connection_count={int(solved_components['connection_count'])}",
38        f"delivered_capacity_ah={solved_components['delivered_capacity_ah']:.3f}",
39        f"end_voltage_v={solved_components['end_voltage_v']:.3f}",
40        f"design_volume_mm3={solved_components['design_volume_mm3']:.2f}",
41        f"violation={solved_violation:.3g}",
42    )
43
44
45if __name__ == "__main__":
46    main()

Expected Results

Run Command

PYTHONPATH=src python3 examples/optimization/battery_open_ended_capacity_max.py

Run the command shown below from repository root. Output should summarize the problem setup, a baseline solution, or diagnostic values relevant to this example.