This commit is contained in:
Laurent Perron
2018-05-31 10:53:47 -07:00
4 changed files with 43 additions and 9 deletions

View File

@@ -247,11 +247,25 @@ def add_time_window_constraints(routing, data, time_evaluator):
time_evaluator,
horizon, # allow waiting time
horizon, # maximum time per vehicle
True, # start cumul to zero
False, # don't force start cumul to zero since we are giving TW to start nodes
time)
time_dimension = routing.GetDimensionOrDie(time)
# Add time window constraints for each location except depot
# and "copy" the slack var in the solution object (aka Assignment) to print it
for location_idx, time_window in enumerate(data.time_windows):
time_dimension.CumulVar(location_idx).SetRange(time_window[0], time_window[1])
if location_idx == 0:
continue
index = routing.NodeToIndex(location_idx)
time_dimension.CumulVar(index).SetRange(time_window[0], time_window[1])
routing.AddToAssignment(time_dimension.SlackVar(index))
# Add time window constraints for each vehicle start node
# and "copy" the slack var in the solution object (aka Assignment) to print it
for vehicle_id in xrange(data.num_vehicles):
index = routing.Start(vehicle_id)
time_dimension.CumulVar(index).SetRange(data.time_windows[0][0], data.time_windows[0][1])
routing.AddToAssignment(time_dimension.SlackVar(index))
# Warning: Slack var is not defined for vehicle's end node
#routing.AddToAssignment(time_dimension.SlackVar(self.routing.End(vehicle_id)))
###########
# Printer #
@@ -302,7 +316,14 @@ class ConsolePrinter():
time_var = time_dimension.CumulVar(index)
time_min = self.assignment.Min(time_var)
time_max = self.assignment.Max(time_var)
plan_output += ' {0} Load({1}) Time({2},{3}) ->'.format(node_index, route_load, time_min, time_max)
slack_var = time_dimension.SlackVar(index)
slack_min = self.assignment.Min(slack_var)
slack_max = self.assignment.Max(slack_var)
plan_output += ' {0} Load({1}) Time({2},{3}) Slack({4},{5}) ->'.format(
node_index,
route_load,
time_min, time_max,
slack_min, slack_max)
index = self.assignment.Value(self.routing.NextVar(index))
node_index = self.routing.IndexToNode(index)
@@ -314,7 +335,10 @@ class ConsolePrinter():
time_max = self.assignment.Max(time_var)
total_dist += route_dist
total_time += route_time
plan_output += ' {0} Load({1}) Time({2},{3})\n'.format(node_index, route_load, time_min, time_max)
plan_output += ' {0} Load({1}) Time({2},{3})\n'.format(
node_index,
route_load,
time_min, time_max)
plan_output += 'Distance of the route: {0}m\n'.format(route_dist)
plan_output += 'Load of the route: {0}\n'.format(route_load)
plan_output += 'Time of the route: {0}min\n'.format(route_time)

View File

@@ -840,8 +840,9 @@ rcc: $(BIN_DIR)/$(basename $(notdir $(EX)))$E
# ref: https://www.gnu.org/prep/standards/html_node/DESTDIR.html
install_dirs:
-$(MKDIR) "$(DESTDIR)$(prefix)"
-$(MKDIR) "$(DESTDIR)$(prefix)$Slib"
-$(MKDIR) "$(DESTDIR)$(prefix)$Sinclude"
-$(MKDIR) "$(DESTDIR)$(prefix)$Slib"
-$(MKDIR) "$(DESTDIR)$(prefix)$Sbin"
-$(DELREC) "$(DESTDIR)$(prefix)$Sinclude$Sortools"
$(MKDIR) "$(DESTDIR)$(prefix)$Sinclude$Sortools"
$(MKDIR) "$(DESTDIR)$(prefix)$Sinclude$Sortools$Salgorithms"
@@ -856,7 +857,7 @@ install_dirs:
$(MKDIR) "$(DESTDIR)$(prefix)$Sinclude$Sortools$Sutil"
.PHONY: install_cc # Install C++ OR-Tools to $(DESTDIR)$(prefix)
install_cc: install_libortools install_third_party
install_cc: install_libortools install_third_party install_doc
install_libortools: ortoolslibs install_dirs
$(COPY) LICENSE-2.0.txt "$(DESTDIR)$(prefix)"
@@ -878,7 +879,7 @@ install_libortools: ortoolslibs install_dirs
$(COPY) ortools$Sutil$S*.h "$(DESTDIR)$(prefix)$Sinclude$Sortools$Sutil"
$(COPY) $(LIB_DIR)$S$(LIB_PREFIX)ortools.$L "$(DESTDIR)$(prefix)$Slib"
install_third_party:
install_third_party: install_dirs
ifeq ($(UNIX_GFLAGS_DIR),$(OR_TOOLS_TOP)/dependencies/install)
$(COPYREC) dependencies$Sinstall$Sinclude$Sgflags "$(DESTDIR)$(prefix)$Sinclude"
$(COPYREC) dependencies$Sinstall$Slib$Slibgflags* "$(DESTDIR)$(prefix)$Slib"
@@ -904,6 +905,14 @@ ifeq ($(UNIX_CBC_DIR),$(OR_TOOLS_TOP)/dependencies/install)
$(COPYREC) dependencies$Sinstall$Sbin$Sclp "$(DESTDIR)$(prefix)$Sbin"
endif
install_doc:
-$(DELREC) "$(DESTDIR)$(prefix)$Sshare$Sdoc$Sortools"
-$(MKDIR_P) "$(DESTDIR)$(prefix)$Sshare$Sdoc$Sortools"
-$(MKDIR) "$(DESTDIR)$(prefix)$Sshare$Sdoc$Sortools$Ssat"
-$(MKDIR) "$(DESTDIR)$(prefix)$Sshare$Sdoc$Sortools$Ssat$Sdoc"
#$(COPY) ortools$Ssat$S*.md "$(DESTDIR)$(prefix)$Sshare$Sdoc$Sortools$Ssat"
$(COPY) ortools$Ssat$Sdoc$S*.md "$(DESTDIR)$(prefix)$Sshare$Sdoc$Sortools$Ssat$Sdoc"
.PHONY: detect_cc # Show variables used to build C++ OR-Tools.
detect_cc:
@echo Relevant info for the C++ build:

View File

@@ -524,7 +524,7 @@ MISSING_PYPI_FILES = \
$(PYPI_ARCHIVE_TEMP_DIR)/ortools/ortools/linear_solver \
$(PYPI_ARCHIVE_TEMP_DIR)/ortools/ortools/sat \
$(PYPI_ARCHIVE_TEMP_DIR)/ortools/ortools/data \
$(PYPI_ARCHIVE_TEMP_DIR)/ortools/ortools/util \
$(PYPI_ARCHIVE_TEMP_DIR)/ortools/ortools/util
$(PYPI_ARCHIVE_TEMP_DIR):
$(MKDIR) $(PYPI_ARCHIVE_TEMP_DIR)
@@ -653,6 +653,7 @@ $(PYPI_ARCHIVE_TEMP_DIR)/ortools/ortools/sat: $(PYSAT_LIBS) | $(PYPI_ARCHIVE_TEM
-$(DELREC) $(PYPI_ARCHIVE_TEMP_DIR)$Sortools$Sortools$Ssat
$(MKDIR) $(PYPI_ARCHIVE_TEMP_DIR)$Sortools$Sortools$Ssat
$(TOUCH) $(PYPI_ARCHIVE_TEMP_DIR)$Sortools$Sortools$Ssat$S__init__.py
$(COPY) ortools$Ssat$Sdoc$S*.md $(PYPI_ARCHIVE_TEMP_DIR)$Sortools$Sortools$Ssat
$(COPY) ortools$Ssat$S*.py $(PYPI_ARCHIVE_TEMP_DIR)$Sortools$Sortools$Ssat
$(COPY) $(GEN_DIR)$Sortools$Ssat$S*.py $(PYPI_ARCHIVE_TEMP_DIR)$Sortools$Sortools$Ssat
$(COPY) $(GEN_DIR)$Sortools$Ssat$S_pywrapsat.* $(PYPI_ARCHIVE_TEMP_DIR)$Sortools$Sortools$Ssat

View File

@@ -55,7 +55,7 @@ setup(
'ortools.linear_solver' : ['_pywraplp.dll'],
'ortools.graph' : ['_pywrapgraph.dll'],
'ortools.algorithms' : ['_pywrapknapsack_solver.dll'],
'ortools.sat' : ['_pywrapsat.dll'],
'ortools.sat' : ['_pywrapsat.dll', '*.md'],
DELETEWIN 'ortools' : ['libortools.DLL' DDDD]
},
include_package_data=True,