Commit a9bd42a2 authored by Valentin Platzgummer's avatar Valentin Platzgummer

appimage mod

parent 9a7d98f8

Too many changes to show.

To preserve performance only 534 of 534+ files are displayed.

...@@ -198,7 +198,7 @@ contains (DEFINES, DISABLE_AIRMAP) { ...@@ -198,7 +198,7 @@ contains (DEFINES, DISABLE_AIRMAP) {
# GeograpicLib (TODO: add Windows support!) # GeograpicLib (TODO: add Windows support!)
LinuxBuild { LinuxBuild {
LIBS += -L/usr/local/lib -lGeographic # libGeograpic.so LIBS += -L$$BASEDIR/libs/libGeographic/lib -lGeographic # libGeograpic.so.17
} }
# google or-tools (TODO: add Windows support!) # google or-tools (TODO: add Windows support!)
......
...@@ -69,7 +69,7 @@ cp -L libts/usr/lib/x86_64-linux-gnu/libts-0.0.so.0 ${APPDIR}/usr/lib/x86_64-lin ...@@ -69,7 +69,7 @@ cp -L libts/usr/lib/x86_64-linux-gnu/libts-0.0.so.0 ${APPDIR}/usr/lib/x86_64-lin
cp -L ${QGC_SRC}/libs/or-tools-src-ubuntu/lib/* ${APPDIR}/usr/lib/x86_64-linux-gnu/ || { echo "libortools.so not found"; exit 1; } cp -L ${QGC_SRC}/libs/or-tools-src-ubuntu/lib/* ${APPDIR}/usr/lib/x86_64-linux-gnu/ || { echo "libortools.so not found"; exit 1; }
# copy libGeographic.so.17 # copy libGeographic.so.17
cp -L /usr/lib/x86_64-linux-gnu/libGeographic.so.17 ${APPDIR}/usr/lib/x86_64-linux-gnu/ || { echo "libGeographic.so.17 not found"; exit 1; } cp -L ${QGC_SRC}/libs/libGeographic/libGeographic.so.17 ${APPDIR}/usr/lib/x86_64-linux-gnu/ || { echo "libGeographic.so.17 not found"; exit 1; }
# copy boost # copy boost
cp -L /usr/lib/x86_64-linux-gnu/libboost_system.so.1.65.1 ${APPDIR}/usr/lib/x86_64-linux-gnu/ || { echo "libboost_system.so.1.65.1 not found"; exit 1; } cp -L /usr/lib/x86_64-linux-gnu/libboost_system.so.1.65.1 ${APPDIR}/usr/lib/x86_64-linux-gnu/ || { echo "libboost_system.so.1.65.1 not found"; exit 1; }
......
...@@ -269,6 +269,8 @@ test_cc: detect_cc ...@@ -269,6 +269,8 @@ test_cc: detect_cc
$(MAKE) run SOURCE=examples/cpp/vrp.cc $(MAKE) run SOURCE=examples/cpp/vrp.cc
$(MAKE) run SOURCE=examples/cpp/nurses_cp.cc $(MAKE) run SOURCE=examples/cpp/nurses_cp.cc
$(MAKE) run SOURCE=examples/cpp/minimal_jobshop_cp.cc $(MAKE) run SOURCE=examples/cpp/minimal_jobshop_cp.cc
$(MAKE) run SOURCE=examples/cpp/linear_programming.cc
$(MAKE) run SOURCE=examples/cpp/integer_programming.cc
################## ##################
## C++ SOURCE ## ## C++ SOURCE ##
......
...@@ -20,7 +20,7 @@ ...@@ -20,7 +20,7 @@
// [END import] // [END import]
namespace operations_research { namespace operations_research {
void IntegerProgrammingExample() { void AssignmentMip() {
// Data // Data
// [START data_model] // [START data_model]
const std::vector<std::vector<double>> costs{ const std::vector<std::vector<double>> costs{
...@@ -34,7 +34,7 @@ void IntegerProgrammingExample() { ...@@ -34,7 +34,7 @@ void IntegerProgrammingExample() {
// Solver // Solver
// [START solver] // [START solver]
// Create the mip solver with the CBC backend. // Create the mip solver with the CBC backend.
MPSolver solver("simple_mip_program", MPSolver solver("AssignmentMip",
MPSolver::CBC_MIXED_INTEGER_PROGRAMMING); MPSolver::CBC_MIXED_INTEGER_PROGRAMMING);
// [END solver] // [END solver]
...@@ -112,7 +112,7 @@ void IntegerProgrammingExample() { ...@@ -112,7 +112,7 @@ void IntegerProgrammingExample() {
} // namespace operations_research } // namespace operations_research
int main(int argc, char** argv) { int main(int argc, char** argv) {
operations_research::IntegerProgrammingExample(); operations_research::AssignmentMip();
return EXIT_SUCCESS; return EXIT_SUCCESS;
} }
// [END program] // [END program]
...@@ -41,7 +41,7 @@ void RunConstraintProgrammingExample() { ...@@ -41,7 +41,7 @@ void RunConstraintProgrammingExample() {
solver.NewSearch(db); solver.NewSearch(db);
while (solver.NextSolution()) { while (solver.NextSolution()) {
LOG(INFO) << "Solution" LOG(INFO) << "Solution"
<< ": x = " << x->Value() << "; y = " << x->Value() << ": x = " << x->Value() << "; y = " << y->Value()
<< "; z = " << z->Value(); << "; z = " << z->Value();
} }
solver.EndSearch(); solver.EndSearch();
......
...@@ -13,13 +13,25 @@ ...@@ -13,13 +13,25 @@
// Integer programming example that shows how to use the API. // Integer programming example that shows how to use the API.
#include "ortools/base/commandlineflags.h"
#include "ortools/base/logging.h" #include "ortools/base/logging.h"
#include "ortools/linear_solver/linear_solver.h" #include "ortools/linear_solver/linear_solver.h"
namespace operations_research { namespace operations_research {
void RunIntegerProgrammingExample( void RunIntegerProgrammingExample(
MPSolver::OptimizationProblemType optimization_problem_type) { const std::string& optimization_problem_type) {
MPSolver solver("IntegerProgrammingExample", optimization_problem_type); LOG(INFO) << "---- Integer programming example with "
<< optimization_problem_type << " ----";
if (!MPSolver::ParseAndCheckSupportForProblemType(
optimization_problem_type)) {
LOG(INFO) << " support for solver not linked in.";
return;
}
MPSolver solver("IntegerProgrammingExample",
MPSolver::ParseSolverTypeOrDie(optimization_problem_type));
const double infinity = solver.infinity(); const double infinity = solver.infinity();
// x and y are integer non-negative variables. // x and y are integer non-negative variables.
MPVariable* const x = solver.MakeIntVar(0.0, infinity, "x"); MPVariable* const x = solver.MakeIntVar(0.0, infinity, "x");
...@@ -44,9 +56,6 @@ void RunIntegerProgrammingExample( ...@@ -44,9 +56,6 @@ void RunIntegerProgrammingExample(
LOG(INFO) << "Number of variables = " << solver.NumVariables(); LOG(INFO) << "Number of variables = " << solver.NumVariables();
LOG(INFO) << "Number of constraints = " << solver.NumConstraints(); LOG(INFO) << "Number of constraints = " << solver.NumConstraints();
solver.SetNumThreads(8);
solver.EnableOutput();
const MPSolver::ResultStatus result_status = solver.Solve(); const MPSolver::ResultStatus result_status = solver.Solve();
// Check that the problem has an optimal solution. // Check that the problem has an optimal solution.
if (result_status != MPSolver::OPTIMAL) { if (result_status != MPSolver::OPTIMAL) {
...@@ -65,32 +74,21 @@ void RunIntegerProgrammingExample( ...@@ -65,32 +74,21 @@ void RunIntegerProgrammingExample(
} }
void RunAllExamples() { void RunAllExamples() {
#if defined(USE_CBC) RunIntegerProgrammingExample("CBC");
LOG(INFO) << "---- Integer programming example with CBC ----"; RunIntegerProgrammingExample("SAT");
RunIntegerProgrammingExample(MPSolver::CBC_MIXED_INTEGER_PROGRAMMING); RunIntegerProgrammingExample("SCIP");
#endif RunIntegerProgrammingExample("GUROBI");
#if defined(USE_GLPK) RunIntegerProgrammingExample("GLPK");
LOG(INFO) << "---- Integer programming example with GLPK ----"; RunIntegerProgrammingExample("CPLEX");
RunIntegerProgrammingExample(MPSolver::GLPK_MIXED_INTEGER_PROGRAMMING); RunIntegerProgrammingExample("XPRESS");
#endif
#if defined(USE_SCIP)
LOG(INFO) << "---- Integer programming example with SCIP ----";
RunIntegerProgrammingExample(MPSolver::SCIP_MIXED_INTEGER_PROGRAMMING);
#endif
#if defined(USE_GUROBI)
LOG(INFO) << "---- Integer programming example with Gurobi ----";
RunIntegerProgrammingExample(MPSolver::GUROBI_MIXED_INTEGER_PROGRAMMING);
#endif // USE_GUROBI
#if defined(USE_CPLEX)
LOG(INFO) << "---- Integer programming example with CPLEX ----";
RunIntegerProgrammingExample(MPSolver::CPLEX_MIXED_INTEGER_PROGRAMMING);
#endif // USE_CPLEX
} }
} // namespace operations_research } // namespace operations_research
int main(int argc, char** argv) { int main(int argc, char** argv) {
google::InitGoogleLogging(argv[0]); google::InitGoogleLogging(argv[0]);
FLAGS_logtostderr = 1; absl::SetFlag(&FLAGS_logtostderr, true);
absl::SetFlag(&FLAGS_log_prefix, false);
gflags::ParseCommandLineFlags(&argc, &argv, true);
operations_research::RunAllExamples(); operations_research::RunAllExamples();
return EXIT_SUCCESS; return 0;
} }
...@@ -21,7 +21,7 @@ namespace operations_research { ...@@ -21,7 +21,7 @@ namespace operations_research {
void IntegerProgrammingExample() { void IntegerProgrammingExample() {
// [START solver] // [START solver]
// Create the mip solver with the CBC backend. // Create the mip solver with the CBC backend.
MPSolver solver("IntegerExample", MPSolver solver("integer_programming_example",
MPSolver::CBC_MIXED_INTEGER_PROGRAMMING); MPSolver::CBC_MIXED_INTEGER_PROGRAMMING);
// [END solver] // [END solver]
......
...@@ -13,58 +13,82 @@ ...@@ -13,58 +13,82 @@
// Linear programming example that shows how to use the API. // Linear programming example that shows how to use the API.
#include "ortools/base/commandlineflags.h"
#include "ortools/base/logging.h" #include "ortools/base/logging.h"
#include "ortools/linear_solver/linear_solver.h" #include "ortools/linear_solver/linear_solver.h"
#include "ortools/linear_solver/linear_solver.pb.h" #include "ortools/linear_solver/linear_solver.pb.h"
namespace operations_research { namespace operations_research {
void RunLinearProgrammingExample() { void RunLinearProgrammingExample(const std::string& optimization_problem_type) {
MPSolver solver("LinearProgrammingExample", LOG(INFO) << "---- Linear programming example with "
MPSolver::GLOP_LINEAR_PROGRAMMING); << optimization_problem_type << " ----";
if (!MPSolver::ParseAndCheckSupportForProblemType(
optimization_problem_type)) {
LOG(INFO) << " support for solver not linked in.";
return;
}
MPSolver solver("IntegerProgrammingExample",
MPSolver::ParseSolverTypeOrDie(optimization_problem_type));
const double infinity = solver.infinity(); const double infinity = solver.infinity();
// x and y are continuous non-negative variables. // x1, x2 and x3 are continuous non-negative variables.
MPVariable* const x = solver.MakeNumVar(0.0, infinity, "x"); MPVariable* const x1 = solver.MakeNumVar(0.0, infinity, "x1");
MPVariable* const y = solver.MakeNumVar(0.0, infinity, "y"); MPVariable* const x2 = solver.MakeNumVar(0.0, infinity, "x2");
MPVariable* const x3 = solver.MakeNumVar(0.0, infinity, "x3");
// Objectif function: Maximize 3x + 4y. // Maximize 10 * x1 + 6 * x2 + 4 * x3.
MPObjective* const objective = solver.MutableObjective(); MPObjective* const objective = solver.MutableObjective();
objective->SetCoefficient(x, 3); objective->SetCoefficient(x1, 10);
objective->SetCoefficient(y, 4); objective->SetCoefficient(x2, 6);
objective->SetCoefficient(x3, 4);
objective->SetMaximization(); objective->SetMaximization();
// x + 2y <= 14. // x1 + x2 + x3 <= 100.
MPConstraint* const c0 = solver.MakeRowConstraint(-infinity, 14.0); MPConstraint* const c0 = solver.MakeRowConstraint(-infinity, 100.0);
c0->SetCoefficient(x, 1); c0->SetCoefficient(x1, 1);
c0->SetCoefficient(y, 2); c0->SetCoefficient(x2, 1);
c0->SetCoefficient(x3, 1);
// 10 * x1 + 4 * x2 + 5 * x3 <= 600.
MPConstraint* const c1 = solver.MakeRowConstraint(-infinity, 600.0);
c1->SetCoefficient(x1, 10);
c1->SetCoefficient(x2, 4);
c1->SetCoefficient(x3, 5);
// 3x - y >= 0. // 2 * x1 + 2 * x2 + 6 * x3 <= 300.
MPConstraint* const c1 = solver.MakeRowConstraint(0.0, infinity); MPConstraint* const c2 = solver.MakeRowConstraint(-infinity, 300.0);
c1->SetCoefficient(x, 3); c2->SetCoefficient(x1, 2);
c1->SetCoefficient(y, -1); c2->SetCoefficient(x2, 2);
c2->SetCoefficient(x3, 6);
// x - y <= 2. // TODO(user): Change example to show = and >= constraints.
MPConstraint* const c2 = solver.MakeRowConstraint(-infinity, 2.0);
c2->SetCoefficient(x, 1);
c2->SetCoefficient(y, -1);
LOG(INFO) << "Number of variables = " << solver.NumVariables(); LOG(INFO) << "Number of variables = " << solver.NumVariables();
LOG(INFO) << "Number of constraints = " << solver.NumConstraints(); LOG(INFO) << "Number of constraints = " << solver.NumConstraints();
const MPSolver::ResultStatus result_status = solver.Solve(); const MPSolver::ResultStatus result_status = solver.Solve();
// Check that the problem has an optimal solution. // Check that the problem has an optimal solution.
if (result_status != MPSolver::OPTIMAL) { if (result_status != MPSolver::OPTIMAL) {
LOG(FATAL) << "The problem does not have an optimal solution!"; LOG(FATAL) << "The problem does not have an optimal solution!";
} }
LOG(INFO) << "Solution:";
LOG(INFO) << "x = " << x->solution_value(); LOG(INFO) << "Problem solved in " << solver.wall_time() << " milliseconds";
LOG(INFO) << "y = " << y->solution_value();
// The objective value of the solution.
LOG(INFO) << "Optimal objective value = " << objective->Value(); LOG(INFO) << "Optimal objective value = " << objective->Value();
LOG(INFO) << "";
// The value of each variable in the solution.
LOG(INFO) << "x1 = " << x1->solution_value();
LOG(INFO) << "x2 = " << x2->solution_value();
LOG(INFO) << "x3 = " << x3->solution_value();
LOG(INFO) << "Advanced usage:"; LOG(INFO) << "Advanced usage:";
LOG(INFO) << "Problem solved in " << solver.wall_time() << " milliseconds";
LOG(INFO) << "Problem solved in " << solver.iterations() << " iterations"; LOG(INFO) << "Problem solved in " << solver.iterations() << " iterations";
LOG(INFO) << "x: reduced cost = " << x->reduced_cost(); LOG(INFO) << "x1: reduced cost = " << x1->reduced_cost();
LOG(INFO) << "y: reduced cost = " << y->reduced_cost(); LOG(INFO) << "x2: reduced cost = " << x2->reduced_cost();
LOG(INFO) << "x3: reduced cost = " << x3->reduced_cost();
const std::vector<double> activities = solver.ComputeConstraintActivities(); const std::vector<double> activities = solver.ComputeConstraintActivities();
LOG(INFO) << "c0: dual value = " << c0->dual_value() LOG(INFO) << "c0: dual value = " << c0->dual_value()
<< " activity = " << activities[c0->index()]; << " activity = " << activities[c0->index()];
...@@ -73,11 +97,22 @@ void RunLinearProgrammingExample() { ...@@ -73,11 +97,22 @@ void RunLinearProgrammingExample() {
LOG(INFO) << "c2: dual value = " << c2->dual_value() LOG(INFO) << "c2: dual value = " << c2->dual_value()
<< " activity = " << activities[c2->index()]; << " activity = " << activities[c2->index()];
} }
void RunAllExamples() {
RunLinearProgrammingExample("GLOP");
RunLinearProgrammingExample("CLP");
RunLinearProgrammingExample("GUROBI_LP");
RunLinearProgrammingExample("CPLEX_LP");
RunLinearProgrammingExample("GLPK_LP");
RunLinearProgrammingExample("XPRESS_LP");
}
} // namespace operations_research } // namespace operations_research
int main(int argc, char** argv) { int main(int argc, char** argv) {
google::InitGoogleLogging(argv[0]); google::InitGoogleLogging(argv[0]);
FLAGS_logtostderr = 1; absl::SetFlag(&FLAGS_logtostderr, true);
operations_research::RunLinearProgrammingExample(); absl::SetFlag(&FLAGS_log_prefix, false);
gflags::ParseCommandLineFlags(&argc, &argv, true);
operations_research::RunAllExamples();
return EXIT_SUCCESS; return EXIT_SUCCESS;
} }
...@@ -20,7 +20,8 @@ ...@@ -20,7 +20,8 @@
namespace operations_research { namespace operations_research {
void LinearProgrammingExample() { void LinearProgrammingExample() {
// [START solver] // [START solver]
MPSolver solver("LinearExample", MPSolver::GLOP_LINEAR_PROGRAMMING); MPSolver solver("linear_programming_examples",
MPSolver::GLOP_LINEAR_PROGRAMMING);
// [END solver] // [END solver]
// [START variables] // [START variables]
......
...@@ -33,7 +33,7 @@ struct DataModel { ...@@ -33,7 +33,7 @@ struct DataModel {
}; };
// [END data_model] // [END data_model]
void IntegerProgrammingExample() { void MipVarArray() {
// [START data] // [START data]
DataModel data; DataModel data;
// [END data] // [END data]
...@@ -41,8 +41,7 @@ void IntegerProgrammingExample() { ...@@ -41,8 +41,7 @@ void IntegerProgrammingExample() {
// [START solver] // [START solver]
// Create the mip solver with the CBC backend. // Create the mip solver with the CBC backend.
MPSolver solver("simple_mip_program", MPSolver solver("mip_var_array", MPSolver::CBC_MIXED_INTEGER_PROGRAMMING);
MPSolver::CBC_MIXED_INTEGER_PROGRAMMING);
// [END solver] // [END solver]
// [START program_part2] // [START program_part2]
...@@ -96,7 +95,7 @@ void IntegerProgrammingExample() { ...@@ -96,7 +95,7 @@ void IntegerProgrammingExample() {
} // namespace operations_research } // namespace operations_research
int main(int argc, char** argv) { int main(int argc, char** argv) {
operations_research::IntegerProgrammingExample(); operations_research::MipVarArray();
return EXIT_SUCCESS; return EXIT_SUCCESS;
} }
// [END program_part2] // [END program_part2]
......
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
// [END import] // [END import]
namespace operations_research { namespace operations_research {
void run() { void SimpleLpProgram() {