コード例 #1
0
 /// <summary>Initializes a new instance of the <see cref="NLoptConstraint" /> class.
 /// </summary>
 /// <param name="nloptConstraintDescriptor">The <see cref="NLoptConstraintFactory"/> object that has been used as factory of the current object.</param>
 /// <param name="dimension">The dimension of the feasible region.</param>
 /// <param name="constraintName">A <see cref="System.String"/> representation of the constraint, i.e a short name.</param>
 /// <param name="applytoNLoptPtr">A delegate to set the constraint for a specific NLopt algorithm represented by a specific <see cref="NLoptPtr"/> object.</param>
 /// <param name="infoOutputAction">A delegate used to fill a specific <see cref="InfoOutputPackage"/> object.</param>
 internal NLoptConstraint(NLoptConstraintFactory nloptConstraintDescriptor, int dimension, string constraintName, Action <NLoptPtr> applytoNLoptPtr, Action <InfoOutputPackage> infoOutputAction = null)
 {
     m_ConstraintDescriptor = nloptConstraintDescriptor;
     Dimension              = dimension;
     m_ApplyToNLoptPtr      = applytoNLoptPtr;
     m_InfoOutputAction     = infoOutputAction;
     m_StringRepresentation = String.Format("NLopt {0}; dimension: {1}", constraintName, dimension);
 }
コード例 #2
0
        /// <summary>Initializes a new instance of the <see cref="NLoptMultiDimOptimizer" /> class.
        /// </summary>
        /// <param name="algorithm">A value indicating the specific NLopt algorithm.</param>
        /// <param name="abortCondition">The abort (stopping) condition of the NLopt algorithm.</param>
        /// <param name="nloptPtrAdjustment">An optional delegate which will be called in the <c>Create</c> methods for <see cref="IMultiDimOptimizerAlgorithm"/> objects that allows individual adjustments of the internal <see cref="NLoptPtr"/> representation.</param>
        /// <param name="loggerStreamFactory">A factory for <see cref="ILoggerStream"/> objects, i.e. for a logging. Each <see cref="IMultiDimOptimizerAlgorithm"/> object will track the function values in the specified logger.</param>
        /// <remarks>One can use <paramref name="nloptPtrAdjustment"/> to change the Initial step size, initial "population" of random points, set Local/subsidiary optimization algorithm etc. See
        /// the documentation of the NLopt library http://ab-initio.mit.edu/wiki/index.php/NLopt for further details.</remarks>
        public NLoptMultiDimOptimizer(NLoptAlgorithm algorithm, NLoptAbortCondition abortCondition, Action <NLoptPtr> nloptPtrAdjustment = null, Func <IMultiDimOptimizerAlgorithm, ILogger> loggerStreamFactory = null)
        {
            Algorithm     = algorithm;
            Configuration = NLoptConfiguration.Create(algorithm);

            if (abortCondition == null)
            {
                throw new ArgumentNullException("abortCondition");
            }
            AbortCondition = abortCondition;

            m_LongName            = new IdentifierString(NLoptPtr.GetName(algorithm));
            m_Name                = new IdentifierString(algorithm.ToFormatString(EnumStringRepresentationUsage.StringAttribute));
            Constraint            = new NLoptConstraintFactory(this);
            Function              = new NLoptFunctionFactory(this);
            m_nloptPtrAdjustment  = nloptPtrAdjustment;
            m_LoggerStreamFactory = loggerStreamFactory;
        }