Writing complicated equations for problem-based optimization
이전 댓글 표시
I'm trying to solve a system of 16 non-linear equations, but don't know how to properly setup the optimization problem in Matlab.
While there are 16 variables that I am optimizing (a vector T, with entries i and scalar p), there are also intermediate parameters that are functions of the choice variables and model parameters (which are given).
The code I have so far is
%Initial Variables
w = [0 2000 4000 6000 8000 10000 12500 15000 17500 20000 25000 30000 50000 100000];
w_dis_init = [.142 .033 .027 .028 .03 .048 .052 .065 .047 .082 .098 .164 .145 .039];
t_init = .4;
nit = 6000;
H = 5000;
v = 1;
%Elasticities
int_elast = .25*ones(1,length(w)); %zeta
ext_elast = zeros(1,length(w)); %eta
for(i=1:length(w))
if(w(i)<= 20000)
ext_elast(i) = .5
end
end
%Constructed Variables
T_init = (1-t_init)*w - nit;
c_init = w - T_init;
%Optimization Variables
T = optimvar('T',1,length(w));
p = optimvar('p',1);
c = zeros(1,length(w));
g = zeros(1,length(w));
h = w_dis_init;
%Optimization Equations
eq_c = c == (w-T);
eq_g = g == (p*c).^(-1);
eq_h = h == w_dis_init.*(c-c_init)/(c_init-c_init(1));
eq_hg = g.*h == 1;
eq_ht = h.*T == H;
I don't know if equations c,g, and h are how to properly code these laws of motion in MATLAB; I also don't know how to code the 14 equations governing T - my current best guess is to use a for loop to write out the 14 equations "manually" but I'm not sure.
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Systems of Nonlinear Equations에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!