user defined initial chromosomes?

58 views
Skip to first unread message

Sam Taylor

unread,
May 23, 2016, 6:23:23 PM5/23/16
to pyevolve
Hi,

I am just beginning to play with Pyevolve and Genetic Algorithms, and I would appreciate some direction to help me solve a problem I am working on.
I have 20 sensors, and I would like to configure their settings to achieve some optimal results.  Each sensor has 6 parameters (three int, three string values), with restrictions. For example the mode parameter can be On or off (not both), the duration parameter could be a 20,30,or 40 seconds. I am not sure how to define my problem, none of the Pyevolve tutorials I came across are solving something similar. Is there a way to say to initialize user defined chromosomes (sensors) ?

Many thanks for all your help.

Have  a great day.

Sam.

Arseniy Terekhin

unread,
May 24, 2016, 4:45:10 AM5/24/16
to pyev...@googlegroups.com
Check "Example 11 - The use of alleles" in documentation.

--

---
You received this message because you are subscribed to the Google Groups "pyevolve" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pyevolve+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
I remain,
Arseniy Terekhin

Sam Taylor

unread,
May 24, 2016, 8:54:24 AM5/24/16
to pyevolve
Dear Arseniy, Many thanks for your help.

I had a look at the exercise 11. As I mentioned I have 20 sensors (a sensor network), each sensor be set up with different configurations. Lets assume there are 3 different configurations for each sensor, making a list of 60. Looking at this exercise, it seems I will be creating an object Sensor and add these 60 objects to the GAlleleList. I will be running these configurations, lets assume I am checking the energy consumption of the overall network. Thus, I can only set up one configuration per sensor. Assume my fitness function is, overall energy consumption of the sensor networks.

Now my question is this, how do I ensure only one configuration is allowed for each sensor, do I force this as part of the eval_funct as done in the exercise 11 (i.e. make sure the chromosome at position contains a certain value). Is there another way to do this?

Thanks.

Arseniy Terekhin

unread,
May 24, 2016, 2:25:43 PM5/24/16
to pyev...@googlegroups.com
On Tue, May 24, 2016 at 2:44 PM, 'Sam Taylor' via pyevolve <pyev...@googlegroups.com> wrote:

Each sensor be set up with different configurations.
Lets assume there are 3 different configurations for each sensor, making a list of 60. Looking at this exercise, it seems I will be creating an object Sensor and add these 60 objects to the GAlleleList. I will be running these configurations, lets assume I am checking the energy consumption of the overall network. Thus, I can only set up one configuration per sensor. Assume my fitness function is, overall energy consumption of the sensor networks.

That's reasonable.

Now my question is this, how do I ensure only one configuration is allowed for each sensor, do I force this as part of the eval_funct as done in the exercise 11 (i.e. make sure the chromosome at position contains a certain value). Is there another way to do this? 

I believe there is nothing wrong with checking uniqueness in `eval_func`.
Do you add alleles like this?

for i in xrange(20):
    duration_s = GAllele.GAlleleList([20, 30, 40])
    voltage = GAllele.GAlleleList(range(10, 110, 10))
    current = GAllele.GAlleleList([0.1, 0.2, 0.4, 0.8])
    state = GAllele.GAlleleList(['on', 'off'])
    mode = GAllele.GAlleleList(['zig-zag', 'steps'])
    magic = GAllele.GAlleleList(['novice', 'wizard])
    setOfAlleles.add(duration_s)
    setOfAlleles.add(voltage)
    setOfAlleles.add(current)
    setOfAlleles.add(state)
    setOfAlleles.add(mode)
    setOfAlleles.add(magic)

In this configuration, do you expect overall energy consumption fitness to set all states to 'off'?

Sam Taylor

unread,
May 25, 2016, 6:53:46 AM5/25/16
to pyevolve


On Tuesday, 24 May 2016 19:25:43 UTC+1, Арсений (rus) wrote:
On Tue, May 24, 2016 at 2:44 PM, 'Sam Taylor' via pyevolve <pyev...@googlegroups.com> wrote:

Each sensor be set up with different configurations.
Lets assume there are 3 different configurations for each sensor, making a list of 60. Looking at this exercise, it seems I will be creating an object Sensor and add these 60 objects to the GAlleleList. I will be running these configurations, lets assume I am checking the energy consumption of the overall network. Thus, I can only set up one configuration per sensor. Assume my fitness function is, overall energy consumption of the sensor networks.

That's reasonable.

Now my question is this, how do I ensure only one configuration is allowed for each sensor, do I force this as part of the eval_funct as done in the exercise 11 (i.e. make sure the chromosome at position contains a certain value). Is there another way to do this? 

I believe there is nothing wrong with checking uniqueness in `eval_func`.
Do you add alleles like this?

for i in xrange(20):
    duration_s = GAllele.GAlleleList([20, 30, 40])
    voltage = GAllele.GAlleleList(range(10, 110, 10))
    current = GAllele.GAlleleList([0.1, 0.2, 0.4, 0.8])
    state = GAllele.GAlleleList(['on', 'off'])
    mode = GAllele.GAlleleList(['zig-zag', 'steps'])
    magic = GAllele.GAlleleList(['novice', 'wizard])
    setOfAlleles.add(duration_s)
    setOfAlleles.add(voltage)
    setOfAlleles.add(current)
    setOfAlleles.add(state)
    setOfAlleles.add(mode)
    setOfAlleles.add(magic)


I have done something similar, I have created an object called Sensor and added the three possible configuration for each sensor to the setOfAlleles:

  sensorIDList=[1, 2, 3, 4, 5, 7, 8, 9, 10, 11, 12, 14, 15, 17, 31, 40, 48, 52, 62, 108]
  totalSensors=len( sensorIDList)
  for i in range(totalSensors):
       sensorID=  sensorIDList[i]
       sensorA =  Sensor.Sensor(sensorID, 'OFF', 'NONE', 0, 0, 0)
        sensorB = Sensor.Sensor(sensorID, 'ON', 'INTERVAL', 20, 30, 40)
        sensorC = Sensor.Sensor(sensorID, 'ON', 'PERIODIC', 5, 100,20)
        a = GAllele.GAlleleList([sensorA, sensorB, sensorsC]);
        setOfAlleles.add(a);

  genome = G1DList.G1DList(20)
  genome.setParams(allele=setOfAlleles)


I wanted GA to give me one configuration (A, B or C) for each 20 sensor. This code seems to work. I thought by doing this, I might get a list of 20 configurations, containing multiple configurations for some sensors. The next part is to take the chromosome (def eval_func(chromosome)) convert it to a script and use this script to configure the sensor networks. I want GA to find the setting with the maximum energy consumption, this is what my fitness function should check. 

In this configuration, do you expect overall energy consumption fitness to set all states to 'off'?

No - there is no need for this.
Reply all
Reply to author
Forward
0 new messages