Minor fix in GPFunctionProblem.
This commit is contained in:
parent
29f2a0d771
commit
4ba48274e7
@ -83,7 +83,10 @@ public class GPFunctionProblem extends AbstractProblemDouble implements Interfac
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public double[] eval(double[] x) {
|
public double[] eval(double[] x) {
|
||||||
if (x.length != dim) EVAERROR.errorMsgOnce("mismatching dimension of GPFunctionProblem!");
|
if (x.length != dim) {
|
||||||
|
EVAERROR.errorMsgOnce("mismatching dimension of GPFunctionProblem! Setting to " + x.length);
|
||||||
|
setProblemDimension(x.length);
|
||||||
|
}
|
||||||
pos = x;
|
pos = x;
|
||||||
Double res = (Double) gpProblem.evaluate(this);
|
Double res = (Double) gpProblem.evaluate(this);
|
||||||
double[] fit = new double[1];
|
double[] fit = new double[1];
|
||||||
@ -91,6 +94,16 @@ public class GPFunctionProblem extends AbstractProblemDouble implements Interfac
|
|||||||
return fit;
|
return fit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the problem dimension. Make sure that the associated GP tree is still valid
|
||||||
|
* and does not explicitely use more dimensions than defined here, for instance.
|
||||||
|
* @param newDim
|
||||||
|
*/
|
||||||
|
public void setProblemDimension(int newDim) {
|
||||||
|
dim = newDim;
|
||||||
|
((ESIndividualDoubleData)m_Template).setDoubleDataLength(dim);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Scale the allover fitness value.
|
* Scale the allover fitness value.
|
||||||
*
|
*
|
||||||
|
Loading…
x
Reference in New Issue
Block a user