-
Notifications
You must be signed in to change notification settings - Fork 40
Closed
Labels
good first issueGood for newcomersGood for newcomersobjectivesAdding or improving objective functionsAdding or improving objective functionsoptimizationAdding or improving optimization methodsAdding or improving optimization methods
Description
ObjectiveFunction.print_value does not always print the true sum of squares error.
Minimal working example:
from desc.equilibrium import Equilibrium
from desc.objectives import ObjectiveFunction, AspectRatio
eq = Equilibrium(L=2, M=2, N=0)
obj = ObjectiveFunction(AspectRatio(eq, target=7))
eq.solve(objective=obj, verbose=3)
Gives the output:
Starting optimization
Using method: lsq-exact
Iteration Total nfev Cost Cost reduction Step norm Optimality
0 1 4.500e+00 5.294e-15
`gtol` condition satisfied.
Current function value: 4.500e+00
Total delta_x: 0.000e+00
Iterations: 0
Function evaluations: 1
Jacobian evaluations: 1
Timer: Solution time = 210 ms
Timer: Avg time per step = 210 ms
Start of solver
Total (sum of squares): 5.000e+01,
Aspect ratio: 3.000e+00 (dimensionless)
Aspect ratio: 3.000e+00 (normalized)
The initial aspect ratio is 10 and the target value is 7, so the error is 3. The corresponds to the cost of 1/2 * 3**2 = 4.5.
But the printed sum of squares is 1/2 * 10**2 = 50.
We should edit the print_value function so it gives the same sum of squares value as the optimizer displays.
Metadata
Metadata
Assignees
Labels
good first issueGood for newcomersGood for newcomersobjectivesAdding or improving objective functionsAdding or improving objective functionsoptimizationAdding or improving optimization methodsAdding or improving optimization methods