资源简介
非线性规划(全局/局部最优化)的C/C++代码。希望对大家有帮助
代码片段和文件信息
/* Copyright (c) 2007-2012 Massachusetts Institute of Technology
*
* Permission is hereby granted free of charge to any person obtaining
* a copy of this software and associated documentation files (the
* “Software“) to deal in the Software without restriction including
* without limitation the rights to use copy modify merge publish
* distribute sublicense and/or sell copies of the Software and to
* permit persons to whom the Software is furnished to do so subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED “AS IS“ WITHOUT WARRANTY OF ANY KIND
* EXPRESS OR IMPLIED INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM DAMAGES OR OTHER LIABILITY WHETHER IN AN ACTION
* OF CONTRACT TORT OR OTHERWISE ARISING FROM OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#include “nlopt.h“
/*************************************************************************/
nlopt_algorithm nlopt_local_search_alg_deriv = NLOPT_LD_MMA;
nlopt_algorithm nlopt_local_search_alg_nonderiv = NLOPT_LN_COBYLA;
int nlopt_local_search_maxeval = -1; /* no maximum by default */
void
NLOPT_STDCALL nlopt_get_local_search_algorithm(nlopt_algorithm *deriv
nlopt_algorithm *nonderiv
int *maxeval)
{
*deriv = nlopt_local_search_alg_deriv;
*nonderiv = nlopt_local_search_alg_nonderiv;
*maxeval = nlopt_local_search_maxeval;
}
void
NLOPT_STDCALL nlopt_set_local_search_algorithm(nlopt_algorithm deriv
nlopt_algorithm nonderiv
int maxeval)
{
nlopt_local_search_alg_deriv = deriv;
nlopt_local_search_alg_nonderiv = nonderiv;
nlopt_local_search_maxeval = maxeval;
}
/*************************************************************************/
int nlopt_stochastic_population = 0;
int
NLOPT_STDCALL nlopt_get_stochastic_population(void) {
return nlopt_stochastic_population; }
void
NLOPT_STDCALL nlopt_set_stochastic_population(int pop) {
nlopt_stochastic_population = pop <= 0 ? 0 : (unsigned) pop; }
/*************************************************************************/
nlopt_result
NLOPT_STDCALL nlopt_minimize_econstrained(
nlopt_algorithm algorithm
int n nlopt_func_old f void *f_data
int m nlopt_func_old fc void *fc_data_ ptrdiff_t fc_datum_size
int p nlopt_func_old h void *h_data_ ptrdiff_t h_datum_size
const double *lb const double *ub /* bounds */
double *x /* in: initial guess out: minimizer */
double *minf /* out: minimum */
double minf_max double ftol_rel double ftol_abs
double xtol_rel const double *xtol_abs
double htol_rel double htol_abs
int maxeval
评论
共有 条评论