#ifndef FPAGAME_HPP
#define FPAGAME_HPP
#include "bce.hpp"
#include "bceabstractgame.hpp"
{
protected:
int numValues;
double fee;
double reservePrice;
double highbid;
double lowbid;
bool exAnteFee;
public:
FPAGame(int na, int nv, double _fee,
double _reservePrice,double _highbid,
bool _exAnteFee)
fee(_fee), highbid(_highbid),
lowbid(0.0), reservePrice(_reservePrice),
exAnteFee(_exAnteFee)
{
}
int getNumValues() const {return numValues;}
void stateToPrivateValues(int state, vector<int> &values) const
{
values.resize(2);
values[0]=state%numValues;
state-=values[0];
values[1]=state/numValues;
}
double prior (
int state,
const vector<int> &types)
const
{
vector<int> values;
stateToPrivateValues(state,values);
double v0 = static_cast<double>(values[0]+1)/numValues;
double v1 = static_cast<double>(values[1]+1)/numValues;
double incr = 1.0/numValues;
return distribution.
PDF(v0,v1,incr);
}
double objective(
int state,
const vector<int> &actions,
int objectiveIndex) const
{
vector<int> values(2,0);
stateToPrivateValues(state,values);
double obj = 0;
double winbid = lowbid + ((actions[0]>actions[1]? actions[0]: actions[1])-1.0)
* (highbid-lowbid) / (numActions[0]-2.0);
if (winbid < reservePrice)
return 0.0;
if (objectiveIndex < 2)
{
int player = objectiveIndex;
if (actions[player]>actions[1-player]
|| (actions[player]==actions[1-player]
&& values[player]>values[1-player]))
obj = ((1.0*values[player])/(numValues-1.0)-winbid);
else if (actions[player]==actions[1-player]
&& values[player]==values[1-player])
obj = ((1.0*values[player])/(numValues-1.0)-winbid)/2.0;
obj -= (actions[player]>0? fee : 0.0);
}
else if (objectiveIndex==2)
{
obj = winbid;
obj += (actions[0]>0? fee : 0.0);
obj += (actions[1]>0? fee : 0.0);
}
return obj;
}
int type, int player) const
{
return !(exAnteFee
&& action>0
&& dev == 0);
}
};
#endif
The base class for games of incomplete information.
Definition: bceabstractgame.hpp:52
virtual bool feasibleDeviation(int action, int dev, int type, int player) const
Check if deviation is feasible.
Definition: bceabstractgame.hpp:178
bool setNumPrivateStates(const vector< int > &_numPrivateStates)
Definition: bceabstractgame.hpp:187
virtual double objective(int state, const vector< int > &actions, int obj) const =0
Objective function.
virtual double prior(int state, const vector< int > &types) const =0
Prior over state and types.
BCEAbstractGame()
Default constructor.
Definition: bceabstractgame.cpp:25
Weighted sum of distributions.
Definition: bcedistr.hpp:71
bool push_back(BCEDistr *newDistr, double newWeight)
Add a new distribution to the array.
Definition: bcedistr.hpp:97
double PDF(double v0, double incr0, double v1, double incr1) const
Discretized PDF for the BCEDistr.
Definition: bcedistr.hpp:47
CDF is of the form .
Definition: bcedistr.hpp:352