Azzera filtri
Azzera filtri

Custom TuningGoal for systune

7 visualizzazioni (ultimi 30 giorni)
max.s
max.s il 18 Mar 2022
Risposto: Milan Bansal il 2 Feb 2024
I'm trying to implement a custom TuningGoal for the systune function. I started by copying the code of TuningGoal.Gain to a new class GainTest and adding the line
fObj = 1/fObj;
to the end of evalSpec_. I expected that when running this code:
k = realp('k', 200);
k.Minimum = 100;
k.Maximum = 500;
G = tf(k, [1 0.1 1], InputName='u', OutputName='y');
goal = GainTest('u', 'y', 1);
opt = systuneOptions(RandomStart=9, MaxIter=1000);
[sol, fSoft, ~, info] = systune(G, goal, opt);
It should maximize k instead of minimizing k because of the modification made to the tuning goal. To my suprise, k still gets minimized.
My feeling is that the tuning goals may be hardcompiled somewhere under the hood?... Is it possible to create custom TuningGoals?
PS: I've seen the other question on Custom TuningGoals, but I feel the option to just define custom classes was not even explored there.
  1 Commento
max.s
max.s il 18 Mar 2022
Okay so I think I got this wrong. evalSpec is not used by systune, instead, the objective is converted to a SPECDATA struct whose Type field determines the operation.

Accedi per commentare.

Risposte (1)

Milan Bansal
Milan Bansal il 2 Feb 2024
Hi max.s
I understand that you are trying to implement a custom "TuningGoal" for the "systune" function. You have modified the "TuningGoal.Gain" class to create a new class, GainTest with the intention of inverting the objective function to maximize the gain instead of minimizing it.
  • The modification "fObj = 1/fObj" should invert the objective function, but it's important to ensure that this change is being applied in the context where "fObj" is used to calculate the cost for the optimization.
  • Instead of inverting the object function "fObj", make the objective negative, i.e., "fObj = - fObj". This modification does not change the shape of the objective function but will only turn the curve upside down.
  • Ensure that the custom "GainTest" class is being used by the "systune" function. It is possible that due to some misconfiguration, the original "TuningGoal.Gain" class is still being used.
Please refer to the following documentation links to learn more about the "systune" function and the "TuningGoal.Gain" object.
Hope this helps!

Categorie

Scopri di più su Discrete Multiresolution Analysis in Help Center e File Exchange

Prodotti


Release

R2021b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by