📄 cmulticontroller.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 CMULTICONTROLLER_H
#define CMULTICONTROLLER_H
#include "cagentcontroller.h"
#include "caction.h"
#include "cactionstatistics.h"
#include "ril_debug.h"
/// baseclass for all multicontroller policies
class CMultiControllerPolicy
{
public:
CMultiControllerPolicy();
virtual ~CMultiControllerPolicy();
/// gets a list of possible actionstatistics and returns the the chosen one
virtual CActionStatistics *getNextAction(std::list<CActionStatistics *> *actionstats) = 0;
};
/// multicontroller policy, chooses a random action
class CMultiControllerRandomPolicy : public CMultiControllerPolicy
{
public:
CMultiControllerRandomPolicy();
virtual ~CMultiControllerRandomPolicy();
virtual CActionStatistics *getNextAction(std::list<CActionStatistics *> *actionstats);
};
/// multicontroller policy, chooses the best action (smallest one, calculated with @see CactionStatisticsComparator
class CMultiControllerGreedyPolicy :public CMultiControllerPolicy
{
private:
CActionStatisticsComparator *comp;
public:
CMultiControllerGreedyPolicy(CActionStatisticsComparator *comp);
void setComparator(CActionStatisticsComparator *comp) {this->comp = comp;};
CActionStatisticsComparator *getComparator() {return this->comp;};
virtual ~CMultiControllerGreedyPolicy();
virtual CActionStatistics *getNextAction(std::list<CActionStatistics *> *actionstats);
};
/// multicontroller: for deterministic switching between different agent(statistic)controllers
/**
the multicontroller offers, together with @see CActionStatistics a very interesting
way to include potentially incomplete prior knowledge (in form of a handwritten agent controller)
into a learning problem. Use the controller and the policy of the learning algorithm as input
for the multicontroller and set the controllers actionstatistics.superior to 0, .equal to 1
and .probability to 0.5. During the first view visits of a special state the
actionstatistics.probability of the policy will be ~ (1 / #actions) and the controller action will
be selected. By the time the probability of the policy action will grow bigger until the policy
action will be selected and the learning algorithm takes over controll
*/
class CMultiController: public CAgentStatisticController
{
protected:
std::list<std::pair<CAgentStatisticController *, CActionStatistics *> *> *controllers;
CMultiControllerPolicy* policy;
public:
CMultiController(CActionSet *actions, CMultiControllerPolicy* policy);
virtual ~CMultiController();
/// add an inputcontroller
void addController(CAgentStatisticController *controller);
/// remove an inputcontroller
void removeController(CAgentStatisticController *controller);
/// get the next action
virtual CAction* getNextAction(CStateCollection *state, CActionDataSet *dataset, CActionStatistics *stat);
};
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -