Skip to content

Allow PybammBuilder to remove/add costs, datasets, models #735

@BradyPlanden

Description

@BradyPlanden

Allow the pybamm builder to remove costs and reapply new costs alongside resetting the model and dataset would be helpful in reducing the verbosity of the multi-fitting style problems. Here's the syntax I'm thinking of:

# First build
builder = pybop.builders.Pybamm()
builder.set_dataset(dataset)
builder.set_simulation(model_1)
builder.add_parameter("Positive electrode active material volume fraction", initial_value=0.6)
builder.add_cost(pybop.costs.pybamm.SumSquaredError("Voltage [V]", "Voltage [V]", 1.0))
builder.set_experiment(experiment)
problem = builder.build()

# Remove all costs, add a new one and build
builder.remove_costs()
builder.add_cost(pybop.costs.pybamm.RootMeanSquaredError("Voltage [V]", "Voltage [V]", 1.0))
problem2 = builder.build()

# Set a new model and build
builder.set_model(model_2)
problem3 = builder.build()

# Set new dataset and build
builder.set_dataset(dataset_2)
problem4 = builder.build()

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions