【问题标题】:Huge nb of parameters, constraint and objective function : how to deal with this in Matlab?大量参数、约束和目标函数:如何在 Matlab 中处理?
【发布时间】:2017-11-28 14:37:25
【问题描述】:

我想找到最小化这个目标函数的 Alpha 系数:

fun_Obj = @(Alpha) norm(A- sum(Alpha.*B(:,:),2),2)

与:

A= 向量 1d (69X1)

B= 矩阵 2d (69X1000)

Alpha_i 一个未知参数的向量 (1X1000),其中 0 和 sum(Alpha) = 1

处理这么多参数的最佳优化方法是什么(我可以尝试减少它仍然会保持很多)? 如何在优化过程中引入第二个约束,即 sum(Alpha_i) = 1

非常感谢您的宝贵帮助。

最好的,

本杰明

【问题讨论】:

  • 69*1 被认为是一维的,69*1000 被认为是二维的/
  • 是的,谢谢阿德里安。已更正。

标签: matlab optimization constraints particle-swarm cost-based-optimizer


【解决方案1】:

可以使用约束优化函数fmincon

% sample data
nvars = 1000;
A = rand(69,1);
B = rand(69,nvars);

% Objective function
fun_Obj = @(Alpha,A,B) norm(A- sum(Alpha.*B(:,:),2),2);

% Nonlinear constraint function. The first linear equality is set to -1 to make it alway true. 
%    The second induces the constraint that sum(Alpha) == 1
confuneq = @(Alpha)deal(-1, sum(Alpha)-1);

% starting values
x0 = ones(1,nvars)/nvars;

% lower and upper bounds
lb = zeros(1,nvars);
ub = ones(1,nvars);

% Finally apply constrained minimisation
Alpha = fmincon(@(x)fun_Obj(x,A,B),x0,[],[],[],[],lb,ub,@(x)confuneq(x));

在我的笔记本电脑上使用默认迭代次数只需几秒钟,但您应该考虑大幅增加该次数以获得更好的结果。此外,在这种情况下,默认算法可能不是正确的选择,'sqp' 可能更好。见documentation

您可以通过以下方式执行这些操作:

options = optimoptions(@fmincon,'Algorithm','sqp','MaxFunctionEvaluations',1e6);
Alpha = fmincon(@(x)fun_Obj(x,A,B),x0,[],[],[],[],lb,ub,@(x)confuneq(x),options);

【讨论】:

  • 非常感谢您的完美回答!它提出了很多其他问题,但现在已经解决了:) 干杯,
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2022-08-02
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2022-01-21
  • 1970-01-01
  • 2015-09-18
相关资源
最近更新 更多