Calculates the whole (discrete) process.
508347
private void doPrecalculateProcess()
	{
		if(discreteProcess != null && discreteProcess.length != 0) {
			return;
		}

		// Allocate Memory
		discreteProcess			= new RandomVariableInterface[timeDiscretization.getNumberOfTimeSteps()+1][numberOfComponents];
		discreteProcessWeights	= new RandomVariableInterface[getTimeDiscretization().getNumberOfTimeSteps()+1];

		// Set initial Monte-Carlo weights
		discreteProcessWeights[0] = new RandomVariable(0.0, 1.0/numberOfPaths);

		// Store components
		discreteProcess[0] = getInitialValue();

		// Evolve process
		for(int timeIndex = 1; timeIndex < timeDiscretization.getNumberOfTimeSteps()+1; timeIndex++)
		{
			// Generate process at timeIndex
			double deltaT = timeDiscretization.getTime(timeIndex) - timeDiscretization.getTime(timeIndex-1);

			// Temp storage for variance and diffusion
			RandomVariableInterface[] variance   = new RandomVariableInterface[numberOfComponents];
			RandomVariableInterface[] diffusion  = new RandomVariableInterface[numberOfComponents];

			// Calculate new realization
			for(int componentIndex = numberOfComponents-1; componentIndex >= 0; componentIndex--)
			{
				// Calculate diffusion

				// Temp storage for variance and diffusion
				RandomVariableInterface varianceOfComponent  = new RandomVariable(getTime(timeIndex-1),0.0);
				RandomVariableInterface diffusionOfComponent = new RandomVariable(getTime(timeIndex-1),0.0);

				// Generate values for diffusionOfComponent and varianceOfComponent
				for(int factor=0; factor<numberOfFactors; factor++) {
					RandomVariableInterface factorLoading       = getFactorLoading(timeIndex-1, factor, componentIndex, null);
					RandomVariableInterface brownianIncrement   = brownianMotion.getBrownianIncrement(timeIndex-1,factor);

					varianceOfComponent = varianceOfComponent.addProduct(factorLoading, factorLoading);
					diffusionOfComponent = diffusionOfComponent.addProduct(factorLoading, brownianIncrement);
				}

				variance[componentIndex] = varianceOfComponent;
				diffusion[componentIndex] = diffusionOfComponent;
			}

			RandomVariableInterface[] drift;
			if(scheme == Scheme.PREDICTOR_USING_LASTREALIZATION) {
				drift = getDrift(timeIndex-1, discreteProcess[timeIndex-1], discreteProcess[timeIndex]);
			} else {
				drift = getDrift(timeIndex-1, discreteProcess[timeIndex-1], null                      );
			}

			// Calculate drift
			for(int componentIndex = numberOfComponents-1; componentIndex >= 0; componentIndex--)
			{
				RandomVariableInterface driftOfComponent  	= drift[componentIndex];
				RandomVariableInterface varianceOfComponent			= variance[componentIndex];
				RandomVariableInterface diffusionOfComponent		= diffusion[componentIndex];

				if(driftOfComponent == null) {
					discreteProcess[timeIndex][componentIndex] = discreteProcess[timeIndex-1][componentIndex];
					continue;
				}

				// Allocate memory for on path-realizations
				double[] newRealization			= new double[numberOfPaths];

				// Euler Scheme
				RandomVariableInterface previouseRealization		= discreteProcess[timeIndex-1][componentIndex];

				// Generate values
				for(int pathIndex = 0; pathIndex < numberOfPaths; pathIndex++)
				{
					double previousValue	= previouseRealization.get(pathIndex);
					double driftOnPath		= driftOfComponent.get(pathIndex);
					double varianceOnPath	= varianceOfComponent.get(pathIndex);
					double diffusionOnPath	= diffusionOfComponent.get(pathIndex);

					// The scheme
					newRealization[pathIndex]	 = previousValue * Math.exp(driftOnPath * deltaT - 0.5 * varianceOnPath * deltaT + diffusionOnPath);
				}

				// Store components
				discreteProcess[timeIndex][componentIndex] = new RandomVariable(getTime(timeIndex),newRealization);
			}

			if(scheme == Scheme.PREDICTOR_USING_EULERSTEP) {
				RandomVariableInterface[] newRealization = new RandomVariable[numberOfComponents];

				// Note: This is actually more than a predictor corrector: The drift of componentIndex already uses the corrected predictor from the previous components
				drift = getDrift(timeIndex-1, discreteProcess[timeIndex-1], discreteProcess[timeIndex]);

				// Apply corrector step to realizations at next time step
				for(int componentIndex = 0; componentIndex < numberOfComponents; componentIndex++)
				{
					RandomVariableInterface driftOfComponent	= drift[componentIndex];
					RandomVariableInterface varianceOfComponent			= variance[componentIndex];
					RandomVariableInterface diffusionOfComponent		= diffusion[componentIndex];

					// Euler Scheme with corrected drift
					RandomVariableInterface previouseRealization 	= discreteProcess[timeIndex-1][componentIndex];

					// The scheme
					// newValue = previousValue * Math.exp(driftValue * deltaT - 0.5 * varianceOnPath * deltaT + diffusionOnPath);
					newRealization[componentIndex] = previouseRealization.mult((driftOfComponent.mult(deltaT).sub(varianceOfComponent.mult(0.5 * deltaT)).add(diffusionOfComponent)).exp());
				} // End for(componentIndex)

				// Store predictor-corrector corrected process.
				discreteProcess[timeIndex] = newRealization;
			} // End if(scheme == LogNormalProcess.SCHEME_PREDICTOR_USES_EULER)

			// Set Monte-Carlo weights (since there is no Monte-Carlo weighting, the weights remain the same (namely 1.0/numberOfPaths).
			discreteProcessWeights[timeIndex] = discreteProcessWeights[timeIndex-1];
		} // End for(timeIndex)
	}
540252
private void doMutation(double probability, DoubleSolution solution) {
    double rnd, deltaq, tempDelta;
    double y, yl, yu;

    for (int i = 0; i < solution.getNumberOfVariables(); i++) {
      if (randomGenerator.nextDouble() <= probability) {
        y = solution.getVariableValue(i);
        yl = solution.getLowerBound(i) ;
        yu = solution.getUpperBound(i) ;
        rnd = randomGenerator.nextDouble();
          
        tempDelta = Math.pow(rnd, -delta);
        deltaq = 0.5 * (rnd - 0.5) * (1 - tempDelta);
          
        y = y + deltaq * (yu - yl);
        y = solutionRepair.repairSolutionVariableValue(y, yl, yu);
        solution.setVariableValue(i, y);
      }
    }
  }
506201
protected function postProcessing(): void
    {
        if (isset($this->value)) {
            $this->value = array_map(function ($item) {
                if (ctype_digit($item)) {
                    return intval($item);
                } else {
                    return $item;
                }
            }, $this->value);
        }
    }
55106
def _compute(self):
        """"""
        if self._min:
            self._box.ymin = min(self._min, self.zero)
        if self._max:
            self._box.ymax = max(self._max, self.zero)
        self._x_pos = [
            x / self._len for x in range(self._len + 1)
        ] if self._len > 1 else [0, 1]  # Center if only one value

        self._points(self._x_pos)

        self._x_pos = [(i + .5) / self._len for i in range(self._len)]
1008226
protected function compute () : void
    {
        $pairwise = $this->_selfElection->getPairwise(false);
        $HeadToHead = [];

        foreach ($pairwise as $candidateId => $CandidateStats) :
            foreach ($CandidateStats['lose'] as $opponentId => $CandidateLose) :
                if (($diff = $CandidateLose - $CandidateStats['win'][$opponentId]) >= 0) :
                    $HeadToHead[$candidateId][$opponentId] = $diff;
                endif;
            endforeach;
        endforeach;

        $dodgsonQuick = [];

        foreach ($HeadToHead as $candidateId => $CandidateTidemanScores) :
            $dodgsonQuick[$candidateId] = 0;

            foreach ($CandidateTidemanScores as $opponentId => $oneTidemanScore) :
                $dodgsonQuick[$candidateId] += ceil($oneTidemanScore / 2);
            endforeach;
        endforeach;
        asort($dodgsonQuick);

        $rank = 0;
        $result = [];

        if($basicCondorcetWinner = $this->_selfElection->getWinner(null)) :
            $result[++$rank][] = $this->_selfElection->getCandidateKey($basicCondorcetWinner);
        endif;

        $lastDodgsonQuickValue = null;

        foreach ($dodgsonQuick as $CandidateId => $dodgsonQuickValue) :
            if($lastDodgsonQuickValue === $dodgsonQuickValue) :
                $result[$rank][] = $CandidateId;
            else:
                $result[++$rank][] = $CandidateId;
                $lastDodgsonQuickValue = $dodgsonQuickValue;
            endif;
        endforeach;

        $this->_Stats = $dodgsonQuick;
        $this->_Result = $this->createResult($result);
    }
901993
def _compute(self):
        """"""
        self.min_ = self._min or 0
        self.max_ = self._max or 0
        if self.max_ - self.min_ == 0:
            self.min_ -= 1
            self.max_ += 1

        self._box.set_polar_box(0, 1, self.min_, self.max_)
39252
def result(self, value):
        """"""
        if self._process_result:
            self._result = self._process_result(value)

        self._raw_result = value
90305
def _euler_step(self, dt):
        
        self.state = self.state + self.ddt() * dt
904440
def compute_amount(self):
        """"""
        self.amount = self.base_amount * self.aliquot / 100
        return self.amount
941383
def finalize(self):
        """"""
        for name, count in sorted(self.blocks.items(), key=lambda x: x[1]):
            print('{:3} {}'.format(count, name))
        print('{:3} total'.format(sum(self.blocks.values())))
509618
private int precisionSum(List<UnitFactor> factors) {
    return factors.stream().map(f -> totalPrecision(f.rational())).reduce(0, Math::addExact);
  }
608553
private void dcstep() {
		double sgnd = gp*Math.signum(gx);

		// the new step
		double stpf;

		if( fp > fx ) {
			stpf = handleCase1();
		} else if( sgnd < 0 ) {
			stpf = handleCase2();
		} else if( Math.abs(gp) < Math.abs(gx) ) {
			stpf = handleCase3();
		} else {
			stpf = handleCase4();
		}

		// update the bracket which contains the solution
		if( fp > fx ) {
			// found an upper bound
			sty = stp;
			fy = fp;
			gy = gp;
		} else {
			// see if its on the other side of the dip
			if( sgnd < 0 ) {
				sty = stx;
				fy = fx;
				gy = gx;
			}
			stx = stp;
			fx = fp;
			gx = gp;
		}
		
		stp = stpf;
		updated = true;
	}
724442
synchronized void computeDominators() {
        boolean changed = true;
        boolean igonoreDirty;
        try {
            do {
                currentMultipleParents.rewind();
                igonoreDirty = !changed;
                changed = computeOneLevel(igonoreDirty);
                switchParents();
            } while (changed || !igonoreDirty);
        } catch (IOException ex) {
            ex.printStackTrace();
        }
        deleteBuffers();
        dirtySet = Collections.EMPTY_SET;
    }
469976
public static int processMultiple(int selectNum, int minNum) {
		int result;
		result = mathSubnode(selectNum, minNum) / mathNode(selectNum - minNum);
		return result;
	}
893678
private function calculate()
    {
        $this->second = 0;

        $iters = 0;
        $maxIters = 100;
        while ($iters < $maxIters && !$this->satisfied()) {
            if ($this->params->minute !== '*' && ($this->minute != $this->params->minute)) {
                if ($this->minute > $this->params->minute) {
                    $this->modify('+1 hour');
                }

                $this->minute = $this->params->minute;
            }

            if ($this->params->hour !== '*' && ($this->hour != $this->params->hour)) {
                if ($this->hour > $this->params->hour) {
                    $this->modify('+1 day');
                }

                $this->hour = $this->params->hour;
                $this->minute = 0;
            }

            if ($this->params->week !== '*' && ($this->week != $this->params->week)) {
                $this->week = $this->params->week;
                $this->hour = 0;
                $this->minute = 0;
            }

            if ($this->params->day !== '*' && ($this->day != $this->params->day)) {
                if ($this->day > $this->params->day) {
                    $this->modify('+1 month');
                }

                $this->day = $this->params->day;
                $this->hour = 0;
                $this->minute = 0;
            }

            if ($this->params->month !== '*' && ($this->month != $this->params->month)) {
                if ($this->month > $this->params->month) {
                    $this->modify('+1 year');
                }

                $this->month = $this->params->month;
                $this->day = 1;
                $this->hour = 0;
                $this->minute = 0;
            }

            ++$iters;
        }
    }
75332
function calculate(control, N, context) {
    var result = this.values.reduce(function(acc, el) {
      if (acc) {
        return context.op(acc, el)
      } else {
        return el
      }
    })
    this.$push('result = ' + result + '\n')
    control.next(N.start)
  }
335711
public function calculateDiscount()
    {
        $dPrice = $this->getPrice();
        $aDiscounts = $this->getDiscounts();

        if ($aDiscounts) {
            foreach ($aDiscounts as $aDiscount) {
                if ($aDiscount['type'] == 'abs') {
                    $dPrice = $dPrice - $aDiscount['value'];
                } else {
                    $dPrice = $dPrice * (100 - $aDiscount['value']) / 100;
                }
            }
            if ($dPrice < 0) {
                $this->setPrice(0);
            } else {
                $this->setPrice($dPrice);
            }

            $this->_flushDiscounts();
        }
    }