FFSM++ 1.1.0
French Forest Sector Model ++
Loading...
Searching...
No Matches
MainProgram.cpp
Go to the documentation of this file.
1/***************************************************************************
2 * Copyright (C) 2015 by Laboratoire d'Economie Forestière *
3 * http://ffsm-project.org *
4 * *
5 * This program is free software; you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation; either version 3 of the License, or *
8 * (at your option) any later version, given the compliance with the *
9 * exceptions listed in the file COPYING that is distribued together *
10 * with this file. *
11 * *
12 * This program is distributed in the hope that it will be useful, *
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
15 * GNU General Public License for more details. *
16 * *
17 * You should have received a copy of the GNU General Public License *
18 * along with this program; if not, write to the *
19 * Free Software Foundation, Inc., *
20 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
21 ***************************************************************************/
22#include <iostream>
23#include <clocale>
24
25#include "MainProgram.h"
26#include "ThreadManager.h"
27#include "Opt.h"
28
29
30
31
32//constructor
34{
35 //input_filename = input_filename_h;
36 MTHREAD = MTHREAD_h;
37 // Creating objects for the program flow:
38 // the regional data object..
39 ModelData *MD = new ModelData(MTHREAD);
42 MTHREAD->MD->loadInput(); // Unzip the ooffice input file and load it into memory
43
44}
45
46//distructor
50
51/**
52This is the main call of the program.
53<br>It firstly create the objects (and keep track of them trough pointers) of the main functional objects of the program.
54<br>Then it call the INIT object to do its jobs and when it ends, it gives control to SCD (Scheduler) for the year loops.
55<br>Finally it clean-up and returns.
56*/
57void
59
60 setlocale(LC_ALL, "C"); // force to use the dot as digital separator also if we are running under the GUI
61
62 // GIS information and methods..
63 Gis *GIS = new Gis(MTHREAD);
65 // a test object for various 0-effects tests (sandbox)..
66 Sandbox* TEST = new Sandbox(MTHREAD);
68 // the Init object, it schedule the pre-simulation phase..
69 Init *INIT = new Init(MTHREAD);
71 // the scheduler object. It manage the simulation loops..
72 Scheduler *SCD = new Scheduler(MTHREAD);
74 // the core of the model
75 ModelCore *CORE = new ModelCore(MTHREAD);
77 // the core of the model (spatial version)
80 // the market optimisation algorithm
81 Opt *OPT = new Opt(MTHREAD);
83 // manage the printing of data needed for scenario-analisys. The "message output" (needed to see "what is it happening?" are instead simply printed with msgOut()..
84 Output *DO = new Output(MTHREAD);
86 // the carbon balance
87 Carbon *CBAL = new Carbon(MTHREAD);
89
90 // Creating an istance of INIT and delegating to it the Initialization phase..
91 MTHREAD->INIT->setInitLevel(1); // Initial environment setting and agent rising
92 refreshGUI();
93 MTHREAD->INIT->setInitLevel(3); // assigning resources to agents and evenutal env reallocation
94 refreshGUI();
95 MTHREAD->INIT->setInitLevel(5); // starting simulations. Once INIT has ended it is the turn of SCD (Scheduler) to manage the simulation...
96 refreshGUI();
97 MTHREAD->INIT->setInitLevel(6); // ending simulations
98 refreshGUI();
99
100 // Deleting the pointers...
101 // 20070102: if I delete the pointers I can not access the legend after simulation has ended
102 // 20070109: pointers (e.g. INIT) are deleted in ThreadManager when a new simulation start
103}
104
ThreadManager * MTHREAD
Pointer to the Thread manager.
Definition BaseClass.h:467
void refreshGUI() const
Ping to periodically return the control to the GUI.
Class responsable to keep the logbook of the Carbon Balance.
Definition Carbon.h:50
Class to manage the spatial dimension.
Definition Gis.h:67
Init the environment, the objects and the agents of the model
Definition Init.h:45
void setInitLevel(int level_h)
Wrapper to the correct setInitLevelX()
Definition Init.cpp:48
void run()
Run the program.
MainProgram(ThreadManager *MTHREAD)
The core of the model (spatial version).
Regional data, including macros and settings.
Definition ModelData.h:80
void loadInput()
Unzip the OpenOffice input file (NEW 2008.05.13)
void setBaseDiretory(string baseDirectory_h)
Definition ModelData.h:183
Definition Opt.h:52
Output methods
Definition Output.h:48
Manage the yearly loops.
Definition Scheduler.h:42
Thread manager. Responsable to manage the main thread and "speak" with the GUI.
void setCBALPointer(Carbon *CBAL_h)
Module that account for the Carbon Balance.
void setDOPointer(Output *DO_h)
manage the printing of data needed for scenario-analisys. The "message output" (needed to see "what i...
void setOPTPointer(Ipopt::SmartPtr< Ipopt::TNLP > OPT_h)
Perform the market optimisation.
Init * INIT
the Init object (pre-simulation scheduler)
void setGISPointer(Gis *GIS_h)
GIS information and methods..
string getBaseDirectory()
void setSCDPointer(Scheduler *SCD_h)
the scheduler object. It manage the simulation loops..
ModelData * MD
the model data object
void setTestPointer(Sandbox *TEST_h)
the sandbox object for within-development quick tests
void setCOREPointer(ModelCore *CORE_h)
Perform the algorithms of the model.
void setMDPointer(ModelData *MD_h)
the regional data object..
void setINITPointer(Init *INIT_h)
the Init object, it schedule the pre-simulation phase..
void setSCOREPointer(ModelCoreSpatial *SCORE_h)
Perform the algorithms of the model.