#include "MpUtil.h" #include "UncoveredSet.cpp" /* Find the Uncovered Set and mixed strategy equilibrium to a two-dimensional two-candidate model of Downsian competition using a finite grid to approximate the strategy space. */ int main() { long RandomSeed = -197347; const int N = 101; // Number of Voters const int J = Sqr(81); // Number of Locations Timer tm; /* Generate Voter Ideal Points from Triangle Distribution */ Print("1: Generating the Voter Ideal Points"); tm.Start(); Vector q1(N); // Ideal points of voters, coordiante 1 Vector q2(N); // Ideal points of voters, coordinate 2 for(int n=0; n q1[n]) Swap(q1(n),q2(n)); } tm.Stop(); Print(""); /* Create a Finite Grid */ Print("2: Creating the Grid"); tm.Start(); double x1low = 0.0; double x1high = 1.0; double x2low = 0.0; double x2high = 1.0; Vector x1(J); // Location, Coordinate 1 Vector x2(J); // Location, Coordinate 2 int Curr = 0; for(int j=0; j A(J,J); cout << "Progess (out of " << J << "):\n"; for(int j=0; j N) A(j,k) = 1; if(vcurr < N) A(j,k) = -1; if(vcurr == N) A(j,k) = 0; } } tm.Stop(); Print(""); /* Compute the Uncovered Set */ Print("4: Computing the Uncovered Set"); tm.Start(); Vector UC(J); UncoveredSet(A,UC); Print("UC",UC); tm.Stop(); Print(""); /* Compute the Mixed Strategy Equilibrium */ Print("5: Finding the Mixed Strategy Equilibrium"); Stack UCStack(J); for(int j=0; j AUC(NumberUncovered,NumberUncovered); for(int i=0; i c(NumberUncovered+1); for(int j=0; j Ae(1,NumberUncovered+1); for(int j=0; j be(1); be[0] = 1.0; Matrix An(NumberUncovered,NumberUncovered+1); for(int i=0; i bn(NumberUncovered); for(int j=0; j lb(NumberUncovered+1,0.0); Vector ub(NumberUncovered+1,Inf); SymmetricMatrix Q(NumberUncovered+1,Zero); MinQuadProg qp(c,Q,Ae,be,An,bn,lb,ub); qp.Solve(); Stack MSEStack(J); for(int j=0; j 0.0000001) MSEStack.Push(UCStack(j)); Vector MSE(J,0); for(int i=0; i