📄 maratos.c
字号:
/* **************************************************************************** *//* user functions *//* **************************************************************************** */#include "o8para.h"main() { void donlp2(void); donlp2(); exit(0);}/* Maratos's example, showing the well known effect of stepsize reduction *//* Change donlp's parameter smalld in order to see it! *//* **************************************************************************** *//* donlp2 standard setup *//* **************************************************************************** */void setup0(void) { #define X extern #include "o8comm.h" #undef X static INTEGER j; strcpy(name,"maratos0"); x[1] = 0.8e0; x[2] = 0.6e0; n = 2; nh = 1; ng = 0; del0 = 1.00e-1; tau0 = 0.5e0; tau = .1e0; for (j = 0 ; j <= 1 ; j++) { gunit[1][j] = -1; gunit[2][j] = 0; gunit[3][j] = 0; } analyt = TRUE; epsdif = 0.e0; nreset = 4; silent = FALSE; return;}/* **************************************************************************** *//* special setup *//* **************************************************************************** */void setup(void) { #define X extern #include "o8comm.h" #undef X return;}/* **************************************************************************** *//* the user may add additional computations using the computed solution here *//* **************************************************************************** */void solchk(void) { #define X extern #include "o8comm.h" #undef X #include "o8cons.h" return;}/* **************************************************************************** *//* objective function *//* **************************************************************************** */void ef(DOUBLE x[],DOUBLE *fx) { #define X extern #include "o8fuco.h" #undef X icf = icf+1; *fx = -x[1] + 10.e0*(pow(x[1],2)+pow(x[2],2)-1.e0); return;}/* **************************************************************************** *//* gradient of objective function *//* **************************************************************************** */void egradf(DOUBLE x[],DOUBLE gradf[]) { #define X extern #include "o8fuco.h" #undef X icgf = icgf+1; gradf[1] = -1.e0+20.e0*x[1]; gradf[2] = 20.e0*x[2]; return;}/* **************************************************************************** *//* compute the i-th equality constaint, value is hxi *//* **************************************************************************** */void eh(INTEGER i,DOUBLE x[],DOUBLE *hxi) { #define X extern #include "o8fuco.h" #undef X cres[i] = cres[i]+1; *hxi = pow(x[1],2)+pow(x[2],2)-1.e0; return;}/* **************************************************************************** *//* compute the gradient of the i-th equality constraint *//* **************************************************************************** */void egradh(INTEGER i,DOUBLE x[],DOUBLE gradhi[]) { #define X extern #include "o8fuco.h" #undef X cgres[i] = cgres[i]+1; gradhi[1] = 2.e0*x[1]; gradhi[2] = 2.e0*x[2]; return;}/* **************************************************************************** *//* compute the i-th inequality constaint, bounds included *//* **************************************************************************** */void eg(INTEGER i,DOUBLE x[],DOUBLE *gxi) { #define X extern #include "o8fuco.h" #undef X return;}/* **************************************************************************** *//* compute the gradient of the i-th inequality constraint *//* not necessary for bounds, but constant gradients must be set *//* here e.g. using dcopy from a data-field *//* **************************************************************************** */void egradg(INTEGER i,DOUBLE x[],DOUBLE gradgi[]) { #define X extern #include "o8fuco.h" #undef X return;}/* **************************************************************************** *//* user functions (if bloc == TRUE) *//* **************************************************************************** */void eval_extern(INTEGER mode) { #define X extern #include "o8comm.h" #include "o8fint.h" #undef X #include "o8cons.h" return;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -