From 7e0c8496c738ce28fc7e6992c342db19f6532325 Mon Sep 17 00:00:00 2001 From: Henri Lefebvre Date: Thu, 17 Aug 2023 14:28:29 +0200 Subject: [PATCH] set default values for tolerances --- lib/CMakeLists.txt | 3 ++- lib/include/modeling/numericals.h | 12 ++++++------ lib/src/modeling/numericals.cpp | 4 ++++ 3 files changed, 12 insertions(+), 7 deletions(-) create mode 100644 lib/src/modeling/numericals.cpp diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt index 40c98e2d..e7efcf07 100644 --- a/lib/CMakeLists.txt +++ b/lib/CMakeLists.txt @@ -1,4 +1,5 @@ -add_library(idol STATIC include/modeling/numericals.h include/containers/Optional.h include/containers/Map.h include/modeling.h include/modeling/parameters/Param.h include/modeling/Types.h include/modeling/expressions/Constant.h src/modeling/expressions/Constant.cpp include/modeling/matrix/AbstractMatrixCoefficient.h include/modeling/matrix/MatrixCoefficientReference.h include/modeling/matrix/MatrixCoefficient.h src/modeling/matrix/MatrixCoefficient.cpp src/modeling/matrix/MatrixCoefficientReference.cpp include/modeling/constraints/TempCtr.h src/modeling/constraints/TempCtr.cpp include/containers/IteratorForward.h include/modeling/solutions/AbstractSolution.h include/modeling/solutions/Solution.h include/modeling/variables/TempVar.h include/containers/Set.h include/errors/NotImplemented.h include/modeling/expressions/LinExpr.h include/modeling/matrix/Row.h src/modeling/matrix/Row.cpp src/modeling/matrix/Column.cpp include/modeling/matrix/Column.h include/modeling/matrix/Matrix.h src/modeling/matrix/Matrix.cpp src/problems/generalized-assignment-problem/GAP_Instance.cpp include/problems/knapsack-problem/KP_Instance.h src/problems/knapsack-problem/KP_Instance.cpp include/problems/multiple-knapsack-problem/MKP_Instance.h src/problems/multiple-knapsack-problem/MKP_Instance.cpp include/modeling/expressions/Expr.h include/modeling/expressions/operations/operators_Var.h src/modeling/expressions/operations/operators_Var.cpp src/modeling/expressions/operations/operators_Ctr.cpp src/modeling/expressions/operations/operators_Constant.cpp include/modeling/expressions/operations/operators_Constant.h include/modeling/expressions/operations/operators_Ctr.h include/modeling/expressions/operations/operators.h include/problems/multiple-knapsack-problem/MKP_Instance.h src/problems/multiple-knapsack-problem/MKP_Instance.cpp src/problems/facility-location-problem/FLP_Instance.cpp include/problems/facility-location-problem/FLP_Instance.h include/problems/helpers/distances.h include/problems/helpers/parse_delimited.h include/modeling/expressions/operations/operators_utils.h include/modeling/expressions/QuadExpr.h include/modeling/expressions/AbstractExpr.h include/modeling/models/Model.h include/modeling/objects/Env.h include/modeling/variables/Var.h src/modeling/objects/Env.cpp include/modeling/variables/VarVersion.h include/modeling/objects/Versions.h include/modeling/objects/Object.h include/modeling/objects/ObjectId.h src/modeling/models/Model.cpp include/modeling/constraints/Ctr.h include/modeling/constraints/CtrVersion.h include/modeling/objects/Version.h src/modeling/variables/Var.cpp src/modeling/constraints/Ctr.cpp include/optimizers/Optimizer.h include/optimizers/solvers/gurobi/Optimizers_Gurobi.h include/optimizers/solvers/OptimizerWithLazyUpdates.h src/optimizers/solvers/gurobi/Optimizers_Gurobi.cpp src/optimizers/Optimizer.cpp src/optimizers/Logger.cpp include/optimizers/Algorithm.h src/optimizers/Algorithm.cpp src/optimizers/Timer.cpp include/modeling/annotations/Annotation.h src/modeling/annotations/impl_Annotation.cpp include/modeling/annotations/impl_Annotation.h include/modeling/models/Model.h include/containers/GeneratorPool.h include/modeling/solutions/types.h include/optimizers/solvers/Optimizers_GLPK.h include/solvers.h src/optimizers/solvers/Optimizers_GLPK.cpp include/optimizers/solvers/Optimizers_Mosek.h src/optimizers/solvers/Optimizers_Mosek.cpp include/linear-algebra/MatrixIndices.h include/linear-algebra/SquareMatrix.h include/linear-algebra/to_rotated_quadratic_cone.h include/optimizers/branch-and-bound/Optimizers_BranchAndBound.h include/optimizers/OptimizerFactory.h include/optimizers/solvers/DefaultOptimizer.h include/optimizers/branch-and-bound/BranchAndBound.h include/optimizers/branch-and-bound/branching-rules/factories/BranchingRuleFactory.h include/optimizers/branch-and-bound/node-selection-rules/factories/NodeSelectionRuleFactory.h include/optimizers/branch-and-bound/branching-rules/factories/MostInfeasible.h include/optimizers/branch-and-bound/node-selection-rules/factories/DepthFirst.h include/optimizers/branch-and-bound/branching-rules/impls/BranchingRule.h include/optimizers/branch-and-bound/node-selection-rules/impls/NodeSelectionRule.h include/optimizers/branch-and-bound/nodes/Node.h include/optimizers/branch-and-bound/nodes/NodeUpdator.h include/optimizers/branch-and-bound/nodes/NodeUpdatorByBound.h src/optimizers/branch-and-bound/nodes/NodeInfo.cpp include/optimizers/branch-and-bound/nodes/NodeInfo.h include/optimizers/branch-and-bound/branching-rules/impls/MostInfeasbile.h include/optimizers/branch-and-bound/node-selection-rules/impls/DepthFirst.h include/optimizers/branch-and-bound/branching-rules/impls/VariableBranchingRule.h include/optimizers/branch-and-bound/node-selection-rules/factories/BreadthFirst.h include/optimizers/branch-and-bound/node-selection-rules/factories/WorstBound.h include/optimizers/branch-and-bound/node-selection-rules/factories/BestBound.h include/optimizers/branch-and-bound/node-selection-rules/impls/WorstBound.h include/optimizers/branch-and-bound/node-selection-rules/impls/BestBound.h include/optimizers/branch-and-bound/node-selection-rules/impls/BreadthFirst.h include/optimizers/solvers/gurobi/Gurobi.h include/optimizers/solvers/GLPK.h include/optimizers/solvers/Mosek.h include/optimizers/column-generation/ColumnGeneration.h include/optimizers/column-generation/Optimizers_ColumnGeneration.h src/optimizers/column-generation/ColumnGeneration.cpp src/optimizers/column-generation/Optimizers_ColumnGeneration.cpp include/optimizers/dantzig-wolfe/DantzigWolfeDecomposition.h src/optimizers/dantzig-wolfe/DantzigWolfeDecomposition.cpp include/optimizers/dantzig-wolfe/Optimizers_DantzigWolfeDecomposition.h src/optimizers/dantzig-wolfe/Optimizers_DantzigWolfeDecomposition.cpp src/optimizers/solvers/gurobi/Gurobi.cpp src/optimizers/solvers/GLPK.cpp src/optimizers/solvers/Mosek.cpp include/optimizers/column-generation/OptimizerFactoryWithColumnGenerationParameters.h include/optimizers/branch-and-bound/callbacks/BranchAndBoundCallbackFactory.h include/optimizers/column-generation/IntegerMasterHeuristic.h src/optimizers/column-generation/IntegerMasterHeuristic.cpp src/optimizers/solvers/gurobi/GurobiCallbackI.cpp include/optimizers/callbacks/Callback.h src/optimizers/branch-and-bound/callbacks/Callback.cpp include/optimizers/callbacks/CutSeparation.h src/optimizers/branch-and-bound/callbacks/CutSeparation.cpp include/optimizers/callbacks/LazyCutCallback.h include/optimizers/callbacks/UserCutCallback.h include/optimizers/callbacks/CallbackFactory.h include/optimizers/branch-and-bound/callbacks/BranchAndBoundCallback.h include/optimizers/branch-and-bound/callbacks/AbstractBranchAndBoundCallbackI.h include/optimizers/branch-and-bound/callbacks/CallbackAsBranchAndBoundCallback.h include/optimizers/branch-and-bound/cutting-planes/CuttingPlaneGenerator.h include/optimizers/branch-and-bound/cutting-planes/CoverCuts.h include/problems/staff-rostering-problem/SRP_Instance.h src/problems/staff-rostering-problem/SRP_Instance.cpp) +add_library(idol STATIC include/modeling/numericals.h include/containers/Optional.h include/containers/Map.h include/modeling.h include/modeling/parameters/Param.h include/modeling/Types.h include/modeling/expressions/Constant.h src/modeling/expressions/Constant.cpp include/modeling/matrix/AbstractMatrixCoefficient.h include/modeling/matrix/MatrixCoefficientReference.h include/modeling/matrix/MatrixCoefficient.h src/modeling/matrix/MatrixCoefficient.cpp src/modeling/matrix/MatrixCoefficientReference.cpp include/modeling/constraints/TempCtr.h src/modeling/constraints/TempCtr.cpp include/containers/IteratorForward.h include/modeling/solutions/AbstractSolution.h include/modeling/solutions/Solution.h include/modeling/variables/TempVar.h include/containers/Set.h include/errors/NotImplemented.h include/modeling/expressions/LinExpr.h include/modeling/matrix/Row.h src/modeling/matrix/Row.cpp src/modeling/matrix/Column.cpp include/modeling/matrix/Column.h include/modeling/matrix/Matrix.h src/modeling/matrix/Matrix.cpp src/problems/generalized-assignment-problem/GAP_Instance.cpp include/problems/knapsack-problem/KP_Instance.h src/problems/knapsack-problem/KP_Instance.cpp include/problems/multiple-knapsack-problem/MKP_Instance.h src/problems/multiple-knapsack-problem/MKP_Instance.cpp include/modeling/expressions/Expr.h include/modeling/expressions/operations/operators_Var.h src/modeling/expressions/operations/operators_Var.cpp src/modeling/expressions/operations/operators_Ctr.cpp src/modeling/expressions/operations/operators_Constant.cpp include/modeling/expressions/operations/operators_Constant.h include/modeling/expressions/operations/operators_Ctr.h include/modeling/expressions/operations/operators.h include/problems/multiple-knapsack-problem/MKP_Instance.h src/problems/multiple-knapsack-problem/MKP_Instance.cpp src/problems/facility-location-problem/FLP_Instance.cpp include/problems/facility-location-problem/FLP_Instance.h include/problems/helpers/distances.h include/problems/helpers/parse_delimited.h include/modeling/expressions/operations/operators_utils.h include/modeling/expressions/QuadExpr.h include/modeling/expressions/AbstractExpr.h include/modeling/models/Model.h include/modeling/objects/Env.h include/modeling/variables/Var.h src/modeling/objects/Env.cpp include/modeling/variables/VarVersion.h include/modeling/objects/Versions.h include/modeling/objects/Object.h include/modeling/objects/ObjectId.h src/modeling/models/Model.cpp include/modeling/constraints/Ctr.h include/modeling/constraints/CtrVersion.h include/modeling/objects/Version.h src/modeling/variables/Var.cpp src/modeling/constraints/Ctr.cpp include/optimizers/Optimizer.h include/optimizers/solvers/gurobi/Optimizers_Gurobi.h include/optimizers/solvers/OptimizerWithLazyUpdates.h src/optimizers/solvers/gurobi/Optimizers_Gurobi.cpp src/optimizers/Optimizer.cpp src/optimizers/Logger.cpp include/optimizers/Algorithm.h src/optimizers/Algorithm.cpp src/optimizers/Timer.cpp include/modeling/annotations/Annotation.h src/modeling/annotations/impl_Annotation.cpp include/modeling/annotations/impl_Annotation.h include/modeling/models/Model.h include/containers/GeneratorPool.h include/modeling/solutions/types.h include/optimizers/solvers/Optimizers_GLPK.h include/solvers.h src/optimizers/solvers/Optimizers_GLPK.cpp include/optimizers/solvers/Optimizers_Mosek.h src/optimizers/solvers/Optimizers_Mosek.cpp include/linear-algebra/MatrixIndices.h include/linear-algebra/SquareMatrix.h include/linear-algebra/to_rotated_quadratic_cone.h include/optimizers/branch-and-bound/Optimizers_BranchAndBound.h include/optimizers/OptimizerFactory.h include/optimizers/solvers/DefaultOptimizer.h include/optimizers/branch-and-bound/BranchAndBound.h include/optimizers/branch-and-bound/branching-rules/factories/BranchingRuleFactory.h include/optimizers/branch-and-bound/node-selection-rules/factories/NodeSelectionRuleFactory.h include/optimizers/branch-and-bound/branching-rules/factories/MostInfeasible.h include/optimizers/branch-and-bound/node-selection-rules/factories/DepthFirst.h include/optimizers/branch-and-bound/branching-rules/impls/BranchingRule.h include/optimizers/branch-and-bound/node-selection-rules/impls/NodeSelectionRule.h include/optimizers/branch-and-bound/nodes/Node.h include/optimizers/branch-and-bound/nodes/NodeUpdator.h include/optimizers/branch-and-bound/nodes/NodeUpdatorByBound.h src/optimizers/branch-and-bound/nodes/NodeInfo.cpp include/optimizers/branch-and-bound/nodes/NodeInfo.h include/optimizers/branch-and-bound/branching-rules/impls/MostInfeasbile.h include/optimizers/branch-and-bound/node-selection-rules/impls/DepthFirst.h include/optimizers/branch-and-bound/branching-rules/impls/VariableBranchingRule.h include/optimizers/branch-and-bound/node-selection-rules/factories/BreadthFirst.h include/optimizers/branch-and-bound/node-selection-rules/factories/WorstBound.h include/optimizers/branch-and-bound/node-selection-rules/factories/BestBound.h include/optimizers/branch-and-bound/node-selection-rules/impls/WorstBound.h include/optimizers/branch-and-bound/node-selection-rules/impls/BestBound.h include/optimizers/branch-and-bound/node-selection-rules/impls/BreadthFirst.h include/optimizers/solvers/gurobi/Gurobi.h include/optimizers/solvers/GLPK.h include/optimizers/solvers/Mosek.h include/optimizers/column-generation/ColumnGeneration.h include/optimizers/column-generation/Optimizers_ColumnGeneration.h src/optimizers/column-generation/ColumnGeneration.cpp src/optimizers/column-generation/Optimizers_ColumnGeneration.cpp include/optimizers/dantzig-wolfe/DantzigWolfeDecomposition.h src/optimizers/dantzig-wolfe/DantzigWolfeDecomposition.cpp include/optimizers/dantzig-wolfe/Optimizers_DantzigWolfeDecomposition.h src/optimizers/dantzig-wolfe/Optimizers_DantzigWolfeDecomposition.cpp src/optimizers/solvers/gurobi/Gurobi.cpp src/optimizers/solvers/GLPK.cpp src/optimizers/solvers/Mosek.cpp include/optimizers/column-generation/OptimizerFactoryWithColumnGenerationParameters.h include/optimizers/branch-and-bound/callbacks/BranchAndBoundCallbackFactory.h include/optimizers/column-generation/IntegerMasterHeuristic.h src/optimizers/column-generation/IntegerMasterHeuristic.cpp src/optimizers/solvers/gurobi/GurobiCallbackI.cpp include/optimizers/callbacks/Callback.h src/optimizers/branch-and-bound/callbacks/Callback.cpp include/optimizers/callbacks/CutSeparation.h src/optimizers/branch-and-bound/callbacks/CutSeparation.cpp include/optimizers/callbacks/LazyCutCallback.h include/optimizers/callbacks/UserCutCallback.h include/optimizers/callbacks/CallbackFactory.h include/optimizers/branch-and-bound/callbacks/BranchAndBoundCallback.h include/optimizers/branch-and-bound/callbacks/AbstractBranchAndBoundCallbackI.h include/optimizers/branch-and-bound/callbacks/CallbackAsBranchAndBoundCallback.h include/optimizers/branch-and-bound/cutting-planes/CuttingPlaneGenerator.h include/optimizers/branch-and-bound/cutting-planes/CoverCuts.h include/problems/staff-rostering-problem/SRP_Instance.h src/problems/staff-rostering-problem/SRP_Instance.cpp + src/modeling/numericals.cpp) find_package(OpenMP REQUIRED) target_link_libraries(idol PUBLIC OpenMP::OpenMP_CXX) diff --git a/lib/include/modeling/numericals.h b/lib/include/modeling/numericals.h index 9203d879..898f82fb 100644 --- a/lib/include/modeling/numericals.h +++ b/lib/include/modeling/numericals.h @@ -31,7 +31,7 @@ namespace idol { * For instance, when a value close to zero should be stored * or ignored when saving a primal point. */ - static double Sparsity; + static double Sparsity = 1e-6; /** * **Default:** \f$ 10^{-4} \f$ @@ -43,7 +43,7 @@ namespace idol { * The relative gap is computed as follows: * \f[ RelativeGap := \frac{ |UB - LB| }{ 10^{-10} + |UB| }. \f] */ - static double MIPRelativeGap; + static double MIPRelativeGap = 1e-4; /** * **Default:** \f$ 10^{-10} \f$ @@ -55,7 +55,7 @@ namespace idol { * The absolute gap is computed as follows: * \f[ AbsoluteGap := |UB - LB| \f] */ - static double MIPAbsoluteGap; + static double MIPAbsoluteGap = 1e-10; /** * **Default:** \f$ 10^{-5} \f$ @@ -65,7 +65,7 @@ namespace idol { * Used to recognized integer values, i.e., a given value is considered integer when the closest integer point * is closer than this tolerance. */ - static double Integer; + static double Integer = 10e-5; /** * **Default:** \f$ 10^{-6} \f$ @@ -75,7 +75,7 @@ namespace idol { * Used to characterized constraint satisfaction, i.e., a constraint is satisfied if it is not violated by a * larger amount than this tolerance. */ - static double Feasibility; + static double Feasibility = 10e-6; /** * **Default:** \f$ 10^{-6} \f$ @@ -84,7 +84,7 @@ namespace idol { * * Used to characterize optimality, i.e., all reduced costs must be smaller than this tolerance. */ - static double Optimality; + static double Optimality = 10e-6; }; static bool is_pos_inf(double t_value) { diff --git a/lib/src/modeling/numericals.cpp b/lib/src/modeling/numericals.cpp new file mode 100644 index 00000000..83b5f373 --- /dev/null +++ b/lib/src/modeling/numericals.cpp @@ -0,0 +1,4 @@ +// +// Created by henri on 17.08.23. +// +#include "modeling/numericals.h"