Merge commit 'fad1b0701819594e9eaaa4fd50a9d7e6dd187510' as 'software/minizinc'
21
software/minizinc/.clang-format
Normal file
@ -0,0 +1,21 @@
|
||||
---
|
||||
BasedOnStyle: Google
|
||||
|
||||
ColumnLimit: 100
|
||||
DerivePointerAlignment: false
|
||||
AccessModifierOffset: -2
|
||||
|
||||
IncludeBlocks: Regroup
|
||||
IncludeCategories:
|
||||
- Regex: '^(<minizinc/)'
|
||||
Priority: 0
|
||||
SortPriority: 0
|
||||
- Regex: '^(<(coin|geas|gecode|ilcplex|scip)/)'
|
||||
Priority: 3
|
||||
SortPriority: 3
|
||||
- Regex: '^(<)'
|
||||
Priority: 2
|
||||
SortPriority: 2
|
||||
- Regex: '.*'
|
||||
Priority: 1
|
||||
SortPriority: 1
|
40
software/minizinc/.clang-tidy
Normal file
@ -0,0 +1,40 @@
|
||||
---
|
||||
Checks: '-*,
|
||||
bugprone-*,
|
||||
modernize-deprecated-headers,
|
||||
modernize-loop-convert,
|
||||
modernize-pass-by-value,
|
||||
modernize-redundant-void-arg,
|
||||
modernize-use-auto,
|
||||
modernize-use-emplace,
|
||||
modernize-use-nullptr,
|
||||
modernize-use-override,
|
||||
performace-*,
|
||||
readability-*,
|
||||
-readability-magic-numbers, # Allow the usage of direct number literals in expressions
|
||||
'
|
||||
WarningsAsErrors: '*'
|
||||
HeaderFilterRegex: 'include/minizinc/[A-Za-z].*'
|
||||
FormatStyle: file
|
||||
CheckOptions:
|
||||
- key: readability-identifier-naming.ClassCase
|
||||
value: CamelCase
|
||||
- key: readability-identifier-naming.StructCase
|
||||
value: CamelCase
|
||||
- key: readability-identifier-naming.MethodCase
|
||||
value: camelBack
|
||||
- key: readability-identifier-naming.ClassMethodCase
|
||||
value: camelBack
|
||||
- key: readability-identifier-naming.FunctionCase
|
||||
value: lower_case
|
||||
- key: readability-identifier-naming.MemberCase
|
||||
value: camelBack
|
||||
- key: readability-identifier-naming.PrivateMemberCase
|
||||
value: camelBack
|
||||
- key: readability-identifier-naming.PrivateMemberPrefix
|
||||
value: _
|
||||
- key: readability-identifier-naming.ProtectedMemberCase
|
||||
value: camelBack
|
||||
- key: readability-identifier-naming.ProtectedMemberPrefix
|
||||
value: _
|
||||
...
|
35
software/minizinc/.gitignore
vendored
Normal file
@ -0,0 +1,35 @@
|
||||
*.o
|
||||
*~
|
||||
mzn2fzn
|
||||
solns2out
|
||||
makefile
|
||||
Makefile
|
||||
include/minizinc/parser.tab.hh
|
||||
lib/lexer.yy.cpp
|
||||
lib/parser.tab.cpp
|
||||
core
|
||||
build/
|
||||
res/
|
||||
vendor/
|
||||
CMakeCache.txt
|
||||
CMakeFiles
|
||||
CMakeScripts
|
||||
cmake_install.cmake
|
||||
install_manifest.txt
|
||||
libminizinc.build
|
||||
libminizinc.xcodeproj
|
||||
CMakeLists.txt.user
|
||||
*.bak
|
||||
*.out
|
||||
*.err
|
||||
.vscode/c_cpp_properties.json
|
||||
.vscode/ipch
|
||||
tests/output
|
||||
tests/env
|
||||
tests/.pytest_cache
|
||||
__pycache__/
|
||||
.mypy_cache/
|
||||
.vscode/settings.json
|
||||
_build/
|
||||
*.pyc
|
||||
.cache/
|
296
software/minizinc/.gitlab-ci.yml
Normal file
@ -0,0 +1,296 @@
|
||||
stages:
|
||||
- build
|
||||
- test
|
||||
- trigger
|
||||
|
||||
.download_vendor: &download_vendor
|
||||
- curl --location --header "PRIVATE-TOKEN:$ACCESS_TOKEN" --silent https://gitlab.com/api/v4/snippets/1796163/raw | tr -d '\r' > download.sh
|
||||
- sh download.sh vendor master vendor:${MZNARCH} vendor.zip
|
||||
- unzip -q vendor.zip
|
||||
|
||||
.download_vendor_win: &download_vendor_win
|
||||
- curl -o download.sh --location --header "PRIVATE-TOKEN:%ACCESS_TOKEN%" --silent https://gitlab.com/api/v4/snippets/1796163/raw
|
||||
- dos2unix download.sh
|
||||
- sh download.sh vendor master vendor:%MZNARCH% vendor.zip
|
||||
- unzip -q vendor.zip
|
||||
|
||||
.download_bundle: &download_bundle
|
||||
- curl --location --header "PRIVATE-TOKEN:$ACCESS_TOKEN" --silent https://gitlab.com/api/v4/snippets/1796163/raw | tr -d '\r' > download.sh
|
||||
- sh download.sh vendor master bundle:${MZNARCH} vendor.zip
|
||||
- unzip -q vendor.zip
|
||||
|
||||
.download_bundle_win: &download_bundle_win
|
||||
- curl -o download.sh --location --header "PRIVATE-TOKEN:%ACCESS_TOKEN%" --silent https://gitlab.com/api/v4/snippets/1796163/raw
|
||||
- dos2unix download.sh
|
||||
- sh download.sh vendor master bundle:%MZNARCH% vendor.zip
|
||||
- unzip -q vendor.zip
|
||||
|
||||
variables:
|
||||
# CCache settings
|
||||
CCACHE_DIR: "$CI_PROJECT_DIR/.ccache"
|
||||
CCACHE_MAXSIZE: "100M"
|
||||
|
||||
default:
|
||||
interruptible: true
|
||||
|
||||
# ----------- Build MiniZinc -----------
|
||||
|
||||
.build:
|
||||
stage: build
|
||||
before_script:
|
||||
- *download_vendor
|
||||
script:
|
||||
- cmake -S . -B build -G"$CMAKE_ARCH" -DCMAKE_BUILD_TYPE=Release -DBUILD_REF=$CI_PIPELINE_ID -DUSE_PROPRIETARY=OFF -DGecode_ROOT="$CI_PROJECT_DIR/vendor/gecode" -DGurobi_ROOT="$CI_PROJECT_DIR/vendor/gurobi" -DCPlex_ROOT="$CI_PROJECT_DIR/vendor/CPLEX_Studio/cplex" -DOsiCBC_ROOT="$CI_PROJECT_DIR/vendor/cbc" -DSCIP_ROOT="$CI_PROJECT_DIR/vendor/scip" -DXpress_ROOT="$CI_PROJECT_DIR/vendor/xpressmp" -DCMAKE_INSTALL_PREFIX="$CI_PROJECT_DIR/minizinc"
|
||||
- cmake --build build --config Release --target install
|
||||
artifacts:
|
||||
paths: [minizinc/]
|
||||
cache:
|
||||
key: "$CI_JOB_STAGE:$CI_JOB_NAME"
|
||||
paths: [.ccache, vendor.zip*]
|
||||
only: [tags, merge_requests, pipelines, develop, master, feature/on_restart]
|
||||
|
||||
build:linux:
|
||||
extends: .build
|
||||
image: minizinc/build-environment:cpp
|
||||
variables:
|
||||
MZNARCH: "linux"
|
||||
CMAKE_ARCH: "Ninja"
|
||||
tags: [linux, docker]
|
||||
|
||||
build:musl:
|
||||
extends: .build
|
||||
image: minizinc/build-environment:alpine
|
||||
variables:
|
||||
MZNARCH: "musl"
|
||||
CMAKE_ARCH: "Ninja"
|
||||
tags: [linux, docker]
|
||||
|
||||
build:osx:
|
||||
extends: .build
|
||||
variables:
|
||||
MZNARCH: "osx"
|
||||
CMAKE_ARCH: "Ninja"
|
||||
tags: [osx, cmake, cpp]
|
||||
|
||||
build:win64:
|
||||
extends: .build
|
||||
variables:
|
||||
MZNARCH: "win64"
|
||||
CMAKE_ARCH: "Ninja"
|
||||
BUILDCACHE_DIR: "$CI_PROJECT_DIR/.ccache"
|
||||
BUILDCACHE_MAX_CACHE_SIZE: "104857600"
|
||||
before_script:
|
||||
- *download_vendor_win
|
||||
script:
|
||||
- cmake -S . -B build -G"%CMAKE_ARCH%" -DCMAKE_BUILD_TYPE=Release -DBUILD_REF=%CI_PIPELINE_ID% -DCCACHE_PROGRAM:STRING=buildcache -DUSE_PROPRIETARY=OFF -DGecode_ROOT="%CI_PROJECT_DIR%/vendor/gecode" -DGurobi_ROOT="%CI_PROJECT_DIR%/vendor/gurobi" -DCPlex_ROOT="%CI_PROJECT_DIR%/vendor/CPLEX_Studio/cplex" -DOsiCBC_ROOT="%CI_PROJECT_DIR%/vendor/cbc" -DSCIP_ROOT="%CI_PROJECT_DIR%/vendor/scip" -DXpress_ROOT="%CI_PROJECT_DIR%/vendor/xpressmp" -DCMAKE_INSTALL_PREFIX="%CI_PROJECT_DIR%/minizinc"
|
||||
- cmake --build build --config Release --target install
|
||||
cache:
|
||||
key: "build_win64"
|
||||
tags: [win64, cmake, cpp, ninja, buildcache]
|
||||
|
||||
build:wasm_complete:
|
||||
extends: .build
|
||||
image: emscripten/emsdk
|
||||
variables:
|
||||
MZNARCH: "wasm"
|
||||
CMAKE_ARCH: "Unix Makefiles"
|
||||
script:
|
||||
- apt-get update && apt-get install -qq python3
|
||||
- emcmake cmake -S . -B build -G"$CMAKE_ARCH" -DCMAKE_FIND_ROOT_PATH="/" -DCMAKE_BUILD_TYPE=MinSizeRel -v -DBUILD_REF=$CI_PIPELINE_ID -DUSE_PROPRIETARY=OFF -DGecode_ROOT="$CI_PROJECT_DIR/vendor/gecode" -DGurobi_ROOT="$CI_PROJECT_DIR/vendor/gurobi" -DCPlex_ROOT="$CI_PROJECT_DIR/vendor/CPLEX_Studio/cplex" -DOsiCBC_ROOT="$CI_PROJECT_DIR/vendor/cbc" -DSCIP_ROOT="$CI_PROJECT_DIR/vendor/scip" -DXpress_ROOT="$CI_PROJECT_DIR/vendor/xpressmp" -DCMAKE_INSTALL_PREFIX="$CI_PROJECT_DIR/minizinc"
|
||||
- cmake --build build --config MinSizeRel --target install
|
||||
tags: [docker, high-mem]
|
||||
when: manual
|
||||
|
||||
build:wasm_minimal:
|
||||
extends: .build
|
||||
image: emscripten/emsdk
|
||||
variables:
|
||||
MZNARCH: "wasm"
|
||||
CMAKE_ARCH: "Unix Makefiles"
|
||||
script:
|
||||
- apt-get update && apt-get install -qq python3
|
||||
- emcmake cmake -S . -B build -G"$CMAKE_ARCH" -DCMAKE_BUILD_TYPE=MinSizeRel -v -DBUILD_REF=$CI_PIPELINE_ID -DUSE_PROPRIETARY=OFF -DGecode_ROOT="$CI_PROJECT_DIR/vendor/gecode" -DGurobi_ROOT="$CI_PROJECT_DIR/vendor/gurobi" -DCPlex_ROOT="$CI_PROJECT_DIR/vendor/CPLEX_Studio/cplex" -DOsiCBC_ROOT="$CI_PROJECT_DIR/vendor/cbc" -DSCIP_ROOT="$CI_PROJECT_DIR/vendor/scip" -DXpress_ROOT="$CI_PROJECT_DIR/vendor/xpressmp" -DCMAKE_INSTALL_PREFIX="$CI_PROJECT_DIR/minizinc"
|
||||
- cmake --build build --config MinSizeRel --target install
|
||||
tags: [docker]
|
||||
when: manual
|
||||
|
||||
# ----------- Test Suite -----------
|
||||
|
||||
test:format:
|
||||
stage: test
|
||||
image: minizinc/build-environment:clang-format
|
||||
script:
|
||||
- cmake -S . -B build -GNinja -DCLANG_FORMAT_EXECUTABLE="run-clang-format" -DCLANG_FORMAT_FLAGS="--color always"
|
||||
- cmake --build build --target format
|
||||
tags: [linux, docker]
|
||||
only:
|
||||
changes:
|
||||
- "**/*.{cpp,c,h,hh,hpp}"
|
||||
- .clang-format
|
||||
refs:
|
||||
- merge_requests
|
||||
needs: []
|
||||
|
||||
test:analyse:
|
||||
extends: .build
|
||||
stage: test
|
||||
image: minizinc/build-environment:clang-tidy
|
||||
variables:
|
||||
MZNARCH: "linux"
|
||||
CMAKE_ARCH: "Ninja"
|
||||
script:
|
||||
- cmake -S . -B build -G"$CMAKE_ARCH" -DCMAKE_CXX_CLANG_TIDY="clang-tidy" -DCMAKE_BUILD_TYPE="Debug" -DGecode_ROOT="$CI_PROJECT_DIR/vendor/gecode" -DGurobi_ROOT="$CI_PROJECT_DIR/vendor/gurobi" -DCPlex_ROOT="$CI_PROJECT_DIR/vendor/CPLEX_Studio/cplex" -DOsiCBC_ROOT="$CI_PROJECT_DIR/vendor/cbc" -DSCIP_ROOT="$CI_PROJECT_DIR/vendor/scip" -DXpress_ROOT="$CI_PROJECT_DIR/vendor/xpressmp"
|
||||
- cmake --build build --config Debug
|
||||
tags: [linux, docker]
|
||||
only:
|
||||
changes:
|
||||
- "**/*.{cpp,c,h,hh,hpp}"
|
||||
- .clang-tidy
|
||||
refs:
|
||||
- merge_requests
|
||||
needs: []
|
||||
|
||||
.tests:
|
||||
stage: test
|
||||
variables:
|
||||
PIP_CACHE_DIR: "$CI_PROJECT_DIR/.cache/pip"
|
||||
MZN_SOLVER_PATH: "$CI_PROJECT_DIR/vendor/chuffed/share/minizinc/solvers/:$CI_PROJECT_DIR/vendor/gecode"
|
||||
before_script:
|
||||
- *download_bundle
|
||||
# TODO: Add gecode configuration to the Gecode solver
|
||||
- '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'
|
||||
- export PATH=$CI_PROJECT_DIR/minizinc/bin:$PATH
|
||||
- minizinc --solvers
|
||||
- cd tests
|
||||
- python3 -m venv env
|
||||
- source env/bin/activate
|
||||
- pip install -r requirements.txt
|
||||
after_script:
|
||||
- echo "Test results at https://minizinc.gitlab.io/-/minizinc/-/jobs/${CI_JOB_ID}/artifacts/tests/output/report.html"
|
||||
artifacts:
|
||||
when: always
|
||||
paths:
|
||||
- tests/output
|
||||
reports:
|
||||
junit: tests/output/junit*.xml
|
||||
cache:
|
||||
key: "$CI_JOB_STAGE:$CI_JOB_NAME"
|
||||
paths: [.cache/pip, vendor.zip*]
|
||||
only: [merge_requests, pipelines, master]
|
||||
|
||||
# Linux specific config
|
||||
.tests_linux:
|
||||
extends: .tests
|
||||
image: python:latest
|
||||
variables:
|
||||
MZNARCH: "linux"
|
||||
tags: [linux, docker]
|
||||
dependencies: ["build:linux"]
|
||||
needs: ["build:linux"]
|
||||
|
||||
# OSX specific config
|
||||
.tests_osx:
|
||||
extends: .tests
|
||||
variables:
|
||||
MZNARCH: "osx"
|
||||
tags: [osx]
|
||||
dependencies: ["build:osx"]
|
||||
needs: ["build:osx"]
|
||||
|
||||
# Windows specific config
|
||||
.tests_win64:
|
||||
extends: .tests
|
||||
variables:
|
||||
MZNARCH: "win64"
|
||||
MZN_SOLVER_PATH: "$CI_PROJECT_DIR/vendor/chuffed/share/minizinc/solvers;$CI_PROJECT_DIR/vendor/gecode"
|
||||
before_script:
|
||||
- *download_bundle_win
|
||||
# TODO: Add gecode configuration to the Gecode solver
|
||||
- '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'
|
||||
- set PATH=%CI_PROJECT_DIR%/minizinc/bin;%PATH%
|
||||
- cd tests
|
||||
- python -m venv env
|
||||
- call env\Scripts\activate.bat
|
||||
- pip install -r requirements.txt
|
||||
after_script:
|
||||
- "echo Test results at https://minizinc.gitlab.io/-/minizinc/-/jobs/%CI_JOB_ID%/artifacts/tests/output/report.html"
|
||||
tags: [win64]
|
||||
dependencies: ["build:win64"]
|
||||
needs: ["build:win64"]
|
||||
cache:
|
||||
key: test_win64
|
||||
|
||||
.tests_fast:
|
||||
script:
|
||||
- pytest
|
||||
|
||||
.tests_full:
|
||||
script:
|
||||
- pytest --all-suites
|
||||
when: manual
|
||||
|
||||
test:linux:fast:
|
||||
extends: [.tests_linux, .tests_fast]
|
||||
|
||||
test:linux:full:
|
||||
extends: [.tests_linux, .tests_full]
|
||||
|
||||
test:osx:fast:
|
||||
extends: [.tests_osx, .tests_fast]
|
||||
|
||||
test:osx:full:
|
||||
extends: [.tests_osx, .tests_full]
|
||||
|
||||
test:win64:fast:
|
||||
extends: [.tests_win64, .tests_fast]
|
||||
cache:
|
||||
key: test_win64_fast
|
||||
|
||||
test:win64:full:
|
||||
extends: [.tests_win64, .tests_full]
|
||||
cache:
|
||||
key: test_win64_full
|
||||
|
||||
# ----------- Documentation -----------
|
||||
|
||||
documentation:
|
||||
stage: test
|
||||
image: guidotack/sphinx-doc:latest
|
||||
variables:
|
||||
MZNARCH: "linux"
|
||||
before_script:
|
||||
- *download_bundle
|
||||
script:
|
||||
- cp $CI_PROJECT_DIR/share/minizinc/gecode_presolver/gecode.mzn $CI_PROJECT_DIR/share/minizinc/std/
|
||||
- cp $CI_PROJECT_DIR/vendor/chuffed/share/minizinc/chuffed/chuffed.mzn $CI_PROJECT_DIR/share/minizinc/std/
|
||||
- echo 'include "globals.mzn"; include "gecode.mzn"; include "chuffed.mzn";' > $CI_PROJECT_DIR/share/minizinc/std/all.mzn
|
||||
- ./minizinc/bin/mzn2doc --rst-output --include-stdlib --output-base $CI_PROJECT_DIR/docs/en/lib $CI_PROJECT_DIR/share/minizinc/std/all.mzn
|
||||
- ./minizinc/bin/mzn2doc --rst-output --include-stdlib --output-base $CI_PROJECT_DIR/docs/chi/lib $CI_PROJECT_DIR/share/minizinc/std/all.mzn
|
||||
- cd $CI_PROJECT_DIR/docs/en
|
||||
- make html latexpdf
|
||||
- cd $CI_PROJECT_DIR/docs/chi
|
||||
- make html latexpdf
|
||||
- mkdir -p $CI_PROJECT_DIR/docs-deploy/en
|
||||
- mkdir -p $CI_PROJECT_DIR/docs-deploy/chi
|
||||
- cp -r $CI_PROJECT_DIR/docs/en/_build/html/* $CI_PROJECT_DIR/docs-deploy/en/
|
||||
- cp $CI_PROJECT_DIR/docs/en/_build/latex/MiniZinc.pdf $CI_PROJECT_DIR/docs-deploy/en/MiniZinc\ Handbook.pdf
|
||||
- cp -r $CI_PROJECT_DIR/docs/chi/_build/html/* $CI_PROJECT_DIR/docs-deploy/chi/
|
||||
- cp $CI_PROJECT_DIR/docs/chi/_build/latex/MiniZinc.pdf $CI_PROJECT_DIR/docs-deploy/chi/MiniZinc\ Handbook.pdf
|
||||
artifacts:
|
||||
paths:
|
||||
- docs-deploy
|
||||
tags:
|
||||
- linux
|
||||
- docker
|
||||
only: [tags, merge_requests, pipelines, develop, master]
|
||||
dependencies: ["build:linux"]
|
||||
needs: ["build:linux"]
|
||||
|
||||
# ----------- Trigger FindMUS pipeline -----------
|
||||
|
||||
trigger:findmus:
|
||||
stage: trigger
|
||||
trigger:
|
||||
project: minizinc/FindMUS
|
||||
branch: develop
|
||||
only: [develop]
|
108
software/minizinc/CMakeLists.txt
Normal file
@ -0,0 +1,108 @@
|
||||
cmake_minimum_required(VERSION 3.4.0)
|
||||
set(CMAKE_OSX_DEPLOYMENT_TARGET "10.9" CACHE STRING "Minimum OS X deployment version") # Must be before project()
|
||||
|
||||
# -------------------------------------------------------------------------------------------------------------------
|
||||
# -- Project information and versioning.
|
||||
|
||||
project(libminizinc
|
||||
VERSION 2.5.5
|
||||
LANGUAGES CXX C)
|
||||
|
||||
if(NOT BUILD_REF)
|
||||
set(BUILD_REF "")
|
||||
endif()
|
||||
|
||||
# -------------------------------------------------------------------------------------------------------------------
|
||||
# -- Project build options
|
||||
|
||||
# Static vs. Dynamic linking
|
||||
option(CPlex_PLUGIN "Build CPLEX binding as a plugin" ON)
|
||||
option(Gurobi_PLUGIN "Build Gurobi binding as a plugin" ON)
|
||||
|
||||
# Enforce non proprietary build
|
||||
option(USE_PROPRIETARY "Enable static linking of proprietary solvers" OFF)
|
||||
if(NOT USE_PROPRIETARY)
|
||||
set(CPLEX_PLUGIN ON)
|
||||
set(GUROBI_PLUGIN ON)
|
||||
endif()
|
||||
|
||||
# CMake options default value
|
||||
option(CMAKE_POSITION_INDEPENDENT_CODE "Default value for POSITION_INDEPENDENT_CODE of targets" TRUE)
|
||||
|
||||
# -------------------------------------------------------------------------------------------------------------------
|
||||
# -- CMake initialisation
|
||||
|
||||
include(GNUInstallDirs)
|
||||
|
||||
# Fix library suffixes for Web Assembly platform
|
||||
include(cmake/support/emscripten_setup.cmake)
|
||||
|
||||
# Try to find possible dependencies
|
||||
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules)
|
||||
if(POLICY CMP0074)
|
||||
cmake_policy(SET CMP0074 NEW)
|
||||
endif(POLICY CMP0074)
|
||||
find_package(CPlex)
|
||||
find_package(Geas)
|
||||
find_package(Gecode 6.0 COMPONENTS Driver Float Int Kernel Minimodel Search Set Support)
|
||||
find_package(Gurobi)
|
||||
find_package(OsiCBC)
|
||||
find_package(SCIP)
|
||||
find_package(Xpress)
|
||||
|
||||
# Set build type when none is selected
|
||||
set(DEFAULT_BUILD_TYPE "Release")
|
||||
if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
|
||||
message(STATUS "Setting build type to '${DEFAULT_BUILD_TYPE}' as none was specified.")
|
||||
set(CMAKE_BUILD_TYPE "${DEFAULT_BUILD_TYPE}" CACHE STRING "Choose the type of build." FORCE)
|
||||
# Set the possible values of build type for cmake-gui
|
||||
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS
|
||||
"Debug"
|
||||
"Release"
|
||||
"MinSizeRel"
|
||||
"RelWithDebInfo")
|
||||
endif()
|
||||
|
||||
# -------------------------------------------------------------------------------------------------------------------
|
||||
# -- Compiler configuration
|
||||
|
||||
include(cmake/support/ccache_setup.cmake)
|
||||
include(cmake/support/compiler_setup.cmake)
|
||||
|
||||
configure_file(
|
||||
${PROJECT_SOURCE_DIR}/include/minizinc/config.hh.in
|
||||
${PROJECT_BINARY_DIR}/include/minizinc/config.hh
|
||||
)
|
||||
|
||||
install(
|
||||
FILES ${PROJECT_BINARY_DIR}/include/minizinc/config.hh
|
||||
DESTINATION include/minizinc
|
||||
)
|
||||
|
||||
# -------------------------------------------------------------------------------------------------------------------
|
||||
# -- MiniZinc compilation targets.
|
||||
|
||||
find_package(Threads REQUIRED)
|
||||
include_directories(${PROJECT_SOURCE_DIR}/include)
|
||||
include_directories(${PROJECT_BINARY_DIR}/include)
|
||||
|
||||
# Libraries
|
||||
include(cmake/targets/libmzn.cmake)
|
||||
|
||||
# Executables
|
||||
include(cmake/targets/minizinc.cmake)
|
||||
include(cmake/targets/mzn2doc.cmake)
|
||||
|
||||
# -------------------------------------------------------------------------------------------------------------------
|
||||
# -- Platform Specific configuration
|
||||
include(cmake/support/config_emscripten.cmake)
|
||||
|
||||
# -------------------------------------------------------------------------------------------------------------------
|
||||
# -- CMake configuration generation
|
||||
|
||||
include(cmake/support/config_export.cmake)
|
||||
include(cmake/support/config_output.cmake)
|
||||
|
||||
# -------------------------------------------------------------------------------------------------------------------
|
||||
# -- Support Actions
|
||||
include(cmake/support/format.cmake)
|
377
software/minizinc/LICENSE.txt
Normal file
@ -0,0 +1,377 @@
|
||||
If not noted otherwise in individual file headers, all files that make up
|
||||
the libminizinc distribution are released under the Mozilla Public License
|
||||
Version 2.0, a copy of which can be found below.
|
||||
|
||||
Mozilla Public License Version 2.0
|
||||
==================================
|
||||
|
||||
1. Definitions
|
||||
--------------
|
||||
|
||||
1.1. "Contributor"
|
||||
means each individual or legal entity that creates, contributes to
|
||||
the creation of, or owns Covered Software.
|
||||
|
||||
1.2. "Contributor Version"
|
||||
means the combination of the Contributions of others (if any) used
|
||||
by a Contributor and that particular Contributor's Contribution.
|
||||
|
||||
1.3. "Contribution"
|
||||
means Covered Software of a particular Contributor.
|
||||
|
||||
1.4. "Covered Software"
|
||||
means Source Code Form to which the initial Contributor has attached
|
||||
the notice in Exhibit A, the Executable Form of such Source Code
|
||||
Form, and Modifications of such Source Code Form, in each case
|
||||
including portions thereof.
|
||||
|
||||
1.5. "Incompatible With Secondary Licenses"
|
||||
means
|
||||
|
||||
(a) that the initial Contributor has attached the notice described
|
||||
in Exhibit B to the Covered Software; or
|
||||
|
||||
(b) that the Covered Software was made available under the terms of
|
||||
version 1.1 or earlier of the License, but not also under the
|
||||
terms of a Secondary License.
|
||||
|
||||
1.6. "Executable Form"
|
||||
means any form of the work other than Source Code Form.
|
||||
|
||||
1.7. "Larger Work"
|
||||
means a work that combines Covered Software with other material, in
|
||||
a separate file or files, that is not Covered Software.
|
||||
|
||||
1.8. "License"
|
||||
means this document.
|
||||
|
||||
1.9. "Licensable"
|
||||
means having the right to grant, to the maximum extent possible,
|
||||
whether at the time of the initial grant or subsequently, any and
|
||||
all of the rights conveyed by this License.
|
||||
|
||||
1.10. "Modifications"
|
||||
means any of the following:
|
||||
|
||||
(a) any file in Source Code Form that results from an addition to,
|
||||
deletion from, or modification of the contents of Covered
|
||||
Software; or
|
||||
|
||||
(b) any new file in Source Code Form that contains any Covered
|
||||
Software.
|
||||
|
||||
1.11. "Patent Claims" of a Contributor
|
||||
means any patent claim(s), including without limitation, method,
|
||||
process, and apparatus claims, in any patent Licensable by such
|
||||
Contributor that would be infringed, but for the grant of the
|
||||
License, by the making, using, selling, offering for sale, having
|
||||
made, import, or transfer of either its Contributions or its
|
||||
Contributor Version.
|
||||
|
||||
1.12. "Secondary License"
|
||||
means either the GNU General Public License, Version 2.0, the GNU
|
||||
Lesser General Public License, Version 2.1, the GNU Affero General
|
||||
Public License, Version 3.0, or any later versions of those
|
||||
licenses.
|
||||
|
||||
1.13. "Source Code Form"
|
||||
means the form of the work preferred for making modifications.
|
||||
|
||||
1.14. "You" (or "Your")
|
||||
means an individual or a legal entity exercising rights under this
|
||||
License. For legal entities, "You" includes any entity that
|
||||
controls, is controlled by, or is under common control with You. For
|
||||
purposes of this definition, "control" means (a) the power, direct
|
||||
or indirect, to cause the direction or management of such entity,
|
||||
whether by contract or otherwise, or (b) ownership of more than
|
||||
fifty percent (50%) of the outstanding shares or beneficial
|
||||
ownership of such entity.
|
||||
|
||||
2. License Grants and Conditions
|
||||
--------------------------------
|
||||
|
||||
2.1. Grants
|
||||
|
||||
Each Contributor hereby grants You a world-wide, royalty-free,
|
||||
non-exclusive license:
|
||||
|
||||
(a) under intellectual property rights (other than patent or trademark)
|
||||
Licensable by such Contributor to use, reproduce, make available,
|
||||
modify, display, perform, distribute, and otherwise exploit its
|
||||
Contributions, either on an unmodified basis, with Modifications, or
|
||||
as part of a Larger Work; and
|
||||
|
||||
(b) under Patent Claims of such Contributor to make, use, sell, offer
|
||||
for sale, have made, import, and otherwise transfer either its
|
||||
Contributions or its Contributor Version.
|
||||
|
||||
2.2. Effective Date
|
||||
|
||||
The licenses granted in Section 2.1 with respect to any Contribution
|
||||
become effective for each Contribution on the date the Contributor first
|
||||
distributes such Contribution.
|
||||
|
||||
2.3. Limitations on Grant Scope
|
||||
|
||||
The licenses granted in this Section 2 are the only rights granted under
|
||||
this License. No additional rights or licenses will be implied from the
|
||||
distribution or licensing of Covered Software under this License.
|
||||
Notwithstanding Section 2.1(b) above, no patent license is granted by a
|
||||
Contributor:
|
||||
|
||||
(a) for any code that a Contributor has removed from Covered Software;
|
||||
or
|
||||
|
||||
(b) for infringements caused by: (i) Your and any other third party's
|
||||
modifications of Covered Software, or (ii) the combination of its
|
||||
Contributions with other software (except as part of its Contributor
|
||||
Version); or
|
||||
|
||||
(c) under Patent Claims infringed by Covered Software in the absence of
|
||||
its Contributions.
|
||||
|
||||
This License does not grant any rights in the trademarks, service marks,
|
||||
or logos of any Contributor (except as may be necessary to comply with
|
||||
the notice requirements in Section 3.4).
|
||||
|
||||
2.4. Subsequent Licenses
|
||||
|
||||
No Contributor makes additional grants as a result of Your choice to
|
||||
distribute the Covered Software under a subsequent version of this
|
||||
License (see Section 10.2) or under the terms of a Secondary License (if
|
||||
permitted under the terms of Section 3.3).
|
||||
|
||||
2.5. Representation
|
||||
|
||||
Each Contributor represents that the Contributor believes its
|
||||
Contributions are its original creation(s) or it has sufficient rights
|
||||
to grant the rights to its Contributions conveyed by this License.
|
||||
|
||||
2.6. Fair Use
|
||||
|
||||
This License is not intended to limit any rights You have under
|
||||
applicable copyright doctrines of fair use, fair dealing, or other
|
||||
equivalents.
|
||||
|
||||
2.7. Conditions
|
||||
|
||||
Sections 3.1, 3.2, 3.3, and 3.4 are conditions of the licenses granted
|
||||
in Section 2.1.
|
||||
|
||||
3. Responsibilities
|
||||
-------------------
|
||||
|
||||
3.1. Distribution of Source Form
|
||||
|
||||
All distribution of Covered Software in Source Code Form, including any
|
||||
Modifications that You create or to which You contribute, must be under
|
||||
the terms of this License. You must inform recipients that the Source
|
||||
Code Form of the Covered Software is governed by the terms of this
|
||||
License, and how they can obtain a copy of this License. You may not
|
||||
attempt to alter or restrict the recipients' rights in the Source Code
|
||||
Form.
|
||||
|
||||
3.2. Distribution of Executable Form
|
||||
|
||||
If You distribute Covered Software in Executable Form then:
|
||||
|
||||
(a) such Covered Software must also be made available in Source Code
|
||||
Form, as described in Section 3.1, and You must inform recipients of
|
||||
the Executable Form how they can obtain a copy of such Source Code
|
||||
Form by reasonable means in a timely manner, at a charge no more
|
||||
than the cost of distribution to the recipient; and
|
||||
|
||||
(b) You may distribute such Executable Form under the terms of this
|
||||
License, or sublicense it under different terms, provided that the
|
||||
license for the Executable Form does not attempt to limit or alter
|
||||
the recipients' rights in the Source Code Form under this License.
|
||||
|
||||
3.3. Distribution of a Larger Work
|
||||
|
||||
You may create and distribute a Larger Work under terms of Your choice,
|
||||
provided that You also comply with the requirements of this License for
|
||||
the Covered Software. If the Larger Work is a combination of Covered
|
||||
Software with a work governed by one or more Secondary Licenses, and the
|
||||
Covered Software is not Incompatible With Secondary Licenses, this
|
||||
License permits You to additionally distribute such Covered Software
|
||||
under the terms of such Secondary License(s), so that the recipient of
|
||||
the Larger Work may, at their option, further distribute the Covered
|
||||
Software under the terms of either this License or such Secondary
|
||||
License(s).
|
||||
|
||||
3.4. Notices
|
||||
|
||||
You may not remove or alter the substance of any license notices
|
||||
(including copyright notices, patent notices, disclaimers of warranty,
|
||||
or limitations of liability) contained within the Source Code Form of
|
||||
the Covered Software, except that You may alter any license notices to
|
||||
the extent required to remedy known factual inaccuracies.
|
||||
|
||||
3.5. Application of Additional Terms
|
||||
|
||||
You may choose to offer, and to charge a fee for, warranty, support,
|
||||
indemnity or liability obligations to one or more recipients of Covered
|
||||
Software. However, You may do so only on Your own behalf, and not on
|
||||
behalf of any Contributor. You must make it absolutely clear that any
|
||||
such warranty, support, indemnity, or liability obligation is offered by
|
||||
You alone, and You hereby agree to indemnify every Contributor for any
|
||||
liability incurred by such Contributor as a result of warranty, support,
|
||||
indemnity or liability terms You offer. You may include additional
|
||||
disclaimers of warranty and limitations of liability specific to any
|
||||
jurisdiction.
|
||||
|
||||
4. Inability to Comply Due to Statute or Regulation
|
||||
---------------------------------------------------
|
||||
|
||||
If it is impossible for You to comply with any of the terms of this
|
||||
License with respect to some or all of the Covered Software due to
|
||||
statute, judicial order, or regulation then You must: (a) comply with
|
||||
the terms of this License to the maximum extent possible; and (b)
|
||||
describe the limitations and the code they affect. Such description must
|
||||
be placed in a text file included with all distributions of the Covered
|
||||
Software under this License. Except to the extent prohibited by statute
|
||||
or regulation, such description must be sufficiently detailed for a
|
||||
recipient of ordinary skill to be able to understand it.
|
||||
|
||||
5. Termination
|
||||
--------------
|
||||
|
||||
5.1. The rights granted under this License will terminate automatically
|
||||
if You fail to comply with any of its terms. However, if You become
|
||||
compliant, then the rights granted under this License from a particular
|
||||
Contributor are reinstated (a) provisionally, unless and until such
|
||||
Contributor explicitly and finally terminates Your grants, and (b) on an
|
||||
ongoing basis, if such Contributor fails to notify You of the
|
||||
non-compliance by some reasonable means prior to 60 days after You have
|
||||
come back into compliance. Moreover, Your grants from a particular
|
||||
Contributor are reinstated on an ongoing basis if such Contributor
|
||||
notifies You of the non-compliance by some reasonable means, this is the
|
||||
first time You have received notice of non-compliance with this License
|
||||
from such Contributor, and You become compliant prior to 30 days after
|
||||
Your receipt of the notice.
|
||||
|
||||
5.2. If You initiate litigation against any entity by asserting a patent
|
||||
infringement claim (excluding declaratory judgment actions,
|
||||
counter-claims, and cross-claims) alleging that a Contributor Version
|
||||
directly or indirectly infringes any patent, then the rights granted to
|
||||
You by any and all Contributors for the Covered Software under Section
|
||||
2.1 of this License shall terminate.
|
||||
|
||||
5.3. In the event of termination under Sections 5.1 or 5.2 above, all
|
||||
end user license agreements (excluding distributors and resellers) which
|
||||
have been validly granted by You or Your distributors under this License
|
||||
prior to termination shall survive termination.
|
||||
|
||||
************************************************************************
|
||||
* *
|
||||
* 6. Disclaimer of Warranty *
|
||||
* ------------------------- *
|
||||
* *
|
||||
* Covered Software is provided under this License on an "as is" *
|
||||
* basis, without warranty of any kind, either expressed, implied, or *
|
||||
* statutory, including, without limitation, warranties that the *
|
||||
* Covered Software is free of defects, merchantable, fit for a *
|
||||
* particular purpose or non-infringing. The entire risk as to the *
|
||||
* quality and performance of the Covered Software is with You. *
|
||||
* Should any Covered Software prove defective in any respect, You *
|
||||
* (not any Contributor) assume the cost of any necessary servicing, *
|
||||
* repair, or correction. This disclaimer of warranty constitutes an *
|
||||
* essential part of this License. No use of any Covered Software is *
|
||||
* authorized under this License except under this disclaimer. *
|
||||
* *
|
||||
************************************************************************
|
||||
|
||||
************************************************************************
|
||||
* *
|
||||
* 7. Limitation of Liability *
|
||||
* -------------------------- *
|
||||
* *
|
||||
* Under no circumstances and under no legal theory, whether tort *
|
||||
* (including negligence), contract, or otherwise, shall any *
|
||||
* Contributor, or anyone who distributes Covered Software as *
|
||||
* permitted above, be liable to You for any direct, indirect, *
|
||||
* special, incidental, or consequential damages of any character *
|
||||
* including, without limitation, damages for lost profits, loss of *
|
||||
* goodwill, work stoppage, computer failure or malfunction, or any *
|
||||
* and all other commercial damages or losses, even if such party *
|
||||
* shall have been informed of the possibility of such damages. This *
|
||||
* limitation of liability shall not apply to liability for death or *
|
||||
* personal injury resulting from such party's negligence to the *
|
||||
* extent applicable law prohibits such limitation. Some *
|
||||
* jurisdictions do not allow the exclusion or limitation of *
|
||||
* incidental or consequential damages, so this exclusion and *
|
||||
* limitation may not apply to You. *
|
||||
* *
|
||||
************************************************************************
|
||||
|
||||
8. Litigation
|
||||
-------------
|
||||
|
||||
Any litigation relating to this License may be brought only in the
|
||||
courts of a jurisdiction where the defendant maintains its principal
|
||||
place of business and such litigation shall be governed by laws of that
|
||||
jurisdiction, without reference to its conflict-of-law provisions.
|
||||
Nothing in this Section shall prevent a party's ability to bring
|
||||
cross-claims or counter-claims.
|
||||
|
||||
9. Miscellaneous
|
||||
----------------
|
||||
|
||||
This License represents the complete agreement concerning the subject
|
||||
matter hereof. If any provision of this License is held to be
|
||||
unenforceable, such provision shall be reformed only to the extent
|
||||
necessary to make it enforceable. Any law or regulation which provides
|
||||
that the language of a contract shall be construed against the drafter
|
||||
shall not be used to construe this License against a Contributor.
|
||||
|
||||
10. Versions of the License
|
||||
---------------------------
|
||||
|
||||
10.1. New Versions
|
||||
|
||||
Mozilla Foundation is the license steward. Except as provided in Section
|
||||
10.3, no one other than the license steward has the right to modify or
|
||||
publish new versions of this License. Each version will be given a
|
||||
distinguishing version number.
|
||||
|
||||
10.2. Effect of New Versions
|
||||
|
||||
You may distribute the Covered Software under the terms of the version
|
||||
of the License under which You originally received the Covered Software,
|
||||
or under the terms of any subsequent version published by the license
|
||||
steward.
|
||||
|
||||
10.3. Modified Versions
|
||||
|
||||
If you create software not governed by this License, and you want to
|
||||
create a new license for such software, you may create and use a
|
||||
modified version of this License if you rename the license and remove
|
||||
any references to the name of the license steward (except to note that
|
||||
such modified license differs from this License).
|
||||
|
||||
10.4. Distributing Source Code Form that is Incompatible With Secondary
|
||||
Licenses
|
||||
|
||||
If You choose to distribute Source Code Form that is Incompatible With
|
||||
Secondary Licenses under the terms of this version of the License, the
|
||||
notice described in Exhibit B of this License must be attached.
|
||||
|
||||
Exhibit A - Source Code Form License Notice
|
||||
-------------------------------------------
|
||||
|
||||
This Source Code Form is subject to the terms of the Mozilla Public
|
||||
License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
If it is not possible or desirable to put the notice in a particular
|
||||
file, then You may include the notice in a location (such as a LICENSE
|
||||
file in a relevant directory) where a recipient would be likely to look
|
||||
for such a notice.
|
||||
|
||||
You may add additional accurate notices of copyright ownership.
|
||||
|
||||
Exhibit B - "Incompatible With Secondary Licenses" Notice
|
||||
---------------------------------------------------------
|
||||
|
||||
This Source Code Form is "Incompatible With Secondary Licenses", as
|
||||
defined by the Mozilla Public License, v. 2.0.
|
168
software/minizinc/README.md
Normal file
@ -0,0 +1,168 @@
|
||||
<!-- PROJECT LOGO -->
|
||||
<br />
|
||||
<p align="center">
|
||||
<a href="https://www.minizinc.org/">
|
||||
<img src="https://www.minizinc.org/MiniZn_logo.png" alt="Logo" width="80" height="80">
|
||||
</a>
|
||||
|
||||
<h3 align="center">MiniZinc</h3>
|
||||
|
||||
<p align="center">
|
||||
A high-level constraint modelling language that allows you to easily
|
||||
express and solve discrete optimisation problems.
|
||||
<br />
|
||||
<a href="https://www.minizinc.org/"><strong>Visit our website »</strong></a>
|
||||
<br />
|
||||
<br />
|
||||
<a href="https://www.minizinc.org/doc-latest/">View Documentation</a>
|
||||
·
|
||||
<a href="https://github.com/MiniZinc/libminizinc/issues">Report Bug</a>
|
||||
·
|
||||
<a href="https://github.com/MiniZinc/libminizinc/issues">Request Feature</a>
|
||||
</p>
|
||||
</p>
|
||||
|
||||
|
||||
<!-- TABLE OF CONTENTS -->
|
||||
## Table of Contents
|
||||
|
||||
* [About the Project](#about-the-project)
|
||||
* [Getting Started](#getting-started)
|
||||
* [Installation](#installation)
|
||||
* [Usage](#usage)
|
||||
* [Building](#building)
|
||||
* [Prerequisites](#prerequisites)
|
||||
* [Compilation](#compilation)
|
||||
* [Testing](#testing)
|
||||
* [License](#license)
|
||||
* [Contact](#contact)
|
||||
|
||||
|
||||
<!-- ABOUT THE PROJECT -->
|
||||
## About The Project
|
||||
|
||||
MiniZinc is a free and open-source constraint modeling language.
|
||||
|
||||
You can use MiniZinc to model constraint satisfaction and optimisation problems
|
||||
in a high-level, solver-independent way, taking advantage of a large library of
|
||||
pre-defined constraints. Your model is then compiled into FlatZinc, a solver
|
||||
input language that is understood by a wide range of solvers.
|
||||
|
||||
MiniZinc is developed at Monash University in collaboration with Data61
|
||||
Decision Sciences.
|
||||
|
||||
<!-- GETTING STARTED -->
|
||||
## Getting Started
|
||||
|
||||
To get a MiniZinc up and running follow these simple steps.
|
||||
|
||||
### Installation
|
||||
|
||||
The recommended way to install _MiniZinc_ is by the use of the bundled binary
|
||||
packages. These packages are available for machines running Linux, Mac, and
|
||||
Windows.
|
||||
|
||||
The latest release can be found on [the MiniZinc
|
||||
website](http://www.minizinc.org/software.html).
|
||||
|
||||
### Usage
|
||||
|
||||
Once the MiniZinc bundle is installed on your machine, you can start expressing
|
||||
and solving discrete optimisation problems. The following code segment shows a
|
||||
MiniZinc model for the well known n-queens problem.
|
||||
|
||||
```minizinc
|
||||
int: n = 8; % The number of queens.
|
||||
|
||||
array [1..n] of var 1..n: q;
|
||||
|
||||
include "alldifferent.mzn";
|
||||
|
||||
constraint alldifferent(q);
|
||||
constraint alldifferent(i in 1..n)(q[i] + i);
|
||||
constraint alldifferent(i in 1..n)(q[i] - i);
|
||||
```
|
||||
|
||||
You have two easy options to solve this model:
|
||||
- In the MiniZincIDE: Select your preferred solver and press the "Run" button.
|
||||
- With the `minizinc` executable available on your path: run `minizinc --solver gecode nqueens.mzn`.
|
||||
|
||||
_For more example MiniZinc models and more information about working with
|
||||
MiniZinc, please refer to our
|
||||
[Documentation](https://www.minizinc.org/doc-latest/)_
|
||||
|
||||
<!-- BUILDING INSTRUCTIONS -->
|
||||
## Building
|
||||
|
||||
The following instructions will help you compile the MiniZinc compiler. Note
|
||||
that this repository does not include the IDE, findMUS, or any solvers that are
|
||||
part of the MiniZinc project. These can be found in the following repositories:
|
||||
|
||||
- [MiniZincIDE](https://github.com/MiniZinc/MiniZincIDE)
|
||||
- [Gecode](https://github.com/Gecode/gecode)
|
||||
- [Chuffed](https://github.com/chuffed/chuffed)
|
||||
|
||||
### Prerequisites
|
||||
|
||||
- [CMake](https://cmake.org/) (>=3.4)
|
||||
- A recent C++ compiler - Compilation is tested with recent versions of Clang,
|
||||
GCC, and Microsoft Visual C++.
|
||||
- (optional) [Bison](https://www.gnu.org/software/bison/) (>=3.4) and
|
||||
[Flex](https://github.com/westes/flex) (>=2.5) - To make changes to the
|
||||
MiniZinc lexer or parser.
|
||||
- (optional) [Gecode](https://www.gecode.org/) - To compile the internal Gecode
|
||||
solver interface (included in the MiniZinc bundle)
|
||||
- (optional) [Coin OR's CBC](https://www.coin-or.org/) - To compile the
|
||||
internal CBC solver interface (included in the MiniZinc bundle)
|
||||
- (optional) Proprietary solver headers
|
||||
([CPLEX](https://www.ibm.com/analytics/cplex-optimizer),
|
||||
[Gurobi](https://www.gurobi.com/), [SCIP](https://www.scipopt.org/),
|
||||
[Xpress](https://www.fico.com/)) - To load these solvers at runtime (included
|
||||
in the MiniZinc bundle)
|
||||
|
||||
### Compilation
|
||||
|
||||
The MiniZinc compiler is compiled as a CMake project. CMake's [User Interaction
|
||||
Guide](https://cmake.org/cmake/help/latest/guide/user-interaction/index.html)
|
||||
can provide you with a quick introduction to compiling CMake projects. The
|
||||
following CMake variables can be used in the MiniZinc project to instruct the
|
||||
compilation behaviour:
|
||||
|
||||
| Variable | Default | Description |
|
||||
|----------------------------------------------|---------|-------------------------------------------------------------|
|
||||
| CMAKE_BUILD_TYPE | Release | Build type of single-configuration generators. |
|
||||
| CMAKE_INSTALL_PREFIX | | Install directory used by `--target install`. |
|
||||
| CMAKE_POSITION_INDEPENDENT_CODE | TRUE | Whether to create a position-independent targets |
|
||||
| **<solver_name>**_ROOT | | Additional directory to look for **<solver_name>** |
|
||||
| CMAKE_DISABLE_FIND_PACKAGE_**<solver_name>** | FALSE | Disable compilation of **<solver_name>**'s solver interface |
|
||||
| USE_PROPRIETARY | FALSE | Allow static linking of proprietary solvers |
|
||||
| **<Gurobi/CPlex>**_PLUGIN | TRUE | Load solver at runtime (instead of static compilation) |
|
||||
|
||||
Possible values for **<solver_name>** are `CPlex`, `Geas`, `Gecode`, `Gurobi`,
|
||||
`OsiCBC`, `SCIP`, and `Xpress`.
|
||||
|
||||
<!-- TESTING INSTRUCTIONS -->
|
||||
## Testing
|
||||
|
||||
The correctness of the MiniZinc compiler is tested using a
|
||||
[PyTest](https://docs.pytest.org/en/stable/) test suite. Instruction on how to
|
||||
run the test suite and how to add new tests can be found
|
||||
[here](https://github.com/MiniZinc/libminizinc/tree/master/tests)
|
||||
|
||||
|
||||
<!-- LICENSE -->
|
||||
## License
|
||||
|
||||
Distributed under the Mozilla Public License Version 2.0. See `LICENSE` for more information.
|
||||
|
||||
|
||||
<!-- CONTACT -->
|
||||
## Contact
|
||||
|
||||
🏛 **MiniZinc Community**
|
||||
- Website: [https://www.minizinc.org/](https://www.minizinc.org/)
|
||||
- StackOverflow: [https://stackoverflow.com/questions/tagged/minizinc](https://stackoverflow.com/questions/tagged/minizinc)
|
||||
- Google Groups: [https://groups.google.com/g/minizinc](https://groups.google.com/g/minizinc)
|
||||
|
||||
🏛 **Monash Optimisation Group**
|
||||
- Website: [https://www.monash.edu/it/dsai/optimisation](https://www.monash.edu/it/dsai/optimisation)
|
2259
software/minizinc/changes.rst
Normal file
74
software/minizinc/cmake/modules/FindCPlex.cmake
Normal file
@ -0,0 +1,74 @@
|
||||
# - Try to find CPLEX
|
||||
# Once done this will define
|
||||
# CPLEX_FOUND - System has CPLEX
|
||||
# CPLEX_INCLUDE_DIRS - The CPLEX include directories
|
||||
# CPLEX_LIBRARIES - The libraries needed to use CPLEX
|
||||
# CPLEX_COMPILE_FLAGS - The definitions required to compile with CPLEX
|
||||
# User can set CPlex_ROOT to the preferred installation prefix
|
||||
|
||||
set(CPLEX_COMPILE_FLAGS "-fPIC -fno-strict-aliasing -fexceptions")
|
||||
|
||||
set(CPLEX_VERSIONS 1210 129 128 1271 127 1263 1262 1261 126)
|
||||
|
||||
foreach(VERSION ${CPLEX_VERSIONS})
|
||||
list(APPEND CPLEX_DEFAULT_LOC "/opt/ibm/ILOG/CPLEX_Studio${VERSION}")
|
||||
list(APPEND CPLEX_DEFAULT_LOC "/opt/IBM/ILOG/CPLEX_Studio${VERSION}")
|
||||
list(APPEND CPLEX_DEFAULT_LOC "C:\\Program Files\\IBM\\ILOG\\CPLEX_Studio${VERSION}")
|
||||
list(APPEND CPLEX_DEFAULT_LOC "C:\\Program Files (x86)\\IBM\\ILOG\\CPLEX_Studio${VERSION}")
|
||||
list(APPEND CPLEX_DEFAULT_LOC "$ENV{HOME}/Applications/IBM/ILOG/CPLEX_Studio${VERSION}")
|
||||
list(APPEND CPLEX_DEFAULT_LOC "/Applications/IBM/ILOG/CPLEX_Studio${VERSION}")
|
||||
list(APPEND CPLEX_DEFAULT_LOC "/Applications/CPLEX_Studio${VERSION}")
|
||||
|
||||
list(APPEND CPLEX_LIB_NAMES cplex${VERSION})
|
||||
endforeach(VERSION)
|
||||
|
||||
find_path(CPLEX_INCLUDE ilcplex/cplex.h
|
||||
HINTS ${CPLEX_DEFAULT_LOC}
|
||||
PATH_SUFFIXES include cplex/include)
|
||||
|
||||
if(NOT "${CPLEX_INCLUDE}" STREQUAL "CPLEX_INCLUDE-NOTFOUND")
|
||||
file(READ "${CPLEX_INCLUDE}/ilcplex/cplex.h" CPLEX_CONFIG)
|
||||
string(REGEX MATCH " +\\* +Version +([0-9]+\\.[0-9]+\\.[0-9]+)" _ "${CPLEX_CONFIG}")
|
||||
set(CPLEX_VERSION "${CMAKE_MATCH_1}")
|
||||
unset(CPLEX_CONFIG)
|
||||
endif()
|
||||
|
||||
if(CPLEX_PLUGIN)
|
||||
include(CheckIncludeFiles)
|
||||
# TODO: Cleanup this mess
|
||||
check_include_files(dlfcn.h HAS_DLFCN_H)
|
||||
check_include_files(Windows.h HAS_WINDOWS_H)
|
||||
if(HAS_DLFCN_H)
|
||||
find_library(CPLEX_LIBRARY dl)
|
||||
elseif(HAS_WINDOWS_H)
|
||||
set(CPLEX_LIBRARY ${CPLEX_INCLUDE})
|
||||
endif()
|
||||
else()
|
||||
foreach(CPLEX_LIB ${CPLEX_LIB_NAMES})
|
||||
find_library(CPLEX_LIBRARY NAMES cplex ${CPLEX_LIB}
|
||||
HINTS ${CPLEX_DEFAULT_LOC}
|
||||
PATH_SUFFIXES lib/x86-64_linux/static_pic lib/x86-64_osx/static_pic lib/x64_windows_vs2013/stat_mda cplex/lib/x86-64_linux/static_pic cplex/lib/x86-64_osx/static_pic cplex/lib/x64_windows_vs2013/stat_mda)
|
||||
if(NOT "${CPLEX_LIBRARY}" STREQUAL "CPLEX_LIBRARY-NOTFOUND")
|
||||
break()
|
||||
endif()
|
||||
endforeach(CPLEX_LIB)
|
||||
endif()
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
# handle the QUIETLY and REQUIRED arguments and set CBC_FOUND to TRUE
|
||||
# if all listed variables are TRUE
|
||||
find_package_handle_standard_args(CPlex
|
||||
FOUND_VAR CPLEX_FOUND
|
||||
REQUIRED_VARS CPLEX_INCLUDE CPLEX_LIBRARY
|
||||
VERSION_VAR CPLEX_VERSION
|
||||
FAIL_MESSAGE "Could NOT find CPlex, use CPlex_ROOT to hint its location"
|
||||
)
|
||||
|
||||
if(CPLEX_PLUGIN AND HAS_WINDOWS_H AND NOT HAS_DLFCN_H)
|
||||
unset(CPLEX_LIBRARY)
|
||||
endif()
|
||||
|
||||
mark_as_advanced(CPLEX_INCLUDE CPLEX_LIBRARY)
|
||||
|
||||
set(CPLEX_LIBRARIES ${CPLEX_LIBRARY})
|
||||
set(CPLEX_INCLUDE_DIRS ${CPLEX_INCLUDE})
|
38
software/minizinc/cmake/modules/FindGeas.cmake
Normal file
@ -0,0 +1,38 @@
|
||||
# - Try to find Geas
|
||||
# Once done this will define
|
||||
# GEAS_FOUND - System has Geas
|
||||
# GEAS_INCLUDE_DIRS - The Geas include directories
|
||||
# GEAS_LIBRARIES - The libraries needed to use Geas
|
||||
# User can set Geas_ROOT to the preferred installation prefix
|
||||
# Imported target Geas will be created for linking purposes
|
||||
find_path(
|
||||
GEAS_INCLUDE geas/c/geas.h
|
||||
PATH_SUFFIXES include
|
||||
)
|
||||
|
||||
find_library(
|
||||
GEAS_LIBRARY NAMES geas libgeas
|
||||
PATH_SUFFIXES lib
|
||||
)
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
# handle the QUIETLY and REQUIRED arguments and set GEAS_FOUND to TRUE
|
||||
# if all listed variables are TRUE
|
||||
find_package_handle_standard_args(Geas
|
||||
FOUND_VAR GEAS_FOUND
|
||||
REQUIRED_VARS GEAS_INCLUDE GEAS_LIBRARY
|
||||
FAIL_MESSAGE "Could NOT find Geas, use Geas_ROOT to hint its location"
|
||||
)
|
||||
|
||||
mark_as_advanced(GEAS_INCLUDE GEAS_LIBRARY)
|
||||
|
||||
if(GEAS_FOUND)
|
||||
add_library(Geas UNKNOWN IMPORTED)
|
||||
set_target_properties(Geas PROPERTIES
|
||||
IMPORTED_LOCATION ${GEAS_LIBRARY}
|
||||
INTERFACE_INCLUDE_DIRECTORIES ${GEAS_INCLUDE}
|
||||
)
|
||||
endif()
|
||||
|
||||
set(GEAS_LIBRARIES ${GEAS_LIBRARY})
|
||||
set(GEAS_INCLUDE_DIRS ${GEAS_INCLUDE})
|
83
software/minizinc/cmake/modules/FindGecode.cmake
Normal file
@ -0,0 +1,83 @@
|
||||
# - Try to find Gecode
|
||||
# Once done this will define
|
||||
# GECODE_FOUND - System has Gecode
|
||||
# GECODE_INCLUDE_DIRS - The Gecode include directories
|
||||
# GECODE_LIBRARIES - The libraries needed to use Gecode
|
||||
# GECODE_TARGETS - The names of imported targets created for gecode
|
||||
# User can set Gecode_ROOT to the preferred installation prefix
|
||||
|
||||
find_path(GECODE_INCLUDE gecode/kernel.hh
|
||||
PATH_SUFFIXES include)
|
||||
|
||||
find_file(GECODE_CONFIG_LOC gecode/support/config.hpp
|
||||
HINTS ${GECODE_INCLUDE}
|
||||
PATH_SUFFIXES include)
|
||||
|
||||
if(NOT "${GECODE_CONFIG_LOC}" STREQUAL "GECODE_CONFIG_LOC-NOTFOUND")
|
||||
file(READ "${GECODE_CONFIG_LOC}" GECODE_CONFIG)
|
||||
string(REGEX MATCH "\#define GECODE_VERSION \"([0-9]+.[0-9]+.[0-9]+)\"" _ "${GECODE_CONFIG}")
|
||||
set(GECODE_VERSION "${CMAKE_MATCH_1}")
|
||||
string(REGEX MATCH "\#define GECODE_LIBRARY_VERSION \"([0-9]+-[0-9]+-[0-9]+)\"" _ "${GECODE_CONFIG}")
|
||||
set(GECODE_LIBRARY_VERSION "${CMAKE_MATCH_1}")
|
||||
string(REGEX MATCH "\#define GECODE_STATIC_LIBS ([0-9]+)" _ "${GECODE_CONFIG}")
|
||||
set(GECODE_STATIC_LIBS "${CMAKE_MATCH_1}")
|
||||
string(REGEX MATCH "\#define GECODE_HAS_GIST" GECODE_HAS_GIST "${GECODE_CONFIG}")
|
||||
string(REGEX MATCH "\#define GECODE_HAS_MPFR" GECODE_HAS_MPFR "${GECODE_CONFIG}")
|
||||
unset(GECODE_CONFIG)
|
||||
endif()
|
||||
unset(GECODE_CONFIG_LOC)
|
||||
|
||||
set(GECODE_COMPONENTS Driver Flatzinc Float Int Kernel Minimodel Search Set Support)
|
||||
if(GECODE_HAS_GIST)
|
||||
list(APPEND GECODE_COMPONENTS Gist)
|
||||
endif()
|
||||
|
||||
foreach(GECODE_COMP ${GECODE_COMPONENTS})
|
||||
# Try to find gecode library
|
||||
string(TOLOWER "gecode${GECODE_COMP}" GECODE_LIB)
|
||||
set(GECODE_LIB_LOC "GECODE_LIB_LOC-NOTFOUND")
|
||||
find_library(GECODE_LIB_LOC NAMES ${GECODE_LIB} lib${GECODE_LIB} ${GECODE_LIB}-${GECODE_LIBRARY_VERSION}-r-x64 ${GECODE_LIB}-${GECODE_LIBRARY_VERSION}-d-x64
|
||||
HINTS ${GECODE_INCLUDE}
|
||||
PATH_SUFFIXES lib)
|
||||
if(NOT "${GECODE_LIB_LOC}" STREQUAL "GECODE_LIB_LOC-NOTFOUND")
|
||||
list(APPEND GECODE_LIBRARY ${GECODE_LIB_LOC})
|
||||
add_library(Gecode::${GECODE_COMP} UNKNOWN IMPORTED)
|
||||
set_target_properties(Gecode::${GECODE_COMP} PROPERTIES
|
||||
IMPORTED_LOCATION ${GECODE_LIB_LOC}
|
||||
INTERFACE_INCLUDE_DIRECTORIES ${GECODE_INCLUDE})
|
||||
set(Gecode_FIND_REQUIRED_${GECODE_COMP} TRUE)
|
||||
set(Gecode_${GECODE_COMP}_FOUND TRUE)
|
||||
endif()
|
||||
endforeach(GECODE_COMP)
|
||||
|
||||
if(WIN32 AND GECODE_HAS_GIST AND GECODE_STATIC_LIBS)
|
||||
find_package(Qt5 QUIET COMPONENTS Core Gui Widgets PrintSupport)
|
||||
set_target_properties(Gecode::Gist PROPERTIES
|
||||
INTERFACE_LINK_LIBRARIES "Qt5::Core;Qt5::Gui;Qt5::Widgets;Qt5::PrintSupport")
|
||||
endif()
|
||||
|
||||
unset(GECODE_REQ_LIBS)
|
||||
unset(GECODE_LIB_WIN)
|
||||
unset(GECODE_LIB_LOC)
|
||||
|
||||
if(GECODE_LIBRARY AND GECODE_HAS_MPFR)
|
||||
find_package(MPFR)
|
||||
list(APPEND GECODE_LIBRARY ${MPFR_LIBRARIES})
|
||||
list(APPEND GECODE_TARGETS ${MPFR_LIBRARIES})
|
||||
endif()
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
# handle the QUIETLY and REQUIRED arguments and set GECODE_FOUND to TRUE
|
||||
# if all listed variables are TRUE
|
||||
find_package_handle_standard_args(
|
||||
Gecode
|
||||
REQUIRED_VARS GECODE_INCLUDE GECODE_LIBRARY
|
||||
VERSION_VAR GECODE_VERSION
|
||||
HANDLE_COMPONENTS
|
||||
FAIL_MESSAGE "Could NOT find Gecode, use Gecode_ROOT to hint its location"
|
||||
)
|
||||
|
||||
mark_as_advanced(GECODE_INCLUDE GECODE_LIBRARY)
|
||||
|
||||
set(GECODE_LIBRARIES ${GECODE_LIBRARY})
|
||||
set(GECODE_INCLUDE_DIRS ${GECODE_INCLUDE})
|
82
software/minizinc/cmake/modules/FindGurobi.cmake
Normal file
@ -0,0 +1,82 @@
|
||||
# - Try to find Gurobi
|
||||
# Once done this will define
|
||||
# GUROBI_FOUND - System has GUROBI
|
||||
# GUROBI_INCLUDE_DIRS - The GUROBI include directories
|
||||
# GUROBI_LIBRARIES - The libraries needed to use GUROBI
|
||||
# GUROBI_COMPILE_FLAGS - The definitions required to compile with GUROBI
|
||||
# User can set Gurobi_ROOT to the preferred installation prefix
|
||||
|
||||
option(GUROBI_PLUGIN "Build Gurobi binding as a plugin" ON)
|
||||
|
||||
set(GUROBI_COMPILE_FLAGS "-fPIC -fno-strict-aliasing -fexceptions")
|
||||
|
||||
set(GUROBI_VERSIONS 913 912 911 910 903 902 901 900 811 810 801 752 702)
|
||||
|
||||
foreach(VERSION ${GUROBI_VERSIONS})
|
||||
list(APPEND GUROBI_DEFAULT_LOC "/opt/gurobi${VERSION}/linux64")
|
||||
list(APPEND GUROBI_DEFAULT_LOC "/opt/gurobi${VERSION}/linux64")
|
||||
list(APPEND GUROBI_DEFAULT_LOC "C:\\gurobi${VERSION}\\win64")
|
||||
list(APPEND GUROBI_DEFAULT_LOC "C:\\gurobi${VERSION}\\win32")
|
||||
list(APPEND GUROBI_DEFAULT_LOC "/Library/gurobi${VERSION}/mac64")
|
||||
|
||||
string(SUBSTRING ${VERSION} 0 2 VERSION)
|
||||
list(APPEND GUROBI_LIB_NAMES gurobi${VERSION})
|
||||
endforeach(VERSION)
|
||||
|
||||
find_path(GUROBI_INCLUDE gurobi_c.h
|
||||
PATHS $ENV{GUROBI_HOME}
|
||||
HINTS ${GUROBI_DEFAULT_LOC}
|
||||
PATH_SUFFIXES include)
|
||||
|
||||
if(NOT "${GUROBI_INCLUDE}" STREQUAL "GUROBI_INCLUDE-NOTFOUND")
|
||||
file(READ "${GUROBI_INCLUDE}/gurobi_c.h" GUROBI_CONFIG)
|
||||
string(REGEX MATCH "\#define GRB_VERSION_MAJOR +([0-9]+)" _ "${GUROBI_CONFIG}")
|
||||
set(GRB_VERSION_MAJOR "${CMAKE_MATCH_1}")
|
||||
string(REGEX MATCH "\#define GRB_VERSION_MINOR +([0-9]+)" _ "${GUROBI_CONFIG}")
|
||||
set(GRB_VERSION_MINOR "${CMAKE_MATCH_1}")
|
||||
string(REGEX MATCH "\#define GRB_VERSION_TECHNICAL +([0-9]+)" _ "${GUROBI_CONFIG}")
|
||||
set(GRB_VERSION_TECHNICAL "${CMAKE_MATCH_1}")
|
||||
set(GUROBI_VERSION "${GRB_VERSION_MAJOR}.${GRB_VERSION_MINOR}.${GRB_VERSION_TECHNICAL}")
|
||||
unset(GUROBI_CONFIG)
|
||||
endif()
|
||||
|
||||
if(GUROBI_PLUGIN)
|
||||
include(CheckIncludeFiles)
|
||||
# TODO: Cleanup this mess
|
||||
check_include_files(dlfcn.h HAS_DLFCN_H)
|
||||
check_include_files(Windows.h HAS_WINDOWS_H)
|
||||
if(HAS_DLFCN_H)
|
||||
find_library(GUROBI_LIBRARY dl)
|
||||
elseif(HAS_WINDOWS_H)
|
||||
set(GUROBI_LIBRARY ${GUROBI_INCLUDE})
|
||||
endif()
|
||||
else()
|
||||
foreach(GUROBI_LIB ${GUROBI_LIB_NAMES})
|
||||
find_library(GUROBI_LIBRARY NAMES ${GUROBI_LIB}
|
||||
HINTS $ENV{GUROBI_HOME}
|
||||
PATHS ${GUROBI_DEFAULT_LOC}
|
||||
PATH_SUFFIXES lib)
|
||||
if(NOT "${GUROBI_LIBRARY}" STREQUAL "GUROBI_LIBRARY-NOTFOUND")
|
||||
break()
|
||||
endif()
|
||||
endforeach(GUROBI_LIB)
|
||||
endif()
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
# handle the QUIETLY and REQUIRED arguments and set GUROBI_FOUND to TRUE
|
||||
# if all listed variables are TRUE
|
||||
find_package_handle_standard_args(Gurobi
|
||||
FOUND_VAR GUROBI_FOUND
|
||||
REQUIRED_VARS GUROBI_INCLUDE GUROBI_LIBRARY
|
||||
VERSION_VAR GUROBI_VERSION
|
||||
FAIL_MESSAGE "Could NOT find Gurobi, use Gurobi_ROOT to hint its location"
|
||||
)
|
||||
|
||||
if(GUROBI_PLUGIN AND HAS_WINDOWS_H AND NOT HAS_DLFCN_H)
|
||||
unset(GUROBI_LIBRARY)
|
||||
endif()
|
||||
|
||||
mark_as_advanced(GUROBI_INCLUDE GUROBI_LIBRARY)
|
||||
|
||||
set(GUROBI_LIBRARIES ${GUROBI_LIBRARY})
|
||||
set(GUROBI_INCLUDE_DIRS ${GUROBI_INCLUDE})
|
25
software/minizinc/cmake/modules/FindMPFR.cmake
Normal file
@ -0,0 +1,25 @@
|
||||
### Try to find MPFR
|
||||
# Once done this will define
|
||||
# MPFR_FOUND - System has MPFR
|
||||
# MPFR_INCLUDE_DIRS - The MPFR include directories
|
||||
# MPFR_LIBRARIES - The libraries needed to use MPFR
|
||||
|
||||
find_path(MPFR_INCLUDE NAMES mpfr.h
|
||||
PATHS $ENV{GMPDIR} $ENV{MPFRDIR} ${INCLUDE_INSTALL_DIR})
|
||||
|
||||
find_library(MPFR_LIBRARY mpfr
|
||||
PATHS $ENV{GMPDIR} $ENV{MPFRDIR} ${LIB_INSTALL_DIR})
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
# handle the QUIETLY and REQUIRED arguments and set MPFR_FOUND to TRUE
|
||||
# if all listed variables are TRUE
|
||||
find_package_handle_standard_args(MPFR
|
||||
FOUND_VAR MPFR_FOUND
|
||||
REQUIRED_VARS MPFR_LIBRARY MPFR_INCLUDE
|
||||
FAIL_MESSAGE "Could NOT find MPFR, use MPFR_ROOT to hint its location"
|
||||
)
|
||||
|
||||
mark_as_advanced(MPFR_INCLUDE MPFR_LIBRARY)
|
||||
|
||||
set(MPFR_INCLUDES ${MPFR_INCLUDE})
|
||||
set(MPFR_LIBRARIES ${MPFR_LIBRARY})
|
91
software/minizinc/cmake/modules/FindOsiCBC.cmake
Normal file
@ -0,0 +1,91 @@
|
||||
# - Try to find CBC
|
||||
# Once done this will define
|
||||
# OSICBC_FOUND - System has CBC
|
||||
# OSICBC_INCLUDE_DIRS - The CBC include directories
|
||||
# OSICBC_LIBRARIES - The libraries needed to use CBC
|
||||
# GOSICBC_TARGETS - The names of imported targets created for CBC
|
||||
# User can set OsiCBC_ROOT to the preferred installation prefix
|
||||
|
||||
set(OSICBC_FIND_FILES coin/CbcSolver.hpp coin/CglPreProcess.hpp coin/ClpConfig.h coin/CoinSignal.hpp coin/OsiClpSolverInterface.hpp coin/OsiSolverInterface.hpp)
|
||||
|
||||
foreach(OSICBC_FILE ${OSICBC_FIND_FILES})
|
||||
set(OSICBC_FILE_LOC "OSICBC_LIB_LOC-NOTFOUND")
|
||||
find_path(OSICBC_FILE_LOC ${OSICBC_FILE}
|
||||
PATH_SUFFIXES cbc cgl clp coinutils osi include)
|
||||
if("${OSICBC_FILE_LOC}" STREQUAL "OSICBC_FILE_LOC-NOTFOUND")
|
||||
# message(STATUS "OsiCBC: Could not find file `${OSICBC_FILE}`")
|
||||
set(OSICBC_INCLUDE "")
|
||||
break()
|
||||
endif()
|
||||
list(APPEND OSICBC_INCLUDE ${OSICBC_FILE_LOC})
|
||||
# Add "/coin" for CBC internal dependencies
|
||||
list(APPEND OSICBC_INCLUDE ${OSICBC_FILE_LOC}/coin)
|
||||
endforeach(OSICBC_FILE)
|
||||
|
||||
list(REMOVE_DUPLICATES OSICBC_INCLUDE)
|
||||
unset(OSICBC_FIND_FILES)
|
||||
unset(OSICBC_FILE_LOC)
|
||||
|
||||
find_file(CBC_CONFIG_LOC NAMES coin/config_cbc_default.h coin/CbcConfig.h
|
||||
HINTS ${OSICBC_INCLUDE}
|
||||
PATH_SUFFIXES cbc)
|
||||
|
||||
if(NOT "${CBC_CONFIG_LOC}" STREQUAL "CBC_CONFIG_LOC-NOTFOUND")
|
||||
file(READ "${CBC_CONFIG_LOC}" CBC_CONFIG)
|
||||
string(REGEX MATCH "\#define +CBC_VERSION +\"([0-9]+.[0-9]+)\"" _ "${CBC_CONFIG}")
|
||||
set(OSICBC_VERSION "${CMAKE_MATCH_1}")
|
||||
unset(CBC_CONFIG)
|
||||
endif()
|
||||
unset(CBC_CONFIG_LOC)
|
||||
|
||||
if(WIN32 AND NOT UNIX)
|
||||
set(OSICBC_REQ_LIBS Osi OsiClp OsiCbc Clp Cgl Cbc CbcSolver CoinUtils)
|
||||
else()
|
||||
set(OSICBC_REQ_LIBS CbcSolver Cbc Cgl OsiClp Clp Osi CoinUtils)
|
||||
endif()
|
||||
|
||||
foreach(OSICBC_LIB ${OSICBC_REQ_LIBS})
|
||||
set(OSICBC_LIB_LOC "OSICBC_LIB_LOC-NOTFOUND")
|
||||
find_library(OSICBC_LIB_LOC NAMES ${OSICBC_LIB} lib${OSICBC_LIB}
|
||||
PATH_SUFFIXES lib)
|
||||
if("${OSICBC_LIB_LOC}" STREQUAL "OSICBC_LIB_LOC-NOTFOUND")
|
||||
# message(STATUS "OsiCBC: Could not find library `${OSICBC_LIB}`")
|
||||
set(OSICBC_LIBRARY "")
|
||||
break()
|
||||
endif()
|
||||
list(APPEND OSICBC_LIBRARY ${OSICBC_LIB_LOC})
|
||||
add_library(${OSICBC_LIB} UNKNOWN IMPORTED)
|
||||
set_target_properties(${OSICBC_LIB} PROPERTIES
|
||||
IMPORTED_LOCATION ${OSICBC_LIB_LOC}
|
||||
INTERFACE_INCLUDE_DIRECTORIES "${OSICBC_INCLUDE}")
|
||||
list(APPEND OSICBC_TARGETS ${OSICBC_LIB})
|
||||
endforeach(OSICBC_LIB)
|
||||
|
||||
unset(OSICBC_REQ_LIBS)
|
||||
unset(OSICBC_LIB_LOC)
|
||||
|
||||
if(UNIX AND NOT WIN32 AND NOT DEFINED EMSCRIPTEN)
|
||||
find_package(ZLIB)
|
||||
if(NOT ZLIB_FOUND)
|
||||
message(STATUS "OsiCBC: Missing dependency `Zlib`")
|
||||
set(OSICBC_LIBRARY "")
|
||||
else()
|
||||
list(APPEND OSICBC_LIBRARY ${ZLIB_LIBRARIES})
|
||||
list(APPEND OSICBC_TARGETS ${ZLIB_LIBRARIES})
|
||||
endif()
|
||||
endif()
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
# handle the QUIETLY and REQUIRED arguments and set CBC_FOUND to TRUE
|
||||
# if all listed variables are TRUE
|
||||
find_package_handle_standard_args(OsiCBC
|
||||
FOUND_VAR OSICBC_FOUND
|
||||
REQUIRED_VARS OSICBC_INCLUDE OSICBC_LIBRARY
|
||||
VERSION_VAR OSICBC_VERSION
|
||||
FAIL_MESSAGE "Could NOT find OsiCBC, use OsiCBC_ROOT to hint its location"
|
||||
)
|
||||
|
||||
mark_as_advanced(OSICBC_INCLUDE OSICBC_LIBRARY)
|
||||
|
||||
set(OSICBC_LIBRARIES ${OSICBC_LIBRARY})
|
||||
set(OSICBC_INCLUDE_DIRS ${OSICBC_INCLUDE})
|
39
software/minizinc/cmake/modules/FindSCIP.cmake
Normal file
@ -0,0 +1,39 @@
|
||||
# - Try to find SCIP
|
||||
# Once done this will define
|
||||
# SCIP_FOUND - System has SCIP
|
||||
# SCIP_INCLUDE_DIRS - The SCIP include directories
|
||||
# User can set SCIP_ROOT to the preferred installation prefix
|
||||
|
||||
# We only need headers, since we always compile SCIP as a plugin
|
||||
find_path(SCIP_INCLUDE scip/scip.h
|
||||
PATH_SUFFIXES include)
|
||||
|
||||
find_file(SCIP_CONFIG_LOC scip/config.h
|
||||
HINTS ${SCIP_INCLUDE}
|
||||
PATH_SUFFIXES include)
|
||||
|
||||
if(NOT "${SCIP_CONFIG_LOC}" STREQUAL "SCIP_CONFIG_LOC-NOTFOUND")
|
||||
file(READ "${SCIP_CONFIG_LOC}" SCIP_CONFIG)
|
||||
string(REGEX MATCH "\#define SCIP_VERSION_MAJOR +([0-9]+)" _ "${SCIP_CONFIG}")
|
||||
set(SCIP_VERSION_MAJOR "${CMAKE_MATCH_1}")
|
||||
string(REGEX MATCH "\#define SCIP_VERSION_MINOR +([0-9]+)" _ "${SCIP_CONFIG}")
|
||||
set(SCIP_VERSION_MINOR "${CMAKE_MATCH_1}")
|
||||
string(REGEX MATCH "\#define SCIP_VERSION_PATCH +([0-9]+)" _ "${SCIP_CONFIG}")
|
||||
set(SCIP_VERSION_PATCH "${CMAKE_MATCH_1}")
|
||||
set(SCIP_VERSION "${SCIP_VERSION_MAJOR}.${SCIP_VERSION_MINOR}.${SCIP_VERSION_PATCH}")
|
||||
unset(SCIP_CONFIG)
|
||||
endif()
|
||||
unset(SCIP_CONFIG_LOC)
|
||||
|
||||
# handle the QUIETLY and REQUIRED arguments and set SCIP_FOUND to TRUE
|
||||
# if all listed variables are TRUE
|
||||
find_package_handle_standard_args(SCIP
|
||||
FOUND_VAR SCIP_FOUND
|
||||
REQUIRED_VARS SCIP_INCLUDE
|
||||
VERSION_VAR SCIP_VERSION
|
||||
FAIL_MESSAGE "Could NOT find SCIP, use SCIP_ROOT to hint its location"
|
||||
)
|
||||
|
||||
mark_as_advanced(SCIP_INCLUDE SCIP_CONFIG_LOC)
|
||||
|
||||
set(SCIP_INCLUDE_DIRS ${SCIP_INCLUDE})
|
23
software/minizinc/cmake/modules/FindXpress.cmake
Normal file
@ -0,0 +1,23 @@
|
||||
# - Try to find FICO Xpress
|
||||
# Once done this will define
|
||||
# XPRESS_FOUND - System has FICO Xpress
|
||||
# XPRESS_INCLUDE_DIRS - The FICO Xpress include directories
|
||||
# User can set Xpress_ROOT to the preferred installation prefix
|
||||
|
||||
#TODO: Check default installation locations
|
||||
find_path(XPRESS_INCLUDE xprs.h
|
||||
PATHS $ENV{XPRESSDIR} $ENV{XPRESS} $ENV{XPRESS_DIR}
|
||||
HINTS /opt/xpressmp C:/xpressmp /Applications/FICO\ Xpress/xpressmp
|
||||
PATH_SUFFIXES include)
|
||||
|
||||
# handle the QUIETLY and REQUIRED arguments and set XPRESS_FOUND to TRUE
|
||||
# if all listed variables are TRUE
|
||||
find_package_handle_standard_args(Xpress
|
||||
FOUND_VAR XPRESS_FOUND
|
||||
REQUIRED_VARS XPRESS_INCLUDE
|
||||
FAIL_MESSAGE "Could NOT find Xpress, use Xpress_ROOT to hint its location"
|
||||
)
|
||||
|
||||
mark_as_advanced(XPRESS_INCLUDE)
|
||||
|
||||
set(XPRESS_INCLUDE_DIRS ${XPRESS_INCLUDE})
|
45
software/minizinc/cmake/scripts/md5_gen.cmake
Normal file
@ -0,0 +1,45 @@
|
||||
# Script to update the cached lexer and parser
|
||||
# Run after modifying lexer.lxx and/or parser.yxx
|
||||
#
|
||||
# 1. generate lexer and parser by building libminizinc
|
||||
# 2. run cmake -DPROJECT_SOURCE_DIR=. -DPROJECT_BINARY_DIR=build -P cmake/scripts/md5_gen.cmake
|
||||
# replacing . and build with the source and binary directory
|
||||
# add -DFORCE=ON to force the renewing of generated files when md5's still match.
|
||||
|
||||
option(FORCE "Force the renewing of generated files" OFF)
|
||||
|
||||
macro(MD5 filename md5sum)
|
||||
file(READ "${filename}" RAW_MD5_FILE)
|
||||
string(REGEX REPLACE "\r" "" STRIPPED_MD5_FILE "${RAW_MD5_FILE}")
|
||||
string(MD5 ${md5sum} "${STRIPPED_MD5_FILE}")
|
||||
endmacro(MD5)
|
||||
|
||||
# When updating the cached files, update MD5 sums defined in this file
|
||||
include(${PROJECT_SOURCE_DIR}/lib/cached/md5_cached.cmake)
|
||||
|
||||
MD5("${PROJECT_SOURCE_DIR}/lib/lexer.lxx" lexer_lxx_md5)
|
||||
MD5("${PROJECT_SOURCE_DIR}/lib/parser.yxx" parser_yxx_md5)
|
||||
MD5("${PROJECT_SOURCE_DIR}/lib/support/regex/lexer.lxx" regex_lexer_lxx_md5)
|
||||
MD5("${PROJECT_SOURCE_DIR}/lib/support/regex/parser.yxx" regex_parser_yxx_md5)
|
||||
|
||||
|
||||
if(FORCE OR (NOT "${lexer_lxx_md5}" STREQUAL "${lexer_lxx_md5_cached}"))
|
||||
file(COPY "${PROJECT_BINARY_DIR}/lexer.yy.cpp" DESTINATION "${PROJECT_SOURCE_DIR}/lib/cached")
|
||||
endif()
|
||||
if(FORCE OR (NOT "${parser_yxx_md5}" STREQUAL "${parser_yxx_md5_cached}"))
|
||||
file(COPY "${PROJECT_BINARY_DIR}/parser.tab.cpp" DESTINATION "${PROJECT_SOURCE_DIR}/lib/cached")
|
||||
file(COPY "${PROJECT_BINARY_DIR}/include/minizinc/parser.tab.hh" DESTINATION "${PROJECT_SOURCE_DIR}/lib/cached/minizinc")
|
||||
endif()
|
||||
if(FORCE OR (NOT "${regex_lexer_lxx_md5}" STREQUAL "${regex_lexer_lxx_md5_cached}"))
|
||||
file(COPY "${PROJECT_BINARY_DIR}/regex_lexer.yy.cpp" DESTINATION "${PROJECT_SOURCE_DIR}/lib/cached")
|
||||
endif()
|
||||
if(FORCE OR (NOT "${regex_parser_yxx_md5}" STREQUAL "${regex_parser_yxx_md5_cached}"))
|
||||
file(COPY "${PROJECT_BINARY_DIR}/regex_parser.tab.cpp" DESTINATION "${PROJECT_SOURCE_DIR}/lib/cached")
|
||||
file(COPY "${PROJECT_BINARY_DIR}/include/minizinc/support/regex_parser.tab.hh" DESTINATION "${PROJECT_SOURCE_DIR}/lib/cached/minizinc/support")
|
||||
endif()
|
||||
|
||||
set(MD5_TEMPLATE "set(lexer_lxx_md5_cached \"${lexer_lxx_md5}\")")
|
||||
set(MD5_TEMPLATE "${MD5_TEMPLATE}\nset(parser_yxx_md5_cached \"${parser_yxx_md5}\")")
|
||||
set(MD5_TEMPLATE "${MD5_TEMPLATE}\nset(regex_lexer_lxx_md5_cached \"${regex_lexer_lxx_md5}\")")
|
||||
set(MD5_TEMPLATE "${MD5_TEMPLATE}\nset(regex_parser_yxx_md5_cached \"${regex_parser_yxx_md5}\")")
|
||||
file(WRITE "${PROJECT_SOURCE_DIR}/lib/cached/md5_cached.cmake" ${MD5_TEMPLATE})
|
25
software/minizinc/cmake/support/ccache_setup.cmake
Normal file
@ -0,0 +1,25 @@
|
||||
option(USE_CCACHE "Use ccache to speed up compilation when found on the system" TRUE)
|
||||
|
||||
find_program(CCACHE_PROGRAM ccache)
|
||||
if(USE_CCACHE AND CCACHE_PROGRAM)
|
||||
# Support Unix Makefiles and Ninja
|
||||
set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE "${CCACHE_PROGRAM}")
|
||||
|
||||
# Support for Xcode
|
||||
get_property(RULE_LAUNCH_COMPILE GLOBAL PROPERTY RULE_LAUNCH_COMPILE)
|
||||
if(RULE_LAUNCH_COMPILE AND CMAKE_GENERATOR STREQUAL "Xcode")
|
||||
# Set up wrapper scripts
|
||||
configure_file(cmake/templates/launch-c.in launch-c)
|
||||
configure_file(cmake/templates/launch-cxx.in launch-cxx)
|
||||
execute_process(COMMAND chmod a+rx
|
||||
"${CMAKE_BINARY_DIR}/launch-c"
|
||||
"${CMAKE_BINARY_DIR}/launch-cxx")
|
||||
|
||||
# Set Xcode project attributes to route compilation through our scripts
|
||||
set(CMAKE_XCODE_ATTRIBUTE_CC "${CMAKE_BINARY_DIR}/launch-c")
|
||||
set(CMAKE_XCODE_ATTRIBUTE_CXX "${CMAKE_BINARY_DIR}/launch-cxx")
|
||||
set(CMAKE_XCODE_ATTRIBUTE_LD "${CMAKE_BINARY_DIR}/launch-c")
|
||||
set(CMAKE_XCODE_ATTRIBUTE_LDPLUSPLUS "${CMAKE_BINARY_DIR}/launch-cxx")
|
||||
endif()
|
||||
endif()
|
||||
|
65
software/minizinc/cmake/support/compiler_setup.cmake
Normal file
@ -0,0 +1,65 @@
|
||||
set(CMAKE_CXX_STANDARD 11)
|
||||
|
||||
option(USE_ADDRESS_SANITIZER "Use GCC Address Sanitizer" OFF)
|
||||
if(USE_ADDRESS_SANITIZER)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=address -fno-omit-frame-pointer")
|
||||
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fsanitize=address")
|
||||
endif()
|
||||
|
||||
set(CMAKE_REQUIRED_QUIET $<NOT:${VERBOSE}>)
|
||||
|
||||
include(CheckCXXCompilerFlag)
|
||||
|
||||
set(SAFE_CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS}")
|
||||
check_cxx_compiler_flag(-Werror HAS_WERROR)
|
||||
|
||||
if(HAS_WERROR)
|
||||
set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -Werror")
|
||||
endif()
|
||||
|
||||
check_cxx_source_compiles("int main(void) { static __thread int x; (void)x; return 0;}" HAS_ATTR_THREAD)
|
||||
|
||||
if(NOT HAS_ATTR_THREAD)
|
||||
check_cxx_source_compiles("int main(void) { __declspec(thread) static int x; (void)x; return 0;}" HAS_DECLSPEC_THREAD)
|
||||
endif()
|
||||
|
||||
check_cxx_source_compiles("#include <cstdlib>
|
||||
int main(void) { long long int x = atoll(\"123\"); (void)x; }" HAS_ATOLL)
|
||||
check_cxx_source_compiles("
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#include <libproc.h>
|
||||
#include <unistd.h>
|
||||
|
||||
int main (int argc, char* argv[])
|
||||
{
|
||||
pid_t pid = getpid();
|
||||
char path[PROC_PIDPATHINFO_MAXSIZE];
|
||||
(void) proc_pidpath (pid, path, sizeof(path));
|
||||
return 0;
|
||||
}
|
||||
" HAS_PIDPATH)
|
||||
|
||||
check_cxx_source_compiles("
|
||||
#include <windows.h>
|
||||
int main (int argc, char* argv[]) {
|
||||
char path[MAX_PATH];
|
||||
(void) GetModuleFileName(NULL, path, MAX_PATH);
|
||||
return 0;
|
||||
}" HAS_GETMODULEFILENAME)
|
||||
|
||||
check_cxx_source_compiles("
|
||||
#include <windows.h>
|
||||
int main (int argc, char* argv[]) {
|
||||
(void) GetFileAttributes(NULL);
|
||||
return 0;
|
||||
}" HAS_GETFILEATTRIBUTES)
|
||||
|
||||
check_cxx_source_compiles("
|
||||
#include <string.h>
|
||||
int main (int argc, char* argv[]) {
|
||||
(void) memcpy_s(NULL,0,NULL,0);
|
||||
return 0;
|
||||
}" HAS_MEMCPY_S)
|
58
software/minizinc/cmake/support/config_emscripten.cmake
Normal file
@ -0,0 +1,58 @@
|
||||
if (DEFINED EMSCRIPTEN)
|
||||
add_custom_command(OUTPUT ${PROJECT_BINARY_DIR}/CMakeFiles/file_packager.js
|
||||
COMMAND python3 ${EMSCRIPTEN_ROOT_PATH}/tools/file_packager.py minizinc.data --lz4 --preload ${PROJECT_SOURCE_DIR}/share@/minizinc --from-emcc --js-output=${PROJECT_BINARY_DIR}/CMakeFiles/file_packager.js
|
||||
COMMENT "building data store minizinc.data")
|
||||
|
||||
set(EMSCRIPTEN_CXX_FLAGS "-s MINIZ_NO_ARCHIVE_APIS -s MINIZ_NO_ZLIB_APIS")
|
||||
set(EMSCRIPTEN_LINK_FLAGS " -s FORCE_FILESYSTEM=1 -s LZ4=1 -s MODULARIZE=1 -s EXTRA_EXPORTED_RUNTIME_METHODS=\"['callMain', 'cwrap', 'FS', 'ENV']\" -s DISABLE_EXCEPTION_CATCHING=0 -s ALLOW_MEMORY_GROWTH=1 --no-heap-copy")
|
||||
|
||||
# -------------------------------------------------------------------------------------------------------------------
|
||||
# -- Web Assembly Configuration.
|
||||
|
||||
# MiniZinc main executable
|
||||
em_link_pre_js(minizinc ${PROJECT_SOURCE_DIR}/cmake/support/emscripten_file_packager_patch.js)
|
||||
em_link_pre_js(minizinc ${PROJECT_BINARY_DIR}/CMakeFiles/file_packager.js)
|
||||
|
||||
set_target_properties(minizinc PROPERTIES CXX_FLAGS ${EMSCRIPTEN_CXX_FLAGS})
|
||||
set_target_properties(minizinc PROPERTIES LINK_FLAGS "-s WASM=1 -s EXPORT_NAME=\"'MINIZINC'\" ${EMSCRIPTEN_LINK_FLAGS}")
|
||||
|
||||
install(FILES ${PROJECT_BINARY_DIR}/minizinc.wasm DESTINATION bin)
|
||||
install(FILES ${PROJECT_BINARY_DIR}/minizinc.data DESTINATION bin)
|
||||
|
||||
# mzn2doc executable
|
||||
em_link_pre_js(mzn2doc ${PROJECT_SOURCE_DIR}/cmake/support/emscripten_file_packager_patch.js)
|
||||
em_link_pre_js(mzn2doc ${PROJECT_BINARY_DIR}/CMakeFiles/file_packager.js)
|
||||
|
||||
set_target_properties(mzn2doc PROPERTIES CXX_FLAGS ${EMSCRIPTEN_CXX_FLAGS})
|
||||
set_target_properties(mzn2doc PROPERTIES LINK_FLAGS "-s WASM=1 -s EXPORT_NAME=\"'MZN2DOC'\" ${EMSCRIPTEN_LINK_FLAGS}")
|
||||
install(FILES ${PROJECT_BINARY_DIR}/mzn2doc.wasm DESTINATION bin)
|
||||
|
||||
# -------------------------------------------------------------------------------------------------------------------
|
||||
# -- ASM.js (JavaScript) Configuration.
|
||||
|
||||
# MiniZinc main executable
|
||||
add_executable(minizinc_asm minizinc.cpp)
|
||||
target_link_libraries(minizinc_asm mzn)
|
||||
|
||||
em_link_pre_js(minizinc_asm ${PROJECT_SOURCE_DIR}/cmake/support/emscripten_file_packager_patch.js)
|
||||
em_link_pre_js(minizinc_asm ${PROJECT_BINARY_DIR}/CMakeFiles/file_packager.js)
|
||||
|
||||
set_target_properties(minizinc_asm PROPERTIES CXX_FLAGS ${EMSCRIPTEN_CXX_FLAGS})
|
||||
set_target_properties(minizinc_asm PROPERTIES LINK_FLAGS "-s WASM=0 -s EXPORT_NAME=\"'MINIZINC'\" ${EMSCRIPTEN_LINK_FLAGS}")
|
||||
|
||||
install(TARGETS minizinc_asm RUNTIME DESTINATION bin)
|
||||
install(FILES $<TARGET_FILE_NAME:minizinc_asm>.mem DESTINATION bin)
|
||||
|
||||
# mzn2doc executable
|
||||
add_executable(mzn2doc_asm mzn2doc.cpp)
|
||||
target_link_libraries(mzn2doc_asm mzn)
|
||||
|
||||
em_link_pre_js(mzn2doc_asm ${PROJECT_SOURCE_DIR}/cmake/support/emscripten_file_packager_patch.js)
|
||||
em_link_pre_js(mzn2doc_asm ${PROJECT_BINARY_DIR}/CMakeFiles/file_packager.js)
|
||||
|
||||
set_target_properties(mzn2doc_asm PROPERTIES CXX_FLAGS ${EMSCRIPTEN_CXX_FLAGS})
|
||||
set_target_properties(mzn2doc_asm PROPERTIES LINK_FLAGS "-s WASM=0 -s EXPORT_NAME=\"'MZN2DOC'\" ${EMSCRIPTEN_LINK_FLAGS}")
|
||||
|
||||
install(TARGETS mzn2doc_asm RUNTIME DESTINATION bin)
|
||||
install(FILES $<TARGET_FILE_NAME:mzn2doc_asm>.mem DESTINATION bin)
|
||||
endif()
|
91
software/minizinc/cmake/support/config_export.cmake
Normal file
@ -0,0 +1,91 @@
|
||||
### Export of a CMake configuration for MiniZinc
|
||||
## This allows for "find_package(minizinc)"
|
||||
|
||||
if(WIN32 AND NOT CYGWIN)
|
||||
set(DEF_INSTALL_CMAKE_DIR CMake)
|
||||
else()
|
||||
set(DEF_INSTALL_CMAKE_DIR ${CMAKE_INSTALL_LIBDIR}/cmake)
|
||||
endif()
|
||||
set(INSTALL_CMAKE_DIR ${DEF_INSTALL_CMAKE_DIR}/libminizinc CACHE PATH "Installation directory for CMake files")
|
||||
|
||||
if(NOT IS_ABSOLUTE "${INSTALL_CMAKE_DIR}")
|
||||
set(INSTALL_CMAKE_DIR "${CMAKE_INSTALL_PREFIX}/${INSTALL_CMAKE_DIR}")
|
||||
endif()
|
||||
|
||||
file(RELATIVE_PATH REL_CMAKE_DIR "${CMAKE_INSTALL_PREFIX}"
|
||||
"${INSTALL_CMAKE_DIR}")
|
||||
file(RELATIVE_PATH REL_INCLUDE_DIR "${INSTALL_CMAKE_DIR}"
|
||||
"${CMAKE_INSTALL_PREFIX}/include")
|
||||
|
||||
# Add external (static) dependencies
|
||||
if(TARGET minizinc_geas)
|
||||
install(
|
||||
FILES cmake/modules/FindGeas.cmake
|
||||
DESTINATION ${REL_CMAKE_DIR}
|
||||
COMPONENT dev
|
||||
)
|
||||
set(CONF_DEPENDENCIES "${CONF_DEPENDENCIES}find_dependency(Geas)\n")
|
||||
endif()
|
||||
if(TARGET minizinc_gecode)
|
||||
install(
|
||||
FILES cmake/modules/FindGecode.cmake cmake/modules/FindMPFR.cmake
|
||||
DESTINATION ${REL_CMAKE_DIR}
|
||||
COMPONENT dev
|
||||
)
|
||||
if(GECODE_HAS_GIST)
|
||||
set(_CONF_GIST " Gist")
|
||||
endif()
|
||||
set(CONF_DEPENDENCIES "${CONF_DEPENDENCIES}find_dependency(Gecode 6.0 COMPONENTS Driver Float Int Kernel Minimodel Search Set Support${_CONF_GIST})\n")
|
||||
endif()
|
||||
if(TARGET minizinc_osicbc)
|
||||
install(
|
||||
FILES cmake/modules/FindOsiCBC.cmake
|
||||
DESTINATION ${REL_CMAKE_DIR}
|
||||
COMPONENT dev
|
||||
)
|
||||
set(CONF_DEPENDENCIES "${CONF_DEPENDENCIES}find_dependency(OsiCBC)\n")
|
||||
endif()
|
||||
|
||||
# Add all targets to the build-tree export set
|
||||
export(TARGETS mzn
|
||||
FILE "${PROJECT_BINARY_DIR}/libminizincTargets.cmake")
|
||||
|
||||
# Export the package for use from the build-tree
|
||||
# (this registers the build-tree with a global CMake-registry)
|
||||
export(PACKAGE libminizinc)
|
||||
|
||||
# Create the libminizincConfig.cmake and libminizincConfigVersion files
|
||||
# ... for the build tree
|
||||
set(CONF_INCLUDE_DIRS "${PROJECT_SOURCE_DIR}" "${PROJECT_BINARY_DIR}")
|
||||
configure_file(
|
||||
cmake/templates/libminizincConfig.cmake.in
|
||||
"${PROJECT_BINARY_DIR}/libminizincConfig.cmake"
|
||||
@ONLY
|
||||
)
|
||||
# ... for the install tree
|
||||
set(CONF_INCLUDE_DIRS "\${libminizinc_CMAKE_DIR}/${REL_INCLUDE_DIR}")
|
||||
configure_file(
|
||||
cmake/templates/libminizincConfig.cmake.in
|
||||
"${PROJECT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/libminizincConfig.cmake"
|
||||
@ONLY
|
||||
)
|
||||
# ... for both
|
||||
configure_file(
|
||||
cmake/templates/libminizincConfigVersion.cmake.in
|
||||
"${PROJECT_BINARY_DIR}/libminizincConfigVersion.cmake"
|
||||
@ONLY
|
||||
)
|
||||
|
||||
# Install the libminizincConfig.cmake and libminizincConfigVersion.cmake
|
||||
install(
|
||||
FILES "${PROJECT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/libminizincConfig.cmake" "${PROJECT_BINARY_DIR}/libminizincConfigVersion.cmake"
|
||||
DESTINATION ${REL_CMAKE_DIR}
|
||||
COMPONENT dev
|
||||
)
|
||||
|
||||
# Install the export set for use with the install-tree
|
||||
install(
|
||||
EXPORT libminizincTargets
|
||||
DESTINATION ${REL_CMAKE_DIR}
|
||||
COMPONENT dev
|
||||
)
|
35
software/minizinc/cmake/support/config_output.cmake
Normal file
@ -0,0 +1,35 @@
|
||||
message("\n----- MiniZinc build configuration ----")
|
||||
if(BUILD_REF)
|
||||
set(STR_BUILD_REF "build ${BUILD_REF}")
|
||||
endif()
|
||||
message("MiniZinc version: ${libminizinc_VERSION} ${STR_BUILD_REF}")
|
||||
message("Enabled drivers:")
|
||||
|
||||
if(TARGET minizinc_cplex)
|
||||
if(NOT CPLEX_PLUGIN)
|
||||
set(STR_CPLEX_PLUGIN " (LINKED)")
|
||||
endif()
|
||||
message("\tCPLEX ${CPLEX_VERSION}${STR_CPLEX_PLUGIN}: ${CPLEX_INCLUDE_DIRS}")
|
||||
endif()
|
||||
if(TARGET minizinc_geas)
|
||||
message("\tGeas: ${GEAS_INCLUDE_DIRS}")
|
||||
endif()
|
||||
if(TARGET minizinc_gecode)
|
||||
message("\tGecode ${GECODE_VERSION}: ${GECODE_INCLUDE_DIRS}")
|
||||
endif()
|
||||
if(TARGET minizinc_gurobi)
|
||||
if(NOT GUROBI_PLUGIN)
|
||||
set(STR_GUROBI_PLUGIN " (LINKED)")
|
||||
endif()
|
||||
message("\tGurobi ${GUROBI_VERSION}${STR_GUROBI_PLUGIN}: ${GUROBI_INCLUDE_DIRS}")
|
||||
endif()
|
||||
if(TARGET minizinc_osicbc)
|
||||
message("\tOSICBC ${OSICBC_VERSION}: ${OSICBC_INCLUDE_DIRS}")
|
||||
endif()
|
||||
if(TARGET minizinc_scip)
|
||||
message("\tSCIP ${SCIP_VERSION}: ${SCIP_INCLUDE_DIRS}")
|
||||
endif()
|
||||
if(TARGET minizinc_xpress)
|
||||
message("\tXPress: ${XPRESS_INCLUDE_DIRS}")
|
||||
endif()
|
||||
message("---------------------------------------\n")
|
@ -0,0 +1,44 @@
|
||||
|
||||
function filePackagerPatch_getPreloadedPackageNode(filename) {
|
||||
var fs = require('fs');
|
||||
var path = require('path');
|
||||
filename = path.normalize(path.resolve(__dirname, filename));
|
||||
const buf = fs.readFileSync(filename);
|
||||
// convert to ArrayBuffer
|
||||
return buf.buffer.slice(buf.byteOffset, buf.byteOffset + buf.byteLength);
|
||||
}
|
||||
|
||||
function filePackagerPatch_isNodeOrShell() {
|
||||
var ENVIRONMENT_IS_WEB = typeof window === 'object';
|
||||
var ENVIRONMENT_IS_WORKER = typeof importScripts === 'function';
|
||||
var ENVIRONMENT_IS_NODE = typeof process === 'object' && typeof require === 'function' && !ENVIRONMENT_IS_WEB && !ENVIRONMENT_IS_WORKER;
|
||||
var ENVIRONMENT_IS_SHELL = !ENVIRONMENT_IS_WEB && !ENVIRONMENT_IS_NODE && !ENVIRONMENT_IS_WORKER;
|
||||
return ENVIRONMENT_IS_NODE || ENVIRONMENT_IS_SHELL;
|
||||
}
|
||||
|
||||
if (typeof location === 'undefined') {
|
||||
// create a fake location to overrule the file_packager
|
||||
var location = {
|
||||
pathname: '/'
|
||||
};
|
||||
}
|
||||
|
||||
if (filePackagerPatch_isNodeOrShell()) {
|
||||
Module.getPreloadedPackage = Module.getPreloadedPackage || filePackagerPatch_getPreloadedPackageNode;
|
||||
} else {
|
||||
// need a hack to locate relative file in browser settings for the file packager
|
||||
var wrappee = Module.locateFile || function (path, prefix) {return prefix + path};
|
||||
Module.locateFile = function (path, prefix) {
|
||||
if (prefix || !path.endsWith('.data')) {
|
||||
return wrappee(path, prefix);
|
||||
}
|
||||
// file packager is called before a proper script location decection
|
||||
var base = _scriptDir ? _scriptDir : (typeof importScripts === 'function' ? self.location.href : (typeof document !== 'undefined' && document.currentScript ? document.currentScript.src : ''));
|
||||
if (base.indexOf('blob:') !== 0) {
|
||||
base = base.substr(0, base.lastIndexOf('/') + 1);
|
||||
} else {
|
||||
base = '';
|
||||
}
|
||||
return wrappee(path, base);
|
||||
};
|
||||
}
|
8
software/minizinc/cmake/support/emscripten_setup.cmake
Normal file
@ -0,0 +1,8 @@
|
||||
# Workaround for bug in emscripten cmake:
|
||||
# add .bc (and on macOS .dylib) as library suffixes
|
||||
if (DEFINED EMSCRIPTEN)
|
||||
list(APPEND CMAKE_FIND_LIBRARY_SUFFIXES ".bc")
|
||||
if (CMAKE_HOST_APPLE)
|
||||
list(APPEND CMAKE_FIND_LIBRARY_SUFFIXES ".dylib")
|
||||
endif()
|
||||
endif()
|
27
software/minizinc/cmake/support/format.cmake
Normal file
@ -0,0 +1,27 @@
|
||||
|
||||
if (NOT CLANG_FORMAT_EXECUTABLE)
|
||||
find_program(CLANG_FORMAT_EXECUTABLE NAMES clang-format clang-format-11 clang-format-10 clang-format-9)
|
||||
endif()
|
||||
|
||||
set(CLANG_FORMAT_FLAGS "-i" CACHE STRING "Flags passed to the clang-format executable")
|
||||
|
||||
if (CLANG_FORMAT_EXECUTABLE)
|
||||
file(GLOB_RECURSE FORMAT_FILES
|
||||
${PROJECT_SOURCE_DIR}/*.c
|
||||
${PROJECT_SOURCE_DIR}/*.cpp
|
||||
${PROJECT_SOURCE_DIR}/*.h
|
||||
${PROJECT_SOURCE_DIR}/*.hh
|
||||
${PROJECT_SOURCE_DIR}/*.hpp
|
||||
)
|
||||
list(FILTER FORMAT_FILES EXCLUDE REGEX ${PROJECT_BINARY_DIR}/*)
|
||||
list(FILTER FORMAT_FILES EXCLUDE REGEX ${PROJECT_SOURCE_DIR}/lib/cached/*)
|
||||
list(FILTER FORMAT_FILES EXCLUDE REGEX ${PROJECT_SOURCE_DIR}/lib/thirdparty/*)
|
||||
list(FILTER FORMAT_FILES EXCLUDE REGEX ${PROJECT_SOURCE_DIR}/include/minizinc/thirdparty/*)
|
||||
|
||||
separate_arguments(CLANG_FORMAT_FLAGS_LIST NATIVE_COMMAND ${CLANG_FORMAT_FLAGS})
|
||||
add_custom_target(format
|
||||
COMMAND ${CLANG_FORMAT_EXECUTABLE} ${CLANG_FORMAT_FLAGS_LIST} ${FORMAT_FILES}
|
||||
COMMENT "Running ${CLANG_FORMAT_EXECUTABLE} on all source files"
|
||||
)
|
||||
endif()
|
||||
|
22
software/minizinc/cmake/targets/libminizinc_cplex.cmake
Normal file
@ -0,0 +1,22 @@
|
||||
### MiniZinc CPLEX Solver Target
|
||||
|
||||
if(CPLEX_FOUND)
|
||||
|
||||
### Compile target for the CPlex interface
|
||||
add_library(minizinc_cplex OBJECT
|
||||
solvers/MIP/MIP_cplex_solverfactory.cpp
|
||||
solvers/MIP/MIP_cplex_wrap.cpp
|
||||
|
||||
include/minizinc/solvers/MIP/MIP_cplex_solverfactory.hh
|
||||
include/minizinc/solvers/MIP/MIP_cplex_wrap.hh
|
||||
)
|
||||
set_target_properties(minizinc_cplex PROPERTIES COMPILE_FLAGS ${CPLEX_COMPILE_FLAGS})
|
||||
target_include_directories(minizinc_cplex PRIVATE ${CPLEX_INCLUDE_DIRS})
|
||||
add_dependencies(minizinc_cplex minizinc_mip)
|
||||
|
||||
### Setup correct compilation into the MiniZinc library
|
||||
target_compile_definitions(mzn PRIVATE HAS_CPLEX)
|
||||
target_sources(mzn PRIVATE $<TARGET_OBJECTS:minizinc_cplex>)
|
||||
set_target_properties(mzn PROPERTIES COMPILE_FLAGS ${CPLEX_COMPILE_FLAGS})
|
||||
target_link_libraries(mzn ${CPLEX_LIBRARIES})
|
||||
endif()
|
14
software/minizinc/cmake/targets/libminizinc_fzn.cmake
Normal file
@ -0,0 +1,14 @@
|
||||
### MiniZinc FlatZinc Executable Solver Target
|
||||
|
||||
add_library(minizinc_fzn OBJECT
|
||||
solvers/fzn/fzn_solverfactory.cpp
|
||||
solvers/fzn/fzn_solverinstance.cpp
|
||||
solvers/mzn/mzn_solverfactory.cpp
|
||||
solvers/mzn/mzn_solverinstance.cpp
|
||||
|
||||
include/minizinc/solvers/fzn_solverfactory.hh
|
||||
include/minizinc/solvers/fzn_solverinstance.hh
|
||||
include/minizinc/solvers/mzn_solverfactory.hh
|
||||
include/minizinc/solvers/mzn_solverinstance.hh
|
||||
)
|
||||
add_dependencies(minizinc_fzn minizinc_parser)
|
23
software/minizinc/cmake/targets/libminizinc_geas.cmake
Normal file
@ -0,0 +1,23 @@
|
||||
### MiniZinc Geas Solver Target
|
||||
|
||||
if(GEAS_FOUND)
|
||||
|
||||
### Compile target for the Geas interface
|
||||
add_library(minizinc_geas OBJECT
|
||||
solvers/geas/geas_constraints.cpp
|
||||
solvers/geas/geas_solverfactory.cpp
|
||||
solvers/geas/geas_solverinstance.cpp
|
||||
|
||||
include/minizinc/solvers/geas/geas_constraints.hh
|
||||
include/minizinc/solvers/geas_solverfactory.hh
|
||||
include/minizinc/solvers/geas_solverinstance.hh
|
||||
)
|
||||
target_include_directories(minizinc_geas PRIVATE "${GEAS_INCLUDE_DIRS}")
|
||||
add_dependencies(minizinc_geas minizinc_parser)
|
||||
|
||||
### Setup correct compilation into the MiniZinc library
|
||||
target_compile_definitions(mzn PRIVATE HAS_GEAS)
|
||||
target_sources(mzn PRIVATE $<TARGET_OBJECTS:minizinc_geas>)
|
||||
target_link_libraries(mzn Geas)
|
||||
|
||||
endif()
|
33
software/minizinc/cmake/targets/libminizinc_gecode.cmake
Normal file
@ -0,0 +1,33 @@
|
||||
### MiniZinc Gecode Solver Target
|
||||
|
||||
if(GECODE_FOUND)
|
||||
|
||||
### Compile target for the Gecode interface
|
||||
add_library(minizinc_gecode OBJECT
|
||||
lib/passes/gecode_pass.cpp
|
||||
|
||||
solvers/gecode/aux_brancher.hh
|
||||
solvers/gecode/fzn_space.cpp
|
||||
solvers/gecode/gecode_constraints.cpp
|
||||
solvers/gecode/gecode_solverfactory.cpp
|
||||
solvers/gecode/gecode_solverinstance.cpp
|
||||
|
||||
include/minizinc/passes/gecode_pass.hh
|
||||
include/minizinc/solvers/gecode/fzn_space.hh
|
||||
include/minizinc/solvers/gecode/gecode_constraints.hh
|
||||
include/minizinc/solvers/gecode_solverfactory.hh
|
||||
include/minizinc/solvers/gecode_solverinstance.hh
|
||||
)
|
||||
target_include_directories(minizinc_gecode PRIVATE "${GECODE_INCLUDE_DIRS}")
|
||||
add_dependencies(minizinc_gecode minizinc_parser)
|
||||
|
||||
### Setup correct compilation into the MiniZinc library
|
||||
target_compile_definitions(mzn PRIVATE HAS_GECODE)
|
||||
target_sources(mzn PRIVATE $<TARGET_OBJECTS:minizinc_gecode>)
|
||||
|
||||
target_link_libraries(mzn Gecode::Driver Gecode::Float Gecode::Int Gecode::Kernel Gecode::Search Gecode::Set)
|
||||
if(WIN32 AND GECODE_HAS_GIST)
|
||||
target_link_libraries(mzn Gecode::Gist)
|
||||
endif()
|
||||
|
||||
endif()
|
21
software/minizinc/cmake/targets/libminizinc_gurobi.cmake
Normal file
@ -0,0 +1,21 @@
|
||||
### MiniZinc Gurobi Solver Target
|
||||
|
||||
if(GUROBI_FOUND)
|
||||
|
||||
### Compile target for the Gurobi interface
|
||||
add_library(minizinc_gurobi OBJECT
|
||||
solvers/MIP/MIP_gurobi_solverfactory.cpp
|
||||
solvers/MIP/MIP_gurobi_wrap.cpp
|
||||
|
||||
include/minizinc/solvers/MIP/MIP_gurobi_solverfactory.hh
|
||||
include/minizinc/solvers/MIP/MIP_gurobi_wrap.hh
|
||||
)
|
||||
target_include_directories(minizinc_gurobi PRIVATE ${GUROBI_INCLUDE_DIRS})
|
||||
add_dependencies(minizinc_gurobi minizinc_mip)
|
||||
|
||||
### Setup correct compilation into the MiniZinc library
|
||||
target_compile_definitions(mzn PRIVATE HAS_GUROBI)
|
||||
target_sources(mzn PRIVATE $<TARGET_OBJECTS:minizinc_gurobi>)
|
||||
target_link_libraries(mzn ${GUROBI_LIBRARIES})
|
||||
|
||||
endif()
|
14
software/minizinc/cmake/targets/libminizinc_mip.cmake
Normal file
@ -0,0 +1,14 @@
|
||||
### Compile target for the base MIP interface
|
||||
|
||||
add_library(minizinc_mip OBJECT
|
||||
lib/algorithms/min_cut.cpp
|
||||
lib/utils_savestream.cpp
|
||||
|
||||
solvers/MIP/MIP_solverinstance.cpp
|
||||
|
||||
include/minizinc/plugin.hh
|
||||
include/minizinc/solvers/MIP/MIP_wrap.hh
|
||||
include/minizinc/solvers/MIP/MIP_solverinstance.hh
|
||||
include/minizinc/solvers/MIP/MIP_solverinstance.hpp
|
||||
)
|
||||
add_dependencies(minizinc_mip minizinc_parser)
|
16
software/minizinc/cmake/targets/libminizinc_nl.cmake
Normal file
@ -0,0 +1,16 @@
|
||||
### MiniZinc NonLinear Executable Solver Target
|
||||
|
||||
add_library(minizinc_nl OBJECT
|
||||
solvers/nl/nl_components.cpp
|
||||
solvers/nl/nl_file.cpp
|
||||
solvers/nl/nl_solreader.cpp
|
||||
solvers/nl/nl_solverfactory.cpp
|
||||
solvers/nl/nl_solverinstance.cpp
|
||||
|
||||
include/minizinc/solvers/nl/nl_components.hh
|
||||
include/minizinc/solvers/nl/nl_file.hh
|
||||
include/minizinc/solvers/nl/nl_solreader.hh
|
||||
include/minizinc/solvers/nl/nl_solverfactory.hh
|
||||
include/minizinc/solvers/nl/nl_solverinstance.hh
|
||||
)
|
||||
add_dependencies(minizinc_nl minizinc_parser)
|
25
software/minizinc/cmake/targets/libminizinc_osicbc.cmake
Normal file
@ -0,0 +1,25 @@
|
||||
### MiniZinc OsiCBC Solver Target
|
||||
|
||||
if(OSICBC_FOUND)
|
||||
|
||||
### Compile target for the OsiCBC interface
|
||||
add_library(minizinc_osicbc OBJECT
|
||||
|
||||
solvers/MIP/MIP_osicbc_solverfactory.cpp
|
||||
solvers/MIP/MIP_osicbc_wrap.cpp
|
||||
|
||||
include/minizinc/solvers/MIP/MIP_osicbc_solverfactory.hh
|
||||
include/minizinc/solvers/MIP/MIP_osicbc_wrap.hh
|
||||
)
|
||||
target_include_directories(minizinc_osicbc PRIVATE ${OSICBC_INCLUDE_DIRS})
|
||||
add_dependencies(minizinc_osicbc minizinc_mip)
|
||||
if (UNIX AND NOT WIN32)
|
||||
target_compile_definitions(minizinc_osicbc PRIVATE HAVE_CONFIG_H)
|
||||
endif()
|
||||
|
||||
### Setup correct compilation into the MiniZinc library
|
||||
target_compile_definitions(mzn PRIVATE HAS_OSICBC)
|
||||
target_sources(mzn PRIVATE $<TARGET_OBJECTS:minizinc_osicbc>)
|
||||
target_link_libraries(mzn ${OSICBC_TARGETS})
|
||||
|
||||
endif()
|
114
software/minizinc/cmake/targets/libminizinc_parser.cmake
Normal file
@ -0,0 +1,114 @@
|
||||
# -------------------------------------------------------------------------------------------------------------------
|
||||
## Parser Generation Targets
|
||||
|
||||
# When updating the cached files, update MD5 sums defined in this file
|
||||
include(${PROJECT_SOURCE_DIR}/lib/cached/md5_cached.cmake)
|
||||
|
||||
macro(MD5 filename md5sum)
|
||||
file(READ "${filename}" RAW_MD5_FILE)
|
||||
string(REGEX REPLACE "\r" "" STRIPPED_MD5_FILE "${RAW_MD5_FILE}")
|
||||
string(MD5 ${md5sum} "${STRIPPED_MD5_FILE}")
|
||||
endmacro(MD5)
|
||||
|
||||
find_package(BISON 3.4)
|
||||
find_package(FLEX 2.5)
|
||||
|
||||
if(BISON_FOUND AND FLEX_FOUND)
|
||||
BISON_TARGET(MZNParser
|
||||
${PROJECT_SOURCE_DIR}/lib/parser.yxx
|
||||
${PROJECT_BINARY_DIR}/parser.tab.cpp
|
||||
DEFINES_FILE ${PROJECT_BINARY_DIR}/include/minizinc/parser.tab.hh
|
||||
COMPILE_FLAGS "-p mzn_yy -l"
|
||||
)
|
||||
|
||||
file(MAKE_DIRECTORY ${PROJECT_BINARY_DIR}/include/minizinc/support/)
|
||||
BISON_TARGET(RegExParser
|
||||
${PROJECT_SOURCE_DIR}/lib/support/regex/parser.yxx
|
||||
${PROJECT_BINARY_DIR}/regex_parser.tab.cpp
|
||||
DEFINES_FILE ${PROJECT_BINARY_DIR}/include/minizinc/support/regex_parser.tab.hh
|
||||
COMPILE_FLAGS "-p regex_yy -l"
|
||||
)
|
||||
|
||||
FLEX_TARGET(MZNLexer
|
||||
${PROJECT_SOURCE_DIR}/lib/lexer.lxx
|
||||
${PROJECT_BINARY_DIR}/lexer.yy.cpp
|
||||
COMPILE_FLAGS "-P mzn_yy -L"
|
||||
)
|
||||
ADD_FLEX_BISON_DEPENDENCY(MZNLexer MZNParser)
|
||||
|
||||
FLEX_TARGET(RegExLexer
|
||||
${PROJECT_SOURCE_DIR}/lib/support/regex/lexer.lxx
|
||||
${PROJECT_BINARY_DIR}/regex_lexer.yy.cpp
|
||||
COMPILE_FLAGS "-P regex_yy -L"
|
||||
)
|
||||
ADD_FLEX_BISON_DEPENDENCY(RegExLexer RegExParser)
|
||||
else()
|
||||
MD5(${PROJECT_SOURCE_DIR}/lib/parser.yxx parser_yxx_md5)
|
||||
if(NOT "${parser_yxx_md5}" STREQUAL "${parser_yxx_md5_cached}")
|
||||
message(FATAL_ERROR
|
||||
"The file parser.yxx has been modified but bison cannot be run.\n"
|
||||
"If you are sure parser.tab.cpp and minizinc/parser.tab.hh in ${PROJECT_SOURCE_DIR}/lib/cached/ are correct "
|
||||
"then copy parser.yxx's md5 ${parser_yxx_md5} into ${PROJECT_SOURCE_DIR}/lib/cached/md5_cached.cmake"
|
||||
)
|
||||
endif()
|
||||
|
||||
MD5(${PROJECT_SOURCE_DIR}/lib/support/regex/parser.yxx regex_parser_yxx_md5)
|
||||
if(NOT "${regex_parser_yxx_md5}" STREQUAL "${regex_parser_yxx_md5_cached}")
|
||||
message(FATAL_ERROR
|
||||
"The file regex/parser.yxx has been modified but bison cannot be run.\n"
|
||||
"If you are sure regex_parser.tab.cpp and minizinc/support/regex_parser.tab.hh in "
|
||||
"${PROJECT_SOURCE_DIR}/lib/cached/ are correct then copy regex_parser.yxx's md5 ${regex_parser_yxx_md5} into "
|
||||
"${PROJECT_SOURCE_DIR}/lib/cached/md5_cached.cmake"
|
||||
)
|
||||
endif()
|
||||
|
||||
MD5(${PROJECT_SOURCE_DIR}/lib/lexer.lxx lexer_lxx_md5)
|
||||
if(NOT "${lexer_lxx_md5}" STREQUAL "${lexer_lxx_md5_cached}")
|
||||
message(FATAL_ERROR
|
||||
"The file lexer.lxx has been modified but flex cannot be run.\n"
|
||||
"If you are sure ${PROJECT_SOURCE_DIR}/lib/cached/lexer.yy.cpp is correct then "
|
||||
"copy lexer.lxx's md5 ${lexer_lxx_md5} into ${PROJECT_SOURCE_DIR}/lib/cached/md5_cached.cmake"
|
||||
)
|
||||
endif()
|
||||
|
||||
MD5(${PROJECT_SOURCE_DIR}/lib/support/regex/lexer.lxx regex_lexer_lxx_md5)
|
||||
if(NOT "${regex_lexer_lxx_md5}" STREQUAL "${regex_lexer_lxx_md5_cached}")
|
||||
message(FATAL_ERROR
|
||||
"The file regex/lexer.lxx has been modified but flex cannot be run.\n"
|
||||
"If you are sure ${PROJECT_SOURCE_DIR}/lib/cached/regex_lexer.yy.cpp is correct then "
|
||||
"copy regex/lexer.lxx's md5 ${regex_lexer_lxx_md5} into ${PROJECT_SOURCE_DIR}/lib/cached/md5_cached.cmake"
|
||||
)
|
||||
endif()
|
||||
|
||||
include_directories(${PROJECT_SOURCE_DIR}/lib/cached)
|
||||
set(BISON_MZNParser_OUTPUTS
|
||||
${PROJECT_SOURCE_DIR}/lib/cached/parser.tab.cpp
|
||||
${PROJECT_SOURCE_DIR}/lib/cached/minizinc/parser.tab.hh
|
||||
)
|
||||
set(BISON_RegExParser_OUTPUTS
|
||||
${PROJECT_SOURCE_DIR}/lib/cached/regex_parser.tab.cpp
|
||||
${PROJECT_SOURCE_DIR}/lib/cached/minizinc/support/regex_parser.tab.hh
|
||||
)
|
||||
set(FLEX_MZNLexer_OUTPUTS ${PROJECT_SOURCE_DIR}/lib/cached/lexer.yy.cpp)
|
||||
set(FLEX_RegExLexer_OUTPUTS ${PROJECT_SOURCE_DIR}/lib/cached/regex_lexer.yy.cpp)
|
||||
endif()
|
||||
|
||||
if(NOT GECODE_FOUND)
|
||||
set(FLEX_RegExLexer_OUTPUTS "")
|
||||
set(BISON_RegExParser_OUTPUTS "")
|
||||
endif()
|
||||
|
||||
add_library(minizinc_parser OBJECT
|
||||
${BISON_MZNParser_OUTPUTS}
|
||||
${FLEX_MZNLexer_OUTPUTS}
|
||||
${BISON_RegExParser_OUTPUTS}
|
||||
${FLEX_RegExLexer_OUTPUTS}
|
||||
)
|
||||
set_target_properties(minizinc_parser PROPERTIES
|
||||
CXX_CLANG_TIDY ""
|
||||
)
|
||||
|
||||
if(GECODE_FOUND)
|
||||
target_include_directories(minizinc_parser PRIVATE "${GECODE_INCLUDE_DIRS}")
|
||||
target_compile_definitions(minizinc_parser PRIVATE HAS_GECODE)
|
||||
endif()
|
20
software/minizinc/cmake/targets/libminizinc_scip.cmake
Normal file
@ -0,0 +1,20 @@
|
||||
### MiniZinc SCIP Solver Target
|
||||
|
||||
if(SCIP_FOUND)
|
||||
|
||||
### Compile target for the SCIP interface
|
||||
add_library(minizinc_scip OBJECT
|
||||
solvers/MIP/MIP_scip_solverfactory.cpp
|
||||
solvers/MIP/MIP_scip_wrap.cpp
|
||||
|
||||
include/minizinc/solvers/MIP/MIP_scip_solverfactory.hh
|
||||
include/minizinc/solvers/MIP/MIP_scip_wrap.hh
|
||||
)
|
||||
target_include_directories(minizinc_scip PRIVATE ${SCIP_INCLUDE_DIRS})
|
||||
add_dependencies(minizinc_scip minizinc_mip)
|
||||
|
||||
### Setup correct compilation into the MiniZinc library
|
||||
target_compile_definitions(mzn PRIVATE HAS_SCIP)
|
||||
target_sources(mzn PRIVATE $<TARGET_OBJECTS:minizinc_scip>)
|
||||
|
||||
endif()
|
21
software/minizinc/cmake/targets/libminizinc_xpress.cmake
Normal file
@ -0,0 +1,21 @@
|
||||
### MiniZinc FICO Xpress Solver Target
|
||||
|
||||
if(XPRESS_FOUND)
|
||||
|
||||
### Compile target for the Xpress interface
|
||||
add_library(minizinc_xpress OBJECT
|
||||
solvers/MIP/MIP_xpress_solverfactory.cpp
|
||||
solvers/MIP/MIP_xpress_wrap.cpp
|
||||
|
||||
include/minizinc/solvers/MIP/MIP_xpress_solverfactory.hh
|
||||
include/minizinc/solvers/MIP/MIP_xpress_wrap.hh
|
||||
)
|
||||
|
||||
target_include_directories(minizinc_xpress PRIVATE ${XPRESS_INCLUDE_DIRS})
|
||||
add_dependencies(minizinc_xpress minizinc_mip)
|
||||
|
||||
### Setup correct compilation into the MiniZinc library
|
||||
target_compile_definitions(mzn PRIVATE HAS_XPRESS)
|
||||
target_sources(mzn PRIVATE $<TARGET_OBJECTS:minizinc_xpress>)
|
||||
|
||||
endif()
|
158
software/minizinc/cmake/targets/libmzn.cmake
Normal file
@ -0,0 +1,158 @@
|
||||
### MiniZinc Library Target
|
||||
# Combined definition of the MiniZinc core and all solvers compiled
|
||||
|
||||
include(cmake/targets/libminizinc_parser.cmake)
|
||||
include(cmake/targets/libminizinc_fzn.cmake)
|
||||
include(cmake/targets/libminizinc_nl.cmake)
|
||||
include(cmake/targets/libminizinc_mip.cmake)
|
||||
|
||||
add_library(mzn
|
||||
lib/MIPdomains.cpp
|
||||
lib/ast.cpp
|
||||
lib/astexception.cpp
|
||||
lib/astmap.cpp
|
||||
lib/aststring.cpp
|
||||
lib/astvec.cpp
|
||||
lib/builtins.cpp
|
||||
lib/cdecode.c
|
||||
lib/cencode.c
|
||||
lib/chain_compressor.cpp
|
||||
lib/copy.cpp
|
||||
lib/eval_par.cpp
|
||||
lib/file_utils.cpp
|
||||
lib/flatten.cpp
|
||||
lib/flatten/flat_exp.cpp
|
||||
lib/flatten/flatten_anon.cpp
|
||||
lib/flatten/flatten_arrayaccess.cpp
|
||||
lib/flatten/flatten_arraylit.cpp
|
||||
lib/flatten/flatten_binop.cpp
|
||||
lib/flatten/flatten_call.cpp
|
||||
lib/flatten/flatten_comp.cpp
|
||||
lib/flatten/flatten_id.cpp
|
||||
lib/flatten/flatten_ite.cpp
|
||||
lib/flatten/flatten_let.cpp
|
||||
lib/flatten/flatten_par.cpp
|
||||
lib/flatten/flatten_setlit.cpp
|
||||
lib/flatten/flatten_unop.cpp
|
||||
lib/flatten/flatten_vardecl.cpp
|
||||
lib/flattener.cpp
|
||||
lib/gc.cpp
|
||||
lib/htmlprinter.cpp
|
||||
lib/json_parser.cpp
|
||||
lib/lexer.lxx
|
||||
lib/thirdparty/miniz.c
|
||||
lib/model.cpp
|
||||
lib/optimize.cpp
|
||||
lib/optimize_constraints.cpp
|
||||
lib/output.cpp
|
||||
lib/param_config.cpp
|
||||
lib/parser.cpp
|
||||
lib/parser.yxx
|
||||
lib/passes/compile_pass.cpp
|
||||
lib/pathfileprinter.cpp
|
||||
lib/prettyprinter.cpp
|
||||
lib/solns2out.cpp
|
||||
lib/solver.cpp
|
||||
lib/solver_config.cpp
|
||||
lib/solver_instance_base.cpp
|
||||
lib/statistics.cpp
|
||||
lib/type.cpp
|
||||
lib/typecheck.cpp
|
||||
lib/values.cpp
|
||||
lib/support/regex/parser.yxx
|
||||
lib/support/regex/lexer.lxx
|
||||
|
||||
include/minizinc/ast.hh
|
||||
include/minizinc/ast.hpp
|
||||
include/minizinc/astexception.hh
|
||||
include/minizinc/astiterator.hh
|
||||
include/minizinc/astmap.hh
|
||||
include/minizinc/aststring.hh
|
||||
include/minizinc/astvec.hh
|
||||
include/minizinc/builtins.hh
|
||||
include/minizinc/chain_compressor.hh
|
||||
include/minizinc/config.hh.in
|
||||
include/minizinc/copy.hh
|
||||
include/minizinc/eval_par.hh
|
||||
include/minizinc/exception.hh
|
||||
include/minizinc/file_utils.hh
|
||||
include/minizinc/flat_exp.hh
|
||||
include/minizinc/flatten.hh
|
||||
include/minizinc/flatten_internal.hh
|
||||
include/minizinc/flattener.hh
|
||||
include/minizinc/gc.hh
|
||||
include/minizinc/hash.hh
|
||||
include/minizinc/htmlprinter.hh
|
||||
include/minizinc/interrupt.hh
|
||||
include/minizinc/iter.hh
|
||||
include/minizinc/json_parser.hh
|
||||
include/minizinc/model.hh
|
||||
include/minizinc/optimize.hh
|
||||
include/minizinc/optimize_constraints.hh
|
||||
include/minizinc/output.hh
|
||||
include/minizinc/param_config.hh
|
||||
include/minizinc/parser.hh
|
||||
include/minizinc/passes/compile_pass.hh
|
||||
include/minizinc/pathfileprinter.hh
|
||||
include/minizinc/prettyprinter.hh
|
||||
include/minizinc/process.hh
|
||||
include/minizinc/solns2out.hh
|
||||
include/minizinc/solver.hh
|
||||
include/minizinc/solver_config.hh
|
||||
include/minizinc/solver_instance.hh
|
||||
include/minizinc/solver_instance_base.hh
|
||||
include/minizinc/statistics.hh
|
||||
include/minizinc/support/regex.hh
|
||||
include/minizinc/_thirdparty/b64/cdecode.h
|
||||
include/minizinc/_thirdparty/b64/cencode.h
|
||||
include/minizinc/_thirdparty/b64/decode.h
|
||||
include/minizinc/_thirdparty/b64/encode.h
|
||||
include/minizinc/_thirdparty/miniz.h
|
||||
include/minizinc/timer.hh
|
||||
include/minizinc/type.hh
|
||||
include/minizinc/typecheck.hh
|
||||
include/minizinc/utils.hh
|
||||
include/minizinc/values.hh
|
||||
|
||||
$<TARGET_OBJECTS:minizinc_parser>
|
||||
$<TARGET_OBJECTS:minizinc_fzn>
|
||||
$<TARGET_OBJECTS:minizinc_mip>
|
||||
$<TARGET_OBJECTS:minizinc_nl>
|
||||
)
|
||||
target_link_libraries(mzn ${CMAKE_THREAD_LIBS_INIT})
|
||||
|
||||
### Add Solver Interfaces to the MiniZinc library when available
|
||||
include(cmake/targets/libminizinc_cplex.cmake)
|
||||
include(cmake/targets/libminizinc_geas.cmake)
|
||||
include(cmake/targets/libminizinc_gecode.cmake)
|
||||
include(cmake/targets/libminizinc_gurobi.cmake)
|
||||
include(cmake/targets/libminizinc_osicbc.cmake)
|
||||
include(cmake/targets/libminizinc_scip.cmake)
|
||||
include(cmake/targets/libminizinc_xpress.cmake)
|
||||
|
||||
if(GECODE_FOUND)
|
||||
target_link_libraries(mzn Gecode::Minimodel Gecode::Support)
|
||||
endif()
|
||||
|
||||
|
||||
### Add all necessary files to the install target
|
||||
install(
|
||||
TARGETS mzn
|
||||
EXPORT libminizincTargets
|
||||
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
|
||||
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||
)
|
||||
install(
|
||||
DIRECTORY share/minizinc
|
||||
DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}
|
||||
)
|
||||
install(
|
||||
DIRECTORY include/minizinc
|
||||
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
|
||||
PATTERN config.hh.in EXCLUDE
|
||||
)
|
||||
install(
|
||||
DIRECTORY lib/cached/minizinc
|
||||
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
|
||||
)
|
12
software/minizinc/cmake/targets/minizinc.cmake
Normal file
@ -0,0 +1,12 @@
|
||||
#### MiniZinc Executable Target
|
||||
|
||||
add_executable(minizinc minizinc.cpp)
|
||||
target_link_libraries(minizinc mzn)
|
||||
|
||||
install(
|
||||
TARGETS minizinc
|
||||
EXPORT libminizincTargets
|
||||
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
|
||||
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||
)
|
11
software/minizinc/cmake/targets/mzn2doc.cmake
Normal file
@ -0,0 +1,11 @@
|
||||
#### Binary target for MiniZinc documentation generator
|
||||
add_executable(mzn2doc mzn2doc.cpp)
|
||||
target_link_libraries(mzn2doc mzn)
|
||||
|
||||
install(
|
||||
TARGETS mzn2doc
|
||||
EXPORT libminizincTargets
|
||||
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
|
||||
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||
)
|
3
software/minizinc/cmake/templates/launch-c.in
Normal file
@ -0,0 +1,3 @@
|
||||
#!/bin/sh
|
||||
export CCACHE_CPP2=true
|
||||
exec "${RULE_LAUNCH_COMPILE}" "${CMAKE_C_COMPILER}" "$@"
|
3
software/minizinc/cmake/templates/launch-cxx.in
Normal file
@ -0,0 +1,3 @@
|
||||
#!/bin/sh
|
||||
export CCACHE_CPP2=true
|
||||
exec "${RULE_LAUNCH_COMPILE}" "${CMAKE_CXX_COMPILER}" "$@"
|
18
software/minizinc/cmake/templates/libminizincConfig.cmake.in
Normal file
@ -0,0 +1,18 @@
|
||||
# - Config file for the libminizinc package
|
||||
# It defines the following variables
|
||||
# libminizinc_INCLUDE_DIRS - include directories for libminizinc
|
||||
# libminizinc_LIBRARIES - libraries to link against
|
||||
# libminizinc_EXECUTABLE - the bar executable
|
||||
|
||||
# Compute paths
|
||||
get_filename_component(libminizinc_CMAKE_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH)
|
||||
set(libminizinc_INCLUDE_DIRS "@CONF_INCLUDE_DIRS@")
|
||||
|
||||
# Our library dependencies
|
||||
list(APPEND CMAKE_MODULE_PATH ${libminizinc_CMAKE_DIR})
|
||||
include(CMakeFindDependencyMacro)
|
||||
@CONF_DEPENDENCIES@
|
||||
|
||||
# Our library targets (contains definitions for IMPORTED targets)
|
||||
include("${libminizinc_CMAKE_DIR}/libminizincTargets.cmake")
|
||||
|
@ -0,0 +1,12 @@
|
||||
set(PACKAGE_VERSION "@libminizinc_VERSION@")
|
||||
|
||||
# Check whether the requested PACKAGE_FIND_VERSION is compatible
|
||||
if("${PACKAGE_VERSION}" VERSION_LESS "${PACKAGE_FIND_VERSION}")
|
||||
set(PACKAGE_VERSION_COMPATIBLE FALSE)
|
||||
else()
|
||||
set(PACKAGE_VERSION_COMPATIBLE TRUE)
|
||||
if ("${PACKAGE_VERSION}" VERSION_EQUAL "${PACKAGE_FIND_VERSION}")
|
||||
set(PACKAGE_VERSION_EXACT TRUE)
|
||||
endif()
|
||||
endif()
|
||||
|
390
software/minizinc/docs/LICENSE.txt
Normal file
@ -0,0 +1,390 @@
|
||||
Attribution-NoDerivatives 4.0 International
|
||||
|
||||
=======================================================================
|
||||
|
||||
Creative Commons Corporation ("Creative Commons") is not a law firm and
|
||||
does not provide legal services or legal advice. Distribution of
|
||||
Creative Commons public licenses does not create a lawyer-client or
|
||||
other relationship. Creative Commons makes its licenses and related
|
||||
information available on an "as-is" basis. Creative Commons gives no
|
||||
warranties regarding its licenses, any material licensed under their
|
||||
terms and conditions, or any related information. Creative Commons
|
||||
disclaims all liability for damages resulting from their use to the
|
||||
fullest extent possible.
|
||||
|
||||
Using Creative Commons Public Licenses
|
||||
|
||||
Creative Commons public licenses provide a standard set of terms and
|
||||
conditions that creators and other rights holders may use to share
|
||||
original works of authorship and other material subject to copyright
|
||||
and certain other rights specified in the public license below. The
|
||||
following considerations are for informational purposes only, are not
|
||||
exhaustive, and do not form part of our licenses.
|
||||
|
||||
Considerations for licensors: Our public licenses are
|
||||
intended for use by those authorized to give the public
|
||||
permission to use material in ways otherwise restricted by
|
||||
copyright and certain other rights. Our licenses are
|
||||
irrevocable. Licensors should read and understand the terms
|
||||
and conditions of the license they choose before applying it.
|
||||
Licensors should also secure all rights necessary before
|
||||
applying our licenses so that the public can reuse the
|
||||
material as expected. Licensors should clearly mark any
|
||||
material not subject to the license. This includes other CC-
|
||||
licensed material, or material used under an exception or
|
||||
limitation to copyright. More considerations for licensors:
|
||||
wiki.creativecommons.org/Considerations_for_licensors
|
||||
|
||||
Considerations for the public: By using one of our public
|
||||
licenses, a licensor grants the public permission to use the
|
||||
licensed material under specified terms and conditions. If
|
||||
the licensor's permission is not necessary for any reason--for
|
||||
example, because of any applicable exception or limitation to
|
||||
copyright--then that use is not regulated by the license. Our
|
||||
licenses grant only permissions under copyright and certain
|
||||
other rights that a licensor has authority to grant. Use of
|
||||
the licensed material may still be restricted for other
|
||||
reasons, including because others have copyright or other
|
||||
rights in the material. A licensor may make special requests,
|
||||
such as asking that all changes be marked or described.
|
||||
Although not required by our licenses, you are encouraged to
|
||||
respect those requests where reasonable. More considerations
|
||||
for the public:
|
||||
wiki.creativecommons.org/Considerations_for_licensees
|
||||
|
||||
|
||||
=======================================================================
|
||||
|
||||
Creative Commons Attribution-NoDerivatives 4.0 International Public
|
||||
License
|
||||
|
||||
By exercising the Licensed Rights (defined below), You accept and agree
|
||||
to be bound by the terms and conditions of this Creative Commons
|
||||
Attribution-NoDerivatives 4.0 International Public License ("Public
|
||||
License"). To the extent this Public License may be interpreted as a
|
||||
contract, You are granted the Licensed Rights in consideration of Your
|
||||
acceptance of these terms and conditions, and the Licensor grants You
|
||||
such rights in consideration of benefits the Licensor receives from
|
||||
making the Licensed Material available under these terms and
|
||||
conditions.
|
||||
|
||||
|
||||
Section 1 -- Definitions.
|
||||
|
||||
a. Adapted Material means material subject to Copyright and Similar
|
||||
Rights that is derived from or based upon the Licensed Material
|
||||
and in which the Licensed Material is translated, altered,
|
||||
arranged, transformed, or otherwise modified in a manner requiring
|
||||
permission under the Copyright and Similar Rights held by the
|
||||
Licensor. For purposes of this Public License, where the Licensed
|
||||
Material is a musical work, performance, or sound recording,
|
||||
Adapted Material is always produced where the Licensed Material is
|
||||
synched in timed relation with a moving image.
|
||||
|
||||
b. Copyright and Similar Rights means copyright and/or similar rights
|
||||
closely related to copyright including, without limitation,
|
||||
performance, broadcast, sound recording, and Sui Generis Database
|
||||
Rights, without regard to how the rights are labeled or
|
||||
categorized. For purposes of this Public License, the rights
|
||||
specified in Section 2(b)(1)-(2) are not Copyright and Similar
|
||||
Rights.
|
||||
|
||||
c. Effective Technological Measures means those measures that, in the
|
||||
absence of proper authority, may not be circumvented under laws
|
||||
fulfilling obligations under Article 11 of the WIPO Copyright
|
||||
Treaty adopted on December 20, 1996, and/or similar international
|
||||
agreements.
|
||||
|
||||
d. Exceptions and Limitations means fair use, fair dealing, and/or
|
||||
any other exception or limitation to Copyright and Similar Rights
|
||||
that applies to Your use of the Licensed Material.
|
||||
|
||||
e. Licensed Material means the artistic or literary work, database,
|
||||
or other material to which the Licensor applied this Public
|
||||
License.
|
||||
|
||||
f. Licensed Rights means the rights granted to You subject to the
|
||||
terms and conditions of this Public License, which are limited to
|
||||
all Copyright and Similar Rights that apply to Your use of the
|
||||
Licensed Material and that the Licensor has authority to license.
|
||||
|
||||
g. Licensor means the individual(s) or entity(ies) granting rights
|
||||
under this Public License.
|
||||
|
||||
h. Share means to provide material to the public by any means or
|
||||
process that requires permission under the Licensed Rights, such
|
||||
as reproduction, public display, public performance, distribution,
|
||||
dissemination, communication, or importation, and to make material
|
||||
available to the public including in ways that members of the
|
||||
public may access the material from a place and at a time
|
||||
individually chosen by them.
|
||||
|
||||
i. Sui Generis Database Rights means rights other than copyright
|
||||
resulting from Directive 96/9/EC of the European Parliament and of
|
||||
the Council of 11 March 1996 on the legal protection of databases,
|
||||
as amended and/or succeeded, as well as other essentially
|
||||
equivalent rights anywhere in the world.
|
||||
|
||||
j. You means the individual or entity exercising the Licensed Rights
|
||||
under this Public License. Your has a corresponding meaning.
|
||||
|
||||
|
||||
Section 2 -- Scope.
|
||||
|
||||
a. License grant.
|
||||
|
||||
1. Subject to the terms and conditions of this Public License,
|
||||
the Licensor hereby grants You a worldwide, royalty-free,
|
||||
non-sublicensable, non-exclusive, irrevocable license to
|
||||
exercise the Licensed Rights in the Licensed Material to:
|
||||
|
||||
a. reproduce and Share the Licensed Material, in whole or
|
||||
in part; and
|
||||
|
||||
b. produce and reproduce, but not Share, Adapted Material.
|
||||
|
||||
2. Exceptions and Limitations. For the avoidance of doubt, where
|
||||
Exceptions and Limitations apply to Your use, this Public
|
||||
License does not apply, and You do not need to comply with
|
||||
its terms and conditions.
|
||||
|
||||
3. Term. The term of this Public License is specified in Section
|
||||
6(a).
|
||||
|
||||
4. Media and formats; technical modifications allowed. The
|
||||
Licensor authorizes You to exercise the Licensed Rights in
|
||||
all media and formats whether now known or hereafter created,
|
||||
and to make technical modifications necessary to do so. The
|
||||
Licensor waives and/or agrees not to assert any right or
|
||||
authority to forbid You from making technical modifications
|
||||
necessary to exercise the Licensed Rights, including
|
||||
technical modifications necessary to circumvent Effective
|
||||
Technological Measures. For purposes of this Public License,
|
||||
simply making modifications authorized by this Section 2(a)
|
||||
(4) never produces Adapted Material.
|
||||
|
||||
5. Downstream recipients.
|
||||
|
||||
a. Offer from the Licensor -- Licensed Material. Every
|
||||
recipient of the Licensed Material automatically
|
||||
receives an offer from the Licensor to exercise the
|
||||
Licensed Rights under the terms and conditions of this
|
||||
Public License.
|
||||
|
||||
b. No downstream restrictions. You may not offer or impose
|
||||
any additional or different terms or conditions on, or
|
||||
apply any Effective Technological Measures to, the
|
||||
Licensed Material if doing so restricts exercise of the
|
||||
Licensed Rights by any recipient of the Licensed
|
||||
Material.
|
||||
|
||||
6. No endorsement. Nothing in this Public License constitutes or
|
||||
may be construed as permission to assert or imply that You
|
||||
are, or that Your use of the Licensed Material is, connected
|
||||
with, or sponsored, endorsed, or granted official status by,
|
||||
the Licensor or others designated to receive attribution as
|
||||
provided in Section 3(a)(1)(A)(i).
|
||||
|
||||
b. Other rights.
|
||||
|
||||
1. Moral rights, such as the right of integrity, are not
|
||||
licensed under this Public License, nor are publicity,
|
||||
privacy, and/or other similar personality rights; however, to
|
||||
the extent possible, the Licensor waives and/or agrees not to
|
||||
assert any such rights held by the Licensor to the limited
|
||||
extent necessary to allow You to exercise the Licensed
|
||||
Rights, but not otherwise.
|
||||
|
||||
2. Patent and trademark rights are not licensed under this
|
||||
Public License.
|
||||
|
||||
3. To the extent possible, the Licensor waives any right to
|
||||
collect royalties from You for the exercise of the Licensed
|
||||
Rights, whether directly or through a collecting society
|
||||
under any voluntary or waivable statutory or compulsory
|
||||
licensing scheme. In all other cases the Licensor expressly
|
||||
reserves any right to collect such royalties.
|
||||
|
||||
|
||||
Section 3 -- License Conditions.
|
||||
|
||||
Your exercise of the Licensed Rights is expressly made subject to the
|
||||
following conditions.
|
||||
|
||||
a. Attribution.
|
||||
|
||||
1. If You Share the Licensed Material, You must:
|
||||
|
||||
a. retain the following if it is supplied by the Licensor
|
||||
with the Licensed Material:
|
||||
|
||||
i. identification of the creator(s) of the Licensed
|
||||
Material and any others designated to receive
|
||||
attribution, in any reasonable manner requested by
|
||||
the Licensor (including by pseudonym if
|
||||
designated);
|
||||
|
||||
ii. a copyright notice;
|
||||
|
||||
iii. a notice that refers to this Public License;
|
||||
|
||||
iv. a notice that refers to the disclaimer of
|
||||
warranties;
|
||||
|
||||
v. a URI or hyperlink to the Licensed Material to the
|
||||
extent reasonably practicable;
|
||||
|
||||
b. indicate if You modified the Licensed Material and
|
||||
retain an indication of any previous modifications; and
|
||||
|
||||
c. indicate the Licensed Material is licensed under this
|
||||
Public License, and include the text of, or the URI or
|
||||
hyperlink to, this Public License.
|
||||
|
||||
For the avoidance of doubt, You do not have permission under
|
||||
this Public License to Share Adapted Material.
|
||||
|
||||
2. You may satisfy the conditions in Section 3(a)(1) in any
|
||||
reasonable manner based on the medium, means, and context in
|
||||
which You Share the Licensed Material. For example, it may be
|
||||
reasonable to satisfy the conditions by providing a URI or
|
||||
hyperlink to a resource that includes the required
|
||||
information.
|
||||
|
||||
3. If requested by the Licensor, You must remove any of the
|
||||
information required by Section 3(a)(1)(A) to the extent
|
||||
reasonably practicable.
|
||||
|
||||
|
||||
Section 4 -- Sui Generis Database Rights.
|
||||
|
||||
Where the Licensed Rights include Sui Generis Database Rights that
|
||||
apply to Your use of the Licensed Material:
|
||||
|
||||
a. for the avoidance of doubt, Section 2(a)(1) grants You the right
|
||||
to extract, reuse, reproduce, and Share all or a substantial
|
||||
portion of the contents of the database, provided You do not Share
|
||||
Adapted Material;
|
||||
b. if You include all or a substantial portion of the database
|
||||
contents in a database in which You have Sui Generis Database
|
||||
Rights, then the database in which You have Sui Generis Database
|
||||
Rights (but not its individual contents) is Adapted Material; and
|
||||
c. You must comply with the conditions in Section 3(a) if You Share
|
||||
all or a substantial portion of the contents of the database.
|
||||
|
||||
For the avoidance of doubt, this Section 4 supplements and does not
|
||||
replace Your obligations under this Public License where the Licensed
|
||||
Rights include other Copyright and Similar Rights.
|
||||
|
||||
|
||||
Section 5 -- Disclaimer of Warranties and Limitation of Liability.
|
||||
|
||||
a. UNLESS OTHERWISE SEPARATELY UNDERTAKEN BY THE LICENSOR, TO THE
|
||||
EXTENT POSSIBLE, THE LICENSOR OFFERS THE LICENSED MATERIAL AS-IS
|
||||
AND AS-AVAILABLE, AND MAKES NO REPRESENTATIONS OR WARRANTIES OF
|
||||
ANY KIND CONCERNING THE LICENSED MATERIAL, WHETHER EXPRESS,
|
||||
IMPLIED, STATUTORY, OR OTHER. THIS INCLUDES, WITHOUT LIMITATION,
|
||||
WARRANTIES OF TITLE, MERCHANTABILITY, FITNESS FOR A PARTICULAR
|
||||
PURPOSE, NON-INFRINGEMENT, ABSENCE OF LATENT OR OTHER DEFECTS,
|
||||
ACCURACY, OR THE PRESENCE OR ABSENCE OF ERRORS, WHETHER OR NOT
|
||||
KNOWN OR DISCOVERABLE. WHERE DISCLAIMERS OF WARRANTIES ARE NOT
|
||||
ALLOWED IN FULL OR IN PART, THIS DISCLAIMER MAY NOT APPLY TO YOU.
|
||||
|
||||
b. TO THE EXTENT POSSIBLE, IN NO EVENT WILL THE LICENSOR BE LIABLE
|
||||
TO YOU ON ANY LEGAL THEORY (INCLUDING, WITHOUT LIMITATION,
|
||||
NEGLIGENCE) OR OTHERWISE FOR ANY DIRECT, SPECIAL, INDIRECT,
|
||||
INCIDENTAL, CONSEQUENTIAL, PUNITIVE, EXEMPLARY, OR OTHER LOSSES,
|
||||
COSTS, EXPENSES, OR DAMAGES ARISING OUT OF THIS PUBLIC LICENSE OR
|
||||
USE OF THE LICENSED MATERIAL, EVEN IF THE LICENSOR HAS BEEN
|
||||
ADVISED OF THE POSSIBILITY OF SUCH LOSSES, COSTS, EXPENSES, OR
|
||||
DAMAGES. WHERE A LIMITATION OF LIABILITY IS NOT ALLOWED IN FULL OR
|
||||
IN PART, THIS LIMITATION MAY NOT APPLY TO YOU.
|
||||
|
||||
c. The disclaimer of warranties and limitation of liability provided
|
||||
above shall be interpreted in a manner that, to the extent
|
||||
possible, most closely approximates an absolute disclaimer and
|
||||
waiver of all liability.
|
||||
|
||||
|
||||
Section 6 -- Term and Termination.
|
||||
|
||||
a. This Public License applies for the term of the Copyright and
|
||||
Similar Rights licensed here. However, if You fail to comply with
|
||||
this Public License, then Your rights under this Public License
|
||||
terminate automatically.
|
||||
|
||||
b. Where Your right to use the Licensed Material has terminated under
|
||||
Section 6(a), it reinstates:
|
||||
|
||||
1. automatically as of the date the violation is cured, provided
|
||||
it is cured within 30 days of Your discovery of the
|
||||
violation; or
|
||||
|
||||
2. upon express reinstatement by the Licensor.
|
||||
|
||||
For the avoidance of doubt, this Section 6(b) does not affect any
|
||||
right the Licensor may have to seek remedies for Your violations
|
||||
of this Public License.
|
||||
|
||||
c. For the avoidance of doubt, the Licensor may also offer the
|
||||
Licensed Material under separate terms or conditions or stop
|
||||
distributing the Licensed Material at any time; however, doing so
|
||||
will not terminate this Public License.
|
||||
|
||||
d. Sections 1, 5, 6, 7, and 8 survive termination of this Public
|
||||
License.
|
||||
|
||||
|
||||
Section 7 -- Other Terms and Conditions.
|
||||
|
||||
a. The Licensor shall not be bound by any additional or different
|
||||
terms or conditions communicated by You unless expressly agreed.
|
||||
|
||||
b. Any arrangements, understandings, or agreements regarding the
|
||||
Licensed Material not stated herein are separate from and
|
||||
independent of the terms and conditions of this Public License.
|
||||
|
||||
|
||||
Section 8 -- Interpretation.
|
||||
|
||||
a. For the avoidance of doubt, this Public License does not, and
|
||||
shall not be interpreted to, reduce, limit, restrict, or impose
|
||||
conditions on any use of the Licensed Material that could lawfully
|
||||
be made without permission under this Public License.
|
||||
|
||||
b. To the extent possible, if any provision of this Public License is
|
||||
deemed unenforceable, it shall be automatically reformed to the
|
||||
minimum extent necessary to make it enforceable. If the provision
|
||||
cannot be reformed, it shall be severed from this Public License
|
||||
without affecting the enforceability of the remaining terms and
|
||||
conditions.
|
||||
|
||||
c. No term or condition of this Public License will be waived and no
|
||||
failure to comply consented to unless expressly agreed to by the
|
||||
Licensor.
|
||||
|
||||
d. Nothing in this Public License constitutes or may be interpreted
|
||||
as a limitation upon, or waiver of, any privileges and immunities
|
||||
that apply to the Licensor or You, including from the legal
|
||||
processes of any jurisdiction or authority.
|
||||
|
||||
=======================================================================
|
||||
|
||||
Creative Commons is not a party to its public
|
||||
licenses. Notwithstanding, Creative Commons may elect to apply one of
|
||||
its public licenses to material it publishes and in those instances
|
||||
will be considered the “Licensor.” The text of the Creative Commons
|
||||
public licenses is dedicated to the public domain under the CC0 Public
|
||||
Domain Dedication. Except for the limited purpose of indicating that
|
||||
material is shared under a Creative Commons public license or as
|
||||
otherwise permitted by the Creative Commons policies published at
|
||||
creativecommons.org/policies, Creative Commons does not authorize the
|
||||
use of the trademark "Creative Commons" or any other trademark or logo
|
||||
of Creative Commons without its prior written consent including,
|
||||
without limitation, in connection with any unauthorized modifications
|
||||
to any of its public licenses or any other arrangements,
|
||||
understandings, or agreements concerning use of licensed material. For
|
||||
the avoidance of doubt, this paragraph does not form part of the
|
||||
public licenses.
|
||||
|
||||
Creative Commons may be contacted at creativecommons.org.
|
27
software/minizinc/docs/README.md
Normal file
@ -0,0 +1,27 @@
|
||||
# README #
|
||||
|
||||
This directory contains the MiniZinc documentation.
|
||||
|
||||
### Building the docs ###
|
||||
|
||||
You need the following tools to build the documentation:
|
||||
|
||||
* Python 3
|
||||
* GNU make
|
||||
* Sphinx version 1.8.0. Install it using the command
|
||||
`pip install git+https://github.com/sphinx-doc/sphinx`
|
||||
* Sphinx Read The Docs html theme. Install it using the command
|
||||
`pip install sphinx_rtd_theme`
|
||||
* If you want to build the PDF documentation, you also need a LaTeX
|
||||
distribution that includes xetex, and install the following fonts: Charter,
|
||||
Lato and Inconsolata.
|
||||
|
||||
To build the HTML documentation, simply run `make html`. To build the PDF, run `make latexpdf`.
|
||||
|
||||
### Including the MiniZinc library reference documentation ###
|
||||
|
||||
The reference documentation for the MiniZinc library can be generated
|
||||
automatically from the source code. Then run the following command:
|
||||
|
||||
``mzn2doc --rst-output --include-stdlib --output-base en ../share/minizinc/std/globals.mzn``
|
||||
|
225
software/minizinc/docs/chi/Makefile
Normal file
@ -0,0 +1,225 @@
|
||||
# Makefile for Sphinx documentation
|
||||
#
|
||||
|
||||
# You can set these variables from the command line.
|
||||
SPHINXOPTS =
|
||||
SPHINXBUILD = sphinx-build
|
||||
PAPER =
|
||||
BUILDDIR = _build
|
||||
|
||||
# Internal variables.
|
||||
PAPEROPT_a4 = -D latex_paper_size=a4
|
||||
PAPEROPT_letter = -D latex_paper_size=letter
|
||||
ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) .
|
||||
# the i18n builder cannot share the environment and doctrees with the others
|
||||
I18NSPHINXOPTS = $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) .
|
||||
|
||||
.PHONY: help
|
||||
help:
|
||||
@echo "Please use \`make <target>' where <target> is one of"
|
||||
@echo " html to make standalone HTML files"
|
||||
@echo " dirhtml to make HTML files named index.html in directories"
|
||||
@echo " singlehtml to make a single large HTML file"
|
||||
@echo " pickle to make pickle files"
|
||||
@echo " json to make JSON files"
|
||||
@echo " htmlhelp to make HTML files and a HTML help project"
|
||||
@echo " qthelp to make HTML files and a qthelp project"
|
||||
@echo " applehelp to make an Apple Help Book"
|
||||
@echo " devhelp to make HTML files and a Devhelp project"
|
||||
@echo " epub to make an epub"
|
||||
@echo " epub3 to make an epub3"
|
||||
@echo " latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter"
|
||||
@echo " latexpdf to make LaTeX files and run them through pdflatex"
|
||||
@echo " latexpdfja to make LaTeX files and run them through platex/dvipdfmx"
|
||||
@echo " text to make text files"
|
||||
@echo " man to make manual pages"
|
||||
@echo " texinfo to make Texinfo files"
|
||||
@echo " info to make Texinfo files and run them through makeinfo"
|
||||
@echo " gettext to make PO message catalogs"
|
||||
@echo " changes to make an overview of all changed/added/deprecated items"
|
||||
@echo " xml to make Docutils-native XML files"
|
||||
@echo " pseudoxml to make pseudoxml-XML files for display purposes"
|
||||
@echo " linkcheck to check all external links for integrity"
|
||||
@echo " doctest to run all doctests embedded in the documentation (if enabled)"
|
||||
@echo " coverage to run coverage check of the documentation (if enabled)"
|
||||
@echo " dummy to check syntax errors of document sources"
|
||||
|
||||
.PHONY: clean
|
||||
clean:
|
||||
rm -rf $(BUILDDIR)/*
|
||||
|
||||
.PHONY: html
|
||||
html:
|
||||
$(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html
|
||||
@echo
|
||||
@echo "Build finished. The HTML pages are in $(BUILDDIR)/html."
|
||||
|
||||
.PHONY: dirhtml
|
||||
dirhtml:
|
||||
$(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml
|
||||
@echo
|
||||
@echo "Build finished. The HTML pages are in $(BUILDDIR)/dirhtml."
|
||||
|
||||
.PHONY: singlehtml
|
||||
singlehtml:
|
||||
$(SPHINXBUILD) -b singlehtml $(ALLSPHINXOPTS) $(BUILDDIR)/singlehtml
|
||||
@echo
|
||||
@echo "Build finished. The HTML page is in $(BUILDDIR)/singlehtml."
|
||||
|
||||
.PHONY: pickle
|
||||
pickle:
|
||||
$(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) $(BUILDDIR)/pickle
|
||||
@echo
|
||||
@echo "Build finished; now you can process the pickle files."
|
||||
|
||||
.PHONY: json
|
||||
json:
|
||||
$(SPHINXBUILD) -b json $(ALLSPHINXOPTS) $(BUILDDIR)/json
|
||||
@echo
|
||||
@echo "Build finished; now you can process the JSON files."
|
||||
|
||||
.PHONY: htmlhelp
|
||||
htmlhelp:
|
||||
$(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) $(BUILDDIR)/htmlhelp
|
||||
@echo
|
||||
@echo "Build finished; now you can run HTML Help Workshop with the" \
|
||||
".hhp project file in $(BUILDDIR)/htmlhelp."
|
||||
|
||||
.PHONY: qthelp
|
||||
qthelp:
|
||||
$(SPHINXBUILD) -b qthelp $(ALLSPHINXOPTS) $(BUILDDIR)/qthelp
|
||||
@echo
|
||||
@echo "Build finished; now you can run "qcollectiongenerator" with the" \
|
||||
".qhcp project file in $(BUILDDIR)/qthelp, like this:"
|
||||
@echo "# qcollectiongenerator $(BUILDDIR)/qthelp/MiniZinc.qhcp"
|
||||
@echo "To view the help file:"
|
||||
@echo "# assistant -collectionFile $(BUILDDIR)/qthelp/MiniZinc.qhc"
|
||||
|
||||
.PHONY: applehelp
|
||||
applehelp:
|
||||
$(SPHINXBUILD) -b applehelp $(ALLSPHINXOPTS) $(BUILDDIR)/applehelp
|
||||
@echo
|
||||
@echo "Build finished. The help book is in $(BUILDDIR)/applehelp."
|
||||
@echo "N.B. You won't be able to view it unless you put it in" \
|
||||
"~/Library/Documentation/Help or install it in your application" \
|
||||
"bundle."
|
||||
|
||||
.PHONY: devhelp
|
||||
devhelp:
|
||||
$(SPHINXBUILD) -b devhelp $(ALLSPHINXOPTS) $(BUILDDIR)/devhelp
|
||||
@echo
|
||||
@echo "Build finished."
|
||||
@echo "To view the help file:"
|
||||
@echo "# mkdir -p $$HOME/.local/share/devhelp/MiniZinc"
|
||||
@echo "# ln -s $(BUILDDIR)/devhelp $$HOME/.local/share/devhelp/MiniZinc"
|
||||
@echo "# devhelp"
|
||||
|
||||
.PHONY: epub
|
||||
epub:
|
||||
$(SPHINXBUILD) -b epub $(ALLSPHINXOPTS) $(BUILDDIR)/epub
|
||||
@echo
|
||||
@echo "Build finished. The epub file is in $(BUILDDIR)/epub."
|
||||
|
||||
.PHONY: epub3
|
||||
epub3:
|
||||
$(SPHINXBUILD) -b epub3 $(ALLSPHINXOPTS) $(BUILDDIR)/epub3
|
||||
@echo
|
||||
@echo "Build finished. The epub3 file is in $(BUILDDIR)/epub3."
|
||||
|
||||
.PHONY: latex
|
||||
latex:
|
||||
$(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
|
||||
@echo
|
||||
@echo "Build finished; the LaTeX files are in $(BUILDDIR)/latex."
|
||||
@echo "Run \`make' in that directory to run these through (pdf)latex" \
|
||||
"(use \`make latexpdf' here to do that automatically)."
|
||||
|
||||
.PHONY: latexpdf
|
||||
latexpdf:
|
||||
$(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
|
||||
@echo "Running LaTeX files through pdflatex..."
|
||||
$(MAKE) -C $(BUILDDIR)/latex all-pdf
|
||||
@echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex."
|
||||
|
||||
.PHONY: latexpdfja
|
||||
latexpdfja:
|
||||
$(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
|
||||
@echo "Running LaTeX files through platex and dvipdfmx..."
|
||||
$(MAKE) -C $(BUILDDIR)/latex all-pdf-ja
|
||||
@echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex."
|
||||
|
||||
.PHONY: text
|
||||
text:
|
||||
$(SPHINXBUILD) -b text $(ALLSPHINXOPTS) $(BUILDDIR)/text
|
||||
@echo
|
||||
@echo "Build finished. The text files are in $(BUILDDIR)/text."
|
||||
|
||||
.PHONY: man
|
||||
man:
|
||||
$(SPHINXBUILD) -b man $(ALLSPHINXOPTS) $(BUILDDIR)/man
|
||||
@echo
|
||||
@echo "Build finished. The manual pages are in $(BUILDDIR)/man."
|
||||
|
||||
.PHONY: texinfo
|
||||
texinfo:
|
||||
$(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo
|
||||
@echo
|
||||
@echo "Build finished. The Texinfo files are in $(BUILDDIR)/texinfo."
|
||||
@echo "Run \`make' in that directory to run these through makeinfo" \
|
||||
"(use \`make info' here to do that automatically)."
|
||||
|
||||
.PHONY: info
|
||||
info:
|
||||
$(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo
|
||||
@echo "Running Texinfo files through makeinfo..."
|
||||
make -C $(BUILDDIR)/texinfo info
|
||||
@echo "makeinfo finished; the Info files are in $(BUILDDIR)/texinfo."
|
||||
|
||||
.PHONY: gettext
|
||||
gettext:
|
||||
$(SPHINXBUILD) -b gettext $(I18NSPHINXOPTS) $(BUILDDIR)/locale
|
||||
@echo
|
||||
@echo "Build finished. The message catalogs are in $(BUILDDIR)/locale."
|
||||
|
||||
.PHONY: changes
|
||||
changes:
|
||||
$(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) $(BUILDDIR)/changes
|
||||
@echo
|
||||
@echo "The overview file is in $(BUILDDIR)/changes."
|
||||
|
||||
.PHONY: linkcheck
|
||||
linkcheck:
|
||||
$(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) $(BUILDDIR)/linkcheck
|
||||
@echo
|
||||
@echo "Link check complete; look for any errors in the above output " \
|
||||
"or in $(BUILDDIR)/linkcheck/output.txt."
|
||||
|
||||
.PHONY: doctest
|
||||
doctest:
|
||||
$(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) $(BUILDDIR)/doctest
|
||||
@echo "Testing of doctests in the sources finished, look at the " \
|
||||
"results in $(BUILDDIR)/doctest/output.txt."
|
||||
|
||||
.PHONY: coverage
|
||||
coverage:
|
||||
$(SPHINXBUILD) -b coverage $(ALLSPHINXOPTS) $(BUILDDIR)/coverage
|
||||
@echo "Testing of coverage in the sources finished, look at the " \
|
||||
"results in $(BUILDDIR)/coverage/python.txt."
|
||||
|
||||
.PHONY: xml
|
||||
xml:
|
||||
$(SPHINXBUILD) -b xml $(ALLSPHINXOPTS) $(BUILDDIR)/xml
|
||||
@echo
|
||||
@echo "Build finished. The XML files are in $(BUILDDIR)/xml."
|
||||
|
||||
.PHONY: pseudoxml
|
||||
pseudoxml:
|
||||
$(SPHINXBUILD) -b pseudoxml $(ALLSPHINXOPTS) $(BUILDDIR)/pseudoxml
|
||||
@echo
|
||||
@echo "Build finished. The pseudo-XML files are in $(BUILDDIR)/pseudoxml."
|
||||
|
||||
.PHONY: dummy
|
||||
dummy:
|
||||
$(SPHINXBUILD) -b dummy $(ALLSPHINXOPTS) $(BUILDDIR)/dummy
|
||||
@echo
|
||||
@echo "Build finished. Dummy builder generates no files."
|
After Width: | Height: | Size: 8.7 KiB |
After Width: | Height: | Size: 11 KiB |
After Width: | Height: | Size: 2.3 KiB |
After Width: | Height: | Size: 2.9 KiB |
After Width: | Height: | Size: 4.2 KiB |
After Width: | Height: | Size: 5.5 KiB |
After Width: | Height: | Size: 6.6 KiB |
After Width: | Height: | Size: 7.0 KiB |
After Width: | Height: | Size: 8.7 KiB |
After Width: | Height: | Size: 9.3 KiB |
After Width: | Height: | Size: 12 KiB |
BIN
software/minizinc/docs/chi/_static/favicon/apple-icon-57x57.png
Normal file
After Width: | Height: | Size: 3.3 KiB |
BIN
software/minizinc/docs/chi/_static/favicon/apple-icon-60x60.png
Normal file
After Width: | Height: | Size: 3.5 KiB |
BIN
software/minizinc/docs/chi/_static/favicon/apple-icon-72x72.png
Normal file
After Width: | Height: | Size: 4.2 KiB |
BIN
software/minizinc/docs/chi/_static/favicon/apple-icon-76x76.png
Normal file
After Width: | Height: | Size: 4.3 KiB |
After Width: | Height: | Size: 12 KiB |
BIN
software/minizinc/docs/chi/_static/favicon/apple-icon.png
Normal file
After Width: | Height: | Size: 12 KiB |
@ -0,0 +1,2 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<browserconfig><msapplication><tile><square70x70logo src="/ms-icon-70x70.png"/><square150x150logo src="/ms-icon-150x150.png"/><square310x310logo src="/ms-icon-310x310.png"/><TileColor>#ffffff</TileColor></tile></msapplication></browserconfig>
|
BIN
software/minizinc/docs/chi/_static/favicon/favicon-16x16.png
Normal file
After Width: | Height: | Size: 1.3 KiB |
BIN
software/minizinc/docs/chi/_static/favicon/favicon-32x32.png
Normal file
After Width: | Height: | Size: 2.1 KiB |
BIN
software/minizinc/docs/chi/_static/favicon/favicon-96x96.png
Normal file
After Width: | Height: | Size: 5.5 KiB |
BIN
software/minizinc/docs/chi/_static/favicon/favicon.ico
Normal file
After Width: | Height: | Size: 1.1 KiB |
41
software/minizinc/docs/chi/_static/favicon/manifest.json
Normal file
@ -0,0 +1,41 @@
|
||||
{
|
||||
"name": "App",
|
||||
"icons": [
|
||||
{
|
||||
"src": "\/android-icon-36x36.png",
|
||||
"sizes": "36x36",
|
||||
"type": "image\/png",
|
||||
"density": "0.75"
|
||||
},
|
||||
{
|
||||
"src": "\/android-icon-48x48.png",
|
||||
"sizes": "48x48",
|
||||
"type": "image\/png",
|
||||
"density": "1.0"
|
||||
},
|
||||
{
|
||||
"src": "\/android-icon-72x72.png",
|
||||
"sizes": "72x72",
|
||||
"type": "image\/png",
|
||||
"density": "1.5"
|
||||
},
|
||||
{
|
||||
"src": "\/android-icon-96x96.png",
|
||||
"sizes": "96x96",
|
||||
"type": "image\/png",
|
||||
"density": "2.0"
|
||||
},
|
||||
{
|
||||
"src": "\/android-icon-144x144.png",
|
||||
"sizes": "144x144",
|
||||
"type": "image\/png",
|
||||
"density": "3.0"
|
||||
},
|
||||
{
|
||||
"src": "\/android-icon-192x192.png",
|
||||
"sizes": "192x192",
|
||||
"type": "image\/png",
|
||||
"density": "4.0"
|
||||
}
|
||||
]
|
||||
}
|
BIN
software/minizinc/docs/chi/_static/favicon/ms-icon-144x144.png
Normal file
After Width: | Height: | Size: 8.7 KiB |
BIN
software/minizinc/docs/chi/_static/favicon/ms-icon-150x150.png
Normal file
After Width: | Height: | Size: 9.2 KiB |
BIN
software/minizinc/docs/chi/_static/favicon/ms-icon-310x310.png
Normal file
After Width: | Height: | Size: 25 KiB |
BIN
software/minizinc/docs/chi/_static/favicon/ms-icon-70x70.png
Normal file
After Width: | Height: | Size: 4.0 KiB |
16
software/minizinc/docs/chi/_static/js/doc-links.js
Normal file
@ -0,0 +1,16 @@
|
||||
window.onload = function () {
|
||||
var to_link = document.getElementsByClassName("highlight-minizinc");
|
||||
for (var i = 0; i<to_link.length; i++) {
|
||||
if (to_link[i].hasAttribute('id')) {
|
||||
var newH6 = document.createElement('p');
|
||||
newH6.setAttribute('class','caption doc-link-caption');
|
||||
var newTag = document.createElement('a');
|
||||
newTag.setAttribute('href','#'+to_link[i].getAttribute('id'));
|
||||
newTag.setAttribute('class','headerlink');
|
||||
newTag.innerText = "¶";
|
||||
newH6.appendChild(newTag);
|
||||
to_link[i].parentNode.insertBefore(newH6, to_link[i]);
|
||||
newH6.appendChild(to_link[i]);
|
||||
}
|
||||
}
|
||||
};
|
30
software/minizinc/docs/chi/_static/style.css
Normal file
@ -0,0 +1,30 @@
|
||||
.rst-content code, .rst-content tt {
|
||||
background: inherit;
|
||||
border: none;
|
||||
padding: 0;
|
||||
}
|
||||
.highlight, .highlight .cs {
|
||||
background: inherit;
|
||||
padding: 0;
|
||||
}
|
||||
.table-nonfluid {
|
||||
width: auto !important;
|
||||
}
|
||||
div.literal-block-wrapper {
|
||||
padding: 0;
|
||||
width: 100%;
|
||||
}
|
||||
div.code-block-caption {
|
||||
border: 1px solid #ccc;
|
||||
border-radius: 4px 4px 0px 0px;
|
||||
background-color: #f5f5f5;
|
||||
}
|
||||
.logo {
|
||||
width: 100% !important;
|
||||
}
|
||||
p.doc-link-caption {
|
||||
margin: 0;
|
||||
}
|
||||
.doc-link-caption .headerlink {
|
||||
float: right;
|
||||
}
|
4
software/minizinc/docs/chi/_templates/footer.html
Normal file
@ -0,0 +1,4 @@
|
||||
{% extends "!footer.html" %}
|
||||
{%- block extrafooter %}
|
||||
<a rel="license" href="http://creativecommons.org/licenses/by-nd/4.0/"><img alt="Creative Commons License" style="border-width:0" src="https://i.creativecommons.org/l/by-nd/4.0/80x15.png" /></a>
|
||||
{% endblock %}
|
61
software/minizinc/docs/chi/_templates/layout.html
Normal file
@ -0,0 +1,61 @@
|
||||
{% extends "!layout.html" %}
|
||||
{% block extrahead %}
|
||||
<link rel="apple-touch-icon" sizes="57x57" href="{{ pathto('_static/favicon/apple-icon-57x57.png', 1) }}">
|
||||
<link rel="apple-touch-icon" sizes="60x60" href="{{ pathto('_static/favicon/apple-icon-60x60.png', 1) }}">
|
||||
<link rel="apple-touch-icon" sizes="72x72" href="{{ pathto('_static/favicon/apple-icon-72x72.png', 1) }}">
|
||||
<link rel="apple-touch-icon" sizes="76x76" href="{{ pathto('_static/favicon/apple-icon-76x76.png', 1) }}">
|
||||
<link rel="apple-touch-icon" sizes="114x114" href="{{ pathto('_static/favicon/apple-icon-114x114.png', 1) }}">
|
||||
<link rel="apple-touch-icon" sizes="120x120" href="{{ pathto('_static/favicon/apple-icon-120x120.png', 1) }}">
|
||||
<link rel="apple-touch-icon" sizes="144x144" href="{{ pathto('_static/favicon/apple-icon-144x144.png', 1) }}">
|
||||
<link rel="apple-touch-icon" sizes="152x152" href="{{ pathto('_static/favicon/apple-icon-152x152.png', 1) }}">
|
||||
<link rel="apple-touch-icon" sizes="180x180" href="{{ pathto('_static/favicon/apple-icon-180x180.png', 1) }}">
|
||||
<link rel="icon" type="image/png" sizes="192x192" href="{{ pathto('_static/favicon/android-icon-192x192.png', 1) }}">
|
||||
<link rel="icon" type="image/png" sizes="32x32" href="{{ pathto('_static/favicon/favicon-32x32.png', 1) }}">
|
||||
<link rel="icon" type="image/png" sizes="96x96" href="{{ pathto('_static/favicon/favicon-96x96.png', 1) }}">
|
||||
<link rel="icon" type="image/png" sizes="16x16" href="{{ pathto('_static/favicon/favicon-16x16.png', 1) }}">
|
||||
<link rel="manifest" href="{{ pathto('_static/favicon/manifest.json', 1) }}">
|
||||
<meta name="msapplication-TileColor" content="#ffffff">
|
||||
<meta name="msapplication-TileImage" content="{{ pathto('_static/favicon/ms-icon-144x144.png', 1) }}">
|
||||
<meta name="theme-color" content="#ffffff">
|
||||
{% endblock %}
|
||||
{% block sidebartitle %}
|
||||
<a href="http://www.minizinc.org">
|
||||
{% if logo %}
|
||||
{# Not strictly valid HTML, but it's the only way to display/scale
|
||||
it properly, without weird scripting or heaps of work
|
||||
#}
|
||||
<img src="{{ pathto('_static/' + logo, 1) }}" class="logo" alt="Logo"/>
|
||||
{% endif %}
|
||||
</a>
|
||||
|
||||
{% if theme_display_version %}
|
||||
{%- set nav_version = release %}
|
||||
{% if nav_version %}
|
||||
<div class="version">
|
||||
{{ nav_version }}
|
||||
</div>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
|
||||
{% include "searchbox.html" %}
|
||||
{% endblock %}
|
||||
|
||||
{% block menu %}
|
||||
{#
|
||||
The singlehtml builder doesn't handle this toctree call when the
|
||||
toctree is empty. Skip building this for now.
|
||||
#}
|
||||
{% if 'singlehtml' not in builder %}
|
||||
{% set global_toc = toctree(maxdepth=theme_navigation_depth|int,
|
||||
collapse=theme_collapse_navigation|tobool,
|
||||
includehidden=theme_includehidden|tobool,
|
||||
titles_only=theme_titles_only|tobool) %}
|
||||
{% endif %}
|
||||
<a href="{{ pathto(master_doc) }}" class="reference internal icon icon-home"> {{ project }} </a>
|
||||
{% if global_toc %}
|
||||
{{ global_toc }}
|
||||
{% else %}
|
||||
<!-- Local TOC -->
|
||||
<div class="local-toc">{{ toc }}</div>
|
||||
{% endif %}
|
||||
{% endblock %}
|
1
software/minizinc/docs/chi/api_interfacing.rst
Normal file
@ -0,0 +1 @@
|
||||
.. include:: ../en/api_interfacing.rst
|
1
software/minizinc/docs/chi/basic_steps.rst
Normal file
@ -0,0 +1 @@
|
||||
.. include:: ../en/basic_steps.rst
|
1
software/minizinc/docs/chi/command_line.rst
Normal file
@ -0,0 +1 @@
|
||||
.. include:: ../en/command_line.rst
|
479
software/minizinc/docs/chi/conf.py
Executable file
@ -0,0 +1,479 @@
|
||||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# MiniZinc documentation build configuration file, created by
|
||||
# sphinx-quickstart on Sat Nov 26 18:22:59 2016.
|
||||
#
|
||||
# This file is execfile()d with the current directory set to its
|
||||
# containing dir.
|
||||
#
|
||||
# Note that not all possible configuration values are present in this
|
||||
# autogenerated file.
|
||||
#
|
||||
# All configuration values have a default; values that are commented out
|
||||
# serve to show the default.
|
||||
|
||||
# If extensions (or modules to document with autodoc) are in another directory,
|
||||
# add these directories to sys.path here. If the directory is relative to the
|
||||
# documentation root, use os.path.abspath to make it absolute, like shown here.
|
||||
#
|
||||
import os
|
||||
import sys
|
||||
sys.path.insert(0, os.path.abspath('../utils'))
|
||||
|
||||
# -- General configuration ------------------------------------------------
|
||||
|
||||
# If your documentation needs a minimal Sphinx version, state it here.
|
||||
#
|
||||
# needs_sphinx = '1.0'
|
||||
|
||||
import defblock
|
||||
import inlinesyntaxhighlight
|
||||
|
||||
# Add any Sphinx extension module names here, as strings. They can be
|
||||
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
|
||||
# ones.
|
||||
extensions = [
|
||||
'sphinx.ext.todo',
|
||||
'sphinx.ext.mathjax',
|
||||
'defblock',
|
||||
'inlinesyntaxhighlight',
|
||||
'sphinxtogithub'
|
||||
]
|
||||
|
||||
inline_highlight_respect_highlight = False
|
||||
|
||||
inline_highlight_literals = False
|
||||
|
||||
# Add any paths that contain templates here, relative to this directory.
|
||||
templates_path = ['_templates']
|
||||
|
||||
# The suffix(es) of source filenames.
|
||||
# You can specify multiple suffix as a list of string:
|
||||
#
|
||||
# source_suffix = ['.rst', '.md']
|
||||
source_suffix = '.rst'
|
||||
|
||||
# The encoding of source files.
|
||||
#
|
||||
# source_encoding = 'utf-8-sig'
|
||||
|
||||
# The master toctree document.
|
||||
master_doc = 'index'
|
||||
|
||||
# General information about the project.
|
||||
project = 'The MiniZinc Handbook'
|
||||
copyright = '2016, 2017, 2018, 2019, 2020 Peter J. Stuckey, Kim Marriott, Guido Tack'
|
||||
author = 'Peter J. Stuckey, Kim Marriott, Guido Tack'
|
||||
|
||||
# The version info for the project you're documenting, acts as replacement for
|
||||
# |version| and |release|, also used in various other places throughout the
|
||||
# built documents.
|
||||
#
|
||||
# The short X.Y version.
|
||||
version = '2.5'
|
||||
# The full version, including alpha/beta/rc tags.
|
||||
release = '2.5.5'
|
||||
|
||||
# The language for content autogenerated by Sphinx. Refer to documentation
|
||||
# for a list of supported languages.
|
||||
#
|
||||
# This is also used if you do content translation via gettext catalogs.
|
||||
# Usually you set "language" from the command line for these cases.
|
||||
language = None
|
||||
|
||||
# There are two options for replacing |today|: either, you set today to some
|
||||
# non-false value, then it is used:
|
||||
#
|
||||
# today = ''
|
||||
#
|
||||
# Else, today_fmt is used as the format for a strftime call.
|
||||
#
|
||||
# today_fmt = '%B %d, %Y'
|
||||
|
||||
# List of patterns, relative to source directory, that match files and
|
||||
# directories to ignore when looking for source files.
|
||||
# This patterns also effect to html_static_path and html_extra_path
|
||||
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store', 'api_interfacing.rst']
|
||||
|
||||
# The reST default role (used for this markup: `text`) to use for all
|
||||
# documents.
|
||||
#
|
||||
# default_role = None
|
||||
|
||||
# If true, '()' will be appended to :func: etc. cross-reference text.
|
||||
#
|
||||
# add_function_parentheses = True
|
||||
|
||||
# If true, the current module name will be prepended to all description
|
||||
# unit titles (such as .. function::).
|
||||
#
|
||||
# add_module_names = True
|
||||
|
||||
# If true, sectionauthor and moduleauthor directives will be shown in the
|
||||
# output. They are ignored by default.
|
||||
#
|
||||
# show_authors = False
|
||||
|
||||
# The name of the Pygments (syntax highlighting) style to use.
|
||||
pygments_style = 'manni'
|
||||
|
||||
# A list of ignored prefixes for module index sorting.
|
||||
# modindex_common_prefix = []
|
||||
|
||||
# If true, keep warnings as "system message" paragraphs in the built documents.
|
||||
# keep_warnings = False
|
||||
|
||||
# If true, `todo` and `todoList` produce output, else they produce nothing.
|
||||
todo_include_todos = True
|
||||
|
||||
|
||||
# -- Options for HTML output ----------------------------------------------
|
||||
|
||||
import sphinx_rtd_theme
|
||||
|
||||
# The theme to use for HTML and HTML Help pages. See the documentation for
|
||||
# a list of builtin themes.
|
||||
#
|
||||
# html_theme = 'alabaster'
|
||||
|
||||
html_theme = 'sphinx_rtd_theme'
|
||||
html_theme_path = ["_themes", ]
|
||||
# html_theme_path = sphinx_bootstrap_theme.get_html_theme_path()
|
||||
|
||||
# Theme options are theme-specific and customize the look and feel of a theme
|
||||
# further. For a list of options available for each theme, see the
|
||||
# documentation.
|
||||
#
|
||||
html_theme_options = {
|
||||
'logo_only' : False,
|
||||
'canonical_url' : 'http://www.minizinc.org/doc-latest/en/'
|
||||
}
|
||||
|
||||
# Add any paths that contain custom themes here, relative to this directory.
|
||||
# html_theme_path = []
|
||||
|
||||
# The name for this set of Sphinx documents.
|
||||
# "<project> v<release> documentation" by default.
|
||||
#
|
||||
html_title = project+" "+release
|
||||
|
||||
# A shorter title for the navigation bar. Default is the same as html_title.
|
||||
#
|
||||
# html_short_title = None
|
||||
|
||||
# The name of an image file (relative to this directory) to place at the top
|
||||
# of the sidebar.
|
||||
#
|
||||
html_logo = 'figures/MiniZn_logo_2.svg'
|
||||
|
||||
# The name of an image file (relative to this directory) to use as a favicon of
|
||||
# the docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32
|
||||
# pixels large.
|
||||
#
|
||||
# html_favicon = None
|
||||
|
||||
# Add any paths that contain custom static files (such as style sheets) here,
|
||||
# relative to this directory. They are copied after the builtin static files,
|
||||
# so a file named "default.css" will overwrite the builtin "default.css".
|
||||
html_static_path = ['_static']
|
||||
|
||||
html_js_files = ['js/doc-links.js']
|
||||
|
||||
# Add any extra paths that contain custom files (such as robots.txt or
|
||||
# .htaccess) here, relative to this directory. These files are copied
|
||||
# directly to the root of the documentation.
|
||||
#
|
||||
# html_extra_path = []
|
||||
|
||||
# If not None, a 'Last updated on:' timestamp is inserted at every page
|
||||
# bottom, using the given strftime format.
|
||||
# The empty string is equivalent to '%b %d, %Y'.
|
||||
#
|
||||
# html_last_updated_fmt = None
|
||||
|
||||
# If true, SmartyPants will be used to convert quotes and dashes to
|
||||
# typographically correct entities.
|
||||
#
|
||||
# html_use_smartypants = True
|
||||
|
||||
# Custom sidebar templates, maps document names to template names.
|
||||
#
|
||||
# html_sidebars = {}
|
||||
|
||||
# Additional templates that should be rendered to pages, maps page names to
|
||||
# template names.
|
||||
#
|
||||
# html_additional_pages = {}
|
||||
|
||||
# If false, no module index is generated.
|
||||
#
|
||||
# html_domain_indices = True
|
||||
|
||||
# If false, no index is generated.
|
||||
#
|
||||
# html_use_index = True
|
||||
|
||||
# If true, the index is split into individual pages for each letter.
|
||||
#
|
||||
html_split_index = False
|
||||
|
||||
# If true, links to the reST sources are added to the pages.
|
||||
#
|
||||
html_show_sourcelink = False
|
||||
html_copy_source = False
|
||||
|
||||
# If true, "Created using Sphinx" is shown in the HTML footer. Default is True.
|
||||
#
|
||||
html_show_sphinx = False
|
||||
|
||||
# If true, "(C) Copyright ..." is shown in the HTML footer. Default is True.
|
||||
#
|
||||
# html_show_copyright = True
|
||||
|
||||
# If true, an OpenSearch description file will be output, and all pages will
|
||||
# contain a <link> tag referring to it. The value of this option must be the
|
||||
# base URL from which the finished HTML is served.
|
||||
#
|
||||
# html_use_opensearch = ''
|
||||
|
||||
# This is the file name suffix for HTML files (e.g. ".xhtml").
|
||||
# html_file_suffix = None
|
||||
|
||||
# Language to be used for generating the HTML full-text search index.
|
||||
# Sphinx supports the following languages:
|
||||
# 'da', 'de', 'en', 'es', 'fi', 'fr', 'h', 'it', 'ja'
|
||||
# 'nl', 'no', 'pt', 'ro', 'r', 'sv', 'tr', 'zh'
|
||||
#
|
||||
# html_search_language = 'en'
|
||||
|
||||
# A dictionary with options for the search language support, empty by default.
|
||||
# 'ja' uses this config value.
|
||||
# 'zh' user can custom change `jieba` dictionary path.
|
||||
#
|
||||
# html_search_options = {'type': 'default'}
|
||||
|
||||
# The name of a javascript file (relative to the configuration directory) that
|
||||
# implements a search results scorer. If empty, the default will be used.
|
||||
#
|
||||
# html_search_scorer = 'scorer.js'
|
||||
|
||||
# Output file base name for HTML help builder.
|
||||
htmlhelp_basename = 'MiniZincdoc'
|
||||
|
||||
# -- Options for LaTeX output ---------------------------------------------
|
||||
|
||||
latex_engine = 'xelatex'
|
||||
|
||||
latex_elements = {
|
||||
# The paper size ('letterpaper' or 'a4paper').
|
||||
#
|
||||
'papersize': 'a4paper',
|
||||
'fontpkg': r'''
|
||||
\usepackage{fontspec}
|
||||
\setmainfont{Charter}
|
||||
\setsansfont{Lato}
|
||||
\setmonofont{Inconsolata}
|
||||
\usepackage{ctex}
|
||||
''',
|
||||
# The font size ('10pt', '11pt' or '12pt').
|
||||
#
|
||||
'pointsize': '11pt',
|
||||
|
||||
# Additional stuff for the LaTeX preamble.
|
||||
#
|
||||
# 'preamble': '',
|
||||
'preamble': r'\usepackage{../../../utils/mznstyle}',
|
||||
# Latex figure (float) alignment
|
||||
#
|
||||
# 'figure_align': 'htbp',
|
||||
'fncychap': r'\usepackage[Sonny]{fncychap}',
|
||||
}
|
||||
|
||||
# Grouping the document tree into LaTeX files. List of tuples
|
||||
# (source start file, target name, title,
|
||||
# author, documentclass [howto, manual, or own class]).
|
||||
latex_documents = [
|
||||
(master_doc, 'MiniZinc.tex', 'MiniZinc Handbook',
|
||||
'Peter J. Stuckey, Kim Marriott, Guido Tack', 'manual'),
|
||||
]
|
||||
|
||||
# The name of an image file (relative to this directory) to place at the top of
|
||||
# the title page.
|
||||
#
|
||||
latex_logo = 'figures/MiniZn_logo_2_small.pdf'
|
||||
|
||||
# For "manual" documents, if this is true, then toplevel headings are parts,
|
||||
# not chapters.
|
||||
#
|
||||
latex_toplevel_sectioning = "part"
|
||||
|
||||
# If true, show page references after internal links.
|
||||
#
|
||||
latex_show_pagerefs = True
|
||||
|
||||
# If true, show URL addresses after external links.
|
||||
#
|
||||
latex_show_urls = "footnote"
|
||||
|
||||
# Documents to append as an appendix to all manuals.
|
||||
#
|
||||
# latex_appendices = []
|
||||
|
||||
# It false, will not define \strong, \code, itleref, \crossref ... but only
|
||||
# \sphinxstrong, ..., \sphinxtitleref, ... To help avoid clash with user added
|
||||
# packages.
|
||||
#
|
||||
# latex_keep_old_macro_names = True
|
||||
|
||||
# If false, no module index is generated.
|
||||
#
|
||||
# latex_domain_indices = True
|
||||
|
||||
|
||||
# -- Options for manual page output ---------------------------------------
|
||||
|
||||
# One entry per manual page. List of tuples
|
||||
# (source start file, name, description, authors, manual section).
|
||||
man_pages = [
|
||||
(master_doc, 'minizinc', 'MiniZinc Documentation',
|
||||
[author], 1)
|
||||
]
|
||||
|
||||
# If true, show URL addresses after external links.
|
||||
#
|
||||
# man_show_urls = False
|
||||
|
||||
|
||||
# -- Options for Texinfo output -------------------------------------------
|
||||
|
||||
# Grouping the document tree into Texinfo files. List of tuples
|
||||
# (source start file, target name, title, author,
|
||||
# dir menu entry, description, category)
|
||||
texinfo_documents = [
|
||||
(master_doc, 'MiniZinc', 'MiniZinc Documentation',
|
||||
author, 'MiniZinc', 'One line description of project.',
|
||||
'Miscellaneous'),
|
||||
]
|
||||
|
||||
# Documents to append as an appendix to all manuals.
|
||||
#
|
||||
# texinfo_appendices = []
|
||||
|
||||
# If false, no module index is generated.
|
||||
#
|
||||
# texinfo_domain_indices = True
|
||||
|
||||
# How to display URL addresses: 'footnote', 'no', or 'inline'.
|
||||
#
|
||||
# texinfo_show_urls = 'footnote'
|
||||
|
||||
# If true, do not generate a @detailmenu in the "Top" node's menu.
|
||||
#
|
||||
# texinfo_no_detailmenu = False
|
||||
|
||||
|
||||
# -- Options for Epub output ----------------------------------------------
|
||||
|
||||
# Bibliographic Dublin Core info.
|
||||
epub_title = project
|
||||
epub_author = author
|
||||
epub_publisher = author
|
||||
epub_copyright = copyright
|
||||
|
||||
# The basename for the epub file. It defaults to the project name.
|
||||
# epub_basename = project
|
||||
|
||||
# The HTML theme for the epub output. Since the default themes are not
|
||||
# optimized for small screen space, using the same theme for HTML and epub
|
||||
# output is usually not wise. This defaults to 'epub', a theme designed to save
|
||||
# visual space.
|
||||
#
|
||||
# epub_theme = 'epub'
|
||||
|
||||
# The language of the text. It defaults to the language option
|
||||
# or 'en' if the language is not set.
|
||||
#
|
||||
# epub_language = ''
|
||||
|
||||
# The scheme of the identifier. Typical schemes are ISBN or URL.
|
||||
# epub_scheme = ''
|
||||
|
||||
# The unique identifier of the text. This can be a ISBN number
|
||||
# or the project homepage.
|
||||
#
|
||||
# epub_identifier = ''
|
||||
|
||||
# A unique identification for the text.
|
||||
#
|
||||
# epub_uid = ''
|
||||
|
||||
# A tuple containing the cover image and cover page html template filenames.
|
||||
#
|
||||
# epub_cover = ()
|
||||
|
||||
# A sequence of (type, uri, title) tuples for the guide element of content.opf.
|
||||
#
|
||||
# epub_guide = ()
|
||||
|
||||
# HTML files that should be inserted before the pages created by sphinx.
|
||||
# The format is a list of tuples containing the path and title.
|
||||
#
|
||||
# epub_pre_files = []
|
||||
|
||||
# HTML files that should be inserted after the pages created by sphinx.
|
||||
# The format is a list of tuples containing the path and title.
|
||||
#
|
||||
# epub_post_files = []
|
||||
|
||||
# A list of files that should not be packed into the epub file.
|
||||
epub_exclude_files = ['search.html']
|
||||
|
||||
# The depth of the table of contents in toc.ncx.
|
||||
#
|
||||
# epub_tocdepth = 3
|
||||
|
||||
# Allow duplicate toc entries.
|
||||
#
|
||||
# epub_tocdup = True
|
||||
|
||||
# Choose between 'default' and 'includehidden'.
|
||||
#
|
||||
# epub_tocscope = 'default'
|
||||
|
||||
# Fix unsupported image types using the Pillow.
|
||||
#
|
||||
# epub_fix_images = False
|
||||
|
||||
# Scale large images.
|
||||
#
|
||||
# epub_max_image_width = 0
|
||||
|
||||
# How to display URL addresses: 'footnote', 'no', or 'inline'.
|
||||
#
|
||||
# epub_show_urls = 'inline'
|
||||
|
||||
# If false, no index is generated.
|
||||
#
|
||||
# epub_use_index = True
|
||||
|
||||
numfig = True
|
||||
numfig_secnum_depth = 2
|
||||
|
||||
rst_prolog = """
|
||||
.. role:: mzn(code)
|
||||
:language: minizinc
|
||||
|
||||
.. role:: mzndef(code)
|
||||
:language: minizincdef
|
||||
"""
|
||||
|
||||
sphinx_to_github = True
|
||||
sphinx_to_github_verbose = True
|
||||
sphinx_to_github_encoding = "utf-8"
|
||||
|
||||
def setup(sphinx):
|
||||
from minizinc_lexer import MznLexer, MznDefLexer
|
||||
sphinx.add_lexer("minizinc", MznLexer())
|
||||
sphinx.add_lexer("minizincdef", MznDefLexer())
|
||||
sphinx.add_stylesheet("style.css")
|
346
software/minizinc/docs/chi/efficient.rst
Normal file
@ -0,0 +1,346 @@
|
||||
.. _sec-efficient:
|
||||
|
||||
MiniZinc中的有效建模实践
|
||||
=========================================
|
||||
|
||||
对同一个问题,几乎总是存在多种方式来建模。其中一些产生的模型可以很有效地求解,另外一些则不是。通常情况下,我们很难提前判断哪个模型是对解决一个特定的问题最有效的。事实上,这或许十分依赖于我们使用的底层求解器。在这一章中,我们专注于建模实践,来避免产生模型的过程和产生的模型低效。
|
||||
|
||||
变量界限
|
||||
---------------
|
||||
|
||||
.. index::
|
||||
single: variable; bound
|
||||
|
||||
有限域传播器,是MiniZinc所针对的求解器中的核心类型。在当其所涉及到的变量的界限越紧凑时,此传播器越有效。
|
||||
它也会当问题含有会取很大整型数值的子表达式时表现得很差,因为它们可能会隐式地限制整型变量的大小。
|
||||
|
||||
|
||||
.. literalinclude:: examples/grocery.mzn
|
||||
:language: minizinc
|
||||
:name: ex-grocery
|
||||
:caption: 没有无界整数的模型 (:download:`grocery.mzn <examples/grocery.mzn>`).
|
||||
|
||||
在 :numref:`ex-grocery` 中的中的杂货店问题要找寻4个物品使得它们的价格加起来有7.11元并且乘起来也有7.11元。变量被声明为无界限。运行
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
$ minizinc --solver g12fd grocery.mzn
|
||||
|
||||
得到
|
||||
|
||||
.. code-block:: none
|
||||
|
||||
=====UNSATISFIABLE=====
|
||||
% /tmp/mznfile85EWzj.fzn:11: warning: model inconsistency detected before search.
|
||||
|
||||
这是因为乘法中的中间表达式的类型也会是 :mzn:`var int` ,也会被求解器给一个默认的界限 :math:`-1,000,000 \dots 1,000,000` 。但是这个范围太小了以至于不能承载住中间表达式所可能取的值。
|
||||
|
||||
更改模型使得初始变量都被声明为拥有更紧致的界限
|
||||
|
||||
.. code-block:: minizinc
|
||||
|
||||
var 1..711: item1;
|
||||
var 1..711: item2;
|
||||
var 1..711: item3;
|
||||
var 1..711: item4;
|
||||
|
||||
我们得到一个更好的模型,因为现在MiniZinc可以推断出中间表达式的界限,并且使用此界限而不是默认的界限。在做此更改后,求解模型我们得到
|
||||
|
||||
.. code-block:: none
|
||||
|
||||
{120,125,150,316}
|
||||
----------
|
||||
|
||||
注意,就算是改善的模型也可能对于某些求解器来说会很难解决。
|
||||
运行
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
$ minizinc --solver g12lazy grocery.mzn
|
||||
|
||||
不能得到任何结果,因为求解器给中间产生的变量创建了巨大的表示。
|
||||
|
||||
.. defblock:: 给变量加界限
|
||||
|
||||
.. index::
|
||||
single: variable; bound
|
||||
|
||||
在模型中要尽量使用有界限的变量。当使用 :mzn:`let` 声明来引进新的变量时,始终尽量给它们定义正确的和紧凑的界限。这会使得你的模型更有效率,避免出现意外溢出的可能性。
|
||||
一个例外是当你引进一个新的变量然后立刻定义它等于一个表达式,通常MiniZinc都可以从此表达式推断出此变量有效的界限。
|
||||
|
||||
有效的生成元
|
||||
--------------------
|
||||
|
||||
.. index::
|
||||
single: generator
|
||||
|
||||
想象下我们想要计算在一个图中出现的三角形的个数( :math:`K_3` 子图)。
|
||||
假设此图由一个邻接矩阵定义:如果点$i$和$j$邻接,则 :mzn:`adj[i,j]` 为真。
|
||||
我们或许可以写成
|
||||
|
||||
.. code-block:: minizinc
|
||||
|
||||
int: count = sum ([ 1 | i,j,k in NODES where i < j /\ j < k
|
||||
/\ adj[i,j] /\ adj[i,k] /\ adj[j,k]]);
|
||||
|
||||
这当然是对的,但是它检查了所有点可能组成的三元组。
|
||||
如果此图是稀疏的,在意识到一旦我们选择了 :mzn:`i` 和 :mzn:`j` ,就可以进行一些测试之后,我们可以做得更好。
|
||||
|
||||
.. code-block:: minizinc
|
||||
|
||||
int: count = sum ([ 1 | i,j in NODES where i < j /\ adj[i,j],
|
||||
k in NODES where j < k /\ adj[i,k] /\ adj[j,k]]);
|
||||
|
||||
你可以使用内建 :mzn:`trace` :index:`函数 <trace>` 来帮助决定在生成元内发生了什么。
|
||||
|
||||
.. defblock:: 追踪
|
||||
|
||||
函数 :mzn:`trace(s,e)` 在对表达式 :mzn:`e` 求值并返回它的值之前就输出字符串 :mzn:`s` 。它可以在任何情境下使用。
|
||||
|
||||
例如,我们可以查看在两种计算方式下的内部循环中分别进行了多少次测试。
|
||||
|
||||
.. literalinclude:: examples/count1.mzn
|
||||
:language: minizinc
|
||||
:lines: 8-15
|
||||
|
||||
得到输出:
|
||||
|
||||
.. code-block:: none
|
||||
|
||||
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
----------
|
||||
|
||||
表示内部循环进行了64次,而
|
||||
|
||||
.. literalinclude:: examples/count2.mzn
|
||||
:language: minizinc
|
||||
:lines: 13-14
|
||||
|
||||
得到输出
|
||||
|
||||
.. code-block:: none
|
||||
|
||||
++++++++++++++++
|
||||
----------
|
||||
|
||||
表示内部循环进行了16次。
|
||||
|
||||
注意你可以在 :mzn:`trace` 中使用单独的字符串来帮助你理解模型创建过程中发生了什么。
|
||||
|
||||
.. literalinclude:: examples/count3.mzn
|
||||
:language: minizinc
|
||||
:lines: 13-15
|
||||
|
||||
会输出在计算过程中找到的每个三角形。得到输出
|
||||
|
||||
.. code-block:: none
|
||||
|
||||
(1,2,3)
|
||||
----------
|
||||
|
||||
我们要承认这里我们有一点点作弊: 在某些情况下, MiniZinc编译器实际上会把 ``where`` 从句中的参数自动重新排序, 所以他们会尽快地被计算。在这种情况下, 加入 ``trace`` 函数实际上 *阻止* 了这种优化. 一般来说, 通过分离 ``where`` 从句把它们摆到尽量接近生成元, 这其实是一个很好的主意来帮助编译器运作正常。
|
||||
|
||||
|
||||
冗余约束
|
||||
---------------------
|
||||
|
||||
.. index::
|
||||
single: constraint; redundant
|
||||
|
||||
模型的形式会影响约束求解器求解它的效率。
|
||||
在很多情况下加入冗余约束,即被现有的模型逻辑上隐含的约束,可能会让求解器在更早时候产生更多可用的信息从而提高找寻解的搜索效率。
|
||||
|
||||
回顾下第 :ref:`sec-complex` 节中的魔术串问题。
|
||||
|
||||
运行 :mzn:`n = 16` 时的模型:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
$ minizinc --all-solutions --statistics magic-series.mzn -D "n=16;"
|
||||
|
||||
:mzn:`n = 16`
|
||||
|
||||
.. code-block:: none
|
||||
|
||||
s = [12, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0];
|
||||
----------
|
||||
==========
|
||||
|
||||
统计数据显示需要有89个失败。
|
||||
|
||||
我们可以在模型中加入冗余约束。由于序列中的每个数字是用来计算某一个数字出现的次数,我们知道它们的和肯定是 :mzn:`n` 。
|
||||
类似地,由于这个序列是魔术的,我们知道 :mzn:`s[i] * i` 的和肯定也是 :mzn:`n` 。
|
||||
使用如下方式把这些约束加入我们的模型 :numref:`ex-magic-series2`.
|
||||
|
||||
.. literalinclude:: examples/magic-series2.mzn
|
||||
:language: minizinc
|
||||
:name: ex-magic-series2
|
||||
:caption: 使用冗余约束求解魔术串问题模型 (:download:`magic-series2.mzn <examples/magic-series2.mzn>`).
|
||||
|
||||
像之前那样求解同一个问题
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
$ minizinc --all-solutions --statistics magic-series2.mzn -D "n=16;"
|
||||
|
||||
产生了同样的输出。但是统计显示只搜索了13个决策点。这些冗余约束使得求解器更早地去剪枝。
|
||||
|
||||
|
||||
模型选择
|
||||
-----------------
|
||||
|
||||
在MiniZinc中有很多方式去给同一个问题建模,尽管其中有些模型或许会比另外的一些模型更自然。
|
||||
不同的模型或许会产生不同的求解效率。更糟糕的是,在不同的求解后端中,不同的模型或许会更好或更差。
|
||||
但是,我们还是可以给出一些关于普遍情况下产生更好的模型的指导:
|
||||
|
||||
.. defblock:: 模型之间的选择
|
||||
|
||||
一个好的模型倾向于有以下特征
|
||||
|
||||
- 更少量的变量,或者至少是更少量的没有被其他变量功能上定义的变量。
|
||||
- 更小的变量定义域范围
|
||||
- 模型的约束定义更简洁或者直接
|
||||
- 尽可能地使用全局约束
|
||||
|
||||
实际情况中,所有这些都需要通过检查这个模型的搜索到底多有效率来断定模型好坏。通常除了用实验之外,我们很难判断搜索是否高效。
|
||||
|
||||
观察如下问题,我们要找寻1到 :math:`n` 这 :math:`n` 个数字的排列,使得相邻数字的差值也形成一个1到 :math:`n` 的排列。
|
||||
:numref:`ex-allint` 中给出了一个用直观的方式来建模此问题的模型。注意变量 :mzn:`u` 被变量 :mzn:`x` 功能性定义。所以最差情况下的搜索空间是 :math:`n^n`。
|
||||
|
||||
.. literalinclude:: examples/allinterval.mzn
|
||||
:language: minizinc
|
||||
:name: ex-allint
|
||||
:caption: 对于CSPlib ``prob007`` 所有间隔系列问题的模型 (:download:`allinterval.mzn <examples/allinterval.mzn>`).
|
||||
|
||||
在这个模型中,数组 :mzn:`x` 代表 :mzn:`n` 个数字的排序。约束自然地可用 :mzn:`alldifferent` 来表示。
|
||||
|
||||
求解模型
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
$ minizinc --solver g12fd --all-solutions --statistics allinterval.mzn -D "n=10;"
|
||||
|
||||
在84598个决策点和3秒的时间内找到了所有的解。
|
||||
|
||||
另外一个模型是使用数组 :mzn:`y` ,其中 :mzn:`y[i]` 代表数字 :mzn:`i` 在序列中的位置。
|
||||
我们同时也使用变量 :mzn:`v` 来建模表示差的位置。 :mzn:`v[i]` 表示了绝对值差 :mzn:`i` 在序列出现的位置。
|
||||
如果 :mzn:`y[i]` 和 :mzn:`y[j]` 差别为一,其中 :mzn:`j > i` ,则代表了它们的位置是相邻的。所以 :mzn:`v[j-i]` 被约束为两个位置中最早的那个。
|
||||
我们可以给这个模型加入两个冗余约束:由于我们知道差值 :mzn:`n-1` 肯定会产生,我们就可以推断出1和 :mzn:`n` 的位置必须是相邻的 :mzn:`abs( y[1] - y[n] ) = 1` 。同时也告诉我们差值 :mzn:`n-1` 的位置就是在 :mzn:`y[1]` 和 :mzn:`y[n]` 中的最早的那个位置,即 :mzn:`v[n-1] = min(y[1], y[n])` 。有了这些之后,我们可以建模此问题为:numref:`ex-allint2` 。
|
||||
输出语句从位置数组 :mzn:`y` 里重现了原本的序列 :mzn:`x` 。
|
||||
|
||||
.. literalinclude:: examples/allinterval2.mzn
|
||||
:language: minizinc
|
||||
:name: ex-allint2
|
||||
:caption: CSPlib中全区间序列问题 ``prob007`` 的一个逆向模型。 (:download:`allinterval2.mzn <examples/allinterval2.mzn>`).
|
||||
|
||||
逆向模型跟初始模型有同样的变量和定义域大小。但是相对于给变量 :mzn:`x` 和 :mzn:`u` 的关系建模,逆向模型使用了一个更加非直接的方式来给变量 :mzn:`y` 和 :mzn:`v` 的关系建模。所以我们或许期望初始模型更好些。
|
||||
|
||||
命令
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
$ minizinc --solver g12fd --all-solutions --statistics allinterval2.mzn -D "n=10;"
|
||||
|
||||
在75536个决策点和18秒内找到了所有的解。
|
||||
有趣的是,尽管这个模型不是简洁的,在变量 :mzn:`y` 上搜索比在变量 :mzn:`x` 上搜索更加有效率。
|
||||
简洁的缺乏意味着尽管搜索需要更少的决策点,但是在时间上实质上会更慢。
|
||||
|
||||
.. _sec-multiple-modelling-and-channels:
|
||||
|
||||
多重建模和连通
|
||||
-------------------------------
|
||||
|
||||
当我们对同一个问题有两个模型时,由于每个模型可以给求解器不同的信息,通过把两个模型中的变量系到一起从而同时使用两个模型或许对我们是有帮助的。
|
||||
|
||||
.. literalinclude:: examples/allinterval3.mzn
|
||||
:language: minizinc
|
||||
:name: ex-allint3
|
||||
:caption: CSPlib中全区间序列问题 ``prob007`` 的一个双重模型。 (:download:`allinterval3.mzn <examples/allinterval3.mzn>`).
|
||||
|
||||
:numref:`ex-allint3` 给出了一个结合 :download:`allinterval.mzn <examples/allinterval.mzn>` 和 :download:`allinterval2.mzn <examples/allinterval2.mzn>` 特征的双重模型。
|
||||
模型的开始来自于 :download:`allinterval.mzn <examples/allinterval.mzn>` 。我们接着介绍了来自于 :download:`allinterval2.mzn <examples/allinterval2.mzn>` 中的变量 :mzn:`y` 和 :mzn:`v` 。我们使用全局约束 :mzn:`inverse` 来把变量绑到一起: :mzn:`inverse(x,y)` 约束 :mzn:`y` 为 :mzn:`x` 的逆向函数(反之亦然),即, :mzn:`x[i] = j <-> y[j] = i` 。 :numref:`ex-inverse` 中给出了它的一个定义。这个模型没有包含把变量 :mzn:`y` 和 :mzn:`v` 关联起来的约束,它们是冗余的(实际上是传播冗余)。所以它们不会给基于传播的求解器多余的信息。 :mzn:`alldifferent` 也不见了。原因是它们被逆向约束变得冗余了(传播冗余)。
|
||||
唯一的约束是关于变量 :mzn:`x` 和 :mzn:`u` 和关系的约束以及 :mzn:`y` 和 :mzn:`v` 的冗余约束。
|
||||
|
||||
.. literalinclude:: examples/inverse.mzn
|
||||
:language: minizinc
|
||||
:name: ex-inverse
|
||||
:caption: 全局约束 ``inverse`` 的一个定义 (:download:`inverse.mzn <examples/inverse.mzn>`).
|
||||
|
||||
双重模型的一个优点是我们可以有更多的定义不同搜索策略的视角。运行双重模型,
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
$ minizinc --solver g12fd --all-solutions --statistics allinterval3.mzn -D "n=10;"
|
||||
|
||||
注意它使用逆向模型的搜索策略,标记变量 :mzn:`y` ,在1714决策点和0.5秒内找到了所有的解。注意标记变量 :mzn:`x` 来运行同样的模型,需要13142个决策点和1.5秒。
|
||||
|
||||
对称
|
||||
--------
|
||||
|
||||
对称在约束满足和优化问题中是常见的。我们可以再次通过 :numref:`ex-queens` 来看一下这个问题。在 :numref:`fig-queens-sym` 棋盘的左上方展示了一个8皇后问题的解(标记为 "original")。剩下的棋盘展示了7个解的对称版本:旋转90度,180度和270度,还有垂直翻转。
|
||||
|
||||
.. _fig-queens-sym:
|
||||
|
||||
.. figure:: figures/queens_symm.*
|
||||
|
||||
8皇后问题解的对称变化
|
||||
|
||||
如果我们想要穷举8皇后问题的 *所有* 解,很明显我们需要通过穷举 *彼此之间不对称的* 解 为求解器省下一些工作,然后生成这些的对称版本。这是我们想要在约束模型中摆脱对称的一个理由。另外一个更重要的理由是,我们的求解器也可能会 **探索非解状态的对称版本!**
|
||||
|
||||
举个例子,一个典型的约束求解器可能会尝试把第1列皇后放在第1行上(这是可以的),然后尝试把第2列的皇后放到第3行上。 这在第一眼看是没有违反任何约束的。然而,这种设置不能被完成成为一个解(求解器会在一些搜索之后发现这一点). :numref:`fig-queens-sym-unsat` 在左上方的棋盘展示了这种设置。现在没有任何东西会阻止求解器去尝试,比如,在 :numref:`fig-queens-sym-unsat` 最低一行的左边第二种设置。其中第1列的皇后仍然在第1行,而第3列的皇后放在第2行。于是,即便是搜索一个解,求解器可能需要探索很多它已经看到并证明不可满足状态的对称状态!
|
||||
|
||||
.. _fig-queens-sym-unsat:
|
||||
|
||||
.. figure:: figures/queens_symm_unsat.*
|
||||
|
||||
8皇后问题不可满足约束的部分解的对称版本
|
||||
|
||||
静态的对称性破缺
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
解决对称问题的建模技巧叫做 *对称性破缺* , 在它的最简单形式里, 需要在模型中加入约束使一个(不完整的)赋值的所有对称变换去除掉而保留一个。 这些约束称作 *静态的对称性破缺约束* 。
|
||||
|
||||
对称性破缺背后基本的想法是加入 *顺序* 。举个例子, 我们可以通过简单地加入约束使第一列的皇后必须在棋盘的上半部分,从而去除掉所有棋盘垂直翻转的。
|
||||
|
||||
.. code-block:: minizinc
|
||||
|
||||
constraint q[1] <= n div 2;
|
||||
|
||||
请相信以上约束会去除掉在 :numref:`fig-queens-sym` 中所有对称变换的一半。 为了去除 *所有* 对称,我们需要更多工作。
|
||||
|
||||
当我们把所有对称都表示成数组变量的排列,一组 *字典顺序约束* 可以用于破坏所有对称。 举个例子,如果数组变量名为 :mzn:`x` ,而翻转数组是这个问题的一种对称,那么以下约束可以破坏那种对称:
|
||||
|
||||
.. code-block:: minizinc
|
||||
|
||||
constraint lex_lesseq(x, reverse(x));
|
||||
|
||||
那么二维数组又怎么样呢?字典顺序同样适用,我们只需要把数组转换成一维的. 举个例子,下面的约束破坏了沿着其中一个对角线翻转数组的对称性(注意到第二个生成式里对换的数组下标):
|
||||
|
||||
.. code-block:: minizinc
|
||||
|
||||
array[1..n,1..n] of var int: x;
|
||||
constraint lex_lesseq([ x[i,j] | i,j in 1..n ], [ x[j,i] | i,j in 1..n ]);
|
||||
|
||||
字典排序约束的好处在于我们可以加入多个(同时破坏几个对称性),而不需要它们互相干扰,只要我们保持第一个参数中的顺序一致即可。
|
||||
|
||||
对于n皇后问题,很不幸的是这个技巧不能马上适用, 因为又一些对称不能被描述成数组 :mzn:`q` 的排列。 克服这个问题的技巧是把n皇后问题表示成布尔变量。 对于每个棋盘的每个格子, 布尔变量表示是否有一个皇后在上面。现在所有的对称性都可以表示成这个数组的排列。 因为主要的n皇后问题的主要约束在整型数组 :mzn:`q` 里面更加容易表达, 我们只需要两个模型都用起来,然后在它们之间加入连通约束。 正如 :ref:`sec-multiple-modelling-and-channels` 中解释的一样。
|
||||
|
||||
加入布尔变量,连通约束和对称性破缺约束的完整模型展示在 :numref:`ex-queens-sym` 里面。 我们可以做一些小实验来检查它是否成功的破坏所有对称性。 尝试用不断增加的 :mzn:`n` 运行模型, 比如从1到10, 数一下解的个数(比如,使用 Gecode求解器的 ``-s`` 标志, 或者选择IDE中"Print all solutions"和"Statistics for solving")。 你应该可以获得以下数列的解: 1, 0, 0, 1, 2, 1, 6, 12, 46, 92。 你可以搜索 *On-Line Encyclopedia of Integer Sequences* (http://oeis.org) 来校验这个序列。
|
||||
|
||||
.. literalinclude:: examples/nqueens_sym.mzn
|
||||
:language: minizinc
|
||||
:name: ex-queens-sym
|
||||
:start-after: % 可选的
|
||||
:end-before: % 搜索
|
||||
:caption: n皇后问题对称性破缺的部分模型 (full model: :download:`nqueens_sym.mzn <examples/nqueens_sym.mzn>`).
|
||||
|
||||
|
||||
其他对称的例子
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
许多其他问题都有内在的对称性,破坏这些对称性常常会令求解表现不一样。以下是一些常见的例子:
|
||||
|
||||
- 装箱问题: 当尝试把物品装入箱子时,任意两个有相同容量的箱子都是对称的
|
||||
- 涂色问题: 当尝试为一个图涂色使得所有相邻的节点都有不同的颜色时,我们通常用整型变量对颜色建模。但是,对颜色的任意排列都是一种合法的涂色方案。
|
||||
- 车辆路线问题: 如果任务是给顾客分配一些车辆,任何两辆有相同容量的车可能是对称的(这跟装箱问题是相似的)
|
||||
- 排班/时间表问题: 两个有相同能力的职员可能是可以相互交换的,就像两个有相同容量或者设备的的房间一样
|
14
software/minizinc/docs/chi/examples/allinterval.mzn
Normal file
@ -0,0 +1,14 @@
|
||||
include "alldifferent.mzn";
|
||||
|
||||
int: n;
|
||||
|
||||
array[1..n] of var 1..n: x; % 数字的序列
|
||||
array[1..n-1] of var 1..n-1: u; % 差的序列
|
||||
|
||||
constraint alldifferent(x);
|
||||
constraint alldifferent(u);
|
||||
constraint forall(i in 1..n-1)(u[i] = abs(x[i+1] - x[i]));
|
||||
|
||||
solve :: int_search(x, first_fail, indomain_min, complete)
|
||||
satisfy;
|
||||
output ["x = ",show(x),"\n"];
|
22
software/minizinc/docs/chi/examples/allinterval2.mzn
Normal file
@ -0,0 +1,22 @@
|
||||
include "alldifferent.mzn";
|
||||
|
||||
int: n;
|
||||
|
||||
array[1..n] of var 1..n: y; % 每个数值的位置
|
||||
array[1..n-1] of var 1..n-1: v; % 差值i的位置
|
||||
|
||||
constraint alldifferent(y);
|
||||
constraint alldifferent(v);
|
||||
constraint forall(i,j in 1..n where i < j)(
|
||||
(y[i] - y[j] = 1 -> v[j-i] = y[j]) /\
|
||||
(y[j] - y[i] = 1 -> v[j-i] = y[i])
|
||||
);
|
||||
|
||||
constraint abs(y[1] - y[n]) = 1 /\ v[n-1] = min(y[1], y[n]);
|
||||
|
||||
solve :: int_search(y, first_fail, indomain_min, complete)
|
||||
satisfy;
|
||||
|
||||
output [ "x = [",] ++
|
||||
[ show(i) ++ if j == n then "]\n;" else ", " endif
|
||||
| j in 1..n, i in 1..n where j == fix(y[i]) ];
|
21
software/minizinc/docs/chi/examples/allinterval3.mzn
Normal file
@ -0,0 +1,21 @@
|
||||
include "inverse.mzn";
|
||||
|
||||
int: n;
|
||||
|
||||
array[1..n] of var 1..n: x; % 数值的序列
|
||||
array[1..n-1] of var 1..n-1: u; % 差值的序列
|
||||
|
||||
constraint forall(i in 1..n-1)(u[i] = abs(x[i+1] - x[i]));
|
||||
|
||||
array[1..n] of var 1..n: y; % 每个数值的位置
|
||||
array[1..n-1] of var 1..n-1: v; % 差值的位置
|
||||
|
||||
constraint inverse(x,y);
|
||||
constraint inverse(u,v);
|
||||
|
||||
constraint abs(y[1] - y[n]) = 1 /\ v[n-1] = min(y[1], y[n]);
|
||||
|
||||
solve :: int_search(y, first_fail, indomain_min, complete)
|
||||
satisfy;
|
||||
|
||||
output ["x = ",show(x),"\n"];
|
11
software/minizinc/docs/chi/examples/aust-enum.mzn
Normal file
@ -0,0 +1,11 @@
|
||||
enum Color;
|
||||
var Color: wa;
|
||||
var Color: nt;
|
||||
var Color: sa;
|
||||
var Color: q;
|
||||
var Color: nsw;
|
||||
var Color: v;
|
||||
var Color: t;
|
||||
constraint wa != nt /\ wa != sa /\ nt != sa /\ nt != q /\ sa != q;
|
||||
constraint sa != nsw /\ sa != v /\ q != nsw /\ nsw != v;
|
||||
solve satisfy;
|
20
software/minizinc/docs/chi/examples/aust.mzn
Normal file
@ -0,0 +1,20 @@
|
||||
% 用nc个颜色来涂澳大利亚
|
||||
int: nc = 3;
|
||||
|
||||
var 1..nc: wa; var 1..nc: nt; var 1..nc: sa; var 1..nc: q;
|
||||
var 1..nc: nsw; var 1..nc: v; var 1..nc: t;
|
||||
|
||||
constraint wa != nt;
|
||||
constraint wa != sa;
|
||||
constraint nt != sa;
|
||||
constraint nt != q;
|
||||
constraint sa != q;
|
||||
constraint sa != nsw;
|
||||
constraint sa != v;
|
||||
constraint q != nsw;
|
||||
constraint nsw != v;
|
||||
solve satisfy;
|
||||
|
||||
output ["wa=\(wa)\t nt=\(nt)\t sa=\(sa)\n",
|
||||
"q=\(q)\t nsw=\(nsw)\t v=\(v)\n",
|
||||
"t=", show(t), "\n"];
|
19
software/minizinc/docs/chi/examples/bboolsum.mzn
Normal file
@ -0,0 +1,19 @@
|
||||
% 布尔型变量x的总和 = s
|
||||
predicate bool_sum_eq(array[int] of var bool:x, int:s) =
|
||||
let { int: c = length(x) } in
|
||||
if s < 0 then false
|
||||
elseif s == 0 then
|
||||
forall(i in 1..c)(x[i] == false)
|
||||
elseif s < c then
|
||||
let { % cp = number of bits required for representing 0..c
|
||||
int: cp = floor(log2(int2float(c))),
|
||||
% z is sum of x in binary
|
||||
array[0..cp] of var bool:z } in
|
||||
binary_sum(x, z) /\
|
||||
% z == s
|
||||
forall(i in 0..cp)(z[i] == ((s div pow(2,i)) mod 2 == 1))
|
||||
elseif s == c then
|
||||
forall(i in 1..c)(x[i] == true)
|
||||
else false endif;
|
||||
|
||||
include "binarysum.mzn";
|
18
software/minizinc/docs/chi/examples/bddsum.mzn
Normal file
@ -0,0 +1,18 @@
|
||||
% the sum of booleans x = s
|
||||
predicate bool_sum_eq(array[int] of var bool:x, int:s) =
|
||||
let { int: c = length(x),
|
||||
array[1..c] of var bool: y = [x[i] | i in index_set(x)]
|
||||
} in
|
||||
rec_bool_sum_eq(y, 1, s);
|
||||
|
||||
predicate rec_bool_sum_eq(array[int] of var bool:x, int: f, int:s) =
|
||||
let { int: c = length(x) } in
|
||||
if s < 0 then false
|
||||
elseif s == 0 then
|
||||
forall(i in f..c)(x[i] == false)
|
||||
elseif s < c - f + 1 then
|
||||
(x[f] == true /\ rec_bool_sum_eq(x,f+1,s-1)) \/
|
||||
(x[f] == false /\ rec_bool_sum_eq(x,f+1,s))
|
||||
elseif s == c - f + 1 then
|
||||
forall(i in f..c)(x[i] == true)
|
||||
else false endif;
|
39
software/minizinc/docs/chi/examples/binarysum.mzn
Normal file
@ -0,0 +1,39 @@
|
||||
% 位 x 的的总和 = 二元表示的 s。
|
||||
% s[0], s[1], ..., s[k] 其中 2^k >= length(x) > 2^(k-1)
|
||||
predicate binary_sum(array[int] of var bool:x,
|
||||
array[int] of var bool:s)=
|
||||
let { int: l = length(x) } in
|
||||
if l == 1 then s[0] = x[1]
|
||||
elseif l == 2 then
|
||||
s[0] = (x[1] xor x[2]) /\ s[1] = (x[1] /\ x[2])
|
||||
else let { int: ll = (l div 2),
|
||||
array[1..ll] of var bool: f = [ x[i] | i in 1..ll ],
|
||||
array[1..ll] of var bool: t = [x[i]| i in ll+1..2*ll],
|
||||
var bool: b = if ll*2 == l then false else x[l] endif,
|
||||
int: cp = floor(log2(int2float(ll))),
|
||||
array[0..cp] of var bool: fs,
|
||||
array[0..cp] of var bool: ts } in
|
||||
binary_sum(f, fs) /\ binary_sum(t, ts) /\
|
||||
binary_add(fs, ts, b, s)
|
||||
endif;
|
||||
|
||||
% 把两个二元数值 x 和 y 加起来,位 ci 用来表示进位,来得到二元 s
|
||||
predicate binary_add(array[int] of var bool: x,
|
||||
array[int] of var bool: y,
|
||||
var bool: ci,
|
||||
array[int] of var bool: s) =
|
||||
let { int:l = length(x),
|
||||
int:n = length(s), } in
|
||||
assert(l == length(y),
|
||||
"length of binary_add input args must be same",
|
||||
assert(n == l \/ n == l+1, "length of binary_add output " ++
|
||||
"must be equal or one more than inputs",
|
||||
let { array[0..l] of var bool: c } in
|
||||
full_adder(x[0], y[0], ci, s[0], c[0]) /\
|
||||
forall(i in 1..l)(full_adder(x[i], y[i], c[i-1], s[i], c[i])) /\
|
||||
if n > l then s[n] = c[l] else c[l] == false endif ));
|
||||
|
||||
predicate full_adder(var bool: x, var bool: y, var bool: ci,
|
||||
var bool: s, var bool: co) =
|
||||
let { var bool: xy = x xor y } in
|
||||
s = (xy xor ci) /\ co = ((x /\ y) \/ (ci /\ xy));
|
21
software/minizinc/docs/chi/examples/cakes.mzn
Normal file
@ -0,0 +1,21 @@
|
||||
% 为校园游乐会做蛋糕
|
||||
|
||||
var 0..100: b; % 香蕉蛋糕的个数
|
||||
var 0..100: c; % 巧克力蛋糕的个数
|
||||
|
||||
% 面粉
|
||||
constraint 250*b + 200*c <= 4000;
|
||||
% 香蕉
|
||||
constraint 2*b <= 6;
|
||||
% 糖
|
||||
constraint 75*b + 150*c <= 2000;
|
||||
% 黄油
|
||||
constraint 100*b + 150*c <= 500;
|
||||
% 可可粉
|
||||
constraint 75*c <= 500;
|
||||
|
||||
% 最大化我们的利润
|
||||
solve maximize 400*b + 450*c;
|
||||
|
||||
output ["no. of banana cakes = \(b)\n",
|
||||
"no. of chocolate cakes = \(c)\n"];
|
38
software/minizinc/docs/chi/examples/cakes2.mzn
Normal file
@ -0,0 +1,38 @@
|
||||
% 为校园游乐会做蛋糕(和数据文件一起)
|
||||
|
||||
int: flour; %拥有的面粉克数
|
||||
int: banana; %拥有的香蕉个数
|
||||
int: sugar; %拥有的糖克数
|
||||
int: butter; %拥有的黄油克数
|
||||
int: cocoa; %拥有的可可粉克数
|
||||
|
||||
constraint assert(flour >= 0,"Invalid datafile: " ++
|
||||
"Amount of flour should be non-negative");
|
||||
constraint assert(banana >= 0,"Invalid datafile: " ++
|
||||
"Amount of banana should be non-negative");
|
||||
constraint assert(sugar >= 0,"Invalid datafile: " ++
|
||||
"Amount of sugar should be non-negative");
|
||||
constraint assert(butter >= 0,"Invalid datafile: " ++
|
||||
"Amount of butter should be non-negative");
|
||||
constraint assert(cocoa >= 0,"Invalid datafile: " ++
|
||||
"Amount of cocoa should be non-negative");
|
||||
|
||||
var 0..100: b; % 香蕉蛋糕的个数
|
||||
var 0..100: c; % 巧克力蛋糕的个数
|
||||
|
||||
% 面粉
|
||||
constraint 250*b + 200*c <= flour;
|
||||
% 香蕉
|
||||
constraint 2*b <= banana;
|
||||
% 糖
|
||||
constraint 75*b + 150*c <= sugar;
|
||||
% 黄油
|
||||
constraint 100*b + 150*c <= butter;
|
||||
% 可可粉
|
||||
constraint 75*c <= cocoa;
|
||||
|
||||
% 最大化我们的利润
|
||||
solve maximize 400*b + 450*c;
|
||||
|
||||
output ["no. of banana cakes = \(b)\n",
|
||||
"no. of chocolate cakes = \(c)\n"];
|
35
software/minizinc/docs/chi/examples/cars.mzn
Normal file
@ -0,0 +1,35 @@
|
||||
% cars.mzn
|
||||
include "globals.mzn";
|
||||
|
||||
int: n_cars; int: n_options; int: n_classes;
|
||||
|
||||
set of int: steps = 1..n_cars;
|
||||
set of int: options = 1..n_options;
|
||||
set of int: classes = 1..n_classes;
|
||||
|
||||
array [options] of int: max_per_block;
|
||||
array [options] of int: block_size;
|
||||
array [classes] of int: cars_in_class;
|
||||
array [classes, options] of 0..1: need;
|
||||
|
||||
% The class of car being started at each step.
|
||||
array [steps] of var classes: class;
|
||||
|
||||
% Which options are required by the car started at each step.
|
||||
array [steps, options] of var 0..1: used;
|
||||
|
||||
% Block p must be used at step s if the class of the car to be
|
||||
% produced at step s needs it.
|
||||
constraint forall (s in steps, p in options) (used[s, p]=need[class[s], p]);
|
||||
|
||||
% For each option p with block size b and maximum limit m, no consecutive
|
||||
% sequence of b cars contains more than m that require option p.
|
||||
constraint
|
||||
forall (p in options, i in 1..(n_cars - (block_size[p] - 1))) (
|
||||
sum (j in 0..(block_size[p] - 1)) (used[i + j, p])
|
||||
<= max_per_block[p]);
|
||||
|
||||
% Require that the right number of cars in each class are produced.
|
||||
constraint forall (c in classes) (count(class, c, cars_in_class[c]));
|
||||
|
||||
solve satisfy; % Find any solution.
|
16
software/minizinc/docs/chi/examples/cars_data.dzn
Normal file
@ -0,0 +1,16 @@
|
||||
% cars_data.dzn
|
||||
n_cars = 10;
|
||||
n_options = 5;
|
||||
n_classes = 6;
|
||||
max_per_block = [1, 2, 1, 2, 1];
|
||||
block_size = [2, 3, 3, 5, 5];
|
||||
cars_in_class = [1, 1, 2, 2, 2, 2];
|
||||
|
||||
need = array2d(1..6, 1..5, [
|
||||
1, 0, 1, 1, 0,
|
||||
0, 0, 0, 1, 0,
|
||||
0, 1, 0, 0, 1,
|
||||
0, 1, 0, 1, 0,
|
||||
1, 0, 1, 0, 0,
|
||||
1, 1, 0, 0, 0
|
||||
]);
|
19
software/minizinc/docs/chi/examples/cnonoverlap.fzn
Normal file
@ -0,0 +1,19 @@
|
||||
% 变量
|
||||
var 2.0 .. 8.0: x1;
|
||||
var 2.0 .. 6.0: y1;
|
||||
var 3.0 .. 7.0: x2;
|
||||
var 3.0 .. 5.0: y2;
|
||||
%
|
||||
var -5.0..5.0: FLOAT01;
|
||||
var -25.0..25.0: FLOAT02;
|
||||
var -3.0..3.0: FLOAT03;
|
||||
var -9.0..9.0: FLOAT04;
|
||||
var 25.0..34.0: FLOAT05;
|
||||
% 约束
|
||||
constraint float_plus(FLOAT01, x2, x1);
|
||||
constraint float_plus(FLOAT03, y2, y1);
|
||||
constraint float_plus(FLOAT02, FLOAT04, FLOAT05);
|
||||
constraint float_times(FLOAT01, FLOAT01, FLOAT02);
|
||||
constraint float_times(FLOAT03, FLOAT03, FLOAT04);
|
||||
%
|
||||
solve satisfy;
|
11
software/minizinc/docs/chi/examples/cnonoverlap.mzn
Normal file
@ -0,0 +1,11 @@
|
||||
float: width; % 包含圆的长方形的宽
|
||||
float: height; % 包含圆的长方形的高
|
||||
float: r1;
|
||||
var r1..width-r1: x1; % (x1,y1) 是第一个圆的中心
|
||||
var r1..height-r1: y1;
|
||||
float: r2;
|
||||
var r2..width-r2: x2; % (x2,y2) 是第二个圆的中心
|
||||
var r2..height-r2: y2;
|
||||
% 中心之间至少有r1 + r2的距离
|
||||
constraint (x1-x2)*(x1-x2) + (y1-y2)*(y1-y2) >= (r1+r2)*(r1+r2);
|
||||
solve satisfy;
|
@ -0,0 +1 @@
|
||||
n = 5;
|
@ -0,0 +1,6 @@
|
||||
int: n;
|
||||
array[1..n] of var 1..2*n: x;
|
||||
include "alldifferent.mzn";
|
||||
constraint alldifferent(x);
|
||||
solve maximize sum(x);
|
||||
output ["The resulting values are \(x).\n"];
|
15
software/minizinc/docs/chi/examples/count1.mzn
Normal file
@ -0,0 +1,15 @@
|
||||
% ignore
|
||||
int:n;
|
||||
set of int: NODES = 1..n;
|
||||
array [NODES,NODES] of bool: adj;
|
||||
bool: t = true;
|
||||
bool: f = false;
|
||||
n = 4;
|
||||
int:count=sum([ 1 | i,j,k in NODES where
|
||||
trace("+", i<j /\j<k /\ adj[i,j] /\ adj[i,k] /\ adj[j,k]) ]);
|
||||
adj = [| false, true, true, false
|
||||
| true, false, true, false
|
||||
| true, true, false, true
|
||||
| false, false, true, false |];
|
||||
constraint trace("\n",true);
|
||||
solve satisfy;
|
17
software/minizinc/docs/chi/examples/count2.mzn
Normal file
@ -0,0 +1,17 @@
|
||||
% ignore
|
||||
int:n;
|
||||
set of int: NODES = 1..n;
|
||||
array [NODES,NODES] of bool: adj;
|
||||
bool: t = true;
|
||||
bool: f = false;
|
||||
n = 4;
|
||||
adj = [| false, true, true, false
|
||||
| true, false, true, false
|
||||
| true, true, false, true
|
||||
| false, false, true, false |];
|
||||
solve satisfy;
|
||||
int: count = sum ([ 1 | i,j in NODES where i < j /\ adj[i,j],
|
||||
k in NODES where trace("+", j < k /\ adj[i,k] /\ adj[j,k])]);
|
||||
|
||||
% ignore
|
||||
constraint trace("\n",true);
|