首页 > 其他分享 >OpenAI Gym custom environment: Discrete observation space with real values

OpenAI Gym custom environment: Discrete observation space with real values

时间:2024-09-02 10:51:17浏览次数:6  
标签:real Box observation space self Discrete values np

题意:OpenAI Gym 自定义环境:具有实数值的离散观测空间

问题背景:

I would like to create custom openai gym environment that has discrete state space, but with float values. To be more precise, it should be a range of values with 0.25 step: 10.0, 10.25, 10.5, 10.75, 11.0, ..., 19.75, 20.0

我想创建一个自定义的 OpenAI Gym 环境,该环境具有离散的状态空间,但使用浮点值。更具体地说,它应该是一个步长为 0.25 的数值范围:10.0, 10.25, 10.5, 10.75, 11.0, ..., 19.75, 20.0。

Is there a way to do this in openai gym custom environment, using spaces like Discrete, Box, MultiDiscrete or some others? Discrete requires an integer, and Box doesn't seem to have some kind of a step parameter.

在 OpenAI Gym 的自定义环境中,是否有办法使用像 `Discrete`、`Box`、`MultiDiscrete` 等空间来实现这一点?`Discrete` 需要整数,而 `Box` 似乎没有步长参数。

问题解决:

You could implement your own space using np.linspace (considering e.g. spaces.Box as a guideline):

你可以使用 `np.linspace` 实现自己的空间(可以参考 `spaces.Box` 作为指导):

from gym.spaces.space import Space
import numpy as np

class Incremental(Space):
    def __init__(self, start, stop, num, **kwargs):
        self.values = np.linspace(start, stop, num, **kwargs)
        super().__init__(self.values.shape, self.values.dtype)

    def sample(self):
        return np.random.choice(self.values)

    def contains(self, x):
        return x in self.values

space = Incremental(10, 20, 41)

标签:real,Box,observation,space,self,Discrete,values,np
From: https://blog.csdn.net/suiusoar/article/details/141813628

相关文章

  • 【#第三期实战营闯关作业 ## MindSearch在 Hugging FaceSpace的部署】
    把MindSearch部署到GithubCodespace后,下一步就是上传到HuggingFaceSpace,以下是记录了实操的过程及截图:打开https://huggingface.co/spaces,并点击CreatenewSpace,如下图所示:在输入Spacename并选择License后,选择配置如下面截图所示:3进入Settings,配置硅基......
  • Lecture 13 Real-time Ray Tracing 2
    Lecture13Real-TimeRayTracing2Implementingaspatialfilter这里想做的是低通滤波移除高频信号会不会丢失高频中的信息?噪声不一定只在高频中集中在频域这些filtering可以应用在PCSS、SSR上的降噪用$$\widetildeC$$表示有noise的图像\[K$$表示滤波核kernel,比......
  • Lecture 08 & 09 Real-time Global Illumination (screen space)
    Lecture08Real-timeGlobalIllumination(screenspace)GIinScreenSpace只使用屏幕空间的信息换句话说,在现在的渲染结果上做后处理ScreenSpaceAmbientOcclusion(SSAO)为什么要环境光遮蔽容易实现增强场景中的物体和物体间的相对位置(立体感)什么是SSAOAO的......
  • Lecture 10 & 11 Real-time Physically-based Materials (surface model)
    Lecture10Real-timePhysically-basedMaterials(surfacemodelsandcont.)PBRandPBRMaterialsPhysically-BasedRendering(PBR)基于物理的渲染渲染内的任何事都应该是PBR的材质、光照、相机、光线传播等等不限于材质,但常常指材质PBRmaterialsinRTR......
  • Lecture 12 Real-time Ray Tracing
    Lecture12Real-TimeRayTracingBasicideasampleperpixelPPS1SPPpathtracing=$$\downarrow$$camera出发打到求出第一个交点(像素上看到的点),这一步是primaryray(工业上实际用rasterization)工业上这一步有一个技巧将这一步改为光栅化因为每个像素都要从camera出......
  • Lecture 04 Real-time Shadows 2
    Lecture04Real-timeShadows2PCFandPCSSPCF背后的数学知识Filter/convolution:如果对某个函数\(f\)做卷积,可以用\([\omega*f](p)=\underset{q\in\Nu(p)}{\sum}w(p,q)f(q)\)比如PCSS中对某一点q周围区域做卷积求visibility\(V(x)=\underset{q\in\Nu(p)}{\sum}w......
  • Lecture 05 Real-time Environment Mapping
    Lecture05Real-timeEnvironmentMappingRecap:EnvironmentLighting一张表示了来自四面八方的无穷远处光(distancelighting)的图片Sphericalmapvs.cubemapShadingfromenvironmentlighing非正式地命名为Image-BasedLighting(IBL)\[L_o(p,\omega_o)=\int_{\Om......
  • Lecture 06 Real-time Environment Mapping (Precomputed Radiance Transfer)
    Lecture06Real-timeEnvironmentMapping(PrecomputedRadianceTransfer)Shadowfromenvironmentlighting通常情况下要实时渲染非常困难在不同观察方向上Asamany-lightproblem:CostofShadowMapislinearlyto#lightAsasamplingproblem:Visibility项V会......
  • Lecture 03 Real-time Shadows 1
    Real-timeShadows1Recap:shadowmappingShadowMapping2-PassAlgorithmThelightpassgeneratestheshadowmapthecamerapassusestheshadowmapAnimage-spacealgorithm好处:无需场景中的几何信息坏处:导致自遮挡和走样问题PassPass1:Renderfrom......
  • 【Qt】Spacer
    Spacer在使用布局管理的时候,如果需要在控件之间添加一段空白,就可以使用QSpacerItem来表示。核心属性属性说明width宽度height⾼度hData⽔平⽅向的sizePolicyQSizePolicy::Ignored:忽略控件的尺⼨,不对布局产⽣影响。QSizePolicy::Minimum:......