Run the actual algorithm

@param hullonly
972264
void run(boolean hullonly) {
    if(points.size() < 3) {
      throw new UnsupportedOperationException("There is no delaunay triangulation for less than three objects!");
    }
    int len = points.size() - 1;
    hull = new LinkedList<>();
    tris = hullonly ? null : new ArrayList<Triangle>(len);

    // 1. Seed point x_0
    final double[] seed;
    final int seedid = 0;

    final double[] sortd = new double[len];
    final int[] sorti = new int[len];
    Arrays.fill(sorti, -42); // To cause errors
    // TODO: remove duplicates.

    // 2. sort by squared Euclidean distance
    {
      Iterator<double[]> iter = points.iterator();
      seed = iter.next();
      for(int i = 0, j = 1; iter.hasNext(); j++, i++) {
        double dist = quadraticEuclidean(seed, iter.next());
        if(dist <= 0.) { // Duplicate.
          --len; // Decrease candidate set size
          --i; // Increase j, but not i.
          continue;
        }
        sortd[i] = dist;
        sorti[i] = j;
      }
      DoubleIntegerArrayQuickSort.sort(sortd, sorti, len);
    }
    // Detect some degenerate situations:
    if(len < 2) {
      hull.add(new IntIntPair(seedid, -1));
      if(len == 1) {
        hull.add(new IntIntPair(sorti[0], -1));
      }
      return;
    }
    assert (sortd[0] > 0);
    // final double[] seed2 = points.get(sort[0].second);
    final int seed2id = sorti[0];

    // 3. Find minimal triangle for these two points:
    Triangle besttri = findSmallest(seedid, seed2id, sortd, sorti, len);
    if(besttri == null) { // Degenerate
      hull.add(new IntIntPair(seedid, -1));
      hull.add(new IntIntPair(seed2id, -1));
      return;
    }
    // Note: sortd no longer accurate, recompute below!
    int start = 2; // First two points have already been processed.

    // 5. Make right-handed:
    besttri.makeClockwise(points);
    // Seed triangulation
    if(!hullonly) {
      tris.add(besttri);
    }
    // Seed convex hull (point, triangle)
    hull.add(new IntIntPair(besttri.a, 0));
    hull.add(new IntIntPair(besttri.b, 0));
    hull.add(new IntIntPair(besttri.c, 0));

    if(LOG.isDebuggingFinest()) {
      debugHull();
    }

    // 6. Resort from triangle circumcircle center
    double[] center = besttri.m;
    for(int i = start; i < len; i++) {
      sortd[i] = quadraticEuclidean(center, points.get(sorti[i]));
    }
    DoubleIntegerArrayQuickSort.sort(sortd, sorti, start, len);

    // Grow hull and triangles
    for(int i = start; i < len; i++) {
      final int pointId = sorti[i];
      final double[] newpoint = points.get(pointId);

      LinkedList<Triangle> newtris = hullonly ? null : new LinkedList<Triangle>();
      // We identify edges by their starting point. -1 is invalid.
      int hstart = -1, hend = -1;
      // Find first and last consecutive visible edge, backwards:
      {
        Iterator<IntIntPair> iter = hull.descendingIterator();
        IntIntPair next = hull.getFirst();
        double[] nextV = points.get(next.first);
        for(int pos = hull.size() - 1; iter.hasNext(); pos--) {
          IntIntPair prev = iter.next();
          double[] prevV = points.get(prev.first);
          // Not yet visible:
          if(hend < 0) {
            if(leftOf(prevV, nextV, newpoint)) {
              hstart = hend = pos;
              if(!hullonly) {
                // Clockwise, A is new point!
                Triangle tri = new Triangle(pointId, next.first, prev.first);
                assert (tri.isClockwise(points));
                assert (prev.second >= 0);
                tri.updateCircumcircle(points);
                tri.bc = prev.second;
                newtris.addFirst(tri);
              }
            }
          }
          else {
            if(leftOf(prevV, nextV, newpoint)) {
              hstart = pos;
              // Add triad:
              if(!hullonly) {
                // Clockwise, A is new point!
                Triangle tri = new Triangle(pointId, next.first, prev.first);
                assert (tri.isClockwise(points));
                assert (prev.second >= 0);
                tri.updateCircumcircle(points);
                tri.bc = prev.second;
                newtris.addFirst(tri);
              }
            }
            else {
              break;
            }
          }
          next = prev;
          nextV = prevV;
        }
      }
      // If the last edge was visible, we also need to scan forwards:
      if(hend == hull.size() - 1) {
        Iterator<IntIntPair> iter = hull.iterator();
        IntIntPair prev = iter.next();
        double[] prevV = points.get(prev.first);
        while(iter.hasNext()) {
          IntIntPair next = iter.next();
          double[] nextV = points.get(next.first);
          if(leftOf(prevV, nextV, newpoint)) {
            hend++;
            // Add triad:
            if(!hullonly) {
              // Clockwise, A is new point!
              Triangle tri = new Triangle(pointId, next.first, prev.first);
              assert (tri.isClockwise(points));
              assert (prev.second >= 0);
              tri.updateCircumcircle(points);
              tri.bc = prev.second;
              newtris.addLast(tri);
            }
          }
          else {
            break;
          }
          prev = next;
          prevV = nextV;
        }
      }
      assert (hstart >= 0 && hend >= hstart);
      // Note that hend can be larger than hull.size() now, interpret as
      // "hend % hull.size()"
      // Update hull, remove points
      final int firsttri, lasttri;
      if(hullonly) {
        firsttri = lasttri = -1;
      }
      else {
        final int tristart = tris.size();
        firsttri = tristart;
        lasttri = tristart + newtris.size() - 1;
      }
      final int hullsize = hull.size();
      if(LOG.isDebuggingFinest()) {
        LOG.debugFinest("Size: " + hullsize + " start: " + hstart + " end: " + hend);
      }
      if(hend < hullsize) {
        ListIterator<IntIntPair> iter = hull.listIterator();
        int p = 0;
        // Skip
        for(; p <= hstart; p++) {
          iter.next();
        }
        // Remove
        for(; p <= hend; p++) {
          iter.next();
          iter.remove();
        }
        // Insert, and update edge->triangle mapping
        iter.add(new IntIntPair(pointId, lasttri));
        iter.previous();
        if(!hullonly) {
          (iter.hasPrevious() ? iter.previous() : hull.getLast()).second = firsttri;
        }
      }
      else {
        ListIterator<IntIntPair> iter = hull.listIterator();
        // Remove end
        int p = hullsize;
        for(; p <= hend; p++) {
          iter.next();
          iter.remove();
        }
        // Insert
        iter.add(new IntIntPair(pointId, lasttri));
        // Wrap around
        p -= hullsize;
        IntIntPair pre = null;
        for(; p <= hstart; p++) {
          pre = iter.next();
        }
        assert (pre != null);
        pre.second = firsttri;
        // Remove remainder
        while(iter.hasNext()) {
          iter.next();
          iter.remove();
        }
      }
      if(LOG.isDebuggingFinest()) {
        debugHull();
      }
      if(!hullonly) {
        final int tristart = tris.size();
        // Connect triads (they are ordered)
        Iterator<Triangle> iter = newtris.iterator();
        for(int o = 0; iter.hasNext(); o++) {
          // This triangle has num tristart + o.
          Triangle cur = iter.next();
          cur.ca = o > 0 ? tristart + o - 1 : -1; // previously added triangle
          cur.ab = iter.hasNext() ? tristart + o + 1 : -1; // next triangle
          // cur.bc was set upon creation
          assert (cur.bc >= 0);
          Triangle other = tris.get(cur.bc);
          Orientation orient = cur.findOrientation(other);
          assert (orient != null) : "Inconsistent triangles: " + cur + " " + other;
          switch(orient){
          case ORIENT_BC_BA:
            assert (other.ab == -1) : "Inconsistent triangles: " + cur + " " + other;
            other.ab = tristart + o;
            break;
          case ORIENT_BC_CB:
            assert (other.bc == -1) : "Inconsistent triangles: " + cur + " " + other;
            other.bc = tristart + o;
            break;
          case ORIENT_BC_AC:
            assert (other.ca == -1) : "Inconsistent triangles: " + cur + " " + other;
            other.ca = tristart + o;
            break;
          default:
            assert (cur.isClockwise(points));
            assert (other.isClockwise(points));
            throw new RuntimeException("Inconsistent triangles: " + cur + " " + other + " size:" + tris.size());
          }
          tris.add(cur);
        }
        assert (tris.size() == lasttri + 1);
      }
    }
    // Now check for triangles that need flipping.
    if(!hullonly) {
      final int size = tris.size();
      long[] flippedA = BitsUtil.zero(size), flippedB = BitsUtil.zero(size);
      // Initial flip
      if(flipTriangles(flippedA) > 0) {
        for(int iterations = 1; iterations < 1000; iterations += 2) {
          if(LOG.isDebuggingFinest()) {
            debugHull();
          }
          if(flipTriangles(flippedA, flippedB) == 0) {
            break;
          }
          if(LOG.isDebuggingFinest()) {
            debugHull();
          }
          if(flipTriangles(flippedB, flippedA) == 0) {
            break;
          }
        }
      }
    }
  }
422854
public void run() {
        Runnable r = null;
        while (true) {
            // Try to drain the maximum capacity of thread-local items, checking
            // whether any were available
            if (workQueue.drainTo(internalQueue, threadLocalItems) == 0) {
                // block until a work item is available
                try {
                    internalQueue.offer(workQueue.take());
                } catch (InterruptedException ie) {
                    throw new Error(ie);
                }
            }
            // Execute all of the thread-local items
            while ((r = internalQueue.poll()) != null)
                r.run();
        }
    }
1092015
@Override
   public void run()
   {
      try {
         startBarrier.await();

         int idleCount = 0;
         while (!isRunning.compareAndSet(idleCount > lingerIterations && pidToProcessMap.isEmpty(), false)) {
            idleCount = (!shutdown && process()) ? 0 : (idleCount + 1);
         }
      }
      catch (Exception e) {
         // TODO: how to handle this error?
         isRunning.set(false);
      }
   }
304668
def run(self, **options):
        """"""
        if not self.is_setup:
            self.setup()

        if self.twisted:
            self.run_with_twisted(**options)
        elif self.gunicorn:
            self.run_with_gunicorn(**options)
        else:
            self.run_with_werkzeug(**options)
990768
@Override
    protected final void performRuntime(OperationContext context, ModelNode operation, Resource resource) throws OperationFailedException {
        if (context.isBooting()) {
            performBoottime(context, operation, resource);
        } else {
            context.reloadRequired();
        }
    }
1261876
public void run( String[] args ) throws Exception {

		// Check
		File baseDirectory = null;
		if( args.length != 1
				|| ! (baseDirectory = new File( args[ 0 ])).exists())
			throw new RuntimeException( "The path of the module's directory was expected as an argument." );

		// Update
		UpdateSwaggerJson updater = new UpdateSwaggerJson();
		JsonObject newDef = updater.prepareNewDefinitions();
		updater.updateSwaggerJson( baseDirectory, newDef );
	}
464838
private void scheduleUpdate() {
		if (!isVisible()) {
			return;
		}
		
		SwingUtilities.invokeLater(new Runnable() {
			public void run() {
				try {
					container.gameLoop();
				} catch (SlickException e) {
					e.printStackTrace();
				}
				container.checkDimensions();
				scheduleUpdate();
			}
		});
	}
880451
def run(self):
        """"""
        while True:
            try:
                self.perform_iteration()
            except Exception:
                traceback.print_exc()
                pass

            time.sleep(ray_constants.REPORTER_UPDATE_INTERVAL_MS / 1000)
94609
public void run()
    {
        final boolean isTraceOn = TraceComponent.isAnyTracingEnabled();
        if (isTraceOn && tc.isDebugEnabled())
            Tr.entry(tc, "run");

        int numPools;
        synchronized (this)
        {
            if (ivIsCanceled)
            {
                return;
            }

            ivIsRunning = true;

            numPools = pools.size();
            if (numPools > 0)
            {
                if (numPools > poolArray.length)
                {
                    poolArray = new PoolImplBase[numPools];
                }

                pools.toArray(poolArray);
            }
        }

        try
        {
            for (int i = 0; i < poolArray.length && poolArray[i] != null; ++i) // 147140
            {
                if (poolArray[i].inactive)
                {
                    poolArray[i].periodicDrain();
                }
                else
                {
                    if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled())
                        Tr.debug(tc, "setting inactive: " + poolArray[i]);
                    poolArray[i].inactive = true;
                }

                // Allow pools to be GC'ed promptly after being removed.     PM54417
                poolArray[i] = null;
            }
        } finally
        {
            synchronized (this)
            {
                ivIsRunning = false;
                if (ivIsCanceled)
                {
                    notify();
                }
                else if (!pools.isEmpty())
                {
                    startAlarm();
                }
                else
                {
                    ivScheduledFuture = null;
                }
            }
        }

        if (isTraceOn && tc.isDebugEnabled())
            Tr.exit(tc, "run");
    }
135072
def run(self, context):
        """"""
        # Don't do something when running non-interactive.
        if not sys.stdout.isatty():
            return

        with local.cwd(context.in_container):
            from benchbuild.projects.gentoo import gentoo
            gentoo.setup_networking()
            gentoo.configure_portage()

            sed_in_chroot = uchroot.uchroot()["/bin/sed"]
            emerge_in_chroot = uchroot.uchroot()["/usr/bin/emerge"]
            has_pkg = uchroot.uchroot()["/usr/bin/qlist", "-I"]

            run.run(sed_in_chroot["-i", '/CC=/d', "/etc/portage/make.conf"])
            run.run(sed_in_chroot["-i", '/CXX=/d', "/etc/portage/make.conf"])

            want_sync = bool(CFG["container"]["strategy"]["polyjit"]["sync"])
            want_upgrade = bool(
                CFG["container"]["strategy"]["polyjit"]["upgrade"])

            packages = \
                CFG["container"]["strategy"]["polyjit"]["packages"].value
            with local.env(MAKEOPTS="-j{0}".format(int(CFG["jobs"]))):
                if want_sync:
                    LOG.debug("Synchronizing portage.")
                    run.run(emerge_in_chroot["--sync"])
                if want_upgrade:
                    LOG.debug("Upgrading world.")
                    run.run(emerge_in_chroot["--autounmask-only=y", "-uUDN",
                                             "--with-bdeps=y", "@world"])
                for pkg in packages:
                    if has_pkg[pkg["name"]] & TF:
                        continue
                    env = pkg["env"]
                    with local.env(**env):
                        run.run(emerge_in_chroot[pkg["name"]])

            gentoo.setup_benchbuild()

        print("Packing new container image.")
        with local.cwd(context.builddir):
            pack_container(context.in_container, context.out_container)
738602
public void run() {
    int maxruns = this.maxruns, maxsmall = this.maxsmall;
    double oldchi = getChiSq();
    while(maxruns-- > 0) {
      iterate();
      double newchi = getChiSq(), deltachi = newchi - oldchi;
      oldchi = newchi;
      // stop condition: only a small improvement in Chi.
      if(deltachi < 0 && deltachi > -small && --maxsmall < 0) {
        break;
      }
    }
  }
238142
def run_kernel(self, func, gpu_args, instance):
        
        logging.debug('run_kernel %s', instance.name)
        logging.debug('thread block dims (%d, %d, %d)', *instance.threads)
        logging.debug('grid dims (%d, %d, %d)', *instance.grid)

        try:
            self.dev.run_kernel(func, gpu_args, instance.threads, instance.grid)
        except Exception as e:
            if "too many resources requested for launch" in str(e) or "OUT_OF_RESOURCES" in str(e):
                logging.debug('ignoring runtime failure due to too many resources required')
                return False
            else:
                logging.debug('encountered unexpected runtime failure: ' + str(e))
                raise e
        return True
918432
def run_locally(self, steps=None, **kwargs):
        """"""
        self.slurm_job = LoggedJobSLURM(self.command(steps),
                                        base_dir = self.parent.p.logs_dir,
                                        modules  = self.modules,
                                        **kwargs)
        self.slurm_job.run_locally()
1077521
public void run() {
    /* check if running the routine is still necessary */
    if(shutDownHookExecuted) {
      return;
    }
    synchronized (processes) {
      running = true;
      Enumeration e = processes.elements();
      while (e.hasMoreElements()) {
        destroy((Process) e.nextElement());
      }
      processes.clear();
      shutDownHookExecuted = true;
    }
  }
439147
public void runOptimization(int maxi) throws StructureException{
		superimposeBySet();
		if ( debug)
			System.err.println("   initial rmsd " + rmsd);

//      if (showAlig)
//         showCurrentAlignment(equLen, equSet, "after initial superimposeBySet Len:" +equLen + " rmsd:" +rmsd);

		maxKeepStep = 4;
		keepStep = 0;

		optimize(maxi);
	}
414254
public void run() {
        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) {
            Tr.entry(tc, "run");
        }

        try {
            framework.stopChain(chainName, 0L);
        } catch (Exception e) {
            FFDCFilter.processException(e, getClass().getName() + ".run", "68",
                                        this, new Object[] { chainName });
        }

        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) {
            Tr.exit(tc, "run");
        }
    }
1231848
@Override
    public void run() {
        boolean cancelledDone = false;
        boolean forceSelect = false;
        long selectTimeoutValue = 0L;
        int numEmptySelects = 0;
        int numExceptions = 0;
        boolean nothingTimedOut = true;
        long firstEmptySelectorTime = 0L;
        int numKeysOnEmptySelect = -1;
        long lastEmptySelectorFFDCTime = 0L;

        if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
            Tr.debug(this, tc, "selector thread started for " + Thread.currentThread().getName());
        }

        nextTimeoutTime = currentTime + TCPFactoryConfiguration.getChannelSelectorIdleTimeout();

        while (!quit) {
            currentTime = CHFWBundle.getApproxTime();
            try {
                nothingTimedOut = true;
                // yielding increases performance by not doing too many selects
                // this gives 10% performance boost on Daves system, 10% performance
                // loss on Tony's
                if (selectorYield) {
                    Thread.yield();
                }

                wakeupPending = false;
                if (checkCancel && forceSelect) {
                    if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                        Tr.debug(this, tc, "selectNow() forced");
                    }
                    selector.selectNow();
                    forceSelect = false;
                    numEmptySelects = 0;
                } else if (nextTimeoutTime > currentTime) {
                    // don't use a timeout of less than 1 second, since thats the
                    // granularity of ApproxTime
                    selectTimeoutValue = nextTimeoutTime - currentTime;
                    if (selectTimeoutValue < 1000L) {
                        selectTimeoutValue = 1000L;
                    }
                    if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                        Tr.debug(this, tc, "select() with timeout = " + selectTimeoutValue);
                    }
                    selector.select(selectTimeoutValue);
                } else {
                    if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                        Tr.debug(this, tc, "selectNow()");
                    }
                    selector.selectNow();
                    nothingTimedOut = false;
                    numEmptySelects = 0;
                }
                wakeupPending = false;
                // if any keys were cancelled on the last time through
                // the selector should now be updated, so notfiy anyone
                // anyone waiting on the cancels
                if (checkCancel && cancelledDone) {
                    notifyCancelRequests();
                    cancelledDone = false;
                }

                currentTime = CHFWBundle.getApproxTime();

                // need to process cancel requests before add requests, because we might
                // be trying to add one back in that we previously cancelled. We also don't want
                // to include keys that have been cancelled in our next-to-timeout logic
                if (checkCancel) {
                    cancelledDone = processCancelRequests();
                    if (cancelledDone) {
                        forceSelect = true;
                        continue;
                    }
                }

                // the following logic is for detecting looping problems in the JDK
                // it will log an ffdc event if the selector fires in quick succession
                if (selector.selectedKeys().isEmpty() && nothingTimedOut && areQueuesEmpty()) {
                    if (numEmptySelects == 0) {
                        firstEmptySelectorTime = currentTime;
                        numKeysOnEmptySelect = selector.keys().size();
                    }
                    numEmptySelects++;
                    if (numEmptySelects == 40) {
                        // selector fired 40 times with nothing selected, see if it was in
                        // quick succession
                        // and key set hasn't changed
                        if (currentTime < (firstEmptySelectorTime + 10000L) && selector.keys().size() == numKeysOnEmptySelect) {
                            if (TraceComponent.isAnyTracingEnabled() && tc.isEventEnabled()) {
                                Tr.event(this, tc, "Selector fired 20 times in a row with no keys selected - possible loop in JDK detected");
                            }
                            // TODO seems to happen sometimes if the socket is closed but not
                            // removed from the keys (Windows JDK 1.6 SR7 at least)... could scan and remove
                            // closed sockets the SocketChannel.close() is supposed to remove it from
                            // selectors but TCP has a checkcancel config option to manually do it (since it's
                            // been broken in the past apparently)

                            // create an exception to be logged in FFDC, but limit to once
                            // every 5 minutes
                            if (currentTime > (lastEmptySelectorFFDCTime + 300000L)) {
                                ChannelException e = new ChannelException("TCP Channel detected a possible loop on thread: " + Thread.currentThread().getName());
                                FFDCFilter.processException(e,
                                                            getClass().getName(),
                                                            "186",
                                                            this,
                                                            new Object[] { "Last FFDC time=" + lastEmptySelectorFFDCTime, "Current time=" + currentTime,
                                                                          "Next timeout time=" + nextTimeoutTime,
                                                                          "First empty select time=" + firstEmptySelectorTime, "First empty select keys=" + numKeysOnEmptySelect,
                                                                          "Number empty selects=" + numEmptySelects, "Thread interrupted=" + Thread.interrupted(), this.workQueue1,
                                                                          this.workQueue2 });
                                lastEmptySelectorFFDCTime = currentTime;
                            }
                        }
                        numEmptySelects = 0;
                    } // end-if-20
                } else {
                    numEmptySelects = 0;
                }
                // end of loop detection code

                if (performRequest()) {
                    // connect logic cancels keys and returns true
                    continue;
                }

                updateCount();

                checkForTimeouts();
                updateSelector();

                // if we got here, we didn't get an IOException
                numExceptions = 0;
            } catch (IOException e) {
                // an IOException can happen due to jdk errors or if we run out of sockets
                // Don't log the exception during server shutdown
                if (!!!com.ibm.wsspi.kernel.service.utils.FrameworkState.isStopping()) {
                    FFDCFilter.processException(e, getClass().getName(), "288", this);
                }
                if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                    Tr.debug(this, tc, "IOException (" + numExceptions + ") in run " + e);
                }
                numExceptions++;

            } catch (Throwable unexpectedException) {
                // Don't log the exception during server shutdown
                if (!!!com.ibm.wsspi.kernel.service.utils.FrameworkState.isStopping()) {
                    FFDCFilter.processException(unexpectedException, getClass().getName(), "254", this);
                }
                if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                    Tr.debug(this, tc, "Exception (" + numExceptions + ") in run " + unexpectedException);
                }
                // force selector to fire immediately, since an event or wakeup call
                // could be missed
                nextTimeoutTime = currentTime;
                numExceptions++;
            }

            // if we don't recover after 5 minutes, stop accepting for a long-ish while.
            // allow for recovery of the system, reconfiguration, or server stop.
            if (numExceptions >= 400) {
                if (pauseAccept()) {
                    numExceptions = 0; // start counting over again
                }
            } else if (numExceptions >= 100) {
                // if we get exceptions repeatedly, wait a second to give other
                // threads a chance to close sockets or update selector
                try {
                    Thread.sleep(1000);
                } catch (InterruptedException ie) {
                    // ignore it
                }
            }
        } // end-while

        channelSelectorClose();
    }