The programs for our paper "Profit Maximization, Industry Structure, and Competition: A critique of neoclassical theory" are linked here. The models have been built in the programming language within Mathcad, and in Objective C in the multi-agent simulation environment EcoLab. Currently only PDF versions of the Mathad programs are linked here; the Ecolab programs will be listed shortly (they require linking to the EcoLab environment to be run). Any programmer should be able to implement a version of the programs very easily after reading the Mathcad code.
Mathcad is general purpose mathematical program with a functional programming language built-in. It's short on features compared to standard programming languages, but integrates well with the overall mathematical environment and allows for very compact code. Below are the links to the programs used for each Figure in the paper (two versions were submitted, one with graphs produced within Mathcad and one with graphs produced within Matlab; the latter was done to generate EPS graphics files; the graphics shown here are from Mathcad itself). Following this, the code for Figure 2 is shown and explained.
Figure 1
Figure 2
Figure 3
I'll focus on the program for
Figure 2 since that is the core program in the paper. The Mathcad document
firstly specifies the linear price function
and the cost functions for the
individual firm: total cost
and
marginal cost
. The functions are chosen so
that the marginal costs will be comparable for different industry structures
(numbers of firms n). Economists seem unaware that, in general, costs
will differ for different industry structures, and their customary use of a
single "supply curve" to compare the output of a single industry firm
("monopoly") to a multi-firm ("competitive") industry actually puts strict
conditions on the nature of cost functions. Our formula applies the most general
of those restrictions.
Given these price and cost functions, the document next calculates the predicted optimal (profit-maximizing) output level given the conventional economic formula qC ("equate marginal revenue to marginal cost"):

and our correct profit-maximizing formula qK :

These two calculations are compared to the outcome of simulations of "instrumental profit maximizers" as explained in the paper. The program is:

Allocate an array variable x: this increments over the number of runs with differing dispersal values.
Loop over dispersal values
For the number of Monte Carlo runs specified,
Set a random number generator
Allocate an initial output per firm as a random uniform distribution between the Keen prediction and the higher standard neoclassical ("Cournot") prediction
Calculate a market price based on the sum of the outputs of individual firms
Decide an amount by which the output of each firm will be varied. The mean variation is zero; variation around this mean is a standard deviation of from 1% of the Cournot prediction (when i=0) to disp per cent, in steps of dispsteps as given in the arguments to the program. Thus a value for disp of 20 with dispsteps of 1 will increment the dispersal from 1% of the Cournot predicted level to 20% in steps of 1%.
For the number of runs specified for each simulation
Add the variation amount to the output of each firm.
Calculate the new market price
Each firm then works out whether the change in output has increased or decreased profit. If profit has risen, they keep changing by the same magnitude and in the same direction; if it has fallen, they change the sign but not the magnitude of their dq. The bar operator over this line indicates that the operations are to be performed across each row of the relevant vectors; it is a shorthand way of writing a FOR loop that loops over the number of firms in the simulation.
At the end of runs steps, the values of the last 4 aggregate outputs are stored.
(The next 5 lines allocate various aspects of the results of the simulation to a row in the matrix F: the dispersal of dq as a percentage of the Cournot prediction, the Cournot prediction for the market output with different numbers of firms, the Keen prediction, the average of the Monte Carlo simulations, and the standard deviation.)
The temporary variable Qend is reset to zero.
This is a programming tracing line
The column counter for F is incremented
F is returned by the program