*--------------------------------------------------------- * Date created: March 3, 2001 * * Hanging Chain. * Bondarenko, Bortz & More, * COPS: Large-scale nonlinearly constrained optimization problems * Technical Report ANL/MCS-TM-237, October 1999 (Revision) * * Problem suggested by H. Mittelmann. * The problem seems to have a unique value for the objective. * SPENBAR needs 3 major iterations for any value on n * I tested the problem for * n=5, 10, 50, 99, 100, 200, 300, 400, 500. * * Dr. Neculai Andrei * Research Institute for Informatics, * 8-10, Averescu Avenue, Bucharest 1, Romania * E-mail: nandrei@u3.ici.ro * web: www.ici.ro/camo *--------------------------------------------------------- * subroutine ini(n,m,mb,me,sb,x,icgc,ipgc,icge,ipge, 1 nszc,nsze,nb) * double precision x(n) integer sb(mb) integer icgc(nszc),ipgc(n+1) integer icge(nsze),ipge(n+1) * write(1,10) 10 format(5x,'Example of a Nonlinear Programming Problem.') write(1,11) 11 format(5x,'Hanging Chain') * n=50 m=0 me=1 mb=0 nszc=0 nsze=n * do i=1,n x(i)=1.d0 end do * * Index vector for simple bounds: * * j=1 * do i=1,n * sb(j)=i * sb(j+1)=-i * j=j+2 * end do * * Rows indices of the nonzeros of the Jacobian of the Equalities. * do i=1,n icge(i)= 1 end do * * Starting address of the columns of the Jacobian of the Equalities. * do i=1,n ipge(i)=i end do ipge(n+1)=n+1 * return end * *-------------------------------------------------------------- * Hanging Chain. (Mittelmann) *-------------------------------------------------------------- * subroutine prob(n,m,mb,me,sb,x,objf,gobj,c,gc,cb,e,ge, 1 nszc,nsze,nb) * * Calculate problem functions at iterate x. * double precision x(n),objf,gobj(n),c(m),gc(nszc), * cb(mb),e(me),ge(nsze) * real*8 h, a, b, lung real*8 ta, tp, tm real*8 s1,s2, sum * * Objective function, and its gradient. * h=1.d0/(1.d0+float(n)) a=1.d0 b=3.d0 lung=4.d0 * hp2=h/2.d0 h2=2.d0*h * objf=0.d0 ta=(x(1)-a)/h objf = objf + 0.5d0*(x(1)+a)*sqrt(1.d0+ta*ta) * do i=1,n-1 tp=(x(i+1)+x(i))/2.d0 tm=(x(i+1)-x(i))/h objf = objf + tp*sqrt(1.d0+tm*tm) end do * ta=(b-x(n))/h objf = objf + 0.5d0*(b+x(n))*sqrt(1.d0+ta*ta) objf = objf*h * *--- Gradient * ta=(x(1)-a)/h tm=(x(2)-x(1))/h s1=sqrt(1.d0+ta*ta) s2=sqrt(1.d0+tm*tm) gobj(1)=hp2*s1 + hp2*s2 + * (x(1)**2 - a*a)/(h2*s1) - * (x(2)**2 - x(1)**2)/(h2*s2) * do i=2,n-1 ta=(x(i)-x(i-1))/h tm=(x(i+1)-x(i))/h s1=sqrt(1.d0+ta*ta) s2=sqrt(1.d0+tm*tm) gobj(i)=hp2*s1 + hp2*s2 + * (x(i)**2 - x(i-1)**2)/(h2*s1) - * (x(i+1)**2 - x(i)**2)/(h2*s2) end do * ta=(x(n)-x(n-1))/h tm=(b-x(n))/h s1=sqrt(1.d0+ta*ta) s2=sqrt(1.d0+tm*tm) gobj(n)=hp2*s1 + hp2*s2 + * (x(n)**2 - x(n-1)**2)/(h2*s1) - * (b**2 - x(n)**2)/(h2*s2) * * Bounds on variables. * * j=1 * do i=1,n * cb(j)=x(i)-0.0001 * cb(j+1)=10.d0-x(i) * j=j+2 * end do * * Equality Constraints. * ta=(x(1)-a)/h sum=sqrt(1.d0+ta**2) * do i=1,n-1 tm=(x(i+1)-x(i))/h sum = sum + sqrt(1.d0+tm**2) end do * ta=(b-x(n))/h sum = sum + sqrt(1.d0+ta**2) * e(1)=sum - lung/h * * Jacobian of the equality constraints. * ta=(x(1)-a)/h tm=(x(2)-x(1))/h s1=sqrt(1.d0+ta**2) s2=sqrt(1.d0+tm**2) ge(1)=(x(1)-a)/(h*h*s1) - (x(2)-x(1))/(h*h*s2) * do i=2,n-1 ta=(x(i)-x(i-1))/h s1=sqrt(1.d0+ta**2) tm=(x(i+1)-x(i))/h s2=sqrt(1.d0+tm**2) ge(i)=(x(i)-x(i-1))/(h*h*s1) - (x(i+1)-x(i))/(h*h*s2) end do * ta=(x(n)-x(n-1))/h s1=sqrt(1.d0+ta**2) tm=(b-x(n))/h s2=sqrt(1.d0+tm**2) ge(n)=(x(n)-x(n-1))/(h*h*s1) - (b-x(n))/(h*h*s2) * return end *---------------------------------------------------Hang.for