# setting-up input variable in genetic algorithm

조회 수: 5 (최근 30일)
Ful0 . 2021년 2월 6일
댓글: Walter Roberson . 2021년 2월 17일
How can I set up an input variable in my ga that varies from 1 to 2 with steps of 0,1?
The results of my ga has too many significant digits after comma ( precisely 4).
Thank you
##### 댓글 수: 1표시 없음숨기기 없음
Walter Roberson 2021년 2월 17일
If you are seeing exactly 4 significant digits, chances are that you have
format short
in effect, and that you would see more digits if you used
format long g

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

### 채택된 답변

Alan Weiss 2021년 2월 17일
You need to use Mixed Integer ga Optimization in one of several ways.
• Internally to your objective function, change your integer variable x to x/10. Or,
• Make a list of allowable values in a variable indexvar. Have your objective function evaluate indexvar(x), where x is your integer-valued variable. This is more flexible, in that you can have any list of allowable values.
See Solving a Mixed Integer Engineering Design Problem Using the Genetic Algorithm and in particular the section Add Discrete Non-Integer Variable Constraints.
Alan Weiss
MATLAB mathematical toolbox documentation

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

### 추가 답변 (1개)

Shiva Kalyan Diwakaruni 2021년 2월 10일
Hi,
You can try using optimoptions for genetic algorithm where you can many options for passing extra parameters either in form of variables or a user defined function.
below is the link to see how we can pass extra paramters for customization of ga function
hope it helps,
thanks
##### 댓글 수: 1표시 없음숨기기 없음
Ful0 2021년 2월 17일
Hi,
I'm yet not able to find a way to set up the option I need for my problem.
How can I set up a step of 0,1 in the output? through PopulationType:custom?
Thank you

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

### 카테고리

Help CenterFile Exchange에서 Genetic Algorithm에 대해 자세히 알아보기

### Community Treasure Hunt

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

Start Hunting!

Translated by