From dc803630d37144730247a35bae231915890563a6 Mon Sep 17 00:00:00 2001 From: Corentin Le Molgat Date: Thu, 20 May 2021 17:54:57 +0200 Subject: [PATCH] Update .Net examples --- examples/dotnet/JobshopSat.cs | 13 +++++++++++++ examples/dotnet/NetworkRoutingSat.cs | 2 +- examples/dotnet/NursesSat.cs | 6 ++++-- examples/dotnet/README.md | 19 +++++++++---------- examples/dotnet/ShiftSchedulingSat.cs | 2 +- examples/dotnet/TaskSchedulingSat.cs | 13 +++++++++++++ 6 files changed, 41 insertions(+), 14 deletions(-) diff --git a/examples/dotnet/JobshopSat.cs b/examples/dotnet/JobshopSat.cs index 2932808903..3a3a629cb0 100644 --- a/examples/dotnet/JobshopSat.cs +++ b/examples/dotnet/JobshopSat.cs @@ -1,3 +1,16 @@ +// Copyright 2010-2021 Google LLC +// 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. + using System; using System.Collections.Generic; using System.Linq; diff --git a/examples/dotnet/NetworkRoutingSat.cs b/examples/dotnet/NetworkRoutingSat.cs index 110ab3f44c..cc5b4e7d4c 100644 --- a/examples/dotnet/NetworkRoutingSat.cs +++ b/examples/dotnet/NetworkRoutingSat.cs @@ -1,4 +1,4 @@ -// Copyright 2010-2021 Google LLC +// Copyright 2010-2021 Google LLC // 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 diff --git a/examples/dotnet/NursesSat.cs b/examples/dotnet/NursesSat.cs index 5f26e4a053..9797ab7b36 100644 --- a/examples/dotnet/NursesSat.cs +++ b/examples/dotnet/NursesSat.cs @@ -18,7 +18,8 @@ using Google.OrTools.Sat; public class NurseSolutionObserver : CpSolverSolutionCallback { - public NurseSolutionObserver(IntVar[,,] shifts, int num_nurses, int num_days, int num_shifts, HashSet to_print, int last_solution_explored) + public NurseSolutionObserver(IntVar[,,] shifts, int num_nurses, int num_days, int num_shifts, HashSet to_print, + int last_solution_explored) { shifts_ = shifts; num_nurses_ = num_nurses; @@ -49,7 +50,8 @@ public class NurseSolutionObserver : CpSolverSolutionCallback } } } - if (solution_count_ >= last_solution_explored_) { + if (solution_count_ >= last_solution_explored_) + { StopSearch(); } } diff --git a/examples/dotnet/README.md b/examples/dotnet/README.md index 2e341c0caf..14bfa1b461 100644 --- a/examples/dotnet/README.md +++ b/examples/dotnet/README.md @@ -1,5 +1,5 @@ # .NetCoreApp examples -The following examples showcase how to use OrTools. +The following examples showcase how to use OrTools.
The project solution has examples for both C# and F#. We recommend that all projects you create target `netcoreapp2.1`, @@ -9,20 +9,20 @@ keep up-to-date with the latest frameworks. Wherever you have or-tools installed, be sure to `PackageReference` the `Google.OrTools` from the project file. -# Execution -Running the examples will involve building them, then running them. +## Execution +Running the examples will involve building them, then running them.
You can run the following command: ```shell dotnet build .csproj dotnet run --no-build --project .csproj ``` -# Note on Google.OrTools.FSharp +## 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*. +### 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; @@ -30,11 +30,10 @@ Two input formats are allowed: **ALL Matrices & Vectors are entered as columns** -## Execution -Running the examples will involve building them, then running them. +### Execution +Running the examples will involve building them, then running them.
You can run the following command: ```shell dotnet build .fsproj dotnet run --no-build --project .fsproj ``` - diff --git a/examples/dotnet/ShiftSchedulingSat.cs b/examples/dotnet/ShiftSchedulingSat.cs index 0a79e7eae0..4e50200809 100644 --- a/examples/dotnet/ShiftSchedulingSat.cs +++ b/examples/dotnet/ShiftSchedulingSat.cs @@ -1,4 +1,4 @@ -// Copyright 2010-2021 Google LLC +// Copyright 2010-2021 Google LLC // 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 diff --git a/examples/dotnet/TaskSchedulingSat.cs b/examples/dotnet/TaskSchedulingSat.cs index 1b5f6aaa70..0c12ee5192 100644 --- a/examples/dotnet/TaskSchedulingSat.cs +++ b/examples/dotnet/TaskSchedulingSat.cs @@ -1,3 +1,16 @@ +// Copyright 2010-2021 Google LLC +// 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. + using System; using System.Collections.Generic; using Google.OrTools.Sat;