@@ -12,8 +12,9 @@
|
||||
// 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.
|
||||
package com.google.ortools.examples;
|
||||
package com.google.ortools.java;
|
||||
|
||||
import com.google.ortools.Loader;
|
||||
import com.google.ortools.constraintsolver.Assignment;
|
||||
import com.google.ortools.constraintsolver.FirstSolutionStrategy;
|
||||
import com.google.ortools.constraintsolver.IntVar;
|
||||
@@ -50,11 +51,6 @@ class Pair<K, V> {
|
||||
* using the swig-wrapped version of the vehicle routing library in src/constraint_solver.
|
||||
*/
|
||||
public class CapacitatedVehicleRoutingProblemWithTimeWindows {
|
||||
|
||||
static {
|
||||
System.loadLibrary("jniortools");
|
||||
}
|
||||
|
||||
private static Logger logger =
|
||||
Logger.getLogger(CapacitatedVehicleRoutingProblemWithTimeWindows.class.getName());
|
||||
|
||||
@@ -289,6 +285,7 @@ public class CapacitatedVehicleRoutingProblemWithTimeWindows {
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
Loader.loadNativeLibraries();
|
||||
CapacitatedVehicleRoutingProblemWithTimeWindows problem =
|
||||
new CapacitatedVehicleRoutingProblemWithTimeWindows();
|
||||
final int xMax = 20;
|
||||
|
||||
@@ -10,21 +10,14 @@
|
||||
// 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.
|
||||
package com.google.ortools.examples;
|
||||
package com.google.ortools.java;
|
||||
|
||||
import com.google.ortools.Loader;
|
||||
import com.google.ortools.graph.MaxFlow;
|
||||
import com.google.ortools.graph.MinCostFlow;
|
||||
|
||||
/**
|
||||
* Sample showing how to model using the flow solver.
|
||||
*
|
||||
*/
|
||||
|
||||
/** Sample showing how to model using the flow solver. */
|
||||
public class FlowExample {
|
||||
static {
|
||||
System.loadLibrary("jniortools");
|
||||
}
|
||||
|
||||
private static void solveMinCostFlow() {
|
||||
System.out.println("Min Cost Flow Problem - Simple interface");
|
||||
final int numSources = 4;
|
||||
@@ -83,6 +76,7 @@ public class FlowExample {
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
Loader.loadNativeLibraries();
|
||||
FlowExample.solveMinCostFlow();
|
||||
FlowExample.solveMaxFlow();
|
||||
}
|
||||
|
||||
@@ -10,24 +10,16 @@
|
||||
// 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.
|
||||
package com.google.ortools.java;
|
||||
|
||||
package com.google.ortools.examples;
|
||||
|
||||
import com.google.ortools.Loader;
|
||||
import com.google.ortools.linearsolver.MPConstraint;
|
||||
import com.google.ortools.linearsolver.MPObjective;
|
||||
import com.google.ortools.linearsolver.MPSolver;
|
||||
import com.google.ortools.linearsolver.MPVariable;
|
||||
|
||||
/**
|
||||
* Integer programming example that shows how to use the API.
|
||||
*
|
||||
*/
|
||||
|
||||
/** Integer programming example that shows how to use the API. */
|
||||
public class IntegerProgramming {
|
||||
static {
|
||||
System.loadLibrary("jniortools");
|
||||
}
|
||||
|
||||
private static void runIntegerProgrammingExample(String solverType) {
|
||||
MPSolver solver = MPSolver.createSolver(solverType);
|
||||
if (solver == null) {
|
||||
@@ -79,6 +71,7 @@ public class IntegerProgramming {
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
Loader.loadNativeLibraries();
|
||||
System.out.println("---- Integer programming example with SCIP (recommended) ----");
|
||||
runIntegerProgrammingExample("SCIP");
|
||||
System.out.println("---- Integer programming example with CBC ----");
|
||||
|
||||
@@ -10,22 +10,17 @@
|
||||
// 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.
|
||||
package com.google.ortools.examples;
|
||||
package com.google.ortools.java;
|
||||
|
||||
import com.google.ortools.Loader;
|
||||
import com.google.ortools.graph.LinearSumAssignment;
|
||||
|
||||
/**
|
||||
* Test assignment on a 4x4 matrix. Example taken from
|
||||
* http://www.ee.oulu.fi/~mpa/matreng/eem1_2-1.htm with kCost[0][1]
|
||||
* modified so the optimum solution is unique.
|
||||
*
|
||||
*/
|
||||
|
||||
public class LinearAssignmentAPI {
|
||||
static {
|
||||
System.loadLibrary("jniortools");
|
||||
}
|
||||
|
||||
private static void runAssignmentOn4x4Matrix() {
|
||||
final int numSources = 4;
|
||||
final int numTargets = 4;
|
||||
@@ -52,6 +47,7 @@ public class LinearAssignmentAPI {
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
Loader.loadNativeLibraries();
|
||||
LinearAssignmentAPI.runAssignmentOn4x4Matrix();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,9 +10,9 @@
|
||||
// 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.
|
||||
package com.google.ortools.java;
|
||||
|
||||
package com.google.ortools.examples;
|
||||
|
||||
import com.google.ortools.Loader;
|
||||
import com.google.ortools.linearsolver.MPConstraint;
|
||||
import com.google.ortools.linearsolver.MPObjective;
|
||||
import com.google.ortools.linearsolver.MPSolver;
|
||||
@@ -20,14 +20,8 @@ import com.google.ortools.linearsolver.MPVariable;
|
||||
|
||||
/**
|
||||
* Linear programming example that shows how to use the API.
|
||||
*
|
||||
*/
|
||||
|
||||
public class LinearProgramming {
|
||||
static {
|
||||
System.loadLibrary("jniortools");
|
||||
}
|
||||
|
||||
private static void runLinearProgrammingExample(String solverType, boolean printModel) {
|
||||
MPSolver solver = MPSolver.createSolver(solverType);
|
||||
if (solver == null) {
|
||||
@@ -115,6 +109,7 @@ public class LinearProgramming {
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
Loader.loadNativeLibraries();
|
||||
System.out.println("---- Linear programming example with GLOP (recommended) ----");
|
||||
runLinearProgrammingExample("GLOP", true);
|
||||
System.out.println("---- Linear programming example with CLP ----");
|
||||
|
||||
@@ -10,25 +10,19 @@
|
||||
// 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.
|
||||
package com.google.ortools.examples;
|
||||
package com.google.ortools.java;
|
||||
|
||||
import com.google.ortools.Loader;
|
||||
import com.google.ortools.constraintsolver.ConstraintSolverParameters;
|
||||
import com.google.ortools.constraintsolver.DecisionBuilder;
|
||||
import com.google.ortools.constraintsolver.IntVar;
|
||||
import com.google.ortools.constraintsolver.Solver;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
/**
|
||||
* Sample showing how to model using the constraint programming solver.
|
||||
*
|
||||
*/
|
||||
/** Sample showing how to model using the constraint programming solver.*/
|
||||
public class RabbitsPheasants {
|
||||
private static Logger logger = Logger.getLogger(RabbitsPheasants.class.getName());
|
||||
|
||||
static {
|
||||
System.loadLibrary("jniortools");
|
||||
}
|
||||
|
||||
/**
|
||||
* Solves the rabbits + pheasants problem. We are seing 20 heads
|
||||
* and 56 legs. How many rabbits and how many pheasants are we thus
|
||||
@@ -55,6 +49,7 @@ public class RabbitsPheasants {
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
Loader.loadNativeLibraries();
|
||||
boolean traceSearch = args.length > 0 && args[1].equals("--trace");
|
||||
RabbitsPheasants.solve(traceSearch);
|
||||
}
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
//
|
||||
// Copyright 2010-2017 Google LLC
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
@@ -12,8 +11,9 @@
|
||||
// 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.
|
||||
package com.google.ortools.examples;
|
||||
package com.google.ortools.java;
|
||||
|
||||
import com.google.ortools.Loader;
|
||||
import com.google.ortools.constraintsolver.Assignment;
|
||||
import com.google.ortools.constraintsolver.FirstSolutionStrategy;
|
||||
import com.google.ortools.constraintsolver.RoutingIndexManager;
|
||||
@@ -28,11 +28,7 @@ import java.util.function.LongBinaryOperator;
|
||||
import java.util.function.LongUnaryOperator;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
class RandomTsp {
|
||||
static {
|
||||
System.loadLibrary("jniortools");
|
||||
}
|
||||
|
||||
public class RandomTsp {
|
||||
private static Logger logger =
|
||||
Logger.getLogger(RandomTsp.class.getName());
|
||||
|
||||
@@ -122,6 +118,7 @@ class RandomTsp {
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
Loader.loadNativeLibraries();
|
||||
int size = 10;
|
||||
if (args.length > 0) {
|
||||
size = Integer.parseInt(args[0]);
|
||||
|
||||
Reference in New Issue
Block a user