PKU-Alignment / omnisafe

JMLR: OmniSafe is an infrastructural framework for accelerating SafeRL research.
https://www.omnisafe.ai
Apache License 2.0
939 stars 132 forks source link

feat: support discrete environment #286

Open Gaiejj opened 1 year ago

Gaiejj commented 1 year ago

Description

This pull request is aimed at supporting environments with discrete action spaces and observation spaces. It has been implemented in the Taxi-v3 and CartPole-v1 environments in Gymnasium. Relevant documents, code checks, and standards have been updated. Currently, it supports the following on-policy algorithms:

['NaturalPG', 'PolicyGradient', 'PPO', 'TRPO', 'RCPO', 'PDO', 'PPOLag', 'TRPOLag', 'OnCRPO', 'P3O', 'IPO', 'CPPOPID', 'TRPOPID', 'CPO', 'PCPO',]

to run in discrete environments. The performance curve below shows the correctness of our implementation. algo---CartPole-v1---bd252e6d92d63ae5628feb2cb9f076c4535775919201e12bb086eb4496b3ed4f

Motivation and Context

resolve #273 #283

Types of changes

What types of changes does your code introduce? Put an x in all the boxes that apply:

Checklist

Go over all the following points, and put an x in all the boxes that apply. If you are unsure about any of these, don't hesitate to ask. We are here to help!

codecov[bot] commented 1 year ago

Codecov Report

Attention: Patch coverage is 90.68323% with 15 lines in your changes missing coverage. Please review.

Project coverage is 96.70%. Comparing base (d55958a) to head (e68bf5c). Report is 13 commits behind head on main.

Files with missing lines Patch % Lines
omnisafe/envs/discrete_env.py 85.96% 8 Missing :warning:
omnisafe/models/base.py 63.64% 4 Missing :warning:
omnisafe/evaluator.py 83.33% 2 Missing :warning:
omnisafe/utils/config.py 87.50% 1 Missing :warning:
Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #286 +/- ## ========================================== - Coverage 96.84% 96.70% -0.14% ========================================== Files 138 140 +2 Lines 7000 7130 +130 ========================================== + Hits 6779 6895 +116 - Misses 221 235 +14 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.