CYCLUS
Loading...
Searching...
No Matches
institution.cc
Go to the documentation of this file.
1// Implements the Institution class
2#include "institution.h"
3
4#include <iostream>
5#include <sstream>
6#include <string>
7
8#include "error.h"
9#include "facility.h"
10#include "infile_tree.h"
11#include "logger.h"
12#include "timer.h"
13
14namespace cyclus {
15
17 kind_ = "Inst";
18}
19
21
25
26std::string Institution::str() {
27 if (parent() != NULL) {
28 return Agent::str() + " in region" + parent()->prototype();
29 } else {
30 return Agent::str() + " with no region.";
31 }
32}
33
37
41
46
48 std::set<Agent*>::iterator it;
49 for (it = children().begin(); it != children().end(); ++it) {
50 Agent* a = *it;
51 if (a->lifetime() != -1 && context()->time() >= a->exit_time()) {
52 Facility* fac = dynamic_cast<Facility*>(a);
53 if (fac == NULL || fac->CheckDecommissionCondition()) {
54 CLOG(LEV_INFO3) << a->prototype()
55 << " has reached the end of its lifetime";
56 context()->SchedDecom(a);
57 }
58 }
59 }
60}
61
62} // namespace cyclus
const int exit_time() const
Returns the default time step at which this agent will exit the simulation (-1 if the agent has an in...
Definition agent.h:402
virtual void InitFrom(QueryableBackend *b)
Intializes an agent's internal state from the database.
Definition agent.cc:44
const std::string prototype() const
Returns the agent's prototype.
Definition agent.h:342
virtual void Build(Agent *parent)
Called when the agent enters the smiulation as an active participant and is only ever called once.
Definition agent.cc:144
void lifetime(int n_timesteps)
Sets the number of time steps this agent operates between building and decommissioning (-1 if the age...
Definition agent.cc:103
Agent(Context *ctx)
Creates a new agent that is managed by the given context.
Definition agent.cc:58
Context * context() const
Returns this agent's simulation context.
Definition agent.h:364
const std::set< Agent * > & children() const
Returns a list of children this agent has.
Definition agent.h:408
virtual void Decommission()
Decommissions the agent, removing it from the simulation.
Definition agent.cc:173
std::string kind_
describes the agent subclass (e.g.
Definition agent.h:443
Agent * parent() const
Returns parent of this agent. Returns NULL if the agent has no parent.
Definition agent.h:370
virtual std::string str()
Description of this agent.
Definition agent.cc:95
A simulation context provides access to necessary simulation-global functions and state.
Definition context.h:146
void RegisterTimeListener(TimeListener *tl)
Registers an agent to receive tick/tock notifications every timestep.
Definition context.cc:343
void SchedDecom(Agent *m, int time=-1)
Schedules the given Agent to be decommissioned at the specified timestep t.
Definition context.cc:136
void UnregisterTimeListener(TimeListener *tl)
Removes an agent from receiving tick/tock notifications.
Definition context.cc:347
The Facility class is the abstract class/interface used by all facility agents.
Definition facility.h:68
virtual bool CheckDecommissionCondition()
facilities over write this method if a condition must be met before their destructors can be called
Definition facility.cc:53
virtual ~Institution()
every agent should be destructable
virtual void Decommission()
Decommissions the agent, removing it from the simulation.
virtual std::string str()
every agent should be able to print a verbose description
virtual void EnterNotify()
Called to give the agent an opportunity to register for services (e.g.
virtual void Build(Agent *parent)
perform all tasks required when an inst enters the simulation
virtual void InitFrom(QueryableBackend *b)
Intializes an agent's internal state from the database.
Definition institution.h:45
Institution(Context *ctx)
Default constructor for Institution Class.
virtual void Tock()
Simulation agents do their end-of-timestep activities in the Tock method.
Code providing rudimentary logging capability for the Cyclus core.
#define CLOG(level)
Definition logger.h:40
taken directly from OsiSolverInterface.cpp on 2/17/14 from https://projects.coin-or....
Definition agent.cc:14
@ LEV_INFO3
Information helpful for simulation users and developers alike.
Definition logger.h:64