this repo has no description

Squashed 'software/minizinc/' changes from 4f10c82056..93be33a6c2

93be33a6c2 Add complete predicate
REVERT: 4f10c82056 Merge branch 'MiniZinc:master' into feature/on_restart
REVERT: 0848ce7ec7 Add changelog for 2.5.5
REVERT: 44e2f770d5 Add test for insertion of ArrayLits into CSE
REVERT: 8a68d3dea8 Don't insert par expressions into CSE map unless they're an ArrayLit
REVERT: 6bf6f1180f Increase version number of development build
REVERT: dcaac92a74 Make min/max on array of opt vars return non-optional var. This is consistent with other functions on optional arrays like sum, product, exists, forall.
REVERT: 32aa288884 Update changelog
REVERT: a4edf0669f Fix flattening of all-par set literals
REVERT: 8c1c9605f6 Fix chain compressor, needs to ignore par constants
REVERT: 0cad1c6306 Use file_path on include paths to ensure separator consistency
REVERT: 05ad7d1931 Update changelog
REVERT: 22f5e2557b Define HAVE_CONFIG_H only for UNIX
REVERT: 81c7778d55 Define HAVE_CONFIG_H for CBC
REVERT: 1f56608e10 mzn-test: don't check symmetry breaking constraints
REVERT: 1a9767457e mzn-test: fix parsing %%%mzn-stat: ... output
REVERT: a41533fd54 MIP: report CPU time in %%%mzn-stat: solveTime=
REVERT: 9d490acd52 Updated docs on OR-Tools v8 installation
REVERT: c513f6599f Add changelog for 2.5.4
REVERT: b2eef2772b Follow ids to declarations when flattening par arrays. Fixes #448.
REVERT: c5c846d426 Check if result of flattening rhs of a vardecl is par.
REVERT: c496052767 Escape strings when pretty printing include items
REVERT: 9e379c995e Canonicalise file names before adding include items into "already seen" list
REVERT: d5d5d0d88c Use generic flattening inside generators. Fixes #451.
REVERT: dc8630a6e9 Small fix to multi-pass library change: use original include path if it is absolute
REVERT: 79c6092bd8 Strip library paths from includes in multi-pass compilation. Fixes #455.
REVERT: 897875d6d7 Compile infinite domains with holes into constraints. Fixes #457.
REVERT: b4e700dc67 Don't create copies of global declarations when creating par versions of functions
REVERT: 0e8cc42bb1 Fix typechecker to coerce bool to int in the objective.
REVERT: e05523b344 Add test for dzn output of arrays
REVERT: 1e0269000e Don't evaluate output_only arrays when generating dzn output.
REVERT: 57018c31d6 Fix matrix transposition in lex2 globals
REVERT: 2617c0c829 Fix output variables in lex_chain tests
REVERT: ef1a250c98 another efort to fix tests
REVERT: c00e199dfd Fix test globals_lex_chain.mzn
REVERT: b5c997d045 Fix code analysis
REVERT: 3352cf0bd5 SCIP constraint handler for lex_chain_..._orbitope
REVERT: 4e71a2cc97 Globals lex_chain_..., including lex_chain_..._orbitope
REVERT: d807428baf Move test specifcation into the correct folder
REVERT: 5be74bc74d MIP decompositions for lex_less_(bool, int, float)
REVERT: 36a554ba40 Don't modify infinte domain of optional variables. Fixes #456.
REVERT: f9e5306d75 Run clang-format
REVERT: 4b57667608 Fix comment reference to relevant test case
REVERT: 648f2ab36d Fix equality of indirection annotations
REVERT: ef7be5fd78 MIP decompositions for lex_lesseq_(bool=int, float)
REVERT: 6511b14e73 Propagate cv flag correctly.
REVERT: 6f27ecf1c0 Never insert par expressions into the CSE map.
REVERT: 7414f3ca0f Fix cplex id in example configuration
REVERT: 7ad7cec506 Update strictly_decreasing with documentation and opt version
REVERT: 8029f6e957 Support undefined enums in type checker.
REVERT: 79e0f0f546 Revert using mzn_in_symmetry_breaking_constraint() for SCIP's orbisack
REVERT: e88efda76c Fix format
REVERT: 4802031dc1 Added test mzn_in_symmetry_breaking_constraint()
REVERT: e21cc2515a More format fixes 02 ...
REVERT: 5bbd67c130 More format fixes...
REVERT: d5f9b777ea Format fixes
REVERT: 43757a09a0 Remove MIP-specific fzn_less(eq)_bool(_reif).mzn
REVERT: c93b5736a3 SCIP: orbisack constraint handler 'fzn_lex_lesseq__orbisack'
REVERT: 4516bb4e2c mzn-test.py: add OR-Tools as checker
REVERT: e2176f017d Add fix and test for crash with empty enum.
REVERT: ac7db35951 Fix documentation bugs.
REVERT: 47ba245832 Fix the incorrect renaming of key in model output interface
REVERT: 925796ed20 Fail on empty var domains in agenda
REVERT: 1ec19d7025 Fix error messages in CMake FindGurobi, FindCPlex
REVERT: 6d169475c1 mzn-test.py: Use -i for intermediate solutions
REVERT: df2f3e423a Allow coercion of JSON lists to enum definitions
REVERT: 2b0b8165e5 Fix clang-tidy errors
REVERT: 6597bc1920 Change the CI build image location
REVERT: 360c988452 Remove illegal duplicate keys in .gitlab-ci.yml
REVERT: 6a5d69c64b Add missing par opt versions of coercion functions
REVERT: 63014e3d8f Don't propagate annotations into annotation calls. Avoids infinite recursion.
REVERT: 54b19428ab Don't use GRB_INT_PAR_NONCONVEX if it's undefined
REVERT: a5bb56c47d Added piecewise_linear for non-continuous intervals

git-subtree-dir: software/minizinc
git-subtree-split: 93be33a6c254e54be7cd38abb7ebd6a6022f0c46

Changed files
+1216 -2474
cmake
docs
include
lib
share
solvers
tests
+9 -9
.gitlab-ci.yml
··· 8 8 - sh download.sh vendor master vendor:${MZNARCH} vendor.zip 9 9 - unzip -q vendor.zip 10 10 11 - .download_vendor_win: &download_vendor_win 11 + .download_vendor: &download_vendor_win 12 12 - curl -o download.sh --location --header "PRIVATE-TOKEN:%ACCESS_TOKEN%" --silent https://gitlab.com/api/v4/snippets/1796163/raw 13 13 - dos2unix download.sh 14 14 - sh download.sh vendor master vendor:%MZNARCH% vendor.zip ··· 19 19 - sh download.sh vendor master bundle:${MZNARCH} vendor.zip 20 20 - unzip -q vendor.zip 21 21 22 - .download_bundle_win: &download_bundle_win 22 + .download_bundle: &download_bundle_win 23 23 - curl -o download.sh --location --header "PRIVATE-TOKEN:%ACCESS_TOKEN%" --silent https://gitlab.com/api/v4/snippets/1796163/raw 24 24 - dos2unix download.sh 25 25 - sh download.sh vendor master bundle:%MZNARCH% vendor.zip ··· 51 51 52 52 build:linux: 53 53 extends: .build 54 - image: minizinc/build-environment:cpp 54 + image: dekker1/minibuild:cpp 55 55 variables: 56 56 MZNARCH: "linux" 57 57 CMAKE_ARCH: "Ninja" ··· 59 59 60 60 build:musl: 61 61 extends: .build 62 - image: minizinc/build-environment:alpine 62 + image: dekker1/minibuild:alpine 63 63 variables: 64 64 MZNARCH: "musl" 65 65 CMAKE_ARCH: "Ninja" ··· 118 118 119 119 test:format: 120 120 stage: test 121 - image: minizinc/build-environment:clang-format 121 + image: dekker1/minibuild:clang-format 122 122 script: 123 123 - cmake -S . -B build -GNinja -DCLANG_FORMAT_EXECUTABLE="run-clang-format" -DCLANG_FORMAT_FLAGS="--color always" 124 124 - cmake --build build --target format ··· 134 134 test:analyse: 135 135 extends: .build 136 136 stage: test 137 - image: minizinc/build-environment:clang-tidy 137 + image: dekker1/minibuild:clang-tidy 138 138 variables: 139 139 MZNARCH: "linux" 140 140 CMAKE_ARCH: "Ninja" ··· 158 158 before_script: 159 159 - *download_bundle 160 160 # TODO: Add gecode configuration to the Gecode solver 161 - - 'echo ''{"id":"org.gecode.gecode","name":"Gecode","description":"Gecode FlatZinc executable","version":"6.1.1","mznlib":"share/gecode/mznlib","executable":"bin/fzn-gecode","tags":["cp","int","float","set","restart"],"stdFlags":["-a","-f","-n","-p","-r","-s","-t"],"extraFlags":[["-c-d","Recomputation commit distance","int","8"],["-a-d","Recomputation adaption distance","int","2"],["-decay","Decay factor","float","0.99"],["-node","Node cutoff","int","0"],["-fail","Failure cutoff","int","0"],["-restart","Restart sequence type","opt:none:constant:linear:luby:geometric","none"],["-restart-base","Base for geometric restart sequence","float","1.5"],["-restart-scale","Scale factor for restart sequence","int","250"],["-nogoods","Use no-goods from restarts","bool","false"],["-nogoods-limit","Depth limit for no-good extraction","int","128"]],"supportsMzn":false,"supportsFzn":true,"needsSolns2Out":true,"needsMznExecutable":false,"needsStdlibDir":false,"isGUIApplication":false}'' > vendor/gecode/gecode.msc' 161 + - "echo '{\"id\":\"org.gecode.gecode\",\"name\":\"Gecode\",\"description\":\"Gecode FlatZinc executable\",\"version\":\"6.1.1\",\"mznlib\":\"share/gecode/mznlib\",\"executable\":\"bin/fzn-gecode\",\"tags\":[\"cp\",\"int\",\"float\",\"set\",\"restart\"],\"stdFlags\":[\"-a\",\"-f\",\"-n\",\"-p\",\"-r\",\"-s\",\"-t\"],\"extraFlags\":[[\"-c-d\",\"Recomputation commit distance\",\"int\",\"8\"],[\"-a-d\",\"Recomputation adaption distance\",\"int\",\"2\"],[\"-decay\",\"Decay factor\",\"float\",\"0.99\"],[\"-node\",\"Node cutoff\",\"int\",\"0\"],[\"-fail\",\"Failure cutoff\",\"int\",\"0\"],[\"-restart\",\"Restart sequence type\",\"opt:none:constant:linear:luby:geometric\",\"none\"],[\"-restart-base\",\"Base for geometric restart sequence\",\"float\",\"1.5\"],[\"-restart-scale\",\"Scale factor for restart sequence\",\"int\",\"250\"],[\"-nogoods\",\"Use no-goods from restarts\",\"bool\",\"false\"],[\"-nogoods-limit\",\"Depth limit for no-good extraction\",\"int\",\"128\"]],\"supportsMzn\":false,\"supportsFzn\":true,\"needsSolns2Out\":true,\"needsMznExecutable\":false,\"needsStdlibDir\":false,\"isGUIApplication\":false}' > vendor/gecode/gecode.msc" 162 162 - export PATH=$CI_PROJECT_DIR/minizinc/bin:$PATH 163 163 - minizinc --solvers 164 164 - cd tests ··· 170 170 artifacts: 171 171 when: always 172 172 paths: 173 - - tests/output 173 + - tests/output 174 174 reports: 175 175 junit: tests/output/junit*.xml 176 176 cache: ··· 213 213 - call env\Scripts\activate.bat 214 214 - pip install -r requirements.txt 215 215 after_script: 216 - - "echo Test results at https://minizinc.gitlab.io/-/minizinc/-/jobs/%CI_JOB_ID%/artifacts/tests/output/report.html" 216 + - 'echo Test results at https://minizinc.gitlab.io/-/minizinc/-/jobs/%CI_JOB_ID%/artifacts/tests/output/report.html' 217 217 tags: [win64] 218 218 dependencies: ["build:win64"] 219 219 needs: ["build:win64"]
+1 -1
CMakeLists.txt
··· 5 5 # -- Project information and versioning. 6 6 7 7 project(libminizinc 8 - VERSION 2.5.5 8 + VERSION 2.5.4 9 9 LANGUAGES CXX C) 10 10 11 11 if(NOT BUILD_REF)
-104
changes.rst
··· 4 4 For detailed bug reports consult the issue tracker at 5 5 https://github.com/MiniZinc/libminizinc/issues. 6 6 7 - .. _v2.5.5: 8 - 9 - `Version 2.5.5 <https://github.com/MiniZinc/MiniZincIDE/releases/tag/2.5.5>`__ 10 - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 11 - 12 - (released 19 March 2021) 13 - 14 - Changes: 15 - ^^^^^^^^ 16 - 17 - - Make min/max on an array of optional variables return a non-optional var, 18 - behaving as if absent values are not in the array. 19 - 20 - Bug fixes: 21 - ^^^^^^^^^^ 22 - 23 - - Insert par array literals in the common subexpression elimination map, fixing 24 - a FlatZinc code bloat issue (:bugref:`458`). 25 - 26 - Changes in the IDE: 27 - ^^^^^^^^^^^^^^^^^^^ 28 - 29 - - Fix editing of custom string parameters so they don't get converted to 30 - floats. 31 - - Fix crash on Windows caused when the ``PATH`` environment contains unicode 32 - characters. 33 - 34 - .. _v2.5.4: 35 - 36 - `Version 2.5.4 <https://github.com/MiniZinc/MiniZincIDE/releases/tag/2.5.4>`__ 37 - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 38 - 39 - (released 16 March 2021) 40 - 41 - Changes: 42 - ^^^^^^^^ 43 - 44 - - Allow empty arrays in global cardinality constraints (:bugref:`440`). 45 - - Add piecewise_linear for non-continuous intervals. 46 - - Fail on empty variable domains in agenda. 47 - - Allow coercion of JSON lists to enum definitions (:bugref:`441`). 48 - - Update strictly_decreasing with documentation and opt version (:bugref:`454`). 49 - - Remove MIP-specific ``fzn_less(eq)_bool(_reif).mzn``. 50 - - Add ``mzn_in_symmetry_breaking_constraint()`` for internal use. 51 - - Add MIP decompositions for ``lex_less[eq]_*``. 52 - - Add ``lex_chain_*`` globals, and use them in ``lex2[_strict]``. 53 - - Improve detection of variable declarations which are actually par to allow 54 - more use of overloaded par versions of predicates. 55 - - Update documentation on installation of OR-Tools. 56 - - Report CPU time in ``solveTime`` statistic for MIP solvers. 57 - 58 - Bug fixes: 59 - ^^^^^^^^^^ 60 - 61 - - Fix handling of bad Xpress licenses when collecting extra flags. 62 - - Don't propagate annotations into annotation calls to infinite recursion. 63 - - Add missing par opt versions of coercion functions. 64 - - Revert incorrect renaming of ``has_output_item`` to ``has_outputItem`` in 65 - model interface output. 66 - - Fix incorrect grammar specification in documentation (:bugref:`453`). 67 - - Fix crash when defining enums with no members (:bugref:`443`, :bugref:`444`). 68 - - Support undefined enums in the type checker. 69 - - Fix CPLEX solver ID in documentation. 70 - - Never insert par expressions in the common subexpression elimination map. 71 - - Fix cv flag propagation when the body of a let or function is cv. 72 - - Fix equality test for annotations involving indirection. 73 - - Don't modify the infinite domain of optional variables (:bugref:`456`). 74 - - Don't immediately evaluate output_only arrays when generating dzn output. 75 - - Coerce boolean objectives to integers. 76 - - Don't create copies of global declarations when creating par versions of 77 - functions. 78 - - Compile infinite domains with holes into constraints (:bugref:`457`). 79 - - Use generic flattening inside generators, disallowing free boolean variables 80 - inside ``in`` expressions (:bugref:`451`). 81 - - Strip library paths from includes in multi-pass compilation (:bugref:`455`). 82 - - Canonicalise file names of includes to ensure the same file is not included 83 - multiple times. 84 - - Escape paths in printed ``include`` items, fixing backslash problems on 85 - Windows. 86 - - Follow ids to declarations when flattening par arrays (:bugref:`448`). 87 - - Ignore par constants during chain compression. 88 - - Fix flattening of all-par set literals. 89 - 90 - Changes in the IDE: 91 - ^^^^^^^^^^^^^^^^^^^ 92 - 93 - - Fix possible crash due to incorrect use of WriteFile on Windows. 94 - - Ensure Gecode Gist dependencies are present in the Linux bundle and AppImage 95 - (:idebugref:`132`). 96 - - Fix crash when stopping solver during exit. 97 - - Don't show irrelevant context menu entries in the project explorer. 98 - - Add support for HTTP/S links in the output pane. 99 - - Fix crash when saving CP Profiler executions where there is no info 100 - associated with a node. 101 - - Show a warning when there are open files which are not part of a MOOC 102 - submission. 103 - - Fix double spinbox precision issues (:idebugref:`134`). 104 - - Include Gecode Gist and CP Profiler dependencies in Snap package. 105 - - Allow opening of multiple files through the open file menu option. 106 - - Ensure file dialogs save last path when opening files. 107 - - Make the escape key close the find/replace dialog when focussed on any child 108 - widget. 109 - - Allow setting MOOC submission items as mandatory. 110 - 111 7 .. _v2.5.3: 112 8 113 9 `Version 2.5.3 <https://github.com/MiniZinc/MiniZincIDE/releases/tag/2.5.3>`__
+1 -1
cmake/modules/FindCPlex.cmake
··· 61 61 FOUND_VAR CPLEX_FOUND 62 62 REQUIRED_VARS CPLEX_INCLUDE CPLEX_LIBRARY 63 63 VERSION_VAR CPLEX_VERSION 64 - FAIL_MESSAGE "Could NOT find CPlex, use CPlex_ROOT to hint its location" 64 + FAIL_MESSAGE "Could NOT find CPlex, use CPLEX_ROOT to hint its location" 65 65 ) 66 66 67 67 if(CPLEX_PLUGIN AND HAS_WINDOWS_H AND NOT HAS_DLFCN_H)
+1 -1
cmake/modules/FindGurobi.cmake
··· 69 69 FOUND_VAR GUROBI_FOUND 70 70 REQUIRED_VARS GUROBI_INCLUDE GUROBI_LIBRARY 71 71 VERSION_VAR GUROBI_VERSION 72 - FAIL_MESSAGE "Could NOT find Gurobi, use Gurobi_ROOT to hint its location" 72 + FAIL_MESSAGE "Could NOT find Gurobi, use GUROBI_ROOT to hint its location" 73 73 ) 74 74 75 75 if(GUROBI_PLUGIN AND HAS_WINDOWS_H AND NOT HAS_DLFCN_H)
-3
cmake/targets/libminizinc_osicbc.cmake
··· 13 13 ) 14 14 target_include_directories(minizinc_osicbc PRIVATE ${OSICBC_INCLUDE_DIRS}) 15 15 add_dependencies(minizinc_osicbc minizinc_mip) 16 - if (UNIX AND NOT WIN32) 17 - target_compile_definitions(minizinc_osicbc PRIVATE HAVE_CONFIG_H) 18 - endif() 19 16 20 17 ### Setup correct compilation into the MiniZinc library 21 18 target_compile_definitions(mzn PRIVATE HAS_OSICBC)
+1 -1
docs/chi/conf.py
··· 73 73 # The short X.Y version. 74 74 version = '2.5' 75 75 # The full version, including alpha/beta/rc tags. 76 - release = '2.5.5' 76 + release = '2.5.4' 77 77 78 78 # The language for content autogenerated by Sphinx. Refer to documentation 79 79 # for a list of supported languages.
+2 -2
docs/en/command_line.rst
··· 511 511 512 512 { 513 513 "mzn_solver_path": ["/usr/share/choco"], 514 - "tagDefaults": [["cp","org.choco-solver.choco"],["mip","org.minizinc.mip.cplex"],["","org.gecode.gecode"]], 515 - "solverDefaults": [["org.minizinc.mip.cplex","--cplex-dll","/opt/CPLEX_Studio128/cplex/bin/x86-64_sles10_4.1/libcplex128.so"]] 514 + "tagDefaults": [["cp","org.choco-solver.choco"],["mip","org.minizinc.cplex"],["","org.gecode.gecode"]], 515 + "solverDefaults": [["org.minizinc.cplex","--cplex-dll","/opt/CPLEX_Studio128/cplex/bin/x86-64_sles10_4.1/libcplex128.so"]] 516 516 } 517 517 518 518 Configuration values in the user-specific configuration file override the global values, except for solver default arguments, which are only overridden if the name of the option is the same, and otherwise get added to the command line.
+1 -1
docs/en/conf.py
··· 73 73 # The short X.Y version. 74 74 version = '2.5' 75 75 # The full version, including alpha/beta/rc tags. 76 - release = '2.5.5' 76 + release = '2.5.4' 77 77 78 78 # The language for content autogenerated by Sphinx. Refer to documentation 79 79 # for a list of supported languages.
+2 -2
docs/en/grammar.mzn
··· 35 35 <assign-item> ::= <ident> "=" <expr> 36 36 37 37 % Constraint items 38 - <constraint-item> ::= "constraint" [ <string-annotation> ] <expr> 38 + <constraint-item> ::= "constraint" <string-annotation> <expr> 39 39 40 40 % Solve item 41 41 <solve-item> ::= "solve" <annotations> "satisfy" ··· 80 80 | <base-type> 81 81 | <ti-variable-expr-tail> 82 82 | "ann" 83 - | "{" <expr> "," ... "}" 83 + | { <expr> "," ... } 84 84 | <num-expr> ".." <num-expr> 85 85 86 86 % Type-inst variables
+2 -4
docs/en/installation_detailed_linux.rst
··· 86 86 87 87 You can install the OR-Tools FlatZinc module as binary or obtain the source code from GitHub (https://github.com/google/or-tools). 88 88 You can find detailed compilation instructions for OR-Tools on https://developers.google.com/optimization/. 89 - Since version 8, `cmake` is supported, see the instructions. Previously, to compile the FlatZinc module from source, 90 - run the following in a terminal (from within the OR-Tools source code directory): 89 + To compile the FlatZinc module from source, run the following in a terminal (from within the OR-Tools source code directory): 91 90 92 91 .. code-block:: bash 93 92 94 93 make fz -j8 95 94 make test_fz 96 95 97 - Since version 8, `cmake --build . --target install` puts a solver configuration file in `/usr/share/minizinc`, so the MiniZinc finds 98 - OR-Tools automatically. With earlier versions, in order to use OR-Tools with MiniZinc, you have to create an appropriate solver configuration file. 96 + In order to use OR-Tools with MiniZinc, you have to create an appropriate solver configuration file. 99 97 Add a file ``ortools.msc`` in an appropriate location (see :ref:`sec-cmdline-conffiles`) containing the following, 100 98 where you replace ``<INSTALLATION_PREFIX>`` with the actual installation path and update the version number if necessary: 101 99
+1 -5
docs/en/solvers.rst
··· 143 143 -DfIndConstr=true -DfMIPdomains=false %% Use solver's indicator constraints, see below 144 144 -DMinMaxGeneral=true %% Send min/max constraints to the solver (Gurobi only) 145 145 -DQuadrFloat=false -DQuadrInt=false %% Not forward float/integer multiplications for MIQCP backends, see below 146 - -DUseCumulative=false %% Not forward cumulative with fixed durations/resources (SCIP only) 147 - -DUseOrbisack=false %% Not forward lex_lesseq for binary/bool vectors (SCIP only) 148 - -DOrbisackAlwaysModelConstraint=true %% lex_lesseq ignores being in symmetry_breaking_constraint() (SCIP only) 149 - %% Required for SCIP 7.0.2, or use patch: http://listserv.zib.de/pipermail/scip/2021-February/004213.html 150 - -DUseOrbitope=false %% Not forward lex_chain_lesseq for binary/bool matrices (SCIP only) 146 + -DCumulative=false %% Not forward cumulative with fixed durations/resources (SCIP only) 151 147 --no-half-reifications %% Turn off halfreification (full reification was until v2.2.3) 152 148 153 149 Some Solver Options and Changed Default Values
+11 -11
include/minizinc/MIPdomains.hh
··· 22 22 #define _CRT_SECURE_NO_WARNINGS 23 23 #endif 24 24 25 - #define MZN_MIPD_assert_soft(c, e) \ 25 + #define MZN_MIPD__assert_soft(c, e) \ 26 26 do { \ 27 27 static int nn = 0; \ 28 28 if (!(c)) \ 29 29 if (++nn <= 1) std::cerr << e << std::endl; /* NOLINT(bugprone-macro-parentheses) */ \ 30 30 } while (0) 31 - #define MZN_MIPD_assert_hard(c) MZN_ASSERT_HARD(c) 32 - #define MZN_MIPD_assert_hard_msg(c, e) MZN_ASSERT_HARD_MSG(c, e) 33 - #define MZN_MIPD_FLATTENING_ERROR_IF_NOT(cond, envi, loc, msg) \ 34 - do { \ 35 - if (!(cond)) { \ 36 - std::ostringstream oss; \ 37 - oss << msg; /* NOLINT(bugprone-macro-parentheses) */ \ 38 - throw FlatteningError(envi, loc, oss.str()); \ 39 - } \ 31 + #define MZN_MIPD__assert_hard(c) MZN_ASSERT_HARD(c) 32 + #define MZN_MIPD__assert_hard_msg(c, e) MZN_ASSERT_HARD_MSG(c, e) 33 + #define MZN_MIPD__FLATTENING_ERROR__IF_NOT(cond, envi, loc, msg) \ 34 + do { \ 35 + if (!(cond)) { \ 36 + std::ostringstream oss; \ 37 + oss << msg; /* NOLINT(bugprone-macro-parentheses) */ \ 38 + throw FlatteningError(envi, loc, oss.str()); \ 39 + } \ 40 40 } while (0) 41 - #define MZN_MIPD_ASSERT_FOR_SAT(cond, envi, loc, msg) \ 41 + #define MZN_MIPD__ASSERT_FOR_SAT(cond, envi, loc, msg) \ 42 42 do { \ 43 43 if (!(cond)) { \ 44 44 std::ostringstream oss; \
-2
include/minizinc/ast.hh
··· 1838 1838 ASTString set_card; // NOLINT(readability-identifier-naming) 1839 1839 ASTString pow; 1840 1840 1841 - ASTString mzn_set_in_internal; // NOLINT(readability-identifier-naming) 1842 - 1843 1841 ASTString introduced_var; // NOLINT(readability-identifier-naming) 1844 1842 ASTString anonEnumFromStrings; 1845 1843 } ids;
+6 -12
include/minizinc/eval_par.hh
··· 87 87 public: 88 88 /// Evaluate bool expression that may contain variables 89 89 static bool evalBoolCV(EnvI& env, Expression* e); 90 - /// Flatten expression that may contain variables 91 - static KeepAlive flattenCV(EnvI& env, Expression* e); 92 90 }; 93 91 94 92 template <class Eval> ··· 124 122 KeepAlive nextin; 125 123 Expression* gen_in = e->in(gen + 1); 126 124 if (gen_in->type().isvar() || gen_in->type().cv()) { 127 - gen_in = eval.flattenCV(env, e->in(gen + 1))(); 125 + gen_in = eval.flatten(env, e->in(gen + 1)); 128 126 } 129 127 if (gen_in->type().dim() == 0) { 130 128 GCLock lock; ··· 156 154 CallStackItem csi(env, e->decl(gen, id)->id(), i); 157 155 if (in() == nullptr) { 158 156 // this is an assignment generator 159 - Expression* asn; 160 - if (e->where(gen)->type().isvar() || e->where(gen)->type().cv()) { 161 - asn = eval.flattenCV(env, e->where(gen))(); 162 - } else { 163 - asn = eval_par(env, e->where(gen)); 164 - } 157 + Expression* asn = e->where(gen)->type().isPar() ? eval_par(env, e->where(gen)) 158 + : eval.flatten(env, e->where(gen)); 165 159 e->decl(gen, id)->e(asn); 166 160 e->rehash(); 167 161 } else { ··· 184 178 KeepAlive nextin; 185 179 Expression* gen_in = e->in(gen + 1); 186 180 if (gen_in->type().isvar() || gen_in->type().cv()) { 187 - gen_in = eval.flattenCV(env, e->in(gen + 1))(); 181 + gen_in = eval.flatten(env, e->in(gen + 1)); 188 182 } 189 183 if (gen_in->type().dim() == 0) { 190 184 GCLock lock; ··· 269 263 in = new SetLit(Location(), eval_intset(env, e->in(0))); 270 264 } 271 265 } else { 272 - if (e->in(0)->type().isvar() || e->in(0)->type().cv()) { 273 - in = eval_array_lit(env, eval.flattenCV(env, e->in(0))()); 266 + if (e->in(0)->type().isvar()) { 267 + in = eval_array_lit(env, eval.flatten(env, e->in(0))); 274 268 } else { 275 269 in = eval_array_lit(env, e->in(0)); 276 270 }
-1
include/minizinc/flatten_internal.hh
··· 109 109 std::vector<int> modifiedVarDecls; 110 110 std::unordered_set<std::string> deprecationWarnings; 111 111 int inRedundantConstraint; 112 - int inSymmetryBreakingConstraint; 113 112 int inMaybePartial; 114 113 struct { 115 114 int reifConstraints;
+2 -2
include/minizinc/output.hh
··· 36 36 /// Remove all links to variables in flat model from output model in \a env 37 37 void cleanup_output(EnvI& env); 38 38 39 - ArrayLit* create_json_output(EnvI& env, bool outputObjective, bool includeOutputItem, 40 - bool hasChecker); 39 + ArrayLit* create__json_output(EnvI& env, bool outputObjective, bool includeOutputItem, 40 + bool hasChecker); 41 41 42 42 } // namespace MiniZinc
+4 -1
include/minizinc/param_config.hh
··· 9 9 * License, v. 2.0. If a copy of the MPL was not distributed with this 10 10 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 11 11 12 - #pragma once 12 + #ifndef __MINIZINC_PARAM_CONFIG_HH__ 13 + #define __MINIZINC_PARAM_CONFIG_HH__ 13 14 14 15 #include <minizinc/ast.hh> 15 16 #include <minizinc/solver_config.hh> ··· 56 57 const char* what() const throw() override { return "MiniZinc: solver parameter error"; } 57 58 }; 58 59 } // namespace MiniZinc 60 + 61 + #endif
+3 -7
include/minizinc/parser.hh
··· 75 75 class ParserState { 76 76 public: 77 77 ParserState(const std::string& f, const std::string& b, std::ostream& err0, 78 - const std::vector<std::string>& includePaths0, std::vector<ParseWorkItem>& files0, 79 - std::map<std::string, Model*>& seenModels0, MiniZinc::Model* model0, bool isDatafile0, 80 - bool isFlatZinc0, bool isSTDLib0, bool parseDocComments0) 78 + std::vector<ParseWorkItem>& files0, std::map<std::string, Model*>& seenModels0, 79 + MiniZinc::Model* model0, bool isDatafile0, bool isFlatZinc0, bool isSTDLib0, 80 + bool parseDocComments0) 81 81 : filename(f.c_str()), 82 82 buf(b.c_str()), 83 83 pos(0), ··· 85 85 lineStartPos(0), 86 86 nTokenNextStart(1), 87 87 hadNewline(false), 88 - includePaths(includePaths0), 89 88 files(files0), 90 89 seenModels(seenModels0), 91 90 model(model0), ··· 106 105 int nTokenNextStart; 107 106 bool hadNewline; 108 107 109 - const std::vector<std::string>& includePaths; 110 108 std::vector<ParseWorkItem>& files; 111 109 std::map<std::string, Model*>& seenModels; 112 110 MiniZinc::Model* model; ··· 150 148 pos += num; 151 149 return num; 152 150 } 153 - 154 - std::string canonicalFilename(const std::string& f) const; 155 151 }; 156 152 157 153 Model* parse(Env& env, const std::vector<std::string>& filename,
+1
include/minizinc/process.hh
··· 13 13 14 14 #include <minizinc/solver.hh> 15 15 16 + const auto SolverInstance__ERROR = MiniZinc::SolverInstance::ERROR; // before windows.h 16 17 #ifdef _WIN32 17 18 #define NOMINMAX 18 19 #include <Windows.h>
+1 -1
include/minizinc/solns2out.hh
··· 76 76 const char* const searchCompleteMsgDef = "=========="; 77 77 /// Output values 78 78 std::string solutionSeparator = solutionSeparatorDef; 79 - std::string solutionComma; 79 + std::string solutionComma = ""; 80 80 std::string unsatisfiableMsg = unsatisfiableMsgDef; 81 81 std::string unboundedMsg = unboundedMsgDef; 82 82 std::string unsatorunbndMsg = unsatorunbndMsgDef;
+1 -1
include/minizinc/solver_instance.hh
··· 33 33 enum StatusReason { SR_OK = -5, SR_TIME, SR_MEMORY, SR_LIMIT, SR_ERROR }; 34 34 }; 35 35 36 - const SolverInstance::Status SolverInstanceError = SolverInstance::ERROR; // just in case... 36 + const SolverInstance::Status SolverInstance__ERROR = SolverInstance::ERROR; // just in case... 37 37 38 38 } // namespace MiniZinc
-27
include/minizinc/solvers/MIP/MIP_scip_wrap.hh
··· 21 21 #include <scip/scipdefplugins.h> 22 22 23 23 #ifndef _WIN32 24 - // NOLINTNEXTLINE(bugprone-reserved-identifier) 25 24 #define __stdcall 26 25 #endif 27 26 ··· 106 105 SCIP_RETCODE(__stdcall* SCIPcreateConsBasicCumulative) 107 106 (SCIP* scip, SCIP_CONS** cons, const char* name, int nvars, SCIP_VAR** vars, int* durations, 108 107 int* demands, int capacity); 109 - 110 - // NOLINTNEXTLINE(readability-identifier-naming) 111 - SCIP_RETCODE(__stdcall* SCIPcreateConsBasicOrbisack) 112 - (SCIP* scip, SCIP_CONS** cons, const char* name, SCIP_VAR** vars1, SCIP_VAR** vars2, int nrows, 113 - SCIP_Bool ispporbisack, SCIP_Bool isparttype, SCIP_Bool ismodelcons); 114 - 115 - // NOLINTNEXTLINE(readability-identifier-naming) 116 - SCIP_RETCODE(__stdcall* SCIPcreateConsBasicOrbitope) 117 - (SCIP* scip, /**< SCIP data structure */ 118 - SCIP_CONS** cons, /**< pointer to hold the created constraint */ 119 - const char* name, /**< name of constraint */ 120 - SCIP_VAR*** vars, /**< matrix of variables on which the symmetry acts */ 121 - SCIP_ORBITOPETYPE orbitopetype, /**< type of orbitope constraint */ 122 - int nspcons, /**< number of set partitioning/packing constraints <=> p */ 123 - int nblocks, /**< number of symmetric variable blocks <=> q */ 124 - SCIP_Bool resolveprop, /**< should propagation be resolved? */ 125 - SCIP_Bool ismodelcons /**< whether the orbitope is a model constraint */ 126 - ); 127 - 128 108 // NOLINTNEXTLINE(readability-identifier-naming) 129 109 SCIP_Longint(__stdcall* SCIPgetNSolsFound)(SCIP* scip); 130 110 // NOLINTNEXTLINE(readability-identifier-naming) ··· 378 358 /// Cumulative, currently SCIP only 379 359 void addCumulative(int nnz, int* rmatind, double* d, double* r, double b, 380 360 const std::string& rowName = "") override; 381 - 382 - /// Lex-lesseq binary, currently SCIP only 383 - void addLexLesseq(int nnz, int* rmatind1, int* rmatind2, bool isModelCons, 384 - const std::string& rowName = "") override; 385 - 386 - void addLexChainLesseq(int m, int n, int* rmatind, int nOrbitopeType, bool resolveprop, 387 - bool isModelCons, const std::string& rowName = "") override; 388 361 389 362 /// Times constraint: var[x]*var[y] == var[z] 390 363 void addTimes(int x, int y, int z, const std::string& rowName = "") override;
+3 -43
include/minizinc/solvers/MIP/MIP_solverinstance.hpp
··· 544 544 }; 545 545 env.outstream.setf(std::ios::fixed); 546 546 env.outstream.precision(4); 547 - env.outstream << "%%%mzn-stat: solveTime=" << _mipWrapper->getCPUTime() << std::endl; 547 + env.outstream << "%%%mzn-stat: solveTime=" << _mipWrapper->getWallTimeElapsed() << std::endl; 548 548 ; 549 549 env.outstream.copyfmt(oldState); 550 550 ··· 979 979 void p_cumulative(SolverInstanceBase& si, const Call* call) { 980 980 auto& gi = dynamic_cast<MIPSolverinstance<MIPWrapper>&>(si); 981 981 982 + std::unique_ptr<SECCutGen> pCG(new SECCutGen(gi.getMIPWrapper())); 983 + 982 984 assert(call->argCount() == 4); 983 985 984 986 std::vector<MIPSolver::Variable> startTimes; ··· 992 994 gi.getMIPWrapper()->addCumulative( 993 995 startTimes.size(), startTimes.data(), durations.data(), demands.data(), b, 994 996 make_constraint_name("p_cumulative_", (gi.getMIPWrapper()->nAddedRows++), call)); 995 - } 996 - 997 - template <class MIPWrapper> 998 - void p_lex_lesseq_binary(SolverInstanceBase& si, const Call* call) { 999 - auto& gi = dynamic_cast<MIPSolverinstance<MIPWrapper>&>(si); 1000 - 1001 - assert(call->argCount() == 3); 1002 - 1003 - std::vector<MIPSolver::Variable> vec1; 1004 - std::vector<MIPSolver::Variable> vec2; 1005 - gi.exprToVarArray(call->arg(0), vec1); 1006 - gi.exprToVarArray(call->arg(1), vec2); 1007 - auto isModelCons = gi.exprToConst(call->arg(2)); 1008 - MZN_ASSERT_HARD(vec1.size() == vec2.size()); 1009 - 1010 - gi.getMIPWrapper()->addLexLesseq( 1011 - vec1.size(), vec1.data(), vec2.data(), (bool)isModelCons, 1012 - make_constraint_name("p_lex_lesseq__orbisack_", (gi.getMIPWrapper()->nAddedRows++), call)); 1013 - } 1014 - 1015 - template <class MIPWrapper> 1016 - void p_lex_chain_lesseq_binary(SolverInstanceBase& si, const Call* call) { 1017 - auto& gi = dynamic_cast<MIPSolverinstance<MIPWrapper>&>(si); 1018 - 1019 - assert(call->argCount() == 5); 1020 - 1021 - std::vector<MIPSolver::Variable> vars; 1022 - gi.exprToVarArray(call->arg(0), vars); 1023 - auto m = gi.exprToConst(call->arg(1)); 1024 - auto orbitopeType = gi.exprToConst(call->arg(2)); 1025 - auto resolveprop = gi.exprToConst(call->arg(3)); 1026 - auto isModelCons = gi.exprToConst(call->arg(4)); 1027 - 1028 - gi.getMIPWrapper()->addLexChainLesseq( 1029 - m, vars.size() / m, vars.data(), orbitopeType, (bool)resolveprop, (bool)isModelCons, 1030 - make_constraint_name("p_lex_lesseq__orbisack_", (gi.getMIPWrapper()->nAddedRows++), call)); 1031 997 } 1032 998 1033 999 /// The XBZ cut generator ··· 1152 1118 SCIPConstraints::p_indicator_eq_if1<MIPWrapper>); 1153 1119 1154 1120 _constraintRegistry.add("fzn_cumulative_fixed_d_r", SCIPConstraints::p_cumulative<MIPWrapper>); 1155 - 1156 - _constraintRegistry.add("fzn_lex_lesseq__orbisack", 1157 - SCIPConstraints::p_lex_lesseq_binary<MIPWrapper>); 1158 - 1159 - _constraintRegistry.add("fzn_lex_chain_lesseq__orbitope", 1160 - SCIPConstraints::p_lex_chain_lesseq_binary<MIPWrapper>); 1161 1121 1162 1122 _constraintRegistry.add("bounds_disj", SCIPConstraints::p_bounds_disj<MIPWrapper>); 1163 1123
+2 -15
include/minizinc/solvers/MIP/MIP_wrap.hh
··· 54 54 /// Lazy cut. Can cut off otherwise feasible integer solutions. 55 55 /// Callback should be able to produce previously generated cuts again if needed [Gurobi] 56 56 static const int MaskConsType_Lazy = 4; 57 - enum Status { OPT, SAT, UNSAT, UNBND, UNSATorUNBND, UNKNOWN, ERROR_STATUS }; 57 + enum Status { OPT, SAT, UNSAT, UNBND, UNSATorUNBND, UNKNOWN, __ERROR }; 58 58 59 59 /// Search strategy for the solver 60 60 enum SearchType { FIXED_SEARCH = 0, FREE_SEARCH = 1, UNIFORM_SEARCH = 2 }; ··· 102 102 LinConType sense = LQ; 103 103 double rhs = 0.0; 104 104 int mask = 0; // need to know what type of cuts are registered before solve() TODO 105 - std::string rowName; 105 + std::string rowName = ""; 106 106 void addVar(int i, double c) { 107 107 rmatind.push_back(i); 108 108 rmatval.push_back(c); ··· 282 282 const std::string& rowName = "") { 283 283 throw std::runtime_error("Cumulative constraints not supported. "); 284 284 } 285 - 286 - /// Lex-lesseq binary, currently SCIP only 287 - virtual void addLexLesseq(int nnz, int* rmatind1, int* rmatind2, bool isModelCons, 288 - const std::string& rowName = "") { 289 - throw std::runtime_error("MIP: lex_lesseq built-in not supported. "); 290 - } 291 - 292 - /// Lex-chain-lesseq binary, currently SCIP only 293 - virtual void addLexChainLesseq(int m, int n, int* rmatind, int nOrbitopeType, bool resolveprop, 294 - bool isModelCons, const std::string& rowName = "") { 295 - throw std::runtime_error("MIP: lex_chain_lesseq built-in not supported. "); 296 - } 297 - 298 285 /// 0: model-defined level, 1: free, 2: uniform search 299 286 virtual int getFreeSearch() { return SearchType::FREE_SEARCH; } 300 287 /// Return 0 if ignoring searches
+14 -14
include/minizinc/solvers/MIP/MIP_xpress_wrap.hh
··· 38 38 // NOLINTNEXTLINE(readability-identifier-naming) 39 39 int(XPRS_CC* XPRSsetlogfile)(XPRSprob prob, const char* logname); 40 40 // NOLINTNEXTLINE(readability-identifier-naming) 41 - int(XPRS_CC* XPRSsetintcontrol)(XPRSprob prob, int index, int ivalue); 41 + int(XPRS_CC* XPRSsetintcontrol)(XPRSprob prob, int _index, int _ivalue); 42 42 // NOLINTNEXTLINE(readability-identifier-naming) 43 - int(XPRS_CC* XPRSsetdblcontrol)(XPRSprob prob, int index, double dvalue); 43 + int(XPRS_CC* XPRSsetdblcontrol)(XPRSprob prob, int _index, double _dvalue); 44 44 // NOLINTNEXTLINE(readability-identifier-naming) 45 45 double(XB_CC* XPRBgetsol)(struct Xbvar* var); 46 46 // NOLINTNEXTLINE(readability-identifier-naming) 47 - int(XPRS_CC* XPRSgetintattrib)(XPRSprob prob, int index, int* ivalue); 47 + int(XPRS_CC* XPRSgetintattrib)(XPRSprob prob, int _index, int* _ivalue); 48 48 // NOLINTNEXTLINE(readability-identifier-naming) 49 - int(XPRS_CC* XPRSgetdblattrib)(XPRSprob prob, int index, double* dvalue); 49 + int(XPRS_CC* XPRSgetdblattrib)(XPRSprob prob, int _index, double* _dvalue); 50 50 // NOLINTNEXTLINE(readability-identifier-naming) 51 51 int(XB_CC* XPRBbegincb)(struct Xbprob* prob, struct xo_prob_struct* optprob); 52 52 // NOLINTNEXTLINE(readability-identifier-naming) ··· 95 95 int(XPRS_CC* XPRSgetcontrolinfo)(XPRSprob prob, const char* sCaName, int* iHeaderId, 96 96 int* iTypeinfo); 97 97 // NOLINTNEXTLINE(readability-identifier-naming) 98 - int(XPRS_CC* XPRSgetintcontrol)(XPRSprob prob, int index, int* ivalue); 98 + int(XPRS_CC* XPRSgetintcontrol)(XPRSprob prob, int _index, int* _ivalue); 99 99 // NOLINTNEXTLINE(readability-identifier-naming) 100 - int(XPRS_CC* XPRSgetintcontrol64)(XPRSprob prob, int index, XPRSint64* ivalue); 100 + int(XPRS_CC* XPRSgetintcontrol64)(XPRSprob prob, int _index, XPRSint64* _ivalue); 101 101 // NOLINTNEXTLINE(readability-identifier-naming) 102 - int(XPRS_CC* XPRSgetdblcontrol)(XPRSprob prob, int index, double* dvalue); 102 + int(XPRS_CC* XPRSgetdblcontrol)(XPRSprob prob, int _index, double* _dvalue); 103 103 // NOLINTNEXTLINE(readability-identifier-naming) 104 - int(XPRS_CC* XPRSgetstrcontrol)(XPRSprob prob, int index, char* svalue); 104 + int(XPRS_CC* XPRSgetstrcontrol)(XPRSprob prob, int _index, char* _svalue); 105 105 // NOLINTNEXTLINE(readability-identifier-naming) 106 - int(XPRS_CC* XPRSsetintcontrol64)(XPRSprob prob, int index, XPRSint64 ivalue); 106 + int(XPRS_CC* XPRSsetintcontrol64)(XPRSprob prob, int _index, XPRSint64 _ivalue); 107 107 // NOLINTNEXTLINE(readability-identifier-naming) 108 - int(XPRS_CC* XPRSgetstringcontrol)(XPRSprob prob, int index, char* svalue, int svaluesize, 109 - int* controlsize); 108 + int(XPRS_CC* XPRSgetstringcontrol)(XPRSprob prob, int _index, char* _svalue, int _svaluesize, 109 + int* _controlsize); 110 110 // NOLINTNEXTLINE(readability-identifier-naming) 111 - int(XPRS_CC* XPRSsetstrcontrol)(XPRSprob prob, int index, const char* svalue); 111 + int(XPRS_CC* XPRSsetstrcontrol)(XPRSprob prob, int _index, const char* _svalue); 112 112 113 113 private: 114 114 void loadDll(); ··· 130 130 int msgLevel = 0; 131 131 int timeout = 0; 132 132 int numSolutions = 0; 133 - std::string logFile; 134 - std::string writeModelFile; 133 + std::string logFile = ""; 134 + std::string writeModelFile = ""; 135 135 std::string writeModelFormat = "lp"; 136 136 double absGap = 0; 137 137 double relGap = 0.0001;
+11 -11
include/minizinc/utils.hh
··· 41 41 42 42 namespace MiniZinc { 43 43 44 - // #define MZN_PRINTATONCE_ 45 - #ifdef MZN_PRINTATONCE_ 46 - #define MZN_PRINT_SRCLOC(e1, e2) \ 44 + // #define __MZN_PRINTATONCE__ 45 + #ifdef __MZN_PRINTATONCE__ 46 + #define __MZN_PRINT_SRCLOC(e1, e2) \ 47 47 std::cerr << '\n' \ 48 48 << __FILE__ << ": " << __LINE__ << " (" << __func__ << "): not " << e1 << ": " \ 49 49 << std::flush; \ 50 50 std::cerr << e2 << std::endl 51 51 #else 52 - #define MZN_PRINT_SRCLOC(e1, e2) 52 + #define __MZN_PRINT_SRCLOC(e1, e2) 53 53 #endif 54 - #define MZN_ASSERT_HARD(c) \ 55 - do { \ 56 - if (!(c)) { \ 57 - MZN_PRINT_SRCLOC(#c, ""); \ 58 - throw InternalError(#c); \ 59 - } \ 54 + #define MZN_ASSERT_HARD(c) \ 55 + do { \ 56 + if (!(c)) { \ 57 + __MZN_PRINT_SRCLOC(#c, ""); \ 58 + throw InternalError(#c); \ 59 + } \ 60 60 } while (0) 61 61 #define MZN_ASSERT_HARD_MSG(c, e) \ 62 62 do { \ 63 63 if (!(c)) { \ 64 - MZN_PRINT_SRCLOC(#c, e); \ 64 + __MZN_PRINT_SRCLOC(#c, e); \ 65 65 std::ostringstream oss; \ 66 66 oss << "not " << #c << ": " << e; /* NOLINT(bugprone-macro-parentheses) */ \ 67 67 throw MiniZinc::InternalError(oss.str()); \
+297 -295
lib/MIPdomains.cpp
··· 42 42 /// TODO use integer division instead of INT_EPS 43 43 #define INT_EPS 1e-5 // the absolute epsilon for integrality of integer vars. 44 44 45 - #define MZN_MIPDOMAINS_PRINTMORESTATS 45 + #define __MZN__MIPDOMAINS__PRINTMORESTATS 46 46 #define MZN_DBG_CHECK_ITER_CUTOUT 47 47 48 - // #define MZN_DBGOUT_MIPDOMAINS 49 - #ifdef MZN_DBGOUT_MIPDOMAINS 48 + // #define __MZN__DBGOUT__MIPDOMAINS__ 49 + #ifdef __MZN__DBGOUT__MIPDOMAINS__ 50 50 #define DBGOUT_MIPD(s) std::cerr << s << std::endl 51 - #define DBGOUT_MIPD_FLUSH(s) std::cerr << s << std::flush 51 + #define DBGOUT_MIPD__(s) std::cerr << s << std::flush 52 52 #define DBGOUT_MIPD_SELF(op) op 53 53 #else 54 54 #define DBGOUT_MIPD(s) \ 55 55 do { \ 56 56 } while (false) 57 - #define DBGOUT_MIPD_FLUSH(s) \ 58 - do { \ 57 + #define DBGOUT_MIPD__(s) \ 58 + do { \ 59 59 } while (false) 60 60 #define DBGOUT_MIPD_SELF(op) \ 61 61 do { \ ··· 64 64 65 65 namespace MiniZinc { 66 66 67 - enum EnumStatIdx_MIPD { 68 - N_POSTs_all, // N all POSTs in the model 69 - N_POSTs_intCmpReif, 70 - N_POSTs_floatCmpReif, // in detail 71 - N_POSTs_intNE, 72 - N_POSTs_floatNE, 73 - N_POSTs_setIn, 74 - N_POSTs_domain, 75 - N_POSTs_setInReif, 76 - N_POSTs_eq_encode, 77 - N_POSTs_intAux, 78 - N_POSTs_floatAux, 67 + enum EnumStatIdx__MIPD { 68 + N_POSTs__all, // N all POSTs in the model 69 + N_POSTs__intCmpReif, 70 + N_POSTs__floatCmpReif, // in detail 71 + N_POSTs__intNE, 72 + N_POSTs__floatNE, 73 + N_POSTs__setIn, 74 + N_POSTs__domain, 75 + N_POSTs__setInReif, 76 + N_POSTs__eq_encode, 77 + N_POSTs__intAux, 78 + N_POSTs__floatAux, 79 79 // Kind of equality connections between involved variables 80 - N_POSTs_eq2intlineq, 81 - N_POSTs_eq2floatlineq, 82 - N_POSTs_int2float, 83 - N_POSTs_internalvarredef, 84 - N_POSTs_initexpr1id, 85 - N_POSTs_initexpr1linexp, 86 - N_POSTs_initexprN, 87 - N_POSTs_eqNlineq, 88 - N_POSTs_eqNmapsize, 80 + N_POSTs__eq2intlineq, 81 + N_POSTs__eq2floatlineq, 82 + N_POSTs__int2float, 83 + N_POSTs__internalvarredef, 84 + N_POSTs__initexpr1id, 85 + N_POSTs__initexpr1linexp, 86 + N_POSTs__initexprN, 87 + N_POSTs__eqNlineq, 88 + N_POSTs__eqNmapsize, 89 89 // other 90 - N_POSTs_varsDirect, 91 - N_POSTs_varsInvolved, 92 - N_POSTs_NSubintvMin, 93 - N_POSTs_NSubintvSum, 94 - N_POSTs_NSubintvMax, // as N subintervals 95 - N_POSTs_SubSizeMin, 96 - N_POSTs_SubSizeSum, 97 - N_POSTs_SubSizeMax, // subintv. size 98 - N_POSTs_linCoefMin, 99 - N_POSTs_linCoefMax, 100 - N_POSTs_cliquesWithEqEncode, 101 - N_POSTs_clEEEnforced, 102 - N_POSTs_clEEFound, 103 - N_POSTs_size 90 + N_POSTs__varsDirect, 91 + N_POSTs__varsInvolved, 92 + N_POSTs__NSubintvMin, 93 + N_POSTs__NSubintvSum, 94 + N_POSTs__NSubintvMax, // as N subintervals 95 + N_POSTs__SubSizeMin, 96 + N_POSTs__SubSizeSum, 97 + N_POSTs__SubSizeMax, // subintv. size 98 + N_POSTs__linCoefMin, 99 + N_POSTs__linCoefMax, 100 + N_POSTs__cliquesWithEqEncode, 101 + N_POSTs__clEEEnforced, 102 + N_POSTs__clEEFound, 103 + N_POSTs__size 104 104 }; 105 - extern std::vector<double> MIPD_stats; 105 + extern std::vector<double> MIPD__stats; 106 106 107 107 enum EnumReifType { RIT_None, RIT_Static, RIT_Reif, RIT_Halfreif }; 108 108 enum EnumConstrType { CT_None, CT_Comparison, CT_SetIn, CT_Encode }; ··· 134 134 FunctionI*& pfi; 135 135 // double dEps = -1.0; 136 136 DCT(const char* fn, const std::vector<Type>& prm, EnumReifType er, EnumConstrType ec, 137 - EnumCmpType ecmp, EnumVarType ev, FunctionI*& pfi_) 137 + EnumCmpType ecmp, EnumVarType ev, FunctionI*& pfi__) 138 138 : sFuncName(fn), 139 139 aParams(prm), 140 140 nReifType(er), 141 141 nConstrType(ec), 142 142 nCmpType(ecmp), 143 143 nVarType(ev), 144 - pfi(pfi_) {} 144 + pfi(pfi__) {} 145 145 }; 146 146 147 147 template <class N> ··· 266 266 // double rhs; 267 267 // }; 268 268 269 - std::vector<double> MIPD_stats(N_POSTs_size); 269 + std::vector<double> MIPD__stats(N_POSTs__size); 270 270 271 271 template <class T> 272 272 static std::vector<T> make_vec(T t1, T t2) { ··· 299 299 const double dMaxNValueDensity = 3.0; // Maximal ratio cardInt() / size() of a domain 300 300 // to enforce ee 301 301 bool doMIPdomains() { 302 - MIPD_stats[N_POSTs_NSubintvMin] = 1e100; 303 - MIPD_stats[N_POSTs_SubSizeMin] = 1e100; 302 + MIPD__stats[N_POSTs__NSubintvMin] = 1e100; 303 + MIPD__stats[N_POSTs__SubSizeMin] = 1e100; 304 304 305 305 if (!registerLinearConstraintDecls()) { 306 306 return true; ··· 325 325 private: 326 326 Env* _env = nullptr; 327 327 Env* getEnv() { 328 - MZN_MIPD_assert_hard(_env); 328 + MZN_MIPD__assert_hard(_env); 329 329 return _env; 330 330 } 331 331 ··· 354 354 // NOLINTNEXTLINE(readability-identifier-naming) 355 355 std::vector<Type> t_VIVF = make_vec(Type::varint(), Type::varfloat()); 356 356 357 - // double float_lt_EPS_coef_ = 1e-5; 357 + // double float_lt_EPS_coef__ = 1e-5; 358 358 359 359 bool registerLinearConstraintDecls() { 360 360 EnvI& env = getEnv()->envi(); ··· 362 362 363 363 int_lin_eq = env.model->matchFn(env, constants().ids.int_.lin_eq, int_lin_eq_t, false); 364 364 DBGOUT_MIPD(" int_lin_eq = " << int_lin_eq); 365 - // MZN_MIPD_assert_hard(fi); 365 + // MZN_MIPD__assert_hard(fi); 366 366 // int_lin_eq = (fi && fi->e()) ? fi : NULL; 367 367 int_lin_le = env.model->matchFn(env, constants().ids.int_.lin_le, int_lin_eq_t, false); 368 368 float_lin_eq = env.model->matchFn(env, constants().ids.float_.lin_eq, float_lin_eq_t, false); ··· 385 385 // new Call(Location(),"mzn_float_lt_EPS_coef__", std::vector<Expression*>()); 386 386 // call_EPS_for_LT->type(Type::parfloat()); 387 387 // call_EPS_for_LT->decl(env.model->matchFn(getEnv()->envi(), call_EPS_for_LT)); 388 - // float_lt_EPS_coef_ = eval_float(getEnv()->envi(), call_EPS_for_LT); 388 + // float_lt_EPS_coef__ = eval_float(getEnv()->envi(), call_EPS_for_LT); 389 389 // } 390 390 } 391 391 // bool matchAndMarkFunction(); ··· 431 431 // std::vector<Type> t_intarray(1); 432 432 // t_intarray[0] = Type::parint(-1); 433 433 434 - typedef std::unordered_map<FunctionI*, DCT*> M_POSTCallTypes; 435 - M_POSTCallTypes _mCallTypes; // actually declared in the input 436 - std::vector<DCT> _aCT; // all possible 434 + typedef std::unordered_map<FunctionI*, DCT*> M__POSTCallTypes; 435 + M__POSTCallTypes _mCallTypes; // actually declared in the input 436 + std::vector<DCT> _aCT; // all possible 437 437 438 438 // Fails: 439 439 // DomainCallType a = { NULL, t_VII, RIT_Halfreif, CT_Comparison, CMPT_EQ, VT_Float }; ··· 458 458 std::vector<VarDescr> _vVarDescr; 459 459 460 460 // NOLINTNEXTLINE(readability-identifier-naming) 461 - FunctionI* int_le_reif_POST = nullptr; 461 + FunctionI* int_le_reif__POST = nullptr; 462 462 // NOLINTNEXTLINE(readability-identifier-naming) 463 - FunctionI* int_ge_reif_POST = nullptr; 463 + FunctionI* int_ge_reif__POST = nullptr; 464 464 // NOLINTNEXTLINE(readability-identifier-naming) 465 - FunctionI* int_eq_reif_POST = nullptr; 465 + FunctionI* int_eq_reif__POST = nullptr; 466 466 // NOLINTNEXTLINE(readability-identifier-naming) 467 - FunctionI* int_ne_POST = nullptr; 467 + FunctionI* int_ne__POST = nullptr; 468 468 // NOLINTNEXTLINE(readability-identifier-naming) 469 - FunctionI* float_le_reif_POST = nullptr; 469 + FunctionI* float_le_reif__POST = nullptr; 470 470 // NOLINTNEXTLINE(readability-identifier-naming) 471 - FunctionI* float_ge_reif_POST = nullptr; 471 + FunctionI* float_ge_reif__POST = nullptr; 472 472 // NOLINTNEXTLINE(readability-identifier-naming) 473 - FunctionI* aux_float_lt_zero_iff_1_POST = nullptr; 473 + FunctionI* aux_float_lt_zero_iff_1__POST = nullptr; 474 474 // NOLINTNEXTLINE(readability-identifier-naming) 475 - FunctionI* float_eq_reif_POST = nullptr; 475 + FunctionI* float_eq_reif__POST = nullptr; 476 476 // NOLINTNEXTLINE(readability-identifier-naming) 477 - FunctionI* float_ne_POST = nullptr; 477 + FunctionI* float_ne__POST = nullptr; 478 478 // NOLINTNEXTLINE(readability-identifier-naming) 479 - FunctionI* aux_float_eq_zero_if_1_POST = nullptr; 479 + FunctionI* aux_float_eq_zero_if_1__POST = nullptr; 480 480 // NOLINTNEXTLINE(readability-identifier-naming) 481 - FunctionI* aux_int_le_zero_if_1_POST = nullptr; 481 + FunctionI* aux_int_le_zero_if_1__POST = nullptr; 482 482 // NOLINTNEXTLINE(readability-identifier-naming) 483 - FunctionI* aux_float_le_zero_if_1_POST = nullptr; 483 + FunctionI* aux_float_le_zero_if_1__POST = nullptr; 484 484 // NOLINTNEXTLINE(readability-identifier-naming) 485 - FunctionI* aux_float_lt_zero_if_1_POST = nullptr; 485 + FunctionI* aux_float_lt_zero_if_1__POST = nullptr; 486 486 // NOLINTNEXTLINE(readability-identifier-naming) 487 - FunctionI* equality_encoding_POST = nullptr; 487 + FunctionI* equality_encoding__POST = nullptr; 488 488 // NOLINTNEXTLINE(readability-identifier-naming) 489 - FunctionI* set_in_POST = nullptr; 489 + FunctionI* set_in__POST = nullptr; 490 490 // NOLINTNEXTLINE(readability-identifier-naming) 491 - FunctionI* set_in_reif_POST = nullptr; 491 + FunctionI* set_in_reif__POST = nullptr; 492 492 493 493 bool registerPOSTConstraintDecls() { 494 494 EnvI& env = getEnv()->envi(); ··· 496 496 497 497 _aCT.clear(); 498 498 _aCT.emplace_back("int_le_reif__POST", t_VIIVI, RIT_Reif, CT_Comparison, CMPT_LE, VT_Int, 499 - int_le_reif_POST); 499 + int_le_reif__POST); 500 500 _aCT.emplace_back("int_ge_reif__POST", t_VIIVI, RIT_Reif, CT_Comparison, CMPT_GE, VT_Int, 501 - int_ge_reif_POST); 501 + int_ge_reif__POST); 502 502 _aCT.emplace_back("int_eq_reif__POST", t_VIIVI, RIT_Reif, CT_Comparison, CMPT_EQ, VT_Int, 503 - int_eq_reif_POST); 503 + int_eq_reif__POST); 504 504 _aCT.emplace_back("int_ne__POST", t_VII, RIT_Static, CT_Comparison, CMPT_NE, VT_Int, 505 - int_ne_POST); 505 + int_ne__POST); 506 506 507 507 _aCT.emplace_back("float_le_reif__POST", t_VFFVIF, RIT_Reif, CT_Comparison, CMPT_LE, VT_Float, 508 - float_le_reif_POST); 508 + float_le_reif__POST); 509 509 _aCT.emplace_back("float_ge_reif__POST", t_VFFVIF, RIT_Reif, CT_Comparison, CMPT_GE, VT_Float, 510 - float_ge_reif_POST); 510 + float_ge_reif__POST); 511 511 _aCT.emplace_back("aux_float_lt_zero_iff_1__POST", t_VFVIF, RIT_Reif, CT_Comparison, CMPT_LT, 512 - VT_Float, aux_float_lt_zero_iff_1_POST); 512 + VT_Float, aux_float_lt_zero_iff_1__POST); 513 513 _aCT.emplace_back("float_eq_reif__POST", t_VFFVIF, RIT_Reif, CT_Comparison, CMPT_EQ, VT_Float, 514 - float_eq_reif_POST); 514 + float_eq_reif__POST); 515 515 _aCT.emplace_back("float_ne__POST", t_VFFF, RIT_Static, CT_Comparison, CMPT_NE, VT_Float, 516 - float_ne_POST); 516 + float_ne__POST); 517 517 518 518 _aCT.emplace_back("aux_float_eq_zero_if_1__POST", t_VFVIVF, RIT_Halfreif, CT_Comparison, 519 - CMPT_EQ_0, VT_Float, aux_float_eq_zero_if_1_POST); 519 + CMPT_EQ_0, VT_Float, aux_float_eq_zero_if_1__POST); 520 520 _aCT.emplace_back("aux_int_le_zero_if_1__POST", t_VIVI, RIT_Halfreif, CT_Comparison, CMPT_LE_0, 521 - VT_Int, aux_int_le_zero_if_1_POST); 521 + VT_Int, aux_int_le_zero_if_1__POST); 522 522 _aCT.emplace_back("aux_float_le_zero_if_1__POST", t_VFVIVF, RIT_Halfreif, CT_Comparison, 523 - CMPT_LE_0, VT_Float, aux_float_le_zero_if_1_POST); 523 + CMPT_LE_0, VT_Float, aux_float_le_zero_if_1__POST); 524 524 _aCT.emplace_back("aux_float_lt_zero_if_1__POST", t_VFVIVFF, RIT_Halfreif, CT_Comparison, 525 - CMPT_LT_0, VT_Float, aux_float_lt_zero_if_1_POST); 525 + CMPT_LT_0, VT_Float, aux_float_lt_zero_if_1__POST); 526 526 527 527 _aCT.emplace_back("equality_encoding__POST", t_VIAVI, RIT_Static, CT_Encode, CMPT_None, VT_Int, 528 - equality_encoding_POST); 529 - _aCT.emplace_back("set_in__POST", t_VISI, RIT_Static, CT_SetIn, CMPT_None, VT_Int, set_in_POST); 528 + equality_encoding__POST); 529 + _aCT.emplace_back("set_in__POST", t_VISI, RIT_Static, CT_SetIn, CMPT_None, VT_Int, 530 + set_in__POST); 530 531 _aCT.emplace_back("set_in_reif__POST", t_VISIVI, RIT_Reif, CT_SetIn, CMPT_None, VT_Int, 531 - set_in_reif_POST); 532 - /// Registering all declared & compatible _POST constraints 532 + set_in_reif__POST); 533 + /// Registering all declared & compatible __POST constraints 533 534 /// (First, cleanup FunctionIs' payload: -- ! doing now) 534 535 for (int i = 0; i < _aCT.size(); ++i) { 535 536 FunctionI* fi = env.model->matchFn(env, ASTString(_aCT[i].sFuncName), _aCT[i].aParams, false); ··· 547 548 return true; 548 549 } 549 550 550 - /// Registering all _POST calls' domain-constrained variables 551 + /// Registering all __POST calls' domain-constrained variables 551 552 void registerPOSTVariables() { 552 553 EnvI& env = getEnv()->envi(); 553 554 GCLock lock; ··· 576 577 checkInitExpr(vd0); 577 578 } 578 579 } else { 579 - DBGOUT_MIPD_FLUSH(" (already touched)"); 580 + DBGOUT_MIPD__(" (already touched)"); 580 581 } 581 - ++MIPD_stats[N_POSTs_domain]; 582 - ++MIPD_stats[N_POSTs_all]; 582 + ++MIPD__stats[N_POSTs__domain]; 583 + ++MIPD__stats[N_POSTs__all]; 583 584 } 584 585 } 585 - // Iterate thru original _POST constraints to mark constrained vars: 586 + // Iterate thru original __POST constraints to mark constrained vars: 586 587 for (ConstraintIterator ic = mFlat.constraints().begin(); ic != mFlat.constraints().end(); 587 588 ++ic) { 588 589 if (ic->removed()) { ··· 593 594 if (ipct != _mCallTypes.end()) { 594 595 // No ! here because might be deleted immediately in later versions. 595 596 // ic->remove(); // mark removed at once 596 - MZN_MIPD_assert_hard(c->argCount() > 1); 597 - ++MIPD_stats[N_POSTs_all]; 597 + MZN_MIPD__assert_hard(c->argCount() > 1); 598 + ++MIPD__stats[N_POSTs__all]; 598 599 VarDecl* vd0 = expr2VarDecl(c->arg(0)); 599 600 if (nullptr == vd0) { 600 - DBGOUT_MIPD_FLUSH(" Call " << *c 601 - << ": 1st arg not a VarDecl, removing if eq_encoding..."); 601 + DBGOUT_MIPD__(" Call " << *c << ": 1st arg not a VarDecl, removing if eq_encoding..."); 602 602 /// Only allow literals as main argument for equality_encoding 603 - if (equality_encoding_POST == 604 - ipct->first) { // was MZN_MIPD_assert_hard before MZN 2017 603 + if (equality_encoding__POST == 604 + ipct->first) { // was MZN_MIPD__assert_hard before MZN 2017 605 605 ic->remove(); 606 606 } 607 607 continue; // ignore this call 608 608 } 609 - DBGOUT_MIPD_FLUSH(" Call " << c->id().str() << " uses variable " << vd0->id()->str()); 609 + DBGOUT_MIPD__(" Call " << c->id().str() << " uses variable " << vd0->id()->str()); 610 610 if (vd0->payload() == -1) { // ! yet visited 611 611 vd0->payload(static_cast<int>(_vVarDescr.size())); 612 612 _vVarDescr.emplace_back(vd0, vd0->type().isint()); // can use /prmTypes/ as well ··· 615 615 checkInitExpr(vd0); 616 616 } 617 617 } else { 618 - DBGOUT_MIPD_FLUSH(" (already touched)"); 618 + DBGOUT_MIPD__(" (already touched)"); 619 619 } 620 620 DBGOUT_MIPD(""); 621 - if (equality_encoding_POST == c->decl()) { 622 - MZN_MIPD_assert_hard(!_vVarDescr[vd0->payload()].pEqEncoding); 621 + if (equality_encoding__POST == c->decl()) { 622 + MZN_MIPD__assert_hard(!_vVarDescr[vd0->payload()].pEqEncoding); 623 623 _vVarDescr[vd0->payload()].pEqEncoding = &*ic; 624 624 DBGOUT_MIPD(" Variable " << vd0->id()->str() << " has eq_encode."); 625 625 } // + if has aux_ constraints? ··· 629 629 } 630 630 } 631 631 } 632 - MIPD_stats[N_POSTs_varsDirect] = static_cast<double>(_vVarDescr.size()); 632 + MIPD__stats[N_POSTs__varsDirect] = static_cast<double>(_vVarDescr.size()); 633 633 } 634 634 635 635 // Should only be called on a newly added variable ··· 639 639 /// The bool param requires RHS to be POST-touched 640 640 // Guido: can! be recursive in FZN 641 641 bool checkInitExpr(VarDecl* vd, bool fCheckArg = false) { 642 - MZN_MIPD_assert_hard(vd->e()); 642 + MZN_MIPD__assert_hard(vd->e()); 643 643 if (!vd->type().isint() && !vd->type().isfloat()) { 644 644 return false; 645 645 } 646 646 if (!fCheckArg) { 647 - MZN_MIPD_assert_hard(vd->payload() >= 0); 647 + MZN_MIPD__assert_hard(vd->payload() >= 0); 648 648 } 649 649 if (Id* id = vd->e()->dynamicCast<Id>()) { 650 650 // const int f1 = ( vd->payload()>=0 ); 651 651 // const int f2 = ( id->decl()->payload()>=0 ); 652 652 if (!fCheckArg || (id->decl()->payload() >= 0)) { 653 - DBGOUT_MIPD_FLUSH(" Checking init expr "); 653 + DBGOUT_MIPD__(" Checking init expr "); 654 654 DBGOUT_MIPD_SELF(debugprint(vd)); 655 655 LinEq2Vars led; 656 656 // FAILS: ··· 659 659 led.coefs = {{1.0, -1.0}}; 660 660 led.rhs = 0.0; 661 661 put2VarsConnection(led, false); 662 - ++MIPD_stats[N_POSTs_initexpr1id]; 662 + ++MIPD__stats[N_POSTs__initexpr1id]; 663 663 if (id->decl()->e() != nullptr) { // no initexpr for initexpr FAILS on cc-base.mzn 664 664 checkInitExpr(id->decl()); 665 665 } ··· 669 669 if (lin_exp_int == c->decl() || lin_exp_float == c->decl()) { 670 670 // std::cerr << " !E call " << std::flush; 671 671 // debugprint(c); 672 - MZN_MIPD_assert_hard(c->argCount() == 3); 672 + MZN_MIPD__assert_hard(c->argCount() == 3); 673 673 // ArrayLit* al = c->args()[1]->dynamicCast<ArrayLit>(); 674 674 auto* al = follow_id(c->arg(1))->cast<ArrayLit>(); 675 - MZN_MIPD_assert_hard(al); 676 - MZN_MIPD_assert_hard(al->size() >= 1); 675 + MZN_MIPD__assert_hard(al); 676 + MZN_MIPD__assert_hard(al->size() >= 1); 677 677 if (al->size() == 1) { // 1-term scalar product in the rhs 678 678 LinEq2Vars led; 679 679 led.vd = {{vd, expr2VarDecl((*al)[0])}}; ··· 684 684 // if ( _sCallLinEq2.end() != _sCallLinEq2.find(c) ) 685 685 // continue; 686 686 // _sCallLinEq2.insert(c); // memorize this call 687 - DBGOUT_MIPD_FLUSH(" REG 1-LINEXP "); 687 + DBGOUT_MIPD__(" REG 1-LINEXP "); 688 688 DBGOUT_MIPD_SELF(debugprint(vd)); 689 689 std::array<double, 1> coef0; 690 690 expr2Array(c->arg(0), coef0); 691 691 led.coefs = {{-1.0, coef0[0]}}; 692 692 led.rhs = -expr2Const(c->arg(2)); // MINUS 693 693 put2VarsConnection(led, false); 694 - ++MIPD_stats[N_POSTs_initexpr1linexp]; 694 + ++MIPD__stats[N_POSTs__initexpr1linexp]; 695 695 if (led.vd[1]->e() != nullptr) { // no initexpr for initexpr FAILS TODO 696 696 checkInitExpr(led.vd[1]); 697 697 } ··· 726 726 propagateImplViews(fChanges); 727 727 } while (fChanges); 728 728 729 - MIPD_stats[N_POSTs_varsInvolved] = static_cast<double>(_vVarDescr.size()); 729 + MIPD__stats[N_POSTs__varsInvolved] = static_cast<double>(_vVarDescr.size()); 730 730 } 731 731 732 732 void propagateViews(bool& fChanges) { ··· 764 764 if (fIntLinEq || fFloatLinEq) { 765 765 // std::cerr << " !E call " << std::flush; 766 766 // debugprint(c); 767 - MZN_MIPD_assert_hard(c->argCount() == 3); 767 + MZN_MIPD__assert_hard(c->argCount() == 3); 768 768 auto* al = follow_id(c->arg(1))->cast<ArrayLit>(); 769 - MZN_MIPD_assert_hard(al); 769 + MZN_MIPD__assert_hard(al); 770 770 if (al->size() == 2) { // 2-term eqn 771 771 LinEq2Vars led; 772 772 expr2DeclArray(c->arg(1), led.vd); ··· 781 781 DBGOUT_MIPD_SELF(debugprint(c)); 782 782 led.rhs = expr2Const(c->arg(2)); 783 783 expr2Array(c->arg(0), led.coefs); 784 - MZN_MIPD_assert_hard(2 == led.coefs.size()); 784 + MZN_MIPD__assert_hard(2 == led.coefs.size()); 785 785 fChanges = true; 786 786 put2VarsConnection(led); 787 - ++MIPD_stats[fIntLinEq ? N_POSTs_eq2intlineq : N_POSTs_eq2floatlineq]; 787 + ++MIPD__stats[fIntLinEq ? N_POSTs__eq2intlineq : N_POSTs__eq2floatlineq]; 788 788 } 789 789 } 790 790 } else if (al->size() == 1) { ··· 804 804 DBGOUT_MIPD(" REG N-call "); 805 805 DBGOUT_MIPD_SELF(debugprint(c)); 806 806 Call* pC = eVD->dynamicCast<Call>(); 807 - MZN_MIPD_assert_hard(pC); 808 - MZN_MIPD_assert_hard(pC->argCount()); 807 + MZN_MIPD__assert_hard(pC); 808 + MZN_MIPD__assert_hard(pC->argCount()); 809 809 // Checking all but adding only touched defined vars? Seems too long. 810 810 VarDecl* vd = expr2VarDecl(pC->arg(0)); 811 811 if ((vd != nullptr) && vd->payload() >= 0) { // only if touched ··· 822 822 if (int2float == c->decl() || constants().varRedef == c->decl()) { 823 823 // std::cerr << " !E call " << std::flush; 824 824 // debugprint(c); 825 - MZN_MIPD_assert_hard(c->argCount() == 2); 825 + MZN_MIPD__assert_hard(c->argCount() == 2); 826 826 LinEq2Vars led; 827 827 // led.vd.resize(2); 828 828 led.vd[0] = expr2VarDecl(c->arg(0)); ··· 839 839 led.coefs = {{1.0, -1.0}}; 840 840 fChanges = true; 841 841 put2VarsConnection(led); 842 - ++MIPD_stats[int2float == c->decl() ? N_POSTs_int2float : N_POSTs_internalvarredef]; 842 + ++MIPD__stats[int2float == c->decl() ? N_POSTs__int2float : N_POSTs__internalvarredef]; 843 843 } 844 844 } 845 845 } ··· 865 865 // _lin_eq: a^T x == b 866 866 bool findOrAddDefining(Expression* exp, Call* pC) { 867 867 Id* pId = exp->dynamicCast<Id>(); 868 - MZN_MIPD_assert_hard(pId); 868 + MZN_MIPD__assert_hard(pId); 869 869 VarDecl* vd = pId->decl(); 870 - MZN_MIPD_assert_hard(vd); 871 - MZN_MIPD_assert_hard(pC->argCount() == 3); 870 + MZN_MIPD__assert_hard(vd); 871 + MZN_MIPD__assert_hard(pC->argCount() == 3); 872 872 873 873 TLinExpLin rhsLin; 874 874 NViewData nVRest; ··· 879 879 expr2DeclArray(pC->arg(1), vars); 880 880 std::vector<double> coefs; 881 881 expr2Array(pC->arg(0), coefs); 882 - MZN_MIPD_assert_hard(vars.size() == coefs.size()); 882 + MZN_MIPD__assert_hard(vars.size() == coefs.size()); 883 883 884 884 int nVD = 0; 885 885 for (int i = 0; i < vars.size(); ++i) { 886 - // MZN_MIPD_assert_hard( 0.0!=std::fabs 886 + // MZN_MIPD__assert_hard( 0.0!=std::fabs 887 887 if (vd == 888 888 vars[i]) { // when int/float_lin_eq :: defines_var(vd) "Recursive definition of " << *vd 889 889 nVRest.coef0 = -coefs[i]; ··· 893 893 rhsLin.push_back(std::make_pair(vars[i], coefs[i])); 894 894 } 895 895 } 896 - MZN_MIPD_assert_hard(1 >= nVD); 896 + MZN_MIPD__assert_hard(1 >= nVD); 897 897 std::sort(rhsLin.begin(), rhsLin.end()); 898 898 899 899 // Divide the equation by the 1st coef 900 900 const double coef1 = rhsLin.begin()->second; 901 - MZN_MIPD_assert_hard(0.0 != std::fabs(coef1)); 901 + MZN_MIPD__assert_hard(0.0 != std::fabs(coef1)); 902 902 nVRest.coef0 /= coef1; 903 903 nVRest.rhs /= coef1; 904 904 for (auto& rhsL : rhsLin) { ··· 913 913 leq.coefs = {{nVRest.coef0, -it->second.coef0}}; // +, - 914 914 leq.rhs = nVRest.rhs - it->second.rhs; 915 915 put2VarsConnection(leq, false); 916 - ++MIPD_stats[nVD != 0 ? N_POSTs_eqNlineq : N_POSTs_initexprN]; 916 + ++MIPD__stats[nVD != 0 ? N_POSTs__eqNlineq : N_POSTs__initexprN]; 917 917 return true; 918 918 } 919 919 if (vd->payload() >= 0) { // only touched ··· 948 948 /// register a 2-variable lin eq 949 949 /// add it to the var clique, joining the participants' cliques if needed 950 950 void put2VarsConnection(LinEq2Vars& led, bool fCheckinitExpr = true) { 951 - MZN_MIPD_assert_hard(led.coefs.size() == led.vd.size()); 952 - MZN_MIPD_assert_hard(led.vd.size() == 2); 953 - DBGOUT_MIPD_FLUSH(" Register 2-var connection: " << led); 951 + MZN_MIPD__assert_hard(led.coefs.size() == led.vd.size()); 952 + MZN_MIPD__assert_hard(led.vd.size() == 2); 953 + DBGOUT_MIPD__(" Register 2-var connection: " << led); 954 954 /// Check it's not same 2 vars 955 955 if (led.vd[0] == led.vd[1]) { 956 - MZN_MIPD_assert_soft( 956 + MZN_MIPD__assert_soft( 957 957 0, "MIPD: STRANGE: registering var connection to itself: " << led << ", skipping"); 958 - MZN_MIPD_ASSERT_FOR_SAT(fabs(led.coefs[0] + led.coefs[1]) < 1e-6, // TODO param 959 - getEnv()->envi(), led.vd[0]->loc(), 960 - "Var connection to itself seems to indicate UNSAT: " << led); 958 + MZN_MIPD__ASSERT_FOR_SAT(fabs(led.coefs[0] + led.coefs[1]) < 1e-6, // TODO param 959 + getEnv()->envi(), led.vd[0]->loc(), 960 + "Var connection to itself seems to indicate UNSAT: " << led); 961 961 return; 962 962 } 963 963 // register if new variables ··· 975 975 if (nMaybeClq >= 0) { 976 976 nCliqueAvailable = nMaybeClq; 977 977 } 978 - // MZN_MIPD_assert_hard( nCliqueAvailable>=0 ); 978 + // MZN_MIPD__assert_hard( nCliqueAvailable>=0 ); 979 979 // fHaveClq[i] = true; 980 980 } 981 981 } ··· 991 991 int& nMaybeClq = _vVarDescr[vd->payload()].nClique; 992 992 if (nMaybeClq >= 0 && nMaybeClq != nCliqueAvailable) { 993 993 TClique& clqOld = _aCliques[nMaybeClq]; 994 - MZN_MIPD_assert_hard(clqOld.size()); 994 + MZN_MIPD__assert_hard(clqOld.size()); 995 995 for (auto& eq2 : clqOld) { 996 996 for (auto* vd : eq2.vd) { // point all the variables to the new clique 997 997 _vVarDescr[vd->payload()].nClique = nCliqueAvailable; ··· 1028 1028 if (this->end() != it1) { 1029 1029 auto it2 = it1->second.find(*(begV + 1)); 1030 1030 if (it1->second.end() != it2) { 1031 - MZN_MIPD_assert_hard(std::fabs(it2->second.first - A) < 1032 - 1e-6 * std::max(std::fabs(it2->second.first), std::fabs(A))); 1033 - MZN_MIPD_assert_hard(std::fabs(it2->second.second - B) < 1034 - 1e-6 * std::max(std::fabs(it2->second.second), std::fabs(B)) + 1035 - 1e-6); 1036 - MZN_MIPD_assert_hard(std::fabs(A) != 0.0); 1037 - MZN_MIPD_assert_soft(!fVerbose || std::fabs(A) > 1e-12, 1038 - " Very small coef: " << (*begV)->id()->str() << " = " << A << " * " 1039 - << (*(begV + 1))->id()->str() << " + " << B); 1031 + MZN_MIPD__assert_hard(std::fabs(it2->second.first - A) < 1032 + 1e-6 * std::max(std::fabs(it2->second.first), std::fabs(A))); 1033 + MZN_MIPD__assert_hard(std::fabs(it2->second.second - B) < 1034 + 1e-6 * std::max(std::fabs(it2->second.second), std::fabs(B)) + 1035 + 1e-6); 1036 + MZN_MIPD__assert_hard(std::fabs(A) != 0.0); 1037 + MZN_MIPD__assert_soft(!fVerbose || std::fabs(A) > 1e-12, 1038 + " Very small coef: " << (*begV)->id()->str() << " = " << A 1039 + << " * " << (*(begV + 1))->id()->str() 1040 + << " + " << B); 1040 1041 if (fReportRepeat) { 1041 - MZN_MIPD_assert_soft(!fVerbose, "LinEqGraph: eqn between " 1042 - << (*begV)->id()->str() << " && " 1043 - << (*(begV + 1))->id()->str() 1044 - << " is repeated. "); 1042 + MZN_MIPD__assert_soft(!fVerbose, "LinEqGraph: eqn between " 1043 + << (*begV)->id()->str() << " && " 1044 + << (*(begV + 1))->id()->str() 1045 + << " is repeated. "); 1045 1046 } 1046 1047 return true; 1047 1048 } ··· 1063 1064 1064 1065 template <class ICoef, class IVarDecl> 1065 1066 void addArc(ICoef begC, IVarDecl begV, double rhs) { 1066 - MZN_MIPD_assert_soft(!fVerbose || std::fabs(*begC) >= 1e-10, 1067 - " Vars " << (*begV)->id()->str() << " to " 1068 - << (*(begV + 1))->id()->str() << ": coef=" << (*begC)); 1067 + MZN_MIPD__assert_soft(!fVerbose || std::fabs(*begC) >= 1e-10, 1068 + " Vars " << (*begV)->id()->str() << " to " 1069 + << (*(begV + 1))->id()->str() << ": coef=" << (*begC)); 1069 1070 // Transform Ax+By=C into x = -B/Ay+C/A 1070 1071 const double negBA = -(*(begC + 1)) / (*begC); 1071 1072 const double CA = rhs / (*begC); ··· 1085 1086 } 1086 1087 /// Propagate linear relations from the given variable 1087 1088 void propagate(iterator itStart, TMapVars& mWhereStore) { 1088 - MZN_MIPD_assert_hard(this->end() != itStart); 1089 + MZN_MIPD__assert_hard(this->end() != itStart); 1089 1090 TMatrixVars mTemp; 1090 1091 mTemp[itStart->first] = itStart->second; // init with existing 1091 1092 DBGOUT_MIPD("Propagation started from " << itStart->first->id()->str() << " having " 1092 1093 << itStart->second.size() << " connections"); 1093 1094 propagate2(itStart, itStart, std::make_pair(1.0, 0.0), mTemp); 1094 1095 mWhereStore = mTemp.begin()->second; 1095 - MZN_MIPD_assert_hard_msg( 1096 + MZN_MIPD__assert_hard_msg( 1096 1097 mWhereStore.size() == this->size() - 1, 1097 1098 "Variable " << (*(mTemp.begin()->first)) 1098 1099 << " should be connected to all others in the clique, but " ··· 1121 1122 } 1122 1123 if (fDive) { 1123 1124 auto itDST = this->find(itDst->first); 1124 - MZN_MIPD_assert_hard(this->end() != itDST); 1125 + MZN_MIPD__assert_hard(this->end() != itDST); 1125 1126 propagate2(itSrc, itDST, std::make_pair(A1A2, A1B2plusB1), mWhereStore); 1126 1127 } 1127 1128 } ··· 1131 1132 1132 1133 TCliqueSorter(MIPD* pm, int iv) : _mipd(*pm), _iVarStart(iv) {} 1133 1134 void doRelate() { 1134 - MZN_MIPD_assert_hard(_mipd._vVarDescr[_iVarStart].nClique >= 0); 1135 + MZN_MIPD__assert_hard(_mipd._vVarDescr[_iVarStart].nClique >= 0); 1135 1136 const TClique& clq = _mipd._aCliques[_mipd._vVarDescr[_iVarStart].nClique]; 1136 1137 for (const auto& eq2 : clq) { 1137 1138 leg.addEdge(eq2); ··· 1189 1190 cls.mRef1[cls.varRef1] = std::make_pair(1.0, 0.0); 1190 1191 1191 1192 int iVarRef1 = cls.varRef1->payload(); 1192 - MZN_MIPD_assert_hard(nClique == mipd._vVarDescr[iVarRef1].nClique); 1193 + MZN_MIPD__assert_hard(nClique == mipd._vVarDescr[iVarRef1].nClique); 1193 1194 cls.fRef1HasEqEncode = (mipd._vVarDescr[iVarRef1].pEqEncoding != nullptr); 1194 1195 1195 1196 // First, construct the domain decomposition in any case ··· 1202 1203 DBGOUT_MIPD("Clique " << nClique << ": main ref var " << cls.varRef1->id()->str() 1203 1204 << ", domain dec: " << sDomain); 1204 1205 1205 - MZN_MIPD_ASSERT_FOR_SAT(!sDomain.empty(), mipd.getEnv()->envi(), cls.varRef1->loc(), 1206 - "clique " << nClique << ": main ref var " << *cls.varRef1->id() 1207 - << ", domain decomposition seems empty: " << sDomain); 1206 + MZN_MIPD__ASSERT_FOR_SAT(!sDomain.empty(), mipd.getEnv()->envi(), cls.varRef1->loc(), 1207 + "clique " << nClique << ": main ref var " << *cls.varRef1->id() 1208 + << ", domain decomposition seems empty: " << sDomain); 1208 1209 1209 - MZN_MIPD_FLATTENING_ERROR_IF_NOT(sDomain.checkFiniteBounds(), mipd.getEnv()->envi(), 1210 - cls.varRef1->loc(), 1211 - "variable " << *cls.varRef1->id() 1212 - << " needs finite bounds for linearisation." 1213 - " Or, use indicator constraints. " 1214 - << "Current domain is " << sDomain); 1210 + MZN_MIPD__FLATTENING_ERROR__IF_NOT(sDomain.checkFiniteBounds(), mipd.getEnv()->envi(), 1211 + cls.varRef1->loc(), 1212 + "variable " << *cls.varRef1->id() 1213 + << " needs finite bounds for linearisation." 1214 + " Or, use indicator constraints. " 1215 + << "Current domain is " << sDomain); 1215 1216 1216 - MZN_MIPD_assert_hard(sDomain.checkDisjunctStrict()); 1217 + MZN_MIPD__assert_hard(sDomain.checkDisjunctStrict()); 1217 1218 1218 1219 makeRangeDomains(); 1219 1220 ··· 1230 1231 implementPOSTs(); 1231 1232 1232 1233 // Statistics 1233 - if (sDomain.size() < MIPD_stats[N_POSTs_NSubintvMin]) { 1234 - MIPD_stats[N_POSTs_NSubintvMin] = static_cast<double>(sDomain.size()); 1234 + if (sDomain.size() < MIPD__stats[N_POSTs__NSubintvMin]) { 1235 + MIPD__stats[N_POSTs__NSubintvMin] = static_cast<double>(sDomain.size()); 1235 1236 } 1236 - MIPD_stats[N_POSTs_NSubintvSum] += sDomain.size(); 1237 - if (sDomain.size() > MIPD_stats[N_POSTs_NSubintvMax]) { 1238 - MIPD_stats[N_POSTs_NSubintvMax] = static_cast<double>(sDomain.size()); 1237 + MIPD__stats[N_POSTs__NSubintvSum] += sDomain.size(); 1238 + if (sDomain.size() > MIPD__stats[N_POSTs__NSubintvMax]) { 1239 + MIPD__stats[N_POSTs__NSubintvMax] = static_cast<double>(sDomain.size()); 1239 1240 } 1240 1241 for (const auto& intv : sDomain) { 1241 1242 const auto nSubSize = intv.right - intv.left; 1242 - if (nSubSize < MIPD_stats[N_POSTs_SubSizeMin]) { 1243 - MIPD_stats[N_POSTs_SubSizeMin] = nSubSize; 1243 + if (nSubSize < MIPD__stats[N_POSTs__SubSizeMin]) { 1244 + MIPD__stats[N_POSTs__SubSizeMin] = nSubSize; 1244 1245 } 1245 - MIPD_stats[N_POSTs_SubSizeSum] += nSubSize; 1246 - if (nSubSize > MIPD_stats[N_POSTs_SubSizeMax]) { 1247 - MIPD_stats[N_POSTs_SubSizeMax] = nSubSize; 1246 + MIPD__stats[N_POSTs__SubSizeSum] += nSubSize; 1247 + if (nSubSize > MIPD__stats[N_POSTs__SubSizeMax]) { 1248 + MIPD__stats[N_POSTs__SubSizeMax] = nSubSize; 1248 1249 } 1249 1250 } 1250 1251 if (cls.fRef1HasEqEncode) { 1251 - ++MIPD_stats[N_POSTs_cliquesWithEqEncode]; 1252 + ++MIPD__stats[N_POSTs__cliquesWithEqEncode]; 1252 1253 } 1253 1254 } 1254 1255 ··· 1256 1257 /// Deltas should be scaled but to a minimum of the target's discr 1257 1258 /// COmparison sense changes on negated vars 1258 1259 void projectVariableConstr(VarDecl* vd, std::pair<double, double> eq1) { 1259 - DBGOUT_MIPD_FLUSH(" MIPD: projecting variable "); 1260 + DBGOUT_MIPD__(" MIPD: projecting variable "); 1260 1261 DBGOUT_MIPD_SELF(debugprint(vd)); 1261 1262 // Always check if domain becomes empty? TODO 1262 1263 const double A = eq1.first; // vd = A*arg + B. conversion ··· 1276 1277 lb = bnds.left; 1277 1278 ub = bnds.right; 1278 1279 } else { 1279 - MZN_MIPD_FLATTENING_ERROR_IF_NOT(0, mipd.getEnv()->envi(), cls.varRef1->loc(), 1280 - "Variable " << vd->id()->str() << " of type " 1281 - << vd->type().toString(mipd._env->envi()) 1282 - << " has a domain."); 1280 + MZN_MIPD__FLATTENING_ERROR__IF_NOT(0, mipd.getEnv()->envi(), cls.varRef1->loc(), 1281 + "Variable " << vd->id()->str() << " of type " 1282 + << vd->type().toString(mipd._env->envi()) 1283 + << " has a domain."); 1283 1284 } 1284 1285 // /// Deleting var domain: 1285 1286 // vd->ti()->domain( NULL ); ··· 1294 1295 auto& aCalls = mipd._vVarDescr[vd->payload()].aCalls; 1295 1296 for (Item* pItem : aCalls) { 1296 1297 auto* pCI = pItem->dynamicCast<ConstraintI>(); 1297 - MZN_MIPD_assert_hard(pCI != nullptr); 1298 + MZN_MIPD__assert_hard(pCI != nullptr); 1298 1299 Call* pCall = pCI->e()->dynamicCast<Call>(); 1299 - MZN_MIPD_assert_hard(pCall != nullptr); 1300 - DBGOUT_MIPD_FLUSH("PROPAG CALL "); 1300 + MZN_MIPD__assert_hard(pCall != nullptr); 1301 + DBGOUT_MIPD__("PROPAG CALL "); 1301 1302 DBGOUT_MIPD_SELF(debugprint(pCall)); 1302 1303 // check the bounds for bool in reifs? TODO 1303 1304 auto ipct = mipd._mCallTypes.find(pCall->decl()); 1304 - MZN_MIPD_assert_hard(mipd._mCallTypes.end() != ipct); 1305 + MZN_MIPD__assert_hard(mipd._mCallTypes.end() != ipct); 1305 1306 const DCT& dct = *ipct->second; 1306 1307 int nCmpType_ADAPTED = dct.nCmpType; 1307 1308 if (A < 0.0) { // negative factor ··· 1315 1316 convertIntSet(pCall->arg(1), SS, cls.varRef1, A, B); 1316 1317 if (RIT_Static == dct.nReifType) { 1317 1318 sDomain.intersect(SS); 1318 - ++MIPD_stats[N_POSTs_setIn]; 1319 + ++MIPD__stats[N_POSTs__setIn]; 1319 1320 } else { 1320 1321 sDomain.cutDeltas(SS, std::max(1.0, std::fabs(A))); // deltas to scale 1321 - ++MIPD_stats[N_POSTs_setInReif]; 1322 + ++MIPD__stats[N_POSTs__setInReif]; 1322 1323 } 1323 1324 } break; 1324 1325 case CT_Comparison: 1325 1326 if (RIT_Reif == dct.nReifType) { 1326 - const double rhs = (mipd.aux_float_lt_zero_iff_1_POST == pCall->decl()) 1327 + const double rhs = (mipd.aux_float_lt_zero_iff_1__POST == pCall->decl()) 1327 1328 ? B /* + A*0.0, relating to 0 */ 1328 1329 // The 2nd argument is constant: 1329 1330 : A * MIPD::expr2Const(pCall->arg(1)) + B; ··· 1352 1353 } 1353 1354 break; 1354 1355 default: 1355 - MZN_MIPD_assert_hard_msg(0, " No other reified cmp type "); 1356 + MZN_MIPD__assert_hard_msg(0, " No other reified cmp type "); 1356 1357 } 1357 - ++MIPD_stats[(vd->ti()->type().isint()) ? N_POSTs_intCmpReif : N_POSTs_floatCmpReif]; 1358 + ++MIPD__stats[(vd->ti()->type().isint()) ? N_POSTs__intCmpReif 1359 + : N_POSTs__floatCmpReif]; 1358 1360 } else if (RIT_Static == dct.nReifType) { 1359 1361 // _ne, later maybe static ineq TODO 1360 - MZN_MIPD_assert_hard(CMPT_NE == dct.nCmpType); 1362 + MZN_MIPD__assert_hard(CMPT_NE == dct.nCmpType); 1361 1363 const double rhs = A * MIPD::expr2Const(pCall->arg(1)) + B; 1362 1364 const double rhsRnd = rndIfInt(cls.varRef1, rhs); 1363 1365 bool fSkipNE = (cls.varRef1->type().isint() && std::fabs(rhs - rhsRnd) > INT_EPS); ··· 1365 1367 const double delta = computeDelta(cls.varRef1, vd, bnds, A, pCall, 2); 1366 1368 sDomain.cutOut({rhsRnd - delta, rhsRnd + delta}); 1367 1369 } 1368 - ++MIPD_stats[(vd->ti()->type().isint()) ? N_POSTs_intNE : N_POSTs_floatNE]; 1370 + ++MIPD__stats[(vd->ti()->type().isint()) ? N_POSTs__intNE : N_POSTs__floatNE]; 1369 1371 } else { // aux_ relate to 0.0 1370 1372 // But we don't modify domain splitting for them currently 1371 - ++MIPD_stats[(vd->ti()->type().isint()) ? N_POSTs_intAux : N_POSTs_floatAux]; 1372 - MZN_MIPD_assert_hard(RIT_Halfreif == dct.nReifType); 1373 + ++MIPD__stats[(vd->ti()->type().isint()) ? N_POSTs__intAux : N_POSTs__floatAux]; 1374 + MZN_MIPD__assert_hard(RIT_Halfreif == dct.nReifType); 1373 1375 // const double rhs = B; // + A*0 1374 1376 // const double delta = vd->type().isint() ? 1.0 : 1e-5; // 1375 1377 // TODO : eps ··· 1377 1379 break; 1378 1380 case CT_Encode: 1379 1381 // See if any further constraints here? TODO 1380 - ++MIPD_stats[N_POSTs_eq_encode]; 1382 + ++MIPD__stats[N_POSTs__eq_encode]; 1381 1383 break; 1382 1384 default: 1383 - MZN_MIPD_assert_hard_msg(0, "Unknown constraint type"); 1385 + MZN_MIPD__assert_hard_msg(0, "Unknown constraint type"); 1384 1386 } 1385 1387 } 1386 1388 DBGOUT_MIPD(" Clique domain after proj of " << A << " * " << vd->id()->str() << " + " << B ··· 1412 1414 double lb0 = (bnds.left - iRef1.second.second) / iRef1.second.first; 1413 1415 double ub0 = (bnds.right - iRef1.second.second) / iRef1.second.first; 1414 1416 if (lb0 > ub0) { 1415 - MZN_MIPD_assert_hard(iRef1.second.first < 0.0); 1417 + MZN_MIPD__assert_hard(iRef1.second.first < 0.0); 1416 1418 std::swap(lb0, ub0); 1417 1419 } 1418 1420 if (vd->type().isint()) { ··· 1433 1435 const long long iMin = mipd.expr2ExprArray( 1434 1436 mipd._vVarDescr[cls.varRef1->payload()].pEqEncoding->e()->dynamicCast<Call>()->arg(1), 1435 1437 pp); 1436 - MZN_MIPD_assert_hard(pp.size() >= bnds.right - bnds.left + 1); 1437 - MZN_MIPD_assert_hard(iMin <= bnds.left); 1438 + MZN_MIPD__assert_hard(pp.size() >= bnds.right - bnds.left + 1); 1439 + MZN_MIPD__assert_hard(iMin <= bnds.left); 1438 1440 long long vEE = iMin; 1439 - DBGOUT_MIPD_FLUSH( 1441 + DBGOUT_MIPD__( 1440 1442 " SYNC EQ_ENCODE( " 1441 1443 << (*cls.varRef1) << ", bitflags: " 1442 1444 << *(mipd._vVarDescr[cls.varRef1->payload()].pEqEncoding->e()->dynamicCast<Call>()->arg( ··· 1449 1451 } 1450 1452 if (pp[vEE - iMin]->isa<Id>()) { 1451 1453 if (pp[vEE - iMin]->dynamicCast<Id>()->decl()->type().isvar()) { 1452 - DBGOUT_MIPD_FLUSH(vEE << ", "); 1454 + DBGOUT_MIPD__(vEE << ", "); 1453 1455 setVarDomain(pp[vEE - iMin]->dynamicCast<Id>()->decl(), 0.0, 0.0); 1454 1456 } 1455 1457 } ··· 1459 1461 for (; vEE < static_cast<long long>(iMin + pp.size()); ++vEE) { 1460 1462 if (pp[vEE - iMin]->isa<Id>()) { 1461 1463 if (pp[vEE - iMin]->dynamicCast<Id>()->decl()->type().isvar()) { 1462 - DBGOUT_MIPD_FLUSH(vEE << ", "); 1464 + DBGOUT_MIPD__(vEE << ", "); 1463 1465 setVarDomain(pp[vEE - iMin]->dynamicCast<Id>()->decl(), 0.0, 0.0); 1464 1466 } 1465 1467 } ··· 1480 1482 if (sDomain.maxInterval() <= mipd.nMaxIntv2Bits || 1481 1483 sDomain.cardInt() <= mipd.dMaxNValueDensity * sDomain.size()) { 1482 1484 sDomain.split2Bits(); 1483 - ++MIPD_stats[N_POSTs_clEEEnforced]; 1485 + ++MIPD__stats[N_POSTs__clEEEnforced]; 1484 1486 } 1485 1487 } 1486 1488 } ··· 1490 1492 void createDomainFlags() { 1491 1493 std::vector<Expression*> vVars(sDomain.size()); // flags for each subinterval 1492 1494 std::vector<double> vIntvLB(sDomain.size() + 1); 1493 - std::vector<double> vIntvUB_(sDomain.size() + 1); 1495 + std::vector<double> vIntvUB__(sDomain.size() + 1); 1494 1496 int i = 0; 1495 1497 double dMaxIntv = -1.0; 1496 1498 for (const auto& intv : sDomain) { 1497 1499 intv.varFlag = addIntVar(0.0, 1.0); 1498 1500 vVars[i] = intv.varFlag->id(); 1499 1501 vIntvLB[i] = intv.left; 1500 - vIntvUB_[i] = -intv.right; 1502 + vIntvUB__[i] = -intv.right; 1501 1503 dMaxIntv = std::max(dMaxIntv, intv.right - intv.left); 1502 1504 ++i; 1503 1505 } ··· 1509 1511 vIntvLB[i] = -1.0; // var1 >= sum(LBi*flagi) 1510 1512 /// STRICT equality encoding if small intervals 1511 1513 if (dMaxIntv > 1e-6) { // EPS = param? TODO 1512 - vIntvUB_[i] = 1.0; // var1 <= sum(UBi*flagi) 1514 + vIntvUB__[i] = 1.0; // var1 <= sum(UBi*flagi) 1513 1515 addLinConstr(vIntvLB, vVars, CMPT_LE, 0.0); 1514 - addLinConstr(vIntvUB_, vVars, CMPT_LE, 0.0); 1516 + addLinConstr(vIntvUB__, vVars, CMPT_LE, 0.0); 1515 1517 } else { 1516 - ++MIPD_stats[N_POSTs_clEEFound]; 1518 + ++MIPD__stats[N_POSTs__clEEFound]; 1517 1519 addLinConstr(vIntvLB, vVars, CMPT_EQ, 0.0); 1518 1520 } 1519 1521 } ··· 1522 1524 void implementPOSTs() { 1523 1525 auto bnds = sDomain.getBounds(); 1524 1526 for (auto& iRef1 : cls.mRef1) { 1525 - // DBGOUT_MIPD_FLUSH( " MIPD: implementing constraints of variable " ); 1527 + // DBGOUT_MIPD__( " MIPD: implementing constraints of variable " ); 1526 1528 // DBGOUT_MIPD_SELF( debugprint(vd) ); 1527 1529 VarDecl* vd = iRef1.first; 1528 1530 auto eq1 = iRef1.second; ··· 1532 1534 auto& aCalls = mipd._vVarDescr[vd->payload()].aCalls; 1533 1535 for (Item* pItem : aCalls) { 1534 1536 auto* pCI = pItem->dynamicCast<ConstraintI>(); 1535 - MZN_MIPD_assert_hard(pCI); 1537 + MZN_MIPD__assert_hard(pCI); 1536 1538 Call* pCall = pCI->e()->dynamicCast<Call>(); 1537 - MZN_MIPD_assert_hard(pCall); 1538 - DBGOUT_MIPD_FLUSH("IMPL CALL "); 1539 + MZN_MIPD__assert_hard(pCall); 1540 + DBGOUT_MIPD__("IMPL CALL "); 1539 1541 DBGOUT_MIPD_SELF(debugprint(pCall)); 1540 1542 // check the bounds for bool in reifs? TODO 1541 1543 auto ipct = mipd._mCallTypes.find(pCall->decl()); 1542 - MZN_MIPD_assert_hard(mipd._mCallTypes.end() != ipct); 1544 + MZN_MIPD__assert_hard(mipd._mCallTypes.end() != ipct); 1543 1545 const DCT& dct = *ipct->second; 1544 1546 int nCmpType_ADAPTED = dct.nCmpType; 1545 1547 if (A < 0.0) { // negative factor ··· 1557 1559 break; 1558 1560 case CT_Comparison: 1559 1561 if (RIT_Reif == dct.nReifType) { 1560 - const double rhs = (mipd.aux_float_lt_zero_iff_1_POST == pCall->decl()) 1562 + const double rhs = (mipd.aux_float_lt_zero_iff_1__POST == pCall->decl()) 1561 1563 ? B /* + A*0.0, relating to 0 */ 1562 1564 // The 2nd argument is constant: 1563 1565 : A * MIPD::expr2Const(pCall->arg(1)) + B; ··· 1588 1590 } 1589 1591 } else if (RIT_Static == dct.nReifType) { 1590 1592 // !hing here for NE 1591 - MZN_MIPD_assert_hard(CMPT_NE == nCmpType_ADAPTED); 1593 + MZN_MIPD__assert_hard(CMPT_NE == nCmpType_ADAPTED); 1592 1594 } else { // aux_ relate to 0.0 1593 1595 // But we don't modify domain splitting for them currently 1594 - MZN_MIPD_assert_hard(RIT_Halfreif == dct.nReifType); 1596 + MZN_MIPD__assert_hard(RIT_Halfreif == dct.nReifType); 1595 1597 double rhs = B; // + A*0 1596 1598 const double rhsUp = rndUpIfInt(cls.varRef1, rhs); 1597 1599 const double rhsDown = rndDownIfInt(cls.varRef1, rhs); 1598 1600 const double rhsRnd = rndIfInt(cls.varRef1, rhs); 1599 1601 double delta = 0.0; 1600 - if (mipd.aux_float_lt_zero_if_1_POST == pCall->decl()) { // only float && lt 1602 + if (mipd.aux_float_lt_zero_if_1__POST == pCall->decl()) { // only float && lt 1601 1603 delta = computeDelta(cls.varRef1, vd, bnds, A, pCall, 3); 1602 1604 } 1603 1605 if (nCmpType_ADAPTED < 0) { ··· 1645 1647 fUseDD = !fInner; 1646 1648 } break; 1647 1649 default: 1648 - MZN_MIPD_assert_hard_msg(0, "Unknown halfreif cmp type"); 1650 + MZN_MIPD__assert_hard_msg(0, "Unknown halfreif cmp type"); 1649 1651 } 1650 1652 } 1651 1653 if (fUseDD) { // use sDomain ··· 1666 1668 cls.varRef1->ti()->type().isint() 1667 1669 ? 1 1668 1670 : 2; // need the type of the variable to be constr 1669 - MZN_MIPD_assert_hard(static_cast<unsigned int>(nIdxInd) < pCall->argCount()); 1671 + MZN_MIPD__assert_hard(static_cast<unsigned int>(nIdxInd) < pCall->argCount()); 1670 1672 Expression* pInd = pCall->arg(nIdxInd); 1671 1673 if (fLE && rhs < bnds.right) { 1672 1674 if (rhs >= bnds.left) { ··· 1694 1696 // See if any further constraints here? TODO 1695 1697 break; 1696 1698 default: 1697 - MZN_MIPD_assert_hard_msg(0, "Unknown constraint type"); 1699 + MZN_MIPD__assert_hard_msg(0, "Unknown constraint type"); 1698 1700 } 1699 1701 pItem->remove(); // removing the call 1700 1702 } ··· 1707 1709 1708 1710 /// sets varFlag = || <= sum( intv.varFlag : SS ) 1709 1711 void relateReifFlag(Expression* expFlag, const SetOfIntvReal& SS, EnumReifType nRT = RIT_Reif) { 1710 - MZN_MIPD_assert_hard(RIT_Reif == nRT || RIT_Halfreif == nRT); 1711 - // MZN_MIPD_assert_hard( sDomain.size()>=2 ); 1712 + MZN_MIPD__assert_hard(RIT_Reif == nRT || RIT_Halfreif == nRT); 1713 + // MZN_MIPD__assert_hard( sDomain.size()>=2 ); 1712 1714 VarDecl* varFlag = MIPD::expr2VarDecl(expFlag); 1713 1715 std::vector<Expression*> vIntvFlags; 1714 1716 if (cls.fRef1HasEqEncode) { // use eq_encoding 1715 - MZN_MIPD_assert_hard(varFlag->type().isint()); 1717 + MZN_MIPD__assert_hard(varFlag->type().isint()); 1716 1718 std::vector<Expression*> pp; 1717 1719 auto bnds = sDomain.getBounds(); 1718 1720 const long long iMin = mipd.expr2ExprArray( 1719 1721 mipd._vVarDescr[cls.varRef1->payload()].pEqEncoding->e()->dynamicCast<Call>()->arg(1), 1720 1722 pp); 1721 - MZN_MIPD_assert_hard(pp.size() >= bnds.right - bnds.left + 1); 1722 - MZN_MIPD_assert_hard(iMin <= bnds.left); 1723 + MZN_MIPD__assert_hard(pp.size() >= bnds.right - bnds.left + 1); 1724 + MZN_MIPD__assert_hard(iMin <= bnds.left); 1723 1725 for (const auto& intv : SS) { 1724 1726 for (long long vv = (long long)std::max(double(iMin), ceil(intv.left)); 1725 1727 vv <= (long long)std::min(double(iMin) + pp.size() - 1, floor(intv.right)); ++vv) { ··· 1727 1729 } 1728 1730 } 1729 1731 } else { 1730 - MZN_MIPD_assert_hard(varFlag->type().isint()); 1732 + MZN_MIPD__assert_hard(varFlag->type().isint()); 1731 1733 for (const auto& intv : SS) { 1732 1734 auto it1 = sDomain.lower_bound(intv.left); 1733 1735 auto it2 = sDomain.upper_bound(intv.right); ··· 1735 1737 // Check that we are looking ! into a subinterval: 1736 1738 if (sDomain.begin() != it11) { 1737 1739 --it11; 1738 - MZN_MIPD_assert_hard(it11->right < intv.left); 1740 + MZN_MIPD__assert_hard(it11->right < intv.left); 1739 1741 } 1740 1742 auto it12 = it2; 1741 1743 if (sDomain.begin() != it12) { 1742 1744 --it12; 1743 - MZN_MIPD_assert_hard_msg(it12->right <= intv.right, 1744 - " relateReifFlag for " << intv << " in " << sDomain); 1745 + MZN_MIPD__assert_hard_msg(it12->right <= intv.right, 1746 + " relateReifFlag for " << intv << " in " << sDomain); 1745 1747 } 1746 1748 for (it12 = it1; it12 != it2; ++it12) { 1747 1749 if (it12->varFlag != nullptr) { 1748 1750 vIntvFlags.push_back(it12->varFlag->id()); 1749 1751 } else { 1750 - MZN_MIPD_assert_hard(1 == sDomain.size()); 1752 + MZN_MIPD__assert_hard(1 == sDomain.size()); 1751 1753 vIntvFlags.push_back(IntLit::a(1)); // just a constant then 1752 1754 } 1753 1755 } ··· 1782 1784 // nti->domain(newDom); 1783 1785 vd->ti()->domain(newDom); 1784 1786 } else { 1785 - MZN_MIPD_assert_hard_msg(0, "Unknown var type "); 1787 + MZN_MIPD__assert_hard_msg(0, "Unknown var type "); 1786 1788 } 1787 1789 } 1788 1790 ··· 1802 1804 void addLinConstr(std::vector<double>& coefs, std::vector<Expression*>& vars, 1803 1805 EnumCmpType nCmpType, double rhs) { 1804 1806 std::vector<Expression*> args(3); 1805 - MZN_MIPD_assert_hard(vars.size() >= 2); 1807 + MZN_MIPD__assert_hard(vars.size() >= 2); 1806 1808 for (auto* v : vars) { 1807 - MZN_MIPD_assert_hard(&v); 1809 + MZN_MIPD__assert_hard(&v); 1808 1810 // throw std::string("addLinConstr: &var=NULL"); 1809 - MZN_MIPD_assert_hard_msg(v->isa<Id>() || v->isa<IntLit>() || v->isa<FloatLit>(), 1810 - " expression at " << (&v) << " eid = " << v->eid() 1811 - << " while E_INTLIT=" << Expression::E_INTLIT); 1811 + MZN_MIPD__assert_hard_msg(v->isa<Id>() || v->isa<IntLit>() || v->isa<FloatLit>(), 1812 + " expression at " << (&v) << " eid = " << v->eid() 1813 + << " while E_INTLIT=" << Expression::E_INTLIT); 1812 1814 // throw std::string("addLinConstr: only id's as variables allowed"); 1813 1815 } 1814 - MZN_MIPD_assert_hard(coefs.size() == vars.size()); 1815 - MZN_MIPD_assert_hard(CMPT_EQ == nCmpType || CMPT_LE == nCmpType); 1816 + MZN_MIPD__assert_hard(coefs.size() == vars.size()); 1817 + MZN_MIPD__assert_hard(CMPT_EQ == nCmpType || CMPT_LE == nCmpType); 1816 1818 DBGOUT_MIPD_SELF( // LinEq leq; leq.coefs=coefs; leq.vd=vars; leq.rhs=rhs; 1817 - DBGOUT_MIPD_FLUSH(" ADDING " << (CMPT_EQ == nCmpType ? "LIN_EQ" : "LIN_LE") << ": [ "); 1819 + DBGOUT_MIPD__(" ADDING " << (CMPT_EQ == nCmpType ? "LIN_EQ" : "LIN_LE") << ": [ "); 1818 1820 for (auto c 1819 - : coefs) DBGOUT_MIPD_FLUSH(c << ','); 1820 - DBGOUT_MIPD_FLUSH(" ] * [ "); for (auto v 1821 - : vars) { 1822 - MZN_MIPD_assert_hard(!v->isa<VarDecl>()); 1823 - if (v->isa<Id>()) DBGOUT_MIPD_FLUSH(v->dynamicCast<Id>()->str() << ','); 1821 + : coefs) DBGOUT_MIPD__(c << ','); 1822 + DBGOUT_MIPD__(" ] * [ "); for (auto v 1823 + : vars) { 1824 + MZN_MIPD__assert_hard(!v->isa<VarDecl>()); 1825 + if (v->isa<Id>()) DBGOUT_MIPD__(v->dynamicCast<Id>()->str() << ','); 1824 1826 // else if ( v->isa<VarDecl>() ) 1825 - // MZN_MIPD_assert_hard ("addLinConstr: only id's as variables allowed"); 1827 + // MZN_MIPD__assert_hard ("addLinConstr: only id's as variables allowed"); 1826 1828 else 1827 - DBGOUT_MIPD_FLUSH(mipd.expr2Const(v) << ','); 1829 + DBGOUT_MIPD__(mipd.expr2Const(v) << ','); 1828 1830 } DBGOUT_MIPD(" ] " << (CMPT_EQ == nCmpType ? "== " : "<= ") << rhs);); 1829 1831 std::vector<Expression*> nc_c; 1830 1832 std::vector<Expression*> nx; ··· 1837 1839 } 1838 1840 auto sName = constants().ids.float_.lin_eq; // "int_lin_eq"; 1839 1841 FunctionI* fDecl = mipd.float_lin_eq; 1840 - if (fFloat) { // MZN_MIPD_assert_hard all vars of same type TODO 1842 + if (fFloat) { // MZN_MIPD__assert_hard all vars of same type TODO 1841 1843 for (int i = 0; i < vars.size(); ++i) { 1842 1844 if (fabs(coefs[i]) > 1e-8) /// Only add terms with non-0 coefs. TODO Eps=param 1843 1845 { ··· 1888 1890 } 1889 1891 } 1890 1892 if (mipd.getEnv()->envi().cseMapEnd() != mipd.getEnv()->envi().cseMapFind(args[0])) { 1891 - DBGOUT_MIPD_FLUSH(" Found expr "); 1893 + DBGOUT_MIPD__(" Found expr "); 1892 1894 DBGOUT_MIPD_SELF(debugprint(args[0])); 1893 1895 } 1894 1896 auto* nc = new Call(Location().introduce(), ASTString(sName), args); ··· 1899 1901 1900 1902 /// domain / reif set of one variable into that for a!her 1901 1903 void convertIntSet(Expression* e, SetOfIntvReal& s, VarDecl* varTarget, double A, double B) { 1902 - MZN_MIPD_assert_hard(A != 0.0); 1904 + MZN_MIPD__assert_hard(A != 0.0); 1903 1905 if (e->type().isIntSet()) { 1904 1906 IntSetVal* S = eval_intset(mipd.getEnv()->envi(), e); 1905 1907 IntSetRanges domr(S); ··· 1949 1951 }; // class DomainDecomp 1950 1952 1951 1953 /// Vars without explicit clique still need a decomposition. 1952 - /// Have !iced all _POSTs, set_in's && eq_encode's to it BEFORE 1954 + /// Have !iced all __POSTs, set_in's && eq_encode's to it BEFORE 1953 1955 /// In each clique, relate all vars to one chosen 1954 1956 /// Find all "smallest rel. factor" variables, integer && with eq_encode if avail 1955 1957 /// Re-relate all vars to it 1956 - /// Refer all _POSTs && dom() to it 1958 + /// Refer all __POSTs && dom() to it 1957 1959 /// build domain decomposition 1958 1960 /// Implement all domain constraints, incl. possible corresp, of eq_encode's 1959 1961 /// ··· 1975 1977 _vVarDescr[iVar].fDomainConstrProcessed = 1U; 1976 1978 } 1977 1979 } 1978 - // Clean up _POSTs: 1980 + // Clean up __POSTs: 1979 1981 for (auto& vVar : _vVarDescr) { 1980 1982 for (auto* pCallI : vVar.aCalls) { 1981 1983 pCallI->remove(); ··· 1991 1993 // The requirement to have actual variable objects 1992 1994 // might be a limitation if more optimizations are done before... 1993 1995 // Might need to flexibilize this TODO 1994 - // MZN_MIPD_assert_hard_msg( ! arg->dynamicCast<IntLit>(), 1996 + // MZN_MIPD__assert_hard_msg( ! arg->dynamicCast<IntLit>(), 1995 1997 // "Expression " << *arg << " is an IntLit!" ); 1996 - // MZN_MIPD_assert_hard( ! arg->dynamicCast<FloatLit>() ); 1997 - // MZN_MIPD_assert_hard( ! arg->dynamicCast<BoolLit>() ); 1998 + // MZN_MIPD__assert_hard( ! arg->dynamicCast<FloatLit>() ); 1999 + // MZN_MIPD__assert_hard( ! arg->dynamicCast<BoolLit>() ); 1998 2000 Id* id = arg->dynamicCast<Id>(); 1999 - // MZN_MIPD_assert_hard(id); 2001 + // MZN_MIPD__assert_hard(id); 2000 2002 if (nullptr == id) { 2001 2003 return nullptr; // the call using this should be ignored? 2002 2004 } 2003 2005 VarDecl* vd = id->decl(); 2004 - MZN_MIPD_assert_hard(vd); 2006 + MZN_MIPD__assert_hard(vd); 2005 2007 return vd; 2006 2008 } 2007 2009 ··· 2037 2039 if (auto* bl = arg->dynamicCast<BoolLit>()) { 2038 2040 return static_cast<double>(bl->v()); 2039 2041 } 2040 - MZN_MIPD_assert_hard_msg(0, "unexpected expression instead of an int/float/bool literal: eid=" 2041 - << arg->eid() << " while E_INTLIT=" << Expression::E_INTLIT); 2042 + MZN_MIPD__assert_hard_msg(0, "unexpected expression instead of an int/float/bool literal: eid=" 2043 + << arg->eid() << " while E_INTLIT=" << Expression::E_INTLIT); 2042 2044 2043 2045 return 0.0; 2044 2046 } ··· 2050 2052 2051 2053 template <class Elem, size_t N> 2052 2054 void checkOrResize(std::array<Elem, N>& cnt, size_t sz) { 2053 - MZN_MIPD_assert_hard(cnt.size() == sz); 2055 + MZN_MIPD__assert_hard(cnt.size() == sz); 2054 2056 } 2055 2057 2056 2058 template <class Array> ··· 2058 2060 ArrayLit* al = eval_array_lit(getEnv()->envi(), arg); 2059 2061 // if ( typeid(typename Array::pointer) == typeid(typename Array::iterator) ) // fixed 2060 2062 // array 2061 - // MZN_MIPD_assert_hard( vals.size() == al->v().size() ); 2063 + // MZN_MIPD__assert_hard( vals.size() == al->v().size() ); 2062 2064 // else 2063 2065 // vals.resize( al->v().size() ); 2064 2066 checkOrResize(vals, al->size()); ··· 2086 2088 } 2087 2089 // os << "N cliques " << _aCliques.size() << " total, " 2088 2090 // << nc << " final" << std::endl; 2089 - MZN_MIPD_assert_hard(nc); 2090 - MIPD_stats[N_POSTs_eqNmapsize] = static_cast<double>(_mNViews.size()); 2091 - double nSubintvAve = MIPD_stats[N_POSTs_NSubintvSum] / nc; 2092 - MZN_MIPD_assert_hard(MIPD_stats[N_POSTs_NSubintvSum]); 2093 - double dSubSizeAve = MIPD_stats[N_POSTs_SubSizeSum] / MIPD_stats[N_POSTs_NSubintvSum]; 2094 - os << MIPD_stats[N_POSTs_all] 2091 + MZN_MIPD__assert_hard(nc); 2092 + MIPD__stats[N_POSTs__eqNmapsize] = static_cast<double>(_mNViews.size()); 2093 + double nSubintvAve = MIPD__stats[N_POSTs__NSubintvSum] / nc; 2094 + MZN_MIPD__assert_hard(MIPD__stats[N_POSTs__NSubintvSum]); 2095 + double dSubSizeAve = MIPD__stats[N_POSTs__SubSizeSum] / MIPD__stats[N_POSTs__NSubintvSum]; 2096 + os << MIPD__stats[N_POSTs__all] 2095 2097 << " POSTs" 2096 - #ifdef MZN_MIPDOMAINS_PRINTMORESTATS 2098 + #ifdef __MZN__MIPDOMAINS__PRINTMORESTATS 2097 2099 " [ "; 2098 - MZN_MIPDOMAINS_PRINTMORESTATS 2099 - for (int i = N_POSTs_intCmpReif; i <= N_POSTs_floatAux; ++i) { 2100 - os << MIPD_stats[i] << ','; 2100 + for (int i = N_POSTs__intCmpReif; i <= N_POSTs__floatAux; ++i) { 2101 + os << MIPD__stats[i] << ','; 2101 2102 } 2102 2103 os << " ], LINEQ [ "; 2103 - for (int i = N_POSTs_eq2intlineq; i <= N_POSTs_eqNmapsize; ++i) { 2104 - os << MIPD_stats[i] << ','; 2104 + for (int i = N_POSTs__eq2intlineq; i <= N_POSTs__eqNmapsize; ++i) { 2105 + os << MIPD__stats[i] << ','; 2105 2106 } 2106 2107 os << " ]" 2107 2108 #endif 2108 2109 ", " 2109 - << MIPD_stats[N_POSTs_varsDirect] << " / " << MIPD_stats[N_POSTs_varsInvolved] << " vars, " 2110 - << nc << " cliques, " << MIPD_stats[N_POSTs_NSubintvMin] << " / " << nSubintvAve << " / " 2111 - << MIPD_stats[N_POSTs_NSubintvMax] << " NSubIntv m/a/m, " << MIPD_stats[N_POSTs_SubSizeMin] 2112 - << " / " << dSubSizeAve << " / " << MIPD_stats[N_POSTs_SubSizeMax] << " SubIntvSize m/a/m, " 2113 - << MIPD_stats[N_POSTs_cliquesWithEqEncode] << "+" << MIPD_stats[N_POSTs_clEEEnforced] << "(" 2114 - << MIPD_stats[N_POSTs_clEEFound] << ")" 2110 + << MIPD__stats[N_POSTs__varsDirect] << " / " << MIPD__stats[N_POSTs__varsInvolved] 2111 + << " vars, " << nc << " cliques, " << MIPD__stats[N_POSTs__NSubintvMin] << " / " 2112 + << nSubintvAve << " / " << MIPD__stats[N_POSTs__NSubintvMax] << " NSubIntv m/a/m, " 2113 + << MIPD__stats[N_POSTs__SubSizeMin] << " / " << dSubSizeAve << " / " 2114 + << MIPD__stats[N_POSTs__SubSizeMax] << " SubIntvSize m/a/m, " 2115 + << MIPD__stats[N_POSTs__cliquesWithEqEncode] << "+" << MIPD__stats[N_POSTs__clEEEnforced] 2116 + << "(" << MIPD__stats[N_POSTs__clEEFound] << ")" 2115 2117 << " clq eq_encoded "; 2116 2118 // << std::flush 2117 2119 if (TCliqueSorter::LinEqGraph::dCoefMax > 1.0) { ··· 2156 2158 } 2157 2159 template <class N> 2158 2160 void SetOfIntervals<N>::cutOut(const Interval<N>& intv) { 2159 - DBGOUT_MIPD_FLUSH("Cutting " << intv << " from " << (*this)); 2161 + DBGOUT_MIPD__("Cutting " << intv << " from " << (*this)); 2160 2162 if (this->empty()) { 2161 2163 return; 2162 2164 } ··· 2167 2169 if (this->begin() != it1) { 2168 2170 --it1; 2169 2171 const N it1l = it1->left; 2170 - MZN_MIPD_assert_hard(it1l <= intv.left); 2172 + MZN_MIPD__assert_hard(it1l <= intv.left); 2171 2173 if (it1->right > intv.left) { // split it 2172 2174 it2Del1 = split(it1, intv.left).second; 2173 2175 // it1->right = intv.left; READ-ONLY 2174 2176 // this->erase(it1); 2175 2177 // it1 = this->end(); 2176 2178 // auto iR = this->insert( Interval<N>( it1l, intv.left ) ); 2177 - // MZN_MIPD_assert_hard( iR.second ); 2179 + // MZN_MIPD__assert_hard( iR.second ); 2178 2180 } 2179 2181 } 2180 - DBGOUT_MIPD_FLUSH("; after split 1: " << (*this)); 2182 + DBGOUT_MIPD__("; after split 1: " << (*this)); 2181 2183 // Processing the right end: 2182 2184 auto it2 = this->lower_bound(Interval<N>(intv.right, intv.right + 1)); 2183 2185 auto it2Del2 = it2; 2184 2186 if (this->begin() != it2) { 2185 2187 --it2; 2186 - MZN_MIPD_assert_hard(it2->left < intv.right); 2188 + MZN_MIPD__assert_hard(it2->left < intv.right); 2187 2189 const N it2r = it2->right; 2188 2190 if ((Interval<N>::infPlus() == intv.right) ? (it2r > intv.right) 2189 2191 : (it2r >= intv.right)) { // >=: split it ··· 2197 2199 } 2198 2200 } 2199 2201 } 2200 - DBGOUT_MIPD_FLUSH("; after split 2: " << (*this)); 2201 - DBGOUT_MIPD_FLUSH("; cutting out: " << SetOfIntervals(it2Del1, it2Del2)); 2202 + DBGOUT_MIPD__("; after split 2: " << (*this)); 2203 + DBGOUT_MIPD__("; cutting out: " << SetOfIntervals(it2Del1, it2Del2)); 2202 2204 #ifdef MZN_DBG_CHECK_ITER_CUTOUT 2203 2205 { 2204 2206 auto it = this->begin(); 2205 2207 int nO = 0; 2206 2208 do { 2207 2209 if (it == it2Del1) { 2208 - MZN_MIPD_assert_hard(!nO); 2210 + MZN_MIPD__assert_hard(!nO); 2209 2211 ++nO; 2210 2212 } 2211 2213 if (it == it2Del2) { 2212 - MZN_MIPD_assert_hard(1 == nO); 2214 + MZN_MIPD__assert_hard(1 == nO); 2213 2215 ++nO; 2214 2216 } 2215 2217 if (this->end() == it) { ··· 2217 2219 } 2218 2220 ++it; 2219 2221 } while (true); 2220 - MZN_MIPD_assert_hard(2 == nO); 2222 + MZN_MIPD__assert_hard(2 == nO); 2221 2223 } 2222 2224 #endif 2223 2225 this->erase(it2Del1, it2Del2); ··· 2225 2227 } 2226 2228 template <class N> 2227 2229 typename SetOfIntervals<N>::SplitResult SetOfIntervals<N>::split(iterator& it, N pos) { 2228 - MZN_MIPD_assert_hard(pos >= it->left); 2229 - MZN_MIPD_assert_hard(pos <= it->right); 2230 + MZN_MIPD__assert_hard(pos >= it->left); 2231 + MZN_MIPD__assert_hard(pos <= it->right); 2230 2232 Interval<N> intvOld = *it; 2231 2233 this->erase(it); 2232 2234 auto it_01 = this->insert(Interval<N>(intvOld.left, pos));
-2
lib/ast.cpp
··· 1592 1592 ids.set_subset = ASTString("set_subset"); 1593 1593 ids.set_card = ASTString("set_card"); 1594 1594 ids.pow = ASTString("pow"); 1595 - ids.mzn_set_in_internal = ASTString("mzn_set_in_internal"); 1596 1595 1597 1596 ids.introduced_var = ASTString("__INTRODUCED"); 1598 1597 ids.anonEnumFromStrings = ASTString("anon_enum"); ··· 1832 1831 ids.set_subset.mark(); 1833 1832 ids.set_card.mark(); 1834 1833 ids.pow.mark(); 1835 - ids.mzn_set_in_internal.mark(); 1836 1834 1837 1835 ids.assert.mark(); 1838 1836 ids.mzn_deprecate.mark();
+1 -9
lib/builtins.cpp
··· 1619 1619 1620 1620 bool b_in_redundant_constraint(EnvI& env, Call* /*call*/) { return env.inRedundantConstraint > 0; } 1621 1621 1622 - bool b_in_symmetry_breaking_constraint(EnvI& env, Call* /*call*/) { 1623 - return env.inSymmetryBreakingConstraint > 0; 1624 - } 1625 - 1626 1622 Expression* b_set2array(EnvI& env, Call* call) { 1627 1623 assert(call->argCount() == 1); 1628 1624 GCLock lock; ··· 1789 1785 } 1790 1786 1791 1787 Expression* b_output_json(EnvI& env, Call* call) { 1792 - return create_json_output(env, false, false, false); 1788 + return create__json_output(env, false, false, false); 1793 1789 } 1794 1790 Expression* b_output_json_parameters(EnvI& env, Call* call) { 1795 1791 std::vector<Expression*> outputVars; ··· 3180 3176 { 3181 3177 rb(env, m, ASTString("mzn_in_redundant_constraint"), std::vector<Type>(), 3182 3178 b_in_redundant_constraint); 3183 - } 3184 - { 3185 - rb(env, m, ASTString("mzn_in_symmetry_breaking_constraint"), std::vector<Type>(), 3186 - b_in_symmetry_breaking_constraint); 3187 3179 } 3188 3180 { 3189 3181 std::vector<Type> t_length(1);
+1 -1
lib/cached/md5_cached.cmake
··· 1 1 set(lexer_lxx_md5_cached "6346180a9a94e9f5218239f10ce67a32") 2 - set(parser_yxx_md5_cached "95616f87b6ecbe14f80175ec8369e696") 2 + set(parser_yxx_md5_cached "dca3042b18c4db1f1e625d1d46bdb3d1") 3 3 set(regex_lexer_lxx_md5_cached "8906a52bfa0c5ae26354cb272348e656") 4 4 set(regex_parser_yxx_md5_cached "68ec070becef5e161c3b97d085b0810e")
+4 -4
lib/cached/minizinc/parser.tab.hh
··· 1 - /* A Bison parser, made by GNU Bison 3.7.4. */ 1 + /* A Bison parser, made by GNU Bison 3.6.4. */ 2 2 3 3 /* Bison interface for Yacc-like parsers in C 4 4 ··· 35 35 especially those whose name start with YY_ or yy_. They are 36 36 private implementation details that can be changed or removed. */ 37 37 38 - #ifndef YY_MZN_YY_USERS_TACK_PROGRAMMING_MINIZINC_LIBMZN_BUILD_XCODE_INCLUDE_MINIZINC_PARSER_TAB_HH_INCLUDED 39 - # define YY_MZN_YY_USERS_TACK_PROGRAMMING_MINIZINC_LIBMZN_BUILD_XCODE_INCLUDE_MINIZINC_PARSER_TAB_HH_INCLUDED 38 + #ifndef YY_MZN_YY_USERS_TACK_PROGRAMMING_MINIZINC_LIBMZN_DEVELOP_BUILD_INCLUDE_MINIZINC_PARSER_TAB_HH_INCLUDED 39 + # define YY_MZN_YY_USERS_TACK_PROGRAMMING_MINIZINC_LIBMZN_DEVELOP_BUILD_INCLUDE_MINIZINC_PARSER_TAB_HH_INCLUDED 40 40 /* Debug traces. */ 41 41 #ifndef YYDEBUG 42 42 # define YYDEBUG 0 ··· 234 234 235 235 int mzn_yyparse (void *parm); 236 236 237 - #endif /* !YY_MZN_YY_USERS_TACK_PROGRAMMING_MINIZINC_LIBMZN_BUILD_XCODE_INCLUDE_MINIZINC_PARSER_TAB_HH_INCLUDED */ 237 + #endif /* !YY_MZN_YY_USERS_TACK_PROGRAMMING_MINIZINC_LIBMZN_DEVELOP_BUILD_INCLUDE_MINIZINC_PARSER_TAB_HH_INCLUDED */
+361 -347
lib/cached/parser.tab.cpp
··· 1 - /* A Bison parser, made by GNU Bison 3.7.4. */ 1 + /* A Bison parser, made by GNU Bison 3.6.4. */ 2 2 3 3 /* Bison implementation for Yacc-like parsers in C 4 4 ··· 45 45 define necessary library symbols; they are noted "INFRINGES ON 46 46 USER NAME SPACE" below. */ 47 47 48 - /* Identify Bison output, and Bison version. */ 49 - #define YYBISON 30704 48 + /* Identify Bison output. */ 49 + #define YYBISON 1 50 50 51 - /* Bison version string. */ 52 - #define YYBISON_VERSION "3.7.4" 51 + /* Bison version. */ 52 + #define YYBISON_VERSION "3.6.4" 53 53 54 54 /* Skeleton name. */ 55 55 #define YYSKELETON_NAME "yacc.c" ··· 730 730 /* YYNSTATES -- Number of states. */ 731 731 #define YYNSTATES 588 732 732 733 - /* YYMAXUTOK -- Last valid token kind. */ 734 733 #define YYMAXUTOK 387 735 734 736 735 ··· 2856 2855 int 2857 2856 yyparse (void *parm) 2858 2857 { 2859 - /* Lookahead token kind. */ 2858 + /* The lookahead symbol. */ 2860 2859 int yychar; 2861 2860 2862 2861 ··· 2875 2874 YYLTYPE yylloc = yyloc_default; 2876 2875 2877 2876 /* Number of syntax errors so far. */ 2878 - int yynerrs = 0; 2877 + int yynerrs; 2879 2878 2880 - yy_state_fast_t yystate = 0; 2879 + yy_state_fast_t yystate; 2881 2880 /* Number of tokens to shift before error messages enabled. */ 2882 - int yyerrstatus = 0; 2881 + int yyerrstatus; 2883 2882 2884 - /* Refer to the stacks through separate pointers, to allow yyoverflow 2883 + /* The stacks and their tools: 2884 + 'yyss': related to states. 2885 + 'yyvs': related to semantic values. 2886 + 'yyls': related to locations. 2887 + 2888 + Refer to the stacks through separate pointers, to allow yyoverflow 2885 2889 to reallocate them elsewhere. */ 2886 2890 2887 2891 /* Their size. */ 2888 - YYPTRDIFF_T yystacksize = YYINITDEPTH; 2892 + YYPTRDIFF_T yystacksize; 2889 2893 2890 - /* The state stack: array, bottom, top. */ 2894 + /* The state stack. */ 2891 2895 yy_state_t yyssa[YYINITDEPTH]; 2892 - yy_state_t *yyss = yyssa; 2893 - yy_state_t *yyssp = yyss; 2896 + yy_state_t *yyss; 2897 + yy_state_t *yyssp; 2894 2898 2895 - /* The semantic value stack: array, bottom, top. */ 2899 + /* The semantic value stack. */ 2896 2900 YYSTYPE yyvsa[YYINITDEPTH]; 2897 - YYSTYPE *yyvs = yyvsa; 2898 - YYSTYPE *yyvsp = yyvs; 2901 + YYSTYPE *yyvs; 2902 + YYSTYPE *yyvsp; 2899 2903 2900 - /* The location stack: array, bottom, top. */ 2904 + /* The location stack. */ 2901 2905 YYLTYPE yylsa[YYINITDEPTH]; 2902 - YYLTYPE *yyls = yylsa; 2903 - YYLTYPE *yylsp = yyls; 2906 + YYLTYPE *yyls; 2907 + YYLTYPE *yylsp; 2904 2908 2905 2909 int yyn; 2906 2910 /* The return value of yyparse. */ 2907 2911 int yyresult; 2908 - /* Lookahead symbol kind. */ 2912 + /* Lookahead token as an internal (translated) token number. */ 2909 2913 yysymbol_kind_t yytoken = YYSYMBOL_YYEMPTY; 2910 2914 /* The variables used to return semantic value and location from the 2911 2915 action routines. */ ··· 2925 2929 /* The number of symbols on the RHS of the reduced rule. 2926 2930 Keep to zero when no symbol should be popped. */ 2927 2931 int yylen = 0; 2932 + 2933 + yynerrs = 0; 2934 + yystate = 0; 2935 + yyerrstatus = 0; 2936 + 2937 + yystacksize = YYINITDEPTH; 2938 + yyssp = yyss = yyssa; 2939 + yyvsp = yyvs = yyvsa; 2940 + yylsp = yyls = yylsa; 2941 + 2928 2942 2929 2943 YYDPRINTF ((stderr, "Starting parse\n")); 2930 2944 ··· 3144 3158 YY_REDUCE_PRINT (yyn); 3145 3159 switch (yyn) 3146 3160 { 3147 - case 5: /* item_list_head: item */ 3161 + case 5: 3148 3162 { 3149 3163 ParserState* pp = static_cast<ParserState*>(parm); 3150 3164 if ((yyvsp[0].item)) { ··· 3155 3169 } 3156 3170 break; 3157 3171 3158 - case 6: /* item_list_head: doc_file_comments item */ 3172 + case 6: 3159 3173 { 3160 3174 ParserState* pp = static_cast<ParserState*>(parm); 3161 3175 if ((yyvsp[0].item)) { ··· 3166 3180 } 3167 3181 break; 3168 3182 3169 - case 7: /* item_list_head: item_list_head ';' item */ 3183 + case 7: 3170 3184 { 3171 3185 ParserState* pp = static_cast<ParserState*>(parm); 3172 3186 if ((yyvsp[0].item)) { ··· 3177 3191 } 3178 3192 break; 3179 3193 3180 - case 8: /* item_list_head: item_list_head ';' doc_file_comments item */ 3194 + case 8: 3181 3195 { 3182 3196 ParserState* pp = static_cast<ParserState*>(parm); 3183 3197 if ((yyvsp[0].item)) { ··· 3188 3202 } 3189 3203 break; 3190 3204 3191 - case 9: /* item_list_head: item error_item_start */ 3205 + case 9: 3192 3206 { yyerror(&(yylsp[0]), parm, "unexpected item, expecting ';' or end of file"); YYERROR; } 3193 3207 break; 3194 3208 3195 - case 11: /* doc_file_comments: "file-level documentation comment" */ 3209 + case 11: 3196 3210 { 3197 3211 ParserState* pp = static_cast<ParserState*>(parm); 3198 3212 if (pp->parseDocComments && (yyvsp[0].sValue)) { ··· 3202 3216 } 3203 3217 break; 3204 3218 3205 - case 12: /* doc_file_comments: doc_file_comments "file-level documentation comment" */ 3219 + case 12: 3206 3220 { 3207 3221 ParserState* pp = static_cast<ParserState*>(parm); 3208 3222 if (pp->parseDocComments && (yyvsp[0].sValue)) { ··· 3212 3226 } 3213 3227 break; 3214 3228 3215 - case 15: /* item: "documentation comment" item_tail */ 3229 + case 15: 3216 3230 { (yyval.item) = (yyvsp[0].item); 3217 3231 ParserState* pp = static_cast<ParserState*>(parm); 3218 3232 if (FunctionI* fi = Item::dynamicCast<FunctionI>((yyval.item))) { ··· 3230 3244 } 3231 3245 break; 3232 3246 3233 - case 16: /* item: item_tail */ 3247 + case 16: 3234 3248 { (yyval.item) = (yyvsp[0].item); } 3235 3249 break; 3236 3250 3237 - case 17: /* item_tail: include_item */ 3251 + case 17: 3238 3252 { (yyval.item)=notInDatafile(&(yyloc),parm,"include") ? (yyvsp[0].item) : nullptr; } 3239 3253 break; 3240 3254 3241 - case 18: /* item_tail: vardecl_item */ 3255 + case 18: 3242 3256 { (yyval.item)=notInDatafile(&(yyloc),parm,"variable declaration") ? (yyvsp[0].item) : nullptr; } 3243 3257 break; 3244 3258 3245 - case 20: /* item_tail: constraint_item */ 3259 + case 20: 3246 3260 { (yyval.item)=notInDatafile(&(yyloc),parm,"constraint") ? (yyvsp[0].item) : nullptr; } 3247 3261 break; 3248 3262 3249 - case 21: /* item_tail: solve_item */ 3263 + case 21: 3250 3264 { (yyval.item)=notInDatafile(&(yyloc),parm,"solve") ? (yyvsp[0].item) : nullptr; } 3251 3265 break; 3252 3266 3253 - case 22: /* item_tail: output_item */ 3267 + case 22: 3254 3268 { (yyval.item)=notInDatafile(&(yyloc),parm,"output") ? (yyvsp[0].item) : nullptr; } 3255 3269 break; 3256 3270 3257 - case 23: /* item_tail: predicate_item */ 3271 + case 23: 3258 3272 { (yyval.item)=notInDatafile(&(yyloc),parm,"predicate") ? (yyvsp[0].item) : nullptr; } 3259 3273 break; 3260 3274 3261 - case 24: /* item_tail: function_item */ 3275 + case 24: 3262 3276 { (yyval.item)=notInDatafile(&(yyloc),parm,"predicate") ? (yyvsp[0].item) : nullptr; } 3263 3277 break; 3264 3278 3265 - case 25: /* item_tail: annotation_item */ 3279 + case 25: 3266 3280 { (yyval.item)=notInDatafile(&(yyloc),parm,"annotation") ? (yyvsp[0].item) : nullptr; } 3267 3281 break; 3268 3282 3269 - case 35: /* include_item: "include" "string literal" */ 3283 + case 35: 3270 3284 { ParserState* pp = static_cast<ParserState*>(parm); 3271 - string canonicalName=pp->canonicalFilename((yyvsp[0].sValue)); 3272 - map<string,Model*>::iterator ret = pp->seenModels.find(canonicalName); 3285 + map<string,Model*>::iterator ret = pp->seenModels.find((yyvsp[0].sValue)); 3273 3286 IncludeI* ii = new IncludeI((yyloc),ASTString((yyvsp[0].sValue))); 3274 3287 (yyval.item) = ii; 3275 3288 if (ret == pp->seenModels.end()) { 3276 3289 Model* im = new Model; 3277 3290 im->setParent(pp->model); 3278 - im->setFilename(canonicalName); 3291 + im->setFilename((yyvsp[0].sValue)); 3279 3292 string fpath = FileUtils::dir_name(pp->filename); 3293 + string fbase = FileUtils::base_name(pp->filename); 3280 3294 if (fpath=="") 3281 3295 fpath="./"; 3282 - pp->files.emplace_back(im, ii, fpath, canonicalName, pp->isSTDLib); 3296 + pp->files.emplace_back(im, ii, fpath, (yyvsp[0].sValue), pp->isSTDLib); 3283 3297 ii->m(im); 3284 - pp->seenModels.insert(pair<string,Model*>(canonicalName,im)); 3298 + pp->seenModels.insert(pair<string,Model*>((yyvsp[0].sValue),im)); 3285 3299 } else { 3286 3300 ii->m(ret->second, false); 3287 3301 } ··· 3289 3303 } 3290 3304 break; 3291 3305 3292 - case 36: /* vardecl_item: ti_expr_and_id annotations */ 3306 + case 36: 3293 3307 { if ((yyvsp[-1].vardeclexpr) && (yyvsp[0].expressions1d)) (yyvsp[-1].vardeclexpr)->addAnnotations(*(yyvsp[0].expressions1d)); 3294 3308 if ((yyvsp[-1].vardeclexpr)) 3295 3309 (yyval.item) = new VarDeclI((yyloc),(yyvsp[-1].vardeclexpr)); ··· 3297 3311 } 3298 3312 break; 3299 3313 3300 - case 37: /* vardecl_item: ti_expr_and_id annotations "=" expr */ 3314 + case 37: 3301 3315 { if ((yyvsp[-3].vardeclexpr)) (yyvsp[-3].vardeclexpr)->e((yyvsp[0].expression)); 3302 3316 if ((yyvsp[-3].vardeclexpr) && (yyvsp[-2].expressions1d)) (yyvsp[-3].vardeclexpr)->addAnnotations(*(yyvsp[-2].expressions1d)); 3303 3317 if ((yyvsp[-3].vardeclexpr)) ··· 3306 3320 } 3307 3321 break; 3308 3322 3309 - case 38: /* vardecl_item: "enum" "identifier" annotations */ 3323 + case 38: 3310 3324 { 3311 3325 TypeInst* ti = new TypeInst((yyloc),Type::parsetint()); 3312 3326 ti->setIsEnum(true); ··· 3318 3332 } 3319 3333 break; 3320 3334 3321 - case 39: /* vardecl_item: "enum" "identifier" annotations "=" enum_init */ 3335 + case 39: 3322 3336 { 3323 3337 if ((yyvsp[0].expressions1d)) { 3324 3338 TypeInst* ti = new TypeInst((yyloc),Type::parsetint()); ··· 3338 3352 } 3339 3353 break; 3340 3354 3341 - case 40: /* vardecl_item: "enum" "identifier" annotations "=" "[" string_lit_list "]" */ 3355 + case 40: 3342 3356 { 3343 3357 TypeInst* ti = new TypeInst((yyloc),Type::parsetint()); 3344 3358 ti->setIsEnum(true); ··· 3354 3368 } 3355 3369 break; 3356 3370 3357 - case 41: /* enum_init: enum_construct */ 3371 + case 41: 3358 3372 { 3359 3373 (yyval.expressions1d) = new std::vector<Expression*>({(yyvsp[0].expression)}); 3360 3374 } 3361 3375 break; 3362 3376 3363 - case 42: /* enum_init: enum_init "++" enum_construct */ 3377 + case 42: 3364 3378 { 3365 3379 (yyval.expressions1d) = (yyvsp[-2].expressions1d); 3366 3380 if ((yyval.expressions1d)) { ··· 3369 3383 } 3370 3384 break; 3371 3385 3372 - case 43: /* enum_construct: '{' enum_id_list '}' */ 3386 + case 43: 3373 3387 { 3374 3388 (yyval.expression) = new SetLit((yyloc), *(yyvsp[-1].expressions1d)); 3375 3389 delete (yyvsp[-1].expressions1d); 3376 3390 } 3377 3391 break; 3378 3392 3379 - case 44: /* enum_construct: "identifier" '(' expr ')' */ 3393 + case 44: 3380 3394 { 3381 3395 vector<Expression*> args({(yyvsp[-1].expression)}); 3382 3396 (yyval.expression) = new Call((yyloc), ASTString((yyvsp[-3].sValue)), args); ··· 3384 3398 } 3385 3399 break; 3386 3400 3387 - case 45: /* string_lit_list: %empty */ 3401 + case 45: 3388 3402 { (yyval.expressions1d) = new std::vector<Expression*>(); } 3389 3403 break; 3390 3404 3391 - case 46: /* string_lit_list: "string literal" */ 3405 + case 46: 3392 3406 { (yyval.expressions1d) = new std::vector<Expression*>(); 3393 3407 (yyval.expressions1d)->push_back(new StringLit((yyloc), (yyvsp[0].sValue))); free((yyvsp[0].sValue)); 3394 3408 } 3395 3409 break; 3396 3410 3397 - case 47: /* string_lit_list: string_lit_list ',' "string literal" */ 3411 + case 47: 3398 3412 { (yyval.expressions1d) = (yyvsp[-2].expressions1d); 3399 3413 if ((yyval.expressions1d)) (yyval.expressions1d)->push_back(new StringLit((yyloc), (yyvsp[0].sValue))); 3400 3414 free((yyvsp[0].sValue)); 3401 3415 } 3402 3416 break; 3403 3417 3404 - case 48: /* enum_id_list: %empty */ 3418 + case 48: 3405 3419 { (yyval.expressions1d) = new std::vector<Expression*>(); } 3406 3420 break; 3407 3421 3408 - case 49: /* enum_id_list: "identifier" */ 3422 + case 49: 3409 3423 { (yyval.expressions1d) = new std::vector<Expression*>(); 3410 3424 (yyval.expressions1d)->push_back(new Id((yyloc),(yyvsp[0].sValue),nullptr)); free((yyvsp[0].sValue)); 3411 3425 } 3412 3426 break; 3413 3427 3414 - case 50: /* enum_id_list: enum_id_list ',' "identifier" */ 3428 + case 50: 3415 3429 { (yyval.expressions1d) = (yyvsp[-2].expressions1d); if ((yyval.expressions1d)) (yyval.expressions1d)->push_back(new Id((yyloc),(yyvsp[0].sValue),nullptr)); free((yyvsp[0].sValue)); } 3416 3430 break; 3417 3431 3418 - case 51: /* assign_item: "identifier" "=" expr */ 3432 + case 51: 3419 3433 { (yyval.item) = new AssignI((yyloc),(yyvsp[-2].sValue),(yyvsp[0].expression)); 3420 3434 free((yyvsp[-2].sValue)); 3421 3435 } 3422 3436 break; 3423 3437 3424 - case 52: /* constraint_item: "constraint" expr */ 3438 + case 52: 3425 3439 { (yyval.item) = new ConstraintI((yyloc),(yyvsp[0].expression));} 3426 3440 break; 3427 3441 3428 - case 53: /* constraint_item: "constraint" "::" string_expr expr */ 3442 + case 53: 3429 3443 { (yyval.item) = new ConstraintI((yyloc),(yyvsp[0].expression)); 3430 3444 if ((yyvsp[0].expression) && (yyvsp[-1].expression)) 3431 3445 (yyval.item)->cast<ConstraintI>()->e()->ann().add(new Call((yylsp[-2]), ASTString("mzn_constraint_name"), {(yyvsp[-1].expression)})); 3432 3446 } 3433 3447 break; 3434 3448 3435 - case 54: /* solve_item: "solve" annotations "satisfy" */ 3449 + case 54: 3436 3450 { (yyval.item) = SolveI::sat((yyloc)); 3437 3451 if ((yyval.item) && (yyvsp[-1].expressions1d)) (yyval.item)->cast<SolveI>()->ann().add(*(yyvsp[-1].expressions1d)); 3438 3452 delete (yyvsp[-1].expressions1d); 3439 3453 } 3440 3454 break; 3441 3455 3442 - case 55: /* solve_item: "solve" annotations "minimize" expr */ 3456 + case 55: 3443 3457 { (yyval.item) = SolveI::min((yyloc),(yyvsp[0].expression)); 3444 3458 if ((yyval.item) && (yyvsp[-2].expressions1d)) (yyval.item)->cast<SolveI>()->ann().add(*(yyvsp[-2].expressions1d)); 3445 3459 delete (yyvsp[-2].expressions1d); 3446 3460 } 3447 3461 break; 3448 3462 3449 - case 56: /* solve_item: "solve" annotations "maximize" expr */ 3463 + case 56: 3450 3464 { (yyval.item) = SolveI::max((yyloc),(yyvsp[0].expression)); 3451 3465 if ((yyval.item) && (yyvsp[-2].expressions1d)) (yyval.item)->cast<SolveI>()->ann().add(*(yyvsp[-2].expressions1d)); 3452 3466 delete (yyvsp[-2].expressions1d); 3453 3467 } 3454 3468 break; 3455 3469 3456 - case 57: /* output_item: "output" expr */ 3470 + case 57: 3457 3471 { (yyval.item) = new OutputI((yyloc),(yyvsp[0].expression));} 3458 3472 break; 3459 3473 3460 - case 58: /* predicate_item: "predicate" "identifier" params annotations operation_item_tail */ 3474 + case 58: 3461 3475 { 3462 3476 ParserState* pp = static_cast<ParserState*>(parm); 3463 3477 if ((yyvsp[-2].vardeclexprs)) (yyval.item) = new FunctionI((yyloc),(yyvsp[-3].sValue),new TypeInst((yyloc), ··· 3469 3483 } 3470 3484 break; 3471 3485 3472 - case 59: /* predicate_item: "test" "identifier" params annotations operation_item_tail */ 3486 + case 59: 3473 3487 { 3474 3488 ParserState* pp = static_cast<ParserState*>(parm); 3475 3489 if ((yyvsp[-2].vardeclexprs)) (yyval.item) = new FunctionI((yyloc),(yyvsp[-3].sValue),new TypeInst((yyloc), ··· 3481 3495 } 3482 3496 break; 3483 3497 3484 - case 60: /* predicate_item: "predicate" "identifier" "^-1" params annotations operation_item_tail */ 3498 + case 60: 3485 3499 { if ((yyvsp[-2].vardeclexprs)) (yyval.item) = new FunctionI((yyloc),std::string((yyvsp[-4].sValue))+"⁻¹",new TypeInst((yyloc), 3486 3500 Type::varbool()),*(yyvsp[-2].vardeclexprs),(yyvsp[0].expression)); 3487 3501 if ((yyval.item) && (yyvsp[-1].expressions1d)) (yyval.item)->cast<FunctionI>()->ann().add(*(yyvsp[-1].expressions1d)); ··· 3491 3505 } 3492 3506 break; 3493 3507 3494 - case 61: /* predicate_item: "test" "identifier" "^-1" params annotations operation_item_tail */ 3508 + case 61: 3495 3509 { if ((yyvsp[-2].vardeclexprs)) (yyval.item) = new FunctionI((yyloc),std::string((yyvsp[-4].sValue))+"⁻¹",new TypeInst((yyloc), 3496 3510 Type::parbool()),*(yyvsp[-2].vardeclexprs),(yyvsp[0].expression)); 3497 3511 if ((yyval.item) && (yyvsp[-1].expressions1d)) (yyval.item)->cast<FunctionI>()->ann().add(*(yyvsp[-1].expressions1d)); ··· 3501 3515 } 3502 3516 break; 3503 3517 3504 - case 62: /* function_item: "function" ti_expr ':' id_or_quoted_op params annotations operation_item_tail */ 3518 + case 62: 3505 3519 { 3506 3520 ParserState* pp = static_cast<ParserState*>(parm); 3507 3521 if ((yyvsp[-2].vardeclexprs)) (yyval.item) = new FunctionI((yyloc),(yyvsp[-3].sValue),(yyvsp[-5].tiexpr),*(yyvsp[-2].vardeclexprs),(yyvsp[0].expression),pp->isSTDLib); ··· 3512 3526 } 3513 3527 break; 3514 3528 3515 - case 63: /* function_item: ti_expr ':' "identifier" '(' params_list ')' annotations operation_item_tail */ 3529 + case 63: 3516 3530 { 3517 3531 ParserState* pp = static_cast<ParserState*>(parm); 3518 3532 if ((yyvsp[-3].vardeclexprs)) (yyval.item) = new FunctionI((yyloc),(yyvsp[-5].sValue),(yyvsp[-7].tiexpr),*(yyvsp[-3].vardeclexprs),(yyvsp[0].expression),pp->isSTDLib); ··· 3523 3537 } 3524 3538 break; 3525 3539 3526 - case 64: /* annotation_item: "annotation" "identifier" params */ 3540 + case 64: 3527 3541 { 3528 3542 ParserState* pp = static_cast<ParserState*>(parm); 3529 3543 TypeInst* ti=new TypeInst((yylsp[-2]),Type::ann()); ··· 3538 3552 } 3539 3553 break; 3540 3554 3541 - case 65: /* annotation_item: "annotation" "identifier" params "=" expr */ 3555 + case 65: 3542 3556 { 3543 3557 ParserState* pp = static_cast<ParserState*>(parm); 3544 3558 TypeInst* ti=new TypeInst((yylsp[-4]),Type::ann()); ··· 3547 3561 } 3548 3562 break; 3549 3563 3550 - case 66: /* operation_item_tail: %empty */ 3564 + case 66: 3551 3565 { (yyval.expression)=nullptr; } 3552 3566 break; 3553 3567 3554 - case 67: /* operation_item_tail: "=" expr */ 3568 + case 67: 3555 3569 { (yyval.expression)=(yyvsp[0].expression); } 3556 3570 break; 3557 3571 3558 - case 68: /* params: %empty */ 3572 + case 68: 3559 3573 { (yyval.vardeclexprs)=new vector<VarDecl*>(); } 3560 3574 break; 3561 3575 3562 - case 69: /* params: '(' params_list ')' */ 3576 + case 69: 3563 3577 { (yyval.vardeclexprs)=(yyvsp[-1].vardeclexprs); } 3564 3578 break; 3565 3579 3566 - case 70: /* params: '(' error ')' */ 3580 + case 70: 3567 3581 { (yyval.vardeclexprs)=new vector<VarDecl*>(); } 3568 3582 break; 3569 3583 3570 - case 71: /* params_list: %empty */ 3584 + case 71: 3571 3585 { (yyval.vardeclexprs)=new vector<VarDecl*>(); } 3572 3586 break; 3573 3587 3574 - case 72: /* params_list: params_list_head comma_or_none */ 3588 + case 72: 3575 3589 { (yyval.vardeclexprs)=(yyvsp[-1].vardeclexprs); } 3576 3590 break; 3577 3591 3578 - case 73: /* params_list_head: ti_expr_and_id_or_anon */ 3592 + case 73: 3579 3593 { (yyval.vardeclexprs)=new vector<VarDecl*>(); 3580 3594 if ((yyvsp[0].vardeclexpr)) (yyvsp[0].vardeclexpr)->toplevel(false); 3581 3595 if ((yyvsp[0].vardeclexpr)) (yyval.vardeclexprs)->push_back((yyvsp[0].vardeclexpr)); } 3582 3596 break; 3583 3597 3584 - case 74: /* params_list_head: params_list_head ',' ti_expr_and_id_or_anon */ 3598 + case 74: 3585 3599 { (yyval.vardeclexprs)=(yyvsp[-2].vardeclexprs); 3586 3600 if ((yyvsp[0].vardeclexpr)) (yyvsp[0].vardeclexpr)->toplevel(false); 3587 3601 if ((yyvsp[-2].vardeclexprs) && (yyvsp[0].vardeclexpr)) (yyvsp[-2].vardeclexprs)->push_back((yyvsp[0].vardeclexpr)); } 3588 3602 break; 3589 3603 3590 - case 77: /* ti_expr_and_id_or_anon: ti_expr_and_id */ 3604 + case 77: 3591 3605 { (yyval.vardeclexpr)=(yyvsp[0].vardeclexpr); } 3592 3606 break; 3593 3607 3594 - case 78: /* ti_expr_and_id_or_anon: ti_expr */ 3608 + case 78: 3595 3609 { if ((yyvsp[0].tiexpr)) (yyval.vardeclexpr)=new VarDecl((yyloc), (yyvsp[0].tiexpr), ""); } 3596 3610 break; 3597 3611 3598 - case 79: /* ti_expr_and_id: ti_expr ':' "identifier" */ 3612 + case 79: 3599 3613 { if ((yyvsp[-2].tiexpr) && (yyvsp[0].sValue)) { 3600 3614 Id* ident = new Id((yylsp[0]), (yyvsp[0].sValue), nullptr); 3601 3615 (yyval.vardeclexpr) = new VarDecl((yyloc), (yyvsp[-2].tiexpr), ident); ··· 3604 3618 } 3605 3619 break; 3606 3620 3607 - case 80: /* ti_expr_list: ti_expr_list_head comma_or_none */ 3621 + case 80: 3608 3622 { (yyval.tiexprs)=(yyvsp[-1].tiexprs); } 3609 3623 break; 3610 3624 3611 - case 81: /* ti_expr_list_head: ti_expr */ 3625 + case 81: 3612 3626 { (yyval.tiexprs)=new vector<TypeInst*>(); (yyval.tiexprs)->push_back((yyvsp[0].tiexpr)); } 3613 3627 break; 3614 3628 3615 - case 82: /* ti_expr_list_head: ti_expr_list_head ',' ti_expr */ 3629 + case 82: 3616 3630 { (yyval.tiexprs)=(yyvsp[-2].tiexprs); if ((yyvsp[-2].tiexprs) && (yyvsp[0].tiexpr)) (yyvsp[-2].tiexprs)->push_back((yyvsp[0].tiexpr)); } 3617 3631 break; 3618 3632 3619 - case 84: /* ti_expr: "array" "[" ti_expr_list "]" "of" base_ti_expr */ 3633 + case 84: 3620 3634 { 3621 3635 (yyval.tiexpr) = (yyvsp[0].tiexpr); 3622 3636 if ((yyval.tiexpr) && (yyvsp[-3].tiexprs)) (yyval.tiexpr)->setRanges(*(yyvsp[-3].tiexprs)); ··· 3624 3638 } 3625 3639 break; 3626 3640 3627 - case 85: /* ti_expr: "list" "of" base_ti_expr */ 3641 + case 85: 3628 3642 { 3629 3643 (yyval.tiexpr) = (yyvsp[0].tiexpr); 3630 3644 std::vector<TypeInst*> ti(1); ··· 3633 3647 } 3634 3648 break; 3635 3649 3636 - case 86: /* base_ti_expr: base_ti_expr_tail */ 3650 + case 86: 3637 3651 { (yyval.tiexpr) = (yyvsp[0].tiexpr); 3638 3652 } 3639 3653 break; 3640 3654 3641 - case 87: /* base_ti_expr: "opt" base_ti_expr_tail */ 3655 + case 87: 3642 3656 { (yyval.tiexpr) = (yyvsp[0].tiexpr); 3643 3657 if ((yyval.tiexpr)) { 3644 3658 Type tt = (yyval.tiexpr)->type(); ··· 3648 3662 } 3649 3663 break; 3650 3664 3651 - case 88: /* base_ti_expr: "par" opt_opt base_ti_expr_tail */ 3665 + case 88: 3652 3666 { (yyval.tiexpr) = (yyvsp[0].tiexpr); 3653 3667 if ((yyval.tiexpr) && (yyvsp[-1].bValue)) { 3654 3668 Type tt = (yyval.tiexpr)->type(); ··· 3658 3672 } 3659 3673 break; 3660 3674 3661 - case 89: /* base_ti_expr: "var" opt_opt base_ti_expr_tail */ 3675 + case 89: 3662 3676 { (yyval.tiexpr) = (yyvsp[0].tiexpr); 3663 3677 if ((yyval.tiexpr)) { 3664 3678 Type tt = (yyval.tiexpr)->type(); ··· 3669 3683 } 3670 3684 break; 3671 3685 3672 - case 90: /* base_ti_expr: "set" "of" base_ti_expr_tail */ 3686 + case 90: 3673 3687 { (yyval.tiexpr) = (yyvsp[0].tiexpr); 3674 3688 if ((yyval.tiexpr)) { 3675 3689 Type tt = (yyval.tiexpr)->type(); ··· 3679 3693 } 3680 3694 break; 3681 3695 3682 - case 91: /* base_ti_expr: "opt" "set" "of" base_ti_expr_tail */ 3696 + case 91: 3683 3697 { (yyval.tiexpr) = (yyvsp[0].tiexpr); 3684 3698 if ((yyval.tiexpr)) { 3685 3699 Type tt = (yyval.tiexpr)->type(); ··· 3690 3704 } 3691 3705 break; 3692 3706 3693 - case 92: /* base_ti_expr: "par" opt_opt "set" "of" base_ti_expr_tail */ 3707 + case 92: 3694 3708 { (yyval.tiexpr) = (yyvsp[0].tiexpr); 3695 3709 if ((yyval.tiexpr)) { 3696 3710 Type tt = (yyval.tiexpr)->type(); ··· 3701 3715 } 3702 3716 break; 3703 3717 3704 - case 93: /* base_ti_expr: "var" opt_opt "set" "of" base_ti_expr_tail */ 3718 + case 93: 3705 3719 { (yyval.tiexpr) = (yyvsp[0].tiexpr); 3706 3720 if ((yyval.tiexpr)) { 3707 3721 Type tt = (yyval.tiexpr)->type(); ··· 3713 3727 } 3714 3728 break; 3715 3729 3716 - case 94: /* opt_opt: %empty */ 3730 + case 94: 3717 3731 { (yyval.bValue) = false; } 3718 3732 break; 3719 3733 3720 - case 95: /* opt_opt: "opt" */ 3734 + case 95: 3721 3735 { (yyval.bValue) = true; } 3722 3736 break; 3723 3737 3724 - case 96: /* base_ti_expr_tail: "int" */ 3738 + case 96: 3725 3739 { (yyval.tiexpr) = new TypeInst((yyloc),Type::parint()); } 3726 3740 break; 3727 3741 3728 - case 97: /* base_ti_expr_tail: "bool" */ 3742 + case 97: 3729 3743 { (yyval.tiexpr) = new TypeInst((yyloc),Type::parbool()); } 3730 3744 break; 3731 3745 3732 - case 98: /* base_ti_expr_tail: "float" */ 3746 + case 98: 3733 3747 { (yyval.tiexpr) = new TypeInst((yyloc),Type::parfloat()); } 3734 3748 break; 3735 3749 3736 - case 99: /* base_ti_expr_tail: "string" */ 3750 + case 99: 3737 3751 { (yyval.tiexpr) = new TypeInst((yyloc),Type::parstring()); } 3738 3752 break; 3739 3753 3740 - case 100: /* base_ti_expr_tail: "ann" */ 3754 + case 100: 3741 3755 { (yyval.tiexpr) = new TypeInst((yyloc),Type::ann()); } 3742 3756 break; 3743 3757 3744 - case 101: /* base_ti_expr_tail: set_expr */ 3758 + case 101: 3745 3759 { if ((yyvsp[0].expression)) (yyval.tiexpr) = new TypeInst((yyloc),Type(),(yyvsp[0].expression)); } 3746 3760 break; 3747 3761 3748 - case 102: /* base_ti_expr_tail: "type-inst identifier" */ 3762 + case 102: 3749 3763 { (yyval.tiexpr) = new TypeInst((yyloc),Type::top(), 3750 3764 new TIId((yyloc), (yyvsp[0].sValue))); 3751 3765 free((yyvsp[0].sValue)); 3752 3766 } 3753 3767 break; 3754 3768 3755 - case 103: /* base_ti_expr_tail: "type-inst enum identifier" */ 3769 + case 103: 3756 3770 { (yyval.tiexpr) = new TypeInst((yyloc),Type::parint(), 3757 3771 new TIId((yyloc), (yyvsp[0].sValue))); 3758 3772 free((yyvsp[0].sValue)); 3759 3773 } 3760 3774 break; 3761 3775 3762 - case 105: /* array_access_expr_list_head: array_access_expr */ 3776 + case 105: 3763 3777 { (yyval.expressions1d)=new std::vector<MiniZinc::Expression*>; (yyval.expressions1d)->push_back((yyvsp[0].expression)); } 3764 3778 break; 3765 3779 3766 - case 106: /* array_access_expr_list_head: array_access_expr_list_head ',' array_access_expr */ 3780 + case 106: 3767 3781 { (yyval.expressions1d)=(yyvsp[-2].expressions1d); if ((yyval.expressions1d) && (yyvsp[0].expression)) (yyval.expressions1d)->push_back((yyvsp[0].expression)); } 3768 3782 break; 3769 3783 3770 - case 107: /* array_access_expr: expr */ 3784 + case 107: 3771 3785 { (yyval.expression) = (yyvsp[0].expression); } 3772 3786 break; 3773 3787 3774 - case 108: /* array_access_expr: ".." */ 3788 + case 108: 3775 3789 { (yyval.expression)=new SetLit((yyloc), IntSetVal::a(-IntVal::infinity(),IntVal::infinity())); } 3776 3790 break; 3777 3791 3778 - case 109: /* array_access_expr: ".." expr */ 3792 + case 109: 3779 3793 { if ((yyvsp[0].expression)==nullptr) { 3780 3794 (yyval.expression) = nullptr; 3781 3795 } else if ((yyvsp[0].expression)->isa<IntLit>()) { ··· 3786 3800 } 3787 3801 break; 3788 3802 3789 - case 110: /* array_access_expr: expr ".." */ 3803 + case 110: 3790 3804 { if ((yyvsp[-1].expression)==nullptr) { 3791 3805 (yyval.expression) = nullptr; 3792 3806 } else if ((yyvsp[-1].expression)->isa<IntLit>()) { ··· 3797 3811 } 3798 3812 break; 3799 3813 3800 - case 112: /* expr_list_head: expr */ 3814 + case 112: 3801 3815 { (yyval.expressions1d)=new std::vector<MiniZinc::Expression*>; (yyval.expressions1d)->push_back((yyvsp[0].expression)); } 3802 3816 break; 3803 3817 3804 - case 113: /* expr_list_head: expr_list_head ',' expr */ 3818 + case 113: 3805 3819 { (yyval.expressions1d)=(yyvsp[-2].expressions1d); if ((yyval.expressions1d) && (yyvsp[0].expression)) (yyval.expressions1d)->push_back((yyvsp[0].expression)); } 3806 3820 break; 3807 3821 3808 - case 115: /* set_expr: set_expr "::" annotation_expr */ 3822 + case 115: 3809 3823 { if ((yyvsp[-2].expression) && (yyvsp[0].expression)) (yyvsp[-2].expression)->addAnnotation((yyvsp[0].expression)); (yyval.expression)=(yyvsp[-2].expression); } 3810 3824 break; 3811 3825 3812 - case 116: /* set_expr: set_expr "union" set_expr */ 3826 + case 116: 3813 3827 { (yyval.expression)=new BinOp((yyloc), (yyvsp[-2].expression), BOT_UNION, (yyvsp[0].expression)); } 3814 3828 break; 3815 3829 3816 - case 117: /* set_expr: set_expr "diff" set_expr */ 3830 + case 117: 3817 3831 { (yyval.expression)=new BinOp((yyloc), (yyvsp[-2].expression), BOT_DIFF, (yyvsp[0].expression)); } 3818 3832 break; 3819 3833 3820 - case 118: /* set_expr: set_expr "symdiff" set_expr */ 3834 + case 118: 3821 3835 { (yyval.expression)=new BinOp((yyloc), (yyvsp[-2].expression), BOT_SYMDIFF, (yyvsp[0].expression)); } 3822 3836 break; 3823 3837 3824 - case 119: /* set_expr: set_expr ".." set_expr */ 3838 + case 119: 3825 3839 { if ((yyvsp[-2].expression)==nullptr || (yyvsp[0].expression)==nullptr) { 3826 3840 (yyval.expression) = nullptr; 3827 3841 } else if ((yyvsp[-2].expression)->isa<IntLit>() && (yyvsp[0].expression)->isa<IntLit>()) { ··· 3832 3846 } 3833 3847 break; 3834 3848 3835 - case 120: /* set_expr: "'..'" '(' expr ',' expr ')' */ 3849 + case 120: 3836 3850 { if ((yyvsp[-3].expression)==nullptr || (yyvsp[-1].expression)==nullptr) { 3837 3851 (yyval.expression) = nullptr; 3838 3852 } else if ((yyvsp[-3].expression)->isa<IntLit>() && (yyvsp[-1].expression)->isa<IntLit>()) { ··· 3843 3857 } 3844 3858 break; 3845 3859 3846 - case 121: /* set_expr: set_expr "intersect" set_expr */ 3860 + case 121: 3847 3861 { (yyval.expression)=new BinOp((yyloc), (yyvsp[-2].expression), BOT_INTERSECT, (yyvsp[0].expression)); } 3848 3862 break; 3849 3863 3850 - case 122: /* set_expr: set_expr "++" set_expr */ 3864 + case 122: 3851 3865 { (yyval.expression)=new BinOp((yyloc), (yyvsp[-2].expression), BOT_PLUSPLUS, (yyvsp[0].expression)); } 3852 3866 break; 3853 3867 3854 - case 123: /* set_expr: set_expr "+" set_expr */ 3868 + case 123: 3855 3869 { (yyval.expression)=new BinOp((yyloc), (yyvsp[-2].expression), BOT_PLUS, (yyvsp[0].expression)); } 3856 3870 break; 3857 3871 3858 - case 124: /* set_expr: set_expr "-" set_expr */ 3872 + case 124: 3859 3873 { (yyval.expression)=new BinOp((yyloc), (yyvsp[-2].expression), BOT_MINUS, (yyvsp[0].expression)); } 3860 3874 break; 3861 3875 3862 - case 125: /* set_expr: set_expr "*" set_expr */ 3876 + case 125: 3863 3877 { (yyval.expression)=new BinOp((yyloc), (yyvsp[-2].expression), BOT_MULT, (yyvsp[0].expression)); } 3864 3878 break; 3865 3879 3866 - case 126: /* set_expr: set_expr "/" set_expr */ 3880 + case 126: 3867 3881 { (yyval.expression)=new BinOp((yyloc), (yyvsp[-2].expression), BOT_DIV, (yyvsp[0].expression)); } 3868 3882 break; 3869 3883 3870 - case 127: /* set_expr: set_expr "div" set_expr */ 3884 + case 127: 3871 3885 { (yyval.expression)=new BinOp((yyloc), (yyvsp[-2].expression), BOT_IDIV, (yyvsp[0].expression)); } 3872 3886 break; 3873 3887 3874 - case 128: /* set_expr: set_expr "mod" set_expr */ 3888 + case 128: 3875 3889 { (yyval.expression)=new BinOp((yyloc), (yyvsp[-2].expression), BOT_MOD, (yyvsp[0].expression)); } 3876 3890 break; 3877 3891 3878 - case 129: /* set_expr: set_expr "^" set_expr */ 3892 + case 129: 3879 3893 { (yyval.expression)=new BinOp((yyloc), (yyvsp[-2].expression), BOT_POW, (yyvsp[0].expression)); } 3880 3894 break; 3881 3895 3882 - case 130: /* set_expr: set_expr "~+" set_expr */ 3896 + case 130: 3883 3897 { vector<Expression*> args; 3884 3898 args.push_back((yyvsp[-2].expression)); args.push_back((yyvsp[0].expression)); 3885 3899 (yyval.expression)=new Call((yyloc), ASTString("~+"), args); 3886 3900 } 3887 3901 break; 3888 3902 3889 - case 131: /* set_expr: set_expr "~-" set_expr */ 3903 + case 131: 3890 3904 { vector<Expression*> args; 3891 3905 args.push_back((yyvsp[-2].expression)); args.push_back((yyvsp[0].expression)); 3892 3906 (yyval.expression)=new Call((yyloc), ASTString("~-"), args); 3893 3907 } 3894 3908 break; 3895 3909 3896 - case 132: /* set_expr: set_expr "~*" set_expr */ 3910 + case 132: 3897 3911 { vector<Expression*> args; 3898 3912 args.push_back((yyvsp[-2].expression)); args.push_back((yyvsp[0].expression)); 3899 3913 (yyval.expression)=new Call((yyloc), ASTString("~*"), args); 3900 3914 } 3901 3915 break; 3902 3916 3903 - case 133: /* set_expr: set_expr "~=" set_expr */ 3917 + case 133: 3904 3918 { vector<Expression*> args; 3905 3919 args.push_back((yyvsp[-2].expression)); args.push_back((yyvsp[0].expression)); 3906 3920 (yyval.expression)=new Call((yyloc), ASTString("~="), args); 3907 3921 } 3908 3922 break; 3909 3923 3910 - case 134: /* set_expr: set_expr "quoted identifier" set_expr */ 3924 + case 134: 3911 3925 { vector<Expression*> args; 3912 3926 args.push_back((yyvsp[-2].expression)); args.push_back((yyvsp[0].expression)); 3913 3927 (yyval.expression)=new Call((yyloc), (yyvsp[-1].sValue), args); ··· 3915 3929 } 3916 3930 break; 3917 3931 3918 - case 135: /* set_expr: "+" set_expr */ 3932 + case 135: 3919 3933 { (yyval.expression)=new UnOp((yyloc), UOT_PLUS, (yyvsp[0].expression)); } 3920 3934 break; 3921 3935 3922 - case 136: /* set_expr: "-" set_expr */ 3936 + case 136: 3923 3937 { if ((yyvsp[0].expression) && (yyvsp[0].expression)->isa<IntLit>()) { 3924 3938 (yyval.expression) = IntLit::a(-(yyvsp[0].expression)->cast<IntLit>()->v()); 3925 3939 } else if ((yyvsp[0].expression) && (yyvsp[0].expression)->isa<FloatLit>()) { ··· 3930 3944 } 3931 3945 break; 3932 3946 3933 - case 138: /* expr: expr "::" annotation_expr */ 3947 + case 138: 3934 3948 { if ((yyvsp[-2].expression) && (yyvsp[0].expression)) (yyvsp[-2].expression)->addAnnotation((yyvsp[0].expression)); (yyval.expression)=(yyvsp[-2].expression); } 3935 3949 break; 3936 3950 3937 - case 139: /* expr: expr "<->" expr */ 3951 + case 139: 3938 3952 { (yyval.expression)=new BinOp((yyloc), (yyvsp[-2].expression), BOT_EQUIV, (yyvsp[0].expression)); } 3939 3953 break; 3940 3954 3941 - case 140: /* expr: expr "->" expr */ 3955 + case 140: 3942 3956 { (yyval.expression)=new BinOp((yyloc), (yyvsp[-2].expression), BOT_IMPL, (yyvsp[0].expression)); } 3943 3957 break; 3944 3958 3945 - case 141: /* expr: expr "<-" expr */ 3959 + case 141: 3946 3960 { (yyval.expression)=new BinOp((yyloc), (yyvsp[-2].expression), BOT_RIMPL, (yyvsp[0].expression)); } 3947 3961 break; 3948 3962 3949 - case 142: /* expr: expr "\\/" expr */ 3963 + case 142: 3950 3964 { (yyval.expression)=new BinOp((yyloc), (yyvsp[-2].expression), BOT_OR, (yyvsp[0].expression)); } 3951 3965 break; 3952 3966 3953 - case 143: /* expr: expr "xor" expr */ 3967 + case 143: 3954 3968 { (yyval.expression)=new BinOp((yyloc), (yyvsp[-2].expression), BOT_XOR, (yyvsp[0].expression)); } 3955 3969 break; 3956 3970 3957 - case 144: /* expr: expr "/\\" expr */ 3971 + case 144: 3958 3972 { (yyval.expression)=new BinOp((yyloc), (yyvsp[-2].expression), BOT_AND, (yyvsp[0].expression)); } 3959 3973 break; 3960 3974 3961 - case 145: /* expr: expr "<" expr */ 3975 + case 145: 3962 3976 { (yyval.expression)=new BinOp((yyloc), (yyvsp[-2].expression), BOT_LE, (yyvsp[0].expression)); } 3963 3977 break; 3964 3978 3965 - case 146: /* expr: expr ">" expr */ 3979 + case 146: 3966 3980 { (yyval.expression)=new BinOp((yyloc), (yyvsp[-2].expression), BOT_GR, (yyvsp[0].expression)); } 3967 3981 break; 3968 3982 3969 - case 147: /* expr: expr "<=" expr */ 3983 + case 147: 3970 3984 { (yyval.expression)=new BinOp((yyloc), (yyvsp[-2].expression), BOT_LQ, (yyvsp[0].expression)); } 3971 3985 break; 3972 3986 3973 - case 148: /* expr: expr ">=" expr */ 3987 + case 148: 3974 3988 { (yyval.expression)=new BinOp((yyloc), (yyvsp[-2].expression), BOT_GQ, (yyvsp[0].expression)); } 3975 3989 break; 3976 3990 3977 - case 149: /* expr: expr "=" expr */ 3991 + case 149: 3978 3992 { (yyval.expression)=new BinOp((yyloc), (yyvsp[-2].expression), BOT_EQ, (yyvsp[0].expression)); } 3979 3993 break; 3980 3994 3981 - case 150: /* expr: expr "!=" expr */ 3995 + case 150: 3982 3996 { (yyval.expression)=new BinOp((yyloc), (yyvsp[-2].expression), BOT_NQ, (yyvsp[0].expression)); } 3983 3997 break; 3984 3998 3985 - case 151: /* expr: expr "in" expr */ 3999 + case 151: 3986 4000 { (yyval.expression)=new BinOp((yyloc), (yyvsp[-2].expression), BOT_IN, (yyvsp[0].expression)); } 3987 4001 break; 3988 4002 3989 - case 152: /* expr: expr "subset" expr */ 4003 + case 152: 3990 4004 { (yyval.expression)=new BinOp((yyloc), (yyvsp[-2].expression), BOT_SUBSET, (yyvsp[0].expression)); } 3991 4005 break; 3992 4006 3993 - case 153: /* expr: expr "superset" expr */ 4007 + case 153: 3994 4008 { (yyval.expression)=new BinOp((yyloc), (yyvsp[-2].expression), BOT_SUPERSET, (yyvsp[0].expression)); } 3995 4009 break; 3996 4010 3997 - case 154: /* expr: expr "union" expr */ 4011 + case 154: 3998 4012 { (yyval.expression)=new BinOp((yyloc), (yyvsp[-2].expression), BOT_UNION, (yyvsp[0].expression)); } 3999 4013 break; 4000 4014 4001 - case 155: /* expr: expr "diff" expr */ 4015 + case 155: 4002 4016 { (yyval.expression)=new BinOp((yyloc), (yyvsp[-2].expression), BOT_DIFF, (yyvsp[0].expression)); } 4003 4017 break; 4004 4018 4005 - case 156: /* expr: expr "symdiff" expr */ 4019 + case 156: 4006 4020 { (yyval.expression)=new BinOp((yyloc), (yyvsp[-2].expression), BOT_SYMDIFF, (yyvsp[0].expression)); } 4007 4021 break; 4008 4022 4009 - case 157: /* expr: expr ".." expr */ 4023 + case 157: 4010 4024 { if ((yyvsp[-2].expression)==nullptr || (yyvsp[0].expression)==nullptr) { 4011 4025 (yyval.expression) = nullptr; 4012 4026 } else if ((yyvsp[-2].expression)->isa<IntLit>() && (yyvsp[0].expression)->isa<IntLit>()) { ··· 4017 4031 } 4018 4032 break; 4019 4033 4020 - case 158: /* expr: "'..'" '(' expr ',' expr ')' */ 4034 + case 158: 4021 4035 { if ((yyvsp[-3].expression)==nullptr || (yyvsp[-1].expression)==nullptr) { 4022 4036 (yyval.expression) = nullptr; 4023 4037 } else if ((yyvsp[-3].expression)->isa<IntLit>() && (yyvsp[-1].expression)->isa<IntLit>()) { ··· 4028 4042 } 4029 4043 break; 4030 4044 4031 - case 159: /* expr: expr "intersect" expr */ 4045 + case 159: 4032 4046 { (yyval.expression)=new BinOp((yyloc), (yyvsp[-2].expression), BOT_INTERSECT, (yyvsp[0].expression)); } 4033 4047 break; 4034 4048 4035 - case 160: /* expr: expr "++" expr */ 4049 + case 160: 4036 4050 { (yyval.expression)=new BinOp((yyloc), (yyvsp[-2].expression), BOT_PLUSPLUS, (yyvsp[0].expression)); } 4037 4051 break; 4038 4052 4039 - case 161: /* expr: expr "+" expr */ 4053 + case 161: 4040 4054 { (yyval.expression)=new BinOp((yyloc), (yyvsp[-2].expression), BOT_PLUS, (yyvsp[0].expression)); } 4041 4055 break; 4042 4056 4043 - case 162: /* expr: expr "-" expr */ 4057 + case 162: 4044 4058 { (yyval.expression)=new BinOp((yyloc), (yyvsp[-2].expression), BOT_MINUS, (yyvsp[0].expression)); } 4045 4059 break; 4046 4060 4047 - case 163: /* expr: expr "*" expr */ 4061 + case 163: 4048 4062 { (yyval.expression)=new BinOp((yyloc), (yyvsp[-2].expression), BOT_MULT, (yyvsp[0].expression)); } 4049 4063 break; 4050 4064 4051 - case 164: /* expr: expr "/" expr */ 4065 + case 164: 4052 4066 { (yyval.expression)=new BinOp((yyloc), (yyvsp[-2].expression), BOT_DIV, (yyvsp[0].expression)); } 4053 4067 break; 4054 4068 4055 - case 165: /* expr: expr "div" expr */ 4069 + case 165: 4056 4070 { (yyval.expression)=new BinOp((yyloc), (yyvsp[-2].expression), BOT_IDIV, (yyvsp[0].expression)); } 4057 4071 break; 4058 4072 4059 - case 166: /* expr: expr "mod" expr */ 4073 + case 166: 4060 4074 { (yyval.expression)=new BinOp((yyloc), (yyvsp[-2].expression), BOT_MOD, (yyvsp[0].expression)); } 4061 4075 break; 4062 4076 4063 - case 167: /* expr: expr "^" expr */ 4077 + case 167: 4064 4078 { (yyval.expression)=new BinOp((yyloc), (yyvsp[-2].expression), BOT_POW, (yyvsp[0].expression)); } 4065 4079 break; 4066 4080 4067 - case 168: /* expr: expr "~+" expr */ 4081 + case 168: 4068 4082 { vector<Expression*> args; 4069 4083 args.push_back((yyvsp[-2].expression)); args.push_back((yyvsp[0].expression)); 4070 4084 (yyval.expression)=new Call((yyloc), ASTString("~+"), args); 4071 4085 } 4072 4086 break; 4073 4087 4074 - case 169: /* expr: expr "~-" expr */ 4088 + case 169: 4075 4089 { vector<Expression*> args; 4076 4090 args.push_back((yyvsp[-2].expression)); args.push_back((yyvsp[0].expression)); 4077 4091 (yyval.expression)=new Call((yyloc), ASTString("~-"), args); 4078 4092 } 4079 4093 break; 4080 4094 4081 - case 170: /* expr: expr "~*" expr */ 4095 + case 170: 4082 4096 { vector<Expression*> args; 4083 4097 args.push_back((yyvsp[-2].expression)); args.push_back((yyvsp[0].expression)); 4084 4098 (yyval.expression)=new Call((yyloc), ASTString("~*"), args); 4085 4099 } 4086 4100 break; 4087 4101 4088 - case 171: /* expr: expr "~=" expr */ 4102 + case 171: 4089 4103 { vector<Expression*> args; 4090 4104 args.push_back((yyvsp[-2].expression)); args.push_back((yyvsp[0].expression)); 4091 4105 (yyval.expression)=new Call((yyloc), ASTString("~="), args); 4092 4106 } 4093 4107 break; 4094 4108 4095 - case 172: /* expr: expr "quoted identifier" expr */ 4109 + case 172: 4096 4110 { vector<Expression*> args; 4097 4111 args.push_back((yyvsp[-2].expression)); args.push_back((yyvsp[0].expression)); 4098 4112 (yyval.expression)=new Call((yyloc), (yyvsp[-1].sValue), args); ··· 4100 4114 } 4101 4115 break; 4102 4116 4103 - case 173: /* expr: "not" expr */ 4117 + case 173: 4104 4118 { (yyval.expression)=new UnOp((yyloc), UOT_NOT, (yyvsp[0].expression)); } 4105 4119 break; 4106 4120 4107 - case 174: /* expr: "+" expr */ 4121 + case 174: 4108 4122 { if (((yyvsp[0].expression) && (yyvsp[0].expression)->isa<IntLit>()) || ((yyvsp[0].expression) && (yyvsp[0].expression)->isa<FloatLit>())) { 4109 4123 (yyval.expression) = (yyvsp[0].expression); 4110 4124 } else { ··· 4113 4127 } 4114 4128 break; 4115 4129 4116 - case 175: /* expr: "-" expr */ 4130 + case 175: 4117 4131 { if ((yyvsp[0].expression) && (yyvsp[0].expression)->isa<IntLit>()) { 4118 4132 (yyval.expression) = IntLit::a(-(yyvsp[0].expression)->cast<IntLit>()->v()); 4119 4133 } else if ((yyvsp[0].expression) && (yyvsp[0].expression)->isa<FloatLit>()) { ··· 4124 4138 } 4125 4139 break; 4126 4140 4127 - case 176: /* expr_atom_head: expr_atom_head_nonstring */ 4141 + case 176: 4128 4142 { (yyval.expression)=(yyvsp[0].expression); } 4129 4143 break; 4130 4144 4131 - case 177: /* expr_atom_head: string_expr */ 4145 + case 177: 4132 4146 { (yyval.expression)=(yyvsp[0].expression); } 4133 4147 break; 4134 4148 4135 - case 178: /* expr_atom_head_nonstring: '(' expr ')' */ 4149 + case 178: 4136 4150 { (yyval.expression)=(yyvsp[-1].expression); } 4137 4151 break; 4138 4152 4139 - case 179: /* expr_atom_head_nonstring: '(' expr ')' array_access_tail */ 4153 + case 179: 4140 4154 { if ((yyvsp[0].expressions2d)) (yyval.expression)=createArrayAccess((yyloc), (yyvsp[-2].expression), *(yyvsp[0].expressions2d)); delete (yyvsp[0].expressions2d); } 4141 4155 break; 4142 4156 4143 - case 180: /* expr_atom_head_nonstring: '(' expr ')' "^-1" */ 4157 + case 180: 4144 4158 { (yyval.expression)=new BinOp((yyloc), (yyvsp[-2].expression), BOT_POW, IntLit::a(-1)); } 4145 4159 break; 4146 4160 4147 - case 181: /* expr_atom_head_nonstring: '(' expr ')' array_access_tail "^-1" */ 4161 + case 181: 4148 4162 { if ((yyvsp[-1].expressions2d)) (yyval.expression)=new BinOp((yyloc),createArrayAccess((yyloc), (yyvsp[-3].expression), *(yyvsp[-1].expressions2d)), BOT_POW, IntLit::a(-1)); delete (yyvsp[-1].expressions2d); } 4149 4163 break; 4150 4164 4151 - case 182: /* expr_atom_head_nonstring: "identifier" */ 4165 + case 182: 4152 4166 { (yyval.expression)=new Id((yyloc), (yyvsp[0].sValue), nullptr); free((yyvsp[0].sValue)); } 4153 4167 break; 4154 4168 4155 - case 183: /* expr_atom_head_nonstring: "identifier" array_access_tail */ 4169 + case 183: 4156 4170 { if ((yyvsp[0].expressions2d)) (yyval.expression)=createArrayAccess((yyloc), new Id((yylsp[-1]),(yyvsp[-1].sValue),nullptr), *(yyvsp[0].expressions2d)); 4157 4171 free((yyvsp[-1].sValue)); delete (yyvsp[0].expressions2d); } 4158 4172 break; 4159 4173 4160 - case 184: /* expr_atom_head_nonstring: "identifier" "^-1" */ 4174 + case 184: 4161 4175 { (yyval.expression)=new BinOp((yyloc),new Id((yyloc), (yyvsp[-1].sValue), nullptr), BOT_POW, IntLit::a(-1)); free((yyvsp[-1].sValue)); } 4162 4176 break; 4163 4177 4164 - case 185: /* expr_atom_head_nonstring: "identifier" array_access_tail "^-1" */ 4178 + case 185: 4165 4179 { if ((yyvsp[-1].expressions2d)) (yyval.expression)=new BinOp((yyloc),createArrayAccess((yyloc), new Id((yylsp[-2]),(yyvsp[-2].sValue),nullptr), *(yyvsp[-1].expressions2d)), BOT_POW, IntLit::a(-1)); 4166 4180 free((yyvsp[-2].sValue)); delete (yyvsp[-1].expressions2d); } 4167 4181 break; 4168 4182 4169 - case 186: /* expr_atom_head_nonstring: "_" */ 4183 + case 186: 4170 4184 { (yyval.expression)=new AnonVar((yyloc)); } 4171 4185 break; 4172 4186 4173 - case 187: /* expr_atom_head_nonstring: "_" array_access_tail */ 4187 + case 187: 4174 4188 { if ((yyvsp[0].expressions2d)) (yyval.expression)=createArrayAccess((yyloc), new AnonVar((yyloc)), *(yyvsp[0].expressions2d)); 4175 4189 delete (yyvsp[0].expressions2d); } 4176 4190 break; 4177 4191 4178 - case 188: /* expr_atom_head_nonstring: "_" "^-1" */ 4192 + case 188: 4179 4193 { (yyval.expression)=new BinOp((yyloc),new AnonVar((yyloc)), BOT_POW, IntLit::a(-1)); } 4180 4194 break; 4181 4195 4182 - case 189: /* expr_atom_head_nonstring: "_" array_access_tail "^-1" */ 4196 + case 189: 4183 4197 { if ((yyvsp[-1].expressions2d)) (yyval.expression)=new BinOp((yyloc),createArrayAccess((yyloc), new AnonVar((yyloc)), *(yyvsp[-1].expressions2d)), BOT_POW, IntLit::a(-1)); 4184 4198 delete (yyvsp[-1].expressions2d); } 4185 4199 break; 4186 4200 4187 - case 190: /* expr_atom_head_nonstring: "bool literal" */ 4201 + case 190: 4188 4202 { (yyval.expression)=constants().boollit(((yyvsp[0].iValue)!=0)); } 4189 4203 break; 4190 4204 4191 - case 191: /* expr_atom_head_nonstring: "bool literal" "^-1" */ 4205 + case 191: 4192 4206 { (yyval.expression)=new BinOp((yyloc),constants().boollit(((yyvsp[-1].iValue)!=0)), BOT_POW, IntLit::a(-1)); } 4193 4207 break; 4194 4208 4195 - case 192: /* expr_atom_head_nonstring: "integer literal" */ 4209 + case 192: 4196 4210 { (yyval.expression)=IntLit::a((yyvsp[0].iValue)); } 4197 4211 break; 4198 4212 4199 - case 193: /* expr_atom_head_nonstring: "integer literal" "^-1" */ 4213 + case 193: 4200 4214 { (yyval.expression)=new BinOp((yyloc),IntLit::a((yyvsp[-1].iValue)), BOT_POW, IntLit::a(-1)); } 4201 4215 break; 4202 4216 4203 - case 194: /* expr_atom_head_nonstring: "infinity" */ 4217 + case 194: 4204 4218 { (yyval.expression)=IntLit::a(IntVal::infinity()); } 4205 4219 break; 4206 4220 4207 - case 195: /* expr_atom_head_nonstring: "infinity" "^-1" */ 4221 + case 195: 4208 4222 { (yyval.expression)=new BinOp((yyloc),IntLit::a(IntVal::infinity()), BOT_POW, IntLit::a(-1)); } 4209 4223 break; 4210 4224 4211 - case 196: /* expr_atom_head_nonstring: "float literal" */ 4225 + case 196: 4212 4226 { (yyval.expression)=FloatLit::a((yyvsp[0].dValue)); } 4213 4227 break; 4214 4228 4215 - case 197: /* expr_atom_head_nonstring: "float literal" "^-1" */ 4229 + case 197: 4216 4230 { (yyval.expression)=new BinOp((yyloc),FloatLit::a((yyvsp[-1].dValue)), BOT_POW, IntLit::a(-1)); } 4217 4231 break; 4218 4232 4219 - case 198: /* expr_atom_head_nonstring: "<>" */ 4233 + case 198: 4220 4234 { (yyval.expression)=constants().absent; } 4221 4235 break; 4222 4236 4223 - case 199: /* expr_atom_head_nonstring: "<>" "^-1" */ 4237 + case 199: 4224 4238 { (yyval.expression)=constants().absent; } 4225 4239 break; 4226 4240 4227 - case 201: /* expr_atom_head_nonstring: set_literal array_access_tail */ 4241 + case 201: 4228 4242 { if ((yyvsp[0].expressions2d)) (yyval.expression)=createArrayAccess((yyloc), (yyvsp[-1].expression), *(yyvsp[0].expressions2d)); 4229 4243 delete (yyvsp[0].expressions2d); } 4230 4244 break; 4231 4245 4232 - case 202: /* expr_atom_head_nonstring: set_literal "^-1" */ 4246 + case 202: 4233 4247 { (yyval.expression) = new BinOp((yyloc),(yyvsp[-1].expression), BOT_POW, IntLit::a(-1)); } 4234 4248 break; 4235 4249 4236 - case 203: /* expr_atom_head_nonstring: set_literal array_access_tail "^-1" */ 4250 + case 203: 4237 4251 { if ((yyvsp[-1].expressions2d)) (yyval.expression)=new BinOp((yyloc),createArrayAccess((yyloc), (yyvsp[-2].expression), *(yyvsp[-1].expressions2d)), BOT_POW, IntLit::a(-1)); 4238 4252 delete (yyvsp[-1].expressions2d); } 4239 4253 break; 4240 4254 4241 - case 205: /* expr_atom_head_nonstring: set_comp array_access_tail */ 4255 + case 205: 4242 4256 { if ((yyvsp[0].expressions2d)) (yyval.expression)=createArrayAccess((yyloc), (yyvsp[-1].expression), *(yyvsp[0].expressions2d)); 4243 4257 delete (yyvsp[0].expressions2d); } 4244 4258 break; 4245 4259 4246 - case 206: /* expr_atom_head_nonstring: set_comp "^-1" */ 4260 + case 206: 4247 4261 { (yyval.expression) = new BinOp((yyloc),(yyvsp[-1].expression), BOT_POW, IntLit::a(-1)); } 4248 4262 break; 4249 4263 4250 - case 207: /* expr_atom_head_nonstring: set_comp array_access_tail "^-1" */ 4264 + case 207: 4251 4265 { if ((yyvsp[-1].expressions2d)) (yyval.expression)=new BinOp((yyloc),createArrayAccess((yyloc), (yyvsp[-2].expression), *(yyvsp[-1].expressions2d)), BOT_POW, IntLit::a(-1)); 4252 4266 delete (yyvsp[-1].expressions2d); } 4253 4267 break; 4254 4268 4255 - case 209: /* expr_atom_head_nonstring: simple_array_literal array_access_tail */ 4269 + case 209: 4256 4270 { if ((yyvsp[0].expressions2d)) (yyval.expression)=createArrayAccess((yyloc), (yyvsp[-1].expression), *(yyvsp[0].expressions2d)); 4257 4271 delete (yyvsp[0].expressions2d); } 4258 4272 break; 4259 4273 4260 - case 210: /* expr_atom_head_nonstring: simple_array_literal "^-1" */ 4274 + case 210: 4261 4275 { (yyval.expression) = new BinOp((yyloc),(yyvsp[-1].expression), BOT_POW, IntLit::a(-1)); } 4262 4276 break; 4263 4277 4264 - case 211: /* expr_atom_head_nonstring: simple_array_literal array_access_tail "^-1" */ 4278 + case 211: 4265 4279 { if ((yyvsp[-1].expressions2d)) (yyval.expression)=new BinOp((yyloc),createArrayAccess((yyloc), (yyvsp[-2].expression), *(yyvsp[-1].expressions2d)), BOT_POW, IntLit::a(-1)); 4266 4280 delete (yyvsp[-1].expressions2d); } 4267 4281 break; 4268 4282 4269 - case 213: /* expr_atom_head_nonstring: simple_array_literal_2d array_access_tail */ 4283 + case 213: 4270 4284 { if ((yyvsp[0].expressions2d)) (yyval.expression)=createArrayAccess((yyloc), (yyvsp[-1].expression), *(yyvsp[0].expressions2d)); 4271 4285 delete (yyvsp[0].expressions2d); } 4272 4286 break; 4273 4287 4274 - case 214: /* expr_atom_head_nonstring: simple_array_literal_2d "^-1" */ 4288 + case 214: 4275 4289 { (yyval.expression) = new BinOp((yyloc),(yyvsp[-1].expression), BOT_POW, IntLit::a(-1)); } 4276 4290 break; 4277 4291 4278 - case 215: /* expr_atom_head_nonstring: simple_array_literal_2d array_access_tail "^-1" */ 4292 + case 215: 4279 4293 { if ((yyvsp[-1].expressions2d)) (yyval.expression)=new BinOp((yyloc),createArrayAccess((yyloc), (yyvsp[-2].expression), *(yyvsp[-1].expressions2d)), BOT_POW, IntLit::a(-1)); 4280 4294 delete (yyvsp[-1].expressions2d); } 4281 4295 break; 4282 4296 4283 - case 217: /* expr_atom_head_nonstring: simple_array_comp array_access_tail */ 4297 + case 217: 4284 4298 { if ((yyvsp[0].expressions2d)) (yyval.expression)=createArrayAccess((yyloc), (yyvsp[-1].expression), *(yyvsp[0].expressions2d)); 4285 4299 delete (yyvsp[0].expressions2d); } 4286 4300 break; 4287 4301 4288 - case 218: /* expr_atom_head_nonstring: simple_array_comp "^-1" */ 4302 + case 218: 4289 4303 { (yyval.expression) = new BinOp((yyloc),(yyvsp[-1].expression), BOT_POW, IntLit::a(-1)); } 4290 4304 break; 4291 4305 4292 - case 219: /* expr_atom_head_nonstring: simple_array_comp array_access_tail "^-1" */ 4306 + case 219: 4293 4307 { if ((yyvsp[-1].expressions2d)) (yyval.expression)=new BinOp((yyloc),createArrayAccess((yyloc), (yyvsp[-2].expression), *(yyvsp[-1].expressions2d)), BOT_POW, IntLit::a(-1)); 4294 4308 delete (yyvsp[-1].expressions2d); } 4295 4309 break; 4296 4310 4297 - case 221: /* expr_atom_head_nonstring: if_then_else_expr array_access_tail */ 4311 + case 221: 4298 4312 { if ((yyvsp[0].expressions2d)) (yyval.expression)=createArrayAccess((yyloc), (yyvsp[-1].expression), *(yyvsp[0].expressions2d)); 4299 4313 delete (yyvsp[0].expressions2d); } 4300 4314 break; 4301 4315 4302 - case 222: /* expr_atom_head_nonstring: if_then_else_expr "^-1" */ 4316 + case 222: 4303 4317 { (yyval.expression) = new BinOp((yyloc),(yyvsp[-1].expression), BOT_POW, IntLit::a(-1)); } 4304 4318 break; 4305 4319 4306 - case 223: /* expr_atom_head_nonstring: if_then_else_expr array_access_tail "^-1" */ 4320 + case 223: 4307 4321 { if ((yyvsp[-1].expressions2d)) (yyval.expression)=new BinOp((yyloc),createArrayAccess((yyloc), (yyvsp[-2].expression), *(yyvsp[-1].expressions2d)), BOT_POW, IntLit::a(-1)); 4308 4322 delete (yyvsp[-1].expressions2d); } 4309 4323 break; 4310 4324 4311 - case 226: /* expr_atom_head_nonstring: call_expr array_access_tail */ 4325 + case 226: 4312 4326 { if ((yyvsp[0].expressions2d)) (yyval.expression)=createArrayAccess((yyloc), (yyvsp[-1].expression), *(yyvsp[0].expressions2d)); 4313 4327 delete (yyvsp[0].expressions2d); } 4314 4328 break; 4315 4329 4316 - case 228: /* expr_atom_head_nonstring: call_expr array_access_tail "^-1" */ 4330 + case 228: 4317 4331 { if ((yyvsp[-1].expressions2d)) (yyval.expression)=createArrayAccess((yyloc), (yyvsp[-2].expression), *(yyvsp[-1].expressions2d)); 4318 4332 delete (yyvsp[-1].expressions2d); } 4319 4333 break; 4320 4334 4321 - case 229: /* string_expr: "string literal" */ 4335 + case 229: 4322 4336 { (yyval.expression)=new StringLit((yyloc), (yyvsp[0].sValue)); free((yyvsp[0].sValue)); } 4323 4337 break; 4324 4338 4325 - case 230: /* string_expr: "interpolated string start" string_quote_rest */ 4339 + case 230: 4326 4340 { (yyval.expression)=new BinOp((yyloc), new StringLit((yyloc), (yyvsp[-1].sValue)), BOT_PLUSPLUS, (yyvsp[0].expression)); 4327 4341 free((yyvsp[-1].sValue)); 4328 4342 } 4329 4343 break; 4330 4344 4331 - case 231: /* string_quote_rest: expr_list_head "interpolated string end" */ 4345 + case 231: 4332 4346 { if ((yyvsp[-1].expressions1d)) (yyval.expression)=new BinOp((yyloc), new Call((yyloc), ASTString("format"), *(yyvsp[-1].expressions1d)), BOT_PLUSPLUS, new StringLit((yyloc),(yyvsp[0].sValue))); 4333 4347 free((yyvsp[0].sValue)); 4334 4348 delete (yyvsp[-1].expressions1d); 4335 4349 } 4336 4350 break; 4337 4351 4338 - case 232: /* string_quote_rest: expr_list_head "interpolated string middle" string_quote_rest */ 4352 + case 232: 4339 4353 { if ((yyvsp[-2].expressions1d)) (yyval.expression)=new BinOp((yyloc), new Call((yyloc), ASTString("format"), *(yyvsp[-2].expressions1d)), BOT_PLUSPLUS, 4340 4354 new BinOp((yyloc), new StringLit((yyloc),(yyvsp[-1].sValue)), BOT_PLUSPLUS, (yyvsp[0].expression))); 4341 4355 free((yyvsp[-1].sValue)); ··· 4343 4357 } 4344 4358 break; 4345 4359 4346 - case 233: /* array_access_tail: "[" array_access_expr_list "]" */ 4360 + case 233: 4347 4361 { (yyval.expressions2d)=new std::vector<std::vector<Expression*> >(); 4348 4362 if ((yyvsp[-1].expressions1d)) { 4349 4363 (yyval.expressions2d)->push_back(*(yyvsp[-1].expressions1d)); ··· 4352 4366 } 4353 4367 break; 4354 4368 4355 - case 234: /* array_access_tail: array_access_tail "[" array_access_expr_list "]" */ 4369 + case 234: 4356 4370 { (yyval.expressions2d)=(yyvsp[-3].expressions2d); 4357 4371 if ((yyval.expressions2d) && (yyvsp[-1].expressions1d)) { 4358 4372 (yyval.expressions2d)->push_back(*(yyvsp[-1].expressions1d)); ··· 4361 4375 } 4362 4376 break; 4363 4377 4364 - case 235: /* set_literal: '{' '}' */ 4378 + case 235: 4365 4379 { (yyval.expression) = new SetLit((yyloc), std::vector<Expression*>()); } 4366 4380 break; 4367 4381 4368 - case 236: /* set_literal: '{' expr_list '}' */ 4382 + case 236: 4369 4383 { if ((yyvsp[-1].expressions1d)) (yyval.expression) = new SetLit((yyloc), *(yyvsp[-1].expressions1d)); 4370 4384 delete (yyvsp[-1].expressions1d); } 4371 4385 break; 4372 4386 4373 - case 237: /* set_comp: '{' expr '|' comp_tail '}' */ 4387 + case 237: 4374 4388 { if ((yyvsp[-1].generatorsPointer)) (yyval.expression) = new Comprehension((yyloc), (yyvsp[-3].expression), *(yyvsp[-1].generatorsPointer), true); 4375 4389 delete (yyvsp[-1].generatorsPointer); 4376 4390 } 4377 4391 break; 4378 4392 4379 - case 238: /* comp_tail: generator_list */ 4393 + case 238: 4380 4394 { if ((yyvsp[0].generators)) (yyval.generatorsPointer)=new Generators; (yyval.generatorsPointer)->g = *(yyvsp[0].generators); delete (yyvsp[0].generators); } 4381 4395 break; 4382 4396 4383 - case 240: /* generator_list_head: generator */ 4397 + case 240: 4384 4398 { (yyval.generators)=new std::vector<Generator>; if ((yyvsp[0].generator)) (yyval.generators)->push_back(*(yyvsp[0].generator)); delete (yyvsp[0].generator); } 4385 4399 break; 4386 4400 4387 - case 241: /* generator_list_head: generator_eq */ 4401 + case 241: 4388 4402 { (yyval.generators)=new std::vector<Generator>; if ((yyvsp[0].generator)) (yyval.generators)->push_back(*(yyvsp[0].generator)); delete (yyvsp[0].generator); } 4389 4403 break; 4390 4404 4391 - case 242: /* generator_list_head: generator_eq "where" expr */ 4405 + case 242: 4392 4406 { (yyval.generators)=new std::vector<Generator>; 4393 4407 if ((yyvsp[-2].generator)) (yyval.generators)->push_back(*(yyvsp[-2].generator)); 4394 4408 if ((yyvsp[-2].generator) && (yyvsp[0].expression)) (yyval.generators)->push_back(Generator((yyval.generators)->size(),(yyvsp[0].expression))); ··· 4396 4410 } 4397 4411 break; 4398 4412 4399 - case 243: /* generator_list_head: generator_list_head ',' generator */ 4413 + case 243: 4400 4414 { (yyval.generators)=(yyvsp[-2].generators); if ((yyval.generators) && (yyvsp[0].generator)) (yyval.generators)->push_back(*(yyvsp[0].generator)); delete (yyvsp[0].generator); } 4401 4415 break; 4402 4416 4403 - case 244: /* generator_list_head: generator_list_head ',' generator_eq */ 4417 + case 244: 4404 4418 { (yyval.generators)=(yyvsp[-2].generators); if ((yyval.generators) && (yyvsp[0].generator)) (yyval.generators)->push_back(*(yyvsp[0].generator)); delete (yyvsp[0].generator); } 4405 4419 break; 4406 4420 4407 - case 245: /* generator_list_head: generator_list_head ',' generator_eq "where" expr */ 4421 + case 245: 4408 4422 { (yyval.generators)=(yyvsp[-4].generators); 4409 4423 if ((yyval.generators) && (yyvsp[-2].generator)) (yyval.generators)->push_back(*(yyvsp[-2].generator)); 4410 4424 if ((yyval.generators) && (yyvsp[-2].generator) && (yyvsp[0].expression)) (yyval.generators)->push_back(Generator((yyval.generators)->size(),(yyvsp[0].expression))); ··· 4412 4426 } 4413 4427 break; 4414 4428 4415 - case 246: /* generator: id_list "in" expr */ 4429 + case 246: 4416 4430 { if ((yyvsp[-2].strings) && (yyvsp[0].expression)) (yyval.generator)=new Generator(*(yyvsp[-2].strings),(yyvsp[0].expression),nullptr); else (yyval.generator)=nullptr; delete (yyvsp[-2].strings); } 4417 4431 break; 4418 4432 4419 - case 247: /* generator: id_list "in" expr "where" expr */ 4433 + case 247: 4420 4434 { if ((yyvsp[-4].strings) && (yyvsp[-2].expression)) (yyval.generator)=new Generator(*(yyvsp[-4].strings),(yyvsp[-2].expression),(yyvsp[0].expression)); else (yyval.generator)=nullptr; delete (yyvsp[-4].strings); } 4421 4435 break; 4422 4436 4423 - case 248: /* generator_eq: "identifier" "=" expr */ 4437 + case 248: 4424 4438 { if ((yyvsp[0].expression)) (yyval.generator)=new Generator({(yyvsp[-2].sValue)},nullptr,(yyvsp[0].expression)); else (yyval.generator)=nullptr; free((yyvsp[-2].sValue)); } 4425 4439 break; 4426 4440 4427 - case 250: /* id_list_head: "identifier" */ 4441 + case 250: 4428 4442 { (yyval.strings)=new std::vector<std::string>; (yyval.strings)->push_back((yyvsp[0].sValue)); free((yyvsp[0].sValue)); } 4429 4443 break; 4430 4444 4431 - case 251: /* id_list_head: id_list_head ',' "identifier" */ 4445 + case 251: 4432 4446 { (yyval.strings)=(yyvsp[-2].strings); if ((yyval.strings) && (yyvsp[0].sValue)) (yyval.strings)->push_back((yyvsp[0].sValue)); free((yyvsp[0].sValue)); } 4433 4447 break; 4434 4448 4435 - case 252: /* simple_array_literal: "[" "]" */ 4449 + case 252: 4436 4450 { (yyval.expression)=new ArrayLit((yyloc), std::vector<MiniZinc::Expression*>()); } 4437 4451 break; 4438 4452 4439 - case 253: /* simple_array_literal: "[" expr_list "]" */ 4453 + case 253: 4440 4454 { if ((yyvsp[-1].expressions1d)) (yyval.expression)=new ArrayLit((yyloc), *(yyvsp[-1].expressions1d)); delete (yyvsp[-1].expressions1d); } 4441 4455 break; 4442 4456 4443 - case 254: /* simple_array_literal_2d: "[|" "|]" */ 4457 + case 254: 4444 4458 { (yyval.expression)=new ArrayLit((yyloc), std::vector<std::vector<Expression*> >()); } 4445 4459 break; 4446 4460 4447 - case 255: /* simple_array_literal_2d: "[|" simple_array_literal_2d_list "|]" */ 4461 + case 255: 4448 4462 { if ((yyvsp[-1].expressions2d)) { 4449 4463 (yyval.expression)=new ArrayLit((yyloc), *(yyvsp[-1].expressions2d)); 4450 4464 for (unsigned int i=1; i<(yyvsp[-1].expressions2d)->size(); i++) ··· 4457 4471 } 4458 4472 break; 4459 4473 4460 - case 256: /* simple_array_literal_2d: "[|" simple_array_literal_2d_list '|' "|]" */ 4474 + case 256: 4461 4475 { if ((yyvsp[-2].expressions2d)) { 4462 4476 (yyval.expression)=new ArrayLit((yyloc), *(yyvsp[-2].expressions2d)); 4463 4477 for (unsigned int i=1; i<(yyvsp[-2].expressions2d)->size(); i++) ··· 4470 4484 } 4471 4485 break; 4472 4486 4473 - case 257: /* simple_array_literal_2d: "[|" simple_array_literal_3d_list "|]" */ 4487 + case 257: 4474 4488 { 4475 4489 if ((yyvsp[-1].expressions3d)) { 4476 4490 std::vector<std::pair<int,int> > dims(3); ··· 4510 4524 } 4511 4525 break; 4512 4526 4513 - case 258: /* simple_array_literal_3d_list: '|' '|' */ 4527 + case 258: 4514 4528 { (yyval.expressions3d)=new std::vector<std::vector<std::vector<MiniZinc::Expression*> > >; 4515 4529 } 4516 4530 break; 4517 4531 4518 - case 259: /* simple_array_literal_3d_list: '|' simple_array_literal_2d_list '|' */ 4532 + case 259: 4519 4533 { (yyval.expressions3d)=new std::vector<std::vector<std::vector<MiniZinc::Expression*> > >; 4520 4534 if ((yyvsp[-1].expressions2d)) (yyval.expressions3d)->push_back(*(yyvsp[-1].expressions2d)); 4521 4535 delete (yyvsp[-1].expressions2d); 4522 4536 } 4523 4537 break; 4524 4538 4525 - case 260: /* simple_array_literal_3d_list: simple_array_literal_3d_list ',' '|' simple_array_literal_2d_list '|' */ 4539 + case 260: 4526 4540 { (yyval.expressions3d)=(yyvsp[-4].expressions3d); 4527 4541 if ((yyval.expressions3d) && (yyvsp[-1].expressions2d)) (yyval.expressions3d)->push_back(*(yyvsp[-1].expressions2d)); 4528 4542 delete (yyvsp[-1].expressions2d); 4529 4543 } 4530 4544 break; 4531 4545 4532 - case 261: /* simple_array_literal_2d_list: expr_list */ 4546 + case 261: 4533 4547 { (yyval.expressions2d)=new std::vector<std::vector<MiniZinc::Expression*> >; 4534 4548 if ((yyvsp[0].expressions1d)) (yyval.expressions2d)->push_back(*(yyvsp[0].expressions1d)); 4535 4549 delete (yyvsp[0].expressions1d); 4536 4550 } 4537 4551 break; 4538 4552 4539 - case 262: /* simple_array_literal_2d_list: simple_array_literal_2d_list '|' expr_list */ 4553 + case 262: 4540 4554 { (yyval.expressions2d)=(yyvsp[-2].expressions2d); if ((yyval.expressions2d) && (yyvsp[0].expressions1d)) (yyval.expressions2d)->push_back(*(yyvsp[0].expressions1d)); delete (yyvsp[0].expressions1d); } 4541 4555 break; 4542 4556 4543 - case 263: /* simple_array_comp: "[" expr '|' comp_tail "]" */ 4557 + case 263: 4544 4558 { if ((yyvsp[-1].generatorsPointer)) (yyval.expression)=new Comprehension((yyloc), (yyvsp[-3].expression), *(yyvsp[-1].generatorsPointer), false); 4545 4559 delete (yyvsp[-1].generatorsPointer); 4546 4560 } 4547 4561 break; 4548 4562 4549 - case 264: /* if_then_else_expr: "if" expr "then" expr "endif" */ 4563 + case 264: 4550 4564 { 4551 4565 std::vector<Expression*> iexps; 4552 4566 iexps.push_back((yyvsp[-3].expression)); ··· 4555 4569 } 4556 4570 break; 4557 4571 4558 - case 265: /* if_then_else_expr: "if" expr "then" expr elseif_list "else" expr "endif" */ 4572 + case 265: 4559 4573 { 4560 4574 std::vector<Expression*> iexps; 4561 4575 iexps.push_back((yyvsp[-6].expression)); ··· 4571 4585 } 4572 4586 break; 4573 4587 4574 - case 266: /* elseif_list: %empty */ 4588 + case 266: 4575 4589 { (yyval.expressions1d)=new std::vector<MiniZinc::Expression*>; } 4576 4590 break; 4577 4591 4578 - case 267: /* elseif_list: elseif_list "elseif" expr "then" expr */ 4592 + case 267: 4579 4593 { (yyval.expressions1d)=(yyvsp[-4].expressions1d); if ((yyval.expressions1d) && (yyvsp[-2].expression) && (yyvsp[0].expression)) { (yyval.expressions1d)->push_back((yyvsp[-2].expression)); (yyval.expressions1d)->push_back((yyvsp[0].expression)); } } 4580 4594 break; 4581 4595 4582 - case 268: /* quoted_op: "'<->'" */ 4596 + case 268: 4583 4597 { (yyval.iValue)=BOT_EQUIV; } 4584 4598 break; 4585 4599 4586 - case 269: /* quoted_op: "'->'" */ 4600 + case 269: 4587 4601 { (yyval.iValue)=BOT_IMPL; } 4588 4602 break; 4589 4603 4590 - case 270: /* quoted_op: "'<-'" */ 4604 + case 270: 4591 4605 { (yyval.iValue)=BOT_RIMPL; } 4592 4606 break; 4593 4607 4594 - case 271: /* quoted_op: "'\\/'" */ 4608 + case 271: 4595 4609 { (yyval.iValue)=BOT_OR; } 4596 4610 break; 4597 4611 4598 - case 272: /* quoted_op: "'xor'" */ 4612 + case 272: 4599 4613 { (yyval.iValue)=BOT_XOR; } 4600 4614 break; 4601 4615 4602 - case 273: /* quoted_op: "'/\\'" */ 4616 + case 273: 4603 4617 { (yyval.iValue)=BOT_AND; } 4604 4618 break; 4605 4619 4606 - case 274: /* quoted_op: "'<'" */ 4620 + case 274: 4607 4621 { (yyval.iValue)=BOT_LE; } 4608 4622 break; 4609 4623 4610 - case 275: /* quoted_op: "'>'" */ 4624 + case 275: 4611 4625 { (yyval.iValue)=BOT_GR; } 4612 4626 break; 4613 4627 4614 - case 276: /* quoted_op: "'<='" */ 4628 + case 276: 4615 4629 { (yyval.iValue)=BOT_LQ; } 4616 4630 break; 4617 4631 4618 - case 277: /* quoted_op: "'>='" */ 4632 + case 277: 4619 4633 { (yyval.iValue)=BOT_GQ; } 4620 4634 break; 4621 4635 4622 - case 278: /* quoted_op: "'='" */ 4636 + case 278: 4623 4637 { (yyval.iValue)=BOT_EQ; } 4624 4638 break; 4625 4639 4626 - case 279: /* quoted_op: "'!='" */ 4640 + case 279: 4627 4641 { (yyval.iValue)=BOT_NQ; } 4628 4642 break; 4629 4643 4630 - case 280: /* quoted_op: "'in'" */ 4644 + case 280: 4631 4645 { (yyval.iValue)=BOT_IN; } 4632 4646 break; 4633 4647 4634 - case 281: /* quoted_op: "'subset'" */ 4648 + case 281: 4635 4649 { (yyval.iValue)=BOT_SUBSET; } 4636 4650 break; 4637 4651 4638 - case 282: /* quoted_op: "'superset'" */ 4652 + case 282: 4639 4653 { (yyval.iValue)=BOT_SUPERSET; } 4640 4654 break; 4641 4655 4642 - case 283: /* quoted_op: "'union'" */ 4656 + case 283: 4643 4657 { (yyval.iValue)=BOT_UNION; } 4644 4658 break; 4645 4659 4646 - case 284: /* quoted_op: "'diff'" */ 4660 + case 284: 4647 4661 { (yyval.iValue)=BOT_DIFF; } 4648 4662 break; 4649 4663 4650 - case 285: /* quoted_op: "'symdiff'" */ 4664 + case 285: 4651 4665 { (yyval.iValue)=BOT_SYMDIFF; } 4652 4666 break; 4653 4667 4654 - case 286: /* quoted_op: "'+'" */ 4668 + case 286: 4655 4669 { (yyval.iValue)=BOT_PLUS; } 4656 4670 break; 4657 4671 4658 - case 287: /* quoted_op: "'-'" */ 4672 + case 287: 4659 4673 { (yyval.iValue)=BOT_MINUS; } 4660 4674 break; 4661 4675 4662 - case 288: /* quoted_op: "'*'" */ 4676 + case 288: 4663 4677 { (yyval.iValue)=BOT_MULT; } 4664 4678 break; 4665 4679 4666 - case 289: /* quoted_op: "'^'" */ 4680 + case 289: 4667 4681 { (yyval.iValue)=BOT_POW; } 4668 4682 break; 4669 4683 4670 - case 290: /* quoted_op: "'/'" */ 4684 + case 290: 4671 4685 { (yyval.iValue)=BOT_DIV; } 4672 4686 break; 4673 4687 4674 - case 291: /* quoted_op: "'div'" */ 4688 + case 291: 4675 4689 { (yyval.iValue)=BOT_IDIV; } 4676 4690 break; 4677 4691 4678 - case 292: /* quoted_op: "'mod'" */ 4692 + case 292: 4679 4693 { (yyval.iValue)=BOT_MOD; } 4680 4694 break; 4681 4695 4682 - case 293: /* quoted_op: "'intersect'" */ 4696 + case 293: 4683 4697 { (yyval.iValue)=BOT_INTERSECT; } 4684 4698 break; 4685 4699 4686 - case 294: /* quoted_op: "'++'" */ 4700 + case 294: 4687 4701 { (yyval.iValue)=BOT_PLUSPLUS; } 4688 4702 break; 4689 4703 4690 - case 295: /* quoted_op: "'not'" */ 4704 + case 295: 4691 4705 { (yyval.iValue)=-1; } 4692 4706 break; 4693 4707 4694 - case 296: /* quoted_op_call: quoted_op '(' expr ',' expr ')' */ 4708 + case 296: 4695 4709 { if ((yyvsp[-5].iValue)==-1) { 4696 4710 (yyval.expression)=nullptr; 4697 4711 yyerror(&(yylsp[-3]), parm, "syntax error, unary operator with two arguments"); ··· 4701 4715 } 4702 4716 break; 4703 4717 4704 - case 297: /* quoted_op_call: quoted_op '(' expr ')' */ 4718 + case 297: 4705 4719 { int uot=-1; 4706 4720 switch ((yyvsp[-3].iValue)) { 4707 4721 case -1: ··· 4733 4747 } 4734 4748 break; 4735 4749 4736 - case 298: /* call_expr: "identifier" '(' ')' */ 4750 + case 298: 4737 4751 { (yyval.expression)=new Call((yyloc), (yyvsp[-2].sValue), std::vector<Expression*>()); free((yyvsp[-2].sValue)); } 4738 4752 break; 4739 4753 4740 - case 299: /* call_expr: "identifier" "^-1" '(' ')' */ 4754 + case 299: 4741 4755 { (yyval.expression)=new Call((yyloc), std::string((yyvsp[-3].sValue))+"⁻¹", std::vector<Expression*>()); free((yyvsp[-3].sValue)); } 4742 4756 break; 4743 4757 4744 - case 301: /* call_expr: "identifier" '(' comp_or_expr ')' */ 4758 + case 301: 4745 4759 { 4746 4760 if ((yyvsp[-1].expressionPairs)!=nullptr) { 4747 4761 bool hadWhere = false; ··· 4763 4777 } 4764 4778 break; 4765 4779 4766 - case 302: /* call_expr: "identifier" '(' comp_or_expr ')' '(' expr ')' */ 4780 + case 302: 4767 4781 { 4768 4782 vector<Generator> gens; 4769 4783 vector<Id*> ids; ··· 4819 4833 } 4820 4834 break; 4821 4835 4822 - case 303: /* call_expr: "identifier" "^-1" '(' comp_or_expr ')' */ 4836 + case 303: 4823 4837 { 4824 4838 if ((yyvsp[-1].expressionPairs)!=nullptr) { 4825 4839 bool hadWhere = false; ··· 4841 4855 } 4842 4856 break; 4843 4857 4844 - case 304: /* call_expr: "identifier" "^-1" '(' comp_or_expr ')' '(' expr ')' */ 4858 + case 304: 4845 4859 { 4846 4860 vector<Generator> gens; 4847 4861 vector<Id*> ids; ··· 4897 4911 } 4898 4912 break; 4899 4913 4900 - case 306: /* comp_or_expr_head: expr */ 4914 + case 306: 4901 4915 { (yyval.expressionPairs)=new vector<pair<Expression*,Expression*> >; 4902 4916 if ((yyvsp[0].expression)) { 4903 4917 (yyval.expressionPairs)->push_back(pair<Expression*,Expression*>((yyvsp[0].expression),nullptr)); ··· 4905 4919 } 4906 4920 break; 4907 4921 4908 - case 307: /* comp_or_expr_head: expr "where" expr */ 4922 + case 307: 4909 4923 { (yyval.expressionPairs)=new vector<pair<Expression*,Expression*> >; 4910 4924 if ((yyvsp[-2].expression) && (yyvsp[0].expression)) { 4911 4925 (yyval.expressionPairs)->push_back(pair<Expression*,Expression*>((yyvsp[-2].expression),(yyvsp[0].expression))); ··· 4913 4927 } 4914 4928 break; 4915 4929 4916 - case 308: /* comp_or_expr_head: comp_or_expr_head ',' expr */ 4930 + case 308: 4917 4931 { (yyval.expressionPairs)=(yyvsp[-2].expressionPairs); if ((yyval.expressionPairs) && (yyvsp[0].expression)) (yyval.expressionPairs)->push_back(pair<Expression*,Expression*>((yyvsp[0].expression),nullptr)); } 4918 4932 break; 4919 4933 4920 - case 309: /* comp_or_expr_head: comp_or_expr_head ',' expr "where" expr */ 4934 + case 309: 4921 4935 { (yyval.expressionPairs)=(yyvsp[-4].expressionPairs); if ((yyval.expressionPairs) && (yyvsp[-2].expression) && (yyvsp[0].expression)) (yyval.expressionPairs)->push_back(pair<Expression*,Expression*>((yyvsp[-2].expression),(yyvsp[0].expression))); } 4922 4936 break; 4923 4937 4924 - case 310: /* let_expr: "let" '{' let_vardecl_item_list '}' "in" expr */ 4938 + case 310: 4925 4939 { if ((yyvsp[-3].expressions1d) && (yyvsp[0].expression)) { 4926 4940 (yyval.expression)=new Let((yyloc), *(yyvsp[-3].expressions1d), (yyvsp[0].expression)); delete (yyvsp[-3].expressions1d); 4927 4941 } else { ··· 4930 4944 } 4931 4945 break; 4932 4946 4933 - case 311: /* let_expr: "let" '{' let_vardecl_item_list comma_or_semi '}' "in" expr */ 4947 + case 311: 4934 4948 { if ((yyvsp[-4].expressions1d) && (yyvsp[0].expression)) { 4935 4949 (yyval.expression)=new Let((yyloc), *(yyvsp[-4].expressions1d), (yyvsp[0].expression)); delete (yyvsp[-4].expressions1d); 4936 4950 } else { ··· 4939 4953 } 4940 4954 break; 4941 4955 4942 - case 312: /* let_vardecl_item_list: let_vardecl_item */ 4956 + case 312: 4943 4957 { (yyval.expressions1d)=new vector<Expression*>; (yyval.expressions1d)->push_back((yyvsp[0].vardeclexpr)); } 4944 4958 break; 4945 4959 4946 - case 313: /* let_vardecl_item_list: constraint_item */ 4960 + case 313: 4947 4961 { (yyval.expressions1d)=new vector<Expression*>; 4948 4962 if ((yyvsp[0].item)) { 4949 4963 ConstraintI* ce = (yyvsp[0].item)->cast<ConstraintI>(); ··· 4953 4967 } 4954 4968 break; 4955 4969 4956 - case 314: /* let_vardecl_item_list: let_vardecl_item_list comma_or_semi let_vardecl_item */ 4970 + case 314: 4957 4971 { (yyval.expressions1d)=(yyvsp[-2].expressions1d); if ((yyval.expressions1d) && (yyvsp[0].vardeclexpr)) (yyval.expressions1d)->push_back((yyvsp[0].vardeclexpr)); } 4958 4972 break; 4959 4973 4960 - case 315: /* let_vardecl_item_list: let_vardecl_item_list comma_or_semi constraint_item */ 4974 + case 315: 4961 4975 { (yyval.expressions1d)=(yyvsp[-2].expressions1d); 4962 4976 if ((yyval.expressions1d) && (yyvsp[0].item)) { 4963 4977 ConstraintI* ce = (yyvsp[0].item)->cast<ConstraintI>(); ··· 4967 4981 } 4968 4982 break; 4969 4983 4970 - case 318: /* let_vardecl_item: ti_expr_and_id annotations */ 4984 + case 318: 4971 4985 { (yyval.vardeclexpr) = (yyvsp[-1].vardeclexpr); 4972 4986 if ((yyval.vardeclexpr)) (yyval.vardeclexpr)->toplevel(false); 4973 4987 if ((yyval.vardeclexpr) && (yyvsp[0].expressions1d)) (yyval.vardeclexpr)->addAnnotations(*(yyvsp[0].expressions1d)); ··· 4975 4989 } 4976 4990 break; 4977 4991 4978 - case 319: /* let_vardecl_item: ti_expr_and_id annotations "=" expr */ 4992 + case 319: 4979 4993 { if ((yyvsp[-3].vardeclexpr)) (yyvsp[-3].vardeclexpr)->e((yyvsp[0].expression)); 4980 4994 (yyval.vardeclexpr) = (yyvsp[-3].vardeclexpr); 4981 4995 if ((yyval.vardeclexpr)) (yyval.vardeclexpr)->loc((yyloc)); ··· 4985 4999 } 4986 5000 break; 4987 5001 4988 - case 320: /* annotations: %empty */ 5002 + case 320: 4989 5003 { (yyval.expressions1d)=nullptr; } 4990 5004 break; 4991 5005 4992 - case 322: /* annotation_expr: expr_atom_head_nonstring */ 5006 + case 322: 4993 5007 { (yyval.expression) = (yyvsp[0].expression); } 4994 5008 break; 4995 5009 4996 - case 323: /* annotation_expr: string_expr */ 5010 + case 323: 4997 5011 { (yyval.expression) = new Call((yylsp[0]), ASTString("mzn_expression_name"), {(yyvsp[0].expression)}); } 4998 5012 break; 4999 5013 5000 - case 324: /* ne_annotations: "::" annotation_expr */ 5014 + case 324: 5001 5015 { (yyval.expressions1d)=new std::vector<Expression*>(1); 5002 5016 (*(yyval.expressions1d))[0] = (yyvsp[0].expression); 5003 5017 } 5004 5018 break; 5005 5019 5006 - case 325: /* ne_annotations: ne_annotations "::" annotation_expr */ 5020 + case 325: 5007 5021 { (yyval.expressions1d)=(yyvsp[-2].expressions1d); if ((yyval.expressions1d)) (yyval.expressions1d)->push_back((yyvsp[0].expression)); } 5008 5022 break; 5009 5023 5010 - case 326: /* id_or_quoted_op: "identifier" */ 5024 + case 326: 5011 5025 { (yyval.sValue)=(yyvsp[0].sValue); } 5012 5026 break; 5013 5027 5014 - case 327: /* id_or_quoted_op: "identifier" "^-1" */ 5028 + case 327: 5015 5029 { (yyval.sValue)=strdup((std::string((yyvsp[-1].sValue))+"⁻¹").c_str()); } 5016 5030 break; 5017 5031 5018 - case 328: /* id_or_quoted_op: "'<->'" */ 5032 + case 328: 5019 5033 { (yyval.sValue)=strdup("'<->'"); } 5020 5034 break; 5021 5035 5022 - case 329: /* id_or_quoted_op: "'->'" */ 5036 + case 329: 5023 5037 { (yyval.sValue)=strdup("'->'"); } 5024 5038 break; 5025 5039 5026 - case 330: /* id_or_quoted_op: "'<-'" */ 5040 + case 330: 5027 5041 { (yyval.sValue)=strdup("'<-'"); } 5028 5042 break; 5029 5043 5030 - case 331: /* id_or_quoted_op: "'\\/'" */ 5044 + case 331: 5031 5045 { (yyval.sValue)=strdup("'\\/'"); } 5032 5046 break; 5033 5047 5034 - case 332: /* id_or_quoted_op: "'xor'" */ 5048 + case 332: 5035 5049 { (yyval.sValue)=strdup("'xor'"); } 5036 5050 break; 5037 5051 5038 - case 333: /* id_or_quoted_op: "'/\\'" */ 5052 + case 333: 5039 5053 { (yyval.sValue)=strdup("'/\\'"); } 5040 5054 break; 5041 5055 5042 - case 334: /* id_or_quoted_op: "'<'" */ 5056 + case 334: 5043 5057 { (yyval.sValue)=strdup("'<'"); } 5044 5058 break; 5045 5059 5046 - case 335: /* id_or_quoted_op: "'>'" */ 5060 + case 335: 5047 5061 { (yyval.sValue)=strdup("'>'"); } 5048 5062 break; 5049 5063 5050 - case 336: /* id_or_quoted_op: "'<='" */ 5064 + case 336: 5051 5065 { (yyval.sValue)=strdup("'<='"); } 5052 5066 break; 5053 5067 5054 - case 337: /* id_or_quoted_op: "'>='" */ 5068 + case 337: 5055 5069 { (yyval.sValue)=strdup("'>='"); } 5056 5070 break; 5057 5071 5058 - case 338: /* id_or_quoted_op: "'='" */ 5072 + case 338: 5059 5073 { (yyval.sValue)=strdup("'='"); } 5060 5074 break; 5061 5075 5062 - case 339: /* id_or_quoted_op: "'!='" */ 5076 + case 339: 5063 5077 { (yyval.sValue)=strdup("'!='"); } 5064 5078 break; 5065 5079 5066 - case 340: /* id_or_quoted_op: "'in'" */ 5080 + case 340: 5067 5081 { (yyval.sValue)=strdup("'in'"); } 5068 5082 break; 5069 5083 5070 - case 341: /* id_or_quoted_op: "'subset'" */ 5084 + case 341: 5071 5085 { (yyval.sValue)=strdup("'subset'"); } 5072 5086 break; 5073 5087 5074 - case 342: /* id_or_quoted_op: "'superset'" */ 5088 + case 342: 5075 5089 { (yyval.sValue)=strdup("'superset'"); } 5076 5090 break; 5077 5091 5078 - case 343: /* id_or_quoted_op: "'union'" */ 5092 + case 343: 5079 5093 { (yyval.sValue)=strdup("'union'"); } 5080 5094 break; 5081 5095 5082 - case 344: /* id_or_quoted_op: "'diff'" */ 5096 + case 344: 5083 5097 { (yyval.sValue)=strdup("'diff'"); } 5084 5098 break; 5085 5099 5086 - case 345: /* id_or_quoted_op: "'symdiff'" */ 5100 + case 345: 5087 5101 { (yyval.sValue)=strdup("'symdiff'"); } 5088 5102 break; 5089 5103 5090 - case 346: /* id_or_quoted_op: "'..'" */ 5104 + case 346: 5091 5105 { (yyval.sValue)=strdup("'..'"); } 5092 5106 break; 5093 5107 5094 - case 347: /* id_or_quoted_op: "'+'" */ 5108 + case 347: 5095 5109 { (yyval.sValue)=strdup("'+'"); } 5096 5110 break; 5097 5111 5098 - case 348: /* id_or_quoted_op: "'-'" */ 5112 + case 348: 5099 5113 { (yyval.sValue)=strdup("'-'"); } 5100 5114 break; 5101 5115 5102 - case 349: /* id_or_quoted_op: "'*'" */ 5116 + case 349: 5103 5117 { (yyval.sValue)=strdup("'*'"); } 5104 5118 break; 5105 5119 5106 - case 350: /* id_or_quoted_op: "'^'" */ 5120 + case 350: 5107 5121 { (yyval.sValue)=strdup("'^'"); } 5108 5122 break; 5109 5123 5110 - case 351: /* id_or_quoted_op: "'/'" */ 5124 + case 351: 5111 5125 { (yyval.sValue)=strdup("'/'"); } 5112 5126 break; 5113 5127 5114 - case 352: /* id_or_quoted_op: "'div'" */ 5128 + case 352: 5115 5129 { (yyval.sValue)=strdup("'div'"); } 5116 5130 break; 5117 5131 5118 - case 353: /* id_or_quoted_op: "'mod'" */ 5132 + case 353: 5119 5133 { (yyval.sValue)=strdup("'mod'"); } 5120 5134 break; 5121 5135 5122 - case 354: /* id_or_quoted_op: "'intersect'" */ 5136 + case 354: 5123 5137 { (yyval.sValue)=strdup("'intersect'"); } 5124 5138 break; 5125 5139 5126 - case 355: /* id_or_quoted_op: "'not'" */ 5140 + case 355: 5127 5141 { (yyval.sValue)=strdup("'not'"); } 5128 5142 break; 5129 5143 5130 - case 356: /* id_or_quoted_op: "'++'" */ 5144 + case 356: 5131 5145 { (yyval.sValue)=strdup("'++'"); } 5132 5146 break; 5133 5147 ··· 5326 5340 yyexhaustedlab: 5327 5341 yyerror (&yylloc, parm, YY_("memory exhausted")); 5328 5342 yyresult = 2; 5329 - goto yyreturn; 5343 + /* Fall through. */ 5330 5344 #endif 5331 5345 5332 5346 5333 - /*-------------------------------------------------------. 5334 - | yyreturn -- parsing is finished, clean up and return. | 5335 - `-------------------------------------------------------*/ 5347 + /*-----------------------------------------------------. 5348 + | yyreturn -- parsing is finished, return the result. | 5349 + `-----------------------------------------------------*/ 5336 5350 yyreturn: 5337 5351 if (yychar != YYEMPTY) 5338 5352 {
+41 -50
lib/chain_compressor.cpp
··· 64 64 auto* positive = c->arg(0)->cast<ArrayLit>(); 65 65 auto* negative = c->arg(1)->cast<ArrayLit>(); 66 66 if (positive->length() == 1 && negative->length() == 1) { 67 - auto* var = (*negative)[0]->dynamicCast<Id>(); 68 - if (var != nullptr) { 69 - storeItem(var->decl(), i); 70 - } 67 + auto* var = (*negative)[0]->cast<Id>(); 68 + storeItem(var->decl(), i); 71 69 return true; 72 70 } 73 71 } else if (c->id() == "mzn_reverse_map_var") { ··· 77 75 return true; 78 76 // pred_imp(..., b); i.e. b -> pred(...) 79 77 } else if (c->id().endsWith("_imp")) { 80 - auto* control = c->arg(c->argCount() - 1)->dynamicCast<Id>(); 81 - if (control != nullptr) { 82 - assert(control->type().isvarbool()); 83 - storeItem(control->decl(), i); 84 - } 78 + auto* control = c->arg(c->argCount() - 1)->cast<Id>(); 79 + assert(control->type().isvarbool()); 80 + storeItem(control->decl(), i); 85 81 return true; 86 82 } 87 83 } ··· 125 121 auto* c = ci->e()->cast<Call>(); 126 122 if (c->id() == constants().ids.clause) { 127 123 auto* positive = c->arg(0)->cast<ArrayLit>(); 128 - auto* var = (*positive)[0]->dynamicCast<Id>(); 129 - if (var != nullptr) { 130 - bool output_var = var->decl()->ann().contains(constants().ann.output_var); 131 - auto usages = _env.varOccurrences.usages(var->decl()); 132 - output_var = output_var || usages.second; 133 - int occurrences = usages.first; 134 - unsigned long lhs_occurences = count(var->decl()); 124 + auto* var = (*positive)[0]->cast<Id>(); 125 + bool output_var = var->decl()->ann().contains(constants().ann.output_var); 126 + auto usages = _env.varOccurrences.usages(var->decl()); 127 + output_var = output_var || usages.second; 128 + int occurrences = usages.first; 129 + unsigned long lhs_occurences = count(var->decl()); 135 130 136 - // Compress if: 137 - // - There is one occurrence on the RHS of a clause and the others are on the LHS of a 138 - // clause 139 - // - There is one occurrence on the RHS of a clause, that Id is a reified forall that has 140 - // no other occurrences 141 - // - There is one occurrence on the RHS of a clause, that Id is a reification in a 142 - // positive context, and all other occurrences are on the LHS of a clause 143 - bool compress = !output_var && lhs_occurences > 0; 144 - if ((var->decl()->e() != nullptr) && (var->decl()->e()->dynamicCast<Call>() != nullptr)) { 145 - auto* call = var->decl()->e()->cast<Call>(); 146 - if (call->id() == constants().ids.forall) { 147 - compress = compress && (occurrences == 1 && lhs_occurences == 1); 148 - } else { 149 - compress = compress && (occurrences == lhs_occurences); 150 - } 131 + // Compress if: 132 + // - There is one occurrence on the RHS of a clause and the others are on the LHS of a 133 + // clause 134 + // - There is one occurrence on the RHS of a clause, that Id is a reified forall that has no 135 + // other occurrences 136 + // - There is one occurrence on the RHS of a clause, that Id is a reification in a positive 137 + // context, and all other occurrences are on the LHS of a clause 138 + bool compress = !output_var && lhs_occurences > 0; 139 + if ((var->decl()->e() != nullptr) && (var->decl()->e()->dynamicCast<Call>() != nullptr)) { 140 + auto* call = var->decl()->e()->cast<Call>(); 141 + if (call->id() == constants().ids.forall) { 142 + compress = compress && (occurrences == 1 && lhs_occurences == 1); 151 143 } else { 152 - compress = compress && (occurrences == lhs_occurences + 1); 144 + compress = compress && (occurrences == lhs_occurences); 153 145 } 154 - if (compress) { 155 - rhs = var->decl(); 156 - auto* negative = c->arg(1)->cast<ArrayLit>(); 157 - lhs = (*negative)[0]->isa<Id>() ? (*negative)[0]->cast<Id>()->decl() : nullptr; 158 - if (lhs == rhs) { 159 - continue; 160 - } 146 + } else { 147 + compress = compress && (occurrences == lhs_occurences + 1); 148 + } 149 + if (compress) { 150 + rhs = var->decl(); 151 + auto* negative = c->arg(1)->cast<ArrayLit>(); 152 + lhs = (*negative)[0]->cast<Id>()->decl(); 153 + if (lhs == rhs) { 154 + continue; 161 155 } 162 - // TODO: Detect equivalences for output variables. 163 156 } 157 + // TODO: Detect equivalences for output variables. 164 158 } 165 159 } 166 160 ··· 195 189 // Given (x -> y) /\ (y -> z), produce x -> z 196 190 if (c->id() == constants().ids.clause) { 197 191 auto* positive = c->arg(0)->cast<ArrayLit>(); 198 - VarDecl* positiveDecl = 199 - (*positive)[0]->isa<Id>() ? (*positive)[0]->cast<Id>()->decl() : nullptr; 200 - if (positiveDecl != newLHS) { 192 + auto* rhs = (*positive)[0]->cast<Id>(); 193 + if (rhs->decl() != newLHS) { 201 194 ConstraintI* nci = constructClause(positive, newLHS->id()); 202 195 _boolConstraints.push_back(addItem(nci)); 203 196 } ··· 219 212 if (c->id() == constants().ids.forall) { 220 213 auto* exprs = c->arg(0)->cast<ArrayLit>(); 221 214 for (int j = 0; j < exprs->size(); ++j) { 222 - VarDecl* rhsDecl = (*exprs)[j]->isa<Id>() ? (*exprs)[j]->cast<Id>()->decl() : nullptr; 223 - if (rhsDecl != newLHS) { 224 - ConstraintI* nci = constructClause((*exprs)[j], newLHS->id()); 215 + auto* rhs = (*exprs)[j]->cast<Id>(); 216 + if (rhs->decl() != newLHS) { 217 + ConstraintI* nci = constructClause(rhs, newLHS->id()); 225 218 _boolConstraints.push_back(addItem(nci)); 226 219 } 227 220 } ··· 260 253 args[1]->type(Type::varbool(1)); 261 254 } 262 255 // NEVER CREATE (a -> a) 263 - assert(!(*args[0]->cast<ArrayLit>())[0]->isa<Id>() || 264 - !(*args[1]->cast<ArrayLit>())[0]->isa<Id>() || 265 - (*args[0]->cast<ArrayLit>())[0]->cast<Id>()->decl() != 266 - (*args[1]->cast<ArrayLit>())[0]->cast<Id>()->decl()); 256 + assert((*args[0]->dynamicCast<ArrayLit>())[0]->dynamicCast<Id>()->decl() != 257 + (*args[1]->dynamicCast<ArrayLit>())[0]->dynamicCast<Id>()->decl()); 267 258 auto* nc = new Call(MiniZinc::Location().introduce(), constants().ids.clause, args); 268 259 nc->type(Type::varbool()); 269 260 nc->decl(_env.model->matchFn(_env, nc, false));
+55 -12
lib/eval_par.cpp
··· 103 103 return eval_bool(env, e); 104 104 }; 105 105 106 - KeepAlive EvalBase::flattenCV(EnvI& env, Expression* e) { 107 - GCLock lock; 108 - Ctx ctx; 109 - ctx.i = C_MIX; 110 - ctx.b = (e->type().bt() == Type::BT_BOOL) ? C_MIX : C_ROOT; 111 - EE ee = flat_exp(env, ctx, e, nullptr, constants().varTrue); 112 - return ee.r; 113 - } 114 - 115 106 class EvalIntLit : public EvalBase { 116 107 public: 117 108 typedef IntLit* Val; 118 109 typedef Expression* ArrayVal; 119 110 static IntLit* e(EnvI& env, Expression* e) { return IntLit::a(eval_int(env, e)); } 120 111 static Expression* exp(IntLit* e) { return e; } 112 + static Expression* flatten(EnvI& /*env*/, Expression* /*e*/) { 113 + throw InternalError("evaluating var assignment generator inside par expression not supported"); 114 + } 121 115 }; 122 116 class EvalIntVal : public EvalBase { 123 117 public: ··· 134 128 } 135 129 } 136 130 } 131 + static Expression* flatten(EnvI& /*env*/, Expression* /*e*/) { 132 + throw InternalError("evaluating var assignment generator inside par expression not supported"); 133 + } 137 134 }; 138 135 class EvalFloatVal : public EvalBase { 139 136 public: ··· 150 147 } 151 148 } 152 149 } 150 + static Expression* flatten(EnvI& /*env*/, Expression* /*e*/) { 151 + throw InternalError("evaluating var assignment generator inside par expression not supported"); 152 + } 153 153 }; 154 154 class EvalFloatLit : public EvalBase { 155 155 public: ··· 157 157 typedef Expression* ArrayVal; 158 158 static FloatLit* e(EnvI& env, Expression* e) { return FloatLit::a(eval_float(env, e)); } 159 159 static Expression* exp(Expression* e) { return e; } 160 + static Expression* flatten(EnvI& /*env*/, Expression* /*e*/) { 161 + throw InternalError("evaluating var assignment generator inside par expression not supported"); 162 + } 160 163 }; 161 164 class EvalString : public EvalBase { 162 165 public: ··· 165 168 static std::string e(EnvI& env, Expression* e) { return eval_string(env, e); } 166 169 static Expression* exp(const std::string& e) { return new StringLit(Location(), e); } 167 170 static void checkRetVal(EnvI& env, const Val& v, FunctionI* fi) {} 171 + static Expression* flatten(EnvI& /*env*/, Expression* /*e*/) { 172 + throw InternalError("evaluating var assignment generator inside par expression not supported"); 173 + } 168 174 }; 169 175 class EvalStringLit : public EvalBase { 170 176 public: ··· 174 180 return new StringLit(Location(), eval_string(env, e)); 175 181 } 176 182 static Expression* exp(Expression* e) { return e; } 183 + static Expression* flatten(EnvI& /*env*/, Expression* /*e*/) { 184 + throw InternalError("evaluating var assignment generator inside par expression not supported"); 185 + } 177 186 }; 178 187 class EvalBoolLit : public EvalBase { 179 188 public: ··· 181 190 typedef Expression* ArrayVal; 182 191 static BoolLit* e(EnvI& env, Expression* e) { return constants().boollit(eval_bool(env, e)); } 183 192 static Expression* exp(Expression* e) { return e; } 193 + static Expression* flatten(EnvI& /*env*/, Expression* /*e*/) { 194 + throw InternalError("evaluating var assignment generator inside par expression not supported"); 195 + } 184 196 }; 185 197 class EvalBoolVal : public EvalBase { 186 198 public: ··· 188 200 static bool e(EnvI& env, Expression* e) { return eval_bool(env, e); } 189 201 static Expression* exp(bool e) { return constants().boollit(e); } 190 202 static void checkRetVal(EnvI& env, Val v, FunctionI* fi) {} 203 + static Expression* flatten(EnvI& /*env*/, Expression* /*e*/) { 204 + throw InternalError("evaluating var assignment generator inside par expression not supported"); 205 + } 191 206 }; 192 207 class EvalArrayLit : public EvalBase { 193 208 public: ··· 195 210 typedef Expression* ArrayVal; 196 211 static ArrayLit* e(EnvI& env, Expression* e) { return eval_array_lit(env, e); } 197 212 static Expression* exp(Expression* e) { return e; } 213 + static Expression* flatten(EnvI& /*env*/, Expression* /*e*/) { 214 + throw InternalError("evaluating var assignment generator inside par expression not supported"); 215 + } 198 216 }; 199 217 class EvalArrayLitCopy : public EvalBase { 200 218 public: ··· 273 291 } 274 292 } 275 293 } 294 + static Expression* flatten(EnvI& /*env*/, Expression* /*e*/) { 295 + throw InternalError("evaluating var assignment generator inside par expression not supported"); 296 + } 276 297 }; 277 298 class EvalIntSet : public EvalBase { 278 299 public: ··· 289 310 "function result violates function type-inst"); 290 311 } 291 312 } 313 + } 314 + static Expression* flatten(EnvI& /*env*/, Expression* /*e*/) { 315 + throw InternalError("evaluating var assignment generator inside par expression not supported"); 292 316 } 293 317 }; 294 318 class EvalFloatSet : public EvalBase { ··· 307 331 } 308 332 } 309 333 } 334 + static Expression* flatten(EnvI& /*env*/, Expression* /*e*/) { 335 + throw InternalError("evaluating var assignment generator inside par expression not supported"); 336 + } 310 337 }; 311 338 class EvalBoolSet : public EvalBase { 312 339 public: ··· 318 345 return sl; 319 346 } 320 347 static void checkRetVal(EnvI& env, Val v, FunctionI* fi) {} 348 + static Expression* flatten(EnvI& /*env*/, Expression* /*e*/) { 349 + throw InternalError("evaluating var assignment generator inside par expression not supported"); 350 + } 321 351 }; 322 352 class EvalSetLit : public EvalBase { 323 353 public: ··· 325 355 typedef Expression* ArrayVal; 326 356 static SetLit* e(EnvI& env, Expression* e) { return eval_set_lit(env, e); } 327 357 static Expression* exp(Expression* e) { return e; } 358 + static Expression* flatten(EnvI& /*env*/, Expression* /*e*/) { 359 + throw InternalError("evaluating var assignment generator inside par expression not supported"); 360 + } 328 361 }; 329 362 class EvalFloatSetLit : public EvalBase { 330 363 public: ··· 332 365 typedef Expression* ArrayVal; 333 366 static SetLit* e(EnvI& env, Expression* e) { return new SetLit(e->loc(), eval_floatset(env, e)); } 334 367 static Expression* exp(Expression* e) { return e; } 368 + static Expression* flatten(EnvI& /*env*/, Expression* /*e*/) { 369 + throw InternalError("evaluating var assignment generator inside par expression not supported"); 370 + } 335 371 }; 336 372 class EvalBoolSetLit : public EvalBase { 337 373 public: ··· 343 379 return sl; 344 380 } 345 381 static Expression* exp(Expression* e) { return e; } 382 + static Expression* flatten(EnvI& /*env*/, Expression* /*e*/) { 383 + throw InternalError("evaluating var assignment generator inside par expression not supported"); 384 + } 346 385 }; 347 386 class EvalCopy : public EvalBase { 348 387 public: ··· 350 389 typedef Expression* ArrayVal; 351 390 static Expression* e(EnvI& env, Expression* e) { return copy(env, e, true); } 352 391 static Expression* exp(Expression* e) { return e; } 392 + static Expression* flatten(EnvI& /*env*/, Expression* /*e*/) { 393 + throw InternalError("evaluating var assignment generator inside par expression not supported"); 394 + } 353 395 }; 354 396 class EvalPar : public EvalBase { 355 397 public: ··· 358 400 static Expression* e(EnvI& env, Expression* e) { return eval_par(env, e); } 359 401 static Expression* exp(Expression* e) { return e; } 360 402 static void checkRetVal(EnvI& env, Val v, FunctionI* fi) {} 403 + static Expression* flatten(EnvI& /*env*/, Expression* /*e*/) { 404 + throw InternalError("evaluating var assignment generator inside par expression not supported"); 405 + } 361 406 }; 362 407 363 408 void check_dom(EnvI& env, Id* arg, IntSetVal* dom, Expression* e) { ··· 1199 1244 return false; 1200 1245 } 1201 1246 } else if (bo->op() == BOT_EQ && lhs->type().isAnn()) { 1202 - // follow ann id to value, since there might be indirection (e.g. func argument, see 1203 - // test_equality_of_indirect_annotations.mzn) 1204 - return Expression::equal(follow_id_to_value(lhs), follow_id_to_value(rhs)); 1247 + return Expression::equal(lhs, rhs); 1205 1248 } else if (bo->op() == BOT_EQ && lhs->type().dim() > 0 && rhs->type().dim() > 0) { 1206 1249 try { 1207 1250 ArrayLit* al0 = eval_array_lit(env, lhs);
+7 -29
lib/flatten.cpp
··· 681 681 ignoreUnknownIds(false), 682 682 maxCallStack(0), 683 683 inRedundantConstraint(0), 684 - inSymmetryBreakingConstraint(0), 685 684 inMaybePartial(0), 686 685 inReverseMapVar(false), 687 686 counters({0, 0, 0, 0}), ··· 737 736 } 738 737 long long int EnvI::genId() { return _ids++; } 739 738 void EnvI::cseMapInsert(Expression* e, const EE& ee) { 740 - if (e->type().isPar() && !e->isa<ArrayLit>()) { 741 - return; 742 - } 743 739 KeepAlive ka(e); 744 740 _cseMap.insert(ka, WW(ee.r(), ee.b())); 745 741 Call* c = e->dynamicCast<Call>(); ··· 857 853 bool allCalls = true; 858 854 for (int i = static_cast<int>(callStack.size()) - 1; i >= prev; i--) { 859 855 Expression* ee = callStack[i]->untag(); 860 - if (ee->type().isAnn()) { 861 - // If we are inside an annotation call, don't annotate it again with 862 - // anything from outside the call 863 - break; 864 - } 865 856 allCalls = allCalls && (i == callStack.size() - 1 || ee->isa<Call>() || ee->isa<BinOp>()); 866 857 for (ExpressionSetIter it = ee->ann().begin(); it != ee->ann().end(); ++it) { 867 858 EE ee_ann = flat_exp(*this, Ctx(), *it, nullptr, constants().varTrue); ··· 1113 1104 if (e->isa<Call>() && e->cast<Call>()->id() == "redundant_constraint") { 1114 1105 env.inRedundantConstraint++; 1115 1106 } 1116 - if (e->isa<Call>() && e->cast<Call>()->id() == "symmetry_breaking_constraint") { 1117 - env.inSymmetryBreakingConstraint++; 1118 - } 1119 1107 if (e->ann().contains(constants().ann.maybe_partial)) { 1120 1108 env.inMaybePartial++; 1121 1109 } ··· 1135 1123 } 1136 1124 if (e->isa<Call>() && e->cast<Call>()->id() == "redundant_constraint") { 1137 1125 env.inRedundantConstraint--; 1138 - } 1139 - if (e->isa<Call>() && e->cast<Call>()->id() == "symmetry_breaking_constraint") { 1140 - env.inSymmetryBreakingConstraint--; 1141 1126 } 1142 1127 if (e->ann().contains(constants().ann.maybe_partial)) { 1143 1128 env.inMaybePartial--; ··· 2689 2674 typedef Expression* ArrayVal; 2690 2675 Expression* e(EnvI& env, Expression* e) const { return flat_cv_exp(env, ctx, e)(); } 2691 2676 static Expression* exp(Expression* e) { return e; } 2677 + static Expression* flatten(EnvI& env, Expression* e0) { 2678 + return flat_exp(env, Ctx(), e0, nullptr, constants().varTrue).r(); 2679 + } 2680 + 2692 2681 } eval(ctx); 2693 2682 std::vector<Expression*> a = eval_comp<EvalFlatCvExp>(env, eval, c); 2694 2683 ··· 3157 3146 GCLock lock; 3158 3147 IntSetVal* dom = eval_intset(env, vdi->e()->ti()->domain()); 3159 3148 3160 - if (0 == dom->size()) { 3161 - std::ostringstream oss; 3162 - oss << "Variable has empty domain: " << (*vdi->e()); 3163 - env.fail(oss.str()); 3164 - } 3165 - 3166 - bool needRangeDomain = onlyRangeDomains && !vdi->e()->type().isOpt(); 3167 - if (!needRangeDomain && !vdi->e()->type().isOpt()) { 3149 + bool needRangeDomain = onlyRangeDomains; 3150 + if (!needRangeDomain && dom->size() > 0) { 3168 3151 if (dom->min(0).isMinusInfinity() || dom->max(dom->size() - 1).isPlusInfinity()) { 3169 3152 needRangeDomain = true; 3170 3153 } ··· 3203 3186 std::vector<Expression*> args(2); 3204 3187 args[0] = vdi->e()->id(); 3205 3188 args[1] = new SetLit(vdi->e()->loc(), dom); 3206 - Call* call = new Call(vdi->e()->loc(), constants().ids.mzn_set_in_internal, args); 3189 + Call* call = new Call(vdi->e()->loc(), constants().ids.set_in, args); 3207 3190 call->type(Type::varbool()); 3208 3191 call->decl(env.model->matchFn(env, call, false)); 3209 3192 // Give distinct call stack ··· 3224 3207 vdi->e()->ti()->domain() != nullptr) { 3225 3208 GCLock lock; 3226 3209 FloatSetVal* vdi_dom = eval_floatset(env, vdi->e()->ti()->domain()); 3227 - if (0 == vdi_dom->size()) { 3228 - std::ostringstream oss; 3229 - oss << "Variable has empty domain: " << (*vdi->e()); 3230 - env.fail(oss.str()); 3231 - } 3232 3210 FloatVal vmin = vdi_dom->min(); 3233 3211 FloatVal vmax = vdi_dom->max(); 3234 3212 if (vmin == -FloatVal::infinity() && vmax == FloatVal::infinity()) {
+3
lib/flatten/flatten_comp.cpp
··· 193 193 : nullptr; 194 194 return flat_exp(env, ctx, e0, r, b); 195 195 } 196 + static Expression* flatten(EnvI& env, Expression* e0) { 197 + return flat_exp(env, Ctx(), e0, nullptr, constants().varTrue).r(); 198 + } 196 199 } _evalf(ctx); 197 200 std::vector<EE> elems_ee; 198 201 bool wasUndefined = false;
+17 -26
lib/flatten/flatten_par.cpp
··· 36 36 } 37 37 if (e->type().dim() > 0) { 38 38 EnvI::CSEMap::iterator it; 39 - auto* ident = e->dynamicCast<Id>(); 40 - if (ident != nullptr) { 41 - Expression* e_val = follow_id_to_decl(ident); 42 - if (e_val->isa<Id>()) { 43 - ident = e_val->cast<Id>(); 44 - } else if (e_val->isa<VarDecl>()) { 45 - ident = e_val->cast<VarDecl>()->id(); 46 - } 47 - if (ident->decl()->flat() == nullptr || ident->decl()->toplevel()) { 48 - VarDecl* vd = ident->decl()->flat(); 49 - if (vd == nullptr) { 50 - EE flat_ident = flat_exp(env, Ctx(), ident->decl(), nullptr, constants().varTrue); 51 - vd = flat_ident.r()->cast<Id>()->decl(); 52 - ident->decl()->flat(vd); 53 - auto* al = follow_id(vd->id())->cast<ArrayLit>(); 54 - if (al->size() == 0) { 55 - if (r == nullptr) { 56 - ret.r = al; 57 - } else { 58 - ret.r = bind(env, ctx, r, al); 59 - } 60 - ret.b = bind(env, Ctx(), b, constants().literalTrue); 61 - return ret; 39 + Id* id = e->dynamicCast<Id>(); 40 + if ((id != nullptr) && (id->decl()->flat() == nullptr || id->decl()->toplevel())) { 41 + VarDecl* vd = id->decl()->flat(); 42 + if (vd == nullptr) { 43 + vd = flat_exp(env, Ctx(), id->decl(), nullptr, constants().varTrue).r()->cast<Id>()->decl(); 44 + id->decl()->flat(vd); 45 + auto* al = follow_id(vd->id())->cast<ArrayLit>(); 46 + if (al->size() == 0) { 47 + if (r == nullptr) { 48 + ret.r = al; 49 + } else { 50 + ret.r = bind(env, ctx, r, al); 62 51 } 52 + ret.b = bind(env, Ctx(), b, constants().literalTrue); 53 + return ret; 63 54 } 64 - ret.r = bind(env, ctx, r, e->cast<Id>()->decl()->flat()->id()); 65 - ret.b = bind(env, Ctx(), b, constants().literalTrue); 66 - return ret; 67 55 } 56 + ret.r = bind(env, ctx, r, e->cast<Id>()->decl()->flat()->id()); 57 + ret.b = bind(env, Ctx(), b, constants().literalTrue); 58 + return ret; 68 59 } 69 60 if ((it = env.cseMapFind(e)) != env.cseMapEnd()) { 70 61 ret.r = bind(env, ctx, r, it->second.r()->cast<VarDecl>()->id());
+1 -5
lib/flatten/flatten_setlit.cpp
··· 34 34 ret.b = conj(env, b, Ctx(), elems_ee); 35 35 if (allPar) { 36 36 GCLock lock; 37 - auto* nsl = new SetLit(Location().introduce(), elems); 38 - Type nsl_t(e->type()); 39 - nsl_t.ti(Type::TI_PAR); 40 - nsl->type(nsl_t); 41 - Expression* ee = eval_set_lit(env, nsl); 37 + Expression* ee = eval_set_lit(env, e); 42 38 ret.r = bind(env, Ctx(), r, ee); 43 39 } else { 44 40 GCLock lock;
-7
lib/flatten/flatten_vardecl.cpp
··· 63 63 } 64 64 } 65 65 } 66 - if (vd->e() != nullptr && vd->e()->type().isPar() && !vd->ti()->type().isPar()) { 67 - // Flattening the RHS resulted in a par expression. Make the variable par. 68 - Type t(vd->ti()->type()); 69 - t.ti(Type::TI_PAR); 70 - vd->ti()->type(t); 71 - vd->type(t); 72 - } 73 66 } 74 67 75 68 ret.r = bind(env, Ctx(), r, vd->id());
+2 -3
lib/flattener.cpp
··· 474 474 } 475 475 476 476 if (!_globalsDir.empty()) { 477 - _includePaths.insert(_includePaths.begin(), 478 - FileUtils::file_path(_stdLibDir + "/" + _globalsDir + "/")); 477 + _includePaths.insert(_includePaths.begin(), _stdLibDir + "/" + _globalsDir + "/"); 479 478 } 480 - _includePaths.push_back(FileUtils::file_path(_stdLibDir + "/std/")); 479 + _includePaths.push_back(_stdLibDir + "/std/"); 481 480 482 481 for (auto& includePath : _includePaths) { 483 482 if (!FileUtils::directory_exists(includePath)) {
+2 -3
lib/json_parser.cpp
··· 629 629 string ident = expectString(is); 630 630 expectToken(is, T_COLON); 631 631 auto it = knownIds.find(ident); 632 - bool possibleString = it == knownIds.end() || 633 - (!it->second->isEnum() && it->second->type().bt() != Type::BT_UNKNOWN); 632 + bool possibleString = it == knownIds.end() || it->second->type().bt() != Type::BT_UNKNOWN; 634 633 Expression* e = parseExp(is, isData, possibleString); 635 634 if (ident[0] != '_' && (!isData || it != knownIds.end())) { 636 635 if (e == nullptr) { ··· 648 647 e = coerceArray(it->second, al); 649 648 } else if (it->second->type().isSet()) { 650 649 // Convert array to a set 651 - e = new SetLit(Location().introduce(), al->getVec()); 650 + e = new Call(Location().introduce(), "array2set", {al}); 652 651 } 653 652 } 654 653 auto* ai = new AssignI(e->loc().introduce(), ident, e);
+10 -36
lib/output.cpp
··· 217 217 bool outputObjective = (c.argCount() == 1 && eval_bool(env, c.arg(0))); 218 218 c.id(ASTString("array1d")); 219 219 Expression* json = 220 - copy(env, env.cmap, create_json_output(env, outputObjective, false, false)); 220 + copy(env, env.cmap, create__json_output(env, outputObjective, false, false)); 221 221 std::vector<Expression*> new_args({json}); 222 222 new_args[0]->type(Type::parstring(1)); 223 223 c.args(new_args); ··· 655 655 bool needArrayXd = false; 656 656 if (vd->type().dim() > 0) { 657 657 ArrayLit* al = nullptr; 658 - if (!vd->ann().contains(constants().ann.output_only)) { 659 - if ((vd->flat() != nullptr) && (vd->flat()->e() != nullptr)) { 660 - al = eval_array_lit(_e, vd->flat()->e()); 661 - } else if (vd->e() != nullptr) { 662 - al = eval_array_lit(_e, vd->e()); 663 - } 658 + if ((vd->flat() != nullptr) && (vd->flat()->e() != nullptr)) { 659 + al = eval_array_lit(_e, vd->flat()->e()); 660 + } else if (vd->e() != nullptr) { 661 + al = eval_array_lit(_e, vd->e()); 664 662 } 665 - if (al == nullptr || al->size() > 0) { 663 + if (al->size() > 0) { 666 664 needArrayXd = true; 667 665 s << "array" << vd->type().dim() << "d("; 668 666 for (int i = 0; i < vd->type().dim(); i++) { ··· 672 670 s << _e.getEnum(enumId)->e()->id()->str() << ", "; 673 671 } else if (al != nullptr) { 674 672 s << al->min(i) << ".." << al->max(i) << ", "; 675 - } else if (vd->ti()->ranges()[i]->domain() != nullptr) { 673 + } else { 676 674 IntSetVal* idxset = eval_intset(_e, vd->ti()->ranges()[i]->domain()); 677 675 s << *idxset << ", "; 678 - } else { 679 - // Don't know index set range - have to compute in solns2out 680 - auto* sl = new StringLit(Location().introduce(), s.str()); 681 - _outputVars.push_back(sl); 682 - 683 - std::string index_set_fn = "index_set"; 684 - if (vd->type().dim() > 1) { 685 - index_set_fn += 686 - "_" + std::to_string(i + 1) + "of" + std::to_string(vd->type().dim()); 687 - } 688 - auto* index_set_xx = new Call(Location().introduce(), index_set_fn, {vd->id()}); 689 - index_set_xx->type(Type::parsetint()); 690 - auto* i_fi = _e.model->matchFn(_e, index_set_xx, false); 691 - assert(i_fi); 692 - index_set_xx->decl(i_fi); 693 - 694 - auto* show = new Call(Location().introduce(), constants().ids.show, {index_set_xx}); 695 - show->type(Type::parstring()); 696 - FunctionI* s_fi = _e.model->matchFn(_e, show, false); 697 - assert(s_fi); 698 - show->decl(s_fi); 699 - 700 - _outputVars.push_back(show); 701 - s.str(", "); 702 676 } 703 677 } 704 678 } ··· 764 738 e.model->addItem(newOutputItem); 765 739 } 766 740 767 - ArrayLit* create_json_output(EnvI& e, bool outputObjective, bool includeOutputItem, 768 - bool hasChecker) { 741 + ArrayLit* create__json_output(EnvI& e, bool outputObjective, bool includeOutputItem, 742 + bool hasChecker) { 769 743 std::vector<Expression*> outputVars; 770 744 outputVars.push_back(new StringLit(Location().introduce(), "{\n")); 771 745 ··· 893 867 bool hasChecker) { 894 868 auto* newOutputItem = 895 869 new OutputI(Location().introduce(), 896 - create_json_output(e, outputObjective, includeOutputItem, hasChecker)); 870 + create__json_output(e, outputObjective, includeOutputItem, hasChecker)); 897 871 e.model->addItem(newOutputItem); 898 872 } 899 873
+43 -64
lib/parser.cpp
··· 53 53 54 54 namespace MiniZinc { 55 55 56 - std::string ParserState::canonicalFilename(const std::string& f) const { 57 - if (FileUtils::is_absolute(f) || std::string(filename).empty()) { 58 - return f; 59 - } 60 - for (const auto& ip : includePaths) { 61 - std::string fullname = FileUtils::file_path(ip + "/" + f); 62 - if (FileUtils::file_exists(fullname)) { 63 - return fullname; 64 - } 65 - } 66 - std::string parentPath = FileUtils::dir_name(filename); 67 - if (parentPath.empty()) { 68 - parentPath = "."; 69 - } 70 - std::string fullname = FileUtils::file_path(parentPath + "/" + f); 71 - if (FileUtils::file_exists(fullname)) { 72 - return fullname; 73 - } 74 - return f; 75 - } 76 - 77 56 void parse(Env& env, Model*& model, const vector<string>& filenames, 78 57 const vector<string>& datafiles, const std::string& modelString, 79 58 const std::string& modelStringName, const vector<string>& ip, bool isFlatZinc, ··· 103 82 string fullName = filenames[i]; 104 83 string baseName = FileUtils::base_name(filenames[i]); 105 84 if (!FileUtils::is_absolute(fullName)) { 106 - fullName = FileUtils::file_path(workingDir + "/" + fullName); 85 + fullName = workingDir + "/" + fullName; 107 86 } 108 87 bool isFzn = (baseName.compare(baseName.length() - 4, 4, ".fzn") == 0); 109 88 if (isFzn) { ··· 112 91 auto* includedModel = new Model; 113 92 includedModel->setFilename(baseName); 114 93 files.emplace_back(includedModel, nullptr, "", fullName); 115 - seenModels.insert(pair<string, Model*>(fullName, includedModel)); 94 + seenModels.insert(pair<string, Model*>(baseName, includedModel)); 116 95 Location loc(ASTString(filenames[i]), 0, 0, 0, 0); 117 96 auto* inc = new IncludeI(loc, includedModel->filename()); 118 97 inc->m(includedModel, true); ··· 138 117 auto include_file = [&](const std::string& libname, bool builtin) { 139 118 GCLock lock; 140 119 auto* lib = new Model; 141 - std::string fullname; 142 - for (const auto& ip : includePaths) { 143 - std::string n = FileUtils::file_path(ip + "/" + libname); 144 - if (FileUtils::file_exists(n)) { 145 - fullname = n; 146 - break; 147 - } 148 - } 149 - lib->setFilename(fullname); 150 - files.emplace_back(lib, nullptr, "./", fullname, builtin); 151 - seenModels.insert(pair<string, Model*>(fullname, lib)); 120 + lib->setFilename(libname); 121 + files.emplace_back(lib, nullptr, "./", libname, builtin); 122 + seenModels.insert(pair<string, Model*>(libname, lib)); 152 123 Location libloc(ASTString(model->filename()), 0, 0, 0, 0); 153 - auto* libinc = new IncludeI(libloc, libname); 124 + auto* libinc = new IncludeI(libloc, lib->filename()); 154 125 libinc->m(lib, true); 155 126 model->addItem(libinc); 156 127 }; ··· 178 149 179 150 std::string s; 180 151 std::string fullname; 181 - std::string basename; 182 152 bool isFzn; 183 153 if (!isModelString) { 184 154 for (Model* p = m->parent(); p != nullptr; p = p->parent()) { ··· 191 161 } 192 162 } 193 163 ifstream file; 194 - if (FileUtils::is_absolute(f)) { 164 + if (FileUtils::is_absolute(f) || parentPath.empty()) { 195 165 fullname = f; 196 - basename = FileUtils::base_name(fullname); 197 166 if (FileUtils::file_exists(fullname)) { 198 167 file.open(FILE_PATH(fullname), std::ios::binary); 199 168 } 200 - } 201 - if (file.is_open() && 202 - FileUtils::file_path(FileUtils::dir_name(fullname)) != FileUtils::file_path(workingDir) && 203 - FileUtils::file_exists(workingDir + "/" + basename)) { 204 - err << "Warning: file " << basename 205 - << " included from library, but also exists in current working directory" << endl; 206 - } 207 - for (const auto& includePath : includePaths) { 208 - std::string deprecatedName = includePath + "/" + basename + ".deprecated.mzn"; 209 - if (FileUtils::file_exists(deprecatedName)) { 210 - string deprecatedFullPath = FileUtils::file_path(deprecatedName); 211 - string deprecatedBaseName = FileUtils::base_name(deprecatedFullPath); 212 - string deprecatedDirName = FileUtils::dir_name(deprecatedFullPath); 213 - auto* includedModel = new Model; 214 - includedModel->setFilename(deprecatedName); 215 - files.emplace_back(includedModel, nullptr, "", deprecatedName, isSTDLib, false); 216 - seenModels.insert(pair<string, Model*>(deprecatedName, includedModel)); 217 - Location loc(ASTString(deprecatedName), 0, 0, 0, 0); 218 - auto* inc = new IncludeI(loc, includedModel->filename()); 219 - inc->m(includedModel, true); 220 - m->addItem(inc); 221 - files.emplace_back(includedModel, inc, deprecatedDirName, deprecatedFullPath, isSTDLib, 222 - false); 169 + } else { 170 + includePaths.push_back(parentPath); 171 + unsigned int i = 0; 172 + for (; i < includePaths.size(); i++) { 173 + fullname = includePaths[i] + "/" + f; 174 + if (FileUtils::file_exists(fullname)) { 175 + file.open(FILE_PATH(fullname), std::ios::binary); 176 + if (file.is_open()) { 177 + break; 178 + } 179 + } 180 + } 181 + if (file.is_open() && i < includePaths.size() - 1 && parentPath == workingDir && 182 + FileUtils::file_path(includePaths[i], workingDir) != FileUtils::file_path(workingDir) && 183 + FileUtils::file_exists(workingDir + "/" + f)) { 184 + err << "Warning: file " << f 185 + << " included from library, but also exists in current working directory" << endl; 186 + } 187 + for (; i < includePaths.size(); i++) { 188 + std::string deprecatedName = includePaths[i] + "/" + f + ".deprecated.mzn"; 189 + if (FileUtils::file_exists(deprecatedName)) { 190 + string deprecatedBaseName = FileUtils::base_name(deprecatedName); 191 + auto* includedModel = new Model; 192 + includedModel->setFilename(deprecatedBaseName); 193 + files.emplace_back(includedModel, nullptr, "", deprecatedName, isSTDLib, false); 194 + seenModels.insert(pair<string, Model*>(deprecatedBaseName, includedModel)); 195 + Location loc(ASTString(deprecatedName), 0, 0, 0, 0); 196 + auto* inc = new IncludeI(loc, includedModel->filename()); 197 + inc->m(includedModel, true); 198 + m->addItem(inc); 199 + files.emplace_back(includedModel, inc, deprecatedName, deprecatedBaseName, isSTDLib, 200 + false); 201 + } 223 202 } 203 + includePaths.pop_back(); 224 204 } 225 205 if (!file.is_open()) { 226 206 if (np_ii != nullptr) { ··· 248 228 fullname = f; 249 229 s = parentPath; 250 230 } 251 - ParserState pp(fullname, s, err, includePaths, files, seenModels, m, false, isFzn, isSTDLib, 231 + ParserState pp(fullname, s, err, files, seenModels, m, false, isFzn, isSTDLib, 252 232 parseDocComments); 253 233 mzn_yylex_init(&pp.yyscanner); 254 234 mzn_yyset_extra(&pp, pp.yyscanner); ··· 285 265 s = get_file_contents(file); 286 266 } 287 267 288 - ParserState pp(f, s, err, includePaths, files, seenModels, model, true, false, false, 289 - parseDocComments); 268 + ParserState pp(f, s, err, files, seenModels, model, true, false, false, parseDocComments); 290 269 mzn_yylex_init(&pp.yyscanner); 291 270 mzn_yyset_extra(&pp, pp.yyscanner); 292 271 mzn_yyparse(&pp);
+5 -5
lib/parser.yxx
··· 395 395 include_item : 396 396 MZN_INCLUDE MZN_STRING_LITERAL 397 397 { ParserState* pp = static_cast<ParserState*>(parm); 398 - string canonicalName=pp->canonicalFilename($2); 399 - map<string,Model*>::iterator ret = pp->seenModels.find(canonicalName); 398 + map<string,Model*>::iterator ret = pp->seenModels.find($2); 400 399 IncludeI* ii = new IncludeI(@$,ASTString($2)); 401 400 $$ = ii; 402 401 if (ret == pp->seenModels.end()) { 403 402 Model* im = new Model; 404 403 im->setParent(pp->model); 405 - im->setFilename(canonicalName); 404 + im->setFilename($2); 406 405 string fpath = FileUtils::dir_name(pp->filename); 406 + string fbase = FileUtils::base_name(pp->filename); 407 407 if (fpath=="") 408 408 fpath="./"; 409 - pp->files.emplace_back(im, ii, fpath, canonicalName, pp->isSTDLib); 409 + pp->files.emplace_back(im, ii, fpath, $2, pp->isSTDLib); 410 410 ii->m(im); 411 - pp->seenModels.insert(pair<string,Model*>(canonicalName,im)); 411 + pp->seenModels.insert(pair<string,Model*>($2,im)); 412 412 } else { 413 413 ii->m(ret->second, false); 414 414 }
+1 -19
lib/passes/compile_pass.cpp
··· 33 33 using std::string; 34 34 using std::vector; 35 35 36 - ASTString strip_stdlib_path(const vector<string>& includePaths, const ASTString& fs) { 37 - std::string f(fs.c_str()); 38 - for (const auto& p : includePaths) { 39 - if (f.size() > p.size() && f.substr(0, p.size()) == p) { 40 - f = f.substr(p.size()); 41 - while (!f.empty() && f[0] == '/') { 42 - f = f.substr(1); 43 - } 44 - return ASTString(f); 45 - } 46 - } 47 - return fs; 48 - } 49 - 50 36 Env* change_library(Env& e, vector<string>& includePaths, const string& globals_dir, 51 37 CompilePassFlags& compflags, bool verbose = false) { 52 38 GCLock lock; ··· 67 53 vector<ASTString> include_names; 68 54 for (Item* item : *m) { 69 55 if (auto* inc = item->dynamicCast<IncludeI>()) { 70 - if (FileUtils::is_absolute(inc->f().c_str())) { 71 - include_names.push_back(inc->f()); 72 - } else { 73 - include_names.push_back(strip_stdlib_path(new_includePaths, inc->m()->filepath())); 74 - } 56 + include_names.push_back(inc->m()->filepath()); 75 57 } else { 76 58 new_mod->addItem(copy(e.envi(), cm, item)); 77 59 }
+2 -2
lib/prettyprinter.cpp
··· 657 657 } 658 658 switch (i->iid()) { 659 659 case Item::II_INC: 660 - _os << "include \"" << Printer::escapeStringLit(i->cast<IncludeI>()->f()) << "\""; 660 + _os << "include \"" << i->cast<IncludeI>()->f() << "\""; 661 661 break; 662 662 case Item::II_VD: 663 663 p(i->cast<VarDeclI>()->e()); ··· 1648 1648 typedef Document* ret; 1649 1649 static ret mapIncludeI(const IncludeI& ii) { 1650 1650 std::ostringstream oss; 1651 - oss << "include \"" << Printer::escapeStringLit(ii.f()) << "\";"; 1651 + oss << "include \"" << ii.f() << "\";"; 1652 1652 return new StringDocument(oss.str()); 1653 1653 } 1654 1654 static ret mapVarDeclI(const VarDeclI& vi) {
+1 -1
lib/solver_instance_base.cpp
··· 18 18 19 19 namespace MiniZinc { 20 20 21 - SolverInstanceBase::Status SolverInstanceBase::solve() { return SolverInstanceError; } 21 + SolverInstanceBase::Status SolverInstanceBase::solve() { return SolverInstance__ERROR; } 22 22 23 23 void SolverInstanceBase::reset() { assert(false); } 24 24
+11 -82
lib/typecheck.cpp
··· 154 154 } 155 155 }; 156 156 157 - // Create all required mapping functions for a new enum 158 - // (mapping enum identifiers to strings, and mapping between different enums) 159 157 void create_enum_mapper(EnvI& env, Model* m, unsigned int enumId, VarDecl* vd, Model* enumItems) { 160 158 GCLock lock; 161 159 162 160 Id* ident = vd->id(); 163 - 164 - if (vd->e() == nullptr) { 165 - // Enum without right hand side (may be supplied later in an assignment 166 - // item, or we may be runnint in --model-interface-only mode). 167 - // Need to create stub function declarations, so that the type checker 168 - // is happy. 169 - Type tx = Type::parint(); 170 - tx.ot(Type::OT_OPTIONAL); 171 - auto* ti_aa = new TypeInst(Location().introduce(), tx); 172 - auto* vd_aa = new VarDecl(Location().introduce(), ti_aa, "x"); 173 - vd_aa->toplevel(false); 174 - 175 - auto* ti_ab = new TypeInst(Location().introduce(), Type::parbool()); 176 - auto* vd_ab = new VarDecl(Location().introduce(), ti_ab, "b"); 177 - vd_ab->toplevel(false); 178 - 179 - auto* ti_aj = new TypeInst(Location().introduce(), Type::parbool()); 180 - auto* vd_aj = new VarDecl(Location().introduce(), ti_aj, "json"); 181 - vd_aj->toplevel(false); 182 - 183 - auto* ti_fi = new TypeInst(Location().introduce(), Type::parstring()); 184 - std::vector<VarDecl*> fi_params(3); 185 - fi_params[0] = vd_aa; 186 - fi_params[1] = vd_ab; 187 - fi_params[2] = vd_aj; 188 - auto* fi = 189 - new FunctionI(Location().introduce(), create_enum_to_string_name(ident, "_toString_"), 190 - ti_fi, fi_params, nullptr); 191 - enumItems->addItem(fi); 192 - 193 - return; 194 - } 195 - 196 161 Call* c = vd->e()->dynamicCast<Call>(); 197 162 auto* al = vd->e()->dynamicCast<ArrayLit>(); 198 163 ··· 796 761 } 797 762 798 763 // Create set literal for overall enum 799 - Expression* upperBound; 800 - if (!partCardinality.empty()) { 801 - upperBound = partCardinality.back(); 802 - } else { 803 - // For empty enums, just create 1..0. 804 - upperBound = IntLit::a(0); 805 - } 806 - auto* rhs = new BinOp(vd->loc(), IntLit::a(1), BOT_DOTDOT, upperBound); 764 + auto* rhs = new BinOp(vd->loc(), IntLit::a(1), BOT_DOTDOT, partCardinality.back()); 807 765 vd->e(rhs); 808 766 809 767 if (parts.size() > 1) { ··· 1162 1120 vd->ti()->type(vdt); 1163 1121 vd->type(vdt); 1164 1122 1165 - create_enum_mapper(env, model, enumId, vd, enumItems); 1123 + if (vd->e() != nullptr) { 1124 + create_enum_mapper(env, model, enumId, vd, enumItems); 1125 + } 1166 1126 } 1167 1127 scopes.add(env, vd); 1168 1128 } ··· 1488 1448 FunctionI* fi = m->matchFn(env, c, false); 1489 1449 assert(fi); 1490 1450 Type ct = fi->rtype(env, args, false); 1491 - ct.cv(e->type().cv() || ct.cv()); 1451 + ct.cv(e->type().cv()); 1492 1452 c->type(ct); 1493 1453 c->decl(fi); 1494 1454 KeepAlive ka(c); ··· 2143 2103 args[0] = bop.lhs(); 2144 2104 args[1] = bop.rhs(); 2145 2105 Type ty = fi->rtype(_env, args, true); 2146 - ty.cv(bop.lhs()->type().cv() || bop.rhs()->type().cv() || ty.cv()); 2106 + ty.cv(bop.lhs()->type().cv() || bop.rhs()->type().cv()); 2147 2107 bop.type(ty); 2148 2108 2149 2109 if (fi->e() != nullptr) { ··· 2292 2252 uop.e(add_coercion(_env, _model, uop.e(), fi->argtype(_env, args, 0))()); 2293 2253 args[0] = uop.e(); 2294 2254 Type ty = fi->rtype(_env, args, true); 2295 - ty.cv(uop.e()->type().cv() || ty.cv()); 2255 + ty.cv(uop.e()->type().cv()); 2296 2256 uop.type(ty); 2297 2257 if (fi->e() != nullptr) { 2298 2258 uop.decl(fi); ··· 2420 2380 2421 2381 // Set type and decl 2422 2382 Type ty = fi->rtype(_env, args, true); 2423 - ty.cv(cv || ty.cv()); 2383 + ty.cv(cv); 2424 2384 call.type(ty); 2425 2385 2426 2386 if (Call* deprecated = fi->ann().getCall(constants().ann.mzn_deprecated)) { ··· 2476 2436 isVar |= li->type().isvar(); 2477 2437 } 2478 2438 Type ty = let.in()->type(); 2479 - ty.cv(cv || ty.cv()); 2439 + ty.cv(cv); 2480 2440 if (isVar && ty.bt() == Type::BT_BOOL && ty.dim() == 0) { 2481 2441 ty.ti(Type::TI_VAR); 2482 2442 } ··· 2952 2912 _bottomUpTyper.run(i->e()); 2953 2913 if (i->e() != nullptr) { 2954 2914 Type et = i->e()->type(); 2955 - if (et.isbool()) { 2956 - Type target_t = Type::varint(); 2957 - if (et.isOpt()) { 2958 - target_t.ot(Type::OT_OPTIONAL); 2959 - } 2960 - i->e(add_coercion(_env, _env.model, i->e(), target_t)()); 2961 - } 2962 2915 2963 2916 bool needOptCoercion = et.isOpt() && et.isint(); 2964 2917 if (needOptCoercion) { ··· 3180 3133 } while (didRemove); 3181 3134 3182 3135 // Create par versions of remaining functions 3183 - if (!fnsToMakePar.empty()) { 3136 + { 3184 3137 // First step: copy and register functions 3185 3138 std::vector<FunctionI*> parFunctions; 3186 3139 CopyMap parCopyMap; 3187 - // Step 1a: enter all global declarations into copy map 3188 - class EnterGlobalDecls : public EVisitor { 3189 - public: 3190 - CopyMap& cm; 3191 - EnterGlobalDecls(CopyMap& cm0) : cm(cm0) {} 3192 - void vId(Id& ident) { 3193 - if (ident.decl() != nullptr && ident.decl()->toplevel()) { 3194 - cm.insert(ident.decl(), ident.decl()); 3195 - } 3196 - } 3197 - } _egd(parCopyMap); 3198 - for (auto& p : fnsToMakePar) { 3199 - if (!p.second.first) { 3200 - for (auto* param : p.first->params()) { 3201 - top_down(_egd, param); 3202 - } 3203 - for (ExpressionSetIter i = p.first->ann().begin(); i != p.first->ann().end(); ++i) { 3204 - top_down(_egd, *i); 3205 - } 3206 - top_down(_egd, p.first->e()); 3207 - } 3208 - } 3209 - 3210 - // Step 1b: copy functions 3211 3140 for (auto& p : fnsToMakePar) { 3212 3141 if (!p.second.first) { 3213 3142 GCLock lock; ··· 3574 3503 os << ",\n \"method\": \""; 3575 3504 os << _ifc.method; 3576 3505 os << "\""; 3577 - os << ",\n \"has_output_item\": " << (_ifc.outputItem ? "true" : "false"); 3506 + os << ",\n \"has_outputItem\": " << (_ifc.outputItem ? "true" : "false"); 3578 3507 os << ",\n \"included_files\": [\n" << _ifc.ossIncludedFiles.str() << "\n ]"; 3579 3508 os << "\n}\n"; 3580 3509 }
+2 -4
share/minizinc/Preferences.json
··· 5 5 "solverDefaults" : [ 6 6 ["org.minizinc.mip.gurobi", "-DQuadrIntSolverConfig=true", ""], 7 7 ["org.minizinc.mip.gurobi", "-DQuadrFloatSolverConfig=true", ""], 8 - ["org.minizinc.mip.scip", "-DQuadrIntSolverConfig=true", ""], 9 - ["org.minizinc.mip.scip", "-DQuadrFloatSolverConfig=true", ""], 10 8 ["org.minizinc.mip.scip", "-DCumulativeSolverConfig=true", ""], 11 - ["org.minizinc.mip.scip", "-DOrbisackSolverConfig=true", ""], 12 - ["org.minizinc.mip.scip", "-DOrbitopeSolverConfig=true", ""] 9 + ["org.minizinc.mip.scip", "-DQuadrIntSolverConfig=true", ""], 10 + ["org.minizinc.mip.scip", "-DQuadrFloatSolverConfig=true", ""] 13 11 ] 14 12 }
-4
share/minizinc/linear/fzn_lex_chain_lesseq_bool.mzn
··· 1 - include "fzn_lex_chain_lesseq_int.mzn"; 2 - 3 - predicate fzn_lex_chain_lesseq_bool(array[int, int] of var bool: a) = 4 - fzn_lex_chain_lesseq_int(a);
-23
share/minizinc/linear/fzn_lex_chain_lesseq_int.mzn
··· 1 - include "lex_lesseq.mzn"; 2 - include "fzn_lex_chain_lesseq_orbitope.mzn"; 3 - 4 - predicate fzn_lex_chain_lesseq_int(array[int, int] of var int: a) = 5 - if MZN__Orbitope /\ dom_array(a) subset 0..1 then 6 - fzn_lex_chain_lesseq__orbitope( a, 7 - card(index_set_1of2(a)), 0, true, 8 - not mzn_in_symmetry_breaking_constraint() 9 - ) 10 - else 11 - fzn_lex_chain_lesseq_int__CP(a) 12 - endif; 13 - 14 - 15 - predicate fzn_lex_chain_lesseq_int__CP(array[int, int] of var int: a) = 16 - let { 17 - int: lb2 = min(index_set_2of2(a)), 18 - int: ub2 = max(index_set_2of2(a)) 19 - } in ( 20 - forall(j in lb2 + 1 .. ub2) ( 21 - lex_lesseq(col(a, j-1), col(a, j)) 22 - ) 23 - );
-40
share/minizinc/linear/fzn_lex_chain_lesseq_orbitope.mzn
··· 1 - include "lex_lesseq.mzn"; 2 - 3 - predicate fzn_lex_chain_lesseq_orbitope( 4 - array[int, int] of var int: a, int: kind) = 5 - if MZN__Orbitope then 6 - fzn_lex_chain_lesseq__orbitope( a, 7 - card(index_set_1of2(a)), kind, true, 8 - not mzn_in_symmetry_breaking_constraint() 9 - ) 10 - else 11 - fzn_lex_chain_lesseq_orbitope__CP(a, kind) 12 - endif; 13 - 14 - 15 - %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SCIP 7.0.2, binary matrix, columns sorted 16 - predicate fzn_lex_chain_lesseq__orbitope(array[int, int] of var int: matr, 17 - int: m, int: orbType, bool: resolveprop, bool: isModelCons); 18 - 19 - 20 - predicate fzn_lex_chain_lesseq_orbitope__CP( 21 - array[int, int] of var int: a, int: kind) = 22 - let { 23 - int: lb2 = min(index_set_2of2(a)), 24 - int: ub2 = max(index_set_2of2(a)) 25 - } in ( 26 - forall(j in lb2 + 1 .. ub2) ( 27 - lex_lesseq(col(a, j-1), col(a, j)) 28 - ) 29 - /\ 30 - if 1==kind then 31 - forall(i in index_set_1of2(a))( 32 - 1 == sum(row(a, i)) 33 - ) 34 - elseif 2==kind then 35 - forall(i in index_set_1of2(a))( 36 - 1 >= sum(row(a, i)) 37 - ) 38 - else true 39 - endif 40 - );
-12
share/minizinc/linear/fzn_lex_less_bool.mzn
··· 1 - %-----------------------------------------------------------------------------% 2 - % Requires that the array 'x' is strictly lexicographically less than 3 - % array 'y'. Compares them from first to last element, regardless of indices 4 - %-----------------------------------------------------------------------------% 5 - 6 - include "fzn_lex_less_int.mzn"; 7 - 8 - predicate fzn_lex_less_bool(array[int] of var bool: x, 9 - array[int] of var bool: y) = 10 - fzn_lex_less_int(x, y); 11 - 12 - %-----------------------------------------------------------------------------%
+21
share/minizinc/linear/fzn_lex_less_bool_reif.mzn
··· 1 + include "../std/fzn_lex_less_bool_reif.mzn"; 2 + 3 + predicate fzn_lex_less_bool_imp(array[int] of var bool: x, 4 + array[int] of var bool: y, 5 + var bool: c) = 6 + let { int: lx = min(index_set(x)), 7 + int: ux = max(index_set(x)), 8 + int: ly = min(index_set(y)), 9 + int: uy = max(index_set(y)), 10 + int: size = max(ux - lx, uy - ly), 11 + array[0..size+1] of var bool: b } 12 + in 13 + (c -> b[0]) 14 + /\ 15 + forall(i in 0..size) ( 16 + b[i] = ( x[lx + i] <= y[ly + i] 17 + /\ 18 + (x[lx + i] < y[ly + i] \/ b[i+1]) ) 19 + ) 20 + /\ 21 + b[size + 1] = (ux - lx < uy - ly);
-38
share/minizinc/linear/fzn_lex_less_float.mzn
··· 1 - %-----------------------------------------------------------------------------% 2 - % Requires that the array 'x' is strictly lexicographically less than 3 - % array 'y'. Compares them from first to last element, regardless of indices 4 - %-----------------------------------------------------------------------------% 5 - 6 - predicate fzn_lex_less_float(array[int] of var float: x, 7 - array[int] of var float: y) = 8 - assert(length(x) == length(y), 9 - "lex_less_float(\(x), \(y)): arrays of different lengths") 10 - /\ 11 - fzn_lex_less_float__MIP(x, y); 12 - 13 - predicate fzn_lex_less_float__MIP(array[int] of var float: x, 14 - array[int] of var float: y) = 15 - let { int: lx = min(index_set(x)), 16 - int: ux = max(index_set(x)), 17 - int: ly = min(index_set(y)), 18 - int: uy = max(index_set(y)), 19 - int: size = min(ux - lx, uy - ly), 20 - array[0..size] of var 0..1: fEQ; 21 - array[0..size] of var 0..1: fLT; 22 - } in 23 - sum(fLT) == 1 24 - /\ 25 - fEQ[0] + fLT[0] == 1 26 - /\ 27 - forall(i in 1..size) ( 28 - fEQ[i-1] == fEQ[i] + fLT[i] 29 - ) 30 - /\ 31 - forall(i in 0..size) ( 32 - aux_float_eq_if_1(x[lx+i], y[ly+i], fEQ[i]) 33 - /\ 34 - aux_float_lt_if_1(x[lx+i], y[ly+i], fLT[i]) 35 - ) 36 - ; 37 - 38 - %-----------------------------------------------------------------------------%
-39
share/minizinc/linear/fzn_lex_less_int.mzn
··· 1 - %-----------------------------------------------------------------------------% 2 - % Requires that the array 'x' is strictly lexicographically less than array 'y'. 3 - % Compares them from first to last element, regardless of indices 4 - %-----------------------------------------------------------------------------% 5 - 6 - predicate fzn_lex_less_int(array[int] of var int: x, 7 - array[int] of var int: y) = 8 - assert(length(x) == length(y), 9 - "lex_less_int(\(x), \(y)): arrays of different lengths") 10 - /\ 11 - fzn_lex_less_int__MIP(x, y) 12 - ; 13 - 14 - predicate fzn_lex_less_int__MIP(array[int] of var int: x, 15 - array[int] of var int: y) = 16 - let { int: lx = min(index_set(x)), 17 - int: ux = max(index_set(x)), 18 - int: ly = min(index_set(y)), 19 - int: uy = max(index_set(y)), 20 - int: size = min(ux - lx, uy - ly), 21 - array[0..size] of var 0..1: fEQ; 22 - array[0..size] of var 0..1: fLT; 23 - } in 24 - sum(fLT) == 1 25 - /\ 26 - fEQ[0] + fLT[0] == 1 27 - /\ 28 - forall(i in 1..size) ( 29 - fEQ[i-1] == fEQ[i] + fLT[i] 30 - ) 31 - /\ 32 - forall(i in 0..size) ( 33 - aux_int_eq_if_1(x[lx+i], y[ly+i], fEQ[i]) 34 - /\ 35 - aux_int_lt_if_1(x[lx+i], y[ly+i], fLT[i]) 36 - ) 37 - ; 38 - 39 - %-----------------------------------------------------------------------------%
+40 -3
share/minizinc/linear/fzn_lex_lesseq_bool.mzn
··· 3 3 % array 'y'. Compares them from first to last element, regardless of indices 4 4 %-----------------------------------------------------------------------------% 5 5 6 - include "fzn_lex_lesseq_int.mzn"; 7 - 8 6 predicate fzn_lex_lesseq_bool(array[int] of var bool: x, 9 7 array[int] of var bool: y) = 10 - fzn_lex_lesseq_int(x, y); 8 + % if (min(card(index_set(x)), card(index_set(y))) <= 25) then 9 + % let { int: size = min(card(index_set(x)), card(index_set(y))); 10 + % } in 11 + % sum(i in 0..size-1)(pow(2, (size-1-i)) * bool2int(x[i+min(index_set(x))])) 12 + % <= sum(i in 0..size-1)(pow(2, (size-1-i)) * bool2int(y[i+min(index_set(y))])) 13 + % else 14 + % my_trace ("lex_lesseq_bool(\(x), \(y))") /\ 15 + let { int: lx = min(index_set(x)), 16 + int: ux = max(index_set(x)), 17 + int: ly = min(index_set(y)), 18 + int: uy = max(index_set(y)), 19 + int: size = min(ux - lx, uy - ly), 20 + array[0..size+1] of var bool: b } 21 + % b[i] is true if the lexicographical order holds from position i on. 22 + in 23 + b[0] 24 + /\ 25 + forall(i in 0..size) ( 26 + b[i] -> ( ( ( x[lx + i] <= y[ly + i] ) ) /\ 27 + % bool2int(b[i]) + bool2int(x[lx + i]) + (1-bool2int(y[ly + i])) <= 2 /\ 28 + 29 + % ( b[i] -> 30 + ( x[lx + i] < y[ly + i] \/ b[i+1] ) ) 31 + % /\ ( bool2int(b[i]) <= bool2int(x[lx + i] < y[ly + i]) + bool2int(b[i+1]) ) /\ 32 + % bool2int(b[i]) + (1-bool2int(x[lx + i])) + (1-bool2int(y[ly + i])) + (1-bool2int(b[i+1])) <= 3 33 + % /\ bool2int(b[i]) + bool2int(x[lx + i]) + bool2int(y[ly + i]) + (1-bool2int(b[i+1])) <= 3 34 + %% This guy is dominated by the 1st one above but helps: 35 + % /\ bool2int(b[i]) + bool2int(x[lx + i]) + (1-bool2int(y[ly + i])) + (1-bool2int(b[i+1])) <= 3 36 + ) 37 + /\ b[size+1] = (ux-lx <= uy-ly) 38 + % endif 39 + ; 40 + 41 + % forall(i in 0..size) ( 42 + % ( b[i] == ( x[lx + i] <= y[ly + i] ) ) 43 + % /\ 44 + % if i < size then 45 + % ( b[i] == ( x[lx + i] < y[ly + i] \/ b[i+1] 46 + % ) ) else true endif 47 + % ); 11 48 12 49 %-----------------------------------------------------------------------------%
+50
share/minizinc/linear/fzn_lex_lesseq_bool_reif.mzn
··· 1 + predicate fzn_lex_lesseq_bool_reif(array[int] of var bool: x, 2 + array[int] of var bool: y, 3 + var bool: c) = 4 + let { int: lx = min(index_set(x)), 5 + int: ux = max(index_set(x)), 6 + int: ly = min(index_set(y)), 7 + int: uy = max(index_set(y)), 8 + int: size = max(ux - lx, uy - ly), 9 + array[0..size+1] of var bool: b } 10 + % b[i] is true if the lexicographical order holds from position i on. 11 + in 12 + (c <-> b[0]) 13 + /\ 14 + forall(i in 0..size) ( 15 + ( b[i] -> ( x[lx + i] <= y[ly + i] ) ) /\ 16 + bool2int(b[i]) + bool2int(x[lx + i]) + (1-bool2int(y[ly + i])) <= 2 17 + /\ 18 + ( b[i] -> ( x[lx + i] < y[ly + i] \/ b[i+1] ) ) /\ 19 + bool2int(b[i]) + (1-bool2int(x[lx + i])) + (1-bool2int(y[ly + i])) + (1-bool2int(b[i+1])) <= 3 20 + /\ bool2int(b[i]) + bool2int(x[lx + i]) + bool2int(y[ly + i]) + (1-bool2int(b[i+1])) <= 3 21 + /\ bool2int(b[i]) + bool2int(x[lx + i]) + (1-bool2int(y[ly + i])) + (1-bool2int(b[i+1])) <= 3 22 + ) 23 + /\ b[size+1] = (ux-lx <= uy-ly) 24 + % endif 25 + ; 26 + 27 + predicate fzn_lex_lesseq_bool_imp(array[int] of var bool: x, 28 + array[int] of var bool: y, 29 + var bool: c) = 30 + let { int: lx = min(index_set(x)), 31 + int: ux = max(index_set(x)), 32 + int: ly = min(index_set(y)), 33 + int: uy = max(index_set(y)), 34 + int: size = max(ux - lx, uy - ly), 35 + array[0..size+1] of var bool: b } 36 + % b[i] is true if the lexicographical order holds from position i on. 37 + in 38 + (c -> b[0]) 39 + /\ 40 + forall(i in 0..size) ( 41 + ( b[i] -> ( x[lx + i] <= y[ly + i] ) ) /\ 42 + bool2int(b[i]) + bool2int(x[lx + i]) + (1-bool2int(y[ly + i])) <= 2 43 + /\ 44 + ( b[i] -> ( x[lx + i] < y[ly + i] \/ b[i+1] ) ) /\ 45 + bool2int(b[i]) + (1-bool2int(x[lx + i])) + (1-bool2int(y[ly + i])) + (1-bool2int(b[i+1])) <= 3 46 + /\ bool2int(b[i]) + bool2int(x[lx + i]) + bool2int(y[ly + i]) + (1-bool2int(b[i+1])) <= 3 47 + /\ bool2int(b[i]) + bool2int(x[lx + i]) + (1-bool2int(y[ly + i])) + (1-bool2int(b[i+1])) <= 3 48 + ) 49 + /\ b[size+1] = (ux-lx <= uy-ly) 50 + ;
-38
share/minizinc/linear/fzn_lex_lesseq_float.mzn
··· 1 - %-----------------------------------------------------------------------------% 2 - % Requires that the array 'x' is lexicographically less than or equal to 3 - % array 'y'. Compares them from first to last element, regardless of indices 4 - %-----------------------------------------------------------------------------% 5 - 6 - predicate fzn_lex_lesseq_float(array[int] of var float: x, 7 - array[int] of var float: y) = 8 - assert(length(x) == length(y), %% SCIP cannot 9 - "lex_lesseq_float(\(x), \(y)): arrays of different lengths") 10 - /\ 11 - fzn_lex_lesseq_float__MIP(x, y); 12 - 13 - predicate fzn_lex_lesseq_float__MIP(array[int] of var float: x, 14 - array[int] of var float: y) = 15 - let { int: lx = min(index_set(x)), 16 - int: ux = max(index_set(x)), 17 - int: ly = min(index_set(y)), 18 - int: uy = max(index_set(y)), 19 - int: size = min(ux - lx, uy - ly), 20 - array[0..size] of var 0..1: fEQ; 21 - array[0..size] of var 0..1: fLT; 22 - } in 23 - sum(fLT) <= 1 24 - /\ 25 - fEQ[0] + fLT[0] == 1 26 - /\ 27 - forall(i in 1..size) ( 28 - fEQ[i-1] == fEQ[i] + fLT[i] 29 - ) 30 - /\ 31 - forall(i in 0..size) ( 32 - aux_float_eq_if_1(x[lx+i], y[ly+i], fEQ[i]) 33 - /\ 34 - aux_float_lt_if_1(x[lx+i], y[ly+i], fLT[i]) 35 - ) 36 - ; 37 - 38 - %-----------------------------------------------------------------------------%
-77
share/minizinc/linear/fzn_lex_lesseq_int.mzn
··· 1 - %-----------------------------------------------------------------------------% 2 - % Requires that the array 'x' is lexicographically less than or equal to 3 - % array 'y'. Compares them from first to last element, regardless of indices 4 - %-----------------------------------------------------------------------------% 5 - 6 - opt bool: UseCPLexLesseq; %% When not UseOrbisack, use CP decomposition 7 - opt bool: OrbisackAlwaysModelConstraint; %% Use with SCIP 7.0.2 8 - 9 - predicate fzn_lex_lesseq_int(array[int] of var int: x, 10 - array[int] of var int: y) = 11 - assert(length(x) == length(y), %% SCIP cannot 12 - "lex_lesseq_int(\(x), \(y)): arrays of different lengths") 13 - /\ 14 - if MZN__Orbisack /\ 15 - dom_array(x) subset 0..1 /\ dom_array(y) subset 0..1 then 16 - fzn_lex_lesseq__orbisack(x, y, 17 - ( occurs(OrbisackAlwaysModelConstraint) /\ 18 - deopt(OrbisackAlwaysModelConstraint) ) \/ 19 - not mzn_in_symmetry_breaking_constraint()) 20 - elseif occurs(UseCPLexLesseq) /\ deopt(UseCPLexLesseq) then 21 - fzn_lex_lesseq_int__CP(x, y) 22 - else 23 - fzn_lex_lesseq_int__MIP(x, y) 24 - endif; 25 - 26 - predicate fzn_lex_lesseq_int__CP(array[int] of var int: x, 27 - array[int] of var int: y) = 28 - let { int: lx = min(index_set(x)), 29 - int: ux = max(index_set(x)), 30 - int: ly = min(index_set(y)), 31 - int: uy = max(index_set(y)), 32 - int: size = min(ux - lx, uy - ly), 33 - array[0..size+1] of var bool: b } 34 - % b[i] is true if the lexicographical order holds from position i on. 35 - in 36 - b[0] 37 - /\ 38 - forall(i in 0..size) ( 39 - b[i] = ( x[lx + i] <= y[ly + i] 40 - /\ 41 - (x[lx + i] < y[ly + i] \/ b[i+1]) 42 - ) 43 - ) 44 - /\ 45 - b[size + 1] = (ux - lx <= uy - ly) 46 - ; 47 - 48 - predicate fzn_lex_lesseq_int__MIP(array[int] of var int: x, 49 - array[int] of var int: y) = 50 - let { int: lx = min(index_set(x)), 51 - int: ux = max(index_set(x)), 52 - int: ly = min(index_set(y)), 53 - int: uy = max(index_set(y)), 54 - int: size = min(ux - lx, uy - ly), 55 - array[0..size] of var 0..1: fEQ; 56 - array[0..size] of var 0..1: fLT; 57 - } in 58 - sum(fLT) <= 1 59 - /\ 60 - fEQ[0] + fLT[0] == 1 61 - /\ 62 - forall(i in 1..size) ( 63 - fEQ[i-1] == fEQ[i] + fLT[i] 64 - ) 65 - /\ 66 - forall(i in 0..size) ( 67 - aux_int_eq_if_1(x[lx+i], y[ly+i], fEQ[i]) 68 - /\ 69 - aux_int_lt_if_1(x[lx+i], y[ly+i], fLT[i]) 70 - ) 71 - ; 72 - 73 - %% SCIP constraint handler orbisack 74 - predicate fzn_lex_lesseq__orbisack( 75 - array[int] of var int: vec1, array[int] of var int: vec2, bool: isModelCons); 76 - 77 - %-----------------------------------------------------------------------------%
+2 -16
share/minizinc/linear/options.mzn
··· 40 40 41 41 %% CUMULATIVE 42 42 opt bool: CumulativeSolverConfig; %% As set in share/minizinc/Preferences.json 43 - opt bool: UseCumulative; %% User option, e.g., with -D 44 - bool: MZN__Cumulative_Fixed_d_r = if occurs(UseCumulative) then deopt(UseCumulative) 43 + opt bool: Cumulative; %% User option, e.g., with -D 44 + bool: MZN__Cumulative_Fixed_d_r = if occurs(Cumulative) then deopt(Cumulative) 45 45 elseif occurs(CumulativeSolverConfig) then deopt(CumulativeSolverConfig) 46 - else false endif; 47 - 48 - %% ORBISACK 49 - opt bool: OrbisackSolverConfig; %% As set in share/minizinc/Preferences.json 50 - opt bool: UseOrbisack; %% User option, e.g., with -D 51 - bool: MZN__Orbisack = if occurs(UseOrbisack) then deopt(UseOrbisack) 52 - elseif occurs(OrbisackSolverConfig) then deopt(OrbisackSolverConfig) 53 - else false endif; 54 - 55 - %% ORBITOPE 56 - opt bool: OrbitopeSolverConfig; %% As set in share/minizinc/Preferences.json 57 - opt bool: UseOrbitope; %% User option, e.g., with -D 58 - bool: MZN__Orbitope = if occurs(UseOrbitope) then deopt(UseOrbitope) 59 - elseif occurs(OrbitopeSolverConfig) then deopt(OrbitopeSolverConfig) 60 46 else false endif; 61 47 62 48
+17 -6
share/minizinc/std/fzn_lex2.mzn
··· 1 - include "lex_chain_lesseq.mzn"; 1 + include "lex_lesseq.mzn"; 2 2 3 3 predicate fzn_lex2(array[int, int] of var int: x) = 4 - lex_chain_lesseq(x) 5 - /\ 6 - lex_chain_lesseq( %% transpose 7 - array2d(index_set_2of2(x), index_set_1of2(x), 8 - [x[i, j] | j in index_set_2of2(x), i in index_set_1of2(x)] 4 + let { 5 + int: lbx1 = min(index_set_1of2(x)), 6 + int: ubx1 = max(index_set_1of2(x)), 7 + int: lbx2 = min(index_set_2of2(x)), 8 + int: ubx2 = max(index_set_2of2(x)) 9 + } in ( 10 + forall(i in lbx1 + 1 .. ubx1) ( 11 + lex_lesseq([x[i - 1, j] | j in index_set_2of2(x)], 12 + [x[i, j] | j in index_set_2of2(x)] 13 + ) 14 + ) 15 + /\ 16 + forall(j in lbx2 + 1 .. ubx2) ( 17 + lex_lesseq([x[i, j - 1] | i in index_set_1of2(x)], 18 + [x[i, j ] | i in index_set_1of2(x)] 19 + ) 9 20 ) 10 21 );
+14 -5
share/minizinc/std/fzn_lex2_reif.mzn
··· 1 1 include "lex_lesseq.mzn"; 2 2 3 3 predicate fzn_lex2_reif(array[int, int] of var int: x, var bool: b) = 4 - b <-> ( 5 - lex_chain_lesseq(x) 4 + let { 5 + int: lbx1 = min(index_set_1of2(x)), 6 + int: ubx1 = max(index_set_1of2(x)), 7 + int: lbx2 = min(index_set_2of2(x)), 8 + int: ubx2 = max(index_set_2of2(x)) 9 + } in b <-> ( 10 + forall(i in lbx1 + 1 .. ubx1) ( 11 + lex_lesseq([x[i - 1, j] | j in index_set_2of2(x)], 12 + [x[i, j] | j in index_set_2of2(x)] 13 + ) 14 + ) 6 15 /\ 7 - lex_chain_lesseq( %% transpose 8 - array2d(index_set_2of2(x), index_set_1of2(x), 9 - [x[i, j] | j in index_set_2of2(x), i in index_set_1of2(x)] 16 + forall(j in lbx2 + 1 .. ubx2) ( 17 + lex_lesseq([x[i, j - 1] | i in index_set_1of2(x)], 18 + [x[i, j ] | i in index_set_1of2(x)] 10 19 ) 11 20 ) 12 21 );
-11
share/minizinc/std/fzn_lex_chain_less_bool.mzn
··· 1 - include "lex_less.mzn"; 2 - 3 - predicate fzn_lex_chain_less_bool(array[int, int] of var bool: a) = 4 - let { 5 - int: lb2 = min(index_set_2of2(a)), 6 - int: ub2 = max(index_set_2of2(a)) 7 - } in ( 8 - forall(j in lb2 + 1 .. ub2) ( 9 - lex_less(col(a, j-1), col(a, j)) 10 - ) 11 - );
-12
share/minizinc/std/fzn_lex_chain_less_bool_reif.mzn
··· 1 - include "lex_less.mzn"; 2 - 3 - predicate fzn_lex_chain_less_bool_reif( 4 - array[int, int] of var bool: a, var bool: b) = 5 - let { 6 - int: lb2 = min(index_set_2of2(a)), 7 - int: ub2 = max(index_set_2of2(a)) 8 - } in b <-> ( 9 - forall(j in lb2 + 1 .. ub2) ( 10 - lex_less(col(a, j-1), col(a, j)) 11 - ) 12 - );
-11
share/minizinc/std/fzn_lex_chain_less_int.mzn
··· 1 - include "lex_less.mzn"; 2 - 3 - predicate fzn_lex_chain_less_int(array[int, int] of var int: a) = 4 - let { 5 - int: lb2 = min(index_set_2of2(a)), 6 - int: ub2 = max(index_set_2of2(a)) 7 - } in ( 8 - forall(j in lb2 + 1 .. ub2) ( 9 - lex_less(col(a, j-1), col(a, j)) 10 - ) 11 - );
-12
share/minizinc/std/fzn_lex_chain_less_int_reif.mzn
··· 1 - include "lex_less.mzn"; 2 - 3 - predicate fzn_lex_chain_less_int_reif( 4 - array[int, int] of var int: a, var bool: b) = 5 - let { 6 - int: lb2 = min(index_set_2of2(a)), 7 - int: ub2 = max(index_set_2of2(a)) 8 - } in b <-> ( 9 - forall(j in lb2 + 1 .. ub2) ( 10 - lex_less(col(a, j-1), col(a, j)) 11 - ) 12 - );
-11
share/minizinc/std/fzn_lex_chain_lesseq_bool.mzn
··· 1 - include "lex_lesseq.mzn"; 2 - 3 - predicate fzn_lex_chain_lesseq_bool(array[int, int] of var bool: a) = 4 - let { 5 - int: lb2 = min(index_set_2of2(a)), 6 - int: ub2 = max(index_set_2of2(a)) 7 - } in ( 8 - forall(j in lb2 + 1 .. ub2) ( 9 - lex_lesseq(col(a, j-1), col(a, j)) 10 - ) 11 - );
-12
share/minizinc/std/fzn_lex_chain_lesseq_bool_reif.mzn
··· 1 - include "lex_lesseq.mzn"; 2 - 3 - predicate fzn_lex_chain_lesseq_bool_reif( 4 - array[int, int] of var bool: a, var bool: b) = 5 - let { 6 - int: lb2 = min(index_set_2of2(a)), 7 - int: ub2 = max(index_set_2of2(a)) 8 - } in b <-> ( 9 - forall(j in lb2 + 1 .. ub2) ( 10 - lex_lesseq(col(a, j-1), col(a, j)) 11 - ) 12 - );
-11
share/minizinc/std/fzn_lex_chain_lesseq_int.mzn
··· 1 - include "lex_lesseq.mzn"; 2 - 3 - predicate fzn_lex_chain_lesseq_int(array[int, int] of var int: a) = 4 - let { 5 - int: lb2 = min(index_set_2of2(a)), 6 - int: ub2 = max(index_set_2of2(a)) 7 - } in ( 8 - forall(j in lb2 + 1 .. ub2) ( 9 - lex_lesseq(col(a, j-1), col(a, j)) 10 - ) 11 - );
-12
share/minizinc/std/fzn_lex_chain_lesseq_int_reif.mzn
··· 1 - include "lex_lesseq.mzn"; 2 - 3 - predicate fzn_lex_chain_lesseq_int_reif( 4 - array[int, int] of var int: a, var bool: b) = 5 - let { 6 - int: lb2 = min(index_set_2of2(a)), 7 - int: ub2 = max(index_set_2of2(a)) 8 - } in b <-> ( 9 - forall(j in lb2 + 1 .. ub2) ( 10 - lex_lesseq(col(a, j-1), col(a, j)) 11 - ) 12 - );
-23
share/minizinc/std/fzn_lex_chain_lesseq_orbitope.mzn
··· 1 - include "lex_lesseq.mzn"; 2 - 3 - predicate fzn_lex_chain_lesseq_orbitope( 4 - array[int, int] of var int: a, int: kind) = 5 - let { 6 - int: lb2 = min(index_set_2of2(a)), 7 - int: ub2 = max(index_set_2of2(a)) 8 - } in ( 9 - forall(j in lb2 + 1 .. ub2) ( 10 - lex_lesseq(col(a, j-1), col(a, j)) 11 - ) 12 - /\ 13 - if 1==kind then 14 - forall(i in index_set_1of2(a))( 15 - 1 == sum(row(a, i)) 16 - ) 17 - elseif 2==kind then 18 - forall(i in index_set_1of2(a))( 19 - 1 >= sum(row(a, i)) 20 - ) 21 - else true 22 - endif 23 - );
-23
share/minizinc/std/fzn_lex_chain_lesseq_orbitope_reif.mzn
··· 1 - include "lex_lesseq.mzn"; 2 - 3 - predicate fzn_lex_chain_lesseq_orbitope_reif( 4 - array[int, int] of var int: a, int: kind, var bool: b) = 5 - let { 6 - int: lb2 = min(index_set_2of2(a)), 7 - int: ub2 = max(index_set_2of2(a)) 8 - } in b <-> ( 9 - forall(j in lb2 + 1 .. ub2) ( 10 - lex_lesseq(col(a, j-1), col(a, j)) 11 - ) 12 - /\ 13 - if 1==kind then 14 - forall(i in index_set_1of2(a))( 15 - 1 == sum(row(a, i)) 16 - ) 17 - elseif 2==kind then 18 - forall(i in index_set_1of2(a))( 19 - 1 >= sum(row(a, i)) 20 - ) 21 - else true 22 - endif 23 - );
+3 -4
share/minizinc/std/fzn_piecewise_linear.mzn
··· 1 1 /* 2 2 * Function fzn_piecewise_linear_base creates 3 - * auxiliary variables for the interval representation of xi 4 - * and constrains them to correspond to the value of x. 5 - * The auxiliaries are reusable if we have several pwls 6 - * on the same set of breakpoints and x. 3 + * interval representation of x, 4 + * which is reusable if we have several pwls 5 + * on the same set of breakpoints 7 6 */ 8 7 function array[int, int] of var 0.0..1.0: fzn_piecewise_linear_base( 9 8 var float: x, array[int] of float: xi) ::promise_total =
-37
share/minizinc/std/fzn_piecewise_linear_non_continuous.mzn
··· 1 - /* 2 - * Function fzn_piecewise_linear_base creates 3 - * auxiliary variables for the intervals {x_start[i]..x_end[i]}, 4 - * and constrains them to correspond to the value of x. 5 - * The auxiliaries are reusable if we have several pwls 6 - * on the same set of intervals and x. 7 - */ 8 - function array[int, int] of var 0.0..1.0: fzn_piecewise_linear_base(var float: x, 9 - array[int] of float: x_start, array[int] of float: x_end) ::promise_total = 10 - let { 11 - set of int: is = index_set(x_start), 12 - array[is] of var 0.0..1.0: s, %% Segment variables 13 - array[is] of var 0..1: f, 14 - constraint 1 == sum(f), 15 - constraint forall(i in is)( 16 - if x_start[i] < x_end[i] then f[i] >= s[i] 17 - elseif x_start[i] == x_end[i] then s[i] == 0.0 18 - else abort("piecewise linear discontinuous: interval \(i): x_end < x_start") endif), 19 - constraint x == sum(i in is)(x_start[i] * f[i] + (x_end[i]-x_start[i]) * s[i]), 20 - } in 21 - array2d(1..2, is, f++s); 22 - 23 - 24 - predicate fzn_piecewise_linear(var float: x, var float: y, 25 - array[int] of float: x_start, array[int] of float: x_end, 26 - array[int] of float: v_start, array[int] of float: v_end) = 27 - let { 28 - set of int: is = index_set(x_start), 29 - constraint assert(is == index_set(v_start) 30 - /\ is == index_set(v_end) /\ is == index_set(x_end) /\ 0<card(is) , 31 - "fzn_pwl: index sets unequal or empty"), 32 - 33 - array[int, int] of var float: fs = fzn_piecewise_linear_base(x, x_start,x_end), 34 - } in 35 - y == sum(i in is)(v_start[i] * fs[1, i] + (v_end[i]-v_start[i]) * fs[2, i]); 36 - 37 - %-----------------------------------------------------------------------------%
-7
share/minizinc/std/fzn_piecewise_linear_non_continuous_reif.mzn
··· 1 - predicate fzn_piecewise_linear_reif(var float: x, var float: y, 2 - array[int] of float: xi1, array[int] of float: xi2, 3 - array[int] of float: vi1, array[int] of float: vi2, 4 - var bool: b) = 5 - abort("Reified piecewise_linear (non_continuous) constraint is not supported"); 6 - 7 - %-----------------------------------------------------------------------------%
+18 -6
share/minizinc/std/fzn_strict_lex2.mzn
··· 1 - include "lex_chain_less.mzn"; 1 + include "lex_less.mzn"; 2 2 3 3 predicate fzn_strict_lex2(array[int, int] of var int: x) = 4 - lex_chain_less(x) 5 - /\ 6 - lex_chain_less( %% transpose 7 - array2d(index_set_2of2(x), index_set_1of2(x), 8 - [x[i, j] | j in index_set_2of2(x), i in index_set_1of2(x)] 4 + let { 5 + int: lbx1 = min(index_set_1of2(x)), 6 + int: ubx1 = max(index_set_1of2(x)), 7 + int: lbx2 = min(index_set_2of2(x)), 8 + int: ubx2 = max(index_set_2of2(x)) 9 + } in ( 10 + forall(i in lbx1 + 1 .. ubx1) ( 11 + lex_less([x[i - 1, j] | j in index_set_2of2(x)], 12 + [x[i, j] | j in index_set_2of2(x)] 13 + ) 14 + ) 15 + /\ 16 + 17 + forall(j in lbx2 + 1 .. ubx2) ( 18 + lex_less([x[i, j - 1] | i in index_set_1of2(x)], 19 + [x[i, j ] | i in index_set_1of2(x)] 20 + ) 9 21 ) 10 22 );
+16 -6
share/minizinc/std/fzn_strict_lex2_reif.mzn
··· 1 - include "lex_chain_less.mzn"; 1 + include "lex_less.mzn"; 2 2 3 3 predicate fzn_strict_lex2_reif(array[int, int] of var int: x, var bool: b) = 4 - b <-> ( 5 - lex_chain_less(x) 4 + let { 5 + int: lbx1 = min(index_set_1of2(x)), 6 + int: ubx1 = max(index_set_1of2(x)), 7 + int: lbx2 = min(index_set_2of2(x)), 8 + int: ubx2 = max(index_set_2of2(x)) 9 + } in b <-> ( 10 + forall(i in lbx1 + 1 .. ubx1) ( 11 + lex_less([x[i - 1, j] | j in index_set_2of2(x)], 12 + [x[i, j] | j in index_set_2of2(x)] 13 + ) 14 + ) 6 15 /\ 7 - lex_chain_less( %% transpose 8 - array2d(index_set_2of2(x), index_set_1of2(x), 9 - [x[i, j] | j in index_set_2of2(x), i in index_set_1of2(x)] 16 + 17 + forall(j in lbx2 + 1 .. ubx2) ( 18 + lex_less([x[i, j - 1] | i in index_set_1of2(x)], 19 + [x[i, j ] | i in index_set_1of2(x)] 10 20 ) 11 21 ) 12 22 );
-8
share/minizinc/std/fzn_strictly_decreasing_int_opt.mzn
··· 1 - include "fzn_strictly_increasing_int_opt.mzn"; 2 - 3 - %-----------------------------------------------------------------------------% 4 - % Requires that the array 'x' is in strict decreasing order 5 - %-----------------------------------------------------------------------------% 6 - 7 - predicate fzn_strictly_decreasing_int_opt(array[int] of var opt int: x) = 8 - fzn_strictly_increasing_int_opt(reverse(x));
+1 -8
share/minizinc/std/globals.mzn
··· 93 93 include "inverse_in_range.mzn"; 94 94 include "inverse_set.mzn"; 95 95 include "knapsack.mzn"; 96 - include "lex_greatereq.mzn"; 97 96 include "lex_greater.mzn"; 97 + include "lex_greatereq.mzn"; 98 98 include "lex_lesseq.mzn"; 99 99 include "lex_less.mzn"; 100 - include "lex_chain_lesseq.mzn"; 101 - include "lex_chain_greatereq.mzn"; 102 - include "lex_chain_lesseq_orbitope.mzn"; 103 - include "lex_chain_greatereq_orbitope.mzn"; 104 - include "lex_chain_less.mzn"; 105 - include "lex_chain_greater.mzn"; 106 100 include "lex2.mzn"; 107 - include "lex2_strict.mzn"; 108 101 include "link_set_to_booleans.mzn"; 109 102 include "maximum.mzn"; 110 103 include "mdd.mzn";
-8
share/minizinc/std/lex2_strict.mzn
··· 1 - include "strict_lex2.mzn"; 2 - 3 - /** @group globals.lexicographic 4 - Require adjacent rows and adjacent columns in the array \a x to be 5 - lexicographically ordered. Adjacent rows and adjacent columns cannot be equal. 6 - */ 7 - predicate lex2_strict(array[int, int] of var int: x) = 8 - strict_lex2(x);
-28
share/minizinc/std/lex_chain_greater.mzn
··· 1 - include "lex_chain_less.mzn"; 2 - 3 - /** @group globals.lexicographic 4 - Requires that the columns of matrix \a a are lexicographically sorted, 5 - strictly decreasing. 6 - */ 7 - predicate lex_chain_greater(array[int, int] of var bool: a) = 8 - if 1>=card(index_set_2of2(a)) then true 9 - else lex_chain_less( 10 - array2d( index_set_1of2(a), index_set_2of2(a), 11 - [a[i, max(index_set_2of2(a)) - j + min(index_set_2of2(a))] | 12 - i in index_set_1of2(a), j in index_set_2of2(a)] 13 - ) 14 - ) endif; 15 - 16 - /** @group globals.lexicographic 17 - Requires that the columns of matrix \a a are lexicographically sorted, 18 - strictly decreasing. 19 - */ 20 - predicate lex_chain_greater(array[int, int] of var int: a) = 21 - if 1>=card(index_set_2of2(a)) then true 22 - else lex_chain_less( 23 - array2d( index_set_1of2(a), index_set_2of2(a), 24 - [a[i, max(index_set_2of2(a)) - j + min(index_set_2of2(a))] | 25 - i in index_set_1of2(a), j in index_set_2of2(a)] 26 - ) 27 - ) endif; 28 -
-28
share/minizinc/std/lex_chain_greatereq.mzn
··· 1 - include "lex_chain_lesseq.mzn"; 2 - 3 - /** @group globals.lexicographic 4 - Requires that the columns of matrix \a a are lexicographically sorted, 5 - non-increasing. 6 - */ 7 - predicate lex_chain_greatereq(array[int, int] of var bool: a) = 8 - if 1>=card(index_set_2of2(a)) then true 9 - else lex_chain_lesseq( 10 - array2d( index_set_1of2(a), index_set_2of2(a), 11 - [a[i, max(index_set_2of2(a)) - j + min(index_set_2of2(a))] | 12 - i in index_set_1of2(a), j in index_set_2of2(a)] 13 - ) 14 - ) endif; 15 - 16 - /** @group globals.lexicographic 17 - Requires that the columns of matrix \a a are lexicographically sorted, 18 - non-increasing. 19 - */ 20 - predicate lex_chain_greatereq(array[int, int] of var int: a) = 21 - if 1>=card(index_set_2of2(a)) then true 22 - else lex_chain_lesseq( 23 - array2d( index_set_1of2(a), index_set_2of2(a), 24 - [a[i, max(index_set_2of2(a)) - j + min(index_set_2of2(a))] | 25 - i in index_set_1of2(a), j in index_set_2of2(a)] 26 - ) 27 - ) endif; 28 -
-19
share/minizinc/std/lex_chain_greatereq_orbitope.mzn
··· 1 - include "lex_chain_lesseq_orbitope.mzn"; 2 - 3 - /** @group globals.lexicographic 4 - Requires that the columns of binary matrix \a a are 5 - lexicographically sorted, non-increasing. 6 - Moreover, the second parameter has the following meaning: 7 - 0: no further constraints, 1: set-partitioning orbitope, 8 - 2: set-packing orbitope 9 - */ 10 - predicate lex_chain_greatereq_orbitope( 11 - array[int, int] of var int: a, int: kind) = 12 - if 1>=card(index_set_2of2(a)) then true 13 - else lex_chain_lesseq_orbitope( 14 - array2d( index_set_1of2(a), index_set_2of2(a), 15 - [a[i, max(index_set_2of2(a)) - j + min(index_set_2of2(a))] | 16 - i in index_set_1of2(a), j in index_set_2of2(a)] 17 - ), 18 - kind) endif; 19 -
-19
share/minizinc/std/lex_chain_less.mzn
··· 1 - include "lex_chain_less_bool.mzn"; 2 - include "lex_chain_less_int.mzn"; 3 - 4 - /** @group globals.lexicographic 5 - Requires that the columns of matrix \a a are lexicographically sorted, 6 - strictly increasing. 7 - */ 8 - predicate lex_chain_less(array[int, int] of var bool: a) = 9 - if 1>=card(index_set_2of2(a)) then true 10 - else lex_chain_less_bool(a) endif; 11 - 12 - /** @group globals.lexicographic 13 - Requires that the columns of matrix \a a are lexicographically sorted, 14 - non-decreasing. 15 - */ 16 - predicate lex_chain_less(array[int, int] of var int: a) = 17 - if 1>=card(index_set_2of2(a)) then true 18 - else lex_chain_less_int(a) endif; 19 -
-12
share/minizinc/std/lex_chain_less_bool.mzn
··· 1 - include "fzn_lex_chain_less_bool.mzn"; 2 - include "fzn_lex_chain_less_bool_reif.mzn"; 3 - 4 - %-----------------------------------------------------------------------------% 5 - % Requires that the columns of matrix \a a are lexicographically sorted, 6 - % strictly increasing. 7 - %-----------------------------------------------------------------------------% 8 - 9 - predicate lex_chain_less_bool(array[int, int] of var bool: a) = 10 - fzn_lex_chain_less_bool(a); 11 - 12 - %-----------------------------------------------------------------------------%
-12
share/minizinc/std/lex_chain_less_int.mzn
··· 1 - include "fzn_lex_chain_less_int.mzn"; 2 - include "fzn_lex_chain_less_int_reif.mzn"; 3 - 4 - %-----------------------------------------------------------------------------% 5 - % Requires that the columns of matrix \a a are lexicographically sorted, 6 - % strictly increasing. 7 - %-----------------------------------------------------------------------------% 8 - 9 - predicate lex_chain_less_int(array[int, int] of var int: a) = 10 - fzn_lex_chain_less_int(a); 11 - 12 - %-----------------------------------------------------------------------------%
-33
share/minizinc/std/lex_chain_lesseq.mzn
··· 1 - include "lex_chain_lesseq_bool.mzn"; 2 - include "lex_chain_lesseq_int.mzn"; 3 - 4 - /** @group globals.lexicographic 5 - Requires that the columns of matrix \a a are lexicographically sorted, 6 - non-decreasing. 7 - */ 8 - predicate lex_chain_lesseq(array[int, int] of var bool: a) = 9 - if 1>=card(index_set_2of2(a)) then true 10 - else lex_chain_lesseq_bool(a) endif; 11 - 12 - /** @group globals.lexicographic 13 - Requires that the columns of matrix \a a are lexicographically sorted, 14 - non-decreasing. 15 - */ 16 - predicate lex_chain_lesseq(array[int, int] of var int: a) = 17 - if 1>=card(index_set_2of2(a)) then true 18 - else lex_chain_lesseq_int(a) endif; 19 - 20 - /** @group globals.lexicographic 21 - Requires that the columns of matrix \a a are lexicographically sorted, 22 - non-decreasing. 23 - */ 24 - predicate lex_chain(array[int, int] of var bool: a) = 25 - lex_chain_lesseq(a); 26 - 27 - /** @group globals.lexicographic 28 - Requires that the columns of matrix \a a are lexicographically sorted, 29 - non-decreasing. 30 - */ 31 - predicate lex_chain(array[int, int] of var int: a) = 32 - lex_chain_lesseq(a); 33 -
-12
share/minizinc/std/lex_chain_lesseq_bool.mzn
··· 1 - include "fzn_lex_chain_lesseq_bool.mzn"; 2 - include "fzn_lex_chain_lesseq_bool_reif.mzn"; 3 - 4 - %-----------------------------------------------------------------------------% 5 - % Requires that the columns of matrix \a a are lexicographically sorted, 6 - % non-decreasing. 7 - %-----------------------------------------------------------------------------% 8 - 9 - predicate lex_chain_lesseq_bool(array[int, int] of var bool: a) = 10 - fzn_lex_chain_lesseq_bool(a); 11 - 12 - %-----------------------------------------------------------------------------%
-12
share/minizinc/std/lex_chain_lesseq_int.mzn
··· 1 - include "fzn_lex_chain_lesseq_int.mzn"; 2 - include "fzn_lex_chain_lesseq_int_reif.mzn"; 3 - 4 - %-----------------------------------------------------------------------------% 5 - % Requires that the columns of matrix \a a are lexicographically sorted, 6 - % non-decreasing. 7 - %-----------------------------------------------------------------------------% 8 - 9 - predicate lex_chain_lesseq_int(array[int, int] of var int: a) = 10 - fzn_lex_chain_lesseq_int(a); 11 - 12 - %-----------------------------------------------------------------------------%
-18
share/minizinc/std/lex_chain_lesseq_orbitope.mzn
··· 1 - include "fzn_lex_chain_lesseq_orbitope.mzn"; 2 - include "fzn_lex_chain_lesseq_orbitope_reif.mzn"; 3 - 4 - /** @group globals.lexicographic 5 - Requires that the columns of binary matrix \a a are 6 - lexicographically sorted, non-decreasing. 7 - Moreover, the second parameter has the following meaning: 8 - 0: no further constraints, 1: set-partitioning orbitope, 9 - 2: set-packing orbitope 10 - */ 11 - predicate lex_chain_lesseq_orbitope( 12 - array[int, int] of var int: a, int: kind) = 13 - assert(dom_array(a) subset 0..1, 14 - "lex_chain_lesseq_orbitope: matrix \(a) is non-binary") 15 - /\ 16 - if 1>=card(index_set_2of2(a)) then true 17 - else fzn_lex_chain_lesseq_orbitope(a, kind) endif; 18 -
+4 -4
share/minizinc/std/piecewise_linear.mzn
··· 2 2 include "fzn_piecewise_linear_reif.mzn"; 3 3 4 4 /** @group globals 5 - Return the piecewise-linear function of x 6 - on the given point-value sequence 5 + Return a piecewise-linear interpolation 6 + of the given point sequence as a function of \a x 7 7 */ 8 8 function var float: piecewise_linear(var float: x, array[int] of float: xi, array[int] of float: vi) ::promise_total = 9 9 let { ··· 13 13 14 14 15 15 /** @group globals 16 - Constrains \a y(\a x) to be the piecewise-linear function 17 - on the provided point-value sequence. 16 + Constrains \a y(\a x) to be a piecewise-linear interpolation of 17 + the provided point sequence. 18 18 */ 19 19 predicate piecewise_linear(var float: x, var float: y, 20 20 array[int] of float: xi, array[int] of float: vi) =
-29
share/minizinc/std/piecewise_linear_non_continuous.mzn
··· 1 - include "fzn_piecewise_linear_non_continuous.mzn"; 2 - include "fzn_piecewise_linear_non_continuous_reif.mzn"; 3 - 4 - /** @group globals 5 - Return the piecewise-linear function of x 6 - on the given (possibly disconnected) intervals. 7 - Each interval \a i connects 8 - (\a x_start[\a i], \a v_start[\a i]) to (\a x_end[\a i], \a v_end[\a i]). 9 - */ 10 - function var float: piecewise_linear(var float: x, 11 - array[int] of float: x_start, array[int] of float: x_end, 12 - array[int] of float: v_start, array[int] of float: v_end) ::promise_total = 13 - let { 14 - var float: res, 15 - constraint piecewise_linear(x, res, x_start,x_end, v_start,v_end), 16 - } in res; 17 - 18 - 19 - /** @group globals 20 - Constrains \a y(\a x) to be the piecewise-linear function on 21 - the provided point-value intervals. 22 - */ 23 - predicate piecewise_linear(var float: x, var float: y, 24 - array[int] of float: x_start, array[int] of float: x_end, 25 - array[int] of float: v_start, array[int] of float: v_end 26 - ) = 27 - fzn_piecewise_linear(x, y, x_start,x_end, v_start,v_end); 28 - 29 - %-----------------------------------------------------------------------------%
+7 -1
share/minizinc/std/restart.mzn
··· 18 18 function var STATUS: status(); 19 19 20 20 /* 21 + When complete is set to 'true', then it marks the search as complete. 22 + */ 23 + predicate complete();% = abort("'complete' should be used in reified context"); 24 + predicate complete_reif(var bool: marker); 25 + 26 + /* 21 27 The 'uniform' function provides random values chosen by the solver. The arguments 22 28 to the function limit the values to a certain domain. 23 29 */ ··· 134 140 select = -1 135 141 else 136 142 select = (sol(select) + 1) mod len 137 - endif; 143 + endif;
-30
share/minizinc/std/stdlib/stdlib_coercion.mzn
··· 13 13 14 14 /** @group stdlib.coercion Return Boolean \a b coerced to an integer */ 15 15 function int: bool2int(bool: b); 16 - 17 - /** @group stdlib.coercion Return Boolean \a b coerced to an integer */ 18 - function opt int: bool2int(opt bool: b) = 19 - if occurs(b) then bool2int(deopt(b)) else <> endif; 20 - 21 16 /** @group stdlib.coercion Return optional 0/1 integer that is absent iff \a x 22 17 is absent, and 1 iff \a x occurs and is true. */ 23 18 function var opt int: bool2int(var opt bool: x) ::promise_total = ··· 30 25 31 26 /** @group stdlib.coercion Return Boolean \a b coerced to a float */ 32 27 function float: bool2float(bool: b) = if b then 1.0 else 0.0 endif; 33 - /** @group stdlib.coercion Return Boolean \a b coerced to a float */ 34 - function opt float: bool2float(opt bool: b) = 35 - if occurs(b) then bool2float(deopt(b)) else <> endif; 36 - 37 28 /** @group stdlib.coercion Return array of Booleans \a x coerced to an array of floats */ 38 29 function array[$T] of float: bool2float(array[$T] of bool: x) ::promise_total = 39 30 let { ··· 52 43 function var float: bool2float(var bool: b) = int2float(bool2int(b)); 53 44 /** @group stdlib.coercion Return integer \a x coerced to a float */ 54 45 function float: int2float(int: x); 55 - /** @group stdlib.coercion Return integer \a x coerced to a float */ 56 - function opt float: int2float(opt int: x) = 57 - if occurs(x) then int2float(deopt(x)) else <> endif; 58 46 /** @group stdlib.coercion Return integer \a x coerced to a float */ 59 47 function var float: int2float(var int: x) ::promise_total; 60 48 ··· 100 88 } in arrayXd(x,[bool2int(xx[i]) | i in index_set(xx)]); 101 89 102 90 /** @group stdlib.coercion Return array of Booleans \a x coerced to an array of integers */ 103 - function array[$T] of opt int: bool2int(array[$T] of opt bool: x) = 104 - let { 105 - array[int] of opt bool: xx = array1d(x) 106 - } in arrayXd(x,[bool2int(xx[i]) | i in index_set(xx)]); 107 - 108 - /** @group stdlib.coercion Return array of Booleans \a x coerced to an array of integers */ 109 91 function array[$T] of var opt int: bool2int(array[$T] of var opt bool: x) ::promise_total = 110 92 let { 111 93 array[int] of var opt bool: xx = array1d(x) 112 94 } in arrayXd(x,[bool2int(xx[i]) | i in index_set(xx)]); 113 95 114 96 /** @group stdlib.coercion Return array of Booleans \a x coerced to an array of floats */ 115 - function array[$T] of opt float: bool2float(array[$T] of opt bool: x) = 116 - let { 117 - array[int] of opt bool: xx = array1d(x) 118 - } in arrayXd(x, [bool2float(xx[i]) | i in index_set(xx)]); 119 - 120 - /** @group stdlib.coercion Return array of Booleans \a x coerced to an array of floats */ 121 97 function array[$T] of var opt float: bool2float(array[$T] of var opt bool: x) ::promise_total = 122 98 let { 123 99 array[int] of var opt bool: xx = array1d(x) ··· 127 103 function array[$T] of float: int2float(array[$T] of int: x) ::promise_total = 128 104 let { 129 105 array[int] of int: xx = array1d(x) 130 - } in arrayXd(x,[int2float(xx[i]) | i in index_set(xx)]); 131 - 132 - /** @group stdlib.coercion Return array of integers \a x coerced to an array of floats */ 133 - function array[$T] of opt float: int2float(array[$T] of opt int: x) ::promise_total = 134 - let { 135 - array[int] of opt int: xx = array1d(x) 136 106 } in arrayXd(x,[int2float(xx[i]) | i in index_set(xx)]); 137 107 138 108 /** @group stdlib.coercion Return array of integers \a x coerced to an array of floats */
-22
share/minizinc/std/stdlib/stdlib_internal.mzn
··· 159 159 160 160 test mzn_in_redundant_constraint(); 161 161 162 - test mzn_in_symmetry_breaking_constraint(); 163 - 164 162 /* Internal function used to optimize over option type objective */ 165 163 function var float: objective_deopt_(var opt float: x, bool: direction) = 166 164 let { ··· 1227 1225 1228 1226 predicate mzn_symmetry_breaking_constraint(var bool: b); 1229 1227 predicate mzn_redundant_constraint(var bool: b); 1230 - 1231 - /* Annotations used for bookkeeping by the compiler */ 1232 - 1233 - annotation mzn_was_undefined; 1234 - 1235 - /* Predicate used in the compiler for translating infinite domains into constraints */ 1236 - 1237 - predicate mzn_set_in_internal(var int: x, set of int: s) = 1238 - if min(s) != -infinity /\ max(s) != infinity then set_in(x,s) 1239 - else let { 1240 - array[int] of int: ranges_ = set_to_ranges(s); 1241 - array[int,1..2] of int: ranges = array2d(1..length(ranges_) div 2,1..2,ranges_); 1242 - int: max_range = card(index_set_1of2(ranges)); 1243 - } in if max_range=2 /\ ranges[1,2]=ranges[2,1]-2 then 1244 - x != ranges[1,2]+1 1245 - else 1246 - x <= ranges[1,2] \/ x >= ranges[max_range,1] \/ 1247 - exists (i in 2..max_range-1) (x in ranges[i,1]..ranges[i,2]) 1248 - endif 1249 - endif;
+39 -21
share/minizinc/std/stdlib/stdlib_math.mzn
··· 218 218 function $T: min( $T: x, $T: y); 219 219 /** @group stdlib.arithmetic Return minimum of elements in array \a x */ 220 220 function $T: min(array[$U] of par $T: x); 221 - /** @group stdlib.arithmetic Return minimum of elements in \a x that are not absent. */ 222 - function var int: min(array[int] of var opt int: x) = 221 + /** @group stdlib.arithmetic Return minimum of elements in \a x that are not absent, or 222 + absent if all elements in \a x are absent. */ 223 + function var opt int: min(array[int] of var opt int: x) ::promise_total = 223 224 let { 224 - var lb_array(x)..ub_array(x): xmax = max(xi in x)(deopt(xi)); 225 - % Array cannot be empty, otherwise min is undefined 226 - constraint exists(xi in x)(occurs(xi)); 227 - } in min([if occurs(xi) then deopt(xi) else xmax endif | xi in x]); 228 - /** @group stdlib.arithmetic Return minimum of elements in \a x that are not absent. */ 229 - function var float: min(array[int] of var opt float: x) = 225 + var opt lb_array(x)..ub_array(x): m; 226 + var lb_array(x)..ub_array(x): xmax; 227 + constraint if ub(xmax) != infinity then xmax = ub(xmax) else forall (i in index_set(x)) (xmax >= deopt(x[i])) endif; 228 + constraint occurs(m) <-> exists (i in index_set(x)) (occurs(x[i])); 229 + constraint occurs(m) -> 230 + deopt(m) = min([if occurs(xi) then deopt(xi) else xmax endif | xi in x]); 231 + } in m; 232 + /** @group stdlib.arithmetic Return minimum of elements in \a x that are not absent, or 233 + absent if all elements in \a x are absent. */ 234 + % :NOTE: since -oo is always a lb for float variables, should we instead return -oo if all absent? 235 + function var opt float: min(array[int] of var opt float: x) ::promise_total = 230 236 let { 231 - var lb_array(x)..ub_array(x): xmax = max(xi in x)(deopt(xi)); 232 - % Array cannot be empty, otherwise min is undefined 233 - constraint exists(xi in x)(occurs(xi)); 234 - } in min([if occurs(xi) then deopt(xi) else xmax endif | xi in x]); 237 + var opt lb_array(x)..ub_array(x): m; 238 + var lb_array(x)..ub_array(x): xmax; 239 + constraint if ub(xmax) != infinity then xmax = ub(xmax) else forall (i in index_set(x)) (xmax >= deopt(x[i])) endif; 240 + constraint occurs(m) <-> exists (i in index_set(x)) (occurs(x[i])); 241 + constraint occurs(m) -> 242 + deopt(m) = min([if occurs(xi) then deopt(xi) else xmax endif | xi in x]); 243 + } in m; 235 244 236 245 /** @group stdlib.arithmetic Return maximum of \a x and \a y */ 237 246 function $T: max( $T: x, $T: y); ··· 239 248 function $T: max(array[$U] of $T: x); 240 249 /** @group stdlib.arithmetic Return maximum of elements in \a x that are not absent, or 241 250 absent if all elements in \a x are absent. */ 242 - function var int: max(array[int] of var opt int: x) = 251 + function var opt int: max(array[int] of var opt int: x) ::promise_total = 243 252 let { 244 - var lb_array(x)..ub_array(x): xmin = min(xi in x)(deopt(xi)); 245 - constraint exists (xi in x) (occurs(xi)); 246 - } in max([if occurs(xi) then deopt(xi) else xmin endif | xi in x]); 253 + var opt lb_array(x)..ub_array(x): m; 254 + var lb_array(x)..ub_array(x): xmin; 255 + constraint if lb(xmin) != -infinity then xmin = lb(xmin) else forall (i in index_set(x)) (xmin <= deopt(x[i])) endif; 256 + constraint occurs(m) <-> exists (i in index_set(x)) (occurs(x[i])); 257 + constraint occurs(m) -> 258 + deopt(m) = max([if occurs(xi) then deopt(xi) else xmin endif | xi in x]); 259 + } in m; 247 260 /** @group stdlib.arithmetic Return minimum of elements in set \a x */ 248 261 function $$E: min(set of $$E: x); 249 262 /** @group stdlib.arithmetic Return maximum of elements in set \a x */ ··· 261 274 array[int] of var int: xx = array1d(x); 262 275 constraint length(x) >= 1; 263 276 } in max_t(xx); 264 - /** @group stdlib.arithmetic Return maximum of elements in \a x that are not absent. */ 265 - function var float: max(array[int] of var opt float: x) = 277 + /** @group stdlib.arithmetic Return maximum of elements in \a x that are not absent, or 278 + absent if all elements in \a x are absent. */ 279 + function var opt float: max(array[int] of var opt float: x) ::promise_total = 266 280 let { 267 - var lb_array(x)..ub_array(x): xmin = min(xi in x)(deopt(xi)); 268 - constraint exists (xi in x) (occurs(xi)); 269 - } in max([if occurs(xi) then deopt(xi) else xmin endif | xi in x]); 281 + var opt lb_array(x)..ub_array(x): m; 282 + var lb_array(x)..ub_array(x): xmin; 283 + constraint if lb(xmin) != -infinity then xmin = lb(xmin) else forall (i in index_set(x)) (xmin <= deopt(x[i])) endif; 284 + constraint occurs(m) <-> exists (i in index_set(x)) (occurs(x[i])); 285 + constraint occurs(m) -> 286 + deopt(m) = max([if occurs(xi) then deopt(xi) else xmin endif | xi in x]); 287 + } in m; 270 288 271 289 /** @group stdlib.arithmetic Return minimum of \a x and \a y */ 272 290 function var int: min(var int: x, var int: y) :: promise_total =
-8
share/minizinc/std/strictly_decreasing.mzn
··· 1 1 include "fzn_strictly_decreasing_int.mzn"; 2 - include "fzn_strictly_decreasing_int_opt.mzn"; 3 2 include "fzn_strictly_decreasing_int_reif.mzn"; 4 3 include "fzn_strictly_decreasing_bool.mzn"; 5 4 include "fzn_strictly_decreasing_bool_reif.mzn"; ··· 9 8 % Requires that the array 'x' is in strict decreasing order 10 9 %-----------------------------------------------------------------------------% 11 10 12 - /** @group globals.sort Requires that the array \a x is in a stricly decreasing order (duplicates are *not* allowed). */ 13 11 predicate strictly_decreasing(array[$X] of var bool: x) = 14 12 analyse_all_different(array1d(x)) /\ 15 13 fzn_strictly_decreasing_bool(array1d(x)); ··· 17 15 predicate strictly_decreasing_reif(array[$X] of var bool: x, var bool: b) = 18 16 fzn_strictly_decreasing_bool_reif(array1d(x),b); 19 17 20 - /** @group globals.sort Requires that the array \a x is in a stricly decreasing order (duplicates are *not* allowed). */ 21 18 predicate strictly_decreasing(array[$X] of var int: x) = 22 19 analyse_all_different(array1d(x)) /\ 23 20 fzn_strictly_decreasing_int(array1d(x)); 24 - 25 - /** @group globals.sort Requires that the array \a x is in a stricly decreasing order (duplicates are *not* allowed). */ 26 - predicate strictly_decreasing(array[$X] of var opt int: x) = 27 - analyse_all_different(array1d(x)) /\ 28 - fzn_strictly_decreasing_int_opt(array1d(x)); 29 21 30 22 predicate strictly_decreasing_reif(array[$X] of var int: x, var bool: b) = 31 23 fzn_strictly_decreasing_int_reif(array1d(x),b);
+1 -1
solvers/MIP/MIP_cplex_wrap.cpp
··· 1070 1070 break; 1071 1071 // case CPXMIP_ABORT_INFEAS: 1072 1072 case CPXMIP_FAIL_INFEAS: 1073 - s = Status::ERROR_STATUS; 1073 + s = Status::__ERROR; 1074 1074 break; 1075 1075 default: 1076 1076 // case CPXMIP_OPTIMAL_TOL:
+1 -4
solvers/MIP/MIP_gurobi_wrap.cpp
··· 461 461 param_name == GRB_DBL_PAR_NODEFILESTART || param_name == GRB_STR_PAR_NODEFILEDIR || 462 462 param_name == GRB_DBL_PAR_MIPGAPABS || param_name == GRB_INT_PAR_MIPFOCUS || 463 463 param_name == GRB_DBL_PAR_MIPGAP || param_name == GRB_DBL_PAR_INTFEASTOL || 464 - param_name == GRB_DBL_PAR_FEASIBILITYTOL || 465 - #ifdef GRB_INT_PAR_NONCONVEX 466 - param_name == GRB_INT_PAR_NONCONVEX || 467 - #endif 464 + param_name == GRB_DBL_PAR_FEASIBILITYTOL || param_name == GRB_INT_PAR_NONCONVEX || 468 465 param_name == GRB_INT_PAR_PRECRUSH || param_name == GRB_INT_PAR_LAZYCONSTRAINTS || 469 466 param_name == GRB_STR_PAR_DUMMY) { 470 467 // These parameters are handled by us or are not useful
+7 -7
solvers/MIP/MIP_osicbc_wrap.cpp
··· 656 656 s = Status::SAT; 657 657 output.statusName = "Feasible"; 658 658 } else if (pModel->isAbandoned()) { // AFTER feas-ty 659 - s = Status::ERROR_STATUS; 659 + s = Status::__ERROR; 660 660 output.statusName = "Abandoned"; 661 661 } else { 662 662 s = Status::UNKNOWN; ··· 680 680 output.statusName = "Dual infeasible"; 681 681 // s = Status::UNSATorUNBND; 682 682 } else if (_osi.isAbandoned()) { 683 - s = Status::ERROR_STATUS; 683 + s = Status::__ERROR; 684 684 output.statusName = "Abandoned"; 685 685 } else if // wrong: (pModel->getColSolution()) 686 686 (fabs(_osi.getObjValue()) < _osi.getInfinity()) { ··· 763 763 cerr << " Model creation..." << endl; 764 764 } 765 765 766 - // #define MZN_USE_CbcSolver -- not linked rev2274 766 + // #define __USE_CbcSolver__ -- not linked rev2274 767 767 /// FOR WARMSTART 768 768 for (const auto& vv : _warmstart) { 769 769 _osi.setColName(vv.first, colNames[vv.first]); 770 770 } 771 - #ifdef MZN_USE_CbcSolver 771 + #ifdef __USE_CbcSolver__ 772 772 CbcSolver control(osi); 773 773 // initialize 774 774 control.fillValuesInSolver(); ··· 938 938 // CbcCbcParamUtils::setCbcModelDefaults(model) ; 939 939 // const char * argv2[]={"mzn-cbc","-solve","-quit"}; 940 940 // CbcMain1(3,argv2,model); 941 - #ifdef MZN_USE_CbcSolver 941 + #ifdef __USE_CbcSolver__ 942 942 if (fVerbose) 943 943 cerr << " Calling control.solve() with options '" << options->cbcCmdOptions << "'..." 944 944 << endl; 945 945 control.solve(options->cbcCmdOptions.c_str(), 1); 946 946 #else 947 - #define MZN_USE_callCbc1 948 - #ifdef MZN_USE_callCbc1 947 + #define __USE_callCbc1__ 948 + #ifdef __USE_callCbc1__ 949 949 if (fVerbose) { 950 950 cerr << " Calling CbcMain with command 'cbc"; 951 951 for (const auto& arg : _options->cbcCmdOptions) {
+5 -55
solvers/MIP/MIP_scip_wrap.cpp
··· 88 88 load_symbol(SCIPcreateConsBasicIndicator); 89 89 load_symbol(SCIPcreateConsBasicBounddisjunction); 90 90 load_symbol(SCIPcreateConsBasicCumulative); 91 - load_symbol(SCIPcreateConsBasicOrbisack); 92 - load_symbol(SCIPcreateConsBasicOrbitope); 93 91 load_symbol(SCIPgetNSolsFound); 94 92 load_symbol(SCIPgetNSols); 95 93 load_symbol(SCIPsetIntParam); ··· 566 564 SCIP_PLUGIN_CALL(_plugin->SCIPreleaseCons(_scip, &cons)); 567 565 } 568 566 569 - /// Lex-lesseq binary, currently SCIP only 570 - /// TODO check all variables are binary, SCIP 7.0.2 does not 571 - void MIPScipWrapper::addLexLesseq(int nnz, int* rmatind1, int* rmatind2, bool isModelCons, 572 - const std::string& rowName) { 573 - SCIP_CONS* cons; 574 - vector<SCIP_VAR*> vars1(nnz); 575 - vector<SCIP_VAR*> vars2(nnz); 576 - 577 - for (int j = 0; j < nnz; ++j) { 578 - vars1[j] = _scipVars[rmatind1[j]]; 579 - vars2[j] = _scipVars[rmatind2[j]]; 580 - } 581 - 582 - SCIP_PLUGIN_CALL(_plugin->SCIPcreateConsBasicOrbisack( 583 - _scip, &cons, rowName.c_str(), vars2.data(), vars1.data(), // it's actually lex_greatereq 584 - nnz, FALSE, FALSE, (SCIP_Bool)isModelCons)); 585 - SCIP_PLUGIN_CALL(_plugin->SCIPaddCons(_scip, cons)); 586 - SCIP_PLUGIN_CALL(_plugin->SCIPreleaseCons(_scip, &cons)); 587 - } 588 - 589 - /// Lex-chain-lesseq binary, currently SCIP only 590 - void MIPScipWrapper::addLexChainLesseq(int m, int n, int* rmatind, int nOrbitopeType, 591 - bool resolveprop, bool isModelCons, 592 - const std::string& rowName) { 593 - SCIP_CONS* cons; 594 - vector<vector<SCIP_VAR*> > vars(m, vector<SCIP_VAR*>(size_t(n))); 595 - vector<SCIP_VAR**> vars_data(m); 596 - 597 - for (int i = 0; i < m; ++i) { 598 - for (int j = 0; j < n; ++j) { 599 - vars[i][j] = _scipVars[rmatind[i * n + (n - j - 1)]]; // it's actually lex_chain_greatereq 600 - } 601 - vars_data[i] = vars[i].data(); 602 - } 603 - 604 - SCIP_PLUGIN_CALL(_plugin->SCIPcreateConsBasicOrbitope( 605 - _scip, &cons, rowName.c_str(), vars_data.data(), (SCIP_ORBITOPETYPE)nOrbitopeType, m, n, 606 - (SCIP_Bool)resolveprop, (SCIP_Bool)isModelCons)); 607 - SCIP_PLUGIN_CALL(_plugin->SCIPaddCons(_scip, cons)); 608 - SCIP_PLUGIN_CALL(_plugin->SCIPreleaseCons(_scip, &cons)); 609 - } 610 - 611 567 void MIPScipWrapper::addTimes(int x, int y, int z, const string& rowName) { 612 568 /// As x*y - z == 0 613 569 double zCoef = -1.0; ··· 627 583 #define EVENTHDLR_NAME "bestsol" 628 584 #define EVENTHDLR_DESC "event handler for best solutions found" 629 585 630 - namespace { 631 586 // Dirty way of accessing SCIP functions inside C callbacks 632 - ScipPlugin* _cb_plugin; 633 - 634 - MIPWrapper::CBUserInfo* cbuiPtr = nullptr; 635 - SCIP_VAR** _scipVarsPtr = nullptr; 636 - } // namespace 587 + static ScipPlugin* _cb_plugin; 637 588 638 589 /** initialization method of event handler (called after problem was transformed) */ 639 590 static SCIP_DECL_EVENTINIT(eventInitBestsol) { /*lint --e{715}*/ ··· 660 611 661 612 return SCIP_OKAY; 662 613 } 614 + 615 + static MIPWrapper::CBUserInfo* cbuiPtr = nullptr; 616 + static SCIP_VAR** _scipVarsPtr = nullptr; 663 617 664 618 /** execution method of event handler */ 665 619 static SCIP_DECL_EVENTEXEC(eventExecBestsol) { /*lint --e{715}*/ ··· 700 654 cbuiPtr->pOutput->nOpenNodes = _cb_plugin->SCIPgetNNodesLeft(scip); 701 655 cbuiPtr->pOutput->bestBound = _cb_plugin->SCIPgetDualbound(scip); 702 656 703 - cbuiPtr->pOutput->dWallTime = std::chrono::duration<double>(std::chrono::steady_clock::now() - 704 - cbuiPtr->pOutput->dWallTime0) 705 - .count(); 706 - cbuiPtr->pOutput->dCPUTime = 707 - double(std::clock() - cbuiPtr->pOutput->cCPUTime0) / CLOCKS_PER_SEC; 657 + cbuiPtr->pOutput->dCPUTime = -1; 708 658 709 659 /// Call the user function: 710 660 if (cbuiPtr->solcbfn != nullptr) {
+1 -1
solvers/MIP/MIP_xpress_wrap.cpp
··· 449 449 case XPRB_MIP_NO_SOL_FOUND: 450 450 return MIPWrapper::Status::UNKNOWN; 451 451 case XPRB_MIP_NOT_LOADED: 452 - return MIPWrapper::Status::ERROR_STATUS; 452 + return MIPWrapper::Status::__ERROR; 453 453 default: 454 454 return MIPWrapper::Status::UNKNOWN; 455 455 }
+3 -3
tests/benchmarking/cmp_result_logs.py
··· 60 60 ] ) 61 61 62 62 ## which of those to print for each method 63 - hdrTable2P = "stt chk objMZN objSLV bnd tFlt tBest" 63 + hdrTable2P = "stt objMZN objSLV bnd tFlt tBest" 64 64 hdrTable2P_spl = hdrTable2P.split( " " ) 65 65 66 66 mapStatShort = { ## Short status names ··· 268 268 0<mRes["SOLUTION_CHECKS_FAILED"]: 269 269 aResultThisInst[ "n_CheckFailed" ] = 1 270 270 aDetThis[ "chk" ] = "BAD" 271 + utils.addMapValues( self.mCmpVecVals[lNames], aResultThisInst ) 271 272 print( "WARNING: SOLUTION CHECK(S) FAILED for the instance ", sInst, 272 273 ", method '", lNames, "'.", sep='', file = self.ioBadChecks ) 273 - ## utils.addMapValues( self.mCmpVecVals[lNames], aResultThisInst ) 274 - ## continue ## TODO. Param? 274 + continue ## TODO. Param? 275 275 aResultThisInst[ "n_ErrorsBackend" ] = 0 276 276 aResultThisInst[ "n_ErrorsLogical" ] = 0 277 277 aDetThis [ "errH" ] = 0
+14 -14
tests/benchmarking/mzn-test.py
··· 5 5 ## checks solutions and compares to given solution logs. 6 6 7 7 ## TODO type errors etc. when checking? 8 + ## TODO -a for optimization only 8 9 ## TODO continuous output dumping as option 9 10 ## TODO CPU/user time limit, proper memory limit (setrlimit not working) 10 11 ··· 34 35 35 36 sDZNOutputAgrs = "--output-mode dzn --output-objective" ## The flattener arguments to produce DZN-compatible output facilitating solution checking 36 37 ## Remove --output-objective in MZN Release <=2.1.7 37 - sFlatOptChecker = "--allow-multiple-assignments -Dmzn_ignore_symmetry_breaking_constraints=true" 38 + sFlatOptChecker = "--allow-multiple-assignments" 38 39 39 40 s_UsageExamples = ( 40 41 "\nUSAGE EXAMPLES:" ··· 147 148 #"MZN-CPLEX", 148 149 "/// At the moment only the 1st element is used for solving" ], 149 150 "SOLUTION_CHECKING": { 150 - "Checkers": ["GECODE-CHK", "GUROBI-CHK", "CPLEX-CHK", "ORTOOLS-CHK" ], 151 + "Checkers": ["GECODE-CHK", "GUROBI-CHK", "CPLEX-CHK" ], 151 152 "n_CheckedMax": [ -10, "/// Negative value means it's that many last solutions" ], 152 153 "n_FailedSaveMax": [ 3, "/// After that many failed solutions, stop checking the instance" ], 153 154 "s_FailedSaveFile": [ sFlnSolFailBase, "/// Filename to save failed solutions" ], ··· 199 200 ], 200 201 "MINIZINC-CHK": [ "__BE_COMMON", "__BE_CHECKER_OLDMINIZINC", "BE_MINIZINC" ], 201 202 "GECODE-CHK": [ "__BE_COMMON", "__BE_CHECKER", "BE_GECODE" ], 202 - "ORTOOLS-CHK": [ "__BE_COMMON", "__BE_CHECKER", "BE_ORTOOLS" ], 203 203 "GUROBI-CHK": [ "__BE_COMMON", "__BE_CHECKER", "BE_GUROBI" ], 204 204 "CPLEX-CHK": [ "__BE_COMMON", "__BE_CHECKER", "BE_CPLEX" ], 205 205 "CHUFFED-CHK": [ "__BE_COMMON", "__BE_CHECKER", "BE_CHUFFED" ], ··· 218 218 s_CommentKey: [ "THE INITIALIZING BACKEND." ], 219 219 "EXE": { 220 220 s_CommentKey: [ "Solver call parameters" ], 221 - "s_SolverCall" : ["minizinc -v -s -i " + sDZNOutputAgrs + " %s", 221 + "s_SolverCall" : ["minizinc -v -s -a " + sDZNOutputAgrs + " %s", 222 222 "/// The 1st element defines the call line. %s is replaced by the instance filename(s)."], 223 223 "s_ExtraCmdline" : ["", "/// Only for __BE_SOLVER/__BE_CHECKER... subprofiles." 224 224 " The 1st element gives extra cmdline arguments to the call"], ··· 241 241 ### The %%%mzn-stat values appear in stdout (as of May 2019) but leave them here just in case 242 242 "Time_Flt": [ "%%%mzn-stat: flatTime", "[:=]", 3, "/// E.g., 'Flattening done, 3s' produces 3." 243 243 " !!! This is interpreted as successful flattening by the checker" ], 244 - "ObjVal_Solver": [ "%%%mzn-stat: objective=", "[,:/=]", 3, ## Need = to avoid mixup with the bound 244 + "ObjVal_Solver": [ "%%%mzn-stat objective=", "[,:/=]", 3, ## Need = to avoid mixup witht the bound 245 245 "/// The objval as reported by solver."], 246 - "DualBnd_Solver": [ "%%%mzn-stat: objectiveBound", "[,:/=]", 3 ], 247 - "CPUTime_Solver": [ "%%%mzn-stat: solveTime", "[,:/=]", 3 ], 248 - "NNodes_Solver": [ "%%%mzn-stat: nodes", "[,:/=]", 3 ], 246 + "DualBnd_Solver": [ "%%%mzn-stat objectiveBound", "[,:/=]", 3 ], 247 + "CPUTime_Solver": [ "%%%mzn-stat solveTime", "[,:/=]", 3 ], 248 + "NNodes_Solver": [ "%%%mzn-stat nodes", "[,:/=]", 3 ], 249 249 }, 250 250 "Stdout_Keylines": { 251 251 s_CommentKey: [ "Similar to Stderr_Keylines"], ··· 268 268 s_CommentKey: ["Similar to Stderr_Keyvalues." ], 269 269 "Time_Flt": [ "%%%mzn-stat: flatTime", "[:=]", 3, "/// E.g., 'Flattening done, 3s' produces 3." 270 270 " !!! This is interpreted as successful flattening by the checker" ], 271 - "ObjVal_Solver": [ "%%%mzn-stat: objective=", "[,:/=]", 3, ## Need = to avoid mixup with the bound 271 + "ObjVal_Solver": [ "%%%mzn-stat objective=", "[,:/=]", 3, ## Need = to avoid mixup witht the bound 272 272 "/// The objval as reported by solver."], 273 - "DualBnd_Solver": [ "%%%mzn-stat: objectiveBound", "[,:/=]", 3 ], 274 - "CPUTime_Solver": [ "%%%mzn-stat: solveTime", "[,:/=]", 3 ], 275 - "NNodes_Solver": [ "%%%mzn-stat: nodes", "[,:/=]", 3 ], 273 + "DualBnd_Solver": [ "%%%mzn-stat objectiveBound", "[,:/=]", 3 ], 274 + "CPUTime_Solver": [ "%%%mzn-stat solveTime", "[,:/=]", 3 ], 275 + "NNodes_Solver": [ "%%%mzn-stat nodes", "[,:/=]", 3 ], 276 276 "ObjVal_MZN": [ "_objective", "[():=;%]", 2, 277 277 "/// The objective value as evaluated by MZN." ], 278 278 "RealTime_Solns2Out": [ "% time elapsed:", " ", 4 ], ··· 281 281 "__BE_SOLVER": { 282 282 s_CommentKey: ["Specializations for a general solver" ], 283 283 "EXE": { 284 - "s_ExtraCmdline" : ["-i"], 284 + "s_ExtraCmdline" : ["-a"], 285 285 "b_ThruShell" : [True], 286 286 "n_TimeoutRealHard": [150], 287 287 # "n_VMEMLIMIT_SoftHard": [8000100000, 8100000000] ··· 890 890 resSlv["NOFZN"] = [" !!!!! No flattening finish time registered or successfully parsed"] 891 891 dTmLast = utils.try_float( resSlv.get( "RealTime_Solns2Out" ) ) 892 892 if None!=dTmLast: 893 - resSlv["TimeReal_LastStatus"] = dTmLast 893 + resSlv["TimeReal_LastStatus"] = dTmLast / 1000.0 894 894 resSlv.pop( "RealTime_Solns2Out" ) 895 895 ## if "SolutionLast" in resSlv: 896 896 ## print( " SOLUTION_LAST:\n", resSlv["SolutionLast"], sep='' )
-9
tests/spec/unit/general/test_empty_enum.mzn
··· 1 - /*** 2 - !Test 3 - expected: !Result 4 - solution: !Solution 5 - ***/ 6 - 7 - enum EmptyEnum; 8 - EmptyEnum = { }; 9 - solve satisfy;
tests/spec/unit/general/test_undefined_enum.fzn

This is a binary file and will not be displayed.

-19
tests/spec/unit/general/test_undefined_enum.mzn
··· 1 - /*** 2 - !Test 3 - check_against: [] 4 - expected: 5 - - !FlatZinc test_undefined_enum.fzn 6 - extra_files: [] 7 - markers: [] 8 - options: 9 - --model-check-only: true 10 - all_solutions: false 11 - solvers: 12 - - gecode 13 - type: compile 14 - 15 - ***/ 16 - 17 - enum A; 18 - enum B = AB(A); 19 -
-53
tests/spec/unit/globals/lex_chain/globals_lex_chain.mzn
··· 1 - /*** 2 - !Test 3 - expected: 4 - - !Result 5 - solution: !Solution 6 - lex_members_int: 7 - - 6 8 - - 0 9 - - 0 10 - lex_members_bool: 11 - - false 12 - ***/ 13 - 14 - include "lex_chain_lesseq.mzn"; 15 - include "lex_chain_less.mzn"; 16 - include "lex_chain_greatereq.mzn"; 17 - include "lex_chain_greater.mzn"; 18 - 19 - %-----------------------------------------------------------------------------% 20 - % lex_chain variants 21 - %-----------------------------------------------------------------------------% 22 - 23 - array[int, int] of var 0..6: arr1 = [| 24 - 5, 5, _ | 25 - 4, 4, 3 | 26 - 2, 5, 3 |]; 27 - constraint lex_chain(arr1); 28 - 29 - array[int, int] of var bool: arr2 = [| 30 - true, true, true | 31 - _, true, true | 32 - false, false, true |]; 33 - constraint lex_chain_less(arr2); 34 - 35 - array[int, int] of var 0..6: arr3 = [| 36 - 5, 1, _ | 37 - 4, 4, 5 | 38 - 2, 5, 5 |]; 39 - constraint lex_chain_greatereq(arr3); 40 - 41 - array[int, int] of var 0..6: arr4 = [| 42 - 5, 1, _ | 43 - 4, 4, 4 | 44 - 2, 5, 5 |]; 45 - constraint lex_chain_greater(arr4); 46 - 47 - solve satisfy; 48 - 49 - array [int] of int: lex_members_int :: output_only :: add_to_output = 50 - [fix(arr1[1, 3]), fix(arr3[1, 3]), fix(arr4[1, 3])]; 51 - 52 - array [int] of bool: lex_members_bool :: output_only :: add_to_output = 53 - [fix(arr2[2, 1])];
-48
tests/spec/unit/globals/lex_chain/globals_lex_chain__orbitope.mzn
··· 1 - /*** 2 - !Test 3 - solvers: [gecode, cbc, scip] 4 - expected: 5 - - !Result 6 - solution: !Solution 7 - lex_members_int: 8 - - 1 9 - - 0 10 - - 1 11 - lex_members_bool: 12 - - false 13 - - false 14 - ***/ 15 - 16 - include "lex_chain_lesseq_orbitope.mzn"; 17 - include "lex_chain_greatereq_orbitope.mzn"; 18 - 19 - %-----------------------------------------------------------------------------% 20 - % lex_chain_..._orbitope variants 21 - %-----------------------------------------------------------------------------% 22 - 23 - array[int, int] of var 0..1: arr1 = [| 24 - 0, 0, _ | 25 - 1, 1, 0 | 26 - 0, 1, 0 |]; 27 - constraint lex_chain_lesseq_orbitope(arr1, 0); 28 - 29 - array[int, int] of var bool: arr2 = [| 30 - false, false, true | 31 - _, false, false| 32 - false, true, _ |]; 33 - constraint lex_chain_lesseq_orbitope(arr2, 2); 34 - 35 - array[int, int] of var 0..1: arr3 = [| 36 - 1, 0, _ | 37 - 0, 1, 0 | 38 - 0, _, 0 |]; 39 - constraint lex_chain_greatereq_orbitope(arr3, 1); 40 - 41 - 42 - solve satisfy; 43 - 44 - array [int] of int: lex_members_int :: output_only :: add_to_output = 45 - [fix(arr1[1, 3]), fix(arr3[1, 3]), fix(arr3[3, 2])]; 46 - 47 - array [int] of bool: lex_members_bool :: output_only :: add_to_output = 48 - [fix(arr2[2, 1]), fix(arr2[3, 3])];
-6
tests/spec/unit/json/json_enum_def.json
··· 1 - { 2 - "P": ["A", "B", "C"], 3 - "Q": [{"e": "D"}, {"e": "E"}, {"e": "F"}], 4 - "R": {"set": ["G", "H", "I"]}, 5 - "S": {"set": [{"e": "J"}, {"e": "K"}, {"e": "L"}]} 6 - }
-24
tests/spec/unit/json/json_enum_def.mzn
··· 1 - /*** 2 - !Test 3 - extra_files: 4 - - json_enum_def.json 5 - solvers: [gecode] 6 - expected: !Result 7 - solution: !Solution 8 - w: A 9 - x: D 10 - y: G 11 - z: J 12 - ***/ 13 - 14 - enum P; 15 - enum Q; 16 - enum R; 17 - enum S; 18 - 19 - var P: w; 20 - var Q: x; 21 - var R: y; 22 - var S: z; 23 - 24 - solve minimize w + x + y + z;
-4
tests/spec/unit/optional/test_bug_456.fzn
··· 1 - var bool: X_INTRODUCED_0_ ::var_is_introduced :: output_var; 2 - var int: X_INTRODUCED_1_ ::var_is_introduced :: output_var; 3 - constraint int_le(0,X_INTRODUCED_1_); 4 - solve satisfy;
-15
tests/spec/unit/optional/test_bug_456.mzn
··· 1 - /*** 2 - !Test 3 - check_against: [] 4 - expected: 5 - - !FlatZinc 'test_bug_456.fzn' 6 - extra_files: [] 7 - markers: [] 8 - name: '' 9 - options: 10 - all_solutions: false 11 - solvers: [gecode] 12 - type: compile 13 - ***/ 14 - 15 - var opt 0..infinity: dummy;
-20
tests/spec/unit/output/dzn_output_array.mzn
··· 1 - /*** 2 - !Test 3 - type: output-model 4 - solvers: [gecode] 5 - expected: !OutputModel dzn_output_array.ozn 6 - ***/ 7 - 8 - enum Foo = { A, B, C }; 9 - 10 - var bool: x; 11 - array [Foo] of var bool: a :: add_to_output = array1d(Foo, [x, x, x]); 12 - array [1..3] of var bool: b :: add_to_output = [x, x, x]; 13 - array [int] of var bool: c :: add_to_output = [x]; 14 - 15 - array [Foo] of bool: d :: output_only :: add_to_output = array1d(Foo, [fix(x), fix(x), fix(x)]); 16 - array [int] of bool: e :: output_only :: add_to_output = [fix(x)]; 17 - array [2..3] of bool: f :: output_only :: add_to_output = array1d(2..3, [fix(x), fix(x)]); 18 - array [int] of bool: g :: output_only :: add_to_output = [fix(x) | i in 1..3]; 19 - 20 - array [1..2, int] of bool: h :: output_only :: add_to_output = array2d(1..2, 2..3, [fix(x) | i in 1..4]);
-11
tests/spec/unit/output/dzn_output_array.ozn
··· 1 - output ["a = array1d(Foo, ",show(a),");\n","b = array1d(1..3, ",show(b),");\n","c = array1d(1..1, ",show(c),");\n","d = array1d(Foo, ",show(d),");\n","e = array1d(",show(index_set(e)),", ",show(e),");\n","f = array1d(2..3, ",show(f),");\n","g = array1d(",show(index_set(g)),", ",show(g),");\n","h = array2d(1..2, ",show(index_set_2of2(h)),", ",show(h),");\n"]; 2 - set of int: Foo = 1..3; 3 - bool: x; 4 - array [Foo] of bool: a = array1d(Foo,[x,x,x]); 5 - array [1..3] of bool: b = [x,x,x]; 6 - array [int] of bool: c = [x]; 7 - array [Foo] of bool: d = array1d(Foo,[fix(x),fix(x),fix(x)]); 8 - array [int] of bool: e = [fix(x)]; 9 - array [2..3] of bool: f = array1d(2..3,[fix(x),fix(x)]); 10 - array [int] of bool: g = [fix(x) | i in 1..3, ]; 11 - array [1..2,int] of bool: h = array2d(1..2,2..3,[fix(x) | i in 1..4, ]);
-15
tests/spec/unit/regression/coercion_par.mzn
··· 1 - /*** 2 - !Test 3 - solvers: [gecode] 4 - expected: !Result 5 - solution: !Solution 6 - x: [1, null] 7 - y: [1.0, null] 8 - z: [0.0, null] 9 - ***/ 10 - 11 - % Previously crashed due to using var bool2int/bool2float since par version was missing 12 - 13 - array [int] of opt int: x :: add_to_output = [true, <>]; 14 - array [int] of opt float: y :: add_to_output = [1, <>]; 15 - array [int] of opt float: z :: add_to_output = [false, <>];
-5
tests/spec/unit/regression/cse_array_lit.fzn
··· 1 - array [1..2] of int: X_INTRODUCED_0_ = [1,-1]; 2 - var 1..10: x:: output_var; 3 - var 1..10: y:: output_var; 4 - constraint int_lin_le(X_INTRODUCED_0_,[x,y],-1); 5 - solve satisfy;
-17
tests/spec/unit/regression/cse_array_lit.mzn
··· 1 - /*** 2 - !Test 3 - type: compile 4 - solvers: [gecode] 5 - expected: !FlatZinc cse_array_lit.fzn 6 - ***/ 7 - 8 - % Regression test for #458 9 - 10 - % In 2.5.4, par arrays were not inserted into the CSE, 11 - % leading to duplicate variables and constraints in the FlatZinc. 12 - 13 - var 1..10: x; 14 - var 1..10: y; 15 - 16 - constraint x < y; 17 - constraint x < y;
+2 -2
tests/spec/unit/regression/flatten_comp_in.mzn
··· 8 8 9 9 % Previously we would only eval_array_lit on the in part 10 10 11 - array[int] of var bool: x :: add_to_output = [y=1 | y in let { 12 - array [1..1] of var 1..2: z; 11 + array[int] of var bool: x :: add_to_output = [y | y in let { 12 + array [1..1] of var bool: z; 13 13 } in z]; 14 14 15 15 constraint x[1];
+3 -3
tests/spec/unit/regression/flatten_comp_in2.mzn
··· 9 9 bs: [true, false, true, false] 10 10 ***/ 11 11 12 - function array[int] of var int: func() = 12 + function array[int] of var bool: func() = 13 13 let { 14 - array[1..2] of var 1..2: x; 14 + array[1..2] of var bool: x; 15 15 } in x; 16 16 17 17 array[1..2] of var bool: as; 18 - array[1..4] of var bool: bs ::add_to_output = [ a \/ x=1 | a in as, x in func() ]; 18 + array[1..4] of var bool: bs ::add_to_output = [ a \/ x | a in as, x in func() ]; 19 19 20 20 constraint bs[1] != bs[2]; 21 21 constraint bs[2] != bs[3];
-19
tests/spec/unit/regression/test_equality_of_indirect_annotations.mzn
··· 1 - /*** 2 - !Test 3 - strict: true 4 - expected: !Result 5 - status: SATISFIED 6 - ***/ 7 - 8 - % Equality of annotation expression was failing if the annotation was an input argument (behind some indirection) 9 - ann: some_ann; 10 - ann: another_ann; 11 - function bool: is_some_ann(ann: input_ann) = 12 - input_ann == some_ann; 13 - 14 - constraint is_some_ann(some_ann); 15 - 16 - % constraint trace("some_ann == some_ann \(some_ann == some_ann)\n"); % true :) 17 - % constraint trace("some_ann == another_ann \(some_ann == another_ann)\n"); % false :) 18 - % constraint trace("is_some_ann(some_ann) \(is_some_ann(some_ann))\n"); % was false :( 19 - % constraint trace("is_some_ann(another_ann) \(is_some_ann(another_ann))\n"); % false :)