rating/featureSet.h
Go to the documentation of this file.
/* featureSet.h
*/
#ifndef OSL_FEATURESET_H
#define OSL_FEATURESET_H
#include "osl/rating/range.h"
#include "osl/rating/ratedMoveVector.h"
#include "osl/container/moveLogProbVector.h"
#include "osl/numEffectState.h"
#include <boost/ptr_container/ptr_vector.hpp>
#include <vector>
#include <string>
#include <iosfwd>
namespace osl
{
namespace stat
{
class Average;
class Variance;
}
namespace rating
{
class Group;
class Feature;
class RatingEnv;
class CheckmateIfCaptureGroup;
class CaptureGroup;
class SendOffGroup;
class FeatureSet
{
// noncopyable
FeatureSet(const FeatureSet&) = delete;
FeatureSet& operator=(const FeatureSet&) = delete;
// range は Groupのメンバーにした方が綺麗な気も
boost::ptr_vector<Group> groups;
std::vector<char> effective_in_check;
std::vector<Feature*> features; // acquaintance
std::vector<range_t> ranges;
std::vector<double> weights;
std::vector<int> weightslog10;
int capture_group, checkmate_if_capture_group, sendoff_group;
std::vector<char> normal_groups;
mutable std::vector<CArray<stat::Average,8> > frequency;
mutable std::vector<CArray<stat::Variance,8> > variance_match;
mutable std::vector<stat::Variance> variance_all;
struct Statistics;
std::vector<Statistics> statistics;
public:
FeatureSet();
virtual ~FeatureSet();
bool tryLoad(const std::string& input_directory);
void setWeight(size_t feature_id, const double& value);
const Group& group(size_t group_id) const { return groups[group_id]; }
bool effectiveInCheck(size_t group_id) const { return effective_in_check[group_id]; }
const Feature& feature(size_t feature_id) const { return *features[feature_id]; }
const range_t& range(size_t group) const { return ranges[group]; }
const double& weight(size_t feature_id) const { return weights[feature_id]; }
size_t groupSize() const { return groups.size(); }
size_t featureSize() const { return features.size(); }
const RatedMove makeRate(const NumEffectState& state, bool in_check,
const RatingEnv& env, Move move) const;
const RatedMove makeRateWithCut(const NumEffectState& state, bool in_check,
const RatingEnv& env, int limit, Move move) const;
const std::string annotate(const NumEffectState& state,
const RatingEnv& env, Move move) const;
void generateRating(const NumEffectState& state, const RatingEnv& env,
int limit, RatedMoveVector& out, bool in_pv_or_all=true) const;
void generateLogProb(const NumEffectState& state, const RatingEnv& env,
int limit, MoveLogProbVector& out, bool in_pv_or_all=true) const;
int logProbTakeBack(const NumEffectState& state, const RatingEnv& env, Move) const;
int logProbSeePlus(const NumEffectState& state, const RatingEnv& env, Move) const;
int logProbKingEscape(const NumEffectState& state, const RatingEnv& env, Move) const;
void showGroup(std::ostream&, size_t group_id) const;
void save(const std::string& output_directory, size_t group_id) const;
void showStatistics(std::ostream&) const;
static void normalize(const RatedMoveVector&, MoveLogProbVector& out);
static std::string defaultDirectory();
protected:
void add(Feature *f);
void add(Group *g);
void add(CaptureGroup *g);
void add(SendOffGroup *g);
void add(CheckmateIfCaptureGroup *g);
void addCommon(Group *g);
void addFinished();
private:
const range_t makeRange(size_t group) const;
int rating(const NumEffectState& state,
const RatingEnv& env, Move move, size_t group_id) const;
};
class StandardFeatureSet : public FeatureSet
{
public:
explicit StandardFeatureSet(bool allow_load_failure=false);
static const StandardFeatureSet& instance();
static bool healthCheck();
};
class CaptureSet : public FeatureSet
{
public:
explicit CaptureSet(bool allow_load_failure=false);
};
class TacticalSet : public FeatureSet
{
public:
explicit TacticalSet(bool allow_load_failure=false);
};
}
}
#endif /* OSL_FEATURESET_H */
// ;;; Local Variables:
// ;;; mode:c++
// ;;; c-basic-offset:2
// ;;; coding:utf-8
// ;;; End:
osl::Move
圧縮していない moveの表現 .
Definition basic_type.h:1052
osl::NumEffectState
利きを持つ局面
Definition numEffectState.h:34
osl::container::MoveLogProbVector
Definition moveLogProbVector.h:14
osl::rating::CaptureGroup
Definition captureGroup.h:14
osl::rating::CaptureSet::CaptureSet
CaptureSet(bool allow_load_failure=false)
Definition featureSet.cc:791
osl::rating::CheckmateIfCaptureGroup
Definition checkmateGroup.h:14
osl::rating::FeatureSet::sendoff_group
int sendoff_group
Definition rating/featureSet.h:43
osl::rating::FeatureSet::featureSize
size_t featureSize() const
Definition rating/featureSet.h:63
osl::rating::FeatureSet::makeRange
const range_t makeRange(size_t group) const
Definition featureSet.cc:66
osl::rating::FeatureSet::capture_group
int capture_group
makeRateで特別扱いのgroup
Definition rating/featureSet.h:43
osl::rating::FeatureSet::group
const Group & group(size_t group_id) const
Definition rating/featureSet.h:57
osl::rating::FeatureSet::showStatistics
void showStatistics(std::ostream &) const
Definition featureSet.cc:655
osl::rating::FeatureSet::FeatureSet
FeatureSet(const FeatureSet &)=delete
osl::rating::FeatureSet::save
void save(const std::string &output_directory, size_t group_id) const
Definition featureSet.cc:649
osl::rating::FeatureSet::FeatureSet
FeatureSet()
Definition featureSet.cc:52
osl::rating::FeatureSet::makeRate
const RatedMove makeRate(const NumEffectState &state, bool in_check, const RatingEnv &env, Move move) const
Definition featureSet.cc:481
osl::rating::FeatureSet::operator=
FeatureSet & operator=(const FeatureSet &)=delete
osl::rating::FeatureSet::addFinished
void addFinished()
Definition featureSet.cc:79
osl::rating::FeatureSet::weightslog10
std::vector< int > weightslog10
Definition rating/featureSet.h:41
osl::rating::FeatureSet::~FeatureSet
virtual ~FeatureSet()
Definition featureSet.cc:58
osl::rating::FeatureSet::effectiveInCheck
bool effectiveInCheck(size_t group_id) const
Definition rating/featureSet.h:58
osl::rating::FeatureSet::addCommon
void addCommon(Group *g)
Definition featureSet.cc:101
osl::rating::FeatureSet::generateLogProb
void generateLogProb(const NumEffectState &state, const RatingEnv &env, int limit, MoveLogProbVector &out, bool in_pv_or_all=true) const
Definition featureSet.cc:389
osl::rating::FeatureSet::variance_all
std::vector< stat::Variance > variance_all
Definition rating/featureSet.h:48
osl::rating::FeatureSet::groups
boost::ptr_vector< Group > groups
Definition rating/featureSet.h:36
osl::rating::FeatureSet::weights
std::vector< double > weights
Definition rating/featureSet.h:40
osl::rating::FeatureSet::checkmate_if_capture_group
int checkmate_if_capture_group
Definition rating/featureSet.h:43
osl::rating::FeatureSet::defaultDirectory
static std::string defaultDirectory()
Definition featureSet.cc:672
osl::rating::FeatureSet::logProbKingEscape
int logProbKingEscape(const NumEffectState &state, const RatingEnv &env, Move) const
Definition featureSet.cc:443
osl::rating::FeatureSet::rating
int rating(const NumEffectState &state, const RatingEnv &env, Move move, size_t group_id) const
Definition featureSet.cc:458
osl::rating::FeatureSet::add
void add(Feature *f)
Definition featureSet.cc:95
osl::rating::FeatureSet::statistics
std::vector< Statistics > statistics
Definition rating/featureSet.h:50
osl::rating::FeatureSet::logProbSeePlus
int logProbSeePlus(const NumEffectState &state, const RatingEnv &env, Move) const
Definition featureSet.cc:431
osl::rating::FeatureSet::features
std::vector< Feature * > features
Definition rating/featureSet.h:38
osl::rating::FeatureSet::makeRateWithCut
const RatedMove makeRateWithCut(const NumEffectState &state, bool in_check, const RatingEnv &env, int limit, Move move) const
Definition featureSet.cc:573
osl::rating::FeatureSet::groupSize
size_t groupSize() const
Definition rating/featureSet.h:62
osl::rating::FeatureSet::effective_in_check
std::vector< char > effective_in_check
Definition rating/featureSet.h:37
osl::rating::FeatureSet::weight
const double & weight(size_t feature_id) const
Definition rating/featureSet.h:61
osl::rating::FeatureSet::range
const range_t & range(size_t group) const
Definition rating/featureSet.h:60
osl::rating::FeatureSet::setWeight
void setWeight(size_t feature_id, const double &value)
Definition featureSet.cc:193
osl::rating::FeatureSet::feature
const Feature & feature(size_t feature_id) const
Definition rating/featureSet.h:59
osl::rating::FeatureSet::variance_match
std::vector< CArray< stat::Variance, 8 > > variance_match
Definition rating/featureSet.h:47
osl::rating::FeatureSet::logProbTakeBack
int logProbTakeBack(const NumEffectState &state, const RatingEnv &env, Move) const
Definition featureSet.cc:420
osl::rating::FeatureSet::tryLoad
bool tryLoad(const std::string &input_directory)
Definition featureSet.cc:143
osl::rating::FeatureSet::annotate
const std::string annotate(const NumEffectState &state, const RatingEnv &env, Move move) const
Definition featureSet.cc:615
osl::rating::FeatureSet::normalize
static void normalize(const RatedMoveVector &, MoveLogProbVector &out)
osl::rating::FeatureSet::frequency
std::vector< CArray< stat::Average, 8 > > frequency
統計測定用
Definition rating/featureSet.h:46
osl::rating::FeatureSet::generateRating
void generateRating(const NumEffectState &state, const RatingEnv &env, int limit, RatedMoveVector &out, bool in_pv_or_all=true) const
Definition featureSet.cc:200
osl::rating::FeatureSet::ranges
std::vector< range_t > ranges
Definition rating/featureSet.h:39
osl::rating::FeatureSet::normal_groups
std::vector< char > normal_groups
Definition rating/featureSet.h:44
osl::rating::FeatureSet::showGroup
void showGroup(std::ostream &, size_t group_id) const
Definition featureSet.cc:642
osl::rating::Feature
Definition rating/feature.h:15
osl::rating::Group
mutually exclusive set of features
Definition group.h:17
osl::rating::RatedMoveVector
Definition ratedMoveVector.h:17
osl::rating::RatedMove
Definition ratedMove.h:14
osl::rating::RatingEnv
Definition ratingEnv.h:16
osl::rating::SendOffGroup
Definition group.h:97
osl::rating::StandardFeatureSet::instance
static const StandardFeatureSet & instance()
Definition featureSet.cc:765
osl::rating::StandardFeatureSet::StandardFeatureSet
StandardFeatureSet(bool allow_load_failure=false)
Definition featureSet.cc:680
osl::rating::StandardFeatureSet::healthCheck
static bool healthCheck()
Definition featureSet.cc:771
osl::rating::TacticalSet::TacticalSet
TacticalSet(bool allow_load_failure=false)
osl::stat::Average
incrementaly maintain average of data sequence
Definition average.h:14
osl::stat::Variance
incrementaly maintain average and variance of data sequence
Definition variance.h:15
moveLogProbVector.h
osl::rating
Definition construct.h:18
osl::rating::range_t
std::pair< int, int > range_t
Definition range.h:10
osl::stat
Definition rating/featureSet.h:18
osl
Definition additionalEffect.h:6
numEffectState.h
range.h
ratedMoveVector.h
osl::rating::FeatureSet::Statistics
Definition featureSet.cc:39