[rules-users] Hard constraint on selecting a skill
André Fróes
arfmoraes at gmail.com
Thu Feb 7 11:04:52 EST 2013
Beside the line "not Engineer(skill == $....." i managed to get close of
that, but my system is way simpler, withing WorkOrder pojo, i have a skill
and within Engineer pojo, also a skill field, both int field. So I wouldn't
be able to do the EngineerSkillRelation as you described since engineer
does not have a field to call itself.
basically, the objects are
WorkOrder
- id (inherited from abstractpersistable) (long)
- requiredWorkTime (int)
- requiredSkill (int)
- Engineer engineer
Engineer
- worktime (int);
- name (String);
- skill (int);
So, if I try something like this:
rule "assignSkillWOToSkilledEngineer"
when
$wo : WorkOrder( $requiredSkill : requiredSkill, $engineer : engineer )
not Engineer(skill == $requiredSkill)
then
insertLogical(new
IntConstraintOccurrence("assignSkillWOToSkilledEngineer",
ConstraintType.NEGATIVE_HARD,1, $wo));
end
it runs, but does not sort.
2013/2/7 Geoffrey De Smet <ge0ffrey.spam at gmail.com>
>
> Op 07-02-13 15:15, André Fróes schreef:
>
> Hello!
> I'm still not getting good with drools rules, i'm trying several examples
> and basic ones. Some i did without any problem and understood plenty well,
> but when I try to make an approach to what i'm aiming, I'm not able to.
>
> Right now I'm trying to compose this:
>
> When
> there's an workorder with skill
> and there's and engineer with the skill and capable of doing that
> workorder
> then
> the engineer should do it
>
> So i tried something like this:
>
> rule "assignSkillWOToSkilledEngineer"
> when
> $wo : WorkOrder( $requiredSkill : requiredSkill )
> $engineer : Engineer(skill == $requiredSkill)
>
> there's no restriction that the WorkerOrder is assigned to that engineer,
> so it matches with every engineer of that skill?
>
> then
> insertLogical(new
> IntConstraintOccurrence("assignSkillWOToSkilledEngineer",
> ConstraintType.NEGATIVE_HARD,
> 1, $engineer));
>
> the cause $engineer is a problem: If an engineer combines with 2
> workorders, it will only count for 1 point due the way insertLogical work.
> Normally the causes are the planning entities involved.
> Try
> insertLogical(new
> IntConstraintOccurrence("assignSkillWOToSkilledEngineer",
> ConstraintType.NEGATIVE_HARD,
> 1, $wo));
>
> end
>
> I would write it like this (pseudo code):
>
> rule "assignSkillWOToSkilledEngineer"
> when
> $wo : WorkOrder( $requiredSkill : requiredSkill, $assignedEngineer :
> assignedEngineer )
> not EngineerSkillRelation(skill == $requiredSkill, engineer ==
> $assignedEngineer)
>
> then
> insertLogical(new
> IntConstraintOccurrence("assignSkillWOToSkilledEngineer",
> ConstraintType.NEGATIVE_HARD,
> 1, $wo));
> end
>
> i get no exceptions, but the sort is not working properly
>
>
> _______________________________________________
> rules-users mailing listrules-users at lists.jboss.orghttps://lists.jboss.org/mailman/listinfo/rules-users
>
>
>
> _______________________________________________
> rules-users mailing list
> rules-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/rules-users/attachments/20130207/60605b3b/attachment.html
More information about the rules-users
mailing list