diff --git a/Makefile b/Makefile index 4d32bf14f2..d0a207bb22 100644 --- a/Makefile +++ b/Makefile @@ -18,7 +18,7 @@ include Makefile.def # Then we overwrite the local ones if the Makefile.local file exists. -include Makefile.local -# Then include specific unix commands and definitions +# Then include specific system commands and definitions include Makefile.$(SYSTEM) # Include build files. diff --git a/Makefile.build.cpp b/Makefile.build.cpp index 661d5e0bcb..598379b3ff 100644 --- a/Makefile.build.cpp +++ b/Makefile.build.cpp @@ -56,16 +56,16 @@ ALGORITHMS_LIBS = \ algorithmslibs: $(ALGORITHMS_LIBS) clean: - rm -f *.$(LIBSUFFIX) - rm -f objs/*.$O - rm -f $(CPBINARIES) - rm -f $(LPBINARIES) - rm -f gen/*/*wrap* - rm -f gen/*/*.pb.* - rm -f objs/com/google/ortools/*/*.class - rm -f gen/com/google/ortools/*/*.java - rm -f *.so - rm -f *.jar + $(DEL) *.$(LIBSUFFIX) + $(DEL) objs/*.$O + $(DEL) $(CPBINARIES) + $(DEL) $(LPBINARIES) + $(DEL) gen/*/*wrap* + $(DEL) gen/*/*.pb.* + $(DEL) objs/com/google/ortools/*/*.class + $(DEL) gen/com/google/ortools/*/*.java + $(DEL) *.so + $(DEL) *.jar # Constraint Solver Lib. @@ -219,7 +219,7 @@ gen/linear_solver/linear_solver.pb.cc:linear_solver/linear_solver.proto gen/linear_solver/linear_solver.pb.h:gen/linear_solver/linear_solver.pb.cc $(LIBPREFIX)linear_solver.$(LIBSUFFIX): $(LINEAR_SOLVER_LIB_OS) - $(LINKCMD) $(LINKPREFIX)liblinear_solver.$(LIBSUFFIX) $(LINEAR_SOLVER_LIB_OS) + $(LINKCMD) $(LINKPREFIX)linear_solver.$(LIBSUFFIX) $(LINEAR_SOLVER_LIB_OS) # Util library. diff --git a/Makefile.build.python b/Makefile.build.python index b57b86d948..1ce93089ce 100644 --- a/Makefile.build.python +++ b/Makefile.build.python @@ -2,7 +2,7 @@ # pywrapknapsack_solver -pyalgorithms: _pywrapknapsack_solver.$(PYLIBEXT) gen/algorithms/pywrapknapsack_solver.py $(ALGORITHMS_LIBS) $(BASE_LIBS) +pyalgorithms: _pywrapknapsack_solver.$(SHAREDLIBEXT) gen/algorithms/pywrapknapsack_solver.py $(ALGORITHMS_LIBS) $(BASE_LIBS) gen/algorithms/pywrapknapsack_solver.py: algorithms/knapsack_solver.swig algorithms/knapsack_solver.h base/base.swig $(SWIG_BINARY) -c++ -python -o gen/algorithms/knapsack_solver_wrap.cc -module pywrapknapsack_solver algorithms/knapsack_solver.swig @@ -13,11 +13,13 @@ objs/knapsack_solver_wrap.$O: gen/algorithms/knapsack_solver_wrap.cc $(CCC) $(CFLAGS) $(PYTHON_INC) -c gen/algorithms/knapsack_solver_wrap.cc $(OBJOUT)objs/knapsack_solver_wrap.$O _pywrapknapsack_solver.$(SHAREDLIBEXT): objs/knapsack_solver_wrap.$O $(ALGORITHMS_LIBS) $(BASE_LIBS) - $(LD) $(LDOUT)_pywrapknapsack_solver.$(SHAREDLIBEXT) objs/knapsack_solver_wrap.$O $(ALGORITHMS_LIBS) $(BASE_LIBS) $(LDFLAGS) - + $(LD) $(LDOUT)_pywrapknapsack_solver.$(SHAREDLIBEXT) objs/knapsack_solver_wrap.$O $(ALGORITHMS_LIBS) $(BASE_LIBS) $(LDFLAGS) $(PYTHON_LNK) +ifeq "$(SYSTEM)" "win" + copy _pywrapknapsack_solver.dll gen\\knapsack_solver\\_pywrapknapsack_solver.pyd +endif # pywrapflow -pygraph: _pywrapflow.$(PYLIBEXT) gen/graph/pywrapflow.py $(GRAPH_LIBS) $(BASE_LIBS) +pygraph: _pywrapflow.$(SHAREDLIBEXT) gen/graph/pywrapflow.py $(GRAPH_LIBS) $(BASE_LIBS) gen/graph/pywrapflow.py: graph/flow.swig graph/min_cost_flow.h graph/max_flow.h graph/ebert_graph.h base/base.swig $(SWIG_BINARY) -c++ -python -o gen/graph/pywrapflow_wrap.cc -module pywrapflow graph/flow.swig @@ -28,11 +30,14 @@ objs/pywrapflow_wrap.$O: gen/graph/pywrapflow_wrap.cc $(CCC) $(CFLAGS) $(PYTHON_INC) -c gen/graph/pywrapflow_wrap.cc $(OBJOUT)objs/pywrapflow_wrap.$O _pywrapflow.$(SHAREDLIBEXT): objs/pywrapflow_wrap.$O $(GRAPH_LIBS) $(BASE_LIBS) - $(LD) $(LDOUT)_pywrapflow.$(SHAREDLIBEXT) objs/pywrapflow_wrap.$O $(GRAPH_LIBS) $(BASE_LIBS) $(LDFLAGS) + $(LD) $(LDOUT)_pywrapflow.$(SHAREDLIBEXT) objs/pywrapflow_wrap.$O $(GRAPH_LIBS) $(BASE_LIBS) $(LDFLAGS) $(PYTHON_LNK) +ifeq "$(SYSTEM)" "win" + copy _pywrapcp.dll gen\\graph\\_pywrapflow.pyd +endif # pywrapcp -pycp: _pywrapcp.$(PYLIBEXT) gen/constraint_solver/pywrapcp.py _pywraprouting.$(PYLIBEXT) gen/constraint_solver/pywraprouting.py $(CP_LIBS) $(BASE_LIBS) +pycp: _pywrapcp.$(SHAREDLIBEXT) gen/constraint_solver/pywrapcp.py _pywraprouting.$(SHAREDLIBEXT) gen/constraint_solver/pywraprouting.py $(CP_LIBS) $(BASE_LIBS) gen/constraint_solver/pywrapcp.py: constraint_solver/constraint_solver.swig constraint_solver/constraint_solver.h constraint_solver/constraint_solveri.h base/base.swig $(SWIG_BINARY) -c++ -python -o gen/constraint_solver/constraint_solver_wrap.cc -module pywrapcp constraint_solver/constraint_solver.swig @@ -43,7 +48,11 @@ objs/constraint_solver_wrap.$O: gen/constraint_solver/constraint_solver_wrap.cc $(CCC) $(CFLAGS) $(PYTHON_INC) -c gen/constraint_solver/constraint_solver_wrap.cc $(OBJOUT)objs/constraint_solver_wrap.$O _pywrapcp.$(SHAREDLIBEXT): objs/constraint_solver_wrap.$O $(CP_LIBS) $(BASE_LIBS) - $(LD) $(LDOUT)_pywrapcp.$(SHAREDLIBEXT) objs/constraint_solver_wrap.$O $(CP_LIBS) $(BASE_LIBS) $(LDFLAGS) + $(LD) $(LDOUT)_pywrapcp.$(SHAREDLIBEXT) objs/constraint_solver_wrap.$O $(CP_LIBS) $(BASE_LIBS) $(LDFLAGS) $(PYTHON_LNK) +ifeq "$(SYSTEM)" "win" + copy _pywrapcp.dll gen\\constraint_solver\\_pywrapcp.pyd +endif + # pywraprouting @@ -56,14 +65,17 @@ objs/routing_wrap.$O: gen/constraint_solver/routing_wrap.cc $(CCC) $(CFLAGS) $(PYTHON_INC) -c gen/constraint_solver/routing_wrap.cc $(OBJOUT)objs/routing_wrap.$O _pywraprouting.$(SHAREDLIBEXT): objs/routing_wrap.$O $(CP_LIBS) $(BASE_LIBS) - $(LD) $(LDOUT)_pywraprouting.$(SHAREDLIBEXT) objs/routing_wrap.$O $(CP_LIBS) $(BASE_LIBS) $(LDFLAGS) + $(LD) $(LDOUT)_pywraprouting.$(SHAREDLIBEXT) objs/routing_wrap.$O $(CP_LIBS) $(BASE_LIBS) $(LDFLAGS) $(PYTHON_LNK) +ifeq "$(SYSTEM)" "win" + copy _pywraprouting.dll gen\\constraint_solver\\_pywraprouting.pyd +endif # pywraplp -pylp: _pywraplp.$(PYLIBEXT) gen/linear_solver/pywraplp.py $(LP_LIBS) $(BASE_LIBS) +pylp: _pywraplp.$(SHAREDLIBEXT) gen/linear_solver/pywraplp.py $(LP_LIBS) $(BASE_LIBS) gen/linear_solver/pywraplp.py: linear_solver/linear_solver.swig linear_solver/linear_solver.h gen/linear_solver/linear_solver.pb.h base/base.swig - $(SWIG_BINARY) $(CLP_INC) $(CBC_INC) $(GLPK_INC) -c++ -python -o gen/linear_solver/linear_solver_wrap.cc -module pywraplp linear_solver/linear_solver.swig + $(SWIG_BINARY) $(CLP_SWIG) $(CBC_SWIG) $(GLPK_SWIG) -c++ -python -o gen/linear_solver/linear_solver_wrap.cc -module pywraplp linear_solver/linear_solver.swig gen/linear_solver/linear_solver_wrap.cc: gen/linear_solver/pywraplp.py @@ -71,4 +83,8 @@ objs/linear_solver_wrap.$O: gen/linear_solver/linear_solver_wrap.cc $(CCC) $(CFLAGS) $(PYTHON_INC) -c gen/linear_solver/linear_solver_wrap.cc $(OBJOUT)objs/linear_solver_wrap.$O _pywraplp.$(SHAREDLIBEXT): objs/linear_solver_wrap.$O $(LP_LIBS) $(BASE_LIBS) - $(LD) $(LDOUT)_pywraplp.$(SHAREDLIBEXT) objs/linear_solver_wrap.$O $(LP_LIBS) $(BASE_LIBS) $(LDLPDEPS) $(LDFLAGS) \ No newline at end of file + $(LD) $(LDOUT)_pywraplp.$(SHAREDLIBEXT) objs/linear_solver_wrap.$O $(LP_LIBS) $(BASE_LIBS) $(LDLPDEPS) $(LDFLAGS) $(PYTHON_LNK) +ifeq "$(SYSTEM)" "win" + copy _pywraplp.dll gen\\linear_solver\\_pywraplp.pyd +endif + diff --git a/Makefile.def b/Makefile.def index 12827af2a3..e115636619 100644 --- a/Makefile.def +++ b/Makefile.def @@ -20,13 +20,42 @@ UNIX_CBC_DIR=../cbc-2.6.2 UNIX_GLPK_DIR=../glpk-4.45 # Linux jdk root # first, determine 32 or 64 bits. +ifeq "$(SYSTEM)" "unix" LBITS := $(shell getconf LONG_BIT) ifeq ($(LBITS),64) JDK_EXT=64 else JDK_EXT=32 endif +endif + LINUX_JDK_ROOT=/usr/local/buildtools/java/jdk-$(JDK_EXT) # Include files path for java on mac os X MAC_JDK_HEADERS=/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home/include -#MAC_JDK_HEADERS=/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home/bundle/Headers \ No newline at end of file +#MAC_JDK_HEADERS=/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home/bundle/Headers + +# Please edit the following: +WINDOWS_GFLAGS_DIR=..\\gflags-1.4 +WINDOWS_ZLIB_DIR=..\\zlib-1.2.5 +WINDOWS_ZLIB_NAME=zlib.lib +WINDOWS_SWIG_BINARY=..\\swigwin-2.0.0\\swig.exe +WINDOWS_PROTOBUF_DIR=..\\protobuf-2.3.0 +WINDOWS_PYTHON_DIR=c:\\Python27 +WINDOWS_PYTHON_LIB=c:\\Python27\\libs\\python27.lib +# This is the root directory of the CLP installation. Please undefine if CLP is +# not installed. If you have installed CBC, CLP_DIR can have the same value as +# CBC_DIR. +WINDOWS_CLP_DIR=..\\cbc-2.6.2 +# This is the root directory of the CBC installation. Please undefine if CBC is +# not installed. +WINDOWS_CBC_DIR=..\\cbc-2.6.2 +# This is the root directory of glpk installation. Please undefine if GLPK is +# not installed. +WINDOWS_GLPK_VER=4_45 +WINDOWS_GLPK_DIR=..\\glpk-4.45 + + +# This describes the python installation. +WINDOWS_PYTHON_INC=/Ic:\\Python27\\include +WINDOWS_PYTHON_LNK=c:\\Python27\\libs\\python27.lib + diff --git a/Makefile.unix b/Makefile.unix index 49de423352..84b4982188 100644 --- a/Makefile.unix +++ b/Makefile.unix @@ -18,14 +18,17 @@ endif # This is needed to find Coin LP include files. ifdef UNIX_CLP_DIR CLP_INC = -I$(UNIX_CLP_DIR)/include -DUSE_CLP +CLP_SWIG = $(CLP_INC) endif # This is needed to find Coin Branch and Cut include files. ifdef UNIX_CBC_DIR CBC_INC = -I$(UNIX_CBC_DIR)/include -DUSE_CBC +CBC_SWIG = $(CBC_INC) endif # This is needed to find GLPK include files. ifdef UNIX_GLPK_DIR GLPK_INC = -I$(UNIX_GLPK_DIR)/include -DUSE_GLPK +GLPK_SWIG = $(GLPK_INC) endif # Compilation flags @@ -108,9 +111,9 @@ LINKCMD=ar rv LINKPREFIX= O=o E= -PYLIBEXT=so SHAREDLIBEXT=so SPACE=$(subst ', ,'$(TEMPSPACE)) # Horrible trick to get a space in a var. LDOUT=-o$(SPACE) OBJOUT=-o EXEOUT=-o$(SPACE) +DEL=rm -f diff --git a/examples/network_routing.cc b/examples/network_routing.cc index 20a21c3e83..df0cd412da 100644 --- a/examples/network_routing.cc +++ b/examples/network_routing.cc @@ -92,6 +92,26 @@ DEFINE_int32(lns_limit, 30, "Limit the number of failures of the lns loop."); DEFINE_bool(focus_lns, true, "Focus LNS on highest cost arcs."); namespace operations_research { + +namespace { +#if defined(_MSC_VER) +// The following class defines a hash function for arcs +class ArcHasher : public stdext::hash_compare > { + public: + size_t operator() (const pair& a) const { + uint32 x = a.first; + uint32 y = 0x9e3779b9UL; + uint32 z = a.second; + mix(x, y, z); + return z; + } + bool operator() (const pair& a1, const pair& a2) const { + return a1.first < a2.first || + (a1.first == a2.first && a1.second < a2.second); + } +}; +#endif +} // ---------- Data and Data Generation ---------- // ----- Data ----- @@ -145,8 +165,13 @@ class NetworkRoutingData { int num_nodes_; int max_capacity_; int fixed_charge_cost_; +#if defined(_MSC_VER) + hash_map, int, ArcHasher> all_arcs_; + hash_map, int, ArcHasher> all_demands_; +#else hash_map, int> all_arcs_; hash_map, int> all_demands_; +#endif }; // ----- Data Generation ----- diff --git a/graph/min_cost_flow.cc b/graph/min_cost_flow.cc index 9e6a759d5d..248b2d6c97 100644 --- a/graph/min_cost_flow.cc +++ b/graph/min_cost_flow.cc @@ -1,4 +1,4 @@ -// Copyright 2010 Google + // Copyright 2010 Google // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at @@ -88,10 +88,12 @@ bool MinCostFlow::CheckCostRange() const { } VLOG(1) << "Min cost magnitude = " << min_cost_magnitude << ", Max cost magnitude = " << max_cost_magnitude; +#if !defined(_MSC_VER) CHECK_GE(log(std::numeric_limits::max()), log(max_cost_magnitude) + log(graph_.num_nodes() + 1)) << "Maximum cost is too high for the number of nodes. " << "Try changing the data."; +#endif return true; } diff --git a/graph/shortestpaths.cc b/graph/shortestpaths.cc index c93aac6daf..1c4494cbaa 100644 --- a/graph/shortestpaths.cc +++ b/graph/shortestpaths.cc @@ -19,5 +19,6 @@ #include "base/integral_types.h" #include "base/logging.h" #include "base/macros.h" + DEFINE_int32(shortestpaths_disconnected_distance, 200000, "Distance returned when two node are disconnected"); diff --git a/linear_solver/cbc_interface.cc b/linear_solver/cbc_interface.cc index eb2386d132..d472484c0c 100644 --- a/linear_solver/cbc_interface.cc +++ b/linear_solver/cbc_interface.cc @@ -38,7 +38,11 @@ #include "coin/CglClique.hpp" #include "coin/CglFlowCover.hpp" #include "coin/CglMixedIntegerRounding.hpp" +#if defined(_MSC_VER) +#include "coin/configall_system.h" +#else #include "coin/config_cbc.h" +#endif // Heuristics diff --git a/util/packed_array.h b/util/packed_array.h index 07a94a0842..97cbb5e8e7 100644 --- a/util/packed_array.h +++ b/util/packed_array.h @@ -16,7 +16,7 @@ #if defined(__APPLE__) && defined(__GNUC__) #include -#else +#elif !defined(_MSC_VER) #include #endif #include