Drools 8.33 Equivalent to WorkingMemory.clearAgenda() - drools

I am porting an application that was built using Drools 2.5 to Java 11+. This involves upgrading to a more recent version of Drools (8.33, the latest).
The application creates Decision Trees from .xls files.
In those older .xls files, the rightmost column on the RHS is called "Stop Processing" and the action is defined as drools.clearAgenda();
The first 10 rules contain nothing in the "Stop Processing" column but the 11th row contains the string "Stop Processing" - which invokes drools.clearAgenda() I presume.
The rules are sequential so I assume that this is telling the rules engine to just quit evaluating any more rules when it finishes with rule #11.
What is the equivalent to use in Drools 8.33 since clearAgenda() is no more?
No alternative that I can find.

Related

Drools, RuleTable and #Watch annotation

I have now run out of ideas on how to get a RuleTable in Excel to define the #Watch annotation.
All the Drools documentation shows you how to define the #Watch with individual files, but no mention on how to add this to RuleTables.
My RuleTable is generating 100% at the moment and works fine for a primitive test case, but I need to have the #Watch on a more complex rule.
When I use the test compiler, I can edit the .drl files by hand and upload them to the engine. My rules are firing correctly then.
Some help on how to define this in Excel will be greatly appreciated.
This is the current Excel RuleTable I have defined:
This is the target .drl I'm aiming for(I have left out the other two rules generated):
rule "TestWatch One"
no-loop
when
$payCommResponseDTO: PaymentCommissionResponseDTO(commissionStructure == CommissionStructure.ADJUSTED) #Watch(commissionStructure)
then
System.out.println("watch one");
end

Opening Anylogic model in an older version

I have created a model in Anylogic 8.3. Now I want to open this model on a different computer that contains an older version, Anylogic 8.2.3. This, however, does not work, as I am prompted with the fact that the model is created in a newer Anylogic version.
Is there a way to circumvent this issue?
I am not a system admin on the computer with the older Anylogic, nor does our license cover updating to a newer version of Anylogic (expired in december 2018).
You can easily do that by opening the .alp file of your model with Notepad or a similar text editor. Then:
Get your actual AnyLogic build version (open AnyLogic, click "Help" and then "About". You can find your build-version as in the image below
replace AnyLogicVersion and AlpVersion with your required values, e.g. something like AnyLogicVersion="8.2.3.xxxxxxxx" and AlpVersion="8.2.3"
save the file and open with AnyLogic 8.2.3
(Note that if you want to open a model in AnyLogic 7 that was developed in AnyLogic 8, you would also need to remove the entire <RunConfiguration> section. But this is not relevant in your case.)
I think it's only possible to go back to an earlier AnyLogicVersion by hacking the .alp if the AlpVersion is the same, because it denotes the structure of the XML. I don't have an 8.4 file handy, but I have, for example, an 8.5.1 and an 8.2.4, and the AlpVersion is 8.4.9 for AnyLogicVersion 8.5.1, but 8.0.4 for AnyLogicVersion 8.2.4.
If the XML structure is different, the newer version of AnyLogic will likely be unable to load the file. Looking at the two examples of essentially the same model that I've detailed above, there are readily apparent structural differences in the ActiveObjectClass, for example. If there are not too many structural differences, you could try replicating them. I've succeeded in doing that manually at least once, that I can recall.
There are a variety of online tools that allow you to compare the XML schemas of two XML documents, from which you will be able to judge whether a manual hack is feasible.

Xcode 10 iOS app build, "hidden" task takes most of build time

After changing single line of code and performing Xcode 10.1 incremental build in large project, Xcode spends most of build time in "Compile swift source files" phase after completing all listed tasks (compile changed files and merge swiftmodule are both completed)
screenshot showing tasks list: https://imgur.com/a/JoVI0zB
While compilation and merging swift module takes less than second, whole phase can take up to 2min in my project (300k LOC).
What does Xcode do in this time? Is there any way to speed up this process?
Similar project written in Obj-C takes just few seconds to launch after changing 1 line of code.
I have this same issue and after a lot of investigation I have determined that whatever it is doing, it is based on the number of swift source files you have.
The Root Cause
In the 2018 wwdc talk about the Xcode build system the presenter says (searchable in the transcript of the video):
What this means is that unlike Clang, when compiling one Swift file, the compiler will parse all the other Swift files in the target.
So even if/though the incremental build only needs to recompile a single file, it still parses every other swift file.
Our project has over 2000 swift source files and we are seeing incremental build times of 3+ minutes for recompiling a single independent file.
Testing to prove the root cause
Because hearing it in a WWDC talk is not enough, I did the following to test it myself:
Created a new project
Tested incremental build times for nearly empty project, changing a single file
Incremental build completes nearly instantaneously (< 1-2 seconds)
Used a script to generate 2,000 swift files, each containing a simple struct with a unique name, 2 variables, and a simple function. There are no dependencies between any of the files.
Add the directory containing the 2,000 new swift files to the project and complete a full build.
Test incremental build times again for a single file
Incremental build time took more than 1 minute
In my testing, the complexity of the contents of the additional swift files does not seem to be significant, only the number of files.
The Solution - Modularization/Frameworks
Separate your app in to smaller frameworks to reduce the number of swift source files in each target.
This is a decent guide showing steps on how to go about this if you don't already know how.
In my test case above, I created a new framework and moved the 2,000 swift files into the framework and then tested incremental build times in the original project (importing the framework) and the build times were back to < 1-2 seconds. Of course doing an incremental build inside of the framework would still be slow, but ideally you would split the project into many and smaller frameworks so that each will have faster incremental build times.
Not the Solution - Merging Files
If the problem is the number of files, why not merge a bunch of files to reduce the number? Because it will likely result in slower incremental builds.
According to 2018 WWDC's Building Faster in Xcode:
Swift's dependency model is based around files
This relates to our current problem because it means that any change to a file (except for changes to function body contents only) will cause recompilation for any file that depends on ANYTHING in the changed file.
If you merge many types into a single file, it will result in more code getting recompiled on incremental builds if any of the changes touch the large file or any of its dependencies. It will also increase the number dependents the large file has, making it so all of them get recompiled if ANY of the types in the large file are modified.

CodeEffects Rule Engine. How to use + operator in evaluation rules

We are doing POC on business rules using CodeEffects rule engine. Trying to write evaluation rules using rule editor. Here question is how to use + operator between custom functions to evaluate specific rule. For example, I would like to write rule like below
check if(somefunc(somevar1)+somefunc(somevar2)+somefun(somevar3) is greater than [1]
Please help how to write such rule in editor.
You need to use the calculation option (the "Add calculation..." menu item) as the value of your condition. Keep in mind that in Code Effects each condition must begin with either a field or an in-rule method. Because of that, your rule needs to be changed as follows:
Check if Somefunc(Somevar1) is greater than
{ Somefunc(Somevar2) + Somefunc(Somevar3) - [1] }
Notice that the result of the evaluation is still the same, I just moved some rule elements around.

Xcode 6.3 code completion too slow

I've just updated Xcode to version 6.3. I'm working on a project in Swift with some imported Objective C code. I also use Cocoapods.
I had the same issue with the Xcode 6.3 beta. I've seen and tried all other StackOverflow answers with no luck.
So far I've tried to:
Delete ~/Library/Developer/Xcode/DerivedData and ~/Library/Caches/com.apple.dt.Xcode with Xcode and/or Mac restart.
Uninstall Spotify.
Not use the "+" concatenation operator.
Set deployment's target to 8.1.
I should mention that Objective C code autocompletes fast and that before indexing Swift code too. Esc button for popup suggestions works with the same delay.
Setting Whole Module Optimization to Yes is a workaround in my project.
In my case, the project has 5 modules, named here A, B, C, D and E, where the dependency is diagramed A -> B -> C -> D, and each of A to D refers E. With Xcode 6.3 and 6.3.1, it is fine to compile modules E and D, but it takes longer to compile C, and much longer to compile B and A, like 10 mins. After I change the project setting, it takes less than a min to compile all the modules. It looks faster than compilation with Xcode 6.2.
References:
Slow test file compilation in Swift 1.2, Xcode 6.3.1
https://devforums.apple.com/message/1128702#1128702
Try to clear project Derived Data, after update.
Window - Projects - YourProject - Derived Data - Delete...
In my case code completion is working better after update.
I used extensions on the GameScene Class and it sped everything up.
I took out three large functions from my gameScene Class, And made three separate extensions for them.
This is probably the easiest solution if none of the above work.
I got code completion down from several minutes to about 2-3 seconds for my large project.
Observation: although code completion considers 'everything' in a project, code completion was extremely slow when performed in one file and very ok when performed in another file.
The property of the slow file was one expression (filling an array with data) over several 1000 lines of code.
splitting the method with this expression up into 3 methods in 2 files (not 3 expressions in 1 method), I got the code completion speed from minutes to seconds.
It appears that there is a threshold where code completion gets slow. This is not a gradual thing where code completion gets slower and slower. It is either slow or fast. You don't have to split up your code into many methods. It is enough to get under the threshold.
This behaviour suggests a constraint in resources, maybe memory. My current machine has 16 GB memory.
So this is what you do:
check if code completion in one file is much slower than in others.
look for large or complex expressions in the slow file.
extract parts of the large expression into one or more separate methods. Probably not many extracts necessary. Start with one.
This issue appears to be fixed in Xcode 6.3.1 (released yesterday).