1
0
This repository has been archived on 2025-03-06. You can view files and clone it, but cannot push or open issues or pull requests.
Jip J. Dekker fad1b07018 Squashed 'software/minizinc/' content from commit 4f10c8205
git-subtree-dir: software/minizinc
git-subtree-split: 4f10c82056ffcb1041d7ffef29d77a7eef92cf76
2021-06-16 14:06:46 +10:00

63 lines
1.4 KiB
MiniZinc

/***
!Test
solvers: [gecode]
expected:
- !Result
solution: !Solution
reg_input:
- 1
- 2
- 3
- 3
- 3
- 2
- 1
reg_input2:
- 1
- 2
- 3
- 3
- 3
- 3
- 3
- 3
- 3
- 2
- 1
***/
include "regular.mzn";
%-----------------------------------------------------------------------------%
% regular
%-----------------------------------------------------------------------------%
% regexp is: 123*21.
int: n_states = 5;
int: input_max = 3;
int: initial_state = 1;
set of int: accepting_states = {5};
array[1..5, 1..3] of int: transition_fn =
[|2, 0, 0 % transitions from state 1: --1--> state 2
|0, 3, 0 % transitions from state 2: --2--> state 3
|0, 4, 3 % transitions from state 3: --2--> state 4, --3--> state 3
|5, 0, 0 % transitions from state 4: --1--> state 5
|0, 0, 0|];% transitions from state 5: (none)
array[-2..4] of var int: reg_input ::add_to_output =
array1d(-2..4, [1, 2, _, _, _, 2, 1]);
array[44..54] of var int: reg_input2 ::add_to_output;
constraint regular(reg_input, n_states, input_max, transition_fn,
initial_state, accepting_states);
constraint regular(reg_input2, n_states, input_max, transition_fn,
initial_state, accepting_states);
solve satisfy;
output [
"reg_input = array1d(-2..4, ", show(reg_input), ");\n",
"reg_input2 = array1d(44..54, ", show(reg_input2), ");\n"
];