polish linear solver samples
This commit is contained in:
@@ -20,7 +20,7 @@
|
||||
// [END import]
|
||||
|
||||
namespace operations_research {
|
||||
void IntegerProgrammingExample() {
|
||||
void AssignmentMip() {
|
||||
// Data
|
||||
// [START data_model]
|
||||
const std::vector<std::vector<double>> costs{
|
||||
@@ -34,7 +34,7 @@ void IntegerProgrammingExample() {
|
||||
// Solver
|
||||
// [START solver]
|
||||
// Create the mip solver with the CBC backend.
|
||||
MPSolver solver("simple_mip_program",
|
||||
MPSolver solver("AssignmentMip",
|
||||
MPSolver::CBC_MIXED_INTEGER_PROGRAMMING);
|
||||
// [END solver]
|
||||
|
||||
@@ -112,7 +112,7 @@ void IntegerProgrammingExample() {
|
||||
} // namespace operations_research
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
operations_research::IntegerProgrammingExample();
|
||||
operations_research::AssignmentMip();
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
// [END program]
|
||||
|
||||
@@ -34,7 +34,7 @@ def main():
|
||||
# Solver
|
||||
# [START solver]
|
||||
# Create the mip solver with the CBC backend.
|
||||
solver = pywraplp.Solver.CreateSolver('simple_mip_program', 'cbc')
|
||||
solver = pywraplp.Solver.CreateSolver('assignment_mip', 'cbc')
|
||||
|
||||
# [END solver]
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@ namespace operations_research {
|
||||
void IntegerProgrammingExample() {
|
||||
// [START solver]
|
||||
// Create the mip solver with the CBC backend.
|
||||
MPSolver solver("IntegerExample",
|
||||
MPSolver solver("integer_programming_example",
|
||||
MPSolver::CBC_MIXED_INTEGER_PROGRAMMING);
|
||||
// [END solver]
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@ def IntegerProgrammingExample():
|
||||
"""Integer programming sample."""
|
||||
# [START solver]
|
||||
# Create the mip solver with the CBC backend.
|
||||
solver = pywraplp.Solver.CreateSolver('IntegerProgrammingExample', 'cbc')
|
||||
solver = pywraplp.Solver.CreateSolver('integer_programming_example', 'cbc')
|
||||
|
||||
# [END solver]
|
||||
|
||||
|
||||
@@ -20,7 +20,8 @@
|
||||
namespace operations_research {
|
||||
void LinearProgrammingExample() {
|
||||
// [START solver]
|
||||
MPSolver solver("LinearExample", MPSolver::GLOP_LINEAR_PROGRAMMING);
|
||||
MPSolver solver("linear_programming_examples",
|
||||
MPSolver::GLOP_LINEAR_PROGRAMMING);
|
||||
// [END solver]
|
||||
|
||||
// [START variables]
|
||||
|
||||
@@ -23,7 +23,7 @@ def LinearProgrammingExample():
|
||||
"""Linear programming sample."""
|
||||
# Instantiate a Glop solver, naming it LinearExample.
|
||||
# [START solver]
|
||||
solver = pywraplp.Solver.CreateSolver('LinearProgrammingExample', 'glop')
|
||||
solver = pywraplp.Solver.CreateSolver('linear_programming_examples', 'glop')
|
||||
# [END solver]
|
||||
|
||||
# Create the two variables and let them take on any non-negative value.
|
||||
|
||||
@@ -33,7 +33,7 @@ struct DataModel {
|
||||
};
|
||||
// [END data_model]
|
||||
|
||||
void IntegerProgrammingExample() {
|
||||
void MipVarArray() {
|
||||
// [START data]
|
||||
DataModel data;
|
||||
// [END data]
|
||||
@@ -41,8 +41,7 @@ void IntegerProgrammingExample() {
|
||||
|
||||
// [START solver]
|
||||
// Create the mip solver with the CBC backend.
|
||||
MPSolver solver("simple_mip_program",
|
||||
MPSolver::CBC_MIXED_INTEGER_PROGRAMMING);
|
||||
MPSolver solver("mip_var_array", MPSolver::CBC_MIXED_INTEGER_PROGRAMMING);
|
||||
// [END solver]
|
||||
|
||||
// [START program_part2]
|
||||
@@ -96,7 +95,7 @@ void IntegerProgrammingExample() {
|
||||
} // namespace operations_research
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
operations_research::IntegerProgrammingExample();
|
||||
operations_research::MipVarArray();
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
// [END program_part2]
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
// [END import]
|
||||
|
||||
namespace operations_research {
|
||||
void run() {
|
||||
void SimpleLpProgram() {
|
||||
// [START solver]
|
||||
// Create the linear solver with the GLOP backend.
|
||||
MPSolver solver("simple_lp_program", MPSolver::GLOP_LINEAR_PROGRAMMING);
|
||||
@@ -63,7 +63,7 @@ void run() {
|
||||
} // namespace operations_research
|
||||
|
||||
int main() {
|
||||
operations_research::run();
|
||||
operations_research::SimpleLpProgram();
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
// [END program]
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
// [END import]
|
||||
|
||||
namespace operations_research {
|
||||
void simple_mip_program() {
|
||||
void SimpleMipProgram() {
|
||||
// [START solver]
|
||||
// Create the mip solver with the CBC backend.
|
||||
MPSolver solver("simple_mip_program",
|
||||
@@ -82,7 +82,7 @@ void simple_mip_program() {
|
||||
} // namespace operations_research
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
operations_research::simple_mip_program();
|
||||
operations_research::SimpleMipProgram();
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
// [END program]
|
||||
|
||||
@@ -21,8 +21,7 @@ from ortools.linear_solver import pywraplp
|
||||
def main():
|
||||
# [START solver]
|
||||
# Create the mip solver with the CBC backend.
|
||||
solver = pywraplp.Solver('simple_mip_program',
|
||||
pywraplp.Solver.CBC_MIXED_INTEGER_PROGRAMMING)
|
||||
solver = pywraplp.Solver.CreateSolver('simple_mip_program', 'cbc')
|
||||
# [END solver]
|
||||
|
||||
# [START variables]
|
||||
|
||||
Reference in New Issue
Block a user