{"id":17259147,"url":"https://github.com/lindonroberts/trust-region","last_synced_at":"2025-04-14T06:12:00.846Z","repository":{"id":36464966,"uuid":"225495945","full_name":"lindonroberts/trust-region","owner":"lindonroberts","description":"Python trust-region subproblem solvers for nonlinear optimization","archived":false,"fork":false,"pushed_at":"2021-11-24T01:03:39.000Z","size":96,"stargazers_count":22,"open_issues_count":4,"forks_count":2,"subscribers_count":1,"default_branch":"master","last_synced_at":"2024-04-10T02:05:41.915Z","etag":null,"topics":["nonlinear-optimization","numerical-analysis","numerical-optimization","optimization","optimization-algorithms","optimization-methods","optimization-tools","python"],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/lindonroberts.png","metadata":{"files":{"readme":"README.rst","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-12-03T00:34:13.000Z","updated_at":"2024-01-16T05:40:01.000Z","dependencies_parsed_at":"2022-08-18T20:10:18.999Z","dependency_job_id":null,"html_url":"https://github.com/lindonroberts/trust-region","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lindonroberts%2Ftrust-region","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lindonroberts%2Ftrust-region/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lindonroberts%2Ftrust-region/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lindonroberts%2Ftrust-region/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lindonroberts","download_url":"https://codeload.github.com/lindonroberts/trust-region/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248830396,"owners_count":21168272,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["nonlinear-optimization","numerical-analysis","numerical-optimization","optimization","optimization-algorithms","optimization-methods","optimization-tools","python"],"created_at":"2024-10-15T07:23:29.364Z","updated_at":"2025-04-14T06:12:00.815Z","avatar_url":"https://github.com/lindonroberts.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"===========================================\ntrustregion: Trust-region subproblem solver\n===========================================\n\n.. image::  https://github.com/lindonroberts/trust-region/actions/workflows/python_testing.yml/badge.svg\n   :target: https://github.com/lindonroberts/trust-region/actions\n   :alt: Build Status\n\n.. image::  https://img.shields.io/badge/License-GPL%20v3-blue.svg\n   :target: https://www.gnu.org/licenses/gpl-3.0\n   :alt: GNU GPL v3 License\n\n.. image:: https://img.shields.io/pypi/v/trustregion.svg\n   :target: https://pypi.python.org/pypi/trustregion\n   :alt: Latest PyPI version\n\nThis package provides Python routines for solving the trust-region subproblem from nonlinear, nonconvex optimization. For more details on trust-region methods, see the book: A. R. Conn, N. I. M. Gould and Ph. L. Toint (2000), Trust-Region Methods, MPS-SIAM Series on Optimization.\n\nThe trust-region subproblem we solve is\n\n.. code-block::\n\n   min_{s in R^n}  g^T s + 0.5 s^T H s, subject to ||s||_2 \u003c= delta (and sl \u003c= s \u003c= su)\n\n**Quick install**\n\n .. code-block:: bash\n\n    $ sudo apt-get install gfortran\n    $ pip install --user numpy\n    $ pip install --user trustregion\n\nFor more details, see below. Note that NumPy must be installed first, as it is used to compile the Fortran-linked modules.\n\n**Interface** \n\nThe Python package :code:`trustregion` provides one routine, :code:`solve`, with interface:\n\n .. code-block:: python\n\n    import trustregion\n    s               = trustregion.solve(g, H, delta, sl=None, su=None, verbose_output=False)\n    s, gnew, crvmin = trustregion.solve(g, H, delta, sl=None, su=None, verbose_output=True)\n\nwhere the inputs are\n\n* :code:`g`, the gradient of the objective (as a 1D NumPy array)\n* :code:`H`, the symmetric Hessian matrix of the objective (as a 2D square NumPy array) - this can be :code:`None` if the model is linear\n* :code:`delta`, the trust-region radius (non-negative float)\n* :code:`sl`, the lower bounds on the step (as a 1D NumPy array) - this can be :code:`None` if not present, but :code:`sl` and :code:`su` must either be both :code:`None` or both set\n* :code:`su`, the upper bounds on the step (as a 1D NumPy array) - this can be :code:`None` if not present, but :code:`sl` and :code:`su` must either be both :code:`None` or both set\n* :code:`verbose_output`, a flag indicating which outputs to return.\n\nThe outputs are:\n\n* :code:`s`, an approximate minimizer of the subproblem (as a 1D NumPy array)\n* :code:`gnew`, the gradient of the objective at the solution :code:`s` (i.e. :code:`gnew = g + H.dot(s)`)\n* :code:`crvmin`, a float giving information about the curvature of the problem. If :code:`s` is on the trust-region boundary (given by :code:`delta`), then :code:`crvmin=0`. If :code:`s` is constrained in all directions by the box constraints, then :code:`crvmin=-1`. Otherwise, :code:`crvmin\u003e0` is the smallest curvature seen in the Hessian.\n\n**Example Usage** \n\nExamples for the use of :code:`trustregion.solve` can be found in the `examples \u003chttps://github.com/lindonroberts/trust-region/tree/master/examples\u003e`_ directory on Github.\n\n**Algorithms**\n\n:code:`trustregion` implements three different methods for solving the subproblem, based on the problem class (in Fortran 90, wrapped to Python):\n\n* :code:`trslin.f90` solves the linear objective case (where :code:`H=None` or :code:`H=0`), using Algorithm B.1 from: L. Roberts (2019), `Derivative-Free Algorithms for Nonlinear Optimisation Problems \u003chttps://ora.ox.ac.uk/objects/uuid:ec76e895-6eee-491a-88ed-b4ed10fa6003\u003e`_, PhD Thesis, University of Oxford.\n* :code:`trsapp.f90` solves the quadratic case without box constraints. It is a minor modification of the routine of the same name in :code:`NEWUOA` [M. J. D. Powell (2004), `The NEWUOA software for unconstrained optimization without derivatives \u003chttp://www.damtp.cam.ac.uk/user/na/NA_papers/NA2004_08.pdf\u003e`_, technical report DAMTP 2004/NA05, University of Cambridge].\n* :code:`trsbox.f90` solves the quadratic case with box constraints. It is a minor modification of the routine of the same name in :code:`BOBYQA` [M. J. D. Powell (2009), `The BOBYQA algorithm for bound constrained optimization without derivatives \u003chttp://www.damtp.cam.ac.uk/user/na/NA_papers/NA2009_06.pdf\u003e`_, technical report DAMTP 2009/NA06, University of Cambridge].\n\nIn the linear case, an active-set method is used to solve the resulting convex problem. In the quadratic cases, a modification of the Steihaug-Toint/conjugate gradient method is used. For more details, see the relevant references above.\n\nRequirements\n------------\n:code:`trustregion` requires the following software to be installed:\n\n* Fortran compiler (e.g. gfortran)\n* Python 3.8 or higher (http://www.python.org/)\n\nAdditionally, the following python packages should be installed (these will be installed automatically if using *pip*, see `Installation using pip`_):\n\n* NumPy (http://www.numpy.org/)\n\nInstallation using pip\n----------------------\nFor easy installation, use `pip \u003chttp://www.pip-installer.org/\u003e`_:\n\n .. code-block:: bash\n\n    $ pip install numpy\n    $ pip install trustregion\n\nNote that NumPy should be installed before :code:`trustregion`, as it is used to compile the Fortran modules.\n\nIf you do not have root privileges or you want to install :code:`trustregion` for your private use, you can use:\n\n .. code-block:: bash\n\n    $ pip install --user numpy\n    $ pip install --user trustregion\n\nwhich will install :code:`trustregion` in your home directory. \nAlternatively, you can use pip inside a virtual environment using `Python's virtual environments \u003chttps://docs.python.org/3/tutorial/venv.html\u003e`_ or the `conda \u003chttps://conda.io/projects/conda/en/latest/index.html\u003e`_ environment manager.\n\nNote that if an older install of :code:`trustregion` is present on your system you can use:\n\n .. code-block:: bash\n\n    $ pip install --upgrade trustregion\n\nto upgrade :code:`trustregion` to the latest version.\n\nManual installation\n-------------------\nAlternatively, you can download the source code from `Github \u003chttps://github.com/lindonroberts/trust-region\u003e`_ and unpack as follows:\n\n .. code-block:: bash\n\n    $ git clone https://github.com/lindonroberts/trust-region\n    $ cd trust-region\n\nTo upgrade :code:`trustregion` to the latest version, navigate to the top-level directory (i.e. the one containing :code:`setup.py`) and rerun the installation using :code:`pip`, as above:\n\n .. code-block:: bash\n\n    $ git pull\n    $ pip install .\n\nTesting\n-------\nIf you installed :code:`trustregion` manually, you can test your installation by running:\n\n .. code-block:: bash\n\n    $ pip install pytest\n    $ cd trustregion/tests\n    $ python -m pytest\n\nAlternatively, the documentation provides some simple examples of how to run :code:`trustregion`.\n\nUninstallation\n--------------\nIf :code:`trustregion` was installed using *pip* you can uninstall as follows:\n\n .. code-block:: bash\n\n    $ pip uninstall trustregion\n\nIf :code:`trustregion` was installed manually you have to remove the installed files by hand (located in your python site-packages directory).\n\nBugs\n----\nPlease report any bugs using GitHub's issue tracker.\n\nLicense\n-------\nThis algorithm is released under the GNU GPL license.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flindonroberts%2Ftrust-region","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flindonroberts%2Ftrust-region","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flindonroberts%2Ftrust-region/lists"}