I get the error
Variables can not be used inside bindings
on the following Drools-Rule Code
rule "minGapsBetweenAppointments"
when
$leftAssignment : AppointmentRequest(feasibleAppointment != null)
$totalValue : Number( ) from accumulate(
AppointmentRequest(feasibleAppointment != null,
$leftAssignment.requestId != requestId,
$quality : this.getOccupiedSurroundingsValue($leftAssignment)),
sum( $quality )
) // ERROR LINE
then
scoreHolder.addSoftConstraintMatch(kcontext, $totalValue.intValue());
end
Although i found this post from another question, it's not helping me much, as I need to call function getOccupiedSurroundingsValue for all other AppointmentRequests, as they're related.
Any help appreciated.
That code should work. There's nothing wrong with it as far as I can see.
Double check if you it's exactly the same as the code you're executing it. I use similar code in my examples and those work.
If it's OK, then it might be a bug in Drools Expert.
There are 2 ways to proceed:
The easy way: repost this question on the drools mailing list, maybe Edson or Wolfgang sees something I don't. Post a jira if no one sees a user-mistake.
The fastest way to solve your problem: create a new test in MiscTest that proves your case and submit it as pull request. Either you find out what you're doing wrong or you prove without a shadow of a doubt there's a bug we need to fix asap :)
Related
new Here! I'm working on Jaspersoft, I've never used it before, but I saw some guide about.
I know that the IF condition has this structure : <condition> ?(Then) True :(else) False.
But I have problem to understand this line of code (see at the end of this message), where the IF is a little bit complicated. Can someone explain me what this line of code does?
($V{REPORT_COUNT}.intValue() == (1+("".equals($P{parametriReport}.get("censimp"))?0:1)) ? ("".equals($P{parametriReport}.get("censimp"))?"":"Codice Censimp "+$P{parametriReport}.get("censimp")):"")
GAMS: I think I have a pretty simple question, however I'm stuck and was wondering if someone could help here.
A simplified version of my model looks like this:
set(i,t) ;
parameter price
D;
variable p(i,t)
e(i,t);
equations
Equation1
obj.. C=sum((i,t), p(i,t)*price);
Model file /all/ ;
Solve file minimizing C using MIP ;
Display C.l;
p(i,t) and e(i,t) are related:
Equation1 .. e(i,t)=e=e(i,t-1)+p(i,t)*D
Now I want to retrieve information from the solution: lets say I want to know at what t e(i,t) has a certain value for example --> e(i,t)= x(i) or otherwise formulated e(i,t=TD)=x(i) find TD, where x(i) thus is depending on i. Does anyone know how I can write this in to my GAMs model? To be clear I do not want to change anything about my solution and the model I have runs; I just want to retrieve this information from the solution given.
So far I tried a couple of thing and nothing worked. I think that this must be simple, can anyone help? Thank you!
Try something like this:
set i /i1*i10/
t /t1*t10/;
variable e(i,t);
*some random dummy "solution"
e.l(i,t) = uniformInt(1,10);
set find5(i,t) 'find all combinations of i and t for which e.l=5';
find5(i,t)$(e.l(i,t)=5) = yes;
display e.l,find5;
Hope that helps,
Lutz
So I wanted to try my hand out creating a decision table from a rule that I've already made in a .drl file. Then I wanted to convert it back to a .drl. Didn't see any nifty conversions from drl to xls/csv nor was the jboss documentation comprehensive enough. It could be the rule is too complicated for a simple decision table but I was hoping this community could help me out.
Here is the drl:
rule "Patient: Compute BMI"
when
$basic : BasicInfoModel(
notPresent('bmi'),
isPresent('height'),
isPresent('weight'),
$height : value('height', 0.0),
$weight : value('weight', 0.0))
then
modify($basic){
put('bmi', $weight / Math.pow($height,2))
};
end
So this rule basically looks at an objects weight and height field and then computes the bmi. I've tried basically taking what I have and putting it into the decision table format but with little success. Nothing really parses (I'm just using the droolsSpreadSheet.compile and printing out what I get, which is a whole of empty rules). Any help would be appreciated!
Update:
This is what my excel sheet looks like
This is what my rule parses out to:
package DROOLS;
//generated from Decision Table
import basic.BasicInfoModel;
// rule values at A11, header at A6
rule "Computing BMI"
when
$patient:BasicInfoModel(notPresent('bmi'), isPresent('height'),isPresent('weight'), $height:value('height', 0.0), $weight:value('weight',0.0) == "20,4")
then
end
Update #2: I think I figured out my parse issues. Here is my new and improved spreadsheet., Basically found out that I cannot have the Computing BMI: data blank, there must be something in there in order to have the rule parse (Which isn't entirely clear in the docs I read, though that could be because my experience with decision tables is novice putting it lightly).
So now the compile looks more like what I want:
// rule values at A11, header at A6
rule "Computing BMI"
when
$patient:BasicInfoModel(notPresent('bmi'), isPresent('height'), isPresent('weight') == "TRUE")
$weight:value('weight',0.0), $height:value('height', 0.0)
then
modify($patient){put('bmi', $weight / Math.pow($height,2))};
end
Can someone confirm that I have to have real, specific data in the rules in order for them to parse? Can I just use injection elsewhere? Perhaps I should ask a new question on this.
So the answer is yes, you do need parameters, but what I didn't know was that the data doesn't have to be hardcoded like every example I've come across. Thanks to stumbling onto this answer. So now the table looks like this. I hope this helps others who've come across this issue. Also my recommendation is to just make your drools in a .drl rather than go through the spreadsheet, unless you have a bunch of rules that are pretty much copy and paste replicas. That's my two cents anyways.
I've started working a little bit with lift+scala+mongorecord but I found a small annoyance :
Usually to easily create a record ( document ) I just do:
User.createRecord.loginName("user").firstName("Name").lastName("LastName").save
But when I use the MongoPasswordField it is impossible to do it in just one line:
val userRecord = User.createRecord.loginName("user").firstName("Name").lastName("LastName")
userRecord.password.setPassword("SomePassword")|
userRecord.save
Source code for the filed is at http://scala-tools.org/mvnsites/liftweb-2.2/framework/scaladocs/lift-persistence/lift-mongodb-record/src/main/scala/net/liftweb/mongodb/record/field/MongoPasswordField.scala.html
Is there any way of doing this in just one line?
or at least can the field code be modified in some way to actually allow doing this?
I think you could do this:
User.createRecord.loginName("user").firstName("Name").lastName("LastName").password(Password("Some password")).save
I have a simple formula in crystal syntax which looks something like this :
if isdate(totext({Absence Details.Return to Work Interview Date})) = true
and {Absence Details.Return to Work Interview required} = true then
1
else
0;
This is the actual code of the formula
but the else part is never getting executed, when the condition is not true report just shows blank. I am not sure what I am doing wrong here.
Thanks in Advance.
- Amit
Maybe you have some null value in your fields - in such case crystal just returns null. You then need either "convert null values to default" setting for report or explicit testing against nulls.
Edit: NM, code was posted to the comments. Doesn't look like this is the issue.
My guess, assuming you've debugged correctly is that you've got a semicolon somewhere you shouldn't.
if {something} = x then
do something;
else
do something different;
instead of
if {something} = x then
do something
else
do something different;
This would cause the behaviour, assuming it doesn't choke on the orphaned else clause. But as the comments say, short of posting real code, we can only guess at what's going on. It could be as simple as your evaluation is always true.
Change the 0 to a 7 and see if it actually prints 7. Some report generation tools (and I have little experience with Crystal but quite a bit with others) will leave fields blank if they're zero - this often helps in reading the report by reducing unnecessary clutter.
If the 7's print out, then that's what the problem is, and it's a matter of figuring out how to get Crystal to output an actual 0.
That may be a matter of configuring the output field or even stting it to a textual "0" instead of numeric 0.
Of course, if that doesn't print out 7's, then feel free to let me know.