#ifndef DUOPOLY_HPP
#define DUOPOLY_HPP
#include "bce.hpp"
{
private:
int numValues;
double entryCost;
double margCost;
public:
Duopoly(int na, int nv, int no, double _entryCost, double _margCost)
{
}
int getNumValues(){return numValues;}
void stateToValues(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
{
return 1.0/(1.0*numValues*numValues);
}
double objective(
int state,
const vector<int> &actions,
int objectiveIndex)
const
{
vector<int> values(2,0);
stateToValues(state,values);
double valuations[2], prices[2], surpluses[2], entryCosts[2];
valuations[0] = 1.0*values[0]/(numValues-1.0);
valuations[1] = 1.0*values[1]/(numValues-1.0);
prices[0] = 1.0*actions[0]/(numActions[0]-1.0);
prices[1] = 1.0*actions[1]/(numActions[1]-1.0);
surpluses[0] = valuations[0] - prices[0];
surpluses[1] = valuations[1] - prices[1];
entryCosts[0] = (actions[0]>0? entryCost : 0.0);
entryCosts[1] = (actions[1]>0? entryCost : 0.0);
if (objectiveIndex==0)
{
if (surpluses[0]>=0)
{
if (surpluses[0]>surpluses[1])
return (prices[0]-margCost-entryCosts[0]);
else if (surpluses[0] == surpluses[1])
return ((prices[0]-margCost)/2-entryCosts[0]);
}
else
return -entryCosts[0];
}
else if (objectiveIndex==1)
{
if (surpluses[1]>=0)
{
if (surpluses[1]>surpluses[0])
return (prices[1]-margCost-entryCosts[1]);
else if (surpluses[1] == surpluses[0])
return ((prices[1]-margCost)/2-entryCosts[1]);
}
else
return -entryCosts[1];
}
else if (objectiveIndex==2)
{
return (max(0.0, max(surpluses[0],surpluses[1])));
}
else if (objectiveIndex==3)
{
if (surpluses[0]>max(0.0,surpluses[1]))
return (valuations[0]-margCost);
else if (surpluses[1]>max(0.0,surpluses[0]))
return (valuations[1]-margCost);
else if (surpluses[0]==surpluses[1]
&& surpluses[0] >= 0)
return (0.5 * valuations[0] + 0.5 * valuations[1] - margCost);
}
return 0;
}
};
#endif
The base class for games of incomplete information.
Definition: bceabstractgame.hpp:52
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