How does one construct a linear (or other mathematical program) to solve a competitive or walrasian equilibrium problem. Specifically, choose prices and quantities over a number of periods, to minimise price times quantities, subject to meeting demand in all periods, no firm operating at a loss and, crucially, no firm making more profit by choosing a different set of quantities. To make the problem interesting, I think it is necessary for there to be a cost of capacity, in addition to a marginal cost of production, for each firm.