.. index:: single: conjugate_gradient(Problem)
.. _conjugate_gradient/1:

.. rst-class:: right

**object**

``conjugate_gradient(Problem)``
===============================

* ``Problem`` - Problem object implementing ``local_optimization_problem_protocol`` and defining ``gradient/2``.


Nonlinear conjugate-gradient local optimizer (Fletcher-Reeves and Polak-Ribière). Requires the problem to define ``gradient/2``. Supports optional box constraints via projection, minimization and maximization, and periodic or automatic restarts.

| **Availability:** 
|    ``logtalk_load(local_optimization(loader))``

| **Author:** Paulo Moura
| **Version:** 1:0:0
| **Date:** 2026-09-03

| **Compilation flags:**
|    ``static, context_switching_calls``


| **Imports:**
|    ``public`` :ref:`local_optimization_solver(Problem) <local_optimization_solver/1>`
| **Uses:**
|    :ref:`linear_algebra <linear_algebra/0>`
|    :ref:`list <list/0>`

| **Remarks:**

   - Beta formulas: The ``beta(fletcher_reeves)`` and ``beta(polak_ribiere)`` options select the conjugacy coefficient. Polak-Ribière uses the standard non-negative truncation ``max(Beta, 0)``.
   - Restarts: The search direction is reset to steepest descent every ``restart(N)`` iterations (default: dimension) and whenever the new direction is insufficiently downhill.
   - Line search: Backtracking Armijo line search (same parameters as gradient descent).
   - Bounds: When the problem defines ``position_bounds/1``, trial points are projected onto the box after each step.

| **Inherited public predicates:**
|     :ref:`options_protocol/0::check_option/1`  :ref:`options_protocol/0::check_options/1`  :ref:`options_protocol/0::default_option/1`  :ref:`options_protocol/0::default_options/1`  :ref:`options_protocol/0::option/2`  :ref:`options_protocol/0::option/3`  :ref:`local_optimization_solver/1::run/2`  :ref:`local_optimization_solver/1::run/3`  :ref:`local_optimization_solver/1::run/4`  :ref:`options_protocol/0::valid_option/1`  :ref:`options_protocol/0::valid_options/1`  

.. contents::
   :local:
   :backlinks: top

Public predicates
-----------------

(no local declarations; see entity ancestors if any)

Protected predicates
--------------------

(no local declarations; see entity ancestors if any)

Private predicates
------------------

(no local declarations; see entity ancestors if any)

Operators
---------

(none)

.. seealso::

   :ref:`local_optimization_problem_protocol <local_optimization_problem_protocol/0>`, :ref:`local_optimization_solver(Problem) <local_optimization_solver/1>`, :ref:`bfgs(Problem) <bfgs/1>`, :ref:`gradient_descent(Problem) <gradient_descent/1>`, :ref:`nelder_mead(Problem) <nelder_mead/1>`

