*--------------------------------------------------------- * Date created: February 9, 2001 * * Shape optimization of a cam. * Anitescu & Serban, 1998 * Please see COPS; Large scale nonlinearly constrained * optimization problems by Bondarenko, Bortz and More, * September 1998, ANL TR (October 1999 revision) pp.12-14. * * Dr. Neculai Andrei, * Research Institute for Informatics - Bucharest * 8-10, Averescu Avenue, * 71316 Bucharest - Romania * E-mail: nandrei@u3.ici.ro * web: http://www.ici.ro/camo/neculai/nandrei.htm *--------------------------------------------------------- * 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,'Shape optimization of a cam') write(1,12) 12 format(5x,'February 9, 2001') * n=10 m=2*n+3 me=0 mb=2*n nszc=5*n nsze=0 * * Initial Point: * do i=1,n x(i)=1.5d0 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. * * * Starting adress for the columns * * * Rows indices of the nonzeros of the Jacobian of the INEqualities. * j=1 do i=1,n icgc(j)=i icgc(j+1)=i+1 icgc(j+2)=i+2 icgc(j+3)=i+n+2 icgc(j+4)=i+n+3 j=j+5 end do * ** Starting adress for the columns * do i=1,n ipgc(i)=(i-1)*5+1 end do ipgc(n+1)=n*5+1 * return end * *-------------------------------------------------------------- * Date created: February 9, 2001 * * Shape optimization of a cam * Anitescu & Serban 1998 *-------------------------------------------------------------- * 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 pi, rv,ri,rm,v,w * pi=3.1415926536d0 rv=1.d0 ri=1.d0 ! rmin rm=2.d0 ! rmax v=dcos((2.d0*pi)/(5.d0*float(n)+5.d0)) w=(1.5d0*2.d0*pi)/(5.d0*float(n)+5.d0) w=w*w * * Objective function, and its gradient. * objf= 0.d0 do i=1,n objf = objf + x(i) end do objf = objf * pi*rv*rv objf=-objf * * Gradient of the Objective Function * do i=1,n gobj(i)=-pi*rv*rv end do * * Bounds on variables. * j=1 do i=1,n cb(j)=x(i)-ri cb(j+1)=rm-x(i) j=j+2 end do * * * -- Equality Constraints * * * -- INEquality Constraints * c(1)=ri*ri + ri*x(1) - 2.d0*ri*v*x(1) c(2)=ri*x(1) + x(1)*x(2) -2.d0*ri*v*x(2) do i=3,n c(i)= x(i-2)*x(i-1) + x(i-1)*x(i) - 2.d0*v*x(i-2)*x(i) end do c(n+1)=x(n-1)*x(n)+x(n)*rm-2.d0*rm*v*x(n-1) c(n+2)=2.d0*rm*x(n)-2.d0*v*x(n)*x(n) c(n+3)=w-(x(1)-ri)**2 do i=1,n-1 c(n+3+i)=w-(x(i+1)-x(i))**2 end do c(2*n+3)=w-(rm-x(n))**2 * * * -- Jacobian of the Equality Constraints * * * -- Jacobian of the Inequality constraints. * gc(1)=ri-2.d0*ri*v gc(2)=ri+x(2) j=3 do i=2,n-1 gc(j)=x(i)-2.d0*v*x(i+1) j=j+5 end do gc(4)=-2.d0*(x(1)-ri) j=5 do i=1,n-1 gc(j)=2.d0*(x(i+1)-x(i)) j=j+5 end do gc(6)=x(1)-2.d0*ri*v gc(7)=x(1)+x(3) j=12 do i=2,n-2 gc(j)=x(i)+x(i+2) j=j+5 end do j=9 do i=2,n gc(j)=-2.d0*(x(i)-x(i-1)) j=j+5 end do j=11 do i=2,n-1 gc(j)=x(i)-2.d0*v*x(i-1) j=j+5 end do gc((n-2)*5+3)=x(n)-2.d0*rm*v gc((n-1)*5+3)=2.d0*rm-4.d0*v*x(n) gc((n-1)*5+2)=x(n-1)+rm gc(n*5)=2.d0*(rm-x(n)) * return end *------------------------------------------------CAM.for