Program Listing for File games.h
↰ Return to documentation for file (include/games/games.h
)
/* #############################################
* This file is part of
* ZERO
*
* Copyright (c) 2020
* Released under the Creative Commons
* CC BY-NC-SA 4.0 License
*
* Find out more at
* https://github.com/ds4dm/ZERO
* #############################################*/
#pragma once
#include "zero.h"
#include <armadillo>
#include <iostream>
#include <memory>
#include <set>
#include <string>
namespace Game {
template <typename DataObjectType> class AbstractGame {
protected:
std::chrono::high_resolution_clock::time_point InitTime;
ZEROStatistics<DataObjectType> Stats = ZEROStatistics<DataObjectType>(DataObjectType());
;
GRBEnv * Env{};
unsigned int NumVariables{0};
unsigned int NumPlayers{0};
bool NashEquilibrium{false};
public:
AbstractGame(GRBEnv *env) : Env{env} {};
AbstractGame() = default;
AbstractGame(AbstractGame &) = delete;
~AbstractGame() = default;
virtual void findNashEq() = 0;
virtual bool isSolved(double tol = 1e-5)
const = 0;
virtual bool
isPureStrategy(double tol = 1e-5) const = 0;
ZEROStatistics<DataObjectType> getStatistics() const { return this->Stats; }
void setNumThreads(unsigned int t) {
this->Stats.AlgorithmData.Threads.set(t);
this->Env->set(GRB_IntParam_Threads, t);
}
void setRandomSeed(unsigned int t) { this->Stats.AlgorithmData.RandomSeed.set(t); }
void setPureNashEquilibrium(bool val) { this->Stats.AlgorithmData.PureNashEquilibrium = val; }
void setDeviationTolerance(double val) {
this->Stats.AlgorithmData.DeviationTolerance.set(val);
}
void setTimeLimit(double val) { this->Stats.AlgorithmData.TimeLimit.set(val); }
int getNumVar() const noexcept { return this->NumVariables; }
int getNumPlayers() const noexcept { return this->NumPlayers; }
};
} // namespace Game
#include "games/epec.h"
#include "games/ipg.h"
#include "games/nash.h"