I think I fixed it, but the broken constraint is still showing, i don't know how to remove it. I did this:verified if the engineer skill list had the same size or bigger than the requiredSkillList, iterate to check skills between both counting the matches and then, if the match was 100% to other, give the workorderif (e.getSkillEngineerList().size() >= requiredSkillList.size()) {int temp = 0;for (SkillEngineer se : e.getSkillEngineerList()) {for (Skill s : requiredSkillList) {if (se.getSkill().getId() == s.getId()) {temp++;}}}if (temp == requiredSkillList.size()) {hardScore += 1;}}2013/2/20 André Fróes <arfmoraes@gmail.com>
After some workaround I noticed that the workorders are not being 100% corretly distributed to, i've changed the scorecalculator to this:int commonSkillCount = 0;for (Skill s : requiredSkillList){for (SkillEngineer se : e.getSkillEngineerList()){if (se.getSkill().getId() == s.getId()){commonSkillCount++;}}}if ((commonSkillCount - e.getSkillEngineerList().size()) <= 0){hardScore += commonSkillCount;}and I got the resultID: 104[Skills: ABC 2,] - Trewq(8)[Skills: ABC 3,ABC 2,] ------ Feasible(0)ID: 103[Skills: ABC 3,] - Trewq(8)[Skills: ABC 3,ABC 2,] ------ Feasible(0)ID: 105[Skills: ABC 4,ABC 3,] - Poiuy(8)[Skills: ABC 1,ABC 2,ABC 3,ABC 4,] ------ Feasible(0)ID: 102[Skills: ABC 2,ABC 1,ABC 4,] - Qwert(8)[Skills: ABC 2,ABC 4,] ------ Broken(1)ID: 101[Skills: ABC 1,] - Lkjhg(8)[Skills: ABC 4,ABC 1,] ------ Feasible(0)ID: 107[Skills: ABC 4,] - Lkjhg(8)[Skills: ABC 4,ABC 1,] ------ Feasible(0)ID: 106[Skills: ABC 1,] - Qwert(8)[Skills: ABC 2,ABC 4,] ------ Broken(1)ID: 108[Skills: ABC 3,ABC 2,] - Poiuy(8)[Skills: ABC 1,ABC 2,ABC 3,ABC 4,] ------ Feasible(0)there's a workorder that woud be disconsidered because no engineer have the required skill to complete it2013/2/19 André Fróes <arfmoraes@gmail.com>
I forgot to post the code:public HardAndSoftScore calculateScore(Distributor distributor) {int hardScore = 0;int softScore = 0;for (Engineer e : distributor.getEngineerList()){long skill = e.getSkillEngineerList().get(0).getSkill().getId();int requiredWorktime = 0;List<Skill> requiredSkillList = new ArrayList<Skill>();for (WorkOrder o : distributor.getWorkOrderList()){if (e.equals(o.getEngineer())){requiredWorktime += o.getRequiredWorktime();for (SkillWorkOrder swo : o.getRequiredSkills()){requiredSkillList.add(swo.getSkill());}}}int engineerAvailableTime = e.getWorktime() - requiredWorktime;if (engineerAvailableTime < 0 ){hardScore += engineerAvailableTime;}int commonSkillCount = 0;for (SkillEngineer se : e.getSkillEngineerList()){for (Skill s : requiredSkillList){if (se.getSkill().getId() == s.getId()){commonSkillCount++;}}}if (commonSkillCount != 0){hardScore += commonSkillCount;}}return DefaultHardAndSoftScore.valueOf(hardScore, softScore);}( but i still want to try to create this in dsl rule after this work :D )2013/2/19 André Fróes <arfmoraes@gmail.com>I managed solving that problem even when there's more than one skill involved, but now my hard constraint of worktime breaks if I add more worktime than the sum of engineers worktime.(8) is the worktime, my workorders all have a worktime of 4 hours, so, I got 32 available hours and 32 hours of workorders to be assigned right? When I stick to this plan, it works:----Compilation Result----Solved distribution with 8 work orders and 4 engineers:ID: 104[Skills: (1002) ABC 2] - Qwert(8)[Skills: (1002) ABC 2]ID: 103[Skills: (1003) ABC 3] - Trewq(8)[Skills: (1003) ABC 3]ID: 105[Skills: (1004) ABC 4] - Lkjhg(8)[Skills: (1004) ABC 4]ID: 102[Skills: (1002) ABC 2] - Qwert(8)[Skills: (1002) ABC 2]ID: 101[Skills: (1001) ABC 1] - Poiuy(8)[Skills: (1001) ABC 1]ID: 107[Skills: (1004) ABC 4] - Lkjhg(8)[Skills: (1004) ABC 4]ID: 106[Skills: (1001) ABC 1] - Poiuy(8)[Skills: (1001) ABC 1]ID: 108[Skills: (1003) ABC 3] - Trewq(8)[Skills: (1003) ABC 3]---------------So, if I add another worktime with 4 hours, it messes everything, this is the outcome:Solved distribution with 9 work orders and 4 engineers:ID: 104[Skills: (1002) ABC 2] - Qwert(8)[Skills: (1002) ABC 2]ID: 103[Skills: (1003) ABC 3] - Trewq(8)[Skills: (1003) ABC 3]ID: 105[Skills: (1004) ABC 4] - Lkjhg(8)[Skills: (1004) ABC 4]ID: 102[Skills: (1002) ABC 2] - Qwert(8)[Skills: (1002) ABC 2]ID: 101[Skills: (1001) ABC 1] - Poiuy(8)[Skills: (1001) ABC 1]ID: 107[Skills: (1004) ABC 4] - Lkjhg(8)[Skills: (1004) ABC 4]ID: 106[Skills: (1001) ABC 1] - Poiuy(8)[Skills: (1001) ABC 1]ID: 108[Skills: (1003) ABC 3] - Trewq(8)[Skills: (1003) ABC 3]ID: 109[Skills: (1003) ABC 3] - Trewq(8)[Skills: (1003) ABC 3]------------to be precise, i don't know if it is because of worktime or skill
2013/2/19 André Fróes <arfmoraes@gmail.com>
Just one correction, it is sorting correctly when there's one workorder with a skill, if there's another workorder with same skill, it doesn't sort that workorder to that skill.This is what is happening:Workorder skill ABC1 ------------ Engineer skill ABC1Workorder skill ABC2 ------------ Engineer skill ABC2Workorder skill ABC1 ------------ Engineer skill ABC2
but if there's only one workorder with one skill it works:Workorder skill ABC1 ------------ Engineer skill ABC1Workorder skill ABC2 ------------ Engineer skill ABC2
Workorder skill ABC3 ------------ Engineer skill ABC3so, from the second workorder on, with a repeated required skill, it doesn't sort properly2013/2/19 André Fróes <arfmoraes@gmail.com>Hello, since i'm not moving a step from where I am at dsl rule, I'm trying to do it with SimpleScoreCalculator, but the same is happening.------------public HardAndSoftScore calculateScore(Distributor distributor) {int hardScore = 0;int softScore = 0;for (Engineer e : distributor.getEngineerList()){long skill = e.getSkillEngineerList().get(0).getSkill().getId();int requiredWorktime = 0;long requiredSkill = 0l;for (WorkOrder o : distributor.getWorkOrderList()){if (e.equals(o.getEngineer())){requiredWorktime += o.getRequiredWorktime();requiredSkill = o.getRequiredSkills().get(0).getSkill().getId();}}int engineerAvailableTime = e.getWorktime() - requiredWorktime;if (engineerAvailableTime < 0 ){hardScore += engineerAvailableTime;}if (requiredSkill == skill){softScore += requiredSkill;}}return DefaultHardAndSoftScore.valueOf(hardScore, softScore);}------------wouldn't that have to fit since i'm comparing the 1st attribute of each skill list from engineers and workorders? And how can I weight which engineer would be better to a determined workorder if the workorder have more skills and so does the engineer?