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
22
26
27std::string Institution::str() {
28 if (parent() != NULL) {
29 return Agent::str() + " in region" + parent()->prototype();
30 } else {
31 return Agent::str() + " with no region.";
32 }
33}
34
38
42
47
49 std::set<Agent*>::iterator it;
50 for (it = children().begin(); it != children().end(); ++it) {
51 Agent* a = *it;
52 if (a->lifetime() != -1 && context()->time() >= a->exit_time()) {
53 Facility* fac = dynamic_cast<Facility*>(a);
54 if (fac == NULL || fac->CheckDecommissionCondition()) {
56 << " has reached the end of its lifetime";
58 }
59 }
60 }
61}
62
63} // namespace cyclus
The abstract base class used by all types of agents that live and interact in a simulation.
Definition agent.h:49
virtual void InitFrom(QueryableBackend *b)
Intializes an agent's internal state from the database.
Definition agent.cc:45
const std::string prototype() const
Returns the agent's prototype.
Definition agent.h:345
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:153
Context * context() const
Returns this agent's simulation context.
Definition agent.h:367
const std::set< Agent * > & children() const
Returns a list of children this agent has.
Definition agent.h:412
virtual void Decommission()
Decommissions the agent, removing it from the simulation.
Definition agent.cc:182
std::string kind_
describes the agent subclass (e.g.
Definition agent.h:447
Agent * parent() const
Returns parent of this agent. Returns NULL if the agent has no parent.
Definition agent.h:373
virtual std::string str()
Description of this agent.
Definition agent.cc:96
A simulation context provides access to necessary simulation-global functions and state.
Definition context.h:145
virtual int time()
Returns the current simulation timestep.
Definition context.cc:313
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:134
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
The Institution class is the abstract class/interface used by all institution agents.
Definition institution.h:29
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:44
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:39
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:55
T OptionalQuery(InfileTree *tree, std::string query, T default_val)
a query method for optional parameters