Projects >> open-tracking-tools >>a59a604bf4f81dc374893b828ddbb0dc9ac72570

Chunk
Conflicting content
      this.domain = Sets.newHashSet();
      if (this.currentEdge.isNullEdge()) {
        final Vector currentLocation =
<<<<<<< HEAD
            MotionStateEstimatorPredictor.Og.times(this.currentMotionState);
        /*
         * When the observation covariance is set to null,
         * the snapping used reflects an intersection through
         * the movement. 
         */
        Collection snappedSegments;
        if (this.obsCovariance != null) {
          final double radius =
              StatisticsUtil
                  .getLargeNormalCovRadius(this.obsCovariance);
          snappedSegments = this.graph.getNearbyEdges(currentLocation, radius);
        } else {
//          final Vector prevLocation =
//            MotionStateEstimatorPredictor.Og.times(this.initialMotionState);
          snappedSegments = this.graph.getTransferEdges(this.currentMotionState, 
              this.initialMotionState); 
        }
        for (final InferenceGraphSegment line : snappedSegments) {
=======
            MotionStateEstimatorPredictor.Og.times(this.motionState);
        final double radius =
            ExtStatisticsUtils
                .getLargeNormalCovRadius(this.obsCovariance);
        for (final InferenceGraphSegment line : this.graph
            .getNearbyEdges(currentLocation, radius)) {
>>>>>>> 5dc42c8383471f2d958e551871142e409cb7e710
          this.domain.add(line);
        }
        // add the off-road possibility
Solution content
      this.domain = Sets.newHashSet();
      if (this.currentEdge.isNullEdge()) {
        final Vector currentLocation =
            MotionStateEstimatorPredictor.Og.times(this.motionState);
        final double radius =
            ExtStatisticsUtils
                .getLargeNormalCovRadius(this.obsCovariance);
        for (final InferenceGraphSegment line : this.graph
            .getNearbyEdges(currentLocation, radius)) {
          this.domain.add(line);
        }
        // add the off-road possibility
File
OnOffEdgeTransDistribution.java
Developer's decision
Version 2
Kind of conflict
Comment
For statement
If statement
Method invocation
Variable
Chunk
Conflicting content
import gov.sandia.cognition.math.signals.LinearDynamicalSystem;
import gov.sandia.cognition.statistics.bayesian.KalmanFilter;
import gov.sandia.cognition.statistics.distribution.MultivariateGaussian;
<<<<<<< HEAD
import gov.sandia.cognition.util.ObjectUtil;
import no.uib.cipr.matrix.DenseMatrix;
import no.uib.cipr.matrix.DenseVector;
import no.uib.cipr.matrix.UpperSPDDenseMatrix;
=======
import no.uib.cipr.matrix.DenseMatrix;
import no.uib.cipr.matrix.UpperSymmBandMatrix;
>>>>>>> 5dc42c8383471f2d958e551871142e409cb7e710

import org.opentrackingtools.distributions.TruncatedRoadGaussian;
Solution content
import gov.sandia.cognition.math.signals.LinearDynamicalSystem;
import gov.sandia.cognition.statistics.bayesian.KalmanFilter;
import gov.sandia.cognition.statistics.distribution.MultivariateGaussian;
import no.uib.cipr.matrix.DenseMatrix;
import no.uib.cipr.matrix.UpperSymmBandMatrix;

import org.opentrackingtools.distributions.TruncatedRoadGaussian;
File
TruncatedRoadKalmanFilter.java
Developer's decision
Version 2
Kind of conflict
Import
Chunk
Conflicting content
  @Override
  }

  @Override
<<<<<<< HEAD
  public AdjMultivariateGaussian createInitialLearnedObject() {
    return new TruncatedRoadGaussian(this.model.getState().clone(),
        this.modelCovariance);
  }

  public boolean equals(Object obj) {
    if (this == obj) {
      return true;
    }
    if (obj == null) {
      return false;
    }
    if (this.getClass() != obj.getClass()) {
      return false;
    }
    final TruncatedRoadKalmanFilter other =
        (TruncatedRoadKalmanFilter) obj;
    if (this.model == null) {
      if (other.model != null) {
        return false;
      }
    } else if (!StatisticsUtil.vectorEquals(
        this.model.convertToVector(), other.model.convertToVector())) {
      return false;
    }
    return true;
  }

  public SvdMatrix getMeasurementCovariance() {
    return this.measurementCovariance;
  }

  /**
   * Getter for model
   * 
   * @return Motion model of the underlying system.
   */
  public LinearDynamicalSystem getModel() {
    return this.model;
  }

  public SvdMatrix getModelCovariance() {
    return this.modelCovariance;
  }

  @Override
  public int hashCode() {
    final int prime = 31;
    int result = super.hashCode();
    result =
        prime
            * result
            + ((this.model == null) ? 0 : StatisticsUtil
                .hashCodeVector(this.model.convertToVector()));
    return result;
  }

  public void
      measure(MultivariateGaussian belief, Vector observation) {
    
    measure_old(belief, observation);
    
    final SvdMatrix covar = new SvdMatrix(belief.getCovariance());
    final AbstractSingularValueDecomposition svd =
        covar.getSvd();
    if (belief.getInputDimensionality() == 2) {
      svd.getS().setElement(1, 1, 0d);
    } else {
      svd.getS().setElement(1, 1, 0d);
      svd.getS().setElement(2, 2, 0d);
    }
    final SvdMatrix newCovar =
        new SvdMatrix(new SimpleSingularValueDecomposition(
            svd.getU(), svd.getS(), svd.getU().transpose()));

    belief.setCovariance(newCovar);

  }
  
  public void measure_old(MultivariateGaussian belief, Vector observation) {
    
    final Matrix F = this.model.getC();
    final Vector a = belief.getMean();
    final Matrix R = belief.getCovariance();
    final Matrix Q2 =
        F.times(R).times(F.transpose())
            .plus(this.getMeasurementCovariance());
    /*
     * This is the source of one major improvement:
     * uses the solve routine for a positive definite matrix
     */
    final UpperSPDDenseMatrix Qspd =
        new UpperSPDDenseMatrix(
            ((AbstractMTJMatrix) Q2).getInternalMatrix(), false);
    final no.uib.cipr.matrix.Matrix CRt =
        ((AbstractMTJMatrix) F.times(R.transpose()))
            .getInternalMatrix();

    final DenseMatrix Amtj =
        new DenseMatrix(Qspd.numRows(), CRt.numColumns());
    Qspd.transSolve(CRt, Amtj);

    final DenseMatrix AtQt =
        new DenseMatrix(Amtj.numColumns(), Qspd.numRows());
    Amtj.transABmult(Qspd, AtQt);

    final DenseMatrix AtQtAMtj =
        new DenseMatrix(AtQt.numRows(), Amtj.numColumns());
    AtQt.mult(Amtj, AtQtAMtj);

    final Matrix AtQtA =
        ((DenseMatrixFactoryMTJ) MatrixFactory.getDenseDefault())
            .createWrapper(AtQtAMtj);

    final DenseVector e2 =
        new DenseVector(
            ((gov.sandia.cognition.math.matrix.mtj.DenseVector) observation
                .minus(F.times(a))).getArray(), false);

    final DenseVector AteMtj = new DenseVector(Amtj.numColumns());
    Amtj.transMult(e2, AteMtj);
    final Vector Ate =
        ((DenseVectorFactoryMTJ) VectorFactory.getDenseDefault())
            .createWrapper(AteMtj);

    final Matrix CC = R.minus(AtQtA);
    final Vector m = a.plus(Ate);

    belief.setCovariance(CC);
    belief.setMean(m);
=======
  public void
      measure(MultivariateGaussian belief, Vector observation) {
//    DlmUtils.svdForwardFilter(observation, belief, this);
    DlmUtils.schurForwardFilter(observation, belief, this);
    // TODO FIXME: hack for a numerical issue
    if (!belief.getCovariance().isSymmetric()) {
      UpperSymmBandMatrix symmat = new UpperSymmBandMatrix(
          ((AbstractMTJMatrix) belief.getCovariance()).getInternalMatrix(), 
          belief.getInputDimensionality());
      belief.setCovariance(((DenseMatrixFactoryMTJ) MatrixFactory.getDenseDefault())
          .createWrapper(new DenseMatrix(symmat)));
    }
//    super.measure(belief, observation);
>>>>>>> 5dc42c8383471f2d958e551871142e409cb7e710
  }

  @Override
Solution content
  }

  @Override
  public void
      measure(MultivariateGaussian belief, Vector observation) {
//    DlmUtils.svdForwardFilter(observation, belief, this);
    DlmUtils.schurForwardFilter(observation, belief, this);
    // TODO FIXME: hack for a numerical issue
    if (!belief.getCovariance().isSymmetric()) {
      UpperSymmBandMatrix symmat = new UpperSymmBandMatrix(
          ((AbstractMTJMatrix) belief.getCovariance()).getInternalMatrix(), 
          belief.getInputDimensionality());
      belief.setCovariance(((DenseMatrixFactoryMTJ) MatrixFactory.getDenseDefault())
          .createWrapper(new DenseMatrix(symmat)));
    }
//    super.measure(belief, observation);
  }

  @Override
File
TruncatedRoadKalmanFilter.java
Developer's decision
Version 2
Kind of conflict
Annotation
Comment
If statement
Method declaration
Method invocation
Method signature
Variable
Chunk
Conflicting content
    final MultivariateGaussian obsDist =
        motionStatePredictor.getObservationDistribution(
            predictedMotionState, newPathState.getEdge());
<<<<<<< HEAD
    updatedState.setMotionStateParam(
        SimpleBayesianParameter.create(obsDist.getMean(),
            obsDist, 
            /*
             * Important: we need the motion state prior to be relative to the edge it's
             * on, otherwise, distance along path will add up indefinitely. 
             */
              newEdgePathStateDist));
    

    final MultivariateGaussian newPathStateDist = 
            new TruncatedRoadGaussian(newPathState.getMotionState(),
                 newMotionCov);
    updatedState.setPathStateParam(
        SimpleBayesianParameter.
          create(newPathState, null, 
            new PathStateDistribution(newPathState.getPath(), 
                newPathStateDist)));

=======
    updatedState.getMotionStateParam().setValue(obsDist.getMean());
    updatedState.getMotionStateParam().setConditionalDistribution(
        obsDist);
    /*
     * Important: we need the motion state prior to be relative to the edge it's
     * on, otherwise, distance along path will add up indefinitely. 
     */
    updatedState.getMotionStateParam().setParameterPrior(
        new TruncatedRoadGaussian(newPathState.getEdgeState(),
            (SvdMatrix)(newPathState.isOnRoad() ? motionStatePredictor
                .getRoadFilter().getModelCovariance()
                : motionStatePredictor.getGroundFilter()
                    .getModelCovariance())));

    updatedState.getPathStateParam().setValue(newPathState);
>>>>>>> 5dc42c8383471f2d958e551871142e409cb7e710
    updatedState.setParentState(previousState);
    
    updatedState.setEdgeTransitionParam(
Solution content
    final MultivariateGaussian obsDist =
        motionStatePredictor.getObservationDistribution(
            predictedMotionState, newPathState.getEdge());
    updatedState.getMotionStateParam().setValue(obsDist.getMean());
    updatedState.getMotionStateParam().setConditionalDistribution(
        obsDist);
    /*
     * Important: we need the motion state prior to be relative to the edge it's
     * on, otherwise, distance along path will add up indefinitely. 
     */
    updatedState.getMotionStateParam().setParameterPrior(
        new TruncatedRoadGaussian(newPathState.getEdgeState(),
            (SvdMatrix)(newPathState.isOnRoad() ? motionStatePredictor
                .getRoadFilter().getModelCovariance()
                : motionStatePredictor.getGroundFilter()
                    .getModelCovariance())));

    updatedState.getPathStateParam().setValue(newPathState);
    updatedState.setParentState(previousState);
    
    updatedState.setEdgeTransitionParam(
File
VehicleStateBootstrapUpdater.java
Developer's decision
Version 2
Kind of conflict
Comment
Method invocation
Variable
Chunk
Conflicting content
          motionStateEstimatorPredictor.getObservationDistribution(
              projectedDist, PathEdge.nullPathEdge);
      final double beliefDistance =
<<<<<<< HEAD
         this.parameters.getObsCovarianceThreshold() == null ?
          StatisticsUtil.getLargeNormalCovRadius(obsDist.getCovariance())
                            : Math.min(StatisticsUtil.getLargeNormalCovRadius(
                                obsDist .getCovariance()), 
                                this.parameters.getObsCovarianceThreshold());
=======
          Math.min(
              ExtStatisticsUtils.getLargeNormalCovRadius(obsDist
                  .getCovariance()),
              this.parameters.getObsCovarianceThreshold());
>>>>>>> 5dc42c8383471f2d958e551871142e409cb7e710

      /*
       * Simply stay off-road and move forward
Solution content
          motionStateEstimatorPredictor.getObservationDistribution(
              projectedDist, PathEdge.nullPathEdge);
      final double beliefDistance =
         this.parameters.getObsCovarianceThreshold() == null ?
          StatisticsUtil.getLargeNormalCovRadius(obsDist.getCovariance())
                            : Math.min(StatisticsUtil.getLargeNormalCovRadius(
                                obsDist .getCovariance()), 
                                this.parameters.getObsCovarianceThreshold());

      /*
       * Simply stay off-road and move forward
File
VehicleStatePLPathSamplingUpdater.java
Developer's decision
Version 1
Kind of conflict
Method invocation
Chunk
Conflicting content
import com.vividsolutions.jts.geom.LineString;

/**
<<<<<<< HEAD:open-tracking-tools-api/src/test/java/org/opentrackingtools/VehicleStatePLPathSamplingFilterSimulationTest.java
 * This is basically a full integration test that runs the bootstrap simulator 
 * to produce observations, then fits those observations with the PL filter.  
 * The test conditions are that the fitted values lie within certain credible 
 * intervals of the true distributions.
 * 
 * @author bwillard
 *
 */
public class VehicleStatePLPathSamplingFilterSimulationTest {

  static final double[] fourZeros =
=======
 * Tests the PL filter on a graph consisting of a 100m x 100m
 * square.
 * 
 * @author bwillar0
 *
 */
public class VehicleStatePLFilterSimulationTest {

  private static final double[] fourZeros =
>>>>>>> 5dc42c8383471f2d958e551871142e409cb7e710:open-tracking-tools-api/src/test/java/org/opentrackingtools/VehicleStatePLFilterSimulationTest.java
      new double[] { 0, 0, 0, 0 };

  private static final double[] oneZero = new double[] { 0 };
Solution content
import com.vividsolutions.jts.geom.LineString;

 * Tests the PL filter on a graph consisting of a 100m x 100m
 * square.
 * 
 * @author bwillar0
 *
 */
public class VehicleStatePLFilterSimulationTest {

  private static final double[] fourZeros =
      new double[] { 0, 0, 0, 0 };

  private static final double[] oneZero = new double[] { 0 };
File
VehicleStatePLPathSamplingFilterSimulationTest.java
Developer's decision
Version 2
Kind of conflict
Attribute
Class signature
Comment