FMU/Source/Simulation.cpp
/**
 * @brief Increments the timestep for the simulation
 * @details Increments the timestep for the EnergyPlus processor, the AgentModel and the ZoneManager.
 * Also we send any effects the agent have to the zones they are located in.
 */
@brief Increments the timestep for the simulation
@details Increments the timestep for the EnergyPlus processor, the AgentModel and the ZoneManager.
Also we send any effects the agent have to the zones they are located in.
@brief Increments the timestep for the simulation @details Increments the timestep for the EnergyPlus processor the AgentModel and the ZoneManager . Also we send any effects the agent have to the zones they are located in .
void Simulation::timeStep() {
  std::shuffle(buildings.begin(), buildings.end(), Utility::engine);
  calculateGridCost();
  for (Building &b : buildings) {
      b.step();
      b.stepAppliancesUse();
      b.addContactsTo(&building_negotiation, true);
  }
  for (Building &b : buildings) {
      b.stepAppliancesUseBatteries(&building_negotiation);
  }
  if (buildings.size() > 1) {
    building_negotiation.process();
  }
  for (Building &b : buildings) {
      b.stepAppliancesNegotiationNeighbourhood(building_negotiation);
  }
  building_negotiation.clear();
  for (Building &b : buildings) {
    b.addContactsTo(&building_negotiation, false);
  }
  double diff = building_negotiation.getDifference();
  Contract m;
  m.id = -1;
  m.buildingID = -1;
  m.supplied = std::abs(diff);
  m.suppliedCost = gridCost;
  m.requested = 0;
  if (diff > 0.0) {
    m.supplied = 0;
    m.suppliedCost = 0;
    m.requested = std::numeric_limits<double>::max();
  }
  m.suppliedLeft = m.supplied;
  building_negotiation.submit(m);
  building_negotiation.process();
  for (Building &b : buildings) {
    b.stepAppliancesNegotiation(building_negotiation);
  }
  m = building_negotiation.getContract(m.buildingID, m.id);
  DataStore::addValue(GridReceivedDataId, m.received);
  DataStore::addValue(GridPowerDataId, m.supplied);
  DataStore::addValue(GridCostDataId, m.suppliedCost);
  building_negotiation.clear();
}
void Simulation :: timeStep ( ) { std :: shuffle ( buildings . begin ( ) , buildings . end ( ) , Utility :: engine ) ; calculateGridCost ( ) ; for ( Building & b : buildings ) { b . step ( ) ; b . stepAppliancesUse ( ) ; b . addContactsTo ( & building_negotiation , true ) ; } for ( Building & b : buildings ) { b . stepAppliancesUseBatteries ( & building_negotiation ) ; } if ( buildings . size ( ) > 1 ) { building_negotiation . process ( ) ; } for ( Building & b : buildings ) { b . stepAppliancesNegotiationNeighbourhood ( building_negotiation ) ; } building_negotiation . clear ( ) ; for ( Building & b : buildings ) { b . addContactsTo ( & building_negotiation , false ) ; } double diff = building_negotiation . getDifference ( ) ; Contract m ; m . id = -1 ; m . buildingID = -1 ; m . supplied = std :: abs ( diff ) ; m . suppliedCost = gridCost ; m . requested = 0 ; if ( diff > 0.0 ) { m . supplied = 0 ; m . suppliedCost = 0 ; m . requested = std :: numeric_limits < double > :: max ( ) ; } m . suppliedLeft = m . supplied ; building_negotiation . submit ( m ) ; building_negotiation . process ( ) ; for ( Building & b : buildings ) { b . stepAppliancesNegotiation ( building_negotiation ) ; } m = building_negotiation . getContract ( m . buildingID , m . id ) ; DataStore :: addValue ( GridReceivedDataId , m . received ) ; DataStore :: addValue ( GridPowerDataId , m . supplied ) ; DataStore :: addValue ( GridCostDataId , m . suppliedCost ) ; building_negotiation . clear ( ) ; }
@brief Increments the timestep for the simulation
 @details Increments the timestep for the EnergyPlus processor, the AgentModel and the ZoneManager.
@brief Increments the timestep for the simulation @details Increments the timestep for the EnergyPlus processor the AgentModel and the ZoneManager .
//local negotiation // add to contracts // battery negotiation // only process contracts if there is a neighbourhood