[accumulate] sum is always a double? What if it's only an int?
by Geoffrey De Smet
Hi guys,
I finally got around to experimenting with the accumulate support in
LocalSearchSolver. Thanks for implementing it :)
I use nothing but int's in my calculations,
but I get a ClassCastExceptions, as sum() always returns a Double and
setSoftConstraintsBroken(int) failes.
In a previous benchmarks I 've proven that summing integers in double's
instead of int's hurts performance for 10% or more (which is rather big).
Is there a sumInteger() available (or do I need to write it)? Or can it
be overloaded over sum() in a much cleaner way?
rule "ScoreCalculator"
when
$scoreFact : ScoreFact(); // singleton
$total : Integer() from accumulate(
Hop($distance : distance ), // distance is an int
sum($distance)
);
then
$scoreFact.setSoftConstraintsBroken($total);
end
svn is still here, till it's ready for drools:
https://taseree.svn.sourceforge.net/svnroot/taseree/trunk
--
With kind regards,
Geoffrey De Smet
17 years, 3 months
JBoss Drools BRMS Standalone
by Fernando Meyer
Now you can download BRMS standalone version, this distribution comes
with a built-in Tomcat 5.5.20 web server and the insurance example as
demo repository, so it runs out the box. If you want to test BRMS and
don't have enough time to deploy, just follow to downloads page
http://labs.jboss.com/drools/downloads
Brief install guide
1. Install a Java Development Kit (JDK) from http://java.sun.com/
javase/downloads/index.jsp (avoid JREs, Java EEs, Netbeans, etc. on
that page - you just want a JDK).
2. Set the JAVA_HOME variable to where you installed Java. Windows
installers may do this for you.
3. Run bin/startup.sh (*nix) or bin\startup.bat (Windows). Check that
there are no errors on the console. See below for troubleshooting
advice.
4. Point your browser at http://localhost/ You should see brms's
login box.
Problem
A common startup problem is when another program has claimed port 80,
which BRMS is configured to run on by default. To avoid this port
conflict, BRMS's port can be changed in conf/server.xml.
If you have installation (or other) problems, ask on the mailing
lists or irc.
http://labs.jboss.com/drools/irc.html
Fernando Meyer http://fmeyer.org
fmcamargo(a)gmail.com
PGP: 0xD804DDFB
17 years, 4 months
drools-solver-localsearch lifecycle design issues
by Geoffrey De Smet
I can't seem to decide on a good lifecycle design for
drools-solver-localsearch
So I was hoping to tap into you guys's experience in doing such things.
You can find a uml diagram here:
https://taseree.svn.sourceforge.net/svnroot/taseree/trunk/src/uml/localse...
Most concepts are explained in my previous blog:
http://blog.athico.com/2007/06/local-search-101.html
There is however a new concept of a "Forager", which simple gathers all
accepted moves and sorts them (for example on max score).
I have different Selector, Accepter, Forager and Finish implementations,
of which some have needs:
- SolutionTabuAccepter needs the Random singleton (this needs to be a
singleton because it's seeded for predicable results)
- SolutionTabuAccepter needs the stepSolution after it has been decided.
- SimulatedAnnealingAccepter needs finish.calculateTimeGradient() (but
this should be cached over all move iterations in a single step.)
- UnimprovedStepCountFinish needs
bestSolutionRecaller.getBestSolutionStepIndex()
- ...
With which scenario do I deal best with this?
scenario 1) chaining till we find it:
- SolutionTabuAccepter:
decider.getLocalSearchSolver().getRandom().nextDouble();
- UnimprovedStepCountFinish:
localSearchSolver.getBestSolutionRecaller().getBestSolutionStepIndex();
This is hell for backwards compatible refactors...
scenario 2) instanceof on Aware and Lifecyle interfaces:
if (accepter implements LocalSearchSolverAware) {
((LocalSearchSolverAware) accepter)
.setLocalSearchSolver(localSearchSolver);
}
This is doing instanceofs...
scenario 3) some ServiceLocator pattern and inject it all over the place
public interface ServiceLocator {
LocalSearchSolver getLocalSearchSolver()
Finish getFinish();
...
}
This is ugly...
Anyone got a better scenario?
I was thinking of scenario 2, which would fit in with the fact solver
needs a configuration framework anyway...
Thanks for helping out this design issue :)
--
With kind regards,
Geoffrey De Smet
17 years, 4 months
Reusing query's in accumulate functions
by Geoffrey De Smet
I wonder if there are any plans to allow query's to be reused in
accumulate functions? Something like
query "multipleQueensHorizontal"
Queen($id : id, $y : y);
Queen(id > $id, y == $y);
end
rule "x"
when
Integer() from accumulate(
count(query "multipleQueensHorizontal") // <==
);
then
...
end
If not, mind if I make a (long term) issue if you think it's a good idea
and possible to implement?
Is there an issue for Multiple Pattern Accumulate and if not, mind if I
create one?
Thanks as always :)
--
With kind regards,
Geoffrey De Smet
17 years, 4 months
Number Guess Example
by Mark Proctor
I've just added a text based Number Guess example, similar to the Seam
example, it uses a recursive ruleflow; which I thought people might find
interesting. Its working, but still needs a bit of cleaning and
tweaking. Thought I'd show a screenshot, to wet people's appetite:
Mark
17 years, 4 months
sources jar not on repo => patch
by Geoffrey De Smet
http://jira.jboss.com/jira/browse/JBRULES-1035
I tried to commit it myself, but failed.
I am not sure if that's because I haven't got commit rights
or if it's because I am using the wrong svn url
or if it's because I am locally using the wrong login for that svn url?
My svn url is https://svn.labs.jboss.com/labs/jbossrules/trunk
Anyway, the patch is attached to the issue, works too :)
----
Because the maven-source-plugin isn't attached to the default lifecylce,
you need to explicitly link it in <plugins>.
Hope this changes for maven 2.1.
I also added test-jar sources :)
In the parent pom I changed this:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>2.0.2</version>
<executions>
<execution>
<goals>
<goal>jar</goal>
+ <goal>test-jar</goal>
</goals>
</execution>
</executions>
</plugin>
...
</pluginManagement>
<plugins>
+ <plugin>
+ <!-- Entry needed to create, install and deploy sources jars -->
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-source-plugin</artifactId>
+ </plugin>
</plugins>
</build>
Then people can use
"mvn -DdownloadSources=true eclipse:eclipse idea:idea"
--
With kind regards,
Geoffrey De Smet
17 years, 4 months
Updated Maven2 artifacts
by Fernando Meyer
Hi everybody
I just checked in new maven2 artifacts to maven repository, Now it
counts with deployment metadata info and md5 + sha1 checksum.
Regards.
Fernando Meyer http://fmeyer.org
fmcamargo(a)gmail.com
PGP: 0xD804DDFB
17 years, 4 months
(no subject)
by Fernando Meyer
Hi everybody
I just checked in new maven2 artifacts to maven repository, Now it
counts with deployment metadata info and md5 + sha1 checksum.
Regards.
Fernando Meyer http://fmeyer.org
fmcamargo(a)gmail.com
PGP: 0xD804DDFB
17 years, 4 months