I got an error when I try to create a population for GA. I used a 2d array to help generate a population. First, the user enters the size of the population, and then the length of the chromosome, in the user form.
My variables are:
Dim Generation As Integer Dim Chromolength As Integer Dim varchromolength As Integer Dim Poparr() As Integer
Then I select the values ββfrom the user form:
PopSize = PopulationSize.value aVariables = AOV.value 'assign userform value entered to this variable varchromolength = Chromolengthentered.value 'assign userform value entered to this variable Chromolength = varchromolength * aVariables 'Chromosome length equals the length of each varaible chromosome combined
Then coding where ocurs error:
For i = 1 To PopSize For j = 1 To Chromolength If Rnd < 0.5 Then Poparr(i, j) = 0 'assign o to gene Else Poparr(i, j) = 1 'assign 1 to gene End If Next j Next i
Sorry, I'm pretty new to VBA. Any help with this error would be appreciated.
source share