⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 cacrobotmodel.h

📁 强化学习算法(R-Learning)难得的珍贵资料
💻 H
字号:
// Copyright (C) 2003
// Gerhard Neumann (gerhard@igi.tu-graz.ac.at)

//                
// This file is part of RL Toolbox.
// http://www.igi.tugraz.at/ril_toolbox
//
// All rights reserved.
// 
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// 1. Redistributions of source code must retain the above copyright
//    notice, this list of conditions and the following disclaimer.
// 2. Redistributions in binary form must reproduce the above copyright
//    notice, this list of conditions and the following disclaimer in the
//    documentation and/or other materials provided with the distribution.
// 3. The name of the author may not be used to endorse or promote products
//    derived from this software without specific prior written permission.
// 
// THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
// IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
// IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
// NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
// THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

#ifndef __CACROBOT_H
#define __CACROBOT_H

#include "cqtconfig.h"

#include "ctransitionfunction.h"
#include "crewardfunction.h"
#include "ril_debug.h"

#ifdef RL_TOOLBOX_USE_QT
#include "cqtmodelvisualizer.h"
#endif

class CAcroBotModel : public CDynamicLinearActionContinuousTimeModel
{
protected:
	virtual void doSimulationStep(CState *state, rlt_real timestep, CAction *action, CActionData *data);

public:
	rlt_real uMax;
	rlt_real g;
	rlt_real mass1;
	rlt_real mass2;
	rlt_real length1;
	rlt_real length2;
	rlt_real mu_1; 
	rlt_real mu_2; 

	CAcroBotModel(rlt_real dt, rlt_real uMax = 2, rlt_real length1 = 0.5, rlt_real length2 = 0.5, rlt_real mass1 = 1.0, rlt_real mass2 = 1.0, rlt_real mu_1 = 0.05, rlt_real mu_2 = 0.05, rlt_real g = 9.8);
	~CAcroBotModel();

	virtual CMyMatrix *getB(CState *state);
	virtual CMyVector *getA(CState *state);


	virtual bool isFailedState(CState *state);

	virtual void getResetState(CState *state);
};

class CAcroBotModelSutton : public CAcroBotModel
{
protected:

public:

	rlt_real I1; 
	rlt_real I2; 

	CAcroBotModelSutton(rlt_real dt, rlt_real uMax = 2, rlt_real length1 = 1.0, rlt_real length2 = 1.0, rlt_real mass1 = 1.0, rlt_real mass2 = 1.0, rlt_real I1 = 1.0, rlt_real I2 = 1.0, rlt_real g = 9.8);
	~CAcroBotModelSutton();

	virtual CMyMatrix *getB(CState *state);
	virtual CMyVector *getA(CState *state);

};


class CAcroBotRewardFunction : public CStateReward
{
protected:
	CAcroBotModel *model;
public:
	CAcroBotRewardFunction(CAcroBotModel *model, rlt_real segmentFactor = 0.5);
	rlt_real segmentFactor;
	bool useHeighPeak;

	rlt_real power;

	virtual rlt_real getStateReward(CState *state);
	virtual void getInputDerivation(CState *modelState, CMyVector *targetState);

};

class CAcroBotHeightRewardFunction : public CStateReward
{
protected:
	CAcroBotModel *model;
	bool useHeighPeak;
public:
	CAcroBotHeightRewardFunction(CAcroBotModel *model);

	virtual rlt_real getStateReward(CState *state);
	virtual void getInputDerivation(CState *modelState, CMyVector *targetState);

};

class CAcroBotVelocityRewardFunction : public CStateReward
{
protected:
	CAcroBotModel *model;
public:
	bool invertVelocity;

	CAcroBotVelocityRewardFunction(CAcroBotModel *model);

	virtual rlt_real getStateReward(CState *state);
	virtual void getInputDerivation(CState *modelState, CMyVector *targetState);
};

class CAcroBotExpRewardFunction : public CStateReward
{
protected:
	CAcroBotModel *model;
public:
	rlt_real expFactor;

	CAcroBotExpRewardFunction(CAcroBotModel *model, rlt_real expFactor = 10.0);

	virtual rlt_real getStateReward(CState *state);
	virtual void getInputDerivation(CState *modelState, CMyVector *targetState);
};

#ifdef RL_TOOLBOX_USE_QT

class CQTAcroBotVisualizer : public CQTModelVisualizer
{
protected:
	rlt_real phi1;
	rlt_real dphi1;
	rlt_real phi2;
	rlt_real dphi2;

	CAcroBotModel *acroModel;

	virtual void doDrawState( QPainter *painter);

public:
	CQTAcroBotVisualizer( CAcroBotModel *acroModel, QWidget *parent=0, const char *name=0);

	virtual void newDrawState(CStateCollection *state);
};

#endif

#endif

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -