cognac package

Subpackages

Submodules

cognac.centralized_dql module

class cognac.centralized_dql.CentralizedDQNAgent(n_agents, state_size, action_size, lr=0.001, gamma=0.95, epsilon=1.0, epsilon_decay=0.995, epsilon_min=0.01)

Bases: object

select_action(state)
store_experience(state, actions, reward, next_state, done)
train()
class cognac.centralized_dql.DeepQNetwork(state_size, action_size, hidden_size=16)

Bases: Module

forward(x)

Define the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

cognac.centralized_qlearning module

class cognac.centralized_qlearning.CentralizedQLearningAgent(n_agents, state_size, action_size, alpha=0.001, gamma=0.95, epsilon=1.0, epsilon_decay=0.9995, epsilon_min=0.01)

Bases: object

get_action_index(actions)

Converts binary action array to an index.

get_state_index(state)

Converts binary state array to an index.

select_action(state)
update_q_table(state, actions, reward, next_state)

cognac.decentralized_reinforce module

class cognac.decentralized_reinforce.PolicyNetwork(input_dim, output_dim)

Bases: Module

forward(x)

Define the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

class cognac.decentralized_reinforce.REINFORCEAgent(input_dim, lr=0.01)

Bases: object

select_action(state)
store_transition(log_probs, reward)
update_policy()
cognac.decentralized_reinforce.decentralized_reinforce(env: ParallelEnv, episodes=1000)

cognac.idql module

class cognac.idql.IndependentQLearningAgents(env, alpha=0.1, gamma=0.9, epsilon=0.1)

Bases: object

select_action(agent, state)
test(episodes=10)
test_all(init_vect_list)
train(episodes=1000)
update_q_table(agent, state, action, reward, next_state)
cognac.idql.encode_state(state)

Encodes a multi-discrete state (NumPy array) as a tuple for dictionary indexing.

cognac.reinforce module

class cognac.reinforce.PolicyNetwork(input_dim, hidden_dim=32)

Bases: Module

forward(state)

Define the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

class cognac.reinforce.REINFORCEAgent(input_dim, lr=0.01)

Bases: object

select_action(state)
store_transition(log_probs, reward)
update_policy()

Module contents