printGHK(ghk);
}
private void adjustValues(ContinuousNode continuousNode, double d,ContinuousNode currentNode) {
Matrix hx = null,hy = null,kxx = null,kxy = null,kyy = null;
double g;
HComponent hc = new HComponent();
KComponent kc = new KComponent();
if(hasNoParents(continuousNode)){ // special case when it is a root node
Matrix h = new Matrix(continuousNode.getGHK().getGhkPot().getH().gethMatrix());
Matrix k = new Matrix(continuousNode.getGHK().getGhkPot().getK().getkMatrix());
g = continuousNode.getGHK().getGhkPot().getG() + h.transpose().times(d).det() - (k.times(d).times(d).times(0.5)).det();
continuousNode.getGHK().getGhkPot().setG(g);
double[][] hMat = new double[1][1];
hMat[0][0]=0;
hc.sethMatrix(hMat);
continuousNode.getGHK().getGhkPot().setH(hc);
double[][] kMat = new double[1][1];
kMat[0][0]=0;
kc.setkMatrix(kMat);
continuousNode.getGHK().getGhkPot().setK(kc);
return;
}
if(continuousNode.getGHK().hasNoDescreteStates){
GHKPotential ghk = new GHKPotential();
hx = new Matrix(getHX(currentNode.getGHK().getGhkPot().getH().gethMatrix(),currentNode.getGHK(),continuousNode));
hy = new Matrix(getHy(currentNode.getGHK().getGhkPot().getH().gethMatrix(),currentNode.getGHK(),continuousNode));
kxx = new Matrix(getKXX(currentNode.getGHK().getGhkPot().getK().getkMatrix(),currentNode.getGHK(),continuousNode));
kxy = new Matrix(getKXY(currentNode.getGHK().getGhkPot().getK().getkMatrix(),currentNode.getGHK(),continuousNode));
kyy = new Matrix(getKYY(currentNode.getGHK().getGhkPot().getK().getkMatrix(),currentNode.getGHK(),continuousNode));
g = currentNode.getGHK().getGhkPot().getG() + hy.transpose().times(d).det() - (kyy.times(Math.pow(d, 2)).times(0.5)).det();
ghk.setG(g);
hc = new HComponent();
hc.sethMatrix(extendAndOPMatrices(hx.getArray(),kxy.times(d).getArray(), MINUS_OPERATOR));
ghk.setH(hc);
kc = new KComponent();
kc.setkMatrix(kxx.getArray());
ghk.setK(kc);
currentNode.getGHK().setGhkPot(ghk);
}else{
for(int i=0;i<currentNode.getGHK().tableSize();i++){
hc = new HComponent();
kc = new KComponent();
hx = new Matrix(getHX(currentNode.getGHK().getHValue(i).gethMatrix(),currentNode.getGHK(),continuousNode));
hy = new Matrix(getHy(currentNode.getGHK().getHValue(i).gethMatrix(),currentNode.getGHK(),continuousNode));
kxx = new Matrix(getKXX(currentNode.getGHK().getKValue(i).getkMatrix(),currentNode.getGHK(),continuousNode));
kxy = new Matrix(getKXY(currentNode.getGHK().getKValue(i).getkMatrix(),currentNode.getGHK(),continuousNode));
kyy = new Matrix(getKYY(currentNode.getGHK().getKValue(i).getkMatrix(),currentNode.getGHK(),continuousNode));
g = currentNode.getGHK().getGValue(i)+ hy.transpose().times(d).det() - (kyy.times(Math.pow(d, 2)).times(0.5)).det();
currentNode.getGHK().setGValue(i, g);
hc = new HComponent();