tdf#149907: sc: Add UItest
[LibreOffice.git] / nlpsolver / ThirdParty / EvolutionarySolver / src / net / adaptivebox / encode / EvalElement.java
blob85e50c9f97f8a176d698a900181a24b12622fa29
1 /**
2 * Description: provide the information for evaluating of a response (target)
4 * Author Create/Modi Note
5 * Xiaofeng Xie Mar 1, 2003
6 * Xiaofeng Xie May 11, 2004
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
18 * Please acknowledge the author(s) if you use this code in any way.
21 package net.adaptivebox.encode;
23 import net.adaptivebox.global.BasicBound;
25 public class EvalElement {
27 // The weight for each response (target)
28 private static final double weight = 1;
29 /**
30 * The expected range of the response value, forms the following objective:
32 * <pre>
33 * NO minValue maxValue : THE ELEMENT OF BasicBound
34 * 1 MINDOUBLE, MINDOUBLE: the minimize objective
35 * 2 MAXDOUBLE, MAXDOUBLE: the maximize objective
36 * 3 MINDOUBLE, v : the less than constraint {@literal (<v)}
37 * 4 v , MAXDOUBLE: the larger than constraint {@literal (>v)}
38 * 5 v1 , v2 : the region constraint, i.e. belongs to [v1, v2]
40 * OPTIM type: the No.1 and No.2
41 * CONS type: the last three
42 * </pre>
44 public BasicBound targetBound = new BasicBound();
46 public boolean isOptType() {
47 return ((targetBound.minValue == BasicBound.MINDOUBLE && targetBound.maxValue == BasicBound.MINDOUBLE)
48 || (targetBound.minValue == BasicBound.MAXDOUBLE && targetBound.maxValue == BasicBound.MAXDOUBLE));
51 public double evaluateCONS(double targetValue) {
52 if (targetValue < targetBound.minValue) {
53 return weight * (targetBound.minValue - targetValue);
55 if (targetValue > targetBound.maxValue) {
56 return weight * (targetValue - targetBound.maxValue);
58 return 0;
61 public double evaluateOPTIM(double targetValue) {
62 if (targetBound.maxValue == BasicBound.MINDOUBLE) { // min mode
63 return weight * targetValue;
64 } else { // max
65 return -weight * targetValue;