Optimization
The optimizer: what may change, what must hold, and what is being minimized.
All three come out of the case file. A variable becomes free by gaining an optimize: entry
where it is already declared, so a study that frees one more variable differs by three lines;
constraints and the objective are their own top-level blocks, mirroring the
add_constraint/add_objective calls in OpenConcept’s own optimizing examples.
Everything is checked before anything expensive starts. A cheap probe of the box is built first,
and every free variable is confirmed to be an independent variable the box accepts, the
objective and every constraint to be a quantity it publishes. A misspelled name is a message
naming it with suggestions, not an OpenMDAO error thrown out of setup after a minute of
building.
Converging before driving is not optional. The box is a Newton-solved implicit system that needs a continuation ladder to reach a long-range mission from a cold start; the driver’s first function evaluation must begin from a converged aircraft, and every later one begins from its predecessor.
- exception cdadt.optimization.OptimizationError[source]
Bases:
ExceptionRaised when an optimization is not well posed, before any of it is run.
- class cdadt.optimization.OptimizationOutcome(baseline, optimum, constraints, objective, sense, failed)[source]
Bases:
objectThe baseline, the optimum, and whether the constraints hold at it.
- Parameters:
baseline (SizingResults) – The converged design before optimization.
optimum (SizingResults) – The converged design after it.
constraints (list of ConstraintResult) – Every constraint evaluated at the optimum.
objective (str) – Name of the objective, as the case file gave it.
sense (str) –
"minimize"or"maximize".failed (bool) – Whether the driver reported failure.
- property baseline: SizingResults
The converged design before optimization.
- property optimum: SizingResults
The converged design after optimization.
- property constraints: list[ConstraintResult]
Every constraint, evaluated at the optimum.
- property objective: str
Name of the objective.
- property sense: str
"minimize"or"maximize".
- property succeeded: bool
Whether the driver converged and every constraint is satisfied.
Both halves matter. A driver that reports success having stopped on its iteration limit inside an infeasible region has not solved the problem, and a report that calls that an optimum is wrong.
- property violated: list[ConstraintResult]
The constraints that are not satisfied at the optimum.
- property active: list[ConstraintResult]
The constraints the optimum sits on, and which therefore shaped the design.
- class cdadt.optimization.Optimizer(analysis)[source]
Bases:
objectOptimize an aircraft against the constraints its case file declares.
- Parameters:
analysis (SizingAnalysis) – The sizing analysis to optimize. Its case file must declare an objective and at least one variable carrying an
optimize:entry.- Raises:
OptimizationError – If the case declares no objective, or if a free variable, the objective or a constraint does not address something the black box publishes.
- property analysis: SizingAnalysis
The sizing analysis being optimized.
- property basis: CertificationBasis
The constraints being enforced.
- property design_variables: dict[str, str]
Return
case-file name -> black-box pathfor every freed variable.The two differ whenever a mission value is freed:
cruise|h0in a case file ismission.cruise|h0inside the box. Resolved once, against a cheap probe, because a design variable has to be declared before the real model exists to be asked.
- property objective_path: str
Return the black-box path of the objective.
- property objective_units: str | None
Return the units the objective is optimized in.
- prepare(verbose=False, driver=True)[source]
Declare the study on the box and converge the baseline design.
- Parameters:
verbose (bool, optional) – Print the continuation steps and the driver’s own progress. Default
False.driver (bool, optional) – Attach the driver the case file asks for. Passing
Falseleaves the same declared, converged problem without one, which is what a total-derivative check needs: the derivatives an optimizer would step on, before it has stepped.
- Returns:
SizingResults – The converged baseline, read before anything has been optimized.
- Return type:
- run(verbose=False)[source]
Declare, converge the baseline, then drive.
- Parameters:
verbose (bool, optional) – Print the continuation steps and the driver’s own progress. Default
False.- Return type:
- report(outcome)[source]
Return the baseline-to-optimum comparison and the traceability matrix.
- Parameters:
outcome (OptimizationOutcome)
- Return type:
str