absolute value in equality constraints
2 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Housam
il 26 Set 2021
Risposto: Walter Roberson
il 26 Set 2021
i would like to know how to write the absolute value in equality constraints.
var10(i) = var10(i-1) + (0.5/4500) * (ABS ( 0.25*var7(i) ) ) / var9(i)
my Input(i) is a vector with the length of 350*1 with positive integer values, that are measurements of a continuous variable.
prob = optimproblem;
% equality constrainst
prob.Constraints.econs6 = optimconstr(N); %Non linear with absoulte
prob.Constraints.econs6(1) = var10(1) == (0.5*(1/4500) * abs((var7(1) *0.25))) ./ var9(1);
prob.Constraints.econs6(2:N)= var10(2:N) == var10(1:N-1) + (0.5*(1/4500) * abs((var7(2:N)*0.25))) ./ var9(2:N);
x0.var7 = zeros(size(N));
x0.var9 = zeros(size(N));
x0.var10 = zeros(size(N));
[values,fval,exitflag,output] = solve(prob,x0,'Options',options);
thanks in advance for hints.
0 Commenti
Risposta accettata
Walter Roberson
il 26 Set 2021
N = 5;
var10 = optimvar('var10', N);
var9 = optimvar('var9', N);
var7 = optimvar('var7', N);
prob = optimproblem;
ABS = @(x) sqrt(x.^2);
% equality constrainst
prob.Constraints.econs6 = optimconstr(N); %Non linear with absoulte
thisconstraint = var10(1) == (0.5*(1/4500) * ABS((var7(1) *0.25))) ./ var9(1)
prob.Constraints.econs6(1) = thisconstraint
prob.Constraints.econs6(2:N)= var10(2:N) == var10(1:N-1) + (0.5*(1/4500) * ABS((var7(2:N)*0.25))) ./ var9(2:N);
x0.var7 = zeros(N,1);
x0.var9 = zeros(N,1);
x0.var10 = zeros(N,1);
[values, fval, exitflag, output] = solve(prob, x0);
0 Commenti
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Nonlinear Optimization in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!