tdf#149907: sc: Add UItest
[LibreOffice.git] / nlpsolver / ThirdParty / EvolutionarySolver / src / net / adaptivebox / goodness / BCHComparator.java
blob8140650dd6e173fd44380157fbe6da37e46cafed
1 /**
2 * Description: For formation the basic goodness landscape.
4 * Author Create/Modi Note
5 * Xiaofeng Xie Jun 24, 2003 Created
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.
20 * @version 1.0
21 * @Since MAOS1.2
23 * [1] Deb K. An efficient constraint handling method for genetic algorithms.
24 * Computer Methods in Applied Mechanics and Engineering, 2000, 186(2-4): 311-338
27 package net.adaptivebox.goodness;
29 public class BCHComparator implements IGoodnessCompareEngine {
31 /* check the magnitude of two array, the frontal is more important */
32 private static int compareArray(double[] fit1, double[] fit2) {
33 for (int i = 0; i < fit1.length; i++) {
34 if (fit1[i] > fit2[i]) {
35 return LARGER_THAN; // Large than
36 } else if (fit1[i] < fit2[i]) {
37 return LESS_THAN; // Less than
40 return IGoodnessCompareEngine.EQUAL_TO; // same
43 public int compare(double[] fit1, double[] fit2) {
44 return compareArray(fit1, fit2);