Ejemplo n.º 1
0
/** Get tie of parameter number i
 * @param i :: The index of a declared parameter.
 * @return A pointer to the tie
 */
ParameterTie *ParamFunction::getTie(size_t i) const {
  if (i >= nParams()) {
    throw std::out_of_range("ParamFunction parameter index out of range.");
  }
  auto it = std::find_if(m_ties.cbegin(), m_ties.cend(), ReferenceEqual(i));
  if (it != m_ties.cend()) {
    return *it;
  }
  return nullptr;
}
Ejemplo n.º 2
0
/** Removes i-th parameter's tie if it is tied or does nothing.
 * @param i :: The index of the tied parameter.
 * @return True if successfull
 */
bool ParamFunction::removeTie(size_t i) {
  if (i >= nParams()) {
    throw std::out_of_range("ParamFunction parameter index out of range.");
  }
  auto it = std::find_if(m_ties.begin(), m_ties.end(), ReferenceEqual(i));
  if (it != m_ties.end()) {
    delete *it;
    m_ties.erase(it);
    unfix(i);
    return true;
  }
  return false;
}
Ejemplo n.º 3
0
/** Get constraint of parameter number i
 * @param i :: The index of a declared parameter.
 * @return A pointer to the constraint or NULL
 */
IConstraint* TiesFunction::getConstraint(size_t i)const
{
  if (i >= nParams())
  {
    throw std::out_of_range("TiesFunction parameter index out of range.");
  }
  std::vector<IConstraint*>::const_iterator it = std::find_if(m_constraints.begin(),m_constraints.end(),ReferenceEqual(i));
  if (it != m_constraints.end())
  {
    return *it;
  }
  return NULL;
}