compute_obj_and_dobj Subroutine

private subroutine compute_obj_and_dobj(me, nf, x, gf, g, ff, f, kd, ld, iext)

computation of the value and the gradient of the objective function.

Note

This routine was formerly called pf1f01.

Type Bound

psqp_class

Arguments

Type IntentOptional Attributes Name
class(psqp_class), intent(inout) :: me
integer, intent(in) :: nf

number of variables.

real(kind=wp), intent(in) :: x(nf)

x(nf) vector of variables.

real(kind=wp), intent(out) :: gf(nf)

gf(nf) gradient of the model function.

real(kind=wp), intent(out) :: g(nf)

g(nf) gradient of the objective function.

real(kind=wp), intent(out) :: ff

value of the model function.

real(kind=wp), intent(out) :: f

value of the objective function.

integer, intent(in) :: kd

degree of required derivatives.

integer, intent(inout) :: ld

degree of previously computed derivatives.

integer, intent(in) :: iext

type of extremum.

  • iext=0 -- minimum.
  • iext=1 -- maximum.

Calls

proc~~compute_obj_and_dobj~~CallsGraph proc~compute_obj_and_dobj psqp_class%compute_obj_and_dobj proc~mxvneg mxvneg proc~compute_obj_and_dobj->proc~mxvneg

Called by

proc~~compute_obj_and_dobj~~CalledByGraph proc~compute_obj_and_dobj psqp_class%compute_obj_and_dobj proc~psqp psqp_class%psqp proc~psqp->proc~compute_obj_and_dobj proc~psqpn psqp_class%psqpn proc~psqpn->proc~psqp

Source Code

   subroutine compute_obj_and_dobj(me, nf, x, gf, g, ff, f, kd, ld, iext)

      class(psqp_class), intent(inout) :: me
      integer,intent(in) :: nf       !! number of variables.
      real(wp),intent(in) :: x(nf)   !! x(nf)   vector of variables.
      real(wp),intent(out) :: gf(nf) !! gf(nf)  gradient of the model function.
      real(wp),intent(out) :: g(nf)  !! g(nf)   gradient of the objective function.
      real(wp),intent(out) :: ff     !! value of the model function.
      real(wp),intent(out) :: f      !! value of the objective function.
      integer,intent(in) :: kd       !! degree of required derivatives.
      integer,intent(inout) :: ld    !! degree of previously computed derivatives.
      integer,intent(in) :: iext     !! type of extremum.
                                     !!
                                     !! * `iext=0` -- minimum.
                                     !! * `iext=1` -- maximum.

      if (kd <= ld) return
      if (ld < 0) then
         me%nfv = me%nfv + 1
         call me%obj(nf, x, ff)
         if (iext <= 0) then
            f = ff
         else
            f = -ff
         end if
      end if
      if (kd >= 1) then
         if (ld < 1) then
            me%nfg = me%nfg + 1
            call me%dobj(nf, x, gf)
            if (iext > 0) call mxvneg(nf, gf, g)
         end if
      end if
      ld = kd

   end subroutine compute_obj_and_dobj