You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The default constraint weight for these constraints is `1`. This can now be overridden by the consumer by passing in the model overrides object in a request.
68
132
For example, to make the Teacher conflict 10 times more impactful, override the weight to 10:
@@ -93,6 +157,11 @@ Usually, it doesn't make sense to allow weight overrides for _hard_ constraints.
93
157
Next, in the xref:./rest-api.adoc#modelConverter[model converter], make sure to map these overrides to a solver specific `ConstraintWeightOverrides` object that must be on the `@PlanningSolution` class.
Copy file name to clipboardExpand all lines: docs/src/modules/ROOT/pages/service/demo-data.adoc
+52Lines changed: 52 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -23,6 +23,11 @@ This interface requires you to implement 2 methods:
23
23
Implementations of this interface must be dependency free meaning simple instantiation (even with reflection) of this class is enough to generate demo data.
24
24
====
25
25
26
+
[tabs]
27
+
====
28
+
Java::
29
+
+
30
+
--
26
31
[source,java,options="nowrap"]
27
32
----
28
33
@ApplicationScoped
@@ -79,6 +84,53 @@ public class TimetableDemoDataGenerator implements DemoDataGenerator {
79
84
}
80
85
}
81
86
----
87
+
--
88
+
89
+
Kotlin::
90
+
+
91
+
--
92
+
[source,kotlin,options="nowrap"]
93
+
----
94
+
@ApplicationScoped
95
+
class TimetableDemoDataGenerator : DemoDataGenerator {
96
+
97
+
enum class DemoDataKind(
98
+
private val metaData: DemoMetaData,
99
+
private val requestFunction: (DemoDataKind) -> ModelRequest<TimetableInput, TimetableConfigOverrides>
format = DataFormat.Values.NUMBER, description = "The maximum number of consecutive lessons assigned to any single teacher.",
173
+
type = SchemaType.NUMBER, example = "3", readOnly = true) val maxConsecutiveLessons: Int
174
+
) : ModelOutputMetrics
175
+
----
176
+
--
177
+
====
96
178
97
179
Next, the `SolverModel` should implement the `OutputMetricsAware` interface and construct the defined `ModelOutputMetrics` object from the solved state.
98
180
99
181
.Example for School Timetabling
182
+
[tabs]
183
+
====
184
+
Java::
185
+
+
186
+
--
100
187
[source,java,options="nowrap"]
101
188
----
102
189
@PlanningSolution
@@ -129,12 +216,50 @@ public class Timetable implements SolverModel<HardSoftScore>, OutputMetricsAware
129
216
// other Getters/Setters/Constructors excluded
130
217
}
131
218
----
219
+
--
220
+
221
+
Kotlin::
222
+
+
223
+
--
224
+
[source,kotlin,options="nowrap"]
225
+
----
226
+
@PlanningSolution
227
+
class Timetable : SolverModel<HardSoftScore>, OutputMetricsAware<TimetableOutputMetrics> {
228
+
229
+
@ProblemFactCollectionProperty
230
+
@ValueRangeProvider
231
+
val timeslots: List<Timeslot> = emptyList()
232
+
233
+
@PlanningEntityCollectionProperty
234
+
val lessons: List<Lesson> = emptyList()
235
+
236
+
private var _score: HardSoftScore? = null
237
+
238
+
@PlanningScore
239
+
override fun getScore(): HardSoftScore? = _score
240
+
241
+
override fun getOutputMetrics(): TimetableOutputMetrics {
0 commit comments