フィルターのクリア

How can I write summationn constraints for an optimization problem?

3 ビュー (過去 30 日間)
Ricardo López
Ricardo López 2020 年 9 月 29 日
コメント済み: Matt J 2020 年 9 月 29 日
Good morning,
I would like to optimize the following equation:
min
with the following contraints:
x>0
Where is a known set of values, is equal to a [288x1] vector and is also known as a [288x1] vector.
How can I add those constraints? I am trying to use x=fmincon(fun,x0,A,b,Aeq,beq);
Thanks!
  1 件のコメント
Ricardo López
Ricardo López 2020 年 9 月 29 日
I would like to get the optimum x_i as a [1x288] vector.

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

採用された回答

Matt J
Matt J 2020 年 9 月 29 日
編集済み: Matt J 2020 年 9 月 29 日
fmincon is not the best tool to use for a linear program. In the problem-based framework, you can set up the problem to be solved with linprog() as follows:
x=optimvar('x',size(c),'LowerBound',0);
prob=optimproblem('Objective',x.'*price);
prob.Constraints.sumx=sum(x-c)==0;
sol=solve(prob);
  2 件のコメント
Ricardo López
Ricardo López 2020 年 9 月 29 日
Thanks! that works but it gives just one minimum. is electricity consumption and price is the price at every time i. I would like to re-locate that consumption in a "real" way. Not just finding a minimum in price and consume everything there.
Idk if I shoud add more constraints then, but it worked with the optimization tool in Matlab. Thing is, I would like to have or understand the code behind it.
Thanks!
Matt J
Matt J 2020 年 9 月 29 日
Thing is, I would like to have or understand the code behind it.
TMW will not provide the code, but there are algorithm descriptions here
It sounds like we have answered your original question, so I encourage you to Accept-click the answer. If you have spin-off questions, it would be best if you pose them in a separate thread.

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

その他の回答 (1 件)

Ameer Hamza
Ameer Hamza 2020 年 9 月 29 日
Something like this
price = rand(288, 1); % example value
c = rand(288, 1); % example value
sum_c = sum(c);
x0 = rand(288, 1); % initial guess
fmincon(@(x) price.'*x, x0, [], [], [], [], [], [], @(x) nlcon(x, sum_c)) % price.'*x is same as sum(price.*x)
function [cneq, ceq] = nlcon(x, sum_c)
cneq = [];
ceq = sum(x) - sum_c;
end

カテゴリ

Help Center および File ExchangeHistorical Contests についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by