Пример #1
0
 /** Return the midpoint (a degenerated box) */
 public Box mid() {
   Box mBox = new Box(dim());
   for (int i = 0; i < dim(); i++) {
     double m = get(i).mid();
     mBox.set(i, new Interval(m, m));
   }
   return mBox;
 }
Пример #2
0
  /**
   * Bisect the box along "var" at point "pt" and return the two sub-boxes. Sub-boxes are new boxes
   * independent from each other and independent from the current box.
   *
   * @throws InvalidIntervalOp (cf. Interval.bisect)
   */
  private Pair<Box, Box> bisect(int var, double pt) {

    // split the variable
    Interval i = get(var);
    Pair<Interval, Interval> pi = i.bisect(pt);
    // copy the box
    Box lowerHalf = copy();
    lowerHalf.set(var, pi.fst);
    Box upperHalf = copy();
    upperHalf.set(var, pi.snd);

    return new Pair<Box, Box>(lowerHalf, upperHalf);
  }
Пример #3
0
 /** Create a deep copy of "other". */
 private Box(Box other) {
   comp = new Vector<Interval>(other.dim());
   for (int i = 0; i < other.dim(); i++) comp.add(other.comp.get(i).copy());
 }