logo资料库

MiniZinc Handbook中文手册.pdf

第1页 / 共496页
第2页 / 共496页
第3页 / 共496页
第4页 / 共496页
第5页 / 共496页
第6页 / 共496页
第7页 / 共496页
第8页 / 共496页
资料共496页,剩余部分请下载后查看
1 Overview
Introduction
Structure
How to Read This
Installation
Microsoft Windows
Linux
Snap
AppImage
Archive
Apple macOS
Adding Third-party Solvers
First steps with MiniZinc
The MiniZinc IDE
The MiniZinc command line tool
2 Minizinc 指南
MiniZinc基本模型
第一个实例
算术优化实例
数据文件和谓词
实数求解
模型的基本结构
更多复杂模型
数组和集合
全局约束
条件表达式
枚举类型
复杂约束
集合约束
汇总
谓词和函数
全局约束
Alldifferent
Cumulative
Table
Regular
定义谓词
定义函数
反射函数
局部变量
语境
局部约束
定义域反射函数
作用域
选项类型
声明和使用选项类型
隐藏选项类型
搜索
有限域搜索
搜索注解
注解
MiniZinc中的有效建模实践
变量界限
有效的生成元
冗余约束
模型选择
多重建模和连通
对称
静态的对称性破缺
其他对称的例子
在MiniZinc中对布尔可满足性问题建模
整型建模
非等式建模
势约束建模
FlatZinc和展平
展平表达式
简化和求值
定义子表达式
FlatZinc约束形式
边界分析
目标函数
线性表达式
展开表达式
数组
具体化
谓词
Let表达式
3 User Manual
The MiniZinc Command Line Tool
Basic Usage
Adding Solvers
Configuration files
Configuration for MIP solvers
Options
General options
Solving options
Flattener input options
Flattener two-pass options
Flattener output options
Solution output options
User Configuration Files
The MiniZinc IDE
Editing files
Editing functions
Fonts and dark mode
Configuring and Running a Solver
Running a model
Solver configurations
Automatic Solution Checking
Compiling a model
Profiling a model
Working With Projects
Submitting Solutions to Online Courses
Configuration Options
Locating the MiniZinc installation
Adding Third-Party Solvers
Configuring existing solvers
Adding new solvers
Globalizer
Basic Usage
Caveats
Supported Constraints
Using Globalizer in the MiniZinc IDE
How it works
Performance tips
Limitations / Future work
FindMUS
Basic Usage
Commandline arguments
Example
Using FindMUS in the MiniZinc IDE
How it works
Performance tips
Limitations / Future work
Using MiniZinc in Jupyter Notebooks
Installation
Basic usage
Python Interface
4 Reference Manual
Specification of MiniZinc
Introduction
Original authors.
Notation
Overview of a Model
Evaluation Phases
Run-time Outcomes
Output
Syntax Overview
Character Set
Comments
Identifiers
High-level Model Structure
Model Instance Files
Namespaces
Scopes
Types and Type-insts
Properties of Types
Instantiations
Type-insts
Type-inst expression overview
Built-in Scalar Types and Type-insts
Booleans
Integers
Floats
Enumerated Types
Strings
Built-in Compound Types and Type-insts
Sets
Arrays
Option Types
The Annotation Type
Constrained Type-insts
Set Expression Type-insts
Float Range Type-insts
Expressions
Expressions Overview
Operators
Expression Atoms
Identifier Expressions and Quoted Operator Expressions
Anonymous Decision Variables
Boolean Literals
Integer and Float Literals
String Literals and String Interpolation
Set Literals
Set Comprehensions
Array Literals
2d Array Literals
Array Comprehensions
Array Access Expressions
Array Slice Expressions
Annotation Literals
If-then-else Expressions
Let Expressions
Call Expressions
Generator Call Expressions
Items
Include Items
Variable Declaration Items
Enum Items
Assignment Items
Constraint Items
Solve Items
Output Items
Annotation Items
User-defined Operations
Basic Properties
Ad-hoc polymorphism
Local Variables
Annotations
Partiality
Partial Assignments
Partial Predicate/Function and Annotation Arguments
Partial Array Accesses
Built-in Operations
Comparison Operations
Arithmetic Operations
Logical Operations
Set Operations
Array Operations
Coercion Operations
String Operations
Bound and Domain Operations
Option Type Operations
Other Operations
Content-types
JSON support
Full grammar
Items
Type-Inst Expressions
Expressions
Miscellaneous Elements
The MiniZinc library
Annotations
General annotations
Parameters
Functions and Predicates
Propagation strength annotations
Search annotations
Variable selection annotations
Value choice annotations
Exploration strategy annotations
Restart annotations
Parameters
Functions and Predicates
Other declarations
Warm start annotations
Warm start annotations with optional values
Other declarations
Option type support
Option type support for Booleans
Option type support for integers
Option type support for floats
Other declarations
Compiler options
Parameters
Functions and Predicates
Builtins
Comparison Builtins
Arithmetic Builtins
Exponential and logarithmic builtins
Trigonometric functions
Logical operations
Set operations
Conditionals
Array operations
Array sorting operations
Coercions
String operations
Reflection operations
Assertions and debugging functions
Functions for enums
Random Number Generator builtins
Special constraints
Language information
FlatZinc builtins
Integer FlatZinc builtins
Bool FlatZinc builtins
Set FlatZinc builtins
Float FlatZinc builtins
FlatZinc builtins added in MiniZinc 2.0.0.
FlatZinc builtins added in MiniZinc 2.0.2.
FlatZinc builtins added in MiniZinc 2.1.0.
FlatZinc builtins added in MiniZinc 2.1.1.
Global constraints
Counting constraints
All-Different and related constraints
Lexicographic constraints
Sorting constraints
Channeling constraints
Packing constraints
Scheduling constraints
Graph constraints
Extensional constraints (table, regular etc.)
Machine learning constraints
Deprecated constraints
Other declarations
Additional declarations for Gecode
Additional Gecode search annotations
Parameters
Functions and Predicates
Additional Gecode constraints
Additional declarations for Chuffed
Additional Chuffed search annotations
Parameters
Functions and Predicates
Interfacing Solvers to Flatzinc
Specification of FlatZinc
Comments
Types
Parameter types
Variable types
The string type
Values and expressions
FlatZinc models
Predicate declarations
Parameter declarations
Variable declarations
Constraints
Solve item
Annotations
Search annotations
Output annotations
Variable definition annotations
Intermediate variables
Constraint annotations
Output
Solution output
Statistics output
Error and warning output
Solver-specific Libraries
Standard predicates
Solver-specific predicates
Reified and half-reified predicates
Command-Line Interface and Standard Options
Solver Configuration Files
Grammar
Index
MiniZinc Handbook Release 2.4.3 Peter J. Stuckey, Kim Marrio, Guido Tack Mar 03, 2020
Contents 1 Overview 1.1 Introduction 1.1.1 Structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1.1.2 How to Read This . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3 5 6 6 1.2 Installation 9 1.2.1 Microsoft Windows . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9 1.2.2 Linux . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10 1.2.2.1 Snap . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10 1.2.2.2 AppImage . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10 1.2.2.3 Archive . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11 1.2.3 Apple macOS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12 1.2.4 Adding Third-party Solvers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12 1.3 First steps with MiniZinc 13 1.3.1 The MiniZinc IDE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13 1.3.2 The MiniZinc command line tool . . . . . . . . . . . . . . . . . . . . . . . . . . 18 2 Minizinc 指南 2.1 MiniZinc 基本模型 21 23 2.1.1 第一个实例 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23 2.1.2 算术优化实例 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28 2.1.3 数据文件和谓词 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29 2.1.4 实数求解 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32 2.1.5 模型的基本结构 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35 2.2 更多复杂模型 39 2.2.1 数组和集合 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39 2.2.2 全局约束 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50 2.2.3 条件表达式 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51 2.2.4 枚举类型 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54 2.2.5 复杂约束 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56 i
2.2.6 集合约束 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63 2.2.7 汇总 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 66 2.3 谓词和函数 69 2.3.1 全局约束 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 69 2.3.1.1 Alldifferent . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 69 2.3.1.2 Cumulative . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 70 2.3.1.3 Table . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 71 2.3.1.4 Regular . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 74 2.3.2 定义谓词 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 77 2.3.3 定义函数 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 79 2.3.4 反射函数 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81 2.3.5 局部变量 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83 2.3.6 语境 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 84 2.3.7 局部约束 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 86 2.3.8 定义域反射函数 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 86 2.3.9 作用域 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 89 2.4 选项类型 91 2.4.1 声明和使用选项类型 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 91 2.4.2 隐藏选项类型 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 92 2.5 搜索 95 2.5.1 有限域搜索 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 95 2.5.2 搜索注解 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 96 2.5.3 注解 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 101 2.6 MiniZinc 中的有效建模实践 103 2.6.1 变量界限 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 103 2.6.2 有效的生成元 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 105 2.6.3 冗余约束 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 106 2.6.4 模型选择 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 108 2.6.5 多重建模和连通 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 110 2.6.6 对称 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 111 2.6.6.1 静态的对称性破缺 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 112 2.6.6.2 其他对称的例子 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 114 2.7 在 MiniZinc 中对布尔可满足性问题建模 115 2.7.1 整型建模 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 115 2.7.2 非等式建模 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 116 2.7.3 势约束建模 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 117 ii
2.8 FlatZinc 和展平 125 2.8.1 展平表达式 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 125 2.8.1.1 简化和求值 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 126 2.8.1.2 定义子表达式 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 127 2.8.1.3 FlatZinc 约束形式 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 127 2.8.1.4 边界分析 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 128 2.8.1.5 目标函数 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 128 2.8.2 线性表达式 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 129 2.8.3 展开表达式 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 130 2.8.4 数组 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 131 2.8.5 具体化 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 134 2.8.6 谓词 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 137 2.8.7 Let 表达式 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 139 3 User Manual 3.1 The MiniZinc Command Line Tool 145 147 3.1.1 Basic Usage . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 147 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 149 3.1.2 Adding Solvers 3.1.2.1 Configuration files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 149 3.1.2.2 Configuration for MIP solvers . . . . . . . . . . . . . . . . . . . . . . . . 149 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 150 3.1.3.1 General options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 150 3.1.3.2 Solving options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 151 3.1.3.3 Flattener input options . . . . . . . . . . . . . . . . . . . . . . . . . . . . 152 Flattener two-pass options . . . . . . . . . . . . . . . . . . . . . . . . . . . 153 Flattener output options . . . . . . . . . . . . . . . . . . . . . . . . . . . . 154 3.1.3.4 Solution output options . . . . . . . . . . . . . . . . . . . . . . . . . . . 155 3.1.4 User Configuration Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 156 3.1.3 Options 3.2 The MiniZinc IDE 159 3.2.1 Editing files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 159 3.2.1.1 Editing functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 160 3.2.1.2 Fonts and dark mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 160 3.2.2 Configuring and Running a Solver . . . . . . . . . . . . . . . . . . . . . . . . . . 160 3.2.2.1 Running a model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 160 3.2.2.2 Solver configurations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 161 3.2.2.3 Automatic Solution Checking . . . . . . . . . . . . . . . . . . . . . . . . 164 3.2.2.4 Compiling a model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 164 3.2.2.5 Profiling a model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 164 iii
3.2.3 Working With Projects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 165 3.2.4 Submitting Solutions to Online Courses . . . . . . . . . . . . . . . . . . . . . . . 167 3.2.5 Configuration Options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 167 3.2.5.1 Locating the MiniZinc installation . . . . . . . . . . . . . . . . . . . . . . 170 . . . . . . . . . . . . . . . . . . . . . . . . . 170 3.2.5.2 Adding Third-Party Solvers Configuring existing solvers . . . . . . . . . . . . . . . . . . . . . . . . . . 170 Adding new solvers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 171 3.3 Globalizer 173 3.3.1 Basic Usage . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 173 3.3.2 Caveats . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 176 3.3.3 Supported Constraints . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 176 3.3.4 Using Globalizer in the MiniZinc IDE . . . . . . . . . . . . . . . . . . . . . . . . 177 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 178 3.3.5 How it works 3.3.6 Performance tips . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 179 3.3.7 Limitations / Future work . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 180 3.4 FindMUS 181 3.4.1 Basic Usage . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 181 3.4.1.1 Commandline arguments . . . . . . . . . . . . . . . . . . . . . . . . . . 182 3.4.1.2 Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 184 3.4.2 Using FindMUS in the MiniZinc IDE . . . . . . . . . . . . . . . . . . . . . . . . . 187 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 190 3.4.3 How it works 3.4.4 Performance tips . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 190 3.4.5 Limitations / Future work . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 190 3.5 Using MiniZinc in Jupyter Notebooks 191 3.5.1 Installation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 191 3.5.2 Basic usage . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 192 3.6 Python Interface 195 4 Reference Manual 4.1 Specification of MiniZinc 4.1.1.1 Original authors. 197 199 4.1.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 199 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 200 4.1.2 Notation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 200 4.1.3 Overview of a Model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 201 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 202 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 202 4.1.3.1 Evaluation Phases 4.1.3.2 Run-time Outcomes iv
4.1.3.3 Output . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 203 4.1.4 Syntax Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 204 4.1.4.1 Character Set . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 204 4.1.4.2 Comments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 204 4.1.4.3 Identifiers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 204 4.1.5 High-level Model Structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 205 4.1.5.1 Model Instance Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 206 4.1.5.2 Namespaces . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 207 4.1.5.3 Scopes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 207 4.1.6 Types and Type-insts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 207 4.1.6.1 Properties of Types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 208 4.1.6.2 Instantiations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 208 4.1.6.3 Type-insts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 209 4.1.6.4 Type-inst expression overview . . . . . . . . . . . . . . . . . . . . . . . . 209 4.1.6.5 Built-in Scalar Types and Type-insts . . . . . . . . . . . . . . . . . . . . . 211 Booleans . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 211 Integers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 211 Floats . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 212 Enumerated Types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 212 Strings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 213 4.1.6.6 Built-in Compound Types and Type-insts . . . . . . . . . . . . . . . . . . 213 Sets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 213 Arrays . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 214 Option Types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 216 The Annotation Type . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 217 4.1.6.7 Constrained Type-insts . . . . . . . . . . . . . . . . . . . . . . . . . . . . 217 Set Expression Type-insts . . . . . . . . . . . . . . . . . . . . . . . . . . . 217 Float Range Type-insts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 218 4.1.7 Expressions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 218 4.1.7.1 Expressions Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . 218 4.1.7.2 Operators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 220 4.1.7.3 Expression Atoms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 223 Identifier Expressions and Quoted Operator Expressions . . . . . . . . . . 223 Anonymous Decision Variables . . . . . . . . . . . . . . . . . . . . . . . . 223 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 224 Boolean Literals Integer and Float Literals . . . . . . . . . . . . . . . . . . . . . . . . . . . 224 String Literals and String Interpolation . . . . . . . . . . . . . . . . . . . . 224 Set Literals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 225 Set Comprehensions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 226 v
Array Literals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 227 2d Array Literals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 227 Array Comprehensions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 228 Array Access Expressions . . . . . . . . . . . . . . . . . . . . . . . . . . . . 229 Array Slice Expressions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 230 Annotation Literals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 231 If-then-else Expressions . . . . . . . . . . . . . . . . . . . . . . . . . . . . 231 Let Expressions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 232 Call Expressions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 233 . . . . . . . . . . . . . . . . . . . . . . . . . . 234 Generator Call Expressions 4.1.8 Items . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 235 4.1.8.1 Include Items . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 235 4.1.8.2 Variable Declaration Items . . . . . . . . . . . . . . . . . . . . . . . . . . 235 4.1.8.3 Enum Items . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 236 4.1.8.4 Assignment Items . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 238 4.1.8.5 Constraint Items . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 238 4.1.8.6 Solve Items . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 238 4.1.8.7 Output Items . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 239 4.1.8.8 Annotation Items . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 239 4.1.8.9 User-defined Operations . . . . . . . . . . . . . . . . . . . . . . . . . . . 240 Basic Properties . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 241 Ad-hoc polymorphism . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 241 Local Variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 243 4.1.9 Annotations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 244 4.1.10 Partiality . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 245 4.1.10.1 Partial Assignments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 246 4.1.10.2 Partial Predicate/Function and Annotation Arguments . . . . . . . . . . 247 4.1.10.3 Partial Array Accesses . . . . . . . . . . . . . . . . . . . . . . . . . . . . 247 4.1.11 Built-in Operations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 248 4.1.11.1 Comparison Operations . . . . . . . . . . . . . . . . . . . . . . . . . . . 248 4.1.11.2 Arithmetic Operations . . . . . . . . . . . . . . . . . . . . . . . . . . . . 248 4.1.11.3 Logical Operations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 251 4.1.11.4 Set Operations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 252 4.1.11.5 Array Operations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 253 4.1.11.6 Coercion Operations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 253 4.1.11.7 String Operations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 254 4.1.11.8 Bound and Domain Operations . . . . . . . . . . . . . . . . . . . . . . . 255 4.1.11.9 Option Type Operations . . . . . . . . . . . . . . . . . . . . . . . . . . . 257 4.1.11.10Other Operations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 257 vi
分享到:
收藏