【发布时间】:2019-05-10 16:50:10
【问题描述】:
我需要求解一个包含 44 个未知数 (x) 的 44 个方程组,其形式如下
(-1/(1 - x(t))) + (phi(t) * (1/T) * Σ_{h=45}^{60} β^{h-t})) = 0
其中 phi_t 对于 t
我有两种类型的约束。首先,所有 x 必须介于 0.1 和 0.5 之间,并且 T 必须低于 0.9。
编辑:以下链接是完整问题的图片以及代表解决方案的相关方程组,Stack Overflow 不允许我发布图片。 Maximization problem 和 system of equations。约束基本上意味着 x(t) \in [0.1, 0.5] 对于所有 t 和 phi(25)x(25) + phi(26)x(26) ... + phi(43)x(43) + phi(44)x(44)
我使用 Matlab 的 fmincon,它返回的解决方案满足 τ 的约束位置,但返回的 T 的结果远高于预期的最大值 0.9 .
我使用以下主文件:
clear all
clc
% Solve restricted problem
global beta phi w C R D
C = 25;
R = 40;
D = 55;
beta = 0.99;
phi = [0,1];
w = ones(1,R-1);
phiB = phi(1)*ones(1,R-1);
for i=C:R-1
phiB(i) = phi(2);
end
lb = 0.1*ones(1,R-1); % Lower bound constraint
ub = 0.5*ones(1,R-1); % Lower bound constraint
rng default % reproducible initial point
x0 = 0.01*ones(R-1,1);
opts = optimoptions(@fmincon,'Algorithm','interior-point','Display','off');
sol = fmincon(@(x)0,x0,phiB,0.9,[],[],lb,ub,@fminconstr,opts)
fmincon 函数表示常数的最大化,因此唯一需要满足的是等式和不等式约束。它调用函数fminconstr,形式为
function [c,ceq] = fminconstr(x)
c = []; % nonlinear inequality
ceq = fbnd(x); % the fsolve objective is fmincon constraints
end
其中约束是方程组,由函数fbnd
定义function F = fbnd(x)
global R C D
global beta
global phi
global w
phiB = phi(1)*ones(1,R-1);
for i=C:R-1
phiB(i) = phi(2);
end
T = phiB * x;
F = NaN(1,R-1);
for i=1:C
betaM = beta*ones(1,D-R);
for j = 1:D-R
betaM(j) = beta^(R+j-i-1);
end
F(i) = ((-1/(w(i)-x(i))) + phi(1)*(1/T)*sum(betaM));
end
for i=C-1:R-1
betaM = beta*ones(1,D-R);
for j = 1:D-R
betaM(j) = beta^(R+j-i-1);
end
F(i) = ((-1/(w(i)-x(i))) + sum(phi(2)*betaM'*(1/T)));
end
end
程序返回的 x 值介于 0.1 和 0.5 之间,因此这些约束确实有效。但是当按照问题中的描述计算 T 时(在 fmincon 表示法中,我理解这个约束是 Ax
我也尝试将此约束定义为 c(x)
sol = fmincon(@(x)0,x0,[],[],[],[],lb,ub,@fminconstr2,opts)
fminconstr2 现在在哪里
function [c,ceq] = fminconstr2(x)
global phi
global R
global C
c = fbnd2(x); % nonlinear inequality
ceq = fbnd(x); % the fsolve objective is fmincon constraints
end
而 fbnd2 是
function T = fbnd2(x)
global R C
global phi
phiB = phi(1)*ones(1,R-1);
for i=C:R-1
phiB(i) = phi(2);
end
T = phiB * x - 0.9;
end
并获得相同的结果,T 约为 4.6。
我想求解同一个方程组,但我需要获得一个在我指定的约束范围内的 T 值。
【问题讨论】:
-
向我们展示等式约束的清晰数学公式,而不仅仅是代码
-
编辑:以下链接是完整问题的图片以及代表解决方案的相关方程组,Stack Overflow 不允许我发布图片。 Maximization problem 和 system of equations。约束基本上意味着 x(t) \in [0.1, 0.5] 对于所有 t 和 phi(25)x(25) + phi(26)x(26) ... + phi(43)x(43) + phi(44)x(44)
标签: matlab constraints system equation