Very new to constraint streams. Maybe somebody can point me in the right direction? #1297
Closed
GilfalasOrcbane
started this conversation in
General
Replies: 1 comment 2 replies
-
How about something like
This is pseudo code. Actual code is a bit more verbose. |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hello,
I have been using Optaplanner with drools for some time now and I am have trouble ajusting to constraint streams.
I apologize in advance if the solution to this question is trivial. Maybe somebody can point me in the right direction?
I have aleady managed to create some more simple constraints but I have trouble with certain concepts.
I want to add that I am not a professional software developer (veterinarian by trade) and english is not my first language.
Here's what I am trying to achieve:
I have a class Planning_event (Planning Entity) which represents certain events. Each event can be attributed a class Planning_day which has of course a date. Each Planning_event also has a certain type.
I also have a list of rules (Planning_rule.class) collected from a database. I use this to parameter my constraints.
Ex: Certain events can only occur on certain days.
Now I would like to implement that certain events can only happen x times per week. And I want to get this "x times per week" from my database.
Here's my line of thought:
I need to match the events of a certain type to the rule that defines the frequency per week of this type of event.
Then I need to count how many times per specific week this event occurs.
For each day over the allocated frequency I must penalize by ONE_HARD.
Here's an example of a rule which seems to work and which would force events not to occur on certain day:
This constraint tries to match a certain rule with a certain type of event and checks if it happens on a forbidden day.
So say my Planning_rule class has a rule type "WEEK_FREQ_MAX" which should apply to a certain type of event which can be fetched with p.getType(). Also this Planning_rule has a frequency attributed to this event (ex: once per week)
And each event has a week which can be fetched with a function p.getPlanning_week().
Here's the begining of what I tried but which does not seem to be the right way:
Am I correct to assume that this way I should have a stream with a certain type of event grouped by week?
How do I get from there to counting how many times a week a specific event occurs and compare it to the maximum frequency defined in my Planning_rule?
Thank you in advance for all your efforts.
Best regards,
Eric
Beta Was this translation helpful? Give feedback.
All reactions