Can I add the condition on State in Reinforcement learning environment?

조회 수: 4 (최근 30일)
Hyoung-Taek Lee
Hyoung-Taek Lee 2022년 1월 31일
답변: Ayush Aniket 2023년 9월 27일
I want to add the condition on the State like below
When the State setting is
obsInfo=rlNumericSpec([4 1],'LowerLimit',[10;10;10;10],'UpperLimit',[100;100;200;200]);
I want to add the below condition
State(1)<State(3) and State(2)<State(4)
Can I do this ?
and additionally,
I have applied below reset function,
function [InitialObservation,LoggedSignal] = reset(this)
LoggedSignal.State=[this.a1 this.a2 this.a3 this.a4];
InitialObservation=LoggedSignal.State;
this.State = LoggedSignal.State;
end
but when the reset is performed, it is not applied to 'LowerLimit' and 'UpperLimit' on State.
How can it be maintained this condition when reset is performed?

답변 (1개)

Ayush Aniket
Ayush Aniket 2023년 9월 27일
As per my understanding you want to impose a custom condition on the states defined in your code. However, the “rlNumericSpec()” function does not have any attributes to apply this condition.
A way to enforce this could be by implementing it in your custom environment logic. You should implement these conditions in custom environment ‘step’ function. If a state does not satisfy these conditions, you can either clip it to the nearest valid state, or define a high penalty in the reward function, or terminate the episode. You can read more about creating custom RL environments by referring to the following link:
For ensuring that the reset function applies the limit, the initial state ‘InitialObservation’ should be within the 'LowerLimit' and 'UpperLimit'. As this is mostly heuristic you can manually enforce this by clipping the value within the limits defined as shown below:
function [InitialObservation,LoggedSignal] = reset(this)
LoggedSignal.State=[this.a1 this.a2 this.a3 this.a4];
% Clip the state to the valid range
LoggedSignal.State = max([10;10;10;10], min([100;100;200;200], LoggedSignal.State));
InitialObservation=LoggedSignal.State;
this.State = LoggedSignal.State;
end
This will ensure that after the reset, the initial state is within the limits. For reading more about defining custom reset functions, you can refer to the following link:
Hope it helps.

카테고리

Help CenterFile Exchange에서 Reinforcement Learning에 대해 자세히 알아보기

제품


릴리스

R2021a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by