How to use the cog.Cog function in cog

To help you get started, weโ€™ve selected a few cog examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github alito / becca / core / gearbox.py View on Github external
""" Initialize the level, defining the dimensions of its cogs """
        self.max_cables = int(2 ** np.ceil(np.log2(min_cables)))
        self.max_cables_per_cog = 16
        self.max_bundles_per_cog = 8
        self.max_cogs = self.max_cables / self.max_bundles_per_cog
        self.max_bundles = self.max_cogs * self.max_bundles_per_cog
        self.name = name
        self.level = level
        ziptie_name = ''.join(('ziptie_', self.name))
        self.ziptie = ZipTie(self.max_cables, self.max_cogs, 
                             max_cables_per_bundle=self.max_cables_per_cog,
                             name=ziptie_name, in_gearbox=True)
        self.cogs = []
        # TODO: only create cogs as needed
        for cog_index in range(self.max_cogs):
            self.cogs.append(Cog(self.max_cables_per_cog, 
                                 self.max_bundles_per_cog,
                                 max_chains_per_bundle=self.max_cables_per_cog,
                                 name='cog'+str(cog_index), 
                                 level=self.level))
        self.cable_activities = np.zeros((self.max_cables, 1))
        self.bundle_activities = np.zeros((self.max_bundles, 1))
        self.raw_cable_activities = np.zeros((self.max_cables, 1))
        self.previous_cable_activities = np.zeros((self.max_cables, 1))
        self.hub_cable_goals = np.zeros((self.max_cables, 1))
        self.fill_fraction_threshold = 0.
        self.step_multiplier = int(2 ** self.level)
        self.step_counter = 1000000
        # The rate at which cable activities decay (float, 0 < x < 1)
        self.ACTIVITY_DECAY_RATE = 1.
        # Constants for adaptively rescaling the cable activities
        self.max_vals = np.zeros((self.max_cables, 1))
github alito / becca / src / scripts / core / block.py View on Github external
self.max_cables_per_cog = max_cables_per_cog
        self.max_bundles_per_cog = max_bundles_per_cog
        self.max_cogs = max_cogs
        self.max_cables = max_cables
        self.max_bundles = self.max_cogs * self.max_bundles_per_cog
        self.name = name
        self.level = level
        ziptie_name = ''.join(('ziptie_', self.name))
        self.ziptie = ZipTie(self.max_cables, self.max_cogs, 
                             max_cables_per_bundle=self.max_cables_per_cog,
                             mean_exponent=-2,
                             joining_threshold=0.2, name=ziptie_name)
        self.cogs = []
        # TODO: only create cogs as needed
        for cog_index in range(max_cogs):
            self.cogs.append(Cog(self.max_cables_per_cog, 
                                 self.max_bundles_per_cog,
                                 max_chains_per_bundle=self.max_cables_per_cog,
                                 name='cog'+str(cog_index), 
                                 level=self.level))
        self.cable_activities = np.zeros((self.max_cables, 1))
        self.ACTIVITY_DECAY_RATE = .5 # real, 0 < x < 1
        # Constants for adaptively rescaling the cable activities
        self.max_vals = np.zeros((self.max_cables, 1)) 
        self.min_vals = np.zeros((self.max_cables, 1))
        self.RANGE_DECAY_RATE = 10 ** -5
github alito / becca / src / scripts / agent / level.py View on Github external
def __init__(self, max_inputs=300, max_cogs=10,
                 max_inputs_per_cog=20, max_outputs_per_cog=50, 
                 name='anonymous'):
        """ Initialize the level, defining the dimensions of its cogs """
        self.max_inputs = max_inputs
        self.max_cogs = max_cogs
        self.max_inputs_per_cog = max_inputs_per_cog
        self.max_outputs_per_cog = max_outputs_per_cog
        self.ziptie = ZipTie(self.max_inputs, self.max_cogs)
        self.cogs = []
        # TODO: only create cogs as needed
        for cog_index in range(max_cogs):
            self.cogs.append(Cog(self.max_inputs_per_cog, 
                                 self.max_outputs_per_cog,
                                 name='cog'+str(cog_index)))
        self.name = name
        # Determine which of the level's inputs will be routed to which cog
        #self.input_map = np.zeros((0,0))
        # Determine how the outputs of each cog will be organized in the 
        # level's set of outputs
        self.output_map = np.zeros((self.max_inputs, self.max_cogs))
        #self.num_feature_inputs = 0
        # Constants for adaptively rescaling the inputs
        self.max_vals = np.zeros((self.max_inputs, 1)) 
        self.min_vals = np.zeros((self.max_inputs, 1))
        self.RANGE_DECAY_RATE = 10 ** -3