From 55326fc36d82d645182eb23e847f7dea033d93a9 Mon Sep 17 00:00:00 2001 From: Mikael Zayenz Lagerkvist Date: Wed, 28 Oct 2026 20:53:39 +0100 Subject: [PATCH 1/4] Normalize API identifiers and resolve Clang diagnostics --- .clang-tidy | 25 +- CMakeLists.txt | 6 + changelog.in | 17 + examples/all-interval.cpp | 8 +- examples/alpha.cpp | 8 +- examples/archimedean-spiral.cpp | 12 +- examples/bacp.cpp | 54 +- examples/bibd.cpp | 12 +- examples/bin-packing.cpp | 63 +- examples/black-hole.cpp | 16 +- examples/car-sequencing.cpp | 157 +- examples/cartesian-heart.cpp | 16 +- examples/colored-matrix.cpp | 18 +- examples/crew.cpp | 186 +-- examples/crossword.cpp | 32 +- examples/crowded-chess.cpp | 12 +- examples/descartes-folium.cpp | 12 +- examples/dominating-queens.cpp | 12 +- examples/domino.cpp | 40 +- examples/donald.cpp | 8 +- examples/efpa.cpp | 8 +- examples/eq20.cpp | 8 +- examples/fifteen-puzzle.cpp | 2 + examples/golden-spiral.cpp | 12 +- examples/golf.cpp | 28 +- examples/golomb-ruler.cpp | 12 +- examples/graph-color.cpp | 18 +- examples/grocery.cpp | 8 +- examples/hamming.cpp | 8 +- examples/ind-set.cpp | 12 +- examples/job-shop.cpp | 56 +- examples/kakuro.cpp | 18 +- examples/knights.cpp | 71 +- examples/langford-number.cpp | 12 +- examples/magic-sequence.cpp | 8 +- examples/magic-square-partial.cpp | 302 ++-- examples/magic-square.cpp | 8 +- examples/minesweeper.cpp | 20 +- examples/money.cpp | 8 +- examples/multi-bin-packing.cpp | 14 +- examples/nonogram.cpp | 8 +- examples/open-shop.cpp | 38 +- examples/ortho-latin.cpp | 8 +- examples/partition.cpp | 8 +- examples/pentominoes.cpp | 8 +- examples/perfect-square.cpp | 10 +- examples/photo.cpp | 16 +- examples/qcp.cpp | 18 +- examples/queen-armies.cpp | 99 +- examples/queens.cpp | 34 +- examples/radiotherapy.cpp | 118 +- examples/sat.cpp | 8 +- examples/schurs-lemma.cpp | 12 +- examples/sports-league.cpp | 8 +- examples/steel-mill.cpp | 122 +- examples/steiner.cpp | 30 +- examples/sudoku-advanced.cpp | 32 +- examples/sudoku-instances.hh | 6 +- examples/sudoku.cpp | 8 +- examples/tsp.cpp | 38 +- examples/tsptw.cpp | 26 +- examples/warehouses.cpp | 24 +- examples/word-square.cpp | 8 +- gecode/driver.hh | 60 +- gecode/driver/options.cpp | 5 +- gecode/driver/script.hpp | 46 +- gecode/flatzinc.hh | 216 +-- gecode/flatzinc/ast.hh | 188 +-- gecode/flatzinc/blackbox-backend.cpp | 18 +- gecode/flatzinc/blackbox-backend.hh | 6 +- gecode/flatzinc/blackbox-process-posix.cpp | 48 +- gecode/flatzinc/blackbox-process-windows.cpp | 103 +- gecode/flatzinc/blackbox-propagator.cpp | 18 +- gecode/flatzinc/blackbox.hh | 4 +- gecode/flatzinc/branch.cpp | 4 +- gecode/flatzinc/branch.hh | 96 +- gecode/flatzinc/branch.hpp | 142 +- gecode/flatzinc/exampleplugin/myplugin.cpp | 6 +- gecode/flatzinc/exampleplugin/myplugin.hh | 3 +- gecode/flatzinc/flatzinc.cpp | 1222 ++++++++-------- gecode/flatzinc/lexer.lxx | 46 +- gecode/flatzinc/lexer.yy.cpp | 170 ++- gecode/flatzinc/parser.hh | 52 +- gecode/flatzinc/parser.tab.cpp | 1280 ++++++++--------- gecode/flatzinc/parser.tab.hpp | 24 +- gecode/flatzinc/parser.yxx | 826 +++++------ gecode/flatzinc/registry-float.cpp | 119 +- gecode/flatzinc/registry-scheduling.cpp | 123 +- gecode/flatzinc/registry-set.cpp | 192 +-- gecode/flatzinc/registry.cpp | 1356 +++++++++--------- gecode/flatzinc/varspec.hh | 50 +- gecode/float.hh | 12 +- gecode/float/arithmetic.hh | 48 +- gecode/float/arithmetic/pow-nroot.hpp | 8 +- gecode/float/bool.hh | 10 +- gecode/float/branch.cpp | 48 +- gecode/float/branch.hh | 6 +- gecode/float/branch/val-sel-commit.cpp | 4 +- gecode/float/branch/view-sel.cpp | 2 +- gecode/float/channel.hh | 4 +- gecode/float/linear.hh | 14 +- gecode/float/linear/post.cpp | 6 +- gecode/float/rel.hh | 40 +- gecode/float/transcendental.hh | 8 +- gecode/float/trigonometric.hh | 30 +- gecode/float/trigonometric/sincos.hpp | 32 +- gecode/float/trigonometric/tanatan.hpp | 10 +- gecode/gist.hh | 18 +- gecode/gist/drawingcursor.cpp | 164 +-- gecode/gist/drawingcursor.hh | 26 +- gecode/gist/drawingcursor.hpp | 39 +- gecode/gist/gecodelogo.cpp | 5 +- gecode/gist/gecodelogo.hh | 6 +- gecode/gist/gist.cpp | 10 +- gecode/gist/gist.hpp | 16 +- gecode/gist/layoutcursor.hh | 6 +- gecode/gist/layoutcursor.hpp | 28 +- gecode/gist/mainwindow.cpp | 321 ++--- gecode/gist/mainwindow.hh | 46 +- gecode/gist/node.cpp | 30 +- gecode/gist/node.hh | 50 +- gecode/gist/node.hpp | 110 +- gecode/gist/nodecursor.hh | 72 +- gecode/gist/nodecursor.hpp | 164 +-- gecode/gist/nodestats.cpp | 54 +- gecode/gist/nodestats.hh | 16 +- gecode/gist/nodevisitor.hh | 6 +- gecode/gist/nodevisitor.hpp | 42 +- gecode/gist/nodewidget.hh | 2 +- gecode/gist/preferences.cpp | 194 +-- gecode/gist/preferences.hh | 32 +- gecode/gist/qtgist.cpp | 911 ++++++------ gecode/gist/qtgist.hh | 172 +-- gecode/gist/spacenode.cpp | 288 ++-- gecode/gist/spacenode.hh | 70 +- gecode/gist/spacenode.hpp | 96 +- gecode/gist/standalone-example/mygist.cpp | 41 +- gecode/gist/stopbrancher.hh | 16 +- gecode/gist/textoutput.cpp | 50 +- gecode/gist/textoutput.hh | 12 +- gecode/gist/treecanvas.cpp | 1024 ++++++------- gecode/gist/treecanvas.hh | 228 +-- gecode/gist/visualnode.cpp | 342 ++--- gecode/gist/visualnode.hh | 93 +- gecode/gist/visualnode.hpp | 108 +- gecode/gist/zoomToFitIcon.hpp | 2 +- gecode/instance.hh | 2 +- gecode/instance/data.cpp | 6 +- gecode/instance/reader.cpp | 5 +- gecode/int.hh | 116 +- gecode/int/arithmetic.cpp | 104 +- gecode/int/arithmetic.hh | 210 +-- gecode/int/arithmetic/argmax.hpp | 46 +- gecode/int/arithmetic/divmod.hpp | 10 +- gecode/int/arithmetic/nroot.hpp | 24 +- gecode/int/arithmetic/open.hpp | 26 +- gecode/int/arithmetic/pow-ops.hpp | 8 +- gecode/int/arithmetic/pow.hpp | 20 +- gecode/int/arithmetic/product-mod.hpp | 12 +- gecode/int/bin-packing.cpp | 10 +- gecode/int/bin-packing.hh | 12 +- gecode/int/bin-packing/conflict-graph.hpp | 4 +- gecode/int/bin-packing/propagate.cpp | 2 +- gecode/int/bool.cpp | 12 +- gecode/int/bool.hh | 124 +- gecode/int/bool/eq.hpp | 22 +- gecode/int/bool/eqv.hpp | 60 +- gecode/int/bool/lq.hpp | 22 +- gecode/int/bool/or.hpp | 314 ++-- gecode/int/branch.cpp | 109 +- gecode/int/branch.hh | 76 +- gecode/int/branch/cbs.hpp | 82 +- gecode/int/branch/open.hpp | 42 +- gecode/int/branch/val-sel-commit.cpp | 8 +- gecode/int/branch/view-sel.cpp | 4 +- gecode/int/branch/view-values.hpp | 8 +- gecode/int/channel.hh | 34 +- gecode/int/circuit.hh | 16 +- gecode/int/count.hh | 54 +- gecode/int/count/int-base.hpp | 4 +- gecode/int/count/rel.hpp | 4 +- gecode/int/count/view-base.hpp | 8 +- gecode/int/count/view-eq.hpp | 10 +- gecode/int/count/view-gq.hpp | 6 +- gecode/int/count/view-lq.hpp | 4 +- gecode/int/cumulative.cpp | 149 +- gecode/int/cumulative.hh | 28 +- gecode/int/cumulative/edge-finding.hpp | 40 +- gecode/int/cumulative/man-prop.hpp | 4 +- gecode/int/cumulative/opt-prop.hpp | 4 +- gecode/int/cumulative/post.hpp | 4 +- gecode/int/cumulative/tree.hpp | 32 +- gecode/int/cumulatives.hh | 10 +- gecode/int/distinct.hh | 46 +- gecode/int/distinct/bnd.hpp | 10 +- gecode/int/distinct/cbs.cpp | 4 +- gecode/int/distinct/cbs.hpp | 88 +- gecode/int/distinct/dom.hpp | 8 +- gecode/int/distinct/open.hpp | 20 +- gecode/int/distinct/val.hpp | 8 +- gecode/int/div.hh | 16 +- gecode/int/div.hpp | 8 +- gecode/int/dom.hh | 10 +- gecode/int/element.cpp | 10 +- gecode/int/element.hh | 34 +- gecode/int/exec.hh | 6 +- gecode/int/extensional-tuple-set.cpp | 74 +- gecode/int/extensional.hh | 64 +- gecode/int/extensional/compact.hpp | 106 +- gecode/int/extensional/dfa.hpp | 2 +- gecode/int/extensional/layered-graph.hpp | 8 +- gecode/int/extensional/open.hpp | 20 +- gecode/int/extensional/tuple-set.cpp | 3 +- gecode/int/extensional/tuple-set.hpp | 2 +- gecode/int/gcc.cpp | 6 +- gecode/int/gcc.hh | 32 +- gecode/int/gcc/bnd-sup.hpp | 62 +- gecode/int/gcc/bnd.hpp | 36 +- gecode/int/gcc/dom-sup.hpp | 56 +- gecode/int/gcc/dom.hpp | 12 +- gecode/int/gcc/post.hpp | 4 +- gecode/int/gcc/val.hpp | 10 +- gecode/int/gcc/view.hpp | 2 +- gecode/int/idx-view.hpp | 4 +- gecode/int/inter-distance.cpp | 204 +-- gecode/int/inter-distance.hh | 8 +- gecode/int/ldsb.cpp | 122 +- gecode/int/ldsb.hh | 64 +- gecode/int/ldsb/brancher.hpp | 46 +- gecode/int/ldsb/sym-imp.cpp | 32 +- gecode/int/ldsb/sym-imp.hpp | 32 +- gecode/int/linear.hh | 176 +-- gecode/int/linear/bool-scale.hpp | 26 +- gecode/int/linear/int-nary.hpp | 74 +- gecode/int/linear/int-post.cpp | 10 +- gecode/int/member.hh | 14 +- gecode/int/min-distance.hh | 36 +- gecode/int/min-distance/prop.hpp | 2 +- gecode/int/no-overlap.cpp | 82 +- gecode/int/no-overlap.hh | 30 +- gecode/int/no-overlap/box.hpp | 8 +- gecode/int/no-overlap/dim.hpp | 12 +- gecode/int/no-overlap/man.hpp | 4 +- gecode/int/no-overlap/opt.hpp | 4 +- gecode/int/nvalues.hh | 40 +- gecode/int/nvalues/int-eq.hpp | 2 +- gecode/int/open-propagator.hpp | 8 +- gecode/int/open-var-list.hpp | 28 +- gecode/int/order.hh | 10 +- gecode/int/precede.hh | 16 +- gecode/int/precede/open.hpp | 24 +- gecode/int/precede/single.hpp | 10 +- gecode/int/propagator.hpp | 18 +- gecode/int/rel.cpp | 12 +- gecode/int/rel.hh | 100 +- gecode/int/rel/lq-le.hpp | 2 +- gecode/int/rel/open.hpp | 26 +- gecode/int/sequence.hh | 12 +- gecode/int/sequence/open.hpp | 54 +- gecode/int/sorted.hh | 10 +- gecode/int/sorted/matching.hpp | 8 +- gecode/int/sorted/narrowing.hpp | 4 +- gecode/int/sorted/propagate.hpp | 10 +- gecode/int/sorted/sortsup.hpp | 4 +- gecode/int/task.hh | 6 +- gecode/int/task/array.hpp | 4 +- gecode/int/unary.cpp | 90 +- gecode/int/unary.hh | 28 +- gecode/int/unary/edge-finding.hpp | 10 +- gecode/int/unary/man-prop.hpp | 4 +- gecode/int/unary/not-first-not-last.hpp | 16 +- gecode/int/unary/opt-prop.hpp | 4 +- gecode/int/unary/overload.hpp | 6 +- gecode/int/unary/post.hpp | 4 +- gecode/int/unary/tree.hpp | 44 +- gecode/int/val-set.hpp | 2 +- gecode/int/var-imp.hpp | 12 +- gecode/int/var-imp/bool.cpp | 4 +- gecode/int/var-imp/bool.hpp | 12 +- gecode/int/var-imp/int.cpp | 14 +- gecode/int/var-imp/int.hpp | 30 +- gecode/int/view.hpp | 36 +- gecode/int/view/bool.hpp | 2 +- gecode/int/view/cached.hpp | 32 +- gecode/int/view/int.hpp | 2 +- gecode/int/view/minus.hpp | 2 +- gecode/int/view/neg-bool.hpp | 2 +- gecode/int/view/offset.hpp | 2 +- gecode/int/view/scale.hpp | 2 +- gecode/iter/ranges-compl.hpp | 28 +- gecode/iter/ranges-union.hpp | 8 +- gecode/kernel/branch/action.hpp | 16 +- gecode/kernel/branch/chb.hpp | 16 +- gecode/kernel/branch/function.cpp | 16 +- gecode/kernel/branch/tiebreak.hpp | 12 +- gecode/kernel/branch/val-sel-commit.hpp | 15 +- gecode/kernel/branch/view-sel.hpp | 66 +- gecode/kernel/branch/view-val.hpp | 35 +- gecode/kernel/branch/view.hpp | 8 +- gecode/kernel/core.cpp | 26 +- gecode/kernel/core.hpp | 142 +- gecode/kernel/data/array.hpp | 38 +- gecode/kernel/data/shared-array.hpp | 2 +- gecode/kernel/data/shared-data.hpp | 2 +- gecode/kernel/memory/allocators.hpp | 4 +- gecode/kernel/memory/manager.hpp | 4 +- gecode/kernel/propagator/pattern.hpp | 48 +- gecode/kernel/propagator/subscribed.hpp | 2 +- gecode/kernel/propagator/wait.hpp | 20 +- gecode/kernel/range-list.hpp | 6 +- gecode/kernel/shared-space-data.hpp | 2 +- gecode/kernel/trace/filter.hpp | 2 +- gecode/kernel/trace/general.cpp | 2 +- gecode/kernel/trace/recorder.hpp | 22 +- gecode/kernel/trace/tracer.hpp | 6 +- gecode/kernel/view.hpp | 38 +- gecode/minimodel.hh | 54 +- gecode/minimodel/aliases.hpp | 26 +- gecode/minimodel/bool-expr.cpp | 4 +- gecode/minimodel/dom.cpp | 4 +- gecode/minimodel/float-arith.cpp | 60 +- gecode/minimodel/int-arith.cpp | 62 +- gecode/minimodel/int-expr.cpp | 11 +- gecode/minimodel/ldsb.hpp | 10 +- gecode/minimodel/reg.cpp | 71 +- gecode/minimodel/reg.hpp | 2 +- gecode/minimodel/set-expr.cpp | 16 +- gecode/minimodel/set-rel.cpp | 2 +- gecode/search.hh | 88 +- gecode/search/astar.cpp | 2 +- gecode/search/astar.hpp | 6 +- gecode/search/bab.cpp | 2 +- gecode/search/bab.hpp | 6 +- gecode/search/cabs.cpp | 2 +- gecode/search/cabs.hpp | 6 +- gecode/search/cpprofiler/connector.hpp | 114 +- gecode/search/cpprofiler/message.hpp | 104 +- gecode/search/cpprofiler/tracer.cpp | 10 +- gecode/search/dfs.cpp | 2 +- gecode/search/dfs.hpp | 6 +- gecode/search/lds.cpp | 2 +- gecode/search/lds.hpp | 6 +- gecode/search/nogoods.cpp | 22 +- gecode/search/nogoods.hh | 22 +- gecode/search/nogoods.hpp | 14 +- gecode/search/par/bab.hh | 16 +- gecode/search/par/bab.hpp | 2 +- gecode/search/par/dfs.hh | 10 +- gecode/search/par/dfs.hpp | 2 +- gecode/search/par/engine.hh | 20 +- gecode/search/par/engine.hpp | 4 +- gecode/search/par/path.hh | 4 +- gecode/search/par/path.hpp | 4 +- gecode/search/par/pbs.hh | 20 +- gecode/search/pbs.cpp | 16 +- gecode/search/pbs.hpp | 74 +- gecode/search/rbs.cpp | 11 +- gecode/search/rbs.hpp | 16 +- gecode/search/seq/bab.hpp | 2 +- gecode/search/seq/dead.cpp | 8 +- gecode/search/seq/dfs.hpp | 2 +- gecode/search/seq/lds.hh | 12 +- gecode/search/seq/path.hh | 4 +- gecode/search/seq/path.hpp | 2 +- gecode/search/seq/pbs.hh | 12 +- gecode/search/seq/rbs.hh | 12 +- gecode/search/support.hh | 12 +- gecode/set.hh | 112 +- gecode/set/array.cpp | 150 +- gecode/set/branch.cpp | 42 +- gecode/set/branch.hh | 18 +- gecode/set/branch/merit.hpp | 10 +- gecode/set/branch/ngl.cpp | 4 +- gecode/set/branch/val-sel-commit.cpp | 4 +- gecode/set/branch/view-sel.cpp | 2 +- gecode/set/cardinality.cpp | 8 +- gecode/set/channel.cpp | 2 +- gecode/set/channel.hh | 42 +- gecode/set/channel/bool.hpp | 68 +- gecode/set/channel/int.hpp | 12 +- gecode/set/channel/set.hpp | 20 +- gecode/set/channel/sorted.hpp | 38 +- gecode/set/convex.hh | 8 +- gecode/set/convex/conv.cpp | 32 +- gecode/set/convex/hull.cpp | 47 +- gecode/set/distinct.cpp | 2 +- gecode/set/distinct.hh | 4 +- gecode/set/distinct/atmostOne.cpp | 40 +- gecode/set/distinct/atmostOne.hpp | 4 +- gecode/set/dom.cpp | 68 +- gecode/set/element.cpp | 14 +- gecode/set/element.hh | 40 +- gecode/set/element/disjoint.hpp | 24 +- gecode/set/element/inter.hpp | 80 +- gecode/set/element/union.hpp | 100 +- gecode/set/element/unionConst.hpp | 100 +- gecode/set/int.cpp | 14 +- gecode/set/int.hh | 38 +- gecode/set/int/card.hpp | 10 +- gecode/set/int/minmax.hpp | 106 +- gecode/set/int/weights.hpp | 66 +- gecode/set/ldsb.cpp | 53 +- gecode/set/ldsb.hh | 34 +- gecode/set/ldsb/brancher.hpp | 98 +- gecode/set/ldsb/sym-imp.cpp | 50 +- gecode/set/precede.hh | 16 +- gecode/set/precede/single.hpp | 30 +- gecode/set/rel-op-const-vcc.cpp | 2 +- gecode/set/rel-op.hh | 40 +- gecode/set/rel-op/common.hpp | 384 ++--- gecode/set/rel-op/inter.hpp | 126 +- gecode/set/rel-op/partition.hpp | 58 +- gecode/set/rel-op/subofunion.hpp | 24 +- gecode/set/rel-op/superofinter.hpp | 24 +- gecode/set/rel-op/union.hpp | 88 +- gecode/set/rel.cpp | 10 +- gecode/set/rel.hh | 54 +- gecode/set/rel/common.hpp | 48 +- gecode/set/rel/eq.hpp | 26 +- gecode/set/rel/lq.hpp | 20 +- gecode/set/rel/nosubset.hpp | 4 +- gecode/set/rel/nq.hpp | 14 +- gecode/set/rel/re-eq.hpp | 2 +- gecode/set/rel/re-lq.hpp | 14 +- gecode/set/rel/re-subset.hpp | 4 +- gecode/set/rel/subset.hpp | 14 +- gecode/set/relax.cpp | 4 +- gecode/set/sequence.hh | 12 +- gecode/set/sequence/common.hpp | 34 +- gecode/set/sequence/seq-u.cpp | 56 +- gecode/set/sequence/seq-u.hpp | 4 +- gecode/set/sequence/seq.cpp | 2 +- gecode/set/trace/trace-view.hpp | 2 +- gecode/set/var-imp.hpp | 120 +- gecode/set/var-imp/delta.hpp | 30 +- gecode/set/var-imp/integerset.cpp | 54 +- gecode/set/var-imp/integerset.hpp | 32 +- gecode/set/var-imp/set.cpp | 36 +- gecode/set/var-imp/set.hpp | 176 +-- gecode/set/var/set.cpp | 53 +- gecode/set/var/set.hpp | 42 +- gecode/set/view.hpp | 332 ++--- gecode/set/view/cached.hpp | 122 +- gecode/set/view/complement.hpp | 84 +- gecode/set/view/const.hpp | 158 +- gecode/set/view/print.hpp | 28 +- gecode/set/view/set.hpp | 94 +- gecode/set/view/singleton.hpp | 48 +- gecode/support/allocator.hpp | 5 +- gecode/support/bitset-base.hpp | 58 +- gecode/support/exception.hpp | 2 +- gecode/support/failpoint.cpp | 2 +- gecode/support/failpoint.hpp | 20 +- gecode/support/heap.hpp | 4 +- gecode/support/marked-pointer.hpp | 16 +- gecode/support/run-jobs.hpp | 18 +- gecode/support/sort.hpp | 14 +- gecode/support/thread.hpp | 10 +- gecode/support/thread/thread.cpp | 16 +- gecode/support/thread/thread.hpp | 6 +- test/afc.cpp | 15 +- test/array.cpp | 46 +- test/assign.cpp | 16 +- test/assign.hh | 8 +- test/assign/bool.cpp | 4 +- test/assign/float.cpp | 4 +- test/assign/int.cpp | 4 +- test/assign/set.cpp | 4 +- test/branch.cpp | 84 +- test/branch.hh | 10 +- test/branch/bool.cpp | 4 +- test/branch/float.cpp | 6 +- test/branch/int.cpp | 30 +- test/branch/set.cpp | 4 +- test/fault.cpp | 272 ++-- test/flatzinc.cpp | 92 +- test/flatzinc.hh | 18 +- test/flatzinc/blackbox-dll.cpp | 6 +- test/flatzinc/blackbox.cpp | 14 +- test/flatzinc/native-registry.cpp | 10 +- test/flatzinc/on_restart_last_val_int.cpp | 4 +- test/flatzinc/random_branching.cpp | 2 +- test/float.cpp | 60 +- test/float.hh | 56 +- test/float.hpp | 18 +- test/float/arithmetic.cpp | 477 +++--- test/float/basic.cpp | 28 +- test/float/channel.cpp | 16 +- test/float/dom.cpp | 28 +- test/float/linear.cpp | 44 +- test/float/mm-lin.cpp | 28 +- test/float/rel.cpp | 42 +- test/float/transcendental.cpp | 126 +- test/float/trigonometric.cpp | 168 +-- test/groups.cpp | 6 +- test/instance.cpp | 4 +- test/int.cpp | 38 +- test/int.hh | 47 +- test/int.hpp | 28 +- test/int/arithmetic.cpp | 927 ++++++------ test/int/basic.cpp | 12 +- test/int/bin-packing.cpp | 74 +- test/int/bool.cpp | 130 +- test/int/channel.cpp | 48 +- test/int/circuit.cpp | 60 +- test/int/count.cpp | 108 +- test/int/cumulative.cpp | 172 ++- test/int/cumulatives.cpp | 50 +- test/int/distinct.cpp | 56 +- test/int/dom.cpp | 48 +- test/int/element.cpp | 152 +- test/int/exec.cpp | 24 +- test/int/extensional.cpp | 462 +++--- test/int/gcc.cpp | 62 +- test/int/inter-distance.cpp | 84 +- test/int/linear.cpp | 60 +- test/int/member.cpp | 24 +- test/int/min-distance.cpp | 24 +- test/int/mm-arithmetic.cpp | 120 +- test/int/mm-bool.cpp | 52 +- test/int/mm-count.cpp | 72 +- test/int/mm-lin.cpp | 90 +- test/int/mm-rel.cpp | 16 +- test/int/no-overlap.cpp | 54 +- test/int/nvalues.cpp | 42 +- test/int/open-var-list.cpp | 162 +-- test/int/order.cpp | 8 +- test/int/precede.cpp | 18 +- test/int/rel.cpp | 150 +- test/int/sequence.cpp | 12 +- test/int/sorted.cpp | 16 +- test/int/unary.cpp | 104 +- test/int/unshare.cpp | 24 +- test/ldsb.cpp | 302 ++-- test/nogoods.cpp | 22 +- test/random.cpp | 6 +- test/region.cpp | 2 +- test/search.cpp | 254 ++-- test/set.cpp | 284 ++-- test/set.hh | 32 +- test/set/channel.cpp | 54 +- test/set/construct.cpp | 40 +- test/set/convex.cpp | 24 +- test/set/distinct.cpp | 12 +- test/set/dom.cpp | 90 +- test/set/element.cpp | 72 +- test/set/exec.cpp | 8 +- test/set/int.cpp | 164 +-- test/set/mm-set.cpp | 41 +- test/set/precede.cpp | 16 +- test/set/rel-op-const.cpp | 35 +- test/set/rel-op.cpp | 91 +- test/set/rel.cpp | 26 +- test/set/sequence.cpp | 24 +- test/test.cpp | 40 +- test/test.hh | 20 +- test/test.hpp | 13 +- tools/flatzinc/fzn-gecode.cpp | 6 +- 558 files changed, 15627 insertions(+), 15371 deletions(-) diff --git a/.clang-tidy b/.clang-tidy index 78d5e41ef6..c71acd6591 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -1,6 +1,7 @@ # Use clang-tidy 22. Keep checks focused on correctness and useful modernization. Checks: >- -*, + clang-analyzer-core.*, bugprone-assert-side-effect, bugprone-dangling-handle, bugprone-integer-division, @@ -17,8 +18,30 @@ Checks: >- performance-inefficient-string-concatenation, performance-move-const-arg, performance-unnecessary-copy-initialization, - performance-unnecessary-value-param + readability-identifier-naming WarningsAsErrors: '*' HeaderFilterRegex: '(gecode|test|examples|tools)/' ExcludeHeaderFilterRegex: 'gecode/third-party/|gecode/flatzinc/(parser\.tab\.(cpp|hpp)|lexer\.yy\.cpp)$' FormatStyle: file + +CheckOptions: + readability-identifier-naming.FunctionCase: lower_case + readability-identifier-naming.MethodCase: lower_case + readability-identifier-naming.VariableCase: lower_case + readability-identifier-naming.MemberCase: lower_case + readability-identifier-naming.ParameterCase: lower_case + readability-identifier-naming.EnumConstantCase: UPPER_CASE + readability-identifier-naming.ConstantCase: lower_case + # Constants and functions standing for constant values, such as + # ME_INT_VAL, ES_SUBSUMED, and INT_VAR_SIZE_MIN, may use UPPER_CASE. + readability-identifier-naming.ConstantIgnoredRegexp: '^(_?[a-z][a-z0-9_]*|[a-z][a-z0-9_]*_|[A-Z][A-Z0-9_]*)$' + readability-identifier-naming.FunctionIgnoredRegexp: '^(_[a-z][a-z0-9_]*|[A-Z][A-Z0-9_]*)$' + readability-identifier-naming.MethodIgnoredRegexp: '^(_[a-z][a-z0-9_]*|[A-Z][A-Z0-9_]*)$' + readability-identifier-naming.VariableIgnoredRegexp: '^(_[a-z][a-z0-9_]*|[a-z][a-z0-9_]*_)$' + readability-identifier-naming.MemberIgnoredRegexp: '^(_[a-z][a-z0-9_]*|[a-z][a-z0-9_]*_)$' + readability-identifier-naming.ParameterIgnoredRegexp: '^(_[a-z][a-z0-9_]*|[a-z][a-z0-9_]*_)$' + readability-identifier-naming.EnumConstantIgnoredRegexp: '^[A-Z][A-Z0-9_]*_$' + # New scoped enums name their constants in PascalCase, as EndReason::Limit; + # scoped enums converted from plain enums keep UPPER_CASE. + readability-identifier-naming.ScopedEnumConstantCase: UPPER_CASE + readability-identifier-naming.ScopedEnumConstantIgnoredRegexp: '^([A-Z][a-zA-Z0-9]*|[A-Z][A-Z0-9_]*_)$' diff --git a/CMakeLists.txt b/CMakeLists.txt index c878a733b6..1f023b91ce 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1611,6 +1611,12 @@ endif() if(GECODE_ENABLE_EXAMPLES) add_subdirectory(examples) + if(GECODE_BUILD_GIST_TARGET) + add_subdirectory(gecode/gist/standalone-example) + endif() + if(GECODE_ENABLE_FLATZINC AND GECODE_HAS_QT_RUNTIME AND GECODE_BUILD_SHARED) + add_subdirectory(gecode/flatzinc/exampleplugin) + endif() endif() # --------------------------------------------------------------------------- diff --git a/changelog.in b/changelog.in index ac7003bafb..f93218d6b0 100644 --- a/changelog.in +++ b/changelog.in @@ -117,6 +117,23 @@ Rank: minor Define the GECODE_FREELIST32_SIZE_MAX and GECODE_FREELIST64_SIZE_MAX build options as numbers in config.hpp. A quoted value broke compilation. +[ENTRY] +Module: other +What: change +Rank: major +[DESCRIPTION] +Require C++23 and adopt four-space indentation and a 120-column limit with +clang-format 22. +Functions, variables, and members use snake_case; types retain PascalCase. +Constants and functions that stand for constant values, such as ME_INT_VAL, +ES_SUBSUMED, and INT_VAR_SIZE_MIN, retain UPPER_CASE. Public API names +change, including no_overlap, bin_packing, and modification_event_delta. +Update downstream source code before recompiling. +[MORE] +Add formatting, clang-tidy, and extended repository check commands. Extended +checks include generated sources, CTest suites, installed-package consumers, +and documentation. EditorConfig replaces per-file indentation headers. + [ENTRY] Module: other What: removed diff --git a/examples/all-interval.cpp b/examples/all-interval.cpp index 1febd2fafd..f9c0bfa77a 100644 --- a/examples/all-interval.cpp +++ b/examples/all-interval.cpp @@ -91,13 +91,13 @@ class AllInterval : public Script { d.update(*this, s.d); } /// Copy during cloning - virtual Space* - copy(void) { + Space* + copy(void) override { return new AllInterval(*this); } /// Print solution - virtual void - print(std::ostream& os) const { + void + print(std::ostream& os) const override { const int n = x.size(); os << "\tx[" << n << "] = {"; for (int i = 0; i < n - 1; i++) diff --git a/examples/alpha.cpp b/examples/alpha.cpp index c1d3816feb..2f38c7b86e 100644 --- a/examples/alpha.cpp +++ b/examples/alpha.cpp @@ -106,13 +106,13 @@ class Alpha : public Script { le.update(*this, s.le); } /// Copy during cloning - virtual Space* - copy(void) { + Space* + copy(void) override { return new Alpha(*this); } /// Print solution - virtual void - print(std::ostream& os) const { + void + print(std::ostream& os) const override { os << "\t"; for (int i = 0; i < n; i++) { os << ((char)(i + 'a')) << '=' << le[i] << ((i < n - 1) ? ", " : "\n"); diff --git a/examples/archimedean-spiral.cpp b/examples/archimedean-spiral.cpp index 90272dec44..c05fb13eac 100644 --- a/examples/archimedean-spiral.cpp +++ b/examples/archimedean-spiral.cpp @@ -91,18 +91,18 @@ class ArchimedeanSpiral : public FloatMaximizeScript { f.update(*this, p.f); } /// Copy during cloning - virtual Space* - copy(void) { + Space* + copy(void) override { return new ArchimedeanSpiral(*this); } /// Cost function - virtual FloatVar - cost(void) const { + FloatVar + cost(void) const override { return f[0]; } /// Print solution coordinates - virtual void - print(std::ostream& os) const { + void + print(std::ostream& os) const override { os << "XY " << f[1].med() << " " << f[2].med() << std::endl; } }; diff --git a/examples/bacp.cpp b/examples/bacp.cpp index a8a687bb93..95a750fa03 100644 --- a/examples/bacp.cpp +++ b/examples/bacp.cpp @@ -117,12 +117,12 @@ class BACP : public IntMinimizeScript { /// Actual model BACP(const SizeOptions& opt) : IntMinimizeScript(opt), curr(curriculum[opt.size()]) { - std::map courseMap; // Map names to course numbers - int maxCredit = 0; - int numberOfCourses = 0; - for (const Course* co = curr.courses; co->name != 0; co++) { - courseMap[co->name] = numberOfCourses++; - maxCredit += co->credit; + std::map course_map; // Map names to course numbers + int max_credit = 0; + int number_of_courses = 0; + for (const Course* co = curr.courses; co->name != nullptr; co++) { + course_map[co->name] = number_of_courses++; + max_credit += co->credit; } int p = curr.p; @@ -132,14 +132,14 @@ class BACP : public IntMinimizeScript { int d = curr.d; l = IntVarArray(*this, p, a, b); - u = IntVar(*this, 0, maxCredit); + u = IntVar(*this, 0, max_credit); q = IntVarArray(*this, p, c, d); - x = IntVarArray(*this, numberOfCourses, 0, p - 1); + x = IntVarArray(*this, number_of_courses, 0, p - 1); for (int j = 0; j < p; j++) { - BoolVarArgs xij(*this, numberOfCourses, 0, 1); - IntArgs t(numberOfCourses); - for (int i = 0; i < numberOfCourses; i++) { + BoolVarArgs xij(*this, number_of_courses, 0, 1); + IntArgs t(number_of_courses); + for (int i = 0; i < number_of_courses; i++) { rel(*this, (x[i] == j) == xij[i]); t[i] = curr.courses[i].credit; } @@ -150,15 +150,15 @@ class BACP : public IntMinimizeScript { } // Precedence - for (const char** prereq = curr.prereqs; *prereq != 0; prereq += 2) - rel(*this, x[courseMap[*prereq]] < x[courseMap[*(prereq + 1)]]); + for (const char** prereq = curr.prereqs; *prereq != nullptr; prereq += 2) + rel(*this, x[course_map[*prereq]] < x[course_map[*(prereq + 1)]]); // Optimization criterion: minimize u max(*this, l, u); // Redundant constraints - linear(*this, l, IRT_EQ, maxCredit); - linear(*this, q, IRT_EQ, numberOfCourses); + linear(*this, l, IRT_EQ, max_credit); + linear(*this, q, IRT_EQ, number_of_courses); switch (opt.branching()) { case BRANCHING_NAIVE: @@ -213,18 +213,18 @@ class BACP : public IntMinimizeScript { x.update(*this, bacp.x); } /// Copy during cloning - virtual Space* - copy(void) { + Space* + copy(void) override { return new BACP(*this); } /// Return solution cost - virtual IntVar - cost(void) const { + IntVar + cost(void) const override { return u; } /// Print solution - virtual void - print(std::ostream& os) const { + void + print(std::ostream& os) const override { std::vector> period(curr.p); for (int i = x.size(); i--;) period[x[i].val()].push_back(i); @@ -277,7 +277,7 @@ namespace { {"hxwxx2", 1}, {"iei231", 4}, {"iei241", 4}, {"iei271", 3}, {"iei281", 3}, {"iwn261", 3}, {"hfw120", 2}, {"iei233", 4}, {"iei238", 3}, {"iei261", 3}, {"iei272", 3}, {"iei273", 3}, {"iei161", 3}, {"iei232", 3}, {"iei262", 3}, {"iei274", 3}, {"iwi365", 3}, {"iwn270", 3}, - {"hrw130", 2}, {"iei218", 3}, {"iei219", 3}, {"iei248", 3}, {0, 0}}; + {"hrw130", 2}, {"iei218", 3}, {"iei219", 3}, {"iei248", 3}, {nullptr, 0}}; /// Prerequisites for first example const char* prereqs8[] = {"dew101", "dew100", "fis101", "fis100", "fis101", "mat192", "mat191", "mat190", "mat193", @@ -288,7 +288,7 @@ namespace { "iei231", "iei238", "iei231", "iei261", "iwn261", "iei272", "iei271", "iei273", "iei271", "iei273", "iei271", "iei161", "iwn261", "iei161", "iwn261", "iei232", "iei273", "iei232", "iei273", "iei262", "iwn261", "iei274", "iei273", "iei274", "iei273", "iei219", "iei232", - "iei248", "iei233", "iei248", "iei233", 0, 0}; + "iei248", "iei233", "iei248", "iei233", nullptr, nullptr}; /// Courses for second example const Course courses10[] = { @@ -298,7 +298,7 @@ namespace { {"ili260", 3}, {"iwn261", 3}, {"mat024", 4}, {"fis130", 4}, {"ili239", 4}, {"ili245", 4}, {"ili253", 4}, {"fis140", 4}, {"ili236", 4}, {"ili243", 4}, {"ili270", 3}, {"ili280", 4}, {"ici344", 4}, {"ili263", 3}, {"ili332", 4}, {"ili355", 4}, {"iwn170", 3}, {"icdxx1", 3}, {"ili362", 3}, {"iwn270", 3}, {"icdxx2", 3}, - {0, 0}}; + {nullptr, 0}}; /// Prerequisites for second example const char* prereqs10[] = {"dew101", "dew100", "fis110", "fis100", "fis110", "mat021", "mat022", "mat021", "dewxx0", @@ -308,7 +308,7 @@ namespace { "ili245", "ili153", "ili253", "ili153", "fis140", "fis120", "fis140", "fis130", "ili236", "ili239", "ili243", "ili245", "ili270", "ili260", "ili270", "iwn261", "ili280", "mat024", "ici344", "ili243", "ili263", "ili260", "ili263", "iwn261", "ili332", "ili236", "ili355", - "ili153", "ili355", "ili280", "ili362", "ili263", 0, 0}; + "ili153", "ili355", "ili280", "ili362", "ili263", nullptr, nullptr}; /// Courses for third example const Course courses12[] = { @@ -321,7 +321,7 @@ namespace { {"ili238", 4}, {"ili242", 3}, {"ili275", 3}, {"ili355", 4}, {"hrw110", 2}, {"ici393", 4}, {"ili237", 4}, {"ili334", 4}, {"ili363", 3}, {"iwn261", 3}, {"hrw100", 2}, {"ici382", 4}, {"ili331", 4}, {"ili362", 3}, {"ili381", 3}, {"iln230", 3}, {"ici313", 2}, {"ici315", 2}, {"ici332", 3}, {"ici344", 4}, {"icn336", 3}, - {"iwi365", 3}, {"ici314", 2}, {"ici367", 2}, {0, 0}}; + {"iwi365", 3}, {"ici314", 2}, {"ici367", 2}, {nullptr, 0}}; /// Prerequisites for third example const char* prereqs12[] = { @@ -336,7 +336,7 @@ namespace { "hrw110", "hrw150", "ici393", "mat210", "ici393", "mat260", "ili237", "ili231", "ili237", "ili252", "ili334", "ili238", "ili363", "ili273", "hrw100", "hrw110", "ici382", "ili334", "ili331", "ili238", "ili331", "ili274", "ili362", "ili363", "ili381", "ili281", "ili381", "mat210", "iln230", "iwn170", "ici313", "ili331", "ici332", - "ici393", "ici332", "ili331", "ici344", "ili243", "icn336", "ici393", "ici314", "ici313", 0, 0}; + "ici393", "ici332", "ili331", "ici344", "ili243", "icn336", "ici393", "ici314", "ici313", nullptr, nullptr}; /// The example specifications const Curriculum curriculum[] = {{8, 10, 24, 2, 10, courses8, prereqs8}, diff --git a/examples/bibd.cpp b/examples/bibd.cpp index f444a82c9c..f55c2dc92d 100644 --- a/examples/bibd.cpp +++ b/examples/bibd.cpp @@ -68,8 +68,8 @@ class BIBDOptions : public Options { derive(); } /// Print help message - virtual void - help(void) { + void + help(void) override { Options::help(); std::cerr << "\t(unsigned int) default: " << v << std::endl << "\t\tparameter v" << std::endl @@ -141,8 +141,8 @@ class BIBD : public Script { } /// Print solution - virtual void - print(std::ostream& os) const { + void + print(std::ostream& os) const override { os << "\tBIBD(" << opt.v << "," << opt.k << "," << opt.lambda << ")" << std::endl; Matrix p(_p, opt.b, opt.v); for (int i = 0; i < opt.v; i++) { @@ -160,8 +160,8 @@ class BIBD : public Script { } /// Copy during cloning - virtual Space* - copy(void) { + Space* + copy(void) override { return new BIBD(*this); } }; diff --git a/examples/bin-packing.cpp b/examples/bin-packing.cpp index bd8b533c5f..6966804f89 100644 --- a/examples/bin-packing.cpp +++ b/examples/bin-packing.cpp @@ -146,26 +146,29 @@ namespace { int u = 0; for (int i = 0; i < n; i++) { + const int item_size = size(i); int j = 0; // Skip bins with insufficient free space - while (f[j] < size(i)) + while ((j < n) && (f[j] < item_size)) j++; + // Every instance item fits in an empty bin. + assert(j < n); if (j > u) { // A new bin is needed u = j; - f[u] -= size(i); + f[u] -= item_size; } else { // The slack of the best-fit bin int b = j++; - int s = f[b] - size(i); + int s = f[b] - item_size; while (j <= u) { - if ((f[j] >= size(i)) && (f[j] - size(i) < s)) { + if ((f[j] >= item_size) && (f[j] - item_size < s)) { b = j; - s = f[b] - size(i); + s = f[b] - item_size; } j++; } - f[b] -= size(i); + f[b] -= item_size; } } delete[] f; @@ -241,15 +244,15 @@ class CDBF : public Brancher { same[k] = s[k]; } /// Archive into \a e - virtual void - archive(Archive& e) const { + void + archive(Archive& e) const override { Gecode::Choice::archive(e); e << alternatives() << item << n_same; for (int i = n_same; i--;) e << same[i]; } /// Destructor - virtual ~Choice(void) { + ~Choice(void) override { heap.free(same, n_same); } }; @@ -271,21 +274,21 @@ class CDBF : public Brancher { bin.update(home, cdbf.bin); } /// Copy brancher - virtual Actor* - copy(Space& home) { + Actor* + copy(Space& home) override { return new (home) CDBF(home, *this); } /// Delete brancher and return its size - virtual size_t - dispose(Space& home) { + size_t + dispose(Space& home) override { home.ignore(*this, AP_DISPOSE); size.~IntSharedArray(); (void)Brancher::dispose(home); return sizeof(*this); } /// Check status of brancher, return true if alternatives left - virtual bool - status(const Space&) const { + bool + status(const Space&) const override { for (int i = item; i < bin.size(); i++) if (!bin[i].assigned()) { item = i; @@ -294,8 +297,8 @@ class CDBF : public Brancher { return false; } /// Return choice - virtual Gecode::Choice* - choice(Space&) { + Gecode::Choice* + choice(Space&) override { assert(!bin[item].assigned()); int n = bin.size(), m = load.size(); @@ -349,8 +352,8 @@ class CDBF : public Brancher { return new Choice(*this, 2, item, same, n_same); } /// Return choice - virtual const Gecode::Choice* - choice(const Space&, Archive& e) { + const Gecode::Choice* + choice(const Space&, Archive& e) override { int alt, item, n_same; e >> alt >> item >> n_same; Region re; @@ -360,8 +363,8 @@ class CDBF : public Brancher { return new Choice(*this, alt, item, same, n_same); } /// Perform commit for choice \a _c and alternative \a a - virtual ExecStatus - commit(Space& home, const Gecode::Choice& _c, unsigned int a) { + ExecStatus + commit(Space& home, const Gecode::Choice& _c, unsigned int a) override { const Choice& c = static_cast(_c); // This catches also the case that the choice has a single aternative only if (a == 0) { @@ -379,8 +382,8 @@ class CDBF : public Brancher { return ES_OK; } /// Print explanation - virtual void - print(const Space&, const Gecode::Choice& _c, unsigned int a, std::ostream& o) const { + void + print(const Space&, const Gecode::Choice& _c, unsigned int a, std::ostream& o) const override { const Choice& c = static_cast(_c); if (a == 0) { o << "bin[" << c.item << "] = " << c.same[0]; @@ -470,7 +473,7 @@ class BinPacking : public IntMinimizeScript { linear(*this, sizes, x.row(j), IRT_EQ, load[j]); } break; case MODEL_PACKING: - binpacking(*this, load, bin, sizes); + bin_packing(*this, load, bin, sizes); break; } @@ -506,8 +509,8 @@ class BinPacking : public IntMinimizeScript { } } /// Return cost - virtual IntVar - cost(void) const { + IntVar + cost(void) const override { return bins; } /// Constructor for cloning \a s @@ -517,13 +520,13 @@ class BinPacking : public IntMinimizeScript { bins.update(*this, s.bins); } /// Copy during cloning - virtual Space* - copy(void) { + Space* + copy(void) override { return new BinPacking(*this); } /// Print solution - virtual void - print(std::ostream& os) const { + void + print(std::ostream& os) const override { int n = bin.size(); int m = load.size(); os << "Bins used: " << bins << " (from " << m << " bins)." << std::endl; diff --git a/examples/black-hole.cpp b/examples/black-hole.cpp index 0153ab38f0..36688bcd93 100644 --- a/examples/black-hole.cpp +++ b/examples/black-hole.cpp @@ -137,14 +137,14 @@ class BlackHole : public Script { // between two consecutive cards is 1 or 12. if (opt.propagation() == PROPAGATION_REIFIED) { // Build table for accessing the rank of a card - IntArgs modtable(52); + IntArgs modulo_table(52); for (int i = 0; i < 52; ++i) { - modtable[i] = i % 13; + modulo_table[i] = i % 13; } for (int i = 0; i < 51; ++i) { IntVar x1(*this, 0, 12), x2(*this, 0, 12); - element(*this, modtable, x[i], x1); - element(*this, modtable, x[i + 1], x2); + element(*this, modulo_table, x[i], x1); + element(*this, modulo_table, x[i + 1], x2); const int dr[2] = {1, 12}; IntVar diff(*this, IntSet(dr, 2)); rel(*this, abs(x1 - x2) == diff, IPL_DOM); @@ -252,8 +252,8 @@ class BlackHole : public Script { return v; } /// Print instance and solution - virtual void - print(std::ostream& os) const { + void + print(std::ostream& os) const override { os << "Layout:" << std::endl; for (int i = 0; i < 17; i++) { for (int j = 0; j < 3; j++) @@ -284,8 +284,8 @@ class BlackHole : public Script { y.update(*this, s.y); } /// Copy during cloning - virtual Space* - copy(void) { + Space* + copy(void) override { return new BlackHole(*this); } }; diff --git a/examples/car-sequencing.cpp b/examples/car-sequencing.cpp index dada00549c..580ca479af 100644 --- a/examples/car-sequencing.cpp +++ b/examples/car-sequencing.cpp @@ -55,13 +55,13 @@ namespace { class CarOptions : public SizeOptions { private: /// Max slack parameter - Driver::UnsignedIntOption _maxstall; + Driver::UnsignedIntOption _max_stalls; public: /// Initialize options for example with name \a s - CarOptions(const char* s) : SizeOptions(s), _maxstall("maxstall", "Maximum numbere of stalls", 30) { + CarOptions(const char* s) : SizeOptions(s), _max_stalls("maxstall", "Maximum numbere of stalls", 30) { // Add options - add(_maxstall); + add(_max_stalls); } /// Parse options from arguments \a argv (number is \a argc) void @@ -70,8 +70,8 @@ namespace { } /// Get max stalls int - maxstall(void) const { - return _maxstall.value(); + max_stalls(void) const { + return _max_stalls.value(); } }; @@ -108,9 +108,9 @@ namespace { /// Constructor for rewriting \a p during cloning PushToEnd(Space& home, Propagator& p, ViewArray& x0, View y0, int val0); /// Copy propagator during cloning - virtual Actor* copy(Space& home); + Actor* copy(Space& home) override; /// Perform propagation - virtual ExecStatus propagate(Space& home, const ModEventDelta& med); + ExecStatus propagate(Space& home, const ModEventDelta& med) override; /// Post propagator static ExecStatus post(Space& home, ViewArray& x0, View y0, int val0); }; @@ -180,7 +180,7 @@ namespace { /** \brief Post PushToEnd propagator. */ void - pushtoend(Space& home, IntVarArgs x, IntVar y, int val) { + push_to_end(Space& home, IntVarArgs x, IntVar y, int val) { ViewArray vx(home, x); Int::IntView vy(y); GECODE_ES_FAIL(PushToEnd::post(home, vx, vy, val)); @@ -216,88 +216,89 @@ class CarSequencing : public Script { /// Problem number const int problem; /// Number of cars - const int ncars; + const int car_count; /// Number of options - const int noptions; + const int option_count; /// Number of classes - const int nclasses; + const int class_count; /// Maximum number of stalls - const int maxstall; + const int max_stalls; /// Stall number - const int stallval; + const int stall_value; /// End number - const int endval; + const int end_value; /// Number of stalls (cost to minimize) - IntVar nstall; + IntVar stall_count; /// Number of end markers - IntVar nend; + IntVar end_count; /// Sequence of cars produced IntVarArray s; public: /// Initial model CarSequencing(const CarOptions& opt) - : Script(opt), problem(opt.size()), ncars(problems[problem][0]), noptions(problems[problem][1]), - nclasses(problems[problem][2]), maxstall(opt.maxstall()), stallval(nclasses), endval(nclasses + 1), - nstall(*this, 0, maxstall), nend(*this, 0, maxstall), s(*this, ncars + maxstall, 0, nclasses + 1) { + : Script(opt), problem(opt.size()), car_count(problems[problem][0]), option_count(problems[problem][1]), + class_count(problems[problem][2]), max_stalls(opt.max_stalls()), stall_value(class_count), + end_value(class_count + 1), stall_count(*this, 0, max_stalls), end_count(*this, 0, max_stalls), + s(*this, car_count + max_stalls, 0, class_count + 1) { // Read problem - const int* probit = problems[problem] + 3; + const int* problem_cursor = problems[problem] + 3; // Sequence requirements for the options. - IntArgs max(noptions), block(noptions); - for (int i = 0; i < noptions; ++i) { - max[i] = *probit++; + IntArgs max(option_count), block(option_count); + for (int i = 0; i < option_count; ++i) { + max[i] = *problem_cursor++; } - for (int i = 0; i < noptions; ++i) { - block[i] = *probit++; + for (int i = 0; i < option_count; ++i) { + block[i] = *problem_cursor++; } // Number of cars per class - IntArgs ncc(nclasses); + IntArgs ncc(class_count); // What classes require an option - IntSetArgs classes(noptions); - int** cdata = new int*[noptions]; - for (int i = noptions; i--;) - cdata[i] = new int[nclasses]; - int* n = new int[noptions]; - for (int i = noptions; i--;) + IntSetArgs classes(option_count); + int** class_data = new int*[option_count]; + for (int i = option_count; i--;) + class_data[i] = new int[class_count]; + int* n = new int[option_count]; + for (int i = option_count; i--;) n[i] = 0; // Read data - for (int c = 0; c < nclasses; ++c) { - probit++; - ncc[c] = *probit++; - for (int o = 0; o < noptions; ++o) { - if (*probit++) { - cdata[o][n[o]++] = c; + for (int c = 0; c < class_count; ++c) { + problem_cursor++; + ncc[c] = *problem_cursor++; + for (int o = 0; o < option_count; ++o) { + if (*problem_cursor++) { + class_data[o][n[o]++] = c; } } } // Transfer specification data to int-sets - for (int o = noptions; o--;) { - classes[o] = IntSet(cdata[o], n[o]); - delete[] cdata[o]; + for (int o = option_count; o--;) { + classes[o] = IntSet(class_data[o], n[o]); + delete[] class_data[o]; } - delete[] cdata; + delete[] class_data; delete[] n; // Count the cars { - IntSetArgs c(nclasses + 2); - for (int i = nclasses; i--;) { + IntSetArgs c(class_count + 2); + for (int i = class_count; i--;) { c[i] = IntSet(ncc[i], ncc[i]); } - c[stallval] = IntSet(0, maxstall); - c[endval] = IntSet(0, maxstall); + c[stall_value] = IntSet(0, max_stalls); + c[end_value] = IntSet(0, max_stalls); count(*this, s, c); } // Count number of end and stalls - count(*this, s, stallval, IRT_EQ, nstall); - count(*this, s, endval, IRT_EQ, nend); - rel(*this, nstall + nend == maxstall); + count(*this, s, stall_value, IRT_EQ, stall_count); + count(*this, s, end_value, IRT_EQ, end_count); + rel(*this, stall_count + end_count == max_stalls); // Make sure nothing is overloaded IntSet one(1, 1); - for (int o = noptions; o--;) { + for (int o = option_count; o--;) { // sb[i] reflects if car s[i] has option o BoolVarArgs sb(s.size()); for (int i = s.size(); i--;) { @@ -311,20 +312,20 @@ class CarSequencing : public Script { // End-markers located at end only switch (opt.propagation()) { case PROP_REGULAR: { - IntArgs notend(nclasses), notstallend(nclasses + 1); - for (int i = nclasses; i--;) { - notend[i] = i; - notstallend[i] = i; + IntArgs class_values(class_count), class_or_stall_values(class_count + 1); + for (int i = class_count; i--;) { + class_values[i] = i; + class_or_stall_values[i] = i; } - notstallend[nclasses] = stallval; - REG r = *REG(notend) + REG(notstallend) + *REG(endval); + class_or_stall_values[class_count] = stall_value; + REG r = *REG(class_values) + REG(class_or_stall_values) + *REG(end_value); extensional(*this, s, r); - for (int pos = s.size() - 1, i = 0; i < maxstall; ++i, --pos) { - rel(*this, (nend > i) >> (s[pos] == endval)); + for (int pos = s.size() - 1, i = 0; i < max_stalls; ++i, --pos) { + rel(*this, (end_count > i) >> (s[pos] == end_value)); } } break; case PROP_CUSTOM: { - pushtoend(*this, s, nend, endval); + push_to_end(*this, s, end_count, end_value); } break; } @@ -352,33 +353,33 @@ class CarSequencing : public Script { } /// Return cost - virtual void - constrain(const Space& _best) { + void + constrain(const Space& _best) override { const CarSequencing& best = static_cast(_best); - rel(*this, nstall, IRT_LE, best.nstall.val()); + rel(*this, stall_count, IRT_LE, best.stall_count.val()); } using Script::compare; /// Compare objective values - virtual SpaceComparison - compare(const Space& _other) const { + SpaceComparison + compare(const Space& _other) const override { const CarSequencing& other = static_cast(_other); - return compare_int(nstall.val(), other.nstall.val(), Sense::Minimize); + return compare_int(stall_count.val(), other.stall_count.val(), Sense::Minimize); } /// Print solution - virtual void - print(std::ostream& os) const { - int width = nclasses > 9 ? 2 : 1; - const char* space = nclasses > 9 ? " " : ""; - os << "Stall slots=" << nstall << ", End slots=" << nend << std::endl; + void + print(std::ostream& os) const override { + int width = class_count > 9 ? 2 : 1; + const char* space = class_count > 9 ? " " : ""; + os << "Stall slots=" << stall_count << ", End slots=" << end_count << std::endl; int i = 0; for (; i < s.size(); ++i) { if (s[i].assigned()) { int v = s[i].val(); - if (v == endval) + if (v == end_value) break; - if (v == stallval) + if (v == stall_value) os << space << "_ "; else os << std::setw(width) << v << " "; @@ -395,15 +396,15 @@ class CarSequencing : public Script { /// Constructor for cloning \a s CarSequencing(CarSequencing& cs) - : Script(cs), problem(cs.problem), ncars(cs.ncars), noptions(cs.noptions), nclasses(cs.nclasses), - maxstall(cs.maxstall), stallval(cs.stallval), endval(cs.endval) { - nstall.update(*this, cs.nstall); - nend.update(*this, cs.nend); + : Script(cs), problem(cs.problem), car_count(cs.car_count), option_count(cs.option_count), + class_count(cs.class_count), max_stalls(cs.max_stalls), stall_value(cs.stall_value), end_value(cs.end_value) { + stall_count.update(*this, cs.stall_count); + end_count.update(*this, cs.end_count); s.update(*this, cs.s); } /// Copy during cloning - virtual Space* - copy(void) { + Space* + copy(void) override { return new CarSequencing(*this); } }; diff --git a/examples/cartesian-heart.cpp b/examples/cartesian-heart.cpp index 0143256143..c56d376a2e 100644 --- a/examples/cartesian-heart.cpp +++ b/examples/cartesian-heart.cpp @@ -81,13 +81,13 @@ class CartesianHeart : public Script { f.update(*this, p.f); } /// Copy during cloning - virtual Space* - copy(void) { + Space* + copy(void) override { return new CartesianHeart(*this); } /// Add constraints to current model to get next solution (not too close) - virtual void - constrain(const Space& _b) { + void + constrain(const Space& _b) override { const CartesianHeart& b = static_cast(_b); rel(*this, (f[0] >= (b.f[0].max() + step)) || (f[1] >= (b.f[1].max() + step)) || (f[1] <= (b.f[1].min() - step))); @@ -101,16 +101,16 @@ class CartesianHeart : public Script { * is far enough from \a other to satisfy constrain, so parallel search keeps * the same kind of solutions as sequential search. This is not an order. */ - virtual SpaceComparison - compare(const Space& _other) const { + SpaceComparison + compare(const Space& _other) const override { const CartesianHeart& b = static_cast(_other); bool apart = (f[0].min() >= (b.f[0].max() + step)) || (f[1].min() >= (b.f[1].max() + step)) || (f[1].max() <= (b.f[1].min() - step)); return apart ? SpaceComparison::Better : SpaceComparison::Worse; } /// Print solution coordinates - virtual void - print(std::ostream& os) const { + void + print(std::ostream& os) const override { os << "XY " << f[0].med() << " " << f[1].med() << std::endl; } }; diff --git a/examples/colored-matrix.cpp b/examples/colored-matrix.cpp index 6a4070d0e1..56192ab2c7 100644 --- a/examples/colored-matrix.cpp +++ b/examples/colored-matrix.cpp @@ -234,9 +234,9 @@ class ColoredMatrix : public IntMinimizeScript { switch (opt.distinct_except_0()) { case DISTINCT_EXCEPT_0_REIFIED: for (int i = v.size(); i--;) { - BoolVar viIsZero = expr(*this, v[i] == 0); + BoolVar vi_is_zero = expr(*this, v[i] == 0); for (int j = i; j--;) { - rel(*this, viIsZero || (v[i] != v[j])); + rel(*this, vi_is_zero || (v[i] != v[j])); } } break; @@ -427,18 +427,18 @@ class ColoredMatrix : public IntMinimizeScript { } } - branch(*this, x, tiebreak(INT_VAR_MIN_MIN(), INT_VAR_SIZE_MIN()), INT_VAL_MIN()); + branch(*this, x, tie_break(INT_VAR_MIN_MIN(), INT_VAR_SIZE_MIN()), INT_VAL_MIN()); } /// Return cost - virtual IntVar - cost(void) const { + IntVar + cost(void) const override { return max_color; } /// Print solution - virtual void - print(std::ostream& os) const { + void + print(std::ostream& os) const override { Matrix m(x, width, height); for (int r = 0; r < height; ++r) { os << "\t"; @@ -459,8 +459,8 @@ class ColoredMatrix : public IntMinimizeScript { max_color.update(*this, s.max_color); } /// Copy during cloning - virtual Space* - copy(void) { + Space* + copy(void) override { return new ColoredMatrix(*this); } }; diff --git a/examples/crew.cpp b/examples/crew.cpp index 8b32abe83f..5d4d6b4f33 100644 --- a/examples/crew.cpp +++ b/examples/crew.cpp @@ -41,28 +41,28 @@ using namespace Gecode; namespace { /// The airline employees typedef enum { - Tom, - David, - Jeremy, - Ron, - Joe, - Bill, - Fred, - Bob, - Mario, - Ed, - Carol, - Janet, - Tracy, - Marilyn, - Carolyn, - Cathy, - Inez, - Jean, - Heather, - Juliet + TOM, + DAVID, + JEREMY, + RON, + JOE, + BILL, + FRED, + BOB, + MARIO, + ED, + CAROL, + JANET, + TRACY, + MARILYN, + CAROLYN, + CATHY, + INEZ, + JEAN, + HEATHER, + JULIET } Employee; - const int noOfEmployees = Juliet + 1; + const int no_of_employees = JULIET + 1; /// A flight to schedule struct Flight { @@ -74,19 +74,19 @@ namespace { int german; ///< How many German speaking employees are required }; - const char* employeeToName(Employee e); + const char* employee_to_name(Employee e); extern const int stewards[]; - extern const int noOfStewards; + extern const int no_of_stewards; extern const int hostesses[]; - extern const int noOfHostesses; - extern const int spanishSpeaking[]; - extern const int noOfSpanishSpeaking; - extern const int frenchSpeaking[]; - extern const int noOfFrenchSpeaking; - extern const int germanSpeaking[]; - extern const int noOfGermanSpeaking; - extern const Flight requiredCrew[]; - extern const int noOfFlights; + extern const int no_of_hostesses; + extern const int spanish_speaking[]; + extern const int no_of_spanish_speaking; + extern const int french_speaking[]; + extern const int no_of_french_speaking; + extern const int german_speaking[]; + extern const int no_of_german_speaking; + extern const Flight required_crew[]; + extern const int no_of_flights; } // namespace /** @@ -105,58 +105,58 @@ class Crew : public Script { SetVarArray flight; /// The actual model - Crew(const Options& opt) : Script(opt), flight(*this, noOfFlights, IntSet::empty, 0, noOfEmployees - 1) { - IntSet stewardsDS(stewards, noOfStewards); - IntSet hostessesDS(hostesses, noOfHostesses); - IntSet spanishDS(spanishSpeaking, noOfSpanishSpeaking); - IntSet frenchDS(frenchSpeaking, noOfFrenchSpeaking); - IntSet germanDS(germanSpeaking, noOfGermanSpeaking); + Crew(const Options& opt) : Script(opt), flight(*this, no_of_flights, IntSet::empty, 0, no_of_employees - 1) { + IntSet stewards_ds(stewards, no_of_stewards); + IntSet hostesses_ds(hostesses, no_of_hostesses); + IntSet spanish_ds(spanish_speaking, no_of_spanish_speaking); + IntSet french_ds(french_speaking, no_of_french_speaking); + IntSet german_ds(german_speaking, no_of_german_speaking); - for (int i = 0; i < noOfFlights; i++) { + for (int i = 0; i < no_of_flights; i++) { // The flight has staff as required by the specification - rel(*this, cardinality(flight[i]) == requiredCrew[i].staff); + rel(*this, cardinality(flight[i]) == required_crew[i].staff); // Enough members of different categories are on board - rel(*this, cardinality(flight[i] & stewardsDS) >= requiredCrew[i].stewards); - rel(*this, cardinality(flight[i] & hostessesDS) >= requiredCrew[i].hostesses); - rel(*this, cardinality(flight[i] & spanishDS) >= requiredCrew[i].spanish); - rel(*this, cardinality(flight[i] & frenchDS) >= requiredCrew[i].french); - rel(*this, cardinality(flight[i] & germanDS) >= requiredCrew[i].german); + rel(*this, cardinality(flight[i] & stewards_ds) >= required_crew[i].stewards); + rel(*this, cardinality(flight[i] & hostesses_ds) >= required_crew[i].hostesses); + rel(*this, cardinality(flight[i] & spanish_ds) >= required_crew[i].spanish); + rel(*this, cardinality(flight[i] & french_ds) >= required_crew[i].french); + rel(*this, cardinality(flight[i] & german_ds) >= required_crew[i].german); } // No crew member of flight i works on flights i+1 and i+2 - for (int i = 0; i < noOfFlights - 2; i++) { + for (int i = 0; i < no_of_flights - 2; i++) { rel(*this, flight[i] || flight[i + 1]); rel(*this, flight[i] || flight[i + 2]); } - rel(*this, flight[noOfFlights - 2] || flight[noOfFlights - 1]); + rel(*this, flight[no_of_flights - 2] || flight[no_of_flights - 1]); branch(*this, flight, SET_VAR_NONE(), SET_VAL_MIN_INC()); } /// Print solution - virtual void - print(std::ostream& os) const { - for (int i = 0; i < noOfFlights; i++) { + void + print(std::ostream& os) const override { + for (int i = 0; i < no_of_flights; i++) { os << "\tFlight " << i + 1 << ":" << std::endl; os << "\t\tCrew\tStew.\tHost.\tFrench\tSpanish\tGerman" << std::endl << "\t"; - os << "\t" << requiredCrew[i].staff << "\t" << requiredCrew[i].stewards << "\t" << requiredCrew[i].hostesses - << "\t" << requiredCrew[i].spanish << "\t" << requiredCrew[i].french << "\t" << requiredCrew[i].german - << std::endl; + os << "\t" << required_crew[i].staff << "\t" << required_crew[i].stewards << "\t" + << required_crew[i].hostesses << "\t" << required_crew[i].spanish << "\t" << required_crew[i].french + << "\t" << required_crew[i].german << std::endl; os << "\t\tSchedule:" << std::endl << "\t\t"; if (flight[i].assigned()) { for (SetVarGlbValues d(flight[i]); d(); ++d) { - os << employeeToName(static_cast(d.val())) << " "; + os << employee_to_name(static_cast(d.val())) << " "; } } else { os << "\tRequired: "; for (SetVarGlbValues d(flight[i]); d(); ++d) { - os << employeeToName(static_cast(d.val())) << " "; + os << employee_to_name(static_cast(d.val())) << " "; } os << std::endl << "\t\t\tPossible: "; for (SetVarUnknownValues d(flight[i]); d(); ++d) { - os << employeeToName(static_cast(d.val())) << " "; + os << employee_to_name(static_cast(d.val())) << " "; } } os << std::endl << std::endl; @@ -168,8 +168,8 @@ class Crew : public Script { flight.update(*this, s.flight); } /// Copy during cloning - virtual Space* - copy(void) { + Space* + copy(void) override { return new Crew(*this); } }; @@ -190,47 +190,47 @@ namespace { /// Return name of employee \a e as a string const char* - employeeToName(Employee e) { + employee_to_name(Employee e) { switch (e) { - case Tom: + case TOM: return "Tom"; - case David: + case DAVID: return "David"; - case Jeremy: + case JEREMY: return "Jeremy"; - case Ron: + case RON: return "Ron"; - case Joe: + case JOE: return "Joe"; - case Bill: + case BILL: return "Bill"; - case Fred: + case FRED: return "Fred"; - case Bob: + case BOB: return "Bob"; - case Mario: + case MARIO: return "Mario"; - case Ed: + case ED: return "Ed"; - case Carol: + case CAROL: return "Carol"; - case Janet: + case JANET: return "Janet"; - case Tracy: + case TRACY: return "Tracy"; - case Marilyn: + case MARILYN: return "Marilyn"; - case Carolyn: + case CAROLYN: return "Carolyn"; - case Cathy: + case CATHY: return "Cathy"; - case Inez: + case INEZ: return "Inez"; - case Jean: + case JEAN: return "Jean"; - case Heather: + case HEATHER: return "Heather"; - case Juliet: + case JULIET: return "Juliet"; default: GECODE_NEVER; @@ -240,33 +240,33 @@ namespace { // these have to be sorted! /// The stewards - const int stewards[] = {Tom, David, Jeremy, Ron, Joe, Bill, Fred, Bob, Mario, Ed}; + const int stewards[] = {TOM, DAVID, JEREMY, RON, JOE, BILL, FRED, BOB, MARIO, ED}; /// The number of stewards - const int noOfStewards = sizeof(stewards) / sizeof(int); + const int no_of_stewards = sizeof(stewards) / sizeof(int); /// The hostesses - const int hostesses[] = {Carol, Janet, Tracy, Marilyn, Carolyn, Cathy, Inez, Jean, Heather, Juliet}; + const int hostesses[] = {CAROL, JANET, TRACY, MARILYN, CAROLYN, CATHY, INEZ, JEAN, HEATHER, JULIET}; /// The number of hostesses - const int noOfHostesses = sizeof(hostesses) / sizeof(int); + const int no_of_hostesses = sizeof(hostesses) / sizeof(int); /// The French speaking employees - const int frenchSpeaking[] = {Bill, Inez, Jean, Juliet}; + const int french_speaking[] = {BILL, INEZ, JEAN, JULIET}; /// The number of French speaking employees - const int noOfFrenchSpeaking = sizeof(frenchSpeaking) / sizeof(int); + const int no_of_french_speaking = sizeof(french_speaking) / sizeof(int); /// The German speaking employees - const int germanSpeaking[] = {Tom, Jeremy, Mario, Cathy, Juliet}; + const int german_speaking[] = {TOM, JEREMY, MARIO, CATHY, JULIET}; /// The number of German speaking employees - const int noOfGermanSpeaking = sizeof(germanSpeaking) / sizeof(int); + const int no_of_german_speaking = sizeof(german_speaking) / sizeof(int); /// The Spanish speaking employees - const int spanishSpeaking[] = {Joe, Bill, Fred, Mario, Marilyn, Inez, Heather}; + const int spanish_speaking[] = {JOE, BILL, FRED, MARIO, MARILYN, INEZ, HEATHER}; /// The number of Spanish speaking employees - const int noOfSpanishSpeaking = sizeof(spanishSpeaking) / sizeof(int); + const int no_of_spanish_speaking = sizeof(spanish_speaking) / sizeof(int); /// The flights to schedule - const Flight requiredCrew[] = {{4, 1, 1, 1, 1, 1}, {5, 1, 1, 1, 1, 1}, {5, 1, 1, 1, 1, 1}, {6, 2, 2, 1, 1, 1}, - {7, 3, 3, 1, 1, 1}, {4, 1, 1, 1, 1, 1}, {5, 1, 1, 1, 1, 1}, {6, 1, 1, 1, 1, 1}, - {6, 2, 2, 1, 1, 1}, {7, 3, 3, 1, 1, 1}}; + const Flight required_crew[] = {{4, 1, 1, 1, 1, 1}, {5, 1, 1, 1, 1, 1}, {5, 1, 1, 1, 1, 1}, {6, 2, 2, 1, 1, 1}, + {7, 3, 3, 1, 1, 1}, {4, 1, 1, 1, 1, 1}, {5, 1, 1, 1, 1, 1}, {6, 1, 1, 1, 1, 1}, + {6, 2, 2, 1, 1, 1}, {7, 3, 3, 1, 1, 1}}; /// The number of flights to schedule - const int noOfFlights = sizeof(requiredCrew) / sizeof(Flight); + const int no_of_flights = sizeof(required_crew) / sizeof(Flight); } // namespace // STATISTICS: example-any diff --git a/examples/crossword.cpp b/examples/crossword.cpp index 8575d252f7..c9a287b5a5 100644 --- a/examples/crossword.cpp +++ b/examples/crossword.cpp @@ -204,57 +204,57 @@ class Crossword : public Script { switch (opt.branching()) { case BRANCH_WORDS_AFC: // Branch by assigning words - branch(*this, allwords, INT_VAR_AFC_SIZE_MAX(opt.decay()), INT_VAL_SPLIT_MIN(), nullptr, &printwords); + branch(*this, allwords, INT_VAR_AFC_SIZE_MAX(opt.decay()), INT_VAL_SPLIT_MIN(), nullptr, &print_words); break; case BRANCH_LETTERS_AFC: // Branch by assigning letters - branch(*this, letters, INT_VAR_AFC_SIZE_MAX(opt.decay()), INT_VAL_MIN(), nullptr, &printletters); + branch(*this, letters, INT_VAR_AFC_SIZE_MAX(opt.decay()), INT_VAL_MIN(), nullptr, &print_letters); break; case BRANCH_LETTERS_AFC_ALL: // Branch by assigning letters (try all letters) - branch(*this, letters, INT_VAR_AFC_SIZE_MAX(opt.decay()), INT_VALUES_MIN(), nullptr, &printletters); + branch(*this, letters, INT_VAR_AFC_SIZE_MAX(opt.decay()), INT_VALUES_MIN(), nullptr, &print_letters); break; case BRANCH_WORDS_ACTION: // Branch by assigning words - branch(*this, allwords, INT_VAR_ACTION_SIZE_MAX(opt.decay()), INT_VAL_SPLIT_MIN(), nullptr, &printwords); + branch(*this, allwords, INT_VAR_ACTION_SIZE_MAX(opt.decay()), INT_VAL_SPLIT_MIN(), nullptr, &print_words); break; case BRANCH_LETTERS_ACTION: // Branch by assigning letters - branch(*this, letters, INT_VAR_ACTION_SIZE_MAX(opt.decay()), INT_VAL_MIN(), nullptr, &printletters); + branch(*this, letters, INT_VAR_ACTION_SIZE_MAX(opt.decay()), INT_VAL_MIN(), nullptr, &print_letters); break; case BRANCH_LETTERS_ACTION_ALL: // Branch by assigning letters (try all letters) - branch(*this, letters, INT_VAR_ACTION_SIZE_MAX(opt.decay()), INT_VALUES_MIN(), nullptr, &printletters); + branch(*this, letters, INT_VAR_ACTION_SIZE_MAX(opt.decay()), INT_VALUES_MIN(), nullptr, &print_letters); break; case BRANCH_WORDS_CHB: // Branch by assigning words - branch(*this, allwords, INT_VAR_CHB_SIZE_MAX(), INT_VAL_SPLIT_MIN(), nullptr, &printwords); + branch(*this, allwords, INT_VAR_CHB_SIZE_MAX(), INT_VAL_SPLIT_MIN(), nullptr, &print_words); break; case BRANCH_LETTERS_CHB: // Branch by assigning letters - branch(*this, letters, INT_VAR_CHB_SIZE_MAX(), INT_VAL_MIN(), nullptr, &printletters); + branch(*this, letters, INT_VAR_CHB_SIZE_MAX(), INT_VAL_MIN(), nullptr, &print_letters); break; case BRANCH_LETTERS_CHB_ALL: // Branch by assigning letters (try all letters) - branch(*this, letters, INT_VAR_CHB_SIZE_MAX(), INT_VALUES_MIN(), nullptr, &printletters); + branch(*this, letters, INT_VAR_CHB_SIZE_MAX(), INT_VALUES_MIN(), nullptr, &print_letters); break; } } /// Print brancher information when branching on letters static void - printletters(const Space& home, const Brancher&, unsigned int a, IntVar, int i, const int& n, std::ostream& os) { + print_letters(const Space& home, const Brancher&, unsigned int a, IntVar, int i, const int& n, std::ostream& os) { const Crossword& c = static_cast(home); int x = i % c.w, y = i / c.w; os << "letters[" << x << "," << y << "] " << ((a == 0) ? "=" : "!=") << " " << static_cast(n); } /// Print brancher information when branching on words static void - printwords(const Space&, const Brancher&, unsigned int a, IntVar, int i, const int& n, std::ostream& os) { + print_words(const Space&, const Brancher&, unsigned int a, IntVar, int i, const int& n, std::ostream& os) { os << "allwords[" << i << "] " << ((a == 0) ? "<=" : ">") << " " << n; } /// Post no-goods, and do not perform a restart when a solution is found void - hub(HubContext& hc) { + hub(HubContext& hc) override { if (hc.engine() == MetaEngine::Restart) { hc.nogoods().post(*this); if (hc.event() == MetaEvent::Solution) @@ -268,13 +268,13 @@ class Crossword : public Script { letters.update(*this, s.letters); } /// Copy during cloning - virtual Space* - copy(void) { + Space* + copy(void) override { return new Crossword(*this); } /// Print solution - virtual void - print(std::ostream& os) const { + void + print(std::ostream& os) const override { // Matrix for letters Matrix ml(letters, w, h); for (int i = 0; i < h; i++) { diff --git a/examples/crowded-chess.cpp b/examples/crowded-chess.cpp index 780cb5cffe..6a1734d338 100644 --- a/examples/crowded-chess.cpp +++ b/examples/crowded-chess.cpp @@ -87,8 +87,8 @@ namespace { Bishops(Bishops& s) : Space(s), n(s.n) { k.update(*this, s.k); } - virtual Space* - copy(void) { + Space* + copy(void) override { return new Bishops(*this); } }; @@ -331,14 +331,14 @@ class CrowdedChess : public Script { } /// Copy during cloning - virtual Space* - copy(void) { + Space* + copy(void) override { return new CrowdedChess(*this); } /// Print solution - virtual void - print(std::ostream& os) const { + void + print(std::ostream& os) const override { Matrix m(s, n); char names[PMAX]; names[E] = '.'; diff --git a/examples/descartes-folium.cpp b/examples/descartes-folium.cpp index b88bf0ee6e..9612baf04e 100644 --- a/examples/descartes-folium.cpp +++ b/examples/descartes-folium.cpp @@ -94,18 +94,18 @@ class DescartesFolium : public FloatMaximizeScript { f.update(*this, p.f); } /// Copy during cloning - virtual Space* - copy(void) { + Space* + copy(void) override { return new DescartesFolium(*this); } /// Cost function - virtual FloatVar - cost(void) const { + FloatVar + cost(void) const override { return f[0]; } /// Print solution coordinates - virtual void - print(std::ostream& os) const { + void + print(std::ostream& os) const override { os << "XY " << f[1].med() << " " << f[2].med() << std::endl; } }; diff --git a/examples/dominating-queens.cpp b/examples/dominating-queens.cpp index f97092cb6c..1dd5a0971a 100644 --- a/examples/dominating-queens.cpp +++ b/examples/dominating-queens.cpp @@ -112,8 +112,8 @@ class DominatingQueens : public IntMinimizeScript { } /// Return cost - virtual IntVar - cost(void) const { + IntVar + cost(void) const override { return q; } @@ -124,14 +124,14 @@ class DominatingQueens : public IntMinimizeScript { } /// Perform copying during cloning - virtual Space* - copy(void) { + Space* + copy(void) override { return new DominatingQueens(*this); } /// Print solution - virtual void - print(std::ostream& os) const { + void + print(std::ostream& os) const override { os << "\tNumber of Queens: " << q << std::endl; os << "\tBoard: " << b << std::endl; if (b.assigned()) { diff --git a/examples/domino.cpp b/examples/domino.cpp index 8ddf572cfa..b4801e06fe 100644 --- a/examples/domino.cpp +++ b/examples/domino.cpp @@ -106,10 +106,10 @@ class Domino : public Script { IntVarArgs p2(*this, 28, 0, (width + 1) * height - 1); if (opt.propagation() == PROP_ELEMENT) { - int dominoCount = 0; + int domino_count = 0; - int possibleDiffsA[] = {1, width + 1}; - IntSet possibleDiffs(possibleDiffsA, 2); + int possible_diffs_a[] = {1, width + 1}; + IntSet possible_diffs(possible_diffs_a, 2); for (int i = 0; i <= 6; i++) for (int j = i; j <= 6; j++) { @@ -119,25 +119,25 @@ class Domino : public Script { // The separator column makes sure that a field // at the right border is not adjacent to the first field // in the next row. - IntVar diff(*this, possibleDiffs); - abs(*this, expr(*this, p1[dominoCount] - p2[dominoCount]), diff, IPL_DOM); + IntVar diff(*this, possible_diffs); + abs(*this, expr(*this, p1[domino_count] - p2[domino_count]), diff, IPL_DOM); // If the piece is symmetrical, order the locations if (i == j) - rel(*this, p1[dominoCount], IRT_LE, p2[dominoCount]); + rel(*this, p1[domino_count], IRT_LE, p2[domino_count]); // Link the current piece to the board - element(*this, board, p1[dominoCount], i); - element(*this, board, p2[dominoCount], j); + element(*this, board, p1[domino_count], i); + element(*this, board, p2[domino_count], j); // Link the current piece to the array where its // number is stored. - element(*this, x, p1[dominoCount], dominoCount); - element(*this, x, p2[dominoCount], dominoCount); - dominoCount++; + element(*this, x, p1[domino_count], domino_count); + element(*this, x, p2[domino_count], domino_count); + domino_count++; } } else { - int dominoCount = 0; + int domino_count = 0; for (int i = 0; i <= 6; i++) for (int j = i; j <= 6; j++) { @@ -160,13 +160,13 @@ class Domino : public Script { valids |= REG(pos + width + 1) + REG(pos); } } - extensional(*this, IntVarArgs({p1[dominoCount], p2[dominoCount]}), valids); + extensional(*this, IntVarArgs({p1[domino_count], p2[domino_count]}), valids); // Link the current piece to the array where its // number is stored. - element(*this, x, p1[dominoCount], dominoCount); - element(*this, x, p2[dominoCount], dominoCount); - dominoCount++; + element(*this, x, p1[domino_count], domino_count); + element(*this, x, p2[domino_count], domino_count); + domino_count++; } } @@ -181,8 +181,8 @@ class Domino : public Script { } /// Print solution - virtual void - print(std::ostream& os) const { + void + print(std::ostream& os) const override { for (int h = 0; h < height; ++h) { os << "\t"; for (int w = 0; w < width; ++w) { @@ -199,8 +199,8 @@ class Domino : public Script { x.update(*this, s.x); } /// Copy space during cloning - virtual Space* - copy(void) { + Space* + copy(void) override { return new Domino(*this); } }; diff --git a/examples/donald.cpp b/examples/donald.cpp index 393a3aa3ba..2cb9a701bc 100644 --- a/examples/donald.cpp +++ b/examples/donald.cpp @@ -94,13 +94,13 @@ class Donald : public Script { le.update(*this, s.le); } /// Copy during cloning - virtual Space* - copy(void) { + Space* + copy(void) override { return new Donald(*this); } /// Print solution - virtual void - print(std::ostream& os) const { + void + print(std::ostream& os) const override { os << "\t" << le << std::endl; ; } diff --git a/examples/efpa.cpp b/examples/efpa.cpp index feb064530d..7579cfaa83 100644 --- a/examples/efpa.cpp +++ b/examples/efpa.cpp @@ -279,8 +279,8 @@ class EFPA : public Script { } /// Print instance and solution - virtual void - print(std::ostream& os) const { + void + print(std::ostream& os) const override { Matrix cm(c, n, v); for (int i = 0; i < v; ++i) { IntVarArgs r = cm.row(i); @@ -295,8 +295,8 @@ class EFPA : public Script { diff.update(*this, s.diff); } /// Copy during cloning - virtual Space* - copy(void) { + Space* + copy(void) override { return new EFPA(*this); } }; diff --git a/examples/eq20.cpp b/examples/eq20.cpp index 60299940b6..5a60036fae 100644 --- a/examples/eq20.cpp +++ b/examples/eq20.cpp @@ -89,13 +89,13 @@ class Eq20 : public Script { x.update(*this, s.x); } /// Perform copying during cloning - virtual Space* - copy(void) { + Space* + copy(void) override { return new Eq20(*this); } /// Print solution - virtual void - print(std::ostream& os) const { + void + print(std::ostream& os) const override { os << "\tx[] = " << x << std::endl; } }; diff --git a/examples/fifteen-puzzle.cpp b/examples/fifteen-puzzle.cpp index 5659934cbf..3d0773d5cc 100644 --- a/examples/fifteen-puzzle.cpp +++ b/examples/fifteen-puzzle.cpp @@ -412,6 +412,8 @@ run(PuzzleOptions& opt) { Script::run(opt); else Script::run(opt); + // The guidance lives only in this block + opt.guidance(nullptr); } break; #endif } diff --git a/examples/golden-spiral.cpp b/examples/golden-spiral.cpp index f24cad2845..fc00d01d9e 100644 --- a/examples/golden-spiral.cpp +++ b/examples/golden-spiral.cpp @@ -99,18 +99,18 @@ class GoldenSpiral : public FloatMaximizeScript { f.update(*this, p.f); } /// Copy during cloning - virtual Space* - copy(void) { + Space* + copy(void) override { return new GoldenSpiral(*this); } /// Cost function - virtual FloatVar - cost(void) const { + FloatVar + cost(void) const override { return f[0]; } /// Print solution coordinates - virtual void - print(std::ostream& os) const { + void + print(std::ostream& os) const override { os << "XY " << f[1].med() << " " << f[2].med() << std::endl; } }; diff --git a/examples/golf.cpp b/examples/golf.cpp index 323742d92e..45777595b7 100644 --- a/examples/golf.cpp +++ b/examples/golf.cpp @@ -111,9 +111,9 @@ class Golf : public Script { Matrix schedule(groups, g, w); // Groups in one week must be disjoint - SetVar allPlayers(*this, 0, g * s - 1, 0, g * s - 1); + SetVar all_players(*this, 0, g * s - 1, 0, g * s - 1); for (int i = 0; i < w; i++) - rel(*this, setdunion(schedule.row(i)) == allPlayers); + rel(*this, set_disjoint_union(schedule.row(i)) == all_players); // No two golfers play in the same group more than once if (opt.propagation() == PROP_SET || opt.propagation() == PROP_MIXED) { @@ -125,12 +125,12 @@ class Golf : public Script { if (opt.propagation() == PROP_INT || opt.propagation() == PROP_MIXED) { // Set up table mapping from pairs (p1,p2) (where p1 schedule(groups, g, w); for (int j = 0; j < w; j++) { @@ -218,8 +218,8 @@ class Golf : public Script { groups.update(*this, s.groups); } /// Copy during cloning - virtual Space* - copy(void) { + Space* + copy(void) override { return new Golf(*this); } }; diff --git a/examples/golomb-ruler.cpp b/examples/golomb-ruler.cpp index b054cf2ddd..b223e10475 100644 --- a/examples/golomb-ruler.cpp +++ b/examples/golomb-ruler.cpp @@ -98,14 +98,14 @@ class GolombRuler : public IntMinimizeScript { } /// Return cost - virtual IntVar - cost(void) const { + IntVar + cost(void) const override { return m[m.size() - 1]; } /// Print solution - virtual void - print(std::ostream& os) const { + void + print(std::ostream& os) const override { os << "\tm[" << m.size() << "] = " << m << std::endl; } @@ -114,8 +114,8 @@ class GolombRuler : public IntMinimizeScript { m.update(*this, s.m); } /// Copy during cloning - virtual Space* - copy(void) { + Space* + copy(void) override { return new GolombRuler(*this); } }; diff --git a/examples/graph-color.cpp b/examples/graph-color.cpp index bbe2508f13..96b0099d8b 100644 --- a/examples/graph-color.cpp +++ b/examples/graph-color.cpp @@ -282,7 +282,7 @@ class GraphColor : public IntMinimizeScript { branch(*this, v, INT_VAR_SIZE_MIN(), INT_VAL_MIN()); break; case BRANCH_DEGREE: - branch(*this, v, tiebreak(INT_VAR_DEGREE_MAX(), INT_VAR_SIZE_MIN()), INT_VAL_MIN()); + branch(*this, v, tie_break(INT_VAR_DEGREE_MAX(), INT_VAR_SIZE_MIN()), INT_VAL_MIN()); break; case BRANCH_DEGREE_SIZE: branch(*this, v, INT_VAR_DEGREE_SIZE_MAX(), INT_VAL_MIN()); @@ -298,13 +298,13 @@ class GraphColor : public IntMinimizeScript { // Branching while considering value symmetry breaking // (every permutation of color values gives equivalent solutions) Symmetries syms; - syms << ValueSymmetry(IntArgs::create(g.n_v, 0)); + syms << value_symmetry(IntArgs::create(g.n_v, 0)); switch (opt.branching()) { case BRANCH_SIZE: branch(*this, v, INT_VAR_SIZE_MIN(), INT_VAL_MIN(), syms); break; case BRANCH_DEGREE: - branch(*this, v, tiebreak(INT_VAR_DEGREE_MAX(), INT_VAR_SIZE_MIN()), INT_VAL_MIN(), syms); + branch(*this, v, tie_break(INT_VAR_DEGREE_MAX(), INT_VAR_SIZE_MIN()), INT_VAL_MIN(), syms); break; case BRANCH_DEGREE_SIZE: branch(*this, v, INT_VAR_DEGREE_SIZE_MAX(), INT_VAL_MIN(), syms); @@ -319,8 +319,8 @@ class GraphColor : public IntMinimizeScript { } } /// Cost function - virtual IntVar - cost(void) const { + IntVar + cost(void) const override { return m; } /// Constructor for cloning \a s @@ -329,13 +329,13 @@ class GraphColor : public IntMinimizeScript { m.update(*this, s.m); } /// Copying during cloning - virtual Space* - copy(void) { + Space* + copy(void) override { return new GraphColor(*this); } /// Print the solution - virtual void - print(std::ostream& os) const { + void + print(std::ostream& os) const override { os << "\tm = " << m << std::endl << "\tv[] = {"; for (int i = 0; i < v.size(); i++) { os << v[i] << ", "; diff --git a/examples/grocery.cpp b/examples/grocery.cpp index 819c9b2e50..f1a60d5650 100644 --- a/examples/grocery.cpp +++ b/examples/grocery.cpp @@ -84,14 +84,14 @@ class Grocery : public Script { } /// Copy during cloning - virtual Space* - copy(void) { + Space* + copy(void) override { return new Grocery(*this); } /// Print solution - virtual void - print(std::ostream& os) const { + void + print(std::ostream& os) const override { os << "\t" << abcd << std::endl; } }; diff --git a/examples/hamming.cpp b/examples/hamming.cpp index 410e412e49..b1071cad25 100644 --- a/examples/hamming.cpp +++ b/examples/hamming.cpp @@ -114,8 +114,8 @@ class Hamming : public Script { } /// Print solution - virtual void - print(std::ostream& os) const { + void + print(std::ostream& os) const override { for (int i = 0; i < x.size(); i++) { os << "\t[" << i << "] = " << x[i] << std::endl; } @@ -126,8 +126,8 @@ class Hamming : public Script { x.update(*this, s.x); } /// Copy during cloning - virtual Space* - copy(void) { + Space* + copy(void) override { return new Hamming(*this); } }; diff --git a/examples/ind-set.cpp b/examples/ind-set.cpp index a00754dd98..8d50a7f221 100644 --- a/examples/ind-set.cpp +++ b/examples/ind-set.cpp @@ -96,18 +96,18 @@ class IndSet : public IntMaximizeScript { k.update(*this, s.k); } /// Copy during cloning - virtual Space* - copy(void) { + Space* + copy(void) override { return new IndSet(*this); } /// Print solution - virtual void - print(std::ostream& os) const { + void + print(std::ostream& os) const override { os << "\tk = " << k << std::endl << "\tv[] = " << v << std::endl; } /// Return solution cost - virtual IntVar - cost(void) const { + IntVar + cost(void) const override { return k; } }; diff --git a/examples/job-shop.cpp b/examples/job-shop.cpp index f93389788a..07a34d677e 100644 --- a/examples/job-shop.cpp +++ b/examples/job-shop.cpp @@ -326,8 +326,8 @@ class JobShopOptions : public InstanceOptions { return _tbf.value(); } /// Print help text for list of instances - virtual void - help(void) { + void + help(void) override { InstanceOptions::help(); std::cerr << "\tAvailable instances:" << std::endl << "\t\t"; for (int i = 1; ::name[i] != nullptr; i++) { @@ -383,7 +383,7 @@ class JobShopBase : public IntMinimizeScript { } /// Do not overload machines void - nooverload(void) { + post_no_overload(void) { // Number of jobs and machines/steps int n = spec.jobs(), m = spec.machines(); @@ -407,8 +407,8 @@ class JobShopBase : public IntMinimizeScript { } } /// Return cost - virtual IntVar - cost(void) const { + IntVar + cost(void) const override { return makespan; } /// Constructor for cloning \a s @@ -417,8 +417,8 @@ class JobShopBase : public IntMinimizeScript { makespan.update(*this, s.makespan); } /// Print solution - virtual void - print(std::ostream& os) const { + void + print(std::ostream& os) const override { os << "\t\t" << spec.name() << " [makespan: " << makespan << "]" << std::endl; if (opt.verbose()) { // Number of jobs @@ -453,7 +453,7 @@ class JobShopProbe : public JobShopBase { public: /// Actual model JobShopProbe(const JobShopOptions& o) : JobShopBase(o) { - nooverload(); + post_no_overload(); } void branch(unsigned int p, Rnd r) { @@ -468,10 +468,10 @@ class JobShopProbe : public JobShopBase { Gecode::branch(*this, start, INT_VAR_SIZE_MIN(), INT_VAL_MIN()); break; case 3U: - Gecode::branch(*this, start, tiebreak(INT_VAR_MIN_MIN(), INT_VAR_RND(r)), INT_VAL_MIN()); + Gecode::branch(*this, start, tie_break(INT_VAR_MIN_MIN(), INT_VAR_RND(r)), INT_VAL_MIN()); break; case 4U: - Gecode::branch(*this, start, tiebreak(INT_VAR_MAX_MIN(), INT_VAR_RND(r)), INT_VAL_MIN()); + Gecode::branch(*this, start, tie_break(INT_VAR_MAX_MIN(), INT_VAR_RND(r)), INT_VAL_MIN()); break; default: if (p & 1U) @@ -485,8 +485,8 @@ class JobShopProbe : public JobShopBase { /// Constructor for cloning \a s JobShopProbe(JobShopProbe& s) : JobShopBase(s) {} /// Copy during cloning - virtual Space* - copy(void) { + Space* + copy(void) override { return new JobShopProbe(*this); } }; @@ -509,7 +509,7 @@ class JobShopSolve : public JobShopBase { } /// Trampoline function for AFC-based cost static double - afcmerit(const Space& home, BoolVar x, int i) { + afc_merit(const Space& home, BoolVar x, int i) { return static_cast(home).afc(x, i); } /// Action information @@ -522,7 +522,7 @@ class JobShopSolve : public JobShopBase { } /// Trampoline function for Action-based cost static double - actionmerit(const Space& home, BoolVar, int i) { + action_merit(const Space& home, BoolVar, int i) { return static_cast(home).action(i); } /// CHB information @@ -535,7 +535,7 @@ class JobShopSolve : public JobShopBase { } /// Trampoline function for CHB-based cost static double - chbmerit(const Space& home, BoolVar, int i) { + chb_merit(const Space& home, BoolVar, int i) { return static_cast(home).chb(i); } /// Random number generator for probing and relaxation @@ -557,7 +557,7 @@ class JobShopSolve : public JobShopBase { JobShopSolve(const JobShopOptions& o) : JobShopBase(o), sorder(*this, spec.machines() * spec.jobs() * (spec.jobs() - 1) / 2, 0, 1), rnd(o.rnd()) { if (opt.propagation() == PROP_UNARY) - nooverload(); + post_no_overload(); // Number of jobs and machines/steps int n = spec.jobs(), m = spec.machines(); @@ -602,9 +602,10 @@ class JobShopSolve : public JobShopBase { assert(b >= w); return b - (b - w) * tbf; }; - branch(*this, sorder, tiebreak(BOOL_VAR_MERIT_MAX(&afcmerit, tbl), BOOL_VAR_RND(rnd)), BOOL_VAL_MIN()); + branch(*this, sorder, tie_break(BOOL_VAR_MERIT_MAX(&afc_merit, tbl), BOOL_VAR_RND(rnd)), + BOOL_VAL_MIN()); } else { - branch(*this, sorder, BOOL_VAR_MERIT_MAX(&afcmerit), BOOL_VAL_MIN()); + branch(*this, sorder, BOOL_VAR_MERIT_MAX(&afc_merit), BOOL_VAL_MIN()); } break; case BRANCH_ACTION: @@ -615,10 +616,10 @@ class JobShopSolve : public JobShopBase { assert(b >= w); return b - (b - w) * tbf; }; - branch(*this, sorder, tiebreak(BOOL_VAR_MERIT_MAX(&actionmerit, tbl), BOOL_VAR_RND(rnd)), + branch(*this, sorder, tie_break(BOOL_VAR_MERIT_MAX(&action_merit, tbl), BOOL_VAR_RND(rnd)), BOOL_VAL_MIN()); } else { - branch(*this, sorder, BOOL_VAR_MERIT_MAX(&actionmerit), BOOL_VAL_MIN()); + branch(*this, sorder, BOOL_VAR_MERIT_MAX(&action_merit), BOOL_VAL_MIN()); } break; case BRANCH_CHB: @@ -629,9 +630,10 @@ class JobShopSolve : public JobShopBase { assert(b >= w); return b - (b - w) * tbf; }; - branch(*this, sorder, tiebreak(BOOL_VAR_MERIT_MAX(&chbmerit, tbl), BOOL_VAR_RND(rnd)), BOOL_VAL_MIN()); + branch(*this, sorder, tie_break(BOOL_VAR_MERIT_MAX(&chb_merit, tbl), BOOL_VAR_RND(rnd)), + BOOL_VAL_MIN()); } else { - branch(*this, sorder, BOOL_VAR_MERIT_MAX(&chbmerit), BOOL_VAL_MIN()); + branch(*this, sorder, BOOL_VAR_MERIT_MAX(&chb_merit), BOOL_VAL_MIN()); } break; } @@ -643,8 +645,8 @@ class JobShopSolve : public JobShopBase { : JobShopBase(s), sorder(s.sorder), fst(s.fst), snd(s.snd), iafc(s.iafc), iaction(s.iaction), baction(s.baction), ichb(s.ichb), bchb(s.bchb), rnd(s.rnd) {} /// Copy during cloning - virtual Space* - copy(void) { + Space* + copy(void) override { return new JobShopSolve(*this); } }; @@ -659,8 +661,8 @@ class FailTimeStop : public Search::Stop { FailTimeStop(unsigned int fail, unsigned int time) : fs(new Search::FailStop(fail)), ts(new Search::TimeStop(time)) {} /// Test whether search must be stopped - virtual bool - stop(const Search::Statistics& s, const Search::Options& o) { + bool + stop(const Search::Statistics& s, const Search::Options& o) override { return fs->stop(s, o) || ts->stop(s, o); } /// Whether the stop was due to failures @@ -674,7 +676,7 @@ class FailTimeStop : public Search::Stop { return ts->stop(s, o); } /// Destructor - ~FailTimeStop(void) { + ~FailTimeStop(void) override { delete fs; delete ts; } diff --git a/examples/kakuro.cpp b/examples/kakuro.cpp index fd2d0a4436..2103dddb03 100644 --- a/examples/kakuro.cpp +++ b/examples/kakuro.cpp @@ -261,8 +261,8 @@ namespace { x.update(*this, s.x); } /// Perform copying during cloning - virtual Space* - copy(void) { + Space* + copy(void) override { return new DistinctLinear(*this); } /// Return a solution @@ -365,7 +365,7 @@ class Kakuro : public Script { } /// Post a distinct-linear constraint on variables \a x with sum \a c void - distinctlinear(Cache& dc, const IntVarArgs& x, int c, const SizeOptions& opt) { + distinct_linear(Cache& dc, const IntVarArgs& x, int c, const SizeOptions& opt) { int n = x.size(); if (opt.model() == MODEL_DECOMPOSE) { if (n < 8) @@ -436,7 +436,7 @@ class Kakuro : public Script { IntVarArgs col(n); for (int i = n; i--;) col[i] = init(b(x, y + i + 1)); - distinctlinear(cache, col, s, opt); + distinct_linear(cache, col, s, opt); } k++; @@ -449,7 +449,7 @@ class Kakuro : public Script { IntVarArgs row(n); for (int i = n; i--;) row[i] = init(b(x + i + 1, y)); - distinctlinear(cache, row, s, opt); + distinct_linear(cache, row, s, opt); } branch(*this, f, INT_VAR_AFC_SIZE_MAX(opt.decay()), INT_VAL_SPLIT_MIN()); } @@ -458,13 +458,13 @@ class Kakuro : public Script { f.update(*this, s.f); } /// Perform copying during cloning - virtual Space* - copy(void) { + Space* + copy(void) override { return new Kakuro(*this); } /// Print solution - virtual void - print(std::ostream& os) const { + void + print(std::ostream& os) const override { Matrix b(f, w, h); for (int y = 0; y < h; y++) { os << '\t'; diff --git a/examples/knights.cpp b/examples/knights.cpp index 425e59585f..35f5cd5aad 100644 --- a/examples/knights.cpp +++ b/examples/knights.cpp @@ -71,8 +71,8 @@ class Warnsdorff : public Brancher { */ Choice(const Brancher& b, int pos0, int val0) : Gecode::Choice(b, 2), pos(pos0), val(val0) {} /// Archive into \a e - virtual void - archive(Archive& e) const { + void + archive(Archive& e) const override { Gecode::Choice::archive(e); e << pos << val; } @@ -87,8 +87,8 @@ class Warnsdorff : public Brancher { public: /// Check status of brancher, return true if alternatives left - virtual bool - status(const Space&) const { + bool + status(const Space&) const override { // A path to follow can be at most x.size() long for (int n = x.size(); n--;) { if (!x[start].assigned()) @@ -99,8 +99,8 @@ class Warnsdorff : public Brancher { return false; } /// Return choice - virtual Gecode::Choice* - choice(Space&) { + Gecode::Choice* + choice(Space&) override { Int::ViewValues iv(x[start]); int n = iv.val(); unsigned int min = x[n].size(); @@ -116,15 +116,15 @@ class Warnsdorff : public Brancher { return new Choice(*this, start, n); } /// Return choice - virtual Choice* - choice(const Space&, Archive& e) { + Choice* + choice(const Space&, Archive& e) override { int pos, val; e >> pos >> val; return new Choice(*this, pos, val); } /// Perform commit for choice \a _c and alternative \a a - virtual ExecStatus - commit(Space& home, const Gecode::Choice& _c, unsigned int a) { + ExecStatus + commit(Space& home, const Gecode::Choice& _c, unsigned int a) override { const Choice& c = static_cast(_c); if (a == 0) return me_failed(x[c.pos].eq(home, c.val)) ? ES_FAILED : ES_OK; @@ -132,14 +132,14 @@ class Warnsdorff : public Brancher { return me_failed(x[c.pos].nq(home, c.val)) ? ES_FAILED : ES_OK; } /// Print explanation - virtual void - print(const Space&, const Gecode::Choice& _c, unsigned int a, std::ostream& o) const { + void + print(const Space&, const Gecode::Choice& _c, unsigned int a, std::ostream& o) const override { const Choice& c = static_cast(_c); o << "x[" << c.pos << "] " << ((a == 0) ? "=" : "!=") << " " << c.val; } /// Copy brancher - virtual Actor* - copy(Space& home) { + Actor* + copy(Space& home) override { return new (home) Warnsdorff(home, *this); } /// Post brancher @@ -149,8 +149,8 @@ class Warnsdorff : public Brancher { (void)new (home) Warnsdorff(home, xv); } /// Delete brancher and return its size - virtual size_t - dispose(Space&) { + size_t + dispose(Space&) override { return sizeof(*this); } }; @@ -216,8 +216,8 @@ class Knights : public Script { succ.update(*this, s.succ); } /// Print board - virtual void - print(std::ostream& os) const { + void + print(std::ostream& os) const override { int* jump = new int[n * n]; { int j = 0; @@ -285,8 +285,8 @@ class KnightsReified : public Knights { /// Constructor for cloning \a s KnightsReified(KnightsReified& s) : Knights(s) {} /// Copy during cloning - virtual Space* - copy(void) { + Space* + copy(void) override { return new KnightsReified(*this); } }; @@ -315,8 +315,8 @@ class KnightsCircuit : public Knights { /// Constructor for cloning \a s KnightsCircuit(KnightsCircuit& s) : Knights(s) {} /// Copy during cloning - virtual Space* - copy(void) { + Space* + copy(void) override { return new KnightsCircuit(*this); } }; @@ -342,13 +342,14 @@ class KnightsInspector : public Gist::Inspector { /// Constructor KnightsInspector(void) : scene(nullptr), mw(nullptr) {} /// Inspect space \a s - virtual void - inspect(const Space& s) { + void + inspect(const Space& s) override { const Knights& k = static_cast(s); + const int half_unit = unit / 2; if (!scene) initialize(); - QList itemList = scene->items(); + QList item_list = scene->items(); foreach (QGraphicsItem* i, scene->items()) { scene->removeItem(i); delete i; @@ -367,8 +368,8 @@ class KnightsInspector : public Gist::Inspector { for (IntVarValues xv(k.succ[i * k.n + j]); xv(); ++xv) { int ky = xv.val() % k.n; int kx = xv.val() / k.n; - scene->addLine(i * unit + unit / 2, j * unit + unit / 2, kx * unit + unit / 2, ky * unit + unit / 2, - pen); + scene->addLine(i * unit + half_unit, j * unit + half_unit, kx * unit + half_unit, + ky * unit + half_unit, pen); } } } @@ -385,20 +386,20 @@ class KnightsInspector : public Gist::Inspector { mw->setCentralWidget(view); mw->setAttribute(Qt::WA_QuitOnClose, false); mw->setAttribute(Qt::WA_DeleteOnClose, false); - QAction* closeWindow = new QAction("Close window", mw); - closeWindow->setShortcut(QKeySequence("Ctrl+W")); - mw->connect(closeWindow, SIGNAL(triggered()), mw, SLOT(close())); - mw->addAction(closeWindow); + QAction* close_window = new QAction("Close window", mw); + close_window->setShortcut(QKeySequence("Ctrl+W")); + mw->connect(close_window, SIGNAL(triggered()), mw, SLOT(close())); + mw->addAction(close_window); } /// Name of the inspector - virtual std::string - name(void) { + std::string + name(void) override { return "Board"; } /// Finalize inspector - virtual void - finalize(void) { + void + finalize(void) override { delete mw; mw = nullptr; } diff --git a/examples/langford-number.cpp b/examples/langford-number.cpp index c481f7a631..68bd57e1ca 100644 --- a/examples/langford-number.cpp +++ b/examples/langford-number.cpp @@ -60,8 +60,8 @@ class LangfordNumberOptions : public Options { k = atoi(argv[2]); } /// Print help message - virtual void - help(void) { + void + help(void) override { Options::help(); std::cerr << "\t(unsigned int) default: " << n << std::endl << "\t\tparameter n" << std::endl @@ -157,8 +157,8 @@ class LangfordNumber : public Script { } /// Print solution - virtual void - print(std::ostream& os) const { + void + print(std::ostream& os) const override { os << "\t" << y << std::endl; } @@ -167,8 +167,8 @@ class LangfordNumber : public Script { y.update(*this, l.y); } /// Copy during cloning - virtual Space* - copy(void) { + Space* + copy(void) override { return new LangfordNumber(*this); } }; diff --git a/examples/magic-sequence.cpp b/examples/magic-sequence.cpp index a29f7b63f9..5a0196e4c8 100644 --- a/examples/magic-sequence.cpp +++ b/examples/magic-sequence.cpp @@ -89,13 +89,13 @@ class MagicSequence : public Script { s.update(*this, e.s); } /// Copy during cloning - virtual Space* - copy(void) { + Space* + copy(void) override { return new MagicSequence(*this); } /// Print sequence - virtual void - print(std::ostream& os) const { + void + print(std::ostream& os) const override { os << "\t"; for (int i = 0; i < n; i++) { os << s[i] << ", "; diff --git a/examples/magic-square-partial.cpp b/examples/magic-square-partial.cpp index 496cd88908..0fa36ca148 100644 --- a/examples/magic-square-partial.cpp +++ b/examples/magic-square-partial.cpp @@ -120,7 +120,7 @@ class MagicSquare : public Script { switch (opt.branching()) { case BRANCH_CBS_MAX_SD: #ifdef GECODE_HAS_CBS - cbsbranch(*this, x); + cbs_branch(*this, x); #endif case BRANCH_SIZE: branch(*this, x, INT_VAR_SIZE_MIN(), INT_VAL_SPLIT_MIN()); @@ -137,13 +137,13 @@ class MagicSquare : public Script { } /// Copy during cloning - virtual Space* - copy(void) { + Space* + copy(void) override { return new MagicSquare(*this); } /// Print solution - virtual void - print(std::ostream& os) const { + void + print(std::ostream& os) const override { // Matrix-wrapper for the square Matrix m(x, n, n); for (int i = 0; i < n; i++) { @@ -189,231 +189,231 @@ namespace { * \relates Magic-square */ //@{ - const int magicSquare5_filled10_10[] = { + const int magic_square5_filled10_10[] = { 5, 10, 1, 2, 18, 1, 3, 9, 1, 5, 2, 2, 2, 5, 3, 1, 1, 3, 5, 24, 4, 2, 21, 4, 3, 6, 5, 2, 13, 5, 4, 10, }; - const int magicSquare5_filled10_11[] = { + const int magic_square5_filled10_11[] = { 5, 10, 1, 3, 6, 1, 5, 2, 2, 2, 8, 2, 5, 25, 3, 1, 1, 3, 4, 17, 3, 5, 24, 4, 1, 9, 4, 2, 21, 5, 3, 16, }; - const int magicSquare5_filled10_12[] = { + const int magic_square5_filled10_12[] = { 5, 10, 1, 2, 5, 1, 4, 21, 2, 1, 10, 2, 2, 16, 2, 3, 8, 3, 4, 12, 4, 2, 20, 4, 5, 11, 5, 1, 18, 5, 5, 3, }; - const int magicSquare5_filled10_13[] = { + const int magic_square5_filled10_13[] = { 5, 10, 1, 5, 2, 1, 2, 16, 2, 3, 8, 3, 3, 21, 3, 1, 1, 4, 1, 12, 5, 2, 6, 5, 1, 20, 5, 3, 14, 5, 5, 3, }; - const int magicSquare5_filled10_14[] = { + const int magic_square5_filled10_14[] = { 5, 10, 1, 3, 14, 1, 2, 7, 2, 3, 12, 2, 4, 4, 3, 3, 21, 3, 5, 24, 4, 5, 11, 4, 4, 6, 4, 3, 13, 5, 4, 22, }; - const int magicSquare5_filled10_15[] = { + const int magic_square5_filled10_15[] = { 5, 10, 1, 5, 2, 1, 1, 21, 2, 1, 15, 2, 2, 5, 4, 2, 18, 4, 5, 11, 5, 4, 20, 5, 5, 3, 5, 2, 12, 5, 3, 8, }; - const int magicSquare5_filled10_16[] = { + const int magic_square5_filled10_16[] = { 5, 10, 1, 1, 22, 1, 5, 2, 1, 4, 18, 2, 5, 25, 2, 4, 7, 3, 4, 15, 3, 1, 1, 3, 2, 9, 4, 4, 4, 5, 1, 23, }; - const int magicSquare5_filled10_17[] = { + const int magic_square5_filled10_17[] = { 5, 10, 1, 2, 5, 2, 4, 4, 2, 5, 25, 3, 4, 16, 3, 5, 24, 3, 3, 14, 3, 1, 1, 4, 2, 22, 5, 3, 13, 5, 4, 7, }; - const int magicSquare5_filled10_18[] = { + const int magic_square5_filled10_18[] = { 5, 10, 1, 3, 7, 1, 4, 22, 2, 5, 25, 2, 4, 4, 2, 1, 10, 3, 1, 1, 4, 4, 6, 4, 3, 20, 5, 3, 8, 5, 2, 12, }; - const int magicSquare5_filled10_19[] = { + const int magic_square5_filled10_19[] = { 5, 10, 1, 2, 6, 1, 5, 2, 2, 2, 18, 2, 1, 13, 3, 5, 24, 3, 3, 17, 5, 2, 7, 5, 1, 22, 5, 4, 21, 5, 3, 12, }; - const int magicSquare5_filled10_1[] = { + const int magic_square5_filled10_1[] = { 5, 10, 1, 4, 16, 1, 5, 2, 1, 3, 20, 2, 5, 25, 2, 4, 4, 3, 5, 24, 3, 1, 1, 4, 4, 9, 5, 2, 12, 5, 1, 23, }; - const int magicSquare5_filled10_20[] = { + const int magic_square5_filled10_20[] = { 5, 10, 1, 1, 22, 2, 5, 25, 2, 2, 5, 3, 5, 24, 3, 1, 1, 4, 4, 19, 4, 5, 11, 5, 1, 23, 5, 2, 8, 5, 3, 10, }; - const int magicSquare5_filled10_2[] = { + const int magic_square5_filled10_2[] = { 5, 10, 1, 2, 19, 1, 4, 9, 2, 5, 25, 2, 1, 15, 3, 2, 6, 4, 2, 20, 4, 1, 5, 5, 5, 3, 5, 3, 10, 5, 1, 23, }; - const int magicSquare5_filled10_3[] = { + const int magic_square5_filled10_3[] = { 5, 10, 1, 1, 15, 1, 5, 2, 2, 1, 20, 2, 3, 7, 3, 4, 5, 4, 1, 6, 4, 4, 16, 5, 1, 23, 5, 2, 12, 5, 3, 8, }; - const int magicSquare5_filled10_4[] = { + const int magic_square5_filled10_4[] = { 5, 10, 1, 2, 15, 1, 5, 2, 1, 1, 22, 1, 4, 16, 2, 5, 25, 3, 5, 24, 3, 1, 1, 4, 1, 23, 4, 2, 18, 4, 3, 9, }; - const int magicSquare5_filled10_5[] = { + const int magic_square5_filled10_5[] = { 5, 10, 1, 1, 14, 1, 4, 21, 2, 2, 12, 2, 5, 25, 3, 2, 5, 3, 3, 19, 3, 5, 24, 4, 2, 18, 5, 1, 22, 5, 2, 10, }; - const int magicSquare5_filled10_6[] = { + const int magic_square5_filled10_6[] = { 5, 10, 1, 1, 19, 1, 2, 20, 2, 1, 7, 3, 3, 23, 4, 5, 11, 4, 4, 4, 5, 3, 13, 5, 5, 3, 5, 4, 22, 5, 2, 10, }; - const int magicSquare5_filled10_7[] = { + const int magic_square5_filled10_7[] = { 5, 10, 1, 2, 10, 2, 4, 4, 3, 5, 24, 3, 4, 17, 4, 5, 11, 4, 2, 23, 4, 4, 5, 4, 1, 14, 5, 2, 6, 5, 5, 3, }; - const int magicSquare5_filled10_8[] = { + const int magic_square5_filled10_8[] = { 5, 10, 1, 1, 22, 1, 3, 5, 2, 5, 25, 2, 4, 4, 3, 5, 24, 3, 2, 8, 4, 1, 10, 4, 2, 21, 4, 3, 16, 4, 5, 11, }; - const int magicSquare5_filled10_9[] = { + const int magic_square5_filled10_9[] = { 5, 10, 1, 5, 2, 2, 2, 10, 2, 5, 25, 3, 3, 23, 3, 1, 1, 4, 2, 15, 4, 4, 13, 4, 3, 6, 5, 5, 3, 5, 3, 5, }; - const int magicSquare5_filled11_3_1[] = { + const int magic_square5_filled11_3_1[] = { 5, 11, 1, 1, 15, 1, 5, 2, 2, 1, 20, 2, 3, 7, 3, 2, 13, 3, 4, 5, 4, 1, 6, 4, 4, 16, 5, 1, 23, 5, 2, 12, 5, 3, 8, }; - const int magicSquare5_filled11_5_1[] = { + const int magic_square5_filled11_5_1[] = { 5, 11, 1, 1, 14, 1, 4, 21, 2, 2, 12, 2, 5, 25, 3, 2, 5, 3, 3, 19, 3, 4, 16, 3, 5, 24, 4, 2, 18, 5, 1, 22, 5, 2, 10, }; - const int magicSquare5_filled11_5_2[] = { + const int magic_square5_filled11_5_2[] = { 5, 11, 1, 1, 14, 1, 4, 21, 2, 2, 12, 2, 5, 25, 3, 2, 5, 3, 3, 19, 3, 5, 24, 4, 2, 18, 5, 1, 22, 5, 2, 10, 5, 5, 3, }; - const int magicSquare5_filled11_5_3[] = { + const int magic_square5_filled11_5_3[] = { 5, 11, 1, 1, 14, 1, 3, 8, 1, 4, 21, 2, 2, 12, 2, 5, 25, 3, 2, 5, 3, 3, 19, 3, 5, 24, 4, 2, 18, 5, 1, 22, 5, 2, 10, }; - const int magicSquare5_filled12_10_1[] = { + const int magic_square5_filled12_10_1[] = { 5, 12, 1, 2, 18, 1, 3, 9, 1, 5, 2, 2, 2, 5, 3, 1, 1, 3, 3, 15, 3, 5, 24, 4, 1, 7, 4, 2, 21, 4, 3, 6, 5, 2, 13, 5, 4, 10, }; - const int magicSquare5_filled12_1_1[] = { + const int magic_square5_filled12_1_1[] = { 5, 12, 1, 1, 21, 1, 3, 20, 1, 4, 16, 1, 5, 2, 2, 5, 25, 2, 4, 4, 3, 1, 1, 3, 3, 14, 3, 5, 24, 4, 4, 9, 5, 2, 12, 5, 1, 23, }; - const int magicSquare5_filled12_1_2[] = { + const int magic_square5_filled12_1_2[] = { 5, 12, 1, 3, 20, 1, 4, 16, 1, 5, 2, 2, 2, 18, 2, 4, 4, 2, 5, 25, 3, 1, 1, 3, 3, 14, 3, 5, 24, 4, 4, 9, 5, 2, 12, 5, 1, 23, }; - const int magicSquare5_filled12_1_3[] = { + const int magic_square5_filled12_1_3[] = { 5, 12, 1, 3, 20, 1, 4, 16, 1, 5, 2, 2, 2, 18, 2, 4, 4, 2, 5, 25, 3, 1, 1, 3, 5, 24, 4, 4, 9, 5, 1, 23, 5, 2, 12, 5, 3, 10, }; - const int magicSquare5_filled12_2_1[] = { + const int magic_square5_filled12_2_1[] = { 5, 12, 1, 1, 21, 1, 2, 19, 1, 4, 9, 2, 1, 15, 2, 5, 25, 3, 2, 6, 3, 4, 18, 4, 1, 5, 4, 2, 20, 5, 1, 23, 5, 3, 10, 5, 5, 3, }; - const int magicSquare5_filled12_2_2[] = { + const int magic_square5_filled12_2_2[] = { 5, 12, 1, 2, 19, 1, 4, 9, 2, 1, 15, 2, 3, 8, 2, 5, 25, 3, 2, 6, 3, 4, 18, 4, 1, 5, 4, 2, 20, 5, 1, 23, 5, 3, 10, 5, 5, 3, }; - const int magicSquare5_filled12_2_3[] = { + const int magic_square5_filled12_2_3[] = { 5, 12, 1, 1, 21, 1, 2, 19, 1, 4, 9, 2, 1, 15, 2, 5, 25, 3, 2, 6, 4, 1, 5, 4, 2, 20, 4, 4, 12, 5, 1, 23, 5, 3, 10, 5, 5, 3, }; - const int magicSquare5_filled12_3_1[] = { + const int magic_square5_filled12_3_1[] = { 5, 12, 1, 1, 15, 1, 4, 21, 1, 5, 2, 2, 1, 20, 2, 3, 7, 3, 4, 5, 4, 1, 6, 4, 4, 16, 5, 1, 23, 5, 2, 12, 5, 3, 8, 5, 5, 3, }; - const int magicSquare5_filled12_3_2[] = { + const int magic_square5_filled12_3_2[] = { 5, 12, 1, 1, 15, 1, 2, 17, 1, 3, 10, 1, 5, 2, 2, 1, 20, 2, 3, 7, 3, 4, 5, 4, 1, 6, 4, 4, 16, 5, 1, 23, 5, 2, 12, 5, 3, 8, }; - const int magicSquare9_filled10_10[] = { + const int magic_square9_filled10_10[] = { 9, 10, 8, 2, 19, 6, 7, 25, 7, 3, 15, 8, 4, 77, 7, 1, 29, 4, 9, 63, 4, 6, 53, 7, 1, 29, 3, 9, 36, 5, 4, 74, }; - const int magicSquare9_filled10_11[] = { + const int magic_square9_filled10_11[] = { 9, 10, 5, 5, 78, 6, 5, 56, 9, 8, 30, 3, 3, 38, 2, 3, 9, 1, 2, 23, 3, 5, 80, 9, 7, 52, 7, 5, 1, 1, 1, 32, }; - const int magicSquare9_filled10_12[] = { + const int magic_square9_filled10_12[] = { 9, 10, 6, 7, 25, 1, 4, 2, 5, 1, 54, 3, 3, 38, 7, 2, 71, 1, 5, 28, 3, 2, 50, 2, 7, 59, 7, 7, 42, 5, 4, 74, }; - const int magicSquare9_filled10_13[] = { + const int magic_square9_filled10_13[] = { 9, 10, 7, 2, 71, 8, 9, 22, 2, 2, 17, 3, 3, 38, 1, 8, 72, 6, 5, 56, 5, 6, 41, 9, 1, 8, 7, 8, 37, 3, 3, 38, }; - const int magicSquare9_filled10_14[] = { + const int magic_square9_filled10_14[] = { 9, 10, 9, 4, 35, 1, 3, 48, 9, 6, 69, 7, 6, 70, 6, 1, 46, 5, 1, 54, 4, 2, 62, 2, 8, 67, 7, 6, 70, 7, 3, 15, }; - const int magicSquare9_filled10_15[] = { + const int magic_square9_filled10_15[] = { 9, 10, 9, 8, 30, 1, 6, 4, 9, 9, 45, 9, 2, 49, 5, 6, 41, 6, 5, 56, 5, 9, 7, 2, 6, 3, 3, 2, 50, 1, 2, 23, }; - const int magicSquare9_filled10_16[] = { + const int magic_square9_filled10_16[] = { 9, 10, 1, 9, 81, 3, 8, 18, 8, 4, 77, 6, 5, 56, 7, 9, 31, 1, 9, 81, 7, 3, 15, 6, 4, 5, 6, 8, 61, 4, 6, 53, }; - const int magicSquare9_filled10_17[] = { + const int magic_square9_filled10_17[] = { 9, 10, 4, 4, 12, 9, 5, 26, 7, 6, 70, 8, 2, 19, 7, 2, 71, 8, 1, 68, 8, 2, 19, 5, 5, 78, 6, 3, 21, 5, 3, 75, }; - const int magicSquare9_filled10_18[] = { + const int magic_square9_filled10_18[] = { 9, 10, 7, 2, 71, 4, 1, 47, 6, 9, 24, 8, 8, 39, 3, 9, 36, 2, 9, 60, 4, 3, 64, 5, 8, 11, 4, 2, 62, 3, 7, 43, }; - const int magicSquare9_filled10_19[] = { + const int magic_square9_filled10_19[] = { 9, 10, 7, 4, 73, 8, 3, 44, 8, 1, 68, 1, 2, 23, 1, 6, 4, 5, 7, 16, 3, 6, 6, 8, 2, 19, 4, 5, 14, 3, 3, 38, }; - const int magicSquare9_filled10_1[] = { + const int magic_square9_filled10_1[] = { 9, 10, 4, 5, 14, 6, 7, 25, 8, 8, 39, 6, 7, 25, 3, 8, 18, 4, 4, 12, 8, 2, 19, 4, 1, 47, 4, 6, 53, 8, 5, 10, }; - const int magicSquare9_filled10_20[] = { + const int magic_square9_filled10_20[] = { 9, 10, 1, 4, 2, 8, 6, 57, 1, 5, 28, 1, 8, 72, 6, 1, 46, 4, 1, 47, 8, 7, 33, 4, 6, 53, 1, 5, 28, 5, 8, 11, }; - const int magicSquare9_filled10_2[] = { + const int magic_square9_filled10_2[] = { 9, 10, 2, 5, 76, 9, 1, 8, 2, 4, 51, 1, 2, 23, 9, 7, 52, 1, 8, 72, 3, 3, 38, 6, 6, 66, 3, 7, 43, 7, 6, 70, }; - const int magicSquare9_filled10_3[] = { + const int magic_square9_filled10_3[] = { 9, 10, 5, 6, 41, 5, 3, 75, 6, 1, 46, 3, 2, 50, 3, 8, 18, 1, 5, 28, 3, 2, 50, 5, 9, 7, 4, 8, 34, 1, 4, 2, }; - const int magicSquare9_filled10_4[] = { + const int magic_square9_filled10_4[] = { 9, 10, 4, 9, 63, 9, 4, 35, 7, 5, 1, 2, 6, 3, 8, 4, 77, 7, 6, 70, 5, 8, 11, 2, 5, 76, 9, 4, 35, 3, 6, 6, }; - const int magicSquare9_filled10_5[] = { + const int magic_square9_filled10_5[] = { 9, 10, 2, 5, 76, 1, 4, 2, 9, 3, 55, 1, 2, 23, 3, 3, 38, 2, 5, 76, 3, 4, 40, 3, 4, 40, 1, 2, 23, 3, 6, 6, }; - const int magicSquare9_filled10_6[] = { + const int magic_square9_filled10_6[] = { 9, 10, 7, 5, 1, 4, 7, 20, 8, 7, 33, 5, 5, 78, 5, 2, 13, 3, 1, 58, 1, 9, 81, 5, 1, 54, 3, 1, 58, 7, 5, 1, }; - const int magicSquare9_filled10_7[] = { + const int magic_square9_filled10_7[] = { 9, 10, 7, 5, 1, 7, 5, 1, 1, 5, 28, 4, 8, 34, 4, 1, 47, 4, 2, 62, 2, 6, 3, 2, 8, 67, 1, 9, 81, 5, 4, 74, }; - const int magicSquare9_filled10_8[] = { + const int magic_square9_filled10_8[] = { 9, 10, 9, 4, 35, 4, 9, 63, 1, 6, 4, 5, 5, 78, 7, 5, 1, 9, 4, 35, 5, 6, 41, 6, 3, 21, 9, 3, 55, 3, 5, 80, }; - const int magicSquare9_filled10_9[] = { + const int magic_square9_filled10_9[] = { 9, 10, 4, 8, 34, 4, 1, 47, 3, 9, 36, 8, 6, 57, 9, 2, 49, 9, 9, 45, 1, 6, 4, 4, 6, 53, 3, 6, 6, 2, 2, 17, }; - const int magicSquare9_filled50_10[] = { + const int magic_square9_filled50_10[] = { 9, 50, 4, 3, 64, 3, 9, 36, 8, 3, 44, 6, 9, 24, 2, 7, 59, 7, 2, 71, 8, 2, 19, 2, 8, 67, 6, 7, 25, 6, 6, 66, 3, 8, 18, 1, 9, 81, 8, 4, 77, 5, 4, 74, 8, 2, 19, 6, 9, 24, 4, 9, 63, 9, 3, 55, 2, 5, 76, 9, 2, 49, 3, 7, 43, 3, 8, 18, 6, 3, 21, 6, 2, 65, 9, 2, 49, 7, 9, 31, 8, 6, 57, 8, 6, 57, 9, 3, 55, 7, 5, 1, 2, 4, 51, 5, 4, 74, 3, @@ -421,7 +421,7 @@ namespace { 3, 15, 9, 5, 26, 7, 1, 29, 6, 9, 24, 2, 6, 3, 3, 5, 80, 7, 9, 31, }; - const int magicSquare9_filled50_11[] = { + const int magic_square9_filled50_11[] = { 9, 50, 6, 8, 61, 3, 3, 38, 9, 7, 52, 6, 3, 21, 4, 9, 63, 3, 9, 36, 7, 3, 15, 1, 1, 32, 2, 7, 59, 1, 8, 72, 2, 5, 76, 8, 7, 33, 5, 1, 54, 3, 5, 80, 3, 8, 18, 4, 8, 34, 4, 5, 14, 2, 3, 9, 9, 5, 26, 3, 3, 38, 2, 5, 76, 9, 8, 30, 8, 9, 22, 6, 7, 25, 7, 6, 70, 5, 6, 41, 2, 1, 27, 4, 4, 12, 8, 4, 77, 8, 2, 19, 9, 1, 8, 7, 3, 15, 5, @@ -429,7 +429,7 @@ namespace { 2, 49, 7, 7, 42, 1, 6, 4, 7, 7, 42, 7, 2, 71, 4, 7, 20, 4, 3, 64, }; - const int magicSquare9_filled50_12[] = { + const int magic_square9_filled50_12[] = { 9, 50, 1, 3, 48, 3, 5, 80, 4, 5, 14, 6, 1, 46, 8, 8, 39, 2, 8, 67, 8, 8, 39, 9, 2, 49, 2, 2, 17, 6, 1, 46, 9, 9, 45, 8, 9, 22, 3, 4, 40, 2, 3, 9, 4, 6, 53, 5, 3, 75, 6, 6, 66, 7, 1, 29, 8, 1, 68, 1, 7, 79, 7, 9, 31, 5, 3, 75, 6, 4, 5, 5, 7, 16, 3, 1, 58, 5, 3, 75, 7, 4, 73, 9, 8, 30, 5, 8, 11, 1, 7, 79, 4, 4, 12, 9, 8, 30, 7, @@ -437,7 +437,7 @@ namespace { 9, 7, 5, 5, 78, 6, 7, 25, 6, 5, 56, 3, 3, 38, 8, 8, 39, 8, 1, 68, }; - const int magicSquare9_filled50_13[] = { + const int magic_square9_filled50_13[] = { 9, 50, 2, 7, 59, 6, 2, 65, 9, 5, 26, 6, 5, 56, 8, 6, 57, 1, 1, 32, 9, 9, 45, 7, 6, 70, 4, 2, 62, 4, 9, 63, 4, 9, 63, 4, 8, 34, 3, 6, 6, 1, 1, 32, 2, 6, 3, 8, 3, 44, 2, 3, 9, 2, 1, 27, 7, 7, 42, 3, 6, 6, 2, 3, 9, 4, 1, 47, 2, 1, 27, 5, 4, 74, 9, 8, 30, 3, 1, 58, 7, 4, 73, 6, 9, 24, 7, 5, 1, 8, 8, 39, 1, 4, 2, 1, 9, 81, 6, @@ -445,7 +445,7 @@ namespace { 3, 44, 2, 4, 51, 1, 9, 81, 8, 8, 39, 9, 2, 49, 6, 6, 66, 3, 1, 58, }; - const int magicSquare9_filled50_14[] = { + const int magic_square9_filled50_14[] = { 9, 50, 1, 4, 2, 6, 7, 25, 3, 2, 50, 6, 6, 66, 2, 8, 67, 5, 1, 54, 2, 6, 3, 7, 7, 42, 6, 2, 65, 2, 8, 67, 8, 3, 44, 2, 9, 60, 4, 5, 14, 9, 5, 26, 4, 1, 47, 5, 2, 13, 4, 9, 63, 6, 5, 56, 1, 9, 81, 1, 2, 23, 8, 4, 77, 1, 9, 81, 9, 7, 52, 5, 3, 75, 8, 6, 57, 1, 7, 79, 8, 9, 22, 4, 9, 63, 5, 1, 54, 3, 6, 6, 1, 7, 79, 5, 3, 75, 6, @@ -453,7 +453,7 @@ namespace { 6, 4, 7, 3, 15, 2, 6, 3, 1, 6, 4, 6, 4, 5, 5, 1, 54, 8, 4, 77, }; - const int magicSquare9_filled50_15[] = { + const int magic_square9_filled50_15[] = { 9, 50, 1, 4, 2, 2, 7, 59, 7, 5, 1, 7, 7, 42, 5, 3, 75, 5, 1, 54, 7, 8, 37, 2, 8, 67, 3, 3, 38, 4, 9, 63, 3, 3, 38, 3, 1, 58, 6, 8, 61, 5, 2, 13, 6, 1, 46, 5, 5, 78, 4, 4, 12, 2, 8, 67, 9, 8, 30, 5, 2, 13, 9, 7, 52, 3, 4, 40, 5, 2, 13, 9, 7, 52, 2, 3, 9, 5, 5, 78, 3, 5, 80, 5, 8, 11, 2, 7, 59, 9, 7, 52, 7, 2, 71, 9, 8, 30, 4, @@ -461,7 +461,7 @@ namespace { 4, 12, 5, 4, 74, 9, 1, 8, 3, 8, 18, 8, 4, 77, 7, 3, 15, 4, 2, 62, }; - const int magicSquare9_filled50_16[] = { + const int magic_square9_filled50_16[] = { 9, 50, 1, 4, 2, 3, 6, 6, 3, 7, 43, 5, 4, 74, 1, 8, 72, 5, 6, 41, 4, 7, 20, 2, 6, 3, 3, 5, 80, 8, 8, 39, 6, 5, 56, 6, 7, 25, 3, 4, 40, 1, 7, 79, 4, 3, 64, 8, 5, 10, 4, 8, 34, 8, 6, 57, 5, 3, 75, 8, 5, 10, 8, 1, 68, 8, 2, 19, 5, 9, 7, 8, 8, 39, 3, 4, 40, 4, 6, 53, 8, 9, 22, 3, 8, 18, 1, 2, 23, 6, 5, 56, 4, 2, 62, 9, 7, 52, 1, @@ -469,7 +469,7 @@ namespace { 9, 81, 4, 4, 12, 4, 5, 14, 6, 3, 21, 2, 4, 51, 8, 9, 22, 8, 6, 57, }; - const int magicSquare9_filled50_17[] = { + const int magic_square9_filled50_17[] = { 9, 50, 8, 6, 57, 9, 2, 49, 3, 5, 80, 3, 6, 6, 8, 2, 19, 9, 1, 8, 2, 1, 27, 3, 1, 58, 1, 2, 23, 1, 2, 23, 5, 2, 13, 6, 8, 61, 5, 5, 78, 2, 1, 27, 5, 8, 11, 4, 1, 47, 4, 3, 64, 2, 4, 51, 8, 3, 44, 9, 4, 35, 2, 8, 67, 5, 4, 74, 7, 5, 1, 2, 7, 59, 6, 2, 65, 9, 9, 45, 4, 3, 64, 7, 6, 70, 8, 9, 22, 4, 3, 64, 7, 7, 42, 1, 1, 32, 7, @@ -477,7 +477,7 @@ namespace { 3, 38, 1, 6, 4, 5, 5, 78, 1, 3, 48, 4, 7, 20, 2, 6, 3, 8, 4, 77, }; - const int magicSquare9_filled50_18[] = { + const int magic_square9_filled50_18[] = { 9, 50, 5, 3, 75, 7, 1, 29, 9, 4, 35, 3, 8, 18, 9, 1, 8, 4, 5, 14, 2, 6, 3, 2, 8, 67, 8, 4, 77, 1, 6, 4, 7, 3, 15, 2, 5, 76, 5, 5, 78, 3, 7, 43, 1, 8, 72, 8, 5, 10, 1, 5, 28, 6, 7, 25, 6, 6, 66, 5, 3, 75, 6, 7, 25, 8, 8, 39, 3, 9, 36, 4, 1, 47, 2, 3, 9, 7, 8, 37, 5, 6, 41, 4, 8, 34, 1, 4, 2, 3, 8, 18, 9, 1, 8, 3, 9, 36, 5, @@ -485,7 +485,7 @@ namespace { 6, 66, 5, 6, 41, 4, 2, 62, 6, 5, 56, 1, 8, 72, 8, 4, 77, 4, 8, 34, }; - const int magicSquare9_filled50_19[] = { + const int magic_square9_filled50_19[] = { 9, 50, 1, 5, 28, 3, 5, 80, 1, 2, 23, 1, 4, 2, 5, 7, 16, 8, 8, 39, 5, 9, 7, 7, 2, 71, 1, 1, 32, 5, 4, 74, 7, 9, 31, 5, 1, 54, 2, 4, 51, 7, 9, 31, 7, 1, 29, 6, 5, 56, 3, 8, 18, 1, 4, 2, 9, 8, 30, 7, 3, 15, 3, 4, 40, 1, 8, 72, 3, 5, 80, 9, 3, 55, 6, 4, 5, 6, 1, 46, 1, 9, 81, 1, 2, 23, 3, 5, 80, 9, 7, 52, 4, 5, 14, 3, 6, 6, 1, @@ -493,7 +493,7 @@ namespace { 2, 71, 2, 4, 51, 8, 5, 10, 6, 1, 46, 2, 6, 3, 1, 6, 4, 4, 7, 20, }; - const int magicSquare9_filled50_1[] = { + const int magic_square9_filled50_1[] = { 9, 50, 7, 1, 29, 2, 9, 60, 2, 4, 51, 1, 8, 72, 8, 5, 10, 4, 6, 53, 3, 4, 40, 6, 2, 65, 8, 2, 19, 3, 6, 6, 6, 2, 65, 2, 8, 67, 2, 5, 76, 8, 9, 22, 6, 2, 65, 6, 1, 46, 2, 8, 67, 1, 4, 2, 9, 8, 30, 2, 5, 76, 3, 3, 38, 1, 3, 48, 4, 6, 53, 5, 1, 54, 7, 5, 1, 6, 1, 46, 4, 6, 53, 6, 5, 56, 1, 5, 28, 3, 6, 6, 4, 8, 34, 7, 6, 70, 4, @@ -501,7 +501,7 @@ namespace { 8, 30, 4, 2, 62, 3, 8, 18, 8, 7, 33, 4, 2, 62, 9, 8, 30, 5, 9, 7, }; - const int magicSquare9_filled50_20[] = { + const int magic_square9_filled50_20[] = { 9, 50, 8, 3, 44, 8, 2, 19, 3, 5, 80, 7, 8, 37, 8, 4, 77, 6, 5, 56, 4, 5, 14, 1, 3, 48, 2, 6, 3, 4, 3, 64, 9, 9, 45, 6, 6, 66, 8, 5, 10, 2, 6, 3, 1, 5, 28, 3, 7, 43, 8, 8, 39, 8, 8, 39, 1, 4, 2, 4, 8, 34, 5, 8, 11, 2, 8, 67, 1, 2, 23, 1, 2, 23, 7, 2, 71, 2, 7, 59, 1, 7, 79, 1, 6, 4, 2, 9, 60, 3, 1, 58, 3, 3, 38, 7, 8, 37, 9, @@ -509,7 +509,7 @@ namespace { 1, 8, 7, 9, 31, 1, 9, 81, 3, 7, 43, 7, 2, 71, 8, 2, 19, 8, 2, 19, }; - const int magicSquare9_filled50_2[] = { + const int magic_square9_filled50_2[] = { 9, 50, 2, 1, 27, 8, 8, 39, 6, 3, 21, 7, 6, 70, 8, 5, 10, 2, 9, 60, 7, 7, 42, 4, 5, 14, 8, 1, 68, 2, 3, 9, 3, 2, 50, 8, 1, 68, 8, 9, 22, 9, 5, 26, 7, 2, 71, 2, 8, 67, 2, 1, 27, 5, 6, 41, 3, 2, 50, 9, 8, 30, 4, 1, 47, 7, 9, 31, 7, 1, 29, 4, 4, 12, 2, 3, 9, 4, 2, 62, 4, 9, 63, 9, 9, 45, 8, 8, 39, 2, 5, 76, 1, 4, 2, 1, 9, 81, 4, @@ -517,7 +517,7 @@ namespace { 7, 79, 1, 9, 81, 9, 8, 30, 3, 7, 43, 5, 4, 74, 3, 8, 18, 7, 4, 73, }; - const int magicSquare9_filled50_3[] = { + const int magic_square9_filled50_3[] = { 9, 50, 8, 7, 33, 9, 8, 30, 4, 4, 12, 4, 1, 47, 3, 3, 38, 5, 9, 7, 1, 9, 81, 9, 7, 52, 9, 7, 52, 2, 7, 59, 7, 1, 29, 5, 9, 7, 8, 7, 33, 2, 8, 67, 3, 6, 6, 2, 1, 27, 3, 9, 36, 9, 6, 69, 3, 3, 38, 5, 3, 75, 4, 9, 63, 2, 4, 51, 6, 2, 65, 2, 5, 76, 8, 1, 68, 9, 5, 26, 2, 2, 17, 3, 7, 43, 9, 2, 49, 3, 2, 50, 7, 2, 71, 3, 1, 58, 1, @@ -525,7 +525,7 @@ namespace { 4, 51, 9, 4, 35, 4, 6, 53, 4, 6, 53, 6, 4, 5, 5, 1, 54, 7, 6, 70, }; - const int magicSquare9_filled50_4[] = { + const int magic_square9_filled50_4[] = { 9, 50, 8, 2, 19, 2, 6, 3, 9, 8, 30, 5, 6, 41, 4, 8, 34, 8, 9, 22, 9, 6, 69, 5, 5, 78, 4, 6, 53, 6, 3, 21, 8, 7, 33, 7, 2, 71, 1, 3, 48, 3, 5, 80, 1, 8, 72, 9, 9, 45, 9, 8, 30, 3, 6, 6, 6, 7, 25, 9, 7, 52, 3, 5, 80, 6, 3, 21, 2, 1, 27, 5, 3, 75, 5, 8, 11, 4, 1, 47, 6, 1, 46, 9, 6, 69, 1, 2, 23, 9, 2, 49, 7, 8, 37, 1, 4, 2, 4, @@ -533,7 +533,7 @@ namespace { 3, 9, 8, 8, 39, 2, 4, 51, 4, 2, 62, 7, 7, 42, 2, 5, 76, 4, 8, 34, }; - const int magicSquare9_filled50_5[] = { + const int magic_square9_filled50_5[] = { 9, 50, 8, 7, 33, 7, 7, 42, 5, 7, 16, 5, 1, 54, 8, 6, 57, 1, 1, 32, 9, 8, 30, 4, 2, 62, 5, 6, 41, 2, 1, 27, 2, 3, 9, 4, 6, 53, 2, 9, 60, 3, 3, 38, 4, 5, 14, 1, 9, 81, 9, 5, 26, 7, 2, 71, 9, 2, 49, 2, 8, 67, 7, 9, 31, 6, 5, 56, 5, 1, 54, 4, 7, 20, 4, 5, 14, 8, 5, 10, 5, 9, 7, 1, 6, 4, 8, 2, 19, 8, 9, 22, 6, 6, 66, 9, 3, 55, 1, @@ -541,7 +541,7 @@ namespace { 7, 43, 9, 8, 30, 6, 3, 21, 4, 5, 14, 6, 2, 65, 1, 1, 32, 2, 6, 3, }; - const int magicSquare9_filled50_6[] = { + const int magic_square9_filled50_6[] = { 9, 50, 4, 7, 20, 6, 7, 25, 9, 1, 8, 4, 1, 47, 8, 7, 33, 4, 8, 34, 6, 4, 5, 5, 4, 74, 9, 5, 26, 1, 9, 81, 1, 7, 79, 9, 4, 35, 2, 5, 76, 5, 1, 54, 3, 5, 80, 4, 7, 20, 9, 7, 52, 2, 8, 67, 7, 3, 15, 7, 3, 15, 7, 1, 29, 1, 1, 32, 2, 3, 9, 5, 1, 54, 5, 5, 78, 7, 5, 1, 9, 5, 26, 6, 2, 65, 7, 8, 37, 9, 1, 8, 1, 1, 32, 5, 1, 54, 7, @@ -549,7 +549,7 @@ namespace { 5, 10, 9, 5, 26, 5, 1, 54, 5, 7, 16, 8, 2, 19, 1, 4, 2, 3, 3, 38, }; - const int magicSquare9_filled50_7[] = { + const int magic_square9_filled50_7[] = { 9, 50, 6, 3, 21, 7, 6, 70, 3, 4, 40, 5, 2, 13, 6, 6, 66, 7, 8, 37, 8, 6, 57, 8, 1, 68, 2, 9, 60, 4, 8, 34, 7, 3, 15, 2, 3, 9, 4, 3, 64, 2, 2, 17, 7, 2, 71, 3, 3, 38, 4, 9, 63, 8, 4, 77, 2, 4, 51, 3, 5, 80, 7, 1, 29, 3, 5, 80, 6, 1, 46, 4, 7, 20, 1, 5, 28, 3, 5, 80, 8, 4, 77, 7, 2, 71, 6, 8, 61, 3, 3, 38, 8, 4, 77, 3, 9, 36, 1, @@ -557,7 +557,7 @@ namespace { 2, 50, 2, 4, 51, 3, 7, 43, 5, 5, 78, 4, 5, 14, 4, 7, 20, 5, 4, 74, }; - const int magicSquare9_filled50_8[] = { + const int magic_square9_filled50_8[] = { 9, 50, 2, 8, 67, 1, 3, 48, 5, 8, 11, 3, 8, 18, 8, 6, 57, 1, 2, 23, 1, 8, 72, 3, 8, 18, 2, 4, 51, 7, 1, 29, 5, 9, 7, 5, 9, 7, 5, 8, 11, 4, 6, 53, 4, 8, 34, 1, 3, 48, 5, 8, 11, 5, 7, 16, 6, 5, 56, 5, 3, 75, 9, 4, 35, 4, 9, 63, 9, 5, 26, 5, 8, 11, 8, 2, 19, 6, 3, 21, 9, 1, 8, 2, 4, 51, 7, 3, 15, 9, 1, 8, 9, 7, 52, 1, 2, 23, 6, @@ -565,7 +565,7 @@ namespace { 2, 71, 5, 5, 78, 2, 2, 17, 2, 9, 60, 3, 7, 43, 2, 2, 17, 7, 9, 31, }; - const int magicSquare9_filled50_9[] = { + const int magic_square9_filled50_9[] = { 9, 50, 3, 8, 18, 6, 7, 25, 2, 9, 60, 8, 9, 22, 7, 8, 37, 3, 3, 38, 5, 6, 41, 8, 2, 19, 8, 4, 77, 3, 4, 40, 8, 2, 19, 5, 9, 7, 8, 8, 39, 5, 9, 7, 7, 9, 31, 9, 9, 45, 5, 5, 78, 4, 7, 20, 3, 9, 36, 4, 9, 63, 8, 5, 10, 9, 3, 55, 8, 6, 57, 2, 7, 59, 9, 2, 49, 1, 7, 79, 1, 3, 48, 4, 8, 34, 8, 6, 57, 7, 5, 1, 5, 6, 41, 2, 1, 27, 9, @@ -574,79 +574,79 @@ namespace { }; const int* specs[] = { - magicSquare5_filled10_1, // 0 - magicSquare5_filled10_2, // 1 - magicSquare5_filled10_3, // 2 - magicSquare5_filled10_4, // 3 - magicSquare5_filled10_5, // 4 - magicSquare5_filled10_6, // 5 - magicSquare5_filled10_7, // 6 - magicSquare5_filled10_8, // 7 - magicSquare5_filled10_9, // 8 - magicSquare5_filled10_10, // 9 - magicSquare5_filled10_11, // 10 - magicSquare5_filled10_12, // 11 - magicSquare5_filled10_13, // 12 - magicSquare5_filled10_14, // 13 - magicSquare5_filled10_15, // 14 - magicSquare5_filled10_16, // 15 - magicSquare5_filled10_17, // 16 - magicSquare5_filled10_18, // 17 - magicSquare5_filled10_19, // 18 - magicSquare5_filled10_20, // 19 - magicSquare5_filled11_3_1, // 20 - magicSquare5_filled11_5_1, // 21 - magicSquare5_filled11_5_2, // 22 - magicSquare5_filled11_5_3, // 23 - magicSquare5_filled12_10_1, // 24 - magicSquare5_filled12_1_1, // 25 - magicSquare5_filled12_1_2, // 26 - magicSquare5_filled12_1_3, // 27 - magicSquare5_filled12_2_1, // 28 - magicSquare5_filled12_2_2, // 29 - magicSquare5_filled12_2_3, // 30 - magicSquare5_filled12_3_1, // 31 - magicSquare5_filled12_3_2, // 32 - magicSquare9_filled10_1, // 33 - magicSquare9_filled10_2, // 34 - magicSquare9_filled10_3, // 35 - magicSquare9_filled10_4, // 36 - magicSquare9_filled10_5, // 37 - magicSquare9_filled10_6, // 38 - magicSquare9_filled10_7, // 39 - magicSquare9_filled10_8, // 40 - magicSquare9_filled10_9, // 41 - magicSquare9_filled10_10, // 42 - magicSquare9_filled10_11, // 43 - magicSquare9_filled10_12, // 44 - magicSquare9_filled10_13, // 45 - magicSquare9_filled10_14, // 46 - magicSquare9_filled10_15, // 47 - magicSquare9_filled10_16, // 48 - magicSquare9_filled10_17, // 49 - magicSquare9_filled10_18, // 50 - magicSquare9_filled10_19, // 51 - magicSquare9_filled10_20, // 52 - magicSquare9_filled50_1, // 53 - magicSquare9_filled50_2, // 54 - magicSquare9_filled50_3, // 55 - magicSquare9_filled50_4, // 56 - magicSquare9_filled50_5, // 57 - magicSquare9_filled50_6, // 58 - magicSquare9_filled50_7, // 59 - magicSquare9_filled50_8, // 60 - magicSquare9_filled50_9, // 61 - magicSquare9_filled50_10, // 62 - magicSquare9_filled50_11, // 63 - magicSquare9_filled50_12, // 64 - magicSquare9_filled50_13, // 65 - magicSquare9_filled50_14, // 66 - magicSquare9_filled50_15, // 67 - magicSquare9_filled50_16, // 68 - magicSquare9_filled50_17, // 69 - magicSquare9_filled50_18, // 70 - magicSquare9_filled50_19, // 71 - magicSquare9_filled50_20 // 72 + magic_square5_filled10_1, // 0 + magic_square5_filled10_2, // 1 + magic_square5_filled10_3, // 2 + magic_square5_filled10_4, // 3 + magic_square5_filled10_5, // 4 + magic_square5_filled10_6, // 5 + magic_square5_filled10_7, // 6 + magic_square5_filled10_8, // 7 + magic_square5_filled10_9, // 8 + magic_square5_filled10_10, // 9 + magic_square5_filled10_11, // 10 + magic_square5_filled10_12, // 11 + magic_square5_filled10_13, // 12 + magic_square5_filled10_14, // 13 + magic_square5_filled10_15, // 14 + magic_square5_filled10_16, // 15 + magic_square5_filled10_17, // 16 + magic_square5_filled10_18, // 17 + magic_square5_filled10_19, // 18 + magic_square5_filled10_20, // 19 + magic_square5_filled11_3_1, // 20 + magic_square5_filled11_5_1, // 21 + magic_square5_filled11_5_2, // 22 + magic_square5_filled11_5_3, // 23 + magic_square5_filled12_10_1, // 24 + magic_square5_filled12_1_1, // 25 + magic_square5_filled12_1_2, // 26 + magic_square5_filled12_1_3, // 27 + magic_square5_filled12_2_1, // 28 + magic_square5_filled12_2_2, // 29 + magic_square5_filled12_2_3, // 30 + magic_square5_filled12_3_1, // 31 + magic_square5_filled12_3_2, // 32 + magic_square9_filled10_1, // 33 + magic_square9_filled10_2, // 34 + magic_square9_filled10_3, // 35 + magic_square9_filled10_4, // 36 + magic_square9_filled10_5, // 37 + magic_square9_filled10_6, // 38 + magic_square9_filled10_7, // 39 + magic_square9_filled10_8, // 40 + magic_square9_filled10_9, // 41 + magic_square9_filled10_10, // 42 + magic_square9_filled10_11, // 43 + magic_square9_filled10_12, // 44 + magic_square9_filled10_13, // 45 + magic_square9_filled10_14, // 46 + magic_square9_filled10_15, // 47 + magic_square9_filled10_16, // 48 + magic_square9_filled10_17, // 49 + magic_square9_filled10_18, // 50 + magic_square9_filled10_19, // 51 + magic_square9_filled10_20, // 52 + magic_square9_filled50_1, // 53 + magic_square9_filled50_2, // 54 + magic_square9_filled50_3, // 55 + magic_square9_filled50_4, // 56 + magic_square9_filled50_5, // 57 + magic_square9_filled50_6, // 58 + magic_square9_filled50_7, // 59 + magic_square9_filled50_8, // 60 + magic_square9_filled50_9, // 61 + magic_square9_filled50_10, // 62 + magic_square9_filled50_11, // 63 + magic_square9_filled50_12, // 64 + magic_square9_filled50_13, // 65 + magic_square9_filled50_14, // 66 + magic_square9_filled50_15, // 67 + magic_square9_filled50_16, // 68 + magic_square9_filled50_17, // 69 + magic_square9_filled50_18, // 70 + magic_square9_filled50_19, // 71 + magic_square9_filled50_20 // 72 }; const unsigned n_examples = sizeof(specs) / sizeof(int*); diff --git a/examples/magic-square.cpp b/examples/magic-square.cpp index c2f94489ee..8ca90fc338 100644 --- a/examples/magic-square.cpp +++ b/examples/magic-square.cpp @@ -109,13 +109,13 @@ class MagicSquare : public Script { } /// Copy during cloning - virtual Space* - copy(void) { + Space* + copy(void) override { return new MagicSquare(*this); } /// Print solution - virtual void - print(std::ostream& os) const { + void + print(std::ostream& os) const override { // Matrix-wrapper for the square Matrix m(x, n, n); for (int i = 0; i < n; i++) { diff --git a/examples/minesweeper.cpp b/examples/minesweeper.cpp index d0e9d99ef9..474f14756d 100644 --- a/examples/minesweeper.cpp +++ b/examples/minesweeper.cpp @@ -42,7 +42,7 @@ namespace { extern const char* specs[]; extern const unsigned int n_examples; int spec_size(const char* s); - int mineField(const char* s, int n, int i, int j); + int mine_field(const char* s, int n, int i, int j); } // namespace /** @@ -75,7 +75,7 @@ class MineSweeper : public Script { /// Return the fields in \a m around position (\a x,\a y) BoolVarArgs - fieldsAround(Matrix& m, int x, int y) { + fields_around(Matrix& m, int x, int y) { int bvsize = 0; for (int ix = std::max(0, x - 1); ix <= x + 1 && ix < size; ix++) for (int iy = std::max(0, y - 1); iy <= y + 1 && iy < size; iy++) @@ -100,10 +100,10 @@ class MineSweeper : public Script { // Initialize matrix and post constraints for (int h = 0; h < size; h++) for (int w = 0; w < size; w++) { - int v = mineField(spec, size, h, w); + int v = mine_field(spec, size, h, w); if (v != -1) { rel(*this, m(w, h), IRT_EQ, 0); - linear(*this, fieldsAround(m, w, h), IRT_EQ, v); + linear(*this, fields_around(m, w, h), IRT_EQ, v); } } @@ -112,12 +112,12 @@ class MineSweeper : public Script { } /// Print solution - virtual void - print(std::ostream& os) const { + void + print(std::ostream& os) const override { for (int h = 0; h < size; ++h) { os << '\t'; for (int w = 0; w < size; ++w) { - int v = mineField(spec, size, h, w); + int v = mine_field(spec, size, h, w); if (v != -1) os << v << " "; else if (pos(h, w).val() == 1) @@ -135,8 +135,8 @@ class MineSweeper : public Script { b.update(*this, s.b); } /// Copy space during cloning - virtual Space* - copy(void) { + Space* + copy(void) override { return new MineSweeper(*this); } }; @@ -280,7 +280,7 @@ namespace { /// Return value at position (\a i,\a j) in the example \a s of size \a n int - mineField(const char* s, int n, int i, int j) { + mine_field(const char* s, int n, int i, int j) { assert(spec_size(s) == n); assert(i >= 0 && i < n); assert(j >= 0 && j < n); diff --git a/examples/money.cpp b/examples/money.cpp index deb14d1150..ef68caa21d 100644 --- a/examples/money.cpp +++ b/examples/money.cpp @@ -98,8 +98,8 @@ class Money : public Script { }); } /// Print solution - virtual void - print(std::ostream& os) const { + void + print(std::ostream& os) const override { os << "\t" << le << std::endl; } @@ -108,8 +108,8 @@ class Money : public Script { le.update(*this, s.le); } /// Copy during cloning - virtual Space* - copy(void) { + Space* + copy(void) override { return new Money(*this); } }; diff --git a/examples/multi-bin-packing.cpp b/examples/multi-bin-packing.cpp index ee365fc79b..8247a20cb4 100644 --- a/examples/multi-bin-packing.cpp +++ b/examples/multi-bin-packing.cpp @@ -156,7 +156,7 @@ class MultiBinPacking : public Script { for (int i = 0; i < spec.items(); i++) s[i] = spec.size(i, k); - binpacking(*this, l, bin, s); + bin_packing(*this, l, bin, s); } } break; case MODEL_MULTI: { @@ -171,8 +171,8 @@ class MultiBinPacking : public Script { for (int k = 0; k < spec.dimension(); k++) s[i * spec.dimension() + k] = spec.size(i, k); - // Post multidimensional binpacking constraint - IntSet mc = binpacking(*this, spec.dimension(), load, bin, s, c); + // Post multidimensional bin_packing constraint + IntSet mc = bin_packing(*this, spec.dimension(), load, bin, s, c); // Symmetry breaking if (opt.symmetry() == SYMMETRY_MAX_CONFLICT) { @@ -202,13 +202,13 @@ class MultiBinPacking : public Script { load.update(*this, s.load); } /// Perform copying during cloning - virtual Space* - copy(void) { + Space* + copy(void) override { return new MultiBinPacking(*this); } /// Print solution - virtual void - print(std::ostream& os) const { + void + print(std::ostream& os) const override { os << "\tInstance: " << spec.iname() << std::endl; if (bin.assigned()) { for (int j = 0; j < spec.bins(); j++) { diff --git a/examples/nonogram.cpp b/examples/nonogram.cpp index 2f67351afd..20dd7c027d 100644 --- a/examples/nonogram.cpp +++ b/examples/nonogram.cpp @@ -243,14 +243,14 @@ class Nonogram : public Script { } /// Copy space during cloning - virtual Space* - copy(void) { + Space* + copy(void) override { return new Nonogram(*this); } /// Print solution - virtual void - print(std::ostream& os) const { + void + print(std::ostream& os) const override { Matrix m(b, width(), height()); for (int h = 0; h < height(); ++h) { os << '\t'; diff --git a/examples/open-shop.cpp b/examples/open-shop.cpp index 603dabfe5f..82e1e445e9 100644 --- a/examples/open-shop.cpp +++ b/examples/open-shop.cpp @@ -129,37 +129,37 @@ class OpenShop : public IntMinimizeScript { new (&tasks[k++]) Task(j, i, dur(i, j)); int* t0_tasks = re.alloc(spec.n * spec.m); // Earliest possible tasks - bool stopCROSH = false; + bool stop_crosh = false; - int maxIterations; + int max_iterations; switch (spec.n) { case 3: - maxIterations = 5; + max_iterations = 5; break; case 4: - maxIterations = 25; + max_iterations = 25; break; case 5: - maxIterations = 50; + max_iterations = 50; break; case 6: - maxIterations = 1000; + max_iterations = 1000; break; case 7: - maxIterations = 10000; + max_iterations = 10000; break; case 8: - maxIterations = 10000; + max_iterations = 10000; break; case 9: - maxIterations = 10000; + max_iterations = 10000; break; default: - maxIterations = 25000; + max_iterations = 25000; break; } int iteration = 0; - while (!stopCROSH && maxmakespan > minmakespan) { + while (!stop_crosh && maxmakespan > minmakespan) { for (int i = spec.n; i--;) ct_j[i] = 0; for (int i = spec.m; i--;) @@ -201,8 +201,8 @@ class OpenShop : public IntMinimizeScript { } maxmakespan = std::min(maxmakespan, cmax); - if (iteration++ > maxIterations) - stopCROSH = true; // Iterate a couple of times + if (iteration++ > max_iterations) + stop_crosh = true; // Iterate a couple of times } } @@ -263,14 +263,14 @@ class OpenShop : public IntMinimizeScript { } /// Perform copying during cloning - virtual Space* - copy(void) { + Space* + copy(void) override { return new OpenShop(*this); } /// Minimize the makespan - virtual IntVar - cost(void) const { + IntVar + cost(void) const override { return makespan; } @@ -288,8 +288,8 @@ class OpenShop : public IntMinimizeScript { }; /// Print solution - virtual void - print(std::ostream& os) const { + void + print(std::ostream& os) const override { Region re; PrintTask* m = re.alloc(spec.n); for (int i = 0; i < spec.m; i++) { diff --git a/examples/ortho-latin.cpp b/examples/ortho-latin.cpp index 3d2605560f..55cb6ef477 100644 --- a/examples/ortho-latin.cpp +++ b/examples/ortho-latin.cpp @@ -133,13 +133,13 @@ class OrthoLatinSquare : public Script { } /// Copy during cloning - virtual Space* - copy(void) { + Space* + copy(void) override { return new OrthoLatinSquare(*this); } /// Print solution - virtual void - print(std::ostream& os) const { + void + print(std::ostream& os) const override { for (int i = 0; i < n; i++) { os << "\t"; for (int j = 0; j < n; j++) { diff --git a/examples/partition.cpp b/examples/partition.cpp index 93db6ddd6e..92233196ba 100644 --- a/examples/partition.cpp +++ b/examples/partition.cpp @@ -98,13 +98,13 @@ class Partition : public Script { y.update(*this, s.y); } /// Copying during cloning - virtual Space* - copy(void) { + Space* + copy(void) override { return new Partition(*this); } /// Print solution - virtual void - print(std::ostream& os) const { + void + print(std::ostream& os) const override { os << "\t"; int a, b; a = b = 0; diff --git a/examples/pentominoes.cpp b/examples/pentominoes.cpp index bc469bec0e..6eda5e3380 100644 --- a/examples/pentominoes.cpp +++ b/examples/pentominoes.cpp @@ -441,14 +441,14 @@ class Pentominoes : public Script { } /// Copy space during cloning - virtual Space* - copy(void) { + Space* + copy(void) override { return new Pentominoes(*this); } /// Print solution - virtual void - print(std::ostream& os) const { + void + print(std::ostream& os) const override { for (int h = 0; h < height; ++h) { os << "\t"; for (int w = 0; w < width - 1; ++w) { diff --git a/examples/perfect-square.cpp b/examples/perfect-square.cpp index 272f5a03e6..a5c531c2ac 100644 --- a/examples/perfect-square.cpp +++ b/examples/perfect-square.cpp @@ -155,7 +155,7 @@ class PerfectSquare : public Script { IntArgs sa(n, s); // Squares do not overlap - nooverlap(*this, x, sa, y, sa); + no_overlap(*this, x, sa, y, sa); /* * Capacity constraints @@ -214,13 +214,13 @@ class PerfectSquare : public Script { y.update(*this, s.y); } /// Copy during cloning - virtual Space* - copy(void) { + Space* + copy(void) override { return new PerfectSquare(*this); } /// Print solution - virtual void - print(std::ostream& os) const { + void + print(std::ostream& os) const override { os << "\t"; for (int i = 0; i < x.size(); i++) os << "(" << x[i] << "," << y[i] << ") "; diff --git a/examples/photo.cpp b/examples/photo.cpp index cd783301ee..6780ec8a87 100644 --- a/examples/photo.cpp +++ b/examples/photo.cpp @@ -120,7 +120,7 @@ class Photo : public IntMinimizeScript { branch(*this, pos, INT_VAR_NONE(), INT_VAL_MIN()); break; case BRANCH_DEGREE: - branch(*this, pos, tiebreak(INT_VAR_DEGREE_MAX(), INT_VAR_SIZE_MIN()), INT_VAL_MIN()); + branch(*this, pos, tie_break(INT_VAR_DEGREE_MAX(), INT_VAR_SIZE_MIN()), INT_VAL_MIN()); break; case BRANCH_AFC_SIZE: branch(*this, pos, INT_VAR_AFC_SIZE_MAX(opt.decay()), INT_VAL_MIN()); @@ -129,7 +129,7 @@ class Photo : public IntMinimizeScript { } /// Relax the last solution for large neighbourhood search void - spoke(SpokeContext& sc) { + spoke(SpokeContext& sc) override { if ((sc.engine() == MetaEngine::Restart) && (sc.last() != nullptr) && (p > 0.0)) { const Photo& l = static_cast(*sc.last()); relax(*this, pos, l.pos, rnd.split(sc), p); @@ -142,18 +142,18 @@ class Photo : public IntMinimizeScript { violations.update(*this, s.violations); } /// Copy during cloning - virtual Space* - copy(void) { + Space* + copy(void) override { return new Photo(*this); } /// Print solution - virtual void - print(std::ostream& os) const { + void + print(std::ostream& os) const override { os << "\tpos[] = " << pos << std::endl << "\tviolations: " << violations << std::endl; } /// Return solution cost - virtual IntVar - cost(void) const { + IntVar + cost(void) const override { return violations; } }; diff --git a/examples/qcp.cpp b/examples/qcp.cpp index 00884501c8..073fcf8829 100644 --- a/examples/qcp.cpp +++ b/examples/qcp.cpp @@ -198,7 +198,7 @@ class QCP : public Script { switch (opt.branching()) { case BRANCH_CBS_MAX_SD: #ifdef GECODE_HAS_CBS - cbsbranch(*this, e); + cbs_branch(*this, e); #endif case BRANCH_SIZE: branch(*this, e, INT_VAR_SIZE_MIN(), INT_VAL_MIN()); @@ -210,8 +210,8 @@ class QCP : public Script { } } /// Post a different branching for each asset of portfolio search - virtual void - spoke(SpokeContext& sc) { + void + spoke(SpokeContext& sc) override { if (sc.engine() == MetaEngine::Portfolio) { double tbf = opt.tbf(); Rnd r(seeds[sc.asset() % n_seeds]); @@ -221,14 +221,14 @@ class QCP : public Script { assert(w >= b); return b + (w - b) * tbf; }; - branch(*this, e, tiebreak(INT_VAR_SIZE_MIN(tbl), INT_VAR_RND(r)), INT_VAL_MIN()); + branch(*this, e, tie_break(INT_VAR_SIZE_MIN(tbl), INT_VAR_RND(r)), INT_VAL_MIN()); } break; case BRANCH_AFC_SIZE: { auto tbl = [tbf](const Space&, double w, double b) { assert(b >= w); return b - (b - w) * tbf; }; - branch(*this, e, tiebreak(INT_VAR_AFC_SIZE_MAX(opt.decay(), tbl), INT_VAR_RND(r)), INT_VAL_MIN()); + branch(*this, e, tie_break(INT_VAR_AFC_SIZE_MAX(opt.decay(), tbl), INT_VAR_RND(r)), INT_VAL_MIN()); } break; default:; } @@ -239,13 +239,13 @@ class QCP : public Script { e.update(*this, s.e); } /// Copy during cloning - virtual Space* - copy(void) { + Space* + copy(void) override { return new QCP(*this); } /// Print solution - virtual void - print(std::ostream& os) const { + void + print(std::ostream& os) const override { int n = spec.size(); Matrix m(e, n); diff --git a/examples/queen-armies.cpp b/examples/queen-armies.cpp index 6580453ebc..cc02ada086 100644 --- a/examples/queen-armies.cpp +++ b/examples/queen-armies.cpp @@ -41,7 +41,7 @@ using namespace Gecode; * * \relates QueenArmies */ -IntSet* A; +IntSet* a; /** * \brief %Example: Peaceable co-existing armies of queens @@ -65,11 +65,11 @@ IntSet* A; class QueenArmies : public IntMaximizeScript { public: const int n; - SetVar U, ///< Set of un-attacked squares - W; ///< Set of squares occupied by white queens - BoolVarArray w, ///< The placement of the white queens - b; ///< The placement of the black queens - IntVar q; ///< The number of white queens placed. + SetVar u, ///< Set of un-attacked squares + white_positions; ///< Set of squares occupied by white queens + BoolVarArray white_matrix, ///< The placement of the white queens + b; ///< The placement of the black queens + IntVar q; ///< The number of white queens placed. /// Branching to use for model enum { @@ -79,29 +79,30 @@ class QueenArmies : public IntMaximizeScript { /// Constructor QueenArmies(const SizeOptions& opt) - : IntMaximizeScript(opt), n(opt.size()), U(*this, IntSet::empty, IntSet(0, n * n)), - W(*this, IntSet::empty, IntSet(0, n * n)), w(*this, n * n, 0, 1), b(*this, n * n, 0, 1), q(*this, 0, n * n) { + : IntMaximizeScript(opt), n(opt.size()), u(*this, IntSet::empty, IntSet(0, n * n)), + white_positions(*this, IntSet::empty, IntSet(0, n * n)), white_matrix(*this, n * n, 0, 1), + b(*this, n * n, 0, 1), q(*this, 0, n * n) { // Basic rules of the model for (int i = n * n; i--;) { // w[i] means that no blacks are allowed on A[i] - rel(*this, w[i] == (U || A[i])); + rel(*this, white_matrix[i] == (u || a[i])); // Make sure blacks and whites are disjoint. - rel(*this, !w[i] || !b[i]); + rel(*this, !white_matrix[i] || !b[i]); // If i in U, then b[i] has a piece. - rel(*this, b[i] == (singleton(i) <= U)); + rel(*this, b[i] == (singleton(i) <= u)); } // Connect optimization variable to number of pieces - linear(*this, w, IRT_EQ, q); + linear(*this, white_matrix, IRT_EQ, q); linear(*this, b, IRT_GQ, q); // Connect cardinality of U to the number of black pieces. - IntVar unknowns = expr(*this, cardinality(U)); + IntVar unknowns = expr(*this, cardinality(u)); rel(*this, q <= unknowns); linear(*this, b, IRT_EQ, unknowns); if (opt.branching() == BRANCH_NAIVE) { - branch(*this, w, BOOL_VAR_NONE(), BOOL_VAL_MAX()); + branch(*this, white_matrix, BOOL_VAR_NONE(), BOOL_VAL_MAX()); branch(*this, b, BOOL_VAR_NONE(), BOOL_VAL_MAX()); } else { QueenBranch::post(*this); @@ -110,32 +111,32 @@ class QueenArmies : public IntMaximizeScript { } /// Constructor for cloning QueenArmies(QueenArmies& s) : IntMaximizeScript(s), n(s.n) { - U.update(*this, s.U); - W.update(*this, s.W); - w.update(*this, s.w); + u.update(*this, s.u); + white_positions.update(*this, s.white_positions); + white_matrix.update(*this, s.white_matrix); b.update(*this, s.b); q.update(*this, s.q); } /// Return copy during cloning - virtual Space* - copy(void) { + Space* + copy(void) override { return new QueenArmies(*this); } /// Return solution cost - virtual IntVar - cost(void) const { + IntVar + cost(void) const override { return q; } /// Print solution - virtual void - print(std::ostream& os) const { + void + print(std::ostream& os) const override { os << '\t'; for (int i = 0; i < n * n; ++i) { - if (w[i].assigned() && w[i].val()) + if (white_matrix[i].assigned() && white_matrix[i].val()) os << "W"; else if (b[i].assigned() && b[i].val()) os << "B"; - else if (!w[i].assigned() && !b[i].assigned()) + else if (!white_matrix[i].assigned() && !b[i].assigned()) os << " "; else os << "."; @@ -168,8 +169,8 @@ class QueenArmies : public IntMaximizeScript { */ Choice(const Brancher& b, int pos0, bool val0) : Gecode::Choice(b, 2), pos(pos0), val(val0) {} /// Archive into \a e - virtual void - archive(Archive& e) const { + void + archive(Archive& e) const override { Gecode::Choice::archive(e); e << pos << val; } @@ -182,11 +183,11 @@ class QueenArmies : public IntMaximizeScript { public: /// Check status of brancher, return true if alternatives left. - virtual bool - status(const Space& home) const { + bool + status(const Space& home) const override { const QueenArmies& q = static_cast(home); for (int i = start; i < q.n * q.n; ++i) - if (!q.w[i].assigned()) { + if (!q.white_matrix[i].assigned()) { start = i; return true; } @@ -194,18 +195,18 @@ class QueenArmies : public IntMaximizeScript { return false; } /// Return choice - virtual Gecode::Choice* - choice(Space& home) { + Gecode::Choice* + choice(Space& home) override { const QueenArmies& q = static_cast(home); int maxsize = -1; int pos = -1; for (int i = start; i < q.n * q.n; ++i) { - if (q.w[i].assigned()) + if (q.white_matrix[i].assigned()) continue; - IntSetRanges ai(A[i]); - SetVarUnknownRanges qU(q.U); - Iter::Ranges::Inter r(ai, qU); + IntSetRanges ai(a[i]); + SetVarUnknownRanges q_u(q.u); + Iter::Ranges::Inter r(ai, q_u); int size = Iter::Ranges::size(r); if (size > maxsize) { maxsize = size; @@ -217,8 +218,8 @@ class QueenArmies : public IntMaximizeScript { return new Choice(*this, pos, true); } /// Return choice - virtual Choice* - choice(const Space&, Archive& e) { + Choice* + choice(const Space&, Archive& e) override { int pos, val; e >> pos >> val; return new Choice(*this, pos, val); @@ -226,23 +227,23 @@ class QueenArmies : public IntMaximizeScript { /** \brief Perform commit for choice \a _c and * alternative \a a. */ - virtual ExecStatus - commit(Space& home, const Gecode::Choice& _c, unsigned int a) { + ExecStatus + commit(Space& home, const Gecode::Choice& _c, unsigned int a) override { QueenArmies& q = static_cast(home); const Choice& c = static_cast(_c); bool val = (a == 0) ? c.val : !c.val; - return me_failed(Int::BoolView(q.w[c.pos]).eq(q, val)) ? ES_FAILED : ES_OK; + return me_failed(Int::BoolView(q.white_matrix[c.pos]).eq(q, val)) ? ES_FAILED : ES_OK; } /// Print explanation - virtual void - print(const Space&, const Gecode::Choice& _c, unsigned int a, std::ostream& o) const { + void + print(const Space&, const Gecode::Choice& _c, unsigned int a, std::ostream& o) const override { const Choice& c = static_cast(_c); bool val = (a == 0) ? c.val : !c.val; o << "w[" << c.pos << "] = " << val; } /// Copy brancher during cloning - virtual Actor* - copy(Space& home) { + Actor* + copy(Space& home) override { return new (home) QueenBranch(home, *this); } /// Post brancher @@ -251,8 +252,8 @@ class QueenArmies : public IntMaximizeScript { (void)new (home) QueenBranch(home); } /// Delete brancher and return its size - virtual size_t - dispose(Space&) { + size_t + dispose(Space&) override { return sizeof(*this); } }; @@ -278,7 +279,7 @@ main(int argc, char* argv[]) { // Set up the A-sets // A[i] will contain the values attacked by a queen at position i int n = opt.size(); - A = new IntSet[n * n]; + a = new IntSet[n * n]; int* p = new int[std::max(n * n, 25)]; int pn = 0; for (int i = n; i--;) { @@ -293,7 +294,7 @@ main(int argc, char* argv[]) { } } - A[pos(i, j, n)] = IntSet(p, pn); + a[pos(i, j, n)] = IntSet(p, pn); pn = 0; } diff --git a/examples/queens.cpp b/examples/queens.cpp index b4aa208e6f..bdf671b21d 100644 --- a/examples/queens.cpp +++ b/examples/queens.cpp @@ -97,14 +97,14 @@ class Queens : public Script { } /// Perform copying during cloning - virtual Space* - copy(void) { + Space* + copy(void) override { return new Queens(*this); } /// Print solution - virtual void - print(std::ostream& os) const { + void + print(std::ostream& os) const override { os << "queens\t"; for (int i = 0; i < q.size(); i++) { os << q[i] << ", "; @@ -130,13 +130,15 @@ class QueensInspector : public Gist::Inspector { /// Constructor QueensInspector(void) : scene(nullptr), mw(nullptr) {} /// Inspect space \a s - virtual void - inspect(const Space& s) { + void + inspect(const Space& s) override { const Queens& q = static_cast(s); + const int inset = unit / 4; + const int diameter = unit / 2; if (!scene) initialize(); - QList itemList = scene->items(); + QList item_list = scene->items(); foreach (QGraphicsItem* i, scene->items()) { scene->removeItem(i); delete i; @@ -149,7 +151,7 @@ class QueensInspector : public Gist::Inspector { QBrush b(q.q[i].assigned() ? Qt::black : Qt::red); QPen p(q.q[i].assigned() ? Qt::black : Qt::white); for (IntVarValues xv(q.q[i]); xv(); ++xv) { - scene->addEllipse(QRectF(i * unit + unit / 4, xv.val() * unit + unit / 4, unit / 2, unit / 2), p, b); + scene->addEllipse(QRectF(i * unit + inset, xv.val() * unit + inset, diameter, diameter), p, b); } } mw->show(); @@ -165,20 +167,20 @@ class QueensInspector : public Gist::Inspector { mw->setCentralWidget(view); mw->setAttribute(Qt::WA_QuitOnClose, false); mw->setAttribute(Qt::WA_DeleteOnClose, false); - QAction* closeWindow = new QAction("Close window", mw); - closeWindow->setShortcut(QKeySequence("Ctrl+W")); - mw->connect(closeWindow, SIGNAL(triggered()), mw, SLOT(close())); - mw->addAction(closeWindow); + QAction* close_window = new QAction("Close window", mw); + close_window->setShortcut(QKeySequence("Ctrl+W")); + mw->connect(close_window, SIGNAL(triggered()), mw, SLOT(close())); + mw->addAction(close_window); } /// Name of the inspector - virtual std::string - name(void) { + std::string + name(void) override { return "Board"; } /// Finalize inspector - virtual void - finalize(void) { + void + finalize(void) override { delete mw; mw = nullptr; } diff --git a/examples/radiotherapy.cpp b/examples/radiotherapy.cpp index 5f47516319..2bdbb6e3b3 100644 --- a/examples/radiotherapy.cpp +++ b/examples/radiotherapy.cpp @@ -57,22 +57,22 @@ class RadiotherapyData { const int n; ///< Width of intensity matrix const int* intensity; ///< Intensity matrix - int btMin; ///< Minimal beam time (computed from other parameters) - int btMax; ///< Maximal beam time (computed from other parameters) - int intsSum; ///< Sum of all intensities + int bt_min; ///< Minimal beam time (computed from other parameters) + int bt_max; ///< Maximal beam time (computed from other parameters) + int ints_sum; ///< Sum of all intensities /// Construct instance data RadiotherapyData(int m0, int n0, const int* intensity0) : m(m0), n(n0), intensity(intensity0) { - btMax = 0; - intsSum = 0; + bt_max = 0; + ints_sum = 0; for (int i = 0; i < m * n; i++) { - btMax = std::max(btMax, intensity[i]); - intsSum += intensity[i]; + bt_max = std::max(bt_max, intensity[i]); + ints_sum += intensity[i]; } - btMin = 0; + bt_min = 0; for (int i = 0; i < m; i++) - btMin = std::max(btMin, incr_sum(i)); + bt_min = std::max(bt_min, incr_sum(i)); } }; @@ -103,9 +103,9 @@ class Radiotherapy : public IntMinimizeScript { /// Total beam-on time IntVar beamtime; /// Number of shape matrices - IntVar K; + IntVar k; /// n[b] is the number of shape matrices with associated beam-on time b - IntVarArray N; + IntVarArray n; /// Q[i,j,b] is the number of shape matrices with associated beam-on time b that expose cell (i,j) IntVarArray q; @@ -117,42 +117,42 @@ class Radiotherapy : public IntMinimizeScript { Radiotherapy(const SizeOptions& opt) : IntMinimizeScript(opt), rd(rds[opt.size()]) { // Initialize variables - beamtime = IntVar(*this, rd.btMin, rd.intsSum); - K = IntVar(*this, 0, rd.m * rd.n); - N = IntVarArray(*this, rd.btMax, 0, rd.m * rd.n); - q = IntVarArray(*this, rd.m * rd.n * rd.btMax, 0, rd.m * rd.n); + beamtime = IntVar(*this, rd.bt_min, rd.ints_sum); + k = IntVar(*this, 0, rd.m * rd.n); + n = IntVarArray(*this, rd.bt_max, 0, rd.m * rd.n); + q = IntVarArray(*this, rd.m * rd.n * rd.bt_max, 0, rd.m * rd.n); - IntArgs coeffs(rd.btMax); - for (int i = 0; i < rd.btMax; i++) + IntArgs coeffs(rd.bt_max); + for (int i = 0; i < rd.bt_max; i++) coeffs[i] = i + 1; - linear(*this, coeffs, N, IRT_EQ, beamtime); - linear(*this, N, IRT_EQ, K); + linear(*this, coeffs, n, IRT_EQ, beamtime); + linear(*this, n, IRT_EQ, k); for (int i = 0; i < rd.m; i++) { for (int j = 0; j < rd.n; j++) { - IntVarArgs qs(rd.btMax); - for (int b = 0; b < rd.btMax; b++) - qs[b] = q[i * rd.n * rd.btMax + j * rd.btMax + b]; + IntVarArgs qs(rd.bt_max); + for (int b = 0; b < rd.bt_max; b++) + qs[b] = q[i * rd.n * rd.bt_max + j * rd.bt_max + b]; linear(*this, coeffs, qs, IRT_EQ, rd.intensity[i * rd.n + j], IPL_DOM); } } for (int i = 0; i < rd.m; i++) { - for (int b = 0; b < rd.btMax; b++) { + for (int b = 0; b < rd.bt_max; b++) { IntVarArgs qs(rd.n); for (int j = 0; j < rd.n; j++) - qs[j] = q[i * rd.n * rd.btMax + j * rd.btMax + b]; - incr_sum(N[b], qs, rd.m * rd.n); + qs[j] = q[i * rd.n * rd.bt_max + j * rd.bt_max + b]; + incr_sum(n[b], qs, rd.m * rd.n); } } - _cost = IntVar(*this, 0, (rd.m * rd.n + 1) * (rd.intsSum + 1)); - rel(*this, _cost == beamtime * (rd.m * rd.n + 1) + K); + _cost = IntVar(*this, 0, (rd.m * rd.n + 1) * (rd.ints_sum + 1)); + rel(*this, _cost == beamtime * (rd.m * rd.n + 1) + k); // First branch over beamtime and N IntVarArgs ba({beamtime}); branch(*this, ba, INT_VAR_NONE(), INT_VAL_MIN()); - branch(*this, N, INT_VAR_NONE(), INT_VAL_SPLIT_MIN()); + branch(*this, n, INT_VAR_NONE(), INT_VAL_SPLIT_MIN()); // Then perform a nested search over q NestedSearch::post(*this); @@ -174,28 +174,28 @@ class Radiotherapy : public IntMinimizeScript { /// Constructor for cloning \a s Radiotherapy(Radiotherapy& s) : IntMinimizeScript(s), rd(s.rd) { beamtime.update(*this, s.beamtime); - N.update(*this, s.N); - K.update(*this, s.K); + n.update(*this, s.n); + k.update(*this, s.k); _cost.update(*this, s._cost); q.update(*this, s.q); } /// Perform copying during cloning - virtual Space* - copy(void) { + Space* + copy(void) override { return new Radiotherapy(*this); } /// Cost to be minimized - virtual IntVar - cost(void) const { + IntVar + cost(void) const override { return _cost; } /// Print solution - virtual void - print(std::ostream& os) const { - os << std::endl << "B / K = " << beamtime << " / " << K << ",\nN = " << N << std::endl; + void + print(std::ostream& os) const override { + os << std::endl << "B / K = " << beamtime << " / " << k << ",\nN = " << n << std::endl; } /// Nested search on the q variables @@ -223,8 +223,8 @@ class Radiotherapy : public IntMinimizeScript { /// Initialize choice for brancher \a b Choice(const Brancher& b, bool fail0) : Gecode::Choice(b, 1), fail(fail0) {} /// Archive into \a e - virtual void - archive(Archive& e) const { + void + archive(Archive& e) const override { Gecode::Choice::archive(e); e.put(fail); } @@ -252,24 +252,24 @@ class Radiotherapy : public IntMinimizeScript { NestedSearch(Space& home, NestedSearch& b) : Brancher(home, b), done(b.done), index(b.index) {} public: - virtual bool - status(const Space&) const { + bool + status(const Space&) const override { return !done; } IntVarArgs - getRow(Radiotherapy* row, int i) { - IntVarArgs ri(row->rd.n * row->rd.btMax); + get_row(Radiotherapy* row, int i) { + IntVarArgs ri(row->rd.n * row->rd.bt_max); for (int j = 0; j < row->rd.n; j++) { - for (int b = 0; b < row->rd.btMax; b++) { - ri[j * row->rd.btMax + b] = row->q[i * row->rd.n * row->rd.btMax + j * row->rd.btMax + b]; + for (int b = 0; b < row->rd.bt_max; b++) { + ri[j * row->rd.bt_max + b] = row->q[i * row->rd.n * row->rd.bt_max + j * row->rd.bt_max + b]; } } return ri; } /// Return choice - virtual Gecode::Choice* - choice(Space& home) { + Gecode::Choice* + choice(Space& home) override { done = true; Radiotherapy& rt = static_cast(home); @@ -282,12 +282,12 @@ class Radiotherapy : public IntMinimizeScript { Radiotherapy* row = static_cast(rt.clone()); // Branch over row i - branch(*row, getRow(row, index[i].idx), INT_VAR_NONE(), INT_VAL_SPLIT_MIN()); + branch(*row, get_row(row, index[i].idx), INT_VAR_NONE(), INT_VAL_SPLIT_MIN()); Search::Options o; o.clone = false; - if (Radiotherapy* newSol = dfs(row, o)) { + if (Radiotherapy* new_sol = dfs(row, o)) { // Found a solution for row i, so try to find one for i+1 - delete newSol; + delete new_sol; std::cerr << index[i].idx; } else { // Found no solution for row i, so back to search the N variables @@ -302,26 +302,26 @@ class Radiotherapy : public IntMinimizeScript { return new Choice(*this, fail); } /// Return choice - virtual Choice* - choice(const Space&, Archive& e) { + Choice* + choice(const Space&, Archive& e) override { bool fail; e >> fail; return new Choice(*this, fail); } /// Perform commit for choice \a _c and alternative \a a - virtual ExecStatus - commit(Space&, const Gecode::Choice& _c, unsigned int) { + ExecStatus + commit(Space&, const Gecode::Choice& _c, unsigned int) override { return static_cast(_c).fail ? ES_FAILED : ES_OK; } /// Print explanation - virtual void - print(const Space&, const Gecode::Choice& _c, unsigned int, std::ostream& o) const { + void + print(const Space&, const Gecode::Choice& _c, unsigned int, std::ostream& o) const override { const Choice& c = static_cast(_c); o << (c.fail ? "fail" : "ok"); } /// Copy brancher - virtual Actor* - copy(Space& home) { + Actor* + copy(Space& home) override { return new (home) NestedSearch(home, *this); } /// Post brancher @@ -331,7 +331,7 @@ class Radiotherapy : public IntMinimizeScript { } /// Dispose member function size_t - dispose(Space& home) { + dispose(Space& home) override { home.ignore(*this, AP_DISPOSE); // Periodic scaling of weights if (!--index[index.size() - 1].idx) { diff --git a/examples/sat.cpp b/examples/sat.cpp index 73cacc6ef7..d5c70a0ff9 100644 --- a/examples/sat.cpp +++ b/examples/sat.cpp @@ -127,14 +127,14 @@ class Sat : public Script { } /// Perform copying during cloning - virtual Space* - copy(void) { + Space* + copy(void) override { return new Sat(*this); } /// Print solution - virtual void - print(std::ostream& os) const { + void + print(std::ostream& os) const override { os << "solution:\n" << x << std::endl; } }; diff --git a/examples/schurs-lemma.cpp b/examples/schurs-lemma.cpp index 6a699dadf1..2236c4e4d3 100644 --- a/examples/schurs-lemma.cpp +++ b/examples/schurs-lemma.cpp @@ -55,8 +55,8 @@ class SchurOptions : public Options { n = atoi(argv[2]); } /// Print help message - virtual void - help(void) { + void + help(void) override { Options::help(); std::cerr << "\t(unsigned int) default: " << c << std::endl << "\t\tparameter c (number of boxes)" << std::endl @@ -100,8 +100,8 @@ class Schur : public Script { branch(*this, box, INT_VAR_AFC_SIZE_MAX(opt.decay()), INT_VAL_MIN()); } /// Print solution - virtual void - print(std::ostream& os) const { + void + print(std::ostream& os) const override { os << "\t" << box << std::endl; } @@ -110,8 +110,8 @@ class Schur : public Script { box.update(*this, s.box); } /// Copy during cloning - virtual Space* - copy(void) { + Space* + copy(void) override { return new Schur(*this); } }; diff --git a/examples/sports-league.cpp b/examples/sports-league.cpp index c040cada3a..3c81ef21af 100644 --- a/examples/sports-league.cpp +++ b/examples/sports-league.cpp @@ -301,13 +301,13 @@ class SportsLeague : public Script { game.update(*this, s.game); } /// Copy during cloning - virtual Space* - copy(void) { + Space* + copy(void) override { return new SportsLeague(*this); } /// Print solution - virtual void - print(std::ostream& os) const { + void + print(std::ostream& os) const override { // print period index os << "\t "; for (int p = 0; p < periods(); p++) { diff --git a/examples/steel-mill.cpp b/examples/steel-mill.cpp index 5e87cfa588..27e1b46e10 100644 --- a/examples/steel-mill.cpp +++ b/examples/steel-mill.cpp @@ -85,7 +85,7 @@ class SteelMillOptions : public Options { _maxcapacity(csplib_maxcapacity), _loss(csplib_loss), _orders(&(csplib_orders[0])), _ncolors(csplib_ncolors), _norders(csplib_norders) {} /// Print help text - virtual void help(void); + void help(void) override; /// Parse options from arguments \a argv (number is \a argc) bool parse(int& argc, char* argv[]); @@ -106,7 +106,7 @@ class SteelMillOptions : public Options { } /// Return maximum of capacities int - maxcapacity(void) const { + max_capacity(void) const { return _maxcapacity; } /// Return loss values @@ -183,7 +183,7 @@ class SteelMill : public IntMinimizeScript { //@{ int* capacities; ///< Capacities int ncapacities; ///< Number of capacities - int maxcapacity; ///< Maximum capacity + int max_capacity; ///< Maximum capacity int* loss; ///< Loss for all sizes int ncolors; ///< Number of colors order_t orders; ///< Orders @@ -195,8 +195,8 @@ class SteelMill : public IntMinimizeScript { */ //@{ IntVarArray slab, ///< Slab assigned to order i - slabload, ///< Load of slab j - slabcost; ///< Cost of slab j + slab_load, ///< Load of slab j + slab_cost; ///< Cost of slab j IntVar total_cost; ///< Total cost //@} @@ -212,17 +212,17 @@ class SteelMill : public IntMinimizeScript { SteelMill(const SteelMillOptions& opt) : // Initialize instance data IntMinimizeScript(opt), capacities(opt.capacities()), ncapacities(opt.ncapacities()), - maxcapacity(opt.maxcapacity()), loss(opt.loss()), ncolors(opt.ncolors()), orders(opt.orders()), + max_capacity(opt.max_capacity()), loss(opt.loss()), ncolors(opt.ncolors()), orders(opt.orders()), norders(opt.size()), nslabs(opt.size()), // Initialize problem variables - slab(*this, norders, 0, nslabs - 1), slabload(*this, nslabs, 0, 45), - slabcost(*this, nslabs, 0, Int::Limits::max), total_cost(*this, 0, Int::Limits::max) { + slab(*this, norders, 0, nslabs - 1), slab_load(*this, nslabs, 0, 45), + slab_cost(*this, nslabs, 0, Int::Limits::max), total_cost(*this, 0, Int::Limits::max) { // Boolean variables for slab[o]==s - BoolVarArgs boolslab(norders * nslabs); + BoolVarArgs order_in_slab(norders * nslabs); for (unsigned int i = 0; i < norders; ++i) { BoolVarArgs tmp(nslabs); for (int j = nslabs; j--;) { - boolslab[j + i * nslabs] = tmp[j] = BoolVar(*this, 0, 1); + order_in_slab[j + i * nslabs] = tmp[j] = BoolVar(*this, 0, 1); } channel(*this, tmp, slab[i]); } @@ -233,52 +233,52 @@ class SteelMill : public IntMinimizeScript { BoolVarArgs x(norders); for (int i = norders; i--;) { c[i] = orders[i][order_weight]; - x[i] = boolslab[s + i * nslabs]; + x[i] = order_in_slab[s + i * nslabs]; } - linear(*this, c, x, IRT_EQ, slabload[s]); + linear(*this, c, x, IRT_EQ, slab_load[s]); } // Redundant packing constraint int totalweight = 0; for (unsigned int i = norders; i--;) totalweight += orders[i][order_weight]; - linear(*this, slabload, IRT_EQ, totalweight); + linear(*this, slab_load, IRT_EQ, totalweight); // Color constraints - IntArgs nofcolor(ncolors); + IntArgs color_order_count(ncolors); for (int c = ncolors; c--;) { - nofcolor[c] = 0; + color_order_count[c] = 0; for (int o = norders; o--;) { if (orders[o][order_color] == c) - nofcolor[c] += 1; + color_order_count[c] += 1; } } BoolVar f(*this, 0, 0); for (unsigned int s = 0; s < nslabs; ++s) { - BoolVarArgs hascolor(ncolors); + BoolVarArgs has_color(ncolors); for (int c = ncolors; c--;) { - if (nofcolor[c]) { - BoolVarArgs hasc(nofcolor[c]); + if (color_order_count[c]) { + BoolVarArgs hasc(color_order_count[c]); int pos = 0; for (int o = norders; o--;) { if (orders[o][order_color] == c) - hasc[pos++] = boolslab[s + o * nslabs]; + hasc[pos++] = order_in_slab[s + o * nslabs]; } - assert(pos == nofcolor[c]); - hascolor[c] = BoolVar(*this, 0, 1); - rel(*this, BOT_OR, hasc, hascolor[c]); + assert(pos == color_order_count[c]); + has_color[c] = BoolVar(*this, 0, 1); + rel(*this, BOT_OR, hasc, has_color[c]); } else { - hascolor[c] = f; + has_color[c] = f; } } - linear(*this, hascolor, IRT_LQ, 2); + linear(*this, has_color, IRT_LQ, 2); } - // Compute slabcost - IntArgs l(maxcapacity, loss); + // Compute slab_cost + IntArgs l(max_capacity, loss); for (int s = nslabs; s--;) { - element(*this, l, slabload[s], slabcost[s]); + element(*this, l, slab_load[s], slab_cost[s]); } - linear(*this, slabcost, IRT_EQ, total_cost); + linear(*this, slab_cost, IRT_EQ, total_cost); // Add branching if (opt.symmetry() == SYMMETRY_BRANCHING) { @@ -289,7 +289,7 @@ class SteelMill : public IntMinimizeScript { } else { // opt.symmetry() == SYMMETRY_LDSB // There is one symmetry: the values (slabs) are interchangeable. Symmetries syms; - syms << ValueSymmetry(IntArgs::create(nslabs, 0)); + syms << value_symmetry(IntArgs::create(nslabs, 0)); // For variable order we mimic the custom brancher. We use // min-size domain, breaking ties by maximum weight (preferring @@ -309,23 +309,23 @@ class SteelMill : public IntMinimizeScript { } /// Print solution - virtual void - print(std::ostream& os) const { + void + print(std::ostream& os) const override { os << "What slab=" << slab << std::endl; - os << "Slab load=" << slabload << std::endl; - os << "Slab cost=" << slabcost << std::endl; + os << "Slab load=" << slab_load << std::endl; + os << "Slab cost=" << slab_cost << std::endl; os << "Total cost=" << total_cost << std::endl; int nslabsused = 0; int nslabscost = 0; bool unassigned = false; for (int i = nslabs; i--;) { - if (!slabload[i].assigned() || !slabcost[i].assigned()) { + if (!slab_load[i].assigned() || !slab_cost[i].assigned()) { unassigned = true; break; } - if (slabload[i].min() > 0) + if (slab_load[i].min() > 0) ++nslabsused; - if (slabcost[i].min() > 0) + if (slab_cost[i].min() > 0) ++nslabscost; } if (!unassigned) @@ -335,21 +335,21 @@ class SteelMill : public IntMinimizeScript { /// Constructor for cloning \a s SteelMill(SteelMill& s) - : IntMinimizeScript(s), capacities(s.capacities), ncapacities(s.ncapacities), maxcapacity(s.maxcapacity), + : IntMinimizeScript(s), capacities(s.capacities), ncapacities(s.ncapacities), max_capacity(s.max_capacity), loss(s.loss), ncolors(s.ncolors), orders(s.orders), norders(s.norders), nslabs(s.nslabs) { slab.update(*this, s.slab); - slabload.update(*this, s.slabload); - slabcost.update(*this, s.slabcost); + slab_load.update(*this, s.slab_load); + slab_cost.update(*this, s.slab_cost); total_cost.update(*this, s.total_cost); } /// Copy during cloning - virtual Space* - copy(void) { + Space* + copy(void) override { return new SteelMill(*this); } /// Return solution cost - virtual IntVar - cost(void) const { + IntVar + cost(void) const override { return total_cost; } @@ -378,8 +378,8 @@ class SteelMill : public IntMinimizeScript { Choice(const Brancher& b, unsigned int a, int pos0, int val0) : Gecode::Choice(b, a), pos(pos0), val(val0) {} /// Archive into \a e - virtual void - archive(Archive& e) const { + void + archive(Archive& e) const override { Gecode::Choice::archive(e); e << alternatives() << pos << val; } @@ -392,8 +392,8 @@ class SteelMill : public IntMinimizeScript { public: /// Check status of brancher, return true if alternatives left. - virtual bool - status(const Space& home) const { + bool + status(const Space& home) const override { const SteelMill& sm = static_cast(home); for (unsigned int i = start; i < sm.norders; ++i) if (!sm.slab[i].assigned()) { @@ -404,8 +404,8 @@ class SteelMill : public IntMinimizeScript { return false; } /// Return choice - virtual Gecode::Choice* - choice(Space& home) { + Gecode::Choice* + choice(Space& home) override { SteelMill& sm = static_cast(home); assert(!sm.slab[start].assigned()); // Find order with a) minimum size, b) largest weight @@ -427,21 +427,21 @@ class SteelMill : public IntMinimizeScript { unsigned int val = sm.slab[pos].min(); // Find first still empty slab (all such slabs are symmetric) unsigned int firstzero = 0; - while (firstzero < sm.nslabs && sm.slabload[firstzero].min() > 0) + while (firstzero < sm.nslabs && sm.slab_load[firstzero].min() > 0) ++firstzero; assert(pos < sm.nslabs && val < sm.norders); return new Choice(*this, (val < firstzero) ? 2 : 1, pos, val); } - virtual Choice* - choice(const Space&, Archive& e) { + Choice* + choice(const Space&, Archive& e) override { unsigned int alt; int pos, val; e >> alt >> pos >> val; return new Choice(*this, alt, pos, val); } /// Perform commit for choice \a _c and alternative \a a - virtual ExecStatus - commit(Space& home, const Gecode::Choice& _c, unsigned int a) { + ExecStatus + commit(Space& home, const Gecode::Choice& _c, unsigned int a) override { SteelMill& sm = static_cast(home); const Choice& c = static_cast(_c); if (a) @@ -450,14 +450,14 @@ class SteelMill : public IntMinimizeScript { return me_failed(Int::IntView(sm.slab[c.pos]).eq(home, c.val)) ? ES_FAILED : ES_OK; } /// Print explanation - virtual void - print(const Space&, const Gecode::Choice& _c, unsigned int a, std::ostream& o) const { + void + print(const Space&, const Gecode::Choice& _c, unsigned int a, std::ostream& o) const override { const Choice& c = static_cast(_c); o << "slab[" << c.pos << "] " << ((a == 0) ? "=" : "!=") << " " << c.val; } /// Copy brancher - virtual Actor* - copy(Space& home) { + Actor* + copy(Space& home) override { return new (home) SteelMillBranch(home, *this); } /// Post brancher @@ -466,8 +466,8 @@ class SteelMill : public IntMinimizeScript { (void)new (home) SteelMillBranch(home); } /// Delete brancher and return its size - virtual size_t - dispose(Space&) { + size_t + dispose(Space&) override { return sizeof(*this); } }; diff --git a/examples/steiner.cpp b/examples/steiner.cpp index 81a536ffea..1d9c1d19d2 100644 --- a/examples/steiner.cpp +++ b/examples/steiner.cpp @@ -55,23 +55,23 @@ class Steiner : public Script { /// Order of the Steiner problem int n; /// Number of Steiner triples - int noOfTriples; + int no_of_triples; /// The steiner triples SetVarArray triples; /// Actual model Steiner(const SizeOptions& opt) - : Script(opt), n(opt.size()), noOfTriples((n * (n - 1)) / 6), - triples(*this, noOfTriples, IntSet::empty, 1, n, 3U, 3U) { + : Script(opt), n(opt.size()), no_of_triples((n * (n - 1)) / 6), + triples(*this, no_of_triples, IntSet::empty, 1, n, 3U, 3U) { - for (int i = 0; i < noOfTriples; i++) { - for (int j = i + 1; j < noOfTriples; j++) { + for (int i = 0; i < no_of_triples; i++) { + for (int j = i + 1; j < no_of_triples; j++) { SetVar x = triples[i]; SetVar y = triples[j]; - SetVar atmostOne(*this, IntSet::empty, 1, n, 0U, 1U); - rel(*this, (x & y) == atmostOne); + SetVar atmost_one(*this, IntSet::empty, 1, n, 0U, 1U); + rel(*this, (x & y) == atmost_one); IntVar x1(*this, 1, n); IntVar x2(*this, 1, n); @@ -96,8 +96,8 @@ class Steiner : public Script { * Using matching constraints */ - channelSorted(*this, {x1, x2, x3}, x); - channelSorted(*this, {y1, y2, y3}, y); + channel_sorted(*this, {x1, x2, x3}, x); + channel_sorted(*this, {y1, y2, y3}, y); } else if (opt.model() == MODEL_SEQ) { SetVar sx1 = expr(*this, singleton(x1)); SetVar sx2 = expr(*this, singleton(x2)); @@ -126,19 +126,19 @@ class Steiner : public Script { branch(*this, triples, SET_VAR_NONE(), SET_VAL_MIN_INC()); } /// Print solution - virtual void - print(std::ostream& os) const { - for (int i = 0; i < noOfTriples; i++) { + void + print(std::ostream& os) const override { + for (int i = 0; i < no_of_triples; i++) { os << "\t[" << i << "] = " << triples[i] << std::endl; } } /// Constructor for copying \a s - Steiner(Steiner& s) : Script(s), n(s.n), noOfTriples(s.noOfTriples) { + Steiner(Steiner& s) : Script(s), n(s.n), no_of_triples(s.no_of_triples) { triples.update(*this, s.triples); } /// Copy during cloning - virtual Space* - copy(void) { + Space* + copy(void) override { return new Steiner(*this); } }; diff --git a/examples/sudoku-advanced.cpp b/examples/sudoku-advanced.cpp index e79fb45796..1aa7813a69 100644 --- a/examples/sudoku-advanced.cpp +++ b/examples/sudoku-advanced.cpp @@ -177,14 +177,14 @@ class SudokuInt : virtual public Sudoku { } /// Perform copying during cloning - virtual Space* - copy(void) { + Space* + copy(void) override { return new SudokuInt(*this); } /// Print solution - virtual void - print(std::ostream& os) const { + void + print(std::ostream& os) const override { os << " "; for (int i = 0; i < nn * nn; i++) { if (x[i].assigned()) { @@ -341,14 +341,14 @@ class SudokuSet : virtual public Sudoku { } /// Perform copying during cloning - virtual Space* - copy(void) { + Space* + copy(void) override { return new SudokuSet(*this); } /// Print solution - virtual void - print(std::ostream& os) const { + void + print(std::ostream& os) const override { os << '\t'; for (int i = 0; i < nn * nn; i++) { for (int j = 0; j < nn; j++) { @@ -377,14 +377,14 @@ class SudokuMixed : public SudokuInt, public SudokuSet { SudokuMixed(const InstanceOptions& opt) : Sudoku(opt), SudokuInt(opt), SudokuSet(opt) { IntSet is0(0, 0); - SetVar dummySet0(*this, is0, is0); - IntVar dummyInt0(*this, 0, 0); + SetVar dummy_set0(*this, is0, is0); + IntVar dummy_int0(*this, 0, 0); SetVarArgs ys(nn + 1); - ys[0] = dummySet0; + ys[0] = dummy_set0; for (int i = 0; i < nn; i++) ys[i + 1] = y[i]; IntVarArgs xs(nn * nn + 1); - xs[0] = dummyInt0; + xs[0] = dummy_int0; for (int i = 0; i < nn * nn; i++) xs[i + 1] = x[i]; @@ -400,14 +400,14 @@ class SudokuMixed : public SudokuInt, public SudokuSet { SudokuMixed(SudokuMixed& s) : Sudoku(s), SudokuInt(s), SudokuSet(s) {} /// Perform copying during cloning - virtual Space* - copy(void) { + Space* + copy(void) override { return new SudokuMixed(*this); } /// Print solution - virtual void - print(std::ostream& os) const { + void + print(std::ostream& os) const override { SudokuInt::print(os); } }; diff --git a/examples/sudoku-instances.hh b/examples/sudoku-instances.hh index d09fdc6963..958ea683b9 100644 --- a/examples/sudoku-instances.hh +++ b/examples/sudoku-instances.hh @@ -38,7 +38,7 @@ namespace { extern const char* examples[]; extern const unsigned int n_examples; int example_size(const char* s); - int sudokuField(const char* s, int n, int i, int j); + int sudoku_field(const char* s, int n, int i, int j); /** \name %Sudoku specifications * @@ -1770,7 +1770,7 @@ namespace { /// Return value at position (\a i,\a j) in the example \a s of size \a n int - sudokuField(const char* s, int n, int i, int j) { + sudoku_field(const char* s, int n, int i, int j) { assert(example_size(s) == std::sqrt(static_cast(n))); assert(i >= 0 && i < n); assert(j >= 0 && j < n); @@ -1842,7 +1842,7 @@ instances { givens = IntArgs(nn * nn); for (int r = 0; r < nn; r++) for (int c = 0; c < nn; c++) - givens[r * nn + c] = sudokuField(examples[i], nn, c, r); + givens[r * nn + c] = sudoku_field(examples[i], nn, c, r); } else if (opt.is_file()) { // The spec has checked the data Instance::Data d = opt.data(); diff --git a/examples/sudoku.cpp b/examples/sudoku.cpp index 349a794b03..b49c723c58 100644 --- a/examples/sudoku.cpp +++ b/examples/sudoku.cpp @@ -101,14 +101,14 @@ class Sudoku : public Script { } /// Perform copying during cloning - virtual Space* - copy(void) { + Space* + copy(void) override { return new Sudoku(*this); } /// Print solution - virtual void - print(std::ostream& os) const { + void + print(std::ostream& os) const override { os << " "; for (int i = 0; i < nn * nn; i++) { if (x[i].assigned()) { diff --git a/examples/tsp.cpp b/examples/tsp.cpp index 69fafcf899..5d79f5ddc8 100644 --- a/examples/tsp.cpp +++ b/examples/tsp.cpp @@ -47,22 +47,22 @@ using namespace Gecode; namespace { /// This instance is taken from SICStus Prolog - const int PA_n = 7; - const int PA_d[PA_n * PA_n] = {0, 205, 677, 581, 461, 878, 345, 205, 0, 882, 427, 390, 1105, + const int pa_n = 7; + const int pa_d[pa_n * pa_n] = {0, 205, 677, 581, 461, 878, 345, 205, 0, 882, 427, 390, 1105, 540, 677, 882, 0, 619, 316, 201, 470, 581, 427, 619, 0, 412, 592, 570, 461, 390, 316, 412, 0, 517, 190, 878, 1105, 201, 592, 517, 0, 691, 345, 540, 470, 570, 190, 691, 0}; /// This instance is taken from SICStus Prolog - const int PB_n = 10; - const int PB_d[PB_n * PB_n] = {2, 4, 4, 1, 9, 2, 4, 4, 1, 9, 2, 9, 5, 5, 5, 2, 9, 5, 5, 5, 1, 5, 2, 3, 3, + const int pb_n = 10; + const int pb_d[pb_n * pb_n] = {2, 4, 4, 1, 9, 2, 4, 4, 1, 9, 2, 9, 5, 5, 5, 2, 9, 5, 5, 5, 1, 5, 2, 3, 3, 1, 5, 2, 3, 3, 2, 6, 8, 9, 5, 2, 6, 8, 9, 5, 3, 7, 1, 6, 4, 3, 7, 1, 6, 4, 1, 2, 4, 1, 7, 1, 2, 4, 1, 7, 3, 5, 2, 7, 6, 3, 5, 2, 7, 6, 2, 7, 9, 5, 5, 2, 7, 9, 5, 5, 3, 9, 7, 3, 4, 3, 9, 7, 3, 4, 4, 1, 5, 9, 2, 4, 1, 5, 9, 2}; /// This instance is br17.atsp from TSPLIB - const int PC_n = 17; - const int PC_d[PC_n * PC_n] = { + const int pc_n = 17; + const int pc_d[pc_n * pc_n] = { 0, 3, 5, 48, 48, 8, 8, 5, 5, 3, 3, 0, 3, 5, 8, 8, 5, 3, 0, 3, 48, 48, 8, 8, 5, 5, 0, 0, 3, 0, 3, 8, 8, 5, 5, 3, 0, 72, 72, 48, 48, 24, 24, 3, 3, 5, 3, 0, 48, 48, 24, 48, 48, 74, 0, 0, 6, 6, 12, 12, 48, 48, 48, 48, 74, 6, 6, 12, 48, 48, 74, 0, 0, 6, 6, 12, 12, 48, 48, 48, 48, @@ -76,8 +76,8 @@ namespace { 0, 8, 5, 5, 26, 12, 12, 8, 8, 0, 0, 5, 5, 5, 5, 26, 8, 8, 0}; /// This instance is ftv33.atsp from TSPLIB - const int PD_n = 34; - const int PD_d[PD_n * PD_n] = { + const int pd_n = 34; + const int pd_d[pd_n * pd_n] = { 0, 26, 82, 65, 100, 147, 134, 69, 117, 42, 89, 125, 38, 13, 38, 31, 22, 103, 143, 94, 104, 123, 98, 58, 38, 30, 67, 120, 149, 100, 93, 162, 62, 66, 66, 0, 56, 39, 109, 156, 140, 135, 183, 108, 155, 190, 104, 79, 104, 97, 88, 130, 176, 121, 131, 150, 125, 85, 65, 57, 94, 147, 160, 80, 67, 189, @@ -184,12 +184,12 @@ namespace { return m * _n; } - Problem PA(PA_n, PA_d); - Problem PB(PB_n, PB_d); - Problem PC(PC_n, PC_d); - Problem PD(PD_n, PD_d); + Problem pa(pa_n, pa_d); + Problem pb(pb_n, pb_d); + Problem pc(pc_n, pc_d); + Problem pd(pd_n, pd_d); - Problem ps[] = {PA, PB, PC, PD}; + Problem ps[] = {pa, pb, pc, pd}; const unsigned int ps_n = sizeof(ps) / sizeof(Problem); /** @@ -381,8 +381,8 @@ class TSP : public IntMinimizeScript { branch(*this, succ, INT_VAR_MIN_MIN(), INT_VAL_MIN()); } /// Return solution cost - virtual IntVar - cost(void) const { + IntVar + cost(void) const override { return total; } /// Constructor for cloning \a s @@ -391,13 +391,13 @@ class TSP : public IntMinimizeScript { total.update(*this, s.total); } /// Copy during cloning - virtual Space* - copy(void) { + Space* + copy(void) override { return new TSP(*this); } /// Print solution - virtual void - print(std::ostream& os) const { + void + print(std::ostream& os) const override { bool assigned = true; for (int i = 0; i < succ.size(); i++) { if (!succ[i].assigned()) { diff --git a/examples/tsptw.cpp b/examples/tsptw.cpp index 92dfe6a661..c826b1a210 100644 --- a/examples/tsptw.cpp +++ b/examples/tsptw.cpp @@ -54,19 +54,19 @@ namespace { }; /// Instance rbg010a (Ascheuer) - const int PA_n = 11; - const int PA_d[PA_n * PA_n] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 71, 0, 85, 85, 85, 96, 85, 85, 97, 85, + const int pa_n = 11; + const int pa_d[pa_n * pa_n] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 71, 0, 85, 85, 85, 96, 85, 85, 97, 85, 77, 50, 65, 0, 77, 77, 62, 77, 77, 62, 77, 74, 64, 74, 88, 0, 88, 80, 88, 88, 82, 88, 87, 44, 54, 68, 68, 0, 60, 68, 68, 62, 68, 67, 51, 75, 51, 51, 51, 0, 51, 51, 80, 51, 65, 53, 64, 78, 78, 78, 68, 0, 78, 69, 78, 76, 51, 67, 69, 69, 69, 75, 69, 0, 75, 69, 63, 43, 61, 71, 71, 71, 43, 71, 71, 0, 71, 68, 53, 64, 78, 78, 78, 68, 78, 78, 69, 0, 80, 42, 66, 52, 52, 52, 70, 52, 52, 70, 52, 0}; - const int PA_w[2 * PA_n] = {0, 9396, 0, 865, 399, 1299, 550, 1450, 685, 1585, 819, + const int pa_w[2 * pa_n] = {0, 9396, 0, 865, 399, 1299, 550, 1450, 685, 1585, 819, 1719, 1208, 2108, 1412, 2312, 1701, 2330, 2413, 3313, 3798, 4698}; /// Instance n20w20.001 (Dumas et al.) - const int PB_n = 21; - const int PB_d[PB_n * PB_n] = { + const int pb_n = 21; + const int pb_d[pb_n * pb_n] = { 0, 19, 17, 34, 7, 20, 10, 17, 28, 15, 23, 29, 23, 29, 21, 20, 9, 16, 21, 13, 12, 19, 0, 10, 41, 26, 3, 27, 25, 15, 17, 17, 14, 18, 48, 17, 6, 21, 14, 17, 13, 31, 17, 10, 0, 47, 23, 13, 26, 15, 25, 22, 26, 24, 27, 44, 7, 5, 23, 21, 25, 18, 29, 34, 41, 47, 0, 36, 39, 25, 51, 36, 24, 27, 38, 25, 44, 54, 45, 25, 28, 26, 28, 27, @@ -83,12 +83,12 @@ namespace { 31, 13, 4, 7, 14, 7, 42, 28, 19, 11, 0, 5, 3, 21, 21, 17, 25, 26, 28, 14, 21, 36, 11, 7, 2, 13, 2, 46, 32, 22, 15, 5, 0, 8, 25, 13, 13, 18, 28, 20, 11, 15, 28, 15, 4, 10, 17, 10, 40, 25, 17, 9, 3, 8, 0, 19, 12, 31, 29, 27, 10, 30, 4, 27, 35, 18, 27, 36, 26, 21, 33, 32, 10, 21, 25, 19, 0}; - const int PB_w[2 * PB_n] = {0, 408, 62, 68, 181, 205, 306, 324, 214, 217, 51, 61, 102, 129, + const int pb_w[2 * pb_n] = {0, 408, 62, 68, 181, 205, 306, 324, 214, 217, 51, 61, 102, 129, 175, 186, 250, 263, 3, 23, 21, 49, 79, 90, 78, 96, 140, 154, 354, 386, 42, 63, 2, 13, 24, 42, 20, 33, 9, 21, 275, 300}; /// The instances - const Builtin instances[] = {{PA_n, PA_d, PA_w}, {PB_n, PB_d, PB_w}}; + const Builtin instances[] = {{pa_n, pa_d, pa_w}, {pb_n, pb_d, pb_w}}; /// Number of instances const unsigned int n_instances = sizeof(instances) / sizeof(Builtin); @@ -251,8 +251,8 @@ class TSPTW : public IntMinimizeScript { branch(*this, x, INT_VAR_NONE(), INT_VALUES_MIN()); } /// Return cost - virtual IntVar - cost(void) const { + IntVar + cost(void) const override { return total; } /// Return the number of positions assigned from the start @@ -321,13 +321,13 @@ class TSPTW : public IntMinimizeScript { total.update(*this, s.total); } /// Copy during cloning - virtual Space* - copy(void) { + Space* + copy(void) override { return new TSPTW(*this); } /// Print solution - virtual void - print(std::ostream& os) const { + void + print(std::ostream& os) const override { os << "\tTour: 0"; for (int i = 0; i < x.size(); i++) os << " -> " << x[i]; diff --git a/examples/warehouses.cpp b/examples/warehouses.cpp index d52f25138e..8875f1ea9b 100644 --- a/examples/warehouses.cpp +++ b/examples/warehouses.cpp @@ -144,8 +144,8 @@ class SumCostWarehouses : public Warehouses { c_total = expr(*this, c_fixed * sum(open) + sum(c_store)); } /// Return solution cost - virtual IntVar - cost(void) const { + IntVar + cost(void) const override { return c_total; } /// Constructor for cloning \a s @@ -153,13 +153,13 @@ class SumCostWarehouses : public Warehouses { c_total.update(*this, s.c_total); } /// Copy during cloning - virtual Space* - copy(void) { + Space* + copy(void) override { return new SumCostWarehouses(*this); } /// Print solution - virtual void - print(std::ostream& os) const { + void + print(std::ostream& os) const override { os << "\tSupplier: " << supplier << std::endl << "\tOpen warehouses: " << open << std::endl << "\tStore cost: " << c_store << std::endl @@ -184,8 +184,8 @@ class LexCostWarehouses : public Warehouses { c_stores = expr(*this, sum(c_store)); } /// Return solution cost - virtual IntVarArgs - cost(void) const { + IntVarArgs + cost(void) const override { return {c_open, c_stores}; } /// Constructor for cloning \a s @@ -194,13 +194,13 @@ class LexCostWarehouses : public Warehouses { c_stores.update(*this, s.c_stores); } /// Copy during cloning - virtual Space* - copy(void) { + Space* + copy(void) override { return new LexCostWarehouses(*this); } /// Print solution - virtual void - print(std::ostream& os) const { + void + print(std::ostream& os) const override { os << "\tSupplier: " << supplier << std::endl << "\tOpen warehouses: " << open << std::endl << "\tOpen cost: " << c_open << std::endl diff --git a/examples/word-square.cpp b/examples/word-square.cpp index 14bd48bb18..b559d7f560 100644 --- a/examples/word-square.cpp +++ b/examples/word-square.cpp @@ -115,13 +115,13 @@ class WordSquare : public Script { letters.update(*this, s.letters); } /// Copy during cloning - virtual Space* - copy(void) { + Space* + copy(void) override { return new WordSquare(*this); } /// Print solution - virtual void - print(std::ostream& os) const { + void + print(std::ostream& os) const override { Matrix ml(letters, w_l, w_l); for (int i = 0; i < w_l; i++) { os << "\t\t"; diff --git a/gecode/driver.hh b/gecode/driver.hh index 1e132ac556..b631ba7a2a 100644 --- a/gecode/driver.hh +++ b/gecode/driver.hh @@ -134,7 +134,7 @@ namespace Gecode { /// Create heap-allocated copy of string \a s static char* strdup(const char* s); /// Create heap-allocated copy of string \a s with hyphen added - static char* stredup(const char* s); + static char* duplicate_option_flag(const char* s); /// Delete heap-allocated copy of string \a s static void strdel(const char* s); }; @@ -150,8 +150,8 @@ namespace Gecode { void value(uint64_t v); /// Construct an independent generator at the configured initial state. Rnd rnd(void) const; - virtual int parse(int argc, char* argv[]); - virtual void help(void); + int parse(int argc, char* argv[]) override; + void help(void) override; }; /** @@ -169,11 +169,11 @@ namespace Gecode { /// Return current option value const char* value(void) const; /// Parse option at first position and return number of parsed arguments - virtual int parse(int argc, char* argv[]); + int parse(int argc, char* argv[]) override; /// Print help text - virtual void help(void); + void help(void) override; /// Destructor - virtual ~StringValueOption(void); + ~StringValueOption(void) override; }; /** @@ -186,7 +186,7 @@ namespace Gecode { /// Initialize for option \a o and explanation \a e StringListOption(const char* o, const char* e); /// Parse option at first position and return number of parsed arguments - virtual int parse(int argc, char* argv[]); + int parse(int argc, char* argv[]) override; }; /** @@ -216,11 +216,11 @@ namespace Gecode { /// Add option value for value \a v, string \a o, and help text \a h void add(int v, const char* o, const char* h = nullptr); /// Parse option at first position and return number of parsed arguments - virtual int parse(int argc, char* argv[]); + int parse(int argc, char* argv[]) override; /// Print help text - virtual void help(void); + void help(void) override; /// Destructor - virtual ~StringOption(void); + ~StringOption(void) override; }; /** @@ -238,9 +238,9 @@ namespace Gecode { /// Return current option value int value(void) const; /// Parse option at first position and return number of parsed arguments - virtual int parse(int argc, char* argv[]); + int parse(int argc, char* argv[]) override; /// Print help text - virtual void help(void); + void help(void) override; }; /** @@ -258,9 +258,9 @@ namespace Gecode { /// Return current option value unsigned int value(void) const; /// Parse option at first position and return number of parsed arguments - virtual int parse(int argc, char* argv[]); + int parse(int argc, char* argv[]) override; /// Print help text - virtual void help(void); + void help(void) override; }; /** @@ -278,9 +278,9 @@ namespace Gecode { /// Return current option value unsigned long long int value(void) const; /// Parse option at first position and return number of parsed arguments - virtual int parse(int argc, char* argv[]); + int parse(int argc, char* argv[]) override; /// Print help text - virtual void help(void); + void help(void) override; }; /** @@ -298,9 +298,9 @@ namespace Gecode { /// Return current option value double value(void) const; /// Parse option at first position and return number of parsed arguments - virtual int parse(int argc, char* argv[]); + int parse(int argc, char* argv[]) override; /// Print help text - virtual void help(void); + void help(void) override; }; /** @@ -318,9 +318,9 @@ namespace Gecode { /// Return current option value bool value(void) const; /// Parse option at first position and return number of parsed arguments - virtual int parse(int argc, char* argv[]); + int parse(int argc, char* argv[]) override; /// Print help text - virtual void help(void); + void help(void) override; }; /** @@ -338,9 +338,9 @@ namespace Gecode { /// Return current option value IntPropLevel value(void) const; /// Parse option at first position and return number of parsed arguments - virtual int parse(int argc, char* argv[]); + int parse(int argc, char* argv[]) override; /// Print help text - virtual void help(void); + void help(void) override; }; /** @@ -358,9 +358,9 @@ namespace Gecode { /// Return current option value int value(void) const; /// Parse option at first position and return number of parsed arguments - virtual int parse(int argc, char* argv[]); + int parse(int argc, char* argv[]) override; /// Print help text - virtual void help(void); + void help(void) override; }; /** @@ -383,9 +383,9 @@ namespace Gecode { /// Return current execution ID int execution_id(void) const; /// Parse option at first position and return number of parsed arguments - virtual int parse(int argc, char* argv[]); + int parse(int argc, char* argv[]) override; /// Print help text - virtual void help(void); + void help(void) override; }; } // namespace Driver @@ -780,7 +780,7 @@ namespace Gecode { /// Initialize options for script with name \a s SizeOptions(const char* s); /// Print help text - virtual void help(void); + void help(void) override; /// Parse options from arguments \a argv (number is \a argc) void parse(int& argc, char* argv[]); /** @@ -857,7 +857,7 @@ namespace Gecode { */ InstanceOptions(const char* s, const char* spec); /// Print help text - virtual void help(void); + void help(void) override; /// Parse options from arguments \a argv (number is \a argc) void parse(int& argc, char* argv[]); /** @@ -913,7 +913,7 @@ namespace Gecode { */ Instance::Data data(void) const; /// Destructor - ~InstanceOptions(void); + ~InstanceOptions(void) override; }; } // namespace Gecode @@ -958,7 +958,7 @@ namespace Gecode { namespace Driver { private: template class Engine, class Options, template class> class Meta> - static void runMeta(const Options& opt, Script* s); + static void run_meta(const Options& opt, Script* s); }; #ifdef GECODE_HAS_FLOAT_VARS diff --git a/gecode/driver/options.cpp b/gecode/driver/options.cpp index 5ce0520da1..1fad215525 100644 --- a/gecode/driver/options.cpp +++ b/gecode/driver/options.cpp @@ -62,7 +62,7 @@ namespace Gecode { } char* - BaseOption::stredup(const char* s) { + BaseOption::duplicate_option_flag(const char* s) { if (s == nullptr) return nullptr; size_t l = strlen(s) + 1; @@ -100,7 +100,8 @@ namespace Gecode { return argv[2]; } - BaseOption::BaseOption(const char* o, const char* e) : eopt(strdup(o)), iopt(stredup(o)), exp(strdup(e)) {} + BaseOption::BaseOption(const char* o, const char* e) + : eopt(strdup(o)), iopt(duplicate_option_flag(o)), exp(strdup(e)) {} BaseOption::~BaseOption(void) { strdel(eopt); diff --git a/gecode/driver/script.hpp b/gecode/driver/script.hpp index bda184d1f5..8faf07f3c1 100644 --- a/gecode/driver/script.hpp +++ b/gecode/driver/script.hpp @@ -74,8 +74,8 @@ namespace Gecode { namespace Driver { SR_INT = 1 << 4 ///< Interrupted by user }; /// Test whether search must be stopped - virtual bool - stop(const Search::Statistics& s, const Search::Options& o) { + bool + stop(const Search::Statistics& s, const Search::Options& o) override { return sigint || ((ns != nullptr) && ns->stop(s, o)) || ((fs != nullptr) && fs->stop(s, o)) || ((ts != nullptr) && ts->stop(s, o)) || ((rs != nullptr) && rs->stop(s, o)); } @@ -102,7 +102,7 @@ namespace Gecode { namespace Driver { interrupt(DWORD t) noexcept { if (t == CTRL_C_EVENT) { sigint = true; - installCtrlHandler(false, true); + install_ctrl_handler(false, true); return true; } return false; @@ -112,12 +112,12 @@ namespace Gecode { namespace Driver { static void interrupt(int) { sigint = true; - installCtrlHandler(false, true); + install_ctrl_handler(false, true); } #endif /// Install handler for catching Ctrl-C static void - installCtrlHandler(bool install, bool force = false) { + install_ctrl_handler(bool install, bool force = false) { if (force || !sigint) { #ifdef GECODE_THREADS_WINDOWS SetConsoleCtrlHandler((PHANDLER_ROUTINE)interrupt, install); @@ -127,7 +127,7 @@ namespace Gecode { namespace Driver { } } /// Destructor - ~CombinedStop(void) { + ~CombinedStop(void) override { delete ns; delete fs; delete ts; @@ -154,7 +154,7 @@ namespace Gecode { namespace Driver { /// Create cutoff object from options template inline Search::Cutoff* - createCutoff(const Options& o) { + create_cutoff(const Options& o) { switch (o.restart()) { case RM_NONE: return nullptr; @@ -227,7 +227,7 @@ namespace Gecode { namespace Driver { /// Initialize ScriptGetInfo(void); /// Return info for a space (which must be a script) - virtual std::string getInfo(const Space& home) const; + std::string get_info(const Space& home) const override; }; #endif @@ -272,7 +272,7 @@ namespace Gecode { namespace Driver { template std::string - ScriptGetInfo::getInfo(const Space& home) const { + ScriptGetInfo::get_info(const Space& home) const { std::stringstream ss; if (const ScriptBase* sb = dynamic_cast*>(&home)) sb->print(ss); @@ -299,11 +299,11 @@ namespace Gecode { namespace Driver { exit(EXIT_FAILURE); } if (o.restart() != RM_NONE) { - runMeta(o, s); + run_meta(o, s); } else if (o.assets() > 0) { - runMeta(o, s); + run_meta(o, s); } else { - runMeta(o, s); + run_meta(o, s); } } @@ -311,7 +311,7 @@ namespace Gecode { namespace Driver { template class Engine, class Options, template class> class Meta> void - ScriptBase::runMeta(const Options& o, Script* s) { + ScriptBase::run_meta(const Options& o, Script* s) { using namespace std; ofstream sol_file, log_file; @@ -357,9 +357,9 @@ namespace Gecode { namespace Driver { { #ifdef GECODE_HAS_CPPROFILER if (o.profiler_port()) { - CPProfilerSearchTracer::GetInfo* getInfo = nullptr; - getInfo = new ScriptGetInfo; - so.tracer = new CPProfilerSearchTracer(o.profiler_id(), o.name(), o.profiler_port(), getInfo); + CPProfilerSearchTracer::GetInfo* get_info = nullptr; + get_info = new ScriptGetInfo; + so.tracer = new CPProfilerSearchTracer(o.profiler_id(), o.name(), o.profiler_port(), get_info); } #endif l_out << o.name() << endl; @@ -378,14 +378,14 @@ namespace Gecode { namespace Driver { so.assets = o.assets(); so.slice = o.slice(); so.stop = CombinedStop::create(o.node(), o.fail(), o.time(), o.restart_limit(), o.interrupt()); - so.cutoff = createCutoff(o); + so.cutoff = create_cutoff(o); #ifdef GECODE_HAS_EXPERIMENTAL so.guidance = o.guidance(); #endif so.clone = false; so.nogoods_limit = o.nogoods() ? o.nogoods_limit() : 0U; if (o.interrupt()) - CombinedStop::installCtrlHandler(true); + CombinedStop::install_ctrl_handler(true); { Meta e(s, so); if (o.print_last()) { @@ -415,7 +415,7 @@ namespace Gecode { namespace Driver { } while (s_n < s_l); } if (o.interrupt()) - CombinedStop::installCtrlHandler(false); + CombinedStop::install_ctrl_handler(false); Search::Statistics stat = e.statistics(); s_out << endl; if (e.end_reason() == Search::EndReason::Incomplete) { @@ -479,13 +479,13 @@ namespace Gecode { namespace Driver { so.a_d = o.a_d(); so.d_l = o.d_l(); so.stop = CombinedStop::create(o.node(), o.fail(), o.time(), o.restart_limit(), o.interrupt()); - so.cutoff = createCutoff(o); + so.cutoff = create_cutoff(o); #ifdef GECODE_HAS_EXPERIMENTAL so.guidance = o.guidance(); #endif so.nogoods_limit = o.nogoods() ? o.nogoods_limit() : 0U; if (o.interrupt()) - CombinedStop::installCtrlHandler(true); + CombinedStop::install_ctrl_handler(true); { Meta e(s, so); do { @@ -496,7 +496,7 @@ namespace Gecode { namespace Driver { s_n++; } while (s_n < s_l); if (o.interrupt()) - CombinedStop::installCtrlHandler(false); + CombinedStop::install_ctrl_handler(false); Search::Statistics stat = e.statistics(); l_out << endl << "\tpropagators: " << n_p << endl @@ -538,7 +538,7 @@ namespace Gecode { namespace Driver { sok.a_d = o.a_d(); sok.d_l = o.d_l(); sok.stop = CombinedStop::create(o.node(), o.fail(), o.time(), o.restart_limit(), false); - sok.cutoff = createCutoff(o); + sok.cutoff = create_cutoff(o); #ifdef GECODE_HAS_EXPERIMENTAL sok.guidance = o.guidance(); #endif diff --git a/gecode/flatzinc.hh b/gecode/flatzinc.hh index 4a0efdf5f3..27d86b7545 100644 --- a/gecode/flatzinc.hh +++ b/gecode/flatzinc.hh @@ -111,26 +111,26 @@ namespace Gecode { namespace FlatZinc { std::vector sv_names; #endif AST::Array* _output; - void printElem(std::ostream& out, AST::Node* ai, const Gecode::IntVarArray& iv, const Gecode::BoolVarArray& bv + void print_elem(std::ostream& out, AST::Node* ai, const Gecode::IntVarArray& iv, const Gecode::BoolVarArray& bv #ifdef GECODE_HAS_SET_VARS - , - const Gecode::SetVarArray& sv + , + const Gecode::SetVarArray& sv #endif #ifdef GECODE_HAS_FLOAT_VARS - , - const Gecode::FloatVarArray& fv + , + const Gecode::FloatVarArray& fv #endif ) const; - void printElemDiff(std::ostream& out, AST::Node* ai, const Gecode::IntVarArray& iv1, - const Gecode::IntVarArray& iv2, const Gecode::BoolVarArray& bv1, - const Gecode::BoolVarArray& bv2 + void print_elem_diff(std::ostream& out, AST::Node* ai, const Gecode::IntVarArray& iv1, + const Gecode::IntVarArray& iv2, const Gecode::BoolVarArray& bv1, + const Gecode::BoolVarArray& bv2 #ifdef GECODE_HAS_SET_VARS - , - const Gecode::SetVarArray& sv1, const Gecode::SetVarArray& sv2 + , + const Gecode::SetVarArray& sv1, const Gecode::SetVarArray& sv2 #endif #ifdef GECODE_HAS_FLOAT_VARS - , - const Gecode::FloatVarArray& fv1, const Gecode::FloatVarArray& fv2 + , + const Gecode::FloatVarArray& fv1, const Gecode::FloatVarArray& fv2 #endif ) const; public: @@ -148,56 +148,57 @@ namespace Gecode { namespace FlatZinc { #endif ) const; - void printDiff(std::ostream& out, const Gecode::IntVarArray& iv1, const Gecode::IntVarArray& iv2, - const Gecode::BoolVarArray& bv1, const Gecode::BoolVarArray& bv2 + void print_diff(std::ostream& out, const Gecode::IntVarArray& iv1, const Gecode::IntVarArray& iv2, + const Gecode::BoolVarArray& bv1, const Gecode::BoolVarArray& bv2 #ifdef GECODE_HAS_SET_VARS - , - const Gecode::SetVarArray& sv1, const Gecode::SetVarArray& sv2 + , + const Gecode::SetVarArray& sv1, const Gecode::SetVarArray& sv2 #endif #ifdef GECODE_HAS_FLOAT_VARS - , - const Gecode::FloatVarArray& fv1, const Gecode::FloatVarArray& fv2 + , + const Gecode::FloatVarArray& fv1, const Gecode::FloatVarArray& fv2 #endif ) const; ~Printer(void); - void addIntVarName(const std::string& n); + void add_int_var_name(const std::string& n); const std::string& - intVarName(int i) const { + int_var_name(int i) const { return iv_names[i]; } - void addBoolVarName(const std::string& n); + void add_bool_var_name(const std::string& n); const std::string& - boolVarName(int i) const { + bool_var_name(int i) const { return bv_names[i]; } #ifdef GECODE_HAS_FLOAT_VARS - void addFloatVarName(const std::string& n); + void add_float_var_name(const std::string& n); const std::string& - floatVarName(int i) const { + float_var_name(int i) const { return fv_names[i]; } #endif #ifdef GECODE_HAS_SET_VARS - void addSetVarName(const std::string& n); + void add_set_var_name(const std::string& n); const std::string& - setVarName(int i) const { + set_var_name(int i) const { return sv_names[i]; } #endif - void shrinkElement(AST::Node* node, std::map& iv, std::map& bv, std::map& sv, - std::map& fv); + void shrink_element(AST::Node* node, std::map& iv, std::map& bv, std::map& sv, + std::map& fv); - void shrinkArrays(Space& home, int& optVar, bool optVarIsInt, Gecode::IntVarArray& iv, Gecode::BoolVarArray& bv + void shrink_arrays(Space& home, int& opt_var, bool opt_var_is_int, Gecode::IntVarArray& iv, + Gecode::BoolVarArray& bv #ifdef GECODE_HAS_SET_VARS - , - Gecode::SetVarArray& sv + , + Gecode::SetVarArray& sv #endif #ifdef GECODE_HAS_FLOAT_VARS - , - Gecode::FloatVarArray& fv + , + Gecode::FloatVarArray& fv #endif ); @@ -215,7 +216,7 @@ namespace Gecode { namespace FlatZinc { /// \name Search options //@{ Gecode::Driver::IntOption _solutions; ///< How many solutions - Gecode::Driver::BoolOption _allSolutions; ///< Return all solutions + Gecode::Driver::BoolOption _all_solutions; ///< Return all solutions Gecode::Driver::DoubleOption _threads; ///< How many threads to use Gecode::Driver::BoolOption _free; ///< Use free search Gecode::Driver::DoubleOption _decay; ///< Decay option @@ -251,7 +252,7 @@ namespace Gecode { namespace FlatZinc { /// Constructor FlatZincOptions(const char* s) : Gecode::BaseOptions(s), _solutions("n", "number of solutions (0 = all, -1 = one/best)", -1), - _allSolutions("a", "return all solutions (equal to -n 0)"), + _all_solutions("a", "return all solutions (equal to -n 0)"), _threads("p", "number of threads (0 = #processing units)", Gecode::Search::Config::threads), _free("f", "free search, no need to follow search-specification"), _decay("decay", "decay factor", 0.99), _c_d("c-d", "recomputation commit distance", Gecode::Search::Config::c_d), @@ -289,7 +290,7 @@ namespace Gecode { namespace FlatZinc { add(_threads); add(_c_d); add(_a_d); - add(_allSolutions); + add(_all_solutions); add(_free); add(_decay); add(_node); @@ -316,7 +317,7 @@ namespace Gecode { namespace FlatZinc { void parse(int& argc, char* argv[]) { Gecode::BaseOptions::parse(argc, argv); - if (_allSolutions.value() && _solutions.value() == -1) { + if (_all_solutions.value() && _solutions.value() == -1) { _solutions.value(0); } if (_time_limit.value()) { @@ -326,8 +327,8 @@ namespace Gecode { namespace FlatZinc { _mode.value(Gecode::SM_STAT); } - virtual void - help(void) { + void + help(void) override { std::cerr << "Gecode FlatZinc interpreter" << std::endl << " - FlatZinc text interface" << std::endl << std::endl; @@ -339,8 +340,8 @@ namespace Gecode { namespace FlatZinc { return _solutions.value(); } bool - allSolutions(void) const { - return _allSolutions.value(); + all_solutions(void) const { + return _all_solutions.value(); } double threads(void) const { @@ -451,8 +452,8 @@ namespace Gecode { namespace FlatZinc { #endif void - allSolutions(bool b) { - _allSolutions.value(b); + all_solutions(bool b) { + _all_solutions.value(b); } }; @@ -497,20 +498,20 @@ namespace Gecode { namespace FlatZinc { protected: /// Initialisation data (only used for posting constraints) - FlatZincSpaceInitData* _initData; + FlatZincSpaceInitData* _init_data; /// Number of integer variables - int intVarCount; + int int_var_count; /// Number of Boolean variables - int boolVarCount; + int bool_var_count; /// Number of float variables - int floatVarCount; + int float_var_count; /// Number of set variables - int setVarCount; + int set_var_count; /// Index of the variable to optimize - int _optVar; + int _opt_var; /// Whether variable to optimize is integer (or float) - bool _optVarIsInt; + bool _opt_var_is_int; /// Whether to solve as satisfaction or optimization problem Meth _method; @@ -519,13 +520,13 @@ namespace Gecode { namespace FlatZinc { unsigned int _lns; /// Initial solution to start the LNS (or nullptr for no LNS) - IntSharedArray _lnsInitialSolution; + IntSharedArray _lns_initial_solution; /// Random number generator Rnd _random; /// Annotations on the solve item - AST::Array* _solveAnnotations; + AST::Array* _solve_annotations; /// Copy constructor FlatZincSpace(FlatZincSpace&); @@ -534,12 +535,12 @@ namespace Gecode { namespace FlatZinc { friend class BlackBoxAccess; /// Run the search engine template