Matlab:fmincon的语法与主动集方法和只有不等式约束? [英] Matlab: syntax of the fmincon with active-set method and only inequality constraints?

查看:707
本文介绍了Matlab:fmincon的语法与主动集方法和只有不等式约束?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想尝试设置



编辑:如果要传递选项,所有可选参数:

  [x,fval] = fmincon(@ DijIIii,x0,A,b,[] ],[],[],@ nonlcon,options); 


I am trying to set up fmincon with the active-set method for the linear constrained minimisation problem where minimising the objective function @fun such that

but the trials firing odd errors more in the history.

Trial 1

[x,fval]=fmincon(@fun, Guess, A, b)

Trial 2

options = optimoptions('fmincon','Algorithm','active-set');
[x,fval]=fmincon(@fun, Guess, A, b, options)

解决方案

You are using the wrong options for the algorithm. MATLAB looks at the parameters you provide and uses an algorithm that uses those parameters. It throws a warning because different algorithms can have different results (and you should never ignore these) 'trust-region-reflective' is the default algorithm for fmincon. From the documentation:

'trust-region-reflective' requires you to provide a gradient, and allows only bounds or linear equality constraints, but not both.

The documentation for your call to fmincon says:

x = fmincon(fun,x0,A,b) starts at x0 and attempts to find a minimizer x of the function described in fun subject to the linear inequalities A*x ≤ b. x0 can be a scalar, vector, or matrix.

You probably intended to use

x = fmincon(fun,x0,A,b,Aeq,beq)

Where you would have A = [], b = [], and Aeq and beq be whatever you had A and b to before (if you want to use trust-region-reflective).

Your second trial did not work because you're actually calling x = fmincon(fun,x0,A,b,Aeq,beq). You instead try to pass an options structure.

This page explains how to set options

EDIT: If you want to pass options, you have to specify all the optional parameters:

[x,fval] = fmincon(@DijIIii,x0, A , b,[], [], [], [],@nonlcon,options);

这篇关于Matlab:fmincon的语法与主动集方法和只有不等式约束?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆