Architectures

Classes to create hierachy architectures from array configurations.
#sys.path.append("..")

source

BaseArchitecture

 BaseArchitecture (name=None, config=None, env=None, inputs=None,
                   history=None, error_collector=None, namespace=None)

Base class of an array architecture. This class is not used direclty by developers, but defines the functionality common to all.


source

ProportionalArchitecture

 ProportionalArchitecture (name='proportional', config=None, env=None,
                           input_indexes=None, history=False,
                           error_collector=None, namespace=None, **cargs)

Proportional Architecture


source

DynamicArchitecture

 DynamicArchitecture (*args, **kwargs)

Dynamic Architecture


source

run_from_properties_file

 run_from_properties_file (root_dir='.', path='.', file=None, nevals=None,
                           runs=500, history=True, verbose=False,
                           test=False, move=None, draw=False,
                           plots_figsize=(15, 4), render=True,
                           layout=None, early_termination=False,
                           plots=None, seed=None, print_properties=False,
                           figsize=(12, 12), summary=False,
                           hpct_verbose=False, error_collector_type=None,
                           error_response_type=None, draw_file=None,
                           funcdata=False, interactive_mode=False)

source

load_properties

 load_properties (root_dir=None, file_path=None, file_name=None,
                  nevals=None, seed=None, print_properties=False,
                  gens=None, pop_size=None, evolve=False)

source

setup_environment

 setup_environment (properties, render=False, seed=None,
                    early_termination=None, error_collector_type=None,
                    error_response_type=None)

source

create_hierarchy

 create_hierarchy (env, error_collector, properties, history=False,
                   suffixes=False)
from pct.environments import VelocityModel
from pct.structure import ArchitectureStructure
from pct.functions import IndexedParameter
from pct.hierarchy import PCTHierarchy
from pct.structure import LevelKey
from pct.nodes import PCTNode
env = VelocityModel(name='VModel')
namespace=env.namespace
inputs=[2]
structure = ArchitectureStructure()
config = {'parameters': {}, 'level0': [[[1.0864011617580416, -1.0342161642584196], [-8.899524671308557, -8.976856229389936]], [-0.7295091920311653, -4.460573287694404], [0, 0], [[-4.146713118740296, 1.2794655139677662]]]}
with warnings.catch_warnings():
    warnings.simplefilter("ignore")
    pa = DynamicArchitecture(structure=structure, config=config, env=env, input_indexes=inputs, namespace=namespace) #, error_collector=te)
    pa()
#hpct = pa.get_hierarchy()
#hpct.summary()
#move={'VModel': [-0.2, -0.3],'Input0': [-0.3, 0],'OL0C0ws': [-0.4, 0],'OL0C1ws': [0.6, 0]}
#hpct.draw(move=move, with_edge_labels=True, figsize=(14,14))
from pct.environments import Pendulum
from pct.functions import Constant
pen = Pendulum(name='Pendulum',render=True, seed=1)
namespace = pen.namespace
#print(namespace)
inputs=[2, 3]
config = {'level0': [[[0, 0, 1], [0, 0, 1]], [74.7727669099358, 37.42447782017047, 70.45900090605967], [[1, 0, 1]]], 'level1': [[[1, 0, 1], [1, 1, 1]], [0.028281504070566288, 0.29618653732851286], [[-49.05302284318027, 46.949638698585005], [-96.63198831250754, -29.78373183094591], [-3.8249493797145107, -60.95121501461629]]], 'level2': [[[1, 0], [0, 1]], [0.633350421196448, 0.5607290603484817], [[41.217164164869104, -76.70635343790484], [83.21744682425535, -96.9311066757899]], [1, 2]], 'parameters': {}}
for key in config.keys():
    print(key, config[key])
pa = ProportionalArchitecture(config=config, env=pen, input_indexes=inputs, namespace=namespace)
pa()
hpct = pa.get_hierarchy()
hpct.draw(move={'Pendulum': [-0.2, -0.3],'Input0': [-0.3, 0], 'Input1': [0.3, 0]})
level0 [[[0, 0, 1], [0, 0, 1]], [74.7727669099358, 37.42447782017047, 70.45900090605967], [[1, 0, 1]]]
level1 [[[1, 0, 1], [1, 1, 1]], [0.028281504070566288, 0.29618653732851286], [[-49.05302284318027, 46.949638698585005], [-96.63198831250754, -29.78373183094591], [-3.8249493797145107, -60.95121501461629]]]
level2 [[[1, 0], [0, 1]], [0.633350421196448, 0.5607290603484817], [[41.217164164869104, -76.70635343790484], [83.21744682425535, -96.9311066757899]], [1, 2]]
parameters {}
pen = Pendulum(name='Pendulum',render=True, seed=1)
namespace = pen.namespace
inputs=[2, 3]
config = {'level0': [[[0], [0]], [60.92750637861888], [[1]]], 'level1': [[[1], [1]], [0.8221926728404025, 0.5936199577845901], [[2.941087338758976, -68.59700733589955]], [1, 2]], 'parameters': {}}
for key in config.keys():
    print(key, config[key])
pa = ProportionalArchitecture(config=config, env=pen, input_indexes=inputs, namespace = namespace)
pa()
hpct = pa.get_hierarchy()
hpct.draw(move={'Pendulum': [-0.2, -0.3],'Input0': [-0.3, 0], 'Input1': [0.3, 0]})
level0 [[[0], [0]], [60.92750637861888], [[1]]]
level1 [[[1], [1]], [0.8221926728404025, 0.5936199577845901], [[2.941087338758976, -68.59700733589955]], [1, 2]]
parameters {}
pen = Pendulum(name='Pendulum',render=True, seed=1)
namespace = pen.namespace
inputs=[2]
config = {'level0': [[[1]], [62.82423385532463], [[0]], [1]], 'parameters': {}}
for key in config.keys():
    print(key, config[key])
    
pa = ProportionalArchitecture(config=config, env=pen, input_indexes=inputs, namespace = namespace)
pa()
hpct = pa.get_hierarchy()
hpct.draw(move={'Pendulum': [-0.2, -0.3],'Input0': [-0.3, 0]})
level0 [[[1]], [62.82423385532463], [[0]], [1]]
parameters {}