summaryrefslogtreecommitdiff
path: root/nlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/knowledge/SearchPoint.java
blob: ea37e1e5cd0b3cacdd53a6252b62d0da5da0c353 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
/**
 * Description: provide the location and encoded goodness information
 *
 * Author          Create/Modi     Note
 * Xiaofeng Xie    Mar 1, 2003
 * Xiaofeng Xie    May 11, 2004
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * Please acknowledge the author(s) if you use this code in any way.
 */
package net.adaptivebox.knowledge;

import net.adaptivebox.global.*;
import net.adaptivebox.space.*;
import net.adaptivebox.encode.*;

public class SearchPoint extends BasicPoint implements IEncodeEngine {
  //store the encode information for goodness evaluation
  //encodeInfo[0]: the sum of constraints (if it equals to 0, then be a feasible point)
  //encodeInfo[1]: the value of objective function
  private double[] encodeInfo = new double[2];
  private double objectiveValue;

  public SearchPoint(int dim) {
    super(dim);
    for(int i=0; i<encodeInfo.length; i++) {
      encodeInfo[i] = BasicBound.MAXDOUBLE;
    }
  }

  public double[] getEncodeInfo() {
    return encodeInfo;
  }

  private void importEncodeInfo(double[] info) {
    System.arraycopy(info, 0, encodeInfo, 0, encodeInfo.length);
  }

  private void importEncodeInfo(IEncodeEngine point) {
    importEncodeInfo(point.getEncodeInfo());
  }

  //Replace self by given point
  public void importPoint(SearchPoint point) {
    importLocation(point);
    importEncodeInfo(point);
    setObjectiveValue(point.getObjectiveValue());
  }

  public double getObjectiveValue() {
      return objectiveValue;
  }

  public void setObjectiveValue(double objectiveValue) {
      this.objectiveValue = objectiveValue;
  }

  public boolean isFeasible() {
      return encodeInfo[0] == 0; //no constraint violations
  }


}