Optimize a variable which is dependent on other variables

I'm trying to mimimize t with two constraints: 1) . 2) .
is a known value for each m. Also l is a constant number. Our optimization variables are s. I'm a little bit condused that how I can use "optimvar", because the optimization objective is not bascially a function of optimization variables.

2 Commenti

Should t >= 0 ?
What about the theta_m ? theta_m are >= 0 ?
Yes, actually t is representing time and is positive. Also are all positive and known in advance.

Accedi per commentare.

 Risposta accettata

theta = 1:20;
l = 5;
obj = @(x) x(1);
x0 = rand(1,numel(theta)+1);
sol = fmincon(obj,x0,[],[],[],[],zeros(1,numel(theta)+1),[],@(x)nonlcon(x,l,theta))
Local minimum found that satisfies the constraints. Optimization completed because the objective function is non-decreasing in feasible directions, to within the value of the optimality tolerance, and constraints are satisfied to within the value of the constraint tolerance.
sol = 1×21
5.5590 2.7795 1.3898 0.9265 0.6949 0.5559 0.4633 0.3971 0.3474 0.3088 0.2780 0.2527 0.2316 0.2138 0.1985 0.1853 0.1737 0.1635 0.1544 0.1463 0.1390
obj(sol)
ans = 5.5590
[c,~] = nonlcon(sol,l,theta)
c = -2.8782e-07
function [c,ceq] = nonlcon(x,l,theta)
c = l - sum(x(2:end).*(1-theta.*x(2:end)/x(1)));
ceq = [];
end

Più risposte (0)

Prodotti

Release

R2021b

Richiesto:

il 12 Dic 2022

Modificato:

il 12 Dic 2022

Community Treasure Hunt

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

Start Hunting!

Translated by