コード例 #1
0
    def __init__(self, rid, created, size, pickup, delivery, transport=None, carry=None, restrictions=None):
        """
        Initialization method.

        :param rid: Request unique ID.
        :type rid: int
        :param created: Time in seconds from now since the request was created.
        :type created: int
        :param size: Request size.
        :type size: int
        :param pickup: Pickup job.
        :type pickup: routevo.job.Job
        :param delivery: Delivery job.
        :type delivery: routevo.job.Job
        """
        assert isinstance(rid, six.integer_types)
        assert check(created, (float, six.integer_types))
        assert check(size, (float, six.integer_types))
        assert isinstance(pickup, Job)
        assert isinstance(delivery, Job)
        assert check(transport, (TimeWindow, None))
        assert check(carry, (TimeWindow, None))
        assert check(restrictions, (Restrictions, None))

        self.id = rid
        self.created = int(created)
        self.size = float(size)
        self.pickup = pickup.parent(self)
        self.delivery = delivery.parent(self)
        self.transport = transport
        self.carry = carry
        self.restrictions = Restrictions() if restrictions is None else restrictions
コード例 #2
0
    def __init__(self, longitude, latitude):
        """
        Initialization method.

        :param longitude: Longitude in degrees.
        :type longitude: float
        :param latitude: Latitude in degrees
        :type latitude: float
        """
        assert check(longitude, (float, six.integer_types))
        assert check(latitude, (float, six.integer_types))

        self.longitude = float(longitude)
        self.latitude = float(latitude)
コード例 #3
0
    def __init__(self,
                 jid,
                 t,
                 location,
                 arrival,
                 waiting,
                 aid=None,
                 times=None):
        """
        Initialization method.

        :param jid: Job unique ID.
        :type jid: int
        :param t: Type of job: PICKUP or DELIVERY
        :type t: str
        :param location: Job location.
        :type location: routevo.utils.point.Point
        :param arrival: Soft restriction on arrival time.
        :type arrival: routevo.constraints.soft.tw.TimeWindow | None
        :param aid: Location ID. It is used to distinguish, for example,
            different floors of the same building, and to group jobs from the same location.
        :type aid: int | None
        :param times: Realization times of finished phases of job, in seconds from now.
        :type times: dict[str, int|float|None] | None
        """
        assert isinstance(jid, six.integer_types)
        assert isinstance(t, six.string_types) and t in self.ALL
        assert isinstance(location, Point)
        assert check(arrival, (TimeWindow, None))
        assert check(waiting, (float, six.integer_types))
        assert check(aid, (six.integer_types, None))
        assert check(times, (dict, None))

        self.id = jid
        self.type = t
        self.aid = aid
        self.location = location
        self.arrival = arrival
        self.waiting = float(waiting)

        _times = {} if times is None else times
        self.begin = _times.get('begin', None)
        self.at = _times.get('at', None)
        self.end = _times.get('end', None)

        self.request = None
        self._size = None
コード例 #4
0
    def __init__(self, limit):
        """
        Initialization method.

        :param limit: Constraint limit, eg. vehicle capacity, maximum deliveries etc.
        :type limit: float
        """
        assert check(limit, (float, six.integer_types))
        self.limit = float(limit)
コード例 #5
0
    def __init__(self, penalty, limit, margin=0.0):
        """
        Initialization method.

        :param penalty: Penalty for violating constraint.
        :type penalty: routevo.utils.penalty.Penalty
        :param limit: Constraint limit, eg. distance, time etc.
        :type limit: float
        :param margin: Safety margin. Limit + margin = upper limit.
        :type margin: float
        """
        assert isinstance(penalty, Penalty)
        assert check(limit, (float, integer_types))
        assert check(margin, (float, integer_types))

        self.limit = float(limit)
        self.margin = float(margin)
        self.cf = penalty
コード例 #6
0
    def __init__(self, timeout=None):
        """
        Initialization method.

        :param timeout: Maximum time in seconds for optimization.
            None means to optimize as long, as there is no improvement.
        :type timeout: float | int | None
        """
        assert check(timeout, (float, six.integer_types, None))
        self.timeout = float(timeout)
コード例 #7
0
    def __init__(self, lower, expected, upper, penalty):
        """
        Initialization method.

        :param lower: lower time limit in seconds of arrival
        :type lower: float
        :param expected: expected time in seconds of arrival
        :type expected: float | None
        :param upper: upper time limit in seconds of arrival
        :type upper: float | None
        :param penalty: cost function object
        :type penalty: routevo.utils.penalty.Penalty | None
        """

        assert check(lower, (float, integer_types))
        assert check(expected, (float, integer_types, None))
        assert check(upper, (float, integer_types, None))
        assert isinstance(penalty, Penalty)

        self.lower = float(lower)
        self.expected = float(expected)
        self.upper = float(upper)
        self.penalty = penalty
コード例 #8
0
    def __init__(self, kind=None, timeout=None):
        """
        Initialization method.

        :param kind: Type of distances in matrix.
        :type kind: basestring | None
        :param timeout: Maximum time in seconds to wait for a computation of distances matrix.
            None means to wait as much as necessary.
        :type timeout: float | int | None
        """
        assert kind is None or kind in self.ALL
        assert check(timeout, (float, six.integer_types, None))

        self.kind = kind
        self.timeout = float(timeout)
コード例 #9
0
    def __init__(self, vid, location, speed, amortization, salary, availability=None,
                 locked=None, restrictions=None, time=0.0, waiting=0.0):
        """
        Initialization method.

        :param vid: Unique vehicle ID.
        :type vid: int
        :param location: Current geographical location of vehicle.
        :type location: routevo.utils.point.Point
        :param speed: Average speed in km/h.
        :type speed: float
        :param amortization: Amortization cost per kilometer.
        :type amortization: float
        :param salary: Driver salary cost per hour.
        :type salary: float
        :param availability: Time window defining when vehicle is operational.
        :type availability: routevo.constraints.mixed.availability.Availability | None
        :param locked: Number of locked jobs in route.
        :type locked: int | None
        :param restrictions: Restrictions for vehicle.
        :type restrictions: routevo.constraints.restrictions.Restrictions | None
        :param time: Location age.
        :type time: int
        """

        assert isinstance(vid, six.integer_types)
        assert isinstance(location, Point)
        assert check(time, (float, six.integer_types))
        assert check(speed, (float, six.integer_types))
        assert check(waiting, (float, six.integer_types))
        assert check(amortization, (float, six.integer_types))
        assert check(salary, (float, six.integer_types))
        assert check(availability, (Availability, None))
        assert check(locked, (six.integer_types, None))
        assert check(restrictions, (Restrictions, None))

        self.id = vid
        self.location = location
        self.time = float(time)
        self.speed = float(speed)
        self.waiting = float(waiting)
        self.amortization = float(amortization)
        self.salary = float(salary)
        self.availability = availability
        self.locked = 0 if locked is None else int(locked)
        self.restrictions = Restrictions() if restrictions is None else restrictions
コード例 #10
0
    def __init__(self, routes, unassigned=None):
        """
        Initialization method.

        :param routes: Routes.
        :type routes: list[routevo.route.Route]
        :param unassigned: New or unassigned requests to any vehicle.
        :type unassigned: list[routevo.request.Request]
        """
        assert isinstance(routes, list)
        for r in routes:
            assert isinstance(r, Route)

        assert check(unassigned, (list, None))
        if unassigned is not None:
            for r in unassigned:
                assert isinstance(r, Request)

        self.routes = {r.vehicle.id: r for r in routes}
        self.unassigned = [] if unassigned is None else unassigned
コード例 #11
0
    def __init__(self, attributes=None, filters=None, hard=None, soft=None):
        """
        Initialization method.

        :param attributes: User defined attributes held by object.
        :type attributes: dict
        :param filters: Filters constraints.
        :type filters: list[routevo.constraints.hard.base.BaseMatchConstraint]
        :param hard: List of hard constraints.
        :type hard: list[routevo.constraints.hard.base.BaseHardConstraint]
        :param soft: List of soft constraints.
        :type soft: list[routevo.constraints.soft.base.BaseSoftConstraint]
        """
        assert check(attributes, (dict, None))
        self._validate(filters, self.FILTERS.values())
        self._validate(hard, self.HARD.values())
        self._validate(soft, self.SOFT.values())

        self.attributes = {} if attributes is None else attributes
        self.filters = [] if filters is None else filters
        self.hard = [] if hard is None else hard
        self.soft = [] if soft is None else soft