Skip to content

Start making users build before optimizing #513

@f0uriest

Description

@f0uriest

We had discussed this in the context of having multiple different optimizeable objects that we need to keep track of. The idea was to require the user to call objective.build themselves with the correct objects, rather than always calling it with eq.

A better option might be to simply require the user to pass in the correct optimizeable objects at objective init, but delay the expensive building part until .build is actually called, but this time .build would not take any arguments.

IE:

# binds the objective and the optimized object, 
# but doesn't actually do the expensive build part yet
objective1 = ForceBalance(eq=eq)
objective2 = QuadraticFlux(eq=eq, coilset=coilset)

# throws an error, needs eq
objective3 = AspectRatio(target=5)

objective1.build()
objective2.build()

That way things would be correctly bound together, but avoids the user having to manually call build a bunch of times (and in principle, we could call build automatically, without the user ever having to).

Metadata

Metadata

Assignees

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