From a1ce31ef63e3c4247837516bd69d17c61e345409 Mon Sep 17 00:00:00 2001 From: Mohammed Ghannam Date: Thu, 20 Nov 2025 07:29:17 +0100 Subject: [PATCH 1/3] Try to find global SCIP installation with pkg-config --- .github/workflows/build_and_test.yml | 25 + Cargo.toml | 4 + build.rs | 95 +- headers/bliss/abstractgraph.hh | 503 - headers/bliss/bignum.hh | 260 - headers/bliss/bliss_C.h | 205 - headers/bliss/defs.hh | 87 - headers/bliss/digraph.hh | 285 - headers/bliss/graph.hh | 281 - headers/bliss/heap.hh | 89 - headers/bliss/kqueue.hh | 165 - headers/bliss/kstack.hh | 141 - headers/bliss/orbit.hh | 109 - headers/bliss/partition.hh | 305 - headers/bliss/stats.hh | 98 - headers/bliss/timer.hh | 57 - headers/bliss/uintseqhash.hh | 60 - headers/bliss/utils.hh | 68 - headers/blockmemshell/memory.h | 897 -- headers/dijkstra/dijkstra.h | 124 - headers/gcg/bliss_automorph.h | 66 - headers/gcg/bliss_automorph.hpp | 55 - headers/gcg/branch_bpstrong.h | 90 - headers/gcg/branch_empty.h | 56 - headers/gcg/branch_generic.h | 129 - headers/gcg/branch_orig.h | 80 - headers/gcg/branch_relpsprob.h | 68 - headers/gcg/branch_ryanfoster.h | 56 - headers/gcg/class_conspartition.h | 147 - headers/gcg/class_detprobdata.h | 681 -- headers/gcg/class_indexpartition.h | 193 - headers/gcg/class_partialdecomp.h | 2081 ---- headers/gcg/class_pricingcontroller.h | 199 - headers/gcg/class_pricingtype.h | 232 - headers/gcg/class_stabilization.h | 231 - headers/gcg/class_varpartition.h | 149 - headers/gcg/clscons_consnamelevenshtein.h | 56 - headers/gcg/clscons_consnamenonumbers.h | 56 - headers/gcg/clscons_gamsdomain.h | 65 - headers/gcg/clscons_gamssymbol.h | 64 - headers/gcg/clscons_miplibconstypes.h | 56 - headers/gcg/clscons_nnonzeros.h | 56 - headers/gcg/clscons_scipconstypes.h | 56 - headers/gcg/clsvar_gamsdomain.h | 64 - headers/gcg/clsvar_gamssymbol.h | 63 - headers/gcg/clsvar_objvalues.h | 55 - headers/gcg/clsvar_objvaluesigns.h | 55 - headers/gcg/clsvar_scipvartypes.h | 55 - headers/gcg/colpool.h | 50 - headers/gcg/cons_decomp.h | 1026 -- headers/gcg/cons_decomp.hpp | 144 - headers/gcg/cons_integralorig.h | 62 - headers/gcg/cons_masterbranch.h | 208 - headers/gcg/cons_origbranch.h | 164 - headers/gcg/dec_compgreedily.h | 54 - headers/gcg/dec_connected_noNewLinkingVars.h | 54 - headers/gcg/dec_connectedbase.h | 55 - headers/gcg/dec_consclass.h | 53 - headers/gcg/dec_constype.h | 53 - headers/gcg/dec_dbscan.h | 56 - headers/gcg/dec_densemasterconss.h | 53 - headers/gcg/dec_generalmastersetcover.h | 66 - headers/gcg/dec_generalmastersetpack.h | 65 - headers/gcg/dec_generalmastersetpart.h | 57 - headers/gcg/dec_hcgpartition.h | 57 - headers/gcg/dec_hrcgpartition.h | 55 - headers/gcg/dec_hrgpartition.h | 55 - headers/gcg/dec_isomorph.h | 53 - headers/gcg/dec_mastersetcover.h | 64 - headers/gcg/dec_mastersetpack.h | 64 - headers/gcg/dec_mastersetpart.h | 64 - headers/gcg/dec_mst.h | 56 - headers/gcg/dec_neighborhoodmaster.h | 53 - headers/gcg/dec_postprocess.h | 54 - headers/gcg/dec_staircase_lsp.h | 55 - headers/gcg/dec_stairheur.h | 64 - headers/gcg/dec_varclass.h | 53 - headers/gcg/decomp.h | 69 - headers/gcg/def.h | 41 - headers/gcg/dialog_gcg.h | 172 - headers/gcg/dialog_graph.h | 105 - headers/gcg/dialog_master.h | 68 - headers/gcg/disp_gcg.h | 48 - headers/gcg/disp_master.h | 55 - headers/gcg/event_bestsol.h | 55 - headers/gcg/event_display.h | 61 - headers/gcg/event_mastersol.h | 61 - headers/gcg/event_relaxsol.h | 63 - headers/gcg/event_solvingstats.h | 41 - headers/gcg/gcg.h | 319 - headers/gcg/gcg_general.h | 60 - headers/gcg/gcgcol.h | 49 - headers/gcg/gcggithash.h | 54 - headers/gcg/gcgplugins.h | 55 - headers/gcg/gcgpqueue.h | 49 - headers/gcg/gcgsort.h | 82 - headers/gcg/graph/bipartitegraph.h | 72 - headers/gcg/graph/bipartitegraph_def.h | 259 - headers/gcg/graph/bridge.h | 142 - headers/gcg/graph/columngraph.h | 69 - headers/gcg/graph/columngraph_def.h | 229 - headers/gcg/graph/graph.h | 226 - headers/gcg/graph/graph_def.h | 342 - headers/gcg/graph/graph_gcg.h | 119 - headers/gcg/graph/graph_interface.h | 97 - headers/gcg/graph/graph_tclique.h | 90 - headers/gcg/graph/graphalgorithms.h | 149 - headers/gcg/graph/graphalgorithms_def.h | 474 - headers/gcg/graph/hypercolgraph.h | 138 - headers/gcg/graph/hypercolgraph_def.h | 514 - headers/gcg/graph/hypergraph.h | 178 - headers/gcg/graph/hypergraph_def.h | 273 - headers/gcg/graph/hyperrowcolgraph.h | 124 - headers/gcg/graph/hyperrowcolgraph_def.h | 679 -- headers/gcg/graph/hyperrowgraph.h | 143 - headers/gcg/graph/hyperrowgraph_def.h | 593 - headers/gcg/graph/matrixgraph.h | 160 - headers/gcg/graph/matrixgraph_def.h | 61 - headers/gcg/graph/rowgraph.h | 78 - headers/gcg/graph/rowgraph_def.h | 394 - headers/gcg/graph/weights.h | 68 - headers/gcg/heur_gcgcoefdiving.h | 57 - headers/gcg/heur_gcgdins.h | 60 - headers/gcg/heur_gcgfeaspump.h | 66 - headers/gcg/heur_gcgfracdiving.h | 57 - headers/gcg/heur_gcgguideddiving.h | 57 - headers/gcg/heur_gcglinesdiving.h | 57 - headers/gcg/heur_gcgpscostdiving.h | 57 - headers/gcg/heur_gcgrens.h | 69 - headers/gcg/heur_gcgrins.h | 56 - headers/gcg/heur_gcgrounding.h | 57 - headers/gcg/heur_gcgshifting.h | 57 - headers/gcg/heur_gcgsimplerounding.h | 57 - headers/gcg/heur_gcgveclendiving.h | 57 - headers/gcg/heur_gcgzirounding.h | 58 - headers/gcg/heur_greedycolsel.h | 56 - headers/gcg/heur_mastercoefdiving.h | 61 - headers/gcg/heur_masterdiving.h | 93 - headers/gcg/heur_masterfracdiving.h | 61 - headers/gcg/heur_masterlinesdiving.h | 62 - headers/gcg/heur_mastervecldiving.h | 62 - headers/gcg/heur_origdiving.h | 93 - headers/gcg/heur_relaxcolsel.h | 56 - headers/gcg/heur_restmaster.h | 56 - headers/gcg/heur_setcover.h | 57 - headers/gcg/heur_xpcrossover.h | 56 - headers/gcg/heur_xprins.h | 56 - headers/gcg/masterplugins.h | 53 - headers/gcg/miscvisualization.h | 67 - headers/gcg/nodesel_master.h | 57 - headers/gcg/objdialog.h | 155 - headers/gcg/objpricer_gcg.h | 458 - headers/gcg/params_visu.h | 263 - headers/gcg/presol_roundbound.h | 48 - headers/gcg/pricer_gcg.h | 298 - headers/gcg/pricestore_gcg.h | 182 - headers/gcg/pricingjob.h | 112 - headers/gcg/pricingprob.h | 123 - headers/gcg/pub_bliss.h | 168 - headers/gcg/pub_colpool.h | 175 - headers/gcg/pub_decomp.h | 731 -- headers/gcg/pub_gcgcol.h | 284 - headers/gcg/pub_gcgheur.h | 68 - headers/gcg/pub_gcgpqueue.h | 136 - headers/gcg/pub_gcgsepa.h | 69 - headers/gcg/pub_gcgvar.h | 668 -- headers/gcg/pub_pricingjob.h | 96 - headers/gcg/pub_pricingprob.h | 136 - headers/gcg/pub_solver.h | 156 - headers/gcg/reader_blk.h | 79 - headers/gcg/reader_cls.h | 64 - headers/gcg/reader_dec.h | 88 - headers/gcg/reader_gp.h | 100 - headers/gcg/reader_ref.h | 81 - headers/gcg/reader_tex.h | 101 - headers/gcg/relax_gcg.h | 413 - headers/gcg/scip_misc.h | 158 - headers/gcg/scoretype.h | 68 - headers/gcg/sepa_basis.h | 98 - headers/gcg/sepa_master.h | 82 - headers/gcg/solver.h | 139 - headers/gcg/solver_cliquer.h | 56 - headers/gcg/solver_knapsack.h | 55 - headers/gcg/solver_mip.h | 56 - headers/gcg/solver_xyz.h | 54 - headers/gcg/stat.h | 67 - headers/gcg/struct_branchgcg.h | 60 - headers/gcg/struct_colpool.h | 76 - headers/gcg/struct_decomp.h | 102 - headers/gcg/struct_detector.h | 83 - headers/gcg/struct_gcgcol.h | 80 - headers/gcg/struct_gcgpqueue.h | 72 - headers/gcg/struct_pricestore_gcg.h | 81 - headers/gcg/struct_pricingjob.h | 69 - headers/gcg/struct_pricingprob.h | 81 - headers/gcg/struct_solver.h | 79 - headers/gcg/struct_vardata.h | 129 - headers/gcg/type_branchgcg.h | 120 - headers/gcg/type_classifier.h | 53 - headers/gcg/type_colpool.h | 49 - headers/gcg/type_consclassifier.h | 64 - headers/gcg/type_decomp.h | 74 - headers/gcg/type_detector.h | 176 - headers/gcg/type_gcgcol.h | 51 - headers/gcg/type_gcgpqueue.h | 49 - headers/gcg/type_masterdiving.h | 134 - headers/gcg/type_origdiving.h | 135 - headers/gcg/type_parameter.h | 53 - headers/gcg/type_pricestore_gcg.h | 58 - headers/gcg/type_pricingjob.h | 51 - headers/gcg/type_pricingprob.h | 51 - headers/gcg/type_pricingstatus.h | 63 - headers/gcg/type_scoretype.h | 69 - headers/gcg/type_solver.h | 140 - headers/gcg/type_varclassifier.h | 62 - headers/gcg/wrapper_partialdecomp.h | 52 - headers/lpi/lpi.h | 1115 -- headers/lpi/type_lpi.h | 114 - headers/objscip/objbenders.h | 329 - headers/objscip/objbenderscut.h | 236 - headers/objscip/objbranchrule.h | 261 - headers/objscip/objcloneable.h | 71 - headers/objscip/objconshdlr.h | 529 - headers/objscip/objcutsel.h | 207 - headers/objscip/objdialog.h | 170 - headers/objscip/objdisp.h | 245 - headers/objscip/objeventhdlr.h | 212 - headers/objscip/objheur.h | 254 - headers/objscip/objmessagehdlr.h | 149 - headers/objscip/objnodesel.h | 228 - headers/objscip/objpresol.h | 228 - headers/objscip/objpricer.h | 230 - headers/objscip/objprobcloneable.h | 75 - headers/objscip/objprobdata.h | 236 - headers/objscip/objprop.h | 297 - headers/objscip/objreader.h | 199 - headers/objscip/objrelax.h | 227 - headers/objscip/objscip.h | 57 - headers/objscip/objscipdefplugins.h | 39 - headers/objscip/objsepa.h | 259 - headers/objscip/objtable.h | 221 - headers/objscip/objvardata.h | 201 - headers/objscip/type_objcloneable.h | 74 - headers/objscip/type_objprobcloneable.h | 58 - headers/papilo/CMakeConfig.hpp | 50 - headers/papilo/Config.hpp | 43 - headers/papilo/core/Components.hpp | 265 - headers/papilo/core/ConstraintMatrix.hpp | 1501 --- headers/papilo/core/MatrixBuffer.hpp | 655 -- headers/papilo/core/Objective.hpp | 53 - headers/papilo/core/Presolve.hpp | 1437 --- headers/papilo/core/PresolveMethod.hpp | 329 - headers/papilo/core/PresolveOptions.hpp | 239 - headers/papilo/core/ProbingView.hpp | 822 -- headers/papilo/core/Problem.hpp | 783 -- headers/papilo/core/ProblemBuilder.hpp | 402 - headers/papilo/core/ProblemUpdate.hpp | 2926 ----- headers/papilo/core/Reductions.hpp | 384 - headers/papilo/core/RowFlags.hpp | 45 - headers/papilo/core/SingleRow.hpp | 847 -- headers/papilo/core/Solution.hpp | 98 - headers/papilo/core/SparseStorage.hpp | 985 -- headers/papilo/core/Statistics.hpp | 72 - headers/papilo/core/VariableDomains.hpp | 135 - .../papilo/core/postsolve/BoundStorage.hpp | 148 - headers/papilo/core/postsolve/Postsolve.hpp | 1526 --- .../papilo/core/postsolve/PostsolveStatus.hpp | 35 - .../core/postsolve/PostsolveStorage.hpp | 717 -- .../papilo/core/postsolve/PostsolveType.hpp | 35 - .../papilo/core/postsolve/ReductionType.hpp | 51 - headers/papilo/core/postsolve/SavedRow.hpp | 178 - headers/papilo/external/fmt/chrono.h | 1106 -- headers/papilo/external/fmt/color.h | 570 - headers/papilo/external/fmt/compile.h | 585 - headers/papilo/external/fmt/core.h | 1519 --- headers/papilo/external/fmt/format-inl.h | 1396 --- headers/papilo/external/fmt/format.cc | 176 - headers/papilo/external/fmt/format.h | 3541 ------ headers/papilo/external/fmt/locale.h | 77 - headers/papilo/external/fmt/ostream.h | 141 - headers/papilo/external/fmt/posix.cc | 237 - headers/papilo/external/fmt/posix.h | 321 - headers/papilo/external/fmt/printf.h | 711 -- headers/papilo/external/fmt/ranges.h | 365 - headers/papilo/external/lusol/clusol.h | 216 - headers/papilo/external/pdqsort/pdqsort.h | 544 - .../papilo/external/ska/bytell_hash_map.hpp | 1260 --- headers/papilo/external/ska/flat_hash_map.hpp | 1496 --- headers/papilo/external/ska/unordered_map.hpp | 885 -- headers/papilo/interfaces/GlopInterface.hpp | 354 - headers/papilo/interfaces/GurobiInterface.hpp | 413 - headers/papilo/interfaces/HighsInterface.hpp | 447 - headers/papilo/interfaces/ScipInterface.hpp | 639 -- headers/papilo/interfaces/SolverInterface.hpp | 155 - headers/papilo/interfaces/SoplexInterface.hpp | 560 - headers/papilo/io/Message.hpp | 203 - headers/papilo/io/MpsParser.hpp | 906 -- headers/papilo/io/MpsWriter.hpp | 263 - headers/papilo/io/SolParser.hpp | 146 - headers/papilo/io/SolWriter.hpp | 230 - headers/papilo/misc/Alloc.hpp | 43 - headers/papilo/misc/Array.hpp | 81 - headers/papilo/misc/DependentRows.hpp | 558 - headers/papilo/misc/Flags.hpp | 103 - headers/papilo/misc/Hash.hpp | 128 - headers/papilo/misc/MultiPrecision.hpp | 144 - headers/papilo/misc/Num.hpp | 545 - headers/papilo/misc/NumericalStatistics.hpp | 258 - headers/papilo/misc/OptionsParser.hpp | 368 - headers/papilo/misc/ParameterSet.hpp | 430 - .../papilo/misc/PrimalDualSolValidation.hpp | 481 - headers/papilo/misc/Signature.hpp | 85 - headers/papilo/misc/StableSum.hpp | 89 - headers/papilo/misc/String.hpp | 36 - headers/papilo/misc/Timer.hpp | 82 - headers/papilo/misc/Validation.hpp | 210 - headers/papilo/misc/Vec.hpp | 40 - headers/papilo/misc/VectorUtils.hpp | 258 - headers/papilo/misc/VersionLogger.hpp | 173 - headers/papilo/misc/Wrappers.hpp | 566 - headers/papilo/misc/compress_vector.hpp | 75 - headers/papilo/misc/fmt.hpp | 67 - headers/papilo/misc/tbb.hpp | 84 - .../presolvers/CoefficientStrengthening.hpp | 294 - .../presolvers/ConstraintPropagation.hpp | 456 - headers/papilo/presolvers/DominatedCols.hpp | 545 - headers/papilo/presolvers/DualFix.hpp | 559 - headers/papilo/presolvers/DualInfer.hpp | 549 - headers/papilo/presolvers/FixContinuous.hpp | 123 - .../papilo/presolvers/FreeVarSubstitution.hpp | 360 - .../papilo/presolvers/ImplIntDetection.hpp | 282 - .../presolvers/ParallelColDetection.hpp | 629 -- .../presolvers/ParallelRowDetection.hpp | 580 - headers/papilo/presolvers/Probing.hpp | 620 -- headers/papilo/presolvers/SimpleProbing.hpp | 242 - .../papilo/presolvers/SimpleSubstitution.hpp | 361 - .../presolvers/SimplifyInequalities.hpp | 492 - headers/papilo/presolvers/SingletonCols.hpp | 492 - .../papilo/presolvers/SingletonStuffing.hpp | 649 -- headers/papilo/presolvers/Sparsify.hpp | 495 - headers/scip/bandit.h | 106 - headers/scip/bandit_epsgreedy.h | 86 - headers/scip/bandit_exp3.h | 85 - headers/scip/bandit_ucb.h | 85 - headers/scip/benders.h | 454 - headers/scip/benders_default.h | 74 - headers/scip/benderscut.h | 165 - headers/scip/benderscut_feas.h | 90 - headers/scip/benderscut_feasalt.h | 79 - headers/scip/benderscut_int.h | 86 - headers/scip/benderscut_nogood.h | 72 - headers/scip/benderscut_opt.h | 149 - headers/scip/bendersdefcuts.h | 57 - headers/scip/bitencode.h | 78 - headers/scip/boundstore.h | 109 - headers/scip/branch.h | 506 - headers/scip/branch_allfullstrong.h | 102 - headers/scip/branch_cloud.h | 59 - headers/scip/branch_distribution.h | 162 - headers/scip/branch_fullstrong.h | 119 - headers/scip/branch_inference.h | 76 - headers/scip/branch_leastinf.h | 72 - headers/scip/branch_lookahead.h | 75 - headers/scip/branch_mostinf.h | 73 - headers/scip/branch_multaggr.h | 68 - headers/scip/branch_nodereopt.h | 59 - headers/scip/branch_pscost.h | 94 - headers/scip/branch_random.h | 67 - headers/scip/branch_relpscost.h | 97 - headers/scip/branch_vanillafullstrong.h | 87 - headers/scip/clock.h | 133 - headers/scip/compr.h | 170 - headers/scip/compr_largestrepr.h | 56 - headers/scip/compr_weakcompr.h | 56 - headers/scip/concsolver.h | 218 - headers/scip/concsolver_scip.h | 54 - headers/scip/concurrent.h | 181 - headers/scip/config.h | 31 - headers/scip/conflict.h | 680 -- headers/scip/conflictstore.h | 212 - headers/scip/cons.h | 1158 -- headers/scip/cons_abspower.h | 147 - headers/scip/cons_and.h | 200 - headers/scip/cons_benders.h | 113 - headers/scip/cons_benderslp.h | 85 - headers/scip/cons_bounddisjunction.h | 223 - headers/scip/cons_cardinality.h | 211 - headers/scip/cons_components.h | 59 - headers/scip/cons_conjunction.h | 129 - headers/scip/cons_countsols.h | 143 - headers/scip/cons_cumulative.h | 433 - headers/scip/cons_disjunction.h | 134 - headers/scip/cons_indicator.h | 409 - headers/scip/cons_integral.h | 58 - headers/scip/cons_knapsack.h | 299 - headers/scip/cons_linear.h | 394 - headers/scip/cons_linking.h | 198 - headers/scip/cons_logicor.h | 192 - headers/scip/cons_nonlinear.h | 1050 -- headers/scip/cons_or.h | 161 - headers/scip/cons_orbisack.h | 161 - headers/scip/cons_orbitope.h | 163 - headers/scip/cons_pseudoboolean.h | 368 - headers/scip/cons_quadratic.h | 272 - headers/scip/cons_setppc.h | 338 - headers/scip/cons_soc.h | 144 - headers/scip/cons_sos1.h | 226 - headers/scip/cons_sos2.h | 172 - headers/scip/cons_superindicator.h | 176 - headers/scip/cons_symresack.h | 191 - headers/scip/cons_varbound.h | 215 - headers/scip/cons_xor.h | 169 - headers/scip/cutpool.h | 178 - headers/scip/cuts.h | 478 - headers/scip/cutsel.h | 169 - headers/scip/cutsel_hybrid.h | 131 - headers/scip/dbldblarith.h | 382 - headers/scip/dcmp.h | 103 - headers/scip/debug.h | 360 - headers/scip/def.h | 461 - headers/scip/dialog.h | 132 - headers/scip/dialog_default.h | 416 - headers/scip/disp.h | 147 - headers/scip/disp_default.h | 57 - headers/scip/event.h | 518 - headers/scip/event_estim.h | 77 - headers/scip/event_globalbnd.h | 84 - headers/scip/event_softtimelimit.h | 40 - headers/scip/event_solvingphase.h | 57 - headers/scip/expr.h | 743 -- headers/scip/expr_abs.h | 93 - headers/scip/expr_entropy.h | 97 - headers/scip/expr_erf.h | 95 - headers/scip/expr_exp.h | 92 - headers/scip/expr_log.h | 92 - headers/scip/expr_pow.h | 144 - headers/scip/expr_product.h | 88 - headers/scip/expr_sum.h | 113 - headers/scip/expr_trig.h | 121 - headers/scip/expr_value.h | 80 - headers/scip/expr_var.h | 82 - headers/scip/expr_varidx.h | 103 - headers/scip/exprinterpret.h | 190 - headers/scip/heur.h | 265 - headers/scip/heur_actconsdiving.h | 64 - headers/scip/heur_adaptivediving.h | 53 - headers/scip/heur_alns.h | 58 - headers/scip/heur_bound.h | 57 - headers/scip/heur_clique.h | 59 - headers/scip/heur_coefdiving.h | 62 - headers/scip/heur_completesol.h | 57 - headers/scip/heur_conflictdiving.h | 58 - headers/scip/heur_crossover.h | 62 - headers/scip/heur_dins.h | 62 - headers/scip/heur_distributiondiving.h | 59 - headers/scip/heur_dps.h | 69 - headers/scip/heur_dualval.h | 83 - headers/scip/heur_farkasdiving.h | 65 - headers/scip/heur_feaspump.h | 67 - headers/scip/heur_fixandinfer.h | 57 - headers/scip/heur_fracdiving.h | 62 - headers/scip/heur_gins.h | 77 - headers/scip/heur_guideddiving.h | 63 - headers/scip/heur_indicator.h | 81 - headers/scip/heur_intdiving.h | 62 - headers/scip/heur_intshifting.h | 62 - headers/scip/heur_linesearchdiving.h | 63 - headers/scip/heur_localbranching.h | 57 - headers/scip/heur_locks.h | 80 - headers/scip/heur_lpface.h | 59 - headers/scip/heur_mpec.h | 110 - headers/scip/heur_multistart.h | 106 - headers/scip/heur_mutation.h | 61 - headers/scip/heur_nlpdiving.h | 64 - headers/scip/heur_objpscostdiving.h | 57 - headers/scip/heur_octane.h | 57 - headers/scip/heur_ofins.h | 57 - headers/scip/heur_oneopt.h | 63 - headers/scip/heur_padm.h | 68 - headers/scip/heur_proximity.h | 93 - headers/scip/heur_pscostdiving.h | 65 - headers/scip/heur_randrounding.h | 69 - headers/scip/heur_rens.h | 85 - headers/scip/heur_reoptsols.h | 78 - headers/scip/heur_repair.h | 62 - headers/scip/heur_rins.h | 61 - headers/scip/heur_rootsoldiving.h | 57 - headers/scip/heur_rounding.h | 64 - headers/scip/heur_shiftandpropagate.h | 63 - headers/scip/heur_shifting.h | 62 - headers/scip/heur_simplerounding.h | 62 - headers/scip/heur_subnlp.h | 109 - headers/scip/heur_sync.h | 80 - headers/scip/heur_trivial.h | 61 - headers/scip/heur_trivialnegation.h | 59 - headers/scip/heur_trustregion.h | 84 - headers/scip/heur_trysol.h | 87 - headers/scip/heur_twoopt.h | 64 - headers/scip/heur_undercover.h | 90 - headers/scip/heur_vbounds.h | 63 - headers/scip/heur_veclendiving.h | 63 - headers/scip/heur_zeroobj.h | 76 - headers/scip/heur_zirounding.h | 63 - headers/scip/heuristics.h | 138 - headers/scip/history.h | 299 - headers/scip/implics.h | 461 - headers/scip/interrupt.h | 92 - headers/scip/intervalarith.h | 797 -- headers/scip/lp.h | 1643 --- headers/scip/mem.h | 85 - headers/scip/message.h | 61 - headers/scip/message_default.h | 56 - headers/scip/misc.h | 384 - headers/scip/nlhdlr.h | 135 - headers/scip/nlhdlr_bilinear.h | 186 - headers/scip/nlhdlr_convex.h | 92 - headers/scip/nlhdlr_default.h | 69 - headers/scip/nlhdlr_perspective.h | 70 - headers/scip/nlhdlr_quadratic.h | 71 - headers/scip/nlhdlr_quotient.h | 72 - headers/scip/nlhdlr_soc.h | 125 - headers/scip/nlp.h | 686 -- headers/scip/nlpi.h | 296 - headers/scip/nlpi_all.h | 57 - headers/scip/nlpi_filtersqp.h | 74 - headers/scip/nlpi_ipopt.h | 109 - headers/scip/nlpi_worhp.h | 82 - headers/scip/nlpioracle.h | 452 - headers/scip/nodesel.h | 311 - headers/scip/nodesel_bfs.h | 57 - headers/scip/nodesel_breadthfirst.h | 61 - headers/scip/nodesel_dfs.h | 57 - headers/scip/nodesel_estimate.h | 57 - headers/scip/nodesel_hybridestim.h | 57 - headers/scip/nodesel_restartdfs.h | 57 - headers/scip/nodesel_uct.h | 94 - headers/scip/paramset.h | 585 - headers/scip/presol.h | 178 - headers/scip/presol_boundshift.h | 65 - headers/scip/presol_convertinttobin.h | 57 - headers/scip/presol_domcol.h | 62 - headers/scip/presol_dualagg.h | 72 - headers/scip/presol_dualcomp.h | 64 - headers/scip/presol_dualinfer.h | 72 - headers/scip/presol_dualsparsify.h | 74 - headers/scip/presol_gateextraction.h | 84 - headers/scip/presol_implics.h | 72 - headers/scip/presol_inttobinary.h | 63 - headers/scip/presol_milp.h | 60 - headers/scip/presol_qpkktref.h | 113 - headers/scip/presol_redvub.h | 57 - headers/scip/presol_sparsify.h | 58 - headers/scip/presol_stuffing.h | 60 - headers/scip/presol_trivial.h | 60 - headers/scip/presol_tworowbnd.h | 96 - headers/scip/presolve.h | 97 - headers/scip/pricer.h | 207 - headers/scip/pricestore.h | 173 - headers/scip/primal.h | 393 - headers/scip/prob.h | 661 -- headers/scip/prop.h | 265 - headers/scip/prop_dualfix.h | 61 - headers/scip/prop_genvbounds.h | 121 - headers/scip/prop_nlobbt.h | 121 - headers/scip/prop_obbt.h | 79 - headers/scip/prop_probing.h | 117 - headers/scip/prop_pseudoobj.h | 83 - headers/scip/prop_redcost.h | 63 - headers/scip/prop_rootredcost.h | 64 - headers/scip/prop_symmetry.h | 86 - headers/scip/prop_sync.h | 90 - headers/scip/prop_vbounds.h | 80 - headers/scip/pub_bandit.h | 91 - headers/scip/pub_bandit_epsgreedy.h | 99 - headers/scip/pub_bandit_exp3.h | 107 - headers/scip/pub_bandit_ucb.h | 93 - headers/scip/pub_benders.h | 483 - headers/scip/pub_benderscut.h | 140 - headers/scip/pub_branch.h | 175 - headers/scip/pub_compr.h | 131 - headers/scip/pub_conflict.h | 114 - headers/scip/pub_cons.h | 946 -- headers/scip/pub_cutpool.h | 125 - headers/scip/pub_cutsel.h | 150 - headers/scip/pub_dcmp.h | 243 - headers/scip/pub_dialog.h | 234 - headers/scip/pub_disp.h | 146 - headers/scip/pub_event.h | 271 - headers/scip/pub_expr.h | 1108 -- headers/scip/pub_fileio.h | 68 - headers/scip/pub_heur.h | 487 - headers/scip/pub_history.h | 115 - headers/scip/pub_implics.h | 136 - headers/scip/pub_lp.h | 551 - headers/scip/pub_matrix.h | 349 - headers/scip/pub_message.h | 427 - headers/scip/pub_misc.h | 2354 ---- headers/scip/pub_misc_linear.h | 135 - headers/scip/pub_misc_rowprep.h | 417 - headers/scip/pub_misc_select.h | 3583 ------ headers/scip/pub_misc_sort.h | 4338 -------- headers/scip/pub_nlhdlr.h | 208 - headers/scip/pub_nlp.h | 170 - headers/scip/pub_nlpi.h | 171 - headers/scip/pub_nodesel.h | 110 - headers/scip/pub_paramset.h | 212 - headers/scip/pub_presol.h | 198 - headers/scip/pub_pricer.h | 137 - headers/scip/pub_prop.h | 281 - headers/scip/pub_reader.h | 98 - headers/scip/pub_relax.h | 169 - headers/scip/pub_reopt.h | 232 - headers/scip/pub_sepa.h | 256 - headers/scip/pub_sol.h | 235 - headers/scip/pub_table.h | 105 - headers/scip/pub_tree.h | 287 - headers/scip/pub_var.h | 1496 --- headers/scip/rbtree.h | 180 - headers/scip/reader.h | 140 - headers/scip/reader_bnd.h | 65 - headers/scip/reader_ccg.h | 83 - headers/scip/reader_cip.h | 63 - headers/scip/reader_cnf.h | 61 - headers/scip/reader_cor.h | 128 - headers/scip/reader_dec.h | 102 - headers/scip/reader_diff.h | 111 - headers/scip/reader_fix.h | 68 - headers/scip/reader_fzn.h | 77 - headers/scip/reader_gms.h | 96 - headers/scip/reader_lp.h | 107 - headers/scip/reader_mps.h | 117 - headers/scip/reader_mst.h | 89 - headers/scip/reader_nl.h | 61 - headers/scip/reader_opb.h | 107 - headers/scip/reader_osil.h | 62 - headers/scip/reader_pbm.h | 81 - headers/scip/reader_pip.h | 106 - headers/scip/reader_ppm.h | 84 - headers/scip/reader_rlp.h | 57 - headers/scip/reader_smps.h | 75 - headers/scip/reader_sol.h | 90 - headers/scip/reader_sto.h | 119 - headers/scip/reader_tim.h | 155 - headers/scip/reader_wbo.h | 60 - headers/scip/reader_zpl.h | 60 - headers/scip/relax.h | 264 - headers/scip/reopt.h | 582 - headers/scip/retcode.h | 60 - headers/scip/scip.h | 179 - headers/scip/scip_bandit.h | 99 - headers/scip/scip_benders.h | 939 -- headers/scip/scip_branch.h | 832 -- headers/scip/scip_compr.h | 181 - headers/scip/scip_concurrent.h | 195 - headers/scip/scip_conflict.h | 517 - headers/scip/scip_cons.h | 1784 --- headers/scip/scip_copy.h | 1292 --- headers/scip/scip_cut.h | 540 - headers/scip/scip_cutsel.h | 175 - headers/scip/scip_datastructures.h | 497 - headers/scip/scip_dcmp.h | 169 - headers/scip/scip_debug.h | 84 - headers/scip/scip_dialog.h | 195 - headers/scip/scip_disp.h | 118 - headers/scip/scip_event.h | 353 - headers/scip/scip_export.h | 42 - headers/scip/scip_expr.h | 1082 -- headers/scip/scip_general.h | 379 - headers/scip/scip_heur.h | 259 - headers/scip/scip_lp.h | 1819 --- headers/scip/scip_mem.h | 246 - headers/scip/scip_message.h | 216 - headers/scip/scip_nlp.h | 1006 -- headers/scip/scip_nlpi.h | 311 - headers/scip/scip_nodesel.h | 198 - headers/scip/scip_numerics.h | 881 -- headers/scip/scip_param.h | 662 -- headers/scip/scip_presol.h | 191 - headers/scip/scip_pricer.h | 297 - headers/scip/scip_prob.h | 1807 --- headers/scip/scip_probing.h | 551 - headers/scip/scip_prop.h | 240 - headers/scip/scip_randnumgen.h | 102 - headers/scip/scip_reader.h | 200 - headers/scip/scip_relax.h | 183 - headers/scip/scip_reopt.h | 335 - headers/scip/scip_sepa.h | 245 - headers/scip/scip_sol.h | 1512 --- headers/scip/scip_solve.h | 468 - headers/scip/scip_solvingstats.h | 2226 ---- headers/scip/scip_table.h | 103 - headers/scip/scip_timing.h | 360 - headers/scip/scip_tree.h | 503 - headers/scip/scip_validation.h | 91 - headers/scip/scip_var.h | 3870 ------- headers/scip/scipbuildflags.h | 52 - headers/scip/scipcoreplugins.h | 57 - headers/scip/scipdefplugins.h | 271 - headers/scip/scipgithash.h | 52 - headers/scip/scipshell.h | 66 - headers/scip/sepa.h | 230 - headers/scip/sepa_aggregation.h | 75 - headers/scip/sepa_cgmip.h | 62 - headers/scip/sepa_clique.h | 59 - headers/scip/sepa_closecuts.h | 83 - headers/scip/sepa_convexproj.h | 99 - headers/scip/sepa_disjunctive.h | 69 - headers/scip/sepa_eccuts.h | 102 - headers/scip/sepa_gauge.h | 102 - headers/scip/sepa_gomory.h | 60 - headers/scip/sepa_impliedbounds.h | 59 - headers/scip/sepa_interminor.h | 60 - headers/scip/sepa_intobj.h | 58 - headers/scip/sepa_mcf.h | 71 - headers/scip/sepa_minor.h | 89 - headers/scip/sepa_mixing.h | 58 - headers/scip/sepa_oddcycle.h | 58 - headers/scip/sepa_rapidlearning.h | 57 - headers/scip/sepa_rlt.h | 71 - headers/scip/sepa_zerohalf.h | 61 - headers/scip/sepastore.h | 196 - headers/scip/set.h | 1806 --- headers/scip/sol.h | 510 - headers/scip/solve.h | 230 - headers/scip/stat.h | 357 - headers/scip/struct_bandit.h | 68 - headers/scip/struct_benders.h | 209 - headers/scip/struct_benderscut.h | 74 - headers/scip/struct_branch.h | 116 - headers/scip/struct_clock.h | 82 - headers/scip/struct_compr.h | 74 - headers/scip/struct_concsolver.h | 92 - headers/scip/struct_concurrent.h | 67 - headers/scip/struct_conflict.h | 199 - headers/scip/struct_conflictstore.h | 85 - headers/scip/struct_cons.h | 299 - headers/scip/struct_cutpool.h | 85 - headers/scip/struct_cuts.h | 55 - headers/scip/struct_cutsel.h | 76 - headers/scip/struct_dcmp.h | 81 - headers/scip/struct_dialog.h | 85 - headers/scip/struct_disp.h | 72 - headers/scip/struct_event.h | 235 - headers/scip/struct_expr.h | 227 - headers/scip/struct_heur.h | 145 - headers/scip/struct_history.h | 75 - headers/scip/struct_implics.h | 119 - headers/scip/struct_lp.h | 409 - headers/scip/struct_matrix.h | 86 - headers/scip/struct_mem.h | 58 - headers/scip/struct_message.h | 67 - headers/scip/struct_misc.h | 308 - headers/scip/struct_nlhdlr.h | 85 - headers/scip/struct_nlp.h | 169 - headers/scip/struct_nlpi.h | 90 - headers/scip/struct_nodesel.h | 85 - headers/scip/struct_paramset.h | 141 - headers/scip/struct_presol.h | 91 - headers/scip/struct_pricer.h | 74 - headers/scip/struct_pricestore.h | 71 - headers/scip/struct_primal.h | 77 - headers/scip/struct_prob.h | 98 - headers/scip/struct_prop.h | 107 - headers/scip/struct_reader.h | 62 - headers/scip/struct_relax.h | 88 - headers/scip/struct_reopt.h | 190 - headers/scip/struct_scip.h | 117 - headers/scip/struct_sepa.h | 94 - headers/scip/struct_sepastore.h | 68 - headers/scip/struct_set.h | 630 -- headers/scip/struct_sol.h | 108 - headers/scip/struct_stat.h | 291 - headers/scip/struct_syncstore.h | 129 - headers/scip/struct_table.h | 67 - headers/scip/struct_tree.h | 259 - headers/scip/struct_var.h | 296 - headers/scip/struct_visual.h | 66 - headers/scip/symmetry.h | 265 - headers/scip/syncstore.h | 303 - headers/scip/table.h | 119 - headers/scip/table_default.h | 58 - headers/scip/tree.h | 981 -- headers/scip/treemodel.h | 113 - headers/scip/type_bandit.h | 92 - headers/scip/type_benders.h | 373 - headers/scip/type_benderscut.h | 131 - headers/scip/type_branch.h | 182 - headers/scip/type_clock.h | 57 - headers/scip/type_compr.h | 126 - headers/scip/type_concsolver.h | 163 - headers/scip/type_concurrent.h | 47 - headers/scip/type_conflict.h | 181 - headers/scip/type_conflictstore.h | 45 - headers/scip/type_cons.h | 925 -- headers/scip/type_cutpool.h | 46 - headers/scip/type_cuts.h | 39 - headers/scip/type_cutsel.h | 139 - headers/scip/type_dcmp.h | 51 - headers/scip/type_dialog.h | 102 - headers/scip/type_disp.h | 146 - headers/scip/type_event.h | 259 - headers/scip/type_expr.h | 730 -- headers/scip/type_exprinterpret.h | 59 - headers/scip/type_heur.h | 204 - headers/scip/type_history.h | 65 - headers/scip/type_implics.h | 50 - headers/scip/type_interrupt.h | 45 - headers/scip/type_lp.h | 116 - headers/scip/type_matrix.h | 46 - headers/scip/type_mem.h | 45 - headers/scip/type_message.h | 128 - headers/scip/type_misc.h | 214 - headers/scip/type_nlhdlr.h | 415 - headers/scip/type_nlp.h | 48 - headers/scip/type_nlpi.h | 572 - headers/scip/type_nodesel.h | 146 - headers/scip/type_paramset.h | 108 - headers/scip/type_presol.h | 177 - headers/scip/type_pricer.h | 180 - headers/scip/type_pricestore.h | 45 - headers/scip/type_primal.h | 45 - headers/scip/type_prob.h | 156 - headers/scip/type_prop.h | 265 - headers/scip/type_reader.h | 138 - headers/scip/type_relax.h | 133 - headers/scip/type_reopt.h | 82 - headers/scip/type_result.h | 67 - headers/scip/type_retcode.h | 69 - headers/scip/type_scip.h | 45 - headers/scip/type_sepa.h | 172 - headers/scip/type_sepastore.h | 54 - headers/scip/type_set.h | 79 - headers/scip/type_sol.h | 77 - headers/scip/type_stat.h | 75 - headers/scip/type_syncstore.h | 57 - headers/scip/type_table.h | 128 - headers/scip/type_timing.h | 107 - headers/scip/type_tree.h | 71 - headers/scip/type_var.h | 197 - headers/scip/type_visual.h | 82 - headers/scip/var.h | 1591 --- headers/scip/visual.h | 172 - headers/soplex.h | 2463 ----- headers/soplex.hpp | 9807 ----------------- headers/soplex/array.h | 275 - headers/soplex/basevectors.h | 1300 --- headers/soplex/changesoplex.hpp | 896 -- headers/soplex/classarray.h | 404 - headers/soplex/classset.h | 689 -- headers/soplex/clufactor.h | 495 - headers/soplex/clufactor.hpp | 6369 ----------- headers/soplex/clufactor_rational.h | 468 - headers/soplex/clufactor_rational.hpp | 6009 ---------- headers/soplex/config.h | 19 - headers/soplex/cring.h | 48 - headers/soplex/dataarray.h | 378 - headers/soplex/datahashtable.h | 502 - headers/soplex/datakey.h | 116 - headers/soplex/dataset.h | 660 -- headers/soplex/didxset.h | 144 - headers/soplex/dsvector.h | 41 - headers/soplex/dsvectorbase.h | 359 - headers/soplex/dvector.h | 44 - headers/soplex/enter.hpp | 1589 --- headers/soplex/exceptions.h | 150 - headers/soplex/gzstream.h | 288 - headers/soplex/idlist.h | 374 - headers/soplex/idxset.h | 208 - headers/soplex/islist.h | 491 - headers/soplex/leave.hpp | 1196 -- headers/soplex/lpcol.h | 42 - headers/soplex/lpcolbase.h | 201 - headers/soplex/lpcolset.h | 40 - headers/soplex/lpcolsetbase.h | 675 -- headers/soplex/lprow.h | 40 - headers/soplex/lprowbase.h | 301 - headers/soplex/lprowset.h | 40 - headers/soplex/lprowsetbase.h | 764 -- headers/soplex/mpsinput.h | 284 - headers/soplex/nameset.h | 388 - headers/soplex/notimer.h | 104 - headers/soplex/random.h | 174 - headers/soplex/rational.h | 1061 -- headers/soplex/ratrecon.h | 51 - headers/soplex/ratrecon.hpp | 294 - headers/soplex/slinsolver.h | 229 - headers/soplex/slinsolver_rational.h | 203 - headers/soplex/slufactor.h | 339 - headers/soplex/slufactor.hpp | 1538 --- headers/soplex/slufactor_rational.h | 514 - headers/soplex/slufactor_rational.hpp | 908 -- headers/soplex/sol.h | 39 - headers/soplex/solbase.h | 320 - headers/soplex/solvedbds.hpp | 4340 -------- headers/soplex/solverational.hpp | 4574 -------- headers/soplex/solvereal.hpp | 764 -- headers/soplex/sorter.h | 392 - headers/soplex/spxalloc.h | 133 - headers/soplex/spxautopr.h | 150 - headers/soplex/spxautopr.hpp | 126 - headers/soplex/spxbasis.h | 1035 -- headers/soplex/spxbasis.hpp | 1511 --- headers/soplex/spxboundflippingrt.h | 275 - headers/soplex/spxboundflippingrt.hpp | 1288 --- headers/soplex/spxbounds.hpp | 457 - headers/soplex/spxchangebasis.hpp | 524 - headers/soplex/spxdantzigpr.h | 111 - headers/soplex/spxdantzigpr.hpp | 258 - headers/soplex/spxdefaultrt.h | 100 - headers/soplex/spxdefaultrt.hpp | 414 - headers/soplex/spxdefines.h | 541 - headers/soplex/spxdefines.hpp | 157 - headers/soplex/spxdesc.hpp | 212 - headers/soplex/spxdevexpr.h | 175 - headers/soplex/spxdevexpr.hpp | 976 -- headers/soplex/spxequilisc.h | 90 - headers/soplex/spxequilisc.hpp | 266 - headers/soplex/spxfastrt.h | 260 - headers/soplex/spxfastrt.hpp | 1576 --- headers/soplex/spxfileio.h | 57 - headers/soplex/spxfileio.hpp | 63 - headers/soplex/spxgeometsc.h | 92 - headers/soplex/spxgeometsc.hpp | 269 - headers/soplex/spxgithash.h | 40 - headers/soplex/spxharrisrt.h | 136 - headers/soplex/spxharrisrt.hpp | 821 -- headers/soplex/spxhybridpr.h | 186 - headers/soplex/spxhybridpr.hpp | 159 - headers/soplex/spxid.h | 197 - headers/soplex/spxleastsqsc.h | 96 - headers/soplex/spxleastsqsc.hpp | 435 - headers/soplex/spxlp.h | 48 - headers/soplex/spxlpbase.h | 2909 ----- headers/soplex/spxlpbase_rational.hpp | 2257 ---- headers/soplex/spxlpbase_real.hpp | 2991 ----- headers/soplex/spxmainsm.h | 1667 --- headers/soplex/spxmainsm.hpp | 5451 --------- headers/soplex/spxout.h | 345 - headers/soplex/spxpapilo.h | 892 -- headers/soplex/spxparmultpr.h | 159 - headers/soplex/spxparmultpr.hpp | 229 - headers/soplex/spxpricer.h | 318 - headers/soplex/spxquality.hpp | 191 - headers/soplex/spxratiotester.h | 219 - headers/soplex/spxscaler.h | 259 - headers/soplex/spxscaler.hpp | 982 -- headers/soplex/spxshift.hpp | 836 -- headers/soplex/spxsimplifier.h | 275 - headers/soplex/spxsolve.hpp | 2368 ---- headers/soplex/spxsolver.h | 2417 ---- headers/soplex/spxsolver.hpp | 2433 ---- headers/soplex/spxstarter.h | 133 - headers/soplex/spxstarter.hpp | 41 - headers/soplex/spxsteepexpr.h | 97 - headers/soplex/spxsteeppr.h | 220 - headers/soplex/spxsteeppr.hpp | 1152 -- headers/soplex/spxsumst.h | 101 - headers/soplex/spxsumst.hpp | 97 - headers/soplex/spxvecs.hpp | 601 - headers/soplex/spxvectorst.h | 147 - headers/soplex/spxvectorst.hpp | 131 - headers/soplex/spxweightpr.h | 194 - headers/soplex/spxweightpr.hpp | 422 - headers/soplex/spxweightst.h | 218 - headers/soplex/spxweightst.hpp | 703 -- headers/soplex/spxwritestate.hpp | 115 - headers/soplex/ssvector.h | 41 - headers/soplex/ssvectorbase.h | 923 -- headers/soplex/stablesum.h | 119 - headers/soplex/statistics.h | 170 - headers/soplex/statistics.hpp | 356 - headers/soplex/svector.h | 42 - headers/soplex/svectorbase.h | 918 -- headers/soplex/svset.h | 39 - headers/soplex/svsetbase.h | 1102 -- headers/soplex/testsoplex.hpp | 276 - headers/soplex/timer.h | 173 - headers/soplex/timerfactory.h | 96 - headers/soplex/unitvector.h | 42 - headers/soplex/unitvectorbase.h | 152 - headers/soplex/updatevector.h | 188 - headers/soplex/updatevector.hpp | 65 - headers/soplex/usertimer.h | 135 - headers/soplex/validation.h | 79 - headers/soplex/validation.hpp | 178 - headers/soplex/vector.h | 42 - headers/soplex/vectorbase.h | 651 -- headers/soplex/wallclocktimer.h | 122 - headers/soplex_interface.h | 146 - headers/symmetry/compute_symmetry.h | 72 - headers/symmetry/type_symmetry.h | 135 - headers/tclique/tclique.h | 302 - headers/tclique/tclique_coloring.h | 89 - headers/tclique/tclique_def.h | 99 - headers/tinycthread/tinycthread.h | 472 - headers/tpi/def_openmp.h | 151 - headers/tpi/tpi.h | 160 - headers/tpi/tpi_none.h | 62 - headers/tpi/tpi_openmp.h | 53 - headers/tpi/tpi_tnycthrd.h | 59 - headers/tpi/type_tpi.h | 77 - headers/tpi/type_tpi_none.h | 46 - headers/tpi/type_tpi_openmp.h | 51 - headers/tpi/type_tpi_tnycthrd.h | 46 - headers/xml/xml.h | 181 - headers/xml/xmldef.h | 110 - headers/zimpl/attribute.h | 99 - headers/zimpl/blkmem.h | 42 - headers/zimpl/bound.h | 64 - headers/zimpl/code.h | 213 - headers/zimpl/conname.h | 48 - headers/zimpl/define.h | 63 - headers/zimpl/elem.h | 81 - headers/zimpl/entry.h | 70 - headers/zimpl/gmpmisc.h | 51 - headers/zimpl/hash.h | 81 - headers/zimpl/heap.h | 66 - headers/zimpl/idxset.h | 67 - headers/zimpl/inst.h | 339 - headers/zimpl/lint.h | 98 - headers/zimpl/list.h | 89 - headers/zimpl/local.h | 56 - headers/zimpl/metaio.h | 61 - headers/zimpl/mme.h | 140 - headers/zimpl/mmlparse2.h | 207 - headers/zimpl/mono.h | 103 - headers/zimpl/mshell.h | 95 - headers/zimpl/numb.h | 139 - headers/zimpl/prog.h | 67 - headers/zimpl/random.h | 42 - headers/zimpl/ratlp.h | 204 - headers/zimpl/ratlpstore.h | 161 - headers/zimpl/ratlptypes.h | 85 - headers/zimpl/rdefpar.h | 78 - headers/zimpl/set.h | 108 - headers/zimpl/set4.h | 286 - headers/zimpl/stkchk.h | 61 - headers/zimpl/stmt.h | 82 - headers/zimpl/strstore.h | 43 - headers/zimpl/symbol.h | 81 - headers/zimpl/term.h | 107 - headers/zimpl/tuple.h | 70 - headers/zimpl/xlpglue.h | 84 - headers/zimpl/zimpllib.h | 49 - headers/zimpl/zlpglue.h | 61 - 1045 files changed, 103 insertions(+), 308567 deletions(-) delete mode 100644 headers/bliss/abstractgraph.hh delete mode 100644 headers/bliss/bignum.hh delete mode 100644 headers/bliss/bliss_C.h delete mode 100644 headers/bliss/defs.hh delete mode 100644 headers/bliss/digraph.hh delete mode 100644 headers/bliss/graph.hh delete mode 100644 headers/bliss/heap.hh delete mode 100644 headers/bliss/kqueue.hh delete mode 100644 headers/bliss/kstack.hh delete mode 100644 headers/bliss/orbit.hh delete mode 100644 headers/bliss/partition.hh delete mode 100644 headers/bliss/stats.hh delete mode 100644 headers/bliss/timer.hh delete mode 100644 headers/bliss/uintseqhash.hh delete mode 100644 headers/bliss/utils.hh delete mode 100644 headers/blockmemshell/memory.h delete mode 100644 headers/dijkstra/dijkstra.h delete mode 100644 headers/gcg/bliss_automorph.h delete mode 100644 headers/gcg/bliss_automorph.hpp delete mode 100644 headers/gcg/branch_bpstrong.h delete mode 100644 headers/gcg/branch_empty.h delete mode 100644 headers/gcg/branch_generic.h delete mode 100644 headers/gcg/branch_orig.h delete mode 100644 headers/gcg/branch_relpsprob.h delete mode 100644 headers/gcg/branch_ryanfoster.h delete mode 100644 headers/gcg/class_conspartition.h delete mode 100644 headers/gcg/class_detprobdata.h delete mode 100644 headers/gcg/class_indexpartition.h delete mode 100644 headers/gcg/class_partialdecomp.h delete mode 100644 headers/gcg/class_pricingcontroller.h delete mode 100644 headers/gcg/class_pricingtype.h delete mode 100644 headers/gcg/class_stabilization.h delete mode 100644 headers/gcg/class_varpartition.h delete mode 100644 headers/gcg/clscons_consnamelevenshtein.h delete mode 100644 headers/gcg/clscons_consnamenonumbers.h delete mode 100644 headers/gcg/clscons_gamsdomain.h delete mode 100644 headers/gcg/clscons_gamssymbol.h delete mode 100644 headers/gcg/clscons_miplibconstypes.h delete mode 100644 headers/gcg/clscons_nnonzeros.h delete mode 100644 headers/gcg/clscons_scipconstypes.h delete mode 100644 headers/gcg/clsvar_gamsdomain.h delete mode 100644 headers/gcg/clsvar_gamssymbol.h delete mode 100644 headers/gcg/clsvar_objvalues.h delete mode 100644 headers/gcg/clsvar_objvaluesigns.h delete mode 100644 headers/gcg/clsvar_scipvartypes.h delete mode 100644 headers/gcg/colpool.h delete mode 100644 headers/gcg/cons_decomp.h delete mode 100644 headers/gcg/cons_decomp.hpp delete mode 100644 headers/gcg/cons_integralorig.h delete mode 100644 headers/gcg/cons_masterbranch.h delete mode 100644 headers/gcg/cons_origbranch.h delete mode 100644 headers/gcg/dec_compgreedily.h delete mode 100644 headers/gcg/dec_connected_noNewLinkingVars.h delete mode 100644 headers/gcg/dec_connectedbase.h delete mode 100644 headers/gcg/dec_consclass.h delete mode 100644 headers/gcg/dec_constype.h delete mode 100644 headers/gcg/dec_dbscan.h delete mode 100644 headers/gcg/dec_densemasterconss.h delete mode 100644 headers/gcg/dec_generalmastersetcover.h delete mode 100644 headers/gcg/dec_generalmastersetpack.h delete mode 100644 headers/gcg/dec_generalmastersetpart.h delete mode 100644 headers/gcg/dec_hcgpartition.h delete mode 100644 headers/gcg/dec_hrcgpartition.h delete mode 100644 headers/gcg/dec_hrgpartition.h delete mode 100644 headers/gcg/dec_isomorph.h delete mode 100644 headers/gcg/dec_mastersetcover.h delete mode 100644 headers/gcg/dec_mastersetpack.h delete mode 100644 headers/gcg/dec_mastersetpart.h delete mode 100644 headers/gcg/dec_mst.h delete mode 100644 headers/gcg/dec_neighborhoodmaster.h delete mode 100644 headers/gcg/dec_postprocess.h delete mode 100644 headers/gcg/dec_staircase_lsp.h delete mode 100644 headers/gcg/dec_stairheur.h delete mode 100644 headers/gcg/dec_varclass.h delete mode 100644 headers/gcg/decomp.h delete mode 100644 headers/gcg/def.h delete mode 100644 headers/gcg/dialog_gcg.h delete mode 100644 headers/gcg/dialog_graph.h delete mode 100644 headers/gcg/dialog_master.h delete mode 100644 headers/gcg/disp_gcg.h delete mode 100644 headers/gcg/disp_master.h delete mode 100644 headers/gcg/event_bestsol.h delete mode 100644 headers/gcg/event_display.h delete mode 100644 headers/gcg/event_mastersol.h delete mode 100644 headers/gcg/event_relaxsol.h delete mode 100644 headers/gcg/event_solvingstats.h delete mode 100644 headers/gcg/gcg.h delete mode 100644 headers/gcg/gcg_general.h delete mode 100644 headers/gcg/gcgcol.h delete mode 100644 headers/gcg/gcggithash.h delete mode 100644 headers/gcg/gcgplugins.h delete mode 100644 headers/gcg/gcgpqueue.h delete mode 100644 headers/gcg/gcgsort.h delete mode 100644 headers/gcg/graph/bipartitegraph.h delete mode 100644 headers/gcg/graph/bipartitegraph_def.h delete mode 100644 headers/gcg/graph/bridge.h delete mode 100644 headers/gcg/graph/columngraph.h delete mode 100644 headers/gcg/graph/columngraph_def.h delete mode 100644 headers/gcg/graph/graph.h delete mode 100644 headers/gcg/graph/graph_def.h delete mode 100644 headers/gcg/graph/graph_gcg.h delete mode 100644 headers/gcg/graph/graph_interface.h delete mode 100644 headers/gcg/graph/graph_tclique.h delete mode 100644 headers/gcg/graph/graphalgorithms.h delete mode 100644 headers/gcg/graph/graphalgorithms_def.h delete mode 100644 headers/gcg/graph/hypercolgraph.h delete mode 100644 headers/gcg/graph/hypercolgraph_def.h delete mode 100644 headers/gcg/graph/hypergraph.h delete mode 100644 headers/gcg/graph/hypergraph_def.h delete mode 100644 headers/gcg/graph/hyperrowcolgraph.h delete mode 100644 headers/gcg/graph/hyperrowcolgraph_def.h delete mode 100644 headers/gcg/graph/hyperrowgraph.h delete mode 100644 headers/gcg/graph/hyperrowgraph_def.h delete mode 100644 headers/gcg/graph/matrixgraph.h delete mode 100644 headers/gcg/graph/matrixgraph_def.h delete mode 100644 headers/gcg/graph/rowgraph.h delete mode 100644 headers/gcg/graph/rowgraph_def.h delete mode 100644 headers/gcg/graph/weights.h delete mode 100644 headers/gcg/heur_gcgcoefdiving.h delete mode 100644 headers/gcg/heur_gcgdins.h delete mode 100644 headers/gcg/heur_gcgfeaspump.h delete mode 100644 headers/gcg/heur_gcgfracdiving.h delete mode 100644 headers/gcg/heur_gcgguideddiving.h delete mode 100644 headers/gcg/heur_gcglinesdiving.h delete mode 100644 headers/gcg/heur_gcgpscostdiving.h delete mode 100644 headers/gcg/heur_gcgrens.h delete mode 100644 headers/gcg/heur_gcgrins.h delete mode 100644 headers/gcg/heur_gcgrounding.h delete mode 100644 headers/gcg/heur_gcgshifting.h delete mode 100644 headers/gcg/heur_gcgsimplerounding.h delete mode 100644 headers/gcg/heur_gcgveclendiving.h delete mode 100644 headers/gcg/heur_gcgzirounding.h delete mode 100644 headers/gcg/heur_greedycolsel.h delete mode 100644 headers/gcg/heur_mastercoefdiving.h delete mode 100644 headers/gcg/heur_masterdiving.h delete mode 100644 headers/gcg/heur_masterfracdiving.h delete mode 100644 headers/gcg/heur_masterlinesdiving.h delete mode 100644 headers/gcg/heur_mastervecldiving.h delete mode 100644 headers/gcg/heur_origdiving.h delete mode 100644 headers/gcg/heur_relaxcolsel.h delete mode 100644 headers/gcg/heur_restmaster.h delete mode 100644 headers/gcg/heur_setcover.h delete mode 100644 headers/gcg/heur_xpcrossover.h delete mode 100644 headers/gcg/heur_xprins.h delete mode 100644 headers/gcg/masterplugins.h delete mode 100644 headers/gcg/miscvisualization.h delete mode 100644 headers/gcg/nodesel_master.h delete mode 100644 headers/gcg/objdialog.h delete mode 100644 headers/gcg/objpricer_gcg.h delete mode 100644 headers/gcg/params_visu.h delete mode 100644 headers/gcg/presol_roundbound.h delete mode 100644 headers/gcg/pricer_gcg.h delete mode 100644 headers/gcg/pricestore_gcg.h delete mode 100644 headers/gcg/pricingjob.h delete mode 100644 headers/gcg/pricingprob.h delete mode 100644 headers/gcg/pub_bliss.h delete mode 100644 headers/gcg/pub_colpool.h delete mode 100644 headers/gcg/pub_decomp.h delete mode 100644 headers/gcg/pub_gcgcol.h delete mode 100644 headers/gcg/pub_gcgheur.h delete mode 100644 headers/gcg/pub_gcgpqueue.h delete mode 100644 headers/gcg/pub_gcgsepa.h delete mode 100644 headers/gcg/pub_gcgvar.h delete mode 100644 headers/gcg/pub_pricingjob.h delete mode 100644 headers/gcg/pub_pricingprob.h delete mode 100644 headers/gcg/pub_solver.h delete mode 100644 headers/gcg/reader_blk.h delete mode 100644 headers/gcg/reader_cls.h delete mode 100644 headers/gcg/reader_dec.h delete mode 100644 headers/gcg/reader_gp.h delete mode 100644 headers/gcg/reader_ref.h delete mode 100644 headers/gcg/reader_tex.h delete mode 100644 headers/gcg/relax_gcg.h delete mode 100644 headers/gcg/scip_misc.h delete mode 100644 headers/gcg/scoretype.h delete mode 100644 headers/gcg/sepa_basis.h delete mode 100644 headers/gcg/sepa_master.h delete mode 100644 headers/gcg/solver.h delete mode 100644 headers/gcg/solver_cliquer.h delete mode 100644 headers/gcg/solver_knapsack.h delete mode 100644 headers/gcg/solver_mip.h delete mode 100644 headers/gcg/solver_xyz.h delete mode 100644 headers/gcg/stat.h delete mode 100644 headers/gcg/struct_branchgcg.h delete mode 100644 headers/gcg/struct_colpool.h delete mode 100644 headers/gcg/struct_decomp.h delete mode 100644 headers/gcg/struct_detector.h delete mode 100644 headers/gcg/struct_gcgcol.h delete mode 100644 headers/gcg/struct_gcgpqueue.h delete mode 100644 headers/gcg/struct_pricestore_gcg.h delete mode 100644 headers/gcg/struct_pricingjob.h delete mode 100644 headers/gcg/struct_pricingprob.h delete mode 100644 headers/gcg/struct_solver.h delete mode 100644 headers/gcg/struct_vardata.h delete mode 100644 headers/gcg/type_branchgcg.h delete mode 100644 headers/gcg/type_classifier.h delete mode 100644 headers/gcg/type_colpool.h delete mode 100644 headers/gcg/type_consclassifier.h delete mode 100644 headers/gcg/type_decomp.h delete mode 100644 headers/gcg/type_detector.h delete mode 100644 headers/gcg/type_gcgcol.h delete mode 100644 headers/gcg/type_gcgpqueue.h delete mode 100644 headers/gcg/type_masterdiving.h delete mode 100644 headers/gcg/type_origdiving.h delete mode 100644 headers/gcg/type_parameter.h delete mode 100644 headers/gcg/type_pricestore_gcg.h delete mode 100644 headers/gcg/type_pricingjob.h delete mode 100644 headers/gcg/type_pricingprob.h delete mode 100644 headers/gcg/type_pricingstatus.h delete mode 100644 headers/gcg/type_scoretype.h delete mode 100644 headers/gcg/type_solver.h delete mode 100644 headers/gcg/type_varclassifier.h delete mode 100644 headers/gcg/wrapper_partialdecomp.h delete mode 100644 headers/lpi/lpi.h delete mode 100644 headers/lpi/type_lpi.h delete mode 100644 headers/objscip/objbenders.h delete mode 100644 headers/objscip/objbenderscut.h delete mode 100644 headers/objscip/objbranchrule.h delete mode 100644 headers/objscip/objcloneable.h delete mode 100644 headers/objscip/objconshdlr.h delete mode 100644 headers/objscip/objcutsel.h delete mode 100644 headers/objscip/objdialog.h delete mode 100644 headers/objscip/objdisp.h delete mode 100644 headers/objscip/objeventhdlr.h delete mode 100644 headers/objscip/objheur.h delete mode 100644 headers/objscip/objmessagehdlr.h delete mode 100644 headers/objscip/objnodesel.h delete mode 100644 headers/objscip/objpresol.h delete mode 100644 headers/objscip/objpricer.h delete mode 100644 headers/objscip/objprobcloneable.h delete mode 100644 headers/objscip/objprobdata.h delete mode 100644 headers/objscip/objprop.h delete mode 100644 headers/objscip/objreader.h delete mode 100644 headers/objscip/objrelax.h delete mode 100644 headers/objscip/objscip.h delete mode 100644 headers/objscip/objscipdefplugins.h delete mode 100644 headers/objscip/objsepa.h delete mode 100644 headers/objscip/objtable.h delete mode 100644 headers/objscip/objvardata.h delete mode 100644 headers/objscip/type_objcloneable.h delete mode 100644 headers/objscip/type_objprobcloneable.h delete mode 100644 headers/papilo/CMakeConfig.hpp delete mode 100644 headers/papilo/Config.hpp delete mode 100644 headers/papilo/core/Components.hpp delete mode 100644 headers/papilo/core/ConstraintMatrix.hpp delete mode 100644 headers/papilo/core/MatrixBuffer.hpp delete mode 100644 headers/papilo/core/Objective.hpp delete mode 100644 headers/papilo/core/Presolve.hpp delete mode 100644 headers/papilo/core/PresolveMethod.hpp delete mode 100644 headers/papilo/core/PresolveOptions.hpp delete mode 100644 headers/papilo/core/ProbingView.hpp delete mode 100644 headers/papilo/core/Problem.hpp delete mode 100644 headers/papilo/core/ProblemBuilder.hpp delete mode 100644 headers/papilo/core/ProblemUpdate.hpp delete mode 100644 headers/papilo/core/Reductions.hpp delete mode 100644 headers/papilo/core/RowFlags.hpp delete mode 100644 headers/papilo/core/SingleRow.hpp delete mode 100644 headers/papilo/core/Solution.hpp delete mode 100644 headers/papilo/core/SparseStorage.hpp delete mode 100644 headers/papilo/core/Statistics.hpp delete mode 100644 headers/papilo/core/VariableDomains.hpp delete mode 100644 headers/papilo/core/postsolve/BoundStorage.hpp delete mode 100644 headers/papilo/core/postsolve/Postsolve.hpp delete mode 100644 headers/papilo/core/postsolve/PostsolveStatus.hpp delete mode 100644 headers/papilo/core/postsolve/PostsolveStorage.hpp delete mode 100644 headers/papilo/core/postsolve/PostsolveType.hpp delete mode 100644 headers/papilo/core/postsolve/ReductionType.hpp delete mode 100644 headers/papilo/core/postsolve/SavedRow.hpp delete mode 100644 headers/papilo/external/fmt/chrono.h delete mode 100644 headers/papilo/external/fmt/color.h delete mode 100644 headers/papilo/external/fmt/compile.h delete mode 100644 headers/papilo/external/fmt/core.h delete mode 100644 headers/papilo/external/fmt/format-inl.h delete mode 100644 headers/papilo/external/fmt/format.cc delete mode 100644 headers/papilo/external/fmt/format.h delete mode 100644 headers/papilo/external/fmt/locale.h delete mode 100644 headers/papilo/external/fmt/ostream.h delete mode 100644 headers/papilo/external/fmt/posix.cc delete mode 100644 headers/papilo/external/fmt/posix.h delete mode 100644 headers/papilo/external/fmt/printf.h delete mode 100644 headers/papilo/external/fmt/ranges.h delete mode 100644 headers/papilo/external/lusol/clusol.h delete mode 100644 headers/papilo/external/pdqsort/pdqsort.h delete mode 100644 headers/papilo/external/ska/bytell_hash_map.hpp delete mode 100644 headers/papilo/external/ska/flat_hash_map.hpp delete mode 100644 headers/papilo/external/ska/unordered_map.hpp delete mode 100644 headers/papilo/interfaces/GlopInterface.hpp delete mode 100644 headers/papilo/interfaces/GurobiInterface.hpp delete mode 100644 headers/papilo/interfaces/HighsInterface.hpp delete mode 100644 headers/papilo/interfaces/ScipInterface.hpp delete mode 100644 headers/papilo/interfaces/SolverInterface.hpp delete mode 100644 headers/papilo/interfaces/SoplexInterface.hpp delete mode 100644 headers/papilo/io/Message.hpp delete mode 100644 headers/papilo/io/MpsParser.hpp delete mode 100644 headers/papilo/io/MpsWriter.hpp delete mode 100644 headers/papilo/io/SolParser.hpp delete mode 100644 headers/papilo/io/SolWriter.hpp delete mode 100644 headers/papilo/misc/Alloc.hpp delete mode 100644 headers/papilo/misc/Array.hpp delete mode 100644 headers/papilo/misc/DependentRows.hpp delete mode 100644 headers/papilo/misc/Flags.hpp delete mode 100644 headers/papilo/misc/Hash.hpp delete mode 100644 headers/papilo/misc/MultiPrecision.hpp delete mode 100644 headers/papilo/misc/Num.hpp delete mode 100644 headers/papilo/misc/NumericalStatistics.hpp delete mode 100644 headers/papilo/misc/OptionsParser.hpp delete mode 100644 headers/papilo/misc/ParameterSet.hpp delete mode 100644 headers/papilo/misc/PrimalDualSolValidation.hpp delete mode 100644 headers/papilo/misc/Signature.hpp delete mode 100644 headers/papilo/misc/StableSum.hpp delete mode 100644 headers/papilo/misc/String.hpp delete mode 100644 headers/papilo/misc/Timer.hpp delete mode 100644 headers/papilo/misc/Validation.hpp delete mode 100644 headers/papilo/misc/Vec.hpp delete mode 100644 headers/papilo/misc/VectorUtils.hpp delete mode 100644 headers/papilo/misc/VersionLogger.hpp delete mode 100644 headers/papilo/misc/Wrappers.hpp delete mode 100644 headers/papilo/misc/compress_vector.hpp delete mode 100644 headers/papilo/misc/fmt.hpp delete mode 100644 headers/papilo/misc/tbb.hpp delete mode 100644 headers/papilo/presolvers/CoefficientStrengthening.hpp delete mode 100644 headers/papilo/presolvers/ConstraintPropagation.hpp delete mode 100644 headers/papilo/presolvers/DominatedCols.hpp delete mode 100644 headers/papilo/presolvers/DualFix.hpp delete mode 100644 headers/papilo/presolvers/DualInfer.hpp delete mode 100644 headers/papilo/presolvers/FixContinuous.hpp delete mode 100644 headers/papilo/presolvers/FreeVarSubstitution.hpp delete mode 100644 headers/papilo/presolvers/ImplIntDetection.hpp delete mode 100644 headers/papilo/presolvers/ParallelColDetection.hpp delete mode 100644 headers/papilo/presolvers/ParallelRowDetection.hpp delete mode 100644 headers/papilo/presolvers/Probing.hpp delete mode 100644 headers/papilo/presolvers/SimpleProbing.hpp delete mode 100644 headers/papilo/presolvers/SimpleSubstitution.hpp delete mode 100644 headers/papilo/presolvers/SimplifyInequalities.hpp delete mode 100644 headers/papilo/presolvers/SingletonCols.hpp delete mode 100644 headers/papilo/presolvers/SingletonStuffing.hpp delete mode 100644 headers/papilo/presolvers/Sparsify.hpp delete mode 100644 headers/scip/bandit.h delete mode 100644 headers/scip/bandit_epsgreedy.h delete mode 100644 headers/scip/bandit_exp3.h delete mode 100644 headers/scip/bandit_ucb.h delete mode 100644 headers/scip/benders.h delete mode 100644 headers/scip/benders_default.h delete mode 100644 headers/scip/benderscut.h delete mode 100644 headers/scip/benderscut_feas.h delete mode 100644 headers/scip/benderscut_feasalt.h delete mode 100644 headers/scip/benderscut_int.h delete mode 100644 headers/scip/benderscut_nogood.h delete mode 100644 headers/scip/benderscut_opt.h delete mode 100644 headers/scip/bendersdefcuts.h delete mode 100644 headers/scip/bitencode.h delete mode 100644 headers/scip/boundstore.h delete mode 100644 headers/scip/branch.h delete mode 100644 headers/scip/branch_allfullstrong.h delete mode 100644 headers/scip/branch_cloud.h delete mode 100644 headers/scip/branch_distribution.h delete mode 100644 headers/scip/branch_fullstrong.h delete mode 100644 headers/scip/branch_inference.h delete mode 100644 headers/scip/branch_leastinf.h delete mode 100644 headers/scip/branch_lookahead.h delete mode 100644 headers/scip/branch_mostinf.h delete mode 100644 headers/scip/branch_multaggr.h delete mode 100644 headers/scip/branch_nodereopt.h delete mode 100644 headers/scip/branch_pscost.h delete mode 100644 headers/scip/branch_random.h delete mode 100644 headers/scip/branch_relpscost.h delete mode 100644 headers/scip/branch_vanillafullstrong.h delete mode 100644 headers/scip/clock.h delete mode 100644 headers/scip/compr.h delete mode 100644 headers/scip/compr_largestrepr.h delete mode 100644 headers/scip/compr_weakcompr.h delete mode 100644 headers/scip/concsolver.h delete mode 100644 headers/scip/concsolver_scip.h delete mode 100644 headers/scip/concurrent.h delete mode 100644 headers/scip/config.h delete mode 100644 headers/scip/conflict.h delete mode 100644 headers/scip/conflictstore.h delete mode 100644 headers/scip/cons.h delete mode 100644 headers/scip/cons_abspower.h delete mode 100644 headers/scip/cons_and.h delete mode 100644 headers/scip/cons_benders.h delete mode 100644 headers/scip/cons_benderslp.h delete mode 100644 headers/scip/cons_bounddisjunction.h delete mode 100644 headers/scip/cons_cardinality.h delete mode 100644 headers/scip/cons_components.h delete mode 100644 headers/scip/cons_conjunction.h delete mode 100644 headers/scip/cons_countsols.h delete mode 100644 headers/scip/cons_cumulative.h delete mode 100644 headers/scip/cons_disjunction.h delete mode 100644 headers/scip/cons_indicator.h delete mode 100644 headers/scip/cons_integral.h delete mode 100644 headers/scip/cons_knapsack.h delete mode 100644 headers/scip/cons_linear.h delete mode 100644 headers/scip/cons_linking.h delete mode 100644 headers/scip/cons_logicor.h delete mode 100644 headers/scip/cons_nonlinear.h delete mode 100644 headers/scip/cons_or.h delete mode 100644 headers/scip/cons_orbisack.h delete mode 100644 headers/scip/cons_orbitope.h delete mode 100644 headers/scip/cons_pseudoboolean.h delete mode 100644 headers/scip/cons_quadratic.h delete mode 100644 headers/scip/cons_setppc.h delete mode 100644 headers/scip/cons_soc.h delete mode 100644 headers/scip/cons_sos1.h delete mode 100644 headers/scip/cons_sos2.h delete mode 100644 headers/scip/cons_superindicator.h delete mode 100644 headers/scip/cons_symresack.h delete mode 100644 headers/scip/cons_varbound.h delete mode 100644 headers/scip/cons_xor.h delete mode 100644 headers/scip/cutpool.h delete mode 100644 headers/scip/cuts.h delete mode 100644 headers/scip/cutsel.h delete mode 100644 headers/scip/cutsel_hybrid.h delete mode 100644 headers/scip/dbldblarith.h delete mode 100644 headers/scip/dcmp.h delete mode 100644 headers/scip/debug.h delete mode 100644 headers/scip/def.h delete mode 100644 headers/scip/dialog.h delete mode 100644 headers/scip/dialog_default.h delete mode 100644 headers/scip/disp.h delete mode 100644 headers/scip/disp_default.h delete mode 100644 headers/scip/event.h delete mode 100644 headers/scip/event_estim.h delete mode 100644 headers/scip/event_globalbnd.h delete mode 100644 headers/scip/event_softtimelimit.h delete mode 100644 headers/scip/event_solvingphase.h delete mode 100644 headers/scip/expr.h delete mode 100644 headers/scip/expr_abs.h delete mode 100644 headers/scip/expr_entropy.h delete mode 100644 headers/scip/expr_erf.h delete mode 100644 headers/scip/expr_exp.h delete mode 100644 headers/scip/expr_log.h delete mode 100644 headers/scip/expr_pow.h delete mode 100644 headers/scip/expr_product.h delete mode 100644 headers/scip/expr_sum.h delete mode 100644 headers/scip/expr_trig.h delete mode 100644 headers/scip/expr_value.h delete mode 100644 headers/scip/expr_var.h delete mode 100644 headers/scip/expr_varidx.h delete mode 100644 headers/scip/exprinterpret.h delete mode 100644 headers/scip/heur.h delete mode 100644 headers/scip/heur_actconsdiving.h delete mode 100644 headers/scip/heur_adaptivediving.h delete mode 100644 headers/scip/heur_alns.h delete mode 100644 headers/scip/heur_bound.h delete mode 100644 headers/scip/heur_clique.h delete mode 100644 headers/scip/heur_coefdiving.h delete mode 100644 headers/scip/heur_completesol.h delete mode 100644 headers/scip/heur_conflictdiving.h delete mode 100644 headers/scip/heur_crossover.h delete mode 100644 headers/scip/heur_dins.h delete mode 100644 headers/scip/heur_distributiondiving.h delete mode 100644 headers/scip/heur_dps.h delete mode 100644 headers/scip/heur_dualval.h delete mode 100644 headers/scip/heur_farkasdiving.h delete mode 100644 headers/scip/heur_feaspump.h delete mode 100644 headers/scip/heur_fixandinfer.h delete mode 100644 headers/scip/heur_fracdiving.h delete mode 100644 headers/scip/heur_gins.h delete mode 100644 headers/scip/heur_guideddiving.h delete mode 100644 headers/scip/heur_indicator.h delete mode 100644 headers/scip/heur_intdiving.h delete mode 100644 headers/scip/heur_intshifting.h delete mode 100644 headers/scip/heur_linesearchdiving.h delete mode 100644 headers/scip/heur_localbranching.h delete mode 100644 headers/scip/heur_locks.h delete mode 100644 headers/scip/heur_lpface.h delete mode 100644 headers/scip/heur_mpec.h delete mode 100644 headers/scip/heur_multistart.h delete mode 100644 headers/scip/heur_mutation.h delete mode 100644 headers/scip/heur_nlpdiving.h delete mode 100644 headers/scip/heur_objpscostdiving.h delete mode 100644 headers/scip/heur_octane.h delete mode 100644 headers/scip/heur_ofins.h delete mode 100644 headers/scip/heur_oneopt.h delete mode 100644 headers/scip/heur_padm.h delete mode 100644 headers/scip/heur_proximity.h delete mode 100644 headers/scip/heur_pscostdiving.h delete mode 100644 headers/scip/heur_randrounding.h delete mode 100644 headers/scip/heur_rens.h delete mode 100644 headers/scip/heur_reoptsols.h delete mode 100644 headers/scip/heur_repair.h delete mode 100644 headers/scip/heur_rins.h delete mode 100644 headers/scip/heur_rootsoldiving.h delete mode 100644 headers/scip/heur_rounding.h delete mode 100644 headers/scip/heur_shiftandpropagate.h delete mode 100644 headers/scip/heur_shifting.h delete mode 100644 headers/scip/heur_simplerounding.h delete mode 100644 headers/scip/heur_subnlp.h delete mode 100644 headers/scip/heur_sync.h delete mode 100644 headers/scip/heur_trivial.h delete mode 100644 headers/scip/heur_trivialnegation.h delete mode 100644 headers/scip/heur_trustregion.h delete mode 100644 headers/scip/heur_trysol.h delete mode 100644 headers/scip/heur_twoopt.h delete mode 100644 headers/scip/heur_undercover.h delete mode 100644 headers/scip/heur_vbounds.h delete mode 100644 headers/scip/heur_veclendiving.h delete mode 100644 headers/scip/heur_zeroobj.h delete mode 100644 headers/scip/heur_zirounding.h delete mode 100644 headers/scip/heuristics.h delete mode 100644 headers/scip/history.h delete mode 100644 headers/scip/implics.h delete mode 100644 headers/scip/interrupt.h delete mode 100644 headers/scip/intervalarith.h delete mode 100644 headers/scip/lp.h delete mode 100644 headers/scip/mem.h delete mode 100644 headers/scip/message.h delete mode 100644 headers/scip/message_default.h delete mode 100644 headers/scip/misc.h delete mode 100644 headers/scip/nlhdlr.h delete mode 100644 headers/scip/nlhdlr_bilinear.h delete mode 100644 headers/scip/nlhdlr_convex.h delete mode 100644 headers/scip/nlhdlr_default.h delete mode 100644 headers/scip/nlhdlr_perspective.h delete mode 100644 headers/scip/nlhdlr_quadratic.h delete mode 100644 headers/scip/nlhdlr_quotient.h delete mode 100644 headers/scip/nlhdlr_soc.h delete mode 100644 headers/scip/nlp.h delete mode 100644 headers/scip/nlpi.h delete mode 100644 headers/scip/nlpi_all.h delete mode 100644 headers/scip/nlpi_filtersqp.h delete mode 100644 headers/scip/nlpi_ipopt.h delete mode 100644 headers/scip/nlpi_worhp.h delete mode 100644 headers/scip/nlpioracle.h delete mode 100644 headers/scip/nodesel.h delete mode 100644 headers/scip/nodesel_bfs.h delete mode 100644 headers/scip/nodesel_breadthfirst.h delete mode 100644 headers/scip/nodesel_dfs.h delete mode 100644 headers/scip/nodesel_estimate.h delete mode 100644 headers/scip/nodesel_hybridestim.h delete mode 100644 headers/scip/nodesel_restartdfs.h delete mode 100644 headers/scip/nodesel_uct.h delete mode 100644 headers/scip/paramset.h delete mode 100644 headers/scip/presol.h delete mode 100644 headers/scip/presol_boundshift.h delete mode 100644 headers/scip/presol_convertinttobin.h delete mode 100644 headers/scip/presol_domcol.h delete mode 100644 headers/scip/presol_dualagg.h delete mode 100644 headers/scip/presol_dualcomp.h delete mode 100644 headers/scip/presol_dualinfer.h delete mode 100644 headers/scip/presol_dualsparsify.h delete mode 100644 headers/scip/presol_gateextraction.h delete mode 100644 headers/scip/presol_implics.h delete mode 100644 headers/scip/presol_inttobinary.h delete mode 100644 headers/scip/presol_milp.h delete mode 100644 headers/scip/presol_qpkktref.h delete mode 100644 headers/scip/presol_redvub.h delete mode 100644 headers/scip/presol_sparsify.h delete mode 100644 headers/scip/presol_stuffing.h delete mode 100644 headers/scip/presol_trivial.h delete mode 100644 headers/scip/presol_tworowbnd.h delete mode 100644 headers/scip/presolve.h delete mode 100644 headers/scip/pricer.h delete mode 100644 headers/scip/pricestore.h delete mode 100644 headers/scip/primal.h delete mode 100644 headers/scip/prob.h delete mode 100644 headers/scip/prop.h delete mode 100644 headers/scip/prop_dualfix.h delete mode 100644 headers/scip/prop_genvbounds.h delete mode 100644 headers/scip/prop_nlobbt.h delete mode 100644 headers/scip/prop_obbt.h delete mode 100644 headers/scip/prop_probing.h delete mode 100644 headers/scip/prop_pseudoobj.h delete mode 100644 headers/scip/prop_redcost.h delete mode 100644 headers/scip/prop_rootredcost.h delete mode 100644 headers/scip/prop_symmetry.h delete mode 100644 headers/scip/prop_sync.h delete mode 100644 headers/scip/prop_vbounds.h delete mode 100644 headers/scip/pub_bandit.h delete mode 100644 headers/scip/pub_bandit_epsgreedy.h delete mode 100644 headers/scip/pub_bandit_exp3.h delete mode 100644 headers/scip/pub_bandit_ucb.h delete mode 100644 headers/scip/pub_benders.h delete mode 100644 headers/scip/pub_benderscut.h delete mode 100644 headers/scip/pub_branch.h delete mode 100644 headers/scip/pub_compr.h delete mode 100644 headers/scip/pub_conflict.h delete mode 100644 headers/scip/pub_cons.h delete mode 100644 headers/scip/pub_cutpool.h delete mode 100644 headers/scip/pub_cutsel.h delete mode 100644 headers/scip/pub_dcmp.h delete mode 100644 headers/scip/pub_dialog.h delete mode 100644 headers/scip/pub_disp.h delete mode 100644 headers/scip/pub_event.h delete mode 100644 headers/scip/pub_expr.h delete mode 100644 headers/scip/pub_fileio.h delete mode 100644 headers/scip/pub_heur.h delete mode 100644 headers/scip/pub_history.h delete mode 100644 headers/scip/pub_implics.h delete mode 100644 headers/scip/pub_lp.h delete mode 100644 headers/scip/pub_matrix.h delete mode 100644 headers/scip/pub_message.h delete mode 100644 headers/scip/pub_misc.h delete mode 100644 headers/scip/pub_misc_linear.h delete mode 100644 headers/scip/pub_misc_rowprep.h delete mode 100644 headers/scip/pub_misc_select.h delete mode 100644 headers/scip/pub_misc_sort.h delete mode 100644 headers/scip/pub_nlhdlr.h delete mode 100644 headers/scip/pub_nlp.h delete mode 100644 headers/scip/pub_nlpi.h delete mode 100644 headers/scip/pub_nodesel.h delete mode 100644 headers/scip/pub_paramset.h delete mode 100644 headers/scip/pub_presol.h delete mode 100644 headers/scip/pub_pricer.h delete mode 100644 headers/scip/pub_prop.h delete mode 100644 headers/scip/pub_reader.h delete mode 100644 headers/scip/pub_relax.h delete mode 100644 headers/scip/pub_reopt.h delete mode 100644 headers/scip/pub_sepa.h delete mode 100644 headers/scip/pub_sol.h delete mode 100644 headers/scip/pub_table.h delete mode 100644 headers/scip/pub_tree.h delete mode 100644 headers/scip/pub_var.h delete mode 100644 headers/scip/rbtree.h delete mode 100644 headers/scip/reader.h delete mode 100644 headers/scip/reader_bnd.h delete mode 100644 headers/scip/reader_ccg.h delete mode 100644 headers/scip/reader_cip.h delete mode 100644 headers/scip/reader_cnf.h delete mode 100644 headers/scip/reader_cor.h delete mode 100644 headers/scip/reader_dec.h delete mode 100644 headers/scip/reader_diff.h delete mode 100644 headers/scip/reader_fix.h delete mode 100644 headers/scip/reader_fzn.h delete mode 100644 headers/scip/reader_gms.h delete mode 100644 headers/scip/reader_lp.h delete mode 100644 headers/scip/reader_mps.h delete mode 100644 headers/scip/reader_mst.h delete mode 100644 headers/scip/reader_nl.h delete mode 100644 headers/scip/reader_opb.h delete mode 100644 headers/scip/reader_osil.h delete mode 100644 headers/scip/reader_pbm.h delete mode 100644 headers/scip/reader_pip.h delete mode 100644 headers/scip/reader_ppm.h delete mode 100644 headers/scip/reader_rlp.h delete mode 100644 headers/scip/reader_smps.h delete mode 100644 headers/scip/reader_sol.h delete mode 100644 headers/scip/reader_sto.h delete mode 100644 headers/scip/reader_tim.h delete mode 100644 headers/scip/reader_wbo.h delete mode 100644 headers/scip/reader_zpl.h delete mode 100644 headers/scip/relax.h delete mode 100644 headers/scip/reopt.h delete mode 100644 headers/scip/retcode.h delete mode 100644 headers/scip/scip.h delete mode 100644 headers/scip/scip_bandit.h delete mode 100644 headers/scip/scip_benders.h delete mode 100644 headers/scip/scip_branch.h delete mode 100644 headers/scip/scip_compr.h delete mode 100644 headers/scip/scip_concurrent.h delete mode 100644 headers/scip/scip_conflict.h delete mode 100644 headers/scip/scip_cons.h delete mode 100644 headers/scip/scip_copy.h delete mode 100644 headers/scip/scip_cut.h delete mode 100644 headers/scip/scip_cutsel.h delete mode 100644 headers/scip/scip_datastructures.h delete mode 100644 headers/scip/scip_dcmp.h delete mode 100644 headers/scip/scip_debug.h delete mode 100644 headers/scip/scip_dialog.h delete mode 100644 headers/scip/scip_disp.h delete mode 100644 headers/scip/scip_event.h delete mode 100644 headers/scip/scip_export.h delete mode 100644 headers/scip/scip_expr.h delete mode 100644 headers/scip/scip_general.h delete mode 100644 headers/scip/scip_heur.h delete mode 100644 headers/scip/scip_lp.h delete mode 100644 headers/scip/scip_mem.h delete mode 100644 headers/scip/scip_message.h delete mode 100644 headers/scip/scip_nlp.h delete mode 100644 headers/scip/scip_nlpi.h delete mode 100644 headers/scip/scip_nodesel.h delete mode 100644 headers/scip/scip_numerics.h delete mode 100644 headers/scip/scip_param.h delete mode 100644 headers/scip/scip_presol.h delete mode 100644 headers/scip/scip_pricer.h delete mode 100644 headers/scip/scip_prob.h delete mode 100644 headers/scip/scip_probing.h delete mode 100644 headers/scip/scip_prop.h delete mode 100644 headers/scip/scip_randnumgen.h delete mode 100644 headers/scip/scip_reader.h delete mode 100644 headers/scip/scip_relax.h delete mode 100644 headers/scip/scip_reopt.h delete mode 100644 headers/scip/scip_sepa.h delete mode 100644 headers/scip/scip_sol.h delete mode 100644 headers/scip/scip_solve.h delete mode 100644 headers/scip/scip_solvingstats.h delete mode 100644 headers/scip/scip_table.h delete mode 100644 headers/scip/scip_timing.h delete mode 100644 headers/scip/scip_tree.h delete mode 100644 headers/scip/scip_validation.h delete mode 100644 headers/scip/scip_var.h delete mode 100644 headers/scip/scipbuildflags.h delete mode 100644 headers/scip/scipcoreplugins.h delete mode 100644 headers/scip/scipdefplugins.h delete mode 100644 headers/scip/scipgithash.h delete mode 100644 headers/scip/scipshell.h delete mode 100644 headers/scip/sepa.h delete mode 100644 headers/scip/sepa_aggregation.h delete mode 100644 headers/scip/sepa_cgmip.h delete mode 100644 headers/scip/sepa_clique.h delete mode 100644 headers/scip/sepa_closecuts.h delete mode 100644 headers/scip/sepa_convexproj.h delete mode 100644 headers/scip/sepa_disjunctive.h delete mode 100644 headers/scip/sepa_eccuts.h delete mode 100644 headers/scip/sepa_gauge.h delete mode 100644 headers/scip/sepa_gomory.h delete mode 100644 headers/scip/sepa_impliedbounds.h delete mode 100644 headers/scip/sepa_interminor.h delete mode 100644 headers/scip/sepa_intobj.h delete mode 100644 headers/scip/sepa_mcf.h delete mode 100644 headers/scip/sepa_minor.h delete mode 100644 headers/scip/sepa_mixing.h delete mode 100644 headers/scip/sepa_oddcycle.h delete mode 100644 headers/scip/sepa_rapidlearning.h delete mode 100644 headers/scip/sepa_rlt.h delete mode 100644 headers/scip/sepa_zerohalf.h delete mode 100644 headers/scip/sepastore.h delete mode 100644 headers/scip/set.h delete mode 100644 headers/scip/sol.h delete mode 100644 headers/scip/solve.h delete mode 100644 headers/scip/stat.h delete mode 100644 headers/scip/struct_bandit.h delete mode 100644 headers/scip/struct_benders.h delete mode 100644 headers/scip/struct_benderscut.h delete mode 100644 headers/scip/struct_branch.h delete mode 100644 headers/scip/struct_clock.h delete mode 100644 headers/scip/struct_compr.h delete mode 100644 headers/scip/struct_concsolver.h delete mode 100644 headers/scip/struct_concurrent.h delete mode 100644 headers/scip/struct_conflict.h delete mode 100644 headers/scip/struct_conflictstore.h delete mode 100644 headers/scip/struct_cons.h delete mode 100644 headers/scip/struct_cutpool.h delete mode 100644 headers/scip/struct_cuts.h delete mode 100644 headers/scip/struct_cutsel.h delete mode 100644 headers/scip/struct_dcmp.h delete mode 100644 headers/scip/struct_dialog.h delete mode 100644 headers/scip/struct_disp.h delete mode 100644 headers/scip/struct_event.h delete mode 100644 headers/scip/struct_expr.h delete mode 100644 headers/scip/struct_heur.h delete mode 100644 headers/scip/struct_history.h delete mode 100644 headers/scip/struct_implics.h delete mode 100644 headers/scip/struct_lp.h delete mode 100644 headers/scip/struct_matrix.h delete mode 100644 headers/scip/struct_mem.h delete mode 100644 headers/scip/struct_message.h delete mode 100644 headers/scip/struct_misc.h delete mode 100644 headers/scip/struct_nlhdlr.h delete mode 100644 headers/scip/struct_nlp.h delete mode 100644 headers/scip/struct_nlpi.h delete mode 100644 headers/scip/struct_nodesel.h delete mode 100644 headers/scip/struct_paramset.h delete mode 100644 headers/scip/struct_presol.h delete mode 100644 headers/scip/struct_pricer.h delete mode 100644 headers/scip/struct_pricestore.h delete mode 100644 headers/scip/struct_primal.h delete mode 100644 headers/scip/struct_prob.h delete mode 100644 headers/scip/struct_prop.h delete mode 100644 headers/scip/struct_reader.h delete mode 100644 headers/scip/struct_relax.h delete mode 100644 headers/scip/struct_reopt.h delete mode 100644 headers/scip/struct_scip.h delete mode 100644 headers/scip/struct_sepa.h delete mode 100644 headers/scip/struct_sepastore.h delete mode 100644 headers/scip/struct_set.h delete mode 100644 headers/scip/struct_sol.h delete mode 100644 headers/scip/struct_stat.h delete mode 100644 headers/scip/struct_syncstore.h delete mode 100644 headers/scip/struct_table.h delete mode 100644 headers/scip/struct_tree.h delete mode 100644 headers/scip/struct_var.h delete mode 100644 headers/scip/struct_visual.h delete mode 100644 headers/scip/symmetry.h delete mode 100644 headers/scip/syncstore.h delete mode 100644 headers/scip/table.h delete mode 100644 headers/scip/table_default.h delete mode 100644 headers/scip/tree.h delete mode 100644 headers/scip/treemodel.h delete mode 100644 headers/scip/type_bandit.h delete mode 100644 headers/scip/type_benders.h delete mode 100644 headers/scip/type_benderscut.h delete mode 100644 headers/scip/type_branch.h delete mode 100644 headers/scip/type_clock.h delete mode 100644 headers/scip/type_compr.h delete mode 100644 headers/scip/type_concsolver.h delete mode 100644 headers/scip/type_concurrent.h delete mode 100644 headers/scip/type_conflict.h delete mode 100644 headers/scip/type_conflictstore.h delete mode 100644 headers/scip/type_cons.h delete mode 100644 headers/scip/type_cutpool.h delete mode 100644 headers/scip/type_cuts.h delete mode 100644 headers/scip/type_cutsel.h delete mode 100644 headers/scip/type_dcmp.h delete mode 100644 headers/scip/type_dialog.h delete mode 100644 headers/scip/type_disp.h delete mode 100644 headers/scip/type_event.h delete mode 100644 headers/scip/type_expr.h delete mode 100644 headers/scip/type_exprinterpret.h delete mode 100644 headers/scip/type_heur.h delete mode 100644 headers/scip/type_history.h delete mode 100644 headers/scip/type_implics.h delete mode 100644 headers/scip/type_interrupt.h delete mode 100644 headers/scip/type_lp.h delete mode 100644 headers/scip/type_matrix.h delete mode 100644 headers/scip/type_mem.h delete mode 100644 headers/scip/type_message.h delete mode 100644 headers/scip/type_misc.h delete mode 100644 headers/scip/type_nlhdlr.h delete mode 100644 headers/scip/type_nlp.h delete mode 100644 headers/scip/type_nlpi.h delete mode 100644 headers/scip/type_nodesel.h delete mode 100644 headers/scip/type_paramset.h delete mode 100644 headers/scip/type_presol.h delete mode 100644 headers/scip/type_pricer.h delete mode 100644 headers/scip/type_pricestore.h delete mode 100644 headers/scip/type_primal.h delete mode 100644 headers/scip/type_prob.h delete mode 100644 headers/scip/type_prop.h delete mode 100644 headers/scip/type_reader.h delete mode 100644 headers/scip/type_relax.h delete mode 100644 headers/scip/type_reopt.h delete mode 100644 headers/scip/type_result.h delete mode 100644 headers/scip/type_retcode.h delete mode 100644 headers/scip/type_scip.h delete mode 100644 headers/scip/type_sepa.h delete mode 100644 headers/scip/type_sepastore.h delete mode 100644 headers/scip/type_set.h delete mode 100644 headers/scip/type_sol.h delete mode 100644 headers/scip/type_stat.h delete mode 100644 headers/scip/type_syncstore.h delete mode 100644 headers/scip/type_table.h delete mode 100644 headers/scip/type_timing.h delete mode 100644 headers/scip/type_tree.h delete mode 100644 headers/scip/type_var.h delete mode 100644 headers/scip/type_visual.h delete mode 100644 headers/scip/var.h delete mode 100644 headers/scip/visual.h delete mode 100644 headers/soplex.h delete mode 100644 headers/soplex.hpp delete mode 100644 headers/soplex/array.h delete mode 100644 headers/soplex/basevectors.h delete mode 100644 headers/soplex/changesoplex.hpp delete mode 100644 headers/soplex/classarray.h delete mode 100644 headers/soplex/classset.h delete mode 100644 headers/soplex/clufactor.h delete mode 100644 headers/soplex/clufactor.hpp delete mode 100644 headers/soplex/clufactor_rational.h delete mode 100644 headers/soplex/clufactor_rational.hpp delete mode 100644 headers/soplex/config.h delete mode 100644 headers/soplex/cring.h delete mode 100644 headers/soplex/dataarray.h delete mode 100644 headers/soplex/datahashtable.h delete mode 100644 headers/soplex/datakey.h delete mode 100644 headers/soplex/dataset.h delete mode 100644 headers/soplex/didxset.h delete mode 100644 headers/soplex/dsvector.h delete mode 100644 headers/soplex/dsvectorbase.h delete mode 100644 headers/soplex/dvector.h delete mode 100644 headers/soplex/enter.hpp delete mode 100644 headers/soplex/exceptions.h delete mode 100644 headers/soplex/gzstream.h delete mode 100644 headers/soplex/idlist.h delete mode 100644 headers/soplex/idxset.h delete mode 100644 headers/soplex/islist.h delete mode 100644 headers/soplex/leave.hpp delete mode 100644 headers/soplex/lpcol.h delete mode 100644 headers/soplex/lpcolbase.h delete mode 100644 headers/soplex/lpcolset.h delete mode 100644 headers/soplex/lpcolsetbase.h delete mode 100644 headers/soplex/lprow.h delete mode 100644 headers/soplex/lprowbase.h delete mode 100644 headers/soplex/lprowset.h delete mode 100644 headers/soplex/lprowsetbase.h delete mode 100644 headers/soplex/mpsinput.h delete mode 100644 headers/soplex/nameset.h delete mode 100644 headers/soplex/notimer.h delete mode 100644 headers/soplex/random.h delete mode 100644 headers/soplex/rational.h delete mode 100644 headers/soplex/ratrecon.h delete mode 100644 headers/soplex/ratrecon.hpp delete mode 100644 headers/soplex/slinsolver.h delete mode 100644 headers/soplex/slinsolver_rational.h delete mode 100644 headers/soplex/slufactor.h delete mode 100644 headers/soplex/slufactor.hpp delete mode 100644 headers/soplex/slufactor_rational.h delete mode 100644 headers/soplex/slufactor_rational.hpp delete mode 100644 headers/soplex/sol.h delete mode 100644 headers/soplex/solbase.h delete mode 100644 headers/soplex/solvedbds.hpp delete mode 100644 headers/soplex/solverational.hpp delete mode 100644 headers/soplex/solvereal.hpp delete mode 100644 headers/soplex/sorter.h delete mode 100644 headers/soplex/spxalloc.h delete mode 100644 headers/soplex/spxautopr.h delete mode 100644 headers/soplex/spxautopr.hpp delete mode 100644 headers/soplex/spxbasis.h delete mode 100644 headers/soplex/spxbasis.hpp delete mode 100644 headers/soplex/spxboundflippingrt.h delete mode 100644 headers/soplex/spxboundflippingrt.hpp delete mode 100644 headers/soplex/spxbounds.hpp delete mode 100644 headers/soplex/spxchangebasis.hpp delete mode 100644 headers/soplex/spxdantzigpr.h delete mode 100644 headers/soplex/spxdantzigpr.hpp delete mode 100644 headers/soplex/spxdefaultrt.h delete mode 100644 headers/soplex/spxdefaultrt.hpp delete mode 100644 headers/soplex/spxdefines.h delete mode 100644 headers/soplex/spxdefines.hpp delete mode 100644 headers/soplex/spxdesc.hpp delete mode 100644 headers/soplex/spxdevexpr.h delete mode 100644 headers/soplex/spxdevexpr.hpp delete mode 100644 headers/soplex/spxequilisc.h delete mode 100644 headers/soplex/spxequilisc.hpp delete mode 100644 headers/soplex/spxfastrt.h delete mode 100644 headers/soplex/spxfastrt.hpp delete mode 100644 headers/soplex/spxfileio.h delete mode 100644 headers/soplex/spxfileio.hpp delete mode 100644 headers/soplex/spxgeometsc.h delete mode 100644 headers/soplex/spxgeometsc.hpp delete mode 100644 headers/soplex/spxgithash.h delete mode 100644 headers/soplex/spxharrisrt.h delete mode 100644 headers/soplex/spxharrisrt.hpp delete mode 100644 headers/soplex/spxhybridpr.h delete mode 100644 headers/soplex/spxhybridpr.hpp delete mode 100644 headers/soplex/spxid.h delete mode 100644 headers/soplex/spxleastsqsc.h delete mode 100644 headers/soplex/spxleastsqsc.hpp delete mode 100644 headers/soplex/spxlp.h delete mode 100644 headers/soplex/spxlpbase.h delete mode 100644 headers/soplex/spxlpbase_rational.hpp delete mode 100644 headers/soplex/spxlpbase_real.hpp delete mode 100644 headers/soplex/spxmainsm.h delete mode 100644 headers/soplex/spxmainsm.hpp delete mode 100644 headers/soplex/spxout.h delete mode 100644 headers/soplex/spxpapilo.h delete mode 100644 headers/soplex/spxparmultpr.h delete mode 100644 headers/soplex/spxparmultpr.hpp delete mode 100644 headers/soplex/spxpricer.h delete mode 100644 headers/soplex/spxquality.hpp delete mode 100644 headers/soplex/spxratiotester.h delete mode 100644 headers/soplex/spxscaler.h delete mode 100644 headers/soplex/spxscaler.hpp delete mode 100644 headers/soplex/spxshift.hpp delete mode 100644 headers/soplex/spxsimplifier.h delete mode 100644 headers/soplex/spxsolve.hpp delete mode 100644 headers/soplex/spxsolver.h delete mode 100644 headers/soplex/spxsolver.hpp delete mode 100644 headers/soplex/spxstarter.h delete mode 100644 headers/soplex/spxstarter.hpp delete mode 100644 headers/soplex/spxsteepexpr.h delete mode 100644 headers/soplex/spxsteeppr.h delete mode 100644 headers/soplex/spxsteeppr.hpp delete mode 100644 headers/soplex/spxsumst.h delete mode 100644 headers/soplex/spxsumst.hpp delete mode 100644 headers/soplex/spxvecs.hpp delete mode 100644 headers/soplex/spxvectorst.h delete mode 100644 headers/soplex/spxvectorst.hpp delete mode 100644 headers/soplex/spxweightpr.h delete mode 100644 headers/soplex/spxweightpr.hpp delete mode 100644 headers/soplex/spxweightst.h delete mode 100644 headers/soplex/spxweightst.hpp delete mode 100644 headers/soplex/spxwritestate.hpp delete mode 100644 headers/soplex/ssvector.h delete mode 100644 headers/soplex/ssvectorbase.h delete mode 100644 headers/soplex/stablesum.h delete mode 100644 headers/soplex/statistics.h delete mode 100644 headers/soplex/statistics.hpp delete mode 100644 headers/soplex/svector.h delete mode 100644 headers/soplex/svectorbase.h delete mode 100644 headers/soplex/svset.h delete mode 100644 headers/soplex/svsetbase.h delete mode 100644 headers/soplex/testsoplex.hpp delete mode 100644 headers/soplex/timer.h delete mode 100644 headers/soplex/timerfactory.h delete mode 100644 headers/soplex/unitvector.h delete mode 100644 headers/soplex/unitvectorbase.h delete mode 100644 headers/soplex/updatevector.h delete mode 100644 headers/soplex/updatevector.hpp delete mode 100644 headers/soplex/usertimer.h delete mode 100644 headers/soplex/validation.h delete mode 100644 headers/soplex/validation.hpp delete mode 100644 headers/soplex/vector.h delete mode 100644 headers/soplex/vectorbase.h delete mode 100644 headers/soplex/wallclocktimer.h delete mode 100644 headers/soplex_interface.h delete mode 100644 headers/symmetry/compute_symmetry.h delete mode 100644 headers/symmetry/type_symmetry.h delete mode 100644 headers/tclique/tclique.h delete mode 100644 headers/tclique/tclique_coloring.h delete mode 100644 headers/tclique/tclique_def.h delete mode 100644 headers/tinycthread/tinycthread.h delete mode 100644 headers/tpi/def_openmp.h delete mode 100644 headers/tpi/tpi.h delete mode 100644 headers/tpi/tpi_none.h delete mode 100644 headers/tpi/tpi_openmp.h delete mode 100644 headers/tpi/tpi_tnycthrd.h delete mode 100644 headers/tpi/type_tpi.h delete mode 100644 headers/tpi/type_tpi_none.h delete mode 100644 headers/tpi/type_tpi_openmp.h delete mode 100644 headers/tpi/type_tpi_tnycthrd.h delete mode 100644 headers/xml/xml.h delete mode 100644 headers/xml/xmldef.h delete mode 100644 headers/zimpl/attribute.h delete mode 100644 headers/zimpl/blkmem.h delete mode 100644 headers/zimpl/bound.h delete mode 100644 headers/zimpl/code.h delete mode 100644 headers/zimpl/conname.h delete mode 100644 headers/zimpl/define.h delete mode 100644 headers/zimpl/elem.h delete mode 100644 headers/zimpl/entry.h delete mode 100644 headers/zimpl/gmpmisc.h delete mode 100644 headers/zimpl/hash.h delete mode 100644 headers/zimpl/heap.h delete mode 100644 headers/zimpl/idxset.h delete mode 100644 headers/zimpl/inst.h delete mode 100644 headers/zimpl/lint.h delete mode 100644 headers/zimpl/list.h delete mode 100644 headers/zimpl/local.h delete mode 100644 headers/zimpl/metaio.h delete mode 100644 headers/zimpl/mme.h delete mode 100644 headers/zimpl/mmlparse2.h delete mode 100644 headers/zimpl/mono.h delete mode 100644 headers/zimpl/mshell.h delete mode 100644 headers/zimpl/numb.h delete mode 100644 headers/zimpl/prog.h delete mode 100644 headers/zimpl/random.h delete mode 100644 headers/zimpl/ratlp.h delete mode 100644 headers/zimpl/ratlpstore.h delete mode 100644 headers/zimpl/ratlptypes.h delete mode 100644 headers/zimpl/rdefpar.h delete mode 100644 headers/zimpl/set.h delete mode 100644 headers/zimpl/set4.h delete mode 100644 headers/zimpl/stkchk.h delete mode 100644 headers/zimpl/stmt.h delete mode 100644 headers/zimpl/strstore.h delete mode 100644 headers/zimpl/symbol.h delete mode 100644 headers/zimpl/term.h delete mode 100644 headers/zimpl/tuple.h delete mode 100644 headers/zimpl/xlpglue.h delete mode 100644 headers/zimpl/zimpllib.h delete mode 100644 headers/zimpl/zlpglue.h diff --git a/.github/workflows/build_and_test.yml b/.github/workflows/build_and_test.yml index a0d5595..d0a8e7e 100644 --- a/.github/workflows/build_and_test.yml +++ b/.github/workflows/build_and_test.yml @@ -68,6 +68,31 @@ jobs: cargo t --features from-source create cargo t --features from-source --examples + linux-system-pkg-config-test: + runs-on: ubuntu-22.04 + env: + SCIP_VERSION: 9.2.4 + steps: + - uses: actions/checkout@v3 + + - name: Install SCIP from debian package + run: | + wget --quiet --no-check-certificate https://github.com/scipopt/scip/releases/download/v$(echo "${{ env.SCIP_VERSION }}" | tr -d '.')/SCIPOptSuite-${{ env.SCIP_VERSION }}-Linux-ubuntu22.deb + sudo apt-get update + sudo apt install -y ./SCIPOptSuite-${{ env.SCIP_VERSION }}-Linux-ubuntu22.deb + + - name: Verify pkg-config can find SCIP + run: | + pkg-config --modversion scip || echo "pkg-config cannot find scip" + pkg-config --cflags scip || echo "No cflags" + pkg-config --libs scip || echo "No libs" + + - name: Build and test (should use pkg-config) + run: | + cargo b -vv + cargo t create + cargo t --examples + linux-conda-test: runs-on: ubuntu-latest steps: diff --git a/Cargo.toml b/Cargo.toml index 7e8cdc5..1043f26 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -7,6 +7,9 @@ repository = "https://github.com/scipopt/scip-sys" license = "Apache-2.0" links = "scip" +[package.metadata.docs.rs] +features = ["bundled"] + [features] bundled = ["ureq", "zip", "tempfile", "zip-extract"] from-source = ["ureq", "zip", "tempfile", "zip-extract", "cmake"] @@ -14,6 +17,7 @@ from-source = ["ureq", "zip", "tempfile", "zip-extract", "cmake"] [build-dependencies] bindgen = "0.72.0" glob = "0.3.1" +pkg-config = "0.3" ureq = { version = "2.9.6", optional = true } zip = { version = "0.5", optional = true } tempfile = { version = "3.2", optional = true } diff --git a/build.rs b/build.rs index 3d4bf55..40076c8 100644 --- a/build.rs +++ b/build.rs @@ -14,6 +14,8 @@ use std::path::PathBuf; use crate::from_source::{compile_scip, download_scip_source, is_from_source_feature_enabled}; use bundled::*; +extern crate pkg_config; + #[cfg(not(feature = "bundled"))] pub fn is_bundled_feature_enabled() -> bool { false @@ -93,6 +95,66 @@ fn look_in_scipoptdir_and_conda_env() -> Option { return None; } +fn try_pkg_config() -> Option { + println!("cargo:warning=Trying to find SCIP via pkg-config"); + + match pkg_config::Config::new().probe("scip") { + Ok(library) => { + println!("cargo:warning=Found SCIP via pkg-config"); + + // Get include paths from pkg-config + let include_paths = library.include_paths; + + if include_paths.is_empty() { + println!("cargo:warning=pkg-config found SCIP but no include paths provided"); + return None; + } + + // Find scip.h and scipdefplugins.h in the include paths + let mut scip_header = None; + let mut scipdefplugins_header = None; + + for include_path in &include_paths { + let scip_h = include_path.join("scip").join("scip.h"); + let scipdefplugins_h = include_path.join("scip").join("scipdefplugins.h"); + + if scip_h.exists() && scip_header.is_none() { + scip_header = Some(scip_h); + } + if scipdefplugins_h.exists() && scipdefplugins_header.is_none() { + scipdefplugins_header = Some(scipdefplugins_h); + } + } + + match (scip_header, scipdefplugins_header) { + (Some(scip_h), Some(scipdefplugins_h)) => { + println!("cargo:warning=Using SCIP headers from pkg-config"); + + let mut builder = bindgen::Builder::default() + .header(scip_h.to_str().unwrap()) + .header(scipdefplugins_h.to_str().unwrap()) + .parse_callbacks(Box::new(bindgen::CargoCallbacks)); + + // Add all include paths as clang args + for include_path in include_paths { + builder = builder.clang_arg(format!("-I{}", include_path.display())); + } + + Some(builder) + } + _ => { + println!("cargo:warning=pkg-config found SCIP but couldn't find scip.h or scipdefplugins.h"); + None + } + } + } + Err(e) => { + println!("cargo:warning=pkg-config failed to find SCIP: {}", e); + None + } + } +} + fn main() -> Result<(), Box> { let builder = if is_bundled_feature_enabled() { download_scip(); @@ -107,29 +169,20 @@ fn main() -> Result<(), Box> { if builder.is_some() { builder.unwrap() } else { - println!("cargo:warning=SCIP was not found in SCIPOPTDIR or in Conda environemnt"); + println!("cargo:warning=SCIP was not found in SCIPOPTDIR or in Conda environment"); println!("cargo:warning=Looking for SCIP in system libraries"); - let headers_dir_path = "headers/"; - let headers_dir = PathBuf::from(headers_dir_path); - let scip_header_file = PathBuf::from(&headers_dir) - .join("scip") - .join("scip.h") - .to_str() - .unwrap() - .to_owned(); - let scipdefplugins_header_file = PathBuf::from(&headers_dir) - .join("scip") - .join("scipdefplugins.h") - .to_str() - .unwrap() - .to_owned(); - - bindgen::Builder::default() - .header(scip_header_file) - .header(scipdefplugins_header_file) - .parse_callbacks(Box::new(bindgen::CargoCallbacks)) - .clang_arg(format!("-I{}", headers_dir_path)) + // Try pkg-config + try_pkg_config().unwrap_or_else(|| { + panic!( + "Could not find SCIP installation.\n\ + Please either:\n\ + - Set SCIPOPTDIR environment variable to point to your SCIP installation\n\ + - Install SCIP with pkg-config support (scip.pc file)\n\ + - Use --features bundled to download and use a bundled version\n\ + - Use --features from-source to build SCIP from source" + ) + }) } }; diff --git a/headers/bliss/abstractgraph.hh b/headers/bliss/abstractgraph.hh deleted file mode 100644 index 53cbee8..0000000 --- a/headers/bliss/abstractgraph.hh +++ /dev/null @@ -1,503 +0,0 @@ -#pragma once - -/* - Copyright (c) 2003-2021 Tommi Junttila - Released under the GNU Lesser General Public License version 3. - - This file is part of bliss. - - bliss is free software: you can redistribute it and/or modify - it under the terms of the GNU Lesser General Public License as published by - the Free Software Foundation, version 3 of the License. - - bliss is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with bliss. If not, see . -*/ - -/** - * \namespace bliss - * The namespace bliss contains all the classes and functions of the bliss - * tool except for the C programming language API. - */ -namespace bliss { - class AbstractGraph; -} - -#include -#include -#include -#include "bliss/stats.hh" -#include "bliss/kqueue.hh" -#include "bliss/heap.hh" -#include "bliss/orbit.hh" -#include "bliss/partition.hh" -#include "bliss/uintseqhash.hh" - -namespace bliss { - - -/** - * \brief An abstract base class for different types of graphs. - */ -class AbstractGraph -{ - friend class Partition; - -public: - AbstractGraph(); - virtual ~AbstractGraph(); - - /** - * Set the verbose output level for the algorithms. - * \param level the level of verbose output, 0 means no verbose output - */ - void set_verbose_level(const unsigned int level); - - /** - * Set the file stream for the verbose output. - * \param fp the file stream; if null, no verbose output is written - */ - void set_verbose_file(FILE * const fp); - - /** - * Add a new vertex with color \a color in the graph and return its index. - */ - virtual unsigned int add_vertex(const unsigned int color = 0) = 0; - - /** - * Add an edge between vertices \a source and \a target. - * Duplicate edges between vertices are ignored but try to avoid introducing - * them in the first place as they are not ignored immediately but will - * consume memory and computation resources for a while. - */ - virtual void add_edge(const unsigned int source, const unsigned int target) = 0; - - /** - * Get the color of a vertex. - */ - virtual unsigned int get_color(const unsigned int vertex) const = 0; - - /** - * Change the color of the vertex \a vertex to \a color. - */ - virtual void change_color(const unsigned int vertex, const unsigned int color) = 0; - - - /** Activate/deactivate failure recording. - * May not be called during the search, i.e. from an automorphism reporting - * hook function. - * \param active if true, activate failure recording, deactivate otherwise - */ - void set_failure_recording(const bool active) { - assert(not in_search); - opt_use_failure_recording = active; - } - - /** Activate/deactivate component recursion. - * The choice affects the computed canonical labelings; - * therefore, if you want to compare whether two graphs are isomorphic by - * computing and comparing (for equality) their canonical versions, - * be sure to use the same choice for both graphs. - * May not be called during the search, i.e. from an automorphism reporting - * hook function. - * \param active if true, activate component recursion, deactivate otherwise - */ - void set_component_recursion(const bool active) { - assert(not in_search); - opt_use_comprec = active; - } - - - - /** - * Return the number of vertices in the graph. - */ - virtual unsigned int get_nof_vertices() const = 0; - - /** - * Return a new graph that is the result of applying the permutation \a perm - * to this graph. This graph is not modified. - * \a perm must contain N=this.get_nof_vertices() elements and be a bijection - * on {0,1,...,N-1}, otherwise the result is undefined or a segfault. - */ - virtual AbstractGraph* permute(const unsigned int* const perm) const = 0; - - /** - * Return a new graph that is the result of applying the permutation \a perm - * to this graph. This graph is not modified. - * \a perm must contain N=this.get_nof_vertices() elements and be a bijection - * on {0,1,...,N-1}, otherwise the result is undefined or a segfault. - */ - virtual AbstractGraph* permute(const std::vector& perm) const = 0; - - /** - * Check whether \a perm is an automorphism of this graph. - * Unoptimized, mainly for debugging purposes. - */ - virtual bool is_automorphism(unsigned int* const perm) const = 0; - - /** - * Check whether \a perm is an automorphism of this graph. - * Unoptimized, mainly for debugging purposes. - */ - virtual bool is_automorphism(const std::vector& perm) const = 0; - - /** - * Find a set of generators for the automorphism group of the graph. - * The function \a report (if non-null) is called each time a new generator - * for the automorphism group is found. - * The first argument \a n for the function - * is the length of the automorphism (equal to get_nof_vertices()), and - * the second argument \a aut is the automorphism - * (a bijection on {0,...,get_nof_vertices()-1}). - * The memory for the automorphism \a aut will be invalidated immediately - * after the return from the \a report function; - * if you want to use the automorphism later, you have to take a copy of it. - * Do not call any member functions from the \a report function. - * - * The search statistics are copied in \a stats. - * - * If the \a terminate function argument is given, - * it is called in each search tree node: if the function returns true, - * then the search is terminated and thus not all the automorphisms - * may have been generated. - * The \a terminate function may be used to limit the time spent in bliss - * in case the graph is too difficult under the available time constraints. - * If used, keep the function simple to evaluate so that - * it does not consume too much time. - */ - void find_automorphisms(Stats& stats, - const std::function& report = nullptr, - const std::function& terminate = nullptr); - - /** - * Otherwise the same as find_automorphisms() except that - * a canonical labeling of the graph (a bijection on - * {0,...,get_nof_vertices()-1}) is returned. - * The memory allocated for the returned canonical labeling will remain - * valid only until the next call to a member function with the exception - * that constant member functions (for example, bliss::Graph::permute()) can - * be called without invalidating the labeling. - * To compute the canonical version of an undirected graph, call this - * function and then bliss::Graph::permute() with the returned canonical - * labeling. - * Note that the computed canonical version may depend on the applied version - * of bliss as well as on some other options (for instance, the splitting - * heuristic selected with bliss::Graph::set_splitting_heuristic()). - * - * If the \a terminate function argument is given, - * it is called in each search tree node: if the function returns true, - * then the search is terminated and thus (i) not all the automorphisms - * may have been generated and (ii) the returned labeling may not - * be canonical. - * The \a terminate function may be used to limit the time spent in bliss - * in case the graph is too difficult under the available time constraints. - * If used, keep the function simple to evaluate so that - * it does not consume too much time. - */ - const unsigned int* canonical_form(Stats& stats, - const std::function& report = nullptr, - const std::function& terminate = nullptr); - - /** - * Write the graph to a file in a variant of the DIMACS format. - * See the bliss website - * for the definition of the file format. - * Note that in the DIMACS file the vertices are numbered from 1 to N while - * in this C++ API they are from 0 to N-1. - * Thus the vertex n in the file corresponds to the vertex n-1 in the API. - * \param fp the file stream where the graph is written - */ - virtual void write_dimacs(FILE * const fp) = 0; - - /** - * Write the graph to a file in the graphviz dotty format. - * \param fp the file stream where the graph is written - */ - virtual void write_dot(FILE * const fp) = 0; - - /** - * Write the graph in a file in the graphviz dotty format. - * Do nothing if the file cannot be written. - * \param file_name the name of the file to which the graph is written - */ - virtual void write_dot(const char * const file_name) = 0; - - /** - * Get a hash value for the graph. - * \return the hash value - */ - virtual unsigned int get_hash() = 0; - - /** - * Disable/enable the "long prune" method. - * The choice affects the computed canonical labelings; - * therefore, if you want to compare whether two graphs are isomorphic by - * computing and comparing (for equality) their canonical versions, - * be sure to use the same choice for both graphs. - * May not be called during the search, i.e. from an automorphism reporting - * hook function. - * \param active if true, activate "long prune", deactivate otherwise - */ - void set_long_prune_activity(const bool active) { - assert(not in_search); - opt_use_long_prune = active; - } - - - -protected: - /** \internal - * How much verbose output is produced (0 means none) */ - unsigned int verbose_level; - - /** \internal - * The output stream for verbose output. */ - FILE *verbstr; - - /** \internal - * The ordered partition used in the search algorithm. */ - Partition p; - - /** \internal - * Whether the search for automorphisms and a canonical labeling is - * in progress. - */ - bool in_search; - - /** \internal - * Is failure recording in use? - */ - bool opt_use_failure_recording; - - /* The "tree-specific" invariant value for the point when current path - * got different from the first path */ - unsigned int failure_recording_fp_deviation; - - /** \internal - * Is component recursion in use? - */ - bool opt_use_comprec; - - - unsigned int refine_current_path_certificate_index; - bool refine_compare_certificate; - bool refine_equal_to_first; - unsigned int refine_first_path_subcertificate_end; - int refine_cmp_to_best; - unsigned int refine_best_path_subcertificate_end; - - static const unsigned int CERT_SPLIT = 0; //UINT_MAX; - static const unsigned int CERT_EDGE = 1; //UINT_MAX-1; - /** \internal - * Add a triple (v1,v2,v3) in the certificate. - * May modify refine_equal_to_first and refine_cmp_to_best. - * May also update eqref_hash and failure_recording_fp_deviation. */ - void cert_add(const unsigned int v1, - const unsigned int v2, - const unsigned int v3); - - /** \internal - * Add a redundant triple (v1,v2,v3) in the certificate. - * Can also just dicard the triple. - * May modify refine_equal_to_first and refine_cmp_to_best. - * May also update eqref_hash and failure_recording_fp_deviation. */ - void cert_add_redundant(const unsigned int x, - const unsigned int y, - const unsigned int z); - - /**\internal - * Is the long prune method in use? - */ - bool opt_use_long_prune; - /**\internal - * Maximum amount of memory (in megabytes) available for - * the long prune method - */ - static const unsigned int long_prune_options_max_mem = 50; - /**\internal - * Maximum amount of automorphisms stored for the long prune method; - * less than this is stored if the memory limit above is reached first - */ - static const unsigned int long_prune_options_max_stored_auts = 100; - - unsigned int long_prune_max_stored_autss; - std::vector *> long_prune_fixed; - std::vector *> long_prune_mcrs; - std::vector long_prune_temp; - unsigned int long_prune_begin; - unsigned int long_prune_end; - /** \internal - * Initialize the "long prune" data structures. - */ - void long_prune_init(); - /** \internal - * Release the memory allocated for "long prune" data structures. - */ - void long_prune_deallocate(); - void long_prune_add_automorphism(const unsigned int *aut); - std::vector& long_prune_get_fixed(const unsigned int index); - std::vector& long_prune_allocget_fixed(const unsigned int index); - std::vector& long_prune_get_mcrs(const unsigned int index); - std::vector& long_prune_allocget_mcrs(const unsigned int index); - /** \internal - * Swap the i:th and j:th stored automorphism information; - * i and j must be "in window, i.e. in [long_prune_begin,long_prune_end[ - */ - void long_prune_swap(const unsigned int i, const unsigned int j); - - /* - * Data structures and routines for refining the partition p into equitable - */ - Heap neighbour_heap; - virtual bool split_neighbourhood_of_unit_cell(Partition::Cell * const) = 0; - virtual bool split_neighbourhood_of_cell(Partition::Cell * const) = 0; - void refine_to_equitable(); - void refine_to_equitable(Partition::Cell * const unit_cell); - void refine_to_equitable(Partition::Cell * const unit_cell1, - Partition::Cell * const unit_cell2); - - - /** \internal - * \return false if it was detected that the current certificate - * is different from the first and/or best (whether this is checked - * depends on in_search and refine_compare_certificate flags. - */ - bool do_refine_to_equitable(); - - unsigned int eqref_max_certificate_index; - /** \internal - * Whether eqref_hash is updated during equitable refinement process. - */ - bool compute_eqref_hash; - UintSeqHash eqref_hash; - - - /** \internal - * Check whether the current partition p is equitable. - * Performance: very slow, use only for debugging purposes. - */ - virtual bool is_equitable() const = 0; - - unsigned int *first_path_labeling; - unsigned int *first_path_labeling_inv; - Orbit first_path_orbits; - unsigned int *first_path_automorphism; - - unsigned int *best_path_labeling; - unsigned int *best_path_labeling_inv; - Orbit best_path_orbits; - unsigned int *best_path_automorphism; - - void update_labeling(unsigned int * const lab); - void update_labeling_and_its_inverse(unsigned int * const lab, - unsigned int * const lab_inv); - void update_orbit_information(Orbit &o, const unsigned int *perm); - - void reset_permutation(unsigned int *perm); - - std::vector certificate_current_path; - std::vector certificate_first_path; - std::vector certificate_best_path; - - unsigned int certificate_index; - virtual void initialize_certificate() = 0; - - /* Remove duplicates from seq. - * If m is the largest element in seq, them m < tmp.size() must hold. - * All entries in tmp must be false when called. - * Under that condition, all entries in tmp are false on exit as well. - */ - static void remove_duplicates(std::vector& seq, std::vector& tmp); - - virtual void remove_duplicate_edges() = 0; - virtual void make_initial_equitable_partition() = 0; - virtual Partition::Cell* find_next_cell_to_be_splitted(Partition::Cell *cell) = 0; - - - /** \struct PathInfo - * - * A structure for holding first, current, and best path information. - */ - typedef struct { - unsigned int splitting_element; - unsigned int certificate_index; - unsigned int subcertificate_length; - UintSeqHash eqref_hash; - } PathInfo; - - void search(const bool canonical, Stats &stats, - const std::function& report_function = nullptr, - const std::function& terminate = nullptr); - - - /* - * - * Nonuniform component recursion (NUCR) - * - */ - - /* The currently traversed component */ - unsigned int cr_level; - - /** @internal @class CR_CEP - * The "Component End Point" data structure - */ - class CR_CEP { - public: - /** At which level in the search was this CEP created */ - unsigned int creation_level; - /** The current component has been fully traversed when the partition has - * this many discrete cells left */ - unsigned int discrete_cell_limit; - /** The component to be traversed after the current one */ - unsigned int next_cr_level; - /** The next component end point */ - unsigned int next_cep_index; - bool first_checked; - bool best_checked; - }; - /** \internal - * A stack for storing Component End Points - */ - std::vector cr_cep_stack; - - /** \internal - * Find the first non-uniformity component at the component recursion - * level \a level. - * The component is stored in \a cr_component. - * If no component is found, \a cr_component is empty. - * Returns false if all the cells in the component recursion level \a level - * were discrete. - * Modifies the max_ival and max_ival_count fields of Partition:Cell - * (assumes that they are 0 when called and - * quarantees that they are 0 when returned). - */ - virtual bool nucr_find_first_component(const unsigned int level) = 0; - virtual bool nucr_find_first_component(const unsigned int level, - std::vector& component, - unsigned int& component_elements, - Partition::Cell*& sh_return) = 0; - /** \internal - * The non-uniformity component found by nucr_find_first_component() - * is stored here. - */ - std::vector cr_component; - /** \internal - * The number of vertices in the component \a cr_component - */ - unsigned int cr_component_elements; - - - - - - -}; - -} // namespace bliss diff --git a/headers/bliss/bignum.hh b/headers/bliss/bignum.hh deleted file mode 100644 index 95a1bd7..0000000 --- a/headers/bliss/bignum.hh +++ /dev/null @@ -1,260 +0,0 @@ -#pragma once - -/* - Copyright (c) 2003-2021 Tommi Junttila - Released under the GNU Lesser General Public License version 3. - - This file is part of bliss. - - bliss is free software: you can redistribute it and/or modify - it under the terms of the GNU Lesser General Public License as published by - the Free Software Foundation, version 3 of the License. - - bliss is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with bliss. If not, see . -*/ - -#if defined(BLISS_USE_GMP) -#include -#else -#include -#include -#endif - -#include -#include -#include "bliss/defs.hh" - - -namespace bliss { - -/** - * \brief A simple wrapper class for non-negative big integers (or approximation of them). - * - * If the compile time flag BLISS_USE_GMP is set, - * then the GNU Multiple Precision Arithmetic library (GMP) is used to - * obtain arbitrary precision. - * Otherwise, if the compile time flag BLISS_BIGNUM_APPROX is set, - * a "long double" is used to approximate a big integer. - * Otherwise, by default, a big integer is represented by a product of - * integer-sized factors. - */ - -#if defined(BLISS_USE_GMP) - -class BigNum -{ - mpz_t v; -public: - /** - * \brief Create a new big number and set it to zero. - */ - BigNum() {mpz_init(v); } - - /** - * \brief Destroy the number. - */ - ~BigNum() {mpz_clear(v); } - - /** - * \brief Set the number to \a n. - */ - void assign(unsigned int n) {mpz_set_ui(v, n); } - - /** - * \brief Multiply the number with \a n. - */ - void multiply(unsigned int n) {mpz_mul_ui(v, v, n); } - - /** - * \brief Print the number in the file stream \a fp. - */ - size_t print(FILE* const fp) const {return mpz_out_str(fp, 10, v); } - - /** - * Get a copy of the internal GNU GMP integer. - * The caller is responsible for calling mpz_init before, - * and mpz_clear afterwards on the \a result variable. - */ - void get(mpz_t& result) const {mpz_set(result, v); } -}; - -#elif defined(BLISS_BIGNUM_APPROX) - -class BigNum -{ - long double v; -public: - /** - * \brief Create a new big number and set it to zero. - */ - BigNum(): v(0.0) {} - - /** - * \brief Set the number to \a n. - */ - void assign(unsigned int n) {v = (long double)n; } - - /** - * \brief Multiply the number with \a n. - */ - void multiply(unsigned int n) {v *= (long double)n; } - - /** - * \brief Print the number in the file stream \a fp. - */ - size_t print(FILE* const fp) const {return fprintf(fp, "%Lg", v); } -}; - -#else - - -class BigNum -{ - /* This is a version that does not actually compute the number - * but rather only stores the factor integers. - */ - std::vector factors; -public: - /** - * Create a new big number and set it to zero. - */ - BigNum() { - factors.push_back(0); - } - - /** - * Destroy the number. - */ - ~BigNum() {} - - /** - * Set the number to \a n. - */ - void assign(unsigned int n) { - factors.clear(); - factors.push_back(n); - } - - /** - * Multiply the number with \a n. - */ - void multiply(unsigned int n) { - factors.push_back(n); - } - - /** - * Print the number in the file stream \a fp. - * In the current version, the returned number of characters printed, - * is incorrect (either -1 or 0). - */ - size_t print(FILE* const fp) const { - assert(not factors.empty()); - size_t r = 0; - /* - const char* sep = ""; - for(int v: factors) { - r += fprintf(fp, "%s%d", sep, v); - sep = "*"; - } - */ - for(char d: to_string()) - r += fprintf(fp, "%c", d); - return r; - } - - /** - * Get a reference to the factors vector. - */ - const std::vector& get_factors() const { - return factors; - } - - /** - * Get the tring representation of the number. - * Unoptimized, uses an elementary school algorithm to multiply the factors. - */ - std::string to_string() const { - // Base 100 result, in reverse order - std::vector result; - result.push_back(1); - for(unsigned int factor: factors) { - std::vector summand; - unsigned int offset = 0; - while(factor != 0) { - const unsigned int multiplier = factor % 100; - // Multiplication by a "digit" - std::vector product; - for(unsigned int i = 0; i < offset; i++) - product.push_back(0); - unsigned int carry = 0; - for(unsigned int digit: result) { - unsigned int v = digit * multiplier + carry; - product.push_back(v % 100); - carry = v / 100; - } - if(carry > 0) - product.push_back(carry); - // Addition - add(summand, product); - // Next "digit" in factor - factor = factor / 100; - offset++; - } - result = summand; - } - return _string(result); - } - -protected: - static void add(std::vector& num, const std::vector& summand) { - unsigned int carry = 0; - unsigned int i = 0; - while(i < num.size() and i < summand.size()) { - const unsigned int v = carry + num[i] + summand[i]; - num[i] = v % 100; - carry = v / 100; - i++; - } - while(i < summand.size()) { - const unsigned int v = carry + summand[i]; - num.push_back(v % 100); - carry = v / 100; - i++; - } - while(i < num.size()) { - const unsigned int v = carry + num[i]; - num[i] = v % 100; - carry = v / 100; - i++; - } - if(carry != 0) - num.push_back(carry); - } - - - static std::string _string(const std::vector n) { - const char digits[] = {'0','1','2','3','4','5','6','7','8','9'}; - std::string r; - bool first = true; - for(auto it = n.crbegin(); it != n.crend(); it++) { - unsigned int digit = *it; - unsigned int high = digit / 10; - if(not first or high > 0) - r.push_back(digits[high]); - first = false; - r.push_back(digits[digit % 10]); - } - return r; - } - -}; - -#endif - -} //namespace bliss diff --git a/headers/bliss/bliss_C.h b/headers/bliss/bliss_C.h deleted file mode 100644 index b83540b..0000000 --- a/headers/bliss/bliss_C.h +++ /dev/null @@ -1,205 +0,0 @@ -#ifndef BLISS_C_H -#define BLISS_C_H - -/* - Copyright (c) 2003-2021 Tommi Junttila - Released under the GNU Lesser General Public License version 3. - - This file is part of bliss. - - bliss is free software: you can redistribute it and/or modify - it under the terms of the GNU Lesser General Public License as published by - the Free Software Foundation, version 3 of the License. - - bliss is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with bliss. If not, see . -*/ - -/** - * \file - * \brief The bliss C API. - * - * This is the C language API to bliss. - * Note that this C API is only a subset of the C++ API; - * please consider using the C++ API whenever possible. - */ - -#include -#include - - -/** - * \brief The true bliss graph is hiding behind this typedef. - */ -typedef struct bliss_graph_struct BlissGraph; - - -/** - * \brief The C API version of the statistics returned by - * the bliss search algorithm. - */ -typedef struct bliss_stats_struct -{ - /** - * \brief An approximation (due to possible rounding errors) of - * the size of the automorphism group. - */ - long double group_size_approx; - /** \brief The number of nodes in the search tree. */ - long unsigned int nof_nodes; - /** \brief The number of leaf nodes in the search tree. */ - long unsigned int nof_leaf_nodes; - /** \brief The number of bad nodes in the search tree. */ - long unsigned int nof_bad_nodes; - /** \brief The number of canonical representative updates. */ - long unsigned int nof_canupdates; - /** \brief The number of generator permutations. */ - long unsigned int nof_generators; - /** \brief The maximal depth of the search tree. */ - unsigned long int max_level; -} BlissStats; - - -/** - * Create a new graph instance with \a N vertices and no edges. - * \a N can be zero and bliss_add_vertex() called afterwards - * to add new vertices on-the-fly. - */ -BlissGraph *bliss_new(const unsigned int N); - - -/** - * Read an undirected graph from a file in the DIMACS format into a new bliss - * instance. - * Returns 0 if an error occurred. - * Note that in the DIMACS file the vertices are numbered from 1 to N while - * in the bliss C API they are from 0 to N-1. - * Thus the vertex n in the file corresponds to the vertex n-1 in the API. - */ -BlissGraph *bliss_read_dimacs(FILE *fp); - - -/** - * Output the graph in the file stream \a fp in the DIMACS format. - * See the User's Guide for the file format details. - * Note that in the DIMACS file the vertices are numbered from 1 to N while - * in bliss they are from 0 to N-1. - */ -void bliss_write_dimacs(BlissGraph *graph, FILE *fp); - - -/** - * Release the graph. - * Note that the memory pointed by the arguments of hook functions for - * bliss_find_automorphisms() and bliss_find_canonical_labeling() - * is deallocated and thus should not be accessed after calling this function. - */ -void bliss_release(BlissGraph *graph); - - -/** - * Print the graph in graphviz dot format. - */ -void bliss_write_dot(BlissGraph *graph, FILE *fp); - - -/** - * Return the number of vertices in the graph. - */ -unsigned int bliss_get_nof_vertices(BlissGraph *graph); - - -/** - * Add a new vertex with color \a c in the graph \a graph and return its index. - * The vertex indices are always in the range - * [0,bliss::bliss_get_nof_vertices(\a bliss)-1]. - */ -unsigned int bliss_add_vertex(BlissGraph *graph, unsigned int c); - - -/** - * Add a new undirected edge in the graph. - * \a v1 and \a v2 are vertex indices returned by bliss_add_vertex(). - * If duplicate edges are added, they will be ignored (however, they are not - * necessarily physically ignored immediately but may consume memory for - * a while so please try to avoid adding duplicate edges whenever possible). - */ -void bliss_add_edge(BlissGraph *graph, unsigned int v1, unsigned int v2); - - -/** - * Compare two graphs according to a total order. - * Return -1, 0, or 1 if the first graph was smaller than, equal to, - * or greater than, resp., the other graph. - * If 0 is returned, then the graphs have the same number vertices, - * the vertices in them are colored in the same way, and they contain - * the same edges; that is, the graphs are equal. - */ -int bliss_cmp(BlissGraph *graph1, BlissGraph *graph2); - - -/** - * Get a hash value for the graph. - */ -unsigned int bliss_hash(BlissGraph *graph); - - -/** - * Permute the graph with the given permutation \a perm. - * Returns the permuted graph, the original graph is not modified. - * The argument \a perm should be an array of - * N=bliss::bliss_get_nof_vertices(\a graph) elements describing - * a bijection on {0,...,N-1}. - */ -BlissGraph *bliss_permute(BlissGraph *graph, const unsigned int *perm); - - -/** - * Find a set of generators for the automorphism group of the graph. - * The hook function \a hook (if non-null) is called each time a new generator - * for the automorphism group is found. - * The first argument \a user_param for the hook function is - * the \a hook_user_param argument, - * the second argument \a N is the length of the automorphism (equal to - * bliss::bliss_get_nof_vertices(\a graph)) and - * the third argument \a aut is the automorphism (a bijection on {0,...,N-1}). - * The memory for the automorphism \a aut will be invalidated immediately - * after the return from the hook; - * if you want to use the automorphism later, you have to take a copy of it. - * Do not call bliss_* functions in the hook. - * If \a stats is non-null, then some search statistics are copied there. - */ -void -bliss_find_automorphisms(BlissGraph *graph, - void (*hook)(void *user_param, - unsigned int N, - const unsigned int *aut), - void *hook_user_param, - BlissStats *stats); - - -/** - * Otherwise the same as bliss_find_automorphisms() except that - * a canonical labeling for the graph (a bijection on {0,...,N-1}) is returned. - * The returned canonical labeling will remain valid only until - * the next call to a bliss_* function with the exception that - * bliss_permute() can be called without invalidating the labeling. - * To compute the canonical version of a graph, call this function and - * then bliss_permute() with the returned canonical labeling. - * Note that the computed canonical version may depend on the applied version - * of bliss. - */ -const unsigned int * -bliss_find_canonical_labeling(BlissGraph *graph, - void (*hook)(void *user_param, - unsigned int N, - const unsigned int *aut), - void *hook_user_param, - BlissStats *stats); - -#endif diff --git a/headers/bliss/defs.hh b/headers/bliss/defs.hh deleted file mode 100644 index 304616e..0000000 --- a/headers/bliss/defs.hh +++ /dev/null @@ -1,87 +0,0 @@ -#pragma once - -/* - Copyright (c) 2003-2021 Tommi Junttila - Released under the GNU Lesser General Public License version 3. - - This file is part of bliss. - - bliss is free software: you can redistribute it and/or modify - it under the terms of the GNU Lesser General Public License as published by - the Free Software Foundation, version 3 of the License. - - bliss is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with bliss. If not, see . -*/ - -#include -#include - -//SV https://en.cppreference.com/w/cpp/language/operator_alternative -#include - -/** \file - * \brief Some common definitions. - */ - -#define BLISS_VERSION "0.77" -#define BLISS_VERSION_MAJOR 0 -#define BLISS_VERSION_MINOR 77 - -namespace bliss { - -/** \brief The version number of bliss. */ -static const char * const version = "0.77"; - - - -#if defined(BLISS_DEBUG) -#define BLISS_CONSISTENCY_CHECKS -#define BLISS_EXPENSIVE_CONSISTENCY_CHECKS -#endif - - -#if defined(BLISS_CONSISTENCY_CHECKS) -/* Force a check that the found automorphisms are valid */ -#define BLISS_VERIFY_AUTOMORPHISMS -#endif - - -#if defined(BLISS_CONSISTENCY_CHECKS) -/* Force a check that the generated partitions are equitable */ -#define BLISS_VERIFY_EQUITABLEDNESS -#endif - -} // namespace bliss - - -/*! \mainpage Outline - * - * This is the C++ API documentation of bliss, - * produced by running doxygen in - * the source directory. - * - * The algorithms and data structures used in bliss, - * the graph file format, as well as the compilation process - * can be found at the - * bliss web site. - * - * The C++ language API is the main API to bliss. - * It basically consists of the public methods in the classes - * * bliss::Graph and - * * bliss::Digraph. - * - * For an example of its use, - * see the \ref executable "source of the bliss executable". - * - * \section capi_sec The C language API - * - * The C language API is given in the file bliss_C.h. - * It is currently only a subset of the C++ API, - * so consider using the C++ API whenever possible. - */ diff --git a/headers/bliss/digraph.hh b/headers/bliss/digraph.hh deleted file mode 100644 index 5d58487..0000000 --- a/headers/bliss/digraph.hh +++ /dev/null @@ -1,285 +0,0 @@ -#pragma once - -/* - Copyright (c) 2003-2021 Tommi Junttila - Released under the GNU Lesser General Public License version 3. - - This file is part of bliss. - - bliss is free software: you can redistribute it and/or modify - it under the terms of the GNU Lesser General Public License as published by - the Free Software Foundation, version 3 of the License. - - bliss is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with bliss. If not, see . -*/ - -#include "bliss/abstractgraph.hh" - -namespace bliss { - -/** - * \brief The class for directed, vertex colored graphs. - * - * Multiple edges between vertices are not allowed (copies will be ignored). - */ -class Digraph : public AbstractGraph -{ -public: - /** - * The possible splitting heuristics. - * The selected splitting heuristics affects the computed canonical - * labelings; therefore, if you want to compare whether two graphs - * are isomorphic by computing and comparing (for equality) their - * canonical versions, be sure to use the same splitting heuristics - * for both graphs. - */ - typedef enum { - /** First non-unit cell. - * Very fast but may result in large search spaces on difficult graphs. - * Use for large but easy graphs. */ - shs_f = 0, - /** First smallest non-unit cell. - * Fast, should usually produce smaller search spaces than shs_f. */ - shs_fs, - /** First largest non-unit cell. - * Fast, should usually produce smaller search spaces than shs_f. */ - shs_fl, - /** First maximally non-trivially connected non-unit cell. - * Not so fast, should usually produce smaller search spaces than shs_f, - * shs_fs, and shs_fl. */ - shs_fm, - /** First smallest maximally non-trivially connected non-unit cell. - * Not so fast, should usually produce smaller search spaces than shs_f, - * shs_fs, and shs_fl. */ - shs_fsm, - /** First largest maximally non-trivially connected non-unit cell. - * Not so fast, should usually produce smaller search spaces than shs_f, - * shs_fs, and shs_fl. */ - shs_flm - } SplittingHeuristic; - -protected: - class Vertex { - public: - Vertex(); - ~Vertex(); - void add_edge_to(const unsigned int dest_vertex); - void add_edge_from(const unsigned int source_vertex); - void remove_duplicate_edges(std::vector& tmp); - void sort_edges(); - unsigned int color; - std::vector edges_out; - std::vector edges_in; - unsigned int nof_edges_in() const {return edges_in.size(); } - unsigned int nof_edges_out() const {return edges_out.size(); } - }; - std::vector vertices; - void remove_duplicate_edges(); - - /** \internal - * Partition independent invariant. - * Returns the color of the vertex. - * Time complexity: O(1). - */ - static unsigned int vertex_color_invariant(const Digraph* const g, - const unsigned int v); - /** \internal - * Partition independent invariant. - * Returns the indegree of the vertex. - * DUPLICATE EDGES MUST HAVE BEEN REMOVED BEFORE. - * Time complexity: O(1). - */ - static unsigned int indegree_invariant(const Digraph* const g, - const unsigned int v); - /** \internal - * Partition independent invariant. - * Returns the outdegree of the vertex. - * DUPLICATE EDGES MUST HAVE BEEN REMOVED BEFORE. - * Time complexity: O(1). - */ - static unsigned int outdegree_invariant(const Digraph* const g, - const unsigned int v); - /** \internal - * Partition independent invariant. - * Returns 1 if there is an edge from the vertex to itself, 0 if not. - * Time complexity: O(k), where k is the number of edges leaving the vertex. - */ - static unsigned int selfloop_invariant(const Digraph* const g, - const unsigned int v); - - /** \internal - * Refine the partition \a p according to - * the partition independent invariant \a inv. - */ - bool refine_according_to_invariant(unsigned int (*inv)(const Digraph* const g, - const unsigned int v)); - - /* - * Routines needed when refining the partition p into equitable - */ - bool split_neighbourhood_of_unit_cell(Partition::Cell* const); - bool split_neighbourhood_of_cell(Partition::Cell* const); - - - /** \internal - * \copydoc AbstractGraph::is_equitable() const - */ - bool is_equitable() const; - - /* Splitting heuristics, documented in more detail in the cc-file. */ - SplittingHeuristic sh; - Partition::Cell* find_next_cell_to_be_splitted(Partition::Cell *cell); - Partition::Cell* sh_first(); - Partition::Cell* sh_first_smallest(); - Partition::Cell* sh_first_largest(); - Partition::Cell* sh_first_max_neighbours(); - Partition::Cell* sh_first_smallest_max_neighbours(); - Partition::Cell* sh_first_largest_max_neighbours(); - - /* A data structure used in many functions. - * Allocated only once to reduce allocation overhead, - * may be used only in one function at a time. - */ - std::vector _neighbour_cells; - - void make_initial_equitable_partition(); - - void initialize_certificate(); - - void sort_edges(); - - bool nucr_find_first_component(const unsigned int level); - bool nucr_find_first_component(const unsigned int level, - std::vector& component, - unsigned int& component_elements, - Partition::Cell*& sh_return); - -public: - /** - * Create a new directed graph with \a N vertices and no edges. - */ - Digraph(const unsigned int N = 0); - - /** - * Destroy the graph. - */ - ~Digraph(); - - /** - * Read the graph from the file \a fp in a variant of the DIMACS format. - * See the bliss website - * for the definition of the file format. - * Note that in the DIMACS file the vertices are numbered from 1 to N while - * in this C++ API they are from 0 to N-1. - * Thus the vertex n in the file corresponds to the vertex n-1 in the API. - * \param fp the file stream for the graph file - * \param errstr if non-null, the possible error messages are printed - * in this file stream - * \return a new Digraph object or 0 if reading failed for some - * reason - */ - static Digraph* read_dimacs(FILE* const fp, FILE* const errstr = stderr); - - /** - * \copydoc AbstractGraph::write_dimacs(FILE * const fp) - */ - void write_dimacs(FILE* const fp); - - - /** - * \copydoc AbstractGraph::write_dot(FILE *fp) - */ - void write_dot(FILE * const fp); - - /** - * \copydoc AbstractGraph::write_dot(const char * const file_name) - */ - void write_dot(const char * const file_name); - - - - /** - * \copydoc AbstractGraph::get_hash() - */ - virtual unsigned int get_hash(); - - /** - * Return the number of vertices in the graph. - */ - unsigned int get_nof_vertices() const {return vertices.size(); } - - /** - * Add a new vertex with color 'color' in the graph and return its index. - */ - unsigned int add_vertex(const unsigned int color = 0); - - /** - * Add an edge from the vertex \a source to the vertex \a target. - * Duplicate edges are ignored but try to avoid introducing - * them in the first place as they are not ignored immediately but will - * consume memory and computation resources for a while. - */ - void add_edge(const unsigned int source, const unsigned int target); - - /** - * \copydoc AbstractGraph::get_color(const unsigned int vertex) const - */ - unsigned int get_color(const unsigned int vertex) const; - - /** - * Change the color of the vertex 'vertex' to 'color'. - */ - void change_color(const unsigned int vertex, const unsigned int color); - - /** - * Get a copy of the graph. - */ - Digraph* copy() const; - - /** - * Compare this graph to the \a other graph in a total orger on graphs. - * \return 0 if the graphs are equal, - * -1 if this graph is "smaller than" the other, and - * 1 if this graph is "greater than" the other. - */ - int cmp(Digraph& other); - - /** - * Set the splitting heuristic used by the automorphism and canonical - * labeling algorithm. - * The selected splitting heuristics affects the computed canonical - * labelings; therefore, if you want to compare whether two graphs - * are isomorphic by computing and comparing (for equality) their - * canonical versions, be sure to use the same splitting heuristics - * for both graphs. - */ - void set_splitting_heuristic(SplittingHeuristic shs) {sh = shs; } - - /** - * \copydoc AbstractGraph::permute(const unsigned int* const perm) const - */ - Digraph* permute(const unsigned int* const perm) const; - - /** - * \copydoc AbstractGraph::permute(const std::vector& perm) const - */ - Digraph* permute(const std::vector& perm) const; - - /** - * \copydoc AbstractGraph::is_automorphism(unsigned int* const perm) const - */ - bool is_automorphism(unsigned int* const perm) const; - - /** - * \copydoc AbstractGraph::is_automorphism(const std::vector& perm) const - */ - bool is_automorphism(const std::vector& perm) const; -}; - -} // namespace bliss diff --git a/headers/bliss/graph.hh b/headers/bliss/graph.hh deleted file mode 100644 index b585fe7..0000000 --- a/headers/bliss/graph.hh +++ /dev/null @@ -1,281 +0,0 @@ -#pragma once - -/* - Copyright (c) 2003-2021 Tommi Junttila - Released under the GNU Lesser General Public License version 3. - - This file is part of bliss. - - bliss is free software: you can redistribute it and/or modify - it under the terms of the GNU Lesser General Public License as published by - the Free Software Foundation, version 3 of the License. - - bliss is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with bliss. If not, see . -*/ - -#include "bliss/abstractgraph.hh" - -namespace bliss { - -/** - * \brief The class for undirected, vertex colored graphs. - * - * Multiple edges between vertices are not allowed (i.e., are ignored). - */ -class Graph : public AbstractGraph -{ -public: - /** - * The possible splitting heuristics. - * The selected splitting heuristics affects the computed canonical - * labelings; therefore, if you want to compare whether two graphs - * are isomorphic by computing and comparing (for equality) their - * canonical versions, be sure to use the same splitting heuristics - * for both graphs. - */ - typedef enum { - /** First non-unit cell. - * Very fast but may result in large search spaces on difficult graphs. - * Use for large but easy graphs. */ - shs_f = 0, - /** First smallest non-unit cell. - * Fast, should usually produce smaller search spaces than shs_f. */ - shs_fs, - /** First largest non-unit cell. - * Fast, should usually produce smaller search spaces than shs_f. */ - shs_fl, - /** First maximally non-trivially connected non-unit cell. - * Not so fast, should usually produce smaller search spaces than shs_f, - * shs_fs, and shs_fl. */ - shs_fm, - /** First smallest maximally non-trivially connected non-unit cell. - * Not so fast, should usually produce smaller search spaces than shs_f, - * shs_fs, and shs_fl. */ - shs_fsm, - /** First largest maximally non-trivially connected non-unit cell. - * Not so fast, should usually produce smaller search spaces than shs_f, - * shs_fs, and shs_fl. */ - shs_flm - } SplittingHeuristic; - -protected: - class Vertex { - public: - Vertex(); - ~Vertex(); - void add_edge(const unsigned int other_vertex); - void remove_duplicate_edges(std::vector& tmp); - void sort_edges(); - - unsigned int color; - std::vector edges; - unsigned int nof_edges() const {return edges.size(); } - }; - std::vector vertices; - void sort_edges(); - void remove_duplicate_edges(); - - /** \internal - * Partition independent invariant. - * Returns the color of the vertex. - * Time complexity: O(1). - */ - static unsigned int vertex_color_invariant(const Graph* const g, - const unsigned int v); - - /** \internal - * Partition independent invariant. - * Returns the degree of the vertex. - * DUPLICATE EDGES MUST HAVE BEEN REMOVED BEFORE. - * Time complexity: O(1). - */ - static unsigned int degree_invariant(const Graph* const g, - const unsigned int v); - - /** \internal - * Partition independent invariant. - * Returns 1 if there is an edge from the vertex to itself, 0 if not. - * Time complexity: O(k), where k is the number of edges leaving the vertex. - */ - static unsigned int selfloop_invariant(const Graph* const g, - const unsigned int v); - - - bool refine_according_to_invariant(unsigned int (*inv)(const Graph* const g, - const unsigned int v)); - - /* - * Routines needed when refining the partition p into equitable - */ - bool split_neighbourhood_of_unit_cell(Partition::Cell * const); - bool split_neighbourhood_of_cell(Partition::Cell * const); - - /** \internal - * \copydoc AbstractGraph::is_equitable() const - */ - bool is_equitable() const; - - /* Splitting heuristics, documented in more detail in graph.cc */ - SplittingHeuristic sh; - Partition::Cell* find_next_cell_to_be_splitted(Partition::Cell *cell); - Partition::Cell* sh_first(); - Partition::Cell* sh_first_smallest(); - Partition::Cell* sh_first_largest(); - Partition::Cell* sh_first_max_neighbours(); - Partition::Cell* sh_first_smallest_max_neighbours(); - Partition::Cell* sh_first_largest_max_neighbours(); - - - /* A data structure used in many functions. - * Allocated only once to reduce allocation overhead, - * may be used only in one function at a time. - */ - std::vector _neighbour_cells; - - void make_initial_equitable_partition(); - - void initialize_certificate(); - - - - bool nucr_find_first_component(const unsigned int level); - bool nucr_find_first_component(const unsigned int level, - std::vector& component, - unsigned int& component_elements, - Partition::Cell*& sh_return); - - - - -public: - /** - * Create a new graph with \a N vertices and no edges. - */ - Graph(const unsigned int N = 0); - - /** - * Destroy the graph. - */ - ~Graph(); - - /** - * Read the graph from the file \a fp in a variant of the DIMACS format. - * See the bliss website - * for the definition of the file format. - * Note that in the DIMACS file the vertices are numbered from 1 to N while - * in this C++ API they are from 0 to N-1. - * Thus the vertex n in the file corresponds to the vertex n-1 in the API. - * - * \param fp the file stream for the graph file - * \param errstr if non-null, the possible error messages are printed - * in this file stream - * \return a new Graph object or 0 if reading failed for some - * reason - */ - static Graph* read_dimacs(FILE* const fp, FILE* const errstr = stderr); - - /** - * Write the graph to a file in a variant of the DIMACS format. - * See the bliss website - * for the definition of the file format. - */ - void write_dimacs(FILE* const fp); - - /** - * \copydoc AbstractGraph::write_dot(FILE * const fp) - */ - void write_dot(FILE* const fp); - - /** - * \copydoc AbstractGraph::write_dot(const char * const file_name) - */ - void write_dot(const char* const file_name); - - - - /** - * \copydoc AbstractGraph::get_hash() - */ - virtual unsigned int get_hash(); - - /** - * Return the number of vertices in the graph. - */ - unsigned int get_nof_vertices() const {return vertices.size(); } - - /** - * \copydoc AbstractGraph::permute(const unsigned int* const perm) const - */ - Graph* permute(const unsigned int* const perm) const; - /** - * \copydoc AbstractGraph::permute(const std::vector& perm) const - */ - Graph* permute(const std::vector& perm) const; - - /** - * \copydoc AbstractGraph::is_automorphism(unsigned int* const perm) const - */ - bool is_automorphism(unsigned int* const perm) const; - - /** - * \copydoc AbstractGraph::is_automorphism(const std::vector& perm) const - */ - bool is_automorphism(const std::vector& perm) const; - - /** - * Add a new vertex with color \a color in the graph and return its index. - */ - unsigned int add_vertex(const unsigned int color = 0); - - /** - * Add an edge between vertices \a v1 and \a v2. - * Duplicate edges between vertices are ignored but try to avoid introducing - * them in the first place as they are not ignored immediately but will - * consume memory and computation resources for a while. - */ - void add_edge(const unsigned int v1, const unsigned int v2); - - /** - * \copydoc AbstractGraph::get_color(const unsigned int vertex) const - */ - unsigned int get_color(const unsigned int vertex) const; - - /** - * Change the color of the vertex \a vertex to \a color. - */ - void change_color(const unsigned int vertex, const unsigned int color); - - /** - * Get a copy of the graph. - */ - Graph* copy() const; - - /** - * Compare this graph to the \a other graph in a total orger on graphs. - * \return 0 if the graphs are equal, - * -1 if this graph is "smaller than" the other, and - * 1 if this graph is "greater than" the other. - */ - int cmp(Graph& other); - - /** - * Set the splitting heuristic used by the automorphism and canonical - * labeling algorithm. - * The selected splitting heuristics affects the computed canonical - * labelings; therefore, if you want to compare whether two graphs - * are isomorphic by computing and comparing (for equality) their - * canonical versions, be sure to use the same splitting heuristics - * for both graphs. - */ - void set_splitting_heuristic(const SplittingHeuristic shs) {sh = shs; } - - -}; - -} // namespace bliss diff --git a/headers/bliss/heap.hh b/headers/bliss/heap.hh deleted file mode 100644 index 8beb2dd..0000000 --- a/headers/bliss/heap.hh +++ /dev/null @@ -1,89 +0,0 @@ -#pragma once - -/* - Copyright (c) 2003-2021 Tommi Junttila - Released under the GNU Lesser General Public License version 3. - - This file is part of bliss. - - bliss is free software: you can redistribute it and/or modify - it under the terms of the GNU Lesser General Public License as published by - the Free Software Foundation, version 3 of the License. - - bliss is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with bliss. If not, see . -*/ - -#include -#include - -namespace bliss { - -/** - * \brief A min-heap of unsigned integers. - */ - -class Heap -{ - std::vector contents; - /** \nternal - * Less-than operator for building min-heaps. - */ - struct { - /** \internal Use greater-than as less-than -> min-heaps. */ - bool operator()(const unsigned int e1, const unsigned int e2) {return e1 > e2; } - } gt; -public: - - /** - * Is the heap empty? - * Time complexity is O(1). - */ - bool is_empty() const {return contents.empty(); } - - /** - * Remove all the elements in the heap. - * Time complexity is O(1). - */ - void clear() {contents.clear(); } - - /** - * Insert the element \a e in the heap. - * Time complexity is O(log(N)), where N is the number of elements - * currently in the heap. - */ - void insert(const unsigned int e) { - contents.push_back(e); - std::push_heap(contents.begin(), contents.end(), gt); - } - - /** - * Return the smallest element in the heap. - * Time complexity is O(1). - */ - unsigned int smallest() const {return contents.front(); } - - /** - * Remove and return the smallest element in the heap. - * Time complexity is O(log(N)), where N is the number of elements - * currently in the heap. - */ - unsigned int remove() { - const unsigned int result = smallest(); - std::pop_heap(contents.begin(),contents.end(), gt); - contents.pop_back(); - return result; - } - - /** - * Get the number of elements in the heap. - */ - size_t size() const {return contents.size(); } -}; - -} // namespace bliss diff --git a/headers/bliss/kqueue.hh b/headers/bliss/kqueue.hh deleted file mode 100644 index 6f52db7..0000000 --- a/headers/bliss/kqueue.hh +++ /dev/null @@ -1,165 +0,0 @@ -#pragma once - -/* - Copyright (c) 2003-2021 Tommi Junttila - Released under the GNU Lesser General Public License version 3. - - This file is part of bliss. - - bliss is free software: you can redistribute it and/or modify - it under the terms of the GNU Lesser General Public License as published by - the Free Software Foundation, version 3 of the License. - - bliss is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with bliss. If not, see . -*/ - -#include -#include - -namespace bliss { - -/** - * \brief A simple implementation of queues with fixed maximum capacity. - */ -template -class KQueue -{ -public: - /** - * Create a new queue with capacity zero. - * The function init() should be called next. - */ - KQueue(); - - ~KQueue(); - - /** - * Initialize the queue to have the capacity to hold at most \a N elements. - */ - void init(const unsigned int N); - - /** Is the queue empty? */ - bool is_empty() const; - - /** Return the number of elements in the queue. */ - unsigned int size() const; - - /** Remove all the elements in the queue. */ - void clear(); - - /** Return (but don't remove) the first element in the queue. */ - Type front() const; - - /** Remove and return the first element of the queue. */ - Type pop_front(); - - /** Push the element \a e in the front of the queue. */ - void push_front(Type e); - - /** Remove and return the last element of the queue. */ - Type pop_back(); - - /** Push the element \a e in the back of the queue. */ - void push_back(Type e); -private: - Type *entries, *end; - Type *head, *tail; -}; - -template -KQueue::KQueue() -{ - entries = nullptr; - end = nullptr; - head = nullptr; - tail = nullptr; -} - -template -KQueue::~KQueue() -{ - delete[] entries; - entries = nullptr; - end = nullptr; - head = nullptr; - tail = nullptr; -} - -template -void KQueue::init(const unsigned int k) -{ - assert(k > 0); - delete[] entries; - entries = new Type[k+1]; - end = entries + k + 1; - head = entries; - tail = head; -} - -template -void KQueue::clear() -{ - head = entries; - tail = head; -} - -template -bool KQueue::is_empty() const -{ - return head == tail; -} - -template -unsigned int KQueue::size() const -{ - if(tail >= head) - return(tail - head); - return (end - head) + (tail - entries); -} - -template -Type KQueue::front() const -{ - assert(head != tail); - return *head; -} - -template -Type KQueue::pop_front() -{ - assert(head != tail); - Type *old_head = head; - head++; - if(head == end) - head = entries; - return *old_head; -} - -template -void KQueue::push_front(Type e) -{ - if(head == entries) - head = end - 1; - else - head--; - assert(head != tail); - *head = e; -} - -template -void KQueue::push_back(Type e) -{ - *tail = e; - tail++; - if(tail == end) - tail = entries; - assert(head != tail); -} - -} // namespace bliss diff --git a/headers/bliss/kstack.hh b/headers/bliss/kstack.hh deleted file mode 100644 index a58ef0d..0000000 --- a/headers/bliss/kstack.hh +++ /dev/null @@ -1,141 +0,0 @@ -#ifndef BLISS_KSTACK_H -#define BLISS_KSTACK_H - -/* - Copyright (c) 2003-2015 Tommi Junttila - Released under the GNU Lesser General Public License version 3. - - This file is part of bliss. - - bliss is free software: you can redistribute it and/or modify - it under the terms of the GNU Lesser General Public License as published by - the Free Software Foundation, version 3 of the License. - - bliss is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with bliss. If not, see . -*/ - -#include -#include "bliss/defs.hh" - -namespace bliss { - -/** \internal - * \brief A very simple implementation of a stack with fixed capacity. - */ -template -class KStack { -public: - /** - * Create a new stack with zero capacity. - * The function init() should be called next. - */ - KStack(); - - /** - * Create a new stack with the capacity to hold at most \a N elements. - */ - KStack(int N); - - ~KStack(); - - /** - * Initialize the stack to have the capacity to hold at most \a N elements. - */ - void init(int N); - - /** - * Is the stack empty? - */ - bool is_empty() const {return(cursor == entries); } - - /** - * Return (but don't remove) the top element of the stack. - */ - Type top() const {BLISS_ASSERT(cursor > entries); return *cursor; } - - /** - * Pop (remove) the top element of the stack. - */ - Type pop() - { - return *cursor--; - } - - /** - * Push the element \a e in the stack. - */ - void push(Type e) - { - *(++cursor) = e; - } - - /** Remove all the elements in the stack. */ - void clean() {cursor = entries; } - - /** - * Get the number of elements in the stack. - */ - unsigned int size() const {return(cursor - entries); } - - /** - * Return the i:th element in the stack, where \a i is in the range - * 0,...,this.size()-1; the 0:th element is the bottom element - * in the stack. - */ - Type element_at(unsigned int i) - { - assert(i < size()); - return entries[i+1]; - } - - /** Return the capacity (NOT the number of elements) of the stack. */ - int capacity() {return kapacity; } -private: - int kapacity; - Type *entries; - Type *cursor; -}; - -template -KStack::KStack() -{ - kapacity = 0; - entries = 0; - cursor = 0; -} - -template -KStack::KStack(int k) -{ - assert(k > 0); - kapacity = k; - entries = (Type*)malloc((k+1) * sizeof(Type)); - cursor = entries; -} - -template -void KStack::init(int k) -{ - assert(k > 0); - if(entries) - free(entries); - kapacity = k; - entries = (Type*)malloc((k+1) * sizeof(Type)); - cursor = entries; -} - -template -KStack::~KStack() -{ - free(entries); -} - -} // namespace bliss - -#endif diff --git a/headers/bliss/orbit.hh b/headers/bliss/orbit.hh deleted file mode 100644 index ead3142..0000000 --- a/headers/bliss/orbit.hh +++ /dev/null @@ -1,109 +0,0 @@ -#pragma once - -/* - Copyright (c) 2003-2021 Tommi Junttila - Released under the GNU Lesser General Public License version 3. - - This file is part of bliss. - - bliss is free software: you can redistribute it and/or modify - it under the terms of the GNU Lesser General Public License as published by - the Free Software Foundation, version 3 of the License. - - bliss is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with bliss. If not, see . -*/ - -namespace bliss { - -/** - * \brief A class for representing orbit information. - * - * Given a set {0,...,N-1} of N elements, represent equivalence - * classes (that is, unordered partitions) of the elements. - * Supports only equivalence class merging, not splitting. - * Merging two classes requires time O(k), where k is the number of - * the elements in the smaller of the merged classes. - * Getting the smallest representative in a class - * (and thus testing whether two elements belong to the same class) - * is a constant time operation. - */ -class Orbit -{ - class OrbitEntry - { - public: - unsigned int element; - OrbitEntry *next; - unsigned int size; - }; - - OrbitEntry *orbits; - OrbitEntry **in_orbit; - unsigned int nof_elements; - unsigned int _nof_orbits; - void merge_orbits(OrbitEntry *o1, OrbitEntry *o2); - -public: - /** - * Create a new orbit information object. - * The init() function must be called next to actually initialize - * the object. - */ - Orbit(); - ~Orbit(); - - /** - * Initialize the orbit information to consider sets of \a N elements. - * It is required that \a N > 0. - * The orbit information is reset so that each element forms - * an orbit of its own. - * Time complexity is O(N). - * \sa reset() - */ - void init(const unsigned int N); - - /** - * Reset the orbits so that each element forms an orbit of its own. - * Time complexity is O(N). - */ - void reset(); - - /** - * Merge the orbits of the elements \a e1 and \a e2. - * Time complexity is O(k), where k is the number of elements in - * the smaller of the merged orbits. - */ - void merge_orbits(unsigned int e1, unsigned int e2); - - /** - * Is the element \a e the smallest element in its orbit? - * Time complexity is O(1). - */ - bool is_minimal_representative(unsigned int e) const; - - /** - * Get the smallest element in the orbit of the element \a e. - * Time complexity is O(1). - */ - unsigned int get_minimal_representative(unsigned int e) const; - - /** - * Get the number of elements in the orbit of the element \a e. - * Time complexity is O(1). - */ - unsigned int orbit_size(unsigned int e) const; - - /** - * Get the number of orbits. - * Time complexity is O(1). - */ - unsigned int nof_orbits() const {return _nof_orbits; } -}; - -} // namespace bliss diff --git a/headers/bliss/partition.hh b/headers/bliss/partition.hh deleted file mode 100644 index f0b36a7..0000000 --- a/headers/bliss/partition.hh +++ /dev/null @@ -1,305 +0,0 @@ -#pragma once - -/* - Copyright (c) 2003-2021 Tommi Junttila - Released under the GNU Lesser General Public License version 3. - - This file is part of bliss. - - bliss is free software: you can redistribute it and/or modify - it under the terms of the GNU Lesser General Public License as published by - the Free Software Foundation, version 3 of the License. - - bliss is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with bliss. If not, see . -*/ - -namespace bliss { - class Partition; -} - -#include -#include -#include "bliss/kqueue.hh" -#include "bliss/abstractgraph.hh" - - -namespace bliss { - -/** - * \brief A class for refinable, backtrackable ordered partitions. - * - * This is rather a data structure with some helper functions than - * a proper self-contained class. - * That is, for efficiency reasons the fields of this class are directly - * manipulated from bliss::AbstractGraph and its subclasses. - * Conversely, some methods of this class modify the fields of - * bliss::AbstractGraph, too. - */ -class Partition -{ -public: - /** - * \brief Data structure for holding information about a cell in a Partition. - */ - class Cell - { - friend class Partition; - public: - unsigned int length; - /* Index of the first element of the cell in - the Partition::elements array */ - unsigned int first; - unsigned int max_ival; - unsigned int max_ival_count; - private: - bool in_splitting_queue; - public: - bool in_neighbour_heap; - /* Pointer to the next cell, null if this is the last one. */ - Cell* next; - Cell* prev; - Cell* next_nonsingleton; - Cell* prev_nonsingleton; - unsigned int split_level; - /** Is this a unit cell? */ - bool is_unit() const {return(length == 1); } - /** Is this cell in splitting queue? */ - bool is_in_splitting_queue() const {return(in_splitting_queue); } - }; - - -private: - - /** \internal - * Data structure for remembering information about splits in order to - * perform efficient backtracking over the splits. - */ - class RefInfo { - public: - unsigned int split_cell_first; - int prev_nonsingleton_first; - int next_nonsingleton_first; - }; - /** \internal - * A stack for remembering the splits, used for backtracking. - */ - std::vector refinement_stack; - - class BacktrackInfo { - public: - unsigned int refinement_stack_size; - unsigned int cr_backtrack_point; - }; - - /** \internal - * The main stack for enabling backtracking. - */ - std::vector bt_stack; - -public: - AbstractGraph* graph; - - /* Used during equitable partition refinement */ - KQueue splitting_queue; - void splitting_queue_add(Cell* const cell); - Cell* splitting_queue_pop(); - bool splitting_queue_is_empty() const; - void splitting_queue_clear(); - - - /** Type for backtracking points. */ - typedef unsigned int BacktrackPoint; - - /** - * Get a new backtrack point for the current partition - */ - BacktrackPoint set_backtrack_point(); - - /** - * Backtrack to the point \a p and remove it. - */ - void goto_backtrack_point(BacktrackPoint p); - - /** - * Split the non-unit Cell \a cell = {\a element,e1,e2,...,en} containing - * the element \a element in two: - * \a cell = {e1,...,en} and \a newcell = {\a element}. - * @param cell a non-unit Cell - * @param element an element in \a cell - * @return the new unit Cell \a newcell - */ - Cell* individualize(Cell* const cell, - const unsigned int element); - - Cell* aux_split_in_two(Cell* const cell, - const unsigned int first_half_size); - - -private: - unsigned int N; - Cell* cells; - Cell* free_cells; - unsigned int discrete_cell_count; -public: - Cell* first_cell; - Cell* first_nonsingleton_cell; - unsigned int *elements; - /* invariant_values[e] gives the invariant value of the element e */ - unsigned int *invariant_values; - /* element_to_cell_map[e] gives the cell of the element e */ - Cell **element_to_cell_map; - /** Get the cell of the element \a e */ - Cell* get_cell(const unsigned int e) const { - assert(e < N); - return element_to_cell_map[e]; - } - /* in_pos[e] points to the elements array s.t. *in_pos[e] = e */ - unsigned int **in_pos; - - Partition(); - ~Partition(); - - /** - * Initialize the partition to the unit partition (all elements in one cell) - * over the \a N > 0 elements {0,...,\a N-1}. - */ - void init(const unsigned int N); - - /** - * Returns true iff the partition is discrete, meaning that all - * the elements are in their own cells. - */ - bool is_discrete() const {return(free_cells == 0); } - - unsigned int nof_discrete_cells() const {return(discrete_cell_count); } - - /** - * Print the partition into the file stream \a fp. - */ - size_t print(FILE* const fp, const bool add_newline = true) const; - - /** - * Print the partition cell sizes into the file stream \a fp. - */ - size_t print_signature(FILE* const fp, const bool add_newline = true) const; - - /* - * Splits the Cell \a cell into [cell_1,...,cell_n] - * according to the invariant_values of the elements in \a cell. - * After splitting, cell_1 == \a cell. - * Returns the pointer to the Cell cell_n; - * cell_n != cell iff the Cell \a cell was actually splitted. - * The flag \a max_ival_info_ok indicates whether the max_ival and - * max_ival_count fields of the Cell \a cell have consistent values - * when the method is called. - * Clears the invariant values of the elements in the Cell \a cell as well as - * the max_ival and max_ival_count fields of the Cell \a cell. - */ - Cell *zplit_cell(Cell * const cell, const bool max_ival_info_ok); - - /* - * Routines for component recursion - */ - void cr_init(); - void cr_free(); - unsigned int cr_get_level(const unsigned int cell_index) const; - unsigned int cr_split_level(const unsigned int level, - const std::vector& cells); - - /** Clear the invariant_values of the elements in the Cell \a cell. */ - void clear_ivs(Cell* const cell); - -private: - /* - * Component recursion data structures - */ - - /* Is component recursion support in use? */ - bool cr_enabled; - - class CRCell { - public: - unsigned int level; - CRCell* next; - CRCell** prev_next_ptr; - void detach() { - if(next) - next->prev_next_ptr = prev_next_ptr; - *(prev_next_ptr) = next; - level = UINT_MAX; - next = nullptr; - prev_next_ptr = nullptr; - } - }; - CRCell* cr_cells; - CRCell** cr_levels; - class CR_BTInfo { - public: - unsigned int created_trail_index; - unsigned int splitted_level_trail_index; - }; - std::vector cr_created_trail; - std::vector cr_splitted_level_trail; - std::vector cr_bt_info; - unsigned int cr_max_level; - void cr_create_at_level(const unsigned int cell_index, unsigned int level); - void cr_create_at_level_trailed(const unsigned int cell_index, unsigned int level); - unsigned int cr_get_backtrack_point(); - void cr_goto_backtrack_point(const unsigned int btpoint); - - - /* - * - * Auxiliary routines for sorting and splitting cells - * - */ - Cell* sort_and_split_cell1(Cell* cell); - Cell* sort_and_split_cell255(Cell* const cell, const unsigned int max_ival); - bool shellsort_cell(Cell* cell); - Cell* split_cell(Cell* const cell); - - /* - * Some auxiliary stuff needed for distribution count sorting. - * To make the code thread-safe (modulo the requirement that each graph is - * only accessed in one thread at a time), the arrays are owned by - * the partition instance, not statically defined. - */ - unsigned int dcs_count[256]; - unsigned int dcs_start[256]; - void dcs_cumulate_count(const unsigned int max); -}; - - -inline Partition::Cell* -Partition::splitting_queue_pop() -{ - assert(!splitting_queue.is_empty()); - Cell* const cell = splitting_queue.pop_front(); - assert(cell->in_splitting_queue); - cell->in_splitting_queue = false; - return cell; -} - -inline bool -Partition::splitting_queue_is_empty() const -{ - return splitting_queue.is_empty(); -} - - -inline unsigned int -Partition::cr_get_level(const unsigned int cell_index) const -{ - assert(cr_enabled); - assert(cell_index < N); - assert(cr_cells[cell_index].level != UINT_MAX); - return(cr_cells[cell_index].level); -} - -} // namespace bliss diff --git a/headers/bliss/stats.hh b/headers/bliss/stats.hh deleted file mode 100644 index 73cc6db..0000000 --- a/headers/bliss/stats.hh +++ /dev/null @@ -1,98 +0,0 @@ -#pragma once - -/* - Copyright (c) 2003-2021 Tommi Junttila - Released under the GNU Lesser General Public License version 3. - - This file is part of bliss. - - bliss is free software: you can redistribute it and/or modify - it under the terms of the GNU Lesser General Public License as published by - the Free Software Foundation, version 3 of the License. - - bliss is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with bliss. If not, see . -*/ - -#include -#include "bliss/abstractgraph.hh" -#include "bliss/bignum.hh" - -namespace bliss { - -/** - * \brief Statistics returned by the bliss search algorithm. - */ -class Stats -{ - friend class AbstractGraph; - /** \internal The size of the automorphism group. */ - BigNum group_size; - /** \internal An approximation (due to possible overflows) of - * the size of the automorphism group. */ - long double group_size_approx; - /** \internal The number of nodes in the search tree. */ - long unsigned int nof_nodes; - /** \internal The number of leaf nodes in the search tree. */ - long unsigned int nof_leaf_nodes; - /** \internal The number of bad nodes in the search tree. */ - long unsigned int nof_bad_nodes; - /** \internal The number of canonical representative updates. */ - long unsigned int nof_canupdates; - /** \internal The number of generator permutations. */ - long unsigned int nof_generators; - /** \internal The maximal depth of the search tree. */ - unsigned long int max_level; - /** \internal Reset the statistics. */ - void reset() - { - group_size.assign(1); - group_size_approx = 1.0; - nof_nodes = 0; - nof_leaf_nodes = 0; - nof_bad_nodes = 0; - nof_canupdates = 0; - nof_generators = 0; - max_level = 0; - } -public: - Stats() { reset(); } - /** Print the statistics. */ - size_t print(FILE* const fp) const - { - size_t r = 0; - r += fprintf(fp, "Nodes: %lu\n", nof_nodes); - r += fprintf(fp, "Leaf nodes: %lu\n", nof_leaf_nodes); - r += fprintf(fp, "Bad nodes: %lu\n", nof_bad_nodes); - r += fprintf(fp, "Canrep updates: %lu\n", nof_canupdates); - r += fprintf(fp, "Generators: %lu\n", nof_generators); - r += fprintf(fp, "Max level: %lu\n", max_level); - r += fprintf(fp, "|Aut|: ")+group_size.print(fp)+fprintf(fp, "\n"); - fflush(fp); - return r; - } - /** The size of the automorphism group. */ - const BigNum& get_group_size() const {return group_size;} - /** An approximation (due to possible overflows/rounding errors) of - * the size of the automorphism group. */ - long double get_group_size_approx() const {return group_size_approx;} - /** The number of nodes in the search tree. */ - long unsigned int get_nof_nodes() const {return nof_nodes;} - /** The number of leaf nodes in the search tree. */ - long unsigned int get_nof_leaf_nodes() const {return nof_leaf_nodes;} - /** The number of bad nodes in the search tree. */ - long unsigned int get_nof_bad_nodes() const {return nof_bad_nodes;} - /** The number of canonical representative updates. */ - long unsigned int get_nof_canupdates() const {return nof_canupdates;} - /** The number of generator permutations. */ - long unsigned int get_nof_generators() const {return nof_generators;} - /** The maximal depth of the search tree. */ - unsigned long int get_max_level() const {return max_level;} -}; - -} // namespace bliss diff --git a/headers/bliss/timer.hh b/headers/bliss/timer.hh deleted file mode 100644 index c35f51e..0000000 --- a/headers/bliss/timer.hh +++ /dev/null @@ -1,57 +0,0 @@ -#pragma once - -/* - Copyright (c) 2003-2021 Tommi Junttila - Released under the GNU Lesser General Public License version 3. - - This file is part of bliss. - - bliss is free software: you can redistribute it and/or modify - it under the terms of the GNU Lesser General Public License as published by - the Free Software Foundation, version 3 of the License. - - bliss is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with bliss. If not, see . -*/ - - -#include - -namespace bliss { - -/** - * \brief A simple helper class for measuring elapsed time. - */ -class Timer -{ - std::chrono::high_resolution_clock::time_point start_time_; -public: - /** - * \brief Create and start a new timer. - */ - Timer() { - reset(); - } - - /** - * \brief Reset the timer. - */ - void reset() { - start_time_ = std::chrono::high_resolution_clock::now(); - } - - /** - * \brief Get the time (in seconds) elapsed since - * the creation or the last reset() call of the timer. - */ - double get_duration() const { - return std::chrono::duration_cast >(std::chrono::high_resolution_clock::now() - start_time_).count(); - } -}; - -} // namespace bliss diff --git a/headers/bliss/uintseqhash.hh b/headers/bliss/uintseqhash.hh deleted file mode 100644 index adc3173..0000000 --- a/headers/bliss/uintseqhash.hh +++ /dev/null @@ -1,60 +0,0 @@ -#pragma once - -/* - Copyright (c) 2003-2021 Tommi Junttila - Released under the GNU Lesser General Public License version 3. - - This file is part of bliss. - - bliss is free software: you can redistribute it and/or modify - it under the terms of the GNU Lesser General Public License as published by - the Free Software Foundation, version 3 of the License. - - bliss is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with bliss. If not, see . -*/ - -namespace bliss { - -/** - * \brief A updatable hash for sequences of unsigned ints. - */ -class UintSeqHash -{ -protected: - unsigned int h; -public: - UintSeqHash() {h = 0; } - UintSeqHash(const UintSeqHash &other) {h = other.h; } - UintSeqHash& operator=(const UintSeqHash &other) {h = other.h; return *this; } - - /** Reset the hash value. */ - void reset() {h = 0; } - - /** Add the unsigned int \a n to the sequence. */ - void update(unsigned int n); - - /** Get the hash value of the sequence seen so far. */ - unsigned int get_value() const {return h; } - - /** Compare the hash values of this and \a other. - * Return -1/0/1 if the value of this is smaller/equal/greater than - * that of \a other. */ - int cmp(const UintSeqHash &other) const { - return (h < other.h)?-1:((h == other.h)?0:1); - } - /** An abbreviation for cmp(other) < 0 */ - bool is_lt(const UintSeqHash &other) const {return cmp(other) < 0; } - /** An abbreviation for cmp(other) <= 0 */ - bool is_le(const UintSeqHash &other) const {return cmp(other) <= 0; } - /** An abbreviation for cmp(other) == 0 */ - bool is_equal(const UintSeqHash &other) const {return cmp(other) == 0; } -}; - - -} // namespace bliss diff --git a/headers/bliss/utils.hh b/headers/bliss/utils.hh deleted file mode 100644 index 40b3f92..0000000 --- a/headers/bliss/utils.hh +++ /dev/null @@ -1,68 +0,0 @@ -#pragma once - -/* - Copyright (c) 2003-2021 Tommi Junttila - Released under the GNU Lesser General Public License version 3. - - This file is part of bliss. - - bliss is free software: you can redistribute it and/or modify - it under the terms of the GNU Lesser General Public License as published by - the Free Software Foundation, version 3 of the License. - - bliss is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with bliss. If not, see . -*/ - -/** - * \file - * \brief Some small utilities. - */ - -#include -#include - -//SV https://en.cppreference.com/w/cpp/language/operator_alternative -#include - -namespace bliss { - -/** - * Print the permutation \a perm of {0,...,N-1} in the cycle format - * in the file stream \a fp. - * The amount \a offset is added to each element before printing, - * e.g. the permutation (2 4) is printed as (3 5) when \a offset is 1. - */ -size_t print_permutation(FILE* fp, - const unsigned int N, - const unsigned int* perm, - const unsigned int offset = 0); - -/** - * Print the permutation \a perm of {0,...,N-1} in the cycle format - * in the file stream \a fp. - * The amount \a offset is added to each element before printing, - * e.g. the permutation (2 4) is printed as (3 5) when \a offset is 1. - */ -size_t print_permutation(FILE* fp, - const std::vector& perm, - const unsigned int offset = 0); - -/** - * Check whether \a perm is a valid permutation on {0,...,N-1}. - * Slow, mainly for debugging and validation purposes. - */ -bool is_permutation(const unsigned int N, const unsigned int* perm); - -/** - * Check whether \a perm is a valid permutation on {0,...,N-1}. - * Slow, mainly for debugging and validation purposes. - */ -bool is_permutation(const std::vector& perm); - -} // namespace bliss diff --git a/headers/blockmemshell/memory.h b/headers/blockmemshell/memory.h deleted file mode 100644 index ce198c8..0000000 --- a/headers/blockmemshell/memory.h +++ /dev/null @@ -1,897 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* */ -/* This file is part of the library */ -/* BMS --- Block Memory Shell */ -/* */ -/* Copyright 2002-2022 Zuse Institute Berlin */ -/* */ -/* Licensed under the Apache License, Version 2.0 (the "License"); */ -/* you may not use this file except in compliance with the License. */ -/* You may obtain a copy of the License at */ -/* */ -/* http://www.apache.org/licenses/LICENSE-2.0 */ -/* */ -/* Unless required by applicable law or agreed to in writing, software */ -/* distributed under the License is distributed on an "AS IS" BASIS, */ -/* 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. */ -/* */ -/* You should have received a copy of the Apache-2.0 license */ -/* along with SCIP; see the file LICENSE. If not visit scipopt.org. */ -/* */ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -/**@file memory.h - * @brief memory allocation routines - * @author Tobias Achterberg - * @author Gerald Gamrath - * @author Marc Pfetsch - */ - -/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/ - -#ifndef __BMS_MEMORY_H__ -#define __BMS_MEMORY_H__ - -#include -#include -#include - -/* - * include build configuration flags - */ -#ifndef NO_CONFIG_HEADER -#include "scip/config.h" -#include "scip/scip_export.h" -#endif - -#ifdef __cplusplus - - -/* special thanks to Daniel Junglas for following template and macros */ - -template T* docast(T*, void *v); -template T* docast(T*, void *v) { return reinterpret_cast(v); } - -/* For C++11, we can easily check whether the types for memory functions like BMSduplicateXYZArray() are equal. */ -#if __cplusplus > 199711L -#include - -/* the following adds a type check for the parameters, used in ASSIGNCHECK below */ -template T1* docastcheck(T1* v1, void* v, T2* v2) -{ - typedef typename std::remove_const::type t1; - typedef typename std::remove_const::type t2; - static_assert(std::is_same::value, "need equal types"); - return reinterpret_cast(v); -} -#else -/* for older compilers do nothing */ -template T1* docastcheck(T1* v1, void* v, T2* v2) { return reinterpret_cast(v); } -#endif - - -extern "C" { - -#define ASSIGN(pointerstarstar, voidstarfunction) (*(pointerstarstar) = docast(*(pointerstarstar), (voidstarfunction))) -#define ASSIGNCHECK(pointerstarstar, voidstarfunction, origpointer) (*(pointerstarstar) = docastcheck(*(pointerstarstar), (voidstarfunction), (origpointer))) - -#else - -#define ASSIGN(pointerstarstar, voidstarfunction) (*(pointerstarstar) = (voidstarfunction)) -#define ASSIGNCHECK(pointerstarstar, voidstarfunction, origpointer) (*(pointerstarstar) = (voidstarfunction)) - -#endif - -/* - * Define the macro SCIP_EXPORT depending if the OS is Windows or not - */ -#ifndef SCIP_EXPORT - -#if defined(_WIN32) || defined(_WIN64) -#define SCIP_EXPORT __declspec(dllexport) -#elif defined(__GNUC__) && __GNUC__ >= 4 -#define SCIP_EXPORT __attribute__((__visibility__("default"))) -#else -#define SCIP_EXPORT -#endif - -#endif - -/* define if not already existing to make file independent from def.h */ -#ifndef SCIP_UNUSED -#define SCIP_UNUSED(x) ((void) (x)) -#endif - - -/************************************************************************************* - * Standard Memory Management - * - * In debug mode, these methods extend malloc() and free() by logging all currently - * allocated memory elements in an allocation list. This can be used as a simple leak - * detection. - *************************************************************************************/ - -/* Note: values that are passed as a size_t parameter are first converted to ptrdiff_t to be sure that negative numbers - * are extended to the larger size. Then they are converted to size_t. Thus, negative numbers are converted to very - * large size_t values. This is then checked within the functions. */ - -#define BMSallocMemory(ptr) ASSIGN((ptr), BMSallocMemory_call( sizeof(**(ptr)), __FILE__, __LINE__ )) -#define BMSallocClearMemory(ptr) ASSIGN((ptr), BMSallocClearMemory_call((size_t)(1), sizeof(**(ptr)), __FILE__, __LINE__ )) -#define BMSallocMemorySize(ptr,size) ASSIGN((ptr), BMSallocMemory_call( (size_t)(ptrdiff_t)(size), __FILE__, __LINE__ )) -#define BMSallocMemoryCPP(size) BMSallocMemory_call( (size_t)(ptrdiff_t)(size), __FILE__, __LINE__ ) -#define BMSallocClearMemorySize(ptr,size) ASSIGN((ptr), BMSallocClearMemory_call((size_t)(1), (size_t)(ptrdiff_t)(size), __FILE__, __LINE__ )) -#define BMSallocMemoryArray(ptr,num) ASSIGN((ptr), BMSallocMemoryArray_call((size_t)(ptrdiff_t)(num), sizeof(**(ptr)), __FILE__, __LINE__ )) -#define BMSallocMemoryArrayCPP(num,size) BMSallocMemoryArray_call( (size_t)(ptrdiff_t)(num), (size_t)(ptrdiff_t)(size), __FILE__, __LINE__ ) -#define BMSallocClearMemoryArray(ptr,num) ASSIGN((ptr), BMSallocClearMemory_call((size_t)(ptrdiff_t)(num), sizeof(**(ptr)), __FILE__, __LINE__ )) -#define BMSreallocMemorySize(ptr,size) ASSIGN((ptr), BMSreallocMemory_call((void*)(*(ptr)), (size_t)(ptrdiff_t)(size), __FILE__, __LINE__ )) -#define BMSreallocMemoryArray(ptr,num) ASSIGN((ptr), BMSreallocMemoryArray_call( *(ptr), (size_t)(ptrdiff_t)(num), sizeof(**(ptr)), __FILE__, __LINE__ )) - -#define BMSclearMemory(ptr) BMSclearMemory_call( (void*)(ptr), sizeof(*(ptr)) ) -#define BMSclearMemoryArray(ptr, num) BMSclearMemory_call( (void*)(ptr), (size_t)(ptrdiff_t)(num)*sizeof(*(ptr)) ) -#define BMSclearMemorySize(ptr, size) BMSclearMemory_call( (void*)(ptr), (size_t)(ptrdiff_t)(size) ) - -#define BMScopyMemory(ptr, source) BMScopyMemory_call( (void*)(ptr), (const void*)(source), sizeof(*(ptr)) ) -#define BMScopyMemoryArray(ptr, source, num) BMScopyMemory_call( (void*)(ptr), (const void*)(source), (size_t)(ptrdiff_t)(num)*sizeof(*(ptr)) ) -#define BMScopyMemorySize(ptr, source, size) BMScopyMemory_call( (void*)(ptr), (const void*)(source), (size_t)(ptrdiff_t)(size) ) - -#define BMSmoveMemory(ptr, source) BMSmoveMemory_call( (void*)(ptr), (const void*)(source), sizeof(*(ptr)) ) -#define BMSmoveMemoryArray(ptr, source, num) BMSmoveMemory_call( (void*)(ptr), (const void*)(source), (size_t)(ptrdiff_t)(num) * sizeof(*(ptr)) ) -#define BMSmoveMemorySize(ptr, source, size) BMSmoveMemory_call( (void*)(ptr), (const void*)(source), (size_t)(ptrdiff_t)(size) ) - -#define BMSduplicateMemory(ptr, source) ASSIGN((ptr), BMSduplicateMemory_call( (const void*)(source), sizeof(**(ptr)), __FILE__, __LINE__ )) -#define BMSduplicateMemorySize(ptr, source, size) ASSIGN((ptr), BMSduplicateMemory_call( (const void*)(source), (size_t)(ptrdiff_t)(size), __FILE__, __LINE__ )) -#define BMSduplicateMemoryArray(ptr, source, num) ASSIGNCHECK((ptr), BMSduplicateMemoryArray_call( (const void*)(source), (size_t)(ptrdiff_t)(num), \ - sizeof(**(ptr)), __FILE__, __LINE__ ), source) -#define BMSfreeMemory(ptr) BMSfreeMemory_call( (void**)(ptr), __FILE__, __LINE__ ) -#define BMSfreeMemoryNull(ptr) BMSfreeMemoryNull_call( (void**)(ptr), __FILE__, __LINE__ ) -#define BMSfreeMemoryArray(ptr) BMSfreeMemory_call( (void**)(ptr), __FILE__, __LINE__ ) -#define BMSfreeMemoryArrayNull(ptr) BMSfreeMemoryNull_call( (void**)(ptr), __FILE__, __LINE__ ) -#define BMSfreeMemorySize(ptr) BMSfreeMemory_call( (void**)(ptr), __FILE__, __LINE__ ) -#define BMSfreeMemorySizeNull(ptr) BMSfreeMemoryNull_call( (void**)(ptr), __FILE__, __LINE__ ) - -#ifndef NDEBUG -#define BMSgetPointerSize(ptr) BMSgetPointerSize_call(ptr) -#define BMSdisplayMemory() BMSdisplayMemory_call() -#define BMScheckEmptyMemory() BMScheckEmptyMemory_call() -#define BMSgetMemoryUsed() BMSgetMemoryUsed_call() -#else -#define BMSgetPointerSize(ptr) 0 -#define BMSdisplayMemory() /**/ -#define BMScheckEmptyMemory() /**/ -#define BMSgetMemoryUsed() 0LL -#endif - -/** allocates array and initializes it with 0; returns NULL if memory allocation failed */ -SCIP_EXPORT -void* BMSallocClearMemory_call( - size_t num, /**< number of memory element to allocate */ - size_t typesize, /**< size of memory element to allocate */ - const char* filename, /**< source file where the allocation is performed */ - int line /**< line number in source file where the allocation is performed */ - ); - -/** allocates memory; returns NULL if memory allocation failed */ -SCIP_EXPORT -void* BMSallocMemory_call( - size_t size, /**< size of memory element to allocate */ - const char* filename, /**< source file where the allocation is performed */ - int line /**< line number in source file where the allocation is performed */ - ); - -/** allocates array; returns NULL if memory allocation failed */ -SCIP_EXPORT -void* BMSallocMemoryArray_call( - size_t num, /**< number of components of array to allocate */ - size_t typesize, /**< size of each component */ - const char* filename, /**< source file where the allocation is performed */ - int line /**< line number in source file where the allocation is performed */ - ); - -/** allocates memory; returns NULL if memory allocation failed */ -SCIP_EXPORT -void* BMSreallocMemory_call( - void* ptr, /**< pointer to memory to reallocate */ - size_t size, /**< new size of memory element */ - const char* filename, /**< source file where the reallocation is performed */ - int line /**< line number in source file where the reallocation is performed */ - ); - -/** reallocates array; returns NULL if memory allocation failed */ -SCIP_EXPORT -void* BMSreallocMemoryArray_call( - void* ptr, /**< pointer to memory to reallocate */ - size_t num, /**< number of components of array to allocate */ - size_t typesize, /**< size of each component */ - const char* filename, /**< source file where the reallocation is performed */ - int line /**< line number in source file where the reallocation is performed */ - ); - -/** clears a memory element (i.e. fills it with zeros) */ -SCIP_EXPORT -void BMSclearMemory_call( - void* ptr, /**< pointer to memory element */ - size_t size /**< size of memory element */ - ); - -/** copies the contents of one memory element into another memory element */ -SCIP_EXPORT -void BMScopyMemory_call( - void* ptr, /**< pointer to target memory element */ - const void* source, /**< pointer to source memory element */ - size_t size /**< size of memory element to copy */ - ); - -/** moves the contents of one memory element into another memory element, should be used if both elements overlap, - * otherwise BMScopyMemory is faster - */ -SCIP_EXPORT -void BMSmoveMemory_call( - void* ptr, /**< pointer to target memory element */ - const void* source, /**< pointer to source memory element */ - size_t size /**< size of memory element to copy */ - ); - -/** allocates memory and copies the contents of the given memory element into the new memory element */ -SCIP_EXPORT -void* BMSduplicateMemory_call( - const void* source, /**< pointer to source memory element */ - size_t size, /**< size of memory element to copy */ - const char* filename, /**< source file where the duplication is performed */ - int line /**< line number in source file where the duplication is performed */ - ); - -/** allocates array and copies the contents of the given source array into the new array */ -SCIP_EXPORT -void* BMSduplicateMemoryArray_call( - const void* source, /**< pointer to source memory element */ - size_t num, /**< number of components of array to allocate */ - size_t typesize, /**< size of each component */ - const char* filename, /**< source file where the duplication is performed */ - int line /**< line number in source file where the duplication is performed */ - ); - -/** frees an allocated memory element and sets pointer to NULL */ -SCIP_EXPORT -void BMSfreeMemory_call( - void** ptr, /**< pointer to pointer to memory element */ - const char* filename, /**< source file where the deallocation is performed */ - int line /**< line number in source file where the deallocation is performed */ - ); - -/** frees an allocated memory element if pointer is not NULL and sets pointer to NULL */ -SCIP_EXPORT -void BMSfreeMemoryNull_call( - void** ptr, /**< pointer to pointer to memory element */ - const char* filename, /**< source file where the deallocation is performed */ - int line /**< line number in source file where the deallocation is performed */ - ); - -/** returns the size of an allocated memory element */ -SCIP_EXPORT -size_t BMSgetPointerSize_call( - const void* ptr /**< pointer to allocated memory */ - ); - -/** outputs information about currently allocated memory to the screen */ -SCIP_EXPORT -void BMSdisplayMemory_call( - void - ); - -/** displays a warning message on the screen, if allocated memory exists */ -SCIP_EXPORT -void BMScheckEmptyMemory_call( - void - ); - -/** returns total number of allocated bytes */ -SCIP_EXPORT -long long BMSgetMemoryUsed_call( - void - ); - - - - -/******************************************************************** - * Chunk Memory Management - * - * Efficient memory management for multiple objects of the same size - ********************************************************************/ - -typedef struct BMS_ChkMem BMS_CHKMEM; /**< collection of memory chunks of the same element size */ - - -#ifndef BMS_NOBLOCKMEM - -#define BMScreateChunkMemory(sz,isz,gbf) BMScreateChunkMemory_call( (sz), (isz), (gbf), __FILE__, __LINE__ ) -#define BMSclearChunkMemory(mem) BMSclearChunkMemory_call( (mem), __FILE__, __LINE__ ) -#define BMSdestroyChunkMemory(mem) BMSdestroyChunkMemory_call( (mem), __FILE__, __LINE__ ) - -#define BMSallocChunkMemory(mem,ptr) ASSIGN((ptr), BMSallocChunkMemory_call((mem), sizeof(**(ptr)), __FILE__, __LINE__)) -#define BMSduplicateChunkMemory(mem, ptr, source) ASSIGN((ptr), BMSduplicateChunkMemory_call((mem), (const void*)(source), \ - sizeof(**(ptr)), __FILE__, __LINE__ )) -#define BMSfreeChunkMemory(mem,ptr) BMSfreeChunkMemory_call( (mem), (void**)(ptr), sizeof(**(ptr)), __FILE__, __LINE__ ) -#define BMSfreeChunkMemoryNull(mem,ptr) BMSfreeChunkMemoryNull_call( (mem), (void**)(ptr), sizeof(**(ptr)), __FILE__, __LINE__ ) -#define BMSgarbagecollectChunkMemory(mem) BMSgarbagecollectChunkMemory_call(mem) -#define BMSgetChunkMemoryUsed(mem) BMSgetChunkMemoryUsed_call(mem) - -#else - -/* block memory management mapped to standard memory management */ - -#define BMScreateChunkMemory(sz,isz,gbf) (void*)(0x01) /* dummy to not return a NULL pointer */ -#define BMSclearChunkMemory(mem) /**/ -#define BMSclearChunkMemoryNull(mem) /**/ -#define BMSdestroyChunkMemory(mem) /**/ -#define BMSdestroyChunkMemoryNull(mem) /**/ -#define BMSallocChunkMemory(mem,ptr) BMSallocMemory(ptr) -#define BMSduplicateChunkMemory(mem, ptr, source) BMSduplicateMemory(ptr,source) -#define BMSfreeChunkMemory(mem,ptr) BMSfreeMemory(ptr) -#define BMSfreeChunkMemoryNull(mem,ptr) BMSfreeMemoryNull(ptr) -#define BMSgarbagecollectChunkMemory(mem) /**/ -#define BMSgetChunkMemoryUsed(mem) 0LL - -#endif - - -/** aligns the given byte size corresponding to the minimal alignment for chunk and block memory */ -SCIP_EXPORT -void BMSalignMemsize( - size_t* size /**< pointer to the size to align */ - ); - -/** checks whether the given size meets the alignment conditions for chunk and block memory */ -SCIP_EXPORT -int BMSisAligned( - size_t size /**< size to check for alignment */ - ); - -/** creates a new chunk block data structure */ -SCIP_EXPORT -BMS_CHKMEM* BMScreateChunkMemory_call( - size_t size, /**< element size of the chunk block */ - int initchunksize, /**< number of elements in the first chunk of the chunk block */ - int garbagefactor, /**< garbage collector is called, if at least garbagefactor * avg. chunksize - * elements are free (-1: disable garbage collection) */ - const char* filename, /**< source file of the function call */ - int line /**< line number in source file of the function call */ - ); - -/** clears a chunk block data structure */ -SCIP_EXPORT -void BMSclearChunkMemory_call( - BMS_CHKMEM* chkmem, /**< chunk block */ - const char* filename, /**< source file of the function call */ - int line /**< line number in source file of the function call */ - ); - -/** destroys and frees a chunk block data structure */ -SCIP_EXPORT -void BMSdestroyChunkMemory_call( - BMS_CHKMEM** chkmem, /**< pointer to chunk block */ - const char* filename, /**< source file of the function call */ - int line /**< line number in source file of the function call */ - ); - -/** allocates a memory element of the given chunk block */ -SCIP_EXPORT -void* BMSallocChunkMemory_call( - BMS_CHKMEM* chkmem, /**< chunk block */ - size_t size, /**< size of memory element to allocate (only needed for sanity check) */ - const char* filename, /**< source file of the function call */ - int line /**< line number in source file of the function call */ - ); - -/** duplicates a given memory element by allocating a new element of the same chunk block and copying the data */ -SCIP_EXPORT -void* BMSduplicateChunkMemory_call( - BMS_CHKMEM* chkmem, /**< chunk block */ - const void* source, /**< source memory element */ - size_t size, /**< size of memory element to allocate (only needed for sanity check) */ - const char* filename, /**< source file of the function call */ - int line /**< line number in source file of the function call */ - ); - -/** frees a memory element of the given chunk block and sets pointer to NULL */ -SCIP_EXPORT -void BMSfreeChunkMemory_call( - BMS_CHKMEM* chkmem, /**< chunk block */ - void** ptr, /**< pointer to pointer to memory element to free */ - size_t size, /**< size of memory element to allocate (only needed for sanity check) */ - const char* filename, /**< source file of the function call */ - int line /**< line number in source file of the function call */ - ); - -/** frees a memory element of the given chunk block if pointer is not NULL and sets pointer to NULL */ -SCIP_EXPORT -void BMSfreeChunkMemoryNull_call( - BMS_CHKMEM* chkmem, /**< chunk block */ - void** ptr, /**< pointer to pointer to memory element to free */ - size_t size, /**< size of memory element to allocate (only needed for sanity check) */ - const char* filename, /**< source file of the function call */ - int line /**< line number in source file of the function call */ - ); - -/** calls garbage collection of chunk block and frees chunks without allocated memory elements */ -SCIP_EXPORT -void BMSgarbagecollectChunkMemory_call( - BMS_CHKMEM* chkmem /**< chunk block */ - ); - -/** returns the number of allocated bytes in the chunk block */ -SCIP_EXPORT -long long BMSgetChunkMemoryUsed_call( - const BMS_CHKMEM* chkmem /**< chunk block */ - ); - - - - -/*********************************************************** - * Block Memory Management - * - * Efficient memory management for objects of varying sizes - ***********************************************************/ - -typedef struct BMS_BlkMem BMS_BLKMEM; /**< block memory: collection of chunk blocks */ - -#ifndef BMS_NOBLOCKMEM - -/* block memory methods for faster memory access */ - -/* Note: values that are passed as a size_t parameter are first converted to ptrdiff_t to be sure that negative numbers - * are extended to the larger size. Then they are converted to size_t. Thus, negative numbers are converted to very - * large size_t values. This is then checked within the functions. */ - -#define BMScreateBlockMemory(csz,gbf) BMScreateBlockMemory_call( (csz), (gbf), __FILE__, __LINE__ ) -#define BMSclearBlockMemory(mem) BMSclearBlockMemory_call( (mem), __FILE__, __LINE__ ) -#define BMSdestroyBlockMemory(mem) BMSdestroyBlockMemory_call( (mem), __FILE__, __LINE__ ) - -#define BMSallocBlockMemory(mem,ptr) ASSIGN((ptr), BMSallocBlockMemory_call((mem), sizeof(**(ptr)), __FILE__, __LINE__)) -#define BMSallocClearBlockMemory(mem,ptr) ASSIGN((ptr), BMSallocClearBlockMemory_call((mem), sizeof(**(ptr)), __FILE__, __LINE__)) -#define BMSallocBlockMemorySize(mem,ptr,size) ASSIGN((ptr), BMSallocBlockMemory_call((mem), (size_t)(ptrdiff_t)(size), __FILE__, __LINE__)) -#define BMSallocBlockMemoryArray(mem,ptr,num) ASSIGN((ptr), BMSallocBlockMemoryArray_call((mem), (size_t)(ptrdiff_t)(num), sizeof(**(ptr)), __FILE__, __LINE__)) -#define BMSallocClearBlockMemoryArray(mem,ptr,num) ASSIGN((ptr), BMSallocClearBlockMemoryArray_call((mem), (size_t)(ptrdiff_t)(num), sizeof(**(ptr)), __FILE__, __LINE__)) -#define BMSreallocBlockMemorySize(mem,ptr,oldsize,newsize) ASSIGN((ptr), BMSreallocBlockMemory_call((mem), (void*)(*(ptr)), \ - (size_t)(ptrdiff_t)(oldsize), (size_t)(ptrdiff_t)(newsize), __FILE__, __LINE__)) -#define BMSreallocBlockMemoryArray(mem,ptr,oldnum,newnum) ASSIGN((ptr), BMSreallocBlockMemoryArray_call((mem), (void*)(*(ptr)), \ - (size_t)(ptrdiff_t)(oldnum), (size_t)(ptrdiff_t)(newnum), sizeof(**(ptr)), __FILE__, __LINE__)) -#define BMSduplicateBlockMemory(mem, ptr, source) ASSIGN((ptr), BMSduplicateBlockMemory_call((mem), (const void*)(source), \ - sizeof(**(ptr)), __FILE__, __LINE__ )) -#define BMSduplicateBlockMemoryArray(mem, ptr, source, num) ASSIGNCHECK((ptr), BMSduplicateBlockMemoryArray_call( (mem), (const void*)(source), \ - (size_t)(ptrdiff_t)(num), sizeof(**(ptr)), __FILE__, __LINE__ ), source) - -#define BMSfreeBlockMemory(mem,ptr) BMSfreeBlockMemory_call( (mem), (void**)(ptr), sizeof(**(ptr)), __FILE__, __LINE__ ) -#define BMSfreeBlockMemoryNull(mem,ptr) BMSfreeBlockMemoryNull_call( (mem), (void**)(ptr), sizeof(**(ptr)), __FILE__, __LINE__ ) -#define BMSfreeBlockMemoryArray(mem,ptr,num) BMSfreeBlockMemory_call( (mem), (void**)(ptr), (num)*sizeof(**(ptr)), __FILE__, __LINE__ ) -#define BMSfreeBlockMemoryArrayNull(mem,ptr,num) BMSfreeBlockMemoryNull_call( (mem), (void**)(ptr), (num)*sizeof(**(ptr)), __FILE__, __LINE__ ) -#define BMSfreeBlockMemorySize(mem,ptr,size) BMSfreeBlockMemory_call( (mem), (void**)(ptr), (size_t)(ptrdiff_t)(size), __FILE__, __LINE__ ) -#define BMSfreeBlockMemorySizeNull(mem,ptr,size) BMSfreeBlockMemory_call( (mem), (void**)(ptr), (size_t)(ptrdiff_t)(size), __FILE__, __LINE__ ) - -#define BMSgarbagecollectBlockMemory(mem) BMSgarbagecollectBlockMemory_call(mem) -#define BMSgetBlockMemoryAllocated(mem) BMSgetBlockMemoryAllocated_call(mem) -#define BMSgetBlockMemoryUsed(mem) BMSgetBlockMemoryUsed_call(mem) -#define BMSgetBlockMemoryUnused(mem) BMSgetBlockMemoryUnused_call(mem) -#define BMSgetBlockMemoryUsedMax(mem) BMSgetBlockMemoryUsedMax_call(mem) -#define BMSgetBlockMemoryUnusedMax(mem) BMSgetBlockMemoryUnusedMax_call(mem) -#define BMSgetBlockMemoryAllocatedMax(mem) BMSgetBlockMemoryAllocatedMax_call(mem) -#define BMSgetBlockPointerSize(mem,ptr) BMSgetBlockPointerSize_call((mem), (ptr)) -#define BMSdisplayBlockMemory(mem) BMSdisplayBlockMemory_call(mem) -#define BMSblockMemoryCheckEmpty(mem) BMScheckEmptyBlockMemory_call(mem) - -#else - -/* block memory management mapped to standard memory management */ - -#define BMScreateBlockMemory(csz,gbf) (SCIP_UNUSED(csz), SCIP_UNUSED(gbf), (void*)(0x01)) /* dummy to not return a NULL pointer */ -#define BMSclearBlockMemory(mem) SCIP_UNUSED(mem) -#define BMSclearBlockMemoryNull(mem) SCIP_UNUSED(mem) -#define BMSdestroyBlockMemory(mem) SCIP_UNUSED(mem) -#define BMSdestroyBlockMemoryNull(mem) SCIP_UNUSED(mem) -#define BMSallocBlockMemory(mem,ptr) (SCIP_UNUSED(mem), BMSallocMemory(ptr)) -#define BMSallocClearBlockMemory(mem,ptr) (SCIP_UNUSED(mem), BMSallocClearMemory(ptr)) -#define BMSallocBlockMemoryArray(mem,ptr,num) (SCIP_UNUSED(mem), BMSallocMemoryArray(ptr,num)) -#define BMSallocClearBlockMemoryArray(mem,ptr,num) (SCIP_UNUSED(mem), BMSallocClearMemoryArray(ptr,num)) -#define BMSallocBlockMemorySize(mem,ptr,size) (SCIP_UNUSED(mem), BMSallocMemorySize(ptr,size)) -#define BMSreallocBlockMemoryArray(mem,ptr,oldnum,newnum) (SCIP_UNUSED(mem), SCIP_UNUSED(oldnum), BMSreallocMemoryArray(ptr,newnum)) -#define BMSreallocBlockMemorySize(mem,ptr,oldsize,newsize) (SCIP_UNUSED(mem), SCIP_UNUSED(oldsize), BMSreallocMemorySize(ptr,newsize)) -#define BMSduplicateBlockMemory(mem, ptr, source) (SCIP_UNUSED(mem), BMSduplicateMemory(ptr,source)) -#define BMSduplicateBlockMemoryArray(mem, ptr, source, num) (SCIP_UNUSED(mem), BMSduplicateMemoryArray(ptr,source,num)) -#define BMSfreeBlockMemory(mem,ptr) (SCIP_UNUSED(mem), BMSfreeMemory(ptr)) -#define BMSfreeBlockMemoryNull(mem,ptr) (SCIP_UNUSED(mem), BMSfreeMemoryNull(ptr)) -#define BMSfreeBlockMemoryArray(mem,ptr,num) (SCIP_UNUSED(mem), SCIP_UNUSED(num), BMSfreeMemoryArray(ptr)) -#define BMSfreeBlockMemoryArrayNull(mem,ptr,num) (SCIP_UNUSED(mem), SCIP_UNUSED(num), BMSfreeMemoryArrayNull(ptr)) -#define BMSfreeBlockMemorySize(mem,ptr,size) (SCIP_UNUSED(mem), SCIP_UNUSED(size), BMSfreeMemory(ptr)) -#define BMSfreeBlockMemorySizeNull(mem,ptr,size) (SCIP_UNUSED(mem), SCIP_UNUSED(size), BMSfreeMemoryNull(ptr)) -#define BMSgarbagecollectBlockMemory(mem) SCIP_UNUSED(mem) -#define BMSgetBlockMemoryAllocated(mem) (SCIP_UNUSED(mem), 0LL) -#define BMSgetBlockMemoryUsed(mem) (SCIP_UNUSED(mem), 0LL) -#define BMSgetBlockMemoryUnused(mem) (SCIP_UNUSED(mem), 0LL) -#define BMSgetBlockMemoryUsedMax(mem) (SCIP_UNUSED(mem), 0LL) -#define BMSgetBlockMemoryUnusedMax(mem) (SCIP_UNUSED(mem), 0LL) -#define BMSgetBlockMemoryAllocatedMax(mem) (SCIP_UNUSED(mem), 0LL) -#define BMSgetBlockPointerSize(mem,ptr) (SCIP_UNUSED(mem), SCIP_UNUSED(ptr), 0) -#define BMSdisplayBlockMemory(mem) SCIP_UNUSED(mem) -#define BMSblockMemoryCheckEmpty(mem) (SCIP_UNUSED(mem), 0LL) - -#endif - - -/** creates a block memory allocation data structure */ -SCIP_EXPORT -BMS_BLKMEM* BMScreateBlockMemory_call( - int initchunksize, /**< number of elements in the first chunk of each chunk block */ - int garbagefactor, /**< garbage collector is called, if at least garbagefactor * avg. chunksize - * elements are free (-1: disable garbage collection) */ - const char* filename, /**< source file of the function call */ - int line /**< line number in source file of the function call */ - ); - -/** frees all chunk blocks in the block memory */ -SCIP_EXPORT -void BMSclearBlockMemory_call( - BMS_BLKMEM* blkmem, /**< block memory */ - const char* filename, /**< source file of the function call */ - int line /**< line number in source file of the function call */ - ); - -/** clears and deletes block memory */ -SCIP_EXPORT -void BMSdestroyBlockMemory_call( - BMS_BLKMEM** blkmem, /**< pointer to block memory */ - const char* filename, /**< source file of the function call */ - int line /**< line number in source file of the function call */ - ); - -/** allocates memory in the block memory pool */ -SCIP_EXPORT -void* BMSallocBlockMemory_call( - BMS_BLKMEM* blkmem, /**< block memory */ - size_t size, /**< size of memory element to allocate */ - const char* filename, /**< source file of the function call */ - int line /**< line number in source file of the function call */ - ); - -/** allocates memory in the block memory pool and clears it */ -SCIP_EXPORT -void* BMSallocClearBlockMemory_call( - BMS_BLKMEM* blkmem, /**< block memory */ - size_t size, /**< size of memory element to allocate */ - const char* filename, /**< source file of the function call */ - int line /**< line number in source file of the function call */ - ); - -/** allocates array in the block memory pool */ -SCIP_EXPORT -void* BMSallocBlockMemoryArray_call( - BMS_BLKMEM* blkmem, /**< block memory */ - size_t num, /**< size of array to be allocated */ - size_t typesize, /**< size of each component */ - const char* filename, /**< source file of the function call */ - int line /**< line number in source file of the function call */ - ); - -/** allocates array in the block memory pool and clears it */ -SCIP_EXPORT -void* BMSallocClearBlockMemoryArray_call( - BMS_BLKMEM* blkmem, /**< block memory */ - size_t num, /**< size of array to be allocated */ - size_t typesize, /**< size of each component */ - const char* filename, /**< source file of the function call */ - int line /**< line number in source file of the function call */ - ); - -/** resizes memory element in the block memory pool and copies the data */ -SCIP_EXPORT -void* BMSreallocBlockMemory_call( - BMS_BLKMEM* blkmem, /**< block memory */ - void* ptr, /**< memory element to reallocated */ - size_t oldsize, /**< old size of memory element */ - size_t newsize, /**< new size of memory element */ - const char* filename, /**< source file of the function call */ - int line /**< line number in source file of the function call */ - ); - -/** resizes array in the block memory pool and copies the data */ -SCIP_EXPORT -void* BMSreallocBlockMemoryArray_call( - BMS_BLKMEM* blkmem, /**< block memory */ - void* ptr, /**< memory element to reallocated */ - size_t oldnum, /**< old size of array */ - size_t newnum, /**< new size of array */ - size_t typesize, /**< size of each component */ - const char* filename, /**< source file of the function call */ - int line /**< line number in source file of the function call */ - ); - -/** duplicates memory element in the block memory pool and copies the data */ -SCIP_EXPORT -void* BMSduplicateBlockMemory_call( - BMS_BLKMEM* blkmem, /**< block memory */ - const void* source, /**< memory element to duplicate */ - size_t size, /**< size of memory elements */ - const char* filename, /**< source file of the function call */ - int line /**< line number in source file of the function call */ - ); - -/** duplicates array in the block memory pool and copies the data */ -SCIP_EXPORT -void* BMSduplicateBlockMemoryArray_call( - BMS_BLKMEM* blkmem, /**< block memory */ - const void* source, /**< memory element to duplicate */ - size_t num, /**< size of array to be duplicated */ - size_t typesize, /**< size of each component */ - const char* filename, /**< source file of the function call */ - int line /**< line number in source file of the function call */ - ); - -/** frees memory element in the block memory pool and sets pointer to NULL */ -SCIP_EXPORT -void BMSfreeBlockMemory_call( - BMS_BLKMEM* blkmem, /**< block memory */ - void** ptr, /**< pointer to pointer to memory element to free */ - size_t size, /**< size of memory element */ - const char* filename, /**< source file of the function call */ - int line /**< line number in source file of the function call */ - ); - -/** frees memory element in the block memory pool if pointer is not NULL and sets pointer to NULL */ -SCIP_EXPORT -void BMSfreeBlockMemoryNull_call( - BMS_BLKMEM* blkmem, /**< block memory */ - void** ptr, /**< pointer to pointer to memory element to free */ - size_t size, /**< size of memory element */ - const char* filename, /**< source file of the function call */ - int line /**< line number in source file of the function call */ - ); - -/** calls garbage collection of block memory, frees chunks without allocated memory elements, and frees - * chunk blocks without any chunks - */ -SCIP_EXPORT -void BMSgarbagecollectBlockMemory_call( - BMS_BLKMEM* blkmem /**< block memory */ - ); - -/** returns the number of allocated bytes in the block memory */ -SCIP_EXPORT -long long BMSgetBlockMemoryAllocated_call( - const BMS_BLKMEM* blkmem /**< block memory */ - ); - -/** returns the number of used bytes in the block memory */ -SCIP_EXPORT -long long BMSgetBlockMemoryUsed_call( - const BMS_BLKMEM* blkmem /**< block memory */ - ); - -/** returns the number of allocated but not used bytes in the block memory */ -SCIP_EXPORT -long long BMSgetBlockMemoryUnused_call( - const BMS_BLKMEM* blkmem /**< block memory */ - ); - -/** returns the maximal number of used bytes in the block memory */ -SCIP_EXPORT -long long BMSgetBlockMemoryUsedMax_call( - const BMS_BLKMEM* blkmem /**< block memory */ - ); - -/** returns the maximal number of allocated but not used bytes in the block memory */ -SCIP_EXPORT -long long BMSgetBlockMemoryUnusedMax_call( - const BMS_BLKMEM* blkmem /**< block memory */ - ); - -/** returns the maximal number of allocated bytes in the block memory */ -long long BMSgetBlockMemoryAllocatedMax_call( - const BMS_BLKMEM* blkmem /**< block memory */ - ); - -/** returns the size of the given memory element; returns 0, if the element is not member of the block memory */ -SCIP_EXPORT -size_t BMSgetBlockPointerSize_call( - const BMS_BLKMEM* blkmem, /**< block memory */ - const void* ptr /**< memory element */ - ); - -/** outputs allocation diagnostics of block memory */ -SCIP_EXPORT -void BMSdisplayBlockMemory_call( - const BMS_BLKMEM* blkmem /**< block memory */ - ); - -/** outputs error messages, if there are allocated elements in the block memory and returns number of unfreed bytes */ -SCIP_EXPORT -long long BMScheckEmptyBlockMemory_call( - const BMS_BLKMEM* blkmem /**< block memory */ - ); - - - - - -/*********************************************************** - * Buffer Memory Management - * - * Efficient memory management for temporary objects - ***********************************************************/ - -typedef struct BMS_BufMem BMS_BUFMEM; /**< buffer memory for temporary objects */ - -/* Note: values that are passed as a size_t parameter are first converted to ptrdiff_t to be sure that negative numbers - * are extended to the larger size. Then they are converted to size_t. Thus, negative numbers are converted to very - * large size_t values. This is then checked within the functions. */ - -#define BMSallocBufferMemory(mem,ptr) ASSIGN((ptr), BMSallocBufferMemory_call((mem), sizeof(**(ptr)), __FILE__, __LINE__)) -#define BMSallocBufferMemorySize(mem,ptr,size) ASSIGN((ptr), BMSallocBufferMemory_call((mem), (size_t)(ptrdiff_t)(size), __FILE__, __LINE__)) -#define BMSreallocBufferMemorySize(mem,ptr,size) \ - ASSIGN((ptr), BMSreallocBufferMemory_call((mem), (void*)(*(ptr)), (size_t)(ptrdiff_t)(size), __FILE__, __LINE__)) -#define BMSallocBufferMemoryArray(mem,ptr,num) ASSIGN((ptr), BMSallocBufferMemoryArray_call((mem), (size_t)(ptrdiff_t)(num), sizeof(**(ptr)), __FILE__, __LINE__)) -#define BMSallocClearBufferMemoryArray(mem,ptr,num) ASSIGN((ptr), BMSallocClearBufferMemoryArray_call((mem), (size_t)(ptrdiff_t)(num), sizeof(**(ptr)), __FILE__, __LINE__)) -#define BMSreallocBufferMemoryArray(mem,ptr,num) ASSIGN((ptr), BMSreallocBufferMemoryArray_call((mem), (void*)(*(ptr)), (size_t)(ptrdiff_t)(num), \ - sizeof(**(ptr)), __FILE__, __LINE__)) -#define BMSduplicateBufferMemory(mem,ptr,source,size) \ - ASSIGN((ptr), BMSduplicateBufferMemory_call((mem), (const void*)(source), (size_t)(ptrdiff_t)(size), __FILE__, __LINE__)) -#define BMSduplicateBufferMemoryArray(mem,ptr,source,num) ASSIGNCHECK((ptr), BMSduplicateBufferMemoryArray_call((mem), \ - (const void*)(source), (size_t)(ptrdiff_t)(num), sizeof(**(ptr)), __FILE__, __LINE__), source) - -#define BMSfreeBufferMemory(mem,ptr) BMSfreeBufferMemory_call((mem), (void**)(ptr), __FILE__, __LINE__) -#define BMSfreeBufferMemoryNull(mem,ptr) BMSfreeBufferMemoryNull_call((mem), (void**)(ptr), __FILE__, __LINE__) -#define BMSfreeBufferMemoryArray(mem,ptr) BMSfreeBufferMemory_call((mem), (void**)(ptr), __FILE__, __LINE__) -#define BMSfreeBufferMemoryArrayNull(mem,ptr) BMSfreeBufferMemoryNull_call((mem), (void**)(ptr), __FILE__, __LINE__) -#define BMSfreeBufferMemorySize(mem,ptr) BMSfreeBufferMemory_call((mem), (void**)(ptr), __FILE__, __LINE__); -#define BMSfreeBufferMemorySizeNull(mem,ptr) BMSfreeBufferMemoryNull_call((mem), (void**)(ptr), __FILE__, __LINE__) - -#define BMScreateBufferMemory(fac,init,clean) BMScreateBufferMemory_call((fac), (init), (clean), __FILE__, __LINE__) -#define BMSdestroyBufferMemory(mem) BMSdestroyBufferMemory_call((mem), __FILE__, __LINE__) - - -/** creates memory buffer storage */ -SCIP_EXPORT -BMS_BUFMEM* BMScreateBufferMemory_call( - double arraygrowfac, /**< memory growing factor for dynamically allocated arrays */ - int arraygrowinit, /**< initial size of dynamically allocated arrays */ - unsigned int clean, /**< should the memory blocks in the buffer be initialized to zero? */ - const char* filename, /**< source file of the function call */ - int line /**< line number in source file of the function call */ - ); - -/** destroys buffer memory */ -SCIP_EXPORT -void BMSdestroyBufferMemory_call( - BMS_BUFMEM** buffer, /**< pointer to memory buffer storage */ - const char* filename, /**< source file of the function call */ - int line /**< line number in source file of the function call */ - ); - -/** set arraygrowfac */ -SCIP_EXPORT -void BMSsetBufferMemoryArraygrowfac( - BMS_BUFMEM* buffer, /**< pointer to memory buffer storage */ - double arraygrowfac /**< memory growing factor for dynamically allocated arrays */ - ); - -/** set arraygrowinit */ -SCIP_EXPORT -void BMSsetBufferMemoryArraygrowinit( - BMS_BUFMEM* buffer, /**< pointer to memory buffer storage */ - int arraygrowinit /**< initial size of dynamically allocated arrays */ - ); - -/** allocates the next unused buffer */ -SCIP_EXPORT -void* BMSallocBufferMemory_call( - BMS_BUFMEM* buffer, /**< memory buffer storage */ - size_t size, /**< minimal required size of the buffer */ - const char* filename, /**< source file of the function call */ - int line /**< line number in source file of the function call */ - ); - -/** allocates the next unused buffer array */ -SCIP_EXPORT -void* BMSallocBufferMemoryArray_call( - BMS_BUFMEM* buffer, /**< memory buffer storage */ - size_t num, /**< size of array to be allocated */ - size_t typesize, /**< size of components */ - const char* filename, /**< source file of the function call */ - int line /**< line number in source file of the function call */ - ); - -/** allocates the next unused buffer and clears it */ -SCIP_EXPORT -void* BMSallocClearBufferMemoryArray_call( - BMS_BUFMEM* buffer, /**< memory buffer storage */ - size_t num, /**< size of array to be allocated */ - size_t typesize, /**< size of components */ - const char* filename, /**< source file of the function call */ - int line /**< line number in source file of the function call */ - ); - -/** reallocates the buffer to at least the given size */ -SCIP_EXPORT -void* BMSreallocBufferMemory_call( - BMS_BUFMEM* buffer, /**< memory buffer storage */ - void* ptr, /**< pointer to the allocated memory buffer */ - size_t size, /**< minimal required size of the buffer */ - const char* filename, /**< source file of the function call */ - int line /**< line number in source file of the function call */ - ); - -/** reallocates an array in the buffer to at least the given size */ -SCIP_EXPORT -void* BMSreallocBufferMemoryArray_call( - BMS_BUFMEM* buffer, /**< memory buffer storage */ - void* ptr, /**< pointer to the allocated memory buffer */ - size_t num, /**< size of array to be allocated */ - size_t typesize, /**< size of components */ - const char* filename, /**< source file of the function call */ - int line /**< line number in source file of the function call */ - ); - -/** allocates the next unused buffer and copies the given memory into the buffer */ -SCIP_EXPORT -void* BMSduplicateBufferMemory_call( - BMS_BUFMEM* buffer, /**< memory buffer storage */ - const void* source, /**< memory block to copy into the buffer */ - size_t size, /**< minimal required size of the buffer */ - const char* filename, /**< source file of the function call */ - int line /**< line number in source file of the function call */ - ); - -/** allocates an array in the next unused buffer and copies the given memory into the buffer */ -SCIP_EXPORT -void* BMSduplicateBufferMemoryArray_call( - BMS_BUFMEM* buffer, /**< memory buffer storage */ - const void* source, /**< memory block to copy into the buffer */ - size_t num, /**< size of array to be allocated */ - size_t typesize, /**< size of components */ - const char* filename, /**< source file of the function call */ - int line /**< line number in source file of the function call */ - ); - -/** frees a buffer and sets pointer to NULL */ -SCIP_EXPORT -void BMSfreeBufferMemory_call( - BMS_BUFMEM* buffer, /**< memory buffer storage */ - void** ptr, /**< pointer to pointer to the allocated memory buffer */ - const char* filename, /**< source file of the function call */ - int line /**< line number in source file of the function call */ - ); - -/** frees a buffer if pointer is not NULL and sets pointer to NULL */ -SCIP_EXPORT -void BMSfreeBufferMemoryNull_call( - BMS_BUFMEM* buffer, /**< memory buffer storage */ - void** ptr, /**< pointer to pointer to the allocated memory buffer */ - const char* filename, /**< source file of the function call */ - int line /**< line number in source file of the function call */ - ); - -/** gets number of used buffers */ -SCIP_EXPORT -size_t BMSgetNUsedBufferMemory( - BMS_BUFMEM* buffer /**< memory buffer storage */ - ); - -/** returns the number of allocated bytes in the buffer memory */ -SCIP_EXPORT -long long BMSgetBufferMemoryUsed( - const BMS_BUFMEM* bufmem /**< buffer memory */ - ); - -/** outputs statistics about currently allocated buffers to the screen */ -SCIP_EXPORT -void BMSprintBufferMemory( - BMS_BUFMEM* buffer /**< memory buffer storage */ - ); - - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/headers/dijkstra/dijkstra.h b/headers/dijkstra/dijkstra.h deleted file mode 100644 index c811604..0000000 --- a/headers/dijkstra/dijkstra.h +++ /dev/null @@ -1,124 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* */ -/* This file is part of the program and library */ -/* SCIP --- Solving Constraint Integer Programs */ -/* */ -/* Copyright 2002-2022 Zuse Institute Berlin */ -/* */ -/* Licensed under the Apache License, Version 2.0 (the "License"); */ -/* you may not use this file except in compliance with the License. */ -/* You may obtain a copy of the License at */ -/* */ -/* http://www.apache.org/licenses/LICENSE-2.0 */ -/* */ -/* Unless required by applicable law or agreed to in writing, software */ -/* distributed under the License is distributed on an "AS IS" BASIS, */ -/* 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. */ -/* */ -/* You should have received a copy of the Apache-2.0 license */ -/* along with SCIP; see the file LICENSE. If not visit scipopt.org. */ -/* */ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -/**@file dijkstra.h - * @brief Definitions for Disjkstra's shortest path algorithm - * @author Thorsten Koch - * @author Marc Pfetsch - */ - -#ifndef DIJSKSTRA_H -#define DIJSKSTRA_H - -#ifdef __cplusplus -extern "C" { -#endif - -/* declare own bools, if necessary */ -#ifndef DIJKSTRA_Bool -#define DIJKSTRA_Bool unsigned int /**< type used for boolean values */ -#endif -#ifndef TRUE -#define TRUE 1 /**< boolean value TRUE */ -#define FALSE 0 /**< boolean value FALSE */ -#endif - -#define DIJKSTRA_FARAWAY 0xffffffffu /**< node has distance 'infinity' */ -#define DIJKSTRA_UNUSED 0xffffffffu /**< node is unused */ - - -/** graph structure - use consecutive storage for arcs */ -struct DIJKSTRA_Graph -{ - unsigned int nodes; /**< number of nodes */ - unsigned int* outbeg; /**< indices of out-arcs for each node in arcs array */ - unsigned int* outcnt; /**< number of out-arcs for each node */ - unsigned int arcs; /**< consecutive storage for all arcs */ - unsigned int* weight; /**< corresponding weights for all arcs */ - unsigned int* head; /**< target nodes for all arcs */ - unsigned int minweight; /**< total minimal weight */ - unsigned int maxweight; /**< total maximal weight */ -}; - -/** graph structure - use consecutive storage for arcs */ -typedef struct DIJKSTRA_Graph DIJKSTRA_GRAPH; - - - -/** Check whether the data structures of the graph are valid. */ -DIJKSTRA_Bool dijkstraGraphIsValid( - const DIJKSTRA_GRAPH* G /**< directed graph to be checked */ - ); - -/** Dijkstra's algorithm using binary heaps */ -unsigned int dijkstra( - const DIJKSTRA_GRAPH* G, /**< directed graph */ - unsigned int source, /**< source node */ - unsigned long long* dist, /**< node distances (allocated by user) */ - unsigned int* pred, /**< node predecessors in final shortest path tree (allocated by user) */ - unsigned int* entry, /**< temporary storage (for each node - must be allocated by user) */ - unsigned int* order /**< temporary storage (for each node - must be allocated by user) */ - ); - -/** Dijkstra's algorithm for shortest paths between a pair of nodes using binary heaps */ -unsigned int dijkstraPair( - const DIJKSTRA_GRAPH* G, /**< directed graph */ - unsigned int source, /**< source node */ - unsigned int target, /**< target node */ - unsigned long long* dist, /**< node distances (allocated by user) */ - unsigned int* pred, /**< node predecessors in final shortest path tree (allocated by user) */ - unsigned int* entry, /**< temporary storage (for each node - must be allocated by user) */ - unsigned int* order /**< temporary storage (for each node - must be allocated by user) */ - ); - -/** Dijkstra's algorithm for shortest paths between a pair of nodes using binary heaps and truncated at cutoff */ -unsigned int dijkstraPairCutoff( - const DIJKSTRA_GRAPH* G, /**< directed graph */ - unsigned int source, /**< source node */ - unsigned int target, /**< target node */ - unsigned long long cutoff, /**< if the distance of a node reached this value, we truncate the search */ - unsigned long long* dist, /**< node distances (allocated by user) */ - unsigned int* pred, /**< node predecessors in final shortest path tree (allocated by user) */ - unsigned int* entry, /**< temporary storage (for each node - must be allocated by user) */ - unsigned int* order /**< temporary storage (for each node - must be allocated by user) */ - ); - -/** Dijkstra's algorithm for shortest paths between a pair of nodes ignoring nodes, using binary heaps, and truncated at cutoff */ -unsigned int dijkstraPairCutoffIgnore( - const DIJKSTRA_GRAPH* G, /**< directed graph */ - unsigned int source, /**< source node */ - unsigned int target, /**< target node */ - unsigned int* ignore, /**< marking nodes to be ignored (if value is nonzero) */ - unsigned long long cutoff, /**< if the distance of a node reached this value, we truncate the search */ - unsigned long long* dist, /**< node distances (allocated by user) */ - unsigned int* pred, /**< node predecessors in final shortest path tree (allocated by user) */ - unsigned int* entry, /**< temporary storage (for each node - must be allocated by user) */ - unsigned int* order /**< temporary storage (for each node - must be allocated by user) */ - ); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/headers/gcg/bliss_automorph.h b/headers/gcg/bliss_automorph.h deleted file mode 100644 index 816d62f..0000000 --- a/headers/gcg/bliss_automorph.h +++ /dev/null @@ -1,66 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* */ -/* This file is part of the program */ -/* GCG --- Generic Column Generation */ -/* a Dantzig-Wolfe decomposition based extension */ -/* of the branch-cut-and-price framework */ -/* SCIP --- Solving Constraint Integer Programs */ -/* */ -/* Copyright (C) 2010-2022 Operations Research, RWTH Aachen University */ -/* Zuse Institute Berlin (ZIB) */ -/* */ -/* This program is free software; you can redistribute it and/or */ -/* modify it under the terms of the GNU Lesser General Public License */ -/* as published by the Free Software Foundation; either version 3 */ -/* of the License, or (at your option) any later version. */ -/* */ -/* This program is distributed in the hope that it will be useful, */ -/* but WITHOUT ANY WARRANTY; without even the implied warranty of */ -/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ -/* GNU Lesser General Public License for more details. */ -/* */ -/* You should have received a copy of the GNU Lesser General Public License */ -/* along with this program; if not, write to the Free Software */ -/* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.*/ -/* */ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -/**@file bliss_automorph.h - * @brief automorphism recognition of SCIPs - * - * @author Martin Bergner - * @author Daniel Peters - */ - -/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/ -#include "scip/type_scip.h" -#include "scip/type_result.h" -#include "scip/type_misc.h" - -#ifndef BLISS_AUTOMORPH_H_ -#define BLISS_AUTOMORPH_H_ - - - -#ifdef __cplusplus -extern "C" { -#endif - -/** compare two graphs w.r.t. automorphism */ -SCIP_RETCODE cmpGraphPair( - SCIP* origscip, /**< SCIP data structure */ - SCIP* scip1, /**< first SCIP data structure to compare */ - SCIP* scip2, /**< second SCIP data structure to compare */ - int prob1, /**< index of first pricing prob */ - int prob2, /**< index of second pricing prob */ - SCIP_RESULT* result, /**< result pointer to indicate success or failure */ - SCIP_HASHMAP* varmap, /**< hashmap to save permutation of variables */ - SCIP_HASHMAP* consmap, /**< hashmap to save permutation of constraints */ - unsigned int searchnodelimit, /**< bliss search node limit (requires patched bliss version) */ - unsigned int generatorlimit /**< bliss generator limit (requires patched bliss version) */ - ); - -#ifdef __cplusplus -} -#endif -#endif /* BLISS_AUTOMORPH_H_ */ diff --git a/headers/gcg/bliss_automorph.hpp b/headers/gcg/bliss_automorph.hpp deleted file mode 100644 index 9194ce1..0000000 --- a/headers/gcg/bliss_automorph.hpp +++ /dev/null @@ -1,55 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* */ -/* This file is part of the program */ -/* GCG --- Generic Column Generation */ -/* a Dantzig-Wolfe decomposition based extension */ -/* of the branch-cut-and-price framework */ -/* SCIP --- Solving Constraint Integer Programs */ -/* */ -/* Copyright (C) 2010-2022 Operations Research, RWTH Aachen University */ -/* Zuse Institute Berlin (ZIB) */ -/* */ -/* This program is free software; you can redistribute it and/or */ -/* modify it under the terms of the GNU Lesser General Public License */ -/* as published by the Free Software Foundation; either version 3 */ -/* of the License, or (at your option) any later version. */ -/* */ -/* This program is distributed in the hope that it will be useful, */ -/* but WITHOUT ANY WARRANTY; without even the implied warranty of */ -/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ -/* GNU Lesser General Public License for more details. */ -/* */ -/* You should have received a copy of the GNU Lesser General Public License */ -/* along with this program; if not, write to the Free Software */ -/* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.*/ -/* */ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -/**@file bliss_automorph.hpp - * @brief automorphism recognition (C++ interface) - * - * @author Erik Muehmer - */ - -/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/ - -#ifndef GCG_BLISS_AUTOMORPH_HPP -#define GCG_BLISS_AUTOMORPH_HPP - -#include "class_partialdecomp.h" - - -/** compare two graphs w.r.t. automorphism */ -SCIP_RETCODE cmpGraphPair( - SCIP* scip, /**< SCIP data structure */ - gcg::PARTIALDECOMP* partialdec, /**< partialdec the graphs should be compared for */ - int block1, /**< index of first pricing prob */ - int block2, /**< index of second pricing prob */ - SCIP_RESULT* result, /**< result pointer to indicate success or failure */ - SCIP_HASHMAP* varmap, /**< hashmap to save permutation of variables */ - SCIP_HASHMAP* consmap, /**< hashmap to save permutation of constraints */ - unsigned int searchnodelimit, /**< bliss search node limit (requires patched bliss version) */ - unsigned int generatorlimit /**< bliss generator limit (requires patched bliss version) */ -); - -#endif //GCG_BLISS_AUTOMORPH_HPP diff --git a/headers/gcg/branch_bpstrong.h b/headers/gcg/branch_bpstrong.h deleted file mode 100644 index 9505213..0000000 --- a/headers/gcg/branch_bpstrong.h +++ /dev/null @@ -1,90 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* */ -/* This file is part of the program */ -/* GCG --- Generic Column Generation */ -/* a Dantzig-Wolfe decomposition based extension */ -/* of the branch-cut-and-price framework */ -/* SCIP --- Solving Constraint Integer Programs */ -/* */ -/* Copyright (C) 2010-2022 Operations Research, RWTH Aachen University */ -/* Zuse Institute Berlin (ZIB) */ -/* */ -/* This program is free software; you can redistribute it and/or */ -/* modify it under the terms of the GNU Lesser General Public License */ -/* as published by the Free Software Foundation; either version 3 */ -/* of the License, or (at your option) any later version. */ -/* */ -/* This program is distributed in the hope that it will be useful, */ -/* but WITHOUT ANY WARRANTY; without even the implied warranty of */ -/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ -/* GNU Lesser General Public License for more details. */ -/* */ -/* You should have received a copy of the GNU Lesser General Public License */ -/* along with this program; if not, write to the Free Software */ -/* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.*/ -/* */ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -/**@file branch_bpstrong.h - * @brief generic branch and price strong branching as described in - * Pecin, D., Pessoa, A., Poggi, M., Uchoa, E. Improved branch-cut-and-price for capacitated vehicle routing. - * In: Math. Prog. Comp. 9:61-100. Springer (2017). - * @ingroup BRANCHINGRULES - * @author Oliver Gaul - */ - -/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/ - -#ifndef GCG_BRANCH_BPSTRONG_H__ -#define GCG_BRANCH_BPSTRONG_H__ - -#include "scip/scip.h" -#include "type_branchgcg.h" - -#ifdef __cplusplus -extern "C" -{ -#endif - -/** creates the xyz branching rule and includes it in SCIP */ -extern SCIP_RETCODE SCIPincludeBranchruleBPStrong( - SCIP *scip /**< SCIP data structure */ -); - -extern SCIP_RETCODE GCGbranchSelectCandidateStrongBranchingOrig( - SCIP* scip, /**< SCIP data structure */ - SCIP_BRANCHRULE *origbranchrule, /**< pointer storing original branching rule */ - SCIP_VAR **branchvar, /**< pointer to store output var pointer */ - SCIP_Bool *upinf, /**< pointer to store whether strong branching detected infeasibility in - * the upbranch */ - SCIP_Bool *downinf, /**< pointer to store whether strong branching detected infeasibility in - * the downbranch */ - SCIP_RESULT *result, /**< pointer to store result */ - SCIP_Bool *stillusestrong /**< pointer to store whether strong branching has reached a permanent - * stopping condition for orig */ -); - -extern SCIP_RETCODE GCGbranchSelectCandidateStrongBranchingRyanfoster( - SCIP* scip, /**< original SCIP data structure */ - SCIP_BRANCHRULE* rfbranchrule, /**< Ryan-Foster branchrule */ - SCIP_VAR **ovar1s, /**< first elements of candidate pairs */ - SCIP_VAR **ovar2s, /**< second elements of candidate pairs */ - int *nspricingblock, /**< pricing block numbers corresponding to input pairs */ - int npairs, /**< number of input pairs */ - SCIP_VAR **ovar1, /**< pointer to store output var 1 pointer */ - SCIP_VAR **ovar2, /**< pointer to store output var 2 pointer */ - int *pricingblock, /**< pointer to store output pricing block number */ - SCIP_Bool *sameinf, /**< pointer to store whether strong branching detected infeasibility in - * the same branch */ - SCIP_Bool *differinf, /**< pointer to store whether strong branching detected infeasibility in - * the differ branch */ - SCIP_RESULT *result, /**< pointer to store result */ - SCIP_Bool *stillusestrong /**< pointer to store whether strong branching has reached a permanent - * stopping condition for Ryan-Foster */ -); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/headers/gcg/branch_empty.h b/headers/gcg/branch_empty.h deleted file mode 100644 index 0488477..0000000 --- a/headers/gcg/branch_empty.h +++ /dev/null @@ -1,56 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* */ -/* This file is part of the program */ -/* GCG --- Generic Column Generation */ -/* a Dantzig-Wolfe decomposition based extension */ -/* of the branch-cut-and-price framework */ -/* SCIP --- Solving Constraint Integer Programs */ -/* */ -/* Copyright (C) 2010-2022 Operations Research, RWTH Aachen University */ -/* Zuse Institute Berlin (ZIB) */ -/* */ -/* This program is free software; you can redistribute it and/or */ -/* modify it under the terms of the GNU Lesser General Public License */ -/* as published by the Free Software Foundation; either version 3 */ -/* of the License, or (at your option) any later version. */ -/* */ -/* This program is distributed in the hope that it will be useful, */ -/* but WITHOUT ANY WARRANTY; without even the implied warranty of */ -/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ -/* GNU Lesser General Public License for more details. */ -/* */ -/* You should have received a copy of the GNU Lesser General Public License */ -/* along with this program; if not, write to the Free Software */ -/* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.*/ -/* */ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -/**@file branch_empty.h - * @brief branching rule for original problem in GCG while real branching is in the master - * @author Marcel Schmickerath - * @ingroup BRANCHINGRULES - */ - -/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/ - -#ifndef GCG_BRANCH_EMPTY_H__ -#define GCG_BRANCH_EMPTY_H__ - - -#include "scip/scip.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/** creates the empty LP branching rule and includes it in SCIP */ -extern -SCIP_RETCODE SCIPincludeBranchruleEmpty( - SCIP* scip /**< SCIP data structure */ - ); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/headers/gcg/branch_generic.h b/headers/gcg/branch_generic.h deleted file mode 100644 index 480620d..0000000 --- a/headers/gcg/branch_generic.h +++ /dev/null @@ -1,129 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* */ -/* This file is part of the program */ -/* GCG --- Generic Column Generation */ -/* a Dantzig-Wolfe decomposition based extension */ -/* of the branch-cut-and-price framework */ -/* SCIP --- Solving Constraint Integer Programs */ -/* */ -/* Copyright (C) 2010-2022 Operations Research, RWTH Aachen University */ -/* Zuse Institute Berlin (ZIB) */ -/* */ -/* This program is free software; you can redistribute it and/or */ -/* modify it under the terms of the GNU Lesser General Public License */ -/* as published by the Free Software Foundation; either version 3 */ -/* of the License, or (at your option) any later version. */ -/* */ -/* This program is distributed in the hope that it will be useful, */ -/* but WITHOUT ANY WARRANTY; without even the implied warranty of */ -/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ -/* GNU Lesser General Public License for more details. */ -/* */ -/* You should have received a copy of the GNU Lesser General Public License */ -/* along with this program; if not, write to the Free Software */ -/* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.*/ -/* */ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -/**@file branch_generic.h - * @brief branching rule based on vanderbeck's generic branching scheme - * @author Marcel Schmickerath - */ - -/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/ - -#ifndef __SCIP_BRANCH_GENERIC_H__ -#define __SCIP_BRANCH_GENERIC_H__ - - -#include "scip/scip.h" -#include "type_branchgcg.h" - -#ifdef __cplusplus -extern "C" { -#endif - -typedef enum { - GCG_COMPSENSE_GE = 1, - GCG_COMPSENSE_LT = 0 -} GCG_COMPSENSE; - -/** component bound structure */ -struct ComponentBoundSequence -{ - SCIP_VAR* component; /**< variable to which this bound belongs */ - GCG_COMPSENSE sense; /**< sense of the bound */ - SCIP_Real bound; /**< bound value */ -}; -typedef struct ComponentBoundSequence GCG_COMPSEQUENCE; - -/** strip structure */ -struct GCG_Strip -{ - SCIP* scip; /**< SCIP data structure */ - SCIP_VAR* mastervar; /**< master variable */ - GCG_COMPSEQUENCE** C; /**< current set of comp bound sequences */ - int Csize; /**< number of component bound sequences */ - int* sequencesizes; /**< array of sizes of component bound sequences */ -}; -typedef struct GCG_Strip GCG_STRIP; - -/** creates the generic branching rule and includes it in SCIP */ -extern -SCIP_RETCODE SCIPincludeBranchruleGeneric( - SCIP* scip /**< SCIP data structure */ - ); - -/** initializes branchdata */ -extern -SCIP_RETCODE GCGbranchGenericCreateBranchdata( - SCIP* scip, /**< SCIP data structure */ - GCG_BRANCHDATA** branchdata /**< branching data to initialize */ - ); - -/** get component bound sequence */ -extern -GCG_COMPSEQUENCE* GCGbranchGenericBranchdataGetConsS( - GCG_BRANCHDATA* branchdata /**< branching data to initialize */ - ); - -/** get size of component bound sequence */ -extern -int GCGbranchGenericBranchdataGetConsSsize( - GCG_BRANCHDATA* branchdata /**< branching data to initialize */ - ); - -/** get id of pricing problem (or block) to which the constraint belongs */ -extern -int GCGbranchGenericBranchdataGetConsblocknr( - GCG_BRANCHDATA* branchdata /**< branching data to initialize */ - ); - -/** get master constraint */ -extern -SCIP_CONS* GCGbranchGenericBranchdataGetMastercons( - GCG_BRANCHDATA* branchdata /**< branching data to initialize */ - ); - -/** prepares informations for using the generic branching scheme */ -extern -SCIP_RETCODE GCGbranchGenericInitbranch( - SCIP* masterscip, /**< SCIP data structure */ - SCIP_BRANCHRULE* branchrule, /**< branching rule */ - SCIP_RESULT* result, /**< pointer to store the result of the branching call */ - int** checkedblocks, /**< blocks that have been checked */ - int* ncheckedblocks, /**< number of checked blocks */ - GCG_STRIP**** checkedblockssortstrips, /**< sorted strips of checked blocks */ - int** checkedblocksnsortstrips /**< sizes of the strips */ - ); - -/** returns true when the branch rule is the generic branchrule */ -SCIP_Bool GCGisBranchruleGeneric( - SCIP_BRANCHRULE* branchrule /**< branchrule to check */ -); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/headers/gcg/branch_orig.h b/headers/gcg/branch_orig.h deleted file mode 100644 index ae54dde..0000000 --- a/headers/gcg/branch_orig.h +++ /dev/null @@ -1,80 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* */ -/* This file is part of the program */ -/* GCG --- Generic Column Generation */ -/* a Dantzig-Wolfe decomposition based extension */ -/* of the branch-cut-and-price framework */ -/* SCIP --- Solving Constraint Integer Programs */ -/* */ -/* Copyright (C) 2010-2022 Operations Research, RWTH Aachen University */ -/* Zuse Institute Berlin (ZIB) */ -/* */ -/* This program is free software; you can redistribute it and/or */ -/* modify it under the terms of the GNU Lesser General Public License */ -/* as published by the Free Software Foundation; either version 3 */ -/* of the License, or (at your option) any later version. */ -/* */ -/* This program is distributed in the hope that it will be useful, */ -/* but WITHOUT ANY WARRANTY; without even the implied warranty of */ -/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ -/* GNU Lesser General Public License for more details. */ -/* */ -/* You should have received a copy of the GNU Lesser General Public License */ -/* along with this program; if not, write to the Free Software */ -/* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.*/ -/* */ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -/**@file branch_orig.h - * @brief branching rule for original problem in GCG - * @author Gerald Gamrath - * @ingroup BRANCHINGRULES - */ - -/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/ - -#ifndef GCG_BRANCH_ORIG_H__ -#define GCG_BRANCH_ORIG_H__ - -#include "type_branchgcg.h" -#include "scip/scip.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/** creates the branching on original variable branching rule and includes it in SCIP */ -extern -SCIP_RETCODE SCIPincludeBranchruleOrig( - SCIP* scip /**< SCIP data structure */ - ); - -/** get the original variable on which the branching was performed */ -extern -SCIP_VAR* GCGbranchOrigGetOrigvar( - GCG_BRANCHDATA* branchdata /**< branching data */ - ); - -/** get the type of the new bound which resulted of the performed branching */ -extern -GCG_BOUNDTYPE GCGbranchOrigGetBoundtype( - GCG_BRANCHDATA* branchdata /**< branching data */ - ); - -/** get the new bound which resulted of the performed branching */ -extern -SCIP_Real GCGbranchOrigGetNewbound( - GCG_BRANCHDATA* branchdata /**< branching data */ - ); - -/** updates extern branching candidates before branching */ -extern -SCIP_RETCODE GCGbranchOrigUpdateExternBranchcands( - SCIP* scip /**< SCIP data structure */ -); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/headers/gcg/branch_relpsprob.h b/headers/gcg/branch_relpsprob.h deleted file mode 100644 index fbc86c4..0000000 --- a/headers/gcg/branch_relpsprob.h +++ /dev/null @@ -1,68 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* */ -/* This file is part of the program */ -/* GCG --- Generic Column Generation */ -/* a Dantzig-Wolfe decomposition based extension */ -/* of the branch-cut-and-price framework */ -/* SCIP --- Solving Constraint Integer Programs */ -/* */ -/* Copyright (C) 2010-2022 Operations Research, RWTH Aachen University */ -/* Zuse Institute Berlin (ZIB) */ -/* */ -/* This program is free software; you can redistribute it and/or */ -/* modify it under the terms of the GNU Lesser General Public License */ -/* as published by the Free Software Foundation; either version 3 */ -/* of the License, or (at your option) any later version. */ -/* */ -/* This program is distributed in the hope that it will be useful, */ -/* but WITHOUT ANY WARRANTY; without even the implied warranty of */ -/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ -/* GNU Lesser General Public License for more details. */ -/* */ -/* You should have received a copy of the GNU Lesser General Public License */ -/* along with this program; if not, write to the Free Software */ -/* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.*/ -/* */ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -/**@file branch_relpsprob.h - * @brief reliable pseudo costs branching rule - * @author Tobias Achterberg - * @author Gerald Gamrath - */ - -/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/ - -#ifndef GCG_BRANCH_RELPSPROB_H__ -#define GCG_BRANCH_RELPSPROB_H__ - - -#include "scip/scip.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/** creates the reliable pseudo cost braching rule and includes it in SCIP */ -extern -SCIP_RETCODE SCIPincludeBranchruleRelpsprob( - SCIP* scip /**< SCIP data structure */ - ); - -/** execution reliability pseudo cost probing branching with the given branching candidates */ -extern -SCIP_RETCODE SCIPgetRelpsprobBranchVar( - SCIP* scip, /**< SCIP data structure */ - SCIP_VAR** branchcands, /**< brancing candidates */ - SCIP_Real* branchcandssol, /**< solution value for the branching candidates */ - int nbranchcands, /**< number of branching candidates */ - int nvars, /**< number of variables to be watched by bdchgdata */ - SCIP_RESULT* result, /**< pointer to the result of the execution */ - SCIP_VAR** branchvar /**< pointer to the variable to branch on */ - ); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/headers/gcg/branch_ryanfoster.h b/headers/gcg/branch_ryanfoster.h deleted file mode 100644 index 1fb73fe..0000000 --- a/headers/gcg/branch_ryanfoster.h +++ /dev/null @@ -1,56 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* */ -/* This file is part of the program */ -/* GCG --- Generic Column Generation */ -/* a Dantzig-Wolfe decomposition based extension */ -/* of the branch-cut-and-price framework */ -/* SCIP --- Solving Constraint Integer Programs */ -/* */ -/* Copyright (C) 2010-2022 Operations Research, RWTH Aachen University */ -/* Zuse Institute Berlin (ZIB) */ -/* */ -/* This program is free software; you can redistribute it and/or */ -/* modify it under the terms of the GNU Lesser General Public License */ -/* as published by the Free Software Foundation; either version 3 */ -/* of the License, or (at your option) any later version. */ -/* */ -/* This program is distributed in the hope that it will be useful, */ -/* but WITHOUT ANY WARRANTY; without even the implied warranty of */ -/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ -/* GNU Lesser General Public License for more details. */ -/* */ -/* You should have received a copy of the GNU Lesser General Public License */ -/* along with this program; if not, write to the Free Software */ -/* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.*/ -/* */ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -/**@file branch_ryanfoster.h - * @brief branching rule for original problem in GCG implementing the Ryan and Foster branching scheme - * @author Gerald Gamrath - * @ingroup BRANCHINGRULES - */ - -/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/ - -#ifndef GCG_BRANCH_RYANFOSTER_H__ -#define GCG_BRANCH_RYANFOSTER_H__ - - -#include "scip/scip.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/** creates the Ryan-Foster LP braching rule and includes it in SCIP */ -extern -SCIP_RETCODE SCIPincludeBranchruleRyanfoster( - SCIP* scip /**< SCIP data structure */ - ); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/headers/gcg/class_conspartition.h b/headers/gcg/class_conspartition.h deleted file mode 100644 index 472090a..0000000 --- a/headers/gcg/class_conspartition.h +++ /dev/null @@ -1,147 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* */ -/* This file is part of the program */ -/* GCG --- Generic Column Generation */ -/* a Dantzig-Wolfe decomposition based extension */ -/* of the branch-cut-and-price framework */ -/* SCIP --- Solving Constraint Integer Programs */ -/* */ -/* Copyright (C) 2010-2022 Operations Research, RWTH Aachen University */ -/* Zuse Institute Berlin (ZIB) */ -/* */ -/* This program is free software; you can redistribute it and/or */ -/* modify it under the terms of the GNU Lesser General Public License */ -/* as published by the Free Software Foundation; either version 3 */ -/* of the License, or (at your option) any later version. */ -/* */ -/* This program is distributed in the hope that it will be useful, */ -/* but WITHOUT ANY WARRANTY; without even the implied warranty of */ -/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ -/* GNU Lesser General Public License for more details. */ -/* */ -/* You should have received a copy of the GNU Lesser General Public License */ -/* along with this program; if not, write to the Free Software */ -/* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.*/ -/* */ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -/**@file class_conspartition.h - * @brief class representing a partition of a set of constraints - * @author Julius Hense - * - */ - -/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/ - -#ifndef GCG_CLASS_CONSPARTITION_H__ -#define GCG_CLASS_CONSPARTITION_H__ - -#include "class_indexpartition.h" - -namespace gcg -{ - -enum ConsClassDecompInfo -{ - BOTH = 0, /**< assign class to master or pricing problem */ - ONLY_MASTER = 1, /**< assign class only to master problem */ - ONLY_PRICING = 2 /**< assign class only to pricing problem */ -}; -typedef enum ConsClassDecompInfo CONS_DECOMPINFO; - - -class ConsPartition : public IndexPartition -{ - -public: - - /** constructor */ - ConsPartition( - SCIP* scip, /**< scip data structure */ - const char* name, /**< name of partition (will be copied) */ - int nClasses, /**< initial number of classes */ - int nConss /**< number of constraints to be classified */ - ); - - /** copy constructor */ - ConsPartition( - const ConsPartition* toCopy /**< ConsPartition to be copied */ - ); - - - /** destructor */ - ~ConsPartition(); - - - /** creates a new class, returns index of the class */ - int addClass( - const char* name, /**< name of the class (will be copied) */ - const char* desc, /**< description of the class (will be copied) */ - CONS_DECOMPINFO decompInfo /**< decomposition code of the class */ - ); - - /** assigns a constraint to a class */ - void assignConsToClass( - int consindex, /**< index of the constraint */ - int classindex /**< index of the class */ - ); - - /** returns a vector containing all possible subsets of the chosen classindices */ - std::vector> getAllSubsets( - bool both, /**< true, if BOTH classes should be considered */ - bool only_master, /**< true, if ONLY_MASTER classes should be considered */ - bool only_pricing /**< true, if ONLY_PRICING classes should be considered */ - ); - - /** returns the decomposition info of a class */ - CONS_DECOMPINFO getClassDecompInfo( - int classindex /**< index of class */ - ); - - /** returns the name of the class a constraint is assigned to */ - const char* getClassNameOfCons( - int consindex /**< index of constraint */ - ); - - - /** returns the index of the class a constraint is assigned to */ - int getClassOfCons( - int consindex /**< index of constraint */ - ); - - /** returns vector containing the assigned class of each constraint */ - const int* getConssToClasses( - ); - - /** returns the number of constraints */ - int getNConss( - ); - - /** returns a vector with the numbers of constraints that are assigned to the classes */ - std::vector getNConssOfClasses( - ); - - /** returns whether a constraint is already assigned to a class */ - bool isConsClassified( - int consindex /**< index of constraint */ - ); - - - /** returns partition with reduced number of classes - * if the current number of classes is greater than an upper bound - * and lower than 2*(upper bound) (returns NULL otherwise) */ - ConsPartition* reduceClasses( - int maxNumberOfClasses /**< upper bound */ - ); - - /** sets the decomposition code of a class */ - void setClassDecompInfo( - int classindex, /**< index of class */ - CONS_DECOMPINFO decompInfo /**< decomposition code of class */ - ); - -}; - - -} /* namespace gcg */ -#endif /* GCG_CLASS_CONSPARTITION_H__ */ diff --git a/headers/gcg/class_detprobdata.h b/headers/gcg/class_detprobdata.h deleted file mode 100644 index b548f70..0000000 --- a/headers/gcg/class_detprobdata.h +++ /dev/null @@ -1,681 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* */ -/* This file is part of the program */ -/* GCG --- Generic Column Generation */ -/* a Dantzig-Wolfe decomposition based extension */ -/* of the branch-cut-and-price framework */ -/* SCIP --- Solving Constraint Integer Programs */ -/* */ -/* Copyright (C) 2010-2022 Operations Research, RWTH Aachen University */ -/* Zuse Institute Berlin (ZIB) */ -/* */ -/* This program is free software; you can redistribute it and/or */ -/* modify it under the terms of the GNU Lesser General Public License */ -/* as published by the Free Software Foundation; either version 3 */ -/* of the License, or (at your option) any later version. */ -/* */ -/* This program is distributed in the hope that it will be useful, */ -/* but WITHOUT ANY WARRANTY; without even the implied warranty of */ -/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ -/* GNU Lesser General Public License for more details. */ -/* */ -/* You should have received a copy of the GNU Lesser General Public License */ -/* along with this program; if not, write to the Free Software */ -/* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.*/ -/* */ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -/**@file class_detprobdata.h - * @ingroup DECOMP - * @brief class storing partialdecs and the problem matrix - * @note formerly called "Seeedpool" - * @author Michael Bastubbe - * @author Julius Hense - * @author Hanna Franzen - */ - -/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/ - -#ifndef GCG_CLASS_DETPROBDATA_H__ -#define GCG_CLASS_DETPROBDATA_H__ - -#include - -#if __cplusplus >= 201103L -#include -using std::unordered_map; -#else -#include -using std::tr1::unordered_map; -#endif - -#include -#include -#include -#include "gcg.h" - -#include "class_partialdecomp.h" -#include "class_conspartition.h" -#include "class_varpartition.h" - -/** constraint type */ -enum SCIP_Constype_orig -{ - SCIP_CONSTYPE_EMPTY = 0, /**< */ - SCIP_CONSTYPE_FREE = 1, /**< */ - SCIP_CONSTYPE_SINGLETON = 2, /**< */ - SCIP_CONSTYPE_AGGREGATION = 3, /**< */ - SCIP_CONSTYPE_VARBOUND = 4, /**< */ - SCIP_CONSTYPE_SETPARTITION = 5, /**< */ - SCIP_CONSTYPE_SETPACKING = 6, /**< */ - SCIP_CONSTYPE_SETCOVERING = 7, /**< */ - SCIP_CONSTYPE_CARDINALITY = 8, /**< */ - SCIP_CONSTYPE_INVKNAPSACK = 9, /**< */ - SCIP_CONSTYPE_EQKNAPSACK = 10, /**< */ - SCIP_CONSTYPE_BINPACKING = 11, /**< */ - SCIP_CONSTYPE_KNAPSACK = 12, /**< */ - SCIP_CONSTYPE_INTKNAPSACK = 13, /**< */ - SCIP_CONSTYPE_MIXEDBINARY = 14, /**< */ - SCIP_CONSTYPE_GENERAL = 15 /**< */ -}; -typedef enum SCIP_Constype_orig SCIP_CONSTYPE_ORIG; - - -namespace gcg{ - -/** - * @brief combine two hash function of objects of a pair to get a vaulue for the pair - */ -struct pair_hash -{ - template - std::size_t operator()( - const std::pair &p) const - { - auto h1 = std::hash{}( p.first ); - auto h2 = std::hash{}( p.second ); - - /* overly simple hash combination */ - return h1 ^ h2; - } -}; - -/** - * class to manage the detection process and data for one coefficient matrix of a MIP, usually there is one detprobdata for the original and one detprobdata for the presolved problem - */ -class DETPROBDATA -{ /*lint -esym(1712,DETPROBDATA)*/ - -private: - SCIP* scip; /**< SCIP data structure */ - std::vector openpartialdecs; /**< vector of open partialdecs */ - std::vector finishedpartialdecs; /**< vector of finished partialdecs */ - std::vector ancestorpartialdecs; /**< old partialdecs that were previously used */ - - std::vector relevantconss; /**< stores all constraints that are not marked as deleted or obsolete */ - std::vector relevantvars; /**< stores all prob variables that are not fixed to 0 */ - std::vector> varsforconss; /**< stores for every constraint the indices of variables - *< that are contained in the constraint */ - std::vector> valsforconss; /**< stores for every constraint the coefficients of - *< variables that are contained in the constraint (i.e. - *< have a nonzero coefficient) */ - std::vector> conssforvars; /**< stores for every variable the indices of constraints - *< containing this variable */ - - std::vector> conssadjacencies; - unordered_map constoindex; /**< maps SCIP_CONS* to the corresponding internal index */ - unordered_map vartoindex; /**< maps SCIP_VAR* to the corresponding internal index */ - - unordered_map, SCIP_Real, pair_hash> valsMap; /**< maps an entry of the matrix to its - *< value, zeros are omitted */ - - std::vector origfixedtozerovars; /**< collection of SCIP_VAR* that are fixed to zero in transformed problem*/ - - int nvars; /**< number of variables */ - int nconss; /**< number of constraints */ - int nnonzeros; /**< number of nonzero entries in the coefficient matrix */ - - SCIP_Bool original; /**< corresponds the matrix data structure to the original - *< problem */ - -public: - std::vector> candidatesNBlocks; /**< candidate for the number of blocks, second int indicates how often a candidate was added */ - - std::vector conspartitioncollection; /**< collection of different constraint class distributions */ - std::vector varpartitioncollection; /**< collection of different variable class distributions */ - - SCIP_Real classificationtime; /**< time that was consumed by the classification of the constraint and variables classifiers */ - SCIP_Real nblockscandidatescalctime; /**< time that was used to calulate the candidates of te block number */ - SCIP_Real postprocessingtime; /**< time that was spent in postproceesing decomposigtions */ - SCIP_Real translatingtime; /**< time that was spent by transforming partialdecs between presolved and orig problem */ - -private: - - /** - * @brief calculates necessary data for translating partialdecs and partitions - */ - void calcTranslationMapping( - DETPROBDATA* origdata, /** original detprobdata */ - std::vector& rowothertothis, /** constraint index mapping from old to new detprobdata */ - std::vector& rowthistoother, /** constraint index mapping new to old detprobdata */ - std::vector& colothertothis, /** variable index mapping from old to new detprobdata */ - std::vector& colthistoother, /** variable index mapping from new to old detprobdata */ - std::vector& missingrowinthis /** missing constraint indices in new detprobdata */ - ); - - /** - * @brief returns translated partialdecs derived from given mapping data - - * @return vector of translated partialdec pointers - */ - void getTranslatedPartialdecs( - std::vector& otherpartialdecs, /**< partialdecs to be translated */ - std::vector& rowothertothis, /** constraint index mapping from old to new detprobdata */ - std::vector& rowthistoother, /** constraint index mapping new to old detprobdata */ - std::vector& colothertothis, /** variable index mapping from old to new detprobdata */ - std::vector& colthistoother, /** variable index mapping from new to old detprobdata */ - std::vector& translatedpartialdecs /**< will contain translated partialdecs */ - ); - -public: - - /** - * @brief constructor - * @param scip SCIP data structure - * @param _originalProblem true iff the detprobdata is created for the presolved problem - */ - DETPROBDATA( - SCIP* scip, - SCIP_Bool _originalProblem - ); - - /** - * destructor - */ - ~DETPROBDATA(); - - /** - * @brief adds a constraint partition if it is no duplicate of an existing constraint partition - */ - void addConsPartition( - ConsPartition* partition /**< conspartition to be added*/ - ); - - /** - * @brief adds a candidate for block number and counts how often a candidate is added - */ - void addCandidatesNBlocksNVotes( - int candidate, /**< candidate for block size */ - int nvotes /**< number of votes this candidates will get */ - ); - - /** - * @brief adds a partialdec to ancestor partialdecs - * @param partialdec partialdec that is added to the ancestor partialdecs - */ - void addPartialdecToAncestor( - PARTIALDECOMP* partialdec - ); - - /** - * @brief adds a partialdec to current partialdecs (data structure for partialdecs that are goin to processed in the propagation rounds) - * @param partialdec pointer of partialdec to be added - * @returns TRUE if the partialdecs was successfully added (i.e. it is no duplicate of a known partialdec) - */ - bool addPartialdecToOpen( - PARTIALDECOMP* partialdec - ); - - /** - * @brief adds a partialdec to finished partialdecs - * @param partialdec pointer of partialdec that is going to be added to the finished partialdecs (data structure to carry finished decompositions) - * @returns TRUE if the partialdecs was successfully added (i.e. it is no duplicate of a known partialdec) - * @see addPartialdecToFinishedUnchecked() - */ - bool addPartialdecToFinished( - PARTIALDECOMP* partialdec - ); - - /** - * @brief adds a partialdec to finished partialdecs without checking for duplicates, dev has to check this on his own - * @param partialdec pointer of partialdec that is going to be added unchecked to the finished partialdecs (data structure to carry finished decompositions) - * @see addPartialdecToFinished() - */ - void addPartialdecToFinishedUnchecked( - PARTIALDECOMP* partialdec - ); - - /** - * @brief adds a variable partition if it is no duplicate of an existing variable partition - * @param partition varpartition to be added - */ - void addVarPartition( - VarPartition* partition - ); - - /** - * @brief clears ancestor partialdec data structure, - * @note does not free the partialdecs themselves - */ - void clearAncestorPartialdecs(); - - /** - * @brief clears current partialdec data structure - * @note does not free the partialdecs themselves - */ - void clearCurrentPartialdecs(); - - /** - * @brief clears finished partialdec data structure - * - * @note does not free the partialdecs themselves - */ - void clearFinishedPartialdecs(); - - /** - * @brief create the constraint adjacency datastructure that is used (if created) for some methods to faster access the constarints that have variables in common - */ - void createConssAdjacency(); - - /** - * @brief frees temporary data that is only needed during the detection process - */ - void freeTemporaryData(); - - /** - * @brief returns a partialdec from ancestor partialdec data structure with given index - * - * @returns partialdec from ancestor partialdec data structure - */ - PARTIALDECOMP* getAncestorPartialdec( - int partialdecindex /**< index of partialdec in ancestor partialdec data structure */ - ); - - /** - * @brief returns pointer to a constraint partition - * @return pointer to a cosntraint partition with the given index - */ - ConsPartition* getConsPartition( - int partitionIndex /**< index of constraint partition */ - ); - - /** - * @brief returns the SCIP constraint related to a constraint index - * @return the SCIP constraint related to a constraint index - */ - SCIP_CONS* getCons( - int consIndex /**< index of the constraint to be considered */ - ); - - /** - * @brief return array of constraint indices that have a common variable with the given constraint - * @return return vector of constraint indices that have a common variable with the given constraint - * @note constraint adjacency data structure has to initilized - */ - std::vector& getConssForCons( - int consIndex /**< index of the constraint to be considered */ - ); - - /** - * \brief returns the constraint indices of the coefficient matrix for a variable - * @return vector of constraint indices that have a nonzero entry with this variable - */ - std::vector& getConssForVar( - int varIndex /**< index of the variable to be considered */ - ); - - /** - * @brief determines all partialdecs from current (open) partialdec data structure - * @returns all partialdecs in current (open) partialdec data structure - */ - /** */ - std::vector& getOpenPartialdecs(); - - /** - * @brief returns a partialdec from finished partialdec data structure - * @return partialdec from finished partialdec data structure - */ - PARTIALDECOMP* getFinishedPartialdec( - int partialdecindex /**< index of partialdec in finished partialdec data structure */ - ); - - /** - * @brief gets all finished partialdecs - * @returns all finished partialdecs - */ - std::vector& getFinishedPartialdecs(); - - /** - * @brief returns the constraint index related to a SCIP constraint - * @param cons the SCIP constraint pointer the index is asked for - * @return the constraint index related to a SCIP constraint - */ - int getIndexForCons( - SCIP_CONS* cons - ); - - /** - * @brief returns the constraint index related to a SCIP constraint - * @param consname name of the constraint the index is asked for - * @return the constraint index related to a SCIP constraint - */ - int getIndexForCons( - const char* consname - ); - - /** - * @brief returns the variable index related to a SCIP variable - * @param var variable pointer the index is asked for - * @return the variable index related to a SCIP variable - */ - int getIndexForVar( - SCIP_VAR* var - ); - - /** - * @brief returns the variable index related to a SCIP variable - * @param varname name of the variable the index is asked for - * @return the variable index related to a SCIP variable - */ - int getIndexForVar( - const char* varname - ); - - /** - * @brief returns size of ancestor partialdec data structure - * @return size of ancestor partialdec data structure - */ - int getNAncestorPartialdecs(); - - /** - * @brief returns number of different constraint partitions - * @return number of different constraint partitions - */ - int getNConsPartitions(); - - /** - * @brief returns the number of variables considered in the detprobdata - * @return number of variables considered in the detprobdata - */ - int getNConss(); - - /** - * @brief returns the number of constraints for a given constraint - * @return the number of constraints for a given constraint - */ - int getNConssForCons( - int consIndex /**< index of the constraint to be considered */ - ); - - /** - * @brief returns the number of constraints for a given variable where the var has a nonzero entry in - * @return the number of constraints for a given variable - */ - int getNConssForVar( - int varIndex /**< index of the variable to be considered */ - ); - - /** - * @brief returns size of current (open) partialdec data structure - * @return size of current (open) partialdec data structure - */ - int getNOpenPartialdecs(); - - /** - * returns size of finished partialdec data structure - * @return size of finished partialdec data structure - */ - int getNFinishedPartialdecs(); - - /** - * returns the number of stored partialdecs - * @return number of stored partialdecs - */ - int getNPartialdecs(); - - /** - * @brief returns the number of nonzero entries in the coefficient matrix - * @return the number of nonzero entries in the coefficient matrix - */ - int getNNonzeros(); - - /** - * @brief returns number of different variable partitions - * @return number of different variable partitions - */ - int getNVarPartitions(); - - /** - * @brief return the number of variables considered in the detprobdata - * @return the number of variables considered in the detprobdata - */ - int getNVars(); - - /** - * @brief returns the number of variables for a given constraint - * @return the number of variables for a given constraint - */ - int getNVarsForCons( - int consIndex /**< index of the constraint to be considered */ - ); - - /** - * @brief returns pointers to all orig vars that are fixed to zero - * @returns vector of vars - */ - std::vector getOrigVarsFixedZero(); - - /** - * @brief returns pointers to all constraints that are not marked as deleted or obsolete - * @returns vector of conss - */ - std::vector getRelevantConss(); - - /** - * @brief returns pointers to all problem vars that are not fixed to 0 - * @returns vector of vars - */ - std::vector getRelevantVars(); - - /** - * @brief returns the corresponding scip data structure - * @return the corresponding scip data structure - */ - SCIP* getScip(); - - /** - * @brief gets the candidates for number of blocks added by the user followed by the found ones sorted in descending order by how often a candidate was proposed - * @param candidates will contain the candidates for number of blocks sorted in descending order by how often a candidate was added - */ - void getSortedCandidatesNBlocks( - std::vector& candidates - ); - - /** - * @brief returns a coefficient from the coefficient matrix - * @return a coefficient from the coefficient matrix - */ - SCIP_Real getVal( - int row, /**< index of the constraint to be considered */ - int col /**< index of the variable to be considered */ - ); - - /** - * @brief returns the nonzero coefficients of the coefficient matrix for a constraint - * @return vector of coefficients of in matrix for constraints - * @note same order as in @see getVarsForCons() - */ - std::vector& getValsForCons( - int consIndex /**< index of the constraint to be considered */ - ); - - /** - * @brief returns pointer to a variable partition with given index - * @return pointer to a variable partition with given index - */ - VarPartition* getVarPartition( - int partitionIndex /**< index of variable partition */ - ); - - /** - * @brief returns vector to stored variable partitions - * @return returns vector to stored variable partitions - */ - std::vector getVarPartitions(); - - /** - * @brief returns SCIP variable related to a variable index - * @return SCIP variable pointer related to a variable index - */ - SCIP_VAR* getVar( - int varIndex /**< index of the variable to be considered */ - ); - - /** - * @brief returns the variable indices of the coefficient matrix for a constraint - * @return the variable indices of the coefficient matrix for a constraint - */ - std::vector& getVarsForCons( - int consIndex /**< index of the constraint to be considered */ - ); - - /** - * @brief returns whether a constraint is a cardinality constraint, i.e. of the \f$\sum_{i} x_i = b\f$ - * @param consindexd index of constraint that is be checked - * @return returns whether a constraint is a cardinality constraint - */ - bool isConsCardinalityCons( - int consindexd - ); - - /** - * @brief determines whether or not the constraint-constraint adjacency data structure is initilized - * - * @returns true iff the constraint-constraint adjacency data structure is initilized - */ - SCIP_Bool isConssAdjInitialized(); - - /** - * @brief is cons with specified indec partitioning, or packing covering constraint? - * @param consindexd index of the given cons - * @return is cons with specified indec partitioning, or packing covering constraint - */ - bool isConsSetpp( - int consindexd - ); - - /** - * @brief is cons with specified index partitioning packing, or covering constraint? - * @param consindexd index of cons to be checked - * @return whether a constraint is partitioning packing, or covering constraint? - */ - bool isConsSetppc( - int consindexd - ); - - /** @brief is constraint ranged row, i.e., -inf < lhs < rhs < inf? - * - * @returns whether val is ranged row - */ - SCIP_Bool isFiniteNonnegativeIntegral( - SCIP* scip, /**< SCIP data structure */ - SCIP_Real x /**< value */ - ); - - /** - * @brief check if partialdec is a duplicate of an existing finished partialdec - * @param partialdec partialdec to be checked - * @returns TRUE iff partialdec is a duplicate of an existing finished partialdec - */ - SCIP_Bool isPartialdecDuplicateofFinished( - PARTIALDECOMP* partialdec - ); - - /** - * @brief returns true if the matrix structure corresponds to the presolved problem - * @return TRUE if the matrix structure corresponds to the presolved problem - */ - SCIP_Bool isAssignedToOrigProb(); - - /** @brief is constraint ranged row, i.e., -inf < lhs < rhs < inf? - * @returns whether constraint is ranged row - */ - SCIP_Bool isRangedRow( - SCIP* scip, /**< SCIP data structure */ - SCIP_Real lhs, /**< left hand side */ - SCIP_Real rhs /**< right hand side */ - ); - - /** - * @brief check if partialdec is a duplicate of any given partialdecs - * @param comppartialdec partialdec to be checked - * @param partialdecs partialdecs to compare with - * @param sort sort the vars and conss data structures in the partialdecs by their indices - * @return TRUE iff partialdec is no duplicate of any given partialdecs - */ - SCIP_Bool partialdecIsNoDuplicateOfPartialdecs( - PARTIALDECOMP* comppartialdec, - std::vector const & partialdecs, - bool sort - ); - - /** - * @brief output method for json file writer to write block candidate information - * @param scip SCIP data structure - * @param file output file or NULL for standard output - */ - void printBlockcandidateInformation( - SCIP* scip, /**< SCIP data structure */ - FILE* file /**< output file or NULL for standard output */ - ); - - /** - * @brief output method for json file writer to write partition candidate information - * @param file output file or NULL for standard output - */ - void printPartitionInformation( - FILE* file /**< output file or NULL for standard output */ - ); - - /** - * @brief sorts partialdecs in finished partialdecs data structure according to the current scoretype - */ - void sortFinishedForScore(); - - /** - * @brief translates partialdecs if the index structure of the problem has changed, e.g. due to presolving - * @return translated partialdecs - */ - std::vector translatePartialdecs( - DETPROBDATA* otherdata, /**< old detprobdata */ - std::vector otherpartialdecs /**< partialdecs to be translated */ - ); - - /** - * @brief translates partialdecs if the index structure of the problem has changed, e.g. due to presolving - * @return translated partialdecs - */ - std::vector translatePartialdecs( - DETPROBDATA* otherdata /**< old detprobdata */ - ); - - -}; -/* class DETPROBDATA */ - - -} /* namespace gcg */ - -/** - * \brief interface data structure for the detector calling methods - */ -struct Partialdec_Detection_Data -{ - gcg::DETPROBDATA* detprobdata; /**< current detprobdata to consider */ - gcg::PARTIALDECOMP* workonpartialdec; /**< partialdec (aka partial decomposition) to be propagted in next detector call */ - gcg::PARTIALDECOMP** newpartialdecs; /**< array of new partialdecs to filled by the detetcor methods */ - int nnewpartialdecs; /**< number of new neeed, set by the detector methods */ - double detectiontime; /**< time spent on detection */ -}; - -#endif /* GCG_CLASS_DETPROBDATA_H__ */ diff --git a/headers/gcg/class_indexpartition.h b/headers/gcg/class_indexpartition.h deleted file mode 100644 index c2f5a10..0000000 --- a/headers/gcg/class_indexpartition.h +++ /dev/null @@ -1,193 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* */ -/* This file is part of the program */ -/* GCG --- Generic Column Generation */ -/* a Dantzig-Wolfe decomposition based extension */ -/* of the branch-cut-and-price framework */ -/* SCIP --- Solving Constraint Integer Programs */ -/* */ -/* Copyright (C) 2010-2022 Operations Research, RWTH Aachen University */ -/* Zuse Institute Berlin (ZIB) */ -/* */ -/* This program is free software; you can redistribute it and/or */ -/* modify it under the terms of the GNU Lesser General Public License */ -/* as published by the Free Software Foundation; either version 3 */ -/* of the License, or (at your option) any later version. */ -/* */ -/* This program is distributed in the hope that it will be useful, */ -/* but WITHOUT ANY WARRANTY; without even the implied warranty of */ -/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ -/* GNU Lesser General Public License for more details. */ -/* */ -/* You should have received a copy of the GNU Lesser General Public License */ -/* along with this program; if not, write to the Free Software */ -/* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.*/ -/* */ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -/**@file class_indexpartition.h - * @brief generalization of ConsPartition and VarPartition - * @author Julius Hense - * - */ - -/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/ - -#ifndef GCG_CLASS_INDEXPARTITION_H__ -#define GCG_CLASS_INDEXPARTITION_H__ - -#include "objscip/objscip.h" -#include -#include - -namespace gcg -{ - -class IndexPartition -{ - -protected: - SCIP* scip; /**< scip data structure */ - -private: - std::string name; /**< name of the partition */ - int nClasses; /**< number of classes the partition provides */ - int nIndices; /**< number of indices */ - std::vector indicesToClasses; /**< index i is assigned to class indicesToClasses[i] (-1 if not assigned)*/ - std::vector classNames; /**< name of class k is classNames[k] */ - std::vector classDescriptions; /**< information text describing class k is classDescriptions[k] */ - std::vector classDecompInfo; /**< decomposition information of class k is classDecompInfo[k] */ - - -protected: - - /** constructor */ - IndexPartition( - SCIP* scip, /**< scip data structure */ - const char* name, /**< name of partition (will be copied) */ - int nClasses, /**< initial number of classes */ - int nIndices /**< number of indices to be classified */ - ); - - /** copy constructor */ - IndexPartition( - const IndexPartition* toCopy /**< IndexPartition to be copied */ - ); - - - /** destructor */ - virtual ~IndexPartition(); - - /** creates a new class, returns index of the class */ - int addClass( - const char* name, /**< name of the class (will be copied) */ - const char* desc /**< description of the class (will be copied) */ - ); - - /** assigns an index to a class */ - void assignIndexToClass( - int index, /**< index to be assigned */ - int classindex /**< index of the class */ - ); - - /** returns a vector containing all possible subsets of the given classindices */ - std::vector> getAllSubsets( - std::vector& classindices /**< classindices to be considered */ - ); - - /** returns the decomposition info of the a class */ - int getClassDecompInfo( - int classindex /**< index of the class */ - ); - - /** returns the name of the class an index is assigned to */ - const char* getClassNameOfIndex( - int index - ); - - /** returns the index of the class an index is assigned to */ - int getClassOfIndex( - int index - ); - - /** returns vector containing the assigned class of each index */ - std::vector& getIndicesToClasses( - ); - - /** returns the number of indices */ - int getNIndices( - ); - - /** returns a vector with the numbers of indices that are assigned to the classes */ - std::vector getNIndicesOfClasses( - ); - - /** returns whether an index is already assigned to a class */ - bool isIndexClassified( - int index - ); - - /** sets the decomposition info of the a class */ - void setClassDecompInfo( - int classindex, /**< index of the class */ - int decompInfo /**< decomposition info */ - ); - - -public: - - /** returns true if the other partition has an equivalent index structure, - * meaning that the partition of the set of constraints is the same ignoring the concrete classindices, classnames, etc. */ - bool isDuplicateOf( - IndexPartition* otherPartition /**< other partition to be checked */ - ); - - /** returns the information text of a class */ - const char* getClassDescription( - int classindex /**< index of class */ - ); - - /** returns the name of a class */ - const char* getClassName( - int classindex /**< index of class */ - ); - - /** returns the name of the partition */ - const char* getName( - ); - - - /** returns the number of classes the partition provides */ - int getNClasses( - ); - - /** returns a class index mapping for creating a new partition - * the enlarged class is always the class with index 0 - * returns empty vector if the current number of classes is lower than an upper bound - * or greater than 2*(upper bound) */ - std::vector reduceClasses( - int maxNumberOfClasses /**< upper bound */ - ); - - /** removes all classes which do not have any assigned index (classindices may change) - * returns number of removed classes */ - int removeEmptyClasses( - ); - - /** sets the information text of a class */ - void setClassDescription( - int classindex, /**< index of class */ - const char* desc /**< description of class (will be copied) */ - ); - - /** sets the name of a class */ - void setClassName( - int classindex, /**< index of class */ - const char* name /**< name of class (will be copied) */ - ); - -}; - - -} /* namespace gcg */ -#endif /* SRC_CLASS_INDEXPARTITION_H_ */ diff --git a/headers/gcg/class_partialdecomp.h b/headers/gcg/class_partialdecomp.h deleted file mode 100644 index d051070..0000000 --- a/headers/gcg/class_partialdecomp.h +++ /dev/null @@ -1,2081 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* */ -/* This file is part of the program */ -/* GCG --- Generic Column Generation */ -/* a Dantzig-Wolfe decomposition based extension */ -/* of the branch-cut-and-price framework */ -/* SCIP --- Solving Constraint Integer Programs */ -/* */ -/* Copyright (C) 2010-2022 Operations Research, RWTH Aachen University */ -/* Zuse Institute Berlin (ZIB) */ -/* */ -/* This program is free software; you can redistribute it and/or */ -/* modify it under the terms of the GNU Lesser General Public License */ -/* as published by the Free Software Foundation; either version 3 */ -/* of the License, or (at your option) any later version. */ -/* */ -/* This program is distributed in the hope that it will be useful, */ -/* but WITHOUT ANY WARRANTY; without even the implied warranty of */ -/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ -/* GNU Lesser General Public License for more details. */ -/* */ -/* You should have received a copy of the GNU Lesser General Public License */ -/* along with this program; if not, write to the Free Software */ -/* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.*/ -/* */ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -/**@file class_partialdecomp.h - * @brief class storing (potentially incomplete) decompositions - * @note formerly called "Seeed" - * @author Michael Bastubbe - * @author Hannah Hechenrieder - * @author Hanna Franzen - */ - -/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/ - -#ifndef GCG_CLASS_PARTIALDECOMP_H__ -#define GCG_CLASS_PARTIALDECOMP_H__ - -#include "objscip/objscip.h" -#include "struct_detector.h" - -#include -#include - -#include "class_conspartition.h" -#include "class_varpartition.h" -#include "graph/graph_gcg.h" -#include "graph/graph.h" -#include "type_scoretype.h" - -#include "reader_gp.h" - -namespace gcg { - - -/** - * @brief enumeration to display if a decomposition was given by the user and if so, how it was processed after adding - */ -enum USERGIVEN -{ - NOT = 0, /**< this partialdec was not given by the user */ - PARTIAL = - 1, /**< this partial partialdec was given by the user as it is*/ - COMPLETE = - 2, /**< this complete partialdec was given by the user as it is*/ - COMPLETED_CONSTOMASTER = - 3 /**< this partialdec was partially given by the user and then completed by setting all missing constraints to the master*/ -}; - -class DETPROBDATA; - - -/*! - * @brief class to manage partial decompositions - * - * each partialdec corresponds to one detprobdata which contains the problem information, - * there is one detprobdata for the original and the transformed problem. - */ -class PARTIALDECOMP -{ -private: - SCIP* scip; /**< SCIP data structure */ - int id; /**< unique id of the partialdec, unique */ - int nblocks; /**< number of blocks the partial decomposition currently has */ - int nvars; /**< number of variables */ - int nconss; /**< number of constraints */ - std::vector masterconss; /**< vector containing indices of master constraints */ - std::vector mastervars; /**< vector containing indices of master variables (these variables are supposed to have all nonzero entries in master constraints) */ - std::vector> conssforblocks; /**< conssforblocks[k] contains a vector of indices of all - *< constraints assigned to block k */ - std::vector> varsforblocks; /**< varsforblocks[k] contains a vector of indices of all - *< variables assigned to block k */ - std::vector linkingvars; /**< vector containing indices of linking variables */ - std::vector> stairlinkingvars; /**< vector containing indices of staircase linking variables - *< of the blocks (stair-linking variables are registered only - *< in their first block) */ - std::vector openvars; /**< vector containing indices of variables that are not - *< assigned yet*/ - std::vector openconss; /**< vector containing indices of constraints that are not - *< assigned yet*/ - std::vector isvaropen; /**< whether ith variable is still open */ - std::vector isconsopen; /**< whether ith constraint is still open */ - std::vector isvarmaster; /**< whether ith variable is assigned to be a only-master variable */ - std::vector isconsmaster; /**< whether ith constraint is assigned to be a master constraint */ - - std::vector ncoeffsforblock; /**< number of coeffs per block */ - - SCIP_Bool calculatedncoeffsforblock; /**< is the number of coeff per block already calculated*/ - int ncoeffsformaster; /**< number of master coefficients */ - std::vector> ncoeffsforblockformastercons; /**< number of coeffs a block has in a certain master constraint */ - - bool varsforblocksorted; /**< bool to store if the varsforblocks datastructure is sorted atm */ - bool stairlinkingvarsforblocksorted; /**< bool to store if the stairlinkingvarsforblock datastructure is sorted atm */ - bool conssforblocksorted; /**< bool to store if the conssforblock datastructure is sorted atm */ - bool linkingvarssorted; /**< bool to store if the linkingvars datastructure is sorted atm */ - bool mastervarssorted; /**< bool to store if the mastervars datastructure is sorted atm */ - bool masterconsssorted; /**< bool to store if the masterconsssorted datastructure is sorted atm */ - - unsigned long hashvalue; /**< hash value of this partial decomposition, decompositions with same has value are considered to be identical */ - bool hvoutdated; /**< true if the internal structure changed such that the hash value needs to be recalculated */ - - bool isselected; /**< is this partialdec selected */ - - bool isagginfoalreadytoexpensive; /**< is agginfo already known to be to expensive to calculate*/ - - const static int primes[]; /**< an array of prime numbers to calculate the hash value */ - const static int nprimes; /**< size of the array of prime numbers */ - - bool isfinishedbyfinisher; /**< was this partialdec finished by the finishpartialdec() method of a detector */ - - /* aggregation information */ - int nrepblocks; /**< number of block representatives */ - std::vector> reptoblocks; /**< translation of the block representatives to (old) blocks */ - std::vector blockstorep; /**< translation of the (old) blocks to the block representatives */ - std::vector > > pidtopidvarmaptofirst; /**< [nrepblocks][blockstorep[k].size()][nvarsforprob] collection of varmaps of probindices from k-th subproblem to the zeroth block that is represented */ - - /* statistic information */ - std::vector detectorchain; /**< vector containing detectors that worked on that partialdec */ - std::vector detectorchaininfo; /**< vector containing information about the detector call */ - std::vector detectorclocktimes; /**< vector containing detector times in seconds */ - std::vector pctvarstoborder; /**< vector containing the fraction of variables assigned to the - *< border for each detector working on that partialdec*/ - std::vector pctvarstoblock; /**< vector containing the fraction of variables assigned to a block - *< for each detector working on that partialdec*/ - std::vector pctvarsfromfree; /**< vector containing the fraction of variables that are not longer - *< open for each detector working on that partialdec*/ - std::vector pctconsstoborder; /**< vector containing the fraction of constraints assigned to the - *< border for each detector working on that partialdec*/ - std::vector pctconsstoblock; /**< vector containing the fraction of constraints assigned to a block - *< for each detector working on that partialdec*/ - std::vector pctconssfromfree; /**< vector containing the fraction of constraints that are not longer - *< open for each detector working on that partialdec*/ - std::vector nnewblocks; /**< vector containing information how many new blocks a detector has assigned */ - - std::vector usedpartition; /**< vector containing pointer to the cons- or varpartitions - *< a detector made use of for each detector working on that partialdec - *< (NULL if no partition was used) */ - std::vector> classestomaster; /**< vector containing the vector of classindices that were assigned - *< to master by the partition used by a detector - *< (empty vector if no partition was used) */ - std::vector> classestolinking; /**< vector containing the vector of classindices that were assigned - *< to linking by the partition used by a detector - *< (empty vector if no partition was used) */ - - std::vector listofancestorids; /**< vector containing decomposition indices that are ancestors of this partialdec */ - - USERGIVEN usergiven; /**< is this partialdec partially or completely given by user */ - - /* score values (or -1 iff nott computed yet) */ - - SCIP_Real maxwhitescore; /**< score corresponding to the max white measure */ - SCIP_Real borderareascore; /**< 1 - fraction of border area to complete area */ - SCIP_Real classicscore; /**< classic score to evaluate the partial */ - SCIP_Real maxforeseeingwhitescore; /**< maximum foreseeing white area score (i.e. maximize fraction of white area score considering problem with copied linking variables and corresponding master constraints; white area is nonblock and nonborder area, stairlinking variables count as linking) */ - SCIP_Real setpartfwhitescore; /**< setpartitioning maximum foreseeing white area score (i.e. convex combination of maximum foreseeing white area score and a boolean score rewarding a master containing only setppc and cardinality constraints )*/ - SCIP_Real maxforeseeingwhitescoreagg; /**< maximum foreseeing white area score with respect to aggregatable blocks (i.e. maximize fraction of white area score considering problem with copied linking variables and corresponding master constraints; white area is nonblock and nonborder area, stairlinking variables count as linking) */ - SCIP_Real setpartfwhitescoreagg; /**< setpartitioning maximum foreseeing white area score with respect to aggregateable (i.e. convex combination of maximum foreseeing white area score and a boolean score rewarding a master containing only setppc and cardinality constraints )*/ - SCIP_Real bendersscore; /**< score to evaluate the partialdecs */ - SCIP_Real strongdecompositionscore; /**< strong decomposition score */ - - /* datastructure to store information if this partialdec stems from a partialdec concerning the orig problem */ - bool stemsfromorig; /**< partialdec has at least one ancestor that is a partialdec from orig problem */ - bool original; /**< indicates whether partialdec is from original problem */ - bool isfinishedbyfinisherorig; /**< was the ancestor partialdec for the unpresolved problem finished by the - *< finishpartialdec() method of a detector */ - DEC_DETECTOR* finishedorigby; /**< index of finishing detector of orig ancestor partialdec */ - - int translatedpartialdecid; - -private: - /**< id of the translated partialdec */ - - /** - * - * @brief simple bliss automorphism check for blocks - * - * Checks blocks for equality by graph automorphism check, done by bliss - * @note equality is only found if variables are in correct order - */ - void checkIdenticalBlocksBliss( - int b1, /**< block id of first block */ - int b2, /**< block id of second block */ - std::vector& varmap, /**< maps variable indices (corresponding to detprobdata indices) of block 2 to block 1 */ - SCIP_HASHMAP* varmap2, /**< maps variable pointers of block 2 to those of block 1 if both blocks (problems) are identical*/ - SCIP_Bool* identical, /**< pointer to store if the subproblems are identical */ - unsigned int searchnodelimit, /**< bliss search node limit (requires patched bliss version) */ - unsigned int generatorlimit /**< bliss generator limit (requires patched bliss version) */ - - ); - - - /** - * @brief brute force equality check for blocks - * - * Checks blocks for equality by brute force - * @note equality is only found if variables are in correct order - */ - void checkIdenticalBlocksBrute( - int b1, /**< block id of first block */ - int b2, /**< block id of second block */ - std::vector& varmap, /**< maps variable indices (corresponding to detprobdata indices) of prob2 to prob1 */ - SCIP_HASHMAP* varmap2, /**< maps variable pointers of block 2 to those of block 1 if both blocks (problems) are identical*/ - SCIP_Bool* identical /**< pointer to store if the subproblems are identical */ - ); - - - /** - * @brief plausibility check whether two blocks could be identical - * - * Check some necessary conditions for two blocks to be identical - */ - void checkIdenticalBlocksTrivial( - int b1, /**< block id of first block */ - int b2, /**< block id of second block */ - SCIP_Bool* notidentical /**< pointer to store whether or not the non-equality is proven */ - ); - -public: - - /** - * @brief Standard constructor, creates empty partialdec with unique id - * @note initially, all conss and vars are open - */ - PARTIALDECOMP( - SCIP* scip, /**< scip data structure */ - bool originalProblem /**< true iff partialdec is for presolved problem (else for original problem) */ - ); - - /** - * @brief copy constructor - */ - PARTIALDECOMP( - const PARTIALDECOMP *partialdecToCopy /**< partialdec to be copied */ - ); - - /** - * Standard destructor - */ - ~PARTIALDECOMP(); - - /** - * @brief adds a block - * @returns the number (id) of the new block - * */ - int addBlock(); - - /** - * @brief adds detection time of one detector - * - * incorporates the needed time of some detector in the detector chain - */ - void addClockTime( - SCIP_Real clocktime /**< time to be added */ - ); - - /** - * @brief adds the statistical differences to an ancestor - * - * incorporates the changes from ancestor partialdec into the statistical data structures - */ - void addDecChangesFromAncestor( - PARTIALDECOMP* ancestor /**< partialdec whose propagation yielded to the current partialdec */ - ); - - /** - * @brief add information about the detector chain - * - * adds a detectorchain information string to the corresponding vector - * (that carries information for each detector call) - * */ - void addDetectorChainInfo( - const char* decinfo /**< information string (about the detector call) to add */ - ); - - /** - * @brief adds how many new blocks were introduced - * - * bookkeeping information: adds number of new blocks created by a detector added to detector chain - */ - void addNNewBlocks( - int nnewblocks /**< number of new added blocks by latest detector call */ - ); - - /** - * @brief adds percentage of closed constraints - * - * bookkeeping information: fraction of constraints that are not longer open for a detector added to detector chain - */ - void addPctConssFromFree( - SCIP_Real pct /**< fraction of constraints that are not longer open */ - ); - - /** - * @brief adds percentage of constraints assigned to blocks - * - * bookkeeping information: adds fraction of constraints assigned to a block for a detector added to detector chain - * */ - void addPctConssToBlock( - SCIP_Real pct /**< fraction of constraints assigned to a block */ - ); - - /** - * @brief adds percentage of constraints assigned to border - * - * bookkeeping information: adds fraction of constraints assigned to the border for a detector added to detector chain - */ - void addPctConssToBorder( - SCIP_Real pct /**< fraction constraints assigned to the border */ - ); - - /** - * @brief adds percentage of closed variables - * - * bookkeeping information: adds fraction of variables that are not longer open for a detector added to detector chain - */ - void addPctVarsFromFree( - SCIP_Real pct /**< fraction of variables that are not longer open */ - ); - - - /** - * @brief adds percentage of variables assigned to blocks - * - * bookkeeping information: adds fraction of variables assigned to a block for a detector added to detector chain - * */ - void addPctVarsToBlock( - SCIP_Real pct /**< fraction of variables assigned to a block */ - ); - - /** - * @brief adds percentage of variables assigned to border - * - * bookkeeping information: adds fraction of variables assigned to the border for a detector added to detector chain - */ - void addPctVarsToBorder( - SCIP_Real pct /**< fraction of variables assigned to the border */ - ); - - /** - * @brief method to check if at least one constraint is assigned to some block - * @returns true iff at least one constraint is assigned to a block - * */ - bool alreadyAssignedConssToBlocks(); - - /** - * @brief assigns open conss to master - * - * assigns open constraints to master according to the cons assignment information given in constoblock hashmap - * @returns scip return code - * @note for conss assigned to blocks according to constoblock there is no assignment \see assignPartialdecFromConstoblock - * @note master assignment is indicated by assigning cons to index additionalNBlocks - * */ - SCIP_RETCODE assignBorderFromConstoblock( - SCIP_HASHMAP* constoblock, /**< hashmap assigning cons indices (not SCIP_Cons*) to block indices */ - int givenNBlocks /**< number of blocks the hashmap contains */ - ); - - /** - * @brief assigns open vars to stairlinking if appropriate - * - * assigns open vars to stairlinking if they can be found in exactly two consecutive blocks - * @returns true iff at least one stairlinkingvar was assigned - */ - bool assignCurrentStairlinking( - ); - - /** - * @brief assigns open conss to master - */ - void assignOpenConssToMaster( - ); - - /** - * @brief assigns conss structure according to given hashmap - * - * adds blocks and assigns open conss to a new block or to master - * according to the cons assignment information given in constoblock hashmap - * @returns scip return code - * \see assignPartialdecFromConstoblockVector() - * @note master assignment is indicated by assigning cons to index additionalNBlocks - * */ - SCIP_RETCODE assignPartialdecFromConstoblock( - SCIP_HASHMAP* constoblock, /**< hashmap assigning cons indices (not SCIP_Cons*) to block indices */ - int additionalNBlocks /**< number of (additional) blocks the hashmap contains */ - ); - - /*! - * @brief assigns conss structure according to given vector - * - * adds blocks and assigns open conss to a new block or to master - * according to the cons assignment information given in constoblock vector - * @returns scip return code - * \see assignPartialdecFromConstoblock() - * @note master is indicated by assigning cons to index additionalNBlocks */ - SCIP_RETCODE assignPartialdecFromConstoblockVector( - std::vector constoblock, /**< vector containing an assignment of conss to a block or to master */ - int additionalNBlocks /**< number of (additional) blocks the vector contains */ - ); - - /** - * @brief computes components by connectedness of conss and vars - * - * computes components corresponding to connectedness of conss and vars - * and assigns them accordingly (all but one of largest components) - * - * strategy: assigns all conss same block if they are connected - * two constraints are adjacent if there is a common variable - * - * @note this relies on the consadjacency structure of the detprobdata - * hence it cannot be applied in presence of linking variables - */ - void assignSmallestComponentsButOneConssAdjacency( - ); - - /** - * @brief reassigns linking vars to stairlinkingvars if possible - * - * potentially reorders blocks for making a maximum number of linking vars stairlinking - * if all vars that connect exactly two blocks have a staircase structure, all of them become stairlinkingvars - * otherwise, the stairlinking assignment is done greedily - * @note precondition: partialdec does not have any stairlinking vars - */ - void calcStairlinkingVars( - ); - - /** - * @brief checks if all conss are assigned - * - * returns true iff all constraints are assigned and deletes the vector open conss if so - * @return true iff all constraints are assigned - * */ - bool checkAllConssAssigned(); - - /** - * @brief Checks whether the assignments in the partialdec are consistent - * - * The following checks are performed: - * - check if nblocks is set appropriately - * - check for empty (row- and col-wise) blocks - * - every variable is assigned at most once - * - check if all not assigned variables are open vars - * - check if all open vars are not assigned - * - every constraint is assigned at most once - * - check if all not assigned constraints are open cons - * - check if all open conss are not assigned - * - check if the data structures are sorted - * - check if variables hitting a cons are either in the cons's block or border or still open - * @returns true iff the partialdec seems to be consistent - * */ - bool checkConsistency( - ); - - /** - * @brief assigns all open constraints and open variables trivially - * - * strategy: assigns all open conss and vars to blocks if they can be refined there, otherwise to the master - * - * @note partialdecomps should usually be completed by a detector, only use this function if you know what you are doing. - */ - void complete( - ); - - /** - * @brief assigns all open constraints and open variables - * - * strategy: assigns all conss and vars to the same block if they are connected, - * a cons and a var are adjacent if the var appears in the cons - */ - void completeByConnected( - ); - - /** - * @brief assigns all open constraints and open variables - * - * strategy: assigns all conss and vars to the same block if they are connected - * a cons and a var are adjacent if the var appears in the cons - * \note this relies on the consadjacency structure of the detprobdata - * hence it cannot be applied in presence of linking variables - */ - void completeByConnectedConssAdjacency( - ); - - /** - * @brief assigns all open constraints and open variables - * - * strategy: assigns a cons (and related vars) to a new block if possible, - * if not to an existing block if possible (by means of prior var assignments) - * and finally to master, if there does not exist such a block - */ - void completeGreedily( - ); - - /** @brief removes the given cons from master - */ - void removeMastercons( - int consid /**< id of cons */ - ); - - /** - * @brief: assigns every open cons/var - * - * Assignments happen as follows: - * - to the respective block if it hits exactly one blockvar/blockcons and no open vars/conss - * - to master/linking if it hits blockvars/blockconss assigned to different blocks - * - and every cons to master that hits a master var - * - and every var to master if it does not hit any blockcons and has no open cons - * - leave the cons/variableopen if nothing from the above holds - * */ - void considerImplicits( - ); - - /** - * @brief copies the given partialdec's partition statistics - * - * @param otherpartialdec partialdec whose partition statistics are to be copied - */ - void copyPartitionStatistics( - const PARTIALDECOMP* otherpartialdec - ); - - /** - * @brief deletes empty blocks and sets nblocks accordingly - * - * A block is considered to be empty if no constraint is assigned to it, - * variables in blocks with no constraints become open - * - * @param variables if true, then blocks with no constraints but at least one variable are considered to be nonempty - */ - void deleteEmptyBlocks( - bool variables - ); - - /** - * @brief deletes a cons from list of open conss - * - * @param opencons id of the cons that is not considered open anymore - */ - void deleteOpencons( - int opencons - ); - - /** - * @brief deletes a cons from list of open conss - * - * @param itr valid iterator pointing to elements of PARTIALDECOMP::openconss - */ - std::vector::const_iterator deleteOpencons( - std::vector::const_iterator itr - ); - - /** - * @brief deletes a var from the list of open vars - * - * @param openvar id of the var that is not considered open anymore - */ - void deleteOpenvar( - int openvar - ); - - /** - * @brief deletes a var from the list of open vars - * - * @param itr valid iterator pointing to elements of PARTIALDECOMP::openvars - */ - std::vector::const_iterator deleteOpenvar( - std::vector::const_iterator itr - ); - - /** - * @brief displays the relevant information of the partialdec - * - * @param detailLevel pass a value that indicates how detailed the output should be: - * 0: brief overview - * 1: block and detector info - * 2: cons and var assignments - */ - void displayInfo( - int detailLevel - ); - - /** - * @brief every constraint is either assigned to master or open - * - * Assignment happens according to the cons assignment information given in constoblock hashmap, - * variables are set accordingly - * @note precondition: no constraint or variable is already assigned to a block - * @return scip return code - */ - SCIP_RETCODE filloutBorderFromConstoblock( - SCIP_HASHMAP* constoblock, /**< hashmap assigning cons indices (not SCIP_Cons*) to block indices - *< (master assignment is indicated by assigning cons to index additionalNBlocks) */ - int givenNBlocks /**< number of blocks the hashmap contains */ - ); - - /** - * @brief assigns all conss to master or a block - * - * Assignment happens according to the cons assignment information given in constoblock hashmap - * - * @return scip return code - * calculates implicit variable assignment through cons assignment - * @note precondition: no cons or var is already assigned to a block and constoblock contains information for every cons */ - - SCIP_RETCODE filloutPartialdecFromConstoblock( - SCIP_HASHMAP* constoblock, /**< hashmap assigning cons indices (not SCIP_Cons*) to block indices - *< (master assignment is indicated by assigning cons to index additionalNBlocks) */ - int givenNBlocks /**< number of blocks the hashmap contains */ - ); - - /** - * @brief reassigns linking variables to master if appropriate - * - * Variables are reassigned as master if the variable only hits master conss - */ - void findVarsLinkingToMaster( - ); - - /** - * @brief reassigns variables classified as linking to stairlinking if appropriate - * - * Variables are reassigned as master if the variable hits conss in exactly two consecutive - * blocks - */ - void findVarsLinkingToStairlinking( - ); - - /** - * @brief gets partialdec id of given ancestor id - * @return partialdec id of given ancestor id - */ - int getAncestorID( - int ancestorindex /**< index of ancestor in list of ancestor ids data structure */ - ); - - /** - * @brief get ancestor ids as vector - * @return vector of ids of all ancestors id - */ - std::vector& getAncestorList( - ); - - /** - * set ancestor list directly - * @param newlist new list of ancestor ids - */ - void setAncestorList( - std::vector& newlist - ); - - /** removes ancestor id from list */ - void removeAncestorID( - int ancestorid /**< id to remove */ - ); - - /** - * adds ancestor id to back of list - * @param ancestor id of ancestor that is to be added - */ - void addAncestorID( - int ancestor - ); - - /** - * @brief get a vector of block ids that are identical to block with id repid - * @param repid id of the representative block - * @return vector of block ids that are identical to block with id repid - */ - const std::vector & getBlocksForRep( - int repid - ); - - /** - * @brief returns the time that the detector related to the given detectorchainindex needed for detecting - * @return the clock time for the corresponding detector in the chain - */ - SCIP_Real getDetectorClockTime( - int detectorchainindex /**< index of the detector in the detectorchain */ - ); - - /** - * @brief returns a vector of the clock times that each detector needed that was involved in this partialdec - * @return vector of the clock times - */ - std::vector& getDetectorClockTimes(); - - /** - * @brief returns array containing constraints assigned to a block - * @param block id of the block the constraint indices are returned - * @return array containing constraints assigned to a block - */ - std::vector& getConssForBlock( - int block - ); - - /** - * @brief returns detector chain as vector of detector pointers - * @return detector chain as array of detector pointers - */ - std::vector& getDetectorchain(); - - /** - * @brief returns true iff this partialdec was finished by finishPartialdec() method of a detector - * @return true iff this partialdec was finished by finishPartialdec() method of a detector - */ - bool getFinishedByFinisher(); - - /** - * @brief returns the calculated hash value of this partialdec - * @return the calculated hash value of this partialdec - */ - unsigned long getHashValue(); - - /** - * @brief returns the unique id of the partialdec - * @return the unique id of the partialdec - */ - int getID(); - - /** - * @brief returns array containing all linking vars indices - * @return vector containing all linking vars indices - * @note when accessed it is supposed to be sorted - */ - std::vector& getLinkingvars(); - - /** - * @brief Gets array containing all master conss indices - * @return array containing all master conss indices - * @note when accessed it is supposed to be sorted - */ - std::vector& getMasterconss(); - - /** - * @brief Gets array containing all master vars indices - * - * master vars hit only constraints in the master, aka static variables - * @return array containing all master vars indices - */ - std::vector& getMastervars(); - - /** - * @brief Gets the number of nonzero coeffs in a certain block - * @param blockid of the block the number of nozerors are requested for - * @return number of nonzero coeffs in a certain block - */ - int getNCoeffsForBlock( - int blockid - ); - - /** - * Gets the number of nonzero coeffs in master - * @return the number of nonzero coeffs in master - */ - int getNCoeffsForMaster( - ); - - /** - * @brief returns the score of the partialdec (depending on used scoretype) - * @param type the scoretype - * @return the score - * @see enum scoretype in cons_decomp.h - */ - SCIP_Real getScore( - SCORETYPE type - ); - - /** - * @brief checks if all master constraints set partitioning, set packing, set cover, or cardinality constraints - * @return TRUE iff all master constraints set partitioning, set packing, set cover, or cardinality constraints - */ - SCIP_Bool hasSetppccardMaster( - ); - - /** - * @brief checks iff all master constraints set partitioning, set packing, or set cover constraints - * @return TRUE iff all master constraints set partitioning, set packing, or set cover - */ - SCIP_Bool hasSetppcMaster( - ); - - /** - * @brief checks iff all master constraints set partitioning, or set packing constraints - * @return TRUE iff all master constraints set partitioning, or set packing constraints - */ - SCIP_Bool hasSetppMaster( - ); - - /** - * @brief Gets the USERGIVEN status of this partialdecs - * @return the USERGIVEN status of this partialdecs - * @see enum USERGIVEN - */ - USERGIVEN getUsergiven(); - - /** - * @brief Gets number of ancestor partialdecs - * @return number of ancestor partialdecs - */ - int getNAncestors(); - - /** - * @brief Gets the number of blocks - * @return number of blocks - */ - int getNBlocks(); - - /** - * @brief Gets the number of constraints - * @return number of constraints - */ - int getNConss(); - - /** - * @brief Gets size of the vector containing conss assigned to a block - * @param block id of the block the number of constraints is asked for - * @return size of the vector containing conss assigned to a block - */ - int getNConssForBlock( - int block - ); - - /** - * @brief Gets the detectorchain info vector - * @return detectorchain info vector - */ - std::vector& getDetectorchainInfo(); - - /** - * @brief Gets the number of detectors the partialdec is propagated by - * @return number of detectors the partialdec is propagated by - */ - int getNDetectors(); - - /** - * @brief Gets size of the vector containing linking vars - * @return size of the vector containing linking vars - */ - int getNLinkingvars(); - - /** - * @brief Gets size of the vector containing master conss - * @returns size of the vector containing master conss - */ - int getNMasterconss(); - - /** - * @brief Gets size of the vector containing master vars - * - * master vars hit only constraints in the master - * @return size of the vector containing master vars - */ - int getNMastervars(); - - /** - * @brief Gets number of blocks a detector added - * - * @return number of blocks a detector added - */ - int getNNewBlocks( - int detectorchainindex /**< index of the detector in the detectorchain */ - ); - - /** - * @brief gets number of blocks the detectors in the detectorchain added - * @return number of blocks the detectors in the detectorchain added - */ - std::vector getNNewBlocksVector(); - - /** - * @brief Gets total number of stairlinking vars - * @return total number of stairlinking vars - */ - int getNTotalStairlinkingvars(); - - /** - * @brief Gets size of vector containing constraints not assigned yet - * @return returns size of vector containing constraints not assigned yet - */ - int getNOpenconss(); - - /** - * @brief Gets size of vector containing variables not assigned yet - * @return size of vector containing variables not assigned yet - */ - int getNOpenvars(); - - /** - * @brief Gets the number of blockrepresentatives - * @return the number of blockrepresentatives - */ - int getNReps(); - - /** - * @brief Gets size of the vector containing stairlinking vars - * @param block id of the block the size of the stairlinking vector is asked for - * @return size of the vector containing stairlinking vars - */ - int getNStairlinkingvars( - int block - ); - - /** - * @brief Gets number of vars - * @return number of vars - */ - int getNVars(); - - /** - * @brief Gets size of the vector containing vars assigned to a block - * @param block id of the block the number of variables is asked for - * @return size of the vector containing vars assigned to a block - */ - int getNVarsForBlock( - int block - ); - - /** - * @brief Gets overall number of vars assigned to a block - * @return number of vars that are assigned to any block - */ - int getNVarsForBlocks( - ); - - /** - * @brief Gets array containing constraints not assigned yet - * @return array containing constraints not assigned yet - */ - const int* getOpenconss(); - - /** - * @brief Gets a vector containing constraint ids not assigned yet as vector - * @return returns a vector containing constraint ids not assigned yet as vector - */ - std::vector& getOpenconssVec(); - - /** - * @brief Gets array containing variables not assigned yet - * @return returns array containing variables not assigned yet - */ - const int* getOpenvars(); - - /** - * Gets array containing variables not assigned yet as vector - * @return array containing variables not assigned yet as vector - */ - std::vector& getOpenvarsVec(); - - /** - * @brief Gets fraction of variables assigned to the border for a detector - * - * @return fraction of variables assigned to the border for a detector - */ - SCIP_Real getPctVarsToBorder( - int detectorchainindex /**< index of the detector in the detectorchain */ - ); - - /** - * @brief Gets fraction of variables assigned to the border for detectors in detectorchain - * @return vector of fractions of variables assigned to the border for detectors in detectorchain - */ - std::vector& getPctVarsToBorderVector(); - - /** - * @brief Gets fraction of variables assigned to a block for a detector - * - * @return fraction of variables assigned to a block for a detector - */ - SCIP_Real getPctVarsToBlock( - int detectorchainindex /**< index of the detector in the detectorchain */ - ); - - /** - * @brief returns fraction of variables assigned to a block for detectors in detectorchain - * @return vector of fractions of variables assigned to a block for detectors in detectorchain - */ - std::vector& getPctVarsToBlockVector(); - - /** - * @brief Gets fraction of variables that are not longer open for a detector - * - * @return index of the detector in the detectorchain - */ - SCIP_Real getPctVarsFromFree( - int detectorchainindex /**< index of the detector in the detectorchain */ - ); - - /** - * @brief Gets fraction of variables that are not longer open for detectors in detectorchain - * @return vector or fractions of variables that are not longer open for detectors in detectorchain - */ - std::vector& getPctVarsFromFreeVector(); - - /** - * @brief Gets fraction of constraints assigned to the border for a detector - * @return returns fraction of constraints assigned to the border for a detector - */ - /** */ - SCIP_Real getPctConssToBorder( - int detectorchainindex /**< index of the detector in the detectorchain */ - ); - - /** - * @brief Gets fraction of constraints assigned to the border for detectors in detectorchain - * @return vector of fractions of constraints assigned to the border for detectors in detectorchain - */ - std::vector& getPctConssToBorderVector(); - - /** - * @brief Gets fraction of constraints assigned to a block for a detector - * @return fraction of constraints assigned to a block for a detector - */ - SCIP_Real getPctConssToBlock( - int detectorchainindex /**< index of the detector in the detectorchain */ - ); - - /** - * @brief Gets fraction of constraints assigned to a block for detectors in detectorchain - * @return vector of fractions of constraints assigned to a block for detectors in detectorchain - */ - std::vector& getPctConssToBlockVector(); - - /** - * @brief Gets fraction of constraints that are not longer open for a detector - * @return fraction of constraints that are not longer open for a detector - */ - SCIP_Real getPctConssFromFree( - int detectorchainindex /**< index of the detector in the detectorchain */ - ); - - /** - * @brief Gets fraction of constraints that are not longer open for detectors in detectorchain - * @return vector of fractions of constraints that are not longer open for detectors in detectorchain - */ - std::vector& getPctConssFromFreeVector(); - - /** - * @brief Gets index of the representative block for a block, this might be blockid itself - * @param blockid id of the block the representative is asked for - * @return index of the representative block for a block, this might be blockid itself - */ - int getRepForBlock( - int blockid - ); - - /** - * @brief Gets the represenation varmap - * - * Var map is vector for represenative repid and the blockrepid-th block that is represented by repid - * @param repid id of representative - * @param blockrepid id of block - * @return the represenation varmap as vector for represenative repid and the blockrepid-th block that is represented by repid - */ - - std::vector & getRepVarmap( - int repid, - int blockrepid - ); - - /** - * @brief Gets the corresponding detprobdata - * @return corresponding detprobdata - */ - DETPROBDATA* getDetprobdata(); - - /** - * @brief Gets array containing stairlinking vars, - * @note if a stairlinking variable links block i and i+1 it is only stored in vector of block i - * @param block id of the block the stairlinking variable varctor is asked for - * @return array containing stairlinking vars, - */ - const int* getStairlinkingvars( - int block - ); - - /** - * @brief Gets array containing vars of a block - * @param block id of the block the vars are requested for - * @return returns array containing vars of a block - */ - std::vector& getVarsForBlock( - int block - ); - - /** - * @brief Gets index in variables array of a block for a variable - * @param varid the id of the variable the index - * @param block the corresponding block id - * @return returns index in variables array of a block for a variable - */ - int getVarProbindexForBlock( - int varid, - int block - ); - - /** - * @brief Gets whether this partialdec is complete, - * i.e. it has no more open constraints and variables - * @return TRUE iff this partialdec is complete - */ - bool isComplete(); - - /** - * @brief Gets whether the cons is a master cons - * @param cons id of ccons to check if it is master constraint - * @return true iff the cons is a master cons - */ - bool isConsMastercons( - int cons - ); - - /** - * @brief Gets whether the cons is an open cons - * @param cons id of cons to check - * @return true iff the cons is an open cons - */ - bool isConsOpencons( - int cons - ); - - /** - * @brief Gets whether the partialdec is from the presolved problem - * @return true iff the partialdec is from the presolved problem - */ - bool isAssignedToOrigProb(); - - /** - * Gets whether the partialdec is currently selected in explore menue - * @return true iff the partialdec is currently selected in explore menue - */ - bool isSelected(); - - /** - * @brief method to check whether this partialdec is equal to a given other partialdec ( \see isEqual(PARTIALDECOMP*)) - - * @return scip return code - */ - SCIP_RETCODE isEqual( - PARTIALDECOMP* otherpartialdec, /**< other partialdec */ - SCIP_Bool* isequal, /**< pointer to store whether partialdecs are identical */ - bool sortpartialdecs /**< should conss and vars be sorted before comparing the partialdecs? */ - ); - - /** - * @brief method to check whether this partialdec is equal to a given other partialdec - * - * @return true iff partialdecs are equal - */ - bool isEqual( - PARTIALDECOMP* other /**< other partialdec to check equality with */ - ); - - /** - * @brief Gets whether this partialdec was propagated by specified detector - * @param detector pointer to detector to check for - * @return true iff this partialdec was propagated by detectorID - */ - bool isPropagatedBy( - DEC_DETECTOR* detector - ); - - /** - * @brief Gets whether this partialdec is considered to be trivial - * - * PARTIALDECOMP is considered trivial if all conss are in one block, all conss are in border, - * all variables linking or mastervars, or all constraints and variables are open - * @return true iff this partialdec is considered to be trivial - */ - bool isTrivial(); - - /** - * @brief Checks whether the var is assigned to the block - * @param var id of var to check - * @param block id of block to check - * @return true iff the var is assigned to the block - */ - bool isVarBlockvarOfBlock( - int var, - int block - ); - - /** - * @brief Checks whether the var is a linking var - * @param var id of var to check - * @return true iff the var is a linking var - */ - bool isVarLinkingvar( - int var - ); - - /** - * @brief Checks whether the var is a master var - * @param var id of var to check - * @return true iff the var is a master var - */ - bool isVarMastervar( - int var - ); - - /** - * @brief Checks whether the var is an open var - * @param var id of var to check - * @return true iff the var is an open var - */ - /** */ - bool isVarOpenvar( - int var - ); - - /** - * @brief Checks whether the var is a stairlinking var - * @param var id of var to check - * @return true iff the var is a stairlinking var - */ - bool isVarStairlinkingvar( - int var - ); - - /** - * @brief Checks whether the var is a stairlinkingvar of a specified block - * @param var id of var to check if it is a stairlinking variable hitting specified block - * @param block id of block to check - * @return true iff the var is a stairlinkingvar of a specified block - */ - bool isVarStairlinkingvarOfBlock( - int var, - int block - ); - - /** - * @brief prints partition information as described in \see cls reader - * @param givenscip scip data structure - * @param file output file - */ - void printPartitionInformation( - SCIP* givenscip, - FILE* file - ); - - /** - * @brief refine partialdec with focus on blocks - * - * strategy: assigns open conss and vars if they can be found in blocks - * (without respect to open vars and conss @see assignHittingOpenconss(), @see assignHittingOpenvars()) - * @note partialdec might be not complete - */ - void refineToBlocks( - ); - - /** - * @brief refine partialdec with focus on master - * - * strategy: do obvious ( @see considerImplicits()) assignments and - * assign other conss and vars to master if possible (@see assignOpenPartialHittingToMaster()) - */ - void refineToMaster( - ); - - /** - * @brief registers statistics for a used conspartition - */ - void setConsPartitionStatistics( - int detectorchainindex, /**< index of the detector in the detectorchain */ - ConsPartition* partition, /**< the used conspartition */ - std::vector& consclassesmaster /**< vector of classindices that were assigned to master */ - ); - - /** - * @brief adds a constraint to a block, does not delete this cons from list of open conss - * @param consToBlock id of cons to add - * @param block id of block to add - */ - void setConsToBlock( - int consToBlock, - int block - ); - - /** - * @brief adds a constraint to a block - * @param cons id of cons to add - * @param block id of block to add - */ - void fixConsToBlock( - int cons, - int block - ); - - /** - * @brief adds a constraint to a block - * @param cons pointer of cons to add - * @param block id of block to add - * @returns true iff successful - */ - bool fixConsToBlock( - SCIP_CONS* cons, - int block - ); - - /** - * @brief adds a constraint to the master constraints, does not delete this cons from list of open conss - * @param consToMaster id of cons to add - */ - void setConsToMaster( - int consToMaster - ); - - /** - * @brief fixes a constraint to the master constraints - * @param itr valid iterator pointing to elements of PARTIALDECOMP::openconss - * @return iterator that points to the next element of PARTIALDECOMP::openconss - * @warning This method modifies the vector PARTIALDECOMP::openconss! Hence, any kind of iterator might be invalid afterwards! - */ - std::vector::const_iterator fixConsToMaster( - std::vector::const_iterator itr - ); - - /** - * @brief fixes a constraint to the master constraints - * @param cons id of cons to add - * @warning This method modifies the vector PARTIALDECOMP::openconss! Hence, any kind of iterator might be invalid afterwards! - */ - void fixConsToMaster( - int cons - ); - - /** - * @brief fixes a constraint to the master constraints - * @param cons pointer of cons to add - * @warning This method modifies the vector PARTIALDECOMP::openconss! Hence, any kind of iterator might be invalid afterwards! - * @returns true iff successful - */ - bool fixConsToMaster( - SCIP_CONS* cons - ); - - /** - * @brief sets the detectorchain with the given vector of detector pointers - * @param givenDetectorChain vector of detector pointers - */ - void setDetectorchain( - std::vector& givenDetectorChain - ); - - /** - * @brief sets partialdec to be propagated by a detector - * @param detector pointer to detector that is registered for this partialdec - */ - void setDetectorPropagated( - DEC_DETECTOR* detector - ); - - /** - * @brief sets detector that finished the partialdec - * @param detector pointer to detector that has finished this partialdecs - */ - void setDetectorFinished( - DEC_DETECTOR* detector - ); - - /** - * @brief sets detector that finished the partialdec in the original problem - * @param detectorID pointer to detector that has finished this partialdecs - * @note does not add the detector to the detectorchain and does not modify partition statistics - */ - void setDetectorFinishedOrig( - DEC_DETECTOR* detectorID - ); - - /** - * @brief sets whether this partialdec was finished by a finishing detector - * @param finished is this partialdecs finished by a finishing detector - */ - void setFinishedByFinisher( - bool finished - ); - - /** - * @brief sets whether this partialdec was finished by a finishing detector in the original problem - * - * (in case this partialdec was translated) - * @param finished was this partialdecs finished by a finishing detector in orig - */ - void setFinishedByFinisherOrig( - bool finished - ); - - /** - * @brief sets number of blocks, only increasing number allowed - * @param nblocks new number of blocks - */ - void setNBlocks( - int nblocks - ); - - /** - * @brief set the selection status of this partialdecs - * @param selected whether the partialdec is selected - */ - void setSelected( - bool selected - ); - - /** - * @brief sets whether this partialdec stems from an orig problem partialdec - * @param fromorig has this partialdec ancestors from the orig problem - */ - void setStemsFromOrig( - bool fromorig - ); - - /** - * @brief sets whether this partialdec is user given - * @param usergiven is this partialdec user given - */ - void setUsergiven( - USERGIVEN usergiven - ); - - /** - * @brief registers statistics for a used varpartition - */ - void setVarPartitionStatistics( - int detectorchainindex, /**< index of the detector in the detectorchain */ - VarPartition* partition, /**< the used varpartition */ - std::vector& varclasseslinking, /**< vector of classindices that were assigned to linking */ - std::vector& varclassesmaster /**< vector of classindices that were assigned to master */ - ); - - /** - * @brief adds a variable to the linking variables, does not delete this var from list of open vars - * @param varToBlock id of var to be added - * @param block id of block to be added - */ - void setVarToBlock( - int varToBlock, - int block - ); - - /** - * @brief adds a variable to the linking variables - * @param var id of var to be added - * @param block id of block to be added - */ - void fixVarToBlock( - int var, - int block - ); - - /** - * @brief adds a variable to the linking variables - * @param itr valid iterator pointing to elements of PARTIALDECOMP::openvars - * @param block id of block to be added - * @return iterator that points to the next element of PARTIALDECOMP::openvars - * @warning This method modifies the vector PARTIALDECOMP::openvars! Hence, any kind of iterator might be invalid afterwards! - */ - std::vector::const_iterator fixVarToBlock( - std::vector::const_iterator itr, - int block - ); - - /** - * @brief adds a variable to the linking variables, does not delete this var from list of open vars - * @param varToLinking var to be set to linking - */ - void setVarToLinking( - int varToLinking - ); - - /** - * @brief adds a variable to the linking variables - * @param var var to be set to linking - */ - void fixVarToLinking( - int var - ); - - /** - * @brief adds a variable to the linking variables - * @param itr valid iterator pointing to elements of PARTIALDECOMP::openvars - * @return iterator that points to the next element of PARTIALDECOMP::openvars - * @warning This method modifies the vector PARTIALDECOMP::openvars! Hence, any kind of iterator might be invalid afterwards! - */ - std::vector::const_iterator fixVarToLinking( - std::vector::const_iterator itr - ); - - /** @brief adds a variable to the master variables, does not delete this var from list of open vars - * - * master variables hit only constraints in the master - */ - void setVarToMaster( - int varToMaster /**< var to be set to master */ - ); - - /** @brief adds a variable to the master variables - * - * master variables hit only constraints in the master - */ - void fixVarToMaster( - int var /**< var to be set to master */ - ); - - /** @brief adds a variable to the master variables - * - * @param itr valid iterator pointing to elements of PARTIALDECOMP::openvars - * @return iterator that points to the next element of PARTIALDECOMP::openvars - * @warning This method modifies the vector PARTIALDECOMP::openvars! Hence, any kind of iterator might be invalid afterwards! - */ - std::vector::const_iterator fixVarToMaster( - std::vector::const_iterator itr /**< var to be set to master */ - ); - - /** - * @brief adds a variable to the stairlinking variables, does not delete this var from list of open vars - * @param varToStairLinking id of variable to be added - * @param block1 id of block one - * @param block2 id of block two - * @note stairlinking variables are only registered in block with smaller index - */ - void setVarToStairlinking( - int varToStairLinking, - int block1, - int block2 - ); - - /** - * @brief adds a variable to the stairlinking variables - * @param var id of variable to be added - * @param firstblock stairlinking variables hit exactly two consecutive blocks, this is the index of the first of these blocks - * @note stairlinking variables are only registered in block with smaller index - */ - void fixVarToStairlinking( - int var, - int firstblock - ); - - /** - * @brief adds a variable to the stairlinking variables - * @param itr valid iterator pointing to elements of PARTIALDECOMP::openvars - * @param firstblock stairlinking variables hit exactly two consecutive blocks, this is the index of the first of these blocks - * @return iterator that points to the next element of PARTIALDECOMP::openvars - * @warning This method modifies the vector PARTIALDECOMP::openvars! Hence, any kind of iterator might be invalid afterwards! - * @note stairlinking variables are only registered in block with smaller index - */ - std::vector::const_iterator fixVarToStairlinking( - std::vector::const_iterator itr, - int firstblock - ); - - /** - * @brief assigns a constraint by name to a block - * @see fixConsToBlock - * @returns true iff successful - */ - bool fixConsToBlockByName( - const char* consname, /**< name of the constraint */ - int blockid /**< block index (counting from 0) */ - ); - - /** - * @brief assigns a variable by name to a block - * @see fixVarToBlock - * @returns true iff successful - */ - bool fixVarToBlockByName( - const char* varname, /**< name of the variable */ - int blockid /**< block index (counting from 0) */ - ); - - /** - * @brief assgins a constraint by name as master - * @see fixConsToMaster - * @returns true iff successful - */ - bool fixConsToMasterByName( - const char* consname /**< name of cons to fix as master cons */ - ); - - /** - * @brief assigns a variable with given name as master - * @see fixVarToMaster - * @returns true iff successful - */ - bool fixVarToMasterByName( - const char* varname /**< name of the variable */ - ); - - /** - * @brief assigns a variable by name to the linking variables - * @see fixVarToLinking - * @returns true iff successful - */ - bool fixVarToLinkingByName( - const char* varname /**< name of the variable */ - ); - - /** - * @brief generates and opens a gp visualization of the partialdec - * @see visual/pdfreader and - * @note linux only - */ - void showVisualization(); - - /** - * @brief generates a visualization of the partialdec using gnuplot - * @param filename Path where to store the gp file - * @param outname Path at which gnuplot will output its result - * @param outputformat The format of the gnuplot output. Should match the file extension of outname - * @note linux only, requires gnuplot - */ - void generateVisualization( - char* filename, - char* outname, - GP_OUTPUT_FORMAT outputformat = GP_OUTPUT_FORMAT_PDF - ); - - /** - * @brief writes a gp visualization of the partialdec to a file - * @param filename Path where to store the gp file - * @param outname Path at which gnuplot will output its result - * @param outputformat The format of the gnuplot output. Should match the file extension of outname - */ - void writeVisualizationFile( - char* filename, - char* outname, - GP_OUTPUT_FORMAT outputformat = GP_OUTPUT_FORMAT_PDF - ); - - /** - * @brief generates a gp visualization of the partialdec without compilation or opening - */ - void exportVisualization(); - - /** - * @brief Checks whether this partialdec is a userpartialdec that should be completed - * - * the completion should be done by setting unspecified constraints to master - * @return TRUE iff this partialdec is a userpartialdec that should be completed - */ - SCIP_Bool shouldCompletedByConsToMaster(); - - /** - * @brief sorts the vars and conss data structures by their indices - * @returns true if the internal order of variables or constraints changed - */ - bool sort(); - - /** - * @brief set statistical vector of fractions of constraints set to blocks per involved detector - * @param newvector vector of fractions of constraints set to blocks per involved detector - */ - void setPctConssToBlockVector( - std::vector& newvector - ); - - /** - * @brief set statistical vector of fractions of constraints that are not longer open per involved detector - * @param newvector vector of fractions of constraints that are not longer open per involved detector - */ - void setPctConssFromFreeVector( - std::vector& newvector - ); - - /** - * @brief set statistical vector of fractions of constraints assigned to the border per involved detector - * @param newvector vector of fractions of constraints assigned to the border per involved detector - */ - void setPctConssToBorderVector( - std::vector& newvector - ); - - /** - * @brief set statistical vector of fraction of variables assigned to the border per involved detector - * @param newvector vector of fractions of variables assigned to the border per involved detector - */ - void setPctVarsToBorderVector( - std::vector& newvector - ); - - /** - * @brief set statistical vector of fractions of variables assigned to a block per involved detector - * @param newvector vector of fractions of variables assigned to a block per involved detector - */ - void setPctVarsToBlockVector( - std::vector& newvector - ); - - /** - * @brief set statistical vector of variables that are not longer open per involved detector - * @param newvector vector of fractions of variables that are not longer open per involved detector - */ - void setPctVarsFromFreeVector( - std::vector& newvector - ); - - /** - * @brief set statistical vector of the times that the detectors needed for detecting per involved detector - * @param newvector vector of the times that the detectors needed for detecting per involved detector - */ - void setDetectorClockTimes( - std::vector& newvector - ); - - /** @brief gets the classic score - * - * @note -1 iff not calculated yet, \see GCGconshdlrDecompCalcClassicScore - * @returns border area score - */ - SCIP_Real getClassicScore(); - - /** @brief set the classic score - */ - void setClassicScore( - SCIP_Real score /**< new score value in [0,1] */ - ); - - /** @brief gets the border area score - * - * @note -1 iff not calculated yet, \see GCGconshdlrDecompCalcBorderAreaScore - * @returns border area score - */ - SCIP_Real getBorderAreaScore(); - - /** @brief set the border area score - */ - void setBorderAreaScore( - SCIP_Real score /**< new score value in [0,1] */ - ); - - /** @brief gets the maximum white area score - * - * "maximum white score" is fraction of the area of the decomposed matrix that is neither block or border - * @note -1 iff not calculated yet, \see GCGconshdlrDecompCalcMaxWhiteScore - * @returns maximum white area score - * */ - SCIP_Real getMaxWhiteScore(); - - /** @brief set the maximum white area score - */ - void setMaxWhiteScore( - SCIP_Real score /**< new score value in [0,1] */ - ); - - /** @brief gets the maximum foreseeing white area score - * - * @note -1 iff not calculated yet, \see GCGconshdlrDecompCalcMaxForseeingWhiteScore - * @returns maximum foreseeing white area score - * */ - SCIP_Real getMaxForWhiteScore(); - - /** @brief set the maximum foreseeing white area score - */ - void setMaxForWhiteScore( - SCIP_Real score /**< new score value in [0,1] */ - ); - - /** @brief gets the setpartitioning maximum foreseeing white area score - * - * @note -1 iff not calculated yet, \see GGCGconshdlrDecompCalcSetPartForseeingWhiteScore - * @returns setpartitioning maximum foreseeing white area score - * */ - SCIP_Real getSetPartForWhiteScore(); - - /** @brief set the setpartitioning maximum foreseeing white area score - */ - void setSetPartForWhiteScore( - SCIP_Real score /**< new score value in [0,1] */ - ); - - /** @brief gets the maximum foreseeing white area score with respect to aggregatable blocks - * - * @note -1 iff not calculated yet, \see GCGconshdlrDecompCalcMaxForeseeingWhiteAggScore - * @returns maximum foreseeing white area score with respect to aggregatable blocks - * */ - SCIP_Real getMaxForWhiteAggScore(); - - /** @brief set the maximum foreseeing white area score with respect to aggregatable blocks - */ - void setMaxForWhiteAggScore( - SCIP_Real score /**< new score value in [0,1] */ - ); - - /** @brief gets the setpartitioning maximum foreseeing white area score with respect to aggregateable - * - * @note -1 iff not calculated yet, \see GCGconshdlrDecompCalcSetPartForWhiteAggScore - * @returns setpartitioning maximum foreseeing white area score with respect to aggregateable - */ - SCIP_Real getSetPartForWhiteAggScore(); - - /** @brief set the setpartitioning maximum foreseeing white area score with respect to aggregateable - */ - void setSetPartForWhiteAggScore( - SCIP_Real score /**< new score value in [0,1] */ - ); - - /** @brief gets the benders score - * - * @note -1 iff not calculated yet, \see GCGconshdlrDecompCalcBendersScore - * @returns benders score - */ - SCIP_Real getBendersScore(); - - /** @brief set the benders score - */ - void setBendersScore( - SCIP_Real score /**< new score value in [0,1] */ - ); - - /** @brief gets the strong decomposition score - * - * @note -1 iff not calculated yet, \see GCGconshdlrDecompCalcStrongDecompositionScore - * @returns strong decomposition score - */ - SCIP_Real getStrongDecompScore(); - - /** @brief set the strong decomposition score - */ - void setStrongDecompScore( - SCIP_Real score /**< new score value in [0,1] */ - ); - - /** sorts the partialdec and calculates a its implicit assignments, hashvalue and evaluation - * - * @returns SCIP_OKAY if the result is consistent, SCIP_ERROR if there was an inconsistency - */ - void prepare(); - - /** - * @brief Checks if the aggregation information was already calculated - * @return true iff the aggregation information was already calculated - */ - bool aggInfoCalculated(); - - /** - * @brief computes if aggregation of sub problems is possible - * - * checks if aggregation of sub problems is possible and stores the corresponding aggregation information - * - * @param ignoreDetectionLimits Set to true if computation should ignore detection limits. This parameter is ignored if the patched bliss version is not present. - */ - void calcAggregationInformation( - bool ignoreDetectionLimits - ); - - /**< @brief gets vector of indices of all constraints assigned to blocks - * - * @note conssforblocks[k] contains a vector of indices of all constraints assigned to block k - * @returns vector of a vector of indices for each block */ - std::vector>& getConssForBlocks( - ); - - int getTranslatedpartialdecid() const; - - void setTranslatedpartialdecid( - int decid - ); - - /** - * @brief creates a detector chain short string for this partialdec, is built from detector chain - */ - void buildDecChainString( - char* buffer /**< will contain string of detector chars in chronological order afterwards*/ - ); - -private: - - /** - * @brief adds empty entries for all partition statistics for a detector added to the detector chain - */ - void addEmptyPartitionStatistics(); - - /** @brief assigns open cons - * - * Assignments as follows: - * - to master if it hits blockvars of different blocks - * - to the respective block if it hits a blockvar of exactly one block and no stairlinking var - * - to master if it hits a stairlinking var but there is no block the cons may be assigned to - * - to the block with the lowest number of conss if it hits a stairlinking var and there are blocks the cons may be - * assigned to - * - leave it open if it hits no blocks yet - * @return true iff some assignment was made by the method - */ - bool assignHittingOpenconss( - ); - - /** @brief assigns every open var - * - * Assignments as follows: - * - to the respective block if it hits blockconss of exactly one block - * - to linking if it hits blockconss of more than one different blocks - * - leave the var open otherwise - * @return true iff there is a var that has been assigned in this call*/ - bool assignHittingOpenvars( - ); - - /** - * @brief assigns every open cons to master that hits - * - * Assignments as follows: - * - exactly one block var and at least one open var or - * - a master var - * - or leave it open elsewise - */ - void assignOpenPartialHittingConsToMaster( - ); - - /** - * @brief assigns open conss/vars that hit exactly one block and at least one open var/cons to border - */ - void assignOpenPartialHittingToMaster( - ); - - /** - * @brief assigns every open var to linking that hits - * - * Assignments as follows: - * - exactly one block cons and at least one open cons - * - leave it open otherwise - */ - void assignOpenPartialHittingVarsToMaster( - ); - - /** - * @brief calculates the number of nonzero coefficients for the blocks - */ - void calcNCoeffsForBlocks( - ); - - /** - * @brief calculates the hash value of the partialdec for comparing - */ - void calcHashvalue(); - - /** - * @brief blockwise calculation of how many master conss contain the block vars - * - * counts for each pair of block and master constraint, how many nonzero entries the variables of the blocks - * have in the master constraint - */ - void calcNCoeffsForBlockForMastercons( - ); - - /** - * @brief optimizes block order to max stairlinking vars - * - * changes the block order in a way such that all linking vars that are potentially stairlinking - * may be reassigned to stairlinking - * @note precondition: all potentially stairlinking vars have a staircase structure */ - void changeBlockOrderStaircase( - GraphGCG* g /**< graph with blocks as nodes and weighted edges for the number of - potentially stairlinkingvars connecting two blocks */ - ); - - /** - * @brief changes the order of the blocks according to the given mapping - * - * \note precondition: given mapping needs to be an adequately sized permutation */ - void changeBlockOrder( - std::vector oldToNewBlockIndex /**< the mapping from old to new block indices */ - ); - - /** - * @brief returns true if the given detector used a conspartition - * @return true iff the given detector used a conspartition - */ - bool consPartitionUsed( - int detectorchainindex /**< index of the detector in the detectorchain */ - ); - - /** - * @brief prints out the current aggregation information - * - * aggregation information: if there has been identified identical blocks - */ - void displayAggregationInformation(); - - /** - * @brief calculates potential stairlinking variables with their blocks - * - * @return a vector of pairs of var index and vector of (two) block indices - * the related linking variable hits exactly these two blocks given in the related vector - */ - std::vector< std::pair< int, std::vector< int > > > findLinkingVarsPotentiallyStairlinking( - ); - - /** - * @brief returns the data of the conspartition that the given detector made use of - */ - void getConsPartitionData( - int detectorchainindex, /**< index of the detector in the detectorchain */ - ConsPartition** partition, /**< a pointer to the used conspartition (set by method)*/ - std::vector& consclassesmaster /**< a vector containing all indices of the consclasses assigned to master - * (set by method) */ - ); - - /** - * @brief returns a string displaying all detector-related clock times and assignment data - * - * @return string displaying all detector-related clock times and assignment data - */ - std::string getDetectorStatistics( - int detectorchainindex /**< index of the detector in the detectorchain */ - ); - - /** - * @brief returns a string displaying partition information if a partition was used - * - * @return string displaying partition information if a partition was used - */ - std::string getDetectorPartitionInfo( - int detectorchainindex, /**< index of the detector in the detectorchain */ - bool displayConssVars /**< pass true if constraints and variables of the respective classes should be displayed */ - ); - - /** - * @brief Gets the number used partitions - * @return number used partitions - */ - int getNUsedPartitions(); - - /** - * @brief Gets the data of the varpartition that the given detector made use of - * @return data of the varpartition that the given detector made use of - */ - void getVarPartitionData( - int detectorchainindex, /**< index of the detector in the detectorchain */ - VarPartition** partition, /**< a pointer to the used varpartition (set by method) */ - std::vector& varclasseslinking, /**< a vector containing all indices of the varclasses assigned to linking (set by method) */ - std::vector& varclassesmaster /**< a vector containing all indices of the varclasses assigned to master (set by method)*/ - ); - - /** - * @brief checks if calculation of aggregation information is considered to be too expensive - * @return TRUE iff calculation of aggregation information is considered to be too expensive - */ - SCIP_Bool isAgginfoTooExpensive(); - - /** - * @brief Gets whether the cons is a cons of the block - * @param cons id of constraint to check - * @param block id of the blocks - * @return true iff the cons is a cons of the block - */ - /** */ - bool isConsBlockconsOfBlock( - int cons, - int block - ); - - /** - * @brief returns true if the given detector used a varpartition - * - * @return true if the given detector used a varpartition - */ - bool varPartitionUsed( - int detectorchainindex /**< index of the detector in the detectorchain */ - ); - -}; - - -} /* namespace gcg */ -#endif /* GCG_CLASS_PARTIALDECOMP_H__ */ diff --git a/headers/gcg/class_pricingcontroller.h b/headers/gcg/class_pricingcontroller.h deleted file mode 100644 index 00bd67b..0000000 --- a/headers/gcg/class_pricingcontroller.h +++ /dev/null @@ -1,199 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* */ -/* This file is part of the program */ -/* GCG --- Generic Column Generation */ -/* a Dantzig-Wolfe decomposition based extension */ -/* of the branch-cut-and-price framework */ -/* SCIP --- Solving Constraint Integer Programs */ -/* */ -/* Copyright (C) 2010-2022 Operations Research, RWTH Aachen University */ -/* Zuse Institute Berlin (ZIB) */ -/* */ -/* This program is free software; you can redistribute it and/or */ -/* modify it under the terms of the GNU Lesser General Public License */ -/* as published by the Free Software Foundation; either version 3 */ -/* of the License, or (at your option) any later version. */ -/* */ -/* This program is distributed in the hope that it will be useful, */ -/* but WITHOUT ANY WARRANTY; without even the implied warranty of */ -/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ -/* GNU Lesser General Public License for more details. */ -/* */ -/* You should have received a copy of the GNU Lesser General Public License */ -/* along with this program; if not, write to the Free Software */ -/* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.*/ -/* */ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -/**@file class_pricingcontroller.h - * @brief pricing controller managing the pricing strategy - * @author Christian Puchert - */ - -/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/ - -#ifndef CLASS_PRICINGCONTROLLER_H_ -#define CLASS_PRICINGCONTROLLER_H_ - -#include "colpool.h" -#include "pricestore_gcg.h" -#include "class_pricingtype.h" -#include "type_gcgpqueue.h" -#include "type_pricingjob.h" -#include "type_pricingprob.h" -#include "objscip/objscip.h" - -namespace gcg { - -class Pricingcontroller -{ - -private: - SCIP* scip_; /**< SCIP instance (master problem) */ - GCG_PRICINGPROB** pricingprobs; /**< pricing problems */ - int npricingprobs; /**< number of pricing problems */ - int maxpricingprobs; /**< capacity of pricingprobs */ - GCG_PRICINGJOB** pricingjobs; /**< pricing jobs */ - int npricingjobs; /**< number of pricing jobs */ - int maxpricingjobs; /**< capacity of pricingjobs */ - - /* parameters */ - int heurpricingiters; /**< maximum number of heuristic pricing iterations per pricing call and problem */ - int maxheurdepth; /**< maximum depth at which heuristic pricing should be performed (-1 for infinity) */ - char sorting; /**< order by which the pricing problems should be sorted */ - int nroundscol; /**< number of previous pricing rounds for which the number of improving columns should be counted */ - int chunksize; /**< maximal number of pricing problems to be solved during one pricing loop */ - int eagerfreq; /**< frequency at which all pricing problems should be solved */ - - /* strategy */ - GCG_PQUEUE* pqueue; /**< priority queue containing the pricing jobs */ - SCIP_Real* score; /**< scores of the pricing problems */ - int maxniters; /**< maximal possible number of pricing iterations */ - int nchunks; /**< number of pricing problem 'chunks' */ - int curchunk; /**< index of current chunk of pricing problems */ - int startchunk; /**< first chunk considered in a pricing call */ - PricingType* pricingtype_; /**< current pricing type */ - - /* statistics */ - int eagerage; /**< iterations since last eager iteration */ - int nsolvedprobs; /**< number of completely solved pricing problems during the current pricing loop */ - - -public: - /** default constructor */ - Pricingcontroller(); - - /** constructor */ - Pricingcontroller(SCIP* scip); - - /** destructor */ - virtual ~Pricingcontroller(); - - SCIP_RETCODE addParameters(); - - SCIP_RETCODE initSol(); - - SCIP_RETCODE exitSol(); - - /** pricing initialization, called right at the beginning of pricing */ - SCIP_RETCODE initPricing( - PricingType* pricingtype /**< type of pricing */ - ); - - /** pricing deinitialization, called when pricing is finished */ - void exitPricing(); - - /** setup the priority queue (done once per stabilization round): add all pricing jobs to be performed */ - SCIP_RETCODE setupPriorityQueue( - SCIP_Real* dualsolconv /**< dual solution values / Farkas coefficients of convexity constraints */ - ); - - /** get the next pricing job to be performed */ - GCG_PRICINGJOB* getNextPricingjob(); - - /** add the information that the next branching constraint must be added, - * and for the pricing job, reset heuristic pricing counter and flag - */ - SCIP_RETCODE pricingprobNextBranchcons( - GCG_PRICINGPROB* pricingprob /**< pricing problem structure */ - ); - - /** set an individual time limit for a pricing job */ - SCIP_RETCODE setPricingjobTimelimit( - GCG_PRICINGJOB* pricingjob /**< pricing job */ - ); - - /** update solution information of a pricing problem */ - void updatePricingprob( - GCG_PRICINGPROB* pricingprob, /**< pricing problem structure */ - GCG_PRICINGSTATUS status, /**< new pricing status */ - SCIP_Real lowerbound, /**< new lower bound */ - int nimpcols /**< number of new improving columns */ - ); - - /** update solution statistics of a pricing job */ - void updatePricingjobSolvingStats( - GCG_PRICINGJOB* pricingjob /**< pricing job */ - ); - - /** decide whether a pricing job must be treated again */ - void evaluatePricingjob( - GCG_PRICINGJOB* pricingjob, /**< pricing job */ - GCG_PRICINGSTATUS status /**< status of pricing job */ - ); - - /** collect solution results from all pricing problems */ - void collectResults( - GCG_COL** bestcols, /**< best found columns per pricing problem */ - SCIP_Bool* infeasible, /**< pointer to store whether pricing is infeasible */ - SCIP_Bool* optimal, /**< pointer to store whether all pricing problems were solved to optimality */ - SCIP_Real* bestobjvals, /**< array to store best lower bounds */ - SCIP_Real* beststabobj, /**< pointer to store total lower bound */ - SCIP_Real* bestredcost, /**< pointer to store best total reduced cost */ - SCIP_Bool* bestredcostvalid /**< pointer to store whether best reduced cost is valid */ - ); - - /** check if the next chunk of pricing problems is to be used */ - SCIP_Bool checkNextChunk(); - - /** decide whether the pricing loop can be aborted */ - SCIP_Bool canPricingloopBeAborted( - PricingType* pricingtype, /**< type of pricing (reduced cost or Farkas) */ - int nfoundcols, /**< number of negative reduced cost columns found so far */ - int nsuccessfulprobs /**< number of pricing problems solved successfully so far */ - ) const; - - void resetEagerage(); - - void increaseEagerage(); - - /** for a given problem index, get the corresponding pricing problem (or NULL, if it does not exist) */ - GCG_PRICINGPROB* getPricingprob( - int probnr /**< index of the pricing problem */ - ); - - /** get maximal possible number of pricing iterations */ - int getMaxNIters() const; - - -private: - /** comparison operator for pricing jobs w.r.t. their solution priority */ - static - SCIP_DECL_SORTPTRCOMP(comparePricingjobs); - - /** for each pricing problem, get its corresponding generic branching constraints */ - SCIP_RETCODE getGenericBranchconss(); - - /** check if a pricing job is done */ - SCIP_Bool pricingprobIsDone( - GCG_PRICINGPROB* pricingprob /**< pricing problem structure */ - ) const; - - /** check whether the next generic branching constraint of a pricing problem must be considered */ - SCIP_Bool pricingprobNeedsNextBranchingcons( - GCG_PRICINGPROB* pricingprob /**< pricing problem structure */ - ) const; -}; - -} /* namespace gcg */ -#endif /* CLASS_PRICINGCONTROLLER_H_ */ diff --git a/headers/gcg/class_pricingtype.h b/headers/gcg/class_pricingtype.h deleted file mode 100644 index 21f04e8..0000000 --- a/headers/gcg/class_pricingtype.h +++ /dev/null @@ -1,232 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* */ -/* This file is part of the program */ -/* GCG --- Generic Column Generation */ -/* a Dantzig-Wolfe decomposition based extension */ -/* of the branch-cut-and-price framework */ -/* SCIP --- Solving Constraint Integer Programs */ -/* */ -/* Copyright (C) 2010-2022 Operations Research, RWTH Aachen University */ -/* Zuse Institute Berlin (ZIB) */ -/* */ -/* This program is free software; you can redistribute it and/or */ -/* modify it under the terms of the GNU Lesser General Public License */ -/* as published by the Free Software Foundation; either version 3 */ -/* of the License, or (at your option) any later version. */ -/* */ -/* This program is distributed in the hope that it will be useful, */ -/* but WITHOUT ANY WARRANTY; without even the implied warranty of */ -/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ -/* GNU Lesser General Public License for more details. */ -/* */ -/* You should have received a copy of the GNU Lesser General Public License */ -/* along with this program; if not, write to the Free Software */ -/* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.*/ -/* */ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -/**@file class_pricingtype.h - * @brief abstraction for SCIP pricing types - * @author Martin Bergner - * @author Christian Puchert - */ - -/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/ -#ifndef GCG_CLASS_PRICINGTYPE_H__ -#define GCG_CLASS_PRICINGTYPE_H__ - -#include "objscip/objscip.h" -#include "pricer_gcg.h" - -class PricingType -{ -protected: - SCIP* scip_; /**< SCIP instance (master problem) */ - GCG_PRICETYPE type; /**< type of pricing */ - SCIP_CLOCK* clock; /**< CPU clock */ - - int calls; /**< number of times this type of pricing was called */ - int maxrounds; /**< maximal number of pricing rounds */ - int maxcolsroundroot; /**< maximal number of columns per pricing round at root node */ - int maxcolsround; /**< maximal number of columns per pricing round */ - int maxcolsprobroot; /**< maximal number of columns per problem to be generated at root node */ - int maxcolsprob; /**< maximal number of columns per problem to be generated */ - int maxsuccessfulprobs; /**< maximal number of successfully solved pricing problems until pricing - * loop is aborted */ - SCIP_Real relmaxprobsroot; /**< maximal percentage of pricing problems that are solved at root node if - * variables have already been found */ - SCIP_Real relmaxprobs; /**< maximal percentage of pricing problems that are solved if variables - * have already been found */ - SCIP_Real relmaxsuccessfulprobs; /**< maximal percentage of pricing problems that need to be solved successfully */ - -public: - /** constructor */ - PricingType(); - - PricingType( - SCIP* p_scip - ); - - /** destructor */ - virtual ~PricingType(); - - /** get dual value of a constraint */ - virtual SCIP_Real consGetDual( - SCIP* scip, /**< SCIP data structure */ - SCIP_CONS* cons /**< constraint to get dual for */ - ) const = 0; - - /** get dual value of a row */ - virtual SCIP_Real rowGetDual( - SCIP_ROW* row /**< row to get dual value for */ - ) const = 0; - - /** get objective value of variable */ - virtual SCIP_Real varGetObj( - SCIP_VAR* var /**< variable to get objective value for */ - ) const = 0; - - /** adds parameters to the SCIP data structure */ - virtual SCIP_RETCODE addParameters() = 0; - - /** starts the clock */ - virtual SCIP_RETCODE startClock(); - - /** stops the clock */ - virtual SCIP_RETCODE stopClock(); - - /** returns the time of the clock */ - virtual SCIP_Real getClockTime() const; - - /** returns the maximal number of rounds */ - virtual int getMaxrounds() const - { - return maxrounds; - } - - /** returns the maximal number of columns per pricing round */ - virtual int getMaxcolsround() const = 0; - - /** returns the maximal number of columns per problem to be generated during pricing */ - virtual int getMaxcolsprob() const = 0; - - /** returns the maximal number of successfully solved pricing problems */ - int getMaxsuccessfulprobs() const - { - return maxsuccessfulprobs; - } - - /** returns the maximal percentage of pricing problems that are solved if variables have already been found */ - virtual SCIP_Real getRelmaxprobs() const = 0; - - /** returns the maximal percentage of pricing problems that need to be solved successfully */ - SCIP_Real getRelmaxsuccessfulprobs() const - { - return relmaxsuccessfulprobs; - } - - /** returns the type of this pricing type */ - GCG_PRICETYPE getType() const - { - return type; - } - - /** returns the number of calls so far */ - int getCalls() const - { - return calls; - } - - /** increases the number of calls */ - virtual void incCalls() - { - calls++; - } - - /** resets the number of calls and the clock for a restart */ - SCIP_RETCODE resetCalls() - { - calls = 0; - SCIP_CALL( SCIPresetClock(scip_, clock) ); - return SCIP_OKAY; - } - -}; - -class ReducedCostPricing : public PricingType -{ -public: - /** constructor */ - ReducedCostPricing(); - - ReducedCostPricing( - SCIP* p_scip - ); - - /** destructor */ - virtual ~ReducedCostPricing() {} - - virtual SCIP_RETCODE addParameters(); - - virtual SCIP_Real consGetDual( - SCIP* scip, - SCIP_CONS* cons - ) const; - - virtual SCIP_Real rowGetDual( - SCIP_ROW* row - ) const; - - virtual SCIP_Real varGetObj( - SCIP_VAR* var - ) const ; - - /** returns the maximal number of columns per pricing round */ - virtual int getMaxcolsround() const; - - /** returns the maximal number of columns per problem to be generated during pricing */ - virtual int getMaxcolsprob() const; - - /** returns the maximal percentage of pricing problems that are solved if variables have already been found */ - virtual SCIP_Real getRelmaxprobs() const; -}; - -class FarkasPricing : public PricingType -{ -public: - /** constructor */ - FarkasPricing(); - - FarkasPricing( - SCIP* p_scip - ); - - /** destructor */ - virtual ~FarkasPricing() {} - - virtual SCIP_RETCODE addParameters(); - - virtual SCIP_Real consGetDual( - SCIP* scip, - SCIP_CONS* cons - ) const; - - virtual SCIP_Real rowGetDual( - SCIP_ROW* row - ) const; - - virtual SCIP_Real varGetObj( - SCIP_VAR* var - ) const; - - /** returns the maximal number of columns per pricing round */ - virtual int getMaxcolsround() const; - - /** returns the maximal number of columns per problem to be generated during pricing */ - virtual int getMaxcolsprob() const; - - /** returns the maximal percentage of pricing problems that are solved if variables have already been found */ - virtual SCIP_Real getRelmaxprobs() const; -}; - -#endif /* CLASS_PRICINGTYPE_H_ */ diff --git a/headers/gcg/class_stabilization.h b/headers/gcg/class_stabilization.h deleted file mode 100644 index 93c2bd8..0000000 --- a/headers/gcg/class_stabilization.h +++ /dev/null @@ -1,231 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* */ -/* This file is part of the program */ -/* GCG --- Generic Column Generation */ -/* a Dantzig-Wolfe decomposition based extension */ -/* of the branch-cut-and-price framework */ -/* SCIP --- Solving Constraint Integer Programs */ -/* */ -/* Copyright (C) 2010-2022 Operations Research, RWTH Aachen University */ -/* Zuse Institute Berlin (ZIB) */ -/* */ -/* This program is free software; you can redistribute it and/or */ -/* modify it under the terms of the GNU Lesser General Public License */ -/* as published by the Free Software Foundation; either version 3 */ -/* of the License, or (at your option) any later version. */ -/* */ -/* This program is distributed in the hope that it will be useful, */ -/* but WITHOUT ANY WARRANTY; without even the implied warranty of */ -/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ -/* GNU Lesser General Public License for more details. */ -/* */ -/* You should have received a copy of the GNU Lesser General Public License */ -/* along with this program; if not, write to the Free Software */ -/* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.*/ -/* */ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -/**@file class_stabilization.h - * @brief class with functions for dual variable smoothing - * @author Martin Bergner - * @author Jonas Witt - */ - -/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/ - -#ifndef CLASS_STABILIZATION_H_ -#define CLASS_STABILIZATION_H_ - -#include "objscip/objscip.h" -#include "class_pricingtype.h" - -namespace gcg { - -class Stabilization -{ -private: - SCIP* scip_; - SCIP_Real* stabcenterconsvals; - int stabcenterconsvalssize; - int nstabcenterconsvals; - SCIP_Real* stabcentercutvals; - int stabcentercutvalssize; - int nstabcentercutvals; - SCIP_Real* stabcenterlinkingconsvals; - int nstabcenterlinkingconsvals; - int stabcenterlinkingconsvalssize; - SCIP_Real* stabcenterconv; - int nstabcenterconv; - SCIP_Real dualdiffnorm; /**< norm of difference between stabcenter and current duals */ - SCIP_Real* subgradientconsvals; - int subgradientconsvalssize; - int nsubgradientconsvals; - SCIP_Real* subgradientcutvals; - int subgradientcutvalssize; - int nsubgradientcutvals; - SCIP_Real* subgradientlinkingconsvals; - int subgradientlinkingconsvalssize; - SCIP_Real subgradientnorm; - SCIP_Real hybridfactor; - PricingType* pricingtype; - SCIP_Real alpha; - SCIP_Real alphabar; /**< alpha that is used and updated in a mispricing schedule */ - SCIP_Bool hybridascent; /**< hybridize smoothing with an ascent method? */ - SCIP_Real beta; - SCIP_Longint nodenr; - int k; /**< counter for the number of stabilized pricing rounds in B&B node, excluding the mispricing schedule iterations */ - int t; /**< counter for the number of pricing rounds during a mispricing schedule, restarted after a mispricing schedule is finished */ - SCIP_Bool hasstabilitycenter; - SCIP_Real stabcenterbound; - SCIP_Bool inmispricingschedule; /**< currently in mispricing schedule */ - SCIP_Real subgradientproduct; - -public: - /** constructor */ - Stabilization( - SCIP* scip, /**< SCIP data structure */ - PricingType* pricingtype, /**< the pricing type when the stabilization should run */ - SCIP_Bool hybridascent /**< enable hybridization of smoothing with an ascent method? */ - ); - /** constructor */ - Stabilization(); - - /** destructor */ - virtual ~Stabilization(); - - /** gets the stabilized dual solution of constraint at position i */ - SCIP_RETCODE consGetDual( - int i, /**< index of the constraint */ - SCIP_Real* dual /**< return pointer for dual value */ - ); - - /** gets the stabilized dual solution of cut at position i */ - SCIP_RETCODE rowGetDual( - int i, /**< index of the row */ - SCIP_Real* dual /**< return pointer for dual value */ - ); - - /** gets the stabilized dual of the convexity constraint at position i */ - SCIP_Real convGetDual( - int i - ); - - /** updates the stability center if the bound has increased */ - SCIP_RETCODE updateStabilityCenter( - SCIP_Real lowerbound, /**< lower bound due to lagrange function corresponding to current (stabilized) dual vars */ - SCIP_Real* dualsolconv, /**< corresponding feasible dual solution for convexity constraints */ - GCG_COL** pricingcols /**< columns of the pricing problems */ - ); - - /** updates the alpha after unsuccessful pricing */ - void updateAlphaMisprice(); - - /** updates the alpha after successful pricing */ - void updateAlpha(); - - /** returns whether the stabilization is active */ - SCIP_Bool isStabilized(); - - /** enabling mispricing schedule */ - void activateMispricingSchedule( - ); - - /** disabling mispricing schedule */ - void disablingMispricingSchedule( - ); - - /** is mispricing schedule enabled */ - SCIP_Bool isInMispricingSchedule( - ) const; - - /** sets the variable linking constraints in the master */ - SCIP_RETCODE setLinkingConss( - SCIP_CONS** linkingconss, /**< array of linking master constraints */ - int* linkingconsblock, /**< block of the linking constraints */ - int nlinkingconss /**< size of the array */ - ); - - /** increases the number of new variable linking constraints */ - SCIP_RETCODE setNLinkingconsvals( - int nlinkingconssnew /**< number of new linking constraints */ - ); - - /** increases the number of new convexity constraints */ - SCIP_RETCODE setNConvconsvals( - int nconvconssnew - ); - - /** gets the dual of variable linking constraints at index i */ - SCIP_Real linkingconsGetDual( - int i - ); - - /**< update node */ - void updateNode(); - - /**< update information for hybrid stablization with dual ascent */ - SCIP_RETCODE updateHybrid(); - - /** update subgradient product */ - SCIP_RETCODE updateSubgradientProduct( - GCG_COL** pricingcols /**< solutions of the pricing problems */ - ); - -private: - /** updates the number of iterations */ - void updateIterationCount(); - - /** updates the number of iterations in the current mispricing schedule */ - void updateIterationCountMispricing(); - - /** updates the constraints in the stability center (and allocates more memory) */ - SCIP_RETCODE updateStabcenterconsvals(); - - /** updates the cuts in the stability center (and allocates more memory) */ - SCIP_RETCODE updateStabcentercutvals(); - - /** updates the constraints in the subgradient (and allocates more memory) */ - SCIP_RETCODE updateSubgradientconsvals(); - - /** updates the cuts in the subgradient (and allocates more memory) */ - SCIP_RETCODE updateSubgradientcutvals(); - - /** increase the alpha value */ - void increaseAlpha(); - - /** decrease the alpha value */ - void decreaseAlpha(); - - /** calculates the product of subgradient (with linking variables) - * with the difference of current duals and the stability center */ - SCIP_Real calculateSubgradientProduct( - GCG_COL** pricingcols /**< columns of the pricing problems */ - ); - - /** calculates the normalized subgradient (with linking variables) multiplied - * with the norm of the difference of current duals and the stability center */ - void calculateSubgradient( - GCG_COL** pricingcols /**< columns of the pricing problems */ - ); - - /**< calculate norm of difference between stabcenter and current duals */ - void calculateDualdiffnorm(); - - /**< calculate beta */ - void calculateBeta(); - - /**< calculate factor that is needed in hybrid stabilization */ - void calculateHybridFactor(); - - /** computes the new dual value based on the current and the stability center values */ - SCIP_Real computeDual( - SCIP_Real center, /**< value of stabilility center */ - SCIP_Real current, /**< current dual value */ - SCIP_Real subgradient, /**< subgradient (or 0.0 if not needed) */ - SCIP_Real lhs, /**< lhs (or 0.0 if not needed) */ - SCIP_Real rhs /**< rhs (or 0.0 if not needed) */ - ) const; -}; - -} /* namespace gcg */ -#endif /* CLASS_STABILIZATION_H_ */ diff --git a/headers/gcg/class_varpartition.h b/headers/gcg/class_varpartition.h deleted file mode 100644 index feed44e..0000000 --- a/headers/gcg/class_varpartition.h +++ /dev/null @@ -1,149 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* */ -/* This file is part of the program */ -/* GCG --- Generic Column Generation */ -/* a Dantzig-Wolfe decomposition based extension */ -/* of the branch-cut-and-price framework */ -/* SCIP --- Solving Constraint Integer Programs */ -/* */ -/* Copyright (C) 2010-2022 Operations Research, RWTH Aachen University */ -/* Zuse Institute Berlin (ZIB) */ -/* */ -/* This program is free software; you can redistribute it and/or */ -/* modify it under the terms of the GNU Lesser General Public License */ -/* as published by the Free Software Foundation; either version 3 */ -/* of the License, or (at your option) any later version. */ -/* */ -/* This program is distributed in the hope that it will be useful, */ -/* but WITHOUT ANY WARRANTY; without even the implied warranty of */ -/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ -/* GNU Lesser General Public License for more details. */ -/* */ -/* You should have received a copy of the GNU Lesser General Public License */ -/* along with this program; if not, write to the Free Software */ -/* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.*/ -/* */ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -/**@file class_varpartition.h - * @brief class representing a partition of a set of variables - * @author Julius Hense - * - */ - -/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/ - -#ifndef GCG_CLASS_VARPARTITION_H__ -#define GCG_CLASS_VARPARTITION_H__ - -#include "class_indexpartition.h" - -namespace gcg -{ - -enum VarClassDecompInfo -{ - ALL = 0, - LINKING = 1, - MASTER = 2, - BLOCK = 3 -}; -typedef enum VarClassDecompInfo VAR_DECOMPINFO; - - -class VarPartition : public IndexPartition -{ - -public: - - /** constructor */ - VarPartition( - SCIP* scip, /**< scip data structure */ - const char* name, /**< name of partition (will be copied) */ - int nClasses, /**< initial number of classes */ - int nVars /**< number of variables to be classified */ - ); - - /** copy constructor */ - VarPartition( - const VarPartition* toCopy /**< VarPartition to be copied */ - ); - - - /** destructor */ - ~VarPartition(); - - - /** creates a new class, returns index of the class */ - int addClass( - const char* name, /**< name of the class (will be copied) */ - const char* desc, /**< description of the class (will be copied) */ - VAR_DECOMPINFO decompInfo /**< decomposition code of the class */ - ); - - /** assigns a variable to a class */ - void assignVarToClass( - int varindex, /**< index of the variable */ - int classindex /**< index of the class */ - ); - - /** returns a vector containing all possible subsets of the chosen classindices */ - std::vector> getAllSubsets( - bool all, /**< true, if ALL classes should be considered */ - bool linking, /**< true, if LINKING classes should be considered */ - bool master, /**< true, if MASTER classes should be considered */ - bool block /**< true, if BLOCK classes should be considered */ - ); - - /** returns the decomposition info of a class */ - VAR_DECOMPINFO getClassDecompInfo( - int classindex /**< index of class */ - ); - - /** returns the name of the class a variable is assigned to */ - const char* getClassNameOfVar( - int varindex /**< index of variable */ - ); - - - /** returns the index of the class a variable is assigned to */ - int getClassOfVar( - int varindex /**< index of variable */ - ); - - /** returns vector containing the assigned class of each variable */ - const int* getVarsToClasses( - ); - - /** returns the number of variables */ - int getNVars( - ); - - /** returns a vector with the numbers of variables that are assigned to the classes */ - std::vector getNVarsOfClasses( - ); - - /** returns whether a variable is already assigned to a class */ - bool isVarClassified( - int varindex /**< index of variable */ - ); - - - /** returns partition with reduced number of classes - * if the current number of classes is greater than an upper bound - * and lower than 2*(upper bound) (returns NULL otherwise) */ - VarPartition* reduceClasses( - int maxNumberOfClasses /**< upper bound */ - ); - - /** sets the decomposition code of a class */ - void setClassDecompInfo( - int classindex, /**< index of class */ - VAR_DECOMPINFO decompInfo /**< decomposition code of class */ - ); - -}; - - -} /* namespace gcg */ -#endif /* GCG_CLASS_VARPARTITION_H__ */ diff --git a/headers/gcg/clscons_consnamelevenshtein.h b/headers/gcg/clscons_consnamelevenshtein.h deleted file mode 100644 index d461c69..0000000 --- a/headers/gcg/clscons_consnamelevenshtein.h +++ /dev/null @@ -1,56 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* */ -/* This file is part of the program */ -/* GCG --- Generic Column Generation */ -/* a Dantzig-Wolfe decomposition based extension */ -/* of the branch-cut-and-price framework */ -/* SCIP --- Solving Constraint Integer Programs */ -/* */ -/* Copyright (C) 2010-2022 Operations Research, RWTH Aachen University */ -/* Zuse Institute Berlin (ZIB) */ -/* */ -/* This program is free software; you can redistribute it and/or */ -/* modify it under the terms of the GNU Lesser General Public License */ -/* as published by the Free Software Foundation; either version 3 */ -/* of the License, or (at your option) any later version. */ -/* */ -/* This program is distributed in the hope that it will be useful, */ -/* but WITHOUT ANY WARRANTY; without even the implied warranty of */ -/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ -/* GNU Lesser General Public License for more details. */ -/* */ -/* You should have received a copy of the GNU Lesser General Public License */ -/* along with this program; if not, write to the Free Software */ -/* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.*/ -/* */ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -/**@file clscons_consnamelevenshtein.h - * @brief classifies constraints according to levenshtein distance graph of their names - * @author William Ma - */ - -/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/ - -#ifndef CLSCONS_CONSNAMELEVENSHTEIN_H_ -#define CLSCONS_CONSNAMELEVENSHTEIN_H_ - - -#include "scip/scip.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/** creates the scip consnames no numbers classifier and includes it in SCIP */ -extern -SCIP_RETCODE SCIPincludeConsClassifierConsnameLevenshtein( - SCIP* scip /**< SCIP data structure */ - ); - -#ifdef __cplusplus -} -#endif - -#endif - diff --git a/headers/gcg/clscons_consnamenonumbers.h b/headers/gcg/clscons_consnamenonumbers.h deleted file mode 100644 index 1ba1f16..0000000 --- a/headers/gcg/clscons_consnamenonumbers.h +++ /dev/null @@ -1,56 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* */ -/* This file is part of the program */ -/* GCG --- Generic Column Generation */ -/* a Dantzig-Wolfe decomposition based extension */ -/* of the branch-cut-and-price framework */ -/* SCIP --- Solving Constraint Integer Programs */ -/* */ -/* Copyright (C) 2010-2022 Operations Research, RWTH Aachen University */ -/* Zuse Institute Berlin (ZIB) */ -/* */ -/* This program is free software; you can redistribute it and/or */ -/* modify it under the terms of the GNU Lesser General Public License */ -/* as published by the Free Software Foundation; either version 3 */ -/* of the License, or (at your option) any later version. */ -/* */ -/* This program is distributed in the hope that it will be useful, */ -/* but WITHOUT ANY WARRANTY; without even the implied warranty of */ -/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ -/* GNU Lesser General Public License for more details. */ -/* */ -/* You should have received a copy of the GNU Lesser General Public License */ -/* along with this program; if not, write to the Free Software */ -/* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.*/ -/* */ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -/**@file clscons_consnamenonumbers.h - * @brief classifies constraints according to names (without digits) - * @author William Ma - */ - -/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/ - -#ifndef CLSCONS_SCIPCONSNAMENONUMBERS_H_ -#define CLSCONS_SCIPCONSNAMENONUMBERS_H_ - - -#include "scip/scip.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/** creates the scip consnames no numbers classifier and includes it in SCIP */ -extern -SCIP_RETCODE SCIPincludeConsClassifierForConsnamesDigitFreeIdentical( - SCIP* scip /**< SCIP data structure */ - ); - -#ifdef __cplusplus -} -#endif - -#endif - diff --git a/headers/gcg/clscons_gamsdomain.h b/headers/gcg/clscons_gamsdomain.h deleted file mode 100644 index d02a730..0000000 --- a/headers/gcg/clscons_gamsdomain.h +++ /dev/null @@ -1,65 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* */ -/* This file is part of the program */ -/* GCG --- Generic Column Generation */ -/* a Dantzig-Wolfe decomposition based extension */ -/* of the branch-cut-and-price framework */ -/* SCIP --- Solving Constraint Integer Programs */ -/* */ -/* Copyright (C) 2010-2022 Operations Research, RWTH Aachen University */ -/* Zuse Institute Berlin (ZIB) */ -/* */ -/* This program is free software; you can redistribute it and/or */ -/* modify it under the terms of the GNU Lesser General Public License */ -/* as published by the Free Software Foundation; either version 3 */ -/* of the License, or (at your option) any later version. */ -/* */ -/* This program is distributed in the hope that it will be useful, */ -/* but WITHOUT ANY WARRANTY; without even the implied warranty of */ -/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ -/* GNU Lesser General Public License for more details. */ -/* */ -/* You should have received a copy of the GNU Lesser General Public License */ -/* along with this program; if not, write to the Free Software */ -/* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.*/ -/* */ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -/**@file clscons_gamsdomain.h - * @brief Classifies by domains from which constraints are created TODO: what is together in one class? - * @author Stefanie Koß - */ - -/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/ - -#ifndef CLSCONS_GAMSDOMAIN_H_ -#define CLSCONS_GAMSDOMAIN_H_ - - -#include "scip/scip.h" -#include "type_consclassifier.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/** adds an entry to clsdata->constodomain */ -extern -SCIP_RETCODE DECconsClassifierGamsdomainAddEntry( - DEC_CONSCLASSIFIER* classifier, - SCIP_CONS* cons, - int symDomIdx[], - int* symDim -); - -/** creates the gamsdomain classifier and includes it in SCIP */ -extern -SCIP_RETCODE SCIPincludeConsClassifierGamsdomain( - SCIP* scip /**< SCIP data structure */ - ); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/headers/gcg/clscons_gamssymbol.h b/headers/gcg/clscons_gamssymbol.h deleted file mode 100644 index fb2b6bf..0000000 --- a/headers/gcg/clscons_gamssymbol.h +++ /dev/null @@ -1,64 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* */ -/* This file is part of the program */ -/* GCG --- Generic Column Generation */ -/* a Dantzig-Wolfe decomposition based extension */ -/* of the branch-cut-and-price framework */ -/* SCIP --- Solving Constraint Integer Programs */ -/* */ -/* Copyright (C) 2010-2022 Operations Research, RWTH Aachen University */ -/* Zuse Institute Berlin (ZIB) */ -/* */ -/* This program is free software; you can redistribute it and/or */ -/* modify it under the terms of the GNU Lesser General Public License */ -/* as published by the Free Software Foundation; either version 3 */ -/* of the License, or (at your option) any later version. */ -/* */ -/* This program is distributed in the hope that it will be useful, */ -/* but WITHOUT ANY WARRANTY; without even the implied warranty of */ -/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ -/* GNU Lesser General Public License for more details. */ -/* */ -/* You should have received a copy of the GNU Lesser General Public License */ -/* along with this program; if not, write to the Free Software */ -/* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.*/ -/* */ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -/**@file clscons_gamssymbol.h - * @brief Constraints which have the same symbol are put into same class - * @author Stefanie Koß - */ - -/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/ - -#ifndef CLSCONS_GAMSSYMBOL_H_ -#define CLSCONS_GAMSSYMBOL_H_ - - -#include "scip/scip.h" -#include "type_consclassifier.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/** adds an entry to clsdata->constosymbol */ -extern -SCIP_RETCODE DECconsClassifierGamssymbolAddEntry( - DEC_CONSCLASSIFIER* classifier, - SCIP_CONS* cons, - int symbolIdx -); - -/** creates the gamssymbol classifier and includes it in SCIP */ -extern -SCIP_RETCODE SCIPincludeConsClassifierGamssymbol( - SCIP* scip /**< SCIP data structure */ - ); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/headers/gcg/clscons_miplibconstypes.h b/headers/gcg/clscons_miplibconstypes.h deleted file mode 100644 index 86a31de..0000000 --- a/headers/gcg/clscons_miplibconstypes.h +++ /dev/null @@ -1,56 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* */ -/* This file is part of the program */ -/* GCG --- Generic Column Generation */ -/* a Dantzig-Wolfe decomposition based extension */ -/* of the branch-cut-and-price framework */ -/* SCIP --- Solving Constraint Integer Programs */ -/* */ -/* Copyright (C) 2010-2022 Operations Research, RWTH Aachen University */ -/* Zuse Institute Berlin (ZIB) */ -/* */ -/* This program is free software; you can redistribute it and/or */ -/* modify it under the terms of the GNU Lesser General Public License */ -/* as published by the Free Software Foundation; either version 3 */ -/* of the License, or (at your option) any later version. */ -/* */ -/* This program is distributed in the hope that it will be useful, */ -/* but WITHOUT ANY WARRANTY; without even the implied warranty of */ -/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ -/* GNU Lesser General Public License for more details. */ -/* */ -/* You should have received a copy of the GNU Lesser General Public License */ -/* along with this program; if not, write to the Free Software */ -/* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.*/ -/* */ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -/**@file clscons_miplibconstypes.h - * @brief classifies constraints according to their miplib constypes - * @author William Ma - */ - -/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/ - -#ifndef CLSCONS_MIPLIBCONSTYPES_H_ -#define CLSCONS_MIPLIBCONSTYPES_H_ - - -#include "scip/scip.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/** creates the miplibconstypes classifier and includes it in SCIP */ -extern -SCIP_RETCODE SCIPincludeConsClassifierMiplibConstypes( - SCIP* scip /**< SCIP data structure */ - ); - -#ifdef __cplusplus -} -#endif - -#endif - diff --git a/headers/gcg/clscons_nnonzeros.h b/headers/gcg/clscons_nnonzeros.h deleted file mode 100644 index 81bffba..0000000 --- a/headers/gcg/clscons_nnonzeros.h +++ /dev/null @@ -1,56 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* */ -/* This file is part of the program */ -/* GCG --- Generic Column Generation */ -/* a Dantzig-Wolfe decomposition based extension */ -/* of the branch-cut-and-price framework */ -/* SCIP --- Solving Constraint Integer Programs */ -/* */ -/* Copyright (C) 2010-2022 Operations Research, RWTH Aachen University */ -/* Zuse Institute Berlin (ZIB) */ -/* */ -/* This program is free software; you can redistribute it and/or */ -/* modify it under the terms of the GNU Lesser General Public License */ -/* as published by the Free Software Foundation; either version 3 */ -/* of the License, or (at your option) any later version. */ -/* */ -/* This program is distributed in the hope that it will be useful, */ -/* but WITHOUT ANY WARRANTY; without even the implied warranty of */ -/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ -/* GNU Lesser General Public License for more details. */ -/* */ -/* You should have received a copy of the GNU Lesser General Public License */ -/* along with this program; if not, write to the Free Software */ -/* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.*/ -/* */ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -/**@file clscons_nnonzeros.h - * @brief classifies constraints according to their nonzero entries - * @author William Ma - */ - -/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/ - -#ifndef CLSCONS_NNONZEROS_H_ -#define CLSCONS_NNONZEROS_H_ - - -#include "scip/scip.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/** creates the classifier for NNonzeros and includes it in SCIP */ -extern -SCIP_RETCODE SCIPincludeConsClassifierNNonzeros( - SCIP* scip /**< SCIP data structure */ - ); - -#ifdef __cplusplus -} -#endif - -#endif - diff --git a/headers/gcg/clscons_scipconstypes.h b/headers/gcg/clscons_scipconstypes.h deleted file mode 100644 index c2ca04e..0000000 --- a/headers/gcg/clscons_scipconstypes.h +++ /dev/null @@ -1,56 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* */ -/* This file is part of the program */ -/* GCG --- Generic Column Generation */ -/* a Dantzig-Wolfe decomposition based extension */ -/* of the branch-cut-and-price framework */ -/* SCIP --- Solving Constraint Integer Programs */ -/* */ -/* Copyright (C) 2010-2022 Operations Research, RWTH Aachen University */ -/* Zuse Institute Berlin (ZIB) */ -/* */ -/* This program is free software; you can redistribute it and/or */ -/* modify it under the terms of the GNU Lesser General Public License */ -/* as published by the Free Software Foundation; either version 3 */ -/* of the License, or (at your option) any later version. */ -/* */ -/* This program is distributed in the hope that it will be useful, */ -/* but WITHOUT ANY WARRANTY; without even the implied warranty of */ -/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ -/* GNU Lesser General Public License for more details. */ -/* */ -/* You should have received a copy of the GNU Lesser General Public License */ -/* along with this program; if not, write to the Free Software */ -/* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.*/ -/* */ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -/**@file clscons_scipconstypes.h - * @brief classifies constraints according to their scip constypes - * @author William Ma - */ - -/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/ - -#ifndef CLSCONS_SCIPCONSTYPES_H_ -#define CLSCONS_SCIPCONSTYPES_H_ - - -#include "scip/scip.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/** creates the scip constypes classifier and includes it in SCIP */ -extern -SCIP_RETCODE SCIPincludeConsClassifierScipConstypes( - SCIP* scip /**< SCIP data structure */ - ); - -#ifdef __cplusplus -} -#endif - -#endif - diff --git a/headers/gcg/clsvar_gamsdomain.h b/headers/gcg/clsvar_gamsdomain.h deleted file mode 100644 index a2834f9..0000000 --- a/headers/gcg/clsvar_gamsdomain.h +++ /dev/null @@ -1,64 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* */ -/* This file is part of the program */ -/* GCG --- Generic Column Generation */ -/* a Dantzig-Wolfe decomposition based extension */ -/* of the branch-cut-and-price framework */ -/* SCIP --- Solving Constraint Integer Programs */ -/* */ -/* Copyright (C) 2010-2022 Operations Research, RWTH Aachen University */ -/* Zuse Institute Berlin (ZIB) */ -/* */ -/* This program is free software; you can redistribute it and/or */ -/* modify it under the terms of the GNU Lesser General Public License */ -/* as published by the Free Software Foundation; either version 3 */ -/* of the License, or (at your option) any later version. */ -/* */ -/* This program is distributed in the hope that it will be useful, */ -/* but WITHOUT ANY WARRANTY; without even the implied warranty of */ -/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ -/* GNU Lesser General Public License for more details. */ -/* */ -/* You should have received a copy of the GNU Lesser General Public License */ -/* along with this program; if not, write to the Free Software */ -/* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.*/ -/* */ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -/**@file clsvar_gamsdomain.h - * @brief Classifies by domains from which variables are created TODO: what is together in one class? - * @author Stefanie Koß - */ - -/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/ - -#ifndef CLSVAR_GAMSDOMAIN_H_ -#define CLSVAR_GAMSDOMAIN_H_ - - -#include "scip/scip.h" -#include "type_varclassifier.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/** adds an entry to clsdata->vartodomain */ -SCIP_RETCODE DECvarClassifierGamsdomainAddEntry( - DEC_VARCLASSIFIER* classifier, - SCIP_VAR* var, - int symDomIdx[], - int* symDim -); - -/** creates the gamsdomain classifier and includes it in SCIP */ -extern -SCIP_RETCODE SCIPincludeVarClassifierGamsdomain( - SCIP* scip /**< SCIP data structure */ - ); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/headers/gcg/clsvar_gamssymbol.h b/headers/gcg/clsvar_gamssymbol.h deleted file mode 100644 index e2d833e..0000000 --- a/headers/gcg/clsvar_gamssymbol.h +++ /dev/null @@ -1,63 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* */ -/* This file is part of the program */ -/* GCG --- Generic Column Generation */ -/* a Dantzig-Wolfe decomposition based extension */ -/* of the branch-cut-and-price framework */ -/* SCIP --- Solving Constraint Integer Programs */ -/* */ -/* Copyright (C) 2010-2022 Operations Research, RWTH Aachen University */ -/* Zuse Institute Berlin (ZIB) */ -/* */ -/* This program is free software; you can redistribute it and/or */ -/* modify it under the terms of the GNU Lesser General Public License */ -/* as published by the Free Software Foundation; either version 3 */ -/* of the License, or (at your option) any later version. */ -/* */ -/* This program is distributed in the hope that it will be useful, */ -/* but WITHOUT ANY WARRANTY; without even the implied warranty of */ -/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ -/* GNU Lesser General Public License for more details. */ -/* */ -/* You should have received a copy of the GNU Lesser General Public License */ -/* along with this program; if not, write to the Free Software */ -/* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.*/ -/* */ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -/**@file clsvar_gamssymbol.h - * @brief variables which have the same symbol are put into same class - * @author Stefanie Koß - */ - -/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/ - -#ifndef CLSVAR_GAMSSYMBOL_H_ -#define CLSVAR_GAMSSYMBOL_H_ - - -#include "scip/scip.h" -#include "type_varclassifier.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/** adds an entry to clsdata->vartosymbol */ -SCIP_RETCODE DECvarClassifierGamssymbolAddEntry( - DEC_VARCLASSIFIER* classifier, - SCIP_VAR* var, - int symbolIdx -); - -/** creates the gamssymbol classifier and includes it in SCIP */ -extern -SCIP_RETCODE SCIPincludeVarClassifierGamssymbol( - SCIP* scip /**< SCIP data structure */ - ); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/headers/gcg/clsvar_objvalues.h b/headers/gcg/clsvar_objvalues.h deleted file mode 100644 index c3a4cbd..0000000 --- a/headers/gcg/clsvar_objvalues.h +++ /dev/null @@ -1,55 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* */ -/* This file is part of the program */ -/* GCG --- Generic Column Generation */ -/* a Dantzig-Wolfe decomposition based extension */ -/* of the branch-cut-and-price framework */ -/* SCIP --- Solving Constraint Integer Programs */ -/* */ -/* Copyright (C) 2010-2022 Operations Research, RWTH Aachen University */ -/* Zuse Institute Berlin (ZIB) */ -/* */ -/* This program is free software; you can redistribute it and/or */ -/* modify it under the terms of the GNU Lesser General Public License */ -/* as published by the Free Software Foundation; either version 3 */ -/* of the License, or (at your option) any later version. */ -/* */ -/* This program is distributed in the hope that it will be useful, */ -/* but WITHOUT ANY WARRANTY; without even the implied warranty of */ -/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ -/* GNU Lesser General Public License for more details. */ -/* */ -/* You should have received a copy of the GNU Lesser General Public License */ -/* along with this program; if not, write to the Free Software */ -/* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.*/ -/* */ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -/**@file clsvar_objvalues.h - * @brief classifies variables according to their objective function values - * @author William Ma - */ - -/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/ - -#ifndef CLSVAR_OBJVALUES_H_ -#define CLSVAR_OBJVALUES_H_ - - -#include "scip/scip.h" - -#ifdef __cplusplus -extern "C" { -#endif - -extern -SCIP_RETCODE SCIPincludeVarClassifierObjValues( - SCIP* scip /**< SCIP data structure */ - ); - -#ifdef __cplusplus -} -#endif - -#endif - diff --git a/headers/gcg/clsvar_objvaluesigns.h b/headers/gcg/clsvar_objvaluesigns.h deleted file mode 100644 index 7765b63..0000000 --- a/headers/gcg/clsvar_objvaluesigns.h +++ /dev/null @@ -1,55 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* */ -/* This file is part of the program */ -/* GCG --- Generic Column Generation */ -/* a Dantzig-Wolfe decomposition based extension */ -/* of the branch-cut-and-price framework */ -/* SCIP --- Solving Constraint Integer Programs */ -/* */ -/* Copyright (C) 2010-2022 Operations Research, RWTH Aachen University */ -/* Zuse Institute Berlin (ZIB) */ -/* */ -/* This program is free software; you can redistribute it and/or */ -/* modify it under the terms of the GNU Lesser General Public License */ -/* as published by the Free Software Foundation; either version 3 */ -/* of the License, or (at your option) any later version. */ -/* */ -/* This program is distributed in the hope that it will be useful, */ -/* but WITHOUT ANY WARRANTY; without even the implied warranty of */ -/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ -/* GNU Lesser General Public License for more details. */ -/* */ -/* You should have received a copy of the GNU Lesser General Public License */ -/* along with this program; if not, write to the Free Software */ -/* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.*/ -/* */ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -/**@file clsvar_objvaluesigns.h - * @brief classifies variables according to their objective function value signs - * @author William Ma - */ - -/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/ - -#ifndef CLSVAR_OBJVALUESIGNS_H_ -#define CLSVAR_OBJVALUESIGNS_H_ - - -#include "scip/scip.h" - -#ifdef __cplusplus -extern "C" { -#endif - -extern -SCIP_RETCODE SCIPincludeVarClassifierObjValueSigns( - SCIP* scip /**< SCIP data structure */ - ); - -#ifdef __cplusplus -} -#endif - -#endif - diff --git a/headers/gcg/clsvar_scipvartypes.h b/headers/gcg/clsvar_scipvartypes.h deleted file mode 100644 index a7ba75e..0000000 --- a/headers/gcg/clsvar_scipvartypes.h +++ /dev/null @@ -1,55 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* */ -/* This file is part of the program */ -/* GCG --- Generic Column Generation */ -/* a Dantzig-Wolfe decomposition based extension */ -/* of the branch-cut-and-price framework */ -/* SCIP --- Solving Constraint Integer Programs */ -/* */ -/* Copyright (C) 2010-2022 Operations Research, RWTH Aachen University */ -/* Zuse Institute Berlin (ZIB) */ -/* */ -/* This program is free software; you can redistribute it and/or */ -/* modify it under the terms of the GNU Lesser General Public License */ -/* as published by the Free Software Foundation; either version 3 */ -/* of the License, or (at your option) any later version. */ -/* */ -/* This program is distributed in the hope that it will be useful, */ -/* but WITHOUT ANY WARRANTY; without even the implied warranty of */ -/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ -/* GNU Lesser General Public License for more details. */ -/* */ -/* You should have received a copy of the GNU Lesser General Public License */ -/* along with this program; if not, write to the Free Software */ -/* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.*/ -/* */ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -/**@file clsvar_scipvartypes.h - * @brief classifies variables according to their scip vartypes - * @author William Ma - */ - -/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/ - -#ifndef CLSVAR_SCIPVARTYPES_H_ -#define CLSVAR_SCIPVARTYPES_H_ - - -#include "scip/scip.h" - -#ifdef __cplusplus -extern "C" { -#endif - -extern -SCIP_RETCODE SCIPincludeVarClassifierScipVartypes( - SCIP* scip /**< SCIP data structure */ - ); - -#ifdef __cplusplus -} -#endif - -#endif - diff --git a/headers/gcg/colpool.h b/headers/gcg/colpool.h deleted file mode 100644 index 7a05b8c..0000000 --- a/headers/gcg/colpool.h +++ /dev/null @@ -1,50 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* */ -/* This file is part of the program */ -/* GCG --- Generic Column Generation */ -/* a Dantzig-Wolfe decomposition based extension */ -/* of the branch-cut-and-price framework */ -/* SCIP --- Solving Constraint Integer Programs */ -/* */ -/* Copyright (C) 2010-2022 Operations Research, RWTH Aachen University */ -/* Zuse Institute Berlin (ZIB) */ -/* */ -/* This program is free software; you can redistribute it and/or */ -/* modify it under the terms of the GNU Lesser General Public License */ -/* as published by the Free Software Foundation; either version 3 */ -/* of the License, or (at your option) any later version. */ -/* */ -/* This program is distributed in the hope that it will be useful, */ -/* but WITHOUT ANY WARRANTY; without even the implied warranty of */ -/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ -/* GNU Lesser General Public License for more details. */ -/* */ -/* You should have received a copy of the GNU Lesser General Public License */ -/* along with this program; if not, write to the Free Software */ -/* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.*/ -/* */ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -/**@file colpool.h - * @brief internal methods for storing cols in a col pool - * @author Jonas Witt - */ - -/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/ - -#ifndef __GCG_COLPOOL_H__ -#define __GCG_COLPOOL_H__ - -#include "type_colpool.h" -#include "pub_colpool.h" -#include "type_pricestore_gcg.h" - -#ifdef __cplusplus -extern "C" { -#endif - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/headers/gcg/cons_decomp.h b/headers/gcg/cons_decomp.h deleted file mode 100644 index 9ecaa9d..0000000 --- a/headers/gcg/cons_decomp.h +++ /dev/null @@ -1,1026 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* */ -/* This file is part of the program */ -/* GCG --- Generic Column Generation */ -/* a Dantzig-Wolfe decomposition based extension */ -/* of the branch-cut-and-price framework */ -/* SCIP --- Solving Constraint Integer Programs */ -/* */ -/* Copyright (C) 2010-2022 Operations Research, RWTH Aachen University */ -/* Zuse Institute Berlin (ZIB) */ -/* */ -/* This program is free software; you can redistribute it and/or */ -/* modify it under the terms of the GNU Lesser General Public License */ -/* as published by the Free Software Foundation; either version 3 */ -/* of the License, or (at your option) any later version. */ -/* */ -/* This program is distributed in the hope that it will be useful, */ -/* but WITHOUT ANY WARRANTY; without even the implied warranty of */ -/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ -/* GNU Lesser General Public License for more details. */ -/* */ -/* You should have received a copy of the GNU Lesser General Public License */ -/* along with this program; if not, write to the Free Software */ -/* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.*/ -/* */ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -/**@file cons_decomp.h -* @ingroup DECOMP - * @brief constraint handler for structure detection - * @author Martin Bergner - * @author Michael Bastubbe - * @author Hanna Franzen - * - * This constraint handler manages the structure detection process. It will run all registered structure detectors in an - * iterative refinement scheme. Afterwards some post-processing detectors might be called. - */ - -/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/ - -#ifndef GCG_CONS_DECOMP_H__ -#define GCG_CONS_DECOMP_H__ - -#include "scip/scip.h" -#include "type_detector.h" -#include "type_varclassifier.h" -#include "type_consclassifier.h" -#include "type_scoretype.h" - - -#ifdef __cplusplus -extern "C" { -#endif - - -/** forward declarations */ -struct Partialdecomp_Wrapper; -typedef struct Partialdecomp_Wrapper PARTIALDECOMP_WRAPPER; - -struct Detprobdata_Wrapper; - -/** - * @brief returns the data of the provided consclassifier - * @returns data of the provided consclassifier - */ -extern -DEC_CLASSIFIERDATA* DECconsClassifierGetData( - DEC_CONSCLASSIFIER* classifier /**< Classifier data structure */ - ); - -/** - * @brief returns the name of the provided classifier - * @returns name of the given classifier - */ -extern -const char* DECconsClassifierGetName( - DEC_CONSCLASSIFIER* classifier /**< classifier data structure */ - ); - -/** - * @brief returns the data of the provided varclassifier - * @returns data of the provided varclassifier - */ -extern -DEC_CLASSIFIERDATA* DECvarClassifierGetData( - DEC_VARCLASSIFIER* classifier /**< Classifier data structure */ - ); - -/** - * @brief returns the name of the provided classifier - * @returns name of the given classifier - */ -extern -const char* DECvarClassifierGetName( - DEC_VARCLASSIFIER* classifier /**< classifier data structure */ - ); - -/** @brief Gets the character of the detector - * @returns detector character */ -extern -char DECdetectorGetChar( - DEC_DETECTOR* detector /**< pointer to detector */ - ); - -/** - * @brief returns the data of the provided detector - * @returns data of the provided detector - */ -extern -DEC_DETECTORDATA* DECdetectorGetData( - DEC_DETECTOR* detector /**< Detector data structure */ - ); - -/** - * @brief returns the name of the provided detector - * @returns name of the given detector - */ -extern -const char* DECdetectorGetName( - DEC_DETECTOR* detector /**< detector data structure */ - ); - -/** @brief interface method to detect the structure including presolving - * @returns SCIP return code */ -extern -SCIP_RETCODE DECdetectStructure( - SCIP* scip, /**< SCIP data structure */ - SCIP_RESULT* result /**< Result pointer to indicate whether some structure was found */ - ); - -/** - * @brief searches for the consclassifier with the given name and returns it or NULL if classifier is not found - * @returns consclassifier pointer or NULL if consclassifier with given name is not found - */ -extern -DEC_CONSCLASSIFIER* DECfindConsClassifier( - SCIP* scip, /**< SCIP data structure */ - const char* name /**< the name of the searched consclassifier */ - ); - -/** - * @brief searches for the varclassifier with the given name and returns it or NULL if classifier is not found - * @returns varclassifier pointer or NULL if varclassifier with given name is not found - */ -extern -DEC_VARCLASSIFIER* DECfindVarClassifier( - SCIP* scip, /**< SCIP data structure */ - const char* name /**< the name of the searched varclassifier */ - ); - - -/** - * @brief searches for the detector with the given name and returns it or NULL if detector is not found - * @returns detector pointer or NULL if detector with given name is not found - */ -extern -DEC_DETECTOR* DECfindDetector( - SCIP* scip, /**< SCIP data structure */ - const char* name /**< the name of the searched detector */ - ); - -/** @brief Gets the best known decomposition - * - * @note caller has to free returned DEC_DECOMP - * @returns the decomposition if available and NULL otherwise */ -extern -DEC_DECOMP* DECgetBestDecomp( - SCIP* scip, /**< SCIP data structure */ - SCIP_Bool printwarnings /**< should warnings pre printed */ - ); - -/** @brief Gets the currently considered best partialdec - * - * If there is a partialdec marked to be returned (e.g. by /DECwriteAllDecomps), it is written. - * Else, the currently "best" decomp is returned. - * - * @returns partialdec to write if one can be found, or partialdecwrapper->partialdec = NULL otherwise */ -extern -SCIP_RETCODE DECgetPartialdecToWrite( - SCIP* scip, /**< SCIP data structure */ - SCIP_Bool transformed, /**< is the problem transformed yet */ - PARTIALDECOMP_WRAPPER* partialdecwrapper /**< partialdec wrapper to output */ - ); - -/** - * @brief returns the remaining time of scip that the decomposition may use - * @returns remaining time that the decompositon may use - */ -extern -SCIP_Real DECgetRemainingTime( - SCIP* scip /**< SCIP data structure */ - ); - -/** - * @brief includes one constraint classifier - * @returns scip return code - */ -extern -SCIP_RETCODE DECincludeConsClassifier( - SCIP* scip, /**< scip data structure */ - const char* name, /**< name of the classifier */ - const char* description, /**< describing main idea of this classifier */ - int priority, /**< priority of the classifier */ - SCIP_Bool enabled, /**< whether the classifier should be enabled by default */ - DEC_CLASSIFIERDATA* classifierdata, /**< classifierdata the associated classifier data (or NULL) */ - DEC_DECL_FREECONSCLASSIFIER((*freeClassifier)), /**< destructor of classifier (or NULL) */ - DEC_DECL_CONSCLASSIFY((*classify)) /**< the method that will classify constraints or variables (must not be NULL) */ - ); - -/** - * @brief includes one detector - * @returns scip return code - */ -extern -SCIP_RETCODE DECincludeDetector( - SCIP* scip, /**< scip data structure */ - const char* name, /**< name of the detector */ - const char decchar, /**< char that is used in detector chain history for this detector */ - const char* description, /**< describing main idea of this detector */ - int freqCallRound, /**< frequency the detector gets called in detection loop, i.e. it is called in round r if and only if minCallRound <= r <= maxCallRound AND (r - minCallRound) mod freqCallRound == 0 */ - int maxCallRound, /**< last detection round the detector gets called */ - int minCallRound, /**< first round the detector gets called (offset in detection loop) */ - int freqCallRoundOriginal, /**< frequency the detector gets called in detection loop while detecting of the original problem */ - int maxCallRoundOriginal, /**< last round the detector gets called while detecting of the original problem */ - int minCallRoundOriginal, /**< first round the detector gets called (offset in detection loop) while detecting of the original problem */ - int priority, /**< priority of the detector */ - SCIP_Bool enabled, /**< whether the detector should be enabled by default */ - SCIP_Bool enabledFinishing, /**< whether the finishing should be enabled */ - SCIP_Bool enabledPostprocessing, /**< whether the postprocessing should be enabled */ - SCIP_Bool skip, /**< whether the detector should be skipped if others found structure */ - SCIP_Bool usefulRecall, /**< is it useful to call this detector on a descendant of the propagated partialdec */ - DEC_DETECTORDATA *detectordata, /**< the associated detector data (or NULL) */ - DEC_DECL_FREEDETECTOR((*freeDetector)), /**< destructor of detector (or NULL) */ - DEC_DECL_INITDETECTOR((*initDetector)), /**< initialization method of detector (or NULL) */ - DEC_DECL_EXITDETECTOR((*exitDetector)), /**< deinitialization method of detector (or NULL) */ - DEC_DECL_PROPAGATEPARTIALDEC((*propagatePartialdecDetector)), /**< method to refine a partial decomposition inside detection loop (or NULL) */ - DEC_DECL_FINISHPARTIALDEC((*finishPartialdecDetector)), /**< method to complete a partial decomposition when called in detection loop (or NULL) */ - DEC_DECL_POSTPROCESSPARTIALDEC((*postprocessPartialdecDetector)), /**< method to postprocess a complete decomposition, called after detection loop (or NULL) */ - DEC_DECL_SETPARAMAGGRESSIVE((*setParamAggressiveDetector)), /**< method that is called if the detection emphasis setting aggressive is chosen */ - DEC_DECL_SETPARAMDEFAULT((*setParamDefaultDetector)), /**< method that is called if the detection emphasis setting default is chosen */ - DEC_DECL_SETPARAMFAST((*setParamFastDetector)) /**< method that is called if the detection emphasis setting fast is chosen */ - ); - -/** - * @brief includes one variable classifier - * @returns scip return code - */ -extern -SCIP_RETCODE DECincludeVarClassifier( - SCIP* scip, /**< scip data structure */ - const char* name, /**< name of the classifier */ - const char* description, /**< description of the classifier */ - int priority, /**< priority how early classifier is invoked */ - SCIP_Bool enabled, /**< whether the classifier should be enabled by default */ - DEC_CLASSIFIERDATA* classifierdata,/**< classifierdata the associated classifier data (or NULL) */ - DEC_DECL_FREEVARCLASSIFIER((*freeClassifier)), /**< destructor of classifier (or NULL) */ - DEC_DECL_VARCLASSIFY((*classify)) /**< method that will classify variables (must not be NULL) */ - ); - -/** @brief writes out a list of all detectors */ -extern -void DECprintListOfDetectors( - SCIP* scip /**< SCIP data structure */ - ); - -/** @brief write out all known decompositions - * @returns SCIP return code */ -extern -SCIP_RETCODE DECwriteAllDecomps( - SCIP* scip, /**< SCIP data structure */ - char* directory, /**< directory for decompositions */ - char* extension, /**< the file extension for the export */ - SCIP_Bool original, /**< should decomps for original problem be written */ - SCIP_Bool presolved /**< should decomps for preoslved problem be written */ - ); - -/** @brief writes all selected decompositions - * @returns scip return code -*/ -extern -SCIP_RETCODE DECwriteSelectedDecomps( - SCIP* scip, /**< SCIP data structure */ - char* directory, /**< directory for decompositions */ - char* extension /**< extension for decompositions */ - ); - -/** @brief adds a candidate for block number and counts how often a candidate is added */ -extern -void GCGconshdlrDecompAddCandidatesNBlocks( - SCIP* scip, /**< SCIP data structure */ - SCIP_Bool origprob, /**< which DETPROBDATA that should be modified */ - int candidate /**< proposed amount of blocks */ -); - -/** - * @brief adds the given decomposition structure - * @returns scip return code - */ -extern -SCIP_RETCODE GCGconshdlrDecompAddDecomp( - SCIP* scip, /**< SCIP data structure */ - DEC_DECOMP* decomp, /**< DEC_DECOMP data structure */ - SCIP_Bool select /**< select the decomposition as candidate */ - ); - -/** - * @brief creates and adds a basic partialdecomp (all cons/vars are assigned to master) - * - * @returns id of partialdec - */ -extern -int GCGconshdlrDecompAddBasicPartialdec( - SCIP* scip, /**< SCIP data structure */ - SCIP_Bool presolved /**< create basic partialdecomp for presolved if true, otherwise for original */ - ); - -/** - * @brief creates a pure matrix partialdecomp (i.e. all cons/vars to one single block) - * - * matrix is added to list of all partialdecs - * @returns id of matrix partialdec - */ -extern -int GCGconshdlrDecompAddMatrixPartialdec( - SCIP* scip, /**< SCIP data structure */ - SCIP_Bool presolved /**< create matrix for presolved if true, otherwise for original */ - ); - -/** - * @brief adds a decomp that exists before the detection is called - * @note this method should only be called if there is no partialdec for this decomposition - * @returns scip return code - */ -extern -SCIP_RETCODE GCGconshdlrDecompAddPreexistingDecomp( - SCIP* scip, /**< SCIP data structure */ - DEC_DECOMP* decomp /**< decomposition data structure */ - ); - -/** - * @brief adds given time to total score calculation time - * @return scip return code - */ -extern -SCIP_RETCODE GCGconshdlrDecompAddScoreTime( - SCIP* scip, /**< SCIP data structure */ - SCIP_Real time /**< time to add */ - ); - -/** @brief adds a candidate for block size given by the user */ -extern -void GCGconshdlrDecompAddUserCandidatesNBlocks( - SCIP* scip, /**< SCIP data structure */ - int candidate /**< candidate for block size */ - ); - -/** - * @brief checks if two pricing problems are identical based on information from detection - * @returns scip return code - */ -extern -SCIP_RETCODE GCGconshdlrDecompArePricingprobsIdenticalForPartialdecid( - SCIP* scip, /**< scip scip data structure */ - int partialdecid, /**< partialdecid id of the partial decompostion for which the pricing problems are checked for identity */ - int probnr1, /**< index of first block to check */ - int probnr2, /**< index of second block to check */ - SCIP_Bool* identical /**< bool pointer to score the result of the check*/ - ); - -/** - * @brief calculates the benders score of a partialdec - * - * in detail: - * bendersscore = max ( 0., 1 - ( 1 - blockareascore + (1 - borderareascore - bendersareascore ) ) ) with - * blockareascore = blockarea / totalarea - * borderareascore = borderarea / totalarea - * bendersareascore = bendersarea /totalarea with - * bendersarea = A + B - PENALTY with - * A = nmasterconshittingonlyblockvars * nblockvarshittngNOmasterconss - * B = nlinkingvarshittingonlyblockconss * nblockconsshittingonlyblockvars - * PENALTY = \f$\sum_{b=1}^(\text{nblocks}) \sum_{\text{blockvars }bv\text{ of block }b\text{ hitting a master constraint}} \sum_{\text{all blocks }b2 != b} \text{nblockcons}(b2)\f$ - * - * @note experimental feature - * @return scip return code - */ -extern -SCIP_RETCODE GCGconshdlrDecompCalcBendersScore( - SCIP* scip, /**< SCIP data structure */ - int partialdecid, /**< id of partialdec the score is calculated for */ - SCIP_Real* score /**< score pointer to store the calculated score */ - ); - -/** - * @brief calculates the border area score of a partialdec - * - * 1 - fraction of border area to complete area - * @return scip return code - */ -extern -SCIP_RETCODE GCGconshdlrDecompCalcBorderAreaScore( - SCIP* scip, /**< SCIP data structure */ - int partialdecid, /**< id of partialdec the score is calculated for */ - SCIP_Real* score /**< score pointer to store the calculated score */ - ); - -/** - * @brief calculates and adds block size candidates using constraint classifications and variable classifications - */ -extern -void GCGconshdlrDecompCalcCandidatesNBlocks( - SCIP* scip, /**< SCIP data structure */ - SCIP_Bool transformed /**< whether to find the candidates for the transformed problem, otherwise the original */ -); - -/** - * @brief calculates the classic score of a partialdec - * - * @return scip return code - */ -extern -SCIP_RETCODE GCGconshdlrDecompCalcClassicScore( - SCIP* scip, /**< SCIP data structure */ - int partialdecid, /**< id of partialdec the score is calculated for */ - SCIP_Real* score /**< score pointer to store the calculated score */ - ); - -/** - * @brief calculates the maxforeseeingwhiteagg score of a partialdec - * - * maximum foreseeing white area score with respect to aggregatable blocks - * (i.e. maximize fraction of white area score considering problem with copied linking variables - * and corresponding master constraints; - * white area is nonblock and nonborder area, stairlinking variables count as linking) - * @return scip return code - */ -extern -SCIP_RETCODE GCGconshdlrDecompCalcMaxForeseeingWhiteAggScore( - SCIP* scip, /**< SCIP data structure */ - int partialdecid, /**< id of partialdec the score is calculated for */ - SCIP_Real* score /**< score pointer to store the calculated score */ - ); - -/** - * @brief calculates the maximum foreseeing white area score of a partialdec - * - * maximum foreseeing white area score - * (i.e. maximize fraction of white area score considering problem with copied linking variables and - * corresponding master constraints; white area is nonblock and nonborder area, stairlinking variables count as linking) - * @return scip return code - */ -extern -SCIP_RETCODE GCGconshdlrDecompCalcMaxForseeingWhiteScore( - SCIP* scip, /**< SCIP data structure */ - int partialdecid, /**< id of partialdec the score is calculated for */ - SCIP_Real* score /**< score pointer to store the calculated score */ - ); - -/** - * @brief calculates the maximum white area score of a partialdec - * - * score corresponding to the max white measure according to aggregated blocks - * @return scip return code - */ -extern -SCIP_RETCODE GCGconshdlrDecompCalcMaxWhiteScore( - SCIP* scip, /**< SCIP data structure */ - int partialdecid, /**< id of partialdec the score is calculated for */ - SCIP_Real* score /**< score pointer to store the calculated score */ - ); - -/** - * @brief calculates the setpartitioning maximum foreseeing white area score of a partialdec - * - * setpartitioning maximum foreseeing white area score - * (i.e. convex combination of maximum foreseeing white area score and - * a boolean score rewarding a master containing only setppc and cardinality constraints) - * @return scip return code - */ -extern -SCIP_RETCODE GCGconshdlrDecompCalcSetPartForseeingWhiteScore( - SCIP* scip, /**< SCIP data structure */ - int partialdecid, /**< id of partialdec the score is calculated for */ - SCIP_Real* score /**< score pointer to store the calculated score */ - ); - -/** - * @brief calculates the setpartfwhiteagg score of a partialdec - * - * setpartitioning maximum foreseeing white area score with respect to aggregateable - * (i.e. convex combination of maximum foreseeing white area score and a boolean score - * rewarding a master containing only setppc and cardinality constraints) - * @return scip return code - */ -extern -SCIP_RETCODE GCGconshdlrDecompCalcSetPartForWhiteAggScore( - SCIP* scip, /**< SCIP data structure */ - int partialdecid, /**< id of partialdec the score is calculated for */ - SCIP_Real* score /**< score pointer to store the calculated score */ - ); - -/** - * @brief calculates the strong decomposition score of a partialdec - * @return scip return code - */ -extern -SCIP_RETCODE GCGconshdlrDecompCalcStrongDecompositionScore( - SCIP* scip, /**< SCIP data structure */ - int partialdecid, /**< id of partialdec the score is calculated for */ - SCIP_Real* score /**< score pointer to store the calculated score */ - ); - -/** - * @brief check whether partialdecs are consistent - * - * Checks whether - * 1) the predecessors of all finished partialdecs in both detprobdatas can be found - * 2) selected list is synchron with selected information in partialdecs - * 3) selected exists is synchronized with selected list - * - * @returns true if partialdec information is consistent */ - extern -SCIP_Bool GCGconshdlrDecompCheckConsistency( - SCIP* scip /**< SCIP data structure **/ - ); - -/** - * @brief run classification of vars and cons - * - * @returns scip return code - */ -extern -SCIP_RETCODE GCGconshdlrDecompClassify( - SCIP* scip, /**< SCIP data structure */ - SCIP_Bool transformed /**< whether to classify the transformed problem, otherwise the original */ -); - -/** - * @brief for two identical pricing problems a corresponding varmap is created - * @param scip scip data structure - * @param hashorig2pricingvar mapping from orig to pricingvar - * @param partialdecid id of the partial decompostion for which the pricing problems are checked for identity - * @param probnr1 index of first block - * @param probnr2 index of second block - * @param scip1 subscip of first block - * @param scip2 subscip of second block - * @param varmap mapping from orig to pricingvar - * @returns scip return code - */ -extern -SCIP_RETCODE GCGconshdlrDecompCreateVarmapForPartialdecId( - SCIP* scip, - SCIP_HASHMAP** hashorig2pricingvar, - int partialdecid, - int probnr1, - int probnr2, - SCIP* scip1, - SCIP* scip2, - SCIP_HASHMAP* varmap - ); - -/** - * @brief decreases the counter for created decompositions and returns it - * @returns number of created decompositions that was recently decreased - */ -extern -int GCGconshdlrDecompDecreaseNCallsCreateDecomp( - SCIP* scip /**< SCIP data structure **/ - ); - -/** @brief deregisters partialdecs in the conshdlr - * - * Use this function for deletion of ALL the partialdecs. - */ -extern -void GCGconshdlrDecompDeregisterPartialdecs( - SCIP* scip, /**< SCIP data structure */ - SCIP_Bool original /**< iff TRUE the status with respect to the original problem is returned */ - ); - -/** @brief Frees Detprobdata of the original and transformed/presolved problem. - * - * @note Does not free Detprobdata of the original problem if GCGconshdlrDecompFreeOrigOnExit is set to false. - */ -void GCGconshdlrDecompFreeDetprobdata( - SCIP* scip /**< SCIP data structure */ - ); - -/** - * @brief sets freeing of detection data of original problem during exit to true - * - * used before calling SCIPfreeTransform(), - * set to true to revoke presolving - * (e.g. if unpresolved decomposition is used, and transformation is not successful) - */ -extern -void GCGconshdlrDecompFreeOrigOnExit( - SCIP* scip, /**< SCIP data structure */ - SCIP_Bool free /**< whether to free orig data */ - ); - -/** - * @brief returns block number user candidate with given index - * @param scip SCIP data structure - * @param index index of block number user candidate that should be returned - * @returns block number user candidate with given index - */ -extern - int GCGconshdlrDecompGetBlockNumberCandidate( - SCIP* scip, - int index - ); - -/** - * @brief returns the total detection time - * @param scip SCIP data structure - * @returns total detection time - */ -extern -SCIP_Real GCGconshdlrDecompGetCompleteDetectionTime( - SCIP* scip - ); - -/** @brief returns an array containing all decompositions - * - * Updates the decomp decomposition structure by converting all finished partialdecs into decompositions and replacing the - * old list in the conshdlr. - * - * @returns decomposition array - * */ -extern -DEC_DECOMP** GCGconshdlrDecompGetDecomps( - SCIP* scip /**< SCIP data structure */ - ); - -/** @brief Gets an array of all detectors - * - * @returns array of detectors */ -extern -DEC_DETECTOR** GCGconshdlrDecompGetDetectors( - SCIP* scip /**< SCIP data structure */ - ); - -/** @brief Gets a list of ids of the current partialdecs that are finished - * - * @note recommendation: when in doubt plan for as many ids as partialdecs - * @see GCGconshdlrDecompGetNPartialdecs - * @returns scip return code */ -extern -SCIP_RETCODE GCGconshdlrDecompGetFinishedPartialdecsList( - SCIP* scip, /**< SCIP data structure */ - int** idlist, /**< id list to output to */ - int* listlength /**< length of output list */ - ); - -/** @brief Gets a list of ids of the current partialdecs - * - * @note recommendation: when in doubt plan for as many ids as partialdecs - * @see GCGconshdlrDecompGetNPartialdecs - * @returns scip return code */ -extern -SCIP_RETCODE GCGconshdlrDecompGetPartialdecsList( - SCIP* scip, /**< SCIP data structure */ - int** idlist, /**< id list to output to */ - int* listlength /**< length of output list */ -); - -/** - * @brief returns the number of block candidates given by the user - * @returns number of block candidates given by the user - */ -extern - int GCGconshdlrDecompGetNBlockNumberCandidates( - SCIP* scip /**< SCIP data structure */ - ); - -/** @brief gets block number of partialdec with given id - * @returns block number of partialdec - */ -extern -int GCGconshdlrDecompGetNBlocksByPartialdecId( - SCIP* scip, /**< SCIP data structure */ - int id /**< id of partialdec */ - ); - -/** @brief gets the number of decompositions (= amount of finished partialdecs) - * - * @returns number of decompositions */ -extern -int GCGconshdlrDecompGetNDecomps( - SCIP* scip /**< SCIP data structure */ - ); - -/** @brief Gets the number of all detectors - * @returns number of detectors */ -extern -int GCGconshdlrDecompGetNDetectors( - SCIP* scip /**< SCIP data structure */ - ); - -/** @brief Gets the next partialdec id managed by cons_decomp - * @returns the next partialdec id managed by cons_decomp */ -extern -int GCGconshdlrDecompGetNextPartialdecID( - SCIP* scip /**< SCIP data structure **/ - ); - -/** @brief gets number of active constraints during the detection of the decomp with given id - * - * Gets the number of constraints that were active while detecting the decomposition originating from the partialdec with the - * given id, this method is used to decide if the problem has changed since detection, if so the aggregation information - * needs to be recalculated - * - * @note if the partialdec is not complete the function returns -1 - * - * @returns number of constraints that were active while detecting the decomposition - */ -extern -int GCGconshdlrDecompGetNFormerDetectionConssForID( - SCIP* scip, /**< SCIP data structure */ - int id /**< id of the partialdec the information is asked for */ - ); - -/** @brief gets number of linking variables of partialdec with given id - * @returns number of linking variables of partialdec - */ -extern -int GCGconshdlrDecompGetNLinkingVarsByPartialdecId( - SCIP* scip, /**< SCIP data structure */ - int id /**< id of partialdec */ - ); - -/** @brief gets number of master constraints of partialdec with given id - * @returns number of master constraints of partialdec - */ -extern -int GCGconshdlrDecompGetNMasterConssByPartialdecId( - SCIP* scip, /**< SCIP data structure */ - int id /**< id of partialdec */ - ); - -/** @brief gets number of master variables of partialdec with given id - * @returns number of master variables of partialdec - */ -extern -int GCGconshdlrDecompGetNMasterVarsByPartialdecId( - SCIP* scip, /**< SCIP data structure */ - int id /**< id of partialdec */ - ); - -/** @brief gets number of open constraints of partialdec with given id - * @returns total number of open constraints of partialdec - */ -extern -int GCGconshdlrDecompGetNOpenConssByPartialdecId( - SCIP* scip, /**< SCIP data structure */ - int id /**< id of partialdec */ - ); - -/** @brief gets number of open variables of partialdec with given id - * @returns total number of open variables of partialdec - */ -extern -int GCGconshdlrDecompGetNOpenVarsByPartialdecId( - SCIP* scip, /**< SCIP data structure */ - int id /**< id of partialdec */ - ); - -/** @brief Gets the number of finished partialdecs available for the original problem - * @returns number of partialdecs */ -extern -unsigned int GCGconshdlrDecompGetNFinishedPartialdecsOrig( - SCIP* scip /**< SCIP data structure */ - ); - -/** @brief Gets the number of finished partialdecs available for the transformed problem - * @returns number of partialdecs */ -extern -unsigned int GCGconshdlrDecompGetNFinishedPartialdecsTransformed( - SCIP* scip /**< SCIP data structure */ - ); - -/** @brief Gets the number of open partialdecs available for the original problem - * @returns number of partialdecs */ -extern -unsigned int GCGconshdlrDecompGetNOpenPartialdecsOrig( - SCIP* scip /**< SCIP data structure */ -); - -/** @brief Gets the number of open partialdecs available for the transformed problem - * @returns number of partialdecs */ -extern -unsigned int GCGconshdlrDecompGetNOpenPartialdecsTransformed( - SCIP* scip /**< SCIP data structure */ -); - -/** @brief Gets the number of all partialdecs - * @returns number of Partialdecs */ -extern -unsigned int GCGconshdlrDecompGetNPartialdecs( - SCIP* scip /**< SCIP data structure */ - ); - -/** @brief Gets the number of partialdecs available for the original problem - * @returns number of partialdecs */ -extern -unsigned int GCGconshdlrDecompGetNPartialdecsOrig( - SCIP* scip /**< SCIP data structure */ - ); - -/** @brief Gets the number of partialdecs available for the transformed problem - * @returns number of partialdecs */ -extern -unsigned int GCGconshdlrDecompGetNPartialdecsTransformed( - SCIP* scip /**< SCIP data structure */ - ); - -/** @brief gets number of stairlinking variables of partialdec with given id - * @returns total number of stairlinking variables of partialdec - */ -extern -int GCGconshdlrDecompGetNStairlinkingVarsByPartialdecId( - SCIP* scip, /**< SCIP data structure */ - int id /**< id of partialdec */ - ); - -/** @brief Gets wrapped PARTIALDECOMP with given id - * - * @returns SCIP return code */ -extern -SCIP_RETCODE GCGconshdlrDecompGetPartialdecFromID( - SCIP* scip, /**< SCIP data structure */ - int partialdecid, /**< id of PARTIALDECOMP */ - PARTIALDECOMP_WRAPPER* pwr /**< wrapper for output PARTIALDECOMP */ - ); - -/** @brief gets score of partialdec with given id - * @returns score in respect to current score type - */ -extern -float GCGconshdlrDecompGetScoreByPartialdecId( - SCIP* scip, /**< SCIP data structure */ - int id /**< id of partialdec */ - ); - -/** @brief gets total score computation time - * @returns total score computation time - */ -extern -SCIP_Real GCGconshdlrDecompGetScoreTotalTime( - SCIP* scip /**< SCIP data structure */ -); - -/** - * @brief Gets the currently selected scoretype - * @returns the currently selected scoretype - */ -extern -SCORETYPE GCGconshdlrDecompGetScoretype( - SCIP* scip /**< SCIP data structure */ - ); - -/** @brief Gets a list of ids of all currently selected partialdecs - * @returns list of partialdecs */ -extern -SCIP_RETCODE GCGconshdlrDecompGetSelectedPartialdecs( - SCIP* scip, /**< SCIP data structure */ - int** idlist, /**< id list to output to */ - int* listlength /**< length of output list */ - ); - -/** - * @brief counts up the counter for created decompositions and returns it - * @returns number of created decompositions that was recently increased - */ - extern -int GCGconshdlrDecompIncreaseNCallsCreateDecomp( - SCIP* scip /**< SCIP data structure **/ - ); - -/** @brief gets whether partialdec with given id is presolved - * @returns true iff partialdec is presolved - */ -extern -SCIP_Bool GCGconshdlrDecompIsPresolvedByPartialdecId( - SCIP* scip, /**< SCIP data structure */ - int id /**< id of partialdec */ - ); - -/** @brief gets whether partialdec with given id is selected - * @returns true iff partialdec is selected - */ -extern -SCIP_Bool GCGconshdlrDecompIsSelectedByPartialdecId( - SCIP* scip, /**< SCIP data structure */ - int id /**< id of partialdec */ - ); - -/** - * @brief returns whether or not a detprobdata structure for the original problem exists - * @returns true iff an original detprobdata exists - */ -extern -SCIP_Bool GCGconshdlrDecompOrigDetprobdataExists( - SCIP* scip /**< SCIP data structure */ - ); - -/** - * @brief returns whether or not an original decompositions exists in the data structures - * @returns true iff an origial decomposition exist - */ -extern -SCIP_Bool GCGconshdlrDecompOrigPartialdecExists( - SCIP* scip /**< SCIP data structure */ - ); - -/** - * @brief returns whether or not a detprobdata structure for the presolved problem exists - * @returns true iff a presolved detprobdata exists - */ -extern -SCIP_Bool GCGconshdlrDecompPresolvedDetprobdataExists( - SCIP* scip /**< SCIP data structure */ - ); - -/** @brief display statistics about detectors - * @returns SCIP return code */ -extern -SCIP_RETCODE GCGconshdlrDecompPrintDetectorStatistics( - SCIP* scip, /**< SCIP data structure */ - FILE* file /**< output file or NULL for standard output */ - ); - -/** - * @brief selects/unselects a partialdecomp - * - * @returns SCIP return code - */ -extern -SCIP_RETCODE GCGconshdlrDecompSelectPartialdec( - SCIP* scip, /**< SCIP data structure */ - int partialdecid, /**< id of partialdecomp */ - SCIP_Bool select /**< select/unselect */ - ); - -/** @brief sets detector parameters values - * - * sets detector parameters values to - * - * - SCIP_PARAMSETTING_DEFAULT which are the default values of all detector parameters - * - SCIP_PARAMSETTING_FAST such that the time spend for detection is decreased - * - SCIP_PARAMSETTING_AGGRESSIVE such that the detectors produce more decompositions - * - SCIP_PARAMSETTING_OFF which turns off all detection - * - * @returns SCIP return code - */ -extern -SCIP_RETCODE GCGconshdlrDecompSetDetection( - SCIP* scip, /**< SCIP data structure */ - SCIP_PARAMSETTING paramsetting, /**< parameter settings */ - SCIP_Bool quiet /**< should the parameter be set quiet (no output) */ - ); - -/** - * @brief Sets the currently used scoretype - */ -extern -void GCGconshdlrDecompSetScoretype( - SCIP* scip, /**< SCIP data structure */ - SCORETYPE sctype /**< new scoretype */ - ); - -/** - * @brief translates n best unpresolved partialdec to a complete presolved one - * @param scip SCIP data structure - * @param n number of partialdecs that should be translated - * @param completeGreedily whether or not to complete the decomposition greedily - * @returns SCIP return code - */ -extern -SCIP_RETCODE GCGconshdlrDecompTranslateNBestOrigPartialdecs( - SCIP* scip, - int n, - SCIP_Bool completeGreedily -); - -/** - * @brief translates unpresolved partialdec to a complete presolved one - * @param scip SCIP data structure - * @returns SCIP return code - */ - extern -SCIP_RETCODE GCGconshdlrDecompTranslateOrigPartialdecs( - SCIP* scip - ); - -/** Gets whether the detection already took place - * @returns true if detection took place, false otherwise */ -extern -SCIP_Bool GCGdetectionTookPlace( - SCIP* scip, /**< SCIP data structure */ - SCIP_Bool original /**< iff TRUE the status with respect to the original problem is returned */ - ); - -/** - * method to eliminate duplicate constraint names and name unnamed constraints - * @return SCIP return code - */ -extern -SCIP_RETCODE SCIPconshdlrDecompRepairConsNames( - SCIP* scip /**< SCIP data structure */ - ); - -/** - * @brief creates the constraint handler for decomp and includes it in SCIP - * @returns scip return code - */ -extern -SCIP_RETCODE SCIPincludeConshdlrDecomp( - SCIP* scip /**< SCIP data structure */ - ); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/headers/gcg/cons_decomp.hpp b/headers/gcg/cons_decomp.hpp deleted file mode 100644 index 8a0cf2d..0000000 --- a/headers/gcg/cons_decomp.hpp +++ /dev/null @@ -1,144 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* */ -/* This file is part of the program */ -/* GCG --- Generic Column Generation */ -/* a Dantzig-Wolfe decomposition based extension */ -/* of the branch-cut-and-price framework */ -/* SCIP --- Solving Constraint Integer Programs */ -/* */ -/* Copyright (C) 2010-2022 Operations Research, RWTH Aachen University */ -/* Zuse Institute Berlin (ZIB) */ -/* */ -/* This program is free software; you can redistribute it and/or */ -/* modify it under the terms of the GNU Lesser General Public License */ -/* as published by the Free Software Foundation; either version 3 */ -/* of the License, or (at your option) any later version. */ -/* */ -/* This program is distributed in the hope that it will be useful, */ -/* but WITHOUT ANY WARRANTY; without even the implied warranty of */ -/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ -/* GNU Lesser General Public License for more details. */ -/* */ -/* You should have received a copy of the GNU Lesser General Public License */ -/* along with this program; if not, write to the Free Software */ -/* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.*/ -/* */ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -/**@file cons_decomp.hpp - * @brief C++ interface of cons_decomp - * @author Erik Muehmer - */ - -/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/ - -#ifndef GCG_CONS_DECOMP_HPP -#define GCG_CONS_DECOMP_HPP - -#include "class_partialdecomp.h" - -/** @brief gets vector of all partialdecs - * @returns finished partialdecs - */ -extern -std::vector* GCGconshdlrDecompGetPartialdecs( - SCIP* scip /**< SCIP data structure */ -); - -extern -gcg::PARTIALDECOMP* DECgetPartialdecToWrite( - SCIP* scip, - SCIP_Bool transformed -); - -/** @brief local method to find a partialdec for a given id or NULL if no partialdec with such id is found - * @returns partialdec pointer of partialdec with given id or NULL if it does not exist - * @note returns NULL if no partialdec by this id is known */ -extern -gcg::PARTIALDECOMP* GCGconshdlrDecompGetPartialdecFromID( - SCIP* scip, /**< SCIP data structure */ - int partialdecid /**< partialdec id */ -); - -/** @brief adds a preexisting partial dec to be considered at the beginning of the detection - * - * @note refines the partialdec to be consistent, adds meta data/statistics - * @returns SCIP return code -*/ -extern -SCIP_RETCODE GCGconshdlrDecompAddPreexisitingPartialDec( - SCIP* scip, /**< SCIP data structure */ - gcg::PARTIALDECOMP* partialdec/**< partial dec to add */ -); - -/** @brief deregisters a partialdec in the conshdlr - * - * Use this function at deletion of the partialdec. - * The partialdec is not destroyed in this function, the conshdlr will not know that it exists. - */ -extern -void GCGconshdlrDecompDeregisterPartialdec( - SCIP* scip, /**< SCIP data structure */ - gcg::PARTIALDECOMP* partialdec /**< the partialdec */ -); - -/** @brief registers a partialdec in the conshdlr - * - * Use this function at initialization of the partialdec. - * If the partialdec already exists in the conshdlr it is ignored. - */ -extern -void GCGconshdlrDecompRegisterPartialdec( - SCIP* scip, /**< SCIP data structure */ - gcg::PARTIALDECOMP* partialdec /**< the partialdec to register */ -); - -/** - * @brief help method to access detprobdata for unpresolved problem - * - * @returns pointer to detprobdata in wrapper data structure - */ -extern -gcg::DETPROBDATA* GCGconshdlrDecompGetDetprobdataOrig( - SCIP* scip /**< SCIP data structure */ -); - -/** - * @brief help method to access detprobdata for transformed problem - * - * @returns pointer to detprobdata in wrapper data structure - */ -extern -gcg::DETPROBDATA* GCGconshdlrDecompGetDetprobdataPresolved( - SCIP* scip /**< SCIP data structure */ -); - -/** - * @brief initilizes the candidates data structures with selected partialdecs - * - * initializes it with all if there are no selected partialdecs, - * sort them according to the current scoretype - * @param scip SCIP data structure - * @param candidates tuples of partialdecs and scores will be added to this vector (sorted w.r.t. the scores). - * @param original choose candidates for the original problem? - * @param printwarnings should warnings be printed? - * @returns SCIP return code - */ -extern -SCIP_RETCODE GCGconshdlrDecompChooseCandidatesFromSelected( - SCIP* scip, - std::vector >& candidates, - SCIP_Bool original, - SCIP_Bool printwarnings - ); - -/** @brief gets detector history of partialdec with given id - * @returns detector history of partialdec as string - */ -extern -std::string GCGconshdlrDecompGetDetectorHistoryByPartialdecId( - SCIP* scip, /**< SCIP data structure */ - int id /**< id of partialdec */ - ); - -#endif //GCG_CONS_DECOMP_HPP diff --git a/headers/gcg/cons_integralorig.h b/headers/gcg/cons_integralorig.h deleted file mode 100644 index ae968d2..0000000 --- a/headers/gcg/cons_integralorig.h +++ /dev/null @@ -1,62 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* */ -/* This file is part of the program */ -/* GCG --- Generic Column Generation */ -/* a Dantzig-Wolfe decomposition based extension */ -/* of the branch-cut-and-price framework */ -/* SCIP --- Solving Constraint Integer Programs */ -/* */ -/* Copyright (C) 2010-2022 Operations Research, RWTH Aachen University */ -/* Zuse Institute Berlin (ZIB) */ -/* */ -/* This program is free software; you can redistribute it and/or */ -/* modify it under the terms of the GNU Lesser General Public License */ -/* as published by the Free Software Foundation; either version 3 */ -/* of the License, or (at your option) any later version. */ -/* */ -/* This program is distributed in the hope that it will be useful, */ -/* but WITHOUT ANY WARRANTY; without even the implied warranty of */ -/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ -/* GNU Lesser General Public License for more details. */ -/* */ -/* You should have received a copy of the GNU Lesser General Public License */ -/* along with this program; if not, write to the Free Software */ -/* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.*/ -/* */ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -/**@file cons_integralorig.h - * @brief constraint handler for the integrality constraint - * @author Gerald Gamrath - */ - -/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/ - -#ifndef GCG_CONS_INTEGRALORIG_H__ -#define GCG_CONS_INTEGRALORIG_H__ - - -#include "scip/scip.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/** creates the handler for the integrality constraint and includes it in SCIP */ -extern -SCIP_RETCODE SCIPincludeConshdlrIntegralOrig( - SCIP* scip /**< SCIP data structure */ - ); - -extern -/** insert branchrule in constraint handler data */ -SCIP_RETCODE GCGconsIntegralorigAddBranchrule( - SCIP* scip, - SCIP_BRANCHRULE* branchrule - ); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/headers/gcg/cons_masterbranch.h b/headers/gcg/cons_masterbranch.h deleted file mode 100644 index e41cbbd..0000000 --- a/headers/gcg/cons_masterbranch.h +++ /dev/null @@ -1,208 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* */ -/* This file is part of the program */ -/* GCG --- Generic Column Generation */ -/* a Dantzig-Wolfe decomposition based extension */ -/* of the branch-cut-and-price framework */ -/* SCIP --- Solving Constraint Integer Programs */ -/* */ -/* Copyright (C) 2010-2022 Operations Research, RWTH Aachen University */ -/* Zuse Institute Berlin (ZIB) */ -/* */ -/* This program is free software; you can redistribute it and/or */ -/* modify it under the terms of the GNU Lesser General Public License */ -/* as published by the Free Software Foundation; either version 3 */ -/* of the License, or (at your option) any later version. */ -/* */ -/* This program is distributed in the hope that it will be useful, */ -/* but WITHOUT ANY WARRANTY; without even the implied warranty of */ -/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ -/* GNU Lesser General Public License for more details. */ -/* */ -/* You should have received a copy of the GNU Lesser General Public License */ -/* along with this program; if not, write to the Free Software */ -/* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.*/ -/* */ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -/**@file cons_masterbranch.h - * @brief constraint handler for storing the branching decisions at each node of the tree - * @author Gerald Gamrath - * @author Martin Bergner - * @author Christian Puchert - * @author Marcel Schmickerath - */ - -#ifndef GCG_CONS_MASTERBRANCH_H__ -#define GCG_CONS_MASTERBRANCH_H__ - -#include "scip/scip.h" -#include "type_branchgcg.h" - -#ifdef __cplusplus -extern "C" { -#endif - - -/** creates the handler for masterbranch constraints and includes it in SCIP */ -extern -SCIP_RETCODE SCIPincludeConshdlrMasterbranch( - SCIP* scip /**< SCIP data structure */ - ); - -/** creates and captures a masterbranch constraint */ -extern -SCIP_RETCODE GCGcreateConsMasterbranch( - SCIP* scip, /**< SCIP data structure */ - SCIP_CONS** cons, /**< pointer to hold the created constraint */ - const char* name, /**< name of the constraint */ - SCIP_NODE* node, /**< node at which the constraint should be created */ - SCIP_CONS* parentcons, /**< parent constraint */ - SCIP_BRANCHRULE* branchrule, /**< pointer to the branching rule */ - GCG_BRANCHDATA* branchdata, /**< branching data */ - SCIP_CONS** origbranchconss, /**< original constraints enforcing the branching decision */ - int norigbranchconss, /**< number of original constraints */ - int maxorigbranchconss /**< capacity origbranchconss */ - ); - -/** returns the name of the constraint */ -extern -char* GCGconsMasterbranchGetName( - SCIP_CONS* cons /**< masterbranch constraint for which the data is requested */ - ); - -/** returns the node in the B&B tree at which the given masterbranch constraint is sticking */ -extern -SCIP_NODE* GCGconsMasterbranchGetNode( - SCIP_CONS* cons /**< constraint pointer */ - ); - -/** returns the masterbranch constraint of the B&B father of the node at which the - * given masterbranch constraint is sticking - */ -extern -SCIP_CONS* GCGconsMasterbranchGetParentcons( - SCIP_CONS* cons /**< constraint pointer */ - ); - -/** returns the number of masterbranch constraints of the children of the node at which the - * given masterbranch constraint is sticking - */ -extern -int GCGconsMasterbranchGetNChildconss( - SCIP_CONS* cons /**< constraint pointer */ - ); - -/** returns a masterbranch constraint of a child of the node at which the - * given masterbranch constraint is sticking - */ -extern -SCIP_CONS* GCGconsMasterbranchGetChildcons( - SCIP_CONS* cons, /**< constraint pointer */ - int childnr /**< index of the child node */ - ); - -/** returns the origbranch constraint of the node in the original program corresponding to the node - * which the given masterbranch constraint is sticking - */ -extern -SCIP_CONS* GCGconsMasterbranchGetOrigcons( - SCIP_CONS* cons /**< constraint pointer */ - ); - -/** sets the origbranch constraint of the node in the master program corresponding to the node - * at which the given masterbranchbranch constraint is sticking - */ -extern -void GCGconsMasterbranchSetOrigcons( - SCIP_CONS* cons, /**< constraint pointer */ - SCIP_CONS* origcons /**< original branching constraint */ - ); - -/** returns the branching data for a given masterbranch constraint */ -extern -GCG_BRANCHDATA* GCGconsMasterbranchGetBranchdata( - SCIP_CONS* cons /**< constraint pointer */ - ); - -/** returns the branching rule of the constraint */ -extern -SCIP_BRANCHRULE* GCGconsMasterbranchGetBranchrule( - SCIP_CONS* cons /**< masterbranch constraint for which the data is requested */ - ); - -/** adds a bound change on an original variable that was directly copied to the master problem */ -extern -SCIP_RETCODE GCGconsMasterbranchAddCopiedVarBndchg( - SCIP* scip, /**< SCIP data structure */ - SCIP_CONS* cons, /**< masterbranch constraint to which the bound change is added */ - SCIP_VAR* var, /**< variable on which the bound change was performed */ - GCG_BOUNDTYPE boundtype, /**< bound type of the bound change */ - SCIP_Real newbound /**< new bound of the variable after the bound change */ - ); - -/** returns the constraints in the original problem that enforce the branching decision */ -extern -SCIP_CONS** GCGconsMasterbranchGetOrigbranchConss( - SCIP_CONS* cons /**< masterbranch constraint for which the data is requested */ - ); - -/** returns the number of constraints in the original problem that enforce the branching decision */ -extern -int GCGconsMasterbranchGetNOrigbranchConss( - SCIP_CONS* cons /**< masterbranch constraint for which the data is requested */ - ); - -/** releases the constraints in the original problem that enforce the branching decision - * and frees the array holding the constraints - */ -extern -SCIP_RETCODE GCGconsMasterbranchReleaseOrigbranchConss( - SCIP* masterscip, /**< master problem SCIP instance */ - SCIP* origscip, /**< original SCIP instance */ - SCIP_CONS* cons /**< masterbranch constraint for which the data is freed */ - ); - -/** returns the masterbranch constraint of the current node */ -extern -SCIP_CONS* GCGconsMasterbranchGetActiveCons( - SCIP* scip /**< SCIP data structure */ - ); - -/** returns the stack and the number of elements on it */ -extern -void GCGconsMasterbranchGetStack( - SCIP* scip, /**< SCIP data structure */ - SCIP_CONS*** stack, /**< return value: pointer to the stack */ - int* nstackelements /**< return value: pointer to int, for number of elements on the stack */ - ); - -/** returns the number of elements on the stack */ -extern -int GCGconsMasterbranchGetNStackelements( - SCIP* scip /**< SCIP data structure */ - ); - -/** adds initial constraint to root node */ -extern -SCIP_RETCODE GCGconsMasterbranchAddRootCons( - SCIP* scip /**< SCIP data structure */ - ); - -/** check whether the node was generated by generic branching */ -extern -SCIP_Bool GCGcurrentNodeIsGeneric( - SCIP* scip /**< SCIP data structure */ - ); - -/** checks the consistency of the masterbranch constraints in the problem */ -extern -void GCGconsMasterbranchCheckConsistency( - SCIP* scip /**< SCIP data structure */ - ); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/headers/gcg/cons_origbranch.h b/headers/gcg/cons_origbranch.h deleted file mode 100644 index 8bf3aaa..0000000 --- a/headers/gcg/cons_origbranch.h +++ /dev/null @@ -1,164 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* */ -/* This file is part of the program */ -/* GCG --- Generic Column Generation */ -/* a Dantzig-Wolfe decomposition based extension */ -/* of the branch-cut-and-price framework */ -/* SCIP --- Solving Constraint Integer Programs */ -/* */ -/* Copyright (C) 2010-2022 Operations Research, RWTH Aachen University */ -/* Zuse Institute Berlin (ZIB) */ -/* */ -/* This program is free software; you can redistribute it and/or */ -/* modify it under the terms of the GNU Lesser General Public License */ -/* as published by the Free Software Foundation; either version 3 */ -/* of the License, or (at your option) any later version. */ -/* */ -/* This program is distributed in the hope that it will be useful, */ -/* but WITHOUT ANY WARRANTY; without even the implied warranty of */ -/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ -/* GNU Lesser General Public License for more details. */ -/* */ -/* You should have received a copy of the GNU Lesser General Public License */ -/* along with this program; if not, write to the Free Software */ -/* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.*/ -/* */ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -/**@file cons_origbranch.h - * @brief constraint handler for storing the branching decisions at each node of the tree - * @author Gerald Gamrath - */ - -/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/ - -#ifndef GCG_CONS_ORIGBRANCH_H__ -#define GCG_CONS_ORIGBRANCH_H__ - -#include "scip/scip.h" -#include "type_branchgcg.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/** creates the handler for origbranch constraints and includes it in SCIP */ -extern -SCIP_RETCODE SCIPincludeConshdlrOrigbranch( - SCIP* scip /**< SCIP data structure */ - ); - -/** creates and captures a origbranch constraint */ -extern -SCIP_RETCODE GCGcreateConsOrigbranch( - SCIP* scip, /**< SCIP data structure */ - SCIP_CONS** cons, /**< pointer to hold the created constraint */ - const char* name, /**< name of constraint */ - SCIP_NODE* node, /**< the node to which this origbranch constraint belongs */ - SCIP_CONS* parentcons, /**< origbranch constraint associated with the father node */ - SCIP_BRANCHRULE* branchrule, /**< the branching rule that created the b&b node the constraint belongs to */ - GCG_BRANCHDATA* branchdata /**< branching data storing information about the branching restrictions at the - * corresponding node */ - ); - -/** returns the branch orig constraint of the current node, only needs the pointer to scip */ -extern -SCIP_CONS* GCGconsOrigbranchGetActiveCons( - SCIP* scip /**< SCIP data structure */ - ); - -/** returns the stack and the number of elements on it */ -extern -void GCGconsOrigbranchGetStack( - SCIP* scip, /**< SCIP data structure */ - SCIP_CONS*** stack, /**< return value: pointer to the stack */ - int* nstackelements /**< return value: pointer to int, for number of elements on the stack */ - ); - -/** set the branching data for a given origbranch constraint */ -extern -void GCGconsOrigbranchSetBranchdata( - SCIP_CONS* cons, /**< origbranch constraint for which the branching data is requested */ - GCG_BRANCHDATA* branchdata /**< branching data */ - ); - -/** returns the branching data for a given origbranch constraint */ -extern -GCG_BRANCHDATA* GCGconsOrigbranchGetBranchdata( - SCIP_CONS* cons /**< origbranch constraint for which the branching data is requested */ - ); - -/** returns the branching rule for a given origbranch constraint */ -extern -SCIP_BRANCHRULE* GCGconsOrigbranchGetBranchrule( - SCIP_CONS* cons /**< origbranch constraint for which the branchrule is requested */ - ); - -/** returns the node in the B&B tree at which the given origbranch constraint is sticking */ -extern -SCIP_NODE* GCGconsOrigbranchGetNode( - SCIP_CONS* cons /**< origbranch constraint for which the corresponding node is requested */ - ); - -/** returns the origbranch constraint of the B&B father of the node at which the - * given origbranch constraint is sticking - */ -extern -SCIP_CONS* GCGconsOrigbranchGetParentcons( - SCIP_CONS* cons /**< origbranch constraint for which the origbranch constraint of - * the father node is requested */ - ); - -/** returns the number of origbranch constraints of the children of the node at which the - * given origbranch constraint is sticking - */ -extern -int GCGconsOrigbranchGetNChildconss( - SCIP_CONS* cons /**< constraint pointer */ - ); - -/** returns an origbranch constraint of a child of the node at which the - * given origbranch constraint is sticking - */ -extern -SCIP_CONS* GCGconsOrigbranchGetChildcons( - SCIP_CONS* cons, /**< constraint */ - int childnr /**< number of child */ - ); - - -/** sets the masterbranch constraint of the node in the master program corresponding to the node - * at which the given origbranchbranch constraint is sticking - */ -extern -void GCGconsOrigbranchSetMastercons( - SCIP_CONS* cons, /**< origbranch constraint for which the masterbranch constraint should be set */ - SCIP_CONS* mastercons /**< masterbranch constraint corresponding to the given origbranch constraint */ - ); - -/** returns the masterbranch constraint of the node in the master program corresponding to the node - * at which the given origbranchbranch constraint is sticking - */ -extern -SCIP_CONS* GCGconsOrigbranchGetMastercons( - SCIP_CONS* cons /**< origbranch constraint for which the corresponding masterbranch - * constraint is requested */ - ); - -/** adds initial constraint to root node */ -extern -SCIP_RETCODE GCGconsOrigbranchAddRootCons( - SCIP* scip /**< SCIP data structure */ - ); - -/** checks the consistency of the origbranch constraints in the problem */ -extern -void GCGconsOrigbranchCheckConsistency( - SCIP* scip /**< SCIP data structure */ - ); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/headers/gcg/dec_compgreedily.h b/headers/gcg/dec_compgreedily.h deleted file mode 100644 index 1f3c1fd..0000000 --- a/headers/gcg/dec_compgreedily.h +++ /dev/null @@ -1,54 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* */ -/* This file is part of the program */ -/* GCG --- Generic Column Generation */ -/* a Dantzig-Wolfe decomposition based extension */ -/* of the branch-cut-and-price framework */ -/* SCIP --- Solving Constraint Integer Programs */ -/* */ -/* Copyright (C) 2010-2022 Operations Research, RWTH Aachen University */ -/* Zuse Institute Berlin (ZIB) */ -/* */ -/* This program is free software; you can redistribute it and/or */ -/* modify it under the terms of the GNU Lesser General Public License */ -/* as published by the Free Software Foundation; either version 3 */ -/* of the License, or (at your option) any later version. */ -/* */ -/* This program is distributed in the hope that it will be useful, */ -/* but WITHOUT ANY WARRANTY; without even the implied warranty of */ -/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ -/* GNU Lesser General Public License for more details. */ -/* */ -/* You should have received a copy of the GNU Lesser General Public License */ -/* along with this program; if not, write to the Free Software */ -/* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.*/ -/* */ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -/**@file dec_compgreedily.h - * @brief compgreedily detector - * @author Martin Bergner - */ - -/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/ - -#ifndef GCG_DEC_COMPGREEDILY_H__ -#define GCG_DEC_COMPGREEDILY_H__ - -#include "scip/scip.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/** creates the handler for compgreedily detector and includes it in SCIP */ -extern -SCIP_RETCODE SCIPincludeDetectorCompgreedily( - SCIP* scip /**< SCIP data structure */ - ); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/headers/gcg/dec_connected_noNewLinkingVars.h b/headers/gcg/dec_connected_noNewLinkingVars.h deleted file mode 100644 index 52ab398..0000000 --- a/headers/gcg/dec_connected_noNewLinkingVars.h +++ /dev/null @@ -1,54 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* */ -/* This file is part of the program */ -/* GCG --- Generic Column Generation */ -/* a Dantzig-Wolfe decomposition based extension */ -/* of the branch-cut-and-price framework */ -/* SCIP --- Solving Constraint Integer Programs */ -/* */ -/* Copyright (C) 2010-2022 Operations Research, RWTH Aachen University */ -/* Zuse Institute Berlin (ZIB) */ -/* */ -/* This program is free software; you can redistribute it and/or */ -/* modify it under the terms of the GNU Lesser General Public License */ -/* as published by the Free Software Foundation; either version 3 */ -/* of the License, or (at your option) any later version. */ -/* */ -/* This program is distributed in the hope that it will be useful, */ -/* but WITHOUT ANY WARRANTY; without even the implied warranty of */ -/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ -/* GNU Lesser General Public License for more details. */ -/* */ -/* You should have received a copy of the GNU Lesser General Public License */ -/* along with this program; if not, write to the Free Software */ -/* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.*/ -/* */ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -/**@file dec_connected_noNewLinkingVars.h - * @brief connected_noNewLinkingVars detector - * @author Martin Bergner - */ - -/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/ - -#ifndef GCG_DEC_CONNECTED_NONEWLINKINGVARS_H__ -#define GCG_DEC_CONNECTED_NONEWLINKINGVARS_H__ - -#include "scip/scip.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/** creates the handler for connected_noNewLinkingVars detector and includes it in SCIP */ -extern -SCIP_RETCODE SCIPincludeDetectorConnected_noNewLinkingVars( - SCIP* scip /**< SCIP data structure */ - ); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/headers/gcg/dec_connectedbase.h b/headers/gcg/dec_connectedbase.h deleted file mode 100644 index 4b0572c..0000000 --- a/headers/gcg/dec_connectedbase.h +++ /dev/null @@ -1,55 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* */ -/* This file is part of the program */ -/* GCG --- Generic Column Generation */ -/* a Dantzig-Wolfe decomposition based extension */ -/* of the branch-cut-and-price framework */ -/* SCIP --- Solving Constraint Integer Programs */ -/* */ -/* Copyright (C) 2010-2022 Operations Research, RWTH Aachen University */ -/* Zuse Institute Berlin (ZIB) */ -/* */ -/* This program is free software; you can redistribute it and/or */ -/* modify it under the terms of the GNU Lesser General Public License */ -/* as published by the Free Software Foundation; either version 3 */ -/* of the License, or (at your option) any later version. */ -/* */ -/* This program is distributed in the hope that it will be useful, */ -/* but WITHOUT ANY WARRANTY; without even the implied warranty of */ -/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ -/* GNU Lesser General Public License for more details. */ -/* */ -/* You should have received a copy of the GNU Lesser General Public License */ -/* along with this program; if not, write to the Free Software */ -/* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.*/ -/* */ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -/**@file dec_connectedbase.h - * @brief connectedbase detector - * @author Martin Bergner - * @author Michael Bastubbe - */ - -/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/ - -#ifndef GCG_DEC_CONNECTEDBASE_H__ -#define GCG_DEC_CONNECTEDBASE_H__ - -#include "scip/scip.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/** creates the handler for connectedbase detector and includes it in SCIP */ -extern -SCIP_RETCODE SCIPincludeDetectorConnectedbase( - SCIP* scip /**< SCIP data structure */ - ); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/headers/gcg/dec_consclass.h b/headers/gcg/dec_consclass.h deleted file mode 100644 index 114eaf7..0000000 --- a/headers/gcg/dec_consclass.h +++ /dev/null @@ -1,53 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* */ -/* This file is part of the program */ -/* GCG --- Generic Column Generation */ -/* a Dantzig-Wolfe decomposition based extension */ -/* of the branch-cut-and-price framework */ -/* SCIP --- Solving Constraint Integer Programs */ -/* */ -/* Copyright (C) 2010-2022 Operations Research, RWTH Aachen University */ -/* Zuse Institute Berlin (ZIB) */ -/* */ -/* This program is free software; you can redistribute it and/or */ -/* modify it under the terms of the GNU Lesser General Public License */ -/* as published by the Free Software Foundation; either version 3 */ -/* of the License, or (at your option) any later version. */ -/* */ -/* This program is distributed in the hope that it will be useful, */ -/* but WITHOUT ANY WARRANTY; without even the implied warranty of */ -/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ -/* GNU Lesser General Public License for more details. */ -/* */ -/* You should have received a copy of the GNU Lesser General Public License */ -/* along with this program; if not, write to the Free Software */ -/* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.*/ -/* */ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -/**@file dec_consclass.h - * @brief consclass detector - * @author Michael Bastubbe - */ - -/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/ - -#ifndef DEC_CONSCLASS_H_ -#define DEC_CONSCLASS_H_ - -#include "scip/scip.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/** creates the handler for consclass detector and includes it in SCIP */ -extern -SCIP_RETCODE SCIPincludeDetectorConsclass( - SCIP* scip /**< SCIP data structure */ - ); - -#ifdef __cplusplus -} -#endif -#endif /* DEC_CONSCLASS_H_ */ diff --git a/headers/gcg/dec_constype.h b/headers/gcg/dec_constype.h deleted file mode 100644 index b28e799..0000000 --- a/headers/gcg/dec_constype.h +++ /dev/null @@ -1,53 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* */ -/* This file is part of the program */ -/* GCG --- Generic Column Generation */ -/* a Dantzig-Wolfe decomposition based extension */ -/* of the branch-cut-and-price framework */ -/* SCIP --- Solving Constraint Integer Programs */ -/* */ -/* Copyright (C) 2010-2022 Operations Research, RWTH Aachen University */ -/* Zuse Institute Berlin (ZIB) */ -/* */ -/* This program is free software; you can redistribute it and/or */ -/* modify it under the terms of the GNU Lesser General Public License */ -/* as published by the Free Software Foundation; either version 3 */ -/* of the License, or (at your option) any later version. */ -/* */ -/* This program is distributed in the hope that it will be useful, */ -/* but WITHOUT ANY WARRANTY; without even the implied warranty of */ -/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ -/* GNU Lesser General Public License for more details. */ -/* */ -/* You should have received a copy of the GNU Lesser General Public License */ -/* along with this program; if not, write to the Free Software */ -/* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.*/ -/* */ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -/**@file dec_constype.h - * @brief constype detector - * @author Michael Bastubbe - */ - -/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/ - -#ifndef DEC_CONSTYPE_H_ -#define DEC_CONSTYPE_H_ - -#include "scip/scip.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/** creates the handler for constype detector and includes it in SCIP */ -extern -SCIP_RETCODE SCIPincludeDetectorConstype( - SCIP* scip /**< SCIP data structure */ - ); - -#ifdef __cplusplus -} -#endif -#endif /* DEC_MASTERSETPACK_H_ */ diff --git a/headers/gcg/dec_dbscan.h b/headers/gcg/dec_dbscan.h deleted file mode 100644 index 6c5ca79..0000000 --- a/headers/gcg/dec_dbscan.h +++ /dev/null @@ -1,56 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* */ -/* This file is part of the program */ -/* GCG --- Generic Column Generation */ -/* a Dantzig-Wolfe decomposition based extension */ -/* of the branch-cut-and-price framework */ -/* SCIP --- Solving Constraint Integer Programs */ -/* */ -/* Copyright (C) 2010-2022 Operations Research, RWTH Aachen University */ -/* Zuse Institute Berlin (ZIB) */ -/* */ -/* This program is free software; you can redistribute it and/or */ -/* modify it under the terms of the GNU Lesser General Public License */ -/* as published by the Free Software Foundation; either version 3 */ -/* of the License, or (at your option) any later version. */ -/* */ -/* This program is distributed in the hope that it will be useful, */ -/* but WITHOUT ANY WARRANTY; without even the implied warranty of */ -/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ -/* GNU Lesser General Public License for more details. */ -/* */ -/* You should have received a copy of the GNU Lesser General Public License */ -/* along with this program; if not, write to the Free Software */ -/* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.*/ -/* */ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -/**@file dec_dbscan.h - * @brief detector for diagonal (bordered) structures via DBSCAN clustering algorithm - * @author Igor Pesic - */ - -/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/ - -#ifndef GCG_DEC_DBSCAN_H__ -#define GCG_DEC_DBSCAN_H__ - - -#include "scip/scip.h" - -#ifdef __cplusplus -extern "C" { -#endif - - -extern -/** creates the DBSCAN presolver and includes it in SCIP */ -SCIP_RETCODE SCIPincludeDetectorDBSCAN( - SCIP* scip /**< SCIP data structure */ - ); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/headers/gcg/dec_densemasterconss.h b/headers/gcg/dec_densemasterconss.h deleted file mode 100644 index 47a573a..0000000 --- a/headers/gcg/dec_densemasterconss.h +++ /dev/null @@ -1,53 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* */ -/* This file is part of the program */ -/* GCG --- Generic Column Generation */ -/* a Dantzig-Wolfe decomposition based extension */ -/* of the branch-cut-and-price framework */ -/* SCIP --- Solving Constraint Integer Programs */ -/* */ -/* Copyright (C) 2010-2022 Operations Research, RWTH Aachen University */ -/* Zuse Institute Berlin (ZIB) */ -/* */ -/* This program is free software; you can redistribute it and/or */ -/* modify it under the terms of the GNU Lesser General Public License */ -/* as published by the Free Software Foundation; either version 3 */ -/* of the License, or (at your option) any later version. */ -/* */ -/* This program is distributed in the hope that it will be useful, */ -/* but WITHOUT ANY WARRANTY; without even the implied warranty of */ -/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ -/* GNU Lesser General Public License for more details. */ -/* */ -/* You should have received a copy of the GNU Lesser General Public License */ -/* along with this program; if not, write to the Free Software */ -/* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.*/ -/* */ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -/**@file dec_densemasterconss.h - * @brief densemasterconss detector - * @author Michael Bastubbe - */ - -/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/ - -#ifndef DEC_DENSEMASTERCONSS_H_ -#define DEC_DENSEMASTERCONSS_H_ - -#include "scip/scip.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/** creates the handler for densemasterconss detector and includes it in SCIP */ -extern -SCIP_RETCODE SCIPincludeDetectorDensemasterconss( - SCIP* scip /**< SCIP data structure */ - ); - -#ifdef __cplusplus -} -#endif -#endif /* DEC_DENSEMASTERCONSS_H_ */ diff --git a/headers/gcg/dec_generalmastersetcover.h b/headers/gcg/dec_generalmastersetcover.h deleted file mode 100644 index 196b84d..0000000 --- a/headers/gcg/dec_generalmastersetcover.h +++ /dev/null @@ -1,66 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* */ -/* This file is part of the program */ -/* GCG --- Generic Column Generation */ -/* a Dantzig-Wolfe decomposition based extension */ -/* of the branch-cut-and-price framework */ -/* SCIP --- Solving Constraint Integer Programs */ -/* */ -/* Copyright (C) 2010-2022 Operations Research, RWTH Aachen University */ -/* Zuse Institute Berlin (ZIB) */ -/* */ -/* This program is free software; you can redistribute it and/or */ -/* modify it under the terms of the GNU Lesser General Public License */ -/* as published by the Free Software Foundation; either version 3 */ -/* of the License, or (at your option) any later version. */ -/* */ -/* This program is distributed in the hope that it will be useful, */ -/* but WITHOUT ANY WARRANTY; without even the implied warranty of */ -/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ -/* GNU Lesser General Public License for more details. */ -/* */ -/* You should have received a copy of the GNU Lesser General Public License */ -/* along with this program; if not, write to the Free Software */ -/* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.*/ -/* */ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -/**@file dec_generalmastersetcover.h - * @brief generalmastersetcover detector - * @author Martin Bergner - */ - -/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/ - -#ifndef DEC_GENERALMASTERSETCOVER_H_ -#define DEC_GENERALMASTERSETCOVER_H_ - -#include "scip/scip.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/** creates the handler for generalmastersetcover detector and includes it in SCIP */ -extern -SCIP_RETCODE SCIPincludeDetectorGeneralmastersetcover( - SCIP* scip /**< SCIP data structure */ - ); - -#ifdef __cplusplus -} -#endif - - - -#endif /* DEC_GENERALMASTERSETCOVER_H_ */ - - - - - - - - - - diff --git a/headers/gcg/dec_generalmastersetpack.h b/headers/gcg/dec_generalmastersetpack.h deleted file mode 100644 index 655b054..0000000 --- a/headers/gcg/dec_generalmastersetpack.h +++ /dev/null @@ -1,65 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* */ -/* This file is part of the program */ -/* GCG --- Generic Column Generation */ -/* a Dantzig-Wolfe decomposition based extension */ -/* of the branch-cut-and-price framework */ -/* SCIP --- Solving Constraint Integer Programs */ -/* */ -/* Copyright (C) 2010-2022 Operations Research, RWTH Aachen University */ -/* Zuse Institute Berlin (ZIB) */ -/* */ -/* This program is free software; you can redistribute it and/or */ -/* modify it under the terms of the GNU Lesser General Public License */ -/* as published by the Free Software Foundation; either version 3 */ -/* of the License, or (at your option) any later version. */ -/* */ -/* This program is distributed in the hope that it will be useful, */ -/* but WITHOUT ANY WARRANTY; without even the implied warranty of */ -/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ -/* GNU Lesser General Public License for more details. */ -/* */ -/* You should have received a copy of the GNU Lesser General Public License */ -/* along with this program; if not, write to the Free Software */ -/* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.*/ -/* */ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -/**@file dec_generalmastersetpack.h - * @brief generalmastersetpack detector - * @author Martin Bergner - */ - -/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/ - -#ifndef DEC_GENERALMASTERSETPACK_H_ -#define DEC_GENERALMASTERSETPACK_H_ - -#include "scip/scip.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/** creates the handler for generalmastersetpack detector and includes it in SCIP */ -extern -SCIP_RETCODE SCIPincludeDetectorGeneralmastersetpack( - SCIP* scip /**< SCIP data structure */ - ); - -#ifdef __cplusplus -} -#endif - - - -#endif /* DEC_GENERALMASTERSETPACK_H_ */ - - - - - - - - - diff --git a/headers/gcg/dec_generalmastersetpart.h b/headers/gcg/dec_generalmastersetpart.h deleted file mode 100644 index 7ee3da7..0000000 --- a/headers/gcg/dec_generalmastersetpart.h +++ /dev/null @@ -1,57 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* */ -/* This file is part of the program */ -/* GCG --- Generic Column Generation */ -/* a Dantzig-Wolfe decomposition based extension */ -/* of the branch-cut-and-price framework */ -/* SCIP --- Solving Constraint Integer Programs */ -/* */ -/* Copyright (C) 2010-2022 Operations Research, RWTH Aachen University */ -/* Zuse Institute Berlin (ZIB) */ -/* */ -/* This program is free software; you can redistribute it and/or */ -/* modify it under the terms of the GNU Lesser General Public License */ -/* as published by the Free Software Foundation; either version 3 */ -/* of the License, or (at your option) any later version. */ -/* */ -/* This program is distributed in the hope that it will be useful, */ -/* but WITHOUT ANY WARRANTY; without even the implied warranty of */ -/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ -/* GNU Lesser General Public License for more details. */ -/* */ -/* You should have received a copy of the GNU Lesser General Public License */ -/* along with this program; if not, write to the Free Software */ -/* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.*/ -/* */ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -/**@file dec_generalmastersetpart.h - * @brief generalmastersetpart detector - * @author Martin Bergner - */ - -/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/ - -#ifndef DEC_GENERALMASTERSETPART_H_ -#define DEC_GENERALMASTERSETPART_H_ - -#include "scip/scip.h" - - -#ifdef __cplusplus -extern "C" { -#endif - -/** creates the handler for generalmastersetpart detector and includes it in SCIP */ -extern -SCIP_RETCODE SCIPincludeDetectorGeneralmastersetpart( - SCIP* scip /**< SCIP data structure */ - ); - -#ifdef __cplusplus -} -#endif - - - -#endif /* DEC_GENERALMASTERSETPART_H_ */ diff --git a/headers/gcg/dec_hcgpartition.h b/headers/gcg/dec_hcgpartition.h deleted file mode 100644 index 677c3f4..0000000 --- a/headers/gcg/dec_hcgpartition.h +++ /dev/null @@ -1,57 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* */ -/* This file is part of the program */ -/* GCG --- Generic Column Generation */ -/* a Dantzig-Wolfe decomposition based extension */ -/* of the branch-cut-and-price framework */ -/* SCIP --- Solving Constraint Integer Programs */ -/* */ -/* Copyright (C) 2010-2022 Operations Research, RWTH Aachen University */ -/* Zuse Institute Berlin (ZIB) */ -/* */ -/* This program is free software; you can redistribute it and/or */ -/* modify it under the terms of the GNU Lesser General Public License */ -/* as published by the Free Software Foundation; either version 3 */ -/* of the License, or (at your option) any later version. */ -/* */ -/* This program is distributed in the hope that it will be useful, */ -/* but WITHOUT ANY WARRANTY; without even the implied warranty of */ -/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ -/* GNU Lesser General Public License for more details. */ -/* */ -/* You should have received a copy of the GNU Lesser General Public License */ -/* along with this program; if not, write to the Free Software */ -/* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.*/ -/* */ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -/**@file dec_hcgpartition.h - * @brief arrowhead and bordered detector via graph partitioning (uses hmetis) - * @author Martin Bergner - */ - -/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/ - -#ifndef GCG_DEC_HCGPARTITION_H__ -#define GCG_DEC_HCGPARTITION_H__ - -#include "scip/scip.h" -#include "type_decomp.h" - -#ifdef __cplusplus -extern "C" { -#endif - - -/** creates the arrowheur detector and includes it in SCIP */ -/** creates the hcgpartition presolver and includes it in SCIP */ -extern -SCIP_RETCODE SCIPincludeDetectorHcgpartition( - SCIP* scip /**< SCIP data structure */ - ); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/headers/gcg/dec_hrcgpartition.h b/headers/gcg/dec_hrcgpartition.h deleted file mode 100644 index 5b043ff..0000000 --- a/headers/gcg/dec_hrcgpartition.h +++ /dev/null @@ -1,55 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* */ -/* This file is part of the program */ -/* GCG --- Generic Column Generation */ -/* a Dantzig-Wolfe decomposition based extension */ -/* of the branch-cut-and-price framework */ -/* SCIP --- Solving Constraint Integer Programs */ -/* */ -/* Copyright (C) 2010-2022 Operations Research, RWTH Aachen University */ -/* Zuse Institute Berlin (ZIB) */ -/* */ -/* This program is free software; you can redistribute it and/or */ -/* modify it under the terms of the GNU Lesser General Public License */ -/* as published by the Free Software Foundation; either version 3 */ -/* of the License, or (at your option) any later version. */ -/* */ -/* This program is distributed in the hope that it will be useful, */ -/* but WITHOUT ANY WARRANTY; without even the implied warranty of */ -/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ -/* GNU Lesser General Public License for more details. */ -/* */ -/* You should have received a copy of the GNU Lesser General Public License */ -/* along with this program; if not, write to the Free Software */ -/* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.*/ -/* */ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -/**@file dec_hrcgpartition.h - * @brief arrowhead and bordered detector via graph partitioning (uses hmetis) - * @author Martin Bergner - */ - -/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/ - -#ifndef GCG_DEC_HRCGPARTITION_H__ -#define GCG_DEC_HRCGPARTITION_H__ - -#include "scip/scip.h" -#include "type_decomp.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/** creates the hrcgpartition presolver and includes it in SCIP */ -extern -SCIP_RETCODE SCIPincludeDetectorHrcgpartition( - SCIP* scip /**< SCIP data structure */ - ); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/headers/gcg/dec_hrgpartition.h b/headers/gcg/dec_hrgpartition.h deleted file mode 100644 index c0b6f2a..0000000 --- a/headers/gcg/dec_hrgpartition.h +++ /dev/null @@ -1,55 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* */ -/* This file is part of the program */ -/* GCG --- Generic Column Generation */ -/* a Dantzig-Wolfe decomposition based extension */ -/* of the branch-cut-and-price framework */ -/* SCIP --- Solving Constraint Integer Programs */ -/* */ -/* Copyright (C) 2010-2022 Operations Research, RWTH Aachen University */ -/* Zuse Institute Berlin (ZIB) */ -/* */ -/* This program is free software; you can redistribute it and/or */ -/* modify it under the terms of the GNU Lesser General Public License */ -/* as published by the Free Software Foundation; either version 3 */ -/* of the License, or (at your option) any later version. */ -/* */ -/* This program is distributed in the hope that it will be useful, */ -/* but WITHOUT ANY WARRANTY; without even the implied warranty of */ -/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ -/* GNU Lesser General Public License for more details. */ -/* */ -/* You should have received a copy of the GNU Lesser General Public License */ -/* along with this program; if not, write to the Free Software */ -/* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.*/ -/* */ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -/**@file dec_hrgpartition.h - * @brief arrowhead and bordered detector via graph partitioning (uses hmetis) - * @author Martin Bergner - */ - -/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/ - -#ifndef GCG_DEC_HRGPARTITION_H__ -#define GCG_DEC_HRGPARTITION_H__ - -#include "scip/scip.h" -#include "type_decomp.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/** creates the hrgpartition presolver and includes it in SCIP */ -extern -SCIP_RETCODE SCIPincludeDetectorHrgpartition( - SCIP* scip /**< SCIP data structure */ - ); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/headers/gcg/dec_isomorph.h b/headers/gcg/dec_isomorph.h deleted file mode 100644 index bd4a2fa..0000000 --- a/headers/gcg/dec_isomorph.h +++ /dev/null @@ -1,53 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* */ -/* This file is part of the program */ -/* GCG --- Generic Column Generation */ -/* a Dantzig-Wolfe decomposition based extension */ -/* of the branch-cut-and-price framework */ -/* SCIP --- Solving Constraint Integer Programs */ -/* */ -/* Copyright (C) 2010-2022 Operations Research, RWTH Aachen University */ -/* Zuse Institute Berlin (ZIB) */ -/* */ -/* This program is free software; you can redistribute it and/or */ -/* modify it under the terms of the GNU Lesser General Public License */ -/* as published by the Free Software Foundation; either version 3 */ -/* of the License, or (at your option) any later version. */ -/* */ -/* This program is distributed in the hope that it will be useful, */ -/* but WITHOUT ANY WARRANTY; without even the implied warranty of */ -/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ -/* GNU Lesser General Public License for more details. */ -/* */ -/* You should have received a copy of the GNU Lesser General Public License */ -/* along with this program; if not, write to the Free Software */ -/* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.*/ -/* */ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -/**@file dec_isomorph.h - * @brief detector for pricing problems that can be aggregated (uses bliss) - * @author Martin Bergner - */ - -/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/ - -#ifndef DEC_ISOMORPH_H__ -#define DEC_ISOMORPH_H__ - -#include "scip/scip.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/** creates the handler for isomorph subproblems and includes it in SCIP */ -extern -SCIP_RETCODE SCIPincludeDetectorIsomorphism( - SCIP* scip /**< SCIP data structure */ - ); - -#ifdef __cplusplus -} -#endif -#endif /* DEC_ISOMORPH_H__ */ diff --git a/headers/gcg/dec_mastersetcover.h b/headers/gcg/dec_mastersetcover.h deleted file mode 100644 index 1c08fc4..0000000 --- a/headers/gcg/dec_mastersetcover.h +++ /dev/null @@ -1,64 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* */ -/* This file is part of the program */ -/* GCG --- Generic Column Generation */ -/* a Dantzig-Wolfe decomposition based extension */ -/* of the branch-cut-and-price framework */ -/* SCIP --- Solving Constraint Integer Programs */ -/* */ -/* Copyright (C) 2010-2022 Operations Research, RWTH Aachen University */ -/* Zuse Institute Berlin (ZIB) */ -/* */ -/* This program is free software; you can redistribute it and/or */ -/* modify it under the terms of the GNU Lesser General Public License */ -/* as published by the Free Software Foundation; either version 3 */ -/* of the License, or (at your option) any later version. */ -/* */ -/* This program is distributed in the hope that it will be useful, */ -/* but WITHOUT ANY WARRANTY; without even the implied warranty of */ -/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ -/* GNU Lesser General Public License for more details. */ -/* */ -/* You should have received a copy of the GNU Lesser General Public License */ -/* along with this program; if not, write to the Free Software */ -/* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.*/ -/* */ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -/**@file dec_mastersetcover.h - * @brief mastersetcover detector - * @author Martin Bergner - */ - -/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/ - -#ifndef DEC_MASTERSETCOVER_H_ -#define DEC_MASTERSETCOVER_H_ - -#include "scip/scip.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/** creates the handler for mastersetcover detector and includes it in SCIP */ -extern -SCIP_RETCODE SCIPincludeDetectorMastersetcover( - SCIP* scip /**< SCIP data structure */ - ); - -#ifdef __cplusplus -} -#endif - - - -#endif /* DEC_MASTERSETCOVER_H_ */ - - - - - - - - diff --git a/headers/gcg/dec_mastersetpack.h b/headers/gcg/dec_mastersetpack.h deleted file mode 100644 index 13750ce..0000000 --- a/headers/gcg/dec_mastersetpack.h +++ /dev/null @@ -1,64 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* */ -/* This file is part of the program */ -/* GCG --- Generic Column Generation */ -/* a Dantzig-Wolfe decomposition based extension */ -/* of the branch-cut-and-price framework */ -/* SCIP --- Solving Constraint Integer Programs */ -/* */ -/* Copyright (C) 2010-2022 Operations Research, RWTH Aachen University */ -/* Zuse Institute Berlin (ZIB) */ -/* */ -/* This program is free software; you can redistribute it and/or */ -/* modify it under the terms of the GNU Lesser General Public License */ -/* as published by the Free Software Foundation; either version 3 */ -/* of the License, or (at your option) any later version. */ -/* */ -/* This program is distributed in the hope that it will be useful, */ -/* but WITHOUT ANY WARRANTY; without even the implied warranty of */ -/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ -/* GNU Lesser General Public License for more details. */ -/* */ -/* You should have received a copy of the GNU Lesser General Public License */ -/* along with this program; if not, write to the Free Software */ -/* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.*/ -/* */ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -/**@file dec_mastersetpack.h - * @brief mastersetpack detector - * @author Martin Bergner - */ - -/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/ - -#ifndef DEC_MASTERSETPACK_H_ -#define DEC_MASTERSETPACK_H_ - -#include "scip/scip.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/** creates the handler for mastersetpack detector and includes it in SCIP */ -extern -SCIP_RETCODE SCIPincludeDetectorMastersetpack( - SCIP* scip /**< SCIP data structure */ - ); - -#ifdef __cplusplus -} -#endif - - - -#endif /* DEC_MASTERSETPACK_H_ */ - - - - - - - - diff --git a/headers/gcg/dec_mastersetpart.h b/headers/gcg/dec_mastersetpart.h deleted file mode 100644 index e5f2ee3..0000000 --- a/headers/gcg/dec_mastersetpart.h +++ /dev/null @@ -1,64 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* */ -/* This file is part of the program */ -/* GCG --- Generic Column Generation */ -/* a Dantzig-Wolfe decomposition based extension */ -/* of the branch-cut-and-price framework */ -/* SCIP --- Solving Constraint Integer Programs */ -/* */ -/* Copyright (C) 2010-2022 Operations Research, RWTH Aachen University */ -/* Zuse Institute Berlin (ZIB) */ -/* */ -/* This program is free software; you can redistribute it and/or */ -/* modify it under the terms of the GNU Lesser General Public License */ -/* as published by the Free Software Foundation; either version 3 */ -/* of the License, or (at your option) any later version. */ -/* */ -/* This program is distributed in the hope that it will be useful, */ -/* but WITHOUT ANY WARRANTY; without even the implied warranty of */ -/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ -/* GNU Lesser General Public License for more details. */ -/* */ -/* You should have received a copy of the GNU Lesser General Public License */ -/* along with this program; if not, write to the Free Software */ -/* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.*/ -/* */ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -/**@file dec_mastersetpart.h - * @brief mastersetpart detector - * @author Martin Bergner - */ - -/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/ - -#ifndef DEC_MASTERSETPART_H_ -#define DEC_MASTERSETPART_H_ - -#include "scip/scip.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/** creates the handler for mastersetpart detector and includes it in SCIP */ -extern -SCIP_RETCODE SCIPincludeDetectorMastersetpart( - SCIP* scip /**< SCIP data structure */ - ); - -#ifdef __cplusplus -} -#endif - - - -#endif /* DEC_MASTERSETPART_H_ */ - - - - - - - - diff --git a/headers/gcg/dec_mst.h b/headers/gcg/dec_mst.h deleted file mode 100644 index 51dfdf0..0000000 --- a/headers/gcg/dec_mst.h +++ /dev/null @@ -1,56 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* */ -/* This file is part of the program */ -/* GCG --- Generic Column Generation */ -/* a Dantzig-Wolfe decomposition based extension */ -/* of the branch-cut-and-price framework */ -/* SCIP --- Solving Constraint Integer Programs */ -/* */ -/* Copyright (C) 2010-2022 Operations Research, RWTH Aachen University */ -/* Zuse Institute Berlin (ZIB) */ -/* */ -/* This program is free software; you can redistribute it and/or */ -/* modify it under the terms of the GNU Lesser General Public License */ -/* as published by the Free Software Foundation; either version 3 */ -/* of the License, or (at your option) any later version. */ -/* */ -/* This program is distributed in the hope that it will be useful, */ -/* but WITHOUT ANY WARRANTY; without even the implied warranty of */ -/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ -/* GNU Lesser General Public License for more details. */ -/* */ -/* You should have received a copy of the GNU Lesser General Public License */ -/* along with this program; if not, write to the Free Software */ -/* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.*/ -/* */ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -/**@file dec_mst.h - * @brief detector for diagonal (bordered) structures via Minimum Spanning Tree clustering algorithm - * @author Igor Pesic - */ - -/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/ - -#ifndef GCG_DEC_MST_H__ -#define GCG_DEC_MST_H__ - - -#include "scip/scip.h" - -#ifdef __cplusplus -extern "C" { -#endif - - -extern -/** creates the DBSCAN presolver and includes it in SCIP */ -SCIP_RETCODE SCIPincludeDetectorMST( - SCIP* scip /**< SCIP data structure */ - ); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/headers/gcg/dec_neighborhoodmaster.h b/headers/gcg/dec_neighborhoodmaster.h deleted file mode 100644 index 19a4686..0000000 --- a/headers/gcg/dec_neighborhoodmaster.h +++ /dev/null @@ -1,53 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* */ -/* This file is part of the program */ -/* GCG --- Generic Column Generation */ -/* a Dantzig-Wolfe decomposition based extension */ -/* of the branch-cut-and-price framework */ -/* SCIP --- Solving Constraint Integer Programs */ -/* */ -/* Copyright (C) 2010-2022 Operations Research, RWTH Aachen University */ -/* Zuse Institute Berlin (ZIB) */ -/* */ -/* This program is free software; you can redistribute it and/or */ -/* modify it under the terms of the GNU Lesser General Public License */ -/* as published by the Free Software Foundation; either version 3 */ -/* of the License, or (at your option) any later version. */ -/* */ -/* This program is distributed in the hope that it will be useful, */ -/* but WITHOUT ANY WARRANTY; without even the implied warranty of */ -/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ -/* GNU Lesser General Public License for more details. */ -/* */ -/* You should have received a copy of the GNU Lesser General Public License */ -/* along with this program; if not, write to the Free Software */ -/* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.*/ -/* */ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -/**@file dec_neighborhoodmaster.h - * @brief neighborhoodmaster detector - * @author Michael Bastubbe - */ - -/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/ - -#ifndef DEC_NEIGHBORHOODMASTER_H_ -#define DEC_NEIGHBORHOODMASTER_H_ - -#include "scip/scip.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/** creates the handler for neighborhoodmasterconss detector and includes it in SCIP */ -extern -SCIP_RETCODE SCIPincludeDetectorNeighborhoodmaster( - SCIP* scip /**< SCIP data structure */ - ); - -#ifdef __cplusplus -} -#endif -#endif /* DEC_NEIGHBORHOODMASTER_H_ */ diff --git a/headers/gcg/dec_postprocess.h b/headers/gcg/dec_postprocess.h deleted file mode 100644 index 764107b..0000000 --- a/headers/gcg/dec_postprocess.h +++ /dev/null @@ -1,54 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* */ -/* This file is part of the program */ -/* GCG --- Generic Column Generation */ -/* a Dantzig-Wolfe decomposition based extension */ -/* of the branch-cut-and-price framework */ -/* SCIP --- Solving Constraint Integer Programs */ -/* */ -/* Copyright (C) 2010-2022 Operations Research, RWTH Aachen University */ -/* Zuse Institute Berlin (ZIB) */ -/* */ -/* This program is free software; you can redistribute it and/or */ -/* modify it under the terms of the GNU Lesser General Public License */ -/* as published by the Free Software Foundation; either version 3 */ -/* of the License, or (at your option) any later version. */ -/* */ -/* This program is distributed in the hope that it will be useful, */ -/* but WITHOUT ANY WARRANTY; without even the implied warranty of */ -/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ -/* GNU Lesser General Public License for more details. */ -/* */ -/* You should have received a copy of the GNU Lesser General Public License */ -/* along with this program; if not, write to the Free Software */ -/* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.*/ -/* */ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -/**@file dec_postprocess.h - * @brief postprocess detector - * @author Michael Bastubbe - */ - -/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/ - -#ifndef GCG_DEC_POSTPROCESS_H__ -#define GCG_DEC_POSTPROCESS_H__ - -#include "scip/scip.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/** creates the handler for postprocess detector and includes it in SCIP */ -extern -SCIP_RETCODE SCIPincludeDetectorPostprocess( - SCIP* scip /**< SCIP data structure */ - ); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/headers/gcg/dec_staircase_lsp.h b/headers/gcg/dec_staircase_lsp.h deleted file mode 100644 index 57507a8..0000000 --- a/headers/gcg/dec_staircase_lsp.h +++ /dev/null @@ -1,55 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* */ -/* This file is part of the program */ -/* GCG --- Generic Column Generation */ -/* a Dantzig-Wolfe decomposition based extension */ -/* of the branch-cut-and-price framework */ -/* SCIP --- Solving Constraint Integer Programs */ -/* */ -/* Copyright (C) 2010-2022 Operations Research, RWTH Aachen University */ -/* Zuse Institute Berlin (ZIB) */ -/* */ -/* This program is free software; you can redistribute it and/or */ -/* modify it under the terms of the GNU Lesser General Public License */ -/* as published by the Free Software Foundation; either version 3 */ -/* of the License, or (at your option) any later version. */ -/* */ -/* This program is distributed in the hope that it will be useful, */ -/* but WITHOUT ANY WARRANTY; without even the implied warranty of */ -/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ -/* GNU Lesser General Public License for more details. */ -/* */ -/* You should have received a copy of the GNU Lesser General Public License */ -/* along with this program; if not, write to the Free Software */ -/* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.*/ -/* */ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -/**@file dec_staircase_lsp.h - * @brief staircase compontent detector - * @author Martin Bergner - * @author Michael Bastubbe - */ - -/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/ - -#ifndef __SCIP_DEC_STAIRCASE_LSP_H__ -#define __SCIP_DEC_STAIRCASE_LSP_H__ - -#include "scip/scip.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/** creates the handler for staircase constraints and includes it in SCIP */ -extern -SCIP_RETCODE SCIPincludeDetectorStaircaseLsp( - SCIP* scip /**< SCIP data structure */ - ); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/headers/gcg/dec_stairheur.h b/headers/gcg/dec_stairheur.h deleted file mode 100644 index 9dc282e..0000000 --- a/headers/gcg/dec_stairheur.h +++ /dev/null @@ -1,64 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* */ -/* This file is part of the program */ -/* GCG --- Generic Column Generation */ -/* a Dantzig-Wolfe decomposition based extension */ -/* of the branch-cut-and-price framework */ -/* SCIP --- Solving Constraint Integer Programs */ -/* */ -/* Copyright (C) 2010-2022 Operations Research, RWTH Aachen University */ -/* Zuse Institute Berlin (ZIB) */ -/* */ -/* This program is free software; you can redistribute it and/or */ -/* modify it under the terms of the GNU Lesser General Public License */ -/* as published by the Free Software Foundation; either version 3 */ -/* of the License, or (at your option) any later version. */ -/* */ -/* This program is distributed in the hope that it will be useful, */ -/* but WITHOUT ANY WARRANTY; without even the implied warranty of */ -/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ -/* GNU Lesser General Public License for more details. */ -/* */ -/* You should have received a copy of the GNU Lesser General Public License */ -/* along with this program; if not, write to the Free Software */ -/* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.*/ -/* */ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -/**@file dec_stairheur.h - * @brief detector for staircase structures via ROC algorithms - * @author Martin Bergner - * @author Mathias Luers - */ - -/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/ - -#ifndef GCG_DEC_STAIRHEUR_H__ -#define GCG_DEC_STAIRHEUR_H__ - - -#include "scip/scip.h" - -#ifdef __cplusplus -extern "C" { -#endif - -enum Blockingtype -{ - DYNAMIC = 1, /**< Tries to minimize the number of linking variables */ - STATIC = 2, /**< Creates blocks with the same number of rows */ - ASSOONASPOSSIBLE = 3 /**< Blocking is done in a way such that three adjacent blocks just do not overlap. This results in (almost) exclusively linking variables. */ -}; -typedef enum Blockingtype BLOCKINGTYPE; - -extern -/** creates the stairheur detector and includes it in SCIP */ -SCIP_RETCODE SCIPincludeDetectorStairheur( - SCIP* scip /**< SCIP data structure */ - ); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/headers/gcg/dec_varclass.h b/headers/gcg/dec_varclass.h deleted file mode 100644 index fb9cadd..0000000 --- a/headers/gcg/dec_varclass.h +++ /dev/null @@ -1,53 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* */ -/* This file is part of the program */ -/* GCG --- Generic Column Generation */ -/* a Dantzig-Wolfe decomposition based extension */ -/* of the branch-cut-and-price framework */ -/* SCIP --- Solving Constraint Integer Programs */ -/* */ -/* Copyright (C) 2010-2022 Operations Research, RWTH Aachen University */ -/* Zuse Institute Berlin (ZIB) */ -/* */ -/* This program is free software; you can redistribute it and/or */ -/* modify it under the terms of the GNU Lesser General Public License */ -/* as published by the Free Software Foundation; either version 3 */ -/* of the License, or (at your option) any later version. */ -/* */ -/* This program is distributed in the hope that it will be useful, */ -/* but WITHOUT ANY WARRANTY; without even the implied warranty of */ -/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ -/* GNU Lesser General Public License for more details. */ -/* */ -/* You should have received a copy of the GNU Lesser General Public License */ -/* along with this program; if not, write to the Free Software */ -/* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.*/ -/* */ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -/**@file dec_varclass.h - * @brief varclass detector - * @author Julius Hense - */ - -/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/ - -#ifndef DEC_VARCLASS_H_ -#define DEC_VARCLASS_H_ - -#include "scip/scip.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/** creates the handler for varclass detector and includes it in SCIP */ -extern -SCIP_RETCODE SCIPincludeDetectorVarclass( - SCIP* scip /**< SCIP data structure */ - ); - -#ifdef __cplusplus -} -#endif -#endif /* DEC_VARCLASS_H_ */ diff --git a/headers/gcg/decomp.h b/headers/gcg/decomp.h deleted file mode 100644 index 985cc0f..0000000 --- a/headers/gcg/decomp.h +++ /dev/null @@ -1,69 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* */ -/* This file is part of the program */ -/* GCG --- Generic Column Generation */ -/* a Dantzig-Wolfe decomposition based extension */ -/* of the branch-cut-and-price framework */ -/* SCIP --- Solving Constraint Integer Programs */ -/* */ -/* Copyright (C) 2010-2022 Operations Research, RWTH Aachen University */ -/* Zuse Institute Berlin (ZIB) */ -/* */ -/* This program is free software; you can redistribute it and/or */ -/* modify it under the terms of the GNU Lesser General Public License */ -/* as published by the Free Software Foundation; either version 3 */ -/* of the License, or (at your option) any later version. */ -/* */ -/* This program is distributed in the hope that it will be useful, */ -/* but WITHOUT ANY WARRANTY; without even the implied warranty of */ -/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ -/* GNU Lesser General Public License for more details. */ -/* */ -/* You should have received a copy of the GNU Lesser General Public License */ -/* along with this program; if not, write to the Free Software */ -/* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.*/ -/* */ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -/**@file decomp.h - * @ingroup DECOMP - * @brief private methods for working with decomp structures - * @author Martin Bergner - */ - -/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/ -#ifndef GCG_DECOMP_H__ -#define GCG_DECOMP_H__ - -#include "type_decomp.h" -#include "type_detector.h" -#include "scip/scip.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/** sets the detectors for the given decomposition - * - * @note make sure you know what you are doing, only use at initialization -*/ -extern -SCIP_RETCODE DECdecompSetDetectorChain( - SCIP* scip, /**< SCIP data structure */ - DEC_DECOMP* decomp, /**< decomposition data structure */ - DEC_DETECTOR** detectors, /**< new detector chain */ - int ndetectors /**< number of new detectors (i.e. length of the detector array) */ - ); - -/** sets the id of the original partialdec */ -extern -void DECdecompSetPartialdecID( - DEC_DECOMP* decomp, /**< decomposition data structure */ - int id /**< ID of partialdec */ - ); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/headers/gcg/def.h b/headers/gcg/def.h deleted file mode 100644 index b42d623..0000000 --- a/headers/gcg/def.h +++ /dev/null @@ -1,41 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* */ -/* This file is part of the program */ -/* GCG --- Generic Column Generation */ -/* a Dantzig-Wolfe decomposition based extension */ -/* of the branch-cut-and-price framework */ -/* SCIP --- Solving Constraint Integer Programs */ -/* */ -/* Copyright (C) 2010-2022 Operations Research, RWTH Aachen University */ -/* Zuse Institute Berlin (ZIB) */ -/* */ -/* This program is free software; you can redistribute it and/or */ -/* modify it under the terms of the GNU Lesser General Public License */ -/* as published by the Free Software Foundation; either version 3 */ -/* of the License, or (at your option) any later version. */ -/* */ -/* This program is distributed in the hope that it will be useful, */ -/* but WITHOUT ANY WARRANTY; without even the implied warranty of */ -/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ -/* GNU Lesser General Public License for more details. */ -/* */ -/* You should have received a copy of the GNU Lesser General Public License */ -/* along with this program; if not, write to the Free Software */ -/* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.*/ -/* */ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -/**@file def.h - * @brief common defines and data types used in all packages of GCG - * @author Stefanie Koß - */ - -/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/ - -#ifndef GCG_DEF_H_ -#define GCG_DEF_H_ - -#define GCG_VERSION 353 /**< GCG version number (multiplied by 100 to get integer number) */ -#define GCG_SUBVERSION 0 /**< GCG sub version number */ - -#endif diff --git a/headers/gcg/dialog_gcg.h b/headers/gcg/dialog_gcg.h deleted file mode 100644 index c8739e2..0000000 --- a/headers/gcg/dialog_gcg.h +++ /dev/null @@ -1,172 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* */ -/* This file is part of the program */ -/* GCG --- Generic Column Generation */ -/* a Dantzig-Wolfe decomposition based extension */ -/* of the branch-cut-and-price framework */ -/* SCIP --- Solving Constraint Integer Programs */ -/* */ -/* Copyright (C) 2010-2022 Operations Research, RWTH Aachen University */ -/* Zuse Institute Berlin (ZIB) */ -/* */ -/* This program is free software; you can redistribute it and/or */ -/* modify it under the terms of the GNU Lesser General Public License */ -/* as published by the Free Software Foundation; either version 3 */ -/* of the License, or (at your option) any later version. */ -/* */ -/* This program is distributed in the hope that it will be useful, */ -/* but WITHOUT ANY WARRANTY; without even the implied warranty of */ -/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ -/* GNU Lesser General Public License for more details. */ -/* */ -/* You should have received a copy of the GNU Lesser General Public License */ -/* along with this program; if not, write to the Free Software */ -/* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.*/ -/* */ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -/**@file dialog_gcg.h - * @ingroup DIALOGS - * @brief GCG user interface dialog - * @author Tobias Achterberg - * @author Timo Berthold - * @author Gerald Gamrath - * @author Martin Bergner - */ - -/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/ - -#ifndef GCG_DIALOG_GCG_H__ -#define GCG_DIALOG_GCG_H__ - - -#include "scip/scip.h" - -#ifdef __cplusplus -extern "C" { -#endif - - -/** dialog execution method for the display additionalstatistics command */ -extern -SCIP_DECL_DIALOGEXEC(GCGdialogExecDisplayAdditionalStatistics); - -/** dialog execution method for the display statistics command */ -extern -SCIP_DECL_DIALOGEXEC(GCGdialogExecDisplayStatistics); - -/** dialog execution method print complete detection information */ -extern -SCIP_DECL_DIALOGEXEC(GCGdialogExecPrintDetectionInformation); - -/** dialog execution method for adding block number candidate */ -extern -SCIP_DECL_DIALOGEXEC(GCGdialogExecChangeAddBlocknr); - -/** dialog execution method for the display detectors command */ -extern -SCIP_DECL_DIALOGEXEC(GCGdialogExecDisplayDetectors); - -/** dialog execution method for the display solvers command */ -extern -SCIP_DECL_DIALOGEXEC(GCGdialogExecDisplaySolvers); - -/** dialog execution method for the display decomposition command */ -extern -SCIP_DECL_DIALOGEXEC(GCGdialogExecDisplayDecomposition); - -/** dialog execution method for the display nblockscandidates command */ -extern -SCIP_DECL_DIALOGEXEC(GCGdialogExecDisplayNBlockcandidates); - -/** dialog execution method for the presolve command */ -extern -SCIP_DECL_DIALOGEXEC(GCGdialogExecPresolve); - -/** dialog execution method for the master command */ -extern -SCIP_DECL_DIALOGEXEC(GCGdialogExecSetMaster); - -/** dialog execution method for the set loadmaster command */ -extern -SCIP_DECL_DIALOGEXEC(GCGdialogExecSetLoadmaster); - -/** dialog execution method for the detect command */ -extern -SCIP_DECL_DIALOGEXEC(GCGdialogExecDetect); - -/** dialog execution method for the select command */ -extern -SCIP_DECL_DIALOGEXEC(GCGdialogExecSelect); - -/** dialog execution method for the transform command */ -extern -SCIP_DECL_DIALOGEXEC(GCGdialogExecTransform); - -/** dialog execution method for the optimize command */ -extern -SCIP_DECL_DIALOGEXEC(GCGdialogExecOptimize); - -/** dialog execution method for the set detectors fast command */ -extern -SCIP_DECL_DIALOGEXEC(SCIPdialogExecSetDetectorsFast); - -/** dialog execution method for the set detectors off command */ -extern -SCIP_DECL_DIALOGEXEC(SCIPdialogExecSetDetectorsOff); - -/** dialog execution method for the set detectors default command */ -extern -SCIP_DECL_DIALOGEXEC(SCIPdialogExecSetDetectorsDefault); - -/** dialog execution method for the set detectors aggressive command */ -extern -SCIP_DECL_DIALOGEXEC(SCIPdialogExecSetDetectorsAggressive); - -/** dialog execution method for the set heuristics fast command */ -extern -SCIP_DECL_DIALOGEXEC(GCGdialogExecSetHeuristicsFast); - -/** dialog execution method for the set heuristics off command */ -extern -SCIP_DECL_DIALOGEXEC(GCGdialogExecSetHeuristicsOff); - -/** dialog execution method for the set heuristics aggressive command */ -extern -SCIP_DECL_DIALOGEXEC(GCGdialogExecSetHeuristicsAggressive); - -/** dialog execution method for the set separators default command */ -extern -SCIP_DECL_DIALOGEXEC(GCGdialogExecSetSeparatorsDefault); - -/** dialog execution method for the set separators fast command */ -extern -SCIP_DECL_DIALOGEXEC(GCGdialogExecSetSeparatorsFast); - -/** dialog execution method for the set separators off command */ -extern -SCIP_DECL_DIALOGEXEC(GCGdialogExecSetSeparatorsOff); - -/** dialog execution method for the set separators aggressive command */ -extern -SCIP_DECL_DIALOGEXEC(GCGdialogExecSetSeparatorsAggressive); - -/** creates a root dialog - * @returns SCIP return code */ -extern -SCIP_RETCODE GCGcreateRootDialog( - SCIP* scip, /**< SCIP data structure */ - SCIP_DIALOG** root /**< pointer to store the root dialog */ - ); - -/** includes or updates the GCG dialog menus in SCIP */ -extern -SCIP_RETCODE SCIPincludeDialogGcg( - SCIP* scip /**< SCIP data structure */ - ); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/headers/gcg/dialog_graph.h b/headers/gcg/dialog_graph.h deleted file mode 100644 index 9f5db28..0000000 --- a/headers/gcg/dialog_graph.h +++ /dev/null @@ -1,105 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* */ -/* This file is part of the program */ -/* GCG --- Generic Column Generation */ -/* a Dantzig-Wolfe decomposition based extension */ -/* of the branch-cut-and-price framework */ -/* SCIP --- Solving Constraint Integer Programs */ -/* */ -/* Copyright (C) 2010-2022 Operations Research, RWTH Aachen University */ -/* Zuse Institute Berlin (ZIB) */ -/* */ -/* This program is free software; you can redistribute it and/or */ -/* modify it under the terms of the GNU Lesser General Public License */ -/* as published by the Free Software Foundation; either version 3 */ -/* of the License, or (at your option) any later version. */ -/* */ -/* This program is distributed in the hope that it will be useful, */ -/* but WITHOUT ANY WARRANTY; without even the implied warranty of */ -/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ -/* GNU Lesser General Public License for more details. */ -/* */ -/* You should have received a copy of the GNU Lesser General Public License */ -/* along with this program; if not, write to the Free Software */ -/* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.*/ -/* */ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -/**@file dialog_graph.h - * @ingroup DIALOGS - * @brief A dialog to write graph representations of the matrix and read partitions as decompositions. - * @author Martin Bergner - */ - -/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/ - - -#ifndef DIALOG_GRAPH_H_ -#define DIALOG_GRAPH_H_ - -#include "objdialog.h" -#include "graph/graph.h" - -namespace gcg -{ - -class DialogGraph: public ObjDialog -{ -public: - DialogGraph( - SCIP* scip /**< SCIP data structure */ - ); - virtual ~DialogGraph() {} - virtual SCIP_DECL_DIALOGEXEC(scip_exec); -}; - -class DialogWriteGraph: public ObjDialog -{ -public: - DialogWriteGraph( - SCIP* scip /**< SCIP data structure */ - ); - virtual ~DialogWriteGraph() {} - virtual SCIP_DECL_DIALOGEXEC(scip_exec); -}; - -class DialogReadPartition: public ObjDialog -{ -public: - DialogReadPartition( - SCIP* scip /**< SCIP data structure */ - ); - virtual ~DialogReadPartition() {} - virtual SCIP_DECL_DIALOGEXEC(scip_exec); -}; - -template class G> -class DialogReadGraphs: public ObjDialog -{ -private: - typedef G GRAPH_TYPE; -public: - DialogReadGraphs( - SCIP* scip /**< SCIP data structure */ - ); - virtual ~DialogReadGraphs() {} - virtual SCIP_DECL_DIALOGEXEC(scip_exec); -}; - -template class G> -class DialogWriteGraphs: public ObjDialog -{ -private: - typedef G GRAPH_TYPE; -public: - DialogWriteGraphs( - SCIP* scip /**< SCIP data structure */ - ); - virtual ~DialogWriteGraphs() {} - virtual SCIP_DECL_DIALOGEXEC(scip_exec); -}; -} /* namespace gcg */ - - - -#endif /* DIALOG_GRAPH_H_ */ diff --git a/headers/gcg/dialog_master.h b/headers/gcg/dialog_master.h deleted file mode 100644 index 5c1adaf..0000000 --- a/headers/gcg/dialog_master.h +++ /dev/null @@ -1,68 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* */ -/* This file is part of the program */ -/* GCG --- Generic Column Generation */ -/* a Dantzig-Wolfe decomposition based extension */ -/* of the branch-cut-and-price framework */ -/* SCIP --- Solving Constraint Integer Programs */ -/* */ -/* Copyright (C) 2010-2022 Operations Research, RWTH Aachen University */ -/* Zuse Institute Berlin (ZIB) */ -/* */ -/* This program is free software; you can redistribute it and/or */ -/* modify it under the terms of the GNU Lesser General Public License */ -/* as published by the Free Software Foundation; either version 3 */ -/* of the License, or (at your option) any later version. */ -/* */ -/* This program is distributed in the hope that it will be useful, */ -/* but WITHOUT ANY WARRANTY; without even the implied warranty of */ -/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ -/* GNU Lesser General Public License for more details. */ -/* */ -/* You should have received a copy of the GNU Lesser General Public License */ -/* along with this program; if not, write to the Free Software */ -/* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.*/ -/* */ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -/**@file dialog_master.h - * @ingroup DIALOGS - * @brief user interface dialog for master problem - * @author Tobias Achterberg - * @author Christian Puchert - */ - -/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/ - -#ifndef GCG_DIALOG_MASTER_H__ -#define GCG_DIALOG_MASTER_H__ - - -#include "scip/scip.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/** dialog execution method telling that a command is not available */ -extern -SCIP_DECL_DIALOGEXEC(GCGmasterDialogExecNotAvailable); - -/** creates a root dialog */ -extern -SCIP_RETCODE GCGcreateRootMasterDialog( - SCIP* scip, /**< SCIP data structure */ - SCIP_DIALOG** root /**< pointer to store the root dialog */ - ); - -/** includes or updates the master dialog menus in GCG */ -extern -SCIP_RETCODE SCIPincludeDialogMaster( - SCIP* scip /**< SCIP data structure */ - ); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/headers/gcg/disp_gcg.h b/headers/gcg/disp_gcg.h deleted file mode 100644 index 65dc3aa..0000000 --- a/headers/gcg/disp_gcg.h +++ /dev/null @@ -1,48 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* */ -/* This file is part of the program */ -/* GCG --- Generic Column Generation */ -/* a Dantzig-Wolfe decomposition based extension */ -/* of the branch-cut-and-price framework */ -/* SCIP --- Solving Constraint Integer Programs */ -/* */ -/* Copyright (C) 2010-2022 Operations Research, RWTH Aachen University */ -/* Zuse Institute Berlin (ZIB) */ -/* */ -/* This program is free software; you can redistribute it and/or */ -/* modify it under the terms of the GNU Lesser General Public License */ -/* as published by the Free Software Foundation; either version 3 */ -/* of the License, or (at your option) any later version. */ -/* */ -/* This program is distributed in the hope that it will be useful, */ -/* but WITHOUT ANY WARRANTY; without even the implied warranty of */ -/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ -/* GNU Lesser General Public License for more details. */ -/* */ -/* You should have received a copy of the GNU Lesser General Public License */ -/* along with this program; if not, write to the Free Software */ -/* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.*/ -/* */ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -/**@file disp_gcg.h - * @brief GCG display columns - * @author Gerald Gamrath - */ - -/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/ - -#ifndef GCG_DISP_GCG_H__ -#define GCG_DISP_GCG_H__ - - -#include "scip/scip.h" - - -/** includes the GCG display columns in SCIP */ -extern -SCIP_RETCODE SCIPincludeDispGcg( - SCIP* scip /**< SCIP data structure */ - ); - -#endif diff --git a/headers/gcg/disp_master.h b/headers/gcg/disp_master.h deleted file mode 100644 index 38557c8..0000000 --- a/headers/gcg/disp_master.h +++ /dev/null @@ -1,55 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* */ -/* This file is part of the program */ -/* GCG --- Generic Column Generation */ -/* a Dantzig-Wolfe decomposition based extension */ -/* of the branch-cut-and-price framework */ -/* SCIP --- Solving Constraint Integer Programs */ -/* */ -/* Copyright (C) 2010-2022 Operations Research, RWTH Aachen University */ -/* Zuse Institute Berlin (ZIB) */ -/* */ -/* This program is free software; you can redistribute it and/or */ -/* modify it under the terms of the GNU Lesser General Public License */ -/* as published by the Free Software Foundation; either version 3 */ -/* of the License, or (at your option) any later version. */ -/* */ -/* This program is distributed in the hope that it will be useful, */ -/* but WITHOUT ANY WARRANTY; without even the implied warranty of */ -/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ -/* GNU Lesser General Public License for more details. */ -/* */ -/* You should have received a copy of the GNU Lesser General Public License */ -/* along with this program; if not, write to the Free Software */ -/* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.*/ -/* */ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -/**@file disp_master.h - * @brief master display columns - * @author Gerald Gamrath - */ - -/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/ - -#ifndef GCG_DISP_MASTER_H__ -#define GCG_DISP_MASTER_H__ - - -#include "scip/scip.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/** includes the master display columns in SCIP */ -extern -SCIP_RETCODE SCIPincludeDispMaster( - SCIP* scip /**< SCIP data structure */ - ); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/headers/gcg/event_bestsol.h b/headers/gcg/event_bestsol.h deleted file mode 100644 index bb457e4..0000000 --- a/headers/gcg/event_bestsol.h +++ /dev/null @@ -1,55 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* */ -/* This file is part of the program */ -/* GCG --- Generic Column Generation */ -/* a Dantzig-Wolfe decomposition based extension */ -/* of the branch-cut-and-price framework */ -/* SCIP --- Solving Constraint Integer Programs */ -/* */ -/* Copyright (C) 2010-2022 Operations Research, RWTH Aachen University */ -/* Zuse Institute Berlin (ZIB) */ -/* */ -/* This program is free software; you can redistribute it and/or */ -/* modify it under the terms of the GNU Lesser General Public License */ -/* as published by the Free Software Foundation; either version 3 */ -/* of the License, or (at your option) any later version. */ -/* */ -/* This program is distributed in the hope that it will be useful, */ -/* but WITHOUT ANY WARRANTY; without even the implied warranty of */ -/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ -/* GNU Lesser General Public License for more details. */ -/* */ -/* You should have received a copy of the GNU Lesser General Public License */ -/* along with this program; if not, write to the Free Software */ -/* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.*/ -/* */ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -/**@file event_bestsol.h - * @ingroup EVENTS - * @brief eventhdlr to record the best primal bound for each heuristic - * @author Christian Puchert - */ - -/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/ - -#ifndef GCG_EVENT_BESTSOL_H__ -#define GCG_EVENT_BESTSOL_H__ - -#include "scip/scip.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/** creates event handler for best event */ -extern -SCIP_RETCODE SCIPincludeEventHdlrBestsol( - SCIP* scip /**< SCIP data structure */ - ); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/headers/gcg/event_display.h b/headers/gcg/event_display.h deleted file mode 100644 index 6ebe036..0000000 --- a/headers/gcg/event_display.h +++ /dev/null @@ -1,61 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* */ -/* This file is part of the program */ -/* GCG --- Generic Column Generation */ -/* a Dantzig-Wolfe decomposition based extension */ -/* of the branch-cut-and-price framework */ -/* SCIP --- Solving Constraint Integer Programs */ -/* */ -/* Copyright (C) 2010-2022 Operations Research, RWTH Aachen University */ -/* Zuse Institute Berlin (ZIB) */ -/* */ -/* This program is free software; you can redistribute it and/or */ -/* modify it under the terms of the GNU Lesser General Public License */ -/* as published by the Free Software Foundation; either version 3 */ -/* of the License, or (at your option) any later version. */ -/* */ -/* This program is distributed in the hope that it will be useful, */ -/* but WITHOUT ANY WARRANTY; without even the implied warranty of */ -/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ -/* GNU Lesser General Public License for more details. */ -/* */ -/* You should have received a copy of the GNU Lesser General Public License */ -/* along with this program; if not, write to the Free Software */ -/* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.*/ -/* */ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -/**@file event_display.h - * @ingroup EVENTS - * @brief eventhdlr to disable the master display after the root node - * @author Martin Bergner - */ - -/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/ - -#ifndef GCG_EVENT_DISPLAY_H__ -#define GCG_EVENT_DISPLAY_H__ - -#include "scip/scip.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/** activates the eventhandler in SCIP */ -extern -SCIP_RETCODE SCIPactivateEventHdlrDisplay( - SCIP* scip /**< SCIP data structure */ - ); - -/** creates event handler for display event */ -extern -SCIP_RETCODE SCIPincludeEventHdlrDisplay( - SCIP* scip /**< SCIP data structure */ - ); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/headers/gcg/event_mastersol.h b/headers/gcg/event_mastersol.h deleted file mode 100644 index d721257..0000000 --- a/headers/gcg/event_mastersol.h +++ /dev/null @@ -1,61 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* */ -/* This file is part of the program */ -/* GCG --- Generic Column Generation */ -/* a Dantzig-Wolfe decomposition based extension */ -/* of the branch-cut-and-price framework */ -/* SCIP --- Solving Constraint Integer Programs */ -/* */ -/* Copyright (C) 2010-2022 Operations Research, RWTH Aachen University */ -/* Zuse Institute Berlin (ZIB) */ -/* */ -/* This program is free software; you can redistribute it and/or */ -/* modify it under the terms of the GNU Lesser General Public License */ -/* as published by the Free Software Foundation; either version 3 */ -/* of the License, or (at your option) any later version. */ -/* */ -/* This program is distributed in the hope that it will be useful, */ -/* but WITHOUT ANY WARRANTY; without even the implied warranty of */ -/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ -/* GNU Lesser General Public License for more details. */ -/* */ -/* You should have received a copy of the GNU Lesser General Public License */ -/* along with this program; if not, write to the Free Software */ -/* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.*/ -/* */ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -/**@file event_mastersol.h - * @ingroup EVENTS - * @brief eventhdlr to transfer solutions found in the original problem to the master problem - * @author Christian Puchert - */ - -/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/ - -#ifndef GCG_EVENT_MASTERSOL_H__ -#define GCG_EVENT_MASTERSOL_H__ - -#include "scip/scip.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/** creates event handler for mastersol event */ -SCIP_EXPORT -SCIP_RETCODE SCIPincludeEventHdlrMastersol( - SCIP* scip /**< SCIP data structure */ - ); - -/** return whether event has been triggered */ -SCIP_EXPORT -SCIP_Bool GCGeventhdlrMastersolIsTriggered( - SCIP* scip /**< SCIP data structure */ - ); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/headers/gcg/event_relaxsol.h b/headers/gcg/event_relaxsol.h deleted file mode 100644 index 646b3e0..0000000 --- a/headers/gcg/event_relaxsol.h +++ /dev/null @@ -1,63 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* */ -/* This file is part of the program */ -/* GCG --- Generic Column Generation */ -/* a Dantzig-Wolfe decomposition based extension */ -/* of the branch-cut-and-price framework */ -/* SCIP --- Solving Constraint Integer Programs */ -/* */ -/* Copyright (C) 2010-2022 Operations Research, RWTH Aachen University */ -/* Zuse Institute Berlin (ZIB) */ -/* */ -/* This program is free software; you can redistribute it and/or */ -/* modify it under the terms of the GNU Lesser General Public License */ -/* as published by the Free Software Foundation; either version 3 */ -/* of the License, or (at your option) any later version. */ -/* */ -/* This program is distributed in the hope that it will be useful, */ -/* but WITHOUT ANY WARRANTY; without even the implied warranty of */ -/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ -/* GNU Lesser General Public License for more details. */ -/* */ -/* You should have received a copy of the GNU Lesser General Public License */ -/* along with this program; if not, write to the Free Software */ -/* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.*/ -/* */ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -/**@file event_relaxsol.h - * @ingroup EVENTS - * @brief eventhandler to update the relaxation solution in the original problem when the master LP has been solved - * @author Christian Puchert - */ - -/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/ - -#ifndef __SCIP_EVENT_RELAXSOL_H__ -#define __SCIP_EVENT_RELAXSOL_H__ - - -#include "scip/scip.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/** creates event handler for relaxsol event */ -SCIP_EXPORT -SCIP_RETCODE SCIPincludeEventHdlrRelaxsol( - SCIP* scip /**< SCIP data structure */ - ); - -/** return whether event has been triggered */ -SCIP_EXPORT -SCIP_Bool GCGeventhdlrRelaxsolIsTriggered( - SCIP* scip, /**< SCIP data structure */ - SCIP* masterprob /**< the SCIP data structure for the master problem */ - ); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/headers/gcg/event_solvingstats.h b/headers/gcg/event_solvingstats.h deleted file mode 100644 index 28f19d6..0000000 --- a/headers/gcg/event_solvingstats.h +++ /dev/null @@ -1,41 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* */ -/* This file is part of the program */ -/* GCG --- Generic Column Generation */ -/* a Dantzig-Wolfe decomposition based extension */ -/* of the branch-cut-and-price framework */ -/* SCIP --- Solving Constraint Integer Programs */ -/* */ -/* Copyright (C) 2010-2022 Operations Research, RWTH Aachen University */ -/* Zuse Institute Berlin (ZIB) */ -/* */ -/* This program is free software; you can redistribute it and/or */ -/* modify it under the terms of the GNU Lesser General Public License */ -/* as published by the Free Software Foundation; either version 3 */ -/* of the License, or (at your option) any later version. */ -/* */ -/* This program is distributed in the hope that it will be useful, */ -/* but WITHOUT ANY WARRANTY; without even the implied warranty of */ -/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ -/* GNU Lesser General Public License for more details. */ -/* */ -/* You should have received a copy of the GNU Lesser General Public License */ -/* along with this program; if not, write to the Free Software */ -/* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.*/ -/* */ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -/**@file event_solvingstats.h - * @brief eventhdlr for writing various types of information during the solving process - * @author Gerald Gamrath - */ - -/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/ - -#include "scip/scip.h" - -/** includes event handler for best solution found */ -extern -SCIP_RETCODE SCIPincludeEventHdlrSolvingstats( - SCIP* scip /**< SCIP data structure */ - ); diff --git a/headers/gcg/gcg.h b/headers/gcg/gcg.h deleted file mode 100644 index 7acf50a..0000000 --- a/headers/gcg/gcg.h +++ /dev/null @@ -1,319 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* */ -/* This file is part of the program */ -/* GCG --- Generic Column Generation */ -/* a Dantzig-Wolfe decomposition based extension */ -/* of the branch-cut-and-price framework */ -/* SCIP --- Solving Constraint Integer Programs */ -/* */ -/* Copyright (C) 2010-2022 Operations Research, RWTH Aachen University */ -/* Zuse Institute Berlin (ZIB) */ -/* */ -/* This program is free software; you can redistribute it and/or */ -/* modify it under the terms of the GNU Lesser General Public License */ -/* as published by the Free Software Foundation; either version 3 */ -/* of the License, or (at your option) any later version. */ -/* */ -/* This program is distributed in the hope that it will be useful, */ -/* but WITHOUT ANY WARRANTY; without even the implied warranty of */ -/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ -/* GNU Lesser General Public License for more details. */ -/* */ -/* You should have received a copy of the GNU Lesser General Public License */ -/* along with this program; if not, write to the Free Software */ -/* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.*/ -/* */ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -/**@file gcg.h - * @ingroup PUBLICCOREAPI - * @brief GCG interface methods - * @author Martin Bergner - */ - -/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/ - -/* #define SCIP_STATISTIC */ - -#ifndef GCG_H_ -#define GCG_H_ - -#include "scip/scip.h" -#include "def.h" - -#include "type_branchgcg.h" -#include "type_decomp.h" -#include "type_detector.h" -#include "type_solver.h" - -#include "pub_gcgvar.h" -#include "pub_decomp.h" - -#include "relax_gcg.h" -#include "gcg_general.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/** checks whether the scip is the original scip instance - * @returns whether the scip is the original scip instance */ -extern -SCIP_Bool GCGisOriginal( - SCIP* scip /**< SCIP data structure */ - ); - -/** checks whether the scip is the master problem scip - * @returns whether the scip is the master problem scip */ -extern -SCIP_Bool GCGisMaster( - SCIP* scip /**< SCIP data structure */ - ); - -/** print out GCG statistics - * @returns SCIP return code */ -SCIP_RETCODE GCGprintStatistics( - SCIP* scip, /**< SCIP data structure */ - FILE* file /**< output file or NULL for standard output */ -); - -/** print out complete detection statistics - * @returns SCIP return code */ -SCIP_RETCODE GCGprintCompleteDetectionStatistics( - SCIP* scip, /**< SCIP data structure */ - FILE* file /**< output file or NULL for standard output */ -); - -/** print name of current instance to given output - * @returns SCIP return code */ -SCIP_RETCODE GCGprintInstanceName( - SCIP* scip, /**< SCIP data structure */ - FILE* file /**< output file or NULL for standard output */ -); - -SCIP_RETCODE GCGprintMiplibStructureInformation( - SCIP* scip, /**< SCIP data structure */ - SCIP_DIALOGHDLR* dialoghdlr /**< dialog handler */ - ); - - - -SCIP_RETCODE GCGprintBlockcandidateInformation( - SCIP* scip, /**< SCIP data structure */ - FILE* file /**< output file or NULL for standard output */ -); - -SCIP_RETCODE GCGprintCompleteDetectionTime( - SCIP* scip, /**< SCIP data structure */ - FILE* file /**< output file or NULL for standard output */ -); - - -SCIP_RETCODE GCGprintPartitionInformation( - SCIP* scip, /**< SCIP data structure */ - FILE* file /**< output file or NULL for standard output */ -); - -SCIP_RETCODE GCGprintDecompInformation( - SCIP* scip, /**< SCIP data structure */ - FILE* file /**< output file or NULL for standard output */ -); - - - -/** gets the total memory used after problem creation stage for all pricingproblems */ -extern -SCIP_Real GCGgetPricingprobsMemUsed( - SCIP* scip /**< SCIP data structure */ - ); - -/** prints out the degeneracy of the problem */ -extern -void GCGprintDegeneracy( - SCIP* scip, /**< SCIP data structure */ - double degeneracy /**< degeneracy to print*/ - ); - -/** returns the average degeneracy */ -extern -SCIP_Real GCGgetDegeneracy( - SCIP* scip /**< SCIP data structure */ - ); - -/** transforms given values of the given original variables into values of the given master variables - * @returns the sum of the values of the corresponding master variables that are fixed */ -extern -SCIP_Real GCGtransformOrigvalsToMastervals( - SCIP* scip, /**< SCIP data structure */ - SCIP_VAR** origvars, /**< array with (subset of the) original variables */ - SCIP_Real* origvals, /**< array with values for the given original variables */ - int norigvars, /**< number of given original variables */ - SCIP_VAR** mastervars, /**< array of (all present) master variables */ - SCIP_Real* mastervals, /**< array to store the values of the master variables */ - int nmastervars /**< number of master variables */ - ); - -/** transforms given solution of the master problem into solution of the original problem - * @returns SCIP return code */ -extern -SCIP_RETCODE GCGtransformMastersolToOrigsol( - SCIP* scip, /**< SCIP data structure */ - SCIP_SOL* mastersol, /**< solution of the master problem */ - SCIP_SOL** origsol /**< pointer to store the new created original problem's solution */ - ); - -/** Checks whether the constraint belongs to GCG or not - * @returns whether the constraint belongs to GCG or not */ -extern -SCIP_Bool GCGisConsGCGCons( - SCIP_CONS* cons /**< constraint to check */ - ); - - -/** returns the original problem for the given master problem */ -SCIP* GCGgetOriginalprob( - SCIP* masterprob /**< the SCIP data structure for the master problem */ - ); - -/** returns the master problem */ -extern -SCIP* GCGgetMasterprob( - SCIP* scip /**< SCIP data structure */ - ); - -/** returns the pricing problem of the given number */ -extern -SCIP* GCGgetPricingprob( - SCIP* scip, /**< SCIP data structure */ - int pricingprobnr /**< number of the pricing problem */ - ); - -/** returns the number of pricing problems */ -extern -int GCGgetNPricingprobs( - SCIP* scip /**< SCIP data structure */ - ); - -/** returns TRUE iff the pricingproblem of the given number is relevant, that means is not identical to - * another and represented by it */ -extern -SCIP_Bool GCGisPricingprobRelevant( - SCIP* scip, /**< SCIP data structure */ - int pricingprobnr /**< number of the pricing problem */ - ); - -/** - * for a given block, return the block by which it is represented - */ -extern -int GCGgetBlockRepresentative( - SCIP* scip, /**< SCIP data structure */ - int pricingprobnr /**< number of the pricing problem */ - ); - -/** returns the number of relevant pricing problems */ -extern -int GCGgetNRelPricingprobs( - SCIP* scip /**< SCIP data structure */ - ); - -/** returns the number of blocks in the original formulation, that are represented by - * the pricingprob with the given number */ -extern -int GCGgetNIdenticalBlocks( - SCIP* scip, /**< SCIP data structure */ - int pricingprobnr /**< number of the pricing problem */ - ); - -/** returns the number of constraints in the master problem */ -extern -int GCGgetNMasterConss( - SCIP* scip /**< SCIP data structure */ - ); - -/** returns the contraints in the master problem */ -extern -SCIP_CONS** GCGgetMasterConss( - SCIP* scip /**< SCIP data structure */ - ); - -/** returns the contraints in the original problem that correspond to the constraints in the master problem */ -extern -SCIP_CONS** GCGgetOrigMasterConss( - SCIP* scip /**< SCIP data structure */ - ); - - -/** returns the convexity constraint for the given block */ -extern -SCIP_CONS* GCGgetConvCons( - SCIP* scip, /**< SCIP data structure */ - int blocknr /**< the number of the block for which we - * need the convexity constraint */ - ); - -/** returns whether the master problem is a set covering problem */ -extern -SCIP_Bool GCGisMasterSetCovering( - SCIP* scip /**< SCIP data structure */ - ); - -/** returns whether the master problem is a set partitioning problem */ -extern -SCIP_Bool GCGisMasterSetPartitioning( - SCIP* scip /**< SCIP data structure */ - ); - -/** returns whether the relaxator has been initialized */ -extern -SCIP_Bool GCGrelaxIsInitialized( - SCIP* scip /**< SCIP data structure */ - ); - -/** return linking constraints for variables */ -extern -SCIP_CONS** GCGgetVarLinkingconss( - SCIP* scip /**< SCIP data structure */ - ); - -/** return blocks of linking constraints for variables */ -extern -int* GCGgetVarLinkingconssBlock( - SCIP* scip /**< SCIP data structure */ - ); - -/** return number of linking constraints for variables */ -extern -int GCGgetNVarLinkingconss( - SCIP* scip /**< SCIP data structure */ - ); - -/** return number of linking variables */ -extern -int GCGgetNLinkingvars( - SCIP* scip /**< SCIP data structure */ - ); - -/** return number of variables directly transferred to the master problem */ -extern -int GCGgetNTransvars( - SCIP* scip /**< SCIP data structure */ - ); - -/** returns the auxiliary variable for the given pricing probblem */ -extern -SCIP_VAR* GCGgetAuxiliaryVariable( - SCIP* scip, /**< SCIP data structure */ - int pricingprobnr /**< number of the pricing problem */ - ); - -/** returns the relaxation solution from the Benders' decomposition */ -extern -SCIP_SOL* GCGgetBendersRelaxationSol( - SCIP* scip /**< SCIP data structure */ - ); - -#ifdef __cplusplus -} -#endif -#endif /* GCG_H_ */ diff --git a/headers/gcg/gcg_general.h b/headers/gcg/gcg_general.h deleted file mode 100644 index 5ec5ebc..0000000 --- a/headers/gcg/gcg_general.h +++ /dev/null @@ -1,60 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* */ -/* This file is part of the program */ -/* GCG --- Generic Column Generation */ -/* a Dantzig-Wolfe decomposition based extension */ -/* of the branch-cut-and-price framework */ -/* SCIP --- Solving Constraint Integer Programs */ -/* */ -/* Copyright (C) 2010-2022 Operations Research, RWTH Aachen University */ -/* Zuse Institute Berlin (ZIB) */ -/* */ -/* This program is free software; you can redistribute it and/or */ -/* modify it under the terms of the GNU Lesser General Public License */ -/* as published by the Free Software Foundation; either version 3 */ -/* of the License, or (at your option) any later version. */ -/* */ -/* This program is distributed in the hope that it will be useful, */ -/* but WITHOUT ANY WARRANTY; without even the implied warranty of */ -/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ -/* GNU Lesser General Public License for more details. */ -/* */ -/* You should have received a copy of the GNU Lesser General Public License */ -/* along with this program; if not, write to the Free Software */ -/* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.*/ -/* */ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -/**@file gcg_general.h - * @brief gcg general public methods - * @author Steffan Schlein - */ - -/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/ - -#ifndef GCG_GENERAL_H__ -#define GCG_GENERAL_H__ - - -#include "scip/def.h" -#include "scip/type_scip.h" - -#include "def.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/** prints out GCG version - * @returns nothing */ -SCIP_EXPORT -void GCGprintVersion( - SCIP* scip, /**< SCIP data structure */ - FILE* file /**< output file (or NULL for standard output) */ - ); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/headers/gcg/gcgcol.h b/headers/gcg/gcgcol.h deleted file mode 100644 index 13d44f5..0000000 --- a/headers/gcg/gcgcol.h +++ /dev/null @@ -1,49 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* */ -/* This file is part of the program */ -/* GCG --- Generic Column Generation */ -/* a Dantzig-Wolfe decomposition based extension */ -/* of the branch-cut-and-price framework */ -/* SCIP --- Solving Constraint Integer Programs */ -/* */ -/* Copyright (C) 2010-2022 Operations Research, RWTH Aachen University */ -/* Zuse Institute Berlin (ZIB) */ -/* */ -/* This program is free software; you can redistribute it and/or */ -/* modify it under the terms of the GNU Lesser General Public License */ -/* as published by the Free Software Foundation; either version 3 */ -/* of the License, or (at your option) any later version. */ -/* */ -/* This program is distributed in the hope that it will be useful, */ -/* but WITHOUT ANY WARRANTY; without even the implied warranty of */ -/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ -/* GNU Lesser General Public License for more details. */ -/* */ -/* You should have received a copy of the GNU Lesser General Public License */ -/* along with this program; if not, write to the Free Software */ -/* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.*/ -/* */ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -/**@file gcgcol.h - * @brief private methods for working with gcg column data structure - * @author Jonas Witt - */ - -/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/ -#ifndef GCG_GCGCOL_H__ -#define GCG_GCGCOL_H__ - -#include "struct_gcgcol.h" -#include "type_gcgcol.h" - -#ifdef __cplusplus -extern "C" { -#endif - - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/headers/gcg/gcggithash.h b/headers/gcg/gcggithash.h deleted file mode 100644 index 7ddc1c4..0000000 --- a/headers/gcg/gcggithash.h +++ /dev/null @@ -1,54 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* */ -/* This file is part of the program */ -/* GCG --- Generic Column Generation */ -/* a Dantzig-Wolfe decomposition based extension */ -/* of the branch-cut-and-price framework */ -/* SCIP --- Solving Constraint Integer Programs */ -/* */ -/* Copyright (C) 2010-2022 Operations Research, RWTH Aachen University */ -/* Zuse Institute Berlin (ZIB) */ -/* */ -/* This program is free software; you can redistribute it and/or */ -/* modify it under the terms of the GNU Lesser General Public License */ -/* as published by the Free Software Foundation; either version 3 */ -/* of the License, or (at your option) any later version. */ -/* */ -/* This program is distributed in the hope that it will be useful, */ -/* but WITHOUT ANY WARRANTY; without even the implied warranty of */ -/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ -/* GNU Lesser General Public License for more details. */ -/* */ -/* You should have received a copy of the GNU Lesser General Public License */ -/* along with this program; if not, write to the Free Software */ -/* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.*/ -/* */ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -/**@file gcggithash.h - * @brief git hash methods - * @author Stefan Heinz - * @author Martin Bergner - */ - -/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/ - -#ifndef GCG_GCGGITHASH_H__ -#define GCG_GCGGITHASH_H__ - -#ifdef __cplusplus -extern "C" { -#endif - -/** Gets the GCG git hash - * @returns the GCG git hash */ -extern -const char* GCGgetGitHash( - void - ); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/headers/gcg/gcgplugins.h b/headers/gcg/gcgplugins.h deleted file mode 100644 index 089c883..0000000 --- a/headers/gcg/gcgplugins.h +++ /dev/null @@ -1,55 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* */ -/* This file is part of the program */ -/* GCG --- Generic Column Generation */ -/* a Dantzig-Wolfe decomposition based extension */ -/* of the branch-cut-and-price framework */ -/* SCIP --- Solving Constraint Integer Programs */ -/* */ -/* Copyright (C) 2010-2022 Operations Research, RWTH Aachen University */ -/* Zuse Institute Berlin (ZIB) */ -/* */ -/* This program is free software; you can redistribute it and/or */ -/* modify it under the terms of the GNU Lesser General Public License */ -/* as published by the Free Software Foundation; either version 3 */ -/* of the License, or (at your option) any later version. */ -/* */ -/* This program is distributed in the hope that it will be useful, */ -/* but WITHOUT ANY WARRANTY; without even the implied warranty of */ -/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ -/* GNU Lesser General Public License for more details. */ -/* */ -/* You should have received a copy of the GNU Lesser General Public License */ -/* along with this program; if not, write to the Free Software */ -/* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.*/ -/* */ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -/**@file gcgplugins.h - * @brief SCIP plugins for generic column generation - * @author Gerald Gamrath - */ - -/*--+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/ - -#ifndef GCG_GCGPLUGINS_H__ -#define GCG_GCGPLUGINS_H__ - - -#include "scip/scip.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/** includes default SCIP plugins into SCIP */ -extern -SCIP_RETCODE SCIPincludeGcgPlugins( - SCIP* scip /**< SCIP data structure */ - ); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/headers/gcg/gcgpqueue.h b/headers/gcg/gcgpqueue.h deleted file mode 100644 index d379ae1..0000000 --- a/headers/gcg/gcgpqueue.h +++ /dev/null @@ -1,49 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* */ -/* This file is part of the program */ -/* GCG --- Generic Column Generation */ -/* a Dantzig-Wolfe decomposition based extension */ -/* of the branch-cut-and-price framework */ -/* SCIP --- Solving Constraint Integer Programs */ -/* */ -/* Copyright (C) 2010-2022 Operations Research, RWTH Aachen University */ -/* Zuse Institute Berlin (ZIB) */ -/* */ -/* This program is free software; you can redistribute it and/or */ -/* modify it under the terms of the GNU Lesser General Public License */ -/* as published by the Free Software Foundation; either version 3 */ -/* of the License, or (at your option) any later version. */ -/* */ -/* This program is distributed in the hope that it will be useful, */ -/* but WITHOUT ANY WARRANTY; without even the implied warranty of */ -/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ -/* GNU Lesser General Public License for more details. */ -/* */ -/* You should have received a copy of the GNU Lesser General Public License */ -/* along with this program; if not, write to the Free Software */ -/* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.*/ -/* */ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -/**@file gcgpqueue.h - * @brief private methods for working with priority queue - * @author Jonas Witt - */ - -/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/ -#ifndef GCG_GCGPQUEUE_H__ -#define GCG_GCGPQUEUE_H__ - -#include "struct_gcgpqueue.h" -#include "type_gcgpqueue.h" - -#ifdef __cplusplus -extern "C" { -#endif - - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/headers/gcg/gcgsort.h b/headers/gcg/gcgsort.h deleted file mode 100644 index 4a4eef0..0000000 --- a/headers/gcg/gcgsort.h +++ /dev/null @@ -1,82 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* */ -/* This file is part of the program */ -/* GCG --- Generic Column Generation */ -/* a Dantzig-Wolfe decomposition based extension */ -/* of the branch-cut-and-price framework */ -/* SCIP --- Solving Constraint Integer Programs */ -/* */ -/* Copyright (C) 2010-2022 Operations Research, RWTH Aachen University */ -/* Zuse Institute Berlin (ZIB) */ -/* */ -/* This program is free software; you can redistribute it and/or */ -/* modify it under the terms of the GNU Lesser General Public License */ -/* as published by the Free Software Foundation; either version 3 */ -/* of the License, or (at your option) any later version. */ -/* */ -/* This program is distributed in the hope that it will be useful, */ -/* but WITHOUT ANY WARRANTY; without even the implied warranty of */ -/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ -/* GNU Lesser General Public License for more details. */ -/* */ -/* You should have received a copy of the GNU Lesser General Public License */ -/* along with this program; if not, write to the Free Software */ -/* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.*/ -/* */ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -/**@file gcgsort.h - * @brief sorting functions, adapted from SCIP's sorttpl to include userdata - * @author Tobias Oelschlegel - **/ - -/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/ - -#ifndef GCG_SORT_H__ -#define GCG_SORT_H__ - -#include "scip/scip.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/** compares two element indices - * result: - * < 0: ind1 comes before (is better than) ind2 - * = 0: both indices have the same value - * > 0: ind2 comes after (is worse than) ind2 - **/ -#define GCG_DECL_SORTINDCOMP(x) int x (void* userdata, void* dataptr, int ind1, int ind2) - -/** compares two data element pointers - * result: - * < 0: elem1 comes before (is better than) elem2 - * = 0: both elements have the same value - * > 0: elem2 comes after (is worse than) elem2 - **/ -#define GCG_DECL_SORTPTRCOMP(x) int x (void* userdata, void* elem1, void* elem2) - -SCIP_EXPORT -void GCGsortPtr( - void** ptrarray, /**< pointer array to be sorted */ - GCG_DECL_SORTPTRCOMP((*ptrcomp)), /**< data element comparator */ - void* userdata, /**< userdata that is supplied to the comparator function */ - int len /**< length of array */ - ); - -/** sort of two joint arrays of pointers/pointers, sorted by first array in non-decreasing order */ -SCIP_EXPORT -void GCGsortPtrPtr( - void** ptrarray1, /**< first pointer array to be sorted */ - void** ptrarray2, /**< second pointer array to be permuted in the same way */ - GCG_DECL_SORTPTRCOMP((*ptrcomp)), /**< data element comparator */ - void* userdata, /**< userdata that is supplied to the comparator function */ - int len /**< length of arrays */ - ); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/headers/gcg/graph/bipartitegraph.h b/headers/gcg/graph/bipartitegraph.h deleted file mode 100644 index 6f84b96..0000000 --- a/headers/gcg/graph/bipartitegraph.h +++ /dev/null @@ -1,72 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* */ -/* This file is part of the program */ -/* GCG --- Generic Column Generation */ -/* a Dantzig-Wolfe decomposition based extension */ -/* of the branch-cut-and-price framework */ -/* SCIP --- Solving Constraint Integer Programs */ -/* */ -/* Copyright (C) 2010-2022 Operations Research, RWTH Aachen University */ -/* Zuse Institute Berlin (ZIB) */ -/* */ -/* This program is free software; you can redistribute it and/or */ -/* modify it under the terms of the GNU Lesser General Public License */ -/* as published by the Free Software Foundation; either version 3 */ -/* of the License, or (at your option) any later version. */ -/* */ -/* This program is distributed in the hope that it will be useful, */ -/* but WITHOUT ANY WARRANTY; without even the implied warranty of */ -/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ -/* GNU Lesser General Public License for more details. */ -/* */ -/* You should have received a copy of the GNU Lesser General Public License */ -/* along with this program; if not, write to the Free Software */ -/* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.*/ -/* */ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -/**@file graph.h - * @brief miscellaneous graph methods for structure detection - * @author Martin Bergner - */ - -/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/ - -#ifndef GCG_BIPARTITEGRAPH_H_ -#define GCG_BIPARTITEGRAPH_H_ - -#include "matrixgraph.h" -#include "graph.h" - -namespace gcg { - -template -class BipartiteGraph : public MatrixGraph -{ -private: - Graph graph; -public: - BipartiteGraph( - SCIP* scip, /**< SCIP data structure */ - Weights w /**< weights for the given graph */ - ); - virtual ~BipartiteGraph(); - virtual SCIP_RETCODE createFromMatrix( - SCIP_CONS** conss, /**< constraints for which graph should be created */ - SCIP_VAR** vars, /**< variables for which graph should be created */ - int nconss_, /**< number of constraints */ - int nvars_ /**< number of variables */ - ); - - - virtual SCIP_RETCODE createFromPartialMatrix( - DETPROBDATA* detprobdata, - PARTIALDECOMP* partialdec - ); - - int getNConsNodes(); - int getNVarNodes(); -}; - -} /* namespace gcg */ -#endif /* GCG_BIPARTITEGRAPH_H_ */ diff --git a/headers/gcg/graph/bipartitegraph_def.h b/headers/gcg/graph/bipartitegraph_def.h deleted file mode 100644 index f6bc714..0000000 --- a/headers/gcg/graph/bipartitegraph_def.h +++ /dev/null @@ -1,259 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* */ -/* This file is part of the program */ -/* GCG --- Generic Column Generation */ -/* a Dantzig-Wolfe decomposition based extension */ -/* of the branch-cut-and-price framework */ -/* SCIP --- Solving Constraint Integer Programs */ -/* */ -/* Copyright (C) 2010-2022 Operations Research, RWTH Aachen University */ -/* Zuse Institute Berlin (ZIB) */ -/* */ -/* This program is free software; you can redistribute it and/or */ -/* modify it under the terms of the GNU Lesser General Public License */ -/* as published by the Free Software Foundation; either version 3 */ -/* of the License, or (at your option) any later version. */ -/* */ -/* This program is distributed in the hope that it will be useful, */ -/* but WITHOUT ANY WARRANTY; without even the implied warranty of */ -/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ -/* GNU Lesser General Public License for more details. */ -/* */ -/* You should have received a copy of the GNU Lesser General Public License */ -/* along with this program; if not, write to the Free Software */ -/* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.*/ -/* */ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -/**@file bipartitegraph_def.h - * @brief A bipartite graph - * @author Martin Bergner - */ - -/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/ - -#ifndef GCG_BIPARTITEGRAPH_DEF_H_ -#define GCG_BIPARTITEGRAPH_DEF_H_ - -#include "bipartitegraph.h" -#include "scip_misc.h" - -namespace gcg { - -template -BipartiteGraph::BipartiteGraph( - SCIP* scip, /**< SCIP data structure */ - Weights w /**< weights for the given graph */ - ): MatrixGraph(scip,w), graph(scip) -{ - this->graphiface = &graph; - this->name = std::string("bipartite"); -} - -template -BipartiteGraph::~BipartiteGraph() -{ - -} - - -/** - * Builds a bipartite graph structure out of the matrix. - * - * The function will create an node for every constraint and every variable. - * A constraint and a variable are adjacent if the variable appears in the constraint variable array. - * - * @todo The nonzeroness is not checked, all variables in the variable array are considered - */ -template -SCIP_RETCODE BipartiteGraph::createFromMatrix( - SCIP_CONS** conss, /**< constraints for which graph should be created */ - SCIP_VAR** vars, /**< variables for which graph should be created */ - int nconss_, /**< number of constraints */ - int nvars_ /**< number of variables */ - ) -{ - int i; - int j; - SCIP_Bool success; - - assert(conss != NULL); - assert(vars != NULL); - assert(nvars_ > 0); - assert(nconss_ > 0); - this->nvars = nvars_; - this->nconss = nconss_; - - for( i = 0; i < this->nvars + this->nconss; ++i ) - { - TCLIQUE_WEIGHT weight; - - /* note that the first nvars nodes correspond to variables */ - if( i < this->nvars ) - weight = this->weights.calculate(vars[i]); - else - weight = this->weights.calculate(conss[i-this->nvars]); - - this->graph.addNode(i, weight); - } - - /* go through all constraints */ - for( i = 0; i < this->nconss; ++i ) - { - SCIP_VAR** curvars = NULL; - - int ncurvars; - SCIP_CALL( SCIPgetConsNVars(this->scip_, conss[i], &ncurvars, &success) ); - assert(success); - if( ncurvars == 0 ) - continue; - - /* - * may work as is, as we are copying the constraint later regardless - * if there are variables in it or not - */ - SCIP_CALL( SCIPallocBufferArray(this->scip_, &curvars, ncurvars) ); - SCIP_CALL( SCIPgetConsVars(this->scip_, conss[i], curvars, ncurvars, &success) ); - assert(success); - - /** @todo skip all variables that have a zero coeffient or where all coefficients add to zero */ - /** @todo Do more then one entry per variable actually work? */ - - for( j = 0; j < ncurvars; ++j ) - { - SCIP_VAR* var = NULL; - int varIndex; - - if( SCIPgetStage(this->scip_) >= SCIP_STAGE_TRANSFORMED) - var = SCIPvarGetProbvar(curvars[j]); - else - var = curvars[j]; - - if( !GCGisVarRelevant(var) ) - continue; - - assert(var != NULL); - varIndex = SCIPvarGetProbindex(var); - assert(varIndex >= 0); - assert(varIndex < this->nvars); - - SCIP_CALL( this->graph.addEdge(varIndex, this->nvars+i) ); - } - SCIPfreeBufferArray(this->scip_, &curvars); - } - - this->graph.flush(); - return SCIP_OKAY; -} - - -template -SCIP_RETCODE BipartiteGraph::createFromPartialMatrix( - DETPROBDATA* detprobdata, - PARTIALDECOMP* partialdec - ){ - - int i; - int j; - unordered_map oldToNewVarIndex; - unordered_map oldToNewConsIndex; - std::vector varsBool(partialdec->getNVars(), false); /* true, if the var will be part of the graph */ - std::vector conssBool(partialdec->getNConss(), false); /* true, if the cons will be part of the graph */ - std::vector conssForGraph; /* stores the conss included by the graph */ - std::vector varsForGraph; /* stores the vars included by the graph */ - - //fillout conssForGraph and varsForGraph - for(int c = 0; c < partialdec->getNOpenconss(); ++c) - { - int cons = partialdec->getOpenconss()[c]; - for(int v = 0; v < partialdec->getNOpenvars(); ++v) - { - int var = partialdec->getOpenvars()[v]; - for(i = 0; i < detprobdata->getNVarsForCons(cons); ++i) - { - if(var == detprobdata->getVarsForCons(cons)[i]) - { - varsBool[var] = true; - conssBool[cons] = true; - } - } - } - } - - for(int v = 0; v < partialdec->getNOpenvars(); ++v) - { - int var = partialdec->getOpenvars()[v]; - if(varsBool[var]) - varsForGraph.push_back(var); - } - for(int c = 0; c < partialdec->getNOpenconss(); ++c) - { - int cons = partialdec->getOpenconss()[c]; - if(conssBool[cons]) - conssForGraph.push_back(cons); - } - - this->nconss = (int)conssForGraph.size(); - this->nvars = (int)varsForGraph.size(); - - - /* add node for every var */ - for( i = 0 ; i < this->nvars; ++i ) - { - TCLIQUE_WEIGHT weight; - int var = varsForGraph[i]; - - /* note that the first nvars nodes correspond to variables */ - weight = this->weights.calculate(detprobdata->getVar(var)); - oldToNewVarIndex.insert({var,i}); - this->graph.addNode(i, weight); - } - - - /* add node for every cons */ - for( j = 0 ; j < this->nconss; ++j ) - { - TCLIQUE_WEIGHT weight; - int cons = conssForGraph[j]; - - /* note that the first nvars nodes correspond to variables (legacy implementation) */ - weight = this->weights.calculate(detprobdata->getCons(cons)); - oldToNewConsIndex.insert({cons, j}); - this->graph.addNode( this->nvars + j, weight); - } - - /* go through all open constraints */ - for( i = 0; i < this->nconss; ++i ) - { - int oldConsId = conssForGraph[i]; - - for( j = 0; j < detprobdata->getNVarsForCons(oldConsId); ++j ) - { - int oldVarId = detprobdata->getVarsForCons(oldConsId)[j]; - if(!varsBool[oldVarId]) - continue; - SCIP_CALL( this->graph.addEdge(oldToNewVarIndex[oldVarId], this->nvars+i) ); - } - } - - this->graph.flush(); - return SCIP_OKAY; - } - - -template -int BipartiteGraph::getNConsNodes() -{ - return this->nconss; -} - -template -int BipartiteGraph::getNVarNodes() -{ - return this->nvars; -} - - -} /* namespace gcg */ - -#endif diff --git a/headers/gcg/graph/bridge.h b/headers/gcg/graph/bridge.h deleted file mode 100644 index 3f04426..0000000 --- a/headers/gcg/graph/bridge.h +++ /dev/null @@ -1,142 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* */ -/* This file is part of the program */ -/* GCG --- Generic Column Generation */ -/* a Dantzig-Wolfe decomposition based extension */ -/* of the branch-cut-and-price framework */ -/* SCIP --- Solving Constraint Integer Programs */ -/* */ -/* Copyright (C) 2010-2022 Operations Research, RWTH Aachen University */ -/* Zuse Institute Berlin (ZIB) */ -/* */ -/* This program is free software; you can redistribute it and/or */ -/* modify it under the terms of the GNU Lesser General Public License */ -/* as published by the Free Software Foundation; either version 3 */ -/* of the License, or (at your option) any later version. */ -/* */ -/* This program is distributed in the hope that it will be useful, */ -/* but WITHOUT ANY WARRANTY; without even the implied warranty of */ -/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ -/* GNU Lesser General Public License for more details. */ -/* */ -/* You should have received a copy of the GNU Lesser General Public License */ -/* along with this program; if not, write to the Free Software */ -/* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.*/ -/* */ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -/**@file bridge.h - * @brief bridge - * @author Annika Thome - */ - -/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/ - -#ifndef GCG_BRIDGE_H -#define GCG_BRIDGE_H -#include "objscip/objscip.h" -#include - - -namespace gcg -{ - -class Bridge -{ -public: - Bridge() {} - virtual ~Bridge() {} - - /** add n nodes in the graph at the same time. it is much faster than to call addNode() many times */ - virtual SCIP_RETCODE addNNodes(int _n_nodes) = 0; - - /** add n nodes in the graph at the same time. it is much faster than to call addNode() many times. weights represent node weights */ - virtual SCIP_RETCODE addNNodes(int _n_nodes, std::vector weights) = 0; - - /** get number of nodes in the graph */ - virtual int getNNodes() = 0; - - /** get number of edges in the graph */ - virtual int getNEdges() = 0; - - /** get list of edges in the graph (not defined how edges are implemented) */ - virtual SCIP_RETCODE getEdges(std::vector& edges) = 0; - - /** return whether a given pair of vertices is connected by an edge */ - virtual SCIP_Bool isEdge(int i, int j) = 0; - - /** get number of neighbors of a given node */ - virtual int getNNeighbors(int i) = 0; - - /** get a vector of all neighbors of a given node */ - virtual std::vector getNeighbors(int i) = 0; - - /** adds the node with the given weight to the graph */ - virtual SCIP_RETCODE addNode(int i,int weight) = 0; - - /** adds the node with 0 weight to the graph */ - virtual SCIP_RETCODE addNode() = 0; - - /** adds the weighted edge to the graph */ - virtual SCIP_RETCODE addEdge(int i, int j, double weight) = 0; - - /** sets the weight of the edge in the graph */ - virtual SCIP_RETCODE setEdge(int i, int j, double weight) = 0; - - /** returns the weight of the edge in the graph */ - virtual double getEdgeWeight(int i, int j) = 0; - - virtual std::vector > getNeighborWeights(int i) {return std::vector >();}; - - /** deletes the given node from the graph */ - virtual SCIP_RETCODE deleteNode(int i) = 0; - - /** adds the edge to the graph */ - virtual SCIP_RETCODE addEdge(int i, int j) = 0; - - /** deletes the edge from the graph */ - virtual SCIP_RETCODE deleteEdge(int i, int j) = 0; - - /** return the weight of a node */ - virtual int graphGetWeights(int i) = 0; - - /** flushes the data stuctures, if needed */ - virtual SCIP_RETCODE flush() = 0; - - /** normalizes the edge weights, so that the biggest edge egiht in the graph is 1 */ - virtual SCIP_RETCODE normalize() = 0; - - virtual double getEdgeWeightPercentile(double q) = 0; - -#ifdef WITH_GSL - /** function needed for MST clustering */ - virtual void expand(int factor) = 0; - - /** function needed for MST clustering */ - virtual void inflate(double factor) = 0; - - /** function needed for MST clustering */ - virtual void colL1Norm() = 0; - - /** function needed for MST clustering */ - virtual void prune() = 0; - - /** function needed for MST clustering */ - virtual bool stopMCL(int iter) {return true;} - - virtual std::vector getClustersMCL() {return std::vector();} - - /** function needed for MST clustering */ - virtual void initMCL() = 0; - - /** function needed for MST clustering */ - virtual void clearMCL() = 0; - -#endif - -}; - - -} /* namespace gcg*/ - -#endif diff --git a/headers/gcg/graph/columngraph.h b/headers/gcg/graph/columngraph.h deleted file mode 100644 index 6c2af39..0000000 --- a/headers/gcg/graph/columngraph.h +++ /dev/null @@ -1,69 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* */ -/* This file is part of the program */ -/* GCG --- Generic Column Generation */ -/* a Dantzig-Wolfe decomposition based extension */ -/* of the branch-cut-and-price framework */ -/* SCIP --- Solving Constraint Integer Programs */ -/* */ -/* Copyright (C) 2010-2022 Operations Research, RWTH Aachen University */ -/* Zuse Institute Berlin (ZIB) */ -/* */ -/* This program is free software; you can redistribute it and/or */ -/* modify it under the terms of the GNU Lesser General Public License */ -/* as published by the Free Software Foundation; either version 3 */ -/* of the License, or (at your option) any later version. */ -/* */ -/* This program is distributed in the hope that it will be useful, */ -/* but WITHOUT ANY WARRANTY; without even the implied warranty of */ -/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ -/* GNU Lesser General Public License for more details. */ -/* */ -/* You should have received a copy of the GNU Lesser General Public License */ -/* along with this program; if not, write to the Free Software */ -/* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.*/ -/* */ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -/**@file columngraph.h - * @brief A row graph where each column is a node and columns are adjacent if they appear in a row - * @author Martin Bergner - */ - -/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/ - -#ifndef GCG_COLUMNGRAPH_H_ -#define GCG_COLUMNGRAPH_H_ - -#include "graph.h" -#include "bipartitegraph.h" -#include "matrixgraph.h" - -namespace gcg { -template -class ColumnGraph: public gcg::MatrixGraph -{ -private: - gcg::Graph graph; - -public: - ColumnGraph( - SCIP* scip, /**< SCIP data structure */ - Weights w /**< weights for the given graph */ - ); - virtual ~ColumnGraph(); - - virtual SCIP_RETCODE createDecompFromPartition( - DEC_DECOMP** decomp /**< decomposition structure to generate */ - ); - - virtual SCIP_RETCODE createFromMatrix( - SCIP_CONS** conss, /**< constraints for which graph should be created */ - SCIP_VAR** vars, /**< variables for which graph should be created */ - int nconss_, /**< number of constraints */ - int nvars_ /**< number of variables */ - ); -}; - -} /* namespace gcg */ -#endif /* GCG_COLUMNGRAPH_H_ */ diff --git a/headers/gcg/graph/columngraph_def.h b/headers/gcg/graph/columngraph_def.h deleted file mode 100644 index 77c17d5..0000000 --- a/headers/gcg/graph/columngraph_def.h +++ /dev/null @@ -1,229 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* */ -/* This file is part of the program */ -/* GCG --- Generic Column Generation */ -/* a Dantzig-Wolfe decomposition based extension */ -/* of the branch-cut-and-price framework */ -/* SCIP --- Solving Constraint Integer Programs */ -/* */ -/* Copyright (C) 2010-2022 Operations Research, RWTH Aachen University */ -/* Zuse Institute Berlin (ZIB) */ -/* */ -/* This program is free software; you can redistribute it and/or */ -/* modify it under the terms of the GNU Lesser General Public License */ -/* as published by the Free Software Foundation; either version 3 */ -/* of the License, or (at your option) any later version. */ -/* */ -/* This program is distributed in the hope that it will be useful, */ -/* but WITHOUT ANY WARRANTY; without even the implied warranty of */ -/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ -/* GNU Lesser General Public License for more details. */ -/* */ -/* You should have received a copy of the GNU Lesser General Public License */ -/* along with this program; if not, write to the Free Software */ -/* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.*/ -/* */ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -/**@file columngraph_def.h - * @brief A row graph where each column is a node and columns are adjacent if they appear in one row - * @author Martin Bergner - * @author Annika Thome - */ - -/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/ - -#ifndef GCG_COLUMNGRAPH_DEF_H_ -#define GCG_COLUMNGRAPH_DEF_H_ - -#include "columngraph.h" -#include -#include -#include - -namespace gcg { - -template -ColumnGraph::ColumnGraph( - SCIP* scip, /**< SCIP data structure */ - Weights w /**< weights for the given graph */ - ) : MatrixGraph(scip, w), graph(scip) -{ - this->graphiface = &graph; - this->name = std::string("columngraph"); -} - -template -ColumnGraph::~ColumnGraph() -{ - // TODO Auto-generated destructor stub -} - -template -SCIP_RETCODE ColumnGraph::createDecompFromPartition( - DEC_DECOMP** decomp -) -{ - int nblocks; - SCIP_HASHMAP* constoblock = NULL; - - int* nsubscipconss = NULL; - int i; - SCIP_CONS **conss; - SCIP_Bool emptyblocks = FALSE; - std::vector partition = graph.getPartition(); - conss = SCIPgetConss(this->scip_); - nblocks = *(std::max_element(partition.begin(), partition.end()))+1; - - SCIP_CALL( SCIPallocBufferArray(this->scip_, &nsubscipconss, nblocks) ); - BMSclearMemoryArray(nsubscipconss, nblocks); - - SCIP_CALL( SCIPhashmapCreate(&constoblock, SCIPblkmem(this->scip_), this->nconss) ); - - /* assign constraints to partition */ - for( i = 0; i < this->nconss; i++ ) - { - int block = partition[i]; - SCIP_CALL( SCIPhashmapInsert(constoblock, conss[i], (void*) (size_t) (block +1)) ); - ++(nsubscipconss[block]); - } - - /* first, make sure that there are constraints in every block, otherwise the hole thing is useless */ - for( i = 0; i < nblocks; ++i ) - { - if( nsubscipconss[i] == 0 ) - { - SCIPdebugMessage("Block %d does not have any constraints!\n", i); - emptyblocks = TRUE; - } - } - - if( !emptyblocks ) - { - SCIP_CALL( DECdecompCreate(this->scip_, decomp) ); - SCIP_CALL( DECfilloutDecompFromConstoblock(this->scip_, *decomp, constoblock, nblocks, FALSE) ); - } - else { - SCIPhashmapFree(&constoblock); - *decomp = NULL; - } - - SCIPfreeBufferArray(this->scip_, &nsubscipconss); - return SCIP_OKAY; -} - - -template -SCIP_RETCODE ColumnGraph::createFromMatrix( - SCIP_CONS** conss, /**< constraints for which graph should be created */ - SCIP_VAR** vars, /**< variables for which graph should be created */ - int nconss_, /**< number of constraints */ - int nvars_ /**< number of variables */ - ) -{ - int i; - int j; - int k; - SCIP_Bool success; - std::pair< int, int> edge; - std::vector< std::pair< int, int> > edges; - - assert(conss != NULL); - assert(vars != NULL); - assert(nvars_ > 0); - assert(nconss_ > 0); - - this->nvars = nvars_; - this->nconss = nconss_; - - /* go through all variables */ - for( i = 0; i < this->nvars; ++i ) - { - TCLIQUE_WEIGHT weight; - - /* calculate weight of node */ - weight = this->weights.calculate(vars[i]); - - this->graph.addNode(i, weight); - } - - /* go through all constraints */ - for( i = 0; i < this->nconss; ++i ) - { - SCIP_VAR** curvars = NULL; - - int ncurvars; - SCIP_CALL( SCIPgetConsNVars(this->scip_, conss[i], &ncurvars, &success) ); - assert(success); - if( ncurvars == 0 ) - continue; - - /* - * may work as is, as we are copying the constraint later regardless - * if there are variables in it or not - */ - SCIP_CALL( SCIPallocBufferArray(this->scip_, &curvars, ncurvars) ); - SCIP_CALL( SCIPgetConsVars(this->scip_, conss[i], curvars, ncurvars, &success) ); - assert(success); - - /** @todo skip all variables that have a zero coeffient or where all coefficients add to zero */ - /** @todo Do more then one entry per variable actually work? */ - - for( j = 0; j < ncurvars; ++j ) - { - SCIP_VAR* var1; - int varIndex1; - - if( SCIPgetStage(this->scip_) >= SCIP_STAGE_TRANSFORMED) - var1 = SCIPvarGetProbvar(curvars[j]); - else - var1 = curvars[j]; - - if( !GCGisVarRelevant(var1) ) - continue; - - assert(var1 != NULL); - varIndex1 = SCIPvarGetProbindex(var1); - assert(varIndex1 >= 0); - assert(varIndex1 < this->nvars); - - for( k = 0; k < j; ++k ) - { - SCIP_VAR* var2; - int varIndex2; - - if( SCIPgetStage(this->scip_) >= SCIP_STAGE_TRANSFORMED) - var2 = SCIPvarGetProbvar(curvars[k]); - else - var2 = curvars[k]; - - if( !GCGisVarRelevant(var2) ) - continue; - - assert(var2 != NULL); - varIndex2 = SCIPvarGetProbindex(var2); - assert(varIndex2 >= 0); - assert(varIndex2 < this->nvars); - - edge = std::make_pair(MIN(varIndex1, varIndex2), MAX(varIndex1, varIndex2) ); - - /* check if edge was not already added to graph */ - if(edges.end() == std::find(edges.begin(), edges.end(), edge) ) - { - - SCIP_CALL( this->graph.addEdge(varIndex1, varIndex2) ); - edges.push_back(edge); - std::sort(edges.begin(), edges.end()); - } - } - } - SCIPfreeBufferArray(this->scip_, &curvars); - } - - this->graph.flush(); - return SCIP_OKAY; -} - -} /* namespace gcg */ - -#endif diff --git a/headers/gcg/graph/graph.h b/headers/gcg/graph/graph.h deleted file mode 100644 index 2aa5e6c..0000000 --- a/headers/gcg/graph/graph.h +++ /dev/null @@ -1,226 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* */ -/* This file is part of the program */ -/* GCG --- Generic Column Generation */ -/* a Dantzig-Wolfe decomposition based extension */ -/* of the branch-cut-and-price framework */ -/* SCIP --- Solving Constraint Integer Programs */ -/* */ -/* Copyright (C) 2010-2022 Operations Research, RWTH Aachen University */ -/* Zuse Institute Berlin (ZIB) */ -/* */ -/* This program is free software; you can redistribute it and/or */ -/* modify it under the terms of the GNU Lesser General Public License */ -/* as published by the Free Software Foundation; either version 3 */ -/* of the License, or (at your option) any later version. */ -/* */ -/* This program is distributed in the hope that it will be useful, */ -/* but WITHOUT ANY WARRANTY; without even the implied warranty of */ -/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ -/* GNU Lesser General Public License for more details. */ -/* */ -/* You should have received a copy of the GNU Lesser General Public License */ -/* along with this program; if not, write to the Free Software */ -/* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.*/ -/* */ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -/**@file graph.h - * @brief miscellaneous graph methods for structure detection - * @author Martin Bergner - * @author Annika Thome - */ - -/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/ - - - -#ifndef GCG_GRAPH_H_ -#define GCG_GRAPH_H_ -#include "objscip/objscip.h" -#include "tclique/tclique.h" -#include "weights.h" -#include "pub_decomp.h" -#include "bridge.h" -#include "graph_interface.h" -#include -#include -#include - -namespace gcg { - -template -class Graph : public GraphInterface { -public: - std::string name; -protected: - SCIP* scip_; - Bridge* graph; - int nconss; - int nvars; - int nnonzeroes; - int dummynodes; - -public: - /** Constructor */ - Graph( - SCIP* scip /**< SCIP data structure */ - ); - - void swap(Graph & other) // the swap member function (should never fail!) - { - // swap all the members (and base subobject, if applicable) with other - std::swap(partition, other.partition); - std::swap(scip_ , other.scip_); - std::swap(graph , other.graph); - std::swap(nconss , other.nconss); - std::swap(nvars , other.nvars); - std::swap(nnonzeroes , other.nnonzeroes); - std::swap(dummynodes, other.dummynodes); - } - - Graph& operator=(Graph other) // note: argument passed by value! - { - // swap this with other - swap(other); - - return *this; - } - - /** Destruktor */ - virtual ~Graph(); - - /** adds n nodes in the graph at the same time. it is much faster than to call addNode() many times */ - SCIP_RETCODE addNNodes(int _n_nodes); - - /** adds n nodes in the graph at the same time. it is much faster than to call addNode() many times. weights represent node weights */ - SCIP_RETCODE addNNodes(int _n_nodes, std::vector weights); - - /** adds the node with the given weight to the graph */ - SCIP_RETCODE addNode(int i,int weight); - - /** adds the node with the 0 weight to the graph */ - SCIP_RETCODE addNode(); - - /** adds the edge to the graph */ - SCIP_RETCODE addEdge(int i, int j); - - /** adds the weighted edge to the graph */ - SCIP_RETCODE addEdge(int i, int j, double weight); - - /** sets the weight of the edge in the graph */ - SCIP_RETCODE setEdge(int i, int j, double weight); - - /** returns the weight of the edge in the graph */ - double getEdgeWeight(int i, int j); - - std::vector > getNeighborWeights(int i); - - /** return the number of nodes */ - int getNNodes(); - - /** return the number of edges (or hyperedges) */ - int getNEdges(); - - /** get list of edges in the graph (not defined how edges are implemented) */ - SCIP_RETCODE getEdges(std::vector& edges); - - /** returns whether there is an edge between nodes i and j */ - virtual int edge(int i, int j); - - /** return the number of neighbor nodes of given node */ - virtual int getNNeighbors( - int i /**< the given node */ - ); - - /** return the neighboring nodes of a given node */ - virtual std::vector getNeighbors( - int i /**< the given node */ - ); - - /** assigns partition to a given node*/ - virtual void setPartition(int i, int ID); - - /** create graph from the matrix, to be overriden by the implementation*/ - virtual SCIP_RETCODE createFromMatrix( - SCIP_CONS** conss, /**< constraints for which graph should be created */ - SCIP_VAR** vars, /**< variables for which graph should be created */ - int nconss_, /**< number of constraints */ - int nvars_ /**< number of variables */ - ) { return SCIP_ERROR; } - - /** writes the graph to the given file. - * The format is graph dependent - */ - virtual SCIP_RETCODE writeToFile( - int fd, /**< filename where the graph should be written to */ - SCIP_Bool writeweights /**< whether to write weights */ - ); - - - /** - * reads the partition from the given file. - * The format is graph dependent. The default is a file with one line for each node a - */ - virtual SCIP_RETCODE readPartition( - const char* filename /**< filename where the partition is stored */ - ); - - int getNNonzeroes() const - { - return nnonzeroes; - } - - /** return the weight of given node */ - virtual int getWeight( - int i /**< the given node */ - ); - - /** set the number of dummy nodes */ - void setDummynodes(int dummynodes_) - { - dummynodes = dummynodes_; - } - - int getDummynodes() const - { - return dummynodes; - } - - SCIP_RETCODE flush(); - - SCIP_RETCODE normalize(); - - virtual double getEdgeWeightPercentile(double q); - -#ifdef WITH_GSL - /** function needed for MST clustering */ - virtual void expand(int factor); - - /** function needed for MST clustering */ - virtual void inflate(double factor); - - /** function needed for MST clustering */ - virtual void colL1Norm(); - - /** function needed for MST clustering */ - virtual void prune(); - - /** function needed for MST clustering */ - virtual bool stopMCL(int iter); - - /** function needed for MST clustering */ - virtual std::vector getClustersMCL(); - - /** function needed for MST clustering */ - virtual void initMCL(); - - /** function needed for MST clustering */ - virtual void clearMCL(); -#endif - -}; - -} - -#endif diff --git a/headers/gcg/graph/graph_def.h b/headers/gcg/graph/graph_def.h deleted file mode 100644 index a096fd6..0000000 --- a/headers/gcg/graph/graph_def.h +++ /dev/null @@ -1,342 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* */ -/* This file is part of the program */ -/* GCG --- Generic Column Generation */ -/* a Dantzig-Wolfe decomposition based extension */ -/* of the branch-cut-and-price framework */ -/* SCIP --- Solving Constraint Integer Programs */ -/* */ -/* Copyright (C) 2010-2022 Operations Research, RWTH Aachen University */ -/* Zuse Institute Berlin (ZIB) */ -/* */ -/* This program is free software; you can redistribute it and/or */ -/* modify it under the terms of the GNU Lesser General Public License */ -/* as published by the Free Software Foundation; either version 3 */ -/* of the License, or (at your option) any later version. */ -/* */ -/* This program is distributed in the hope that it will be useful, */ -/* but WITHOUT ANY WARRANTY; without even the implied warranty of */ -/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ -/* GNU Lesser General Public License for more details. */ -/* */ -/* You should have received a copy of the GNU Lesser General Public License */ -/* along with this program; if not, write to the Free Software */ -/* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.*/ -/* */ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -/**@file graph_def.h - * @brief miscellaneous graph methods for structure detection - * @author Martin Bergner - */ - -/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/ - -#define SCIP_Debug - -#ifndef GCG_GRAPH_DEF_H_ -#define GCG_GRAPH_DEF_H_ - -#include "scip/scip.h" -#include "graph.h" - -namespace gcg { - -template -Graph::Graph( - SCIP* scip /**< SCIP data structure */ -) : name("graph"),scip_(scip),graph(NULL),nconss(0),nvars(0),nnonzeroes(0),dummynodes(0) -{ - graph = new T(); -} - -template -Graph::~Graph() -{ - if(graph != NULL) - delete graph; - -} - -template -SCIP_RETCODE Graph::addNNodes(int _n_nodes) -{ - return graph->addNNodes(_n_nodes); -} - -template -SCIP_RETCODE Graph::addNNodes(int _n_nodes, std::vector weights) -{ - return graph->addNNodes(_n_nodes, weights); -} - -template -int Graph::getNNodes() { - return graph->getNNodes(); -} - -template -int Graph::getNEdges() { - return graph->getNEdges(); -} - -template -SCIP_RETCODE Graph::getEdges(std::vector& edges) -{ - return graph->getEdges(edges); -} - -template -SCIP_RETCODE Graph::addNode(int i,int weight) -{ - SCIP_CALL( graph->addNode(i, weight) ); - return SCIP_OKAY; -} - -template -SCIP_RETCODE Graph::addNode() -{ - SCIP_CALL( graph->addNode() ); - return SCIP_OKAY; -} - -/** adds the edge to the graph */ -template -SCIP_RETCODE Graph::addEdge(int i, int j) -{ - SCIP_CALL( graph->addEdge(i, j) ); - return SCIP_OKAY; -} - -template -SCIP_RETCODE Graph::flush() -{ - SCIP_CALL( graph->flush() ); - return SCIP_OKAY; -} - -template -SCIP_RETCODE Graph::normalize() -{ - SCIP_CALL( graph->normalize() ); - return SCIP_OKAY; -} - -template -int Graph::edge(int i, int j) { - assert( i>= 0); - assert(j >= 0); - - int edge_ij=0; - std::vector Neighbors; - - Neighbors = getNeighbors(i); - for(int k=0; k<(int)Neighbors.size(); k++) - { - if(Neighbors[k] == j) - { - edge_ij = 1; - k = (int)Neighbors.size(); - } - } - return edge_ij; -} - -template -int Graph::getNNeighbors(int i) { - assert( i >= 0); - return graph->getNNeighbors(i); -} - -template -std::vector Graph::getNeighbors(int i) { - assert(i >= 0); - - return graph->getNeighbors(i); -} - -template -void Graph::setPartition(int i, int ID) { - partition.resize(getNNodes(), -1); - partition[i] = ID; -} - -/** write the graph to a file */ -template -SCIP_RETCODE Graph::writeToFile( - int fd, - SCIP_Bool writeweights - ) -{ - int nnodes; - int nedges; - FILE* file; - file = fdopen(fd, "wx"); - if( file == NULL ) - return SCIP_FILECREATEERROR; - - nnodes = Graph::getNNodes(); - nedges = Graph::getNEdges(); - - SCIPinfoMessage(scip_, file, "%d %d\n", nnodes+dummynodes, nedges/2); - - for( int i = 0; i < nnodes; ++i ) - { - int nneighbors = Graph::getNNeighbors(i); - std::vector neighbors = Graph::getNeighbors(i); - - if( writeweights ) - { - SCIPinfoMessage(scip_, file, "%d ", Graph::getWeight(i)); - } - for( int j = 0; j < nneighbors; ++j ) - { - SCIPinfoMessage(scip_, file, "%d ", neighbors[j]+1); - } - SCIPinfoMessage(scip_, file, "\n"); - } - - for( int i = 0; i < dummynodes; ++i ) - { - SCIPinfoMessage(scip_, file, "\n"); - } - - return SCIP_OKAY; -} - - -/** read in the partition from a file */ -template -SCIP_RETCODE Graph::readPartition( - const char* filename -) -{ - ifstream input(filename); - if( !input.good() ) - { - SCIPerrorMessage("Could not open file <%s> for reading\n", filename); - return SCIP_READERROR; - } - partition.resize(getNNodes(), -1); - for( int i = 0; i < getNNodes(); ++i ) - { - int part = 0; - if( !(input >> part) ) - { - SCIPerrorMessage("Could not read from file <%s>. It may be in the wrong format\n", filename); - return SCIP_READERROR; - } - partition[i] = part; - } - - input.close(); - return SCIP_OKAY; -} - -/** return the weight of given node */ -template -int Graph::getWeight( - int i /**< the given node */ - ) -{ - return graph->graphGetWeights(i); -} - - -/** adds the weighted edge to the graph */ -template -SCIP_RETCODE Graph::addEdge(int i, int j, double weight) -{ - SCIP_CALL( graph->addEdge(i, j, weight) ); - return SCIP_OKAY; -} - -/** sets the weight of the edge in the graph */ -template -SCIP_RETCODE Graph::setEdge(int i, int j, double weight) -{ - SCIP_CALL( graph->setEdge(i, j, weight) ); - return SCIP_OKAY; -} - -/** returns the weight of the edge in the graph */ -template -double Graph::getEdgeWeight(int i, int j) -{ - return graph->getEdgeWeight(i, j); -} - -template -std::vector > Graph::getNeighborWeights(int i) -{ - return graph->getNeighborWeights(i); -} - - -template -double Graph::getEdgeWeightPercentile(double q) -{ - return graph->getEdgeWeightPercentile(q); -} - - - -#ifdef WITH_GSL - -template -void Graph::expand(int factor) -{ - graph->expand(factor); -} - -template -void Graph::inflate(double factor) -{ - graph->inflate(factor); -} - -template -void Graph::colL1Norm() -{ - graph->colL1Norm(); -} - -template -void Graph::prune() -{ - graph->prune(); -} - -template -bool Graph::stopMCL(int iter) -{ - return graph->stopMCL(iter); -} - -template -std::vector Graph::getClustersMCL() -{ - return graph->getClustersMCL(); -} - - -template -void Graph::initMCL() -{ - graph->initMCL(); -} - -template -void Graph::clearMCL() -{ - graph->clearMCL(); -} - - - -#endif - - -} /* namespace gcg */ - -#endif diff --git a/headers/gcg/graph/graph_gcg.h b/headers/gcg/graph/graph_gcg.h deleted file mode 100644 index d908a5f..0000000 --- a/headers/gcg/graph/graph_gcg.h +++ /dev/null @@ -1,119 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* */ -/* This file is part of the program */ -/* GCG --- Generic Column Generation */ -/* a Dantzig-Wolfe decomposition based extension */ -/* of the branch-cut-and-price framework */ -/* SCIP --- Solving Constraint Integer Programs */ -/* */ -/* Copyright (C) 2010-2022 Operations Research, RWTH Aachen University */ -/* Zuse Institute Berlin (ZIB) */ -/* */ -/* This program is free software; you can redistribute it and/or */ -/* modify it under the terms of the GNU Lesser General Public License */ -/* as published by the Free Software Foundation; either version 3 */ -/* of the License, or (at your option) any later version. */ -/* */ -/* This program is distributed in the hope that it will be useful, */ -/* but WITHOUT ANY WARRANTY; without even the implied warranty of */ -/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ -/* GNU Lesser General Public License for more details. */ -/* */ -/* You should have received a copy of the GNU Lesser General Public License */ -/* along with this program; if not, write to the Free Software */ -/* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.*/ -/* */ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -/**@file graph_gcg.h - * @brief Implementation of the graph which supports both node and edge weights. - * @author Igor Pesic - */ - -/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/ - -#ifndef GCG_GRAPH_GCG_H_ -#define GCG_GRAPH_GCG_H_ - -#include -#include "bridge.h" - -#ifdef WITH_GSL - #include - #include -#endif - -namespace gcg { - -class EdgeGCG -{ -public: - int src, dest; - double weight; - EdgeGCG(): src(-1), dest(-1), weight(0.0) {} - EdgeGCG(int s, int d, double w): src(s), dest(d), weight(w) {} -} ; - -class GraphGCG: public gcg::Bridge -{ -private: - bool undirected; - bool locked; // true if we are not allowed to change the graph anymore - bool initialized; // true if at least 1 node - std::vector nodes; -#ifdef WITH_GSL - gsl_spmatrix* adj_matrix_sparse; - gsl_spmatrix* working_adj_matrix; // this one is used ONLY during MCL algorithm! -#else - std::vector> adj_matrix; /** For undirected graphs, this matrix is symmetrical */ -#endif - std::vector edges; - -public: - - GraphGCG(); - GraphGCG(int _n_nodes, bool _undirected); - - virtual ~GraphGCG(); - virtual SCIP_RETCODE addNNodes(int _n_nodes); - virtual SCIP_RETCODE addNNodes(int _n_nodes, std::vector weights); - virtual int getNNodes(); - virtual int getNEdges(); - -#ifdef WITH_GSL - virtual gsl_spmatrix* getAdjMatrix(); - virtual void expand(int factor); - virtual void inflate(double factor); - virtual void colL1Norm(); - virtual void prune(); - virtual bool stopMCL(int iter); - virtual std::vector getClustersMCL(); - virtual void initMCL(); - virtual void clearMCL(); -#else - virtual std::vector> getAdjMatrix(); -#endif - virtual SCIP_RETCODE getEdges(std::vector& edges); - virtual SCIP_Bool isEdge(int node_i, int node_j); - virtual int getNNeighbors(int node); - virtual std::vector getNeighbors(int node); - virtual std::vector > getNeighborWeights(int node); - virtual SCIP_RETCODE addNode(int node, int weight); - virtual SCIP_RETCODE addNode(); /** Sets node weight to 0 and the ID to the next available. */ - virtual SCIP_RETCODE deleteNode(int node); - virtual SCIP_RETCODE addEdge(int i, int j); /** Sets edge weight to 1. */ - virtual SCIP_RETCODE addEdge(int node_i, int node_j, double weight); - virtual SCIP_RETCODE setEdge(int node_i, int node_j, double weight); - virtual SCIP_RETCODE deleteEdge(int node_i, int node_j); - virtual int graphGetWeights(int node); - virtual double getEdgeWeight(int node_i, int node_j); - - virtual int edgeComp(const EdgeGCG* a, const EdgeGCG* b); - - virtual SCIP_RETCODE flush(); // lock the graph and compresses the adj matrix if we use GSL - virtual SCIP_RETCODE normalize(); - virtual double getEdgeWeightPercentile(double q); -}; - -} /* namespace gcg */ -#endif /* GCG_GRAPH_GCG_H_ */ diff --git a/headers/gcg/graph/graph_interface.h b/headers/gcg/graph/graph_interface.h deleted file mode 100644 index 9cec11c..0000000 --- a/headers/gcg/graph/graph_interface.h +++ /dev/null @@ -1,97 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* */ -/* This file is part of the program */ -/* GCG --- Generic Column Generation */ -/* a Dantzig-Wolfe decomposition based extension */ -/* of the branch-cut-and-price framework */ -/* SCIP --- Solving Constraint Integer Programs */ -/* */ -/* Copyright (C) 2010-2022 Operations Research, RWTH Aachen University */ -/* Zuse Institute Berlin (ZIB) */ -/* */ -/* This program is free software; you can redistribute it and/or */ -/* modify it under the terms of the GNU Lesser General Public License */ -/* as published by the Free Software Foundation; either version 3 */ -/* of the License, or (at your option) any later version. */ -/* */ -/* This program is distributed in the hope that it will be useful, */ -/* but WITHOUT ANY WARRANTY; without even the implied warranty of */ -/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ -/* GNU Lesser General Public License for more details. */ -/* */ -/* You should have received a copy of the GNU Lesser General Public License */ -/* along with this program; if not, write to the Free Software */ -/* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.*/ -/* */ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -/**@file graph_interface.h - * @brief miscellaneous graph interface methods - * @author Martin Bergner - * @author Annika Thome - */ - -/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/ - - - -#ifndef GCG_GRAPHINTERFACE_H_ -#define GCG_GRAPHINTERFACE_H_ - -#include "objscip/objscip.h" -#include "weights.h" - -#include -#include - -using std::ifstream; -namespace gcg { - -class GraphInterface { -protected: - std::vector partition; -public: - - GraphInterface() {} - - virtual ~GraphInterface() {} - - /** return a partition of the nodes */ - virtual std::vector getPartition() const { return partition; } - - /** assigns partition to a given node*/ - virtual void setPartition(int i, int nodeid) = 0; - - /** writes the graph to the given file. - * The format is graph dependent - */ - virtual SCIP_RETCODE writeToFile( - int fd, /**< filename where the graph should be written to */ - SCIP_Bool writeweights /**< whether to write weights */ - ) = 0; - - - /** - * reads the partition from the given file. - * The format is graph dependent. The default is a file with one line for each node a - */ - virtual SCIP_RETCODE readPartition( - const char* filename /**< filename where the partition is stored */ - ) = 0; - - - /** create decomposition based on the read in partition */ - virtual SCIP_RETCODE createDecompFromPartition( - DEC_DECOMP** decomp /**< decomposition structure to generate */ - ) - { /*lint -e715*/ - return SCIP_ERROR; - } - - virtual SCIP_RETCODE flush() = 0; - -}; - -} - -#endif diff --git a/headers/gcg/graph/graph_tclique.h b/headers/gcg/graph/graph_tclique.h deleted file mode 100644 index c2e5979..0000000 --- a/headers/gcg/graph/graph_tclique.h +++ /dev/null @@ -1,90 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* */ -/* This file is part of the program */ -/* GCG --- Generic Column Generation */ -/* a Dantzig-Wolfe decomposition based extension */ -/* of the branch-cut-and-price framework */ -/* SCIP --- Solving Constraint Integer Programs */ -/* */ -/* Copyright (C) 2010-2022 Operations Research, RWTH Aachen University */ -/* Zuse Institute Berlin (ZIB) */ -/* */ -/* This program is free software; you can redistribute it and/or */ -/* modify it under the terms of the GNU Lesser General Public License */ -/* as published by the Free Software Foundation; either version 3 */ -/* of the License, or (at your option) any later version. */ -/* */ -/* This program is distributed in the hope that it will be useful, */ -/* but WITHOUT ANY WARRANTY; without even the implied warranty of */ -/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ -/* GNU Lesser General Public License for more details. */ -/* */ -/* You should have received a copy of the GNU Lesser General Public License */ -/* along with this program; if not, write to the Free Software */ -/* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.*/ -/* */ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -/**@file graph_tclique.h - * @brief interface to the SCIP tclique graph library - * @author Annika Thome - * @author Martin Bergner - */ - -/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/ - -#ifndef GCG_GRAPH_TCLIQUE_H_ -#define GCG_GRAPH_TCLIQUE_H_ - -#include "bridge.h" -#include "tclique/tclique.h" - -namespace gcg { - -class GraphTclique: public gcg::Bridge -{ -private: - TCLIQUE_GRAPH* graph; - -public: - - GraphTclique(); - - virtual ~GraphTclique(); - virtual SCIP_RETCODE addNNodes(int _n_nodes); - virtual SCIP_RETCODE addNNodes(int _n_nodes, std::vector weights); - virtual int getNNodes(); - virtual int getNEdges(); - virtual SCIP_RETCODE getEdges(std::vector& edges); - virtual SCIP_Bool isEdge(int i, int j); - virtual int getNNeighbors(int i); - virtual std::vector getNeighbors(int i); - virtual SCIP_RETCODE addNode(int i, int weight); - virtual SCIP_RETCODE addNode(); - virtual SCIP_RETCODE deleteNode(int i); - virtual SCIP_RETCODE addEdge(int i, int j); - virtual SCIP_RETCODE addEdge(int i, int j, double weight); - virtual SCIP_RETCODE setEdge(int i, int j, double weight); - virtual double getEdgeWeight(int i, int j); - virtual std::vector > getNeighborWeights(int i); - virtual SCIP_RETCODE deleteEdge(int i, int j); - virtual int graphGetWeights(int i); - - virtual SCIP_RETCODE flush(); - virtual SCIP_RETCODE normalize(); - virtual double getEdgeWeightPercentile(double q); - -#ifdef WITH_GSL - void expand(int factor) {return;} - void inflate(double factor) {return;} - void colL1Norm() {return;} - void prune() {return;} - bool stopMCL(int iter) {return true;} - std::vector getClustersMCL() {return std::vector();} - virtual void initMCL() {return;} - virtual void clearMCL() {return;} -#endif -}; - -} /* namespace gcg */ -#endif /* GCG_GRAPH_TCLIQUE_H_ */ diff --git a/headers/gcg/graph/graphalgorithms.h b/headers/gcg/graph/graphalgorithms.h deleted file mode 100644 index ba823bf..0000000 --- a/headers/gcg/graph/graphalgorithms.h +++ /dev/null @@ -1,149 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* */ -/* This file is part of the program */ -/* GCG --- Generic Column Generation */ -/* a Dantzig-Wolfe decomposition based extension */ -/* of the branch-cut-and-price framework */ -/* SCIP --- Solving Constraint Integer Programs */ -/* */ -/* Copyright (C) 2010-2022 Operations Research, RWTH Aachen University */ -/* Zuse Institute Berlin (ZIB) */ -/* */ -/* This program is free software; you can redistribute it and/or */ -/* modify it under the terms of the GNU Lesser General Public License */ -/* as published by the Free Software Foundation; either version 3 */ -/* of the License, or (at your option) any later version. */ -/* */ -/* This program is distributed in the hope that it will be useful, */ -/* but WITHOUT ANY WARRANTY; without even the implied warranty of */ -/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ -/* GNU Lesser General Public License for more details. */ -/* */ -/* You should have received a copy of the GNU Lesser General Public License */ -/* along with this program; if not, write to the Free Software */ -/* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.*/ -/* */ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -/**@file graphalgorithms.h - * @brief several metrics for graphs - * @author Martin Bergner - */ - -/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/ - -#ifndef GRAPHALGORITHMS_H_ -#define GRAPHALGORITHMS_H_ - -#include "hypergraph.h" -#include "graph.h" -#include "graph_gcg.h" - -namespace gcg { - -// A structure to represent a subset for union-find -typedef struct subset -{ - int parent; - int rank; -} subset; - - -template -class GraphAlgorithms { - -public: - /** compute weighted sum of external degrees */ - static SCIP_Real computeSoed( - Hypergraph& graph /**< the hypergraph */ - ); - - /** compute minimum hyperedge cut */ - static SCIP_Real computeMincut( - Hypergraph& graph /**< the hypergraph */ - ); - - /** compute k-1 metric */ - static SCIP_Real computekMetric( - Hypergraph& graph /**< the hypergraph */ - ); - - /** run DBSCAN on the distance graph */ - static std::vector dbscan( - Graph& graph, /**< the graph with weighted edges */ - double eps, /**< radius in which we search for the neighbors */ - int minPts = 4 /**< minimum number of neighbors needed to define a core point (can be fixed to 4 as stated in the paper) */ - ); - - - /** run MST on the distance graph */ - static std::vector mst( - Graph& graph, /**< the graph with weighted edges */ - double cutoff, /**< threshold below which we cut the edges */ - int minPts = 4 /**< minimum number of points needed in a cluster */ - ); - - - /** run MCL on the similarity graph */ - static std::vector mcl( - Graph& graph, /**< the graph with weighted edges */ - int& stoppedAfter, /**< number of iterations after which the clustering terminated */ - double inflatefac, /**< inflate factor */ - int maxiters = 25, /**< max number of iterations, set to 25 per default */ - int expandfac = 2 /**< expand factor, should be always set to 2 */ - ); - - - - -//private: - - /** help function for DBSCAN */ - static void expandCluster( - Graph& graph, - std::vector& visited, - std::vector& is_core, - std::vector& labels, - int point, - std::vector& NeighborPts, - int curr_cluster, - double eps, - int minPts - ); - - static double cutoff; - - // Returns true if the weight of the edge is bigger than the this->cutoff - static bool cutoffif( - EdgeGCG &a - ); - - // Compare two edges according to their weights. - // Used in sort() for sorting an array of edges - static int weightComp( - const void* a, - const void* b - ); - - // A utility function to find set of an element i - // (uses path compression technique) - static int mstfind( - std::vector& subsets, - int i - ); - - // A function that does union of two sets of x and y - // (uses union by rank) - static void mstunion( - std::vector& subsets, - int x, - int y - ); - -}; - -} /* namespace gcg */ - - - -#endif /* GRAPHALGORITHMS_H_ */ diff --git a/headers/gcg/graph/graphalgorithms_def.h b/headers/gcg/graph/graphalgorithms_def.h deleted file mode 100644 index d3d9b29..0000000 --- a/headers/gcg/graph/graphalgorithms_def.h +++ /dev/null @@ -1,474 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* */ -/* This file is part of the program */ -/* GCG --- Generic Column Generation */ -/* a Dantzig-Wolfe decomposition based extension */ -/* of the branch-cut-and-price framework */ -/* SCIP --- Solving Constraint Integer Programs */ -/* */ -/* Copyright (C) 2010-2022 Operations Research, RWTH Aachen University */ -/* Zuse Institute Berlin (ZIB) */ -/* */ -/* This program is free software; you can redistribute it and/or */ -/* modify it under the terms of the GNU Lesser General Public License */ -/* as published by the Free Software Foundation; either version 3 */ -/* of the License, or (at your option) any later version. */ -/* */ -/* This program is distributed in the hope that it will be useful, */ -/* but WITHOUT ANY WARRANTY; without even the implied warranty of */ -/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ -/* GNU Lesser General Public License for more details. */ -/* */ -/* You should have received a copy of the GNU Lesser General Public License */ -/* along with this program; if not, write to the Free Software */ -/* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.*/ -/* */ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -/**@file graphalgorithms_def.h - * @brief several metrics for graphs - * @author Martin Bergner - */ - -/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/ - -#ifndef GCG_GRAPHALGORITHMS_DEF_H_ -#define GCG_GRAPHALGORITHMS_DEF_H_ - -#include "graph/graphalgorithms.h" -#include -#include -#include -#include -#include "stdlib.h" -#include "graph/graph_tclique.h" -#include "graph/graph_gcg.h" - - -using std::vector; - - -namespace gcg { - -template -double GraphAlgorithms::cutoff = 0.0; - - -/** compute weighted sum of external degrees */ -template -double GraphAlgorithms::computeSoed( - Hypergraph& graph /**< the hypergraph */ -) -{ - SCIP_Real soed = 0.0; - size_t nedges = graph.getNHyperedges(); - vector partition = vector(graph.getPartition()); - - for( size_t i = 0; i < nedges; ++i ) - { - vector nodes = graph.getHyperedgeNodes(i); - for( auto &it : nodes) - { - it = partition[it]; - } - auto end = std::unique(nodes.begin(), nodes.end()); - if( end - nodes.begin() > 1) - soed += ( end - nodes.begin())*graph.getHyperedgeWeight(i); - } - return soed; -} - -/** compute minimum hyperedge cut */ -template -double GraphAlgorithms::computeMincut( - Hypergraph& graph /**< the hypergraph */ -) -{ - SCIP_Real mincut = 0.0; - size_t nedges = graph.getNHyperedges(); - vector partition = vector(graph.getPartition()); - - for( size_t i = 0; i < nedges; ++i ) - { - vector nodes = graph.getHyperedgeNodes(i); - for( auto &it : nodes) - { - it = partition[it]; - } - auto end = std::unique(nodes.begin(), nodes.end()); - - if( end - nodes.begin() > 1) - mincut += graph.getHyperedgeWeight(i); - } - - return mincut; -} - -/** compute k-1 metric */ -template -double GraphAlgorithms::computekMetric( - Hypergraph& graph /**< the hypergraph */ -) -{ - SCIP_Real kmetric = 0.0; - size_t nedges = graph.getNHyperedges(); - vector partition = vector(graph.getPartition()); - - for( size_t i = 0; i < nedges; ++i ) - { - vector nodes = graph.getHyperedgeNodes(i); - for( auto &it : nodes) - { - it = partition[it]; - } - auto end = std::unique(nodes.begin(), nodes.end()); - - kmetric += ( end - nodes.begin() -1)*graph.getHyperedgeWeight(i); - } - - return kmetric; -} - - -/** run DBSCAN on the distance graph */ -template -std::vector GraphAlgorithms::dbscan( - Graph& graph, /**< the graph with weighted edges */ - double eps, /**< radius in which we search for the neighbors */ - int minPts /**< minimum number of neighbors needed to define a core point (can be fixed to 4 as stated in the paper) */ -) -{ - - int n_nodes = graph.getNNodes(); - std::vector visited(n_nodes, false); - std::vector is_core(n_nodes, false); - std::vector labels(n_nodes, -1); - int curr_cluster = -1; - - // visit all the points and check for the core points - for(int i = 0; i < n_nodes; i++) - { - if(visited[i]) - { - continue; - } - visited[i] = true; - - // check if i is a core point - std::vector > NeighborPts_row = graph.getNeighborWeights(i); // gets ALL connected points - std::vector NeighborPts; // holds ONLY the neighbors within the radius - for(int j = 0; j < (int)NeighborPts_row.size(); j++) - { - if(NeighborPts_row[j].second <= eps) - { - NeighborPts.push_back(NeighborPts_row[j].first); - } - - } - if((int)NeighborPts.size() < minPts) - { - labels[i] = -1; // mark point as noise - } - else { - curr_cluster++; - expandCluster(graph, visited, is_core, labels, i, NeighborPts, curr_cluster, eps, minPts); - } - } - - // Add border points also. We assign the border point the same label as the first core point. This is basically arbitrary, but not random. - for(int i = 0; i < n_nodes; i++) - { - if(is_core[i]) - { - continue; - } - std::vector > NeighborPts_row = graph.getNeighborWeights(i); // gets ALL connected points // holds ONLY the neighbors within the radius - for(int j = 0; j < (int)NeighborPts_row.size(); j++) - { - if(NeighborPts_row[j].second <= eps && is_core[NeighborPts_row[j].first]) - { - labels[i] = labels[NeighborPts_row[j].first]; - break; - } - } - } - - return labels; -} - -/** help function for DBSCAN */ -template -void GraphAlgorithms::expandCluster( - Graph& graph, - std::vector& visited, - std::vector& is_core, - std::vector& labels, - int point, - std::vector& NeighborPts, - int curr_cluster, - double eps, - int minPts -) -{ - // add P to cluster C - labels[point] = curr_cluster; - is_core[point] = true; - - // for each point P' in NeighborPts - for(int i = 0; i < (int)NeighborPts.size(); i++) - { - int neighbor = NeighborPts[i]; - // if P' is not visited { - if(!visited[neighbor]) - { - // mark P' as visited - visited[neighbor] = true; - // NeighborPts' = regionQuery(P', eps) - std::vector > NeighborPts_tmp_row = graph.getNeighborWeights(neighbor); // gets ALL connected points - std::vector NeighborPts_tmp; // holds ONLY the neighbors within the radius - for(int j = 0; j < (int)NeighborPts_tmp_row.size(); j++) - { - if(NeighborPts_tmp_row[j].second <= eps) - { - NeighborPts_tmp.push_back(NeighborPts_tmp_row[j].first); - } - - } - if((int)NeighborPts_tmp.size() >= minPts) - { - // NeighborPts = NeighborPts joined with NeighborPts' - NeighborPts.insert(NeighborPts.end(), NeighborPts_tmp.begin(), NeighborPts_tmp.end()); - } - - } - - // if P' is not yet member of any cluster - // add P' to cluster C - if(labels[neighbor] < 0) - { - labels[neighbor] = curr_cluster; - is_core[neighbor] = true; - } - } -} - -/* - * template - * std::vector GraphAlgorithms::mst( - */ -template -std::vector GraphAlgorithms::mst( - Graph& graph, /**< the graph with weighted edges */ - double _cutoff, /**< threshold below which we cut the edges */ - int minPts /**< minimum number of points needed in a cluster */ -) -{ - cutoff = _cutoff; - // Step 1: find a minimum spanning tree using Kruskal's algorithm - - int nnodes = graph.getNNodes(); - std::vector edges(graph.getNEdges()); - graph.getEdges(edges); - - vector resultMST(nnodes-1); - int e = 0; // An index variable, used for resultMST - unsigned int j = 0; // An index variable, used for sorted edges - - // Step 1: Sort all the edges in non-decreasing order of their weight - // If we are not allowed to change the given graph, we can create a copy of - // array of edges - sort(edges.begin(), edges.end(), weightComp); - - // Create V subsets (one for each node) - vector subsetsmst(nnodes); - - // Create V subsets with single elements - for (int v = 0; v < nnodes; ++v) - { - subsetsmst[v].parent = v; - subsetsmst[v].rank = 0; - } - - // Number of edges to be taken is equal to V-1 - while (e < nnodes - 1) - { - // Step 2: Pick the smallest edge. And increment the index - // for next iteration - if(j == edges.size()) break; - EdgeGCG next_edge = *(EdgeGCG *)(edges[j++]); - assert(next_edge.src < graph.getNNodes()); - assert(next_edge.dest < graph.getNNodes()); - - int x = mstfind(subsetsmst, next_edge.src); // O(tree height) - int y = mstfind(subsetsmst, next_edge.dest); - - // If including this edge does't cause cycle, include it - // in result and increment the index of result for next edge - if (x != y) - { - resultMST[e++] = next_edge; - mstunion(subsetsmst, x, y); - } - // Else discard the next_edge - } - - resultMST.resize(e); - - // Step 2: remove all the edges from the MST that are greater or equal to cutoff - - //std::vector resultDBG = resultMST; - resultMST.erase(std::remove_if(resultMST.begin(), resultMST.end(), cutoffif), resultMST.end()); - // Step 3: use find-union to find the graph components - - // saves the component labels (i.e. cluster labels) - std::vector labels(nnodes, -1); - - // Create V subsets (one for each node) - std::vector subsetscomp(nnodes); - - // Create V subsets with single elements - for (int v = 0; v < nnodes; ++v) - { - subsetscomp[v].parent = v; - subsetscomp[v].rank = 0; - } - - - // iterate all the edges and assign its nodes to the root node of the set - for(unsigned int edge_it = 0; edge_it < resultMST.size(); edge_it++) - { - auto edge = resultMST[edge_it]; - /*if(!(edge.src < graph.getNNodes()) || !(edge.dest < graph.getNNodes())){ - cout << "DEBUG ME!!!" << endl; - }*/ - assert(edge.src < graph.getNNodes()); - assert(edge.dest < graph.getNNodes()); - // if the nodes are directly connected, put them in the same set - mstunion(subsetscomp, edge.src, edge.dest); - } - - for(int i = 0; i < nnodes; i++) - { - labels[i] = mstfind(subsetscomp, i); - } - - - // remove the clusters that are smaller than minPts - std::map labelcount; - for(int i = 0; i < nnodes; i++) - { - labelcount[labels[i]]++; - } - - for(int i = 0; i < nnodes; i++) - { - if(labelcount[labels[i]] < minPts) - labels[i] = -1; - } - - - // reassign the labels so that they start from 0 (actually this is done in postProcess, so we can skip this part here) - - - return labels; -} - - -template -bool GraphAlgorithms::cutoffif(EdgeGCG &a) -{ - return a.weight > cutoff; -} - - -// Compare two edges according to their weights. -// Used in sort() for sorting an array of edges -template -int GraphAlgorithms::weightComp(const void* a, const void* b) -{ - const EdgeGCG* a1 = static_cast(a); - const EdgeGCG* b1 = static_cast(b); - return a1->weight < b1->weight; -} - - -// A utility function to find set of an element i -// (uses path compression technique) -template -int GraphAlgorithms::mstfind(std::vector& subsets, int i) -{ - // find root and make root as parent of i (path compression) - if (subsets[i].parent != i) - subsets[i].parent = mstfind(subsets, subsets[i].parent); - - return subsets[i].parent; -} - - -// A function that does union of two sets of x and y -// (uses union by rank) -template -void GraphAlgorithms::mstunion(std::vector& subsets, int x, int y) -{ - int xroot = mstfind(subsets, x); - int yroot = mstfind(subsets, y); - - // Attach smaller rank tree under root of high rank tree - // (Union by Rank) - if (subsets[xroot].rank < subsets[yroot].rank) - subsets[xroot].parent = yroot; - else if (subsets[xroot].rank > subsets[yroot].rank) - subsets[yroot].parent = xroot; - - // If ranks are same, then make one as root and increment - // its rank by one - else - { - subsets[yroot].parent = xroot; - subsets[xroot].rank++; - } -} - - -template -std::vector GraphAlgorithms::mcl( - Graph& graph, /**< the graph with weighted edges */ - int& stoppedAfter, /**< number of iterations after which the clustering terminated */ - double inflatefac, /**< inflate factor */ - int maxiters, /**< max number of iterations, set to 25 per default */ - int expandfac /**< expand factor, should be always set to 2 */ -) -{ -#ifdef WITH_GSL - graph.initMCL(); - graph.colL1Norm(); - graph.prune(); - - int i = 0; - for(; i < maxiters; i++) - { - graph.inflate(inflatefac); - graph.expand(expandfac); - graph.prune(); - - if(graph.stopMCL(i)) - { - break; - } - } - assert(i > 6); - stoppedAfter = i; - - std::vector res = graph.getClustersMCL(); - graph.clearMCL(); - return res; -#else - return vector(); -#endif -} - - - - -} /* namespace gcg */ -#endif diff --git a/headers/gcg/graph/hypercolgraph.h b/headers/gcg/graph/hypercolgraph.h deleted file mode 100644 index 62cb7b1..0000000 --- a/headers/gcg/graph/hypercolgraph.h +++ /dev/null @@ -1,138 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* */ -/* This file is part of the program */ -/* GCG --- Generic Column Generation */ -/* a Dantzig-Wolfe decomposition based extension */ -/* of the branch-cut-and-price framework */ -/* SCIP --- Solving Constraint Integer Programs */ -/* */ -/* Copyright (C) 2010-2022 Operations Research, RWTH Aachen University */ -/* Zuse Institute Berlin (ZIB) */ -/* */ -/* This program is free software; you can redistribute it and/or */ -/* modify it under the terms of the GNU Lesser General Public License */ -/* as published by the Free Software Foundation; either version 3 */ -/* of the License, or (at your option) any later version. */ -/* */ -/* This program is distributed in the hope that it will be useful, */ -/* but WITHOUT ANY WARRANTY; without even the implied warranty of */ -/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ -/* GNU Lesser General Public License for more details. */ -/* */ -/* You should have received a copy of the GNU Lesser General Public License */ -/* along with this program; if not, write to the Free Software */ -/* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.*/ -/* */ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -/**@file hypercolgraph.h - * @brief Column hypergraph - * @author Martin Bergner - */ - -/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/ - -#ifndef GCG_HYPERCOLGRAPH_H_ -#define GCG_HYPERCOLGRAPH_H_ - -#include "matrixgraph.h" -#include "hypergraph.h" -#include "class_partialdecomp.h" -#include "class_detprobdata.h" - -namespace gcg -{ -template -class HypercolGraph: public gcg::MatrixGraph -{ - -private: - Hypergraph graph; -protected: - class function { - int diff; - public: - function(int i):diff(i) {} - int operator()(int i) { return i-diff;} - }; - -public: - HypercolGraph( - SCIP* scip, /**< SCIP data structure */ - Weights w /**< weights for the given graph */ - ); - - virtual ~HypercolGraph(); - - /** writes the graph to the given file. - * The format is graph dependent - */ - SCIP_RETCODE writeToFile( - int fd, /**< filename where the graph should be written to */ - SCIP_Bool edgeweights /**< whether to write edgeweights */ - ); - - /** return the number of nodes */ - virtual int getNNodes(); - - /** return the number of edges (or hyperedges) */ - virtual int getNEdges(); - - virtual std::vector getNeighbors( - int i - ) - { - return this->graph.getNeighbors(i); - } - - virtual std::vector getHyperedgeNodes( - int i - ); - - /** - * reads the partition from the given file. - * The format is graph dependent. The default is a file with one line for each node a - */ - virtual SCIP_RETCODE readPartition( - const char* filename /**< filename where the partition is stored */ - ) - { - SCIP_CALL( this->graph.readPartition(filename) ); - return SCIP_OKAY; - } - - virtual SCIP_RETCODE createFromMatrix( - SCIP_CONS** conss, /**< constraints for which graph should be created */ - SCIP_VAR** vars, /**< variables for which graph should be created */ - int nconss_, /**< number of constraints */ - int nvars_ /**< number of variables */ - ); - - /** creates a graph with open constraints and open variables of the partialdec */ - virtual SCIP_RETCODE createFromPartialMatrix( - DETPROBDATA* detprobdata, /**< detection process information and data */ - PARTIALDECOMP* partialdec /**< partial decomposition to use for graph */ - ); - - virtual SCIP_RETCODE createDecompFromPartition( - DEC_DECOMP** decomp /**< decomposition structure to generate */ - ); - - /** creates a new partialdec by dint of a graph created with all constraints and variables */ - virtual SCIP_RETCODE createPartialdecFromPartition( - PARTIALDECOMP** firstpartialdec, /**< pointer to buffer the new partialdec created by dint of the graph */ - PARTIALDECOMP** secondpartialdec, /**< pointer to buffer the new partialdec whose border is amplified by dint of the graph */ - DETPROBDATA* detprobdata /**< detection process information and data */ - ); - - /** amplifies a partialdec by dint of a graph created with open constraints and open variables of the partialdec */ - virtual SCIP_RETCODE createPartialdecFromPartition( - PARTIALDECOMP* oldpartialdec, /**< partialdec which should be amplifies */ - PARTIALDECOMP** firstpartialdec, /**< pointer to buffer the new partialdec amplified by dint of the graph */ - PARTIALDECOMP** secondpartialdec, /**< pinter to buffer the new partialdec whose border is amplified by dint of the graph */ - DETPROBDATA* detprobdata /**< detection process information and data */ - ); -}; - -} /* namespace gcg */ -#endif /* GCG_HYPERCOLGRAPH_H_ */ diff --git a/headers/gcg/graph/hypercolgraph_def.h b/headers/gcg/graph/hypercolgraph_def.h deleted file mode 100644 index b55ca99..0000000 --- a/headers/gcg/graph/hypercolgraph_def.h +++ /dev/null @@ -1,514 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* */ -/* This file is part of the program */ -/* GCG --- Generic Column Generation */ -/* a Dantzig-Wolfe decomposition based extension */ -/* of the branch-cut-and-price framework */ -/* SCIP --- Solving Constraint Integer Programs */ -/* */ -/* Copyright (C) 2010-2022 Operations Research, RWTH Aachen University */ -/* Zuse Institute Berlin (ZIB) */ -/* */ -/* This program is free software; you can redistribute it and/or */ -/* modify it under the terms of the GNU Lesser General Public License */ -/* as published by the Free Software Foundation; either version 3 */ -/* of the License, or (at your option) any later version. */ -/* */ -/* This program is distributed in the hope that it will be useful, */ -/* but WITHOUT ANY WARRANTY; without even the implied warranty of */ -/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ -/* GNU Lesser General Public License for more details. */ -/* */ -/* You should have received a copy of the GNU Lesser General Public License */ -/* along with this program; if not, write to the Free Software */ -/* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.*/ -/* */ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -/**@file hypercolgraph_def.h - * @brief Column hypergraph - * @author Martin Bergner - * @author Annika Thome - * - * A hypergraph structure with a node for every constraint and a hyperedge for every variable. - */ - -/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/ - -#ifndef GCG_HYPERCOLGRAPH_DEF_H_ -#define GCG_HYPERCOLGRAPH_DEF_H_ - -#include "hypercolgraph.h" -#include "class_partialdecomp.h" -#include "class_detprobdata.h" -#include -#include -#include -#include - -namespace gcg -{ -template -HypercolGraph::HypercolGraph( - SCIP* scip, /**< SCIP data structure */ - Weights w /**< weights for the given graph */ -): MatrixGraph(scip, w), graph(scip) -{ - this->graphiface = &graph; - this->name = std::string("hypercol"); -} - -template -HypercolGraph::~HypercolGraph() -{ - // TODO Auto-generated destructor stub -} - - -/** writes the graph to the given file. - * The format is graph dependent - */ -template -SCIP_RETCODE HypercolGraph::writeToFile( - int fd, /**< filename where the graph should be written to */ - SCIP_Bool edgeweights /**< whether to write edgeweights */ - ) -{ - function f(this->nvars); - FILE* file; - file = fdopen(fd, "w"); - if( file == NULL ) - return SCIP_FILECREATEERROR; - - SCIPinfoMessage(this->scip_, file, "%d %d %d\n", getNEdges(), getNNodes()+this->dummynodes, edgeweights ? 1 :0); - - for( int i = 0; i < getNEdges(); ++i ) - { - std::vector neighbors = getHyperedgeNodes(i); - - if( edgeweights ) - { - SCIPinfoMessage(this->scip_, file, "%d ", graph.getHyperedgeWeight(i)); - } - for( size_t j = 0; j < neighbors.size(); ++j ) - { - SCIPinfoMessage(this->scip_, file, "%d ",neighbors[j]+1); - } - SCIPinfoMessage(this->scip_, file, "\n"); - } - if( !fclose(file) ) - return SCIP_OKAY; - else - return SCIP_WRITEERROR; -} - -template -int HypercolGraph::getNEdges() -{ - return this->nvars; -} - -template -int HypercolGraph::getNNodes() -{ - return this->nconss; -} - - -template -std::vector HypercolGraph::getHyperedgeNodes( - int i -) -{ - assert(i >= 0); - assert(i < getNEdges()); - - std::vector neighbors = graph.getHyperedgeNodes(i); - return neighbors; -} - - -template -SCIP_RETCODE HypercolGraph::createFromMatrix( - SCIP_CONS** conss, /**< constraints for which graph should be created */ - SCIP_VAR** vars, /**< variables for which graph should be created */ - int nconss_, /**< number of constraints */ - int nvars_ /**< number of variables */ - ) -{ - int i; - int k; - SCIP_Bool success; - std::vector< std::vector > hyperedges; - - assert(conss != NULL); - assert(vars != NULL); - assert(nvars_ > 0); - assert(nconss_ > 0); - - this->nvars = nvars_; - this->nconss = nconss_; - - /* go through all constraints */ - for( i = 0; i < this->nconss; ++i ) - { - TCLIQUE_WEIGHT weight; - - /* calculate weight of node */ - weight = this->weights.calculate(conss[i]); - - this->graph.addNode(i, weight); - } - - hyperedges.resize(this->nvars); - - /* go through all constraints */ - for( i = 0; i < this->nconss; ++i ) - { - SCIP_VAR** curvars1 = NULL; - - int ncurvars1; - SCIP_CALL( SCIPgetConsNVars(this->scip_, conss[i], &ncurvars1, &success) ); - assert(success); - if( ncurvars1 == 0 ) - continue; - - /* - * may work as is, as we are copying the constraint later regardless - * if there are variables in it or not - */ - SCIP_CALL( SCIPallocBufferArray(this->scip_, &curvars1, ncurvars1) ); - SCIP_CALL( SCIPgetConsVars(this->scip_, conss[i], curvars1, ncurvars1, &success) ); - assert(success); - - /** @todo skip all variables that have a zero coeffient or where all coefficients add to zero */ - /** @todo Do more then one entry per variable actually work? */ - - for( k = 0; k < ncurvars1; ++k ) - { - SCIP_VAR* var1 = NULL; - int varIndex1; - - if( SCIPgetStage(this->scip_) >= SCIP_STAGE_TRANSFORMED) - var1 = SCIPvarGetProbvar(curvars1[k]); - else - var1 = curvars1[k]; - - if( !GCGisVarRelevant(var1) ) - continue; - - assert(var1 != NULL); - varIndex1 = SCIPvarGetProbindex(var1); - assert(varIndex1 >= 0); - assert(varIndex1 < this->nvars); - - hyperedges[varIndex1].insert(hyperedges[varIndex1].end(), i); - } - SCIPfreeBufferArray(this->scip_, &curvars1); - } - - /* go through all variables */ - for( i = 0; i < this->nvars; ++i ) - { - TCLIQUE_WEIGHT weight; - - /* calculate weight of node */ - weight = this->weights.calculate(vars[i]); - - this->graph.addHyperedge(hyperedges[i], weight); - } - this->graph.flush(); - - return SCIP_OKAY; -} - -template -SCIP_RETCODE HypercolGraph::createFromPartialMatrix( - DETPROBDATA* detprobdata, - PARTIALDECOMP* partialdec - ) -{ - int i; - int j; - TCLIQUE_WEIGHT weight; - std::vector< std::vector > hyperedges; - unordered_map oldToNewConsIndex; - vector varsBool(partialdec->getNVars(), false); /**< true, if the var will be part of the graph */ - vector conssBool(partialdec->getNConss(), false); /**< true, if the cons will be part of the graph */ - vector conssForGraph; /** stores the conss included by the graph */ - vector varsForGraph; /** stores the vars included by the graph */ - - //fillout conssForGraph and varsForGraph - for(int c = 0; c < partialdec->getNOpenconss(); ++c) - { - int cons = partialdec->getOpenconss()[c]; - for(int v = 0; v < partialdec->getNOpenvars(); ++v) - { - int var = partialdec->getOpenvars()[v]; - for(i = 0; i < detprobdata->getNVarsForCons(cons); ++i) - { - if(var == detprobdata->getVarsForCons(cons)[i]) - { - varsBool[var] = true; - conssBool[cons] = true; - } - } - } - } - - for(int v = 0; v < partialdec->getNOpenvars(); ++v) - { - int var = partialdec->getOpenvars()[v]; - if(varsBool[var]) - varsForGraph.push_back(var); - } - for(int c = 0; c < partialdec->getNOpenconss(); ++c) - { - int cons = partialdec->getOpenconss()[c]; - if(conssBool[cons]) - conssForGraph.push_back(cons); - } - - this->nconss = (int)conssForGraph.size(); - this->nvars = (int)varsForGraph.size(); - - /* go through all open constraints */ - for( i = 0; i < this->nconss; ++i ) - { - int oldConsId = conssForGraph[i]; - - /* calculate weight of node */ - weight = this->weights.calculate(detprobdata->getCons(oldConsId)); - - oldToNewConsIndex.insert({oldConsId,i}); - - this->graph.addNode(i, weight); - } - - - - /* go through all open variables */ - for( i = 0; i < this->nvars; ++i ) - { - std::vector hyperedge; - int oldVarId = varsForGraph[i]; - - for( j = 0; j < detprobdata->getNConssForVar(oldVarId); ++j ) - { - int oldConsId = detprobdata->getConssForVar(oldVarId)[j]; - if(!conssBool[oldConsId]) - continue; - hyperedge.insert(hyperedge.end(), oldToNewConsIndex[oldConsId]); - } - /* calculate weight of hyperedge */ - weight = this->weights.calculate(detprobdata->getVar(oldVarId)); - this->graph.addHyperedge(hyperedge, weight); - } - - - this->graph.flush(); - - return SCIP_OKAY; -} - - -template -SCIP_RETCODE HypercolGraph::createDecompFromPartition( - DEC_DECOMP** decomp /**< decomposition structure to generate */ - ) -{ - SCIP_HASHMAP* constoblock; - SCIP_CONS** conss; - int nblocks; - - assert(decomp != NULL); - std::vector partition = this->getPartition(); - conss = SCIPgetConss(this->scip_); - - SCIP_CALL( SCIPhashmapCreate(&constoblock, SCIPblkmem(this->scip_), this->nconss) ); - - assert((size_t)SCIPgetNConss(this->scip_) == partition.size()); - nblocks = 1+*std::max_element(partition.begin(), partition.end() ); - - for( int c = 0; c < this->nconss; ++c ) - { - int consblock = partition[c]+1; - - SCIP_CALL( SCIPhashmapInsert(constoblock, conss[c], (void*) (size_t) consblock) ); - } - - SCIP_CALL( DECdecompCreate(this->scip_, decomp) ); - SCIP_CALL( DECfilloutDecompFromConstoblock(this->scip_, *decomp, constoblock, nblocks, FALSE) ); - - return SCIP_OKAY; -} - -template -SCIP_RETCODE HypercolGraph::createPartialdecFromPartition( - PARTIALDECOMP** firstpartialdec, - PARTIALDECOMP** secondpartialdec, - DETPROBDATA* detprobdata - ) -{ - SCIP_HASHMAP* constoblock; - SCIP_CONS** conss; - int nblocks; - - std::vector partition = this->getPartition(); - conss = SCIPgetConss(this->scip_); - std::vector isEmptyBlock; - std::vector nEmptyBlocksBefore; - - SCIP_CALL( SCIPhashmapCreate(&constoblock, SCIPblkmem(this->scip_), this->nconss) ); - - assert((size_t)SCIPgetNConss(this->scip_) == partition.size()); - nblocks = 1+*std::max_element(partition.begin(), partition.end() ); - - /** add data structures to handle empty blocks */ - - isEmptyBlock = std::vector(nblocks, true); - nEmptyBlocksBefore = std::vector(nblocks, 0); - - for( int c = 0; c < this->nconss; ++c ) - { - int consblock = partition[c]+1; - isEmptyBlock[consblock-1] = false; - } - - for(int b1 = 0; b1 < nblocks; ++b1) - { - if (isEmptyBlock[b1] ) - { - std::cout << "block " << b1 << " is an empty block " << std::endl; - for(int b2 = b1+1; b2 < nblocks; ++b2) - nEmptyBlocksBefore[b2]++; - } - } - - for( int c = 0; c < this->nconss; ++c ) - { - int consblock = partition[c]+1; - consblock -= nEmptyBlocksBefore[partition[c] ]; - SCIP_CALL( SCIPhashmapInsert(constoblock, (void*) (size_t) detprobdata->getIndexForCons(conss[c]), (void*) (size_t) consblock) ); - } - - bool original = detprobdata->isAssignedToOrigProb(); - if( firstpartialdec != NULL ) - { - (*firstpartialdec) = new PARTIALDECOMP(this->scip_, original); - SCIP_CALL((*firstpartialdec)->filloutPartialdecFromConstoblock(constoblock, nblocks)); - } - if( secondpartialdec != NULL ) - { - (*secondpartialdec) = new PARTIALDECOMP(this->scip_, original); - SCIP_CALL((*secondpartialdec)->filloutBorderFromConstoblock(constoblock, nblocks)); - } - SCIPhashmapFree(&constoblock); - - return SCIP_OKAY; -} - -template -SCIP_RETCODE HypercolGraph::createPartialdecFromPartition( - PARTIALDECOMP* oldpartialdec, - PARTIALDECOMP** firstpartialdec, - PARTIALDECOMP** secondpartialdec, - DETPROBDATA* detprobdata - ) -{ - SCIP_HASHMAP* constoblock; - int nblocks; - std::vector isEmptyBlock; - std::vector nEmptyBlocksBefore; - int nEmptyBlocks = 0; - - if(this->nconss == 0) - { - (*firstpartialdec) = NULL; - (*secondpartialdec) = NULL; - return SCIP_OKAY; - } - - std::vector partition = this->getPartition(); - - //fillout conssForGraph - vector conssForGraph; /** stores the conss included by the graph */ - vector conssBool(oldpartialdec->getNConss(), false); /**< true, if the cons will be part of the graph */ - bool found; - - for(int c = 0; c < oldpartialdec->getNOpenconss(); ++c) - { - int cons = oldpartialdec->getOpenconss()[c]; - found = false; - for(int v = 0; v < oldpartialdec->getNOpenvars() && !found; ++v) - { - int var = oldpartialdec->getOpenvars()[v]; - for(int i = 0; i < detprobdata->getNVarsForCons(cons) && !found; ++i) - { - if(var == detprobdata->getVarsForCons(cons)[i]) - { - conssBool[cons] = true; - found = true; - } - } - } - } - - for(int c = 0; c < oldpartialdec->getNOpenconss(); ++c) - { - int cons = oldpartialdec->getOpenconss()[c]; - if(conssBool[cons]) - conssForGraph.push_back(cons); - } - - SCIP_CALL( SCIPhashmapCreate(&constoblock, SCIPblkmem(this->scip_), this->nconss) ); - nblocks = 1+*std::max_element(partition.begin(), partition.end() ); - /** add data structures to handle empty blocks */ - - isEmptyBlock = std::vector(nblocks, true); - nEmptyBlocksBefore = std::vector(nblocks, 0); - - for( int c = 0; c < this->nconss; ++c ) - { - int consblock = partition[c]+1; - isEmptyBlock[consblock-1] = false; - } - - for(int b1 = 0; b1 < nblocks; ++b1) - { - if (isEmptyBlock[b1] ) - { - nEmptyBlocks++; - for(int b2 = b1+1; b2 < nblocks; ++b2) - nEmptyBlocksBefore[b2]++; - } - } - - for( int c = 0; c < this->nconss; ++c ) - { - int consblock = partition[c]+1; - consblock -= nEmptyBlocksBefore[partition[c] ]; - SCIP_CALL( SCIPhashmapInsert(constoblock, (void*) (size_t) conssForGraph[c], (void*) (size_t) consblock) ); - } - - nblocks -= nEmptyBlocks; - - if( firstpartialdec != NULL ) - { - (*firstpartialdec) = new PARTIALDECOMP(oldpartialdec); - SCIP_CALL((*firstpartialdec)->assignPartialdecFromConstoblock(constoblock, nblocks)); - } - if( secondpartialdec != NULL ) - { - (*secondpartialdec) = new PARTIALDECOMP(oldpartialdec); - SCIP_CALL((*secondpartialdec)->assignBorderFromConstoblock(constoblock, nblocks)); - } - SCIPhashmapFree(&constoblock); - - return SCIP_OKAY; -} - - -} /* namespace gcg */ - -#endif diff --git a/headers/gcg/graph/hypergraph.h b/headers/gcg/graph/hypergraph.h deleted file mode 100644 index e363a4c..0000000 --- a/headers/gcg/graph/hypergraph.h +++ /dev/null @@ -1,178 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* */ -/* This file is part of the program */ -/* GCG --- Generic Column Generation */ -/* a Dantzig-Wolfe decomposition based extension */ -/* of the branch-cut-and-price framework */ -/* SCIP --- Solving Constraint Integer Programs */ -/* */ -/* Copyright (C) 2010-2022 Operations Research, RWTH Aachen University */ -/* Zuse Institute Berlin (ZIB) */ -/* */ -/* This program is free software; you can redistribute it and/or */ -/* modify it under the terms of the GNU Lesser General Public License */ -/* as published by the Free Software Foundation; either version 3 */ -/* of the License, or (at your option) any later version. */ -/* */ -/* This program is distributed in the hope that it will be useful, */ -/* but WITHOUT ANY WARRANTY; without even the implied warranty of */ -/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ -/* GNU Lesser General Public License for more details. */ -/* */ -/* You should have received a copy of the GNU Lesser General Public License */ -/* along with this program; if not, write to the Free Software */ -/* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.*/ -/* */ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -/**@file hypergraph.h - * @brief miscellaneous hypergraph methods for structure detection - * @author Martin Bergner - * @author Annika Thome - */ - -/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/ - - - -#ifndef GCG_HYPERGRAPH_H_ -#define GCG_HYPERGRAPH_H_ -#include "objscip/objscip.h" -#include "tclique/tclique.h" -#include "weights.h" -#include "pub_decomp.h" -#include "graph.h" -#include "graph_interface.h" - -#include -#include -#include - -namespace gcg { - -template -class Hypergraph : public GraphInterface { -public: - std::string name; -protected: - SCIP* scip_; - Graph* graph; - std::vector nodes; - std::vector hedges; - std::vector mapping; - int lastnode; - int dummynodes; - -public: - /** Constructor */ - Hypergraph( - SCIP* scip - ); - - void swap(Hypergraph & other) // the swap member function (should never fail!) - { - // swap all the members (and base subobject, if applicable) with other - std::swap(partition, other.partition); - std::swap(scip_ , other.scip_); - std::swap(graph , other.graph); - std::swap(hedges , other.hedges); - std::swap(nodes , other.nodes); - std::swap(lastnode, other.lastnode); - std::swap(dummynodes, other.dummynodes); - } - - Hypergraph& operator=(Hypergraph other) // note: argument passed by value! - { - // swap this with other - swap(other); - - return *this; - } - - /** Destruktor */ - ~Hypergraph(); - - /** adds the node with the given weight to the graph */ - SCIP_RETCODE addNode(int i,int weight); - - /** adds the edge to the graph */ - SCIP_RETCODE addHyperedge(std::vector &edge, int weight); - - /** adds the edge to the graph */ - SCIP_RETCODE addNodeToHyperedge(int node, int hedge); - - /** return the number of nodes */ - int getNNodes(); - - /** return the number of edges (or hyperedges) */ - int getNHyperedges(); - - /** return the number of neighbor nodes of given node */ - int getNNeighbors( - int i /**< the given node */ - ); - - /** return the neighboring nodes of a given node */ - std::vector getNeighbors( - int i /**< the given node */ - ); - - /** return the nodes spanned by hyperedge */ - std::vector getHyperedgeNodes( - int i - ); - - /** return the number of nodes spanned by hyperedge */ - int getNHyperedgeNodes( - int i - ); - - /** assigns partition to a given node*/ - void setPartition(int i, int ID); - - /** writes the hypergraph to the given file. - * The format is hypergraph dependent - */ - SCIP_RETCODE writeToFile( - int fd, /**< filename where the graph should be written to */ - SCIP_Bool writeweights /**< whether to write weights */ - ); - - /** - * reads the partition from the given file. - * The format is hypergraph dependent. The default is a file with one line for each node a - */ - SCIP_RETCODE readPartition( - const char* filename /**< filename where the partition is stored */ - ); - - /** return the weight of given node */ - int getWeight( - int i /**< the given node */ - ); - - /** return the weight of given hyperedge */ - int getHyperedgeWeight( - int i /**< the given hyperedge */ - ); - - /** set the number of dummy nodes */ - void setDummynodes(int dummynodes_) - { - dummynodes = dummynodes_; - } - - - int getDummynodes() const - { - return dummynodes; - } - - SCIP_RETCODE flush(); -private: - int computeNodeId(int i); -}; - -} - -#endif diff --git a/headers/gcg/graph/hypergraph_def.h b/headers/gcg/graph/hypergraph_def.h deleted file mode 100644 index 4034b50..0000000 --- a/headers/gcg/graph/hypergraph_def.h +++ /dev/null @@ -1,273 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* */ -/* This file is part of the program */ -/* GCG --- Generic Column Generation */ -/* a Dantzig-Wolfe decomposition based extension */ -/* of the branch-cut-and-price framework */ -/* SCIP --- Solving Constraint Integer Programs */ -/* */ -/* Copyright (C) 2010-2022 Operations Research, RWTH Aachen University */ -/* Zuse Institute Berlin (ZIB) */ -/* */ -/* This program is free software; you can redistribute it and/or */ -/* modify it under the terms of the GNU Lesser General Public License */ -/* as published by the Free Software Foundation; either version 3 */ -/* of the License, or (at your option) any later version. */ -/* */ -/* This program is distributed in the hope that it will be useful, */ -/* but WITHOUT ANY WARRANTY; without even the implied warranty of */ -/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ -/* GNU Lesser General Public License for more details. */ -/* */ -/* You should have received a copy of the GNU Lesser General Public License */ -/* along with this program; if not, write to the Free Software */ -/* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.*/ -/* */ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -/**@file hypergraph_def.h - * @brief miscellaneous hypergraph methods for structure detection - * @author Martin Bergner - */ - -/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/ - - -#ifndef GCG_HYPERGRAPH_DEF_H_ -#define GCG_HYPERGRAPH_DEF_H_ - -#include "scip/scip.h" -#include "hypergraph.h" - -namespace gcg { - -template -Hypergraph::Hypergraph( - SCIP* scip /**< SCIP data structure */ -) : name("hypergraph"),scip_(scip),graph(NULL),lastnode(0),dummynodes(0) -{ - SCIPdebugMessage("Creating graph\n"); - graph = new Graph(scip); -} - -template -Hypergraph::~Hypergraph() -{ - if(graph != NULL) - delete graph; - -} - -template -int Hypergraph::computeNodeId(int i) -{ - int nodeid; - if( i < (int) nodes.size()) - nodeid = nodes[i]; - else - nodeid = lastnode; - - SCIPdebugMessage("Nodeid %d is %d\n", i, nodeid); - return nodeid; -} - -template -SCIP_RETCODE Hypergraph::addNode(int i,int weight) -{ - int nodeid = lastnode; - SCIPdebugMessage("Adding node %d (id=%d)\n", i, nodeid); - SCIP_CALL( graph->addNode(nodeid, weight) ); - nodes.push_back(nodeid); - mapping.resize(nodeid+1); - mapping[nodeid] = i; - ++lastnode; - return SCIP_OKAY; -} - -/** adds the edge to the graph */ -template -SCIP_RETCODE Hypergraph::addHyperedge(std::vector &edge, int weight) -{ - int edgenodeid = lastnode; - ++lastnode; - SCIPdebugMessage("Adding hyperedge %lu (id=%d)\n", hedges.size(), edgenodeid); - SCIP_CALL( graph->addNode(edgenodeid, weight) ); - - for( size_t i = 0; i < edge.size(); ++i ) - { - SCIP_CALL( graph->addEdge(edgenodeid, computeNodeId(edge[i])) ); - } - hedges.push_back(edgenodeid); - mapping.resize(edgenodeid+1); - mapping[edgenodeid] = hedges.size()-1; - return SCIP_OKAY; -} - -/** adds the edge to the graph */ -template -SCIP_RETCODE Hypergraph::addNodeToHyperedge(int node, int hedge) -{ - int edgenodeid = hedges[hedge]; - int nodeid = nodes[node]; - SCIP_CALL( graph->addEdge(edgenodeid, nodeid) ); - - return SCIP_OKAY; -} - - -template -int Hypergraph::getNNodes() { - return nodes.size(); -} - -template -int Hypergraph::getNHyperedges() { - return hedges.size(); -} - -template -int Hypergraph::getNNeighbors(int i) { - assert( i >= 0); - return graph->getNNeighbors(i); -} - -template -std::vector Hypergraph::getNeighbors(int i) { - assert(i >= 0); - int nodeid = computeNodeId(i); - std::vector edges = graph->getNeighbors(nodeid); - - std::set neighbors; - for( size_t j = 0; j < edges.size(); ++j ) - { - std::vector tempneighbors = graph->getNeighbors(edges[j]); - neighbors.insert(tempneighbors.begin(), tempneighbors.end()); - } - std::vector r(neighbors.begin(), neighbors.end()); - for( size_t j = 0; j < r.size(); ++j) - { - r[j] = mapping[r[j]]; - } - std::vector::iterator it = std::remove(r.begin(), r.end(), nodeid); - - return std::vector(r.begin(), it); -} - -template -std::vector Hypergraph::getHyperedgeNodes( - int i - ) -{ - std::vector hnodes = graph->getNeighbors(hedges[i]); - for( size_t j = 0; j < hnodes.size(); ++j) - { - hnodes[j] = computeNodeId(hnodes[j]); - } - return hnodes; -} - -template -int Hypergraph::getNHyperedgeNodes( - int i - ) -{ - return graph->getNNeighbors(hedges[i]); -} - -template -void Hypergraph::setPartition(int i, int ID) { - partition.resize(getNNodes(), -1); - partition[i] = ID; -} - -/** write the hypergraph to a file */ -template -SCIP_RETCODE Hypergraph::writeToFile( - int fd, /**< filename where the graph should be written to */ - SCIP_Bool writeweights - ) -{ - FILE* file; - file = fdopen(fd, "w"); - if( file == NULL ) - return SCIP_FILECREATEERROR; - - SCIPinfoMessage(scip_, file, "%ld %ld\n", nodes.size()+dummynodes, hedges.size()); - - for( size_t i = 0; i < hedges.size(); ++i ) - { - int nneighbors = graph->getNNeighbors(hedges[i]); - std::vector neighbors = graph->getNeighbors(hedges[i]); - - if( writeweights ) - { - SCIPinfoMessage(scip_, file, "%d ", graph->getWeight(i)); - } - for( int j = 0; j < nneighbors; ++j ) - { - SCIPinfoMessage(scip_, file, "%d ", computeNodeId(neighbors[j])+1); - } - SCIPinfoMessage(scip_, file, "\n"); - } - - return SCIP_OKAY; -} - -/** read in the partition from a file */ -template -SCIP_RETCODE Hypergraph::readPartition( - const char* filename -) -{ - ifstream input(filename); - if( !input.good() ) - { - SCIPerrorMessage("Could not open file <%s> for reading\n", filename); - return SCIP_READERROR; - } - partition.resize(getNNodes(), -1); - for( int i = 0; i < getNNodes(); ++i ) - { - int part = 0; - if( !(input >> part) ) - { - SCIPerrorMessage("Could not read from file <%s>. It may be in the wrong format\n", filename); - return SCIP_READERROR; - } - partition[i] = part; - } - - input.close(); - return SCIP_OKAY; -} - -/** return the weight of given node */ -template -int Hypergraph::getWeight( - int i /**< the given node */ - ) -{ - return graph->getWeight(i); -} - -/** return the weight of given hyperedge */ -template -int Hypergraph::getHyperedgeWeight( - int i /**< the given hyperedge */ - ) -{ - int edgenodeid = hedges[i]; - - return graph->getWeight(edgenodeid); -} - -template -SCIP_RETCODE Hypergraph::flush() -{ - SCIP_CALL( graph->flush() ); - return SCIP_OKAY; -} - -} /* namespace gcg */ - -#endif diff --git a/headers/gcg/graph/hyperrowcolgraph.h b/headers/gcg/graph/hyperrowcolgraph.h deleted file mode 100644 index eaae8ef..0000000 --- a/headers/gcg/graph/hyperrowcolgraph.h +++ /dev/null @@ -1,124 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* */ -/* This file is part of the program */ -/* GCG --- Generic Column Generation */ -/* a Dantzig-Wolfe decomposition based extension */ -/* of the branch-cut-and-price framework */ -/* SCIP --- Solving Constraint Integer Programs */ -/* */ -/* Copyright (C) 2010-2022 Operations Research, RWTH Aachen University */ -/* Zuse Institute Berlin (ZIB) */ -/* */ -/* This program is free software; you can redistribute it and/or */ -/* modify it under the terms of the GNU Lesser General Public License */ -/* as published by the Free Software Foundation; either version 3 */ -/* of the License, or (at your option) any later version. */ -/* */ -/* This program is distributed in the hope that it will be useful, */ -/* but WITHOUT ANY WARRANTY; without even the implied warranty of */ -/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ -/* GNU Lesser General Public License for more details. */ -/* */ -/* You should have received a copy of the GNU Lesser General Public License */ -/* along with this program; if not, write to the Free Software */ -/* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.*/ -/* */ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -/**@file hyperrowcolgraph.h - * @brief A hypergraph with row and column nodes - * @author Martin Bergner - */ - -/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/ - -#ifndef GCG_HYPERROWCOLGRAPH_H_ -#define GCG_HYPERROWCOLGRAPH_H_ - -#include "matrixgraph.h" -#include "hypergraph.h" -#include "class_partialdecomp.h" -#include "class_detprobdata.h" - -namespace gcg { -template -class HyperrowcolGraph: public MatrixGraph -{ -private: - Graph graph; -public: - HyperrowcolGraph( - SCIP* scip, /**< SCIP data structure */ - Weights w /**< weights for the given graph */ - ); - virtual ~HyperrowcolGraph(); - - SCIP_RETCODE createFromMatrix( - SCIP_CONS** conss, /**< constraints for which graph should be created */ - SCIP_VAR** vars, /**< variables for which graph should be created */ - int nconss, /**< number of constraints */ - int nvars /**< number of variables */ - ); - - /** creates a graph with open constraints and open variables of the partialdec */ - virtual SCIP_RETCODE createFromPartialMatrix( - DETPROBDATA* detprobdata, /**< detection process information and data */ - PARTIALDECOMP* partialdec /**< partial decomposition to use for matrix */ - ); - - /** writes the graph to the given file. - * The format is graph dependent - */ - virtual SCIP_RETCODE writeToFile( - int fd, /**< file descriptor where the graph should be written to */ - SCIP_Bool writeweights /**< whether to write weights */ - ); - - - virtual SCIP_RETCODE createDecompFromPartition( - DEC_DECOMP** decomp /**< decomposition structure to generate */ - ); - - /** creates a new partialdec by dint of a graph created with all constraints and variables */ - virtual SCIP_RETCODE createPartialdecFromPartition( - PARTIALDECOMP** firstpartialdec, /**< pointer to buffer the new partialdec created by dint of the graph */ - PARTIALDECOMP** secondpartialdec, /**< pointer to buffer the new partialdec whose border is amplified by dint of the graph */ - DETPROBDATA* detprobdata /**< detection process information and data */ - ); - - /** amplifies a partialdec by dint of a graph created with open constraints and open variables of the partialdec */ - virtual SCIP_RETCODE createPartialdecFromPartition( - PARTIALDECOMP* oldpartialdec, /**< partialdec which should be amplifies */ - PARTIALDECOMP** firstpartialdec, /**< pointer to buffer the new partialdec amplified by dint of the graph */ - PARTIALDECOMP** secondpartialdec, /**< pinter to buffer the new partialdec whose border is amplified by dint of the graph */ - DETPROBDATA* detprobdata /**< detection process information and data */ - ); - - /** - * reads the partition from the given file. - * The format is graph dependent. The default is a file with one line for each node a - */ - virtual SCIP_RETCODE readPartition( - const char* filename /**< filename where the partition is stored */ - ); - - virtual std::vector getNeighbors( - int i - ); - - virtual std::vector getHyperedgeNodes( - int i - ); - - std::vector getConsNonzeroNodes( - int i - ); - - std::vector getVarNonzeroNodes( - int i - ); - -}; - -} /* namespace gcg */ -#endif /* GCG_HYPERROWCOLGRAPH_H_ */ diff --git a/headers/gcg/graph/hyperrowcolgraph_def.h b/headers/gcg/graph/hyperrowcolgraph_def.h deleted file mode 100644 index 336df8d..0000000 --- a/headers/gcg/graph/hyperrowcolgraph_def.h +++ /dev/null @@ -1,679 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* */ -/* This file is part of the program */ -/* GCG --- Generic Column Generation */ -/* a Dantzig-Wolfe decomposition based extension */ -/* of the branch-cut-and-price framework */ -/* SCIP --- Solving Constraint Integer Programs */ -/* */ -/* Copyright (C) 2010-2022 Operations Research, RWTH Aachen University */ -/* Zuse Institute Berlin (ZIB) */ -/* */ -/* This program is free software; you can redistribute it and/or */ -/* modify it under the terms of the GNU Lesser General Public License */ -/* as published by the Free Software Foundation; either version 3 */ -/* of the License, or (at your option) any later version. */ -/* */ -/* This program is distributed in the hope that it will be useful, */ -/* but WITHOUT ANY WARRANTY; without even the implied warranty of */ -/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ -/* GNU Lesser General Public License for more details. */ -/* */ -/* You should have received a copy of the GNU Lesser General Public License */ -/* along with this program; if not, write to the Free Software */ -/* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.*/ -/* */ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -/**@file hyperrowcolgraph_def.h - * @brief A hypergraph with row and column nodes - * @author Martin Bergner - * @author Annika Thome - */ - -/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/ - -#ifndef GCG_HYPERROWCOLGRAPH_DEF_H_ -#define GCG_HYPERROWCOLGRAPH_DEF_H_ - -#include "hyperrowcolgraph.h" -#include "scip_misc.h" -#include "class_partialdecomp.h" -#include "class_detprobdata.h" -#include -#include - -namespace gcg { -template -HyperrowcolGraph::HyperrowcolGraph( - SCIP* scip, /**< SCIP data structure */ - Weights w /**< weights for the given graph */ -): MatrixGraph(scip, w),graph(scip) -{ - this->graphiface = &graph; - this->name = std::string("hyperrowcol"); -} - -template -HyperrowcolGraph::~HyperrowcolGraph() -{ - -} - - -/** - * Builds a bipartite representation of the hyperrowcol graph out of the matrix. - * - * The function will create an node for every constraint, every variable and every nonzero entry of the matrix. - * One side of the bipartite graph are the nonzero entries (nodes), the constraints and variables are on the other side (hyperedges). - * A nonzero entry a_{ij} is incident to the constraint i and the variable j. - * - * @todo The nonzeroness is not checked, all variables in the variable array are considered - */ -template -SCIP_RETCODE HyperrowcolGraph::createFromMatrix( - SCIP_CONS** conss, /**< constraints for which graph should be created */ - SCIP_VAR** vars, /**< variables for which graph should be created */ - int nconss_, /**< number of constraints */ - int nvars_ /**< number of variables */ - ) -{ - int i; - int j; - SCIP_Bool success; - - assert(conss != NULL); - assert(vars != NULL); - assert(nvars_ > 0); - assert(nconss_ > 0); - - this->nvars = nvars_; - this->nconss = nconss_; - - /* create nodes for constraints and variables (hyperedges) */ - for( i = 0; i < this->nvars + this->nconss; ++i ) - { - TCLIQUE_WEIGHT weight; - - /* note that the first nvars nodes correspond to variables */ - if( i < this->nvars ) - { - weight = this->weights.calculate(vars[i]); - SCIPdebugMessage("Weight for var <%s> is %d\n", SCIPvarGetName(vars[i]), weight); - } - - else - { - weight = this->weights.calculate(conss[i-this->nvars]); - SCIPdebugMessage("Weight for cons <%s> is %d\n", SCIPconsGetName(conss[i-this->nvars]), weight); - } - - SCIP_CALL( this->graph.addNode(i, weight) ); - } - - /* go through all constraints */ - for( i = 0; i < this->nconss; ++i ) - { - SCIP_VAR **curvars = NULL; - - int ncurvars; - SCIP_CALL( SCIPgetConsNVars(this->scip_, conss[i], &ncurvars, &success) ); - assert(success); - if( ncurvars == 0 ) - continue; - - /* - * may work as is, as we are copying the constraint later regardless - * if there are variables in it or not - */ - SCIP_CALL( SCIPallocBufferArray(this->scip_, &curvars, ncurvars) ); - SCIP_CALL( SCIPgetConsVars(this->scip_, conss[i], curvars, ncurvars, &success) ); - assert(success); - - /** @todo skip all variables that have a zero coeffient or where all coefficients add to zero */ - /** @todo Do more then one entry per variable actually work? */ - - for( j = 0; j < ncurvars; ++j ) - { - SCIP_VAR* var; - int varIndex; - - if( SCIPgetStage(this->scip_) >= SCIP_STAGE_TRANSFORMED) - var = SCIPvarGetProbvar(curvars[j]); - else - var = curvars[j]; - - if( !GCGisVarRelevant(var) ) - continue; - - assert(var != NULL); - varIndex = SCIPvarGetProbindex(var); - assert(varIndex >= 0); - assert(varIndex < this->nvars); - - SCIPdebugMessage("Cons <%s> (%d), var <%s> (%d), nonzero %d\n", SCIPconsGetName(conss[i]), i, SCIPvarGetName(var), varIndex, this->nnonzeroes); - /* add nonzero node and edge to variable and constraint) */; - SCIP_CALL( this->graph.addNode( this->nvars+this->nconss+this->nnonzeroes, 0) ); - SCIP_CALL( this->graph.addEdge(varIndex, this->nvars+this->nconss+this->nnonzeroes) ); - SCIP_CALL( this->graph.addEdge(this->nvars+i, this->nvars+this->nconss+this->nnonzeroes) ); - - this->nnonzeroes++; - } - SCIPfreeBufferArray(this->scip_, &curvars); - } - - SCIP_CALL( this->graph.flush() ); - - return SCIP_OKAY; -} - -template -SCIP_RETCODE HyperrowcolGraph::createFromPartialMatrix( - DETPROBDATA* detprobdata, - PARTIALDECOMP* partialdec - ) -{ - int i; - int j; - unordered_map oldToNewConsIndex; - unordered_map oldToNewVarIndex; - vector conssForGraph; /** stores the conss included by the graph */ - vector varsForGraph; /** stores the vars included by the graph */ - vector varsBool(partialdec->getNVars(), false); /**< true, if the var will be part of the graph */ - vector conssBool(partialdec->getNConss(), false); /**< true, if the cons will be part of the graph */ - - - //fillout conssForGraph and varsForGraph - for(int c = 0; c < partialdec->getNOpenconss(); ++c) - { - int cons = partialdec->getOpenconss()[c]; - for(int v = 0; v < partialdec->getNOpenvars(); ++v) - { - int var = partialdec->getOpenvars()[v]; - for(i = 0; i < detprobdata->getNVarsForCons(cons); ++i) - { - if(var == detprobdata->getVarsForCons(cons)[i]) - { - varsBool[var] = true; - conssBool[cons] = true; - } - } - } - } - - for(int v = 0; v < partialdec->getNOpenvars(); ++v) - { - int var = partialdec->getOpenvars()[v]; - if(varsBool[var]) - varsForGraph.push_back(var); - } - for(int c = 0; c < partialdec->getNOpenconss(); ++c) - { - int cons = partialdec->getOpenconss()[c]; - if(conssBool[cons]) - conssForGraph.push_back(cons); - } - - this->nconss = (int)conssForGraph.size(); - this->nvars = (int)varsForGraph.size(); - - /** add node for every var */ - for( i = 0 ; i < (int)varsForGraph.size(); ++i ) - { - int oldVarId = varsForGraph[i]; - assert(varsBool[oldVarId]); - TCLIQUE_WEIGHT weight; - - /* note that the first nvars nodes correspond to variables */ - weight = this->weights.calculate(detprobdata->getVar(oldVarId)); - oldToNewVarIndex.insert({oldVarId ,i}); - - this->graph.addNode(i, weight); - } - - /** add node for every cons */ - for( j = 0 ; j < (int)conssForGraph.size(); ++j ) - { - int oldConsId = conssForGraph[j]; - assert(conssBool[oldConsId]); - TCLIQUE_WEIGHT weight; - - /* note that the first nvars nodes correspond to variables (legacy implementation) */ - weight = this->weights.calculate(detprobdata->getCons(oldConsId)); - oldToNewConsIndex.insert({ oldConsId, j}); - this->graph.addNode( this->nvars + j, weight); - } - - this->nnonzeroes = 0; - /* go through all open constraints */ - for( i = 0; i < (int)conssForGraph.size(); ++i ) - { - int oldConsId = conssForGraph[i]; - - for( j = 0; j < detprobdata->getNVarsForCons(oldConsId); ++j ) - { - int oldVarId = detprobdata->getVarsForCons(oldConsId)[j]; - if(!varsBool[oldVarId]) - continue; - SCIPdebugMessage("Cons <%s> (%d), var <%s> (%d), nonzero %d\n", SCIPconsGetName(detprobdata->getCons(oldConsId)), i, - SCIPvarGetName(detprobdata->getVar(oldVarId)), oldToNewVarIndex[oldVarId], this->nnonzeroes); - /* add nonzero node and edge to variable and constraint) */; - SCIP_CALL( this->graph.addNode( this->nvars+this->nconss+this->nnonzeroes, 0) ); - SCIP_CALL( this->graph.addEdge(oldToNewVarIndex[oldVarId], this->nvars+this->nconss+this->nnonzeroes) ); - SCIP_CALL( this->graph.addEdge(this->nvars+oldToNewConsIndex[oldConsId], this->nvars+this->nconss+this->nnonzeroes) ); - - this->nnonzeroes++; - } - } - - this->graph.flush(); - return SCIP_OKAY; -} - - -/** writes the graph to the given file. - * The format is graph dependent - */ -template -SCIP_RETCODE HyperrowcolGraph::writeToFile( - int fd, /**< filename where the graph should be written to */ - SCIP_Bool edgeweights /**< whether to write edgeweights */ - ) -{ - FILE* file; - file = fdopen(fd, "wx"); - if( file == NULL ) - return SCIP_FILECREATEERROR; - - SCIPinfoMessage(this->scip_, file, "%d %d %d\n", this->nvars+this->nconss, this->nnonzeroes+this->dummynodes, edgeweights ? 1 :0); - - for( int i = 0; i < this->nvars+this->nconss; ++i ) - { - std::vector neighbors = graph.getNeighbors(i); - int nneighbors = graph.getNNeighbors(i); - if( edgeweights ) - { - SCIPinfoMessage(this->scip_, file, "%d ", graph.getWeight(i)); - } - for( int j = 0; j < nneighbors; ++j ) - { - SCIPinfoMessage(this->scip_, file, "%d ",neighbors[j]+1-this->nvars-this->nconss); - } - SCIPinfoMessage(this->scip_, file, "\n"); - } - - if( !fclose(file) ) - return SCIP_OKAY; - else - return SCIP_WRITEERROR; -} - - -class function { - int diff; -public: - function(int i):diff(i) {} - int operator()(int i) const { return i-diff;} -}; - -template -std::vector HyperrowcolGraph::getNeighbors( - int i -) -{ - assert(i >= 0); - assert(i < this->nnonzeroes); - function f(this->nconss+this->nvars); - std::vector::iterator it; - std::set neighbors; - std::vector immediateneighbors = this->graph.getNeighbors(i+this->nconss+this->nvars); - for( size_t j = 0; j < immediateneighbors.size(); ++j) - { - std::vector alternateneighbor = this->graph.getNeighbors(immediateneighbors[j]); - neighbors.insert(alternateneighbor.begin(), alternateneighbor.end() ); - } - std::vector r(neighbors.size(), 0); - std::transform(neighbors.begin(), neighbors.end(), r.begin(), f); - it = std::remove(r.begin(), r.end(), i); - - return std::vector(r.begin(), it); -} - -template -std::vector HyperrowcolGraph::getHyperedgeNodes( - int i -) -{ - function f(this->nconss+this->nvars); - assert(i >= 0); - assert(i < this->nconss+this->nvars); - - std::vector neighbors = this->graph.getNeighbors(i); - std::transform(neighbors.begin(), neighbors.end(), neighbors.begin(), f); - return neighbors; -} - -template -std::vector HyperrowcolGraph::getConsNonzeroNodes( - int i -) -{ - function f(this->nconss+this->nvars); - assert(i >= 0); - assert(i < this->nconss); - - std::vector neighbors = this->graph.getNeighbors(i+this->nvars); - std::transform(neighbors.begin(), neighbors.end(), neighbors.begin(), f); - return neighbors; -} - -template -std::vector HyperrowcolGraph::getVarNonzeroNodes( - int i -) -{ - function f(this->nconss+this->nvars); - assert(i >= 0); - assert(i < this->nvars); - - std::vector neighbors = this->graph.getNeighbors(i); - std::transform(neighbors.begin(), neighbors.end(), neighbors.begin(), f); - return neighbors; -} - -template -SCIP_RETCODE HyperrowcolGraph::createDecompFromPartition( - DEC_DECOMP** decomp /**< decomposition structure to generate */ - ) -{ - int nblocks; - SCIP_HASHMAP* constoblock = NULL; - - int* nsubscipconss = NULL; - int i; - SCIP_CONS** conss = NULL; - SCIP_Bool emptyblocks = FALSE; - std::vector partition = graph.getPartition(); - conss = SCIPgetConss(this->scip_); - - nblocks = *(std::max_element(partition.begin(), partition.end()))+1; - SCIP_CALL( SCIPallocBufferArray(this->scip_, &nsubscipconss, nblocks) ); - BMSclearMemoryArray(nsubscipconss, nblocks); - - SCIP_CALL( SCIPhashmapCreate(&constoblock, SCIPblkmem(this->scip_), this->nconss) ); - - /* assign constraints to partition */ - for( i = 0; i < this->nconss; i++ ) - { - std::set blocks; - std::vector nonzeros = getConsNonzeroNodes(i); - for( size_t k = 0; k < nonzeros.size(); ++k ) - { - blocks.insert(partition[nonzeros[k]]); - } - if( blocks.size() > 1 ) - { - SCIP_CALL( SCIPhashmapInsert(constoblock, conss[i], (void*) (size_t) (nblocks+1)) ); - } - else - { - int block = *(blocks.begin()); - SCIP_CALL( SCIPhashmapInsert(constoblock, conss[i], (void*) (size_t) (block +1)) ); - ++(nsubscipconss[block]); - } - } - - /* first, make sure that there are constraints in every block, otherwise the hole thing is useless */ - for( i = 0; i < nblocks; ++i ) - { - if( nsubscipconss[i] == 0 ) - { - SCIPdebugMessage("Block %d does not have any constraints!\n", i); - emptyblocks = TRUE; - } - } - - if( !emptyblocks ) - { - SCIP_CALL( DECdecompCreate(this->scip_, decomp) ); - SCIP_CALL( DECfilloutDecompFromConstoblock(this->scip_, *decomp, constoblock, nblocks, FALSE) ); - } - else { - SCIPhashmapFree(&constoblock); - *decomp = NULL; - } - - SCIPfreeBufferArray(this->scip_, &nsubscipconss); - return SCIP_OKAY; -} - -template -SCIP_RETCODE HyperrowcolGraph::createPartialdecFromPartition( - PARTIALDECOMP** firstpartialdec, - PARTIALDECOMP** secondpartialdec, - DETPROBDATA* detprobdata - ) -{ - int nblocks; - SCIP_HASHMAP* constoblock = NULL; - - int *nsubscipconss = NULL; - int i; - SCIP_CONS **conss = NULL; - SCIP_Bool emptyblocks = FALSE; - std::vector partition = graph.getPartition(); - conss = SCIPgetConss(this->scip_); - - nblocks = *(std::max_element(partition.begin(), partition.end()))+1; - SCIP_CALL( SCIPallocBufferArray(this->scip_, &nsubscipconss, nblocks) ); - BMSclearMemoryArray(nsubscipconss, nblocks); - - SCIP_CALL( SCIPhashmapCreate(&constoblock, SCIPblkmem(this->scip_), this->nconss) ); - - /* assign constraints to partition */ - for( i = 0; i < this->nconss; i++ ) - { - std::set blocks; - std::vector nonzeros = getConsNonzeroNodes(i); - for( size_t k = 0; k < nonzeros.size(); ++k ) - { - blocks.insert(partition[nonzeros[k]]); - } - if( blocks.size() > 1 ) - { - SCIP_CALL( SCIPhashmapInsert(constoblock, (void*) (size_t)detprobdata->getIndexForCons(conss[i]), (void*) (size_t) (nblocks+1)) ); - } - else - { - int block = *(blocks.begin()); - SCIP_CALL( SCIPhashmapInsert(constoblock, (void*) (size_t) detprobdata->getIndexForCons(conss[i]), (void*) (size_t) (block +1)) ); - ++(nsubscipconss[block]); - } - } - - /* first, make sure that there are constraints in every block, otherwise the whole thing is useless */ - for( i = 0; i < nblocks; ++i ) - { - if( nsubscipconss[i] == 0 ) - { - SCIPdebugMessage("Block %d does not have any constraints!\n", i); - emptyblocks = TRUE; - } - } - - if( !emptyblocks ) - { - bool original = detprobdata->isAssignedToOrigProb(); - if( firstpartialdec != NULL ) - { - (*firstpartialdec) = new PARTIALDECOMP(this->scip_, original); - SCIP_CALL((*firstpartialdec)->filloutPartialdecFromConstoblock(constoblock, nblocks)); - } - if( secondpartialdec != NULL ) - { - (*secondpartialdec) = new PARTIALDECOMP(this->scip_, original); - SCIP_CALL((*secondpartialdec)->filloutBorderFromConstoblock(constoblock, nblocks)); - for( int col = 0; col < (*firstpartialdec)->getNLinkingvars(); ++col ) - { - (*secondpartialdec)->setVarToLinking((*firstpartialdec)->getLinkingvars()[col]); - (*secondpartialdec)->deleteOpenvar(col); - } - } - SCIPhashmapFree(&constoblock); - } - else { - SCIPhashmapFree(&constoblock); - if( firstpartialdec != NULL ) - { - (*firstpartialdec) = NULL; - } - if( secondpartialdec != NULL) - { - (*secondpartialdec) = NULL; - } - } - - SCIPfreeBufferArray(this->scip_, &nsubscipconss); - return SCIP_OKAY; -} - -template -SCIP_RETCODE HyperrowcolGraph::createPartialdecFromPartition( - PARTIALDECOMP* oldpartialdec, - PARTIALDECOMP** firstpartialdec, - PARTIALDECOMP** secondpartialdec, - DETPROBDATA* detprobdata - ) -{ - int nblocks; - SCIP_HASHMAP* constoblock = NULL; - - int* nsubscipconss = NULL; - int i; - SCIP_Bool emptyblocks = FALSE; - - if(this->nconss == 0) - { - (*firstpartialdec) = NULL; - (*secondpartialdec) = NULL; - return SCIP_OKAY; - } - - std::vector partition = graph.getPartition(); - - nblocks = *(std::max_element(partition.begin(), partition.end()))+1; - SCIP_CALL( SCIPallocBufferArray(this->scip_, &nsubscipconss, nblocks) ); - BMSclearMemoryArray(nsubscipconss, nblocks); - - SCIP_CALL( SCIPhashmapCreate(&constoblock, SCIPblkmem(this->scip_), this->nconss) ); - - //fillout conssForGraph - vector conssForGraph; /** stores the conss included by the graph */ - vector conssBool(oldpartialdec->getNConss(), false); /**< true, if the cons will be part of the graph */ - bool found; - - for(int c = 0; c < oldpartialdec->getNOpenconss(); ++c) - { - int cons = oldpartialdec->getOpenconss()[c]; - found = false; - for(int v = 0; v < oldpartialdec->getNOpenvars() && !found; ++v) - { - int var = oldpartialdec->getOpenvars()[v]; - for(i = 0; i < detprobdata->getNVarsForCons(cons) && !found; ++i) - { - if(var == detprobdata->getVarsForCons(cons)[i]) - { - conssBool[cons] = true; - found = true; - } - } - } - } - - for(int c = 0; c < oldpartialdec->getNOpenconss(); ++c) - { - int cons = oldpartialdec->getOpenconss()[c]; - if(conssBool[cons]) - conssForGraph.push_back(cons); - } - - - /* assign constraints to partition */ - for( i = 0; i < this->nconss; i++ ) - { - std::set blocks; - std::vector nonzeros = getConsNonzeroNodes(i); - for( size_t k = 0; k < nonzeros.size(); ++k ) - { - blocks.insert(partition[nonzeros[k]]); - } - if( blocks.size() > 1 ) - { - SCIP_CALL( SCIPhashmapInsert(constoblock, (void*) (size_t) conssForGraph[i], (void*) (size_t) (nblocks+1)) ); - } - else - { - int block = *(blocks.begin()); - SCIP_CALL( SCIPhashmapInsert(constoblock, (void*) (size_t) conssForGraph[i], (void*) (size_t) (block +1)) ); - ++(nsubscipconss[block]); - } - } - - /* first, make sure that there are constraints in every block, otherwise the hole thing is useless */ - for( i = 0; i < nblocks; ++i ) - { - if( nsubscipconss[i] == 0 ) - { - SCIPdebugMessage("Block %d does not have any constraints!\n", i); - emptyblocks = TRUE; - } - } - - if( !emptyblocks ) - { - (*firstpartialdec) = new PARTIALDECOMP(oldpartialdec); - SCIP_CALL( (*firstpartialdec)->assignPartialdecFromConstoblock(constoblock, nblocks) ); - (*secondpartialdec) = new PARTIALDECOMP(oldpartialdec); - SCIP_CALL( (*secondpartialdec)->assignBorderFromConstoblock(constoblock, nblocks) ); - SCIPhashmapFree(&constoblock); - } - else { - SCIPhashmapFree(&constoblock); - (*firstpartialdec) = NULL; - (*secondpartialdec) = NULL; - } - - SCIPfreeBufferArray(this->scip_, &nsubscipconss); - return SCIP_OKAY; -} - -template -SCIP_RETCODE HyperrowcolGraph::readPartition( - const char* filename /**< filename where the partition is stored */ - ) -{ - - ifstream input(filename); - if( !input.good() ) - { - SCIPerrorMessage("Could not open file <%s> for reading\n", filename); - return SCIP_READERROR; - } - for( int i = 0; i < this->nnonzeroes; ++i ) - { - int part = 0; - if( !(input >> part) ) - { - SCIPerrorMessage("Could not read from file <%s>. It may be in the wrong format\n", filename); - return SCIP_READERROR; - } - graph.setPartition(i,part); - } - - input.close(); - return SCIP_OKAY; - -} - -} /* namespace gcg */ -#endif diff --git a/headers/gcg/graph/hyperrowgraph.h b/headers/gcg/graph/hyperrowgraph.h deleted file mode 100644 index 789f0a7..0000000 --- a/headers/gcg/graph/hyperrowgraph.h +++ /dev/null @@ -1,143 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* */ -/* This file is part of the program */ -/* GCG --- Generic Column Generation */ -/* a Dantzig-Wolfe decomposition based extension */ -/* of the branch-cut-and-price framework */ -/* SCIP --- Solving Constraint Integer Programs */ -/* */ -/* Copyright (C) 2010-2022 Operations Research, RWTH Aachen University */ -/* Zuse Institute Berlin (ZIB) */ -/* */ -/* This program is free software; you can redistribute it and/or */ -/* modify it under the terms of the GNU Lesser General Public License */ -/* as published by the Free Software Foundation; either version 3 */ -/* of the License, or (at your option) any later version. */ -/* */ -/* This program is distributed in the hope that it will be useful, */ -/* but WITHOUT ANY WARRANTY; without even the implied warranty of */ -/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ -/* GNU Lesser General Public License for more details. */ -/* */ -/* You should have received a copy of the GNU Lesser General Public License */ -/* along with this program; if not, write to the Free Software */ -/* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.*/ -/* */ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -/**@file hyperrowgraph.h - * @brief Column hypergraph - * @author Martin Bergner - * @author Annika Thome - */ - -/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/ - - -#ifndef GCG_HYPERROWGRAPH_H_ -#define GCG_HYPERROWGRAPH_H_ - -#include "matrixgraph.h" -#include "hypergraph.h" -#include "class_partialdecomp.h" -#include "class_detprobdata.h" - -namespace gcg -{ -template -class HyperrowGraph: public gcg::MatrixGraph -{ -private: - Hypergraph graph; -public: - HyperrowGraph( - SCIP* scip, /**< SCIP data structure */ - Weights w /**< weights for the given graph */ - ); - - virtual ~HyperrowGraph(); - - /** writes the graph to the given file. - * The format is graph dependent - */ - SCIP_RETCODE writeToFile( - int fd, /**< filename where the graph should be written to */ - SCIP_Bool edgeweights /**< whether to write edgeweights */ - ); - - /** return the number of nodes */ - virtual int getNNodes(); - - /** return the number of edges (or hyperedges) */ - virtual int getNEdges(); - - /** return node degree */ - virtual int getNNeighbors( - int i - ); - - virtual std::vector getNeighbors( - int i - ) - { - return this->graph.getNeighbors(i); - } - - virtual std::vector getHyperedgeNodes( - int i - ); - - /** - * reads the partition from the given file. - * The format is graph dependent. The default is a file with one line for each node a - */ - virtual SCIP_RETCODE readPartition( - const char* filename /**< filename where the partition is stored */ - ) - { - SCIP_CALL( this->graph.readPartition(filename) ); - return SCIP_OKAY; - } - - /** return a partition of the nodes */ - virtual std::vector getPartition() - { - return this->graph.getPartition(); - } - - virtual SCIP_RETCODE createDecompFromPartition( - DEC_DECOMP** decomp /**< decomposition structure to generate */ - ); - - /** amplifies a partialdec by dint of a graph created with open constraints and open variables of the partialdec */ - virtual SCIP_RETCODE createPartialdecFromPartition( - PARTIALDECOMP* oldpartialdec, /**< partialdec which should be amplifies */ - PARTIALDECOMP** firstpartialdec, /**< pointer to buffer the new partialdec amplified by dint of the graph */ - PARTIALDECOMP** secondpartialdec, /**< pinter to buffer the new partialdec whose border is amplified by dint of the graph */ - DETPROBDATA* detprobdata /**< detection process information and data */ - ); - - /** creates a new partialdec by dint of a graph created with all constraints and variables */ - virtual SCIP_RETCODE createPartialdecFromPartition( - PARTIALDECOMP** firstpartialdec, /**< pointer to buffer the new partialdec created by dint of the graph */ - PARTIALDECOMP** secondpartialdec, /**< pointer to buffer the new partialdec whose border is amplified by dint of the graph */ - DETPROBDATA* detprobdata /**< detection process information and data */ - ); - - virtual SCIP_RETCODE createFromMatrix( - SCIP_CONS** conss, /**< constraints for which graph should be created */ - SCIP_VAR** vars, /**< variables for which graph should be created */ - int nconss_, /**< number of constraints */ - int nvars_ /**< number of variables */ - ); - - /** creates a graph with open constraints and open variables of the partialdec */ - virtual SCIP_RETCODE createFromPartialMatrix( - DETPROBDATA* detprobdata, /**< detection process information and data */ - PARTIALDECOMP* partialdec /**< partial decomposition to use for matrix */ - ); - -}; - -} /* namespace gcg */ -#endif /* GCG_HYPERROWGRAPH_H_ */ diff --git a/headers/gcg/graph/hyperrowgraph_def.h b/headers/gcg/graph/hyperrowgraph_def.h deleted file mode 100644 index 44044b0..0000000 --- a/headers/gcg/graph/hyperrowgraph_def.h +++ /dev/null @@ -1,593 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* */ -/* This file is part of the program */ -/* GCG --- Generic Column Generation */ -/* a Dantzig-Wolfe decomposition based extension */ -/* of the branch-cut-and-price framework */ -/* SCIP --- Solving Constraint Integer Programs */ -/* */ -/* Copyright (C) 2010-2022 Operations Research, RWTH Aachen University */ -/* Zuse Institute Berlin (ZIB) */ -/* */ -/* This program is free software; you can redistribute it and/or */ -/* modify it under the terms of the GNU Lesser General Public License */ -/* as published by the Free Software Foundation; either version 3 */ -/* of the License, or (at your option) any later version. */ -/* */ -/* This program is distributed in the hope that it will be useful, */ -/* but WITHOUT ANY WARRANTY; without even the implied warranty of */ -/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ -/* GNU Lesser General Public License for more details. */ -/* */ -/* You should have received a copy of the GNU Lesser General Public License */ -/* along with this program; if not, write to the Free Software */ -/* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.*/ -/* */ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -/**@file hyperrowgraph_def.h - * @brief Column hypergraph - * @author Martin Bergner - * @author Annika Thome - * - * Hypergraph with a node for every variable and a hyperedge for every constraint - */ - -/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/ -//#define SCIP_DEBUG - -#ifndef GCG_HYPERROWGRAPH_DEF_H_ -#define GCG_HYPERROWGRAPH_DEF_H_ - -#include "hyperrowgraph.h" -#include "scip_misc.h" -#include "class_partialdecomp.h" -#include "class_detprobdata.h" -#include -#include -#include - -namespace gcg -{ -template -HyperrowGraph::HyperrowGraph( - SCIP* scip, /**< SCIP data structure */ - Weights w /**< weights for the given graph */ -): MatrixGraph(scip, w), graph(scip) -{ - this->graphiface = &graph; - this->name = std::string("hyperrow"); -} - -template -HyperrowGraph::~HyperrowGraph() -{ - // TODO Auto-generated destructor stub -} - - -/** writes the graph to the given file. - * The format is graph dependent - */ -template -SCIP_RETCODE HyperrowGraph::writeToFile( - int fd, /**< filename where the graph should be written to */ - SCIP_Bool edgeweights /**< whether to write edgeweights */ - ) -{ - FILE* file; - file = fdopen(fd, "w"); - if( file == NULL ) - return SCIP_FILECREATEERROR; - - SCIPinfoMessage(this->scip_, file, "%d %d %d\n", getNEdges(), getNNodes()+this->dummynodes, edgeweights ? 1 :0); - - for( int i = 0; i < getNEdges(); ++i ) - { - std::vector neighbors = getHyperedgeNodes(i); - - if( edgeweights ) - { - SCIPinfoMessage(this->scip_, file, "%d ", graph.getWeight(i+this->nvars)); - } - for( size_t j = 0; j < neighbors.size(); ++j ) - { - SCIPinfoMessage(this->scip_, file, "%d ",neighbors[j]+1); - } - SCIPinfoMessage(this->scip_, file, "\n"); - } - - if( !fclose(file) ) - return SCIP_OKAY; - else - return SCIP_WRITEERROR; -} - -template -int HyperrowGraph::getNEdges() -{ - return this->nconss; -} - -template -int HyperrowGraph::getNNodes() -{ - return this->nvars; -} - -template -int HyperrowGraph::getNNeighbors( - int i -) -{ - assert(i >= 0); - assert(i < getNNodes()); - - return graph.getNNeighbors(i); -} - -template -std::vector HyperrowGraph::getHyperedgeNodes( - int i -) -{ - assert(i >= 0); - assert(i < getNEdges()); - - std::vector neighbors = graph.getHyperedgeNodes(i); - return neighbors; -} - -template -SCIP_RETCODE HyperrowGraph::createDecompFromPartition( - DEC_DECOMP** decomp /**< decomposition structure to generate */ -) -{ - int nblocks; - SCIP_HASHMAP* constoblock = NULL; - - int* nsubscipconss = NULL; - int i; - SCIP_CONS** conss = NULL; - SCIP_Bool emptyblocks = FALSE; - std::vector partition = graph.getPartition(); - conss = SCIPgetConss(this->scip_); - nblocks = *(std::max_element(partition.begin(), partition.end()))+1; - - SCIP_CALL( SCIPallocBufferArray(this->scip_, &nsubscipconss, nblocks) ); - BMSclearMemoryArray(nsubscipconss, nblocks); - - SCIP_CALL( SCIPhashmapCreate(&constoblock, SCIPblkmem(this->scip_), this->nconss) ); - - /* assign constraints to partition */ - for( i = 0; i < this->nconss; i++ ) - { - - std::set blocks; - std::vector neighbors = getHyperedgeNodes(i); - for( size_t k = 0; k < neighbors.size(); ++k ) - { - if( partition[neighbors[k]] >= 0 ) - blocks.insert(partition[neighbors[k]]); - } - if( blocks.size() > 1 ) - { - SCIP_CALL( SCIPhashmapInsert(constoblock, conss[i], (void*) (size_t) (nblocks+1)) ); - } - else - { - int block = *(blocks.begin()); - SCIP_CALL( SCIPhashmapInsert(constoblock, conss[i], (void*) (size_t) (block +1)) ); - ++(nsubscipconss[block]); - } - } - - /* first, make sure that there are constraints in every block, otherwise the hole thing is useless */ - for( i = 0; i < nblocks; ++i ) - { - if( nsubscipconss[i] == 0 ) - { - SCIPdebugMessage("Block %d does not have any constraints!\n", i); - emptyblocks = TRUE; - } - } - - if( !emptyblocks ) - { - SCIP_CALL( DECdecompCreate(this->scip_, decomp) ); - SCIP_CALL( DECfilloutDecompFromConstoblock(this->scip_, *decomp, constoblock, nblocks, FALSE) ); - } - else { - SCIPhashmapFree(&constoblock); - *decomp = NULL; - } - - SCIPfreeBufferArray(this->scip_, &nsubscipconss); - return SCIP_OKAY; -} - -template -SCIP_RETCODE HyperrowGraph::createPartialdecFromPartition( - PARTIALDECOMP** firstpartialdec, - PARTIALDECOMP** secondpartialdec, - DETPROBDATA* detprobdata - ) -{ - int nblocks; - SCIP_HASHMAP* constoblock = NULL; - - int* nsubscipconss = NULL; - int i; - SCIP_CONS** conss = NULL; - SCIP_Bool emptyblocks = FALSE; - std::vector partition = graph.getPartition(); - conss = SCIPgetConss(this->scip_); - nblocks = *(std::max_element(partition.begin(), partition.end()))+1; - - SCIP_CALL( SCIPallocBufferArray(this->scip_, &nsubscipconss, nblocks) ); - BMSclearMemoryArray(nsubscipconss, nblocks); - - SCIP_CALL( SCIPhashmapCreate(&constoblock, SCIPblkmem(this->scip_), this->nconss) ); - - /* assign constraints to partition */ - for( i = 0; i < this->nconss; i++ ) - { - - std::set blocks; - std::vector neighbors = getHyperedgeNodes(i); - for( size_t k = 0; k < neighbors.size(); ++k ) - { - if( partition[neighbors[k]] >= 0 ) - blocks.insert(partition[neighbors[k]]); - } - if( blocks.size() > 1 ) - { - SCIP_CALL( SCIPhashmapInsert(constoblock, (void*) (size_t)detprobdata->getIndexForCons(conss[i]), (void*) (size_t) (nblocks+1)) ); - } - else - { - int block = *(blocks.begin()); - SCIP_CALL( SCIPhashmapInsert(constoblock, (void*) (size_t)detprobdata->getIndexForCons(conss[i]), (void*) (size_t) (block +1)) ); - ++(nsubscipconss[block]); - } - } - - /* first, make sure that there are constraints in every block, otherwise the hole thing is useless */ - for( i = 0; i < nblocks; ++i ) - { - if( nsubscipconss[i] == 0 ) - { - SCIPdebugMessage("Block %d does not have any constraints!\n", i); - emptyblocks = TRUE; - } - } - - if( !emptyblocks ) - { - bool original = detprobdata->isAssignedToOrigProb(); - if( firstpartialdec != NULL ) - { - (*firstpartialdec) = new PARTIALDECOMP(this->scip_, original); - SCIP_CALL((*firstpartialdec)->filloutPartialdecFromConstoblock(constoblock, nblocks)); - } - if( secondpartialdec != NULL ) - { - (*secondpartialdec) = new PARTIALDECOMP(this->scip_, original); - SCIP_CALL((*secondpartialdec)->filloutBorderFromConstoblock(constoblock, nblocks)); - } - SCIPhashmapFree(&constoblock); - } - else { - SCIPhashmapFree(&constoblock); - if( firstpartialdec != NULL ) - { - *firstpartialdec = NULL; - } - if( secondpartialdec != NULL ) - { - *secondpartialdec = NULL; - } - } - - SCIPfreeBufferArray(this->scip_, &nsubscipconss); - return SCIP_OKAY; -} - -template -SCIP_RETCODE HyperrowGraph::createPartialdecFromPartition( - PARTIALDECOMP* oldpartialdec, - PARTIALDECOMP** firstpartialdec, - PARTIALDECOMP** secondpartialdec, - DETPROBDATA* detprobdata - ) -{ - int nblocks; - SCIP_HASHMAP* constoblock = NULL; - - int *nsubscipconss = NULL; - int i; - SCIP_Bool emptyblocks = FALSE; - - if(this->nconss == 0) - { - (*firstpartialdec) = NULL; - (*secondpartialdec) = NULL; - return SCIP_OKAY; - } - - std::vector partition = graph.getPartition(); - nblocks = *(std::max_element(partition.begin(), partition.end()))+1; - - SCIP_CALL( SCIPallocBufferArray(this->scip_, &nsubscipconss, nblocks) ); - BMSclearMemoryArray(nsubscipconss, nblocks); - - for(int b = 0; b < nblocks; ++b) - { - nsubscipconss[b] = 0; - } - - SCIP_CALL( SCIPhashmapCreate(&constoblock, SCIPblkmem(this->scip_), this->nconss) ); - - //fillout conssForGraph - vector conssForGraph; /** stores the conss included by the graph */ - vector conssBool(oldpartialdec->getNConss(), false); /**< true, if the cons will be part of the graph */ - bool found; - - for(int c = 0; c < oldpartialdec->getNOpenconss(); ++c) - { - int cons = oldpartialdec->getOpenconss()[c]; - found = false; - for(int v = 0; v < oldpartialdec->getNOpenvars() && !found; ++v) - { - int var = oldpartialdec->getOpenvars()[v]; - for(i = 0; i < detprobdata->getNVarsForCons(cons) && !found; ++i) - { - if(var == detprobdata->getVarsForCons(cons)[i]) - { - conssBool[cons] = true; - found = true; - } - } - } - } - - for(int c = 0; c < oldpartialdec->getNOpenconss(); ++c) - { - int cons = oldpartialdec->getOpenconss()[c]; - if(conssBool[cons]) - conssForGraph.push_back(cons); - } - - /* assign constraints to partition */ - for( i = 0; i < this->nconss; i++ ) - { - - std::set blocks; - std::vector neighbors = getHyperedgeNodes(i); - for( size_t k = 0; k < neighbors.size(); ++k ) - { - if( partition[neighbors[k]] >= 0 ) - blocks.insert(partition[neighbors[k]]); - } - if( blocks.size() > 1 ) - { - SCIP_CALL( SCIPhashmapInsert(constoblock, (void*) (size_t) conssForGraph[i], (void*) (size_t) (nblocks+1)) ); - } - else - { - int block = *(blocks.begin()); - SCIP_CALL( SCIPhashmapInsert(constoblock, (void*) (size_t) conssForGraph[i], (void*) (size_t) (block +1)) ); - ++(nsubscipconss[block]); - } - } - - /* first, make sure that there are constraints in every block, otherwise the hole thing is useless */ - for( i = 0; i < nblocks; ++i ) - { - if( nsubscipconss[i] == 0 ) - { - SCIPdebugMessage("Block %d does not have any constraints!\n", i); - emptyblocks = TRUE; - } - } - - if( !emptyblocks ) - { - (*firstpartialdec) = new PARTIALDECOMP(oldpartialdec); - SCIP_CALL( (*firstpartialdec)->assignPartialdecFromConstoblock(constoblock, nblocks) ); - (*secondpartialdec) = new PARTIALDECOMP(oldpartialdec); - SCIP_CALL( (*secondpartialdec)->assignBorderFromConstoblock(constoblock, nblocks) ); - SCIPhashmapFree(&constoblock); - } - else { - SCIPhashmapFree(&constoblock); - *firstpartialdec = NULL; - *secondpartialdec = NULL; - } - - SCIPfreeBufferArray(this->scip_, &nsubscipconss); - return SCIP_OKAY; -} - -template -SCIP_RETCODE HyperrowGraph::createFromMatrix( - SCIP_CONS** conss, /**< constraints for which graph should be created */ - SCIP_VAR** vars, /**< variables for which graph should be created */ - int nconss_, /**< number of constraints */ - int nvars_ /**< number of variables */ - ) -{ - int i; - int j; - SCIP_Bool success; - - assert(conss != NULL); - assert(vars != NULL); - assert(nvars_ > 0); - assert(nconss_ > 0); - - this->nvars = nvars_; - this->nconss = nconss_; - - /* go through all variables */ - for( i = 0; i < this->nvars; ++i ) - { - TCLIQUE_WEIGHT weight; - - /* calculate weight of node */ - weight = this->weights.calculate(vars[i]); - - this->graph.addNode(i, weight); - } - - /* go through all constraints */ - for( i = 0; i < this->nconss; ++i ) - { - SCIP_VAR** curvars = NULL; - std::vector hyperedge; - TCLIQUE_WEIGHT weight; - - int ncurvars; - SCIP_CALL( SCIPgetConsNVars(this->scip_, conss[i], &ncurvars, &success) ); - assert(success); - if( ncurvars == 0 ) - continue; - - /* - * may work as is, as we are copying the constraint later regardless - * if there are variables in it or not - */ - SCIP_CALL( SCIPallocBufferArray(this->scip_, &curvars, ncurvars) ); - SCIP_CALL( SCIPgetConsVars(this->scip_, conss[i], curvars, ncurvars, &success) ); - assert(success); - - /** @todo skip all variables that have a zero coeffient or where all coefficients add to zero */ - /** @todo Do more then one entry per variable actually work? */ - - for( j = 0; j < ncurvars; ++j ) - { - SCIP_VAR* var1 = NULL; - int varIndex1; - - if( SCIPgetStage(this->scip_) >= SCIP_STAGE_TRANSFORMED) - var1 = SCIPvarGetProbvar(curvars[j]); - else - var1 = curvars[j]; - - if( !GCGisVarRelevant(var1) ) - continue; - - assert(var1 != NULL); - varIndex1 = SCIPvarGetProbindex(var1); - assert(varIndex1 >= 0); - assert(varIndex1 < this->nvars); - - hyperedge.insert(hyperedge.end(), varIndex1); - } - /* calculate weight of hyperedge */ - weight = this->weights.calculate(conss[i]); - - this->graph.addHyperedge(hyperedge, weight); - - SCIPfreeBufferArray(this->scip_, &curvars); - } - - - - this->graph.flush(); - return SCIP_OKAY; -} - - - -template -SCIP_RETCODE HyperrowGraph::createFromPartialMatrix( - DETPROBDATA* detprobdata, - PARTIALDECOMP* partialdec - ){ - int i; - int j; - unordered_map oldToNewVarIndex; - TCLIQUE_WEIGHT weight; - - vector varsBool(partialdec->getNVars(), false); /**< true, if the var will be part of the graph */ - vector conssBool(partialdec->getNConss(), false); /**< true, if the cons will be part of the graph */ - vector conssForGraph; /** stores the conss included by the graph */ - vector varsForGraph; /** stores the vars included by the graph */ - - //fillout conssForGraph and varsForGraph - for(int c = 0; c < partialdec->getNOpenconss(); ++c) - { - int cons = partialdec->getOpenconss()[c]; - for(int v = 0; v < partialdec->getNOpenvars(); ++v) - { - int var = partialdec->getOpenvars()[v]; - for(i = 0; i < detprobdata->getNVarsForCons(cons); ++i) - { - if(var == detprobdata->getVarsForCons(cons)[i]) - { - varsBool[var] = true; - conssBool[cons] = true; - } - } - } - } - - for(int v = 0; v < partialdec->getNOpenvars(); ++v) - { - int var = partialdec->getOpenvars()[v]; - if(varsBool[var]) - varsForGraph.push_back(var); - } - for(int c = 0; c < partialdec->getNOpenconss(); ++c) - { - int cons = partialdec->getOpenconss()[c]; - if(conssBool[cons]) - conssForGraph.push_back(cons); - } - - this->nconss = (int)conssForGraph.size(); - this->nvars = (int)varsForGraph.size(); - - /* go through all variables */ - for( i = 0; i < this->nvars; ++i ) - { - int oldVarId = varsForGraph[i]; - assert(varsBool[oldVarId]); - - /* calculate weight of node */ - weight = this->weights.calculate(detprobdata->getVar(oldVarId)); - - oldToNewVarIndex.insert({oldVarId,i}); - this->graph.addNode(i, weight); - } - - /* go through all open constraints */ - for( i = 0; i < this->nconss; ++i ) - { - std::vector hyperedge; - int oldConsId = conssForGraph[i]; - - assert(conssBool[oldConsId]); - - for( j = 0; j < detprobdata->getNVarsForCons(oldConsId); ++j ) - { - int oldVarId = detprobdata->getVarsForCons(oldConsId)[j]; - if(!varsBool[oldVarId]) - continue; - hyperedge.insert(hyperedge.end(), oldToNewVarIndex[oldVarId]); - } - /* calculate weight of hyperedge */ - weight = this->weights.calculate(detprobdata->getCons(oldConsId)); - this->graph.addHyperedge(hyperedge, weight); - } - - - this->graph.flush(); - return SCIP_OKAY; -} - - -} /* namespace gcg */ - -#endif diff --git a/headers/gcg/graph/matrixgraph.h b/headers/gcg/graph/matrixgraph.h deleted file mode 100644 index 2be20ea..0000000 --- a/headers/gcg/graph/matrixgraph.h +++ /dev/null @@ -1,160 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* */ -/* This file is part of the program */ -/* GCG --- Generic Column Generation */ -/* a Dantzig-Wolfe decomposition based extension */ -/* of the branch-cut-and-price framework */ -/* SCIP --- Solving Constraint Integer Programs */ -/* */ -/* Copyright (C) 2010-2022 Operations Research, RWTH Aachen University */ -/* Zuse Institute Berlin (ZIB) */ -/* */ -/* This program is free software; you can redistribute it and/or */ -/* modify it under the terms of the GNU Lesser General Public License */ -/* as published by the Free Software Foundation; either version 3 */ -/* of the License, or (at your option) any later version. */ -/* */ -/* This program is distributed in the hope that it will be useful, */ -/* but WITHOUT ANY WARRANTY; without even the implied warranty of */ -/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ -/* GNU Lesser General Public License for more details. */ -/* */ -/* You should have received a copy of the GNU Lesser General Public License */ -/* along with this program; if not, write to the Free Software */ -/* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.*/ -/* */ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -/**@file matrixgraph.h - * @brief miscellaneous matrixgraph methods for structure detection - * @author Martin Bergner - * @author Annika Thome - */ - -/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/ - - -#ifndef GCG_MATRIXGRAPH_H_ -#define GCG_MATRIXGRAPH_H_ -#include "objscip/objscip.h" -#include "tclique/tclique.h" -#include "weights.h" -#include "pub_decomp.h" -#include "bridge.h" -#include "graph_interface.h" -#include "class_partialdecomp.h" -#include "class_detprobdata.h" -#include -#include -#include - -namespace gcg { - -template -class MatrixGraph { -public: - std::string name; -protected: - SCIP* scip_; - int nconss; - int nvars; - int dummynodes; - Weights weights; - GraphInterface *graphiface; - int nnonzeroes; - -public: - /** Constructor */ - MatrixGraph( - SCIP* scip, /**< SCIP data structure */ - Weights w /**< weights for the given graph */ - ); - - /** Destructor */ - virtual ~MatrixGraph(); - - /** writes the graph to the given file. - * The format is graph dependent - */ - virtual SCIP_RETCODE writeToFile( - int fd, /**< file descriptor where the graph should be written to */ - SCIP_Bool writeweights /**< whether to write weights */ - ) - { - SCIP_CALL(graphiface->writeToFile(fd, writeweights) ); - return SCIP_OKAY; - } - - - virtual SCIP_RETCODE createDecompFromPartition( - DEC_DECOMP** decomp /**< decomposition structure to generate */ - ) - { - return SCIP_ERROR; - } - - - - /** amplifies a partialdec by dint of a graph created with open constraints and open variables of the partialdec */ - virtual SCIP_RETCODE createPartialdecFromPartition( - PARTIALDECOMP* oldpartialdec, /**< partialdec which should be amplifies */ - PARTIALDECOMP** firstpartialdec, /**< pointer to buffer the new partialdec amplified by dint of the graph */ - PARTIALDECOMP** secondpartialdec, /**< pinter to buffer the new partialdec whose border is amplified by dint of the graph */ - DETPROBDATA* detprobdata /**< detection process information and data */ - ) - { - return SCIP_ERROR; - } - - /** - * reads the partition from the given file. - * The format is graph dependent. The default is a file with one line for each node a - */ - virtual SCIP_RETCODE readPartition( - const char* filename /**< filename where the partition is stored */ - ) - { - SCIP_CALL( graphiface->readPartition(filename) ); - return SCIP_OKAY; - } - - /** set the number of dummy nodes */ - void setDummynodes(int dummynodes_) - { - dummynodes = dummynodes_; - } - - int getDummynodes() const - { - return dummynodes; - } - - /** return a partition of the nodes */ - virtual std::vector getPartition() - { - return graphiface->getPartition(); - } - - virtual SCIP_RETCODE createFromMatrix( - SCIP_CONS** conss, /**< constraints for which graph should be created */ - SCIP_VAR** vars, /**< variables for which graph should be created */ - int nconss_, /**< number of constraints */ - int nvars_ /**< number of variables */ - ) { return SCIP_ERROR; } - - /** creates a graph with open constraints and open variables of the partialdec */ - virtual SCIP_RETCODE createFromPartialMatrix( - DETPROBDATA* detprobdata, - PARTIALDECOMP* partialdec - ) { return SCIP_ERROR; } - - - virtual int getNNonzeroes() const - { - return nnonzeroes; - } -}; - -} - -#endif diff --git a/headers/gcg/graph/matrixgraph_def.h b/headers/gcg/graph/matrixgraph_def.h deleted file mode 100644 index 6506e88..0000000 --- a/headers/gcg/graph/matrixgraph_def.h +++ /dev/null @@ -1,61 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* */ -/* This file is part of the program */ -/* GCG --- Generic Column Generation */ -/* a Dantzig-Wolfe decomposition based extension */ -/* of the branch-cut-and-price framework */ -/* SCIP --- Solving Constraint Integer Programs */ -/* */ -/* Copyright (C) 2010-2022 Operations Research, RWTH Aachen University */ -/* Zuse Institute Berlin (ZIB) */ -/* */ -/* This program is free software; you can redistribute it and/or */ -/* modify it under the terms of the GNU Lesser General Public License */ -/* as published by the Free Software Foundation; either version 3 */ -/* of the License, or (at your option) any later version. */ -/* */ -/* This program is distributed in the hope that it will be useful, */ -/* but WITHOUT ANY WARRANTY; without even the implied warranty of */ -/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ -/* GNU Lesser General Public License for more details. */ -/* */ -/* You should have received a copy of the GNU Lesser General Public License */ -/* along with this program; if not, write to the Free Software */ -/* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.*/ -/* */ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -/**@file matrixgraph_def.h - * @brief miscellaneous matrixgraph methods for structure detection - * @author Martin Bergner - */ - -/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/ - -#ifndef GCG_MATRIXGRAPH_DEF_H_ -#define GCG_MATRIXGRAPH_DEF_H_ - -#include "scip/scip.h" -#include "matrixgraph.h" - -namespace gcg { - -template -MatrixGraph::MatrixGraph( - SCIP* scip, /**< SCIP data structure */ - Weights w /**< weights for the given graph */ -) : name("graph"),scip_(scip),nconss(0),nvars(0),dummynodes(0),weights(w),graphiface(NULL),nnonzeroes(0) -{ - -} - -template -MatrixGraph::~MatrixGraph() -{ - -} - - -} /* namespace gcg */ - -#endif diff --git a/headers/gcg/graph/rowgraph.h b/headers/gcg/graph/rowgraph.h deleted file mode 100644 index af62b54..0000000 --- a/headers/gcg/graph/rowgraph.h +++ /dev/null @@ -1,78 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* */ -/* This file is part of the program */ -/* GCG --- Generic Column Generation */ -/* a Dantzig-Wolfe decomposition based extension */ -/* of the branch-cut-and-price framework */ -/* SCIP --- Solving Constraint Integer Programs */ -/* */ -/* Copyright (C) 2010-2022 Operations Research, RWTH Aachen University */ -/* Zuse Institute Berlin (ZIB) */ -/* */ -/* This program is free software; you can redistribute it and/or */ -/* modify it under the terms of the GNU Lesser General Public License */ -/* as published by the Free Software Foundation; either version 3 */ -/* of the License, or (at your option) any later version. */ -/* */ -/* This program is distributed in the hope that it will be useful, */ -/* but WITHOUT ANY WARRANTY; without even the implied warranty of */ -/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ -/* GNU Lesser General Public License for more details. */ -/* */ -/* You should have received a copy of the GNU Lesser General Public License */ -/* along with this program; if not, write to the Free Software */ -/* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.*/ -/* */ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -/**@file rowgraph.h - * @brief A row graph where each row is a node and rows are adjacent if they share a variable - * @author Martin Bergner - * @author Annika Thome - */ - -/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/ - -#ifndef GCG_ROWGRAPH_H_ -#define GCG_ROWGRAPH_H_ - -#include "graph.h" -#include "bipartitegraph.h" -#include "matrixgraph.h" - -namespace gcg { -template -class RowGraph : public gcg::MatrixGraph -{ -protected: - gcg::Graph graph; - -public: - RowGraph( - SCIP* scip, /**< SCIP data structure */ - Weights w /**< weights for the given graph */ - ); - virtual ~RowGraph(); - - virtual SCIP_RETCODE createDecompFromPartition( - DEC_DECOMP** decomp /**< decomposition structure to generate */ - ); - - /** amplifies a partialdec by dint of a graph created with open constraints and open variables of the partialdec */ - virtual SCIP_RETCODE createPartialdecFromPartition( - PARTIALDECOMP* oldpartialdec, /**< partialdec which should be amplifies */ - PARTIALDECOMP** firstpartialdec, /**< pointer to buffer the new partialdec amplified by dint of the graph */ - PARTIALDECOMP** secondpartialdec, /**< pointer to buffer the new partialdec whose border is amplified by dint of the graph */ - DETPROBDATA* detprobdata /**< datprobdata the partialdecs correspond to */ - ); - - virtual SCIP_RETCODE createFromMatrix( - SCIP_CONS** conss, /**< constraints for which graph should be created */ - SCIP_VAR** vars, /**< variables for which graph should be created */ - int nconss_, /**< number of constraints */ - int nvars_ /**< number of variables */ - ); -}; - -} /* namespace gcg */ -#endif /* GCG_ROWGRAPH_H_ */ diff --git a/headers/gcg/graph/rowgraph_def.h b/headers/gcg/graph/rowgraph_def.h deleted file mode 100644 index afab72c..0000000 --- a/headers/gcg/graph/rowgraph_def.h +++ /dev/null @@ -1,394 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* */ -/* This file is part of the program */ -/* GCG --- Generic Column Generation */ -/* a Dantzig-Wolfe decomposition based extension */ -/* of the branch-cut-and-price framework */ -/* SCIP --- Solving Constraint Integer Programs */ -/* */ -/* Copyright (C) 2010-2022 Operations Research, RWTH Aachen University */ -/* Zuse Institute Berlin (ZIB) */ -/* */ -/* This program is free software; you can redistribute it and/or */ -/* modify it under the terms of the GNU Lesser General Public License */ -/* as published by the Free Software Foundation; either version 3 */ -/* of the License, or (at your option) any later version. */ -/* */ -/* This program is distributed in the hope that it will be useful, */ -/* but WITHOUT ANY WARRANTY; without even the implied warranty of */ -/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ -/* GNU Lesser General Public License for more details. */ -/* */ -/* You should have received a copy of the GNU Lesser General Public License */ -/* along with this program; if not, write to the Free Software */ -/* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.*/ -/* */ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -/**@file rowgraph_def.h - * @brief A row graph where each row is a node and rows are adjacent if they share a variable - * @author Martin Bergner - * @author Annika Thome - */ - -/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/ -// #define SCIP_DEBUG - -#ifndef GCG_ROWGRAPH_DEF_H_ -#define GCG_ROWGRAPH_DEF_H_ - -#include "rowgraph.h" -#include - -namespace gcg { - -template -RowGraph::RowGraph( - SCIP* scip, /**< SCIP data structure */ - Weights w /**< weights for the given graph */ - ) : MatrixGraph(scip,w), graph(scip) -{ - this->graphiface = &graph; - this->name = std::string("rowgraph"); -} - -template -RowGraph::~RowGraph() -{ - // TODO Auto-generated destructor stub -} - -template -SCIP_RETCODE RowGraph::createDecompFromPartition( - DEC_DECOMP** decomp /**< decomposition structure to generate */ -) -{ - int nblocks; - SCIP_HASHMAP* constoblock = NULL; - - int* nsubscipconss = NULL; - int i; - SCIP_CONS** conss = NULL; - SCIP_Bool emptyblocks = FALSE; - std::vector partition = graph.getPartition(); - conss = SCIPgetConss(this->scip_); - nblocks = *(std::max_element(partition.begin(), partition.end()))+1; - - SCIP_CALL( SCIPallocBufferArray(this->scip_, &nsubscipconss, nblocks) ); - BMSclearMemoryArray(nsubscipconss, nblocks); - - SCIP_CALL( SCIPhashmapCreate(&constoblock, SCIPblkmem(this->scip_), this->nconss) ); - - /* assign constraints to partition */ - for( i = 0; i < this->nconss; i++ ) - { - int block = partition[i]; - - if(block == -1) - { - SCIP_CALL( SCIPhashmapInsert(constoblock, conss[i], (void*) (size_t) (nblocks +1)) ); - } - else - { assert(block >= 0); - assert(block < nblocks); - SCIP_CALL( SCIPhashmapInsert(constoblock, conss[i], (void*) (size_t) (block +1)) ); - ++(nsubscipconss[block]); - } - - } - - - // TODO: remove- FOR DEBUG ONLY!!! - std::vector nsubscipconss_dbg(nblocks); - - /* first, make sure that there are constraints in every block, otherwise the hole thing is useless */ - for( i = 0; i < nblocks; ++i ) - { - // TODO: remove- FOR DEBUG ONLY!!! - nsubscipconss_dbg[i] = nsubscipconss[i]; - if( nsubscipconss[i] == 0 ) - { - SCIPdebugMessage("Block %d does not have any constraints!\n", i); - emptyblocks = TRUE; - } - } - - if( !emptyblocks ) - { - SCIP_CALL( DECdecompCreate(this->scip_, decomp) ); - SCIP_CALL( DECfilloutDecompFromConstoblock(this->scip_, *decomp, constoblock, nblocks, FALSE) ); - } - else { - SCIPhashmapFree(&constoblock); - *decomp = NULL; - } - - SCIPfreeBufferArray(this->scip_, &nsubscipconss); - return SCIP_OKAY; -} - -template -SCIP_RETCODE RowGraph::createPartialdecFromPartition( - PARTIALDECOMP* oldpartialdec, - PARTIALDECOMP** firstpartialdec, - PARTIALDECOMP** secondpartialdec, - DETPROBDATA* detprobdata - ) -{ - int nblocks; - SCIP_HASHMAP* constoblock = NULL; - - int* nsubscipconss = NULL; - int i; - SCIP_Bool emptyblocks = FALSE; - - //fillout conssForGraph - std::vector conssForGraph; /** stores the conss included by the graph */ - std::vector conssBool(oldpartialdec->getNConss(), false); /**< true, if the cons will be part of the graph */ - bool found; - - for(int c = 0; c < oldpartialdec->getNOpenconss(); ++c) - { - int cons = oldpartialdec->getOpenconss()[c]; - found = false; - for(int v = 0; v < oldpartialdec->getNOpenvars() && !found; ++v) - { - int var = oldpartialdec->getOpenvars()[v]; - for(i = 0; i < detprobdata->getNVarsForCons(cons) && !found; ++i) - { - if(var == detprobdata->getVarsForCons(cons)[i]) - { - conssBool[cons] = true; - found = true; - } - } - } - } - - for(int c = 0; c < oldpartialdec->getNOpenconss(); ++c) - { - int cons = oldpartialdec->getOpenconss()[c]; - if(conssBool[cons]) - conssForGraph.push_back(cons); - } - - std::vector partition = graph.getPartition(); - nblocks = *(std::max_element(partition.begin(), partition.end()))+1; - - SCIP_CALL( SCIPallocBufferArray(this->scip_, &nsubscipconss, nblocks) ); - BMSclearMemoryArray(nsubscipconss, nblocks); - - SCIP_CALL( SCIPhashmapCreate(&constoblock, SCIPblkmem(this->scip_), this->nconss) ); - - /* assign constraints to partition */ - for( i = 0; i < this->nconss; i++ ) - { - int block = partition[i]; - - if(block == -1) - { - SCIP_CALL( SCIPhashmapInsert(constoblock, (void*) (size_t) conssForGraph[i], (void*) (size_t) (nblocks +1)) ); - } - else - { assert(block >= 0); - assert(block < nblocks); - SCIP_CALL( SCIPhashmapInsert(constoblock, (void*) (size_t) conssForGraph[i], (void*) (size_t) (block +1)) ); - ++(nsubscipconss[block]); - } - - } - - /* first, make sure that there are constraints in every block, otherwise the hole thing is useless */ - for( i = 0; i < nblocks; ++i ) - { - if( nsubscipconss[i] == 0 ) - { - SCIPdebugMessage("Block %d does not have any constraints!\n", i); - emptyblocks = TRUE; - } - } - - if( !emptyblocks ) - { - if( firstpartialdec != NULL ) - { - (*firstpartialdec) = new PARTIALDECOMP(oldpartialdec); - SCIP_CALL((*firstpartialdec)->assignPartialdecFromConstoblock(constoblock, nblocks)); - } - if( secondpartialdec != NULL ) - { - (*secondpartialdec) = new PARTIALDECOMP(oldpartialdec); - SCIP_CALL((*secondpartialdec)->assignBorderFromConstoblock(constoblock, nblocks)); - } - SCIPhashmapFree(&constoblock); - } - else - { - SCIPhashmapFree(&constoblock); - if( firstpartialdec != NULL ) - { - (*firstpartialdec) = NULL; - } - if( secondpartialdec != NULL ) - { - (*secondpartialdec) = NULL; - } - } - - SCIPfreeBufferArray(this->scip_, &nsubscipconss); - return SCIP_OKAY; -} - -template -SCIP_RETCODE RowGraph::createFromMatrix( - SCIP_CONS** conss, /**< constraints for which graph should be created */ - SCIP_VAR** vars, /**< variables for which graph should be created */ - int nconss_, /**< number of constraints */ - int nvars_ /**< number of variables */ - ) -{ - int i; - int j; - int k; - int l; - SCIP_Bool success; - - std::pair< int, int> edge; - std::vector< std::pair< int, int> > edges; - - assert(conss != NULL); - assert(vars != NULL); - assert(nvars_ > 0); - assert(nconss_ > 0); - - this->nvars = nvars_; - this->nconss = nconss_; - - /* go through all constraints */ - for( i = 0; i < this->nconss; ++i ) - { - TCLIQUE_WEIGHT weight; - - /* calculate weight of node */ - weight = this->weights.calculate(conss[i]); - - this->graph.addNode(i, weight); - } - - /* go through all constraints */ - for( i = 0; i < this->nconss; ++i ) - { - SCIP_VAR** curvars1 = NULL; - - int ncurvars1; - SCIP_CALL( SCIPgetConsNVars(this->scip_, conss[i], &ncurvars1, &success) ); - assert(success); - if( ncurvars1 == 0 ) - continue; - - /* - * may work as is, as we are copying the constraint later regardless - * if there are variables in it or not - */ - SCIP_CALL( SCIPallocBufferArray(this->scip_, &curvars1, ncurvars1) ); - SCIP_CALL( SCIPgetConsVars(this->scip_, conss[i], curvars1, ncurvars1, &success) ); - assert(success); - - /* go through all constraints */ - for( j = 0; j < i; ++j ) - { - SCIP_VAR** curvars2 = NULL; - SCIP_Bool continueloop; - int ncurvars2; - SCIP_CALL( SCIPgetConsNVars(this->scip_, conss[j], &ncurvars2, &success) ); - assert(success); - if( ncurvars2 == 0 ) - continue; - - edge = std::make_pair(MIN(i, j), MAX(i, j) ); - - /* check if edge was not already added to graph */ - if(edges.end() != std::find(edges.begin(), edges.end(), edge) ) - continue; - - /*if(this->graph.edge(i, j)) - continue; - */ - continueloop = FALSE; - /* - * may work as is, as we are copying the constraint later regardless - * if there are variables in it or not - */ - SCIP_CALL( SCIPallocBufferArray(this->scip_, &curvars2, ncurvars2) ); - SCIP_CALL( SCIPgetConsVars(this->scip_, conss[j], curvars2, ncurvars2, &success) ); - assert(success); - - - /** @todo skip all variables that have a zero coeffient or where all coefficients add to zero */ - /** @todo Do more then one entry per variable actually work? */ - - for( k = 0; k < ncurvars1; ++k ) - { - SCIP_VAR* var1 = NULL; - int varIndex1; - - if( SCIPgetStage(this->scip_) >= SCIP_STAGE_TRANSFORMED) - var1 = SCIPvarGetProbvar(curvars1[k]); - else - var1 = curvars1[k]; - - if( !GCGisVarRelevant(var1) ) - continue; - - assert(var1 != NULL); - varIndex1 = SCIPvarGetProbindex(var1); - assert(varIndex1 >= 0); - assert(varIndex1 < this->nvars); - - for( l = 0; l < ncurvars2; ++l ) - { - SCIP_VAR* var2; - int varIndex2; - - if( SCIPgetStage(this->scip_) >= SCIP_STAGE_TRANSFORMED) - var2 = SCIPvarGetProbvar(curvars2[l]); - else - var2 = curvars2[l]; - - if( !GCGisVarRelevant(var2) ) - continue; - - assert(var2 != NULL); - varIndex2 = SCIPvarGetProbindex(var2); - assert(varIndex2 >= 0); - assert(varIndex2 < this->nvars); - - if(varIndex1 == varIndex2) - { - SCIP_CALL( this->graph.addEdge(i, j) ); - - edges.push_back(edge); - std::sort(edges.begin(), edges.end()); - - /* - * this->graph.flush(); - */ - - continueloop = TRUE; - break; - } - } - if(continueloop) - break; - } - SCIPfreeBufferArray(this->scip_, &curvars2); - } - SCIPfreeBufferArray(this->scip_, &curvars1); - } - this->graph.flush(); - - return SCIP_OKAY; -} - -} /* namespace gcg */ -#endif diff --git a/headers/gcg/graph/weights.h b/headers/gcg/graph/weights.h deleted file mode 100644 index 1b250c5..0000000 --- a/headers/gcg/graph/weights.h +++ /dev/null @@ -1,68 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* */ -/* This file is part of the program */ -/* GCG --- Generic Column Generation */ -/* a Dantzig-Wolfe decomposition based extension */ -/* of the branch-cut-and-price framework */ -/* SCIP --- Solving Constraint Integer Programs */ -/* */ -/* Copyright (C) 2010-2022 Operations Research, RWTH Aachen University */ -/* Zuse Institute Berlin (ZIB) */ -/* */ -/* This program is free software; you can redistribute it and/or */ -/* modify it under the terms of the GNU Lesser General Public License */ -/* as published by the Free Software Foundation; either version 3 */ -/* of the License, or (at your option) any later version. */ -/* */ -/* This program is distributed in the hope that it will be useful, */ -/* but WITHOUT ANY WARRANTY; without even the implied warranty of */ -/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ -/* GNU Lesser General Public License for more details. */ -/* */ -/* You should have received a copy of the GNU Lesser General Public License */ -/* along with this program; if not, write to the Free Software */ -/* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.*/ -/* */ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -/**@file weights.h - * @brief weight class for graphs - * @author Martin Bergner - */ - -/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/ - -#ifndef WEIGHTS_H_ -#define WEIGHTS_H_ -#include "objscip/objscip.h" - -namespace gcg { - -class Weights -{ -protected: - int varweight; /**< weight of a variable vertex */ - int vbinary; /**< weight of a binary variable vertex */ - int vcontinous; /**< weight of a continuous variable vertex */ - int vinteger; /**< weight of an integer variable vertex */ - int vimplint; /**< weight of an implicit integer variable vertex */ - int consweight; /**< weight of a constraint vertex */ - -public: - Weights( - int varweight_, - int vbinary_, - int vcontinous_, - int vinteger_, - int vimplint_, - int consweight_ - ); - Weights(); - - virtual ~Weights(); - int calculate(SCIP_CONS* cons) const; - int calculate(SCIP_VAR* var) const; -}; - -} /* namespace gcg */ -#endif /* WEIGHTS_H_ */ diff --git a/headers/gcg/heur_gcgcoefdiving.h b/headers/gcg/heur_gcgcoefdiving.h deleted file mode 100644 index 8c50d9d..0000000 --- a/headers/gcg/heur_gcgcoefdiving.h +++ /dev/null @@ -1,57 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* */ -/* This file is part of the program */ -/* GCG --- Generic Column Generation */ -/* a Dantzig-Wolfe decomposition based extension */ -/* of the branch-cut-and-price framework */ -/* SCIP --- Solving Constraint Integer Programs */ -/* */ -/* Copyright (C) 2010-2022 Operations Research, RWTH Aachen University */ -/* Zuse Institute Berlin (ZIB) */ -/* */ -/* This program is free software; you can redistribute it and/or */ -/* modify it under the terms of the GNU Lesser General Public License */ -/* as published by the Free Software Foundation; either version 3 */ -/* of the License, or (at your option) any later version. */ -/* */ -/* This program is distributed in the hope that it will be useful, */ -/* but WITHOUT ANY WARRANTY; without even the implied warranty of */ -/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ -/* GNU Lesser General Public License for more details. */ -/* */ -/* You should have received a copy of the GNU Lesser General Public License */ -/* along with this program; if not, write to the Free Software */ -/* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.*/ -/* */ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -/**@file heur_gcgcoefdiving.h - * @ingroup DIVINGHEURISTICS - * @brief LP diving heuristic that chooses fixings w.r.t. the matrix coefficients - * @author Tobias Achterberg - * @author Christian Puchert - */ - -/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/ - -#ifndef GCG_HEUR_GCGCOEFDIVING_H__ -#define GCG_HEUR_GCGCOEFDIVING_H__ - - -#include "scip/scip.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/** creates the gcgcoefdiving heuristic and includes it in GCG */ -SCIP_EXPORT -SCIP_RETCODE GCGincludeHeurGcgcoefdiving( - SCIP* scip /**< SCIP data structure */ - ); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/headers/gcg/heur_gcgdins.h b/headers/gcg/heur_gcgdins.h deleted file mode 100644 index 7fa975b..0000000 --- a/headers/gcg/heur_gcgdins.h +++ /dev/null @@ -1,60 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* */ -/* This file is part of the program */ -/* GCG --- Generic Column Generation */ -/* a Dantzig-Wolfe decomposition based extension */ -/* of the branch-cut-and-price framework */ -/* SCIP --- Solving Constraint Integer Programs */ -/* */ -/* Copyright (C) 2010-2022 Operations Research, RWTH Aachen University */ -/* Zuse Institute Berlin (ZIB) */ -/* */ -/* This program is free software; you can redistribute it and/or */ -/* modify it under the terms of the GNU Lesser General Public License */ -/* as published by the Free Software Foundation; either version 3 */ -/* of the License, or (at your option) any later version. */ -/* */ -/* This program is distributed in the hope that it will be useful, */ -/* but WITHOUT ANY WARRANTY; without even the implied warranty of */ -/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ -/* GNU Lesser General Public License for more details. */ -/* */ -/* You should have received a copy of the GNU Lesser General Public License */ -/* along with this program; if not, write to the Free Software */ -/* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.*/ -/* */ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -/**@file heur_gcgdins.h - * @ingroup PRIMALHEURISTICS - * @brief DINS primal heuristic - * @author Robert Waniek - * - * DINS combines the ideas of RINS and Local Branching. It - * defines the neighborhood by introducing a distance function between the incumbent solution and the optimum of the LP - * relaxation. When applied during a branch-and-bound search, it further takes into account how variables change their - * values at different nodes of the tree. - */ - -/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/ - -#ifndef __SCIP_HEUR_GCGDINS_H__ -#define __SCIP_HEUR_GCGDINS_H__ - -#include "scip/scip.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/** creates the DINS primal heuristic and includes it in SCIP */ -SCIP_EXPORT -SCIP_RETCODE SCIPincludeHeurGcgdins( - SCIP* scip /**< SCIP data structure */ - ); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/headers/gcg/heur_gcgfeaspump.h b/headers/gcg/heur_gcgfeaspump.h deleted file mode 100644 index d7f52d4..0000000 --- a/headers/gcg/heur_gcgfeaspump.h +++ /dev/null @@ -1,66 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* */ -/* This file is part of the program */ -/* GCG --- Generic Column Generation */ -/* a Dantzig-Wolfe decomposition based extension */ -/* of the branch-cut-and-price framework */ -/* SCIP --- Solving Constraint Integer Programs */ -/* */ -/* Copyright (C) 2010-2022 Operations Research, RWTH Aachen University */ -/* Zuse Institute Berlin (ZIB) */ -/* */ -/* This program is free software; you can redistribute it and/or */ -/* modify it under the terms of the GNU Lesser General Public License */ -/* as published by the Free Software Foundation; either version 3 */ -/* of the License, or (at your option) any later version. */ -/* */ -/* This program is distributed in the hope that it will be useful, */ -/* but WITHOUT ANY WARRANTY; without even the implied warranty of */ -/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ -/* GNU Lesser General Public License for more details. */ -/* */ -/* You should have received a copy of the GNU Lesser General Public License */ -/* along with this program; if not, write to the Free Software */ -/* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.*/ -/* */ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -/**@file heur_gcgfeaspump.h - * @ingroup PRIMALHEURISTICS - * @brief Objective Feasibility Pump 2.0 - * @author Timo Berthold - * @author Domenico Salvagnin - * - * The fundamental idea of the Feasibility Pump is to construct two sequences of points which hopefully converge to a - * feasible solution. One sequence consists of LP-feasiblepoints, the other one of integer feasible points. They are - * produced by alternately rounding an LP-feasible point and solvng an LP that finds a point on the LP polyhedron which - * is closest to the rounded, integral point (w.r.t. Manhattan distance). - * - * The version implemented in SCIP supports using an Objective Feasibility Pump that uses a convex combination of the - * Manhattan distance and the original LP objective for reoptimization. It further features Feasibility Pump 2.0 - * capabilities, hence propagating the fixings for a faster convergence. - */ - -/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/ - -#ifndef __SCIP_HEUR_GCGFEASPUMP_H__ -#define __SCIP_HEUR_GCGFEASPUMP_H__ - - -#include "scip/scip.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/** creates the feaspump primal heuristic and includes it in SCIP */ -SCIP_EXPORT -SCIP_RETCODE SCIPincludeHeurGcgfeaspump( - SCIP* scip /**< SCIP data structure */ - ); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/headers/gcg/heur_gcgfracdiving.h b/headers/gcg/heur_gcgfracdiving.h deleted file mode 100644 index 7b70f80..0000000 --- a/headers/gcg/heur_gcgfracdiving.h +++ /dev/null @@ -1,57 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* */ -/* This file is part of the program */ -/* GCG --- Generic Column Generation */ -/* a Dantzig-Wolfe decomposition based extension */ -/* of the branch-cut-and-price framework */ -/* SCIP --- Solving Constraint Integer Programs */ -/* */ -/* Copyright (C) 2010-2022 Operations Research, RWTH Aachen University */ -/* Zuse Institute Berlin (ZIB) */ -/* */ -/* This program is free software; you can redistribute it and/or */ -/* modify it under the terms of the GNU Lesser General Public License */ -/* as published by the Free Software Foundation; either version 3 */ -/* of the License, or (at your option) any later version. */ -/* */ -/* This program is distributed in the hope that it will be useful, */ -/* but WITHOUT ANY WARRANTY; without even the implied warranty of */ -/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ -/* GNU Lesser General Public License for more details. */ -/* */ -/* You should have received a copy of the GNU Lesser General Public License */ -/* along with this program; if not, write to the Free Software */ -/* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.*/ -/* */ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -/**@file heur_gcgfracdiving.h - * @ingroup DIVINGHEURISTICS - * @brief LP diving heuristic that chooses fixings w.r.t. the fractionalities - * @author Tobias Achterberg - * @author Christian Puchert - */ - -/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/ - -#ifndef GCG_HEUR_GCGFRACDIVING_H__ -#define GCG_HEUR_GCGFRACDIVING_H__ - - -#include "scip/scip.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/** creates the gcgfracdiving heuristic and includes it in GCG */ -SCIP_EXPORT -SCIP_RETCODE GCGincludeHeurGcgfracdiving( - SCIP* scip /**< SCIP data structure */ - ); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/headers/gcg/heur_gcgguideddiving.h b/headers/gcg/heur_gcgguideddiving.h deleted file mode 100644 index 7307b6d..0000000 --- a/headers/gcg/heur_gcgguideddiving.h +++ /dev/null @@ -1,57 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* */ -/* This file is part of the program */ -/* GCG --- Generic Column Generation */ -/* a Dantzig-Wolfe decomposition based extension */ -/* of the branch-cut-and-price framework */ -/* SCIP --- Solving Constraint Integer Programs */ -/* */ -/* Copyright (C) 2010-2022 Operations Research, RWTH Aachen University */ -/* Zuse Institute Berlin (ZIB) */ -/* */ -/* This program is free software; you can redistribute it and/or */ -/* modify it under the terms of the GNU Lesser General Public License */ -/* as published by the Free Software Foundation; either version 3 */ -/* of the License, or (at your option) any later version. */ -/* */ -/* This program is distributed in the hope that it will be useful, */ -/* but WITHOUT ANY WARRANTY; without even the implied warranty of */ -/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ -/* GNU Lesser General Public License for more details. */ -/* */ -/* You should have received a copy of the GNU Lesser General Public License */ -/* along with this program; if not, write to the Free Software */ -/* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.*/ -/* */ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -/**@file heur_gcgguideddiving.h - * @ingroup DIVINGHEURISTICS - * @brief LP diving heuristic that chooses fixings in direction of incumbent solutions - * @author Tobias Achterberg - * @author Christian Puchert - */ - -/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/ - -#ifndef GCG_HEUR_GCGGUIDEDDIVING_H__ -#define GCG_HEUR_GCGGUIDEDDIVING_H__ - - -#include "scip/scip.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/** creates the gcgguideddiving heuristic and includes it in GCG */ -SCIP_EXPORT -SCIP_RETCODE GCGincludeHeurGcgguideddiving( - SCIP* scip /**< SCIP data structure */ - ); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/headers/gcg/heur_gcglinesdiving.h b/headers/gcg/heur_gcglinesdiving.h deleted file mode 100644 index 3e7a4de..0000000 --- a/headers/gcg/heur_gcglinesdiving.h +++ /dev/null @@ -1,57 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* */ -/* This file is part of the program */ -/* GCG --- Generic Column Generation */ -/* a Dantzig-Wolfe decomposition based extension */ -/* of the branch-cut-and-price framework */ -/* SCIP --- Solving Constraint Integer Programs */ -/* */ -/* Copyright (C) 2010-2022 Operations Research, RWTH Aachen University */ -/* Zuse Institute Berlin (ZIB) */ -/* */ -/* This program is free software; you can redistribute it and/or */ -/* modify it under the terms of the GNU Lesser General Public License */ -/* as published by the Free Software Foundation; either version 3 */ -/* of the License, or (at your option) any later version. */ -/* */ -/* This program is distributed in the hope that it will be useful, */ -/* but WITHOUT ANY WARRANTY; without even the implied warranty of */ -/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ -/* GNU Lesser General Public License for more details. */ -/* */ -/* You should have received a copy of the GNU Lesser General Public License */ -/* along with this program; if not, write to the Free Software */ -/* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.*/ -/* */ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -/**@file heur_gcglinesdiving.h - * @ingroup PRIMALHEURISTICS - * @brief LP diving heuristic that fixes variables with a large difference to their root solution - * @author Tobias Achterberg - * @author Christian Puchert - */ - -/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/ - -#ifndef GCG_HEUR_GCGLINESDIVING_H__ -#define GCG_HEUR_GCGLINESDIVING_H__ - - -#include "scip/scip.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/** creates the gcglinesdiving heuristic and includes it in GCG */ -SCIP_EXPORT -SCIP_RETCODE GCGincludeHeurGcglinesdiving( - SCIP* scip /**< SCIP data structure */ - ); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/headers/gcg/heur_gcgpscostdiving.h b/headers/gcg/heur_gcgpscostdiving.h deleted file mode 100644 index 993f3eb..0000000 --- a/headers/gcg/heur_gcgpscostdiving.h +++ /dev/null @@ -1,57 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* */ -/* This file is part of the program */ -/* GCG --- Generic Column Generation */ -/* a Dantzig-Wolfe decomposition based extension */ -/* of the branch-cut-and-price framework */ -/* SCIP --- Solving Constraint Integer Programs */ -/* */ -/* Copyright (C) 2010-2022 Operations Research, RWTH Aachen University */ -/* Zuse Institute Berlin (ZIB) */ -/* */ -/* This program is free software; you can redistribute it and/or */ -/* modify it under the terms of the GNU Lesser General Public License */ -/* as published by the Free Software Foundation; either version 3 */ -/* of the License, or (at your option) any later version. */ -/* */ -/* This program is distributed in the hope that it will be useful, */ -/* but WITHOUT ANY WARRANTY; without even the implied warranty of */ -/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ -/* GNU Lesser General Public License for more details. */ -/* */ -/* You should have received a copy of the GNU Lesser General Public License */ -/* along with this program; if not, write to the Free Software */ -/* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.*/ -/* */ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -/**@file heur_gcgpscostdiving.h - * @ingroup DIVINGHEURISTICS - * @brief LP diving heuristic that chooses fixings w.r.t. the pseudo cost values - * @author Tobias Achterberg - * @author Christian Puchert - */ - -/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/ - -#ifndef GCG_HEUR_GCGPSCOSTDIVING_H__ -#define GCG_HEUR_GCGPSCOSTDIVING_H__ - - -#include "scip/scip.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/** creates the gcgpscostdiving heuristic and includes it in GCG */ -SCIP_EXPORT -SCIP_RETCODE GCGincludeHeurGcgpscostdiving( - SCIP* scip /**< SCIP data structure */ - ); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/headers/gcg/heur_gcgrens.h b/headers/gcg/heur_gcgrens.h deleted file mode 100644 index b12335a..0000000 --- a/headers/gcg/heur_gcgrens.h +++ /dev/null @@ -1,69 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* */ -/* This file is part of the program */ -/* GCG --- Generic Column Generation */ -/* a Dantzig-Wolfe decomposition based extension */ -/* of the branch-cut-and-price framework */ -/* SCIP --- Solving Constraint Integer Programs */ -/* */ -/* Copyright (C) 2010-2022 Operations Research, RWTH Aachen University */ -/* Zuse Institute Berlin (ZIB) */ -/* */ -/* This program is free software; you can redistribute it and/or */ -/* modify it under the terms of the GNU Lesser General Public License */ -/* as published by the Free Software Foundation; either version 3 */ -/* of the License, or (at your option) any later version. */ -/* */ -/* This program is distributed in the hope that it will be useful, */ -/* but WITHOUT ANY WARRANTY; without even the implied warranty of */ -/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ -/* GNU Lesser General Public License for more details. */ -/* */ -/* You should have received a copy of the GNU Lesser General Public License */ -/* along with this program; if not, write to the Free Software */ -/* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.*/ -/* */ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -/**@file heur_gcgrens.h - * @brief LNS heuristic that finds the optimal rounding to a given point - * @author Timo Berthold - * @author Christian Puchert - * @ingroup PRIMALHEURISTICS - */ - -/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/ - -#ifndef GCG_HEUR_GCGRENS_H__ -#define GCG_HEUR_GCGRENS_H__ - -#include "scip/scip.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/** creates RENS primal heuristic and includes it in SCIP */ -extern -SCIP_RETCODE SCIPincludeHeurGcgrens( - SCIP* scip /**< SCIP data structure */ - ); - -/** main procedure of the GCG RENS heuristic, creates and solves a sub-SCIP */ -SCIP_RETCODE GCGapplyGcgrens( - SCIP* scip, /**< original SCIP data structure */ - SCIP_HEUR* heur, /**< heuristic data structure */ - SCIP_RESULT* result, /**< result data structure */ - SCIP_Real minfixingrate, /**< minimum percentage of integer variables that have to be fixed */ - SCIP_Real minimprove, /**< factor by which RENS should at least improve the incumbent */ - SCIP_Longint maxnodes, /**< maximum number of nodes for the subproblem */ - SCIP_Longint nstallnodes, /**< number of stalling nodes for the subproblem */ - SCIP_Bool binarybounds, /**< should general integers get binary bounds [floor(.),ceil(.)]? */ - SCIP_Bool uselprows /**< should subproblem be created out of the rows in the LP rows? */ - ); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/headers/gcg/heur_gcgrins.h b/headers/gcg/heur_gcgrins.h deleted file mode 100644 index dd20ab6..0000000 --- a/headers/gcg/heur_gcgrins.h +++ /dev/null @@ -1,56 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* */ -/* This file is part of the program */ -/* GCG --- Generic Column Generation */ -/* a Dantzig-Wolfe decomposition based extension */ -/* of the branch-cut-and-price framework */ -/* SCIP --- Solving Constraint Integer Programs */ -/* */ -/* Copyright (C) 2010-2022 Operations Research, RWTH Aachen University */ -/* Zuse Institute Berlin (ZIB) */ -/* */ -/* This program is free software; you can redistribute it and/or */ -/* modify it under the terms of the GNU Lesser General Public License */ -/* as published by the Free Software Foundation; either version 3 */ -/* of the License, or (at your option) any later version. */ -/* */ -/* This program is distributed in the hope that it will be useful, */ -/* but WITHOUT ANY WARRANTY; without even the implied warranty of */ -/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ -/* GNU Lesser General Public License for more details. */ -/* */ -/* You should have received a copy of the GNU Lesser General Public License */ -/* along with this program; if not, write to the Free Software */ -/* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.*/ -/* */ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -/**@file heur_gcgrins.h - * @brief LNS heuristic that combines the incumbent with the LP optimum - * @author Timo Berthold - * @author Christian Puchert - * @ingroup PRIMALHEURISTICS - */ - -/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/ - -#ifndef GCG_HEUR_GCGRINS_H__ -#define GCG_HEUR_GCGRINS_H__ - -#include "scip/scip.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/** creates RINS primal heuristic and includes it in SCIP */ -extern -SCIP_RETCODE SCIPincludeHeurGcgrins( - SCIP* scip /**< SCIP data structure */ - ); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/headers/gcg/heur_gcgrounding.h b/headers/gcg/heur_gcgrounding.h deleted file mode 100644 index 87f527e..0000000 --- a/headers/gcg/heur_gcgrounding.h +++ /dev/null @@ -1,57 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* */ -/* This file is part of the program */ -/* GCG --- Generic Column Generation */ -/* a Dantzig-Wolfe decomposition based extension */ -/* of the branch-cut-and-price framework */ -/* SCIP --- Solving Constraint Integer Programs */ -/* */ -/* Copyright (C) 2010-2022 Operations Research, RWTH Aachen University */ -/* Zuse Institute Berlin (ZIB) */ -/* */ -/* This program is free software; you can redistribute it and/or */ -/* modify it under the terms of the GNU Lesser General Public License */ -/* as published by the Free Software Foundation; either version 3 */ -/* of the License, or (at your option) any later version. */ -/* */ -/* This program is distributed in the hope that it will be useful, */ -/* but WITHOUT ANY WARRANTY; without even the implied warranty of */ -/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ -/* GNU Lesser General Public License for more details. */ -/* */ -/* You should have received a copy of the GNU Lesser General Public License */ -/* along with this program; if not, write to the Free Software */ -/* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.*/ -/* */ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -/**@file heur_gcgrounding.h - * @brief LP gcgrounding heuristic that tries to recover from intermediate infeasibilities - * @author Tobias Achterberg - * @author Christian Puchert - * @ingroup PRIMALHEURISTICS - */ - -/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/ - -#ifndef GCG_HEUR_GCGROUNDING_H__ -#define GCG_HEUR_GCGROUNDING_H__ - - -#include "scip/scip.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/** creates the GCG rounding heuristic with infeasibility recovering and includes it in SCIP */ -extern -SCIP_RETCODE SCIPincludeHeurGcgrounding( - SCIP* scip /**< SCIP data structure */ - ); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/headers/gcg/heur_gcgshifting.h b/headers/gcg/heur_gcgshifting.h deleted file mode 100644 index 44bcc88..0000000 --- a/headers/gcg/heur_gcgshifting.h +++ /dev/null @@ -1,57 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* */ -/* This file is part of the program */ -/* GCG --- Generic Column Generation */ -/* a Dantzig-Wolfe decomposition based extension */ -/* of the branch-cut-and-price framework */ -/* SCIP --- Solving Constraint Integer Programs */ -/* */ -/* Copyright (C) 2010-2022 Operations Research, RWTH Aachen University */ -/* Zuse Institute Berlin (ZIB) */ -/* */ -/* This program is free software; you can redistribute it and/or */ -/* modify it under the terms of the GNU Lesser General Public License */ -/* as published by the Free Software Foundation; either version 3 */ -/* of the License, or (at your option) any later version. */ -/* */ -/* This program is distributed in the hope that it will be useful, */ -/* but WITHOUT ANY WARRANTY; without even the implied warranty of */ -/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ -/* GNU Lesser General Public License for more details. */ -/* */ -/* You should have received a copy of the GNU Lesser General Public License */ -/* along with this program; if not, write to the Free Software */ -/* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.*/ -/* */ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -/**@file heur_gcgshifting.h - * @brief LP gcgrounding heuristic that tries to recover from intermediate infeasibilities and shifts continuous variables - * @author Tobias Achterberg - * @author Christian Puchert - * @ingroup PRIMALHEURISTICS - */ - -/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/ - -#ifndef GCG_HEUR_GCGSHIFTING_H__ -#define GCG_HEUR_GCGSHIFTING_H__ - - -#include "scip/scip.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/** creates the GCG shifting heuristic with infeasibility recovering and includes it in SCIP */ -extern -SCIP_RETCODE SCIPincludeHeurGcgshifting( - SCIP* scip /**< SCIP data structure */ - ); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/headers/gcg/heur_gcgsimplerounding.h b/headers/gcg/heur_gcgsimplerounding.h deleted file mode 100644 index edf721a..0000000 --- a/headers/gcg/heur_gcgsimplerounding.h +++ /dev/null @@ -1,57 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* */ -/* This file is part of the program */ -/* GCG --- Generic Column Generation */ -/* a Dantzig-Wolfe decomposition based extension */ -/* of the branch-cut-and-price framework */ -/* SCIP --- Solving Constraint Integer Programs */ -/* */ -/* Copyright (C) 2010-2022 Operations Research, RWTH Aachen University */ -/* Zuse Institute Berlin (ZIB) */ -/* */ -/* This program is free software; you can redistribute it and/or */ -/* modify it under the terms of the GNU Lesser General Public License */ -/* as published by the Free Software Foundation; either version 3 */ -/* of the License, or (at your option) any later version. */ -/* */ -/* This program is distributed in the hope that it will be useful, */ -/* but WITHOUT ANY WARRANTY; without even the implied warranty of */ -/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ -/* GNU Lesser General Public License for more details. */ -/* */ -/* You should have received a copy of the GNU Lesser General Public License */ -/* along with this program; if not, write to the Free Software */ -/* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.*/ -/* */ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -/**@file heur_gcgsimplerounding.h - * @brief simple and fast LP rounding heuristic - * @author Tobias Achterberg - * @author Christian Puchert - * @ingroup PRIMALHEURISTICS - */ - -/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/ - -#ifndef GCG_HEUR_GCGSIMPLEROUNDING_H__ -#define GCG_HEUR_GCGSIMPLEROUNDING_H__ - - -#include "scip/scip.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/** creates the GCG simple rounding heuristic and includes it in SCIP */ -extern -SCIP_RETCODE SCIPincludeHeurGcgsimplerounding( - SCIP* scip /**< SCIP data structure */ - ); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/headers/gcg/heur_gcgveclendiving.h b/headers/gcg/heur_gcgveclendiving.h deleted file mode 100644 index 45d73ef..0000000 --- a/headers/gcg/heur_gcgveclendiving.h +++ /dev/null @@ -1,57 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* */ -/* This file is part of the program */ -/* GCG --- Generic Column Generation */ -/* a Dantzig-Wolfe decomposition based extension */ -/* of the branch-cut-and-price framework */ -/* SCIP --- Solving Constraint Integer Programs */ -/* */ -/* Copyright (C) 2010-2022 Operations Research, RWTH Aachen University */ -/* Zuse Institute Berlin (ZIB) */ -/* */ -/* This program is free software; you can redistribute it and/or */ -/* modify it under the terms of the GNU Lesser General Public License */ -/* as published by the Free Software Foundation; either version 3 */ -/* of the License, or (at your option) any later version. */ -/* */ -/* This program is distributed in the hope that it will be useful, */ -/* but WITHOUT ANY WARRANTY; without even the implied warranty of */ -/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ -/* GNU Lesser General Public License for more details. */ -/* */ -/* You should have received a copy of the GNU Lesser General Public License */ -/* along with this program; if not, write to the Free Software */ -/* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.*/ -/* */ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -/**@file heur_gcgveclendiving.h - * @ingroup DIVINGHEURISTICS - * @brief LP diving heuristic that rounds variables with long column vectors - * @author Tobias Achterberg - * @author Christian Puchert - */ - -/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/ - -#ifndef GCG_HEUR_GCGVECLENDIVING_H__ -#define GCG_HEUR_GCGVECLENDIVING_H__ - - -#include "scip/scip.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/** creates the gcgveclendiving heuristic and includes it in GCG */ -SCIP_EXPORT -SCIP_RETCODE GCGincludeHeurGcgveclendiving( - SCIP* scip /**< SCIP data structure */ - ); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/headers/gcg/heur_gcgzirounding.h b/headers/gcg/heur_gcgzirounding.h deleted file mode 100644 index a6ff401..0000000 --- a/headers/gcg/heur_gcgzirounding.h +++ /dev/null @@ -1,58 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* */ -/* This file is part of the program */ -/* GCG --- Generic Column Generation */ -/* a Dantzig-Wolfe decomposition based extension */ -/* of the branch-cut-and-price framework */ -/* SCIP --- Solving Constraint Integer Programs */ -/* */ -/* Copyright (C) 2010-2022 Operations Research, RWTH Aachen University */ -/* Zuse Institute Berlin (ZIB) */ -/* */ -/* This program is free software; you can redistribute it and/or */ -/* modify it under the terms of the GNU Lesser General Public License */ -/* as published by the Free Software Foundation; either version 3 */ -/* of the License, or (at your option) any later version. */ -/* */ -/* This program is distributed in the hope that it will be useful, */ -/* but WITHOUT ANY WARRANTY; without even the implied warranty of */ -/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ -/* GNU Lesser General Public License for more details. */ -/* */ -/* You should have received a copy of the GNU Lesser General Public License */ -/* along with this program; if not, write to the Free Software */ -/* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.*/ -/* */ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -/**@file heur_gcgzirounding.h - * @brief zirounding primal heuristic - * @author Tobias Achterberg - * @author Gregor Hendel - * @author Christian Puchert - * @ingroup PRIMALHEURISTICS - */ - -/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/ - -#ifndef GCG_HEUR_GCGZIROUNDING_H__ -#define GCG_HEUR_GCGZIROUNDING_H__ - - -#include "scip/scip.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/** creates the GCG zirounding primal heuristic and includes it in SCIP */ -extern -SCIP_RETCODE SCIPincludeHeurGcgzirounding( - SCIP* scip /**< SCIP data structure */ - ); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/headers/gcg/heur_greedycolsel.h b/headers/gcg/heur_greedycolsel.h deleted file mode 100644 index 901bd11..0000000 --- a/headers/gcg/heur_greedycolsel.h +++ /dev/null @@ -1,56 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* */ -/* This file is part of the program */ -/* GCG --- Generic Column Generation */ -/* a Dantzig-Wolfe decomposition based extension */ -/* of the branch-cut-and-price framework */ -/* SCIP --- Solving Constraint Integer Programs */ -/* */ -/* Copyright (C) 2010-2022 Operations Research, RWTH Aachen University */ -/* Zuse Institute Berlin (ZIB) */ -/* */ -/* This program is free software; you can redistribute it and/or */ -/* modify it under the terms of the GNU Lesser General Public License */ -/* as published by the Free Software Foundation; either version 3 */ -/* of the License, or (at your option) any later version. */ -/* */ -/* This program is distributed in the hope that it will be useful, */ -/* but WITHOUT ANY WARRANTY; without even the implied warranty of */ -/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ -/* GNU Lesser General Public License for more details. */ -/* */ -/* You should have received a copy of the GNU Lesser General Public License */ -/* along with this program; if not, write to the Free Software */ -/* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.*/ -/* */ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -/**@file heur_greedycolsel.h - * @brief greedy column selection primal heuristic - * @author Christian Puchert - * @ingroup PRIMALHEURISTICS - */ - -/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/ - -#ifndef GCG_HEUR_GREEDYCOLSEL_H__ -#define GCG_HEUR_GREEDYCOLSEL_H__ - - -#include "scip/scip.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/** creates the greedy column selection primal heuristic and includes it in SCIP */ -extern -SCIP_RETCODE SCIPincludeHeurGreedycolsel( - SCIP* scip /**< SCIP data structure */ - ); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/headers/gcg/heur_mastercoefdiving.h b/headers/gcg/heur_mastercoefdiving.h deleted file mode 100644 index 00bbc00..0000000 --- a/headers/gcg/heur_mastercoefdiving.h +++ /dev/null @@ -1,61 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* */ -/* This file is part of the program */ -/* GCG --- Generic Column Generation */ -/* a Dantzig-Wolfe decomposition based extension */ -/* of the branch-cut-and-price framework */ -/* SCIP --- Solving Constraint Integer Programs */ -/* */ -/* Copyright (C) 2010-2022 Operations Research, RWTH Aachen University */ -/* Zuse Institute Berlin (ZIB) */ -/* */ -/* This program is free software; you can redistribute it and/or */ -/* modify it under the terms of the GNU Lesser General Public License */ -/* as published by the Free Software Foundation; either version 3 */ -/* of the License, or (at your option) any later version. */ -/* */ -/* This program is distributed in the hope that it will be useful, */ -/* but WITHOUT ANY WARRANTY; without even the implied warranty of */ -/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ -/* GNU Lesser General Public License for more details. */ -/* */ -/* You should have received a copy of the GNU Lesser General Public License */ -/* along with this program; if not, write to the Free Software */ -/* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.*/ -/* */ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -/**@file heur_mastercoefdiving.h - * @ingroup DIVINGHEURISTICS - * @brief master LP diving heuristic that chooses fixings w.r.t. the matrix coefficients - * @author Tobias Achterberg - * - * Diving heuristic: Iteratively fixes some fractional variable and resolves the LP-relaxation, thereby simulating a - * depth-first-search in the tree. Coefficient Diving chooses the variable with the fewest locking number in any - * direction and rounds it into this direction. One-level backtracking is applied: If the LP gets infeasible, the last - * fixing is undone, and the opposite fixing is tried. If this is infeasible, too, the procedure aborts. - */ - -/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/ - -#ifndef __SCIP_HEUR_MASTERCOEFDIVING_H__ -#define __SCIP_HEUR_MASTERCOEFDIVING_H__ - - -#include "scip/scip.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/** creates the mastercoefdiving heuristic and includes it in GCG */ -SCIP_EXPORT -SCIP_RETCODE GCGincludeHeurMastercoefdiving( - SCIP* scip /**< SCIP data structure */ - ); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/headers/gcg/heur_masterdiving.h b/headers/gcg/heur_masterdiving.h deleted file mode 100644 index 9f3ca9c..0000000 --- a/headers/gcg/heur_masterdiving.h +++ /dev/null @@ -1,93 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* */ -/* This file is part of the program */ -/* GCG --- Generic Column Generation */ -/* a Dantzig-Wolfe decomposition based extension */ -/* of the branch-cut-and-price framework */ -/* SCIP --- Solving Constraint Integer Programs */ -/* */ -/* Copyright (C) 2010-2022 Operations Research, RWTH Aachen University */ -/* Zuse Institute Berlin (ZIB) */ -/* */ -/* This program is free software; you can redistribute it and/or */ -/* modify it under the terms of the GNU Lesser General Public License */ -/* as published by the Free Software Foundation; either version 3 */ -/* of the License, or (at your option) any later version. */ -/* */ -/* This program is distributed in the hope that it will be useful, */ -/* but WITHOUT ANY WARRANTY; without even the implied warranty of */ -/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ -/* GNU Lesser General Public License for more details. */ -/* */ -/* You should have received a copy of the GNU Lesser General Public License */ -/* along with this program; if not, write to the Free Software */ -/* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.*/ -/* */ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -/**@file heur_masterdiving.h - * @ingroup DIVINGHEURISTICS - * @brief primal heuristic interface for LP diving heuristics on the master variables - * @author Christian Puchert - */ - -/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/ - -#ifndef GCG_HEUR_MASTERDIVING_H__ -#define GCG_HEUR_MASTERDIVING_H__ - - -#include "scip/scip.h" -#include "type_masterdiving.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/** gets diving rule specific data of a diving heuristic */ -SCIP_EXPORT -GCG_DIVINGDATA* GCGheurGetDivingDataMaster( - SCIP_HEUR* heur /**< primal heuristic */ - ); - -/** sets diving rule specific data of a diving heuristic */ -SCIP_EXPORT -void GCGheurSetDivingDataMaster( - SCIP_HEUR* heur, /**< primal heuristic */ - GCG_DIVINGDATA* divingdata /**< diving rule specific data */ - ); - -/** creates a master diving heuristic and includes it in GCG */ -SCIP_EXPORT -SCIP_RETCODE GCGincludeDivingHeurMaster( - SCIP* scip, /**< SCIP data structure */ - SCIP_HEUR** heur, /**< pointer to diving heuristic */ - const char* name, /**< name of primal heuristic */ - const char* desc, /**< description of primal heuristic */ - char dispchar, /**< display character of primal heuristic */ - int priority, /**< priority of the primal heuristic */ - int freq, /**< frequency for calling primal heuristic */ - int freqofs, /**< frequency offset for calling primal heuristic */ - int maxdepth, /**< maximal depth level to call heuristic at (-1: no limit) */ - GCG_DECL_DIVINGFREE ((*divingfree)), /**< destructor of diving heuristic */ - GCG_DECL_DIVINGINIT ((*divinginit)), /**< initialize diving heuristic */ - GCG_DECL_DIVINGEXIT ((*divingexit)), /**< deinitialize diving heuristic */ - GCG_DECL_DIVINGINITSOL ((*divinginitsol)), /**< solving process initialization method of diving heuristic */ - GCG_DECL_DIVINGEXITSOL ((*divingexitsol)), /**< solving process deinitialization method of diving heuristic */ - GCG_DECL_DIVINGINITEXEC ((*divinginitexec)), /**< execution initialization method of diving heuristic */ - GCG_DECL_DIVINGEXITEXEC ((*divingexitexec)), /**< execution deinitialization method of diving heuristic */ - GCG_DECL_DIVINGSELECTVAR ((*divingselectvar)), /**< variable selection method of diving heuristic */ - GCG_DIVINGDATA* divingdata /**< diving rule specific data (or NULL) */ - ); - -/** creates event handler for masterdiving event */ -SCIP_EXPORT -SCIP_RETCODE SCIPincludeEventHdlrMasterdiving( - SCIP* scip /**< SCIP data structure */ - ); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/headers/gcg/heur_masterfracdiving.h b/headers/gcg/heur_masterfracdiving.h deleted file mode 100644 index af01335..0000000 --- a/headers/gcg/heur_masterfracdiving.h +++ /dev/null @@ -1,61 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* */ -/* This file is part of the program */ -/* GCG --- Generic Column Generation */ -/* a Dantzig-Wolfe decomposition based extension */ -/* of the branch-cut-and-price framework */ -/* SCIP --- Solving Constraint Integer Programs */ -/* */ -/* Copyright (C) 2010-2022 Operations Research, RWTH Aachen University */ -/* Zuse Institute Berlin (ZIB) */ -/* */ -/* This program is free software; you can redistribute it and/or */ -/* modify it under the terms of the GNU Lesser General Public License */ -/* as published by the Free Software Foundation; either version 3 */ -/* of the License, or (at your option) any later version. */ -/* */ -/* This program is distributed in the hope that it will be useful, */ -/* but WITHOUT ANY WARRANTY; without even the implied warranty of */ -/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ -/* GNU Lesser General Public License for more details. */ -/* */ -/* You should have received a copy of the GNU Lesser General Public License */ -/* along with this program; if not, write to the Free Software */ -/* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.*/ -/* */ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -/**@file heur_masterfracdiving.h - * @ingroup DIVINGHEURISTICS - * @brief master LP diving heuristic that chooses fixings w.r.t. the fractionalities - * @author Tobias Achterberg - * - * Diving heuristic: Iteratively fixes some fractional variable and resolves the LP-relaxation, thereby simulating a - * depth-first-search in the tree. Fractional Diving chooses the variable with the highest fractionality and rounds it to the - * nearest integer. One-level backtracking is applied: If the LP gets infeasible, the last fixing is undone, and the - * opposite fixing is tried. If this is infeasible, too, the procedure aborts. - */ - -/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/ - -#ifndef __SCIP_HEUR_MASTERFRACDIVING_H__ -#define __SCIP_HEUR_MASTERFRACDIVING_H__ - - -#include "scip/scip.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/** creates the masterfracdiving heuristic and includes it in GCG */ -SCIP_EXPORT -SCIP_RETCODE GCGincludeHeurMasterfracdiving( - SCIP* scip /**< SCIP data structure */ - ); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/headers/gcg/heur_masterlinesdiving.h b/headers/gcg/heur_masterlinesdiving.h deleted file mode 100644 index da497cf..0000000 --- a/headers/gcg/heur_masterlinesdiving.h +++ /dev/null @@ -1,62 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* */ -/* This file is part of the program */ -/* GCG --- Generic Column Generation */ -/* a Dantzig-Wolfe decomposition based extension */ -/* of the branch-cut-and-price framework */ -/* SCIP --- Solving Constraint Integer Programs */ -/* */ -/* Copyright (C) 2010-2022 Operations Research, RWTH Aachen University */ -/* Zuse Institute Berlin (ZIB) */ -/* */ -/* This program is free software; you can redistribute it and/or */ -/* modify it under the terms of the GNU Lesser General Public License */ -/* as published by the Free Software Foundation; either version 3 */ -/* of the License, or (at your option) any later version. */ -/* */ -/* This program is distributed in the hope that it will be useful, */ -/* but WITHOUT ANY WARRANTY; without even the implied warranty of */ -/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ -/* GNU Lesser General Public License for more details. */ -/* */ -/* You should have received a copy of the GNU Lesser General Public License */ -/* along with this program; if not, write to the Free Software */ -/* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.*/ -/* */ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -/**@file heur_masterlinesdiving.h - * @ingroup DIVINGHEURISTICS - * @brief master LP diving heuristic that fixes variables with a large difference to their root solution - * @author Tobias Achterberg - * - * Diving heuristic: Iteratively fixes some fractional variable and resolves the LP-relaxation, thereby simulating a - * depth-first-search in the tree. Line search diving chooses the variable with the greatest difference of its root LP - * solution and the current LP solution, hence, the variable that developed most. It is fixed to the next integer in - * the direction it developed. One-level backtracking is applied: If the LP gets infeasible, the last fixing is undone, - * and the opposite fixing is tried. If this is infeasible, too, the procedure aborts. - */ - -/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/ - -#ifndef __SCIP_HEUR_MASTERLINESDIVING_H__ -#define __SCIP_HEUR_MASTERLINESDIVING_H__ - - -#include "scip/scip.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/** creates the masterlinesdiving primal heuristic and includes it in GCG */ -SCIP_EXPORT -SCIP_RETCODE GCGincludeHeurMasterlinesdiving( - SCIP* scip /**< SCIP data structure */ - ); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/headers/gcg/heur_mastervecldiving.h b/headers/gcg/heur_mastervecldiving.h deleted file mode 100644 index 2ef73f6..0000000 --- a/headers/gcg/heur_mastervecldiving.h +++ /dev/null @@ -1,62 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* */ -/* This file is part of the program */ -/* GCG --- Generic Column Generation */ -/* a Dantzig-Wolfe decomposition based extension */ -/* of the branch-cut-and-price framework */ -/* SCIP --- Solving Constraint Integer Programs */ -/* */ -/* Copyright (C) 2010-2022 Operations Research, RWTH Aachen University */ -/* Zuse Institute Berlin (ZIB) */ -/* */ -/* This program is free software; you can redistribute it and/or */ -/* modify it under the terms of the GNU Lesser General Public License */ -/* as published by the Free Software Foundation; either version 3 */ -/* of the License, or (at your option) any later version. */ -/* */ -/* This program is distributed in the hope that it will be useful, */ -/* but WITHOUT ANY WARRANTY; without even the implied warranty of */ -/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ -/* GNU Lesser General Public License for more details. */ -/* */ -/* You should have received a copy of the GNU Lesser General Public License */ -/* along with this program; if not, write to the Free Software */ -/* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.*/ -/* */ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -/**@file heur_mastervecldiving.h - * @ingroup DIVINGHEURISTICS - * @brief master LP diving heuristic that rounds variables with long column vectors - * @author Tobias Achterberg - * - * Diving heuristic: Iteratively fixes some fractional variable and resolves the LP-relaxation, thereby simulating a - * depth-first-search in the tree. Vectorlength Diving chooses the variable with the smallest ratio of potential - * objective change and number of affected constraints and fixes it. One-level backtracking is applied: If the LP gets - * infeasible, the last fixings is undone, and the opposite fixing is tried. If this is infeasible, too, the procedure - * aborts. - */ - -/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/ - -#ifndef __SCIP_HEUR_MASTERVECLDIVING_H__ -#define __SCIP_HEUR_MASTERVECLDIVING_H__ - - -#include "scip/scip.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/** creates the mastervecldiving heuristic and includes it in GCG */ -SCIP_EXPORT -SCIP_RETCODE GCGincludeHeurMastervecldiving( - SCIP* scip /**< SCIP data structure */ - ); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/headers/gcg/heur_origdiving.h b/headers/gcg/heur_origdiving.h deleted file mode 100644 index 95d5a9f..0000000 --- a/headers/gcg/heur_origdiving.h +++ /dev/null @@ -1,93 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* */ -/* This file is part of the program */ -/* GCG --- Generic Column Generation */ -/* a Dantzig-Wolfe decomposition based extension */ -/* of the branch-cut-and-price framework */ -/* SCIP --- Solving Constraint Integer Programs */ -/* */ -/* Copyright (C) 2010-2022 Operations Research, RWTH Aachen University */ -/* Zuse Institute Berlin (ZIB) */ -/* */ -/* This program is free software; you can redistribute it and/or */ -/* modify it under the terms of the GNU Lesser General Public License */ -/* as published by the Free Software Foundation; either version 3 */ -/* of the License, or (at your option) any later version. */ -/* */ -/* This program is distributed in the hope that it will be useful, */ -/* but WITHOUT ANY WARRANTY; without even the implied warranty of */ -/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ -/* GNU Lesser General Public License for more details. */ -/* */ -/* You should have received a copy of the GNU Lesser General Public License */ -/* along with this program; if not, write to the Free Software */ -/* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.*/ -/* */ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -/**@file heur_origdiving.h - * @ingroup DIVINGHEURISTICS - * @brief primal heuristic interface for LP diving heuristics on the original variables - * @author Christian Puchert - */ - -/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/ - -#ifndef GCG_HEUR_ORIGDIVING_H__ -#define GCG_HEUR_ORIGDIVING_H__ - - -#include "scip/scip.h" -#include "type_origdiving.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/** gets diving rule specific data of a diving heuristic */ -SCIP_EXPORT -GCG_DIVINGDATA* GCGheurGetDivingDataOrig( - SCIP_HEUR* heur /**< primal heuristic */ - ); - -/** sets diving rule specific data of a diving heuristic */ -SCIP_EXPORT -void GCGheurSetDivingDataOrig( - SCIP_HEUR* heur, /**< primal heuristic */ - GCG_DIVINGDATA* divingdata /**< diving rule specific data */ - ); - -/** creates an original diving heuristic and includes it in GCG */ -SCIP_EXPORT -SCIP_RETCODE GCGincludeDivingHeurOrig( - SCIP* scip, /**< SCIP data structure */ - SCIP_HEUR** heur, /**< pointer to diving heuristic */ - const char* name, /**< name of primal heuristic */ - const char* desc, /**< description of primal heuristic */ - char dispchar, /**< display character of primal heuristic */ - int priority, /**< priority of the primal heuristic */ - int freq, /**< frequency for calling primal heuristic */ - int freqofs, /**< frequency offset for calling primal heuristic */ - int maxdepth, /**< maximal depth level to call heuristic at (-1: no limit) */ - GCG_DECL_DIVINGFREE ((*divingfree)), /**< destructor of diving heuristic */ - GCG_DECL_DIVINGINIT ((*divinginit)), /**< initialize diving heuristic */ - GCG_DECL_DIVINGEXIT ((*divingexit)), /**< deinitialize diving heuristic */ - GCG_DECL_DIVINGINITSOL ((*divinginitsol)), /**< solving process initialization method of diving heuristic */ - GCG_DECL_DIVINGEXITSOL ((*divingexitsol)), /**< solving process deinitialization method of diving heuristic */ - GCG_DECL_DIVINGINITEXEC ((*divinginitexec)), /**< execution initialization method of diving heuristic */ - GCG_DECL_DIVINGEXITEXEC ((*divingexitexec)), /**< execution deinitialization method of diving heuristic */ - GCG_DECL_DIVINGSELECTVAR ((*divingselectvar)), /**< variable selection method of diving heuristic */ - GCG_DIVINGDATA* divingdata /**< diving rule specific data (or NULL) */ - ); - -/** creates event handler for origdiving event */ -SCIP_EXPORT -SCIP_RETCODE SCIPincludeEventHdlrOrigdiving( - SCIP* scip /**< SCIP data structure */ - ); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/headers/gcg/heur_relaxcolsel.h b/headers/gcg/heur_relaxcolsel.h deleted file mode 100644 index 96395fb..0000000 --- a/headers/gcg/heur_relaxcolsel.h +++ /dev/null @@ -1,56 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* */ -/* This file is part of the program */ -/* GCG --- Generic Column Generation */ -/* a Dantzig-Wolfe decomposition based extension */ -/* of the branch-cut-and-price framework */ -/* SCIP --- Solving Constraint Integer Programs */ -/* */ -/* Copyright (C) 2010-2022 Operations Research, RWTH Aachen University */ -/* Zuse Institute Berlin (ZIB) */ -/* */ -/* This program is free software; you can redistribute it and/or */ -/* modify it under the terms of the GNU Lesser General Public License */ -/* as published by the Free Software Foundation; either version 3 */ -/* of the License, or (at your option) any later version. */ -/* */ -/* This program is distributed in the hope that it will be useful, */ -/* but WITHOUT ANY WARRANTY; without even the implied warranty of */ -/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ -/* GNU Lesser General Public License for more details. */ -/* */ -/* You should have received a copy of the GNU Lesser General Public License */ -/* along with this program; if not, write to the Free Software */ -/* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.*/ -/* */ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -/**@file heur_relaxcolsel.h - * @brief relaxation based column selection primal heuristic - * @author Christian Puchert - * @ingroup PRIMALHEURISTICS - */ - -/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/ - -#ifndef GCG_HEUR_RELAXCOLSEL_H__ -#define GCG_HEUR_RELAXCOLSEL_H__ - - -#include "scip/scip.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/** creates the relaxation based column selection primal heuristic and includes it in SCIP */ -extern -SCIP_RETCODE SCIPincludeHeurRelaxcolsel( - SCIP* scip /**< SCIP data structure */ - ); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/headers/gcg/heur_restmaster.h b/headers/gcg/heur_restmaster.h deleted file mode 100644 index 004eddb..0000000 --- a/headers/gcg/heur_restmaster.h +++ /dev/null @@ -1,56 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* */ -/* This file is part of the program */ -/* GCG --- Generic Column Generation */ -/* a Dantzig-Wolfe decomposition based extension */ -/* of the branch-cut-and-price framework */ -/* SCIP --- Solving Constraint Integer Programs */ -/* */ -/* Copyright (C) 2010-2022 Operations Research, RWTH Aachen University */ -/* Zuse Institute Berlin (ZIB) */ -/* */ -/* This program is free software; you can redistribute it and/or */ -/* modify it under the terms of the GNU Lesser General Public License */ -/* as published by the Free Software Foundation; either version 3 */ -/* of the License, or (at your option) any later version. */ -/* */ -/* This program is distributed in the hope that it will be useful, */ -/* but WITHOUT ANY WARRANTY; without even the implied warranty of */ -/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ -/* GNU Lesser General Public License for more details. */ -/* */ -/* You should have received a copy of the GNU Lesser General Public License */ -/* along with this program; if not, write to the Free Software */ -/* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.*/ -/* */ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -/**@file heur_restmaster.h - * @brief Restricted Master Heuristic - * @author Christian Puchert - * @ingroup PRIMALHEURISTICS - */ - -/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/ - -#ifndef GCG_HEUR_RESTMASTER_H__ -#define GCG_HEUR_RESTMASTER_H__ - - -#include "scip/scip.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/** creates the Restricted Master primal heuristic and includes it in SCIP */ -extern -SCIP_RETCODE SCIPincludeHeurRestmaster( - SCIP* scip /**< SCIP data structure */ - ); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/headers/gcg/heur_setcover.h b/headers/gcg/heur_setcover.h deleted file mode 100644 index 480ca1c..0000000 --- a/headers/gcg/heur_setcover.h +++ /dev/null @@ -1,57 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* */ -/* This file is part of the program */ -/* GCG --- Generic Column Generation */ -/* a Dantzig-Wolfe decomposition based extension */ -/* of the branch-cut-and-price framework */ -/* SCIP --- Solving Constraint Integer Programs */ -/* */ -/* Copyright (C) 2010-2022 Operations Research, RWTH Aachen University */ -/* Zuse Institute Berlin (ZIB) */ -/* */ -/* This program is free software; you can redistribute it and/or */ -/* modify it under the terms of the GNU Lesser General Public License */ -/* as published by the Free Software Foundation; either version 3 */ -/* of the License, or (at your option) any later version. */ -/* */ -/* This program is distributed in the hope that it will be useful, */ -/* but WITHOUT ANY WARRANTY; without even the implied warranty of */ -/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ -/* GNU Lesser General Public License for more details. */ -/* */ -/* You should have received a copy of the GNU Lesser General Public License */ -/* along with this program; if not, write to the Free Software */ -/* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.*/ -/* */ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -/**@file heur_setcover.h - * @ingroup PRIMALHEURISTICS - * @brief set covering primal heuristic according to Caprara, Fischetti, and Toth (1999) - * @author Tobias Oelschlaegel - * - */ - -/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/ - -#ifndef GCG_HEUR_SETCOVER_H__ -#define GCG_HEUR_SETCOVER_H__ - - -#include "scip/scip.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/** creates the setcover primal heuristic and includes it in SCIP */ -SCIP_EXPORT -SCIP_RETCODE SCIPincludeHeurSetcover( - SCIP* scip /**< SCIP data structure */ - ); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/headers/gcg/heur_xpcrossover.h b/headers/gcg/heur_xpcrossover.h deleted file mode 100644 index ab390e6..0000000 --- a/headers/gcg/heur_xpcrossover.h +++ /dev/null @@ -1,56 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* */ -/* This file is part of the program */ -/* GCG --- Generic Column Generation */ -/* a Dantzig-Wolfe decomposition based extension */ -/* of the branch-cut-and-price framework */ -/* SCIP --- Solving Constraint Integer Programs */ -/* */ -/* Copyright (C) 2010-2022 Operations Research, RWTH Aachen University */ -/* Zuse Institute Berlin (ZIB) */ -/* */ -/* This program is free software; you can redistribute it and/or */ -/* modify it under the terms of the GNU Lesser General Public License */ -/* as published by the Free Software Foundation; either version 3 */ -/* of the License, or (at your option) any later version. */ -/* */ -/* This program is distributed in the hope that it will be useful, */ -/* but WITHOUT ANY WARRANTY; without even the implied warranty of */ -/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ -/* GNU Lesser General Public License for more details. */ -/* */ -/* You should have received a copy of the GNU Lesser General Public License */ -/* along with this program; if not, write to the Free Software */ -/* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.*/ -/* */ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -/**@file heur_xpcrossover.h - * @brief Extreme Point Crossover - * @author Christian Puchert - * @ingroup PRIMALHEURISTICS - */ - -/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/ - -#ifndef GCG_HEUR_XPCROSSOVER_H__ -#define GCG_HEUR_XPCROSSOVER_H__ - - -#include "scip/scip.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/** creates the Extreme Point Crossover primal heuristic and includes it in SCIP */ -extern -SCIP_RETCODE SCIPincludeHeurXpcrossover( - SCIP* scip /**< SCIP data structure */ - ); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/headers/gcg/heur_xprins.h b/headers/gcg/heur_xprins.h deleted file mode 100644 index a07cffa..0000000 --- a/headers/gcg/heur_xprins.h +++ /dev/null @@ -1,56 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* */ -/* This file is part of the program */ -/* GCG --- Generic Column Generation */ -/* a Dantzig-Wolfe decomposition based extension */ -/* of the branch-cut-and-price framework */ -/* SCIP --- Solving Constraint Integer Programs */ -/* */ -/* Copyright (C) 2010-2022 Operations Research, RWTH Aachen University */ -/* Zuse Institute Berlin (ZIB) */ -/* */ -/* This program is free software; you can redistribute it and/or */ -/* modify it under the terms of the GNU Lesser General Public License */ -/* as published by the Free Software Foundation; either version 3 */ -/* of the License, or (at your option) any later version. */ -/* */ -/* This program is distributed in the hope that it will be useful, */ -/* but WITHOUT ANY WARRANTY; without even the implied warranty of */ -/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ -/* GNU Lesser General Public License for more details. */ -/* */ -/* You should have received a copy of the GNU Lesser General Public License */ -/* along with this program; if not, write to the Free Software */ -/* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.*/ -/* */ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -/**@file heur_xprins.h - * @brief Extreme Point RINS - * @author Christian Puchert - * @ingroup PRIMALHEURISTICS - */ - -/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/ - -#ifndef GCG_HEUR_XPRINS_H__ -#define GCG_HEUR_XPRINS_H__ - - -#include "scip/scip.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/** creates the Extreme Point RINS primal heuristic and includes it in SCIP */ -extern -SCIP_RETCODE SCIPincludeHeurXprins( - SCIP* scip /**< SCIP data structure */ - ); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/headers/gcg/masterplugins.h b/headers/gcg/masterplugins.h deleted file mode 100644 index aa33856..0000000 --- a/headers/gcg/masterplugins.h +++ /dev/null @@ -1,53 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* */ -/* This file is part of the program */ -/* GCG --- Generic Column Generation */ -/* a Dantzig-Wolfe decomposition based extension */ -/* of the branch-cut-and-price framework */ -/* SCIP --- Solving Constraint Integer Programs */ -/* */ -/* Copyright (C) 2010-2022 Operations Research, RWTH Aachen University */ -/* Zuse Institute Berlin (ZIB) */ -/* */ -/* This program is free software; you can redistribute it and/or */ -/* modify it under the terms of the GNU Lesser General Public License */ -/* as published by the Free Software Foundation; either version 3 */ -/* of the License, or (at your option) any later version. */ -/* */ -/* This program is distributed in the hope that it will be useful, */ -/* but WITHOUT ANY WARRANTY; without even the implied warranty of */ -/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ -/* GNU Lesser General Public License for more details. */ -/* */ -/* You should have received a copy of the GNU Lesser General Public License */ -/* along with this program; if not, write to the Free Software */ -/* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.*/ -/* */ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -/**@file masterplugins.h - * @brief SCIP plugins for generic column generation - * @author Gerald Gamrath - */ - -/*--+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/ - -#ifndef GCG_MASTERPLUGINS_H__ -#define GCG_MASTERPLUGINS_H__ - -#include "scip/scip.h" - -#ifdef __cplusplus -extern "C" { -#endif - -extern -SCIP_RETCODE GCGincludeMasterPlugins( - SCIP* scip /**< SCIP data structure */ - ); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/headers/gcg/miscvisualization.h b/headers/gcg/miscvisualization.h deleted file mode 100644 index cd17192..0000000 --- a/headers/gcg/miscvisualization.h +++ /dev/null @@ -1,67 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* */ -/* This file is part of the program */ -/* GCG --- Generic Column Generation */ -/* a Dantzig-Wolfe decomposition based extension */ -/* of the branch-cut-and-price framework */ -/* SCIP --- Solving Constraint Integer Programs */ -/* */ -/* Copyright (C) 2010-2022 Operations Research, RWTH Aachen University */ -/* Zuse Institute Berlin (ZIB) */ -/* */ -/* This program is free software; you can redistribute it and/or */ -/* modify it under the terms of the GNU Lesser General Public License */ -/* as published by the Free Software Foundation; either version 3 */ -/* of the License, or (at your option) any later version. */ -/* */ -/* This program is distributed in the hope that it will be useful, */ -/* but WITHOUT ANY WARRANTY; without even the implied warranty of */ -/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ -/* GNU Lesser General Public License for more details. */ -/* */ -/* You should have received a copy of the GNU Lesser General Public License */ -/* along with this program; if not, write to the Free Software */ -/* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.*/ -/* */ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -/**@file miscvisualization.h - * @brief miscellaneous methods for visualizations - * @author Hanna Franzen - * - */ - -/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/ - -#ifndef GCG_MISCVISUALIZATION_H__ -#define GCG_MISCVISUALIZATION_H__ - -#include -#include -#include - -#include "class_detprobdata.h" - -using namespace gcg; - -/** Gives a consistent filename for a (single) partialdec visualization that includes the probname and partialdecID. - * - * @returns standardized filename - * */ -void GCGgetVisualizationFilename( - SCIP* scip, /**< scip data structure */ - PARTIALDECOMP* partialdec, /**< partialdec that is to be visualized */ - const char* extension, /**< future file extension (to be included in the name) */ - char* filename /**< filename output */ - ); - - -/** Gives the path of the provided file. - * - * */ -void GCGgetFilePath( - FILE* file, /**< file */ - char* path /**< buffer containing the path afterward, must be of length PATH_MAX! */ - ); - -#endif /* SRC_MISCVISUALIZATION_H_ */ diff --git a/headers/gcg/nodesel_master.h b/headers/gcg/nodesel_master.h deleted file mode 100644 index 643fa4a..0000000 --- a/headers/gcg/nodesel_master.h +++ /dev/null @@ -1,57 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* */ -/* This file is part of the program */ -/* GCG --- Generic Column Generation */ -/* a Dantzig-Wolfe decomposition based extension */ -/* of the branch-cut-and-price framework */ -/* SCIP --- Solving Constraint Integer Programs */ -/* */ -/* Copyright (C) 2010-2022 Operations Research, RWTH Aachen University */ -/* Zuse Institute Berlin (ZIB) */ -/* */ -/* This program is free software; you can redistribute it and/or */ -/* modify it under the terms of the GNU Lesser General Public License */ -/* as published by the Free Software Foundation; either version 3 */ -/* of the License, or (at your option) any later version. */ -/* */ -/* This program is distributed in the hope that it will be useful, */ -/* but WITHOUT ANY WARRANTY; without even the implied warranty of */ -/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ -/* GNU Lesser General Public License for more details. */ -/* */ -/* You should have received a copy of the GNU Lesser General Public License */ -/* along with this program; if not, write to the Free Software */ -/* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.*/ -/* */ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -/**@file nodesel_master.h - * @brief Node selector for coordination of master and original formulation - * @author Gerald Gamrath - */ - -/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/ - -#ifndef GCG_NODESEL_MASTER_H__ -#define GCG_NODESEL_MASTER_H__ - - -#include "scip/scip.h" - -#ifdef __cplusplus -extern "C" { -#endif - - -/** creates the node selector for depth first search and includes it in SCIP */ -extern -SCIP_RETCODE SCIPincludeNodeselMaster( - SCIP* scip /**< SCIP data structure */ - ); - - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/headers/gcg/objdialog.h b/headers/gcg/objdialog.h deleted file mode 100644 index 7d5b490..0000000 --- a/headers/gcg/objdialog.h +++ /dev/null @@ -1,155 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* */ -/* This file is part of the program */ -/* GCG --- Generic Column Generation */ -/* a Dantzig-Wolfe decomposition based extension */ -/* of the branch-cut-and-price framework */ -/* SCIP --- Solving Constraint Integer Programs */ -/* */ -/* Copyright (C) 2010-2022 Operations Research, RWTH Aachen University */ -/* Zuse Institute Berlin (ZIB) */ -/* */ -/* This program is free software; you can redistribute it and/or */ -/* modify it under the terms of the GNU Lesser General Public License */ -/* as published by the Free Software Foundation; either version 3 */ -/* of the License, or (at your option) any later version. */ -/* */ -/* This program is distributed in the hope that it will be useful, */ -/* but WITHOUT ANY WARRANTY; without even the implied warranty of */ -/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ -/* GNU Lesser General Public License for more details. */ -/* */ -/* You should have received a copy of the GNU Lesser General Public License */ -/* along with this program; if not, write to the Free Software */ -/* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.*/ -/* */ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -/**@file objdialog.h - * @brief C++ wrapper for dialogs - * @author Kati Wolter - * @author Martin Bergner - */ - -/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/ - -#ifndef GCG_OBJDIALOG_H__ -#define GCG_OBJDIALOG_H__ - -#include - -#include "scip/scip.h" -#include "objscip/objcloneable.h" - -namespace gcg -{ - -/** - * @brief C++ wrapper for dialogs - * - * This class defines the interface for dialogs implemented in C++. Note that there is a pure virtual function (this - * function has to be implemented). This function is: scip_exec(). - */ -class ObjDialog : public scip::ObjCloneable -{ -public: - /*lint --e{1540}*/ - - /** SCIP data structure */ - SCIP* scip_; - - /** name of the dialog */ - char* scip_name_; - - /** description of the dialog */ - char* scip_desc_; - - /** default for whether the dialog is a menu */ - const SCIP_Bool scip_issubmenu_; - - /** default constructor */ - ObjDialog( - SCIP* scip, /**< SCIP data structure */ - const char* name, /**< name of the dialog */ - const char* desc, /**< description of the dialog */ - SCIP_Bool issubmenu /**< default for whether the dialog is a menu */ - ) - : scip_(scip), - scip_name_(0), - scip_desc_(0), - scip_issubmenu_(issubmenu) - { - /* the macro SCIPduplicateMemoryArray does not need the first argument: */ - SCIP_CALL_ABORT( SCIPduplicateMemoryArray(scip_, &scip_name_, name, std::strlen(name)+1) ); - SCIP_CALL_ABORT( SCIPduplicateMemoryArray(scip_, &scip_desc_, desc, std::strlen(desc)+1) ); - } - - /** destructor */ - virtual ~ObjDialog() - { - /* the macro SCIPfreeMemoryArray does not need the first argument: */ - /*lint --e{64}*/ - SCIPfreeMemoryArray(scip_, &scip_name_); - SCIPfreeMemoryArray(scip_, &scip_desc_); - scip_ = NULL; - } - - /** destructor of dialog to free user data (called when SCIP is exiting) - * - * @see SCIP_DECL_DIALOGFREE(x) in type_dialog.h - */ - virtual SCIP_DECL_DIALOGFREE(scip_free) - { /*lint --e{715}*/ - return SCIP_OKAY; - } - - /** description output method of dialog - * - * @see SCIP_DECL_DIALOGDESC(x) in type_dialog.h - */ - virtual SCIP_DECL_DIALOGDESC(scip_desc) - { /*lint --e{715}*/ - SCIPdialogMessage(scip, 0, "%s", scip_desc_); - return SCIP_OKAY; - } - - /** execution method of dialog - * - * @see SCIP_DECL_DIALOGEXEC(x) in type_dialog.h - */ - virtual SCIP_DECL_DIALOGEXEC(scip_exec) = 0; -}; - -} /* namespace scip */ - - - -/** creates the dialog for the given dialog object and includes it in SCIP - * - * The method should be called in one of the following ways: - * - * 1. The user is resposible of deleting the object: - * SCIP_CALL( SCIPcreate(&scip) ); - * ... - * MyDialog* mydialog = new MyDialog(...); - * SCIP_CALL( SCIPincludeObjDialog(scip, &mydialog, FALSE) ); - * ... - * SCIP_CALL( SCIPfree(&scip) ); - * delete mydialog; // delete dialog AFTER SCIPfree() ! - * - * 2. The object pointer is passed to SCIP and deleted by SCIP in the SCIPfree() call: - * SCIP_CALL( SCIPcreate(&scip) ); - * ... - * SCIP_CALL( SCIPincludeObjDialog(scip, new MyDialog(...), TRUE) ); - * ... - * SCIP_CALL( SCIPfree(&scip) ); // destructor of MyDialog is called here - */ -extern -SCIP_RETCODE SCIPincludeObjDialog( - SCIP* scip, /**< SCIP data structure */ - SCIP_DIALOG* parentdialog, /**< parent dialog */ - gcg::ObjDialog* objdialog, /**< dialog object */ - SCIP_Bool deleteobject /**< should the dialog object be deleted when dialog is freed? */ - ); - -#endif diff --git a/headers/gcg/objpricer_gcg.h b/headers/gcg/objpricer_gcg.h deleted file mode 100644 index 33dca62..0000000 --- a/headers/gcg/objpricer_gcg.h +++ /dev/null @@ -1,458 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* */ -/* This file is part of the program */ -/* GCG --- Generic Column Generation */ -/* a Dantzig-Wolfe decomposition based extension */ -/* of the branch-cut-and-price framework */ -/* SCIP --- Solving Constraint Integer Programs */ -/* */ -/* Copyright (C) 2010-2022 Operations Research, RWTH Aachen University */ -/* Zuse Institute Berlin (ZIB) */ -/* */ -/* This program is free software; you can redistribute it and/or */ -/* modify it under the terms of the GNU Lesser General Public License */ -/* as published by the Free Software Foundation; either version 3 */ -/* of the License, or (at your option) any later version. */ -/* */ -/* This program is distributed in the hope that it will be useful, */ -/* but WITHOUT ANY WARRANTY; without even the implied warranty of */ -/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ -/* GNU Lesser General Public License for more details. */ -/* */ -/* You should have received a copy of the GNU Lesser General Public License */ -/* along with this program; if not, write to the Free Software */ -/* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.*/ -/* */ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -/**@file objpricer_gcg.h - * @brief GCG variable pricer - * @author Martin Bergner - * @ingroup PRICERS - */ - -/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/ - -#ifndef GCG_OBJPRICER_GCG_H_ -#define GCG_OBJPRICER_GCG_H_ - -#include "objscip/objscip.h" -#include "class_pricingtype.h" -#include "class_pricingcontroller.h" -#include "class_stabilization.h" -#include "pub_gcgcol.h" -#include "pub_colpool.h" -#include "pricestore_gcg.h" - -/**@defgroup GCGPRICEROBJ GCG Variable Pricer Object - * @ingroup PRICING_PUB - * @{ - */ - -using gcg::Pricingcontroller; -using gcg::Stabilization; - -class ObjPricerGcg : public scip::ObjPricer -{ -public: - /*lint --e{1540}*/ - - SCIP* origprob; /**< the original program */ - SCIP_PRICERDATA* pricerdata; /**< pricerdata data structure */ - GCG_COLPOOL* colpool; /**< column pool */ - GCG_PRICESTORE* pricestore; /**< price storage */ - static int threads; - - /** default constructor */ - ObjPricerGcg( - SCIP* scip, /**< SCIP data structure */ - SCIP* origscip, /**< SCIP data structure of original problem */ - const char* name, /**< name of variable pricer */ - const char* desc, /**< description of variable pricer */ - int priority, /**< priority of the variable pricer */ - unsigned int delay, /**< should the pricer be delayed until no other pricers or already existing*/ - SCIP_PRICERDATA *pricerdata /**< pricerdata data structure */ - ); - /** destructor */ - virtual ~ObjPricerGcg() - {} - - /** destructor of variable pricer to free user data (called when SCIP is exiting) */ - virtual SCIP_DECL_PRICERFREE(scip_free); - /** initialization method of variable pricer (called after problem was transformed) */ - virtual SCIP_DECL_PRICERINIT(scip_init); - /** deinitialization method of variable pricer (called before transformed problem is freed) */ - virtual SCIP_DECL_PRICEREXIT(scip_exit); - /** solving process initialization method of variable pricer (called when branch and bound process is about to begin) */ - virtual SCIP_DECL_PRICERINITSOL(scip_initsol); - /** solving process deinitialization method of variable pricer (called before branch and bound process data is freed) */ - virtual SCIP_DECL_PRICEREXITSOL(scip_exitsol); - /** reduced cost pricing method of variable pricer for feasible LPs */ - virtual SCIP_DECL_PRICERREDCOST(scip_redcost); - /** farkas pricing method of variable pricer for infeasible LPs */ - virtual SCIP_DECL_PRICERFARKAS(scip_farkas); - inline SCIP_PRICERDATA *getPricerdata() - { - return pricerdata; - } - - /** for a pricing problem, get the dual solution value or Farkas value of the convexity constraint */ - SCIP_Real getConvconsDualsol( - PricingType* pricetype, /**< Farkas or Reduced cost pricing */ - int probnr /**< index of corresponding pricing problem */ - ); - - /** computes the pricing problem objectives */ - SCIP_RETCODE setPricingObjs( - PricingType* pricetype, /**< Farkas or Reduced cost pricing */ - SCIP_Bool stabilize /**< do we use stabilization ? */ - ); - - /** update reduced cost of columns in column pool */ - void updateRedcostColumnPool( - PricingType* pricetype /**< type of pricing: reduced cost or Farkas */ - ); - /** method to price new columns from Column Pool */ - SCIP_RETCODE priceColumnPoolOld( - PricingType* pricetype, /**< type of pricing: reduced cost or Farkas */ - int* pnfoundvars /**< pointer to store number of priced variables */ - ); - - /** performs the pricing routine, gets the type of pricing that should be done: farkas or redcost pricing */ - SCIP_RETCODE priceNewVariables( - PricingType* pricetype, /**< type of the pricing */ - SCIP_RESULT* result, /**< result pointer */ - double* lowerbound /**< lower bound of pricingproblems */ - ); - - /** creates a new master variable corresponding to the given solution and problem */ - SCIP_RETCODE createNewMasterVar( - SCIP* scip, /**< SCIP data structure */ - PricingType* pricetype, /**< type of the pricing */ - SCIP_SOL* sol, /**< solution to compute reduced cost for */ - SCIP_VAR** solvars, /**< array of variables with non-zero value in the solution of the pricing problem */ - double* solvals, /**< array of values in the solution of the pricing problem for variables in array solvars*/ - int nsolvars, /**< number of variables in array solvars */ - unsigned int solisray, /**< is the solution a ray? */ - int prob, /**< number of the pricing problem the solution belongs to */ - unsigned int force, /**< should the given variable be added also if it has non-negative reduced cost? */ - unsigned int* added, /**< pointer to store whether the variable was successfully added */ - SCIP_VAR** addedvar /**< pointer to store the created variable */ - ); - - /** creates a new master variable corresponding to the given gcg column */ - SCIP_RETCODE createNewMasterVarFromGcgCol( - SCIP* scip, /**< SCIP data structure */ - PricingType* pricetype, /**< type of pricing */ - GCG_COL* gcgcol, /**< GCG column data structure */ - SCIP_Bool force, /**< should the given variable be added also if it has non-negative reduced cost? */ - SCIP_Bool* added, /**< pointer to store whether the variable was successfully added */ - SCIP_VAR** addedvar, /**< pointer to store the created variable */ - SCIP_Real score /**< score of column (or -1.0 if not specified) */ - ); - - /* Compute difference of two dual solutions */ - SCIP_RETCODE computeDualDiff( - SCIP_Real** dualvals1, /**< array of dual values for each pricing problem */ - SCIP_Real* dualconv1, /**< array of dual solutions for the convexity constraints */ - SCIP_Real** dualvals2, /**< array of dual values for each pricing problem */ - SCIP_Real* dualconv2, /**< array of dual solutions for the convexity constraints */ - SCIP_Real* dualdiff /**< pointer to store difference of duals solutions */ - ); - - /** the pricing loop: solve the pricing problems */ - SCIP_RETCODE pricingLoop( - PricingType* pricetype, /**< type of pricing */ - SCIP_RESULT* result, /**< result pointer */ - int* nfoundvars, /**< pointer to store number of found variables */ - SCIP_Real* lowerbound, /**< pointer to store lowerbound obtained due to lagrange bound */ - SCIP_Bool* bestredcostvalid /**< pointer to store if bestredcost are valid (pp solvedoptimal) */ - ); - - const FarkasPricing* getFarkasPricing() const - { - return farkaspricing; - } - - FarkasPricing* getFarkasPricingNonConst() - { - return farkaspricing; - } - - const ReducedCostPricing* getReducedCostPricing() const - { - return reducedcostpricing; - } - - ReducedCostPricing* getReducedCostPricingNonConst() - { - return reducedcostpricing; - } - - SCIP* getOrigprob() - { - return origprob; - } - - /** get the number of columns to be added to the master LP in the current pricing round */ - int getMaxColsRound() const; - - /** get the number of columns per pricing problem to be added to the master LP in the current pricing round */ - int getMaxColsProb() const; - - /** add artificial vars */ - SCIP_RETCODE addArtificialVars(); - - /** add trivial sols */ - SCIP_RETCODE addTrivialsols(); - - /** create the pointers for the pricing types */ - SCIP_RETCODE createPricingTypes(); - - /** create the pricing controller */ - SCIP_RETCODE createPricingcontroller(); - - /** create the pointers for the stabilization */ - void createStabilization(); - - /** create the pointers for the colpool */ - SCIP_RETCODE createColpool(); - - /** create the pointers for the pricestore */ - SCIP_RETCODE createPricestore(); - - /** for given columns, (re-)compute and update their reduced costs */ - void updateRedcosts( - PricingType* pricetype, /**< type of pricing */ - GCG_COL** cols, /**< columns to compute reduced costs for */ - int ncols, /**< number of columns */ - int* nimpcols /**< pointer to store number of improving columns */ - ); - - /** add a new column to the pricing storage */ - SCIP_RETCODE addColToPricestore( - GCG_COL* col /**< priced col */ - ); - - /** for each pricing problem, get the best found column from the pricing storage */ - void getBestCols( - GCG_COL** pricingprobcols /**< array to be filled with best column per pricing problem */ - ); - - /** get the sum over the dual values of convexity constraints */ - SCIP_Real getDualconvsum( - GCG_COL** bestcols /**< best columns found per pricing problem */ - ); - - /* computes the objective value of the current (stabilized) dual variables) in the dual program */ - SCIP_RETCODE getStabilizedDualObjectiveValue( - PricingType* pricetype, /**< type of pricing */ - SCIP_Real* stabdualval, /**< pointer to store stabilized dual objective value */ - SCIP_Bool stabilize /**< stabilize? */ - ); - - SCIP_Real computeRedCostGcgCol( - PricingType* pricetype, /**< type of pricing */ - GCG_Col* gcgcol, /**< gcg column to compute reduced cost for */ - SCIP_Real* objvalptr /**< pointer to store the computed objective value */ - ) const; - - /** compute master coefficients of column */ - SCIP_RETCODE computeColMastercoefs( - GCG_COL* gcgcol /**< GCG column data structure */ - ); - - /** compute master cut coefficients of column */ - SCIP_RETCODE computeColMastercuts( - GCG_COL* gcgcol /**< GCG column data structure */ - ); - -private: - ReducedCostPricing* reducedcostpricing; - FarkasPricing* farkaspricing; - PricingType* pricingtype; /**< current pricing type, or NULL if we are not in pricing */ - Pricingcontroller* pricingcontroller; - Stabilization* stabilization; - - /** free pricing problems */ - SCIP_RETCODE freePricingProblems(); - - SCIP_Real computeRedCost( - PricingType* pricetype, /**< type of pricing */ - SCIP_SOL* sol, /**< solution to compute reduced cost for */ - SCIP_Bool solisray, /**< is the solution a ray? */ - int prob, /**< number of the pricing problem the solution belongs to */ - SCIP_Real* objvalptr /**< pointer to store the computed objective value */ - ) const; - - /** for given columns, (re-)compute and update their reduced costs */ - void updateRedcosts( - PricingType* pricetype, /**< type of pricing */ - GCG_COL** cols, /**< columns to compute reduced costs for */ - int ncols /**< number of columns */ - ) const; - - /** return TRUE or FALSE whether the master LP is solved to optimality */ - SCIP_Bool isMasterLPOptimal() const; - - /** ensures size of pricedvars array */ - SCIP_RETCODE ensureSizePricedvars( - int size /**< needed size */ - ); - - /** adds new variable to the end of the priced variables array */ - SCIP_RETCODE addVariableToPricedvars( - SCIP_VAR* newvar /**< variable to add */ - ); - - /** ensures size of root bounds arrays */ - SCIP_RETCODE ensureSizeRootBounds( - int size /**< needed size */ - ); - - /** adds new bounds to the bound arrays as well as some additional information on dual variables and root lp solution */ - SCIP_RETCODE addRootBounds( - SCIP_Real primalbound, /**< new primal bound for the root master LP */ - SCIP_Real dualbound /**< new dual bound for the root master LP */ - ); - - /** add master variable to all constraints */ - SCIP_RETCODE addVariableToMasterconstraints( - SCIP_VAR* newvar, /**< The new variable to add */ - int prob, /**< number of the pricing problem the solution belongs to */ - SCIP_VAR** solvars, /**< array of variables with non-zero value in the solution of the pricing problem */ - SCIP_Real* solvals, /**< array of values in the solution of the pricing problem for variables in array solvars*/ - int nsolvars /**< number of variables in array solvars */ - ); - - /** add master variable to all constraints */ - SCIP_RETCODE addVariableToMasterconstraintsFromGCGCol( - SCIP_VAR* newvar, /**< The new variable to add */ - GCG_COL* gcgcol /**< GCG column data structure */ - ); - - /** add variable with computed coefficients to the master cuts */ - SCIP_RETCODE addVariableToMastercuts( - SCIP_VAR* newvar, /**< The new variable to add */ - int prob, /**< number of the pricing problem the solution belongs to */ - SCIP_VAR** solvars, /**< array of variables with non-zero value in the solution of the pricing problem */ - SCIP_Real* solvals, /**< array of values in the solution of the pricing problem for variables in array solvars*/ - int nsolvars /**< number of variables in array solvars */ - ); - - /** add variable with computed coefficients to the master cuts */ - SCIP_RETCODE addVariableToMastercutsFromGCGCol( - SCIP_VAR* newvar, /**< The new variable to add */ - GCG_COL* gcgcol /**< GCG column data structure */ - ); - - /** - * check whether pricing can be aborted: - * if objective value is always integral and the current node's current - * lowerbound rounded up equals the current lp objective value rounded - * up we don't need to continue pricing since the best possible feasible - * solution must have at least this value - */ - SCIP_Bool canPricingBeAborted() const; - - /** sorts pricing problems according to their score */ - void sortPricingProblemsByScore() const; - - /** returns the gegeneracy of the masterproblem */ - SCIP_RETCODE computeCurrentDegeneracy( - double* degeneracy /**< pointer to store degeneracy */ - ); - - /** set subproblem memory limit */ - SCIP_RETCODE setPricingProblemMemorylimit( - SCIP* pricingscip /**< SCIP of the pricingproblem */ - ); - -#ifdef SCIP_DISABLED_CODE - /** generic method to generate feasible columns from the pricing problem - * @note This method has to be threadsafe! - */ - SCIP_RETCODE generateColumnsFromPricingProblem( - GCG_PRICINGJOB* pricingjob, /**< pricing job to be performed */ - PricingType* pricetype, /**< type of pricing: reduced cost or Farkas */ - int maxcols /**< size of the cols array to indicate maximum columns */ - ); - - /** solves a specific pricing problem - * @todo simplify - * @note This method has to be threadsafe! - */ - SCIP_RETCODE solvePricingProblem( - GCG_PRICINGJOB* pricingjob, /**< pricing job to be performed */ - PricingType* pricetype, /**< type of pricing: reduced cost or Farkas */ - int maxcols /**< size of the cols array to indicate maximum columns */ - ); -#endif - - /** perform a pricing job, i.e. apply the corresponding solver to the pricing problem - * @note This method has to be threadsafe! - */ - SCIP_RETCODE performPricingjob( - GCG_PRICINGJOB* pricingjob, /**< pricing job */ - PricingType* pricetype, /**< type of pricing: reduced cost or Farkas */ - GCG_PRICINGSTATUS* status, /**< pointer to store pricing status */ - SCIP_Real* lowerbound /**< pointer to store the obtained lower bound */ - ); - - /** frees all solvers */ - SCIP_RETCODE solversFree(); - - /** calls the init method on all solvers */ - SCIP_RETCODE solversInit(); - - /** calls the exit method on all solvers */ - SCIP_RETCODE solversExit(); - - /** calls the initsol method on all solvers */ - SCIP_RETCODE solversInitsol(); - - /** calls the exitsol method of all solvers */ - SCIP_RETCODE solversExitsol(); - - /** computes the stack of masterbranch constraints up to the last generic branching node - * @note This method has to be threadsafe! - */ - SCIP_RETCODE computeGenericBranchingconssStack( - PricingType* pricetype, /**< type of pricing: reduced cost or Farkas */ - int prob, /**< index of pricing problem */ - SCIP_CONS*** consstack, /**< stack of branching constraints */ - int* nconsstack, /**< size of the stack */ - SCIP_Real** consduals /**< dual values of the masterbranch solutions, or NULL */ - ) const; - - /** add bounds change from constraint from the pricing problem at this node - * @note This method has to be threadsafe! - */ - SCIP_RETCODE addBranchingBoundChangesToPricing( - int prob, /**< index of pricing problem */ - SCIP_CONS* branchcons /**< branching constraints from which bound should applied */ - ) const; - - SCIP_RETCODE checkBranchingBoundChanges( - int prob, /**< index of pricing problem */ - SCIP_SOL* sol, /**< solution to check */ - SCIP_CONS* branchcons, /**< branching constraints from which bound should applied */ - SCIP_Bool* feasible /**< check whether the solution is feasible */ - ) const; - - /** check bounds change from constraint from the pricing problem at this node - * @note This method has to be threadsafe! - */ - SCIP_RETCODE checkBranchingBoundChangesGcgCol( - GCG_COL* gcgcol, /**< gcg column to check */ - SCIP_CONS* branchcons, /**< branching constraints from which bound should applied */ - SCIP_Bool* feasible /**< check whether the solution is feasible */ - ) const; - - SCIP_RETCODE ensureSizeArtificialvars( - int size /**< needed size */ - ); - -}; -/** @} */ -#endif diff --git a/headers/gcg/params_visu.h b/headers/gcg/params_visu.h deleted file mode 100644 index eba13eb..0000000 --- a/headers/gcg/params_visu.h +++ /dev/null @@ -1,263 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* */ -/* This file is part of the program */ -/* GCG --- Generic Column Generation */ -/* a Dantzig-Wolfe decomposition based extension */ -/* of the branch-cut-and-price framework */ -/* SCIP --- Solving Constraint Integer Programs */ -/* */ -/* Copyright (C) 2010-2022 Operations Research, RWTH Aachen University */ -/* Zuse Institute Berlin (ZIB) */ -/* */ -/* This program is free software; you can redistribute it and/or */ -/* modify it under the terms of the GNU Lesser General Public License */ -/* as published by the Free Software Foundation; either version 3 */ -/* of the License, or (at your option) any later version. */ -/* */ -/* This program is distributed in the hope that it will be useful, */ -/* but WITHOUT ANY WARRANTY; without even the implied warranty of */ -/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ -/* GNU Lesser General Public License for more details. */ -/* */ -/* You should have received a copy of the GNU Lesser General Public License */ -/* along with this program; if not, write to the Free Software */ -/* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.*/ -/* */ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -/**@file reader_tex.h - * @brief parameter settings for visualization readers - * @author Hanna Franzen - - * This file provides universally used parameters for visualizations. - - */ - -/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/ - -#ifndef GCG_PARAMS_VISU_H__ -#define GCG_PARAMS_VISU_H__ - -#ifdef __cplusplus -extern "C" { -#endif - -#include "type_decomp.h" -#include "type_parameter.h" - -#include "scip/scip.h" - -/** Colorscheme selection for the visualizations */ -enum Colorscheme -{ - COLORSCHEME_DEFAULT = 0, /**< default colors (supposedly eye-friendly) */ - COLORSCHEME_GREY = 1, /**< on a range from black to white */ - COLORSCHEME_MANUAL = 2 /**< take user-defined input */ -}; - -typedef enum Colorscheme VISU_COLORSCHEME; /**< visualization colorscheme type */ - -/** includes the visualization parameters into GCG - * @returns SCIP return code */ -extern SCIP_RETCODE SCIPcreateParamsVisu( - SCIP* scip, /**< SCIP data structure */ - GCG_PARAMDATA** paramdata /**< input empty paramdata, oputput new set of param data */ - ); - -/** gets whether draftmode is on - * draftmode lets visualizations omit nonzeros - * @returns true if draftmode is on */ -extern SCIP_Bool SCIPvisuGetDraftmode( - SCIP* scip /**< SCIP data structure */ - ); - -/** sets draftmode - * draftmode lets visualizations omit nonzeros - * @returns nothing */ -extern void SCIPvisuSetDraftmode( - SCIP* scip, /**< SCIP data structure */ - SCIP_Bool setmode /**< true iff draftmode should be on */ - ); - -/** gets the colorscheme for visualizations - * @returns current colorscheme */ -extern VISU_COLORSCHEME SCIPvisuGetColorscheme( - SCIP* scip /**< SCIP data structure */ - ); - -/** sets colorscheme for visualizations - * @returns nothing */ -extern void SCIPvisuSetColorscheme( - SCIP* scip, /**< SCIP data structure */ - VISU_COLORSCHEME newscheme /**< new colorscheme */ - ); - -/** sets color for mastercons block in current color scheme - * @returns nothing*/ -extern void SCIPvisuSetColorManMasterconss( - SCIP* scip, /**< SCIP data structure */ - const char* newcolor /**< new color */ - ); - -/** sets manual color for mastervar block in current color scheme - * @returns nothing */ -extern void SCIPvisuSetColorManMastervars( - SCIP* scip, /**< SCIP data structure */ - const char* newcolor /**< new color */ - ); - -/** sets manual color for linking blocks in current color scheme - * @returns nothing */ -extern void SCIPvisuSetColorManLinking( - SCIP* scip, /**< SCIP data structure */ - const char* newcolor /**< new color */ - ); - -/** sets manual color for stairlinking blocks in current color scheme - * @returns nothing */ -extern void SCIPvisuSetColorManStairlinking( - SCIP* scip, /**< SCIP data structure */ - const char* newcolor /**< new color */ - ); - -/** sets manual color for normal decomp blocks in current color scheme - * @returns nothing */ -extern void SCIPvisuSetColorManBlock( - SCIP* scip, /**< SCIP data structure */ - const char* newcolor /**< new color */ - ); - -/** sets manual color for open blocks in current color scheme - * @returns nothing */ -extern void SCIPvisuSetColorManOpen( - SCIP* scip, /**< SCIP data structure */ - const char* newcolor /**< new color */ - ); - -/** sets manual color for non-zero points in current color scheme - * @returns nothing */ -extern void SCIPvisuSetColorManNonzero( - SCIP* scip, /**< SCIP data structure */ - const char* newcolor /**< new color */ - ); - -/** sets manual color for lines in current color scheme - * @returns nothing */ -extern void SCIPvisuSetColorManLine( - SCIP* scip, /**< SCIP data structure */ - const char* newcolor /**< new color */ - ); - -/** gets color for mastercons block in current color scheme - * @returns mastercons color */ -extern const char* SCIPvisuGetColorMasterconss( - SCIP* scip /**< SCIP data structure */ - ); - -/** gets color for mastervar block in current color scheme - * @returns mastervar color */ -extern const char* SCIPvisuGetColorMastervars( - SCIP* scip /**< SCIP data structure */ - ); - -/** gets color for linking blocks in current color scheme - * @returns linking color */ -extern const char* SCIPvisuGetColorLinking( - SCIP* scip /**< SCIP data structure */ - ); - -/** gets color for stairlinking blocks in current color scheme - * @returns stairlinking color */ -extern const char* SCIPvisuGetColorStairlinking( - SCIP* scip /**< SCIP data structure */ - ); - -/** gets color for normal decomp blocks in current color scheme - * @returns block color */ -extern const char* SCIPvisuGetColorBlock( - SCIP* scip /**< SCIP data structure */ - ); - -/** gets color for open blocks in current color scheme - * @returns open color */ -extern const char* SCIPvisuGetColorOpen( - SCIP* scip /**< SCIP data structure */ - ); - -/** gets color for non-zero points in current color scheme - * @returns non-zero color */ -extern const char* SCIPvisuGetColorNonzero( - SCIP* scip /**< SCIP data structure */ - ); - -/** gets color for lines in current color scheme - * @returns line color */ -extern const char* SCIPvisuGetColorLine( - SCIP* scip /**< SCIP data structure */ - ); - -/** gets appropriate radius for nonzeros - * needs highest indices of both axes for scaling - * @returns radius */ -extern float SCIPvisuGetNonzeroRadius( - SCIP* scip, /**< SCIP data structure */ - int maxindx, /**< highest index x-axis */ - int maxindy, /**< highest index y-axis */ - float scalingfactor /**< percentage to scale radius, 1 if no scaling */ - ); - - -/** if true gp reader should be used for sub-visualizations, otherwise tex reader - * @returns true if gp reader should be used, false if tex reader should be used */ -extern SCIP_Bool GCGgetUseGp( - SCIP* scip /**< SCIP data structure */ - ); - -/** gets the name of the pdf reader that should be used - * @returns name of pdf reader */ -extern const char* GCGVisuGetPdfReader( - SCIP* scip /**< SCIP data structure */ - ); - -/** gets the max number of decomps to be included in reports - * @returns max number of decomps */ -extern int GCGreportGetMaxNDecomps( - SCIP* scip /**< SCIP data structure */ - ); - -/** gets what type of decomps to show in reports (where 0 corresponds to 'show all') - * @returns type of decomps */ -extern DEC_DECTYPE GCGreportGetDecompTypeToShow( - SCIP* scip /**< SCIP data structure */ - ); - -/** gets whether a titlepage should be included in reports - * @returns true iff title page should be generated */ -extern SCIP_Bool GCGreportGetShowTitlepage( - SCIP* scip /**< SCIP data structure */ - ); - -/** gets whether a table of contents should be included in reports - * @returns true iff table of contents should be generated */ -extern SCIP_Bool GCGreportGetShowToc( - SCIP* scip /**< SCIP data structure */ - ); - -/** gets whether statistics should be included for each decomp in reports - * @returns true iff statistics for each decomp should be generated */ -extern SCIP_Bool GCGreportGetShowStatistics( - SCIP* scip /**< SCIP data structure */ - ); - -/** frees all visualization parameters - * @returns nothing */ -extern void GCGVisuFreeParams( - SCIP* scip, /**< SCIP data structure */ - GCG_PARAMDATA* paramdata /**< input empty paramdata, oputput new set of param data */ - ); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/headers/gcg/presol_roundbound.h b/headers/gcg/presol_roundbound.h deleted file mode 100644 index 05233b6..0000000 --- a/headers/gcg/presol_roundbound.h +++ /dev/null @@ -1,48 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* */ -/* This file is part of the program and library */ -/* SCIP --- Solving Constraint Integer Programs */ -/* */ -/* Copyright (C) 2002-2022 Konrad-Zuse-Zentrum */ -/* fuer Informationstechnik Berlin */ -/* */ -/* SCIP is distributed under the terms of the ZIB Academic License. */ -/* */ -/* You should have received a copy of the ZIB Academic License */ -/* along with SCIP; see the file COPYING. If not email to scip@zib.de. */ -/* */ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -/**@file presol_roundbound.h - * @ingroup PRESOLVERS - * @brief roundbound presolver: round fractional bounds on integer variables - * @author Tobias Achterberg - * @author Michael Bastubbe - * - * This presolver ensures that, all integral variables, for which the - * bounds are fractional, will get rounded new bounds. - */ - -/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/ - -#ifndef __SCIP_PRESOL_ROUNDBOUND_H__ -#define __SCIP_PRESOL_ROUNDBOUND_H__ - - -#include "scip/scip.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/** creates the roundbound presolver and includes it in SCIP */ -SCIP_EXPORT -SCIP_RETCODE SCIPincludePresolRoundbound( - SCIP* scip /**< SCIP data structure */ - ); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/headers/gcg/pricer_gcg.h b/headers/gcg/pricer_gcg.h deleted file mode 100644 index ce5843b..0000000 --- a/headers/gcg/pricer_gcg.h +++ /dev/null @@ -1,298 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* */ -/* This file is part of the program */ -/* GCG --- Generic Column Generation */ -/* a Dantzig-Wolfe decomposition based extension */ -/* of the branch-cut-and-price framework */ -/* SCIP --- Solving Constraint Integer Programs */ -/* */ -/* Copyright (C) 2010-2022 Operations Research, RWTH Aachen University */ -/* Zuse Institute Berlin (ZIB) */ -/* */ -/* This program is free software; you can redistribute it and/or */ -/* modify it under the terms of the GNU Lesser General Public License */ -/* as published by the Free Software Foundation; either version 3 */ -/* of the License, or (at your option) any later version. */ -/* */ -/* This program is distributed in the hope that it will be useful, */ -/* but WITHOUT ANY WARRANTY; without even the implied warranty of */ -/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ -/* GNU Lesser General Public License for more details. */ -/* */ -/* You should have received a copy of the GNU Lesser General Public License */ -/* along with this program; if not, write to the Free Software */ -/* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.*/ -/* */ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -/**@file pricer_gcg.h - * @brief GCG variable pricer - * @author Gerald Gamrath - * @author Martin Bergner - * @ingroup PRICERS - */ - -/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/ - -#ifndef GCG_PRICER_GCG__ -#define GCG_PRICER_GCG__ - -#include "scip/scip.h" -#include "type_solver.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/**@defgroup GCGPRICER GCG Variable Pricer - * @ingroup PRICING_PUB - * @{ - */ - -enum GCG_Pricetype -{ - GCG_PRICETYPE_UNKNOWN = -1, /**< unknown pricing type */ - GCG_PRICETYPE_INIT = 0, /**< initial pricing */ - GCG_PRICETYPE_FARKAS = 1, /**< farkas pricing */ - GCG_PRICETYPE_REDCOST = 2 /**< redcost pricing */ -}; -typedef enum GCG_Pricetype GCG_PRICETYPE; - - - -/** creates the GCG variable pricer and includes it in SCIP */ -extern -SCIP_RETCODE SCIPincludePricerGcg( - SCIP* scip, /**< SCIP data structure */ - SCIP* origprob /**< SCIP data structure of the original problem */ - ); - -/** returns the pointer to the scip instance representing the original problem */ -extern -SCIP* GCGmasterGetOrigprob( - SCIP* scip /**< SCIP data structure */ - ); - -/** returns the array of variables that were priced in during the solving process */ -extern -SCIP_VAR** GCGmasterGetPricedvars( - SCIP* scip /**< SCIP data structure */ - ); - -/** returns the number of variables that were priced in during the solving process */ -extern -int GCGmasterGetNPricedvars( - SCIP* scip /**< SCIP data structure */ - ); - -/** adds the given constraint and the given position to the hashmap of the pricer */ -extern -SCIP_RETCODE GCGmasterAddMasterconsToHashmap( - SCIP* scip, /**< SCIP data structure */ - SCIP_CONS* cons, /**< the constraint that should be added */ - int pos /**< the position of the constraint in the relaxator's masterconss array */ - ); - -/** sets the optimal LP solution in the pricerdata */ -extern -SCIP_RETCODE GCGmasterSetRootLPSol( - SCIP* scip, /**< SCIP data structure */ - SCIP_SOL** sol /**< pointer to optimal solution to root LP */ - ); - -#ifdef SCIP_STATISTIC -/** gets the optimal LP solution in the pricerdata */ -extern -SCIP_SOL* GCGmasterGetRootLPSol( - SCIP* scip /**< SCIP data structure */ - ); -#endif - -/** includes a solver into the pricer data */ -extern -SCIP_RETCODE GCGpricerIncludeSolver( - SCIP* scip, /**< SCIP data structure */ - const char* name, /**< name of solver */ - const char* desc, /**< description of solver */ - int priority, /**< priority of solver */ - SCIP_Bool heurenabled, /**< flag to indicate whether heuristic solving method of the solver is enabled */ - SCIP_Bool exactenabled, /**< flag to indicate whether exact solving method of the solver is enabled */ - GCG_DECL_SOLVERUPDATE((*solverupdate)), /**< update method for solver */ - GCG_DECL_SOLVERSOLVE ((*solversolve)), /**< solving method for solver */ - GCG_DECL_SOLVERSOLVEHEUR((*solveheur)), /**< heuristic solving method for solver */ - GCG_DECL_SOLVERFREE ((*solverfree)), /**< free method of solver */ - GCG_DECL_SOLVERINIT ((*solverinit)), /**< init method of solver */ - GCG_DECL_SOLVEREXIT ((*solverexit)), /**< exit method of solver */ - GCG_DECL_SOLVERINITSOL((*solverinitsol)), /**< initsol method of solver */ - GCG_DECL_SOLVEREXITSOL((*solverexitsol)), /**< exitsol method of solver */ - GCG_SOLVERDATA* solverdata /**< pricing solver data */ - ); - - -/** returns the available pricing solvers */ -extern -GCG_SOLVER** GCGpricerGetSolvers( - SCIP* scip /**< SCIP data structure */ - ); - -/** returns the number of available pricing solvers */ -extern -int GCGpricerGetNSolvers( - SCIP* scip /**< SCIP data structure */ - ); - -/** writes out a list of all pricing problem solvers */ -extern -void GCGpricerPrintListOfSolvers( - SCIP* scip /**< SCIP data structure */ - ); - -/** prints pricing solver statistics */ -extern -void GCGpricerPrintPricingStatistics( - SCIP* scip, /**< SCIP data structure */ - FILE* file /**< output file */ - ); - -extern -void GCGpricerPrintStatistics( - SCIP* scip, /**< SCIP data structure */ - FILE* file /**< output file */ - ); - -/** method to get existence of rays */ -extern -SCIP_RETCODE GCGpricerExistRays( - SCIP* scip, /**< master SCIP data structure */ - SCIP_Bool* exist /**< pointer to store if there exists any ray */ - ); - -/** get the number of extreme points that a pricing problem has generated so far */ -extern -int GCGpricerGetNPointsProb( - SCIP* scip, /**< master SCIP data structure */ - int probnr /**< index of pricing problem */ - ); - -/** get the number of extreme rays that a pricing problem has generated so far */ -extern -int GCGpricerGetNRaysProb( - SCIP* scip, /**< master SCIP data structure */ - int probnr /**< index of pricing problem */ - ); - -/** get the number of columns to be added to the master LP in the current pricing round */ -extern -int GCGpricerGetMaxColsRound( - SCIP* scip /**< master SCIP data structure */ - ); - -/** get the number of columns per pricing problem to be added to the master LP in the current pricing round */ -extern -int GCGpricerGetMaxColsProb( - SCIP* scip /**< master SCIP data structure */ - ); - -/** add a new column to the pricing storage */ -extern -SCIP_RETCODE GCGpricerAddCol( - SCIP* scip, /**< SCIP data structure */ - GCG_COL* col /**< priced col */ - ); - -/** transfers a primal solution of the original problem into the master variable space, - * i.e. creates one master variable for each block and adds the solution to the master problem */ -extern -SCIP_RETCODE GCGmasterTransOrigSolToMasterVars( - SCIP* scip, /**< SCIP data structure */ - SCIP_SOL* origsol, /**< the solution that should be transferred */ - SCIP_Bool* stored /**< pointer to store if transferred solution is feasible (or NULL) */ - ); - -/** create initial master variables */ -extern -SCIP_RETCODE GCGmasterCreateInitialMastervars( - SCIP* scip /**< master SCIP data structure */ - ); - -/** get root node degeneracy */ -extern -SCIP_Real GCGmasterGetDegeneracy( - SCIP* scip /**< SCIP data structure */ - ); - -/** return if artifical variables are used in current solution */ -extern -SCIP_Bool GCGmasterIsCurrentSolValid( - SCIP* scip /**< SCIP data structure */ - ); - -extern -SCIP_Bool GCGmasterIsBestsolValid( - SCIP* scip /**< SCIP data structure */ - ); - -extern -SCIP_Bool GCGmasterIsSolValid( - SCIP* scip, /**< SCIP data structure */ - SCIP_SOL* mastersol /**< solution of the master problem, or NULL for current LP solution */ - ); - - -/** get number of iterations in pricing problems */ -extern -SCIP_Longint GCGmasterGetPricingSimplexIters( - SCIP* scip /**< SCIP data structure */ - ); - -/** print simplex iteration statistics */ -extern -SCIP_RETCODE GCGmasterPrintSimplexIters( - SCIP* scip, /**< SCIP data structure */ - FILE* file /**< output file */ - ); - -/** set pricing objectives */ -extern -SCIP_RETCODE GCGsetPricingObjs( - SCIP* scip, /**< SCIP data structure */ - SCIP_Real* dualsolconv /**< array of dual solutions corresponding to convexity constraints */ - ); - -/** creates a new master variable corresponding to the given gcg column */ -extern -SCIP_RETCODE GCGcreateNewMasterVarFromGcgCol( - SCIP* scip, /**< SCIP data structure */ - SCIP_Bool infarkas, /**< in Farkas pricing? */ - GCG_COL* gcgcol, /**< GCG column data structure */ - SCIP_Bool force, /**< should the given variable be added also if it has non-negative reduced cost? */ - SCIP_Bool* added, /**< pointer to store whether the variable was successfully added */ - SCIP_VAR** addedvar, /**< pointer to store the created variable */ - SCIP_Real score /**< score of column (or -1.0 if not specified) */ - - ); - -/** computes the reduced cost of a column */ -extern -SCIP_Real GCGcomputeRedCostGcgCol( - SCIP* scip, /**< SCIP data structure */ - SCIP_Bool infarkas, /**< in Farkas pricing? */ - GCG_COL* gcgcol, /**< gcg column to compute reduced cost for */ - SCIP_Real* objvalptr /**< pointer to store the computed objective value */ - ); - - -/** compute master and cut coefficients of column */ -extern -SCIP_RETCODE GCGcomputeColMastercoefs( - SCIP* scip, /**< SCIP data structure */ - GCG_COL* gcgcol /**< GCG column data structure */ - ); - -/**@} */ -#ifdef __cplusplus -} - -#endif - -#endif diff --git a/headers/gcg/pricestore_gcg.h b/headers/gcg/pricestore_gcg.h deleted file mode 100644 index d0f7c77..0000000 --- a/headers/gcg/pricestore_gcg.h +++ /dev/null @@ -1,182 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* */ -/* This file is part of the program */ -/* GCG --- Generic Column Generation */ -/* a Dantzig-Wolfe decomposition based extension */ -/* of the branch-cut-and-price framework */ -/* SCIP --- Solving Constraint Integer Programs */ -/* */ -/* Copyright (C) 2010-2022 Operations Research, RWTH Aachen University */ -/* Zuse Institute Berlin (ZIB) */ -/* */ -/* This program is free software; you can redistribute it and/or */ -/* modify it under the terms of the GNU Lesser General Public License */ -/* as published by the Free Software Foundation; either version 3 */ -/* of the License, or (at your option) any later version. */ -/* */ -/* This program is distributed in the hope that it will be useful, */ -/* but WITHOUT ANY WARRANTY; without even the implied warranty of */ -/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ -/* GNU Lesser General Public License for more details. */ -/* */ -/* You should have received a copy of the GNU Lesser General Public License */ -/* along with this program; if not, write to the Free Software */ -/* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.*/ -/* */ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -/**@file pricestore_gcg.h - * @brief methods for storing priced cols (based on SCIP's separation storage) - * @author Jonas Witt - */ - -/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/ - -#ifndef __GCG_PRICESTORE_H__ -#define __GCG_PRICESTORE_H__ - - -#include "scip/def.h" -#include "blockmemshell/memory.h" -#include "scip/type_implics.h" -#include "scip/type_retcode.h" -#include "scip/type_set.h" -#include "scip/type_stat.h" -#include "scip/type_event.h" -#include "scip/type_lp.h" -#include "scip/type_prob.h" -#include "scip/type_tree.h" -#include "scip/type_reopt.h" -#include "scip/type_branch.h" - -#include "pub_colpool.h" -#include "pub_gcgcol.h" -#include "type_pricestore_gcg.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/** creates price storage */ -extern -SCIP_RETCODE GCGpricestoreCreate( - SCIP* scip, /**< SCIP data structure */ - GCG_PRICESTORE** pricestore, /**< pointer to store price storage */ - SCIP_Real redcostfac, /**< factor of -redcost/norm in score function */ - SCIP_Real objparalfac, /**< factor of objective parallelism in score function */ - SCIP_Real orthofac, /**< factor of orthogonalities in score function */ - SCIP_Real mincolorth, /**< minimal orthogonality of columns to add - (with respect to columns added in the current round) */ - GCG_EFFICIACYCHOICE efficiacychoice /**< choice to base efficiacy on */ - ); - -/** frees price storage */ -extern -SCIP_RETCODE GCGpricestoreFree( - SCIP* scip, /**< SCIP data structure */ - GCG_PRICESTORE** pricestore /**< pointer to store price storage */ - ); - -/** informs price storage, that Farkas pricing starts now */ -extern -void GCGpricestoreStartFarkas( - GCG_PRICESTORE* pricestore /**< price storage */ - ); - -/** informs price storage, that Farkas pricing is now finished */ -extern -void GCGpricestoreEndFarkas( - GCG_PRICESTORE* pricestore /**< price storage */ - ); - -/** informs price storage, that the following cols should be used in any case */ -extern -void GCGpricestoreStartForceCols( - GCG_PRICESTORE* pricestore /**< price storage */ - ); - -/** informs price storage, that the following cols should no longer be used in any case */ -extern -void GCGpricestoreEndForceCols( - GCG_PRICESTORE* pricestore /**< price storage */ - ); - -/** adds col to price storage; - * if the col should be forced to enter the LP, an infinite score has to be used - */ -extern -SCIP_RETCODE GCGpricestoreAddCol( - SCIP* scip, /**< SCIP data structure */ - GCG_PRICESTORE* pricestore, /**< price storage */ - GCG_COL* col, /**< priced col */ - SCIP_Bool forcecol /**< should the col be forced to enter the LP? */ - ); - -/** adds cols to priced vars and clears price storage */ -extern -SCIP_RETCODE GCGpricestoreApplyCols( - GCG_PRICESTORE* pricestore, /**< price storage */ - GCG_COLPOOL* colpool, /**< GCG column pool */ - SCIP_Bool usecolpool, /**< use column pool? */ - int* nfoundvars /**< pointer to store number of variables that were added to the problem */ - ); - -/** clears the price storage without adding the cols to priced vars */ -extern -void GCGpricestoreClearCols( - GCG_PRICESTORE* pricestore /**< price storage */ - ); - -/** removes cols that are inefficacious w.r.t. the current LP solution from price storage without adding the cols to the LP */ -extern -void GCGpricestoreRemoveInefficaciousCols( - GCG_PRICESTORE* pricestore /**< price storage */ - ); - -/** get cols in the price storage */ -extern -GCG_COL** GCGpricestoreGetCols( - GCG_PRICESTORE* pricestore /**< price storage */ - ); - -/** get number of cols in the price storage */ -extern -int GCGpricestoreGetNCols( - GCG_PRICESTORE* pricestore /**< price storage */ - ); - -/** get number of efficacious cols in the price storage */ -extern -int GCGpricestoreGetNEfficaciousCols( - GCG_PRICESTORE* pricestore /**< price storage */ - ); - -/** get total number of cols found so far */ -extern -int GCGpricestoreGetNColsFound( - GCG_PRICESTORE* pricestore /**< price storage */ - ); - -/** get number of cols found so far in current price round */ -extern -int GCGpricestoreGetNColsFoundRound( - GCG_PRICESTORE* pricestore /**< price storage */ - ); - -/** get total number of cols applied to the LPs */ -extern -int GCGpricestoreGetNColsApplied( - GCG_PRICESTORE* pricestore /**< price storage */ - ); - -/** gets time in seconds used for pricing cols from the pricestore */ -extern -SCIP_Real GCGpricestoreGetTime( - GCG_PRICESTORE* pricestore /**< price storage */ - ); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/headers/gcg/pricingjob.h b/headers/gcg/pricingjob.h deleted file mode 100644 index fb4aa9b..0000000 --- a/headers/gcg/pricingjob.h +++ /dev/null @@ -1,112 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* */ -/* This file is part of the program */ -/* GCG --- Generic Column Generation */ -/* a Dantzig-Wolfe decomposition based extension */ -/* of the branch-cut-and-price framework */ -/* SCIP --- Solving Constraint Integer Programs */ -/* */ -/* Copyright (C) 2010-2022 Operations Research, RWTH Aachen University */ -/* Zuse Institute Berlin (ZIB) */ -/* */ -/* This program is free software; you can redistribute it and/or */ -/* modify it under the terms of the GNU Lesser General Public License */ -/* as published by the Free Software Foundation; either version 3 */ -/* of the License, or (at your option) any later version. */ -/* */ -/* This program is distributed in the hope that it will be useful, */ -/* but WITHOUT ANY WARRANTY; without even the implied warranty of */ -/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ -/* GNU Lesser General Public License for more details. */ -/* */ -/* You should have received a copy of the GNU Lesser General Public License */ -/* along with this program; if not, write to the Free Software */ -/* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.*/ -/* */ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -/**@file pricingjob.h - * @brief private methods for working with pricing jobs, to be used by the pricing controller only - * @author Christian Puchert - */ - -/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/ -#ifndef GCG_PRICINGJOB_H__ -#define GCG_PRICINGJOB_H__ - -#include "struct_pricingjob.h" -#include "type_pricingjob.h" - -#include "type_pricingprob.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/** create a pricing job */ -SCIP_EXPORT -SCIP_RETCODE GCGpricingjobCreate( - SCIP* scip, /**< SCIP data structure (master problem) */ - GCG_PRICINGJOB** pricingjob, /**< pricing job to be created */ - GCG_PRICINGPROB* pricingprob, /**< data structure of the corresponding pricing problem */ - GCG_SOLVER* solver, /**< pricing solver responsible for the pricing job */ - int chunk /**< chunk that the pricing problem should belong to */ -); - -/** free a pricing job */ -SCIP_EXPORT -void GCGpricingjobFree( - SCIP* scip, /**< SCIP data structure (master problem) */ - GCG_PRICINGJOB** pricingjob /**< pricing job to be freed */ -); - -/** setup a pricing job at the beginning of the pricing loop */ -SCIP_EXPORT -SCIP_RETCODE GCGpricingjobSetup( - SCIP* scip, /**< SCIP data structure (master problem) */ - GCG_PRICINGJOB* pricingjob, /**< pricing job */ - SCIP_Bool heuristic, /**< shall the pricing job be performed heuristically? */ - int scoring, /**< scoring parameter */ - int nroundscol, /**< number of previous pricing rounds for which the number of improving columns should be counted */ - SCIP_Real dualsolconv, /**< dual solution value of corresponding convexity constraint */ - int npointsprob, /**< total number of extreme points generated so far by the pricing problem */ - int nraysprob /**< total number of extreme rays generated so far by the pricing problem */ - ); - -/** reset the pricing solver to be used to the one with the highest priority */ -SCIP_EXPORT -void GCGpricingjobResetSolver( - SCIP* scip, /**< SCIP data structure (master problem) */ - GCG_PRICINGJOB* pricingjob /**< pricing job */ - ); - -/** get the next pricing solver to be used, or NULL of there is none */ -SCIP_EXPORT -void GCGpricingjobNextSolver( - SCIP* scip, /**< SCIP data structure (master problem) */ - GCG_PRICINGJOB* pricingjob /**< pricing job */ - ); - -/** set the pricing job to be performed exactly */ -SCIP_EXPORT -void GCGpricingjobSetExact( - GCG_PRICINGJOB* pricingjob /**< pricing job */ - ); - -/** reset number of heuristic pricing iterations of a pricing job */ -SCIP_EXPORT -void GCGpricingjobResetHeuristic( - GCG_PRICINGJOB* pricingjob /**< pricing job */ - ); - -/** update number of heuristic pricing iterations of a pricing job */ -SCIP_EXPORT -void GCGpricingjobIncreaseNHeurIters( - GCG_PRICINGJOB* pricingjob /**< pricing job */ - ); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/headers/gcg/pricingprob.h b/headers/gcg/pricingprob.h deleted file mode 100644 index a8507b8..0000000 --- a/headers/gcg/pricingprob.h +++ /dev/null @@ -1,123 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* */ -/* This file is part of the program */ -/* GCG --- Generic Column Generation */ -/* a Dantzig-Wolfe decomposition based extension */ -/* of the branch-cut-and-price framework */ -/* SCIP --- Solving Constraint Integer Programs */ -/* */ -/* Copyright (C) 2010-2022 Operations Research, RWTH Aachen University */ -/* Zuse Institute Berlin (ZIB) */ -/* */ -/* This program is free software; you can redistribute it and/or */ -/* modify it under the terms of the GNU Lesser General Public License */ -/* as published by the Free Software Foundation; either version 3 */ -/* of the License, or (at your option) any later version. */ -/* */ -/* This program is distributed in the hope that it will be useful, */ -/* but WITHOUT ANY WARRANTY; without even the implied warranty of */ -/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ -/* GNU Lesser General Public License for more details. */ -/* */ -/* You should have received a copy of the GNU Lesser General Public License */ -/* along with this program; if not, write to the Free Software */ -/* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.*/ -/* */ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -/**@file pricingprob.h - * @brief private methods for working with pricing problems, to be used by the pricing controller only - * @author Christian Puchert - */ - -/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/ -#ifndef GCG_PRICINGPROB_H__ -#define GCG_PRICINGPROB_H__ - -#include "struct_pricingprob.h" -#include "type_pricingprob.h" - -#include "pricer_gcg.h" -#include "type_colpool.h" -#include "type_pricestore_gcg.h" -#include "type_pricingjob.h" -#include "type_solver.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/** create a pricing problem */ -SCIP_EXPORT -SCIP_RETCODE GCGpricingprobCreate( - SCIP* scip, /**< SCIP data structure (master problem) */ - GCG_PRICINGPROB** pricingprob, /**< pricing problem to be created */ - SCIP* pricingscip, /**< SCIP data structure of the corresponding pricing problem */ - int probnr, /**< index of the corresponding pricing problem */ - int nroundscol /**< number of previous pricing rounds for which the number of improving columns should be counted */ -); - -/** free a pricing problem */ -SCIP_EXPORT -void GCGpricingprobFree( - SCIP* scip, /**< SCIP data structure (master problem) */ - GCG_PRICINGPROB** pricingprob /**< pricing problem to be freed */ -); - -/** initialize pricing problem at the beginning of the pricing round */ -SCIP_EXPORT -void GCGpricingprobInitPricing( - GCG_PRICINGPROB* pricingprob /**< pricing problem structure */ - ); - -/** uninitialize pricing problem at the beginning of the pricing round */ -SCIP_EXPORT -void GCGpricingprobExitPricing( - GCG_PRICINGPROB* pricingprob, /**< pricing problem structure */ - int nroundscol /**< number of previous pricing rounds for which the number of improving columns should be counted */ - ); - -/** add generic branching data (constraint and dual value) to the current pricing problem */ -SCIP_EXPORT -SCIP_RETCODE GCGpricingprobAddGenericBranchData( - SCIP* scip, /**< SCIP data structure (master problem) */ - GCG_PRICINGPROB* pricingprob, /**< pricing problem structure */ - SCIP_CONS* branchcons, /**< generic branching constraint */ - SCIP_Real branchdual /**< corresponding dual solution value */ - ); - -/** reset the pricing problem statistics for the current pricing round */ -SCIP_EXPORT -void GCGpricingprobReset( - SCIP* scip, /**< SCIP data structure (master problem) */ - GCG_PRICINGPROB* pricingprob /**< pricing problem structure */ - ); - -/** update solution information of a pricing problem */ -SCIP_EXPORT -void GCGpricingprobUpdate( - SCIP* scip, /**< SCIP data structure (master problem) */ - GCG_PRICINGPROB* pricingprob, /**< pricing problem structure */ - GCG_PRICINGSTATUS status, /**< status of last pricing job */ - SCIP_Real lowerbound, /**< new lower bound */ - int nimpcols /**< number of new improving columns */ - ); - -/** add the information that the next branching constraint must be added */ -SCIP_EXPORT -void GCGpricingprobNextBranchcons( - GCG_PRICINGPROB* pricingprob /**< pricing problem structure */ - ); - -/** set the lower bound of a pricing job */ -SCIP_EXPORT -void GCGpricingjobSetLowerbound( - GCG_PRICINGJOB* pricingjob, /**< pricing job */ - SCIP_Real lowerbound /**< new lower bound */ - ); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/headers/gcg/pub_bliss.h b/headers/gcg/pub_bliss.h deleted file mode 100644 index 1b33c10..0000000 --- a/headers/gcg/pub_bliss.h +++ /dev/null @@ -1,168 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* */ -/* This file is part of the program */ -/* GCG --- Generic Column Generation */ -/* a Dantzig-Wolfe decomposition based extension */ -/* of the branch-cut-and-price framework */ -/* SCIP --- Solving Constraint Integer Programs */ -/* */ -/* Copyright (C) 2010-2022 Operations Research, RWTH Aachen University */ -/* Zuse Institute Berlin (ZIB) */ -/* */ -/* This program is free software; you can redistribute it and/or */ -/* modify it under the terms of the GNU Lesser General Public License */ -/* as published by the Free Software Foundation; either version 3 */ -/* of the License, or (at your option) any later version. */ -/* */ -/* This program is distributed in the hope that it will be useful, */ -/* but WITHOUT ANY WARRANTY; without even the implied warranty of */ -/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ -/* GNU Lesser General Public License for more details. */ -/* */ -/* You should have received a copy of the GNU Lesser General Public License */ -/* along with this program; if not, write to the Free Software */ -/* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.*/ -/* */ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -/**@file pub_bliss.h - * @ingroup PUBLICCOREAPI - * @brief helper functions for automorphism detection - * - * @author Martin Bergner - * @author Daniel Peters - * @author Jonas Witt - * - */ - -/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/ - -#ifndef PUB_BLISS_H_ -#define PUB_BLISS_H_ - -#include "scip/scip.h" - -#ifdef __cplusplus -extern "C" { -#endif - - -typedef struct struct_cons AUT_CONS; -typedef struct struct_var AUT_VAR; -typedef struct struct_coef AUT_COEF; -typedef struct struct_colorinformation AUT_COLOR; -/** -* @ingroup BLISS -* @{ - */ - -/** returns bliss version */ -extern -void GCGgetBlissName(char* buffer, int len); - -#ifdef __cplusplus -} -#endif - -#ifdef __cplusplus -/** saves a constraint with its corresponding scip */ -struct struct_cons -{ - SCIP* scip; /**< SCIP data structure */ - SCIP_CONS* cons; /**< pointer to SCIP constraint */ - - /** constructor for the constraint struct */ - struct_cons( SCIP* scip, SCIP_CONS* scons ); - - /** getter for the SCIP constraint */ - SCIP_CONS* getCons(); - - /** getter for the SCIP itself */ - SCIP* getScip(); -}; - -/** saves a variable with its corresponding scip */ -struct struct_var -{ - SCIP* scip; /**< SCIP data structure */ - SCIP_VAR* var; /**< pointer to SCIP variable */ - - /** constructor for the variable struct */ - struct_var( SCIP* scip, SCIP_VAR* svar ); - - /** getter for the SCIP variable */ - SCIP_VAR* getVar(); - - /** getter for the SCIP itself */ - SCIP* getScip(); -}; - -/** saves a coefficient with its corresponding scip */ -struct struct_coef -{ - SCIP* scip; /**< SCIP data structure */ - SCIP_Real val; /**< SCIP Real value */ - - /** constructor for the coefficient struct */ - struct_coef( SCIP* scip, SCIP_Real val ); - - /** getter for the SCIP Real value */ - SCIP_Real getVal(); - - /** getter for the SCIP itself */ - SCIP* getScip(); -}; - -/** saves helping information for creating the graph */ -struct struct_colorinformation -{ - int color; /**< color of the nodes of the graph */ - int lenconssarray; /**< size of ptrarrayconss */ - int lenvarsarray; /**< size of ptrarrayvars */ - int lencoefsarray; /**< size of ptrarraycoefs */ - int alloccoefsarray; /**< allocated size of ptrarraycoefs */ - - void** ptrarraycoefs; /**< array of pointers to coefficient */ - void** ptrarrayvars; /**< array of pointers to variables */ - void** ptrarrayconss; /**< array of pointers to constraints */ - - SCIP_Bool onlysign; /**< use sign of values instead of values? (should be FALSE if we check whether pricin problems can be aggregated) */ - - /** default constructor */ - struct_colorinformation(); - - /** insert a variable to its pointer array */ - SCIP_RETCODE insert( AUT_VAR* svar, SCIP_Bool* added); - - /** insert a constraint to its pointer array */ - SCIP_RETCODE insert( AUT_CONS* scons, SCIP_Bool* added); - - /** insert a coefficient to its pointer array */ - SCIP_RETCODE insert( AUT_COEF* scoef, SCIP_Bool* added); - - /** getter for the length of the variable array */ - int getLenVar(); - - /** getter for the length of the constraint array */ - int getLenCons(); - - /** getter for the variable struct */ - int get( AUT_VAR svar); - - /** getter for the constraint struct */ - int get( AUT_CONS scons); - - /** getter for the coefficient struct */ - int get( AUT_COEF scoef); - - /** set onlysign bool */ - SCIP_RETCODE setOnlySign(SCIP_Bool onlysign_); - - /** get onlysign bool */ - SCIP_Bool getOnlySign(); -}; - - -#endif -/** @} */ -#endif /* PUB_BLISS_H_ */ diff --git a/headers/gcg/pub_colpool.h b/headers/gcg/pub_colpool.h deleted file mode 100644 index 594795f..0000000 --- a/headers/gcg/pub_colpool.h +++ /dev/null @@ -1,175 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* */ -/* This file is part of the program */ -/* GCG --- Generic Column Generation */ -/* a Dantzig-Wolfe decomposition based extension */ -/* of the branch-cut-and-price framework */ -/* SCIP --- Solving Constraint Integer Programs */ -/* */ -/* Copyright (C) 2010-2022 Operations Research, RWTH Aachen University */ -/* Zuse Institute Berlin (ZIB) */ -/* */ -/* This program is free software; you can redistribute it and/or */ -/* modify it under the terms of the GNU Lesser General Public License */ -/* as published by the Free Software Foundation; either version 3 */ -/* of the License, or (at your option) any later version. */ -/* */ -/* This program is distributed in the hope that it will be useful, */ -/* but WITHOUT ANY WARRANTY; without even the implied warranty of */ -/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ -/* GNU Lesser General Public License for more details. */ -/* */ -/* You should have received a copy of the GNU Lesser General Public License */ -/* along with this program; if not, write to the Free Software */ -/* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.*/ -/* */ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -/**@file pub_colpool.h - * @ingroup PUBLICCOREAPI - * @brief public methods for storing cols in a col pool - * @author Tobias Achterberg - */ - -/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/ - -#ifndef __SCIP_PUB_COLPOOL_H__ -#define __SCIP_PUB_COLPOOL_H__ - - -#include "scip/def.h" -#include "type_colpool.h" -#include "type_gcgcol.h" -#include "type_pricestore_gcg.h" - - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @ingroup DATASTRUCTURES - * @{ - */ - -/** gets array of cols in the col pool */ -SCIP_EXPORT -GCG_COL** GCGcolpoolGetCols( - GCG_COLPOOL* colpool /**< col pool */ - ); - -/** get number of cols in the col pool */ -SCIP_EXPORT -int GCGcolpoolGetNCols( - GCG_COLPOOL* colpool /**< col pool */ - ); - -/** get maximum number of cols that were stored in the col pool at the same time */ -SCIP_EXPORT -int GCGcolpoolGetMaxNCols( - GCG_COLPOOL* colpool /**< col pool */ - ); - -/** gets time in seconds used for pricing cols from the pool */ -SCIP_EXPORT -SCIP_Real GCGcolpoolGetTime( - GCG_COLPOOL* colpool /**< col pool */ - ); - -/** get number of times, the col pool was separated */ -SCIP_EXPORT -SCIP_Longint GCGcolpoolGetNCalls( - GCG_COLPOOL* colpool /**< col pool */ - ); - -/** get total number of cols that were priced from the col pool */ -SCIP_EXPORT -SCIP_Longint GCGcolpoolGetNColsFound( - GCG_COLPOOL* colpool /**< col pool */ - ); - -/** creates col pool */ -SCIP_EXPORT -SCIP_RETCODE GCGcolpoolCreate( - SCIP* scip, /**< SCIP data structure */ - GCG_COLPOOL** colpool, /**< pointer to store col pool */ - int agelimit /**< maximum age a col can reach before it is deleted from the pool */ - ); - -/** frees col pool */ -SCIP_EXPORT -SCIP_RETCODE GCGcolpoolFree( - SCIP* scip, /**< SCIP data structure */ - GCG_COLPOOL** colpool /**< pointer to store col pool */ - ); - -/** removes all cols from the col pool */ -SCIP_EXPORT -SCIP_RETCODE GCGcolpoolClear( - GCG_COLPOOL* colpool /**< col pool */ - ); - -/** if not already existing, adds col to col pool and captures it */ -SCIP_EXPORT -SCIP_RETCODE GCGcolpoolAddCol( - GCG_COLPOOL* colpool, /**< col pool */ - GCG_COL* col, /**< column to add */ - SCIP_Bool* success /**< pointer to store if col was added */ - ); - -/** adds col to col pool and captures it; doesn't check for multiple cols */ -SCIP_EXPORT -SCIP_RETCODE GCGcolpoolAddNewCol( - GCG_COLPOOL* colpool, /**< col pool */ - GCG_COL* col /**< column to add */ - ); - -/** removes the col from the col pool */ -SCIP_EXPORT -SCIP_RETCODE GCGcolpoolDelCol( - GCG_COLPOOL* colpool, /**< col pool */ - GCG_COL* col, /**< col to remove */ - SCIP_Bool freecol /**< should the col be freed? */ - ); - -/** update node at which columns of column pool are feasible */ -SCIP_EXPORT -SCIP_RETCODE GCGcolpoolUpdateNode( - GCG_COLPOOL* colpool /**< col pool */ - ); - -/** update reduced cost of columns in column pool */ -SCIP_EXPORT -SCIP_RETCODE GCGcolpoolUpdateRedcost( - GCG_COLPOOL* colpool /**< col pool */ - ); - -/** gets number of cols in the col pool */ -SCIP_EXPORT -void GCGcolpoolStartFarkas( - GCG_COLPOOL* colpool /**< col pool */ - ); - -/** gets number of cols in the col pool */ -SCIP_EXPORT -void GCGcolpoolEndFarkas( - GCG_COLPOOL* colpool /**< col pool */ - ); - -/** prices cols of the col pool */ -SCIP_EXPORT -SCIP_RETCODE GCGcolpoolPrice( - SCIP* scip, /**< SCIP data structure */ - GCG_COLPOOL* colpool, /**< col pool */ - GCG_PRICESTORE* pricestore, /**< GCG price storage */ - SCIP_SOL* sol, /**< solution to be separated (or NULL for LP-solution) */ - SCIP_Bool* foundvars /**< pointer to store the result of the separation call */ - ); - -/** @} */ - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/headers/gcg/pub_decomp.h b/headers/gcg/pub_decomp.h deleted file mode 100644 index fbe935a..0000000 --- a/headers/gcg/pub_decomp.h +++ /dev/null @@ -1,731 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* */ -/* This file is part of the program */ -/* GCG --- Generic Column Generation */ -/* a Dantzig-Wolfe decomposition based extension */ -/* of the branch-cut-and-price framework */ -/* SCIP --- Solving Constraint Integer Programs */ -/* */ -/* Copyright (C) 2010-2022 Operations Research, RWTH Aachen University */ -/* Zuse Institute Berlin (ZIB) */ -/* */ -/* This program is free software; you can redistribute it and/or */ -/* modify it under the terms of the GNU Lesser General Public License */ -/* as published by the Free Software Foundation; either version 3 */ -/* of the License, or (at your option) any later version. */ -/* */ -/* This program is distributed in the hope that it will be useful, */ -/* but WITHOUT ANY WARRANTY; without even the implied warranty of */ -/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ -/* GNU Lesser General Public License for more details. */ -/* */ -/* You should have received a copy of the GNU Lesser General Public License */ -/* along with this program; if not, write to the Free Software */ -/* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.*/ -/* */ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -/**@file pub_decomp.h - * @ingroup PUBLICCOREAPI - * @brief public methods for working with decomposition structures - * @author Martin Bergner - */ - -/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/ -#ifndef GCG_PUB_DECOMP_H__ -#define GCG_PUB_DECOMP_H__ - -#include "type_decomp.h" -#include "scip/type_scip.h" -#include "scip/type_retcode.h" -#include "scip/type_var.h" -#include "scip/type_cons.h" -#include "scip/type_misc.h" -#include "type_detector.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @ingroup DECOMP - * @{ - */ - -/** score data structure - * @ingroup DATASTRUCTURES -**/ -struct Dec_Scores -{ - SCIP_Real borderscore; /**< score of the border */ - SCIP_Real densityscore; /**< score of block densities */ - SCIP_Real linkingscore; /**< score related to interlinking blocks */ - SCIP_Real totalscore; /**< accumulated score */ - SCIP_Real maxwhitescore; /**< score related to max white measure (i.e. fraction of white (nonblock and nonborder) matrix area ) */ -}; -typedef struct Dec_Scores DEC_SCORES; - -/** converts the DEC_DECTYPE enum to a string */ -const char *DECgetStrType( - DEC_DECTYPE type /**< decomposition type */ - ); - -/** initializes the decomposition to absolutely nothing */ -extern -SCIP_RETCODE DECdecompCreate( - SCIP* scip, /**< SCIP data structure */ - DEC_DECOMP** decomp /**< pointer to the decomposition data structure */ - ); - -/** frees the decomposition */ -extern -SCIP_RETCODE DECdecompFree( - SCIP* scip, /**< SCIP data structure */ - DEC_DECOMP** decomp /**< pointer to the decomposition data structure */ - ); - -/** sets the type of the decomposition */ -extern -SCIP_RETCODE DECdecompSetType( - DEC_DECOMP* decomp, /**< decomposition data structure */ - DEC_DECTYPE type /**< type of the decomposition */ - ); - -/** gets the type of the decomposition */ -extern -DEC_DECTYPE DECdecompGetType( - DEC_DECOMP* decomp /**< decomposition data structure */ - ); - -extern -SCIP_Real DECdecompGetMaxwhiteScore( - DEC_DECOMP* decomp /**< decomposition data structure */ - ); - -extern -void DECsetMaxWhiteScore( - SCIP* scip, /**< SCIP data structure */ - DEC_DECOMP* decomp, /**< decomposition data structure */ - SCIP_Real maxwhitescore /**< score related to max white measure (i.e. fraction of white (nonblock and nonborder) matrix area ) */ - ); - -/** sets the presolved flag for decomposition */ -extern -void DECdecompSetPresolved( - DEC_DECOMP* decomp, /**< decomposition data structure */ - SCIP_Bool presolved /**< presolved flag for decomposition */ - ); - -/** gets the presolved flag for decomposition */ -extern -SCIP_Bool DECdecompGetPresolved( - DEC_DECOMP* decomp /**< decomposition data structure */ - ); - -/** sets the number of blocks for decomposition */ -extern -void DECdecompSetNBlocks( - DEC_DECOMP* decomp, /**< decomposition data structure */ - int nblocks /**< number of blocks for decomposition */ - ); - -/** gets the number of blocks for decomposition */ -extern -int DECdecompGetNBlocks( - DEC_DECOMP* decomp /**< decomposition data structure */ - ); - -/** copies the input subscipvars array to the given decomposition */ -extern -SCIP_RETCODE DECdecompSetSubscipvars( - SCIP* scip, /**< SCIP data structure */ - DEC_DECOMP* decomp, /**< decomposition data structure */ - SCIP_VAR*** subscipvars, /**< subscipvars array */ - int* nsubscipvars /**< number of subscipvars per block */ - ); - -/** returns the subscipvars array of the given decomposition */ -extern -SCIP_VAR*** DECdecompGetSubscipvars( - DEC_DECOMP* decomp /**< decomposition data structure */ - ); - -/** returns the nsubscipvars array of the given decomposition */ -extern -int* DECdecompGetNSubscipvars( - DEC_DECOMP* decomp /**< decomposition data structure */ - ); - -/** copies the input subscipconss array to the given decomposition */ -extern -SCIP_RETCODE DECdecompSetSubscipconss( - SCIP* scip, /**< SCIP data structure */ - DEC_DECOMP* decomp, /**< decomposition data structure */ - SCIP_CONS*** subscipconss, /**< subscipconss array */ - int* nsubscipconss /**< number of subscipconss per block */ - ); - -/** returns the subscipconss array of the given decomposition */ -extern -SCIP_CONS*** DECdecompGetSubscipconss( - DEC_DECOMP* decomp /**< decomposition data structure */ - ); - -/** returns the nsubscipconss array of the given decomposition */ -extern -int* DECdecompGetNSubscipconss( - DEC_DECOMP* decomp /**< decomposition data structure */ - ); - -/** copies the input linkingconss array to the given decomposition */ -extern -SCIP_RETCODE DECdecompSetLinkingconss( - SCIP* scip, /**< SCIP data structure */ - DEC_DECOMP* decomp, /**< decomposition data structure */ - SCIP_CONS** linkingconss, /**< linkingconss array */ - int nlinkingconss /**< number of linkingconss per block */ - ); - -/** returns the linkingconss array of the given decomposition */ -extern -SCIP_CONS** DECdecompGetLinkingconss( - DEC_DECOMP* decomp /**< decomposition data structure */ - ); - -/** returns the nlinkingconss array of the given decomposition */ -extern -int DECdecompGetNLinkingconss( - DEC_DECOMP* decomp /**< decomposition data structure */ - ); - -/** copies the input linkingvars array to the given decomposition */ -extern -SCIP_RETCODE DECdecompSetLinkingvars( - SCIP* scip, /**< SCIP data structure */ - DEC_DECOMP* decomp, /**< decomposition data structure */ - SCIP_VAR** linkingvars, /**< linkingvars array */ - int nlinkingvars, /**< number of linkingvars per block */ - int nfixedlinkingvars, /**< number of linking variables that are fixed */ - int nmastervars /**< number of linkingvars that are purely master variables */ - ); - -/** returns the linkingvars array of the given decomposition */ -extern -SCIP_VAR** DECdecompGetLinkingvars( - DEC_DECOMP* decomp /**< decomposition data structure */ - ); - -/** returns the number of master variables of the given decomposition */ -extern -int DECdecompGetNMastervars( - DEC_DECOMP* decomp /**< decomposition data structure */ - ); - - -/** returns the nlinkingvars array of the given decomposition */ -extern -int DECdecompGetNLinkingvars( - DEC_DECOMP* decomp /**< decomposition data structure */ - ); - -/** returns the nlinkingvars array of the given decomposition */ -extern -int DECdecompGetNFixedLinkingvars( - DEC_DECOMP* decomp /**< decomposition data structure */ - ); - - -/** copies the input stairlinkingvars array to the given decomposition */ -extern -SCIP_RETCODE DECdecompSetStairlinkingvars( - SCIP* scip, /**< SCIP data structure */ - DEC_DECOMP* decomp, /**< decomposition data structure */ - SCIP_VAR*** stairlinkingvars, /**< stairlinkingvars array */ - int* nstairlinkingvars /**< number of linkingvars per block */ - ); - -/** returns the stairlinkingvars array of the given decomposition */ -extern -SCIP_VAR*** DECdecompGetStairlinkingvars( - DEC_DECOMP* decomp /**< decomposition data structure */ - ); - -/** returns the nstairlinkingvars array of the given decomposition */ -extern -int* DECdecompGetNStairlinkingvars( - DEC_DECOMP* decomp /**< decomposition data structure */ - ); - -/** returns the total number of stairlinkingvars array of the given decomposition */ -int DECdecompGetNTotalStairlinkingvars( - DEC_DECOMP* decomp /**< decomposition data structure */ - ); - - -/** sets the vartoblock hashmap of the given decomposition */ -extern -void DECdecompSetVartoblock( - DEC_DECOMP* decomp, /**< decomposition data structure */ - SCIP_HASHMAP* vartoblock /**< Vartoblock hashmap */ - ); - -/** returns the vartoblock hashmap of the given decomposition */ -extern -SCIP_HASHMAP* DECdecompGetVartoblock( - DEC_DECOMP* decomp /**< decomposition data structure */ - ); - -/** sets the constoblock hashmap of the given decomposition */ -void DECdecompSetConstoblock( - DEC_DECOMP* decomp, /**< decomposition data structure */ - SCIP_HASHMAP* constoblock /**< Constoblock hashmap */ - ); - -/** returns the constoblock hashmap of the given decomposition */ -extern -SCIP_HASHMAP* DECdecompGetConstoblock( - DEC_DECOMP* decomp /**< decomposition data structure */ - ); - -/** sets the varindex hashmap of the given decomposition */ -void DECdecompSetVarindex( - DEC_DECOMP* decomp, /**< decomposition data structure */ - SCIP_HASHMAP* varindex /**< Varindex hashmap */ - ); - -/** returns the varindex hashmap of the given decomposition */ -SCIP_HASHMAP* DECdecompGetVarindex( - DEC_DECOMP* decomp /**< decomposition data structure */ - ); - -/** sets the consindex hashmap of the given decomposition */ -extern -void DECdecompSetConsindex( - DEC_DECOMP* decomp, /**< decomposition data structure */ - SCIP_HASHMAP* consindex /**< Consindex hashmap */ - ); - -/** returns the consindex hashmap of the given decomposition */ -extern -SCIP_HASHMAP* DECdecompGetConsindex( - DEC_DECOMP* decomp /**< decomposition data structure */ - ); - -/** completely initializes decomposition structure from the values of the hashmaps */ -extern -SCIP_RETCODE DECfilloutDecompFromHashmaps( - SCIP* scip, /**< SCIP data structure */ - DEC_DECOMP* decomp, /**< decomposition data structure */ - SCIP_HASHMAP* vartoblock, /**< variable to block hashmap */ - SCIP_HASHMAP* constoblock, /**< constraint to block hashmap */ - int nblocks, /**< number of blocks */ - SCIP_Bool staircase /**< should the decomposition be a staircase structure */ - ); - -/** completely fills out decomposition structure from only the constraint partition */ -extern -SCIP_RETCODE DECfilloutDecompFromConstoblock( - SCIP* scip, /**< SCIP data structure */ - DEC_DECOMP* decomp, /**< decomposition data structure */ - SCIP_HASHMAP* constoblock, /**< constraint to block hashmap, start with 1 for first block and nblocks+1 for linking constraints */ - int nblocks, /**< number of blocks */ - SCIP_Bool staircase /**< should the decomposition be a staircase structure */ - ); - -/** sets the detector for the given decomposition */ -extern -void DECdecompSetDetector( - DEC_DECOMP* decomp, /**< decomposition data structure */ - DEC_DETECTOR* detector /**< detector data structure */ - ); - -/** gets the detector for the given decomposition */ -extern -DEC_DETECTOR* DECdecompGetDetector( - DEC_DECOMP* decomp /**< decomposition data structure */ - ); - -/** gets the detectors for the given decomposition */ -extern -DEC_DETECTOR** DECdecompGetDetectorChain( - DEC_DECOMP* decomp /**< decomposition data structure */ - ); - -/** gets the number of detectors for the given decomposition */ -extern -int DECdecompGetDetectorChainSize( - DEC_DECOMP* decomp /**< decomposition data structure */ - ); - -/** gets the id of the original partialdec */ -extern -int DECdecompGetPartialdecID( - DEC_DECOMP* decomp /**< decomposition data structure */ - ); - -/** sets the detector clock times of the detectors of the detector chain */ -extern -void DECdecompSetDetectorClockTimes( - SCIP* scip, /**< SCIP data structure */ - DEC_DECOMP* decomp, /**< decomposition data structure */ - SCIP_Real* detectorClockTimes /**< time used by the detectors */ - ); - -/** gets the detector clock times of the detectors of the detector chain */ -extern -SCIP_Real* DECdecompGetDetectorClockTimes( - DEC_DECOMP* decomp /**< decomposition data structure */ - ); - -/** sets the detector clock times of the detectors of the detector chain */ -extern -SCIP_RETCODE DECdecompSetDetectorChainString( - SCIP* scip, /**< SCIP data structure */ - DEC_DECOMP* decomp, /**< decomposition data structure */ - const char* detectorchainstring /**< string for the detector information working on that decomposition */ - ); - - -extern -char* DECdecompGetDetectorChainString( - SCIP* scip, /**< SCIP data structure */ - DEC_DECOMP* decomp /**< decomposition data structure */ - ); - - -/** sets the percentages of variables assigned to the border of the corresponding detectors (of the detector chain) on this decomposition */ -extern -void DECdecompSetDetectorPctVarsToBorder( - SCIP* scip, /**< SCIP data structure */ - DEC_DECOMP* decomp, /**< decomposition data structure */ - SCIP_Real* pctVarsToBorder - ); - -/** gets the percentages of variables assigned to the border of the corresponding detectors (of the detector chain) on this decomposition */ -extern -SCIP_Real* DECdecompGetDetectorPctVarsToBorder( - DEC_DECOMP* decomp /**< decomposition data structure */ - ); - -/** sets the percentages of constraints assigned to the border of the corresponding detectors (of the detector chain) on this decomposition */ -extern -void DECdecompSetDetectorPctConssToBorder( - SCIP* scip, /**< SCIP data structure */ - DEC_DECOMP* decomp, /**< decomposition data structure */ - SCIP_Real* pctConssToBorder - ); - -/** gets the percentages of constraints assigned to the border of the corresponding detectors (of the detector chain) on this decomposition */ -extern -SCIP_Real* DECdecompGetDetectorPctConssToBorder( - DEC_DECOMP* decomp /**< decomposition data structure */ - ); - -/** sets the percentages of variables assigned to some block of the corresponding detectors (of the detector chain) on this decomposition */ -extern -void DECdecompSetDetectorPctVarsToBlock( - SCIP* scip, /**< SCIP data structure */ - DEC_DECOMP* decomp, /**< decomposition data structure */ - SCIP_Real* pctVarsToBlock - ); - -/** gets the percentages of variables assigned to some block of the corresponding detectors (of the detector chain) on this decomposition */ -extern -SCIP_Real* DECdecompGetDetectorPctVarsToBlock( - DEC_DECOMP* decomp /**< decomposition data structure */ - ); - -/** sets the percentages of constraints assigned to some block of the corresponding detectors (of the detector chain) on this decomposition */ -extern -void DECdecompSetDetectorPctConssToBlock( - SCIP* scip, /**< SCIP data structure */ - DEC_DECOMP* decomp, /**< decomposition data structure */ - SCIP_Real* pctConssToBlock - ); - -/** gets the percentages of constraints assigned to some block of the corresponding detectors (of the detector chain) on this decomposition */ -extern -SCIP_Real* DECdecompGetDetectorPctConssToBlock( - DEC_DECOMP* decomp /**< decomposition data structure */ - ); - - -/** sets the percentages of variables assigned to some block of the corresponding detectors (of the detector chain) on this decomposition */ -extern -void DECdecompSetDetectorPctVarsFromOpen( - SCIP* scip, /**< SCIP data structure */ - DEC_DECOMP* decomp, /**< decomposition data structure */ - SCIP_Real* pctVarsFromOpen - ); - -/** gets the percentages of variables assigned to some block of the corresponding detectors (of the detector chain) on this decomposition */ -extern -SCIP_Real* DECdecompGetDetectorPctVarsFromOpen( - DEC_DECOMP* decomp /**< decomposition data structure */ - ); - -/** sets the percentages of constraints assigned to some block of the corresponding detectors (of the detector chain) on this decomposition */ -extern -void DECdecompSetDetectorPctConssFromOpen( - SCIP* scip, /**< SCIP data structure */ - DEC_DECOMP* decomp, /**< decomposition data structure */ - SCIP_Real* pctConssToBorder - ); - -/** gets the percentages of constraints assigned to some block of the corresponding detectors (of the detector chain) on this decomposition */ -extern -SCIP_Real* DECdecompGetDetectorPctConssFromOpen( - DEC_DECOMP* decomp /**< decomposition data structure */ - ); - -/** sets the number of new blocks of the corresponding detectors (of the detector chain) on this decomposition */ -extern -void DECdecompSetNNewBlocks( - SCIP* scip, /**< SCIP data structure */ - DEC_DECOMP* decomp, /**< decomposition data structure */ - int* nNewBlocks /**< number of new blocks on this decomposition */ - ); - -/** gets the number of new blocks corresponding detectors (of the detector chain) on this decomposition */ -extern -int* DECdecompGetNNewBlocks( - DEC_DECOMP* decomp /**< decomposition data structure */ - ); - -/** transforms all constraints and variables, updating the arrays */ -extern -SCIP_RETCODE DECdecompTransform( - SCIP* scip, /**< SCIP data structure */ - DEC_DECOMP* decomp /**< decomposition data structure */ - ); - -/** - * Remove all those constraints that were removed from the problem after the decomposition had been created - */ -extern -SCIP_RETCODE DECdecompRemoveDeletedConss( - SCIP* scip, /**< SCIP data structure */ - DEC_DECOMP* decomp /**< decomposition data structure */ - ); - -/** - * Adds all those constraints that were added to the problem after the decomposition as created - */ -extern -SCIP_RETCODE DECdecompAddRemainingConss( - SCIP* scip, /**< SCIP data structure */ - DEC_DECOMP* decomp /**< decomposition data structure */ - ); - -/** checks the validity of the decomposition data structure */ -extern -SCIP_RETCODE DECdecompCheckConsistency( - SCIP* scip, /**< SCIP data structure */ - DEC_DECOMP* decomp /**< decomposition data structure */ - ); - -/** creates a decomposition with all constraints in the master */ -extern -SCIP_RETCODE DECcreateBasicDecomp( - SCIP* scip, /**< SCIP data structure */ - DEC_DECOMP** decomp, /**< decomposition data structure */ - SCIP_Bool solveorigprob /**< is the original problem being solved? */ - ); - -/** creates a decomposition with provided constraints in the master - * The function will put the remaining constraints in one or more pricing problems - * depending on whether the subproblems decompose with no variables in common. - */ -extern -SCIP_RETCODE DECcreateDecompFromMasterconss( - SCIP* scip, /**< SCIP data structure */ - DEC_DECOMP** decomp, /**< decomposition data structure */ - SCIP_CONS** conss, /**< constraints to be put in the master */ - int nconss /**< number of constraints in the master */ - ); - -/** return the number of variables and binary, integer, implied integer, continuous variables of all subproblems */ -extern -void DECgetSubproblemVarsData( - SCIP* scip, /**< SCIP data structure */ - DEC_DECOMP* decomp, /**< decomposition data structure */ - int* nvars, /**< pointer to array of size nproblems to store number of subproblem vars or NULL */ - int* nbinvars, /**< pointer to array of size nproblems to store number of binary subproblem vars or NULL */ - int* nintvars, /**< pointer to array of size nproblems to store number of integer subproblem vars or NULL */ - int* nimplvars, /**< pointer to array of size nproblems to store number of implied subproblem vars or NULL */ - int* ncontvars, /**< pointer to array of size nproblems to store number of continuous subproblem vars or NULL */ - int nproblems /**< size of the arrays*/ - ); - -/** return the number of variables and binary, integer, implied integer, continuous variables of the master */ -extern -void DECgetLinkingVarsData( - SCIP* scip, /**< SCIP data structure */ - DEC_DECOMP* decomp, /**< decomposition data structure */ - int* nvars, /**< pointer to store number of linking vars or NULL */ - int* nbinvars, /**< pointer to store number of binary linking vars or NULL */ - int* nintvars, /**< pointer to store number of integer linking vars or NULL */ - int* nimplvars, /**< pointer to store number of implied linking vars or NULL */ - int* ncontvars /**< pointer to store number of continuous linking vars or NULL */ - ); - -/** - * returns the number of nonzeros of each column of the constraint matrix both in the subproblem and in the master - * @note For linking variables, the number of nonzeros in the subproblems corresponds to the number on nonzeros - * in the border - * - * @note The arrays have to be allocated by the caller - * - * @pre This function assumes that constraints are partitioned in the decomp structure, no constraint is present in more than one block - * - */ -extern -SCIP_RETCODE DECgetDensityData( - SCIP* scip, /**< SCIP data structure */ - DEC_DECOMP* decomp, /**< decomposition data structure */ - SCIP_VAR** vars, /**< pointer to array store variables belonging to density */ - int nvars, /**< number of variables */ - SCIP_CONS** conss, /**< pointer to array to store constraints belonging to the density */ - int nconss, /**< number of constraints */ - int* varsubproblemdensity, /**< pointer to array to store the nonzeros for the subproblems */ - int* varmasterdensity, /**< pointer to array to store the nonzeros for the master */ - int* conssubproblemdensity, /**< pointer to array to store the nonzeros for the subproblems */ - int* consmasterdensity /**< pointer to array to store the nonzeros for the master */ -); - -/** - * calculates the number of up and down locks of variables for a given decomposition in both the original problem and the pricingproblems - * - * @note All arrays need to be allocated by the caller - * - * @warning This function needs a lot of memory (nvars*nblocks+1) array entries - */ -SCIP_RETCODE DECgetVarLockData( - SCIP* scip, /**< SCIP data structure */ - DEC_DECOMP* decomp, /**< decomposition data structure */ - SCIP_VAR** vars, /**< pointer to array store variables belonging to density */ - int nvars, /**< number of variables */ - int nsubproblems, /**< number of sub problems */ - int** subsciplocksdown, /**< pointer to two dimensional array to store the down locks for the subproblems */ - int** subsciplocksup, /**< pointer to two dimensional array to store the down locks for the subproblems */ - int* masterlocksdown, /**< pointer to array to store the down locks for the master */ - int* masterlocksup /**< pointer to array to store the down locks for the master */ - ); - -/** - * returns the maximum white score ( if it is not calculated yet is decomp is evaluated) - */ -SCIP_Real DECgetMaxWhiteScore( - SCIP* scip, /**< SCIP data structure */ - DEC_DECOMP* decomp /**< decomposition data structure */ - ); - - -/** computes the score of the given decomposition based on the border, the average density score and the ratio of - * linking variables - */ -extern -SCIP_RETCODE DECevaluateDecomposition( - SCIP* scip, /**< SCIP data structure */ - DEC_DECOMP* decomp, /**< decomposition data structure */ - DEC_SCORES* score /**< returns the score of the decomposition */ - ); - -/** returns the number of constraints saved in the decomposition */ -int DECdecompGetNConss( - DEC_DECOMP* decomp /**< decomposition data structure */ - ); - -/** display statistics about the decomposition */ -extern -SCIP_RETCODE GCGprintDecompStatistics( - SCIP* scip, /**< SCIP data structure */ - FILE* file, /**< output file or NULL for standard output */ - DEC_DECOMP* decomp /**< decomp that should be evaluated */ - ); - -/** returns whether both structures lead to the same decomposition */ -extern -SCIP_Bool DECdecompositionsAreEqual( - SCIP* scip, /**< SCIP data structure */ - DEC_DECOMP* decomp1, /**< first decomp data structure */ - DEC_DECOMP* decomp2 /**< second decomp data structure */ -); - - -/** filters similar decompositions from a given list and moves them to the end - * @return the number of unique decompositions - */ -extern -int DECfilterSimilarDecompositions( - SCIP* scip, /**< SCIP data structure */ - DEC_DECOMP** decs, /**< array of decompositions */ - int ndecs /**< number of decompositions */ -); - -/** returns the number of the block that the constraint is with respect to the decomposition */ -extern -SCIP_RETCODE DECdetermineConsBlock( - SCIP* scip, /**< SCIP data structure */ - DEC_DECOMP* decomp, /**< decomposition data structure */ - SCIP_CONS* cons, /**< constraint to check */ - int *block /**< block of the constraint (or nblocks for master) */ -); - -/** move a master constraint to pricing problem */ -extern -SCIP_RETCODE DECdecompMoveLinkingConsToPricing( - SCIP* scip, /**< SCIP data structure */ - DEC_DECOMP* decomp, /**< decomposition data structure */ - int consindex, /**< index of constraint to move */ - int block /**< block of the pricing problem where to move */ - ); - -/** tries to assign masterconss to pricing problem */ -extern -SCIP_RETCODE DECtryAssignMasterconssToExistingPricing( - SCIP* scip, /**< SCIP data structure */ - DEC_DECOMP* decomp, /**< decomposition data structure */ - int* transferred /**< number of master constraints reassigned */ - ); - -/** tries to assign masterconss to new pricing problem */ -extern -SCIP_RETCODE DECtryAssignMasterconssToNewPricing( - SCIP* scip, /**< SCIP data structure */ - DEC_DECOMP* decomp, /**< decomposition data structure */ - DEC_DECOMP** newdecomp, /**< new decomposition, if successful */ - int* transferred /**< number of master constraints reassigned */ - ); - -/** polish the decomposition and try to greedily assign master constraints to pricing problem where useful */ -extern -SCIP_RETCODE DECcreatePolishedDecomp( - SCIP* scip, /**< SCIP data structure */ - DEC_DECOMP* decomp, /**< decomposition data structure */ - DEC_DECOMP** newdecomp /**< new decomposition, if successful */ - ); - -/** permutes the decomposition according to the permutation seed */ -extern -SCIP_RETCODE DECpermuteDecomp( - SCIP* scip, /**< SCIP data structure */ - DEC_DECOMP* decomp, /**< decomposition data structure */ - SCIP_RANDNUMGEN* randnumgen /**< random number generator */ - ); - -/** gets the number of existing decompositions - * - * @returns number of decompositions - */ -extern -int DECgetNDecomps( - SCIP* scip /**< SCIP data structure */ - ); - -/** @} */ -#ifdef __cplusplus -} - -#endif -#endif diff --git a/headers/gcg/pub_gcgcol.h b/headers/gcg/pub_gcgcol.h deleted file mode 100644 index 62316d9..0000000 --- a/headers/gcg/pub_gcgcol.h +++ /dev/null @@ -1,284 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* */ -/* This file is part of the program */ -/* GCG --- Generic Column Generation */ -/* a Dantzig-Wolfe decomposition based extension */ -/* of the branch-cut-and-price framework */ -/* SCIP --- Solving Constraint Integer Programs */ -/* */ -/* Copyright (C) 2010-2022 Operations Research, RWTH Aachen University */ -/* Zuse Institute Berlin (ZIB) */ -/* */ -/* This program is free software; you can redistribute it and/or */ -/* modify it under the terms of the GNU Lesser General Public License */ -/* as published by the Free Software Foundation; either version 3 */ -/* of the License, or (at your option) any later version. */ -/* */ -/* This program is distributed in the hope that it will be useful, */ -/* but WITHOUT ANY WARRANTY; without even the implied warranty of */ -/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ -/* GNU Lesser General Public License for more details. */ -/* */ -/* You should have received a copy of the GNU Lesser General Public License */ -/* along with this program; if not, write to the Free Software */ -/* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.*/ -/* */ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -/**@file pub_gcgcol.h - * @ingroup PUBLICCOREAPI - * @brief public methods for working with gcg columns - * @author Jonas Witt - */ - -/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/ -#ifndef GCG_PUB_GCGCOL_H__ -#define GCG_PUB_GCGCOL_H__ - -#include "type_gcgcol.h" -#include "scip/type_scip.h" -#include "scip/type_retcode.h" -#include "scip/type_var.h" -#include "scip/type_cons.h" -#include "scip/type_misc.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/* - * GCG Column - */ - -/**@defgroup GCG_COLUMN GCG Column - * @ingroup DATASTRUCTURES - * @{ - */ - -/** create a gcg column */ -extern -SCIP_RETCODE GCGcreateGcgCol( - SCIP* scip, /**< SCIP data structure */ - GCG_COL** gcgcol, /**< pointer to store gcg column */ - int prob, /**< number of corresponding pricing problem */ - SCIP_VAR** vars, /**< (sorted) array of variables of corresponding pricing problem */ - SCIP_Real* vals, /**< array of solution values (belonging to vars) */ - int nvars, /**< number of variables */ - SCIP_Bool isray, /**< is the column a ray? */ - SCIP_Real redcost /**< last known reduced cost */ -); - -/** free a gcg column */ -extern -void GCGfreeGcgCol( - GCG_COL** gcgcol /**< pointer to store gcg column */ -); - -/** create a gcg column from a solution to a pricing problem */ -extern -SCIP_RETCODE GCGcreateGcgColFromSol( - SCIP* scip, /**< SCIP data structure (original problem) */ - GCG_COL** gcgcol, /**< pointer to store gcg column */ - int prob, /**< number of corresponding pricing problem */ - SCIP_SOL* sol, /**< solution of pricing problem with index prob */ - SCIP_Bool isray, /**< is column a ray? */ - SCIP_Real redcost /**< last known reduced cost */ -); - -/** get pricing problem index of gcg column */ -extern -int GCGcolGetProbNr( - GCG_COL* gcgcol /**< gcg column structure */ -); - -/** get pricing problem of gcg column */ -extern -SCIP* GCGcolGetPricingProb( - GCG_COL* gcgcol /**< gcg column structure */ -); - -/** get variables of gcg column */ -extern -SCIP_VAR** GCGcolGetVars( - GCG_COL* gcgcol /**< gcg column structure */ -); - -/** get values of gcg column */ -extern -SCIP_Real* GCGcolGetVals( - GCG_COL* gcgcol /**< gcg column structure */ -); - -/** get number of variables of gcg column */ -extern -int GCGcolGetNVars( - GCG_COL* gcgcol /**< gcg column structure */ -); - -/** is gcg column a ray? */ -extern -SCIP_Bool GCGcolIsRay( - GCG_COL* gcgcol /**< gcg column structure */ -); - -/** get reduced cost of gcg column */ -extern -SCIP_Real GCGcolGetRedcost( - GCG_COL* gcgcol /**< gcg column structure */ -); - -/** comparison method for sorting gcg columns by non-decreasing reduced cost */ -extern -SCIP_DECL_SORTPTRCOMP(GCGcolCompRedcost); - -/** comparison method for sorting gcg columns by non-increasing age */ -extern -SCIP_DECL_SORTPTRCOMP(GCGcolCompAge); - -/** comparison method for gcg columns. Returns TRUE iff columns are equal */ -extern -SCIP_Bool GCGcolIsEq( - GCG_COL* gcgcol1, /**< first gcg column structure */ - GCG_COL* gcgcol2 /**< second gcg column structure */ -); - -/** update reduced cost of variable and increase age */ -extern -void GCGcolUpdateRedcost( - GCG_COL* gcgcol, /**< gcg column structure */ - SCIP_Real redcost, /**< new reduced cost */ - SCIP_Bool growold /**< increase age counter? */ - ); - -/** return solution value of variable in gcg column */ -extern -SCIP_Real GCGcolGetSolVal( - SCIP* scip, /**< SCIP data structure */ - GCG_COL* gcgcol, /**< gcg column */ - SCIP_VAR* var /**< variable */ - ); - -/** get master coefficients of column */ -extern -SCIP_Real* GCGcolGetMastercoefs( - GCG_COL* gcgcol /**< gcg column structure */ - ); - -/** get number of master coefficients of column */ -extern -int GCGcolGetNMastercoefs( - GCG_COL* gcgcol /**< gcg column structure */ - ); - -/** set master coefficients of column */ -extern -SCIP_RETCODE GCGcolSetMastercoefs( - GCG_COL* gcgcol, /**< gcg column structure */ - SCIP_Real* mastercoefs, /**< array of master coefficients */ - int nmastercoefs /**< number of master coefficients */ - ); - -/** set norm of column */ -extern -void GCGcolSetNorm( - GCG_COL* gcgcol, /**< gcg column structure */ - SCIP_Real norm /**< norm of column */ - ); -/** get norm of column */ -extern -void GCGcolComputeNorm( - SCIP* scip, /**< SCIP data structure */ - GCG_COL* gcgcol /**< gcg column structure */ - ); - -/** set master coefficients of column as initialized */ -extern -SCIP_RETCODE GCGcolSetInitializedCoefs( - GCG_COL* gcgcol /**< gcg column structure */ - ); - -/** return if master coefficients of column have been initialized */ -extern -SCIP_Bool GCGcolGetInitializedCoefs( - GCG_COL* gcgcol /**< gcg column structure */ - ); - -/** get master coefficients of column */ -extern -int* GCGcolGetLinkvars( - GCG_COL* gcgcol /**< gcg column structure */ - ); - -/** get number of master coefficients of column */ -extern -int GCGcolGetNLinkvars( - GCG_COL* gcgcol /**< gcg column structure */ - ); - -/** set master coefficients information of column */ -extern -SCIP_RETCODE GCGcolSetLinkvars( - GCG_COL* gcgcol, /**< gcg column structure */ - int* linkvars, /**< array of linking variable indices for gcgcol->var */ - int nlinkvars /**< number of linking variables in gcgcol->var */ - ); - -/** get master cut coefficients of column */ -extern -SCIP_Real* GCGcolGetMastercuts( - GCG_COL* gcgcol /**< gcg column structure */ - ); - -/** get number of master cut coefficients of column */ -extern -int GCGcolGetNMastercuts( - GCG_COL* gcgcol /**< gcg column structure */ - ); - -/** get norm of column */ -extern -SCIP_Real GCGcolGetNorm( - GCG_COL* gcgcol /**< gcg column structure */ - ); - -/** update master cut coefficients information of column */ -extern -SCIP_RETCODE GCGcolUpdateMastercuts( - GCG_COL* gcgcol, /**< gcg column structure */ - SCIP_Real* newmastercuts, /**< pointer to new array of master cut coefficients */ - int nnewmastercuts /**< new number of master cut coefficients */ - ); - -/** gets the age of the col */ -extern -int GCGcolGetAge( - GCG_COL* col /**< col */ - ); - -/** returns whether the col's age exceeds the age limit */ -extern -SCIP_Bool GCGcolIsAged( - GCG_COL* col, /**< col to check */ - int agelimit /**< maximum age a col can reach before it is deleted from the pool, or -1 */ - ); - -/** compute parallelism of column to dual objective */ -SCIP_Real GCGcolComputeDualObjPara( - SCIP* scip, /**< SCIP data structure */ - GCG_COL* gcgcol /**< gcg column */ - ); - -/** compute orthogonality of two gcg columns */ -extern -SCIP_Real GCGcolComputeOrth( - SCIP* scip, /**< SCIP data structure */ - GCG_COL* gcgcol1, /**< first gcg column */ - GCG_COL* gcgcol2 /**< second gcg column */ - ); - -/**@} */ - -#ifdef __cplusplus -} -#endif -#endif diff --git a/headers/gcg/pub_gcgheur.h b/headers/gcg/pub_gcgheur.h deleted file mode 100644 index 96c9de7..0000000 --- a/headers/gcg/pub_gcgheur.h +++ /dev/null @@ -1,68 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* */ -/* This file is part of the program */ -/* GCG --- Generic Column Generation */ -/* a Dantzig-Wolfe decomposition based extension */ -/* of the branch-cut-and-price framework */ -/* SCIP --- Solving Constraint Integer Programs */ -/* */ -/* Copyright (C) 2010-2022 Operations Research, RWTH Aachen University */ -/* Zuse Institute Berlin (ZIB) */ -/* */ -/* This program is free software; you can redistribute it and/or */ -/* modify it under the terms of the GNU Lesser General Public License */ -/* as published by the Free Software Foundation; either version 3 */ -/* of the License, or (at your option) any later version. */ -/* */ -/* This program is distributed in the hope that it will be useful, */ -/* but WITHOUT ANY WARRANTY; without even the implied warranty of */ -/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ -/* GNU Lesser General Public License for more details. */ -/* */ -/* You should have received a copy of the GNU Lesser General Public License */ -/* along with this program; if not, write to the Free Software */ -/* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.*/ -/* */ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -/**@file pub_gcgheur.h - * @ingroup PUBLICCOREAPI - * @brief public methods for GCG heuristics - * @author Christian Puchert - */ - -/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/ - -#ifndef GCG_PUB_GCGHEUR_H__ -#define GCG_PUB_GCGHEUR_H__ - - -#include "scip/scip.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @ingroup HEURISTICS - * @{ - */ - -/** sets heuristic parameters values to - * - * - SCIP_PARAMSETTING_DEFAULT which are the default values of all heuristic parameters - * - SCIP_PARAMSETTING_FAST such that the time spent for heuristic is decreased - * - SCIP_PARAMSETTING_AGGRESSIVE such that the heuristic are called more aggressively - * - SCIP_PARAMSETTING_OFF which turns off all heuristics - */ -SCIP_RETCODE GCGsetHeuristics( - SCIP* scip, /**< SCIP data structure */ - SCIP_PARAMSETTING paramsetting /**< parameter settings */ - ); - -#ifdef __cplusplus -} - -#endif -/** @} */ -#endif diff --git a/headers/gcg/pub_gcgpqueue.h b/headers/gcg/pub_gcgpqueue.h deleted file mode 100644 index e58716b..0000000 --- a/headers/gcg/pub_gcgpqueue.h +++ /dev/null @@ -1,136 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* */ -/* This file is part of the program */ -/* GCG --- Generic Column Generation */ -/* a Dantzig-Wolfe decomposition based extension */ -/* of the branch-cut-and-price framework */ -/* SCIP --- Solving Constraint Integer Programs */ -/* */ -/* Copyright (C) 2010-2022 Operations Research, RWTH Aachen University */ -/* Zuse Institute Berlin (ZIB) */ -/* */ -/* This program is free software; you can redistribute it and/or */ -/* modify it under the terms of the GNU Lesser General Public License */ -/* as published by the Free Software Foundation; either version 3 */ -/* of the License, or (at your option) any later version. */ -/* */ -/* This program is distributed in the hope that it will be useful, */ -/* but WITHOUT ANY WARRANTY; without even the implied warranty of */ -/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ -/* GNU Lesser General Public License for more details. */ -/* */ -/* You should have received a copy of the GNU Lesser General Public License */ -/* along with this program; if not, write to the Free Software */ -/* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.*/ -/* */ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -/**@file pub_decomp.h - * @ingroup PUBLICCOREAPI - * @ingroup DATASTRUCTURES - * @brief public methods for working with priority queues - * @author Jonas Witt - */ - -/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/ -#ifndef GCG_PUB_GCGPQUEUE_H__ -#define GCG_PUB_GCGPQUEUE_H__ - -#include "scip/type_scip.h" -#include "scip/type_retcode.h" -#include "scip/type_var.h" -#include "scip/type_cons.h" -#include "scip/type_misc.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/* - * Priority Queue - */ - -/**@defgroup PriorityQueue Priority Queue - * @ingroup DATASTRUCTURES - * @{ - */ - -/** creates priority queue */ -SCIP_EXPORT -SCIP_RETCODE GCGpqueueCreate( - SCIP* scip, /** SCIP data structure */ - GCG_PQUEUE** pqueue, /**< pointer to a priority queue */ - int initsize, /**< initial number of available element slots */ - SCIP_DECL_SORTPTRCOMP((*ptrcomp)) /**< data element comparator */ - ); - -/** frees priority queue, but not the data elements themselves */ -SCIP_EXPORT -void GCGpqueueFree( - GCG_PQUEUE** pqueue /**< pointer to a priority queue */ - ); - -/** clears the priority queue, but doesn't free the data elements themselves */ -SCIP_EXPORT -void GCGpqueueClear( - GCG_PQUEUE* pqueue /**< priority queue */ - ); - -/** inserts element into priority queue */ -SCIP_EXPORT -SCIP_RETCODE GCGpqueueInsert( - GCG_PQUEUE* pqueue, /**< priority queue */ - void* elem /**< element to be inserted */ - ); - -/** removes and returns best element from the priority queue */ -SCIP_EXPORT -void* GCGpqueueRemove( - GCG_PQUEUE* pqueue /**< priority queue */ - ); - -/** resorts priority queue after changing the key values */ -SCIP_EXPORT -SCIP_RETCODE GCGpqueueResort( - GCG_PQUEUE* pqueue /**< priority queue */ - ); - -/** set the comperator of the priority queue */ -SCIP_RETCODE GCGpqueueSetComperator( - GCG_PQUEUE* pqueue, /**< priority queue */ - SCIP_DECL_SORTPTRCOMP((*ptrcomp)) /**< data element comparator */ - ); - -/**< delete item at position pos and insert last item at this position and resort pqueue */ -extern -SCIP_RETCODE GCGpqueueDelete( - GCG_PQUEUE* pqueue, /**< priority queue */ - int pos, /**< position of item that should be deleted */ - void** elem /**< pointer to store element that was deleted from pqueue */ -); - -/** returns the best element of the queue without removing it */ -SCIP_EXPORT -void* GCGpqueueFirst( - GCG_PQUEUE* pqueue /**< priority queue */ - ); - -/** returns the number of elements in the queue */ -SCIP_EXPORT -int GCGpqueueNElems( - GCG_PQUEUE* pqueue /**< priority queue */ - ); - -/** returns the elements of the queue; changing the returned array may destroy the queue's ordering! */ -SCIP_EXPORT -void** GCGpqueueElems( - GCG_PQUEUE* pqueue /**< priority queue */ - ); - -/**@} */ - - -#ifdef __cplusplus -} -#endif -#endif diff --git a/headers/gcg/pub_gcgsepa.h b/headers/gcg/pub_gcgsepa.h deleted file mode 100644 index 8494d3d..0000000 --- a/headers/gcg/pub_gcgsepa.h +++ /dev/null @@ -1,69 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* */ -/* This file is part of the program */ -/* GCG --- Generic Column Generation */ -/* a Dantzig-Wolfe decomposition based extension */ -/* of the branch-cut-and-price framework */ -/* SCIP --- Solving Constraint Integer Programs */ -/* */ -/* Copyright (C) 2010-2022 Operations Research, RWTH Aachen University */ -/* Zuse Institute Berlin (ZIB) */ -/* */ -/* This program is free software; you can redistribute it and/or */ -/* modify it under the terms of the GNU Lesser General Public License */ -/* as published by the Free Software Foundation; either version 3 */ -/* of the License, or (at your option) any later version. */ -/* */ -/* This program is distributed in the hope that it will be useful, */ -/* but WITHOUT ANY WARRANTY; without even the implied warranty of */ -/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ -/* GNU Lesser General Public License for more details. */ -/* */ -/* You should have received a copy of the GNU Lesser General Public License */ -/* along with this program; if not, write to the Free Software */ -/* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.*/ -/* */ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -/**@file pub_gcgsepa.h - * @ingroup PUBLICCOREAPI - * @brief public methods for GCG separators - * @author Christian Puchert - * @author Jonas Witt - */ - -/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/ - -#ifndef GCG_PUB_GCGSEPA_H__ -#define GCG_PUB_GCGSEPA_H__ - - -#include "scip/scip.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @ingroup SEPARATORS_PUB - * @{ - */ - -/** sets separator parameters values to - * - * - SCIP_PARAMSETTING_DEFAULT which are the default values of all separator parameters - * - SCIP_PARAMSETTING_FAST such that the time spent for separator is decreased - * - SCIP_PARAMSETTING_AGGRESSIVE such that the separator are called more aggressively - * - SCIP_PARAMSETTING_OFF which turns off all separators - */ -SCIP_RETCODE GCGsetSeparators( - SCIP* scip, /**< SCIP data structure */ - SCIP_PARAMSETTING paramsetting /**< parameter settings */ - ); - -#ifdef __cplusplus -} - -#endif -/** @} */ -#endif diff --git a/headers/gcg/pub_gcgvar.h b/headers/gcg/pub_gcgvar.h deleted file mode 100644 index 71ec73b..0000000 --- a/headers/gcg/pub_gcgvar.h +++ /dev/null @@ -1,668 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* */ -/* This file is part of the program */ -/* GCG --- Generic Column Generation */ -/* a Dantzig-Wolfe decomposition based extension */ -/* of the branch-cut-and-price framework */ -/* SCIP --- Solving Constraint Integer Programs */ -/* */ -/* Copyright (C) 2010-2022 Operations Research, RWTH Aachen University */ -/* Zuse Institute Berlin (ZIB) */ -/* */ -/* This program is free software; you can redistribute it and/or */ -/* modify it under the terms of the GNU Lesser General Public License */ -/* as published by the Free Software Foundation; either version 3 */ -/* of the License, or (at your option) any later version. */ -/* */ -/* This program is distributed in the hope that it will be useful, */ -/* but WITHOUT ANY WARRANTY; without even the implied warranty of */ -/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ -/* GNU Lesser General Public License for more details. */ -/* */ -/* You should have received a copy of the GNU Lesser General Public License */ -/* along with this program; if not, write to the Free Software */ -/* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.*/ -/* */ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -/**@file pub_gcgvar.h - * @ingroup PUBLICCOREAPI - * @brief public methods for GCG variables - * @author Martin Bergner - * @author Christian Puchert - */ - -/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/ - -#ifndef GCG_PUB_GCGVAR_H__ -#define GCG_PUB_GCGVAR_H__ - -#include "type_decomp.h" -#include "scip/scip.h" -#include "struct_vardata.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @ingroup TYPEDEFINITIONS - * - * @{ - */ - -/** returns TRUE or FALSE whether variable is a pricing variable or not */ -extern -SCIP_Bool GCGvarIsPricing( - SCIP_VAR* var /**< SCIP variable structure */ - ); - -#ifdef NDEBUG -#define GCGvarIsOriginal(var) (SCIPvarGetData(var)->vartype == GCG_VARTYPE_ORIGINAL) -#else -/** returns TRUE or FALSE whether variable is a original variable or not */ -extern -SCIP_Bool GCGvarIsOriginal( - SCIP_VAR* var /**< SCIP variable structure */ - ); -#endif - -#ifdef NDEBUG -#define GCGvarIsMaster(var) (SCIPvarGetData(var)->vartype == GCG_VARTYPE_MASTER) -#else -/** returns TRUE or FALSE whether variable is a master variable or not */ -extern -SCIP_Bool GCGvarIsMaster( - SCIP_VAR* var /**< SCIP variable structure */ - ); -#endif - -#ifdef NDEBUG -#define GCGoriginalVarIsLinking(var) (SCIPvarGetData(var)->blocknr == -2) -#else -/** returns TRUE or FALSE whether variable is a linking variable or not */ -extern -SCIP_Bool GCGoriginalVarIsLinking( - SCIP_VAR* var /**< SCIP variable structure */ - ); -#endif - -#ifdef NDEBUG -#define GCGoriginalVarIsTransVar(var) (SCIPvarGetData(var)->blocknr == -1) -#else -/** returns TRUE or FALSE whether variable is a directly transferred variable or not */ -extern -SCIP_Bool GCGoriginalVarIsTransVar( - SCIP_VAR* var /**< SCIP variable structure */ - ); -#endif - -#ifdef NDEBUG -#define GCGpricingVarGetOriginalVar(var) (SCIPvarGetData(var)->data.pricingvardata.origvars[0]) -#else -/** returns the original var of a pricing variable */ -extern -SCIP_VAR* GCGpricingVarGetOriginalVar( - SCIP_VAR* var /**< SCIP variable structure */ - ); -#endif - -/** adds the original var to the pricing variable */ -extern -SCIP_RETCODE GCGpricingVarAddOrigVar( - SCIP* scip, /**< SCIP variable structure */ - SCIP_VAR* pricingvar, /**< pricing variable */ - SCIP_VAR* origvar /**< original pricing variable */ - ); - -#ifdef NDEBUG -#define GCGoriginalVarGetPricingVar(var) (SCIPvarGetData(var)->data.origvardata.pricingvar) -#else -/** returns the pricing var of an original variable */ -extern -SCIP_VAR* GCGoriginalVarGetPricingVar( - SCIP_VAR* var /**< variable data structure */ - ); -#endif - -/** returns the pricing var of an original variable */ -extern -void GCGoriginalVarSetPricingVar( - SCIP_VAR* var, /**< SCIP variable structure */ - SCIP_VAR* pricingvar /**< SCIP variable structure */ - ); - -/** copies the pricing variable data to a master problem variable. This is used in the Benders' decomposition mode when - * subproblems are merged into the master problem. - */ -extern -SCIP_RETCODE GCGcopyPricingvarDataToMastervar( - SCIP* scip, /**< master SCIP data structure */ - SCIP_VAR* pricingvar, /**< the pricing problem variable is copied from */ - SCIP_VAR* mastervar /**< the master variable that the vardata is copied to */ - ); - -#ifdef NDEBUG -#define GCGlinkingVarGetPricingVars(var) (SCIPvarGetData(var)->data.origvardata.linkingvardata->pricingvars) -#else -/** returns the pricing variables of an linking variable */ -extern -SCIP_VAR** GCGlinkingVarGetPricingVars( - SCIP_VAR* var /**< SCIP variable structure */ - ); -#endif - -/** sets the pricing var of the corresponding linking variable at the specified position */ -extern -void GCGlinkingVarSetPricingVar( - SCIP_VAR* origvar, /**< original variable */ - int pricingprobnr, /**< number of pricing problem */ - SCIP_VAR* var /**< pricing variable */ - ); - -#ifdef NDEBUG -#define GCGoriginalVarGetNMastervars(var) (SCIPvarGetData(var)->data.origvardata.nmastervars) -#else -/** returns the number of master variables the original variable is contained in */ -extern -int GCGoriginalVarGetNMastervars( - SCIP_VAR* var /**< variable data structure */ - ); -#endif - -#ifdef NDEBUG -#define GCGoriginalVarGetMastervars(var) (SCIPvarGetData(var)->data.origvardata.mastervars) -#else -/** returns the master variables the original variable is contained in */ -extern -SCIP_VAR** GCGoriginalVarGetMastervars( - SCIP_VAR* var /**< variable data structure */ - ); -#endif - -#ifdef NDEBUG -#define GCGoriginalVarGetMastervals(var) (SCIPvarGetData(var)->data.origvardata.mastervals) -#else -/** returns the fraction of master variables the original variable is contained in */ -extern -SCIP_Real* GCGoriginalVarGetMastervals( - SCIP_VAR* var /**< variable data structure */ - ); -#endif - -#ifdef NDEBUG -#define GCGoriginalVarGetCoefs(var) (SCIPvarGetData(var)->data.origvardata.coefs) -#else -/** returns the fraction of master variables the original variable is contained in */ -extern -SCIP_Real* GCGoriginalVarGetCoefs( - SCIP_VAR* var /**< variable data structure */ - ); -#endif - -#ifdef NDEBUG -#define GCGoriginalVarGetMasterconss(var) (SCIPvarGetData(var)->data.origvardata.masterconss) -#else -/** returns the fraction of master variables the original variable is contained in */ -extern -SCIP_CONS** GCGoriginalVarGetMasterconss( - SCIP_VAR* var /**< variable data structure */ - ); -#endif - -/** adds a coefficient of the master variable to the coefs array for the resp. constraint */ -extern -SCIP_RETCODE GCGoriginalVarAddCoef( - SCIP* scip, /**< SCIP data structure */ - SCIP_VAR* var, /**< variable to add coef */ - SCIP_Real val, /**< coefficent to set */ - SCIP_CONS* cons /**< constraint the variable is in */ - ); - -/** adds variable to a new block, making a linkingvariable out of it, if necessary */ -extern -SCIP_RETCODE GCGoriginalVarAddBlock( - SCIP* scip, /**< SCIP data structure */ - SCIP_VAR* var, /**< var that is added to a block */ - int newblock, /**< the new block the variable will be in */ - int nblocks, /**< total number of pricing problems */ - DEC_DECMODE mode /**< the decomposition mode */ - ); - -#ifdef NDEBUG -#define GCGlinkingVarGetLinkingConss(var) (SCIPvarGetData(var)->data.origvardata.linkingvardata->linkconss) -#else -/** returns the linking constraints */ -extern -SCIP_CONS** GCGlinkingVarGetLinkingConss( - SCIP_VAR* var /**< variable data structure */ - ); -#endif - -/** sets the linking constraints*/ -extern -void GCGlinkingVarSetLinkingCons( - SCIP_VAR* var, /**< variable data structure */ - SCIP_CONS* cons, /**< linking constraint */ - int index /**< index of pricing problem */ - ); - -/** returns the blocks the linking variable is in */ -extern -SCIP_RETCODE GCGlinkingVarGetBlocks( - SCIP_VAR* var, /**< SCIP variable structure */ - int nblocks, /**< number of blocks the linking variable is in */ - int* blocks /**< array to store the blocks of the linking variable */ - ); - -#ifdef NDEBUG -#define GCGlinkingVarGetNBlocks(var) (SCIPvarGetData(var)->data.origvardata.linkingvardata->nblocks) -#else -/** returns the number of blocks the linking variable is in */ -extern -int GCGlinkingVarGetNBlocks( - SCIP_VAR* var /**< SCIP variable structure */ - ); -#endif - -#ifdef NDEBUG -#define GCGoriginalVarGetNCoefs(var) (SCIPvarGetData(var)->data.origvardata.ncoefs) -#else -/** returns the number of coefficients of master constraints the original variable is contained in */ -extern -int GCGoriginalVarGetNCoefs( - SCIP_VAR* var /**< SCIP variable structure */ - ); -#endif - -/** sets the number of master variables the original variable is contained in */ -extern -void GCGoriginalVarSetNCoefs( - SCIP_VAR* var, /**< SCIP variable structure */ - int coef /**< number of coefficient to set */ - ); - -/** returns TRUE or FALSE whether a master variable is a direct copy of a linking variable or not */ -extern -SCIP_Bool GCGmasterVarIsLinking( - SCIP_VAR* var /**< variable data structure */ - ); - -/** returns scip instance corresponding to master variable */ -extern -SCIP* GCGmasterVarGetProb( - SCIP_VAR* var /**< variable data structure */ - ); - -#ifdef NDEBUG -#define GCGmasterVarIsRay(var) (SCIPvarGetData(var)->data.mastervardata.isray) -#else -/** returns whether the master variable is a ray */ -extern -SCIP_Bool GCGmasterVarIsRay( - SCIP_VAR* var /**< variable data structure */ - ); -#endif - -#ifdef NDEBUG -#define GCGmasterVarIsArtificial(var) (SCIPvarGetData(var)->data.mastervardata.isartificial) -#else -/** returns TRUE or FALSE whether a master variable is an artificial variable */ -extern -SCIP_Bool GCGmasterVarIsArtificial( - SCIP_VAR* var /**< variable data structure */ - ); -#endif - -#ifdef NDEBUG -#define GCGmasterVarGetNOrigvars(var) (SCIPvarGetData(var)->data.mastervardata.norigvars) -#else -/** returns the number of original variables the master variable is contained in */ -extern -int GCGmasterVarGetNOrigvars( - SCIP_VAR* var /**< variable data structure */ - ); -#endif - -#ifdef NDEBUG -#define GCGmasterVarGetOrigvars(var) (SCIPvarGetData(var)->data.mastervardata.origvars) -#else -/** returns the original variables the master variable is contained in */ -extern -SCIP_VAR** GCGmasterVarGetOrigvars( - SCIP_VAR* var /**< variable data structure */ - ); -#endif - -#ifdef NDEBUG -#define GCGmasterVarGetOrigvals(var) (SCIPvarGetData(var)->data.mastervardata.origvals) -#else -/** returns the fraction of original variables the master variable is contained in */ -extern -SCIP_Real* GCGmasterVarGetOrigvals( - SCIP_VAR* var /**< variable data structure */ - ); -#endif - -/** returns the fraction of the original variable the master variable is contained in */ -extern -SCIP_Real GCGmasterVarGetOrigval( - SCIP_VAR* mastervar, /**< master variable data structure */ - SCIP_VAR* origvar /**< original variable data structure */ -); - -#ifdef NDEBUG -#define GCGmasterVarGetOrigvalmap(var) (SCIPvarGetData(var)->data.mastervardata.origvar2val) -#else -/** returns a hash map that stores the fraction of original variables the master variable is contained in */ -extern -SCIP_HASHMAP* GCGmasterVarGetOrigvalmap( - SCIP_VAR* var /**< master variable data structure */ -); -#endif - -#ifdef NDEBUG -#define GCGpricingVarGetNOrigvars(var) (SCIPvarGetData(var)->data.pricingvardata.norigvars) -#else -/** returns the number of original variables the pricing variable is contained in */ -extern -int GCGpricingVarGetNOrigvars( - SCIP_VAR* var /**< variable data structure */ - ); -#endif - -#ifdef NDEBUG -#define GCGpricingVarGetOrigvars(var) (SCIPvarGetData(var)->data.pricingvardata.origvars) -#else -/** returns the original variables the pricing variable is contained in */ -extern -SCIP_VAR** GCGpricingVarGetOrigvars( - SCIP_VAR* var /**< variable data structure */ - ); -#endif - -#ifdef NDEBUG -#define GCGvarGetBlock(var) (SCIPvarGetData(var)->blocknr) -#else -/** returns the block of the variable */ -extern -int GCGvarGetBlock( - SCIP_VAR* var /**< variable data structure */ - ); -#endif - -/** sets the block of the variable */ -extern -void GCGvarSetBlock( - SCIP_VAR* var, /**< variable to set block for */ - int block /**< block to set */ - ); - -/** creates the data for all variables of the original program */ -extern -SCIP_RETCODE GCGcreateOrigVarsData( - SCIP* scip /**< SCIP data structure */ - ); - -/** frees the data for all variables of the original program */ -extern -SCIP_RETCODE GCGfreeOrigVarsData( - SCIP* scip /**< SCIP data structure */ - ); - -/** creates the data for a variable of the original program */ -extern -SCIP_RETCODE GCGorigVarCreateData( - SCIP* scip, /**< SCIP data structure */ - SCIP_VAR* var /**< pointer to variable object */ - ); - -#ifdef NDEBUG -#define GCGisLinkingVarInBlock(var, block) (GCGlinkingVarGetPricingVars(var)[block] != NULL) -#else -/** returns TRUE if the linking variable is in the block, FALSE otherwise */ -extern -SCIP_Bool GCGisLinkingVarInBlock( - SCIP_VAR* var, /**< variable data structure */ - int block /**< pricing problem number */ - ); -#endif - -/** determines if the master variable is in the given block */ -extern -SCIP_Bool GCGisMasterVarInBlock( - SCIP_VAR* mastervar, /**< master variable */ - int blocknr /**< block number to check */ - ); - -/** informs an original variable, that a variable in the master problem was created, - * that contains a part of the original variable. - * Saves this information in the original variable's data - */ -extern -SCIP_RETCODE GCGoriginalVarAddMasterVar( - SCIP* scip, /**< SCIP data structure */ - SCIP_VAR* origvar, /**< original variable */ - SCIP_VAR* var, /**< master variable */ - SCIP_Real val /**< fraction of the original variable */ - ); - -/* informs an original variable, that a variable in the master problem was deleted, - * that contains a part of the original variable. - * Update the information in the original variable's data - */ -extern -SCIP_RETCODE GCGoriginalVarRemoveMasterVar( - SCIP* scip, /**< SCIP data structure */ - SCIP_VAR* origvar, /**< original variable */ - SCIP_VAR* var /**< master variable */ - ); - - -/** creates the corresponding pricing variable for the given original variable */ -extern -SCIP_RETCODE GCGoriginalVarCreatePricingVar( - SCIP* scip, /**< SCIP data structure */ - SCIP_VAR* origvar, /**< original variable */ - SCIP_VAR** var /**< pricing variable */ - ); - -/** creates the corresponding pricing variable for the given original variable */ -extern -SCIP_RETCODE GCGlinkingVarCreatePricingVar( - SCIP* pricingscip, /**< pricing problem SCIP data structure */ - int pricingprobnr, /**< number of the pricing problem */ - SCIP_VAR* origvar, /**< original variable */ - SCIP_VAR** var /**< pointer to store new pricing variable */ - ); - -/** creates the corresponding constraint in the master problem for the linking variable */ -extern -SCIP_RETCODE GCGlinkingVarCreateMasterCons( - SCIP* masterscip, /**< master problem SCIP data structure */ - int pricingprobnr, /**< number of the pricing problem */ - SCIP_VAR* origvar, /**< original variable */ - SCIP_CONS** linkcons /**< constraint linking pricing variables */ - ); - -/** creates the master var and initializes the vardata */ -extern -SCIP_RETCODE GCGcreateMasterVar( - SCIP* scip, /**< SCIP data structure */ - SCIP* origscip, /**< original SCIP data structure */ - SCIP* pricingscip, /**< pricing problem SCIP data structure */ - SCIP_VAR** newvar, /**< pointer to store new master variable */ - const char* varname, /**< new variable name */ - SCIP_Real objcoeff, /**< new objective coeffient */ - SCIP_VARTYPE vartype, /**< new variable type */ - SCIP_Bool solisray, /**< indicates whether new variable is a ray */ - int prob, /**< number of pricing problem that created this variable */ - int nsolvars, /**< number of variables in the solution */ - SCIP_Real* solvals, /**< values of variables in the solution */ - SCIP_VAR** solvars, /**< variables with non zero coefficient in the solution */ - SCIP_Bool auxiliaryvar /**< is new variable an Benders' auxiliary variables? */ - ); - -/** creates initial master variables and the vardata */ -SCIP_RETCODE GCGcreateInitialMasterVar( - SCIP* scip, /**< SCIP data structure */ - SCIP_VAR* var, /**< original variable */ - SCIP_VAR** newvar /**< pointer to store new variable */ - ); - -/** creates artificial variable and the vardata */ -SCIP_RETCODE GCGcreateArtificialVar( - SCIP* scip, /**< SCIP data structure */ - SCIP_VAR** newvar, /**< pointer to store new variable */ - const char* name, /**< name of variable, or NULL for automatic name creation */ - SCIP_Real objcoef /**< objective coefficient of artificial variable */ - ); - -/* adds the vardata to the auxiliary variable */ -extern -SCIP_RETCODE GCGaddDataAuxiliaryVar( - SCIP* scip, /**< SCIP data structure */ - SCIP_VAR* auxiliaryvar, /**< the auxiliary variable */ - int probnumber /**< the subproblem number */ - ); - -/** sets the creation node of this var */ -extern -void GCGsetCreationNode( - SCIP_VAR* var, /**< created variable */ - SCIP_Longint creationNode /**< node */ - ); - -#ifdef NDEBUG -#define GCGgetCreationNode(var) (SCIPvarGetData(var)->creationnode) -#else -/** returns the creation node of this var */ -extern -long long int GCGgetCreationNode( - SCIP_VAR* var /**< created variable */ - ); -#endif - -/** sets the creation time of this var */ -extern -void GCGsetCreationTime( - SCIP_VAR* var, /**< created variable */ - SCIP_Real time /**< creation time */ - ); - -#ifdef NDEBUG -#define GCGgetCreationTime(var) (SCIPvarGetData(var)->creationtime) -#else -/** returns the creation time of this var */ -extern -SCIP_Real GCGgetCreationTime( - SCIP_VAR* var /**< created variable */ - ); -#endif - -/** store pricing reduced cost call */ -extern -void GCGsetRootRedcostCall( - SCIP_VAR* var, /**< variable data structure */ - SCIP_Longint rootredcostcall /**< iteration at which the variable is created */ - ); - -#ifdef NDEBUG -#define GCGgetRootRedcostCall(var) (SCIPvarGetData(var)->rootredcostcall) -#else -/** return stored pricing reduced cost call */ -extern -SCIP_Longint GCGgetRootRedcostCall( - SCIP_VAR* var /**< variable data structure */ - ); -#endif - -#ifdef NDEBUG -#define GCGgetIteration(var) (SCIPvarGetData(var)->iteration) -#else -/** returns the iteration when the var was created */ -extern -SCIP_Longint GCGgetIteration( - SCIP_VAR* var /**< created variable */ - ); -#endif - -/** sets the iteration when the var was created */ -extern -void GCGsetIteration( - SCIP_VAR* var, /**< created variable */ - SCIP_Longint iteration /**< iteration that this var was created */ - ); - -/** store gap */ -void GCGsetVarGap( - SCIP_VAR* var, /**< variable data structure */ - SCIP_Real gap /**< present gap when variable is created */ - ); - -#ifdef NDEBUG -#define GCGgetVarGap(var) (SCIPvarGetData(var)->gap) -#else -/** return stored gap */ -SCIP_Real GCGgetVarGap( - SCIP_VAR* var /**< variable data structure */ - ); -#endif - -/** store reduced cost */ -void GCGsetRedcost( - SCIP* scip, /**< SCIP data structure */ - SCIP_VAR* var, /**< variable data structure */ - SCIP_Real redcost /**< reduced cost of the variable at creation */ - ); - -#ifdef NDEBUG -#define GCGgetRedcost(var) (SCIPvarGetData(var)->redcost) -#else -/** return stored reduced cost */ -SCIP_Real GCGgetRedcost( - SCIP_VAR* var /**< variable data structure */ - ); -#endif - -/** updates the statistics part of the variable */ -void GCGupdateVarStatistics( - SCIP* scip, /**< master SCIP data structure */ - SCIP* origprob, /**< original SCIP data structure */ - SCIP_VAR* newvar, /**< new variable for statistic update */ - SCIP_Real redcost /**< reduced cost of the variable */ - ); - -/** prints the given variable: name, type (original, master or pricing) block number, - * and the list of all variables related to the given variable */ -extern -void GCGprintVar( - SCIP* scip, /**< SCIP data structure */ - FILE* file, /**< File to write information to, or NULL for stdout */ - SCIP_VAR* var /**< variable that should be printed */ - ); - -#ifdef NDEBUG -#define GCGmasterVarGetIndex(var) (SCIPvarGetData(var)->data.mastervardata.index) -#else -/** returns the index of the mater variable */ -extern -int GCGmasterVarGetIndex( - SCIP_VAR* var /**< SCIP variable structure */ - ); -#endif - -/** sets the index of the master variable */ -extern -void GCGmasterVarSetIndex( - SCIP_VAR* var, /**< SCIP variable structure */ - int index /**< index */ - ); - -#ifdef __cplusplus -} - - -#endif -/** @} */ -#endif diff --git a/headers/gcg/pub_pricingjob.h b/headers/gcg/pub_pricingjob.h deleted file mode 100644 index d9d3bc8..0000000 --- a/headers/gcg/pub_pricingjob.h +++ /dev/null @@ -1,96 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* */ -/* This file is part of the program */ -/* GCG --- Generic Column Generation */ -/* a Dantzig-Wolfe decomposition based extension */ -/* of the branch-cut-and-price framework */ -/* SCIP --- Solving Constraint Integer Programs */ -/* */ -/* Copyright (C) 2010-2022 Operations Research, RWTH Aachen University */ -/* Zuse Institute Berlin (ZIB) */ -/* */ -/* This program is free software; you can redistribute it and/or */ -/* modify it under the terms of the GNU Lesser General Public License */ -/* as published by the Free Software Foundation; either version 3 */ -/* of the License, or (at your option) any later version. */ -/* */ -/* This program is distributed in the hope that it will be useful, */ -/* but WITHOUT ANY WARRANTY; without even the implied warranty of */ -/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ -/* GNU Lesser General Public License for more details. */ -/* */ -/* You should have received a copy of the GNU Lesser General Public License */ -/* along with this program; if not, write to the Free Software */ -/* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.*/ -/* */ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -/**@file pub_pricingjob.h - * @ingroup PUBLICCOREAPI - * @brief public methods for working with pricing jobs - * @author Christian Puchert - */ - -/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/ -#ifndef GCG_PUB_PRICINGJOB_H__ -#define GCG_PUB_PRICINGJOB_H__ - -#include "type_pricingjob.h" -#include "scip/type_scip.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/* - * GCG Pricing Job - */ - -/** - * @ingroup PRICINGJOB - * - * @{ - */ - - -/** get the pricing problem structure associated with a pricing job */ -SCIP_EXPORT -GCG_PRICINGPROB* GCGpricingjobGetPricingprob( - GCG_PRICINGJOB* pricingjob /**< pricing job */ - ); - -/** get the pricing solver with which the pricing job is to be performed */ -SCIP_EXPORT -GCG_SOLVER* GCGpricingjobGetSolver( - GCG_PRICINGJOB* pricingjob /**< pricing job */ - ); - -/** get the chunk of a pricing job */ -SCIP_EXPORT -SCIP_Real GCGpricingjobGetChunk( - GCG_PRICINGJOB* pricingjob /**< pricing job */ - ); - -/** get the score of a pricing job */ -SCIP_EXPORT -SCIP_Real GCGpricingjobGetScore( - GCG_PRICINGJOB* pricingjob /**< pricing job */ - ); - -/** return whether the pricing job is to be performed heuristically */ -SCIP_EXPORT -SCIP_Bool GCGpricingjobIsHeuristic( - GCG_PRICINGJOB* pricingjob /**< pricing job */ - ); - -/** get the number of heuristic pricing iterations of the pricing job */ -SCIP_EXPORT -int GCGpricingjobGetNHeurIters( - GCG_PRICINGJOB* pricingjob /**< pricing job */ - ); - -/**@} */ -#ifdef __cplusplus -} -#endif -#endif diff --git a/headers/gcg/pub_pricingprob.h b/headers/gcg/pub_pricingprob.h deleted file mode 100644 index 16bbee7..0000000 --- a/headers/gcg/pub_pricingprob.h +++ /dev/null @@ -1,136 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* */ -/* This file is part of the program */ -/* GCG --- Generic Column Generation */ -/* a Dantzig-Wolfe decomposition based extension */ -/* of the branch-cut-and-price framework */ -/* SCIP --- Solving Constraint Integer Programs */ -/* */ -/* Copyright (C) 2010-2022 Operations Research, RWTH Aachen University */ -/* Zuse Institute Berlin (ZIB) */ -/* */ -/* This program is free software; you can redistribute it and/or */ -/* modify it under the terms of the GNU Lesser General Public License */ -/* as published by the Free Software Foundation; either version 3 */ -/* of the License, or (at your option) any later version. */ -/* */ -/* This program is distributed in the hope that it will be useful, */ -/* but WITHOUT ANY WARRANTY; without even the implied warranty of */ -/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ -/* GNU Lesser General Public License for more details. */ -/* */ -/* You should have received a copy of the GNU Lesser General Public License */ -/* along with this program; if not, write to the Free Software */ -/* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.*/ -/* */ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -/**@file pub_pricingprob.h - * @ingroup PUBLICCOREAPI - * @brief public methods for working with pricing problems - * @author Christian Puchert - */ - -/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/ -#ifndef GCG_PUB_PRICINGPROB_H__ -#define GCG_PUB_PRICINGPROB_H__ - -#include "type_pricingprob.h" -#include "scip/type_scip.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/* - * GCG Pricing Problem - */ - -/** - * @ingroup PRICINGPROB - * @{ - */ - - -/** get the SCIP instance corresponding to the pricing problem */ -SCIP_EXPORT -SCIP* GCGpricingprobGetPricingscip( - GCG_PRICINGPROB* pricingprob /**< pricing problem structure */ - ); - -/** get the index of the corresponding pricing problem */ -SCIP_EXPORT -int GCGpricingprobGetProbnr( - GCG_PRICINGPROB* pricingprob /**< pricing problem structure */ - ); - -/** get generic branching data corresponding to the pricing problem */ -SCIP_EXPORT -void GCGpricingprobGetGenericBranchData( - GCG_PRICINGPROB* pricingprob, /**< pricing problem structure */ - SCIP_CONS*** branchconss, /**< pointer to store branching constraints array, or NULL */ - SCIP_Real** branchduals, /**< pointer to store array of corresponding dual values, or NULL */ - int* nbranchconss /**< pointer to store number of generic branching constraints, or NULL */ - ); - -/** get the number of generic branching constraints corresponding to the pricing problem */ -SCIP_EXPORT -int GCGpricingprobGetNGenericBranchconss( - GCG_PRICINGPROB* pricingprob /**< pricing problem structure */ - ); - -/** get index of current generic branching constraint considered the pricing problem */ -SCIP_EXPORT -int GCGpricingprobGetBranchconsIdx( - GCG_PRICINGPROB* pricingprob /**< pricing problem structure */ - ); - -/** check if the current generic branching constraint has already been added */ -SCIP_EXPORT -SCIP_Bool GCGpricingprobBranchconsIsAdded( - GCG_PRICINGPROB* pricingprob /**< pricing problem structure */ - ); - -/** mark the current generic branching constraint to be added */ -SCIP_EXPORT -void GCGpricingprobMarkBranchconsAdded( - GCG_PRICINGPROB* pricingprob /**< pricing problem structure */ - ); - -/** get the status of a pricing problem */ -SCIP_EXPORT -GCG_PRICINGSTATUS GCGpricingprobGetStatus( - GCG_PRICINGPROB* pricingprob /**< pricing problem structure */ - ); - -/** get the lower bound of a pricing problem */ -SCIP_EXPORT -SCIP_Real GCGpricingprobGetLowerbound( - GCG_PRICINGPROB* pricingprob /**< pricing problem structure */ - ); - -/** get the number of improving columns found for this pricing problem */ -SCIP_EXPORT -int GCGpricingprobGetNImpCols( - GCG_PRICINGPROB* pricingprob /**< pricing problem structure */ - ); - -/** get the number of times the pricing problem was solved during the loop */ -SCIP_EXPORT -int GCGpricingprobGetNSolves( - GCG_PRICINGPROB* pricingprob /**< pricing problem structure */ - ); - -/** get the total number of improving colums found in the last pricing rounds */ -SCIP_EXPORT -int GCGpricingprobGetNColsLastRounds( - GCG_PRICINGPROB* pricingprob, /**< pricing problem structure */ - int nroundscol /**< number of previous pricing rounds for which the number of improving columns should be counted */ - ); - -/**@} */ - -#ifdef __cplusplus -} -#endif -#endif diff --git a/headers/gcg/pub_solver.h b/headers/gcg/pub_solver.h deleted file mode 100644 index b21f144..0000000 --- a/headers/gcg/pub_solver.h +++ /dev/null @@ -1,156 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* */ -/* This file is part of the program */ -/* GCG --- Generic Column Generation */ -/* a Dantzig-Wolfe decomposition based extension */ -/* of the branch-cut-and-price framework */ -/* SCIP --- Solving Constraint Integer Programs */ -/* */ -/* Copyright (C) 2010-2022 Operations Research, RWTH Aachen University */ -/* Zuse Institute Berlin (ZIB) */ -/* */ -/* This program is free software; you can redistribute it and/or */ -/* modify it under the terms of the GNU Lesser General Public License */ -/* as published by the Free Software Foundation; either version 3 */ -/* of the License, or (at your option) any later version. */ -/* */ -/* This program is distributed in the hope that it will be useful, */ -/* but WITHOUT ANY WARRANTY; without even the implied warranty of */ -/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ -/* GNU Lesser General Public License for more details. */ -/* */ -/* You should have received a copy of the GNU Lesser General Public License */ -/* along with this program; if not, write to the Free Software */ -/* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.*/ -/* */ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -/**@file solver.h - * @ingroup PUBLICCOREAPI - * @brief public methods for GCG pricing solvers - * @author Christian Puchert - */ - -/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/ - -#ifndef GCG_PUB_SOLVER_H_ -#define GCG_PUB_SOLVER_H_ - -#include "type_solver.h" -#include "scip/scip.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @ingroup PRICING_PUB - * @{ - */ - -/** compares two solvers w. r. t. their priorities */ -SCIP_EXPORT -SCIP_DECL_SORTPTRCOMP(GCGsolverComp); - -/** gets user data of GCG pricing solver */ -SCIP_EXPORT -GCG_SOLVERDATA* GCGsolverGetData( - GCG_SOLVER* solver /**< pricing solver */ - ); - -/** sets user data of GCG pricing solver */ -SCIP_EXPORT -void GCGsolverSetData( - GCG_SOLVER* solver, /**< pricing solver */ - GCG_SOLVERDATA* solverdata /**< pricing solver data */ - ); - -/** gets name of GCG pricing solver */ -SCIP_EXPORT -const char* GCGsolverGetName( - GCG_SOLVER* solver /**< pricing solver */ - ); - -/** gets description of GCG pricing solver */ -SCIP_EXPORT -const char* GCGsolverGetDesc( - GCG_SOLVER* solver /**< pricing solver */ - ); - -/** gets priority of GCG pricing solver */ -SCIP_EXPORT -int GCGsolverGetPriority( - GCG_SOLVER* solver /**< pricing solver */ - ); - -/** gets whether heuristic solving method of GCG pricing solver is enabled */ -SCIP_EXPORT -SCIP_Bool GCGsolverIsHeurEnabled( - GCG_SOLVER* solver /**< pricing solver */ - ); - -/** gets whether exact solving method of GCG pricing solver is enabled */ -SCIP_EXPORT -SCIP_Bool GCGsolverIsExactEnabled( - GCG_SOLVER* solver /**< pricing solver */ - ); - -/** gets number of exact Farkas pricing calls of pricing solver */ -SCIP_EXPORT -int GCGsolverGetOptFarkasCalls( - GCG_SOLVER* solver /**< pricing solver */ - ); - -/** gets number of exact reduced cost pricing calls of pricing solver */ -SCIP_EXPORT -int GCGsolverGetOptRedcostCalls( - GCG_SOLVER* solver /**< pricing solver */ - ); - -/** gets number of heuristic Farkas pricing calls of pricing solver */ -SCIP_EXPORT -int GCGsolverGetHeurFarkasCalls( - GCG_SOLVER* solver /**< pricing solver */ - ); - -/** gets number of heuristic reduced cost pricing calls of pricing solver */ -SCIP_EXPORT -int GCGsolverGetHeurRedcostCalls( - GCG_SOLVER* solver /**< pricing solver */ - ); - -/** gets exact Farkas pricing time of pricing solver */ -SCIP_EXPORT -SCIP_Real GCGsolverGetOptFarkasTime( - SCIP* scip, /**< SCIP data structure (master problem) */ - GCG_SOLVER* solver /**< pricing solver */ - ); - -/** gets exact reduced cost pricing time of pricing solver */ -SCIP_EXPORT -SCIP_Real GCGsolverGetOptRedcostTime( - SCIP* scip, /**< SCIP data structure (master problem) */ - GCG_SOLVER* solver /**< pricing solver */ - ); - -/** gets heuristic Farkas pricing time of pricing solver */ -SCIP_EXPORT -SCIP_Real GCGsolverGetHeurFarkasTime( - SCIP* scip, /**< SCIP data structure (master problem) */ - GCG_SOLVER* solver /**< pricing solver */ - ); - -/** gets heuristic reduced cost pricing time of pricing solver */ -SCIP_EXPORT -SCIP_Real GCGsolverGetHeurRedcostTime( - SCIP* scip, /**< SCIP data structure (master problem) */ - GCG_SOLVER* solver /**< pricing solver */ - ); - -/** @} */ -#ifdef __cplusplus -} - -#endif - -#endif diff --git a/headers/gcg/reader_blk.h b/headers/gcg/reader_blk.h deleted file mode 100644 index 54aa4d3..0000000 --- a/headers/gcg/reader_blk.h +++ /dev/null @@ -1,79 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* */ -/* This file is part of the program */ -/* GCG --- Generic Column Generation */ -/* a Dantzig-Wolfe decomposition based extension */ -/* of the branch-cut-and-price framework */ -/* SCIP --- Solving Constraint Integer Programs */ -/* */ -/* Copyright (C) 2010-2022 Operations Research, RWTH Aachen University */ -/* Zuse Institute Berlin (ZIB) */ -/* */ -/* This program is free software; you can redistribute it and/or */ -/* modify it under the terms of the GNU Lesser General Public License */ -/* as published by the Free Software Foundation; either version 3 */ -/* of the License, or (at your option) any later version. */ -/* */ -/* This program is distributed in the hope that it will be useful, */ -/* but WITHOUT ANY WARRANTY; without even the implied warranty of */ -/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ -/* GNU Lesser General Public License for more details. */ -/* */ -/* You should have received a copy of the GNU Lesser General Public License */ -/* along with this program; if not, write to the Free Software */ -/* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.*/ -/* */ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -/**@file reader_blk.h - * @brief BLK file reader for structure information - * @author Gerald Gamrath - * @author Martin Bergner - * @ingroup FILEREADERS - * - * This reader reads in a blk-file that defines the structur to be used for the decomposition. - * The structure is defined variable-wise, i.e., the number of blocks and the variables belonging to each block are - * defined. Afterwards, each constraint that has only variables of one block is added to that block, - * constraints having variables of more than one block go into the master. If needed, constraints can also be - * forced into the master, even if they could be transferred to one block. - * - * The keywords are: - * - Presolved: to be followed by either 0 or 1 indicating that the decomposition is for the presolved or unpresolved problem - * - NBlocks: to be followed by a line giving the number of blocks - * - Block i with 1 <= i <= nblocks: to be followed by the names of the variables belonging to block i, one per line. - * - Masterconss: to be followed by names of constraints, one per line, that should go into the master, - * even if they only contain variables of one block and could thus be added to this block. - */ - -/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/ - -#ifndef GCG_READER_BLK_H__ -#define GCG_READER_BLK_H__ - - -#include "scip/scip.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/** includes the blk file reader into SCIP */ -extern -SCIP_RETCODE SCIPincludeReaderBlk( - SCIP* scip /**< SCIP data structure */ - ); - - -/* reads problem from file */ -extern -SCIP_RETCODE SCIPreadBlk( - SCIP* scip, /**< SCIP data structure */ - const char* filename, /**< full path and name of file to read, or NULL if stdin should be used */ - SCIP_RESULT* result /**< pointer to store the result of the file reading call */ - ); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/headers/gcg/reader_cls.h b/headers/gcg/reader_cls.h deleted file mode 100644 index 4781c44..0000000 --- a/headers/gcg/reader_cls.h +++ /dev/null @@ -1,64 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* */ -/* This file is part of the program */ -/* GCG --- Generic Column Generation */ -/* a Dantzig-Wolfe decomposition based extension */ -/* of the branch-cut-and-price framework */ -/* SCIP --- Solving Constraint Integer Programs */ -/* */ -/* Copyright (C) 2010-2022 Operations Research, RWTH Aachen University */ -/* Zuse Institute Berlin (ZIB) */ -/* */ -/* This program is free software; you can redistribute it and/or */ -/* modify it under the terms of the GNU Lesser General Public License */ -/* as published by the Free Software Foundation; either version 3 */ -/* of the License, or (at your option) any later version. */ -/* */ -/* This program is distributed in the hope that it will be useful, */ -/* but WITHOUT ANY WARRANTY; without even the implied warranty of */ -/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ -/* GNU Lesser General Public License for more details. */ -/* */ -/* You should have received a copy of the GNU Lesser General Public License */ -/* along with this program; if not, write to the Free Software */ -/* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.*/ -/* */ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -/**@file reader_cls.h - * @brief CLS reader for writing files containing classification data - * @author Julius Hense - * @ingroup FILEREADERS - * - */ - -/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/ - -#ifndef GCG_READER_CLS_H__ -#define GCG_READER_CLS_H__ - -#include "scip/scip.h" -#include "type_decomp.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/** includes the cls file reader into SCIP */ -extern -SCIP_RETCODE SCIPincludeReaderCls( - SCIP* scip /**< SCIP data structure */ - ); - -/** write a CLS file for a given decomposition */ -SCIP_RETCODE GCGwriteCls( - SCIP* scip, /**< SCIP data structure */ - FILE* file /**< File pointer to write to */ - ); - - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/headers/gcg/reader_dec.h b/headers/gcg/reader_dec.h deleted file mode 100644 index cba8ef8..0000000 --- a/headers/gcg/reader_dec.h +++ /dev/null @@ -1,88 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* */ -/* This file is part of the program */ -/* GCG --- Generic Column Generation */ -/* a Dantzig-Wolfe decomposition based extension */ -/* of the branch-cut-and-price framework */ -/* SCIP --- Solving Constraint Integer Programs */ -/* */ -/* Copyright (C) 2010-2022 Operations Research, RWTH Aachen University */ -/* Zuse Institute Berlin (ZIB) */ -/* */ -/* This program is free software; you can redistribute it and/or */ -/* modify it under the terms of the GNU Lesser General Public License */ -/* as published by the Free Software Foundation; either version 3 */ -/* of the License, or (at your option) any later version. */ -/* */ -/* This program is distributed in the hope that it will be useful, */ -/* but WITHOUT ANY WARRANTY; without even the implied warranty of */ -/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ -/* GNU Lesser General Public License for more details. */ -/* */ -/* You should have received a copy of the GNU Lesser General Public License */ -/* along with this program; if not, write to the Free Software */ -/* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.*/ -/* */ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -/**@file reader_dec.h - * @brief DEC file reader for structure information - * @author Martin Bergner - * @author Lukas Kirchhart - * @author Micahel Bastubbe - * @ingroup FILEREADERS - - * This reader reads and write files in .dec format. A data format to pass a (possibly partial) decomposition to GCG, prerequisite is a given MIP, whose constraints and variables are referred to by name - * – everything behind a backslash (“\”) is a comment and is ignored - * – information is given section-wise - * – sections are started by key words (ignoring the case of the characters) and finished by starting a new section or reaching end of file - * – each line in a section provides one value - * – key words for sections are: - * – consdefaultmaster: - * – optional; followed by line with possible values: {0, 1}; default: 1; description: if set to 1 then (directly after file is read) each unassigned constraint is assigned to the master (needed for backward compatibility) - * – presolved: - * – mandatory; followed by line with possible values: {0, 1}; description: if set to 0 (1) then the decomposition is considered for the unpresolved (presolved) problem - * – nblocks - * – mandatory; possible values: N; description: number of (possibly empty) blocks this decomposition file has information for - * – block (alternatives: blockconss or blockcons) - * – optional; directly followed by block index (starting with 1); each following line contains name of a constraint belonging to this block - * – masterconss (alternative: mastercons) - * + optional; each following line contains name of a constraint belonging to the master - * – blockvars - * + optional; directly followed by block index (starting with 1); each following line contains name of a variable belonging to this block - * – mastervars (alternative: mastervar) - * + optional; each following line contains name of a master variable; (belongs explicitly only to master constraints) - * – linkingvars (alternative: linkingvar) - * + optional; each following line contains name of a linking variable - * – decomposition is rejected if there are any inconsistencies - * – after reading (and and possibly assigning unassigned constraints because of consdefaultmaster, see above) implicit assignments are made: - * – unassigned constraints hitting at least two blocks -> assign to master; - * – unassigned variables hitting at least two blocks -> assign to linking ; - * – all constraints of an unassigned variable are master constraints -> variable is master variable; - * - */ - -/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/ - -#ifndef GCG_READER_DEC_H__ -#define GCG_READER_DEC_H__ - - -#include "scip/scip.h" -#include "type_decomp.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/** includes the dec file reader into SCIP */ -extern -SCIP_RETCODE GCGincludeReaderDec( - SCIP* scip /**< SCIP data structure */ - ); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/headers/gcg/reader_gp.h b/headers/gcg/reader_gp.h deleted file mode 100644 index f7285dc..0000000 --- a/headers/gcg/reader_gp.h +++ /dev/null @@ -1,100 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* */ -/* This file is part of the program */ -/* GCG --- Generic Column Generation */ -/* a Dantzig-Wolfe decomposition based extension */ -/* of the branch-cut-and-price framework */ -/* SCIP --- Solving Constraint Integer Programs */ -/* */ -/* Copyright (C) 2010-2022 Operations Research, RWTH Aachen University */ -/* Zuse Institute Berlin (ZIB) */ -/* */ -/* This program is free software; you can redistribute it and/or */ -/* modify it under the terms of the GNU Lesser General Public License */ -/* as published by the Free Software Foundation; either version 3 */ -/* of the License, or (at your option) any later version. */ -/* */ -/* This program is distributed in the hope that it will be useful, */ -/* but WITHOUT ANY WARRANTY; without even the implied warranty of */ -/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ -/* GNU Lesser General Public License for more details. */ -/* */ -/* You should have received a copy of the GNU Lesser General Public License */ -/* along with this program; if not, write to the Free Software */ -/* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.*/ -/* */ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -/**@file reader_gp.h - * @brief GP file reader writing decompositions to gnuplot files - * @author Martin Bergner - * @author Hanna Franzen - * @ingroup FILEREADERS - * - * This reader can write visualizations of partialdecs to a .gp file. - */ - -/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/ - -#ifndef GCG_READER_GP_H__ -#define GCG_READER_GP_H__ - -#include "scip/scip.h" -#include "type_decomp.h" - -#ifdef __cplusplus -extern "C" { -#endif - - -/** Output format of gnuplot. Specifies the output format that gnuplot will produce. */ -enum GPOutputFormat -{ - GP_OUTPUT_FORMAT_PDF, - GP_OUTPUT_FORMAT_PNG, - GP_OUTPUT_FORMAT_SVG -}; -typedef enum GPOutputFormat GP_OUTPUT_FORMAT; - -/** Includes the gp file reader into SCIP - * @returns SCIP status */ -extern -SCIP_RETCODE SCIPincludeReaderGp( - SCIP* scip /**< SCIP data structure */ - ); - -/* Writes a visualization for the given partialdec */ -extern SCIP_RETCODE GCGwriteGpVisualizationFormat( - SCIP* scip, /**< SCIP data structure */ - char* filename, /**< filename (including path) to write to */ - char* outputname, /**< filename for compiled output file */ - int partialdecid, /**< id of partialdec to visualize */ - GP_OUTPUT_FORMAT outputformat /**< the output format which gnuplot should emit */ - ); - -/** Writes a visualization as .pdf file for the given partialdec - * @returns SCIP status */ -extern -SCIP_RETCODE GCGwriteGpVisualization( - SCIP* scip, /**< SCIP data structure */ - char* filename, /**< filename (including path), location of the output*/ - char* outputname, /**< outputname is the name of the file for the compiled gnuplot output file */ - int partialdecid /**< id of partialdec to visualize */ - ); - -/** Creates a block matrix and outputs its visualization as .pdf file - * @returns SCIP return code - * */ -extern -SCIP_RETCODE GCGWriteGpDecompMatrix( - SCIP* scip, /**< scip data structure */ - const char* filename, /**< filename the output should be written to (including directory) */ - const char* workfolder, /**< directory in which should be worked */ - SCIP_Bool originalmatrix /**< should the original (or transformed) matrix be written */ -); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/headers/gcg/reader_ref.h b/headers/gcg/reader_ref.h deleted file mode 100644 index dbb513a..0000000 --- a/headers/gcg/reader_ref.h +++ /dev/null @@ -1,81 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* */ -/* This file is part of the program */ -/* GCG --- Generic Column Generation */ -/* a Dantzig-Wolfe decomposition based extension */ -/* of the branch-cut-and-price framework */ -/* SCIP --- Solving Constraint Integer Programs */ -/* */ -/* Copyright (C) 2010-2022 Operations Research, RWTH Aachen University */ -/* Zuse Institute Berlin (ZIB) */ -/* */ -/* This program is free software; you can redistribute it and/or */ -/* modify it under the terms of the GNU Lesser General Public License */ -/* as published by the Free Software Foundation; either version 3 */ -/* of the License, or (at your option) any later version. */ -/* */ -/* This program is distributed in the hope that it will be useful, */ -/* but WITHOUT ANY WARRANTY; without even the implied warranty of */ -/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ -/* GNU Lesser General Public License for more details. */ -/* */ -/* You should have received a copy of the GNU Lesser General Public License */ -/* along with this program; if not, write to the Free Software */ -/* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.*/ -/* */ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -/**@file reader_ref.h - * @brief REF file reader for structure information - * @ingroup FILEREADERS - * @author Gerald Gamrath - * @author Christian Puchert - * @author Martin Bergner - * - * This reader reads and writes a ref-file that defines the structur to be used for the decomposition. - * The structure is defined constraint-wise, i.e., the number of blocks and the constraints belonging to each - * block are defined. The constraints are numbered by the appearance in the problem. - * - * Constraints not mentioned in one of the blocks will remain in the master problem - * - * The format is the following - * - first line: \#nblocks \#ncons_block_1 ... \#n_cons_block_n - * - one line for each block with the indices of constraints to be put into that block separated by a comma - * - */ - -/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/ - -#ifndef GCG_READER_REF_H__ -#define GCG_READER_REF_H__ - - -#include "scip/type_scip.h" -#include "scip/type_reader.h" -#include "scip/type_result.h" -#include "type_decomp.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/** includes the ref file reader into SCIP */ -extern -SCIP_RETCODE SCIPincludeReaderRef( - SCIP* scip /**< SCIP data structure */ - ); - -/* reads problem from file */ -extern -SCIP_RETCODE SCIPreadRef( - SCIP* scip, /**< SCIP data structure */ - SCIP_READER* reader, /**< the file reader itself */ - const char* filename, /**< full path and name of file to read, or NULL if stdin should be used */ - SCIP_RESULT* result /**< pointer to store the result of the file reading call */ - ); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/headers/gcg/reader_tex.h b/headers/gcg/reader_tex.h deleted file mode 100644 index c1b1edf..0000000 --- a/headers/gcg/reader_tex.h +++ /dev/null @@ -1,101 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* */ -/* This file is part of the program */ -/* GCG --- Generic Column Generation */ -/* a Dantzig-Wolfe decomposition based extension */ -/* of the branch-cut-and-price framework */ -/* SCIP --- Solving Constraint Integer Programs */ -/* */ -/* Copyright (C) 2010-2022 Operations Research, RWTH Aachen University */ -/* Zuse Institute Berlin (ZIB) */ -/* */ -/* This program is free software; you can redistribute it and/or */ -/* modify it under the terms of the GNU Lesser General Public License */ -/* as published by the Free Software Foundation; either version 3 */ -/* of the License, or (at your option) any later version. */ -/* */ -/* This program is distributed in the hope that it will be useful, */ -/* but WITHOUT ANY WARRANTY; without even the implied warranty of */ -/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ -/* GNU Lesser General Public License for more details. */ -/* */ -/* You should have received a copy of the GNU Lesser General Public License */ -/* along with this program; if not, write to the Free Software */ -/* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.*/ -/* */ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -/**@file reader_tex.h - * @brief tex file reader for writing decomposition details to LaTeX files - * @author Hanna Franzen - * @ingroup FILEREADERS - - * This reader can write visualizations, family trees and reports of partialdecs to a .tex LaTeX file. - * The gp reader might be required for visualizations. - - */ - -/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/ - -#ifndef GCG_READER_TEX_H__ -#define GCG_READER_TEX_H__ - -#include "scip/scip.h" -#include "type_decomp.h" -#include "cons_decomp.h" - -#ifdef __cplusplus -extern "C" { -#endif - - -/** Includes the tex file reader into SCIP - * - * @returns SCIP status */ -extern SCIP_RETCODE SCIPincludeReaderTex( - SCIP* scip /**< SCIP data structure */ - ); - -/** Writes visualization LaTeX code for the given partialdec - * - * @returns SCIP status */ -extern SCIP_RETCODE GCGwriteTexVisualization( - SCIP* scip, /**< SCIP data structure */ - FILE* file, /**< file in which to write the LaTeX code */ - int partialdecid, /**< id of partialdec to visualize */ - SCIP_Bool statistics, /**< additionally to picture show statistics */ - SCIP_Bool usegp /**< true if the gp reader should be used for the image generation (instead of tikz) */ - ); - -/** Writes a report for the given partialdecs - * - * @note *npartialdecs will be set to the number of actually written decompositions. - * @returns SCIP status */ -extern SCIP_RETCODE GCGwriteTexReport( - SCIP* scip, /**< SCIP data structure */ - FILE* file, /**< file in which to put the LaTeX code */ - int* partialdecids, /**< ids of partialdecs to visualize */ - int* npartialdecs, /**< number of partialdecs to visualize */ - SCIP_Bool titlepage, /**< true if a title page should be included in the document */ - SCIP_Bool toc, /**< true if an interactive table of contents should be included */ - SCIP_Bool statistics, /**< true if statistics for each partialdec should be included */ - SCIP_Bool usegp /**< true if the gp reader should be used for the image generation */ - ); - -/** Makes a new makefile and readme for the given .tex file - * - * @returns SCIP status */ -extern SCIP_RETCODE GCGtexWriteMakefileAndReadme( - SCIP* scip, /**< SCIP data structure */ - FILE* file, /**< tex file for which the makefile & readme are generated */ - SCIP_Bool usegp, /**< true if the gp reader was used for creation of images */ - SCIP_Bool compiletex /**< true if there are tex files to be compiled before main document */ - ); - -#ifdef __cplusplus -} -#endif - - -#endif /* GCG_READER_TEX_H__ */ - diff --git a/headers/gcg/relax_gcg.h b/headers/gcg/relax_gcg.h deleted file mode 100644 index 1293d9e..0000000 --- a/headers/gcg/relax_gcg.h +++ /dev/null @@ -1,413 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* */ -/* This file is part of the program */ -/* GCG --- Generic Column Generation */ -/* a Dantzig-Wolfe decomposition based extension */ -/* of the branch-cut-and-price framework */ -/* SCIP --- Solving Constraint Integer Programs */ -/* */ -/* Copyright (C) 2010-2022 Operations Research, RWTH Aachen University */ -/* Zuse Institute Berlin (ZIB) */ -/* */ -/* This program is free software; you can redistribute it and/or */ -/* modify it under the terms of the GNU Lesser General Public License */ -/* as published by the Free Software Foundation; either version 3 */ -/* of the License, or (at your option) any later version. */ -/* */ -/* This program is distributed in the hope that it will be useful, */ -/* but WITHOUT ANY WARRANTY; without even the implied warranty of */ -/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ -/* GNU Lesser General Public License for more details. */ -/* */ -/* You should have received a copy of the GNU Lesser General Public License */ -/* along with this program; if not, write to the Free Software */ -/* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.*/ -/* */ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -/**@file relax_gcg.h - * @brief GCG relaxator - * @author Gerald Gamrath - * @author Christian Puchert - * @author Martin Bergner - * @author Oliver Gaul - */ - -/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/ - -#ifndef GCG_RELAX_GCG_H__ -#define GCG_RELAX_GCG_H__ - -#include "scip/scip.h" -#include "type_branchgcg.h" -#include "type_decomp.h" -#include "type_parameter.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @ingroup RELAXATORS - * @{ - */ - -/** creates the GCG relaxator and includes it in SCIP */ -extern -SCIP_RETCODE SCIPincludeRelaxGcg( - SCIP* scip /**< SCIP data structure */ - ); - -/** includes a branching rule into the relaxator data */ -extern -SCIP_RETCODE GCGrelaxIncludeBranchrule( - SCIP* scip, /**< SCIP data structure */ - SCIP_BRANCHRULE* branchrule, /**< branching rule for which callback methods are saved */ - GCG_DECL_BRANCHACTIVEMASTER((*branchactivemaster)),/**< activation method for branchrule */ - GCG_DECL_BRANCHDEACTIVEMASTER ((*branchdeactivemaster)),/**< deactivation method for branchrule */ - GCG_DECL_BRANCHPROPMASTER((*branchpropmaster)),/**< propagation method for branchrule */ - GCG_DECL_BRANCHMASTERSOLVED((*branchmastersolved)),/**< master solved method for branchrule */ - GCG_DECL_BRANCHDATADELETE((*branchdatadelete))/**< branchdata deletion method for branchrule */ - ); - -/** perform activation method of the given branchrule for the given branchdata */ -extern -SCIP_RETCODE GCGrelaxBranchActiveMaster( - SCIP* scip, /**< SCIP data structure */ - SCIP_BRANCHRULE* branchrule, /**< branching rule that did the branching */ - GCG_BRANCHDATA* branchdata /**< data representing the branching decision */ - ); - -/** perform deactivation method of the given branchrule for the given branchdata */ -extern -SCIP_RETCODE GCGrelaxBranchDeactiveMaster( - SCIP* scip, /**< SCIP data structure */ - SCIP_BRANCHRULE* branchrule, /**< branching rule that did the branching */ - GCG_BRANCHDATA* branchdata /**< data representing the branching decision */ - ); - -/** perform propagation method of the given branchrule for the given branchdata */ -extern -SCIP_RETCODE GCGrelaxBranchPropMaster( - SCIP* scip, /**< SCIP data structure */ - SCIP_BRANCHRULE* branchrule, /**< branching rule that did the branching */ - GCG_BRANCHDATA* branchdata, /**< data representing the branching decision */ - SCIP_RESULT* result /**< pointer to store the result of the propagation call */ - ); - -/** perform method of the given branchrule that is called after the master LP is solved */ -extern -SCIP_RETCODE GCGrelaxBranchMasterSolved( - SCIP* scip, /**< SCIP data structure */ - SCIP_BRANCHRULE* branchrule, /**< branching rule that did the branching */ - GCG_BRANCHDATA* branchdata, /**< data representing the branching decision */ - SCIP_Real newlowerbound /**< the new local lowerbound */ - ); - -/** frees branching data created by the given branchrule */ -extern -SCIP_RETCODE GCGrelaxBranchDataDelete( - SCIP* scip, /**< SCIP data structure */ - SCIP_BRANCHRULE* branchrule, /**< branching rule that did the branching */ - GCG_BRANCHDATA** branchdata /**< data representing the branching decision */ - ); - -/** transformes a constraint of the original problem into the master variable space and - * adds it to the master problem */ -extern -SCIP_RETCODE GCGrelaxTransOrigToMasterCons( - SCIP* scip, /**< SCIP data structure */ - SCIP_CONS* cons, /**< the constraint that should be transformed */ - SCIP_CONS** transcons /**< pointer to the transformed constraint */ - ); - -/** returns the current solution for the original problem */ -extern -SCIP_SOL* GCGrelaxGetCurrentOrigSol( - SCIP* scip /**< SCIP data structure */ - ); - -/** returns whether the current solution is primal feasible in the original problem */ -extern -SCIP_Bool GCGrelaxIsOrigSolFeasible( - SCIP* scip /**< SCIP data structure */ - ); - -/** start probing mode on both the original and master problems - * - * @note This mode is intended for working on the original variables but using the master LP; - * it currently only supports bound changes on the original variables, - * but no additional rows - */ -extern -SCIP_RETCODE GCGrelaxStartProbing( - SCIP* scip, /**< SCIP data structure */ - SCIP_HEUR* probingheur /**< heuristic that started probing mode, or NULL */ - ); - -/** returns the heuristic that started probing in the master problem, or NULL */ -extern -SCIP_HEUR* GCGrelaxGetProbingheur( - SCIP* scip /**< SCIP data structure */ - ); - -/** add a new probing node the original problem together with an original branching constraint - * - * @note A corresponding probing node must be added to the master problem right before solving the probing LP - */ -extern -SCIP_RETCODE GCGrelaxNewProbingnodeOrig( - SCIP* scip /**< SCIP data structure */ - ); - -/** add a new probing node the master problem together with a master branching constraint - * which ensures that bound changes are transferred to master and pricing problems - * - * @note A corresponding probing node must have been added to the original problem beforehand; - * furthermore, this method must be called after bound changes to the original problem have been made - */ -extern -SCIP_RETCODE GCGrelaxNewProbingnodeMaster( - SCIP* scip /**< SCIP data structure */ - ); - -/** add a new probing node the master problem together with a master branching constraint - * which ensures that bound changes are transferred to master and pricing problems as well as additional - * constraints - * - * @note A corresponding probing node must have been added to the original problem beforehand; - * furthermore, this method must be called after bound changes to the original problem have been made - */ -extern -SCIP_RETCODE GCGrelaxNewProbingnodeMasterCons( - SCIP* scip, /**< SCIP data structure */ - SCIP_BRANCHRULE* branchrule, /**< pointer to the branching rule */ - GCG_BRANCHDATA* branchdata, /**< branching data */ - SCIP_CONS** origbranchconss, /**< original constraints enforcing the branching decision */ - int norigbranchconss, /**< number of original constraints */ - int maxorigbranchconss /**< capacity of origbranchconss */ - ); - -/** add probing nodes to both the original and master problem; - * furthermore, add origbranch and masterbranch constraints to transfer branching decisions - * from the original to the master problem - */ -extern -SCIP_RETCODE GCGrelaxBacktrackProbing( - SCIP* scip, /**< SCIP data structure */ - int probingdepth /**< probing depth of the node in the probing path that should be reactivated */ - ); - -/** solve the master probing LP without pricing */ -extern -SCIP_RETCODE GCGrelaxPerformProbing( - SCIP* scip, /**< SCIP data structure */ - int maxlpiterations, /**< maximum number of lp iterations allowed */ - SCIP_Longint* nlpiterations, /**< pointer to store the number of performed LP iterations (or NULL) */ - SCIP_Real* lpobjvalue, /**< pointer to store the lp obj value if lp was solved */ - SCIP_Bool* lpsolved, /**< pointer to store whether the lp was solved */ - SCIP_Bool* lperror, /**< pointer to store whether an unresolved LP error occured or the - * solving process should be stopped (e.g., due to a time limit) */ - SCIP_Bool* cutoff /**< pointer to store whether the probing direction is infeasible */ - ); - -/** solve the master probing LP with pricing */ -extern -SCIP_RETCODE GCGrelaxPerformProbingWithPricing( - SCIP* scip, /**< SCIP data structure */ - int maxpricerounds, /**< maximum number of pricing rounds allowed */ - SCIP_Longint* nlpiterations, /**< pointer to store the number of performed LP iterations (or NULL) */ - int* npricerounds, /**< pointer to store the number of performed pricing rounds (or NULL) */ - SCIP_Real* lpobjvalue, /**< pointer to store the lp obj value if lp was solved */ - SCIP_Bool* lpsolved, /**< pointer to store whether the lp was solved */ - SCIP_Bool* lperror, /**< pointer to store whether an unresolved LP error occured or the - * solving process should be stopped (e.g., due to a time limit) */ - SCIP_Bool* cutoff /**< pointer to store whether the probing direction is infeasible */ - ); - -/** end probing mode in both the original and master problems */ -extern -SCIP_RETCODE GCGrelaxEndProbing( - SCIP* scip /**< SCIP data structure */ - ); - -/** transforms the current solution of the master problem into the original problem's space - * and saves this solution as currentsol in the relaxator's data */ -extern -SCIP_RETCODE GCGrelaxUpdateCurrentSol( - SCIP* scip /**< SCIP data structure */ - ); - -/** returns the decomposition mode */ -extern -DEC_DECMODE GCGgetDecompositionMode( - SCIP* scip /**< SCIP data structure */ - ); - -/** returns the decomposition mode of the master problem. The mode is given by the existence of either the GCG pricer or - * the GCG Benders' decomposition plugins. - */ -extern -DEC_DECMODE GCGgetMasterDecompMode( - SCIP* masterprob /**< the master problem SCIP instance */ - ); - -/** gets the structure information */ -extern -DEC_DECOMP* GCGgetStructDecomp( - SCIP* scip /**< SCIP data structure */ - ); - -/** returns the visualization parameters */ -extern -GCG_PARAMDATA* GCGgetParamsVisu( - SCIP* scip /**< SCIP data structure */ - ); - - -/** return root node clock */ -extern -SCIP_CLOCK* GCGgetRootNodeTime( - SCIP* scip /**< SCIP data structure */ - ); - - -/** initializes solving data structures and transforms problem for solving with GCG - * - * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref - * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes. - * - * @pre This method can be called if @p scip is in one of the following stages: - * - \ref SCIP_STAGE_PROBLEM - * - \ref SCIP_STAGE_TRANSFORMED - * - \ref SCIP_STAGE_INITPRESOLVE - * - \ref SCIP_STAGE_PRESOLVING - * - \ref SCIP_STAGE_EXITPRESOLVE - * - \ref SCIP_STAGE_PRESOLVED - * - \ref SCIP_STAGE_INITSOLVE - * - \ref SCIP_STAGE_SOLVING - * - \ref SCIP_STAGE_SOLVED - * - \ref SCIP_STAGE_EXITSOLVE - * - \ref SCIP_STAGE_FREETRANS - * - \ref SCIP_STAGE_FREE - * - * @post When calling this method in the \ref SCIP_STAGE_PROBLEM stage, the \SCIP stage is changed to \ref - * SCIP_STAGE_TRANSFORMED; otherwise, the stage is not changed - * - * See \ref SCIP_Stage "SCIP_STAGE" for a complete list of all possible solving stages. - */ -SCIP_RETCODE GCGtransformProb( - SCIP* scip /**< SCIP data structure */ - ); - -/** transforms and presolves the problem suitable for GCG - * - * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref - * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes. - * - * @pre This method can be called if @p scip is in one of the following stages: - * - \ref SCIP_STAGE_PROBLEM - * - \ref SCIP_STAGE_TRANSFORMED - * - \ref SCIP_STAGE_PRESOLVING - * - \ref SCIP_STAGE_PRESOLVED - * - * @post After calling this method \SCIP reaches one of the following stages: - * - \ref SCIP_STAGE_PRESOLVING if the presolving process was interrupted - * - \ref SCIP_STAGE_PRESOLVED if the presolving process was finished and did not solve the problem - * - \ref SCIP_STAGE_SOLVED if the problem was solved during presolving - * - * See \ref SCIP_Stage "SCIP_STAGE" for a complete list of all possible solving stages. - */ -SCIP_RETCODE GCGpresolve( - SCIP* scip /**< SCIP data structure */ - ); - -/** transforms and detects the problem - * - * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref - * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes. - * - * @pre This method can be called if @p scip is in one of the following stages: - * - \ref SCIP_STAGE_PROBLEM - * - \ref SCIP_STAGE_TRANSFORMED - * - \ref SCIP_STAGE_PRESOLVING - * - \ref SCIP_STAGE_PRESOLVED - * - * @post When calling this method in the \ref SCIP_STAGE_PROBLEM stage, the \SCIP stage is changed to \ref - * SCIP_STAGE_TRANSFORMED; otherwise, the stage is not changed - * - * See \ref SCIP_Stage "SCIP_STAGE" for a complete list of all possible solving stages. - */ -SCIP_RETCODE GCGdetect( - SCIP* scip /**< SCIP data structure */ - ); - -/** transforms, resolves, detects, and solves the problem using GCG - * - * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref - * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes. - * - * @pre This method can be called if @p scip is in one of the following stages: - * - \ref SCIP_STAGE_PROBLEM - * - \ref SCIP_STAGE_TRANSFORMED - * - \ref SCIP_STAGE_PRESOLVING - * - \ref SCIP_STAGE_PRESOLVED - * - \ref SCIP_STAGE_SOLVING - * - \ref SCIP_STAGE_SOLVED - * - * @post After calling this method \SCIP reaches one of the following stages depending on if and when the solution - * process was interrupted: - * - \ref SCIP_STAGE_PRESOLVING if the solution process was interrupted during presolving - * - \ref SCIP_STAGE_SOLVING if the solution process was interrupted during the tree search - * - \ref SCIP_STAGE_SOLVED if the solving process was not interrupted - * - * See \ref SCIP_Stage "SCIP_STAGE" for a complete list of all possible solving stages. - */ -SCIP_RETCODE GCGsolve( - SCIP* scip /**< SCIP data structure */ - ); - -/** @} */ - -/** gets GCG's global dual bound - * - * Computes the global dual bound while considering the original - * problem SCIP instance and the master problem SCIP instance. - * - * @return the global dual bound - */ -SCIP_Real GCGgetDualbound( - SCIP* scip /**< SCIP data structure */ - ); - -/** gets GCG's global primal bound - * - * Computes the global primal bound while considering the original - * problem SCIP instance and the master problem SCIP instance. - * - * @return the global dual bound - */ -SCIP_Real GCGgetPrimalbound( - SCIP* scip /**< SCIP data structure */ - ); - -/** gets GCG's global gap - * - * Computes the global gap based on the gloal dual bound and the - * global primal bound. - * - * @return the global dual bound - * - * @see GCGgetDualbound() - * @see GCGgetPrimalbound() - */ -SCIP_Real GCGgetGap( - SCIP* scip /**< SCIP data structure */ - ); - -#ifdef __cplusplus -} - -#endif - -#endif diff --git a/headers/gcg/scip_misc.h b/headers/gcg/scip_misc.h deleted file mode 100644 index 79707fc..0000000 --- a/headers/gcg/scip_misc.h +++ /dev/null @@ -1,158 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* */ -/* This file is part of the program */ -/* GCG --- Generic Column Generation */ -/* a Dantzig-Wolfe decomposition based extension */ -/* of the branch-cut-and-price framework */ -/* SCIP --- Solving Constraint Integer Programs */ -/* */ -/* Copyright (C) 2010-2022 Operations Research, RWTH Aachen University */ -/* Zuse Institute Berlin (ZIB) */ -/* */ -/* This program is free software; you can redistribute it and/or */ -/* modify it under the terms of the GNU Lesser General Public License */ -/* as published by the Free Software Foundation; either version 3 */ -/* of the License, or (at your option) any later version. */ -/* */ -/* This program is distributed in the hope that it will be useful, */ -/* but WITHOUT ANY WARRANTY; without even the implied warranty of */ -/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ -/* GNU Lesser General Public License for more details. */ -/* */ -/* You should have received a copy of the GNU Lesser General Public License */ -/* along with this program; if not, write to the Free Software */ -/* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.*/ -/* */ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -/**@file scip_misc.h - * @brief various SCIP helper methods - * @author Martin Bergner - */ - -/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/ - -#ifndef GCG_SCIP_MISC_H__ -#define GCG_SCIP_MISC_H__ - -#include "scip/scip.h" -#include "scip/cons_setppc.h" - -#ifdef __cplusplus -extern "C" { -#endif - - -/** constraint types */ -typedef enum { - linear, knapsack, varbound, setpacking, setcovering, setpartitioning, - logicor, sos1, sos2, unknown, nconsTypeItems, indicator -} consType; - -/**@defgroup MISC Miscellaneous -* @ingroup PUBLICCOREAPI -* @{ - */ - -/** returns TRUE if variable is relevant, FALSE otherwise */ -extern -SCIP_Bool GCGisVarRelevant( - SCIP_VAR* var /**< variable to test */ - ); - -/** returns the type of an arbitrary SCIP constraint */ -extern -consType GCGconsGetType( - SCIP* scip, /**< SCIP data structure */ - SCIP_CONS* cons /**< constraint to get type for */ - ); - -/** returns the rhs of an arbitrary SCIP constraint */ -extern -SCIP_Real GCGconsGetRhs( - SCIP* scip, /**< SCIP data structure */ - SCIP_CONS* cons /**< constraint to get left hand side for */ - ); - -/** returns the lhs of an arbitrary SCIP constraint */ -extern -SCIP_Real GCGconsGetLhs( - SCIP* scip, /**< SCIP data structure */ - SCIP_CONS* cons /**< constraint to get left hand side for */ - ); - -/** returns the dual farkas sol of an arbitrary SCIP constraint */ -extern -SCIP_Real GCGconsGetDualfarkas( - SCIP* scip, /**< SCIP data structure */ - SCIP_CONS* cons /**< constraint to get left hand side for */ - ); - -/** returns the dual sol of an arbitrary SCIP constraint */ -extern -SCIP_Real GCGconsGetDualsol( - SCIP* scip, /**< SCIP data structure */ - SCIP_CONS* cons /**< constraint to get left hand side for */ - ); - -/** returns the number of variables in an arbitrary SCIP constraint */ -extern -int GCGconsGetNVars( - SCIP* scip, /**< SCIP data structure */ - SCIP_CONS* cons /**< constraint to get number of variables */ - ); - -/** returns the variable array of an arbitrary SCIP constraint */ -extern -SCIP_RETCODE GCGconsGetVars( - SCIP* scip, /**< SCIP data structure */ - SCIP_CONS* cons, /**< constraint to get variables from */ - SCIP_VAR** vars, /**< array where variables are stored */ - int nvars /**< size of storage array */ - ); - -/** returns the value array of an arbitrary SCIP constraint */ -extern -SCIP_RETCODE GCGconsGetVals( - SCIP* scip, /**< SCIP data structure */ - SCIP_CONS* cons, /**< constraint to get values from */ - SCIP_Real* vals, /**< array where values are stored */ - int nvals /**< size of storage array */ - ); - -/** returns true if the constraint should be a master constraint and false otherwise */ -SCIP_Bool GCGconsIsRanged( - SCIP* scip, /**< SCIP data structure */ - SCIP_CONS* cons /**< constraint to check */ -); - -/** returns true if the constraint should be a master constraint and false otherwise */ -SCIP_Bool GCGgetConsIsSetppc( - SCIP* scip, /**< SCIP data structure */ - SCIP_CONS* cons, /**< constraint to check */ - SCIP_SETPPCTYPE* setppctype /**< returns the type of the constraints */ - ); - -SCIP_Bool GCGgetConsIsCardinalityCons( - SCIP* scip, /**< SCIP data structure */ - SCIP_CONS* cons /**< constraint to check */ -); - - -/** returns TRUE or FALSE, depending whether we are in the root node or not */ -extern -SCIP_Bool GCGisRootNode( - SCIP* scip /**< SCIP data structure */ - ); - -extern -SCIP_RETCODE GCGincludeDialogsGraph( - SCIP* scip - ); - -/**@} */ -#ifdef __cplusplus -} -#endif - -#endif /* GCG_SCIP_MISC_H_ */ diff --git a/headers/gcg/scoretype.h b/headers/gcg/scoretype.h deleted file mode 100644 index 7e49037..0000000 --- a/headers/gcg/scoretype.h +++ /dev/null @@ -1,68 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* */ -/* This file is part of the program */ -/* GCG --- Generic Column Generation */ -/* a Dantzig-Wolfe decomposition based extension */ -/* of the branch-cut-and-price framework */ -/* SCIP --- Solving Constraint Integer Programs */ -/* */ -/* Copyright (C) 2010-2022 Operations Research, RWTH Aachen University */ -/* Zuse Institute Berlin (ZIB) */ -/* */ -/* This program is free software; you can redistribute it and/or */ -/* modify it under the terms of the GNU Lesser General Public License */ -/* as published by the Free Software Foundation; either version 3 */ -/* of the License, or (at your option) any later version. */ -/* */ -/* This program is distributed in the hope that it will be useful, */ -/* but WITHOUT ANY WARRANTY; without even the implied warranty of */ -/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ -/* GNU Lesser General Public License for more details. */ -/* */ -/* You should have received a copy of the GNU Lesser General Public License */ -/* along with this program; if not, write to the Free Software */ -/* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.*/ -/* */ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -/**@file scoretype.h - * @brief miscellaneous methods for working with SCORETYPE - * @author Erik Muehmer - */ - -/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/ - -#ifndef __GCG_SCORETYPE_H__ -#define __GCG_SCORETYPE_H__ - -#include "type_scoretype.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @brief returns the description of the given scoretype - * - * @returns description of the scoretype - */ -extern -const char* GCGscoretypeGetDescription( - SCORETYPE sctype /**< scoretype */ - ); - -/** - * @brief Gets the shortname of the given scoretype - * - * @returns the shortname of the given Scoretype - */ -extern -const char* GCGscoretypeGetShortName( - SCORETYPE sctype /**< scoretype */ - ); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/headers/gcg/sepa_basis.h b/headers/gcg/sepa_basis.h deleted file mode 100644 index 5ceffcf..0000000 --- a/headers/gcg/sepa_basis.h +++ /dev/null @@ -1,98 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* */ -/* This file is part of the program */ -/* GCG --- Generic Column Generation */ -/* a Dantzig-Wolfe decomposition based extension */ -/* of the branch-cut-and-price framework */ -/* SCIP --- Solving Constraint Integer Programs */ -/* */ -/* Copyright (C) 2010-2022 Operations Research, RWTH Aachen University */ -/* Zuse Institute Berlin (ZIB) */ -/* */ -/* This program is free software; you can redistribute it and/or */ -/* modify it under the terms of the GNU Lesser General Public License */ -/* as published by the Free Software Foundation; either version 3 */ -/* of the License, or (at your option) any later version. */ -/* */ -/* This program is distributed in the hope that it will be useful, */ -/* but WITHOUT ANY WARRANTY; without even the implied warranty of */ -/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ -/* GNU Lesser General Public License for more details. */ -/* */ -/* You should have received a copy of the GNU Lesser General Public License */ -/* along with this program; if not, write to the Free Software */ -/* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.*/ -/* */ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -/**@file sepa_basis.h - * @ingroup SEPARATORS - * @brief basis separator - * @author Jonas Witt - */ - -/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/ - -#ifndef __SCIP_SEPA_BASIS_H__ -#define __SCIP_SEPA_BASIS_H__ - - -#include "scip/scip.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/** creates the basis separator and includes it in SCIP */ -extern -SCIP_RETCODE SCIPincludeSepaBasis( - SCIP* scip /**< SCIP data structure */ - ); - -/** returns the array of original cuts saved in the separator data */ -extern -SCIP_ROW** GCGsepaBasisGetOrigcuts( - SCIP* scip /**< SCIP data structure */ - ); - -/** returns the number of original cuts saved in the separator data */ -extern -int GCGsepaBasisGetNOrigcuts( - SCIP* scip /**< SCIP data structure */ - ); - -/** returns the array of master cuts saved in the separator data */ -extern -SCIP_ROW** GCGsepaBasisGetMastercuts( - SCIP* scip /**< SCIP data structure */ - ); - -/** returns the number of master cuts saved in the separator data */ -extern -int GCGsepaBasisGetNMastercuts( - SCIP* scip /**< SCIP data structure */ - ); - -/** transforms cut in pricing variables to cut in original variables and adds it to newcuts array */ -extern -SCIP_RETCODE GCGsepaBasisAddPricingCut( - SCIP* scip, /**< SCIP data structure */ - int ppnumber, /**< number of pricing problem */ - SCIP_ROW* cut /**< cut to be added */ - ); - -/** add cuts which are due to the latest objective function of the pricing problems - * (reduced cost non-negative) */ -extern -SCIP_RETCODE SCIPsepaBasisAddPPObjConss( - SCIP* scip, /**< SCIP data structure */ - int ppnumber, /**< number of pricing problem */ - SCIP_Real dualsolconv, /**< dual solution corresponding to convexity constraint */ - SCIP_Bool newcuts /**< add cut to newcuts in sepadata? (otherwise add it just to the cutpool) */ - ); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/headers/gcg/sepa_master.h b/headers/gcg/sepa_master.h deleted file mode 100644 index b73a982..0000000 --- a/headers/gcg/sepa_master.h +++ /dev/null @@ -1,82 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* */ -/* This file is part of the program */ -/* GCG --- Generic Column Generation */ -/* a Dantzig-Wolfe decomposition based extension */ -/* of the branch-cut-and-price framework */ -/* SCIP --- Solving Constraint Integer Programs */ -/* */ -/* Copyright (C) 2010-2022 Operations Research, RWTH Aachen University */ -/* Zuse Institute Berlin (ZIB) */ -/* */ -/* This program is free software; you can redistribute it and/or */ -/* modify it under the terms of the GNU Lesser General Public License */ -/* as published by the Free Software Foundation; either version 3 */ -/* of the License, or (at your option) any later version. */ -/* */ -/* This program is distributed in the hope that it will be useful, */ -/* but WITHOUT ANY WARRANTY; without even the implied warranty of */ -/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ -/* GNU Lesser General Public License for more details. */ -/* */ -/* You should have received a copy of the GNU Lesser General Public License */ -/* along with this program; if not, write to the Free Software */ -/* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.*/ -/* */ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -/**@file sepa_master.h - * @ingroup SEPARATORS - * @brief master separator - * @author Gerald Gamrath - */ - -/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/ - -#ifndef GCG_SEPA_MASTER_H__ -#define GCG_SEPA_MASTER_H__ - - -#include "scip/scip.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/** creates the master separator and includes it in SCIP */ -extern -SCIP_RETCODE SCIPincludeSepaMaster( - SCIP* scip /**< SCIP data structure */ - ); - -/** returns the array of original cuts saved in the separator data */ -extern -SCIP_ROW** GCGsepaGetOrigcuts( - SCIP* scip /**< SCIP data structure */ - ); - -/** returns the number of cuts saved in the separator data */ -extern -int GCGsepaGetNCuts( - SCIP* scip /**< SCIP data structure */ - ); - -/** returns the array of master cuts saved in the separator data */ -extern -SCIP_ROW** GCGsepaGetMastercuts( - SCIP* scip /**< SCIP data structure */ - ); - -/** adds given original and master cut to master separator data */ -extern -SCIP_RETCODE GCGsepaAddMastercuts( - SCIP* scip, /**< SCIP data structure */ - SCIP_ROW* origcut, /**< pointer to orginal cut */ - SCIP_ROW* mastercut /**< pointer to master cut */ -); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/headers/gcg/solver.h b/headers/gcg/solver.h deleted file mode 100644 index 80629f6..0000000 --- a/headers/gcg/solver.h +++ /dev/null @@ -1,139 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* */ -/* This file is part of the program */ -/* GCG --- Generic Column Generation */ -/* a Dantzig-Wolfe decomposition based extension */ -/* of the branch-cut-and-price framework */ -/* SCIP --- Solving Constraint Integer Programs */ -/* */ -/* Copyright (C) 2010-2022 Operations Research, RWTH Aachen University */ -/* Zuse Institute Berlin (ZIB) */ -/* */ -/* This program is free software; you can redistribute it and/or */ -/* modify it under the terms of the GNU Lesser General Public License */ -/* as published by the Free Software Foundation; either version 3 */ -/* of the License, or (at your option) any later version. */ -/* */ -/* This program is distributed in the hope that it will be useful, */ -/* but WITHOUT ANY WARRANTY; without even the implied warranty of */ -/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ -/* GNU Lesser General Public License for more details. */ -/* */ -/* You should have received a copy of the GNU Lesser General Public License */ -/* along with this program; if not, write to the Free Software */ -/* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.*/ -/* */ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -/**@file solver.h - * @ingroup PRICING - * @brief private methods for GCG pricing solvers - * @author Henri Lotze - * @author Christian Puchert - */ - -/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/ - -#ifndef GCG_SOLVER_H_ -#define GCG_SOLVER_H_ - -#include "type_solver.h" -#include "scip/scip.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @ingroup PRICING - * - * @{ - */ - -/** creates a GCG pricing solver */ -SCIP_EXPORT -SCIP_RETCODE GCGsolverCreate( - SCIP* scip, /**< SCIP data structure (master problem) */ - GCG_SOLVER** solver, /**< pointer to pricing solver data structure */ - const char* name, /**< name of solver */ - const char* desc, /**< description of solver */ - int priority, /**< priority of solver */ - SCIP_Bool heurenabled, /**< flag to indicate whether heuristic solving method of the solver is enabled */ - SCIP_Bool exactenabled, /**< flag to indicate whether exact solving method of the solver is enabled */ - GCG_DECL_SOLVERUPDATE((*solverupdate)), /**< update method for solver */ - GCG_DECL_SOLVERSOLVE ((*solversolve)), /**< solving method for solver */ - GCG_DECL_SOLVERSOLVEHEUR((*solveheur)), /**< heuristic solving method for solver */ - GCG_DECL_SOLVERFREE ((*solverfree)), /**< free method of solver */ - GCG_DECL_SOLVERINIT ((*solverinit)), /**< init method of solver */ - GCG_DECL_SOLVEREXIT ((*solverexit)), /**< exit method of solver */ - GCG_DECL_SOLVERINITSOL((*solverinitsol)), /**< initsol method of solver */ - GCG_DECL_SOLVEREXITSOL((*solverexitsol)), /**< exitsol method of solver */ - GCG_SOLVERDATA* solverdata /**< pricing solver data */ - ); - -/** calls destructor and frees memory of GCG pricing solver */ -SCIP_EXPORT -SCIP_RETCODE GCGsolverFree( - SCIP* scip, /**< SCIP data structure (master problem) */ - GCG_SOLVER** solver /**< pointer to pricing solver data structure */ - ); - -/** initializes GCG pricing solver */ -SCIP_EXPORT -SCIP_RETCODE GCGsolverInit( - SCIP* scip, /**< SCIP data structure (master problem) */ - GCG_SOLVER* solver /**< pricing solver */ - ); - -/** calls exit method of GCG pricing solver */ -SCIP_EXPORT -SCIP_RETCODE GCGsolverExit( - SCIP* scip, /**< SCIP data structure (master problem) */ - GCG_SOLVER* solver /**< pricing solver */ - ); - -/** calls solving process initialization method of GCG pricing solver */ -SCIP_EXPORT -SCIP_RETCODE GCGsolverInitsol( - SCIP* scip, /**< SCIP data structure (master problem) */ - GCG_SOLVER* solver /**< pricing solver */ - ); - -/** calls solving process deinitialization method of GCG pricing solver */ -SCIP_EXPORT -SCIP_RETCODE GCGsolverExitsol( - SCIP* scip, /**< SCIP data structure (master problem) */ - GCG_SOLVER* solver /**< pricing solver */ - ); - -/** calls update method of GCG pricing solver */ -SCIP_EXPORT -SCIP_RETCODE GCGsolverUpdate( - SCIP* pricingprob, /**< the pricing problem that should be solved */ - GCG_SOLVER* solver, /**< pricing solver */ - int probnr, /**< number of the pricing problem */ - SCIP_Bool varobjschanged, /**< have the objective coefficients changed? */ - SCIP_Bool varbndschanged, /**< have the lower and upper bounds changed? */ - SCIP_Bool consschanged /**< have the constraints changed? */ - ); - -/** calls heuristic or exact solving method of GCG pricing solver */ -SCIP_EXPORT -SCIP_RETCODE GCGsolverSolve( - SCIP* scip, /**< SCIP data structure (master problem) */ - SCIP* pricingprob, /**< the pricing problem that should be solved */ - GCG_SOLVER* solver, /**< pricing solver */ - SCIP_Bool redcost, /**< is reduced cost (TRUE) or Farkas (FALSE) pricing performed? */ - SCIP_Bool heuristic, /**< shall the pricing problem be solved heuristically? */ - int probnr, /**< number of the pricing problem */ - SCIP_Real dualsolconv, /**< dual solution of the corresponding convexity constraint */ - SCIP_Real* lowerbound, /**< pointer to store lower bound of pricing problem */ - GCG_PRICINGSTATUS* status, /**< pointer to store the returned pricing status */ - SCIP_Bool* solved /**< pointer to store whether the solution method was called */ - ); -/**@} */ -#ifdef __cplusplus -} -#endif - -#endif diff --git a/headers/gcg/solver_cliquer.h b/headers/gcg/solver_cliquer.h deleted file mode 100644 index 1664672..0000000 --- a/headers/gcg/solver_cliquer.h +++ /dev/null @@ -1,56 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* */ -/* This file is part of the program */ -/* GCG --- Generic Column Generation */ -/* a Dantzig-Wolfe decomposition based extension */ -/* of the branch-cut-and-price framework */ -/* SCIP --- Solving Constraint Integer Programs */ -/* */ -/* Copyright (C) 2010-2022 Operations Research, RWTH Aachen University */ -/* Zuse Institute Berlin (ZIB) */ -/* */ -/* This program is free software; you can redistribute it and/or */ -/* modify it under the terms of the GNU Lesser General Public License */ -/* as published by the Free Software Foundation; either version 3 */ -/* of the License, or (at your option) any later version. */ -/* */ -/* This program is distributed in the hope that it will be useful, */ -/* but WITHOUT ANY WARRANTY; without even the implied warranty of */ -/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ -/* GNU Lesser General Public License for more details. */ -/* */ -/* You should have received a copy of the GNU Lesser General Public License */ -/* along with this program; if not, write to the Free Software */ -/* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.*/ -/* */ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -/**@file solver_cliquer.h - * @brief heuristic solver for pricing problems that solves independent set problems with cliquer - * @author Henri Lotze - * @author Christian Puchert - * @ingroup PRICINGSOLVERS - */ - -/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/ - -#ifndef GCG_SOLVER_CLIQUER_H__ -#define GCG_SOLVER_CLIQUER_H__ - -#include "scip/scip.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/** creates the cliquer solver for pricing problems and includes it in GCG */ -extern -SCIP_RETCODE GCGincludeSolverCliquer( - SCIP* scip /**< SCIP data structure */ - ); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/headers/gcg/solver_knapsack.h b/headers/gcg/solver_knapsack.h deleted file mode 100644 index 11f08b0..0000000 --- a/headers/gcg/solver_knapsack.h +++ /dev/null @@ -1,55 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* */ -/* This file is part of the program */ -/* GCG --- Generic Column Generation */ -/* a Dantzig-Wolfe decomposition based extension */ -/* of the branch-cut-and-price framework */ -/* SCIP --- Solving Constraint Integer Programs */ -/* */ -/* Copyright (C) 2010-2022 Operations Research, RWTH Aachen University */ -/* Zuse Institute Berlin (ZIB) */ -/* */ -/* This program is free software; you can redistribute it and/or */ -/* modify it under the terms of the GNU Lesser General Public License */ -/* as published by the Free Software Foundation; either version 3 */ -/* of the License, or (at your option) any later version. */ -/* */ -/* This program is distributed in the hope that it will be useful, */ -/* but WITHOUT ANY WARRANTY; without even the implied warranty of */ -/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ -/* GNU Lesser General Public License for more details. */ -/* */ -/* You should have received a copy of the GNU Lesser General Public License */ -/* along with this program; if not, write to the Free Software */ -/* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.*/ -/* */ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -/**@file solver_knapsack.h - * @brief knapsack solver for pricing problems - * @author Gerald Gamrath - * @ingroup PRICINGSOLVERS - */ - -/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/ - -#ifndef GCG_SOLVER_KNAPSACK_H__ -#define GCG_SOLVER_KNAPSACK_H__ - -#include "scip/scip.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/** creates the knapsack solver for pricing problems and includes it in GCG */ -extern -SCIP_RETCODE GCGincludeSolverKnapsack( - SCIP* scip /**< SCIP data structure */ - ); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/headers/gcg/solver_mip.h b/headers/gcg/solver_mip.h deleted file mode 100644 index 79b100c..0000000 --- a/headers/gcg/solver_mip.h +++ /dev/null @@ -1,56 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* */ -/* This file is part of the program */ -/* GCG --- Generic Column Generation */ -/* a Dantzig-Wolfe decomposition based extension */ -/* of the branch-cut-and-price framework */ -/* SCIP --- Solving Constraint Integer Programs */ -/* */ -/* Copyright (C) 2010-2022 Operations Research, RWTH Aachen University */ -/* Zuse Institute Berlin (ZIB) */ -/* */ -/* This program is free software; you can redistribute it and/or */ -/* modify it under the terms of the GNU Lesser General Public License */ -/* as published by the Free Software Foundation; either version 3 */ -/* of the License, or (at your option) any later version. */ -/* */ -/* This program is distributed in the hope that it will be useful, */ -/* but WITHOUT ANY WARRANTY; without even the implied warranty of */ -/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ -/* GNU Lesser General Public License for more details. */ -/* */ -/* You should have received a copy of the GNU Lesser General Public License */ -/* along with this program; if not, write to the Free Software */ -/* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.*/ -/* */ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -/**@file solver_mip.h - * @brief mip solver for pricing problems - * @author Gerald Gamrath - * @ingroup PRICINGSOLVERS - */ - -/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/ - -#ifndef GCG_SOLVER_MIP_H__ -#define GCG_SOLVER_MIP_H__ - -#include "scip/scip.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/** creates the mip solver for pricing problems and includes it in GCG */ -extern -SCIP_RETCODE GCGincludeSolverMip( - SCIP* scip /**< SCIP data structure */ - ); - -#ifdef __cplusplus -} -#endif - - -#endif diff --git a/headers/gcg/solver_xyz.h b/headers/gcg/solver_xyz.h deleted file mode 100644 index 3695591..0000000 --- a/headers/gcg/solver_xyz.h +++ /dev/null @@ -1,54 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* */ -/* This file is part of the program */ -/* GCG --- Generic Column Generation */ -/* a Dantzig-Wolfe decomposition based extension */ -/* of the branch-cut-and-price framework */ -/* SCIP --- Solving Constraint Integer Programs */ -/* */ -/* Copyright (C) 2010-2022 Operations Research, RWTH Aachen University */ -/* Zuse Institute Berlin (ZIB) */ -/* */ -/* This program is free software; you can redistribute it and/or */ -/* modify it under the terms of the GNU Lesser General Public License */ -/* as published by the Free Software Foundation; either version 3 */ -/* of the License, or (at your option) any later version. */ -/* */ -/* This program is distributed in the hope that it will be useful, */ -/* but WITHOUT ANY WARRANTY; without even the implied warranty of */ -/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ -/* GNU Lesser General Public License for more details. */ -/* */ -/* You should have received a copy of the GNU Lesser General Public License */ -/* along with this program; if not, write to the Free Software */ -/* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.*/ -/* */ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -/**@file solver_xyz.c - * @brief xyz solver for pricing problems - * @author Gerald Gamrath - */ - -/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/ - -#ifndef GCG_SOLVER_XYZ_H__ -#define GCG_SOLVER_XYZ_H__ - -#include "scip/scip.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/** creates the Xyz pricing solver and includes it in GCG */ -extern -SCIP_RETCODE GCGincludeSolverXyz( - SCIP* scip /**< SCIP data structure */ - ); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/headers/gcg/stat.h b/headers/gcg/stat.h deleted file mode 100644 index b3356f8..0000000 --- a/headers/gcg/stat.h +++ /dev/null @@ -1,67 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* */ -/* This file is part of the program */ -/* GCG --- Generic Column Generation */ -/* a Dantzig-Wolfe decomposition based extension */ -/* of the branch-cut-and-price framework */ -/* SCIP --- Solving Constraint Integer Programs */ -/* */ -/* Copyright (C) 2010-2022 Operations Research, RWTH Aachen University */ -/* Zuse Institute Berlin (ZIB) */ -/* */ -/* This program is free software; you can redistribute it and/or */ -/* modify it under the terms of the GNU Lesser General Public License */ -/* as published by the Free Software Foundation; either version 3 */ -/* of the License, or (at your option) any later version. */ -/* */ -/* This program is distributed in the hope that it will be useful, */ -/* but WITHOUT ANY WARRANTY; without even the implied warranty of */ -/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ -/* GNU Lesser General Public License for more details. */ -/* */ -/* You should have received a copy of the GNU Lesser General Public License */ -/* along with this program; if not, write to the Free Software */ -/* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.*/ -/* */ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/**@file stat.h - * @ingroup DECOMP - * @brief Prints information about the best decomposition - * @author Alexander Gross - * @author Martin Bergner - */ - -/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/ -#ifndef GCG_STAT_H__ -#define GCG_STAT_H__ - -#include "scip/type_scip.h" -#include "scip/type_retcode.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/** prints information about the best decomposition*/ -extern -SCIP_RETCODE GCGwriteDecompositionData( - SCIP* scip /**< SCIP data structure */ - ); - -/** prints additional information about the solving process */ -extern -SCIP_RETCODE GCGwriteSolvingDetails( - SCIP* scip /**< SCIP data structure */ -); - -/** prints information about the creation of the Vars*/ -extern -SCIP_RETCODE GCGwriteVarCreationDetails( - SCIP* scip /**< SCIP data structure */ -); - - -#ifdef __cplusplus -} -#endif -#endif /* GCG_STAT_H_ */ diff --git a/headers/gcg/struct_branchgcg.h b/headers/gcg/struct_branchgcg.h deleted file mode 100644 index 03d104c..0000000 --- a/headers/gcg/struct_branchgcg.h +++ /dev/null @@ -1,60 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* */ -/* This file is part of the program */ -/* GCG --- Generic Column Generation */ -/* a Dantzig-Wolfe decomposition based extension */ -/* of the branch-cut-and-price framework */ -/* SCIP --- Solving Constraint Integer Programs */ -/* */ -/* Copyright (C) 2010-2022 Operations Research, RWTH Aachen University */ -/* Zuse Institute Berlin (ZIB) */ -/* */ -/* This program is free software; you can redistribute it and/or */ -/* modify it under the terms of the GNU Lesser General Public License */ -/* as published by the Free Software Foundation; either version 3 */ -/* of the License, or (at your option) any later version. */ -/* */ -/* This program is distributed in the hope that it will be useful, */ -/* but WITHOUT ANY WARRANTY; without even the implied warranty of */ -/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ -/* GNU Lesser General Public License for more details. */ -/* */ -/* You should have received a copy of the GNU Lesser General Public License */ -/* along with this program; if not, write to the Free Software */ -/* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.*/ -/* */ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -/**@file struct_branchgcg.h - * @ingroup DATASTRUCTURES - * @brief data structures for branching rules - * @author Gerald Gamrath - */ - -/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/ - -#ifndef GCG_STRUCT_BRANCHGCG_H__ -#define GCG_STRUCT_BRANCHGCG_H__ - -#include "type_branchgcg.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/** branching rule */ -struct GCG_Branchrule -{ - SCIP_BRANCHRULE* branchrule; /**< pointer to the SCIP branching rule */ - GCG_DECL_BRANCHACTIVEMASTER ((*branchactivemaster)); /**< node activation method of branching rule */ - GCG_DECL_BRANCHDEACTIVEMASTER ((*branchdeactivemaster)); /**< node deactivation method of branching rule */ - GCG_DECL_BRANCHPROPMASTER ((*branchpropmaster)); /**< propagation method of branching rule */ - GCG_DECL_BRANCHMASTERSOLVED((*branchmastersolved)); /**< lp solved method of branching rule */ - GCG_DECL_BRANCHDATADELETE ((*branchdatadelete)); /**< deinitialization method of branching rule */ -}; - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/headers/gcg/struct_colpool.h b/headers/gcg/struct_colpool.h deleted file mode 100644 index c442c8c..0000000 --- a/headers/gcg/struct_colpool.h +++ /dev/null @@ -1,76 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* */ -/* This file is part of the program */ -/* GCG --- Generic Column Generation */ -/* a Dantzig-Wolfe decomposition based extension */ -/* of the branch-cut-and-price framework */ -/* SCIP --- Solving Constraint Integer Programs */ -/* */ -/* Copyright (C) 2010-2022 Operations Research, RWTH Aachen University */ -/* Zuse Institute Berlin (ZIB) */ -/* */ -/* This program is free software; you can redistribute it and/or */ -/* modify it under the terms of the GNU Lesser General Public License */ -/* as published by the Free Software Foundation; either version 3 */ -/* of the License, or (at your option) any later version. */ -/* */ -/* This program is distributed in the hope that it will be useful, */ -/* but WITHOUT ANY WARRANTY; without even the implied warranty of */ -/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ -/* GNU Lesser General Public License for more details. */ -/* */ -/* You should have received a copy of the GNU Lesser General Public License */ -/* along with this program; if not, write to the Free Software */ -/* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.*/ -/* */ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -/**@file struct_colpool.h - * @ingroup DATASTRUCTURES - * @brief data structures for storing cols in a col pool - * @author Jonas Witt - */ - -/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/ - -#ifndef __SCIP_STRUCT_COLPOOL_H__ -#define __SCIP_STRUCT_COLPOOL_H__ - - -#include "scip/def.h" -#include "scip/type_clock.h" -#include "scip/type_misc.h" -#include "scip/type_lp.h" -#include "type_colpool.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/** storage for pooled cols */ -struct GCG_Colpool -{ - SCIP* scip; /**< SCIP data structure */ - SCIP_Longint nodenr; /**< node at which columns in colpool respect branching decisions */ - SCIP_Bool infarkas; /**< in Farkas pricing? */ - SCIP_Longint ncalls; /**< number of times, the colpool was separated */ - SCIP_Longint ncolsfound; /**< total number of cols that were separated from the pool */ - SCIP_CLOCK* poolclock; /**< pricing time */ - SCIP_HASHTABLE* hashtable; /**< hash table to identify already stored cols */ - GCG_COL** cols; /**< stored cols of the pool */ - SCIP_Longint processedlp; /**< last LP that has been processed for separating the LP */ - SCIP_Longint processedlpsol; /**< last LP that has been processed for separating other solutions */ - int colssize; /**< size of cols array */ - int ncols; /**< number of cols stored in the pool */ - int agelimit; /**< maximum age a col can reach before it is deleted from the pool */ - int firstunprocessed; /**< first col that has not been processed in the last LP */ - int firstunprocessedsol;/**< first col that has not been processed in the last LP when separating other solutions */ - int maxncols; /**< maximal number of cols stored in the pool at the same time */ - SCIP_Bool globalcolpool; /**< is this the global col pool of SCIP? */ -}; - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/headers/gcg/struct_decomp.h b/headers/gcg/struct_decomp.h deleted file mode 100644 index 6d21018..0000000 --- a/headers/gcg/struct_decomp.h +++ /dev/null @@ -1,102 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* */ -/* This file is part of the program */ -/* GCG --- Generic Column Generation */ -/* a Dantzig-Wolfe decomposition based extension */ -/* of the branch-cut-and-price framework */ -/* SCIP --- Solving Constraint Integer Programs */ -/* */ -/* Copyright (C) 2010-2022 Operations Research, RWTH Aachen University */ -/* Zuse Institute Berlin (ZIB) */ -/* */ -/* This program is free software; you can redistribute it and/or */ -/* modify it under the terms of the GNU Lesser General Public License */ -/* as published by the Free Software Foundation; either version 3 */ -/* of the License, or (at your option) any later version. */ -/* */ -/* This program is distributed in the hope that it will be useful, */ -/* but WITHOUT ANY WARRANTY; without even the implied warranty of */ -/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ -/* GNU Lesser General Public License for more details. */ -/* */ -/* You should have received a copy of the GNU Lesser General Public License */ -/* along with this program; if not, write to the Free Software */ -/* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.*/ -/* */ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -/**@file struct_decomp.h - * @ingroup DECOMP - * @ingroup DATASTRUCTURES - * @brief structure information for decomposition information in GCG projects - * @author Martin Bergner - * @author Michael Bastubbe - */ - -/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/ - -#ifndef GCG_STRUCT_DECOMP_H_ -#define GCG_STRUCT_DECOMP_H_ - - -#include "scip/scip.h" -#include "type_decomp.h" -#include "type_detector.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/** decomposition structure information */ -struct DecDecomp -{ - SCIP_Bool presolved; /**< does the decomposition refer to the presolved problem? */ - int nblocks; /**< number of blocks in this decomposition */ - SCIP_VAR*** subscipvars; /**< two dimensional array of variables in each block - Usage: Usage: subscipvars[b][v] is variable v in block b */ - int* nsubscipvars; /**< array of number of variables in each block - Usage: nsubscipvars[b] is the number of variables of block b */ - SCIP_CONS*** subscipconss; /**< two dimensional array of constraints in each block - Usage: subscipcons[b][c] is constraint c in block b */ - int* nsubscipconss; /**< array of number of constraints in each block - Usage: nsubscipcons[b] is the number of constraints of block b */ - SCIP_CONS** linkingconss; /**< array of constraints linking the blocks - Usage: linkingcons[c] is linking constraint number c */ - int nlinkingconss; /**< number of linking constraints */ - SCIP_VAR** linkingvars; /**< array of variables linking the blocks - Usage: linkingvars[v] is linking variable number v */ - int nlinkingvars; /**< number of linking variables */ - int nfixedlinkingvars; /**< number of linking variables that are fixed */ - int nmastervars; /**< number of linking variables that are purely master variables*/ - SCIP_VAR*** stairlinkingvars; /**< array of variables staircaselinking the blocks */ - int* nstairlinkingvars; /**< number of staircaselinking variables */ - SCIP_HASHMAP* vartoblock; /**< hashmap mapping variables to their blocks (from 1 to nblocks) - Usage: SCIPhashmapGetImage(vartoblock, var) returns b+1, where b is the block of - variable var. This map is somehow inverse of the subscipcvars array. */ - SCIP_HASHMAP* constoblock; /**< hashmap mapping constraints to their blocks (from 1 to nblocks) - Usage: Usage: SCIPhashmapGetImage(constoblock, cons) returns b+1, where b is the block of - constraint cons. This map is somehow inverse of the subscipconss array.*/ - SCIP_HASHMAP* varindex; /**< hashmap mapping variables to indices for a visual ordering */ - SCIP_HASHMAP* consindex; /**< hashmap mapping constraints to indices for visual ordering */ - DEC_DECTYPE type; /**< type of the decomposition */ - DEC_DETECTOR** detectorchain; /**< array of detectors that worked on this decomposition */ - DEC_DETECTOR* detector; /**< detector that found this decomposition */ - int sizedetectorchain; /**< number of detectors that worked on this decomposition */ - int partialdecid; /**< id of the partialdec this decomposition originates from */ - SCIP_Real* detectorclocktimes; /**< times of the detectors that worked on this decomposition */ - SCIP_Real* pctvarstoborder; /**< percentages of variables assigned to the border of the corresponding detectors on this decomposition */ - SCIP_Real* pctconsstoborder; /**< percentages of constraints assigned to the border of the corresponding detectors on this decomposition */ - SCIP_Real* pctvarstoblock; /**< percentages of variables assigned to a block of the corresponding detectors on this decomposition */ - SCIP_Real* pctconsstoblock; /**< percentages of variables assigned to a block of the corresponding detectors on this decomposition */ - SCIP_Real* pctvarsfromopen; /**< percentages of variables assigned to a block or border of the corresponding detectors on this decomposition */ - SCIP_Real* pctconssfromopen; /**< percentages of constraints assigned to a block or the border of the corresponding detectors on this decomposition */ - int* nnewblocks; /**< number of new blocks of the corresponding detectors on this decomposition */ - char* detectorchainstring;/**< string for the detector information working on that decomposition */ - SCIP_Real maxwhitescore; /**< maximum white score (i.e. [fraction of white area] (nonborder+nonblock) ) */ -}; - -#ifdef __cplusplus -} -#endif - -#endif /* STRUCT_DECOMP_H_ */ diff --git a/headers/gcg/struct_detector.h b/headers/gcg/struct_detector.h deleted file mode 100644 index da21f12..0000000 --- a/headers/gcg/struct_detector.h +++ /dev/null @@ -1,83 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* */ -/* This file is part of the program */ -/* GCG --- Generic Column Generation */ -/* a Dantzig-Wolfe decomposition based extension */ -/* of the branch-cut-and-price framework */ -/* SCIP --- Solving Constraint Integer Programs */ -/* */ -/* Copyright (C) 2010-2022 Operations Research, RWTH Aachen University */ -/* Zuse Institute Berlin (ZIB) */ -/* */ -/* This program is free software; you can redistribute it and/or */ -/* modify it under the terms of the GNU Lesser General Public License */ -/* as published by the Free Software Foundation; either version 3 */ -/* of the License, or (at your option) any later version. */ -/* */ -/* This program is distributed in the hope that it will be useful, */ -/* but WITHOUT ANY WARRANTY; without even the implied warranty of */ -/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ -/* GNU Lesser General Public License for more details. */ -/* */ -/* You should have received a copy of the GNU Lesser General Public License */ -/* along with this program; if not, write to the Free Software */ -/* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.*/ -/* */ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -/**@file struct_detector.h - * @ingroup DATASTRUCTURES - * @brief data structures for detectors - * @author Martin Bergner - * @author Christian Puchert - * @author Michael Bastubbe - */ - -/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/ - -#ifndef GCG_STRUCT_DETECTOR_H__ -#define GCG_STRUCT_DETECTOR_H__ - -#include "type_detector.h" - - - -/** detector data structure */ -struct DEC_Detector { - const char* name; /**< name of the detector */ - DEC_DETECTORDATA* decdata; /**< custom data structure of the detectors */ - char decchar; /**< display character of detector */ - const char* description; /**< description of the detector */ - int freqCallRound; /** frequency the detector gets called in detection loop ,ie it is called in round r if and only if minCallRound <= r <= maxCallRound AND (r - minCallRound) mod freqCallRound == 0 */ - int maxCallRound; /** last round the detector gets called */ - int minCallRound; /** first round the detector gets called (offset in detection loop) */ - int freqCallRoundOriginal; /** frequency the detector gets called in detection loop while detecting the original problem */ - int maxCallRoundOriginal; /** last round the detector gets called while detecting the original problem */ - int minCallRoundOriginal; /** first round the detector gets calles (offset in detection loop) while detecting the original problem */ - int priority; /**< detector priority */ - SCIP_Bool enabled; /**< flag to indicate whether detector is enabled */ - SCIP_Bool enabledFinishing; /**< flag to indicate whether finishing is enabled */ - SCIP_Bool enabledPostprocessing; /**< flag to indicate whether finishing is enabled */ - SCIP_Bool skip; /**< should detector be skipped if other detectors found decompositions */ - SCIP_Bool usefulRecall; /** is it useful to call this detector on a descendant of the propagated partialdec */ - SCIP_Bool overruleemphasis; /**< should the emphasis settings be overruled */ - int ndecomps; /**< number of decompositions the detector has worked on */ - int ncompletedecomps; /**< number of complete decompositions the detector has worked on (including decompositions that were finished by other detectors) */ - SCIP_Real dectime; /**< time the detector took to find decompositions */ - - DEC_DECL_FREEDETECTOR((*freeDetector)); /**< destructor of detector */ - DEC_DECL_INITDETECTOR((*initDetector)); /**< initialization method of detector */ - DEC_DECL_EXITDETECTOR((*exitDetector)); /**< deinitialization method of detector */ - DEC_DECL_EXITDETECTOR((*exitDetection)); /**< deinitialization method of detector */ - DEC_DECL_PROPAGATEPARTIALDEC((*propagatePartialdec)); /**< propagation method of detector (or NULL) */ - DEC_DECL_FINISHPARTIALDEC((*finishPartialdec)); /**< finish method of detector (or NULL) */ - DEC_DECL_POSTPROCESSPARTIALDEC((*postprocessPartialdec)); /**< postprocess method of detector (or NULL) */ - DEC_DECL_SETPARAMAGGRESSIVE((*setParamAggressive)); /**< set method for aggressive parameters of detector (or NULL) */ - DEC_DECL_SETPARAMDEFAULT((*setParamDefault)); /**< set method for default parameters of detector (or NULL) */ - DEC_DECL_SETPARAMFAST((*setParamFast)); /**< set method for fast parameters of detector (or NULL) */ - - -}; - - -#endif diff --git a/headers/gcg/struct_gcgcol.h b/headers/gcg/struct_gcgcol.h deleted file mode 100644 index 0714c8c..0000000 --- a/headers/gcg/struct_gcgcol.h +++ /dev/null @@ -1,80 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* */ -/* This file is part of the program */ -/* GCG --- Generic Column Generation */ -/* a Dantzig-Wolfe decomposition based extension */ -/* of the branch-cut-and-price framework */ -/* SCIP --- Solving Constraint Integer Programs */ -/* */ -/* Copyright (C) 2010-2022 Operations Research, RWTH Aachen University */ -/* Zuse Institute Berlin (ZIB) */ -/* */ -/* This program is free software; you can redistribute it and/or */ -/* modify it under the terms of the GNU Lesser General Public License */ -/* as published by the Free Software Foundation; either version 3 */ -/* of the License, or (at your option) any later version. */ -/* */ -/* This program is distributed in the hope that it will be useful, */ -/* but WITHOUT ANY WARRANTY; without even the implied warranty of */ -/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ -/* GNU Lesser General Public License for more details. */ -/* */ -/* You should have received a copy of the GNU Lesser General Public License */ -/* along with this program; if not, write to the Free Software */ -/* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.*/ -/* */ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -/**@file struct_gcgcol.h - * @ingroup DATASTRUCTURES - * @brief data structure to store columns (solutions from a pricing problem) - * @author Jonas Witt - */ - -/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/ - -#ifndef GCG_STRUCT_GCGCOL_H_ -#define GCG_STRUCT_GCGCOL_H_ - -#include "scip/def.h" -#include "scip/type_misc.h" -#include "scip/scip.h" - -#include "type_gcgcol.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/** Column data structure */ -struct GCG_Col -{ - SCIP* pricingprob; /**< SCIP data structure (pricing problem)*/ - int probnr; /**< number of corresponding pricing problem */ - SCIP_VAR** vars; /**< (sorted) array of variables of corresponding pricing problem */ - SCIP_Real* vals; /**< array of solution values (belonging to vars) */ - int nvars; /**< number of variables */ - int maxvars; /**< capacity of vars */ - SCIP_Bool isray; /**< is the column a ray? */ - SCIP_Real redcost; /**< last known reduced cost */ - int age; /**< age of column (number of iterations since it was created; - each time reduced cost are calculated counts as an interation) */ - int pos; /**< position in column pool (or -1) */ - SCIP_Real* mastercoefs; /**< array of master coefficients */ - int nmastercoefs; /**< number of master coefficients */ - int maxmastercoefs; /**< capacity of mastercoefs */ - SCIP_Real* mastercuts; /**< array of master cut coefficients */ - int nmastercuts; /**< number of master cut coefficients */ - int maxmastercuts; /**< capacity of mastercuts */ - SCIP_Real norm; /**< norm of the coefficients in the master */ - int* linkvars; /**< array of indices of variables in var-array which are linking variables */ - int nlinkvars; /**< number of variables in var-array which are linking variables */ - int maxlinkvars; /**< capacity of linkvars */ - SCIP_Bool initcoefs; /**< returns if mastercoefs and linkvars have been computed */ -}; - -#ifdef __cplusplus -} -#endif - -#endif /* STRUCT_GCGCOL_H_ */ diff --git a/headers/gcg/struct_gcgpqueue.h b/headers/gcg/struct_gcgpqueue.h deleted file mode 100644 index 5fb5005..0000000 --- a/headers/gcg/struct_gcgpqueue.h +++ /dev/null @@ -1,72 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* */ -/* This file is part of the program */ -/* GCG --- Generic Column Generation */ -/* a Dantzig-Wolfe decomposition based extension */ -/* of the branch-cut-and-price framework */ -/* SCIP --- Solving Constraint Integer Programs */ -/* */ -/* Copyright (C) 2010-2022 Operations Research, RWTH Aachen University */ -/* Zuse Institute Berlin (ZIB) */ -/* */ -/* This program is free software; you can redistribute it and/or */ -/* modify it under the terms of the GNU Lesser General Public License */ -/* as published by the Free Software Foundation; either version 3 */ -/* of the License, or (at your option) any later version. */ -/* */ -/* This program is distributed in the hope that it will be useful, */ -/* but WITHOUT ANY WARRANTY; without even the implied warranty of */ -/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ -/* GNU Lesser General Public License for more details. */ -/* */ -/* You should have received a copy of the GNU Lesser General Public License */ -/* along with this program; if not, write to the Free Software */ -/* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.*/ -/* */ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -/**@file struct_gcgpqueue.h - * @ingroup DATASTRUCTURES - * @brief data structure for priority queue - * @author Jonas Witt - */ - -/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/ - -#ifndef GCG_STRUCT_GCGPQUEUE_H_ -#define GCG_STRUCT_GCGPQUEUE_H_ - -#include "scip/def.h" -#include "scip/type_misc.h" -#include "scip/scip.h" - -#include "type_gcgpqueue.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/** @brief priority queue data structure - * - * Elements are stored in an array, which grows dynamically in size as new elements are added to the queue. - * The ordering is done through a pointer comparison function. - * The array is organized as follows. The root element (that is the "best" element $r$ with $r <= x$ for all $x$) - * is stored in position 0. The children of an element at position $p$ are stored at positions $q_1 = 2*p+1$ and - * $q_2 = 2*p+2$. That means, the parent of the element at position $q$ is at position $p = (q-1)/2$. - * At any time, the condition holds that $p <= q$ for each parent $p$ and its children $q$. - * Insertion and removal of single elements needs time $O(log n)$. - */ -struct GCG_PQueue -{ - SCIP* scip; /**< SCIP data structure */ - SCIP_DECL_SORTPTRCOMP((*ptrcomp)); /**< compares two data elements */ - void** slots; /**< array of element slots */ - int len; /**< number of used element slots */ - int size; /**< total number of available element slots */ -}; - -#ifdef __cplusplus -} -#endif - -#endif /* STRUCT_GCGPQUEUE_H_ */ diff --git a/headers/gcg/struct_pricestore_gcg.h b/headers/gcg/struct_pricestore_gcg.h deleted file mode 100644 index 1c4d485..0000000 --- a/headers/gcg/struct_pricestore_gcg.h +++ /dev/null @@ -1,81 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* */ -/* This file is part of the program */ -/* GCG --- Generic Column Generation */ -/* a Dantzig-Wolfe decomposition based extension */ -/* of the branch-cut-and-price framework */ -/* SCIP --- Solving Constraint Integer Programs */ -/* */ -/* Copyright (C) 2010-2022 Operations Research, RWTH Aachen University */ -/* Zuse Institute Berlin (ZIB) */ -/* */ -/* This program is free software; you can redistribute it and/or */ -/* modify it under the terms of the GNU Lesser General Public License */ -/* as published by the Free Software Foundation; either version 3 */ -/* of the License, or (at your option) any later version. */ -/* */ -/* This program is distributed in the hope that it will be useful, */ -/* but WITHOUT ANY WARRANTY; without even the implied warranty of */ -/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ -/* GNU Lesser General Public License for more details. */ -/* */ -/* You should have received a copy of the GNU Lesser General Public License */ -/* along with this program; if not, write to the Free Software */ -/* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.*/ -/* */ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -/**@file struct_pricestore_gcg.h - * @ingroup DATASTRUCTURES - * @brief datastructures for storing priced cols - * @author Jonas Witt - */ - -/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/ - -#ifndef __GCG_STRUCT_PRICESTORE_H__ -#define __GCG_STRUCT_PRICESTORE_H__ - - -#include "scip/def.h" -#include "scip/type_lp.h" -#include "scip/type_var.h" -#include "type_pricestore_gcg.h" -#include "pub_gcgcol.h" -#include "type_gcgcol.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/** storage for priced cols */ -struct GCG_PriceStore -{ - SCIP* scip; /**< SCIP data structure */ - GCG_COL** cols; /**< array with priced cols sorted by score */ - SCIP_Real* objparallelisms; /**< parallelism of col to the objective function */ - SCIP_Real* orthogonalities; /**< minimal orthogonality of col with all other cols of larger score */ - SCIP_Real* scores; /**< score for each priced col: weighted sum of efficacy and orthogonality */ - int colssize; /**< size of cols and score arrays */ - int ncols; /**< number of priced cols (max. is set->price_maxcols) */ - int nforcedcols; /**< number of forced priced cols (first positions in cols array) */ - int nefficaciouscols; /**< number of improving priced cols */ - int ncolsfound; /**< total number of cols found so far */ - int ncolsfoundround; /**< number of cols found so far in this pricing round */ - int ncolsapplied; /**< total number of cols applied to the LPs */ - SCIP_Bool infarkas; /**< is the price storage currently being filled with the columns from farkas pricing? */ - SCIP_Bool forcecols; /**< should the cols be used despite the number of cols parameter limit? */ - SCIP_Real efficiacyfac; /**< factor of efficiacy in score function */ - SCIP_Real objparalfac; /**< factor of objective parallelism in score function */ - SCIP_Real orthofac; /**< factor of orthogonalities in score function */ - SCIP_Real mincolorth; /**< minimal orthogonality of columns to add - (with respect to columns added in the current round) */ - SCIP_CLOCK* priceclock; /**< pricing time */ - GCG_EFFICIACYCHOICE efficiacychoice; /**< choice to base efficiacy on */ -}; - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/headers/gcg/struct_pricingjob.h b/headers/gcg/struct_pricingjob.h deleted file mode 100644 index b23d666..0000000 --- a/headers/gcg/struct_pricingjob.h +++ /dev/null @@ -1,69 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* */ -/* This file is part of the program */ -/* GCG --- Generic Column Generation */ -/* a Dantzig-Wolfe decomposition based extension */ -/* of the branch-cut-and-price framework */ -/* SCIP --- Solving Constraint Integer Programs */ -/* */ -/* Copyright (C) 2010-2022 Operations Research, RWTH Aachen University */ -/* Zuse Institute Berlin (ZIB) */ -/* */ -/* This program is free software; you can redistribute it and/or */ -/* modify it under the terms of the GNU Lesser General Public License */ -/* as published by the Free Software Foundation; either version 3 */ -/* of the License, or (at your option) any later version. */ -/* */ -/* This program is distributed in the hope that it will be useful, */ -/* but WITHOUT ANY WARRANTY; without even the implied warranty of */ -/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ -/* GNU Lesser General Public License for more details. */ -/* */ -/* You should have received a copy of the GNU Lesser General Public License */ -/* along with this program; if not, write to the Free Software */ -/* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.*/ -/* */ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -/**@file struct_pricingjob.h - * @ingroup DATASTRUCTURES - * @brief data structure for pricing jobs - * @author Christian Puchert - */ - -/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/ - -#ifndef GCG_STRUCT_PRICINGJOB_H_ -#define GCG_STRUCT_PRICINGJOB_H_ - -#include "scip/def.h" -#include "scip/type_misc.h" -#include "scip/scip.h" - -#include "type_pricingjob.h" -#include "type_pricingprob.h" -#include "type_solver.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/** pricing job data structure */ -struct GCG_PricingJob -{ - /* problem data */ - GCG_PRICINGPROB* pricingprob; /**< data structure of the corresponding pricing problem */ - GCG_SOLVER* solver; /**< solver with which to solve the pricing problem */ - - /* strategic parameters */ - int chunk; /**< chunk the pricing job belongs to */ - SCIP_Real score; /**< current score of the pricing job */ - SCIP_Bool heuristic; /**< shall the pricing problem be solved heuristically? */ - int nheuriters; /**< number of times the pricing job was performed heuristically */ -}; - -#ifdef __cplusplus -} -#endif - -#endif /* STRUCT_PRICINGJOB_H_ */ diff --git a/headers/gcg/struct_pricingprob.h b/headers/gcg/struct_pricingprob.h deleted file mode 100644 index 09cedb7..0000000 --- a/headers/gcg/struct_pricingprob.h +++ /dev/null @@ -1,81 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* */ -/* This file is part of the program */ -/* GCG --- Generic Column Generation */ -/* a Dantzig-Wolfe decomposition based extension */ -/* of the branch-cut-and-price framework */ -/* SCIP --- Solving Constraint Integer Programs */ -/* */ -/* Copyright (C) 2010-2022 Operations Research, RWTH Aachen University */ -/* Zuse Institute Berlin (ZIB) */ -/* */ -/* This program is free software; you can redistribute it and/or */ -/* modify it under the terms of the GNU Lesser General Public License */ -/* as published by the Free Software Foundation; either version 3 */ -/* of the License, or (at your option) any later version. */ -/* */ -/* This program is distributed in the hope that it will be useful, */ -/* but WITHOUT ANY WARRANTY; without even the implied warranty of */ -/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ -/* GNU Lesser General Public License for more details. */ -/* */ -/* You should have received a copy of the GNU Lesser General Public License */ -/* along with this program; if not, write to the Free Software */ -/* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.*/ -/* */ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -/**@file struct_pricingprob.h - * @ingroup DATASTRUCTURES - * @brief data structure to store pricing problem information - * @author Christian Puchert - */ - -/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/ - -#ifndef GCG_STRUCT_PRICINGPROB_H_ -#define GCG_STRUCT_PRICINGPROB_H_ - -#include "scip/def.h" -#include "scip/type_misc.h" -#include "scip/scip.h" - -#include "type_pricingprob.h" -#include "type_gcgcol.h" -#include "type_solver.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/** pricing problem data structure */ -struct GCG_PricingProb -{ - /* problem data */ - SCIP* pricingscip; /**< SCIP data structure */ - int probnr; /**< (block) index of the corresponding pricing problem */ - - /* generic branching information */ - SCIP_CONS** branchconss; /**< stack of generic branching constraints */ - SCIP_Real* branchduals; /**< corresponding dual solution values */ - int nbranchconss; /**< number of generic branching constraints */ - int branchconsssize; /**< size of generic branching constraints array */ - int branchconsidx; /**< lowest index generic branching constraint that is considered */ - SCIP_Bool consisadded; /**< flag to indicate whether this constraint has already been added */ - - /* result values */ - GCG_PRICINGSTATUS status; /**< current status of the pricing problem */ - SCIP_Real lowerbound; /**< lower bound obtained by solving the pricing problem */ - int nimpcols; /**< number of improving columns found in the current pricing round */ - - /* statistics */ - int nsolves; /**< number of times the pricing problem was solved during the loop */ - int* ncolsround; /**< number of improving columns found in the last rounds */ - int maxcolsround; /**< capacity of ncolsround */ -}; - -#ifdef __cplusplus -} -#endif - -#endif /* STRUCT_PRICINGPROB_H_ */ diff --git a/headers/gcg/struct_solver.h b/headers/gcg/struct_solver.h deleted file mode 100644 index e1f5384..0000000 --- a/headers/gcg/struct_solver.h +++ /dev/null @@ -1,79 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* */ -/* This file is part of the program */ -/* GCG --- Generic Column Generation */ -/* a Dantzig-Wolfe decomposition based extension */ -/* of the branch-cut-and-price framework */ -/* SCIP --- Solving Constraint Integer Programs */ -/* */ -/* Copyright (C) 2010-2022 Operations Research, RWTH Aachen University */ -/* Zuse Institute Berlin (ZIB) */ -/* */ -/* This program is free software; you can redistribute it and/or */ -/* modify it under the terms of the GNU Lesser General Public License */ -/* as published by the Free Software Foundation; either version 3 */ -/* of the License, or (at your option) any later version. */ -/* */ -/* This program is distributed in the hope that it will be useful, */ -/* but WITHOUT ANY WARRANTY; without even the implied warranty of */ -/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ -/* GNU Lesser General Public License for more details. */ -/* */ -/* You should have received a copy of the GNU Lesser General Public License */ -/* along with this program; if not, write to the Free Software */ -/* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.*/ -/* */ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -/**@file struct_solver.h - * @ingroup DATASTRUCTURES - * @brief data structures for solvers - * @author Gerald Gamrath - */ - -/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/ - -#ifndef GCG_STRUCT_SOLVER_H__ -#define GCG_STRUCT_SOLVER_H__ - -#include "type_solver.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/** pricing problem solver data structure */ -struct GCG_Solver -{ - char* name; /**< solver name */ - char* desc; /**< solver description */ - int priority; /**< solver priority */ - SCIP_Bool heurenabled; /**< switch for heuristic solving method */ - SCIP_Bool exactenabled; /**< switch for exact solving method */ - GCG_SOLVERDATA* solverdata; /**< private solver data structure */ - - GCG_DECL_SOLVERFREE((*solverfree)); /**< destruction method */ - GCG_DECL_SOLVERINIT((*solverinit)); /**< initialization method */ - GCG_DECL_SOLVEREXIT((*solverexit)); /**< deinitialization method */ - GCG_DECL_SOLVERINITSOL((*solverinitsol)); /**< solving process initialization method */ - GCG_DECL_SOLVEREXITSOL((*solverexitsol)); /**< solving process deinitialization method */ - GCG_DECL_SOLVERUPDATE((*solverupdate)); /**< update method */ - GCG_DECL_SOLVERSOLVE((*solversolve)); /**< solving callback method */ - GCG_DECL_SOLVERSOLVEHEUR((*solversolveheur)); /**< heuristic solving callback method */ - - SCIP_CLOCK* optfarkasclock; /**< optimal farkas pricing time */ - SCIP_CLOCK* optredcostclock; /**< optimal reduced cost pricing time */ - SCIP_CLOCK* heurfarkasclock; /**< heuristic farkas pricing time */ - SCIP_CLOCK* heurredcostclock; /**< heuristic reduced cost pricing time */ - int optfarkascalls; /**< optimal farkas pricing calls */ - int optredcostcalls; /**< optimal reduced cost pricing calls */ - int heurfarkascalls; /**< heuristic farkas pricing calls */ - int heurredcostcalls; /**< heuristic reduced cost pricing calls */ -}; - - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/headers/gcg/struct_vardata.h b/headers/gcg/struct_vardata.h deleted file mode 100644 index a596647..0000000 --- a/headers/gcg/struct_vardata.h +++ /dev/null @@ -1,129 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* */ -/* This file is part of the program */ -/* GCG --- Generic Column Generation */ -/* a Dantzig-Wolfe decomposition based extension */ -/* of the branch-cut-and-price framework */ -/* SCIP --- Solving Constraint Integer Programs */ -/* */ -/* Copyright (C) 2010-2022 Operations Research, RWTH Aachen University */ -/* Zuse Institute Berlin (ZIB) */ -/* */ -/* This program is free software; you can redistribute it and/or */ -/* modify it under the terms of the GNU Lesser General Public License */ -/* as published by the Free Software Foundation; either version 3 */ -/* of the License, or (at your option) any later version. */ -/* */ -/* This program is distributed in the hope that it will be useful, */ -/* but WITHOUT ANY WARRANTY; without even the implied warranty of */ -/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ -/* GNU Lesser General Public License for more details. */ -/* */ -/* You should have received a copy of the GNU Lesser General Public License */ -/* along with this program; if not, write to the Free Software */ -/* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.*/ -/* */ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -/**@file struct_vardata.h - * @ingroup DATASTRUCTURES - * @brief data structures for GCG variable data - * @author Gerald Gamrath - * @author Martin Bergner - */ - -/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/ - -#ifndef GCG_STRUCT_VARDATA_H__ -#define GCG_STRUCT_VARDATA_H__ - -#ifdef __cplusplus -extern "C" { -#endif - -/** type of the variable */ -enum GCG_Vartype -{ - GCG_VARTYPE_ORIGINAL = 0, /**< variable belongs to original problem */ - GCG_VARTYPE_PRICING = 1, /**< variable belongs to a pricing problem */ - GCG_VARTYPE_MASTER = 2 /**< variable belongs to the master problem */ -}; -typedef enum GCG_Vartype GCG_VARTYPE; - -/** additional data for linking variables */ -struct GCG_LinkingVarData -{ - SCIP_VAR** pricingvars; /**< array of corresponding variables in the pricing programs (NULL if variable is not linking this block)*/ - SCIP_CONS** linkconss; /**< array of constraints in the master problem that ensure that all copies have the same values */ - int nblocks; /**< number of blocks that this variable is linking */ -}; -typedef struct GCG_LinkingVarData GCG_LINKINGVARDATA; - - -/** data for original variables */ -struct GCG_OrigVarData -{ - SCIP_VAR* pricingvar; /**< corresponding variable in the pricing program */ - SCIP_CONS** masterconss; /**< master constraints of the original program in which the variable has a nonzero entry */ - SCIP_Real* coefs; /**< coefficients in the linking constraints of the original program */ - int ncoefs; /**< number of coefficients */ - SCIP_VAR** mastervars; /**< variables in the master problem that contain the variable */ - SCIP_Real* mastervals; /**< value of this variable in the master problem variables */ - int nmastervars; /**< number of corresponding master variables */ - int maxmastervars; /**< length of arrays mastervars and vals */ - GCG_LINKINGVARDATA* linkingvardata; /**< additional data for linking variables */ -}; -typedef struct GCG_OrigVarData GCG_ORIGVARDATA; - -/** data for pricing variables */ -struct GCG_PricingVarData -{ - SCIP_VAR** origvars; /**< corresponding variables in the original program */ - int norigvars; /**< number of corresponding variables in the original program */ - int maxorigvars; /**< length of origvars array */ -}; -typedef struct GCG_PricingVarData GCG_PRICINGVARDATA; - - -/** data for master variables */ -struct GCG_MasterVarData -{ - int norigvars; /**< number of variables in the original program corresponding to the current variable */ - int maxorigvars; /**< capacity of origvars and origvals */ - SCIP_VAR** origvars; /**< variables in the original program corresponding to the current variable */ - SCIP_Real* origvals; /**< this variable represents vals[i] times the variable origvars[i] in the - * original program */ - SCIP_Bool isray; /**< does this variable represent a ray or an extreme point? */ - SCIP_Bool isartificial; /**< is variable artificial? */ - SCIP_HASHMAP* origvar2val; /**< hash map that stores the fraction of original variables the master variable is contained in */ - int index; /**< index of the master variable if stored in GCG's pricedvars array, -1 otherwise */ -}; -typedef struct GCG_MasterVarData GCG_MASTERVARDATA; - -/** variable data structure */ -struct SCIP_VarData -{ - union - { - GCG_ORIGVARDATA origvardata; /**< data for original variables */ - GCG_PRICINGVARDATA pricingvardata; /**< data for pricing variables */ - GCG_MASTERVARDATA mastervardata; /**< data for variable of the master problem */ - } data; - GCG_VARTYPE vartype; /**< type of variable */ - int blocknr; /**< number of the block and pricing problem, the variable belongs to, - * or -1 if variable is directly transferred to the master problem, - * or -2 if variable is a linking variable */ - SCIP_Longint creationnode; /**< node where the variable is created */ - SCIP_Longint rootredcostcall; /**< pricing reduced cost call when the variable is created - * (-1 if variable was not created at the root node or was created in Farkas pricing) */ - SCIP_Real creationtime; /**< time when the variable is created */ - SCIP_Longint iteration; /**< iteration when the variable is created */ - SCIP_Real gap; /**< gap when the variable was created */ - SCIP_Real redcost; /**< reduced cost of the variable */ -}; - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/headers/gcg/type_branchgcg.h b/headers/gcg/type_branchgcg.h deleted file mode 100644 index fb89dc7..0000000 --- a/headers/gcg/type_branchgcg.h +++ /dev/null @@ -1,120 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* */ -/* This file is part of the program */ -/* GCG --- Generic Column Generation */ -/* a Dantzig-Wolfe decomposition based extension */ -/* of the branch-cut-and-price framework */ -/* SCIP --- Solving Constraint Integer Programs */ -/* */ -/* Copyright (C) 2010-2022 Operations Research, RWTH Aachen University */ -/* Zuse Institute Berlin (ZIB) */ -/* */ -/* This program is free software; you can redistribute it and/or */ -/* modify it under the terms of the GNU Lesser General Public License */ -/* as published by the Free Software Foundation; either version 3 */ -/* of the License, or (at your option) any later version. */ -/* */ -/* This program is distributed in the hope that it will be useful, */ -/* but WITHOUT ANY WARRANTY; without even the implied warranty of */ -/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ -/* GNU Lesser General Public License for more details. */ -/* */ -/* You should have received a copy of the GNU Lesser General Public License */ -/* along with this program; if not, write to the Free Software */ -/* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.*/ -/* */ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -/**@file type_branchgcg.h - * @ingroup TYPEDEFINITIONS - * @brief type definitions for branching rules in GCG projects - * @author Gerald Gamrath - */ - -/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/ - -#ifndef GCG_TYPE_BRANCHGCG_H__ -#define GCG_TYPE_BRANCHGCG_H__ - -#include "scip/def.h" -#include "scip/type_result.h" -#include "scip/type_scip.h" - -#ifdef __cplusplus -extern "C" { -#endif - -typedef struct GCG_BranchData GCG_BRANCHDATA; /**< branching data */ -typedef struct GCG_Branchrule GCG_BRANCHRULE; /**< branching rule */ - -/** type of variable bound: lower or upper bound */ -enum GCG_BoundType -{ - GCG_BOUNDTYPE_LOWER = 0, /**< lower bound */ - GCG_BOUNDTYPE_UPPER = 1, /**< upper bound */ - GCG_BOUNDTYPE_FIXED = 2, /**< variable fixed */ - GCG_BOUNDTYPE_NONE = 3 /**< no bound */ -}; -typedef enum GCG_BoundType GCG_BOUNDTYPE; - -/** activation method for branchrule, called when a node in the master problem is activated, - * should perform changes to the current node's problem due to the branchdata - * - * input: - * - scip : SCIP main data structure of the master problem - * - branchdata : the branching data - */ -#define GCG_DECL_BRANCHACTIVEMASTER(x) SCIP_RETCODE x (SCIP* scip, GCG_BRANCHDATA* branchdata) - -/** deactivation method for branchrule, called when a node in the master problem is deactivated, - * should undo changes to the current node's problem due to the branchdata - * - * input: - * - scip : SCIP main data structure of the master problem - * - branchdata : the branching data - */ -#define GCG_DECL_BRANCHDEACTIVEMASTER(x) SCIP_RETCODE x (SCIP* scip, GCG_BRANCHDATA* branchdata) - -/** propagation method for branchrule, called when a node in the master problem is propagated, - * should perform propagation at the current node due to the branchdata - * - * input: - * - scip : SCIP main data structure of the master problem - * - branchdata : the branching data - * - node : the activated node - * - result : pointer to store the result of the propagation call - * - * possible return values for *result: - * - SCIP_CUTOFF : the node is infeasible in the variable's bounds and can be cut off - * - SCIP_REDUCEDDOM : at least one domain reduction was found - * - SCIP_DIDNOTFIND : the propagator searched but did not find any domain reductions - * - SCIP_DIDNOTRUN : the propagator was skipped - * - SCIP_DELAYED : the propagator was skipped, but should be called again - - */ -#define GCG_DECL_BRANCHPROPMASTER(x) SCIP_RETCODE x (SCIP* scip, GCG_BRANCHDATA* branchdata, SCIP_RESULT* result) - -/** method for branchrule, called when the master LP is solved at one node, - * can store pseudocosts for the branching decisions - * - * input: - * - scip : SCIP main data structure of the original problem - * - branchdata : the branching data - * - newlowerbound : the new local lower bound - * - */ -#define GCG_DECL_BRANCHMASTERSOLVED(x) SCIP_RETCODE x (SCIP* scip, GCG_BRANCHDATA* branchdata, SCIP_Real newlowerbound) - -/** frees branching data of an origbranch constraint (called when the origbranch constraint is deleted) - * - * input: - * scip : SCIP main data structure of the original problem - * branchdata : pointer to the branching data to free - */ -#define GCG_DECL_BRANCHDATADELETE(x) SCIP_RETCODE x (SCIP* scip, GCG_BRANCHDATA** branchdata) - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/headers/gcg/type_classifier.h b/headers/gcg/type_classifier.h deleted file mode 100644 index b6a7382..0000000 --- a/headers/gcg/type_classifier.h +++ /dev/null @@ -1,53 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* */ -/* This file is part of the program */ -/* GCG --- Generic Column Generation */ -/* a Dantzig-Wolfe decomposition based extension */ -/* of the branch-cut-and-price framework */ -/* SCIP --- Solving Constraint Integer Programs */ -/* */ -/* Copyright (C) 2010-2022 Operations Research, RWTH Aachen University */ -/* Zuse Institute Berlin (ZIB) */ -/* */ -/* This program is free software; you can redistribute it and/or */ -/* modify it under the terms of the GNU Lesser General Public License */ -/* as published by the Free Software Foundation; either version 3 */ -/* of the License, or (at your option) any later version. */ -/* */ -/* This program is distributed in the hope that it will be useful, */ -/* but WITHOUT ANY WARRANTY; without even the implied warranty of */ -/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ -/* GNU Lesser General Public License for more details. */ -/* */ -/* You should have received a copy of the GNU Lesser General Public License */ -/* along with this program; if not, write to the Free Software */ -/* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.*/ -/* */ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -/**@file type_classifier.h - * @ingroup TYPEDEFINITIONS - * @brief type definitions for classifier in GCG project - * @author Stefanie Koß - */ - -/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/ - -#ifndef GCG_TYPE_CLASSIFIER_H__ -#define GCG_TYPE_CLASSIFIER_H__ - -//#include "scip/type_scip.h" - -#ifdef __cplusplus -extern "C" { -#endif - - -typedef struct DEC_ClassifierData DEC_CLASSIFIERDATA; /**< CLASSIFIER data */ - - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/headers/gcg/type_colpool.h b/headers/gcg/type_colpool.h deleted file mode 100644 index 87c1f36..0000000 --- a/headers/gcg/type_colpool.h +++ /dev/null @@ -1,49 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* */ -/* This file is part of the program */ -/* GCG --- Generic Column Generation */ -/* a Dantzig-Wolfe decomposition based extension */ -/* of the branch-cut-and-price framework */ -/* SCIP --- Solving Constraint Integer Programs */ -/* */ -/* Copyright (C) 2010-2022 Operations Research, RWTH Aachen University */ -/* Zuse Institute Berlin (ZIB) */ -/* */ -/* This program is free software; you can redistribute it and/or */ -/* modify it under the terms of the GNU Lesser General Public License */ -/* as published by the Free Software Foundation; either version 3 */ -/* of the License, or (at your option) any later version. */ -/* */ -/* This program is distributed in the hope that it will be useful, */ -/* but WITHOUT ANY WARRANTY; without even the implied warranty of */ -/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ -/* GNU Lesser General Public License for more details. */ -/* */ -/* You should have received a copy of the GNU Lesser General Public License */ -/* along with this program; if not, write to the Free Software */ -/* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.*/ -/* */ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -/**@file type_colpool.h - * @ingroup TYPEDEFINITIONS - * @brief type definitions for storing cols in a col pool - * @author Jonas Witt - */ - -/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/ - -#ifndef __SCIP_TYPE_COLPOOL_H__ -#define __SCIP_TYPE_COLPOOL_H__ - -#ifdef __cplusplus -extern "C" { -#endif - -typedef struct GCG_Colpool GCG_COLPOOL; /**< storage for pooled cols */ - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/headers/gcg/type_consclassifier.h b/headers/gcg/type_consclassifier.h deleted file mode 100644 index ad9d0ee..0000000 --- a/headers/gcg/type_consclassifier.h +++ /dev/null @@ -1,64 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* */ -/* This file is part of the program */ -/* GCG --- Generic Column Generation */ -/* a Dantzig-Wolfe decomposition based extension */ -/* of the branch-cut-and-price framework */ -/* SCIP --- Solving Constraint Integer Programs */ -/* */ -/* Copyright (C) 2010-2022 Operations Research, RWTH Aachen University */ -/* Zuse Institute Berlin (ZIB) */ -/* */ -/* This program is free software; you can redistribute it and/or */ -/* modify it under the terms of the GNU Lesser General Public License */ -/* as published by the Free Software Foundation; either version 3 */ -/* of the License, or (at your option) any later version. */ -/* */ -/* This program is distributed in the hope that it will be useful, */ -/* but WITHOUT ANY WARRANTY; without even the implied warranty of */ -/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ -/* GNU Lesser General Public License for more details. */ -/* */ -/* You should have received a copy of the GNU Lesser General Public License */ -/* along with this program; if not, write to the Free Software */ -/* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.*/ -/* */ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -/**@file type_consclassifier.h - * @ingroup TYPEDEFINITIONS - * @brief type definitions for constraints classifier in GCG projects - * @author William Ma - */ - -#ifndef GCG_TYPE_CONSCLASSIFIER_H__ -#define GCG_TYPE_CONSCLASSIFIER_H__ - -#include -#include "scip/type_retcode.h" -#include "scip/type_scip.h" -#include "scip/type_result.h" -#include "type_classifier.h" - -typedef struct DEC_ConsClassifier DEC_CONSCLASSIFIER; - - -/** destructor of classifier to free classifier data (called when GCG is exiting) - * - * input: - * - scip : SCIP main data structure - * - classifier : classifier data structure - */ -#define DEC_DECL_FREECONSCLASSIFIER(x) SCIP_RETCODE x (SCIP* scip, DEC_CONSCLASSIFIER* classifier) - -/** - * Tries to classify constraints with data of the according detprobdata and store the classification in the detprobdata - * - * input: - * - scip : SCIP data structure - * - transformed : should use data from transformed detprobdata or not - */ -#define DEC_DECL_CONSCLASSIFY(x) SCIP_RETCODE x (SCIP* scip, SCIP_Bool transformed) - - -#endif //GCG_TYPE_CONSCLASSIFIER_H__ diff --git a/headers/gcg/type_decomp.h b/headers/gcg/type_decomp.h deleted file mode 100644 index dc7101d..0000000 --- a/headers/gcg/type_decomp.h +++ /dev/null @@ -1,74 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* */ -/* This file is part of the program */ -/* GCG --- Generic Column Generation */ -/* a Dantzig-Wolfe decomposition based extension */ -/* of the branch-cut-and-price framework */ -/* SCIP --- Solving Constraint Integer Programs */ -/* */ -/* Copyright (C) 2010-2022 Operations Research, RWTH Aachen University */ -/* Zuse Institute Berlin (ZIB) */ -/* */ -/* This program is free software; you can redistribute it and/or */ -/* modify it under the terms of the GNU Lesser General Public License */ -/* as published by the Free Software Foundation; either version 3 */ -/* of the License, or (at your option) any later version. */ -/* */ -/* This program is distributed in the hope that it will be useful, */ -/* but WITHOUT ANY WARRANTY; without even the implied warranty of */ -/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ -/* GNU Lesser General Public License for more details. */ -/* */ -/* You should have received a copy of the GNU Lesser General Public License */ -/* along with this program; if not, write to the Free Software */ -/* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.*/ -/* */ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -/**@file type_decomp.h - * @ingroup DECOMP - * @ingroup TYPEDEFINITIONS - * @brief type definitions for decomposition information in GCG projects - * @author Martin Bergner - */ - -/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/ - -#ifndef GCG_TYPE_DECOMP_H__ -#define GCG_TYPE_DECOMP_H__ - -#ifdef __cplusplus -extern "C" { -#endif - -typedef struct DecDecomp DEC_DECOMP; /**< decomposition structure */ - -/** type of the decomposition */ -enum Dectype -{ - DEC_DECTYPE_UNKNOWN = 0, /**< unknown structure (used for initialization) */ - DEC_DECTYPE_ARROWHEAD = 1, /**< arrowhead structure (linking variables and constraints) */ - DEC_DECTYPE_STAIRCASE = 2, /**< staircase structure (linking variables between consecutive blocks) */ - DEC_DECTYPE_DIAGONAL = 3, /**< block diagonal structure (no linking variables and constraints) */ - DEC_DECTYPE_BORDERED = 4 /**< bordered block diagonal structure (linking constraints only) */ -}; - -typedef enum Dectype DEC_DECTYPE; /**< decomposition type */ - -/** the decomposition mode */ -enum Decmode -{ - DEC_DECMODE_DANTZIGWOLFE = 0, /**< Datizig-Wolfe reformulation */ - DEC_DECMODE_BENDERS = 1, /**< Benders' decomposition */ - DEC_DECMODE_ORIGINAL = 2, /**< the original problem will be solved without decomposition */ - DEC_DECMODE_AUTO = 3, /**< the best of either Dantzig-Wolfe or Benders' will be applied */ - DEC_DECMODE_UNKNOWN = 4 /**< the mode can not be determined from the given information */ -}; - -typedef enum Decmode DEC_DECMODE; /**< decomposition mode */ - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/headers/gcg/type_detector.h b/headers/gcg/type_detector.h deleted file mode 100644 index 85a7086..0000000 --- a/headers/gcg/type_detector.h +++ /dev/null @@ -1,176 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* */ -/* This file is part of the program */ -/* GCG --- Generic Column Generation */ -/* a Dantzig-Wolfe decomposition based extension */ -/* of the branch-cut-and-price framework */ -/* SCIP --- Solving Constraint Integer Programs */ -/* */ -/* Copyright (C) 2010-2022 Operations Research, RWTH Aachen University */ -/* Zuse Institute Berlin (ZIB) */ -/* */ -/* This program is free software; you can redistribute it and/or */ -/* modify it under the terms of the GNU Lesser General Public License */ -/* as published by the Free Software Foundation; either version 3 */ -/* of the License, or (at your option) any later version. */ -/* */ -/* This program is distributed in the hope that it will be useful, */ -/* but WITHOUT ANY WARRANTY; without even the implied warranty of */ -/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ -/* GNU Lesser General Public License for more details. */ -/* */ -/* You should have received a copy of the GNU Lesser General Public License */ -/* along with this program; if not, write to the Free Software */ -/* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.*/ -/* */ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -/**@file type_detector.h - * @ingroup TYPEDEFINITIONS - * @brief type definitions for detectors in GCG projects - * @author Martin Bergner - * @author Christian Puchert - */ - -/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/ - -#ifndef GCG_TYPE_DETECTOR_H__ -#define GCG_TYPE_DETECTOR_H__ - -#include "scip/type_retcode.h" -#include "scip/type_scip.h" -#include "scip/type_result.h" -#include "type_decomp.h" - - -typedef struct DEC_Detector DEC_DETECTOR; -typedef struct DEC_DetectorData DEC_DETECTORDATA; - - -struct Partialdec_Detection_Data; -typedef struct Partialdec_Detection_Data PARTIALDEC_DETECTION_DATA; - - -/** destructor of detector to free user data (called when GCG is exiting) - * - * input: - * - scip : SCIP main data structure - * - detector : detector data structure - */ -#define DEC_DECL_FREEDETECTOR(x) SCIP_RETCODE x (SCIP* scip, DEC_DETECTOR* detector) - -/** - * detector initialization method (called after problem was transformed) - * It can be used to fill the detector data with needed information. The implementation is optional. - * - * input: - * - scip : SCIP data structure - * - detector : detector data structure - */ -#define DEC_DECL_INITDETECTOR(x) SCIP_RETCODE x (SCIP* scip, DEC_DETECTOR* detector) - -/** - * detector deinitialization method (called before the transformed problem is freed) - * It can be used to clean up the data created in DEC_DECL_INITDETECTOR. The implementation is optional. - * - * input: - * - scip : SCIP data structure - * - detector : detector data structure - */ -#define DEC_DECL_EXITDETECTOR(x) SCIP_RETCODE x (SCIP* scip, DEC_DETECTOR* detector) - - -/** - * given a partialdec (incomplete decomposition) the detector - * tries to find refined partialdec and stores it - * - * input: - * - scip : SCIP data structure - * - detector : pointer to detector - * - partialdecdetectiondata : pointer to partialdec propagation data structure - * - result : pointer where to store the result - * - * possible return values for result: - * - SCIP_SUCCESS : the method completed and found decompositions - * - SCIP_DIDNOTFIND : the method completed without finding a decomposition - * - SCIP_DIDNOTRUN : the method did not run - */ -#define DEC_DECL_PROPAGATEPARTIALDEC(x) SCIP_RETCODE x (SCIP* scip, DEC_DETECTOR* detector, PARTIALDEC_DETECTION_DATA* partialdecdetectiondata, SCIP_RESULT* result) - - -/** - * given a partialdec (incomplete decomposition) the detector - * tries to find finished partialdecs and stores them - * - * input: - * - scip : SCIP data structure - * - detector : pointer to detector - * - partialdecdetectiondata : pointer to partialdec propagation data structure - * - result : pointer where to store the result - * - * possible return values for result: - * - SCIP_SUCCESS : the method completed and found decompositions - * - SCIP_DIDNOTFIND : the method completed without finding a decomposition - * - SCIP_DIDNOTRUN : the method did not run - */ -#define DEC_DECL_FINISHPARTIALDEC(x) SCIP_RETCODE x (SCIP* scip, DEC_DETECTOR* detector, PARTIALDEC_DETECTION_DATA* partialdecdetectiondata, SCIP_RESULT* result) - -/** - * given a complete partialdec (complete decomposition) the detector - * postprocess the partialdec in order to find a different yet promising partialdec - * - * input: - * - scip : SCIP data structure - * - detector : pointer to detector - * - partialdecdetectiondata : pointer to partialdec propagation data structure - * - result : pointer where to store the result - * - * possible return values for result: - * - SCIP_SUCCESS : the method completed and found decompositions - * - SCIP_DIDNOTFIND : the method completed without finding a decomposition - * - SCIP_DIDNOTRUN : the method did not run - */ -#define DEC_DECL_POSTPROCESSPARTIALDEC(x) SCIP_RETCODE x (SCIP* scip, DEC_DETECTOR* detector, PARTIALDEC_DETECTION_DATA* partialdecdetectiondata, SCIP_RESULT* result) - -/** - * set the parameter of a detector to values according to fast emphasis and size of the instance - * input: - * - scip : SCIP data structure - * - detector : pointer to detector - * - result : pointer where to store the result - * - * possible return values for result: - * - SCIP_SUCCESS : the method completed - * - SCIP_DIDNOTRUN : the method did not run - */ -#define DEC_DECL_SETPARAMFAST(x) SCIP_RETCODE x (SCIP* scip, DEC_DETECTOR* detector, SCIP_RESULT* result) - -/** - * set the parameter of a detector to values according to aggressive emphasis and size of the instance - * input: - * - scip : SCIP data structure - * - detector : pointer to detector - * - result : pointer where to store the result - * - * possible return values for result: - * - SCIP_SUCCESS : the method completed - * - SCIP_DIDNOTRUN : the method did not run - */ -#define DEC_DECL_SETPARAMAGGRESSIVE(x) SCIP_RETCODE x (SCIP* scip, DEC_DETECTOR* detector, SCIP_RESULT* result) - -/** - * set the parameter of a detector to values according to default emphasis and size of the instance - * input: - * - scip : SCIP data structure - * - detector : pointer to detector - * - result : pointer where to store the result - * - * possible return values for result: - * - SCIP_SUCCESS : the method completed - * - SCIP_DIDNOTRUN : the method did not run - */ -#define DEC_DECL_SETPARAMDEFAULT(x) SCIP_RETCODE x (SCIP* scip, DEC_DETECTOR* detector, SCIP_RESULT* result) - - - -#endif diff --git a/headers/gcg/type_gcgcol.h b/headers/gcg/type_gcgcol.h deleted file mode 100644 index a328d4e..0000000 --- a/headers/gcg/type_gcgcol.h +++ /dev/null @@ -1,51 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* */ -/* This file is part of the program */ -/* GCG --- Generic Column Generation */ -/* a Dantzig-Wolfe decomposition based extension */ -/* of the branch-cut-and-price framework */ -/* SCIP --- Solving Constraint Integer Programs */ -/* */ -/* Copyright (C) 2010-2022 Operations Research, RWTH Aachen University */ -/* Zuse Institute Berlin (ZIB) */ -/* */ -/* This program is free software; you can redistribute it and/or */ -/* modify it under the terms of the GNU Lesser General Public License */ -/* as published by the Free Software Foundation; either version 3 */ -/* of the License, or (at your option) any later version. */ -/* */ -/* This program is distributed in the hope that it will be useful, */ -/* but WITHOUT ANY WARRANTY; without even the implied warranty of */ -/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ -/* GNU Lesser General Public License for more details. */ -/* */ -/* You should have received a copy of the GNU Lesser General Public License */ -/* along with this program; if not, write to the Free Software */ -/* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.*/ -/* */ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -/**@file type_gcgcol.h - * @ingroup TYPEDEFINITIONS - * @brief type definitions for gcg column data structure - * @author Jonas Witt - */ - -/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/ - -#ifndef GCG_TYPE_GCGCOL_H__ -#define GCG_TYPE_GCGCOL_H__ - -#include "struct_gcgcol.h" - -#ifdef __cplusplus -extern "C" { -#endif - -typedef struct GCG_Col GCG_COL; /**< data structure to store colums (solutions of a pricing problem) */ - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/headers/gcg/type_gcgpqueue.h b/headers/gcg/type_gcgpqueue.h deleted file mode 100644 index 01ba929..0000000 --- a/headers/gcg/type_gcgpqueue.h +++ /dev/null @@ -1,49 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* */ -/* This file is part of the program */ -/* GCG --- Generic Column Generation */ -/* a Dantzig-Wolfe decomposition based extension */ -/* of the branch-cut-and-price framework */ -/* SCIP --- Solving Constraint Integer Programs */ -/* */ -/* Copyright (C) 2010-2022 Operations Research, RWTH Aachen University */ -/* Zuse Institute Berlin (ZIB) */ -/* */ -/* This program is free software; you can redistribute it and/or */ -/* modify it under the terms of the GNU Lesser General Public License */ -/* as published by the Free Software Foundation; either version 3 */ -/* of the License, or (at your option) any later version. */ -/* */ -/* This program is distributed in the hope that it will be useful, */ -/* but WITHOUT ANY WARRANTY; without even the implied warranty of */ -/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ -/* GNU Lesser General Public License for more details. */ -/* */ -/* You should have received a copy of the GNU Lesser General Public License */ -/* along with this program; if not, write to the Free Software */ -/* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.*/ -/* */ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -/**@file type_gcgpqueue.h - * @ingroup TYPEDEFINITIONS - * @brief type definitions for priority queue - * @author Jonas Witt - */ - -/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/ - -#ifndef GCG_TYPE_GCGPQUEUE_H__ -#define GCG_TYPE_GCGPQUEUE_H__ - -#ifdef __cplusplus -extern "C" { -#endif - -typedef struct GCG_PQueue GCG_PQUEUE; /**< priority queue */ - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/headers/gcg/type_masterdiving.h b/headers/gcg/type_masterdiving.h deleted file mode 100644 index ef1c33a..0000000 --- a/headers/gcg/type_masterdiving.h +++ /dev/null @@ -1,134 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* */ -/* This file is part of the program */ -/* GCG --- Generic Column Generation */ -/* a Dantzig-Wolfe decomposition based extension */ -/* of the branch-cut-and-price framework */ -/* SCIP --- Solving Constraint Integer Programs */ -/* */ -/* Copyright (C) 2010-2022 Operations Research, RWTH Aachen University */ -/* Zuse Institute Berlin (ZIB) */ -/* */ -/* This program is free software; you can redistribute it and/or */ -/* modify it under the terms of the GNU Lesser General Public License */ -/* as published by the Free Software Foundation; either version 3 */ -/* of the License, or (at your option) any later version. */ -/* */ -/* This program is distributed in the hope that it will be useful, */ -/* but WITHOUT ANY WARRANTY; without even the implied warranty of */ -/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ -/* GNU Lesser General Public License for more details. */ -/* */ -/* You should have received a copy of the GNU Lesser General Public License */ -/* along with this program; if not, write to the Free Software */ -/* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.*/ -/* */ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -/**@file type_masterdiving.h - * @ingroup TYPEDEFINITIONS - * @brief type definitions for GCG diving heuristics on the master variables - * @author Christian Puchert - */ - -/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/ - -#ifndef __SCIP_TYPE_MASTERDIVING_H__ -#define __SCIP_TYPE_MASTERDIVING_H__ - -#include "scip/type_scip.h" - -#ifdef __cplusplus -extern "C" { -#endif - -typedef struct GCG_DivingData GCG_DIVINGDATA; /**< locally defined diving data */ - - -/** destructor of diving heuristic to free user data (called when GCG is exiting) - * - * input: - * - scip : SCIP main data structure - * - heur : the diving heuristic itself - */ -#define GCG_DECL_DIVINGFREE(x) SCIP_RETCODE x (SCIP* scip, SCIP_HEUR* heur) - -/** initialization method of diving heuristic (called after problem was transformed) - * - * input: - * - scip : SCIP main data structure - * - heur : the diving heuristic itself - */ -#define GCG_DECL_DIVINGINIT(x) SCIP_RETCODE x (SCIP* scip, SCIP_HEUR* heur) - -/** deinitialization method of diving heuristic (called before transformed problem is freed) - * - * input: - * - scip : SCIP main data structure - * - heur : the diving heuristic itself - */ -#define GCG_DECL_DIVINGEXIT(x) SCIP_RETCODE x (SCIP* scip, SCIP_HEUR* heur) - -/** solving process initialization method of diving heuristic (called when branch and bound process is about to begin) - * - * This method is called when the presolving was finished and the branch and bound process is about to begin. - * The diving heuristic may use this call to initialize its branch and bound specific data. - * - * input: - * - scip : SCIP main data structure - * - heur : the diving heuristic itself - */ -#define GCG_DECL_DIVINGINITSOL(x) SCIP_RETCODE x (SCIP* scip, SCIP_HEUR* heur) - -/** solving process deinitialization method of primal heuristic (called before branch and bound process data is freed) - * - * This method is called before the branch and bound process is freed. - * The diving heuristic should use this call to clean up its branch and bound data. - * - * input: - * - scip : SCIP main data structure - * - heur : the diving heuristic itself - */ -#define GCG_DECL_DIVINGEXITSOL(x) SCIP_RETCODE x (SCIP* scip, SCIP_HEUR* heur) - -/** execution initialization method of diving heuristic (called when execution of diving heuristic is about to begin) - * - * This method is called when the execution of the diving heuristic starts, before the diving loop. - * The diving heuristic may use this call to collect data which is specific to this call of the heuristic. - * - * input: - * - scip : SCIP main data structure - * - heur : the diving heuristic itself - */ -#define GCG_DECL_DIVINGINITEXEC(x) SCIP_RETCODE x (SCIP* scip, SCIP_HEUR* heur) - -/** execution deinitialization method of diving heuristic (called when execution data is freed) - * - * This method is called before the execution of the heuristic stops. - * The diving heuristic should use this call to clean up its execution specific data. - * - * input: - * - scip : SCIP main data structure - * - heur : the diving heuristic itself - */ -#define GCG_DECL_DIVINGEXITEXEC(x) SCIP_RETCODE x (SCIP* scip, SCIP_HEUR* heur) - -/** variable selection method of diving heuristic - * - * Selects an original variable to dive on - * - * input: - * - scip : SCIP main data structure - * - heur : the diving heuristic itself - * - tabulist : an array containing variables that must not be chosen - * - tabulistsize : the size of the array - * - bestcand : pointer to store the SCIP_VAR* returned by the selection rule - * - bestcandmayround : pointer to store whether the variable may be rounded without losing LP feasibility - */ -#define GCG_DECL_DIVINGSELECTVAR(x) SCIP_RETCODE x (SCIP* scip, SCIP_HEUR* heur, SCIP_VAR** tabulist, int tabulistsize, SCIP_VAR** bestcand, SCIP_Bool* bestcandmayround) - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/headers/gcg/type_origdiving.h b/headers/gcg/type_origdiving.h deleted file mode 100644 index 4424ec5..0000000 --- a/headers/gcg/type_origdiving.h +++ /dev/null @@ -1,135 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* */ -/* This file is part of the program */ -/* GCG --- Generic Column Generation */ -/* a Dantzig-Wolfe decomposition based extension */ -/* of the branch-cut-and-price framework */ -/* SCIP --- Solving Constraint Integer Programs */ -/* */ -/* Copyright (C) 2010-2022 Operations Research, RWTH Aachen University */ -/* Zuse Institute Berlin (ZIB) */ -/* */ -/* This program is free software; you can redistribute it and/or */ -/* modify it under the terms of the GNU Lesser General Public License */ -/* as published by the Free Software Foundation; either version 3 */ -/* of the License, or (at your option) any later version. */ -/* */ -/* This program is distributed in the hope that it will be useful, */ -/* but WITHOUT ANY WARRANTY; without even the implied warranty of */ -/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ -/* GNU Lesser General Public License for more details. */ -/* */ -/* You should have received a copy of the GNU Lesser General Public License */ -/* along with this program; if not, write to the Free Software */ -/* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.*/ -/* */ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -/**@file type_origdiving.h - * @ingroup TYPEDEFINITIONS - * @brief type definitions for GCG diving heuristics on the original variables - * @author Christian Puchert - */ - -/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/ - -#ifndef __SCIP_TYPE_ORIGDIVING_H__ -#define __SCIP_TYPE_ORIGDIVING_H__ - -#include "scip/type_scip.h" - -#ifdef __cplusplus -extern "C" { -#endif - -typedef struct GCG_DivingData GCG_DIVINGDATA; /**< locally defined diving data */ - - -/** destructor of diving heuristic to free user data (called when GCG is exiting) - * - * input: - * - scip : SCIP main data structure - * - heur : the diving heuristic itself - */ -#define GCG_DECL_DIVINGFREE(x) SCIP_RETCODE x (SCIP* scip, SCIP_HEUR* heur) - -/** initialization method of diving heuristic (called after problem was transformed) - * - * input: - * - scip : SCIP main data structure - * - heur : the diving heuristic itself - */ -#define GCG_DECL_DIVINGINIT(x) SCIP_RETCODE x (SCIP* scip, SCIP_HEUR* heur) - -/** deinitialization method of diving heuristic (called before transformed problem is freed) - * - * input: - * - scip : SCIP main data structure - * - heur : the diving heuristic itself - */ -#define GCG_DECL_DIVINGEXIT(x) SCIP_RETCODE x (SCIP* scip, SCIP_HEUR* heur) - -/** solving process initialization method of diving heuristic (called when branch and bound process is about to begin) - * - * This method is called when the presolving was finished and the branch and bound process is about to begin. - * The diving heuristic may use this call to initialize its branch and bound specific data. - * - * input: - * - scip : SCIP main data structure - * - heur : the diving heuristic itself - */ -#define GCG_DECL_DIVINGINITSOL(x) SCIP_RETCODE x (SCIP* scip, SCIP_HEUR* heur) - -/** solving process deinitialization method of primal heuristic (called before branch and bound process data is freed) - * - * This method is called before the branch and bound process is freed. - * The diving heuristic should use this call to clean up its branch and bound data. - * - * input: - * - scip : SCIP main data structure - * - heur : the diving heuristic itself - */ -#define GCG_DECL_DIVINGEXITSOL(x) SCIP_RETCODE x (SCIP* scip, SCIP_HEUR* heur) - -/** execution initialization method of diving heuristic (called when execution of diving heuristic is about to begin) - * - * This method is called when the execution of the diving heuristic starts, before the diving loop. - * The diving heuristic may use this call to collect data which is specific to this call of the heuristic. - * - * input: - * - scip : SCIP main data structure - * - heur : the diving heuristic itself - */ -#define GCG_DECL_DIVINGINITEXEC(x) SCIP_RETCODE x (SCIP* scip, SCIP_HEUR* heur) - -/** execution deinitialization method of diving heuristic (called when execution data is freed) - * - * This method is called before the execution of the heuristic stops. - * The diving heuristic should use this call to clean up its execution specific data. - * - * input: - * - scip : SCIP main data structure - * - heur : the diving heuristic itself - */ -#define GCG_DECL_DIVINGEXITEXEC(x) SCIP_RETCODE x (SCIP* scip, SCIP_HEUR* heur) - -/** variable selection method of diving heuristic - * - * Selects a master variable to dive on - * - * input: - * - scip : SCIP main data structure - * - heur : the diving heuristic itself - * - tabulist : an array containing variables that must not be chosen - * - tabulistsize : the size of the array - * - bestcand : pointer to store the SCIP_VAR* returned by the selection rule - * - bestcandmayround : pointer to store whether the variable may be rounded without losing LP feasibility - * - bestcandroundup : pointer to store whether the variable is to be rounded up - */ -#define GCG_DECL_DIVINGSELECTVAR(x) SCIP_RETCODE x (SCIP* scip, SCIP_HEUR* heur, SCIP_VAR** tabulist, int tabulistsize, SCIP_VAR** bestcand, SCIP_Bool* bestcandmayround, SCIP_Bool* bestcandroundup) - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/headers/gcg/type_parameter.h b/headers/gcg/type_parameter.h deleted file mode 100644 index 92eb98c..0000000 --- a/headers/gcg/type_parameter.h +++ /dev/null @@ -1,53 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* */ -/* This file is part of the program */ -/* GCG --- Generic Column Generation */ -/* a Dantzig-Wolfe decomposition based extension */ -/* of the branch-cut-and-price framework */ -/* SCIP --- Solving Constraint Integer Programs */ -/* */ -/* Copyright (C) 2010-2022 Operations Research, RWTH Aachen University */ -/* Zuse Institute Berlin (ZIB) */ -/* */ -/* This program is free software; you can redistribute it and/or */ -/* modify it under the terms of the GNU Lesser General Public License */ -/* as published by the Free Software Foundation; either version 3 */ -/* of the License, or (at your option) any later version. */ -/* */ -/* This program is distributed in the hope that it will be useful, */ -/* but WITHOUT ANY WARRANTY; without even the implied warranty of */ -/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ -/* GNU Lesser General Public License for more details. */ -/* */ -/* You should have received a copy of the GNU Lesser General Public License */ -/* along with this program; if not, write to the Free Software */ -/* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.*/ -/* */ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -/**@file type_parameter.h - * @ingroup TYPEDEFINITIONS - * @brief type definitions for parameters in GCG project - * @author Hanna Franzen - */ - -/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/ - -#ifndef GCG_TYPE_PARAMETER_H__ -#define GCG_TYPE_PARAMETER_H__ - -#include "scip/type_scip.h" - -#ifdef __cplusplus -extern "C" { -#endif - - -typedef struct GCG_ParamData GCG_PARAMDATA; /**< PARAMETER data */ - - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/headers/gcg/type_pricestore_gcg.h b/headers/gcg/type_pricestore_gcg.h deleted file mode 100644 index a8498ac..0000000 --- a/headers/gcg/type_pricestore_gcg.h +++ /dev/null @@ -1,58 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* */ -/* This file is part of the program */ -/* GCG --- Generic Column Generation */ -/* a Dantzig-Wolfe decomposition based extension */ -/* of the branch-cut-and-price framework */ -/* SCIP --- Solving Constraint Integer Programs */ -/* */ -/* Copyright (C) 2010-2022 Operations Research, RWTH Aachen University */ -/* Zuse Institute Berlin (ZIB) */ -/* */ -/* This program is free software; you can redistribute it and/or */ -/* modify it under the terms of the GNU Lesser General Public License */ -/* as published by the Free Software Foundation; either version 3 */ -/* of the License, or (at your option) any later version. */ -/* */ -/* This program is distributed in the hope that it will be useful, */ -/* but WITHOUT ANY WARRANTY; without even the implied warranty of */ -/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ -/* GNU Lesser General Public License for more details. */ -/* */ -/* You should have received a copy of the GNU Lesser General Public License */ -/* along with this program; if not, write to the Free Software */ -/* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.*/ -/* */ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -/**@file type_pricestore_gcg.h - * @ingroup TYPEDEFINITIONS - * @brief type definitions for storing priced cols - * @author Jonas Witt - */ - -/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/ - -#ifndef __GCG_TYPE_PRICESTORE_H__ -#define __GCG_TYPE_PRICESTORE_H__ - -#ifdef __cplusplus -extern "C" { -#endif - -/** possible settings for specifying the solution for which cuts are selected */ -enum GCG_Efficiacychoice -{ - GCG_EFFICIACYCHOICE_DANTZIG = 0, /**< use Dantzig's rule (reduced cost) to base efficacy on */ - GCG_EFFICIACYCHOICE_STEEPESTEDGE = 1, /**< use steepest edge rule s( to base efficacy on */ - GCG_EFFICIACYCHOICE_LAMBDA = 2 /**< use lambda pricing to base efficacy on */ -}; -typedef enum GCG_Efficiacychoice GCG_EFFICIACYCHOICE; - -typedef struct GCG_PriceStore GCG_PRICESTORE; /**< storage for priced variables */ - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/headers/gcg/type_pricingjob.h b/headers/gcg/type_pricingjob.h deleted file mode 100644 index ed098be..0000000 --- a/headers/gcg/type_pricingjob.h +++ /dev/null @@ -1,51 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* */ -/* This file is part of the program */ -/* GCG --- Generic Column Generation */ -/* a Dantzig-Wolfe decomposition based extension */ -/* of the branch-cut-and-price framework */ -/* SCIP --- Solving Constraint Integer Programs */ -/* */ -/* Copyright (C) 2010-2022 Operations Research, RWTH Aachen University */ -/* Zuse Institute Berlin (ZIB) */ -/* */ -/* This program is free software; you can redistribute it and/or */ -/* modify it under the terms of the GNU Lesser General Public License */ -/* as published by the Free Software Foundation; either version 3 */ -/* of the License, or (at your option) any later version. */ -/* */ -/* This program is distributed in the hope that it will be useful, */ -/* but WITHOUT ANY WARRANTY; without even the implied warranty of */ -/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ -/* GNU Lesser General Public License for more details. */ -/* */ -/* You should have received a copy of the GNU Lesser General Public License */ -/* along with this program; if not, write to the Free Software */ -/* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.*/ -/* */ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -/**@file type_pricingjob.h - * @ingroup TYPEDEFINITIONS - * @brief type definitions for pricing job data structure - * @author Christian Puchert - */ - -/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/ - -#ifndef GCG_TYPE_PRICINGJOB_H__ -#define GCG_TYPE_PRICINGJOB_H__ - -#include "struct_pricingjob.h" - -#ifdef __cplusplus -extern "C" { -#endif - -typedef struct GCG_PricingJob GCG_PRICINGJOB; /**< data structure to store pricing jobs */ - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/headers/gcg/type_pricingprob.h b/headers/gcg/type_pricingprob.h deleted file mode 100644 index 9c90d6a..0000000 --- a/headers/gcg/type_pricingprob.h +++ /dev/null @@ -1,51 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* */ -/* This file is part of the program */ -/* GCG --- Generic Column Generation */ -/* a Dantzig-Wolfe decomposition based extension */ -/* of the branch-cut-and-price framework */ -/* SCIP --- Solving Constraint Integer Programs */ -/* */ -/* Copyright (C) 2010-2022 Operations Research, RWTH Aachen University */ -/* Zuse Institute Berlin (ZIB) */ -/* */ -/* This program is free software; you can redistribute it and/or */ -/* modify it under the terms of the GNU Lesser General Public License */ -/* as published by the Free Software Foundation; either version 3 */ -/* of the License, or (at your option) any later version. */ -/* */ -/* This program is distributed in the hope that it will be useful, */ -/* but WITHOUT ANY WARRANTY; without even the implied warranty of */ -/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ -/* GNU Lesser General Public License for more details. */ -/* */ -/* You should have received a copy of the GNU Lesser General Public License */ -/* along with this program; if not, write to the Free Software */ -/* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.*/ -/* */ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -/**@file type_pricingprob.h - * @ingroup TYPEDEFINITIONS - * @brief type definitions for pricing problem data structure - * @author Christian Puchert - */ - -/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/ - -#ifndef GCG_TYPE_PRICINGPROB_H__ -#define GCG_TYPE_PRICINGPROB_H__ - -#include "struct_pricingprob.h" - -#ifdef __cplusplus -extern "C" { -#endif - -typedef struct GCG_PricingProb GCG_PRICINGPROB; /**< data structure to store pricing problem information */ - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/headers/gcg/type_pricingstatus.h b/headers/gcg/type_pricingstatus.h deleted file mode 100644 index 8d862aa..0000000 --- a/headers/gcg/type_pricingstatus.h +++ /dev/null @@ -1,63 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* */ -/* This file is part of the program */ -/* GCG --- Generic Column Generation */ -/* a Dantzig-Wolfe decomposition based extension */ -/* of the branch-cut-and-price framework */ -/* SCIP --- Solving Constraint Integer Programs */ -/* */ -/* Copyright (C) 2010-2022 Operations Research, RWTH Aachen University */ -/* Zuse Institute Berlin (ZIB) */ -/* */ -/* This program is free software; you can redistribute it and/or */ -/* modify it under the terms of the GNU Lesser General Public License */ -/* as published by the Free Software Foundation; either version 3 */ -/* of the License, or (at your option) any later version. */ -/* */ -/* This program is distributed in the hope that it will be useful, */ -/* but WITHOUT ANY WARRANTY; without even the implied warranty of */ -/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ -/* GNU Lesser General Public License for more details. */ -/* */ -/* You should have received a copy of the GNU Lesser General Public License */ -/* along with this program; if not, write to the Free Software */ -/* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.*/ -/* */ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -/**@file type_pricingstatus.h - * @ingroup TYPEDEFINITIONS - * @brief type definitions for pricing status - * @author Christian Puchert - */ - -/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/ - -#ifndef __GCG_TYPE_PRICINGSTATUS_H__ -#define __GCG_TYPE_PRICINGSTATUS_H__ - -#ifdef __cplusplus -extern "C" { -#endif - -/** GCG pricing status */ -enum GCG_PricingStatus -{ - GCG_PRICINGSTATUS_UNKNOWN = 0, /**< the pricing solver terminated with an unknown status; - * feasible columns might have been found, but it is not known - * whether the pricing problem has been solved to optimality - */ - GCG_PRICINGSTATUS_NOTAPPLICABLE = 1, /**< the pricing solver can not be applied on the pricing problem */ - GCG_PRICINGSTATUS_SOLVERLIMIT = 2, /**< a solver specific limit was reached, and the solver can be called again */ - GCG_PRICINGSTATUS_OPTIMAL = 3, /**< the pricing problem was solved to optimality, an optimal solution is available */ - - GCG_PRICINGSTATUS_INFEASIBLE = 4, /**< the problem was proven to be infeasible */ - GCG_PRICINGSTATUS_UNBOUNDED = 5 /**< the problem was proven to be unbounded */ -}; -typedef enum GCG_PricingStatus GCG_PRICINGSTATUS; - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/headers/gcg/type_scoretype.h b/headers/gcg/type_scoretype.h deleted file mode 100644 index 758605f..0000000 --- a/headers/gcg/type_scoretype.h +++ /dev/null @@ -1,69 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* */ -/* This file is part of the program */ -/* GCG --- Generic Column Generation */ -/* a Dantzig-Wolfe decomposition based extension */ -/* of the branch-cut-and-price framework */ -/* SCIP --- Solving Constraint Integer Programs */ -/* */ -/* Copyright (C) 2010-2022 Operations Research, RWTH Aachen University */ -/* Zuse Institute Berlin (ZIB) */ -/* */ -/* This program is free software; you can redistribute it and/or */ -/* modify it under the terms of the GNU Lesser General Public License */ -/* as published by the Free Software Foundation; either version 3 */ -/* of the License, or (at your option) any later version. */ -/* */ -/* This program is distributed in the hope that it will be useful, */ -/* but WITHOUT ANY WARRANTY; without even the implied warranty of */ -/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ -/* GNU Lesser General Public License for more details. */ -/* */ -/* You should have received a copy of the GNU Lesser General Public License */ -/* along with this program; if not, write to the Free Software */ -/* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.*/ -/* */ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -/**@file type_scoretype.h - * @ingroup DECOMP - * @brief type definition for score type - * @author Michael Bastubbe - * @author Hanna Franzen - */ - -/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/ - -#ifndef __GCG_TYPE_SCORETYPE_H__ -#define __GCG_TYPE_SCORETYPE_H__ - -#ifdef __cplusplus -extern "C" { -#endif - -/** GCG score type for (partial) decomposition evaluation */ -/*! - * \brief possible scores to evaluate founds decompositions - * \sa GCGscoretypeGetDescription for a description of this score - * \sa GCGscoretypeGetShortName - * \sa class_partialdecomp:getScore() - */ -enum scoretype { - /* Note: Please ensure that this enum is compatible with the arrays in scoretype.c! */ - MAX_WHITE = 0, - BORDER_AREA = 1, - CLASSIC = 2, - MAX_FORESSEEING_WHITE = 3, - SETPART_FWHITE = 4, - MAX_FORESEEING_AGG_WHITE = 5, - SETPART_AGG_FWHITE = 6, - BENDERS = 7, - STRONG_DECOMP = 8 -}; -typedef enum scoretype SCORETYPE; - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/headers/gcg/type_solver.h b/headers/gcg/type_solver.h deleted file mode 100644 index 44f078b..0000000 --- a/headers/gcg/type_solver.h +++ /dev/null @@ -1,140 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* */ -/* This file is part of the program */ -/* GCG --- Generic Column Generation */ -/* a Dantzig-Wolfe decomposition based extension */ -/* of the branch-cut-and-price framework */ -/* SCIP --- Solving Constraint Integer Programs */ -/* */ -/* Copyright (C) 2010-2022 Operations Research, RWTH Aachen University */ -/* Zuse Institute Berlin (ZIB) */ -/* */ -/* This program is free software; you can redistribute it and/or */ -/* modify it under the terms of the GNU Lesser General Public License */ -/* as published by the Free Software Foundation; either version 3 */ -/* of the License, or (at your option) any later version. */ -/* */ -/* This program is distributed in the hope that it will be useful, */ -/* but WITHOUT ANY WARRANTY; without even the implied warranty of */ -/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ -/* GNU Lesser General Public License for more details. */ -/* */ -/* You should have received a copy of the GNU Lesser General Public License */ -/* along with this program; if not, write to the Free Software */ -/* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.*/ -/* */ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -/**@file type_solver.h - * @ingroup TYPEDEFINITIONS - * @brief type definitions for pricing problem solvers in GCG project - * @author Gerald Gamrath - * @author Christian Puchert - */ - -/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/ - -#ifndef GCG_TYPE_SOLVER_H__ -#define GCG_TYPE_SOLVER_H__ - -#include "scip/def.h" -#include "scip/type_scip.h" -#include "type_gcgcol.h" -#include "type_pricingstatus.h" - -#ifdef __cplusplus -extern "C" { -#endif - -typedef struct GCG_SolverData GCG_SOLVERDATA; /**< solver data */ -typedef struct GCG_Solver GCG_SOLVER; /**< the solver */ - - -/** destructor of pricing solver to free user data (called when GCG is exiting) - * - * input: - * - scip : SCIP main data structure (master problem) - * - solver : the pricing solver itself - */ -#define GCG_DECL_SOLVERFREE(x) SCIP_RETCODE x (SCIP* scip, GCG_SOLVER* solver) - -/** initialization method of pricing solver (called after problem was transformed and solver is active) - * - * input: - * - scip : SCIP main data structure (master problem) - * - solver : the pricing solver itself - */ -#define GCG_DECL_SOLVERINIT(x) SCIP_RETCODE x (SCIP* scip, GCG_SOLVER* solver) - -/** deinitialization method of pricing solver (called before transformed problem is freed and solver is active) - * - * input: - * - scip : SCIP main data structure (master problem) - * - solver : the pricing solver itself - */ -#define GCG_DECL_SOLVEREXIT(x) SCIP_RETCODE x (SCIP* scip, GCG_SOLVER* solver) - -/** solving process initialization method of pricing solver (called when branch and bound process is about to begin) - * - * This method is called when the presolving was finished and the branch and bound process is about to begin. - * The pricing solver may use this call to initialize its branch and bound specific data. - * - * input: - * - scip : SCIP main data structure (master problem) - * - solver : the pricing solver itself - */ -#define GCG_DECL_SOLVERINITSOL(x) SCIP_RETCODE x (SCIP* scip, GCG_SOLVER* solver) - -/** solving process deinitialization method of pricing solver (called before branch and bound process data is freed) - * - * This method is called before the branch and bound process is freed. - * The pricing solver should use this call to clean up its branch and bound data. - * - * input: - * - scip : SCIP main data structure (master problem) - * - solver : the pricing solver itself - */ -#define GCG_DECL_SOLVEREXITSOL(x) SCIP_RETCODE x (SCIP* scip, GCG_SOLVER* solver) - -/** - * update method for pricing solver, used to update solver specific pricing problem data - * - * The pricing solver may use this method to update its own representation of the pricing problem, - * i.e. to apply changes on variable objectives and bounds and to apply branching constraints - */ -#define GCG_DECL_SOLVERUPDATE(x) SCIP_RETCODE x (SCIP* pricingprob, GCG_SOLVER* solver, int probnr, SCIP_Bool varobjschanged, SCIP_Bool varbndschanged, SCIP_Bool consschanged) - -/** solving method for pricing solver which solves the pricing problem to optimality - * - * - * input: - * - scip : SCIP main data structure (master problem) - * - pricingprob : the pricing problem that should be solved - * - solver : the pricing solver itself - * - probnr : number of the pricing problem - * - dualsolconv : dual solution of the corresponding convexity constraint - * - lowerbound : pointer to store lower bound of pricing problem - * - status : pointer to store the pricing status - */ -#define GCG_DECL_SOLVERSOLVE(x) SCIP_RETCODE x (SCIP* scip, SCIP* pricingprob, GCG_SOLVER* solver, int probnr, SCIP_Real dualsolconv, SCIP_Real* lowerbound, GCG_PRICINGSTATUS* status) - -/** solving method for pricing solver using heuristic pricing only - * - * - * input: - * - scip : SCIP main data structure (master problem) - * - pricingprob : the pricing problem that should be solved - * - solver : the pricing solver itself - * - probnr : number of the pricing problem - * - dualsolconv : dual solution of the corresponding convexity constraint - * - lowerbound : pointer to store lower bound of pricing problem - * - status : pointer to store the pricing status - */ -#define GCG_DECL_SOLVERSOLVEHEUR(x) SCIP_RETCODE x (SCIP* scip, SCIP* pricingprob, GCG_SOLVER* solver, int probnr, SCIP_Real dualsolconv, SCIP_Real* lowerbound, GCG_PRICINGSTATUS* status) - - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/headers/gcg/type_varclassifier.h b/headers/gcg/type_varclassifier.h deleted file mode 100644 index c4f02bd..0000000 --- a/headers/gcg/type_varclassifier.h +++ /dev/null @@ -1,62 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* */ -/* This file is part of the program */ -/* GCG --- Generic Column Generation */ -/* a Dantzig-Wolfe decomposition based extension */ -/* of the branch-cut-and-price framework */ -/* SCIP --- Solving Constraint Integer Programs */ -/* */ -/* Copyright (C) 2010-2022 Operations Research, RWTH Aachen University */ -/* Zuse Institute Berlin (ZIB) */ -/* */ -/* This program is free software; you can redistribute it and/or */ -/* modify it under the terms of the GNU Lesser General Public License */ -/* as published by the Free Software Foundation; either version 3 */ -/* of the License, or (at your option) any later version. */ -/* */ -/* This program is distributed in the hope that it will be useful, */ -/* but WITHOUT ANY WARRANTY; without even the implied warranty of */ -/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ -/* GNU Lesser General Public License for more details. */ -/* */ -/* You should have received a copy of the GNU Lesser General Public License */ -/* along with this program; if not, write to the Free Software */ -/* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.*/ -/* */ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -/**@file type_varclassifier.h - * @ingroup TYPEDEFINITIONS - * @brief type definitions for variable classifier in GCG projects - * @author William Ma - */ - -#ifndef GCG_TYPE_VARCLASSIFIER_H__ -#define GCG_TYPE_VARCLASSIFIER_H__ - -#include -#include "scip/type_retcode.h" -#include "scip/type_scip.h" -#include "scip/type_result.h" -#include "type_classifier.h" - -typedef struct DEC_VarClassifier DEC_VARCLASSIFIER; - -/** destructor of classifier to free classifier data (called when GCG is exiting) - * - * input: - * - scip : SCIP main data structure - * - classifier : classifier data structure - */ -#define DEC_DECL_FREEVARCLASSIFIER(x) SCIP_RETCODE x (SCIP* scip, DEC_VARCLASSIFIER* classifier) - -/** - * Tries to classify variables with data of the according detprobdata and store the classification in the detprobdata - * - * input: - * - scip : SCIP data structure - * - transformed : should use data from transformed detprobdata or not - */ -#define DEC_DECL_VARCLASSIFY(x) SCIP_RETCODE x (SCIP* scip, SCIP_Bool transformed) - -#endif //GCG_TYPE_VARCLASSIFIER_H__ diff --git a/headers/gcg/wrapper_partialdecomp.h b/headers/gcg/wrapper_partialdecomp.h deleted file mode 100644 index 876584b..0000000 --- a/headers/gcg/wrapper_partialdecomp.h +++ /dev/null @@ -1,52 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* */ -/* This file is part of the program */ -/* GCG --- Generic Column Generation */ -/* a Dantzig-Wolfe decomposition based extension */ -/* of the branch-cut-and-price framework */ -/* SCIP --- Solving Constraint Integer Programs */ -/* */ -/* Copyright (C) 2010-2022 Operations Research, RWTH Aachen University */ -/* Zuse Institute Berlin (ZIB) */ -/* */ -/* This program is free software; you can redistribute it and/or */ -/* modify it under the terms of the GNU Lesser General Public License */ -/* as published by the Free Software Foundation; either version 3 */ -/* of the License, or (at your option) any later version. */ -/* */ -/* This program is distributed in the hope that it will be useful, */ -/* but WITHOUT ANY WARRANTY; without even the implied warranty of */ -/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ -/* GNU Lesser General Public License for more details. */ -/* */ -/* You should have received a copy of the GNU Lesser General Public License */ -/* along with this program; if not, write to the Free Software */ -/* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.*/ -/* */ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -/**@file wrapper_partialdecomp.h - * @ingroup DECOMP - * @brief Provides wrapping to have Partialdecomps as parameters in C-conform function headers with C++ - * implementations. - * @author Hanna Franzen - */ - -/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/ - -#ifndef GCG_WRAPPER_PARTIALDECOMP_H__ -#define GCG_WRAPPER_PARTIALDECOMP_H__ - -#include "cons_decomp.h" -#include "class_partialdecomp.h" - -/** Wrapper class body to be included in .cpp files only. - * To pass a wrapper object through C headers include the wrapper forward declaration in cons_decomp.h - * - * The struct can contain a PARTIALDECOMP object.*/ -struct Partialdecomp_Wrapper -{ - gcg::PARTIALDECOMP* partialdec; /**< partialdec pointer */ -}; - -#endif /* GCG_WRAPPER_PARTIALDECOMP_H__ */ diff --git a/headers/lpi/lpi.h b/headers/lpi/lpi.h deleted file mode 100644 index 2080c9a..0000000 --- a/headers/lpi/lpi.h +++ /dev/null @@ -1,1115 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* */ -/* This file is part of the program and library */ -/* SCIP --- Solving Constraint Integer Programs */ -/* */ -/* Copyright 2002-2022 Zuse Institute Berlin */ -/* */ -/* Licensed under the Apache License, Version 2.0 (the "License"); */ -/* you may not use this file except in compliance with the License. */ -/* You may obtain a copy of the License at */ -/* */ -/* http://www.apache.org/licenses/LICENSE-2.0 */ -/* */ -/* Unless required by applicable law or agreed to in writing, software */ -/* distributed under the License is distributed on an "AS IS" BASIS, */ -/* 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. */ -/* */ -/* You should have received a copy of the Apache-2.0 license */ -/* along with SCIP; see the file LICENSE. If not visit scipopt.org. */ -/* */ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -/**@file lpi.h - * @ingroup LPIS - * @brief interface methods for specific LP solvers - * @author Tobias Achterberg - * @author Marc Pfetsch - * - */ - -/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/ - -#ifndef __SCIP_LPI_H__ -#define __SCIP_LPI_H__ - -#include "blockmemshell/memory.h" -#include "lpi/type_lpi.h" -#include "scip/def.h" -#include "scip/type_message.h" -#include "scip/type_retcode.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/**@addtogroup LPIS - * - * This file specifies a generic LP solver interface used by SCIP to create, modify, and solve linear programs of the - * form - * - * min/max obj * x - * lhs <= A * x <= rhs - * lb <= x <= ub - * - * and query information about the solution. Although it includes a few SCIP header files, e.g., because it uses SCIP's - * return codes, it can be used independently of any SCIP instance. - * - * The basis status for (column) variables are as follows: - * - If x_j = lb, then j is at its lower bound (SCIP_BASESTAT_LOWER). - * - If x_j = ub, then j is at its lower bound (SCIP_BASESTAT_UPPER). - * - If x_j is in the basis, it has SCIP_BASESTAT_BASIC status. - * - If x_j is free and non-basic, it has SCIP_BASESTAT_ZERO status. - * - * The basis status for (row) slack variables are: - * - If (A * x)_i = lhs, then i is at its lower bound (SCIP_BASESTAT_LOWER). - * - If (A * x)_i = rhs, then i is at its upper bound (SCIP_BASESTAT_UPPER). - * - If the slack variable for row i is basic, it has SCIP_BASESTAT_BASIC status. - * - * If the solvers use their status differently, those status codes have to be corrected. - * - * In the methods accessing information about the (inverse of the) basis matrix, the interface assumes the following - * column-oriented format: slack variables of rows have coefficient +1 and the basis matrix is a regular m times m - * submatrix of (A,I), where m is the number of rows and I is the identity matrix. This means that if, internally, the - * LP solver uses coefficients -1 for some of the slack variables, then every row associated with a slack variable whose - * coefficient is -1 should be negated in order to return the result in terms of the LP interface definition. - * - * The creation of a new LP should always be done in the following ways: Either one can use SCIPlpiLoadColLP() or one - * first adds empty columns or rows. Then the matrix entries can be added by adding columns and rows, respectively. - * Adding matrix entries for a row or column that have not been added before will result in an error. - * - * The handling of the objective limit is as follows, if supported by the LP-solver: If the objective is larger than the - * objective limit for minimization problems or smaller than the objective limit for maximization problems, the solution - * process can be stopped. This naturally occurs in a branch-and-bound process, where the objective limit is set to the - * value of the best solution found so far. If the problem is a minimization problem and we use the dual simplex, the - * dual feasible solutions are maximized. If their value are larger than the objective limit, the process can be - * stopped. In this case, no feasible integer solution can be found in the corresponding branch. - * - * Some LP-solvers also support the opposite setting, but this can easily be checked after the solution process (i.e., - * for a minimization problem a check whether the optimal value is smaller than the limit). Note that this check can - * only be determined at the end of the optimization. Thus, we do not support this. - * - * @{ - */ - -/* - * Miscellaneous Methods - */ - -/**@name Miscellaneous Methods */ -/**@{ */ - -/** gets name and version of LP solver */ -SCIP_EXPORT -const char* SCIPlpiGetSolverName( - void - ); - -/** gets description of LP solver (developer, webpage, ...) */ -SCIP_EXPORT -const char* SCIPlpiGetSolverDesc( - void - ); - -/** gets pointer for LP solver - use only with great care - * - * The behavior of this function depends on the solver and its use is - * therefore only recommended if you really know what you are - * doing. In general, it returns a pointer to the LP solver object. - */ -SCIP_EXPORT -void* SCIPlpiGetSolverPointer( - SCIP_LPI* lpi /**< pointer to an LP interface structure */ - ); - -/** pass integrality information about variables to the solver */ -SCIP_EXPORT -SCIP_RETCODE SCIPlpiSetIntegralityInformation( - SCIP_LPI* lpi, /**< pointer to an LP interface structure */ - int ncols, /**< length of integrality array */ - int* intInfo /**< integrality array (0: continuous, 1: integer). May be NULL iff ncols is 0. */ - ); - -/** informs about availability of a primal simplex solving method */ -SCIP_EXPORT -SCIP_Bool SCIPlpiHasPrimalSolve( - void - ); - -/** informs about availability of a dual simplex solving method */ -SCIP_EXPORT -SCIP_Bool SCIPlpiHasDualSolve( - void - ); - -/** informs about availability of a barrier solving method */ -SCIP_EXPORT -SCIP_Bool SCIPlpiHasBarrierSolve( - void - ); - -/**@} */ - - - - -/* - * LPI Creation and Destruction Methods - */ - -/**@name LPI Creation and Destruction Methods */ -/**@{ */ - -/** creates an LP problem object */ -SCIP_EXPORT -SCIP_RETCODE SCIPlpiCreate( - SCIP_LPI** lpi, /**< pointer to an LP interface structure */ - SCIP_MESSAGEHDLR* messagehdlr, /**< message handler to use for printing messages, or NULL */ - const char* name, /**< problem name */ - SCIP_OBJSEN objsen /**< objective sense */ - ); - -/** deletes an LP problem object */ -SCIP_EXPORT -SCIP_RETCODE SCIPlpiFree( - SCIP_LPI** lpi /**< pointer to an LP interface structure */ - ); - -/**@} */ - - - - -/* - * Modification Methods - */ - -/**@name Modification Methods */ -/**@{ */ - -/** copies LP data with column matrix into LP solver */ -SCIP_EXPORT -SCIP_RETCODE SCIPlpiLoadColLP( - SCIP_LPI* lpi, /**< LP interface structure */ - SCIP_OBJSEN objsen, /**< objective sense */ - int ncols, /**< number of columns */ - const SCIP_Real* obj, /**< objective function values of columns */ - const SCIP_Real* lb, /**< lower bounds of columns */ - const SCIP_Real* ub, /**< upper bounds of columns */ - char** colnames, /**< column names, or NULL */ - int nrows, /**< number of rows */ - const SCIP_Real* lhs, /**< left hand sides of rows */ - const SCIP_Real* rhs, /**< right hand sides of rows */ - char** rownames, /**< row names, or NULL */ - int nnonz, /**< number of nonzero elements in the constraint matrix */ - const int* beg, /**< start index of each column in ind- and val-array */ - const int* ind, /**< row indices of constraint matrix entries */ - const SCIP_Real* val /**< values of constraint matrix entries */ - ); - -/** adds columns to the LP - * - * @note ind array is not checked for duplicates, problems may appear if indices are added more than once - */ -SCIP_EXPORT -SCIP_RETCODE SCIPlpiAddCols( - SCIP_LPI* lpi, /**< LP interface structure */ - int ncols, /**< number of columns to be added */ - const SCIP_Real* obj, /**< objective function values of new columns */ - const SCIP_Real* lb, /**< lower bounds of new columns */ - const SCIP_Real* ub, /**< upper bounds of new columns */ - char** colnames, /**< column names, or NULL */ - int nnonz, /**< number of nonzero elements to be added to the constraint matrix */ - const int* beg, /**< start index of each column in ind- and val-array, or NULL if nnonz == 0 */ - const int* ind, /**< row indices of constraint matrix entries, or NULL if nnonz == 0 */ - const SCIP_Real* val /**< values of constraint matrix entries, or NULL if nnonz == 0 */ - ); - -/** deletes all columns in the given range from LP */ -SCIP_EXPORT -SCIP_RETCODE SCIPlpiDelCols( - SCIP_LPI* lpi, /**< LP interface structure */ - int firstcol, /**< first column to be deleted */ - int lastcol /**< last column to be deleted */ - ); - -/** deletes columns from SCIP_LPI; the new position of a column must not be greater that its old position */ -SCIP_EXPORT -SCIP_RETCODE SCIPlpiDelColset( - SCIP_LPI* lpi, /**< LP interface structure */ - int* dstat /**< deletion status of columns - * input: 1 if column should be deleted, 0 if not - * output: new position of column, -1 if column was deleted */ - ); - -/** adds rows to the LP - * - * @note ind array is not checked for duplicates, problems may appear if indices are added more than once - */ -SCIP_EXPORT -SCIP_RETCODE SCIPlpiAddRows( - SCIP_LPI* lpi, /**< LP interface structure */ - int nrows, /**< number of rows to be added */ - const SCIP_Real* lhs, /**< left hand sides of new rows */ - const SCIP_Real* rhs, /**< right hand sides of new rows */ - char** rownames, /**< row names, or NULL */ - int nnonz, /**< number of nonzero elements to be added to the constraint matrix */ - const int* beg, /**< start index of each row in ind- and val-array, or NULL if nnonz == 0 */ - const int* ind, /**< column indices of constraint matrix entries, or NULL if nnonz == 0 */ - const SCIP_Real* val /**< values of constraint matrix entries, or NULL if nnonz == 0 */ - ); - -/** deletes all rows in the given range from LP */ -SCIP_EXPORT -SCIP_RETCODE SCIPlpiDelRows( - SCIP_LPI* lpi, /**< LP interface structure */ - int firstrow, /**< first row to be deleted */ - int lastrow /**< last row to be deleted */ - ); - -/** deletes rows from SCIP_LPI; the new position of a row must not be greater that its old position */ -SCIP_EXPORT -SCIP_RETCODE SCIPlpiDelRowset( - SCIP_LPI* lpi, /**< LP interface structure */ - int* dstat /**< deletion status of rows - * input: 1 if row should be deleted, 0 if not - * output: new position of row, -1 if row was deleted */ - ); - -/** clears the whole LP */ -SCIP_EXPORT -SCIP_RETCODE SCIPlpiClear( - SCIP_LPI* lpi /**< LP interface structure */ - ); - -/** changes lower and upper bounds of columns */ -SCIP_EXPORT -SCIP_RETCODE SCIPlpiChgBounds( - SCIP_LPI* lpi, /**< LP interface structure */ - int ncols, /**< number of columns to change bounds for */ - const int* ind, /**< column indices or NULL if ncols is zero */ - const SCIP_Real* lb, /**< values for the new lower bounds or NULL if ncols is zero */ - const SCIP_Real* ub /**< values for the new upper bounds or NULL if ncols is zero */ - ); - -/** changes left and right hand sides of rows */ -SCIP_EXPORT -SCIP_RETCODE SCIPlpiChgSides( - SCIP_LPI* lpi, /**< LP interface structure */ - int nrows, /**< number of rows to change sides for */ - const int* ind, /**< row indices */ - const SCIP_Real* lhs, /**< new values for left hand sides */ - const SCIP_Real* rhs /**< new values for right hand sides */ - ); - -/** changes a single coefficient */ -SCIP_EXPORT -SCIP_RETCODE SCIPlpiChgCoef( - SCIP_LPI* lpi, /**< LP interface structure */ - int row, /**< row number of coefficient to change */ - int col, /**< column number of coefficient to change */ - SCIP_Real newval /**< new value of coefficient */ - ); - -/** changes the objective sense */ -SCIP_EXPORT -SCIP_RETCODE SCIPlpiChgObjsen( - SCIP_LPI* lpi, /**< LP interface structure */ - SCIP_OBJSEN objsen /**< new objective sense */ - ); - -/** changes objective values of columns in the LP */ -SCIP_EXPORT -SCIP_RETCODE SCIPlpiChgObj( - SCIP_LPI* lpi, /**< LP interface structure */ - int ncols, /**< number of columns to change objective value for */ - const int* ind, /**< column indices to change objective value for */ - const SCIP_Real* obj /**< new objective values for columns */ - ); - -/** multiplies a row with a non-zero scalar; for negative scalars, the row's sense is switched accordingly */ -SCIP_EXPORT -SCIP_RETCODE SCIPlpiScaleRow( - SCIP_LPI* lpi, /**< LP interface structure */ - int row, /**< row number to scale */ - SCIP_Real scaleval /**< scaling multiplier */ - ); - -/** multiplies a column with a non-zero scalar; the objective value is multiplied with the scalar, and the bounds - * are divided by the scalar; for negative scalars, the column's bounds are switched - */ -SCIP_EXPORT -SCIP_RETCODE SCIPlpiScaleCol( - SCIP_LPI* lpi, /**< LP interface structure */ - int col, /**< column number to scale */ - SCIP_Real scaleval /**< scaling multiplier */ - ); - -/**@} */ - - - - -/* - * Data Accessing Methods - */ - -/**@name Data Accessing Methods */ -/**@{ */ - -/** gets the number of rows in the LP */ -SCIP_EXPORT -SCIP_RETCODE SCIPlpiGetNRows( - SCIP_LPI* lpi, /**< LP interface structure */ - int* nrows /**< pointer to store the number of rows */ - ); - -/** gets the number of columns in the LP */ -SCIP_EXPORT -SCIP_RETCODE SCIPlpiGetNCols( - SCIP_LPI* lpi, /**< LP interface structure */ - int* ncols /**< pointer to store the number of cols */ - ); - -/** gets the objective sense of the LP */ -SCIP_EXPORT -SCIP_RETCODE SCIPlpiGetObjsen( - SCIP_LPI* lpi, /**< LP interface structure */ - SCIP_OBJSEN* objsen /**< pointer to store objective sense */ - ); - -/** gets the number of nonzero elements in the LP constraint matrix */ -SCIP_EXPORT -SCIP_RETCODE SCIPlpiGetNNonz( - SCIP_LPI* lpi, /**< LP interface structure */ - int* nnonz /**< pointer to store the number of nonzeros */ - ); - -/** gets columns from LP problem object; the arrays have to be large enough to store all values; - * Either both, lb and ub, have to be NULL, or both have to be non-NULL, - * either nnonz, beg, ind, and val have to be NULL, or all of them have to be non-NULL. - */ -SCIP_EXPORT -SCIP_RETCODE SCIPlpiGetCols( - SCIP_LPI* lpi, /**< LP interface structure */ - int firstcol, /**< first column to get from LP */ - int lastcol, /**< last column to get from LP */ - SCIP_Real* lb, /**< buffer to store the lower bound vector, or NULL */ - SCIP_Real* ub, /**< buffer to store the upper bound vector, or NULL */ - int* nnonz, /**< pointer to store the number of nonzero elements returned, or NULL */ - int* beg, /**< buffer to store start index of each column in ind- and val-array, or NULL */ - int* ind, /**< buffer to store row indices of constraint matrix entries, or NULL */ - SCIP_Real* val /**< buffer to store values of constraint matrix entries, or NULL */ - ); - -/** gets rows from LP problem object; the arrays have to be large enough to store all values. - * Either both, lhs and rhs, have to be NULL, or both have to be non-NULL, - * either nnonz, beg, ind, and val have to be NULL, or all of them have to be non-NULL. - */ -SCIP_EXPORT -SCIP_RETCODE SCIPlpiGetRows( - SCIP_LPI* lpi, /**< LP interface structure */ - int firstrow, /**< first row to get from LP */ - int lastrow, /**< last row to get from LP */ - SCIP_Real* lhs, /**< buffer to store left hand side vector, or NULL */ - SCIP_Real* rhs, /**< buffer to store right hand side vector, or NULL */ - int* nnonz, /**< pointer to store the number of nonzero elements returned, or NULL */ - int* beg, /**< buffer to store start index of each row in ind- and val-array, or NULL */ - int* ind, /**< buffer to store column indices of constraint matrix entries, or NULL */ - SCIP_Real* val /**< buffer to store values of constraint matrix entries, or NULL */ - ); - -/** gets column names */ -SCIP_EXPORT -SCIP_RETCODE SCIPlpiGetColNames( - SCIP_LPI* lpi, /**< LP interface structure */ - int firstcol, /**< first column to get name from LP */ - int lastcol, /**< last column to get name from LP */ - char** colnames, /**< pointers to column names (of size at least lastcol-firstcol+1) or NULL if namestoragesize is zero */ - char* namestorage, /**< storage for col names or NULL if namestoragesize is zero */ - int namestoragesize, /**< size of namestorage (if 0, -storageleft returns the storage needed) */ - int* storageleft /**< amount of storage left (if < 0 the namestorage was not big enough) or NULL if namestoragesize is zero */ - ); - -/** gets row names */ -SCIP_EXPORT -SCIP_RETCODE SCIPlpiGetRowNames( - SCIP_LPI* lpi, /**< LP interface structure */ - int firstrow, /**< first row to get name from LP */ - int lastrow, /**< last row to get name from LP */ - char** rownames, /**< pointers to row names (of size at least lastrow-firstrow+1) or NULL if namestoragesize is zero */ - char* namestorage, /**< storage for row names or NULL if namestoragesize is zero */ - int namestoragesize, /**< size of namestorage (if 0, -storageleft returns the storage needed) */ - int* storageleft /**< amount of storage left (if < 0 the namestorage was not big enough) or NULL if namestoragesize is zero */ - ); - -/** gets objective coefficients from LP problem object */ -SCIP_EXPORT -SCIP_RETCODE SCIPlpiGetObj( - SCIP_LPI* lpi, /**< LP interface structure */ - int firstcol, /**< first column to get objective coefficient for */ - int lastcol, /**< last column to get objective coefficient for */ - SCIP_Real* vals /**< array to store objective coefficients */ - ); - -/** gets current bounds from LP problem object */ -SCIP_EXPORT -SCIP_RETCODE SCIPlpiGetBounds( - SCIP_LPI* lpi, /**< LP interface structure */ - int firstcol, /**< first column to get bounds for */ - int lastcol, /**< last column to get bounds for */ - SCIP_Real* lbs, /**< array to store lower bound values, or NULL */ - SCIP_Real* ubs /**< array to store upper bound values, or NULL */ - ); - -/** gets current row sides from LP problem object */ -SCIP_EXPORT -SCIP_RETCODE SCIPlpiGetSides( - SCIP_LPI* lpi, /**< LP interface structure */ - int firstrow, /**< first row to get sides for */ - int lastrow, /**< last row to get sides for */ - SCIP_Real* lhss, /**< array to store left hand side values, or NULL */ - SCIP_Real* rhss /**< array to store right hand side values, or NULL */ - ); - -/** gets a single coefficient */ -SCIP_EXPORT -SCIP_RETCODE SCIPlpiGetCoef( - SCIP_LPI* lpi, /**< LP interface structure */ - int row, /**< row number of coefficient */ - int col, /**< column number of coefficient */ - SCIP_Real* val /**< pointer to store the value of the coefficient */ - ); - -/**@} */ - - - - -/* - * Solving Methods - */ - -/**@name Solving Methods */ -/**@{ */ - -/** calls primal simplex to solve the LP */ -SCIP_EXPORT -SCIP_RETCODE SCIPlpiSolvePrimal( - SCIP_LPI* lpi /**< LP interface structure */ - ); - -/** calls dual simplex to solve the LP */ -SCIP_EXPORT -SCIP_RETCODE SCIPlpiSolveDual( - SCIP_LPI* lpi /**< LP interface structure */ - ); - -/** calls barrier or interior point algorithm to solve the LP with crossover to simplex basis */ -SCIP_EXPORT -SCIP_RETCODE SCIPlpiSolveBarrier( - SCIP_LPI* lpi, /**< LP interface structure */ - SCIP_Bool crossover /**< perform crossover */ - ); - -/** start strong branching - call before any strong branching */ -SCIP_EXPORT -SCIP_RETCODE SCIPlpiStartStrongbranch( - SCIP_LPI* lpi /**< LP interface structure */ - ); - -/** end strong branching - call after any strong branching */ -SCIP_EXPORT -SCIP_RETCODE SCIPlpiEndStrongbranch( - SCIP_LPI* lpi /**< LP interface structure */ - ); - -/** performs strong branching iterations on one @b fractional candidate */ -SCIP_EXPORT -SCIP_RETCODE SCIPlpiStrongbranchFrac( - SCIP_LPI* lpi, /**< LP interface structure */ - int col, /**< column to apply strong branching on */ - SCIP_Real psol, /**< fractional current primal solution value of column */ - int itlim, /**< iteration limit for strong branchings */ - SCIP_Real* down, /**< stores dual bound after branching column down */ - SCIP_Real* up, /**< stores dual bound after branching column up */ - SCIP_Bool* downvalid, /**< stores whether the returned down value is a valid dual bound; - * otherwise, it can only be used as an estimate value */ - SCIP_Bool* upvalid, /**< stores whether the returned up value is a valid dual bound; - * otherwise, it can only be used as an estimate value */ - int* iter /**< stores total number of strong branching iterations, or -1; may be NULL */ - ); - -/** performs strong branching iterations on given @b fractional candidates */ -SCIP_EXPORT -SCIP_RETCODE SCIPlpiStrongbranchesFrac( - SCIP_LPI* lpi, /**< LP interface structure */ - int* cols, /**< columns to apply strong branching on */ - int ncols, /**< number of columns */ - SCIP_Real* psols, /**< fractional current primal solution values of columns */ - int itlim, /**< iteration limit for strong branchings */ - SCIP_Real* down, /**< stores dual bounds after branching columns down */ - SCIP_Real* up, /**< stores dual bounds after branching columns up */ - SCIP_Bool* downvalid, /**< stores whether the returned down values are valid dual bounds; - * otherwise, they can only be used as an estimate values */ - SCIP_Bool* upvalid, /**< stores whether the returned up values are a valid dual bounds; - * otherwise, they can only be used as an estimate values */ - int* iter /**< stores total number of strong branching iterations, or -1; may be NULL */ - ); - -/** performs strong branching iterations on one candidate with @b integral value */ -SCIP_EXPORT -SCIP_RETCODE SCIPlpiStrongbranchInt( - SCIP_LPI* lpi, /**< LP interface structure */ - int col, /**< column to apply strong branching on */ - SCIP_Real psol, /**< current integral primal solution value of column */ - int itlim, /**< iteration limit for strong branchings */ - SCIP_Real* down, /**< stores dual bound after branching column down */ - SCIP_Real* up, /**< stores dual bound after branching column up */ - SCIP_Bool* downvalid, /**< stores whether the returned down value is a valid dual bound; - * otherwise, it can only be used as an estimate value */ - SCIP_Bool* upvalid, /**< stores whether the returned up value is a valid dual bound; - * otherwise, it can only be used as an estimate value */ - int* iter /**< stores total number of strong branching iterations, or -1; may be NULL */ - ); - -/** performs strong branching iterations on given candidates with @b integral values */ -SCIP_EXPORT -SCIP_RETCODE SCIPlpiStrongbranchesInt( - SCIP_LPI* lpi, /**< LP interface structure */ - int* cols, /**< columns to apply strong branching on */ - int ncols, /**< number of columns */ - SCIP_Real* psols, /**< current integral primal solution values of columns */ - int itlim, /**< iteration limit for strong branchings */ - SCIP_Real* down, /**< stores dual bounds after branching columns down */ - SCIP_Real* up, /**< stores dual bounds after branching columns up */ - SCIP_Bool* downvalid, /**< stores whether the returned down values are valid dual bounds; - * otherwise, they can only be used as an estimate values */ - SCIP_Bool* upvalid, /**< stores whether the returned up values are a valid dual bounds; - * otherwise, they can only be used as an estimate values */ - int* iter /**< stores total number of strong branching iterations, or -1; may be NULL */ - ); -/**@} */ - - - - -/* - * Solution Information Methods - */ - -/**@name Solution Information Methods */ -/**@{ */ - -/** returns whether a solve method was called after the last modification of the LP */ -SCIP_EXPORT -SCIP_Bool SCIPlpiWasSolved( - SCIP_LPI* lpi /**< LP interface structure */ - ); - -/** gets information about primal and dual feasibility of the current LP solution - * - * The feasibility information is with respect to the last solving call and it is only relevant if SCIPlpiWasSolved() - * returns true. If the LP is changed, this information might be invalidated. - * - * Note that @p primalfeasible and @p dualfeasible should only return true if the solver has proved the respective LP to - * be feasible. Thus, the return values should be equal to the values of SCIPlpiIsPrimalFeasible() and - * SCIPlpiIsDualFeasible(), respectively. Note that if feasibility cannot be proved, they should return false (even if - * the problem might actually be feasible). - */ -SCIP_EXPORT -SCIP_RETCODE SCIPlpiGetSolFeasibility( - SCIP_LPI* lpi, /**< LP interface structure */ - SCIP_Bool* primalfeasible, /**< pointer to store primal feasibility status */ - SCIP_Bool* dualfeasible /**< pointer to store dual feasibility status */ - ); - -/** returns TRUE iff LP is proven to have a primal unbounded ray (but not necessary a primal feasible point); - * this does not necessarily mean, that the solver knows and can return the primal ray - */ -SCIP_EXPORT -SCIP_Bool SCIPlpiExistsPrimalRay( - SCIP_LPI* lpi /**< LP interface structure */ - ); - -/** returns TRUE iff LP is proven to have a primal unbounded ray (but not necessary a primal feasible point), - * and the solver knows and can return the primal ray - */ -SCIP_EXPORT -SCIP_Bool SCIPlpiHasPrimalRay( - SCIP_LPI* lpi /**< LP interface structure */ - ); - -/** returns TRUE iff LP is proven to be primal unbounded */ -SCIP_EXPORT -SCIP_Bool SCIPlpiIsPrimalUnbounded( - SCIP_LPI* lpi /**< LP interface structure */ - ); - -/** returns TRUE iff LP is proven to be primal infeasible */ -SCIP_EXPORT -SCIP_Bool SCIPlpiIsPrimalInfeasible( - SCIP_LPI* lpi /**< LP interface structure */ - ); - -/** returns TRUE iff LP is proven to be primal feasible */ -SCIP_EXPORT -SCIP_Bool SCIPlpiIsPrimalFeasible( - SCIP_LPI* lpi /**< LP interface structure */ - ); - -/** returns TRUE iff LP is proven to have a dual unbounded ray (but not necessary a dual feasible point); - * this does not necessarily mean, that the solver knows and can return the dual ray - */ -SCIP_EXPORT -SCIP_Bool SCIPlpiExistsDualRay( - SCIP_LPI* lpi /**< LP interface structure */ - ); - -/** returns TRUE iff LP is proven to have a dual unbounded ray (but not necessary a dual feasible point), - * and the solver knows and can return the dual ray - */ -SCIP_EXPORT -SCIP_Bool SCIPlpiHasDualRay( - SCIP_LPI* lpi /**< LP interface structure */ - ); - -/** returns TRUE iff LP is proven to be dual unbounded */ -SCIP_EXPORT -SCIP_Bool SCIPlpiIsDualUnbounded( - SCIP_LPI* lpi /**< LP interface structure */ - ); - -/** returns TRUE iff LP is proven to be dual infeasible */ -SCIP_EXPORT -SCIP_Bool SCIPlpiIsDualInfeasible( - SCIP_LPI* lpi /**< LP interface structure */ - ); - -/** returns TRUE iff LP is proven to be dual feasible */ -SCIP_EXPORT -SCIP_Bool SCIPlpiIsDualFeasible( - SCIP_LPI* lpi /**< LP interface structure */ - ); - -/** returns TRUE iff LP was solved to optimality */ -SCIP_EXPORT -SCIP_Bool SCIPlpiIsOptimal( - SCIP_LPI* lpi /**< LP interface structure */ - ); - -/** returns TRUE iff current LP solution is stable - * - * This function should return true if the solution is reliable, i.e., feasible and optimal (or proven - * infeasible/unbounded) with respect to the original problem. The optimality status might be with respect to a scaled - * version of the problem, but the solution might not be feasible to the unscaled original problem; in this case, - * SCIPlpiIsStable() should return false. - */ -SCIP_EXPORT -SCIP_Bool SCIPlpiIsStable( - SCIP_LPI* lpi /**< LP interface structure */ - ); - -/** returns TRUE iff the objective limit was reached */ -SCIP_EXPORT -SCIP_Bool SCIPlpiIsObjlimExc( - SCIP_LPI* lpi /**< LP interface structure */ - ); - -/** returns TRUE iff the iteration limit was reached */ -SCIP_EXPORT -SCIP_Bool SCIPlpiIsIterlimExc( - SCIP_LPI* lpi /**< LP interface structure */ - ); - -/** returns TRUE iff the time limit was reached */ -SCIP_EXPORT -SCIP_Bool SCIPlpiIsTimelimExc( - SCIP_LPI* lpi /**< LP interface structure */ - ); - -/** returns the internal solution status of the solver */ -SCIP_EXPORT -int SCIPlpiGetInternalStatus( - SCIP_LPI* lpi /**< LP interface structure */ - ); - -/** tries to reset the internal status of the LP solver in order to ignore an instability of the last solving call */ -SCIP_EXPORT -SCIP_RETCODE SCIPlpiIgnoreInstability( - SCIP_LPI* lpi, /**< LP interface structure */ - SCIP_Bool* success /**< pointer to store, whether the instability could be ignored */ - ); - -/** gets objective value of solution */ -SCIP_EXPORT -SCIP_RETCODE SCIPlpiGetObjval( - SCIP_LPI* lpi, /**< LP interface structure */ - SCIP_Real* objval /**< stores the objective value */ - ); - -/** gets primal and dual solution vectors for feasible LPs - * - * Before calling this function, the caller must ensure that the LP has been solved to optimality, i.e., that - * SCIPlpiIsOptimal() returns true. - */ -SCIP_EXPORT -SCIP_RETCODE SCIPlpiGetSol( - SCIP_LPI* lpi, /**< LP interface structure */ - SCIP_Real* objval, /**< stores the objective value, may be NULL if not needed */ - SCIP_Real* primsol, /**< primal solution vector, may be NULL if not needed */ - SCIP_Real* dualsol, /**< dual solution vector, may be NULL if not needed */ - SCIP_Real* activity, /**< row activity vector, may be NULL if not needed */ - SCIP_Real* redcost /**< reduced cost vector, may be NULL if not needed */ - ); - -/** gets primal ray for unbounded LPs */ -SCIP_EXPORT -SCIP_RETCODE SCIPlpiGetPrimalRay( - SCIP_LPI* lpi, /**< LP interface structure */ - SCIP_Real* ray /**< primal ray */ - ); - -/** gets dual Farkas proof for infeasibility */ -SCIP_EXPORT -SCIP_RETCODE SCIPlpiGetDualfarkas( - SCIP_LPI* lpi, /**< LP interface structure */ - SCIP_Real* dualfarkas /**< dual Farkas row multipliers */ - ); - -/** gets the number of LP iterations of the last solve call */ -SCIP_EXPORT -SCIP_RETCODE SCIPlpiGetIterations( - SCIP_LPI* lpi, /**< LP interface structure */ - int* iterations /**< pointer to store the number of iterations of the last solve call */ - ); - -/** gets information about the quality of an LP solution - * - * Such information is usually only available, if also a (maybe not optimal) solution is available. - * The LPI should return SCIP_INVALID for @p quality, if the requested quantity is not available. - */ -SCIP_EXPORT -SCIP_RETCODE SCIPlpiGetRealSolQuality( - SCIP_LPI* lpi, /**< LP interface structure */ - SCIP_LPSOLQUALITY qualityindicator, /**< indicates which quality should be returned */ - SCIP_Real* quality /**< pointer to store quality number */ - ); - -/**@} */ - - - - -/* - * LP Basis Methods - */ - -/**@name LP Basis Methods */ -/**@{ */ - -/** gets current basis status for columns and rows; arrays must be large enough to store the basis status */ -SCIP_EXPORT -SCIP_RETCODE SCIPlpiGetBase( - SCIP_LPI* lpi, /**< LP interface structure */ - int* cstat, /**< array to store column basis status, or NULL */ - int* rstat /**< array to store row basis status, or NULL */ - ); - -/** sets current basis status for columns and rows */ -SCIP_EXPORT -SCIP_RETCODE SCIPlpiSetBase( - SCIP_LPI* lpi, /**< LP interface structure */ - const int* cstat, /**< array with column basis status */ - const int* rstat /**< array with row basis status */ - ); - -/** returns the indices of the basic columns and rows; basic column n gives value n, basic row m gives value -1-m */ -SCIP_EXPORT -SCIP_RETCODE SCIPlpiGetBasisInd( - SCIP_LPI* lpi, /**< LP interface structure */ - int* bind /**< pointer to store basis indices ready to keep number of rows entries */ - ); - -/** get row of inverse basis matrix B^-1 - * - * @note The LP interface defines slack variables to have coefficient +1. This means that if, internally, the LP solver - * uses a -1 coefficient, then rows associated with slacks variables whose coefficient is -1, should be negated; - * see also the explanation in lpi.h. - */ -SCIP_EXPORT -SCIP_RETCODE SCIPlpiGetBInvRow( - SCIP_LPI* lpi, /**< LP interface structure */ - int r, /**< row number */ - SCIP_Real* coef, /**< pointer to store the coefficients of the row */ - int* inds, /**< array to store the non-zero indices, or NULL */ - int* ninds /**< pointer to store the number of non-zero indices, or NULL - * (-1: if we do not store sparsity information) */ - ); - -/** get column of inverse basis matrix B^-1 - * - * @note The LP interface defines slack variables to have coefficient +1. This means that if, internally, the LP solver - * uses a -1 coefficient, then rows associated with slacks variables whose coefficient is -1, should be negated; - * see also the explanation in lpi.h. - */ -SCIP_EXPORT -SCIP_RETCODE SCIPlpiGetBInvCol( - SCIP_LPI* lpi, /**< LP interface structure */ - int c, /**< column number of B^-1; this is NOT the number of the column in the LP; - * you have to call SCIPlpiGetBasisInd() to get the array which links the - * B^-1 column numbers to the row and column numbers of the LP! - * c must be between 0 and nrows-1, since the basis has the size - * nrows * nrows */ - SCIP_Real* coef, /**< pointer to store the coefficients of the column */ - int* inds, /**< array to store the non-zero indices, or NULL */ - int* ninds /**< pointer to store the number of non-zero indices, or NULL - * (-1: if we do not store sparsity information) */ - ); - -/** get row of inverse basis matrix times constraint matrix B^-1 * A - * - * @note The LP interface defines slack variables to have coefficient +1. This means that if, internally, the LP solver - * uses a -1 coefficient, then rows associated with slacks variables whose coefficient is -1, should be negated; - * see also the explanation in lpi.h. - */ -SCIP_EXPORT -SCIP_RETCODE SCIPlpiGetBInvARow( - SCIP_LPI* lpi, /**< LP interface structure */ - int r, /**< row number */ - const SCIP_Real* binvrow, /**< row in (A_B)^-1 from prior call to SCIPlpiGetBInvRow(), or NULL */ - SCIP_Real* coef, /**< vector to return coefficients of the row */ - int* inds, /**< array to store the non-zero indices, or NULL */ - int* ninds /**< pointer to store the number of non-zero indices, or NULL - * (-1: if we do not store sparsity information) */ - ); - -/** get column of inverse basis matrix times constraint matrix B^-1 * A - * - * @note The LP interface defines slack variables to have coefficient +1. This means that if, internally, the LP solver - * uses a -1 coefficient, then rows associated with slacks variables whose coefficient is -1, should be negated; - * see also the explanation in lpi.h. - */ -SCIP_EXPORT -SCIP_RETCODE SCIPlpiGetBInvACol( - SCIP_LPI* lpi, /**< LP interface structure */ - int c, /**< column number */ - SCIP_Real* coef, /**< vector to return coefficients of the column */ - int* inds, /**< array to store the non-zero indices, or NULL */ - int* ninds /**< pointer to store the number of non-zero indices, or NULL - * (-1: if we do not store sparsity information) */ - ); - -/**@} */ - - - - -/* - * LPi State Methods - */ - -/**@name LPi State Methods */ -/**@{ */ - -/** stores LPi state (like basis information) into lpistate object */ -SCIP_EXPORT -SCIP_RETCODE SCIPlpiGetState( - SCIP_LPI* lpi, /**< LP interface structure */ - BMS_BLKMEM* blkmem, /**< block memory */ - SCIP_LPISTATE** lpistate /**< pointer to LPi state information (like basis information) */ - ); - -/** loads LPi state (like basis information) into solver; note that the LP might have been extended with additional - * columns and rows since the state was stored with SCIPlpiGetState() - */ -SCIP_EXPORT -SCIP_RETCODE SCIPlpiSetState( - SCIP_LPI* lpi, /**< LP interface structure */ - BMS_BLKMEM* blkmem, /**< block memory */ - const SCIP_LPISTATE* lpistate /**< LPi state information (like basis information), or NULL */ - ); - -/** clears current LPi state (like basis information) of the solver */ -SCIP_EXPORT -SCIP_RETCODE SCIPlpiClearState( - SCIP_LPI* lpi /**< LP interface structure */ - ); - -/** frees LPi state information */ -SCIP_EXPORT -SCIP_RETCODE SCIPlpiFreeState( - SCIP_LPI* lpi, /**< LP interface structure */ - BMS_BLKMEM* blkmem, /**< block memory */ - SCIP_LPISTATE** lpistate /**< pointer to LPi state information (like basis information) */ - ); - -/** checks, whether the given LPi state contains simplex basis information */ -SCIP_EXPORT -SCIP_Bool SCIPlpiHasStateBasis( - SCIP_LPI* lpi, /**< LP interface structure */ - SCIP_LPISTATE* lpistate /**< LPi state information (like basis information) */ - ); - -/** reads LPi state (like basis information from a file */ -SCIP_EXPORT -SCIP_RETCODE SCIPlpiReadState( - SCIP_LPI* lpi, /**< LP interface structure */ - const char* fname /**< file name */ - ); - -/** writes LPi state (i.e. basis information) to a file */ -SCIP_EXPORT -SCIP_RETCODE SCIPlpiWriteState( - SCIP_LPI* lpi, /**< LP interface structure */ - const char* fname /**< file name */ - ); - -/**@} */ - - -/* - * LPi Pricing Norms Methods - */ - -/**@name LPi Pricing Norms Methods */ -/**@{ */ - -/** stores LPi pricing norms into lpinorms object */ -SCIP_RETCODE SCIPlpiGetNorms( - SCIP_LPI* lpi, /**< LP interface structure */ - BMS_BLKMEM* blkmem, /**< block memory */ - SCIP_LPINORMS** lpinorms /**< pointer to LPi pricing norms information */ - ); - -/** loads LPi pricing norms into solver; note that the LP might have been extended with additional - * columns and rows since the norms were stored with SCIPlpiGetNorms() - */ -SCIP_RETCODE SCIPlpiSetNorms( - SCIP_LPI* lpi, /**< LP interface structure */ - BMS_BLKMEM* blkmem, /**< block memory */ - const SCIP_LPINORMS* lpinorms /**< LPi pricing norms information, or NULL */ - ); - -/** frees LPi pricing norms information */ -SCIP_RETCODE SCIPlpiFreeNorms( - SCIP_LPI* lpi, /**< LP interface structure */ - BMS_BLKMEM* blkmem, /**< block memory */ - SCIP_LPINORMS** lpinorms /**< pointer to LPi pricing norms information, or NULL */ - ); - - -/**@} */ - - - - -/* - * Parameter Methods - */ - -/**@name Parameter Methods */ -/**@{ */ - -/** gets integer parameter of LP */ -SCIP_EXPORT -SCIP_RETCODE SCIPlpiGetIntpar( - SCIP_LPI* lpi, /**< LP interface structure */ - SCIP_LPPARAM type, /**< parameter number */ - int* ival /**< buffer to store the parameter value */ - ); - -/** sets integer parameter of LP */ -SCIP_EXPORT -SCIP_RETCODE SCIPlpiSetIntpar( - SCIP_LPI* lpi, /**< LP interface structure */ - SCIP_LPPARAM type, /**< parameter number */ - int ival /**< parameter value */ - ); - -/** gets floating point parameter of LP */ -SCIP_EXPORT -SCIP_RETCODE SCIPlpiGetRealpar( - SCIP_LPI* lpi, /**< LP interface structure */ - SCIP_LPPARAM type, /**< parameter number */ - SCIP_Real* dval /**< buffer to store the parameter value */ - ); - -/** sets floating point parameter of LP */ -SCIP_EXPORT -SCIP_RETCODE SCIPlpiSetRealpar( - SCIP_LPI* lpi, /**< LP interface structure */ - SCIP_LPPARAM type, /**< parameter number */ - SCIP_Real dval /**< parameter value */ - ); - -/** interrupts the currently ongoing lp solve or disables the interrupt */ -SCIP_EXPORT -SCIP_RETCODE SCIPlpiInterrupt( - SCIP_LPI* lpi, /**< LP interface structure */ - SCIP_Bool interrupt /**< TRUE if interrupt should be set, FALSE if it should be disabled */ - ); - -/**@} */ - - - - -/* - * Numerical Methods - */ - -/**@name Numerical Methods */ -/**@{ */ - -/** returns value treated as infinity in the LP solver */ -SCIP_EXPORT -SCIP_Real SCIPlpiInfinity( - SCIP_LPI* lpi /**< LP interface structure */ - ); - -/** checks if given value is treated as infinity in the LP solver */ -SCIP_EXPORT -SCIP_Bool SCIPlpiIsInfinity( - SCIP_LPI* lpi, /**< LP interface structure */ - SCIP_Real val /**< value to be checked for infinity */ - ); - -/**@} */ - - - - -/* - * File Interface Methods - */ - -/**@name File Interface Methods */ -/**@{ */ - -/** reads LP from a file */ -SCIP_EXPORT -SCIP_RETCODE SCIPlpiReadLP( - SCIP_LPI* lpi, /**< LP interface structure */ - const char* fname /**< file name */ - ); - -/** writes LP to a file */ -SCIP_EXPORT -SCIP_RETCODE SCIPlpiWriteLP( - SCIP_LPI* lpi, /**< LP interface structure */ - const char* fname /**< file name */ - ); - -/**@} */ - -/**@} */ - - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/headers/lpi/type_lpi.h b/headers/lpi/type_lpi.h deleted file mode 100644 index b68bdcf..0000000 --- a/headers/lpi/type_lpi.h +++ /dev/null @@ -1,114 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* */ -/* This file is part of the program and library */ -/* SCIP --- Solving Constraint Integer Programs */ -/* */ -/* Copyright 2002-2022 Zuse Institute Berlin */ -/* */ -/* Licensed under the Apache License, Version 2.0 (the "License"); */ -/* you may not use this file except in compliance with the License. */ -/* You may obtain a copy of the License at */ -/* */ -/* http://www.apache.org/licenses/LICENSE-2.0 */ -/* */ -/* Unless required by applicable law or agreed to in writing, software */ -/* distributed under the License is distributed on an "AS IS" BASIS, */ -/* 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. */ -/* */ -/* You should have received a copy of the Apache-2.0 license */ -/* along with SCIP; see the file LICENSE. If not visit scipopt.org. */ -/* */ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -/**@file type_lpi.h - * @brief type definitions for specific LP solvers interface - * @author Tobias Achterberg - */ - -/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/ - -#ifndef __SCIP_TYPE_LPI_H__ -#define __SCIP_TYPE_LPI_H__ - -#ifdef __cplusplus -extern "C" { -#endif - -/** objective sense */ -enum SCIP_ObjSen -{ - SCIP_OBJSEN_MAXIMIZE = -1, /**< maximize objective function */ - SCIP_OBJSEN_MINIMIZE = +1 /**< minimize objective function */ -}; -typedef enum SCIP_ObjSen SCIP_OBJSEN; - -/** LP solver parameters */ -enum SCIP_LPParam -{ - SCIP_LPPAR_FROMSCRATCH = 0, /**< solver should start from scratch at next call? */ - SCIP_LPPAR_FASTMIP = 1, /**< fast mip setting of LP solver */ - SCIP_LPPAR_SCALING = 2, /**< should LP solver use scaling? */ - SCIP_LPPAR_PRESOLVING = 3, /**< should LP solver use presolving? */ - SCIP_LPPAR_PRICING = 4, /**< pricing strategy */ - SCIP_LPPAR_LPINFO = 5, /**< should LP solver output information to the screen? */ - SCIP_LPPAR_FEASTOL = 6, /**< feasibility tolerance for primal variables and slacks, strictly positive */ - SCIP_LPPAR_DUALFEASTOL = 7, /**< feasibility tolerance for dual variables and reduced costs, strictly positive */ - SCIP_LPPAR_BARRIERCONVTOL = 8, /**< convergence tolerance used in barrier algorithm */ - SCIP_LPPAR_OBJLIM = 9, /**< objective limit (stop if objective is known be larger/smaller than limit for min/max-imization) */ - SCIP_LPPAR_LPITLIM = 10, /**< LP iteration limit, greater than or equal 0 */ - SCIP_LPPAR_LPTILIM = 11, /**< LP time limit, positive */ - SCIP_LPPAR_MARKOWITZ = 12, /**< Markowitz tolerance */ - SCIP_LPPAR_ROWREPSWITCH = 13, /**< simplex algorithm shall use row representation of the basis - * if number of rows divided by number of columns exceeds this value - * (0 <= value or -1 = valu ; if negative, this change never occurs) */ - SCIP_LPPAR_THREADS = 14, /**< number of threads used to solve the LP */ - SCIP_LPPAR_CONDITIONLIMIT = 15, /**< maximum condition number of LP basis counted as stable */ - SCIP_LPPAR_TIMING = 16, /**< type of timer (1 - cpu, 2 - wallclock, 0 - off) */ - SCIP_LPPAR_RANDOMSEED = 17, /**< inital random seed, e.g. for perturbations in the simplex (0: LP default) */ - SCIP_LPPAR_POLISHING = 18, /**< set solution polishing (0 - disable, 1 - enable) */ - SCIP_LPPAR_REFACTOR = 19 /**< set refactorization interval (0 - automatic) */ -}; -typedef enum SCIP_LPParam SCIP_LPPARAM; - -/** LP pricing strategy */ -enum SCIP_Pricing -{ - SCIP_PRICING_LPIDEFAULT = 0, /**< the SCIP/LP interface should use its preferred strategy */ - SCIP_PRICING_AUTO = 1, /**< the LP solver should use its preferred strategy */ - SCIP_PRICING_FULL = 2, /**< full pricing */ - SCIP_PRICING_PARTIAL = 3, /**< partial pricing */ - SCIP_PRICING_STEEP = 4, /**< steepest edge pricing */ - SCIP_PRICING_STEEPQSTART = 5, /**< steepest edge pricing without initial dual norms */ - SCIP_PRICING_DEVEX = 6 /**< devex pricing */ -}; -typedef enum SCIP_Pricing SCIP_PRICING; - -/** basis status for columns and rows */ -enum SCIP_BaseStat -{ - SCIP_BASESTAT_LOWER = 0, /**< (slack) variable is at its lower bound */ - SCIP_BASESTAT_BASIC = 1, /**< (slack) variable is basic */ - SCIP_BASESTAT_UPPER = 2, /**< (slack) variable is at its upper bound */ - SCIP_BASESTAT_ZERO = 3 /**< free variable is non-basic and set to zero */ -}; -typedef enum SCIP_BaseStat SCIP_BASESTAT; - -/** LP solution quality quantities */ -enum SCIP_LPSolQuality -{ - SCIP_LPSOLQUALITY_ESTIMCONDITION = 0, /**< estimated condition number of (scaled) basis matrix (SCIP_Real) */ - SCIP_LPSOLQUALITY_EXACTCONDITION = 1 /**< exact condition number of (scaled) basis matrix (SCIP_Real) */ -}; -typedef enum SCIP_LPSolQuality SCIP_LPSOLQUALITY; - -typedef struct SCIP_LPi SCIP_LPI; /**< solver dependent LP interface */ -typedef struct SCIP_LPiState SCIP_LPISTATE; /**< complete LP state (i.e. basis information) */ -typedef struct SCIP_LPiNorms SCIP_LPINORMS; /**< LP pricing norms information */ - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/headers/objscip/objbenders.h b/headers/objscip/objbenders.h deleted file mode 100644 index 33ccc87..0000000 --- a/headers/objscip/objbenders.h +++ /dev/null @@ -1,329 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* */ -/* This file is part of the program and library */ -/* SCIP --- Solving Constraint Integer Programs */ -/* */ -/* Copyright 2002-2022 Zuse Institute Berlin */ -/* */ -/* Licensed under the Apache License, Version 2.0 (the "License"); */ -/* you may not use this file except in compliance with the License. */ -/* You may obtain a copy of the License at */ -/* */ -/* http://www.apache.org/licenses/LICENSE-2.0 */ -/* */ -/* Unless required by applicable law or agreed to in writing, software */ -/* distributed under the License is distributed on an "AS IS" BASIS, */ -/* 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. */ -/* */ -/* You should have received a copy of the Apache-2.0 license */ -/* along with SCIP; see the file LICENSE. If not visit scipopt.org. */ -/* */ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -/**@file objbenders.h - * @brief C++ wrapper for Benders' decomposition - * @author Stephen J. Maher - */ - -/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/ - -#ifndef __SCIP_OBJBENDERS_H__ -#define __SCIP_OBJBENDERS_H__ - - -#include -#include -#include - -#include "scip/scip.h" -#include "objscip/objcloneable.h" - -namespace scip -{ - -/** - * @brief C++ wrapper for Benders' decomposition plugins - * - * This class defines the interface for the Benders' decomposition framework implemented in C++. Note that there - * are pure virtual functions (these have to be implemented). These functions are: benders_exec(), benders_createsub(), - * benders_getvar(). - * - * - \ref BENDER "Instructions for implementing a Benders' decomposition plugin" - * - \ref BENDERS "List of available Benders' decomposition plugins" - * - \ref type_benders.h "Corresponding C interface" - */ -class ObjBenders : public ObjCloneable -{ -public: - /*lint --e{1540}*/ - - /** SCIP data structure */ - SCIP* scip_; - - /** name of the Benders' decomposition */ - char* scip_name_; - - /** description of the Benders' decomposition */ - char* scip_desc_; - - /** the priority of the Benders' decomposition */ - const int scip_priority_; - - /** should cuts be generated from the LP solution */ - const SCIP_Bool scip_cutlp_; - - /** should cuts be generated from the pseudo solution */ - const SCIP_Bool scip_cutpseudo_; - - /** should cuts be generated from the relaxation solution */ - const SCIP_Bool scip_cutrelax_; - - /** should this Benders' decomposition share the auxiliary variables from the highest priority Benders? */ - const SCIP_Bool scip_shareauxvars_; - - /** default constructor */ - ObjBenders( - SCIP* scip, /**< SCIP data structure */ - const char* name, /**< name of Benders' decomposition */ - const char* desc, /**< description of Benders' decomposition */ - int priority, /**< priority of the Benders' decomposition */ - SCIP_Bool cutlp, /**< should Benders' cuts be generated for LP solutions */ - SCIP_Bool cutpseudo, /**< should Benders' cuts be generated for pseudo solutions */ - SCIP_Bool cutrelax, /**< should Benders' cuts be generated for relaxation solutions */ - SCIP_Bool shareauxvars /**< should this Benders' use the highest priority Benders' aux vars */ - ) - : scip_(scip), - scip_name_(0), - scip_desc_(0), - scip_priority_(priority), - scip_cutlp_(cutlp), - scip_cutpseudo_(cutpseudo), - scip_cutrelax_(cutrelax), - scip_shareauxvars_(shareauxvars) - { - /* the macro SCIPduplicateMemoryArray does not need the first argument: */ - SCIP_CALL_ABORT( SCIPduplicateMemoryArray(scip_, &scip_name_, name, std::strlen(name)+1) ); - SCIP_CALL_ABORT( SCIPduplicateMemoryArray(scip_, &scip_desc_, desc, std::strlen(desc)+1) ); - } - - /** copy constructor */ - ObjBenders(const ObjBenders& o) - : ObjBenders(o.scip_, o.scip_name_, o.scip_desc_, o.scip_priority_, o.scip_cutlp_, o.scip_cutpseudo_, - o.scip_cutrelax_, o.scip_shareauxvars_) - { - } - - /** move constructor */ - ObjBenders(ObjBenders&& o) - : scip_(o.scip_), - scip_name_(0), - scip_desc_(0), - scip_priority_(o.scip_priority_), - scip_cutlp_(o.scip_cutlp_), - scip_cutpseudo_(o.scip_cutpseudo_), - scip_cutrelax_(o.scip_cutrelax_), - scip_shareauxvars_(o.scip_shareauxvars_) - { - std::swap(scip_name_, o.scip_name_); - std::swap(scip_desc_, o.scip_desc_); - } - - /** destructor */ - virtual ~ObjBenders() - { - /* the macro SCIPfreeMemoryArray does not need the first argument: */ - /*lint --e{64}*/ - SCIPfreeMemoryArray(scip_, &scip_name_); - SCIPfreeMemoryArray(scip_, &scip_desc_); - } - - /** assignment of polymorphic classes causes slicing and is therefore disabled. */ - ObjBenders& operator=(const ObjBenders& o) = delete; - - /** assignment of polymorphic classes causes slicing and is therefore disabled. */ - ObjBenders& operator=(ObjBenders&& o) = delete; - - /** copy method for benders plugins (called when SCIP copies plugins) - * - * @see SCIP_DECL_BENDERSCOPY(x) in @ref type_benders.h - */ - virtual SCIP_DECL_BENDERSCOPY(scip_copy) - { /*lint --e{715}*/ - return SCIP_OKAY; - } - - /** destructor of variable benders to free user data (called when SCIP is exiting) - * - * @see SCIP_DECL_BENDERSFREE(x) in @ref type_benders.h - */ - virtual SCIP_DECL_BENDERSFREE(scip_free) - { /*lint --e{715}*/ - return SCIP_OKAY; - } - - /** initialization method of variable benders (called after problem was transformed and benders is active) - * - * @see SCIP_DECL_BENDERSINIT(x) in @ref type_benders.h - */ - virtual SCIP_DECL_BENDERSINIT(scip_init) - { /*lint --e{715}*/ - return SCIP_OKAY; - } - - /** deinitialization method of variable benders (called before transformed problem is freed and benders is active) - * - * @see SCIP_DECL_BENDERSEXIT(x) in @ref type_benders.h - */ - virtual SCIP_DECL_BENDERSEXIT(scip_exit) - { /*lint --e{715}*/ - return SCIP_OKAY; - } - - /** presolving initialization method of constraint handler (called when presolving is about to begin) - * - * @see SCIP_DECL_BENDERSINITPRE(x) in @ref type_benders.h - */ - virtual SCIP_DECL_BENDERSINITPRE(scip_initpre) - { /*lint --e{715}*/ - return SCIP_OKAY; - } - - /** presolving deinitialization method of constraint handler (called after presolving has been finished) - * - * @see SCIP_DECL_BENDERSEXITPRE(x) in @ref type_benders.h - */ - virtual SCIP_DECL_BENDERSEXITPRE(scip_exitpre) - { /*lint --e{715}*/ - return SCIP_OKAY; - } - - /** solving process initialization method of variable benders (called when branch and bound process is about to begin) - * - * @see SCIP_DECL_BENDERSINITSOL(x) in @ref type_benders.h - */ - virtual SCIP_DECL_BENDERSINITSOL(scip_initsol) - { /*lint --e{715}*/ - return SCIP_OKAY; - } - - /** solving process deinitialization method of variable benders (called before branch and bound process data is freed) - * - * @see SCIP_DECL_BENDERSEXITSOL(x) in @ref type_benders.h - */ - virtual SCIP_DECL_BENDERSEXITSOL(scip_exitsol) - { /*lint --e{715}*/ - return SCIP_OKAY; - } - - /** the method for creating the Benders' decomposition subproblem. This method is called during the initialisation stage - * (after the master problem was transformed) - * - * @see SCIP_DECL_BENDERSCREATESUB(x) in @ref type_benders.h - */ - virtual SCIP_DECL_BENDERSCREATESUB(scip_createsub) = 0; - - /** called before the subproblem solving loop for Benders' decomposition. The pre subproblem solve function gives the - * user an oppportunity to perform any global set up for the Benders' decomposition. - * - * @see SCIP_DECL_BENDERSPRESUBSOLVE(x) in @ref type_benders.h - */ - virtual SCIP_DECL_BENDERSPRESUBSOLVE(scip_presubsolve) - { /*lint --e{715}*/ - return SCIP_OKAY; - } - - /** the solving method for a single convex Benders' decomposition subproblem. The solving methods are separated so - * that they can be called in parallel. - * - * @see SCIP_DECL_BENDERSSOLVESUBCONVEX(x) in @ref type_benders.h - */ - virtual SCIP_DECL_BENDERSSOLVESUBCONVEX(scip_solvesubconvex) - { /*lint --e{715}*/ - return SCIP_OKAY; - } - - /** the solving method for a single Benders' decomposition subproblem. The solving methods are separated so that they - * can be called in parallel. - * - * @see SCIP_DECL_BENDERSSOLVESUB(x) in @ref type_benders.h - */ - virtual SCIP_DECL_BENDERSSOLVESUB(scip_solvesub) - { /*lint --e{715}*/ - return SCIP_OKAY; - } - - /** the post-solve method for Benders' decomposition. The post-solve method is called after the subproblems have - * been solved but before they are freed. - * @see SCIP_DECL_BENDERSPOSTSOLVE(x) in @ref type_benders.h - */ - virtual SCIP_DECL_BENDERSPOSTSOLVE(scip_postsolve) - { /*lint --e{715}*/ - return SCIP_OKAY; - } - - /** frees the subproblem so that it can be resolved in the next iteration. In the SCIP case, this involves freeing the - * transformed problem using SCIPfreeTransform() - * - * @see SCIP_DECL_BENDERSFREESUB(x) in @ref type_benders.h - */ - virtual SCIP_DECL_BENDERSFREESUB(scip_freesub) - { /*lint --e{715}*/ - return SCIP_OKAY; - } - - /** the variable mapping from the subproblem to the master problem. - * - * @see SCIP_DECL_BENDERSGETVAR(x) in @ref type_benders.h - */ - virtual SCIP_DECL_BENDERSGETVAR(scip_getvar) = 0; - -}; - -} /* namespace scip */ - - - -/** creates the Benders' decomposition for the given Benders' decomposition object and includes it in SCIP - * - * The method should be called in one of the following ways: - * - * 1. The user is resposible of deleting the object: - * SCIP_CALL( SCIPcreate(&scip) ); - * ... - * MyBenders* mybenders = new MyBenders(...); - * SCIP_CALL( SCIPincludeObjBenders(scip, &mybenders, FALSE) ); - * ... - * SCIP_CALL( SCIPfree(&scip) ); - * delete mybenders; // delete benders AFTER SCIPfree() ! - * - * 2. The object pointer is passed to SCIP and deleted by SCIP in the SCIPfree() call: - * SCIP_CALL( SCIPcreate(&scip) ); - * ... - * SCIP_CALL( SCIPincludeObjBenders(scip, new MyBenders(...), TRUE) ); - * ... - * SCIP_CALL( SCIPfree(&scip) ); // destructor of MyBenders is called here - */ -SCIP_EXPORT -SCIP_RETCODE SCIPincludeObjBenders( - SCIP* scip, /**< SCIP data structure */ - scip::ObjBenders* objbenders, /**< Benders' decomposition object */ - SCIP_Bool deleteobject /**< should the Benders' decomposition object be deleted when benders is freed? */ - ); - -/** returns the benders object of the given name, or 0 if not existing */ -SCIP_EXPORT -scip::ObjBenders* SCIPfindObjBenders( - SCIP* scip, /**< SCIP data structure */ - const char* name /**< name of Benders' decomposition */ - ); - -/** returns the benders object for the given constraint handler */ -SCIP_EXPORT -scip::ObjBenders* SCIPgetObjBenders( - SCIP* scip, /**< SCIP data structure */ - SCIP_BENDERS* benders /**< Benders' decomposition */ - ); - -#endif diff --git a/headers/objscip/objbenderscut.h b/headers/objscip/objbenderscut.h deleted file mode 100644 index b01b1cb..0000000 --- a/headers/objscip/objbenderscut.h +++ /dev/null @@ -1,236 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* */ -/* This file is part of the program and library */ -/* SCIP --- Solving Constraint Integer Programs */ -/* */ -/* Copyright 2002-2022 Zuse Institute Berlin */ -/* */ -/* Licensed under the Apache License, Version 2.0 (the "License"); */ -/* you may not use this file except in compliance with the License. */ -/* You may obtain a copy of the License at */ -/* */ -/* http://www.apache.org/licenses/LICENSE-2.0 */ -/* */ -/* Unless required by applicable law or agreed to in writing, software */ -/* distributed under the License is distributed on an "AS IS" BASIS, */ -/* 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. */ -/* */ -/* You should have received a copy of the Apache-2.0 license */ -/* along with SCIP; see the file LICENSE. If not visit scipopt.org. */ -/* */ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -/**@file objbenderscut.h - * @brief C++ wrapper for Benders' decomposition cuts - * @author Stephen J. Maher - */ - -/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/ - -#ifndef __SCIP_OBJBENDERSCUT_H__ -#define __SCIP_OBJBENDERSCUT_H__ - - -#include -#include -#include - -#include "scip/scip.h" -#include "objscip/objcloneable.h" -#include "objscip/objbenders.h" - -namespace scip -{ - -/** - * @brief C++ wrapper for Benders' decomposition cut - * - * This class defines the interface for the Benders' decomposition cuts implemented in C++. Note that there is - * a pure virtual function (this must be implemented). This function is: benderscut_exec(). - * - * - \ref BENDERSCUT "Instructions for implementing a Benders' decomposition plugin" - * - \ref BENDERSCUTS "List of available Benders' decomposition plugins" - * - \ref type_benderscut.h "Corresponding C interface" - */ -class ObjBenderscut : public ObjCloneable -{ -public: - /*lint --e{1540}*/ - - /** SCIP data structure */ - SCIP* scip_; - - /** name of the Benders' decomposition cut */ - char* scip_name_; - - /** description of the Benders' decomposition cut */ - char* scip_desc_; - - /** the priority of the Benders' decomposition cut */ - const int scip_priority_; - - /** is the Benders' decomposition cut generated from the LP relaxation of the subproblem */ - const SCIP_Bool scip_islpcut_; - - /** default constructor */ - ObjBenderscut( - SCIP* scip, /**< SCIP data structure */ - const char* name, /**< name of Benders' decomposition */ - const char* desc, /**< description of Benders' decomposition */ - int priority, /**< priority of the Benders' decomposition */ - SCIP_Bool islpcut /**< is the cut generated from the LP relaxation */ - ) - : scip_(scip), - scip_name_(0), - scip_desc_(0), - scip_priority_(priority), - scip_islpcut_(islpcut) - { - /* the macro SCIPduplicateMemoryArray does not need the first argument: */ - SCIP_CALL_ABORT( SCIPduplicateMemoryArray(scip_, &scip_name_, name, std::strlen(name)+1) ); - SCIP_CALL_ABORT( SCIPduplicateMemoryArray(scip_, &scip_desc_, desc, std::strlen(desc)+1) ); - } - - /** copy constructor */ - ObjBenderscut(const ObjBenderscut& o) - : ObjBenderscut(o.scip_, o.scip_name_, o.scip_desc_, o.scip_priority_, o.scip_islpcut_) - { - } - - /** move constructor */ - ObjBenderscut(ObjBenderscut&& o) - : scip_(o.scip_), scip_name_(0), scip_desc_(0), scip_priority_(o.scip_priority_), scip_islpcut_(o.scip_islpcut_) - { - std::swap(scip_name_, o.scip_name_); - std::swap(scip_desc_, o.scip_desc_); - } - - /** destructor */ - virtual ~ObjBenderscut() - { - /* the macro SCIPfreeMemoryArray does not need the first argument: */ - /*lint --e{64}*/ - SCIPfreeMemoryArray(scip_, &scip_name_); - SCIPfreeMemoryArray(scip_, &scip_desc_); - } - - /** assignment of polymorphic classes causes slicing and is therefore disabled. */ - ObjBenderscut& operator=(const ObjBenderscut& o) = delete; - - /** assignment of polymorphic classes causes slicing and is therefore disabled. */ - ObjBenderscut& operator=(ObjBenderscut&& o) = delete; - - /** copy method for compression plugins (called when SCIP copies plugins) - * - * @see SCIP_DECL_BENDERSCUTCOPY(x) in @ref type_benders.h - */ - virtual SCIP_DECL_BENDERSCUTCOPY(scip_copy) - { /*lint --e{715}*/ - return SCIP_OKAY; - } - - /** destructor of Benders' decomposition cuts to free user data (called when SCIP is exiting) - * - * @see SCIP_DECL_BENDERSCUTFREE(x) in @ref type_benders.h - */ - virtual SCIP_DECL_BENDERSCUTFREE(scip_free) - { /*lint --e{715}*/ - return SCIP_OKAY; - } - - /** initialization method of Benders' decomposition cuts (called after problem was transformed) - * - * @see SCIP_DECL_BENDERSCUTINIT(x) in @ref type_benders.h - */ - virtual SCIP_DECL_BENDERSCUTINIT(scip_init) - { /*lint --e{715}*/ - return SCIP_OKAY; - } - - /** deinitialization method of Benders' decomposition cuts (called before transformed problem is freed) - * - * @see SCIP_DECL_BENDERSCUTEXIT(x) in @ref type_benders.h - */ - virtual SCIP_DECL_BENDERSCUTEXIT(scip_exit) - { /*lint --e{715}*/ - return SCIP_OKAY; - } - - /** solving process initialization method of Benders' decomposition cuts (called when branch and bound process is about to begin) - * - * @see SCIP_DECL_BENDERSCUTINITSOL(x) in @ref type_benders.h - */ - virtual SCIP_DECL_BENDERSCUTINITSOL(scip_initsol) - { /*lint --e{715}*/ - return SCIP_OKAY; - } - - /** solving process deinitialization method of Benders' decomposition cuts (called before branch and bound process data is freed) - * - * This method is called before the branch and bound process is freed. - * The Benders' decomposition cuts should use this call to clean up its branch and bound data. - * - * @see SCIP_DECL_BENDERSCUTEXITSOL(x) in @ref type_benders.h - */ - virtual SCIP_DECL_BENDERSCUTEXITSOL(scip_exitsol) - { /*lint --e{715}*/ - return SCIP_OKAY; - } - - /** execution method of Benders' decomposition cuts technique - * - * @see SCIP_DECL_BENDERSCUTEXEC(x) in @ref type_benders.h - */ - virtual SCIP_DECL_BENDERSCUTEXEC(scip_exec) = 0; - -}; - -} /* namespace scip */ - - - -/** creates the Benders' decomposition cut for the given Benders' decomposition cut object and includes it in SCIP - * - * The method should be called in one of the following ways: - * - * 1. The user is responsible for deleting the object: - * SCIP_CALL( SCIPcreate(&scip) ); - * ... - * MyBenderscut* mybenderscut = new MyBenderscut(...); - * SCIP_CALL( SCIPincludeObjBenderscut(scip, benders, &mybenderscut, FALSE) ); - * ... - * SCIP_CALL( SCIPfree(&scip) ); - * delete mybenderscut; // delete benderscut AFTER SCIPfree() ! - * - * 2. The object pointer is passed to SCIP and deleted by SCIP in the SCIPfree() call: - * SCIP_CALL( SCIPcreate(&scip) ); - * ... - * SCIP_CALL( SCIPincludeObjBenderscut(scip, benders, new MyBenderscut(...), TRUE) ); - * ... - * SCIP_CALL( SCIPfree(&scip) ); // destructor of MyBenderscut is called here - */ -SCIP_EXPORT -SCIP_RETCODE SCIPincludeObjBenderscut( - SCIP* scip, /**< SCIP data structure */ - scip::ObjBenders* objbenders, /**< Benders' decomposition object */ - scip::ObjBenderscut* objbenderscut, /**< Benders' decomposition cut object */ - SCIP_Bool deleteobject /**< should the Benders' cut object be deleted when benderscut is freed? */ - ); - -/** returns the benderscut object of the given name, or 0 if not existing */ -SCIP_EXPORT -scip::ObjBenderscut* SCIPfindObjBenderscut( - scip::ObjBenders* objbenders, /**< Benders' decomposition object */ - const char* name /**< name of Benders' decomposition cut */ - ); - -/** returns the benderscut object for the given constraint handler */ -SCIP_EXPORT -scip::ObjBenderscut* SCIPgetObjBenderscut( - SCIP* scip, /**< SCIP data structure */ - SCIP_BENDERSCUT* benderscut /**< Benders' decomposition cut */ - ); - -#endif diff --git a/headers/objscip/objbranchrule.h b/headers/objscip/objbranchrule.h deleted file mode 100644 index 1cb2d52..0000000 --- a/headers/objscip/objbranchrule.h +++ /dev/null @@ -1,261 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* */ -/* This file is part of the program and library */ -/* SCIP --- Solving Constraint Integer Programs */ -/* */ -/* Copyright 2002-2022 Zuse Institute Berlin */ -/* */ -/* Licensed under the Apache License, Version 2.0 (the "License"); */ -/* you may not use this file except in compliance with the License. */ -/* You may obtain a copy of the License at */ -/* */ -/* http://www.apache.org/licenses/LICENSE-2.0 */ -/* */ -/* Unless required by applicable law or agreed to in writing, software */ -/* distributed under the License is distributed on an "AS IS" BASIS, */ -/* 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. */ -/* */ -/* You should have received a copy of the Apache-2.0 license */ -/* along with SCIP; see the file LICENSE. If not visit scipopt.org. */ -/* */ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -/**@file objbranchrule.h - * @brief C++ wrapper for branching rules - * @author Tobias Achterberg - */ - -/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/ - -#ifndef __SCIP_OBJBRANCHRULE_H__ -#define __SCIP_OBJBRANCHRULE_H__ - - -#include -#include -#include - -#include "scip/scip.h" -#include "objscip/objcloneable.h" - -namespace scip -{ - -/** - * @brief C++ wrapper for branching rules - * - * This class defines the interface for branching rules implemented in C++. - * - * - \ref BRANCH "Instructions for implementing a branching rule" - * - \ref BRANCHINGRULES "List of available branching rules" - * - \ref type_branch.h "Corresponding C interface" - */ -class ObjBranchrule : public ObjCloneable -{ -public: - /*lint --e{1540}*/ - - /** SCIP data structure */ - SCIP* scip_; - - /** name of the branching rule */ - char* scip_name_; - - /** description of the branching rule */ - char* scip_desc_; - - /** default priority of the branching rule */ - const int scip_priority_; - - /** default maximal depth for applying the branching rule */ - const int scip_maxdepth_; - - /** default maximal relative distance from current node's dual bound to primal bound - * compared to best node's dual bound for applying branching rule - * (0.0: only on current best node, 1.0: on all nodes) - */ - const SCIP_Real scip_maxbounddist_; - - /** default constructor */ - ObjBranchrule( - SCIP* scip, /**< SCIP data structure */ - const char* name, /**< name of branching rule */ - const char* desc, /**< description of branching rule */ - int priority, /**< priority of the branching rule */ - int maxdepth, /**< maximal depth level, up to which this branching rule should be used (or -1) */ - SCIP_Real maxbounddist /**< maximal relative distance from current node's dual bound to primal bound - * compared to best node's dual bound for applying branching rule - * (0.0: only on current best node, 1.0: on all nodes) */ - ) - : scip_(scip), - scip_name_(0), - scip_desc_(0), - scip_priority_(priority), - scip_maxdepth_(maxdepth), - scip_maxbounddist_(maxbounddist) - { - /* the macro SCIPduplicateMemoryArray does not need the first argument: */ - SCIP_CALL_ABORT( SCIPduplicateMemoryArray(scip_, &scip_name_, name, std::strlen(name)+1) ); - SCIP_CALL_ABORT( SCIPduplicateMemoryArray(scip_, &scip_desc_, desc, std::strlen(desc)+1) ); - } - - /** copy constructor */ - ObjBranchrule(const ObjBranchrule& o) - : ObjBranchrule(o.scip_, o.scip_name_, o.scip_desc_, o.scip_priority_, o.scip_maxdepth_, o.scip_maxbounddist_) - { - } - - /** move constructor */ - ObjBranchrule(ObjBranchrule&& o) - : scip_(o.scip_), - scip_name_(0), - scip_desc_(0), - scip_priority_(o.scip_priority_), - scip_maxdepth_(o.scip_maxdepth_), - scip_maxbounddist_(o.scip_maxbounddist_) - { - std::swap(scip_name_, o.scip_name_); - std::swap(scip_desc_, o.scip_desc_); - } - - /** destructor */ - virtual ~ObjBranchrule() - { - /* the macro SCIPfreeMemoryArray does not need the first argument: */ - /*lint --e{64}*/ - SCIPfreeMemoryArray(scip_, &scip_name_); - SCIPfreeMemoryArray(scip_, &scip_desc_); - } - - /** assignment of polymorphic classes causes slicing and is therefore disabled. */ - ObjBranchrule& operator=(const ObjBranchrule& o) = delete; - - /** assignment of polymorphic classes causes slicing and is therefore disabled. */ - ObjBranchrule& operator=(ObjBranchrule&& o) = delete; - - /** destructor of branching rule to free user data (called when SCIP is exiting) - * - * @see SCIP_DECL_BRANCHFREE(x) in @ref type_branch.h - */ - virtual SCIP_DECL_BRANCHFREE(scip_free) - { /*lint --e{715}*/ - return SCIP_OKAY; - } - - /** initialization method of branching rule (called after problem was transformed) - * - * @see SCIP_DECL_BRANCHINIT(x) in @ref type_branch.h - */ - virtual SCIP_DECL_BRANCHINIT(scip_init) - { /*lint --e{715}*/ - return SCIP_OKAY; - } - - /** deinitialization method of branching rule (called before transformed problem is freed) - * - * @see SCIP_DECL_BRANCHEXIT(x) in @ref type_branch.h - */ - virtual SCIP_DECL_BRANCHEXIT(scip_exit) - { /*lint --e{715}*/ - return SCIP_OKAY; - } - - /** solving process initialization method of branching rule (called when branch and bound process is about to begin) - * - * @see SCIP_DECL_BRANCHINITSOL(x) in @ref type_branch.h - */ - virtual SCIP_DECL_BRANCHINITSOL(scip_initsol) - { /*lint --e{715}*/ - return SCIP_OKAY; - } - - /** solving process deinitialization method of branching rule (called before branch and bound process data is freed) - * - * @see SCIP_DECL_BRANCHEXITSOL(x) in @ref type_branch.h - */ - virtual SCIP_DECL_BRANCHEXITSOL(scip_exitsol) - { /*lint --e{715}*/ - return SCIP_OKAY; - } - - /** branching execution method for fractional LP solutions - * - * @see SCIP_DECL_BRANCHEXECLP(x) in @ref type_branch.h - */ - virtual SCIP_DECL_BRANCHEXECLP(scip_execlp) - { /*lint --e{715}*/ - assert(result != NULL); - *result = SCIP_DIDNOTRUN; - return SCIP_OKAY; - } - - /** branching execution method for external candidates - * - * @see SCIP_DECL_BRANCHEXECEXT(x) in @ref type_branch.h - */ - virtual SCIP_DECL_BRANCHEXECEXT(scip_execext) - { /*lint --e{715}*/ - assert(result != NULL); - *result = SCIP_DIDNOTRUN; - return SCIP_OKAY; - } - - /** branching execution method for not completely fixed pseudo solutions - * - * @see SCIP_DECL_BRANCHEXECPS(x) in @ref type_branch.h - */ - virtual SCIP_DECL_BRANCHEXECPS(scip_execps) - { /*lint --e{715}*/ - assert(result != NULL); - *result = SCIP_DIDNOTRUN; - return SCIP_OKAY; - } -}; - -} /* namespace scip */ - - -/** creates the branching rule for the given branching rule object and includes it in SCIP - * - * The method should be called in one of the following ways: - * - * 1. The user is resposible of deleting the object: - * SCIP_CALL( SCIPcreate(&scip) ); - * ... - * MyBranchrule* mybranchrule = new MyBranchrule(...); - * SCIP_CALL( SCIPincludeObjBranchrule(scip, &mybranchrule, FALSE) ); - * ... - * SCIP_CALL( SCIPfree(&scip) ); - * delete mybranchrule; // delete branchrule AFTER SCIPfree() ! - * - * 2. The object pointer is passed to SCIP and deleted by SCIP in the SCIPfree() call: - * SCIP_CALL( SCIPcreate(&scip) ); - * ... - * SCIP_CALL( SCIPincludeObjBranchrule(scip, new MyBranchrule(...), TRUE) ); - * ... - * SCIP_CALL( SCIPfree(&scip) ); // destructor of MyBranchrule is called here - */ -SCIP_EXPORT -SCIP_RETCODE SCIPincludeObjBranchrule( - SCIP* scip, /**< SCIP data structure */ - scip::ObjBranchrule* objbranchrule, /**< branching rule object */ - SCIP_Bool deleteobject /**< should the branching rule object be deleted when branching rule is freed? */ - ); - -/** returns the branchrule object of the given name, or 0 if not existing */ -SCIP_EXPORT -scip::ObjBranchrule* SCIPfindObjBranchrule( - SCIP* scip, /**< SCIP data structure */ - const char* name /**< name of branching rule */ - ); - -/** returns the branchrule object for the given branching rule */ -SCIP_EXPORT -scip::ObjBranchrule* SCIPgetObjBranchrule( - SCIP* scip, /**< SCIP data structure */ - SCIP_BRANCHRULE* branchrule /**< branching rule */ - ); - -#endif diff --git a/headers/objscip/objcloneable.h b/headers/objscip/objcloneable.h deleted file mode 100644 index 0dddb0b..0000000 --- a/headers/objscip/objcloneable.h +++ /dev/null @@ -1,71 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* */ -/* This file is part of the program and library */ -/* SCIP --- Solving Constraint Integer Programs */ -/* */ -/* Copyright 2002-2022 Zuse Institute Berlin */ -/* */ -/* Licensed under the Apache License, Version 2.0 (the "License"); */ -/* you may not use this file except in compliance with the License. */ -/* You may obtain a copy of the License at */ -/* */ -/* http://www.apache.org/licenses/LICENSE-2.0 */ -/* */ -/* Unless required by applicable law or agreed to in writing, software */ -/* distributed under the License is distributed on an "AS IS" BASIS, */ -/* 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. */ -/* */ -/* You should have received a copy of the Apache-2.0 license */ -/* along with SCIP; see the file LICENSE. If not visit scipopt.org. */ -/* */ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -/**@file objcloneable.h - * @brief definition of base class for all clonable classes - * @author Michael Winkler - */ - -/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/ - -#ifndef __SCIP_OBJCLONEABLE_H__ -#define __SCIP_OBJCLONEABLE_H__ - -#include "scip/def.h" -#include "scip/scip.h" -#include "objscip/type_objcloneable.h" - - -namespace scip -{ - /** @brief Definition of base class for all clonable classes - * - * All C++ wrapper object plugins should extend this class, except constraint handlers and variable pricers. This is - * needed to be able to copy (clone) a SCIP instance. - */ - struct ObjCloneable - { - virtual ~ObjCloneable() {} - - /** assignment of polymorphic classes causes slicing and is therefore disabled. */ - ObjCloneable& operator=(const ObjCloneable& o) = delete; - - /** assignment of polymorphic classes causes slicing and is therefore disabled. */ - ObjCloneable& operator=(ObjCloneable&& o) = delete; - - /** clone method, used to copy plugins which are not constraint handlers or variable pricer plugins */ - virtual SCIP_DECL_OBJCLONEABLECLONE(ObjCloneable* clone) - { - return 0; - } - - /** returns whether the plugin object is copyable */ - virtual SCIP_DECL_OBJCLONEABLEISCLONEABLE(iscloneable) - { - return false; - } - }; -} - -#endif diff --git a/headers/objscip/objconshdlr.h b/headers/objscip/objconshdlr.h deleted file mode 100644 index da78b81..0000000 --- a/headers/objscip/objconshdlr.h +++ /dev/null @@ -1,529 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* */ -/* This file is part of the program and library */ -/* SCIP --- Solving Constraint Integer Programs */ -/* */ -/* Copyright 2002-2022 Zuse Institute Berlin */ -/* */ -/* Licensed under the Apache License, Version 2.0 (the "License"); */ -/* you may not use this file except in compliance with the License. */ -/* You may obtain a copy of the License at */ -/* */ -/* http://www.apache.org/licenses/LICENSE-2.0 */ -/* */ -/* Unless required by applicable law or agreed to in writing, software */ -/* distributed under the License is distributed on an "AS IS" BASIS, */ -/* 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. */ -/* */ -/* You should have received a copy of the Apache-2.0 license */ -/* along with SCIP; see the file LICENSE. If not visit scipopt.org. */ -/* */ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -/**@file objconshdlr.h - * @brief C++ wrapper for constraint handlers - * @author Tobias Achterberg - */ - -/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/ - -#ifndef __SCIP_OBJCONSHDLR_H__ -#define __SCIP_OBJCONSHDLR_H__ - - -#include -#include -#include - -#include "scip/scip.h" -#include "objscip/objprobcloneable.h" - -namespace scip -{ - -/** - * @brief C++ wrapper for constraint handlers - * - * This class defines the interface for constraint handlers implemented in C++. Note that there are pure virtual - * functions (these have to be implemented). These functions are: scip_trans(), scip_enfolp(), scip_enforelax(), - * scip_enfops(), scip_check(), and scip_lock(). - * - * - \ref CONS "Instructions for implementing a constraint handler" - * - \ref CONSHDLRS "List of available constraint handlers" - * - \ref type_cons.h "Corresponding C interface" - */ -class ObjConshdlr : public ObjProbCloneable -{ -public: - /*lint --e{1540}*/ - - /** SCIP data structure */ - SCIP* scip_; - - /** name of the constraint handler */ - char* scip_name_; - - /** description of the constraint handler */ - char* scip_desc_; - - /** default separation priority of the constraint handler */ - const int scip_sepapriority_; - - /** default enforcing priority of the constraint handler */ - const int scip_enfopriority_; - - /** default checking priority of the constraint handler */ - const int scip_checkpriority_; - - /** default separation frequency of the constraint handler */ - const int scip_sepafreq_; - - /** default propagation frequency of the constraint handler */ - const int scip_propfreq_; - - /** default frequency of the constraint handler for eager evaluations in separation, propagation and enforcement */ - const int scip_eagerfreq_; - - /** maximal number of presolving rounds the constraint handler participates in (-1: no limit) */ - const int scip_maxprerounds_; - - /** should separation method be delayed, if other separators found cuts? */ - const SCIP_Bool scip_delaysepa_; - - /** should propagation method be delayed, if other propagators found reductions? */ - const SCIP_Bool scip_delayprop_; - - /** should the constraint handler be skipped, if no constraints are available? */ - const SCIP_Bool scip_needscons_; - - /** positions in the node solving loop where propagation method of constraint handler should be executed */ - const SCIP_PROPTIMING scip_proptiming_; - - /**< timing mask of the constraint handler's presolving method */ - const SCIP_PRESOLTIMING scip_presoltiming_; - - /** default constructor */ - ObjConshdlr( - SCIP* scip, /**< SCIP data structure */ - const char* name, /**< name of constraint handler */ - const char* desc, /**< description of constraint handler */ - int sepapriority, /**< priority of the constraint handler for separation */ - int enfopriority, /**< priority of the constraint handler for constraint enforcing */ - int checkpriority, /**< priority of the constraint handler for checking infeasibility (and propagation) */ - int sepafreq, /**< frequency for separating cuts; zero means to separate only in the root node */ - int propfreq, /**< frequency for propagating domains; zero means only preprocessing propagation */ - int eagerfreq, /**< frequency for using all instead of only the useful constraints in separation, - * propagation and enforcement, -1 for no eager evaluations, 0 for first only */ - int maxprerounds, /**< maximal number of presolving rounds the constraint handler participates in (-1: no limit) */ - SCIP_Bool delaysepa, /**< should separation method be delayed, if other separators found cuts? */ - SCIP_Bool delayprop, /**< should propagation method be delayed, if other propagators found reductions? */ - SCIP_Bool needscons, /**< should the constraint handler be skipped, if no constraints are available? */ - SCIP_PROPTIMING proptiming, /**< positions in the node solving loop where propagation method of constraint handlers should be executed */ - SCIP_PRESOLTIMING presoltiming /**< timing mask of the constraint handler's presolving method */ - ) - : scip_(scip), - scip_name_(0), - scip_desc_(0), - scip_sepapriority_(sepapriority), - scip_enfopriority_(enfopriority), - scip_checkpriority_(checkpriority), - scip_sepafreq_(sepafreq), - scip_propfreq_(propfreq), - scip_eagerfreq_(eagerfreq), - scip_maxprerounds_(maxprerounds), - scip_delaysepa_(delaysepa), - scip_delayprop_(delayprop), - scip_needscons_(needscons), - scip_proptiming_(proptiming), - scip_presoltiming_(presoltiming) - { - /* the macro SCIPduplicateMemoryArray does not need the first argument: */ - SCIP_CALL_ABORT( SCIPduplicateMemoryArray(scip_, &scip_name_, name, std::strlen(name)+1) ); - SCIP_CALL_ABORT( SCIPduplicateMemoryArray(scip_, &scip_desc_, desc, std::strlen(desc)+1) ); - } - - /** copy constructor */ - ObjConshdlr(const ObjConshdlr& o) - : ObjConshdlr(o.scip_, o.scip_name_, o.scip_desc_, o.scip_sepapriority_, o.scip_enfopriority_, - o.scip_checkpriority_, o.scip_sepafreq_, o.scip_propfreq_, o.scip_eagerfreq_, o.scip_maxprerounds_, - o.scip_delaysepa_, o.scip_delayprop_, o.scip_needscons_, o.scip_proptiming_, o.scip_presoltiming_) - { - } - - /** move constructor */ - ObjConshdlr(ObjConshdlr&& o) - : scip_(o.scip_), - scip_name_(0), - scip_desc_(0), - scip_sepapriority_(o.scip_sepapriority_), - scip_enfopriority_(o.scip_enfopriority_), - scip_checkpriority_(o.scip_checkpriority_), - scip_sepafreq_(o.scip_sepafreq_), - scip_propfreq_(o.scip_propfreq_), - scip_eagerfreq_(o.scip_eagerfreq_), - scip_maxprerounds_(o.scip_maxprerounds_), - scip_delaysepa_(o.scip_delaysepa_), - scip_delayprop_(o.scip_delayprop_), - scip_needscons_(o.scip_needscons_), - scip_proptiming_(o.scip_proptiming_), - scip_presoltiming_(o.scip_presoltiming_) - { - std::swap(scip_name_, o.scip_name_); - std::swap(scip_desc_, o.scip_desc_); - } - - /** destructor */ - virtual ~ObjConshdlr() - { - /* the macro SCIPfreeMemoryArray does not need the first argument: */ - /*lint --e{64}*/ - SCIPfreeMemoryArray(scip_, &scip_name_); - SCIPfreeMemoryArray(scip_, &scip_desc_); - } - - /** assignment of polymorphic classes causes slicing and is therefore disabled. */ - ObjConshdlr& operator=(const ObjConshdlr& o) = delete; - - /** assignment of polymorphic classes causes slicing and is therefore disabled. */ - ObjConshdlr& operator=(ObjConshdlr&& o) = delete; - - /** destructor of constraint handler to free user data (called when SCIP is exiting) - * - * @see SCIP_DECL_CONSFREE(x) in @ref type_cons.h - */ - virtual SCIP_DECL_CONSFREE(scip_free) - { /*lint --e{715}*/ - return SCIP_OKAY; - } - - /** initialization method of constraint handler (called after problem has been transformed) - * - * @see SCIP_DECL_CONSINIT(x) in @ref type_cons.h - */ - virtual SCIP_DECL_CONSINIT(scip_init) - { /*lint --e{715}*/ - return SCIP_OKAY; - } - - /** deinitialization method of constraint handler (called before transformed problem is freed) - * - * @see SCIP_DECL_CONSEXIT(x) in @ref type_cons.h - */ - virtual SCIP_DECL_CONSEXIT(scip_exit) - { /*lint --e{715}*/ - return SCIP_OKAY; - } - - /** presolving initialization method of constraint handler (called when presolving is about to begin) - * - * @see SCIP_DECL_CONSINITPRE(x) in @ref type_cons.h - */ - virtual SCIP_DECL_CONSINITPRE(scip_initpre) - { /*lint --e{715}*/ - return SCIP_OKAY; - } - - /** presolving deinitialization method of constraint handler (called after presolving has been finished) - * - * @see SCIP_DECL_CONSEXITPRE(x) in @ref type_cons.h - */ - virtual SCIP_DECL_CONSEXITPRE(scip_exitpre) - { /*lint --e{715}*/ - return SCIP_OKAY; - } - - /** solving process initialization method of constraint handler (called when branch and bound process is about to begin) - * - * @see SCIP_DECL_CONSINITSOL(x) in @ref type_cons.h - */ - virtual SCIP_DECL_CONSINITSOL(scip_initsol) - { /*lint --e{715}*/ - return SCIP_OKAY; - } - - /** solving process deinitialization method of constraint handler (called before branch and bound process data is freed) - * - * @see SCIP_DECL_CONSEXITSOL(x) in @ref type_cons.h - */ - virtual SCIP_DECL_CONSEXITSOL(scip_exitsol) - { /*lint --e{715}*/ - return SCIP_OKAY; - } - - /** frees specific constraint data - * - * @see SCIP_DECL_CONSDELETE(x) in @ref type_cons.h - */ - virtual SCIP_DECL_CONSDELETE(scip_delete) - { /*lint --e{715}*/ - return SCIP_OKAY; - } - - /** transforms constraint data into data belonging to the transformed problem - * - * @see SCIP_DECL_CONSTRANS(x) in @ref type_cons.h - */ - virtual SCIP_DECL_CONSTRANS(scip_trans) = 0; - - /** LP initialization method of constraint handler (called before the initial LP relaxation at a node is solved) - * - * @see SCIP_DECL_CONSINITLP(x) in @ref type_cons.h - */ - virtual SCIP_DECL_CONSINITLP(scip_initlp) - { /*lint --e{715}*/ - return SCIP_OKAY; - } - - /** separation method of constraint handler for LP solution - * - * @see SCIP_DECL_CONSSEPALP(x) in @ref type_cons.h - */ - virtual SCIP_DECL_CONSSEPALP(scip_sepalp) - { /*lint --e{715}*/ - assert(result != NULL); - *result = SCIP_DIDNOTRUN; - return SCIP_OKAY; - } - - /** separation method of constraint handler for arbitrary primal solution - * - * @see SCIP_DECL_CONSSEPASOL(x) in @ref type_cons.h - */ - virtual SCIP_DECL_CONSSEPASOL(scip_sepasol) - { /*lint --e{715}*/ - assert(result != NULL); - *result = SCIP_DIDNOTRUN; - return SCIP_OKAY; - } - - /** constraint enforcing method of constraint handler for LP solutions - * - * @see SCIP_DECL_CONSENFOLP(x) in @ref type_cons.h - */ - virtual SCIP_DECL_CONSENFOLP(scip_enfolp) = 0; - - /** constraint enforcing method of constraint handler for relaxation solutions - * - * @see SCIP_DECL_CONSENFORELAX(x) in @ref type_cons.h - */ - virtual SCIP_DECL_CONSENFORELAX(scip_enforelax) - { /*lint --e{715}*/ - assert(result != NULL); - *result = SCIP_DIDNOTRUN; - return SCIP_OKAY; - } - - /** constraint enforcing method of constraint handler for pseudo solutions - * - * @see SCIP_DECL_CONSENFOPS(x) in @ref type_cons.h - */ - virtual SCIP_DECL_CONSENFOPS(scip_enfops) = 0; - - /** feasibility check method of constraint handler for primal solutions - * - * @see SCIP_DECL_CONSCHECK(x) in @ref type_cons.h - */ - virtual SCIP_DECL_CONSCHECK(scip_check) = 0; - - /** domain propagation method of constraint handler - * - * @see SCIP_DECL_CONSPROP(x) in @ref type_cons.h - */ - virtual SCIP_DECL_CONSPROP(scip_prop) - { /*lint --e{715}*/ - assert(result != NULL); - *result = SCIP_DIDNOTRUN; - return SCIP_OKAY; - } - - /** presolving method of constraint handler - * - * @see SCIP_DECL_CONSPRESOL(x) in @ref type_cons.h - */ - virtual SCIP_DECL_CONSPRESOL(scip_presol) - { /*lint --e{715}*/ - assert(result != NULL); - *result = SCIP_DIDNOTRUN; - return SCIP_OKAY; - } - - /** propagation conflict resolving method of constraint handler - * - * @see SCIP_DECL_CONSRESPROP(x) in @ref type_cons.h - */ - virtual SCIP_DECL_CONSRESPROP(scip_resprop) - { /*lint --e{715}*/ - assert(result != NULL); - *result = SCIP_DIDNOTFIND; - return SCIP_OKAY; - } - - /** variable rounding lock method of constraint handler - * - * @see SCIP_DECL_CONSLOCK(x) in @ref type_cons.h - */ - virtual SCIP_DECL_CONSLOCK(scip_lock) = 0; - - /** constraint activation notification method of constraint handler - * - * @see SCIP_DECL_CONSACTIVE(x) in @ref type_cons.h - */ - virtual SCIP_DECL_CONSACTIVE(scip_active) - { /*lint --e{715}*/ - return SCIP_OKAY; - } - - /** constraint deactivation notification method of constraint handler - * - * @see SCIP_DECL_CONSDEACTIVE(x) in @ref type_cons.h - */ - virtual SCIP_DECL_CONSDEACTIVE(scip_deactive) - { /*lint --e{715}*/ - return SCIP_OKAY; - } - - /** constraint enabling notification method of constraint handler - * - * @see SCIP_DECL_CONSENABLE(x) in @ref type_cons.h - */ - virtual SCIP_DECL_CONSENABLE(scip_enable) - { /*lint --e{715}*/ - return SCIP_OKAY; - } - - /** constraint disabling notification method of constraint handler - * - * @see SCIP_DECL_CONSDISABLE(x) in @ref type_cons.h - */ - virtual SCIP_DECL_CONSDISABLE(scip_disable) - { /*lint --e{715}*/ - return SCIP_OKAY; - } - - /** variable deletion method of constraint handler - * - * @see SCIP_DECL_CONSDELVARS(x) in @ref type_cons.h - */ - virtual SCIP_DECL_CONSDELVARS(scip_delvars) - { /*lint --e{715}*/ - return SCIP_OKAY; - } - - /** constraint display method of constraint handler - * - * @see SCIP_DECL_CONSPRINT(x) in @ref type_cons.h - */ - virtual SCIP_DECL_CONSPRINT(scip_print) - { /*lint --e{715}*/ - if ( file == NULL ) - fprintf(stdout, "constraint handler <%s> does not support printing constraints\n", SCIPconshdlrGetName(conshdlr)); - else - fprintf(file, "constraint handler <%s> does not support printing constraints\n", SCIPconshdlrGetName(conshdlr)); - return SCIP_OKAY; - } - - /** constraint copying method of constraint handler - * - * @see SCIP_DECL_CONSCOPY(x) in @ref type_cons.h - */ - virtual SCIP_DECL_CONSCOPY(scip_copy) - { /*lint --e{715}*/ - *valid = FALSE; - return SCIP_OKAY; - } - - /** constraint parsing method of constraint handler - * - * @see SCIP_DECL_CONSPARSE(x) in @ref type_cons.h - */ - virtual SCIP_DECL_CONSPARSE(scip_parse) - { /*lint --e{715}*/ - return SCIP_OKAY; - } - - /** constraint method of constraint handler which returns the variables (if possible) - * - * @see SCIP_DECL_CONSGETVARS(x) in @ref type_cons.h - */ - virtual SCIP_DECL_CONSGETVARS(scip_getvars) - { /*lint --e{715}*/ - - (*success) = FALSE; - - return SCIP_OKAY; - } - - /** constraint method of constraint handler which returns the number of variables (if possible) - * - * @see SCIP_DECL_CONSGETNVARS(x) in @ref type_cons.h - */ - virtual SCIP_DECL_CONSGETNVARS(scip_getnvars) - { /*lint --e{715}*/ - - (*nvars) = 0; - (*success) = FALSE; - - return SCIP_OKAY; - } - - /** constraint handler method to suggest dive bound changes during the generic diving algorithm - * - * @see SCIP_DECL_CONSGETDIVEBDCHGS(x) in @ref type_cons.h - */ - virtual SCIP_DECL_CONSGETDIVEBDCHGS(scip_getdivebdchgs) - { /*lint --e{715}*/ - - (*success) = FALSE; - - return SCIP_OKAY; - } -}; - -} /* namespace scip */ - - - -/** creates the constraint handler for the given constraint handler object and includes it in SCIP - * - * The method should be called in one of the following ways: - * - * 1. The user is resposible of deleting the object: - * SCIP_CALL( SCIPcreate(&scip) ); - * ... - * MyConshdlr* myconshdlr = new MyConshdlr(...); - * SCIP_CALL( SCIPincludeObjConshdlr(scip, &myconshdlr, FALSE) ); - * ... - * SCIP_CALL( SCIPfree(&scip) ); - * delete myconshdlr; // delete conshdlr AFTER SCIPfree() ! - * - * 2. The object pointer is passed to SCIP and deleted by SCIP in the SCIPfree() call: - * SCIP_CALL( SCIPcreate(&scip) ); - * ... - * SCIP_CALL( SCIPincludeObjConshdlr(scip, new MyConshdlr(...), TRUE) ); - * ... - * SCIP_CALL( SCIPfree(&scip) ); // destructor of MyConshdlr is called here - */ -SCIP_EXPORT -SCIP_RETCODE SCIPincludeObjConshdlr( - SCIP* scip, /**< SCIP data structure */ - scip::ObjConshdlr* objconshdlr, /**< constraint handler object */ - SCIP_Bool deleteobject /**< should the constraint handler object be deleted when conshdlr is freed? */ - ); - -/** returns the conshdlr object of the given name, or 0 if not existing */ -SCIP_EXPORT -scip::ObjConshdlr* SCIPfindObjConshdlr( - SCIP* scip, /**< SCIP data structure */ - const char* name /**< name of constraint handler */ - ); - -/** returns the conshdlr object for the given constraint handler */ -SCIP_EXPORT -scip::ObjConshdlr* SCIPgetObjConshdlr( - SCIP* scip, /**< SCIP data structure */ - SCIP_CONSHDLR* conshdlr /**< constraint handler */ - ); - -#endif diff --git a/headers/objscip/objcutsel.h b/headers/objscip/objcutsel.h deleted file mode 100644 index 9836dc4..0000000 --- a/headers/objscip/objcutsel.h +++ /dev/null @@ -1,207 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* */ -/* This file is part of the program and library */ -/* SCIP --- Solving Constraint Integer Programs */ -/* */ -/* Copyright 2002-2022 Zuse Institute Berlin */ -/* */ -/* Licensed under the Apache License, Version 2.0 (the "License"); */ -/* you may not use this file except in compliance with the License. */ -/* You may obtain a copy of the License at */ -/* */ -/* http://www.apache.org/licenses/LICENSE-2.0 */ -/* */ -/* Unless required by applicable law or agreed to in writing, software */ -/* distributed under the License is distributed on an "AS IS" BASIS, */ -/* 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. */ -/* */ -/* You should have received a copy of the Apache-2.0 license */ -/* along with SCIP; see the file LICENSE. If not visit scipopt.org. */ -/* */ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -/**@file objcutsel.h - * @brief C++ wrapper for cut selectors - * @author Felipe Serrano - * @author Mark Turner - */ - -/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/ - -#ifndef __SCIP_OBJCUTSEL_H__ -#define __SCIP_OBJCUTSEL_H__ - -#include -#include - -#include "scip/scip.h" -#include "objscip/objcloneable.h" - -namespace scip -{ - -/** @brief C++ wrapper for cut selectors - * - * This class defines the interface for cut selectors implemented in C++. - * - * - \ref CUTSEL "Instructions for implementing a cut selector" - * - \ref CUTSELECTORS "List of available cut selectors" - * - \ref type_cutsel.h "Corresponding C interface" - */ -class ObjCutsel : public ObjCloneable -{ -public: - /*lint --e{1540}*/ - - /** SCIP data structure */ - SCIP* scip_; - - /** name of the cut selector */ - char* scip_name_; - - /** description of the cut selector */ - char* scip_desc_; - - /** priority of the cut selector */ - const int scip_priority_; - - /** default constructor */ - ObjCutsel( - SCIP* scip, /**< SCIP data structure */ - const char* name, /**< name of cut selector */ - const char* desc, /**< description of cut selector */ - int priority /**< priority of the cut */ - ) - : scip_(scip), - scip_name_(0), - scip_desc_(0), - scip_priority_(priority) - { - SCIP_CALL_ABORT( SCIPduplicateMemoryArray(scip_, &scip_name_, name, std::strlen(name)+1) ); - SCIP_CALL_ABORT( SCIPduplicateMemoryArray(scip_, &scip_desc_, desc, std::strlen(desc)+1) ); - } - - /** copy constructor */ - ObjCutsel(const ObjCutsel& o) : ObjCutsel(o.scip_, o.scip_name_, o.scip_desc_, o.scip_priority_) {} - - /** move constructor */ - ObjCutsel(ObjCutsel&& o) : scip_(o.scip_), scip_name_(0), scip_desc_(0), scip_priority_(o.scip_priority_) - { - std::swap(scip_name_, o.scip_name_); - std::swap(scip_desc_, o.scip_desc_); - } - - /** destructor */ - virtual ~ObjCutsel() - { - /*lint --e{64}*/ - SCIPfreeMemoryArray(scip_, &scip_name_); - SCIPfreeMemoryArray(scip_, &scip_desc_); - } - - /** assignment of polymorphic classes causes slicing and is therefore disabled. */ - ObjCutsel& operator=(const ObjCutsel& o) = delete; - - /** assignment of polymorphic classes causes slicing and is therefore disabled. */ - ObjCutsel& operator=(ObjCutsel&& o) = delete; - - /** destructor of cut selector to free user data (called when SCIP is exiting) - * - * @see SCIP_DECL_CUTSELFREE(x) in @ref type_cutsel.h - */ - virtual SCIP_DECL_CUTSELFREE(scip_free) - { /*lint --e{715}*/ - return SCIP_OKAY; - } - - /** initialization method of cut selector (called after problem was transformed) - * - * @see SCIP_DECL_CUTSELINIT(x) in @ref type_cutsel.h - */ - virtual SCIP_DECL_CUTSELINIT(scip_init) - { /*lint --e{715}*/ - return SCIP_OKAY; - } - - /** deinitialization method of cut selector (called before transformed problem is freed) - * - * @see SCIP_DECL_CUTSELEXIT(x) in @ref type_cutsel.h - */ - virtual SCIP_DECL_CUTSELEXIT(scip_exit) - { /*lint --e{715}*/ - return SCIP_OKAY; - } - - /** solving process initialization method of cut selector (called when branch and bound process is about to begin) - * - * @see SCIP_DECL_CUTSELINITSOL(x) in @ref type_cutsel.h - */ - virtual SCIP_DECL_CUTSELINITSOL(scip_initsol) - { /*lint --e{715}*/ - return SCIP_OKAY; - } - - /** solving process deinitialization method of cut selector (called before branch and bound process data is freed) - * - * @see SCIP_DECL_CUTSELEXITSOL(x) in @ref type_cutsel.h - */ - virtual SCIP_DECL_CUTSELEXITSOL(scip_exitsol) - { /*lint --e{715}*/ - return SCIP_OKAY; - } - - /** cut selection method of cut selector - * - * @see SCIP_DECL_CUTSELSELECT(x) in @ref type_cutsel.h - */ - virtual SCIP_DECL_CUTSELSELECT(scip_select) = 0; -}; - -} /* namespace scip */ - - - -/** creates the cut selector for the given cut selector object and includes it in SCIP - * - * The method should be called in one of the following ways: - * - * 1. The user is responsible for deleting the object: - * SCIP_CALL( SCIPcreate(&scip) ); - * ... - * MyCutsel* mycutsel = new MyCutsel(...); - * SCIP_CALL( SCIPincludeObjCutsel(scip, &mycutsel, FALSE) ); - * ... - * SCIP_CALL( SCIPfree(&scip) ); - * delete mycutsel; // delete cutsel AFTER SCIPfree() ! - * - * 2. The object pointer is passed to SCIP and deleted by SCIP in the SCIPfree() call: - * SCIP_CALL( SCIPcreate(&scip) ); - * ... - * SCIP_CALL( SCIPincludeObjCutsel(scip, new MyCutsel(...), TRUE) ); - * ... - * SCIP_CALL( SCIPfree(&scip) ); // destructor of MyCutsel is called here - */ -SCIP_EXPORT -SCIP_RETCODE SCIPincludeObjCutsel( - SCIP* scip, /**< SCIP data structure */ - scip::ObjCutsel* objcutsel, /**< cut selector object */ - SCIP_Bool deleteobject /**< should the cut selector object be deleted when cut selector is freed? */ - ); - -/** returns the cutsel object of the given name, or 0 if not existing */ -SCIP_EXPORT -scip::ObjCutsel* SCIPfindObjCutsel( - SCIP* scip, /**< SCIP data structure */ - const char* name /**< name of cut selector */ - ); - -/** returns the cutsel object for the given cut selector */ -SCIP_EXPORT -scip::ObjCutsel* SCIPgetObjCutsel( - SCIP* scip, /**< SCIP data structure */ - SCIP_CUTSEL* cutsel /**< cut selector */ - ); - -#endif diff --git a/headers/objscip/objdialog.h b/headers/objscip/objdialog.h deleted file mode 100644 index beca1a8..0000000 --- a/headers/objscip/objdialog.h +++ /dev/null @@ -1,170 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* */ -/* This file is part of the program and library */ -/* SCIP --- Solving Constraint Integer Programs */ -/* */ -/* Copyright 2002-2022 Zuse Institute Berlin */ -/* */ -/* Licensed under the Apache License, Version 2.0 (the "License"); */ -/* you may not use this file except in compliance with the License. */ -/* You may obtain a copy of the License at */ -/* */ -/* http://www.apache.org/licenses/LICENSE-2.0 */ -/* */ -/* Unless required by applicable law or agreed to in writing, software */ -/* distributed under the License is distributed on an "AS IS" BASIS, */ -/* 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. */ -/* */ -/* You should have received a copy of the Apache-2.0 license */ -/* along with SCIP; see the file LICENSE. If not visit scipopt.org. */ -/* */ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -/**@file objdialog.h - * @brief C++ wrapper for dialogs - * @author Kati Wolter - */ - -/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/ - -#ifndef __SCIP_OBJDIALOG_H__ -#define __SCIP_OBJDIALOG_H__ - -#include -#include - -#include "scip/scip.h" -#include "objscip/objcloneable.h" - -namespace scip -{ - -/** - * @brief C++ wrapper for dialogs - * - * This class defines the interface for dialogs implemented in C++. Note that there is a pure virtual function (this - * function has to be implemented). This function is: scip_exec(). - * - * - \ref DIALOG "Instructions for implementing a dialog" - * - \ref DIALOGS "List of available dialogs" - * - \ref type_dialog.h "Corresponding C interface" - */ -class ObjDialog : public ObjCloneable -{ -public: - /*lint --e{1540}*/ - - /** SCIP data structure */ - SCIP* scip_; - - /** name of the dialog */ - char* scip_name_; - - /** description of the dialog */ - char* scip_desc_; - - /** default for whether the dialog is a menu */ - const SCIP_Bool scip_issubmenu_; - - /** default constructor */ - ObjDialog( - SCIP* scip, /**< SCIP data structure */ - const char* name, /**< name of the dialog */ - const char* desc, /**< description of the dialog */ - SCIP_Bool issubmenu /**< default for whether the dialog is a menu */ - ) - : scip_(scip), - scip_name_(0), - scip_desc_(0), - scip_issubmenu_(issubmenu) - { - /* the macro SCIPduplicateMemoryArray does not need the first argument: */ - SCIP_CALL_ABORT( SCIPduplicateMemoryArray(scip_, &scip_name_, name, std::strlen(name)+1) ); - SCIP_CALL_ABORT( SCIPduplicateMemoryArray(scip_, &scip_desc_, desc, std::strlen(desc)+1) ); - } - - /** copy constructor */ - ObjDialog(const ObjDialog& o) : ObjDialog(o.scip_, o.scip_name_, o.scip_desc_, o.scip_issubmenu_) {} - - /** move constructor */ - ObjDialog(ObjDialog&& o) : scip_(o.scip_), scip_name_(0), scip_desc_(0), scip_issubmenu_(o.scip_issubmenu_) - { - std::swap(scip_name_, o.scip_name_); - std::swap(scip_desc_, o.scip_desc_); - } - - /** destructor */ - virtual ~ObjDialog() - { - /* the macro SCIPfreeMemoryArray does not need the first argument: */ - /*lint --e{64}*/ - SCIPfreeMemoryArray(scip_, &scip_name_); - SCIPfreeMemoryArray(scip_, &scip_desc_); - } - - /** assignment of polymorphic classes causes slicing and is therefore disabled. */ - ObjDialog& operator=(const ObjDialog& o) = delete; - - /** assignment of polymorphic classes causes slicing and is therefore disabled. */ - ObjDialog& operator=(ObjDialog&& o) = delete; - - /** destructor of dialog to free user data (called when SCIP is exiting) - * - * @see SCIP_DECL_DIALOGFREE(x) in @ref type_dialog.h - */ - virtual SCIP_DECL_DIALOGFREE(scip_free) - { /*lint --e{715}*/ - return SCIP_OKAY; - } - - /** description output method of dialog - * - * @see SCIP_DECL_DIALOGDESC(x) in @ref type_dialog.h - */ - virtual SCIP_DECL_DIALOGDESC(scip_desc) - { /*lint --e{715}*/ - SCIPdialogMessage(scip, 0, "%s", scip_desc_); - return SCIP_OKAY; - } - - /** execution method of dialog - * - * @see SCIP_DECL_DIALOGEXEC(x) in @ref type_dialog.h - */ - virtual SCIP_DECL_DIALOGEXEC(scip_exec) = 0; -}; - -} /* namespace scip */ - - - -/** creates the dialog for the given dialog object and includes it in SCIP - * - * The method should be called in one of the following ways: - * - * 1. The user is resposible of deleting the object: - * SCIP_CALL( SCIPcreate(&scip) ); - * ... - * MyDialog* mydialog = new MyDialog(...); - * SCIP_CALL( SCIPincludeObjDialog(scip, &mydialog, FALSE) ); - * ... - * SCIP_CALL( SCIPfree(&scip) ); - * delete mydialog; // delete dialog AFTER SCIPfree() ! - * - * 2. The object pointer is passed to SCIP and deleted by SCIP in the SCIPfree() call: - * SCIP_CALL( SCIPcreate(&scip) ); - * ... - * SCIP_CALL( SCIPincludeObjDialog(scip, new MyDialog(...), TRUE) ); - * ... - * SCIP_CALL( SCIPfree(&scip) ); // destructor of MyDialog is called here - */ -SCIP_EXPORT -SCIP_RETCODE SCIPincludeObjDialog( - SCIP* scip, /**< SCIP data structure */ - scip::ObjDialog* objdialog, /**< dialog object */ - SCIP_Bool deleteobject /**< should the dialog object be deleted when dialog is freed? */ - ); - -#endif diff --git a/headers/objscip/objdisp.h b/headers/objscip/objdisp.h deleted file mode 100644 index 61b0206..0000000 --- a/headers/objscip/objdisp.h +++ /dev/null @@ -1,245 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* */ -/* This file is part of the program and library */ -/* SCIP --- Solving Constraint Integer Programs */ -/* */ -/* Copyright 2002-2022 Zuse Institute Berlin */ -/* */ -/* Licensed under the Apache License, Version 2.0 (the "License"); */ -/* you may not use this file except in compliance with the License. */ -/* You may obtain a copy of the License at */ -/* */ -/* http://www.apache.org/licenses/LICENSE-2.0 */ -/* */ -/* Unless required by applicable law or agreed to in writing, software */ -/* distributed under the License is distributed on an "AS IS" BASIS, */ -/* 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. */ -/* */ -/* You should have received a copy of the Apache-2.0 license */ -/* along with SCIP; see the file LICENSE. If not visit scipopt.org. */ -/* */ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -/**@file objdisp.h - * @brief C++ wrapper for display columns - * @author Kati Wolter - */ - -/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/ - -#ifndef __SCIP_OBJDISP_H__ -#define __SCIP_OBJDISP_H__ - -#include -#include - -#include "scip/scip.h" -#include "objscip/objcloneable.h" - -namespace scip -{ - -/** - * @brief C++ wrapper for display columns - * - * This class defines the interface for display columns implemented in C++. Note that there is a pure virtual function - * (this function has to be implemented). This function is: scip_output(). - * - * - \ref DISP "Instructions for implementing a display column" - * - \ref DISPLAYS "List of available display columns" - * - \ref type_disp.h "Corresponding C interface" - */ -class ObjDisp : public ObjCloneable -{ -public: - /*lint --e{1540}*/ - - /** SCIP data structure */ - SCIP* scip_; - - /** name of the display column */ - char* scip_name_; - - /** description of the display column */ - char* scip_desc_; - - /** head line of the display column */ - char* scip_header_; - - /** width of the display column (no. of chars used) */ - const int scip_width_; - - /** priority of the display column */ - const int scip_priority_; - - /** relative position of the display column */ - const int scip_position_; - - /** should the column be separated with a line from its right neighbour? */ - const SCIP_Bool scip_stripline_; - - /** default constructor */ - ObjDisp( - SCIP* scip, /**< SCIP data structure */ - const char* name, /**< name of display column */ - const char* desc, /**< description of display column */ - const char* header, /**< head line of display column */ - int width, /**< width of display column (no. of chars used) */ - int priority, /**< priority of display column */ - int position, /**< relative position of display column */ - SCIP_Bool stripline /**< should the column be separated with a line from its right neighbour? */ - ) - : scip_(scip), - scip_name_(0), - scip_desc_(0), - scip_header_(0), - scip_width_(width), - scip_priority_(priority), - scip_position_(position), - scip_stripline_(stripline) - { - /* the macro SCIPduplicateMemoryArray does not need the first argument: */ - SCIP_CALL_ABORT( SCIPduplicateMemoryArray(scip_, &scip_name_, name, std::strlen(name)+1) ); - SCIP_CALL_ABORT( SCIPduplicateMemoryArray(scip_, &scip_desc_, desc, std::strlen(desc)+1) ); - SCIP_CALL_ABORT( SCIPduplicateMemoryArray(scip_, &scip_header_, header, std::strlen(header)+1) ); - } - - /** copy constructor */ - ObjDisp(const ObjDisp& o) - : ObjDisp(o.scip_, o.scip_name_, o.scip_desc_, o.scip_header_, o.scip_width_, o.scip_priority_, o.scip_position_, - o.scip_stripline_) - { - } - - /** move constructor */ - ObjDisp(ObjDisp&& o) - : scip_(o.scip_), - scip_name_(0), - scip_desc_(0), - scip_header_(0), - scip_width_(o.scip_width_), - scip_priority_(o.scip_priority_), - scip_position_(o.scip_position_), - scip_stripline_(o.scip_stripline_) - { - std::swap(scip_name_, o.scip_name_); - std::swap(scip_desc_, o.scip_desc_); - std::swap(scip_header_, o.scip_header_); - } - - /** destructor */ - virtual ~ObjDisp() - { - /* the macro SCIPfreeMemoryArray does not need the first argument: */ - /*lint --e{64}*/ - SCIPfreeMemoryArray(scip_, &scip_name_); - SCIPfreeMemoryArray(scip_, &scip_desc_); - SCIPfreeMemoryArray(scip_, &scip_header_); - } - - /** assignment of polymorphic classes causes slicing and is therefore disabled. */ - ObjDisp& operator=(const ObjDisp& o) = delete; - - /** assignment of polymorphic classes causes slicing and is therefore disabled. */ - ObjDisp& operator=(ObjDisp&& o) = delete; - - /** destructor of display column to free user data (called when SCIP is exiting) - * - * @see SCIP_DECL_DISPFREE(x) in @ref type_disp.h - */ - virtual SCIP_DECL_DISPFREE(scip_free) - { /*lint --e{715}*/ - return SCIP_OKAY; - } - - /** initialization method of display column (called after problem was transformed) - * - * @see SCIP_DECL_DISPINIT(x) in @ref type_disp.h - */ - virtual SCIP_DECL_DISPINIT(scip_init) - { /*lint --e{715}*/ - return SCIP_OKAY; - } - - /** deinitialization method of display column (called before transformed problem is freed) - * - * @see SCIP_DECL_DISPEXIT(x) in @ref type_disp.h - */ - virtual SCIP_DECL_DISPEXIT(scip_exit) - { /*lint --e{715}*/ - return SCIP_OKAY; - } - - /** solving process initialization method of display column (called when branch and bound process is about to begin) - * - * @see SCIP_DECL_DISPINITSOL(x) in @ref type_disp.h - */ - virtual SCIP_DECL_DISPINITSOL(scip_initsol) - { /*lint --e{715}*/ - return SCIP_OKAY; - } - - /** solving process deinitialization method of display column (called before branch and bound process data is freed) - * - * @see SCIP_DECL_DISPEXITSOL(x) in @ref type_disp.h - */ - virtual SCIP_DECL_DISPEXITSOL(scip_exitsol) - { /*lint --e{715}*/ - return SCIP_OKAY; - } - - /** output method of display column to output file stream 'file' - * - * @see SCIP_DECL_DISPOUTPUT(x) in @ref type_disp.h - */ - virtual SCIP_DECL_DISPOUTPUT(scip_output) = 0; -}; - -} /* namespace scip */ - - - -/** creates the display column for the given display column object and includes it in SCIP - * - * The method should be called in one of the following ways: - * - * 1. The user is resposible of deleting the object: - * SCIP_CALL( SCIPcreate(&scip) ); - * ... - * MyDisp* mydisp = new MyDisp(...); - * SCIP_CALL( SCIPincludeObjDisp(scip, &mydisp, FALSE) ); - * ... - * SCIP_CALL( SCIPfree(&scip) ); - * delete mydisp; // delete disp AFTER SCIPfree() ! - * - * 2. The object pointer is passed to SCIP and deleted by SCIP in the SCIPfree() call: - * SCIP_CALL( SCIPcreate(&scip) ); - * ... - * SCIP_CALL( SCIPincludeObjDisp(scip, new MyDisp(...), TRUE) ); - * ... - * SCIP_CALL( SCIPfree(&scip) ); // destructor of MyDisp is called here - */ -SCIP_EXPORT -SCIP_RETCODE SCIPincludeObjDisp( - SCIP* scip, /**< SCIP data structure */ - scip::ObjDisp* objdisp, /**< display column object */ - SCIP_Bool deleteobject /**< should the display column object be deleted when display column is freed? */ - ); - -/** returns the display column object of the given name, or 0 if not existing */ -SCIP_EXPORT -scip::ObjDisp* SCIPfindObjDisp( - SCIP* scip, /**< SCIP data structure */ - const char* name /**< name of display column */ - ); - -/** returns the display column object for the given display column */ -SCIP_EXPORT -scip::ObjDisp* SCIPgetObjDisp( - SCIP* scip, /**< SCIP data structure */ - SCIP_DISP* disp /**< display column */ - ); - -#endif diff --git a/headers/objscip/objeventhdlr.h b/headers/objscip/objeventhdlr.h deleted file mode 100644 index 3b9eb39..0000000 --- a/headers/objscip/objeventhdlr.h +++ /dev/null @@ -1,212 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* */ -/* This file is part of the program and library */ -/* SCIP --- Solving Constraint Integer Programs */ -/* */ -/* Copyright 2002-2022 Zuse Institute Berlin */ -/* */ -/* Licensed under the Apache License, Version 2.0 (the "License"); */ -/* you may not use this file except in compliance with the License. */ -/* You may obtain a copy of the License at */ -/* */ -/* http://www.apache.org/licenses/LICENSE-2.0 */ -/* */ -/* Unless required by applicable law or agreed to in writing, software */ -/* distributed under the License is distributed on an "AS IS" BASIS, */ -/* 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. */ -/* */ -/* You should have received a copy of the Apache-2.0 license */ -/* along with SCIP; see the file LICENSE. If not visit scipopt.org. */ -/* */ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -/**@file objeventhdlr.h - * @brief C++ wrapper for event handlers - * @author Tobias Achterberg - */ - -/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/ - -#ifndef __SCIP_OBJEVENTHDLR_H__ -#define __SCIP_OBJEVENTHDLR_H__ - -#include -#include - -#include "scip/scip.h" -#include "objscip/objcloneable.h" - -namespace scip -{ - -/** @brief C++ wrapper for event handlers - * - * This class defines the interface for eventt handlers implemented in C++. Note that there is a pure virtual function - * (this function has to be implemented). This function is: scip_exec(). - * - * - \ref EVENT "Instructions for implementing an event handler" - * - \ref type_event.h "Corresponding C interface" - */ -class ObjEventhdlr : public ObjCloneable -{ -public: - /*lint --e{1540}*/ - - /** SCIP data structure */ - SCIP* scip_; - - /** name of the event handler */ - char* scip_name_; - - /** description of the event handler */ - char* scip_desc_; - - /** default constructor */ - ObjEventhdlr( - SCIP* scip, /**< SCIP data structure */ - const char* name, /**< name of event handler */ - const char* desc /**< description of event handler */ - ) - : scip_(scip), - scip_name_(0), - scip_desc_(0) - { - /* the macro SCIPduplicateMemoryArray does not need the first argument: */ - SCIP_CALL_ABORT( SCIPduplicateMemoryArray(scip_, &scip_name_, name, std::strlen(name)+1) ); - SCIP_CALL_ABORT( SCIPduplicateMemoryArray(scip_, &scip_desc_, desc, std::strlen(desc)+1) ); - } - - /** copy constructor */ - ObjEventhdlr(const ObjEventhdlr& o) : ObjEventhdlr(o.scip_, o.scip_name_, o.scip_desc_) {} - - /** move constructor */ - ObjEventhdlr(ObjEventhdlr&& o) : scip_(o.scip_), scip_name_(0), scip_desc_(0) - { - std::swap(scip_name_, o.scip_name_); - std::swap(scip_desc_, o.scip_desc_); - } - - /** destructor */ - virtual ~ObjEventhdlr() - { - /* the macro SCIPfreeMemoryArray does not need the first argument: */ - /*lint --e{64}*/ - SCIPfreeMemoryArray(scip_, &scip_name_); - SCIPfreeMemoryArray(scip_, &scip_desc_); - } - - /** assignment of polymorphic classes causes slicing and is therefore disabled. */ - ObjEventhdlr& operator=(const ObjEventhdlr& o) = delete; - - /** assignment of polymorphic classes causes slicing and is therefore disabled. */ - ObjEventhdlr& operator=(ObjEventhdlr&& o) = delete; - - /** destructor of event handler to free user data (called when SCIP is exiting) - * - * @see SCIP_DECL_EVENTFREE(x) in @ref type_event.h - */ - virtual SCIP_DECL_EVENTFREE(scip_free) - { /*lint --e{715}*/ - return SCIP_OKAY; - } - - /** initialization method of event handler (called after problem was transformed) - * - * @see SCIP_DECL_EVENTINIT(x) in @ref type_event.h - */ - virtual SCIP_DECL_EVENTINIT(scip_init) - { /*lint --e{715}*/ - return SCIP_OKAY; - } - - /** deinitialization method of event handler (called before transformed problem is freed) - * - * @see SCIP_DECL_EVENTEXIT(x) in @ref type_event.h - */ - virtual SCIP_DECL_EVENTEXIT(scip_exit) - { /*lint --e{715}*/ - return SCIP_OKAY; - } - - /** solving process initialization method of event handler (called when branch and bound process is about to begin) - * - * @see SCIP_DECL_EVENTINITSOL(x) in @ref type_event.h - */ - virtual SCIP_DECL_EVENTINITSOL(scip_initsol) - { /*lint --e{715}*/ - return SCIP_OKAY; - } - - /** solving process deinitialization method of event handler (called before branch and bound process data is freed) - * - * @see SCIP_DECL_EVENTEXITSOL(x) in @ref type_event.h - */ - virtual SCIP_DECL_EVENTEXITSOL(scip_exitsol) - { /*lint --e{715}*/ - return SCIP_OKAY; - } - - /** frees specific constraint data - * - * @see SCIP_DECL_EVENTDELETE(x) in @ref type_event.h - */ - virtual SCIP_DECL_EVENTDELETE(scip_delete) - { /*lint --e{715}*/ - return SCIP_OKAY; - } - - /** execution method of event handler - * - * @see SCIP_DECL_EVENTEXEC(x) in @ref type_event.h - */ - virtual SCIP_DECL_EVENTEXEC(scip_exec) = 0; -}; - -} /* namespace scip */ - - - -/** creates the event handler for the given event handler object and includes it in SCIP - * - * The method should be called in one of the following ways: - * - * 1. The user is resposible of deleting the object: - * SCIP_CALL( SCIPcreate(&scip) ); - * ... - * MyEventhdlr* myeventhdlr = new MyEventhdlr(...); - * SCIP_CALL( SCIPincludeObjEventhdlr(scip, &myeventhdlr, FALSE) ); - * ... - * SCIP_CALL( SCIPfree(&scip) ); - * delete myeventhdlr; // delete eventhdlr AFTER SCIPfree() ! - * - * 2. The object pointer is passed to SCIP and deleted by SCIP in the SCIPfree() call: - * SCIP_CALL( SCIPcreate(&scip) ); - * ... - * SCIP_CALL( SCIPincludeObjEventhdlr(scip, new MyEventhdlr(...), TRUE) ); - * ... - * SCIP_CALL( SCIPfree(&scip) ); // destructor of MyEventhdlr is called here - */ -SCIP_EXPORT -SCIP_RETCODE SCIPincludeObjEventhdlr( - SCIP* scip, /**< SCIP data structure */ - scip::ObjEventhdlr* objeventhdlr, /**< event handler object */ - SCIP_Bool deleteobject /**< should the event handler object be deleted when eventhdlristic is freed? */ - ); - -/** returns the eventhdlr object of the given name, or 0 if not existing */ -SCIP_EXPORT -scip::ObjEventhdlr* SCIPfindObjEventhdlr( - SCIP* scip, /**< SCIP data structure */ - const char* name /**< name of event handler */ - ); - -/** returns the eventhdlr object for the given event handler */ -SCIP_EXPORT -scip::ObjEventhdlr* SCIPgetObjEventhdlr( - SCIP* scip, /**< SCIP data structure */ - SCIP_EVENTHDLR* eventhdlr /**< event handler */ - ); - -#endif diff --git a/headers/objscip/objheur.h b/headers/objscip/objheur.h deleted file mode 100644 index 2f8aef0..0000000 --- a/headers/objscip/objheur.h +++ /dev/null @@ -1,254 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* */ -/* This file is part of the program and library */ -/* SCIP --- Solving Constraint Integer Programs */ -/* */ -/* Copyright 2002-2022 Zuse Institute Berlin */ -/* */ -/* Licensed under the Apache License, Version 2.0 (the "License"); */ -/* you may not use this file except in compliance with the License. */ -/* You may obtain a copy of the License at */ -/* */ -/* http://www.apache.org/licenses/LICENSE-2.0 */ -/* */ -/* Unless required by applicable law or agreed to in writing, software */ -/* distributed under the License is distributed on an "AS IS" BASIS, */ -/* 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. */ -/* */ -/* You should have received a copy of the Apache-2.0 license */ -/* along with SCIP; see the file LICENSE. If not visit scipopt.org. */ -/* */ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -/**@file objheur.h - * @brief C++ wrapper for primal heuristics - * @author Tobias Achterberg - */ - -/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/ - -#ifndef __SCIP_OBJHEUR_H__ -#define __SCIP_OBJHEUR_H__ - -#include -#include - -#include "scip/scip.h" -#include "objscip/objcloneable.h" - -namespace scip -{ - -/** @brief C++ wrapper for primal heuristics - * - * This class defines the interface for primal heuristics implemented in C++. Note that there is a pure virtual - * function (this function has to be implemented). This function is: scip_exec(). - * - * - \ref HEUR "Instructions for implementing a primal heuristic" - * - \ref PRIMALHEURISTICS "List of available primal heuristics" - * - \ref type_heur.h "Corresponding C interface" - */ -class ObjHeur : public ObjCloneable -{ -public: - /*lint --e{1540}*/ - - /** SCIP data structure */ - SCIP* scip_; - - /** name of the primal heuristic */ - char* scip_name_; - - /** description of the primal heuristic */ - char* scip_desc_; - - /** display character of primal heuristic */ - const char scip_dispchar_; - - /** default priority of the primal heuristic */ - const int scip_priority_; - - /** frequency for calling primal heuristic */ - const int scip_freq_; - - /** frequency offset for calling primal heuristic */ - const int scip_freqofs_; - - /** maximal depth level to call heuristic at (-1: no limit) */ - const int scip_maxdepth_; - - /** positions in the node solving loop where heuristic should be executed */ - const SCIP_HEURTIMING scip_timingmask_; - - /** does the heuristic use a secondary SCIP instance? */ - const SCIP_Bool scip_usessubscip_; - - /** default constructor */ - ObjHeur( - SCIP* scip, /**< SCIP data structure */ - const char* name, /**< name of primal heuristic */ - const char* desc, /**< description of primal heuristic */ - char dispchar, /**< display character of primal heuristic */ - int priority, /**< priority of the primal heuristic */ - int freq, /**< frequency for calling primal heuristic */ - int freqofs, /**< frequency offset for calling primal heuristic */ - int maxdepth, /**< maximal depth level to call heuristic at (-1: no limit) */ - SCIP_HEURTIMING timingmask, /**< positions in the node solving loop where heuristic should be executed; - * see definition of SCIP_HEURTIMING for possible values */ - SCIP_Bool usessubscip /**< does the heuristic use a secondary SCIP instance? */ - ) - : scip_(scip), - scip_name_(0), - scip_desc_(0), - scip_dispchar_(dispchar), - scip_priority_(priority), - scip_freq_(freq), - scip_freqofs_(freqofs), - scip_maxdepth_(maxdepth), - scip_timingmask_(timingmask), - scip_usessubscip_(usessubscip) - { - /* the macro SCIPduplicateMemoryArray does not need the first argument: */ - SCIP_CALL_ABORT( SCIPduplicateMemoryArray(scip_, &scip_name_, name, std::strlen(name)+1) ); - SCIP_CALL_ABORT( SCIPduplicateMemoryArray(scip_, &scip_desc_, desc, std::strlen(desc)+1) ); - } - - /** copy constructor */ - ObjHeur(const ObjHeur& o) - : ObjHeur(o.scip_, o.scip_name_, o.scip_desc_, o.scip_dispchar_, o.scip_priority_, o.scip_freq_, o.scip_freqofs_, - o.scip_maxdepth_, o.scip_timingmask_, o.scip_usessubscip_) - { - } - - /** move constructor */ - ObjHeur(ObjHeur&& o) - : scip_(o.scip_), - scip_name_(0), - scip_desc_(0), - scip_dispchar_(o.scip_dispchar_), - scip_priority_(o.scip_priority_), - scip_freq_(o.scip_freq_), - scip_freqofs_(o.scip_freqofs_), - scip_maxdepth_(o.scip_maxdepth_), - scip_timingmask_(o.scip_timingmask_), - scip_usessubscip_(o.scip_usessubscip_) - { - std::swap(scip_name_, o.scip_name_); - std::swap(scip_desc_, o.scip_desc_); - } - - /** destructor */ - virtual ~ObjHeur() - { - /* the macro SCIPfreeMemoryArray does not need the first argument: */ - /*lint --e{64}*/ - SCIPfreeMemoryArray(scip_, &scip_name_); - SCIPfreeMemoryArray(scip_, &scip_desc_); - } - - /** assignment of polymorphic classes causes slicing and is therefore disabled. */ - ObjHeur& operator=(const ObjHeur& o) = delete; - - /** assignment of polymorphic classes causes slicing and is therefore disabled. */ - ObjHeur& operator=(ObjHeur&& o) = delete; - - /** destructor of primal heuristic to free user data (called when SCIP is exiting) - * - * @see SCIP_DECL_HEURFREE(x) in @ref type_heur.h - */ - virtual SCIP_DECL_HEURFREE(scip_free) - { /*lint --e{715}*/ - return SCIP_OKAY; - } - - /** initialization method of primal heuristic (called after problem was transformed) - * - * @see SCIP_DECL_HEURINIT(x) in @ref type_heur.h - */ - virtual SCIP_DECL_HEURINIT(scip_init) - { /*lint --e{715}*/ - return SCIP_OKAY; - } - - /** deinitialization method of primal heuristic (called before transformed problem is freed) - * - * @see SCIP_DECL_HEUREXIT(x) in @ref type_heur.h - */ - virtual SCIP_DECL_HEUREXIT(scip_exit) - { /*lint --e{715}*/ - return SCIP_OKAY; - } - - /** solving process initialization method of primal heuristic (called when branch and bound process is about to begin) - * - * @see SCIP_DECL_HEURINITSOL(x) in @ref type_heur.h - */ - virtual SCIP_DECL_HEURINITSOL(scip_initsol) - { /*lint --e{715}*/ - return SCIP_OKAY; - } - - /** solving process deinitialization method of primal heuristic (called before branch and bound process data is freed) - * - * @see SCIP_DECL_HEUREXITSOL(x) in @ref type_heur.h - */ - virtual SCIP_DECL_HEUREXITSOL(scip_exitsol) - { /*lint --e{715}*/ - return SCIP_OKAY; - } - - /** execution method of primal heuristic - * - * @see SCIP_DECL_HEUREXEC(x) in @ref type_heur.h - */ - virtual SCIP_DECL_HEUREXEC(scip_exec) = 0; -}; - -} /* namespace scip */ - - - -/** creates the primal heuristic for the given primal heuristic object and includes it in SCIP - * - * The method should be called in one of the following ways: - * - * 1. The user is resposible of deleting the object: - * SCIP_CALL( SCIPcreate(&scip) ); - * ... - * MyHeur* myheur = new MyHeur(...); - * SCIP_CALL( SCIPincludeObjHeur(scip, &myheur, FALSE) ); - * ... - * SCIP_CALL( SCIPfree(&scip) ); - * delete myheur; // delete heur AFTER SCIPfree() ! - * - * 2. The object pointer is passed to SCIP and deleted by SCIP in the SCIPfree() call: - * SCIP_CALL( SCIPcreate(&scip) ); - * ... - * SCIP_CALL( SCIPincludeObjHeur(scip, new MyHeur(...), TRUE) ); - * ... - * SCIP_CALL( SCIPfree(&scip) ); // destructor of MyHeur is called here - */ -SCIP_EXPORT -SCIP_RETCODE SCIPincludeObjHeur( - SCIP* scip, /**< SCIP data structure */ - scip::ObjHeur* objheur, /**< primal heuristic object */ - SCIP_Bool deleteobject /**< should the primal heuristic object be deleted when heuristic is freed? */ - ); - -/** returns the heur object of the given name, or 0 if not existing */ -SCIP_EXPORT -scip::ObjHeur* SCIPfindObjHeur( - SCIP* scip, /**< SCIP data structure */ - const char* name /**< name of primal heuristic */ - ); - -/** returns the heur object for the given primal heuristic */ -SCIP_EXPORT -scip::ObjHeur* SCIPgetObjHeur( - SCIP* scip, /**< SCIP data structure */ - SCIP_HEUR* heur /**< primal heuristic */ - ); - -#endif diff --git a/headers/objscip/objmessagehdlr.h b/headers/objscip/objmessagehdlr.h deleted file mode 100644 index eedbf1d..0000000 --- a/headers/objscip/objmessagehdlr.h +++ /dev/null @@ -1,149 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* */ -/* This file is part of the program and library */ -/* SCIP --- Solving Constraint Integer Programs */ -/* */ -/* Copyright 2002-2022 Zuse Institute Berlin */ -/* */ -/* Licensed under the Apache License, Version 2.0 (the "License"); */ -/* you may not use this file except in compliance with the License. */ -/* You may obtain a copy of the License at */ -/* */ -/* http://www.apache.org/licenses/LICENSE-2.0 */ -/* */ -/* Unless required by applicable law or agreed to in writing, software */ -/* distributed under the License is distributed on an "AS IS" BASIS, */ -/* 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. */ -/* */ -/* You should have received a copy of the Apache-2.0 license */ -/* along with SCIP; see the file LICENSE. If not visit scipopt.org. */ -/* */ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -/**@file objmessagehdlr.h - * @brief C++ wrapper for message handlers - * @author Tobias Achterberg - */ - -/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/ - -#ifndef __SCIP_OBJMESSAGEHDLR_H__ -#define __SCIP_OBJMESSAGEHDLR_H__ - -#include "scip/scip.h" - -namespace scip -{ - -/** - * @brief C++ wrapper for message handlers - * - * This class defines the interface for message handlers implemented in C++. Note that all functions are pure virtual - * (these functions have to be implemented). - * - * - \ref type_message.h "Corresponding C interface" - */ -class ObjMessagehdlr -{ -public: - /** should the output be buffered up to the next newline? */ - const SCIP_Bool scip_bufferedoutput_; - - /** default constructor */ - explicit ObjMessagehdlr( - SCIP_Bool bufferedoutput /**< should the output be buffered up to the next newline? */ - ) - : scip_bufferedoutput_(bufferedoutput) - { - } - - /** destructor */ - virtual ~ObjMessagehdlr() - { - } - - /** assignment of polymorphic classes causes slicing and is therefore disabled. */ - ObjMessagehdlr& operator=(const ObjMessagehdlr& o) = delete; - - /** assignment of polymorphic classes causes slicing and is therefore disabled. */ - ObjMessagehdlr& operator=(ObjMessagehdlr&& o) = delete; - - /** error message print method of message handler - * - * @note This function can be activated by calling SCIPsetStaticErrorPrintingMessagehdlr(). - * - * @see SCIP_DECL_ERRORPRINTING(x) in @ref type_message.h - */ /*lint -e715*/ - virtual void scip_error( - SCIP_MESSAGEHDLR* messagehdlr, /**< the message handler itself */ - FILE* file, /**< file stream to print into (NULL for stderr) */ - const char* msg /**< string to output into the file (or NULL to flush) */ - ) - { /*lint --e{715}*/ - - } - - /** warning message print method of message handler - * - * @see SCIP_DECL_MESSAGEWARNING(x) in @ref type_message.h - */ /*lint -e715*/ - virtual SCIP_DECL_MESSAGEWARNING(scip_warning) - { /*lint --e{715}*/ - - } - - /** dialog message print method of message handler - * - * @see SCIP_DECL_MESSAGEDIALOG(x) in @ref type_message.h - */ /*lint -e715*/ - virtual SCIP_DECL_MESSAGEDIALOG(scip_dialog) - { /*lint --e{715}*/ - - } - - /** info message print method of message handler - * - * @see SCIP_DECL_MESSAGEINFO(x) in @ref type_message.h - */ /*lint -e715*/ - virtual SCIP_DECL_MESSAGEINFO(scip_info) - { /*lint --e{715}*/ - - } - - /** destructor of message handler to free message handler data - * - * @see SCIP_DECL_MESSAGEHDLRFREE(x) in @ref type_message.h - */ /*lint -e715*/ - virtual SCIP_DECL_MESSAGEHDLRFREE(scip_free) - { /*lint --e{715}*/ - return SCIP_OKAY; - } -}; - -} /* namespace scip */ - - - -/** creates the message handler for the given message handler object */ -SCIP_EXPORT -SCIP_RETCODE SCIPcreateObjMessagehdlr( - SCIP_MESSAGEHDLR** messagehdlr, /**< pointer to store the message handler */ - scip::ObjMessagehdlr* objmessagehdlr, /**< message handler object */ - SCIP_Bool deleteobject /**< should the message handler object be deleted when message handler is freed? */ - ); - -/** returns the message handler object for the given message handler */ -SCIP_EXPORT -scip::ObjMessagehdlr* SCIPgetObjMessagehdlr( - SCIP_MESSAGEHDLR* messagehdlr /**< message handler */ - ); - -/** set static error output function to the corresponding function of message handler */ -SCIP_EXPORT -void SCIPsetStaticErrorPrintingMessagehdlr( - SCIP_MESSAGEHDLR* messagehdlr /**< message handler */ - ); - -#endif diff --git a/headers/objscip/objnodesel.h b/headers/objscip/objnodesel.h deleted file mode 100644 index 498ce82..0000000 --- a/headers/objscip/objnodesel.h +++ /dev/null @@ -1,228 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* */ -/* This file is part of the program and library */ -/* SCIP --- Solving Constraint Integer Programs */ -/* */ -/* Copyright 2002-2022 Zuse Institute Berlin */ -/* */ -/* Licensed under the Apache License, Version 2.0 (the "License"); */ -/* you may not use this file except in compliance with the License. */ -/* You may obtain a copy of the License at */ -/* */ -/* http://www.apache.org/licenses/LICENSE-2.0 */ -/* */ -/* Unless required by applicable law or agreed to in writing, software */ -/* distributed under the License is distributed on an "AS IS" BASIS, */ -/* 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. */ -/* */ -/* You should have received a copy of the Apache-2.0 license */ -/* along with SCIP; see the file LICENSE. If not visit scipopt.org. */ -/* */ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -/**@file objnodesel.h - * @brief C++ wrapper for node selectors - * @author Tobias Achterberg - */ - -/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/ - -#ifndef __SCIP_OBJNODESEL_H__ -#define __SCIP_OBJNODESEL_H__ - -#include -#include - -#include "scip/scip.h" -#include "objscip/objcloneable.h" - -namespace scip -{ - -/** @brief C++ wrapper for primal heuristics - * - * This class defines the interface for node selectors implemented in C++. Note that there is a pure virtual - * function (this function has to be implemented). This function is: scip_comp(). - * - * - \ref NODESEL "Instructions for implementing a node selector" - * - \ref NODESELECTORS "List of available node selectors" - * - \ref type_nodesel.h "Corresponding C interface" - */ -class ObjNodesel : public ObjCloneable -{ -public: - /*lint --e{1540}*/ - - /** SCIP data structure */ - SCIP* scip_; - - /** name of the node selector */ - char* scip_name_; - - /** description of the node selector */ - char* scip_desc_; - - /** priority of the node selector in standard mode */ - const int scip_stdpriority_; - - /** priority of the node selector in memory saving mode */ - const int scip_memsavepriority_; - - /** default constructor */ - ObjNodesel( - SCIP* scip, /**< SCIP data structure */ - const char* name, /**< name of node selector */ - const char* desc, /**< description of node selector */ - int stdpriority, /**< priority of the node selector in standard mode */ - int memsavepriority /**< priority of the node selector in memory saving mode */ - ) - : scip_(scip), - scip_name_(0), - scip_desc_(0), - scip_stdpriority_(stdpriority), - scip_memsavepriority_(memsavepriority) - { - /* the macro SCIPduplicateMemoryArray does not need the first argument: */ - SCIP_CALL_ABORT( SCIPduplicateMemoryArray(scip_, &scip_name_, name, std::strlen(name)+1) ); - SCIP_CALL_ABORT( SCIPduplicateMemoryArray(scip_, &scip_desc_, desc, std::strlen(desc)+1) ); - } - - /** copy constructor */ - ObjNodesel(const ObjNodesel& o) - : ObjNodesel(o.scip_, o.scip_name_, o.scip_desc_, o.scip_stdpriority_, o.scip_memsavepriority_) - { - } - - /** move constructor */ - ObjNodesel(ObjNodesel&& o) - : scip_(o.scip_), - scip_name_(0), - scip_desc_(0), - scip_stdpriority_(o.scip_stdpriority_), - scip_memsavepriority_(o.scip_memsavepriority_) - { - std::swap(scip_name_, o.scip_name_); - std::swap(scip_desc_, o.scip_desc_); - } - - /** destructor */ - virtual ~ObjNodesel() - { - /* the macro SCIPfreeMemoryArray does not need the first argument: */ - /*lint --e{64}*/ - SCIPfreeMemoryArray(scip_, &scip_name_); - SCIPfreeMemoryArray(scip_, &scip_desc_); - } - - /** assignment of polymorphic classes causes slicing and is therefore disabled. */ - ObjNodesel& operator=(const ObjNodesel& o) = delete; - - /** assignment of polymorphic classes causes slicing and is therefore disabled. */ - ObjNodesel& operator=(ObjNodesel&& o) = delete; - - /** destructor of node selector to free user data (called when SCIP is exiting) - * - * @see SCIP_DECL_NODESELFREE(x) in @ref type_nodesel.h - */ - virtual SCIP_DECL_NODESELFREE(scip_free) - { /*lint --e{715}*/ - return SCIP_OKAY; - } - - /** initialization method of node selector (called after problem was transformed) - * - * @see SCIP_DECL_NODESELINIT(x) in @ref type_nodesel.h - */ - virtual SCIP_DECL_NODESELINIT(scip_init) - { /*lint --e{715}*/ - return SCIP_OKAY; - } - - /** deinitialization method of node selector (called before transformed problem is freed) - * - * @see SCIP_DECL_NODESELEXIT(x) in @ref type_nodesel.h - */ - virtual SCIP_DECL_NODESELEXIT(scip_exit) - { /*lint --e{715}*/ - return SCIP_OKAY; - } - - /** solving process initialization method of node selector (called when branch and bound process is about to begin) - * - * @see SCIP_DECL_NODESELINITSOL(x) in @ref type_nodesel.h - */ - virtual SCIP_DECL_NODESELINITSOL(scip_initsol) - { /*lint --e{715}*/ - return SCIP_OKAY; - } - - /** solving process deinitialization method of node selector (called before branch and bound process data is freed) - * - * @see SCIP_DECL_NODESELEXITSOL(x) in @ref type_nodesel.h - */ - virtual SCIP_DECL_NODESELEXITSOL(scip_exitsol) - { /*lint --e{715}*/ - return SCIP_OKAY; - } - - /** node selection method of node selector - * - * @see SCIP_DECL_NODESELSELECT(x) in @ref type_nodesel.h - */ - virtual SCIP_DECL_NODESELSELECT(scip_select) = 0; - - /** node comparison method of node selector - * - * @see SCIP_DECL_NODESELCOMP(x) in @ref type_nodesel.h - */ - virtual SCIP_DECL_NODESELCOMP(scip_comp) = 0; -}; - -} /* namespace scip */ - - - -/** creates the node selector for the given node selector object and includes it in SCIP - * - * The method should be called in one of the following ways: - * - * 1. The user is resposible of deleting the object: - * SCIP_CALL( SCIPcreate(&scip) ); - * ... - * MyNodesel* mynodesel = new MyNodesel(...); - * SCIP_CALL( SCIPincludeObjNodesel(scip, &mynodesel, FALSE) ); - * ... - * SCIP_CALL( SCIPfree(&scip) ); - * delete mynodesel; // delete nodesel AFTER SCIPfree() ! - * - * 2. The object pointer is passed to SCIP and deleted by SCIP in the SCIPfree() call: - * SCIP_CALL( SCIPcreate(&scip) ); - * ... - * SCIP_CALL( SCIPincludeObjNodesel(scip, new MyNodesel(...), TRUE) ); - * ... - * SCIP_CALL( SCIPfree(&scip) ); // destructor of MyNodesel is called here - */ -SCIP_EXPORT -SCIP_RETCODE SCIPincludeObjNodesel( - SCIP* scip, /**< SCIP data structure */ - scip::ObjNodesel* objnodesel, /**< node selector object */ - SCIP_Bool deleteobject /**< should the node selector object be deleted when node selector is freed? */ - ); - -/** returns the nodesel object of the given name, or 0 if not existing */ -SCIP_EXPORT -scip::ObjNodesel* SCIPfindObjNodesel( - SCIP* scip, /**< SCIP data structure */ - const char* name /**< name of node selector */ - ); - -/** returns the nodesel object for the given node selector */ -SCIP_EXPORT -scip::ObjNodesel* SCIPgetObjNodesel( - SCIP* scip, /**< SCIP data structure */ - SCIP_NODESEL* nodesel /**< node selector */ - ); - -#endif diff --git a/headers/objscip/objpresol.h b/headers/objscip/objpresol.h deleted file mode 100644 index d45815c..0000000 --- a/headers/objscip/objpresol.h +++ /dev/null @@ -1,228 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* */ -/* This file is part of the program and library */ -/* SCIP --- Solving Constraint Integer Programs */ -/* */ -/* Copyright 2002-2022 Zuse Institute Berlin */ -/* */ -/* Licensed under the Apache License, Version 2.0 (the "License"); */ -/* you may not use this file except in compliance with the License. */ -/* You may obtain a copy of the License at */ -/* */ -/* http://www.apache.org/licenses/LICENSE-2.0 */ -/* */ -/* Unless required by applicable law or agreed to in writing, software */ -/* distributed under the License is distributed on an "AS IS" BASIS, */ -/* 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. */ -/* */ -/* You should have received a copy of the Apache-2.0 license */ -/* along with SCIP; see the file LICENSE. If not visit scipopt.org. */ -/* */ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -/**@file objpresol.h - * @brief C++ wrapper for presolvers - * @author Tobias Achterberg - */ - -/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/ - -#ifndef __SCIP_OBJPRESOL_H__ -#define __SCIP_OBJPRESOL_H__ - -#include -#include - -#include "scip/scip.h" -#include "objscip/objcloneable.h" - -namespace scip -{ - -/** @brief C++ wrapper for presolvers - * - * This class defines the interface for presolvers implemented in C++. Note that there is a pure virtual - * function (this function has to be implemented). This function is: scip_exec(). - * - * - \ref PRESOL "Instructions for implementing a presolver" - * - \ref PRESOLVERS "List of available presolvers" - * - \ref type_presol.h "Corresponding C interface" - */ -class ObjPresol : public ObjCloneable -{ -public: - /*lint --e{1540}*/ - - /** SCIP data structure */ - SCIP* scip_; - - /** name of the presolver */ - char* scip_name_; - - /** description of the presolver */ - char* scip_desc_; - - /** default priority of the presolver */ - const int scip_priority_; - - /** default maximal number of presolving rounds the presolver participates in (-1: no limit) */ - const int scip_maxrounds_; - - /**< timing mask of the presolver */ - const SCIP_PRESOLTIMING scip_timing_; - - /** default constructor */ - ObjPresol( - SCIP* scip, /**< SCIP data structure */ - const char* name, /**< name of presolver */ - const char* desc, /**< description of presolver */ - int priority, /**< priority of the presolver */ - int maxrounds, /**< maximal number of presolving rounds the presolver participates in (-1: no limit) */ - SCIP_PRESOLTIMING timing /**< timing mask of the presolver */ - ) - : scip_(scip), - scip_name_(0), - scip_desc_(0), - scip_priority_(priority), - scip_maxrounds_(maxrounds), - scip_timing_(timing) - { - /* the macro SCIPduplicateMemoryArray does not need the first argument: */ - SCIP_CALL_ABORT( SCIPduplicateMemoryArray(scip_, &scip_name_, name, std::strlen(name)+1) ); - SCIP_CALL_ABORT( SCIPduplicateMemoryArray(scip_, &scip_desc_, desc, std::strlen(desc)+1) ); - } - - /** copy constructor */ - ObjPresol(const ObjPresol& o) - : ObjPresol(o.scip_, o.scip_name_, o.scip_desc_, o.scip_priority_, o.scip_maxrounds_, o.scip_timing_) - { - } - - /** move constructor */ - ObjPresol(ObjPresol&& o) - : scip_(o.scip_), - scip_name_(0), - scip_desc_(0), - scip_priority_(o.scip_priority_), - scip_maxrounds_(o.scip_maxrounds_), - scip_timing_(o.scip_timing_) - { - std::swap(scip_name_, o.scip_name_); - std::swap(scip_desc_, o.scip_desc_); - } - - /** destructor */ - virtual ~ObjPresol() - { - /* the macro SCIPfreeMemoryArray does not need the first argument: */ - /*lint --e{64}*/ - SCIPfreeMemoryArray(scip_, &scip_name_); - SCIPfreeMemoryArray(scip_, &scip_desc_); - } - - /** assignment of polymorphic classes causes slicing and is therefore disabled. */ - ObjPresol& operator=(const ObjPresol& o) = delete; - - /** assignment of polymorphic classes causes slicing and is therefore disabled. */ - ObjPresol& operator=(ObjPresol&& o) = delete; - - /** destructor of presolver to free user data (called when SCIP is exiting) - * - * @see SCIP_DECL_PRESOLFREE(x) in @ref type_prop.h - */ - virtual SCIP_DECL_PRESOLFREE(scip_free) - { /*lint --e{715}*/ - return SCIP_OKAY; - } - - /** initialization method of presolver (called after problem was transformed) - * - * @see SCIP_DECL_PRESOLINIT(x) in @ref type_prop.h - */ - virtual SCIP_DECL_PRESOLINIT(scip_init) - { /*lint --e{715}*/ - return SCIP_OKAY; - } - - /** deinitialization method of presolver (called before transformed problem is freed) - * - * @see SCIP_DECL_PRESOLEXIT(x) in @ref type_prop.h - */ - virtual SCIP_DECL_PRESOLEXIT(scip_exit) - { /*lint --e{715}*/ - return SCIP_OKAY; - } - - /** presolving initialization method of presolver (called when presolving is about to begin) - * - * @see SCIP_DECL_PRESOLINITPRE(x) in @ref type_prop.h - */ - virtual SCIP_DECL_PRESOLINITPRE(scip_initpre) - { /*lint --e{715}*/ - return SCIP_OKAY; - } - - /** presolving deinitialization method of presolver (called after presolving has been finished) - * - * @see SCIP_DECL_PRESOLEXITPRE(x) in @ref type_prop.h - */ - virtual SCIP_DECL_PRESOLEXITPRE(scip_exitpre) - { /*lint --e{715}*/ - return SCIP_OKAY; - } - - /** execution method of presolver - * - * @see SCIP_DECL_PRESOLEXEC(x) in @ref type_prop.h - */ - virtual SCIP_DECL_PRESOLEXEC(scip_exec) = 0; -}; - -} /* namespace scip */ - - - -/** creates the presolver for the given presolver object and includes it in SCIP - * - * The method should be called in one of the following ways: - * - * 1. The user is resposible of deleting the object: - * SCIP_CALL( SCIPcreate(&scip) ); - * ... - * MyPresol* mypresol = new MyPresol(...); - * SCIP_CALL( SCIPincludeObjPresol(scip, &mypresol, FALSE) ); - * ... - * SCIP_CALL( SCIPfree(&scip) ); - * delete mypresol; // delete presol AFTER SCIPfree() ! - * - * 2. The object pointer is passed to SCIP and deleted by SCIP in the SCIPfree() call: - * SCIP_CALL( SCIPcreate(&scip) ); - * ... - * SCIP_CALL( SCIPincludeObjPresol(scip, new MyPresol(...), TRUE) ); - * ... - * SCIP_CALL( SCIPfree(&scip) ); // destructor of MyPresol is called here - */ -SCIP_EXPORT -SCIP_RETCODE SCIPincludeObjPresol( - SCIP* scip, /**< SCIP data structure */ - scip::ObjPresol* objpresol, /**< presolver object */ - SCIP_Bool deleteobject /**< should the presolver object be deleted when presolver is freed? */ - ); - -/** returns the presol object of the given name, or 0 if not existing */ -SCIP_EXPORT -scip::ObjPresol* SCIPfindObjPresol( - SCIP* scip, /**< SCIP data structure */ - const char* name /**< name of presolver */ - ); - -/** returns the presol object for the given presolver */ -SCIP_EXPORT -scip::ObjPresol* SCIPgetObjPresol( - SCIP* scip, /**< SCIP data structure */ - SCIP_PRESOL* presol /**< presolver */ - ); - -#endif diff --git a/headers/objscip/objpricer.h b/headers/objscip/objpricer.h deleted file mode 100644 index 9b5eba5..0000000 --- a/headers/objscip/objpricer.h +++ /dev/null @@ -1,230 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* */ -/* This file is part of the program and library */ -/* SCIP --- Solving Constraint Integer Programs */ -/* */ -/* Copyright 2002-2022 Zuse Institute Berlin */ -/* */ -/* Licensed under the Apache License, Version 2.0 (the "License"); */ -/* you may not use this file except in compliance with the License. */ -/* You may obtain a copy of the License at */ -/* */ -/* http://www.apache.org/licenses/LICENSE-2.0 */ -/* */ -/* Unless required by applicable law or agreed to in writing, software */ -/* distributed under the License is distributed on an "AS IS" BASIS, */ -/* 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. */ -/* */ -/* You should have received a copy of the Apache-2.0 license */ -/* along with SCIP; see the file LICENSE. If not visit scipopt.org. */ -/* */ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -/**@file objpricer.h - * @brief C++ wrapper for variable pricers - * @author Tobias Achterberg - */ - -/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/ - -#ifndef __SCIP_OBJPRICER_H__ -#define __SCIP_OBJPRICER_H__ - -#include -#include - -#include "scip/scip.h" -#include "objscip/objprobcloneable.h" - -namespace scip -{ - -/** @brief C++ wrapper for variable pricer - * - * This class defines the interface for variable pricer implemented in C++. Note that there is a pure virtual - * function (this function has to be implemented). This function is: scip_redcost(). - * - * - \ref PRICER "Instructions for implementing a variable pricer" - * - \ref type_pricer.h "Corresponding C interface" - */ -class ObjPricer : public ObjProbCloneable -{ -public: - /*lint --e{1540}*/ - - /** SCIP data structure */ - SCIP* scip_; - - /** name of the variable pricer */ - char* scip_name_; - - /** description of the variable pricer */ - char* scip_desc_; - - /** default priority of the variable pricer */ - const int scip_priority_; - - /** should the pricer be delayed until no other pricers or already existing problem variables with negative reduced - * costs are found? - */ - const SCIP_Bool scip_delay_; - - /** default constructor */ - ObjPricer( - SCIP* scip, /**< SCIP data structure */ - const char* name, /**< name of variable pricer */ - const char* desc, /**< description of variable pricer */ - int priority, /**< priority of the variable pricer */ - SCIP_Bool delay /**< should the pricer be delayed until no other pricers or already existing - * problem variables with negative reduced costs are found? - * if this is set to FALSE it may happen that the pricer produces columns - * that already exist in the problem (which are also priced in by the - * default problem variable pricing in the same round) - */ - ) - : scip_(scip), - scip_name_(0), - scip_desc_(0), - scip_priority_(priority), - scip_delay_(delay) - { - /* the macro SCIPduplicateMemoryArray does not need the first argument: */ - SCIP_CALL_ABORT( SCIPduplicateMemoryArray(scip_, &scip_name_, name, std::strlen(name)+1) ); - SCIP_CALL_ABORT( SCIPduplicateMemoryArray(scip_, &scip_desc_, desc, std::strlen(desc)+1) ); - } - - /** copy constructor */ - ObjPricer(const ObjPricer& o) : ObjPricer(o.scip_, o.scip_name_, o.scip_desc_, o.scip_priority_, o.scip_delay_) {} - - /** move constructor */ - ObjPricer(ObjPricer&& o) - : scip_(o.scip_), scip_name_(0), scip_desc_(0), scip_priority_(o.scip_priority_), scip_delay_(o.scip_delay_) - { - std::swap(scip_name_, o.scip_name_); - std::swap(scip_desc_, o.scip_desc_); - } - - /** destructor */ - virtual ~ObjPricer() - { - /* the macro SCIPfreeMemoryArray does not need the first argument: */ - /*lint --e{64}*/ - SCIPfreeMemoryArray(scip_, &scip_name_); - SCIPfreeMemoryArray(scip_, &scip_desc_); - } - - /** assignment of polymorphic classes causes slicing and is therefore disabled. */ - ObjPricer& operator=(const ObjPricer& o) = delete; - - /** assignment of polymorphic classes causes slicing and is therefore disabled. */ - ObjPricer& operator=(ObjPricer&& o) = delete; - - /** destructor of variable pricer to free user data (called when SCIP is exiting) - * - * @see SCIP_DECL_PRICERFREE(x) in @ref type_pricer.h - */ - virtual SCIP_DECL_PRICERFREE(scip_free) - { /*lint --e{715}*/ - return SCIP_OKAY; - } - - /** initialization method of variable pricer (called after problem was transformed) - * - * @see SCIP_DECL_PRICERINIT(x) in @ref type_pricer.h - */ - virtual SCIP_DECL_PRICERINIT(scip_init) - { /*lint --e{715}*/ - return SCIP_OKAY; - } - - /** deinitialization method of variable pricer (called before transformed problem is freed) - * - * @see SCIP_DECL_PRICEREXIT(x) in @ref type_pricer.h - */ - virtual SCIP_DECL_PRICEREXIT(scip_exit) - { /*lint --e{715}*/ - return SCIP_OKAY; - } - - /** solving process initialization method of variable pricer (called when branch and bound process is about to begin) - * - * @see SCIP_DECL_PRICERINITSOL(x) in @ref type_pricer.h - */ - virtual SCIP_DECL_PRICERINITSOL(scip_initsol) - { /*lint --e{715}*/ - return SCIP_OKAY; - } - - /** solving process deinitialization method of variable pricer (called before branch and bound process data is freed) - * - * @see SCIP_DECL_PRICEREXITSOL(x) in @ref type_pricer.h - */ - virtual SCIP_DECL_PRICEREXITSOL(scip_exitsol) - { /*lint --e{715}*/ - return SCIP_OKAY; - } - - /** reduced cost pricing method of variable pricer for feasible LPs - * - * @see SCIP_DECL_PRICERREDCOST(x) in @ref type_pricer.h - */ - virtual SCIP_DECL_PRICERREDCOST(scip_redcost) = 0; - - /** farkas pricing method of variable pricer for infeasible LPs - * - * @see SCIP_DECL_PRICERFARKAS(x) in @ref type_pricer.h - */ - virtual SCIP_DECL_PRICERFARKAS(scip_farkas) - { /*lint --e{715}*/ - return SCIP_OKAY; - } -}; - -} /* namespace scip */ - - - -/** creates the variable pricer for the given variable pricer object and includes it in SCIP - * - * The method should be called in one of the following ways: - * - * 1. The user is resposible of deleting the object: - * SCIP_CALL( SCIPcreate(&scip) ); - * ... - * MyPricer* mypricer = new MyPricer(...); - * SCIP_CALL( SCIPincludeObjPricer(scip, &mypricer, FALSE) ); - * ... - * SCIP_CALL( SCIPfree(&scip) ); - * delete mypricer; // delete pricer AFTER SCIPfree() ! - * - * 2. The object pointer is passed to SCIP and deleted by SCIP in the SCIPfree() call: - * SCIP_CALL( SCIPcreate(&scip) ); - * ... - * SCIP_CALL( SCIPincludeObjPricer(scip, new MyPricer(...), TRUE) ); - * ... - * SCIP_CALL( SCIPfree(&scip) ); // destructor of MyPricer is called here - */ -SCIP_EXPORT -SCIP_RETCODE SCIPincludeObjPricer( - SCIP* scip, /**< SCIP data structure */ - scip::ObjPricer* objpricer, /**< variable pricer object */ - SCIP_Bool deleteobject /**< should the pricer object be deleted when pricer is freed? */ - ); - -/** returns the variable pricer object of the given name, or 0 if not existing */ -SCIP_EXPORT -scip::ObjPricer* SCIPfindObjPricer( - SCIP* scip, /**< SCIP data structure */ - const char* name /**< name of variable pricer */ - ); - -/** returns the variable pricer object for the given pricer */ -SCIP_EXPORT -scip::ObjPricer* SCIPgetObjPricer( - SCIP* scip, /**< SCIP data structure */ - SCIP_PRICER* pricer /**< pricer */ - ); - -#endif diff --git a/headers/objscip/objprobcloneable.h b/headers/objscip/objprobcloneable.h deleted file mode 100644 index bb4a49f..0000000 --- a/headers/objscip/objprobcloneable.h +++ /dev/null @@ -1,75 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* */ -/* This file is part of the program and library */ -/* SCIP --- Solving Constraint Integer Programs */ -/* */ -/* Copyright 2002-2022 Zuse Institute Berlin */ -/* */ -/* Licensed under the Apache License, Version 2.0 (the "License"); */ -/* you may not use this file except in compliance with the License. */ -/* You may obtain a copy of the License at */ -/* */ -/* http://www.apache.org/licenses/LICENSE-2.0 */ -/* */ -/* Unless required by applicable law or agreed to in writing, software */ -/* distributed under the License is distributed on an "AS IS" BASIS, */ -/* 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. */ -/* */ -/* You should have received a copy of the Apache-2.0 license */ -/* along with SCIP; see the file LICENSE. If not visit scipopt.org. */ -/* */ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -/**@file objprobcloneable.h - * @brief Definition of base class for all clonable classes which define problem data - * @author Tobias Achterberg - * @author Timo Berthold - * @author Ambros Gleixner - * @author Stefan Heinz - * @author Stefan Vigerske - */ - -/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/ - -#ifndef __SCIP_OBJPROBCLONEABLE_H__ -#define __SCIP_OBJPROBCLONEABLE_H__ - -#include "scip/def.h" -#include "scip/scip.h" -#include "objscip/type_objprobcloneable.h" - - - -namespace scip -{ - /** @brief Definition of base class for all clonable classes which define problem data - * - * Constraint handler and variable pricer C++ wrapper object plugins should extend this class - */ - struct ObjProbCloneable - { - virtual ~ObjProbCloneable() {} - - /** assignment of polymorphic classes causes slicing and is therefore disabled. */ - ObjProbCloneable& operator=(const ObjProbCloneable& o) = delete; - - /** assignment of polymorphic classes causes slicing and is therefore disabled. */ - ObjProbCloneable& operator=(ObjProbCloneable&& o) = delete; - - /** clone method which will be used to copy constraint handler and variable pricer objects */ - virtual SCIP_DECL_OBJPROBCLONE(ObjProbCloneable* clone) - { - return 0; - } - - /** returns whether the plugin object is copyable */ - virtual SCIP_DECL_OBJPROBISCLONEABLE(iscloneable) - { - return FALSE; - } - }; -} - -#endif diff --git a/headers/objscip/objprobdata.h b/headers/objscip/objprobdata.h deleted file mode 100644 index d01b9b6..0000000 --- a/headers/objscip/objprobdata.h +++ /dev/null @@ -1,236 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* */ -/* This file is part of the program and library */ -/* SCIP --- Solving Constraint Integer Programs */ -/* */ -/* Copyright 2002-2022 Zuse Institute Berlin */ -/* */ -/* Licensed under the Apache License, Version 2.0 (the "License"); */ -/* you may not use this file except in compliance with the License. */ -/* You may obtain a copy of the License at */ -/* */ -/* http://www.apache.org/licenses/LICENSE-2.0 */ -/* */ -/* Unless required by applicable law or agreed to in writing, software */ -/* distributed under the License is distributed on an "AS IS" BASIS, */ -/* 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. */ -/* */ -/* You should have received a copy of the Apache-2.0 license */ -/* along with SCIP; see the file LICENSE. If not visit scipopt.org. */ -/* */ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -/**@file objprobdata.h - * @brief C++ wrapper for user problem data - * @author Tobias Achterberg - */ - -/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/ - -#ifndef __SCIP_OBJPROBDATA_H__ -#define __SCIP_OBJPROBDATA_H__ - - -#include - -#include "scip/scip.h" -#include "objscip/objcloneable.h" - -namespace scip -{ - -/** @brief C++ wrapper for user problem data - * - * This class defines the interface for user problem data implemented in C++. This class can be accessed at any time - * using the methods SCIPgetObjProbData(). Therefore, it can be used to store data which has to be accessible within - * several plugins. - * - * - \ref type_prob.h "Corresponding C interface" - */ -class ObjProbData -{ -public: - /** default constructor */ - ObjProbData() - { - } - - /** destructor */ - virtual ~ObjProbData() - { - } - - /** assignment of polymorphic classes causes slicing and is therefore disabled. */ - ObjProbData& operator=(const ObjProbData& o) = delete; - - /** assignment of polymorphic classes causes slicing and is therefore disabled. */ - ObjProbData& operator=(ObjProbData&& o) = delete; - - /** destructor of user problem data to free original user data (called when original problem is freed) - * - * If the "deleteobject" flag in the SCIPcreateObjProb() method was set to TRUE, this method is not needed, - * because all the work to delete the user problem data can be done in the destructor of the user problem - * data object. If the "deleteobject" flag was set to FALSE, and the user problem data object stays alive - * after the SCIP problem is freed, this method should delete all the problem specific data that is no - * longer needed. - */ /*lint -e715*/ - virtual SCIP_RETCODE scip_delorig( - SCIP* scip /**< SCIP data structure */ - ) - { /*lint --e{715}*/ - return SCIP_OKAY; - } - - /** creates user data of transformed problem by transforming the original user problem data - * (called after problem was transformed) - * - * The user has two possibilities to implement this method: - * 1. Return the pointer to the original problem data object (this) as pointer to the transformed problem data - * object. The user may modify some internal attributes, but he has to make sure, that these modifications are - * reversed in the scip_deltrans() method, such that the original problem data is restored. In this case, - * he should set *deleteobject to FALSE, because the problem data must not be destructed by SCIP after the - * solving process is terminated. - * 2. Call the copy constructor of the problem data object and return the created copy as transformed problem - * data object. In this case, he probably wants to set *deleteobject to TRUE, thus letting SCIP call the - * destructor of the object if the transformed problem data is no longer needed. - */ /*lint -e715*/ - virtual SCIP_RETCODE scip_trans( - SCIP* scip, /**< SCIP data structure */ - ObjProbData** objprobdata, /**< pointer to store the transformed problem data object */ - SCIP_Bool* deleteobject /**< pointer to store whether SCIP should delete the object after solving */ - ) - { /*lint --e{715}*/ - assert(objprobdata != NULL); - assert(deleteobject != NULL); - - /* the default implementation just copies the pointer to the problem data object; - * SCIP must not destruct the transformed problem data object, because the original problem data must stay alive - */ - *objprobdata = this; - *deleteobject = FALSE; - - return SCIP_OKAY; - } - - /** destructor of user problem data to free transformed user data (called when transformed problem is freed) - * - * If the "*deleteobject" flag in the scip_trans() method was set to TRUE, this method is not needed, - * because all the work to delete the user problem data can be done in the destructor of the user problem - * data object. If the "*deleteobject" flag was set to FALSE, and the user problem data object stays alive - * after the SCIP problem is freed, this method should delete all the problem specific data that is no - * longer needed. - */ /*lint -e715*/ - virtual SCIP_RETCODE scip_deltrans( - SCIP* scip /**< SCIP data structure */ - ) - { /*lint --e{715}*/ - return SCIP_OKAY; - } - - /** solving process initialization method of transformed data (called before the branch and bound process begins) - * - * This method is called before the branch and bound process begins and can be used to initialize user problem - * data that depends for example on the number of active problem variables, because these are now fixed. - */ /*lint -e715*/ - virtual SCIP_RETCODE scip_initsol( - SCIP* scip /**< SCIP data structure */ - ) - { /*lint --e{715}*/ - return SCIP_OKAY; - } - - /** solving process deinitialization method of transformed data (called before the branch and bound data is freed) - * - * This method is called before the branch and bound data is freed and should be used to free all data that - * was allocated in the solving process initialization method. The user has to make sure, that all LP rows associated - * to the transformed user problem data are released. - */ /*lint -e715*/ - virtual SCIP_RETCODE scip_exitsol( - SCIP* scip, /**< SCIP data structure */ - SCIP_Bool restart /**< was this exit solve call triggered by a restart? */ - ) - { /*lint --e{715}*/ - return SCIP_OKAY; - } - - /** copies user data of source SCIP for the target SCIP - * - * This method should copy the problem data of the source SCIP and create a target problem data for (target) - * SCIP. Implementing this callback is optional. If the copying process was successful the target SCIP gets this - * problem data assigned. In case the result pointer is set to SCIP_DIDNOTRUN the target SCIP will have no problem data - * at all. - * - * The variable map and the constraint map can be used via the function SCIPgetVarCopy() and SCIPgetConsCopy(), - * respectively, to get for certain variables and constraints of the source SCIP the counter parts in the target - * SCIP. You should be very carefully in using these two methods since they could lead to an infinite loop due to - * recursion. - * - * possible return values for *result: - * - SCIP_DIDNOTRUN : the copying process was not performed - * - SCIP_SUCCESS : the copying process was successfully performed - */ /*lint -e715*/ - virtual SCIP_RETCODE scip_copy( - SCIP* scip, /**< SCIP data structure */ - SCIP* sourcescip, /**< source SCIP main data structure */ - SCIP_HASHMAP* varmap, /**< a hashmap which stores the mapping of source variables to corresponding - * target variables */ - SCIP_HASHMAP* consmap, /**< a hashmap which stores the mapping of source contraints to corresponding - * target constraints */ - ObjProbData** objprobdata, /**< pointer to store the copied problem data object */ - SCIP_Bool global, /**< create a global or a local copy? */ - SCIP_RESULT* result /**< pointer to store the result of the call */ - ) - { /*lint --e{715}*/ - (*objprobdata) = 0; - (*result) = SCIP_DIDNOTRUN; - return SCIP_OKAY; - } -}; - -} /* namespace scip */ - - - -/** creates empty problem, initializes all solving data structures, and sets the user problem data to point to the - * given user data object - * - * The method should be called in one of the following ways: - * - * 1. The user is resposible of deleting the object: - * SCIP_CALL( SCIPcreate(&scip) ); - * ... - * MyProbData* myprobdata = new MyProbData(...); - * SCIP_CALL( SCIPcreateObjProb(scip, "probname", &myprobdata, FALSE) ); - * ... // solve the problem - * SCIP_CALL( SCIPfreeProb(scip) ); - * delete myprobdata; // delete probdata AFTER SCIPfreeProb() ! - * ... - * SCIP_CALL( SCIPfree(&scip) ); - * - * 2. The object pointer is passed to SCIP and deleted by SCIP in the SCIPfreeProb() call: - * SCIP_CALL( SCIPcreate(&scip) ); - * ... - * SCIP_CALL( SCIPcreateObjProb(scip, "probname", new MyProbData(...), TRUE) ); - * ... - * SCIP_CALL( SCIPfree(&scip) ); // problem is freed and destructor of MyProbData is called here - */ -SCIP_EXPORT -SCIP_RETCODE SCIPcreateObjProb( - SCIP* scip, /**< SCIP data structure */ - const char* name, /**< problem name */ - scip::ObjProbData* objprobdata, /**< user problem data object */ - SCIP_Bool deleteobject /**< should the user problem data object be deleted when problem is freed? */ - ); - -/** gets user problem data object - * Warning! This method should only be called after a problem was created with SCIPcreateObjProb(). - * Otherwise, a segmentation fault may arise, or an undefined pointer is returned. - */ -SCIP_EXPORT -scip::ObjProbData* SCIPgetObjProbData( - SCIP* scip /**< SCIP data structure */ - ); - -#endif diff --git a/headers/objscip/objprop.h b/headers/objscip/objprop.h deleted file mode 100644 index 6ad7936..0000000 --- a/headers/objscip/objprop.h +++ /dev/null @@ -1,297 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* */ -/* This file is part of the program and library */ -/* SCIP --- Solving Constraint Integer Programs */ -/* */ -/* Copyright 2002-2022 Zuse Institute Berlin */ -/* */ -/* Licensed under the Apache License, Version 2.0 (the "License"); */ -/* you may not use this file except in compliance with the License. */ -/* You may obtain a copy of the License at */ -/* */ -/* http://www.apache.org/licenses/LICENSE-2.0 */ -/* */ -/* Unless required by applicable law or agreed to in writing, software */ -/* distributed under the License is distributed on an "AS IS" BASIS, */ -/* 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. */ -/* */ -/* You should have received a copy of the Apache-2.0 license */ -/* along with SCIP; see the file LICENSE. If not visit scipopt.org. */ -/* */ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -/**@file objprop.h - * @brief C++ wrapper for propagators - * @author Tobias Achterberg - */ - -/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/ - -#ifndef __SCIP_OBJPROP_H__ -#define __SCIP_OBJPROP_H__ - -#include -#include - -#include "scip/scip.h" -#include "objscip/objcloneable.h" - -namespace scip -{ - -/** @brief C++ wrapper for propagators - * - * This class defines the interface for propagators implemented in C++. Note that there is a pure virtual - * function (this function has to be implemented). This function is: scip_exec(). - * - * - \ref PROP "Instructions for implementing a propagator" - * - \ref PROPAGATORS "List of available propagators" - * - \ref type_prop.h "Corresponding C interface" - */ -class ObjProp : public ObjCloneable -{ -public: - /*lint --e{1540}*/ - - /** SCIP data structure */ - SCIP* scip_; - - /** name of the propagator */ - char* scip_name_; - - /** description of the propagator */ - char* scip_desc_; - - /** default priority of the propagator */ - const int scip_priority_; - - /** frequency for calling propagator */ - const int scip_freq_; - - /** should propagator be delayed, if other propagators found reductions? */ - const SCIP_Bool scip_delay_; - - /** positions in the node solving loop where propagator should be executed */ - const SCIP_PROPTIMING scip_timingmask_; - - /** default presolving priority of the propagator */ - const int scip_presol_priority_; - - /** frequency for calling propagator */ - const int scip_presol_maxrounds_; - - /**< timing mask of the propagator's presolving method */ - const SCIP_PRESOLTIMING scip_presol_timing_; - - - /** default constructor */ - ObjProp( - SCIP* scip, /**< SCIP data structure */ - const char* name, /**< name of propagator */ - const char* desc, /**< description of propagator */ - int priority, /**< priority of the propagator */ - int freq, /**< frequency for calling propagator */ - SCIP_Bool delay, /**< should propagator be delayed, if other propagators found reductions? */ - SCIP_PROPTIMING timingmask, /**< positions in the node solving loop where propagator should be executed */ - int presolpriority, /**< presolving priority of the propagator (>= 0: before, < 0: after constraint handlers) */ - int presolmaxrounds, /**< maximal number of presolving rounds the propagator participates in (-1: no limit) */ - SCIP_PRESOLTIMING presoltiming /**< timing mask of the propagator's presolving method */ - ) - : scip_(scip), - scip_name_(0), - scip_desc_(0), - scip_priority_(priority), - scip_freq_(freq), - scip_delay_(delay), - scip_timingmask_(timingmask), - scip_presol_priority_(presolpriority), - scip_presol_maxrounds_(presolmaxrounds), - scip_presol_timing_(presoltiming) - { - /* the macro SCIPduplicateMemoryArray does not need the first argument: */ - SCIP_CALL_ABORT( SCIPduplicateMemoryArray(scip_, &scip_name_, name, std::strlen(name)+1) ); - SCIP_CALL_ABORT( SCIPduplicateMemoryArray(scip_, &scip_desc_, desc, std::strlen(desc)+1) ); - } - - /** copy constructor */ - ObjProp(const ObjProp& o) - : ObjProp(o.scip_, o.scip_name_, o.scip_desc_, o.scip_priority_, o.scip_freq_, o.scip_delay_, o.scip_timingmask_, - o.scip_presol_priority_, o.scip_presol_maxrounds_, o.scip_presol_timing_) - { - } - - /** move constructor */ - ObjProp(ObjProp&& o) - : scip_(o.scip_), - scip_name_(0), - scip_desc_(0), - scip_priority_(o.scip_priority_), - scip_freq_(o.scip_freq_), - scip_delay_(o.scip_delay_), - scip_timingmask_(o.scip_timingmask_), - scip_presol_priority_(o.scip_presol_priority_), - scip_presol_maxrounds_(o.scip_presol_maxrounds_), - scip_presol_timing_(o.scip_presol_timing_) - { - std::swap(scip_name_, o.scip_name_); - std::swap(scip_desc_, o.scip_desc_); - } - - /** destructor */ - virtual ~ObjProp() - { - /* the macro SCIPfreeMemoryArray does not need the first argument: */ - /*lint --e{64}*/ - SCIPfreeMemoryArray(scip_, &scip_name_); - SCIPfreeMemoryArray(scip_, &scip_desc_); - } - - /** assignment of polymorphic classes causes slicing and is therefore disabled. */ - ObjProp& operator=(const ObjProp& o) = delete; - - /** assignment of polymorphic classes causes slicing and is therefore disabled. */ - ObjProp& operator=(ObjProp&& o) = delete; - - /** destructor of propagator to free user data (called when SCIP is exiting) - * - * @see SCIP_DECL_PROPFREE(x) in @ref type_prop.h - */ - virtual SCIP_DECL_PROPFREE(scip_free) - { /*lint --e{715}*/ - return SCIP_OKAY; - } - - /** initialization method of propagator (called after problem was transformed) - * - * @see SCIP_DECL_PROPINIT(x) in @ref type_prop.h - */ - virtual SCIP_DECL_PROPINIT(scip_init) - { /*lint --e{715}*/ - return SCIP_OKAY; - } - - /** deinitialization method of propagator (called before transformed problem is freed) - * - * @see SCIP_DECL_PROPEXIT(x) in @ref type_prop.h - */ - virtual SCIP_DECL_PROPEXIT(scip_exit) - { /*lint --e{715}*/ - return SCIP_OKAY; - } - - /** presolving initialization method of propagator (called when presolving is about to begin) - * - * @see SCIP_DECL_PROPINITPRE(x) in @ref type_prop.h - */ - virtual SCIP_DECL_PROPINITPRE(scip_initpre) - { /*lint --e{715}*/ - return SCIP_OKAY; - } - - /** presolving deinitialization method of propagator (called after presolving has been finished) - * - * @see SCIP_DECL_PROPEXITPRE(x) in @ref type_prop.h - */ - virtual SCIP_DECL_PROPEXITPRE(scip_exitpre) - { /*lint --e{715}*/ - return SCIP_OKAY; - } - - /** solving process initialization method of propagator (called when branch and bound process is about to begin) - * - * @see SCIP_DECL_PROPINITSOL(x) in @ref type_prop.h - */ - virtual SCIP_DECL_PROPINITSOL(scip_initsol) - { /*lint --e{715}*/ - return SCIP_OKAY; - } - - /** solving process deinitialization method of propagator (called before branch and bound process data is freed) - * - * @see SCIP_DECL_PROPEXITSOL(x) in @ref type_prop.h - */ - virtual SCIP_DECL_PROPEXITSOL(scip_exitsol) - { /*lint --e{715}*/ - return SCIP_OKAY; - } - - /** presolving method of propagator - * - * @see SCIP_DECL_PROPPRESOL(x) in @ref type_prop.h - */ - virtual SCIP_DECL_PROPPRESOL(scip_presol) - { /*lint --e{715}*/ - assert(result != NULL); - *result = SCIP_DIDNOTRUN; - return SCIP_OKAY; - } - - /** execution method of propagator - * - * @see SCIP_DECL_PROPEXEC(x) in @ref type_prop.h - */ - virtual SCIP_DECL_PROPEXEC(scip_exec) = 0; - - /** propagation conflict resolving method of propagator - * - * @see SCIP_DECL_PROPRESPROP(x) in @ref type_prop.h - */ - virtual SCIP_DECL_PROPRESPROP(scip_resprop) - { /*lint --e{715}*/ - - /* set result pointer to indicate the propagation was not resolved */ - assert(result != NULL); - (*result) = SCIP_DIDNOTFIND; - - return SCIP_OKAY; - } -}; - -} /* namespace scip */ - - - -/** creates the propagator for the given propagator object and includes it in SCIP - * - * The method should be called in one of the following ways: - * - * 1. The user is resposible of deleting the object: - * SCIP_CALL( SCIPcreate(&scip) ); - * ... - * MyProp* myprop = new MyProp(...); - * SCIP_CALL( SCIPincludeObjProp(scip, &myprop, FALSE) ); - * ... - * SCIP_CALL( SCIPfree(&scip) ); - * delete myprop; // delete prop AFTER SCIPfree() ! - * - * 2. The object pointer is passed to SCIP and deleted by SCIP in the SCIPfree() call: - * SCIP_CALL( SCIPcreate(&scip) ); - * ... - * SCIP_CALL( SCIPincludeObjProp(scip, new MyProp(...), TRUE) ); - * ... - * SCIP_CALL( SCIPfree(&scip) ); // destructor of MyProp is called here - */ -SCIP_EXPORT -SCIP_RETCODE SCIPincludeObjProp( - SCIP* scip, /**< SCIP data structure */ - scip::ObjProp* objprop, /**< propagator object */ - SCIP_Bool deleteobject /**< should the propagator object be deleted when propagator is freed? */ - ); - -/** returns the prop object of the given name, or 0 if not existing */ -SCIP_EXPORT -scip::ObjProp* SCIPfindObjProp( - SCIP* scip, /**< SCIP data structure */ - const char* name /**< name of propagator */ - ); - -/** returns the prop object for the given propagator */ -SCIP_EXPORT -scip::ObjProp* SCIPgetObjProp( - SCIP* scip, /**< SCIP data structure */ - SCIP_PROP* prop /**< propagator */ - ); - -#endif diff --git a/headers/objscip/objreader.h b/headers/objscip/objreader.h deleted file mode 100644 index 978ac9c..0000000 --- a/headers/objscip/objreader.h +++ /dev/null @@ -1,199 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* */ -/* This file is part of the program and library */ -/* SCIP --- Solving Constraint Integer Programs */ -/* */ -/* Copyright 2002-2022 Zuse Institute Berlin */ -/* */ -/* Licensed under the Apache License, Version 2.0 (the "License"); */ -/* you may not use this file except in compliance with the License. */ -/* You may obtain a copy of the License at */ -/* */ -/* http://www.apache.org/licenses/LICENSE-2.0 */ -/* */ -/* Unless required by applicable law or agreed to in writing, software */ -/* distributed under the License is distributed on an "AS IS" BASIS, */ -/* 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. */ -/* */ -/* You should have received a copy of the Apache-2.0 license */ -/* along with SCIP; see the file LICENSE. If not visit scipopt.org. */ -/* */ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -/**@file objreader.h - * @brief C++ wrapper for file readers and writers - * @author Tobias Achterberg - */ - -/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/ - -#ifndef __SCIP_OBJREADER_H__ -#define __SCIP_OBJREADER_H__ - -#include -#include - -#include "scip/scip.h" -#include "objscip/objcloneable.h" - -namespace scip -{ - -/** @brief C++ wrapper for file readers and writers - * - * This class defines the interface for file readers and writers implemented in C++. - * - * - \ref READER "Instructions for implementing a file reader and writer" - * - \ref FILEREADERS "List of available file readers and writers" - * - \ref type_reader.h "Corresponding C interface" - */ -class ObjReader : public ObjCloneable -{ -public: - /*lint --e{1540}*/ - - /** SCIP data structure */ - SCIP* scip_; - - /** name of the file reader */ - char* scip_name_; - - /** description of the file reader */ - char* scip_desc_; - - /** file extension that reader processes */ - char* scip_extension_; - - /** default constructor */ - ObjReader( - SCIP* scip, /**< SCIP data structure */ - const char* name, /**< name of file reader */ - const char* desc, /**< description of file reader */ - const char* extension /**< file extension that reader processes */ - ) - : scip_(scip), - scip_name_(0), - scip_desc_(0), - scip_extension_(0) - { - /* the macro SCIPduplicateMemoryArray does not need the first argument: */ - SCIP_CALL_ABORT( SCIPduplicateMemoryArray(scip_, &scip_name_, name, std::strlen(name)+1) ); - SCIP_CALL_ABORT( SCIPduplicateMemoryArray(scip_, &scip_desc_, desc, std::strlen(desc)+1) ); - SCIP_CALL_ABORT( SCIPduplicateMemoryArray(scip_, &scip_extension_, extension, std::strlen(extension)+1) ); - } - - /** copy constructor */ - ObjReader(const ObjReader& o) : ObjReader(o.scip_, o.scip_name_, o.scip_desc_, o.scip_extension_) {} - - /** move constructor */ - ObjReader(ObjReader&& o) : scip_(o.scip_), scip_name_(0), scip_desc_(0), scip_extension_(0) - { - std::swap(scip_name_, o.scip_name_); - std::swap(scip_desc_, o.scip_desc_); - std::swap(scip_extension_, o.scip_extension_); - } - - /** destructor */ - virtual ~ObjReader() - { - /* the macro SCIPfreeMemoryArray does not need the first argument: */ - /*lint --e{64}*/ - SCIPfreeMemoryArray(scip_, &scip_name_); - SCIPfreeMemoryArray(scip_, &scip_desc_); - SCIPfreeMemoryArray(scip_, &scip_extension_); - } - - /** assignment of polymorphic classes causes slicing and is therefore disabled. */ - ObjReader& operator=(const ObjReader& o) = delete; - - /** assignment of polymorphic classes causes slicing and is therefore disabled. */ - ObjReader& operator=(ObjReader&& o) = delete; - - /** destructor of file reader to free user data (called when SCIP is exiting) - * - * @see SCIP_DECL_READERFREE(x) in @ref type_reader.h - */ - virtual SCIP_DECL_READERFREE(scip_free) - { /*lint --e{715}*/ - return SCIP_OKAY; - } - - /** problem reading method of reader - * - * @see SCIP_DECL_READERREAD(x) in @ref type_reader.h - */ - virtual SCIP_DECL_READERREAD(scip_read) - { /*lint --e{715}*/ - - /* set result pointer to indicate that the reading was not performed */ - assert(result != NULL); - (*result) = SCIP_DIDNOTRUN; - - return SCIP_OKAY; - } - - /** problem writing method of reader; NOTE: if the parameter "genericnames" is TRUE, then - * SCIP already set all variable and constraint names to generic names; therefore, this - * method should always use SCIPvarGetName() and SCIPconsGetName(); - * - * @see SCIP_DECL_READERWRITE(x) in @ref type_reader.h - */ - virtual SCIP_DECL_READERWRITE(scip_write) - { /*lint --e{715}*/ - - /* set result pointer to indicate that the writing was not performed */ - assert(result != NULL); - (*result) = SCIP_DIDNOTRUN; - - return SCIP_OKAY; - } -}; - -} /* namespace scip */ - - - -/** creates the file reader for the given file reader object and includes it in SCIP - * - * The method should be called in one of the following ways: - * - * 1. The user is resposible of deleting the object: - * SCIP_CALL( SCIPcreate(&scip) ); - * ... - * MyReader* myreader = new MyReader(...); - * SCIP_CALL( SCIPincludeObjReader(scip, &myreader, FALSE) ); - * ... - * SCIP_CALL( SCIPfree(&scip) ); - * delete myreader; // delete reader AFTER SCIPfree() ! - * - * 2. The object pointer is passed to SCIP and deleted by SCIP in the SCIPfree() call: - * SCIP_CALL( SCIPcreate(&scip) ); - * ... - * SCIP_CALL( SCIPincludeObjReader(scip, new MyReader(...), TRUE) ); - * ... - * SCIP_CALL( SCIPfree(&scip) ); // destructor of MyReader is called here - */ -SCIP_EXPORT -SCIP_RETCODE SCIPincludeObjReader( - SCIP* scip, /**< SCIP data structure */ - scip::ObjReader* objreader, /**< file reader object */ - SCIP_Bool deleteobject /**< should the reader object be deleted when reader is freed? */ - ); - -/** returns the reader object of the given name, or 0 if not existing */ -SCIP_EXPORT -scip::ObjReader* SCIPfindObjReader( - SCIP* scip, /**< SCIP data structure */ - const char* name /**< name of file reader */ - ); - -/** returns the reader object for the given file reader */ -SCIP_EXPORT -scip::ObjReader* SCIPgetObjReader( - SCIP* scip, /**< SCIP data structure */ - SCIP_READER* reader /**< file reader */ - ); - -#endif diff --git a/headers/objscip/objrelax.h b/headers/objscip/objrelax.h deleted file mode 100644 index ec78d00..0000000 --- a/headers/objscip/objrelax.h +++ /dev/null @@ -1,227 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* */ -/* This file is part of the program and library */ -/* SCIP --- Solving Constraint Integer Programs */ -/* */ -/* Copyright 2002-2022 Zuse Institute Berlin */ -/* */ -/* Licensed under the Apache License, Version 2.0 (the "License"); */ -/* you may not use this file except in compliance with the License. */ -/* You may obtain a copy of the License at */ -/* */ -/* http://www.apache.org/licenses/LICENSE-2.0 */ -/* */ -/* Unless required by applicable law or agreed to in writing, software */ -/* distributed under the License is distributed on an "AS IS" BASIS, */ -/* 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. */ -/* */ -/* You should have received a copy of the Apache-2.0 license */ -/* along with SCIP; see the file LICENSE. If not visit scipopt.org. */ -/* */ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -/**@file objrelax.h - * @brief C++ wrapper for relaxation handlers - * @author Tobias Achterberg - */ - -/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/ - -#ifndef __SCIP_OBJRELAX_H__ -#define __SCIP_OBJRELAX_H__ - -#include -#include - -#include "scip/scip.h" -#include "objscip/objcloneable.h" - -namespace scip -{ - -/** @brief C++ wrapper for relaxation handlers - * - * This class defines the interface for relaxation handlers implemented in C++. Note that there is a pure virtual - * function (this function has to be implemented). This function is: scip_exec(). - * - * - \ref RELAX "Instructions for implementing a relaxation handler" - * - \ref type_relax.h "Corresponding C interface" - */ -class ObjRelax : public ObjCloneable -{ -public: - /*lint --e{1540}*/ - - /** SCIP data structure */ - SCIP* scip_; - - /** name of the relaxator */ - char* scip_name_; - - /** description of the relaxator */ - char* scip_desc_; - - /** default priority of the relaxator (negative: call after LP, non-negative: call before LP) */ - const int scip_priority_; - - /** frequency for calling relaxator */ - const int scip_freq_; - - /** does the relaxator contain all cuts in the LP? */ - const SCIP_Bool scip_includeslp_; - - /** default constructor */ - ObjRelax( - SCIP* scip, /**< SCIP data structure */ - const char* name, /**< name of relaxator */ - const char* desc, /**< description of relaxator */ - int priority, /**< priority of the relaxator (negative: after LP, non-negative: before LP) */ - int freq, /**< frequency for calling relaxator */ - SCIP_Bool includeslp /**< Does the relaxator contain all cuts in the LP? */ - ) - : scip_(scip), - scip_name_(0), - scip_desc_(0), - scip_priority_(priority), - scip_freq_(freq), - scip_includeslp_(includeslp) - { - /* the macro SCIPduplicateMemoryArray does not need the first argument: */ - SCIP_CALL_ABORT( SCIPduplicateMemoryArray(scip_, &scip_name_, name, std::strlen(name)+1) ); - SCIP_CALL_ABORT( SCIPduplicateMemoryArray(scip_, &scip_desc_, desc, std::strlen(desc)+1) ); - } - - /** copy constructor */ - ObjRelax(const ObjRelax& o) - : ObjRelax(o.scip_, o.scip_name_, o.scip_desc_, o.scip_priority_, o.scip_priority_, o.scip_includeslp_) - { - } - - /** move constructor */ - ObjRelax(ObjRelax&& o) - : scip_(o.scip_), - scip_name_(0), - scip_desc_(0), - scip_priority_(o.scip_priority_), - scip_freq_(o.scip_freq_), - scip_includeslp_(o.scip_includeslp_) - { - std::swap(scip_name_, o.scip_name_); - std::swap(scip_desc_, o.scip_desc_); - } - - /** destructor */ - virtual ~ObjRelax() - { - /* the macro SCIPfreeMemoryArray does not need the first argument: */ - /*lint --e{64}*/ - SCIPfreeMemoryArray(scip_, &scip_name_); - SCIPfreeMemoryArray(scip_, &scip_desc_); - } - - /** assignment of polymorphic classes causes slicing and is therefore disabled. */ - ObjRelax& operator=(const ObjRelax& o) = delete; - - /** assignment of polymorphic classes causes slicing and is therefore disabled. */ - ObjRelax& operator=(ObjRelax&& o) = delete; - - /** destructor of relaxator to free user data (called when SCIP is exiting) - * - * @see SCIP_DECL_RELAXFREE(x) in @ref type_relax.h - */ - virtual SCIP_DECL_RELAXFREE(scip_free) - { /*lint --e{715}*/ - return SCIP_OKAY; - } - - /** initialization method of relaxator (called after problem was transformed) - * - * @see SCIP_DECL_RELAXINIT(x) in @ref type_relax.h - */ - virtual SCIP_DECL_RELAXINIT(scip_init) - { /*lint --e{715}*/ - return SCIP_OKAY; - } - - /** deinitialization method of relaxator (called before transformed problem is freed) - * - * @see SCIP_DECL_RELAXEXIT(x) in @ref type_relax.h - */ - virtual SCIP_DECL_RELAXEXIT(scip_exit) - { /*lint --e{715}*/ - return SCIP_OKAY; - } - - /** solving process initialization method of relaxator (called when branch and bound process is about to begin) - * - * @see SCIP_DECL_RELAXINITSOL(x) in @ref type_relax.h - */ - virtual SCIP_DECL_RELAXINITSOL(scip_initsol) - { /*lint --e{715}*/ - return SCIP_OKAY; - } - - /** solving process deinitialization method of relaxator (called before branch and bound process data is freed) - * - * @see SCIP_DECL_RELAXEXITSOL(x) in @ref type_relax.h - */ - virtual SCIP_DECL_RELAXEXITSOL(scip_exitsol) - { /*lint --e{715}*/ - return SCIP_OKAY; - } - - /** execution method of relaxator - * - * @see SCIP_DECL_RELAXEXEC(x) in @ref type_relax.h - */ - virtual SCIP_DECL_RELAXEXEC(scip_exec) = 0; -}; - -} /* namespace scip */ - - - -/** creates the relaxator for the given relaxator object and includes it in SCIP - * - * The method should be called in one of the following ways: - * - * 1. The user is resposible of deleting the object: - * SCIP_CALL( SCIPcreate(&scip) ); - * ... - * MyRelax* myrelax = new MyRelax(...); - * SCIP_CALL( SCIPincludeObjRelax(scip, &myrelax, FALSE) ); - * ... - * SCIP_CALL( SCIPfree(&scip) ); - * delete myrelax; // delete relax AFTER SCIPfree() ! - * - * 2. The object pointer is passed to SCIP and deleted by SCIP in the SCIPfree() call: - * SCIP_CALL( SCIPcreate(&scip) ); - * ... - * SCIP_CALL( SCIPincludeObjRelax(scip, new MyRelax(...), TRUE) ); - * ... - * SCIP_CALL( SCIPfree(&scip) ); // destructor of MyRelax is called here - */ -SCIP_EXPORT -SCIP_RETCODE SCIPincludeObjRelax( - SCIP* scip, /**< SCIP data structure */ - scip::ObjRelax* objrelax, /**< relaxator object */ - SCIP_Bool deleteobject /**< should the relaxator object be deleted when relaxator is freed? */ - ); - -/** returns the relax object of the given name, or 0 if not existing */ -SCIP_EXPORT -scip::ObjRelax* SCIPfindObjRelax( - SCIP* scip, /**< SCIP data structure */ - const char* name /**< name of relaxator */ - ); - -/** returns the relax object for the given relaxator */ -SCIP_EXPORT -scip::ObjRelax* SCIPgetObjRelax( - SCIP* scip, /**< SCIP data structure */ - SCIP_RELAX* relax /**< relaxator */ - ); - -#endif diff --git a/headers/objscip/objscip.h b/headers/objscip/objscip.h deleted file mode 100644 index 8d7a0ec..0000000 --- a/headers/objscip/objscip.h +++ /dev/null @@ -1,57 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* */ -/* This file is part of the program and library */ -/* SCIP --- Solving Constraint Integer Programs */ -/* */ -/* Copyright 2002-2022 Zuse Institute Berlin */ -/* */ -/* Licensed under the Apache License, Version 2.0 (the "License"); */ -/* you may not use this file except in compliance with the License. */ -/* You may obtain a copy of the License at */ -/* */ -/* http://www.apache.org/licenses/LICENSE-2.0 */ -/* */ -/* Unless required by applicable law or agreed to in writing, software */ -/* distributed under the License is distributed on an "AS IS" BASIS, */ -/* 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. */ -/* */ -/* You should have received a copy of the Apache-2.0 license */ -/* along with SCIP; see the file LICENSE. If not visit scipopt.org. */ -/* */ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -/**@file objscip.h - * @brief C++ wrapper classes for SCIP - * @author Tobias Achterberg - */ - -/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/ - -#ifndef __SCIP_OBJSCIP_H__ -#define __SCIP_OBJSCIP_H__ - - -#include "objscip/objbenders.h" -#include "objscip/objbenderscut.h" -#include "objscip/objbranchrule.h" -#include "objscip/objconshdlr.h" -#include "objscip/objcutsel.h" -#include "objscip/objdialog.h" -#include "objscip/objdisp.h" -#include "objscip/objeventhdlr.h" -#include "objscip/objheur.h" -#include "objscip/objmessagehdlr.h" -#include "objscip/objnodesel.h" -#include "objscip/objpresol.h" -#include "objscip/objpricer.h" -#include "objscip/objprobdata.h" -#include "objscip/objprop.h" -#include "objscip/objreader.h" -#include "objscip/objrelax.h" -#include "objscip/objsepa.h" -#include "objscip/objvardata.h" -#include "objscip/objcloneable.h" - -#endif diff --git a/headers/objscip/objscipdefplugins.h b/headers/objscip/objscipdefplugins.h deleted file mode 100644 index 3c1d6f9..0000000 --- a/headers/objscip/objscipdefplugins.h +++ /dev/null @@ -1,39 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* */ -/* This file is part of the program and library */ -/* SCIP --- Solving Constraint Integer Programs */ -/* */ -/* Copyright 2002-2022 Zuse Institute Berlin */ -/* */ -/* Licensed under the Apache License, Version 2.0 (the "License"); */ -/* you may not use this file except in compliance with the License. */ -/* You may obtain a copy of the License at */ -/* */ -/* http://www.apache.org/licenses/LICENSE-2.0 */ -/* */ -/* Unless required by applicable law or agreed to in writing, software */ -/* distributed under the License is distributed on an "AS IS" BASIS, */ -/* 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. */ -/* */ -/* You should have received a copy of the Apache-2.0 license */ -/* along with SCIP; see the file LICENSE. If not visit scipopt.org. */ -/* */ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -/**@file objscipdefplugins.h - * @brief C++ wrapper for default SCIP plugins - * @author Tobias Achterberg - */ - -/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/ - -#ifndef __SCIP_OBJSCIPDEFPLUGINS_H__ -#define __SCIP_OBJSCIPDEFPLUGINS_H__ - - -#include "objscip/objscip.h" -#include "scip/scipdefplugins.h" - -#endif diff --git a/headers/objscip/objsepa.h b/headers/objscip/objsepa.h deleted file mode 100644 index 1069d30..0000000 --- a/headers/objscip/objsepa.h +++ /dev/null @@ -1,259 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* */ -/* This file is part of the program and library */ -/* SCIP --- Solving Constraint Integer Programs */ -/* */ -/* Copyright 2002-2022 Zuse Institute Berlin */ -/* */ -/* Licensed under the Apache License, Version 2.0 (the "License"); */ -/* you may not use this file except in compliance with the License. */ -/* You may obtain a copy of the License at */ -/* */ -/* http://www.apache.org/licenses/LICENSE-2.0 */ -/* */ -/* Unless required by applicable law or agreed to in writing, software */ -/* distributed under the License is distributed on an "AS IS" BASIS, */ -/* 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. */ -/* */ -/* You should have received a copy of the Apache-2.0 license */ -/* along with SCIP; see the file LICENSE. If not visit scipopt.org. */ -/* */ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -/**@file objsepa.h - * @brief C++ wrapper for cut separators - * @author Tobias Achterberg - */ - -/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/ - -#ifndef __SCIP_OBJSEPA_H__ -#define __SCIP_OBJSEPA_H__ - -#include -#include - -#include "scip/scip.h" -#include "objscip/objcloneable.h" - -namespace scip -{ - -/** @brief C++ wrapper for cut separators - * - * This class defines the interface for cut separators implemented in C++. - * - * - \ref SEPA "Instructions for implementing a cut separator" - * - \ref SEPARATORS "List of available cut separators" - * - \ref type_sepa.h "Corresponding C interface" - */ -class ObjSepa : public ObjCloneable -{ -public: - /*lint --e{1540}*/ - - /** SCIP data structure */ - SCIP* scip_; - - /** name of the cut separator */ - char* scip_name_; - - /** description of the cut separator */ - char* scip_desc_; - - /** default priority of the cut separator */ - const int scip_priority_; - - /** frequency for calling separator */ - const int scip_freq_; - - /** maximal relative distance from current node's dual bound to primal bound compared to best node's dual bound for applying - * separation (0.0: only on current best node, 1.0: on all nodes) - */ - const SCIP_Real scip_maxbounddist_; - - /** does the separator use a secondary SCIP instance? */ - const SCIP_Bool scip_usessubscip_; - - /** should separator be delayed, if other separators found cuts? */ - const SCIP_Bool scip_delay_; - - /** default constructor */ - ObjSepa( - SCIP* scip, /**< SCIP data structure */ - const char* name, /**< name of cut separator */ - const char* desc, /**< description of cut separator */ - int priority, /**< priority of the cut separator */ - int freq, /**< frequency for calling separator */ - SCIP_Real maxbounddist, /**< maximal relative distance from current node's dual bound to primal bound compared - * to best node's dual bound for applying separation */ - SCIP_Bool usessubscip, /**< does the separator use a secondary SCIP instance? */ - SCIP_Bool delay /**< should separator be delayed, if other separators found cuts? */ - ) - : scip_(scip), - scip_name_(0), - scip_desc_(0), - scip_priority_(priority), - scip_freq_(freq), - scip_maxbounddist_(maxbounddist), - scip_usessubscip_(usessubscip), - scip_delay_(delay) - { - /* the macro SCIPduplicateMemoryArray does not need the first argument: */ - SCIP_CALL_ABORT( SCIPduplicateMemoryArray(scip_, &scip_name_, name, std::strlen(name)+1) ); - SCIP_CALL_ABORT( SCIPduplicateMemoryArray(scip_, &scip_desc_, desc, std::strlen(desc)+1) ); - } - - /** copy constructor */ - ObjSepa(const ObjSepa& o) - : ObjSepa(o.scip_, o.scip_name_, o.scip_desc_, o.scip_priority_, o.scip_freq_, o.scip_maxbounddist_, - o.scip_usessubscip_, o.scip_delay_) - { - } - - /** move constructor */ - ObjSepa(ObjSepa&& o) - : scip_(o.scip_), - scip_name_(0), - scip_desc_(0), - scip_priority_(o.scip_priority_), - scip_freq_(o.scip_freq_), - scip_maxbounddist_(o.scip_maxbounddist_), - scip_usessubscip_(o.scip_usessubscip_), - scip_delay_(o.scip_delay_) - { - std::swap(scip_name_, o.scip_name_); - std::swap(scip_desc_, o.scip_desc_); - } - - /** destructor */ - virtual ~ObjSepa() - { - /* the macro SCIPfreeMemoryArray does not need the first argument: */ - /*lint --e{64}*/ - SCIPfreeMemoryArray(scip_, &scip_name_); - SCIPfreeMemoryArray(scip_, &scip_desc_); - } - - /** assignment of polymorphic classes causes slicing and is therefore disabled. */ - ObjSepa& operator=(const ObjSepa& o) = delete; - - /** assignment of polymorphic classes causes slicing and is therefore disabled. */ - ObjSepa& operator=(ObjSepa&& o) = delete; - - /** destructor of cut separator to free user data (called when SCIP is exiting) - * - * @see SCIP_DECL_SEPAFREE(x) in @ref type_sepa.h - */ - virtual SCIP_DECL_SEPAFREE(scip_free) - { /*lint --e{715}*/ - return SCIP_OKAY; - } - - /** initialization method of cut separator (called after problem was transformed) - * - * @see SCIP_DECL_SEPAINIT(x) in @ref type_sepa.h - */ - virtual SCIP_DECL_SEPAINIT(scip_init) - { /*lint --e{715}*/ - return SCIP_OKAY; - } - - /** deinitialization method of cut separator (called before transformed problem is freed) - * - * @see SCIP_DECL_SEPAEXIT(x) in @ref type_sepa.h - */ - virtual SCIP_DECL_SEPAEXIT(scip_exit) - { /*lint --e{715}*/ - return SCIP_OKAY; - } - - /** solving process initialization method of separator (called when branch and bound process is about to begin) - * - * @see SCIP_DECL_SEPAINITSOL(x) in @ref type_sepa.h - */ - virtual SCIP_DECL_SEPAINITSOL(scip_initsol) - { /*lint --e{715}*/ - return SCIP_OKAY; - } - - /** solving process deinitialization method of separator (called before branch and bound process data is freed) - * - * @see SCIP_DECL_SEPAEXITSOL(x) in @ref type_sepa.h - */ - virtual SCIP_DECL_SEPAEXITSOL(scip_exitsol) - { /*lint --e{715}*/ - return SCIP_OKAY; - } - - /** LP solution separation method of separator - * - * @see SCIP_DECL_SEPAEXECLP(x) in @ref type_sepa.h - */ - virtual SCIP_DECL_SEPAEXECLP(scip_execlp) - { /*lint --e{715}*/ - assert(result != NULL); - *result = SCIP_DIDNOTRUN; - return SCIP_OKAY; - } - - /** arbitrary primal solution separation method of separator - * - * @see SCIP_DECL_SEPAEXECSOL(x) in @ref type_sepa.h - */ - virtual SCIP_DECL_SEPAEXECSOL(scip_execsol) - { /*lint --e{715}*/ - assert(result != NULL); - *result = SCIP_DIDNOTRUN; - return SCIP_OKAY; - } -}; - -} /* namespace scip */ - - - -/** creates the cut separator for the given cut separator object and includes it in SCIP - * - * The method should be called in one of the following ways: - * - * 1. The user is resposible of deleting the object: - * SCIP_CALL( SCIPcreate(&scip) ); - * ... - * MySepa* mysepa = new MySepa(...); - * SCIP_CALL( SCIPincludeObjSepa(scip, &mysepa, FALSE) ); - * ... - * SCIP_CALL( SCIPfree(&scip) ); - * delete mysepa; // delete sepa AFTER SCIPfree() ! - * - * 2. The object pointer is passed to SCIP and deleted by SCIP in the SCIPfree() call: - * SCIP_CALL( SCIPcreate(&scip) ); - * ... - * SCIP_CALL( SCIPincludeObjSepa(scip, new MySepa(...), TRUE) ); - * ... - * SCIP_CALL( SCIPfree(&scip) ); // destructor of MySepa is called here - */ -SCIP_EXPORT -SCIP_RETCODE SCIPincludeObjSepa( - SCIP* scip, /**< SCIP data structure */ - scip::ObjSepa* objsepa, /**< cut separator object */ - SCIP_Bool deleteobject /**< should the cut separator object be deleted when cut separator is freed? */ - ); - -/** returns the sepa object of the given name, or 0 if not existing */ -SCIP_EXPORT -scip::ObjSepa* SCIPfindObjSepa( - SCIP* scip, /**< SCIP data structure */ - const char* name /**< name of cut separator */ - ); - -/** returns the sepa object for the given cut separator */ -SCIP_EXPORT -scip::ObjSepa* SCIPgetObjSepa( - SCIP* scip, /**< SCIP data structure */ - SCIP_SEPA* sepa /**< cut separator */ - ); - -#endif diff --git a/headers/objscip/objtable.h b/headers/objscip/objtable.h deleted file mode 100644 index 2249a4b..0000000 --- a/headers/objscip/objtable.h +++ /dev/null @@ -1,221 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* */ -/* This file is part of the program and library */ -/* SCIP --- Solving Constraint Integer Programs */ -/* */ -/* Copyright 2002-2022 Zuse Institute Berlin */ -/* */ -/* Licensed under the Apache License, Version 2.0 (the "License"); */ -/* you may not use this file except in compliance with the License. */ -/* You may obtain a copy of the License at */ -/* */ -/* http://www.apache.org/licenses/LICENSE-2.0 */ -/* */ -/* Unless required by applicable law or agreed to in writing, software */ -/* distributed under the License is distributed on an "AS IS" BASIS, */ -/* 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. */ -/* */ -/* You should have received a copy of the Apache-2.0 license */ -/* along with SCIP; see the file LICENSE. If not visit scipopt.org. */ -/* */ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -/**@file objtable.h - * @brief C++ wrapper for statistics tables - * @author Tristan Gally - */ - -/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/ - -#ifndef __SCIP_OBJTABLE_H__ -#define __SCIP_OBJTABLE_H__ - -#include -#include - -#include "scip/scip.h" -#include "objscip/objcloneable.h" -namespace scip -{ - -/** - * @brief C++ wrapper for statistics tables - * - * This class defines the interface for statistics tables implemented in C++. Note that there is a pure virtual function - * (this function has to be implemented). This function is: scip_output(). - * - * - \ref TABLE "Instructions for implementing a statistics table" - * - \ref TABLES "List of available statistics tables" - * - \ref type_table.h "Corresponding C interface" - */ -class ObjTable : public ObjCloneable -{ -public: - /*lint --e{1540}*/ - - /** SCIP data structure */ - SCIP* scip_; - - /** name of the statistics tables */ - char* scip_name_; - - /** description of the statistics table */ - char* scip_desc_; - - /** position of the statistics table */ - const int scip_position_; - - /** output of the statistics table is only printed from this stage onwards */ - SCIP_STAGE scip_earlieststage_; - - /** default constructor */ - ObjTable( - SCIP* scip, /**< SCIP data structure */ - const char* name, /**< name of statistics table */ - const char* desc, /**< description of statistics table */ - int position, /**< position of statistics table */ - SCIP_STAGE earlieststage /**< output of the statistics table is only printed from this stage onwards */ - ) - : scip_(scip), - scip_name_(0), - scip_desc_(0), - scip_position_(position), - scip_earlieststage_(earlieststage) - { - /* the macro SCIPduplicateMemoryArray does not need the first argument: */ - SCIP_CALL_ABORT( SCIPduplicateMemoryArray(scip_, &scip_name_, name, std::strlen(name)+1) ); - SCIP_CALL_ABORT( SCIPduplicateMemoryArray(scip_, &scip_desc_, desc, std::strlen(desc)+1) ); - } - - /** copy constructor */ - ObjTable(const ObjTable& o) : ObjTable(o.scip_, o.scip_name_, o.scip_desc_, o.scip_position_, o.scip_earlieststage_) - { - } - - /** move constructor */ - ObjTable(ObjTable&& o) - : scip_(o.scip_), - scip_name_(0), - scip_desc_(0), - scip_position_(o.scip_position_), - scip_earlieststage_(o.scip_earlieststage_) - { - std::swap(scip_name_, o.scip_name_); - std::swap(scip_desc_, o.scip_desc_); - } - - /** destructor */ - virtual ~ObjTable() - { - /* the macro SCIPfreeMemoryArray does not need the first argument: */ - /*lint --e{64}*/ - SCIPfreeMemoryArray(scip_, &scip_name_); - SCIPfreeMemoryArray(scip_, &scip_desc_); - } - - /** assignment of polymorphic classes causes slicing and is therefore disabled. */ - ObjTable& operator=(const ObjTable& o) = delete; - - /** assignment of polymorphic classes causes slicing and is therefore disabled. */ - ObjTable& operator=(ObjTable&& o) = delete; - - /** destructor of statistics table to free user data (called when SCIP is exiting) - * - * @see SCIP_DECL_TABLEFREE(x) in @ref type_disp.h - */ - virtual SCIP_DECL_TABLEFREE(scip_free) - { /*lint --e{715}*/ - return SCIP_OKAY; - } - - /** initialization method of statistics table (called after problem was transformed) - * - * @see SCIP_DECL_TABLEINIT(x) in @ref type_table.h - */ - virtual SCIP_DECL_TABLEINIT(scip_init) - { /*lint --e{715}*/ - return SCIP_OKAY; - } - - /** deinitialization method of statistics table (called before transformed problem is freed) - * - * @see SCIP_DECL_TABLEEXIT(x) in @ref type_table.h - */ - virtual SCIP_DECL_TABLEEXIT(scip_exit) - { /*lint --e{715}*/ - return SCIP_OKAY; - } - - /** solving process initialization method of statistics table (called when branch and bound process is about to begin) - * - * @see SCIP_DECL_TABLEINITSOL(x) in @ref type_table.h - */ - virtual SCIP_DECL_TABLEINITSOL(scip_initsol) - { /*lint --e{715}*/ - return SCIP_OKAY; - } - - /** solving process deinitialization method of statistics table (called before branch and bound process data is freed) - * - * @see SCIP_DECL_TABLEEXITSOL(x) in @ref type_table.h - */ - virtual SCIP_DECL_TABLEEXITSOL(scip_exitsol) - { /*lint --e{715}*/ - return SCIP_OKAY; - } - - /** output method of statistics table to output file stream 'file' - * - * @see SCIP_DECL_TABLEOUTPUT(x) in @ref type_table.h - */ - virtual SCIP_DECL_TABLEOUTPUT(scip_output) = 0; -}; - -} /* namespace scip */ - - - -/** creates the statistics table for the given statistics table object and includes it in SCIP - * - * The method should be called in one of the following ways: - * - * 1. The user is resposible of deleting the object: - * SCIP_CALL( SCIPcreate(&scip) ); - * ... - * MyTable* mytable = new MyTable(...); - * SCIP_CALL( SCIPincludeObjTable(scip, &mytable, FALSE) ); - * ... - * SCIP_CALL( SCIPfree(&scip) ); - * delete mytable; // delete table AFTER SCIPfree() ! - * - * 2. The object pointer is passed to SCIP and deleted by SCIP in the SCIPfree() call: - * SCIP_CALL( SCIPcreate(&scip) ); - * ... - * SCIP_CALL( SCIPincludeObjTable(scip, new MyTable(...), TRUE) ); - * ... - * SCIP_CALL( SCIPfree(&scip) ); // destructor of MyTable is called here - */ -SCIP_EXPORT -SCIP_RETCODE SCIPincludeObjTable( - SCIP* scip, /**< SCIP data structure */ - scip::ObjTable* objtable, /**< statistics table object */ - SCIP_Bool deleteobject /**< should the statistics table object be deleted when statistics table is freed? */ - ); - -/** returns the statistics table object of the given name, or 0 if not existing */ -SCIP_EXPORT -scip::ObjTable* SCIPfindObjTable( - SCIP* scip, /**< SCIP data structure */ - const char* name /**< name of statistics table */ - ); - -/** returns the statistics table object for the given statistics table */ -SCIP_EXPORT -scip::ObjTable* SCIPgetObjTable( - SCIP* scip, /**< SCIP data structure */ - SCIP_TABLE* table /**< statistics table */ - ); - -#endif diff --git a/headers/objscip/objvardata.h b/headers/objscip/objvardata.h deleted file mode 100644 index e84670a..0000000 --- a/headers/objscip/objvardata.h +++ /dev/null @@ -1,201 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* */ -/* This file is part of the program and library */ -/* SCIP --- Solving Constraint Integer Programs */ -/* */ -/* Copyright 2002-2022 Zuse Institute Berlin */ -/* */ -/* Licensed under the Apache License, Version 2.0 (the "License"); */ -/* you may not use this file except in compliance with the License. */ -/* You may obtain a copy of the License at */ -/* */ -/* http://www.apache.org/licenses/LICENSE-2.0 */ -/* */ -/* Unless required by applicable law or agreed to in writing, software */ -/* distributed under the License is distributed on an "AS IS" BASIS, */ -/* 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. */ -/* */ -/* You should have received a copy of the Apache-2.0 license */ -/* along with SCIP; see the file LICENSE. If not visit scipopt.org. */ -/* */ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -/**@file objvardata.h - * @brief C++ wrapper for user variable data - * @author Tobias Achterberg - */ - -/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/ - -#ifndef __SCIP_OBJVARDATA_H__ -#define __SCIP_OBJVARDATA_H__ - - -#include - -#include "scip/scip.h" -#include "objscip/objcloneable.h" - -namespace scip -{ - -/** @brief C++ wrapper for user variable data - * - * This class defines the interface for user variable data implemented in C++. Each variable can be equipped with a - * variable data class. This data can be accessed via the function SCIPgetObjVardata() at any time after it is created - * and before it is deleted. - * - * - \ref type_var.h "Corresponding C interface" - */ -class ObjVardata -{ -public: - /** default constructor */ - ObjVardata() - { - } - - /** destructor */ - virtual ~ObjVardata() - { - } - - /** assignment of polymorphic classes causes slicing and is therefore disabled. */ - ObjVardata& operator=(const ObjVardata& o) = delete; - - /** assignment of polymorphic classes causes slicing and is therefore disabled. */ - ObjVardata& operator=(ObjVardata&& o) = delete; - - /** destructor of user variable data to free original user data (called when original variable is freed) - * - * If the "deleteobject" flag in the SCIPcreateObjVar() method was set to TRUE, this method is not needed, - * because all the work to delete the user variable data can be done in the destructor of the user variable - * data object. If the "deleteobject" flag was set to FALSE, and the user variable data object stays alive - * after the SCIP variable is freed, this method should delete all the variable specific data that is no - * longer needed. - */ /*lint -e715*/ - virtual SCIP_RETCODE scip_delorig( - SCIP* scip, /**< SCIP data structure */ - SCIP_VAR* var /**< original variable, the data to free is belonging to */ - ) - { /*lint --e{715}*/ - return SCIP_OKAY; - } - - /** creates user data of transformed variable by transforming the original user variable data - * (called after variable was transformed) - * - * The user has two possibilities to implement this method: - * 1. Return the pointer to the original variable data object (this) as pointer to the transformed variable data - * object. The user may modify some internal attributes, but he has to make sure, that these modifications are - * reversed in the scip_deltrans() method, such that the original variable data is restored. In this case, - * he should set *deleteobject to FALSE, because the variable data must not be destructed by SCIP after the - * solving process is terminated. - * 2. Call the copy constructor of the variable data object and return the created copy as transformed variable - * data object. In this case, he probably wants to set *deleteobject to TRUE, thus letting SCIP call the - * destructor of the object if the transformed variable data is no longer needed. - */ /*lint -e715*/ - virtual SCIP_RETCODE scip_trans( - SCIP* scip, /**< SCIP data structure */ - SCIP_VAR* var, /**< transformed variable, the data to create is belonging to */ - ObjVardata** objvardata, /**< pointer to store the transformed variable data object */ - SCIP_Bool* deleteobject /**< pointer to store whether SCIP should delete the object after solving */ - ) - { /*lint --e{715}*/ - assert(objvardata != NULL); - assert(deleteobject != NULL); - - /* the default implementation just copies the pointer to the variable data object; - * SCIP must not destruct the transformed variable data object, because the original variable data must stay alive - */ - *objvardata = this; - *deleteobject = FALSE; - - return SCIP_OKAY; - } - - /** destructor of user variable data to free transformed user data (called when transformed variable is freed) - * - * If the "*deleteobject" flag in the scip_trans() method was set to TRUE, this method is not needed, - * because all the work to delete the user variable data can be done in the destructor of the user variable - * data object. If the "*deleteobject" flag was set to FALSE, and the user variable data object stays alive - * after the SCIP variable is freed, this method should delete all the variable specific data that is no - * longer needed. - */ /*lint -e715*/ - virtual SCIP_RETCODE scip_deltrans( - SCIP* scip, /**< SCIP data structure */ - SCIP_VAR* var /**< transformed variable, the data to free is belonging to */ - ) - { /*lint --e{715}*/ - return SCIP_OKAY; - } - - /** copies variable data of source SCIP variable for the target SCIP variable - * - * This method should copy the variable data of the source SCIP and create a target variable data for target - * variable. This callback is optional. If the copying process was successful, the target variable gets this variable - * data assigned. In case the result pointer is set to SCIP_DIDNOTRUN, the target variable will have no variable data at - * all. - * - * The variable map and the constraint map can be used via the function SCIPgetVarCopy() and SCIPgetConsCopy(), - * respectively, to get for certain variables and constraints of the source SCIP the counter parts in the target - * SCIP. You should be very carefully in using these two methods since they could lead to infinite loop. - * - * possible return values for *result: - * - SCIP_DIDNOTRUN : the copying process was not performed - * - SCIP_SUCCESS : the copying process was successfully performed - */ /*lint -e715*/ - virtual SCIP_RETCODE scip_copy( - SCIP* scip, /**< SCIP data structure */ - SCIP* sourcescip, /**< source SCIP main data structure */ - SCIP_VAR* sourcevar, /**< variable of the source SCIP */ - SCIP_HASHMAP* varmap, /**< a hashmap which stores the mapping of source variables to corresponding - * target variables */ - SCIP_HASHMAP* consmap, /**< a hashmap which stores the mapping of source contraints to corresponding - * target constraints */ - SCIP_VAR* targetvar, /**< variable of the (targert) SCIP (targetvar is the copy of sourcevar) */ - ObjVardata** objvardata, /**< pointer to store the copied variable data object */ - SCIP_RESULT* result /**< pointer to store the result of the call */ - ) - { /*lint --e{715}*/ - (*objvardata) = 0; - (*result) = SCIP_DIDNOTRUN; - return SCIP_OKAY; - } -}; - -} /* namespace scip */ - - - -/** create and capture problem variable and associates the given variable data with the variable; - * if variable is of integral type, fractional bounds are automatically rounded - */ -SCIP_EXPORT -SCIP_RETCODE SCIPcreateObjVar( - SCIP* scip, /**< SCIP data structure */ - SCIP_VAR** var, /**< pointer to variable object */ - const char* name, /**< name of variable, or NULL for automatic name creation */ - SCIP_Real lb, /**< lower bound of variable */ - SCIP_Real ub, /**< upper bound of variable */ - SCIP_Real obj, /**< objective function value */ - SCIP_VARTYPE vartype, /**< type of variable */ - SCIP_Bool initial, /**< should var's column be present in the initial root LP? */ - SCIP_Bool removable, /**< is var's column removable from the LP (due to aging or cleanup)? */ - scip::ObjVardata* objvardata, /**< user variable data object */ - SCIP_Bool deleteobject /**< should the user variable data object be deleted when variable is freed? */ - ); - -/** gets user variable data object for given problem variable - * Warning! This method should only be called after a variable was created with SCIPcreateObjVar(). - * Otherwise, a segmentation fault may arise, or an undefined pointer is returned. - */ -SCIP_EXPORT -scip::ObjVardata* SCIPgetObjVardata( - SCIP* scip, /**< SCIP data structure */ - SCIP_VAR* var /**< problem variable */ - ); - -#endif diff --git a/headers/objscip/type_objcloneable.h b/headers/objscip/type_objcloneable.h deleted file mode 100644 index 688833d..0000000 --- a/headers/objscip/type_objcloneable.h +++ /dev/null @@ -1,74 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* */ -/* This file is part of the program and library */ -/* SCIP --- Solving Constraint Integer Programs */ -/* */ -/* Copyright 2002-2022 Zuse Institute Berlin */ -/* */ -/* Licensed under the Apache License, Version 2.0 (the "License"); */ -/* you may not use this file except in compliance with the License. */ -/* You may obtain a copy of the License at */ -/* */ -/* http://www.apache.org/licenses/LICENSE-2.0 */ -/* */ -/* Unless required by applicable law or agreed to in writing, software */ -/* distributed under the License is distributed on an "AS IS" BASIS, */ -/* 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. */ -/* */ -/* You should have received a copy of the Apache-2.0 license */ -/* along with SCIP; see the file LICENSE. If not visit scipopt.org. */ -/* */ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -/**@file type_objcloneable.h - * @ingroup TYPEDEFINITIONS - * @brief function type definitions for clonable classes - * @author Marc Pfetsch - */ - -/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/ - -#ifndef __SCIP_TYPE_OBJPCLONEABLE_H__ -#define __SCIP_TYPE_OBJPCLONEABLE_H__ - -/** clone method, used to copy plugins which are not constraint handlers or variable pricer plugins - * - * input: - * - scip : SCIP main data structure - */ -#define SCIP_DECL_OBJCLONEABLECLONE(x) x (SCIP* scip) const -#define SCIP_DECL_BENDERSCUTCLONE(x) x (SCIP* scip) const -#define SCIP_DECL_BRANCHCLONE(x) x (SCIP* scip) const -#define SCIP_DECL_DIALOGCLONE(x) x (SCIP* scip) const -#define SCIP_DECL_DISPCLONE(x) x (SCIP* scip) const -#define SCIP_DECL_EVENTCLONE(x) x (SCIP* scip) const -#define SCIP_DECL_HEURCLONE(x) x (SCIP* scip) const -#define SCIP_DECL_NODESELCLONE(x) x (SCIP* scip) const -#define SCIP_DECL_PRESOLCLONE(x) x (SCIP* scip) const -#define SCIP_DECL_PROPCLONE(x) x (SCIP* scip) const -#define SCIP_DECL_READERCLONE(x) x (SCIP* scip) const -#define SCIP_DECL_RELAXCLONE(x) x (SCIP* scip) const -#define SCIP_DECL_SEPACLONE(x) x (SCIP* scip) const - - -/** returns whether the plugin object is copyable - * - * return value : whether object is copyable - */ -#define SCIP_DECL_OBJCLONEABLEISCLONEABLE(x) SCIP_Bool x (void) const -#define SCIP_DECL_BENDERSCUTISCLONEABLE(x) SCIP_Bool x (void) const -#define SCIP_DECL_BRANCHISCLONEABLE(x) SCIP_Bool x (void) const -#define SCIP_DECL_DIALOGISCLONEABLE(x) SCIP_Bool x (void) const -#define SCIP_DECL_DISPISCLONEABLE(x) SCIP_Bool x (void) const -#define SCIP_DECL_EVENTISCLONEABLE(x) SCIP_Bool x (void) const -#define SCIP_DECL_HEURISCLONEABLE(x) SCIP_Bool x (void) const -#define SCIP_DECL_NODESELISCLONEABLE(x) SCIP_Bool x (void) const -#define SCIP_DECL_PRESOLISCLONEABLE(x) SCIP_Bool x (void) const -#define SCIP_DECL_PROPISCLONEABLE(x) SCIP_Bool x (void) const -#define SCIP_DECL_READERISCLONEABLE(x) SCIP_Bool x (void) const -#define SCIP_DECL_RELAXISCLONEABLE(x) SCIP_Bool x (void) const -#define SCIP_DECL_SEPAISCLONEABLE(x) SCIP_Bool x (void) const - -#endif diff --git a/headers/objscip/type_objprobcloneable.h b/headers/objscip/type_objprobcloneable.h deleted file mode 100644 index 50f474b..0000000 --- a/headers/objscip/type_objprobcloneable.h +++ /dev/null @@ -1,58 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* */ -/* This file is part of the program and library */ -/* SCIP --- Solving Constraint Integer Programs */ -/* */ -/* Copyright 2002-2022 Zuse Institute Berlin */ -/* */ -/* Licensed under the Apache License, Version 2.0 (the "License"); */ -/* you may not use this file except in compliance with the License. */ -/* You may obtain a copy of the License at */ -/* */ -/* http://www.apache.org/licenses/LICENSE-2.0 */ -/* */ -/* Unless required by applicable law or agreed to in writing, software */ -/* distributed under the License is distributed on an "AS IS" BASIS, */ -/* 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. */ -/* */ -/* You should have received a copy of the Apache-2.0 license */ -/* along with SCIP; see the file LICENSE. If not visit scipopt.org. */ -/* */ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -/**@file type_objprobcloneable.h - * @ingroup TYPEDEFINITIONS - * @brief function type definitions for clonable classes which define problem data - * @author Marc Pfetsch - */ - -/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/ - -#ifndef __SCIP_TYPE_OBJPROBCLONEABLE_H__ -#define __SCIP_TYPE_OBJPROBCLONEABLE_H__ - -/** clone method which will be used to copy constraint handler and variable pricer objects - * - * input: - * - scip : SCIP main data structure - * - * output: - * - valid : pointer to store whether to copy is valid w.r.t. copying dual reductions - */ -#define SCIP_DECL_OBJPROBCLONE(x) x (SCIP* scip, SCIP_Bool* valid) const -#define SCIP_DECL_CONSHDLRCLONE(x) x (SCIP* scip, SCIP_Bool* valid) const -#define SCIP_DECL_PRICERCLONE(x) x (SCIP* scip, SCIP_Bool* valid) const -#define SCIP_DECL_BENDERSCLONE(x) x (SCIP* scip, SCIP_Bool* valid) const - -/** returns whether the plugin object is copyable - * - * return value : whether object is copyable - */ -#define SCIP_DECL_OBJPROBISCLONEABLE(x) SCIP_Bool x (void) const -#define SCIP_DECL_CONSHDLRISCLONEABLE(x) SCIP_Bool x (void) const -#define SCIP_DECL_PRICERISCLONEABLE(x) SCIP_Bool x (void) const -#define SCIP_DECL_BENDERSISCLONEABLE(x) SCIP_Bool x (void) const - -#endif diff --git a/headers/papilo/CMakeConfig.hpp b/headers/papilo/CMakeConfig.hpp deleted file mode 100644 index b612353..0000000 --- a/headers/papilo/CMakeConfig.hpp +++ /dev/null @@ -1,50 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* */ -/* This file is part of the program and library */ -/* PaPILO --- Parallel Presolve for Integer and Linear Optimization */ -/* */ -/* Copyright (C) 2020-2022 Konrad-Zuse-Zentrum */ -/* fuer Informationstechnik Berlin */ -/* */ -/* This program is free software: you can redistribute it and/or modify */ -/* it under the terms of the GNU Lesser General Public License as published */ -/* by the Free Software Foundation, either version 3 of the License, or */ -/* (at your option) any later version. */ -/* */ -/* This program is distributed in the hope that it will be useful, */ -/* but WITHOUT ANY WARRANTY; without even the implied warranty of */ -/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ -/* GNU Lesser General Public License for more details. */ -/* */ -/* You should have received a copy of the GNU Lesser General Public License */ -/* along with this program. If not, see . */ -/* */ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -#ifndef _PAPILO_CMAKE_CONFIG_HPP_ -#define _PAPILO_CMAKE_CONFIG_HPP_ - -/* #undef PAPILO_HAVE_FLOAT128 */ -#define PAPILO_HAVE_GMP -/* #undef PAPILO_HAVE_LUSOL */ -/* #undef PAPILO_USE_STANDARD_HASHMAP */ -/* #undef PAPILO_USE_BOOST_IOSTREAMS_WITH_ZLIB */ -/* #undef PAPILO_USE_BOOST_IOSTREAMS_WITH_BZIP2 */ -#define PAPILO_GITHASH_AVAILABLE -#define BOOST_FOUND -#define PAPILO_TBB - -#define PAPILO_VERSION_MAJOR 2 -#define PAPILO_VERSION_MINOR 1 -#define PAPILO_VERSION_PATCH 2 -#define PAPILO_VERSION_TWEAK 0 - -#ifdef PAPILO_HAVE_GMP - #define GMP_VERSION "6.2.0" -#endif - -#ifdef PAPILO_GITHASH_AVAILABLE - #define PAPILO_GITHASH "2fe2543" -#endif - -#endif diff --git a/headers/papilo/Config.hpp b/headers/papilo/Config.hpp deleted file mode 100644 index 5014f15..0000000 --- a/headers/papilo/Config.hpp +++ /dev/null @@ -1,43 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* */ -/* This file is part of the program and library */ -/* PaPILO --- Parallel Presolve for Integer and Linear Optimization */ -/* */ -/* Copyright (C) 2020-2022 Konrad-Zuse-Zentrum */ -/* fuer Informationstechnik Berlin */ -/* */ -/* This program is free software: you can redistribute it and/or modify */ -/* it under the terms of the GNU Lesser General Public License as published */ -/* by the Free Software Foundation, either version 3 of the License, or */ -/* (at your option) any later version. */ -/* */ -/* This program is distributed in the hope that it will be useful, */ -/* but WITHOUT ANY WARRANTY; without even the implied warranty of */ -/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ -/* GNU Lesser General Public License for more details. */ -/* */ -/* You should have received a copy of the GNU Lesser General Public License */ -/* along with this program. If not, see . */ -/* */ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -#ifndef _PAPILO_CONFIG_HPP_ -#define _PAPILO_CONFIG_HPP_ - -#ifndef PAPILO_NO_CMAKE_CONFIG - -#include "papilo/CMakeConfig.hpp" - -#else - -#define PAPILO_VERSION_MAJOR 2 -#define PAPILO_VERSION_MINOR 1 -#define PAPILO_VERSION_PATCH 2 -#define PAPILO_VERSION_TWEAK 0 - -#define PAPILO_GITHASH_AVAILABLE -#define PAPILO_GITHASH "2fe2543" - -#endif - -#endif diff --git a/headers/papilo/core/Components.hpp b/headers/papilo/core/Components.hpp deleted file mode 100644 index 738b436..0000000 --- a/headers/papilo/core/Components.hpp +++ /dev/null @@ -1,265 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* */ -/* This file is part of the program and library */ -/* PaPILO --- Parallel Presolve for Integer and Linear Optimization */ -/* */ -/* Copyright (C) 2020-2022 Konrad-Zuse-Zentrum */ -/* fuer Informationstechnik Berlin */ -/* */ -/* This program is free software: you can redistribute it and/or modify */ -/* it under the terms of the GNU Lesser General Public License as published */ -/* by the Free Software Foundation, either version 3 of the License, or */ -/* (at your option) any later version. */ -/* */ -/* This program is distributed in the hope that it will be useful, */ -/* but WITHOUT ANY WARRANTY; without even the implied warranty of */ -/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ -/* GNU Lesser General Public License for more details. */ -/* */ -/* You should have received a copy of the GNU Lesser General Public License */ -/* along with this program. If not, see . */ -/* */ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -#ifndef _PAPILO_CORE_COMPONENTS_HPP_ -#define _PAPILO_CORE_COMPONENTS_HPP_ - -#include "papilo/core/Problem.hpp" -#include "papilo/misc/Hash.hpp" -#include "papilo/misc/Vec.hpp" -#include "papilo/external/pdqsort/pdqsort.h" -#include - -namespace papilo -{ - -struct ComponentInfo -{ - int componentid; - int nintegral; - int ncontinuous; - int nnonz; - - bool - operator<( const ComponentInfo& other ) const - { - return std::make_tuple( nintegral, nnonz, ncontinuous, componentid ) < - std::make_tuple( other.nintegral, other.nnonz, other.ncontinuous, - other.componentid ); - } -}; - -class Components -{ - private: - Vec col2comp; - Vec row2comp; - Vec compcols; - Vec comprows; - Vec compcolstart; - Vec comprowstart; - Vec compInfo; - - public: - const int* - getComponentsRows( int c ) const - { - return &comprows[comprowstart[c]]; - } - - int - getComponentsNumRows( int c ) const - { - return comprowstart[c + 1] - comprowstart[c]; - } - - int - getRowComponentIdx( int row ) const - { - return row2comp[row]; - } - - const int* - getComponentsCols( int c ) const - { - return &compcols[compcolstart[c]]; - } - - int - getComponentsNumCols( int c ) const - { - return compcolstart[c + 1] - compcolstart[c]; - } - - int - getColComponentIdx( int col ) const - { - return col2comp[col]; - } - - const Vec& - getComponentInfo() const - { - return compInfo; - } - - template - int - detectComponents( const Problem& problem ) - { - const int ncols = problem.getNCols(); - std::unique_ptr rank{ new int[ncols] }; - std::unique_ptr parent{ new int[ncols] }; - boost::disjoint_sets djsets( rank.get(), parent.get() ); - - for( int i = 0; i != ncols; ++i ) - djsets.make_set( i ); - - const ConstraintMatrix& consMatrix = problem.getConstraintMatrix(); - const IndexRange* ranges; - int nrows; - - std::tie( ranges, nrows ) = consMatrix.getRangeInfo(); - const int* colinds = consMatrix.getColumns(); - - for( int r = 0; r != nrows; ++r ) - { - if( ranges[r].end - ranges[r].start <= 1 ) - continue; - - int firstcol = colinds[ranges[r].start]; - - for( int i = ranges[r].start + 1; i != ranges[r].end; ++i ) - djsets.link( firstcol, colinds[i] ); - } - - HashMap componentmap; - - for( int i = 0; i != ncols; ++i ) - { - int nextid = static_cast( componentmap.size() ); - componentmap.insert( { djsets.find_set( i ), nextid } ); - } - - int numcomponents = static_cast( componentmap.size() ); - - if( numcomponents > 1 ) - { - col2comp.resize( ncols ); - compcols.resize( ncols ); - - for( int i = 0; i != ncols; ++i ) - { - col2comp[i] = componentmap[djsets.find_set( i )]; - compcols[i] = i; - } - - row2comp.resize( nrows ); - comprows.resize( nrows ); - for( int i = 0; i != nrows; ++i ) - { - assert( problem.getConstraintMatrix() - .getRowCoefficients( i ) - .getLength() > 0 ); - int col = problem.getConstraintMatrix() - .getRowCoefficients( i ) - .getIndices()[0]; - row2comp[i] = col2comp[col]; - comprows[i] = i; - } - - pdqsort( compcols.begin(), compcols.end(), [&]( int col1, int col2 ) { - return col2comp[col1] < col2comp[col2]; - } ); - - compcolstart.resize( numcomponents + 1 ); - int k = 0; - - // first component starts at 0 - compcolstart[0] = 0; - - // fill out starts for second to last components, also reuse the - // col2comp vector to map the columns of a component to indices - // starting at 0 without gaps - for( int i = 1; i != numcomponents; ++i ) - { - while( k != ncols && col2comp[compcols[k]] == i - 1 ) - { - col2comp[compcols[k]] = k - compcolstart[i - 1]; - ++k; - } - - compcolstart[i] = k; - } - - while( k != ncols ) - { - assert( col2comp[compcols[k]] == numcomponents - 1 ); - col2comp[compcols[k]] = k - compcolstart[numcomponents - 1]; - ++k; - } - - // last component ends at ncols - compcolstart[numcomponents] = ncols; - - pdqsort( comprows.begin(), comprows.end(), [&]( int row1, int row2 ) { - return row2comp[row1] < row2comp[row2]; - } ); - - comprowstart.resize( numcomponents + 1 ); - k = 0; - // first component starts at 0 - comprowstart[0] = 0; - - // fill out starts for second to last components, also reuse the - // row2comp vector to map the rows of a component to indices starting - // at 0 without gaps - for( int i = 1; i != numcomponents; ++i ) - { - while( k != nrows && row2comp[comprows[k]] == i - 1 ) - { - row2comp[comprows[k]] = k - comprowstart[i - 1]; - ++k; - } - - comprowstart[i] = k; - } - - while( k != nrows ) - { - assert( row2comp[comprows[k]] == numcomponents - 1 ); - row2comp[comprows[k]] = k - comprowstart[numcomponents - 1]; - ++k; - } - // last component ends at nrows - comprowstart[numcomponents] = nrows; - - // compute size informaton of components - compInfo.resize( numcomponents ); - const auto& colsizes = problem.getColSizes(); - const auto& cflags = problem.getColFlags(); - - for( int i = 0; i != numcomponents; ++i ) - { - for( int j = compcolstart[i]; j != compcolstart[i + 1]; ++j ) - { - if( cflags[compcols[j]].test( ColFlag::kIntegral ) ) - ++compInfo[i].nintegral; - else - ++compInfo[i].ncontinuous; - - compInfo[i].nnonz += colsizes[compcols[j]]; - compInfo[i].componentid = i; - } - } - - pdqsort( compInfo.begin(), compInfo.end() ); - } - - return numcomponents; - } -}; - -} // namespace papilo - -#endif diff --git a/headers/papilo/core/ConstraintMatrix.hpp b/headers/papilo/core/ConstraintMatrix.hpp deleted file mode 100644 index b4e7acf..0000000 --- a/headers/papilo/core/ConstraintMatrix.hpp +++ /dev/null @@ -1,1501 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* */ -/* This file is part of the program and library */ -/* PaPILO --- Parallel Presolve for Integer and Linear Optimization */ -/* */ -/* Copyright (C) 2020-2022 Konrad-Zuse-Zentrum */ -/* fuer Informationstechnik Berlin */ -/* */ -/* This program is free software: you can redistribute it and/or modify */ -/* it under the terms of the GNU Lesser General Public License as published */ -/* by the Free Software Foundation, either version 3 of the License, or */ -/* (at your option) any later version. */ -/* */ -/* This program is distributed in the hope that it will be useful, */ -/* but WITHOUT ANY WARRANTY; without even the implied warranty of */ -/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ -/* GNU Lesser General Public License for more details. */ -/* */ -/* You should have received a copy of the GNU Lesser General Public License */ -/* along with this program. If not, see . */ -/* */ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -#ifndef _PAPILO_CORE_CONSTRAINT_MATRIX_HPP_ -#define _PAPILO_CORE_CONSTRAINT_MATRIX_HPP_ - -#define UNUSED(expr) do { (void)(expr); } while (0) - - -#include "papilo/core/MatrixBuffer.hpp" -#include "papilo/core/Objective.hpp" -#include "papilo/core/PresolveMethod.hpp" -#include "papilo/core/RowFlags.hpp" -#include "papilo/core/SingleRow.hpp" -#include "papilo/core/SparseStorage.hpp" -#include "papilo/core/VariableDomains.hpp" -#include "papilo/misc/MultiPrecision.hpp" -#include "papilo/misc/Num.hpp" -#include "papilo/misc/Vec.hpp" -#include "papilo/misc/compress_vector.hpp" -#include "papilo/misc/fmt.hpp" -#ifdef PAPILO_TBB -#include "papilo/misc/tbb.hpp" -#endif -#include - -namespace papilo -{ - -/// non-owning type representing a sparse vector -template -class SparseVectorView -{ - public: - SparseVectorView() : vals( nullptr ), indices( nullptr ), len( 0 ) {} - - SparseVectorView( const REAL* _vals, const int* _inds, int _len ) - : vals( _vals ), indices( _inds ), len( _len ) - { - } - - const REAL* - getValues() const - { - return vals; - } - - const int* - getIndices() const - { - return indices; - } - - int - getLength() const - { - return len; - } - - REAL - getMaxAbsValue() const - { - REAL maxabsval = 0.0; - - for( int i = 0; i != len; ++i ) - maxabsval = std::max( REAL( abs( vals[i] ) ), maxabsval ); - - return maxabsval; - } - - std::pair - getMinMaxAbsValue() const - { - if( len != 0 ) - { - REAL maxabsval = abs( vals[0] ); - REAL minabsval = maxabsval; - - for( int i = 1; i != len; ++i ) - { - maxabsval = std::max( REAL( abs( vals[i] ) ), maxabsval ); - minabsval = std::min( REAL( abs( vals[i] ) ), minabsval ); - } - - return std::make_pair( minabsval, maxabsval ); - } - - return std::make_pair( 0, 0 ); - } - - REAL - getDynamism() const - { - if( len != 0 ) - { - REAL maxabsval = abs( vals[0] ); - REAL minabsval = maxabsval; - - for( int i = 1; i != len; ++i ) - { - maxabsval = Num::max( abs( vals[i] ), maxabsval ); - minabsval = Num::min( abs( vals[i] ), minabsval ); - } - - return maxabsval / minabsval; - } - - return 0; - } - - private: - const REAL* vals; - const int* indices; - int len; -}; - -/// type representing the constraint matrix including the left and right hand -/// sides -template -class ConstraintMatrix -{ - public: - ConstraintMatrix() = default; - - /// construct the constraint matrix from the given values - ConstraintMatrix( SparseStorage cons_matrix_init, - SparseStorage cons_matrix_transp_init, - Vec lhs_values_init, Vec rhs_values_init, - Vec row_flags_init ) - : cons_matrix( std::move( cons_matrix_init ) ), - cons_matrix_transp( std::move( cons_matrix_transp_init ) ), - lhs_values( std::move( lhs_values_init ) ), - rhs_values( std::move( rhs_values_init ) ), - flags( std::move( row_flags_init ) ) - { - rowsize.reserve( cons_matrix.getNRows() ); - colsize.reserve( cons_matrix.getNCols() ); - - auto rowranges = cons_matrix.getRowRanges(); - - assert( (int) flags.size() == cons_matrix.getNRows() ); - - for( int i = 0; i < cons_matrix.getNRows(); ++i ) - rowsize.push_back( rowranges[i].end - rowranges[i].start ); - - auto colranges = cons_matrix_transp.getRowRanges(); - - for( int i = 0; i < cons_matrix.getNCols(); ++i ) - colsize.push_back( colranges[i].end - colranges[i].start ); - } - - /// returns number of rows in the constraint matrix - int - getNRows() const - { - return cons_matrix.getNRows(); - } - - /// returns number of columns in the constraint matrix - int - getNCols() const - { - return cons_matrix.getNCols(); - } - - /// returns number of non-zeros in the constraint matrix - int - getNnz() const - { - assert( cons_matrix.getNnz() == cons_matrix_transp.getNnz() ); - return cons_matrix.getNnz(); - } - - - std::pair - getRangeInfo() const - { - return std::make_pair( cons_matrix.getRowRanges(), - cons_matrix.getNRows() ); - } - - const int* - getColumns() const - { - return cons_matrix.getColumns(); - } - - /// returns a sparse vector view on the row coefficients and their column - /// indices - SparseVectorView - getRowCoefficients( int r ) const - { - assert( r >= 0 && r < getNRows() ); - - auto index_range = cons_matrix.getRowRanges()[r]; - - return SparseVectorView{ - cons_matrix.getValues() + index_range.start, - cons_matrix.getColumns() + index_range.start, - index_range.end - index_range.start }; - } - - /// returns a sparse vector view on the column coefficients and their row - /// indices - SparseVectorView - getColumnCoefficients( int c ) const - { - assert( c >= 0 && c < getNCols() ); - - auto index_range = cons_matrix_transp.getRowRanges()[c]; - - return SparseVectorView{ - cons_matrix_transp.getValues() + index_range.start, - cons_matrix_transp.getColumns() + index_range.start, - index_range.end - index_range.start }; - } - - /// returns maximal change of constraint feasibility for the given change of - /// value in the given column - REAL - getMaxFeasChange( int col, const REAL& val ) const - { - return abs( val * getColumnCoefficients( col ).getMaxAbsValue() ); - } - - /// returns dense vector with left hand side values of each row - Vec& - getLeftHandSides() - { - return lhs_values; - } - - /// returns dense vector with right hand side values of each row - Vec& - getRightHandSides() - { - return rhs_values; - } - - /// returns dense vector with left hand side values of each row - const Vec& - getLeftHandSides() const - { - return lhs_values; - } - - /// returns dense vector with right hand side values of each row - const Vec& - getRightHandSides() const - { - return rhs_values; - } - - const Vec& - getRowFlags() const - { - return flags; - } - - Vec& - getRowFlags() - { - return flags; - } - - /// modify the value of an element from the left hand side - template - void - modifyLeftHandSide( const int index, const Num& num, - const REAL& value = 0) - { - assert( index >= 0 ); - assert( index < getNRows() ); - if( !infval ) - { - flags[index].unset( RowFlag::kLhsInf ); - - if( num.isEq( value, rhs_values[index] ) ) - lhs_values[index] = rhs_values[index]; - else - lhs_values[index] = value; - - if( !flags[index].test( RowFlag::kRhsInf ) && - lhs_values[index] == rhs_values[index] ) - flags[index].set( RowFlag::kEquation ); - else - flags[index].unset( RowFlag::kEquation ); - } - else - { - flags[index].unset( RowFlag::kEquation ); - flags[index].set( RowFlag::kLhsInf ); - } - } - - /// modify the value of an element from the right hand side - template - void - modifyRightHandSide( const int index, const Num& num, - const REAL& value = 0) - { - assert( index >= 0 ); - assert( index < getNRows() ); - if( !infval ) - { - flags[index].unset( RowFlag::kRhsInf ); - if( num.isEq( value, lhs_values[index] ) ) - rhs_values[index] = lhs_values[index]; - else - rhs_values[index] = value; - - if( !flags[index].test( RowFlag::kLhsInf ) && - lhs_values[index] == rhs_values[index] ) - flags[index].set( RowFlag::kEquation ); - else - flags[index].unset( RowFlag::kEquation ); - } - else - { - flags[index].unset( RowFlag::kEquation ); - flags[index].set( RowFlag::kRhsInf ); - } - } - - /// is given row redundant - bool - isRowRedundant( const int row ) const - { - return flags[row].test( RowFlag::kRedundant ); - } - - /// Compress the storage and the indices by removing empty rows and columns - /// from the system. Returns a pair of vectors that store for each index used - /// previously the new index or -1 if the corresponding row/column has been - /// removed. - /// The first vector of the pair stores the mapping for the rows, the second - /// vector stores the mapping of the columns. - std::pair, Vec> - compress( bool full = false ); - - void - deleteRowsAndCols( Vec& deletedRows, Vec& deletedCols, - Vec>& activities, - Vec& singletonRows, Vec& singletonCols, - Vec& emptyCols ); - - const Vec& - getRowSizes() const - { - return rowsize; - } - - Vec& - getRowSizes() - { - return rowsize; - } - - const Vec& - getColSizes() const - { - return colsize; - } - - Vec& - getColSizes() - { - return colsize; - } - - template - void - changeCoefficients( const MatrixBuffer& matrixBuffer, - Vec& singletonRows, Vec& singletonCols, - Vec& emptyCols, Vec>& activities, - CoeffChanged&& coeffChanged ) - { - if( matrixBuffer.empty() ) - return; - - // update row major storage, and pass down the coeffChanged callback -#ifdef PAPILO_TBB - tbb::parallel_invoke( - [&]() { -#endif - SmallVec buffer; - const MatrixEntry* iter = - matrixBuffer.template begin( buffer ); - - while( iter != matrixBuffer.end() ) - { - int row = iter->row; - - int newsize = cons_matrix.changeRowInplace( - row, - [&]() { - return iter != matrixBuffer.end() && iter->row == row; - }, - [&]() { - auto nextval = std::make_pair( iter->col, iter->val ); - iter = matrixBuffer.template next( buffer ); - return nextval; - }, - coeffChanged ); - - if( newsize != rowsize[row] ) - { - switch( newsize ) - { - case 0: - activities[row].min = 0; - activities[row].max = 0; - break; - case 1: - singletonRows.push_back( row ); - default: - break; - } - - rowsize[row] = newsize; - } - } -#ifdef PAPILO_TBB - }, - [&]() { -#endif - SmallVec buffer2; - - // update col major storage, do not pass down the coeffChanged - // callback so that it - /// is only called once - const MatrixEntry* iter2 = - matrixBuffer.template begin( buffer2 ); - - while( iter2 != matrixBuffer.end() ) - { - int col = iter2->col; - - int newsize = cons_matrix_transp.changeRowInplace( - col, - [&]() { - return iter2 != matrixBuffer.end() && iter2->col == col; - }, - [&]() { - auto nextval = std::make_pair( iter2->row, iter2->val ); - iter2 = matrixBuffer.template next( buffer2 ); - return nextval; - }, - []( int, int, REAL, REAL ) {} ); - - if( newsize != colsize[col] ) - { - switch( newsize ) - { - case 0: - emptyCols.push_back( col ); - break; - case 1: - singletonCols.push_back( col ); - default: - break; - } - // in case that a singleton var is aggregated and has 2 - // appearances and then is reduced again immediately it may - // appear two times in the list -> causes no bug but some - // unneccessary overhead - colsize[col] = newsize; - } - } -#ifdef PAPILO_TBB - } ); -#endif - } - - /// get the index of the column in the sparse array of row coefficients - template - int - getSparseIndex( int col, int row ) const - { - if( !transpose ) - { - auto rowCoef = getRowCoefficients( row ); - const int* indices = rowCoef.getIndices(); - const int len = rowCoef.getLength(); - - int index = std::lower_bound( indices, indices + len, col ) - indices; - if( index != len && indices[index] == col ) - return index; - return -1; - } - else - { - auto colCoef = getColumnCoefficients( col ); - const int* indices = colCoef.getIndices(); - const int len = colCoef.getLength(); - - int index = std::lower_bound( indices, indices + len, row ) - indices; - if( index != len && indices[index] == row ) - return index; - return -1; - } - } - - /// checks in there is enough sapce in the sparse storage to performe an - /// aggregation, and remove rows from the input relevantRows where the - /// sparsity condition is not verified, returns true if the condition is - /// verified on all relevantRows - bool - checkAggregationSparsityCondition( int col, - const SparseVectorView& equalityLHS, - int maxfillin, int maxshiftperrow, - Vec& indbuffer ); - - int - sparsify( const Num& num, int eqrow, const REAL& scale, int targetrow, - Vec& intbuffer, Vec& valbuffer, - const VariableDomains& domains, Vec& changedActivities, - Vec>& activities, Vec& singletonRows, - Vec& singletonCols, Vec& emptyCols, int presolveround ); - - /// perform the substitution of a column using an equality, and updates - /// the sides - /// @param substituted_col the columns to substituted - /// @param equalityLHS the right hand side of the equality i.e sum{ - /// a_j*x_i }, (needs to be sorted) - /// @param equalityRHS the left hand side of the equality such that sum{ - /// a_j*x_i } = equalityRHS - void - aggregate( const Num& num, int substituted_col, SparseVectorView equalityLHS, - REAL equalityRHS, const VariableDomains& domains, - Vec& indbuffer, Vec& valbuffer, - Vec>& tripletbuffer, Vec& changedActivities, - Vec>& activities, Vec& singletonRows, - Vec& singletonCols, Vec& emptyCols, int presolveround ); - - const SparseStorage& - getMatrixTranspose() const - { - return cons_matrix_transp; - } - - SparseStorage& - getMatrixTranspose() - { - return cons_matrix_transp; - } - - const SparseStorage& - getConstraintMatrix() const - { - return cons_matrix; - } - - SparseStorage& - getConstraintMatrix() - { - return cons_matrix; - } - - template - void - serialize( Archive& ar, const unsigned int version ) - { - ar& cons_matrix; - - if( Archive::is_loading::value ) - cons_matrix_transp = cons_matrix.getTranspose(); - - ar& lhs_values; - ar& rhs_values; - ar& flags; - ar& rowsize; - ar& colsize; - } - - private: - /// row-major compressed sparse storage (CSR) of the constraint matrix - SparseStorage cons_matrix; - - /// column-major compressed sparse storage (CSC) of the - /// constraint matrix - SparseStorage cons_matrix_transp; - - /// left hand side values for each row in the constraint - /// matrix - Vec lhs_values; - - /// right hand side values for each row in the constraint - /// matrix - Vec rhs_values; - - Vec flags; - - /// additional vector storing the number of non-zeros - /// within each row of the constraint matrix - Vec rowsize; - - /// additional vector storing the number of non-zeros - /// within each column of the constraint matrix - Vec colsize; -}; - -#ifdef PAPILO_USE_EXTERN_TEMPLATES -extern template class ConstraintMatrix; -extern template class ConstraintMatrix; -extern template class ConstraintMatrix; -#endif - -template -std::pair, Vec> -ConstraintMatrix::compress( bool full ) -{ - std::pair, Vec> mappings; -#ifdef PAPILO_TBB - tbb::parallel_invoke( - [this, &mappings, full]() { - mappings.first = - cons_matrix_transp.compress( colsize, rowsize, full ); - }, - [this, &mappings, full]() { - mappings.second = cons_matrix.compress( rowsize, colsize, full ); - } ); -#else - mappings.first = - cons_matrix_transp.compress( colsize, rowsize, full ); - mappings.second = cons_matrix.compress( rowsize, colsize, full ); -#endif - -#ifdef PAPILO_TBB - tbb::parallel_invoke( - [this, &mappings, full]() { - compress_vector( mappings.second, colsize ); - if( full ) - colsize.shrink_to_fit(); - }, - [this, &mappings, full]() { - compress_vector( mappings.first, rowsize ); - if( full ) - rowsize.shrink_to_fit(); - }, - [this, &mappings, full]() { - compress_vector( mappings.first, lhs_values ); - if( full ) - lhs_values.shrink_to_fit(); - }, - [this, &mappings, full]() { - compress_vector( mappings.first, rhs_values ); - if( full ) - rhs_values.shrink_to_fit(); - }, - [this, &mappings, full]() { - compress_vector( mappings.first, flags ); - if( full ) - flags.shrink_to_fit(); - } ); -#else - compress_vector( mappings.second, colsize ); - compress_vector( mappings.first, rowsize ); - compress_vector( mappings.first, lhs_values ); - compress_vector( mappings.first, rhs_values ); - compress_vector( mappings.first, flags ); - - if( full ) - { - colsize.shrink_to_fit(); - rowsize.shrink_to_fit(); - rhs_values.shrink_to_fit(); - lhs_values.shrink_to_fit(); - flags.shrink_to_fit(); - } - -#endif - - return mappings; -} - -template -void -ConstraintMatrix::deleteRowsAndCols( Vec& deletedRows, - Vec& deletedCols, - Vec>& activities, - Vec& singletonRows, - Vec& singletonCols, - Vec& emptyCols ) -{ - if( deletedRows.empty() && deletedCols.empty() ) - return; - - // CSR storage - int* rowcols = cons_matrix.getColumns(); - IndexRange* rowranges = cons_matrix.getRowRanges(); - REAL* rowvalues = cons_matrix.getValues(); - - // CSC storage - int* colrows = cons_matrix_transp.getColumns(); - IndexRange* colranges = cons_matrix_transp.getRowRanges(); - REAL* colvalues = cons_matrix_transp.getValues(); - -#ifdef PAPILO_TBB - tbb::parallel_invoke( - [this, &deletedRows]() { - for( int row : deletedRows ) - { - cons_matrix.getNnz() -= rowsize[row]; - rowsize[row] = -1; - } - }, - [this, &deletedCols]() { - for( int col : deletedCols ) - colsize[col] = -1; - } ); -#else - for( int row : deletedRows ) - { - cons_matrix.getNnz() -= rowsize[row]; - rowsize[row] = -1; - } - for( int col : deletedCols ) - colsize[col] = -1; -#endif - - // delete rows from row storage and update column sizes -#ifdef PAPILO_TBB - tbb::parallel_invoke( - [this, &deletedRows, rowranges, rowcols, &activities]() { -#endif - for( int row : deletedRows ) - { - assert( flags[row].test( RowFlag::kRedundant ) ); - - for( int i = rowranges[row].start; i != rowranges[row].end; ++i ) - { - int col = rowcols[i]; - if( colsize[col] == -1 ) - continue; - - --colsize[col]; - assert( colsize[col] >= 0 ); - } - - rowranges[row].start = rowranges[row + 1].start; - rowranges[row].end = rowranges[row + 1].start; - lhs_values[row] = 0.0; - rhs_values[row] = 0.0; - activities[row].ninfmax = 0; - activities[row].ninfmin = 0; - activities[row].min = 0; - activities[row].max = 0; - } -#ifdef PAPILO_TBB - }, - // delete cols from col storage and update rowsizes - [this, &deletedCols, colranges, colrows] { -#endif - for( int col : deletedCols ) - { - for( int i = colranges[col].start; i != colranges[col].end; ++i ) - { - int row = colrows[i]; - - if( rowsize[row] == -1 ) - continue; - - --rowsize[row]; - assert( rowsize[row] >= 0 ); - } - - colranges[col].start = colranges[col + 1].start; - colranges[col].end = colranges[col + 1].start; - } -#ifdef PAPILO_TBB - } ); -#endif - -#ifdef PAPILO_TBB - tbb::parallel_invoke( - [this, colranges, &singletonCols, &emptyCols, colrows, colvalues]() { -#endif - for( int col = 0; col != getNCols(); ++col ) - { - // if the size did not change, skip column - if( colsize[col] == -1 || - colsize[col] == colranges[col].end - colranges[col].start ) - continue; - - // if the size is now 1, add to singleton column vector - switch( colsize[col] ) - { - case 0: - emptyCols.push_back( col ); - colranges[col].start = colranges[col + 1].start; - colranges[col].end = colranges[col + 1].start; - break; - case 1: - singletonCols.push_back( col ); - } - - if( colsize[col] >= 1 ) - { - // now move contents of column to occupy free spaces - int j = 0; - - for( int i = colranges[col].start; i != colranges[col].end; - ++i ) - { - int row = colrows[i]; - - if( rowsize[row] == -1 ) - ++j; - else if( j > 0 ) - { - colvalues[i - j] = colvalues[i]; - colrows[i - j] = colrows[i]; - } - } - assert( colsize[col] >= 0 ); - assert( colsize[col] + colranges[col].start == - colranges[col].end - j ); - - colranges[col].end = colranges[col].start + colsize[col]; - } - } -#ifdef PAPILO_TBB - }, - [this, rowranges, &singletonRows, &activities, rowcols, rowvalues]() { -#endif - for( int row = 0; row != getNRows(); ++row ) - { - // if the size did not change, skip row - if( rowsize[row] == -1 || - rowsize[row] == rowranges[row].end - rowranges[row].start ) - continue; - - // if the size is now 1, add to singleton row vector - switch( rowsize[row] ) - { - case 0: - activities[row].min = 0; - activities[row].max = 0; - break; - case 1: - singletonRows.push_back( row ); - } - - // now move contents of row to occupy free spaces - int j = 0; - - for( int i = rowranges[row].start; i != rowranges[row].end; ++i ) - { - int col = rowcols[i]; - - if( colsize[col] == -1 ) - ++j; - else if( j > 0 ) - { - rowvalues[i - j] = rowvalues[i]; - rowcols[i - j] = rowcols[i]; - } - } - - assert( rowsize[row] >= 0 ); - assert( rowsize[row] + rowranges[row].start == - rowranges[row].end - j ); - cons_matrix.getNnz() -= j; - - rowranges[row].end = rowranges[row].start + rowsize[row]; - } -#ifdef PAPILO_TBB - } ); -#endif - - cons_matrix_transp.getNnz() = cons_matrix.getNnz(); - - deletedRows.clear(); - deletedCols.clear(); -} - -template -bool -ConstraintMatrix::checkAggregationSparsityCondition( - int col, const SparseVectorView& equalityLHS, int maxfillin, - int maxshiftperrow, Vec& indbuffer ) -{ - const int* indices = equalityLHS.getIndices(); - const int len = equalityLHS.getLength(); - - const auto& freecolcoef = getColumnCoefficients( col ); - const int* freecolindices = freecolcoef.getIndices(); - const int length = freecolcoef.getLength(); - - auto rowranges = cons_matrix.getRowRanges(); - auto colranges = cons_matrix_transp.getRowRanges(); - - int totalfillin = 0; - bool eqinmatrix = false; - bool shift = true; - - indbuffer.clear(); - indbuffer.reserve( std::max( length, len ) ); - - for( int k = 0; k < length; ++k ) - { - int row = freecolindices[k]; - auto currentrow = getRowCoefficients( row ); - const int* rowindices = currentrow.getIndices(); - const int currentrowlen = currentrow.getLength(); - - if( rowindices == indices ) - { - totalfillin -= len; - eqinmatrix = true; - indbuffer.push_back( 0 ); - continue; - } - - int i = 0; - int j = 0; - int fillin = -1; - - while( i < len && j < currentrowlen ) - { - if( indices[i] == rowindices[j] ) - { - ++i; - ++j; - } - else if( indices[i] < rowindices[j] ) - { - ++i; - ++fillin; - } - else - { - ++j; - } - } - - fillin += ( len - i ); - totalfillin += fillin; - - int sparespace = rowranges[row + 1].start - rowranges[row].end; - - if( sparespace < fillin ) - shift = true; - - indbuffer.push_back( fillin ); - } - - if( totalfillin > maxfillin ) - { - indbuffer.clear(); - return false; - } - - if( shift && !cons_matrix.shiftRows( freecolindices, length, maxshiftperrow, - indbuffer ) ) - { - indbuffer.clear(); - return false; - } - - indbuffer.clear(); - shift = false; - - for( int k = 0; k < len; ++k ) - { - int currentcolind = indices[k]; - if( currentcolind == col ) - { - indbuffer.push_back( 0 ); - continue; - } - - auto currentcol = getColumnCoefficients( currentcolind ); - const int* colindices = currentcol.getIndices(); - const int currentcollen = currentcol.getLength(); - - int i = 0; - int j = 0; - int fillin = eqinmatrix ? -1 : 0; - - while( i < length && j < currentcollen ) - { - if( freecolindices[i] == colindices[j] ) - { - ++i; - ++j; - } - else if( freecolindices[i] < colindices[j] ) - { - ++i; - ++fillin; - } - else - { - ++j; - } - } - - fillin += ( length - i ); - - int sparespace = - colranges[currentcolind + 1].start - colranges[currentcolind].end; - - if( sparespace < fillin ) - shift = true; - - indbuffer.push_back( fillin ); - } - - if( shift && !cons_matrix_transp.shiftRows( indices, len, maxshiftperrow, - indbuffer ) ) - { - indbuffer.clear(); - return false; - } - - indbuffer.clear(); - return true; -} - -template -int -ConstraintMatrix::sparsify( - const Num& num, int eqrow, const REAL& scale, int targetrow, - Vec& intbuffer, Vec& valbuffer, - const VariableDomains& domains, Vec& changedActivities, - Vec>& activities, Vec& singletonRows, - Vec& singletonCols, Vec& emptyCols, int presolveround ) -{ - int ncancel = 0; - int fillincol = -1; - REAL fillinval = 0; - IndexRange* colranges = cons_matrix_transp.getRowRanges(); - - const IndexRange& eqrange = cons_matrix.getRowRanges()[eqrow]; - IndexRange& targetrange = cons_matrix.getRowRanges()[targetrow]; - - int* rowcols = cons_matrix.getColumns(); - REAL* rowvals = cons_matrix.getValues(); - - int j = eqrange.start; - int k = targetrange.start; - - while( j != eqrange.end && k != targetrange.end ) - { - if( rowcols[j] == rowcols[k] ) - { - REAL newval = rowvals[j] * scale + rowvals[k]; - - if( num.isZero( newval ) ) - ++ncancel; - else if( num.isFeasZero( newval ) ) - return 0; - - ++j; - ++k; - } - else if( rowcols[j] < rowcols[k] ) - { - if( fillincol != -1 ) - return 0; - - fillincol = rowcols[j]; - if( colranges[fillincol + 1].start - colranges[fillincol].start == - colsize[fillincol] ) - return 0; - - fillinval = scale * rowvals[j]; - --ncancel; - ++j; - } - else - { - ++k; - } - } - - int remainingfillin = eqrange.end - j; - - if( remainingfillin != 0 ) - { - if( remainingfillin != 1 ) - return 0; - if( fillincol != -1 ) - return 0; - - fillincol = rowcols[j]; - if( colranges[fillincol + 1].start - colranges[fillincol].start == - colsize[fillincol] ) - return 0; - - fillinval = scale * rowvals[j]; - --ncancel; - } - - if( ncancel <= 0 ) - return 0; - - // change coefficients for column where fillin occurs (we allow at most one - // such column, otherwise we return from this function before we reach this - // part) - if( fillincol != -1 ) - { - - assert( colsize[fillincol] < - colranges[fillincol + 1].start - colranges[fillincol].start ); - - colsize[fillincol] = cons_matrix_transp.changeRow( - fillincol, 0, 1, - [&]( int i ) { - assert( i == 0 ); - return targetrow; - }, - [&]( int i ) { - assert( i == 0 ); - return fillinval; - }, - []( const REAL& curr, const REAL& val ) { - assert( curr == 0 ); - return val; - }, - []( int, int, REAL, REAL ) {}, valbuffer, intbuffer ); - } - - // change coefficients in column storage for other columns - j = eqrange.start; - k = targetrange.start; - - while( j != eqrange.end && k != targetrange.end ) - { - if( rowcols[j] == rowcols[k] ) - { - int col = rowcols[k]; - assert( col != fillincol ); - - REAL newval = rowvals[k] + scale * rowvals[j]; - - if( num.isZero( newval ) ) - { - --colsize[col]; - - switch( colsize[col] ) - { - case 0: - emptyCols.push_back( col ); - break; - case 1: - singletonCols.push_back( col ); - } - - newval = 0; - } - - int count = 0; - int newsize = cons_matrix_transp.changeRowInplace( - col, [&]() { return ( count++ ) == 0; }, - [&]() { - assert( count == 1 ); - return std::make_pair( targetrow, newval ); - }, - []( int, int, REAL, REAL ) {} ); - - UNUSED(newsize); - assert( newsize == colsize[col] ); - - ++j; - ++k; - } - else if( rowcols[j] < rowcols[k] ) - { - assert( rowcols[j] == fillincol ); - ++j; - } - else - { - assert( rowcols[k] < rowcols[j] ); - ++k; - } - } - - assert( j == eqrange.end || - ( j + 1 == eqrange.end && rowcols[j] == fillincol ) ); - - // update sides if necessary - if( rhs_values[eqrow] != 0 ) - { - if( !flags[targetrow].test( RowFlag::kLhsInf ) ) - lhs_values[targetrow] += scale * rhs_values[eqrow]; - - if( !flags[targetrow].test( RowFlag::kRhsInf ) ) - rhs_values[targetrow] += scale * rhs_values[eqrow]; - - // due to numerics the row can become an equation - if( !flags[targetrow].test( RowFlag::kLhsInf, RowFlag::kRhsInf, - RowFlag::kEquation ) && - lhs_values[targetrow] == rhs_values[targetrow] ) - flags[targetrow].set( RowFlag::kEquation ); - } - - // finally update the row - auto updateActivity = [&]( int row, int col, REAL oldval, REAL newval ) { - auto activityChange = [row, presolveround, &changedActivities]( - ActivityChange actChange, - RowActivity& activity ) { - if( activity.lastchange == presolveround ) - return; - - if( actChange == ActivityChange::kMin && activity.ninfmin > 1 ) - return; - - if( actChange == ActivityChange::kMax && activity.ninfmax > 1 ) - return; - - activity.lastchange = presolveround; - changedActivities.push_back( row ); - }; - const SparseVectorView& rowvec = getRowCoefficients( row ); - update_activity_after_coeffchange( - domains.lower_bounds[col], domains.upper_bounds[col], - domains.flags[col], oldval, newval, activities[row], rowvec.getLength(), - rowvec.getIndices(), rowvec.getValues(), domains, num, - activityChange ); - }; - - int newsize = cons_matrix.changeRow( - targetrow, eqrange.start, eqrange.end, - [&]( int i ) { return rowcols[i]; }, - [&]( int i ) { return scale * rowvals[i]; }, - [&]( const REAL& a, const REAL& b ) { - REAL val = a + b; - if( num.isZero( val ) ) - val = 0; - return val; - }, - updateActivity, valbuffer, intbuffer ); - - assert( rowsize[targetrow] - ncancel == newsize ); - rowsize[targetrow] = newsize; - - switch( rowsize[targetrow] ) - { - case 0: - activities[targetrow].min = 0; - activities[targetrow].max = 0; - break; - case 1: - singletonRows.push_back( targetrow ); - } - - assert( cons_matrix.getNnz() == cons_matrix_transp.getNnz() ); - - return ncancel; -} - -template -void -ConstraintMatrix::aggregate( - const Num& num, int substituted_col, SparseVectorView equalityLHS, - REAL equalityRHS, const VariableDomains& domains, Vec& indbuffer, - Vec& valbuffer, Vec>& tripletbuffer, - Vec& changedActivities, Vec>& activities, - Vec& singletonRows, Vec& singletonCols, Vec& emptyCols, - int presolveround ) -{ - const int equalitylen = equalityLHS.getLength(); - const REAL* equalityvalues = equalityLHS.getValues(); - const int* equalityindices = equalityLHS.getIndices(); - - assert( std::is_sorted( equalityindices, equalityindices + equalitylen ) ); - - int freeColPos; - for( freeColPos = 0; freeColPos < equalitylen; ++freeColPos ) - { - if( equalityindices[freeColPos] == substituted_col ) - break; - } - assert( freeColPos != equalitylen ); - - REAL eqbasescale = REAL{ -1 } / equalityvalues[freeColPos]; - - assert( tripletbuffer.empty() ); - tripletbuffer.reserve( equalitylen * colsize[substituted_col] ); - - auto updateActivity = [presolveround, &changedActivities, &domains, - &activities, &tripletbuffer, this, num]( - int row, int col, REAL oldval, REAL newval ) { - if( oldval == newval ) - return; - - auto activityChange = [row, presolveround, &changedActivities]( - ActivityChange actChange, - RowActivity& activity ) { - if( activity.lastchange == presolveround ) - return; - - if( actChange == ActivityChange::kMin && activity.ninfmin > 1 ) - return; - - if( actChange == ActivityChange::kMax && activity.ninfmax > 1 ) - return; - - activity.lastchange = presolveround; - changedActivities.push_back( row ); - }; - - tripletbuffer.emplace_back( col, row, newval ); - - const SparseVectorView& rowVec = getRowCoefficients( row ); - update_activity_after_coeffchange( - domains.lower_bounds[col], domains.upper_bounds[col], - domains.flags[col], oldval, newval, activities[row], - rowVec.getLength(), rowVec.getIndices(), rowVec.getValues(), domains, - num, activityChange ); - }; - - auto mergeVal = [&]( const REAL& oldval, const REAL& addition ) { - REAL val = oldval + addition; - if( num.isZero( val ) ) - return REAL{ 0 }; - - return val; - }; - - const auto& freecol = getColumnCoefficients( substituted_col ); - const REAL* freecolcoef = freecol.getValues(); - const int* freecolindices = freecol.getIndices(); - const int freecollength = freecol.getLength(); - - // make the changes in the matrix and update the constraints' sides - for( int i = 0; i < freecollength; ++i ) - { - int row = freecolindices[i]; - - assert( flags[row].test( RowFlag::kRedundant ) || - ( !flags[row].test( RowFlag::kEquation ) && - ( flags[row].test( RowFlag::kLhsInf, RowFlag::kRhsInf ) || - lhs_values[row] != rhs_values[row] ) ) || - ( flags[row].test( RowFlag::kEquation ) && - !flags[row].test( RowFlag::kLhsInf, RowFlag::kRhsInf ) && - lhs_values[row] == rhs_values[row] ) ); - - // do not modify the equations content while it is still used, - // just set the size and the sides to zero since they are copied in - // local variables - if( cons_matrix.getColumns() + cons_matrix.rowranges[row].start == - equalityindices ) - { - for( int k = 0; k < equalitylen; ++k ) - tripletbuffer.emplace_back( equalityindices[k], row, 0 ); - - flags[row].set( RowFlag::kRedundant ); - cons_matrix.rowranges[row].start = - cons_matrix.rowranges[row + 1].start; - cons_matrix.rowranges[row].end = cons_matrix.rowranges[row + 1].start; - lhs_values[row] = 0.0; - rhs_values[row] = 0.0; - cons_matrix.getNnz() -= rowsize[row]; - rowsize[row] = -1; - continue; - } - - REAL eqscale = eqbasescale * freecolcoef[i]; - - int newsize = cons_matrix.changeRow( - row, int{ 0 }, equalitylen, - [&]( int k ) { return equalityindices[k]; }, - [&]( int k ) { - return k == freeColPos ? REAL( -freecolcoef[i] ) - : REAL( equalityvalues[k] * eqscale ); - }, - mergeVal, updateActivity, valbuffer, indbuffer ); - - if( newsize != rowsize[row] ) - { - switch( newsize ) - { - case 0: - activities[row].min = 0; - activities[row].max = 0; - break; - case 1: - singletonRows.push_back( row ); - default: - break; - } - - rowsize[row] = newsize; - } - - assert( - std::all_of( getRowCoefficients( row ).getIndices(), - getRowCoefficients( row ).getIndices() + rowsize[row], - [&]( int rowcol ) { return rowcol != substituted_col; } ) ); - - // change the bounds - if( equalityRHS != 0 ) - { - if( !flags[row].test( RowFlag::kLhsInf ) ) - lhs_values[row] += eqscale * equalityRHS; - - if( !flags[row].test( RowFlag::kRhsInf ) ) - rhs_values[row] += eqscale * equalityRHS; - - // due to numerics the row can become an equation - if( !flags[row].test( RowFlag::kLhsInf, RowFlag::kRhsInf, - RowFlag::kEquation ) && - lhs_values[row] == rhs_values[row] ) - flags[row].set( RowFlag::kEquation ); - } - - assert( flags[row].test( RowFlag::kRedundant ) || - ( !flags[row].test( RowFlag::kEquation ) && - ( flags[row].test( RowFlag::kLhsInf, RowFlag::kRhsInf ) || - lhs_values[row] != rhs_values[row] ) ) || - ( flags[row].test( RowFlag::kEquation ) && - !flags[row].test( RowFlag::kLhsInf, RowFlag::kRhsInf ) && - lhs_values[row] == rhs_values[row] ) ); - } - - if( !tripletbuffer.empty() ) - { - pdqsort( tripletbuffer.begin(), tripletbuffer.end() ); - - auto handleCol = [&]( int col, int start, int end ) { - int newsize = cons_matrix_transp.changeRow( - col, start, end, - [&]( int k ) { return std::get<1>( tripletbuffer[k] ); }, - [&]( int k ) { return std::get<2>( tripletbuffer[k] ); }, - []( const REAL& oldval, const REAL& newval ) { return newval; }, - []( int, int, REAL, REAL ) {}, valbuffer, indbuffer ); - - if( newsize != colsize[col] ) - { - switch( newsize ) - { - case 0: - emptyCols.push_back( col ); - break; - case 1: - singletonCols.push_back( col ); - default: - break; - } - //TODO: remove column from singleton columns if necessary - colsize[col] = newsize; - } - }; - - int start = 0; - int currcol = std::get<0>( tripletbuffer[0] ); - int nchgs = tripletbuffer.size(); - for( int i = 1; i != nchgs; ++i ) - { - if( std::get<0>( tripletbuffer[i] ) != currcol ) - { - handleCol( currcol, start, i ); - currcol = std::get<0>( tripletbuffer[i] ); - start = i; - } - } - - handleCol( currcol, start, nchgs ); - - tripletbuffer.clear(); - } - - // set column size to zero - cons_matrix_transp.rowranges[substituted_col].start = - cons_matrix_transp.rowranges[substituted_col + 1].start; - cons_matrix_transp.rowranges[substituted_col].end = - cons_matrix_transp.rowranges[substituted_col + 1].start; - cons_matrix_transp.getNnz() -= colsize[substituted_col]; - colsize[substituted_col] = -1; - - assert( cons_matrix_transp.getNnz() == cons_matrix.getNnz() ); -} - -} // namespace papilo - -#endif diff --git a/headers/papilo/core/MatrixBuffer.hpp b/headers/papilo/core/MatrixBuffer.hpp deleted file mode 100644 index 429e9be..0000000 --- a/headers/papilo/core/MatrixBuffer.hpp +++ /dev/null @@ -1,655 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* */ -/* This file is part of the program and library */ -/* PaPILO --- Parallel Presolve for Integer and Linear Optimization */ -/* */ -/* Copyright (C) 2020-2022 Konrad-Zuse-Zentrum */ -/* fuer Informationstechnik Berlin */ -/* */ -/* This program is free software: you can redistribute it and/or modify */ -/* it under the terms of the GNU Lesser General Public License as published */ -/* by the Free Software Foundation, either version 3 of the License, or */ -/* (at your option) any later version. */ -/* */ -/* This program is distributed in the hope that it will be useful, */ -/* but WITHOUT ANY WARRANTY; without even the implied warranty of */ -/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ -/* GNU Lesser General Public License for more details. */ -/* */ -/* You should have received a copy of the GNU Lesser General Public License */ -/* along with this program. If not, see . */ -/* */ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -#ifndef _PAPILO_CORE_MATRIX_BUFFER_HPP_ -#define _PAPILO_CORE_MATRIX_BUFFER_HPP_ - -#include "papilo/core/SparseStorage.hpp" -#include "papilo/misc/Vec.hpp" -#include -#include - -namespace papilo -{ - -// for doubles, entry is 32bytes which makes two entries per cache line -// the entries are added to a vector and linked to two trees. One -// allows traversal for row major and one for column major storage order -template -struct MatrixEntry -{ - REAL val; - int row; - int col; - - struct TreeHook - { - int left; - int right; - }; - - TreeHook row_major; - TreeHook col_major; - - MatrixEntry() {} - - MatrixEntry( int _row, int _col, const REAL& _val ) - : val( _val ), row( _row ), col( _col ) - { - row_major.left = 0; - row_major.right = 0; - col_major.left = 0; - col_major.right = 0; - } -}; - -template -struct GetNodeProperty; - -/// data structure for sparse matrix entries that allows efficient row -/// major and column major traversal -template -struct MatrixBuffer -{ - template - int - splay( int n, int t ) - { - using Node = GetNodeProperty; - - /* Simple top down splay, not requiring i to be in the tree t. */ - /* What it does is described above. */ - - assert( t != 0 ); - - int l = 0; - int r = 0; - int y; - - for( ;; ) - { - if( Node::lesser( entries[n], entries[t] ) ) - { - int t_left = Node::left( entries[t] ); - if( t_left == 0 ) - break; - if( Node::lesser( entries[n], entries[t_left] ) ) - { - // rotate right - y = t_left; - Node::left( entries[t] ) = Node::right( entries[y] ); - Node::right( entries[y] ) = t; - t = y; - if( Node::left( entries[t] ) == 0 ) - break; - } - - // link right - Node::left( entries[r] ) = t; - - r = t; - t = Node::left( entries[t] ); - } - else - { - int t_right = Node::right( entries[t] ); - if( t_right == 0 ) - break; - if( Node::lesser( entries[t_right], entries[n] ) ) - { - // rotate left - y = t_right; - Node::right( entries[t] ) = Node::left( entries[y] ); - Node::left( entries[y] ) = t; - t = y; - if( Node::right( entries[t] ) == 0 ) - break; - } - - // link left - Node::right( entries[l] ) = t; - - l = t; - t = Node::right( entries[t] ); - } - } - - // assemble - Node::right( entries[l] ) = Node::left( entries[t] ); - Node::left( entries[r] ) = Node::right( entries[t] ); - Node::left( entries[t] ) = Node::right( entries[0] ); - Node::right( entries[t] ) = Node::left( entries[0] ); - - Node::left( entries[0] ) = 0; - Node::right( entries[0] ) = 0; - - return t; - } - - template - void - splay_insert( int n, int t ) - { - using Node = GetNodeProperty; - - t = splay( n, t ); - // make n the new root - if( Node::lesser( entries[n], entries[t] ) ) - { - Node::left( entries[n] ) = Node::left( entries[t] ); - Node::right( entries[n] ) = t; - Node::left( entries[t] ) = 0; - } - else - { - Node::right( entries[n] ) = Node::right( entries[t] ); - Node::left( entries[n] ) = t; - Node::right( entries[t] ) = 0; - } - } - - /// link node n into the tree for the given storage order - template - void - link( int n ) - { - using Node = GetNodeProperty; - - // currnode is the pointer of the parent node - // where n will be inserted, starting with the root pointer - int* currnode = &Node::root( this ); - - // get priority of n - uint32_t prio = Node::priority( entries[n] ); - - // after this loop n will be the subtree that needs - // to be linked to *currnode. That is either a - // leaf node or a treap where n is the root - while( *currnode != 0 ) - { - uint32_t p = Node::priority( entries[*currnode] ); - - if( p < prio ) - { - // if we found a node with a smaller priority we do - // a top down splay to make n the root of this sub tree - // and stop insertion here. - int t = splay( n, *currnode ); - - // make n the new root - if( Node::lesser( entries[n], entries[t] ) ) - { - Node::left( entries[n] ) = Node::left( entries[t] ); - Node::right( entries[n] ) = t; - Node::left( entries[t] ) = 0; - } - else - { - Node::right( entries[n] ) = Node::right( entries[t] ); - Node::left( entries[n] ) = t; - Node::right( entries[t] ) = 0; - } - - break; - } - - // go further down the tree - if( Node::lesser( entries[n], entries[*currnode] ) ) - currnode = &Node::left( entries[*currnode] ); - else - currnode = &Node::right( entries[*currnode] ); - } - - // update the parents pointer to the the tree now rooted at n - // (could be the root pointer) - *currnode = n; - } - - bool - empty() const - { - return entries.size() == 1; - } - - void - clear() - { - entries.resize( 1 ); - col_major_root = 0; - row_major_root = 0; - } - - void - addEntry( int row, int col, const REAL& val ) - { - int n = entries.size(); - entries.emplace_back( row, col, val ); - - this->template link( n ); - this->template link( n ); - } - - template - MatrixEntry* - findEntry( int row, int col ) - { - using Node = GetNodeProperty; - MatrixEntry entry( row, col, REAL{ 0 } ); - - int k = Node::root( this ); - - while( k != 0 ) - { - if( Node::lesser( entry, entries[k] ) ) - k = Node::left( entries[k] ); - else if( Node::lesser( entries[k], entry ) ) - k = Node::right( entries[k] ); - else - { - assert( entries[k].row == row ); - assert( entries[k].col == col ); - return &entries[k]; - } - } - - return nullptr; - } - - void - addEntrySafe( int row, int col, const REAL& val ) - { - MatrixEntry* entry = findEntry( row, col ); - - if( entry != NULL ) - entry->val += val; - else - addEntry( row, col, val ); - } - - template - const MatrixEntry* - begin( SmallVec& stack ) const - { - using Node = GetNodeProperty; - - stack.clear(); - stack.push_back( 0 ); - - int k = Node::root( this ); - - while( k != 0 ) - { - stack.push_back( k ); - k = Node::left( entries[k] ); - } - - return &entries[stack.back()]; - } - - template - const MatrixEntry* - beginStart( SmallVec& stack, int row, int col ) const - { - using Node = GetNodeProperty; - - stack.clear(); - stack.push_back( 0 ); - - int k = Node::root( this ); - - assert( row == -1 || col == -1 ); - - MatrixEntry dummy( row, col, REAL{ 0 } ); - - while( k != 0 ) - { - if( Node::lesser( dummy, entries[k] ) ) - { - stack.push_back( k ); - k = Node::left( entries[k] ); - } - else - { - k = Node::right( entries[k] ); - } - } - - return &entries[stack.back()]; - } - - template - const MatrixEntry* - next( SmallVec& stack ) const - { - using Node = GetNodeProperty; - - int k = stack.back(); - stack.pop_back(); - - k = Node::right( entries[k] ); - while( k != 0 ) - { - stack.push_back( k ); - k = Node::left( entries[k] ); - } - - return &entries[stack.back()]; - } - - const MatrixEntry* - end() const - { - return &entries[0]; - } - - void - reserve( int nnz ) - { - entries.reserve( nnz + 1 ); - } - - void - startBadge() - { - badge_start = entries.size(); - } - - void - addBadgeEntry( int row, int col, const REAL& val ) - { - assert( badge_start >= 0 && badge_start <= (int)entries.size() ); - entries.emplace_back( row, col, val ); - } - - void - discardBadge() - { - assert( badge_start >= 0 && badge_start <= entries.size() ); - entries.resize( badge_start ); - badge_start = -1; - } - - void - finishBadge() - { - assert( badge_start >= 0 && badge_start <= (int)entries.size() ); - - for( int i = badge_start; i != (int)entries.size(); ++i ) - { - this->template link( i ); - this->template link( i ); - } - - badge_start = -1; - } - - int - getNnz() const - { - return entries.size() - 1; - } - - SparseStorage - buildCSR( - int nrows, int ncols, - double spareRatio = SparseStorage::DEFAULT_SPARE_RATIO, - int mininterrowspace = SparseStorage::DEFAULT_MIN_INTER_ROW_SPACE ) - { - int nnz = getNnz(); - - SparseStorage csrStorage( nrows, ncols, nnz, spareRatio, - mininterrowspace ); - - SmallVec stack; - - REAL* values = csrStorage.getValues(); - int* columns = csrStorage.getColumns(); - IndexRange* rowranges = csrStorage.getRowRanges(); - - const MatrixEntry* it = this->begin( stack ); - const MatrixEntry* end = this->end(); - - int k = 0; - - for( int i = 0; i != nrows; ++i ) - { - rowranges[i].start = k; - - while( it != end && it->row == i ) - { - values[k] = it->val; - columns[k] = it->col; - - ++k; - - it = this->next( stack ); - } - - rowranges[i].end = k; - - if( k != rowranges[i].start ) - { - int rowsize = k - rowranges[i].start; - k += csrStorage.computeRowAlloc( rowsize ) - rowsize; - } - } - - rowranges[nrows].start = csrStorage.getNAlloc(); - rowranges[nrows].end = csrStorage.getNAlloc(); - - return csrStorage; - } - - SparseStorage - buildCSC( - int nrows, int ncols, - double spareRatio = SparseStorage::DEFAULT_SPARE_RATIO, - int minintercolspace = SparseStorage::DEFAULT_MIN_INTER_ROW_SPACE ) - { - int nnz = getNnz(); - - SparseStorage cscStorage( ncols, nrows, nnz, spareRatio, - minintercolspace ); - - SmallVec stack; - - REAL* values = cscStorage.getValues(); - int* rows = cscStorage.getColumns(); - IndexRange* colranges = cscStorage.getRowRanges(); - - const MatrixEntry* it = this->begin( stack ); - const MatrixEntry* end = this->end(); - - int k = 0; - - for( int i = 0; i != ncols; ++i ) - { - colranges[i].start = k; - - while( it != end && it->col == i ) - { - values[k] = it->val; - rows[k] = it->row; - - ++k; - - it = this->next( stack ); - } - - colranges[i].end = k; - - if( k != colranges[i].start ) - { - int colsize = k - colranges[i].start; - k += cscStorage.computeRowAlloc( colsize ) - colsize; - } - } - - colranges[ncols].start = cscStorage.getNAlloc(); - colranges[ncols].end = cscStorage.getNAlloc(); - - return cscStorage; - } - - MatrixBuffer() - { - // root is the dummy NULL node - row_major_root = 0; - col_major_root = 0; - - // insert dummy NULL node at position 0 - entries.emplace_back( -1, -1, 0 ); - } - - int badge_start = -1; - int row_major_root; - int col_major_root; - Vec> entries; -}; - -template <> -struct GetNodeProperty -{ - template - static uint32_t - priority( const MatrixEntry& e ) - { - uint64_t x = uint64_t( uint32_t( e.row ) ) << 32 | uint32_t( e.col ); - return uint32_t( ( x * UINT64_C( 0x9e3779b97f4a7c15 ) ) >> 32 ); - } - - template - static bool - lesser( const MatrixEntry& a, const MatrixEntry& b ) - { - return a.row < b.row || ( a.row == b.row && a.col < b.col ); - } - - template - static int& - left( MatrixEntry& e ) - { - return e.row_major.left; - } - - template - static int& - right( MatrixEntry& e ) - { - return e.row_major.right; - } - - template - static int& - root( MatrixBuffer* thisptr ) - { - return thisptr->row_major_root; - } - - template - static const int& - left( const MatrixEntry& e ) - { - return e.row_major.left; - } - - template - static const int& - right( const MatrixEntry& e ) - { - return e.row_major.right; - } - - template - static const int& - root( const MatrixBuffer* thisptr ) - { - return thisptr->row_major_root; - } -}; - -template <> -struct GetNodeProperty -{ - - template - static uint32_t - priority( const MatrixEntry& e ) - { - uint64_t x = uint64_t( uint32_t( e.col ) ) << 32 | uint32_t( e.row ); - return uint32_t( ( x * UINT64_C( 0x9e3779b97f4a7c15 ) ) >> 32 ); - } - - template - static bool - lesser( const MatrixEntry& a, const MatrixEntry& b ) - { - return a.col < b.col || ( a.col == b.col && a.row < b.row ); - } - - template - static int& - left( MatrixEntry& e ) - { - return e.col_major.left; - } - - template - static int& - right( MatrixEntry& e ) - { - return e.col_major.right; - } - - template - static int& - root( MatrixBuffer* thisptr ) - { - return thisptr->col_major_root; - } - - template - static const int& - left( const MatrixEntry& e ) - { - return e.col_major.left; - } - - template - static const int& - right( const MatrixEntry& e ) - { - return e.col_major.right; - } - - template - static const int& - root( const MatrixBuffer* thisptr ) - { - return thisptr->col_major_root; - } -}; - -} // namespace papilo - -#endif diff --git a/headers/papilo/core/Objective.hpp b/headers/papilo/core/Objective.hpp deleted file mode 100644 index acb0ca1..0000000 --- a/headers/papilo/core/Objective.hpp +++ /dev/null @@ -1,53 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* */ -/* This file is part of the program and library */ -/* PaPILO --- Parallel Presolve for Integer and Linear Optimization */ -/* */ -/* Copyright (C) 2020-2022 Konrad-Zuse-Zentrum */ -/* fuer Informationstechnik Berlin */ -/* */ -/* This program is free software: you can redistribute it and/or modify */ -/* it under the terms of the GNU Lesser General Public License as published */ -/* by the Free Software Foundation, either version 3 of the License, or */ -/* (at your option) any later version. */ -/* */ -/* This program is distributed in the hope that it will be useful, */ -/* but WITHOUT ANY WARRANTY; without even the implied warranty of */ -/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ -/* GNU Lesser General Public License for more details. */ -/* */ -/* You should have received a copy of the GNU Lesser General Public License */ -/* along with this program. If not, see . */ -/* */ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -#ifndef _PAPILO_CORE_OBJECTIVE_HPP_ -#define _PAPILO_CORE_OBJECTIVE_HPP_ - -#include "papilo/misc/Vec.hpp" - -namespace papilo -{ - -/// type to store an objective function -template -struct Objective -{ - /// dense vector of objective coefficients - Vec coefficients; - - /// offset of objective function - REAL offset; - - template - void - serialize( Archive& ar, const unsigned int version ) - { - ar& coefficients; - ar& offset; - } -}; - -} // namespace papilo - -#endif diff --git a/headers/papilo/core/Presolve.hpp b/headers/papilo/core/Presolve.hpp deleted file mode 100644 index cf8cf5c..0000000 --- a/headers/papilo/core/Presolve.hpp +++ /dev/null @@ -1,1437 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* */ -/* This file is part of the program and library */ -/* PaPILO --- Parallel Presolve for Integer and Linear Optimization */ -/* */ -/* Copyright (C) 2020-2022 Konrad-Zuse-Zentrum */ -/* fuer Informationstechnik Berlin */ -/* */ -/* This program is free software: you can redistribute it and/or modify */ -/* it under the terms of the GNU Lesser General Public License as published */ -/* by the Free Software Foundation, either version 3 of the License, or */ -/* (at your option) any later version. */ -/* */ -/* This program is distributed in the hope that it will be useful, */ -/* but WITHOUT ANY WARRANTY; without even the implied warranty of */ -/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ -/* GNU Lesser General Public License for more details. */ -/* */ -/* You should have received a copy of the GNU Lesser General Public License */ -/* along with this program. If not, see . */ -/* */ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -#ifndef _PAPILO_CORE_PRESOLVE_HPP_ -#define _PAPILO_CORE_PRESOLVE_HPP_ - -#include -#include -#include -#include -#include -#include - -#include -#include - -#include "papilo/core/PresolveMethod.hpp" -#include "papilo/core/PresolveOptions.hpp" -#include "papilo/core/Problem.hpp" -#include "papilo/core/ProblemUpdate.hpp" -#include "papilo/core/Statistics.hpp" -#include "papilo/core/postsolve/Postsolve.hpp" -#include "papilo/core/postsolve/PostsolveStorage.hpp" -#include "papilo/interfaces/SolverInterface.hpp" -#include "papilo/io/Message.hpp" -#include "papilo/misc/DependentRows.hpp" -#include "papilo/misc/ParameterSet.hpp" -#include "papilo/misc/Timer.hpp" -#include "papilo/misc/Vec.hpp" -#ifdef PAPILO_TBB -#include "papilo/misc/tbb.hpp" -#endif -#include "papilo/presolvers/CoefficientStrengthening.hpp" -#include "papilo/presolvers/ConstraintPropagation.hpp" -#include "papilo/presolvers/DominatedCols.hpp" -#include "papilo/presolvers/DualFix.hpp" -#include "papilo/presolvers/DualInfer.hpp" -#include "papilo/presolvers/FixContinuous.hpp" -#include "papilo/presolvers/FreeVarSubstitution.hpp" -#include "papilo/presolvers/ImplIntDetection.hpp" -#include "papilo/presolvers/ParallelColDetection.hpp" -#include "papilo/presolvers/ParallelRowDetection.hpp" -#include "papilo/presolvers/Probing.hpp" -#include "papilo/presolvers/SimpleProbing.hpp" -#include "papilo/presolvers/SimpleSubstitution.hpp" -#include "papilo/presolvers/SimplifyInequalities.hpp" -#include "papilo/presolvers/SingletonCols.hpp" -#include "papilo/presolvers/SingletonStuffing.hpp" -#include "papilo/presolvers/Sparsify.hpp" - -namespace papilo -{ - -template -struct PresolveResult -{ - PostsolveStorage postsolve; - PresolveStatus status; -}; - -enum class Delegator -{ - kAbort, - kFast, - kMedium, - kExhaustive, - kExceeded -}; - -template -class Presolve -{ - public: - void - - addDefaultPresolvers() - { - using uptr = std::unique_ptr>; - - // fast presolvers - addPresolveMethod( uptr( new SingletonCols() ) ); - addPresolveMethod( uptr( new CoefficientStrengthening() ) ); - addPresolveMethod( uptr( new ConstraintPropagation() ) ); - - //medium presolvers - addPresolveMethod( uptr( new SimpleProbing() ) ); - addPresolveMethod( uptr( new ParallelRowDetection() ) ); - addPresolveMethod( uptr( new ParallelColDetection() ) ); - addPresolveMethod( uptr( new SingletonStuffing() ) ); - addPresolveMethod( uptr( new DualFix() ) ); - addPresolveMethod( uptr( new FixContinuous() ) ); - addPresolveMethod( uptr( new SimplifyInequalities() ) ); - addPresolveMethod( uptr( new SimpleSubstitution() ) ); - - //exhaustive presolvers - addPresolveMethod( uptr( new ImplIntDetection() ) ); - addPresolveMethod( uptr( new DominatedCols() ) ); - addPresolveMethod( uptr( new DualInfer ) ); - addPresolveMethod( uptr( new Probing() ) ); - addPresolveMethod( uptr( new Substitution() ) ); - addPresolveMethod( uptr( new Sparsify() ) ); - } - - ParameterSet - getParameters() - { - ParameterSet paramSet; - msg.addParameters( paramSet ); - presolveOptions.addParameters( paramSet ); - - for( const std::unique_ptr>& presolver : presolvers ) - presolver->addParameters( paramSet ); - - return paramSet; - } - - /*** - * presolves the problem and applies the reductions found by the presolvers - * immediately to it. - * The functions returns the PresolveStatus (Reduced, Unchanged, ) and the - * postsolve information - * - * @tparam REAL: computational accuracy template - * @param problem: the problem to be presolved - * @return: presolved problem and PresolveResult contains postsolve - * information - */ - PresolveResult - apply( Problem& problem, bool store_dual_postsolve = true ); - - /// add presolve method to presolving - void - addPresolveMethod( std::unique_ptr> presolveMethod ) - { - presolvers.emplace_back( std::move( presolveMethod ) ); - } - - void - setLPSolverFactory( std::unique_ptr> value ) - { - this->lpSolverFactory = std::move( value ); - } - - void - setMIPSolverFactory( std::unique_ptr> value ) - { - this->mipSolverFactory = std::move( value ); - } - - const std::unique_ptr>& - getLPSolverFactory() const - { - return this->lpSolverFactory; - } - - const std::unique_ptr>& - getMIPSolverFactory() const - { - return this->mipSolverFactory; - } - - void - setPresolverOptions( const PresolveOptions& value ) - { - this->presolveOptions = value; - } - - const PresolveOptions& - getPresolveOptions() const - { - return this->presolveOptions; - } - - PresolveOptions& - getPresolveOptions() - { - return this->presolveOptions; - } - - /// get epsilon value for numerical comparisons - const REAL& - getEpsilon() const - { - return num.getEpsilon(); - } - - /// get feasibility tolerance value - const REAL& - getFeasTol() const - { - return num.getFeasTol(); - } - - /// set the verbosity level - void - setVerbosityLevel( VerbosityLevel verbosity ) - { - msg.setVerbosityLevel( verbosity ); - } - - /// get the verbosity level - VerbosityLevel - getVerbosityLevel() const - { - return msg.getVerbosityLevel(); - } - - const Message& - message() const - { - return msg; - } - - Message& - message() - { - return msg; - } - - /// access statistics of presolving - const Statistics& - getStatistics() const - { - return stats; - } - - std::pair - applyReductions( int p, const Reductions& reductions_, - ProblemUpdate& probUpdate ); - - private: - // data to perform presolving - Vec results; - Vec>> presolvers; - Vec> reductions; - Delegator round_to_evaluate; - - Vec*, const Reduction*>> - postponedReductions; - Vec postponedReductionToPresolver; - - // settings for presolve behavior - Num num; - Message msg; - PresolveOptions presolveOptions; - // statistics - Statistics stats; - - std::unique_ptr> lpSolverFactory; - std::unique_ptr> mipSolverFactory; - - Vec> presolverStats; - bool lastRoundReduced; - int nunsuccessful; - bool rundelayed; - - /// evaluate result array of each presolver, return the largest result value - PresolveStatus - evaluateResults(); - - void - finishRound( ProblemUpdate& probUpdate ); - - void - applyPostponed( ProblemUpdate& probUpdate ); - - Delegator - determine_next_round( Problem& problem, - ProblemUpdate& probUpdate, - const Statistics& roundStats, - const Timer& presolvetimer, bool unchanged = false ); - - PresolveStatus - apply_all_presolver_reductions( ProblemUpdate& probUpdate ); - - void - printRoundStats( bool unchanged, std::string rndtype ); - - void - printPresolversStats(); - - private: - void - logStatus( const Problem& problem, - const PostsolveStorage& postsolveStorage ) const; - - bool - is_time_exceeded( const Timer& presolvetimer ) const; - - bool - is_only_slighlty_changes( const Problem& problem, - const ProblemUpdate& probUpdate, - const Statistics& roundStats ) const; - - Delegator - increase_delegator( Delegator delegator ); - - std::string - get_round_type( Delegator delegator ); - - Delegator - increase_round_if_last_run_was_not_successfull( - const Problem& problem, const ProblemUpdate& probUpdate, - const Statistics& roundStats, bool unchanged ); - - Delegator - handle_case_exceeded( Delegator& next_round ); - - PresolveStatus - evaluate_and_apply( const Timer& timer, Problem& problem, - PresolveResult& result, - ProblemUpdate& probUpdate, - const Statistics& oldstats, bool run_sequential ); - - void - apply_reduction_of_solver( ProblemUpdate& probUpdate, - size_t index_presolver ); - - void - apply_result_sequential( int index_presolver, - ProblemUpdate& probUpdate, - bool& run_sequential ); - - void - run_presolvers( const Problem& problem, - const std::pair& presolver_2_run, - ProblemUpdate& probUpdate, bool& run_sequential, const Timer& timer ); - - bool - is_status_infeasible_or_unbounded( const PresolveStatus& status ) const; - - bool - are_only_dual_postsolve_presolvers_enabled(); -}; - -#ifdef PAPILO_USE_EXTERN_TEMPLATES -extern template class Presolve; -extern template class Presolve; -extern template class Presolve; -#endif - -/*** - * presolves the problem and applies the reductions found by the presolvers - * immediately to it. - * The functions returns the PresolveStatus (Reduced, Unchanged, ) and the - * postsolve information - * - * @tparam REAL: computational accuracy template - * @param problem: the problem to be presolved - * @param store_dual_postsolve: should dual postsolve reductions stored in the postsolve stack - * @return: presolved problem and PresolveResult contains postsolve information - */ -template -PresolveResult -Presolve::apply( Problem& problem, bool store_dual_postsolve ) -{ -#ifdef PAPILO_TBB - tbb::task_arena arena( presolveOptions.threads == 0 - ? tbb::task_arena::automatic - : presolveOptions.threads ); -#endif - -#ifdef PAPILO_TBB - return arena.execute( [this, &problem, store_dual_postsolve]() { -#endif - stats = Statistics(); - num.setFeasTol( REAL{ presolveOptions.feastol } ); - num.setEpsilon( REAL{ presolveOptions.epsilon } ); - num.setHugeVal( REAL{ presolveOptions.hugeval } ); - - Timer timer( stats.presolvetime ); - - ConstraintMatrix& constraintMatrix = problem.getConstraintMatrix(); - Vec& rhsVals = constraintMatrix.getRightHandSides(); - Vec& rflags = constraintMatrix.getRowFlags(); - const Vec& rowsize = constraintMatrix.getRowSizes(); - - msg.info( "\nstarting presolve of problem {}:\n", problem.getName() ); - msg.info( " rows: {}\n", problem.getNRows() ); - msg.info( " columns: {}\n", problem.getNCols() ); - msg.info( " int. columns: {}\n", problem.getNumIntegralCols() ); - msg.info( " cont. columns: {}\n", problem.getNumContinuousCols() ); - msg.info( " nonzeros: {}\n\n", problem.getConstraintMatrix().getNnz() ); - - PresolveResult result; - - result.postsolve = - PostsolveStorage( problem, num, presolveOptions ); - -#ifndef PAPILO_TBB - if( presolveOptions.threads != 1 ) - msg.warn( "PaPILO without TBB can only use one thread. Number of " - "threads is set to 1\n" ); - presolveOptions.threads = 1; -#endif - - if( store_dual_postsolve && problem.getNumIntegralCols() == 0 ) - { - if( presolveOptions.componentsmaxint == -1 && presolveOptions.detectlindep == 0 && - are_only_dual_postsolve_presolvers_enabled()) - result.postsolve.postsolveType = PostsolveType::kFull; - else - { - msg.error( - "Please turn off the presolvers substitution and sparsify and " - "componentsdetection to use dual postsolving\n" ); - return result; - } - } - result.status = PresolveStatus::kUnchanged; - - std::stable_sort( presolvers.begin(), presolvers.end(), - []( const std::unique_ptr>& a, - const std::unique_ptr>& b ) { - return static_cast( a->getTiming() ) < - static_cast( b->getTiming() ); - } ); - - std::pair fastPresolvers; - std::pair mediumPresolvers; - std::pair exhaustivePresolvers; - - int npresolvers = static_cast( presolvers.size() ); - - fastPresolvers.first = fastPresolvers.second = 0; - while( fastPresolvers.second < npresolvers && - presolvers[fastPresolvers.second]->getTiming() == - PresolverTiming::kFast ) - ++fastPresolvers.second; - - mediumPresolvers.first = mediumPresolvers.second = fastPresolvers.second; - while( mediumPresolvers.second < npresolvers && - presolvers[mediumPresolvers.second]->getTiming() == - PresolverTiming::kMedium ) - ++mediumPresolvers.second; - - exhaustivePresolvers.first = exhaustivePresolvers.second = - mediumPresolvers.second; - while( exhaustivePresolvers.second < npresolvers && - presolvers[exhaustivePresolvers.second]->getTiming() == - PresolverTiming::kExhaustive ) - ++exhaustivePresolvers.second; - - reductions.resize( presolvers.size() ); - results.resize( presolvers.size() ); - - round_to_evaluate = Delegator::kFast; - - presolverStats.resize( presolvers.size(), std::pair( 0, 0 ) ); - - ProblemUpdate probUpdate( problem, result.postsolve, stats, - presolveOptions, num, msg ); - - for( int i = 0; i != npresolvers; ++i ) - { - if( presolvers[i]->isEnabled() ) - { - if( presolvers[i]->initialize( problem, presolveOptions ) ) - probUpdate.observeCompress( presolvers[i].get() ); - } - } - - result.status = probUpdate.trivialPresolve(); - - if( result.status == PresolveStatus::kInfeasible || - result.status == PresolveStatus::kUnbndOrInfeas || - result.status == PresolveStatus::kUnbounded ) - return result; - - printRoundStats( false, "Trivial" ); - round_to_evaluate = Delegator::kFast; - - finishRound( probUpdate ); - ++stats.nrounds; - - nunsuccessful = 0; - rundelayed = true; - for( int i = 0; i < npresolvers; ++i ) - { - if( presolvers[i]->isEnabled() && presolvers[i]->isDelayed() ) - { - rundelayed = false; - break; - } - } - - Statistics last_rounds_stats = stats; - do - { - bool was_executed_sequential = false; - // if problem is trivial abort here - if( probUpdate.getNActiveCols() == 0 || - probUpdate.getNActiveRows() == 0 ) - break; - - switch( round_to_evaluate ) - { - case Delegator::kFast: - run_presolvers( problem, fastPresolvers, probUpdate, - was_executed_sequential, timer ); - break; - case Delegator::kMedium: - run_presolvers( problem, mediumPresolvers, probUpdate, - was_executed_sequential, timer ); - break; - case Delegator::kExhaustive: - run_presolvers( problem, exhaustivePresolvers, probUpdate, - was_executed_sequential, timer ); - break; - default: - assert( false ); - } - - result.status = - evaluate_and_apply( timer, problem, result, probUpdate, - last_rounds_stats, was_executed_sequential ); - if( is_status_infeasible_or_unbounded( result.status ) ) - return result; - last_rounds_stats = stats; - - } while( round_to_evaluate != Delegator::kAbort ); - - if( stats.ntsxapplied > 0 || stats.nboundchgs > 0 || - stats.ncoefchgs > 0 || stats.ndeletedcols > 0 || - stats.ndeletedrows > 0 || stats.nsidechgs > 0 ) - { - result.status = probUpdate.trivialPresolve(); - - if( result.status == PresolveStatus::kInfeasible || - result.status == PresolveStatus::kUnbndOrInfeas || - result.status == PresolveStatus::kUnbounded ) - return result; - - probUpdate.clearStates(); - probUpdate.check_and_compress(); - } - - printPresolversStats(); - - if( DependentRows::Enabled && - ( presolveOptions.detectlindep == 2 || - ( problem.getNumIntegralCols() == 0 && - presolveOptions.detectlindep == 1 ) ) ) - { - ConstraintMatrix& consMatrix = problem.getConstraintMatrix(); - Vec equations; - - equations.reserve( problem.getNRows() ); - size_t eqnnz = 0; - - for( int i = 0; i != problem.getNRows(); ++i ) - { - if( rflags[i].test( RowFlag::kRedundant ) || - !rflags[i].test( RowFlag::kEquation ) ) - continue; - - equations.push_back( i ); - eqnnz += rowsize[i] + 1; - } - - if( !equations.empty() ) - { - DependentRows depRows( equations.size(), problem.getNCols(), - eqnnz ); - - for( size_t i = 0; i != equations.size(); ++i ) - depRows.addRow( i, consMatrix.getRowCoefficients( equations[i] ), - REAL( rhsVals[equations[i]] ) ); - - Vec dependentEqs; - double factorTime = 0.0; - msg.info( "found {} equations, checking for linear dependency\n", - equations.size() ); - { - Timer t{ factorTime }; - dependentEqs = depRows.getDependentRows( msg, num ); - } - msg.info( "{} equations are redundant, factorization took {} " - "seconds\n", - dependentEqs.size(), factorTime ); - - if( !dependentEqs.empty() ) - { - for( int dependentEq : dependentEqs ) - { - probUpdate.markRowRedundant( equations[dependentEq] ); - } - probUpdate.flush( true ); - } - } - - if( presolveOptions.dualreds == 2 ) - { - Vec freeCols; - freeCols.reserve( problem.getNCols() ); - size_t freeColNnz = 0; - - const Vec& cflags = problem.getColFlags(); - const Vec& colsize = problem.getColSizes(); - const Vec& obj = problem.getObjective().coefficients; - - for( int col = 0; col != problem.getNCols(); ++col ) - { - if( cflags[col].test( ColFlag::kInactive, ColFlag::kIntegral ) || - !cflags[col].test( ColFlag::kLbInf ) || - !cflags[col].test( ColFlag::kUbInf ) ) - continue; - - freeCols.push_back( col ); - freeColNnz += colsize[col] + 1; - } - - if( !freeCols.empty() ) - { - DependentRows depRows( freeCols.size(), problem.getNRows(), - freeColNnz ); - - for( size_t i = 0; i != freeCols.size(); ++i ) - depRows.addRow( - i, consMatrix.getColumnCoefficients( freeCols[i] ), - obj[freeCols[i]] ); - - Vec dependentFreeCols; - double factorTime = 0.0; - msg.info( - "found {} free columns, checking for linear dependency\n", - freeCols.size(), freeColNnz ); - - { - Timer t{ factorTime }; - dependentFreeCols = depRows.getDependentRows( msg, num ); - } - - msg.info( "{} free columns are redundant, factorization took {} " - "seconds\n", - dependentFreeCols.size(), factorTime ); - - if( !dependentFreeCols.empty() ) - { - for( int dependentFreeCol : dependentFreeCols ) - probUpdate.fixCol( freeCols[dependentFreeCol], 0 ); - - probUpdate.flush( true ); - } - } - } - } - - // finally compress problem fully and release excess storage even if - // problem was not reduced - probUpdate.compress( true ); - - // check whether problem was reduced - if( stats.ntsxapplied > 0 || stats.nboundchgs > 0 || - stats.ncoefchgs > 0 || stats.ndeletedcols > 0 || - stats.ndeletedrows > 0 || stats.nsidechgs > 0 ) - { - if( presolveOptions.boundrelax && problem.getNumIntegralCols() == 0 ) - { - int nremoved; - int nnewfreevars; - - std::tie( nremoved, nnewfreevars ) = - probUpdate.removeRedundantBounds(); - if( nremoved != 0 ) - msg.info( "removed {} redundant column bounds, got {} new free " - "variables\n", - nremoved, nnewfreevars ); - } - - bool detectComponents = presolveOptions.componentsmaxint != -1; - - if( !lpSolverFactory && problem.getNumContinuousCols() != 0 ) - detectComponents = false; - - if( !mipSolverFactory && problem.getNumIntegralCols() != 0 ) - detectComponents = false; - - if( problem.getNCols() == 0 ) - detectComponents = false; - - if( detectComponents && probUpdate.getNActiveCols() > 0 ) - { - assert( problem.getNCols() != 0 && problem.getNRows() != 0 ); - Components components; - - int ncomponents = components.detectComponents( problem ); - - if( ncomponents > 1 ) - { - const Vec& compInfo = - components.getComponentInfo(); - - msg.info( "found {} disconnected components\n", ncomponents ); - msg.info( - "largest component has {} cols ({} int., {} cont.) and " - "{} nonzeros\n", - compInfo[ncomponents - 1].nintegral + - compInfo[ncomponents - 1].ncontinuous, - compInfo[ncomponents - 1].nintegral, - compInfo[ncomponents - 1].ncontinuous, - compInfo[ncomponents - 1].nnonz ); - - Solution solution; - solution.primal.resize( problem.getNCols() ); - Vec componentSolved( ncomponents ); - - if( result.postsolve.postsolveType == PostsolveType::kFull ) - { - solution.type = SolutionType::kPrimalDual; - solution.reducedCosts.resize( problem.getNCols() ); - solution.dual.resize( problem.getNRows() ); - solution.varBasisStatus.resize( problem.getNCols() ); - } - -#ifdef PAPILO_TBB - tbb::parallel_for( - tbb::blocked_range( 0, ncomponents - 1 ), - [this, &components, &solution, &problem, &result, &compInfo, - &componentSolved, - &timer]( const tbb::blocked_range& r ) { - for( int i = r.begin(); i != r.end(); ++i ) -#else - for( int i = 0; i < ncomponents - 1; ++i ) - -#endif - { - if( compInfo[i].nintegral == 0 ) - { - std::unique_ptr> solver = - lpSolverFactory->newSolver( - VerbosityLevel::kQuiet ); - - solver->setUp( problem, - result.postsolve.origrow_mapping, - result.postsolve.origcol_mapping, - components, compInfo[i] ); - - if( presolveOptions.tlim != - std::numeric_limits::max() ) - { - double tlim = - presolveOptions.tlim - timer.getTime(); - if( tlim <= 0 ) - break; - solver->setTimeLimit( tlim ); - } - - solver->solve(); - - SolverStatus status = solver->getStatus(); - - if( status == SolverStatus::kOptimal ) - { - if( solver->getSolution( components, - compInfo[i].componentid, - solution ) ) - componentSolved[compInfo[i].componentid] = - true; - } - } - else if( compInfo[i].nintegral <= - presolveOptions.componentsmaxint ) - { - std::unique_ptr> solver = - mipSolverFactory->newSolver( - VerbosityLevel::kQuiet ); - - solver->setGapLimit( 0 ); - solver->setNodeLimit( - problem.getConstraintMatrix().getNnz() / - std::max( compInfo[i].nnonz, 1 ) ); - - solver->setUp( problem, - result.postsolve.origrow_mapping, - result.postsolve.origcol_mapping, - components, compInfo[i] ); - - if( presolveOptions.tlim != - std::numeric_limits::max() ) - { - double tlim = - presolveOptions.tlim - timer.getTime(); - if( tlim <= 0 ) - break; - solver->setTimeLimit( tlim ); - } - - solver->solve(); - - SolverStatus status = solver->getStatus(); - - if( status == SolverStatus::kOptimal ) - { - if( solver->getSolution( components, - compInfo[i].componentid, - solution ) ) - componentSolved[compInfo[i].componentid] = - true; - } - } - } -#ifdef PAPILO_TBB - } - ,tbb::simple_partitioner() ); -#endif - - int nsolved = 0; - - int oldndelcols = stats.ndeletedcols; - int oldndelrows = stats.ndeletedrows; - - auto& lbs = problem.getLowerBounds(); - auto& ubs = problem.getUpperBounds(); - for( int i = 0; i != ncomponents; ++i ) - { - if( componentSolved[i] ) - { - ++nsolved; - - const int* compcols = components.getComponentsCols( i ); - int numcompcols = components.getComponentsNumCols( i ); - - for( int j = 0; j != numcompcols; ++j ) - { - const int col = compcols[j]; - lbs[compcols[j]] = solution.primal[col]; - ubs[compcols[j]] = solution.primal[col]; - probUpdate.markColFixed( col ); - if( result.postsolve.postsolveType == - PostsolveType::kFull ) - result.postsolve.storeDualValue( - true, col, solution.reducedCosts[col] ); - } - - const int* comprows = components.getComponentsRows( i ); - int numcomprows = components.getComponentsNumRows( i ); - - for( int j = 0; j != numcomprows; ++j ) - { - probUpdate.markRowRedundant( comprows[j] ); - } - } - } - - if( nsolved != 0 ) - { - if( probUpdate.flush( true ) == PresolveStatus::kInfeasible ) - assert( false ); - - probUpdate.compress(); - - msg.info( "solved {} components: {} cols fixed, {} rows " - "deleted\n", - nsolved, stats.ndeletedcols - oldndelcols, - stats.ndeletedrows - oldndelrows ); - } - } - } - - logStatus( problem, result.postsolve ); - result.status = PresolveStatus::kReduced; - if( result.postsolve.postsolveType == PostsolveType::kFull ) - { - auto& coefficients = problem.getObjective().coefficients; - auto& col_lower = problem.getLowerBounds(); - auto& col_upper = problem.getUpperBounds(); - auto& row_lhs = problem.getConstraintMatrix().getLeftHandSides(); - auto& row_rhs = problem.getConstraintMatrix().getRightHandSides(); - auto& row_flags = problem.getRowFlags(); - auto& col_flags = problem.getColFlags(); - - result.postsolve.storeReducedBoundsAndCost( - col_lower, col_upper, row_lhs, row_rhs, coefficients, row_flags, - col_flags ); - } - - return result; - } - - logStatus( problem, result.postsolve ); - - // problem was not changed - result.status = PresolveStatus::kUnchanged; - return result; -#ifdef PAPILO_TBB - } ); -#endif -} - -template -void -Presolve::run_presolvers( const Problem& problem, - const std::pair& presolver_2_run, - ProblemUpdate& probUpdate, - bool& run_sequential, const Timer& timer ) -{ -#ifndef PAPILO_TBB - assert(presolveOptions.runs_sequential() == true); -#endif - if( presolveOptions.runs_sequential() && - presolveOptions.apply_results_immediately_if_run_sequentially ) - { - probUpdate.setPostponeSubstitutions( false ); - for( int i = presolver_2_run.first; i != presolver_2_run.second; ++i ) - { - results[i] = - presolvers[i]->run( problem, probUpdate, num, reductions[i], timer ); - apply_result_sequential( i, probUpdate, run_sequential ); - if( results[i] == PresolveStatus::kInfeasible ) - return; - if( problem.getNRows() == 0 || problem.getNCols() == 0 ) - return; - } - PresolveStatus status = probUpdate.trivialPresolve(); - if( is_status_infeasible_or_unbounded( status ) ) - { - results[presolver_2_run.first] = status; - return; - } - probUpdate.clearStates(); - probUpdate.check_and_compress(); - } -#ifdef PAPILO_TBB - else - { - tbb::parallel_for( - tbb::blocked_range( presolver_2_run.first, - presolver_2_run.second ), - [&]( const tbb::blocked_range& r ) { - for( int i = r.begin(); i != r.end(); ++i ) - { - results[i] = presolvers[i]->run( problem, probUpdate, num, - reductions[i], timer ); - } - }, - tbb::simple_partitioner() ); - } -#endif -} - -template -void -Presolve::apply_result_sequential( int index_presolver, - ProblemUpdate& probUpdate, - bool& run_sequential ) -{ - run_sequential = true; - apply_reduction_of_solver( probUpdate, index_presolver ); - probUpdate.flushChangedCoeffs(); - if( probUpdate.flush( false ) == PresolveStatus::kInfeasible ) - { - results[index_presolver] = PresolveStatus::kInfeasible; - return; - } - probUpdate.clearStates(); -} - -template -Delegator -Presolve::determine_next_round( Problem& problem, - ProblemUpdate& probUpdate, - const Statistics& roundStats, - const Timer& presolvetimer, - bool unchanged ) -{ - if( is_time_exceeded( presolvetimer ) ) - return Delegator::kAbort; - - Delegator next_round = increase_round_if_last_run_was_not_successfull( - problem, probUpdate, roundStats, unchanged ); - - next_round = handle_case_exceeded( next_round ); - - assert( next_round != Delegator::kExceeded ); - return next_round; -} - -template -PresolveStatus -Presolve::evaluate_and_apply( const Timer& timer, Problem& problem, - PresolveResult& result, - ProblemUpdate& probUpdate, - const Statistics& oldstats, - bool run_sequential ) -{ - if( round_to_evaluate == Delegator::kFast ) - { - probUpdate.clearChangeInfo(); - lastRoundReduced = false; - } - - result.status = evaluateResults(); - switch( result.status ) - { - case PresolveStatus::kUnbndOrInfeas: - case PresolveStatus::kUnbounded: - case PresolveStatus::kInfeasible: - printPresolversStats(); - return result.status; - case PresolveStatus::kUnchanged: - round_to_evaluate = determine_next_round( - problem, probUpdate, ( stats - oldstats ), timer, true ); - return result.status; - case PresolveStatus::kReduced: - // problem reductions where found by at least one presolver - PresolveStatus status; - if( !run_sequential ) - status = apply_all_presolver_reductions( probUpdate ); - else - status = PresolveStatus::kReduced; - if( is_status_infeasible_or_unbounded( status ) ) - return status; - round_to_evaluate = determine_next_round( problem, probUpdate, - ( stats - oldstats ), timer ); - finishRound( probUpdate ); - return status; - } - return result.status; -} - -template -bool -Presolve::is_status_infeasible_or_unbounded( - const PresolveStatus& status ) const -{ - return status == PresolveStatus::kUnbndOrInfeas || - status == PresolveStatus::kUnbounded || - status == PresolveStatus::kInfeasible; -} - -template -PresolveStatus -Presolve::apply_all_presolver_reductions( - ProblemUpdate& probUpdate ) -{ - probUpdate.setPostponeSubstitutions( true ); - - postponedReductionToPresolver.push_back( 0 ); - - for( std::size_t i = 0; i < presolvers.size(); ++i ) - { - apply_reduction_of_solver( probUpdate, i ); - postponedReductionToPresolver.push_back( postponedReductions.size() ); - } - - PresolveStatus status = evaluateResults(); - if( is_status_infeasible_or_unbounded( status ) ) - return status; - - probUpdate.flushChangedCoeffs(); - - applyPostponed( probUpdate ); - - return probUpdate.flush( true ); -} - -template -void -Presolve::apply_reduction_of_solver( ProblemUpdate& probUpdate, - size_t index_presolver ) -{ - if( results[index_presolver] != PresolveStatus::kReduced ) - return; - - Message::debug( this, "applying reductions of presolver {}\n", - presolvers[index_presolver]->getName() ); - - auto statistics = applyReductions( index_presolver, - reductions[index_presolver], probUpdate ); - - // if infeasible it returns -1 -1 - if( statistics.first >= 0 && statistics.second >= 0 ) - { - presolverStats[index_presolver].first += statistics.first; - presolverStats[index_presolver].second += statistics.second; - } - else - results[index_presolver] = PresolveStatus::kInfeasible; -} - -template -std::pair -Presolve::applyReductions( int p, const Reductions& reductions_, - ProblemUpdate& probUpdate ) -{ - int k = 0; - ApplyResult result; - int nbtsxAppliedStart = stats.ntsxapplied; - int nbtsxTotal = 0; - - const auto& reds = reductions_.getReductions(); - - msg.detailed( "Presolver {} applying \n", presolvers[p]->getName() ); - - for( const auto& transaction : reductions_.getTransactions() ) - { - int start = transaction.start; - int end = transaction.end; - - for( ; k != start; ++k ) - { - result = probUpdate.applyTransaction( &reds[k], &reds[k + 1] ); - if( result == ApplyResult::kApplied ) - ++stats.ntsxapplied; - else if( result == ApplyResult::kRejected ) - ++stats.ntsxconflicts; - else if( result == ApplyResult::kInfeasible ) - return std::make_pair( -1, -1 ); - else if( result == ApplyResult::kPostponed ) - postponedReductions.emplace_back( &reds[k], &reds[k + 1] ); - - ++nbtsxTotal; - } - - result = probUpdate.applyTransaction( &reds[start], &reds[end] ); - if( result == ApplyResult::kApplied ) - ++stats.ntsxapplied; - else if( result == ApplyResult::kRejected ) - ++stats.ntsxconflicts; - else if( result == ApplyResult::kInfeasible ) - return std::make_pair( -1, -1 ); - else if( result == ApplyResult::kPostponed ) - postponedReductions.emplace_back( &reds[start], &reds[end] ); - - k = end; - ++nbtsxTotal; - } - - for( ; k != static_cast( reds.size() ); ++k ) - { - result = probUpdate.applyTransaction( &reds[k], &reds[k + 1] ); - if( result == ApplyResult::kApplied ) - ++stats.ntsxapplied; - else if( result == ApplyResult::kRejected ) - ++stats.ntsxconflicts; - else if( result == ApplyResult::kInfeasible ) - return std::make_pair( -1, -1 ); - else if( result == ApplyResult::kPostponed ) - postponedReductions.emplace_back( &reds[k], &reds[k + 1] ); - - ++nbtsxTotal; - } - - return { nbtsxTotal, ( stats.ntsxapplied - nbtsxAppliedStart ) }; -} - -template -void -Presolve::applyPostponed( ProblemUpdate& probUpdate ) -{ - probUpdate.setPostponeSubstitutions( false ); - - for( int presolver = 0; presolver != (int) presolvers.size(); ++presolver ) - { - int first = postponedReductionToPresolver[presolver]; - int last = postponedReductionToPresolver[presolver + 1]; - if( first < last ) - msg.detailed( "Presolver {} applying \n", - presolvers[presolver]->getName() ); - for( int i = first; i != last; ++i ) - { - const auto& ptrpair = postponedReductions[i]; - - ApplyResult r = - probUpdate.applyTransaction( ptrpair.first, ptrpair.second ); - if( r == ApplyResult::kApplied ) - { - ++stats.ntsxapplied; - ++presolverStats[presolver].second; - } - else if( r == ApplyResult::kRejected ) - ++stats.ntsxconflicts; - } - } - - postponedReductions.clear(); - postponedReductionToPresolver.clear(); -} - -template -void -Presolve::finishRound( ProblemUpdate& probUpdate ) -{ - probUpdate.clearStates(); - probUpdate.check_and_compress(); - - for( auto& reduction : reductions ) - reduction.clear(); - - std::fill( results.begin(), results.end(), PresolveStatus::kUnchanged ); -} - -template -Delegator -Presolve::handle_case_exceeded( Delegator& next_round ) -{ - if( next_round != Delegator::kExceeded ) - return next_round; - - ++nunsuccessful; - - if( !( rundelayed && ( !lastRoundReduced || nunsuccessful == 2 ) ) ) - { - printRoundStats( !lastRoundReduced, "Exhaustive" ); - if( !rundelayed ) - { - msg.info( "activating delayed presolvers\n" ); - for( auto& p : presolvers ) - p->setDelayed( false ); - rundelayed = true; - } - ++stats.nrounds; - return Delegator::kFast; - } - printRoundStats( !lastRoundReduced, get_round_type( next_round ) ); - return Delegator::kAbort; -} - -template -bool -Presolve::is_time_exceeded( const Timer& presolvetimer ) const -{ - return presolveOptions.tlim != std::numeric_limits::max() && - presolvetimer.getTime() >= presolveOptions.tlim; -} - -template -bool -Presolve::is_only_slighlty_changes( const Problem& problem, - const ProblemUpdate& probUpdate, - const Statistics& roundStats ) const -{ - double abort_factor = problem.getNumIntegralCols() == 0 - ? presolveOptions.lpabortfac - : presolveOptions.abortfac; - return ( 0.1 * roundStats.nboundchgs + roundStats.ndeletedcols ) <= - abort_factor * probUpdate.getNActiveCols() && - ( roundStats.nsidechgs + roundStats.ndeletedrows ) <= - abort_factor * probUpdate.getNActiveRows() && - ( roundStats.ncoefchgs <= - abort_factor * problem.getConstraintMatrix().getNnz() ); -} - -template -Delegator -Presolve::increase_round_if_last_run_was_not_successfull( - const Problem& problem, const ProblemUpdate& probUpdate, - const Statistics& roundStats, bool unchanged ) -{ - Delegator next_round; - if( !unchanged ) - { - if( is_only_slighlty_changes( problem, probUpdate, roundStats ) ) - { - lastRoundReduced = - lastRoundReduced || roundStats.nsidechgs > 0 || - roundStats.nboundchgs > 0 || roundStats.ndeletedcols > 0 || - roundStats.ndeletedrows > 0 || roundStats.ncoefchgs > 0; - next_round = increase_delegator( round_to_evaluate ); - } - else - { - printRoundStats( false, get_round_type( round_to_evaluate ) ); - lastRoundReduced = true; - next_round = Delegator::kFast; - nunsuccessful = 0; - ++stats.nrounds; - } - } - else - next_round = increase_delegator( round_to_evaluate ); - return next_round; -} - -template -Delegator -Presolve::increase_delegator( Delegator delegator ) -{ - switch( delegator ) - { - case Delegator::kFast: - return Delegator::kMedium; - case Delegator::kMedium: - return Delegator::kExhaustive; - case Delegator::kAbort: - case Delegator::kExhaustive: - case Delegator::kExceeded: - break; - } - return Delegator::kExceeded; -} - -template -PresolveStatus -Presolve::evaluateResults() -{ - int largestValue = static_cast( PresolveStatus::kUnchanged ); - - for( auto& i : results ) - largestValue = std::max( largestValue, static_cast( i ) ); - - return static_cast( largestValue ); -} - -template -void -Presolve::printRoundStats( bool unchanged, std::string rndtype ) -{ - - if( unchanged ) - { - msg.info( "round {:<3} ({:^10}): Unchanged\n", stats.nrounds, rndtype ); - return; - } - - msg.info( "round {:<3} ({:^10}): {:>4} del cols, {:>4} del rows, " - "{:>4} chg bounds, {:>4} chg sides, {:>4} chg coeffs, " - "{:>4} tsx applied, {:>4} tsx conflicts\n", - stats.nrounds, rndtype, stats.ndeletedcols, stats.ndeletedrows, - stats.nboundchgs, stats.nsidechgs, stats.ncoefchgs, - stats.ntsxapplied, stats.ntsxconflicts ); -} -template -void -Presolve::printPresolversStats() -{ - msg.info( "presolved {} rounds: {:>4} del cols, {:>4} del rows, " - "{:>4} chg bounds, {:>4} chg sides, {:>4} chg coeffs, " - "{:>4} tsx applied, {:>4} tsx conflicts\n", - stats.nrounds, stats.ndeletedcols, stats.ndeletedrows, - stats.nboundchgs, stats.nsidechgs, stats.ncoefchgs, - stats.ntsxapplied, stats.ntsxconflicts ); - msg.info( "\n {:>18} {:>12} {:>18} {:>18} {:>18} {:>18} \n", "presolver", - "nb calls", "success calls(%)", "nb transactions", - "tsx applied(%)", "execution time(s)" ); - for( std::size_t i = 0; i < presolvers.size(); ++i ) - { - presolvers[i]->printStats( msg, presolverStats[i] ); - } - - msg.info( "\n" ); -} - -template -void -Presolve::logStatus( const Problem& problem, - const PostsolveStorage& postsolveStorage ) const -{ - if(msg.getVerbosityLevel() == VerbosityLevel::kQuiet) - return; - msg.info( "reduced problem:\n" ); - msg.info( " reduced rows: {}\n", problem.getNRows() ); - msg.info( " reduced columns: {}\n", problem.getNCols() ); - msg.info( " reduced int. columns: {}\n", problem.getNumIntegralCols() ); - msg.info( " reduced cont. columns: {}\n", problem.getNumContinuousCols() ); - msg.info( " reduced nonzeros: {}\n", - problem.getConstraintMatrix().getNnz() ); - if( problem.getNCols() == 0) - { - // the primaldual can be disabled therefore calculate only primal for obj - Solution solution{}; - SolutionType type = postsolveStorage.postsolveType == PostsolveType::kFull - ? SolutionType::kPrimalDual - : SolutionType::kPrimal; - Solution empty_sol{ type }; - Postsolve postsolve{ msg, num }; - postsolve.undo( empty_sol, solution, postsolveStorage ); - const Problem& origprob = postsolveStorage.getOriginalProblem(); - REAL origobj = origprob.computeSolObjective( solution.primal ); - msg.info( - "problem is solved [optimal solution found] [objective value: {} (double precision)]\n", - (double) origobj ); - } -} - -template -std::string -Presolve::get_round_type( Delegator delegator ) -{ - switch( delegator ) - { - case Delegator::kFast: - return "Fast"; - case Delegator::kMedium: - return "Medium"; - case Delegator::kExhaustive: - return "Exhaustive"; - case Delegator::kExceeded: - return "Final"; - case Delegator::kAbort: - break; - } - return "Undefined"; -} - -template -bool -Presolve::are_only_dual_postsolve_presolvers_enabled() -{ - for( int i = 0; i < (int) presolvers.size(); i++ ) - { - if( presolvers[i]->isEnabled() ) - { - if( presolvers[i]->getName().compare( "substitution" ) == 0 || - presolvers[i]->getName().compare( "sparsify" ) == 0 || - presolvers[i]->getName().compare( "dualinfer" ) == 0 || - presolvers[i]->getName().compare( "doubletoneq" ) == 0 ) - return false; - } - } - return true; -} - -} // namespace papilo - -#endif diff --git a/headers/papilo/core/PresolveMethod.hpp b/headers/papilo/core/PresolveMethod.hpp deleted file mode 100644 index 0296432..0000000 --- a/headers/papilo/core/PresolveMethod.hpp +++ /dev/null @@ -1,329 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* */ -/* This file is part of the program and library */ -/* PaPILO --- Parallel Presolve for Integer and Linear Optimization */ -/* */ -/* Copyright (C) 2020-2022 Konrad-Zuse-Zentrum */ -/* fuer Informationstechnik Berlin */ -/* */ -/* This program is free software: you can redistribute it and/or modify */ -/* it under the terms of the GNU Lesser General Public License as published */ -/* by the Free Software Foundation, either version 3 of the License, or */ -/* (at your option) any later version. */ -/* */ -/* This program is distributed in the hope that it will be useful, */ -/* but WITHOUT ANY WARRANTY; without even the implied warranty of */ -/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ -/* GNU Lesser General Public License for more details. */ -/* */ -/* You should have received a copy of the GNU Lesser General Public License */ -/* along with this program. If not, see . */ -/* */ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -#ifndef _PAPILO_CORE_PRESOLVE_METHOD_HPP_ -#define _PAPILO_CORE_PRESOLVE_METHOD_HPP_ - -#include "papilo/core/PresolveOptions.hpp" -#include "papilo/core/Reductions.hpp" -#include "papilo/core/RowFlags.hpp" -#include "papilo/core/VariableDomains.hpp" -#include "papilo/io/Message.hpp" -#include "papilo/misc/Num.hpp" -#include "papilo/misc/Vec.hpp" -#include "papilo/misc/fmt.hpp" -#include "papilo/misc/Timer.hpp" -#ifdef PAPILO_TBB -#include "papilo/misc/tbb.hpp" -#else -#include -#endif -#include - - -namespace papilo -{ - -// forward declaration of problem and reduction -template -class Presolve; - -template -class Problem; - -template -class ProblemUpdate; - -enum class PresolveStatus : int -{ - kUnchanged = 0, - - kReduced = 1, - - kUnbndOrInfeas = 2, - - kUnbounded = 3, - - kInfeasible = 4, -}; - -enum class PresolverTiming : int -{ - kFast = 0, - kMedium = 1, - kExhaustive = 2, -}; - -enum class PresolverType -{ - kAllCols, - kIntegralCols, - kContinuousCols, - kMixedCols, -}; - -template -class PresolveMethod -{ - public: - PresolveMethod() - { - ncalls = 0; - nsuccessCall = 0; - name = "unnamed"; - type = PresolverType::kAllCols; - timing = PresolverTiming::kExhaustive; - delayed = false; - execTime = 0.0; - enabled = true; - skip = 0; - nconsecutiveUnsuccessCall = 0; - } - - virtual ~PresolveMethod() = default; - - virtual void - compress( const Vec& rowmap, const Vec& colmap ) - { - } - - virtual bool - initialize( const Problem& problem, - const PresolveOptions& presolveOptions ) - { - return false; - } - - virtual void - addPresolverParams( ParameterSet& paramSet ) - { - } - - void - addParameters( ParameterSet& paramSet ) - { - paramSet.addParameter( - fmt::format( "{}.enabled", this->name ).c_str(), - fmt::format( "is presolver {} enabled", this->name ).c_str(), - this->enabled ); - - addPresolverParams( paramSet ); - } - - PresolveStatus - run( const Problem& problem, const ProblemUpdate& problemUpdate, - const Num& num, Reductions& reductions, const Timer& timer ) - { - if( !enabled || delayed ) - return PresolveStatus::kUnchanged; - - if( skip != 0 ) - { - --skip; - return PresolveStatus::kUnchanged; - } - - if( problem.getNumIntegralCols() == 0 && - ( type == PresolverType::kIntegralCols || - type == PresolverType::kMixedCols ) ) - return PresolveStatus::kUnchanged; - - if( problem.getNumContinuousCols() == 0 && - ( type == PresolverType::kContinuousCols || - type == PresolverType::kMixedCols ) ) - return PresolveStatus::kUnchanged; - - ++ncalls; - -#ifdef PAPILO_TBB - auto start = tbb::tick_count::now(); -#else - auto start = std::chrono::steady_clock::now(); -#endif - PresolveStatus result = - execute( problem, problemUpdate, num, reductions, timer ); -#ifdef PAPILO_TBB - auto end = tbb::tick_count::now(); - auto duration = end - start; - execTime = execTime + duration.seconds(); -#else - auto end = std::chrono::steady_clock::now(); - execTime = execTime + std::chrono::duration_cast( - end- start ).count()/1000; -#endif - - - switch( result ) - { - case PresolveStatus::kUnbounded: - case PresolveStatus::kUnbndOrInfeas: - case PresolveStatus::kInfeasible: - Message::debug( &problemUpdate, - "[{}:{}] {} detected unboundedness or infeasibility\n", - __FILE__, __LINE__, this->name ); - break; - case PresolveStatus::kReduced: - ++nsuccessCall; - nconsecutiveUnsuccessCall = 0; - break; - case PresolveStatus::kUnchanged: - ++nconsecutiveUnsuccessCall; - if( timing != PresolverTiming::kFast ) - skip += nconsecutiveUnsuccessCall; - break; - } - - return result; - } - - void - printStats( const Message& message, std::pair stats ) - { - double success = - ncalls == 0 ? 0.0 - : ( double( nsuccessCall ) / double( ncalls ) ) * 100.0; - double applied = - stats.first == 0 - ? 0.0 - : ( double( stats.second ) / double( stats.first ) ) * 100.0; - message.info( " {:>18} {:>12} {:>18.1f} {:>18} {:>18.1f} {:>18.3f}\n", - name, ncalls, success, stats.first, applied, execTime ); - } - - PresolverTiming - getTiming() const - { - return this->timing; - } - - bool - isEnabled() const - { - return this->enabled; - } - - bool - isDelayed() const - { - return this->delayed; - } - - const std::string& - getName() const - { - return this->name; - } - - unsigned int - getNCalls() const - { - return ncalls; - } - - void - setDelayed( bool value ) - { - this->delayed = value; - } - - void - setEnabled( bool value ) - { - this->enabled = value; - } - - protected: - /// execute member function for a presolve method gets the constant problem - /// and can communicate reductions via the given reductions object - virtual PresolveStatus - execute( const Problem& problem, - const ProblemUpdate& problemUpdate, const Num& num, - Reductions& reductions, const Timer& timer ) = 0; - - void - setName( const std::string& value ) - { - this->name = value; - } - - void - setTiming( PresolverTiming value ) - { - this->timing = value; - } - - void - setType( PresolverType value ) - { - this->type = value; - } - - static bool - is_time_exceeded( const Timer& timer, double tlim) - { - return tlim != std::numeric_limits::max() && - timer.getTime() >= tlim; - } - - void - skipRounds( unsigned int nrounds ) - { - this->skip += nrounds; - } - - template - void - loop( int start, int end, LOOP&& loop_instruction ) - { -#ifdef PAPILO_TBB - tbb::parallel_for( tbb::blocked_range( start, end ), - [&]( const tbb::blocked_range& r ) - { - for( int i = r.begin(); i != r.end(); ++i ) - loop_instruction( i ); - } ); -#else - for( int i = 0; i < end; i++ ) - { - loop_instruction( i ); - } -#endif - } - - private: - std::string name; - double execTime; - bool enabled; - bool delayed; - PresolverTiming timing; - PresolverType type; - unsigned int ncalls; - // number of times execute returns REDUCED - unsigned int nsuccessCall; - unsigned int nconsecutiveUnsuccessCall; - unsigned int skip; - }; - -} // namespace papilo - -#endif diff --git a/headers/papilo/core/PresolveOptions.hpp b/headers/papilo/core/PresolveOptions.hpp deleted file mode 100644 index 9ba9a65..0000000 --- a/headers/papilo/core/PresolveOptions.hpp +++ /dev/null @@ -1,239 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* */ -/* This file is part of the program and library */ -/* PaPILO --- Parallel Presolve for Integer and Linear Optimization */ -/* */ -/* Copyright (C) 2020-2022 Konrad-Zuse-Zentrum */ -/* fuer Informationstechnik Berlin */ -/* */ -/* This program is free software: you can redistribute it and/or modify */ -/* it under the terms of the GNU Lesser General Public License as published */ -/* by the Free Software Foundation, either version 3 of the License, or */ -/* (at your option) any later version. */ -/* */ -/* This program is distributed in the hope that it will be useful, */ -/* but WITHOUT ANY WARRANTY; without even the implied warranty of */ -/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ -/* GNU Lesser General Public License for more details. */ -/* */ -/* You should have received a copy of the GNU Lesser General Public License */ -/* along with this program. If not, see . */ -/* */ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -#ifndef _PAPILO_CORE_PRESOLVE_OPTIONS_HPP_ -#define _PAPILO_CORE_PRESOLVE_OPTIONS_HPP_ - -#include "papilo/misc/ParameterSet.hpp" -#include - -namespace papilo -{ - -struct PresolveOptions -{ - // add the parameters with their default values - int maxfillinpersubstitution = 10; - - double markowitz_tolerance = 0.01; - - int maxshiftperrow = 10; - - bool substitutebinarieswithints = true; - - int dualreds = 2; - - double abortfac = 8e-4; - - double lpabortfac = 1e-2; - - bool boundrelax = false; - - int componentsmaxint = 0; - - double compressfac = 0.85; - - double tlim = std::numeric_limits::max(); - - double minabscoeff = 1e-10; - - double feastol = 1e-6; - - double epsilon = 1e-9; - - double hugeval = 1e8; - - bool removeslackvars = true; - - int weakenlpvarbounds = 0; - - int detectlindep = 1; - - int threads = 0; - - unsigned int randomseed = 0; - - bool apply_results_immediately_if_run_sequentially = true; - - bool dual_fix_parallel = false; - - bool simple_probing_parallel = false; - - bool implied_integer_parallel = false; - - bool simple_substitution_parallel = false; - - bool constraint_propagation_parallel = true; - - bool coefficient_strengthening_parallel = true; - - bool simplify_inequalities_parallel = true; - - bool calculate_basis_for_dual = true; - - double bound_tightening_offset = 0.0001; - - bool validation_after_every_postsolving_step = false; - - void - addParameters( ParameterSet& paramSet ) - { - paramSet.addParameter( - "presolve.dualreds", - "0: disable dual reductions, 1: allow dual reductions that never cut " - "off optimal solutions, 2: allow all dual reductions", - dualreds, 0, 2 ); - paramSet.addParameter( - "substitution.markowitz_tolerance", - "markowitz tolerance value for allowing a substitution", - markowitz_tolerance, 0.0, 1.0 ); - paramSet.addParameter( - "presolve.abortfac", - "abort factor of weighted number of reductions for presolving", - abortfac, 0.0, 1.0 ); - paramSet.addParameter( - "presolve.lpabortfac", - "abort factor of weighted number of reductions for presolving LPs", - lpabortfac, 0.0, 1.0 ); - paramSet.addParameter( - "substitution.maxfillin", - "maximum estimated fillin for variable substitutions", - maxfillinpersubstitution, 0 ); - paramSet.addParameter( "presolve.randomseed", "random seed value", - randomseed ); - paramSet.addParameter( "substitution.maxshiftperrow", - "maximum amount of nonzeros being moved to make " - "space for fillin from substitutions within a row", - maxshiftperrow, 0 ); - paramSet.addParameter( "substitution.binarieswithints", - "should substitution of binary variables with " - "general integers be allowed", - substitutebinarieswithints ); - paramSet.addParameter( - "presolve.boundrelax", - "relax bounds of implied free variables after presolving", - boundrelax ); - paramSet.addParameter( "presolve.removeslackvars", - "remove slack variables in equations", - removeslackvars ); - paramSet.addParameter( - "presolve.componentsmaxint", - "maximum number of integral variables for trying to solve " - "disconnected components of the problem in presolving (-1: disabled)", - componentsmaxint, -1 ); - paramSet.addParameter( "presolve.compressfac", - "compress the problem if fewer than compressfac " - "times the number of rows or columns are active", - compressfac, 0.0, 1.0 ); - paramSet.addParameter( "presolve.tlim", "time limit for presolve", tlim, - 0.0 ); - paramSet.addParameter( "presolve.minabscoeff", - "minimum absolute coefficient value allowed in " - "matrix, before it is set to zero", - minabscoeff, 0.0, 1e-1 ); - paramSet.addParameter( "numerics.feastol", "the feasibility tolerance", - feastol, 0.0, 1e-1 ); - paramSet.addParameter( "numerics.epsilon", - "epsilon tolerance to consider two values equal", - epsilon, 0.0, 1e-1 ); - paramSet.addParameter( "numerics.hugeval", - "absolute bound value that is considered too huge " - "for activitity based calculations", - hugeval, 0.0 ); - paramSet.addParameter( - "presolve.weakenlpvarbounds", - "weaken bounds obtained by constraint propagation by this factor of " - "the feasibility tolerance if the problem is an LP", - weakenlpvarbounds ); - paramSet.addParameter( "presolve.detectlindep", - "detect and remove linearly dependent equations " - "and free columns (0: off, 1: for LPs, 2: always)", - detectlindep, 0, 2 ); - paramSet.addParameter( "presolve.threads", - "maximal number of threads to use (0: automatic)", - threads, 0 ); - paramSet.addParameter( - "presolve.apply_results_immediately_if_run_sequentially", - "# if only one thread (presolve.threads = 1) is used, apply the " - "reductions immediately afterwards", - apply_results_immediately_if_run_sequentially ); - paramSet.addParameter( - "propagation.parallel", - "#execute loop over rows in constraintpropagation in parallel", - constraint_propagation_parallel ); - paramSet.addParameter( - "coefftightening.parallel", - "#execute loop over rows in coefficientstrengthening in parallel", - coefficient_strengthening_parallel ); - paramSet.addParameter( - "dualfix.parallel", - "#execute loop over columns in dualfix in parallel", - dual_fix_parallel ); - paramSet.addParameter( - "implint.parallel", - "#execute loop over rows in impliedint in parallel", - implied_integer_parallel ); - paramSet.addParameter( - "simpleprobing.parallel", - "#execute loop over rows in simpleprobing in parallel", - simple_probing_parallel ); - paramSet.addParameter( - "doubletoneq.parallel", - "#execute loop over rows in simplesubstitution in parallel", - simple_substitution_parallel ); - paramSet.addParameter( - "simplifyineq.parallel", - "#execute loop over rows in simplifyineq in parallel", - simplify_inequalities_parallel ); - paramSet.addParameter( - "calculate_basis_for_dual", - "#if basis for LP should be calculated presolving steps tightening the variable bounds can not be applied.", - calculate_basis_for_dual ); - paramSet.addParameter( - "validation_after_every_postsolving_step", - "# should the primal/dual solution be validated during after every postsolving step? ", - validation_after_every_postsolving_step ); - paramSet.addParameter( - "bound_tightening_offset", - "# defines the offset for bound tightening ", - bound_tightening_offset ); - } - - bool - runs_sequential() const - { - return threads == 1; - } - - double - get_variable_bound_tightening_offset() const - { - if( bound_tightening_offset > feastol ) - return bound_tightening_offset; - return feastol * 10; - }; -}; - -} // namespace papilo - -#endif diff --git a/headers/papilo/core/ProbingView.hpp b/headers/papilo/core/ProbingView.hpp deleted file mode 100644 index 1425e97..0000000 --- a/headers/papilo/core/ProbingView.hpp +++ /dev/null @@ -1,822 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* */ -/* This file is part of the program and library */ -/* PaPILO --- Parallel Presolve for Integer and Linear Optimization */ -/* */ -/* Copyright (C) 2020-2022 Konrad-Zuse-Zentrum */ -/* fuer Informationstechnik Berlin */ -/* */ -/* This program is free software: you can redistribute it and/or modify */ -/* it under the terms of the GNU Lesser General Public License as published */ -/* by the Free Software Foundation, either version 3 of the License, or */ -/* (at your option) any later version. */ -/* */ -/* This program is distributed in the hope that it will be useful, */ -/* but WITHOUT ANY WARRANTY; without even the implied warranty of */ -/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ -/* GNU Lesser General Public License for more details. */ -/* */ -/* You should have received a copy of the GNU Lesser General Public License */ -/* along with this program. If not, see . */ -/* */ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -#ifndef _PAPILO_CORE_PROBING_VIEW_HPP_ -#define _PAPILO_CORE_PROBING_VIEW_HPP_ - -#include "papilo/core/Problem.hpp" -#include "papilo/core/SingleRow.hpp" -#include "papilo/io/Message.hpp" -#include -#include "papilo/misc/MultiPrecision.hpp" -#include "papilo/misc/Vec.hpp" - -namespace papilo -{ - -template -struct ProbingBoundChg -{ - REAL bound; - unsigned int col : 31; - unsigned int upper : 1; - - ProbingBoundChg( bool upper_, int col_, REAL bound_ ) - { - this->upper = upper_ ? 1 : 0; - this->col = static_cast( col_ ); - this->bound = bound_; - } -}; - -template -struct ProbingSubstitution -{ - REAL col2scale; - REAL col2const; - int col1; - int col2; - - ProbingSubstitution( int col1_, REAL col2scale_, int col2_, REAL col2const_ ) - : col2scale( col2scale_ ), col2const( col2const_ ), col1( col1_ ), - col2( col2_ ) - { - } -}; - -template -class ProbingView -{ - public: - ProbingView( const Problem& problem, const Num& num ); - - void - setMinIntDomRed( const REAL& value ) - { - this->minintdomred = value; - } - - void - setMinContDomRed( const REAL& value ) - { - this->mincontdomred = value; - } - - void - reset(); - - void - setProbingColumn( int col, bool value ) - { - // remember probing column and probed value - probingCol = col; - probingValue = value; - - // fix upper/lower bound of probed column - if( value ) - changeLb( col, 1.0 ); - else - changeUb( col, 0.0 ); - } - - void - activityChanged( ActivityChange actchange, int rowid, - RowActivity& activity ); - void - changeLb( int col, REAL newlb ); - - void - changeUb( int col, REAL newub ); - - void - storeImplications(); - - bool - analyzeImplications(); - - void - propagateDomains(); - - bool - isInfeasible() const - { - return infeasible; - } - - int - getNumSubstitutions() const - { - return static_cast( substitutions.size() ); - } - - Vec>& - getProbingBoundChanges() - { - return boundChanges; - } - - Vec>& - getProbingSubstitutions() - { - return substitutions; - } - - const Vec>& - getProbingBoundChanges() const - { - return boundChanges; - } - - const Vec>& - getProbingSubstitutions() const - { - return substitutions; - } - - int64_t - getAmountOfWork() const - { - return amountofwork; - } - - const Vec& - getProbingLowerBounds() const - { - return probing_lower_bounds; - } - - const Vec& - getProbingUpperBounds() const - { - return probing_upper_bounds; - } - - const Vec& - getProbingDomainFlags() const - { - return probing_domain_flags; - } - - void - clearResults() - { - amountofwork = 0; - boundChanges.clear(); - substitutions.clear(); - } - - private: - // reference to problem and numerics class - const Problem& problem; - const Num& num; - REAL minintdomred; - REAL mincontdomred; - - // datastructures used for probing - Vec changed_lbs; - Vec changed_ubs; - Vec changed_activities; - Vec probing_lower_bounds; - Vec probing_upper_bounds; - Vec probing_domain_flags; - Vec> probing_activities; - - Vec prop_activities; - Vec next_prop_activities; - - bool infeasible; - int round; - int probingCol; - bool probingValue; - - // datastructures for storing result of probing on one value - Vec> otherValueImplications; - bool otherValueInfeasible; - - // results of probing and statistics - Vec> boundChanges; - Vec> substitutions; - - int64_t amountofwork; -}; - -#ifdef PAPILO_USE_EXTERN_TEMPLATES -extern template class ProbingView; -extern template class ProbingView; -extern template class ProbingView; -#endif - -template -ProbingView::ProbingView( const Problem& problem_, - const Num& num_ ) - : problem( problem_ ), num( num_ ), - probing_lower_bounds( problem_.getLowerBounds() ), - probing_upper_bounds( problem_.getUpperBounds() ), - probing_domain_flags( problem_.getColFlags() ), - probing_activities( problem_.getRowActivities() ) -{ - round = -2; - infeasible = false; - amountofwork = 0; - probingCol = -1; - probingValue = false; - otherValueInfeasible = false; - minintdomred = num.getFeasTol() * 1000; - mincontdomred = 0.3; -} - -template -void -ProbingView::reset() -{ - const Vec& rowsize = problem.getConstraintMatrix().getRowSizes(); - - const auto& orig_lbs = problem.getLowerBounds(); - for( int i : changed_lbs ) - { - if( i < 0 ) - { - int c = -i - 1; - assert( !probing_domain_flags[c].test( ColFlag::kLbUseless ) && - problem.getColFlags()[c].test( ColFlag::kLbUseless ) ); - probing_domain_flags[c].set( ColFlag::kLbUseless ); -#ifndef NDEBUG - probing_lower_bounds[c] = orig_lbs[c]; -#endif - } - else - probing_lower_bounds[i] = orig_lbs[i]; - } - changed_lbs.clear(); - - const auto& orig_ubs = problem.getUpperBounds(); - for( int i : changed_ubs ) - { - if( i < 0 ) - { - int c = -i - 1; - assert( !probing_domain_flags[c].test( ColFlag::kUbUseless ) && - problem.getColFlags()[c].test( ColFlag::kUbUseless ) ); - probing_domain_flags[c].set( ColFlag::kUbUseless ); -#ifndef NDEBUG - probing_upper_bounds[c] = orig_ubs[c]; -#endif - } - else - probing_upper_bounds[i] = orig_ubs[i]; - } - changed_ubs.clear(); - - const auto& orig_activities = problem.getRowActivities(); - for( int i : changed_activities ) - { - amountofwork += rowsize[i]; - probing_activities[i] = orig_activities[i]; - } - changed_activities.clear(); - - // reset should result in original domains and activities - assert( std::equal( orig_lbs.begin(), orig_lbs.end(), - probing_lower_bounds.begin() ) ); - assert( std::equal( orig_ubs.begin(), orig_ubs.end(), - probing_upper_bounds.begin() ) ); - assert( std::equal( - orig_activities.begin(), orig_activities.end(), - probing_activities.begin(), - []( const RowActivity& a, const RowActivity& b ) { - return a.ninfmax == b.ninfmax && a.ninfmin == b.ninfmin && - a.min == b.min && a.max == b.max && - a.lastchange == b.lastchange; - } ) ); - - round = -2; - prop_activities.clear(); - next_prop_activities.clear(); - infeasible = false; - probingCol = -1; -} - -template -void -ProbingView::activityChanged( ActivityChange actchange, int rowid, - RowActivity& activity ) -{ - const auto& consMatrix = problem.getConstraintMatrix(); - const auto& lhs = consMatrix.getLeftHandSides(); - const auto& rhs = consMatrix.getRightHandSides(); - const auto& rflags = consMatrix.getRowFlags(); - - // mark the lastchange fields with round values starting from -2 - // and counting backward By doing this we avoid that we need to - // alter the lastchange field after copying the original activities - // since they are always larger or equal to -1 - if( activity.lastchange > -2 ) - changed_activities.push_back( - rowid ); // activity was changed for the first time - - if( activity.lastchange != round ) - next_prop_activities.push_back( rowid ); - - activity.lastchange = round; - - // check if the updated activity is reliable or if it is zero relative to - // the initial activity - const RowActivity& origactivity = problem.getRowActivities()[rowid]; - - bool unreliable; - - if( actchange == ActivityChange::kMin ) - unreliable = ( activity.ninfmin <= 1 && activity.min != 0 && - origactivity.min != 0 && - num.isZero( activity.min / origactivity.min ) ); - else - unreliable = ( activity.ninfmax <= 1 && activity.max != 0 && - origactivity.max != 0 && - num.isZero( activity.max / origactivity.max ) ); - - if( unreliable ) - { - auto rowvec = problem.getConstraintMatrix().getRowCoefficients( rowid ); - - activity = compute_row_activity( rowvec.getValues(), rowvec.getIndices(), - rowvec.getLength(), probing_lower_bounds, - probing_upper_bounds, - probing_domain_flags, round ); - } - - // check for infeasibility - if( actchange == ActivityChange::kMin && activity.ninfmin == 0 && - !rflags[rowid].test( RowFlag::kRhsInf ) && - num.isFeasLT( rhs[rowid], activity.min ) && - num.isSafeLT( rhs[rowid], activity.min ) ) - { - Message::debug( this, - "[{}:{}] probing on col {} with val {} is infeasible min " - "activity is {:.15}, right hand side is {:.15}, and " - "original max activity was {:.15}\n", - __FILE__, __LINE__, probingCol, probingValue, - double( activity.min ), double( rhs[rowid] ), - double( problem.getRowActivities()[rowid].min ) ); - infeasible = true; - } - - if( actchange == ActivityChange::kMax && activity.ninfmax == 0 && - !rflags[rowid].test( RowFlag::kLhsInf ) && - num.isFeasGT( lhs[rowid], activity.max ) && - num.isSafeGT( lhs[rowid], activity.max ) ) - { - Message::debug( this, - "[{}:{}] probing on col {} with val {} is infeasible max " - "activity is {:.15}, left hand side is {:.15}, and " - "original max activity was {:.15}\n", - __FILE__, __LINE__, probingCol, probingValue, - double( activity.max ), double( lhs[rowid] ), - double( problem.getRowActivities()[rowid].max ) ); - infeasible = true; - } -} - -template -void -ProbingView::changeLb( int col, REAL newlb ) -{ - const auto& consMatrix = problem.getConstraintMatrix(); - auto colvec = consMatrix.getColumnCoefficients( col ); - const auto& orig_lbs = problem.getLowerBounds(); - - // bound must be tighter than current domains - bool lbinf = probing_domain_flags[col].test( ColFlag::kLbUseless ); - assert( lbinf || probing_lower_bounds[col] != newlb ); - - Message::debug( this, "changing probing lower bound of col {} to {}\n", col, - double( newlb ) ); - - if( lbinf ) - { - // bound was not altered yet, store the negative (index + 1) to - // indicate that the infinity flag was altered - probing_domain_flags[col].unset( ColFlag::kLbUseless ); - changed_lbs.push_back( -col - 1 ); - } - else if( probing_lower_bounds[col] == orig_lbs[col] && - !problem.getColFlags()[col].test( ColFlag::kLbUseless ) ) - // if bound was not altered yet remember it in the index vector - changed_lbs.push_back( col ); - - // change the bound in the domain vector - REAL oldlb = probing_lower_bounds[col]; - probing_lower_bounds[col] = newlb; - - // update the probing activities by using the column view - update_activities_after_boundchange( - colvec.getValues(), colvec.getIndices(), colvec.getLength(), - BoundChange::kLower, oldlb, newlb, lbinf, probing_activities, - [this]( ActivityChange actChange, int rowid, - RowActivity& activity ) { - activityChanged( actChange, rowid, activity ); - }, - true ); -} - -template -void -ProbingView::changeUb( int col, REAL newub ) -{ - const auto& consMatrix = problem.getConstraintMatrix(); - auto colvec = consMatrix.getColumnCoefficients( col ); - const auto& orig_ubs = problem.getUpperBounds(); - - // bound must be tighter than current domains - bool ubinf = probing_domain_flags[col].test( ColFlag::kUbUseless ); - assert( ubinf || probing_upper_bounds[col] != newub ); - - Message::debug( this, "changing probing upper bound of col {} to {}\n", col, - double( newub ) ); - - if( ubinf ) - { - // bound was not altered yet, store the negative (index + 1) to - // indicate that the infinity flag was altered - probing_domain_flags[col].unset( ColFlag::kUbUseless ); - changed_ubs.push_back( -col - 1 ); - } - else if( probing_upper_bounds[col] == orig_ubs[col] && - !problem.getColFlags()[col].test( ColFlag::kUbUseless ) ) - // if bound was not altered yet remember it in the index vector - changed_ubs.push_back( col ); - - // change the bound in the domain vector - REAL oldub = probing_upper_bounds[col]; - probing_upper_bounds[col] = newub; - - // update the probing activities by using the column view - update_activities_after_boundchange( - colvec.getValues(), colvec.getIndices(), colvec.getLength(), - BoundChange::kUpper, oldub, newub, ubinf, probing_activities, - [this]( ActivityChange actChange, int rowid, - RowActivity& activity ) { - activityChanged( actChange, rowid, activity ); - }, - true ); -} - -template -void -ProbingView::storeImplications() -{ - otherValueInfeasible = isInfeasible(); - - if( otherValueInfeasible ) - return; - - otherValueImplications.clear(); - otherValueImplications.reserve( changed_lbs.size() + changed_ubs.size() - - 1 ); - - for( int c : changed_lbs ) - { - int col = c < 0 ? -c - 1 : c; - - if( col == probingCol ) - continue; - - otherValueImplications.emplace_back( - ProbingBoundChg( false, col, probing_lower_bounds[col] ) ); - } - - for( int c : changed_ubs ) - { - int col = c < 0 ? -c - 1 : c; - - if( col == probingCol ) - continue; - - otherValueImplications.emplace_back( - ProbingBoundChg( true, col, probing_upper_bounds[col] ) ); - } -} - -template -bool -ProbingView::analyzeImplications() -{ - const auto& orig_ubs = problem.getUpperBounds(); - const auto& orig_lbs = problem.getLowerBounds(); - const Vec& orig_domain_flags = problem.getColFlags(); - - // check infeasibility - if( otherValueInfeasible ) - { - // both probing values are infeasible - if( infeasible ) - return true; - - // only the other probing value is infeasible, so store all changed - // bounds as bound changes note that this includes the fixing of the - // probing column to the probed value - boundChanges.reserve( boundChanges.size() + changed_lbs.size() + - changed_ubs.size() ); - - for( int c : changed_lbs ) - { - int col = c < 0 ? -c - 1 : c; - - assert( c >= 0 || - ( !probing_domain_flags[col].test( ColFlag::kLbUseless ) && - orig_domain_flags[col].test( ColFlag::kLbUseless ) ) ); - assert( c < 0 || - ( !probing_domain_flags[col].test( ColFlag::kLbUseless ) && - !orig_domain_flags[col].test( ColFlag::kLbUseless ) ) ); - assert( c < 0 || probing_lower_bounds[col] > orig_lbs[col] ); - - boundChanges.emplace_back( - ProbingBoundChg( false, col, probing_lower_bounds[col] ) ); - } - - for( int c : changed_ubs ) - { - int col = c < 0 ? -c - 1 : c; - - assert( c >= 0 || - ( !probing_domain_flags[col].test( ColFlag::kUbUseless ) && - orig_domain_flags[col].test( ColFlag::kUbUseless ) ) ); - assert( c < 0 || - ( !probing_domain_flags[col].test( ColFlag::kUbUseless ) && - !orig_domain_flags[col].test( ColFlag::kUbUseless ) ) ); - assert( c < 0 || probing_upper_bounds[col] < orig_ubs[col] ); - - boundChanges.emplace_back( - ProbingBoundChg( true, col, probing_upper_bounds[col] ) ); - } - - return false; - } - - boundChanges.reserve( boundChanges.size() + otherValueImplications.size() + - 1 ); - - if( infeasible ) - { - if( probingValue ) - { - // probing to 1 is infeasible, fix probing column to 0 - boundChanges.emplace_back( - ProbingBoundChg( true, probingCol, 0.0 ) ); - } - else - { - // probing to 0 is infeasible, fix probing column to 1 - boundChanges.emplace_back( - ProbingBoundChg( false, probingCol, 1.0 ) ); - } - } - - assert( !otherValueInfeasible ); - - for( const ProbingBoundChg& boundChg : otherValueImplications ) - { - bool impliedFixing = - ( boundChg.upper && - !orig_domain_flags[boundChg.col].test( ColFlag::kLbUseless ) && - orig_lbs[boundChg.col] == boundChg.bound ) || - ( !boundChg.upper && - !orig_domain_flags[boundChg.col].test( ColFlag::kUbUseless ) && - orig_ubs[boundChg.col] == boundChg.bound ); - - // only this probing branch is infeasible, so add all implications of - // the other value as bound change - if( infeasible ) - { - boundChanges.emplace_back( boundChg ); - - continue; - } - - bool fixed = - ( !probing_domain_flags[boundChg.col].test( ColFlag::kUnbounded ) && - probing_lower_bounds[boundChg.col] == - probing_upper_bounds[boundChg.col] ); - - if( impliedFixing && fixed && - !num.isFeasEq( probing_lower_bounds[boundChg.col], boundChg.bound ) ) - { // column is fixed to different values in both probing branches - REAL zerofixval; - REAL onefixval; - - // Determine the fixed values for probing with value 0 and 1 - if( probingValue ) - { - zerofixval = boundChg.bound; - onefixval = probing_lower_bounds[boundChg.col]; - } - else - { - zerofixval = probing_lower_bounds[boundChg.col]; - onefixval = boundChg.bound; - } - - int col1 = boundChg.col; - int col2 = probingCol; - REAL scale = onefixval - zerofixval; - - // in case both columns are binary, we keep the one whith the - // smaller index - if( col1 < col2 && abs( scale ) == 1 && - ( zerofixval == 1 || zerofixval == 0 ) && - probing_domain_flags[col1].test( ColFlag::kIntegral ) ) - std::swap( col1, col2 ); - - // add the corresponding substitution. - substitutions.emplace_back( - ProbingSubstitution( col1, scale, col2, zerofixval ) ); - } - else if( boundChg.upper && - !probing_domain_flags[boundChg.col].test( ColFlag::kUbInf ) && - ( orig_domain_flags[boundChg.col].test( ColFlag::kUbInf ) || - orig_ubs[boundChg.col] > probing_upper_bounds[boundChg.col] ) ) - { - assert( orig_domain_flags[boundChg.col].test( ColFlag::kUbInf ) || - orig_ubs[boundChg.col] > boundChg.bound ); - - // upper bound is tightened in both probing branches - boundChanges.emplace_back( ProbingBoundChg( - true, boundChg.col, - num.max( boundChg.bound, probing_upper_bounds[boundChg.col] ) ) ); - } - else if( !boundChg.upper && - !probing_domain_flags[boundChg.col].test( ColFlag::kLbInf ) && - ( orig_domain_flags[boundChg.col].test( ColFlag::kLbInf ) || - orig_lbs[boundChg.col] < probing_lower_bounds[boundChg.col] ) ) - { - assert( orig_domain_flags[boundChg.col].test( ColFlag::kLbInf ) || - orig_lbs[boundChg.col] < boundChg.bound ); - - // lower bound is tightened in both probing branches - boundChanges.emplace_back( ProbingBoundChg( - false, boundChg.col, - num.min( boundChg.bound, probing_lower_bounds[boundChg.col] ) ) ); - } - } - - return false; -} - -template -void -ProbingView::propagateDomains() -{ - const auto& consMatrix = problem.getConstraintMatrix(); - const auto& lhs = consMatrix.getLeftHandSides(); - const auto& rhs = consMatrix.getRightHandSides(); - const auto& rflags = consMatrix.getRowFlags(); - - using std::swap; - - swap( prop_activities, next_prop_activities ); - next_prop_activities.clear(); - - while( !prop_activities.empty() ) - { - int curr_round = round--; - - Message::debug( this, - "starting probing propagation round {} on {} rows\n", - -curr_round - 2, prop_activities.size() ); - - for( int candrow : prop_activities ) - { - bool propagate = false; - - if( !rflags[candrow].test( RowFlag::kRhsInf ) && - probing_activities[candrow].ninfmin <= 1 ) - propagate = true; - - if( !rflags[candrow].test( RowFlag::kLhsInf ) && - probing_activities[candrow].ninfmax <= 1 ) - propagate = true; - - if( !propagate ) - continue; - - auto rowvec = consMatrix.getRowCoefficients( candrow ); - - propagate_row(candrow, - rowvec.getValues(), rowvec.getIndices(), rowvec.getLength(), - probing_activities[candrow], lhs[candrow], rhs[candrow], - rflags[candrow], probing_lower_bounds, probing_upper_bounds, - probing_domain_flags, - [this]( BoundChange bndChg, int colid, REAL newbound , int row ) { - if( num.isHugeVal( newbound ) ) - return; - - bool isint = probing_domain_flags[colid].test( - ColFlag::kIntegral, ColFlag::kImplInt ); - - if( bndChg == BoundChange::kLower ) - { - if( isint ) - newbound = num.feasCeil( newbound ); - - if( !probing_domain_flags[colid].test( ColFlag::kUbInf ) && - newbound > probing_upper_bounds[colid] ) - { - if( num.isFeasGT( newbound, - probing_upper_bounds[colid] ) ) - { - Message::debug( this, - "[{}:{}] probing on col {} with " - "val {} is infeasible\n", - __FILE__, __LINE__, probingCol, - probingValue ); - infeasible = true; - return; - } - - newbound = probing_upper_bounds[colid]; - } - - REAL delta = newbound - probing_lower_bounds[colid]; - bool finiteDomain = - !probing_domain_flags[colid].test( ColFlag::kUbInf ); - - REAL mindomred = isint ? minintdomred : mincontdomred; - - if( probing_domain_flags[colid].test( - ColFlag::kLbUseless ) || - ( finiteDomain && delta > 0 && - ( delta / ( probing_upper_bounds[colid] - - probing_lower_bounds[colid] ) >= - mindomred ) ) ) - changeLb( colid, newbound ); - } - else - { - assert( bndChg == BoundChange::kUpper ); - if( isint ) - newbound = num.feasFloor( newbound ); - - if( !probing_domain_flags[colid].test( ColFlag::kLbInf ) && - newbound < probing_lower_bounds[colid] ) - { - if( num.isFeasLT( newbound, - probing_lower_bounds[colid] ) ) - { - Message::debug( this, - "[{}:{}] probing on col {} with " - "val {} is infeasible\n", - __FILE__, __LINE__, probingCol, - probingValue ); - infeasible = true; - return; - } - - newbound = probing_lower_bounds[colid]; - } - - REAL delta = probing_upper_bounds[colid] - newbound; - bool finiteDomain = - !probing_domain_flags[colid].test( ColFlag::kLbInf ); - - REAL mindomred = isint ? minintdomred : mincontdomred; - - if( probing_domain_flags[colid].test( - ColFlag::kUbUseless ) || - ( finiteDomain && delta > 0 && - ( delta / ( probing_upper_bounds[colid] - - probing_lower_bounds[colid] ) >= - mindomred ) ) ) - changeUb( colid, newbound ); - } - } ); - if( infeasible ) - return; - } - - swap( prop_activities, next_prop_activities ); - next_prop_activities.clear(); - } -} - -} // namespace papilo - -#endif diff --git a/headers/papilo/core/Problem.hpp b/headers/papilo/core/Problem.hpp deleted file mode 100644 index 042e276..0000000 --- a/headers/papilo/core/Problem.hpp +++ /dev/null @@ -1,783 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* */ -/* This file is part of the program and library */ -/* PaPILO --- Parallel Presolve for Integer and Linear Optimization */ -/* */ -/* Copyright (C) 2020-2022 Konrad-Zuse-Zentrum */ -/* fuer Informationstechnik Berlin */ -/* */ -/* This program is free software: you can redistribute it and/or modify */ -/* it under the terms of the GNU Lesser General Public License as published */ -/* by the Free Software Foundation, either version 3 of the License, or */ -/* (at your option) any later version. */ -/* */ -/* This program is distributed in the hope that it will be useful, */ -/* but WITHOUT ANY WARRANTY; without even the implied warranty of */ -/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ -/* GNU Lesser General Public License for more details. */ -/* */ -/* You should have received a copy of the GNU Lesser General Public License */ -/* along with this program. If not, see . */ -/* */ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -#ifndef _PAPILO_CORE_PROBLEM_HPP_ -#define _PAPILO_CORE_PROBLEM_HPP_ - -#include "papilo/core/ConstraintMatrix.hpp" -#include "papilo/core/Objective.hpp" -#include "papilo/core/SingleRow.hpp" -#include "papilo/core/VariableDomains.hpp" -#include "papilo/io/Message.hpp" -#include "papilo/misc/MultiPrecision.hpp" -#include "papilo/misc/StableSum.hpp" -#include "papilo/misc/String.hpp" -#include "papilo/misc/Vec.hpp" -#include "papilo/misc/fmt.hpp" -#ifdef PAPILO_TBB -#include "papilo/misc/tbb.hpp" -#endif - -namespace papilo -{ - -/// struct to hold counters for up an downlocks of a column -struct Locks -{ - int up; - int down; - - template - void - serialize( Archive& ar, const unsigned int version ) - { - ar& up; - ar& down; - } -}; - -/// class representing the problem consisting of the constraint matrix, the left -/// and right hand side values, the variable domains, the column bounds, -/// column integrality restrictions, and the objective function -template -class Problem -{ - public: - /// set objective function - void - setObjective( Vec coefficients, REAL offset = 0.0 ) - { - objective = Objective{ std::move( coefficients ), offset }; - } - - /// set objective function - void - setObjective( Objective&& obj ) - { - objective = obj; - } - - /// set (transposed) constraint matrix - void - setConstraintMatrix( SparseStorage cons_matrix, Vec lhs_values, - Vec rhs_values, Vec row_flags, - bool transposed = false ) - { - assert( lhs_values.size() == rhs_values.size() ); - assert( lhs_values.size() == row_flags.size() ); - assert( ( transposed ? cons_matrix.getNCols() - : cons_matrix.getNRows() ) == row_flags.size() ); - - auto cons_matrix_other = cons_matrix.getTranspose(); - if( transposed ) - constraintMatrix = ConstraintMatrix{ - std::move( cons_matrix_other ), std::move( cons_matrix ), - std::move( lhs_values ), std::move( rhs_values ), - std::move( row_flags ) }; - else - constraintMatrix = ConstraintMatrix{ - std::move( cons_matrix ), std::move( cons_matrix_other ), - std::move( lhs_values ), std::move( rhs_values ), - std::move( row_flags ) }; - } - - /// set constraint matrix - void - setConstraintMatrix( ConstraintMatrix&& cons_matrix ) - { - constraintMatrix = cons_matrix; - } - - /// set domains of variables - void - setVariableDomains( VariableDomains&& domains ) - { - variableDomains = domains; - - nintegers = 0; - ncontinuous = 0; - - for( ColFlags cf : variableDomains.flags ) - { - if( cf.test( ColFlag::kIntegral ) ) - ++nintegers; - else - ++ncontinuous; - } - } - - /// set domains of variables - void - setVariableDomains( Vec lower_bounds, Vec upper_bounds, - Vec col_flags ) - { - variableDomains = VariableDomains{ std::move( lower_bounds ), - std::move( upper_bounds ), - std::move( col_flags ) }; - nintegers = 0; - ncontinuous = 0; - - for( ColFlags cf : variableDomains.flags ) - { - if( cf.test( ColFlag::kIntegral ) ) - ++nintegers; - else - ++ncontinuous; - } - } - - /// returns number of active integral columns - int - getNumIntegralCols() const - { - return nintegers; - } - - /// returns number of active integral columns - int& - getNumIntegralCols() - { - return nintegers; - } - - /// returns number of active continuous columns - int - getNumContinuousCols() const - { - return ncontinuous; - } - - /// returns number of active continuous columns - int& - getNumContinuousCols() - { - return ncontinuous; - } - - /// set variable names - void - setVariableNames( Vec var_names ) - { - variableNames = std::move( var_names ); - } - - /// set constraint names - void - setConstraintNames( Vec cons_names ) - { - constraintNames = std::move( cons_names ); - } - - /// set problem name - void - setName( String name_ ) - { - this->name = std::move( name_ ); - } - - /// get the problem matrix - const ConstraintMatrix& - getConstraintMatrix() const - { - return constraintMatrix; - } - - /// get the problem matrix - ConstraintMatrix& - getConstraintMatrix() - { - return constraintMatrix; - } - - /// get number of columns - int - getNCols() const - { - return constraintMatrix.getNCols(); - } - - /// get number of rows - int - getNRows() const - { - return constraintMatrix.getNRows(); - } - - /// get the objective function - const Objective& - getObjective() const - { - return objective; - } - - /// get the objective function - Objective& - getObjective() - { - return objective; - } - - /// get the variable domains - const VariableDomains& - getVariableDomains() const - { - return variableDomains; - } - - /// get the variable domains - VariableDomains& - getVariableDomains() - { - return variableDomains; - } - - const Vec& - getColFlags() const - { - return variableDomains.flags; - } - - Vec& - getColFlags() - { - return variableDomains.flags; - } - - const Vec& - getRowFlags() const - { - return constraintMatrix.getRowFlags(); - } - - Vec& - getRowFlags() - { - return constraintMatrix.getRowFlags(); - } - - /// get the variable names - const Vec& - getVariableNames() const - { - return variableNames; - } - - /// get the constraint names - const Vec& - getConstraintNames() const - { - return constraintNames; - } - - /// get the problem name - const String& - getName() const - { - return name; - } - - /// get the (dense) vector of variable lower bounds - const Vec& - getLowerBounds() const - { - return variableDomains.lower_bounds; - } - - /// get the (dense) vector of variable lower bounds - Vec& - getLowerBounds() - { - return variableDomains.lower_bounds; - } - - /// get the (dense) vector of variable upper bounds - const Vec& - getUpperBounds() const - { - return variableDomains.upper_bounds; - } - - /// get the (dense) vector of variable upper bounds - Vec& - getUpperBounds() - { - return variableDomains.upper_bounds; - } - - /// get the (dense) vector of column sizes - const Vec& - getColSizes() const - { - return constraintMatrix.getColSizes(); - } - - /// get the (dense) vector of column sizes - Vec& - getColSizes() - { - return constraintMatrix.getColSizes(); - } - - /// get the (dense) vector of row sizes - const Vec& - getRowSizes() const - { - return constraintMatrix.getRowSizes(); - } - - /// get the (dense) vector of row sizes - Vec& - getRowSizes() - { - return constraintMatrix.getRowSizes(); - } - - /// substitute a variable in the objective using an equality constraint - /// given by a row index - void - substituteVarInObj( const Num& num, int col, int equalityrow ); - - bool - computeSolViolations( const Num& num, const Vec& sol, - REAL& boundviolation, REAL& rowviolation, - REAL& intviolation ) const - { - if( (int) sol.size() != getNCols() ) - return false; - - boundviolation = 0; - intviolation = 0; - - for( int i = 0; i != getNCols(); ++i ) - { - if( !variableDomains.flags[i].test( ColFlag::kLbInf ) && - sol[i] < variableDomains.lower_bounds[i] ) - { - REAL thisviol = variableDomains.lower_bounds[i] - sol[i]; - - if( !num.isFeasZero( thisviol ) ) - Message::debug( this, - "lower bound {} of column {} with solution " - "value {} is violated by {}\n", - double( variableDomains.lower_bounds[i] ), i, - double( sol[i] ), double( thisviol ) ); - - boundviolation = num.max( boundviolation, thisviol ); - } - - if( !variableDomains.flags[i].test( ColFlag::kUbInf ) && - sol[i] > variableDomains.upper_bounds[i] ) - { - REAL thisviol = sol[i] - variableDomains.upper_bounds[i]; - - if( !num.isFeasZero( thisviol ) ) - Message::debug( this, - "upper bound {} of column {} with solution " - "value {} is violated by {}\n", - double( variableDomains.upper_bounds[i] ), i, - double( sol[i] ), double( thisviol ) ); - - boundviolation = num.max( boundviolation, thisviol ); - } - - if( variableDomains.flags[i].test( ColFlag::kIntegral ) ) - { - REAL thisviol = abs( num.round( sol[i] ) - sol[i] ); - - if( !num.isFeasZero( thisviol ) ) - Message::debug( this, - "integrality of column {} with solution value " - "{} is violated by {}\n", - i, double( sol[i] ), double( thisviol ) ); - - intviolation = num.max( intviolation, thisviol ); - } - } - - rowviolation = 0; - - const Vec& rflags = getRowFlags(); - const Vec& lhs = constraintMatrix.getLeftHandSides(); - const Vec& rhs = constraintMatrix.getRightHandSides(); - - for( int i = 0; i != getNRows(); ++i ) - { - auto rowvec = constraintMatrix.getRowCoefficients( i ); - const REAL* vals = rowvec.getValues(); - const int* inds = rowvec.getIndices(); - - StableSum activitySum; - for( int j = 0; j != rowvec.getLength(); ++j ) - activitySum.add( sol[inds[j]] * vals[j] ); - - REAL activity = activitySum.get(); - - if( !rflags[i].test( RowFlag::kRhsInf ) - && num.isFeasGT( activity, rhs[i] ) ) - { - Message::debug( this, - "the activity {} of constraint {} " - "{} is greater than the righthandside {}\n", - activity, i, rhs[i] ); - rowviolation = num.max( rowviolation, activity - rhs[i] ); - } - - if( !rflags[i].test( RowFlag::kLhsInf ) - && num.isFeasLT( activity, rhs[i] ) ) - { - Message::debug( this, - "the activity {} of constraint {} " - "{} is greater than the lefthandside {}\n", - activity, i, lhs[i] ); - rowviolation = num.max( rowviolation, lhs[i] - activity ); - } - } - - return num.isFeasZero( boundviolation ) && - num.isFeasZero( intviolation ) && num.isFeasZero( rowviolation ); - } - - REAL - computeSolObjective( const Vec& sol ) const - { - assert( (int) sol.size() == getNCols() ); - - StableSum obj( objective.offset ); - for( int i = 0; i < getNCols(); ++i ) - obj.add( sol[i] * objective.coefficients[i] ); - - return obj.get(); - } - - /// return const reference to vector of row activities - const Vec>& - getRowActivities() const - { - return rowActivities; - } - - /// return reference to vector of row activities - Vec>& - getRowActivities() - { - return rowActivities; - } - - /// returns a reference to the vector of locks of each column, the locks - /// include the objective cutoff constraint - Vec& - getLocks() - { - return locks; - } - - std::pair, Vec> - compress( bool full = false ) - { - std::pair, Vec> mappings = - constraintMatrix.compress( full ); - - // update information about columns that is stored by index -#ifdef PAPILO_TBB - tbb::parallel_invoke( - [this, &mappings, full]() { - compress_vector( mappings.second, objective.coefficients ); - if( full ) - objective.coefficients.shrink_to_fit(); - }, - [this, &mappings, full]() { - variableDomains.compress( mappings.second, full ); - }, - [this, &mappings, full]() { - // compress row activities - // recomputeAllActivities(); - if( rowActivities.size() != 0 ) - compress_vector( mappings.first, rowActivities ); - - if( full ) - rowActivities.shrink_to_fit(); - } ); -#else - compress_vector( mappings.second, objective.coefficients ); - variableDomains.compress( mappings.second, full ); - if( rowActivities.size() != 0 ) - compress_vector( mappings.first, rowActivities ); - if( full ) - { - objective.coefficients.shrink_to_fit(); - rowActivities.shrink_to_fit(); - } -#endif - - // compress row activities - return mappings; - } - - /// sets the tolerance of the input format - void - setInputTolerance( REAL inputTolerance_ ) - { - this->inputTolerance = std::move( inputTolerance_ ); - } - - void - recomputeAllActivities() - { - rowActivities.resize( getNRows() ); - - // loop through rows once, compute initial acitvities, detect trivial - // redundancy -#ifdef PAPILO_TBB - tbb::parallel_for( - tbb::blocked_range( 0, getNRows() ), - [this]( const tbb::blocked_range& r ) { - for( int row = r.begin(); row < r.end(); ++row ) -#else - for( int row = 0; row < getNRows(); ++row ) -#endif - { - auto rowvec = constraintMatrix.getRowCoefficients( row ); - rowActivities[row] = compute_row_activity( - rowvec.getValues(), rowvec.getIndices(), rowvec.getLength(), - variableDomains.lower_bounds, variableDomains.upper_bounds, - variableDomains.flags ); - } -#ifdef PAPILO_TBB - } ); -#endif - } - - void - recomputeLocks() - { - locks.resize( getNCols() ); - - // loop through rows once, compute initial activities, detect trivial - // redundancy -#ifdef PAPILO_TBB - tbb::parallel_for( - tbb::blocked_range( 0, getNCols() ), - [this]( const tbb::blocked_range& c ) { - for( int col = c.begin(); col != c.end(); ++col ) -#else - for( int col = 0; col < getNCols(); ++col ) -#endif - { - auto colvec = constraintMatrix.getColumnCoefficients( col ); - - const REAL* vals = colvec.getValues(); - const int* inds = colvec.getIndices(); - int len = colvec.getLength(); - const auto& rflags = getRowFlags(); - - for( int i = 0; i != len; ++i ) - count_locks( vals[i], rflags[inds[i]], locks[col].down, - locks[col].up ); - } -#ifdef PAPILO_TBB - } ); -#endif - } - - std::pair - removeRedundantBounds( const Num& num, Vec& cflags, - Vec>& activities ) const - { - const Vec& lhs = constraintMatrix.getLeftHandSides(); - const Vec& rhs = constraintMatrix.getRightHandSides(); - const Vec& colsize = constraintMatrix.getColSizes(); - const Vec& rflags = getRowFlags(); - - const Vec& lbs = getLowerBounds(); - const Vec& ubs = getUpperBounds(); - int nremoved = 0; - int nnewfreevars = 0; - - Vec> colperm( getNCols() ); - - for( int i = 0; i != getNCols(); ++i ) - colperm[i] = std::make_tuple( - colsize[i], - constraintMatrix.getColumnCoefficients( i ).getDynamism(), i ); - - pdqsort( colperm.begin(), colperm.end() ); - - for( const auto& tuple : colperm ) - { - int col = std::get<2>( tuple ); - - if( cflags[col].test( ColFlag::kInactive ) || - !cflags[col].test( ColFlag::kUnbounded ) ) - continue; - - auto colvec = constraintMatrix.getColumnCoefficients( col ); - const int* colrows = colvec.getIndices(); - const REAL* colvals = colvec.getValues(); - const int collen = colvec.getLength(); - - int k = 0; - - ColFlags colf = cflags[col]; - - while( ( !colf.test( ColFlag::kLbInf ) || - !colf.test( ColFlag::kUbInf ) ) && - k != collen ) - { - int row = colrows[k]; - - if( rflags[row].test( RowFlag::kRedundant ) ) - { - ++k; - continue; - } - - if( !colf.test( ColFlag::kLbInf ) && - row_implies_LB( num, lhs[row], rhs[row], rflags[row], - activities[row], colvals[k], lbs[col], ubs[col], - cflags[col] ) ) - colf.set( ColFlag::kLbInf ); - - if( !colf.test( ColFlag::kUbInf ) && - row_implies_UB( num, lhs[row], rhs[row], rflags[row], - activities[row], colvals[k], lbs[col], ubs[col], - cflags[col] ) ) - colf.set( ColFlag::kUbInf ); - - ++k; - } - - if( colf.test( ColFlag::kLbInf ) && colf.test( ColFlag::kUbInf ) ) - { - int oldnremoved = nremoved; - if( !cflags[col].test( ColFlag::kLbInf ) ) - { - update_activities_remove_finite_bound( colrows, colvals, collen, - BoundChange::kLower, - lbs[col], activities ); - cflags[col].set( ColFlag::kLbInf ); - ++nremoved; - } - - if( !cflags[col].test( ColFlag::kUbInf ) ) - { - update_activities_remove_finite_bound( colrows, colvals, collen, - BoundChange::kUpper, - ubs[col], activities ); - cflags[col].set( ColFlag::kUbInf ); - ++nremoved; - } - - if( oldnremoved != nremoved ) - ++nnewfreevars; - } - } - - return std::make_pair( nremoved, nnewfreevars ); - } - - template - void - serialize( Archive& ar, const unsigned int version ) - { - ar& name; - ar& inputTolerance; - ar& objective; - - ar& constraintMatrix; - ar& variableDomains; - ar& ncontinuous; - ar& nintegers; - - ar& variableNames; - ar& constraintNames; - ar& rowActivities; - - ar& locks; - } - - private: - String name; - REAL inputTolerance{ 0 }; - Objective objective; - ConstraintMatrix constraintMatrix; - VariableDomains variableDomains; - int ncontinuous; - int nintegers; - - Vec variableNames; - Vec constraintNames; - - /// minimal and maximal row activities - Vec> rowActivities; - - /// up and down locks for each column - Vec locks; -}; - -template -void -Problem::substituteVarInObj( const Num& num, int col, int row ) -{ - auto& consMatrix = getConstraintMatrix(); - auto& objcoefficients = getObjective().coefficients; - REAL freevarCoefInObj = objcoefficients[col]; - - if( freevarCoefInObj == REAL{ 0 } ) - return; - - const auto equalityrow = consMatrix.getRowCoefficients( row ); - const int length = equalityrow.getLength(); - const REAL* values = equalityrow.getValues(); - const int* indices = equalityrow.getIndices(); - - int consid = consMatrix.getSparseIndex( col, row ); - assert( consid >= 0 ); - assert( indices[consid] == col ); - REAL freevarCoefInCons = values[consid]; - - REAL substscale = -freevarCoefInObj / freevarCoefInCons; - - objcoefficients[col] = REAL{ 0.0 }; - for( int j = 0; j < length; ++j ) - { - if( indices[j] == col ) - continue; - - REAL newobjcoeff = objcoefficients[indices[j]] + values[j] * substscale; - if( num.isZero( newobjcoeff ) ) - newobjcoeff = 0; - - objcoefficients[indices[j]] = newobjcoeff; - } - - assert( consMatrix.getRowFlags()[row].test( RowFlag::kEquation ) && - !consMatrix.getRowFlags()[row].test( RowFlag::kRhsInf ) && - !consMatrix.getRowFlags()[row].test( RowFlag::kLhsInf ) && - consMatrix.getLeftHandSides()[row] == - consMatrix.getRightHandSides()[row] ); - getObjective().offset -= consMatrix.getLeftHandSides()[row] * substscale; -} - -} // namespace papilo - -#endif diff --git a/headers/papilo/core/ProblemBuilder.hpp b/headers/papilo/core/ProblemBuilder.hpp deleted file mode 100644 index a9757b6..0000000 --- a/headers/papilo/core/ProblemBuilder.hpp +++ /dev/null @@ -1,402 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* */ -/* This file is part of the program and library */ -/* PaPILO --- Parallel Presolve for Integer and Linear Optimization */ -/* */ -/* Copyright (C) 2020-2022 Konrad-Zuse-Zentrum */ -/* fuer Informationstechnik Berlin */ -/* */ -/* This program is free software: you can redistribute it and/or modify */ -/* it under the terms of the GNU Lesser General Public License as published */ -/* by the Free Software Foundation, either version 3 of the License, or */ -/* (at your option) any later version. */ -/* */ -/* This program is distributed in the hope that it will be useful, */ -/* but WITHOUT ANY WARRANTY; without even the implied warranty of */ -/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ -/* GNU Lesser General Public License for more details. */ -/* */ -/* You should have received a copy of the GNU Lesser General Public License */ -/* along with this program. If not, see . */ -/* */ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -#ifndef _PAPILO_CORE_PROBLEM_BUILDER_HPP_ -#define _PAPILO_CORE_PROBLEM_BUILDER_HPP_ - -namespace papilo -{ - -#include "papilo/core/MatrixBuffer.hpp" -#include "papilo/core/Problem.hpp" -#include "papilo/misc/String.hpp" -#include "papilo/misc/Vec.hpp" - -template -class ProblemBuilder -{ - public: - /// Sets the number of columns to the given value. The information of columns - /// that already exist is kept, new columns are continuous and fixed to zero. - /// If the number of columns is reduced, then the information for the removed - /// columns is lost. - void - setNumCols( int ncols ) - { - // allocate column information - obj.coefficients.resize( ncols ); - domains.lower_bounds.resize( ncols ); - domains.upper_bounds.resize( ncols ); - domains.flags.resize( ncols ); - colnames.resize( ncols ); - } - - /// Sets the number of rows to the given value. The information of rows that - /// already exist is kept, new rows are qualities with right hand side zero. - /// If the number of rows is reduced, then the information for the removed - /// rows is lost. - void - setNumRows( int nrows ) - { - // allocate row information - lhs.resize( nrows ); - rhs.resize( nrows ); - rflags.resize( nrows ); - rownames.resize( nrows ); - } - - /// Returns the current number of rows - int - getNumRows() const - { - return static_cast( rflags.size() ); - } - - /// Returns the current number of cols - int - getNumCols() const - { - return static_cast( domains.flags.size() ); - } - - /// reserve storage for the given number of non-zeros - void - reserve( int nnz, int nrows, int ncols ) - { - matrix_buffer.reserve( nnz ); - - // reserve space for row information - lhs.reserve( nrows ); - rhs.reserve( nrows ); - rflags.reserve( nrows ); - rownames.reserve( nrows ); - - // reserve space for column information - obj.coefficients.reserve( ncols ); - domains.lower_bounds.reserve( ncols ); - domains.upper_bounds.reserve( ncols ); - domains.flags.reserve( ncols ); - colnames.reserve( ncols ); - } - - /// change the objective coefficient of a column - void - setObj( int col, REAL val ) - { - obj.coefficients[col] = std::move( val ); - } - - /// change the objective coefficient of all columns - void - setObjAll( Vec values ) - { - assert( values.size() == obj.coefficients.size() ); - for( int c = 0; c < (int) values.size(); ++c ) - obj.coefficients[c] = std::move( values[c] ); - } - - /// change the objectives constant offset - void - setObjOffset( REAL val ) - { - obj.offset = std::move( val ); - } - - void - setColLbInf( int col, bool isInfinite ) - { - if( isInfinite ) - domains.flags[col].set( ColFlag::kLbInf ); - else - domains.flags[col].unset( ColFlag::kLbInf ); - } - - void - setColLbInfAll( Vec isInfinite ) - { - assert( domains.flags.size() == isInfinite.size() ); - for( int c = 0; c < (int) isInfinite.size(); ++c ) - setColLbInf( c, isInfinite[c] ); - } - - void - setColUbInf( int col, bool isInfinite ) - { - if( isInfinite ) - domains.flags[col].set( ColFlag::kUbInf ); - else - domains.flags[col].unset( ColFlag::kUbInf ); - } - - void - setColUbInfAll( Vec isInfinite ) - { - assert( domains.flags.size() == isInfinite.size() ); - for( int c = 0; c < (int) isInfinite.size(); ++c ) - setColUbInf( c, isInfinite[c] ); - } - - void - setColLb( int col, REAL lb ) - { - domains.lower_bounds[col] = std::move( lb ); - } - - void - setColLbAll( Vec lbs ) - { - assert( lbs.size() == domains.lower_bounds.size() ); - for( int c = 0; c < (int) lbs.size(); ++c ) - domains.lower_bounds[c] = std::move( lbs[c - ] ); - } - - void - setColUb( int col, REAL ub ) - { - domains.upper_bounds[col] = std::move( ub ); - } - - void - setColUbAll( Vec ubs ) - { - assert( ubs.size() == domains.upper_bounds.size() ); - for( int c = 0; c < (int) ubs.size(); ++c ) - domains.upper_bounds[c] = std::move( ubs[c] ); - } - - void - setColIntegral( int col, bool isIntegral ) - { - if( isIntegral ) - domains.flags[col].set( ColFlag::kIntegral ); - else - domains.flags[col].unset( ColFlag::kIntegral ); - } - - void - setColImplInt( int col, bool isImplInt ) - { - if( isImplInt ) - domains.flags[col].set( ColFlag::kImplInt ); - else - domains.flags[col].unset( ColFlag::kImplInt ); - } - - void - setColIntegralAll( Vec isIntegral ) - { - assert( isIntegral.size() == domains.flags.size() ); - for( int c = 0; c < (int) isIntegral.size(); ++c ) - setColIntegral( c, isIntegral[c] ); - } - - void - setRowLhsInf( int row, bool isInfinite ) - { - if( isInfinite ) - rflags[row].set( RowFlag::kLhsInf ); - else - rflags[row].unset( RowFlag::kLhsInf ); - } - - void - setRowLhsInfAll( Vec isInfinite ) - { - assert( isInfinite.size() == rflags.size() ); - for( int r = 0; r < (int) isInfinite.size(); ++r ) - setRowLhsInf( r, isInfinite[r] ); - } - - void - setRowRhsInf( int row, bool isInfinite ) - { - if( isInfinite ) - rflags[row].set( RowFlag::kRhsInf ); - else - rflags[row].unset( RowFlag::kRhsInf ); - } - - void - setRowRhsInfAll( Vec isInfinite ) - { - assert( isInfinite.size() == rflags.size() ); - for( int r = 0; r < (int) isInfinite.size(); ++r ) - setRowRhsInf( r, isInfinite[r] ); - } - - void - setRowLhs( int row, REAL lhsval ) - { - lhs[row] = std::move( lhsval ); - } - - void - setRowLhsAll( Vec lhsvals ) - { - assert( lhsvals.size() == lhs.size() ); - for( int r = 0; r < (int) lhsvals.size(); ++r ) - lhs[r] = std::move( lhsvals[r] ); - } - - void - setRowRhs( int row, REAL rhsval ) - { - rhs[row] = std::move( rhsval ); - } - - void - setRowRhsAll( Vec rhsvals ) - { - assert( rhsvals.size() == rhs.size() ); - for( int r = 0; r < (int) rhsvals.size(); ++r ) - rhs[r] = std::move( rhsvals[r] ); - } - - /// add a nonzero entry for the given row and column - void - addEntry( int row, int col, const REAL& val ) - { - assert( val != 0 ); - matrix_buffer.addEntry( row, col, val ); - } - - /// add all given entries given in tripel: (row,col,val) - void - addEntryAll( Vec> entries ) - { - for( auto trp : entries ) - addEntry( std::get<0>( trp ), std::get<1>( trp ), std::get<2>( trp ) ); - } - - /// add the nonzero entries for the given row - template - void - addRowEntries( int row, int len, const int* cols, const R* vals ) - { - for( int i = 0; i != len; ++i ) - { - assert( vals[i] != 0 ); - matrix_buffer.addEntry( row, cols[i], REAL{ vals[i] } ); - } - } - - template - void - setRowName( int row, Str&& name ) - { - rownames[row] = String( name ); - } - - template - void - setRowNameAll( Vec names ) - { - assert( rownames.size() == names.size() ); - for( int r = 0; r < (int) names.size(); ++r ) - rownames[r] = String( names[r] ); - } - - template - void - setColName( int col, Str&& name ) - { - colnames[col] = String( name ); - } - - template - void - setColNameAll( Vec names ) - { - assert( colnames.size() == names.size() ); - for( int c = 0; c < (int) names.size(); ++c ) - colnames[c] = String( names[c] ); - } - - template - void - setProblemName( Str&& name ) - { - probname = String( name ); - } - - /// add the nonzero entries for the given column - template - void - addColEntries( int col, int len, const int* rows, const R* vals ) - { - for( int i = 0; i != len; ++i ) - { - assert( vals[i] != 0 ); - matrix_buffer.addEntry( rows[i], col, REAL{ vals[i] } ); - } - } - - Problem - build() - { - Problem problem; - - int nRows = lhs.size(); - int nColumns = obj.coefficients.size(); - - problem.setName( std::move( probname ) ); - - problem.setConstraintMatrix( ConstraintMatrix{ - matrix_buffer.buildCSR( nRows, nColumns ), - matrix_buffer.buildCSC( nRows, nColumns ), std::move( lhs ), - std::move( rhs ), std::move( rflags ) } ); - - matrix_buffer.clear(); - - problem.setObjective( std::move( obj ) ); - problem.setVariableDomains( std::move( domains ) ); - problem.setVariableNames( std::move( colnames ) ); - problem.setConstraintNames( std::move( rownames ) ); - ConstraintMatrix& matrix = problem.getConstraintMatrix(); - for(int i=0; i< problem.getNRows(); i++){ - RowFlags rowFlag = matrix.getRowFlags()[i]; - if( !rowFlag.test( RowFlag::kRhsInf ) && - !rowFlag.test( RowFlag::kLhsInf ) && - matrix.getLeftHandSides()[i] == matrix.getRightHandSides()[i] ) - matrix.getRowFlags()[i].set(RowFlag::kEquation); - } - - return problem; - } - - private: - MatrixBuffer matrix_buffer; - Objective obj; - VariableDomains domains; - Vec lhs; - Vec rhs; - Vec rflags; - Vec rownames; - Vec colnames; - String probname; -}; - -} // namespace papilo - -#endif diff --git a/headers/papilo/core/ProblemUpdate.hpp b/headers/papilo/core/ProblemUpdate.hpp deleted file mode 100644 index 09e6273..0000000 --- a/headers/papilo/core/ProblemUpdate.hpp +++ /dev/null @@ -1,2926 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* */ -/* This file is part of the program and library */ -/* PaPILO --- Parallel Presolve for Integer and Linear Optimization */ -/* */ -/* Copyright (C) 2020-2022 Konrad-Zuse-Zentrum */ -/* fuer Informationstechnik Berlin */ -/* */ -/* This program is free software: you can redistribute it and/or modify */ -/* it under the terms of the GNU Lesser General Public License as published */ -/* by the Free Software Foundation, either version 3 of the License, or */ -/* (at your option) any later version. */ -/* */ -/* This program is distributed in the hope that it will be useful, */ -/* but WITHOUT ANY WARRANTY; without even the implied warranty of */ -/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ -/* GNU Lesser General Public License for more details. */ -/* */ -/* You should have received a copy of the GNU Lesser General Public License */ -/* along with this program. If not, see . */ -/* */ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -#ifndef _PAPILO_CORE_PROBLEM_UPDATE_HPP_ -#define _PAPILO_CORE_PROBLEM_UPDATE_HPP_ - -#include "papilo/core/MatrixBuffer.hpp" -#include "papilo/core/PresolveMethod.hpp" -#include "papilo/core/PresolveOptions.hpp" -#include "papilo/core/Problem.hpp" -#include "papilo/core/Reductions.hpp" -#include "papilo/core/SingleRow.hpp" -#include "papilo/core/Statistics.hpp" -#include "papilo/core/postsolve/PostsolveStorage.hpp" -#include "papilo/misc/Flags.hpp" -#include "papilo/misc/MultiPrecision.hpp" -#include "papilo/misc/Num.hpp" -#include -#include -#include "boost/random.hpp" - -namespace papilo -{ - -enum class ConflictType -{ - kNoConflict, - kConflict, - kPostpone -}; - -enum class ApplyResult -{ - kApplied, - kRejected, - kPostponed, - kInfeasible -}; - -template -class ProblemUpdate -{ - Problem& problem; - PostsolveStorage& postsolve; - Statistics& stats; - const PresolveOptions& presolveOptions; - const Num& num; - const Message& msg; - - bool postponeSubstitutions; - Vec dirty_row_states; - Vec dirty_col_states; - - Vec deleted_cols; - Vec redundant_rows; - - Vec changed_activities; - Vec singletonRows; - Vec singletonColumns; - Vec emptyColumns; - int firstNewSingletonCol; - - MatrixBuffer matrix_buffer; - Vec intbuffer; - Vec realbuffer; - Vec> tripletbuffer; - - Vec*> compress_observers; - - Vec random_col_perm; - Vec random_row_perm; - - int lastcompress_ndelcols; - int lastcompress_ndelrows; - - enum class State : uint8_t - { - kUnmodified = 0, - kModified = 1 << 1, - kBoundsModified = 1 << 2, - }; - - Vec> row_state; - Vec> col_state; - - - - template - void - setColState( int col, Args... flags ) - { - assert( col >= 0 && col < problem.getNCols() ); - - if( col_state[col].equal( State::kUnmodified ) ) - dirty_col_states.push_back( col ); - - col_state[col].set( flags... ); - } - - template - void - setRowState( int row, Args... flags ) - { - assert( row >= 0 && row < problem.getNRows() ); - - // check that equation flag is set correctly - assert( - problem.getRowFlags()[row].test( RowFlag::kRedundant ) || - ( !problem.getRowFlags()[row].test( RowFlag::kEquation ) && - ( problem.getRowFlags()[row].test( RowFlag::kLhsInf, - RowFlag::kRhsInf ) || - problem.getConstraintMatrix().getLeftHandSides()[row] != - problem.getConstraintMatrix().getRightHandSides()[row] ) ) || - ( problem.getRowFlags()[row].test( RowFlag::kEquation ) && - !problem.getRowFlags()[row].test( RowFlag::kLhsInf, - RowFlag::kRhsInf ) && - problem.getConstraintMatrix().getLeftHandSides()[row] == - problem.getConstraintMatrix().getRightHandSides()[row] ) ); - - if( row_state[row].equal( State::kUnmodified ) ) - dirty_row_states.push_back( row ); - - row_state[row].set( flags... ); - } - - public: - ProblemUpdate( Problem& problem, PostsolveStorage& postsolve, - Statistics& stats, const PresolveOptions& presolveOptions, - const Num& num, const Message& msg ); - - void - setPostponeSubstitutions( bool value ) - { - this->postponeSubstitutions = value; - } - - void - update_activity( ActivityChange actChange, int rowid, - RowActivity& activity ); - - PresolveStatus - fixCol( int col, REAL val ); - - PresolveStatus - fixColInfinity( int col, REAL val ); - - PresolveStatus - changeLB( int col, REAL val ); - - void - merge_parallel_columns( - int col1, int col2, REAL col2scale, - ConstraintMatrix& constraintMatrix, Vec& lbs, Vec& ubs, - Vec& cflags ); - - ConstraintMatrix& - getConstraintMatrix() - { - return problem.getConstraintMatrix(); - } - - Problem& - getProblem() - { - return problem; - } - - void - clearDeletedCols() - { - deleted_cols.clear(); - } - - PresolveStatus - changeUB( int col, REAL val ); - - void - markRowRedundant( int row ) - { - RowFlags& rflags = problem.getRowFlags()[row]; - if( !rflags.test( RowFlag::kRedundant ) ) - { - redundant_rows.push_back( row ); - ++stats.ndeletedrows; - rflags.set( RowFlag::kRedundant ); - } - postsolve.storeRedundantRow( row ); - } - - void - observeCompress( PresolveMethod* observer ) - { - compress_observers.push_back( observer ); - } - - void - markColFixed( int col ) - { - ColFlags& cflags = problem.getColFlags()[col]; - assert( !cflags.test( ColFlag::kInactive ) ); - cflags.set( ColFlag::kFixed ); - deleted_cols.push_back( col ); - ++stats.ndeletedcols; - - if( cflags.test( ColFlag::kIntegral ) ) - --problem.getNumIntegralCols(); - else - --problem.getNumContinuousCols(); - } - - /// removes the constant contribution of fixed columns - /// from the left and right hand sides and the activity - void - removeFixedCols(); - - /// scans through all columns and does some trivial presolve reductions: - /// * it rounds fractional bounds of integer variables - /// * checks for infeasibility of bound constraints - /// * performs dual fixing if the parameter dualfix is true - /// * remembers singleton columns - /// if dualfixing is true the locks of the problem must have been initialized - /// by calling problem.recomputeLocks() - PresolveStatus - trivialColumnPresolve(); - - /// scans through all rows and does some trivial presolve reductions: - /// * removes singleton rows and updates the column bounds accordingly - /// * checks if the row is redundant or proves infeasibility w.r.t. the - /// activity bounds - /// The activities of the problem must be initialized before calling this - /// fucntion by callnig problem.recomputeActivities() - PresolveStatus - trivialRowPresolve(); - - /// performs trivial row and column presolve and initializes the locks and - /// acitivities. Updates the matrix to reflect the changes - PresolveStatus - trivialPresolve(); - - /// adds a singleton row as a bound change and marks the row redundant - PresolveStatus - removeSingletonRow( int row ); - - /// cleanup small coefficients from single row, adds coefficients changes to - /// the matrix buffer - void - cleanupSmallCoefficients( int row ); - - PresolveStatus - removeEmptyColumns(); - - void - compress( bool full = false ); - - /// check changed activities for infeasibility and row redundancy - PresolveStatus - checkChangedActivities(); - - /// flush changes after applying several reductions - PresolveStatus - flush( bool reset_changed_activities ); - - /// flush changes coefficients after applying several reductions - void - flushChangedCoeffs(); - - void - clearChangeInfo() - { - changed_activities.clear(); - firstNewSingletonCol = singletonColumns.size(); - } - - void - clearStates(); - - void - check_and_compress(); - - const Vec& - getChangedActivities() const - { - return changed_activities; - } - - const Vec& - getSingletonCols() const - { - return singletonColumns; - } - - void - addDeletedVar(int col) - { - deleted_cols.push_back(col); - } - - const Vec& - getRandomColPerm() const - { - return random_col_perm; - } - - const Vec& - getRandomRowPerm() const - { - return random_row_perm; - } - - bool - isColBetterForSubstitution( int col1, int col2 ) const - { - int col1size = problem.getColSizes()[col1]; - int col2size = problem.getColSizes()[col2]; - - // first criterion is sparsity - if( col1size < col2size ) - return true; - if( col2size < col1size ) - return false; - - // second criterion is whether the objective is zero - bool obj1zero = problem.getObjective().coefficients[col1] == 0; - bool obj2zero = problem.getObjective().coefficients[col2] == 0; - - if( obj1zero && !obj2zero ) - return true; - if( !obj1zero && obj2zero ) - return false; - - // tie breaker is the random column permutation - return random_col_perm[col1] < random_col_perm[col2]; - } - - int - getFirstNewSingletonCol() const - { - return firstNewSingletonCol; - } - - int - getNActiveRows() const - { - return problem.getNRows() - stats.ndeletedrows + lastcompress_ndelrows; - } - - int - getNActiveCols() const - { - return problem.getNCols() - stats.ndeletedcols + lastcompress_ndelcols; - } - - const PresolveOptions& - getPresolveOptions() const - { - return presolveOptions; - } - - - std::pair - removeRedundantBounds() - { - return problem.removeRedundantBounds( num, problem.getColFlags(), - problem.getRowActivities() ); - } - - /// returns true if the given transaction conflicts with the current state of - /// changes and false otherwise - ConflictType - checkTransactionConflicts( const Reduction* first, - const Reduction* last ); - - /// returns true if the given transaction was applied and false otherwise - ApplyResult - applyTransaction( const Reduction* first, - const Reduction* last ); - void - roundIntegralColumns( Vec& lbs, Vec& ubs, int col, - Vec& cflags, PresolveStatus& status ); - void - mark_huge_values( const Vec& lbs, const Vec& ubs, - Vec& cflags, int col ); - bool - is_dualfix_enabled( const Vec& obj, int col ) const; - - PresolveStatus - apply_dualfix( Vec& lbs, Vec& ubs, Vec& cflags, - const Vec& obj, const Vec& locks, int col ); - - void - print_detailed( const Reduction* first, - const Reduction* last ) const; - - void - shuffle( std::ranlux24& random_generator, Vec& array ); -}; - -#ifdef PAPILO_USE_EXTERN_TEMPLATES -extern template class ProblemUpdate; -extern template class ProblemUpdate; -extern template class ProblemUpdate; -#endif - -template -ProblemUpdate::ProblemUpdate( Problem& _problem, - PostsolveStorage& _postsolve, - Statistics& _stats, - const PresolveOptions& _presolveOptions, - const Num& _num, const Message& _msg ) - : problem( _problem ), postsolve( _postsolve ), stats( _stats ), - presolveOptions( _presolveOptions ), num( _num ), msg( _msg ) -{ - row_state.resize( _problem.getNRows() ); - col_state.resize( _problem.getNCols() ); - postponeSubstitutions = true; - firstNewSingletonCol = 0; - - lastcompress_ndelcols = 0; - lastcompress_ndelrows = 0; - - std::ranlux24 randgen( _presolveOptions.randomseed ); - random_col_perm.resize( _problem.getNCols() ); - for( int i = 0; i < _problem.getNCols(); ++i ) - random_col_perm[i] = i; - shuffle( randgen, random_col_perm ); - - random_row_perm.resize( _problem.getNRows() ); - for( int i = 0; i < _problem.getNRows(); ++i ) - random_row_perm[i] = i; - shuffle( randgen, random_row_perm ); - -} - -template -void -ProblemUpdate::shuffle( std::ranlux24& random_generator, Vec& array ) -{ - int tmp; - int i; - int end = (int)array.size(); - - int begin = 0; - // loop backwards through all elements and always swap the current last - // element to a random position - while( end > begin + 1 ) - { - end--; - - // get a random position into which the last entry should be shuffled - boost::random::uniform_int_distribution<> distrib( begin, end ); - i = distrib( random_generator ); - - // swap the last element and the random element - tmp = array[i]; - array[i] = array[end]; - array[end] = tmp; - } -} - -template -void -ProblemUpdate::update_activity( ActivityChange actChange, int rowid, - RowActivity& activity ) -{ - if( activity.lastchange == stats.nrounds || - ( actChange == ActivityChange::kMin && activity.ninfmin > 1 ) || - ( actChange == ActivityChange::kMax && activity.ninfmax > 1 ) || - problem.getConstraintMatrix().isRowRedundant( rowid ) ) - return; - - activity.lastchange = stats.nrounds; - - changed_activities.push_back( rowid ); -} - -template -PresolveStatus -ProblemUpdate::fixCol( int col, REAL val ) -{ - ConstraintMatrix& constraintMatrix = problem.getConstraintMatrix(); - Vec& lbs = problem.getLowerBounds(); - Vec& ubs = problem.getUpperBounds(); - Vec& cflags = problem.getColFlags(); - - if( cflags[col].test( ColFlag::kSubstituted ) ) - return PresolveStatus::kUnchanged; - - auto updateActivity = [this]( ActivityChange actChange, int rowid, - RowActivity& activity ) { - update_activity( actChange, rowid, activity ); - }; - - bool lbchanged = cflags[col].test( ColFlag::kLbInf ) || val != lbs[col]; - bool ubchanged = cflags[col].test( ColFlag::kUbInf ) || val != ubs[col]; - - if( lbchanged ) - ++stats.nboundchgs; - if( ubchanged ) - ++stats.nboundchgs; - - if( lbchanged || ubchanged ) - { - auto colvec = constraintMatrix.getColumnCoefficients( col ); - - if( ( !cflags[col].test( ColFlag::kLbInf ) && - num.isFeasLT( val, lbs[col] ) ) || - ( !cflags[col].test( ColFlag::kUbInf ) && - num.isFeasGT( val, ubs[col] ) ) || - ( cflags[col].test( ColFlag::kIntegral ) && - !num.isFeasIntegral( val ) ) ) - { - Message::debug( this, - "fixing {} col {} with bounds [{},{}] to value {} was " - "detected to be infeasible\n", - cflags[col].test( ColFlag::kIntegral ) ? "integral" - : "continuous", - col, - cflags[col].test( ColFlag::kLbInf ) - ? -std::numeric_limits::infinity() - : double( lbs[col] ), - cflags[col].test( ColFlag::kUbInf ) - ? std::numeric_limits::infinity() - : double( ubs[col] ), - double( val ) ); - return PresolveStatus::kInfeasible; - } - - if( cflags[col].test( ColFlag::kFixed ) ) - return PresolveStatus::kUnchanged; - - if( lbchanged ) - { - update_activities_after_boundchange( - colvec.getValues(), colvec.getIndices(), colvec.getLength(), - BoundChange::kLower, lbs[col], val, - cflags[col].test( ColFlag::kLbUseless ), - problem.getRowActivities(), updateActivity ); - - postsolve.storeVarBoundChange( - true, col, lbs[col], - problem.getColFlags()[col].test( ColFlag::kLbInf ), val ); - lbs[col] = val; - cflags[col].unset( ColFlag::kLbUseless ); - } - - if( ubchanged ) - { - update_activities_after_boundchange( - colvec.getValues(), colvec.getIndices(), colvec.getLength(), - BoundChange::kUpper, ubs[col], val, - cflags[col].test( ColFlag::kUbUseless ), - problem.getRowActivities(), updateActivity ); - - postsolve.storeVarBoundChange( - false, col, ubs[col], - problem.getColFlags()[col].test( ColFlag::kUbInf ), val ); - ubs[col] = val; - cflags[col].unset( ColFlag::kUbUseless ); - } - - // remember fixed column - markColFixed( col ); - - setColState( col, State::kBoundsModified ); - - return PresolveStatus::kReduced; - } - - assert( cflags[col].test( ColFlag::kFixed ) ); - - return PresolveStatus::kUnchanged; -} - -template -PresolveStatus -ProblemUpdate::fixColInfinity( int col, REAL val ) -{ - Vec& lbs = problem.getLowerBounds(); - Vec& ubs = problem.getUpperBounds(); - Vec& cflags = problem.getColFlags(); - - if( cflags[col].test( ColFlag::kSubstituted ) || - cflags[col].test( ColFlag::kFixed ) || val == 0 ) - return PresolveStatus::kUnchanged; - - assert( ( val < 0 && cflags[col].test( ColFlag::kLbInf ) ) || - ( val > 0 && cflags[col].test( ColFlag::kUbInf ) ) ); - - // activity doesn't need to be upgraded because rows should be mark redundant - markColFixed( col ); - - setColState( col, State::kBoundsModified ); - if( val == -1 ) - { - assert(cflags[col].test( ColFlag::kLbInf )); - REAL ub = cflags[col].test( ColFlag::kUbInf )? (double) std::numeric_limits::max() :ubs[col]; - postsolve.storeFixedInfCol( col, -1, ub, problem ); - } - if( val == 1 ) - { - assert(cflags[col].test( ColFlag::kUbInf )); - REAL lb = cflags[col].test( ColFlag::kLbInf )? (double) std::numeric_limits::max() :lbs[col]; - postsolve.storeFixedInfCol( col, 1, lb, problem ); - } - - return PresolveStatus::kReduced; -} - -template -PresolveStatus -ProblemUpdate::changeLB( int col, REAL val ) -{ - ConstraintMatrix& constraintMatrix = problem.getConstraintMatrix(); - Vec& cflags = problem.getColFlags(); - Vec& lbs = problem.getLowerBounds(); - Vec& ubs = problem.getUpperBounds(); - - if( cflags[col].test( ColFlag::kSubstituted ) ) - return PresolveStatus::kUnchanged; - - REAL newbound = val; - - auto updateActivity = [this]( ActivityChange actChange, int rowid, - RowActivity& activity ) { - update_activity( actChange, rowid, activity ); - }; - - if( cflags[col].test( ColFlag::kIntegral, ColFlag::kImplInt ) ) - newbound = num.feasCeil( newbound ); - - bool isInfinity = cflags[col].test( ColFlag::kLbInf ); - if( isInfinity || newbound > lbs[col] ) - { - ++stats.nboundchgs; - if( !cflags[col].test( ColFlag::kUbInf ) && newbound > ubs[col] ) - { - if( num.isFeasGT( newbound, ubs[col] ) ) - { - Message::debug( this, - "changing lower bound of {} col {} with bounds " - "[{},{}] to value {} was " - "detected to be infeasible\n", - cflags[col].test( ColFlag::kIntegral ) - ? "integral" - : "continuous", - col, - cflags[col].test( ColFlag::kLbInf ) - ? -std::numeric_limits::infinity() - : double( lbs[col] ), - cflags[col].test( ColFlag::kUbInf ) - ? std::numeric_limits::infinity() - : double( ubs[col] ), - double( newbound ) ); - return PresolveStatus::kInfeasible; - } - - if( !cflags[col].test( ColFlag::kLbInf ) && lbs[col] == ubs[col] ) - return PresolveStatus::kUnchanged; - - newbound = ubs[col]; - } - - if( !num.isHugeVal( newbound ) ) - { - auto colvec = constraintMatrix.getColumnCoefficients( col ); - update_activities_after_boundchange( - colvec.getValues(), colvec.getIndices(), colvec.getLength(), - BoundChange::kLower, lbs[col], newbound, - cflags[col].test( ColFlag::kLbUseless ), - problem.getRowActivities(), updateActivity ); - - cflags[col].unset( ColFlag::kLbUseless ); - } - else - cflags[col].unset( ColFlag::kLbInf ); - - postsolve.storeVarBoundChange( true, col, lbs[col], isInfinity, - newbound ); - lbs[col] = newbound; - - if( !cflags[col].test( ColFlag::kUbInf ) && ubs[col] == lbs[col] ) - { - cflags[col].set( ColFlag::kFixed ); - deleted_cols.push_back( col ); - ++stats.ndeletedcols; - - if( cflags[col].test( ColFlag::kIntegral ) ) - --problem.getNumIntegralCols(); - else - --problem.getNumContinuousCols(); - } - - setColState( col, State::kBoundsModified ); - - return PresolveStatus::kReduced; - } - - return PresolveStatus::kUnchanged; -} - -template -PresolveStatus -ProblemUpdate::changeUB( int col, REAL val ) -{ - ConstraintMatrix& constraintMatrix = problem.getConstraintMatrix(); - Vec& cflags = problem.getColFlags(); - Vec& lbs = problem.getLowerBounds(); - Vec& ubs = problem.getUpperBounds(); - - if( cflags[col].test( ColFlag::kSubstituted ) ) - return PresolveStatus::kUnchanged; - - REAL newbound = val; - - auto updateActivity = [this]( ActivityChange actChange, int rowid, - RowActivity& activity ) { - update_activity( actChange, rowid, activity ); - }; - - if( cflags[col].test( ColFlag::kIntegral, ColFlag::kImplInt ) ) - newbound = num.feasFloor( newbound ); - - bool isInfinity = cflags[col].test( ColFlag::kUbInf ); - if( isInfinity || newbound < ubs[col] ) - { - ++stats.nboundchgs; - if( !cflags[col].test( ColFlag::kLbInf ) && newbound < lbs[col] ) - { - if( num.isFeasLT( newbound, lbs[col] ) ) - { - Message::debug( this, - "changing upper bound of {} col {} with bounds " - "[{},{}] to value {} was " - "detected to be infeasible\n", - cflags[col].test( ColFlag::kIntegral ) - ? "integral" - : "continuous", - col, - cflags[col].test( ColFlag::kLbInf ) - ? -std::numeric_limits::infinity() - : double( lbs[col] ), - cflags[col].test( ColFlag::kUbInf ) - ? std::numeric_limits::infinity() - : double( ubs[col] ), - double( newbound ) ); - return PresolveStatus::kInfeasible; - } - - if( !cflags[col].test( ColFlag::kUbInf ) && lbs[col] == ubs[col] ) - return PresolveStatus::kUnchanged; - - newbound = lbs[col]; - } - - if( !num.isHugeVal( newbound ) ) - { - auto colvec = constraintMatrix.getColumnCoefficients( col ); - update_activities_after_boundchange( - colvec.getValues(), colvec.getIndices(), colvec.getLength(), - BoundChange::kUpper, ubs[col], newbound, - cflags[col].test( ColFlag::kUbUseless ), - problem.getRowActivities(), updateActivity ); - cflags[col].unset( ColFlag::kUbUseless ); - } - else - cflags[col].unset( ColFlag::kUbInf ); - - postsolve.storeVarBoundChange( false, col, ubs[col], isInfinity, - newbound ); - ubs[col] = newbound; - - if( !cflags[col].test( ColFlag::kLbInf ) && ubs[col] == lbs[col] ) - { - cflags[col].set( ColFlag::kFixed ); - deleted_cols.push_back( col ); - ++stats.ndeletedcols; - - if( cflags[col].test( ColFlag::kIntegral ) ) - --problem.getNumIntegralCols(); - else - --problem.getNumContinuousCols(); - } - - setColState( col, State::kBoundsModified ); - - return PresolveStatus::kReduced; - } - - return PresolveStatus::kUnchanged; -} - -template -void -ProblemUpdate::compress( bool full ) -{ - if( problem.getNCols() == getNActiveCols() && - problem.getNRows() == getNActiveRows() && !full ) - return; - // TODO: do not compress if ActiveRows are zero because rowmapping in Postsolve is deleted. -// if(getNActiveRows() <= 0) -// return; - - Message::debug( this, - "compressing problem ({} rows, {} cols) to active problem " - "({} rows, {} cols)\n", - problem.getNRows(), problem.getNCols(), getNActiveRows(), - getNActiveCols() ); - - std::pair, Vec> mappings = problem.compress( full ); - assert( redundant_rows.empty() ); - assert( deleted_cols.empty() ); - assert( dirty_col_states.empty() ); - assert( dirty_row_states.empty() ); - assert( matrix_buffer.empty() ); - - row_state.resize( problem.getNRows() ); - col_state.resize( problem.getNCols() ); - -#ifdef PAPILO_TBB - tbb::parallel_invoke( - [this, &mappings, full]() { - compress_index_vector( mappings.first, random_row_perm ); - if( full ) - random_row_perm.shrink_to_fit(); - }, - [this, &mappings, full]() { - compress_index_vector( mappings.second, random_col_perm ); - if( full ) - random_col_perm.shrink_to_fit(); - }, - [this, &mappings, full]() { - postsolve.compress( mappings.first, mappings.second, full ); - }, - [this, &mappings, full]() { - // update row index sets - compress_index_vector( mappings.first, changed_activities ); - if( full ) - changed_activities.shrink_to_fit(); - }, - [this, &mappings, full]() { - compress_index_vector( mappings.first, singletonRows ); - if( full ) - singletonRows.shrink_to_fit(); - }, - // update column index sets - [this, &mappings, full]() { - int numNewSingletonCols = - static_cast( singletonColumns.size() ) - - firstNewSingletonCol; - compress_index_vector( mappings.second, singletonColumns ); - firstNewSingletonCol = - std::max( 0, static_cast( singletonColumns.size() ) - - numNewSingletonCols ); - if( full ) - singletonColumns.shrink_to_fit(); - }, - [this, &mappings, full]() { - compress_index_vector( mappings.second, emptyColumns ); - if( full ) - emptyColumns.shrink_to_fit(); - }, - [this, &mappings]() { - for( PresolveMethod* observer : compress_observers ) - observer->compress( mappings.first, mappings.second ); - } ); -#else - compress_index_vector( mappings.first, random_row_perm ); - compress_index_vector( mappings.second, random_col_perm ); - postsolve.compress( mappings.first, mappings.second, full ); - compress_index_vector( mappings.first, changed_activities ); - compress_index_vector( mappings.first, singletonRows ); - compress_index_vector( mappings.second, emptyColumns ); - int numNewSingletonCols = - static_cast( singletonColumns.size() ) - - firstNewSingletonCol; - compress_index_vector( mappings.second, singletonColumns ); - firstNewSingletonCol = - std::max( 0, static_cast( singletonColumns.size() ) - - numNewSingletonCols ); - if( full ) - { - random_row_perm.shrink_to_fit(); - random_col_perm.shrink_to_fit(); - changed_activities.shrink_to_fit(); - singletonRows.shrink_to_fit(); - emptyColumns.shrink_to_fit(); - singletonColumns.shrink_to_fit(); - - } - for( PresolveMethod* observer : compress_observers ) - observer->compress( mappings.first, mappings.second ); -#endif - - lastcompress_ndelrows = stats.ndeletedrows; - lastcompress_ndelcols = stats.ndeletedcols; -} - -template -PresolveStatus -ProblemUpdate::checkChangedActivities() -{ - ConstraintMatrix& consmatrix = problem.getConstraintMatrix(); - const Vec& rflags = consmatrix.getRowFlags(); - const Vec& lhs = consmatrix.getLeftHandSides(); - const Vec& rhs = consmatrix.getRightHandSides(); - - PresolveStatus status = PresolveStatus::kUnchanged; - for( int r : changed_activities ) - { - if( rflags[r].test( RowFlag::kRedundant ) ) - continue; - - RowStatus st = problem.getRowActivities()[r].checkStatus( - num, rflags[r], lhs[r], rhs[r] ); - - switch( st ) - { - case RowStatus::kRedundant: - markRowRedundant( r ); - status = PresolveStatus::kReduced; - break; - case RowStatus::kRedundantLhs: - postsolve.storeRowBoundChange( - true, r, REAL{ 0 }, true, REAL{ 0 }, - consmatrix.getRowFlags()[r].test( RowFlag::kLhsInf ) ); - consmatrix.template modifyLeftHandSide( r, num ); - status = PresolveStatus::kReduced; - break; - case RowStatus::kRedundantRhs: - postsolve.storeRowBoundChange( - false, r, REAL{ 0 }, true, REAL{ 0 }, - consmatrix.getRowFlags()[r].test( RowFlag::kRhsInf ) ); - consmatrix.template modifyRightHandSide( r, num ); - status = PresolveStatus::kReduced; - break; - case RowStatus::kInfeasible: - return PresolveStatus::kInfeasible; - case RowStatus::kUnknown: - continue; - } - } - - return status; -} - -template -void -ProblemUpdate::flushChangedCoeffs() -{ - // apply outstanding coefficient change - if( !matrix_buffer.empty() ) - { - const Vec& lbs = problem.getLowerBounds(); - const Vec& ubs = problem.getUpperBounds(); - const Vec& cflags = problem.getColFlags(); - Vec>& activities = problem.getRowActivities(); - - auto coeffChanged = [this, &lbs, &cflags, &ubs, &activities]( - int row, int col, REAL oldval, REAL newval ) { - auto rowvec = problem.getConstraintMatrix().getRowCoefficients( row ); - update_activity_after_coeffchange( - lbs[col], ubs[col], cflags[col], oldval, newval, activities[row], - rowvec.getLength(), rowvec.getIndices(), rowvec.getValues(), - problem.getVariableDomains(), num, - [this, row]( ActivityChange actChange, - RowActivity& activity ) - { update_activity( actChange, row, activity ); } ); - ++stats.ncoefchgs; - // TODO: update up/down-locks -> so that i.e. DualFix can use it - }; - - problem.getConstraintMatrix().changeCoefficients( - matrix_buffer, singletonRows, singletonColumns, emptyColumns, - activities, coeffChanged ); - - matrix_buffer.clear(); - } -} - -template -PresolveStatus -ProblemUpdate::flush( bool reset_changed_activities ) -{ - Vec& rflags = problem.getRowFlags(); - Vec>& activities = problem.getRowActivities(); - ConstraintMatrix& consMatrix = problem.getConstraintMatrix(); - - // apply outstanding coefficient change - flushChangedCoeffs(); - - // remove all singleton rows after applying the coefficient changes - if( !singletonRows.empty() ) - { - for( int row : singletonRows ) - { - if( removeSingletonRow( row ) == PresolveStatus::kInfeasible ) - { - Message::debug( - this, "[{}:{}] removeSingletonRow detected infeasible row\n", - __FILE__, __LINE__ ); - return PresolveStatus::kInfeasible; - } - } - - singletonRows.clear(); - } - - // check rows with changed activities for redundancy or infeasibility - // and remove them from the changed activities vector - if( checkChangedActivities() == PresolveStatus::kInfeasible ) - return PresolveStatus::kInfeasible; - - if( reset_changed_activities ) - { - auto iter = - std::remove_if( changed_activities.begin(), changed_activities.end(), - [&rflags]( int row ) { - return rflags[row].test( RowFlag::kRedundant ); - } ); - - changed_activities.erase( iter, changed_activities.end() ); - } - - // remove constants of fixed columns - removeFixedCols(); - - // delete fixed columns and redundant rows form the matrix - // TODO update locks in delete rows and cols function - consMatrix.deleteRowsAndCols( redundant_rows, deleted_cols, activities, - singletonRows, singletonColumns, - emptyColumns ); - - // remove singleton columns from list of singleton columns if they are not - // singletons anymore - if( !singletonColumns.empty() ) - { - const Vec& colsizes = problem.getColSizes(); - int k = 0; - int i; - assert( firstNewSingletonCol <= (int) singletonColumns.size() ); - for( i = 0; i != firstNewSingletonCol; ++i ) - { - if( colsizes[singletonColumns[i]] != 1 ) - ++k; - else if( k != 0 ) - singletonColumns[i - k] = singletonColumns[i]; - } - - firstNewSingletonCol -= k; - - int nsingletoncols = static_cast( singletonColumns.size() ); - assert( i <= nsingletoncols ); - for( ; i != nsingletoncols; ++i ) - { - if( colsizes[singletonColumns[i]] != 1 ) - ++k; - else if( k != 0 ) - singletonColumns[i - k] = singletonColumns[i]; - } - - nsingletoncols -= k; - singletonColumns.resize( nsingletoncols ); - - assert( firstNewSingletonCol >= 0 && - firstNewSingletonCol <= nsingletoncols ); - assert( std::all_of( singletonColumns.begin(), singletonColumns.end(), - [&]( int col ) { return colsizes[col] == 1; } ) ); - } - - // fix empty columns - if( removeEmptyColumns() == PresolveStatus::kUnbndOrInfeas ) - return PresolveStatus::kUnbndOrInfeas; - - return PresolveStatus::kReduced; -} - -template -void -ProblemUpdate::clearStates() -{ - // clear states of rows - for( int row : dirty_row_states ) - row_state[row] = State::kUnmodified; - - dirty_row_states.clear(); - - assert( - std::all_of( row_state.begin(), row_state.end(), []( Flags s ) { - return s.equal( State::kUnmodified ); - } ) ); - - // clear states of columns - for( int col : dirty_col_states ) - col_state[col] = State::kUnmodified; - - dirty_col_states.clear(); - - assert( - std::all_of( col_state.begin(), col_state.end(), []( Flags s ) { - return s.equal( State::kUnmodified ); - } ) ); -} - -template -void -ProblemUpdate::check_and_compress() -{ - if( presolveOptions.compressfac != 0 && - ( ( problem.getNCols() > 100 && - getNActiveCols() < - problem.getNCols() * presolveOptions.compressfac ) || - ( problem.getNRows() > 100 && - getNActiveRows() < - problem.getNRows() * presolveOptions.compressfac ) ) ) - compress(); -} - -template -void -ProblemUpdate::removeFixedCols() -{ - Objective& obj = problem.getObjective(); - const Vec& lbs = problem.getLowerBounds(); - const Vec& cflags = problem.getColFlags(); - Vec>& activities = problem.getRowActivities(); - ConstraintMatrix& consMatrix = problem.getConstraintMatrix(); - Vec& rflags = consMatrix.getRowFlags(); - Vec& lhs = consMatrix.getLeftHandSides(); - Vec& rhs = consMatrix.getRightHandSides(); - - for( int col : deleted_cols ) - { - if( !cflags[col].test( ColFlag::kFixed ) ) - continue; - - if( cflags[col].test( ColFlag::kLbInf ) || cflags[col].test( ColFlag::kUbInf ) ) - continue; - - assert( - num.isEq( lbs[col], problem.getUpperBounds()[col] ) && !problem.getColFlags()[col] - .test( ColFlag::kUbInf ) && - !problem.getColFlags()[col].test( ColFlag::kLbInf ) ); - - auto colvec = consMatrix.getColumnCoefficients( col ); - postsolve.storeFixedCol( col, lbs[col], colvec, obj.coefficients ); - - // if it is fixed to zero activities and sides do not need to be - // updated - if( lbs[col] == 0 ) - continue; - - // update objective offset - if( obj.coefficients[col] != 0 ) - { - obj.offset += lbs[col] * obj.coefficients[col]; - obj.coefficients[col] = 0; - } - - - // fixed to nonzero value, so update sides and activities - int collen = colvec.getLength(); - const int* colrows = colvec.getIndices(); - const REAL* colvals = colvec.getValues(); - - for( int i = 0; i != collen; ++i ) - { - int row = colrows[i]; - - // if the row is redundant it will also be removed and does not need - // to be updated - if( rflags[row].test( RowFlag::kRedundant ) ) - continue; - - // subtract constant contribution from activity and sides - REAL constant = lbs[col] * colvals[i]; - activities[row].min -= constant; - activities[row].max -= constant; - - if( !rflags[row].test( RowFlag::kLhsInf ) ) - lhs[row] -= constant; - - if( !rflags[row].test( RowFlag::kRhsInf ) ) - rhs[row] -= constant; - - // due to numerics a ranged row can become an equality - if( !rflags[row].test( RowFlag::kLhsInf, RowFlag::kRhsInf, - RowFlag::kEquation ) && - lhs[row] == rhs[row] ) - rflags[row].set( RowFlag::kEquation ); - } - } -} - -template -PresolveStatus -ProblemUpdate::trivialColumnPresolve() -{ - Vec& lbs = problem.getLowerBounds(); - Vec& ubs = problem.getUpperBounds(); - Vec& cflags = problem.getColFlags(); - Vec& colsize = problem.getColSizes(); - Vec& obj = problem.getObjective().coefficients; - Vec& locks = problem.getLocks(); - - PresolveStatus status = PresolveStatus::kUnchanged; - - for( int col = 0; col < problem.getNCols(); ++col ) - { - if( cflags[col].test( ColFlag::kInactive ) ) - continue; - - // for integral columns round the bounds to integral values - roundIntegralColumns( lbs, ubs, col, cflags, status ); - - mark_huge_values( lbs, ubs, cflags, col ); - - if( !cflags[col].test( ColFlag::kUnbounded ) ) - { - if( lbs[col] > ubs[col] ) - { - Message::debug( - this, "[{}:{}] trivial presolve detected conflicting bounds\n", - __FILE__, __LINE__ ); - return PresolveStatus::kInfeasible; - } - - // remember fixed columns - if( lbs[col] == ubs[col] ) - { - markColFixed( col ); - status = PresolveStatus::kReduced; - continue; - } - } - - status = apply_dualfix( lbs, ubs, cflags, obj, locks, col ); - if( status == PresolveStatus::kUnbndOrInfeas ) - return status; - else if( status == PresolveStatus::kReduced ) - continue; - - switch( colsize[col] ) - { - case 0: - emptyColumns.push_back( col ); - break; - case 1: - singletonColumns.push_back( col ); - } - } - - return status; -} - -template -PresolveStatus -ProblemUpdate::apply_dualfix( Vec& lbs, Vec& ubs, - Vec& cflags, const Vec& obj, - const Vec& locks, int col ) -{ - if( is_dualfix_enabled( obj, col ) ) - { - if( locks[col].down == 0 && obj[col] >= 0 ) - { - if( cflags[col].test( ColFlag::kLbInf ) ) - { - if( obj[col] != 0 ) - { - Message::debug( this, - "[{}:{}] dual fixing in trivial presolve " - "detected status UNBND_OR_INFEAS\n", - __FILE__, __LINE__ ); - return PresolveStatus::kUnbndOrInfeas; - } - } - else - { - postsolve.storeVarBoundChange( false, col, ubs[col], - cflags[col].test( ColFlag::kUbInf ), - lbs[col] ); - ubs[col] = lbs[col]; - cflags[col].unset( ColFlag::kUbInf ); - ++stats.nboundchgs; - - markColFixed( col ); - return PresolveStatus::kReduced; - } - } - - if( locks[col].up == 0 && obj[col] <= 0 ) - { - if( cflags[col].test( ColFlag::kUbInf ) ) - { - if( obj[col] != 0 ) - { - Message::debug( this, - "[{}:{}] dual fixing in trivial presolve " - "detected status UNBND_OR_INFEAS\n", - __FILE__, __LINE__ ); - return PresolveStatus::kUnbndOrInfeas; - } - } - else - { - postsolve.storeVarBoundChange( true, col, lbs[col], - cflags[col].test( ColFlag::kLbInf ), - ubs[col] ); - lbs[col] = ubs[col]; - cflags[col].unset( ColFlag::kLbInf ); - ++stats.nboundchgs; - - markColFixed( col ); - - return PresolveStatus::kReduced; - } - } - } - return PresolveStatus::kUnchanged; -} - -template -bool -ProblemUpdate::is_dualfix_enabled( const Vec& obj, int col ) const -{ - bool dualfix; - switch( presolveOptions.dualreds ) - { - default: - assert( false ); - case 0: - dualfix = false; - break; - case 1: - dualfix = obj[col] != 0; - break; - case 2: - dualfix = true; - } - return dualfix; -} - -template -void -ProblemUpdate::mark_huge_values( const Vec& lbs, - const Vec& ubs, - Vec& cflags, int col ) -{ - if( !cflags[col].test( ColFlag::kLbInf ) && num.isHugeVal( lbs[col] ) ) - cflags[col].set( ColFlag::kLbHuge ); - - if( !cflags[col].test( ColFlag::kUbInf ) && num.isHugeVal( ubs[col] ) ) - cflags[col].set( ColFlag::kUbHuge ); -} - -template -void -ProblemUpdate::roundIntegralColumns( Vec& lbs, Vec& ubs, - int col, Vec& cflags, - PresolveStatus& status ) -{ - if( cflags[col].test( ColFlag::kIntegral ) ) - { - if( !cflags[col].test( ColFlag::kLbInf ) ) - { - REAL ceillb = ceil( lbs[col] ); - if( ceillb != lbs[col] ) - { - ++stats.nboundchgs; - lbs[col] = ceillb; - status = PresolveStatus::kReduced; - } - } - - if( !cflags[col].test( ColFlag::kUbInf ) ) - { - REAL floorub = floor( ubs[col] ); - if( floorub != ubs[col] ) - { - ++stats.nboundchgs; - ubs[col] = floorub; - status = PresolveStatus::kReduced; - } - } - } -} - -template -PresolveStatus -ProblemUpdate::trivialRowPresolve() -{ - ConstraintMatrix& consMatrix = problem.getConstraintMatrix(); - Vec& rowsize = consMatrix.getRowSizes(); - Vec& rflags = consMatrix.getRowFlags(); - Vec>& activities = problem.getRowActivities(); - const Vec& lhs = consMatrix.getLeftHandSides(); - const Vec& rhs = consMatrix.getRightHandSides(); - - assert( (int) activities.size() == problem.getNRows() ); - PresolveStatus status = PresolveStatus::kUnchanged; - - for( int row = 0; row != problem.getNRows(); ++row ) - { - switch( rowsize[row] ) - { - case 0: - if( !rflags[row].test( RowFlag::kLhsInf ) && - num.isFeasGT( lhs[row], 0 ) ) - { - Message::debug( - this, "[{}:{}] trivial presolve detected infeasible row\n", - __FILE__, __LINE__ ); - return PresolveStatus::kInfeasible; - } - if( !rflags[row].test( RowFlag::kRhsInf ) && - num.isFeasLT( rhs[row], 0 ) ) - { - Message::debug( - this, "[{}:{}] trivial presolve detected infeasible row\n", - __FILE__, __LINE__ ); - return PresolveStatus::kInfeasible; - } - rflags[row].set( RowFlag::kRedundant ); - rowsize[row] = -1; - postsolve.storeRedundantRow( row ); - status = PresolveStatus::kReduced; - break; - case 1: - status = removeSingletonRow( row ); - if( status == PresolveStatus::kInfeasible ) - { - Message::debug( - this, "[{}:{}] removeSingletonRow detected infeasible row\n", - __FILE__, __LINE__ ); - return status; - } - break; - default: - { - RowStatus st = activities[row].checkStatus( num, rflags[row], lhs[row], - rhs[row] ); - switch( st ) - { - case RowStatus::kRedundant: - break; - case RowStatus::kRedundantLhs: - postsolve.storeRowBoundChange( - true, row, REAL{ 0 }, true, REAL{ 0 }, - consMatrix.getRowFlags()[row].test( RowFlag::kLhsInf ) ); - consMatrix.template modifyLeftHandSide( row, num ); - status = PresolveStatus::kReduced; - cleanupSmallCoefficients( row ); - break; - case RowStatus::kRedundantRhs: - postsolve.storeRowBoundChange( - false, row, REAL{ 0 }, true, REAL{ 0 }, - consMatrix.getRowFlags()[row].test( RowFlag::kRhsInf ) ); - consMatrix.template modifyRightHandSide( row, num ); - status = PresolveStatus::kReduced; - cleanupSmallCoefficients( row ); - break; - case RowStatus::kInfeasible: - return PresolveStatus::kInfeasible; - case RowStatus::kUnknown: - if( !rflags[row].test( RowFlag::kRhsInf, RowFlag::kLhsInf, - RowFlag::kEquation ) ) - { - assert( !rflags[row].test( RowFlag::kRhsInf ) ); - assert( !rflags[row].test( RowFlag::kLhsInf ) ); - assert( !rflags[row].test( RowFlag::kEquation ) ); - if( lhs[row] == rhs[row] ) - rflags[row].set( RowFlag::kEquation ); - } - cleanupSmallCoefficients( row ); - } - } - } - - // row should be either redundant, or the equality flag must be set - // correctly - assert( rflags[row].test( RowFlag::kRedundant ) || - ( !rflags[row].test( RowFlag::kEquation ) && - ( rflags[row].test( RowFlag::kLhsInf, RowFlag::kRhsInf ) || - lhs[row] != rhs[row] ) ) || - ( rflags[row].test( RowFlag::kEquation ) && - lhs[row] == rhs[row] && - !rflags[row].test( RowFlag::kLhsInf, RowFlag::kRhsInf ) ) ); - } - - flushChangedCoeffs(); - - return status; -} - -template -PresolveStatus -ProblemUpdate::trivialPresolve() -{ - if( presolveOptions.dualreds != 0 ) - problem.recomputeLocks(); - - PresolveStatus status = trivialColumnPresolve(); - if( status == PresolveStatus::kInfeasible || - status == PresolveStatus::kUnbndOrInfeas ) - return status; - - problem.recomputeAllActivities(); - status = trivialRowPresolve(); - if( status == PresolveStatus::kInfeasible || - status == PresolveStatus::kUnbndOrInfeas ) - return status; - - removeFixedCols(); - - problem.getConstraintMatrix().deleteRowsAndCols( - redundant_rows, deleted_cols, problem.getRowActivities(), singletonRows, - singletonColumns, emptyColumns ); - - for( int row : singletonRows ) - { - status = removeSingletonRow( row ); - if( status == PresolveStatus::kInfeasible ) - { - Message::debug( this, - "[{}:{}] removeSingletonRow detected infeasible row\n", - __FILE__, __LINE__ ); - return status; - } - } - - if( !singletonColumns.empty() ) - { - int numNewSingletonCols = - static_cast( singletonColumns.size() ) - firstNewSingletonCol; - assert( numNewSingletonCols >= 0 ); - // erasing variables from the singleton Cols with >1 or ==0 - // if a variable is aggregated its appearance can again be raised - auto it = std::remove_if( - singletonColumns.begin(), singletonColumns.end(), - [this]( int c ) { return problem.getColSizes()[c] != 1; } ); - singletonColumns.erase( it, singletonColumns.end() ); - firstNewSingletonCol = - std::max( 0, static_cast( singletonColumns.size() ) - - numNewSingletonCols ); - } - - status = checkChangedActivities(); - if( status == PresolveStatus::kInfeasible || - status == PresolveStatus::kUnbndOrInfeas ) - return status; - - changed_activities.clear(); - - const Vec& rflags = problem.getRowFlags(); - - for( int r = 0; r != problem.getNRows(); ++r ) - { - if( rflags[r].test( RowFlag::kRedundant ) ) - continue; - - RowActivity& activity = problem.getRowActivities()[r]; - if( activity.ninfmin == 0 || activity.ninfmax == 0 || - ( activity.ninfmax == 1 && !rflags[r].test( RowFlag::kLhsInf ) ) || - ( activity.ninfmin == 1 && !rflags[r].test( RowFlag::kRhsInf ) ) ) - changed_activities.push_back( r ); - } - - flush( true ); - - return status; -} - -template -PresolveStatus -ProblemUpdate::removeSingletonRow( int row ) -{ - ConstraintMatrix& consMatrix = problem.getConstraintMatrix(); - const Vec& rowsize = consMatrix.getRowSizes(); - Vec& rflags = consMatrix.getRowFlags(); - - PresolveStatus status = PresolveStatus::kUnchanged; - - if( rowsize[row] != 1 || rflags[row].test( RowFlag::kRedundant ) ) - return status; - - auto rowvec = consMatrix.getRowCoefficients( row ); - - assert( rowvec.getLength() == 1 ); - - const REAL val = rowvec.getValues()[0]; - const int col = rowvec.getIndices()[0]; - const REAL lhs = consMatrix.getLeftHandSides()[row]; - const REAL rhs = consMatrix.getRightHandSides()[row]; - const bool isLhsInfinity = rflags[row].test( RowFlag::kLhsInf ); - const bool isRhsInfinity = rflags[row].test( RowFlag::kRhsInf ); - - if( rflags[row].test( RowFlag::kEquation ) ) - { - postsolve.storeSavedRow( row, rowvec, lhs, rhs, rflags[row] ); - REAL fixed_val = rhs / val; - if( num.isZero( rhs ) ) - fixed_val = 0.0; - status = fixCol( col, fixed_val ); - } - else - { - if( val < 0 ) - { - if( !isLhsInfinity ) - { - REAL fixed_val = lhs / val; - if( num.isZero( lhs ) ) - fixed_val = 0.0; - postsolve.storeSavedRow( row, rowvec, lhs, rhs, rflags[row] ); - status = changeUB( col, fixed_val ); - } - - if( !isRhsInfinity && status != PresolveStatus::kInfeasible ) - { - REAL fixed_val = rhs / val; - if( num.isZero( rhs ) ) - fixed_val = 0.0; - postsolve.storeSavedRow( row, rowvec, lhs, rhs, rflags[row] ); - status = changeLB( col, fixed_val ); - } - } - else - { - assert( val > 0 ); - if( !isLhsInfinity ) - { - REAL fixed_val = lhs / val; - if( num.isZero( lhs ) ) - fixed_val = 0.0; - postsolve.storeSavedRow( row, rowvec, lhs, rhs, rflags[row] ); - status = changeLB( col, fixed_val ); - } - - if( !isRhsInfinity && status != PresolveStatus::kInfeasible ) - { - REAL fixed_val = rhs / val; - if( num.isZero( rhs ) ) - fixed_val = 0.0; - postsolve.storeSavedRow( row, rowvec, lhs, rhs, rflags[row] ); - status = changeUB( col, fixed_val ); - } - } - } - - markRowRedundant( row ); - - return status; -} // namespace papilo - -template -void -ProblemUpdate::cleanupSmallCoefficients( int row ) -{ - ConstraintMatrix& consMatrix = problem.getConstraintMatrix(); - const Vec& lbs = problem.getLowerBounds(); - const Vec& ubs = problem.getUpperBounds(); - const Vec& cflags = problem.getColFlags(); - - auto rowvec = consMatrix.getRowCoefficients( row ); - - // arrays with nonzeros and their column index of this row - const REAL* values = rowvec.getValues(); - const int* columns = rowvec.getIndices(); - - // number of nonzeros in row, i.e. length of arrays above - int len = rowvec.getLength(); - - // acces to sides of the given row - REAL& lhs = consMatrix.getLeftHandSides()[row]; - REAL& rhs = consMatrix.getRightHandSides()[row]; - RowFlags& rowf = consMatrix.getRowFlags()[row]; - - // loop over non-zeros of this row - REAL total_mod = 0; - for( int i = 0; i != len; ++i ) - { - int col = columns[i]; - - if( cflags[col].test( ColFlag::kUnbounded, ColFlag::kInactive ) ) - continue; - - assert( ubs[col] > lbs[col] ); - - // model Cleanup - REAL absval = abs( values[i] ); - - if( absval < presolveOptions.minabscoeff ) - { - matrix_buffer.addEntry( row, col, 0 ); - - Message::debug( this, "removed tiny coefficient with value {}\n", - double( values[i] ) ); - - continue; - } - - if( absval <= 1e-3 && - absval * ( ubs[col] - lbs[col] ) * len <= 1e-2 * num.getFeasTol() ) - { - REAL temp_total_mod = total_mod + absval * ( ubs[col] - lbs[col] ); - if( temp_total_mod <= 0.1 * num.getFeasTol() ) - { - matrix_buffer.addEntry( row, col, 0 ); - - Message::debug( this, "removed small coefficient with value {}\n", - double( values[i] ) ); - - if( lbs[col] != 0 ) - { - REAL sidechange = values[i] * lbs[col]; - if( !rowf.test( RowFlag::kRhsInf ) ) - { - rhs -= sidechange; - ++stats.nsidechgs; - } - if( !rowf.test( RowFlag::kLhsInf ) ) - { - lhs -= sidechange; - ++stats.nsidechgs; - } - - // due to numerics a ranged row can become an equality - if( !rowf.test( RowFlag::kLhsInf, RowFlag::kRhsInf, - RowFlag::kEquation ) && - lhs == rhs ) - rowf.set( RowFlag::kEquation ); - } - - total_mod = temp_total_mod; - } - } - } -} - -template -PresolveStatus -ProblemUpdate::removeEmptyColumns() -{ - if( presolveOptions.dualreds != 0 && !emptyColumns.empty() ) - { - Objective& obj = problem.getObjective(); - VariableDomains& domains = problem.getVariableDomains(); - Vec& colsize = problem.getConstraintMatrix().getColSizes(); - - SparseVectorView empty_column; - for( int col : emptyColumns ) - { - if( colsize[col] != 0 ) - continue; - - if( presolveOptions.dualreds == 1 && num.isZero(obj.coefficients[col]) ) - continue; - - if( !domains.flags[col].test( ColFlag::kInactive ) ) - { - assert( colsize[col] == 0 ); - - REAL fixval; - - if( num.isZero(obj.coefficients[col]) ) - { - fixval = 0; - - if( !domains.flags[col].test( ColFlag::kUbInf ) && - num.isLT(domains.upper_bounds[col], 0) ) - fixval = domains.upper_bounds[col]; - else if( !domains.flags[col].test( ColFlag::kLbInf ) && - num.isGT(domains.lower_bounds[col], 0) ) - fixval = domains.lower_bounds[col]; - - // notify for storing the bound for recalculation - if( domains.flags[col].test( ColFlag::kLbInf ) || - !num.isEq( domains.lower_bounds[col], fixval ) ) - postsolve.storeVarBoundChange( - true, col, domains.lower_bounds[col], - domains.flags[col].test( ColFlag::kLbInf ), fixval ); - if( domains.flags[col].test( ColFlag::kUbInf ) || - !num.isEq( domains.upper_bounds[col], fixval ) ) - postsolve.storeVarBoundChange( - false, col, domains.upper_bounds[col], - domains.flags[col].test( ColFlag::kUbInf ), fixval ); - } - else - { - if( obj.coefficients[col] < 0 ) - { - if( domains.flags[col].test( ColFlag::kUbInf ) ) - return PresolveStatus::kUnbndOrInfeas; - - fixval = domains.upper_bounds[col]; - postsolve.storeVarBoundChange( - true, col, domains.lower_bounds[col], - domains.flags[col].test( ColFlag::kLbInf ), fixval ); - } - else - { - assert( obj.coefficients[col] > 0 ); - if( domains.flags[col].test( ColFlag::kLbInf ) ) - return PresolveStatus::kUnbndOrInfeas; - - fixval = domains.lower_bounds[col]; - postsolve.storeVarBoundChange( - false, col, domains.upper_bounds[col], - domains.flags[col].test( ColFlag::kUbInf ), fixval ); - } - } - postsolve.storeFixedCol( col, fixval, empty_column, - obj.coefficients ); - if( obj.coefficients[col] != 0 ) - { - obj.offset += obj.coefficients[col] * fixval; - obj.coefficients[col] = 0; - } - domains.flags[col].set( ColFlag::kFixed ); - - ++stats.ndeletedcols; - - if( domains.flags[col].test( ColFlag::kIntegral ) ) - --problem.getNumIntegralCols(); - else - --problem.getNumContinuousCols(); - } - - assert( num.isZero(obj.coefficients[col]) ); - - colsize[col] = -1; - } - - emptyColumns.clear(); - - return PresolveStatus::kReduced; - } - - return PresolveStatus::kUnchanged; -} - -/// returns true if the given transaction conflicts with the current state of -/// changes and false otherwise -template -ConflictType -ProblemUpdate::checkTransactionConflicts( const Reduction* first, - const Reduction* last ) -{ - // check if transaction conflicts with current state - for( const Reduction* iter = first; iter != last; ++iter ) - { - const Reduction& reduction = *iter; - - if( reduction.row < 0 ) - { - assert( reduction.col >= 0 ); - int colop = reduction.row; - switch( colop ) - { - case ColReduction::LOCKED: - // if the transaction wants to lock the column it must not be - // modifed yet - if( col_state[reduction.col].test( State::kModified ) ) - { - msg.detailed( "CONFLICT lock col {}\n", reduction.col ); - return ConflictType::kConflict; - } - break; - case ColReduction::BOUNDS_LOCKED: - if( col_state[reduction.col].test( State::kBoundsModified ) ) - { - msg.detailed( "CONFLICT bounds lock col {}\n", reduction.col ); - return ConflictType::kConflict; - } - break; - case ColReduction::OBJECTIVE: - case ColReduction::PARALLEL: - case ColReduction::SUBSTITUTE_OBJ: - break; - case ColReduction::SUBSTITUTE: - case ColReduction::REPLACE: - // we postponed the substitution to be performed last - if( postponeSubstitutions ) - return ConflictType::kPostpone; - break; - default: - break; - } - } - else if( reduction.col < 0 ) - { - assert( reduction.row >= 0 && reduction.col < 0 ); - int rowop = reduction.col; - switch( rowop ) - { - case RowReduction::LOCKED: - // if the transaction wants to lock the row it must not be - // modified yet - if( row_state[reduction.row].test( State::kModified, - State::kBoundsModified ) ) - { - msg.detailed( "CONFLICT row lock row {}\n", reduction.row ); - return ConflictType::kConflict; - } - break; - case RowReduction::LHS_INF: - case RowReduction::LHS: - case RowReduction::LHS_LESS_RESTRICTIVE: - case RowReduction::RHS_INF: - case RowReduction::RHS: - case RowReduction::RHS_LESS_RESTRICTIVE: - case RowReduction::SAVE_ROW: - break; - case RowReduction::SPARSIFY: - if( postponeSubstitutions ) - return ConflictType::kPostpone; - default: - break; - } - } - } - - // no conflicts found - return ConflictType::kNoConflict; -} - -/// returns true if the given transaction was applied and false otherwise -template -ApplyResult -ProblemUpdate::applyTransaction( const Reduction* first, - const Reduction* last ) -{ - - Objective& objective = problem.getObjective(); - Vec& lbs = problem.getLowerBounds(); - Vec& ubs = problem.getUpperBounds(); - Vec& cflags = problem.getColFlags(); - ConstraintMatrix& constraintMatrix = problem.getConstraintMatrix(); - Vec& rflags = constraintMatrix.getRowFlags(); - - auto updateActivity = [this]( ActivityChange actChange, int rowid, - RowActivity& activity ) { - update_activity( actChange, rowid, activity ); - }; - - // check if transaction conflicts with current state - ConflictType conflictType = checkTransactionConflicts( first, last ); - - if( conflictType == ConflictType::kConflict ) - { - print_detailed( first, last ); - return ApplyResult::kRejected; - } - else if( conflictType == ConflictType::kPostpone ) - return ApplyResult::kPostponed; - - print_detailed( first, last ); - - for( auto iter = first; iter < last; ++iter ) - { - const auto& reduction = *iter; - - if( reduction.row >= 0 && reduction.col >= 0 ) - { - setRowState( reduction.row, State::kModified ); - setColState( reduction.col, State::kModified ); - - postsolve.storeCoefficientChange( reduction.row, reduction.col, - reduction.newval ); - matrix_buffer.addEntry( reduction.row, reduction.col, - reduction.newval ); - } - else if( reduction.row < 0 ) - { - assert( reduction.col >= 0 ); - int colop = reduction.row; - switch( colop ) - { - case ColReduction::NONE: - assert( false ); - break; - case ColReduction::OBJECTIVE: - setColState( reduction.col, State::kModified ); - objective.coefficients[reduction.col] = reduction.newval; - break; - case ColReduction::FIXED: - { - if( fixCol( reduction.col, reduction.newval ) == - PresolveStatus::kInfeasible ) - return ApplyResult::kInfeasible; - break; - } - case ColReduction::FIXED_INFINITY: - { - if( fixColInfinity( reduction.col, reduction.newval ) == - PresolveStatus::kInfeasible ) - return ApplyResult::kInfeasible; - break; - } - case ColReduction::LOWER_BOUND: - { - if( changeLB( reduction.col, reduction.newval ) == - PresolveStatus::kInfeasible ) - return ApplyResult::kInfeasible; - break; - } - case ColReduction::UPPER_BOUND: - { - if( changeUB( reduction.col, reduction.newval ) == - PresolveStatus::kInfeasible ) - return ApplyResult::kInfeasible; - break; - } - case ColReduction::IMPL_INT: - { - if( !cflags[reduction.col].test( ColFlag::kInactive ) ) - { - cflags[reduction.col].set( ColFlag::kImplInt ); - if( !cflags[reduction.col].test( ColFlag::kLbInf ) ) - { - if( changeLB( reduction.col, lbs[reduction.col] ) == - PresolveStatus::kInfeasible ) - return ApplyResult::kInfeasible; - } - - if( !cflags[reduction.col].test( ColFlag::kUbInf ) ) - { - if( changeUB( reduction.col, ubs[reduction.col] ) == - PresolveStatus::kInfeasible ) - return ApplyResult::kInfeasible; - } - } - break; - } - case ColReduction::SUBSTITUTE: - { - int col = reduction.col; - int equalityrow = static_cast( reduction.newval ); - - if( constraintMatrix.getRowCoefficients( equalityrow ) - .getLength() == 1 ) - { - assert( !rflags[equalityrow].test( RowFlag::kLhsInf, - RowFlag::kRhsInf ) ); - REAL val = constraintMatrix.getLeftHandSides()[equalityrow] / - constraintMatrix.getRowCoefficients( equalityrow ) - .getValues()[0]; - if( fixCol( col, val ) == PresolveStatus::kInfeasible ) - return ApplyResult::kInfeasible; - break; - } - - assert( row_state[equalityrow].equal( State::kUnmodified ) ); - assert( !col_state[col].test( State::kBoundsModified ) ); - - // check that the conditions for substitution are verified - if( !constraintMatrix.checkAggregationSparsityCondition( - col, constraintMatrix.getRowCoefficients( equalityrow ), - presolveOptions.maxfillinpersubstitution, - presolveOptions.maxshiftperrow, intbuffer ) ) - { - msg.detailed( "canceled\n" ); - return ApplyResult::kRejected; - } - - const auto colvec = constraintMatrix.getColumnCoefficients( col ); - const int* colindices = colvec.getIndices(); - const int nbrelevantrows = colvec.getLength(); - - postsolve.storeSubstitution( col, equalityrow, problem ); - - assert( - !cflags[col].test( ColFlag::kSubstituted, ColFlag::kFixed ) ); - cflags[col].set( ColFlag::kSubstituted ); - - // change the objective coefficients and offset - problem.substituteVarInObj( num, col, equalityrow ); - - // update row states - msg.detailed( "modified rows: " ); - for( int k = 0; k < nbrelevantrows; ++k ) - { - msg.detailed( "{},", colindices[k] ); - setRowState( colindices[k], State::kModified ); - } - msg.detailed( "\n" ); - - // update col states - const auto rowvec = - constraintMatrix.getRowCoefficients( equalityrow ); - const int length = rowvec.getLength(); - const int* indices = rowvec.getIndices(); - - msg.detailed( "modified columns: " ); - for( int j = 0; j < length; ++j ) - { - msg.detailed( "{},", indices[j] ); - setColState( indices[j], State::kModified ); - } - msg.detailed( "\n" ); - - auto eqRHS = constraintMatrix.getLeftHandSides()[equalityrow]; - - - // make the changes in the constraint matrix - constraintMatrix.aggregate( - num, col, rowvec, eqRHS, problem.getVariableDomains(), - intbuffer, realbuffer, tripletbuffer, changed_activities, - problem.getRowActivities(), singletonRows, singletonColumns, - emptyColumns, stats.nrounds ); - - stats.ncoefchgs += length * nbrelevantrows; - - assert( constraintMatrix.getRowSizes()[equalityrow] == -1 ); - assert( constraintMatrix.getRowCoefficients( equalityrow ) - .getLength() == 0 ); - assert( constraintMatrix.getLeftHandSides()[equalityrow] == - REAL{ 0 } ); - assert( constraintMatrix.getRightHandSides()[equalityrow] == - REAL{ 0 } ); - assert( constraintMatrix.getColSizes()[col] == -1 ); - assert( constraintMatrix.getColumnCoefficients( col ).getLength() == - REAL{ 0 } ); - assert( objective.coefficients[col] == REAL{ 0 } ); - - assert( row_state[equalityrow].test( State::kModified ) ); - assert( col_state[col].test( State::kModified ) ); - - // statistics - ++stats.ndeletedcols; - - // statistics - ++stats.ndeletedrows; - - if( cflags[col].test( ColFlag::kIntegral ) ) - --problem.getNumIntegralCols(); - else - --problem.getNumContinuousCols(); - - if( constraintMatrix.getLeftHandSides()[equalityrow] != 0 ) - stats.nsidechgs += 2 * nbrelevantrows; - break; - } - case ColReduction::SUBSTITUTE_OBJ: - { - int col = reduction.col; - int equalityrow = static_cast( reduction.newval ); - - assert( !cflags[col].test( ColFlag::kInactive ) ); - cflags[col].set( ColFlag::kSubstituted ); - - const auto rowvec = - constraintMatrix.getRowCoefficients( equalityrow ); - - postsolve.storeSubstitution( col, equalityrow, problem ); - - // change the objective coefficients and offset - problem.substituteVarInObj( num, col, equalityrow ); - - auto colvec = constraintMatrix.getColumnCoefficients( col ); - - if( cflags[col].test( ColFlag::kLbUseless ) || lbs[col] != 0 ) - update_activities_after_boundchange( - colvec.getValues(), colvec.getIndices(), colvec.getLength(), - BoundChange::kLower, lbs[col], REAL{ 0 }, - cflags[col].test( ColFlag::kLbUseless ), - problem.getRowActivities(), updateActivity ); - - if( cflags[col].test( ColFlag::kUbUseless ) || ubs[col] != 0 ) - update_activities_after_boundchange( - colvec.getValues(), colvec.getIndices(), colvec.getLength(), - BoundChange::kUpper, ubs[col], REAL{ 0 }, - cflags[col].test( ColFlag::kUbUseless ), - problem.getRowActivities(), updateActivity ); - - cflags[col].unset( ColFlag::kLbUseless, ColFlag::kUbUseless ); - lbs[col] = 0; - ubs[col] = 0; - deleted_cols.push_back( col ); - - const int length = rowvec.getLength(); - const int* indices = rowvec.getIndices(); - - msg.detailed( "modified columns: ", ColReduction::SUBSTITUTE, col, - equalityrow ); - for( int j = 0; j != length; ++j ) - { - msg.detailed( "{},", indices[j] ); - setColState( indices[j], State::kModified ); - } - msg.detailed( "\n" ); - - // statistics - ++stats.ndeletedcols; - - if( cflags[col].test( ColFlag::kIntegral ) ) - --problem.getNumIntegralCols(); - else - --problem.getNumContinuousCols(); - - break; - } - case ColReduction::PARALLEL: - { - int col1 = reduction.col; - int col2 = static_cast( reduction.newval ); - - if( cflags[col1].test( ColFlag::kInactive ) || - cflags[col2].test( ColFlag::kInactive ) ) - return ApplyResult::kRejected; - - setColState( col1, State::kBoundsModified ); - setColState( col2, State::kBoundsModified ); - - auto col1vec = constraintMatrix.getColumnCoefficients( col1 ); - auto col2vec = constraintMatrix.getColumnCoefficients( col2 ); - - - const REAL* vals1 = col1vec.getValues(); - const REAL* vals2 = col2vec.getValues(); - - assert( col1vec.getLength() > 0 ); - REAL col2scale = vals1[0] / vals2[0]; - assert( col2vec.getLength() == col1vec.getLength() ); - - assert( num.isEq( objective.coefficients[col1], - objective.coefficients[col2] * col2scale ) ); - - - ++stats.ndeletedcols; - - merge_parallel_columns( col1, col2, col2scale, constraintMatrix, - lbs, ubs, cflags ); - - break; - } - case ColReduction::REPLACE: - { - int col1 = reduction.col; - REAL factor = reduction.newval; - - // get the rest of the information from the next reduction - ++iter; - assert( iter->row == ColReduction::NONE ); - int col2 = iter->col; - REAL offset = iter->newval; - - // one variable is fixed, try to fix the other one - if( cflags[col1].test( ColFlag::kFixed ) || - cflags[col2].test( ColFlag::kFixed ) ) - { - if( !cflags[col1].test( ColFlag::kFixed, - ColFlag::kSubstituted ) ) - { - assert( cflags[col2].test( ColFlag::kFixed ) ); - if( fixCol( col1, factor * lbs[col2] + offset ) == - PresolveStatus::kInfeasible ) - return ApplyResult::kInfeasible; - } - else if( !cflags[col2].test( ColFlag::kFixed, - ColFlag::kSubstituted ) ) - { - assert( cflags[col1].test( ColFlag::kFixed ) ); - if( fixCol( col2, ( lbs[col1] - offset ) / factor ) == - PresolveStatus::kInfeasible ) - return ApplyResult::kInfeasible; - } - break; - } - - // one variable might have been substituted - if( cflags[col1].test( ColFlag::kFixed, ColFlag::kSubstituted ) || - cflags[col2].test( ColFlag::kFixed, ColFlag::kSubstituted ) ) - break; - - assert( constraintMatrix.getColSizes()[col1] > 0 && - constraintMatrix.getColSizes()[col2] > 0 ); - - REAL col2_imp_lb; - REAL col2_imp_ub; - if( factor > 0.0 ) - { - col2_imp_lb = ( lbs[col1] - offset ) / factor; - col2_imp_ub = ( ubs[col1] - offset ) / factor; - } - else - { - col2_imp_lb = ( ubs[col1] - offset ) / factor; - col2_imp_ub = ( lbs[col1] - offset ) / factor; - } - if( col2_imp_lb > lbs[col2] ) - { - if( changeLB( col2, col2_imp_lb ) == - PresolveStatus::kInfeasible ) - return ApplyResult::kInfeasible; - } - else if( col2_imp_ub < ubs[col2] ) - { - if( changeUB( col2, col2_imp_ub ) == - PresolveStatus::kInfeasible ) - return ApplyResult::kInfeasible; - } - - // set up the equality - // x_1 - factor * x_2 = offset - int indices[] = { col1, col2 }; - REAL coefficients[] = { 1.0, -factor }; - // argument needs to be sorted - if( col1 > col2 ) - { - std::swap( indices[0], indices[1] ); - std::swap( coefficients[0], coefficients[1] ); - } - SparseVectorView equalityLHS( coefficients, indices, 2 ); - - // check sparsity - if( constraintMatrix.checkAggregationSparsityCondition( - col1, equalityLHS, presolveOptions.maxfillinpersubstitution, - presolveOptions.maxshiftperrow, intbuffer ) ) - { - auto colvec = constraintMatrix.getColumnCoefficients( col1 ); - const int* colindices = colvec.getIndices(); - int length = colvec.getLength(); - - cflags[col1].set( ColFlag::kSubstituted ); - - if( cflags[col1].test( ColFlag::kIntegral ) ) - --problem.getNumIntegralCols(); - else - --problem.getNumContinuousCols(); - - // update row flags - - msg.detailed( "modified rows: " ); - for( int k = 0; k < length; ++k ) - { - msg.detailed( "{},", colindices[k] ); - setRowState( colindices[k], State::kModified ); - } - msg.detailed( "\n" ); - - // perform changes in matrix and sides - //TODO: - postsolve.storeSubstitution( col1, equalityLHS, offset ); - - constraintMatrix.aggregate( - num, col1, equalityLHS, offset, problem.getVariableDomains(), - intbuffer, realbuffer, tripletbuffer, changed_activities, - problem.getRowActivities(), singletonRows, singletonColumns, - emptyColumns, stats.nrounds ); - - // update col flags - setColState( col1, State::kModified ); - setColState( col2, State::kModified ); - - // change the objective - auto& obj = problem.getObjective(); - auto& obj_coef = obj.coefficients; - if( obj_coef[col1] != REAL{ 0 } ) - { - obj_coef[col2] += obj_coef[col1] * factor; - if( num.isZero( obj_coef[col2] ) ) - obj_coef[col2] = REAL{ 0 }; - obj.offset += obj_coef[col1] * offset; - obj_coef[col1] = REAL{ 0 }; - } - - // statistics - if( offset != REAL{ 0 } ) - stats.nsidechgs += 2 * length; - stats.ncoefchgs += 2 * length; - ++stats.ndeletedcols; - } - break; - } - default: - break; - } - } - else - { - assert( reduction.row >= 0 && reduction.col < 0 ); - int rowop = reduction.col; - switch( rowop ) - { - case RowReduction::NONE: - assert( false ); - break; - case RowReduction::SAVE_ROW: - { - int row = reduction.row; - postsolve.storeSavedRow( row, - constraintMatrix.getRowCoefficients( row ), - constraintMatrix.getLeftHandSides()[row], - constraintMatrix.getRightHandSides()[row], - problem.getRowFlags()[row] ); - } - break; - case RowReduction::LHS: - assert( rflags[reduction.row].test( RowFlag::kLhsInf ) || - reduction.newval != - constraintMatrix.getLeftHandSides()[reduction.row] ); - setRowState( reduction.row, State::kBoundsModified ); - - if( rflags[reduction.row].test( RowFlag::kLhsInf ) ) - { - auto rowvec = - constraintMatrix.getRowCoefficients( reduction.row ); - const int rowlen = rowvec.getLength(); - const int* rowcols = rowvec.getIndices(); - - msg.detailed( "modified columns: " ); - for( int i = 0; i < rowlen; ++i ) - { - msg.detailed( "{},", rowcols[i] ); - setColState( rowcols[i], State::kModified ); - } - msg.detailed( "\n" ); - } - if( !rflags[reduction.row].test( RowFlag::kRhsInf ) && - num.isFeasGT( - reduction.newval, - constraintMatrix.getRightHandSides()[reduction.row] ) ) - { - Message::debug( - this, - "fixing the lhs of row {} with bounds [{},{}] to value {} " - "is " - "detected to be infeasible\n", - reduction.row, - rflags[reduction.row].test( RowFlag::kLhsInf ) - ? -std::numeric_limits::infinity() - : double( constraintMatrix - .getLeftHandSides()[reduction.row] ), - double( - constraintMatrix.getRightHandSides()[reduction.row] ), - double( reduction.newval ) ); - return ApplyResult::kInfeasible; - } - - postsolve.storeRowBoundChange( - true, reduction.row, reduction.newval, false, - constraintMatrix.getLeftHandSides()[reduction.row], - constraintMatrix.getRowFlags()[reduction.row].test( - RowFlag::kLhsInf ) ); - constraintMatrix.modifyLeftHandSide( reduction.row, num, - reduction.newval ); - - ++stats.nsidechgs; - break; - case RowReduction::LHS_LESS_RESTRICTIVE: - assert( rflags[reduction.row].test( RowFlag::kLhsInf ) || - reduction.newval != - constraintMatrix.getLeftHandSides()[reduction.row] ); - setRowState( reduction.row, State::kBoundsModified ); - if( !rflags[reduction.row].test( RowFlag::kRhsInf ) && - num.isFeasGT( - reduction.newval, - constraintMatrix.getRightHandSides()[reduction.row] ) ) - { - Message::debug( - this, - "fixing the lhs of row {} with bounds [{},{}] to value {} " - "is " - "detected to be infeasible\n", - reduction.row, - rflags[reduction.row].test( RowFlag::kLhsInf ) - ? -std::numeric_limits::infinity() - : double( constraintMatrix - .getLeftHandSides()[reduction.row] ), - double( - constraintMatrix.getRightHandSides()[reduction.row] ), - double( reduction.newval ) ); - return ApplyResult::kInfeasible; - } - - constraintMatrix.modifyLeftHandSide( reduction.row, num, - reduction.newval ); - postsolve.storeRowBoundChangeForcedByRow( true, reduction.row, - reduction.newval, false ); - - ++stats.nsidechgs; - break; - case RowReduction::REASON_FOR_LESS_RESTRICTIVE_BOUND_CHANGE: - { - REAL factor = problem.getConstraintMatrix() - .getRowCoefficients( (int)reduction.newval ) - .getValues()[0] / - problem.getConstraintMatrix() - .getRowCoefficients( reduction.row ) - .getValues()[0]; - postsolve.storeReasonForRowBoundChangeForcedByRow( - (int)reduction.newval, reduction.row, factor ); - break; - } - case RowReduction::RHS: - assert( rflags[reduction.row].test( RowFlag::kRhsInf ) || - reduction.newval != - constraintMatrix.getRightHandSides()[reduction.row] ); - setRowState( reduction.row, State::kBoundsModified ); - if( rflags[reduction.row].test( RowFlag::kRhsInf ) ) - { - auto rowvec = - constraintMatrix.getRowCoefficients( reduction.row ); - const int rowlen = rowvec.getLength(); - const int* rowcols = rowvec.getIndices(); - msg.detailed( "modified columns: " ); - for( int i = 0; i < rowlen; ++i ) - { - msg.detailed( "{},", rowcols[i] ); - setColState( rowcols[i], State::kModified ); - } - msg.detailed( "\n" ); - } - if( !rflags[reduction.row].test( RowFlag::kLhsInf ) && - num.isFeasGT( - constraintMatrix.getLeftHandSides()[reduction.row], - reduction.newval ) ) - { - Message::debug( - this, - "fixing the rhs of row {} with bounds [{},{}] to value {} " - "is " - "detected to be infeasible\n", - reduction.row, - double( constraintMatrix.getLeftHandSides()[reduction.row] ), - rflags[reduction.row].test( RowFlag::kRhsInf ) - ? -std::numeric_limits::infinity() - : double( constraintMatrix - .getRightHandSides()[reduction.row] ), - - double( reduction.newval ) ); - return ApplyResult::kInfeasible; - } - - postsolve.storeRowBoundChange( - false, reduction.row, reduction.newval, false, - constraintMatrix.getRightHandSides()[reduction.row], - constraintMatrix.getRowFlags()[reduction.row].test( - RowFlag::kRhsInf ) ); - constraintMatrix.modifyRightHandSide( reduction.row, num, - reduction.newval ); - - ++stats.nsidechgs; - break; - case RowReduction::RHS_LESS_RESTRICTIVE: - assert( rflags[reduction.row].test( RowFlag::kRhsInf ) || - reduction.newval != - constraintMatrix.getRightHandSides()[reduction.row] ); - setRowState( reduction.row, State::kBoundsModified ); - if( !rflags[reduction.row].test( RowFlag::kLhsInf ) && - num.isFeasGT( - constraintMatrix.getLeftHandSides()[reduction.row], - reduction.newval ) ) - { - Message::debug( - this, - "fixing the rhs of row {} with bounds [{},{}] to value {} " - "is " - "detected to be infeasible\n", - reduction.row, - double( constraintMatrix.getLeftHandSides()[reduction.row] ), - rflags[reduction.row].test( RowFlag::kRhsInf ) - ? -std::numeric_limits::infinity() - : double( constraintMatrix - .getRightHandSides()[reduction.row] ), - - double( reduction.newval ) ); - return ApplyResult::kInfeasible; - } - - constraintMatrix.modifyRightHandSide( reduction.row, num, - reduction.newval ); - postsolve.storeRowBoundChangeForcedByRow( false, reduction.row, - reduction.newval, false ); - - ++stats.nsidechgs; - break; - case RowReduction::LHS_INF: - if( !rflags[reduction.row].test( RowFlag::kLhsInf ) ) - { - setRowState( reduction.row, State::kBoundsModified ); - - postsolve.storeRowBoundChange( - true, reduction.row, REAL{ 0 }, true, REAL{ 0 }, - constraintMatrix.getRowFlags()[reduction.row].test( - RowFlag::kLhsInf ) ); - constraintMatrix.template modifyLeftHandSide( - reduction.row, num, REAL{ 0 } ); - - - ++stats.nsidechgs; - } - break; - case RowReduction::RHS_INF: - if( !rflags[reduction.row].test( RowFlag::kRhsInf ) ) - { - setRowState( reduction.row, State::kBoundsModified ); - postsolve.storeRowBoundChange( - false, reduction.row, REAL{ 0 }, true, REAL{ 0 }, - constraintMatrix.getRowFlags()[reduction.row].test( - RowFlag::kRhsInf ) ); - constraintMatrix.template modifyRightHandSide( - reduction.row, num, REAL{ 0 } ); - ++stats.nsidechgs; - } - break; - case RowReduction::REDUNDANT: - if( !rflags[reduction.row].test( RowFlag::kRedundant ) ) - { - setRowState( reduction.row, State::kBoundsModified ); - markRowRedundant( reduction.row ); - } - break; - case RowReduction::SPARSIFY: - { - int nsparsifyrows = static_cast( reduction.newval ); - int eqrow = reduction.row; - assert( matrix_buffer.empty() ); - - int ncancel = 0; - int ncanceledrows = 0; - - auto eqrowvec = constraintMatrix.getRowCoefficients( eqrow ); - const REAL& eqrhs = constraintMatrix.getRightHandSides()[eqrow]; - int eqlen = eqrowvec.getLength(); - - for( int i = 0; i != nsparsifyrows; ++i ) - { - ++iter; - int candrow = iter->row; - const REAL& scale = iter->newval; - - assert( candrow != eqrow ); - - int canceled = constraintMatrix.sparsify( - num, eqrow, scale, candrow, intbuffer, realbuffer, - problem.getVariableDomains(), changed_activities, - problem.getRowActivities(), singletonRows, singletonColumns, - emptyColumns, stats.nrounds ); - - if( canceled != 0 ) - { - setRowState( candrow, State::kModified ); - msg.detailed( "modified rows: {}, \n", candrow ); - ++ncanceledrows; - ncancel += canceled; - - if( eqrhs != 0 ) - { - if( !rflags[candrow].test( RowFlag::kLhsInf ) ) - ++stats.nsidechgs; - - if( !rflags[candrow].test( RowFlag::kRhsInf ) ) - ++stats.nsidechgs; - } - } - } - - if( ncancel != 0 ) - { - stats.ncoefchgs += eqlen * ncanceledrows; - const int* eqrowcols = eqrowvec.getIndices(); - - msg.detailed( "modified columns: " ); - for( int j = 0; j != eqlen; ++j ) - { - msg.detailed( "{},", eqrowcols[j] ); - setColState( eqrowcols[j], State::kModified ); - } - msg.detailed( "\n" ); - } - } - break; - default: - break; - } - } - } - - // no conflicts found - return ApplyResult::kApplied; -} - -template -void -ProblemUpdate::merge_parallel_columns( - int col1, int col2, REAL col2scale, - ConstraintMatrix& constraintMatrix, Vec& lbs, Vec& ubs, - Vec& cflags ) -{ - const SparseVectorView& col1vec = constraintMatrix.getColumnCoefficients(col1); - const SparseVectorView& col2vec = constraintMatrix.getColumnCoefficients(col2); - - bool col1lbinf = cflags[col1].test( ColFlag::kLbInf ); - bool col1ubinf = cflags[col1].test( ColFlag::kUbInf ); - bool col1int = cflags[col1].test( ColFlag::kIntegral ); - bool col2lbinf = cflags[col2].test( ColFlag::kLbInf ); - bool col2ubinf = cflags[col2].test( ColFlag::kUbInf ); - bool col2int = cflags[col2].test( ColFlag::kIntegral ); - - postsolve.storeParallelCols( col1, col1int, col1lbinf, lbs[col1], col1ubinf, - ubs[col1], col2, col2int, col2lbinf, lbs[col2], - col2ubinf, ubs[col2], col2scale ); - - auto updateActivity = [this]( ActivityChange actChange, int rowid, - RowActivity& activity ) { - update_activity( actChange, rowid, activity ); - }; - - - const int* inds = col1vec.getIndices(); - const REAL* vals1 = col1vec.getValues(); - const REAL* vals2 = col2vec.getValues(); - const int collen = col1vec.getLength(); - - // compute the new domains for column 2 - REAL newlb = 0; - REAL newub = 0; - - ColFlags newflags; - - newflags.set( ColFlag::kLbInf, ColFlag::kUbInf ); - - // in the case that column 1 is not integral the new column - // is also not integral regardless of whether column 2 is integral - // or not (the necessary conditions must have been checked by the - // presolver) - if( cflags[col1].test( ColFlag::kIntegral ) ) - { - --problem.getNumIntegralCols(); - newflags.set( ColFlag::kIntegral ); - } - else if( cflags[col2].test( ColFlag::kIntegral ) ) - --problem.getNumIntegralCols(); - else - --problem.getNumContinuousCols(); - - if( col2scale < 0 ) - { - if( !col2lbinf && !col1ubinf ) - { - newlb = lbs[col2] + col2scale * ubs[col1]; - newflags.unset( ColFlag::kLbInf ); - if( cflags[col1].test( ColFlag::kUbHuge ) || - cflags[col2].test( ColFlag::kLbHuge ) ) - newflags.set( ColFlag::kLbHuge ); - } - - if( !col2ubinf && !col1lbinf ) - { - newub = ubs[col2] + col2scale * lbs[col1]; - newflags.unset( ColFlag::kUbInf ); - if( cflags[col1].test( ColFlag::kLbHuge ) || - cflags[col2].test( ColFlag::kUbHuge ) ) - newflags.set( ColFlag::kUbHuge ); - } - } - else - { - if( !col2lbinf && !col1lbinf ) - { - newlb = lbs[col2] + col2scale * lbs[col1]; - newflags.unset( ColFlag::kLbInf ); - if( cflags[col1].test( ColFlag::kLbHuge ) || - cflags[col2].test( ColFlag::kLbHuge ) ) - newflags.set( ColFlag::kLbHuge ); - } - - if( !col2ubinf && !col1ubinf ) - { - newub = ubs[col2] + col2scale * ubs[col1]; - newflags.unset( ColFlag::kUbInf ); - if( cflags[col1].test( ColFlag::kUbHuge ) || - cflags[col2].test( ColFlag::kUbHuge ) ) - newflags.set( ColFlag::kUbHuge ); - } - } - - // update the activities if required - if( newflags.test( ColFlag::kLbUseless ) ) - { - // the new columns lower bound does not contribute to the - // activities - - if( !cflags[col2].test( ColFlag::kLbUseless ) ) - { - // The current bound of column 2 contributes to the activity, - // therefore column 1 must have a infinite or huge bound from - // which we keep the infinite contribution for the new columns - // domains. The finite constribution of the lower bound of - // column 2 is removed. - if( lbs[col2] != 0 ) - { - update_activities_after_boundchange( - vals2, inds, collen, BoundChange::kLower, lbs[col2], REAL{ 0 }, - false, problem.getRowActivities(), - []( ActivityChange, int, const RowActivity& ) {} ); - } - } - else if( col2scale < 0 ) - { - // The lower bound of column 2 also does not contribute to the - // activities, and we keep that infinite contribution for the - // new column. Depending on the scale we remove any finite or - // infinite contribution of column 1's bound. In this if case - // the scale is negative, so the upper bound is removed. - if( cflags[col1].test( ColFlag::kUbUseless ) || ubs[col1] != 0 ) - { - update_activities_after_boundchange( - vals1, inds, collen, BoundChange::kUpper, ubs[col1], REAL{ 0 }, - cflags[col1].test( ColFlag::kUbUseless ), - problem.getRowActivities(), - []( ActivityChange, int, const RowActivity& ) {} ); - } - } - else - { - // The lower bound of column 2 also does not contribute to the - // activities, and we keep that infinite contribution for the - // new column. Depending on the scale we remove any finite or - // infinite contribution of column 1's bound. In this if case - // the scale is positive, so the lower bound is removed. - if( cflags[col1].test( ColFlag::kLbUseless ) || lbs[col1] != 0 ) - { - update_activities_after_boundchange( - vals1, inds, collen, BoundChange::kLower, lbs[col1], REAL{ 0 }, - cflags[col1].test( ColFlag::kLbUseless ), - problem.getRowActivities(), - []( ActivityChange, int, const RowActivity& ) {} ); - } - } - } - - if( newflags.test( ColFlag::kUbUseless ) ) - { - // symmetric cases as above for the lower bound - if( !cflags[col2].test( ColFlag::kUbUseless ) ) - { - if( ubs[col2] != 0 ) - { - update_activities_after_boundchange( - vals2, inds, collen, BoundChange::kUpper, ubs[col2], REAL{ 0 }, - false, problem.getRowActivities(), updateActivity ); - } - } - else if( col2scale < 0 ) - { - if( cflags[col1].test( ColFlag::kLbUseless ) || lbs[col1] != 0 ) - { - update_activities_after_boundchange( - vals1, inds, collen, BoundChange::kLower, lbs[col1], REAL{ 0 }, - cflags[col1].test( ColFlag::kLbUseless ), - problem.getRowActivities(), - []( ActivityChange, int, const RowActivity& ) {} ); - } - } - else - { - if( cflags[col1].test( ColFlag::kUbUseless ) || ubs[col1] != 0 ) - { - update_activities_after_boundchange( - vals1, inds, collen, BoundChange::kUpper, ubs[col1], REAL{ 0 }, - cflags[col1].test( ColFlag::kUbUseless ), - problem.getRowActivities(), - []( ActivityChange, int, const RowActivity& ) {} ); - } - } - } - - // column 1 can now be treated as if it fixed to zero - // the flag however is not set to ColFlag::kFixed since - // this indicates that their will be a notification to postsolve - // about that case, instead it is set to substituted - lbs[col1] = 0; - ubs[col1] = 0; - cflags[col1].unset( ColFlag::kLbUseless, ColFlag::kUbUseless ); - cflags[col1].set( ColFlag::kSubstituted ); - deleted_cols.push_back( col1 ); - - // the domains of column 2 are now set column 2 bounds are set to - // new bound values - lbs[col2] = newlb; - ubs[col2] = newub; - cflags[col2] = newflags; -} - -template -void -ProblemUpdate::print_detailed( const Reduction* first, - const Reduction* last ) const -{ - if( msg.getVerbosityLevel() == VerbosityLevel::kDetailed ) - { - for( auto iter = first; iter < last; ++iter ) - { - const auto& reduction = *iter; - msg.detailed( "row {} col {} val {}\n", reduction.row, reduction.col, - (double) reduction.newval ); - } - msg.detailed( "tsx\n" ); - } -} - -} // namespace papilo - -#endif diff --git a/headers/papilo/core/Reductions.hpp b/headers/papilo/core/Reductions.hpp deleted file mode 100644 index 606cdcf..0000000 --- a/headers/papilo/core/Reductions.hpp +++ /dev/null @@ -1,384 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* */ -/* This file is part of the program and library */ -/* PaPILO --- Parallel Presolve for Integer and Linear Optimization */ -/* */ -/* Copyright (C) 2020-2022 Konrad-Zuse-Zentrum */ -/* fuer Informationstechnik Berlin */ -/* */ -/* This program is free software: you can redistribute it and/or modify */ -/* it under the terms of the GNU Lesser General Public License as published */ -/* by the Free Software Foundation, either version 3 of the License, or */ -/* (at your option) any later version. */ -/* */ -/* This program is distributed in the hope that it will be useful, */ -/* but WITHOUT ANY WARRANTY; without even the implied warranty of */ -/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ -/* GNU Lesser General Public License for more details. */ -/* */ -/* You should have received a copy of the GNU Lesser General Public License */ -/* along with this program. If not, see . */ -/* */ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -#ifndef _PAPILO_CORE_REDUCTIONS_HPP_ -#define _PAPILO_CORE_REDUCTIONS_HPP_ - -#include "papilo/misc/Vec.hpp" -#include - -namespace papilo -{ - -struct ColReduction -{ - enum - { - NONE = -1, - OBJECTIVE = -2, - LOWER_BOUND = -3, - UPPER_BOUND = -4, - FIXED = -5, - LOCKED = -6, - SUBSTITUTE = -8, - BOUNDS_LOCKED = -9, - REPLACE = -10, - SUBSTITUTE_OBJ = -11, - PARALLEL = -12, - IMPL_INT = -13, - FIXED_INFINITY = -14, - }; -}; - -struct RowReduction -{ - enum - { - NONE = -1, - RHS = -2, - LHS = -3, - REDUNDANT = -4, - LOCKED = -5, - RHS_INF = -7, - LHS_INF = -8, - SPARSIFY = -9, - RHS_LESS_RESTRICTIVE = -10, - LHS_LESS_RESTRICTIVE = -11, - REASON_FOR_LESS_RESTRICTIVE_BOUND_CHANGE = -12, - SAVE_ROW = -13 - }; -}; - -template -struct Reduction -{ - /// value stored in reduction. Meaning depends on the operation - REAL newval; - - /// index of row or negative for column specific operations - int row; - - /// index of column or negative for row specific operations - int col; - - Reduction( REAL _newval, int _row, int _col ) - : newval( _newval ), row( _row ), col( _col ) - { - } -}; - -template -class Reductions -{ - public: - void - startTransaction() - { - assert( transactions.empty() || transactions.back().end >= 0 ); - - const int start = static_cast( reductions.size() ); - transactions.emplace_back( start, -1 ); - } - - void - endTransaction() - { - assert( !transactions.empty() && transactions.back().end == -1 ); - - const int end = static_cast( reductions.size() ); - assert( end != transactions.back().start ); - transactions.back().end = end; - } - - void - add_reduction( int row, int col, REAL newval ) - { - reductions.emplace_back( newval, row, col ); - } - - void - changeMatrixEntry( int row, int col, REAL newval ) - { - assert( row >= 0 && col >= 0 ); - reductions.emplace_back( newval, row, col ); - } - - void - changeRowLHS( int row, REAL newval ) - { - reductions.emplace_back( newval, row, RowReduction::LHS ); - } - - void - change_row_lhs_parallel( int row, REAL newval ) - { - reductions.emplace_back( newval, row, RowReduction::LHS_LESS_RESTRICTIVE ); - } - - void - changeRowRHS( int row, REAL newval ) - { - reductions.emplace_back( newval, row, RowReduction::RHS ); - } - - void - change_row_rhs_parallel( int row, REAL newval ) - { - reductions.emplace_back( newval, row, RowReduction::RHS_LESS_RESTRICTIVE ); - } - - void - bound_change_caused_by_row( int remaining_row, int deleted_row ) - { - reductions.emplace_back( - remaining_row, deleted_row, - RowReduction::REASON_FOR_LESS_RESTRICTIVE_BOUND_CHANGE ); - } - - void - changeRowLHSInf( int row ) - { - reductions.emplace_back( 0.0, row, RowReduction::LHS_INF ); - } - - void - changeRowRHSInf( int row ) - { - reductions.emplace_back( 0.0, row, RowReduction::RHS_INF ); - } - - void - markRowRedundant( int row ) - { - reductions.emplace_back( REAL{ 0.0 }, row, RowReduction::REDUNDANT ); - } - - /// lock row, i.e. modifications that come before this transaction are - /// conflicting but not modifications that come after this transaction - void - lockRow( int row ) - { - // locks are only valid inside a transaction - assert( !transactions.empty() && transactions.back().end == -1 ); - // locks must come first within a transaction - assert( transactions.back().start + transactions.back().nlocks == - static_cast( reductions.size() ) ); - - reductions.emplace_back( 0.0, row, RowReduction::LOCKED ); - ++transactions.back().nlocks; - } - - void - changeColLB( int col, REAL new_val, int forcing_row = -1 ) - { - if(forcing_row > -1) - reductions.emplace_back(0, forcing_row, RowReduction::SAVE_ROW); - reductions.emplace_back( new_val, ColReduction::LOWER_BOUND, col ); - } - - void - changeColUB( int col, REAL new_val, int forcing_row = -1 ) - { - if( forcing_row > -1) - reductions.emplace_back(0, forcing_row, RowReduction::SAVE_ROW); - reductions.emplace_back( new_val, ColReduction::UPPER_BOUND, col ); - } - - void - fixCol( int col, REAL val, int forcing_row = -1 ) - { - if(forcing_row > -1) - reductions.emplace_back(0, forcing_row, RowReduction::SAVE_ROW); - reductions.emplace_back( val, ColReduction::FIXED, col ); - } - - void - fixColPositiveInfinity( int col, int columnLength, const int* rowIndices ) - { - for( int i = 0; i < columnLength; i++ ) - markRowRedundant( rowIndices[i] ); - - reductions.emplace_back( 1, ColReduction::FIXED_INFINITY, col ); - } - - void - fixColNegativeInfinity( int col, int columnLength, const int* rowIndices ) - { - for( int i = 0; i < columnLength; i++ ) - markRowRedundant( rowIndices[i] ); - - reductions.emplace_back( -1, ColReduction::FIXED_INFINITY, col ); - } - - /// lock column, i.e. modifications that come before this transaction are - /// conflicting but not modifications that come after this transaction - void - lockCol( int col ) - { - assert( !transactions.empty() && transactions.back().end == -1 ); - assert( transactions.back().start + transactions.back().nlocks == - static_cast( reductions.size() ) ); - - reductions.emplace_back( 0.0, ColReduction::LOCKED, col ); - ++transactions.back().nlocks; - } - - /// lock column lower and upper bounds - void - lockColBounds( int col ) - { - assert( !transactions.empty() && transactions.back().end == -1 ); - assert( transactions.back().start + transactions.back().nlocks == - static_cast( reductions.size() ) ); - - reductions.emplace_back( 0.0, ColReduction::BOUNDS_LOCKED, col ); - ++transactions.back().nlocks; - } - - /// signal that a column in free and can be substituted in the matrix - void - aggregateFreeCol( int col, int equalityRow ) - { - assert( col >= 0 && equalityRow >= 0 ); - reductions.emplace_back( static_cast( equalityRow ), - ColReduction::SUBSTITUTE, col ); - } - - /// signal that a column in free and can be substituted in the matrix - void - substituteColInObjective( int col, int equalityRow ) - { - assert( col >= 0 && equalityRow >= 0 ); - reductions.emplace_back( static_cast( equalityRow ), - ColReduction::SUBSTITUTE_OBJ, col ); - } - - // replace col1 = factor * col2 + offset - void - replaceCol( int col1, int col2, REAL factor, REAL offset ) - { - assert( col1 >= 0 && col2 >= 0 ); - - startTransaction(); - reductions.emplace_back( factor, ColReduction::REPLACE, col1 ); - reductions.emplace_back( offset, ColReduction::NONE, col2 ); - endTransaction(); - } - - /// parallel columns col1 and col2 must satisfies all conditions so - /// that they can be substituted by a new variable y = col2 + factor * col1 - /// where factor is computed by using the ratio between the two - /// columns coefficients - void - mark_parallel_cols( int col1, int col2 ) - { - assert( col1 >= 0 && col2 >= 0 ); - reductions.emplace_back( static_cast( col2 ), - ColReduction::PARALLEL, col1 ); - } - - void - impliedInteger( int col ) - { - assert( col >= 0 ); - reductions.emplace_back( 0, ColReduction::IMPL_INT, col ); - } - - void - sparsify( int eq, int numrows, const std::pair* sparsifiedrows ) - { - reductions.emplace_back( static_cast( numrows ), eq, - RowReduction::SPARSIFY ); - for( int i = 0; i != numrows; ++i ) - reductions.emplace_back( sparsifiedrows[i].second, - sparsifiedrows[i].first, RowReduction::NONE ); - } - - unsigned int - size() - { - return reductions.size(); - } - - void - clear() - { - reductions.clear(); - transactions.clear(); - } - - const Vec>& - getReductions() const - { - return reductions; - } - - struct Transaction - { - int start; - int end; - int nlocks; - int naddcoeffs; - - Transaction( int start_, int end_ ) - : start( start_ ), end( end_ ), nlocks( 0 ), naddcoeffs( 0 ) - { - } - }; - - const Vec& - getTransactions() const - { - return transactions; - } - - private: - Vec> reductions; - Vec transactions; - - public: - Reduction& - getReduction( int i ) - { - return reductions[i]; - } -}; - -template -class TransactionGuard -{ - public: - TransactionGuard( Reductions& _reductions ) : reductions( _reductions ) - { - _reductions.startTransaction(); - } - - ~TransactionGuard() { reductions.endTransaction(); } - - private: - Reductions& reductions; -}; - -} // namespace papilo - -#endif diff --git a/headers/papilo/core/RowFlags.hpp b/headers/papilo/core/RowFlags.hpp deleted file mode 100644 index 87e2980..0000000 --- a/headers/papilo/core/RowFlags.hpp +++ /dev/null @@ -1,45 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* */ -/* This file is part of the program and library */ -/* PaPILO --- Parallel Presolve for Integer and Linear Optimization */ -/* */ -/* Copyright (C) 2020-2022 Konrad-Zuse-Zentrum */ -/* fuer Informationstechnik Berlin */ -/* */ -/* This program is free software: you can redistribute it and/or modify */ -/* it under the terms of the GNU Lesser General Public License as published */ -/* by the Free Software Foundation, either version 3 of the License, or */ -/* (at your option) any later version. */ -/* */ -/* This program is distributed in the hope that it will be useful, */ -/* but WITHOUT ANY WARRANTY; without even the implied warranty of */ -/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ -/* GNU Lesser General Public License for more details. */ -/* */ -/* You should have received a copy of the GNU Lesser General Public License */ -/* along with this program. If not, see . */ -/* */ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -#ifndef _PAPILO_CORE_ROW_FLAGS_HPP_ -#define _PAPILO_CORE_ROW_FLAGS_HPP_ - -#include "papilo/misc/Flags.hpp" - -namespace papilo -{ - -enum class RowFlag : uint8_t -{ - kLhsInf = 1 << 0, - kRhsInf = 1 << 1, - kEquation = 1 << 2, - kIntegral = 1 << 3, - kRedundant = 1 << 4, -}; - -using RowFlags = Flags; - -} // namespace papilo - -#endif \ No newline at end of file diff --git a/headers/papilo/core/SingleRow.hpp b/headers/papilo/core/SingleRow.hpp deleted file mode 100644 index a1e1497..0000000 --- a/headers/papilo/core/SingleRow.hpp +++ /dev/null @@ -1,847 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* */ -/* This file is part of the program and library */ -/* PaPILO --- Parallel Presolve for Integer and Linear Optimization */ -/* */ -/* Copyright (C) 2020-2022 Konrad-Zuse-Zentrum */ -/* fuer Informationstechnik Berlin */ -/* */ -/* This program is free software: you can redistribute it and/or modify */ -/* it under the terms of the GNU Lesser General Public License as published */ -/* by the Free Software Foundation, either version 3 of the License, or */ -/* (at your option) any later version. */ -/* */ -/* This program is distributed in the hope that it will be useful, */ -/* but WITHOUT ANY WARRANTY; without even the implied warranty of */ -/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ -/* GNU Lesser General Public License for more details. */ -/* */ -/* You should have received a copy of the GNU Lesser General Public License */ -/* along with this program. If not, see . */ -/* */ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -#ifndef _PAPILO_CORE_SINGLE_ROW_HPP_ -#define _PAPILO_CORE_SINGLE_ROW_HPP_ - -#include "papilo/core/RowFlags.hpp" -#include "papilo/core/VariableDomains.hpp" -#include "papilo/misc/Flags.hpp" -#include "papilo/misc/Num.hpp" -#include "papilo/misc/Vec.hpp" -#include - -namespace papilo -{ - -enum class BoundChange -{ - kLower, - kUpper -}; - -enum class ActivityChange -{ - kMin, - kMax -}; - -enum class RowStatus -{ - kInfeasible, - kRedundant, - kRedundantLhs, - kRedundantRhs, - kUnknown, -}; - -template -struct RowActivity -{ - /// minimal activity of the row - REAL min; - - /// maximal activity of the row - REAL max; - - /// number of variables that contribute with an infinite bound to the minimal - /// activity of this row - int ninfmin; - - /// number of variables that contribute with an infinite bound to the maximal - /// activity of this row - int ninfmax; - - /// last presolving round where this activity changed - int lastchange; - - bool - repropagate( ActivityChange actChange, RowFlags rflags ) - { - if( actChange == ActivityChange::kMin && - !rflags.test( RowFlag::kRhsInf ) && ninfmin <= 1 ) - return true; - - if( actChange == ActivityChange::kMax && - !rflags.test( RowFlag::kLhsInf ) && ninfmax <= 1 ) - return true; - - return false; - } - - RowStatus - checkStatus( const Num& num, RowFlags rflags, const REAL& lhs, - const REAL& rhs ) const - { - RowStatus status = RowStatus::kRedundant; - - if( !rflags.test( RowFlag::kLhsInf ) ) - { - if( ninfmax == 0 && num.isFeasLT( max, lhs ) && - num.isSafeLT( max, lhs ) ) - return RowStatus::kInfeasible; - - if( ninfmin == 0 && num.isFeasGE( min, lhs ) ) - status = RowStatus::kRedundantLhs; - else - status = RowStatus::kUnknown; - } - - if( !rflags.test( RowFlag::kRhsInf ) ) - { - if( ninfmin == 0 && num.isFeasGT( min, rhs ) && - num.isSafeGT( min, rhs ) ) - return RowStatus::kInfeasible; - - if( ninfmax == 0 && num.isFeasLE( max, rhs ) ) - { - if( status == RowStatus::kUnknown ) - status = RowStatus::kRedundantRhs; - else - status = RowStatus::kRedundant; - } - else if( status == RowStatus::kRedundant ) - status = RowStatus::kUnknown; - } - else if( status == RowStatus::kRedundantLhs ) - status = RowStatus::kRedundant; - - return status; - } - - template - void - serialize( Archive& ar, const unsigned int version ) - { - ar& min; - ar& max; - ar& ninfmin; - - ar& ninfmax; - ar& lastchange; - } - - RowActivity() = default; -}; - -/// counts the locks for the given row entry -template -void -count_locks( const REAL& val, RowFlags rflags, int& ndownlocks, int& nuplocks ) -{ - assert( val != 0 ); - - if( val < 0 ) - { - if( !rflags.test( RowFlag::kLhsInf ) ) - ++nuplocks; - - if( !rflags.test( RowFlag::kRhsInf ) ) - ++ndownlocks; - } - else - { - if( !rflags.test( RowFlag::kLhsInf ) ) - ++ndownlocks; - - if( !rflags.test( RowFlag::kRhsInf ) ) - ++nuplocks; - } -} - -template -RowActivity -compute_row_activity( const REAL* rowvals, const int* colindices, int rowlen, - const Vec& lower_bounds, - const Vec& upper_bounds, const Vec& flags, - int presolveround = -1 ) -{ - RowActivity activity; - - activity.min = 0.0; - activity.max = 0.0; - activity.ninfmin = 0; - activity.ninfmax = 0; - activity.lastchange = presolveround; - - for( int j = 0; j < rowlen; ++j ) - { - int col = colindices[j]; - if( !flags[col].test( ColFlag::kUbUseless ) ) - { - if( rowvals[j] < 0 ) - activity.min += rowvals[j] * upper_bounds[col]; - else - activity.max += rowvals[j] * upper_bounds[col]; - } - else - { - assert( flags[col].test( ColFlag::kUbUseless ) ); - if( rowvals[j] < 0 ) - ++activity.ninfmin; - else - ++activity.ninfmax; - } - - if( !flags[col].test( ColFlag::kLbUseless ) ) - { - if( rowvals[j] < 0 ) - activity.max += rowvals[j] * lower_bounds[col]; - else - activity.min += rowvals[j] * lower_bounds[col]; - } - else - { - assert( flags[col].test( ColFlag::kLbUseless ) ); - if( rowvals[j] < 0 ) - ++activity.ninfmax; - else - ++activity.ninfmin; - } - } - - return activity; -} - -template -REAL -compute_minimal_row_activity( const REAL* rowvals, const int* colindices, int rowlen, - const Vec& lower_bounds, - const Vec& upper_bounds, const Vec& flags) -{ - REAL min = 0.0; - - for( int j = 0; j < rowlen; ++j ) - { - int col = colindices[j]; - if( !flags[col].test( ColFlag::kUbUseless ) && rowvals[j] < 0 ) - min += rowvals[j] * upper_bounds[col]; - if( !flags[col].test( ColFlag::kLbUseless ) && rowvals[j] > 0 ) - min += rowvals[j] * lower_bounds[col]; - } - return min ; -} - -template -REAL -compute_maximal_row_activity( const REAL* rowvals, const int* colindices, int rowlen, - const Vec& lower_bounds, - const Vec& upper_bounds, const Vec& flags) -{ - REAL max = 0.0; - - for( int j = 0; j < rowlen; ++j ) - { - int col = colindices[j]; - if( !flags[col].test( ColFlag::kUbUseless ) && rowvals[j] > 0 ) - max += rowvals[j] * upper_bounds[col]; - if( !flags[col].test( ColFlag::kLbUseless ) && rowvals[j] < 0 ) - max += rowvals[j] * lower_bounds[col]; - } - - return max; -} - -/// update the vector of row activities after lower or upper bounds of a column -/// changed. The last argument must be callable with arguments (ActivityChange, -/// rowid, RowActivity) and is called to inform about row activities that -/// changed -template -ActivityChange -update_activity_after_boundchange( const REAL& colval, BoundChange type, - const REAL& oldbound, const REAL& newbound, - bool oldbound_inf, - RowActivity& activity ) -{ - assert( oldbound_inf || - ( type == BoundChange::kLower && newbound != oldbound ) || - ( type == BoundChange::kUpper && newbound != oldbound ) ); - - if( type == BoundChange::kLower ) - { - if( colval < REAL{ 0.0 } ) - { - if( oldbound_inf ) - { - assert( activity.ninfmax > 0 ); - --activity.ninfmax; - - activity.max += newbound * colval; - } - else - { - activity.max += ( newbound - oldbound ) * colval; - } - - return ActivityChange::kMax; - } - else - { - if( oldbound_inf ) - { - assert( activity.ninfmin > 0 ); - --activity.ninfmin; - - activity.min += newbound * colval; - } - else - { - activity.min += ( newbound - oldbound ) * colval; - } - - return ActivityChange::kMin; - } - } - else - { - if( colval < REAL{ 0.0 } ) - { - if( oldbound_inf ) - { - assert( activity.ninfmin > 0 ); - --activity.ninfmin; - - activity.min += newbound * colval; - } - else - { - activity.min += ( newbound - oldbound ) * colval; - } - - return ActivityChange::kMin; - } - else - { - if( oldbound_inf ) - { - assert( activity.ninfmax > 0 ); - --activity.ninfmax; - - activity.max += newbound * colval; - } - else - { - activity.max += ( newbound - oldbound ) * colval; - } - - return ActivityChange::kMax; - } - } -} - -/// update the vector of row activities after removing a finite lower or upper -/// bound of a column -template -void -update_activities_remove_finite_bound( const int* colinds, const REAL* colvals, - int collen, BoundChange type, - const REAL& oldbound, - Vec>& activities ) -{ - if( type == BoundChange::kLower ) - { - for( int i = 0; i != collen; ++i ) - { - const REAL& colval = colvals[i]; - RowActivity& activity = activities[colinds[i]]; - - if( colval < REAL{ 0.0 } ) - { - activity.max -= oldbound * colval; - ++activity.ninfmax; - } - else - { - activity.min -= oldbound * colval; - ++activity.ninfmin; - } - } - } - else - { - for( int i = 0; i != collen; ++i ) - { - const REAL& colval = colvals[i]; - RowActivity& activity = activities[colinds[i]]; - - if( colval < REAL{ 0.0 } ) - { - activity.min -= oldbound * colval; - ++activity.ninfmin; - } - else - { - activity.max -= oldbound * colval; - ++activity.ninfmax; - } - } - } -} - -/// update the vector of row activities after lower or upper bounds of a column -/// changed. The last argument must be callable with arguments (ActivityChange, -/// rowid, RowActivity) and is called to inform about row activities that -/// changed -template -void -update_activities_after_boundchange( const REAL* colvals, const int* colrows, - int collen, BoundChange type, - REAL oldbound, REAL newbound, - bool oldbound_inf, - Vec>& activities, - ACTIVITYCHANGE&& activityChange, - bool watchInfiniteActivities = false ) -{ - assert( oldbound_inf || - ( type == BoundChange::kLower && newbound != oldbound ) || - ( type == BoundChange::kUpper && newbound != oldbound ) ); - - for( int i = 0; i < collen; ++i ) - { - RowActivity& activity = activities[colrows[i]]; - - ActivityChange actChange = update_activity_after_boundchange( - colvals[i], type, oldbound, newbound, oldbound_inf, activity ); - - if( actChange == ActivityChange::kMin && - ( activity.ninfmin == 0 || watchInfiniteActivities ) ) - activityChange( ActivityChange::kMin, colrows[i], activity ); - - if( actChange == ActivityChange::kMax && - ( activity.ninfmax == 0 || watchInfiniteActivities ) ) - activityChange( ActivityChange::kMax, colrows[i], activity ); - } -} - -/** - * updates the row activity for a changed coefficient in the matrix. - * In case that the difference between the old and new coefficient is large, - * the activity is recalculated entirely to prevent numerical difficulties. - * The last argument must be callable with arguments (ActivityChange, - * RowActivity) and is called to inform about row activities that changed. - * @tparam REAL - * @tparam ACTIVITYCHANGE - * @param collb - * @param colub - * @param cflags - * @param oldcolcoef - * @param newcolcoef - * @param activity - * @param rowLength - * @param colindices - * @param rowvals - * @param domains - * @param num - * @param activityChange - */ -template -void -update_activity_after_coeffchange( REAL collb, REAL colub, ColFlags cflags, - REAL oldcolcoef, REAL newcolcoef, - RowActivity& activity, - int rowLength, const int* colindices, - const REAL* rowvals, - const VariableDomains& domains, - const Num num, - ACTIVITYCHANGE&& activityChange ) -{ - assert( oldcolcoef != newcolcoef ); - - if( oldcolcoef * newcolcoef <= 0.0 ) - { // the sign of the coefficient flipped, so the column bounds now contribute - // to the opposite activity bound - - // remember old activity - RowActivity oldactivity = activity; - - if( oldcolcoef != 0.0 ) - { // if the old coefficient was not 0.0 we remove its contributions to the - // minimum and maximum activity - // remove old contributions of the lower bound - if( cflags.test( ColFlag::kLbUseless ) ) - { - if( oldcolcoef < 0.0 ) - --activity.ninfmax; - else - --activity.ninfmin; - } - else - { - if( oldcolcoef < 0.0 ) - activity.max -= oldcolcoef * collb; - else - activity.min -= oldcolcoef * collb; - } - - // remove old contributions of the upper bound - if( cflags.test( ColFlag::kUbUseless ) ) - { - if( oldcolcoef < 0.0 ) - --activity.ninfmin; - else - --activity.ninfmax; - } - else - { - if( oldcolcoef < 0.0 ) - activity.min -= oldcolcoef * colub; - else - activity.max -= oldcolcoef * colub; - } - } - - if( newcolcoef != 0.0 ) - { // if the new coefficient is not 0.0 we add its contributions to the - // minimum and maximum activity - // add new contributions of the lower bound - if( cflags.test( ColFlag::kLbUseless ) ) - { - if( newcolcoef < 0.0 ) - ++activity.ninfmax; - else - ++activity.ninfmin; - } - else - { - if( newcolcoef < 0.0 ) - activity.max += newcolcoef * collb; - else - activity.min += newcolcoef * collb; - } - - // addnewold contributions of the upper bound - if( cflags.test( ColFlag::kUbUseless ) ) - { - if( newcolcoef < 0.0 ) - ++activity.ninfmin; - else - ++activity.ninfmax; - } - else - { - if( newcolcoef < 0.0 ) - activity.min += newcolcoef * colub; - else - activity.max += newcolcoef * colub; - } - } - - if( ( oldactivity.ninfmin != 0 && activity.ninfmin == 0 ) || - ( oldactivity.ninfmin == 0 && activity.ninfmin == 0 && - oldactivity.min != activity.min ) ) - activityChange( ActivityChange::kMin, activity ); - - if( ( oldactivity.ninfmax != 0 && activity.ninfmax == 0 ) || - ( oldactivity.ninfmax == 0 && activity.ninfmax == 0 && - oldactivity.max != activity.max ) ) - activityChange( ActivityChange::kMax, activity ); - } - else - { // the sign of the coefficient did not flip, so the column bounds still - // contribute to the same activity bound - bool isDifferenceHugeVal = num.isHugeVal( newcolcoef - oldcolcoef ); - if( !cflags.test( ColFlag::kLbUseless ) && collb != 0.0 ) - { - if( newcolcoef < REAL{ 0.0 } ) - { - if( isDifferenceHugeVal ) - activity.max = compute_maximal_row_activity( - rowvals, colindices, rowLength, domains.lower_bounds, - domains.upper_bounds, domains.flags ); - else - activity.max += collb * ( newcolcoef - oldcolcoef ); - - if( activity.ninfmax == 0 ) - activityChange( ActivityChange::kMax, activity ); - } - else - { - if( isDifferenceHugeVal ) - activity.min = compute_minimal_row_activity( - rowvals, colindices, rowLength, domains.lower_bounds, - domains.upper_bounds, domains.flags ); - - else - activity.min += collb * ( newcolcoef - oldcolcoef ); - if( activity.ninfmin == 0 ) - activityChange( ActivityChange::kMin, activity ); - } - } - - if( !cflags.test( ColFlag::kUbUseless ) && colub != 0.0 ) - { - if( newcolcoef < REAL{ 0.0 } ) - { - if( isDifferenceHugeVal ) - activity.min = compute_minimal_row_activity( - rowvals, colindices, rowLength, domains.lower_bounds, - domains.upper_bounds, domains.flags ); - else - activity.min += colub * ( newcolcoef - oldcolcoef ); - if( activity.ninfmin == 0 ) - activityChange( ActivityChange::kMin, activity ); - } - else - { - if( isDifferenceHugeVal ) - activity.max = compute_maximal_row_activity( - rowvals, colindices, rowLength, domains.lower_bounds, - domains.upper_bounds, domains.flags ); - else - activity.max += colub * ( newcolcoef - oldcolcoef ); - if( activity.ninfmax == 0 ) - activityChange( ActivityChange::kMax, activity ); - } - } - } -} - -/// propagate domains of variables using the given a row and its activity. The -/// last argument must be callable with arguments (BoundChange, colid, newbound, row) -/// and is called to inform about column bounds that changed. -template -void -propagate_row( int row, const REAL* rowvals, const int* colindices, int rowlen, - const RowActivity& activity, REAL lhs, REAL rhs, - RowFlags rflags, const Vec& lower_bounds, - const Vec& upper_bounds, const Vec& domainFlags, - BOUNDCHANGE&& boundchange ) -{ - - bool adj_rhs = false; - if( activity.ninfmin == 1 && activity.ninfmax == 0 && - rflags.test( RowFlag::kRhsInf ) ) - { - adj_rhs = true; - rhs = activity.max; - } - - if( ( !rflags.test( RowFlag::kRhsInf ) && activity.ninfmin <= 1 ) || - adj_rhs ) - { - for( int j = 0; j < rowlen; ++j ) - { - int col = colindices[j]; - REAL lb = lower_bounds[col]; - REAL ub = upper_bounds[col]; - REAL minresact = activity.min; - REAL val = rowvals[j]; - - if( val < REAL{ 0.0 } ) - { - if( activity.ninfmin == 1 ) - { - if( !domainFlags[col].test( ColFlag::kUbUseless ) ) - continue; - - j = rowlen; - } - else - { - assert( !domainFlags[col].test( ColFlag::kUbUseless ) ); - minresact -= val * ub; - } - - REAL newlb = ( rhs - minresact ) / val; - if( domainFlags[col].test( ColFlag::kLbInf ) || newlb > lb ) - boundchange( BoundChange::kLower, col, newlb, row ); - } - else - { - if( activity.ninfmin == 1 ) - { - if( !domainFlags[col].test( ColFlag::kLbUseless ) ) - continue; - - j = rowlen; - } - else - { - assert( !domainFlags[col].test( ColFlag::kLbUseless ) ); - minresact -= val * lb; - } - - REAL newub = ( rhs - minresact ) / val; - if( domainFlags[col].test( ColFlag::kUbInf ) || newub < ub ) - boundchange( BoundChange::kUpper, col, newub, row ); - } - } - } - - bool adj_lhs = false; - if( activity.ninfmax == 1 && activity.ninfmin == 0 && - rflags.test( RowFlag::kLhsInf ) ) - { - adj_lhs = true; - lhs = activity.min; - } - - if( ( !rflags.test( RowFlag::kLhsInf ) && activity.ninfmax <= 1 ) || - adj_lhs ) - { - for( int j = 0; j < rowlen; ++j ) - { - int col = colindices[j]; - REAL lb = lower_bounds[col]; - REAL ub = upper_bounds[col]; - REAL maxresact = activity.max; - REAL val = rowvals[j]; - - if( val < REAL{ 0.0 } ) - { - if( activity.ninfmax == 1 ) - { - if( !domainFlags[col].test( ColFlag::kLbUseless ) ) - continue; - - j = rowlen; - } - else - { - assert( !domainFlags[col].test( ColFlag::kLbUseless ) ); - maxresact -= val * lb; - } - - REAL newub = ( lhs - maxresact ) / val; - if( domainFlags[col].test( ColFlag::kUbInf ) || newub < ub ) - boundchange( BoundChange::kUpper, col, newub, row ); - } - else - { - if( activity.ninfmax == 1 ) - { - if( !domainFlags[col].test( ColFlag::kUbUseless ) ) - continue; - - j = rowlen; - } - else - { - assert( !domainFlags[col].test( ColFlag::kUbUseless ) ); - maxresact -= val * ub; - } - - REAL newlb = ( lhs - maxresact ) / val; - if( domainFlags[col].test( ColFlag::kLbInf ) || newlb > lb ) - boundchange( BoundChange::kLower, col, newlb, row ); - } - } - } -} - -template -bool -row_implies_LB( const Num& num, REAL lhs, REAL rhs, RowFlags rflags, - const RowActivity& activity, REAL colcoef, REAL collb, - REAL colub, ColFlags cflags ) - -{ - if( cflags.test( ColFlag::kLbInf ) ) - return true; - - REAL resact; - REAL side; - - if( colcoef > 0.0 && !rflags.test( RowFlag::kLhsInf ) ) - { - if( activity.ninfmax == 0 ) - { - assert( !cflags.test( ColFlag::kUbUseless ) ); - resact = activity.max - colub * colcoef; - } - else if( activity.ninfmax == 1 && cflags.test( ColFlag::kUbUseless ) ) - resact = activity.max; - else - return false; - - side = lhs; - } - else if( colcoef < 0.0 && !rflags.test( RowFlag::kRhsInf ) ) - { - if( activity.ninfmin == 0 ) - { - assert( !cflags.test( ColFlag::kUbUseless ) ); - resact = activity.min - colub * colcoef; - } - else if( activity.ninfmin == 1 && cflags.test( ColFlag::kUbUseless ) ) - resact = activity.min; - else - return false; - - side = rhs; - } - else - return false; - - return num.isFeasGE( ( side - resact ) / colcoef, collb ); -} - -template -bool -row_implies_UB( const Num& num, REAL lhs, REAL rhs, RowFlags rflags, - const RowActivity& activity, REAL colcoef, REAL collb, - REAL colub, ColFlags cflags ) -{ - if( cflags.test( ColFlag::kUbInf ) ) - return true; - - REAL resact; - REAL side; - - if( colcoef > 0.0 && !rflags.test( RowFlag::kRhsInf ) ) - { - if( activity.ninfmin == 0 ) - { - assert( !cflags.test( ColFlag::kLbUseless ) ); - resact = activity.min - collb * colcoef; - } - else if( activity.ninfmin == 1 && cflags.test( ColFlag::kLbUseless ) ) - resact = activity.min; - else - return false; - - side = rhs; - } - else if( colcoef < 0.0 && !rflags.test( RowFlag::kLhsInf ) ) - { - if( activity.ninfmax == 0 ) - { - assert( !cflags.test( ColFlag::kLbUseless ) ); - resact = activity.max - collb * colcoef; - } - else if( activity.ninfmax == 1 && cflags.test( ColFlag::kLbUseless ) ) - resact = activity.max; - else - return false; - - side = lhs; - } - else - return false; - - return num.isFeasLE( ( side - resact ) / colcoef, colub ); -} - -} // namespace papilo - -#endif diff --git a/headers/papilo/core/Solution.hpp b/headers/papilo/core/Solution.hpp deleted file mode 100644 index 7f75949..0000000 --- a/headers/papilo/core/Solution.hpp +++ /dev/null @@ -1,98 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* */ -/* This file is part of the program and library */ -/* PaPILO --- Parallel Presolve for Integer and Linear Optimization */ -/* */ -/* Copyright (C) 2020-2022 Konrad-Zuse-Zentrum */ -/* fuer Informationstechnik Berlin */ -/* */ -/* This program is free software: you can redistribute it and/or modify */ -/* it under the terms of the GNU Lesser General Public License as published */ -/* by the Free Software Foundation, either version 3 of the License, or */ -/* (at your option) any later version. */ -/* */ -/* This program is distributed in the hope that it will be useful, */ -/* but WITHOUT ANY WARRANTY; without even the implied warranty of */ -/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ -/* GNU Lesser General Public License for more details. */ -/* */ -/* You should have received a copy of the GNU Lesser General Public License */ -/* along with this program. If not, see . */ -/* */ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -#ifndef _PAPILO_CORE_SOLUTION_HPP_ -#define _PAPILO_CORE_SOLUTION_HPP_ - -#include "papilo/misc/Vec.hpp" - -namespace papilo -{ - -enum class SolutionType -{ - kPrimal, - kPrimalDual -}; - -enum class VarBasisStatus : int -{ - ON_UPPER = 0, - ON_LOWER = 1, - FIXED = 2, - ZERO = 3, - BASIC = 4, - UNDEFINED = 5 -}; - -template -class Solution -{ - public: - SolutionType type; - Vec primal; - Vec dual; - Vec reducedCosts; - Vec slack; - bool basisAvailabe; - Vec varBasisStatus; - Vec rowBasisStatus; - - // Default type primal only. - Solution() : type( SolutionType::kPrimal ), basisAvailabe( false ) {} - - explicit Solution( SolutionType type_ ) : type( type_ ), basisAvailabe( false ) {} - - Solution( SolutionType type_, Vec values ) - : type( type_ ), primal( std::move( values ) ), basisAvailabe( false ) - { - } - - explicit Solution( Vec values ) - : type( SolutionType::kPrimal ), primal( std::move( values ) ), - basisAvailabe( false ) - { - } - - Solution( Vec primal_values, Vec dual_values, - Vec reduced_values, Vec slack_values, - bool basisAvailabe_value, - Vec var_basis_status, - Vec row_basis_status -) - : type( SolutionType::kPrimalDual ), - primal( std::move( primal_values ) ), - dual( std::move( dual_values ), - reducedCosts( std::move( reduced_values ) ), - slack( std::move( slack_values ) ) ), - basisAvailabe( basisAvailabe_value ), - varBasisStatus( std::move( var_basis_status )), - rowBasisStatus( std::move( row_basis_status )) - - { - } -}; - -} // namespace papilo - -#endif diff --git a/headers/papilo/core/SparseStorage.hpp b/headers/papilo/core/SparseStorage.hpp deleted file mode 100644 index bef761b..0000000 --- a/headers/papilo/core/SparseStorage.hpp +++ /dev/null @@ -1,985 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* */ -/* This file is part of the program and library */ -/* PaPILO --- Parallel Presolve for Integer and Linear Optimization */ -/* */ -/* Copyright (C) 2020-2022 Konrad-Zuse-Zentrum */ -/* fuer Informationstechnik Berlin */ -/* */ -/* This program is free software: you can redistribute it and/or modify */ -/* it under the terms of the GNU Lesser General Public License as published */ -/* by the Free Software Foundation, either version 3 of the License, or */ -/* (at your option) any later version. */ -/* */ -/* This program is distributed in the hope that it will be useful, */ -/* but WITHOUT ANY WARRANTY; without even the implied warranty of */ -/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ -/* GNU Lesser General Public License for more details. */ -/* */ -/* You should have received a copy of the GNU Lesser General Public License */ -/* along with this program. If not, see . */ -/* */ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -#ifndef _PAPILO_CORE_SPARSE_STORAGE_HPP_ -#define _PAPILO_CORE_SPARSE_STORAGE_HPP_ - -#include "papilo/misc/MultiPrecision.hpp" -#include "papilo/misc/Vec.hpp" -#include "papilo/external/pdqsort/pdqsort.h" -#include -#include -#include -#include -#include - -namespace papilo -{ - -/// type definition for a non-zero entry in triplet format -template -using Triplet = std::tuple; - -// forward declaration of constraint matrix to declare the constraint matrix a -// friend class of SparseStorage -template -class ConstraintMatrix; - -struct IndexRange -{ - int start; - int end; - - IndexRange() : start( -1 ), end( -1 ){}; - - template - void - serialize( Archive& ar, const unsigned int version ) - { - ar& start; - ar& end; - } -}; - -/// Sparse storage class to store a matrix in modified CSR format -/// which includes a start and end for each row and allows for some free -/// space between the rows which is useful if the matrix may be altered -template -class SparseStorage -{ - friend class ConstraintMatrix; - - public: - static constexpr double DEFAULT_SPARE_RATIO = 2.0; - static constexpr int DEFAULT_MIN_INTER_ROW_SPACE = 4; - - SparseStorage() = default; - SparseStorage( Vec> entries, int nRows_in, int nCols_in, - bool sorted = false, double spareRatio = DEFAULT_SPARE_RATIO, - int minInterRowSpace = DEFAULT_MIN_INTER_ROW_SPACE ); - SparseStorage( REAL* values_in, int* rowstart_in, int* columns_in, - int nRows_in, int nCols_in, int nnz_in, - double spareRatio = DEFAULT_SPARE_RATIO, - int minInterRowSpace = DEFAULT_MIN_INTER_ROW_SPACE ); - SparseStorage( int nRows_in, int nCols_in, int nnz_in, double spareRatio, - int minInterRowSpace ); - - SparseStorage - getTranspose() const; - - Vec - compress( const Vec& rowsize, const Vec& colsize, - bool full = false ); - - int - getNRows() const - { - return nRows; - } - - bool - shiftRows( const int* rowinds, int ninds, int maxshiftperrow, - const Vec& requiredSpareSpace ); - - int - getNCols() const - { - return nCols; - } - - int - getNnz() const - { - return nnz; - } - - int& - getNnz() - { - return nnz; - } - - int - getNAlloc() const - { - return nAlloc; - } - - const REAL* - getValues() const - { - return values.data(); - } - - REAL* - getValues() - { - return values.data(); - } - - const Vec& - getValuesVec() const - { - return values; - } - - const IndexRange* - getRowRanges() const - { - return rowranges.data(); - } - - const Vec& - getRowRangesVec() const - { - return rowranges; - } - - IndexRange* - getRowRanges() - { - return rowranges.data(); - } - - const int* - getColumns() const - { - return columns.data(); - } - - int* - getColumns() - { - return columns.data(); - } - - const Vec& - getColumnsVec() const - { - return columns; - } - - Vec - getRowStarts() const; - - // function to change existing coefficients in row. Must not be called with - // coefficients that are currently not in the row. Changes must be given in - // sorted order. - template - int - changeRowInplace( int row, HasNext&& hasNext, GetNext&& getNext, - CoeffChanged&& coeffChanged ) - { - int i = rowranges[row].start; - int j = 0; - - while( hasNext() ) - { - int col; - REAL newval; - - std::tie( col, newval ) = getNext(); - - while( col != columns[i] ) - { - if( j != 0 ) - { - columns[i - j] = columns[i]; - values[i - j] = std::move( values[i] ); - } - ++i; - } - - coeffChanged( row, col, values[i], newval ); - - if( newval == 0 ) - { - ++j; - } - else if( j != 0 ) - { - columns[i - j] = columns[i]; - values[i - j] = std::move( newval ); - } - else - { - values[i] = std::move( newval ); - } - - ++i; - } - - if( j != 0 ) - { - while( i != rowranges[row].end ) - { - columns[i - j] = columns[i]; - values[i - j] = std::move( values[i] ); - ++i; - } - - rowranges[row].end -= j; - nnz -= j; - } - - return rowranges[row].end - rowranges[row].start; - } - - /// change coefficients inside the given row. The details of how to change - /// the row are templatized to allow for a generalized use of this function. - /// The iteration of the changes is controlled by the Iter template type and - /// the GetCol and GetVal callbacks to retrieve the column and the value out - /// of that iterator type. If a matching support has been found the MergeVals - /// callback is called with the first argument being the rows current value. - /// The value returned by MergeVals is used as the new coefficient. This - /// allows to use the function for setting the coefficients to values, or to - /// add values to the coefficients. If a coefficient was changed the caller - /// is informed about the old and the new coefficient via the CoeffChanged - /// callback. - /// Returns the new size of the row. - template - int - changeRow( int row, Iter it, Iter itend, GetCol&& getCol, GetVal&& getVal, - MergeVals&& mergeVals, CoeffChanged&& coeffChanged, - Vec& valbuffer, Vec& indbuffer ) - { - auto rowmaxlen = - rowranges[row].end - rowranges[row].start + ( itend - it ); - assert( valbuffer.empty() ); - assert( indbuffer.empty() ); - - valbuffer.reserve( rowmaxlen ); - indbuffer.reserve( rowmaxlen ); - - int i = rowranges[row].start; - - while( i != rowranges[row].end && it != itend ) - { - int col = getCol( it ); - - if( columns[i] == col ) - { - REAL newval = mergeVals( values[i], getVal( it ) ); - coeffChanged( row, col, values[i], newval ); - - if( newval != 0.0 ) - { - indbuffer.push_back( col ); - valbuffer.push_back( std::move( newval ) ); - } - ++i; - ++it; - } - else if( columns[i] < col ) - { - indbuffer.push_back( columns[i] ); - valbuffer.push_back( values[i] ); - ++i; - } - else - { - REAL newval = getVal( it ); - coeffChanged( row, col, 0.0, newval ); - - indbuffer.push_back( col ); - valbuffer.push_back( std::move( newval ) ); - ++it; - } - } - - if( i != rowranges[row].end ) - { - indbuffer.insert( indbuffer.end(), &columns[i], - &columns[rowranges[row].end] ); - valbuffer.insert( valbuffer.end(), &values[i], - &values[rowranges[row].end] ); - } - else - { - while( it != itend ) - { - int col = getCol( it ); - REAL newval = getVal( it ); - coeffChanged( row, col, 0.0, newval ); - - indbuffer.push_back( col ); - valbuffer.push_back( std::move( newval ) ); - ++it; - } - } - - // copy over values from buffer - assert( valbuffer.size() == indbuffer.size() ); - assert( std::is_sorted( indbuffer.begin(), indbuffer.end() ) ); - - int newsize = static_cast( indbuffer.size() ); - - assert( newsize <= rowranges[row + 1].start - rowranges[row].start ); - - nnz = nnz - rowranges[row].end + rowranges[row].start + newsize; - - // copy over values from buffer - std::copy_n( valbuffer.data(), newsize, &values[rowranges[row].start] ); - std::memcpy( &columns[rowranges[row].start], indbuffer.data(), - sizeof( int ) * newsize ); - - rowranges[row].end = rowranges[row].start + newsize; - - valbuffer.clear(); - indbuffer.clear(); - - return newsize; - } - - template - void - serialize( Archive& ar, const unsigned int version ) - { - ar& nRows; - ar& nCols; - ar& nnz; - ar& nAlloc; - ar& spareRatio; - ar& minInterRowSpace; - - if( Archive::is_loading::value ) - { - assert( values.empty() ); - assert( rowranges.empty() ); - assert( columns.empty() ); - - rowranges.resize( nRows + 1 ); - values.resize( nAlloc ); - columns.resize( nAlloc ); - } - - for( int i = 0; i != nRows + 1; ++i ) - ar& rowranges[i]; - - for( int i = 0; i != nRows; ++i ) - { - for( int j = rowranges[i].start; j != rowranges[i].end; ++j ) - { - ar& values[j]; - ar& columns[j]; - } - } - } - - int - computeRowAlloc( int rowsize ) const - { - return static_cast( rowsize * spareRatio ) + minInterRowSpace; - } - - private: - int - computeNAlloc() const - { - return static_cast( nnz * spareRatio ) + nRows * minInterRowSpace; - } - - Vec values; - Vec rowranges; - Vec columns; - - int nRows = -1; - int nCols = -1; - int nnz = -1; - int nAlloc = -1; - double spareRatio = 0.0; - int minInterRowSpace = 0; -}; - -#ifdef PAPILO_USE_EXTERN_TEMPLATES -extern template class SparseStorage; -extern template class SparseStorage; -extern template class SparseStorage; -#endif - -template -SparseStorage::SparseStorage( Vec> entries, int nRows_in, - int nCols_in, bool sorted, - double spareRatio_, int minInterRowSpace_ ) - : nRows( nRows_in ), nCols( nCols_in ), spareRatio( spareRatio_ ), - minInterRowSpace( minInterRowSpace_ ) -{ - assert( spareRatio_ >= 0.0 ); - assert( !sorted || std::is_sorted( entries.begin(), entries.end() ) ); - - if( !sorted ) - pdqsort( entries.begin(), entries.end() ); - - nnz = entries.size(); - nAlloc = computeNAlloc(); - - rowranges.resize( nRows + 1 ); - values.resize( nAlloc ); - columns.resize( nAlloc ); - - rowranges[0].start = 0; - - int idx = 0; - int current_row = 0; - for( auto entry : entries ) - { - int row; - int col; - REAL value; - - std::tie( row, col, value ) = entry; - - assert( row >= 0 && row < nRows ); - assert( col >= 0 && col < nCols ); - - if( row != current_row ) - { - assert( row > current_row ); - - rowranges[current_row].end = idx; - - idx = rowranges[current_row].start + - computeRowAlloc( rowranges[current_row].end - - rowranges[current_row].start ); - assert( idx > rowranges[current_row].end ); - - rowranges[current_row + 1].start = idx; - - // there might be empty rows - for( int r = current_row + 1; r < row; r++ ) - { - rowranges[r].end = idx; - rowranges[r + 1].start = idx; - } - - current_row = row; - } - - if( value != 0 ) - { - assert( idx < nAlloc ); - - values[idx] = value; - columns[idx++] = col; - } - else - --nnz; - } - - rowranges[current_row].end = idx; - - idx = rowranges[current_row].start + - computeRowAlloc( rowranges[current_row].end - - rowranges[current_row].start ); - assert( idx > rowranges[current_row].end ); - assert( idx <= nAlloc ); - - rowranges[current_row + 1].start = idx; - - // there might be empty rows at the end - for( int r = current_row + 1; r < nRows; r++ ) - { - rowranges[r].end = idx; - rowranges[r + 1].start = idx; - } - - rowranges[nRows].end = idx; -} - -template -SparseStorage::SparseStorage( int nRows_in, int nCols_in, int nnz_in, - double spareRatio_, int minInterRowSpace_ ) - : nRows( nRows_in ), nCols( nCols_in ), nnz( nnz_in ), - spareRatio( spareRatio_ ), minInterRowSpace( minInterRowSpace_ ) -{ - nAlloc = computeNAlloc(); - assert( spareRatio_ >= 1.0 ); - - rowranges.resize( nRows + 1 ); - values.resize( nAlloc ); - columns.resize( nAlloc ); - - rowranges[nRows].start = nAlloc; - rowranges[nRows].end = nAlloc; -} - -template -SparseStorage::SparseStorage( REAL* values_in, int* rowstart_in, - int* columns_in, int nRows_in, int nCols_in, - int nnz_in, double spareRatio_in, - int minInterRowSpace_in ) - : nRows( nRows_in ), nCols( nCols_in ), nnz( nnz_in ), - spareRatio( spareRatio_in ), minInterRowSpace( minInterRowSpace_in ) -{ - assert( nRows_in >= 0 && nnz_in >= 0 && spareRatio >= 1.0 ); - assert( rowstart_in ); - - // compute length of new storage - nAlloc = computeNAlloc(); - - columns.resize( nAlloc ); - values.resize( nAlloc ); - rowranges.resize( nRows + 1 ); - - // build storage - int shift = 0; - for( int r = 0; r < nRows; r++ ) - { - rowranges[r].start = rowstart_in[r] + shift; - - for( int j = rowstart_in[r]; j < rowstart_in[r + 1]; j++ ) - { - if( values_in[j] != REAL{ 0.0 } ) - { - assert( j + shift >= 0 ); - - values[j + shift] = values_in[j]; - columns[j + shift] = columns_in[j]; - } - else - { - shift--; - } - } - - rowranges[r].end = rowstart_in[r + 1] + shift; - const int rowsize = rowranges[r].end - rowranges[r].start; - const int rowalloc = computeRowAlloc( rowsize ); - shift += rowalloc - rowsize; - } - - assert( nRows == 0 ); - - rowranges[nRows].start = rowstart_in[nRows] + shift; - rowranges[nRows].end = rowranges[nRows].start; -} - -template -SparseStorage -SparseStorage::getTranspose() const -{ -// if( nCols <= 0 ) -// return SparseStorage{}; - - // compute nnz of each row of At (column of A) - - Vec w( size_t( nCols ), 0 ); - - for( int r = 0; r < nRows; r++ ) - { - const int start = rowranges[r].start; - const int end = rowranges[r].end; - - for( int j = start; j < end; j++ ) - { - assert( values[j] != REAL{ 0.0 } ); - w[columns[j]]++; - } - } - - assert( spareRatio >= 1.0 ); - - SparseStorage transpose{ nCols, nRows, nnz, spareRatio, - minInterRowSpace }; - - // set row ranges of transpose - transpose.rowranges[0].start = 0; - - for( int i = 1; i <= nCols; i++ ) - { - const int oldstart = transpose.rowranges[i - 1].start; - const int oldend = oldstart + w[i - 1]; - assert( oldend >= oldstart ); - - transpose.rowranges[i - 1].end = oldend; - transpose.rowranges[i].start = - oldstart + transpose.computeRowAlloc( w[i - 1] ); - - w[i - 1] = oldstart; - } - - transpose.rowranges[nCols].start = transpose.nAlloc; - transpose.rowranges[nCols].end = transpose.nAlloc; - - // fill values and columns arrays of transpose - for( int r = 0; r < nRows; r++ ) - { - const int start = rowranges[r].start; - const int end = rowranges[r].end; - - for( int j = start; j < end; j++ ) - { - const int idx = w[columns[j]]; - - assert( idx < transpose.nAlloc ); - - transpose.values[idx] = values[j]; - transpose.columns[idx] = r; - - w[columns[j]] = idx + 1; - } - } - return transpose; -} - -template -Vec -SparseStorage::compress( const Vec& rowsize, const Vec& colsize, - bool full ) -{ - if( full ) - { - spareRatio = 1.0; - minInterRowSpace = 0; - } - // now create and fill storage - Vec colsmap( static_cast( nCols ) ); - - if( nCols > 0 ) - { - int colcount = 0; - - for( int i = 0; i < nCols; i++ ) - { - if( colsize[i] >= 0 ) - colsmap[i] = colcount++; - else - colsmap[i] = -1; - } - - nCols = colcount; - } - - if( nRows > 0 ) - { - int offset = 0; - int rowcount = 0; - for( int r = 0; r < nRows; r++ ) - { - const int start = rowranges[r].start; - const int end = rowranges[r].end; - const int rowalloc = rowranges[r + 1].start - start; - - // empty row? - if( rowsize[r] == -1 ) - offset += rowalloc; - else - { - rowranges[rowcount].start = start; - rowranges[rowcount].end = end; - - if( offset > 0 ) - { - // move values and columns - assert( start >= offset ); - - std::move( &values[start], &values[end], - &values[start - offset] ); - std::move( &columns[start], &columns[end], - &columns[start - offset] ); - - rowranges[rowcount].start -= offset; - rowranges[rowcount].end -= offset; - } - - offset = std::max( - offset + rowalloc - computeRowAlloc( end - start ), 0 ); - - ++rowcount; - } - - assert( offset <= nAlloc ); - } - - rowranges[rowcount].start = rowranges[nRows].start - offset; - rowranges[rowcount].end = rowranges[nRows].end - offset; - - nRows = rowcount; - nAlloc = nAlloc - offset; - assert( nAlloc >= 0 ); - - rowranges.resize( nRows + 1 ); - values.resize( nAlloc ); - columns.resize( nAlloc ); - - if( full ) - { - rowranges.shrink_to_fit(); - values.shrink_to_fit(); - columns.shrink_to_fit(); - } - - for( int r = 0; r < nRows; r++ ) - { - const int start = rowranges[r].start; - const int end = rowranges[r].end; - - for( int j = start; j < end; j++ ) - { - assert( columns[j] >= 0 ); - assert( columns[j] < static_cast( colsmap.size() ) ); - columns[j] = colsmap[columns[j]]; - assert( columns[j] >= 0 ); - assert( columns[j] < nCols ); - } - } - } - - return colsmap; -} - -template -bool -SparseStorage::shiftRows( const int* rowinds, int ninds, - int maxshiftperrow, - const Vec& requiredSpareSpace ) -{ - assert( ninds > 0 ); - assert( rowinds != nullptr ); - assert( (int) requiredSpareSpace.size() == ninds ); - assert( std::is_sorted( rowinds, rowinds + ninds ) ); - - for( int i = 0; i != ninds; ++i ) - { - const int row = rowinds[i]; - int missingspace = requiredSpareSpace[i] - - ( rowranges[row + 1].start - rowranges[row].end ); - if( missingspace > 0 ) - { - int leftbound = i == 0 ? 0 : rowinds[i - 1] + 1; - int rightbound = i == ninds - 1 ? nRows : rowinds[i + 1]; - - int l = row; - int r = row + 1; - int lastshiftleft = 0; - int lastshiftright = 0; - int maxshift = maxshiftperrow; - while( missingspace > 0 ) - { - if( l > leftbound && r < rightbound ) - { - int nspaceleft = std::min( - missingspace, rowranges[l].start - rowranges[l - 1].end ); - int nspaceright = std::min( - missingspace, rowranges[r + 1].start - rowranges[r].end ); - int nshiftleft = rowranges[l].end - rowranges[l].start; - int nshiftright = rowranges[r].end - rowranges[r].start; - - bool goleft; - if( nshiftleft == 0 ) - goleft = true; - else if( nshiftright == 0 ) - goleft = false; - else if( nshiftleft <= maxshift && - nspaceleft / (double)nshiftleft >= - nspaceright / (double)nshiftright ) - goleft = true; - else if( nshiftright <= maxshift ) - goleft = false; - else - return false; - - // take direction that gives the most space per shifted - // nonzero - if( goleft ) - { - maxshift -= nshiftleft; - if( nspaceleft != 0 ) - { - lastshiftleft = nspaceleft; - missingspace -= lastshiftleft; - } - --l; - } - else - { - maxshift -= nshiftright; - if( nspaceright != 0 ) - { - lastshiftright = nspaceright; - missingspace -= lastshiftright; - } - ++r; - } - } - else if( l > leftbound && - rowranges[l].end - rowranges[l].start <= maxshift ) - { - maxshift -= rowranges[l].end - rowranges[l].start; - lastshiftleft = std::min( - missingspace, rowranges[l].start - rowranges[l - 1].end ); - missingspace -= lastshiftleft; - --l; - } - else if( r < rightbound && - rowranges[r].end - rowranges[r].start <= maxshift ) - { - maxshift -= rowranges[r].end - rowranges[r].start; - lastshiftright = std::min( missingspace, rowranges[r + 1].start - - rowranges[r].end ); - missingspace -= lastshiftright; - ++r; - } - else - return false; - } - - assert( missingspace == 0 && - ( lastshiftleft > 0 || lastshiftright > 0 ) ); - if( lastshiftleft > 0 ) - { - do - { - ++l; - // skip possibly empty rows that did not increase the available - // space - } while( rowranges[l].start == rowranges[l - 1].end ); - - REAL* valsout = &values[rowranges[l].start - lastshiftleft]; - int* colsout = &columns[rowranges[l].start - lastshiftleft]; - - assert( rowranges[l - 1].end <= - rowranges[l].start - lastshiftleft ); - - while( l <= row ) - { - int shift = &values[rowranges[l].start] - valsout; - -#ifndef NDEBUG - Vec tmpvals; - Vec tmpinds; - tmpvals.insert( tmpvals.end(), &values[rowranges[l].start], - &values[rowranges[l].end] ); - tmpinds.insert( tmpinds.end(), &columns[rowranges[l].start], - &columns[rowranges[l].end] ); -#endif - if( rowranges[l].start != rowranges[l].end ) - { - valsout = std::move( &values[rowranges[l].start], - &values[rowranges[l].end], valsout ); - colsout = std::move( &columns[rowranges[l].start], - &columns[rowranges[l].end], colsout ); - } - - rowranges[l].start -= shift; - rowranges[l].end -= shift; - assert( &columns[rowranges[l].end] == colsout ); - assert( &values[rowranges[l].end] == valsout ); - assert( rowranges[l - 1].end <= rowranges[l].start ); - assert( rowranges[l].end - rowranges[l].start == - (int) tmpvals.size() ); - assert( std::equal( tmpvals.begin(), tmpvals.end(), - &values[rowranges[l].start] ) ); - assert( std::equal( tmpinds.begin(), tmpinds.end(), - &columns[rowranges[l].start] ) ); - ++l; - } - } - - if( lastshiftright > 0 ) - { - do - { - --r; - // skip possibly empty rows that did not increase the available - // space - } while( rowranges[r].end == rowranges[r + 1].start ); - - REAL* valsout = &values[rowranges[r].end + lastshiftright]; - int* colsout = &columns[rowranges[r].end + lastshiftright]; - - assert( rowranges[r + 1].start >= - rowranges[r].end + lastshiftright ); - - while( r > row ) - { - int shift = valsout - &values[rowranges[r].end]; - -#ifndef NDEBUG - Vec tmpvals; - Vec tmpinds; - tmpvals.insert( tmpvals.end(), &values[rowranges[r].start], - &values[rowranges[r].end] ); - tmpinds.insert( tmpinds.end(), &columns[rowranges[r].start], - &columns[rowranges[r].end] ); -#endif - if( rowranges[r].start != rowranges[r].end ) - { - valsout = - std::move_backward( &values[rowranges[r].start], - &values[rowranges[r].end], valsout ); - colsout = - std::move_backward( &columns[rowranges[r].start], - &columns[rowranges[r].end], colsout ); - } - - rowranges[r].start += shift; - rowranges[r].end += shift; - assert( &columns[rowranges[r].start] == colsout ); - assert( &values[rowranges[r].start] == valsout ); - assert( rowranges[r + 1].start >= rowranges[r].end ); - assert( rowranges[r].end - rowranges[r].start == - (int) tmpvals.size() ); - assert( std::equal( tmpvals.begin(), tmpvals.end(), - &values[rowranges[r].start] ) ); - assert( std::equal( tmpinds.begin(), tmpinds.end(), - &columns[rowranges[r].start] ) ); - --r; - } - } - - assert( rowranges[row + 1].start - rowranges[row].end >= - requiredSpareSpace[i] ); - } - - // space should suffice now, either because it already did, or because it - // was modified - assert( requiredSpareSpace[i] <= - ( rowranges[row + 1].start - rowranges[row].end ) ); - } - - return true; -} - -template -Vec -SparseStorage::getRowStarts() const -{ - int size = getNRows() + 1; - Vec colStart( size ); - - unsigned int i; - for( i = 0; i < colStart.size() - 1; ++i ) - { - colStart[i] = rowranges[i].start; - assert( rowranges[i].end == rowranges[i + 1].start ); - } - colStart[i] = rowranges[i].end; - - return colStart; -} - -} // namespace papilo - -#endif diff --git a/headers/papilo/core/Statistics.hpp b/headers/papilo/core/Statistics.hpp deleted file mode 100644 index fdadad0..0000000 --- a/headers/papilo/core/Statistics.hpp +++ /dev/null @@ -1,72 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* */ -/* This file is part of the program and library */ -/* PaPILO --- Parallel Presolve for Integer and Linear Optimization */ -/* */ -/* Copyright (C) 2020-2022 Konrad-Zuse-Zentrum */ -/* fuer Informationstechnik Berlin */ -/* */ -/* This program is free software: you can redistribute it and/or modify */ -/* it under the terms of the GNU Lesser General Public License as published */ -/* by the Free Software Foundation, either version 3 of the License, or */ -/* (at your option) any later version. */ -/* */ -/* This program is distributed in the hope that it will be useful, */ -/* but WITHOUT ANY WARRANTY; without even the implied warranty of */ -/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ -/* GNU Lesser General Public License for more details. */ -/* */ -/* You should have received a copy of the GNU Lesser General Public License */ -/* along with this program. If not, see . */ -/* */ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -#ifndef _PAPILO_CORE_STATISTICS_HPP_ -#define _PAPILO_CORE_STATISTICS_HPP_ - -namespace papilo -{ - -struct Statistics -{ - double presolvetime; - int ntsxapplied; - int ntsxconflicts; - int nboundchgs; - int nsidechgs; - int ncoefchgs; - int nrounds; - int ndeletedcols; - int ndeletedrows; - - Statistics( double _presolvetime, int _ntsxapplied, int _ntsxconflicts, - int _nboundchgs, int _nsidechgs, int _ncoefchgs, int _nrounds, - int _ndeletedcols, int _ndeletedrows ) - : presolvetime( _presolvetime ), ntsxapplied( _ntsxapplied ), - ntsxconflicts( _ntsxconflicts ), nboundchgs( _nboundchgs ), - nsidechgs( _nsidechgs ), ncoefchgs( _ncoefchgs ), nrounds( _nrounds ), - ndeletedcols( _ndeletedcols ), ndeletedrows( _ndeletedrows ) - { - } - - Statistics() - : presolvetime( 0.0 ), ntsxapplied( 0 ), ntsxconflicts( 0 ), - nboundchgs( 0 ), nsidechgs( 0 ), ncoefchgs( 0 ), nrounds( 0 ), - ndeletedcols( 0 ), ndeletedrows( 0 ) - { - } -}; - -inline Statistics -operator-( const Statistics& a, const Statistics& b ) -{ - return { - 0.0, a.ntsxapplied - b.ntsxapplied, a.ntsxconflicts - b.ntsxconflicts, - a.nboundchgs - b.nboundchgs, a.nsidechgs - b.nsidechgs, - a.ncoefchgs - b.ncoefchgs, a.nrounds - b.nrounds, - a.ndeletedcols - b.ndeletedcols, a.ndeletedrows - b.ndeletedrows }; -} - -} // namespace papilo - -#endif \ No newline at end of file diff --git a/headers/papilo/core/VariableDomains.hpp b/headers/papilo/core/VariableDomains.hpp deleted file mode 100644 index 1aa2e49..0000000 --- a/headers/papilo/core/VariableDomains.hpp +++ /dev/null @@ -1,135 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* */ -/* This file is part of the program and library */ -/* PaPILO --- Parallel Presolve for Integer and Linear Optimization */ -/* */ -/* Copyright (C) 2020-2022 Konrad-Zuse-Zentrum */ -/* fuer Informationstechnik Berlin */ -/* */ -/* This program is free software: you can redistribute it and/or modify */ -/* it under the terms of the GNU Lesser General Public License as published */ -/* by the Free Software Foundation, either version 3 of the License, or */ -/* (at your option) any later version. */ -/* */ -/* This program is distributed in the hope that it will be useful, */ -/* but WITHOUT ANY WARRANTY; without even the implied warranty of */ -/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ -/* GNU Lesser General Public License for more details. */ -/* */ -/* You should have received a copy of the GNU Lesser General Public License */ -/* along with this program. If not, see . */ -/* */ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -#ifndef _PAPILO_CORE_VARIABLE_DOMAINS_HPP_ -#define _PAPILO_CORE_VARIABLE_DOMAINS_HPP_ - -#include "papilo/misc/Flags.hpp" -#include "papilo/misc/MultiPrecision.hpp" -#include "papilo/misc/Vec.hpp" -#include "papilo/misc/compress_vector.hpp" -#ifdef PAPILO_TBB -#include "papilo/misc/tbb.hpp" -#endif - -namespace papilo -{ - -enum class ColFlag : uint8_t -{ - kNone = 0, - kLbInf = 1 << 0, - kLbHuge = 1 << 1, - kUbInf = 1 << 2, - kUbHuge = 1 << 3, - kIntegral = 1 << 4, - kFixed = 1 << 5, - kSubstituted = 1 << 6, - kImplInt = 1 << 7, - kUnbounded = static_cast( ColFlag::kLbInf ) | - static_cast( ColFlag::kUbInf ), - kInactive = static_cast( ColFlag::kFixed ) | - static_cast( ColFlag::kSubstituted ), - kLbUseless = static_cast( ColFlag::kLbInf ) | - static_cast( ColFlag::kLbHuge ), - kUbUseless = static_cast( ColFlag::kUbInf ) | - static_cast( ColFlag::kUbHuge ), -}; - -using ColFlags = Flags; - -/// Type to store the domains for the variables in a problem. -/// This includes the lower and upper bounds, and whether the -/// variable is constraint to integral values. -template -struct VariableDomains -{ - Vec lower_bounds; - Vec upper_bounds; - Vec flags; - - void - compress( const Vec& colmapping, bool full = false ); - - bool - isBinary( int col ) const - { - return flags[col].test( ColFlag::kIntegral ) && - !flags[col].test( ColFlag::kLbUseless, ColFlag::kUbUseless, - ColFlag::kInactive ) && - lower_bounds[col] == 0 && upper_bounds[col] == 1; - } - - template - void - serialize( Archive& ar, const unsigned int version ) - { - ar& lower_bounds; - ar& upper_bounds; - ar& flags; - } -}; - -#ifdef PAPILO_USE_EXTERN_TEMPLATES -extern template struct VariableDomains; -extern template struct VariableDomains; -extern template struct VariableDomains; -#endif - -template -void -VariableDomains::compress( const Vec& colmapping, bool full ) -{ -#ifdef PAPILO_TBB - tbb::parallel_invoke( - [this, &colmapping, full]() { - compress_vector( colmapping, lower_bounds ); - if( full ) - lower_bounds.shrink_to_fit(); - }, - [this, &colmapping, full]() { - compress_vector( colmapping, upper_bounds ); - if( full ) - upper_bounds.shrink_to_fit(); - }, - [this, &colmapping, full]() { - compress_vector( colmapping, flags ); - if( full ) - flags.shrink_to_fit(); - } ); -#else - compress_vector( colmapping, lower_bounds ); - compress_vector( colmapping, upper_bounds ); - compress_vector( colmapping, flags ); - if( full ) - { - flags.shrink_to_fit(); - upper_bounds.shrink_to_fit(); - lower_bounds.shrink_to_fit(); - } - -#endif -} -} // namespace papilo - -#endif diff --git a/headers/papilo/core/postsolve/BoundStorage.hpp b/headers/papilo/core/postsolve/BoundStorage.hpp deleted file mode 100644 index 462467a..0000000 --- a/headers/papilo/core/postsolve/BoundStorage.hpp +++ /dev/null @@ -1,148 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* */ -/* This file is part of the program and library */ -/* PaPILO --- Parallel Presolve for Integer and Linear Optimization */ -/* */ -/* Copyright (C) 2020-2022 Konrad-Zuse-Zentrum */ -/* fuer Informationstechnik Berlin */ -/* */ -/* This program is free software: you can redistribute it and/or modify */ -/* it under the terms of the GNU Lesser General Public License as published */ -/* by the Free Software Foundation, either version 3 of the License, or */ -/* (at your option) any later version. */ -/* */ -/* This program is distributed in the hope that it will be useful, */ -/* but WITHOUT ANY WARRANTY; without even the implied warranty of */ -/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ -/* GNU Lesser General Public License for more details. */ -/* */ -/* You should have received a copy of the GNU Lesser General Public License */ -/* along with this program. If not, see . */ -/* */ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -#ifndef _PAPILO_CORE_STORED_HPP_ -#define _PAPILO_CORE_STORED_HPP_ - -#include "papilo/misc/Num.hpp" -#include "papilo/core/Problem.hpp" - -namespace papilo -{ - -template -class BoundStorage -{ - private: - Num num; - Vec col_cost; - Vec row_lhs; - Vec row_rhs; - Vec row_infinity_lhs; - Vec row_infinity_rhs; - - public: - Vec col_infinity_lower; - Vec col_infinity_upper; - Vec col_lower; - Vec col_upper; - - public: - BoundStorage( const Num& n, int cols, int rows, bool is_primal_dual ) - { - if( ! is_primal_dual ) - return; - num = n; - col_cost.assign( cols, 0 ); - col_lower.assign( cols, 0 ); - col_upper.assign( cols, 0 ); - row_lhs.assign( rows, 0 ); - row_rhs.assign( rows, 0 ); - col_infinity_upper.assign( cols, 1 ); - col_infinity_lower.assign( cols, 1 ); - row_infinity_rhs.assign( rows, 1 ); - row_infinity_lhs.assign( rows, 1 ); - } - - void - set_bounds_of_variable( int col, bool lb_inf, bool ub_inf, REAL lb, REAL ub ) - { - assert( lb_inf || ub_inf || lb <= ub ); - col_lower[col] = lb; - col_upper[col] = ub; - col_infinity_lower[col] = lb_inf; - col_infinity_upper[col] = ub_inf; - } - - void - set_bound_of_variable( int col, bool is_lower, bool inf, REAL value ) - { - if( is_lower ) - { - col_lower[col] = value; - col_infinity_lower[col] = inf; - } - else - { - col_upper[col] = value; - col_infinity_upper[col] = inf; - } - } - - bool - is_lower_and_upper_bound_infinity( int col ) - { - return col_infinity_lower[col] && col_infinity_upper[col]; - } - - void - set_bounds_of_row( int row, bool lhs_inf, bool rhs_inf, REAL lhs, REAL rhs ) - { - assert( rhs_inf || lhs_inf || lhs <= rhs ); - row_lhs[row] = lhs; - row_rhs[row] = rhs; - row_infinity_lhs[row] = rhs_inf; - row_infinity_rhs[row] = lhs_inf; - } - - bool - is_on_upper_bound( int col, REAL value ) - { - return ! col_infinity_upper[col] && num.isEq( value, col_upper[col] ); - } - - bool - is_on_lower_bound( int col, REAL value ) - { - return ! col_infinity_lower[col] && num.isEq( value, col_lower[col] ); - } - - bool - check_bounds( const Problem& problem ) - { - const Vec& colFlags = problem.getColFlags(); - const Vec& lowerBounds = problem.getLowerBounds(); - const Vec& upperBounds = problem.getUpperBounds(); - - for( int i = 0; i < problem.getNCols(); i++ ) - { - if( colFlags[i].test( ColFlag::kInactive ) ) - continue; - if( col_infinity_lower[i] != colFlags[i].test( ColFlag::kLbInf ) ) - return false; - if( col_infinity_upper[i] != colFlags[i].test( ColFlag::kUbInf ) ) - return false; - if( !num.isEq( col_upper[i], upperBounds[i] ) && - !colFlags[i].test( ColFlag::kUbInf ) ) - return false; - if( !num.isEq( col_lower[i], lowerBounds[i] ) && - !colFlags[i].test( ColFlag::kLbInf ) ) - return false; - } - return true; - } -}; - -} // namespace papilo - -#endif diff --git a/headers/papilo/core/postsolve/Postsolve.hpp b/headers/papilo/core/postsolve/Postsolve.hpp deleted file mode 100644 index e8962cd..0000000 --- a/headers/papilo/core/postsolve/Postsolve.hpp +++ /dev/null @@ -1,1526 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* */ -/* This file is part of the program and library */ -/* PaPILO --- Parallel Presolve for Integer and Linear Optimization */ -/* */ -/* Copyright (C) 2020-2022 Konrad-Zuse-Zentrum */ -/* fuer Informationstechnik Berlin */ -/* */ -/* This program is free software: you can redistribute it and/or modify */ -/* it under the terms of the GNU Lesser General Public License as published */ -/* by the Free Software Foundation, either version 3 of the License, or */ -/* (at your option) any later version. */ -/* */ -/* This program is distributed in the hope that it will be useful, */ -/* but WITHOUT ANY WARRANTY; without even the implied warranty of */ -/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ -/* GNU Lesser General Public License for more details. */ -/* */ -/* You should have received a copy of the GNU Lesser General Public License */ -/* along with this program. If not, see . */ -/* */ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -#ifndef _PAPILO_CORE_POSTSOLVE_SERVICE_HPP_ -#define _PAPILO_CORE_POSTSOLVE_SERVICE_HPP_ - -#include "SavedRow.hpp" -#include "papilo/core/Problem.hpp" -#include "papilo/core/ProblemUpdate.hpp" -#include "papilo/core/postsolve/BoundStorage.hpp" -#include "papilo/core/postsolve/PostsolveStatus.hpp" -#include "papilo/core/postsolve/PostsolveStorage.hpp" -#include "papilo/core/postsolve/PostsolveType.hpp" -#include "papilo/core/postsolve/ReductionType.hpp" -#include "papilo/misc/MultiPrecision.hpp" -#include "papilo/misc/Num.hpp" -#include "papilo/misc/PrimalDualSolValidation.hpp" -#include "papilo/misc/StableSum.hpp" -#include "papilo/misc/Vec.hpp" -#include "papilo/misc/compress_vector.hpp" -#include "papilo/misc/fmt.hpp" -#ifdef PAPILO_TBB -#include "papilo/misc/tbb.hpp" -#endif - -#include - -#include -#include -#include -#include -#include -#include -#include - -namespace papilo -{ - -template -class Postsolve -{ - private: - Message message; - Num num; - - static constexpr int IS_INTEGRAL = static_cast( ColFlag::kIntegral ); - static constexpr int IS_LBINF = static_cast( ColFlag::kLbInf ); - static constexpr int IS_UBINF = static_cast( ColFlag::kUbInf ); - - public: - Postsolve( const Message msg, const Num n ) - { - message = msg; - num = n; - }; - - PostsolveStatus - undo( const Solution& reducedSolution, - Solution& originalSolution, - PostsolveStorage postsolveStorage, bool is_optimal = true ) const; - - private: - REAL - calculate_row_value_for_fixed_infinity_variable( - REAL lhs, REAL rhs, int rowLength, int column, const int* row_indices, - const REAL* coefficients, Vec& current_solution, bool is_negative, - REAL& coeff_of_column_in_row ) const; - - Problem - recalculate_current_problem_from_the_original_problem( - const PostsolveStorage& listener, int current_index ) const; - - void - copy_from_reduced_to_original( - const Solution& reducedSolution, Solution& originalSolution, - const PostsolveStorage& postsolveStorage ) const; - - void - apply_fix_var_in_original_solution( Solution& originalSolution, - const Vec& indices, - const Vec& values, - int current_index ) const; - - int - apply_fix_infinity_variable_in_original_solution( - Solution& originalSolution, Vec& indices, Vec& values, - int first, const Problem& problem, - BoundStorage& stored_bounds ) const; - - void - apply_var_bound_change_forced_by_column_in_original_solution( - Solution& originalSolution, const Vec& types, - const Vec& start, const Vec& indices, const Vec& values, - int i, int first, BoundStorage& stored_bounds, bool is_optimal ) const; - - void - apply_parallel_col_to_original_solution( Solution& originalSolution, - const Vec& indices, - const Vec& values, int first, - int last, - BoundStorage& stored ) const; - - void - apply_row_bound_change_to_original_solution( - Solution& originalSolution, const Vec& types, - const Vec& start, const Vec& indices, const Vec& values, - int i, int first ) const; - - void - apply_substituted_column_to_original_solution( - Solution& originalSolution, const Vec& indices, - const Vec& values, int first, int last, - BoundStorage& stored, bool is_optimal ) const; - - VarBasisStatus - calculate_basis( int flags, REAL lb, REAL ub, REAL solution, - bool is_on_bounds ) const; - - bool - are_the_next_n_types_redundant_rows( const Vec& types, int i, - int redundant_rows ) const; - void - remove_row_from_basis( Solution& originalSolution, - const Vec& types, - const Vec& start, const Vec& indices, - const Vec& values, int i, - BoundStorage& stored_bounds, - bool is_optimal ) const; - - VarBasisStatus - get_var_basis_status( BoundStorage& stored_bounds, int col, - REAL val ) const; - - bool - is_variable_on_lower_bound( bool lb_infinity, REAL lb, - REAL primal_solution ) const; - - bool - is_variable_on_upper_bound( bool ub_infinity, REAL ub, - REAL primal_solution ) const; - - bool - skip_if_row_bound_belongs_to_substitution( const Vec& types, - const Vec& start, - const Vec& indices, - const Vec& values, int i, - int row ) const; -}; - -#ifdef PAPILO_USE_EXTERN_TEMPLATES -extern template class Postsolve; -extern template class Postsolve; -extern template class Postsolve; -#endif - -template -PostsolveStatus -Postsolve::undo( const Solution& reducedSolution, - Solution& originalSolution, - PostsolveStorage postsolveStorage, bool is_optimal ) const -{ - - PrimalDualSolValidation validation{message, num}; - - copy_from_reduced_to_original( reducedSolution, originalSolution, - postsolveStorage ); - - auto types = postsolveStorage.types; - auto start = postsolveStorage.start; - auto indices = postsolveStorage.indices; - auto values = postsolveStorage.values; - auto origcol_mapping = postsolveStorage.origcol_mapping; - auto origrow_mapping = postsolveStorage.origrow_mapping; - auto problem = postsolveStorage.problem; - - // Will be used during dual postsolve for fast access to bound values. - // TODO: rows bounds are currently not updated during - BoundStorage stored_bounds{ num, (int)postsolveStorage.nColsOriginal, - (int)postsolveStorage.nRowsOriginal, - originalSolution.type == - SolutionType::kPrimalDual }; - - for( int i = (int) postsolveStorage.types.size() - 1; i >= 0; --i ) - { - auto type = types[i]; - int first = start[i]; - int last = start[i + 1]; - - //check which type is done: - // - calculate the primal solution - //only in primal-dual mode: - // - update stored variable bound - // - calculate dual, reduced and basis (optional) - switch( type ) - { - case ReductionType::kColumnDualValue: - assert( originalSolution.type == SolutionType::kPrimalDual ); - originalSolution.reducedCosts[postsolveStorage.indices[first]] = - postsolveStorage.values[postsolveStorage.indices[first]]; - break; - case ReductionType::kRowDualValue: - assert( originalSolution.type == SolutionType::kPrimalDual ); - originalSolution.dual[postsolveStorage.indices[first]] = - postsolveStorage.values[postsolveStorage.indices[first]]; - break; - case ReductionType::kFixedCol: - { - apply_fix_var_in_original_solution( originalSolution, indices, values, - first ); - if( SolutionType::kPrimalDual == originalSolution.type ) - stored_bounds.set_bounds_of_variable( - indices[first], false, false, values[first], values[first] ); - break; - } - case ReductionType::kFixedInfCol: - { - int redundant_rows = apply_fix_infinity_variable_in_original_solution( - originalSolution, indices, values, first, problem, stored_bounds ); - // skip redundant rows because basis for those are already set and - // should not be overwritten - if( originalSolution.type == SolutionType::kPrimalDual ) - { - assert( are_the_next_n_types_redundant_rows( types, i, - redundant_rows ) ); - i -= redundant_rows; - assert( i >= 0 ); - } - break; - } - case ReductionType::kVarBoundChange: - { - assert( originalSolution.type == SolutionType::kPrimalDual ); - apply_var_bound_change_forced_by_column_in_original_solution( - originalSolution, types, start, indices, values, i, first, - stored_bounds, is_optimal ); - - break; - } - case ReductionType::kSubstitutedCol: - { - int col = indices[first]; - REAL side = values[first]; - REAL colCoef = 0.0; - StableSum sumcols; - for( int j = first + 1; j < last; ++j ) - { - if( indices[j] == col ) - colCoef = values[j]; - else - sumcols.add( originalSolution.primal[indices[j]] * values[j] ); - } - sumcols.add( -side ); - - assert( colCoef != 0.0 ); - originalSolution.primal[col] = ( -sumcols.get() ) / colCoef; - break; - } - case ReductionType::kSubstitutedColWithDual: - apply_substituted_column_to_original_solution( - originalSolution, indices, values, first, last, stored_bounds, is_optimal ); - break; - case ReductionType::kParallelCol: - apply_parallel_col_to_original_solution( - originalSolution, indices, values, first, last, stored_bounds ); - break; - case ReductionType::kRowBoundChangeForcedByRow: - assert( originalSolution.type == SolutionType::kPrimalDual ); - apply_row_bound_change_to_original_solution( - originalSolution, types, start, indices, values, i, first ); - break; - case ReductionType::kRowBoundChange: - { - assert( originalSolution.type == SolutionType::kPrimalDual ); - - bool isLhs = indices[first] == 1; - int row = (int)values[first]; - // bool is_infinity = indices[first + 1] ==1; - // bool was_infinity = indices[first + 2] ==1; - // REAL new_value = values[first + 1]; - // REAL old_value = values[first + 2]; - - // if a row bound change happened because of a substitution skip the - // verification for this step - if(skip_if_row_bound_belongs_to_substitution( types, start, indices, - values, i, row )) - continue; - - if(originalSolution.basisAvailabe) - { - // TODO: setting the bound to infinity might turn the a ZERO - switch( originalSolution.rowBasisStatus[row] ) - { - case VarBasisStatus::FIXED: - if( isLhs ) - originalSolution.rowBasisStatus[row] = - VarBasisStatus::ON_UPPER; - else - originalSolution.rowBasisStatus[row] = - VarBasisStatus::ON_LOWER; - break; - case VarBasisStatus::ON_LOWER: - if( isLhs ) - originalSolution.rowBasisStatus[row] = VarBasisStatus::BASIC; - break; - case VarBasisStatus::ON_UPPER: - if( ! isLhs ) - originalSolution.rowBasisStatus[row] = VarBasisStatus::BASIC; - break; - case VarBasisStatus::ZERO: - case VarBasisStatus::BASIC: - break; - case VarBasisStatus::UNDEFINED: - assert( false ); - break; - } - } - - break; - } - case ReductionType::kReducedBoundsCost: - { - assert( originalSolution.type == SolutionType::kPrimalDual ); - - // get column bounds - for( unsigned int j = 0; j < postsolveStorage.origcol_mapping.size(); j++ ) - { - int origCol = postsolveStorage.origcol_mapping[j]; - int index = first + 2 * j; - stored_bounds.set_bounds_of_variable( - origCol, postsolveStorage.indices[index] == 1, - postsolveStorage.indices[index + 1] == 1, - postsolveStorage.values[index], - postsolveStorage.values[index + 1] ); - } - - // get row bounds - int first_row_bounds = - first + 2 * postsolveStorage.origcol_mapping.size(); - for( unsigned int k = 0; k < postsolveStorage.origrow_mapping.size(); k++ ) - { - int origRow = postsolveStorage.origrow_mapping[k]; - int index = first_row_bounds + 2 * k; - stored_bounds.set_bounds_of_row( - origRow, postsolveStorage.indices[index] == 1, - postsolveStorage.indices[index + 1] == 1, - postsolveStorage.values[index], - postsolveStorage.values[index + 1] ); - } - - break; - } - case ReductionType::kCoefficientChange: - { - // if a row bound change happened because of a substitution skip the - // verification for this step - if( i >= 1 && types[i - 1] == ReductionType::kSubstitutedColWithDual ) - continue; - break; - } - case ReductionType::kRedundantRow: - assert( originalSolution.type == SolutionType::kPrimalDual ); - if( originalSolution.basisAvailabe ) - originalSolution.rowBasisStatus[indices[first]] = - VarBasisStatus::BASIC; - if( types[i - 1] == ReductionType::kSubstitutedColWithDual ) - continue; - break; - // the remaining Types are used as additional information for other - // types and therefore have no own case - case ReductionType::kReasonForRowBoundChangeForcedByRow: - case ReductionType::kSaveRow: - assert( originalSolution.type == SolutionType::kPrimalDual ); - break; - } - -#ifndef NDEBUG - if( postsolveStorage.presolveOptions - .validation_after_every_postsolving_step ) - { - Problem problem_at_step_i = - recalculate_current_problem_from_the_original_problem( - postsolveStorage, i ); - message.info( "Validation of partial ({}) reconstr. sol : ", i ); - validation.verifySolutionAndUpdateSlack( originalSolution, - problem_at_step_i ); - assert( !( postsolveStorage.types.size() - 1 >= 0 && - types[postsolveStorage.types.size() - 1] == - ReductionType::kReducedBoundsCost ) || - stored_bounds.check_bounds( problem_at_step_i ) ); - } -#endif - } - - PostsolveStatus status = - validation.verifySolutionAndUpdateSlack( originalSolution, problem ); - - assert( !( !postsolveStorage.types.empty() && - types[postsolveStorage.types.size() - 1] == - ReductionType::kReducedBoundsCost ) || - stored_bounds.check_bounds( problem ) ); - if( status == PostsolveStatus::kFailed ) - message.error( "Postsolving solution failed. Please use debug mode to " - "obtain more information." ); - - return status; -} - -template -bool -Postsolve::skip_if_row_bound_belongs_to_substitution( - const Vec& types, const Vec& start, - const Vec& indices, const Vec& values, int i, int row ) const -{ - if( i >= 2 && types[i - 1] == ReductionType::kCoefficientChange && - types[i - 2] == ReductionType::kSubstitutedColWithDual ) - { - int row_of_coefficient_change = indices[start[i - 1]]; - int row_of_substitution = indices[start[i - 2]]; - if( row == row_of_coefficient_change && row_of_substitution == row ) - return true; - } - if( i >= 3 && types[i - 2] == ReductionType::kCoefficientChange && - types[i - 3] == ReductionType::kSubstitutedColWithDual ) - { - int row_of_row_bound_change = (int) values[start[i - 1]]; - int row_of_coefficient_change = indices[start[i - 2]]; - int row_of_substitution = indices[start[i - 3]]; - if( row_of_coefficient_change == row && row_of_substitution == row && - row == row_of_row_bound_change ) - return true; - } - return false; -} - -template -void -Postsolve::copy_from_reduced_to_original( - const Solution& reducedSolution, Solution& originalSolution, - const PostsolveStorage& postsolveStorage ) const -{ - if( reducedSolution.type == SolutionType::kPrimalDual ) - originalSolution.type = SolutionType::kPrimalDual; - - originalSolution.primal.clear(); - originalSolution.primal.resize( postsolveStorage.nColsOriginal ); - - int reduced_columns = (int)reducedSolution.primal.size(); - for( int k = 0; k < reduced_columns; ++k ) - originalSolution.primal[postsolveStorage.origcol_mapping[k]] = - reducedSolution.primal[k]; - - if( originalSolution.type == SolutionType::kPrimalDual ) - { - originalSolution.basisAvailabe = - reducedSolution.basisAvailabe && - postsolveStorage.problem.getNumIntegralCols() == 0 && - postsolveStorage.presolveOptions.calculate_basis_for_dual; - int reduced_rows = (int)reducedSolution.dual.size(); - - assert( (int) reducedSolution.dual.size() == reduced_rows ); - originalSolution.dual.clear(); - originalSolution.dual.resize( postsolveStorage.nRowsOriginal ); - for( int k = 0; k < reduced_rows; k++ ) - originalSolution.dual[postsolveStorage.origrow_mapping[k]] = - reducedSolution.dual[k]; - - assert( (int) reducedSolution.reducedCosts.size() == reduced_columns ); - originalSolution.reducedCosts.clear(); - originalSolution.reducedCosts.resize( postsolveStorage.nColsOriginal ); - for( int k = 0; k < reduced_columns; k++ ) - originalSolution.reducedCosts[postsolveStorage.origcol_mapping[k]] = - reducedSolution.reducedCosts[k]; - - assert( (int) reducedSolution.varBasisStatus.size() == reduced_columns ); - originalSolution.varBasisStatus.clear(); - originalSolution.varBasisStatus.resize( postsolveStorage.nColsOriginal, - VarBasisStatus::UNDEFINED ); - for( int k = 0; k < reduced_columns; k++ ) - originalSolution.varBasisStatus[postsolveStorage.origcol_mapping[k]] = - reducedSolution.varBasisStatus[k]; - - assert( (int) reducedSolution.rowBasisStatus.size() == reduced_rows ); - - originalSolution.rowBasisStatus.clear(); - originalSolution.rowBasisStatus.resize( postsolveStorage.nRowsOriginal, - VarBasisStatus::UNDEFINED ); - for( int k = 0; k < reduced_rows; k++ ) - originalSolution.rowBasisStatus[postsolveStorage.origrow_mapping[k]] = - reducedSolution.rowBasisStatus[k]; - } -} - -template -void -Postsolve::apply_fix_var_in_original_solution( - Solution& originalSolution, const Vec& indices, - const Vec& values, int current_index ) const -{ - // fix variable in the primal solution - int col = indices[current_index]; - originalSolution.primal[col] = values[current_index]; - - if( originalSolution.type == SolutionType::kPrimalDual ) - { - // calculate the reduced costs in the dual z_j = c_j - sum_i a_ij*y_i - REAL objective_coefficient = values[current_index + 1]; - - int col_length = indices[current_index + 1]; - StableSum stablesum; - stablesum.add( objective_coefficient ); - for( int k = 0; k < col_length; ++k ) - { - int index = current_index + 2 + k; - int row = indices[index]; - REAL coeff = values[index]; - stablesum.add( -coeff * originalSolution.dual[row] ); - } - originalSolution.reducedCosts[col] = stablesum.get(); - - // mark the variable as fixed in the basis - if( originalSolution.basisAvailabe ) - originalSolution.varBasisStatus[col] = VarBasisStatus::FIXED; - } -} - -template -int -Postsolve::apply_fix_infinity_variable_in_original_solution( - Solution& originalSolution, Vec& indices, Vec& values, - int first, const Problem& problem, - BoundStorage& stored_bounds ) const -{ - // calculate the feasible (minimal) value for the infinity variable - int col = indices[first]; - REAL bound = values[first + 1]; - int number_rows = indices[first + 1]; - REAL solution = bound; - int row_counter = 0; - int current_counter = first + 2; - - bool isNegativeInfinity = values[first] < 0; - int* row_indices = new int[number_rows]; - REAL* col_coefficents = new REAL[number_rows]; - if( isNegativeInfinity ) - { - while( row_counter < number_rows ) - { - int length = (int)values[current_counter]; - row_indices[row_counter] = indices[current_counter]; - - REAL lhs = values[current_counter + 1]; - REAL rhs = values[current_counter + 2]; - const REAL* coefficients = &values[current_counter + 3]; - const int* col_indices = &indices[current_counter + 3]; - - REAL newValue = calculate_row_value_for_fixed_infinity_variable( - lhs, rhs, length, col, col_indices, coefficients, - originalSolution.primal, true, col_coefficents[row_counter] ); - if( num.isLT( newValue, solution ) ) - { - if( originalSolution.basisAvailabe ) - { - if( num.isGT( col_coefficents[row_counter], 0 ) ) - originalSolution.rowBasisStatus[row_indices[row_counter]] = - VarBasisStatus::ON_UPPER; - else - originalSolution.rowBasisStatus[row_indices[row_counter]] = - VarBasisStatus::ON_LOWER; - } - solution = newValue; - } - else if( originalSolution.basisAvailabe ) - originalSolution.rowBasisStatus[row_indices[row_counter]] = - VarBasisStatus::BASIC; - - current_counter += 3 + length; - row_counter++; - } - if( problem.getColFlags()[col].test( ColFlag::kIntegral ) ) - solution = num.epsFloor( solution ); - originalSolution.primal[col] = solution; - } - else - { - while( row_counter < number_rows ) - { - int length = (int)values[current_counter]; - row_indices[row_counter] = indices[current_counter]; - - REAL lhs = values[current_counter + 1]; - REAL rhs = values[current_counter + 2]; - - const REAL* coefficients = &values[current_counter + 3]; - const int* col_indices = &indices[current_counter + 3]; - - REAL newValue = calculate_row_value_for_fixed_infinity_variable( - lhs, rhs, length, col, col_indices, coefficients, - originalSolution.primal, false, col_coefficents[row_counter] ); - if( num.isGT( newValue, solution ) ) - { - if( originalSolution.basisAvailabe ) - { - if( num.isGT( col_coefficents[row_counter], 0 ) ) - originalSolution.rowBasisStatus[row_indices[row_counter]] = - VarBasisStatus::ON_LOWER; - else - originalSolution.rowBasisStatus[row_indices[row_counter]] = - VarBasisStatus::ON_UPPER; - } - solution = newValue; - } - else if( originalSolution.basisAvailabe ) - originalSolution.rowBasisStatus[row_indices[row_counter]] = - VarBasisStatus::BASIC; - - current_counter += 3 + length; - row_counter++; - } - if( problem.getColFlags()[col].test( ColFlag::kIntegral ) ) - solution = num.epsCeil( solution ); - originalSolution.primal[col] = solution; - } - - if( originalSolution.type == SolutionType::kPrimalDual ) - { - // calculate the reduced costs (analogous for the case FIXED) - StableSum sum; - // objective is zero as condition for this presolve result - for( int k = 0; k < number_rows; ++k ) - sum.add( -col_coefficents[k] * originalSolution.dual[row_indices[k]] ); - originalSolution.reducedCosts[col] = sum.get(); - - // store the bounds of the variable - if( isNegativeInfinity ) - stored_bounds.set_bounds_of_variable( col, true, false, 0, bound ); - else - stored_bounds.set_bounds_of_variable( col, false, true, bound, 0 ); - - // set the basis depending on the status - if( originalSolution.basisAvailabe ) - { - if( num.isEq( solution, bound ) ) - if( isNegativeInfinity ) - originalSolution.varBasisStatus[col] = VarBasisStatus::ON_UPPER; - else - originalSolution.varBasisStatus[col] = VarBasisStatus::ON_LOWER; - else - originalSolution.varBasisStatus[col] = VarBasisStatus::BASIC; - } - } - return number_rows; -} - -template -void -Postsolve::apply_substituted_column_to_original_solution( - Solution& originalSolution, const Vec& indices, - const Vec& values, int first, int last, - BoundStorage& stored, bool is_optimal ) const -{ - int row = indices[first]; - int row_length = (int)values[first]; - assert( indices[first + 1] == 0 ); - REAL lhs = values[first + 1]; - assert( lhs == values[first + 2] ); - assert( indices[first + 2] == 0 ); - int col = indices[first + 3 + row_length]; - - // calculate the primal solution by solving the stored equation - REAL colCoef = 0.0; - StableSum sumcols; - for( int j = first + 3; j < first + 3 + row_length; ++j ) - { - if( indices[j] == col ) - colCoef = values[j]; - else - sumcols.add( originalSolution.primal[indices[j]] * values[j] ); - } - sumcols.add( -lhs ); - assert( colCoef != 0.0 ); - originalSolution.primal[col] = ( -sumcols.get() ) / colCoef; - - assert( ( originalSolution.type == SolutionType::kPrimalDual && - values[first + 3 + row_length] > 0 ) || - ( originalSolution.type != SolutionType::kPrimalDual && - values[first + 3 + row_length] == 0 ) ); - if( originalSolution.type == SolutionType::kPrimalDual ) - { - -// int col_length = (int)values[first + 3 + row_length]; - assert( indices[first + 4 + row_length] == 0 ); - REAL obj = values[first + 4 + row_length]; - - bool ub_infinity = indices[first + 5 + row_length] == 1; - REAL ub = values[first + 5 + row_length]; - bool lb_infinity = indices[first + 6 + row_length] == 1; - REAL lb = values[first + 6 + row_length]; - assert( lb_infinity || ub_infinity || num.isGE( ub, lb ) ); - - // update the stored variable bounds - stored.set_bound_of_variable( col, true, lb_infinity, lb ); - stored.set_bound_of_variable( col, false, ub_infinity, ub ); - - // calculate the dual solution - bool variableOnLowerBound = is_variable_on_lower_bound( - lb_infinity, lb, originalSolution.primal[col] ); - bool variableOnUpperBound = is_variable_on_upper_bound( - ub_infinity, ub, originalSolution.primal[col] ); - - if( variableOnLowerBound || variableOnUpperBound ) - { - // since the variable is not at its bounds calculate the reduced costs - // and update the dual solution - originalSolution.dual[row] += obj / colCoef; - - StableSum sum_dual; - for( int j = first + 7 + row_length; j < last; ++j ) - sum_dual.add( -originalSolution.dual[indices[j]] * values[j] ); - sum_dual.add( obj ); - - originalSolution.reducedCosts[col] = ( sum_dual.get() ); - assert( variableOnLowerBound || variableOnUpperBound ); - - // set the basis of the variable - if( originalSolution.basisAvailabe ) - { - if( originalSolution.rowBasisStatus[row] == - VarBasisStatus::BASIC && - ! num.isFeasZero( originalSolution.dual[row] ) ) - { - assert( num.isFeasZero( originalSolution.reducedCosts[col] ) ); - originalSolution.varBasisStatus[col] = VarBasisStatus::BASIC; - originalSolution.rowBasisStatus[row] = VarBasisStatus::FIXED; - } - else - { - // set the variable on its bounds - if( variableOnLowerBound && variableOnUpperBound ) - originalSolution.varBasisStatus[col] = VarBasisStatus::FIXED; - else if( variableOnLowerBound ) - originalSolution.varBasisStatus[col] = - VarBasisStatus::ON_LOWER; - else if( variableOnUpperBound ) - originalSolution.varBasisStatus[col] = - VarBasisStatus::ON_UPPER; - else if( lb_infinity && ub_infinity && - num.isZero( originalSolution.primal[col] ) ) - originalSolution.varBasisStatus[col] = - VarBasisStatus::ZERO; - } - } - } - else - { - // since variable is not at its bounds the reduced costs are 0 and - // calculate the dual variable - originalSolution.reducedCosts[col] = 0; - - REAL rowCoef = 0.0; - StableSum sum_dual; - for( int j = first + 7 + row_length; j < last; ++j ) - { - if( indices[j] == row ) - rowCoef = values[j]; - else - sum_dual.add( -originalSolution.dual[indices[j]] * values[j] ); - } - - assert( rowCoef != 0 ); - assert( num.isZero( originalSolution.dual[row] ) || !is_optimal ); - assert( ! variableOnLowerBound && ! variableOnUpperBound ); - sum_dual.add( obj ); - originalSolution.dual[row] = sum_dual.get() / rowCoef; - - if( originalSolution.basisAvailabe ) - { - assert( originalSolution.rowBasisStatus[row] == - VarBasisStatus::BASIC ); - originalSolution.varBasisStatus[col] = VarBasisStatus::BASIC; - originalSolution.rowBasisStatus[row] = VarBasisStatus::FIXED; - } - } - assert( row_length + (int)values[first + 3 + row_length] + 7 == - last - first ); - } -} - -template -bool -Postsolve::is_variable_on_upper_bound( bool ub_infinity, REAL ub, - REAL primal_solution ) const -{ - return num.isFeasEq( primal_solution, ub ) && ! ub_infinity; -} - -template -bool -Postsolve::is_variable_on_lower_bound( bool lb_infinity, REAL lb, - REAL primal_solution ) const -{ - return ( num.isFeasEq( primal_solution, lb ) && ! lb_infinity ); -} - -template -void -Postsolve::apply_row_bound_change_to_original_solution( - Solution& originalSolution, const Vec& types, - const Vec& start, const Vec& indices, const Vec& values, - int i, int first ) const -{ - bool isLhs = indices[first] == 1; - int row = (int)values[first]; - // REAL new_value = values[first + 1]; - // bool is_infinity = indices[first + 1] == 1; - // REAL old_value = values[first + 2]; - // bool was_infinity = indices[first + 2] == 1; - - int next_type = i - 1; - int start_reason = start[next_type]; - assert( types[next_type] == - ReductionType::kReasonForRowBoundChangeForcedByRow ); - int deleted_row = indices[start_reason + 1]; - REAL factor = values[start_reason]; - assert( row == indices[start_reason] ); - REAL dual_row_value = originalSolution.dual[row]; - if( ( isLhs && num.isGT(dual_row_value, 0) ) || - ( ! isLhs && num.isLT(dual_row_value, 0) ) ) - { - originalSolution.dual[deleted_row] = dual_row_value * factor; - originalSolution.dual[row] = 0; - if( originalSolution.basisAvailabe ) - { - assert( originalSolution.rowBasisStatus[deleted_row] == - VarBasisStatus::BASIC ); - if( originalSolution.rowBasisStatus[row] == VarBasisStatus::FIXED ) - { - if( isLhs ) - { - if( num.isLT( factor, 0 ) ) - originalSolution.rowBasisStatus[deleted_row] = - VarBasisStatus::ON_UPPER; - else - originalSolution.rowBasisStatus[deleted_row] = - VarBasisStatus::ON_LOWER; - originalSolution.rowBasisStatus[row] = VarBasisStatus::BASIC; - } - else - { - if( num.isLT( factor, 0 ) ) - originalSolution.rowBasisStatus[deleted_row] = - VarBasisStatus::ON_LOWER; - else - originalSolution.rowBasisStatus[deleted_row] = - VarBasisStatus::ON_UPPER; - originalSolution.rowBasisStatus[row] = VarBasisStatus::BASIC; - } - } - else - { - //consider case that the rhs/lhs are both passed to new constraint and rhs == lhs - //then the lhs is first transformed and then the rhs - if( !isLhs && - originalSolution.rowBasisStatus[deleted_row] != - VarBasisStatus::UNDEFINED && - originalSolution.rowBasisStatus[row] == VarBasisStatus::BASIC ) - { - originalSolution.rowBasisStatus[deleted_row] = - VarBasisStatus::FIXED; - } - else - { - originalSolution.rowBasisStatus[deleted_row] = - originalSolution.rowBasisStatus[row]; - originalSolution.rowBasisStatus[row] = VarBasisStatus::BASIC; - } - } - } - } - else if( originalSolution.basisAvailabe) - { - // check if bound is modified on non basic variable and dual solution is 0 - // this can happen in ParallelRowDetection - if( ( (isLhs && ( originalSolution.rowBasisStatus[row] == - VarBasisStatus::ON_LOWER || - originalSolution.rowBasisStatus[row] == - VarBasisStatus::ZERO )) || - ( ! isLhs && originalSolution.rowBasisStatus[row] == - VarBasisStatus::ON_UPPER ) ) ) - { - originalSolution.rowBasisStatus[deleted_row] = - originalSolution.rowBasisStatus[row]; - originalSolution.rowBasisStatus[row] = VarBasisStatus::BASIC; - } - else if( originalSolution.rowBasisStatus[row] == VarBasisStatus::FIXED ) - { - if( isLhs) - originalSolution.rowBasisStatus[row] = VarBasisStatus::ON_UPPER; - else - originalSolution.rowBasisStatus[row] = VarBasisStatus::ON_LOWER; - // TODO: handle case ZERO - } - } -} - -template -void -Postsolve::apply_var_bound_change_forced_by_column_in_original_solution( - Solution& originalSolution, const Vec& types, - const Vec& start, const Vec& indices, const Vec& values, - int i, int first, BoundStorage& stored_bounds, bool is_optimal ) const -{ - - bool isLowerBound = indices[first] == 1; - int col = indices[first + 1]; - REAL old_value = values[first + 2]; - REAL new_value = values[first + 1]; - bool was_infinity = indices[first + 2] == 1; - - stored_bounds.set_bound_of_variable( col, isLowerBound, was_infinity, - old_value ); - - - const REAL reduced_costs = originalSolution.reducedCosts[col]; - bool changes_neg_reduced_costs = - ! isLowerBound && num.isLT( reduced_costs, 0 ); - bool changes_pos_reduced_costs = - isLowerBound && num.isGT( reduced_costs, 0 ); - - int variables_removed_from_basis = 0; - - // calculate the reduced costs if loosens variable at a bound - if( num.isFeasEq( new_value, originalSolution.primal[col] ) && - ( changes_neg_reduced_costs || changes_pos_reduced_costs ) ) - { - assert( ! num.isZero( reduced_costs ) ); - SavedRow saved_row{ - num, i, types, start, indices, values, originalSolution.primal }; - int row = saved_row.getRow(); - REAL increasing_value = reduced_costs / saved_row.getCoeffOfCol( col ); - - originalSolution.dual[saved_row.getRow()] += increasing_value; - - if( originalSolution.basisAvailabe && - originalSolution.rowBasisStatus[row] == VarBasisStatus::BASIC && - ! num.isZero( originalSolution.dual[row] ) ) - { - originalSolution.rowBasisStatus[row] = saved_row.getVBS(); - - assert( originalSolution.rowBasisStatus[row] != - VarBasisStatus::BASIC || saved_row.is_violated(originalSolution.primal, stored_bounds)); - variables_removed_from_basis++; - } - - for( int j = 0; j < saved_row.getLength(); ++j ) - { - int col_index = saved_row.getCoeff( j ); - if( col_index == col ) - continue; - originalSolution.reducedCosts[col_index] -= - increasing_value * saved_row.getValue( j ); - - if( originalSolution.basisAvailabe && - originalSolution.varBasisStatus[col_index] == - VarBasisStatus::BASIC && - ! num.isZero( originalSolution.reducedCosts[col_index] ) ) - { - originalSolution.varBasisStatus[col_index] = get_var_basis_status( - stored_bounds, col_index, originalSolution.primal[col_index] ); - assert( originalSolution.varBasisStatus[col_index] != - VarBasisStatus::BASIC || - saved_row.is_violated( originalSolution.primal, - stored_bounds ) ); - variables_removed_from_basis++; - } - - assert( ! originalSolution.basisAvailabe || - ! num.isZero( originalSolution.reducedCosts[col_index]) || - originalSolution.varBasisStatus[col_index] != - VarBasisStatus::BASIC ); - - // assert for bound tightening - assert( !originalSolution.basisAvailabe || - //whether variable was fixed - originalSolution.varBasisStatus[col] == VarBasisStatus::FIXED || - // or lowerbound is not tight - ( isLowerBound && - num.isGT( originalSolution.primal[col], new_value ) ) || - // or upperbound is not tight - ( !isLowerBound && - num.isLT( originalSolution.primal[col], new_value ) ) || - // or singleton row since there bound-tightening is allowed - saved_row.getLength() == 1 || - // do not handle case if row is violated - saved_row.is_violated(originalSolution.primal, stored_bounds) - ); - } - if( originalSolution.basisAvailabe && variables_removed_from_basis > 0 ) - { - originalSolution.varBasisStatus[col] = VarBasisStatus::BASIC; - variables_removed_from_basis--; - } - assert( variables_removed_from_basis == 0 || - saved_row.is_violated( originalSolution.primal, stored_bounds ) ); - originalSolution.reducedCosts[col] = 0; - } - - - - - if( originalSolution.basisAvailabe ) - { - switch( originalSolution.varBasisStatus[col] ) - { - case VarBasisStatus::FIXED: - if( isLowerBound ) - originalSolution.varBasisStatus[col] = VarBasisStatus::ON_UPPER; - else - originalSolution.varBasisStatus[col] = VarBasisStatus::ON_LOWER; - break; - case VarBasisStatus::ON_LOWER: - { - if( stored_bounds.is_lower_and_upper_bound_infinity( col ) && - num.isZero(originalSolution.primal[col])) - { - originalSolution.varBasisStatus[col] = VarBasisStatus::ZERO; - break; - } - if( ! isLowerBound ) - break; - remove_row_from_basis( originalSolution, types, start, indices, values, - i, stored_bounds, is_optimal ); - originalSolution.varBasisStatus[col] = VarBasisStatus::BASIC; - break; - } - case VarBasisStatus::ON_UPPER: - { - if( stored_bounds.is_lower_and_upper_bound_infinity( col ) && - num.isZero(originalSolution.primal[col])) - { - originalSolution.varBasisStatus[col] = VarBasisStatus::ZERO; - break; - } - if( isLowerBound ) - break; - remove_row_from_basis( originalSolution, types, start, indices, values, - i, stored_bounds, is_optimal ); - originalSolution.varBasisStatus[col] = VarBasisStatus::BASIC; - break; - } - case VarBasisStatus::ZERO: - case VarBasisStatus::UNDEFINED: - case VarBasisStatus::BASIC: - break; - } - } -} - -template -void -Postsolve::apply_parallel_col_to_original_solution( - Solution& originalSolution, const Vec& indices, - const Vec& values, int first, int last, - BoundStorage& stored ) const -{ - // calculate values of the parallel cols such that at least one is at its - // bounds - assert( last - first == 5 ); - - int col1 = indices[first]; - int col1boundFlags = indices[first + 1]; - int col2 = indices[first + 2]; - int col2boundFlags = indices[first + 3]; - const REAL& col1lb = values[first]; - const REAL& col1ub = values[first + 1]; - const REAL& col2lb = values[first + 2]; - const REAL& col2ub = values[first + 3]; - const REAL& col2scale = values[first + 4]; - const REAL& solval = originalSolution.primal[col2]; - - REAL col1val = 0; - REAL col2val = 0; - - if( col1boundFlags & IS_INTEGRAL ) - { - assert( !( col1boundFlags & IS_LBINF ) ); - assert( !( col1boundFlags & IS_UBINF ) ); - assert( !( col2boundFlags & IS_LBINF ) ); - assert( !( col2boundFlags & IS_UBINF ) ); - assert( col2boundFlags & IS_INTEGRAL ); - - col1val = col1lb; - - while( num.isFeasLE( col1val, col1ub ) ) - { - col2val = solval - col1val * col2scale; - - if( num.isFeasIntegral( col2val ) && num.isFeasGE( col2val, col2lb ) && - num.isFeasLE( col2val, col2ub ) ) - break; - - col1val += 1; - } - } - else - { - REAL col2valGuess; - if( !( col2boundFlags & IS_LBINF ) ) - col2valGuess = col2lb; - else if( !( col2boundFlags & IS_UBINF ) ) - col2valGuess = col2ub; - else - col2valGuess = 0; - - col1val = ( solval - col2valGuess ) / col2scale; - - // check if value for column 1 is feasible - if( !( col1boundFlags & IS_LBINF ) && num.isFeasLT( col1val, col1lb ) ) - { - // lower bound was violated -> set column 1 to lower bound - col1val = col1lb; - // compute new value for column1 - col2val = solval - col2scale * col1val; - } - else if( !( col1boundFlags & IS_UBINF ) && - num.isFeasGT( col1val, col1ub ) ) - { - // upper bound was violated -> set column 1 to lower bound - col1val = col1ub; - // compute new value for column 2 - col2val = solval - col2scale * col1val; - } - else - { - // guess was feasible - col2val = col2valGuess; - } - - // domains should be valid now, except for integrality of column - // 2 which could still be violated - assert( ( col1boundFlags & IS_LBINF ) || - num.isFeasGE( col1val, col1lb ) ); - assert( ( col1boundFlags & IS_UBINF ) || - num.isFeasLE( col1val, col1ub ) ); - assert( ( col2boundFlags & IS_LBINF ) || - num.isFeasGE( col2val, col2lb ) ); - assert( ( col2boundFlags & IS_UBINF ) || - num.isFeasLE( col2val, col2ub ) ); - - // maybe integrality is violated now for column 2, then we round - // further in the direction that we already moved to column 2 to - if( ( col2boundFlags & IS_INTEGRAL ) && !num.isFeasIntegral( col2val ) ) - { - // round in the direction that we moved away from when we - // corrected the bound violation for column 1 otherwise we - // will violate the bounds of column 1 again - if( col2val > col2valGuess ) - col2val = ceil( col2val ); - else - col2val = floor( col2val ); - - // recompute value for column 1 - col1val = solval - col1val * col2scale; - } - } - // bounds and integrality should hold now within feasibility - // tolerance - assert( ( col1boundFlags & IS_LBINF ) || num.isFeasGE( col1val, col1lb ) ); - assert( ( col1boundFlags & IS_UBINF ) || num.isFeasLE( col1val, col1ub ) ); - assert( !( col1boundFlags & IS_INTEGRAL ) || num.isFeasIntegral( col1val ) ); - assert( ( col2boundFlags & IS_LBINF ) || num.isFeasGE( col2val, col2lb ) ); - assert( ( col2boundFlags & IS_UBINF ) || num.isFeasLE( col2val, col2ub ) ); - assert( !( col2boundFlags & IS_INTEGRAL ) || num.isFeasIntegral( col2val ) ); - assert( num.isFeasEq( solval, col2scale * col1val + col2val ) ); - - originalSolution.primal[col1] = col1val; - originalSolution.primal[col2] = col2val; - - bool col1onBounds = - ( !( col1boundFlags & IS_UBINF ) && num.isEq( col1val, col1ub ) ) || - ( !( col1boundFlags & IS_LBINF ) && num.isEq( col1val, col1lb ) ); - bool col2onBounds = - ( !( col1boundFlags & IS_UBINF ) && num.isEq( col2val, col2ub ) ) || - ( !( col1boundFlags & IS_LBINF ) && num.isEq( col2val, col2lb ) ); - assert( col1onBounds || col2onBounds ); - - if( originalSolution.type == SolutionType::kPrimalDual ) - { - stored.set_bounds_of_variable( - col1, ( col1boundFlags & IS_LBINF ) == IS_LBINF, - ( col1boundFlags & IS_UBINF ) == IS_UBINF, col1lb, col1ub ); - stored.set_bounds_of_variable( - col2, ( col2boundFlags & IS_LBINF ) == IS_LBINF, - ( col2boundFlags & IS_UBINF ) == IS_UBINF, col2lb, col2ub ); - if( col1onBounds && col2onBounds ) - { - if( ! num.isZero( originalSolution.reducedCosts[col2] ) ) - { - assert( num.isZero( originalSolution.reducedCosts[col1] ) ); - originalSolution.reducedCosts[col1] = - originalSolution.reducedCosts[col2] * col2scale; - } - else - { - assert( num.isZero( originalSolution.reducedCosts[col2] ) ); - originalSolution.reducedCosts[col2] = - originalSolution.reducedCosts[col1] / col2scale; - } - } - - if( originalSolution.basisAvailabe ) - { - - originalSolution.varBasisStatus[col1] = calculate_basis( - col1boundFlags, col1lb, col1ub, col1val, col1onBounds ); - - if(!( col1onBounds && col2onBounds && - originalSolution.varBasisStatus[col2] == VarBasisStatus::BASIC )) - { - originalSolution.varBasisStatus[col2] = calculate_basis( - col2boundFlags, col2lb, col2ub, col2val, col2onBounds ); - } - assert( - originalSolution.varBasisStatus[col1] != VarBasisStatus::BASIC || - originalSolution.varBasisStatus[col2] != VarBasisStatus::BASIC ); - } - } -} - -template -bool -Postsolve::are_the_next_n_types_redundant_rows( - const Vec& types, int i, int redundant_rows ) const -{ - for( int j = 0; j < redundant_rows; j++ ) - if( types[i - j - 1] != ReductionType::kRedundantRow ) - return false; - return true; -} - -/** - * checks if variable is in BASIS, ON_LOWER etc - * @tparam REAL - * @param flags - * @param lb - * @param ub - * @param solution - * @param is_on_bounds - * @return - */ -template -VarBasisStatus -Postsolve::calculate_basis( int flags, REAL lb, REAL ub, REAL solution, - bool is_on_bounds ) const -{ - if( ! is_on_bounds ) - return VarBasisStatus::BASIC; - else if( !( flags & IS_UBINF ) && num.isEq( solution, ub ) ) - return VarBasisStatus::ON_UPPER; - else if( ( flags & IS_LBINF ) && ( flags & IS_UBINF ) && - num.isZero( solution ) ) - return VarBasisStatus::ZERO; - else if( !( flags & IS_LBINF ) && num.isEq( solution, lb ) ) - return VarBasisStatus::ON_LOWER; - return VarBasisStatus::UNDEFINED; -} - -template -VarBasisStatus -Postsolve::get_var_basis_status( BoundStorage& stored_bounds, int col, - REAL val ) const -{ - bool isOnUpperBound = stored_bounds.is_on_upper_bound( col, val ); - bool isOnLowerBound = stored_bounds.is_on_lower_bound( col, val ); - if( isOnUpperBound && isOnLowerBound ) - return VarBasisStatus::FIXED; - else if( isOnUpperBound ) - return VarBasisStatus::ON_UPPER; - else if( stored_bounds.is_lower_and_upper_bound_infinity( col ) && num.isZero( val ) ) - return VarBasisStatus::ZERO; - else if( isOnLowerBound ) - return VarBasisStatus::ON_LOWER; - return VarBasisStatus::BASIC; -} - -template -void -Postsolve::remove_row_from_basis( Solution& originalSolution, - const Vec& types, - const Vec& start, - const Vec& indices, - const Vec& values, int i, BoundStorage& stored_bounds, bool is_optimal ) const -{ - SavedRow saved_row{ - num, i, types, start, indices, values, originalSolution.primal }; - - assert( (originalSolution.rowBasisStatus[saved_row.getRow()] == - VarBasisStatus::BASIC && - ( saved_row.is_on_rhs() || saved_row.is_on_lhs() )) || !is_optimal ); - originalSolution.rowBasisStatus[saved_row.getRow()] = saved_row.getVBS(); - assert( originalSolution.rowBasisStatus[saved_row.getRow()] != - VarBasisStatus::BASIC || !is_optimal); -} - -template -REAL -Postsolve::calculate_row_value_for_fixed_infinity_variable( - REAL lhs, REAL rhs, int rowLength, int column, const int* row_indices, - const REAL* coefficients, Vec& current_solution, bool is_negative, - REAL& coeff_of_column_in_row ) const -{ - StableSum stableSum; - - coeff_of_column_in_row = 0; - for( int l = 0; l < rowLength; l++ ) - { - int row_index = row_indices[l]; - if( row_index == column ) - { - coeff_of_column_in_row = coefficients[l]; - continue; - } - - stableSum.add( -coefficients[l] * current_solution[row_index] ); - } - if( ( coeff_of_column_in_row > 0 && is_negative ) || - ( coeff_of_column_in_row < 0 && ! is_negative ) ) - stableSum.add( rhs ); - else - stableSum.add( lhs ); - assert( coeff_of_column_in_row != 0 ); - return ( stableSum.get() / coeff_of_column_in_row ); -} - -template -Problem -Postsolve::recalculate_current_problem_from_the_original_problem( - const PostsolveStorage& listener, int current_index ) const -{ - - auto types = listener.types; - auto start = listener.start; - auto indices = listener.indices; - auto values = listener.values; - auto origcol_mapping = listener.origcol_mapping; - auto origrow_mapping = listener.origrow_mapping; - auto problem = listener.problem; - - Problem reduced = Problem( problem ); - reduced.recomputeAllActivities(); - Statistics statistics{}; - PresolveOptions presolveOptions{}; - PostsolveStorage postsolveStorage = - PostsolveStorage( reduced, num, presolveOptions ); - ProblemUpdate problemUpdate( reduced, postsolveStorage, statistics, - presolveOptions, num, message ); - - for( int j = 0; j < current_index; j++ ) - { - auto type = types[j]; - int first = start[j]; - switch( type ) - { - case ReductionType::kRedundantRow: - problemUpdate.markRowRedundant( indices[first] ); - break; - case ReductionType::kFixedCol: - case ReductionType::kFixedInfCol: - { - int col = indices[first]; - REAL val = values[first]; - problemUpdate.getProblem().getLowerBounds()[col] = val; - REAL obj = problemUpdate.getProblem().getObjective().coefficients[col]; - problemUpdate.getProblem().getUpperBounds()[col] = val; - problemUpdate.getProblem().getColFlags()[col].set( ColFlag::kFixed ); - problemUpdate.addDeletedVar( col ); - problemUpdate.removeFixedCols(); - problemUpdate.clearDeletedCols(); - problemUpdate.getProblem().getObjective().coefficients[col] = obj; - break; - } - case ReductionType::kVarBoundChange: - { - bool isLowerBound = indices[first] == 1; - int col = indices[first + 1]; - // REAL old_value = values[first + 2]; - REAL new_value = values[first + 1]; - if( isLowerBound ) - { - problemUpdate.getProblem().getLowerBounds()[col] = new_value; - problemUpdate.getProblem().getColFlags()[col].unset( - ColFlag::kLbInf ); - } - else - { - problemUpdate.getProblem().getUpperBounds()[col] = new_value; - problemUpdate.getProblem().getColFlags()[col].unset( - ColFlag::kUbInf ); - } - break; - } - case ReductionType::kRowBoundChange: - case ReductionType::kRowBoundChangeForcedByRow: - { - bool isLhs = indices[first] == 1; - bool isInfinity = indices[first + 1]; - int row = (int)values[first]; - REAL new_value = values[first + 1]; - if( isLhs ) - { - if( isInfinity ) - { - problemUpdate.getProblem() - .getConstraintMatrix() - .template modifyLeftHandSide( row, num ); - } - else - { - problemUpdate.getProblem() - .getConstraintMatrix() - .modifyLeftHandSide( row, num, new_value ); - } - } - else - { - if( isInfinity ) - { - problemUpdate.getProblem() - .getConstraintMatrix() - .template modifyRightHandSide( row, num ); - } - else - { - problemUpdate.getProblem() - .getConstraintMatrix() - .modifyRightHandSide( row, num, new_value ); - } - } - break; - } - case ReductionType::kCoefficientChange: - { - // int row = indices[first]; - // int col = indices[first + 1]; - // REAL value = values[first]; - // TODO: - break; - } - case ReductionType::kSubstitutedColWithDual: - case ReductionType::kSubstitutedCol: - { - int row = indices[first]; - int row_length = (int)values[first]; - assert( indices[first + 1] == 0 ); - int col = indices[first + 3 + row_length]; - int colsize = problemUpdate.getProblem() - .getConstraintMatrix() - .getColSizes()[col]; - - problemUpdate.getProblem().getColFlags()[col].set( - ColFlag::kSubstituted ); - problemUpdate.getProblem().substituteVarInObj( num, col, row ); - - if( colsize > 1 ) - { - // auto eqRHS = problemUpdate.getProblem() - // .getConstraintMatrix() - // .getLeftHandSides()[row]; - - // TODO: make the changes in the constraint matrix? - // problemUpdate.getProblem().getConstraintMatrix().aggregate( - // num, col, rowvec, eqRHS, - // problemUpdate.getProblem().getVariableDomains(), - // intbuffer, realbuffer, tripletbuffer, - // changed_activities, problem.getRowActivities(), - // singletonRows, singletonColumns, emptyColumns, - // stats.nrounds ); - } - break; - } - case ReductionType::kParallelCol: - { - int col1 = indices[first]; - int col2 = indices[first + 2]; - const REAL& col2scale = values[first + 4]; - - problemUpdate.merge_parallel_columns( - col1, col2, col2scale, problemUpdate.getConstraintMatrix(), - problemUpdate.getProblem().getLowerBounds(), - problemUpdate.getProblem().getUpperBounds(), - problemUpdate.getProblem().getColFlags() ); - } - case ReductionType::kReducedBoundsCost: - case ReductionType::kSaveRow: - case ReductionType::kReasonForRowBoundChangeForcedByRow: - break; - default: - assert( false ); - } - } - - return reduced; -} - -} // namespace papilo - -#endif diff --git a/headers/papilo/core/postsolve/PostsolveStatus.hpp b/headers/papilo/core/postsolve/PostsolveStatus.hpp deleted file mode 100644 index 5215b3e..0000000 --- a/headers/papilo/core/postsolve/PostsolveStatus.hpp +++ /dev/null @@ -1,35 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* */ -/* This file is part of the program and library */ -/* PaPILO --- Parallel Presolve for Integer and Linear Optimization */ -/* */ -/* Copyright (C) 2020-2022 Konrad-Zuse-Zentrum */ -/* fuer Informationstechnik Berlin */ -/* */ -/* This program is free software: you can redistribute it and/or modify */ -/* it under the terms of the GNU Lesser General Public License as published */ -/* by the Free Software Foundation, either version 3 of the License, or */ -/* (at your option) any later version. */ -/* */ -/* This program is distributed in the hope that it will be useful, */ -/* but WITHOUT ANY WARRANTY; without even the implied warranty of */ -/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ -/* GNU Lesser General Public License for more details. */ -/* */ -/* You should have received a copy of the GNU Lesser General Public License */ -/* along with this program. If not, see . */ -/* */ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -#ifndef _PAPILO_CORE_POSTSOLVE_STATUS_HPP_ -#define _PAPILO_CORE_POSTSOLVE_STATUS_HPP_ - - -/// possible types of post solving -enum class PostsolveStatus : int -{ - kOk = 0, - kFailed = 1 -}; - -#endif diff --git a/headers/papilo/core/postsolve/PostsolveStorage.hpp b/headers/papilo/core/postsolve/PostsolveStorage.hpp deleted file mode 100644 index e9e75e1..0000000 --- a/headers/papilo/core/postsolve/PostsolveStorage.hpp +++ /dev/null @@ -1,717 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* */ -/* This file is part of the program and library */ -/* PaPILO --- Parallel Presolve for Integer and Linear Optimization */ -/* */ -/* Copyright (C) 2020-2022 Konrad-Zuse-Zentrum */ -/* fuer Informationstechnik Berlin */ -/* */ -/* This program is free software: you can redistribute it and/or modify */ -/* it under the terms of the GNU Lesser General Public License as published */ -/* by the Free Software Foundation, either version 3 of the License, or */ -/* (at your option) any later version. */ -/* */ -/* This program is distributed in the hope that it will be useful, */ -/* but WITHOUT ANY WARRANTY; without even the implied warranty of */ -/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ -/* GNU Lesser General Public License for more details. */ -/* */ -/* You should have received a copy of the GNU Lesser General Public License */ -/* along with this program. If not, see . */ -/* */ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -#ifndef _PAPILO_CORE_POSTSOLVE_LISTENER_HPP_ -#define _PAPILO_CORE_POSTSOLVE_LISTENER_HPP_ - -#include "papilo/core/Problem.hpp" -#include "papilo/core/postsolve/PostsolveType.hpp" -#include "papilo/core/postsolve/ReductionType.hpp" -#include "papilo/misc/MultiPrecision.hpp" -#include "papilo/misc/Num.hpp" -#include "papilo/misc/PrimalDualSolValidation.hpp" -#include "papilo/misc/StableSum.hpp" -#include "papilo/misc/Vec.hpp" -#include "papilo/misc/compress_vector.hpp" -#include "papilo/misc/fmt.hpp" -#ifdef PAPILO_TBB -#include "papilo/misc/tbb.hpp" -#endif -#include - -#include -#include -#include -#include -#include -#include -#include - -namespace papilo -{ - -template -class SparseVectorView; - -struct IndexRange; - -/// type to store necessary data for post solve -template -class PostsolveStorage -{ - public: - unsigned int nColsOriginal; - unsigned int nRowsOriginal; - - /// mapping of reduced problems column indices to column indices in the - /// original problem - Vec origcol_mapping; - - /// mapping of reduced problems row indices to row indices in the original - /// problem - Vec origrow_mapping; - - // set to full for development of postsolve, - // later will not be default value - // PostsolveType postsolveType = PostsolveType::kFull; - PostsolveType postsolveType = PostsolveType::kPrimal; - - //types containes the Reductiontypes - Vec types; - - // indices/values can be considered as Vec> - // To reduce the number of vectors and hence speedup there is only one vector and - // start indicates by saving the start index where the information of the Reduction type begins - Vec indices; - Vec values; - - // indices where the information of the i-th reduction inside start/values starts - // information go from [start[i], start [i+1]) - Vec start; - - Problem problem; - - PresolveOptions presolveOptions; - - Num num; - - PostsolveStorage() = default; - - PostsolveStorage( int nrows, int ncols ) - { - origrow_mapping.reserve( nrows ); - origrow_mapping.reserve( ncols ); - - for( int i = 0; i < nrows; ++i ) - origrow_mapping.push_back( i ); - - for( int i = 0; i < ncols; ++i ) - origcol_mapping.push_back( i ); - - nColsOriginal = ncols; - nRowsOriginal = nrows; - - start.push_back( 0 ); - } - - PostsolveStorage( const Problem& _problem, const Num& _num, const PresolveOptions _options ) - : problem( _problem ), presolveOptions(_options), num( _num ) - { - nRowsOriginal = _problem.getNRows(); - nColsOriginal = _problem.getNCols(); - - origrow_mapping.reserve( nRowsOriginal ); - origrow_mapping.reserve( nColsOriginal ); - - for( unsigned int i = 0; i < nRowsOriginal; ++i ) - origrow_mapping.push_back( (int) i ); - - for( unsigned int i = 0; i < nColsOriginal; ++i ) - origcol_mapping.push_back( (int) i ); - - start.push_back( 0 ); - - // release excess storage in original problem copy - this->problem.compress( true ); - } - - void - storeRedundantRow( int row ); - - void - storeVarBoundChange( bool isLowerBound, int col, REAL oldBound, - bool was_infinity, REAL newBound ); - - void - storeRowBoundChange( bool isLhs, int row, REAL newBound, bool is_infinity, REAL oldBound, bool was_infinity ); - - void - storeRowBoundChangeForcedByRow( bool isLhs, int row, REAL newBound, bool isInfinity ); - - void - storeReasonForRowBoundChangeForcedByRow( int remained_row, int deleted_row, REAL factor); - - void - storeReducedBoundsAndCost( const Vec& col_lb, const Vec& col_ub, - const Vec& row_lhs, const Vec& row_rhs, - const Vec& coefficients, - const Vec& row_flags, - const Vec& col_flags ); - - void - storeFixedCol( int col, REAL val, - const SparseVectorView& colvec, - const Vec& cost ); - - void - storeCoefficientChange(int row, int col, REAL new_value); - - void - storeDualValue( bool is_column_dual, int index, REAL value ); - - void - storeSavedRow( int row, const SparseVectorView& coefficients, - REAL lhs, REAL rhs, const RowFlags& flags ); - - void - storeFixedInfCol( int col, REAL val, REAL bound, - const Problem& currentProblem ); - - void - storeSubstitution( int col, int row, const Problem& currentProblem ); - - void - storeSubstitution( int col, SparseVectorView equalityLHS, - REAL equalityRHS ); - - /// col1 = col2scale * col2 and are merged into a new column y = col2 + - /// col2scale * col1 which takes over the index of col2 - void - storeParallelCols( int col1, bool col1integral, bool col1lbinf, - REAL& col1lb, bool col1ubinf, REAL& col1ub, - int col2, bool col2integral, bool col2lbinf, - REAL& col2lb, bool col2ubinf, REAL& col2ub, - REAL& col2scale ); - - void - compress( const Vec& rowmapping, const Vec& colmapping, - bool full = false ) - { -#ifdef PAPILO_TBB - tbb::parallel_invoke( - [this, &colmapping, full]() { - compress_vector( colmapping, origcol_mapping ); - if( full ) - origcol_mapping.shrink_to_fit(); - }, - [this, &rowmapping, full]() { - // update information about rows that is stored by index - compress_vector( rowmapping, origrow_mapping ); - if( full ) - origrow_mapping.shrink_to_fit(); - } ); -#else - compress_vector( colmapping, origcol_mapping ); - compress_vector( rowmapping, origrow_mapping ); - if( full ) - { - origrow_mapping.shrink_to_fit(); - origcol_mapping.shrink_to_fit(); - } -#endif - } - - template - void - serialize( Archive& ar, const unsigned int version ) - { - ar& nColsOriginal; - ar& nRowsOriginal; - ar& origcol_mapping; - ar& origrow_mapping; - ar& postsolveType; - ar& types; - ar& indices; - ar& values; - ar& start; - - ar& problem; - - ar& num; - } - - - const Problem& - getOriginalProblem() const - { - return problem; - } - - const Num& - getNum() const - { - return num; - } - - private: - void - finishStorage() - { - assert( types.size() == start.size() ); - assert( values.size() == indices.size() ); - start.push_back( values.size() ); - } - - void - push_back_row( int row, const Problem& currentProblem ); - - void - push_back_col( int col, const Problem& currentProblem ); - -}; - -#ifdef PAPILO_USE_EXTERN_TEMPLATES -extern template class PostsolveStorage; -extern template class PostsolveStorage; -extern template class PostsolveStorage; -#endif - -template -void -PostsolveStorage::push_back_row( int row, - const Problem& currentProblem ) -{ - const auto& coefficients = - currentProblem.getConstraintMatrix().getRowCoefficients( row ); - REAL lhs = currentProblem.getConstraintMatrix().getLeftHandSides()[row]; - REAL rhs = currentProblem.getConstraintMatrix().getRightHandSides()[row]; - const auto& flags = currentProblem.getConstraintMatrix().getRowFlags()[row]; - - const REAL* coefs = coefficients.getValues(); - const int* columns = coefficients.getIndices(); - const int length = coefficients.getLength(); - - indices.push_back( origrow_mapping[row] ); - values.push_back( (double)length ); - - // LB - if( flags.test( RowFlag::kLhsInf ) ) - indices.push_back( 1 ); - else - indices.push_back( 0 ); - values.push_back( lhs ); - - // UB - if( flags.test( RowFlag::kRhsInf ) ) - indices.push_back( 1 ); - else - indices.push_back( 0 ); - values.push_back( rhs ); - - for( int i = 0; i < length; ++i ) - { - indices.push_back( origcol_mapping[columns[i]] ); - values.push_back( coefs[i] ); - } -} - -template -void -PostsolveStorage::push_back_col( int col, - const Problem& currentProblem ) -{ - const auto& coefficients = - currentProblem.getConstraintMatrix().getColumnCoefficients( col ); - ColFlags flags = currentProblem.getColFlags()[col]; - REAL obj = currentProblem.getObjective().coefficients[col]; - - const REAL* coefs = coefficients.getValues(); - const int* row_indices = coefficients.getIndices(); - const int length = coefficients.getLength(); - - indices.push_back( origcol_mapping[col] ); - values.push_back( (double)length ); - - indices.push_back( 0 ); - values.push_back( obj ); - - // UB - if( flags.test( ColFlag::kUbInf ) ) - indices.push_back( 1 ); - else - indices.push_back( 0 ); - values.push_back( currentProblem.getUpperBounds()[col] ); - - // LB - if( flags.test( ColFlag::kLbInf ) ) - indices.push_back( 1 ); - else - indices.push_back( 0 ); - values.push_back( currentProblem.getLowerBounds()[col] ); - - for( int i = 0; i < length; ++i ) - { - indices.push_back( origrow_mapping[row_indices[i]] ); - values.push_back( coefs[i] ); - } -} - -template -void -PostsolveStorage::storeRedundantRow( int row ) -{ - if( postsolveType == PostsolveType::kPrimal ) - return; - - types.push_back( ReductionType::kRedundantRow ); - indices.push_back(origrow_mapping[row] ); - values.push_back( 0 ); - - finishStorage(); -} - - -template -void -PostsolveStorage::storeVarBoundChange( bool isLowerBound, - int col, - REAL oldBound, - bool was_infinity, - REAL newBound ) -{ - if( postsolveType == PostsolveType::kPrimal ) - return; - types.push_back( ReductionType::kVarBoundChange ); - if( isLowerBound ) - indices.push_back( 1 ); - else - indices.push_back( 0 ); - values.push_back( 0 ); - - int c = origcol_mapping[col]; - indices.push_back( c ); - values.push_back( newBound ); - - indices.push_back( was_infinity ); - values.push_back( oldBound ); - - finishStorage(); -} - - -template -void -PostsolveStorage::storeRowBoundChange( bool isLhs, int row, REAL newBound, bool is_infinity, REAL oldBound, bool was_infinity ){ - if( postsolveType == PostsolveType::kPrimal ) - return; - types.push_back( ReductionType::kRowBoundChange ); - if( isLhs ) - indices.push_back( 1 ); - else - indices.push_back( 0 ); - values.push_back( origrow_mapping[row] ); - indices.push_back( is_infinity ); - values.push_back( newBound ); - indices.push_back( was_infinity ); - values.push_back( oldBound ); - - finishStorage(); -} - -template -void -PostsolveStorage::storeRowBoundChangeForcedByRow( bool isLhs, int row, REAL newBound, bool isInfinity ){ - if( postsolveType == PostsolveType::kPrimal ) - return; - types.push_back( ReductionType::kRowBoundChangeForcedByRow ); - if( isLhs ) - indices.push_back( 1 ); - else - indices.push_back( 0 ); - values.push_back( origrow_mapping[row] ); - indices.push_back( isInfinity ); - values.push_back( newBound ); - - finishStorage(); -} - -template -void -PostsolveStorage::storeReasonForRowBoundChangeForcedByRow( int remained_row, int deleted_row, REAL factor){ - if( postsolveType == PostsolveType::kPrimal ) - return; - types.push_back( ReductionType::kReasonForRowBoundChangeForcedByRow ); - indices.push_back( origrow_mapping[remained_row] ); - values.push_back( factor ); - indices.push_back( origrow_mapping[deleted_row] ); - values.push_back( 0 ); - - finishStorage(); -} - - -template -void -PostsolveStorage::storeFixedCol( int col, REAL val, - const SparseVectorView& colvec, - const Vec& cost ) -{ - types.push_back( ReductionType::kFixedCol ); - indices.push_back( origcol_mapping[col] ); - values.push_back( val ); - - if( postsolveType == PostsolveType::kFull ) - { - const int length = colvec.getLength(); - indices.push_back( length ); - values.push_back( cost[col] ); - - const REAL* vals = colvec.getValues(); - const int* inds = colvec.getIndices(); - - for( int j = 0; j < length; j++ ) - { - indices.push_back( origrow_mapping[inds[j]] ); - values.push_back( vals[j] ); - } - } - - finishStorage(); -} - -template -void -PostsolveStorage::storeFixedInfCol( - int col, REAL val, REAL bound, const Problem& currentProblem ) -{ - types.push_back( ReductionType::kFixedInfCol ); - indices.push_back( origcol_mapping[col] ); - values.push_back( val ); - - const auto& coefficients = - currentProblem.getConstraintMatrix().getColumnCoefficients( col ); - const int* row_indices = coefficients.getIndices(); - - indices.push_back( coefficients.getLength() ); - values.push_back( bound ); - - for( int i = 0; i < coefficients.getLength(); i++ ) - push_back_row( row_indices[i], currentProblem ); - - finishStorage(); -} - -template -void -PostsolveStorage::storeCoefficientChange( int row, int col, - REAL new_value ) -{ - if( postsolveType == PostsolveType::kPrimal ) - return; - types.push_back( ReductionType::kCoefficientChange ); - indices.push_back( origrow_mapping[row] ); - indices.push_back( origcol_mapping[col] ); - values.push_back( new_value ); - values.push_back( 0 ); - finishStorage(); - -} - -template -void -PostsolveStorage::storeDualValue( bool is_column_dual, int index, REAL value ) -{ - if( postsolveType == PostsolveType::kPrimal ) - return; - if( is_column_dual ) - types.push_back( ReductionType::kColumnDualValue ); - else - types.push_back( ReductionType::kRowDualValue ); - - indices.push_back( index ); - values.push_back( value ); - finishStorage(); -} - - template - void -PostsolveStorage::storeSavedRow( int row, - const SparseVectorView& coefficients, - REAL lhs, REAL rhs, const RowFlags& flags ) - { - if( postsolveType == PostsolveType::kPrimal ) - return; - const REAL* coefs = coefficients.getValues(); - const int* columns = coefficients.getIndices(); - const int length = coefficients.getLength(); - - types.push_back( ReductionType::kSaveRow ); - indices.push_back( origrow_mapping[row] ); - values.push_back( (double)length ); - - // LB - if( flags.test( RowFlag::kLhsInf ) ) - indices.push_back( 1 ); - else - indices.push_back( 0 ); - values.push_back( lhs ); - - // UB - if( flags.test( RowFlag::kRhsInf ) ) - indices.push_back( 1 ); - else - indices.push_back( 0 ); - values.push_back( rhs ); - - for( int i = 0; i < length; ++i ) - { - indices.push_back( origcol_mapping[columns[i]] ); - values.push_back( coefs[i] ); - } - - finishStorage(); - } - -template -void - PostsolveStorage::storeSubstitution( int col, int row, - const Problem& currentProblem ) -{ - types.push_back( ReductionType::kSubstitutedColWithDual ); - push_back_row( row, currentProblem ); - if( postsolveType == PostsolveType::kFull ) - push_back_col( col, currentProblem ); - else - { - indices.push_back( origcol_mapping[col] ); - values.push_back( 0 ); - } - - finishStorage(); -} - -template -void -PostsolveStorage::storeSubstitution( int col, - SparseVectorView equalityLHS, - REAL equalityRHS ) -{ - const REAL* coefs = equalityLHS.getValues(); - const int* columns = equalityLHS.getIndices(); - const int length = equalityLHS.getLength(); - assert( length > 1 ); - - types.push_back( ReductionType::kSubstitutedCol ); - values.push_back( equalityRHS ); - indices.push_back( origcol_mapping[col] ); - for( int i = 0; i < length; ++i ) - { - indices.push_back( origcol_mapping[columns[i]] ); - values.push_back( coefs[i] ); - } - finishStorage(); -} - -/// col1 = col2scale * col2 and are merged into a new column y = col2 + -/// col2scale * col1 which takes over the index of col2 -template -void -PostsolveStorage::storeParallelCols( int col1, bool col1integral, - bool col1lbinf, REAL& col1lb, - bool col1ubinf, REAL& col1ub, - int col2, bool col2integral, - bool col2lbinf, REAL& col2lb, - bool col2ubinf, REAL& col2ub, - REAL& col2scale ) -{ - // encode the finiteness of the bounds in one integer and store it as - // value for column 1 - int col1BoundFlags = 0; - int col2BoundFlags = 0; - - if( col1integral ) - col1BoundFlags |= static_cast( ColFlag::kIntegral ); - if( col1lbinf ) - col1BoundFlags |= static_cast( ColFlag::kLbInf ); - if( col1ubinf ) - col1BoundFlags |= static_cast( ColFlag::kUbInf ); - if( col2integral ) - col2BoundFlags |= static_cast( ColFlag::kIntegral ); - if( col2lbinf ) - col2BoundFlags |= static_cast( ColFlag::kLbInf ); - if( col2ubinf ) - col2BoundFlags |= static_cast( ColFlag::kUbInf ); - - // add all information - indices.push_back( origcol_mapping[col1] ); - indices.push_back( col1BoundFlags ); - indices.push_back( origcol_mapping[col2] ); - indices.push_back( col2BoundFlags ); - indices.push_back( -1 ); // last index slot is not used - values.push_back( col1lb ); - values.push_back( col1ub ); - values.push_back( col2lb ); - values.push_back( col2ub ); - values.push_back( col2scale ); - - // add the range and the type of the reduction - types.push_back( ReductionType::kParallelCol ); - - finishStorage(); -} - -template -void -PostsolveStorage::storeReducedBoundsAndCost( - const Vec& col_lb, const Vec& col_ub, const Vec& row_lhs, - const Vec& row_rhs, const Vec& coefficients, - const Vec& row_flags, const Vec& col_flags ) -{ - // store the row/col bounds and the objective of the reduced problem - if( postsolveType == PostsolveType::kPrimal ) - return; - types.push_back( ReductionType::kReducedBoundsCost ); - - // col bound - for( int col = 0; col < (int) col_lb.size(); col++ ) - { - int flag_lb = 0; - int flag_ub = 0; - if( col_flags[col].test( ColFlag::kLbInf ) ) - flag_lb = 1; - if( col_flags[col].test( ColFlag::kUbInf ) ) - flag_ub = 1; - indices.push_back( flag_lb ); - values.push_back( col_lb[col] ); - indices.push_back( flag_ub ); - values.push_back( col_ub[col] ); - } - - // row bounds - for( int row = 0; row < (int) row_lhs.size(); row++ ) - { - int flag_lb = 0; - int flag_ub = 0; - if( row_flags[row].test( RowFlag::kLhsInf ) ) - flag_lb = 1; - if( row_flags[row].test( RowFlag::kRhsInf ) ) - flag_ub = 1; - indices.push_back( flag_lb ); - values.push_back( row_lhs[row] ); - indices.push_back( flag_ub ); - values.push_back( row_rhs[row] ); - } - - // col coefficients - for( int col = 0; col < (int) coefficients.size(); col++ ) - { - indices.push_back( col ); - values.push_back( coefficients[col] ); - } - - finishStorage(); -} - -} // namespace papilo - -#endif diff --git a/headers/papilo/core/postsolve/PostsolveType.hpp b/headers/papilo/core/postsolve/PostsolveType.hpp deleted file mode 100644 index 8c8fbca..0000000 --- a/headers/papilo/core/postsolve/PostsolveType.hpp +++ /dev/null @@ -1,35 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* */ -/* This file is part of the program and library */ -/* PaPILO --- Parallel Presolve for Integer and Linear Optimization */ -/* */ -/* Copyright (C) 2020-2022 Konrad-Zuse-Zentrum */ -/* fuer Informationstechnik Berlin */ -/* */ -/* This program is free software: you can redistribute it and/or modify */ -/* it under the terms of the GNU Lesser General Public License as published */ -/* by the Free Software Foundation, either version 3 of the License, or */ -/* (at your option) any later version. */ -/* */ -/* This program is distributed in the hope that it will be useful, */ -/* but WITHOUT ANY WARRANTY; without even the implied warranty of */ -/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ -/* GNU Lesser General Public License for more details. */ -/* */ -/* You should have received a copy of the GNU Lesser General Public License */ -/* along with this program. If not, see . */ -/* */ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -#ifndef _PAPILO_CORE_POSTSOLVE_TYPE_HPP_ -#define _PAPILO_CORE_POSTSOLVE_TYPE_HPP_ - - -/// possible types of post solving -enum class PostsolveType : int -{ - kPrimal = 0, - kFull = 1, -}; - -#endif diff --git a/headers/papilo/core/postsolve/ReductionType.hpp b/headers/papilo/core/postsolve/ReductionType.hpp deleted file mode 100644 index 176cd9d..0000000 --- a/headers/papilo/core/postsolve/ReductionType.hpp +++ /dev/null @@ -1,51 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* */ -/* This file is part of the program and library */ -/* PaPILO --- Parallel Presolve for Integer and Linear Optimization */ -/* */ -/* Copyright (C) 2020-2022 Konrad-Zuse-Zentrum */ -/* fuer Informationstechnik Berlin */ -/* */ -/* This program is free software: you can redistribute it and/or modify */ -/* it under the terms of the GNU Lesser General Public License as published */ -/* by the Free Software Foundation, either version 3 of the License, or */ -/* (at your option) any later version. */ -/* */ -/* This program is distributed in the hope that it will be useful, */ -/* but WITHOUT ANY WARRANTY; without even the implied warranty of */ -/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ -/* GNU Lesser General Public License for more details. */ -/* */ -/* You should have received a copy of the GNU Lesser General Public License */ -/* along with this program. If not, see . */ -/* */ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -#ifndef _PAPILO_CORE_REDUCTION_TYPE_HPP_ -#define _PAPILO_CORE_REDUCTION_TYPE_HPP_ - - -/// possible types of post solving -enum class ReductionType : int -{ - kFixedCol = 0, - kFixedInfCol = 5, - kParallelCol = 2, - kSubstitutedColWithDual = 3, - kSubstitutedCol = 1, - kVarBoundChange = 4, - - kRedundantRow = 7, - kRowBoundChange = 8, - kReasonForRowBoundChangeForcedByRow = 9, - kRowBoundChangeForcedByRow = 10, - - kSaveRow = 11, - - kReducedBoundsCost = 12, - kColumnDualValue = 13, - kRowDualValue = 14, - kCoefficientChange = 15, -}; - -#endif diff --git a/headers/papilo/core/postsolve/SavedRow.hpp b/headers/papilo/core/postsolve/SavedRow.hpp deleted file mode 100644 index 9815716..0000000 --- a/headers/papilo/core/postsolve/SavedRow.hpp +++ /dev/null @@ -1,178 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* */ -/* This file is part of the program and library */ -/* PaPILO --- Parallel Presolve for Integer and Linear Optimization */ -/* */ -/* Copyright (C) 2020-2022 Konrad-Zuse-Zentrum */ -/* fuer Informationstechnik Berlin */ -/* */ -/* This program is free software: you can redistribute it and/or modify */ -/* it under the terms of the GNU Lesser General Public License as published */ -/* by the Free Software Foundation, either version 3 of the License, or */ -/* (at your option) any later version. */ -/* */ -/* This program is distributed in the hope that it will be useful, */ -/* but WITHOUT ANY WARRANTY; without even the implied warranty of */ -/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ -/* GNU Lesser General Public License for more details. */ -/* */ -/* You should have received a copy of the GNU Lesser General Public License */ -/* along with this program. If not, see . */ -/* */ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -#ifndef _PAPILO_CORE_SAVED_ROW_HPP_ -#define _PAPILO_CORE_SAVED_ROW_HPP_ - -#include "papilo/core/Solution.hpp" -#include "papilo/core/postsolve/BoundStorage.hpp" -#include "papilo/core/postsolve/ReductionType.hpp" -#include "papilo/misc/Num.hpp" -#include "papilo/misc/StableSum.hpp" -#include "papilo/misc/Vec.hpp" - -namespace papilo -{ - -template -class SavedRow -{ - private: - Num num; - - int row; - - Vec col_coefficients; - Vec row_values; - - REAL slack; - - bool is_lhs_inf; - REAL lhs; - bool is_rhs_inf; - REAL rhs; - int length; - - public: - SavedRow( const Num& n, int i, const Vec& types, - const Vec& start, const Vec& indices, - const Vec& values, const Vec& primal_solution ) - { - int next_type = i - 1; - int next_but_one_type = i - 2; - - int saved_row = start[next_type]; - if( types[next_type] == ReductionType::kSaveRow ) - saved_row = start[next_type]; - else if( types[next_but_one_type] == ReductionType::kSaveRow ) - saved_row = start[next_but_one_type]; - else - assert( false ); - row = indices[saved_row]; - length = (int)values[saved_row]; - is_lhs_inf = indices[saved_row + 1] == 1; - lhs = values[saved_row + 1]; - is_rhs_inf = indices[saved_row + 2] == 1; - rhs = values[saved_row + 2]; - - col_coefficients.resize( length ); - row_values.resize( length ); - - StableSum slack_of_row{}; - for( int j = 0; j < length; ++j ) - { - int col_index = indices[saved_row + 3 + j]; - REAL val = values[saved_row + 3 + j]; - col_coefficients[j] = col_index; - row_values[j] = val; - slack_of_row.add( val * primal_solution[col_index] ); - } - slack = slack_of_row.get(); - } - - bool - is_on_lhs() - { - return !is_lhs_inf && num.isFeasEq( slack, lhs ); - } - - bool - is_on_rhs() - { - return !is_rhs_inf && num.isFeasEq( slack, rhs ); - } - - int - getRow() - { - return row; - } - - int - getLength() - { - return length; - } - - REAL - getCoeffOfCol( int col ) - { - for( int j = 0; j < length; ++j ) - { - if( col_coefficients[j] == col ) - return row_values[j]; - } - assert( false ); - return 0; - } - - int - getCoeff( int index ) - { - return col_coefficients[index]; - } - - REAL - getValue( int index ) - { - return row_values[index]; - } - - VarBasisStatus - getVBS() - { - if( is_on_lhs() && is_on_rhs() ) - return VarBasisStatus::FIXED; - else if( is_on_rhs() ) - return VarBasisStatus::ON_UPPER; - else if( is_on_lhs() ) - return VarBasisStatus::ON_LOWER; - else if( is_lhs_inf && is_rhs_inf && num.isZero( slack ) ) - return VarBasisStatus::ZERO; - return VarBasisStatus::BASIC; - } - - bool - is_violated( const Vec& primal, - const BoundStorage& stored_bounds ) - { - for( int i = 0; i < length; i++ ) - { - int index = col_coefficients[i]; - REAL sol = primal[index]; - bool is_lb_violated = !stored_bounds.col_infinity_lower[index] && - num.isLT( sol, stored_bounds.col_lower[index] ); - bool is_ub_violated = !stored_bounds.col_infinity_upper[index] && - num.isGT( sol, stored_bounds.col_upper[index] ); - if(is_lb_violated || is_ub_violated) - return true; - } - bool rhs_violated = !is_rhs_inf && num.isFeasGT( slack, rhs ); - bool lhs_violated = !is_lhs_inf && num.isFeasLT( slack, lhs ); - return rhs_violated || lhs_violated; - } -}; - -} // namespace papilo - -#endif diff --git a/headers/papilo/external/fmt/chrono.h b/headers/papilo/external/fmt/chrono.h deleted file mode 100644 index ca4ed30..0000000 --- a/headers/papilo/external/fmt/chrono.h +++ /dev/null @@ -1,1106 +0,0 @@ -// Formatting library for C++ - chrono support -// -// Copyright (c) 2012 - present, Victor Zverovich -// All rights reserved. -// -// For the license information refer to format.h. - -#ifndef FMT_CHRONO_H_ -#define FMT_CHRONO_H_ - -#include "format.h" -#include "locale.h" - -#include -#include -#include -#include - -FMT_BEGIN_NAMESPACE - -// Enable safe chrono durations, unless explicitly disabled. -#ifndef FMT_SAFE_DURATION_CAST -# define FMT_SAFE_DURATION_CAST 1 -#endif -#if FMT_SAFE_DURATION_CAST - -// For conversion between std::chrono::durations without undefined -// behaviour or erroneous results. -// This is a stripped down version of duration_cast, for inclusion in fmt. -// See https://github.com/pauldreik/safe_duration_cast -// -// Copyright Paul Dreik 2019 -namespace safe_duration_cast { - -template ::value && - std::numeric_limits::is_signed == - std::numeric_limits::is_signed)> -FMT_CONSTEXPR To lossless_integral_conversion(const From from, int& ec) { - ec = 0; - using F = std::numeric_limits; - using T = std::numeric_limits; - static_assert(F::is_integer, "From must be integral"); - static_assert(T::is_integer, "To must be integral"); - - // A and B are both signed, or both unsigned. - if (F::digits <= T::digits) { - // From fits in To without any problem. - } else { - // From does not always fit in To, resort to a dynamic check. - if (from < T::min() || from > T::max()) { - // outside range. - ec = 1; - return {}; - } - } - return static_cast(from); -} - -/** - * converts From to To, without loss. If the dynamic value of from - * can't be converted to To without loss, ec is set. - */ -template ::value && - std::numeric_limits::is_signed != - std::numeric_limits::is_signed)> -FMT_CONSTEXPR To lossless_integral_conversion(const From from, int& ec) { - ec = 0; - using F = std::numeric_limits; - using T = std::numeric_limits; - static_assert(F::is_integer, "From must be integral"); - static_assert(T::is_integer, "To must be integral"); - - if (F::is_signed && !T::is_signed) { - // From may be negative, not allowed! - if (fmt::internal::is_negative(from)) { - ec = 1; - return {}; - } - - // From is positive. Can it always fit in To? - if (F::digits <= T::digits) { - // yes, From always fits in To. - } else { - // from may not fit in To, we have to do a dynamic check - if (from > static_cast(T::max())) { - ec = 1; - return {}; - } - } - } - - if (!F::is_signed && T::is_signed) { - // can from be held in To? - if (F::digits < T::digits) { - // yes, From always fits in To. - } else { - // from may not fit in To, we have to do a dynamic check - if (from > static_cast(T::max())) { - // outside range. - ec = 1; - return {}; - } - } - } - - // reaching here means all is ok for lossless conversion. - return static_cast(from); - -} // function - -template ::value)> -FMT_CONSTEXPR To lossless_integral_conversion(const From from, int& ec) { - ec = 0; - return from; -} // function - -// clang-format off -/** - * converts From to To if possible, otherwise ec is set. - * - * input | output - * ---------------------------------|--------------- - * NaN | NaN - * Inf | Inf - * normal, fits in output | converted (possibly lossy) - * normal, does not fit in output | ec is set - * subnormal | best effort - * -Inf | -Inf - */ -// clang-format on -template ::value)> -FMT_CONSTEXPR To safe_float_conversion(const From from, int& ec) { - ec = 0; - using T = std::numeric_limits; - static_assert(std::is_floating_point::value, "From must be floating"); - static_assert(std::is_floating_point::value, "To must be floating"); - - // catch the only happy case - if (std::isfinite(from)) { - if (from >= T::lowest() && from <= T::max()) { - return static_cast(from); - } - // not within range. - ec = 1; - return {}; - } - - // nan and inf will be preserved - return static_cast(from); -} // function - -template ::value)> -FMT_CONSTEXPR To safe_float_conversion(const From from, int& ec) { - ec = 0; - static_assert(std::is_floating_point::value, "From must be floating"); - return from; -} - -/** - * safe duration cast between integral durations - */ -template ::value), - FMT_ENABLE_IF(std::is_integral::value)> -To safe_duration_cast(std::chrono::duration from, - int& ec) { - using From = std::chrono::duration; - ec = 0; - // the basic idea is that we need to convert from count() in the from type - // to count() in the To type, by multiplying it with this: - struct Factor - : std::ratio_divide {}; - - static_assert(Factor::num > 0, "num must be positive"); - static_assert(Factor::den > 0, "den must be positive"); - - // the conversion is like this: multiply from.count() with Factor::num - // /Factor::den and convert it to To::rep, all this without - // overflow/underflow. let's start by finding a suitable type that can hold - // both To, From and Factor::num - using IntermediateRep = - typename std::common_type::type; - - // safe conversion to IntermediateRep - IntermediateRep count = - lossless_integral_conversion(from.count(), ec); - if (ec) { - return {}; - } - // multiply with Factor::num without overflow or underflow - if (Factor::num != 1) { - const auto max1 = internal::max_value() / Factor::num; - if (count > max1) { - ec = 1; - return {}; - } - const auto min1 = std::numeric_limits::min() / Factor::num; - if (count < min1) { - ec = 1; - return {}; - } - count *= Factor::num; - } - - // this can't go wrong, right? den>0 is checked earlier. - if (Factor::den != 1) { - count /= Factor::den; - } - // convert to the to type, safely - using ToRep = typename To::rep; - const ToRep tocount = lossless_integral_conversion(count, ec); - if (ec) { - return {}; - } - return To{tocount}; -} - -/** - * safe duration_cast between floating point durations - */ -template ::value), - FMT_ENABLE_IF(std::is_floating_point::value)> -To safe_duration_cast(std::chrono::duration from, - int& ec) { - using From = std::chrono::duration; - ec = 0; - if (std::isnan(from.count())) { - // nan in, gives nan out. easy. - return To{std::numeric_limits::quiet_NaN()}; - } - // maybe we should also check if from is denormal, and decide what to do about - // it. - - // +-inf should be preserved. - if (std::isinf(from.count())) { - return To{from.count()}; - } - - // the basic idea is that we need to convert from count() in the from type - // to count() in the To type, by multiplying it with this: - struct Factor - : std::ratio_divide {}; - - static_assert(Factor::num > 0, "num must be positive"); - static_assert(Factor::den > 0, "den must be positive"); - - // the conversion is like this: multiply from.count() with Factor::num - // /Factor::den and convert it to To::rep, all this without - // overflow/underflow. let's start by finding a suitable type that can hold - // both To, From and Factor::num - using IntermediateRep = - typename std::common_type::type; - - // force conversion of From::rep -> IntermediateRep to be safe, - // even if it will never happen be narrowing in this context. - IntermediateRep count = - safe_float_conversion(from.count(), ec); - if (ec) { - return {}; - } - - // multiply with Factor::num without overflow or underflow - if (Factor::num != 1) { - constexpr auto max1 = internal::max_value() / - static_cast(Factor::num); - if (count > max1) { - ec = 1; - return {}; - } - constexpr auto min1 = std::numeric_limits::lowest() / - static_cast(Factor::num); - if (count < min1) { - ec = 1; - return {}; - } - count *= static_cast(Factor::num); - } - - // this can't go wrong, right? den>0 is checked earlier. - if (Factor::den != 1) { - using common_t = typename std::common_type::type; - count /= static_cast(Factor::den); - } - - // convert to the to type, safely - using ToRep = typename To::rep; - - const ToRep tocount = safe_float_conversion(count, ec); - if (ec) { - return {}; - } - return To{tocount}; -} -} // namespace safe_duration_cast -#endif - -// Prevents expansion of a preceding token as a function-style macro. -// Usage: f FMT_NOMACRO() -#define FMT_NOMACRO - -namespace internal { -inline null<> localtime_r FMT_NOMACRO(...) { return null<>(); } -inline null<> localtime_s(...) { return null<>(); } -inline null<> gmtime_r(...) { return null<>(); } -inline null<> gmtime_s(...) { return null<>(); } -} // namespace internal - -// Thread-safe replacement for std::localtime -inline std::tm localtime(std::time_t time) { - struct dispatcher { - std::time_t time_; - std::tm tm_; - - dispatcher(std::time_t t) : time_(t) {} - - bool run() { - using namespace fmt::internal; - return handle(localtime_r(&time_, &tm_)); - } - - bool handle(std::tm* tm) { return tm != nullptr; } - - bool handle(internal::null<>) { - using namespace fmt::internal; - return fallback(localtime_s(&tm_, &time_)); - } - - bool fallback(int res) { return res == 0; } - -#if !FMT_MSC_VER - bool fallback(internal::null<>) { - using namespace fmt::internal; - std::tm* tm = std::localtime(&time_); - if (tm) tm_ = *tm; - return tm != nullptr; - } -#endif - }; - dispatcher lt(time); - // Too big time values may be unsupported. - if (!lt.run()) FMT_THROW(format_error("time_t value out of range")); - return lt.tm_; -} - -// Thread-safe replacement for std::gmtime -inline std::tm gmtime(std::time_t time) { - struct dispatcher { - std::time_t time_; - std::tm tm_; - - dispatcher(std::time_t t) : time_(t) {} - - bool run() { - using namespace fmt::internal; - return handle(gmtime_r(&time_, &tm_)); - } - - bool handle(std::tm* tm) { return tm != nullptr; } - - bool handle(internal::null<>) { - using namespace fmt::internal; - return fallback(gmtime_s(&tm_, &time_)); - } - - bool fallback(int res) { return res == 0; } - -#if !FMT_MSC_VER - bool fallback(internal::null<>) { - std::tm* tm = std::gmtime(&time_); - if (tm) tm_ = *tm; - return tm != nullptr; - } -#endif - }; - dispatcher gt(time); - // Too big time values may be unsupported. - if (!gt.run()) FMT_THROW(format_error("time_t value out of range")); - return gt.tm_; -} - -namespace internal { -inline std::size_t strftime(char* str, std::size_t count, const char* format, - const std::tm* time) { - return std::strftime(str, count, format, time); -} - -inline std::size_t strftime(wchar_t* str, std::size_t count, - const wchar_t* format, const std::tm* time) { - return std::wcsftime(str, count, format, time); -} -} // namespace internal - -template struct formatter { - template - auto parse(ParseContext& ctx) -> decltype(ctx.begin()) { - auto it = ctx.begin(); - if (it != ctx.end() && *it == ':') ++it; - auto end = it; - while (end != ctx.end() && *end != '}') ++end; - tm_format.reserve(internal::to_unsigned(end - it + 1)); - tm_format.append(it, end); - tm_format.push_back('\0'); - return end; - } - - template - auto format(const std::tm& tm, FormatContext& ctx) -> decltype(ctx.out()) { - basic_memory_buffer buf; - std::size_t start = buf.size(); - for (;;) { - std::size_t size = buf.capacity() - start; - std::size_t count = - internal::strftime(&buf[start], size, &tm_format[0], &tm); - if (count != 0) { - buf.resize(start + count); - break; - } - if (size >= tm_format.size() * 256) { - // If the buffer is 256 times larger than the format string, assume - // that `strftime` gives an empty result. There doesn't seem to be a - // better way to distinguish the two cases: - // https://github.com/fmtlib/fmt/issues/367 - break; - } - const std::size_t MIN_GROWTH = 10; - buf.reserve(buf.capacity() + (size > MIN_GROWTH ? size : MIN_GROWTH)); - } - return std::copy(buf.begin(), buf.end(), ctx.out()); - } - - basic_memory_buffer tm_format; -}; - -namespace internal { -template FMT_CONSTEXPR const char* get_units() { - return nullptr; -} -template <> FMT_CONSTEXPR const char* get_units() { return "as"; } -template <> FMT_CONSTEXPR const char* get_units() { return "fs"; } -template <> FMT_CONSTEXPR const char* get_units() { return "ps"; } -template <> FMT_CONSTEXPR const char* get_units() { return "ns"; } -template <> FMT_CONSTEXPR const char* get_units() { return "µs"; } -template <> FMT_CONSTEXPR const char* get_units() { return "ms"; } -template <> FMT_CONSTEXPR const char* get_units() { return "cs"; } -template <> FMT_CONSTEXPR const char* get_units() { return "ds"; } -template <> FMT_CONSTEXPR const char* get_units>() { return "s"; } -template <> FMT_CONSTEXPR const char* get_units() { return "das"; } -template <> FMT_CONSTEXPR const char* get_units() { return "hs"; } -template <> FMT_CONSTEXPR const char* get_units() { return "ks"; } -template <> FMT_CONSTEXPR const char* get_units() { return "Ms"; } -template <> FMT_CONSTEXPR const char* get_units() { return "Gs"; } -template <> FMT_CONSTEXPR const char* get_units() { return "Ts"; } -template <> FMT_CONSTEXPR const char* get_units() { return "Ps"; } -template <> FMT_CONSTEXPR const char* get_units() { return "Es"; } -template <> FMT_CONSTEXPR const char* get_units>() { - return "m"; -} -template <> FMT_CONSTEXPR const char* get_units>() { - return "h"; -} - -enum class numeric_system { - standard, - // Alternative numeric system, e.g. 十二 instead of 12 in ja_JP locale. - alternative -}; - -// Parses a put_time-like format string and invokes handler actions. -template -FMT_CONSTEXPR const Char* parse_chrono_format(const Char* begin, - const Char* end, - Handler&& handler) { - auto ptr = begin; - while (ptr != end) { - auto c = *ptr; - if (c == '}') break; - if (c != '%') { - ++ptr; - continue; - } - if (begin != ptr) handler.on_text(begin, ptr); - ++ptr; // consume '%' - if (ptr == end) FMT_THROW(format_error("invalid format")); - c = *ptr++; - switch (c) { - case '%': - handler.on_text(ptr - 1, ptr); - break; - case 'n': { - const char newline[] = "\n"; - handler.on_text(newline, newline + 1); - break; - } - case 't': { - const char tab[] = "\t"; - handler.on_text(tab, tab + 1); - break; - } - // Day of the week: - case 'a': - handler.on_abbr_weekday(); - break; - case 'A': - handler.on_full_weekday(); - break; - case 'w': - handler.on_dec0_weekday(numeric_system::standard); - break; - case 'u': - handler.on_dec1_weekday(numeric_system::standard); - break; - // Month: - case 'b': - handler.on_abbr_month(); - break; - case 'B': - handler.on_full_month(); - break; - // Hour, minute, second: - case 'H': - handler.on_24_hour(numeric_system::standard); - break; - case 'I': - handler.on_12_hour(numeric_system::standard); - break; - case 'M': - handler.on_minute(numeric_system::standard); - break; - case 'S': - handler.on_second(numeric_system::standard); - break; - // Other: - case 'c': - handler.on_datetime(numeric_system::standard); - break; - case 'x': - handler.on_loc_date(numeric_system::standard); - break; - case 'X': - handler.on_loc_time(numeric_system::standard); - break; - case 'D': - handler.on_us_date(); - break; - case 'F': - handler.on_iso_date(); - break; - case 'r': - handler.on_12_hour_time(); - break; - case 'R': - handler.on_24_hour_time(); - break; - case 'T': - handler.on_iso_time(); - break; - case 'p': - handler.on_am_pm(); - break; - case 'Q': - handler.on_duration_value(); - break; - case 'q': - handler.on_duration_unit(); - break; - case 'z': - handler.on_utc_offset(); - break; - case 'Z': - handler.on_tz_name(); - break; - // Alternative representation: - case 'E': { - if (ptr == end) FMT_THROW(format_error("invalid format")); - c = *ptr++; - switch (c) { - case 'c': - handler.on_datetime(numeric_system::alternative); - break; - case 'x': - handler.on_loc_date(numeric_system::alternative); - break; - case 'X': - handler.on_loc_time(numeric_system::alternative); - break; - default: - FMT_THROW(format_error("invalid format")); - } - break; - } - case 'O': - if (ptr == end) FMT_THROW(format_error("invalid format")); - c = *ptr++; - switch (c) { - case 'w': - handler.on_dec0_weekday(numeric_system::alternative); - break; - case 'u': - handler.on_dec1_weekday(numeric_system::alternative); - break; - case 'H': - handler.on_24_hour(numeric_system::alternative); - break; - case 'I': - handler.on_12_hour(numeric_system::alternative); - break; - case 'M': - handler.on_minute(numeric_system::alternative); - break; - case 'S': - handler.on_second(numeric_system::alternative); - break; - default: - FMT_THROW(format_error("invalid format")); - } - break; - default: - FMT_THROW(format_error("invalid format")); - } - begin = ptr; - } - if (begin != ptr) handler.on_text(begin, ptr); - return ptr; -} - -struct chrono_format_checker { - FMT_NORETURN void report_no_date() { FMT_THROW(format_error("no date")); } - - template void on_text(const Char*, const Char*) {} - FMT_NORETURN void on_abbr_weekday() { report_no_date(); } - FMT_NORETURN void on_full_weekday() { report_no_date(); } - FMT_NORETURN void on_dec0_weekday(numeric_system) { report_no_date(); } - FMT_NORETURN void on_dec1_weekday(numeric_system) { report_no_date(); } - FMT_NORETURN void on_abbr_month() { report_no_date(); } - FMT_NORETURN void on_full_month() { report_no_date(); } - void on_24_hour(numeric_system) {} - void on_12_hour(numeric_system) {} - void on_minute(numeric_system) {} - void on_second(numeric_system) {} - FMT_NORETURN void on_datetime(numeric_system) { report_no_date(); } - FMT_NORETURN void on_loc_date(numeric_system) { report_no_date(); } - FMT_NORETURN void on_loc_time(numeric_system) { report_no_date(); } - FMT_NORETURN void on_us_date() { report_no_date(); } - FMT_NORETURN void on_iso_date() { report_no_date(); } - void on_12_hour_time() {} - void on_24_hour_time() {} - void on_iso_time() {} - void on_am_pm() {} - void on_duration_value() {} - void on_duration_unit() {} - FMT_NORETURN void on_utc_offset() { report_no_date(); } - FMT_NORETURN void on_tz_name() { report_no_date(); } -}; - -template ::value)> -inline bool isnan(T) { - return false; -} -template ::value)> -inline bool isnan(T value) { - return std::isnan(value); -} - -template ::value)> -inline bool isfinite(T) { - return true; -} -template ::value)> -inline bool isfinite(T value) { - return std::isfinite(value); -} - -// Converts value to int and checks that it's in the range [0, upper). -template ::value)> -inline int to_nonnegative_int(T value, int upper) { - FMT_ASSERT(value >= 0 && value <= upper, "invalid value"); - (void)upper; - return static_cast(value); -} -template ::value)> -inline int to_nonnegative_int(T value, int upper) { - FMT_ASSERT( - std::isnan(value) || (value >= 0 && value <= static_cast(upper)), - "invalid value"); - (void)upper; - return static_cast(value); -} - -template ::value)> -inline T mod(T x, int y) { - return x % static_cast(y); -} -template ::value)> -inline T mod(T x, int y) { - return std::fmod(x, static_cast(y)); -} - -// If T is an integral type, maps T to its unsigned counterpart, otherwise -// leaves it unchanged (unlike std::make_unsigned). -template ::value> -struct make_unsigned_or_unchanged { - using type = T; -}; - -template struct make_unsigned_or_unchanged { - using type = typename std::make_unsigned::type; -}; - -#if FMT_SAFE_DURATION_CAST -// throwing version of safe_duration_cast -template -To fmt_safe_duration_cast(std::chrono::duration from) { - int ec; - To to = safe_duration_cast::safe_duration_cast(from, ec); - if (ec) FMT_THROW(format_error("cannot format duration")); - return to; -} -#endif - -template ::value)> -inline std::chrono::duration get_milliseconds( - std::chrono::duration d) { - // this may overflow and/or the result may not fit in the - // target type. -#if FMT_SAFE_DURATION_CAST - using CommonSecondsType = - typename std::common_type::type; - const auto d_as_common = fmt_safe_duration_cast(d); - const auto d_as_whole_seconds = - fmt_safe_duration_cast(d_as_common); - // this conversion should be nonproblematic - const auto diff = d_as_common - d_as_whole_seconds; - const auto ms = - fmt_safe_duration_cast>(diff); - return ms; -#else - auto s = std::chrono::duration_cast(d); - return std::chrono::duration_cast(d - s); -#endif -} - -template ::value)> -inline std::chrono::duration get_milliseconds( - std::chrono::duration d) { - using common_type = typename std::common_type::type; - auto ms = mod(d.count() * static_cast(Period::num) / - static_cast(Period::den) * 1000, - 1000); - return std::chrono::duration(static_cast(ms)); -} - -template -OutputIt format_chrono_duration_value(OutputIt out, Rep val, int precision) { - if (precision >= 0) return format_to(out, "{:.{}f}", val, precision); - return format_to(out, std::is_floating_point::value ? "{:g}" : "{}", - val); -} - -template -static OutputIt format_chrono_duration_unit(OutputIt out) { - if (const char* unit = get_units()) return format_to(out, "{}", unit); - if (Period::den == 1) return format_to(out, "[{}]s", Period::num); - return format_to(out, "[{}/{}]s", Period::num, Period::den); -} - -template -struct chrono_formatter { - FormatContext& context; - OutputIt out; - int precision; - // rep is unsigned to avoid overflow. - using rep = - conditional_t::value && sizeof(Rep) < sizeof(int), - unsigned, typename make_unsigned_or_unchanged::type>; - rep val; - using seconds = std::chrono::duration; - seconds s; - using milliseconds = std::chrono::duration; - bool negative; - - using char_type = typename FormatContext::char_type; - - explicit chrono_formatter(FormatContext& ctx, OutputIt o, - std::chrono::duration d) - : context(ctx), - out(o), - val(static_cast(d.count())), - negative(false) { - if (d.count() < 0) { - val = 0 - val; - negative = true; - } - - // this may overflow and/or the result may not fit in the - // target type. -#if FMT_SAFE_DURATION_CAST - // might need checked conversion (rep!=Rep) - auto tmpval = std::chrono::duration(val); - s = fmt_safe_duration_cast(tmpval); -#else - s = std::chrono::duration_cast( - std::chrono::duration(val)); -#endif - } - - // returns true if nan or inf, writes to out. - bool handle_nan_inf() { - if (isfinite(val)) { - return false; - } - if (isnan(val)) { - write_nan(); - return true; - } - // must be +-inf - if (val > 0) { - write_pinf(); - } else { - write_ninf(); - } - return true; - } - - Rep hour() const { return static_cast(mod((s.count() / 3600), 24)); } - - Rep hour12() const { - Rep hour = static_cast(mod((s.count() / 3600), 12)); - return hour <= 0 ? 12 : hour; - } - - Rep minute() const { return static_cast(mod((s.count() / 60), 60)); } - Rep second() const { return static_cast(mod(s.count(), 60)); } - - std::tm time() const { - auto time = std::tm(); - time.tm_hour = to_nonnegative_int(hour(), 24); - time.tm_min = to_nonnegative_int(minute(), 60); - time.tm_sec = to_nonnegative_int(second(), 60); - return time; - } - - void write_sign() { - if (negative) { - *out++ = '-'; - negative = false; - } - } - - void write(Rep value, int width) { - write_sign(); - if (isnan(value)) return write_nan(); - uint32_or_64_or_128_t n = - to_unsigned(to_nonnegative_int(value, max_value())); - int num_digits = internal::count_digits(n); - if (width > num_digits) out = std::fill_n(out, width - num_digits, '0'); - out = format_decimal(out, n, num_digits); - } - - void write_nan() { std::copy_n("nan", 3, out); } - void write_pinf() { std::copy_n("inf", 3, out); } - void write_ninf() { std::copy_n("-inf", 4, out); } - - void format_localized(const tm& time, const char* format) { - if (isnan(val)) return write_nan(); - auto locale = context.locale().template get(); - auto& facet = std::use_facet>(locale); - std::basic_ostringstream os; - os.imbue(locale); - facet.put(os, os, ' ', &time, format, format + std::strlen(format)); - auto str = os.str(); - std::copy(str.begin(), str.end(), out); - } - - void on_text(const char_type* begin, const char_type* end) { - std::copy(begin, end, out); - } - - // These are not implemented because durations don't have date information. - void on_abbr_weekday() {} - void on_full_weekday() {} - void on_dec0_weekday(numeric_system) {} - void on_dec1_weekday(numeric_system) {} - void on_abbr_month() {} - void on_full_month() {} - void on_datetime(numeric_system) {} - void on_loc_date(numeric_system) {} - void on_loc_time(numeric_system) {} - void on_us_date() {} - void on_iso_date() {} - void on_utc_offset() {} - void on_tz_name() {} - - void on_24_hour(numeric_system ns) { - if (handle_nan_inf()) return; - - if (ns == numeric_system::standard) return write(hour(), 2); - auto time = tm(); - time.tm_hour = to_nonnegative_int(hour(), 24); - format_localized(time, "%OH"); - } - - void on_12_hour(numeric_system ns) { - if (handle_nan_inf()) return; - - if (ns == numeric_system::standard) return write(hour12(), 2); - auto time = tm(); - time.tm_hour = to_nonnegative_int(hour12(), 12); - format_localized(time, "%OI"); - } - - void on_minute(numeric_system ns) { - if (handle_nan_inf()) return; - - if (ns == numeric_system::standard) return write(minute(), 2); - auto time = tm(); - time.tm_min = to_nonnegative_int(minute(), 60); - format_localized(time, "%OM"); - } - - void on_second(numeric_system ns) { - if (handle_nan_inf()) return; - - if (ns == numeric_system::standard) { - write(second(), 2); -#if FMT_SAFE_DURATION_CAST - // convert rep->Rep - using duration_rep = std::chrono::duration; - using duration_Rep = std::chrono::duration; - auto tmpval = fmt_safe_duration_cast(duration_rep{val}); -#else - auto tmpval = std::chrono::duration(val); -#endif - auto ms = get_milliseconds(tmpval); - if (ms != std::chrono::milliseconds(0)) { - *out++ = '.'; - write(ms.count(), 3); - } - return; - } - auto time = tm(); - time.tm_sec = to_nonnegative_int(second(), 60); - format_localized(time, "%OS"); - } - - void on_12_hour_time() { - if (handle_nan_inf()) return; - - format_localized(time(), "%r"); - } - - void on_24_hour_time() { - if (handle_nan_inf()) { - *out++ = ':'; - handle_nan_inf(); - return; - } - - write(hour(), 2); - *out++ = ':'; - write(minute(), 2); - } - - void on_iso_time() { - on_24_hour_time(); - *out++ = ':'; - if (handle_nan_inf()) return; - write(second(), 2); - } - - void on_am_pm() { - if (handle_nan_inf()) return; - format_localized(time(), "%p"); - } - - void on_duration_value() { - if (handle_nan_inf()) return; - write_sign(); - out = format_chrono_duration_value(out, val, precision); - } - - void on_duration_unit() { out = format_chrono_duration_unit(out); } -}; -} // namespace internal - -template -struct formatter, Char> { - private: - basic_format_specs specs; - int precision; - using arg_ref_type = internal::arg_ref; - arg_ref_type width_ref; - arg_ref_type precision_ref; - mutable basic_string_view format_str; - using duration = std::chrono::duration; - - struct spec_handler { - formatter& f; - basic_format_parse_context& context; - basic_string_view format_str; - - template FMT_CONSTEXPR arg_ref_type make_arg_ref(Id arg_id) { - context.check_arg_id(arg_id); - return arg_ref_type(arg_id); - } - - FMT_CONSTEXPR arg_ref_type make_arg_ref(basic_string_view arg_id) { - context.check_arg_id(arg_id); - return arg_ref_type(arg_id); - } - - FMT_CONSTEXPR arg_ref_type make_arg_ref(internal::auto_id) { - return arg_ref_type(context.next_arg_id()); - } - - void on_error(const char* msg) { FMT_THROW(format_error(msg)); } - void on_fill(Char fill) { f.specs.fill[0] = fill; } - void on_align(align_t align) { f.specs.align = align; } - void on_width(int width) { f.specs.width = width; } - void on_precision(int _precision) { f.precision = _precision; } - void end_precision() {} - - template void on_dynamic_width(Id arg_id) { - f.width_ref = make_arg_ref(arg_id); - } - - template void on_dynamic_precision(Id arg_id) { - f.precision_ref = make_arg_ref(arg_id); - } - }; - - using iterator = typename basic_format_parse_context::iterator; - struct parse_range { - iterator begin; - iterator end; - }; - - FMT_CONSTEXPR parse_range do_parse(basic_format_parse_context& ctx) { - auto begin = ctx.begin(), end = ctx.end(); - if (begin == end || *begin == '}') return {begin, begin}; - spec_handler handler{*this, ctx, format_str}; - begin = internal::parse_align(begin, end, handler); - if (begin == end) return {begin, begin}; - begin = internal::parse_width(begin, end, handler); - if (begin == end) return {begin, begin}; - if (*begin == '.') { - if (std::is_floating_point::value) - begin = internal::parse_precision(begin, end, handler); - else - handler.on_error("precision not allowed for this argument type"); - } - end = parse_chrono_format(begin, end, internal::chrono_format_checker()); - return {begin, end}; - } - - public: - formatter() : precision(-1) {} - - FMT_CONSTEXPR auto parse(basic_format_parse_context& ctx) - -> decltype(ctx.begin()) { - auto range = do_parse(ctx); - format_str = basic_string_view( - &*range.begin, internal::to_unsigned(range.end - range.begin)); - return range.end; - } - - template - auto format(const duration& d, FormatContext& ctx) -> decltype(ctx.out()) { - auto begin = format_str.begin(), end = format_str.end(); - // As a possible future optimization, we could avoid extra copying if width - // is not specified. - basic_memory_buffer buf; - auto out = std::back_inserter(buf); - using range = internal::output_range; - internal::basic_writer w(range(ctx.out())); - internal::handle_dynamic_spec(specs.width, - width_ref, ctx); - internal::handle_dynamic_spec( - precision, precision_ref, ctx); - if (begin == end || *begin == '}') { - out = internal::format_chrono_duration_value(out, d.count(), precision); - internal::format_chrono_duration_unit(out); - } else { - internal::chrono_formatter f( - ctx, out, d); - f.precision = precision; - parse_chrono_format(begin, end, f); - } - w.write(buf.data(), buf.size(), specs); - return w.out(); - } -}; - -FMT_END_NAMESPACE - -#endif // FMT_CHRONO_H_ diff --git a/headers/papilo/external/fmt/color.h b/headers/papilo/external/fmt/color.h deleted file mode 100644 index 362a95e..0000000 --- a/headers/papilo/external/fmt/color.h +++ /dev/null @@ -1,570 +0,0 @@ -// Formatting library for C++ - color support -// -// Copyright (c) 2018 - present, Victor Zverovich and fmt contributors -// All rights reserved. -// -// For the license information refer to format.h. - -#ifndef FMT_COLOR_H_ -#define FMT_COLOR_H_ - -#include "format.h" - -FMT_BEGIN_NAMESPACE - -enum class color : uint32_t { - alice_blue = 0xF0F8FF, // rgb(240,248,255) - antique_white = 0xFAEBD7, // rgb(250,235,215) - aqua = 0x00FFFF, // rgb(0,255,255) - aquamarine = 0x7FFFD4, // rgb(127,255,212) - azure = 0xF0FFFF, // rgb(240,255,255) - beige = 0xF5F5DC, // rgb(245,245,220) - bisque = 0xFFE4C4, // rgb(255,228,196) - black = 0x000000, // rgb(0,0,0) - blanched_almond = 0xFFEBCD, // rgb(255,235,205) - blue = 0x0000FF, // rgb(0,0,255) - blue_violet = 0x8A2BE2, // rgb(138,43,226) - brown = 0xA52A2A, // rgb(165,42,42) - burly_wood = 0xDEB887, // rgb(222,184,135) - cadet_blue = 0x5F9EA0, // rgb(95,158,160) - chartreuse = 0x7FFF00, // rgb(127,255,0) - chocolate = 0xD2691E, // rgb(210,105,30) - coral = 0xFF7F50, // rgb(255,127,80) - cornflower_blue = 0x6495ED, // rgb(100,149,237) - cornsilk = 0xFFF8DC, // rgb(255,248,220) - crimson = 0xDC143C, // rgb(220,20,60) - cyan = 0x00FFFF, // rgb(0,255,255) - dark_blue = 0x00008B, // rgb(0,0,139) - dark_cyan = 0x008B8B, // rgb(0,139,139) - dark_golden_rod = 0xB8860B, // rgb(184,134,11) - dark_gray = 0xA9A9A9, // rgb(169,169,169) - dark_green = 0x006400, // rgb(0,100,0) - dark_khaki = 0xBDB76B, // rgb(189,183,107) - dark_magenta = 0x8B008B, // rgb(139,0,139) - dark_olive_green = 0x556B2F, // rgb(85,107,47) - dark_orange = 0xFF8C00, // rgb(255,140,0) - dark_orchid = 0x9932CC, // rgb(153,50,204) - dark_red = 0x8B0000, // rgb(139,0,0) - dark_salmon = 0xE9967A, // rgb(233,150,122) - dark_sea_green = 0x8FBC8F, // rgb(143,188,143) - dark_slate_blue = 0x483D8B, // rgb(72,61,139) - dark_slate_gray = 0x2F4F4F, // rgb(47,79,79) - dark_turquoise = 0x00CED1, // rgb(0,206,209) - dark_violet = 0x9400D3, // rgb(148,0,211) - deep_pink = 0xFF1493, // rgb(255,20,147) - deep_sky_blue = 0x00BFFF, // rgb(0,191,255) - dim_gray = 0x696969, // rgb(105,105,105) - dodger_blue = 0x1E90FF, // rgb(30,144,255) - fire_brick = 0xB22222, // rgb(178,34,34) - floral_white = 0xFFFAF0, // rgb(255,250,240) - forest_green = 0x228B22, // rgb(34,139,34) - fuchsia = 0xFF00FF, // rgb(255,0,255) - gainsboro = 0xDCDCDC, // rgb(220,220,220) - ghost_white = 0xF8F8FF, // rgb(248,248,255) - gold = 0xFFD700, // rgb(255,215,0) - golden_rod = 0xDAA520, // rgb(218,165,32) - gray = 0x808080, // rgb(128,128,128) - green = 0x008000, // rgb(0,128,0) - green_yellow = 0xADFF2F, // rgb(173,255,47) - honey_dew = 0xF0FFF0, // rgb(240,255,240) - hot_pink = 0xFF69B4, // rgb(255,105,180) - indian_red = 0xCD5C5C, // rgb(205,92,92) - indigo = 0x4B0082, // rgb(75,0,130) - ivory = 0xFFFFF0, // rgb(255,255,240) - khaki = 0xF0E68C, // rgb(240,230,140) - lavender = 0xE6E6FA, // rgb(230,230,250) - lavender_blush = 0xFFF0F5, // rgb(255,240,245) - lawn_green = 0x7CFC00, // rgb(124,252,0) - lemon_chiffon = 0xFFFACD, // rgb(255,250,205) - light_blue = 0xADD8E6, // rgb(173,216,230) - light_coral = 0xF08080, // rgb(240,128,128) - light_cyan = 0xE0FFFF, // rgb(224,255,255) - light_golden_rod_yellow = 0xFAFAD2, // rgb(250,250,210) - light_gray = 0xD3D3D3, // rgb(211,211,211) - light_green = 0x90EE90, // rgb(144,238,144) - light_pink = 0xFFB6C1, // rgb(255,182,193) - light_salmon = 0xFFA07A, // rgb(255,160,122) - light_sea_green = 0x20B2AA, // rgb(32,178,170) - light_sky_blue = 0x87CEFA, // rgb(135,206,250) - light_slate_gray = 0x778899, // rgb(119,136,153) - light_steel_blue = 0xB0C4DE, // rgb(176,196,222) - light_yellow = 0xFFFFE0, // rgb(255,255,224) - lime = 0x00FF00, // rgb(0,255,0) - lime_green = 0x32CD32, // rgb(50,205,50) - linen = 0xFAF0E6, // rgb(250,240,230) - magenta = 0xFF00FF, // rgb(255,0,255) - maroon = 0x800000, // rgb(128,0,0) - medium_aquamarine = 0x66CDAA, // rgb(102,205,170) - medium_blue = 0x0000CD, // rgb(0,0,205) - medium_orchid = 0xBA55D3, // rgb(186,85,211) - medium_purple = 0x9370DB, // rgb(147,112,219) - medium_sea_green = 0x3CB371, // rgb(60,179,113) - medium_slate_blue = 0x7B68EE, // rgb(123,104,238) - medium_spring_green = 0x00FA9A, // rgb(0,250,154) - medium_turquoise = 0x48D1CC, // rgb(72,209,204) - medium_violet_red = 0xC71585, // rgb(199,21,133) - midnight_blue = 0x191970, // rgb(25,25,112) - mint_cream = 0xF5FFFA, // rgb(245,255,250) - misty_rose = 0xFFE4E1, // rgb(255,228,225) - moccasin = 0xFFE4B5, // rgb(255,228,181) - navajo_white = 0xFFDEAD, // rgb(255,222,173) - navy = 0x000080, // rgb(0,0,128) - old_lace = 0xFDF5E6, // rgb(253,245,230) - olive = 0x808000, // rgb(128,128,0) - olive_drab = 0x6B8E23, // rgb(107,142,35) - orange = 0xFFA500, // rgb(255,165,0) - orange_red = 0xFF4500, // rgb(255,69,0) - orchid = 0xDA70D6, // rgb(218,112,214) - pale_golden_rod = 0xEEE8AA, // rgb(238,232,170) - pale_green = 0x98FB98, // rgb(152,251,152) - pale_turquoise = 0xAFEEEE, // rgb(175,238,238) - pale_violet_red = 0xDB7093, // rgb(219,112,147) - papaya_whip = 0xFFEFD5, // rgb(255,239,213) - peach_puff = 0xFFDAB9, // rgb(255,218,185) - peru = 0xCD853F, // rgb(205,133,63) - pink = 0xFFC0CB, // rgb(255,192,203) - plum = 0xDDA0DD, // rgb(221,160,221) - powder_blue = 0xB0E0E6, // rgb(176,224,230) - purple = 0x800080, // rgb(128,0,128) - rebecca_purple = 0x663399, // rgb(102,51,153) - red = 0xFF0000, // rgb(255,0,0) - rosy_brown = 0xBC8F8F, // rgb(188,143,143) - royal_blue = 0x4169E1, // rgb(65,105,225) - saddle_brown = 0x8B4513, // rgb(139,69,19) - salmon = 0xFA8072, // rgb(250,128,114) - sandy_brown = 0xF4A460, // rgb(244,164,96) - sea_green = 0x2E8B57, // rgb(46,139,87) - sea_shell = 0xFFF5EE, // rgb(255,245,238) - sienna = 0xA0522D, // rgb(160,82,45) - silver = 0xC0C0C0, // rgb(192,192,192) - sky_blue = 0x87CEEB, // rgb(135,206,235) - slate_blue = 0x6A5ACD, // rgb(106,90,205) - slate_gray = 0x708090, // rgb(112,128,144) - snow = 0xFFFAFA, // rgb(255,250,250) - spring_green = 0x00FF7F, // rgb(0,255,127) - steel_blue = 0x4682B4, // rgb(70,130,180) - tan = 0xD2B48C, // rgb(210,180,140) - teal = 0x008080, // rgb(0,128,128) - thistle = 0xD8BFD8, // rgb(216,191,216) - tomato = 0xFF6347, // rgb(255,99,71) - turquoise = 0x40E0D0, // rgb(64,224,208) - violet = 0xEE82EE, // rgb(238,130,238) - wheat = 0xF5DEB3, // rgb(245,222,179) - white = 0xFFFFFF, // rgb(255,255,255) - white_smoke = 0xF5F5F5, // rgb(245,245,245) - yellow = 0xFFFF00, // rgb(255,255,0) - yellow_green = 0x9ACD32 // rgb(154,205,50) -}; // enum class color - -enum class terminal_color : uint8_t { - black = 30, - red, - green, - yellow, - blue, - magenta, - cyan, - white, - bright_black = 90, - bright_red, - bright_green, - bright_yellow, - bright_blue, - bright_magenta, - bright_cyan, - bright_white -}; - -enum class emphasis : uint8_t { - bold = 1, - italic = 1 << 1, - underline = 1 << 2, - strikethrough = 1 << 3 -}; - -// rgb is a struct for red, green and blue colors. -// Using the name "rgb" makes some editors show the color in a tooltip. -struct rgb { - FMT_CONSTEXPR rgb() : r(0), g(0), b(0) {} - FMT_CONSTEXPR rgb(uint8_t r_, uint8_t g_, uint8_t b_) : r(r_), g(g_), b(b_) {} - FMT_CONSTEXPR rgb(uint32_t hex) - : r((hex >> 16) & 0xFF), g((hex >> 8) & 0xFF), b(hex & 0xFF) {} - FMT_CONSTEXPR rgb(color hex) - : r((uint32_t(hex) >> 16) & 0xFF), - g((uint32_t(hex) >> 8) & 0xFF), - b(uint32_t(hex) & 0xFF) {} - uint8_t r; - uint8_t g; - uint8_t b; -}; - -namespace internal { - -// color is a struct of either a rgb color or a terminal color. -struct color_type { - FMT_CONSTEXPR color_type() FMT_NOEXCEPT : is_rgb(), value{} {} - FMT_CONSTEXPR color_type(color rgb_color) FMT_NOEXCEPT : is_rgb(true), - value{} { - value.rgb_color = static_cast(rgb_color); - } - FMT_CONSTEXPR color_type(rgb rgb_color) FMT_NOEXCEPT : is_rgb(true), value{} { - value.rgb_color = (static_cast(rgb_color.r) << 16) | - (static_cast(rgb_color.g) << 8) | rgb_color.b; - } - FMT_CONSTEXPR color_type(terminal_color term_color) FMT_NOEXCEPT : is_rgb(), - value{} { - value.term_color = static_cast(term_color); - } - bool is_rgb; - union color_union { - uint8_t term_color; - uint32_t rgb_color; - } value; -}; -} // namespace internal - -// Experimental text formatting support. -class text_style { - public: - FMT_CONSTEXPR text_style(emphasis em = emphasis()) FMT_NOEXCEPT - : set_foreground_color(), - set_background_color(), - ems(em) {} - - FMT_CONSTEXPR text_style& operator|=(const text_style& rhs) { - if (!set_foreground_color) { - set_foreground_color = rhs.set_foreground_color; - foreground_color = rhs.foreground_color; - } else if (rhs.set_foreground_color) { - if (!foreground_color.is_rgb || !rhs.foreground_color.is_rgb) - FMT_THROW(format_error("can't OR a terminal color")); - foreground_color.value.rgb_color |= rhs.foreground_color.value.rgb_color; - } - - if (!set_background_color) { - set_background_color = rhs.set_background_color; - background_color = rhs.background_color; - } else if (rhs.set_background_color) { - if (!background_color.is_rgb || !rhs.background_color.is_rgb) - FMT_THROW(format_error("can't OR a terminal color")); - background_color.value.rgb_color |= rhs.background_color.value.rgb_color; - } - - ems = static_cast(static_cast(ems) | - static_cast(rhs.ems)); - return *this; - } - - friend FMT_CONSTEXPR text_style operator|(text_style lhs, - const text_style& rhs) { - return lhs |= rhs; - } - - FMT_CONSTEXPR text_style& operator&=(const text_style& rhs) { - if (!set_foreground_color) { - set_foreground_color = rhs.set_foreground_color; - foreground_color = rhs.foreground_color; - } else if (rhs.set_foreground_color) { - if (!foreground_color.is_rgb || !rhs.foreground_color.is_rgb) - FMT_THROW(format_error("can't AND a terminal color")); - foreground_color.value.rgb_color &= rhs.foreground_color.value.rgb_color; - } - - if (!set_background_color) { - set_background_color = rhs.set_background_color; - background_color = rhs.background_color; - } else if (rhs.set_background_color) { - if (!background_color.is_rgb || !rhs.background_color.is_rgb) - FMT_THROW(format_error("can't AND a terminal color")); - background_color.value.rgb_color &= rhs.background_color.value.rgb_color; - } - - ems = static_cast(static_cast(ems) & - static_cast(rhs.ems)); - return *this; - } - - friend FMT_CONSTEXPR text_style operator&(text_style lhs, - const text_style& rhs) { - return lhs &= rhs; - } - - FMT_CONSTEXPR bool has_foreground() const FMT_NOEXCEPT { - return set_foreground_color; - } - FMT_CONSTEXPR bool has_background() const FMT_NOEXCEPT { - return set_background_color; - } - FMT_CONSTEXPR bool has_emphasis() const FMT_NOEXCEPT { - return static_cast(ems) != 0; - } - FMT_CONSTEXPR internal::color_type get_foreground() const FMT_NOEXCEPT { - FMT_ASSERT(has_foreground(), "no foreground specified for this style"); - return foreground_color; - } - FMT_CONSTEXPR internal::color_type get_background() const FMT_NOEXCEPT { - FMT_ASSERT(has_background(), "no background specified for this style"); - return background_color; - } - FMT_CONSTEXPR emphasis get_emphasis() const FMT_NOEXCEPT { - FMT_ASSERT(has_emphasis(), "no emphasis specified for this style"); - return ems; - } - - private: - FMT_CONSTEXPR text_style(bool is_foreground, - internal::color_type text_color) FMT_NOEXCEPT - : set_foreground_color(), - set_background_color(), - ems() { - if (is_foreground) { - foreground_color = text_color; - set_foreground_color = true; - } else { - background_color = text_color; - set_background_color = true; - } - } - - friend FMT_CONSTEXPR_DECL text_style fg(internal::color_type foreground) - FMT_NOEXCEPT; - friend FMT_CONSTEXPR_DECL text_style bg(internal::color_type background) - FMT_NOEXCEPT; - - internal::color_type foreground_color; - internal::color_type background_color; - bool set_foreground_color; - bool set_background_color; - emphasis ems; -}; - -FMT_CONSTEXPR text_style fg(internal::color_type foreground) FMT_NOEXCEPT { - return text_style(/*is_foreground=*/true, foreground); -} - -FMT_CONSTEXPR text_style bg(internal::color_type background) FMT_NOEXCEPT { - return text_style(/*is_foreground=*/false, background); -} - -FMT_CONSTEXPR text_style operator|(emphasis lhs, emphasis rhs) FMT_NOEXCEPT { - return text_style(lhs) | rhs; -} - -namespace internal { - -template struct ansi_color_escape { - FMT_CONSTEXPR ansi_color_escape(internal::color_type text_color, - const char* esc) FMT_NOEXCEPT { - // If we have a terminal color, we need to output another escape code - // sequence. - if (!text_color.is_rgb) { - bool is_background = esc == internal::data::background_color; - uint32_t value = text_color.value.term_color; - // Background ASCII codes are the same as the foreground ones but with - // 10 more. - if (is_background) value += 10u; - - std::size_t index = 0; - buffer[index++] = static_cast('\x1b'); - buffer[index++] = static_cast('['); - - if (value >= 100u) { - buffer[index++] = static_cast('1'); - value %= 100u; - } - buffer[index++] = static_cast('0' + value / 10u); - buffer[index++] = static_cast('0' + value % 10u); - - buffer[index++] = static_cast('m'); - buffer[index++] = static_cast('\0'); - return; - } - - for (int i = 0; i < 7; i++) { - buffer[i] = static_cast(esc[i]); - } - rgb color(text_color.value.rgb_color); - to_esc(color.r, buffer + 7, ';'); - to_esc(color.g, buffer + 11, ';'); - to_esc(color.b, buffer + 15, 'm'); - buffer[19] = static_cast(0); - } - FMT_CONSTEXPR ansi_color_escape(emphasis em) FMT_NOEXCEPT { - uint8_t em_codes[4] = {}; - uint8_t em_bits = static_cast(em); - if (em_bits & static_cast(emphasis::bold)) em_codes[0] = 1; - if (em_bits & static_cast(emphasis::italic)) em_codes[1] = 3; - if (em_bits & static_cast(emphasis::underline)) em_codes[2] = 4; - if (em_bits & static_cast(emphasis::strikethrough)) - em_codes[3] = 9; - - std::size_t index = 0; - for (int i = 0; i < 4; ++i) { - if (!em_codes[i]) continue; - buffer[index++] = static_cast('\x1b'); - buffer[index++] = static_cast('['); - buffer[index++] = static_cast('0' + em_codes[i]); - buffer[index++] = static_cast('m'); - } - buffer[index++] = static_cast(0); - } - FMT_CONSTEXPR operator const Char*() const FMT_NOEXCEPT { return buffer; } - - FMT_CONSTEXPR const Char* begin() const FMT_NOEXCEPT { return buffer; } - FMT_CONSTEXPR const Char* end() const FMT_NOEXCEPT { - return buffer + std::strlen(buffer); - } - - private: - Char buffer[7u + 3u * 4u + 1u]; - - static FMT_CONSTEXPR void to_esc(uint8_t c, Char* out, - char delimiter) FMT_NOEXCEPT { - out[0] = static_cast('0' + c / 100); - out[1] = static_cast('0' + c / 10 % 10); - out[2] = static_cast('0' + c % 10); - out[3] = static_cast(delimiter); - } -}; - -template -FMT_CONSTEXPR ansi_color_escape make_foreground_color( - internal::color_type foreground) FMT_NOEXCEPT { - return ansi_color_escape(foreground, internal::data::foreground_color); -} - -template -FMT_CONSTEXPR ansi_color_escape make_background_color( - internal::color_type background) FMT_NOEXCEPT { - return ansi_color_escape(background, internal::data::background_color); -} - -template -FMT_CONSTEXPR ansi_color_escape make_emphasis(emphasis em) FMT_NOEXCEPT { - return ansi_color_escape(em); -} - -template -inline void fputs(const Char* chars, FILE* stream) FMT_NOEXCEPT { - std::fputs(chars, stream); -} - -template <> -inline void fputs(const wchar_t* chars, FILE* stream) FMT_NOEXCEPT { - std::fputws(chars, stream); -} - -template inline void reset_color(FILE* stream) FMT_NOEXCEPT { - fputs(internal::data::reset_color, stream); -} - -template <> inline void reset_color(FILE* stream) FMT_NOEXCEPT { - fputs(internal::data::wreset_color, stream); -} - -template -inline void reset_color(basic_memory_buffer& buffer) FMT_NOEXCEPT { - const char* begin = data::reset_color; - const char* end = begin + sizeof(data::reset_color) - 1; - buffer.append(begin, end); -} - -template -void vformat_to(basic_memory_buffer& buf, const text_style& ts, - basic_string_view format_str, - basic_format_args> args) { - bool has_style = false; - if (ts.has_emphasis()) { - has_style = true; - auto emphasis = internal::make_emphasis(ts.get_emphasis()); - buf.append(emphasis.begin(), emphasis.end()); - } - if (ts.has_foreground()) { - has_style = true; - auto foreground = - internal::make_foreground_color(ts.get_foreground()); - buf.append(foreground.begin(), foreground.end()); - } - if (ts.has_background()) { - has_style = true; - auto background = - internal::make_background_color(ts.get_background()); - buf.append(background.begin(), background.end()); - } - vformat_to(buf, format_str, args); - if (has_style) { - internal::reset_color(buf); - } -} -} // namespace internal - -template > -void vprint(std::FILE* f, const text_style& ts, const S& format, - basic_format_args> args) { - basic_memory_buffer buf; - internal::vformat_to(buf, ts, to_string_view(format), args); - buf.push_back(Char(0)); - internal::fputs(buf.data(), f); -} - -/** - Formats a string and prints it to the specified file stream using ANSI - escape sequences to specify text formatting. - Example: - fmt::print(fmt::emphasis::bold | fg(fmt::color::red), - "Elapsed time: {0:.2f} seconds", 1.23); - */ -template ::value)> -void print(std::FILE* f, const text_style& ts, const S& format_str, - const Args&... args) { - internal::check_format_string(format_str); - using context = buffer_context>; - format_arg_store as{args...}; - vprint(f, ts, format_str, basic_format_args(as)); -} - -/** - Formats a string and prints it to stdout using ANSI escape sequences to - specify text formatting. - Example: - fmt::print(fmt::emphasis::bold | fg(fmt::color::red), - "Elapsed time: {0:.2f} seconds", 1.23); - */ -template ::value)> -void print(const text_style& ts, const S& format_str, const Args&... args) { - return print(stdout, ts, format_str, args...); -} - -template > -inline std::basic_string vformat( - const text_style& ts, const S& format_str, - basic_format_args> args) { - basic_memory_buffer buf; - internal::vformat_to(buf, ts, to_string_view(format_str), args); - return fmt::to_string(buf); -} - -/** - \rst - Formats arguments and returns the result as a string using ANSI - escape sequences to specify text formatting. - - **Example**:: - - #include - std::string message = fmt::format(fmt::emphasis::bold | fg(fmt::color::red), - "The answer is {}", 42); - \endrst -*/ -template > -inline std::basic_string format(const text_style& ts, const S& format_str, - const Args&... args) { - return vformat(ts, to_string_view(format_str), - {internal::make_args_checked(format_str, args...)}); -} - -FMT_END_NAMESPACE - -#endif // FMT_COLOR_H_ diff --git a/headers/papilo/external/fmt/compile.h b/headers/papilo/external/fmt/compile.h deleted file mode 100644 index 5829f62..0000000 --- a/headers/papilo/external/fmt/compile.h +++ /dev/null @@ -1,585 +0,0 @@ -// Formatting library for C++ - experimental format string compilation -// -// Copyright (c) 2012 - present, Victor Zverovich and fmt contributors -// All rights reserved. -// -// For the license information refer to format.h. - -#ifndef FMT_COMPILE_H_ -#define FMT_COMPILE_H_ - -#include -#include "format.h" - -FMT_BEGIN_NAMESPACE -namespace internal { - -// Part of a compiled format string. It can be either literal text or a -// replacement field. -template struct format_part { - enum class kind { arg_index, arg_name, text, replacement }; - - struct replacement { - arg_ref arg_id; - dynamic_format_specs specs; - }; - - kind part_kind; - union value { - int arg_index; - basic_string_view str; - replacement repl; - - FMT_CONSTEXPR value(int index = 0) : arg_index(index) {} - FMT_CONSTEXPR value(basic_string_view s) : str(s) {} - FMT_CONSTEXPR value(replacement r) : repl(r) {} - } val; - // Position past the end of the argument id. - const Char* arg_id_end = nullptr; - - FMT_CONSTEXPR format_part(kind k = kind::arg_index, value v = {}) - : part_kind(k), val(v) {} - - static FMT_CONSTEXPR format_part make_arg_index(int index) { - return format_part(kind::arg_index, index); - } - static FMT_CONSTEXPR format_part make_arg_name(basic_string_view name) { - return format_part(kind::arg_name, name); - } - static FMT_CONSTEXPR format_part make_text(basic_string_view text) { - return format_part(kind::text, text); - } - static FMT_CONSTEXPR format_part make_replacement(replacement repl) { - return format_part(kind::replacement, repl); - } -}; - -template struct part_counter { - unsigned num_parts = 0; - - FMT_CONSTEXPR void on_text(const Char* begin, const Char* end) { - if (begin != end) ++num_parts; - } - - FMT_CONSTEXPR void on_arg_id() { ++num_parts; } - FMT_CONSTEXPR void on_arg_id(int) { ++num_parts; } - FMT_CONSTEXPR void on_arg_id(basic_string_view) { ++num_parts; } - - FMT_CONSTEXPR void on_replacement_field(const Char*) {} - - FMT_CONSTEXPR const Char* on_format_specs(const Char* begin, - const Char* end) { - // Find the matching brace. - unsigned brace_counter = 0; - for (; begin != end; ++begin) { - if (*begin == '{') { - ++brace_counter; - } else if (*begin == '}') { - if (brace_counter == 0u) break; - --brace_counter; - } - } - return begin; - } - - FMT_CONSTEXPR void on_error(const char*) {} -}; - -// Counts the number of parts in a format string. -template -FMT_CONSTEXPR unsigned count_parts(basic_string_view format_str) { - part_counter counter; - parse_format_string(format_str, counter); - return counter.num_parts; -} - -template -class format_string_compiler : public error_handler { - private: - using part = format_part; - - PartHandler handler_; - part part_; - basic_string_view format_str_; - basic_format_parse_context parse_context_; - - public: - FMT_CONSTEXPR format_string_compiler(basic_string_view format_str, - PartHandler handler) - : handler_(handler), - format_str_(format_str), - parse_context_(format_str) {} - - FMT_CONSTEXPR void on_text(const Char* begin, const Char* end) { - if (begin != end) - handler_(part::make_text({begin, to_unsigned(end - begin)})); - } - - FMT_CONSTEXPR void on_arg_id() { - part_ = part::make_arg_index(parse_context_.next_arg_id()); - } - - FMT_CONSTEXPR void on_arg_id(int id) { - parse_context_.check_arg_id(id); - part_ = part::make_arg_index(id); - } - - FMT_CONSTEXPR void on_arg_id(basic_string_view id) { - part_ = part::make_arg_name(id); - } - - FMT_CONSTEXPR void on_replacement_field(const Char* ptr) { - part_.arg_id_end = ptr; - handler_(part_); - } - - FMT_CONSTEXPR const Char* on_format_specs(const Char* begin, - const Char* end) { - auto repl = typename part::replacement(); - dynamic_specs_handler> handler( - repl.specs, parse_context_); - auto it = parse_format_specs(begin, end, handler); - if (*it != '}') on_error("missing '}' in format string"); - repl.arg_id = part_.part_kind == part::kind::arg_index - ? arg_ref(part_.val.arg_index) - : arg_ref(part_.val.str); - auto part = part::make_replacement(repl); - part.arg_id_end = begin; - handler_(part); - return it; - } -}; - -// Compiles a format string and invokes handler(part) for each parsed part. -template -FMT_CONSTEXPR void compile_format_string(basic_string_view format_str, - PartHandler handler) { - parse_format_string( - format_str, - format_string_compiler(format_str, handler)); -} - -template -void format_arg( - basic_format_parse_context& parse_ctx, - Context& ctx, Id arg_id) { - ctx.advance_to( - visit_format_arg(arg_formatter(ctx, &parse_ctx), ctx.arg(arg_id))); -} - -// vformat_to is defined in a subnamespace to prevent ADL. -namespace cf { -template -auto vformat_to(Range out, CompiledFormat& cf, basic_format_args args) - -> typename Context::iterator { - using char_type = typename Context::char_type; - basic_format_parse_context parse_ctx( - to_string_view(cf.format_str_)); - Context ctx(out.begin(), args); - - const auto& parts = cf.parts(); - for (auto part_it = std::begin(parts); part_it != std::end(parts); - ++part_it) { - const auto& part = *part_it; - const auto& value = part.val; - - using format_part_t = format_part; - switch (part.part_kind) { - case format_part_t::kind::text: { - const auto text = value.str; - auto output = ctx.out(); - auto&& it = reserve(output, text.size()); - it = std::copy_n(text.begin(), text.size(), it); - ctx.advance_to(output); - break; - } - - case format_part_t::kind::arg_index: - advance_to(parse_ctx, part.arg_id_end); - internal::format_arg(parse_ctx, ctx, value.arg_index); - break; - - case format_part_t::kind::arg_name: - advance_to(parse_ctx, part.arg_id_end); - internal::format_arg(parse_ctx, ctx, value.str); - break; - - case format_part_t::kind::replacement: { - const auto& arg_id_value = value.repl.arg_id.val; - const auto arg = value.repl.arg_id.kind == arg_id_kind::index - ? ctx.arg(arg_id_value.index) - : ctx.arg(arg_id_value.name); - - auto specs = value.repl.specs; - - handle_dynamic_spec(specs.width, specs.width_ref, ctx); - handle_dynamic_spec(specs.precision, - specs.precision_ref, ctx); - - error_handler h; - numeric_specs_checker checker(h, arg.type()); - if (specs.align == align::numeric) checker.require_numeric_argument(); - if (specs.sign != sign::none) checker.check_sign(); - if (specs.alt) checker.require_numeric_argument(); - if (specs.precision >= 0) checker.check_precision(); - - advance_to(parse_ctx, part.arg_id_end); - ctx.advance_to( - visit_format_arg(arg_formatter(ctx, nullptr, &specs), arg)); - break; - } - } - } - return ctx.out(); -} -} // namespace cf - -struct basic_compiled_format {}; - -template -struct compiled_format_base : basic_compiled_format { - using char_type = char_t; - using parts_container = std::vector>; - - parts_container compiled_parts; - - explicit compiled_format_base(basic_string_view format_str) { - compile_format_string(format_str, - [this](const format_part& part) { - compiled_parts.push_back(part); - }); - } - - const parts_container& parts() const { return compiled_parts; } -}; - -template struct format_part_array { - format_part data[N] = {}; - FMT_CONSTEXPR format_part_array() = default; -}; - -template -FMT_CONSTEXPR format_part_array compile_to_parts( - basic_string_view format_str) { - format_part_array parts; - unsigned counter = 0; - // This is not a lambda for compatibility with older compilers. - struct { - format_part* parts; - unsigned* counter; - FMT_CONSTEXPR void operator()(const format_part& part) { - parts[(*counter)++] = part; - } - } collector{parts.data, &counter}; - compile_format_string(format_str, collector); - if (counter < N) { - parts.data[counter] = - format_part::make_text(basic_string_view()); - } - return parts; -} - -template constexpr const T& constexpr_max(const T& a, const T& b) { - return (a < b) ? b : a; -} - -template -struct compiled_format_base::value>> - : basic_compiled_format { - using char_type = char_t; - - FMT_CONSTEXPR explicit compiled_format_base(basic_string_view) {} - -// Workaround for old compilers. Format string compilation will not be -// performed there anyway. -#if FMT_USE_CONSTEXPR - static FMT_CONSTEXPR_DECL const unsigned num_format_parts = - constexpr_max(count_parts(to_string_view(S())), 1u); -#else - static const unsigned num_format_parts = 1; -#endif - - using parts_container = format_part[num_format_parts]; - - const parts_container& parts() const { - static FMT_CONSTEXPR_DECL const auto compiled_parts = - compile_to_parts( - internal::to_string_view(S())); - return compiled_parts.data; - } -}; - -template -class compiled_format : private compiled_format_base { - public: - using typename compiled_format_base::char_type; - - private: - basic_string_view format_str_; - - template - friend auto cf::vformat_to(Range out, CompiledFormat& cf, - basic_format_args args) -> - typename Context::iterator; - - public: - compiled_format() = delete; - explicit constexpr compiled_format(basic_string_view format_str) - : compiled_format_base(format_str), format_str_(format_str) {} -}; - -#ifdef __cpp_if_constexpr -template struct type_list {}; - -// Returns a reference to the argument at index N from [first, rest...]. -template -constexpr const auto& get(const T& first, const Args&... rest) { - static_assert(N < 1 + sizeof...(Args), "index is out of bounds"); - if constexpr (N == 0) - return first; - else - return get(rest...); -} - -template struct get_type_impl; - -template struct get_type_impl> { - using type = remove_cvref_t(std::declval()...))>; -}; - -template -using get_type = typename get_type_impl::type; - -template struct text { - basic_string_view data; - using char_type = Char; - - template - OutputIt format(OutputIt out, const Args&...) const { - // TODO: reserve - return copy_str(data.begin(), data.end(), out); - } -}; - -template -constexpr text make_text(basic_string_view s, size_t pos, - size_t size) { - return {{&s[pos], size}}; -} - -template , int> = 0> -OutputIt format_default(OutputIt out, T value) { - // TODO: reserve - format_int fi(value); - return std::copy(fi.data(), fi.data() + fi.size(), out); -} - -template -OutputIt format_default(OutputIt out, double value) { - writer w(out); - w.write(value); - return w.out(); -} - -template -OutputIt format_default(OutputIt out, Char value) { - *out++ = value; - return out; -} - -template -OutputIt format_default(OutputIt out, const Char* value) { - auto length = std::char_traits::length(value); - return copy_str(value, value + length, out); -} - -// A replacement field that refers to argument N. -template struct field { - using char_type = Char; - - template - OutputIt format(OutputIt out, const Args&... args) const { - // This ensures that the argument type is convertile to `const T&`. - const T& arg = get(args...); - return format_default(out, arg); - } -}; - -template struct concat { - L lhs; - R rhs; - using char_type = typename L::char_type; - - template - OutputIt format(OutputIt out, const Args&... args) const { - out = lhs.format(out, args...); - return rhs.format(out, args...); - } -}; - -template -constexpr concat make_concat(L lhs, R rhs) { - return {lhs, rhs}; -} - -struct unknown_format {}; - -template -constexpr size_t parse_text(basic_string_view str, size_t pos) { - for (size_t size = str.size(); pos != size; ++pos) { - if (str[pos] == '{' || str[pos] == '}') break; - } - return pos; -} - -template -constexpr auto compile_format_string(S format_str); - -template -constexpr auto parse_tail(T head, S format_str) { - if constexpr (POS != to_string_view(format_str).size()) { - constexpr auto tail = compile_format_string(format_str); - if constexpr (std::is_same, - unknown_format>()) - return tail; - else - return make_concat(head, tail); - } else { - return head; - } -} - -// Compiles a non-empty format string and returns the compiled representation -// or unknown_format() on unrecognized input. -template -constexpr auto compile_format_string(S format_str) { - using char_type = typename S::char_type; - constexpr basic_string_view str = format_str; - if constexpr (str[POS] == '{') { - if (POS + 1 == str.size()) - throw format_error("unmatched '{' in format string"); - if constexpr (str[POS + 1] == '{') { - return parse_tail(make_text(str, POS, 1), format_str); - } else if constexpr (str[POS + 1] == '}') { - using type = get_type; - if constexpr (std::is_same::value) { - return parse_tail(field(), - format_str); - } else { - return unknown_format(); - } - } else { - return unknown_format(); - } - } else if constexpr (str[POS] == '}') { - if (POS + 1 == str.size()) - throw format_error("unmatched '}' in format string"); - return parse_tail(make_text(str, POS, 1), format_str); - } else { - constexpr auto end = parse_text(str, POS + 1); - return parse_tail(make_text(str, POS, end - POS), - format_str); - } -} -#endif // __cpp_if_constexpr -} // namespace internal - -#if FMT_USE_CONSTEXPR -# ifdef __cpp_if_constexpr -template ::value)> -constexpr auto compile(S format_str) { - constexpr basic_string_view str = format_str; - if constexpr (str.size() == 0) { - return internal::make_text(str, 0, 0); - } else { - constexpr auto result = - internal::compile_format_string, 0, 0>( - format_str); - if constexpr (std::is_same, - internal::unknown_format>()) { - return internal::compiled_format(to_string_view(format_str)); - } else { - return result; - } - } -} - -template ::value)> -std::basic_string format(const CompiledFormat& cf, const Args&... args) { - basic_memory_buffer buffer; - cf.format(std::back_inserter(buffer), args...); - return to_string(buffer); -} - -template ::value)> -OutputIt format_to(OutputIt out, const CompiledFormat& cf, - const Args&... args) { - return cf.format(out, args...); -} -# else -template ::value)> -constexpr auto compile(S format_str) -> internal::compiled_format { - return internal::compiled_format(to_string_view(format_str)); -} -# endif // __cpp_if_constexpr -#endif // FMT_USE_CONSTEXPR - -// Compiles the format string which must be a string literal. -template -auto compile(const Char (&format_str)[N]) - -> internal::compiled_format { - return internal::compiled_format( - basic_string_view(format_str, N - 1)); -} - -template ::value)> -std::basic_string format(const CompiledFormat& cf, const Args&... args) { - basic_memory_buffer buffer; - using range = buffer_range; - using context = buffer_context; - internal::cf::vformat_to(range(buffer), cf, - {make_format_args(args...)}); - return to_string(buffer); -} - -template ::value)> -OutputIt format_to(OutputIt out, const CompiledFormat& cf, - const Args&... args) { - using char_type = typename CompiledFormat::char_type; - using range = internal::output_range; - using context = format_context_t; - return internal::cf::vformat_to( - range(out), cf, {make_format_args(args...)}); -} - -template ::value)> -format_to_n_result format_to_n(OutputIt out, size_t n, - const CompiledFormat& cf, - const Args&... args) { - auto it = - format_to(internal::truncating_iterator(out, n), cf, args...); - return {it.base(), it.count()}; -} - -template -std::size_t formatted_size(const CompiledFormat& cf, const Args&... args) { - return format_to(internal::counting_iterator(), cf, args...).count(); -} - -FMT_END_NAMESPACE - -#endif // FMT_COMPILE_H_ diff --git a/headers/papilo/external/fmt/core.h b/headers/papilo/external/fmt/core.h deleted file mode 100644 index 9fd8df2..0000000 --- a/headers/papilo/external/fmt/core.h +++ /dev/null @@ -1,1519 +0,0 @@ -// Formatting library for C++ - the core API -// -// Copyright (c) 2012 - present, Victor Zverovich -// All rights reserved. -// -// For the license information refer to format.h. - -#ifndef FMT_CORE_H_ -#define FMT_CORE_H_ - -#include // std::FILE -#include -#include -#include -#include - -// The fmt library version in the form major * 10000 + minor * 100 + patch. -#define FMT_VERSION 60102 - -#ifdef __has_feature -# define FMT_HAS_FEATURE(x) __has_feature(x) -#else -# define FMT_HAS_FEATURE(x) 0 -#endif - -#if defined(__has_include) && !defined(__INTELLISENSE__) && \ - !(defined(__INTEL_COMPILER) && __INTEL_COMPILER < 1600) -# define FMT_HAS_INCLUDE(x) __has_include(x) -#else -# define FMT_HAS_INCLUDE(x) 0 -#endif - -#ifdef __has_cpp_attribute -# define FMT_HAS_CPP_ATTRIBUTE(x) __has_cpp_attribute(x) -#else -# define FMT_HAS_CPP_ATTRIBUTE(x) 0 -#endif - -#if defined(__GNUC__) && !defined(__clang__) -# define FMT_GCC_VERSION (__GNUC__ * 100 + __GNUC_MINOR__) -#else -# define FMT_GCC_VERSION 0 -#endif - -#if __cplusplus >= 201103L || defined(__GXX_EXPERIMENTAL_CXX0X__) -# define FMT_HAS_GXX_CXX11 FMT_GCC_VERSION -#else -# define FMT_HAS_GXX_CXX11 0 -#endif - -#ifdef __NVCC__ -# define FMT_NVCC __NVCC__ -#else -# define FMT_NVCC 0 -#endif - -#ifdef _MSC_VER -# define FMT_MSC_VER _MSC_VER -#else -# define FMT_MSC_VER 0 -#endif - -// Check if relaxed C++14 constexpr is supported. -// GCC doesn't allow throw in constexpr until version 6 (bug 67371). -#ifndef FMT_USE_CONSTEXPR -# define FMT_USE_CONSTEXPR \ - (FMT_HAS_FEATURE(cxx_relaxed_constexpr) || FMT_MSC_VER >= 1910 || \ - (FMT_GCC_VERSION >= 600 && __cplusplus >= 201402L)) && \ - !FMT_NVCC -#endif -#if FMT_USE_CONSTEXPR -# define FMT_CONSTEXPR constexpr -# define FMT_CONSTEXPR_DECL constexpr -#else -# define FMT_CONSTEXPR inline -# define FMT_CONSTEXPR_DECL -#endif - -#ifndef FMT_OVERRIDE -# if FMT_HAS_FEATURE(cxx_override) || \ - (FMT_GCC_VERSION >= 408 && FMT_HAS_GXX_CXX11) || FMT_MSC_VER >= 1900 -# define FMT_OVERRIDE override -# else -# define FMT_OVERRIDE -# endif -#endif - -// Check if exceptions are disabled. -#ifndef FMT_EXCEPTIONS -# if (defined(__GNUC__) && !defined(__EXCEPTIONS)) || \ - FMT_MSC_VER && !_HAS_EXCEPTIONS -# define FMT_EXCEPTIONS 0 -# else -# define FMT_EXCEPTIONS 1 -# endif -#endif - -// Define FMT_USE_NOEXCEPT to make fmt use noexcept (C++11 feature). -#ifndef FMT_USE_NOEXCEPT -# define FMT_USE_NOEXCEPT 0 -#endif - -#if FMT_USE_NOEXCEPT || FMT_HAS_FEATURE(cxx_noexcept) || \ - (FMT_GCC_VERSION >= 408 && FMT_HAS_GXX_CXX11) || FMT_MSC_VER >= 1900 -# define FMT_DETECTED_NOEXCEPT noexcept -# define FMT_HAS_CXX11_NOEXCEPT 1 -#else -# define FMT_DETECTED_NOEXCEPT throw() -# define FMT_HAS_CXX11_NOEXCEPT 0 -#endif - -#ifndef FMT_NOEXCEPT -# if FMT_EXCEPTIONS || FMT_HAS_CXX11_NOEXCEPT -# define FMT_NOEXCEPT FMT_DETECTED_NOEXCEPT -# else -# define FMT_NOEXCEPT -# endif -#endif - -// [[noreturn]] is disabled on MSVC because of bogus unreachable code warnings. -#if FMT_EXCEPTIONS && FMT_HAS_CPP_ATTRIBUTE(noreturn) && !FMT_MSC_VER -# define FMT_NORETURN [[noreturn]] -#else -# define FMT_NORETURN -#endif - -#ifndef FMT_DEPRECATED -# if (FMT_HAS_CPP_ATTRIBUTE(deprecated) && __cplusplus >= 201402L) || \ - FMT_MSC_VER >= 1900 -# define FMT_DEPRECATED [[deprecated]] -# else -# if defined(__GNUC__) || defined(__clang__) -# define FMT_DEPRECATED __attribute__((deprecated)) -# elif FMT_MSC_VER -# define FMT_DEPRECATED __declspec(deprecated) -# else -# define FMT_DEPRECATED /* deprecated */ -# endif -# endif -#endif - -// Workaround broken [[deprecated]] in the Intel compiler and NVCC. -#if defined(__INTEL_COMPILER) || FMT_NVCC -# define FMT_DEPRECATED_ALIAS -#else -# define FMT_DEPRECATED_ALIAS FMT_DEPRECATED -#endif - -#ifndef FMT_BEGIN_NAMESPACE -# if FMT_HAS_FEATURE(cxx_inline_namespaces) || FMT_GCC_VERSION >= 404 || \ - FMT_MSC_VER >= 1900 -# define FMT_INLINE_NAMESPACE inline namespace -# define FMT_END_NAMESPACE \ - } \ - } -# else -# define FMT_INLINE_NAMESPACE namespace -# define FMT_END_NAMESPACE \ - } \ - using namespace v6; \ - } -# endif -# define FMT_BEGIN_NAMESPACE \ - namespace fmt { \ - FMT_INLINE_NAMESPACE v6 { -#endif - -#if !defined(FMT_HEADER_ONLY) && defined(_WIN32) -# ifdef FMT_EXPORT -# define FMT_API __declspec(dllexport) -# elif defined(FMT_SHARED) -# define FMT_API __declspec(dllimport) -# define FMT_EXTERN_TEMPLATE_API FMT_API -# endif -#endif -#ifndef FMT_API -# define FMT_API -#endif -#ifndef FMT_EXTERN_TEMPLATE_API -# define FMT_EXTERN_TEMPLATE_API -#endif - -#ifndef FMT_HEADER_ONLY -# define FMT_EXTERN extern -#else -# define FMT_EXTERN -#endif - -// libc++ supports string_view in pre-c++17. -#if (FMT_HAS_INCLUDE() && \ - (__cplusplus > 201402L || defined(_LIBCPP_VERSION))) || \ - (defined(_MSVC_LANG) && _MSVC_LANG > 201402L && _MSC_VER >= 1910) -# include -# define FMT_USE_STRING_VIEW -#elif FMT_HAS_INCLUDE("experimental/string_view") && __cplusplus >= 201402L -# include -# define FMT_USE_EXPERIMENTAL_STRING_VIEW -#endif - -FMT_BEGIN_NAMESPACE - -// Implementations of enable_if_t and other types for pre-C++14 systems. -template -using enable_if_t = typename std::enable_if::type; -template -using conditional_t = typename std::conditional::type; -template using bool_constant = std::integral_constant; -template -using remove_reference_t = typename std::remove_reference::type; -template -using remove_const_t = typename std::remove_const::type; -template -using remove_cvref_t = typename std::remove_cv>::type; - -struct monostate {}; - -// An enable_if helper to be used in template parameters which results in much -// shorter symbols: https://godbolt.org/z/sWw4vP. Extra parentheses are needed -// to workaround a bug in MSVC 2019 (see #1140 and #1186). -#define FMT_ENABLE_IF(...) enable_if_t<(__VA_ARGS__), int> = 0 - -namespace internal { - -// A workaround for gcc 4.8 to make void_t work in a SFINAE context. -template struct void_t_impl { using type = void; }; - -FMT_API void assert_fail(const char* file, int line, const char* message); - -#ifndef FMT_ASSERT -# ifdef NDEBUG -# define FMT_ASSERT(condition, message) -# else -# define FMT_ASSERT(condition, message) \ - ((condition) \ - ? void() \ - : fmt::internal::assert_fail(__FILE__, __LINE__, (message))) -# endif -#endif - -#if defined(FMT_USE_STRING_VIEW) -template using std_string_view = std::basic_string_view; -#elif defined(FMT_USE_EXPERIMENTAL_STRING_VIEW) -template -using std_string_view = std::experimental::basic_string_view; -#else -template struct std_string_view {}; -#endif - -#ifdef FMT_USE_INT128 -// Do nothing. -#elif defined(__SIZEOF_INT128__) -# define FMT_USE_INT128 1 -using int128_t = __int128_t; -using uint128_t = __uint128_t; -#else -# define FMT_USE_INT128 0 -#endif -#if !FMT_USE_INT128 -struct int128_t {}; -struct uint128_t {}; -#endif - -// Casts a nonnegative integer to unsigned. -template -FMT_CONSTEXPR typename std::make_unsigned::type to_unsigned(Int value) { - FMT_ASSERT(value >= 0, "negative value"); - return static_cast::type>(value); -} -} // namespace internal - -template -using void_t = typename internal::void_t_impl::type; - -/** - An implementation of ``std::basic_string_view`` for pre-C++17. It provides a - subset of the API. ``fmt::basic_string_view`` is used for format strings even - if ``std::string_view`` is available to prevent issues when a library is - compiled with a different ``-std`` option than the client code (which is not - recommended). - */ -template class basic_string_view { - private: - const Char* data_; - size_t size_; - - public: - using char_type = Char; - using iterator = const Char*; - - FMT_CONSTEXPR basic_string_view() FMT_NOEXCEPT : data_(nullptr), size_(0) {} - - /** Constructs a string reference object from a C string and a size. */ - FMT_CONSTEXPR basic_string_view(const Char* s, size_t count) FMT_NOEXCEPT - : data_(s), - size_(count) {} - - /** - \rst - Constructs a string reference object from a C string computing - the size with ``std::char_traits::length``. - \endrst - */ - basic_string_view(const Char* s) - : data_(s), size_(std::char_traits::length(s)) {} - - /** Constructs a string reference from a ``std::basic_string`` object. */ - template - FMT_CONSTEXPR basic_string_view( - const std::basic_string& s) FMT_NOEXCEPT - : data_(s.data()), - size_(s.size()) {} - - template < - typename S, - FMT_ENABLE_IF(std::is_same>::value)> - FMT_CONSTEXPR basic_string_view(S s) FMT_NOEXCEPT : data_(s.data()), - size_(s.size()) {} - - /** Returns a pointer to the string data. */ - FMT_CONSTEXPR const Char* data() const { return data_; } - - /** Returns the string size. */ - FMT_CONSTEXPR size_t size() const { return size_; } - - FMT_CONSTEXPR iterator begin() const { return data_; } - FMT_CONSTEXPR iterator end() const { return data_ + size_; } - - FMT_CONSTEXPR const Char& operator[](size_t pos) const { return data_[pos]; } - - FMT_CONSTEXPR void remove_prefix(size_t n) { - data_ += n; - size_ -= n; - } - - // Lexicographically compare this string reference to other. - int compare(basic_string_view other) const { - size_t str_size = size_ < other.size_ ? size_ : other.size_; - int result = std::char_traits::compare(data_, other.data_, str_size); - if (result == 0) - result = size_ == other.size_ ? 0 : (size_ < other.size_ ? -1 : 1); - return result; - } - - friend bool operator==(basic_string_view lhs, basic_string_view rhs) { - return lhs.compare(rhs) == 0; - } - friend bool operator!=(basic_string_view lhs, basic_string_view rhs) { - return lhs.compare(rhs) != 0; - } - friend bool operator<(basic_string_view lhs, basic_string_view rhs) { - return lhs.compare(rhs) < 0; - } - friend bool operator<=(basic_string_view lhs, basic_string_view rhs) { - return lhs.compare(rhs) <= 0; - } - friend bool operator>(basic_string_view lhs, basic_string_view rhs) { - return lhs.compare(rhs) > 0; - } - friend bool operator>=(basic_string_view lhs, basic_string_view rhs) { - return lhs.compare(rhs) >= 0; - } -}; - -using string_view = basic_string_view; -using wstring_view = basic_string_view; - -#ifndef __cpp_char8_t -// A UTF-8 code unit type. -enum char8_t : unsigned char {}; -#endif - -/** Specifies if ``T`` is a character type. Can be specialized by users. */ -template struct is_char : std::false_type {}; -template <> struct is_char : std::true_type {}; -template <> struct is_char : std::true_type {}; -template <> struct is_char : std::true_type {}; -template <> struct is_char : std::true_type {}; -template <> struct is_char : std::true_type {}; - -/** - \rst - Returns a string view of `s`. In order to add custom string type support to - {fmt} provide an overload of `to_string_view` for it in the same namespace as - the type for the argument-dependent lookup to work. - - **Example**:: - - namespace my_ns { - inline string_view to_string_view(const my_string& s) { - return {s.data(), s.length()}; - } - } - std::string message = fmt::format(my_string("The answer is {}"), 42); - \endrst - */ -template ::value)> -inline basic_string_view to_string_view(const Char* s) { - return s; -} - -template -inline basic_string_view to_string_view( - const std::basic_string& s) { - return s; -} - -template -inline basic_string_view to_string_view(basic_string_view s) { - return s; -} - -template >::value)> -inline basic_string_view to_string_view( - internal::std_string_view s) { - return s; -} - -// A base class for compile-time strings. It is defined in the fmt namespace to -// make formatting functions visible via ADL, e.g. format(fmt("{}"), 42). -struct compile_string {}; - -template -struct is_compile_string : std::is_base_of {}; - -template ::value)> -constexpr basic_string_view to_string_view(const S& s) { - return s; -} - -namespace internal { -void to_string_view(...); -using fmt::v6::to_string_view; - -// Specifies whether S is a string type convertible to fmt::basic_string_view. -// It should be a constexpr function but MSVC 2017 fails to compile it in -// enable_if and MSVC 2015 fails to compile it as an alias template. -template -struct is_string : std::is_class()))> { -}; - -template struct char_t_impl {}; -template struct char_t_impl::value>> { - using result = decltype(to_string_view(std::declval())); - using type = typename result::char_type; -}; - -struct error_handler { - FMT_CONSTEXPR error_handler() = default; - FMT_CONSTEXPR error_handler(const error_handler&) = default; - - // This function is intentionally not constexpr to give a compile-time error. - FMT_NORETURN FMT_API void on_error(const char* message); -}; -} // namespace internal - -/** String's character type. */ -template using char_t = typename internal::char_t_impl::type; - -/** - \rst - Parsing context consisting of a format string range being parsed and an - argument counter for automatic indexing. - - You can use one of the following type aliases for common character types: - - +-----------------------+-------------------------------------+ - | Type | Definition | - +=======================+=====================================+ - | format_parse_context | basic_format_parse_context | - +-----------------------+-------------------------------------+ - | wformat_parse_context | basic_format_parse_context | - +-----------------------+-------------------------------------+ - \endrst - */ -template -class basic_format_parse_context : private ErrorHandler { - private: - basic_string_view format_str_; - int next_arg_id_; - - public: - using char_type = Char; - using iterator = typename basic_string_view::iterator; - - explicit FMT_CONSTEXPR basic_format_parse_context( - basic_string_view format_str, ErrorHandler eh = ErrorHandler()) - : ErrorHandler(eh), format_str_(format_str), next_arg_id_(0) {} - - /** - Returns an iterator to the beginning of the format string range being - parsed. - */ - FMT_CONSTEXPR iterator begin() const FMT_NOEXCEPT { - return format_str_.begin(); - } - - /** - Returns an iterator past the end of the format string range being parsed. - */ - FMT_CONSTEXPR iterator end() const FMT_NOEXCEPT { return format_str_.end(); } - - /** Advances the begin iterator to ``it``. */ - FMT_CONSTEXPR void advance_to(iterator it) { - format_str_.remove_prefix(internal::to_unsigned(it - begin())); - } - - /** - Reports an error if using the manual argument indexing; otherwise returns - the next argument index and switches to the automatic indexing. - */ - FMT_CONSTEXPR int next_arg_id() { - if (next_arg_id_ >= 0) return next_arg_id_++; - on_error("cannot switch from manual to automatic argument indexing"); - return 0; - } - - /** - Reports an error if using the automatic argument indexing; otherwise - switches to the manual indexing. - */ - FMT_CONSTEXPR void check_arg_id(int) { - if (next_arg_id_ > 0) - on_error("cannot switch from automatic to manual argument indexing"); - else - next_arg_id_ = -1; - } - - FMT_CONSTEXPR void check_arg_id(basic_string_view) {} - - FMT_CONSTEXPR void on_error(const char* message) { - ErrorHandler::on_error(message); - } - - FMT_CONSTEXPR ErrorHandler error_handler() const { return *this; } -}; - -using format_parse_context = basic_format_parse_context; -using wformat_parse_context = basic_format_parse_context; - -template -using basic_parse_context FMT_DEPRECATED_ALIAS = - basic_format_parse_context; -using parse_context FMT_DEPRECATED_ALIAS = basic_format_parse_context; -using wparse_context FMT_DEPRECATED_ALIAS = basic_format_parse_context; - -template class basic_format_arg; -template class basic_format_args; - -// A formatter for objects of type T. -template -struct formatter { - // A deleted default constructor indicates a disabled formatter. - formatter() = delete; -}; - -template -struct FMT_DEPRECATED convert_to_int - : bool_constant::value && - std::is_convertible::value> {}; - -// Specifies if T has an enabled formatter specialization. A type can be -// formattable even if it doesn't have a formatter e.g. via a conversion. -template -using has_formatter = - std::is_constructible>; - -namespace internal { - -/** A contiguous memory buffer with an optional growing ability. */ -template class buffer { - private: - T* ptr_; - std::size_t size_; - std::size_t capacity_; - - protected: - // Don't initialize ptr_ since it is not accessed to save a few cycles. - buffer(std::size_t sz) FMT_NOEXCEPT : size_(sz), capacity_(sz) {} - - buffer(T* p = nullptr, std::size_t sz = 0, std::size_t cap = 0) FMT_NOEXCEPT - : ptr_(p), - size_(sz), - capacity_(cap) {} - - /** Sets the buffer data and capacity. */ - void set(T* buf_data, std::size_t buf_capacity) FMT_NOEXCEPT { - ptr_ = buf_data; - capacity_ = buf_capacity; - } - - /** Increases the buffer capacity to hold at least *capacity* elements. */ - virtual void grow(std::size_t capacity) = 0; - - public: - using value_type = T; - using const_reference = const T&; - - buffer(const buffer&) = delete; - void operator=(const buffer&) = delete; - virtual ~buffer() = default; - - T* begin() FMT_NOEXCEPT { return ptr_; } - T* end() FMT_NOEXCEPT { return ptr_ + size_; } - - /** Returns the size of this buffer. */ - std::size_t size() const FMT_NOEXCEPT { return size_; } - - /** Returns the capacity of this buffer. */ - std::size_t capacity() const FMT_NOEXCEPT { return capacity_; } - - /** Returns a pointer to the buffer data. */ - T* data() FMT_NOEXCEPT { return ptr_; } - - /** Returns a pointer to the buffer data. */ - const T* data() const FMT_NOEXCEPT { return ptr_; } - - /** - Resizes the buffer. If T is a POD type new elements may not be initialized. - */ - void resize(std::size_t new_size) { - reserve(new_size); - size_ = new_size; - } - - /** Clears this buffer. */ - void clear() { size_ = 0; } - - /** Reserves space to store at least *capacity* elements. */ - void reserve(std::size_t new_capacity) { - if (new_capacity > capacity_) grow(new_capacity); - } - - void push_back(const T& value) { - reserve(size_ + 1); - ptr_[size_++] = value; - } - - /** Appends data to the end of the buffer. */ - template void append(const U* begin, const U* end); - - T& operator[](std::size_t index) { return ptr_[index]; } - const T& operator[](std::size_t index) const { return ptr_[index]; } -}; - -// A container-backed buffer. -template -class container_buffer : public buffer { - private: - Container& container_; - - protected: - void grow(std::size_t capacity) FMT_OVERRIDE { - container_.resize(capacity); - this->set(&container_[0], capacity); - } - - public: - explicit container_buffer(Container& c) - : buffer(c.size()), container_(c) {} -}; - -// Extracts a reference to the container from back_insert_iterator. -template -inline Container& get_container(std::back_insert_iterator it) { - using bi_iterator = std::back_insert_iterator; - struct accessor : bi_iterator { - accessor(bi_iterator iter) : bi_iterator(iter) {} - using bi_iterator::container; - }; - return *accessor(it).container; -} - -template -struct fallback_formatter { - fallback_formatter() = delete; -}; - -// Specifies if T has an enabled fallback_formatter specialization. -template -using has_fallback_formatter = - std::is_constructible>; - -template struct named_arg_base; -template struct named_arg; - -enum type { - none_type, - named_arg_type, - // Integer types should go first, - int_type, - uint_type, - long_long_type, - ulong_long_type, - int128_type, - uint128_type, - bool_type, - char_type, - last_integer_type = char_type, - // followed by floating-point types. - float_type, - double_type, - long_double_type, - last_numeric_type = long_double_type, - cstring_type, - string_type, - pointer_type, - custom_type -}; - -// Maps core type T to the corresponding type enum constant. -template -struct type_constant : std::integral_constant {}; - -#define FMT_TYPE_CONSTANT(Type, constant) \ - template \ - struct type_constant : std::integral_constant {} - -FMT_TYPE_CONSTANT(const named_arg_base&, named_arg_type); -FMT_TYPE_CONSTANT(int, int_type); -FMT_TYPE_CONSTANT(unsigned, uint_type); -FMT_TYPE_CONSTANT(long long, long_long_type); -FMT_TYPE_CONSTANT(unsigned long long, ulong_long_type); -FMT_TYPE_CONSTANT(int128_t, int128_type); -FMT_TYPE_CONSTANT(uint128_t, uint128_type); -FMT_TYPE_CONSTANT(bool, bool_type); -FMT_TYPE_CONSTANT(Char, char_type); -FMT_TYPE_CONSTANT(float, float_type); -FMT_TYPE_CONSTANT(double, double_type); -FMT_TYPE_CONSTANT(long double, long_double_type); -FMT_TYPE_CONSTANT(const Char*, cstring_type); -FMT_TYPE_CONSTANT(basic_string_view, string_type); -FMT_TYPE_CONSTANT(const void*, pointer_type); - -FMT_CONSTEXPR bool is_integral_type(type t) { - FMT_ASSERT(t != named_arg_type, "invalid argument type"); - return t > none_type && t <= last_integer_type; -} - -FMT_CONSTEXPR bool is_arithmetic_type(type t) { - FMT_ASSERT(t != named_arg_type, "invalid argument type"); - return t > none_type && t <= last_numeric_type; -} - -template struct string_value { - const Char* data; - std::size_t size; -}; - -template struct custom_value { - using parse_context = basic_format_parse_context; - const void* value; - void (*format)(const void* arg, parse_context& parse_ctx, Context& ctx); -}; - -// A formatting argument value. -template class value { - public: - using char_type = typename Context::char_type; - - union { - int int_value; - unsigned uint_value; - long long long_long_value; - unsigned long long ulong_long_value; - int128_t int128_value; - uint128_t uint128_value; - bool bool_value; - char_type char_value; - float float_value; - double double_value; - long double long_double_value; - const void* pointer; - string_value string; - custom_value custom; - const named_arg_base* named_arg; - }; - - FMT_CONSTEXPR value(int val = 0) : int_value(val) {} - FMT_CONSTEXPR value(unsigned val) : uint_value(val) {} - value(long long val) : long_long_value(val) {} - value(unsigned long long val) : ulong_long_value(val) {} - value(int128_t val) : int128_value(val) {} - value(uint128_t val) : uint128_value(val) {} - value(float val) : float_value(val) {} - value(double val) : double_value(val) {} - value(long double val) : long_double_value(val) {} - value(bool val) : bool_value(val) {} - value(char_type val) : char_value(val) {} - value(const char_type* val) { string.data = val; } - value(basic_string_view val) { - string.data = val.data(); - string.size = val.size(); - } - value(const void* val) : pointer(val) {} - - template value(const T& val) { - custom.value = &val; - // Get the formatter type through the context to allow different contexts - // have different extension points, e.g. `formatter` for `format` and - // `printf_formatter` for `printf`. - custom.format = format_custom_arg< - T, conditional_t::value, - typename Context::template formatter_type, - fallback_formatter>>; - } - - value(const named_arg_base& val) { named_arg = &val; } - - private: - // Formats an argument of a custom type, such as a user-defined class. - template - static void format_custom_arg( - const void* arg, basic_format_parse_context& parse_ctx, - Context& ctx) { - Formatter f; - parse_ctx.advance_to(f.parse(parse_ctx)); - ctx.advance_to(f.format(*static_cast(arg), ctx)); - } -}; - -template -FMT_CONSTEXPR basic_format_arg make_arg(const T& value); - -// To minimize the number of types we need to deal with, long is translated -// either to int or to long long depending on its size. -enum { long_short = sizeof(long) == sizeof(int) }; -using long_type = conditional_t; -using ulong_type = conditional_t; - -// Maps formatting arguments to core types. -template struct arg_mapper { - using char_type = typename Context::char_type; - - FMT_CONSTEXPR int map(signed char val) { return val; } - FMT_CONSTEXPR unsigned map(unsigned char val) { return val; } - FMT_CONSTEXPR int map(short val) { return val; } - FMT_CONSTEXPR unsigned map(unsigned short val) { return val; } - FMT_CONSTEXPR int map(int val) { return val; } - FMT_CONSTEXPR unsigned map(unsigned val) { return val; } - FMT_CONSTEXPR long_type map(long val) { return val; } - FMT_CONSTEXPR ulong_type map(unsigned long val) { return val; } - FMT_CONSTEXPR long long map(long long val) { return val; } - FMT_CONSTEXPR unsigned long long map(unsigned long long val) { return val; } - FMT_CONSTEXPR int128_t map(int128_t val) { return val; } - FMT_CONSTEXPR uint128_t map(uint128_t val) { return val; } - FMT_CONSTEXPR bool map(bool val) { return val; } - - template ::value)> - FMT_CONSTEXPR char_type map(T val) { - static_assert( - std::is_same::value || std::is_same::value, - "mixing character types is disallowed"); - return val; - } - - FMT_CONSTEXPR float map(float val) { return val; } - FMT_CONSTEXPR double map(double val) { return val; } - FMT_CONSTEXPR long double map(long double val) { return val; } - - FMT_CONSTEXPR const char_type* map(char_type* val) { return val; } - FMT_CONSTEXPR const char_type* map(const char_type* val) { return val; } - template ::value)> - FMT_CONSTEXPR basic_string_view map(const T& val) { - static_assert(std::is_same>::value, - "mixing character types is disallowed"); - return to_string_view(val); - } - template , T>::value && - !is_string::value)> - FMT_CONSTEXPR basic_string_view map(const T& val) { - return basic_string_view(val); - } - template < - typename T, - FMT_ENABLE_IF( - std::is_constructible, T>::value && - !std::is_constructible, T>::value && - !is_string::value && !has_formatter::value)> - FMT_CONSTEXPR basic_string_view map(const T& val) { - return std_string_view(val); - } - FMT_CONSTEXPR const char* map(const signed char* val) { - static_assert(std::is_same::value, "invalid string type"); - return reinterpret_cast(val); - } - FMT_CONSTEXPR const char* map(const unsigned char* val) { - static_assert(std::is_same::value, "invalid string type"); - return reinterpret_cast(val); - } - - FMT_CONSTEXPR const void* map(void* val) { return val; } - FMT_CONSTEXPR const void* map(const void* val) { return val; } - FMT_CONSTEXPR const void* map(std::nullptr_t val) { return val; } - template FMT_CONSTEXPR int map(const T*) { - // Formatting of arbitrary pointers is disallowed. If you want to output - // a pointer cast it to "void *" or "const void *". In particular, this - // forbids formatting of "[const] volatile char *" which is printed as bool - // by iostreams. - static_assert(!sizeof(T), "formatting of non-void pointers is disallowed"); - return 0; - } - - template ::value && - !has_formatter::value && - !has_fallback_formatter::value)> - FMT_CONSTEXPR auto map(const T& val) -> decltype( - map(static_cast::type>(val))) { - return map(static_cast::type>(val)); - } - template < - typename T, - FMT_ENABLE_IF( - !is_string::value && !is_char::value && - !std::is_constructible, T>::value && - (has_formatter::value || - (has_fallback_formatter::value && - !std::is_constructible, T>::value)))> - FMT_CONSTEXPR const T& map(const T& val) { - return val; - } - - template - FMT_CONSTEXPR const named_arg_base& map( - const named_arg& val) { - auto arg = make_arg(val.value); - std::memcpy(val.data, &arg, sizeof(arg)); - return val; - } -}; - -// A type constant after applying arg_mapper. -template -using mapped_type_constant = - type_constant().map(std::declval())), - typename Context::char_type>; - -enum { packed_arg_bits = 5 }; -// Maximum number of arguments with packed types. -enum { max_packed_args = 63 / packed_arg_bits }; -enum : unsigned long long { is_unpacked_bit = 1ULL << 63 }; - -template class arg_map; -} // namespace internal - -// A formatting argument. It is a trivially copyable/constructible type to -// allow storage in basic_memory_buffer. -template class basic_format_arg { - private: - internal::value value_; - internal::type type_; - - template - friend FMT_CONSTEXPR basic_format_arg internal::make_arg( - const T& value); - - template - friend FMT_CONSTEXPR auto visit_format_arg(Visitor&& vis, - const basic_format_arg& arg) - -> decltype(vis(0)); - - friend class basic_format_args; - friend class internal::arg_map; - - using char_type = typename Context::char_type; - - public: - class handle { - public: - explicit handle(internal::custom_value custom) : custom_(custom) {} - - void format(basic_format_parse_context& parse_ctx, - Context& ctx) const { - custom_.format(custom_.value, parse_ctx, ctx); - } - - private: - internal::custom_value custom_; - }; - - FMT_CONSTEXPR basic_format_arg() : type_(internal::none_type) {} - - FMT_CONSTEXPR explicit operator bool() const FMT_NOEXCEPT { - return type_ != internal::none_type; - } - - internal::type type() const { return type_; } - - bool is_integral() const { return internal::is_integral_type(type_); } - bool is_arithmetic() const { return internal::is_arithmetic_type(type_); } -}; - -/** - \rst - Visits an argument dispatching to the appropriate visit method based on - the argument type. For example, if the argument type is ``double`` then - ``vis(value)`` will be called with the value of type ``double``. - \endrst - */ -template -FMT_CONSTEXPR auto visit_format_arg(Visitor&& vis, - const basic_format_arg& arg) - -> decltype(vis(0)) { - using char_type = typename Context::char_type; - switch (arg.type_) { - case internal::none_type: - break; - case internal::named_arg_type: - FMT_ASSERT(false, "invalid argument type"); - break; - case internal::int_type: - return vis(arg.value_.int_value); - case internal::uint_type: - return vis(arg.value_.uint_value); - case internal::long_long_type: - return vis(arg.value_.long_long_value); - case internal::ulong_long_type: - return vis(arg.value_.ulong_long_value); -#if FMT_USE_INT128 - case internal::int128_type: - return vis(arg.value_.int128_value); - case internal::uint128_type: - return vis(arg.value_.uint128_value); -#else - case internal::int128_type: - case internal::uint128_type: - break; -#endif - case internal::bool_type: - return vis(arg.value_.bool_value); - case internal::char_type: - return vis(arg.value_.char_value); - case internal::float_type: - return vis(arg.value_.float_value); - case internal::double_type: - return vis(arg.value_.double_value); - case internal::long_double_type: - return vis(arg.value_.long_double_value); - case internal::cstring_type: - return vis(arg.value_.string.data); - case internal::string_type: - return vis(basic_string_view(arg.value_.string.data, - arg.value_.string.size)); - case internal::pointer_type: - return vis(arg.value_.pointer); - case internal::custom_type: - return vis(typename basic_format_arg::handle(arg.value_.custom)); - } - return vis(monostate()); -} - -namespace internal { -// A map from argument names to their values for named arguments. -template class arg_map { - private: - using char_type = typename Context::char_type; - - struct entry { - basic_string_view name; - basic_format_arg arg; - }; - - entry* map_; - unsigned size_; - - void push_back(value val) { - const auto& named = *val.named_arg; - map_[size_] = {named.name, named.template deserialize()}; - ++size_; - } - - public: - arg_map(const arg_map&) = delete; - void operator=(const arg_map&) = delete; - arg_map() : map_(nullptr), size_(0) {} - void init(const basic_format_args& args); - ~arg_map() { delete[] map_; } - - basic_format_arg find(basic_string_view name) const { - // The list is unsorted, so just return the first matching name. - for (entry *it = map_, *end = map_ + size_; it != end; ++it) { - if (it->name == name) return it->arg; - } - return {}; - } -}; - -// A type-erased reference to an std::locale to avoid heavy include. -class locale_ref { - private: - const void* locale_; // A type-erased pointer to std::locale. - - public: - locale_ref() : locale_(nullptr) {} - template explicit locale_ref(const Locale& loc); - - explicit operator bool() const FMT_NOEXCEPT { return locale_ != nullptr; } - - template Locale get() const; -}; - -template constexpr unsigned long long encode_types() { return 0; } - -template -constexpr unsigned long long encode_types() { - return mapped_type_constant::value | - (encode_types() << packed_arg_bits); -} - -template -FMT_CONSTEXPR basic_format_arg make_arg(const T& value) { - basic_format_arg arg; - arg.type_ = mapped_type_constant::value; - arg.value_ = arg_mapper().map(value); - return arg; -} - -template -inline value make_arg(const T& val) { - return arg_mapper().map(val); -} - -template -inline basic_format_arg make_arg(const T& value) { - return make_arg(value); -} -} // namespace internal - -// Formatting context. -template class basic_format_context { - public: - /** The character type for the output. */ - using char_type = Char; - - private: - OutputIt out_; - basic_format_args args_; - internal::arg_map map_; - internal::locale_ref loc_; - - public: - using iterator = OutputIt; - using format_arg = basic_format_arg; - template using formatter_type = formatter; - - basic_format_context(const basic_format_context&) = delete; - void operator=(const basic_format_context&) = delete; - /** - Constructs a ``basic_format_context`` object. References to the arguments are - stored in the object so make sure they have appropriate lifetimes. - */ - basic_format_context(OutputIt out, - basic_format_args ctx_args, - internal::locale_ref loc = internal::locale_ref()) - : out_(out), args_(ctx_args), loc_(loc) {} - - format_arg arg(int id) const { return args_.get(id); } - - // Checks if manual indexing is used and returns the argument with the - // specified name. - format_arg arg(basic_string_view name); - - internal::error_handler error_handler() { return {}; } - void on_error(const char* message) { error_handler().on_error(message); } - - // Returns an iterator to the beginning of the output range. - iterator out() { return out_; } - - // Advances the begin iterator to ``it``. - void advance_to(iterator it) { out_ = it; } - - internal::locale_ref locale() { return loc_; } -}; - -template -using buffer_context = - basic_format_context>, - Char>; -using format_context = buffer_context; -using wformat_context = buffer_context; - -/** - \rst - An array of references to arguments. It can be implicitly converted into - `~fmt::basic_format_args` for passing into type-erased formatting functions - such as `~fmt::vformat`. - \endrst - */ -template class format_arg_store { - private: - static const size_t num_args = sizeof...(Args); - static const bool is_packed = num_args < internal::max_packed_args; - - using value_type = conditional_t, - basic_format_arg>; - - // If the arguments are not packed, add one more element to mark the end. - value_type data_[num_args + (num_args == 0 ? 1 : 0)]; - - friend class basic_format_args; - - public: - static constexpr unsigned long long types = - is_packed ? internal::encode_types() - : internal::is_unpacked_bit | num_args; - - format_arg_store(const Args&... args) - : data_{internal::make_arg(args)...} {} -}; - -/** - \rst - Constructs an `~fmt::format_arg_store` object that contains references to - arguments and can be implicitly converted to `~fmt::format_args`. `Context` - can be omitted in which case it defaults to `~fmt::context`. - See `~fmt::arg` for lifetime considerations. - \endrst - */ -template -inline format_arg_store make_format_args( - const Args&... args) { - return {args...}; -} - -/** Formatting arguments. */ -template class basic_format_args { - public: - using size_type = int; - using format_arg = basic_format_arg; - - private: - // To reduce compiled code size per formatting function call, types of first - // max_packed_args arguments are passed in the types_ field. - unsigned long long types_; - union { - // If the number of arguments is less than max_packed_args, the argument - // values are stored in values_, otherwise they are stored in args_. - // This is done to reduce compiled code size as storing larger objects - // may require more code (at least on x86-64) even if the same amount of - // data is actually copied to stack. It saves ~10% on the bloat test. - const internal::value* values_; - const format_arg* args_; - }; - - bool is_packed() const { return (types_ & internal::is_unpacked_bit) == 0; } - - internal::type type(int index) const { - int shift = index * internal::packed_arg_bits; - unsigned int mask = (1 << internal::packed_arg_bits) - 1; - return static_cast((types_ >> shift) & mask); - } - - friend class internal::arg_map; - - void set_data(const internal::value* values) { values_ = values; } - void set_data(const format_arg* args) { args_ = args; } - - format_arg do_get(int index) const { - format_arg arg; - if (!is_packed()) { - auto num_args = max_size(); - if (index < num_args) arg = args_[index]; - return arg; - } - if (index > internal::max_packed_args) return arg; - arg.type_ = type(index); - if (arg.type_ == internal::none_type) return arg; - internal::value& val = arg.value_; - val = values_[index]; - return arg; - } - - public: - basic_format_args() : types_(0) {} - - /** - \rst - Constructs a `basic_format_args` object from `~fmt::format_arg_store`. - \endrst - */ - template - basic_format_args(const format_arg_store& store) - : types_(store.types) { - set_data(store.data_); - } - - /** - \rst - Constructs a `basic_format_args` object from a dynamic set of arguments. - \endrst - */ - basic_format_args(const format_arg* args, int count) - : types_(internal::is_unpacked_bit | internal::to_unsigned(count)) { - set_data(args); - } - - /** Returns the argument at specified index. */ - format_arg get(int index) const { - format_arg arg = do_get(index); - if (arg.type_ == internal::named_arg_type) - arg = arg.value_.named_arg->template deserialize(); - return arg; - } - - int max_size() const { - unsigned long long max_packed = internal::max_packed_args; - return static_cast(is_packed() ? max_packed - : types_ & ~internal::is_unpacked_bit); - } -}; - -/** An alias to ``basic_format_args``. */ -// It is a separate type rather than an alias to make symbols readable. -struct format_args : basic_format_args { - template - format_args(Args&&... args) - : basic_format_args(std::forward(args)...) {} -}; -struct wformat_args : basic_format_args { - template - wformat_args(Args&&... args) - : basic_format_args(std::forward(args)...) {} -}; - -template struct is_contiguous : std::false_type {}; - -template -struct is_contiguous> : std::true_type {}; - -template -struct is_contiguous> : std::true_type {}; - -namespace internal { - -template -struct is_contiguous_back_insert_iterator : std::false_type {}; -template -struct is_contiguous_back_insert_iterator> - : is_contiguous {}; - -template struct named_arg_base { - basic_string_view name; - - // Serialized value. - mutable char data[sizeof(basic_format_arg>)]; - - named_arg_base(basic_string_view nm) : name(nm) {} - - template basic_format_arg deserialize() const { - basic_format_arg arg; - std::memcpy(&arg, data, sizeof(basic_format_arg)); - return arg; - } -}; - -template struct named_arg : named_arg_base { - const T& value; - - named_arg(basic_string_view name, const T& val) - : named_arg_base(name), value(val) {} -}; - -template ::value)> -inline void check_format_string(const S&) { -#if defined(FMT_ENFORCE_COMPILE_STRING) - static_assert(is_compile_string::value, - "FMT_ENFORCE_COMPILE_STRING requires all format strings to " - "utilize FMT_STRING() or fmt()."); -#endif -} -template ::value)> -void check_format_string(S); - -struct view {}; -template struct bool_pack; -template -using all_true = - std::is_same, bool_pack>; - -template > -inline format_arg_store, remove_reference_t...> -make_args_checked(const S& format_str, - const remove_reference_t&... args) { - static_assert(all_true<(!std::is_base_of>() || - !std::is_reference())...>::value, - "passing views as lvalues is disallowed"); - check_format_string>...>(format_str); - return {args...}; -} - -template -std::basic_string vformat(basic_string_view format_str, - basic_format_args> args); - -template -typename buffer_context::iterator vformat_to( - buffer& buf, basic_string_view format_str, - basic_format_args> args); -} // namespace internal - -/** - \rst - Returns a named argument to be used in a formatting function. - - The named argument holds a reference and does not extend the lifetime - of its arguments. - Consequently, a dangling reference can accidentally be created. - The user should take care to only pass this function temporaries when - the named argument is itself a temporary, as per the following example. - - **Example**:: - - fmt::print("Elapsed time: {s:.2f} seconds", fmt::arg("s", 1.23)); - \endrst - */ -template > -inline internal::named_arg arg(const S& name, const T& arg) { - static_assert(internal::is_string::value, ""); - return {name, arg}; -} - -// Disable nested named arguments, e.g. ``arg("a", arg("b", 42))``. -template -void arg(S, internal::named_arg) = delete; - -/** Formats a string and writes the output to ``out``. */ -// GCC 8 and earlier cannot handle std::back_insert_iterator with -// vformat_to(...) overload, so SFINAE on iterator type instead. -template , - FMT_ENABLE_IF( - internal::is_contiguous_back_insert_iterator::value)> -OutputIt vformat_to(OutputIt out, const S& format_str, - basic_format_args> args) { - using container = remove_reference_t; - internal::container_buffer buf((internal::get_container(out))); - internal::vformat_to(buf, to_string_view(format_str), args); - return out; -} - -template ::value&& internal::is_string::value)> -inline std::back_insert_iterator format_to( - std::back_insert_iterator out, const S& format_str, - Args&&... args) { - return vformat_to( - out, to_string_view(format_str), - {internal::make_args_checked(format_str, args...)}); -} - -template > -inline std::basic_string vformat( - const S& format_str, basic_format_args> args) { - return internal::vformat(to_string_view(format_str), args); -} - -/** - \rst - Formats arguments and returns the result as a string. - - **Example**:: - - #include - std::string message = fmt::format("The answer is {}", 42); - \endrst -*/ -// Pass char_t as a default template parameter instead of using -// std::basic_string> to reduce the symbol size. -template > -inline std::basic_string format(const S& format_str, Args&&... args) { - return internal::vformat( - to_string_view(format_str), - {internal::make_args_checked(format_str, args...)}); -} - -FMT_API void vprint(std::FILE* f, string_view format_str, format_args args); -FMT_API void vprint(string_view format_str, format_args args); - -/** - \rst - Prints formatted data to the file *f*. For wide format strings, - *f* should be in wide-oriented mode set via ``fwide(f, 1)`` or - ``_setmode(_fileno(f), _O_U8TEXT)`` on Windows. - - **Example**:: - - fmt::print(stderr, "Don't {}!", "panic"); - \endrst - */ -template ::value)> -inline void print(std::FILE* f, const S& format_str, Args&&... args) { - vprint(f, to_string_view(format_str), - internal::make_args_checked(format_str, args...)); -} - -/** - \rst - Prints formatted data to ``stdout``. - - **Example**:: - - fmt::print("Elapsed time: {0:.2f} seconds", 1.23); - \endrst - */ -template ::value)> -inline void print(const S& format_str, Args&&... args) { - vprint(to_string_view(format_str), - internal::make_args_checked(format_str, args...)); -} -FMT_END_NAMESPACE - -#endif // FMT_CORE_H_ diff --git a/headers/papilo/external/fmt/format-inl.h b/headers/papilo/external/fmt/format-inl.h deleted file mode 100644 index 72b3046..0000000 --- a/headers/papilo/external/fmt/format-inl.h +++ /dev/null @@ -1,1396 +0,0 @@ -// Formatting library for C++ - implementation -// -// Copyright (c) 2012 - 2016, Victor Zverovich -// All rights reserved. -// -// For the license information refer to format.h. - -#ifndef FMT_FORMAT_INL_H_ -#define FMT_FORMAT_INL_H_ - -#include "format.h" - -#include -#include -#include -#include -#include -#include // for std::memmove -#include -#if !defined(FMT_STATIC_THOUSANDS_SEPARATOR) -# include -#endif - -#if FMT_USE_WINDOWS_H -# if !defined(FMT_HEADER_ONLY) && !defined(WIN32_LEAN_AND_MEAN) -# define WIN32_LEAN_AND_MEAN -# endif -# if defined(NOMINMAX) || defined(FMT_WIN_MINMAX) -# include -# else -# define NOMINMAX -# include -# undef NOMINMAX -# endif -#endif - -#if FMT_EXCEPTIONS -# define FMT_TRY try -# define FMT_CATCH(x) catch (x) -#else -# define FMT_TRY if (true) -# define FMT_CATCH(x) if (false) -#endif - -#ifdef _MSC_VER -# pragma warning(push) -# pragma warning(disable : 4702) // unreachable code -#endif - -// Dummy implementations of strerror_r and strerror_s called if corresponding -// system functions are not available. -inline fmt::internal::null<> strerror_r(int, char*, ...) { return {}; } -inline fmt::internal::null<> strerror_s(char*, std::size_t, ...) { return {}; } - -FMT_BEGIN_NAMESPACE -namespace internal { - -FMT_FUNC void assert_fail(const char* file, int line, const char* message) { - print(stderr, "{}:{}: assertion failed: {}", file, line, message); - std::abort(); -} - -#ifndef _MSC_VER -# define FMT_SNPRINTF snprintf -#else // _MSC_VER -inline int fmt_snprintf(char* buffer, size_t size, const char* format, ...) { - va_list args; - va_start(args, format); - int result = vsnprintf_s(buffer, size, _TRUNCATE, format, args); - va_end(args); - return result; -} -# define FMT_SNPRINTF fmt_snprintf -#endif // _MSC_VER - -using format_func = void (*)(internal::buffer&, int, string_view); - -// A portable thread-safe version of strerror. -// Sets buffer to point to a string describing the error code. -// This can be either a pointer to a string stored in buffer, -// or a pointer to some static immutable string. -// Returns one of the following values: -// 0 - success -// ERANGE - buffer is not large enough to store the error message -// other - failure -// Buffer should be at least of size 1. -FMT_FUNC int safe_strerror(int error_code, char*& buffer, - std::size_t buffer_size) FMT_NOEXCEPT { - FMT_ASSERT(buffer != nullptr && buffer_size != 0, "invalid buffer"); - - class dispatcher { - private: - int error_code_; - char*& buffer_; - std::size_t buffer_size_; - - // A noop assignment operator to avoid bogus warnings. - void operator=(const dispatcher&) {} - - // Handle the result of XSI-compliant version of strerror_r. - int handle(int result) { - // glibc versions before 2.13 return result in errno. - return result == -1 ? errno : result; - } - - // Handle the result of GNU-specific version of strerror_r. - int handle(char* message) { - // If the buffer is full then the message is probably truncated. - if (message == buffer_ && strlen(buffer_) == buffer_size_ - 1) - return ERANGE; - buffer_ = message; - return 0; - } - - // Handle the case when strerror_r is not available. - int handle(internal::null<>) { - return fallback(strerror_s(buffer_, buffer_size_, error_code_)); - } - - // Fallback to strerror_s when strerror_r is not available. - int fallback(int result) { - // If the buffer is full then the message is probably truncated. - return result == 0 && strlen(buffer_) == buffer_size_ - 1 ? ERANGE - : result; - } - -#if !FMT_MSC_VER - // Fallback to strerror if strerror_r and strerror_s are not available. - int fallback(internal::null<>) { - errno = 0; - buffer_ = strerror(error_code_); - return errno; - } -#endif - - public: - dispatcher(int err_code, char*& buf, std::size_t buf_size) - : error_code_(err_code), buffer_(buf), buffer_size_(buf_size) {} - - int run() { return handle(strerror_r(error_code_, buffer_, buffer_size_)); } - }; - return dispatcher(error_code, buffer, buffer_size).run(); -} - -FMT_FUNC void format_error_code(internal::buffer& out, int error_code, - string_view message) FMT_NOEXCEPT { - // Report error code making sure that the output fits into - // inline_buffer_size to avoid dynamic memory allocation and potential - // bad_alloc. - out.resize(0); - static const char SEP[] = ": "; - static const char ERROR_STR[] = "error "; - // Subtract 2 to account for terminating null characters in SEP and ERROR_STR. - std::size_t error_code_size = sizeof(SEP) + sizeof(ERROR_STR) - 2; - auto abs_value = static_cast>(error_code); - if (internal::is_negative(error_code)) { - abs_value = 0 - abs_value; - ++error_code_size; - } - error_code_size += internal::to_unsigned(internal::count_digits(abs_value)); - internal::writer w(out); - if (message.size() <= inline_buffer_size - error_code_size) { - w.write(message); - w.write(SEP); - } - w.write(ERROR_STR); - w.write(error_code); - assert(out.size() <= inline_buffer_size); -} - -// A wrapper around fwrite that throws on error. -FMT_FUNC void fwrite_fully(const void* ptr, size_t size, size_t count, - FILE* stream) { - size_t written = std::fwrite(ptr, size, count, stream); - if (written < count) { - FMT_THROW(system_error(errno, "cannot write to file")); - } -} - -FMT_FUNC void report_error(format_func func, int error_code, - string_view message) FMT_NOEXCEPT { - memory_buffer full_message; - func(full_message, error_code, message); - // Don't use fwrite_fully because the latter may throw. - (void)std::fwrite(full_message.data(), full_message.size(), 1, stderr); - std::fputc('\n', stderr); -} -} // namespace internal - -#if !defined(FMT_STATIC_THOUSANDS_SEPARATOR) -namespace internal { - -template -locale_ref::locale_ref(const Locale& loc) : locale_(&loc) { - static_assert(std::is_same::value, ""); -} - -template Locale locale_ref::get() const { - static_assert(std::is_same::value, ""); - return locale_ ? *static_cast(locale_) : std::locale(); -} - -template FMT_FUNC std::string grouping_impl(locale_ref loc) { - return std::use_facet>(loc.get()).grouping(); -} -template FMT_FUNC Char thousands_sep_impl(locale_ref loc) { - return std::use_facet>(loc.get()) - .thousands_sep(); -} -template FMT_FUNC Char decimal_point_impl(locale_ref loc) { - return std::use_facet>(loc.get()) - .decimal_point(); -} -} // namespace internal -#else -template -FMT_FUNC std::string internal::grouping_impl(locale_ref) { - return "\03"; -} -template -FMT_FUNC Char internal::thousands_sep_impl(locale_ref) { - return FMT_STATIC_THOUSANDS_SEPARATOR; -} -template -FMT_FUNC Char internal::decimal_point_impl(locale_ref) { - return '.'; -} -#endif - -FMT_API FMT_FUNC format_error::~format_error() FMT_NOEXCEPT = default; -FMT_API FMT_FUNC system_error::~system_error() FMT_NOEXCEPT = default; - -FMT_FUNC void system_error::init(int err_code, string_view format_str, - format_args args) { - error_code_ = err_code; - memory_buffer buffer; - format_system_error(buffer, err_code, vformat(format_str, args)); - std::runtime_error& base = *this; - base = std::runtime_error(to_string(buffer)); -} - -namespace internal { - -template <> FMT_FUNC int count_digits<4>(internal::fallback_uintptr n) { - // fallback_uintptr is always stored in little endian. - int i = static_cast(sizeof(void*)) - 1; - while (i > 0 && n.value[i] == 0) --i; - auto char_digits = std::numeric_limits::digits / 4; - return i >= 0 ? i * char_digits + count_digits<4, unsigned>(n.value[i]) : 1; -} - -template -const char basic_data::digits[] = - "0001020304050607080910111213141516171819" - "2021222324252627282930313233343536373839" - "4041424344454647484950515253545556575859" - "6061626364656667686970717273747576777879" - "8081828384858687888990919293949596979899"; - -template -const char basic_data::hex_digits[] = "0123456789abcdef"; - -#define FMT_POWERS_OF_10(factor) \ - factor * 10, (factor)*100, (factor)*1000, (factor)*10000, (factor)*100000, \ - (factor)*1000000, (factor)*10000000, (factor)*100000000, \ - (factor)*1000000000 - -template -const uint64_t basic_data::powers_of_10_64[] = { - 1, FMT_POWERS_OF_10(1), FMT_POWERS_OF_10(1000000000ULL), - 10000000000000000000ULL}; - -template -const uint32_t basic_data::zero_or_powers_of_10_32[] = {0, - FMT_POWERS_OF_10(1)}; - -template -const uint64_t basic_data::zero_or_powers_of_10_64[] = { - 0, FMT_POWERS_OF_10(1), FMT_POWERS_OF_10(1000000000ULL), - 10000000000000000000ULL}; - -// Normalized 64-bit significands of pow(10, k), for k = -348, -340, ..., 340. -// These are generated by support/compute-powers.py. -template -const uint64_t basic_data::pow10_significands[] = { - 0xfa8fd5a0081c0288, 0xbaaee17fa23ebf76, 0x8b16fb203055ac76, - 0xcf42894a5dce35ea, 0x9a6bb0aa55653b2d, 0xe61acf033d1a45df, - 0xab70fe17c79ac6ca, 0xff77b1fcbebcdc4f, 0xbe5691ef416bd60c, - 0x8dd01fad907ffc3c, 0xd3515c2831559a83, 0x9d71ac8fada6c9b5, - 0xea9c227723ee8bcb, 0xaecc49914078536d, 0x823c12795db6ce57, - 0xc21094364dfb5637, 0x9096ea6f3848984f, 0xd77485cb25823ac7, - 0xa086cfcd97bf97f4, 0xef340a98172aace5, 0xb23867fb2a35b28e, - 0x84c8d4dfd2c63f3b, 0xc5dd44271ad3cdba, 0x936b9fcebb25c996, - 0xdbac6c247d62a584, 0xa3ab66580d5fdaf6, 0xf3e2f893dec3f126, - 0xb5b5ada8aaff80b8, 0x87625f056c7c4a8b, 0xc9bcff6034c13053, - 0x964e858c91ba2655, 0xdff9772470297ebd, 0xa6dfbd9fb8e5b88f, - 0xf8a95fcf88747d94, 0xb94470938fa89bcf, 0x8a08f0f8bf0f156b, - 0xcdb02555653131b6, 0x993fe2c6d07b7fac, 0xe45c10c42a2b3b06, - 0xaa242499697392d3, 0xfd87b5f28300ca0e, 0xbce5086492111aeb, - 0x8cbccc096f5088cc, 0xd1b71758e219652c, 0x9c40000000000000, - 0xe8d4a51000000000, 0xad78ebc5ac620000, 0x813f3978f8940984, - 0xc097ce7bc90715b3, 0x8f7e32ce7bea5c70, 0xd5d238a4abe98068, - 0x9f4f2726179a2245, 0xed63a231d4c4fb27, 0xb0de65388cc8ada8, - 0x83c7088e1aab65db, 0xc45d1df942711d9a, 0x924d692ca61be758, - 0xda01ee641a708dea, 0xa26da3999aef774a, 0xf209787bb47d6b85, - 0xb454e4a179dd1877, 0x865b86925b9bc5c2, 0xc83553c5c8965d3d, - 0x952ab45cfa97a0b3, 0xde469fbd99a05fe3, 0xa59bc234db398c25, - 0xf6c69a72a3989f5c, 0xb7dcbf5354e9bece, 0x88fcf317f22241e2, - 0xcc20ce9bd35c78a5, 0x98165af37b2153df, 0xe2a0b5dc971f303a, - 0xa8d9d1535ce3b396, 0xfb9b7cd9a4a7443c, 0xbb764c4ca7a44410, - 0x8bab8eefb6409c1a, 0xd01fef10a657842c, 0x9b10a4e5e9913129, - 0xe7109bfba19c0c9d, 0xac2820d9623bf429, 0x80444b5e7aa7cf85, - 0xbf21e44003acdd2d, 0x8e679c2f5e44ff8f, 0xd433179d9c8cb841, - 0x9e19db92b4e31ba9, 0xeb96bf6ebadf77d9, 0xaf87023b9bf0ee6b, -}; - -// Binary exponents of pow(10, k), for k = -348, -340, ..., 340, corresponding -// to significands above. -template -const int16_t basic_data::pow10_exponents[] = { - -1220, -1193, -1166, -1140, -1113, -1087, -1060, -1034, -1007, -980, -954, - -927, -901, -874, -847, -821, -794, -768, -741, -715, -688, -661, - -635, -608, -582, -555, -529, -502, -475, -449, -422, -396, -369, - -343, -316, -289, -263, -236, -210, -183, -157, -130, -103, -77, - -50, -24, 3, 30, 56, 83, 109, 136, 162, 189, 216, - 242, 269, 295, 322, 348, 375, 402, 428, 455, 481, 508, - 534, 561, 588, 614, 641, 667, 694, 720, 747, 774, 800, - 827, 853, 880, 907, 933, 960, 986, 1013, 1039, 1066}; - -template -const char basic_data::foreground_color[] = "\x1b[38;2;"; -template -const char basic_data::background_color[] = "\x1b[48;2;"; -template const char basic_data::reset_color[] = "\x1b[0m"; -template const wchar_t basic_data::wreset_color[] = L"\x1b[0m"; -template const char basic_data::signs[] = {0, '-', '+', ' '}; - -template struct bits { - static FMT_CONSTEXPR_DECL const int value = - static_cast(sizeof(T) * std::numeric_limits::digits); -}; - -class fp; -template fp normalize(fp value); - -// Lower (upper) boundary is a value half way between a floating-point value -// and its predecessor (successor). Boundaries have the same exponent as the -// value so only significands are stored. -struct boundaries { - uint64_t lower; - uint64_t upper; -}; - -// A handmade floating-point number f * pow(2, e). -class fp { - private: - using significand_type = uint64_t; - - // All sizes are in bits. - // Subtract 1 to account for an implicit most significant bit in the - // normalized form. - static FMT_CONSTEXPR_DECL const int double_significand_size = - std::numeric_limits::digits - 1; - static FMT_CONSTEXPR_DECL const uint64_t implicit_bit = - 1ULL << double_significand_size; - - public: - significand_type f; - int e; - - static FMT_CONSTEXPR_DECL const int significand_size = - bits::value; - - fp() : f(0), e(0) {} - fp(uint64_t f_val, int e_val) : f(f_val), e(e_val) {} - - // Constructs fp from an IEEE754 double. It is a template to prevent compile - // errors on platforms where double is not IEEE754. - template explicit fp(Double d) { assign(d); } - - // Normalizes the value converted from double and multiplied by (1 << SHIFT). - template friend fp normalize(fp value) { - // Handle subnormals. - const auto shifted_implicit_bit = fp::implicit_bit << SHIFT; - while ((value.f & shifted_implicit_bit) == 0) { - value.f <<= 1; - --value.e; - } - // Subtract 1 to account for hidden bit. - const auto offset = - fp::significand_size - fp::double_significand_size - SHIFT - 1; - value.f <<= offset; - value.e -= offset; - return value; - } - - // Assigns d to this and return true iff predecessor is closer than successor. - template - bool assign(Double d) { - // Assume double is in the format [sign][exponent][significand]. - using limits = std::numeric_limits; - const int exponent_size = - bits::value - double_significand_size - 1; // -1 for sign - const uint64_t significand_mask = implicit_bit - 1; - const uint64_t exponent_mask = (~0ULL >> 1) & ~significand_mask; - const int exponent_bias = (1 << exponent_size) - limits::max_exponent - 1; - auto u = bit_cast(d); - f = u & significand_mask; - auto biased_e = (u & exponent_mask) >> double_significand_size; - // Predecessor is closer if d is a normalized power of 2 (f == 0) other than - // the smallest normalized number (biased_e > 1). - bool is_predecessor_closer = f == 0 && biased_e > 1; - if (biased_e != 0) - f += implicit_bit; - else - biased_e = 1; // Subnormals use biased exponent 1 (min exponent). - e = static_cast(biased_e - exponent_bias - double_significand_size); - return is_predecessor_closer; - } - - template - bool assign(Double) { - *this = fp(); - return false; - } - - // Assigns d to this together with computing lower and upper boundaries, - // where a boundary is a value half way between the number and its predecessor - // (lower) or successor (upper). The upper boundary is normalized and lower - // has the same exponent but may be not normalized. - template boundaries assign_with_boundaries(Double d) { - bool is_lower_closer = assign(d); - fp lower = - is_lower_closer ? fp((f << 2) - 1, e - 2) : fp((f << 1) - 1, e - 1); - // 1 in normalize accounts for the exponent shift above. - fp upper = normalize<1>(fp((f << 1) + 1, e - 1)); - lower.f <<= lower.e - upper.e; - return boundaries{lower.f, upper.f}; - } - - template boundaries assign_float_with_boundaries(Double d) { - assign(d); - constexpr int min_normal_e = std::numeric_limits::min_exponent - - std::numeric_limits::digits; - significand_type half_ulp = 1 << (std::numeric_limits::digits - - std::numeric_limits::digits - 1); - if (min_normal_e > e) half_ulp <<= min_normal_e - e; - fp upper = normalize<0>(fp(f + half_ulp, e)); - fp lower = fp( - f - (half_ulp >> ((f == implicit_bit && e > min_normal_e) ? 1 : 0)), e); - lower.f <<= lower.e - upper.e; - return boundaries{lower.f, upper.f}; - } -}; - -inline bool operator==(fp x, fp y) { return x.f == y.f && x.e == y.e; } - -// Computes lhs * rhs / pow(2, 64) rounded to nearest with half-up tie breaking. -inline uint64_t multiply(uint64_t lhs, uint64_t rhs) { -#if FMT_USE_INT128 - auto product = static_cast<__uint128_t>(lhs) * rhs; - auto f = static_cast(product >> 64); - return (static_cast(product) & (1ULL << 63)) != 0 ? f + 1 : f; -#else - // Multiply 32-bit parts of significands. - uint64_t mask = (1ULL << 32) - 1; - uint64_t a = lhs >> 32, b = lhs & mask; - uint64_t c = rhs >> 32, d = rhs & mask; - uint64_t ac = a * c, bc = b * c, ad = a * d, bd = b * d; - // Compute mid 64-bit of result and round. - uint64_t mid = (bd >> 32) + (ad & mask) + (bc & mask) + (1U << 31); - return ac + (ad >> 32) + (bc >> 32) + (mid >> 32); -#endif -} - -inline fp operator*(fp x, fp y) { return {multiply(x.f, y.f), x.e + y.e + 64}; } - -// Returns a cached power of 10 `c_k = c_k.f * pow(2, c_k.e)` such that its -// (binary) exponent satisfies `min_exponent <= c_k.e <= min_exponent + 28`. -FMT_FUNC fp get_cached_power(int min_exponent, int& pow10_exponent) { - const uint64_t one_over_log2_10 = 0x4d104d42; // round(pow(2, 32) / log2(10)) - int index = static_cast( - static_cast( - (min_exponent + fp::significand_size - 1) * one_over_log2_10 + - ((uint64_t(1) << 32) - 1) // ceil - ) >> - 32 // arithmetic shift - ); - // Decimal exponent of the first (smallest) cached power of 10. - const int first_dec_exp = -348; - // Difference between 2 consecutive decimal exponents in cached powers of 10. - const int dec_exp_step = 8; - index = (index - first_dec_exp - 1) / dec_exp_step + 1; - pow10_exponent = first_dec_exp + index * dec_exp_step; - return {data::pow10_significands[index], data::pow10_exponents[index]}; -} - -// A simple accumulator to hold the sums of terms in bigint::square if uint128_t -// is not available. -struct accumulator { - uint64_t lower; - uint64_t upper; - - accumulator() : lower(0), upper(0) {} - explicit operator uint32_t() const { return static_cast(lower); } - - void operator+=(uint64_t n) { - lower += n; - if (lower < n) ++upper; - } - void operator>>=(int shift) { - assert(shift == 32); - (void)shift; - lower = (upper << 32) | (lower >> 32); - upper >>= 32; - } -}; - -class bigint { - private: - // A bigint is stored as an array of bigits (big digits), with bigit at index - // 0 being the least significant one. - using bigit = uint32_t; - using double_bigit = uint64_t; - enum { bigits_capacity = 32 }; - basic_memory_buffer bigits_; - int exp_; - - static FMT_CONSTEXPR_DECL const int bigit_bits = bits::value; - - friend struct formatter; - - void subtract_bigits(int index, bigit other, bigit& borrow) { - auto result = static_cast(bigits_[index]) - other - borrow; - bigits_[index] = static_cast(result); - borrow = static_cast(result >> (bigit_bits * 2 - 1)); - } - - void remove_leading_zeros() { - int num_bigits = static_cast(bigits_.size()) - 1; - while (num_bigits > 0 && bigits_[num_bigits] == 0) --num_bigits; - bigits_.resize(num_bigits + 1); - } - - // Computes *this -= other assuming aligned bigints and *this >= other. - void subtract_aligned(const bigint& other) { - FMT_ASSERT(other.exp_ >= exp_, "unaligned bigints"); - FMT_ASSERT(compare(*this, other) >= 0, ""); - bigit borrow = 0; - int i = other.exp_ - exp_; - for (int j = 0, n = static_cast(other.bigits_.size()); j != n; - ++i, ++j) { - subtract_bigits(i, other.bigits_[j], borrow); - } - while (borrow > 0) subtract_bigits(i, 0, borrow); - remove_leading_zeros(); - } - - void multiply(uint32_t value) { - const double_bigit wide_value = value; - bigit carry = 0; - for (size_t i = 0, n = bigits_.size(); i < n; ++i) { - double_bigit result = bigits_[i] * wide_value + carry; - bigits_[i] = static_cast(result); - carry = static_cast(result >> bigit_bits); - } - if (carry != 0) bigits_.push_back(carry); - } - - void multiply(uint64_t value) { - const bigit mask = ~bigit(0); - const double_bigit lower = value & mask; - const double_bigit upper = value >> bigit_bits; - double_bigit carry = 0; - for (size_t i = 0, n = bigits_.size(); i < n; ++i) { - double_bigit result = bigits_[i] * lower + (carry & mask); - carry = - bigits_[i] * upper + (result >> bigit_bits) + (carry >> bigit_bits); - bigits_[i] = static_cast(result); - } - while (carry != 0) { - bigits_.push_back(carry & mask); - carry >>= bigit_bits; - } - } - - public: - bigint() : exp_(0) {} - explicit bigint(uint64_t n) { assign(n); } - ~bigint() { assert(bigits_.capacity() <= bigits_capacity); } - - bigint(const bigint&) = delete; - void operator=(const bigint&) = delete; - - void assign(const bigint& other) { - bigits_.resize(other.bigits_.size()); - auto data = other.bigits_.data(); - std::copy(data, data + other.bigits_.size(), bigits_.data()); - exp_ = other.exp_; - } - - void assign(uint64_t n) { - int num_bigits = 0; - do { - bigits_[num_bigits++] = n & ~bigit(0); - n >>= bigit_bits; - } while (n != 0); - bigits_.resize(num_bigits); - exp_ = 0; - } - - int num_bigits() const { return static_cast(bigits_.size()) + exp_; } - - bigint& operator<<=(int shift) { - assert(shift >= 0); - exp_ += shift / bigit_bits; - shift %= bigit_bits; - if (shift == 0) return *this; - bigit carry = 0; - for (size_t i = 0, n = bigits_.size(); i < n; ++i) { - bigit c = bigits_[i] >> (bigit_bits - shift); - bigits_[i] = (bigits_[i] << shift) + carry; - carry = c; - } - if (carry != 0) bigits_.push_back(carry); - return *this; - } - - template bigint& operator*=(Int value) { - FMT_ASSERT(value > 0, ""); - multiply(uint32_or_64_or_128_t(value)); - return *this; - } - - friend int compare(const bigint& lhs, const bigint& rhs) { - int num_lhs_bigits = lhs.num_bigits(), num_rhs_bigits = rhs.num_bigits(); - if (num_lhs_bigits != num_rhs_bigits) - return num_lhs_bigits > num_rhs_bigits ? 1 : -1; - int i = static_cast(lhs.bigits_.size()) - 1; - int j = static_cast(rhs.bigits_.size()) - 1; - int end = i - j; - if (end < 0) end = 0; - for (; i >= end; --i, --j) { - bigit lhs_bigit = lhs.bigits_[i], rhs_bigit = rhs.bigits_[j]; - if (lhs_bigit != rhs_bigit) return lhs_bigit > rhs_bigit ? 1 : -1; - } - if (i != j) return i > j ? 1 : -1; - return 0; - } - - // Returns compare(lhs1 + lhs2, rhs). - friend int add_compare(const bigint& lhs1, const bigint& lhs2, - const bigint& rhs) { - int max_lhs_bigits = (std::max)(lhs1.num_bigits(), lhs2.num_bigits()); - int num_rhs_bigits = rhs.num_bigits(); - if (max_lhs_bigits + 1 < num_rhs_bigits) return -1; - if (max_lhs_bigits > num_rhs_bigits) return 1; - auto get_bigit = [](const bigint& n, int i) -> bigit { - return i >= n.exp_ && i < n.num_bigits() ? n.bigits_[i - n.exp_] : 0; - }; - double_bigit borrow = 0; - int min_exp = (std::min)((std::min)(lhs1.exp_, lhs2.exp_), rhs.exp_); - for (int i = num_rhs_bigits - 1; i >= min_exp; --i) { - double_bigit sum = - static_cast(get_bigit(lhs1, i)) + get_bigit(lhs2, i); - bigit rhs_bigit = get_bigit(rhs, i); - if (sum > rhs_bigit + borrow) return 1; - borrow = rhs_bigit + borrow - sum; - if (borrow > 1) return -1; - borrow <<= bigit_bits; - } - return borrow != 0 ? -1 : 0; - } - - // Assigns pow(10, exp) to this bigint. - void assign_pow10(int exp) { - assert(exp >= 0); - if (exp == 0) return assign(1); - // Find the top bit. - int bitmask = 1; - while (exp >= bitmask) bitmask <<= 1; - bitmask >>= 1; - // pow(10, exp) = pow(5, exp) * pow(2, exp). First compute pow(5, exp) by - // repeated squaring and multiplication. - assign(5); - bitmask >>= 1; - while (bitmask != 0) { - square(); - if ((exp & bitmask) != 0) *this *= 5; - bitmask >>= 1; - } - *this <<= exp; // Multiply by pow(2, exp) by shifting. - } - - void square() { - basic_memory_buffer n(std::move(bigits_)); - int num_bigits = static_cast(bigits_.size()); - int num_result_bigits = 2 * num_bigits; - bigits_.resize(num_result_bigits); - using accumulator_t = conditional_t; - auto sum = accumulator_t(); - for (int bigit_index = 0; bigit_index < num_bigits; ++bigit_index) { - // Compute bigit at position bigit_index of the result by adding - // cross-product terms n[i] * n[j] such that i + j == bigit_index. - for (int i = 0, j = bigit_index; j >= 0; ++i, --j) { - // Most terms are multiplied twice which can be optimized in the future. - sum += static_cast(n[i]) * n[j]; - } - bigits_[bigit_index] = static_cast(sum); - sum >>= bits::value; // Compute the carry. - } - // Do the same for the top half. - for (int bigit_index = num_bigits; bigit_index < num_result_bigits; - ++bigit_index) { - for (int j = num_bigits - 1, i = bigit_index - j; i < num_bigits;) - sum += static_cast(n[i++]) * n[j--]; - bigits_[bigit_index] = static_cast(sum); - sum >>= bits::value; - } - --num_result_bigits; - remove_leading_zeros(); - exp_ *= 2; - } - - // Divides this bignum by divisor, assigning the remainder to this and - // returning the quotient. - int divmod_assign(const bigint& divisor) { - FMT_ASSERT(this != &divisor, ""); - if (compare(*this, divisor) < 0) return 0; - int num_bigits = static_cast(bigits_.size()); - FMT_ASSERT(divisor.bigits_[divisor.bigits_.size() - 1] != 0, ""); - int exp_difference = exp_ - divisor.exp_; - if (exp_difference > 0) { - // Align bigints by adding trailing zeros to simplify subtraction. - bigits_.resize(num_bigits + exp_difference); - for (int i = num_bigits - 1, j = i + exp_difference; i >= 0; --i, --j) - bigits_[j] = bigits_[i]; - std::uninitialized_fill_n(bigits_.data(), exp_difference, 0); - exp_ -= exp_difference; - } - int quotient = 0; - do { - subtract_aligned(divisor); - ++quotient; - } while (compare(*this, divisor) >= 0); - return quotient; - } -}; - -enum round_direction { unknown, up, down }; - -// Given the divisor (normally a power of 10), the remainder = v % divisor for -// some number v and the error, returns whether v should be rounded up, down, or -// whether the rounding direction can't be determined due to error. -// error should be less than divisor / 2. -inline round_direction get_round_direction(uint64_t divisor, uint64_t remainder, - uint64_t error) { - FMT_ASSERT(remainder < divisor, ""); // divisor - remainder won't overflow. - FMT_ASSERT(error < divisor, ""); // divisor - error won't overflow. - FMT_ASSERT(error < divisor - error, ""); // error * 2 won't overflow. - // Round down if (remainder + error) * 2 <= divisor. - if (remainder <= divisor - remainder && error * 2 <= divisor - remainder * 2) - return down; - // Round up if (remainder - error) * 2 >= divisor. - if (remainder >= error && - remainder - error >= divisor - (remainder - error)) { - return up; - } - return unknown; -} - -namespace digits { -enum result { - more, // Generate more digits. - done, // Done generating digits. - error // Digit generation cancelled due to an error. -}; -} - -// Generates output using the Grisu digit-gen algorithm. -// error: the size of the region (lower, upper) outside of which numbers -// definitely do not round to value (Delta in Grisu3). -template -FMT_ALWAYS_INLINE digits::result grisu_gen_digits(fp value, uint64_t error, - int& exp, Handler& handler) { - const fp one(1ULL << -value.e, value.e); - // The integral part of scaled value (p1 in Grisu) = value / one. It cannot be - // zero because it contains a product of two 64-bit numbers with MSB set (due - // to normalization) - 1, shifted right by at most 60 bits. - auto integral = static_cast(value.f >> -one.e); - FMT_ASSERT(integral != 0, ""); - FMT_ASSERT(integral == value.f >> -one.e, ""); - // The fractional part of scaled value (p2 in Grisu) c = value % one. - uint64_t fractional = value.f & (one.f - 1); - exp = count_digits(integral); // kappa in Grisu. - // Divide by 10 to prevent overflow. - auto result = handler.on_start(data::powers_of_10_64[exp - 1] << -one.e, - value.f / 10, error * 10, exp); - if (result != digits::more) return result; - // Generate digits for the integral part. This can produce up to 10 digits. - do { - uint32_t digit = 0; - auto divmod_integral = [&](uint32_t divisor) { - digit = integral / divisor; - integral %= divisor; - }; - // This optimization by Milo Yip reduces the number of integer divisions by - // one per iteration. - switch (exp) { - case 10: - divmod_integral(1000000000); - break; - case 9: - divmod_integral(100000000); - break; - case 8: - divmod_integral(10000000); - break; - case 7: - divmod_integral(1000000); - break; - case 6: - divmod_integral(100000); - break; - case 5: - divmod_integral(10000); - break; - case 4: - divmod_integral(1000); - break; - case 3: - divmod_integral(100); - break; - case 2: - divmod_integral(10); - break; - case 1: - digit = integral; - integral = 0; - break; - default: - FMT_ASSERT(false, "invalid number of digits"); - } - --exp; - uint64_t remainder = - (static_cast(integral) << -one.e) + fractional; - result = handler.on_digit(static_cast('0' + digit), - data::powers_of_10_64[exp] << -one.e, remainder, - error, exp, true); - if (result != digits::more) return result; - } while (exp > 0); - // Generate digits for the fractional part. - for (;;) { - fractional *= 10; - error *= 10; - char digit = - static_cast('0' + static_cast(fractional >> -one.e)); - fractional &= one.f - 1; - --exp; - result = handler.on_digit(digit, one.f, fractional, error, exp, false); - if (result != digits::more) return result; - } -} - -// The fixed precision digit handler. -struct fixed_handler { - char* buf; - int size; - int precision; - int exp10; - bool fixed; - - digits::result on_start(uint64_t divisor, uint64_t remainder, uint64_t error, - int& exp) { - // Non-fixed formats require at least one digit and no precision adjustment. - if (!fixed) return digits::more; - // Adjust fixed precision by exponent because it is relative to decimal - // point. - precision += exp + exp10; - // Check if precision is satisfied just by leading zeros, e.g. - // format("{:.2f}", 0.001) gives "0.00" without generating any digits. - if (precision > 0) return digits::more; - if (precision < 0) return digits::done; - auto dir = get_round_direction(divisor, remainder, error); - if (dir == unknown) return digits::error; - buf[size++] = dir == up ? '1' : '0'; - return digits::done; - } - - digits::result on_digit(char digit, uint64_t divisor, uint64_t remainder, - uint64_t error, int, bool integral) { - FMT_ASSERT(remainder < divisor, ""); - buf[size++] = digit; - if (size < precision) return digits::more; - if (!integral) { - // Check if error * 2 < divisor with overflow prevention. - // The check is not needed for the integral part because error = 1 - // and divisor > (1 << 32) there. - if (error >= divisor || error >= divisor - error) return digits::error; - } else { - FMT_ASSERT(error == 1 && divisor > 2, ""); - } - auto dir = get_round_direction(divisor, remainder, error); - if (dir != up) return dir == down ? digits::done : digits::error; - ++buf[size - 1]; - for (int i = size - 1; i > 0 && buf[i] > '9'; --i) { - buf[i] = '0'; - ++buf[i - 1]; - } - if (buf[0] > '9') { - buf[0] = '1'; - buf[size++] = '0'; - } - return digits::done; - } -}; - -// The shortest representation digit handler. -struct grisu_shortest_handler { - char* buf; - int size; - // Distance between scaled value and upper bound (wp_W in Grisu3). - uint64_t diff; - - digits::result on_start(uint64_t, uint64_t, uint64_t, int&) { - return digits::more; - } - - // Decrement the generated number approaching value from above. - void round(uint64_t d, uint64_t divisor, uint64_t& remainder, - uint64_t error) { - while ( - remainder < d && error - remainder >= divisor && - (remainder + divisor < d || d - remainder >= remainder + divisor - d)) { - --buf[size - 1]; - remainder += divisor; - } - } - - // Implements Grisu's round_weed. - digits::result on_digit(char digit, uint64_t divisor, uint64_t remainder, - uint64_t error, int exp, bool integral) { - buf[size++] = digit; - if (remainder >= error) return digits::more; - uint64_t unit = integral ? 1 : data::powers_of_10_64[-exp]; - uint64_t up = (diff - 1) * unit; // wp_Wup - round(up, divisor, remainder, error); - uint64_t down = (diff + 1) * unit; // wp_Wdown - if (remainder < down && error - remainder >= divisor && - (remainder + divisor < down || - down - remainder > remainder + divisor - down)) { - return digits::error; - } - return 2 * unit <= remainder && remainder <= error - 4 * unit - ? digits::done - : digits::error; - } -}; - -// Formats value using a variation of the Fixed-Precision Positive -// Floating-Point Printout ((FPP)^2) algorithm by Steele & White: -// https://fmt.dev/p372-steele.pdf. -template -void fallback_format(Double d, buffer& buf, int& exp10) { - bigint numerator; // 2 * R in (FPP)^2. - bigint denominator; // 2 * S in (FPP)^2. - // lower and upper are differences between value and corresponding boundaries. - bigint lower; // (M^- in (FPP)^2). - bigint upper_store; // upper's value if different from lower. - bigint* upper = nullptr; // (M^+ in (FPP)^2). - fp value; - // Shift numerator and denominator by an extra bit or two (if lower boundary - // is closer) to make lower and upper integers. This eliminates multiplication - // by 2 during later computations. - // TODO: handle float - int shift = value.assign(d) ? 2 : 1; - uint64_t significand = value.f << shift; - if (value.e >= 0) { - numerator.assign(significand); - numerator <<= value.e; - lower.assign(1); - lower <<= value.e; - if (shift != 1) { - upper_store.assign(1); - upper_store <<= value.e + 1; - upper = &upper_store; - } - denominator.assign_pow10(exp10); - denominator <<= 1; - } else if (exp10 < 0) { - numerator.assign_pow10(-exp10); - lower.assign(numerator); - if (shift != 1) { - upper_store.assign(numerator); - upper_store <<= 1; - upper = &upper_store; - } - numerator *= significand; - denominator.assign(1); - denominator <<= shift - value.e; - } else { - numerator.assign(significand); - denominator.assign_pow10(exp10); - denominator <<= shift - value.e; - lower.assign(1); - if (shift != 1) { - upper_store.assign(1ULL << 1); - upper = &upper_store; - } - } - if (!upper) upper = &lower; - // Invariant: value == (numerator / denominator) * pow(10, exp10). - bool even = (value.f & 1) == 0; - int num_digits = 0; - char* data = buf.data(); - for (;;) { - int digit = numerator.divmod_assign(denominator); - bool low = compare(numerator, lower) - even < 0; // numerator <[=] lower. - // numerator + upper >[=] pow10: - bool high = add_compare(numerator, *upper, denominator) + even > 0; - data[num_digits++] = static_cast('0' + digit); - if (low || high) { - if (!low) { - ++data[num_digits - 1]; - } else if (high) { - int result = add_compare(numerator, numerator, denominator); - // Round half to even. - if (result > 0 || (result == 0 && (digit % 2) != 0)) - ++data[num_digits - 1]; - } - buf.resize(num_digits); - exp10 -= num_digits - 1; - return; - } - numerator *= 10; - lower *= 10; - if (upper != &lower) *upper *= 10; - } -} - -// Formats value using the Grisu algorithm -// (https://www.cs.tufts.edu/~nr/cs257/archive/florian-loitsch/printf.pdf) -// if T is a IEEE754 binary32 or binary64 and snprintf otherwise. -template -int format_float(T value, int precision, float_specs specs, buffer& buf) { - static_assert(!std::is_same(), ""); - FMT_ASSERT(value >= 0, "value is negative"); - - const bool fixed = specs.format == float_format::fixed; - if (value <= 0) { // <= instead of == to silence a warning. - if (precision <= 0 || !fixed) { - buf.push_back('0'); - return 0; - } - buf.resize(to_unsigned(precision)); - std::uninitialized_fill_n(buf.data(), precision, '0'); - return -precision; - } - - if (!specs.use_grisu) return snprintf_float(value, precision, specs, buf); - - int exp = 0; - const int min_exp = -60; // alpha in Grisu. - int cached_exp10 = 0; // K in Grisu. - if (precision != -1) { - if (precision > 17) return snprintf_float(value, precision, specs, buf); - fp normalized = normalize(fp(value)); - const auto cached_pow = get_cached_power( - min_exp - (normalized.e + fp::significand_size), cached_exp10); - normalized = normalized * cached_pow; - fixed_handler handler{buf.data(), 0, precision, -cached_exp10, fixed}; - if (grisu_gen_digits(normalized, 1, exp, handler) == digits::error) - return snprintf_float(value, precision, specs, buf); - int num_digits = handler.size; - if (!fixed) { - // Remove trailing zeros. - while (num_digits > 0 && buf[num_digits - 1] == '0') { - --num_digits; - ++exp; - } - } - buf.resize(to_unsigned(num_digits)); - } else { - fp fp_value; - auto boundaries = specs.binary32 - ? fp_value.assign_float_with_boundaries(value) - : fp_value.assign_with_boundaries(value); - fp_value = normalize(fp_value); - // Find a cached power of 10 such that multiplying value by it will bring - // the exponent in the range [min_exp, -32]. - const fp cached_pow = get_cached_power( - min_exp - (fp_value.e + fp::significand_size), cached_exp10); - // Multiply value and boundaries by the cached power of 10. - fp_value = fp_value * cached_pow; - boundaries.lower = multiply(boundaries.lower, cached_pow.f); - boundaries.upper = multiply(boundaries.upper, cached_pow.f); - assert(min_exp <= fp_value.e && fp_value.e <= -32); - --boundaries.lower; // \tilde{M}^- - 1 ulp -> M^-_{\downarrow}. - ++boundaries.upper; // \tilde{M}^+ + 1 ulp -> M^+_{\uparrow}. - // Numbers outside of (lower, upper) definitely do not round to value. - grisu_shortest_handler handler{buf.data(), 0, - boundaries.upper - fp_value.f}; - auto result = - grisu_gen_digits(fp(boundaries.upper, fp_value.e), - boundaries.upper - boundaries.lower, exp, handler); - if (result == digits::error) { - exp += handler.size - cached_exp10 - 1; - fallback_format(value, buf, exp); - return exp; - } - buf.resize(to_unsigned(handler.size)); - } - return exp - cached_exp10; -} - -template -int snprintf_float(T value, int precision, float_specs specs, - buffer& buf) { - // Buffer capacity must be non-zero, otherwise MSVC's vsnprintf_s will fail. - FMT_ASSERT(buf.capacity() > buf.size(), "empty buffer"); - static_assert(!std::is_same(), ""); - - // Subtract 1 to account for the difference in precision since we use %e for - // both general and exponent format. - if (specs.format == float_format::general || - specs.format == float_format::exp) - precision = (precision >= 0 ? precision : 6) - 1; - - // Build the format string. - enum { max_format_size = 7 }; // Ths longest format is "%#.*Le". - char format[max_format_size]; - char* format_ptr = format; - *format_ptr++ = '%'; - if (specs.trailing_zeros) *format_ptr++ = '#'; - if (precision >= 0) { - *format_ptr++ = '.'; - *format_ptr++ = '*'; - } - if (std::is_same()) *format_ptr++ = 'L'; - *format_ptr++ = specs.format != float_format::hex - ? (specs.format == float_format::fixed ? 'f' : 'e') - : (specs.upper ? 'A' : 'a'); - *format_ptr = '\0'; - - // Format using snprintf. - auto offset = buf.size(); - for (;;) { - auto begin = buf.data() + offset; - auto capacity = buf.capacity() - offset; -#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION - if (precision > 100000) - throw std::runtime_error( - "fuzz mode - avoid large allocation inside snprintf"); -#endif - // Suppress the warning about a nonliteral format string. - auto snprintf_ptr = FMT_SNPRINTF; - int result = precision >= 0 - ? snprintf_ptr(begin, capacity, format, precision, value) - : snprintf_ptr(begin, capacity, format, value); - if (result < 0) { - buf.reserve(buf.capacity() + 1); // The buffer will grow exponentially. - continue; - } - unsigned size = to_unsigned(result); - // Size equal to capacity means that the last character was truncated. - if (size >= capacity) { - buf.reserve(size + offset + 1); // Add 1 for the terminating '\0'. - continue; - } - auto is_digit = [](char c) { return c >= '0' && c <= '9'; }; - if (specs.format == float_format::fixed) { - if (precision == 0) { - buf.resize(size); - return 0; - } - // Find and remove the decimal point. - auto end = begin + size, p = end; - do { - --p; - } while (is_digit(*p)); - int fraction_size = static_cast(end - p - 1); - std::memmove(p, p + 1, fraction_size); - buf.resize(size - 1); - return -fraction_size; - } - if (specs.format == float_format::hex) { - buf.resize(size + offset); - return 0; - } - // Find and parse the exponent. - auto end = begin + size, exp_pos = end; - do { - --exp_pos; - } while (*exp_pos != 'e'); - char sign = exp_pos[1]; - assert(sign == '+' || sign == '-'); - int exp = 0; - auto p = exp_pos + 2; // Skip 'e' and sign. - do { - assert(is_digit(*p)); - exp = exp * 10 + (*p++ - '0'); - } while (p != end); - if (sign == '-') exp = -exp; - int fraction_size = 0; - if (exp_pos != begin + 1) { - // Remove trailing zeros. - auto fraction_end = exp_pos - 1; - while (*fraction_end == '0') --fraction_end; - // Move the fractional part left to get rid of the decimal point. - fraction_size = static_cast(fraction_end - begin - 1); - std::memmove(begin + 1, begin + 2, fraction_size); - } - buf.resize(fraction_size + offset + 1); - return exp - fraction_size; - } -} -} // namespace internal - -template <> struct formatter { - format_parse_context::iterator parse(format_parse_context& ctx) { - return ctx.begin(); - } - - format_context::iterator format(const internal::bigint& n, - format_context& ctx) { - auto out = ctx.out(); - bool first = true; - for (auto i = n.bigits_.size(); i > 0; --i) { - auto value = n.bigits_[i - 1]; - if (first) { - out = format_to(out, "{:x}", value); - first = false; - continue; - } - out = format_to(out, "{:08x}", value); - } - if (n.exp_ > 0) - out = format_to(out, "p{}", n.exp_ * internal::bigint::bigit_bits); - return out; - } -}; - -#if FMT_USE_WINDOWS_H - -FMT_FUNC internal::utf8_to_utf16::utf8_to_utf16(string_view s) { - static const char ERROR_MSG[] = "cannot convert string from UTF-8 to UTF-16"; - if (s.size() > INT_MAX) - FMT_THROW(windows_error(ERROR_INVALID_PARAMETER, ERROR_MSG)); - int s_size = static_cast(s.size()); - if (s_size == 0) { - // MultiByteToWideChar does not support zero length, handle separately. - buffer_.resize(1); - buffer_[0] = 0; - return; - } - - int length = MultiByteToWideChar(CP_UTF8, MB_ERR_INVALID_CHARS, s.data(), - s_size, nullptr, 0); - if (length == 0) FMT_THROW(windows_error(GetLastError(), ERROR_MSG)); - buffer_.resize(length + 1); - length = MultiByteToWideChar(CP_UTF8, MB_ERR_INVALID_CHARS, s.data(), s_size, - &buffer_[0], length); - if (length == 0) FMT_THROW(windows_error(GetLastError(), ERROR_MSG)); - buffer_[length] = 0; -} - -FMT_FUNC internal::utf16_to_utf8::utf16_to_utf8(wstring_view s) { - if (int error_code = convert(s)) { - FMT_THROW(windows_error(error_code, - "cannot convert string from UTF-16 to UTF-8")); - } -} - -FMT_FUNC int internal::utf16_to_utf8::convert(wstring_view s) { - if (s.size() > INT_MAX) return ERROR_INVALID_PARAMETER; - int s_size = static_cast(s.size()); - if (s_size == 0) { - // WideCharToMultiByte does not support zero length, handle separately. - buffer_.resize(1); - buffer_[0] = 0; - return 0; - } - - int length = WideCharToMultiByte(CP_UTF8, 0, s.data(), s_size, nullptr, 0, - nullptr, nullptr); - if (length == 0) return GetLastError(); - buffer_.resize(length + 1); - length = WideCharToMultiByte(CP_UTF8, 0, s.data(), s_size, &buffer_[0], - length, nullptr, nullptr); - if (length == 0) return GetLastError(); - buffer_[length] = 0; - return 0; -} - -FMT_FUNC void windows_error::init(int err_code, string_view format_str, - format_args args) { - error_code_ = err_code; - memory_buffer buffer; - internal::format_windows_error(buffer, err_code, vformat(format_str, args)); - std::runtime_error& base = *this; - base = std::runtime_error(to_string(buffer)); -} - -FMT_FUNC void internal::format_windows_error(internal::buffer& out, - int error_code, - string_view message) FMT_NOEXCEPT { - FMT_TRY { - wmemory_buffer buf; - buf.resize(inline_buffer_size); - for (;;) { - wchar_t* system_message = &buf[0]; - int result = FormatMessageW( - FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, nullptr, - error_code, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), system_message, - static_cast(buf.size()), nullptr); - if (result != 0) { - utf16_to_utf8 utf8_message; - if (utf8_message.convert(system_message) == ERROR_SUCCESS) { - internal::writer w(out); - w.write(message); - w.write(": "); - w.write(utf8_message); - return; - } - break; - } - if (GetLastError() != ERROR_INSUFFICIENT_BUFFER) - break; // Can't get error message, report error code instead. - buf.resize(buf.size() * 2); - } - } - FMT_CATCH(...) {} - format_error_code(out, error_code, message); -} - -#endif // FMT_USE_WINDOWS_H - -FMT_FUNC void format_system_error(internal::buffer& out, int error_code, - string_view message) FMT_NOEXCEPT { - FMT_TRY { - memory_buffer buf; - buf.resize(inline_buffer_size); - for (;;) { - char* system_message = &buf[0]; - int result = - internal::safe_strerror(error_code, system_message, buf.size()); - if (result == 0) { - internal::writer w(out); - w.write(message); - w.write(": "); - w.write(system_message); - return; - } - if (result != ERANGE) - break; // Can't get error message, report error code instead. - buf.resize(buf.size() * 2); - } - } - FMT_CATCH(...) {} - format_error_code(out, error_code, message); -} - -FMT_FUNC void internal::error_handler::on_error(const char* message) { - FMT_THROW(format_error(message)); -} - -FMT_FUNC void report_system_error(int error_code, - fmt::string_view message) FMT_NOEXCEPT { - report_error(format_system_error, error_code, message); -} - -#if FMT_USE_WINDOWS_H -FMT_FUNC void report_windows_error(int error_code, - fmt::string_view message) FMT_NOEXCEPT { - report_error(internal::format_windows_error, error_code, message); -} -#endif - -FMT_FUNC void vprint(std::FILE* f, string_view format_str, format_args args) { - memory_buffer buffer; - internal::vformat_to(buffer, format_str, - basic_format_args>(args)); - internal::fwrite_fully(buffer.data(), 1, buffer.size(), f); -} - -FMT_FUNC void vprint(string_view format_str, format_args args) { - vprint(stdout, format_str, args); -} - -FMT_END_NAMESPACE - -#ifdef _MSC_VER -# pragma warning(pop) -#endif - -#endif // FMT_FORMAT_INL_H_ diff --git a/headers/papilo/external/fmt/format.cc b/headers/papilo/external/fmt/format.cc deleted file mode 100644 index 44ba77f..0000000 --- a/headers/papilo/external/fmt/format.cc +++ /dev/null @@ -1,176 +0,0 @@ -// Formatting library for C++ -// -// Copyright (c) 2012 - 2016, Victor Zverovich -// All rights reserved. -// -// For the license information refer to format.h. - -#include "fmt/format-inl.h" - -FMT_BEGIN_NAMESPACE -namespace internal { - -template -int format_float(char* buf, std::size_t size, const char* format, int precision, - T value) { -#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION - if (precision > 100000) - throw std::runtime_error( - "fuzz mode - avoid large allocation inside snprintf"); -#endif - // Suppress the warning about nonliteral format string. - auto snprintf_ptr = FMT_SNPRINTF; - return precision < 0 ? snprintf_ptr(buf, size, format, value) - : snprintf_ptr(buf, size, format, precision, value); -} -struct sprintf_specs { - int precision; - char type; - bool alt : 1; - - template - constexpr sprintf_specs(basic_format_specs specs) - : precision(specs.precision), type(specs.type), alt(specs.alt) {} - - constexpr bool has_precision() const { return precision >= 0; } -}; - -// This is deprecated and is kept only to preserve ABI compatibility. -template -char* sprintf_format(Double value, internal::buffer& buf, - sprintf_specs specs) { - // Buffer capacity must be non-zero, otherwise MSVC's vsnprintf_s will fail. - FMT_ASSERT(buf.capacity() != 0, "empty buffer"); - - // Build format string. - enum { max_format_size = 10 }; // longest format: %#-*.*Lg - char format[max_format_size]; - char* format_ptr = format; - *format_ptr++ = '%'; - if (specs.alt || !specs.type) *format_ptr++ = '#'; - if (specs.precision >= 0) { - *format_ptr++ = '.'; - *format_ptr++ = '*'; - } - if (std::is_same::value) *format_ptr++ = 'L'; - - char type = specs.type; - - if (type == '%') - type = 'f'; - else if (type == 0 || type == 'n') - type = 'g'; -#if FMT_MSC_VER - if (type == 'F') { - // MSVC's printf doesn't support 'F'. - type = 'f'; - } -#endif - *format_ptr++ = type; - *format_ptr = '\0'; - - // Format using snprintf. - char* start = nullptr; - char* decimal_point_pos = nullptr; - for (;;) { - std::size_t buffer_size = buf.capacity(); - start = &buf[0]; - int result = - format_float(start, buffer_size, format, specs.precision, value); - if (result >= 0) { - unsigned n = internal::to_unsigned(result); - if (n < buf.capacity()) { - // Find the decimal point. - auto p = buf.data(), end = p + n; - if (*p == '+' || *p == '-') ++p; - if (specs.type != 'a' && specs.type != 'A') { - while (p < end && *p >= '0' && *p <= '9') ++p; - if (p < end && *p != 'e' && *p != 'E') { - decimal_point_pos = p; - if (!specs.type) { - // Keep only one trailing zero after the decimal point. - ++p; - if (*p == '0') ++p; - while (p != end && *p >= '1' && *p <= '9') ++p; - char* where = p; - while (p != end && *p == '0') ++p; - if (p == end || *p < '0' || *p > '9') { - if (p != end) std::memmove(where, p, to_unsigned(end - p)); - n -= static_cast(p - where); - } - } - } - } - buf.resize(n); - break; // The buffer is large enough - continue with formatting. - } - buf.reserve(n + 1); - } else { - // If result is negative we ask to increase the capacity by at least 1, - // but as std::vector, the buffer grows exponentially. - buf.reserve(buf.capacity() + 1); - } - } - return decimal_point_pos; -} -} // namespace internal - -template FMT_API char* internal::sprintf_format(double, internal::buffer&, - sprintf_specs); -template FMT_API char* internal::sprintf_format(long double, - internal::buffer&, - sprintf_specs); - -template struct FMT_API internal::basic_data; - -// Workaround a bug in MSVC2013 that prevents instantiation of format_float. -int (*instantiate_format_float)(double, int, internal::float_specs, - internal::buffer&) = - internal::format_float; - -#ifndef FMT_STATIC_THOUSANDS_SEPARATOR -template FMT_API internal::locale_ref::locale_ref(const std::locale& loc); -template FMT_API std::locale internal::locale_ref::get() const; -#endif - -// Explicit instantiations for char. - -template FMT_API std::string internal::grouping_impl(locale_ref); -template FMT_API char internal::thousands_sep_impl(locale_ref); -template FMT_API char internal::decimal_point_impl(locale_ref); - -template FMT_API void internal::buffer::append(const char*, const char*); - -template FMT_API void internal::arg_map::init( - const basic_format_args& args); - -template FMT_API std::string internal::vformat( - string_view, basic_format_args); - -template FMT_API format_context::iterator internal::vformat_to( - internal::buffer&, string_view, basic_format_args); - -template FMT_API int internal::snprintf_float(double, int, - internal::float_specs, - internal::buffer&); -template FMT_API int internal::snprintf_float(long double, int, - internal::float_specs, - internal::buffer&); -template FMT_API int internal::format_float(double, int, internal::float_specs, - internal::buffer&); -template FMT_API int internal::format_float(long double, int, - internal::float_specs, - internal::buffer&); - -// Explicit instantiations for wchar_t. - -template FMT_API std::string internal::grouping_impl(locale_ref); -template FMT_API wchar_t internal::thousands_sep_impl(locale_ref); -template FMT_API wchar_t internal::decimal_point_impl(locale_ref); - -template FMT_API void internal::buffer::append(const wchar_t*, - const wchar_t*); - -template FMT_API std::wstring internal::vformat( - wstring_view, basic_format_args); -FMT_END_NAMESPACE diff --git a/headers/papilo/external/fmt/format.h b/headers/papilo/external/fmt/format.h deleted file mode 100644 index 01f41f5..0000000 --- a/headers/papilo/external/fmt/format.h +++ /dev/null @@ -1,3541 +0,0 @@ -/* - Formatting library for C++ - - Copyright (c) 2012 - present, Victor Zverovich - - Permission is hereby granted, free of charge, to any person obtaining - a copy of this software and associated documentation files (the - "Software"), to deal in the Software without restriction, including - without limitation the rights to use, copy, modify, merge, publish, - distribute, sublicense, and/or sell copies of the Software, and to - permit persons to whom the Software is furnished to do so, subject to - the following conditions: - - The above copyright notice and this permission notice shall be - included in all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - - --- Optional exception to the license --- - - As an exception, if, as a result of your compiling your source code, portions - of this Software are embedded into a machine-executable object form of such - source code, you may redistribute such embedded portions in such object form - without including the above copyright and permission notices. - */ - -#ifndef FMT_FORMAT_H_ -#define FMT_FORMAT_H_ - -#include "core.h" - -#include -#include -#include -#include -#include -#include -#include - -#ifdef __clang__ -# define FMT_CLANG_VERSION (__clang_major__ * 100 + __clang_minor__) -#else -# define FMT_CLANG_VERSION 0 -#endif - -#ifdef __INTEL_COMPILER -# define FMT_ICC_VERSION __INTEL_COMPILER -#elif defined(__ICL) -# define FMT_ICC_VERSION __ICL -#else -# define FMT_ICC_VERSION 0 -#endif - -#ifdef __NVCC__ -# define FMT_CUDA_VERSION (__CUDACC_VER_MAJOR__ * 100 + __CUDACC_VER_MINOR__) -#else -# define FMT_CUDA_VERSION 0 -#endif - -#ifdef __has_builtin -# define FMT_HAS_BUILTIN(x) __has_builtin(x) -#else -# define FMT_HAS_BUILTIN(x) 0 -#endif - -#if FMT_HAS_CPP_ATTRIBUTE(fallthrough) && \ - (__cplusplus >= 201703 || FMT_GCC_VERSION != 0) -# define FMT_FALLTHROUGH [[fallthrough]] -#else -# define FMT_FALLTHROUGH -#endif - -#ifndef FMT_THROW -# if FMT_EXCEPTIONS -# if FMT_MSC_VER -FMT_BEGIN_NAMESPACE -namespace internal { -template inline void do_throw(const Exception& x) { - // Silence unreachable code warnings in MSVC because these are nearly - // impossible to fix in a generic code. - volatile bool b = true; - if (b) throw x; -} -} // namespace internal -FMT_END_NAMESPACE -# define FMT_THROW(x) internal::do_throw(x) -# else -# define FMT_THROW(x) throw x -# endif -# else -# define FMT_THROW(x) \ - do { \ - static_cast(sizeof(x)); \ - FMT_ASSERT(false, ""); \ - } while (false) -# endif -#endif - -#ifndef FMT_USE_USER_DEFINED_LITERALS -// For Intel and NVIDIA compilers both they and the system gcc/msc support UDLs. -# if (FMT_HAS_FEATURE(cxx_user_literals) || FMT_GCC_VERSION >= 407 || \ - FMT_MSC_VER >= 1900) && \ - (!(FMT_ICC_VERSION || FMT_CUDA_VERSION) || FMT_ICC_VERSION >= 1500 || \ - FMT_CUDA_VERSION >= 700) -# define FMT_USE_USER_DEFINED_LITERALS 1 -# else -# define FMT_USE_USER_DEFINED_LITERALS 0 -# endif -#endif - -#ifndef FMT_USE_UDL_TEMPLATE -// EDG front end based compilers (icc, nvcc) do not support UDL templates yet -// and GCC 9 warns about them. -# if FMT_USE_USER_DEFINED_LITERALS && FMT_ICC_VERSION == 0 && \ - FMT_CUDA_VERSION == 0 && \ - ((FMT_GCC_VERSION >= 600 && FMT_GCC_VERSION <= 900 && \ - __cplusplus >= 201402L) || \ - FMT_CLANG_VERSION >= 304) -# define FMT_USE_UDL_TEMPLATE 1 -# else -# define FMT_USE_UDL_TEMPLATE 0 -# endif -#endif - -// __builtin_clz is broken in clang with Microsoft CodeGen: -// https://github.com/fmtlib/fmt/issues/519 -#if (FMT_GCC_VERSION || FMT_HAS_BUILTIN(__builtin_clz)) && !FMT_MSC_VER -# define FMT_BUILTIN_CLZ(n) __builtin_clz(n) -#endif -#if (FMT_GCC_VERSION || FMT_HAS_BUILTIN(__builtin_clzll)) && !FMT_MSC_VER -# define FMT_BUILTIN_CLZLL(n) __builtin_clzll(n) -#endif - -// Some compilers masquerade as both MSVC and GCC-likes or otherwise support -// __builtin_clz and __builtin_clzll, so only define FMT_BUILTIN_CLZ using the -// MSVC intrinsics if the clz and clzll builtins are not available. -#if FMT_MSC_VER && !defined(FMT_BUILTIN_CLZLL) && !defined(_MANAGED) -# include // _BitScanReverse, _BitScanReverse64 - -FMT_BEGIN_NAMESPACE -namespace internal { -// Avoid Clang with Microsoft CodeGen's -Wunknown-pragmas warning. -# ifndef __clang__ -# pragma intrinsic(_BitScanReverse) -# endif -inline uint32_t clz(uint32_t x) { - unsigned long r = 0; - _BitScanReverse(&r, x); - - FMT_ASSERT(x != 0, ""); - // Static analysis complains about using uninitialized data - // "r", but the only way that can happen is if "x" is 0, - // which the callers guarantee to not happen. -# pragma warning(suppress : 6102) - return 31 - r; -} -# define FMT_BUILTIN_CLZ(n) internal::clz(n) - -# if defined(_WIN64) && !defined(__clang__) -# pragma intrinsic(_BitScanReverse64) -# endif - -inline uint32_t clzll(uint64_t x) { - unsigned long r = 0; -# ifdef _WIN64 - _BitScanReverse64(&r, x); -# else - // Scan the high 32 bits. - if (_BitScanReverse(&r, static_cast(x >> 32))) return 63 - (r + 32); - - // Scan the low 32 bits. - _BitScanReverse(&r, static_cast(x)); -# endif - - FMT_ASSERT(x != 0, ""); - // Static analysis complains about using uninitialized data - // "r", but the only way that can happen is if "x" is 0, - // which the callers guarantee to not happen. -# pragma warning(suppress : 6102) - return 63 - r; -} -# define FMT_BUILTIN_CLZLL(n) internal::clzll(n) -} // namespace internal -FMT_END_NAMESPACE -#endif - -// Enable the deprecated numeric alignment. -#ifndef FMT_NUMERIC_ALIGN -# define FMT_NUMERIC_ALIGN 1 -#endif - -// Enable the deprecated percent specifier. -#ifndef FMT_DEPRECATED_PERCENT -# define FMT_DEPRECATED_PERCENT 0 -#endif - -FMT_BEGIN_NAMESPACE -namespace internal { - -// A helper function to suppress bogus "conditional expression is constant" -// warnings. -template inline T const_check(T value) { return value; } - -// An equivalent of `*reinterpret_cast(&source)` that doesn't have -// undefined behavior (e.g. due to type aliasing). -// Example: uint64_t d = bit_cast(2.718); -template -inline Dest bit_cast(const Source& source) { - static_assert(sizeof(Dest) == sizeof(Source), "size mismatch"); - Dest dest; - std::memcpy(&dest, &source, sizeof(dest)); - return dest; -} - -inline bool is_big_endian() { - auto u = 1u; - struct bytes { - char data[sizeof(u)]; - }; - return bit_cast(u).data[0] == 0; -} - -// A fallback implementation of uintptr_t for systems that lack it. -struct fallback_uintptr { - unsigned char value[sizeof(void*)]; - - fallback_uintptr() = default; - explicit fallback_uintptr(const void* p) { - *this = bit_cast(p); - if (is_big_endian()) { - for (size_t i = 0, j = sizeof(void*) - 1; i < j; ++i, --j) - std::swap(value[i], value[j]); - } - } -}; -#ifdef UINTPTR_MAX -using uintptr_t = ::uintptr_t; -inline uintptr_t to_uintptr(const void* p) { return bit_cast(p); } -#else -using uintptr_t = fallback_uintptr; -inline fallback_uintptr to_uintptr(const void* p) { - return fallback_uintptr(p); -} -#endif - -// Returns the largest possible value for type T. Same as -// std::numeric_limits::max() but shorter and not affected by the max macro. -template constexpr T max_value() { - return (std::numeric_limits::max)(); -} -template constexpr int num_bits() { - return std::numeric_limits::digits; -} -template <> constexpr int num_bits() { - return static_cast(sizeof(void*) * - std::numeric_limits::digits); -} - -// An approximation of iterator_t for pre-C++20 systems. -template -using iterator_t = decltype(std::begin(std::declval())); - -// Detect the iterator category of *any* given type in a SFINAE-friendly way. -// Unfortunately, older implementations of std::iterator_traits are not safe -// for use in a SFINAE-context. -template -struct iterator_category : std::false_type {}; - -template struct iterator_category { - using type = std::random_access_iterator_tag; -}; - -template -struct iterator_category> { - using type = typename It::iterator_category; -}; - -// Detect if *any* given type models the OutputIterator concept. -template class is_output_iterator { - // Check for mutability because all iterator categories derived from - // std::input_iterator_tag *may* also meet the requirements of an - // OutputIterator, thereby falling into the category of 'mutable iterators' - // [iterator.requirements.general] clause 4. The compiler reveals this - // property only at the point of *actually dereferencing* the iterator! - template - static decltype(*(std::declval())) test(std::input_iterator_tag); - template static char& test(std::output_iterator_tag); - template static const char& test(...); - - using type = decltype(test(typename iterator_category::type{})); - - public: - static const bool value = !std::is_const>::value; -}; - -// A workaround for std::string not having mutable data() until C++17. -template inline Char* get_data(std::basic_string& s) { - return &s[0]; -} -template -inline typename Container::value_type* get_data(Container& c) { - return c.data(); -} - -#ifdef _SECURE_SCL -// Make a checked iterator to avoid MSVC warnings. -template using checked_ptr = stdext::checked_array_iterator; -template checked_ptr make_checked(T* p, std::size_t size) { - return {p, size}; -} -#else -template using checked_ptr = T*; -template inline T* make_checked(T* p, std::size_t) { return p; } -#endif - -template ::value)> -inline checked_ptr reserve( - std::back_insert_iterator& it, std::size_t n) { - Container& c = get_container(it); - std::size_t size = c.size(); - c.resize(size + n); - return make_checked(get_data(c) + size, n); -} - -template -inline Iterator& reserve(Iterator& it, std::size_t) { - return it; -} - -// An output iterator that counts the number of objects written to it and -// discards them. -class counting_iterator { - private: - std::size_t count_; - - public: - using iterator_category = std::output_iterator_tag; - using difference_type = std::ptrdiff_t; - using pointer = void; - using reference = void; - using _Unchecked_type = counting_iterator; // Mark iterator as checked. - - struct value_type { - template void operator=(const T&) {} - }; - - counting_iterator() : count_(0) {} - - std::size_t count() const { return count_; } - - counting_iterator& operator++() { - ++count_; - return *this; - } - - counting_iterator operator++(int) { - auto it = *this; - ++*this; - return it; - } - - value_type operator*() const { return {}; } -}; - -template class truncating_iterator_base { - protected: - OutputIt out_; - std::size_t limit_; - std::size_t count_; - - truncating_iterator_base(OutputIt out, std::size_t limit) - : out_(out), limit_(limit), count_(0) {} - - public: - using iterator_category = std::output_iterator_tag; - using difference_type = void; - using pointer = void; - using reference = void; - using _Unchecked_type = - truncating_iterator_base; // Mark iterator as checked. - - OutputIt base() const { return out_; } - std::size_t count() const { return count_; } -}; - -// An output iterator that truncates the output and counts the number of objects -// written to it. -template ::value_type>::type> -class truncating_iterator; - -template -class truncating_iterator - : public truncating_iterator_base { - using traits = std::iterator_traits; - - mutable typename traits::value_type blackhole_; - - public: - using value_type = typename traits::value_type; - - truncating_iterator(OutputIt out, std::size_t limit) - : truncating_iterator_base(out, limit) {} - - truncating_iterator& operator++() { - if (this->count_++ < this->limit_) ++this->out_; - return *this; - } - - truncating_iterator operator++(int) { - auto it = *this; - ++*this; - return it; - } - - value_type& operator*() const { - return this->count_ < this->limit_ ? *this->out_ : blackhole_; - } -}; - -template -class truncating_iterator - : public truncating_iterator_base { - public: - using value_type = typename OutputIt::container_type::value_type; - - truncating_iterator(OutputIt out, std::size_t limit) - : truncating_iterator_base(out, limit) {} - - truncating_iterator& operator=(value_type val) { - if (this->count_++ < this->limit_) this->out_ = val; - return *this; - } - - truncating_iterator& operator++() { return *this; } - truncating_iterator& operator++(int) { return *this; } - truncating_iterator& operator*() { return *this; } -}; - -// A range with the specified output iterator and value type. -template -class output_range { - private: - OutputIt it_; - - public: - using value_type = T; - using iterator = OutputIt; - struct sentinel {}; - - explicit output_range(OutputIt it) : it_(it) {} - OutputIt begin() const { return it_; } - sentinel end() const { return {}; } // Sentinel is not used yet. -}; - -template -inline size_t count_code_points(basic_string_view s) { - return s.size(); -} - -// Counts the number of code points in a UTF-8 string. -inline size_t count_code_points(basic_string_view s) { - const char8_t* data = s.data(); - size_t num_code_points = 0; - for (size_t i = 0, size = s.size(); i != size; ++i) { - if ((data[i] & 0xc0) != 0x80) ++num_code_points; - } - return num_code_points; -} - -template -inline size_t code_point_index(basic_string_view s, size_t n) { - size_t size = s.size(); - return n < size ? n : size; -} - -// Calculates the index of the nth code point in a UTF-8 string. -inline size_t code_point_index(basic_string_view s, size_t n) { - const char8_t* data = s.data(); - size_t num_code_points = 0; - for (size_t i = 0, size = s.size(); i != size; ++i) { - if ((data[i] & 0xc0) != 0x80 && ++num_code_points > n) { - return i; - } - } - return s.size(); -} - -inline char8_t to_char8_t(char c) { return static_cast(c); } - -template -using needs_conversion = bool_constant< - std::is_same::value_type, - char>::value && - std::is_same::value>; - -template ::value)> -OutputIt copy_str(InputIt begin, InputIt end, OutputIt it) { - return std::copy(begin, end, it); -} - -template ::value)> -OutputIt copy_str(InputIt begin, InputIt end, OutputIt it) { - return std::transform(begin, end, it, to_char8_t); -} - -#ifndef FMT_USE_GRISU -# define FMT_USE_GRISU 1 -#endif - -template constexpr bool use_grisu() { - return FMT_USE_GRISU && std::numeric_limits::is_iec559 && - sizeof(T) <= sizeof(double); -} - -template -template -void buffer::append(const U* begin, const U* end) { - std::size_t new_size = size_ + to_unsigned(end - begin); - reserve(new_size); - std::uninitialized_copy(begin, end, make_checked(ptr_, capacity_) + size_); - size_ = new_size; -} -} // namespace internal - -// A range with an iterator appending to a buffer. -template -class buffer_range : public internal::output_range< - std::back_insert_iterator>, T> { - public: - using iterator = std::back_insert_iterator>; - using internal::output_range::output_range; - buffer_range(internal::buffer& buf) - : internal::output_range(std::back_inserter(buf)) {} -}; - -// A UTF-8 string view. -class u8string_view : public basic_string_view { - public: - u8string_view(const char* s) - : basic_string_view(reinterpret_cast(s)) {} - u8string_view(const char* s, size_t count) FMT_NOEXCEPT - : basic_string_view(reinterpret_cast(s), count) { - } -}; - -#if FMT_USE_USER_DEFINED_LITERALS -inline namespace literals { -inline u8string_view operator"" _u(const char* s, std::size_t n) { - return {s, n}; -} -} // namespace literals -#endif - -// The number of characters to store in the basic_memory_buffer object itself -// to avoid dynamic memory allocation. -enum { inline_buffer_size = 500 }; - -/** - \rst - A dynamically growing memory buffer for trivially copyable/constructible types - with the first ``SIZE`` elements stored in the object itself. - - You can use one of the following type aliases for common character types: - - +----------------+------------------------------+ - | Type | Definition | - +================+==============================+ - | memory_buffer | basic_memory_buffer | - +----------------+------------------------------+ - | wmemory_buffer | basic_memory_buffer | - +----------------+------------------------------+ - - **Example**:: - - fmt::memory_buffer out; - format_to(out, "The answer is {}.", 42); - - This will append the following output to the ``out`` object: - - .. code-block:: none - - The answer is 42. - - The output can be converted to an ``std::string`` with ``to_string(out)``. - \endrst - */ -template > -class basic_memory_buffer : private Allocator, public internal::buffer { - private: - T store_[SIZE]; - - // Deallocate memory allocated by the buffer. - void deallocate() { - T* data = this->data(); - if (data != store_) Allocator::deallocate(data, this->capacity()); - } - - protected: - void grow(std::size_t size) FMT_OVERRIDE; - - public: - using value_type = T; - using const_reference = const T&; - - explicit basic_memory_buffer(const Allocator& alloc = Allocator()) - : Allocator(alloc) { - this->set(store_, SIZE); - } - ~basic_memory_buffer() FMT_OVERRIDE { deallocate(); } - - private: - // Move data from other to this buffer. - void move(basic_memory_buffer& other) { - Allocator &this_alloc = *this, &other_alloc = other; - this_alloc = std::move(other_alloc); - T* data = other.data(); - std::size_t size = other.size(), capacity = other.capacity(); - if (data == other.store_) { - this->set(store_, capacity); - std::uninitialized_copy(other.store_, other.store_ + size, - internal::make_checked(store_, capacity)); - } else { - this->set(data, capacity); - // Set pointer to the inline array so that delete is not called - // when deallocating. - other.set(other.store_, 0); - } - this->resize(size); - } - - public: - /** - \rst - Constructs a :class:`fmt::basic_memory_buffer` object moving the content - of the other object to it. - \endrst - */ - basic_memory_buffer(basic_memory_buffer&& other) FMT_NOEXCEPT { move(other); } - - /** - \rst - Moves the content of the other ``basic_memory_buffer`` object to this one. - \endrst - */ - basic_memory_buffer& operator=(basic_memory_buffer&& other) FMT_NOEXCEPT { - FMT_ASSERT(this != &other, ""); - deallocate(); - move(other); - return *this; - } - - // Returns a copy of the allocator associated with this buffer. - Allocator get_allocator() const { return *this; } -}; - -template -void basic_memory_buffer::grow(std::size_t size) { -#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION - if (size > 1000) throw std::runtime_error("fuzz mode - won't grow that much"); -#endif - std::size_t old_capacity = this->capacity(); - std::size_t new_capacity = old_capacity + old_capacity / 2; - if (size > new_capacity) new_capacity = size; - T* old_data = this->data(); - T* new_data = std::allocator_traits::allocate(*this, new_capacity); - // The following code doesn't throw, so the raw pointer above doesn't leak. - std::uninitialized_copy(old_data, old_data + this->size(), - internal::make_checked(new_data, new_capacity)); - this->set(new_data, new_capacity); - // deallocate must not throw according to the standard, but even if it does, - // the buffer already uses the new storage and will deallocate it in - // destructor. - if (old_data != store_) Allocator::deallocate(old_data, old_capacity); -} - -using memory_buffer = basic_memory_buffer; -using wmemory_buffer = basic_memory_buffer; - -/** A formatting error such as invalid format string. */ -class FMT_API format_error : public std::runtime_error { - public: - explicit format_error(const char* message) : std::runtime_error(message) {} - explicit format_error(const std::string& message) - : std::runtime_error(message) {} - format_error(const format_error&) = default; - format_error& operator=(const format_error&) = default; - format_error(format_error&&) = default; - format_error& operator=(format_error&&) = default; - ~format_error() FMT_NOEXCEPT FMT_OVERRIDE; -}; - -namespace internal { - -// Returns true if value is negative, false otherwise. -// Same as `value < 0` but doesn't produce warnings if T is an unsigned type. -template ::is_signed)> -FMT_CONSTEXPR bool is_negative(T value) { - return value < 0; -} -template ::is_signed)> -FMT_CONSTEXPR bool is_negative(T) { - return false; -} - -// Smallest of uint32_t, uint64_t, uint128_t that is large enough to -// represent all values of T. -template -using uint32_or_64_or_128_t = conditional_t< - std::numeric_limits::digits <= 32, uint32_t, - conditional_t::digits <= 64, uint64_t, uint128_t>>; - -// Static data is placed in this class template for the header-only config. -template struct FMT_EXTERN_TEMPLATE_API basic_data { - static const uint64_t powers_of_10_64[]; - static const uint32_t zero_or_powers_of_10_32[]; - static const uint64_t zero_or_powers_of_10_64[]; - static const uint64_t pow10_significands[]; - static const int16_t pow10_exponents[]; - static const char digits[]; - static const char hex_digits[]; - static const char foreground_color[]; - static const char background_color[]; - static const char reset_color[5]; - static const wchar_t wreset_color[5]; - static const char signs[]; -}; - -FMT_EXTERN template struct basic_data; - -// This is a struct rather than an alias to avoid shadowing warnings in gcc. -struct data : basic_data<> {}; - -#ifdef FMT_BUILTIN_CLZLL -// Returns the number of decimal digits in n. Leading zeros are not counted -// except for n == 0 in which case count_digits returns 1. -inline int count_digits(uint64_t n) { - // Based on http://graphics.stanford.edu/~seander/bithacks.html#IntegerLog10 - // and the benchmark https://github.com/localvoid/cxx-benchmark-count-digits. - int t = (64 - FMT_BUILTIN_CLZLL(n | 1)) * 1233 >> 12; - return t - (n < data::zero_or_powers_of_10_64[t]) + 1; -} -#else -// Fallback version of count_digits used when __builtin_clz is not available. -inline int count_digits(uint64_t n) { - int count = 1; - for (;;) { - // Integer division is slow so do it for a group of four digits instead - // of for every digit. The idea comes from the talk by Alexandrescu - // "Three Optimization Tips for C++". See speed-test for a comparison. - if (n < 10) return count; - if (n < 100) return count + 1; - if (n < 1000) return count + 2; - if (n < 10000) return count + 3; - n /= 10000u; - count += 4; - } -} -#endif - -#if FMT_USE_INT128 -inline int count_digits(uint128_t n) { - int count = 1; - for (;;) { - // Integer division is slow so do it for a group of four digits instead - // of for every digit. The idea comes from the talk by Alexandrescu - // "Three Optimization Tips for C++". See speed-test for a comparison. - if (n < 10) return count; - if (n < 100) return count + 1; - if (n < 1000) return count + 2; - if (n < 10000) return count + 3; - n /= 10000U; - count += 4; - } -} -#endif - -// Counts the number of digits in n. BITS = log2(radix). -template inline int count_digits(UInt n) { - int num_digits = 0; - do { - ++num_digits; - } while ((n >>= BITS) != 0); - return num_digits; -} - -template <> int count_digits<4>(internal::fallback_uintptr n); - -#if FMT_GCC_VERSION || FMT_CLANG_VERSION -# define FMT_ALWAYS_INLINE inline __attribute__((always_inline)) -#else -# define FMT_ALWAYS_INLINE -#endif - -#ifdef FMT_BUILTIN_CLZ -// Optional version of count_digits for better performance on 32-bit platforms. -inline int count_digits(uint32_t n) { - int t = (32 - FMT_BUILTIN_CLZ(n | 1)) * 1233 >> 12; - return t - (n < data::zero_or_powers_of_10_32[t]) + 1; -} -#endif - -template FMT_API std::string grouping_impl(locale_ref loc); -template inline std::string grouping(locale_ref loc) { - return grouping_impl(loc); -} -template <> inline std::string grouping(locale_ref loc) { - return grouping_impl(loc); -} - -template FMT_API Char thousands_sep_impl(locale_ref loc); -template inline Char thousands_sep(locale_ref loc) { - return Char(thousands_sep_impl(loc)); -} -template <> inline wchar_t thousands_sep(locale_ref loc) { - return thousands_sep_impl(loc); -} - -template FMT_API Char decimal_point_impl(locale_ref loc); -template inline Char decimal_point(locale_ref loc) { - return Char(decimal_point_impl(loc)); -} -template <> inline wchar_t decimal_point(locale_ref loc) { - return decimal_point_impl(loc); -} - -// Formats a decimal unsigned integer value writing into buffer. -// add_thousands_sep is called after writing each char to add a thousands -// separator if necessary. -template -inline Char* format_decimal(Char* buffer, UInt value, int num_digits, - F add_thousands_sep) { - FMT_ASSERT(num_digits >= 0, "invalid digit count"); - buffer += num_digits; - Char* end = buffer; - while (value >= 100) { - // Integer division is slow so do it for a group of two digits instead - // of for every digit. The idea comes from the talk by Alexandrescu - // "Three Optimization Tips for C++". See speed-test for a comparison. - auto index = static_cast((value % 100) * 2); - value /= 100; - *--buffer = static_cast(data::digits[index + 1]); - add_thousands_sep(buffer); - *--buffer = static_cast(data::digits[index]); - add_thousands_sep(buffer); - } - if (value < 10) { - *--buffer = static_cast('0' + value); - return end; - } - auto index = static_cast(value * 2); - *--buffer = static_cast(data::digits[index + 1]); - add_thousands_sep(buffer); - *--buffer = static_cast(data::digits[index]); - return end; -} - -template constexpr int digits10() noexcept { - return std::numeric_limits::digits10; -} -template <> constexpr int digits10() noexcept { return 38; } -template <> constexpr int digits10() noexcept { return 38; } - -template -inline Iterator format_decimal(Iterator out, UInt value, int num_digits, - F add_thousands_sep) { - FMT_ASSERT(num_digits >= 0, "invalid digit count"); - // Buffer should be large enough to hold all digits (<= digits10 + 1). - enum { max_size = digits10() + 1 }; - Char buffer[2 * max_size]; - auto end = format_decimal(buffer, value, num_digits, add_thousands_sep); - return internal::copy_str(buffer, end, out); -} - -template -inline It format_decimal(It out, UInt value, int num_digits) { - return format_decimal(out, value, num_digits, [](Char*) {}); -} - -template -inline Char* format_uint(Char* buffer, UInt value, int num_digits, - bool upper = false) { - buffer += num_digits; - Char* end = buffer; - do { - const char* digits = upper ? "0123456789ABCDEF" : data::hex_digits; - unsigned digit = (value & ((1 << BASE_BITS) - 1)); - *--buffer = static_cast(BASE_BITS < 4 ? static_cast('0' + digit) - : digits[digit]); - } while ((value >>= BASE_BITS) != 0); - return end; -} - -template -Char* format_uint(Char* buffer, internal::fallback_uintptr n, int num_digits, - bool = false) { - auto char_digits = std::numeric_limits::digits / 4; - int start = (num_digits + char_digits - 1) / char_digits - 1; - if (int start_digits = num_digits % char_digits) { - unsigned value = n.value[start--]; - buffer = format_uint(buffer, value, start_digits); - } - for (; start >= 0; --start) { - unsigned value = n.value[start]; - buffer += char_digits; - auto p = buffer; - for (int i = 0; i < char_digits; ++i) { - unsigned digit = (value & ((1 << BASE_BITS) - 1)); - *--p = static_cast(data::hex_digits[digit]); - value >>= BASE_BITS; - } - } - return buffer; -} - -template -inline It format_uint(It out, UInt value, int num_digits, bool upper = false) { - // Buffer should be large enough to hold all digits (digits / BASE_BITS + 1). - char buffer[num_bits() / BASE_BITS + 1]; - format_uint(buffer, value, num_digits, upper); - return internal::copy_str(buffer, buffer + num_digits, out); -} - -#ifndef _WIN32 -# define FMT_USE_WINDOWS_H 0 -#elif !defined(FMT_USE_WINDOWS_H) -# define FMT_USE_WINDOWS_H 1 -#endif - -// Define FMT_USE_WINDOWS_H to 0 to disable use of windows.h. -// All the functionality that relies on it will be disabled too. -#if FMT_USE_WINDOWS_H -// A converter from UTF-8 to UTF-16. -// It is only provided for Windows since other systems support UTF-8 natively. -class utf8_to_utf16 { - private: - wmemory_buffer buffer_; - - public: - FMT_API explicit utf8_to_utf16(string_view s); - operator wstring_view() const { return wstring_view(&buffer_[0], size()); } - size_t size() const { return buffer_.size() - 1; } - const wchar_t* c_str() const { return &buffer_[0]; } - std::wstring str() const { return std::wstring(&buffer_[0], size()); } -}; - -// A converter from UTF-16 to UTF-8. -// It is only provided for Windows since other systems support UTF-8 natively. -class utf16_to_utf8 { - private: - memory_buffer buffer_; - - public: - utf16_to_utf8() {} - FMT_API explicit utf16_to_utf8(wstring_view s); - operator string_view() const { return string_view(&buffer_[0], size()); } - size_t size() const { return buffer_.size() - 1; } - const char* c_str() const { return &buffer_[0]; } - std::string str() const { return std::string(&buffer_[0], size()); } - - // Performs conversion returning a system error code instead of - // throwing exception on conversion error. This method may still throw - // in case of memory allocation error. - FMT_API int convert(wstring_view s); -}; - -FMT_API void format_windows_error(internal::buffer& out, int error_code, - string_view message) FMT_NOEXCEPT; -#endif - -template struct null {}; - -// Workaround an array initialization issue in gcc 4.8. -template struct fill_t { - private: - Char data_[6]; - - public: - FMT_CONSTEXPR Char& operator[](size_t index) { return data_[index]; } - FMT_CONSTEXPR const Char& operator[](size_t index) const { - return data_[index]; - } - - static FMT_CONSTEXPR fill_t make() { - auto fill = fill_t(); - fill[0] = Char(' '); - return fill; - } -}; -} // namespace internal - -// We cannot use enum classes as bit fields because of a gcc bug -// https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61414. -namespace align { -enum type { none, left, right, center, numeric }; -} -using align_t = align::type; - -namespace sign { -enum type { none, minus, plus, space }; -} -using sign_t = sign::type; - -// Format specifiers for built-in and string types. -template struct basic_format_specs { - int width; - int precision; - char type; - align_t align : 4; - sign_t sign : 3; - bool alt : 1; // Alternate form ('#'). - internal::fill_t fill; - - constexpr basic_format_specs() - : width(0), - precision(-1), - type(0), - align(align::none), - sign(sign::none), - alt(false), - fill(internal::fill_t::make()) {} -}; - -using format_specs = basic_format_specs; - -namespace internal { - -// A floating-point presentation format. -enum class float_format : unsigned char { - general, // General: exponent notation or fixed point based on magnitude. - exp, // Exponent notation with the default precision of 6, e.g. 1.2e-3. - fixed, // Fixed point with the default precision of 6, e.g. 0.0012. - hex -}; - -struct float_specs { - int precision; - float_format format : 8; - sign_t sign : 8; - bool upper : 1; - bool locale : 1; - bool percent : 1; - bool binary32 : 1; - bool use_grisu : 1; - bool trailing_zeros : 1; -}; - -// Writes the exponent exp in the form "[+-]d{2,3}" to buffer. -template It write_exponent(int exp, It it) { - FMT_ASSERT(-10000 < exp && exp < 10000, "exponent out of range"); - if (exp < 0) { - *it++ = static_cast('-'); - exp = -exp; - } else { - *it++ = static_cast('+'); - } - if (exp >= 100) { - const char* top = data::digits + (exp / 100) * 2; - if (exp >= 1000) *it++ = static_cast(top[0]); - *it++ = static_cast(top[1]); - exp %= 100; - } - const char* d = data::digits + exp * 2; - *it++ = static_cast(d[0]); - *it++ = static_cast(d[1]); - return it; -} - -template class float_writer { - private: - // The number is given as v = digits_ * pow(10, exp_). - const char* digits_; - int num_digits_; - int exp_; - size_t size_; - float_specs specs_; - Char decimal_point_; - - template It prettify(It it) const { - // pow(10, full_exp - 1) <= v <= pow(10, full_exp). - int full_exp = num_digits_ + exp_; - if (specs_.format == float_format::exp) { - // Insert a decimal point after the first digit and add an exponent. - *it++ = static_cast(*digits_); - int num_zeros = specs_.precision - num_digits_; - bool trailing_zeros = num_zeros > 0 && specs_.trailing_zeros; - if (num_digits_ > 1 || trailing_zeros) *it++ = decimal_point_; - it = copy_str(digits_ + 1, digits_ + num_digits_, it); - if (trailing_zeros) - it = std::fill_n(it, num_zeros, static_cast('0')); - *it++ = static_cast(specs_.upper ? 'E' : 'e'); - return write_exponent(full_exp - 1, it); - } - if (num_digits_ <= full_exp) { - // 1234e7 -> 12340000000[.0+] - it = copy_str(digits_, digits_ + num_digits_, it); - it = std::fill_n(it, full_exp - num_digits_, static_cast('0')); - if (specs_.trailing_zeros) { - *it++ = decimal_point_; - int num_zeros = specs_.precision - full_exp; - if (num_zeros <= 0) { - if (specs_.format != float_format::fixed) - *it++ = static_cast('0'); - return it; - } -#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION - if (num_zeros > 1000) - throw std::runtime_error("fuzz mode - avoiding excessive cpu use"); -#endif - it = std::fill_n(it, num_zeros, static_cast('0')); - } - } else if (full_exp > 0) { - // 1234e-2 -> 12.34[0+] - it = copy_str(digits_, digits_ + full_exp, it); - if (!specs_.trailing_zeros) { - // Remove trailing zeros. - int num_digits = num_digits_; - while (num_digits > full_exp && digits_[num_digits - 1] == '0') - --num_digits; - if (num_digits != full_exp) *it++ = decimal_point_; - return copy_str(digits_ + full_exp, digits_ + num_digits, it); - } - *it++ = decimal_point_; - it = copy_str(digits_ + full_exp, digits_ + num_digits_, it); - if (specs_.precision > num_digits_) { - // Add trailing zeros. - int num_zeros = specs_.precision - num_digits_; - it = std::fill_n(it, num_zeros, static_cast('0')); - } - } else { - // 1234e-6 -> 0.001234 - *it++ = static_cast('0'); - int num_zeros = -full_exp; - if (specs_.precision >= 0 && specs_.precision < num_zeros) - num_zeros = specs_.precision; - int num_digits = num_digits_; - if (!specs_.trailing_zeros) - while (num_digits > 0 && digits_[num_digits - 1] == '0') --num_digits; - if (num_zeros != 0 || num_digits != 0) { - *it++ = decimal_point_; - it = std::fill_n(it, num_zeros, static_cast('0')); - it = copy_str(digits_, digits_ + num_digits, it); - } - } - return it; - } - - public: - float_writer(const char* digits, int num_digits, int exp, float_specs specs, - Char decimal_point) - : digits_(digits), - num_digits_(num_digits), - exp_(exp), - specs_(specs), - decimal_point_(decimal_point) { - int full_exp = num_digits + exp - 1; - int precision = specs.precision > 0 ? specs.precision : 16; - if (specs_.format == float_format::general && - !(full_exp >= -4 && full_exp < precision)) { - specs_.format = float_format::exp; - } - size_ = prettify(counting_iterator()).count(); - size_ += specs.sign ? 1 : 0; - } - - size_t size() const { return size_; } - size_t width() const { return size(); } - - template void operator()(It&& it) { - if (specs_.sign) *it++ = static_cast(data::signs[specs_.sign]); - it = prettify(it); - } -}; - -template -int format_float(T value, int precision, float_specs specs, buffer& buf); - -// Formats a floating-point number with snprintf. -template -int snprintf_float(T value, int precision, float_specs specs, - buffer& buf); - -template T promote_float(T value) { return value; } -inline double promote_float(float value) { return value; } - -template -FMT_CONSTEXPR void handle_int_type_spec(char spec, Handler&& handler) { - switch (spec) { - case 0: - case 'd': - handler.on_dec(); - break; - case 'x': - case 'X': - handler.on_hex(); - break; - case 'b': - case 'B': - handler.on_bin(); - break; - case 'o': - handler.on_oct(); - break; - case 'n': - handler.on_num(); - break; - default: - handler.on_error(); - } -} - -template -FMT_CONSTEXPR float_specs parse_float_type_spec( - const basic_format_specs& specs, ErrorHandler&& eh = {}) { - auto result = float_specs(); - result.trailing_zeros = specs.alt; - switch (specs.type) { - case 0: - result.format = float_format::general; - result.trailing_zeros |= specs.precision != 0; - break; - case 'G': - result.upper = true; - FMT_FALLTHROUGH; - case 'g': - result.format = float_format::general; - break; - case 'E': - result.upper = true; - FMT_FALLTHROUGH; - case 'e': - result.format = float_format::exp; - result.trailing_zeros |= specs.precision != 0; - break; - case 'F': - result.upper = true; - FMT_FALLTHROUGH; - case 'f': - result.format = float_format::fixed; - result.trailing_zeros |= specs.precision != 0; - break; -#if FMT_DEPRECATED_PERCENT - case '%': - result.format = float_format::fixed; - result.percent = true; - break; -#endif - case 'A': - result.upper = true; - FMT_FALLTHROUGH; - case 'a': - result.format = float_format::hex; - break; - case 'n': - result.locale = true; - break; - default: - eh.on_error("invalid type specifier"); - break; - } - return result; -} - -template -FMT_CONSTEXPR void handle_char_specs(const basic_format_specs* specs, - Handler&& handler) { - if (!specs) return handler.on_char(); - if (specs->type && specs->type != 'c') return handler.on_int(); - if (specs->align == align::numeric || specs->sign != sign::none || specs->alt) - handler.on_error("invalid format specifier for char"); - handler.on_char(); -} - -template -FMT_CONSTEXPR void handle_cstring_type_spec(Char spec, Handler&& handler) { - if (spec == 0 || spec == 's') - handler.on_string(); - else if (spec == 'p') - handler.on_pointer(); - else - handler.on_error("invalid type specifier"); -} - -template -FMT_CONSTEXPR void check_string_type_spec(Char spec, ErrorHandler&& eh) { - if (spec != 0 && spec != 's') eh.on_error("invalid type specifier"); -} - -template -FMT_CONSTEXPR void check_pointer_type_spec(Char spec, ErrorHandler&& eh) { - if (spec != 0 && spec != 'p') eh.on_error("invalid type specifier"); -} - -template class int_type_checker : private ErrorHandler { - public: - FMT_CONSTEXPR explicit int_type_checker(ErrorHandler eh) : ErrorHandler(eh) {} - - FMT_CONSTEXPR void on_dec() {} - FMT_CONSTEXPR void on_hex() {} - FMT_CONSTEXPR void on_bin() {} - FMT_CONSTEXPR void on_oct() {} - FMT_CONSTEXPR void on_num() {} - - FMT_CONSTEXPR void on_error() { - ErrorHandler::on_error("invalid type specifier"); - } -}; - -template -class char_specs_checker : public ErrorHandler { - private: - char type_; - - public: - FMT_CONSTEXPR char_specs_checker(char type, ErrorHandler eh) - : ErrorHandler(eh), type_(type) {} - - FMT_CONSTEXPR void on_int() { - handle_int_type_spec(type_, int_type_checker(*this)); - } - FMT_CONSTEXPR void on_char() {} -}; - -template -class cstring_type_checker : public ErrorHandler { - public: - FMT_CONSTEXPR explicit cstring_type_checker(ErrorHandler eh) - : ErrorHandler(eh) {} - - FMT_CONSTEXPR void on_string() {} - FMT_CONSTEXPR void on_pointer() {} -}; - -template -void arg_map::init(const basic_format_args& args) { - if (map_) return; - map_ = new entry[internal::to_unsigned(args.max_size())]; - if (args.is_packed()) { - for (int i = 0;; ++i) { - internal::type arg_type = args.type(i); - if (arg_type == internal::none_type) return; - if (arg_type == internal::named_arg_type) push_back(args.values_[i]); - } - } - for (int i = 0, n = args.max_size(); i < n; ++i) { - auto type = args.args_[i].type_; - if (type == internal::named_arg_type) push_back(args.args_[i].value_); - } -} - -template struct nonfinite_writer { - sign_t sign; - const char* str; - static constexpr size_t str_size = 3; - - size_t size() const { return str_size + (sign ? 1 : 0); } - size_t width() const { return size(); } - - template void operator()(It&& it) const { - if (sign) *it++ = static_cast(data::signs[sign]); - it = copy_str(str, str + str_size, it); - } -}; - -// This template provides operations for formatting and writing data into a -// character range. -template class basic_writer { - public: - using char_type = typename Range::value_type; - using iterator = typename Range::iterator; - using format_specs = basic_format_specs; - - private: - iterator out_; // Output iterator. - locale_ref locale_; - - // Attempts to reserve space for n extra characters in the output range. - // Returns a pointer to the reserved range or a reference to out_. - auto reserve(std::size_t n) -> decltype(internal::reserve(out_, n)) { - return internal::reserve(out_, n); - } - - template struct padded_int_writer { - size_t size_; - string_view prefix; - char_type fill; - std::size_t padding; - F f; - - size_t size() const { return size_; } - size_t width() const { return size_; } - - template void operator()(It&& it) const { - if (prefix.size() != 0) - it = copy_str(prefix.begin(), prefix.end(), it); - it = std::fill_n(it, padding, fill); - f(it); - } - }; - - // Writes an integer in the format - // - // where are written by f(it). - template - void write_int(int num_digits, string_view prefix, format_specs specs, F f) { - std::size_t size = prefix.size() + to_unsigned(num_digits); - char_type fill = specs.fill[0]; - std::size_t padding = 0; - if (specs.align == align::numeric) { - auto unsiged_width = to_unsigned(specs.width); - if (unsiged_width > size) { - padding = unsiged_width - size; - size = unsiged_width; - } - } else if (specs.precision > num_digits) { - size = prefix.size() + to_unsigned(specs.precision); - padding = to_unsigned(specs.precision - num_digits); - fill = static_cast('0'); - } - if (specs.align == align::none) specs.align = align::right; - write_padded(specs, padded_int_writer{size, prefix, fill, padding, f}); - } - - // Writes a decimal integer. - template void write_decimal(Int value) { - auto abs_value = static_cast>(value); - bool negative = is_negative(value); - // Don't do -abs_value since it trips unsigned-integer-overflow sanitizer. - if (negative) abs_value = ~abs_value + 1; - int num_digits = count_digits(abs_value); - auto&& it = reserve((negative ? 1 : 0) + static_cast(num_digits)); - if (negative) *it++ = static_cast('-'); - it = format_decimal(it, abs_value, num_digits); - } - - // The handle_int_type_spec handler that writes an integer. - template struct int_writer { - using unsigned_type = uint32_or_64_or_128_t; - - basic_writer& writer; - const Specs& specs; - unsigned_type abs_value; - char prefix[4]; - unsigned prefix_size; - - string_view get_prefix() const { return string_view(prefix, prefix_size); } - - int_writer(basic_writer& w, Int value, const Specs& s) - : writer(w), - specs(s), - abs_value(static_cast(value)), - prefix_size(0) { - if (is_negative(value)) { - prefix[0] = '-'; - ++prefix_size; - abs_value = 0 - abs_value; - } else if (specs.sign != sign::none && specs.sign != sign::minus) { - prefix[0] = specs.sign == sign::plus ? '+' : ' '; - ++prefix_size; - } - } - - struct dec_writer { - unsigned_type abs_value; - int num_digits; - - template void operator()(It&& it) const { - it = internal::format_decimal(it, abs_value, num_digits); - } - }; - - void on_dec() { - int num_digits = count_digits(abs_value); - writer.write_int(num_digits, get_prefix(), specs, - dec_writer{abs_value, num_digits}); - } - - struct hex_writer { - int_writer& self; - int num_digits; - - template void operator()(It&& it) const { - it = format_uint<4, char_type>(it, self.abs_value, num_digits, - self.specs.type != 'x'); - } - }; - - void on_hex() { - if (specs.alt) { - prefix[prefix_size++] = '0'; - prefix[prefix_size++] = specs.type; - } - int num_digits = count_digits<4>(abs_value); - writer.write_int(num_digits, get_prefix(), specs, - hex_writer{*this, num_digits}); - } - - template struct bin_writer { - unsigned_type abs_value; - int num_digits; - - template void operator()(It&& it) const { - it = format_uint(it, abs_value, num_digits); - } - }; - - void on_bin() { - if (specs.alt) { - prefix[prefix_size++] = '0'; - prefix[prefix_size++] = static_cast(specs.type); - } - int num_digits = count_digits<1>(abs_value); - writer.write_int(num_digits, get_prefix(), specs, - bin_writer<1>{abs_value, num_digits}); - } - - void on_oct() { - int num_digits = count_digits<3>(abs_value); - if (specs.alt && specs.precision <= num_digits && abs_value != 0) { - // Octal prefix '0' is counted as a digit, so only add it if precision - // is not greater than the number of digits. - prefix[prefix_size++] = '0'; - } - writer.write_int(num_digits, get_prefix(), specs, - bin_writer<3>{abs_value, num_digits}); - } - - enum { sep_size = 1 }; - - struct num_writer { - unsigned_type abs_value; - int size; - const std::string& groups; - char_type sep; - - template void operator()(It&& it) const { - basic_string_view s(&sep, sep_size); - // Index of a decimal digit with the least significant digit having - // index 0. - int digit_index = 0; - std::string::const_iterator group = groups.cbegin(); - it = format_decimal( - it, abs_value, size, - [this, s, &group, &digit_index](char_type*& buffer) { - if (*group <= 0 || ++digit_index % *group != 0 || - *group == max_value()) - return; - if (group + 1 != groups.cend()) { - digit_index = 0; - ++group; - } - buffer -= s.size(); - std::uninitialized_copy(s.data(), s.data() + s.size(), - make_checked(buffer, s.size())); - }); - } - }; - - void on_num() { - std::string groups = grouping(writer.locale_); - if (groups.empty()) return on_dec(); - auto sep = thousands_sep(writer.locale_); - if (!sep) return on_dec(); - int num_digits = count_digits(abs_value); - int size = num_digits; - std::string::const_iterator group = groups.cbegin(); - while (group != groups.cend() && num_digits > *group && *group > 0 && - *group != max_value()) { - size += sep_size; - num_digits -= *group; - ++group; - } - if (group == groups.cend()) - size += sep_size * ((num_digits - 1) / groups.back()); - writer.write_int(size, get_prefix(), specs, - num_writer{abs_value, size, groups, sep}); - } - - FMT_NORETURN void on_error() { - FMT_THROW(format_error("invalid type specifier")); - } - }; - - template struct str_writer { - const Char* s; - size_t size_; - - size_t size() const { return size_; } - size_t width() const { - return count_code_points(basic_string_view(s, size_)); - } - - template void operator()(It&& it) const { - it = copy_str(s, s + size_, it); - } - }; - - template struct pointer_writer { - UIntPtr value; - int num_digits; - - size_t size() const { return to_unsigned(num_digits) + 2; } - size_t width() const { return size(); } - - template void operator()(It&& it) const { - *it++ = static_cast('0'); - *it++ = static_cast('x'); - it = format_uint<4, char_type>(it, value, num_digits); - } - }; - - public: - explicit basic_writer(Range out, locale_ref loc = locale_ref()) - : out_(out.begin()), locale_(loc) {} - - iterator out() const { return out_; } - - // Writes a value in the format - // - // where is written by f(it). - template void write_padded(const format_specs& specs, F&& f) { - // User-perceived width (in code points). - unsigned width = to_unsigned(specs.width); - size_t size = f.size(); // The number of code units. - size_t num_code_points = width != 0 ? f.width() : size; - if (width <= num_code_points) return f(reserve(size)); - auto&& it = reserve(width + (size - num_code_points)); - char_type fill = specs.fill[0]; - std::size_t padding = width - num_code_points; - if (specs.align == align::right) { - it = std::fill_n(it, padding, fill); - f(it); - } else if (specs.align == align::center) { - std::size_t left_padding = padding / 2; - it = std::fill_n(it, left_padding, fill); - f(it); - it = std::fill_n(it, padding - left_padding, fill); - } else { - f(it); - it = std::fill_n(it, padding, fill); - } - } - - void write(int value) { write_decimal(value); } - void write(long value) { write_decimal(value); } - void write(long long value) { write_decimal(value); } - - void write(unsigned value) { write_decimal(value); } - void write(unsigned long value) { write_decimal(value); } - void write(unsigned long long value) { write_decimal(value); } - -#if FMT_USE_INT128 - void write(int128_t value) { write_decimal(value); } - void write(uint128_t value) { write_decimal(value); } -#endif - - template - void write_int(T value, const Spec& spec) { - handle_int_type_spec(spec.type, int_writer(*this, value, spec)); - } - - template ::value)> - void write(T value, format_specs specs = {}) { - float_specs fspecs = parse_float_type_spec(specs); - fspecs.sign = specs.sign; - if (std::signbit(value)) { // value < 0 is false for NaN so use signbit. - fspecs.sign = sign::minus; - value = -value; - } else if (fspecs.sign == sign::minus) { - fspecs.sign = sign::none; - } - - if (!std::isfinite(value)) { - auto str = std::isinf(value) ? (fspecs.upper ? "INF" : "inf") - : (fspecs.upper ? "NAN" : "nan"); - return write_padded(specs, nonfinite_writer{fspecs.sign, str}); - } - - if (specs.align == align::none) { - specs.align = align::right; - } else if (specs.align == align::numeric) { - if (fspecs.sign) { - auto&& it = reserve(1); - *it++ = static_cast(data::signs[fspecs.sign]); - fspecs.sign = sign::none; - if (specs.width != 0) --specs.width; - } - specs.align = align::right; - } - - memory_buffer buffer; - if (fspecs.format == float_format::hex) { - if (fspecs.sign) buffer.push_back(data::signs[fspecs.sign]); - snprintf_float(promote_float(value), specs.precision, fspecs, buffer); - write_padded(specs, str_writer{buffer.data(), buffer.size()}); - return; - } - int precision = specs.precision >= 0 || !specs.type ? specs.precision : 6; - if (fspecs.format == float_format::exp) ++precision; - if (const_check(std::is_same())) fspecs.binary32 = true; - fspecs.use_grisu = use_grisu(); - if (const_check(FMT_DEPRECATED_PERCENT) && fspecs.percent) value *= 100; - int exp = format_float(promote_float(value), precision, fspecs, buffer); - if (const_check(FMT_DEPRECATED_PERCENT) && fspecs.percent) { - buffer.push_back('%'); - --exp; // Adjust decimal place position. - } - fspecs.precision = precision; - char_type point = fspecs.locale ? decimal_point(locale_) - : static_cast('.'); - write_padded(specs, float_writer(buffer.data(), - static_cast(buffer.size()), - exp, fspecs, point)); - } - - void write(char value) { - auto&& it = reserve(1); - *it++ = value; - } - - template ::value)> - void write(Char value) { - auto&& it = reserve(1); - *it++ = value; - } - - void write(string_view value) { - auto&& it = reserve(value.size()); - it = copy_str(value.begin(), value.end(), it); - } - void write(wstring_view value) { - static_assert(std::is_same::value, ""); - auto&& it = reserve(value.size()); - it = std::copy(value.begin(), value.end(), it); - } - - template - void write(const Char* s, std::size_t size, const format_specs& specs) { - write_padded(specs, str_writer{s, size}); - } - - template - void write(basic_string_view s, const format_specs& specs = {}) { - const Char* data = s.data(); - std::size_t size = s.size(); - if (specs.precision >= 0 && to_unsigned(specs.precision) < size) - size = code_point_index(s, to_unsigned(specs.precision)); - write(data, size, specs); - } - - template - void write_pointer(UIntPtr value, const format_specs* specs) { - int num_digits = count_digits<4>(value); - auto pw = pointer_writer{value, num_digits}; - if (!specs) return pw(reserve(to_unsigned(num_digits) + 2)); - format_specs specs_copy = *specs; - if (specs_copy.align == align::none) specs_copy.align = align::right; - write_padded(specs_copy, pw); - } -}; - -using writer = basic_writer>; - -template struct is_integral : std::is_integral {}; -template <> struct is_integral : std::true_type {}; -template <> struct is_integral : std::true_type {}; - -template -class arg_formatter_base { - public: - using char_type = typename Range::value_type; - using iterator = typename Range::iterator; - using format_specs = basic_format_specs; - - private: - using writer_type = basic_writer; - writer_type writer_; - format_specs* specs_; - - struct char_writer { - char_type value; - - size_t size() const { return 1; } - size_t width() const { return 1; } - - template void operator()(It&& it) const { *it++ = value; } - }; - - void write_char(char_type value) { - if (specs_) - writer_.write_padded(*specs_, char_writer{value}); - else - writer_.write(value); - } - - void write_pointer(const void* p) { - writer_.write_pointer(internal::to_uintptr(p), specs_); - } - - protected: - writer_type& writer() { return writer_; } - FMT_DEPRECATED format_specs* spec() { return specs_; } - format_specs* specs() { return specs_; } - iterator out() { return writer_.out(); } - - void write(bool value) { - string_view sv(value ? "true" : "false"); - specs_ ? writer_.write(sv, *specs_) : writer_.write(sv); - } - - void write(const char_type* value) { - if (!value) { - FMT_THROW(format_error("string pointer is null")); - } else { - auto length = std::char_traits::length(value); - basic_string_view sv(value, length); - specs_ ? writer_.write(sv, *specs_) : writer_.write(sv); - } - } - - public: - arg_formatter_base(Range r, format_specs* s, locale_ref loc) - : writer_(r, loc), specs_(s) {} - - iterator operator()(monostate) { - FMT_ASSERT(false, "invalid argument type"); - return out(); - } - - template ::value)> - iterator operator()(T value) { - if (specs_) - writer_.write_int(value, *specs_); - else - writer_.write(value); - return out(); - } - - iterator operator()(char_type value) { - internal::handle_char_specs( - specs_, char_spec_handler(*this, static_cast(value))); - return out(); - } - - iterator operator()(bool value) { - if (specs_ && specs_->type) return (*this)(value ? 1 : 0); - write(value != 0); - return out(); - } - - template ::value)> - iterator operator()(T value) { - writer_.write(value, specs_ ? *specs_ : format_specs()); - return out(); - } - - struct char_spec_handler : ErrorHandler { - arg_formatter_base& formatter; - char_type value; - - char_spec_handler(arg_formatter_base& f, char_type val) - : formatter(f), value(val) {} - - void on_int() { - if (formatter.specs_) - formatter.writer_.write_int(value, *formatter.specs_); - else - formatter.writer_.write(value); - } - void on_char() { formatter.write_char(value); } - }; - - struct cstring_spec_handler : internal::error_handler { - arg_formatter_base& formatter; - const char_type* value; - - cstring_spec_handler(arg_formatter_base& f, const char_type* val) - : formatter(f), value(val) {} - - void on_string() { formatter.write(value); } - void on_pointer() { formatter.write_pointer(value); } - }; - - iterator operator()(const char_type* value) { - if (!specs_) return write(value), out(); - internal::handle_cstring_type_spec(specs_->type, - cstring_spec_handler(*this, value)); - return out(); - } - - iterator operator()(basic_string_view value) { - if (specs_) { - internal::check_string_type_spec(specs_->type, internal::error_handler()); - writer_.write(value, *specs_); - } else { - writer_.write(value); - } - return out(); - } - - iterator operator()(const void* value) { - if (specs_) - check_pointer_type_spec(specs_->type, internal::error_handler()); - write_pointer(value); - return out(); - } -}; - -template FMT_CONSTEXPR bool is_name_start(Char c) { - return ('a' <= c && c <= 'z') || ('A' <= c && c <= 'Z') || '_' == c; -} - -// Parses the range [begin, end) as an unsigned integer. This function assumes -// that the range is non-empty and the first character is a digit. -template -FMT_CONSTEXPR int parse_nonnegative_int(const Char*& begin, const Char* end, - ErrorHandler&& eh) { - FMT_ASSERT(begin != end && '0' <= *begin && *begin <= '9', ""); - if (*begin == '0') { - ++begin; - return 0; - } - unsigned value = 0; - // Convert to unsigned to prevent a warning. - constexpr unsigned max_int = max_value(); - unsigned big = max_int / 10; - do { - // Check for overflow. - if (value > big) { - value = max_int + 1; - break; - } - value = value * 10 + unsigned(*begin - '0'); - ++begin; - } while (begin != end && '0' <= *begin && *begin <= '9'); - if (value > max_int) eh.on_error("number is too big"); - return static_cast(value); -} - -template class custom_formatter { - private: - using char_type = typename Context::char_type; - - basic_format_parse_context& parse_ctx_; - Context& ctx_; - - public: - explicit custom_formatter(basic_format_parse_context& parse_ctx, - Context& ctx) - : parse_ctx_(parse_ctx), ctx_(ctx) {} - - bool operator()(typename basic_format_arg::handle h) const { - h.format(parse_ctx_, ctx_); - return true; - } - - template bool operator()(T) const { return false; } -}; - -template -using is_integer = - bool_constant::value && !std::is_same::value && - !std::is_same::value && - !std::is_same::value>; - -template class width_checker { - public: - explicit FMT_CONSTEXPR width_checker(ErrorHandler& eh) : handler_(eh) {} - - template ::value)> - FMT_CONSTEXPR unsigned long long operator()(T value) { - if (is_negative(value)) handler_.on_error("negative width"); - return static_cast(value); - } - - template ::value)> - FMT_CONSTEXPR unsigned long long operator()(T) { - handler_.on_error("width is not integer"); - return 0; - } - - private: - ErrorHandler& handler_; -}; - -template class precision_checker { - public: - explicit FMT_CONSTEXPR precision_checker(ErrorHandler& eh) : handler_(eh) {} - - template ::value)> - FMT_CONSTEXPR unsigned long long operator()(T value) { - if (is_negative(value)) handler_.on_error("negative precision"); - return static_cast(value); - } - - template ::value)> - FMT_CONSTEXPR unsigned long long operator()(T) { - handler_.on_error("precision is not integer"); - return 0; - } - - private: - ErrorHandler& handler_; -}; - -// A format specifier handler that sets fields in basic_format_specs. -template class specs_setter { - public: - explicit FMT_CONSTEXPR specs_setter(basic_format_specs& specs) - : specs_(specs) {} - - FMT_CONSTEXPR specs_setter(const specs_setter& other) - : specs_(other.specs_) {} - - FMT_CONSTEXPR void on_align(align_t align) { specs_.align = align; } - FMT_CONSTEXPR void on_fill(Char fill) { specs_.fill[0] = fill; } - FMT_CONSTEXPR void on_plus() { specs_.sign = sign::plus; } - FMT_CONSTEXPR void on_minus() { specs_.sign = sign::minus; } - FMT_CONSTEXPR void on_space() { specs_.sign = sign::space; } - FMT_CONSTEXPR void on_hash() { specs_.alt = true; } - - FMT_CONSTEXPR void on_zero() { - specs_.align = align::numeric; - specs_.fill[0] = Char('0'); - } - - FMT_CONSTEXPR void on_width(int width) { specs_.width = width; } - FMT_CONSTEXPR void on_precision(int precision) { - specs_.precision = precision; - } - FMT_CONSTEXPR void end_precision() {} - - FMT_CONSTEXPR void on_type(Char type) { - specs_.type = static_cast(type); - } - - protected: - basic_format_specs& specs_; -}; - -template class numeric_specs_checker { - public: - FMT_CONSTEXPR numeric_specs_checker(ErrorHandler& eh, internal::type arg_type) - : error_handler_(eh), arg_type_(arg_type) {} - - FMT_CONSTEXPR void require_numeric_argument() { - if (!is_arithmetic_type(arg_type_)) - error_handler_.on_error("format specifier requires numeric argument"); - } - - FMT_CONSTEXPR void check_sign() { - require_numeric_argument(); - if (is_integral_type(arg_type_) && arg_type_ != int_type && - arg_type_ != long_long_type && arg_type_ != internal::char_type) { - error_handler_.on_error("format specifier requires signed argument"); - } - } - - FMT_CONSTEXPR void check_precision() { - if (is_integral_type(arg_type_) || arg_type_ == internal::pointer_type) - error_handler_.on_error("precision not allowed for this argument type"); - } - - private: - ErrorHandler& error_handler_; - internal::type arg_type_; -}; - -// A format specifier handler that checks if specifiers are consistent with the -// argument type. -template class specs_checker : public Handler { - public: - FMT_CONSTEXPR specs_checker(const Handler& handler, internal::type arg_type) - : Handler(handler), checker_(*this, arg_type) {} - - FMT_CONSTEXPR specs_checker(const specs_checker& other) - : Handler(other), checker_(*this, other.arg_type_) {} - - FMT_CONSTEXPR void on_align(align_t align) { - if (align == align::numeric) checker_.require_numeric_argument(); - Handler::on_align(align); - } - - FMT_CONSTEXPR void on_plus() { - checker_.check_sign(); - Handler::on_plus(); - } - - FMT_CONSTEXPR void on_minus() { - checker_.check_sign(); - Handler::on_minus(); - } - - FMT_CONSTEXPR void on_space() { - checker_.check_sign(); - Handler::on_space(); - } - - FMT_CONSTEXPR void on_hash() { - checker_.require_numeric_argument(); - Handler::on_hash(); - } - - FMT_CONSTEXPR void on_zero() { - checker_.require_numeric_argument(); - Handler::on_zero(); - } - - FMT_CONSTEXPR void end_precision() { checker_.check_precision(); } - - private: - numeric_specs_checker checker_; -}; - -template