Output function for Simulated Anealing

7 views (last 30 days)
Mohammad Shojaei Arani
Mohammad Shojaei Arani on 13 Jan 2023
Answered: Alan Weiss on 24 Mar 2023
Hello,
I am using Simulated anealing as my optimization solver. Unfortunately, I am unable to get what I want. When I look at the 'optimValues' (see bellow)I do not see 2 VERY IMPORTANT piece of information: 1) the current best solution x 2) The objective value of the current best solution. I believe you agree with me that these 2 pieces of information are the most important information any user needs (or wants) to know.
I do not know what to do with this??? !!!
Any idea?
Thanks for your kind help, in advance!
Babak
Default properties:
AcceptanceFcn: @acceptancesa
AnnealingFcn: @annealingfast
DataType: 'double'
Display: 'iter'
FunctionTolerance: 1.0000e-06
HybridFcn: []
InitialTemperature: [8×1 double]
MaxFunctionEvaluations: 1.7977e+308
MaxIterations: 200
MaxStallIterations: 4000
MaxTime: Inf
ObjectiveLimit: -Inf
OutputFcn: {@(optimValues,options,flag)myoutput_SA_Parametric(optimValues,options,flag,Max_iter)}
PlotFcn: []
ReannealInterval: 100
TemperatureFcn: @temperatureexp

Answers (2)

Sarthak
Sarthak on 24 Mar 2023
Hi Mohammad,
As per my understanding, the optimValues structure does contain
  • x — Current point
  • fval — Objective function value at x
  • bestx — Best point found so far
  • bestfval — Objective function value at best point
Attaching a documentation link for your reference as well.

Alan Weiss
Alan Weiss on 24 Mar 2023
You have mistaken the output of optimoptions for the optimvalues structure in simulate annealing.
opts = optimoptions("simulannealbnd")
opts =
simulannealbnd options: Set properties: No options set. Default properties: AcceptanceFcn: @acceptancesa AnnealingFcn: @annealingfast DataType: 'double' Display: 'final' FunctionTolerance: 1.0000e-06 HybridFcn: [] InitialTemperature: 100 MaxFunctionEvaluations: '3000*numberOfVariables' MaxIterations: Inf MaxStallIterations: '500*numberOfVariables' MaxTime: Inf ObjectiveLimit: -Inf OutputFcn: [] PlotFcn: [] ReannealInterval: 100 TemperatureFcn: @temperatureexp
When you create an output function for simulated annealing you can obtain the information from the optimvalues structure as described in Output Function Options. For an example showing how to use an output function for ga, which has a different syntax, see Custom Output Function for Genetic Algorithm. Be careful to use the syntax for simulannealbnd, not the syntax for ga, in your custom output function.
Alan Weiss
MATLAB mathematical toolbox documentation

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!