@@ -12,6 +12,7 @@
|
||||
// limitations under the License.
|
||||
package com.google.ortools.contrib;
|
||||
|
||||
import com.google.ortools.Loader;
|
||||
import com.google.ortools.constraintsolver.DecisionBuilder;
|
||||
import com.google.ortools.constraintsolver.IntVar;
|
||||
import com.google.ortools.constraintsolver.Solver;
|
||||
@@ -20,18 +21,10 @@ import java.text.*;
|
||||
import java.util.*;
|
||||
|
||||
public class AllDifferentExcept0 {
|
||||
|
||||
static {
|
||||
System.loadLibrary("jniortools");
|
||||
}
|
||||
|
||||
//
|
||||
// alldifferent_except_0(solver, x)
|
||||
//
|
||||
// A decomposition of the global constraint
|
||||
// alldifferent_except_0, i.e. all values
|
||||
// must be either distinct, or 0.
|
||||
//
|
||||
public static void alldifferent_except_0(Solver solver, IntVar[] a) {
|
||||
|
||||
int n = a.length;
|
||||
@@ -104,6 +97,7 @@ public class AllDifferentExcept0 {
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
Loader.loadNativeLibraries();
|
||||
AllDifferentExcept0.solve();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
// limitations under the License.
|
||||
package com.google.ortools.contrib;
|
||||
|
||||
import com.google.ortools.Loader;
|
||||
import com.google.ortools.constraintsolver.DecisionBuilder;
|
||||
import com.google.ortools.constraintsolver.IntVar;
|
||||
import com.google.ortools.constraintsolver.Solver;
|
||||
@@ -20,16 +21,10 @@ import java.text.*;
|
||||
import java.util.*;
|
||||
|
||||
public class AllInterval {
|
||||
|
||||
static {
|
||||
System.loadLibrary("jniortools");
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements the all interval problem. See http://www.hakank.org/google_or_tools/all_interval.py
|
||||
*/
|
||||
private static void solve(int n) {
|
||||
|
||||
Solver solver = new Solver("AllInterval");
|
||||
|
||||
//
|
||||
@@ -87,6 +82,7 @@ public class AllInterval {
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
Loader.loadNativeLibraries();
|
||||
|
||||
int n = 12;
|
||||
if (args.length > 0) {
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
// limitations under the License.
|
||||
package com.google.ortools.contrib;
|
||||
|
||||
import com.google.ortools.Loader;
|
||||
import com.google.ortools.constraintsolver.DecisionBuilder;
|
||||
import com.google.ortools.constraintsolver.IntVar;
|
||||
import com.google.ortools.constraintsolver.Solver;
|
||||
@@ -20,11 +21,6 @@ import java.text.*;
|
||||
import java.util.*;
|
||||
|
||||
public class Circuit {
|
||||
|
||||
static {
|
||||
System.loadLibrary("jniortools");
|
||||
}
|
||||
|
||||
/**
|
||||
* circuit(solver, x)
|
||||
*
|
||||
@@ -100,6 +96,7 @@ public class Circuit {
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
Loader.loadNativeLibraries();
|
||||
|
||||
int n = 5;
|
||||
if (args.length > 0) {
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
// limitations under the License.
|
||||
package com.google.ortools.contrib;
|
||||
|
||||
import com.google.ortools.Loader;
|
||||
import com.google.ortools.constraintsolver.DecisionBuilder;
|
||||
import com.google.ortools.constraintsolver.IntVar;
|
||||
import com.google.ortools.constraintsolver.OptimizeVar;
|
||||
@@ -21,11 +22,6 @@ import java.text.*;
|
||||
import java.util.*;
|
||||
|
||||
public class CoinsGrid {
|
||||
|
||||
static {
|
||||
System.loadLibrary("jniortools");
|
||||
}
|
||||
|
||||
/** Solves the Coins Grid problem. See http://www.hakank.org/google_or_tools/coins_grid.py */
|
||||
private static void solve() {
|
||||
Solver solver = new Solver("CoinsGrid");
|
||||
@@ -111,6 +107,7 @@ public class CoinsGrid {
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
Loader.loadNativeLibraries();
|
||||
CoinsGrid.solve();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -43,13 +43,10 @@
|
||||
*/
|
||||
package com.google.ortools.contrib;
|
||||
|
||||
import com.google.ortools.Loader;
|
||||
import com.google.ortools.linearsolver.*;
|
||||
|
||||
public class CoinsGridMIP {
|
||||
static {
|
||||
System.loadLibrary("jniortools");
|
||||
}
|
||||
|
||||
private static void solve(String solverType) {
|
||||
System.out.println("---- CoinsGridMIP with " + solverType);
|
||||
|
||||
@@ -95,6 +92,7 @@ public class CoinsGridMIP {
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
Loader.loadNativeLibraries();
|
||||
solve("SCIP");
|
||||
solve("CBC");
|
||||
solve("GLPK");
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
*/
|
||||
package com.google.ortools.contrib;
|
||||
|
||||
import com.google.ortools.Loader;
|
||||
import com.google.ortools.linearsolver.MPConstraint;
|
||||
import com.google.ortools.linearsolver.MPObjective;
|
||||
import com.google.ortools.linearsolver.MPSolver;
|
||||
@@ -35,10 +36,6 @@ public class ColoringMIP {
|
||||
}
|
||||
}
|
||||
|
||||
static {
|
||||
System.loadLibrary("jniortools");
|
||||
}
|
||||
|
||||
private static void solve(String solverType) {
|
||||
System.out.println("---- CoinsGridMIP with " + solverType);
|
||||
|
||||
@@ -135,6 +132,7 @@ public class ColoringMIP {
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
Loader.loadNativeLibraries();
|
||||
solve("SCIP");
|
||||
solve("CBC");
|
||||
solve("GLPK");
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
// limitations under the License.
|
||||
package com.google.ortools.contrib;
|
||||
|
||||
import com.google.ortools.Loader;
|
||||
import com.google.ortools.constraintsolver.DecisionBuilder;
|
||||
import com.google.ortools.constraintsolver.IntVar;
|
||||
import com.google.ortools.constraintsolver.OptimizeVar;
|
||||
@@ -21,11 +22,6 @@ import java.text.*;
|
||||
import java.util.*;
|
||||
|
||||
public class CoveringOpl {
|
||||
|
||||
static {
|
||||
System.loadLibrary("jniortools");
|
||||
}
|
||||
|
||||
/** Solves a set covering problem. See http://www.hakank.org/google_or_tools/covering_opl.py */
|
||||
private static void solve() {
|
||||
|
||||
@@ -119,7 +115,7 @@ public class CoveringOpl {
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
|
||||
Loader.loadNativeLibraries();
|
||||
CoveringOpl.solve();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
// limitations under the License.
|
||||
package com.google.ortools.contrib;
|
||||
|
||||
import com.google.ortools.Loader;
|
||||
import com.google.ortools.constraintsolver.DecisionBuilder;
|
||||
import com.google.ortools.constraintsolver.IntVar;
|
||||
import com.google.ortools.constraintsolver.Solver;
|
||||
@@ -20,11 +21,6 @@ import java.text.*;
|
||||
import java.util.*;
|
||||
|
||||
public class Crossword {
|
||||
|
||||
static {
|
||||
System.loadLibrary("jniortools");
|
||||
}
|
||||
|
||||
/** Solving a simple crossword. See http://www.hakank.org/google_or_tools/crossword2.py */
|
||||
private static void solve() {
|
||||
|
||||
@@ -196,7 +192,7 @@ public class Crossword {
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
|
||||
Loader.loadNativeLibraries();
|
||||
Crossword.solve();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
// limitations under the License.
|
||||
package com.google.ortools.contrib;
|
||||
|
||||
import com.google.ortools.Loader;
|
||||
import com.google.ortools.constraintsolver.DecisionBuilder;
|
||||
import com.google.ortools.constraintsolver.IntVar;
|
||||
import com.google.ortools.constraintsolver.Solver;
|
||||
@@ -20,11 +21,6 @@ import java.text.*;
|
||||
import java.util.*;
|
||||
|
||||
public class DeBruijn {
|
||||
|
||||
static {
|
||||
System.loadLibrary("jniortools");
|
||||
}
|
||||
|
||||
/**
|
||||
* toNum(solver, a, num, base)
|
||||
*
|
||||
@@ -182,6 +178,7 @@ public class DeBruijn {
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
Loader.loadNativeLibraries();
|
||||
|
||||
int base = 2;
|
||||
int n = 3;
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
// limitations under the License.
|
||||
package com.google.ortools.contrib;
|
||||
|
||||
import com.google.ortools.Loader;
|
||||
import com.google.ortools.constraintsolver.*;
|
||||
import com.google.ortools.constraintsolver.DecisionBuilder;
|
||||
import com.google.ortools.constraintsolver.IntVar;
|
||||
@@ -21,14 +22,8 @@ import java.text.*;
|
||||
import java.util.*;
|
||||
|
||||
public class Diet {
|
||||
|
||||
static {
|
||||
System.loadLibrary("jniortools");
|
||||
}
|
||||
|
||||
/** Solves the Diet problem. See http://www.hakank.org/google_or_tools/diet1.py */
|
||||
private static void solve() {
|
||||
|
||||
Solver solver = new Solver("Diet");
|
||||
|
||||
int n = 4;
|
||||
@@ -90,6 +85,7 @@ public class Diet {
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
Loader.loadNativeLibraries();
|
||||
Diet.solve();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,16 +19,13 @@
|
||||
*/
|
||||
package com.google.ortools.contrib;
|
||||
|
||||
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;
|
||||
|
||||
public class DietMIP {
|
||||
static {
|
||||
System.loadLibrary("jniortools");
|
||||
}
|
||||
|
||||
private static void solve(String solverType) {
|
||||
MPSolver solver = MPSolver.createSolver(solverType);
|
||||
double infinity = MPSolver.infinity();
|
||||
@@ -79,6 +76,7 @@ public class DietMIP {
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
Loader.loadNativeLibraries();
|
||||
solve("CBC");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
// limitations under the License.
|
||||
package com.google.ortools.contrib;
|
||||
|
||||
import com.google.ortools.Loader;
|
||||
import com.google.ortools.constraintsolver.DecisionBuilder;
|
||||
import com.google.ortools.constraintsolver.IntVar;
|
||||
import com.google.ortools.constraintsolver.Solver;
|
||||
@@ -20,11 +21,6 @@ import java.text.*;
|
||||
import java.util.*;
|
||||
|
||||
public class DivisibleBy9Through1 {
|
||||
|
||||
static {
|
||||
System.loadLibrary("jniortools");
|
||||
}
|
||||
|
||||
/**
|
||||
* A simple propagator for modulo constraint.
|
||||
*
|
||||
@@ -168,7 +164,7 @@ public class DivisibleBy9Through1 {
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
|
||||
Loader.loadNativeLibraries();
|
||||
int base = 10;
|
||||
|
||||
if (args.length > 0) {
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
*/
|
||||
package com.google.ortools.contrib;
|
||||
|
||||
import com.google.ortools.Loader;
|
||||
import com.google.ortools.constraintsolver.DecisionBuilder;
|
||||
import com.google.ortools.constraintsolver.IntVar;
|
||||
import com.google.ortools.constraintsolver.OptimizeVar;
|
||||
@@ -35,10 +36,6 @@ import com.google.ortools.constraintsolver.Solver;
|
||||
* @since 17/03/11
|
||||
*/
|
||||
public class GolombRuler {
|
||||
static {
|
||||
System.loadLibrary("jniortools");
|
||||
}
|
||||
|
||||
/** Golomb Ruler Problem. */
|
||||
private static void solve(int m) {
|
||||
Solver solver = new Solver("GR " + m);
|
||||
@@ -83,6 +80,7 @@ public class GolombRuler {
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
Loader.loadNativeLibraries();
|
||||
GolombRuler.solve(8);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,16 +1,12 @@
|
||||
package com.google.ortools.contrib;
|
||||
|
||||
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;
|
||||
|
||||
public class Issue173 {
|
||||
|
||||
static {
|
||||
System.loadLibrary("jniortools");
|
||||
}
|
||||
|
||||
public static void breakit() {
|
||||
|
||||
for (int i = 0; i < 50000; i++) {
|
||||
@@ -34,6 +30,7 @@ public class Issue173 {
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
Loader.loadNativeLibraries();
|
||||
breakit();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,13 +22,10 @@
|
||||
*/
|
||||
package com.google.ortools.contrib;
|
||||
|
||||
import com.google.ortools.Loader;
|
||||
import com.google.ortools.linearsolver.*;
|
||||
|
||||
public class KnapsackMIP {
|
||||
static {
|
||||
System.loadLibrary("jniortools");
|
||||
}
|
||||
|
||||
private static MPSolver createSolver(String solverType) {
|
||||
try {
|
||||
return new MPSolver("MIPDiet", MPSolver.OptimizationProblemType.valueOf(solverType));
|
||||
@@ -93,6 +90,7 @@ public class KnapsackMIP {
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
Loader.loadNativeLibraries();
|
||||
solve("CBC_MIXED_INTEGER_PROGRAMMING");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,17 +12,13 @@
|
||||
// limitations under the License.
|
||||
package com.google.ortools.contrib;
|
||||
|
||||
import com.google.ortools.Loader;
|
||||
import com.google.ortools.constraintsolver.*;
|
||||
import java.io.*;
|
||||
import java.text.*;
|
||||
import java.util.*;
|
||||
|
||||
public class LeastDiff {
|
||||
|
||||
static {
|
||||
System.loadLibrary("jniortools");
|
||||
}
|
||||
|
||||
/** Solves the Least Diff problem. See http://www.hakank.org/google_or_tools/least_diff.py */
|
||||
private static void solve() {
|
||||
final int base = 10;
|
||||
@@ -90,6 +86,7 @@ public class LeastDiff {
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
Loader.loadNativeLibraries();
|
||||
LeastDiff.solve();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
// limitations under the License.
|
||||
package com.google.ortools.contrib;
|
||||
|
||||
import com.google.ortools.Loader;
|
||||
import com.google.ortools.constraintsolver.DecisionBuilder;
|
||||
import com.google.ortools.constraintsolver.IntVar;
|
||||
import com.google.ortools.constraintsolver.Solver;
|
||||
@@ -20,11 +21,6 @@ import java.text.*;
|
||||
import java.util.*;
|
||||
|
||||
public class MagicSquare {
|
||||
|
||||
static {
|
||||
System.loadLibrary("jniortools");
|
||||
}
|
||||
|
||||
/** Solves the Magic Square problem. See http://www.hakank.org/google_or_tools/magic_square.py */
|
||||
private static void solve(int n, int num) {
|
||||
|
||||
@@ -112,6 +108,7 @@ public class MagicSquare {
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
Loader.loadNativeLibraries();
|
||||
int n = 4;
|
||||
int num = 0;
|
||||
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
// limitations under the License.
|
||||
package com.google.ortools.contrib;
|
||||
|
||||
import com.google.ortools.Loader;
|
||||
import com.google.ortools.constraintsolver.*;
|
||||
import com.google.ortools.constraintsolver.DecisionBuilder;
|
||||
import com.google.ortools.constraintsolver.IntVar;
|
||||
@@ -21,14 +22,8 @@ import java.text.*;
|
||||
import java.util.*;
|
||||
|
||||
public class Map {
|
||||
|
||||
static {
|
||||
System.loadLibrary("jniortools");
|
||||
}
|
||||
|
||||
/** Solves a simple map coloring problem. See http://www.hakank.org/google_or_tools/map.py */
|
||||
private static void solve() {
|
||||
|
||||
Solver solver = new Solver("Map");
|
||||
|
||||
//
|
||||
@@ -90,6 +85,7 @@ public class Map {
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
Loader.loadNativeLibraries();
|
||||
Map.solve();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
// limitations under the License.
|
||||
package com.google.ortools.contrib;
|
||||
|
||||
import com.google.ortools.Loader;
|
||||
import com.google.ortools.constraintsolver.*;
|
||||
import com.google.ortools.constraintsolver.DecisionBuilder;
|
||||
import com.google.ortools.constraintsolver.IntVar;
|
||||
@@ -21,11 +22,6 @@ import java.text.*;
|
||||
import java.util.*;
|
||||
|
||||
public class Map2 {
|
||||
|
||||
static {
|
||||
System.loadLibrary("jniortools");
|
||||
}
|
||||
|
||||
/**
|
||||
* Solves a simple map coloring problem, take II. See http://www.hakank.org/google_or_tools/map.py
|
||||
*/
|
||||
@@ -99,6 +95,7 @@ public class Map2 {
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
Loader.loadNativeLibraries();
|
||||
Map2.solve();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
// limitations under the License.
|
||||
package com.google.ortools.contrib;
|
||||
|
||||
import com.google.ortools.Loader;
|
||||
import com.google.ortools.constraintsolver.*;
|
||||
import com.google.ortools.constraintsolver.DecisionBuilder;
|
||||
import com.google.ortools.constraintsolver.IntVar;
|
||||
@@ -21,13 +22,7 @@ import java.text.*;
|
||||
import java.util.*;
|
||||
|
||||
public class Minesweeper {
|
||||
|
||||
static {
|
||||
System.loadLibrary("jniortools");
|
||||
}
|
||||
|
||||
static int X = -1;
|
||||
|
||||
//
|
||||
// Default problem.
|
||||
// It has 4 solutions.
|
||||
@@ -200,6 +195,7 @@ public class Minesweeper {
|
||||
} // end readFile
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
Loader.loadNativeLibraries();
|
||||
|
||||
String file = "";
|
||||
if (args.length > 0) {
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.google.ortools.contrib;
|
||||
|
||||
import com.google.ortools.Loader;
|
||||
import com.google.ortools.linearsolver.MPConstraint;
|
||||
import com.google.ortools.linearsolver.MPObjective;
|
||||
import com.google.ortools.linearsolver.MPSolver;
|
||||
@@ -15,14 +16,10 @@ import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
|
||||
public class MultiThreadTest {
|
||||
|
||||
static {
|
||||
System.loadLibrary("jniortools");
|
||||
}
|
||||
|
||||
private static final boolean verboseOutput = false; // To enable Cbc logging
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
Loader.loadNativeLibraries();
|
||||
launchProtocol(10, 8, true);
|
||||
System.out.println("Cbc multi thread test successful");
|
||||
return;
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
// limitations under the License.
|
||||
package com.google.ortools.contrib;
|
||||
|
||||
import com.google.ortools.Loader;
|
||||
import com.google.ortools.constraintsolver.DecisionBuilder;
|
||||
import com.google.ortools.constraintsolver.IntVar;
|
||||
import com.google.ortools.constraintsolver.Solver;
|
||||
@@ -20,14 +21,8 @@ import java.text.*;
|
||||
import java.util.*;
|
||||
|
||||
public class NQueens {
|
||||
|
||||
static {
|
||||
System.loadLibrary("jniortools");
|
||||
}
|
||||
|
||||
/** Solves the N Queens problem. See http://www.hakank.org/google_or_tools/nqueens2.py */
|
||||
private static void solve(int n, int num, int print) {
|
||||
|
||||
Solver solver = new Solver("NQueens");
|
||||
|
||||
System.out.println("n: " + n);
|
||||
@@ -87,6 +82,7 @@ public class NQueens {
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
Loader.loadNativeLibraries();
|
||||
int n = 8;
|
||||
int num = 0;
|
||||
int print = 1;
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
// limitations under the License.
|
||||
package com.google.ortools.contrib;
|
||||
|
||||
import com.google.ortools.Loader;
|
||||
import com.google.ortools.constraintsolver.DecisionBuilder;
|
||||
import com.google.ortools.constraintsolver.IntVar;
|
||||
import com.google.ortools.constraintsolver.Solver;
|
||||
@@ -20,14 +21,8 @@ import java.text.*;
|
||||
import java.util.*;
|
||||
|
||||
public class NQueens2 {
|
||||
|
||||
static {
|
||||
System.loadLibrary("jniortools");
|
||||
}
|
||||
|
||||
/** Solves the N Queens problem. See http://www.hakank.org/google_or_tools/nqueens2.py */
|
||||
private static void solve(int n, int num, int print) {
|
||||
|
||||
Solver solver = new Solver("NQueens");
|
||||
|
||||
System.out.println("n: " + n);
|
||||
@@ -81,6 +76,7 @@ public class NQueens2 {
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
Loader.loadNativeLibraries();
|
||||
int n = 8;
|
||||
int num = 0;
|
||||
int print = 1;
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
*/
|
||||
package com.google.ortools.contrib;
|
||||
|
||||
import com.google.ortools.Loader;
|
||||
import com.google.ortools.constraintsolver.*;
|
||||
|
||||
/**
|
||||
@@ -32,11 +33,6 @@ import com.google.ortools.constraintsolver.*;
|
||||
* @since 18/03/11
|
||||
*/
|
||||
public class Partition {
|
||||
|
||||
static {
|
||||
System.loadLibrary("jniortools");
|
||||
}
|
||||
|
||||
/** Partition Problem. */
|
||||
private static void solve(int m) {
|
||||
Solver solver = new Solver("Partition " + m);
|
||||
@@ -102,6 +98,7 @@ public class Partition {
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
Loader.loadNativeLibraries();
|
||||
Partition.solve(32);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
// limitations under the License.
|
||||
package com.google.ortools.contrib;
|
||||
|
||||
import com.google.ortools.Loader;
|
||||
import com.google.ortools.constraintsolver.*;
|
||||
import com.google.ortools.constraintsolver.DecisionBuilder;
|
||||
import com.google.ortools.constraintsolver.IntVar;
|
||||
@@ -21,11 +22,6 @@ import java.text.*;
|
||||
import java.util.*;
|
||||
|
||||
public class QuasigroupCompletion {
|
||||
|
||||
static {
|
||||
System.loadLibrary("jniortools");
|
||||
}
|
||||
|
||||
static int X = 0;
|
||||
|
||||
/*
|
||||
@@ -201,6 +197,7 @@ public class QuasigroupCompletion {
|
||||
} // end readFile
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
Loader.loadNativeLibraries();
|
||||
|
||||
if (args.length > 0) {
|
||||
String file = "";
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
// limitations under the License.
|
||||
package com.google.ortools.contrib;
|
||||
|
||||
import com.google.ortools.Loader;
|
||||
import com.google.ortools.constraintsolver.DecisionBuilder;
|
||||
import com.google.ortools.constraintsolver.IntVar;
|
||||
import com.google.ortools.constraintsolver.Solver;
|
||||
@@ -20,11 +21,6 @@ import java.text.*;
|
||||
import java.util.*;
|
||||
|
||||
public class SendMoreMoney {
|
||||
|
||||
static {
|
||||
System.loadLibrary("jniortools");
|
||||
}
|
||||
|
||||
/** Solves the SEND+MORE=MONEY problem. */
|
||||
private static void solve() {
|
||||
int base = 10;
|
||||
@@ -90,6 +86,7 @@ public class SendMoreMoney {
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
Loader.loadNativeLibraries();
|
||||
SendMoreMoney.solve();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,22 +12,15 @@
|
||||
// limitations under the License.
|
||||
package com.google.ortools.contrib;
|
||||
|
||||
import com.google.ortools.Loader;
|
||||
import com.google.ortools.constraintsolver.*;
|
||||
import java.io.*;
|
||||
import java.text.*;
|
||||
import java.util.*;
|
||||
|
||||
public class SendMoreMoney2 {
|
||||
|
||||
static Solver sol;
|
||||
|
||||
static {
|
||||
System.loadLibrary("jniortools");
|
||||
}
|
||||
|
||||
//
|
||||
// Some helper methods
|
||||
//
|
||||
static IntExpr p(IntExpr a, int b, IntExpr c) {
|
||||
return sol.makeSum(sol.makeProd(a, b), c);
|
||||
}
|
||||
@@ -194,6 +187,7 @@ public class SendMoreMoney2 {
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
Loader.loadNativeLibraries();
|
||||
for (int i = 0; i < 5; i++) {
|
||||
System.out.println("\nalternative #" + i);
|
||||
SendMoreMoney2.solve(i);
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
// limitations under the License.
|
||||
package com.google.ortools.contrib;
|
||||
|
||||
import com.google.ortools.Loader;
|
||||
import com.google.ortools.constraintsolver.*;
|
||||
import com.google.ortools.constraintsolver.DecisionBuilder;
|
||||
import com.google.ortools.constraintsolver.IntVar;
|
||||
@@ -21,17 +22,11 @@ import java.text.*;
|
||||
import java.util.*;
|
||||
|
||||
public class SendMostMoney {
|
||||
|
||||
static {
|
||||
System.loadLibrary("jniortools");
|
||||
}
|
||||
|
||||
/**
|
||||
* Solves the SEND+MOST=MONEY problem, where we maximize MONEY. See
|
||||
* http://www.hakank.org/google_or_tools/send_more_money.py
|
||||
*/
|
||||
private static long solve(long MONEY) {
|
||||
|
||||
Solver solver = new Solver("SendMostMoney");
|
||||
|
||||
//
|
||||
@@ -128,6 +123,7 @@ public class SendMostMoney {
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
Loader.loadNativeLibraries();
|
||||
System.out.println("Get the max value of money:");
|
||||
long this_money = SendMostMoney.solve(0);
|
||||
System.out.println("\nThen find all solutions with this value:");
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
// limitations under the License.
|
||||
package com.google.ortools.contrib;
|
||||
|
||||
import com.google.ortools.Loader;
|
||||
import com.google.ortools.constraintsolver.DecisionBuilder;
|
||||
import com.google.ortools.constraintsolver.IntVar;
|
||||
import com.google.ortools.constraintsolver.Solver;
|
||||
@@ -20,14 +21,8 @@ import java.text.*;
|
||||
import java.util.*;
|
||||
|
||||
public class Seseman {
|
||||
|
||||
static {
|
||||
System.loadLibrary("jniortools");
|
||||
}
|
||||
|
||||
/** Solves the Seseman convent problem. See http://www.hakank.org/google_or_tools/seseman.py */
|
||||
private static void solve(int n) {
|
||||
|
||||
Solver solver = new Solver("Seseman");
|
||||
|
||||
//
|
||||
@@ -116,6 +111,7 @@ public class Seseman {
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
Loader.loadNativeLibraries();
|
||||
int n = 3;
|
||||
if (args.length > 0) {
|
||||
n = Integer.parseInt(args[0]);
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
// limitations under the License.
|
||||
package com.google.ortools.contrib;
|
||||
|
||||
import com.google.ortools.Loader;
|
||||
import com.google.ortools.constraintsolver.DecisionBuilder;
|
||||
import com.google.ortools.constraintsolver.IntVar;
|
||||
import com.google.ortools.constraintsolver.OptimizeVar;
|
||||
@@ -21,14 +22,8 @@ import java.text.*;
|
||||
import java.util.*;
|
||||
|
||||
public class SetCovering {
|
||||
|
||||
static {
|
||||
System.loadLibrary("jniortools");
|
||||
}
|
||||
|
||||
/** Solves a set covering problem. See http://www.hakank.org/google_or_tools/set_covering.py */
|
||||
private static void solve() {
|
||||
|
||||
Solver solver = new Solver("SetCovering");
|
||||
|
||||
//
|
||||
@@ -102,6 +97,7 @@ public class SetCovering {
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
Loader.loadNativeLibraries();
|
||||
SetCovering.solve();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
// limitations under the License.
|
||||
package com.google.ortools.contrib;
|
||||
|
||||
import com.google.ortools.Loader;
|
||||
import com.google.ortools.constraintsolver.DecisionBuilder;
|
||||
import com.google.ortools.constraintsolver.IntVar;
|
||||
import com.google.ortools.constraintsolver.OptimizeVar;
|
||||
@@ -21,14 +22,8 @@ import java.text.*;
|
||||
import java.util.*;
|
||||
|
||||
public class SetCovering2 {
|
||||
|
||||
static {
|
||||
System.loadLibrary("jniortools");
|
||||
}
|
||||
|
||||
/** Solves a set covering problem. See http://www.hakank.org/google_or_tools/set_covering2.py */
|
||||
private static void solve() {
|
||||
|
||||
Solver solver = new Solver("SetCovering2");
|
||||
|
||||
//
|
||||
@@ -113,6 +108,7 @@ public class SetCovering2 {
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
Loader.loadNativeLibraries();
|
||||
SetCovering2.solve();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
// limitations under the License.
|
||||
package com.google.ortools.contrib;
|
||||
|
||||
import com.google.ortools.Loader;
|
||||
import com.google.ortools.constraintsolver.DecisionBuilder;
|
||||
import com.google.ortools.constraintsolver.IntVar;
|
||||
import com.google.ortools.constraintsolver.OptimizeVar;
|
||||
@@ -21,14 +22,8 @@ import java.text.*;
|
||||
import java.util.*;
|
||||
|
||||
public class SetCovering3 {
|
||||
|
||||
static {
|
||||
System.loadLibrary("jniortools");
|
||||
}
|
||||
|
||||
/** Solves a set covering problem. See http://www.hakank.org/google_or_tools/set_covering3.py */
|
||||
private static void solve() {
|
||||
|
||||
Solver solver = new Solver("SetCovering3");
|
||||
|
||||
//
|
||||
@@ -120,6 +115,7 @@ public class SetCovering3 {
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
Loader.loadNativeLibraries();
|
||||
SetCovering3.solve();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
// limitations under the License.
|
||||
package com.google.ortools.contrib;
|
||||
|
||||
import com.google.ortools.Loader;
|
||||
import com.google.ortools.constraintsolver.DecisionBuilder;
|
||||
import com.google.ortools.constraintsolver.IntVar;
|
||||
import com.google.ortools.constraintsolver.OptimizeVar;
|
||||
@@ -21,14 +22,8 @@ import java.text.*;
|
||||
import java.util.*;
|
||||
|
||||
public class SetCovering4 {
|
||||
|
||||
static {
|
||||
System.loadLibrary("jniortools");
|
||||
}
|
||||
|
||||
/** Solves a set covering problem. See http://www.hakank.org/google_or_tools/set_covering4.py */
|
||||
private static void solve(int set_partition) {
|
||||
|
||||
Solver solver = new Solver("SetCovering4");
|
||||
|
||||
//
|
||||
@@ -121,6 +116,7 @@ public class SetCovering4 {
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
Loader.loadNativeLibraries();
|
||||
System.out.println("Set partition:");
|
||||
SetCovering4.solve(1);
|
||||
System.out.println("\nSet covering:");
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
// limitations under the License.
|
||||
package com.google.ortools.contrib;
|
||||
|
||||
import com.google.ortools.Loader;
|
||||
import com.google.ortools.constraintsolver.DecisionBuilder;
|
||||
import com.google.ortools.constraintsolver.IntVar;
|
||||
import com.google.ortools.constraintsolver.OptimizeVar;
|
||||
@@ -21,17 +22,11 @@ import java.text.*;
|
||||
import java.util.*;
|
||||
|
||||
public class SetCoveringDeployment {
|
||||
|
||||
static {
|
||||
System.loadLibrary("jniortools");
|
||||
}
|
||||
|
||||
/**
|
||||
* Solves a set covering deployment problem. See
|
||||
* http://www.hakank.org/google_or_tools/set_covering_deployment.py
|
||||
*/
|
||||
private static void solve() {
|
||||
|
||||
Solver solver = new Solver("SetCoveringDeployment");
|
||||
|
||||
//
|
||||
@@ -137,7 +132,7 @@ public class SetCoveringDeployment {
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
|
||||
Loader.loadNativeLibraries();
|
||||
SetCoveringDeployment.solve();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.google.ortools.contrib;
|
||||
|
||||
import com.google.ortools.Loader;
|
||||
import com.google.ortools.constraintsolver.Assignment;
|
||||
import com.google.ortools.constraintsolver.FirstSolutionStrategy;
|
||||
import com.google.ortools.constraintsolver.RoutingIndexManager;
|
||||
@@ -10,12 +11,7 @@ import java.util.ArrayList;
|
||||
import java.util.function.LongBinaryOperator;
|
||||
|
||||
public class SimpleRoutingTest {
|
||||
|
||||
// Static Add Library
|
||||
static {
|
||||
System.loadLibrary("jniortools");
|
||||
}
|
||||
|
||||
private ArrayList<Integer> globalRes;
|
||||
private long globalResCost;
|
||||
private int[][] costMatrix;
|
||||
@@ -94,6 +90,7 @@ public class SimpleRoutingTest {
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
Loader.loadNativeLibraries();
|
||||
int[][] values = new int[4][4];
|
||||
values[0][0] = 0;
|
||||
values[0][1] = 5;
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
// limitations under the License.
|
||||
package com.google.ortools.contrib;
|
||||
|
||||
import com.google.ortools.Loader;
|
||||
import com.google.ortools.constraintsolver.DecisionBuilder;
|
||||
import com.google.ortools.constraintsolver.IntVar;
|
||||
import com.google.ortools.constraintsolver.Solver;
|
||||
@@ -20,17 +21,11 @@ import java.text.*;
|
||||
import java.util.*;
|
||||
|
||||
public class StableMarriage {
|
||||
|
||||
static {
|
||||
System.loadLibrary("jniortools");
|
||||
}
|
||||
|
||||
/**
|
||||
* Solves some stable marriage problems. See
|
||||
* http://www.hakank.org/google_or_tools/stable_marriage.py
|
||||
*/
|
||||
private static void solve(long[][][] ranks, String problem_name) {
|
||||
|
||||
Solver solver = new Solver("StableMarriage");
|
||||
|
||||
//
|
||||
@@ -128,6 +123,7 @@ public class StableMarriage {
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
Loader.loadNativeLibraries();
|
||||
|
||||
//
|
||||
// From Pascal Van Hentenryck's OPL book
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
*/
|
||||
package com.google.ortools.contrib;
|
||||
|
||||
import com.google.ortools.Loader;
|
||||
import com.google.ortools.linearsolver.MPConstraint;
|
||||
import com.google.ortools.linearsolver.MPObjective;
|
||||
import com.google.ortools.linearsolver.MPSolver;
|
||||
@@ -28,10 +29,6 @@ import java.math.RoundingMode;
|
||||
import java.text.DecimalFormat;
|
||||
|
||||
public class StiglerMIP {
|
||||
static {
|
||||
System.loadLibrary("jniortools");
|
||||
}
|
||||
|
||||
private static void solve(String solverType) {
|
||||
System.out.println("---- StiglerMIP with " + solverType);
|
||||
|
||||
@@ -282,6 +279,7 @@ public class StiglerMIP {
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
Loader.loadNativeLibraries();
|
||||
solve("SCIP");
|
||||
solve("CBC");
|
||||
solve("GLPK");
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
// limitations under the License.
|
||||
package com.google.ortools.contrib;
|
||||
|
||||
import com.google.ortools.Loader;
|
||||
import com.google.ortools.constraintsolver.DecisionBuilder;
|
||||
import com.google.ortools.constraintsolver.IntVar;
|
||||
import com.google.ortools.constraintsolver.Solver;
|
||||
@@ -20,14 +21,8 @@ import java.text.*;
|
||||
import java.util.*;
|
||||
|
||||
public class Strimko2 {
|
||||
|
||||
static {
|
||||
System.loadLibrary("jniortools");
|
||||
}
|
||||
|
||||
/** Solves a Strimko problem. See http://www.hakank.org/google_or_tools/strimko2.py */
|
||||
private static void solve() {
|
||||
|
||||
Solver solver = new Solver("Strimko2");
|
||||
|
||||
//
|
||||
@@ -140,7 +135,7 @@ public class Strimko2 {
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
|
||||
Loader.loadNativeLibraries();
|
||||
Strimko2.solve();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
// limitations under the License.
|
||||
package com.google.ortools.contrib;
|
||||
|
||||
import com.google.ortools.Loader;
|
||||
import com.google.ortools.constraintsolver.DecisionBuilder;
|
||||
import com.google.ortools.constraintsolver.IntVar;
|
||||
import com.google.ortools.constraintsolver.Solver;
|
||||
@@ -20,14 +21,8 @@ import java.text.*;
|
||||
import java.util.*;
|
||||
|
||||
public class Sudoku {
|
||||
|
||||
static {
|
||||
System.loadLibrary("jniortools");
|
||||
}
|
||||
|
||||
/** Solves a Sudoku problem. */
|
||||
private static void solve() {
|
||||
|
||||
Solver solver = new Solver("Sudoku");
|
||||
|
||||
int cell_size = 3;
|
||||
@@ -126,6 +121,7 @@ public class Sudoku {
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
Loader.loadNativeLibraries();
|
||||
Sudoku.solve();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
// limitations under the License.
|
||||
package com.google.ortools.contrib;
|
||||
|
||||
import com.google.ortools.Loader;
|
||||
import com.google.ortools.constraintsolver.*;
|
||||
import com.google.ortools.constraintsolver.DecisionBuilder;
|
||||
import com.google.ortools.constraintsolver.IntVar;
|
||||
@@ -21,14 +22,7 @@ import java.text.*;
|
||||
import java.util.*;
|
||||
|
||||
public class SurvoPuzzle {
|
||||
|
||||
static {
|
||||
System.loadLibrary("jniortools");
|
||||
}
|
||||
|
||||
/*
|
||||
* default problem
|
||||
*/
|
||||
/* default problem */
|
||||
static int default_r = 3;
|
||||
static int default_c = 4;
|
||||
static int[] default_rowsums = {30, 18, 30};
|
||||
@@ -200,6 +194,7 @@ public class SurvoPuzzle {
|
||||
} // end readFile
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
Loader.loadNativeLibraries();
|
||||
|
||||
if (args.length > 0) {
|
||||
String file = args[0];
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
// limitations under the License.
|
||||
package com.google.ortools.contrib;
|
||||
|
||||
import com.google.ortools.Loader;
|
||||
import com.google.ortools.constraintsolver.DecisionBuilder;
|
||||
import com.google.ortools.constraintsolver.IntVar;
|
||||
import com.google.ortools.constraintsolver.Solver;
|
||||
@@ -20,14 +21,8 @@ import java.text.*;
|
||||
import java.util.*;
|
||||
|
||||
public class ToNum {
|
||||
|
||||
static {
|
||||
System.loadLibrary("jniortools");
|
||||
}
|
||||
|
||||
/**
|
||||
* toNum(solver, a, num, base)
|
||||
*
|
||||
* <p>channelling between the array a and the number num
|
||||
*/
|
||||
private static void toNum(Solver solver, IntVar[] a, IntVar num, int base) {
|
||||
@@ -96,6 +91,7 @@ public class ToNum {
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
Loader.loadNativeLibraries();
|
||||
ToNum.solve();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
// limitations under the License.
|
||||
package com.google.ortools.contrib;
|
||||
|
||||
import com.google.ortools.Loader;
|
||||
import com.google.ortools.constraintsolver.DecisionBuilder;
|
||||
import com.google.ortools.constraintsolver.IntVar;
|
||||
import com.google.ortools.constraintsolver.Solver;
|
||||
@@ -20,17 +21,11 @@ import java.text.*;
|
||||
import java.util.*;
|
||||
|
||||
public class WhoKilledAgatha {
|
||||
|
||||
static {
|
||||
System.loadLibrary("jniortools");
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements the Who killed Agatha problem. See
|
||||
* http://www.hakank.org/google_or_tools/who_killed_agatha.py
|
||||
*/
|
||||
private static void solve() {
|
||||
|
||||
Solver solver = new Solver("WhoKilledAgatha");
|
||||
|
||||
//
|
||||
@@ -190,6 +185,7 @@ public class WhoKilledAgatha {
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
Loader.loadNativeLibraries();
|
||||
WhoKilledAgatha.solve();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
// limitations under the License.
|
||||
package com.google.ortools.contrib;
|
||||
|
||||
import com.google.ortools.Loader;
|
||||
import com.google.ortools.constraintsolver.*;
|
||||
import com.google.ortools.constraintsolver.DecisionBuilder;
|
||||
import com.google.ortools.constraintsolver.IntVar;
|
||||
@@ -21,14 +22,8 @@ import java.text.*;
|
||||
import java.util.*;
|
||||
|
||||
public class Xkcd {
|
||||
|
||||
static {
|
||||
System.loadLibrary("jniortools");
|
||||
}
|
||||
|
||||
/** Solves the xkcd problem. See http://www.hakank.org/google_or_tools/xkcd.py */
|
||||
private static void solve() {
|
||||
|
||||
Solver solver = new Solver("Xkcd");
|
||||
|
||||
int n = 6;
|
||||
@@ -70,6 +65,7 @@ public class Xkcd {
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
Loader.loadNativeLibraries();
|
||||
Xkcd.solve();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
// limitations under the License.
|
||||
package com.google.ortools.contrib;
|
||||
|
||||
import com.google.ortools.Loader;
|
||||
import com.google.ortools.constraintsolver.DecisionBuilder;
|
||||
import com.google.ortools.constraintsolver.IntVar;
|
||||
import com.google.ortools.constraintsolver.Solver;
|
||||
@@ -20,17 +21,11 @@ import java.text.*;
|
||||
import java.util.*;
|
||||
|
||||
public class YoungTableaux {
|
||||
|
||||
static {
|
||||
System.loadLibrary("jniortools");
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements Young tableaux and partitions. See
|
||||
* http://www.hakank.org/google_or_tools/young_tableuax.py
|
||||
*/
|
||||
private static void solve(int n) {
|
||||
|
||||
Solver solver = new Solver("YoungTableaux");
|
||||
|
||||
System.out.println("n: " + n);
|
||||
@@ -133,6 +128,7 @@ public class YoungTableaux {
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
Loader.loadNativeLibraries();
|
||||
|
||||
int n = 5;
|
||||
if (args.length > 0) {
|
||||
|
||||
@@ -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]);
|
||||
|
||||
@@ -365,20 +365,6 @@ $(CLASS_DIR)/%: $(TEST_DIR)/%.java $(JAVA_ORTOOLS_JAR) | $(CLASS_DIR)
|
||||
-cp $(LIB_DIR)$Scom.google.ortools.jar$(CPSEP)$(LIB_DIR)$Sprotobuf.jar \
|
||||
$(TEST_PATH)$S$*.java
|
||||
|
||||
$(CLASS_DIR)/%: $(JAVA_EX_DIR)/%.java $(JAVA_ORTOOLS_JAR) | $(CLASS_DIR)
|
||||
-$(DELREC) $(CLASS_DIR)$S$*
|
||||
-$(MKDIR_P) $(CLASS_DIR)$S$*
|
||||
"$(JAVAC_BIN)" -encoding UTF-8 -d $(CLASS_DIR)$S$* \
|
||||
-cp $(LIB_DIR)$Scom.google.ortools.jar$(CPSEP)$(LIB_DIR)$Sprotobuf.jar \
|
||||
$(JAVA_EX_PATH)$S$*.java
|
||||
|
||||
$(CLASS_DIR)/%: $(CONTRIB_EX_DIR)/%.java $(JAVA_ORTOOLS_JAR) | $(CLASS_DIR)
|
||||
-$(DELREC) $(CLASS_DIR)$S$*
|
||||
-$(MKDIR_P) $(CLASS_DIR)$S$*
|
||||
"$(JAVAC_BIN)" -encoding UTF-8 -d $(CLASS_DIR)$S$* \
|
||||
-cp $(LIB_DIR)$Scom.google.ortools.jar$(CPSEP)$(LIB_DIR)$Sprotobuf.jar \
|
||||
$(CONTRIB_EX_PATH)$S$*.java
|
||||
|
||||
$(LIB_DIR)/%$J: $(CLASS_DIR)/% | $(LIB_DIR)
|
||||
-$(DEL) $(LIB_DIR)$S$*.jar
|
||||
"$(JAR_BIN)" cvf $(LIB_DIR)$S$*.jar -C $(CLASS_DIR)$S$* .
|
||||
@@ -388,16 +374,6 @@ rjava_%: $(TEST_DIR)/%.java $(LIB_DIR)/%$J FORCE
|
||||
-cp $(LIB_DIR)$S$*$J$(CPSEP)$(LIB_DIR)$Scom.google.ortools.jar$(CPSEP)$(LIB_DIR)$Sprotobuf.jar \
|
||||
$* $(ARGS)
|
||||
|
||||
rjava_%: $(JAVA_EX_DIR)/%.java $(LIB_DIR)/%$J FORCE
|
||||
"$(JAVA_BIN)" -Xss2048k $(JAVAFLAGS) \
|
||||
-cp $(LIB_DIR)$S$*$J$(CPSEP)$(LIB_DIR)$Scom.google.ortools.jar$(CPSEP)$(LIB_DIR)$Sprotobuf.jar \
|
||||
com.google.ortools.examples.$* $(ARGS)
|
||||
|
||||
rjava_%: $(CONTRIB_EX_DIR)/%.java $(LIB_DIR)/%$J FORCE
|
||||
"$(JAVA_BIN)" -Xss2048k $(JAVAFLAGS) \
|
||||
-cp $(LIB_DIR)$S$*$J$(CPSEP)$(LIB_DIR)$Scom.google.ortools.jar$(CPSEP)$(LIB_DIR)$Sprotobuf.jar \
|
||||
com.google.ortools.contrib.$* $(ARGS)
|
||||
|
||||
.PHONY: test_java_algorithms_samples # Build and Run all Java Algorithms Samples (located in ortools/algorithms/samples)
|
||||
test_java_algorithms_samples: \
|
||||
rjava_Knapsack
|
||||
@@ -676,6 +652,52 @@ endef
|
||||
|
||||
$(foreach sample,$(SAMPLES),$(eval $(call java-sample-target,$(sample),$(subst _,,$(sample)))))
|
||||
|
||||
EXAMPLES := contrib java
|
||||
|
||||
define java-example-target
|
||||
$$(TEMP_JAVA_DIR)/$1: | $$(TEMP_JAVA_DIR)
|
||||
-$$(MKDIR) $$(TEMP_JAVA_DIR)$$S$1
|
||||
|
||||
$$(TEMP_JAVA_DIR)/$1/%: \
|
||||
$$(SRC_DIR)/examples/$1/%.java \
|
||||
| $$(TEMP_JAVA_DIR)/$1
|
||||
-$$(MKDIR) $$(TEMP_JAVA_DIR)$$S$1$$S$$*
|
||||
|
||||
$$(TEMP_JAVA_DIR)/$1/%/pom.xml: \
|
||||
$${SRC_DIR}/ortools/java/pom-sample.xml.in \
|
||||
| $$(TEMP_JAVA_DIR)/$1/%
|
||||
$$(SED) -e "s/@JAVA_PACKAGE@/$$(JAVA_ORTOOLS_PACKAGE)/" \
|
||||
ortools$$Sjava$$Spom-sample.xml.in \
|
||||
> $$(TEMP_JAVA_DIR)$$S$1$$S$$*$$Spom.xml
|
||||
$$(SED) -i -e 's/@JAVA_SAMPLE_PROJECT@/$$*/' \
|
||||
$$(TEMP_JAVA_DIR)$$S$1$$S$$*$$Spom.xml
|
||||
$$(SED) -i -e 's/@PROJECT_VERSION@/$$(OR_TOOLS_VERSION)/' \
|
||||
$$(TEMP_JAVA_DIR)$$S$1$$S$$*$$Spom.xml
|
||||
$$(SED) -i -e 's/@JAVA_PROJECT@/$$(JAVA_ORTOOLS_PROJECT)/' \
|
||||
$$(TEMP_JAVA_DIR)$$S$1$$S$$*$$Spom.xml
|
||||
|
||||
$$(TEMP_JAVA_DIR)/$1/%/$$(JAVA_SRC_DIR)/%.java: \
|
||||
$$(SRC_DIR)/examples/$1/%.java \
|
||||
| $$(TEMP_JAVA_DIR)/$1/%
|
||||
$$(MKDIR_P) $$(TEMP_JAVA_DIR)$$S$1$$S$$*$$S$$(JAVA_SRC_PATH)
|
||||
$$(COPY) $$(SRC_DIR)$$Sexamples$$S$1$$S$$*.java \
|
||||
$$(TEMP_JAVA_DIR)$$S$1$$S$$*$$S$$(JAVA_SRC_PATH)
|
||||
|
||||
rjava_%: \
|
||||
java_package \
|
||||
$$(SRC_DIR)/examples/$1/%.java \
|
||||
$$(TEMP_JAVA_DIR)/$1/%/pom.xml \
|
||||
$$(TEMP_JAVA_DIR)/$1/%/$$(JAVA_SRC_DIR)/%.java \
|
||||
FORCE
|
||||
cd $$(TEMP_JAVA_DIR)$$S$1$$S$$* && "$$(MVN_BIN)" compile
|
||||
cd $$(TEMP_JAVA_DIR)$$S$1$$S$$* && "$$(MVN_BIN)" exec:java \
|
||||
-Dexec.mainClass=com.google.ortools.$1.$$* $$(ARGS)
|
||||
|
||||
endef
|
||||
|
||||
$(foreach example,$(EXAMPLES),$(eval $(call java-example-target,$(example))))
|
||||
|
||||
|
||||
#############
|
||||
## DEBUG ##
|
||||
#############
|
||||
|
||||
Reference in New Issue
Block a user