Matlab优化工具包学习(2)

    本来以为这个会很难学,发现学起来还挺简单的,感觉都不知道写啥了(可能要具体实施去做的时候才会感觉到难),由于官方文档中总提示优化APP(也就是那个系统界面)会在未来取消,所以我就学习了怎么在命令行去设置这个参数。下面是关于设置优化工具的函数。 

options = optimoptions(SolverName) %returns a set of default options for the SolverName solver.
options = optimoptions(SolverName,Name,Value) %returns options with the named parameters altered with the specified values.
options = optimoptions(oldoptions,Name,Value) z5returns a copy of oldoptions with the named parameters altered with the specified values.
options = optimoptions(SolverName,oldoptions) %returns default options for the SolverName solver, and copies the applicable options in oldoptions to options                             

其实这四个函数就是一个,只是有其四种不同的用法,第一个函数的主要作用是设置一个求解器,剩下的都是默认值。

options = optimoptions('fmincon')
options = fmincon options:

Options used by current Algorithm ('interior-point'):
(Other available algorithms: 'active-set', 'sqp', 'sqp-legacy', 'trust-region-reflective')
Set properties:
No options set.

Default properties:
Algorithm: 'interior-point'
CheckGradients: 0
ConstraintTolerance: 1.0000e-06
Display: 'final'
FiniteDifferenceStepSize: 'sqrt(eps)'
FiniteDifferenceType: 'forward'
HessianApproximation: 'bfgs'
HessianFcn: []
HessianMultiplyFcn: []
HonorBounds: 1
MaxFunctionEvaluations: 3000
MaxIterations: 1000
ObjectiveLimit: -1.0000e+20
OptimalityTolerance: 1.0000e-06
OutputFcn: []
PlotFcn: []
ScaleProblem: 0
SpecifyConstraintGradient: 0
SpecifyObjectiveGradient: 0
StepTolerance: 1.0000e-10
SubproblemAlgorithm: 'factorization'
TypicalX: 'ones(numberOfVariables,1)'
UseParallel: 0

Show options not used by current Algorithm ('interior-point')

如上述代码可知,第一个用法的调用就是第一行,而默认值default properties全在下面一系列,一般我们需要改的不是很多,如果要进行修改默认属性则需要用到第二个用法,由于默认属性都一样,以下三个用法我皆只举例说明。

第二个用法:修改设置 options = optimoptions(@fmincon,Algorithm’,‘sqp’,‘MaxIterations’,1500),括号里共有五个参数,第一个是求解器,第二个和第三个是一组,修改算法为sqp,第四个和第五个为修改最大迭代次数为1500

第三个用法:更新设置

oldoptions = optimoptions(@lsqnonlin,‘Algorithm’,‘levenberg-marquardt’, ‘MaxFunctionEvaluations’,1500) 

options = optimoptions(oldoptions,‘MaxFunctionEvaluations’,2000) 在你已经配置好了又不需要修改所有配置时,就可以用这个进行个别配置的更改,当然还可以直接用点标法进行修改,如: options.MaxFunctionEvaluations = 2000

第四个用法:复制配置到另一个求解器,如下所示 oldoptions = optimoptions(@fmincon,‘Algorithm’,‘sqp’,‘MaxIterations’,1500) ,options = optimoptions(@fminunc,oldoptions) 这里将fmincon的配置复制给了fminunc,需要注意的是复制过去的配置不仅仅是后面括号里的参数还有一些默认的参数,因为每个求解器的默认参数是有区别的。


最后就是将配置好的工具包用具体的求解函数调用即可,详情可见(1)。

5 Replies to “Matlab优化工具包学习(2)

  1. I’m really enjoying the desiign and layouht off your site.

    It’s a very easy on the eyes which makes itt much more pleasant
    for me to come here and visit more often. Did you hire outt a designer to create your theme?
    Great work!

  2. Winner’s live seller games feature slots, blackjack, baccarat, and Casino Hold ‘Em.

    Winner is essentially essentially the most ground breaking online casino to click on the market.
    Bingo gives you patience and perseverance to maintain on playing while
    some additional circumstances like winning bonuses will assist you to being indulge with the game at probably the most.

发表评论

邮箱地址不会被公开。 必填项已用*标注