Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to set black_death to true #661

Closed
Axelskool opened this issue Apr 21, 2022 · 12 comments
Closed

How to set black_death to true #661

Axelskool opened this issue Apr 21, 2022 · 12 comments
Labels
question Further information is requested

Comments

@Axelskool
Copy link

Hi, I have a custom pettingzoo Parallel environment and want to train a shared policy on multiple agents. I want to be able to have a few of my agents inactive during a training-episode under certain conditions. I also want to bring back agents during an episode. I call the petting_zoo_env_to_vec_env_v1 and concat_vec_envs_v1 on my environment to allow for shared policy and training on copies of the environment.

I also use the wrappers black_death_v3, pad_observations_v0 and pad_action_space_v0 to allow for agent death but I still get an error message "environment has agent death. Not allowed for pettingzoo_env_to_vec_env_v1 unless black_death is true". How do I set this? So in principle is it possible to have self.possible_agents as a sort of agent pool to take agents from and then have self.agents as the active agents during an episode?

best regards

Axel

@Axelskool
Copy link
Author

Alternatively can we somehow set the reward/observation to some value for the agents that have some inactive attribute set, in order to avoid using these agents for the learning step while they are inactive?

@jjshoots
Copy link
Member

jjshoots commented Apr 21, 2022

environment has agent death. Not allowed for pettingzoo_env_to_vec_env_v1 unless black_death is true

I believe the order of wrappers matters in this case. Are you wrappingn it in black death before doing pettingzoo_env_to_vec_env, and then only doing concat_vec_envs_v1?

@jjshoots
Copy link
Member

Alternatively can we somehow set the reward/observation to some value for the agents that have some inactive attribute set, in order to avoid using these agents for the learning step while they are inactive?

In general no, at least not without modifying the environment some manner or form I believe. Since you're the one writing the environment, that should be doable.

In general though, this sort of behaviour is the whole idea of the AEC environment.

@Axelskool
Copy link
Author

I am first wrapping the parallel petting zoo environment with black death, then petting_zoo_env_to_vec_env then concat_vec_envs_v1. The problem for our environment is that the problem is most easily formulated as a parallel enviroment and the rewards are difficult to calculate without knowing all the other agents actions at once. We are applying marl to manage creation of tracks in a multi-object tracking system.

@Axelskool
Copy link
Author

And if I convert this environment to an AEC, does vectorize_aec_env_v0(aec_env, num_envs, num_cpus=x) allow me to have parameter sharing if I use stable-baseline3 and ppo to train the agent.

Thank you again for your time. It's very appreciated!

@jjshoots
Copy link
Member

I think @RedTachyon is a better person to answer this question.

@benblack769
Copy link
Contributor

This black death error is often a symtom hiding the underlying problem. Some ideas:

  1. Did you check that your paralell env passes the parallel_api_test? https://www.pettingzoo.ml/environment_creation#parallel-api-test
  2. Does your environment generate new agents after reset is called? (the environment vectorization does not support this)
  3. Could you share your code snippet of how your environment is wrapped? We might be able to help debug this.

Unfortunately, vectorize_aec_env_v0 is not compatable with SB3.

@Axelskool
Copy link
Author

We generate new agents after reset is called in the sense that we reset the self.agents list and populate it once more. However, we do not change the the possible agents, list. We will try your suggestions! Thanks again!

@jjshoots jjshoots added the question Further information is requested label May 1, 2022
@benblack769
Copy link
Contributor

Do you repopulate the agents outside of reset (i.e. in step?). This is what is not supported.

@Axelskool
Copy link
Author

Yes this is what we did. Thanks for the reply.

@jjshoots
Copy link
Member

Hi @Axelskool, has this issue been solved? If so would it be possible to close it?

@Axelskool
Copy link
Author

Axelskool commented May 11, 2022 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants