Exemple #1
0
 def _set_constraint_on_var(index: int, constraint: TimeWindowConstraint,
                            time_dimension: RoutingDimension):
     if constraint.is_hard:
         time_dimension.CumulVar(index).SetRange(constraint.from_time,
                                                 constraint.to_time)
     else:
         if constraint.from_time > 0:
             time_dimension.SetCumulVarSoftLowerBound(
                 index, constraint.from_time, constraint.weight)
         if constraint.to_time < MAX_TIMESTAMP_VALUE:
             time_dimension.SetCumulVarSoftUpperBound(
                 index, constraint.to_time, constraint.weight)
Exemple #2
0
def node_properties(
    routing: pywrapcp.RoutingModel,
    assignment: pywrapcp.Assignment,
    capacity_dimension: pywrapcp.RoutingDimension,
    time_dimension: pywrapcp.RoutingDimension,
    index: int,
) -> tuple:
    """
    Get a node's properties on the index.
    """
    node_index = routing.IndexToNode(index)
    load = assignment.Value(capacity_dimension.CumulVar(index))
    time_var = time_dimension.CumulVar(index)
    time_min, time_max = assignment.Min(time_var), assignment.Max(time_var)
    return (node_index, load, time_min, time_max)
Exemple #3
0
def node_properties(
    manager: RoutingIndexManager,
    assignment: Assignment,
    capacity_dimension: RoutingDimension,
    time_dimension: RoutingDimension,
    index: int,
) -> tuple:
    """
    Get a node's properties corresponding to the index.
    """

    node_index = manager.IndexToNode(index)
    load = assignment.Value(capacity_dimension.CumulVar(index))
    time_var = time_dimension.CumulVar(index)
    time_min, time_max = assignment.Min(time_var), assignment.Max(time_var)
    return (node_index, load, time_min, time_max)
Exemple #4
0
def node_properties(
	data: dict,
	manager: RoutingIndexManager,
	assignment: Assignment,
	capacity_dimension: RoutingDimension,
	time_dimension: RoutingDimension,
	index: int,
) -> tuple:
	"""
	Get a node's properties corresponding to the index.
	"""
	node_index = manager.IndexToNode(index)
	demand = data['demands'][node_index]
	load = assignment.Value(capacity_dimension.CumulVar(index))
	if 'time_windows' in data.keys():
		time_var = time_dimension.CumulVar(index)
		time = assignment.Value(time_dimension.CumulVar(index))
		time_min, time_max = assignment.Min(time_var), assignment.Max(time_var)
		return (node_index, demand, time_min, time_max, load, time)
	return (node_index, demand, load)