LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Feedback for Genetic Algorith

Solved!
Go to solution

Scenarios - I select a number between 1 and 100. I want to make a genetic algorithm that prompts the user for an initial guess, max step size (s), and population size (n).

Actions - Mutate the generations to guess the correct number. This number of "mutations" or iterations is not limited yet but could be.

 

Ideally, I would like to plot each round and do this at a time of 1 second per generation. Attached is my vi. I am a new user.

 

 

 

0 Kudos
Message 1 of 7
(2,534 Views)

As a first step, do a few LabVIEW tutorials.

  1. There is absolutely no need for a sequence structure.
  2. Your controls belong before the loop.
  3. "Insert into array" is not the right tool to append two 1D arrays (well, it works, but ...).
  4. There is a negate. No need for 0-x (and 0+x makes little sense either)
  5. Don't you need some toplevel loop or state machine?
  6. Label things. Which control gets the 1...100 user selection?
  7. ...

 

In general, of you have question about a certain algorithm, please add a link to a website that describes it.

0 Kudos
Message 2 of 7
(2,499 Views)

Thanks for the feedback altenbach. Instead of saying what is wrong with the vi, could you suggest solutions?

 

The goal is this:

https://ieeexplore.ieee.org/abstract/document/5393665

0 Kudos
Message 3 of 7
(2,490 Views)

Man there are a lot of Rube Goldberg's in your code.

 

I went ahead and cleaned them up with the equivalent but simpler code.  See attached.  (Test it to make sure I didn't miswire something that causes a different result.)

 

As for your question, I have no idea what you mean by a "genetic algorithm" or understand your description of the process.  Hopefully cleaner code makes it easier for you and others to sort that out.

0 Kudos
Message 4 of 7
(2,489 Views)

@JohnKellyPhD wrote:

Thanks for the feedback altenbach. Instead of saying what is wrong with the vi, could you suggest solutions?


I pointed out general flaws. I cannot suggest improvements until I know what the code is supposed to do.  You have not even said where the 1...100 is entered and what typical values for all controls are. I'll have a look at your link later.

0 Kudos
Message 5 of 7
(2,486 Views)

Thanks for the clean up! But it looks like the task is different. I did a horrible job of explaining...

 

The process should be:

1) Set "Target"value (ex: 50)

2) Set "Initial" value (ex: 10)

3) Set "Range" (ex: 5)

4) The program should generate n number of random values. n = Population size.

5) These numbers should be compared to the Target. The closest number to that Target should be sent back as the initial value so that new random numbers can be generated from that.

Note: If the initial value is 10 and the range is 5, the best case output is 15 (if the target is 50). The next iteration. 15 is the starting point and now 20 is the best possible output. Eventually the output gets close to 50 and then statistics of the random number generator will drive the number of iterations.

 

Does this make sense?

 

0 Kudos
Message 6 of 7
(2,456 Views)
Solution
Accepted by topic author JohnKellyPhD

Maybe something like the attached can give you some ideas.

0 Kudos
Message 7 of 7
(2,440 Views)