From 5a55bb655af826acbfa952b344bf60f72fc8ffa7 Mon Sep 17 00:00:00 2001 From: Corentin Le Molgat Date: Fri, 7 Sep 2018 10:02:02 +0200 Subject: [PATCH] Update FSharp examples so all use .NetCoreApp2.1 --- examples/dotnet/README.md | 31 ++++++++++++++++--- ...rogramming.fsx => csintegerprogramming.fs} | 0 examples/dotnet/csintegerprogramming.fsproj | 19 ++++++++++++ ...programming.fsx => cslinearprogramming.fs} | 0 examples/dotnet/cslinearprogramming.fsproj | 19 ++++++++++++ .../dotnet/{fsharp-netfx/diet.fsx => diet.fs} | 0 examples/dotnet/diet.fsproj | 19 ++++++++++++ ...-inequality.fsx => equality-inequality.fs} | 0 examples/dotnet/equality-inequality.fsproj | 19 ++++++++++++ .../equality.fsx => equality.fs} | 0 examples/dotnet/equality.fsproj | 19 ++++++++++++ examples/dotnet/fsharp-netfx/README.md | 18 ----------- examples/dotnet/fsharp-netfx/packages.config | 4 --- ...-program.fsx => integer-linear-program.fs} | 0 examples/dotnet/integer-linear-program.fsproj | 19 ++++++++++++ .../knapsack.fsx => knapsack.fs} | 0 examples/dotnet/knapsack.fsproj | 19 ++++++++++++ ...pSolve.fsx => network-max-flow-lpSolve.fs} | 0 .../dotnet/network-max-flow-lpSolve.fsproj | 19 ++++++++++++ ...twork-max-flow.fsx => network-max-flow.fs} | 0 examples/dotnet/network-max-flow.fsproj | 19 ++++++++++++ ...cost-flow.fsx => network-min-cost-flow.fs} | 0 examples/dotnet/network-min-cost-flow.fsproj | 19 ++++++++++++ ...rabbit-pheasant.fsx => rabbit-pheasant.fs} | 0 examples/dotnet/rabbit-pheasant.fsproj | 19 ++++++++++++ .../{fsharp-netfx/volsay.fsx => volsay.fs} | 0 examples/dotnet/volsay.fsproj | 19 ++++++++++++ ...volsay3-lpSolve.fsx => volsay3-lpSolve.fs} | 0 examples/dotnet/volsay3-lpSolve.fsproj | 19 ++++++++++++ .../{fsharp-netfx/volsay3.fsx => volsay3.fs} | 0 examples/dotnet/volsay3.fsproj | 19 ++++++++++++ makefiles/Makefile.dotnet.mk | 30 +++++++++++++----- ...tnet_csproj.sh => generate_dotnet_proj.sh} | 1 + 33 files changed, 317 insertions(+), 33 deletions(-) rename examples/dotnet/{fsharp-netfx/csintegerprogramming.fsx => csintegerprogramming.fs} (100%) create mode 100644 examples/dotnet/csintegerprogramming.fsproj rename examples/dotnet/{fsharp-netfx/cslinearprogramming.fsx => cslinearprogramming.fs} (100%) create mode 100644 examples/dotnet/cslinearprogramming.fsproj rename examples/dotnet/{fsharp-netfx/diet.fsx => diet.fs} (100%) create mode 100644 examples/dotnet/diet.fsproj rename examples/dotnet/{fsharp-netfx/equality-inequality.fsx => equality-inequality.fs} (100%) create mode 100644 examples/dotnet/equality-inequality.fsproj rename examples/dotnet/{fsharp-netfx/equality.fsx => equality.fs} (100%) create mode 100644 examples/dotnet/equality.fsproj delete mode 100644 examples/dotnet/fsharp-netfx/README.md delete mode 100644 examples/dotnet/fsharp-netfx/packages.config rename examples/dotnet/{fsharp-netfx/integer-linear-program.fsx => integer-linear-program.fs} (100%) create mode 100644 examples/dotnet/integer-linear-program.fsproj rename examples/dotnet/{fsharp-netfx/knapsack.fsx => knapsack.fs} (100%) create mode 100644 examples/dotnet/knapsack.fsproj rename examples/dotnet/{fsharp-netfx/network-max-flow-lpSolve.fsx => network-max-flow-lpSolve.fs} (100%) create mode 100644 examples/dotnet/network-max-flow-lpSolve.fsproj rename examples/dotnet/{fsharp-netfx/network-max-flow.fsx => network-max-flow.fs} (100%) create mode 100644 examples/dotnet/network-max-flow.fsproj rename examples/dotnet/{fsharp-netfx/network-min-cost-flow.fsx => network-min-cost-flow.fs} (100%) create mode 100644 examples/dotnet/network-min-cost-flow.fsproj rename examples/dotnet/{fsharp-netfx/rabbit-pheasant.fsx => rabbit-pheasant.fs} (100%) create mode 100644 examples/dotnet/rabbit-pheasant.fsproj rename examples/dotnet/{fsharp-netfx/volsay.fsx => volsay.fs} (100%) create mode 100644 examples/dotnet/volsay.fsproj rename examples/dotnet/{fsharp-netfx/volsay3-lpSolve.fsx => volsay3-lpSolve.fs} (100%) create mode 100644 examples/dotnet/volsay3-lpSolve.fsproj rename examples/dotnet/{fsharp-netfx/volsay3.fsx => volsay3.fs} (100%) create mode 100644 examples/dotnet/volsay3.fsproj rename tools/{generate_dotnet_csproj.sh => generate_dotnet_proj.sh} (99%) diff --git a/examples/dotnet/README.md b/examples/dotnet/README.md index ab7edca2f5..0ad3524657 100644 --- a/examples/dotnet/README.md +++ b/examples/dotnet/README.md @@ -1,4 +1,4 @@ -# Dotnet Core examples +# .NetCoreApp examples The following examples showcase how to use OrTools. The project solution has examples for both C# and F#. @@ -10,8 +10,31 @@ Wherever you have or-tools installed, be sure to `PackageReference` the `Google. from the project file. ## Execution -Running the examples will involve compiling them, then running them. You can run the following command: -```bash -dotnet run --project examples/dotnet/.csproj +Running the examples will involve building them, then running them. +You can run the following command: +```shell +dotnet build examples/dotnet/.csproj +dotnet run --no-build --project examples/dotnet/.csproj +``` + +# Note on Google.OrTools.FSharp +This part describes how to use Google.OrTools.FSharp nuget package in F#. + +## SolverOptions and lpSolve +This function and parameter object are a wrapper around the standard Google.OrTools functions. +It is designed to enter the Linear/Integer program as *matrices* and *vectors*. + +Two input formats are allowed: +* Canonical Form; +* Standard Form. + +**ALL Matrices & Vectors are entered as columns** + +## Execution +Running the examples will involve building them, then running them. +You can run the following command: +```shell +dotnet build examples/dotnet/.fsproj +dotnet run --no-build --project examples/dotnet/.fsproj ``` diff --git a/examples/dotnet/fsharp-netfx/csintegerprogramming.fsx b/examples/dotnet/csintegerprogramming.fs similarity index 100% rename from examples/dotnet/fsharp-netfx/csintegerprogramming.fsx rename to examples/dotnet/csintegerprogramming.fs diff --git a/examples/dotnet/csintegerprogramming.fsproj b/examples/dotnet/csintegerprogramming.fsproj new file mode 100644 index 0000000000..30b2b304e0 --- /dev/null +++ b/examples/dotnet/csintegerprogramming.fsproj @@ -0,0 +1,19 @@ + + + Exe + netcoreapp2.1 + false + ../../packages;$(RestoreSources);https://api.nuget.org/v3/index.json + + + + full + true + true + + + + + + + diff --git a/examples/dotnet/fsharp-netfx/cslinearprogramming.fsx b/examples/dotnet/cslinearprogramming.fs similarity index 100% rename from examples/dotnet/fsharp-netfx/cslinearprogramming.fsx rename to examples/dotnet/cslinearprogramming.fs diff --git a/examples/dotnet/cslinearprogramming.fsproj b/examples/dotnet/cslinearprogramming.fsproj new file mode 100644 index 0000000000..e2decafe3b --- /dev/null +++ b/examples/dotnet/cslinearprogramming.fsproj @@ -0,0 +1,19 @@ + + + Exe + netcoreapp2.1 + false + ../../packages;$(RestoreSources);https://api.nuget.org/v3/index.json + + + + full + true + true + + + + + + + diff --git a/examples/dotnet/fsharp-netfx/diet.fsx b/examples/dotnet/diet.fs similarity index 100% rename from examples/dotnet/fsharp-netfx/diet.fsx rename to examples/dotnet/diet.fs diff --git a/examples/dotnet/diet.fsproj b/examples/dotnet/diet.fsproj new file mode 100644 index 0000000000..0ebbcad4f4 --- /dev/null +++ b/examples/dotnet/diet.fsproj @@ -0,0 +1,19 @@ + + + Exe + netcoreapp2.1 + false + ../../packages;$(RestoreSources);https://api.nuget.org/v3/index.json + + + + full + true + true + + + + + + + diff --git a/examples/dotnet/fsharp-netfx/equality-inequality.fsx b/examples/dotnet/equality-inequality.fs similarity index 100% rename from examples/dotnet/fsharp-netfx/equality-inequality.fsx rename to examples/dotnet/equality-inequality.fs diff --git a/examples/dotnet/equality-inequality.fsproj b/examples/dotnet/equality-inequality.fsproj new file mode 100644 index 0000000000..699eb1fc1c --- /dev/null +++ b/examples/dotnet/equality-inequality.fsproj @@ -0,0 +1,19 @@ + + + Exe + netcoreapp2.1 + false + ../../packages;$(RestoreSources);https://api.nuget.org/v3/index.json + + + + full + true + true + + + + + + + diff --git a/examples/dotnet/fsharp-netfx/equality.fsx b/examples/dotnet/equality.fs similarity index 100% rename from examples/dotnet/fsharp-netfx/equality.fsx rename to examples/dotnet/equality.fs diff --git a/examples/dotnet/equality.fsproj b/examples/dotnet/equality.fsproj new file mode 100644 index 0000000000..05c8d78254 --- /dev/null +++ b/examples/dotnet/equality.fsproj @@ -0,0 +1,19 @@ + + + Exe + netcoreapp2.1 + false + ../../packages;$(RestoreSources);https://api.nuget.org/v3/index.json + + + + full + true + true + + + + + + + diff --git a/examples/dotnet/fsharp-netfx/README.md b/examples/dotnet/fsharp-netfx/README.md deleted file mode 100644 index 53dd9ba808..0000000000 --- a/examples/dotnet/fsharp-netfx/README.md +++ /dev/null @@ -1,18 +0,0 @@ -# Examples of using or-tools in FSharp - -This file describes how to use the or-tools .NET binary archive in F# - -## SolverOptions and lpSolve -This function and parameter object are a wrapper around the standard or-tools functions. It is designed -to enter the Linear/Integer program as matrices & vectors. Two input formats are allowed: Canonical Form; Standard Form. - -*__ALL Matrices & Vectors are entered as columns__* - -## Execution -Be sure to compile the or-tools (native & managed F# library) before executing following -```shell -fsharpc --target:exe --out:bin/.exe --platform:anycpu --lib:bin examples/fsharp/.fsx - -DYLD_FALLBACK_LIBRARY_PATH=lib mono bin/.exe - -``` diff --git a/examples/dotnet/fsharp-netfx/packages.config b/examples/dotnet/fsharp-netfx/packages.config deleted file mode 100644 index 6bfae13b5f..0000000000 --- a/examples/dotnet/fsharp-netfx/packages.config +++ /dev/null @@ -1,4 +0,0 @@ - - - - \ No newline at end of file diff --git a/examples/dotnet/fsharp-netfx/integer-linear-program.fsx b/examples/dotnet/integer-linear-program.fs similarity index 100% rename from examples/dotnet/fsharp-netfx/integer-linear-program.fsx rename to examples/dotnet/integer-linear-program.fs diff --git a/examples/dotnet/integer-linear-program.fsproj b/examples/dotnet/integer-linear-program.fsproj new file mode 100644 index 0000000000..e4001198f5 --- /dev/null +++ b/examples/dotnet/integer-linear-program.fsproj @@ -0,0 +1,19 @@ + + + Exe + netcoreapp2.1 + false + ../../packages;$(RestoreSources);https://api.nuget.org/v3/index.json + + + + full + true + true + + + + + + + diff --git a/examples/dotnet/fsharp-netfx/knapsack.fsx b/examples/dotnet/knapsack.fs similarity index 100% rename from examples/dotnet/fsharp-netfx/knapsack.fsx rename to examples/dotnet/knapsack.fs diff --git a/examples/dotnet/knapsack.fsproj b/examples/dotnet/knapsack.fsproj new file mode 100644 index 0000000000..0997e10293 --- /dev/null +++ b/examples/dotnet/knapsack.fsproj @@ -0,0 +1,19 @@ + + + Exe + netcoreapp2.1 + false + ../../packages;$(RestoreSources);https://api.nuget.org/v3/index.json + + + + full + true + true + + + + + + + diff --git a/examples/dotnet/fsharp-netfx/network-max-flow-lpSolve.fsx b/examples/dotnet/network-max-flow-lpSolve.fs similarity index 100% rename from examples/dotnet/fsharp-netfx/network-max-flow-lpSolve.fsx rename to examples/dotnet/network-max-flow-lpSolve.fs diff --git a/examples/dotnet/network-max-flow-lpSolve.fsproj b/examples/dotnet/network-max-flow-lpSolve.fsproj new file mode 100644 index 0000000000..b807e8f0a0 --- /dev/null +++ b/examples/dotnet/network-max-flow-lpSolve.fsproj @@ -0,0 +1,19 @@ + + + Exe + netcoreapp2.1 + false + ../../packages;$(RestoreSources);https://api.nuget.org/v3/index.json + + + + full + true + true + + + + + + + diff --git a/examples/dotnet/fsharp-netfx/network-max-flow.fsx b/examples/dotnet/network-max-flow.fs similarity index 100% rename from examples/dotnet/fsharp-netfx/network-max-flow.fsx rename to examples/dotnet/network-max-flow.fs diff --git a/examples/dotnet/network-max-flow.fsproj b/examples/dotnet/network-max-flow.fsproj new file mode 100644 index 0000000000..9d00c78854 --- /dev/null +++ b/examples/dotnet/network-max-flow.fsproj @@ -0,0 +1,19 @@ + + + Exe + netcoreapp2.1 + false + ../../packages;$(RestoreSources);https://api.nuget.org/v3/index.json + + + + full + true + true + + + + + + + diff --git a/examples/dotnet/fsharp-netfx/network-min-cost-flow.fsx b/examples/dotnet/network-min-cost-flow.fs similarity index 100% rename from examples/dotnet/fsharp-netfx/network-min-cost-flow.fsx rename to examples/dotnet/network-min-cost-flow.fs diff --git a/examples/dotnet/network-min-cost-flow.fsproj b/examples/dotnet/network-min-cost-flow.fsproj new file mode 100644 index 0000000000..99116c3add --- /dev/null +++ b/examples/dotnet/network-min-cost-flow.fsproj @@ -0,0 +1,19 @@ + + + Exe + netcoreapp2.1 + false + ../../packages;$(RestoreSources);https://api.nuget.org/v3/index.json + + + + full + true + true + + + + + + + diff --git a/examples/dotnet/fsharp-netfx/rabbit-pheasant.fsx b/examples/dotnet/rabbit-pheasant.fs similarity index 100% rename from examples/dotnet/fsharp-netfx/rabbit-pheasant.fsx rename to examples/dotnet/rabbit-pheasant.fs diff --git a/examples/dotnet/rabbit-pheasant.fsproj b/examples/dotnet/rabbit-pheasant.fsproj new file mode 100644 index 0000000000..bd63d7c237 --- /dev/null +++ b/examples/dotnet/rabbit-pheasant.fsproj @@ -0,0 +1,19 @@ + + + Exe + netcoreapp2.1 + false + ../../packages;$(RestoreSources);https://api.nuget.org/v3/index.json + + + + full + true + true + + + + + + + diff --git a/examples/dotnet/fsharp-netfx/volsay.fsx b/examples/dotnet/volsay.fs similarity index 100% rename from examples/dotnet/fsharp-netfx/volsay.fsx rename to examples/dotnet/volsay.fs diff --git a/examples/dotnet/volsay.fsproj b/examples/dotnet/volsay.fsproj new file mode 100644 index 0000000000..a02c78508a --- /dev/null +++ b/examples/dotnet/volsay.fsproj @@ -0,0 +1,19 @@ + + + Exe + netcoreapp2.1 + false + ../../packages;$(RestoreSources);https://api.nuget.org/v3/index.json + + + + full + true + true + + + + + + + diff --git a/examples/dotnet/fsharp-netfx/volsay3-lpSolve.fsx b/examples/dotnet/volsay3-lpSolve.fs similarity index 100% rename from examples/dotnet/fsharp-netfx/volsay3-lpSolve.fsx rename to examples/dotnet/volsay3-lpSolve.fs diff --git a/examples/dotnet/volsay3-lpSolve.fsproj b/examples/dotnet/volsay3-lpSolve.fsproj new file mode 100644 index 0000000000..71849ed924 --- /dev/null +++ b/examples/dotnet/volsay3-lpSolve.fsproj @@ -0,0 +1,19 @@ + + + Exe + netcoreapp2.1 + false + ../../packages;$(RestoreSources);https://api.nuget.org/v3/index.json + + + + full + true + true + + + + + + + diff --git a/examples/dotnet/fsharp-netfx/volsay3.fsx b/examples/dotnet/volsay3.fs similarity index 100% rename from examples/dotnet/fsharp-netfx/volsay3.fsx rename to examples/dotnet/volsay3.fs diff --git a/examples/dotnet/volsay3.fsproj b/examples/dotnet/volsay3.fsproj new file mode 100644 index 0000000000..01360b628a --- /dev/null +++ b/examples/dotnet/volsay3.fsproj @@ -0,0 +1,19 @@ + + + Exe + netcoreapp2.1 + false + ../../packages;$(RestoreSources);https://api.nuget.org/v3/index.json + + + + full + true + true + + + + + + + diff --git a/makefiles/Makefile.dotnet.mk b/makefiles/Makefile.dotnet.mk index 12f0efb9e4..7f6a358382 100644 --- a/makefiles/Makefile.dotnet.mk +++ b/makefiles/Makefile.dotnet.mk @@ -402,8 +402,10 @@ test_dotnet_fsharp: $(DOTNET_ORTOOLS_FSHARP_NUPKG) \ ## .NET Examples/Samples ## ############################# .PHONY: test_donet_examples # Build and Run all .Net Examples (located in examples/dotnet) -test_dotnet_examples: $(DOTNET_ORTOOLS_NUPKG) -# csharp examples +test_dotnet_examples: test_donet_examples_csharp test_donet_examples_fsharp + +.PHONY: test_donet_examples_csharp # Build and Run all CSharp Examples (located in examples/dotnet) +test_dotnet_examples_csharp: $(DOTNET_ORTOOLS_NUPKG) $(MAKE) rdotnet_3_jugs_regular $(MAKE) rdotnet_alldifferent_except_0 $(MAKE) rdotnet_all_interval @@ -527,8 +529,24 @@ endif $(MAKE) rdotnet_xkcd $(MAKE) rdotnet_young_tableaux $(MAKE) rdotnet_zebra -# fsharp examples + +.PHONY: test_donet_examples_fsharp # Build and Run all FSharp Samples (located in examples/dotnet) +test_dotnet_examples_fsharp: $(DOTNET_ORTOOLS_FSHARP_NUPKG) + $(MAKE) rdotnet_csintegerprogramming + $(MAKE) rdotnet_cslinearprogramming + $(MAKE) rdotnet_diet + $(MAKE) rdotnet_equality + $(MAKE) rdotnet_equality-inequality + $(MAKE) rdotnet_integer-linear-program + $(MAKE) rdotnet_knapsack + $(MAKE) rdotnet_network-max-flow + $(MAKE) rdotnet_network-max-flow-lpSolve + $(MAKE) rdotnet_network-min-cost-flow $(MAKE) rdotnet_Program + $(MAKE) rdotnet_rabbit-pheasant + $(MAKE) rdotnet_volsay3 + $(MAKE) rdotnet_volsay3-lpSolve + $(MAKE) rdotnet_volsay .PHONY: test_donet_samples # Build and Run all .Net Samples (located in ortools/*/samples) test_dotnet_samples: $(DOTNET_ORTOOLS_NUPKG) @@ -647,10 +665,8 @@ clean_dotnet: -$(DEL) $(LIB_DIR)$S$(OR_TOOLS_NATIVE_ASSEMBLY_NAME).* -$(DEL) $(BIN_DIR)$S$(OR_TOOLS_ASSEMBLY_NAME).* -$(DEL) $(BIN_DIR)$S$(OR_TOOLS_FSHARP_ASSEMBLY_NAME).* - -$(DELREC) $(EX_PATH)$Sdotnet$Scsharp$Sbin - -$(DELREC) $(EX_PATH)$Sdotnet$Scsharp$Sobj - -$(DELREC) $(EX_PATH)$Sdotnet$Sfsharp$Sbin - -$(DELREC) $(EX_PATH)$Sdotnet$Sfsharp$Sobj + -$(DELREC) $(EX_PATH)$Sdotnet$Sbin + -$(DELREC) $(EX_PATH)$Sdotnet$Sobj -$(DELREC) ortools$Ssat$Ssamples$Sbin -$(DELREC) ortools$Ssat$Ssamples$Sobj -$(DELREC) $(TEMP_DOTNET_DIR) diff --git a/tools/generate_dotnet_csproj.sh b/tools/generate_dotnet_proj.sh similarity index 99% rename from tools/generate_dotnet_csproj.sh rename to tools/generate_dotnet_proj.sh index bcd2e87d0e..51bdd36d4c 100755 --- a/tools/generate_dotnet_csproj.sh +++ b/tools/generate_dotnet_proj.sh @@ -72,6 +72,7 @@ EOL echo "Generate $PROJ...DONE" done +# Samples for FILE in ortools/sat/samples/*.cs; do # if no files found do nothing [ -e "$FILE" ] || continue