/// <summary>
        /// Constructor for creating a new Ipopt Problem object.  This function
        /// returns an object that can be passed to the IpoptSolve call.  It
        /// contains the basic definition of the optimization problem, such
        /// as number of variables and constraints, bounds on variables and
        /// constraints, information about the derivatives, and the callback
        /// function for the computation of the optimization problem
        /// functions and derivatives.  During this call, the options file
        /// PARAMS.DAT is read as well.
        /// </summary>
        /// <param name="n">Number of optimization variables</param>
        /// <param name="x_L">Lower bounds on variables. This array of size n is copied internally, so that the
        /// caller can change the incoming data after return without that IpoptProblem is modified.  Any value
        /// less or equal than the number specified by option 'nlp_lower_bound_inf' is interpreted to be minus infinity.</param>
        /// <param name="x_U">Upper bounds on variables. This array of size n is copied internally, so that the
        /// caller can change the incoming data after return without that IpoptProblem is modified.  Any value
        /// greater or equal than the number specified by option 'nlp_upper_bound_inf' is interpreted to be plus infinity.</param>
        /// <param name="m">Number of constraints.</param>
        /// <param name="g_L">Lower bounds on constraints. This array of size m is copied internally, so that the
        /// caller can change the incoming data after return without that IpoptProblem is modified.  Any value
        /// less or equal than the number specified by option 'nlp_lower_bound_inf' is interpreted to be minus infinity.</param>
        /// <param name="g_U">Upper bounds on constraints. This array of size m is copied internally, so that the
        /// caller can change the incoming data after return without that IpoptProblem is modified.  Any value
        /// greater or equal than the number specified by option 'nlp_upper_bound_inf' is interpreted to be plus infinity.</param>
        /// <param name="nele_jac">Number of non-zero elements in constraint Jacobian.</param>
        /// <param name="nele_hess">Number of non-zero elements in Hessian of Lagrangian.</param>
        /// <param name="eval_f">Callback function for evaluating objective function</param>
        /// <param name="eval_g">Callback function for evaluating constraint functions</param>
        /// <param name="eval_grad_f">Callback function for evaluating gradient of objective function</param>
        /// <param name="eval_jac_g">Callback function for evaluating Jacobian of constraint functions</param>
        /// <param name="eval_h">Callback function for evaluating Hessian of Lagrangian function</param>
        public Ipopt(int n, double[] x_L, double[] x_U, int m, double[] g_L, double[] g_U, int nele_jac, int nele_hess,
                     EvaluateObjectiveDelegate eval_f, EvaluateConstraintsDelegate eval_g, EvaluateObjectiveGradientDelegate eval_grad_f,
                     EvaluateJacobianDelegate eval_jac_g, EvaluateHessianDelegate eval_h)
        {
            unsafe
            {
                fixed(double *p_x_L = x_L, p_x_U = x_U, p_g_L = g_L, p_g_U = g_U)
                {
                    m_eval_f       = new ObjectiveEvaluator(eval_f).Evaluate;
                    m_eval_g       = new ConstraintsEvaluator(eval_g).Evaluate;
                    m_eval_grad_f  = new ObjectiveGradientEvaluator(eval_grad_f).Evaluate;
                    m_eval_jac_g   = new JacobianEvaluator(eval_jac_g).Evaluate;
                    m_eval_h       = new HessianEvaluator(eval_h).Evaluate;
                    m_intermediate = null;

                    m_problem = CreateIpoptProblem(n, p_x_L, p_x_U, m, p_g_L, p_g_U, nele_jac, nele_hess, 0,
                                                   m_eval_f, m_eval_g, m_eval_grad_f, m_eval_jac_g, m_eval_h);

                    if (m_problem == IntPtr.Zero)
                    {
                        throw new ArgumentException("Failed to initialize IPOPT problem");
                    }
                }
            }

            m_disposed = false;
        }
示例#2
0
        /// <summary>
        /// Constructor for creating a new Ipopt Problem object using native
        /// function delegates. This function
        /// initializes an object that can be passed to the IpoptSolve call.  It
        /// contains the basic definition of the optimization problem, such
        /// as number of variables and constraints, bounds on variables and
        /// constraints, information about the derivatives, and the callback
        /// function for the computation of the optimization problem
        /// functions and derivatives.  During this call, the options file
        /// ipopt.opt is read as well.
        /// </summary>
        /// <param name="n">Number of optimization variables</param>
        /// <param name="x_L">Lower bounds on variables. This array of size n is copied internally, so that the
        /// caller can change the incoming data after return without that IpoptProblem is modified.  Any value
        /// less or equal than the number specified by option 'nlp_lower_bound_inf' is interpreted to be minus infinity.</param>
        /// <param name="x_U">Upper bounds on variables. This array of size n is copied internally, so that the
        /// caller can change the incoming data after return without that IpoptProblem is modified.  Any value
        /// greater or equal than the number specified by option 'nlp_upper_bound_inf' is interpreted to be plus infinity.</param>
        /// <param name="m">Number of constraints.</param>
        /// <param name="g_L">Lower bounds on constraints. This array of size m is copied internally, so that the
        /// caller can change the incoming data after return without that IpoptProblem is modified.  Any value
        /// less or equal than the number specified by option 'nlp_lower_bound_inf' is interpreted to be minus infinity.</param>
        /// <param name="g_U">Upper bounds on constraints. This array of size m is copied internally, so that the
        /// caller can change the incoming data after return without that IpoptProblem is modified.  Any value
        /// greater or equal than the number specified by option 'nlp_upper_bound_inf' is interpreted to be plus infinity.</param>
        /// <param name="nele_jac">Number of non-zero elements in constraint Jacobian.</param>
        /// <param name="nele_hess">Number of non-zero elements in Hessian of Lagrangian.</param>
        /// <param name="eval_f_cb">Native callback function for evaluating objective function</param>
        /// <param name="eval_g_cb">Native callback function for evaluating constraint functions</param>
        /// <param name="eval_grad_f_cb">Native callback function for evaluating gradient of objective function</param>
        /// <param name="eval_jac_g_cb">Native callback function for evaluating Jacobian of constraint functions</param>
        /// <param name="eval_h_cb">Native callback function for evaluating Hessian of Lagrangian function</param>
        public IpoptProblem(int n, double[] x_L, double[] x_U, int m, double[] g_L, double[] g_U, int nele_jac, int nele_hess,
                            Eval_F_CB eval_f_cb, Eval_G_CB eval_g_cb, Eval_Grad_F_CB eval_grad_f_cb, Eval_Jac_G_CB eval_jac_g_cb, Eval_H_CB eval_h_cb)
        {
            m_eval_f_cb       = eval_f_cb;
            m_eval_g_cb       = eval_g_cb;
            m_eval_grad_f_cb  = eval_grad_f_cb;
            m_eval_jac_g_cb   = eval_jac_g_cb;
            m_eval_h_cb       = eval_h_cb;
            m_intermediate_cb = null;

            m_problem = IpoptAdapter.CreateIpoptProblem(n, x_L, x_U, m, g_L, g_U, nele_jac, nele_hess, IpoptIndexStyle.C,
                                                        m_eval_f_cb, m_eval_g_cb, m_eval_grad_f_cb, m_eval_jac_g_cb, m_eval_h_cb);

            m_disposed = false;
        }
示例#3
0
        /// <summary>
        /// Constructor for creating a new Ipopt Problem object using managed
        /// function delegates.  This function
        /// initializes an object that can be passed to the IpoptSolve call.  It
        /// contains the basic definition of the optimization problem, such
        /// as number of variables and constraints, bounds on variables and
        /// constraints, information about the derivatives, and the callback
        /// function for the computation of the optimization problem
        /// functions and derivatives.  During this call, the options file
        /// ipopt.opt is read as well.
        /// </summary>
        /// <param name="n">Number of optimization variables</param>
        /// <param name="x_L">Lower bounds on variables. This array of size n is copied internally, so that the
        /// caller can change the incoming data after return without that IpoptProblem is modified.  Any value
        /// less or equal than the number specified by option 'nlp_lower_bound_inf' is interpreted to be minus infinity.</param>
        /// <param name="x_U">Upper bounds on variables. This array of size n is copied internally, so that the
        /// caller can change the incoming data after return without that IpoptProblem is modified.  Any value
        /// greater or equal than the number specified by option 'nlp_upper_bound_inf' is interpreted to be plus infinity.</param>
        /// <param name="m">Number of constraints.</param>
        /// <param name="g_L">Lower bounds on constraints. This array of size m is copied internally, so that the
        /// caller can change the incoming data after return without that IpoptProblem is modified.  Any value
        /// less or equal than the number specified by option 'nlp_lower_bound_inf' is interpreted to be minus infinity.</param>
        /// <param name="g_U">Upper bounds on constraints. This array of size m is copied internally, so that the
        /// caller can change the incoming data after return without that IpoptProblem is modified.  Any value
        /// greater or equal than the number specified by option 'nlp_upper_bound_inf' is interpreted to be plus infinity.</param>
        /// <param name="nele_jac">Number of non-zero elements in constraint Jacobian.</param>
        /// <param name="nele_hess">Number of non-zero elements in Hessian of Lagrangian.</param>
        /// <param name="eval_f_cb">Managed callback function for evaluating objective function</param>
        /// <param name="eval_g_cb">Managed callback function for evaluating constraint functions</param>
        /// <param name="eval_grad_f_cb">Managed callback function for evaluating gradient of objective function</param>
        /// <param name="eval_jac_g_cb">Managed callback function for evaluating Jacobian of constraint functions</param>
        /// <param name="eval_h_cb">Managed callback function for evaluating Hessian of Lagrangian function</param>
        public IpoptProblem(int n, double[] x_L, double[] x_U, int m, double[] g_L, double[] g_U, int nele_jac, int nele_hess,
                            EvaluateObjectiveDelegate eval_f_cb, EvaluateConstraintsDelegate eval_g_cb, EvaluateObjectiveGradientDelegate eval_grad_f_cb,
                            EvaluateJacobianDelegate eval_jac_g_cb, EvaluateHessianDelegate eval_h_cb)
        {
            m_eval_f_cb       = new ObjectiveEvaluator(eval_f_cb).Evaluate;
            m_eval_g_cb       = new ConstraintsEvaluator(eval_g_cb).Evaluate;
            m_eval_grad_f_cb  = new ObjectiveGradientEvaluator(eval_grad_f_cb).Evaluate;
            m_eval_jac_g_cb   = new JacobianEvaluator(eval_jac_g_cb).Evaluate;
            m_eval_h_cb       = new HessianEvaluator(eval_h_cb).Evaluate;
            m_intermediate_cb = null;

            m_problem = IpoptAdapter.CreateIpoptProblem(n, x_L, x_U, m, g_L, g_U, nele_jac, nele_hess, IpoptIndexStyle.C,
                                                        m_eval_f_cb, m_eval_g_cb, m_eval_grad_f_cb, m_eval_jac_g_cb, m_eval_h_cb);

            m_disposed = false;
        }
示例#4
0
        /// <summary>
        /// Constructor for creating a subclassed Ipopt Problem object using managed or
        /// native function delegates. This is the preferred constructor when
        /// subclassing IpoptProblem. Prerequisite is that the managed/native optimization
        /// function delegates are implemented in the inheriting class.
        /// This function
        /// initializes an object that can be passed to the IpoptSolve call.  It
        /// contains the basic definition of the optimization problem, such
        /// as number of variables and constraints, bounds on variables and
        /// constraints, information about the derivatives, and the callback
        /// function for the computation of the optimization problem
        /// functions and derivatives. During this call, the options file
        /// ipopt.opt is read as well.
        /// </summary>
        /// <param name="n">Number of optimization variables</param>
        /// <param name="x_L">Lower bounds on variables. This array of size n is copied internally, so that the
        /// caller can change the incoming data after return without that IpoptProblem is modified.  Any value
        /// less or equal than the number specified by option 'nlp_lower_bound_inf' is interpreted to be minus infinity.</param>
        /// <param name="x_U">Upper bounds on variables. This array of size n is copied internally, so that the
        /// caller can change the incoming data after return without that IpoptProblem is modified.  Any value
        /// greater or equal than the number specified by option 'nlp_upper_bound_inf' is interpreted to be plus infinity.</param>
        /// <param name="m">Number of constraints.</param>
        /// <param name="g_L">Lower bounds on constraints. This array of size m is copied internally, so that the
        /// caller can change the incoming data after return without that IpoptProblem is modified.  Any value
        /// less or equal than the number specified by option 'nlp_lower_bound_inf' is interpreted to be minus infinity.</param>
        /// <param name="g_U">Upper bounds on constraints. This array of size m is copied internally, so that the
        /// caller can change the incoming data after return without that IpoptProblem is modified.  Any value
        /// greater or equal than the number specified by option 'nlp_upper_bound_inf' is interpreted to be plus infinity.</param>
        /// <param name="nele_jac">Number of non-zero elements in constraint Jacobian.</param>
        /// <param name="nele_hess">Number of non-zero elements in Hessian of Lagrangian.</param>
        /// <param name="useNativeCallbackFunctions">If set to true, native callback functions are used to setup
        /// the Ipopt problem; if set to false, managed callback functions are used.</param>
        /// <param name="useHessianApproximation">If set to true, the Ipopt optimizer creates a limited memory
        /// Hessian approximation and the eval_h (managed or native) method need not be implemented.
        /// If set to false, an exact Hessian should be evaluated using the appropriate Hessian evaluation method.</param>
        /// <param name="useIntermediateCallback">If set to true, the intermediate method (managed or native) will be called
        /// after each full iteration. If false, the intermediate callback function will not be called.</param>
        protected IpoptProblem(int n, double[] x_L, double[] x_U, int m, double[] g_L, double[] g_U, int nele_jac, int nele_hess,
                               bool useNativeCallbackFunctions = false, bool useHessianApproximation = false, bool useIntermediateCallback = false)
        {
            if (useNativeCallbackFunctions)
            {
                m_eval_f_cb      = eval_f;
                m_eval_g_cb      = eval_g;
                m_eval_grad_f_cb = eval_grad_f;
                m_eval_jac_g_cb  = eval_jac_g;
                m_eval_h_cb      = eval_h;
            }
            else
            {
                m_eval_f_cb      = new ObjectiveEvaluator(eval_f).Evaluate;
                m_eval_g_cb      = new ConstraintsEvaluator(eval_g).Evaluate;
                m_eval_grad_f_cb = new ObjectiveGradientEvaluator(eval_grad_f).Evaluate;
                m_eval_jac_g_cb  = new JacobianEvaluator(eval_jac_g).Evaluate;
                m_eval_h_cb      = new HessianEvaluator(eval_h).Evaluate;
            }
            m_intermediate_cb = null;

            m_problem = IpoptAdapter.CreateIpoptProblem(n, x_L, x_U, m, g_L, g_U, nele_jac, nele_hess, IpoptIndexStyle.C,
                                                        m_eval_f_cb, m_eval_g_cb, m_eval_grad_f_cb, m_eval_jac_g_cb, m_eval_h_cb);

            if (useHessianApproximation)
            {
                AddOption("hessian_approximation", "limited-memory");
            }

            if (useIntermediateCallback)
            {
                if (useNativeCallbackFunctions)
                {
                    SetIntermediateCallback((Intermediate_CB)intermediate);
                }
                else
                {
                    SetIntermediateCallback((IntermediateDelegate)intermediate);
                }
            }

            m_disposed = false;
        }
示例#5
0
        /// <summary>
        /// Constructor for creating a subclassed Ipopt Problem object using managed or
        /// native function delegates. This is the preferred constructor when
        /// subclassing IpoptProblem. Prerequisite is that the managed/native optimization 
        /// function delegates are implemented in the inheriting class.
        /// This function
        /// initializes an object that can be passed to the IpoptSolve call.  It
        /// contains the basic definition of the optimization problem, such
        /// as number of variables and constraints, bounds on variables and
        /// constraints, information about the derivatives, and the callback
        /// function for the computation of the optimization problem
        /// functions and derivatives. During this call, the options file
        /// ipopt.opt is read as well.
        /// </summary>
        /// <param name="n">Number of optimization variables</param>
        /// <param name="x_L">Lower bounds on variables. This array of size n is copied internally, so that the
        /// caller can change the incoming data after return without that IpoptProblem is modified.  Any value 
        /// less or equal than the number specified by option 'nlp_lower_bound_inf' is interpreted to be minus infinity.</param>
        /// <param name="x_U">Upper bounds on variables. This array of size n is copied internally, so that the
        /// caller can change the incoming data after return without that IpoptProblem is modified.  Any value 
        /// greater or equal than the number specified by option 'nlp_upper_bound_inf' is interpreted to be plus infinity.</param>
        /// <param name="m">Number of constraints.</param>
        /// <param name="g_L">Lower bounds on constraints. This array of size m is copied internally, so that the
        /// caller can change the incoming data after return without that IpoptProblem is modified.  Any value 
        /// less or equal than the number specified by option 'nlp_lower_bound_inf' is interpreted to be minus infinity.</param>
        /// <param name="g_U">Upper bounds on constraints. This array of size m is copied internally, so that the
        /// caller can change the incoming data after return without that IpoptProblem is modified.  Any value 
        /// greater or equal than the number specified by option 'nlp_upper_bound_inf' is interpreted to be plus infinity.</param>
        /// <param name="nele_jac">Number of non-zero elements in constraint Jacobian.</param>
        /// <param name="nele_hess">Number of non-zero elements in Hessian of Lagrangian.</param>
        /// <param name="useNativeCallbackFunctions">If set to true, native callback functions are used to setup
        /// the Ipopt problem; if set to false, managed callback functions are used.</param>
        /// <param name="useHessianApproximation">If set to true, the Ipopt optimizer creates a limited memory
        /// Hessian approximation and the eval_h (managed or native) method need not be implemented. 
        /// If set to false, an exact Hessian should be evaluated using the appropriate Hessian evaluation method.</param>
        /// <param name="useIntermediateCallback">If set to true, the intermediate method (managed or native) will be called 
        /// after each full iteration. If false, the intermediate callback function will not be called.</param>
        protected IpoptProblem(int n, double[] x_L, double[] x_U, int m, double[] g_L, double[] g_U, int nele_jac, int nele_hess,
            bool useNativeCallbackFunctions = false, bool useHessianApproximation = false, bool useIntermediateCallback = false)
        {
            if (useNativeCallbackFunctions)
            {
                m_eval_f_cb = eval_f;
                m_eval_g_cb = eval_g;
                m_eval_grad_f_cb = eval_grad_f;
                m_eval_jac_g_cb = eval_jac_g;
                m_eval_h_cb = eval_h;
            }
            else
            {
                m_eval_f_cb = new ObjectiveEvaluator(eval_f).Evaluate;
                m_eval_g_cb = new ConstraintsEvaluator(eval_g).Evaluate;
                m_eval_grad_f_cb = new ObjectiveGradientEvaluator(eval_grad_f).Evaluate;
                m_eval_jac_g_cb = new JacobianEvaluator(eval_jac_g).Evaluate;
                m_eval_h_cb = new HessianEvaluator(eval_h).Evaluate;
            }
            m_intermediate_cb = null;

            m_problem = IpoptAdapter.CreateIpoptProblem(n, x_L, x_U, m, g_L, g_U, nele_jac, nele_hess, IpoptIndexStyle.C,
                                           m_eval_f_cb, m_eval_g_cb, m_eval_grad_f_cb, m_eval_jac_g_cb, m_eval_h_cb);

            if (useHessianApproximation) AddOption("hessian_approximation", "limited-memory");

            if (useIntermediateCallback)
            {
                if (useNativeCallbackFunctions)
                    SetIntermediateCallback((Intermediate_CB)intermediate);
                else
                    SetIntermediateCallback((IntermediateDelegate)intermediate);
            }

            m_disposed = false;
        }
示例#6
0
        /// <summary>
        /// Constructor for creating a new Ipopt Problem object using native
        /// function delegates. This function
        /// initializes an object that can be passed to the IpoptSolve call.  It
        /// contains the basic definition of the optimization problem, such
        /// as number of variables and constraints, bounds on variables and
        /// constraints, information about the derivatives, and the callback
        /// function for the computation of the optimization problem
        /// functions and derivatives.  During this call, the options file
        /// ipopt.opt is read as well.
        /// </summary>
        /// <param name="n">Number of optimization variables</param>
        /// <param name="x_L">Lower bounds on variables. This array of size n is copied internally, so that the
        /// caller can change the incoming data after return without that IpoptProblem is modified.  Any value 
        /// less or equal than the number specified by option 'nlp_lower_bound_inf' is interpreted to be minus infinity.</param>
        /// <param name="x_U">Upper bounds on variables. This array of size n is copied internally, so that the
        /// caller can change the incoming data after return without that IpoptProblem is modified.  Any value 
        /// greater or equal than the number specified by option 'nlp_upper_bound_inf' is interpreted to be plus infinity.</param>
        /// <param name="m">Number of constraints.</param>
        /// <param name="g_L">Lower bounds on constraints. This array of size m is copied internally, so that the
        /// caller can change the incoming data after return without that IpoptProblem is modified.  Any value 
        /// less or equal than the number specified by option 'nlp_lower_bound_inf' is interpreted to be minus infinity.</param>
        /// <param name="g_U">Upper bounds on constraints. This array of size m is copied internally, so that the
        /// caller can change the incoming data after return without that IpoptProblem is modified.  Any value 
        /// greater or equal than the number specified by option 'nlp_upper_bound_inf' is interpreted to be plus infinity.</param>
        /// <param name="nele_jac">Number of non-zero elements in constraint Jacobian.</param>
        /// <param name="nele_hess">Number of non-zero elements in Hessian of Lagrangian.</param>
        /// <param name="eval_f_cb">Native callback function for evaluating objective function</param>
        /// <param name="eval_g_cb">Native callback function for evaluating constraint functions</param>
        /// <param name="eval_grad_f_cb">Native callback function for evaluating gradient of objective function</param>
        /// <param name="eval_jac_g_cb">Native callback function for evaluating Jacobian of constraint functions</param>
        /// <param name="eval_h_cb">Native callback function for evaluating Hessian of Lagrangian function</param>
        public IpoptProblem(int n, double[] x_L, double[] x_U, int m, double[] g_L, double[] g_U, int nele_jac, int nele_hess,
            Eval_F_CB eval_f_cb, Eval_G_CB eval_g_cb, Eval_Grad_F_CB eval_grad_f_cb, Eval_Jac_G_CB eval_jac_g_cb, Eval_H_CB eval_h_cb)
        {
            m_eval_f_cb = eval_f_cb;
            m_eval_g_cb = eval_g_cb;
            m_eval_grad_f_cb = eval_grad_f_cb;
            m_eval_jac_g_cb = eval_jac_g_cb;
            m_eval_h_cb = eval_h_cb;
            m_intermediate_cb = null;

            m_problem = IpoptAdapter.CreateIpoptProblem(n, x_L, x_U, m, g_L, g_U, nele_jac, nele_hess, IpoptIndexStyle.C,
                m_eval_f_cb, m_eval_g_cb, m_eval_grad_f_cb, m_eval_jac_g_cb, m_eval_h_cb);
            
            m_disposed = false;
        }
示例#7
0
        /// <summary>
        /// Constructor for creating a new Ipopt Problem object using managed 
        /// function delegates.  This function
        /// initializes an object that can be passed to the IpoptSolve call.  It
        /// contains the basic definition of the optimization problem, such
        /// as number of variables and constraints, bounds on variables and
        /// constraints, information about the derivatives, and the callback
        /// function for the computation of the optimization problem
        /// functions and derivatives.  During this call, the options file
        /// ipopt.opt is read as well.
        /// </summary>
        /// <param name="n">Number of optimization variables</param>
        /// <param name="x_L">Lower bounds on variables. This array of size n is copied internally, so that the
        /// caller can change the incoming data after return without that IpoptProblem is modified.  Any value 
        /// less or equal than the number specified by option 'nlp_lower_bound_inf' is interpreted to be minus infinity.</param>
        /// <param name="x_U">Upper bounds on variables. This array of size n is copied internally, so that the
        /// caller can change the incoming data after return without that IpoptProblem is modified.  Any value 
        /// greater or equal than the number specified by option 'nlp_upper_bound_inf' is interpreted to be plus infinity.</param>
        /// <param name="m">Number of constraints.</param>
        /// <param name="g_L">Lower bounds on constraints. This array of size m is copied internally, so that the
        /// caller can change the incoming data after return without that IpoptProblem is modified.  Any value 
        /// less or equal than the number specified by option 'nlp_lower_bound_inf' is interpreted to be minus infinity.</param>
        /// <param name="g_U">Upper bounds on constraints. This array of size m is copied internally, so that the
        /// caller can change the incoming data after return without that IpoptProblem is modified.  Any value 
        /// greater or equal than the number specified by option 'nlp_upper_bound_inf' is interpreted to be plus infinity.</param>
        /// <param name="nele_jac">Number of non-zero elements in constraint Jacobian.</param>
        /// <param name="nele_hess">Number of non-zero elements in Hessian of Lagrangian.</param>
        /// <param name="eval_f_cb">Managed callback function for evaluating objective function</param>
        /// <param name="eval_g_cb">Managed callback function for evaluating constraint functions</param>
        /// <param name="eval_grad_f_cb">Managed callback function for evaluating gradient of objective function</param>
        /// <param name="eval_jac_g_cb">Managed callback function for evaluating Jacobian of constraint functions</param>
        /// <param name="eval_h_cb">Managed callback function for evaluating Hessian of Lagrangian function</param>
        public IpoptProblem(int n, double[] x_L, double[] x_U, int m, double[] g_L, double[] g_U, int nele_jac, int nele_hess,
            EvaluateObjectiveDelegate eval_f_cb, EvaluateConstraintsDelegate eval_g_cb, EvaluateObjectiveGradientDelegate eval_grad_f_cb,
            EvaluateJacobianDelegate eval_jac_g_cb, EvaluateHessianDelegate eval_h_cb)
        {
            m_eval_f_cb = new ObjectiveEvaluator(eval_f_cb).Evaluate;
            m_eval_g_cb = new ConstraintsEvaluator(eval_g_cb).Evaluate;
            m_eval_grad_f_cb = new ObjectiveGradientEvaluator(eval_grad_f_cb).Evaluate;
            m_eval_jac_g_cb = new JacobianEvaluator(eval_jac_g_cb).Evaluate;
            m_eval_h_cb = new HessianEvaluator(eval_h_cb).Evaluate;
            m_intermediate_cb = null;

            m_problem = IpoptAdapter.CreateIpoptProblem(n, x_L, x_U, m, g_L, g_U, nele_jac, nele_hess, IpoptIndexStyle.C,
                m_eval_f_cb, m_eval_g_cb, m_eval_grad_f_cb, m_eval_jac_g_cb, m_eval_h_cb);

            m_disposed = false;
        }
示例#8
0
 public static extern IntPtr CreateIpoptProblem(int n, double[] x_L, double[] x_U, int m, double[] g_L, double[] g_U,
                                                int nele_jac, int nele_hess, IpoptIndexStyle index_style,
                                                Eval_F_CB eval_f, Eval_G_CB eval_g, Eval_Grad_F_CB eval_grad_f, Eval_Jac_G_CB eval_jac_g, Eval_H_CB eval_h);
示例#9
0
        public static extern IntPtr CreateIpoptProblem(int n, double[] x_L, double[] x_U, int m, double[] g_L, double[] g_U, 
			int nele_jac, int nele_hess, IpoptIndexStyle index_style, 
			Eval_F_CB eval_f, Eval_G_CB eval_g, Eval_Grad_F_CB eval_grad_f, Eval_Jac_G_CB eval_jac_g, Eval_H_CB eval_h);
示例#10
0
 unsafe private static extern IntPtr CreateIpoptProblem(int n, double *x_L, double *x_U, int m, double *g_L, double *g_U, int nele_jac,
                                                        int nele_hess, int index_style, Eval_F_CB eval_f, Eval_G_CB eval_g, Eval_Grad_F_CB eval_grad_f, Eval_Jac_G_CB eval_jac_g, Eval_H_CB eval_h);
示例#11
0
 /// <summary>
 /// This function returns an object that can be passed to the IpoptSolve call.  It
 /// contains the basic definition of the optimization problem, such
 /// as number of variables and constraints, bounds on variables and
 /// constraints, information about the derivatives, and the callback
 /// function for the computation of the optimization problem
 /// functions and derivatives.  During this call, the options file
 /// ipopt.opt is read as well.
 /// </summary>
 /// <param name="n">Number of optimization variables</param>
 /// <param name="x_L">Lower bounds on variables. This array of size n is copied internally, so that the
 /// caller can change the incoming data after return without that IpoptProblem is modified.  Any value 
 /// less or equal than the number specified by option 'nlp_lower_bound_inf' is interpreted to be minus infinity.</param>
 /// <param name="x_U">Upper bounds on variables. This array of size n is copied internally, so that the
 /// caller can change the incoming data after return without that IpoptProblem is modified.  Any value 
 /// greater or equal than the number specified by option 'nlp_upper_bound_inf' is interpreted to be plus infinity.</param>
 /// <param name="m">Number of constraints.</param>
 /// <param name="g_L">Lower bounds on constraints. This array of size m is copied internally, so that the
 /// caller can change the incoming data after return without that IpoptProblem is modified.  Any value 
 /// less or equal than the number specified by option 'nlp_lower_bound_inf' is interpreted to be minus infinity.</param>
 /// <param name="g_U">Upper bounds on constraints. This array of size m is copied internally, so that the
 /// caller can change the incoming data after return without that IpoptProblem is modified.  Any value 
 /// greater or equal than the number specified by option 'nlp_upper_bound_inf' is interpreted to be plus infinity.</param>
 /// <param name="nele_jac">Number of non-zero elements in constraint Jacobian.</param>
 /// <param name="nele_hess">Number of non-zero elements in Hessian of Lagrangian.</param>
 /// <param name="index_style">Indexing style for iRow & jCol, 0 for C style, 1 for Fortran style</param>
 /// <param name="eval_f">Callback function for evaluating objective function</param>
 /// <param name="eval_g">Callback function for evaluating constraint functions</param>
 /// <param name="eval_grad_f">Callback function for evaluating gradient of objective function</param>
 /// <param name="eval_jac_g">Callback function for evaluating Jacobian of constraint functions</param>
 /// <param name="eval_h">Callback function for evaluating Hessian of Lagrangian function</param>
 public static IntPtr CreateIpoptProblem(int n, double[] x_L, double[] x_U, int m, double[] g_L, double[] g_U,
     int nele_jac, int nele_hess, IpoptIndexStyle index_style,
     Eval_F_CB eval_f, Eval_G_CB eval_g, Eval_Grad_F_CB eval_grad_f, Eval_Jac_G_CB eval_jac_g, Eval_H_CB eval_h)
 {
     if (IntPtr.Size == 4)
     {
         return IpoptAdapter32.CreateIpoptProblem(n, x_L, x_U, m, g_L, g_U, nele_jac, nele_hess, index_style, eval_f, eval_g, eval_grad_f, eval_jac_g, eval_h);
     }
     else if (IntPtr.Size == 8)
     {
         return IpoptAdapter64.CreateIpoptProblem(n, x_L, x_U, m, g_L, g_U, nele_jac, nele_hess, index_style, eval_f, eval_g, eval_grad_f, eval_jac_g, eval_h);
     }
     else
     {
         throw new NotSupportedException();
     }
 }