Class LinearTernaryCoreFloat

    • Method Detail

      • permute

        public void permute​(int[] permutation)
        Reorganize our already-seen state as if the variables had shifted order underneath us (rearrangement given by the permutation).
      • isActive

        @Pure
        public boolean isActive​(@GuardSatisfied LinearTernaryCoreFloat this)
        Returns whether or not the invariant is currently active. We become active after MINTRIPLES values have been seen and a line is not calculated. In addition, the coefficients (a, b, c) must all be non-zero, else the invariant would be described by a LinearBinary or constant invariant. Before that, a, b, and c are uninitialized.
      • setup

        public InvariantStatus setup​(LinearBinaryFloat lb,
                                     VarInfo con_var,
                                     double con_val)
        Sets up the invariant from a LinearBinary invariant and a constant value for the third variable. Points are taken from the LinearBinary cache and its min_x/y and max_x/y points and combined with the constant value.
        Returns:
        InvariantStatus.NO_CHANGE if the invariant is valid, InvariantStatus.FALSIFIED if one of the points invalidated the LinearTernary invariant
      • setup

        public InvariantStatus setup​(OneOfFloat oo,
                                     VarInfo v1,
                                     double con1,
                                     VarInfo v2,
                                     double con2)
        Sets up the invariant from a OneOf and two constants. Points are taken from the OneOf cache and the constant values.
        Returns:
        InvariantStatus.NO_CHANGE if the invariant is valid, or InvariantStatus.FALSIFIED if one of the points invalidated the LinearTernary invariant
      • add_modified

        public InvariantStatus add_modified​(double x,
                                            double y,
                                            double z,
                                            int count)
        Looks for points that define a plane (ax + by + cz + d = 0). Collects MINTRIPLE points before attempting to define a line through the points. Once the equation for the line is found, each subsequent point is compared to it. If the point does not match, recalculates the maximally separated points and attempts to fit the points to the new line. If the points do not fit the line, attempts to define the plane (to hopefully get at least some spread between the points, so that small errors don't get magnified). Once the equation for the plane is found, each subsequent point is compared to it. If the point does not match the point is examined to see if it would is maximally separated when compared to the points originally used to define the plane. If it is, it is used to recalcalulate the coefficients (a, b, c). If those coefficients are relatively close to the original coefficients (within the ratio defined by Global.fuzzy) then the new coefficients are used.
        See Also:
        FuzzyFloat
      • try_new_equation

        public boolean try_new_equation​(double x,
                                        double y,
                                        double z)
        Calculates new coefficients that for the new point. Uses the new coefficients if they are relatively close to to the previous ones. Kills off the invariant if they are not.
        Returns:
        true if the new equation worked, false otherwise
      • calc_tri_linear

        public double[] calc_tri_linear​(@Nullable LinearTernaryCoreFloat.Point[] points)
        Calculates the coefficients (a, b, c) and constant (d) for the equation ax + by + cz + d = 0 using the first three points in points.
        Parameters:
        points - array of points to use to calculate the coefficents. Only the first three points (all of which must be non-null) are used.
        Returns:
        a four element array where a is the first element, b the second, c the third, and d is the fourth. All elements are mutually prime, integers and a is positive.
      • enoughSamples

        public boolean enoughSamples​(@GuardSatisfied LinearTernaryCoreFloat this)
      • repr

        public String repr​(@GuardSatisfied LinearTernaryCoreFloat this)
      • mergeFormulasOk

        public boolean mergeFormulasOk()
        In general, we can't merge formulas, but we can merge invariants with too few samples to have formed a plane with invariants with enough samples. And those will appear to have different formulas.
      • merge

        public @Nullable LinearTernaryCoreFloat merge​(List<LinearTernaryCoreFloat> cores,
                                                      Invariant wrapper)
        Merge the linear ternary cores in cores to form a new core. Any core in the list that has seen enough points to define a plane, must define the same plane. Any cores that have not yet seen enough points, will have each of their points applied to that invariant. The merged core is returned. Null is returned if the cores don't describe the same plane
        Parameters:
        cores - list of LinearTernary cores to merge. They should all be permuted to match the variable order in ppt.