LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

I've made a mess of my VI and I'm lost

Anybody that could help would be helping my immensely.
 
I have incorporated a new subVI into this simple genetic algorithm VI. The problem is that originally, initially an array was formed. Now a cluster is formed and it has messed up the rest of my VI. as the data types are different.
 
I have included the VI, can anyone suggest how I would fix it? The broken wires show where (I am assuming) the data types are incompatible and the system breaks down. Also, the aim of the "calculate fitness VI" was to sum all of the values in the array and return the overall value as an evaluation function. Do I have this part set-up correctly?
 
Thanks
 
Alan Homer
 
P.S. Genetic Algorithm is the main overall VI, the other VI's are subVIs in the main VI.
0 Kudos
Message 1 of 10
(3,533 Views)
I added some comments to your code and tried to get it working, but I guess I am still a little lost, ie not really understanding what ll you want to do with it and what you need to input and output.  Go through the code I sent back and read all the comments and maybe it will give you an idea of where to go or I can work with you more to try to get it going.

It seems like it will be a really cool program when it is working right.
Kenny

Message 2 of 10
(3,479 Views)

Hi,

I have a problem opening the file you sent back. I am using v.7.1 and I assume you must have used v.8 as that is an error that comes up. Genetic algorithms are great little programs, but I can explain a little more about what I am trying to do. Firstly on the left of the VI, a user defined number of samples is specified, and a user defined length of array. The "createinitialarray.vi" creates N samples of length M arrays filed with random values that has a floating point representation (i.e. if I want my values in the array to lir between 0-5, the numbers are any random number (doesn't have to be an integer) between 0 and 5).

After the arrays are created (ultimately I need approx. 30 arrays of 640 values) they are assigned a fitness function. The fitness function I have in the VI at present will not be what I use experimentally. The feedback into the fitness function will come from a mass spectrometer assigning a particular current associated with each array. I don't yet have that equipment or the drivers so I can't create that part yet, so I keep a simple fitness function for now. Each array will eventually be linked to a liquid crystal spatial light modulator (LC-SLM) that has 640 pixels, hence the 640 points in the array. Each pixel will have it's phase varied between user defined values (that is why I needed the floating point representation). I am trying to optically shape femtosecond laser pulses. Again, I can't add the link to the LC-SLM as it hasn't arrived yet and all I know is that it is LabVIEW compatible. After each generation (the calculation of the fitness of each of the 30 arrays) the fitness is plotted to a chart and the 30 (intially random) arrays go through a selection process. The arrays with the highest (or lowest depending on what I want) fitness functions undergo crossover and mutation (Darwinian evolution operators) in the "RouletteWheelSelectionSmallArray", and an improved population of another 30 arrays is created.

This process will continue until the fitness function reaches a required accuracy specified by me, at which the GA will have done it's job and I will have the laser pulse that I require.

 

I hope this makes your understanding of my project a little clearer. I can use LabVIEW OK but I haven't used it for 18 months and I am very rusty. I am most grateful for any help. Is there a way of opening an application produced in LabVIEW 8 in LabVIEW 7.1?

Thanks

 

ALan Homer

0 Kudos
Message 3 of 10
(3,449 Views)

Hi Alan,

You cannot open an application SAVED in LabVIEW 8 within LabVIEW 7.1.

However, you can save an application produced in LV 8 as previous version ie produce it in LV 8 and save it as LV7.1. This will allow LV 7.1 users to open the application although it was produced in LV 8

This is done by using "file"> "save for previous version" rather than using "save as".

I have opened the annotated LV 8 VI that was posted and saved it back to LV 7.1 for you, so you should be able to open it now.

Hope this helps you,

Emma R

NIUK & Ireland

Message 4 of 10
(3,427 Views)
Thanks
0 Kudos
Message 5 of 10
(3,423 Views)

Kenny K,

I have attached the original version of the simple GA that works and originally created a Boolean array. That is the reason why I changed the "Create Initial array" subVI. I need to be able to specify the number of arrays, the number of genes(values) in each array, and I need the values in the array to be a floating point representation. The "N random arrays" VI works exactly as I want it to, but I need to incorporate that VI into this version that I have attached instead of the "CreateInitialArray.vi".

Also, the feedback loop shown in this attached version is definately required. That is the whole idea of the GA to operate in a feedback loop system so the fitness function is continually improved.

Thanks for the help.

0 Kudos
Message 6 of 10
(3,417 Views)

If i read it right, you want to replace the Create Initial Array (outputs boolean into theinitalze terminal) with the NRandomArray (which outputs double into the initalize terminal).  Did I get it right??

I altered your VI to use dbl's throughout instead of the booleans.  I attached it below.  You will need to go though and make sure it is outputting erverything you need.  You will probably need to change some of the algorithms, but let me know if it helps.

Kenny

Kenny

0 Kudos
Message 7 of 10
(3,386 Views)

Thanks for the help mate but I think there still maybe some misunderstanding as to what I am trying to achieve. I have worked through the GA and for a while I thought it was working but after a closer look I realized it is not achieving its aims. I have worked through the GA from start to finish and mentioned what I expect to see at each point.

1) On the front panel, the user inputs a vlaue for the "Number of Samples" and "Length" which correspond to the number of arrays wanted and the length of these arrays. For a simple case scenario I tried to run Number of Samples = 5, and Length =2.

2) These values then pass into the "N Random Arrays VI" and 5 arrays of length of 2 should be created and filled with floating point numbers randomly selected between 0 and 1. i.e. an example of the expected output here would be [0.12, 0.45], [0.98, 0.65], [0.45, 0.32], [0.76, 0.74], and [0.01, 0.67]. (These have just been made up by me to show what I want to be produced).

3) These N arrays should then pass into the  "Calculate Fitness.vi" which is presently set to calculate "4 x Total sum of array elements" in each array, therefore all 5 arrays would be assigned a fitness value (i.e.for my example arrays above the respective fitness values would be 2.28, 6.52, 3.08, 6 and 2.72.

4) Ignoring the statistics route for now, each of these 5 arrays should pass into the "RouletteWheelSelectionSmallArray.vi" where these "parent" arrays are paired up and undergo a crossover procedure dependant on their fitness values. The higher the fitness value the more likely they are to be involved in the crossover procedure. They then undergo a 0.1% chance of a random mutation at a random point on an array. At this point at the end of this subVI there should still be a population of 5 arrays consisting of 2 floating point values, but which are different to the initial population.

5) There is then a feedback loop that returns these 5 new arrays to the "Calculate Fitness VI" and the process repeats until the average fitness is optimized.

In testing the GA I placed a write to spreadsheet subVI at the enf of (4) so in theory I should be prompted in each generation (one single loop) for 5 file names in which in each should be placed an array of 2 floating point values between 0 and 1. Instead I get the results:

Generation 0 (the first loop using the 5 initial arrays in theory): one file that contains the values 0.536 and 0.462 (exactly what I want but I want 5 of these in each generation not just one) and I was prompted for a second filename in generation 0 and inside it returned the values (4,3,4,4,3) that look to be like the sample numbers 5 times? (not what is required).

In generation2 I was prompted for another filename that returned the value 72, and another filename that returned the value 288 (72 x 4). By this point I think the VI is just looping an individual fitness value and multiplying it by 4 instead of assigned 5 arrays of 2 values a fitness function each. Then in following generations the same proces occurs, i.e. the gen 4 values were 1152 (288 x 4) and 4608 (1152 x 4).

Can anyone help put this procedure correct so that the VI does what it should? I have tried following the process through step by step and I can't see why it's not working.

Thanks

I was prompted for nothing

Message Edited by alanhomer on 03-30-2006 03:25 AM

0 Kudos
Message 8 of 10
(3,328 Views)
I did some changes to the VI.  I tried to comment what I could.  I hope that it is close to what you were looking for.  I am sure there are some tweaks that might need to be done, but it should get you started on the rght foot.
 
See if you can play with it if you need to make changes.
 
Kenny
Kenny

0 Kudos
Message 9 of 10
(3,302 Views)

FAO KennyK:

Hi, I managed to solve the problem of the VI so now it works (almost) as I would like. I thought I would post the vi so you could have a look as you seemed quite interested in the work.

Thanks for the help.

0 Kudos
Message 10 of 10
(3,253 Views)