didp-yaml 0.10.0

YAML interface for Dynamic Programming Description Language (DyPDL) and DyPDL solvers.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
# User Guide for Expressions in DyPDL

This document describes the syntax of expressions, which are used to describe base cases, constraints, and transitions.

## TIPS

When writing a long expression, you can use multiple lines by placing `>` before a string.
For example,

```yaml
dual_bounds: 
    - >
      (max (max (ceil(/ (- (sum time uncompleted) idle-time) cycle-time))
                (- (+ (sum lb2-weight1 uncompleted)
                      (ceil(sum lb2-weight2 uncompleted)))
                   (if (>= idle-time (/ cycle-time 2.0)) 1 0)))
           (- (ceil(sum lb3-weight uncompleted))
              (if (>= idle-time (/ cycle-time 3.0)) 1 0)))
```

## Table of Contents

- [Element Expression]#element-expression
  - [Immediate Value]#immediate-value
  - [Table]#table
  - [Parameter]#parameter
  - [Variable]#variable
  - [State Function]#state-function
  - [Arithmetic Operations]#arithmetic-operations
  - [if]#if
- [Set Expression]#set-expression
  - [Immediate Value]#immediate-value-1
  - [Immediate Value with an Object Type]#immediate-value-with-an-object-type
  - [Table or Dictionary]#table-or-dictionary
  - [Table or Dictionary Reduce]#table-or-dictionary-reduce
  - [Variable]#variable-1
  - [State Function]#state-function-1
  - [complement]#complement
  - [union]#union
  - [intersection]#intersection
  - [difference]#difference
  - [add]#add
  - [remove]#remove
  - [if]#if-1
- [Integer Expression]#integer-expression
  - [Immediate Value]#immediate-value-2
  - [Table or Dictionary]#table-or-dictionary-1
  - [Table or Dictionary Reduce]#table-or-dictionary-reduce-1
  - [Variable]#variable-2
  - [State Function]#state-function-2
  - [Arithmetic Operations]#arithmetic-operations-1
  - [Rounding]#rounding
  - [Cardinality]#cardinality
  - [if]#if-2
- [Continuous Expression]#continuous-expression
  - [Immediate Value]#immediate-value-3
  - [Table or Dictionary]#table-or-dictionary-2
  - [Table or Dictionary Reduce]#table-or-dictionary-reduce-2
  - [Variable]#variable-3
  - [State Function]#state-function-3
  - [Arithmetic Operations]#arithmetic-operations-2
  - [Rounding]#rounding-1
  - [Cardinality]#cardinality-1
  - [if]#if-3
- [Condition]#condition
  - [Table or Dictionary]#table-or-dictionary-3
  - [State Function]#state-function-4
  - [Arithmetic Comparison]#arithmetic-comparison
  - [Set Comparison]#set-comparison
  - [is_in]#is_in
  - [is_empty]#is_empty
  - [not]#not
  - [and]#and
  - [or]#or

## Element Expression

An effect on an element variable must be an element expression.
Also, element expressions are used to access tables.
The value of an element expression must be non-negative and less than the number of the associated object.

### Immediate Value

A nonzero integer value is an element expression.

### Table

```
(<table name> <element expression 1>, ..., <element expression k>)
```

It returns a value in table `<table name>` with indices `<element expression 1>` to `<element expression k>`.
The number of element expressions must be the same as `args` of the table.

### Parameter

```
<parameter name>
```

It returns the value of parameter `<parameter name>`.
Parameter are defined with `forall` in conditions and `parameters` in transitions.

### Variable

```
<variable name>
```

It returns element the value of element variable `<variable name>`.

### State Function

```
<state function name>
```

It returns the value of element state function `<state function name>`.

If a state function is defined with a parameter, you can specify a particular instantiation with the following syntax.

```
(<state function name> <element constant 1>, ..., <element constant n>)
```

Unlike a table, only immediate values and parameters are allowed as arguments.

### Arithmetic Operations

```
(+ <element expression 1> <element expression 2>)
(- <element expression 1> <element expression 2>)
(* <element expression 1> <element expression 2>)
(/ <element expression 1> <element expression 2>)
(% <element expression 1> <element expression 2>)
(max <element expression 1> <element expression 2>)
(min <element expression 1> <element expression 2>)
```

For two element expressions, addition (`+`), subtraction (`-`), multiplication (`*`), division (`/`), modulus (`%`), the maximum (`max`), and the minimum (`min`) are defined.

### if

```
(if <condition> <element expression 1> <element expression 2>)
```

It returns `<element expression 1>` if `<condition>` is true.
Otherwise, it returns `<element expression 2>`.

## Set Expression

An effect on an set variable must be a set expression.

### Immediate Value

```
{<nonegatve integer 1>, ..., <nonegative integer k> : <positive integer>}
```

It returns a set consisting of the nonnegative integers with the maximum cardinality of `<positive integer>`.

### Immediate Value with an Object Type

```
(<object name> <parameter 1>|<element constant 1>|<element immediate 1> , ..., <parameter k>|<element constant k>|<element immediate k>)
```

It returns a set of objects with type `<object name>` consisting of the argument.
Each argument is an element expression but restricted to a parameter, an element table having no `args`, and an immediate value.

### Table or Dictionary

```
(<table name>|<dictionary name> <element expression 1>, ..., <element expression k>)
```

It returns a value in table `<table name>` or dictionary `<dictionary name>` with indices `<element expression 1>` to `<element expression k>`.
The number of element expressions must be the same as `args` of the table.

### Table or Dictionary Reduce

```
(union <table name>|<dictionary name> <element expression 1>|<set expression 1>, ..., <element expression k>|<set expression k>)
(intersection <table name>|<dictionary nam> <element expression 1>|<set expression 1>, ..., <element expression k>|<set expression k>)
(disjunctive_union <table name>|<dictionary name> <element expression 1>|<set expression 1>, ..., <element expression k>|<set expression k>)
```

It returns the union/intersection/disjunctive union of values in table `<table name>` or dictionary `<dictionary name>` with indices specified by the arguments.
It takes the sum over all elements in the cartesian product of the arguments.

For example, suppose that a table named `table1` is 3-dimensional.
`(union table1 set1 2 set2)` where `set1 = { 0, 1 }` and `set2 = { 3, 4 }` returns the union of `(table1 0 2 3)`, `(table1 0 2 4)`, `(table1 1 2 3)`, and `(table1 1 2 4)`.

### Variable

```
<variable name>
```

It returns element the value of element variable `<variable name>`.

### State Function

```
<state function name>
```

It returns the value of set state function `<state function name>`.

### complement

```
~<set expression>
```

It returns a complement set of the value of `<set expression>`.

### union

```
(union <set expression 1> <set expression 2>)
```

It returns the union of `<set expression 1>` and `<set expression 2>`.

### intersection

```
(intersection <set expression 1> <set expression 2>)
```

It returns the intersection of `<set expression 1>` and `<set expression 2>`.

### difference

```
(difference <set expression 1> <set expression 2>)
```

It returns the differene of `<set expression 1>` and `<set expression 2>`, i.e., the intersection of `<set expression 1>` and the complement set of `<set expression 2>`.

### add

```
(add <element expression> <set expression>)
```

It returns the set containing all elements in `<set expression>` in addition to `<element expression>`.

### remove

```
(remove <element expression> <set expression>)
```

It returns the set containing all elements in `<set expression>` except for `<element expression>`.

### if

```
(if <condition> <set expression 1> <set expression 2>)
```

It returns `<set expression 1>` if `<condition>` is true.
Otherwise, it returns `<set expression 2>`.

## Integer Expression

An integer expression is a numeric expression using integer values.
An effect on an integer variable must be an integer expression.
If `cost_type` is `integer`, the cost expression of each transition and dual bounds must be integer expressions.

### Immediate Value

An integer is an integer expression.

### Table or Dictionary

```
(<table name>|<dictionary name> <element expression 1>, ..., <element expression k>)
```

It returns a value in table `<table name>` or dictionary `<dictionary name>` with indices `<element expression 1>` to `<element expression k>`.
The number of element expressions must be the same as `args` of the table.

### Table or Dictionary Reduce

```
(sum <table name>|<dictionary name> <element expression 1>|<set expression 1>, ..., <element expression k>|<set expression k>)
(max <table name>|<dictionary name> <element expression 1>|<set expression 1>, ..., <element expression k>|<set expression k>)
(min <table name>|<dictionary name> <element expression 1>|<set expression 1>, ..., <element expression k>|<set expression k>)
```

It returns the sum/maximum/minimum of values in table `<table name>` or dictionary `<dictionary name>` with indices specified by the arguments.
It takes the sum over all elements in the cartesian product of the arguments.

For example, suppose that a table named `table1` is 3-dimensional.
`(sum table1 set1 2 set2)` where `set1 = { 0, 1 }` and `set2 = { 3, 4 }` returns the sum of `(table1 0 2 3)`, `(table1 0 2 4)`, `(table1 1 2 3)`, and `(table1 1 2 4)`.

### Variable

```
<variable name>
```

### State Function

```
<state function name>
```

It returns the value of integer state function `<state function name>`.

If a state function is defined with a parameter, you can specify a particular instantiation with the following syntax.

```
(<state function name> <element constant 1>, ..., <element constant n>)
```

Unlike a table, only immediate values and parameters are allowed as arguments.

### Arithmetic Operations

```
(+ <integer expression 1> <integer expression 2>)
(- <integer expression 1> <integer expression 2>)
(* <integer expression 1> <integer expression 2>)
(/ <integer expression 1> <integer expression 2>)
(% <integer expression 1> <integer expression 2>)
(max <integer expression 1> <integer expression 2>)
(min <integer expression 1> <integer expression 2>)
(abs <integer expression>)
```

For two integer expressions, addition (`+`), subtraction (`-`), multiplication (`*`), division (`/`), modulus (`%`), the maximum (`max`), and the minimum (`min`) are defined.
Taking the absolute value of an integer expression (`abs`) is also possible.

### Rounding

```
(ceil <continuous expression>)
(floor <continuous expression>)
(round <continuous expression>)
(trunc <continuous expression>)
```

These expressions convert a continuous expression to an integer expression.

- `ceil` returns the smallest integer that is greater than or equal to the value of the continuous expression.
- `floor` returns the largest integer that does not exceed the value of the continuous expression.
- `round` returns the closest integer.
- `trunc` returns the integer part.

### Cardinality

```
|<set expression>|
```

It returns the cardinality of `<set expression>`.

### if

```
(if <condition> <integer expression 1> <integer expression 2>)
```

It returns `<integer expression 1>` if `<condition>` is true.
Otherwise, it returns `<integer expression 2>`.

## Continuous Expression

A continuous expression is a numeric expression using continuous values.
An effect on a continuous variable must be a continuous expression.
If `cost_type` is `continuous`, the cost expression of each transition and dual bounds must be continuous expressions.

### Immediate Value

A real value is a continuous expression.

### Table or Dictionary

```
(<table name>|<dictionary name> <element expression 1>, ..., <element expression k>)
```

It returns a value in table `<table name>` or dictionary `<dictionary name>` with indices `<element expression 1>` to `<element expression k>`.
The number of element expressions must be the same as `args` of the table.
An integer table can be used in a continuous expression.

### Table or Dictionary Reduce

```
(sum <table name>|<dictionary name> <element expression 1>|<set expression 1>, ..., <element expression k>|<set expression k>)
(max <table name>|<dictionary name> <element expression 1>|<set expression 1>, ..., <element expression k>|<set expression k>)
(min <table name>|<dictionary name> <element expression 1>|<set expression 1>, ..., <element expression k>|<set expression k>)
```

It returns the sum/maximum/minimum of values in table `<table name>` or dictionary `<dictionary name>` with indices specified by the arguments.
It takes the sum over all elements in the cartesian product of the arguments.

For example, suppose that a table named `table1` is 3-dimensional.
`(sum table1 set1 2 set2)` where `set1 = { 0, 1 }` and `set2 = { 3, 4 }` returns the sum of `(table1 0 2 3)`, `(table1 0 2 4)`, `(table1 1 2 3)`, and `(table1 1 2 4)`.

### Variable

```
<variable name>
```

It returns the value of continuous variable `<variable name>`.
An integer variable can also be used in a continuous expression.

### State Function

```
<state function name>
```

It returns the value of continuous state function `<state function name>`.
An integer state function can also be used in a continuous expression.

If a state function is defined with a parameter, you can specify a particular instantiation with the following syntax.

```
(<state function name> <element constant 1>, ..., <element constant n>)
```

### Arithmetic Operations

```
(+ <continuous expression 1> <continuous expression 2>)
(- <continuous expression 1> <continuous expression 2>)
(* <continuous expression 1> <continuous expression 2>)
(/ <continuous expression 1> <continuous expression 2>)
(% <continuous expression 1> <continuous expression 2>)
(pow <continuous expression 1> <continuous expression 2>)
(log <continuous expression 1> <continuous expression 2>)
(max <continuous expression 1> <continuous expression 2>)
(min <continuous expression 1> <continuous expression 2>)
(abs <continuous expression>)
(sqrt <continuous expression>)
```

For two integer expressions, addition (`+`), subtraction (`-`), multiplication (`*`), division (`/`), modulus (`%`), power (`pow`), logarithm (`log`),  the maximum (`max`), the minimum (`min`) are defined.
For `pow`, the second argument is an exponent.
For `log`, the second argument is a base.
Taking the absolute value (`abs`) and the square root (`sqrt`) is also possible.

### Rounding

```
(ceil <continuous expression>)
(floor <continuous expression>)
(round <continuous expression>)
(trunc <continuous expression>)
```

These expressions make the fractoinal part to be zero.
However, the returned value is still a continuous expression.

- `ceil` returns the smallest integer that is greater than or equal to the value of the continuous expression.
- `floor` returns the largest integer that does not exceed the value of the continuous expression.
- `round` returns the closest integer.
- `trunc` returns the integer part.

### Cardinality

```
|<set expression>|
```

It returns the cardinality of `<set expression>`.

### if

```
(if <condition> <continuous expression 1> <continuous expression 2>)
```

It returns `<continuous expression 1>` if `<condition>` is true.
Otherwise, it returns `<continuous expression 2>`.

## Condition

Conditions are used in state constraints and preconditions.
It returns a boolean value, `true` or `false`.
Also, conditions are used in element, set, and numeric expressions with `if`.

### Table or Dictionary

```
(<table name>|<dictionary name> <element expression 1>, ..., <element expression k>)
```

It returns a value in table `<table name>` or dictionary `<dictionary name>` with indices `<element expression 1>` to `<element expression k>`.
The `type` of the table must be `bool`.
The number of element expressions must be the same as `args` of the table.

### State Function

```
<state function name>
```

It returns the value of bool state function `<state function name>`.

If a state function is defined with a parameter, you can specify a particular instantiation with the following syntax.

```
(<state function name> <element constant 1>, ..., <element constant n>)
```

### Arithmetic Comparison

```
(= <element expression 1> <element expression 2>)
(!= <element expression 1> <element expression 2>)
(> <element expression 1> <element expression 2>)
(>= <element expression 1> <element expression 2>)
(< <element expression 1> <element expression 2>)
(<= <element expression 1> <element expression 2>)
```

Two element expressions can be compared.

```
(= <numeric expression 1> <numeric expression 2>)
(!= <numeric expression 1> <numeric expression 2>)
(> <numeric expression 1> <numeric expression 2>)
(>= <numeric expression 1> <numeric expression 2>)
(< <numeric expression 1> <numeric expression 2>)
(<= <numeric expression 1> <numeric expression 2>)
```

Two numeric expressions can be compared.
An integer expression and a continuous expression cannot be compared.

### Set Comparison

```
(= <set expression 1> <set expression 2>)
(!= <set expression 1> <set expression 2>)
(is_subset <set expression 1> <set expression 2>)
```

Two set expressions can be compared.
`is_subset` checks if the value of `<set expression 1>` is a subset of `<set expression 2>`.

### is_in

```
(is_in <element expression> <set expression>)
```

It checks if the value of `<element expression>` is included in the value of `<set expression>`.

### is_empty

```
(is_empty <set expression>)
```

It checks if the value of `<set expression>` is an empty set.

### not

```
(not <condition>)
```

It returns the negation of the value of `<condition>`.

### and

```
(and <condition 1> <condition 2>)
```

It returns the conjunction of the values of `<condition 1>` and `<condition 2>`.

### or

```
(or <condition 1> <condition 2>)
```

It returns the disjunction of the values of `<condition 1>` and `<condition 2>`.