# How to do Ascent with RegularStepGradientDescentOptimizerv4

**URL:** https://discourse.itk.org/t/how-to-do-ascent-with-regularstepgradientdescentoptimizerv4/3150
**Category:** Beginner Questions
**Tags:** registration
**Created:** [June 5, 2020, 5:55pm UTC](https://discourse.itk.org/t/how-to-do-ascent-with-regularstepgradientdescentoptimizerv4/3150 "2020-06-05T17:55:29Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![vnpavanelli](https://discourse.itk.org/user_avatar/discourse.itk.org/vnpavanelli/32/1519_2.png) [@vnpavanelli](https://discourse.itk.org/u/vnpavanelli)
#### Post date: [June 5, 2020, 5:55pm UTC](https://discourse.itk.org/t/how-to-do-ascent-with-regularstepgradientdescentoptimizerv4/3150/1 "2020-06-05T17:55:29Z")

</div>

The RegularStepGradientDescentOptimizer had member functions to set Maximize or Minimize mode, how this can be made with RegularStepGradientDescentOptimizerv4?

I’m thinking about changing my metric function in the UpdateParameters to subtract instead of adding the update parameters but it may not be the right way. I’m using itkGradientDescentOptimizerv4Test.cxx as a base for me right now.

Thanks!

---

<div class="post-metadata">

### Author: ![zivy](https://discourse.itk.org/user_avatar/discourse.itk.org/zivy/32/1726_2.png) [@zivy](https://discourse.itk.org/u/zivy)
#### Post date: [June 5, 2020, 6:03pm UTC](https://discourse.itk.org/t/how-to-do-ascent-with-regularstepgradientdescentoptimizerv4/3150/2 "2020-06-05T18:03:31Z")

</div>

Hello @vnpavanelli,

The ITK v4 registration framework removed this functionality (~10 years ago). All metrics are minimized, so any metric you want to add/use needs to be set up so that the minimal value is the optimum (i.e. negate the metric if the optimal value is a maximum).

---

<div class="post-metadata">

### Author: ![vnpavanelli](https://discourse.itk.org/user_avatar/discourse.itk.org/vnpavanelli/32/1519_2.png) [@vnpavanelli](https://discourse.itk.org/u/vnpavanelli)
#### Post date: [June 5, 2020, 7:35pm UTC](https://discourse.itk.org/t/how-to-do-ascent-with-regularstepgradientdescentoptimizerv4/3150/3 "2020-06-05T19:35:13Z")

</div>

Thanks @zivy,

I got it working now! Was also missing the factor variable in the metric::UpdateTransformParameters 🙂
