Optaplanner: Shadow Variables vs insertLogical
by jonathan.labin
I noticed the recent introduction of the concept of Shadow Variables in the
Optaplanner. I'm wondering if someone could help me understand the
difference between Shadow Variables and inserting facts with
insertLogical()?
Each are described a little bit in the manual and it seems that there is a
similar use case but I'm not sure I understand the implications of using one
over the other? I see that some of the examples still use insertLogical so
I'm assuming that shadow variables are not a replacement in every case.
To help frame the answer, consider the following toy problem which maps to
my domain fairly well:
Say my problem is creating purchase orders of raw materials for my factory
from various vendors. The input states how many of each raw material I
need. Obviously I would want to minimize cost but I also have no capacity
to store extra raw materials so any extra that I buy will be waste.
Therefore, I'll want to create a list of orders that obtains exactly the
required number of each if possible.
Each vendor offers package deals that include different combinations of raw
materials in different amounts.
There would clearly be other optimizations such as reducing the number of
vendors used but those would likely be secondary to the cost and waste
optimizations.
The domain model for this problem would include a Planning Value for each
individual raw material item as well as one for each package combo offered
by a vendor (essentially anything with a price).
So, for a problem space like this, I'll want rules which count the number of
each raw material type across all of the different packages purchased from
different vendors and make sure it meets the needs of the particular
provided problem.
Currently I am using a rule that fires for each raw material type and counts
the number of units ordered for that type using an accumulator over Planning
Entities. I am currently experiencing score corruption which I believe may
be due to this approach so I am looking to redesign.
Would Shadow Variables or calls to insertLogical() be more
appropriate/efficient for this use?
Thanks in advance,
Jon
--
View this message in context: http://drools.46999.n3.nabble.com/Optaplanner-Shadow-Variables-vs-insertL...
Sent from the Drools: User forum mailing list archive at Nabble.com.
12 years, 5 months
Error when I try to open technical rule asset in Guvnor
by Lance
Some background...
Using Drools v5.3.5.Final and Guvnor v5.3.5.Final
Created numerous packages, some of which contain assets that were promoted
to "global"
Some of the assets in "global" were placed there at the outset
Assets that were placed in "global" at the outset are jar files for domain
models used across multiple packages
Assets that were promoted to "global" are functions that it turned out were
needed in multiple packages
The problem...
For a subset of packages, any attempt to open a 'technical rule asset' in
the Guvnor web interface results in the following pop-up error dialogs:
/Unable to get content assistance for this rule./
*AND*
/Unable to validate package configuration (eg, DSLs, models) for
'shipment.document.validation'.
Suggestion completions may not operate correctly for graphical
editors for this package./
Other possible information of interest, with regards to the packages that
have the problem...
Using JBoss Dev Studio, and its web-dav based interface, I can open the DRL
files and they appear to be okay
If I click on the link to download the source for the package, the resultant
package file appears to contain everything as expected
I am able to validate and compile the package, without error, from within
Guvnor
It should be noted that out of the nine packages I have defined, so far,
only two of the packages exhibit this problem. In all of the other packages,
I am able to manipulate technical rules via the Guvnor web-app.
Summary...
The primary problem is that I cannot use the rule editor within the Guvnor
web-app to manipulate the rules. On the one hand, I'm not too concerned as
JBDS seems to provide an adequate workaround. However, not being able to
open the rules within the Guvnor application does seem to be a bit of a
nuisance.
--
View this message in context: http://drools.46999.n3.nabble.com/Error-when-I-try-to-open-technical-rule...
Sent from the Drools: User forum mailing list archive at Nabble.com.
12 years, 5 months
Problem with Guvnor using Rest API
by Demian Calcaprina
Hey Guys.
I am using guvnor 5.5.0.Final.
I am accesing to from another app using the REST API. I am currently having
a problem. I create a new package, sending a post to guvnor/rest/packages/,
sending it an xml version of PackageMetadata. Then, I create assets (drl
files), by sending a post to guvnor/rest/packages/" + packageName +
"/asset, with the drl contents. This works fine. The problem in with
package building. I read somewhere that it is automatically built when you
create a new asset or update one. But just after creating the package, I go
to the package url, the one I configure in the changeset,
localhost:8080/guvnor/org.drools.guvnor.Guvnor/package/mypackage/LATEST,
and I get a NPE,
java.lang.NullPointerException
java.io.OutputStream.write(OutputStream.java:75)
org.drools.guvnor.server.files.FileManagerService.loadBinaryPackage(FileManagerService.java:201)
org.drools.guvnor.server.files.FileManagerService$Proxy$_$$_WeldClientProxy.loadBinaryPackage(FileManagerService$Proxy$_$$_WeldClientProxy.java)
org.drools.guvnor.server.files.PackageDeploymentServlet$1.execute(PackageDeploymentServlet.java:260)
org.drools.guvnor.server.files.RepositoryServlet.doAuthorizedAction(RepositoryServlet.java:59)
org.drools.guvnor.server.files.PackageDeploymentServlet.doGet(PackageDeploymentServlet.java:139)
javax.servlet.http.HttpServlet.service(HttpServlet.java:742)
javax.servlet.http.HttpServlet.service(HttpServlet.java:847)
org.jboss.weld.servlet.ConversationPropagationFilter.doFilter(ConversationPropagationFilter.java:62)
org.jboss.solder.servlet.exception.CatchExceptionFilter.doFilter(CatchExceptionFilter.java:65)
org.jboss.solder.servlet.event.ServletEventBridgeFilter.doFilter(ServletEventBridgeFilter.java:74)
If I build the package manually, I am able to get the PKG there. I am
making something wrong? Is there a way to make it build the package
from REST?
Thanks!
Demian
12 years, 5 months
Problem importing assets using REST API
by calcacuervo
Hi Guys!
I am importing lot of assets to guvnor using rest API. And sometimes I get
the following error:
02:33:14,718 WARN [org.apache.jackrabbit.core.session.SessionState]
(http--0.0.0.0-8080-80) Attempt to perform session.save() while another
thread is concurrently writing to session-guest-3. Blocking until the other
thread is finished using this session. Please review your code to avoid
concurrent use of a session.: java.lang.Exception: Stack trace of concurrent
access to session-guest-3
at
org.apache.jackrabbit.core.session.SessionState.perform(SessionState.java:147)
[jackrabbit-core-2.2.8.jar:2.2.8]
at org.apache.jackrabbit.core.SessionImpl.perform(SessionImpl.java:355)
[jackrabbit-core-2.2.8.jar:2.2.8]
at org.apache.jackrabbit.core.SessionImpl.save(SessionImpl.java:758)
[jackrabbit-core-2.2.8.jar:2.2.8]
at org.drools.repository.RulesRepository.save(RulesRepository.java:1405)
[guvnor-repository-5.4.0.Final.jar:5.4.0.Final]
at
org.drools.guvnor.server.jaxrs.PackageResource.updateAssetBinary(PackageResource.java:791)
[guvnor-webapp-core-5.4.0.Final.jar:5.4.0.Final]
at sun.reflect.GeneratedMethodAccessor97.invoke(Unknown Source) [:1.7.0_21]
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
[rt.jar:1.7.0_21]
at java.lang.reflect.Method.invoke(Method.java:601) [rt.jar:1.7.0_21]
at
org.apache.cxf.service.invoker.AbstractInvoker.performInvocation(AbstractInvoker.java:173)
[cxf-rt-core-2.4.4.jar:2.4.4]
at
org.apache.cxf.service.invoker.AbstractInvoker.invoke(AbstractInvoker.java:89)
[cxf-rt-core-2.4.4.jar:2.4.4]
at org.apache.cxf.jaxrs.JAXRSInvoker.invoke(JAXRSInvoker.java:164)
[cxf-rt-frontend-jaxrs-2.4.4.jar:2.4.4]
at org.apache.cxf.jaxrs.JAXRSInvoker.invoke(JAXRSInvoker.java:91)
[cxf-rt-frontend-jaxrs-2.4.4.jar:2.4.4]
at
org.apache.cxf.interceptor.ServiceInvokerInterceptor$1.run(ServiceInvokerInterceptor.java:58)
[cxf-rt-core-2.4.4.jar:2.4.4]
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
[rt.jar:1.7.0_21]
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
[rt.jar:1.7.0_21]
at java.util.concurrent.FutureTask.run(FutureTask.java:166)
[rt.jar:1.7.0_21]
at
org.apache.cxf.workqueue.SynchronousExecutor.execute(SynchronousExecutor.java:37)
[cxf-rt-core-2.4.4.jar:2.4.4]
at
org.apache.cxf.interceptor.ServiceInvokerInterceptor.handleMessage(ServiceInvokerInterceptor.java:106)
[cxf-rt-core-2.4.4.jar:2.4.4]
at
org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:263)
[cxf-api-2.4.4.jar:2.4.4]
at
org.apache.cxf.transport.ChainInitiationObserver.onMessage(ChainInitiationObserver.java:121)
[cxf-rt-core-2.4.4.jar:2.4.4]
at
org.apache.cxf.transport.http.AbstractHTTPDestination.invoke(AbstractHTTPDestination.java:206)
[cxf-rt-transports-http-2.4.4.jar:2.4.4]
at
org.apache.cxf.transport.servlet.ServletController.invokeDestination(ServletController.java:209)
[cxf-rt-transports-http-2.4.4.jar:2.4.4]
at
org.apache.cxf.transport.servlet.ServletController.invoke(ServletController.java:152)
[cxf-rt-transports-http-2.4.4.jar:2.4.4]
at
org.apache.cxf.transport.servlet.CXFNonSpringServlet.invoke(CXFNonSpringServlet.java:114)
[cxf-rt-transports-http-2.4.4.jar:2.4.4]
at
org.apache.cxf.transport.servlet.AbstractHTTPServlet.handleRequest(AbstractHTTPServlet.java:184)
[cxf-rt-transports-http-2.4.4.jar:2.4.4]
at
org.apache.cxf.transport.servlet.AbstractHTTPServlet.doPut(AbstractHTTPServlet.java:124)
[cxf-rt-transports-http-2.4.4.jar:2.4.4]
at javax.servlet.http.HttpServlet.service(HttpServlet.java:757)
[jboss-servlet-api_3.0_spec-1.0.0.Final.jar:1.0.0.Final]
at
org.apache.cxf.transport.servlet.AbstractHTTPServlet.service(AbstractHTTPServlet.java:163)
[cxf-rt-transports-http-2.4.4.jar:2.4.4]
at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:329)
[jbossweb-7.0.13.Final.jar:]
at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248)
[jbossweb-7.0.13.Final.jar:]
at
org.jboss.weld.servlet.ConversationPropagationFilter.doFilter(ConversationPropagationFilter.java:62)
[weld-core-1.1.5.AS71.Final.jar:2012-02-10 15:31]
at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:280)
[jbossweb-7.0.13.Final.jar:]
at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248)
[jbossweb-7.0.13.Final.jar:]
at
org.jboss.solder.servlet.exception.CatchExceptionFilter.doFilter(CatchExceptionFilter.java:65)
[solder-impl-3.1.1.Final.jar:3.1.1.Final]
at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:280)
[jbossweb-7.0.13.Final.jar:]
at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248)
[jbossweb-7.0.13.Final.jar:]
at
org.jboss.solder.servlet.event.ServletEventBridgeFilter.doFilter(ServletEventBridgeFilter.java:74)
[solder-impl-3.1.1.Final.jar:3.1.1.Final]
at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:280)
[jbossweb-7.0.13.Final.jar:]
at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248)
[jbossweb-7.0.13.Final.jar:]
at
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:275)
[jbossweb-7.0.13.Final.jar:]
at
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:161)
[jbossweb-7.0.13.Final.jar:]
at
org.jboss.as.web.security.SecurityContextAssociationValve.invoke(SecurityContextAssociationValve.java:153)
[jboss-as-web-7.1.1.Final.jar:7.1.1.Final]
at
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:155)
[jbossweb-7.0.13.Final.jar:]
at
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
[jbossweb-7.0.13.Final.jar:]
at
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
[jbossweb-7.0.13.Final.jar:]
at
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:368)
[jbossweb-7.0.13.Final.jar:]
at
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:877)
[jbossweb-7.0.13.Final.jar:]
at
org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:671)
[jbossweb-7.0.13.Final.jar:]
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:930)
[jbossweb-7.0.13.Final.jar:]
at java.lang.Thread.run(Thread.java:722) [rt.jar:1.7.0_21]
Does someone know how guvnor manages JCR sessions, and/or if there is a
potential bug somewhere?
Thanks!
Demian
--
View this message in context: http://drools.46999.n3.nabble.com/Problem-importing-assets-using-REST-API...
Sent from the Drools: User forum mailing list archive at Nabble.com.
12 years, 5 months
Re: [rules-users] Dynamic Rules and Eval
by Davide Sottara
I'll see if I can reproduce it in 5.6.. I'm traveling so it will take a couple of days
T-Mobile. America's First Nationwide 4G Network
rrdh <rrdh(a)gmx.net> wrote:
>Ah, thanks for letting me know! I'll try an earlier version then.
>
>
>On Sun, Jul 14, 2013 at 8:54 PM, Wolfgang Laun <wolfgang.laun(a)gmail.com>wrote:
>
>> It's a bug, possibly a regression from 5.2.0 that has been in 5.3.0,
>> 5.4.0 and is still in 5.5.0.
>>
>> It should be very simple to add http://codetidy.com/6206/ as a test
>> case so that this will be fixed.
>>
>> -W
>>
>>
>> On 14/07/2013, Wolfgang Laun <wolfgang.laun(a)gmail.com> wrote:
>> > Which Drools version do you use?
>> >
>> > On 14/07/2013, k <rrdh(a)gmx.net> wrote:
>> >> Hi,
>> >> basically it's the same problem this guy had
>> >>
>> http://stackoverflow.com/questions/11485122/non-template-dynamic-rules-in...
>> >> <
>> http://stackoverflow.com/questions/11485122/non-template-dynamic-rules-in...
>> >
>> >>
>> >> , but the links in that question don't work.
>> >>
>> >> I'd like to dynamically add rules to a running session, but can use
>> >> 'eval'
>> >> only in the very first one. If I add a second rule like the following,
>> it
>> >> won't execute:
>> >>
>> >> ---
>> >>
>> >> String test2 =
>> >> "\nrule id4" +
>> >> "\nwhen" +
>> >> "\neval(0 == 0)" + // if this eval is removed, "done2" is inserted
>> >> "\nthen" +
>> >> "\ninsertLogical( \"done2\" );" +
>> >> "\nend";
>> >>
>> >> kbuilder.add(ResourceFactory.newByteArrayResource(test2.getBytes()),
>> >> ResourceType.DRL);
>> >>
>> session.getKnowledgeBase().addKnowledgePackages(kbuilder.getKnowledgePackages());
>> >>
>> >> fired = session.fireAllRules();
>> >> System.out.println(fired); // 0
>> >> effects = session.getObjects();
>> >> assertTrue("fired", effects.contains("done2")); // fails
>> >>
>> >> ---
>> >>
>> >> You can see the complete Test at http://codetidy.com/6206/
>> >>
>> >> I'm also not sure if this is the correct way to dynamically add rules,
>> so
>> >> please let me know, if there's a better way to add rules from strings.
>> >>
>> >> How can I dynamically add new rules to a running session and still use
>> >> eval?
>> >>
>> >>
>> >>
>> >> --
>> >> View this message in context:
>> >> http://drools.46999.n3.nabble.com/Dynamic-Rules-and-Eval-tp4024908.html
>> >> Sent from the Drools: User forum mailing list archive at Nabble.com.
>> >> _______________________________________________
>> >> rules-users mailing list
>> >> rules-users(a)lists.jboss.org
>> >> https://lists.jboss.org/mailman/listinfo/rules-users
>> >>
>> >
>> _______________________________________________
>> rules-users mailing list
>> rules-users(a)lists.jboss.org
>> https://lists.jboss.org/mailman/listinfo/rules-users
>>
>
>_______________________________________________
>rules-users mailing list
>rules-users(a)lists.jboss.org
>https://lists.jboss.org/mailman/listinfo/rules-users
12 years, 5 months
Guvnor repository backward compatible?
by Sean Su
While evaluating and building rules in using Guvnor 5.5, we have noticed
that there will be some major changes in 6.0. We have some concerns that
the repository (rules) built using 5.5 may not be accessible by Gunvor 6.0.
Does anyone know anything about this? Do we have document about 6.0? It
seems the document in the 6.0 beta download has the old content.
Also what is the estimated release date for 6.0?
Thanks
Sean
12 years, 5 months
java.lang.ClassCastException: [Lorg.drools.rule.Package; cannot be cast to org.drools.rule.Package
by Ganesh Neelekani
Hi,
I am strugling with "java.lang.ClassCastException:
[Lorg.drools.rule.Package; cannot be cast to org.drools.rule.Package " from
many days,
can you please help me to resolve this exception ,
As it is causing run time and if i again restarted and issue is not found
for same request...
I am using drools-guvnor.war(jboss version) of 5.4 version
--
Thanking you.
----------------------------------------------------------------------
With regards.
Ganesh N Neelekani
ph - +91 7829108302
12 years, 5 months
ClassCastException when changing drools version 5.3.5.Final to 6.0.0.Beta3
by Andreas
Hi,
when I change the version of drools from 5.3.5.Final to 6.0.0.Beta3 (maven
pom)
I'm getting following exception:
org.drools.RuntimeDroolsException: Unable to load dialect
'org.drools.compiler.rule.builder.dialect.mvel.MVELDialectConfiguration:mvel:org.drools.compiler.rule.builder.dialect.mvel.MVELDialectConfiguration'
at
org.drools.compiler.PackageBuilderConfiguration.addDialect(PackageBuilderConfiguration.java:283)
at
org.drools.compiler.PackageBuilderConfiguration.buildDialectConfigurationMap(PackageBuilderConfiguration.java:268)
at
org.drools.compiler.PackageBuilderConfiguration.init(PackageBuilderConfiguration.java:181)
at
org.drools.compiler.PackageBuilderConfiguration.<init>(PackageBuilderConfiguration.java:159)
at org.drools.compiler.PackageBuilder.<init>(PackageBuilder.java:210)
at org.drools.compiler.PackageBuilder.<init>(PackageBuilder.java:143)
at
org.drools.builder.impl.KnowledgeBuilderFactoryServiceImpl.newKnowledgeBuilder(KnowledgeBuilderFactoryServiceImpl.java:34)
at
org.drools.builder.KnowledgeBuilderFactory.newKnowledgeBuilder(KnowledgeBuilderFactory.java:47)
at
net.javabeansdotasia.casestudy.test.Tester.prepareKnowledgeBase(Tester.java:136)
at net.javabeansdotasia.casestudy.test.Tester.setUp(Tester.java:71)
at net.javabeansdotasia.casestudy.test.Tester.main(Tester.java:160)
Caused by: java.lang.ClassCastException:
org.drools.compiler.rule.builder.dialect.mvel.MVELDialectConfiguration
cannot be cast to org.drools.compiler.DialectConfiguration
at
org.drools.compiler.PackageBuilderConfiguration.addDialect(PackageBuilderConfiguration.java:278)
... 10 more
would be nice if someone could help me,
if the source code is needed let me know
Andreas
--
View this message in context: http://drools.46999.n3.nabble.com/ClassCastException-when-changing-drools...
Sent from the Drools: User forum mailing list archive at Nabble.com.
12 years, 5 months