/// <summary>Initializes a new instance of the <see cref="BoxTransformationAlgorithm"/> class.
 /// </summary>
 /// <param name="optimizer">The <see cref="MultiDimOptimizer"/> object that serves as factory of the current object and solve optimization problems without constraints.</param>
 /// <param name="boxConstraint">The box constraint.</param>
 internal BoxTransformationAlgorithm(MultiDimOptimizer optimizer, MultiDimRegion.Interval boxConstraint)
 {
     m_Optimizer               = optimizer ?? throw new ArgumentNullException(nameof(optimizer));
     m_BoxConstraint           = boxConstraint ?? throw new ArgumentNullException(nameof(boxConstraint));
     m_TempFunctionArgument    = new double[boxConstraint.Dimension];
     m_InnerOptimizerAlgorithm = optimizer.Create(boxConstraint.Dimension);
 }
Beispiel #2
0
 /// <summary>Creates a new <see cref="MultiDimOptimizer.IConstraint"/> object.
 /// </summary>
 /// <param name="boxConstraint">The specific box constraint, i.e. the argument of the objective function are constrainted to lie in a specified hyperrectangle.</param>
 /// <returns>A specific <see cref="MultiDimOptimizer.IConstraint"/> object with respect to the specified optimization algorithm.</returns>
 /// <exception cref="InvalidOperationException">Thrown, if the optimization algorithm does not support this kind of constraints.</exception>
 public MultiDimOptimizer.IConstraint Create(MultiDimRegion.Interval boxConstraint)
 {
     if (SupportedConstraints.HasFlag(ConstraintType.Box) == true)
     {
         return(new MultiDimOptimizerConstraint(this, boxConstraint));
     }
     throw new InvalidOperationException();
 }
Beispiel #3
0
 /// <summary>Creates a new <see cref="FeasibleSetProjection"/> object.
 /// </summary>
 /// <param name="boxConstraints">The box constraints.</param>
 public static FeasibleSetProjection Create(MultiDimRegion.Interval boxConstraints)
 {
     /* Projection onto box constraints: P_X(p) is defined via [P_X(p)]_j = p_j if lowerBound_j < p_j < upperBound_j; [P_X(p)]_j = upperBound_j, if p_j >= upperBound_j etc. */
     return(new FeasibleSetProjection(boxConstraints.Dimension, p =>
     {
         for (int j = 0; j < boxConstraints.Dimension; j++)
         {
             var p_j = p[j];
             if (p_j <= boxConstraints.LowerBounds[j])
             {
                 p[j] = boxConstraints.LowerBounds[j];
             }
             else if (p_j >= boxConstraints.UpperBounds[j])
             {
                 p[j] = boxConstraints.UpperBounds[j];
             }
         }
     }));
 }
 /// <summary>Creates a new <see cref="NLoptConstraint"/> object.
 /// </summary>
 /// <param name="boxConstraint">The specific box constraint, i.e. the argument of the objective function are constrainted to lie in a specified hyperrectangle.</param>
 /// <returns>A specific <see cref="NLoptConstraint"/> object with respect to the specified optimization algorithm.</returns>
 /// <exception cref="InvalidOperationException">Thrown, if the optimization algorithm does not support this kind of constraints.</exception>
 public NLoptConstraint Create(MultiDimRegion.Interval boxConstraint)
 {
     if (boxConstraint == null)
     {
         throw new ArgumentNullException(nameof(boxConstraint));
     }
     if (nloptMultiDimOptimizer.Configuration.BoxConstraintRequirement == NLoptBoundConstraintRequirement.None)
     {
         throw new InvalidOperationException("The NLopt algorithm does not support box constraints");
     }
     return(new NLoptConstraint(this,
                                boxConstraint.Dimension,
                                "Box constraint",
                                nloptPtr =>
     {
         nloptPtr.SetLowerBounds(boxConstraint.LowerBounds.ToArray());
         nloptPtr.SetUpperBounds(boxConstraint.UpperBounds.ToArray());
     },
                                infoOutputPackage => { }));
 }
 /// <summary>Creates a new <see cref="MultiDimOptimizer.IConstraint"/> object.
 /// </summary>
 /// <param name="boxConstraint">The specific box constraint, i.e. the argument of the objective function are constrainted to lie in a specified hyperrectangle.</param>
 /// <returns>A specific <see cref="MultiDimOptimizer.IConstraint"/> object with respect to the specified optimization algorithm.</returns>
 /// <exception cref="InvalidOperationException">Thrown, if the optimization algorithm does not support this kind of constraints.</exception>
 MultiDimOptimizer.IConstraint MultiDimOptimizer.IConstraintFactory.Create(MultiDimRegion.Interval boxConstraint)
 {
     return(this.Create(boxConstraint));
 }
Beispiel #6
0
 /// <summary>Initializes a new instance of the <see cref="Algorithm"/> class.
 /// </summary>
 /// <param name="optimizer">The <see cref="LevenbergMarquardtOptimizer"/> object that serves as factory of the current object.</param>
 /// <param name="boxConstraints">The box constraints.</param>
 internal Algorithm(LevenbergMarquardtOptimizer optimizer, MultiDimRegion.Interval boxConstraints)
 {
     m_Optimizer = optimizer ?? throw new ArgumentNullException(nameof(optimizer));
     m_ProjectionOntoFeasibleSet = FeasibleSetProjection.Create(boxConstraints);
 }