polish examples and samples

This commit is contained in:
Laurent Perron
2020-06-26 09:35:26 +02:00
parent a8cd11401f
commit 2022071171
28 changed files with 47 additions and 48 deletions

View File

@@ -106,19 +106,19 @@ public class CsIntegerProgramming
static void Main()
{
Console.WriteLine("---- Integer programming example with GLPK ----");
RunIntegerProgrammingExample("GLPK_MIXED_INTEGER_PROGRAMMING");
RunIntegerProgrammingExample("GLPK");
Console.WriteLine("---- Linear programming example with CBC ----");
RunIntegerProgrammingExample("CBC_MIXED_INTEGER_PROGRAMMING");
RunIntegerProgrammingExample("CBC");
Console.WriteLine("---- Linear programming example with SCIP ----");
RunIntegerProgrammingExample("SCIP_MIXED_INTEGER_PROGRAMMING");
RunIntegerProgrammingExample("SCIP");
Console.WriteLine(
"---- Integer programming example (Natural API) with GLPK ----");
RunIntegerProgrammingExampleNaturalApi("GLPK_MIXED_INTEGER_PROGRAMMING");
RunIntegerProgrammingExampleNaturalApi("GLPK");
Console.WriteLine(
"---- Linear programming example (Natural API) with CBC ----");
RunIntegerProgrammingExampleNaturalApi("CBC_MIXED_INTEGER_PROGRAMMING");
RunIntegerProgrammingExampleNaturalApi("CBC");
Console.WriteLine(
"---- Linear programming example (Natural API) with SCIP ----");
RunIntegerProgrammingExampleNaturalApi("SCIP_MIXED_INTEGER_PROGRAMMING");
RunIntegerProgrammingExampleNaturalApi("SCIP");
}
}

View File

@@ -18,6 +18,8 @@ public class CsLinearProgramming
{
private static void RunLinearProgrammingExample(String solverType)
{
Console.WriteLine($"---- Linear programming example with {solverType} ----");
Solver solver = Solver.CreateSolver("IntegerProgramming", solverType);
if (solver == null)
{
@@ -96,6 +98,9 @@ public class CsLinearProgramming
private static void RunLinearProgrammingExampleNaturalApi(
String solverType, bool printModel)
{
Console.WriteLine(
$"---- Linear programming example (Natural API) with {solverType} ----");
Solver solver = Solver.CreateSolver("IntegerProgramming", solverType);
if (solver == null)
{
@@ -157,20 +162,12 @@ public class CsLinearProgramming
static void Main()
{
Console.WriteLine("---- Linear programming example with GLOP ----");
RunLinearProgrammingExample("GLOP_LINEAR_PROGRAMMING");
Console.WriteLine("---- Linear programming example with GLPK ----");
RunLinearProgrammingExample("GLPK_LINEAR_PROGRAMMING");
Console.WriteLine("---- Linear programming example with CLP ----");
RunLinearProgrammingExample("CLP_LINEAR_PROGRAMMING");
Console.WriteLine(
"---- Linear programming example (Natural API) with GLOP ----");
RunLinearProgrammingExampleNaturalApi("GLOP_LINEAR_PROGRAMMING", true);
Console.WriteLine(
"---- Linear programming example (Natural API) with GLPK ----");
RunLinearProgrammingExampleNaturalApi("GLPK_LINEAR_PROGRAMMING", false);
Console.WriteLine(
"---- Linear programming example (Natural API) with CLP ----");
RunLinearProgrammingExampleNaturalApi("CLP_LINEAR_PROGRAMMING", false);
RunLinearProgrammingExample("GLOP");
RunLinearProgrammingExample("GLPK_LP");
RunLinearProgrammingExample("CLP");
RunLinearProgrammingExampleNaturalApi("GLOP", true);
RunLinearProgrammingExampleNaturalApi("GLPK_LP", false);
RunLinearProgrammingExampleNaturalApi("CLP", false);
}
}

View File

@@ -80,10 +80,10 @@ public class IntegerProgramming {
public static void main(String[] args) throws Exception {
System.out.println("---- Integer programming example with SCIP (recommended) ----");
runIntegerProgrammingExample("SCIP_MIXED_INTEGER_PROGRAMMING");
runIntegerProgrammingExample("SCIP");
System.out.println("---- Integer programming example with CBC ----");
runIntegerProgrammingExample("CBC_MIXED_INTEGER_PROGRAMMING");
runIntegerProgrammingExample("CBC");
System.out.println("---- Integer programming example with CP-SAT ----");
runIntegerProgrammingExample("SAT_INTEGER_PROGRAMMING");
runIntegerProgrammingExample("SAT");
}
}

View File

@@ -116,8 +116,8 @@ public class LinearProgramming {
public static void main(String[] args) throws Exception {
System.out.println("---- Linear programming example with GLOP (recommended) ----");
runLinearProgrammingExample("GLOP_LINEAR_PROGRAMMING", true);
runLinearProgrammingExample("GLOP", true);
System.out.println("---- Linear programming example with CLP ----");
runLinearProgrammingExample("CLP_LINEAR_PROGRAMMING", false);
runLinearProgrammingExample("CLP", false);
}
}

View File

@@ -13,6 +13,7 @@
"""Linear programming examples that show how to use the APIs."""
from __future__ import print_function
from ortools.linear_solver import pywraplp

View File

@@ -285,6 +285,7 @@ PROTO2_RETURN(
%unignore operations_research::MPSolver;
%unignore operations_research::MPSolver::MPSolver;
%unignore operations_research::MPSolver::~MPSolver;
%newobject operations_research::MPSolver::CreateSolver;
%rename (createSolver) operations_research::MPSolver::CreateSolver;
%rename (parseAndCheckSupportForProblemType)
operations_research::MPSolver::ParseAndCheckSupportForProblemType;

View File

@@ -36,7 +36,7 @@ public class AssignmentMip
// Model.
// [START model]
Solver solver = Solver.CreateSolver("AssignmentMip", "cbc");
Solver solver = Solver.CreateSolver("AssignmentMip", "CBC");
// [END model]
// Variables.

View File

@@ -43,7 +43,7 @@ public class AssignmentMip {
// Solver
// [START solver]
// Create the linear solver with the CBC backend.
MPSolver solver = MPSolver.createSolver("AssignmentMip", "cbc");
MPSolver solver = MPSolver.createSolver("AssignmentMip", "CBC");
// [END solver]
// Variables

View File

@@ -38,7 +38,7 @@ public class BinPackingMip
// [START solver]
// Create the linear solver with the CBC backend.
Solver solver = Solver.CreateSolver("BinPackingMip", "cbc");
Solver solver = Solver.CreateSolver("BinPackingMip", "CBC");
// [END solver]
// [START program_part2]

View File

@@ -45,7 +45,7 @@ public class BinPackingMip {
// [START solver]
// Create the linear solver with the CBC backend.
MPSolver solver = MPSolver.createSolver("BinPackingMip", "cbc");
MPSolver solver = MPSolver.createSolver("BinPackingMip", "CBC");
// [END solver]
// [START program_part2]

View File

@@ -20,7 +20,7 @@ public class LinearProgrammingExample
static void Main()
{
// [START solver]
Solver solver = Solver.CreateSolver("LinearProgrammingExample", "glop");
Solver solver = Solver.CreateSolver("LinearProgrammingExample", "GLOP");
// [END solver]
// x and y are continuous non-negative variables.
// [START variables]

View File

@@ -27,7 +27,7 @@ public class LinearProgrammingExample {
public static void main(String[] args) throws Exception {
// [START solver]
MPSolver solver = MPSolver.createSolver("LinearProgrammingExample", "glop");
MPSolver solver = MPSolver.createSolver("LinearProgrammingExample", "GLOP");
// [END solver]
// [START variables]

View File

@@ -44,7 +44,7 @@ public class MipVarArray
// [START solver]
// Create the linear solver with the CBC backend.
Solver solver = Solver.CreateSolver("MipVarArray", "cbc");
Solver solver = Solver.CreateSolver("MipVarArray", "CBC");
// [END solver]
// [START program_part2]

View File

@@ -50,7 +50,7 @@ public class MipVarArray {
// [START solver]
// Create the linear solver with the CBC backend.
MPSolver solver = MPSolver.createSolver("MipVarArray", "cbc");
MPSolver solver = MPSolver.createSolver("MipVarArray", "CBC");
// [END solver]
// [START program_part2]

View File

@@ -41,7 +41,7 @@ public class MultipleKnapsackMip
// [START solver]
// Create the linear solver with the CBC backend.
Solver solver = Solver.CreateSolver("MultipleKnapsackMip", "cbc");
Solver solver = Solver.CreateSolver("MultipleKnapsackMip", "CBC");
// [END solver]
// [START program_part2]

View File

@@ -46,7 +46,7 @@ public class MultipleKnapsackMip {
// [START solver]
// Create the linear solver with the CBC backend.
MPSolver solver = MPSolver.createSolver("MultipleKnapsackMip", "cbc");
MPSolver solver = MPSolver.createSolver("MultipleKnapsackMip", "CBC");
// [END solver]
// [START program_part2]

View File

@@ -22,7 +22,7 @@ public class SimpleLpProgram
{
// [START solver]
// Create the linear solver with the GLOP backend.
Solver solver = Solver.CreateSolver("SimpleLpProgram", "glop");
Solver solver = Solver.CreateSolver("SimpleLpProgram", "GLOP");
// [END solver]
// [START variables]

View File

@@ -30,7 +30,7 @@ public class SimpleLpProgram {
public static void main(String[] args) throws Exception {
// [START solver]
// Create the linear solver with the GLOP backend.
MPSolver solver = MPSolver.createSolver("SimpleLpProgram", "glop");
MPSolver solver = MPSolver.createSolver("SimpleLpProgram", "GLOP");
// [END solver]
// [START variables]

View File

@@ -23,7 +23,7 @@ public class SimpleMipProgram
{
// [START solver]
// Create the linear solver with the CBC backend.
Solver solver = Solver.CreateSolver("SimpleMipProgram", "cbc");
Solver solver = Solver.CreateSolver("SimpleMipProgram", "CBC");
// [END solver]
// [START variables]

View File

@@ -30,7 +30,7 @@ public class SimpleMipProgram {
public static void main(String[] args) throws Exception {
// [START solver]
// Create the linear solver with the CBC backend.
MPSolver solver = MPSolver.createSolver("SimpleMipProgram", "cbc");
MPSolver solver = MPSolver.createSolver("SimpleMipProgram", "CBC");
// [END solver]
// [START variables]

View File

@@ -34,7 +34,7 @@ def main():
# Solver
# [START solver]
# Create the mip solver with the CBC backend.
solver = pywraplp.Solver.CreateSolver('assignment_mip', 'cbc')
solver = pywraplp.Solver.CreateSolver('assignment_mip', 'CBC')
# [END solver]

View File

@@ -43,7 +43,7 @@ def main():
# [START solver]
# Create the mip solver with the CBC backend.
solver = pywraplp.Solver.CreateSolver('bin_packing_mip', 'cbc')
solver = pywraplp.Solver.CreateSolver('bin_packing_mip', 'CBC')
# [END solver]

View File

@@ -22,7 +22,7 @@ def IntegerProgrammingExample():
"""Integer programming sample."""
# [START solver]
# Create the mip solver with the CBC backend.
solver = pywraplp.Solver.CreateSolver('integer_programming_example', 'cbc')
solver = pywraplp.Solver.CreateSolver('integer_programming_example', 'CBC')
# [END solver]

View File

@@ -23,7 +23,7 @@ def LinearProgrammingExample():
"""Linear programming sample."""
# Instantiate a Glop solver, naming it LinearExample.
# [START solver]
solver = pywraplp.Solver.CreateSolver('linear_programming_examples', 'glop')
solver = pywraplp.Solver.CreateSolver('linear_programming_examples', 'GLOP')
# [END solver]
# Create the two variables and let them take on any non-negative value.

View File

@@ -47,7 +47,7 @@ def main():
# [END program_part1]
# [START solver]
# Create the mip solver with the CBC backend.
solver = pywraplp.Solver.CreateSolver('mip_var_array', 'cbc')
solver = pywraplp.Solver.CreateSolver('mip_var_array', 'CBC')
# [END solver]
# [START program_part2]

View File

@@ -47,7 +47,7 @@ def main():
# [START solver]
# Create the mip solver with the CBC backend.
solver = pywraplp.Solver.CreateSolver('multiple_knapsack_mip', 'cbc')
solver = pywraplp.Solver.CreateSolver('multiple_knapsack_mip', 'CBC')
# [END solver]
# [START program_part2]

View File

@@ -21,7 +21,7 @@ from ortools.linear_solver import pywraplp
def main():
# [START solver]
# Create the linear solver with the GLOP backend.
solver = pywraplp.Solver.CreateSolver('simple_lp_program', 'glop')
solver = pywraplp.Solver.CreateSolver('simple_lp_program', 'GLOP')
# [END solver]
# [START variables]

View File

@@ -21,7 +21,7 @@ from ortools.linear_solver import pywraplp
def main():
# [START solver]
# Create the mip solver with the CBC backend.
solver = pywraplp.Solver.CreateSolver('simple_mip_program', 'cbc')
solver = pywraplp.Solver.CreateSolver('simple_mip_program', 'CBC')
# [END solver]
# [START variables]