1 /* cobyla : contrained optimization by linear approximation */
4 * Copyright (c) 1992, Michael J. D. Powell (M.J.D.Powell@damtp.cam.ac.uk)
5 * Copyright (c) 2004, Jean-Sebastien Roy (js@jeannot.org)
7 * Permission is hereby granted, free of charge, to any person obtaining a
8 * copy of this software and associated documentation files (the
9 * "Software"), to deal in the Software without restriction, including
10 * without limitation the rights to use, copy, modify, merge, publish,
11 * distribute, sublicense, and/or sell copies of the Software, and to
12 * permit persons to whom the Software is furnished to do so, subject to
13 * the following conditions:
15 * The above copyright notice and this permission notice shall be included
16 * in all copies or substantial portions of the Software.
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
19 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
21 * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
22 * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
23 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
24 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
28 * This software is a C version of COBYLA2, a contrained optimization by linear
29 * approximation package developed by Michael J. D. Powell in Fortran.
31 * The original source code can be found at :
32 * http://plato.la.asu.edu/topics/problems/nlores.html
35 /* $Jeannot: cobyla.h,v 1.10 2004/04/18 09:51:37 js Exp $ */
41 #include "nlopt-util.h"
46 #endif /* __cplusplus */
52 COBYLA_MSG_NONE = 0, /* No messages */
53 COBYLA_MSG_EXIT = 1, /* Exit reasons */
54 COBYLA_MSG_ITER = 2, /* Rho and Sigma changes */
55 COBYLA_MSG_INFO = 3, /* Informational messages */
59 * A function as required by cobyla
60 * state is a void pointer provided to the function at each call
62 * n : the number of variables
63 * m : the number of constraints
64 * x : on input, then vector of variables (should not be modified)
65 * f : on output, the value of the function
66 * con : on output, the value of the constraints (vector of size m)
67 * state : on input, the value of the state variable as provided to cobyla
69 * COBYLA will try to make all the values of the constraints positive.
70 * So if you want to input a constraint j such as x[i] <= MAX, set:
72 * The function must returns 0 if no error occurs or 1 to immediately end the
76 typedef int cobyla_function(int n, int m, double *x, double *f, double *con,
80 * cobyla : minimize a function subject to constraints
82 * n : number of variables (>=0)
83 * m : number of constraints (>=0)
84 * x : on input, initial estimate ; on output, the solution
85 * minf : on output, minimum objective function
86 * rhobeg : a reasonable initial change to the variables
87 * stop : the NLopt stopping criteria
88 * lb, ub : lower and upper bounds on x
89 * message : see the cobyla_message enum
90 * calcfc : the function to minimize (see cobyla_function)
91 * state : used by function (see cobyla_function)
93 * The cobyla function returns the usual nlopt_result codes.
96 extern nlopt_result cobyla(int n, int m, double *x, double *minf, double rhobeg, nlopt_stopping *stop, const double *lb, const double *ub,
97 int message, cobyla_function *calcfc, void *state);
99 /* NLopt-style interface function */
100 nlopt_result cobyla_minimize(int n, nlopt_func f, void *f_data,
101 int m, nlopt_constraint *fc,
102 const double *lb, const double *ub, /* bounds */
103 double *x, /* in: initial guess, out: minimizer */
105 nlopt_stopping *stop,
112 #endif /* _COBYLA_ */