/* Connects to a single variable, pushing a fixed (Gaussian) value
to that variable.
171986
function PriorFactor(variable, param) {
      PriorFactor.__super__.constructor.call(this, [variable]);
      this.param = param;
    }
628148
public int put(Object value) {
        value = makePoolValue(value);
//      assert !(value instanceof Type.TypeVar);
        Integer index = indices.get(value);
        if (index == null) {
//          System.err.println("put " + value + " " + value.getClass());//DEBUG
            index = pp;
            indices.put(value, index);
            pool = ArrayUtils.ensureCapacity(pool, pp);
            pool[pp++] = value;
            if (value instanceof Long || value instanceof Double) {
                pool = ArrayUtils.ensureCapacity(pool, pp);
                pool[pp++] = null;
            }
        }
        return index.intValue();
    }
155783
public final void addValue(ExtendedStatistic stat, double value) {
      container.addValue(stat, value);
      if (trace) {
         log.tracef("Add %s to %s", value, stat);
      }
   }
315531
public ForwardToView with(String varName, Object value) {
        attributes.put(varName,value);
        return this;
    }
828608
@Override
	public RandomVariableInterface getValue(double evaluationTime, LIBORModelMonteCarloSimulationInterface model) throws CalculationException {

		if(inceptionTime > evaluationTime) {
			return new RandomVariable(0.0);
		}
		if(accrualPeriod <= 0) {
			return new RandomVariable(Double.MAX_VALUE);
		}

		// Initialize the value of the account to 1.0
		RandomVariableInterface value = new RandomVariable(initialValue);

		// Loop over accrual periods
		for(double time=inceptionTime; time<evaluationTime; time += accrualPeriod) {
			// Get the forward fixed at the beginning of the period
			RandomVariableInterface	forwardRate				= model.getLIBOR(time, time, time+accrualPeriod);
			double					currentAccrualPeriod	= Math.min(accrualPeriod , evaluationTime-time);

			// Accrue the value using the current forward rate
			value = value.accrue(forwardRate, currentAccrualPeriod);
		}

		return value;
	}
532554
@Override
	public RandomVariable div(double value) {
		return apply(new DoubleUnaryOperator() {
			@Override
			public double applyAsDouble(double x) {
				return x / value;
			}
		});
	}
896081
public void push(Value value) {
		for (MeasureListener<Value> listener : listeners) {
			listener.measureGenerated(value);
		}
	}
320717
def _set_value(self, new_value):
        """"""

        if self.min_value is not None and new_value < self.min_value:

            raise SettingOutOfBounds(
                "Trying to set parameter {0} = {1}, which is less than the minimum allowed {2}".format(
                    self.name, new_value, self.min_value))

        if self.max_value is not None and new_value > self.max_value:
            raise SettingOutOfBounds(
                "Trying to set parameter {0} = {1}, which is more than the maximum allowed {2}".format(
                    self.name, new_value, self.max_value))

        # Issue a warning if there is an auxiliary variable, as the setting does not have any effect
        if self.has_auxiliary_variable():

            with warnings.catch_warnings():

                warnings.simplefilter("always", RuntimeWarning)

                warnings.warn("You are trying to assign to a parameter which is either linked or "
                              "has auxiliary variables. The assignment has no effect.", RuntimeWarning)

        # Save the value as a pure floating point to avoid the overhead of the astropy.units machinery when
        # not needed

        if self._transformation is None:

            new_internal_value = new_value

        else:

            new_internal_value = self._transformation.forward(new_value)

        # If the parameter has changed, update its value and call the callbacks if needed

        if new_internal_value != self._internal_value:

            # Update
            self._internal_value = new_internal_value

            # Call the callbacks (if any)
            for callback in self._callbacks:

                try:

                    callback(self)

                except:

                    raise NotCallableOrErrorInCall("Could not call callback for parameter %s" % self.name)
1154310
def add_variable(var)
      ret = Gurobi.GRBaddvar @ptr, 0, nil, nil, var.coefficient,
                             var.lower_bound, var.upper_bound,
                             gurobi_type(var.type), var.name
      fail if ret != 0

      store_variable var
    end
400167
public void fixupVariables(java.util.Vector vars, int globalsSize)
  {
    for (int i = 0; i < m_patterns.length; i++) 
    {
      m_patterns[i].fixupVariables(vars, globalsSize);
    }
  }
617477
@Override
	public RandomVariable add(double value) {
		return apply(new DoubleUnaryOperator() {
			@Override
			public double applyAsDouble(double x) {
				return x + value;
			}
		});
	}
323801
public SDVariable pow(SDVariable x, SDVariable y) {
        return pow(null, x, y);
    }
963169
@Override
	public RandomVariable add(RandomVariable randomVariable) {
		if(randomVariable.getTypePriority() > this.getTypePriority()) {
			// Check type priority
			return randomVariable.add(this);
		}

		// Set time of this random variable to maximum of time with respect to which measurability is known.
		double newTime = Math.max(time, randomVariable.getFiltrationTime());

		if(isDeterministic() && randomVariable.isDeterministic()) {
			double newValueIfNonStochastic = valueIfNonStochastic + randomVariable.get(0);
			return new RandomVariableFromDoubleArray(newTime, newValueIfNonStochastic);
		}
		else if(isDeterministic()) {
			double[] newRealizations = new double[Math.max(size(), randomVariable.size())];
			for(int i=0; i<newRealizations.length; i++) {
				newRealizations[i]		 = valueIfNonStochastic + randomVariable.get(i);
			}
			return new RandomVariableFromDoubleArray(newTime, newRealizations);
		} else {
			double[] newRealizations = new double[Math.max(size(), randomVariable.size())];
			for(int i=0; i<newRealizations.length; i++) {
				newRealizations[i]		 = realizations[i] + randomVariable.get(i);
			}
			return new RandomVariableFromDoubleArray(newTime, newRealizations);
		}
	}
417496
public final SimpleContext addValue(String variable, Object value) {
		variables.put(variable, value);
		return this;
	}
719791
public static double clamp(double value, double min, double max)
    {
        final double fixed;
        if (value < min)
        {
            fixed = min;
        }
        else if (value > max)
        {
            fixed = max;
        }
        else
        {
            fixed = value;
        }
        return fixed;
    }
1004388
public <T> Future<Boolean> push(String k, T value) {
    Future<Boolean> rv = null;
    while (rv == null) {
      try {
        rv = client.set(k, expiration, value);
      } catch (IllegalStateException ex) {
        // Need to slow down a bit when we start getting rejections.
        try {
          if (rv != null) {
            rv.get(250, TimeUnit.MILLISECONDS);
          } else {
            Thread.sleep(250);
          }
        } catch (InterruptedException ie) {
          Thread.currentThread().interrupt();
        } catch (Exception e2) {
          // Ignore exceptions here. We're just trying to slow
          // down input.
        }
      }

    }
    return rv;
  }
720511
public final void push(int value)
  {

    int ff = m_firstFree;

    if ((ff + 1) >= m_mapSize)
    {
      if (null == m_map)
      {
        m_map = new int[m_blocksize];
        m_mapSize = m_blocksize;
      }
      else
      {
        m_mapSize += m_blocksize;

        int newMap[] = new int[m_mapSize];

        System.arraycopy(m_map, 0, newMap, 0, ff + 1);

        m_map = newMap;
      }
    }

    m_map[ff] = value;

    ff++;

    m_firstFree = ff;
  }