Module cma :: Class SolutionDict
[hide private]
[frames] | no frames]

Class SolutionDict

source code

       object --+                
                |                
    _abcoll.Sized --+            
                    |            
       object --+   |            
                |   |            
 _abcoll.Iterable --+            
                    |            
       object --+   |            
                |   |            
_abcoll.Container --+            
                    |            
      _abcoll.Mapping --+        
                        |        
   _abcoll.MutableMapping --+    
                            |    
              DerivedDictBase --+
                                |
                               SolutionDict
Known Subclasses:

dictionary with computation of an hash key.

The hash key is generated from the inserted solution and a stack of previously inserted same solutions is provided. Each entry is meant to store additional information related to the solution.

>>> import cma, numpy as np
>>> d = cma.SolutionDict()
>>> x = np.array([1,2,4])
>>> d[x] = {'f': sum(x**2), 'iteration': 1}
>>> assert d[x]['iteration'] == 1
>>> assert d.get(x) == (d[x] if d.key(x) in d.keys() else None)

TODO: data_with_same_key behaves like a stack (see setitem and delitem), but rather should behave like a queue?! A queue is less consistent with the operation self[key] = ..., if self.data_with_same_key[key] is not empty.

TODO: iteration key is used to clean up without error management

Nested Classes [hide private]

Inherited from _abcoll.Sized: __metaclass__

Instance Methods [hide private]
 
__init__(self, *args, **kwargs)
x.__init__(...) initializes x; see help(type(x)) for signature
source code
 
key(self, x) source code
 
__setitem__(self, key, value)
defines self[key] = value
source code
 
__getitem__(self, key)
defines self[key]
source code
 
__delitem__(self, key)
remove only most current key-entry
source code
 
truncate(self, max_len, min_iter) source code

Inherited from DerivedDictBase: __contains__, __iter__, __len__

Inherited from _abcoll.MutableMapping: clear, pop, popitem, setdefault, update

Inherited from _abcoll.Mapping: __eq__, __ne__, get, items, iteritems, iterkeys, itervalues, keys, values

Inherited from object: __delattr__, __format__, __getattribute__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__

Class Methods [hide private]

Inherited from _abcoll.Sized: __subclasshook__

Class Variables [hide private]

Inherited from DerivedDictBase: __abstractmethods__

Inherited from _abcoll.Mapping: __hash__

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, *args, **kwargs)
(Constructor)

source code 

x.__init__(...) initializes x; see help(type(x)) for signature

Overrides: object.__init__
(inherited documentation)

__setitem__(self, key, value)
(Index assignment operator)

source code 
defines self[key] = value
Overrides: _abcoll.MutableMapping.__setitem__

__getitem__(self, key)
(Indexing operator)

source code 
defines self[key]
Overrides: _abcoll.Mapping.__getitem__

__delitem__(self, key)
(Index deletion operator)

source code 
remove only most current key-entry
Overrides: _abcoll.MutableMapping.__delitem__