I'm trying to run this program through Optimtool but getting the errors - "Undefined function 'symsum' for input arguments of type double". Can somebody help me with this code?

Attached Picture is the actual question. I want to perform a Simulated Annealing algorithm on this question to find the number of iterations occurring before reaching the final value. Here is the code that I wrote -
function y = SAcode(N)
syms i
y = symsum((N(1)-3).^2+(N(2).^(i)-3).^2 +(N(3).^(i)-3).^2,i,1,N(1));
end
ObjectiveFunction = @SAcode;
n = [2 2.4 3.6];
lb = [1 1 1];
ub = [5 5 5];
[N,fval,exitFlag,output] = simulannealbnd(ObjectiveFunction,n,lb,ub);
fprintf('The number of iterations was : %d\n', output.iterations);
fprintf('The number of function evaluations was : %d\n', output.funccount);
fprintf('The best function value found was : %g\n', fval);

 Respuesta aceptada

>> N =[20:23]
syms k
y = symsum((N(1)-3).^2+(N(2).^(K)-3).^2 +(N(3).^(K)-3).^2,K,1,N(1));
N =
20 21 22 23
>> y
y =
576242485144297694059340321398556670349680706722787840
>>

10 comentarios

The above shows an example but I didn't get any trouble getting the result
But when I'm trying to run the same function for Simulated Annealing, it is giving me the error. The attached picture is what I'm getting.
I think symbolic operations are not allowed in optimisation maybe try:
N =[20:23]
K=1:N(1)
y = cumsum((N(1)-3).^2+(N(2).^(K)-3).^2 +(N(3).^(K)-3).^2);
y(end)
Yeah. It finally ran. Thank you so much.
The program did ran, but in the output I found that only two values of N are displayed. What could be the explanation for that?
Two values of N are displayed
I don’t understand , mind explaining?
This is what I got in output.
Optimization terminated: change in best function value less than options.FunctionTolerance.
The number of iterations was : 1000
The number of function evaluations was : 1009
The best function value found was : 5
>> [N,fval,exitFlag,output] = simulannealbnd(ObjectiveFunction,n,lb,ub)
Optimization terminated: change in best function value less than options.FunctionTolerance.
N =
2.4000 3.6000
fval =
5
exitFlag =
1
I don’t have any experience with optimisation so my knowledge is limited in this field sorry
No problem. Thank you so much for the rectification.
Anytime :) glad that I could help

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Productos

Preguntada:

el 29 de Oct. de 2018

Comentada:

el 29 de Oct. de 2018

Community Treasure Hunt

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

Start Hunting!

Translated by