예제 #1
0
    def __init__(self, uid, model, clock, cur_location, house_agent, company,
                 location_road_manager, car_model_manager, whereabouts_manager,
                 calendar_planer, parameters):
        """
        Parameters
        ----------
        uid : int
            Unique of the car agent.
        model : ChargingModel
            The base charging model defined as base for the simulation.
        clock : Clock
            The Handle to the global clock object.
        house_agent : HouseAgent
            The house_agent assigned to this car_agent.
        company : Company
            The company where this agent is working.
        location_road_manager : LocationRoadManager
            Handle to the location road manager.
        car_model_manager : CarModelManager
            The object handling all car models created in ChargingModel class.
        whereabouts_manager : WhereaboutsManager
            The object handling all whereabouts created in ChargingModel class.
        calendar_planer: CalendarPlaner
            The object handling the creation of calendars across the
            simulation.
        parameters: Parameters
            Provides external parameters.
            
        Parameters handed by Parameter class
        ----------
        departure_condition : string
            Ensures that car never runs out of power midway. Can take three
            different values:
                ROUND_TRIP   = SOC needs to allow for completing next route
                               twice (back and forth) PLUS reserve_range.
                ONE_WAY_TRIP = SOC needs to allow for completing next route
                               once PLUS reserve_range.
                NEXT_NODE    = SOC needs to allow for reaching the next node
                               PLUS reserve_range.
        reserve_range : int
            Range the car needs to be able drive without charging in km.
        reserve_speed : int
            Velocity assumed car is driving maximum once it hits reserve in
            km/h.
        queuing_condition : string
            Allows to choose if the car owner is actively trying to charge its
            car in case all chargers are blocked by the time of arrival. That
            is, return later once a charger is available or just leave the car
            not charging in case there is no charger available by the time of
            arrival. Can take two values:
                ALWAYS      = Que everytime a destination is reached.
                WHEN_NEEDED = Only if the departure criteria is not satisfied.

        Returns
        -------
        None.
        """
        super().__init__(uid, model)
        # uid is redundant because super alreay incorperates unique_id but
        # for brevity and consistency through out the code i define uid
        self.uid = uid
        self.parameters = parameters
        self.clock = clock
        self.house_agent = house_agent
        self.company = company
        # TODO reconsider how car models are chosen
        self.lrm = location_road_manager
        self.car_model = car_model_manager.draw_car_model_at_random()
        self.whereabouts = whereabouts_manager.track_new_agent(
            uid, cur_location)
        # TODO check if all agents should start with 100% SOC
        self.soc = self.car_model.battery_capacity  # soc in kWh
        self.charge_at_home_from_grid = 0.0
        self.charge_at_home_from_pv = 0.0
        self.charge_at_work = 0.0

        self.electricity_cost = 0  # in $
        self.calendar = Cal(self.clock, self.lrm, calendar_planer,
                            self.whereabouts, house_agent.location,
                            company.location)

        self.departure_condition \
            = parameters.get_parameter("departure_condition","string")
        if self.departure_condition not in {
                "ROUND_TRIP", "ONE_WAY_TRIP", "NEXT_NODE"
        }:
            sys.exit("Departure condition: " + str(self.departure_condition) \
                     + " is ill defined!")
        self.reserve_range = parameters.get_parameter("reserve_range", "int")
        self.reserve_speed = parameters.get_parameter("reserve_speed", "int")
        self.emergency_charging = 0.0  # in kWh
        self.queuing_condition = parameters.get_parameter(
            "queuing_condition", "string")
        if self.queuing_condition not in {"ALWAYS", "WHEN_NEEDED"}:
            sys.exit("Queuing condition: " + str(self.queuing_condition) \
                     + " is ill defined!")
        self.would_run_flat = False
예제 #2
0
 def setUp(self):
     self.settings = DEFAULT_SETTINGS
     self.cal = Cal(DEFAULT_SETTINGS, 'key', 'path')
예제 #3
0
#main program---mop.py
from cal import Cal
xo = Cal()
xo.disp()