Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug during crossover #9

Open
cassiotbatista opened this issue Jun 23, 2021 · 1 comment
Open

bug during crossover #9

cassiotbatista opened this issue Jun 23, 2021 · 1 comment
Labels
bug Something isn't working

Comments

@cassiotbatista
Copy link
Owner

python -m rwa_wdm -t rnp -c 8 --rwa genetic-algorithm -y 2 -s 10 -d /tmp/results -p                                               
[2021-06-23 18:12:15] [__main__] INFO     Simulating 150 connection requests over rnp topology with 8 λ per link using genetic-algorith
m as RWA algorithm                                                                                                                     
Load:      1    2    3    4    5    6    7    8    9   10   11   12   13   14   15   16   17   18   19   20   21   22   23   24   25   
26   27   28   29   30                                             
Blocks: Traceback (most recent call last):                                                                                             
  File "/home/cassio/anaconda3/lib/python3.8/runpy.py", line 194, in _run_module_as_main                                               
    return _run_code(code, main_globals, None,                                                                                         
  File "/home/cassio/anaconda3/lib/python3.8/runpy.py", line 87, in _run_code                                                          
    exec(code, run_globals)                                        
  File "/home/cassio/anaconda3/lib/python3.8/site-packages/rwa_wdm/__main__.py", line 107, in <module>                                 
    simulator(args)                                                                                                                    
  File "/home/cassio/anaconda3/lib/python3.8/site-packages/rwa_wdm/sim.py", line 172, in simulator                                     
    lightpath = rwa(net, args.y)                                   
  File "/home/cassio/anaconda3/lib/python3.8/site-packages/rwa_wdm/rwa/rwa.py", line 151, in genetic_algorithm_callback                
    route, wavelength = ga.run(net, k)                                                                                                 
  File "/home/cassio/anaconda3/lib/python3.8/site-packages/rwa_wdm/rwa/ga/ga.py", line 107, in run
    offspring = cross(mating_pool, self._population_size,                                                                              
  File "/home/cassio/anaconda3/lib/python3.8/site-packages/rwa_wdm/rwa/ga/env.py", line 113, in cross
    children.add_chromosome(Chromosome(son))                       
UnboundLocalError: local variable 'son' referenced before assignment     
@cassiotbatista cassiotbatista added the bug Something isn't working label Jun 23, 2021
@cassiotbatista
Copy link
Owner Author

The crossover function is sampling bad chromosomes from the mating pool. In RNP, for example, the "dad" chromosome is often a short route [3, 11], from DF to PE, which is impossible topology-wise.

from rwa_wdm.net import RedeNacionalPesquisa
RedeNacionalPesquisa(8).plot_topology()  # bad practice but OK we just wanna take a look

Figure_1

Log (try-except on env.cross()):

-> % python -m rwa_wdm -t rnp -c 8 --rwa genetic-algorithm -s 10  -d /tmp/results38 -p                                         
[2021-07-08 20:32:47] [__main__] INFO     Simulating 150 connection requests over rnp topology with 8 λ per link using genetic-
algorithm as RWA algorithm                                                                                                     
Load:      1    2    3    4    5    6    7    8    9   10   11   12   13   14   15   16   17   18   19   20   21   22   23   24
   25   26   27   28   29   30                                                                                                 
Blocks:  0139                   
dad [3, 11]                                                                                                                    
mom [3, 9, 8, 7, 18, 17, 16, 15, 11]                                                                                           
Blocks: 0000  0000                                                                                                             
dad [3, 11]                                                                                                                    
mom [3, 22, 18, 17, 16, 15, 11]

Router indices (from rnp.py#L49):

  • ('DF', (4.00, 5.00)), # 3
  • ('PE', (9.50, 1.00)), # 11

This might be so for a couple of reasons, yet to be investigated:

  • rnp.py: get_edges() may be defining wrong neighbours in the topology
  • pop.py: make_chromosome() may be initialising the population with bad chromosomes from the start
  • env.py: cross() may be generating a bad offspring across generations
  • env.py: mutate() may also be generating invalid chromosomes across generations

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant