필터 지우기
필터 지우기

How to pass variables to the fintness function in Genetic algorithm?

조회 수: 4 (최근 30일)
hello I am testing a Genetic algorithm without using the global optimization toolbox, I have defined the fitness function in a separtae matlab file and it is called by the main program with ga function ,in my fitness function i need some parametrs from the main function .Can someone tell me hwo to do this ?? I thought about declaring the variables as global variables but it doesn t work ?

채택된 답변

Alan Weiss
Alan Weiss 2012년 10월 10일
Alan Weiss
MATLAB mathematical toolbox documentation
  댓글 수: 1
Mariem Harmassi
Mariem Harmassi 2012년 10월 11일
Hello Alan thank u for the answer , i saw the documentation but it seems not possible to call the ga with f = @(x)parameterfun(x,a,b,c) i must call the fminunc function [x,fval] = fminunc(f,x0) :-/ :-(

댓글을 달려면 로그인하십시오.

추가 답변 (3개)

Alan Weiss
Alan Weiss 2012년 10월 11일
I'm sorry, I do not understand you. It is indeed possible to call the fitnes function with f = @(x)parameterfun(x,a,b,c). If you want more help, you will need to provide more information. Specifically:
1. Your function signature (function f = parameterfun(x,a,b))
2. Your calling syntax (x = ga(f,n,A,b))
3. All output MATLAB gives. I mean all, not an edited version.
Alan Weiss
MATLAB mathematical toolbox documentation

Alex Omar Topa Gavilema
Alex Omar Topa Gavilema 2022년 6월 3일
I have the same problem. how did you do it?

M Mirrashid
M Mirrashid 2022년 6월 5일

카테고리

Help CenterFile Exchange에서 Solver Outputs and Iterative Display에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by