Example #1
0
    def GtoP(self, genome):
        """
        Convert genome to network metrics.

        Need to update this to fit MN network.
        """
        n = 0

        self.i2h_weights = []
        for i in range(self.h):
            w = []
            for j in range(self.i):
                w.append(normalize(genome[n]))
                n += 1
            self.i2h_weights.append(w)
        print(n)

        self.h2o_weights = []
        for i in range(self.o):
            w = []
            for j in range(self.h):
                w.append(normalize(genome[n]))
                n += 1
            self.h2o_weights.append(w)
        print(n)

        self.hidden_bias = [normalize(x) for x in genome[n:n + self.h]]
        self.output_bias = [normalize(x) for x in genome[n + self.h:]]
def G_to_P(genome, nodes, connections):
    """Convert genome type to phenotype."""
    # nodes
    for n in nodes.keys():
        if 'time_const_locus' in nodes[n].keys():
            nodes[n]['time_const'] = normalize(
                genome[nodes[n]['time_const_locus']], out_min=0, out_max=1)
        if 'bias_locus' in nodes[n].keys():
            nodes[n]['bias'] = normalize(genome[nodes[n]['bias_locus']])
    # connections
    for c in connections.keys():
        connections[c]['weight'] = normalize(
            genome[connections[c]['weight_locus']])

    return nodes, connections
Example #3
0
    def G_to_P(self):
        """Convert genome type to phenotype."""
        for n in self.nodes.keys():
            if 'time_const_locus' in self.nodes[n].keys():
                self.nodes[n]['time_const'] = normalize(
                    self.genome[self.nodes[n]['time_const_locus']],
                    out_min=0,
                    out_max=1)
            if 'bias_locus' in self.nodes[n].keys():
                self.nodes[n]['bias'] = normalize(
                    self.genome[self.nodes[n]['bias_locus']])

        for c in self.connections.keys():
            self.connections[c]['weight'] = normalize(
                self.genome[self.connections[c]['weight_locus']])
            print(self.connections[c]['weight'])
Example #4
0
drone_dyn_body.add_forceobj(point_name='Aero', force_obj=AeroForces(Fd))
# Flight computer

fc = FlightComputer(dt, fc_config)
fc.PWM_hover = PWM_hover

state_ = SixDofState.zero_states('ground_ned')
state_.g_fun = ned_gravity
state = np.hstack([state_.vector, w])
for t in time:

    if (t > 3):
        eulAngSP = np.array([-0.1, 0.1, 0])

    x = np.array(state[0:3])
    q_s = normalize(state[3:7])
    x_dot = np.array(state[7:10])
    omega = np.array(state[10:13])
    w = state[13:17]
    state_.update(state[0:13])

    # Model Updates
    drone_dyn_body.force_obj_dict['Aero'].update(x_dot)
    # Derivatives
    drone_dyn_body.force_obj_dict.keys()
    w_dot = []
    for idx, motor in enumerate(motor_objs):
        w_dot.append(motor.derivative(w[idx]))
    w_dot = np.array(w_dot)
    sixdofstate_dot = drone_dyn_body.derivative(state_)