### Question:
GradientOptimizer implements Optimizer { @Override public OptimizedResult maxAPosteriori() { return optimize(ProbabilityFitness.MAP); }  static GradientOptimizerBuilder builder(); void addGradientCalculationHandler(BiConsumer<Map<VariableReference, DoubleTensor>, Map<? extends VariableReference, DoubleTensor>> gradientCalculationHandler); void removeGradientCalculationHandler(BiConsumer<Map<VariableReference, DoubleTensor>, Map<? extends VariableReference, DoubleTensor>> gradientCalculationHandler); @Override void addFitnessCalculationHandler(BiConsumer<Map<VariableReference, DoubleTensor>, Double> fitnessCalculationHandler); @Override void removeFitnessCalculationHandler(BiConsumer<Map<VariableReference, DoubleTensor>, Double> fitnessCalculationHandler); @Override OptimizedResult maxAPosteriori(); @Override OptimizedResult maxLikelihood();  }### Answer:
@Test public void shouldAllowObservationChange() { GaussianVertex A = new GaussianVertex(0, 1); GaussianVertex B = new GaussianVertex(A.abs(), 1); A.observe(2.0); GradientOptimizer optimizer = Keanu.Optimizer.Gradient.ofConnectedGraph(B); optimizer.maxAPosteriori(); assertEquals(2.0, B.getValue().scalar(), 1e-5); A.observe(3.0); GradientOptimizer optimizerAfterObserve = Keanu.Optimizer.Gradient.ofConnectedGraph(B); optimizerAfterObserve.maxAPosteriori(); assertEquals(3.0, B.getValue().scalar(), 1e-5); }