This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import accumulate org.optaplanner.examples.tennis.solver.drools.functions.LoadBalanceAccumulateFunction loadBalance; | |
| rule "fairAssignmentCountPerTeam" | |
| when | |
| accumulate( | |
| $t : Team() | |
| and accumulate( | |
| TeamAssignment(team == $t); | |
| $assignmentCount : count() | |
| ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| rule "fairAssignmentCountPerTeam" | |
| when | |
| accumulate( | |
| $t : Team() | |
| and accumulate( | |
| $a : TeamAssignment(team == $t); | |
| $teamTotal : count($a) | |
| ); | |
| $total : sum($teamTotal.intValue() * $teamTotal.intValue()) | |
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Requirements: | |
| 1) Parse n properties from a Map | |
| 2) Fail fast with good error message if such a property is not the correct type (for example partCount is not an int) | |
| 3) Fail fast if an unknown key is in the Map | |
| 4) Do not modify the Map because it is reused | |
| Proposal A: | |
| public void applyCustomProperties(Map<String, String> customPropertyMap) { | |
| String partCountString = customPropertyMap.remove("partCount"); // BUG: MODIFIES MAP |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| rule "Fairness standard deviation" | |
| when | |
| accumulate ( | |
| $c : candidate | |
| accumulate ( | |
| $f : FederalState ( winningCandidate == $c ); | |
| $candidateSum : sum( $f.getElectoralVotes() ) | |
| ); | |
| $variance : sum($candidateSum * $candidateSum) | |
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| When running KieContainerSolverFactoryTest, I get: | |
| java.lang.NoClassDefFoundError: org/kie/internal/builder/conf/RuleEngineOption | |
| at java.lang.Class.getDeclaredMethods0(Native Method) | |
| at java.lang.Class.privateGetDeclaredMethods(Class.java:2701) | |
| at java.lang.Class.getDeclaredMethods(Class.java:1975) | |
| at org.junit.internal.MethodSorter.getDeclaredMethods(MethodSorter.java:54) | |
| at org.junit.runners.model.TestClass.scanAnnotatedMembers(TestClass.java:65) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 2016-11-04 16:18:49,052 [AWT-EventQueue-0] INFO Opened: data/cloudbalancing/unsolved/100computers-300processes.xml | |
| 2016-11-04 16:18:51,737 [SwingWorker-pool-4-thread-7] INFO Solving started: time spent (1), best score (-300init/0hard/0soft), environment mode (REPRODUCIBLE), random (JDK with seed 0). | |
| 2016-11-04 16:18:51,738 [pool-1-thread-24] DEBUG CH step (0), time spent (2), score (-74init/0hard/-1400soft), selected move count (25), picked move (CloudProcess-24 {null -> CloudComputer-64}). | |
| 2016-11-04 16:18:51,738 [pool-1-thread-21] DEBUG CH step (0), time spent (2), score (-74init/0hard/-1070soft), selected move count (25), picked move (CloudProcess-257 {null -> CloudComputer-93}). | |
| 2016-11-04 16:18:51,738 [pool-1-thread-24] DEBUG CH step (1), time spent (2), score (-73init/0hard/-3000soft), selected move count (25), picked move (CloudProcess-204 {null -> CloudComputer-8}). | |
| 2016-11-04 16:18:51,738 [pool-1-thread-24] DEBUG CH step (2), time spent (2), score (-72init/0hard/-4070soft), selected |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 15:21:36.775 [main] DEBUG o.d.c.k.b.impl.KieRepositoryImpl - Cannot load a KieRepositoryScanner, using the DummyKieScanner | |
| java.lang.IllegalArgumentException: Unable to instantiate service for Class 'org.kie.api.builder.KieScannerFactoryService' | |
| at org.kie.internal.utils.ServiceRegistryImpl.get(ServiceRegistryImpl.java:169) ~[kie-internal-7.0.0-20160824.165432-310.jar:7.0.0-SNAPSHOT] | |
| at org.drools.compiler.kie.builder.impl.KieRepositoryImpl$KieScannerHolder.getInternalKieScanner(KieRepositoryImpl.java:88) [drools-compiler-7.0.0-20160824.170017-483.jar:7.0.0-SNAPSHOT] | |
| at org.drools.compiler.kie.builder.impl.KieRepositoryImpl$KieScannerHolder.<clinit>(KieRepositoryImpl.java:80) [drools-compiler-7.0.0-20160824.170017-483.jar:7.0.0-SNAPSHOT] | |
| at org.drools.compiler.kie.builder.impl.KieRepositoryImpl.getKieModule(KieRepositoryImpl.java:130) [drools-compiler-7.0.0-20160824.170017-483.jar:7.0.0-SNAPSHOT] | |
| at org.drools.compiler.kie.builder.impl.KieRepositoryImpl.getKieModule(KieRepositoryImpl.java:117) [drools-co |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class TwMain { | |
| // I have 8 cores. | |
| // If I set this to 2, then my CPU is at 25% | |
| // If I set this to 4, then my CPU is at 50% | |
| // If I set this to 6, then my CPU is at 74% | |
| // If I set this to 8, then my CPU is at 98% | |
| // If I set this to 10, then my CPU is at 98% | |
| private static final int ACTIVE_THREAD_LIMIT = 10; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ublic class TwMain { | |
| private final static Semaphore SEMAPHORE = new Semaphore(2, true); | |
| public static void main(String[] args) { | |
| for (int i = 0; i < 6; i++) { | |
| StringBuilder name = new StringBuilder(); | |
| for (int j = 0; j < i + 1; j++) { | |
| name.append(i); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| This rule: | |
| // Identical shiftTypes during a weekend | |
| rule "identicalShiftTypesDuringWeekend" | |
| when | |
| $contractLine : BooleanContractLine(contractLineType == ContractLineType.IDENTICAL_SHIFT_TYPES_DURING_WEEKEND, | |
| enabled == true, $contract : contract) | |
| $employee : Employee(contract == $contract, $weekendLength : weekendLength) | |
| ShiftDate(dayOfWeek == DayOfWeek.SUNDAY, $sundayIndex : dayIndex) |