After the Enlargement: Trends and Threats in the European Union Decision - Making
Perspectives. Review of International Affairs (1/2012), pp. 33 - 57
Wolfram Mathematica 8.0
Computer simulations source code
Uploaded : 31 Jan 2013
Note that this txt file is ot formated properly, it is only intended for control. For actual simulations, please use the Wolfram Mathematica file.
//////////////////////////////////////////////////////////
Certain principles should be followed in using this code :
1. To obtain the results, the individual parts of the code need to be run \
in the given order.
Each part of the code (indicated by sections with bold titles) needs to be \
run.
2. Throughout the code, lists ending with " 2 " refer to the benign model \
of formal politics, while lists without " 2 " refer to the informal politics \
model.
3. The main loop is built around a numerical model, where for each point of \
the political space a set of calculations and decisions is simulated.
In particular, for each individual point it is determined whether it would \
be acceptable for enough states (given their utility functions) and hence \
adopted, and consequently what would the Commission' s (agenda setter' s) \
utility from making such a proposal be. This is done for two model -
informal politics model, and the bening formal politics model, as discussed \
in the article.
Such calculations are done for each of the points in the space.
Subsequently, the results across for all the points are aggregated.
Finally, the entire process is repeated X -
times (in the article 200 times) with random assignments of various \
parameters of the model.
4. Additional statistics can be easily generated,
following the Wolfram Mathematica Documentation Center at :
http : // reference.wolfram.com/mathematica/guide/Mathematica.html.
5. Please contact me at parizekm@
fsv.cuni.cz if you have problems with running the simulation or if you \
have questions or suggestions regarding the source code.
//////////////////////////////////////////////////////////
Setup of the key parameters, including number of iterations
(*Qualified majority voting quota (QMV) per cent quota, default the true \
value of 0.74*)
q = 0.74;
(*Number of the member states. Default 27.*)
n = 27;
(*Number of points defining the space. Dramatically influences the \
computation time. Default 32x32=1024.*)
(*x-iterations*)
s = 32 ;
(*y-iterations*)
t = 32 ;
(*Transaction costs. Default 0.1.*)
tau = 0.1;
(*Side-payments willingness. How much are the states willing to engage in \
sidepayments? The higher spw is, the more will be MSs willing to side-pay \
others for providing support; for spw=0 side-payments cannot be made, for \
spw=1 they are willing to provide all their surplus in side-payments. Default \
0.8.*)
spw = 0.8;
(*Weight of dimensions. Takes values between 0 and 1 where 1 assigns all \
weight only to x (eu dimension) and 0 only to y (substantive dimension).*)
w = 0.5;
(*How much random do we want the assignment of ideal points on X to be. For \
r=0 the positionson x is given by i or by some constant, for r=1 it is \
completely random, either from normal or uniform distribution.*)
rx = 0;
ry = 1;
(*The main do-loop iterations. Note that with 200 iteration the simulation \
may take, depending on the computer hardware, a substantial amount of time.*)
iterations = 200;
//////////////////////////////////////////////////////////
Setting all variables to zero or to empty lists
(*Lists referring to the informal politics model*)
(*************************************************)
mspositions = {};(*this will be the overall vector for saving MSs' positions \
over many iterations*)
msydistance = {};
msxdistance = {};
msydistancevector = {};
msxdistancevector = {};
msxpositions = {};
optimalvector = {};(*this will be the overall vector for saving Commission's \
optimally chosen policies*)
(*xycompayoffflatiterated={{},{},{}};*)
optimaliterated = {};
xycompayoffflatiterated = 0;
xycompayoffflatiteratedmean = 0;
(*Lists referring to the formal benign politics model*)
(******************************************************)
msydistance2 = {};
msxdistance2 = {};
msydistancevector2 = {};
msxdistancevector2 = {};
optimalvector2 = {};
optimaliterated2 = {};
xycompayoffflatiterated2 = 0;
xycompayoffflatiteratedmean2 = 0;
//////////////////////////////////////////////////////////
The main loop, with several components and levels
Do[
(*Creation of the actors' ideal points and related calculations.*)
(****************************************************************)
i = 1;
xyi = {};
xyivector = {};
(*loop for creation of positions of n member states.*)
While[i < (n + 1),
xi = List[(1 - rx) N[(i - 1)/(n - 1)] +
rx RandomVariate[UniformDistribution[]]];
yi = List[(1 - ry) N[(i - 1)/(n - 1)] +
ry RandomVariate[UniformDistribution[]]];
xyi = Flatten[List[i, Join[xi, yi]]];
xyivector = Append[xyivector, xyi];
i++];
(*Vector of triplets with {i, xi, yi} positions for each actor i.*)
mspositions = Append[mspositions, xyivector];
(*To get explicitly just the x coordinates, useful later for analysis.*)
msxpositions = Flatten[Append[msxpositions, xyivector[[All, 2]]]];
(*The mean of y positions and therefore the no-agreement,
or the reversion point default*)
ysq = Mean[xyivector[[All, 3]]];
(*The Commission's optimization scheme, with the nested states' decision-
scheme*)
(*The programme checks each of the s times t points in the space to see the \
Commission's utility. This is computationally very demanding,
it is a brute force solution.*)
(**************************************)
(*Setup of the lists*)
i = 1;
xycompayoff = {};
xycompayoff2 = {};
xycompayoffflat = {};
xycompayoffflat2 = {};
x = 0;
(*The loop that runs through all points on the horizontal eu (x) dimension.*)
While[x < s + 1,
ycompayoff = {};
ycompayoff2 = {};
(*The loop that runs, for each point on the horizontal eu (x) dimension,
through all points on the vertical sc (y) dimension.*)
y = 0;
While[y < t + 1,
(*Here will start the nested decision-making scheme of the states*)
(*First set all the values to default before running the individual MS's \
calculation*)
(**************************************)
i = 1;
stm = 0;
stmi = 0;
msstrategiesvector = {};
mspayoffsvector = {};
lacking = 0;
lackinginteger = 0;
lackingguys = {};
lackingguyssorted = {};
tobesidepaid = 0;
totalsidepayments = 0;
supportguyssurplus = {};
totalsurplus = 0;
totalsubplus = 0;
ycp = {};
ycp2 = {};
(*The loop of the nested decision-making scheme of the states*)
While[i < n + 1,
(*Utility of the member states from the given combination of x and y,
in this specific higher-level loop (see above). So,
again this will be calculated over all the s times t iterations for each \
individual point in the space*)
(*note that all the ws indicate the weights of the dimensions (see first \
section of this code)*)
um[x_,
y_] := -((2 w (((x/s) - xyivector[[i, 2]])^2) + (2 -
2 w) ( ((y/t) - xyivector[[i, 3]])^2))^(1/2));
(*Utility of the member state from the reversion point (sq as status \
quo)*)
umsq[x_,
y_] := -((2 w ((0 - xyivector[[i, 2]])^2 ) + (2 -
2 w) ((ysq - xyivector[[i, 3]])^2))^(1/2));
(*In this specific point (x,y), num gives the net utility, i.e.
positive or negative difference between the proposal at x,
y and the reversion point,
minus the transaction costs tau that were set arbitrarily at the \
beginning*)
num[x_, y_] := (um[x, y] - umsq[x, y]) - tau;
(*Payoff of the member state from this combination of x and y*)
msipayoff = List[i, num[x, y]];
mspayoffsvector = AppendTo[mspayoffsvector, msipayoff];
(*Decision by the state to support or oppose the proposal.
If proposal better than the reversion point, i.e. num>0,
the state supports the proposal.*)
If[num[x, y] >= 0, stmi = 1, stmi = 0];
msstrategiesvector = AppendTo[msstrategiesvector, stmi];
(*Sums support over all states i,
adds 1 for each state that decides to support.*)
If[num[x, y] >= 0, stm = stm + 1, stm = stm];
(*Here ends the decision-making scheme of the states,
and we come back to the Commission.*)
i++];
(*1 The informal politics model*)
(*Here part of the surplus generated by the proposal among the actors can \
be traded among the states,
and thus secure support also from other states that would normally,
withouth the traded side-payments, oppose the proposal.*)
(*******************************************************)
(*stm>= n q is the condition for reaching of the qualified majority quota*)
If[stm >= n q,
lacking = 0,
(*How many states are lacking for reaching of the QMV?*)
lacking = n q - stm];
(*Order the lacking states according to how much they want to change from \
nay to yay*)
lackinginteger = Ceiling[lacking];
lackingguys = Pick[mspayoffsvector, msstrategiesvector, 0];
lackingguyssorted = Sort[lackingguys, #1[[2]] > #2[[2]] &];
(*Identifies how much surplus was generated among the supporters, i.e.
how much can be used for side-payments.*)
supportguyssurplus = Pick[mspayoffsvector, msstrategiesvector, 1];
(*Sum of all the surpluses of the MSs who vote for.
So how much extra surplus gain the proposal would generate among its \
supporters?*)
totalsurplus = Total[supportguyssurplus[[All, 2]]];
(*How much extra "subplus" opposition the proposal generates among its \
opponents?
This indicates how much they will be willing to invest into prevention of \
the pivots from switching to support. This is the opposition to side-
payments from the supporters.*)
totalsubplus = Abs[Total[lackingguys[[All, 2]]]];
(*The decision: if there is more surplus than subplus,
by a sufficient margin,
proposal can be adopted and uc will be the utility of Commission.*)
(*spw is the willingness to provide side-payments, where spw=
1 means that state are willing to trade all their extra gains in side-
payments for support or opposition*)
If[spw totalsurplus >= spw totalsubplus, uc = (x/s), uc = 0];
ycp = List[(x/s), (y/t), uc];
AppendTo[ycompayoff, ycp];
(*2. The formal politics model,
where proposal is adopted simply if n q states like it, no side-
payments are possible. This will be used for comparison at the end.*)
(*******************************************************)
If[stm >= n q, uc2 = (x/s), uc2 = 0];
ycp2 = List[(x/s), (y/t), uc2];
AppendTo[ycompayoff2, ycp2];
(*Here ends the vertical y-
dimension loop for all the points of the political space*)
y++];
AppendTo[xycompayoff, ycompayoff];
AppendTo[xycompayoff2, ycompayoff2];
(*Here ends the horizontal x-
dimension loop for all the points of the political space*)
x++];
(*This gives the commission payoffs for each point of the space,
in ordered triples {x,y,uc}.*)
xycompayoffflat = Partition[Flatten[xycompayoff], 3];
xycompayoffflatiterated = xycompayoffflatiterated + xycompayoffflat;
xycompayoffflat2 = Partition[Flatten[xycompayoff2], 3];
xycompayoffflatiterated2 = xycompayoffflatiterated2 + xycompayoffflat2;
(*From all the points in the space, identify those,
that maximize the Commission's payoffs,
and hence that would identify the point where it will make its proposal.
The median is used, in case there are more maxima.*)
(**********************************)
optimal = {};
optimalmedian = {};
optimal =
Pick[xycompayoffflat, xycompayoffflat[[All, 3]],
Max[xycompayoffflat[[All, 3]]]];
optimalmedian = Median[optimal];
(*The same for the formal politics model, for later comparison.*)
optimal2 = {};
optimalmedian2 = {};
optimal2 =
Pick[xycompayoffflat2, xycompayoffflat2[[All, 3]],
Max[xycompayoffflat2[[All, 3]]]];
optimalmedian2 = Median[optimal2];
(*How far are the states' ideal points from the result,
on each of the axis? For later analysis.*)
(**********************************)
(*Raw distances for each iteration.*)
msydistance = ((xyivector[[All, 3]] - optimalmedian[[2]])^2)^(1/2);
msxdistance = ((xyivector[[All, 2]] - optimalmedian[[1]])^2)^(1/2);
msydistance2 = ((xyivector[[All, 3]] - optimalmedian2[[2]])^2)^(1/2);
msxdistance2 = ((xyivector[[All, 2]] - optimalmedian2[[1]])^2)^(1/2);
(*Vectors of the distances to store results from many iterations.*)
optimalvector = Append[optimalvector, optimalmedian];
msydistancevector = Flatten[Append[msydistancevector, msydistance]];
msxdistancevector = Flatten[Append[msxdistancevector, msxdistance]];
optimalvector2 = Append[optimalvector2, optimalmedian2];
msydistancevector2 = Flatten[Append[msydistancevector2, msydistance2]];
msxdistancevector2 = Flatten[Append[msxdistancevector2, msxdistance2]];
(*Aggregate value across all iterations, for later analysis.*)
msydistancevectormean = Mean[msydistancevector];
msydistancevectormean2 = Mean[msydistancevector2];
(*END of the main loop*)
, {iterations}];
//////////////////////////////////////////////////////////
Additional variables generated
(*Analysis of the member states' positions. Note that the results in the \
simulation are already given by the decisions of the Commission (it located \
its proposals at the points that maximize its utility and that are acceptable \
for enough states.)*)
(*****************************************************************************)
Clear[x, y];
(*Creates a list of pairs with distances of result from ideal points on both \
dimensions.*)
regressdata11 = Partition[Riffle[msxdistancevector, msydistancevector], 2];
(*Creates a list of pairs with ideal point on the eu (x) dimension and \
distance on sc (y) dimension of result from the ideal points.*)
regressdata12 = Partition[Riffle[msxpositions, msydistancevector], 2];
(*Creates a list of pairs with distances of result from ideal points on both \
dimensions, but for the benign formal politics model.*)
regressdata21 = Partition[Riffle[msxdistancevector2, msydistancevector2], 2];
(*Creates a list of pairs with ideal point on the eu (x) dimension and \
distance on sc (y) dimension of result from the ideal points, but for the \
benign formal politics model.*)
regressdata22 = Partition[Riffle[msxpositions, msydistancevector2], 2];
(*A small loop to obtain data for regression across all states' results.*)
(*******************************)
i = 1;
regressdata12individ = {};
regressdata12individagg = {};
While[i < (n + 1),
(*For each state,
this gives the mean value of distance on the vertical sc (y) dimension.
So it gives a pair {ideal point on x,
mean distance on y across all iterations}.
This can then be used to analyze how position on x relates to outcomes \
(payoffs) for states on y.*)
regressdata12individ =
Mean[Pick[regressdata12, regressdata12[[All, 1]], N[(i - 1)/(n - 1)]]];
(*Creates a vector with results from all states.*)
regressdata12individagg =
Flatten[Append[regressdata12individagg, regressdata12individ]];
i++];
(*This divides the long list for all states into pairs, one for each state \
(as in regressdata12individ). So this is what is used in the graphs.*)
regressdata13 = Partition[regressdata12individagg, 2];
(*Another small loop to obtain data for regression across all states' \
results, for the bening formal politics model. Structurall the same as the \
previous piece of code.*)
(*******************************)
i = 1;
regressdata22individ = {};
regressdata22individagg = {};
While[i < (n + 1),
regressdata22individ =
Mean[Pick[regressdata22, regressdata22[[All, 1]], N[(i - 1)/(n - 1)]]];
regressdata22individagg =
Flatten[Append[regressdata22individagg, regressdata22individ]];
i++];
(*This divides the long list for all states into pairs, one for each state \
(as in regressdata12individ). So this is what is used in the graphs.*)
regressdata23 = Partition[regressdata22individagg, 2];
(*Set of linear models form the regression data, to be used later.*)
(*********************************************)
lm11 = LinearModelFit[regressdata11, x, x];
lm12 = LinearModelFit[regressdata12, x, x];
lm13 = LinearModelFit[regressdata13, {1, x}, x];
lm21 = LinearModelFit[regressdata21, x, x];
lm22 = LinearModelFit[regressdata22, x, x];
lm23 = LinearModelFit[regressdata23, {1, x}, x];
(*A non-linear fit model.*)
nlm13 = Fit[regressdata13, {1, x, x^2}, x];
nlm23 = Fit[regressdata23, {1, x, x^2}, x];
(*These are averaged optimal points (i.e. results, the Commission's \
proposals) and the Commission's payoffs from these. *)
(*********************************************)
optimalxiterated = N[Total[optimalvector[[All, 1]]/iterations]];
optimalyiterated = N[Total[optimalvector[[All, 2]]/iterations]];
optimalxyiteratedpayoff = N[Total[optimalvector[[All, 3]]/iterations]];
(*The same for the bening formal politics model.*)
optimalxiterated2 = N[Total[optimalvector2[[All, 1]]/iterations]];
optimalyiterated2 = N[Total[optimalvector2[[All, 2]]/iterations]];
optimalxyiteratedpayoff2 = N[Total[optimalvector2[[All, 3]]/iterations]];
(*This is one number of average utlity of the Commission under the informal \
politics anf formal politics models. The averages are necessary to get a \
smooth picture and a truly aggregate pattern. So this shows the utility of \
Commission on average from making proposals at each individual point in the \
space. For one of the graphs (the 3D one).*)
xycompayoffflatiteratedmean = xycompayoffflatiterated/iterations;
xycompayoffflatiteratedmean2 = xycompayoffflatiterated2/iterations;
//////////////////////////////////////////////////////////
Graphs (and the output)
(*FIGURE 3 in the article. The aggregate pattern of Commission utility across \
all iterations for each point in space.*)
ListPlot3D[xycompayoffflatiteratedmean, Mesh -> Automatic,
PlotRange -> {{0, 1}, {0, 1}, {0, 1}}]
(*FIGURE 4 in the article. Shows location of the resulting points that \
maximize Commission's utility, in a 2D space.*)
Show[ListPlot[optimalvector[[All, 1 ;; 2]], Mesh -> None,
PlotRange -> {{0, 1}, {0, 1}}, AspectRatio -> 1, Frame -> True],
Plot[x = 0.5, {x, 0, 1}] ]
(*FIGURE 5 in the article. Informal politics model. Relationship between \
position of the ideal point on the eu (x) dimension and the resulting \
distance from the ideal point on the sc (y) dimension.*)
Show[ListPlot[regressdata13], Plot[lm13[x], {x, 0, 1}]]
Show[ListPlot[regressdata23], Plot[lm23[x], {x, 0, 1}]]
(*Note that exactly the same graphs can be produced for the formal politics \
model, for comparison. Just change the names of the data from which the \
graphs are generated by adding "2", so e.g. regressdata23, optimalvector2, \
or at the end or xycompayoffflatiteratedmean2.*)