Merge branch 'master' of https://github.com/google/or-tools
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
Protobuf = 3.5.0
|
||||
Protobuf = 3.5.1
|
||||
gflags = 2.2.1
|
||||
glog = 0.3.5
|
||||
Cbc = 2.9.9
|
||||
|
||||
@@ -79,40 +79,37 @@ type LinearSolverAlgorithm =
|
||||
| IP of IntegerProgramming
|
||||
|
||||
/// Max Flow Solver Result
|
||||
module MaximumFlow =
|
||||
let (|Optimal|IntOverflow|BadInput|BadResult|) status =
|
||||
match status with
|
||||
| 0 ->
|
||||
Optimal
|
||||
| 1 ->
|
||||
IntOverflow
|
||||
| 2 ->
|
||||
BadInput
|
||||
| 3 ->
|
||||
BadResult
|
||||
| unknownResult ->
|
||||
failwithf "Unknown result %i" unknownResult
|
||||
type MaximumFlowResult =
|
||||
| Optimal
|
||||
| IntegerOverflow
|
||||
| BadInput
|
||||
| BadResult
|
||||
member this.Id =
|
||||
match this with
|
||||
| Optimal -> 0
|
||||
| IntegerOverflow -> 1
|
||||
| BadInput -> 2
|
||||
| BadResult -> 3
|
||||
|
||||
/// Minimum Cost Flow Result
|
||||
module MinimumCostFlow =
|
||||
let (|NotSolved|Optimal|Feasible|Infeasible|Unbalanced|BadResult|BadCostRange|) status =
|
||||
match status with
|
||||
| 0 ->
|
||||
NotSolved
|
||||
| 1 ->
|
||||
Optimal
|
||||
| 2 ->
|
||||
Feasible
|
||||
| 3 ->
|
||||
Infeasible
|
||||
| 4 ->
|
||||
Unbalanced
|
||||
| 5 ->
|
||||
BadResult
|
||||
| 6 ->
|
||||
BadCostRange
|
||||
| unknownResult ->
|
||||
failwithf "Unknown result %i" unknownResult
|
||||
type MinimumCostFlowResult =
|
||||
| NotSolved
|
||||
| Optimal
|
||||
| Feasible
|
||||
| Infeasible
|
||||
| Unbalanced
|
||||
| BadResult
|
||||
| BadCostRange
|
||||
member this.Id =
|
||||
match this with
|
||||
| NotSolved -> 0
|
||||
| Optimal -> 1
|
||||
| Feasible -> 2
|
||||
| Infeasible -> 3
|
||||
| Unbalanced -> 4
|
||||
| BadResult -> 5
|
||||
| BadCostRange -> 6
|
||||
|
||||
|
||||
/// Knapsack Solver Algorithm
|
||||
type KnapsackSolverAlgorithm =
|
||||
|
||||
41
examples/fsharp/network-max-flow-lpSolve.fsx
Normal file
41
examples/fsharp/network-max-flow-lpSolve.fsx
Normal file
@@ -0,0 +1,41 @@
|
||||
(*
|
||||
The matrix in the problem represent the arcs versus the number of nodes
|
||||
(not including the source and sink nodes). In this problem we have 6 nodes
|
||||
and nine arcs. For maximal flow, we want to maximize the flow in the arcs
|
||||
connected to the source (in this case node 6). The answer represent the arcs
|
||||
flows.
|
||||
|
||||
The objective function vector identify the arcs we want to maximize and the lower
|
||||
and upper bounds are the arc capacities.
|
||||
|
||||
Answer:
|
||||
Objective: 12.000000
|
||||
var[0] : 1.000000
|
||||
var[1] : 4.000000
|
||||
var[2] : 5.000000
|
||||
var[3] : 2.000000
|
||||
var[4] : 4.000000
|
||||
var[5] : 0.000000
|
||||
var[6] : 6.000000
|
||||
var[7] : 6.000000
|
||||
var[8] : 1.000000
|
||||
|
||||
*)
|
||||
|
||||
#I "./lib"
|
||||
#load "Google.OrTools.FSharp.fsx"
|
||||
|
||||
open Google.OrTools.FSharp
|
||||
|
||||
let opts = SolverOpts.Default
|
||||
.Name("Max Flow with Linear Programming")
|
||||
.Goal(Maximize)
|
||||
.Objective([0.; 0.; 0.; 0.; 0.; 0.; 1.; 1.; 0.])
|
||||
.MatrixEq([[1.; 0.; 0. ;0.]; [0.; 1.; 0.; 0.]; [0.; 0.; 1.; 0.]; [0.; 0.; 0.; 1.]; [0.; -1.; 0.; 1.]; [0.; 0.; -1.; 1.]; [0.; 0.; 0.; -1.]; [0.; 0.; -1.; 0.]; [-1.; 0.; 1.; 0.]])
|
||||
.VectorEq([0.; 0.; 0.; 0.])
|
||||
.VarLowerBound([0.; 0.; 0.; 0.; 0.; 0.; 0.; 0.; 0.])
|
||||
.VarUpperBound([5.; 8.; 5.; 3.; 4.; 5.; 6.; 6.; 4.])
|
||||
.Algorithm(LP CLP)
|
||||
|
||||
let slvr = opts |> lpSolve
|
||||
slvr |> SolverSummary
|
||||
@@ -1,3 +1,33 @@
|
||||
(*
|
||||
|
||||
Copyright 2010-2017 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
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
|
||||
Answer:
|
||||
Solving max flow with 6 nodes, and 9 arcs, source=0, sink=5
|
||||
total computed flow 10, expected = 10
|
||||
Arc 1 (1 -> 0), capacity=5, computed=4, expected=4
|
||||
Arc 2 (2 -> 0), capacity=8, computed=4, expected=4
|
||||
Arc 3 (3 -> 0), capacity=5, computed=2, expected=2
|
||||
Arc 4 (4 -> 0), capacity=3, computed=0, expected=0
|
||||
Arc 5 (3 -> 1), capacity=4, computed=4, expected=4
|
||||
Arc 6 (4 -> 2), capacity=5, computed=4, expected=4
|
||||
Arc 7 (4 -> 3), capacity=6, computed=0, expected=0
|
||||
Arc 8 (5 -> 3), capacity=6, computed=6, expected=6
|
||||
Arc 9 (5 -> 4), capacity=4, computed=4, expected=4
|
||||
|
||||
*)
|
||||
|
||||
#I "./lib"
|
||||
#load "Google.OrTools.FSharp.fsx"
|
||||
|
||||
@@ -5,7 +35,7 @@ open Google.OrTools.Graph
|
||||
open Google.OrTools.FSharp
|
||||
|
||||
printfn "Max Flow Problem"
|
||||
let numNodes = 6;
|
||||
let numNodes = 6;
|
||||
let numArcs = 9;
|
||||
let tails = [0; 0; 0; 0; 1; 2; 3; 3; 4]
|
||||
let heads = [1; 2; 3; 4; 3; 4; 4; 5; 5]
|
||||
@@ -25,7 +55,7 @@ printfn "Solving max flow with %i nodes, and %i arcs, source=%i, sink=%i " numNo
|
||||
let solveStatus = maxFlow.Solve(source, sink)
|
||||
|
||||
match solveStatus with
|
||||
| MaximumFlow.Optimal ->
|
||||
| x when x = MaximumFlowResult.Optimal.Id ->
|
||||
let totalFlow = maxFlow.OptimalFlow();
|
||||
printfn "total computed flow %i, expected = %i" totalFlow expectedTotalFlow
|
||||
|
||||
|
||||
@@ -31,7 +31,7 @@ printfn "Solving min cost flow with %i sources, and %i targets." numSources numT
|
||||
let solveStatus = minCostFlow.Solve();
|
||||
|
||||
match solveStatus with
|
||||
| MinimumCostFlow.Optimal ->
|
||||
| x when x = MinimumCostFlowResult.Optimal.Id ->
|
||||
printfn "Total computed flow cost = %i, expected = %i" (minCostFlow.OptimalCost()) expectedCost
|
||||
| _ ->
|
||||
printfn "Solving the min cost flow problem failed. Solver status: %i" solveStatus
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
# SVN tags of dependencies to checkout.
|
||||
|
||||
GFLAGS_TAG = 2.2.1
|
||||
PROTOBUF_TAG = 3.5.0
|
||||
PROTOBUF_TAG = 3.5.1
|
||||
GLOG_TAG = 0.3.5
|
||||
CBC_TAG = 2.9.9
|
||||
|
||||
@@ -226,14 +226,17 @@ dependencies/sources/glog-$(GLOG_TAG)/CMakeLists.txt:
|
||||
# Install Coin CBC.
|
||||
install_cbc: dependencies/install/bin/cbc
|
||||
|
||||
dependencies/install/bin/cbc: dependencies/sources/cbc-$(CBC_TAG)/Makefile
|
||||
cd dependencies/sources/cbc-$(CBC_TAG) && $(SET_COMPILER) make -j 4 && $(SET_COMPILER) make install
|
||||
dependencies/install/bin/cbc: dependencies/sources/Cbc-$(CBC_TAG)/Makefile
|
||||
cd dependencies/sources/Cbc-$(CBC_TAG) && $(SET_COMPILER) make -j 4 && $(SET_COMPILER) make install
|
||||
|
||||
dependencies/sources/cbc-$(CBC_TAG)/Makefile: dependencies/sources/cbc-$(CBC_TAG)/Makefile.in
|
||||
cd dependencies/sources/cbc-$(CBC_TAG) && $(SET_COMPILER) ./configure --prefix=$(OR_ROOT_FULL)/dependencies/install --disable-bzlib --without-lapack --enable-static --with-pic ADD_CXXFLAGS="-DCBC_THREAD_SAFE -DCBC_NO_INTERRUPT $(MAC_VERSION)"
|
||||
dependencies/sources/Cbc-$(CBC_TAG)/Makefile: dependencies/sources/Cbc-$(CBC_TAG)/Makefile.in
|
||||
cd dependencies/sources/Cbc-$(CBC_TAG) && $(SET_COMPILER) ./configure --prefix=$(OR_ROOT_FULL)/dependencies/install --disable-bzlib --without-lapack --enable-static --with-pic ADD_CXXFLAGS="-DCBC_THREAD_SAFE -DCBC_NO_INTERRUPT $(MAC_VERSION)"
|
||||
|
||||
dependencies/sources/cbc-$(CBC_TAG)/Makefile.in:
|
||||
svn co https://projects.coin-or.org/svn/Cbc/releases/$(CBC_TAG) dependencies/sources/cbc-$(CBC_TAG)
|
||||
CBC_ARCHIVE:=https://www.coin-or.org/download/source/Cbc/Cbc-${CBC_TAG}.tgz
|
||||
|
||||
dependencies/sources/Cbc-$(CBC_TAG)/Makefile.in:
|
||||
wget --continue -P dependencies/archives ${CBC_ARCHIVE} || (@echo wget failed to dowload $(CBC_ARCHIVE), try running 'wget -P dependencies/archives --no-check-certificate $(CBC_ARCHIVE)' then rerun 'make third_party' && exit 1)
|
||||
tar xzvf dependencies/archives/Cbc-${CBC_TAG}.tgz -C dependencies/sources/
|
||||
|
||||
# Install patchelf on linux platforms.
|
||||
dependencies/install/bin/patchelf: dependencies/sources/patchelf-0.8/Makefile
|
||||
@@ -261,8 +264,8 @@ dependencies/install/lib/protobuf.jar: dependencies/install/bin/protoc
|
||||
# Clean everything.
|
||||
clean_third_party:
|
||||
-$(DEL) Makefile.local
|
||||
-$(DELREC) dependencies/install
|
||||
-$(DELREC) dependencies/sources/cbc*
|
||||
-$(DELREC) dependencies/archives/Cbc*
|
||||
-$(DELREC) dependencies/sources/Cbc*
|
||||
-$(DELREC) dependencies/sources/coin-cbc*
|
||||
-$(DELREC) dependencies/sources/gflags*
|
||||
-$(DELREC) dependencies/sources/glog*
|
||||
@@ -280,6 +283,7 @@ clean_third_party:
|
||||
-$(DELREC) dependencies/sources/flex*
|
||||
-$(DELREC) dependencies/sources/help2man*
|
||||
-$(DELREC) dependencies/sources/patchelf*
|
||||
-$(DELREC) dependencies/install
|
||||
|
||||
# Create Makefile.local
|
||||
makefile_third_party: Makefile.local
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# tags of dependencies to checkout.
|
||||
GFLAGS_TAG = 2.2.1
|
||||
PROTOBUF_TAG = 3.5.0
|
||||
PROTOBUF_TAG = 3.5.1
|
||||
GLOG_TAG = 0.3.5
|
||||
CBC_TAG = 2.9.9
|
||||
ZLIB_TAG = 1.2.11
|
||||
@@ -164,11 +164,11 @@ ortools/gen/ortools/sat:
|
||||
|
||||
|
||||
download_third_party: \
|
||||
dependencies/archives/zlib$(ZLIB_ARCHIVE_TAG).zip \
|
||||
dependencies/archives/zlib$(ZLIB_ARCHIVE_TAG).zip \
|
||||
dependencies/sources/gflags/autogen.sh \
|
||||
dependencies/sources/protobuf/autogen.sh \
|
||||
dependencies/archives/swigwin-$(SWIG_TAG).zip \
|
||||
dependencies/sources/cbc-$(CBC_TAG)/configure
|
||||
dependencies/sources/Cbc-$(CBC_TAG)/configure
|
||||
|
||||
# Directories:
|
||||
.PHONY: install_directories
|
||||
@@ -285,37 +285,39 @@ dependencies/archives/glog-$(GLOG_TAG).zip:
|
||||
# Install Coin CBC.
|
||||
install_coin_cbc: dependencies\install\bin\cbc.exe
|
||||
|
||||
dependencies\install\bin\cbc.exe: dependencies\sources\cbc-$(CBC_TAG)\Cbc\MSVisualStudio\v10\$(CBC_PLATFORM)\cbc.exe
|
||||
copy dependencies\sources\cbc-$(CBC_TAG)\Cbc\MSVisualStudio\v10\$(CBC_PLATFORM)\*.lib dependencies\install\lib\coin
|
||||
copy dependencies\sources\cbc-$(CBC_TAG)\Cbc\src\*.hpp dependencies\install\include\coin
|
||||
copy dependencies\sources\cbc-$(CBC_TAG)\Clp\src\*.hpp dependencies\install\include\coin
|
||||
copy dependencies\sources\cbc-$(CBC_TAG)\Clp\src\OsiClp\*.hpp dependencies\install\include\coin
|
||||
copy dependencies\sources\cbc-$(CBC_TAG)\CoinUtils\src\*.hpp dependencies\install\include\coin
|
||||
copy dependencies\sources\cbc-$(CBC_TAG)\Cgl\src\*.hpp dependencies\install\include\coin
|
||||
copy dependencies\sources\cbc-$(CBC_TAG)\Osi\src\Osi\*.hpp dependencies\install\include\coin
|
||||
copy dependencies\sources\cbc-$(CBC_TAG)\Cbc\src\*.h dependencies\install\include\coin
|
||||
copy dependencies\sources\cbc-$(CBC_TAG)\Clp\src\*.h dependencies\install\include\coin
|
||||
copy dependencies\sources\cbc-$(CBC_TAG)\CoinUtils\src\*.h dependencies\install\include\coin
|
||||
copy dependencies\sources\cbc-$(CBC_TAG)\Cgl\src\*.h dependencies\install\include\coin
|
||||
copy dependencies\sources\cbc-$(CBC_TAG)\Osi\src\Osi\*.h dependencies\install\include\coin
|
||||
copy dependencies\sources\cbc-$(CBC_TAG)\Cbc\MSVisualStudio\v10\$(CBC_PLATFORM)\cbc.exe dependencies\install\bin
|
||||
dependencies\install\bin\cbc.exe: dependencies\sources\Cbc-$(CBC_TAG)\Cbc\MSVisualStudio\v10\$(CBC_PLATFORM)\cbc.exe
|
||||
copy dependencies\sources\Cbc-$(CBC_TAG)\Cbc\MSVisualStudio\v10\$(CBC_PLATFORM)\*.lib dependencies\install\lib\coin
|
||||
copy dependencies\sources\Cbc-$(CBC_TAG)\Cbc\src\*.hpp dependencies\install\include\coin
|
||||
copy dependencies\sources\Cbc-$(CBC_TAG)\Clp\src\*.hpp dependencies\install\include\coin
|
||||
copy dependencies\sources\Cbc-$(CBC_TAG)\Clp\src\OsiClp\*.hpp dependencies\install\include\coin
|
||||
copy dependencies\sources\Cbc-$(CBC_TAG)\CoinUtils\src\*.hpp dependencies\install\include\coin
|
||||
copy dependencies\sources\Cbc-$(CBC_TAG)\Cgl\src\*.hpp dependencies\install\include\coin
|
||||
copy dependencies\sources\Cbc-$(CBC_TAG)\Osi\src\Osi\*.hpp dependencies\install\include\coin
|
||||
copy dependencies\sources\Cbc-$(CBC_TAG)\Cbc\src\*.h dependencies\install\include\coin
|
||||
copy dependencies\sources\Cbc-$(CBC_TAG)\Clp\src\*.h dependencies\install\include\coin
|
||||
copy dependencies\sources\Cbc-$(CBC_TAG)\CoinUtils\src\*.h dependencies\install\include\coin
|
||||
copy dependencies\sources\Cbc-$(CBC_TAG)\Cgl\src\*.h dependencies\install\include\coin
|
||||
copy dependencies\sources\Cbc-$(CBC_TAG)\Osi\src\Osi\*.h dependencies\install\include\coin
|
||||
copy dependencies\sources\Cbc-$(CBC_TAG)\Cbc\MSVisualStudio\v10\$(CBC_PLATFORM)\cbc.exe dependencies\install\bin
|
||||
|
||||
dependencies\sources\cbc-$(CBC_TAG)\Cbc\MSVisualStudio\v10\$(CBC_PLATFORM)\cbc.exe: dependencies\sources\cbc-$(CBC_TAG)\configure
|
||||
tools\upgrade_vs_project.cmd dependencies\\sources\\cbc-$(CBC_TAG)\\Clp\\MSVisualStudio\\v10\\libOsiClp\\libOsiClp.vcxproj $(VS_RELEASE)
|
||||
tools\upgrade_vs_project.cmd dependencies\\sources\\cbc-$(CBC_TAG)\\Clp\\MSVisualStudio\\v10\\libClp\\libClp.vcxproj $(VS_RELEASE)
|
||||
tools\upgrade_vs_project.cmd dependencies\\sources\\cbc-$(CBC_TAG)\\Cbc\\MSVisualStudio\\v10\\libOsiCbc\\libOsiCbc.vcxproj $(VS_RELEASE)
|
||||
tools\upgrade_vs_project.cmd dependencies\\sources\\cbc-$(CBC_TAG)\\Cbc\\MSVisualStudio\\v10\\libCbc\\libCbc.vcxproj $(VS_RELEASE)
|
||||
tools\upgrade_vs_project.cmd dependencies\\sources\\cbc-$(CBC_TAG)\\Cbc\\MSVisualStudio\\v10\\cbc\\cbc.vcxproj $(VS_RELEASE)
|
||||
tools\upgrade_vs_project.cmd dependencies\\sources\\cbc-$(CBC_TAG)\\Cbc\\MSVisualStudio\\v10\\libCbcSolver\\libCbcSolver.vcxproj $(VS_RELEASE)
|
||||
tools\upgrade_vs_project.cmd dependencies\\sources\\cbc-$(CBC_TAG)\\Osi\\MSVisualStudio\\v10\\libOsi\\libOsi.vcxproj $(VS_RELEASE)
|
||||
tools\upgrade_vs_project.cmd dependencies\\sources\\cbc-$(CBC_TAG)\\CoinUtils\\MSVisualStudio\\v10\\libCoinUtils\\libCoinUtils.vcxproj $(VS_RELEASE)
|
||||
tools\upgrade_vs_project.cmd dependencies\\sources\\cbc-$(CBC_TAG)\\Cgl\\MSVisualStudio\\v10\\libCgl\\libCgl.vcxproj $(VS_RELEASE)
|
||||
tools\sed -i 's/CBC_BUILD;/CBC_BUILD;CBC_THREAD_SAFE;CBC_NO_INTERRUPT;/g' dependencies\\sources\\cbc-$(CBC_TAG)\\Cbc\\MSVisualStudio\\v10\\libCbcSolver\\libCbcSolver.vcxproj
|
||||
cd dependencies\sources\cbc-$(CBC_TAG)\Cbc\MSVisualStudio\v10 && msbuild Cbc.sln /t:cbc /p:Configuration=Release;BuildCmd=ReBuild
|
||||
dependencies\sources\Cbc-$(CBC_TAG)\Cbc\MSVisualStudio\v10\$(CBC_PLATFORM)\cbc.exe: dependencies\sources\Cbc-$(CBC_TAG)\configure
|
||||
tools\upgrade_vs_project.cmd dependencies\\sources\\Cbc-$(CBC_TAG)\\Clp\\MSVisualStudio\\v10\\libOsiClp\\libOsiClp.vcxproj $(VS_RELEASE)
|
||||
tools\upgrade_vs_project.cmd dependencies\\sources\\Cbc-$(CBC_TAG)\\Clp\\MSVisualStudio\\v10\\libClp\\libClp.vcxproj $(VS_RELEASE)
|
||||
tools\upgrade_vs_project.cmd dependencies\\sources\\Cbc-$(CBC_TAG)\\Cbc\\MSVisualStudio\\v10\\libOsiCbc\\libOsiCbc.vcxproj $(VS_RELEASE)
|
||||
tools\upgrade_vs_project.cmd dependencies\\sources\\Cbc-$(CBC_TAG)\\Cbc\\MSVisualStudio\\v10\\libCbc\\libCbc.vcxproj $(VS_RELEASE)
|
||||
tools\upgrade_vs_project.cmd dependencies\\sources\\Cbc-$(CBC_TAG)\\Cbc\\MSVisualStudio\\v10\\cbc\\cbc.vcxproj $(VS_RELEASE)
|
||||
tools\upgrade_vs_project.cmd dependencies\\sources\\Cbc-$(CBC_TAG)\\Cbc\\MSVisualStudio\\v10\\libCbcSolver\\libCbcSolver.vcxproj $(VS_RELEASE)
|
||||
tools\upgrade_vs_project.cmd dependencies\\sources\\Cbc-$(CBC_TAG)\\Osi\\MSVisualStudio\\v10\\libOsi\\libOsi.vcxproj $(VS_RELEASE)
|
||||
tools\upgrade_vs_project.cmd dependencies\\sources\\Cbc-$(CBC_TAG)\\CoinUtils\\MSVisualStudio\\v10\\libCoinUtils\\libCoinUtils.vcxproj $(VS_RELEASE)
|
||||
tools\upgrade_vs_project.cmd dependencies\\sources\\Cbc-$(CBC_TAG)\\Cgl\\MSVisualStudio\\v10\\libCgl\\libCgl.vcxproj $(VS_RELEASE)
|
||||
tools\sed -i 's/CBC_BUILD;/CBC_BUILD;CBC_THREAD_SAFE;CBC_NO_INTERRUPT;/g' dependencies\\sources\\Cbc-$(CBC_TAG)\\Cbc\\MSVisualStudio\\v10\\libCbcSolver\\libCbcSolver.vcxproj
|
||||
cd dependencies\sources\Cbc-$(CBC_TAG)\Cbc\MSVisualStudio\v10 && msbuild Cbc.sln /t:cbc /p:Configuration=Release;BuildCmd=ReBuild
|
||||
|
||||
dependencies\sources\cbc-$(CBC_TAG)\configure:
|
||||
svn co https://projects.coin-or.org/svn/Cbc/releases/$(CBC_TAG) dependencies/sources/cbc-$(CBC_TAG)
|
||||
CBC_ARCHIVE:=https://www.coin-or.org/download/source/Cbc/Cbc-${CBC_TAG}.zip
|
||||
|
||||
dependencies\sources\Cbc-$(CBC_TAG)\configure:
|
||||
tools\wget --continue -P dependencies\archives --no-check-certificate ${CBC_ARCHIVE} || (@echo wget failed to dowload $(CBC_ARCHIVE), try running 'tools\wget -P dependencies\archives --no-check-certificate $(CBC_ARCHIVE)' then rerun 'make third_party' && exit 1)
|
||||
tools\unzip -d dependencies\sources dependencies\archives\Cbc-$(CBC_TAG).zip
|
||||
|
||||
# Install SWIG.
|
||||
install_swig: dependencies\install\swigwin-$(SWIG_TAG)\swig.exe
|
||||
@@ -344,24 +346,24 @@ kill_tortoisesvn_cache:
|
||||
remove_readonly_svn_attribs: kill_tortoisesvn_cache
|
||||
if exist dependencies\sources\* $(ATTRIB) -r /s dependencies\sources\*
|
||||
|
||||
|
||||
# Clean everything. Remember to also delete archived dependencies, i.e. in the event of download failure, etc.
|
||||
clean_third_party: remove_readonly_svn_attribs
|
||||
-$(DEL) Makefile.local
|
||||
-$(DEL) dependencies\archives\swigwin*.zip
|
||||
-$(DEL) dependencies\archives\Cbc*
|
||||
-$(DEL) dependencies\archives\gflags*.zip
|
||||
-$(DEL) dependencies\archives\sparsehash*.zip
|
||||
-$(DEL) dependencies\archives\zlib*.zip
|
||||
-$(DEL) dependencies\archives\v*.zip
|
||||
-$(DEL) dependencies\archives\win_flex_bison*.zip
|
||||
-$(DELREC) dependencies\install
|
||||
-$(DELREC) dependencies\sources\cbc-*
|
||||
-$(DELREC) dependencies\sources\Cbc-*
|
||||
-$(DELREC) dependencies\sources\gflags*
|
||||
-$(DELREC) dependencies\sources\glpk*
|
||||
-$(DELREC) dependencies\sources\google*
|
||||
-$(DELREC) dependencies\sources\protobuf*
|
||||
-$(DELREC) dependencies\sources\sparsehash*
|
||||
-$(DELREC) dependencies\sources\zlib*
|
||||
-$(DELREC) dependencies\install
|
||||
|
||||
# Create Makefile.local
|
||||
makefile_third_party: Makefile.local
|
||||
|
||||
33
test.py.in
Normal file
33
test.py.in
Normal file
@@ -0,0 +1,33 @@
|
||||
from ortools.linear_solver import pywraplp
|
||||
from ortools.constraint_solver import pywrapcp
|
||||
from ortools.sat import pywrapsat
|
||||
from ortools.graph import pywrapgraph
|
||||
from ortools.algorithms import pywrapknapsack_solver
|
||||
from ortools.data import pywraprcpsp
|
||||
|
||||
def lpsolver():
|
||||
print('Test lpsolver...')
|
||||
lpsolver = pywraplp.Solver(
|
||||
'LinearTest',
|
||||
pywraplp.Solver.GLOP_LINEAR_PROGRAMMING)
|
||||
lpsolver.Solve()
|
||||
print('Test lpsolver...DONE')
|
||||
|
||||
def cpsolver():
|
||||
print('Test cpsolver...')
|
||||
cpsolver = pywrapcp.Solver('ConstraintTest')
|
||||
num_vals = 3
|
||||
x = cpsolver.IntVar(0, num_vals - 1, "x")
|
||||
y = cpsolver.IntVar(0, num_vals - 1, "y")
|
||||
z = cpsolver.IntVar(0, num_vals - 1, "z")
|
||||
cpsolver.Add(x != y)
|
||||
db = cpsolver.Phase([x, y, z], cpsolver.CHOOSE_FIRST_UNBOUND, cpsolver.ASSIGN_MIN_VALUE)
|
||||
cpsolver.Solve(db)
|
||||
print('Test cpsolver...DONE')
|
||||
|
||||
def main():
|
||||
lpsolver()
|
||||
cpsolver()
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
@@ -1,34 +1,74 @@
|
||||
#!/bin/bash
|
||||
echo Cleaning or-tools
|
||||
make clean
|
||||
echo Builing all libraries
|
||||
make all fz -j 5 UNIX_PYTHON_VER=2.7
|
||||
echo Running tests
|
||||
make test UNIX_PYTHON_VER=2.7
|
||||
set -x
|
||||
set -e
|
||||
|
||||
echo Creating standard artifacts.
|
||||
echo Rebuilding or-tools...
|
||||
make clean
|
||||
make all fz -j 5 UNIX_PYTHON_VER=2.7
|
||||
make test UNIX_PYTHON_VER=2.7
|
||||
echo Rebuilding or-tools...DONE
|
||||
|
||||
echo Creating standard artifacts...
|
||||
rm -rf temp *.tar.gz
|
||||
make archive fz_archive python_examples_archive UNIX_PYTHON_VER=2.7
|
||||
make clean_python UNIX_PYTHON_VER=2.7
|
||||
echo Creating standard artifacts...DONE
|
||||
|
||||
echo Rebuilding for python 2.7
|
||||
rm -rf temp-python2.7
|
||||
echo Rebuilding for Python 2.7...
|
||||
make clean_python UNIX_PYTHON_VER=2.7
|
||||
make python UNIX_PYTHON_VER=2.7 -j 5
|
||||
make test_python UNIX_PYTHON_VER=2.7
|
||||
make pypi_upload UNIX_PYTHON_VER=2.7
|
||||
make clean_python UNIX_PYTHON_VER=2.7
|
||||
make pypi_archive UNIX_PYTHON_VER=2.7
|
||||
echo Rebuilding for Python 2.7...DONE
|
||||
echo Creating Python 2.7 venv...
|
||||
TEMP_DIR=temp-python2.7
|
||||
VENV_DIR=${TEMP_DIR}/venv
|
||||
python2.7 -m pip install --user virtualenv
|
||||
python2.7 -m virtualenv -p python2.7 ${VENV_DIR}
|
||||
VENV_BIN=${VENV_DIR}/bin/python
|
||||
# Bug: setup.py must be run in this directory !
|
||||
(cd ${TEMP_DIR}/ortools && ../venv/bin/python setup.py install)
|
||||
cp test.py.in ${TEMP_DIR}/venv/test.py
|
||||
echo Creating Python 2.7 venv...DONE
|
||||
|
||||
echo Rebuilding for python 3.5
|
||||
rm -rf temp-python3.5
|
||||
echo Rebuilding for Python 3.5
|
||||
make clean_python UNIX_PYTHON_VER=3.5
|
||||
make python UNIX_PYTHON_VER=3.5 -j 5
|
||||
make test_python UNIX_PYTHON_VER=3.5
|
||||
make pypi_upload UNIX_PYTHON_VER=3.5
|
||||
make clean_python UNIX_PYTHON_VER=3.5
|
||||
make pypi_archive UNIX_PYTHON_VER=3.5
|
||||
echo Rebuilding for Python 3.5...DONE
|
||||
echo Creating Python 3.5 venv...
|
||||
TEMP_DIR=temp-python3.5
|
||||
VENV_DIR=${TEMP_DIR}/venv
|
||||
python3.5 -m pip install --user virtualenv
|
||||
python3.5 -m virtualenv -p python3.5 ${VENV_DIR}
|
||||
VENV_BIN=${VENV_DIR}/bin/python
|
||||
# Bug: setup.py must be run in this directory !
|
||||
(cd ${TEMP_DIR}/ortools && ../venv/bin/python setup.py install)
|
||||
cp test.py.in ${TEMP_DIR}/venv/test.py
|
||||
echo Creating Python 3.5 venv...DONE
|
||||
|
||||
echo Rebuilding for python 3.6
|
||||
rm -rf temp-python3.6
|
||||
echo Rebuilding for Python 3.6
|
||||
make clean_python UNIX_PYTHON_VER=3.6
|
||||
make python UNIX_PYTHON_VER=3.6 -j 5
|
||||
make test_python UNIX_PYTHON_VER=3.6
|
||||
make pypi_upload UNIX_PYTHON_VER=3.6
|
||||
make clean_python UNIX_PYTHON_VER=3.6
|
||||
make pypi_archive UNIX_PYTHON_VER=3.6
|
||||
echo Rebuilding for Python 3.6...DONE
|
||||
echo Creating Python 3.6 venv...
|
||||
TEMP_DIR=temp-python3.6
|
||||
VENV_DIR=${TEMP_DIR}/venv
|
||||
python3.6 -m pip install --user virtualenv
|
||||
python3.6 -m virtualenv -p python3.6 ${VENV_DIR}
|
||||
VENV_BIN=${VENV_DIR}/bin/python
|
||||
# Bug: setup.py must be run in this directory !
|
||||
(cd ${TEMP_DIR}/ortools && ../venv/bin/python setup.py install)
|
||||
cp test.py.in ${TEMP_DIR}/venv/test.py
|
||||
echo Creating Python 3.6 venv...DONE
|
||||
|
||||
# To be sure to have sandboxed library (i.e. @loader_path)
|
||||
make clean_cc
|
||||
|
||||
echo Testing in virtualenv...
|
||||
temp-python2.7/venv/bin/python temp-python2.7/venv/test.py
|
||||
temp-python3.5/venv/bin/python temp-python3.5/venv/test.py
|
||||
temp-python3.6/venv/bin/python temp-python3.6/venv/test.py
|
||||
echo Testing in virtualenv...DONE
|
||||
|
||||
@@ -5,4 +5,5 @@ install_name_tool -change $P @loader_path/../libortools.dylib $1/ortools/ortools
|
||||
install_name_tool -change $P @loader_path/../libortools.dylib $1/ortools/ortools/constraint_solver/_pywrapcp.so
|
||||
install_name_tool -change $P @loader_path/../libortools.dylib $1/ortools/ortools/graph/_pywrapgraph.so
|
||||
install_name_tool -change $P @loader_path/../libortools.dylib $1/ortools/ortools/linear_solver/_pywraplp.so
|
||||
install_name_tool -change $P @loader_path/../libortools.dylib $1/ortools/ortools/linear_solver/_pywrapsat.so
|
||||
install_name_tool -change $P @loader_path/../libortools.dylib $1/ortools/ortools/sat/_pywrapsat.so
|
||||
install_name_tool -change $P @loader_path/../libortools.dylib $1/ortools/ortools/data/_pywraprcpsp.so
|
||||
|
||||
9
tools/publish_delivery_mac.sh
Executable file
9
tools/publish_delivery_mac.sh
Executable file
@@ -0,0 +1,9 @@
|
||||
#!/bin/bash
|
||||
set -x
|
||||
set -e
|
||||
|
||||
echo Uploading all Python artifacts...
|
||||
make pypi_upload UNIX_PYTHON_VER=2.7
|
||||
make pypi_upload UNIX_PYTHON_VER=3.5
|
||||
make pypi_upload UNIX_PYTHON_VER=3.6
|
||||
echo Uploading all Python artifacts...DONE
|
||||
Reference in New Issue
Block a user