c                         Kohdefunktio
      subroutine funobj(mode, n, x, f, g, nstate, nprob, z, nwcore)
      implicit none
      integer n, nstate, nprob, nwcore
      double precision x(n), f, g(n), z(nwcore), t1, t2, t3, t4, t5
c                        Funktion arvo
      t1 = x(1) - 1.0
      t2 = x(1) - x(2)
      t3 = x(2) - x(3)
      t4 = x(3) - x(4)
      t5 = x(4) - x(5)
      f = t1**2 + t2**2 + t3**3 + t4**4 + t5**4
c                        Gradienttivektori
      g(1) = 2.0*(t1 + t2)
      g(2) = -2.0*t2 + 3.0*t3**2
      g(3) = -3.0*t3**2 + 4.0*t4**3
      g(4) = -4.0*t4**3 + 4.0*t5**3
      g(5) = -4.0*t5**3
c
      return
      end
c                         Rajoitusehdot
      subroutine funcon(mode, m, n, njac, x, f, g, nstate, 
     %     nprob, z, nwcore)
      implicit none
      integer m, n, njac, nstate, nprob, nwcore
      double precision x(n), f(m), g(m,n), z(nwcore)
c                        Rajoitusehto 1
      f(1) = x(1) + x(2)**2 + x(3)**3
      g(1,1) = 1.0
      g(1,2) = 2.0*x(2)
      g(1,3) = 3.0*x(3)**2
c                        Rajoitusehto 2
      f(2) = x(2) - x(3)**2 + x(4)
      g(2,2) = 1.0
      g(2,3) = -2.0*x(3)
      g(2,4) = 1.0
c                        Rajoitusehto 3
      f(3) = x(1)*x(5)
      g(3,1) = x(5)
      g(3,5) = x(1)
c
      return
      end
