How to test constraint streams with impact(...) result?

38 views
Skip to first unread message

Frank Förster

unread,
Jan 20, 2022, 6:09:09 AMJan 20
to OptaPlanner development
Hi Optaplanners,
I have to use the impact() method as a constraint stream result to create soft scores because the score value is given from an external system an can be both, negative and positive - Works fine!
Unfortunately I can not unit test this stream with the ConstraintVerifier, no method impactedWith(...) is available. If I use rewardsWith() to test an impact of +1 I get an AssertionError:
   Expected reward: 1 (class java.lang.Integer)
     Actual impact: 1 (class java.lang.Integer)


Is there a way to test this or does anybody knows if it is planned to extend the verifier for impacts or to allow impact tests with rewardsWith()?

Thanks in advance,
Frank

Lukáš Petrovický

unread,
Jan 20, 2022, 6:52:45 AMJan 20
to optapla...@googlegroups.com
Frank,

On Thu, Jan 20, 2022 at 12:09 PM Frank Förster <fft...@gmail.com> wrote:
Is there a way to test this or does anybody knows if it is planned to extend the verifier for impacts or to allow impact tests with rewardsWith()?

are you using the latest version of OptaPlanner? I vaguely recall we fixed an issue with these symptoms a couple months ago.
 
--

Lukáš Petrovický

He/Him/His

Principal Software Engineer, Business Automation

lukas.pe...@redhat.com    IM: triceo/lpetrovi

My work week is Monday to Thursday.

Frank Förster

unread,
Jan 20, 2022, 8:05:59 AMJan 20
to OptaPlanner development
Hi Lukáš,
thanks for your fast reply.
Currently we work with version 8.9.1 because we have to use a JRE 8 yet.
But we plan to switch to JRE 11, and after hearing your good news about the constraint testing I will force this change to be able to update the OptaPlanner  :-)

Many thanks,
Frank

Lukáš Petrovický

unread,
Jan 20, 2022, 8:48:41 AMJan 20
to optapla...@googlegroups.com
On Thu, Jan 20, 2022 at 2:06 PM Frank Förster <fft...@gmail.com> wrote:
But we plan to switch to JRE 11, and after hearing your good news about the constraint testing I will force this change to be able to update the OptaPlanner  :-)

Good plan. I think that with 8.9, you just missed the cut-off on that issue:
 

徐广

unread,
May 25, 2022, 9:02:05 PMMay 25
to OptaPlanner development
Is this really fixed? I tried to test impact giving result as -3000 by penalty(3000)  and it gave a failure, and if I change to reward(3000) it succeeded. 
I am confused, so impact(-3000) = reward(3000) ? 
Reply all
Reply to author
Forward
0 new messages