#include #include #include #include "define.h" static int nvar, nineq, ncond; static double *lm, *t; static double *mu, *r; static double (*objective)(); static double *(*inequalities)(); static double *(*conditions)(); static double *u, **ug, *umat; static double *v, **vg, *vmat; static double *gvalue, *ga; static double *hvalue, *ha; static int timeoutn = 1000; static double epsn = 1.0e-20; static void initialize() { int i, j; lm = alloc(double, nineq); t = alloc(double, nineq); for (i=0; i= 0.00) { sum += (lm[i] + 0.5*t[i]*u[i])*u[i]; } else { sum += (-0.5)*lm[i]*lm[i]/t[i]; } } (*conditions)(n, x, ncond, v); for (j=0; j= b) { return (a); } else { return (b); } } double vectormax(int size, double *d) { int k; double max; max = d[0]; for (k=0; k= max) { max = d[k]; } } return max; } MultiplierMethodSimplex(int n, double (*f)(), int m, double *(*g)(), int l, double *(*h)(), double x[], double length, int timeout, double eps) { int count, i, j; double alpha = 10, beta = 0.25, c = MAXFLOAT; double lopt, gmax, hmax, betac; status s, stat; nvar = n; nineq = m; ncond = l; objective = f; inequalities = g; conditions = h; initialize(); stat = failure; for (count=0; count betac) { t[i] *= alpha; } } for (j=0; j betac) { r[j] *= alpha; } } } return (stat); } double *nullfunction(){ return 0; } MultiplierMethodSimplexEqConds(int n, double (*f)(), int l, double *(*h)(), double x[], double length, int timeout, double eps) { return MultiplierMethodSimplex(n, f, 0, nullfunction, l, h, x, length, timeout, eps); }