How to perform the absolute value function on the output of an optimisation expression?

8 visualizzazioni (ultimi 30 giorni)
% Create Optimisation expressions
j = length(x); % is a double array
Tk = optimexpr(j);
Uk = optimexpr(j);
energyCost = optimexpr(j);
thermalCost = optimexpr(j);
%Initialise optimisation expressions
Tk(1,1) = 22;
Uk(1,1) = Tk(1,1)*K; % K=0.6
energyCost(1,1) = Uk(1,1)*abs(x(1,1));
thermalCost(1,1) = abs(Tk(1,1)-nominal_T); % THIS WHERE THE PROBLEM IS
% The last line always produces an error... "Undefined function 'abs' for input arguments of type 'optim.problemdef.OptimizationExpression'"
% How can I get round this?
  4 Commenti
dpb
dpb il 17 Lug 2019
Modificato: dpb il 17 Lug 2019
That'll be under however the TB does constrained optimization, then, but certainly that wouldn't be done by calling abs() on the optimization object but has to be internal.
I'm not that familiar with the app; I've only used the direct user-called routines so not sure exactly how to set it up.
Boy, this seems to be a rat's nest of complexity to wend one's way through...but, try
and related links and see if can figure out how it's all supposed to work together.

Accedi per commentare.

Risposta accettata

Matt J
Matt J il 22 Lug 2019
Modificato: Matt J il 22 Lug 2019
Without seeing your complete problem, it is hard to be certain, but you might find minL1lin (File Exchange download) applicable to this case. You need to enter the data into minL1lin in solver-based form, but you can still use prob2struct to extract all the relevant constraint matrices from your current problem-based code.
  11 Commenti
Matt J
Matt J il 23 Lug 2019
Should this line not be
energyCost(i,1) = Uk(i,1)*abs(x(i,1));
Without the abs, it could surely explain why the cost could be driven to -Inf.
Akinkunmi Adegbenro
Akinkunmi Adegbenro il 23 Lug 2019
Modificato: Akinkunmi Adegbenro il 23 Lug 2019
Well spotted Matt! It was indeed the problem, it works now. Thank you very much for your help.

Accedi per commentare.

Più risposte (0)

Prodotti


Release

R2017b

Community Treasure Hunt

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

Start Hunting!

Translated by