2 * Description: provide the location and encoded goodness information
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.
20 package net
.adaptivebox
.knowledge
;
22 import net
.adaptivebox
.encode
.IEncodeEngine
;
23 import net
.adaptivebox
.global
.BasicBound
;
24 import net
.adaptivebox
.space
.BasicPoint
;
26 public class SearchPoint
extends BasicPoint
implements IEncodeEngine
{
27 // store the encode information for goodness evaluation
28 // encodeInfo[0]: the sum of constraints (if it equals to 0, then be a feasible point)
29 // encodeInfo[1]: the value of objective function
30 private final double[] encodeInfo
= new double[2];
31 private double objectiveValue
;
33 public SearchPoint(int dim
) {
35 for (int i
= 0; i
< encodeInfo
.length
; i
++) {
36 encodeInfo
[i
] = BasicBound
.MAXDOUBLE
;
40 public double[] getEncodeInfo() {
44 private void importEncodeInfo(double[] info
) {
45 System
.arraycopy(info
, 0, encodeInfo
, 0, encodeInfo
.length
);
48 private void importEncodeInfo(IEncodeEngine point
) {
49 importEncodeInfo(point
.getEncodeInfo());
52 // Replace self by given point
53 public void importPoint(SearchPoint point
) {
54 importLocation(point
);
55 importEncodeInfo(point
);
56 setObjectiveValue(point
.getObjectiveValue());
59 public double getObjectiveValue() {
60 return objectiveValue
;
63 public void setObjectiveValue(double objectiveValue
) {
64 this.objectiveValue
= objectiveValue
;
67 public boolean isFeasible() {
68 return encodeInfo
[0] == 0; // no constraint violations