Optaplanner unable to add nearbySelection to subChainSelector - optaplanner

My question is essentially the same as Nearby selection with subChainChangeMoveSelector or subChainSwapMoveSelector
I am unable to configure a <nearbySelection> for a subChainSwapMoveSelector or subChainChangeMoveSelector.
The docs outline the use of nearbySelector as for example:
<tailChainSwapMoveSelector>
<entitySelector id="entitySelector3"/>
<valueSelector>
<nearbySelection>
<originEntitySelector mimicSelectorRef="entitySelector3"/>
<nearbyDistanceMeterClass>...CustomerNearbyDistanceMeter</nearbyDistanceMeterClass>
<parabolicDistributionSizeMaximum>40</parabolicDistributionSizeMaximum>
</nearbySelection>
</valueSelector>
</tailChainSwapMoveSelector>
However, setting an entitySelector on a subChainChangeMove or subChainSwapMoveis not possible due to them lacking an entitySelectorConfig. They do support a valueSelectorConfig, which in turn supports a nearbySelectionConfig. However it is impossible to do something like this:
<subChainSwapMoveSelector>
<entityClass>...</entityClass>
<selectReversingMoveToo>true</selectReversingMoveToo>
<subChainSelector>
<minimumSubChainSize>2</minimumSubChainSize>
<maximumSubChainSize>10</maximumSubChainSize>
<valueSelector variableName="previousStandstill" mimicSelectorRef="subChainSwapMove">
<nearbySelection>
<originEntitySelector mimicSelectorRef="subChainSwapMove"/>
<nearbyDistanceMeterClass>....</nearbyDistanceMeterClass>
<parabolicDistributionSizeMaximum>40</parabolicDistributionSizeMaximum>
</nearbySelection>
</valueSelector>
</subChainSelector>
</subChainSwapMoveSelector>
Because when ValueSeletorConfig tries to call buildMimicReplaying() it fails on
if (id != null
|| variableName != null
|| cacheType != null
|| selectionOrder != null
|| nearbySelectionConfig != null
Is this a bug? Is there supposed to be an entitySelectorConfig for both these moves, or how do I get the nearbySelection to work with a valueSelector as the docs only outline the use of entitySelector ?
Thanks!

Related

ng-class multiple condition in on statement

I need to check if two things is true to decide the class. I have been trying to find a solution for this because i believe this should be a pretty common problem. Maybe i'm just searching for the wrong things.
I want to have two conditions in one statement, if that is what it is called?
I've tried similar things to this:
ng-class="{'in-behalf-of-background-color' : parameters.Username == quote.InBehalfOf } ,{'not-in-behalf-of-background-color' : ((parameters.Username != quote.InBehalfOf) && (quote.InBehalfOf != 'null'))}"
As you can see i want to check parameters.Username != quote.InBehalfOf and also if quote.InBehalfOf != null in the same condition. Is this possible?
try this code;
You want multiple condition then define one object and define conditions with key value pair {key1:value1, key2: value2}
ng-class="{'in-behalf-of-background-color' : parameters.Username == quote.InBehalfOf, 'not-in-behalf-of-background-color' : ((parameters.Username != quote.InBehalfOf) && (quote.InBehalfOf)) }"
The thing you are missing is, for multiple classes in ng-class you don't need to create another {..}. You can specify multiple just by seperating them with a comma ,. So, the following should work,
ng-class="{'in-behalf-of-background-color' : parameters.Username == quote.InBehalfOf,
'not-in-behalf-of-background-color' : (parameters.Username != quote.InBehalfOf) && (quote.InBehalfOf != 'null')}"
Try this,
ng-class="{'in-behalf-of-background-color' : parameters.Username === quote.InBehalfOf , 'not-in-behalf-of-background-color' : ((parameters.Username !== quote.InBehalfOf) && (quote.InBehalfOf !== 'null'))}"
refer angular ng-class doc

Drools, how to check if an object with a specific property exists more than once in the list

I have a number of PersonEntitys in my working memory. I need to write a rule to check if two PersonEntitys with the same someProperty are existed in the working memory. I have written as follows, but the problem is, when there are really two PersonEntitys with same someProperty, the sys.out is executing twice:
when
$person : PersonEntity(person.personType == PersonType.LegalPerson);
$personList : ArrayList( size > 1 ) from collect( PersonEntity(someProperty.id == $legalPerson.someProperty.id))
then
System.out.println("error occured");
I also tried this, but I think since my working memory has a number of PersonEntities, the rule is executing 4times (number of PersonEntitys) and my "error occurred " sentence appears 4times in console:
PersonEntity(some conditions, $relatedId :relatedPerson.id);
exists PersonEntity(some conditions, relatedPerson.id > $relatedId)
The standard solution to this problem is to add another constraint using a unique property which guarantees an ordering.
when
PersonEntity(personType == PersonType.LegalPerson, $pid: personId)
exists PersonEntity(personType == PersonType.LegalPerson, personId > $pid)
then
// two LegalPerson
If you expect three or more of the same, you may even have to add another pattern to block multiple activations:
when
PersonEntity(personType == PersonType.LegalPerson, $pid: personId)
not PersonEntity(personType == PersonType.LegalPerson, personId < $pid )
exists PersonEntity(personType == PersonType.LegalPerson, personId > $pid)
then
// two or more LegalPerson
(The suggestion to use collect isn't good unless you really need all of these.)
This will work even when you need to check for any personType:
when
PersonEntity( $pt: personType, $pid: personId)
not PersonEntity(personType == $pt, personId < $pid )
exists PersonEntity(personType == $pt, personId > $pid)
then
// two or more $pt
Here you may add a collect instead of the third pattern to get all such PersonEntity facts.

iphone ios 7.x vs ios 6.x constraints

Have a situation where UI is working fine on iOS 7.x, but on iOS 6.x getting constraint breaks. Wondering why there is such a difference with the exact same UI Auto Layout, etc.
Here is an example of a break on iOS 6.x
Will attempt to recover by breaking constraint
<NSLayoutConstraint:0x17e91390 V:[UIView:0x17ecb3b0]-(0)-| (Names: '|':XxxCollectionViewCollectionViewCell:0x17eca520 )>
Break on objc_exception_throw to catch this in the debugger.
The methods in the UIConstraintBasedLayoutDebugging category on UIView listed in <UIKit/UIView.h> may also be helpful.
2014-07-11 11:39:33.886 XXXXX[25856:c07] Unable to simultaneously satisfy constraints.
Probably at least one of the constraints in the following list is one you don't want. Try this: (1) look at each constraint and try to figure out which you don't expect; (2) find the code that added the unwanted constraint or constraints and fix it. (Note: If you're seeing NSAutoresizingMaskLayoutConstraints that you don't understand, refer to the documentation for the UIView property translatesAutoresizingMaskIntoConstraints)
(
"<NSAutoresizingMaskLayoutConstraint:0x17ecaf40 h=--& v=-&& XxxCollectionViewCollectionViewCell:0x17eca520.height == 34*UICollectionView:0xe294400.height - 20740>",
"<NSAutoresizingMaskLayoutConstraint:0x1660b530 h=-&- v=-&- UINavigationTransitionView:0xbaf7b60.height == UILayoutContainerView:0xbaf6f80.height>",
"<NSAutoresizingMaskLayoutConstraint:0xd24fec0 h=-&- v=-&- UICollectionView:0xe294400.height == UIView:0x17ed5da0.height>",
"<NSAutoresizingMaskLayoutConstraint:0xd257470 h=-&- v=-&- UIViewControllerWrapperView:0xbe75e80.height == UINavigationTransitionView:0xbaf7b60.height - 64>",
"<NSAutoresizingMaskLayoutConstraint:0xd233b30 h=-&- v=-&- UIView:0x17ed5da0.height == UIViewControllerWrapperView:0xbe75e80.height>",
"<NSAutoresizingMaskLayoutConstraint:0xba5ea50 h=-&- v=-&- UILayoutContainerView:0xbaf6f80.height == VoiceTouchOverlayWindow:0xbec7fb0.height>",
"<NSAutoresizingMaskLayoutConstraint:0xba5d4b0 h=--- v=--- V:[VoiceTouchOverlayWindow:0xbec7fb0(480)]>"
)

Jira Custom Release Notes: Velocity if(..) Statements and Returned Values from Macros

I have been experimenting with Jira's custom release notes feature, which requires writing a custom .vm file. This is my first time working with Velocity and would greatly appreciate a hand with this minor issue:
I have a simple macro that checks is an $issue has a custom field called For Release Notes and gets its value. Based on this value, I want Velocity to either output the issue summary, or skip it.
The problem is that even though the macro is returning true or false, I cannot get the if() statement to properly process the value.
Macro:
#macro(getForReleaseNotes $issue $customFieldManager)
#set ($customFields = $customFieldManager.getCustomFieldObjects($issue.project.getLong("id"), $issue.issueType.getString("id")))
#set( $retVal = "false" )
#foreach($customField in $customFields)
#if($customField.name.equals("For Release Notes"))
#if($customField.getValue($issue)) #set( $retVal = "true" )
#end
#end
#end
$retVal
#end
HTML:
#foreach ($issueType in $issueTypes)
#if($issueType.issues.size() > 0)
<h2>$textUtils.htmlEncode($issueType.name)</h2>
<ul>
#foreach ($issue in $issueType.issues)
#set( $tester = "#getForReleaseNotes($issue $customFieldManager)" )
#if($tester == "true")
<li>[<a href='$requestContext.canonicalBaseUrl/browse/$issue.key'>$issue.key</a>] - $textUtils.htmlEncode($issue.summary)</li>
#else
<li> Value for macro: #getForReleaseNotes($issue $customFieldManager), $tester </li>
#end
#end
</ul>
#end
#end
I have tried a number of combinations within the if(), from if( $tester.equals("getForReleaseNotes(..))" ), to simply if( "getForReleaseNotes(..) ).
Now, the macro actually works and returns $retVal = false (or is it $retVal = "false" and does that make a difference?) when the issue does not have this property/the property is set to false. The Macro will likewise return true if otherwise. The issue is simply getting the if(..) statement to properly evaluate, because as of right now it says everything I pass into it is false, and issues never get printed.
Any help on this issue would be greatly appreciated. Thanks for reading.
I have found a solution for this problem, though I do not believe it to be the most efficient because it requires looping through the list of issues twice.
The first loop checks if there are issues of the given issue type, and if any of those issues are marked as "For Release Notes."
If the first loop does find an issue marked For Release Notes, it moves to the second loop. The second loop then pulls out the details of all the issues within that issue type that are marked For Release Notes.
NOTE: I added another field called "Release Note," so users have more control over what appears in the generated release notes. If the field is not set, it defaults to using the issue summary.
#if($issueType.issues.size() > 0)
#set($flag = "")
#foreach ($issue in $issueType.issues)
#set ($customFields = $customFieldManager.getCustomFieldObjects($issue.project.getLong("id"), $issue.issueType.getString("id")))
#foreach($customField in $customFields)
#if($customField.name.equals("For Release Notes"))
#if($customField.getValue($issue))
#if($flag==$textUtils.htmlEncode($issueType.name))
#else
<h2>$textUtils.htmlEncode($issueType.name)</h2>
#set($flag = $textUtils.htmlEncode($issueType.name))
#end
#end
#end
#end
#end
## Go through the list again, displaying all issues that are "for release notes."
<ul>
#foreach ($issue in $issueType.issues)
#set ($customFields = $customFieldManager.getCustomFieldObjects($issue.project.getLong("id"), $issue.issueType.getString("id")))
#foreach($customField in $customFields)
#if($customField.name.equals("For Release Notes"))
#if($customField.getValue($issue))
## If the issue has the "Release Note" field set, use that, otherwise use the summary
#foreach($customField in $customFields)
#if($customField.name.equals("Release Note"))
#if($customField.getValue($issue))
<li>[<a href='$requestContext.canonicalBaseUrl/browse/$issue.key'>$issue.key</a>] - $textUtils.htmlEncode($customField.getValue($issue))</li>
#else
<li>[<a href='$requestContext.canonicalBaseUrl/browse/$issue.key'>$issue.key</a>] - $textUtils.htmlEncode($issue.summary)</li>
#end
#end
#end
#end
#end
#end
#end
</ul>
#end
http://velocity.apache.org/engine/devel/vtl-reference-guide.html has some examples of conditions in Velocity, and as you found out, they're not entirely obvious.
Create the following macro and simply call it from whatever place in your vm file where you want to include the issue summary.
#macro( myMacro )
#set( $customFieldObj = $customFieldManager.getCustomFieldObjectByName('For Release Notes') )
#set( $customFieldValue = $issue.getCustomFieldValue($customFieldObj) )
## next line only makes sure the 2 variables are not null
#if( $customFieldObj && $customFieldValue )
## now output the issue summary
$issue.getSummary()
#end
#end
According to the API, getCustomFieldObjectByName will return the 1st custom field object with the give name, so if you have more than one custom field called 'For Release Notes', you wanna try the method getCustomFieldObject and pass the Long id of the field as a parameter.

how to write dsl condition with null check

we have .dsl file with below entry
[condition][]residence duration >\= {value}=FamilyMember(basicInfo.permanentResidenceDuration >= {value})
Now this basicInfo.permanentResidenceDuration is coming out to be null in beginning. Can anyboy help me out how to write the state which satisfy the following condition. If basicInfo.permanentResidenceDuration == null assign 0 else the value of basicInfo.permanentResidenceDuration
Not sure I understand what you need, but why not simply do something like this?
[condition][]residence duration >\= {value}=FamilyMember(basicInfo.permanentResidenceDuration != null && >= {value})

Resources