text2model 0.1.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (135) hide show
  1. text2model/__init__.py +1 -0
  2. text2model/grammar.mzn +277 -0
  3. text2model/knowledge_graphs/CSPLib_12.ttl +41 -0
  4. text2model/knowledge_graphs/CSPLib_14.ttl +51 -0
  5. text2model/knowledge_graphs/CSPLib_2.ttl +59 -0
  6. text2model/knowledge_graphs/CSPLib_22.ttl +62 -0
  7. text2model/knowledge_graphs/CSPLib_28.ttl +28 -0
  8. text2model/knowledge_graphs/CSPLib_30.ttl +72 -0
  9. text2model/knowledge_graphs/CSPLib_34.ttl +52 -0
  10. text2model/knowledge_graphs/CSPLib_39.ttl +51 -0
  11. text2model/knowledge_graphs/CSPLib_54.ttl +50 -0
  12. text2model/knowledge_graphs/CSPLib_6.ttl +36 -0
  13. text2model/knowledge_graphs/CSPLib_8.ttl +53 -0
  14. text2model/knowledge_graphs/LPWP_128.ttl +79 -0
  15. text2model/knowledge_graphs/LPWP_232.ttl +95 -0
  16. text2model/knowledge_graphs/LPWP_53.ttl +58 -0
  17. text2model/knowledge_graphs/LPWP_66.ttl +52 -0
  18. text2model/knowledge_graphs/LPWP_85.ttl +95 -0
  19. text2model/knowledge_graphs/OR_LP_IP_Scheduling_problem_1.ttl +34 -0
  20. text2model/knowledge_graphs/OR_LP_IP_Scheduling_problem_18.ttl +59 -0
  21. text2model/knowledge_graphs/OR_LP_IP_Scheduling_problem_2.ttl +43 -0
  22. text2model/knowledge_graphs/OR_LP_IP_Scheduling_problem_28.ttl +42 -0
  23. text2model/knowledge_graphs/OR_LP_IP_Scheduling_problem_31.ttl +44 -0
  24. text2model/knowledge_graphs/OR_LP_IP_Scheduling_problem_4.ttl +48 -0
  25. text2model/knowledge_graphs/OR_LP_IP_Scheduling_problem_5.ttl +40 -0
  26. text2model/knowledge_graphs/OR_LP_IP_Scheduling_problem_6.ttl +61 -0
  27. text2model/knowledge_graphs/OR_LP_IP_Scheduling_problem_8.ttl +54 -0
  28. text2model/knowledge_graphs/combinatorial_problem_1.ttl +48 -0
  29. text2model/knowledge_graphs/combinatorial_problem_31.ttl +43 -0
  30. text2model/knowledge_graphs/combinatorial_problem_32.ttl +39 -0
  31. text2model/knowledge_graphs/combinatorial_problem_7.ttl +52 -0
  32. text2model/knowledge_graphs/complexor_AircraftAssignment.ttl +73 -0
  33. text2model/knowledge_graphs/complexor_AircraftLanding.ttl +53 -0
  34. text2model/knowledge_graphs/complexor_CFLP.ttl +43 -0
  35. text2model/knowledge_graphs/complexor_CapacitatedWarehouseLocation.ttl +59 -0
  36. text2model/knowledge_graphs/complexor_CarSelection.ttl +30 -0
  37. text2model/knowledge_graphs/complexor_TSP.ttl +52 -0
  38. text2model/knowledge_graphs/complexor_VRPTW.ttl +67 -0
  39. text2model/knowledge_graphs/nlp4lp_1.ttl +56 -0
  40. text2model/knowledge_graphs/nlp4lp_10.ttl +46 -0
  41. text2model/knowledge_graphs/nlp4lp_11.ttl +57 -0
  42. text2model/knowledge_graphs/nlp4lp_12.ttl +48 -0
  43. text2model/knowledge_graphs/nlp4lp_13.ttl +48 -0
  44. text2model/knowledge_graphs/nlp4lp_14.ttl +82 -0
  45. text2model/knowledge_graphs/nlp4lp_15.ttl +60 -0
  46. text2model/knowledge_graphs/nlp4lp_16.ttl +64 -0
  47. text2model/knowledge_graphs/nlp4lp_17.ttl +72 -0
  48. text2model/knowledge_graphs/nlp4lp_18.ttl +64 -0
  49. text2model/knowledge_graphs/nlp4lp_19.ttl +98 -0
  50. text2model/knowledge_graphs/nlp4lp_2.ttl +103 -0
  51. text2model/knowledge_graphs/nlp4lp_20.ttl +129 -0
  52. text2model/knowledge_graphs/nlp4lp_21.ttl +65 -0
  53. text2model/knowledge_graphs/nlp4lp_22.ttl +72 -0
  54. text2model/knowledge_graphs/nlp4lp_23.ttl +63 -0
  55. text2model/knowledge_graphs/nlp4lp_24.ttl +99 -0
  56. text2model/knowledge_graphs/nlp4lp_25.ttl +77 -0
  57. text2model/knowledge_graphs/nlp4lp_27.ttl +75 -0
  58. text2model/knowledge_graphs/nlp4lp_28.ttl +50 -0
  59. text2model/knowledge_graphs/nlp4lp_29.ttl +63 -0
  60. text2model/knowledge_graphs/nlp4lp_3.ttl +49 -0
  61. text2model/knowledge_graphs/nlp4lp_30.ttl +49 -0
  62. text2model/knowledge_graphs/nlp4lp_31.ttl +35 -0
  63. text2model/knowledge_graphs/nlp4lp_32.ttl +33 -0
  64. text2model/knowledge_graphs/nlp4lp_33.ttl +49 -0
  65. text2model/knowledge_graphs/nlp4lp_34.ttl +67 -0
  66. text2model/knowledge_graphs/nlp4lp_35.ttl +75 -0
  67. text2model/knowledge_graphs/nlp4lp_36.ttl +56 -0
  68. text2model/knowledge_graphs/nlp4lp_37.ttl +52 -0
  69. text2model/knowledge_graphs/nlp4lp_38.ttl +55 -0
  70. text2model/knowledge_graphs/nlp4lp_39.ttl +58 -0
  71. text2model/knowledge_graphs/nlp4lp_4.ttl +64 -0
  72. text2model/knowledge_graphs/nlp4lp_40.ttl +49 -0
  73. text2model/knowledge_graphs/nlp4lp_41.ttl +62 -0
  74. text2model/knowledge_graphs/nlp4lp_42.ttl +49 -0
  75. text2model/knowledge_graphs/nlp4lp_43.ttl +98 -0
  76. text2model/knowledge_graphs/nlp4lp_44.ttl +41 -0
  77. text2model/knowledge_graphs/nlp4lp_45.ttl +56 -0
  78. text2model/knowledge_graphs/nlp4lp_46.ttl +35 -0
  79. text2model/knowledge_graphs/nlp4lp_47.ttl +68 -0
  80. text2model/knowledge_graphs/nlp4lp_48.ttl +74 -0
  81. text2model/knowledge_graphs/nlp4lp_49.ttl +66 -0
  82. text2model/knowledge_graphs/nlp4lp_5.ttl +69 -0
  83. text2model/knowledge_graphs/nlp4lp_50.ttl +51 -0
  84. text2model/knowledge_graphs/nlp4lp_51.ttl +53 -0
  85. text2model/knowledge_graphs/nlp4lp_52.ttl +51 -0
  86. text2model/knowledge_graphs/nlp4lp_53.ttl +55 -0
  87. text2model/knowledge_graphs/nlp4lp_54.ttl +74 -0
  88. text2model/knowledge_graphs/nlp4lp_55.ttl +50 -0
  89. text2model/knowledge_graphs/nlp4lp_56.ttl +67 -0
  90. text2model/knowledge_graphs/nlp4lp_57.ttl +59 -0
  91. text2model/knowledge_graphs/nlp4lp_58.ttl +65 -0
  92. text2model/knowledge_graphs/nlp4lp_6.ttl +63 -0
  93. text2model/knowledge_graphs/nlp4lp_60.ttl +36 -0
  94. text2model/knowledge_graphs/nlp4lp_61.ttl +83 -0
  95. text2model/knowledge_graphs/nlp4lp_62.ttl +44 -0
  96. text2model/knowledge_graphs/nlp4lp_63.ttl +49 -0
  97. text2model/knowledge_graphs/nlp4lp_64.ttl +41 -0
  98. text2model/knowledge_graphs/nlp4lp_65.ttl +78 -0
  99. text2model/knowledge_graphs/nlp4lp_66.ttl +51 -0
  100. text2model/knowledge_graphs/nlp4lp_67.ttl +40 -0
  101. text2model/knowledge_graphs/nlp4lp_7.ttl +53 -0
  102. text2model/knowledge_graphs/nlp4lp_8.ttl +51 -0
  103. text2model/knowledge_graphs/nlp4lp_9.ttl +58 -0
  104. text2model/knowledge_graphs/non_linear_problem_10.ttl +57 -0
  105. text2model/knowledge_graphs/non_linear_problem_15.ttl +55 -0
  106. text2model/knowledge_graphs/non_linear_problem_23.ttl +42 -0
  107. text2model/knowledge_graphs/non_linear_problem_9.ttl +61 -0
  108. text2model/knowledge_graphs/puzzles_problem_1.ttl +64 -0
  109. text2model/knowledge_graphs/puzzles_problem_11.ttl +65 -0
  110. text2model/knowledge_graphs/puzzles_problem_12.ttl +79 -0
  111. text2model/knowledge_graphs/puzzles_problem_13.ttl +50 -0
  112. text2model/knowledge_graphs/puzzles_problem_31.ttl +62 -0
  113. text2model/main.py +771 -0
  114. text2model/prompts/assembler_prompt.txt +104 -0
  115. text2model/prompts/code_stitching_prompt.txt +49 -0
  116. text2model/prompts/code_validation_prompt.txt +36 -0
  117. text2model/prompts/constraint_generation_prompt.txt +35 -0
  118. text2model/prompts/cot_prompt.txt +45 -0
  119. text2model/prompts/global_constraint_prompts/all_different_prompt.txt +67 -0
  120. text2model/prompts/global_constraint_prompts/count_prompt.txt +75 -0
  121. text2model/prompts/global_constraint_prompts/cumulative_prompt.txt +88 -0
  122. text2model/prompts/global_constraint_prompts/global_cardinality_prompt.txt +76 -0
  123. text2model/prompts/global_constraint_prompts/increasing_prompt.txt +81 -0
  124. text2model/prompts/global_constraint_prompts/lex_less_prompt.txt +68 -0
  125. text2model/prompts/grammar_validation_prompt.txt +18 -0
  126. text2model/prompts/kg_code_generation_prompt.txt +20 -0
  127. text2model/prompts/kg_generation_prompt.txt +40 -0
  128. text2model/prompts/objective_generation_prompt.txt +34 -0
  129. text2model/prompts/parameter_and_variable_generation_prompt.txt +35 -0
  130. text2model/utils.py +350 -0
  131. text2model-0.1.0.dist-info/METADATA +221 -0
  132. text2model-0.1.0.dist-info/RECORD +135 -0
  133. text2model-0.1.0.dist-info/WHEEL +5 -0
  134. text2model-0.1.0.dist-info/entry_points.txt +2 -0
  135. text2model-0.1.0.dist-info/top_level.txt +1 -0
@@ -0,0 +1,104 @@
1
+ You are the world’s best **MiniZinc** programmer.
2
+
3
+ Given a **problem description** in natural language and some **input data**, your task is to produce **one clean, runnable MiniZinc model**.
4
+
5
+ To help you, I will supply **hints**: short code fragments, each already written in MiniZinc, that implement individual global constraints (`all_different`, `global_cardinality`, `count`, `cumulative`, `lex_less`, `increasing`)
6
+
7
+ **What you must do**
8
+
9
+ * Read the description and data.
10
+ * The MiniZinc code should assume that the data needed, will be provided in **input data** through a .dzn file.
11
+ * Analyse every hint, decide which ones are relevant, and **assemble** them into a complete model.
12
+ * You may **rename, merge or deduplicate variables** appearing in the hints so that everything fits coherently.
13
+ * Add any **missing constraints, declarations, objective function, solve item, and output block** that the problem still needs.
14
+ * The final answer must be **one MiniZinc code-block** – nothing else.
15
+ ---
16
+
17
+ ## In-context examples
18
+
19
+ ### Example 1 – Latin-Square row
20
+ **Input (description)**
21
+ > Place numbers 1-4 in a single row so that they are all distinct.
22
+
23
+ **Input (data)**
24
+ ```
25
+ n = 4;
26
+ ```
27
+
28
+ **Hints**
29
+ * `all_different`
30
+ ```mzn
31
+ array[1..n] of var 1..n: q;
32
+ constraint all_different(q);
33
+ ```
34
+
35
+ **Output**
36
+ ```mzn
37
+ include "globals.mzn";
38
+
39
+ int: n; % copied from data
40
+ array[1..n] of var 1..n: row; % renamed q → row
41
+
42
+ constraint all_different(row);
43
+
44
+ solve satisfy;
45
+ output [ "Row = ", show(row), "\n" ];
46
+ ```
47
+ % Renamed *q*→*row* to clarify its meaning.
48
+
49
+ ---
50
+
51
+ ### Example 2 – Weekend staff roster
52
+ **Input (description)**
53
+ > Ten nurses are assigned to shifts 1, 2, 3.
54
+ > Exactly 3 nurses on shift 1, 4 on shift 2, 3 on shift 3.
55
+ > At most **two** nurses may be trainees (1 = trainee, 0 = regular).
56
+
57
+ **Input (data)**
58
+ ```
59
+ n = 10;
60
+ ```
61
+
62
+ **Hints**
63
+ * `global_cardinality`
64
+ ```mzn
65
+ array[1..n] of var 1..3: shift;
66
+ array[1..3] of int: need = [3,4,3];
67
+ constraint global_cardinality(shift, 1..3, need);
68
+ ```
69
+ * `count`
70
+ ```mzn
71
+ array[1..n] of var 0..1: trainee; % 1 = trainee
72
+ var 0..n: trCnt;
73
+ constraint count(trainee, 1, trCnt);
74
+ constraint trCnt <= 2;
75
+ ```
76
+
77
+ **Output**
78
+ ```mzn
79
+ include "globals.mzn";
80
+
81
+ int: n;
82
+
83
+ /* Variables */
84
+ array[1..n] of var 1..3: shift; % kept name from hint
85
+ array[1..n] of var 0..1: trainee;
86
+
87
+ /* Constraints */
88
+ array[1..3] of int: need = [3,4,3];
89
+ constraint global_cardinality(shift, 1..3, need);
90
+
91
+ var 0..n: trCnt;
92
+ constraint count(trainee, 1, trCnt);
93
+ constraint trCnt <= 2;
94
+
95
+ /* Linking: a trainee must be assigned some shift */
96
+ constraint forall(i in 1..n)( trainee[i] = 1 -> shift[i] != 0 );
97
+
98
+ /* Solve & output */
99
+ solve satisfy;
100
+ output [ "Shift = ", show(shift), "\nTrainee = ", show(trainee), "\n" ];
101
+ ```
102
+ % Re-used *shift* array from GCC hint; added a linking constraint between `trainee` and `shift`.
103
+
104
+ ---
@@ -0,0 +1,49 @@
1
+ You are an expert MiniZinc developer.
2
+
3
+ Given the Parameters, Variables, Constraints, and Objective sections of the code, stitch them into a complete solution for the optimization problem.
4
+
5
+ When stitching the code, follow this format:
6
+
7
+ ```minizinc
8
+ % Parameters
9
+
10
+ % Variables
11
+
12
+ % Constraints
13
+
14
+ % Objective
15
+ ```
16
+
17
+ Ensure the following principles for syntactic accuracy and logical consistency:
18
+
19
+ **General Principles**:
20
+ 1. Verify that all intermediate sections (parameters, variables, constraints, objective) are consistent and correctly referenced.
21
+ 2. Confirm that the final MiniZinc code is syntactically accurate and logically coherent.
22
+ 3. Ensure that the code sections are properly integrated, maintaining the prescribed format.
23
+ 4. Check for and resolve any circular dependencies or ordering issues in declarations.
24
+ 5. Check for and resolve any coercion issues.
25
+ 5. Validate type consistency across all expressions and declarations.
26
+ 6. Utilize clear and concise comments to describe each section and its components.
27
+ 7. Make sure global constraints are utilized where applicable to enhance model efficiency.
28
+ 8. Ensure only one objective is defined, using the `solve` keyword appropriately.
29
+
30
+ **Problem Description**:
31
+ {problem_description}
32
+
33
+ **Input Data**:
34
+ {input_data}
35
+
36
+ **Parameters and Variables**:
37
+ ```minizinc
38
+ {parameters_and_variables}
39
+ ```
40
+
41
+ **Constraints**:
42
+ ```minizinc
43
+ {constraints}
44
+ ```
45
+
46
+ **Objective**:
47
+ ```minizinc
48
+ {objective}
49
+ ```
@@ -0,0 +1,36 @@
1
+ You are an expert MiniZinc developer.
2
+
3
+ The generated MiniZinc code failed to compile. Review and fix the code based on the error message, problem description, input parameters, and objective type.
4
+
5
+ **Problem Description:**
6
+ {problem_description}
7
+
8
+ **Input Data:**
9
+ {input_data}
10
+
11
+ **Objective Type:**
12
+ {objective_type}
13
+
14
+ **Generated MiniZinc Code:**
15
+ ```minizinc
16
+ {final_code}
17
+ ```
18
+
19
+ **Compilation Error:**
20
+ ```
21
+ {syntax_error_message}
22
+ ```
23
+
24
+ ### **Validation Checklist**
25
+ 1. **Fix the compilation error first** - Address the specific issue indicated in the error message above.
26
+ 2. Ensure all parameters and variable names in `data.dzn` match the generated MiniZinc code.
27
+ 3. Verify that constraints are properly structured and align with the problem description.
28
+ 4. Check the objective function to confirm it is correctly set as:
29
+ - `minimize` if `{objective_type}` is "minimization".
30
+ - `maximize` if `{objective_type}` is "maximization".
31
+ - `satisfy` if `{objective_type}` is "satisfaction".
32
+ 5. Ensure no syntax errors exist in the generated MiniZinc code.
33
+ 6. Validate the order of declarations (parameters, variables, constraints, and objective).
34
+ 7. Identify any missing components or inconsistencies.
35
+
36
+ Output only the corrected MiniZinc code.
@@ -0,0 +1,35 @@
1
+ You are an expert MiniZinc developer.
2
+
3
+ Generate MiniZinc code for the Constraints from a given problem description with additional information about the parameters provided.
4
+
5
+ Given the Parameters and Variables part of the code, generate only the constraints.
6
+
7
+ When generating the code, follow this format:
8
+
9
+ ```minizinc
10
+ % Constraints
11
+ ```
12
+
13
+ Also, make sure to follow the following principles when generating the code:
14
+
15
+ **General Principles**:
16
+ 1. Separate constraints into distinct constraint blocks whenever possible.
17
+ 2. Utilize global constraints as much as possible.
18
+ 3. When using iteration constructs like `forall`, define the range or set being iterated over properly (e.g., use `1..M` instead of `M` for iteration).
19
+ 4. Ensure operands in operations are of compatible types to prevent coercion errors.
20
+ 5. Ensure type consistency in expressions to avoid coercion errors.
21
+ 6. Clearly comment on the purpose of each constraint for clarity and maintenance.
22
+ 7. Avoid hardcoding values; use parameters and variables instead.
23
+ 8. Use meaningful names for all constraint blocks.
24
+ 9. Only generate constraints and do not generate objective.
25
+
26
+ **Problem Description**:
27
+ {problem_description}
28
+
29
+ **Input Data**:
30
+ {input_data}
31
+
32
+ **Parameters and Variables**:
33
+ ```minizinc
34
+ {parameters_and_variables}
35
+ ```
@@ -0,0 +1,45 @@
1
+ You are an expert MiniZinc developer.
2
+
3
+ Generate Minizinc code from a given problem description with additional information about the parameters provided.
4
+
5
+ The MiniZinc code should assume that the data needed, will be provided in a specific format through a .dzn file, so the generated code should assume the same names/data-types defined in the **input data nomenclature and examples**.
6
+
7
+ When generating the code, follow this format:
8
+
9
+ ```
10
+ % Parameters
11
+
12
+ % Variables
13
+
14
+ % Constraints
15
+
16
+ % Objective
17
+ ```
18
+
19
+ Also, make sure to follow the following principles when generating the code:
20
+
21
+ **General Principles**:
22
+ 1. The generated code should assume that data will be provided via a ".dzn" file. Do not declare values directly from the input data nomenclature and examples within the MiniZinc model.
23
+ 2. Adhere to the input data and examples precisely when declaring input parameter names and their data types.
24
+ 3. Use bounded variables whenever possible. If bounds are explicit (e.g., non-negative), include them as constraints.
25
+ 4. When defining arrays of variables, ensure bounds are integers. Apply element-wise constraints in a separate constraint block if bounds depend on array elements.
26
+ 5. When defining arrays of variables, ensure bounding constraints are applied separately rather than during initialization to avoid type mismatches.
27
+ 6. Define explicit bounds for all variables used in linear expressions, either in their declaration or through additional constraints.
28
+ 7. Separate constraints into distinct constraint blocks whenever possible.
29
+ 8. Use direct and succinct definitions for constraints in the model.
30
+ 9. Utilize global constraints as much as possible.
31
+ 10. Declare all parameters and sets before using them in other declarations to avoid circular dependencies and ordering issues.
32
+ 11. When using iteration constructs like `forall`, define the range or set being iterated over properly (e.g., use `1..M` instead of `M` for iteration).
33
+ 12. Ensure operands in operations are of compatible types to prevent coercion errors.
34
+ 13. Declare all identifiers (such as indices or ranges like `n`) before using them in any array or parameter declarations.
35
+ 14. Ensure type consistency in expressions to avoid coercion errors. Explicitly cast types if necessary.
36
+ 15. Ensure there is only one objective, which will be a maximization, minimization, or a satisfy problem. Do not forget the `solve` keyword.
37
+
38
+
39
+ Please do not generate any other token, except the MiniZinc code.
40
+
41
+ **Problem Description**:
42
+ {problem_description}
43
+
44
+ **Input Data**:
45
+ {input_data}
@@ -0,0 +1,67 @@
1
+ You are a constraint modeling assistant specialized in MiniZinc, especially in detecting and modeling `all_different` constraints.
2
+
3
+ ## Task
4
+ Given a **problem description** and optional **input data**, decide whether the problem **requires one or more `all_different` constraints**.
5
+
6
+ - If it does, generate **only MiniZinc code** specifying the `all_different` constraint and its variables.
7
+ - Do **not** generate any other constraints.
8
+ - If it does **not** require `all_different`, return `FALSE` and a brief reason.
9
+
10
+ The MiniZinc code should assume that the data needed, will be provided in **input data** through a .dzn file.
11
+
12
+ ## What is an all_different constraint?
13
+ An `all_different` constraint ensures that **a set of variables take distinct values**. It is commonly used in:
14
+ - Puzzles (e.g., Sudoku, N-Queens)
15
+ - Scheduling (unique time slots)
16
+ - Permutations and mappings (one-to-one assignments)
17
+
18
+ ## Detection Guide: Common Clues
19
+ A problem likely involves `all_different` if it includes language such as:
20
+ - "Each item must use a unique ..."
21
+ - "No two ... share the same ..."
22
+ - "All ... are different, distinct, or unique"
23
+ - "Forms a permutation of 1..n"
24
+ - "There is a one-to-one mapping between A and B"
25
+ - Constraints related to rows/columns in Sudoku, or diagonals in N-Queens
26
+
27
+ Heuristic: Look for **injectivity** (no repeats) over a bounded domain — model this as an `all_different`.
28
+
29
+ ## Output Format
30
+ - If constraint is needed, output **MiniZinc code only**, using `include "globals.mzn";`
31
+ - If not needed, return:
32
+ ```text
33
+ FALSE
34
+ Reason: <short explanation>
35
+ ```
36
+
37
+ ## MiniZinc Snippets
38
+
39
+ ```mzn
40
+ include "globals.mzn";
41
+ array[1..n] of var 1..n: x;
42
+ constraint all_different(x);
43
+ ```
44
+
45
+ ```mzn
46
+ include "alldifferent_except_0.mzn";
47
+ constraint alldifferent_except_0([x[i] | i in S]);
48
+ ```
49
+
50
+ ## Examples
51
+ ### ✅ Example: Unique delivery routes
52
+ "Each of 5 delivery vans must have a different route number (1–5)"
53
+
54
+ ```mzn
55
+ include "globals.mzn";
56
+ int: n = 5;
57
+ array[1..n] of var 1..n: route;
58
+ constraint all_different(route);
59
+ ```
60
+
61
+ ### ❌ Example: Jersey color limits
62
+ "Choose among red, blue, green with limits: max 5 reds, 4 blues..."
63
+
64
+ ```text
65
+ FALSE
66
+ Reason: No requirement for all values to be unique; count-based limit instead.
67
+ ```
@@ -0,0 +1,75 @@
1
+ You are a constraint modeling assistant specialized in MiniZinc, especially in detecting and modeling `count` constraints.
2
+
3
+ ## Task
4
+ Given a **problem description** and optional **input data**, decide whether the problem **requires one or more `count` constraints**.
5
+
6
+ - If it does, generate **only MiniZinc code** specifying the `count` constraint and its variables.
7
+ - Do **not** generate any other constraints.
8
+ - If it does **not** require `count`, return `FALSE` and a brief reason.
9
+
10
+ The MiniZinc code should assume that the data needed, will be provided in **input data** through a .dzn file.
11
+
12
+ ## What is a count constraint?
13
+ A `count` constraint ensures that a specific value (or values) appears a given number of times in a collection of variables. It is commonly used in:
14
+ - Frequency-based assignments
15
+ - Limiting how many times a choice is made
16
+ - Controlling resource allocations
17
+
18
+ ## Detection Guide: Common Clues
19
+ A problem likely involves `count` if it includes language such as:
20
+ - "There must be exactly/at most/at least N occurrences of ..."
21
+ - "No more than 3 players wear red shirts"
22
+ - "Two tasks must be scheduled at the same time"
23
+ - "Exactly 4 machines operate in parallel"
24
+ - Count constraints often model **value frequencies** or **category limits**
25
+
26
+ Heuristic: Look for **counting of values or categories** — model this as a `count` constraint.
27
+
28
+ ## Output Format
29
+ - If constraint is needed, output **MiniZinc code only**, using `include "globals.mzn";`
30
+ - If not needed, return:
31
+ ```text
32
+ FALSE
33
+ Reason: <short explanation>
34
+ ```
35
+
36
+ ## MiniZinc Snippet
37
+
38
+ ```mzn
39
+ include "globals.mzn";
40
+
41
+ /* 1. Exact number of v's */
42
+ array[1..n] of var DOMAIN: x;
43
+ int: v;
44
+ constraint count(x, v, k); % k is a constant
45
+
46
+ /* 2. At‑most / at‑least using a decision variable */
47
+ array[1..n] of var DOMAIN: x;
48
+ var 0..n: occ;
49
+ constraint count(x, v, occ);
50
+ constraint occ <= 2; % change to ≥ for “at least”
51
+
52
+ /* 3. Counting a value set S */
53
+ set of int: S = {0,1};
54
+ constraint count(x, S, 3); % exactly 3 variables in S
55
+ ```
56
+
57
+ ## Examples
58
+ ### ✅ Example: Binary string with four 1’s
59
+ A length‑10 binary string must contain **exactly four** 1‑bits.
60
+
61
+ ```mzn
62
+ include "globals.mzn";
63
+
64
+ int: n = 10;
65
+ array[1..n] of var 0..1: bit;
66
+ constraint count(bit, 1, 4);
67
+ ```
68
+
69
+ ### ❌ Example: Unique delivery routes
70
+ "Each of 5 delivery vans must have a different route number (1–5)"
71
+
72
+ ```text
73
+ FALSE
74
+ Reason: This is a uniqueness constraint — use all_different, not count.
75
+ ```
@@ -0,0 +1,88 @@
1
+ You are a constraint modeling assistant specialized in MiniZinc, especially in detecting and modeling the `cumulative` constraint.
2
+
3
+ ## Task
4
+ Given a **problem description** and optional **input data**, decide whether the problem **requires one or more `cumulative` constraints**.
5
+
6
+ - If it does, generate **only MiniZinc code** specifying the `cumulative` constraint and its relevant parameters.
7
+ - Do **not** generate any other constraints.
8
+ - If it does **not** require `cumulative`, return `FALSE` and a brief reason.
9
+
10
+ The MiniZinc code should assume that the data needed, will be provided in **input data** through a .dzn file.
11
+
12
+ ## What is a cumulative constraint?
13
+ The `cumulative` constraint is used in scheduling and resource allocation problems where:
14
+ - Each task consumes a certain amount of a limited resource
15
+ - Tasks may overlap in time
16
+ - The **total resource usage** at any point must not exceed a given limit
17
+
18
+ It applies to scenarios such as:
19
+ - Job-shop scheduling
20
+ - Machine or crew availability
21
+ - Project management with overlapping tasks
22
+
23
+ ## Detection Guide: Common Clues
24
+ Use `cumulative` when the problem includes language such as:
25
+ - "Each task has a start time, duration, and resource usage"
26
+ - "No more than X units of resource can be used at once"
27
+ - "Tasks may overlap but total usage must stay within a limit"
28
+ - "Limited machines or workers shared between overlapping jobs"
29
+
30
+ Heuristic: Use `cumulative` if there are **start times**, **durations**, **resource usages**, and a **maximum limit** on total usage at any time.
31
+
32
+ ## Output Format
33
+ - If constraint is needed, output **MiniZinc code only**, using `include "globals.mzn";`
34
+ - If not needed, return:
35
+ ```text
36
+ FALSE
37
+ Reason: <short explanation>
38
+ ```
39
+
40
+ ## MiniZinc Snippets
41
+ ```mzn
42
+ include "globals.mzn";
43
+
44
+ /* 1. Unary resource (cap = 1) */
45
+ int: n;
46
+ array[1..n] of int: dur;
47
+ array[1..n] of var int: start;
48
+ array[1..n] of int: use = [1 | i in 1..n];
49
+ int: cap = 1;
50
+ constraint cumulative(start, dur, use, cap);
51
+
52
+ /* 2. Shared resource with fixed usages */
53
+ array[1..n] of int: dur;
54
+ array[1..n] of int: use; % usage[i] ≤ cap
55
+ array[1..n] of var int: start;
56
+ int: cap;
57
+ constraint cumulative(start, dur, use, cap);
58
+
59
+ /* 3. With decision‑variable end times */
60
+ array[1..n] of var int: start;
61
+ array[1..n] of int: dur;
62
+ array[1..n] of var int: end;
63
+ constraint forall(i in 1..n)( end[i] = start[i] + dur[i] );
64
+ constraint cumulative(start, dur, use, cap);
65
+ ```
66
+
67
+ ## Examples
68
+ ### ✅ Tasks with variable durations
69
+ "Each task can take 1 to 3 units of time"
70
+ ```mzn
71
+ include "globals.mzn";
72
+
73
+ int: n = 4;
74
+ int: limit = 6;
75
+
76
+ array[1..n] of var 0..10: start;
77
+ array[1..n] of var 1..3: duration;
78
+ array[1..n] of int: usage = [3, 2, 2, 1];
79
+
80
+ constraint cumulative(start, duration, usage, limit);
81
+ ```
82
+
83
+ ### ❌ Not a cumulative problem
84
+ "Each task must have a unique duration"
85
+ ```text
86
+ FALSE
87
+ Reason: No resource limit or overlapping tasks — this is not a cumulative scheduling problem.
88
+ ```
@@ -0,0 +1,76 @@
1
+ You are a constraint modeling assistant specialized in MiniZinc, especially in detecting and modeling the `global_cardinality` constraint.
2
+
3
+ ## Task
4
+ Given a **problem description** and optional **input data**, decide whether the problem **requires a `global_cardinality` constraint**.
5
+
6
+ - If it does, generate **only MiniZinc code** specifying the `global_cardinality` constraint and its variables.
7
+ - Do **not** generate any other constraints.
8
+ - If it does **not** require `global_cardinality`, return `FALSE` and a brief reason.
9
+
10
+ The MiniZinc code should assume that the data needed, will be provided in **input data** through a .dzn file.
11
+
12
+ ## What is a global_cardinality constraint?
13
+ A `global_cardinality` constraint controls how many times **multiple values** appear in a list of variables. It generalizes `count` for many values at once. It is useful for:
14
+ - Category or color usage limits
15
+ - Balanced frequency distribution
16
+ - Labeling problems with limits per label
17
+
18
+ ## Detection Guide: Common Clues
19
+ This constraint is useful when the problem includes phrases like:
20
+ - "There may be at most X of color A, Y of color B..."
21
+ - "Each number must appear exactly once"
22
+ - "Red: max 5, Blue: max 4, Green: max 3"
23
+ - You are counting **multiple values at once**, not just one
24
+
25
+ ## Output Format
26
+ - If constraint is needed, output **MiniZinc code only**, using `include "globals.mzn";`
27
+ - If not needed, return:
28
+ ```text
29
+ FALSE
30
+ Reason: <short explanation>
31
+ ```
32
+
33
+ ## MiniZinc Snippet
34
+
35
+ ```mzn
36
+ include "globals.mzn";
37
+
38
+ /* 1. Exact counts for each value */
39
+ array[1..n] of var VALSET: x;
40
+ array[VALSET] of int: occ = [...];
41
+ constraint global_cardinality(x, VALSET, occ);
42
+
43
+ /* 2. Lower & upper bounds per value */
44
+ array[1..n] of var VALSET: x;
45
+ array[VALSET] of int: lo = [...];
46
+ array[VALSET] of int: up = [...];
47
+ constraint global_cardinality_low_up(x, lo, up);
48
+
49
+ /* 3. Decision-variable counts (optimisable) */
50
+ array[VALSET] of var 0..n: occVar;
51
+ constraint global_cardinality(x, VALSET, occVar);
52
+ ```
53
+
54
+ ## Example
55
+ ### ✅ Example: Jersey color limit
56
+ "A team chooses among red, blue, green. Max 5 reds, 4 blues, 3 greens."
57
+
58
+ ```mzn
59
+ include "globals.mzn";
60
+
61
+ int: n = 12;
62
+ array[1..n] of var 1..3: jersey; % 1=red, 2=blue, 3=green
63
+
64
+ array[1..3] of int: values = [1, 2, 3];
65
+ array[1..3] of int: max_counts = [5, 4, 3];
66
+ array[1..3] of var 0..n: counts;
67
+
68
+ constraint global_cardinality(jersey, values, counts);
69
+ constraint forall(i in 1..3)(counts[i] <= max_counts[i]);
70
+ ```
71
+
72
+ ### ❌ Example: "No duplicate assignments"
73
+ ```text
74
+ FALSE
75
+ Reason: This is a uniqueness constraint — use all_different, not global_cardinality.
76
+ ```
@@ -0,0 +1,81 @@
1
+ You are a constraint modeling assistant specialized in MiniZinc, especially in detecting and modeling the `increasing` constraint.
2
+
3
+ ## Task
4
+ Given a **problem description** and optional **input data**, decide whether the problem **requires one or more `increasing` constraints**.
5
+
6
+ - If it does, generate **only MiniZinc code** specifying the `increasing` constraint and its variables.
7
+ - Do **not** generate any other constraints.
8
+ - If it does **not** require `increasing`, return `FALSE` and a brief reason.
9
+
10
+ The MiniZinc code should assume that the data needed, will be provided in **input data** through a .dzn file.
11
+
12
+ ## What is an increasing constraint?
13
+ The `increasing` constraint enforces that a sequence of variables is in **non-decreasing order**, i.e., each value is greater than or equal to the one before it.
14
+
15
+ This constraint is used when:
16
+ - Tasks or values must occur in a certain order
17
+ - Output must be sorted
18
+ - Scheduled start times or priorities must not decrease
19
+
20
+ ## Detection Guide: Common Clues
21
+ Use `increasing` when the problem includes language such as:
22
+ - "In non-decreasing order"
23
+ - "Must be sorted"
24
+ - "Each item must be >= the previous"
25
+ - "Start times must follow a sequence"
26
+
27
+ Heuristic: Use `increasing` if you need to enforce that values **never decrease** over a sequence.
28
+
29
+ ## Output Format
30
+ - If constraint is needed, output **MiniZinc code only**, using `include "globals.mzn";`
31
+ - If not needed, return:
32
+ ```text
33
+ FALSE
34
+ Reason: <short explanation>
35
+ ```
36
+
37
+ ## MiniZinc Snippets (Examples)
38
+
39
+ ### ✅ Basic usage
40
+ ```mzn
41
+ include "globals.mzn";
42
+
43
+ array[1..n] of var int: x;
44
+
45
+ constraint increasing(x);
46
+ ```
47
+
48
+ ### ✅ Enforce increasing start times
49
+ "Each job must start no earlier than the one before"
50
+ ```mzn
51
+ include "globals.mzn";
52
+
53
+ int: n = 4;
54
+ array[1..n] of var 0..10: start;
55
+
56
+ constraint increasing(start);
57
+ ```
58
+
59
+ ### ✅ Increasing with bounds
60
+ "Output sequence must be sorted between 1 and 100"
61
+ ```mzn
62
+ include "globals.mzn";
63
+
64
+ int: n = 5;
65
+ array[1..n] of var 1..100: result;
66
+
67
+ constraint increasing(result);
68
+ ```
69
+
70
+ ### ✅ Alternative manual encoding
71
+ If `increasing` is not available, it can be rewritten as:
72
+ ```mzn
73
+ constraint forall(i in 1..n-1)(x[i] <= x[i+1]);
74
+ ```
75
+
76
+ ### ❌ Not an increasing problem
77
+ "All values must be different"
78
+ ```text
79
+ FALSE
80
+ Reason: This is a uniqueness constraint — use all_different, not increasing.
81
+ ```