/* * * EDGECITY v1.5 -- The Model's main file * * 'Evolution of Central Places' a model by Paul Krugman * * This simulation is based on the demo model published by P. Krugman, which was * reformulated as an agent-based model by László Gulyás. * It was implemented in MAML v0.03 as an example application. * * (c) 1998, CEU Systems Laboratory * */ @model EdgeCity { @var: int NumOfPlaces; // Number Of Locations @var: int NumOfFirms; // Number Of Agents @var: double A, B, r1, r2, mobility; // Model Parameters // (mobility stands for gamma in the paper) @var: double initialFlatness; // Parameter used in the equation for // the initial distribution (was k in the // original paper) @var: int randomMoveFactor; // Newly introduced parameter (noise) // MAML code for the centralized information broker agent // which stores the common information available for the agents // (note: every agent could calculate it itself through intensive // communication, however technically this is a much more elegant // version) $import "infobank.maml.stub"; // MAML code for the agents (firms) $import "firm.maml.stub"; @var: [] int places; // Array storing the actual number of // firms residing at each locations. @var: InfoBank infoBank; // Instance of the InfoBroker Agent Class // The model's schedule which drives the dynamics of it @schedule cyclic(1) { // It is a cyclic schedule of the length 1 0: @planDef seq { // This actions are executed for every // cycle, exactly in this order @forEach groupOfFirm determineMove; // All firms execute 'determineMove' @to infoBank updateInformation; // infoBank updates its contents } } // Array used in initialization // (Technical variable storing the intervals used to determine the initial // locations of the firms). @var: [] double initialProb; // The initialization of the model @init: Firm *dummy; // Temporaly variables for firm creation double sum, locValue; int i, j; // Initializing the locations @create [NumOfPlaces:i] int places { places[i] = 0; } // Initializing the firms // First, we create random probabilities for the locations // modified by the initialFlatness parameter (as in the paper) @create [NumOfPlaces:i] double initialProb { initialProb[i] = initialFlatness + [uniformDblRand getDoubleWithMin: 0 withMax: 1.0 ]; } // Then, we create connected intervals out of them for (i=1; i