bump product version to 4.1.6.2
[LibreOffice.git] / nlpsolver / ThirdParty / EvolutionarySolver / src / net / adaptivebox / encode / EvalElement.java
blob82e4073ee4e86db9046cdd22dae5578759818a44
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.*;
25 public class EvalElement {
27 //The weight for each response (target)
28 public double weight = 1;
29 /**
30 * The expected range of the response value, forms the following objective:
32 * NO minValue maxValue : THE ELEMENT OF BasicBound
33 * 1 MINDOUBLE, MINDOUBLE: the minimize objective
34 * 2 MAXDOUBLE, MAXDOUBLE: the maximize objective
35 * 3 MINDOUBLE, v : the lessthan constraint (<v)
36 * 4 v , MAXDOUBLE: the largethan constraint (>v)
37 * 5 v1 , v2 : the region constraint, i.e. belongs to [v1, v2]
39 * OPTIM type: the No.1 and No.2
40 * CONS type: the last three
43 public BasicBound targetBound = new BasicBound();
45 public EvalElement() {};
47 public boolean isOptType() {
48 return ((targetBound.minValue==BasicBound.MINDOUBLE&&targetBound.maxValue==BasicBound.MINDOUBLE)||
49 (targetBound.minValue==BasicBound.MAXDOUBLE&&targetBound.maxValue==BasicBound.MAXDOUBLE));
52 public double evaluateCONS(double targetValue) {
53 if(targetValue<targetBound.minValue) {
54 return weight*(targetBound.minValue-targetValue);
56 if(targetValue>targetBound.maxValue) {
57 return weight*(targetValue-targetBound.maxValue);
59 return 0;
62 public double evaluateOPTIM(double targetValue) {
63 if(targetBound.maxValue==BasicBound.MINDOUBLE) { //min mode
64 return weight*targetValue;
65 } else { //max
66 return -weight*targetValue;