diff --git a/examples/csharp/cscvrptw.cs b/examples/csharp/cscvrptw.cs
index 5d612755cd..01d8a452dc 100644
--- a/examples/csharp/cscvrptw.cs
+++ b/examples/csharp/cscvrptw.cs
@@ -1,6 +1,4 @@
-//
-// Copyright 2012 Google
-//
+// Copyright 2010-2014 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
@@ -17,9 +15,9 @@ using System.Collections.Generic;
using Google.OrTools.ConstraintSolver;
///
-/// Sample showing how to model and solve a capacitated vehicle routing problem
-/// with time windows using the swig-wrapped version of the vehicle routing
-/// library in src/constraint_solver.
+/// Sample showing how to model and solve a capacitated vehicle routing
+/// problem with time windows using the swig-wrapped version of the vehicle
+/// routing library in src/constraint_solver.
///
public class CapacitatedVehicleRoutingProblemWithTimeWindows {
@@ -71,7 +69,8 @@ public class CapacitatedVehicleRoutingProblemWithTimeWindows {
}
public override long Run(int first_index, int second_index) {
- if (first_index >= locations_.Length || second_index >= locations_.Length) {
+ if (first_index >= locations_.Length ||
+ second_index >= locations_.Length) {
return 0;
}
return (Math.Abs(locations_[first_index].x_ -
@@ -143,7 +142,8 @@ public class CapacitatedVehicleRoutingProblemWithTimeWindows {
/// maximum quantity of a demand.
/// maximum starting time of the order time
/// window.
- /// duration of the order time window.
+ /// duration of the order time window.
+ ///
/// minimum pernalty cost if order is dropped.
///
/// maximum pernalty cost if order is dropped.
diff --git a/examples/csharp/csflow.cs b/examples/csharp/csflow.cs
index 056cf971e3..65ccb75549 100644
--- a/examples/csharp/csflow.cs
+++ b/examples/csharp/csflow.cs
@@ -1,4 +1,4 @@
-// Copyright 2010-2013 Google
+// Copyright 2010-2014 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
@@ -10,56 +10,11 @@
// 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 Google.OrTools.Graph;
public class CsFlow
{
- private static void SolveMinCostFlow()
- {
- Console.WriteLine("Min Cost Flow Problem");
- int numSources = 4;
- int numTargets = 4;
- int[,] costs = { {90, 75, 75, 80},
- {35, 85, 55, 65},
- {125, 95, 90, 105},
- {45, 110, 95, 115} };
- int expectedCost = 275;
- StarGraph graph = new StarGraph(numSources + numTargets,
- numSources * numTargets);
- MinCostFlow minCostFlow = new MinCostFlow(graph);
- for (int source = 0; source < numSources; ++source)
- {
- for (int target = 0; target < numTargets; ++target) {
- int arc = graph.AddArc(source, numSources + target);
- minCostFlow.SetArcUnitCost(arc, costs[source, target]);
- minCostFlow.SetArcCapacity(arc, 1);
- }
- }
-
- for (int source = 0; source < numSources; ++source)
- {
- minCostFlow.SetNodeSupply(source, 1);
- }
- for (int target = 0; target < numTargets; ++target)
- {
- minCostFlow.SetNodeSupply(numSources + target, -1);
- }
- Console.WriteLine("Solving min cost flow with " + numSources +
- " sources, and " + numTargets + " targets.");
- if (minCostFlow.Solve())
- {
- long totalFlowCost = minCostFlow.GetOptimalCost();
- Console.WriteLine("total computed flow cost = " + totalFlowCost +
- ", expected = " + expectedCost);
- }
- else
- {
- Console.WriteLine("No solution found");
- }
- }
-
private static void SolveMaxFlow()
{
Console.WriteLine("Max Flow Problem");
@@ -70,36 +25,83 @@ public class CsFlow
int[] capacities = {5, 8, 5, 3, 4, 5, 6, 6, 4};
int[] expectedFlows = {4, 4, 2, 0, 4, 4, 0, 6, 4};
int expectedTotalFlow = 10;
- StarGraph graph = new StarGraph(numNodes, numArcs);
- MaxFlow maxFlow = new MaxFlow(graph, 0, numNodes - 1);
+ MaxFlow maxFlow = new MaxFlow();
for (int i = 0; i < numArcs; ++i)
{
- int arc = graph.AddArc(tails[i], heads[i]);
- maxFlow.SetArcCapacity(arc, capacities[i]);
+ int arc = maxFlow.AddArcWithCapacity(tails[i], heads[i], capacities[i]);
+ if (arc != i) throw new Exception("Internal error");
}
+ int source = 0;
+ int sink = numNodes - 1;
Console.WriteLine("Solving max flow with " + numNodes + " nodes, and " +
- numArcs + " arcs, source = 0, sink = " + (numNodes - 1));
- if (maxFlow.Solve())
+ numArcs + " arcs, source=" + source + ", sink=" + sink);
+ int solveStatus = maxFlow.Solve(source, sink);
+ if (solveStatus == MaxFlow.OPTIMAL)
{
- long totalFlow = maxFlow.GetOptimalFlow();
+ long totalFlow = maxFlow.OptimalFlow();
Console.WriteLine("total computed flow " + totalFlow +
", expected = " + expectedTotalFlow);
for (int i = 0; i < numArcs; ++i)
{
- Console.WriteLine("Arc " + i + " (" + heads[i] + " -> " + tails[i] +
- ", capacity = " + capacities[i] + ") computed = " +
+ Console.WriteLine("Arc " + i + " (" + maxFlow.Head(i) + " -> " +
+ maxFlow.Tail(i) + "), capacity = " +
+ maxFlow.Capacity(i) + ") computed = " +
maxFlow.Flow(i) + ", expected = " + expectedFlows[i]);
}
}
else
{
- Console.WriteLine("No solution found");
+ Console.WriteLine("Solving the max flow problem failed. Solver status: " +
+ solveStatus);
+ }
+ }
+
+ private static void SolveMinCostFlow()
+ {
+ Console.WriteLine("Min Cost Flow Problem");
+ int numSources = 4;
+ int numTargets = 4;
+ int[,] costs = { {90, 75, 75, 80},
+ {35, 85, 55, 65},
+ {125, 95, 90, 105},
+ {45, 110, 95, 115} };
+ int expectedCost = 275;
+ MinCostFlow minCostFlow = new MinCostFlow();
+ for (int source = 0; source < numSources; ++source)
+ {
+ for (int target = 0; target < numTargets; ++target) {
+ minCostFlow.AddArcWithCapacityAndUnitCost(
+ source, /*target=*/numSources + target, /*capacity=*/1,
+ /*flow unit cost=*/costs[source, target]);
+ }
+ }
+ for (int source = 0; source < numSources; ++source)
+ {
+ minCostFlow.SetNodeSupply(source, 1);
+ }
+ for (int target = 0; target < numTargets; ++target)
+ {
+ minCostFlow.SetNodeSupply(numSources + target, -1);
+ }
+ Console.WriteLine("Solving min cost flow with " + numSources +
+ " sources, and " + numTargets + " targets.");
+ int solveStatus = minCostFlow.Solve();
+ if (solveStatus == MinCostFlow.OPTIMAL)
+ {
+ Console.WriteLine("total computed flow cost = " +
+ minCostFlow.OptimalCost() +
+ ", expected = " + expectedCost);
+ }
+ else
+ {
+ Console.WriteLine("Solving the min cost flow problem failed." +
+ " Solver status: " + solveStatus);
}
}
static void Main()
{
- SolveMinCostFlow();
SolveMaxFlow();
+ SolveMinCostFlow();
}
}
diff --git a/examples/csharp/csintegerprogramming.cs b/examples/csharp/csintegerprogramming.cs
index 39f41bf593..876fda3fd4 100644
--- a/examples/csharp/csintegerprogramming.cs
+++ b/examples/csharp/csintegerprogramming.cs
@@ -1,4 +1,4 @@
-// Copyright 2010-2013 Google
+// Copyright 2010-2014 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
@@ -10,7 +10,6 @@
// 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 Google.OrTools.LinearSolver;
@@ -29,8 +28,10 @@ public class CsIntegerProgramming
Variable x2 = solver.MakeIntVar(0.0, double.PositiveInfinity, "x2");
// Minimize x1 + 2 * x2.
- solver.Objective().SetCoefficient(x1, 1);
- solver.Objective().SetCoefficient(x2, 2);
+ Objective objective = solver.Objective();
+ objective.SetMinimization();
+ objective.SetCoefficient(x1, 1);
+ objective.SetCoefficient(x2, 2);
// 2 * x2 + 3 * x1 >= 17.
Constraint ct = solver.MakeConstraint(17, double.PositiveInfinity);
@@ -50,8 +51,7 @@ public class CsIntegerProgramming
" milliseconds");
// The objective value of the solution.
- Console.WriteLine("Optimal objective value = " +
- solver.Objective().Value());
+ Console.WriteLine("Optimal objective value = " + objective.Value());
// The value of each variable in the solution.
Console.WriteLine("x1 = " + x1.SolutionValue());
diff --git a/examples/csharp/csknapsack.cs b/examples/csharp/csknapsack.cs
index c878ab7e41..9bf79af6a6 100644
--- a/examples/csharp/csknapsack.cs
+++ b/examples/csharp/csknapsack.cs
@@ -1,4 +1,4 @@
-// Copyright 2010-2013 Google
+// Copyright 2010-2014 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
@@ -10,7 +10,6 @@
// 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 Google.OrTools.Algorithms;
diff --git a/examples/csharp/cslinearprogramming.cs b/examples/csharp/cslinearprogramming.cs
index 5ac5ac1c4b..4fd4b9e11e 100644
--- a/examples/csharp/cslinearprogramming.cs
+++ b/examples/csharp/cslinearprogramming.cs
@@ -1,4 +1,4 @@
-// Copyright 2010-2013 Google
+// Copyright 2010-2014 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
@@ -10,7 +10,6 @@
// 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 Google.OrTools.LinearSolver;
@@ -30,10 +29,11 @@ public class CsLinearProgramming
Variable x3 = solver.MakeNumVar(0.0, double.PositiveInfinity, "x3");
// Maximize 10 * x1 + 6 * x2 + 4 * x3.
- solver.Objective().SetCoefficient(x1, 10);
- solver.Objective().SetCoefficient(x2, 6);
- solver.Objective().SetCoefficient(x3, 4);
- solver.Objective().SetMaximization();
+ Objective objective = solver.Objective();
+ objective.SetCoefficient(x1, 10);
+ objective.SetCoefficient(x2, 6);
+ objective.SetCoefficient(x3, 4);
+ objective.SetMaximization();
// x1 + x2 + x3 <= 100.
Constraint c0 = solver.MakeConstraint(double.NegativeInfinity, 100.0);
diff --git a/examples/csharp/csls_api.cs b/examples/csharp/csls_api.cs
index a6c0f32b82..2f6e83a5e0 100644
--- a/examples/csharp/csls_api.cs
+++ b/examples/csharp/csls_api.cs
@@ -1,4 +1,4 @@
-// Copyright 2010-2011 Google
+// Copyright 2010-2014 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
@@ -10,7 +10,6 @@
// 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 Google.OrTools.ConstraintSolver;
diff --git a/examples/csharp/csrabbitspheasants.cs b/examples/csharp/csrabbitspheasants.cs
index 26f9c2a2cc..4b6b721aea 100644
--- a/examples/csharp/csrabbitspheasants.cs
+++ b/examples/csharp/csrabbitspheasants.cs
@@ -1,4 +1,4 @@
-// Copyright 2010-2013 Google
+// Copyright 2010-2014 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
@@ -10,7 +10,6 @@
// 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 Google.OrTools.ConstraintSolver;
diff --git a/examples/csharp/cstsp.cs b/examples/csharp/cstsp.cs
index ffd9a02364..e4e482abd0 100644
--- a/examples/csharp/cstsp.cs
+++ b/examples/csharp/cstsp.cs
@@ -1,6 +1,4 @@
-//
-// Copyright 2012 Google
-//
+// Copyright 2010-2014 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
@@ -12,7 +10,6 @@
// 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.ConstraintSolver;
diff --git a/examples/csharp/furniture_moving_intervals.cs b/examples/csharp/furniture_moving_intervals.cs
index 0a4023058c..91e535956f 100644
--- a/examples/csharp/furniture_moving_intervals.cs
+++ b/examples/csharp/furniture_moving_intervals.cs
@@ -1,5 +1,4 @@
-// Copyright 2010-2012 Google
-//
+// Copyright 2010-2014 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
@@ -11,7 +10,6 @@
// 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;
using System.Linq;
diff --git a/examples/csharp/organize_day_intervals.cs b/examples/csharp/organize_day_intervals.cs
index 01018680ea..e8f68afa00 100644
--- a/examples/csharp/organize_day_intervals.cs
+++ b/examples/csharp/organize_day_intervals.cs
@@ -1,6 +1,4 @@
-//
-// Copyright 2010-2012 Google
-//
+// Copyright 2010-2014 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
@@ -12,7 +10,6 @@
// 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;
using System.IO;
@@ -20,7 +17,6 @@ using System.Linq;
using System.Text.RegularExpressions;
using Google.OrTools.ConstraintSolver;
-
public class OrganizeDay
{
/**
diff --git a/examples/tests/issue18.cs b/examples/tests/issue18.cs
index da635fd9db..507c164a35 100644
--- a/examples/tests/issue18.cs
+++ b/examples/tests/issue18.cs
@@ -1,4 +1,4 @@
-// Copyright 2010-2012 Google
+// Copyright 2010-2014 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
@@ -10,7 +10,6 @@
// 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.ConstraintSolver;
@@ -46,6 +45,5 @@ public class CpTestNewSearch
}
Console.WriteLine("fini");
Console.ReadLine();
-
}
}
diff --git a/examples/tests/issue22.cs b/examples/tests/issue22.cs
index 95c1d501a1..170e771d50 100644
--- a/examples/tests/issue22.cs
+++ b/examples/tests/issue22.cs
@@ -1,3 +1,15 @@
+// Copyright 2010-2014 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.
using System;
using System.Collections;
using System.Collections.Generic;
diff --git a/examples/tests/remote/linear_programming.cc b/examples/tests/remote/linear_programming.cc
index c50933cea8..1587bb07d2 100644
--- a/examples/tests/remote/linear_programming.cc
+++ b/examples/tests/remote/linear_programming.cc
@@ -1,4 +1,4 @@
-// Copyright 2010-2013 Google
+// Copyright 2010-2014 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
diff --git a/examples/tests/remote/tsp.cc b/examples/tests/remote/tsp.cc
index 0d85f8cf71..b7da24a521 100644
--- a/examples/tests/remote/tsp.cc
+++ b/examples/tests/remote/tsp.cc
@@ -1,4 +1,4 @@
-// Copyright 2010-2013 Google
+// Copyright 2010-2014 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
diff --git a/examples/tests/testcp.cs b/examples/tests/testcp.cs
index 75b004110e..dd30a1b656 100644
--- a/examples/tests/testcp.cs
+++ b/examples/tests/testcp.cs
@@ -1,4 +1,4 @@
-// Copyright 2010-2012 Google
+// Copyright 2010-2014 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
@@ -10,12 +10,13 @@
// 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.ConstraintSolver;
public class CsTestCpOperator
{
+ // TODO(user): Add proper tests.
static void Check(bool test, String message)
{
if (!test)
@@ -412,42 +413,6 @@ public class CsTestCpOperator
Console.WriteLine(seq.Length);
}
- // static void TestScheduling()
- // {
- // Solver solver = new Solver("Scheduling");
- // IntervalVar[] tasks = new IntervalVar[taskCount];
- // List all_ends = new List();
- // int i = 0;
- // foreach(Task t in myTaskList)
- // {
- // tasks[i] = solver.MakeFixedInterval(0, (long)t.Duration, t.Name);
- // if (t.Successors.Count <= 0)
- // all_ends.Add(tasks[i].EndExpr().Var());
- // //solver.Add(solver.MakeGreaterOrEqual(tasks[i].StartExpr(), 1)); // { 1 }
- // i++;
- // }
-
- // IntVar objective_var = solver.MakeMax(all_ends.ToArray()).Var();
- // OptimizeVar objective_monitor = solver.MakeMinimize(objective_var, 1);
- // DecisionBuilder obj_phase = solver.MakePhase(objective_var, Solver.CHOOSE_FIRST_UNBOUND, Solver.ASSIGN_MIN_VALUE);
-
- // const int kLogFrequency = 999999999;
- // SearchMonitor search_log = solver.MakeSearchLog(kLogFrequency, objective_monitor);
-
- // SolutionCollector collector = solver.MakeLastSolutionCollector();
- // collector.AddObjective(objective_var);
-
- // if (solver.Solve(obj_phase, objective_monitor))
- // {
- // Console.Out.WriteLine("Solution: ");
- // foreach(IntervalVar t in tasks)
- // Console.Out.WriteLine(t.ToString());
- // }else
- // {
- // Console.Out.WriteLine("Can not find a solution");
- // }
- // }
-
static void Main()
{
TestConstructors();
diff --git a/examples/tests/testlp.cs b/examples/tests/testlp.cs
index 78abc55d13..73e57256cd 100644
--- a/examples/tests/testlp.cs
+++ b/examples/tests/testlp.cs
@@ -1,4 +1,4 @@
-// Copyright 2010-2012 Google
+// Copyright 2010-2014 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
@@ -10,25 +10,29 @@
// 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 Google.OrTools.LinearSolver;
public class CsTestLp
{
+
+ static int error_count = 0;
+
static void Check(bool test, String message)
{
if (!test)
{
Console.WriteLine("Error: " + message);
+ error_count++;
}
}
- static void CheckEquality(double v1, double v2, String message)
+ static void CheckDoubleEq(double v1, double v2, String message)
{
if (v1 != v2)
{
Console.WriteLine("Error: " + v1 + " != " + v2 + " " + message);
+ error_count++;
}
}
@@ -44,24 +48,24 @@ public class CsTestLp
Constraint ct4 = solver.Add(1 >= x);
Constraint ct5 = solver.Add(1 <= x);
Constraint ct6 = solver.Add(1 == x);
- CheckEquality(ct1.GetCoefficient(x), 1.0, "test1");
- CheckEquality(ct2.GetCoefficient(x), 1.0, "test2");
- CheckEquality(ct3.GetCoefficient(x), 1.0, "test3");
- CheckEquality(ct4.GetCoefficient(x), 1.0, "test4");
- CheckEquality(ct5.GetCoefficient(x), 1.0, "test5");
- CheckEquality(ct6.GetCoefficient(x), 1.0, "test6");
- CheckEquality(ct1.Lb(), 1.0, "test7");
- CheckEquality(ct1.Ub(), double.PositiveInfinity, "test8");
- CheckEquality(ct2.Lb(), double.NegativeInfinity, "test9");
- CheckEquality(ct2.Ub(), 1.0, "test10");
- CheckEquality(ct3.Lb(), 1.0, "test11");
- CheckEquality(ct3.Ub(), 1.0, "test12");
- CheckEquality(ct4.Lb(), double.NegativeInfinity, "test13");
- CheckEquality(ct4.Ub(), 1.0, "test14");
- CheckEquality(ct5.Lb(), 1.0, "test15");
- CheckEquality(ct5.Ub(), double.PositiveInfinity, "test16");
- CheckEquality(ct6.Lb(), 1.0, "test17");
- CheckEquality(ct6.Ub(), 1.0, "test18");
+ CheckDoubleEq(ct1.GetCoefficient(x), 1.0, "test1");
+ CheckDoubleEq(ct2.GetCoefficient(x), 1.0, "test2");
+ CheckDoubleEq(ct3.GetCoefficient(x), 1.0, "test3");
+ CheckDoubleEq(ct4.GetCoefficient(x), 1.0, "test4");
+ CheckDoubleEq(ct5.GetCoefficient(x), 1.0, "test5");
+ CheckDoubleEq(ct6.GetCoefficient(x), 1.0, "test6");
+ CheckDoubleEq(ct1.Lb(), 1.0, "test7");
+ CheckDoubleEq(ct1.Ub(), double.PositiveInfinity, "test8");
+ CheckDoubleEq(ct2.Lb(), double.NegativeInfinity, "test9");
+ CheckDoubleEq(ct2.Ub(), 1.0, "test10");
+ CheckDoubleEq(ct3.Lb(), 1.0, "test11");
+ CheckDoubleEq(ct3.Ub(), 1.0, "test12");
+ CheckDoubleEq(ct4.Lb(), double.NegativeInfinity, "test13");
+ CheckDoubleEq(ct4.Ub(), 1.0, "test14");
+ CheckDoubleEq(ct5.Lb(), 1.0, "test15");
+ CheckDoubleEq(ct5.Ub(), double.PositiveInfinity, "test16");
+ CheckDoubleEq(ct6.Lb(), 1.0, "test17");
+ CheckDoubleEq(ct6.Ub(), 1.0, "test18");
}
static void TestVarAddition()
@@ -72,18 +76,18 @@ public class CsTestLp
Variable x = solver.MakeNumVar(0.0, 100.0, "x");
Variable y = solver.MakeNumVar(0.0, 100.0, "y");
Constraint ct1 = solver.Add(x + y == 1);
- CheckEquality(ct1.GetCoefficient(x), 1.0, "test1");
- CheckEquality(ct1.GetCoefficient(y), 1.0, "test2");
+ CheckDoubleEq(ct1.GetCoefficient(x), 1.0, "test1");
+ CheckDoubleEq(ct1.GetCoefficient(y), 1.0, "test2");
Constraint ct2 = solver.Add(x + x == 1);
- CheckEquality(ct2.GetCoefficient(x), 2.0, "test3");
+ CheckDoubleEq(ct2.GetCoefficient(x), 2.0, "test3");
Constraint ct3 = solver.Add(x + (y + x) == 1);
- CheckEquality(ct3.GetCoefficient(x), 2.0, "test4");
- CheckEquality(ct3.GetCoefficient(y), 1.0, "test5");
+ CheckDoubleEq(ct3.GetCoefficient(x), 2.0, "test4");
+ CheckDoubleEq(ct3.GetCoefficient(y), 1.0, "test5");
Constraint ct4 = solver.Add(x + (y + x + 3) == 1);
- CheckEquality(ct4.GetCoefficient(x), 2.0, "test4");
- CheckEquality(ct4.GetCoefficient(y), 1.0, "test5");
- CheckEquality(ct4.Lb(), -2.0, "test6");
- CheckEquality(ct4.Ub(), -2.0, "test7");
+ CheckDoubleEq(ct4.GetCoefficient(x), 2.0, "test4");
+ CheckDoubleEq(ct4.GetCoefficient(y), 1.0, "test5");
+ CheckDoubleEq(ct4.Lb(), -2.0, "test6");
+ CheckDoubleEq(ct4.Ub(), -2.0, "test7");
}
static void TestVarMultiplication()
@@ -94,22 +98,22 @@ public class CsTestLp
Variable x = solver.MakeNumVar(0.0, 100.0, "x");
Variable y = solver.MakeNumVar(0.0, 100.0, "y");
Constraint ct1 = solver.Add(3 * x == 1);
- CheckEquality(ct1.GetCoefficient(x), 3.0, "test1");
+ CheckDoubleEq(ct1.GetCoefficient(x), 3.0, "test1");
Constraint ct2 = solver.Add(x * 3 == 1);
- CheckEquality(ct2.GetCoefficient(x), 3.0, "test2");
+ CheckDoubleEq(ct2.GetCoefficient(x), 3.0, "test2");
Constraint ct3 = solver.Add(x + (2 * y + 3 * x) == 1);
- CheckEquality(ct3.GetCoefficient(x), 4.0, "test3");
- CheckEquality(ct3.GetCoefficient(y), 2.0, "test4");
+ CheckDoubleEq(ct3.GetCoefficient(x), 4.0, "test3");
+ CheckDoubleEq(ct3.GetCoefficient(y), 2.0, "test4");
Constraint ct4 = solver.Add(x + 5 * (y + x + 3) == 1);
- CheckEquality(ct4.GetCoefficient(x), 6.0, "test5");
- CheckEquality(ct4.GetCoefficient(y), 5.0, "test6");
- CheckEquality(ct4.Lb(), -14.0, "test7");
- CheckEquality(ct4.Ub(), -14.0, "test8");
+ CheckDoubleEq(ct4.GetCoefficient(x), 6.0, "test5");
+ CheckDoubleEq(ct4.GetCoefficient(y), 5.0, "test6");
+ CheckDoubleEq(ct4.Lb(), -14.0, "test7");
+ CheckDoubleEq(ct4.Ub(), -14.0, "test8");
Constraint ct5 = solver.Add(x + (2 * y + x + 3) * 3 == 1);
- CheckEquality(ct5.GetCoefficient(x), 4.0, "test9");
- CheckEquality(ct5.GetCoefficient(y), 6.0, "test10");
- CheckEquality(ct5.Lb(), -8.0, "test11");
- CheckEquality(ct5.Ub(), -8.0, "test12");
+ CheckDoubleEq(ct5.GetCoefficient(x), 4.0, "test9");
+ CheckDoubleEq(ct5.GetCoefficient(y), 6.0, "test10");
+ CheckDoubleEq(ct5.Lb(), -8.0, "test11");
+ CheckDoubleEq(ct5.Ub(), -8.0, "test12");
}
static void TestBinaryOperations()
@@ -120,18 +124,18 @@ public class CsTestLp
Variable x = solver.MakeNumVar(0.0, 100.0, "x");
Variable y = solver.MakeNumVar(0.0, 100.0, "y");
Constraint ct1 = solver.Add(x == y);
- CheckEquality(ct1.GetCoefficient(x), 1.0, "test1");
- CheckEquality(ct1.GetCoefficient(y), -1.0, "test2");
+ CheckDoubleEq(ct1.GetCoefficient(x), 1.0, "test1");
+ CheckDoubleEq(ct1.GetCoefficient(y), -1.0, "test2");
Constraint ct2 = solver.Add(x == 3 * y + 5);
- CheckEquality(ct2.GetCoefficient(x), 1.0, "test3");
- CheckEquality(ct2.GetCoefficient(y), -3.0, "test4");
- CheckEquality(ct2.Lb(), 5.0, "test5");
- CheckEquality(ct2.Ub(), 5.0, "test6");
+ CheckDoubleEq(ct2.GetCoefficient(x), 1.0, "test3");
+ CheckDoubleEq(ct2.GetCoefficient(y), -3.0, "test4");
+ CheckDoubleEq(ct2.Lb(), 5.0, "test5");
+ CheckDoubleEq(ct2.Ub(), 5.0, "test6");
Constraint ct3 = solver.Add(2 * x - 9 == y);
- CheckEquality(ct3.GetCoefficient(x), 2.0, "test7");
- CheckEquality(ct3.GetCoefficient(y), -1.0, "test8");
- CheckEquality(ct3.Lb(), 9.0, "test9");
- CheckEquality(ct3.Ub(), 9.0, "test10");
+ CheckDoubleEq(ct3.GetCoefficient(x), 2.0, "test7");
+ CheckDoubleEq(ct3.GetCoefficient(y), -1.0, "test8");
+ CheckDoubleEq(ct3.Lb(), 9.0, "test9");
+ CheckDoubleEq(ct3.Ub(), 9.0, "test10");
Check(x == x, "test11");
Check(!(x == y), "test12");
Check(!(x != x), "test13");
@@ -146,25 +150,25 @@ public class CsTestLp
Variable x = solver.MakeNumVar(0.0, 100.0, "x");
Variable y = solver.MakeNumVar(0.0, 100.0, "y");
Constraint ct1 = solver.Add(2 * (x + 3) + 5 * (y + x -1) >= 3);
- CheckEquality(ct1.GetCoefficient(x), 7.0, "test1");
- CheckEquality(ct1.GetCoefficient(y), 5.0, "test2");
- CheckEquality(ct1.Lb(), 2.0, "test3");
- CheckEquality(ct1.Ub(), double.PositiveInfinity, "test4");
+ CheckDoubleEq(ct1.GetCoefficient(x), 7.0, "test1");
+ CheckDoubleEq(ct1.GetCoefficient(y), 5.0, "test2");
+ CheckDoubleEq(ct1.Lb(), 2.0, "test3");
+ CheckDoubleEq(ct1.Ub(), double.PositiveInfinity, "test4");
Constraint ct2 = solver.Add(2 * (x + 3) + 5 * (y + x -1) <= 3);
- CheckEquality(ct2.GetCoefficient(x), 7.0, "test5");
- CheckEquality(ct2.GetCoefficient(y), 5.0, "test6");
- CheckEquality(ct2.Lb(), double.NegativeInfinity, "test7");
- CheckEquality(ct2.Ub(), 2.0, "test8");
+ CheckDoubleEq(ct2.GetCoefficient(x), 7.0, "test5");
+ CheckDoubleEq(ct2.GetCoefficient(y), 5.0, "test6");
+ CheckDoubleEq(ct2.Lb(), double.NegativeInfinity, "test7");
+ CheckDoubleEq(ct2.Ub(), 2.0, "test8");
Constraint ct3 = solver.Add(2 * (x + 3) + 5 * (y + x -1) >= 3 - x - y);
- CheckEquality(ct3.GetCoefficient(x), 8.0, "test9");
- CheckEquality(ct3.GetCoefficient(y), 6.0, "test10");
- CheckEquality(ct3.Lb(), 2.0, "test11");
- CheckEquality(ct3.Ub(), double.PositiveInfinity, "test12");
+ CheckDoubleEq(ct3.GetCoefficient(x), 8.0, "test9");
+ CheckDoubleEq(ct3.GetCoefficient(y), 6.0, "test10");
+ CheckDoubleEq(ct3.Lb(), 2.0, "test11");
+ CheckDoubleEq(ct3.Ub(), double.PositiveInfinity, "test12");
Constraint ct4 = solver.Add(2 * (x + 3) + 5 * (y + x -1) <= -x - y + 3);
- CheckEquality(ct4.GetCoefficient(x), 8.0, "test13");
- CheckEquality(ct4.GetCoefficient(y), 6.0, "test14");
- CheckEquality(ct4.Lb(), double.NegativeInfinity, "test15");
- CheckEquality(ct4.Ub(), 2.0, "test16");
+ CheckDoubleEq(ct4.GetCoefficient(x), 8.0, "test13");
+ CheckDoubleEq(ct4.GetCoefficient(y), 6.0, "test14");
+ CheckDoubleEq(ct4.Lb(), double.NegativeInfinity, "test15");
+ CheckDoubleEq(ct4.Ub(), 2.0, "test16");
}
static void TestSumArray()
@@ -173,14 +177,14 @@ public class CsTestLp
Solver solver = new Solver("TestSumArray", Solver.CLP_LINEAR_PROGRAMMING);
Variable[] x = solver.MakeBoolVarArray(10, "x");
Constraint ct1 = solver.Add(x.Sum() == 3);
- CheckEquality(ct1.GetCoefficient(x[0]), 1.0, "test1");
+ CheckDoubleEq(ct1.GetCoefficient(x[0]), 1.0, "test1");
Constraint ct2 = solver.Add(-2 * x.Sum() == 3);
- CheckEquality(ct2.GetCoefficient(x[0]), -2.0, "test2");
+ CheckDoubleEq(ct2.GetCoefficient(x[0]), -2.0, "test2");
LinearExpr[] array = new LinearExpr[] { x[0]+ 2.0, x[0] + 3, x[0] + 4 };
Constraint ct3 = solver.Add(array.Sum() == 1);
- CheckEquality(ct3.GetCoefficient(x[0]), 3.0, "test3");
- CheckEquality(ct3.Lb(), -8.0, "test4");
- CheckEquality(ct3.Ub(), -8.0, "test5");
+ CheckDoubleEq(ct3.GetCoefficient(x[0]), 3.0, "test3");
+ CheckDoubleEq(ct3.Lb(), -8.0, "test4");
+ CheckDoubleEq(ct3.Ub(), -8.0, "test5");
}
static void TestObjective()
@@ -190,13 +194,13 @@ public class CsTestLp
Variable x = solver.MakeNumVar(0.0, 100.0, "x");
Variable y = solver.MakeNumVar(0.0, 100.0, "y");
solver.Maximize(x);
- CheckEquality(0.0, solver.Objective().Offset(), "test1");
- CheckEquality(1.0, solver.Objective().GetCoefficient(x), "test2");
+ CheckDoubleEq(0.0, solver.Objective().Offset(), "test1");
+ CheckDoubleEq(1.0, solver.Objective().GetCoefficient(x), "test2");
Check(solver.Objective().Maximization(), "test3");
solver.Minimize(-x - 2 * y + 3);
- CheckEquality(3.0, solver.Objective().Offset(), "test4");
- CheckEquality(-1.0, solver.Objective().GetCoefficient(x), "test5");
- CheckEquality(-2.0, solver.Objective().GetCoefficient(y), "test6");
+ CheckDoubleEq(3.0, solver.Objective().Offset(), "test4");
+ CheckDoubleEq(-1.0, solver.Objective().GetCoefficient(x), "test5");
+ CheckDoubleEq(-2.0, solver.Objective().GetCoefficient(y), "test6");
Check(solver.Objective().Minimization(), "test7");
}
@@ -209,5 +213,9 @@ public class CsTestLp
TestInequalities();
TestSumArray();
TestObjective();
+ if (error_count != 0) {
+ Console.WriteLine("Found " + error_count + " errors.");
+ Environment.Exit(1);
+ }
}
}
diff --git a/src/com/google/ortools/constraintsolver/IntArrayHelper.cs b/src/com/google/ortools/constraintsolver/IntArrayHelper.cs
index 4e4040b37c..ddab050ff5 100644
--- a/src/com/google/ortools/constraintsolver/IntArrayHelper.cs
+++ b/src/com/google/ortools/constraintsolver/IntArrayHelper.cs
@@ -1,4 +1,4 @@
-// Copyright 2010-2013 Google
+// Copyright 2010-2014 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
@@ -10,7 +10,6 @@
// 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.
-
namespace Google.OrTools.ConstraintSolver {
using System;
using System.Collections.Generic;
diff --git a/src/com/google/ortools/constraintsolver/IntVarArrayHelper.cs b/src/com/google/ortools/constraintsolver/IntVarArrayHelper.cs
index 29fd0d4411..6a826d3834 100644
--- a/src/com/google/ortools/constraintsolver/IntVarArrayHelper.cs
+++ b/src/com/google/ortools/constraintsolver/IntVarArrayHelper.cs
@@ -1,4 +1,4 @@
-// Copyright 2010-2013 Google
+// Copyright 2010-2014 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
@@ -10,7 +10,6 @@
// 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.
-
namespace Google.OrTools.ConstraintSolver
{
using System;
diff --git a/src/com/google/ortools/constraintsolver/IntervalVarArrayHelper.cs b/src/com/google/ortools/constraintsolver/IntervalVarArrayHelper.cs
index 502d51b802..65689c396f 100644
--- a/src/com/google/ortools/constraintsolver/IntervalVarArrayHelper.cs
+++ b/src/com/google/ortools/constraintsolver/IntervalVarArrayHelper.cs
@@ -1,4 +1,4 @@
-// Copyright 2010-2013 Google
+// Copyright 2010-2014 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
@@ -10,7 +10,6 @@
// 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.
-
namespace Google.OrTools.ConstraintSolver
{
using System;
diff --git a/src/com/google/ortools/constraintsolver/JavaDecisionBuilder.java b/src/com/google/ortools/constraintsolver/JavaDecisionBuilder.java
index df1b2d5be0..7118bf4e8d 100644
--- a/src/com/google/ortools/constraintsolver/JavaDecisionBuilder.java
+++ b/src/com/google/ortools/constraintsolver/JavaDecisionBuilder.java
@@ -1,4 +1,4 @@
-// Copyright 2010-2013 Google
+// Copyright 2010-2014 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
diff --git a/src/com/google/ortools/constraintsolver/NetDecisionBuilder.cs b/src/com/google/ortools/constraintsolver/NetDecisionBuilder.cs
index 42d5d1d960..006904e63d 100644
--- a/src/com/google/ortools/constraintsolver/NetDecisionBuilder.cs
+++ b/src/com/google/ortools/constraintsolver/NetDecisionBuilder.cs
@@ -1,4 +1,4 @@
-// Copyright 2010-2013 Google
+// Copyright 2010-2014 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
@@ -10,7 +10,6 @@
// 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;
namespace Google.OrTools.ConstraintSolver
@@ -48,4 +47,3 @@ public class NetDecisionBuilder : DecisionBuilder
}
}
} // namespace Google.OrTools.ConstraintSolver
-
diff --git a/src/com/google/ortools/constraintsolver/ValCstPair.cs b/src/com/google/ortools/constraintsolver/ValCstPair.cs
index 8afcaed3d8..1080243d28 100644
--- a/src/com/google/ortools/constraintsolver/ValCstPair.cs
+++ b/src/com/google/ortools/constraintsolver/ValCstPair.cs
@@ -1,4 +1,4 @@
-// Copyright 2010-2013 Google
+// Copyright 2010-2014 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
@@ -10,7 +10,6 @@
// 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.
-
namespace Google.OrTools.ConstraintSolver
{
using System;
@@ -103,7 +102,8 @@ public abstract class BaseEquality : IConstraintWithStatus
return new WrappedConstraint(a.solver().MakeGreater(a.Var(), v));
}
public static WrappedConstraint operator >=(BaseEquality a, BaseEquality b) {
- return new WrappedConstraint(a.solver().MakeGreaterOrEqual(a.Var(), b.Var()));
+ return new WrappedConstraint(a.solver().MakeGreaterOrEqual(a.Var(),
+ b.Var()));
}
public static WrappedConstraint operator >(BaseEquality a, BaseEquality b) {
return new WrappedConstraint(a.solver().MakeGreater(a.Var(), b.Var()));
diff --git a/src/com/google/ortools/linearsolver/LinearConstraint.cs b/src/com/google/ortools/linearsolver/LinearConstraint.cs
index fbfebbcd6f..e01085b525 100644
--- a/src/com/google/ortools/linearsolver/LinearConstraint.cs
+++ b/src/com/google/ortools/linearsolver/LinearConstraint.cs
@@ -1,4 +1,4 @@
-// Copyright 2010-2012 Google
+// Copyright 2010-2014 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
@@ -10,7 +10,6 @@
// 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.
-
namespace Google.OrTools.LinearSolver
{
using System;
diff --git a/src/com/google/ortools/linearsolver/LinearExpr.cs b/src/com/google/ortools/linearsolver/LinearExpr.cs
index 3c2604e09e..97d3526e48 100644
--- a/src/com/google/ortools/linearsolver/LinearExpr.cs
+++ b/src/com/google/ortools/linearsolver/LinearExpr.cs
@@ -1,4 +1,4 @@
-// Copyright 2010-2012 Google
+// Copyright 2010-2014 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
@@ -10,7 +10,6 @@
// 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.
-
namespace Google.OrTools.LinearSolver
{
using System;
diff --git a/src/com/google/ortools/util/NestedArrayHelper.cs b/src/com/google/ortools/util/NestedArrayHelper.cs
index b6665f035f..d316bf3cd1 100644
--- a/src/com/google/ortools/util/NestedArrayHelper.cs
+++ b/src/com/google/ortools/util/NestedArrayHelper.cs
@@ -1,4 +1,4 @@
-// Copyright 2010-2013 Google
+// Copyright 2010-2014 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
@@ -10,7 +10,6 @@
// 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.
-
namespace Google.OrTools {
using System;
diff --git a/src/constraint_solver/csharp/constraint_solver.swig b/src/constraint_solver/csharp/constraint_solver.swig
index 3a1c4b5ca7..4faf1d8039 100644
--- a/src/constraint_solver/csharp/constraint_solver.swig
+++ b/src/constraint_solver/csharp/constraint_solver.swig
@@ -1,4 +1,4 @@
-// Copyright 2010-2013 Google
+// Copyright 2010-2014 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
@@ -10,6 +10,7 @@
// 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.
+// TODO(user): Refactor this file to adhere to the SWIG style guide.
%include exception.i
%include util/csharp/data.swig
@@ -188,7 +189,19 @@ struct FailureProtect {
%ignore operations_research::Solver::MakeBoolVarArray;
%ignore operations_research::Solver::MakeFixedDurationIntervalVarArray;
%ignore operations_research::IntVarLocalSearchFilter::FindIndex;
-%ignore operations_research::SequenceVarLocalSearchOperatorTemplate::Value;
+%ignore operations_research::VarLocalSearchOperator::Value;
+%ignore operations_research::VarLocalSearchOperator::OldValue;
+%ignore operations_research::SequenceVarLocalSearchOperator::Sequence;
+%ignore operations_research::SequenceVarLocalSearchOperator::OldSequence;
+%ignore operations_research::SolutionCollector::ForwardSequence;
+%ignore operations_research::SolutionCollector::BackwardSequence;
+%ignore operations_research::SolutionCollector::Unperformed;
+%ignore operations_research::SequenceVarElement::ForwardSequence;
+%ignore operations_research::SequenceVarElement::BackwardSequence;
+%ignore operations_research::SequenceVarElement::Unperformed;
+%ignore operations_research::Assignment::ForwardSequence;
+%ignore operations_research::Assignment::BackwardSequence;
+%ignore operations_research::Assignment::Unperformed;
// Generic rename rule.
%rename("%(camelcase)s", %$isfunction) "";
@@ -413,144 +426,144 @@ CS_TYPEMAP_STDVECTOR_OBJECT(operations_research::SymmetryBreaker, SymmetryBreake
namespace operations_research {
%extend IntervalVar {
Constraint* EndsAfterEnd(IntervalVar* other) {
- return self->solver()->MakeIntervalVarRelation(self, operations_research::Solver::ENDS_AFTER_END, other);
+ return $self->solver()->MakeIntervalVarRelation($self, operations_research::Solver::ENDS_AFTER_END, other);
}
Constraint* EndsAfterStart(IntervalVar* other) {
- return self->solver()->MakeIntervalVarRelation(self, operations_research::Solver::ENDS_AFTER_START, other);
+ return $self->solver()->MakeIntervalVarRelation($self, operations_research::Solver::ENDS_AFTER_START, other);
}
Constraint* EndsAtEnd(IntervalVar* other) {
- return self->solver()->MakeIntervalVarRelation(self, operations_research::Solver::ENDS_AT_END, other);
+ return $self->solver()->MakeIntervalVarRelation($self, operations_research::Solver::ENDS_AT_END, other);
}
Constraint* EndsAtStart(IntervalVar* other) {
- return self->solver()->MakeIntervalVarRelation(self, operations_research::Solver::ENDS_AT_START, other);
+ return $self->solver()->MakeIntervalVarRelation($self, operations_research::Solver::ENDS_AT_START, other);
}
Constraint* StartsAfterEnd(IntervalVar* other) {
- return self->solver()->MakeIntervalVarRelation(self, operations_research::Solver::STARTS_AFTER_END, other);
+ return $self->solver()->MakeIntervalVarRelation($self, operations_research::Solver::STARTS_AFTER_END, other);
}
Constraint* StartsAfterStart(IntervalVar* other) {
- return self->solver()->MakeIntervalVarRelation(self,
- operations_research::Solver::STARTS_AFTER_START,
- other);
+ return $self->solver()->MakeIntervalVarRelation($self,
+ operations_research::Solver::STARTS_AFTER_START,
+ other);
}
Constraint* StartsAtEnd(IntervalVar* other) {
- return self->solver()->MakeIntervalVarRelation(self, operations_research::Solver::STARTS_AT_END, other);
+ return $self->solver()->MakeIntervalVarRelation($self, operations_research::Solver::STARTS_AT_END, other);
}
Constraint* StartsAtStart(IntervalVar* other) {
- return self->solver()->MakeIntervalVarRelation(self,
- operations_research::Solver::STARTS_AT_START,
- other);
+ return $self->solver()->MakeIntervalVarRelation($self,
+ operations_research::Solver::STARTS_AT_START,
+ other);
}
Constraint* EndsAfter(int64 date) {
- return self->solver()->MakeIntervalVarRelation(self,
- operations_research::Solver::ENDS_AFTER,
- date);
+ return $self->solver()->MakeIntervalVarRelation($self,
+ operations_research::Solver::ENDS_AFTER,
+ date);
}
Constraint* EndsAt(int64 date) {
- return self->solver()->MakeIntervalVarRelation(self,
- operations_research::Solver::ENDS_AT,
- date);
+ return $self->solver()->MakeIntervalVarRelation($self,
+ operations_research::Solver::ENDS_AT,
+ date);
}
Constraint* EndsBefore(int64 date) {
- return self->solver()->MakeIntervalVarRelation(self,
- operations_research::Solver::ENDS_BEFORE,
- date);
+ return $self->solver()->MakeIntervalVarRelation($self,
+ operations_research::Solver::ENDS_BEFORE,
+ date);
}
Constraint* StartsAfter(int64 date) {
- return self->solver()->MakeIntervalVarRelation(self,
- operations_research::Solver::STARTS_AFTER,
- date);
+ return $self->solver()->MakeIntervalVarRelation($self,
+ operations_research::Solver::STARTS_AFTER,
+ date);
}
Constraint* StartsAt(int64 date) {
- return self->solver()->MakeIntervalVarRelation(self,
- operations_research::Solver::STARTS_AT,
- date);
+ return $self->solver()->MakeIntervalVarRelation($self,
+ operations_research::Solver::STARTS_AT,
+ date);
}
Constraint* StartsBefore(int64 date) {
- return self->solver()->MakeIntervalVarRelation(self,
- operations_research::Solver::STARTS_BEFORE,
- date);
+ return $self->solver()->MakeIntervalVarRelation($self,
+ operations_research::Solver::STARTS_BEFORE,
+ date);
}
Constraint* CrossesDate(int64 date) {
- return self->solver()->MakeIntervalVarRelation(self,
- operations_research::Solver::CROSS_DATE,
- date);
+ return $self->solver()->MakeIntervalVarRelation($self,
+ operations_research::Solver::CROSS_DATE,
+ date);
}
Constraint* AvoidsDate(int64 date) {
- return self->solver()->MakeIntervalVarRelation(self,
- operations_research::Solver::AVOID_DATE,
- date);
+ return $self->solver()->MakeIntervalVarRelation($self,
+ operations_research::Solver::AVOID_DATE,
+ date);
}
IntervalVar* RelaxedMax() {
- return self->solver()->MakeIntervalRelaxedMax(self);
+ return $self->solver()->MakeIntervalRelaxedMax($self);
}
IntervalVar* RelaxedMin() {
- return self->solver()->MakeIntervalRelaxedMin(self);
+ return $self->solver()->MakeIntervalRelaxedMin($self);
}
}
%extend IntExpr {
Constraint* MapTo(const std::vector& vars) {
- return self->solver()->MakeMapDomain(self->Var(), vars);
+ return $self->solver()->MakeMapDomain($self->Var(), vars);
}
IntExpr* IndexOf(const std::vector& vars) {
- return self->solver()->MakeElement(vars, self->Var());
+ return $self->solver()->MakeElement(vars, $self->Var());
}
IntExpr* IndexOf(const std::vector& vars) {
- return self->solver()->MakeElement(vars, self->Var());
+ return $self->solver()->MakeElement(vars, $self->Var());
}
IntVar* IsEqual(int64 value) {
- return self->solver()->MakeIsEqualCstVar(self->Var(), value);
+ return $self->solver()->MakeIsEqualCstVar($self->Var(), value);
}
IntVar* IsDifferent(int64 value) {
- return self->solver()->MakeIsDifferentCstVar(self->Var(), value);
+ return $self->solver()->MakeIsDifferentCstVar($self->Var(), value);
}
IntVar* IsGreater(int64 value) {
- return self->solver()->MakeIsGreaterCstVar(self->Var(), value);
+ return $self->solver()->MakeIsGreaterCstVar($self->Var(), value);
}
IntVar* IsGreaterOrEqual(int64 value) {
- return self->solver()->MakeIsGreaterOrEqualCstVar(self->Var(), value);
+ return $self->solver()->MakeIsGreaterOrEqualCstVar($self->Var(), value);
}
IntVar* IsLess(int64 value) {
- return self->solver()->MakeIsLessCstVar(self->Var(), value);
+ return $self->solver()->MakeIsLessCstVar($self->Var(), value);
}
IntVar* IsLessOrEqual(int64 value) {
- return self->solver()->MakeIsLessOrEqualCstVar(self->Var(), value);
+ return $self->solver()->MakeIsLessOrEqualCstVar($self->Var(), value);
}
IntVar* IsMember(const std::vector& values) {
- return self->solver()->MakeIsMemberVar(self->Var(), values);
+ return $self->solver()->MakeIsMemberVar($self->Var(), values);
}
IntVar* IsMember(const std::vector& values) {
- return self->solver()->MakeIsMemberVar(self->Var(), values);
+ return $self->solver()->MakeIsMemberVar($self->Var(), values);
}
Constraint* Member(const std::vector& values) {
- return self->solver()->MakeMemberCt(self->Var(), values);
+ return $self->solver()->MakeMemberCt($self->Var(), values);
}
Constraint* Member(const std::vector& values) {
- return self->solver()->MakeMemberCt(self->Var(), values);
+ return $self->solver()->MakeMemberCt($self->Var(), values);
}
IntVar* IsEqual(IntExpr* const other) {
- return self->solver()->MakeIsEqualVar(self->Var(), other->Var());
+ return $self->solver()->MakeIsEqualVar($self->Var(), other->Var());
}
IntVar* IsDifferent(IntExpr* const other) {
- return self->solver()->MakeIsDifferentVar(self->Var(), other->Var());
+ return $self->solver()->MakeIsDifferentVar($self->Var(), other->Var());
}
IntVar* IsGreater(IntExpr* const other) {
- return self->solver()->MakeIsGreaterVar(self->Var(), other->Var());
+ return $self->solver()->MakeIsGreaterVar($self->Var(), other->Var());
}
IntVar* IsGreaterOrEqual(IntExpr* const other) {
- return self->solver()->MakeIsGreaterOrEqualVar(self->Var(), other->Var());
+ return $self->solver()->MakeIsGreaterOrEqualVar($self->Var(), other->Var());
}
IntVar* IsLess(IntExpr* const other) {
- return self->solver()->MakeIsLessVar(self->Var(), other->Var());
+ return $self->solver()->MakeIsLessVar($self->Var(), other->Var());
}
IntVar* IsLessOrEqual(IntExpr* const other) {
- return self->solver()->MakeIsLessOrEqualVar(self->Var(), other->Var());
+ return $self->solver()->MakeIsLessOrEqualVar($self->Var(), other->Var());
}
OptimizeVar* Minimize(long step) {
- return self->solver()->MakeMinimize(self->Var(), step);
+ return $self->solver()->MakeMinimize($self->Var(), step);
}
OptimizeVar* Maximize(long step) {
- return self->solver()->MakeMaximize(self->Var(), step);
+ return $self->solver()->MakeMaximize($self->Var(), step);
}
}
@@ -868,148 +881,91 @@ namespace operations_research {
private DecisionBuilder pinned_decision_builder_;
%}
+%extend Assignment {
+ int ForwardSequenceSize(const SequenceVar* const v) const {
+ return $self->ForwardSequence(v).size();
+ }
+ int ForwardSequenceValueAt(const SequenceVar* const v, int i) const {
+ return $self->ForwardSequence(v)[i];
+ }
+ int BackwardSequenceSize(const SequenceVar* const v) const {
+ return $self->BackwardSequence(v).size();
+ }
+ int BackwardSequenceValueAt(const SequenceVar* const v, int position) const {
+ return $self->BackwardSequence(v)[position];
+ }
+ int UnperformedSize(const SequenceVar* const v) const {
+ return $self->Unperformed(v).size();
+ }
+ int UnperformedValueAt(const SequenceVar* const v, int position) const {
+ return $self->Unperformed(v)[position];
+ }
+}
+
+%typemap(cscode) Assignment %{
+ public int[] ForwardSequence(SequenceVar v) {
+ int size = ForwardSequenceSize(v);
+ int[] result = new int[size];
+ for (int i = 0; i < size; ++i) result[i] = ForwardSequenceValueAt(v, i);
+ return result;
+ }
+ public int[] BackwardSequence(SequenceVar v) {
+ int size = BackwardSequenceSize(v);
+ int[] result = new int[size];
+ for (int i = 0; i < size; ++i) result[i] = BackwardSequenceValueAt(v, i);
+ return result;
+ }
+ public int[] Unperformed(SequenceVar v) {
+ int size = UnperformedSize(v);
+ int[] result = new int[size];
+ for (int i = 0; i < size; ++i) result[i] = UnperformedValueAt(v, i);
+ return result;
+ }
+%}
+
+%extend SequenceVarLocalSearchOperator {
+ int SequenceSize(int index) const {
+ return $self->Sequence(index).size();
+ }
+ int SequenceValueAt(int index, int position) const {
+ return $self->Sequence(index)[position];
+ }
+ int OldSequenceSize(int index) const {
+ return $self->OldSequence(index).size();
+ }
+ int OldSequenceValueAt(int index, int position) const {
+ return $self->OldSequence(index)[position];
+ }
+}
+
+%typemap(cscode) SequenceVarLocalSearchOperator %{
+ public int[] Sequence(int index) {
+ int size = SequenceSize(index);
+ int[] result = new int[size];
+ for (int position = 0; position < size; ++position) {
+ result[position] = SequenceValueAt(index, position);
+ }
+ return result;
+ }
+ public int[] OldSequence(int index) {
+ int size = OldSequenceSize(index);
+ int[] result = new int[size];
+ for (int position = 0; position < size; ++position) {
+ result[position] = OldSequenceValueAt(index, position);
+ }
+ return result;
+ }
+%}
+
%extend IntVarLocalSearchFilter {
int Index(IntVar* const var) {
int64 index = -1;
- self->FindIndex(var, &index);
+ $self->FindIndex(var, &index);
return index;
}
}
-
} // namespace operations_research
-CS_VECTOR_RETURN1(operations_research, SequenceVarLocalSearchOperator, Sequence,
- int, int64)
-CS_VECTOR_RETURN1(operations_research, SequenceVarLocalSearchOperator,
- OldSequence, int, int64)
-
-%typemap(cscode) operations_research::SequenceVarLocalSearchOperator %{
- public int[] Sequence(long a) {
- int size = SequenceSize(a);
- int[] result = new int[size];
- for (int position = 0; position < size; ++position) {
- result[position] = SequenceValueAt(a, position);
- }
- return result;
- }
- public int[] OldSequence(long a) {
- int size = OldSequenceSize(a);
- int[] result = new int[size];
- for (int position = 0; position < size; ++position) {
- result[position] = OldSequenceValueAt(a, position);
- }
- return result;
- }
-%}
-
-CS_VECTOR_RETURN2(operations_research, SolutionCollector, ForwardSequence,
- int, int, SequenceVar*)
-CS_VECTOR_RETURN2(operations_research, SolutionCollector, BackwardSequence,
- int, int, SequenceVar*)
-CS_VECTOR_RETURN2(operations_research, SolutionCollector, Unperformed,
- int, int, SequenceVar*)
-
-%typemap(cscode) operations_research::SolutionCollector %{
- public int[] ForwardSequence(int a, SequenceVar b) {
- int size = ForwardSequenceSize(a, b);
- int[] result = new int[size];
- for (int position = 0; position < size; ++position) {
- result[position] = ForwardSequenceValueAt(a, b, position);
- }
- return result;
- }
- public int[] BackwardSequence(int a, SequenceVar b) {
- int size = BackwardSequenceSize(a, b);
- int[] result = new int[size];
- for (int position = 0; position < size; ++position) {
- result[position] = BackwardSequenceValueAt(a, b, position);
- }
- return result;
- }
- public int[] Unperformed(int a, SequenceVar b) {
- int size = UnperformedSize(a, b);
- int[] result = new int[size];
- for (int position = 0; position < size; ++position) {
- result[position] = UnperformedValueAt(a, b, position);
- }
- return result;
- }
-%}
-
-CS_VECTOR_RETURN1(operations_research, Assignment, ForwardSequence,
- int, const SequenceVar* const)
-CS_VECTOR_RETURN1(operations_research, Assignment, BackwardSequence,
- int, const SequenceVar* const)
-CS_VECTOR_RETURN1(operations_research, Assignment, Unperformed,
- int, const SequenceVar* const)
-
-%typemap(cscode) operations_research::Assignment %{
- public int[] ForwardSequence(SequenceVar a) {
- int size = ForwardSequenceSize(a);
- int[] result = new int[size];
- for (int position = 0; position < size; ++position) {
- result[position] = ForwardSequenceValueAt(a, position);
- }
- return result;
- }
- public int[] BackwardSequence(SequenceVar a) {
- int size = BackwardSequenceSize(a);
- int[] result = new int[size];
- for (int position = 0; position < size; ++position) {
- result[position] = BackwardSequenceValueAt(a, position);
- }
- return result;
- }
- public int[] Unperformed(SequenceVar a) {
- int size = UnperformedSize(a);
- int[] result = new int[size];
- for (int position = 0; position < size; ++position) {
- result[position] = UnperformedValueAt(a, position);
- }
- return result;
- }
-%}
-
-CS_VECTOR_RETURN0(operations_research, SequenceVarElement, ForwardSequence,
- int)
-CS_VECTOR_RETURN0(operations_research, SequenceVarElement, BackwardSequence,
- int)
-CS_VECTOR_RETURN0(operations_research, SequenceVarElement, Unperformed,
- int)
-
-%typemap(cscode) operations_research::SequenceVarElement %{
- public int[] ForwardSequence() {
- int size = ForwardSequenceSize();
- int[] result = new int[size];
- for (int position = 0; position < size; ++position) {
- result[position] = ForwardSequenceValueAt(position);
- }
- return result;
- }
- public int[] BackwardSequence() {
- int size = BackwardSequenceSize();
- int[] result = new int[size];
- for (int position = 0; position < size; ++position) {
- result[position] = BackwardSequenceValueAt(position);
- }
- return result;
- }
- public int[] Unperformed() {
- int size = UnperformedSize();
- int[] result = new int[size];
- for (int position = 0; position < size; ++position) {
- result[position] = UnperformedValueAt(position);
- }
- return result;
- }
-%}
-
-
-%extend operations_research::IntVarLocalSearchOperator {
- int64 Value(int64 index) const { return self->Value(index); }
- int64 OldValue(int64 index) const { return self->OldValue(index); }
-}
-
namespace operations_research {
class LocalSearchPhaseParameters {
public:
@@ -1022,10 +978,19 @@ class LocalSearchPhaseParameters {
%include constraint_solver/constraint_solver.h
%include constraint_solver/constraint_solveri.h
-// Define templates instantiation after wrapping.
namespace operations_research {
%template(RevInteger) Rev;
%template(RevBool) Rev;
typedef Assignment::AssignmentContainer AssignmentContainer;
%template(AssignmentIntContainer) AssignmentContainer;
+
+// We can't use VarLocalSearchOperator::[Old]Value() because it's problematic
+// when instantiated on the SequenceVarLocalSearchOperator subclass (because
+// their return type is a const std::vector&). So we ignore them and
+// redefine them here, only for the base class of IntVarLocalSearchOperator.
+%extend VarLocalSearchOperator {
+ int64 Value(int64 i) const { return $self->Value(i); }
+ int64 OldValue(int64 i) const { return $self->OldValue(i); }
+}
}
diff --git a/src/constraint_solver/csharp/routing.swig b/src/constraint_solver/csharp/routing.swig
index 38f9b8ca90..02d6136c6f 100644
--- a/src/constraint_solver/csharp/routing.swig
+++ b/src/constraint_solver/csharp/routing.swig
@@ -1,4 +1,4 @@
-// Copyright 2010-2013 Google
+// Copyright 2010-2014 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
@@ -10,6 +10,7 @@
// 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.
+// TODO(user): Refactor this file to adhere to the SWIG style guide.
%include "constraint_solver/csharp/constraint_solver.swig"
diff --git a/src/graph/csharp/graph.swig b/src/graph/csharp/graph.swig
index ba8b589689..1487bec7f1 100644
--- a/src/graph/csharp/graph.swig
+++ b/src/graph/csharp/graph.swig
@@ -1,54 +1,136 @@
-// TODO(user): Refactor this file to adhere to the SWIG style guide.
+// Copyright 2010-2014 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.
+// This .swig file is only used in the open-source export of
+//
+// It exposes some of the C++ classes in ../, namely :
+// - SimpleMaxFlow, from ../max_flow.h
+// - SimpleMinCostFlow, from ../min_cost_flow.h
+// - LinearSumAssignment, from ../assignment.h
+//
+// USAGE EXAMPLES:
+// - examples/csharp/assignment.cs
+// - examples/csharp/csflow.cs
-%include util/csharp/data.swig
+%include "base/base.swig"
+
+%import "graph/ebert_graph.h"
-// First phase: #include the file we want to wrap.
%{
-#include "util/zvector.h"
-#include "graph/ebert_graph.h"
#include "graph/assignment.h"
#include "graph/max_flow.h"
#include "graph/min_cost_flow.h"
%}
-// Rename rules on EbertGraph.
-%rename(EndArcIndex) operations_research::StarGraphBase::end_arc_index;
-%rename(EndNodeIndex) operations_research::StarGraphBase::end_node_index;
-%rename(MaxEndArcIndex) operations_research::StarGraphBase::max_end_arc_index;
-%rename(MaxEndNodeIndex) operations_research::StarGraphBase::max_end_node_index;
-%rename(MaxNumArcs) operations_research::StarGraphBase::max_num_arcs;
-%rename(MaxNumArcs) operations_research::StarGraphBase::max_num_arcs;
-%rename(MaxNumNodes) operations_research::StarGraphBase::max_num_nodes;
-%rename(MaxNumNodes) operations_research::StarGraphBase::max_num_nodes;
-%rename(NumArcs) operations_research::StarGraphBase::num_arcs;
-%rename(NumNodes) operations_research::StarGraphBase::num_nodes;
+// ############ max_flow.h ############
-// Rename rules on MaxFlow.
-%rename (Graph) operations_research::MaxFlow::graph;
-%rename (GetStatus) operations_research::MaxFlow::status;
+%ignoreall
-// Rename rules on MinCostFlow.
-%rename (Graph) operations_research::MinCostFlow::graph;
-%rename (GetStatus) operations_research::MinCostFlow::status;
+%unignore operations_research;
+%rename (MaxFlow) operations_research::SimpleMaxFlow;
+%unignore operations_research::SimpleMaxFlow::SimpleMaxFlow;
+// %unignore operations_research::SimpleMaxFlow::~SimpleMaxFlow;
+%unignore operations_research::SimpleMaxFlow::AddArcWithCapacity;
+%unignore operations_research::SimpleMaxFlow::Solve;
+%unignore operations_research::SimpleMaxFlow::NumNodes;
+%unignore operations_research::SimpleMaxFlow::NumArcs;
+%unignore operations_research::SimpleMaxFlow::Tail;
+%unignore operations_research::SimpleMaxFlow::Head;
+%unignore operations_research::SimpleMaxFlow::Capacity;
+%unignore operations_research::SimpleMaxFlow::OptimalFlow;
+%unignore operations_research::SimpleMaxFlow::Flow;
+%unignore operations_research::SimpleMaxFlow::GetSourceSideMinCut;
+%unignore operations_research::SimpleMaxFlow::GetSinkSideMinCut;
-// Use the SimpleLinearSumAssignment.
-%rename(ComplexLinearSumAssignment) operations_research::LinearSumAssignment;
-%rename(LinearSumAssignment) operations_research::SimpleLinearSumAssignment;
-
-// Second phase: %include the same files.
-%include "util/zvector.h"
-%include "graph/ebert_graph.h"
-%include "graph/assignment.h"
+// Expose the "operations_research::SimpleMaxFlow::Status" enum.
+%unignore operations_research::SimpleMaxFlow::Status;
+%unignore operations_research::SimpleMaxFlow::OPTIMAL;
+%unignore operations_research::SimpleMaxFlow::POSSIBLE_OVERFLOW;
+%unignore operations_research::SimpleMaxFlow::BAD_INPUT;
+%unignore operations_research::SimpleMaxFlow::BAD_RESULT;
%include "graph/max_flow.h"
+
+%unignoreall
+
+// ############ min_cost_flow.h ############
+
+%ignoreall
+
+%unignore operations_research;
+
+// We prefer our users to access the Status enum via the "SimpleMinCostFlow"
+// class, i.e. SimpleMinCostFlow.OPTIMAL. But since they're defined on a
+// base class in the .h, we must expose it.
+%unignore operations_research::MinCostFlowBase;
+%unignore operations_research::MinCostFlowBase::Status;
+%unignore operations_research::MinCostFlowBase::OPTIMAL;
+%unignore operations_research::MinCostFlowBase::NOT_SOLVED;
+%unignore operations_research::MinCostFlowBase::FEASIBLE;
+%unignore operations_research::MinCostFlowBase::INFEASIBLE;
+%unignore operations_research::MinCostFlowBase::UNBALANCED;
+%unignore operations_research::MinCostFlowBase::BAD_RESULT;
+%unignore operations_research::MinCostFlowBase::BAD_COST_RANGE;
+
+%rename (MinCostFlow) operations_research::SimpleMinCostFlow;
+%unignore operations_research::SimpleMinCostFlow::SimpleMinCostFlow;
+%unignore operations_research::SimpleMinCostFlow::~SimpleMinCostFlow;
+%unignore operations_research::SimpleMinCostFlow::AddArcWithCapacityAndUnitCost;
+%unignore operations_research::SimpleMinCostFlow::SetNodeSupply;
+%unignore operations_research::SimpleMinCostFlow::Solve;
+%unignore operations_research::SimpleMinCostFlow::SolveMaxFlowWithMinCost;
+%unignore operations_research::SimpleMinCostFlow::OptimalCost;
+%unignore operations_research::SimpleMinCostFlow::MaximumFlow;
+%unignore operations_research::SimpleMinCostFlow::Flow;
+%unignore operations_research::SimpleMinCostFlow::NumNodes;
+%unignore operations_research::SimpleMinCostFlow::NumArcs;
+%unignore operations_research::SimpleMinCostFlow::Tail;
+%unignore operations_research::SimpleMinCostFlow::Head;
+%unignore operations_research::SimpleMinCostFlow::Capacity;
+%unignore operations_research::SimpleMinCostFlow::Supply;
+%unignore operations_research::SimpleMinCostFlow::UnitCost;
+
%include "graph/min_cost_flow.h"
-%template(StarStarGraphBase) operations_research::StarGraphBase >;
-%template(StarGraphCore) operations_research::EbertGraphBase >;
-%template(StarGraph) operations_research::EbertGraph;
-%template(ForwardStarStarGraphBase) operations_research::StarGraphBase >;
-%template(ForwardStarGraphCore) operations_research::EbertGraphBase >;
-%template(ForwardStarGraph) operations_research::ForwardEbertGraph;
-%template(ForwardStarStaticStarGraphBase) operations_research::StarGraphBase >;
-%template(ForwardStarStaticGraph) operations_research::ForwardStaticGraph;
-%template(MaxFlow) operations_research::GenericMaxFlow >;
-%template(MinCostFlow) operations_research::GenericMinCostFlow, operations_research::FlowQuantity, operations_research::CostValue>;
+%unignoreall
+
+// ############ assignment.h ############
+
+// TODO(user): document which method is tested and which isn't, once the C#
+// example using this code has been backported from or-tools.
+%ignoreall
+
+%unignore operations_research;
+// We only expose the C++ "operations_research::SimpleLinearSumAssignment"
+// class, and we rename it "LinearSumAssignment".
+%rename(LinearSumAssignment) operations_research::SimpleLinearSumAssignment;
+%unignore
+ operations_research::SimpleLinearSumAssignment::SimpleLinearSumAssignment;
+%unignore operations_research::SimpleLinearSumAssignment::AddArcWithCost;
+%unignore operations_research::SimpleLinearSumAssignment::Solve;
+%unignore operations_research::SimpleLinearSumAssignment::NumNodes;
+%unignore operations_research::SimpleLinearSumAssignment::NumArcs;
+%unignore operations_research::SimpleLinearSumAssignment::LeftNode;
+%unignore operations_research::SimpleLinearSumAssignment::RightNode;
+%unignore operations_research::SimpleLinearSumAssignment::Cost;
+%unignore operations_research::SimpleLinearSumAssignment::OptimalCost;
+%unignore operations_research::SimpleLinearSumAssignment::RightMate;
+%unignore operations_research::SimpleLinearSumAssignment::AssignmentCost;
+
+// Expose the "operations_research::SimpleLinearSumAssignment::Status" enum.
+%unignore operations_research::SimpleLinearSumAssignment::Status;
+%unignore operations_research::SimpleLinearSumAssignment::OPTIMAL;
+%unignore operations_research::SimpleLinearSumAssignment::INFEASIBLE;
+%unignore operations_research::SimpleLinearSumAssignment::POSSIBLE_OVERFLOW;
+
+%include "graph/assignment.h"
+
+%unignoreall
diff --git a/src/util/csharp/data.swig b/src/util/csharp/data.swig
index fb6a3591fb..9778de0b29 100644
--- a/src/util/csharp/data.swig
+++ b/src/util/csharp/data.swig
@@ -238,43 +238,3 @@ CS_TYPEMAP_STDVECTOR_IN1(int, int, int)
}
}
%enddef // end PROTO2_RETURN_AND_DELETE
-
-%define CS_VECTOR_RETURN0(Namespace, Class, Method, RType)
-%ignore Namespace::Class::Method;
-
-%extend Namespace::Class {
- int Method ## Size() const {
- return self->Method().size();
- }
- RType Method ## ValueAt(int index) const {
- return self->Method()[index];
- }
-}
-%enddef // CS_VECTOR_RETURN0
-
-%define CS_VECTOR_RETURN1(Namespace, Class, Method, RType, ArgType)
-%ignore Namespace::Class::Method;
-
-%extend Namespace::Class {
- int Method ## Size(ArgType a) const {
- return self->Method(a).size();
- }
- RType Method ## ValueAt(ArgType a, int index) const {
- return self->Method(a)[index];
- }
-}
-%enddef // CS_VECTOR_RETURN1
-
-%define CS_VECTOR_RETURN2(Namespace, Class, Method, RType,
- ArgType1, ArgType2)
-%ignore Namespace::Class::Method;
-
-%extend Namespace::Class {
- int Method ## Size(ArgType1 a, ArgType2 b) const {
- return self->Method(a, b).size();
- }
- RType Method ## ValueAt(ArgType1 a, ArgType2 b, int index) const {
- return self->Method(a, b)[index];
- }
-}
-%enddef // CS_VECTOR_RETURN2