Optimizing a function with a vector as input

14 ビュー (過去 30 日間)
Víctor García
Víctor García 2021 年 5 月 18 日
編集済み: Matt J 2021 年 5 月 19 日
Hi everyone,
I have a function with an input of 6 values (6 periods of power) and only one output, the price. I would like to optimize the output value (minimize it) changing the input, but I have found no information about how to optimize with a vector as an imput instead of an scalar. I already tried with fminsearch or optimproblem, but none worked.
Thank you in advance!

採用された回答

Matt J
Matt J 2021 年 5 月 18 日
There is no reason why an OptimizationVariable can't be vector-valued, e.g.,
P=optimvar('P',[6,1]);
size(P)
ans = 1×2
6 1
  5 件のコメント
Víctor García
Víctor García 2021 年 5 月 19 日
How can I write then the prob.Objective function? Let's say you want to minimize a function f output (which is a scalar), and the input is that: P=optimvar('P',[6,1]); Wouldn't it be:
prob = optimproblem('Objective',@function(P);
[x, fval] = solve(prob)
Thank you Matt!
Matt J
Matt J 2021 年 5 月 19 日
編集済み: Matt J 2021 年 5 月 19 日
You have much more freedom in the way you write the objective function if you use the solver-based framework

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeGet Started with Optimization Toolbox についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by