experimental support for dynamic loading of gurobi; add MPSolver.CreateSolver() factory method for non C++ languages to check correctly installed linear solver backends and licenses when needed; port all non C++ examples
This commit is contained in:
@@ -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.
|
||||
|
||||
package com.google.ortools.examples;
|
||||
|
||||
import com.google.ortools.linearsolver.MPConstraint;
|
||||
@@ -27,17 +28,8 @@ public class IntegerProgramming {
|
||||
System.loadLibrary("jniortools");
|
||||
}
|
||||
|
||||
private static MPSolver createSolver(String solverType) {
|
||||
try {
|
||||
return new MPSolver(
|
||||
"IntegerProgrammingExample", MPSolver.OptimizationProblemType.valueOf(solverType));
|
||||
} catch (java.lang.IllegalArgumentException e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private static void runIntegerProgrammingExample(String solverType) {
|
||||
MPSolver solver = createSolver(solverType);
|
||||
MPSolver solver = MPSolver.createSolver("IntegerProgramming", solverType);
|
||||
if (solver == null) {
|
||||
System.out.println("Could not create solver " + solverType);
|
||||
return;
|
||||
@@ -91,7 +83,7 @@ public class IntegerProgramming {
|
||||
runIntegerProgrammingExample("SCIP_MIXED_INTEGER_PROGRAMMING");
|
||||
System.out.println("---- Integer programming example with CBC ----");
|
||||
runIntegerProgrammingExample("CBC_MIXED_INTEGER_PROGRAMMING");
|
||||
System.out.println("---- Integer programming example with GLPK ----");
|
||||
runIntegerProgrammingExample("GLPK_MIXED_INTEGER_PROGRAMMING");
|
||||
System.out.println("---- Integer programming example with CP-SAT ----");
|
||||
runIntegerProgrammingExample("SAT_INTEGER_PROGRAMMING");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user