Filter löschen
Filter löschen

Optimization cost function file

4 Ansichten (letzte 30 Tage)
Mondeep maz
Mondeep maz am 8 Jun. 2018
Kommentiert: Walter Roberson am 20 Aug. 2022
Is it possible that optimization can be done without creating a seperate function file for the cost function and the constraint?..if yes then how can we do it....?
  5 Kommentare
sabreen farouq
sabreen farouq am 19 Aug. 2022
where i can find this famous cost function ?
Walter Roberson
Walter Roberson am 20 Aug. 2022
There are a few example cost functions such as rosenbeck, but mostly you write your own cost function depending on what you want to optimize.
See also Problem Based Optimization

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

Walter Roberson
Walter Roberson am 9 Jun. 2018
Each iteration of the objective function called by fmincon or ga or similar must involve the same number of variables, and must be deterministic (no random values.)
You can use different numbers of variables for different calls to the minimizer, including in a loop. That could involve creating a new anonymous function for each iteration of the loop.
An objective function which is just the sum of variables can be expressed as just @sum; for a weighted sum, @(x) sum(x.*weights) or more robustly @(x) sum(x(:).*weights(:)) to be sure you do not have row/column difficulties.

Weitere Antworten (0)

Kategorien

Mehr zu Get Started with Optimization Toolbox finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by