public final double doOperation() throws OperatorFailedException {
  final int dim=parameter.getDimension();
  final int dim1=MathUtils.nextInt(dim);
  int dim2=dim1;
  while (dim1 == dim2) {
    dim2=MathUtils.nextInt(dim);
  }
  double scalar1=parameter.getParameterValue(dim1);
  double scalar2=parameter.getParameterValue(dim2);
  if (isIntegerOperator) {
    int d=MathUtils.nextInt((int)Math.round(delta)) + 1;
    if (parameterWeights[dim1] != parameterWeights[dim2])     throw new RuntimeException();
    scalar1=Math.round(scalar1 - d);
    scalar2=Math.round(scalar2 + d);
  }
 else {
    final double d=MathUtils.nextDouble() * delta;
    scalar1-=d;
    if (parameterWeights[dim1] != parameterWeights[dim2]) {
      scalar2+=d * (double)parameterWeights[dim1] / (double)parameterWeights[dim2];
    }
 else {
      scalar2+=d;
    }
  }
  Bounds<Double> bounds=parameter.getBounds();
  if (scalar1 < bounds.getLowerLimit(dim1) || scalar1 > bounds.getUpperLimit(dim1) || scalar2 < bounds.getLowerLimit(dim2) || scalar2 > bounds.getUpperLimit(dim2)) {
    throw new OperatorFailedException("proposed values out of range!");
  }
  parameter.setParameterValue(dim1,scalar1);
  parameter.setParameterValue(dim2,scalar2);
  return 0.0;
}

public final double doOperation ( ) throws OperatorFailedException { final int dim = parameter . getDimension ( ) ; final int dim1 = MathUtils . nextInt ( dim ) ; int dim2 = dim1 ; while ( dim1 == dim2 ) { dim2 = MathUtils . nextInt ( dim ) ; } double scalar1 = parameter . getParameterValue ( dim1 ) ; double scalar2 = parameter . getParameterValue ( dim2 ) ; if ( isIntegerOperator ) { int d = MathUtils . nextInt ( ( int ) Math . round ( delta ) ) + 1 ; if ( parameterWeights [ dim1 ] != parameterWeights [ dim2 ] ) throw new RuntimeException ( ) ; scalar1 = Math . round ( scalar1 - d ) ; scalar2 = Math . round ( scalar2 + d ) ; } else { final double d = MathUtils . nextDouble ( ) * delta ; scalar1 -= d ; if ( parameterWeights [ dim1 ] != parameterWeights [ dim2 ] ) { scalar2 += d * ( double ) parameterWeights [ dim1 ] / ( double ) parameterWeights [ dim2 ] ; } else { scalar2 += d ; } } Bounds < Double > bounds = parameter . getBounds ( ) ; if ( scalar1 < bounds . getLowerLimit ( dim1 ) || scalar1 > bounds . getUpperLimit ( dim1 ) || scalar2 < bounds . getLowerLimit ( dim2 ) || scalar2 > bounds . getUpperLimit ( dim2 ) ) { throw new OperatorFailedException ( "proposed values out of range!" ) ; } parameter . setParameterValue ( dim1 , scalar1 ) ; parameter . setParameterValue ( dim2 , scalar2 ) ; return 0.0 ; }
change the parameter and return the hastings ratio . performs a delta exchange operation between two scalars in the vector and return the hastings ratio .
