├── .github ├── dependabot.yml └── workflows │ ├── build.yml │ ├── main.yml │ └── pre-commit.yml.disable ├── .gitignore ├── .pre-commit-config.yaml ├── CHANGES ├── INSTALL ├── LICENSE ├── MANIFEST.in ├── QUICKGUIDE.md ├── README.md ├── examples ├── autorefine.py ├── groups.py ├── history.py ├── nsga2_multi_objective.py ├── parallel_alpso.py ├── parallel_gradient.py ├── parallel_ipopt.py ├── parallel_midaco.py ├── parallel_nlpqlp.py ├── passing_args.py ├── rosenbrock.py ├── tp037.py └── usersens.py ├── pyOpt ├── __init__.py ├── pyALGENCAN │ ├── LICENSE │ ├── README │ ├── __init__.py │ ├── pyALGENCAN.py │ ├── setup.py │ └── source │ │ ├── README │ │ ├── algconst.par │ │ ├── algencan.f │ │ ├── algparam.inc │ │ ├── auglag.f │ │ ├── backtrack.f │ │ ├── betra.f │ │ ├── calc.f │ │ ├── cgm.f │ │ ├── checkder.f │ │ ├── closeunit.f │ │ ├── counters.inc │ │ ├── dim.par │ │ ├── dogleg.f │ │ ├── drand.f │ │ ├── evalal.f │ │ ├── extrap.f │ │ ├── f2py │ │ ├── README │ │ └── algencan.pyf │ │ ├── fixvar.inc │ │ ├── fparam.f │ │ ├── gencan.f │ │ ├── graddat.inc │ │ ├── happdat.inc │ │ ├── happrox.f │ │ ├── hessdat.inc │ │ ├── hpredat.inc │ │ ├── itetyp.inc │ │ ├── lss.f │ │ ├── machconst.inc │ │ ├── moresor.f │ │ ├── newtd.f │ │ ├── newtonkkt.f │ │ ├── openunit.f │ │ ├── outtyp.inc │ │ ├── probdata.inc │ │ ├── rspace.inc │ │ ├── scaling.inc │ │ ├── scl.f │ │ ├── setpoint.f │ │ ├── sevalus.f │ │ ├── slacks.inc │ │ ├── spgls.f │ │ ├── sydat.inc │ │ ├── tevalus.f │ │ ├── tnls.f │ │ ├── uevalus.f │ │ └── vevalus.f ├── pyALHSO │ ├── LICENSE │ ├── README │ ├── __init__.py │ ├── alhso.py │ ├── pyALHSO.py │ └── setup.py ├── pyALPSO │ ├── LICENSE │ ├── README │ ├── __init__.py │ ├── alpso.py │ ├── alpso_dpm.py │ ├── alpso_poa.py │ ├── alpso_spm.py │ ├── pyALPSO.py │ └── setup.py ├── pyCOBYLA │ ├── LICENSE │ ├── README │ ├── __init__.py │ ├── pyCOBYLA.py │ ├── setup.py │ └── source │ │ ├── README │ │ ├── closeunit.f │ │ ├── cobyla.f │ │ ├── cobylb.f │ │ ├── f2py │ │ ├── README │ │ └── cobyla.pyf │ │ ├── openunit.f │ │ └── trstlp.f ├── pyCONMIN │ ├── LICENSE │ ├── README │ ├── __init__.py │ ├── pyCONMIN.py │ ├── setup.py │ └── source │ │ ├── README │ │ ├── closeunit.f │ │ ├── cnmn00.f │ │ ├── cnmn01.f │ │ ├── cnmn02.f │ │ ├── cnmn03.f │ │ ├── cnmn04.f │ │ ├── cnmn05.f │ │ ├── cnmn06.f │ │ ├── cnmn07.f │ │ ├── cnmn08.f │ │ ├── cnmn09.f │ │ ├── conmin.f │ │ ├── f2py │ │ ├── README │ │ └── conmin.pyf │ │ └── openunit.f ├── pyFILTERSD │ ├── LICENSE │ ├── README │ ├── __init__.py │ ├── pyFILTERSD.py │ ├── setup.py │ └── source │ │ ├── README │ │ ├── checkd.f │ │ ├── closeunit.f │ │ ├── densea.f │ │ ├── densel.f │ │ ├── f2py │ │ ├── README │ │ └── filtersd.pyf │ │ ├── filtersd.f │ │ ├── filtersd_wrap.f │ │ ├── glcpd.f │ │ ├── l1sold.f │ │ ├── openunit.f │ │ ├── shared.f │ │ └── util.f ├── pyFSQP │ ├── LICENSE │ ├── README │ ├── __init__.py │ ├── pyFSQP.py │ ├── setup.py │ └── source │ │ ├── README │ │ ├── closeunit.f │ │ ├── f2py │ │ ├── README │ │ └── ffsqp.pyf │ │ ├── ffsqp.diff │ │ └── openunit.f ├── pyGCMMA │ ├── LICENSE │ ├── README │ ├── __init__.py │ ├── pyGCMMA.py │ ├── setup.py │ └── source │ │ ├── README │ │ ├── closeunit.f │ │ ├── f2py │ │ ├── README │ │ └── gcmma.pyf │ │ ├── ksgcmain.diff │ │ └── openunit.f ├── pyIPOPT │ ├── __init__.py │ ├── pyIPOPT.py │ └── setup.py ├── pyKSOPT │ ├── LICENSE │ ├── README │ ├── __init__.py │ ├── pyKSOPT.py │ ├── setup.py │ └── source │ │ ├── README │ │ ├── closeunit.f │ │ ├── f2py │ │ ├── README │ │ └── ksopt.pyf │ │ ├── ks.f │ │ ├── ksales.f │ │ ├── ksando.f │ │ ├── kscomg.f │ │ ├── kscomp.f │ │ ├── kscube.f │ │ ├── ksd.f │ │ ├── ksdfp.f │ │ ├── ksdfun.f │ │ ├── ksfun.f │ │ ├── ksgrad.f │ │ ├── kshess.f │ │ ├── kshmul.f │ │ ├── ksinfo.f │ │ ├── ksinit.f │ │ ├── ksmain.f │ │ ├── ksoned.f │ │ ├── ksopt.f │ │ ├── ksprnt.diff │ │ ├── ksprnt.f │ │ ├── ksqmin.f │ │ ├── ksquad.f │ │ ├── ksscal.f │ │ ├── ksside.f │ │ ├── ksunsc.f │ │ ├── ksvprd.f │ │ ├── ksxlim.f │ │ └── openunit.f ├── pyMIDACO │ ├── LICENSE │ ├── README │ ├── __init__.py │ ├── pyMIDACO.py │ ├── setup.py │ └── source │ │ ├── README │ │ ├── closeunit.f │ │ ├── f2py │ │ ├── README │ │ └── midaco.pyf │ │ ├── midaco.f │ │ ├── midaco_wrap.f │ │ └── openunit.f ├── pyMMA │ ├── LICENSE │ ├── README │ ├── __init__.py │ ├── pyMMA.py │ ├── setup.py │ └── source │ │ ├── README │ │ ├── closeunit.f │ │ ├── f2py │ │ ├── README │ │ └── mma.pyf │ │ ├── ksmmamain.diff │ │ └── openunit.f ├── pyMMFD │ ├── LICENSE │ ├── README │ ├── __init__.py │ ├── pyMMFD.py │ ├── setup.py │ └── source │ │ ├── README │ │ ├── closeunit.f │ │ ├── f2py │ │ ├── README │ │ └── mmfd.pyf │ │ ├── mmfd.f │ │ └── openunit.f ├── pyNLPQL │ ├── LICENSE │ ├── README │ ├── __init__.py │ ├── pyNLPQL.py │ ├── setup.py │ └── source │ │ ├── README │ │ ├── closeunit.f │ │ ├── f2py │ │ ├── README │ │ └── nlpql.pyf │ │ ├── nlpql1.diff │ │ ├── nlpql2.diff │ │ └── openunit.f ├── pyNLPQLP │ ├── LICENSE │ ├── README │ ├── __init__.py │ ├── pyNLPQLP.py │ ├── setup.py │ └── source │ │ ├── README │ │ ├── closeunit.for │ │ ├── f2py │ │ ├── README │ │ └── nlpqlp.pyf │ │ ├── nlpqlp_wrap.for │ │ └── openunit.for ├── pyNSGA2 │ ├── LICENSE │ ├── README │ ├── __init__.py │ ├── pyNSGA2.py │ ├── setup.py │ └── source │ │ ├── README │ │ ├── allocate.c │ │ ├── auxiliary.c │ │ ├── crossover.c │ │ ├── crowddist.c │ │ ├── decode.c │ │ ├── dominance.c │ │ ├── eval.c │ │ ├── fillnds.c │ │ ├── initialize.c │ │ ├── list.c │ │ ├── merge.c │ │ ├── mutation.c │ │ ├── nsga2.c │ │ ├── nsga2.h │ │ ├── rand.c │ │ ├── rand.h │ │ ├── rank.c │ │ ├── report.c │ │ ├── sort.c │ │ ├── swig │ │ ├── .gitignore │ │ ├── README │ │ └── nsga2.i │ │ └── tourselect.c ├── pyOpt_constraint.py ├── pyOpt_gradient.py ├── pyOpt_history.py ├── pyOpt_objective.py ├── pyOpt_optimization.py ├── pyOpt_optimizer.py ├── pyOpt_parameter.py ├── pyOpt_variable.py ├── pyPSQP │ ├── LICENSE │ ├── README │ ├── __init__.py │ ├── pyPSQP.py │ ├── setup.py │ └── source │ │ ├── README │ │ ├── closeunit.f │ │ ├── f2py │ │ ├── README │ │ └── psqp.pyf │ │ ├── mqsubs.f │ │ ├── openunit.f │ │ ├── pqsubs.f │ │ ├── psqp.f │ │ └── psqp_wrap.f ├── pySDPEN │ ├── LICENSE │ ├── README │ ├── __init__.py │ ├── pySDPEN.py │ ├── setup.py │ └── source │ │ ├── README │ │ ├── closeunit.f90 │ │ ├── f2py │ │ ├── README │ │ └── sdpen.pyf │ │ ├── funct.f90 │ │ ├── linesearchbox.f90 │ │ ├── openunit.f90 │ │ ├── penseq.f90 │ │ ├── sdpen.f90 │ │ └── stop.f90 ├── pySLSQP │ ├── LICENSE │ ├── README │ ├── __init__.py │ ├── pySLSQP.py │ ├── setup.py │ └── source │ │ ├── README │ │ ├── closeunit.f │ │ ├── daxpy.f │ │ ├── dcopy.f │ │ ├── drot.f │ │ ├── drotg.f │ │ ├── dscal.f │ │ ├── f2py │ │ ├── README │ │ └── slsqp.pyf │ │ ├── h12.f │ │ ├── hfti.f │ │ ├── ldl.f │ │ ├── ldp.f │ │ ├── lsei.f │ │ ├── lsi.f │ │ ├── lsq.f │ │ ├── nnls.f │ │ ├── openunit.f │ │ ├── slsqp.f │ │ └── slsqpb.f ├── pySNOPT │ ├── LICENSE │ ├── README │ ├── __init__.py │ ├── pySNOPT.py │ ├── setup.py │ └── source │ │ ├── README │ │ ├── closeunit.f │ │ ├── f2py │ │ ├── README │ │ └── snopt.pyf │ │ └── openunit.f ├── pySOLVOPT │ ├── LICENSE │ ├── README │ ├── __init__.py │ ├── pySOLVOPT.py │ ├── setup.py │ └── source │ │ ├── README │ │ ├── apprgrdn.f │ │ ├── closeunit.f │ │ ├── f2py │ │ ├── README │ │ └── solvopt.pyf │ │ ├── messages.inc │ │ ├── openunit.f │ │ ├── solvopt.diff │ │ ├── solvopt.f │ │ └── soptions.f └── setup.py ├── pyproject.toml ├── requirements.txt ├── setup.cfg ├── setup.py ├── tests ├── test_init.py └── test_minimizers1.py └── util └── env └── build-env.yml /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | updates: 3 | - package-ecosystem: "github-actions" 4 | directory: "/" 5 | schedule: 6 | # Check for updates to GitHub Actions every week 7 | interval: "weekly" 8 | -------------------------------------------------------------------------------- /.github/workflows/main.yml: -------------------------------------------------------------------------------- 1 | name: CI tests 2 | 3 | on: 4 | push: 5 | 6 | jobs: 7 | checks: 8 | runs-on: ubuntu-latest 9 | strategy: 10 | fail-fast: false 11 | matrix: 12 | python-version: 13 | - 3.7 14 | - 3.8 15 | - 3.9 16 | - 3.10 17 | - 3.11 18 | name: Check Python ${{ matrix.python-version }} 19 | steps: 20 | - uses: actions/checkout@v3 21 | with: 22 | fetch-depth: 0 23 | 24 | - uses: conda-incubator/setup-miniconda@v2 25 | with: 26 | environment-file: util/env/build-env.yml 27 | miniforge-version: latest 28 | auto-update-conda: true 29 | python-version: ${{ matrix.python-version }} 30 | activate-environment: pyopt-env 31 | 32 | - name: Install package 33 | shell: bash -l {0} 34 | run: | 35 | python -m pip install -e .[all] 36 | python setup.py build_ext -i 37 | 38 | - name: Test package 39 | shell: bash -l {0} 40 | run: python -m pytest 41 | -------------------------------------------------------------------------------- /.github/workflows/pre-commit.yml.disable: -------------------------------------------------------------------------------- 1 | name: pre-commit 2 | 3 | on: 4 | push: 5 | 6 | jobs: 7 | pre-commit: 8 | runs-on: ubuntu-latest 9 | steps: 10 | - uses: actions/checkout@v3 11 | - uses: actions/setup-python@v3 12 | - uses: pre-commit/action@v3.0.0 13 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # optimization history, saved state and output 2 | *.cue 3 | *.bin 4 | *.out 5 | 6 | build 7 | *.pyc 8 | **/f2py/*.c 9 | **/f2py/*.f 10 | *.so 11 | .idea 12 | 13 | *.egg-info 14 | venv* 15 | /MANIFEST 16 | -------------------------------------------------------------------------------- /.pre-commit-config.yaml: -------------------------------------------------------------------------------- 1 | repos: 2 | - repo: https://github.com/pre-commit/pre-commit-hooks 3 | rev: v4.4.0 4 | hooks: 5 | - id: check-added-large-files 6 | - id: check-case-conflict 7 | - id: check-merge-conflict 8 | - id: check-symlinks 9 | - id: check-yaml 10 | - id: check-toml 11 | - id: debug-statements 12 | - id: end-of-file-fixer 13 | - id: mixed-line-ending 14 | - id: requirements-txt-fixer 15 | - id: trailing-whitespace 16 | - id: detect-private-key 17 | - id: fix-byte-order-marker 18 | - id: check-ast 19 | 20 | - repo: https://github.com/myint/docformatter 21 | rev: v1.7.5 22 | hooks: 23 | - id: docformatter 24 | args: [ -r, --in-place, --wrap-descriptions, '120', --wrap-summaries, '120', -- ] 25 | 26 | - repo: https://github.com/mattlqx/pre-commit-sign 27 | rev: v1.1.3 28 | hooks: 29 | - id: sign-commit 30 | - repo: https://github.com/pre-commit/pygrep-hooks 31 | rev: v1.10.0 32 | hooks: 33 | - id: python-use-type-annotations 34 | - id: python-check-mock-methods 35 | - id: python-no-eval 36 | - id: rst-directive-colons 37 | 38 | - repo: https://github.com/PyCQA/isort 39 | rev: 5.12.0 40 | hooks: 41 | - id: isort 42 | 43 | - repo: https://github.com/asottile/pyupgrade 44 | rev: v3.10.1 45 | hooks: 46 | - id: pyupgrade 47 | args: [ --py36-plus ] 48 | 49 | - repo: https://github.com/asottile/setup-cfg-fmt 50 | rev: v2.4.0 51 | hooks: 52 | - id: setup-cfg-fmt 53 | 54 | # Notebook formatting 55 | - repo: https://github.com/nbQA-dev/nbQA 56 | rev: 1.7.0 57 | hooks: 58 | - id: nbqa-isort 59 | additional_dependencies: [ isort==5.6.4 ] 60 | 61 | - id: nbqa-pyupgrade 62 | additional_dependencies: [ pyupgrade==2.7.4 ] 63 | args: [ --py36-plus ] 64 | 65 | - repo: https://github.com/mgedmin/check-manifest 66 | rev: '0.49' 67 | hooks: 68 | - id: check-manifest 69 | stages: [ manual ] 70 | - repo: https://github.com/sondrelg/pep585-upgrade 71 | rev: 'v1.0' 72 | hooks: 73 | - id: upgrade-type-hints 74 | args: [ '--futures=true' ] 75 | -------------------------------------------------------------------------------- /CHANGES: -------------------------------------------------------------------------------- 1 | Release 1.2.0 (July 31, 2014) 2 | =============================== 3 | 4 | * Added unconstrained problems support for all optimizers 5 | (COBYLA,CONMIN and SNOPT improvements contributed by 6 | Herbert Schilling, NASA Glenn). 7 | 8 | * Update MIDACO optimizer support to version 4.0. 9 | 10 | * Update ALGENCAN optimizer support to version 2.4. 11 | 12 | * Updated NLPQLP optimizer fixing memory buffer bug 13 | (reported by Simon Rudolph, Technische Universitat Munchen). 14 | 15 | * Updated FilterSD optimizer support to version 2.0. 16 | 17 | * Updated SLSQP optimizer fixing error 18 | (reported by Mueen Nawaz, Intel). 19 | 20 | * Updated NSGA2 optimizer adding initial solution support 21 | (reported by Smit Patel). 22 | 23 | 24 | Release 1.1.1 (May 28, 2013) 25 | =============================== 26 | 27 | * Fix minor issue with SDPEN and FILTERSD imports. 28 | 29 | 30 | Release 1.1.0 (March 22, 2013) 31 | =============================== 32 | 33 | * Updated history file handling functionality. 34 | 35 | * Updated python code for os system compatibility. 36 | 37 | * Updated KSOPT optimizer to version 2.8. 38 | 39 | * Updated MMA optimizer support to 2007 version. 40 | 41 | * Updated GCMMA optimizer support to 2007 version. 42 | 43 | * Updated MIDACO optimizer to version 3.0, its 44 | source is now included with a trial license 45 | that allows to test problems up to four variables. 46 | 47 | * Updated SLSQP optimizer to make it thread-safe 48 | (reported by Dr. K.T. Moore, NASA). 49 | 50 | * Updated package __init__ to fix circular dependencies 51 | (reported by Dr. K.A. Weinman, DLR). 52 | 53 | * Added ALGENCAN optimizer functionality. 54 | 55 | * Added SDPEN optimizer functionality. 56 | 57 | * Added FilterSD optimizer functionality. 58 | 59 | * Added NLPQLP optimizer functionality. 60 | 61 | 62 | Release 1.0.1 (June 10, 2011) 63 | ============================= 64 | 65 | * Fix minor issue with Optimizers warm-start. 66 | 67 | * Updated QUICKGUIDE. 68 | 69 | * Fix minor issue with SNOPT no print-out option. 70 | 71 | * Updated Optimization class to address minor issue 72 | with multiple optimization problem instances. 73 | 74 | 75 | Release 1.0.0 (Mar 17, 2011) 76 | ============================ 77 | 78 | * First public release. 79 | -------------------------------------------------------------------------------- /INSTALL: -------------------------------------------------------------------------------- 1 | pyOpt - Building and Installing 2 | =============================== 3 | Copyright (c) 2008-2014, pyOpt Developers 4 | 5 | 6 | Requirements 7 | ------------ 8 | pyOpt has the following dependencies: 9 | 10 | * Python 2.4+ 11 | * Numpy 1.0+ 12 | * Swig 1.3+ 13 | * c/FORTRAN compiler (compatible with f2py) 14 | 15 | Further dependencies to take advantage 16 | of parallel computing capabilities are: 17 | 18 | * mpi4py 19 | 20 | Notes: 21 | 22 | * In Windows with python x86 and numpy-win32 MinGW is recommended if c/FORTRAN compilers are not available. 23 | * In Windows with python x86-64 and numpy-amd64 MinGW-W64 is recommended if c/FORTRAN compilers are not available. 24 | * In Linux, the python header files (python-dev) and numpy header files (numpy-dev) are also required. 25 | * In OpenSUSE systems, install as superuser and modify package execution permission for non-superusers. 26 | 27 | 28 | Installation 29 | ------------ 30 | To install the pyOpt package in a folder on the Python search path 31 | (usually in site-packages/) run: 32 | 33 | >>> python setup.py install 34 | 35 | 36 | Alternatively, to use pyOpt from the current directory without 37 | installing it run: 38 | 39 | >>> python setup.py build_ext --inplace 40 | 41 | this will compile all available optimizers and place the libraries in the corresponding directory. 42 | 43 | 44 | Notes: 45 | 46 | * You may want to uninstall any previous version of pyOpt before installing a new 47 | version, as there may be conflicts. 48 | * Some optimizers are licensed and their sources are not included with this distribution. 49 | To use them, please request their sources from the authors as indicated in the optimizer 50 | LICENSE files, and place them in their respective source folders before installing the package. 51 | * In Windows, if MinGW is used make sure to install for it the C, C++, and Fortran compilers and run: 52 | 53 | >>> python setup.py install --compiler=mingw32 54 | 55 | * Installing to site-packages/ requires root privileges on Linux. 56 | * By default pyOpt will attempt to use compilers available on the system. To get a list of 57 | available compilers and their corresponding flag on a specific system use: 58 | 59 | >>> python setup.py config_fc --help-compiler 60 | >>> python setup.py config_fc --help-fcompiler 61 | -------------------------------------------------------------------------------- /MANIFEST.in: -------------------------------------------------------------------------------- 1 | prune * 2 | graft tests 3 | 4 | include LICENSE README.md pyproject.toml setup.py setup.cfg 5 | recursive-include pyOpt * 6 | global-exclude __pycache__ *.py[cod] .* 7 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # pyOpt 2 | PYthon OPTimization Framework 3 | Copyright (c) 2008-2014, pyOpt Developers 4 | 5 | pyOpt is an object-oriented framework for formulating and solving 6 | nonlinear constrained optimization problems. 7 | 8 | Some of the features of pyOpt: 9 | 10 | * Object-oriented development maintains independence between 11 | the optimization problem formulation and its solution by 12 | different optimizers 13 | * Allows for easy integration of gradient-based, gradient-free, 14 | and population-based optimization algorithms 15 | * Interfaces both open source as well as industrial optimizers 16 | * Ease the work required to do nested optimization and provides 17 | automated solution refinement 18 | * On parallel systems it enables the use of optimizers when 19 | running in a mpi parallel environment, allows for evaluation 20 | of gradients in parallel, and can distribute function 21 | evaluations for gradient-free optimizers 22 | * Optimization solution histories can be stored during the 23 | optimization process. A partial history can also be used 24 | to warm-restart the optimization 25 | 26 | see QUICKGUIDE.md for further details. 27 | 28 | ## Building and installing 29 | 30 | ### Requirements: 31 | 32 | - python 33 | - numpy and numpy-ext 34 | - fortran compiler 35 | - swig 36 | 37 | 38 | ### Build commands 39 | 40 | Build default pyOpt 41 | 42 | ```sh 43 | python setup.py build_ext --inplace 44 | ``` 45 | 46 | Build debug pyOpt with no optimization 47 | 48 | ```sh 49 | python setup.py config_fc --debug --noopt build_ext --inplace 50 | ``` 51 | 52 | Get information about the available compilers 53 | 54 | ```sh 55 | python setup.py config_fc --help-fcompiler 56 | ``` 57 | 58 | 59 | ## Licensing 60 | Distributed using the GNU Lesser General Public License (LGPL); see 61 | the LICENSE file for details. 62 | 63 | Please cite pyOpt and the authors of the respective optimization 64 | algorithms in any publication for which you find it useful. 65 | (This is not a legal requirement, just a polite request.) 66 | 67 | 68 | ## Contact and Feedback 69 | 70 | If you have questions, comments, problems, want to contribute to the 71 | framework development, or want to report a bug, please contact the 72 | main developers: 73 | 74 | - [Dr. Ruben E. Perez](mailto:Ruben.Perez@rmc.ca) 75 | - [Peter W. Jansen](mailto:Peter.Jansen@rmc.ca) 76 | -------------------------------------------------------------------------------- /examples/autorefine.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | """Solves Langermann Multimodal Problem with Automatic Optimization Refinement.""" 3 | 4 | from numpy import cos, exp, pi 5 | 6 | from pyOpt import NSGA2, SLSQP, Optimization 7 | 8 | 9 | def objfunc(x): 10 | a = [3, 5, 2, 1, 7] 11 | b = [5, 2, 1, 4, 9] 12 | c = [1, 2, 5, 2, 3] 13 | 14 | f = 0.0 15 | for i in range(5): 16 | f += -(c[i] * exp(-(1 / pi) * ((x[0] - a[i]) ** 2 + (x[1] - b[i]) ** 2)) * cos( 17 | pi * ((x[0] - a[i]) ** 2 + (x[1] - b[i]) ** 2))) 18 | 19 | g = [ 20 | 20.04895 - (x[0] + 2.0) ** 2 - (x[1] + 1.0) ** 2, 21 | ] 22 | 23 | fail = 0 24 | 25 | return f, g, fail 26 | 27 | 28 | opt_prob = Optimization('Langermann Function 11', objfunc) 29 | opt_prob.addVar('x1', 'c', lower=-2.0, upper=10.0, value=8.0) 30 | opt_prob.addVar('x2', 'c', lower=-2.0, upper=10.0, value=8.0) 31 | opt_prob.addObj('f') 32 | opt_prob.addCon('g', 'i') 33 | print(opt_prob) 34 | 35 | # Global Optimization 36 | nsga2 = NSGA2() 37 | nsga2(opt_prob) 38 | print(opt_prob.solution(0)) 39 | 40 | # Local Optimization Refinement 41 | slsqp = SLSQP() 42 | slsqp(opt_prob.solution(0)) 43 | print(opt_prob.solution(0).solution(0)) 44 | -------------------------------------------------------------------------------- /examples/groups.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | """Solves Constrained Toy Problem Using Variable Groups. 3 | 4 | min x1^2 + x2^2 5 | s.t.: 3 - x1 <= 0 6 | 2 - x2 <= 0 7 | -10 <= x1 <= 10 8 | -10 <= x2 <= 10 9 | """ 10 | 11 | # ============================================================================= 12 | # Standard Python modules 13 | # ============================================================================= 14 | import os 15 | import sys 16 | import time 17 | 18 | import numpy 19 | 20 | # ============================================================================= 21 | # Extension modules 22 | # ============================================================================= 23 | from pyOpt import SLSQP, Optimization 24 | 25 | 26 | # ============================================================================= 27 | # 28 | # ============================================================================= 29 | def objfunc(xn): 30 | 31 | x0 = xn['x'] 32 | x1 = xn['z'] 33 | 34 | f = x0**2 + x1**2 35 | g = [0.0]*2 36 | g[0] = 3 - x0 37 | g[1] = 2 - x1 38 | 39 | fail = 0 40 | 41 | return f,g,fail 42 | 43 | 44 | # ============================================================================= 45 | # 46 | # ============================================================================= 47 | 48 | # Instantiate Optimization Problem 49 | opt_prob = Optimization('TOY Constrained Problem',objfunc,use_groups=True) 50 | opt_prob.addVarGroup('a',2,'c',value=1.0, lower=0.0, upper=10) 51 | opt_prob.delVarGroup('a') 52 | opt_prob.addVar('x','c',value=1.0, lower=0.0, upper=10) 53 | opt_prob.addVarGroup('y',2,'c',value=1.0, lower=0.0, upper=10) 54 | opt_prob.delVarGroup('y') 55 | opt_prob.addVarGroup('z',1,'c',value=1.0, lower=0.0, upper=10) 56 | opt_prob.addVarGroup('b',5,'c',value=3.0, lower=0.0, upper=10) 57 | opt_prob.delVarGroup('b') 58 | opt_prob.addObj('f') 59 | opt_prob.addCon('g1','i') 60 | opt_prob.addCon('g2','i') 61 | print(opt_prob) 62 | 63 | # Instantiate Optimizer (SLSQP) & Solve Problem 64 | slsqp = SLSQP() 65 | slsqp(opt_prob) 66 | print(opt_prob.solution(0)) 67 | -------------------------------------------------------------------------------- /examples/history.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | """Solves Constrained Toy Problem Storing Optimization History. 3 | 4 | min x1^2 + x2^2 5 | s.t.: 3 - x1 <= 0 6 | 2 - x2 <= 0 7 | -10 <= x1 <= 10 8 | -10 <= x2 <= 10 9 | """ 10 | 11 | from pyOpt import SLSQP, Optimization 12 | 13 | 14 | def objfunc(x): 15 | f = x[0] ** 2 + x[1] ** 2 16 | g = [ 17 | 3 - x[0], 18 | 2 - x[1], 19 | ] 20 | fail = 0 21 | 22 | return f, g, fail 23 | 24 | 25 | # ============================================================================= 26 | # 27 | # ============================================================================= 28 | 29 | # Instantiate Optimization Problem 30 | opt_prob = Optimization('TOY Constrained Problem', objfunc) 31 | opt_prob.addVar('x1', 'c', value=1.0, lower=0.0, upper=10.0) 32 | opt_prob.addVar('x2', 'c', value=1.0, lower=0.0, upper=10.0) 33 | opt_prob.addObj('f') 34 | opt_prob.addCon('g1', 'i') 35 | opt_prob.addCon('g2', 'i') 36 | print(opt_prob) 37 | 38 | # Instantiate Optimizer (SLSQP) & Solve Problem Storing History 39 | slsqp = SLSQP() 40 | slsqp.setOption('IFILE', 'slsqp1.out') 41 | slsqp(opt_prob, store_hst=True) 42 | print(opt_prob.solution(0)) 43 | 44 | # Solve Problem Using Stored History (Warm Start) 45 | slsqp.setOption('IFILE', 'slsqp2.out') 46 | slsqp(opt_prob, store_hst=True, hot_start='slsqp1') 47 | print(opt_prob.solution(1)) 48 | -------------------------------------------------------------------------------- /examples/nsga2_multi_objective.py: -------------------------------------------------------------------------------- 1 | from pyOpt import NSGA2, Optimization 2 | 3 | 4 | def objfunc(xdict): 5 | x = xdict['x'] 6 | y = xdict['y'] 7 | 8 | ff = [ 9 | (x - 0.0)**2 + (y - 0.0)**2, 10 | (x - 1.0)**2 + (y - 1.0)**2, 11 | ] 12 | gg = [] 13 | fail = False 14 | 15 | return ff, gg, fail 16 | 17 | 18 | # Instantiate Optimization Problem 19 | optProb = Optimization('Rosenbrock function', objfunc, use_groups=True) 20 | optProb.addVar('x', 'c', value=0, lower=-600, upper=600) 21 | optProb.addVar('y', 'c', value=0, lower=-600, upper=600) 22 | 23 | optProb.addObj('obj1') 24 | optProb.addObj('obj2') 25 | 26 | # 300 generations will find x=(0,0), 200 or less will find x=(1,1) 27 | options = { 28 | 'maxGen': 200, 29 | } 30 | opt = NSGA2(options=options) 31 | opt.setOption('PrintOut', 0) 32 | opt(optProb) 33 | 34 | print(optProb.getSol(0)) 35 | -------------------------------------------------------------------------------- /examples/parallel_alpso.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | """Solves Runarsson's G08 Problem Using ALPSO Parallelization Options. 3 | 4 | min -(sin(2*pi*x1)**3*sin(2*pi*x2)) 5 | s.t.: x1**2 - x2 + 1 <= 0 6 | 1 - x1 + (x2-4)**2 <= 0 7 | 0 <= xi <= 10, i = 1,2 8 | 9 | x* = [1.2279713, 4.2453733] 10 | f* = -0.095825 11 | """ 12 | 13 | import math 14 | # ============================================================================= 15 | # Standard Python modules 16 | # ============================================================================= 17 | import os 18 | import sys 19 | import time 20 | 21 | # ============================================================================= 22 | # External Python modules 23 | # ============================================================================= 24 | try: 25 | from mpi4py import MPI 26 | comm = MPI.COMM_WORLD 27 | myrank = comm.Get_rank() 28 | except: 29 | raise ImportError('mpi4py is required for parallelization') 30 | 31 | # ============================================================================= 32 | # Extension modules 33 | # ============================================================================= 34 | #from pyOpt import * 35 | from pyOpt import ALPSO, Optimization 36 | 37 | 38 | # ============================================================================= 39 | # 40 | # ============================================================================= 41 | def objfunc(x): 42 | 43 | f = -(((math.sin(2*math.pi*x[0])**3)*math.sin(2*math.pi*x[1]))/((x[0]**3)*(x[0]+x[1]))) 44 | 45 | g = [0.0]*2 46 | g[0] = x[0]**2 - x[1] + 1 47 | g[1] = 1 - x[0] + (x[1]-4)**2 48 | 49 | time.sleep(0.01) 50 | 51 | fail = 0 52 | return f,g, fail 53 | 54 | 55 | # ============================================================================= 56 | # 57 | # ============================================================================= 58 | 59 | # Instantiate Optimization Problem 60 | opt_prob = Optimization('G08 Global Constrained Problem',objfunc) 61 | opt_prob.addVar('x1','c',lower=5.0,upper=1e-6,value=10.0) 62 | opt_prob.addVar('x2','c',lower=5.0,upper=1e-6,value=10.0) 63 | opt_prob.addObj('f') 64 | opt_prob.addCon('g1','i') 65 | opt_prob.addCon('g2','i') 66 | 67 | # Solve Problem (No-Parallelization) 68 | alpso_none = ALPSO() 69 | alpso_none.setOption('fileout',0) 70 | alpso_none(opt_prob) 71 | if myrank == 0: 72 | print(opt_prob.solution(0)) 73 | 74 | # Solve Problem (SPM-Parallelization) 75 | alpso_spm = ALPSO(pll_type='SPM') 76 | alpso_spm.setOption('fileout',0) 77 | alpso_spm(opt_prob) 78 | print(opt_prob.solution(1)) 79 | 80 | # Solve Problem (DPM-Parallelization) 81 | alpso_poa = ALPSO(pll_type='POA') 82 | alpso_poa.setOption('fileout',0) 83 | alpso_poa(opt_prob) 84 | print(opt_prob.solution(2)) 85 | -------------------------------------------------------------------------------- /examples/parallel_gradient.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | """Solves Schittkowski's TP37 Problem Using Gradient Parallelization. 3 | 4 | min -x1*x2*x3 5 | s.t.: x1 + 2.*x2 + 2.*x3 - 72 <= 0 6 | - x1 - 2.*x2 - 2.*x3 <= 0 7 | 0 <= xi <= 42, i = 1,2,3 8 | 9 | f* = -3456 , x* = [24, 12, 12] 10 | """ 11 | 12 | # ============================================================================= 13 | # Standard Python modules 14 | # ============================================================================= 15 | import os 16 | import sys 17 | import time 18 | 19 | # ============================================================================= 20 | # External Python modules 21 | # ============================================================================= 22 | try: 23 | from mpi4py import MPI 24 | comm = MPI.COMM_WORLD 25 | myrank = comm.Get_rank() 26 | except: 27 | raise ImportError('mpi4py is required for parallelization') 28 | 29 | # ============================================================================= 30 | # Extension modules 31 | # ============================================================================= 32 | #from pyOpt import * 33 | from pyOpt import SLSQP, Optimization 34 | 35 | 36 | # ============================================================================= 37 | # 38 | # ============================================================================= 39 | def objfunc(x): 40 | 41 | f = -x[0]*x[1]*x[2] 42 | g = [ 43 | x[0] + 2.*x[1] + 2.*x[2] - 72.0, 44 | -x[0] - 2.*x[1] - 2.*x[2], 45 | ] 46 | 47 | time.sleep(0.3) 48 | 49 | fail = 0 50 | return f,g, fail 51 | 52 | 53 | # ============================================================================= 54 | # 55 | # ============================================================================= 56 | 57 | # Instantiate Optimization Problem 58 | opt_prob = Optimization('TP37 Constrained Problem',objfunc) 59 | opt_prob.addVar('x1','c',lower=0.0,upper=42.0,value=10.0) 60 | opt_prob.addVar('x2','c',lower=0.0,upper=42.0,value=10.0) 61 | opt_prob.addVar('x3','c',lower=0.0,upper=42.0,value=10.0) 62 | opt_prob.addObj('f') 63 | opt_prob.addCon('g1','i') 64 | opt_prob.addCon('g2','i') 65 | 66 | # Instantiate Optimizer (SLSQP) 67 | slsqp = SLSQP() 68 | slsqp.setOption('IPRINT',-1) 69 | 70 | # Solve Problem (Without Parallel Gradient) 71 | slsqp(opt_prob,sens_type='CS') 72 | if myrank == 0: 73 | print(opt_prob.solution(0)) 74 | 75 | # Solve Problem (With Parallel Gradient) 76 | slsqp(opt_prob,sens_type='CS',sens_mode='pgc') 77 | print(opt_prob.solution(1)) 78 | -------------------------------------------------------------------------------- /examples/parallel_ipopt.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | """Solves Schittkowski's TP37 Problem Using Gradient Parallelization. 3 | 4 | min -x1*x2*x3 5 | s.t.: x1 + 2.*x2 + 2.*x3 - 72 <= 0 6 | - x1 - 2.*x2 - 2.*x3 <= 0 7 | 0 <= xi <= 42, i = 1,2,3 8 | 9 | f* = -3456 , x* = [24, 12, 12] 10 | """ 11 | 12 | import time 13 | 14 | try: 15 | from mpi4py import MPI 16 | comm = MPI.COMM_WORLD 17 | myrank = comm.Get_rank() 18 | except: 19 | raise ImportError('mpi4py is required for parallelization') 20 | 21 | from pyOpt import IPOPT, Optimization 22 | 23 | 24 | def objfunc(x): 25 | f = -x[0] * x[1] * x[2] 26 | g = [ 27 | x[0] + 2. * x[1] + 2. * x[2] - 72.0, 28 | -x[0] - 2. * x[1] - 2. * x[2], 29 | ] 30 | 31 | time.sleep(0.1) 32 | 33 | fail = 0 34 | return f, g, fail 35 | 36 | 37 | # Instantiate Optimization Problem 38 | opt_prob = Optimization('TP37 Constrained Problem', objfunc) 39 | opt_prob.addVar('x1', 'c', lower=0.0, upper=42.0, value=10.0) 40 | opt_prob.addVar('x2', 'c', lower=0.0, upper=42.0, value=10.0) 41 | opt_prob.addVar('x3', 'c', lower=0.0, upper=42.0, value=10.0) 42 | opt_prob.addObj('f') 43 | opt_prob.addCon('g1', 'i') 44 | opt_prob.addCon('g2', 'i') 45 | 46 | # Instantiate Optimizer 47 | ipopt = IPOPT() 48 | ipopt.setOption('print_level', 0) # 0 none ... 5 max 49 | 50 | # Solve Problem (Without Parallel Gradient) 51 | ipopt(opt_prob, sens_type='CS') 52 | if myrank == 0: 53 | print(opt_prob.solution(0)) 54 | 55 | # Solve Problem (With Parallel Gradient) 56 | ipopt(opt_prob, sens_type='CS', sens_mode='pgc') 57 | print(opt_prob.solution(1)) 58 | -------------------------------------------------------------------------------- /examples/parallel_midaco.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | """Solves MIDACO's Toy Problem Using MIDACO's Parallelization. 3 | 4 | min (x1-1.0)**2 + (x2-2.0)**2 + (x3-3.0)**2 + (x4-4.0)**2 + 1.23456789 5 | s.t.: x1 - 1.0 = 0 6 | 1.333333333 - x2 <= 0 7 | 2.666666666 - x3 <= 0 8 | 1 <= xi <= 4, i = 1,...,4 9 | 10 | x* = [, ] 11 | f* = 12 | """ 13 | 14 | # ============================================================================= 15 | # Standard Python modules 16 | # ============================================================================= 17 | import os 18 | import sys 19 | import time 20 | 21 | # ============================================================================= 22 | # External Python modules 23 | # ============================================================================= 24 | try: 25 | from mpi4py import MPI 26 | comm = MPI.COMM_WORLD 27 | myrank = comm.Get_rank() 28 | except: 29 | raise ImportError('mpi4py is required for parallelization') 30 | 31 | # ============================================================================= 32 | # Extension modules 33 | # ============================================================================= 34 | #from pyOpt import * 35 | from pyOpt import MIDACO, Optimization 36 | 37 | 38 | # ============================================================================= 39 | # 40 | # ============================================================================= 41 | def objfunc(x): 42 | 43 | f = (x[0]-1.0)**2 + (x[1]-2.0)**2 + (x[2]-3.0)**2 + (x[3]-4.0)**2 + 1.23456789 44 | 45 | g = [0.0]*3 46 | g[0] = x[0] - 1.0 47 | g[1] = 1.333333333 - x[1] 48 | g[2] = 2.666666666 - x[2] 49 | 50 | time.sleep(0.0002) 51 | 52 | fail = 0 53 | return f,g, fail 54 | 55 | 56 | # ============================================================================= 57 | # 58 | # ============================================================================= 59 | 60 | # Instantiate Optimization Problem 61 | opt_prob = Optimization('MIDACO Toy Problem',objfunc) 62 | opt_prob.addVar('x1','c',lower=1.0,upper=4.0,value=1.0) 63 | opt_prob.addVar('x2','c',lower=1.0,upper=4.0,value=1.0) 64 | opt_prob.addVar('x3','c',lower=1.0,upper=4.0,value=1.0) 65 | opt_prob.addVar('x4','c',lower=1.0,upper=4.0,value=1.0) 66 | opt_prob.addObj('f') 67 | opt_prob.addCon('g1','e') 68 | opt_prob.addCon('g2','i') 69 | opt_prob.addCon('g3','i') 70 | 71 | # Solve Problem (No-Parallelization) 72 | midaco_none = MIDACO() 73 | midaco_none.setOption('IPRINT',-1) 74 | midaco_none.setOption('MAXEVAL',50000) 75 | midaco_none(opt_prob) 76 | if myrank == 0: 77 | print(opt_prob.solution(0)) 78 | 79 | # Solve Problem (SPM-Parallelization) 80 | midaco_spm = MIDACO(pll_type='SPM') 81 | midaco_spm.setOption('IPRINT',-1) 82 | midaco_none.setOption('MAXEVAL',50000) 83 | midaco_spm(opt_prob) 84 | print(opt_prob.solution(1)) 85 | -------------------------------------------------------------------------------- /examples/parallel_nlpqlp.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | """Solves Schittkowski's TP37 Constrained Problem Using NLPQLP's Parallel Line Search. 3 | 4 | min -x1*x2*x3 5 | s.t.: x1 + 2.*x2 + 2.*x3 - 72 <= 0 6 | - x1 - 2.*x2 - 2.*x3 <= 0 7 | 0 <= xi <= 42, i = 1,2,3 8 | 9 | f* = -3456 , x* = [24, 12, 12] 10 | """ 11 | 12 | # ============================================================================= 13 | # Standard Python modules 14 | # ============================================================================= 15 | import os 16 | import sys 17 | import time 18 | 19 | # ============================================================================= 20 | # External Python modules 21 | # ============================================================================= 22 | try: 23 | from mpi4py import MPI 24 | comm = MPI.COMM_WORLD 25 | myrank = comm.Get_rank() 26 | except: 27 | raise ImportError('mpi4py is required for parallelization') 28 | 29 | # ============================================================================= 30 | # Extension modules 31 | # ============================================================================= 32 | #from pyOpt import * 33 | from pyOpt import NLPQLP, Optimization 34 | 35 | 36 | # ============================================================================= 37 | # 38 | # ============================================================================= 39 | def objfunc(x): 40 | 41 | f = -x[0]*x[1]*x[2] 42 | g = [0.0]*2 43 | g[0] = x[0] + 2.*x[1] + 2.*x[2] - 72.0 44 | g[1] = -x[0] - 2.*x[1] - 2.*x[2] 45 | 46 | time.sleep(0.5) 47 | 48 | fail = 0 49 | return f,g, fail 50 | 51 | 52 | # ============================================================================= 53 | # 54 | # ============================================================================= 55 | 56 | # Instantiate Optimization Problem 57 | opt_prob = Optimization('TP37 Constrained Problem',objfunc) 58 | opt_prob.addVar('x1','c',lower=0.0,upper=42.0,value=10.0) 59 | opt_prob.addVar('x2','c',lower=0.0,upper=42.0,value=10.0) 60 | opt_prob.addVar('x3','c',lower=0.0,upper=42.0,value=10.0) 61 | opt_prob.addObj('f') 62 | opt_prob.addCon('g1','i') 63 | opt_prob.addCon('g2','i') 64 | 65 | # Solve Problem (No-Parallelization) 66 | nlpqlp_none = NLPQLP() 67 | nlpqlp_none.setOption('IPRINT',0) 68 | nlpqlp_none(opt_prob) 69 | if myrank == 0: 70 | print(opt_prob.solution(0)) 71 | 72 | # Solve Problem (Parallel Gradient) 73 | nlpqlp_pgc = NLPQLP() 74 | nlpqlp_pgc.setOption('IPRINT',0) 75 | nlpqlp_pgc(opt_prob,sens_mode='pgc') 76 | if myrank == 0: 77 | print(opt_prob.solution(1)) 78 | 79 | # Solve Problem (Parallel Line Search) 80 | nlpqlp_spm = NLPQLP(pll_type='SPM') 81 | nlpqlp_spm.setOption('IPRINT',0) 82 | nlpqlp_spm(opt_prob) 83 | print(opt_prob.solution(2)) 84 | -------------------------------------------------------------------------------- /examples/passing_args.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | """Solves Constrained Rosenbrock's Passing Arguments into Objective Function. 3 | 4 | min A1*(X(2)-X(1)^2)^2 + (A2-x(1))^2 5 | s.t.: X(1)^2 + X(2)^2 - A2 <= 0 6 | -1.0 <= xi <= 1.0, i = 1,2 7 | 8 | arguments (passing into objfunc as kwargs) 9 | A1 = 100.0, A2 = 1.0 (kwarg passing as list of args) 10 | A3 = 1.0 (kwarg passing as single arg) 11 | 12 | f* = 0.0457 , x* = [0.7864, 0.6177] 13 | """ 14 | 15 | from pyOpt import SLSQP, Optimization 16 | 17 | 18 | def objfunc(x, **kwargs): 19 | a1 = kwargs['a12'][0] 20 | a2 = kwargs['a12'][1] 21 | a3 = kwargs['a3'] 22 | 23 | f = a1 * (x[1] - x[0] ** 2.) ** 2. + (a2 - x[0]) ** 2. 24 | g = [ 25 | x[0] ** 2. + x[1] ** 2.0 - a3, 26 | ] 27 | 28 | fail = 0 29 | return f, g, fail 30 | 31 | 32 | # ============================================================================= 33 | # 34 | # ============================================================================= 35 | 36 | # Instantiate Optimization Problem 37 | opt_prob = Optimization('Rosenbrock Constrained Problem', objfunc) 38 | opt_prob.addVar('x1', 'c', lower=0.0, upper=1.0, value=0.5) 39 | opt_prob.addVar('x2', 'c', lower=0.0, upper=1.0, value=0.5) 40 | opt_prob.addObj('f') 41 | opt_prob.addCon('g1', 'i') 42 | print(opt_prob) 43 | 44 | # Arguments to pass into objfunc 45 | a1 = 100.0 46 | a2 = 1.0 47 | a3 = 1.0 48 | 49 | # Instantiate Optimizer (SLSQP) & Solve Problem 50 | slsqp = SLSQP() 51 | slsqp.setOption('IPRINT', -1) 52 | slsqp(opt_prob, sens_type='FD', a12=[a1, a2], a3=a3) 53 | print(opt_prob.solution(0)) 54 | -------------------------------------------------------------------------------- /examples/rosenbrock.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | """Solves Rosenbrock's Unconstrained Problem. 3 | 4 | min 100*(x2-x1^2)**2 + (1-x1)^2 s.t.: -10 <= xi <= 10, i = 1,2 5 | 6 | f* = 0 , x* = [1, 1] 7 | """ 8 | 9 | from pyOpt import Optimization 10 | 11 | 12 | def objfunc(x): 13 | f = 100 * (x[1] - x[0] ** 2) ** 2 + (1 - x[0]) ** 2 14 | g = [] 15 | 16 | fail = 0 17 | return f, g, fail 18 | 19 | 20 | def getlastsolution(prob: Optimization): 21 | new_index = prob.firstavailableindex(prob.getSolSet()) 22 | return prob.getSol(new_index - 1) 23 | 24 | 25 | # Instantiate Optimization Problem 26 | opt_prob = Optimization('Rosenbrock Unconstraint Problem', objfunc) 27 | opt_prob.addVar('x1', 'c', lower=-10.0, upper=10.0, value=-3.0) 28 | opt_prob.addVar('x2', 'c', lower=-10.0, upper=10.0, value=-4.0) 29 | opt_prob.addObj('f') 30 | print(opt_prob) 31 | 32 | # Instantiate Optimizer (PSQP) & Solve Problem 33 | from pyOpt import PSQP 34 | 35 | psqp = PSQP() 36 | psqp.setOption('IPRINT', 0) 37 | psqp(opt_prob, sens_type='FD') 38 | print(opt_prob.solution(0)) 39 | 40 | # Instantiate Optimizer (SLSQP) & Solve Problem 41 | from pyOpt import SLSQP 42 | 43 | slsqp = SLSQP() 44 | slsqp.setOption('IPRINT', -1) 45 | slsqp(opt_prob, sens_type='FD') 46 | print(getlastsolution(opt_prob)) 47 | 48 | # Instantiate Optimizer (CONMIN) & Solve Problem 49 | from pyOpt import CONMIN 50 | 51 | conmin = CONMIN() 52 | conmin.setOption('IPRINT', 0) 53 | conmin(opt_prob, sens_type='CS') 54 | print(getlastsolution(opt_prob)) 55 | 56 | # Instantiate Optimizer (COBYLA) & Solve Problem 57 | from pyOpt import COBYLA 58 | 59 | cobyla = COBYLA() 60 | cobyla.setOption('IPRINT', 0) 61 | cobyla(opt_prob) 62 | print(getlastsolution(opt_prob)) 63 | 64 | # Instantiate Optimizer (SOLVOPT) & Solve Problem 65 | from pyOpt import SOLVOPT 66 | 67 | solvopt = SOLVOPT() 68 | solvopt.setOption('iprint', -1) 69 | solvopt(opt_prob, sens_type='FD') 70 | print(getlastsolution(opt_prob)) 71 | 72 | # Instantiate Optimizer (KSOPT) & Solve Problem 73 | from pyOpt import KSOPT 74 | 75 | ksopt = KSOPT() 76 | ksopt.setOption('IPRINT', 0) 77 | ksopt(opt_prob, sens_type='FD') 78 | print(getlastsolution(opt_prob)) 79 | 80 | # Instantiate Optimizer (NSGA2) & Solve Problem 81 | from pyOpt import NSGA2 82 | 83 | nsga2 = NSGA2() 84 | nsga2.setOption('PrintOut', 0) 85 | nsga2(opt_prob) 86 | print(getlastsolution(opt_prob)) 87 | 88 | # Instantiate Optimizer (SDPEN) & Solve Problem 89 | from pyOpt import SDPEN 90 | 91 | sdpen = SDPEN() 92 | sdpen.setOption('iprint', -1) 93 | sdpen(opt_prob) 94 | print(getlastsolution(opt_prob)) 95 | -------------------------------------------------------------------------------- /examples/usersens.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | """Solves Constrained Rosen-Suzuki Function. 3 | 4 | - Different gradient calculation approaches are used 5 | 6 | f* = -6 , x* = [0, 1, 2, -1] 7 | """ 8 | 9 | import numpy 10 | 11 | from pyOpt import CONMIN, Optimization 12 | 13 | 14 | def objfunc(x): 15 | f = x[0] ** 2 - 5. * x[0] + x[1] ** 2 - 5. * x[1] + 2. * x[2] ** 2 - 21. * x[2] + x[3] ** 2 + 7.0 * x[3] + 50. 16 | g = [ 17 | x[0] ** 2 + x[0] + x[1] ** 2 - x[1] + x[2] ** 2 + x[2] + x[3] ** 2 - x[3] - 8.0, 18 | x[0] ** 2 - x[0] + 2. * x[1] ** 2 + x[2] ** 2 + 2. * x[3] ** 2 - x[3] - 10.0, 19 | 2. * x[0] ** 2 + 2. * x[0] + x[1] ** 2 - x[1] + x[2] ** 2 - x[3] - 5.0, 20 | ] 21 | fail = 0 22 | 23 | return f, g, fail 24 | 25 | 26 | def gradfunc(x, f, g): 27 | g_obj = [ 28 | 2. * x[0] - 5, 29 | 2. * x[1] - 5, 30 | 4. * x[2] - 21, 31 | 2. * x[3] + 7, 32 | ] 33 | 34 | g_con = numpy.zeros([3, 4]) 35 | g_con[0][0] = 2. * x[0] + 1 36 | g_con[0][1] = 2. * x[1] - 1 37 | g_con[0][2] = 2. * x[2] + 1 38 | g_con[0][3] = 2. * x[3] - 1 39 | g_con[1][0] = 2. * x[0] - 1 40 | g_con[1][1] = 4. * x[1] 41 | g_con[1][2] = 2. * x[2] 42 | g_con[1][3] = 4. * x[3] - 1 43 | g_con[2][0] = 4. * x[0] + 2 44 | g_con[2][1] = 2. * x[1] - 1 45 | g_con[2][2] = 2. * x[2] 46 | g_con[2][3] = -1. 47 | 48 | fail = 0 49 | 50 | return g_obj, g_con, fail 51 | 52 | 53 | def getlastsolution(prob: Optimization): 54 | new_index = prob.firstavailableindex(prob.getSolSet()) 55 | return prob.getSol(new_index - 1) 56 | 57 | 58 | # ============================================================================= 59 | # 60 | # ============================================================================= 61 | 62 | # Instantiate Optimization Problem 63 | opt_prob = Optimization('Constrained Rosen-Suzuki', objfunc) 64 | opt_prob.addVar('x1', 'c', value=1.5) 65 | opt_prob.addVar('x2', 'c', value=1.5) 66 | opt_prob.addVar('x3', 'c', value=1.5) 67 | opt_prob.addVar('x4', 'c', value=1.5) 68 | opt_prob.addObj('f') 69 | opt_prob.addCon('g1', 'i') 70 | opt_prob.addCon('g2', 'i') 71 | opt_prob.addCon('g3', 'i') 72 | print(opt_prob) 73 | 74 | # Instantiate Optimizer (CONMIN) 75 | conmin = CONMIN() 76 | 77 | # Solve Problem with Optimizer Using Finite Differences 78 | conmin(opt_prob, sens_type='FD') 79 | print(getlastsolution(opt_prob)) 80 | 81 | # Solve Problem with Optimizer Using Complex Step 82 | conmin(opt_prob, sens_type='CS') 83 | print(getlastsolution(opt_prob)) 84 | 85 | # Solve Problem with Optimizer Using User-Provided Sensitivities 86 | conmin(opt_prob, sens_type=gradfunc) 87 | print(getlastsolution(opt_prob)) 88 | -------------------------------------------------------------------------------- /pyOpt/__init__.py: -------------------------------------------------------------------------------- 1 | from .pyALGENCAN import * 2 | from .pyALHSO import * 3 | from .pyALPSO import * 4 | from .pyCOBYLA import * 5 | from .pyCONMIN import * 6 | from .pyFILTERSD import * 7 | # from .pyFSQP import FSQP 8 | # from .pyGCMMA import GCMMA 9 | # from .pyIPOPT import IPOPT 10 | from .pyKSOPT import * 11 | from .pyMIDACO import * 12 | # from .pyMMA import MMA 13 | # from .pyMMFD import MMFD 14 | # from .pyNLPQL import NLPQL 15 | # from .pyNLPQLP import NLPQLP 16 | from .pyNSGA2 import * 17 | from .pyOpt_constraint import Constraint 18 | from .pyOpt_gradient import Gradient 19 | from .pyOpt_history import History 20 | from .pyOpt_objective import Objective 21 | from .pyOpt_optimization import Optimization 22 | from .pyOpt_optimizer import Optimizer 23 | from .pyOpt_parameter import Parameter 24 | from .pyOpt_variable import Variable 25 | from .pyPSQP import * 26 | from .pySDPEN import * 27 | from .pySLSQP import * 28 | # from .pySNOPT import SNOPT 29 | from .pySOLVOPT import * 30 | 31 | # from .version import version as __version__ 32 | 33 | 34 | __all__ = ['History', 'Parameter', 'Variable', 'Gradient', 'Constraint', 'Objective', 'Optimization', 'Optimizer'] 35 | -------------------------------------------------------------------------------- /pyOpt/pyALGENCAN/README: -------------------------------------------------------------------------------- 1 | This directory contains the algencan class definition and 2 | the algencan shared library, algencan.so or algencan.pyd. 3 | -------------------------------------------------------------------------------- /pyOpt/pyALGENCAN/__init__.py: -------------------------------------------------------------------------------- 1 | try: 2 | from .pyALGENCAN import ALGENCAN 3 | __all__ = ['ALGENCAN'] 4 | except: 5 | __all__ = [] 6 | -------------------------------------------------------------------------------- /pyOpt/pyALGENCAN/setup.py: -------------------------------------------------------------------------------- 1 | import os 2 | 3 | 4 | def configuration(parent_package='',top_path=None): 5 | from numpy.distutils.misc_util import Configuration 6 | 7 | config = Configuration('pyALGENCAN',parent_package,top_path) 8 | config.add_library('algencan', 9 | sources=[os.path.join('source', '*.f')], 10 | ) 11 | config.add_extension('algencan', 12 | sources=['source/f2py/algencan.pyf'], 13 | libraries=['algencan'], 14 | ) 15 | config.add_data_files('LICENSE', 'README') 16 | 17 | return config 18 | 19 | 20 | if __name__ == '__main__': 21 | from numpy.distutils.core import setup 22 | setup(**configuration(top_path='').todict()) 23 | -------------------------------------------------------------------------------- /pyOpt/pyALGENCAN/source/README: -------------------------------------------------------------------------------- 1 | This directory contains the Fortran 77 source for ALGENCAN, 2 | modified for pyOpt interfacing by Dr. Ruben E. Perez, 3 | plus two helper files called openunit.f and closeunit.f 4 | to manipulate Fortran units from Python. 5 | -------------------------------------------------------------------------------- /pyOpt/pyALGENCAN/source/algconst.par: -------------------------------------------------------------------------------- 1 | C PARAMETERS 2 | 3 | C General constants 4 | 5 | double precision fmin 6 | 7 | parameter ( fmin = - 1.0d+20 ) 8 | 9 | C Line search constants 10 | 11 | integer maxextrap,mininterp 12 | double precision beta,etaint,etaext,gamma,sigma1,sigma2 13 | 14 | parameter ( maxextrap = 100 ) 15 | parameter ( mininterp = 4 ) 16 | 17 | parameter ( gamma = 1.0d-04 ) 18 | parameter ( beta = 0.5d0 ) 19 | parameter ( sigma1 = 0.1d0 ) 20 | parameter ( sigma2 = 0.9d0 ) 21 | parameter ( etaint = 2.0d0 ) 22 | parameter ( etaext = 2.0d0 ) 23 | 24 | C Safeguarding spectral step constants 25 | 26 | double precision lspgma,lspgmi 27 | 28 | parameter ( lspgma = 1.0d+10 ) 29 | parameter ( lspgmi = 1.0d-10 ) 30 | 31 | C Conjugate gradients constants 32 | 33 | integer maxcgitnp 34 | double precision epsnqmp,theta 35 | 36 | parameter ( theta = 1.0d-06 ) 37 | parameter ( epsnqmp = 1.0d-08 ) 38 | parameter ( maxcgitnp = 5 ) 39 | 40 | C BETRA constants 41 | 42 | logical extrp4,extrp5 43 | integer msmaxit 44 | double precision mseps,msrho,mssig,phieps,trdelini,trdelmin, 45 | + tralpha 46 | 47 | parameter ( extrp4 = .true. ) 48 | parameter ( extrp5 = .true. ) 49 | 50 | parameter ( msmaxit = 20 ) 51 | 52 | parameter ( mseps = 1.0d-08 ) 53 | parameter ( mssig = 1.0d-01 ) 54 | parameter ( msrho = 9.0d-01 ) 55 | parameter ( phieps = 1.0d-08 ) 56 | parameter ( trdelini = 1.0d+02 ) 57 | parameter ( trdelmin = 1.0d-08 ) 58 | parameter ( tralpha = 1.0d-01 ) 59 | 60 | C GENCAN constants 61 | 62 | integer maxinnitnp 63 | double precision cggpnf,cgepsi,cgepsf,delmin,eta 64 | 65 | parameter ( maxinnitnp = 3 ) 66 | parameter ( delmin = 1.0d+04 ) 67 | parameter ( eta = 0.1d0 ) 68 | parameter ( cggpnf = 1.0d-04 ) 69 | parameter ( cgepsi = 1.0d-01 ) 70 | parameter ( cgepsf = 1.0d-08 ) 71 | 72 | C ALGENCAN constants 73 | 74 | logical rhorestart 75 | integer maxoutitnp,maxoutit 76 | double precision lammax,lammin,rhofrac,rhoinimax,rhoinimin,rhomax, 77 | + rhomult 78 | 79 | parameter ( maxoutitnp = 10 ) 80 | parameter ( maxoutit = 100 ) 81 | 82 | parameter ( lammin = - 1.0d+20 ) 83 | parameter ( lammax = 1.0d+20 ) 84 | 85 | parameter ( rhofrac = 0.5d0 ) 86 | parameter ( rhomult = 1.0d+01 ) 87 | parameter ( rhomax = 1.0d+20 ) 88 | 89 | parameter ( rhorestart = .true. ) 90 | parameter ( rhoinimin = 1.0d-08 ) 91 | parameter ( rhoinimax = 1.0d+08 ) 92 | -------------------------------------------------------------------------------- /pyOpt/pyALGENCAN/source/algparam.inc: -------------------------------------------------------------------------------- 1 | C COMMON SCALARS 2 | character * 6 hptype 3 | character * 2 innslvr 4 | logical ccoded,fccoded,fcoded,gcoded,gjaccoded,gjacpcoded, 5 | + innercall,jaccoded,jacpcoded,hcoded,hccoded,hlcoded, 6 | + hlpcoded,firstde,seconde,truehpr,ignoref,skipacc,sclsys, 7 | + useustp,safemode 8 | 9 | C COMMON BLOCKS 10 | common /algparam/ fcoded,gcoded,hcoded,ccoded,jaccoded,jacpcoded, 11 | + hccoded,hlcoded,hlpcoded,fccoded,gjaccoded, 12 | + gjacpcoded,firstde,seconde,truehpr,ignoref, 13 | + skipacc,sclsys,innercall,useustp,innslvr,hptype, 14 | + safemode 15 | save /algparam/ 16 | -------------------------------------------------------------------------------- /pyOpt/pyALGENCAN/source/auglag.f: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/madebr/pyOpt/635f1209f82c22fd6fb4063fa8cb99778e8dcf9c/pyOpt/pyALGENCAN/source/auglag.f -------------------------------------------------------------------------------- /pyOpt/pyALGENCAN/source/betra.f: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/madebr/pyOpt/635f1209f82c22fd6fb4063fa8cb99778e8dcf9c/pyOpt/pyALGENCAN/source/betra.f -------------------------------------------------------------------------------- /pyOpt/pyALGENCAN/source/closeunit.f: -------------------------------------------------------------------------------- 1 | C Helper subroutine to close files in the Fortran world 2 | subroutine closeunit(unitnum) 3 | 4 | integer unitnum 5 | Cf2py intent(in) unitnum 6 | 7 | close(unitnum) 8 | 9 | return 10 | end 11 | -------------------------------------------------------------------------------- /pyOpt/pyALGENCAN/source/counters.inc: -------------------------------------------------------------------------------- 1 | C COMMON SCALARS 2 | integer efcnt,efccnt,egcnt,egjccnt,egjcpcnt,ehcnt,ehlcnt,ehlpcnt, 3 | + fcnt 4 | 5 | C COMMON ARRAYS 6 | integer eccnt(mmax),ehccnt(mmax),ejccnt(mmax) 7 | 8 | C COMMON BLOCKS 9 | common /counters/ eccnt,ehccnt,ejccnt,efcnt,efccnt,egcnt,egjccnt, 10 | + egjcpcnt,ehcnt,ehlcnt,ehlpcnt,fcnt 11 | save /counters/ 12 | -------------------------------------------------------------------------------- /pyOpt/pyALGENCAN/source/dim.par: -------------------------------------------------------------------------------- 1 | C PARAMETERS 2 | 3 | integer mmax,nmax,nsmax,nsysmax,nnzmax,jcnnzmax,hnnzmax 4 | 5 | parameter ( mmax = 5000 ) 6 | parameter ( nmax = 5000 ) 7 | parameter ( nsmax = 1000 ) 8 | parameter ( nsysmax = 50000 ) 9 | parameter ( nnzmax = 100000 ) 10 | parameter ( jcnnzmax = 100000 ) 11 | parameter ( hnnzmax = 100000 ) 12 | -------------------------------------------------------------------------------- /pyOpt/pyALGENCAN/source/drand.f: -------------------------------------------------------------------------------- 1 | C ****************************************************************** 2 | C ****************************************************************** 3 | 4 | double precision function drand(ix) 5 | 6 | C This is the random number generator of Schrage: 7 | C 8 | C L. Schrage, A more portable Fortran random number generator, ACM 9 | C Transactions on Mathematical Software 5 (1979), 132-138. 10 | 11 | double precision ix 12 | 13 | double precision a,p,b15,b16,xhi,xalo,leftlo,fhi,k 14 | data a/16807.d0/,b15/32768.d0/,b16/65536.d0/,p/2147483647.d0/ 15 | 16 | xhi= ix/b16 17 | xhi= xhi - dmod(xhi,1.d0) 18 | xalo= (ix-xhi*b16)*a 19 | leftlo= xalo/b16 20 | leftlo= leftlo - dmod(leftlo,1.d0) 21 | fhi= xhi*a + leftlo 22 | k= fhi/b15 23 | k= k - dmod(k,1.d0) 24 | ix= (((xalo-leftlo*b16)-p)+(fhi-k*b15)*b16)+k 25 | if (ix.lt.0) ix= ix + p 26 | drand= ix*4.656612875d-10 27 | 28 | return 29 | 30 | end 31 | -------------------------------------------------------------------------------- /pyOpt/pyALGENCAN/source/f2py/README: -------------------------------------------------------------------------------- 1 | This directory contains the f2py signature file. 2 | Do not edit these file unless you really know what you are doing. 3 | -------------------------------------------------------------------------------- /pyOpt/pyALGENCAN/source/fixvar.inc: -------------------------------------------------------------------------------- 1 | C COMMON SCALARS 2 | logical rmfixv 3 | 4 | C COMMON ARRAYS 5 | integer ycor(nmax),yind(0:nmax) 6 | double precision y(nmax) 7 | 8 | C COMMON BLOCKS 9 | common /fixvar/ y,ycor,yind,rmfixv 10 | save /fixvar/ 11 | -------------------------------------------------------------------------------- /pyOpt/pyALGENCAN/source/graddat.inc: -------------------------------------------------------------------------------- 1 | C COMMON SCALARS 2 | logical constrc,gotc,gotj 3 | 4 | C COMMON ARRAYS 5 | integer jcvar(jcnnzmax),jcsta(mmax),jclen(mmax) 6 | double precision c(mmax),dpdc(mmax),g(nmax),gparc(nmax), 7 | + jcval(jcnnzmax),xset(nmax) 8 | 9 | C COMMON BLOCKS 10 | common /gdata/ xset,g,gparc,c,dpdc,jcval,jcvar,jcsta,jclen, 11 | + constrc,gotc,gotj 12 | save /gdata/ 13 | -------------------------------------------------------------------------------- /pyOpt/pyALGENCAN/source/happdat.inc: -------------------------------------------------------------------------------- 1 | C COMMON SCALARS 2 | double precision hlspg,hstds 3 | 4 | C COMMON ARRAYS 5 | double precision hds(nmax) 6 | 7 | C COMMON BLOCKS 8 | common /happdata/ hlspg,hds,hstds 9 | save /happdata/ 10 | -------------------------------------------------------------------------------- /pyOpt/pyALGENCAN/source/hessdat.inc: -------------------------------------------------------------------------------- 1 | C COMMON SCALARS 2 | integer hnnz 3 | 4 | C COMMON ARRAYS 5 | integer hcol(hnnzmax),hlin(hnnzmax) 6 | double precision hval(hnnzmax) 7 | 8 | C COMMON BLOCKS 9 | common /hdata/ hval,hlin,hcol,hnnz 10 | save /hdata/ 11 | -------------------------------------------------------------------------------- /pyOpt/pyALGENCAN/source/hpredat.inc: -------------------------------------------------------------------------------- 1 | C COMMON SCALARS 2 | double precision plspg,psmdyty 3 | 4 | C COMMON ARRAYS 5 | double precision pdiag(nmax),psmdy(nmax) 6 | 7 | C COMMON BLOCKS 8 | common /hpredata/ pdiag,psmdy,plspg,psmdyty 9 | save /hpredata/ 10 | -------------------------------------------------------------------------------- /pyOpt/pyALGENCAN/source/itetyp.inc: -------------------------------------------------------------------------------- 1 | C COMMON SCALARS 2 | logical sameface 3 | integer ittype 4 | 5 | C COMMON BLOCKS 6 | common /itedat/ sameface,ittype 7 | save /itedat/ 8 | -------------------------------------------------------------------------------- /pyOpt/pyALGENCAN/source/machconst.inc: -------------------------------------------------------------------------------- 1 | C COMMON SCALARS 2 | double precision bignum,macheps,macheps12,macheps13,macheps23 3 | 4 | C COMMON BLOCKS 5 | common /machcon/ bignum,macheps,macheps12,macheps13,macheps23 6 | save /machcon/ 7 | -------------------------------------------------------------------------------- /pyOpt/pyALGENCAN/source/openunit.f: -------------------------------------------------------------------------------- 1 | C Helper subroutine to open files in the Fortran world 2 | subroutine openunit(unitnum,filename,filestatus,fileaction,ierror) 3 | 4 | integer unitnum 5 | Cf2py intent(in) unitnum 6 | character*(*) filename 7 | Cf2py intent(in) filename 8 | character*(*) filestatus 9 | Cf2py intent(in) filestatus 10 | character*(*) fileaction 11 | Cf2py intent(in) fileaction 12 | integer ierror 13 | Cf2py intent(out) ierror 14 | 15 | open(unit=unitnum,file=filename,status=filestatus, 16 | > access=fileaction,iostat=ierror) 17 | 18 | return 19 | end 20 | 21 | C Helper routine to flush buffers to files 22 | subroutine pyflush(unitnum) 23 | 24 | integer unitnum 25 | 26 | call flush(unitnum) 27 | 28 | return 29 | end 30 | -------------------------------------------------------------------------------- /pyOpt/pyALGENCAN/source/outtyp.inc: -------------------------------------------------------------------------------- 1 | C COMMON SCALARS 2 | logical iprintctl(7) 3 | integer iprintinn,iprintout,mprint,nprint 4 | 5 | C COMMON BLOCKS 6 | common /outdat/ iprintctl,iprintinn,iprintout,nprint,mprint 7 | save /outdat/ 8 | -------------------------------------------------------------------------------- /pyOpt/pyALGENCAN/source/probdata.inc: -------------------------------------------------------------------------------- 1 | C COMMON SCALARS 2 | integer nbds 3 | 4 | C COMMON BLOCKS 5 | common /probdata/ nbds 6 | save /probdata/ 7 | -------------------------------------------------------------------------------- /pyOpt/pyALGENCAN/source/rspace.inc: -------------------------------------------------------------------------------- 1 | C COMMON SCALARS 2 | integer nt 3 | 4 | C COMMON ARRAYS 5 | integer ind(nmax) 6 | double precision xcomplement(nmax) 7 | 8 | C COMMON BLOCKS 9 | common /rspace/ xcomplement,ind,nt 10 | save /rspace/ 11 | -------------------------------------------------------------------------------- /pyOpt/pyALGENCAN/source/scaling.inc: -------------------------------------------------------------------------------- 1 | C COMMON SCALARS 2 | logical scale 3 | double precision sf,usf 4 | 5 | C COMMON ARRAYS 6 | double precision sc(mmax),usc(mmax) 7 | 8 | C COMMON BLOCK 9 | common /scadat/ sc,usc,sf,usf,scale 10 | save /scadat/ 11 | -------------------------------------------------------------------------------- /pyOpt/pyALGENCAN/source/scl.f: -------------------------------------------------------------------------------- 1 | C sclinfo: 2 | C 3 | C 0: Success. 4 | C 1: Invalid row or column index. 5 | C 2: Duplicate entry. 6 | C 6: Insufficient space to store the input matrix. 7 | C 7: Insufficient double precision working space. 8 | 9 | C ****************************************************************** 10 | C ****************************************************************** 11 | 12 | logical function scl(sclsub) 13 | 14 | implicit none 15 | 16 | C SCALAR ARGUMENTS 17 | character * 4 sclsub 18 | 19 | scl = .false. 20 | return 21 | 22 | end 23 | 24 | C ****************************************************************** 25 | C ****************************************************************** 26 | 27 | subroutine sclini() 28 | 29 | implicit none 30 | 31 | end 32 | 33 | C ****************************************************************** 34 | C ****************************************************************** 35 | 36 | subroutine sclana(nsys,hnnz,hlin,hcol,hval,hdiag,sclinfo) 37 | 38 | implicit none 39 | 40 | C SCALAR ARGUMENTS 41 | integer nsys,hnnz,sclinfo 42 | 43 | C ARRAY ARGUMENTS 44 | integer hlin(hnnz),hcol(hnnz),hdiag(nsys) 45 | double precision hval(hnnz) 46 | 47 | end 48 | 49 | C ****************************************************************** 50 | C ****************************************************************** 51 | 52 | subroutine sclsys(nsys,hnnz,hlin,hcol,hval,s,sclinfo) 53 | 54 | implicit none 55 | 56 | C SCALAR ARGUMENTS 57 | integer nsys,hnnz,sclinfo 58 | 59 | C ARRAY ARGUMENTS 60 | integer hlin(hnnz),hcol(hnnz) 61 | double precision hval(hnnz),s(nsys) 62 | 63 | end 64 | -------------------------------------------------------------------------------- /pyOpt/pyALGENCAN/source/setpoint.f: -------------------------------------------------------------------------------- 1 | C ****************************************************************** 2 | C ****************************************************************** 3 | 4 | subroutine setp(n,x) 5 | 6 | implicit none 7 | 8 | C SCALAR ARGUMENTS 9 | integer n 10 | 11 | C ARRAY ARGUMENTS 12 | double precision x(n) 13 | 14 | end 15 | 16 | C ****************************************************************** 17 | C ****************************************************************** 18 | 19 | subroutine unsetp() 20 | 21 | implicit none 22 | 23 | end 24 | -------------------------------------------------------------------------------- /pyOpt/pyALGENCAN/source/slacks.inc: -------------------------------------------------------------------------------- 1 | C COMMON SCALARS 2 | logical slacks 3 | integer nws 4 | 5 | C COMMON ARRAYS 6 | integer slaind(mmax) 7 | 8 | C COMMON BLOCKS 9 | common /sladat/ slaind,nws,slacks 10 | save /sladat/ 11 | -------------------------------------------------------------------------------- /pyOpt/pyALGENCAN/source/sydat.inc: -------------------------------------------------------------------------------- 1 | C COMMON SCALARS 2 | double precision seucn,sts,sty,yeucn 3 | 4 | C COMMON ARRAYS 5 | double precision s(nmax),y(nmax) 6 | 7 | C COMMON BLOCKS 8 | common /sydata/ s,y,seucn,yeucn,sts,sty 9 | save /sydata/ 10 | -------------------------------------------------------------------------------- /pyOpt/pyALHSO/README: -------------------------------------------------------------------------------- 1 | This directory contains the alhso class definition and source. 2 | -------------------------------------------------------------------------------- /pyOpt/pyALHSO/__init__.py: -------------------------------------------------------------------------------- 1 | try: 2 | from .pyALHSO import ALHSO 3 | __all__ = ['ALHSO'] 4 | except: 5 | __all__ = [] 6 | -------------------------------------------------------------------------------- /pyOpt/pyALHSO/setup.py: -------------------------------------------------------------------------------- 1 | def configuration(parent_package='', top_path=None): 2 | from numpy.distutils.misc_util import Configuration 3 | 4 | config = Configuration('pyALHSO', parent_package,top_path) 5 | config.add_data_files('LICENSE','README') 6 | 7 | return config 8 | 9 | 10 | if __name__ == '__main__': 11 | from numpy.distutils.core import setup 12 | 13 | setup(**configuration(top_path='').todict()) 14 | -------------------------------------------------------------------------------- /pyOpt/pyALPSO/README: -------------------------------------------------------------------------------- 1 | This directory contains the alpso class definition and source. 2 | -------------------------------------------------------------------------------- /pyOpt/pyALPSO/__init__.py: -------------------------------------------------------------------------------- 1 | try: 2 | from .pyALPSO import ALPSO 3 | __all__ = ['ALPSO'] 4 | except: 5 | __all__ = [] 6 | -------------------------------------------------------------------------------- /pyOpt/pyALPSO/setup.py: -------------------------------------------------------------------------------- 1 | def configuration(parent_package='', top_path=None): 2 | from numpy.distutils.misc_util import Configuration 3 | 4 | config = Configuration('pyALPSO', parent_package, top_path) 5 | config.add_data_files('LICENSE', 'README') 6 | 7 | return config 8 | 9 | 10 | if __name__ == '__main__': 11 | from numpy.distutils.core import setup 12 | 13 | setup(**configuration(top_path='').todict()) 14 | -------------------------------------------------------------------------------- /pyOpt/pyCOBYLA/LICENSE: -------------------------------------------------------------------------------- 1 | COBYLA - Constrained Optimization BY Linear Approximation 2 | Copyright (c) 1992, Michael J.D. Powell (M.J.D.Powell@damtp.cam.ac.uk) 3 | Modified for pyOpt - 2009, Ruben E. Perez (Ruben.Perez@rmc.ca) 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a 6 | copy of this software and associated documentation files (the 7 | "Software"), to deal in the Software without restriction, including 8 | without limitation the rights to use, copy, modify, merge, publish, 9 | distribute, sublicense, and/or sell copies of the Software, and to 10 | permit persons to whom the Software is furnished to do so, subject to 11 | the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be included 14 | in all copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 17 | OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 19 | IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 20 | CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 21 | TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 22 | SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 23 | -------------------------------------------------------------------------------- /pyOpt/pyCOBYLA/README: -------------------------------------------------------------------------------- 1 | This directory contains the cobyla class definition 2 | and the cobyla shared library, cobyla.so or cobyla.pyd. 3 | -------------------------------------------------------------------------------- /pyOpt/pyCOBYLA/__init__.py: -------------------------------------------------------------------------------- 1 | try: 2 | from .pyCOBYLA import COBYLA 3 | __all__ = ['COBYLA'] 4 | except: 5 | __all__ = [] 6 | -------------------------------------------------------------------------------- /pyOpt/pyCOBYLA/setup.py: -------------------------------------------------------------------------------- 1 | import os 2 | 3 | 4 | def configuration(parent_package='', top_path=None): 5 | from numpy.distutils.misc_util import Configuration 6 | 7 | config = Configuration('pyCOBYLA', parent_package, top_path) 8 | config.add_library('cobyla', sources=[os.path.join('source', '*.f')]) 9 | config.add_extension('cobyla', 10 | sources=['source/f2py/cobyla.pyf'], 11 | libraries=['cobyla']) 12 | config.add_data_files('LICENSE', 'README') 13 | 14 | return config 15 | 16 | 17 | if __name__ == '__main__': 18 | from numpy.distutils.core import setup 19 | 20 | setup(**configuration(top_path='').todict()) 21 | -------------------------------------------------------------------------------- /pyOpt/pyCOBYLA/source/README: -------------------------------------------------------------------------------- 1 | This directory contains the Fortran 77 source for COBYLA, 2 | modified for pyOpt interfacing by Dr. Ruben E. Perez, 3 | plus two helper files called openunit.f and closeunit.f 4 | to manipulate Fortran units from Python. 5 | -------------------------------------------------------------------------------- /pyOpt/pyCOBYLA/source/closeunit.f: -------------------------------------------------------------------------------- 1 | C Helper subroutine to close files in the Fortran world 2 | subroutine closeunit(unitnum) 3 | 4 | integer unitnum 5 | Cf2py intent(in) unitnum 6 | 7 | close(unitnum) 8 | 9 | return 10 | end 11 | -------------------------------------------------------------------------------- /pyOpt/pyCOBYLA/source/f2py/README: -------------------------------------------------------------------------------- 1 | This directory contains the f2py signature file. 2 | Do not edit these file unless you really know what you are doing. 3 | -------------------------------------------------------------------------------- /pyOpt/pyCOBYLA/source/f2py/cobyla.pyf: -------------------------------------------------------------------------------- 1 | ! -*- f90 -*- 2 | ! Note: the context of this file is case sensitive. 3 | 4 | python module cobyla__user__routines 5 | interface cobyla_user_interface 6 | subroutine calcfc(n,m,x,f,con) 7 | integer intent(in) :: n 8 | integer intent(in) :: m 9 | double precision dimension(n),depend(n),intent(in) :: x 10 | double precision intent(in,out) :: f 11 | double precision intent(in,out),dimension(m),depend(m) :: con 12 | end subroutine calcfc 13 | end interface cobyla_user_interface 14 | end python module cobyla__user__routines 15 | python module cobyla ! in 16 | interface ! in : cobyla 17 | subroutine cobyla(calcfc,n,m,x,rhobeg,rhoend,iprint,maxfun,w,iact,ifail,nfvals,iout,ifile,ff,gg) ! in :cobyla:source/cobyla.f 18 | use cobyla__user__routines 19 | external calcfc 20 | integer intent(in) :: n 21 | integer intent(in) :: m 22 | double precision dimension(n),intent(inout),depend(n) :: x 23 | double precision intent(in) :: rhobeg 24 | double precision intent(in) :: rhoend 25 | integer intent(in) :: iprint 26 | integer intent(in) :: maxfun 27 | double precision dimension(n*(3*n+2*m+11)+4*m+6),intent(in),depend(n,m) :: w 28 | integer dimension(m+1),intent(inout),depend(m) :: iact 29 | integer intent(inout) :: ifail 30 | integer intent(inout) :: nfvals 31 | integer intent(in) :: iout 32 | character*(*) intent(in) :: ifile 33 | double precision intent(inout) :: ff 34 | double precision dimension(m),intent(inout),depend(m) :: gg 35 | end subroutine cobyla 36 | subroutine openunit(unitnum,filename,filestatus,fileaction,ierror) ! in :cobyla:source/openunit.f 37 | integer intent(in) :: unitnum 38 | character*(*) intent(in) :: filename 39 | character*(*) intent(in) :: filestatus 40 | character*(*) intent(in) :: fileaction 41 | integer intent(out) :: ierror 42 | end subroutine openunit 43 | subroutine pyflush(unitnum) ! in :cobyla:source/openunit.f 44 | integer :: unitnum 45 | end subroutine pyflush 46 | subroutine closeunit(unitnum) ! in :cobyla:source/closeunit.f 47 | integer intent(in) :: unitnum 48 | end subroutine closeunit 49 | end interface 50 | end python module cobyla 51 | -------------------------------------------------------------------------------- /pyOpt/pyCOBYLA/source/openunit.f: -------------------------------------------------------------------------------- 1 | C Helper subroutine to open files in the Fortran world 2 | subroutine openunit(unitnum,filename,filestatus,fileaction,ierror) 3 | 4 | integer unitnum 5 | Cf2py intent(in) unitnum 6 | character*(*) filename 7 | Cf2py intent(in) filename 8 | character*(*) filestatus 9 | Cf2py intent(in) filestatus 10 | character*(*) fileaction 11 | Cf2py intent(in) fileaction 12 | integer ierror 13 | Cf2py intent(out) ierror 14 | 15 | open(unit=unitnum,file=filename,status=filestatus, 16 | > access=fileaction,iostat=ierror) 17 | 18 | return 19 | end 20 | 21 | C Helper routine to flush buffers to files 22 | subroutine pyflush(unitnum) 23 | 24 | integer unitnum 25 | 26 | call flush(unitnum) 27 | 28 | return 29 | end 30 | -------------------------------------------------------------------------------- /pyOpt/pyCONMIN/README: -------------------------------------------------------------------------------- 1 | This directory contains the conmin class definition 2 | and the conmin shared library, conmin.so or conmin.pyd. 3 | -------------------------------------------------------------------------------- /pyOpt/pyCONMIN/__init__.py: -------------------------------------------------------------------------------- 1 | try: 2 | from .pyCONMIN import CONMIN 3 | __all__ = ['CONMIN'] 4 | except: 5 | __all__ = [] 6 | -------------------------------------------------------------------------------- /pyOpt/pyCONMIN/setup.py: -------------------------------------------------------------------------------- 1 | import os 2 | 3 | 4 | def configuration(parent_package='', top_path=None): 5 | from numpy.distutils.misc_util import Configuration 6 | 7 | config = Configuration('pyCONMIN', parent_package, top_path) 8 | config.add_library('conmin', 9 | sources=[os.path.join('source', '*.f')]) 10 | config.add_extension('conmin', 11 | sources=['source/f2py/conmin.pyf'], 12 | libraries=['conmin']) 13 | config.add_data_files('LICENSE', 'README') 14 | 15 | return config 16 | 17 | 18 | if __name__ == '__main__': 19 | from numpy.distutils.core import setup 20 | 21 | setup(**configuration(top_path='').todict()) 22 | -------------------------------------------------------------------------------- /pyOpt/pyCONMIN/source/README: -------------------------------------------------------------------------------- 1 | This directory contains the Fortran 77 source for CONMIN 2 | modified for pyOpt interfacing by Dr. Ruben E. Perez, 3 | plus two helper files called openunit.f and closeunit.f 4 | to manipulate Fortran units from Python. 5 | -------------------------------------------------------------------------------- /pyOpt/pyCONMIN/source/closeunit.f: -------------------------------------------------------------------------------- 1 | C Helper subroutine to close files in the Fortran world 2 | subroutine closeunit(unitnum) 3 | 4 | integer unitnum 5 | Cf2py intent(in) unitnum 6 | 7 | close(unitnum) 8 | 9 | return 10 | end 11 | -------------------------------------------------------------------------------- /pyOpt/pyCONMIN/source/cnmn02.f: -------------------------------------------------------------------------------- 1 | SUBROUTINE CNMN02 (NCALC,SLOPE,DFTDF1,DF,S,N1) 2 | IMPLICIT DOUBLE PRECISION(A-H,O-Z) 3 | COMMON /CNMN1/ DELFUN,DABFUN,FDCH,FDCHM,CT,CTMIN,CTL,CTLMIN,ALPHAX 4 | 1,ABOBJ1,THETA,OBJ,NDV,NCON,NSIDE,IPRINT,NFDG,NSCAL,LINOBJ,ITMAX,IT 5 | 2RM,ICNDIR,IGOTO,NAC,INFO,INFOG,ITER,NFEASCT 6 | DIMENSION DF(N1), S(N1) 7 | C ROUTINE TO DETERMINE CONJUGATE DIRECTION VECTOR OR DIRECTION 8 | C OF STEEPEST DESCENT FOR UNCONSTRAINED FUNCTION MINIMIZATION. 9 | C BY G. N. VANDERPLAATS APRIL, 1972. 10 | C NASA-AMES RESEARCH CENTER, MOFFETT FIELD, CALIF. 11 | C NCALC = CALCULATION CONTROL. 12 | C NCALC = 0, S = STEEPEST DESCENT. 13 | C NCALC = 1, S = CONJUGATE DIRECTION. 14 | C CONJUGATE DIRECTION IS FOUND BY FLETCHER-REEVES ALGORITHM. 15 | C ------------------------------------------------------------------ 16 | C CALCULATE NORM OF GRADIENT VECTOR 17 | C ------------------------------------------------------------------ 18 | DFTDF=0. 19 | DO 10 I=1,NDV 20 | DFI=DF(I) 21 | 10 DFTDF=DFTDF+DFI*DFI 22 | C ------------------------------------------------------------------ 23 | C ********** FIND DIRECTION S ********** 24 | C ------------------------------------------------------------------ 25 | IF (NCALC.NE.1) GO TO 30 26 | IF (DFTDF1.LT.1.0E-20) GO TO 30 27 | C ------------------------------------------------------------------ 28 | C FIND FLETCHER-REEVES CONJUGATE DIRECTION 29 | C ------------------------------------------------------------------ 30 | BETA=DFTDF/DFTDF1 31 | SLOPE=0. 32 | DO 20 I=1,NDV 33 | DFI=DF(I) 34 | SI=BETA*S(I)-DFI 35 | SLOPE=SLOPE+SI*DFI 36 | 20 S(I)=SI 37 | GO TO 50 38 | 30 CONTINUE 39 | NCALC=0 40 | C ------------------------------------------------------------------ 41 | C CALCULATE DIRECTION OF STEEPEST DESCENT 42 | C ------------------------------------------------------------------ 43 | DO 40 I=1,NDV 44 | 40 S(I)=-DF(I) 45 | SLOPE=-DFTDF 46 | 50 CONTINUE 47 | C ------------------------------------------------------------------ 48 | C NORMALIZE S TO MAX ABS VALUE OF UNITY 49 | C ------------------------------------------------------------------ 50 | S1=0. 51 | DO 60 I=1,NDV 52 | S2=ABS(S(I)) 53 | IF (S2.GT.S1) S1=S2 54 | 60 CONTINUE 55 | IF (S1.LT.1.0E-20) S1=1.0E-20 56 | S1=1./S1 57 | DFTDF1=DFTDF*S1 58 | DO 70 I=1,NDV 59 | 70 S(I)=S1*S(I) 60 | SLOPE=S1*SLOPE 61 | RETURN 62 | END 63 | -------------------------------------------------------------------------------- /pyOpt/pyCONMIN/source/cnmn07.f: -------------------------------------------------------------------------------- 1 | SUBROUTINE CNMN07 (II,XBAR,EPS,X1,Y1,X2,Y2,X3,Y3) 2 | IMPLICIT DOUBLE PRECISION(A-H,O-Z) 3 | C ROUTINE TO FIND FIRST XBAR.GE.EPS CORRESPONDING TO A REAL ZERO 4 | C OF A ONE-DIMENSIONAL FUNCTION BY POLYNOMIEL INTERPOLATION. 5 | C BY G. N. VANDERPLAATS APRIL, 1972. 6 | C NASA-AMES RESEARCH CENTER, MOFFETT FIELD, CALIF. 7 | C II = CALCULATION CONTROL. 8 | C 1: 2-POINT LINEAR INTERPOLATION, GIVEN X1, Y1, X2 AND Y2. 9 | C 2: 3-POINT QUADRATIC INTERPOLATION, GIVEN X1, Y1, X2, Y2, 10 | C X3 AND Y3. 11 | C EPS MAY BE NEGATIVE. 12 | C IF REQUIRED ZERO ON Y DOES NOT EXITS, OR THE FUNCTION IS 13 | C ILL-CONDITIONED, XBAR = EPS-1.0 WILL BE RETURNED AS AN ERROR 14 | C INDICATOR. 15 | C IF DESIRED INTERPOLATION IS ILL-CONDITIONED, A LOWER ORDER 16 | C INTERPOLATION, CONSISTANT WITH INPUT DATA, WILL BE ATTEMPTED AND 17 | C II WILL BE CHANGED ACCORDINGLY. 18 | XBAR1=EPS-1. 19 | XBAR=XBAR1 20 | JJ=0 21 | X21=X2-X1 22 | IF (ABS(X21).LT.1.0E-20) RETURN 23 | IF (II.EQ.2) GO TO 30 24 | C 25 | 10 CONTINUE 26 | C ------------------------------------------------------------------ 27 | C II=1: 2-POINT LINEAR INTERPOLATION 28 | C ------------------------------------------------------------------ 29 | II=1 30 | YY=Y1*Y2 31 | IF (JJ.EQ.0.OR.YY.LT.0.) GO TO 20 32 | C INTERPOLATE BETWEEN X2 AND X3. 33 | DY=Y3-Y2 34 | IF (ABS(DY).LT.1.0E-20) GO TO 20 35 | XBAR=X2+Y2*(X2-X3)/DY 36 | IF (XBAR.LT.EPS) XBAR=XBAR1 37 | RETURN 38 | 20 DY=Y2-Y1 39 | C INTERPOLATE BETWEEN X1 AND X2. 40 | IF (ABS(DY).LT.1.0E-20) RETURN 41 | XBAR=X1+Y1*(X1-X2)/DY 42 | IF (XBAR.LT.EPS) XBAR=XBAR1 43 | RETURN 44 | 30 CONTINUE 45 | C ------------------------------------------------------------------ 46 | C II=2: 3-POINT QUADRATIC INTERPOLATION 47 | C ------------------------------------------------------------------ 48 | JJ=1 49 | X31=X3-X1 50 | X32=X3-X2 51 | QQ=X21*X31*X32 52 | IF (ABS(QQ).LT.1.0E-20) RETURN 53 | AA=(Y1*X32-Y2*X31+Y3*X21)/QQ 54 | IF (ABS(AA).LT.1.0E-20) GO TO 10 55 | BB=(Y2-Y1)/X21-AA*(X1+X2) 56 | CC=Y1-X1*(AA*X1+BB) 57 | BAC=BB*BB-4.*AA*CC 58 | IF (BAC.LT.0.) GO TO 10 59 | BAC=SQRT(BAC) 60 | AA=.5/AA 61 | XBAR=AA*(BAC-BB) 62 | XB2=-AA*(BAC+BB) 63 | IF (XBAR.LT.EPS) XBAR=XB2 64 | IF (XB2.LT.XBAR.AND.XB2.GT.EPS) XBAR=XB2 65 | IF (XBAR.LT.EPS) XBAR=XBAR1 66 | RETURN 67 | END 68 | -------------------------------------------------------------------------------- /pyOpt/pyCONMIN/source/cnmn09.f: -------------------------------------------------------------------------------- 1 | SUBROUTINE CNMN09(CNMNFUN,CNMNGRD,X,G,IC,DF,A, 2 | . N1,N2,N3,N4,N5) 3 | 4 | IMPLICIT DOUBLE PRECISION(A-H,O-Z) 5 | 6 | COMMON /CNMN1/ DELFUN,DABFUN,FDCH,FDCHM,CT, 7 | . CTMIN,CTL,CTLMIN,ALPHAX,ABOBJ1,THETA,OBJ, 8 | . NDV,NCON,NSIDE,IPRINT,NFDG,NSCAL,LINOBJ, 9 | . ITMAX,ITRM,ICNDIR,IGOTO,NAC,INFO,INFOG,ITER 10 | 11 | COMMON /VARABLE/ AOBJ 12 | COMMON /FEVALS/ NFUN,NGRD 13 | 14 | DIMENSION X(N1),G(N2),IC(N2),DF(N1),A(N1,N2) 15 | 16 | EXTERNAL CNMNFUN,CNMNGRD 17 | 18 | C 19 | C 20 | IF(INFO.GE.2) GO TO 10 21 | C 22 | C OBJECTIVE FUNCTION & CONSTRAINTS 23 | C 24 | CALL CNMNFUN(N1,N2,X,AOBJ,G) 25 | NFUN=NFUN+1 26 | GO TO 20 27 | 28 | 10 CONTINUE 29 | C 30 | C 31 | C GRADIENT INFORMATION 32 | C 33 | CALL CNMNGRD(N1,N2,X,AOBJ,G,CT,DF,A,IC,NAC) 34 | NGRD=NGRD+1 35 | 36 | 20 CONTINUE 37 | 38 | RETURN 39 | END 40 | -------------------------------------------------------------------------------- /pyOpt/pyCONMIN/source/f2py/README: -------------------------------------------------------------------------------- 1 | This directory contains the f2py signature file. 2 | Do not edit these file unless you really know what you are doing. 3 | -------------------------------------------------------------------------------- /pyOpt/pyCONMIN/source/openunit.f: -------------------------------------------------------------------------------- 1 | C Helper subroutine to open files in the Fortran world 2 | subroutine openunit(unitnum,filename,filestatus,fileaction,ierror) 3 | 4 | integer unitnum 5 | Cf2py intent(in) unitnum 6 | character*(*) filename 7 | Cf2py intent(in) filename 8 | character*(*) filestatus 9 | Cf2py intent(in) filestatus 10 | character*(*) fileaction 11 | Cf2py intent(in) fileaction 12 | integer ierror 13 | Cf2py intent(out) ierror 14 | 15 | open(unit=unitnum,file=filename,status=filestatus, 16 | &access=fileaction,iostat=ierror) 17 | 18 | return 19 | end 20 | 21 | C Helper routine to flush buffers to files 22 | subroutine pyflush(unitnum) 23 | 24 | integer unitnum 25 | 26 | call flush(unitnum) 27 | 28 | return 29 | end 30 | -------------------------------------------------------------------------------- /pyOpt/pyFILTERSD/README: -------------------------------------------------------------------------------- 1 | This directory contains the filtersd class definition 2 | and the filtersd shared libraries, filtersd.so or filtersd.pyd. 3 | -------------------------------------------------------------------------------- /pyOpt/pyFILTERSD/__init__.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | try: 4 | from .pyFILTERSD import FILTERSD 5 | __all__ = ['FILTERSD'] 6 | except: 7 | __all__ = [] 8 | -------------------------------------------------------------------------------- /pyOpt/pyFILTERSD/setup.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | import os 4 | 5 | 6 | def configuration(parent_package='', top_path=None): 7 | from numpy.distutils.misc_util import Configuration 8 | 9 | config = Configuration('pyFILTERSD', parent_package, top_path) 10 | config.add_library('filtersd', 11 | sources=[os.path.join('source', '*.f')]) 12 | config.add_extension('filtersd', 13 | sources=['source/f2py/filtersd.pyf'], 14 | libraries=['filtersd']) 15 | config.add_data_files('LICENSE', 'README') 16 | 17 | return config 18 | 19 | 20 | if __name__ == '__main__': 21 | from numpy.distutils.core import setup 22 | 23 | setup(**configuration(top_path='').todict()) 24 | -------------------------------------------------------------------------------- /pyOpt/pyFILTERSD/source/README: -------------------------------------------------------------------------------- 1 | This directory contains the Fortran 77 source for 2 | filterSD, plus two helper files called openunit.f and 3 | closeunit.f to manipulate Fortran units from Python. 4 | -------------------------------------------------------------------------------- /pyOpt/pyFILTERSD/source/closeunit.f: -------------------------------------------------------------------------------- 1 | C Helper subroutine to close files in the Fortran world 2 | subroutine closeunit(unitnum) 3 | 4 | integer unitnum 5 | Cf2py intent(in) unitnum 6 | 7 | close(unitnum) 8 | 9 | return 10 | end 11 | -------------------------------------------------------------------------------- /pyOpt/pyFILTERSD/source/f2py/README: -------------------------------------------------------------------------------- 1 | This directory contains the f2py signature file. 2 | Do not edit these file unless you really know what you are doing. 3 | -------------------------------------------------------------------------------- /pyOpt/pyFILTERSD/source/openunit.f: -------------------------------------------------------------------------------- 1 | C Helper subroutine to open files in the Fortran world 2 | subroutine openunit(unitnum,filename,filestatus,fileaction,ierror) 3 | 4 | integer unitnum 5 | Cf2py intent(in) unitnum 6 | character*(*) filename 7 | Cf2py intent(in) filename 8 | character*(*) filestatus 9 | Cf2py intent(in) filestatus 10 | character*(*) fileaction 11 | Cf2py intent(in) fileaction 12 | integer ierror 13 | Cf2py intent(out) ierror 14 | 15 | open(unit=unitnum,file=filename,status=filestatus, 16 | &access=fileaction,iostat=ierror) 17 | 18 | return 19 | end 20 | 21 | C Helper routine to flush buffers to files 22 | subroutine pyflush(unitnum) 23 | 24 | integer unitnum 25 | 26 | call flush(unitnum) 27 | 28 | return 29 | end 30 | -------------------------------------------------------------------------------- /pyOpt/pyFSQP/LICENSE: -------------------------------------------------------------------------------- 1 | FSQP - Feasible Sequential Quadratic Programming 2 | Copyright (c) 1993-1998 by Craig T. Lawrence, Jian L. Zhou, and Andre L. Tits 3 | Patched for pyOpt - 2009, Ruben E. Perez (Ruben.Perez@rmc.ca) 4 | 5 | FSQP is a licensed software, for term and conditions of use 6 | please refer to the specific commercial or academic agreement 7 | made with AEM Design, Inc. 8 | -------------------------------------------------------------------------------- /pyOpt/pyFSQP/README: -------------------------------------------------------------------------------- 1 | This directory contains the fsqp class definition 2 | and the fsqp shared libraries, ffsqp.so or ffsqp.pyd. 3 | -------------------------------------------------------------------------------- /pyOpt/pyFSQP/__init__.py: -------------------------------------------------------------------------------- 1 | try: 2 | from .pyFSQP import FSQP 3 | __all__ = ['FSQP'] 4 | except: 5 | __all__ = [] 6 | -------------------------------------------------------------------------------- /pyOpt/pyFSQP/setup.py: -------------------------------------------------------------------------------- 1 | import os 2 | 3 | 4 | def configuration(parent_package='', top_path=None): 5 | from numpy.distutils.misc_util import Configuration 6 | 7 | config = Configuration('pyFSQP', parent_package, top_path) 8 | config.add_library('ffsqp', 9 | sources=[os.path.join('source', '*.f')]) 10 | config.add_extension('ffsqp', 11 | sources=['source/f2py/ffsqp.pyf'], 12 | libraries=['ffsqp']) 13 | config.add_data_files('LICENSE', 'README') 14 | 15 | return config 16 | 17 | 18 | if __name__ == '__main__': 19 | from numpy.distutils.core import setup 20 | 21 | setup(**configuration(top_path='').todict()) 22 | -------------------------------------------------------------------------------- /pyOpt/pyFSQP/source/README: -------------------------------------------------------------------------------- 1 | This directory contains the Fortran 77 source for 2 | FSQP, plus two helper files called openunit.f and 3 | closeunit.f to manipulate Fortran units from Python. 4 | -------------------------------------------------------------------------------- /pyOpt/pyFSQP/source/closeunit.f: -------------------------------------------------------------------------------- 1 | C Helper subroutine to close files in the Fortran world 2 | subroutine closeunit(unitnum) 3 | 4 | integer unitnum 5 | Cf2py intent(in) unitnum 6 | 7 | close(unitnum) 8 | 9 | return 10 | end 11 | -------------------------------------------------------------------------------- /pyOpt/pyFSQP/source/f2py/README: -------------------------------------------------------------------------------- 1 | This directory contains the f2py signature file. 2 | Do not edit these file unless you really know what you are doing. 3 | -------------------------------------------------------------------------------- /pyOpt/pyFSQP/source/openunit.f: -------------------------------------------------------------------------------- 1 | C Helper subroutine to open files in the Fortran world 2 | subroutine openunit(unitnum,filename,filestatus,fileaction,ierror) 3 | 4 | integer unitnum 5 | Cf2py intent(in) unitnum 6 | character*(*) filename 7 | Cf2py intent(in) filename 8 | character*(*) filestatus 9 | Cf2py intent(in) filestatus 10 | character*(*) fileaction 11 | Cf2py intent(in) fileaction 12 | integer ierror 13 | Cf2py intent(out) ierror 14 | 15 | open(unit=unitnum,file=filename,status=filestatus, 16 | &access=fileaction,iostat=ierror) 17 | 18 | return 19 | end 20 | 21 | C Helper routine to flush buffers to files 22 | subroutine pyflush(unitnum) 23 | 24 | integer unitnum 25 | 26 | call flush(unitnum) 27 | 28 | return 29 | end 30 | -------------------------------------------------------------------------------- /pyOpt/pyGCMMA/LICENSE: -------------------------------------------------------------------------------- 1 | GCMMA - Globally Convergent Method of Moving Asymptotes 2 | Copyright (c) 2000, Krister Svanberg 3 | Modified for pyOpt - 2008, Ruben E. Perez (Ruben.Perez@rmc.ca) 4 | 5 | GCMMA is a licensed software, for term and conditions of use 6 | please refer to the specific commercial or academic agreement 7 | made with Professor Svanberg. 8 | -------------------------------------------------------------------------------- /pyOpt/pyGCMMA/README: -------------------------------------------------------------------------------- 1 | This directory contains the gcmma class definition 2 | and the gcmma shared library, gcmma.so or gcmma.pyd. 3 | -------------------------------------------------------------------------------- /pyOpt/pyGCMMA/__init__.py: -------------------------------------------------------------------------------- 1 | try: 2 | from .pyGCMMA import GCMMA 3 | __all__ = ['GCMMA'] 4 | except: 5 | __all__ = [] 6 | -------------------------------------------------------------------------------- /pyOpt/pyGCMMA/setup.py: -------------------------------------------------------------------------------- 1 | import os 2 | 3 | 4 | def configuration(parent_package='', top_path=None): 5 | from numpy.distutils.misc_util import Configuration 6 | 7 | config = Configuration('pyGCMMA', parent_package, top_path) 8 | config.add_library('gcmma', 9 | sources=[os.path.join('source', '*.f')]) 10 | config.add_extension('gcmma', 11 | sources=['source/f2py/gcmma.pyf'], 12 | libraries=['gcmma']) 13 | config.add_data_files('LICENSE', 'README') 14 | 15 | return config 16 | 17 | 18 | if __name__ == '__main__': 19 | from numpy.distutils.core import setup 20 | 21 | setup(**configuration(top_path='').todict()) 22 | -------------------------------------------------------------------------------- /pyOpt/pyGCMMA/source/README: -------------------------------------------------------------------------------- 1 | This directory contains the Fortran 77 source for GCMMA, 2 | the main routine of the original program has been modified 3 | to enable Python interfacing by Mr. Andrew Lambe with 4 | updated functionality added by Dr. Ruben E. Perez. 5 | -------------------------------------------------------------------------------- /pyOpt/pyGCMMA/source/closeunit.f: -------------------------------------------------------------------------------- 1 | C Helper subroutine to close files in the Fortran world 2 | subroutine closeunit(unitnum) 3 | 4 | integer unitnum 5 | Cf2py intent(in) unitnum 6 | 7 | close(unitnum) 8 | 9 | return 10 | end 11 | -------------------------------------------------------------------------------- /pyOpt/pyGCMMA/source/f2py/README: -------------------------------------------------------------------------------- 1 | This directory contains the f2py signature file. 2 | Do not edit these file unless you really know what you are doing. 3 | -------------------------------------------------------------------------------- /pyOpt/pyGCMMA/source/openunit.f: -------------------------------------------------------------------------------- 1 | C Helper subroutine to open files in the Fortran world 2 | subroutine openunit(unitnum,filename,filestatus,fileaction,ierror) 3 | 4 | integer unitnum 5 | Cf2py intent(in) unitnum 6 | character*(*) filename 7 | Cf2py intent(in) filename 8 | character*(*) filestatus 9 | Cf2py intent(in) filestatus 10 | character*(*) fileaction 11 | Cf2py intent(in) fileaction 12 | integer ierror 13 | Cf2py intent(out) ierror 14 | 15 | open(unit=unitnum,file=filename,status=filestatus, 16 | > access=fileaction,iostat=ierror) 17 | 18 | return 19 | end 20 | 21 | C Helper routine to flush buffers to files 22 | subroutine pyflush(unitnum) 23 | 24 | integer unitnum 25 | 26 | call flush(unitnum) 27 | 28 | return 29 | end 30 | -------------------------------------------------------------------------------- /pyOpt/pyIPOPT/__init__.py: -------------------------------------------------------------------------------- 1 | try: 2 | from .pyIPOPT import IPOPT 3 | __all__ = ['IPOPT'] 4 | except: 5 | __all__ = [] 6 | -------------------------------------------------------------------------------- /pyOpt/pyIPOPT/setup.py: -------------------------------------------------------------------------------- 1 | def configuration(parent_package='', top_path=None): 2 | 3 | from numpy.distutils.misc_util import Configuration 4 | 5 | config = Configuration('pyIPOPT',parent_package, top_path) 6 | config.add_data_files('source/LICENSE', 'source/README.md') 7 | 8 | return config 9 | 10 | 11 | if __name__ == '__main__': 12 | from numpy.distutils.core import setup 13 | 14 | setup(**configuration(top_path='').todict()) 15 | -------------------------------------------------------------------------------- /pyOpt/pyKSOPT/LICENSE: -------------------------------------------------------------------------------- 1 | KSOPT - Kreisselmeier-Steinhauser Optimizer 2 | Copyright (c) 1992, Gregory A. Wrenn 3 | Patched for pyOpt - 2010, Ruben E. Perez (Ruben.Perez@rmc.ca) 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a 6 | copy of this software and associated documentation files (the 7 | "Software"), to deal in the Software without restriction, including 8 | without limitation the rights to use, copy, modify, merge, publish, 9 | distribute, sublicense, and/or sell copies of the Software, and to 10 | permit persons to whom the Software is furnished to do so, subject to 11 | the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be included 14 | in all copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY OF ANY KIND, 17 | EITHER EXPRESSED, IMPLIED, OR STATUTORY, INCLUDING, BUT NOT LIMITED 18 | TO, ANY WARRANTY THAT THE SOFTWARE WILL CONFORM TO SPECIFICATIONS, 19 | ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR 20 | PURPOSE, AND FREEDOM FROM INFRINGEMENT, AND ANY WARRANTY THAT THE 21 | DOCUMENTATION WILL CONFORM TO THE SOFTWARE, OR ANY WARRANTY THAT 22 | THE SOFTWARE WILL BE ERROR FREE. IN NO EVENT SHALL NASA BE LIABLE 23 | FOR ANY DAMAGES, INCLUDING, BUT NOT LIMITED TO, DIRECT, INDIRECT, 24 | SPECIAL OR CONSEQUENTIAL DAMAGES, ARISING OUT OF, RESULTING FROM, 25 | OR IN ANY WAY CONNECTED WITH THIS SOFTWARE, WHETHER OR NOT BASED 26 | UPON WARRANTY, CONTRACT, TORT , OR OTHERWISE, WHETHER OR NOT INJURY 27 | WAS SUSTAINED BY PERSONS OR PROPERTY OR OTHERWISE, AND WHETHER OR 28 | NOT LOSS WAS SUSTAINED FROM, OR AROSE OUT OF THE RESULTS OF, OR USE 29 | OF, THE SOFTWARE OR SERVICES PROVIDED HEREUNDER. 30 | -------------------------------------------------------------------------------- /pyOpt/pyKSOPT/README: -------------------------------------------------------------------------------- 1 | This directory contains the ksopt class definition 2 | and the ksopt shared library, ksopt.so or ksopt.pyd. 3 | -------------------------------------------------------------------------------- /pyOpt/pyKSOPT/__init__.py: -------------------------------------------------------------------------------- 1 | try: 2 | from .pyKSOPT import KSOPT 3 | __all__ = ['KSOPT'] 4 | except: 5 | __all__ = [] 6 | -------------------------------------------------------------------------------- /pyOpt/pyKSOPT/setup.py: -------------------------------------------------------------------------------- 1 | import os 2 | 3 | 4 | def configuration(parent_package='', top_path=None): 5 | from numpy.distutils.misc_util import Configuration 6 | 7 | config = Configuration('pyKSOPT', parent_package, top_path) 8 | config.add_library('ksopt', 9 | sources=[os.path.join('source', '*.f')]) 10 | config.add_extension('ksopt', 11 | sources=['source/f2py/ksopt.pyf'], 12 | libraries=['ksopt']) 13 | config.add_data_files('LICENSE', 'README') 14 | 15 | return config 16 | 17 | 18 | if __name__ == '__main__': 19 | from numpy.distutils.core import setup 20 | 21 | setup(**configuration(top_path='').todict()) 22 | -------------------------------------------------------------------------------- /pyOpt/pyKSOPT/source/README: -------------------------------------------------------------------------------- 1 | This directory contains the Fortran 77 source for 2 | KSOPT, plus two helper files called openunit.f and 3 | closeunit.f to manipulate Fortran units from Python. 4 | -------------------------------------------------------------------------------- /pyOpt/pyKSOPT/source/closeunit.f: -------------------------------------------------------------------------------- 1 | C Helper subroutine to close files in the Fortran world 2 | subroutine closeunit(unitnum) 3 | 4 | integer unitnum 5 | Cf2py intent(in) unitnum 6 | 7 | close(unitnum) 8 | 9 | return 10 | end 11 | -------------------------------------------------------------------------------- /pyOpt/pyKSOPT/source/f2py/README: -------------------------------------------------------------------------------- 1 | This directory contains the f2py signature file. 2 | Do not edit these file unless you really know what you are doing. 3 | -------------------------------------------------------------------------------- /pyOpt/pyKSOPT/source/ks.f: -------------------------------------------------------------------------------- 1 | subroutine ks (f,g,ng,rho) 2 | implicit double precision (a-h,o-z) 3 | dimension g(ng) 4 | data toler /-40.0/ 5 | c 6 | c routine to compute k-s function (type 2) 7 | c 8 | c author - Gregory A. Wrenn 9 | c location - Lockheed Engineering and Sciences Co. 10 | c 144 Research Drive 11 | c Hampton, Va. 23666 12 | c 13 | c last modification - 9 July 1988 14 | c 15 | sum = 0.0 16 | gmax = g(1) 17 | if (ng .lt. 2) go to 30 18 | do 10 i = 2,ng 19 | if (g(i) .gt. gmax) gmax = g(i) 20 | 10 continue 21 | do 20 i = 1,ng 22 | val = rho * (g(i) - gmax) 23 | if (val .lt. toler) go to 20 24 | sum = sum + exp(val) 25 | 20 continue 26 | 30 continue 27 | f = gmax 28 | if (ng .gt. 1) f = gmax + log(sum) / rho 29 | c 30 | return 31 | end 32 | -------------------------------------------------------------------------------- /pyOpt/pyKSOPT/source/ksales.f: -------------------------------------------------------------------------------- 1 | subroutine ksales (a1,a2,a3,f1,f2,f3,alim,alpha) 2 | implicit double precision (a-h,o-z) 3 | c 4 | c routine to estimate the next one-dimensional 5 | c step size alpha, based on the slopes of the 6 | c previous two trial points. 7 | c 8 | c author - Gregory A. Wrenn 9 | c location - Lockheed Engineering and Sciences Co. 10 | c 144 Research Drive 11 | c Hampton, Va. 23666 12 | c 13 | c last modification - 21 April 1989 14 | c 15 | alpha = 0.0 16 | alpmin = 2.0 * a3 - a2 17 | alpmax = 3.0 * a3 18 | c 19 | if (abs(a2 - a1) .lt. 1.0e-08) go to 10 20 | x1 = a2 21 | y1 = (f2 - f1) / (a2 - a1) 22 | c 23 | if (abs(a3 - a2) .lt. 1.0e-08) go to 10 24 | x2 = a3 25 | y2 = (f3 - f2) / (a3 - a2) 26 | c 27 | a = (y2 - y1) / (x2 - x1) 28 | b = y1 - a * x1 29 | c 30 | if (abs(a) .ge. 1.0e-08) alpha = -b / a 31 | 10 continue 32 | if (alpha .le. 0.0 ) alpha = alpmax 33 | if (alpha .lt. alpmin) alpha = alpmin 34 | if (alpha .gt. alpmax) alpha = alpmax 35 | if (alim .gt. 0.0 .and. alpha .ge. alim) alpha = 0.5 * (a3 + alim) 36 | c 37 | return 38 | end 39 | -------------------------------------------------------------------------------- /pyOpt/pyKSOPT/source/ksando.f: -------------------------------------------------------------------------------- 1 | subroutine ksando (obj,g,fscale,offset,ncon,nobj) 2 | implicit double precision (a-h,o-z) 3 | dimension obj(*),g(*),fscale(*),offset(*) 4 | data eps/1.0e-6/ 5 | c 6 | c routine to compute scale and offset for obj 7 | c 8 | c author - Gregory A. Wrenn 9 | c location - Lockheed Engineering and Sciences Co. 10 | c 144 Research Drive 11 | c Hampton, Va. 23666 12 | c 13 | c last modification - 17 July 1996 14 | c 15 | if (ncon .le. 0) go to 20 16 | gmax = g(1) 17 | if (ncon .eq. 1) go to 20 18 | do 10 i = 2,ncon 19 | if (g(i) .gt. gmax) gmax = g(i) 20 | 10 continue 21 | c 22 | 20 continue 23 | do 30 j = 1,nobj 24 | fscl = abs(obj(j)) 25 | foff = abs(obj(j)) 26 | if (fscl .lt. 1.0) fscl = 1.0 27 | if (foff .gt. 1.0) foff = 1.0 28 | fscale(j) = fscl 29 | offset(j) = 0.0 30 | c 31 | c compute offset if ncon > 0 32 | c 33 | if (ncon .le. 0) go to 30 34 | if (obj(j) .ge. 0.0) offset(j) = -foff - gmax - eps 35 | if (obj(j) .lt. 0.0) offset(j) = foff - gmax + eps 36 | 30 continue 37 | c 38 | return 39 | end 40 | -------------------------------------------------------------------------------- /pyOpt/pyKSOPT/source/kscube.f: -------------------------------------------------------------------------------- 1 | subroutine kscube (a1,a2,a3,a4,f1,f2,f3,f4,astar,fstar) 2 | implicit double precision (a-h,o-z) 3 | c 4 | c routine to compute the minimum of a cubic 5 | c curve through points a1,f1 a2,f2 a3,f3 and a4,f4. 6 | c 7 | c author - Gregory A. Wrenn 8 | c location - Lockheed Engineering and Sciences Co. 9 | c 144 Research Drive 10 | c Hampton, Va. 23666 11 | c 12 | c last modification - 27 April 1989 13 | c 14 | a1c = a1 * a1 * a1 15 | a2c = a2 * a2 * a2 16 | a3c = a3 * a3 * a3 17 | a4c = a4 * a4 * a4 18 | c 19 | q1 = a3c * (a2 - a1) - a2c * (a3 - a1) + a1c * (a3 - a2) 20 | q2 = a4c * (a2 - a1) - a2c * (a4 - a1) + a1c * (a4 - a2) 21 | q3 = (a3 - a2) * (a2 - a1) * (a3 - a1) 22 | q4 = (a4 - a2) * (a2 - a1) * (a4 - a1) 23 | q5 = f3 * (a2 - a1) - f2 * (a3 - a1) + f1 * (a3 - a2) 24 | q6 = f4 * (a2 - a1) - f2 * (a4 - a1) + f1 * (a4 - a2) 25 | c 26 | d1 = q2 * q3 - q1 * q4 27 | d2 = a2 - a1 28 | if (d1 .lt. 1.0e-12 .or. d2 .lt. 1.0e-12) go to 10 29 | c 30 | b3 = (q3 * q6 - q4 * q5) / d1 31 | b2 = (q5 - b3 * q1) / q3 32 | b1 = (f2 - f1) / d2 - b3 * (a2c - a1c) / d2 - b2 * (a1 + a2) 33 | b0 = f1 - b1 * a1 - b2 * a1 * a1 - b3 * a1c 34 | c 35 | bb = b2 * b2 - 3.0 * b1 * b3 36 | if (bb .lt. 0.0 .or. abs(b3) .lt. 1.0e-12) go to 10 37 | astar = (-b2 + sqrt(bb)) / (3.0 * b3) 38 | if (astar .lt. a1 .or. astar .gt. a4) go to 10 39 | as2 = astar * astar 40 | as3 = astar * as2 41 | fstar = b0 + b1 * astar + b2 * as2 + b3 * as3 42 | go to 40 43 | c 44 | 10 continue 45 | astar = a1 46 | fstar = f1 47 | if (f2 .ge. fstar) go to 20 48 | astar = a2 49 | fstar = f2 50 | 20 continue 51 | if (f3 .ge. fstar) go to 30 52 | astar = a3 53 | fstar = f3 54 | 30 continue 55 | if (f4 .ge. fstar) go to 40 56 | astar = a4 57 | fstar = f4 58 | c 59 | 40 continue 60 | return 61 | end 62 | -------------------------------------------------------------------------------- /pyOpt/pyKSOPT/source/ksd.f: -------------------------------------------------------------------------------- 1 | subroutine ksd (df,g,dgdx,ng,rho) 2 | implicit double precision (a-h,o-z) 3 | dimension g(ng),dgdx(ng) 4 | data toler /-40.0/ 5 | c 6 | c routine to compute partial k-s w.r.t. x (type 2). 7 | c partial of g(i) w.r.t. x (e.g. by finite difference) 8 | c must be supplied in array dgdx(i). 9 | c 10 | c author - Gregory A. Wrenn 11 | c location - Lockheed Engineering and Sciences Co. 12 | c 144 Research Drive 13 | c Hampton, Va. 23666 14 | c 15 | c last modification - 9 July 1988 16 | c 17 | sum1 = 0.0 18 | sum2 = 0.0 19 | gmax = g(1) 20 | if (ng .lt. 2) go to 30 21 | do 10 i = 2,ng 22 | if (g(i) .gt. gmax) gmax = g(i) 23 | 10 continue 24 | do 20 i = 1,ng 25 | val = rho * (g(i) - gmax) 26 | if (val .lt. toler) go to 20 27 | sum1 = sum1 + exp(val) * dgdx(i) 28 | sum2 = sum2 + exp(val) 29 | 20 continue 30 | 30 continue 31 | df = dgdx(1) 32 | if (ng .gt. 1) df = sum1 / sum2 33 | c 34 | return 35 | end 36 | -------------------------------------------------------------------------------- /pyOpt/pyKSOPT/source/ksdfp.f: -------------------------------------------------------------------------------- 1 | subroutine ksdfp (x,side,act,dfun,ndv,s,slope,y,p,h,hess, 2 | 1 isdflg) 3 | implicit double precision (a-h,o-z) 4 | dimension x(*),side(*),act(*),dfun(*),s(*),y(*),p(*),h(*) 5 | dimension hess(*) 6 | c 7 | c routine to compute search direction using the 8 | c davidon-fletcher-powell method 9 | c 10 | c author - Gregory A. Wrenn 11 | c location - Lockheed Engineering and Sciences Co. 12 | c 144 Research Drive 13 | c Hampton, Va. 23666 14 | c 15 | c last modification - 19 July 1996 16 | c 17 | if (isdflg .gt. 0) go to 40 18 | c 19 | c reset approximate hessian matrix to initial condition 20 | c 21 | 10 continue 22 | c 23 | c set h matrix to hess matrix 24 | c 25 | isdflg = 0 26 | nh = ndv * (ndv + 1) / 2 27 | do 20 i = 1,nh 28 | h(i) = hess(i) 29 | 20 continue 30 | do 30 i = 1,ndv 31 | act(i) = side(i) 32 | 30 continue 33 | go to 80 34 | c 35 | c dfp algorithm 36 | c 37 | 40 continue 38 | c 39 | c check for validity of hessian matrix 40 | c in the case of side constraints 41 | c 42 | do 50 i = 1,ndv 43 | if (side(i) .ne. act(i)) go to 10 44 | 50 continue 45 | c 46 | c compute vectors p and y 47 | c 48 | do 60 i = 1,ndv 49 | y(i) = dfun(i) - y(i) 50 | p(i) = x(i) - p(i) 51 | 60 continue 52 | c 53 | c compute update to hessian matrix 54 | c 55 | call kshmul (h,y,s,ndv) 56 | call ksvprd (p,y,sigma,ndv) 57 | call ksvprd (y,s,tau,ndv) 58 | if (abs(sigma) .lt. 1.0e-08) sigma = 1.0e-08 59 | if (abs(tau) .lt. 1.0e-08) tau = 1.0e-08 60 | sigma = 1.0 / sigma 61 | tau = 1.0 / tau 62 | c 63 | k = 0 64 | do 70 i = 1,ndv 65 | do 70 j = 1,i 66 | k = k + 1 67 | h(k) = h(k) + sigma * p(i) * p(j) - tau * s(i) * s(j) 68 | 70 continue 69 | c 70 | 80 continue 71 | call kshmul (h,dfun,s,ndv) 72 | c 73 | c negate s-vector 74 | c 75 | smax = 1.0e-08 76 | do 90 i = 1,ndv 77 | s(i) = -s(i) 78 | si = abs(s(i)) 79 | if (si .gt. smax) smax = si 80 | 90 continue 81 | c 82 | c normalize search direction to unit maximum 83 | c and save previous gradients in y-vector 84 | c and previous design variables in p-vector 85 | c 86 | do 100 i = 1,ndv 87 | s(i) = s(i) / smax 88 | y(i) = dfun(i) 89 | p(i) = x(i) 90 | 100 continue 91 | c 92 | c compute slope 93 | c 94 | call ksvprd (s,dfun,slope,ndv) 95 | if (slope .gt. 0.0 .and. isdflg .gt. 0) go to 10 96 | if (slope .gt. 0.0) slope = 0.0 97 | c 98 | return 99 | end 100 | -------------------------------------------------------------------------------- /pyOpt/pyKSOPT/source/ksdfun.f: -------------------------------------------------------------------------------- 1 | subroutine ksdfun (dfun,obj,fscale,offset,df,g,dg,rho,ndv,ncon, 2 | 1 nobj,temp1,temp2,nodim,ncdim) 3 | implicit double precision (a-h,o-z) 4 | dimension dfun(*),obj(*),fscale(*),offset(*),df(nodim,*) 5 | dimension g(*),dg(ncdim,*),temp1(*),temp2(*) 6 | c 7 | c routine to compute gradients of function to be minimized 8 | c 9 | c author - Gregory A. Wrenn 10 | c location - Lockheed Engineering and Sciences Co. 11 | c 144 Research Drive 12 | c Hampton, Va. 23666 13 | c 14 | c last modification - 19 July 1996 15 | c 16 | do 10 i = 1,nobj 17 | temp1(i) = obj(i) / fscale(i) + offset(i) 18 | 10 continue 19 | j = nobj 20 | if (ncon .le. 0) go to 30 21 | do 20 i = 1,ncon 22 | j = j + 1 23 | temp1(j) = g(i) 24 | 20 continue 25 | 30 continue 26 | c 27 | do 70 n = 1,ndv 28 | do 40 i = 1,nobj 29 | temp2(i) = df(i,n) / fscale(i) 30 | 40 continue 31 | j = nobj 32 | if (ncon .le. 0) go to 60 33 | do 50 i = 1,ncon 34 | j = j + 1 35 | temp2(j) = dg(i,n) 36 | 50 continue 37 | 60 continue 38 | c 39 | call ksd (dfun(n),temp1,temp2,j,rho) 40 | c 41 | 70 continue 42 | c 43 | return 44 | end 45 | -------------------------------------------------------------------------------- /pyOpt/pyKSOPT/source/ksfun.f: -------------------------------------------------------------------------------- 1 | subroutine ksfun (fun,obj,g,rho,fscale,offset,ncon,nobj,temp) 2 | implicit double precision (a-h,o-z) 3 | dimension obj(*),g(*),fscale(*),offset(*),temp(*) 4 | c 5 | c routine to compute unconstrained function to be minimized 6 | c 7 | c author - Gregory A. Wrenn 8 | c location - Lockheed Engineering and Sciences Co. 9 | c 144 Research Drive 10 | c Hampton, Va. 23666 11 | c 12 | c last modification - 17 July 1996 13 | c 14 | do 10 i = 1,nobj 15 | temp(i) = obj(i) / fscale(i) + offset(i) 16 | 10 continue 17 | j = nobj 18 | if (ncon .le. 0) go to 30 19 | do 20 i = 1,ncon 20 | j = j + 1 21 | temp(j) = g(i) 22 | 20 continue 23 | 30 continue 24 | c 25 | call ks (fun,temp,j,rho) 26 | c 27 | return 28 | end 29 | -------------------------------------------------------------------------------- /pyOpt/pyKSOPT/source/ksgrad.f: -------------------------------------------------------------------------------- 1 | subroutine ksgrad (inext,x,x0,xlb,xub,g,g0,obj,obj0,df,dg,scale, 2 | 1 delx,ndv,ncon,nobj,nside,fdelt,fdmin,nodim, 3 | 2 ncdim) 4 | implicit double precision (a-h,o-z) 5 | dimension x(*),x0(*),xlb(*),xub(*),g(*),g0(*) 6 | dimension obj(*),obj0(*),df(nodim,*),dg(ncdim,*),scale(ndv,2) 7 | c 8 | c routine to determine df and dg by finite differences 9 | c 10 | c author - Gregory A. Wrenn 11 | c location - Lockheed Engineering and Sciences Co. 12 | c 144 Research Drive 13 | c Hampton, Va. 23666 14 | c 15 | c last modification - 19 July 1996 16 | c 17 | if (inext .gt. 0) go to 40 18 | c 19 | c initialize obj0, x0, and g0 20 | c 21 | do 10 i = 1,nobj 22 | obj0(i) = obj(i) 23 | 10 continue 24 | c 25 | do 20 i = 1,ndv 26 | x0(i) = x(i) 27 | 20 continue 28 | 29 | if (ncon .le. 0) go to 40 30 | do 30 i = 1,ncon 31 | g0(i) = g(i) 32 | 30 continue 33 | c 34 | c calculate gradients and restore design variables 35 | c 36 | c note - these gradients are already scaled by the 37 | c design variable scale factors 38 | c 39 | 40 continue 40 | if (inext .eq. 0) go to 80 41 | c 42 | do 50 i = 1,nobj 43 | df(i,inext) = (obj(i) - obj0(i)) / delx 44 | 50 continue 45 | c 46 | if (ncon .le. 0) go to 70 47 | do 60 i = 1,ncon 48 | dg(i,inext) = (g(i) - g0(i)) / delx 49 | 60 continue 50 | 70 continue 51 | x(inext) = x0(inext) 52 | c 53 | c increment design variable inext and get obj and g 54 | c 55 | 80 continue 56 | inext = inext + 1 57 | if (inext .gt. ndv) go to 100 58 | xhere = x0(inext) 59 | delmin = fdmin / scale(inext,1) 60 | delx = abs(xhere * fdelt) 61 | if (delx .lt. delmin) delx = delmin 62 | c 63 | if (nside .le. 0) go to 90 64 | c 65 | xtest = xhere + delx 66 | if (xtest .le. xub(inext)) go to 90 67 | c 68 | c adjust delta-x for upper bound 69 | 70 | delx1 = delx 71 | delx = abs(xub(inext) - xhere) 72 | if (delx .ge. delmin) go to 90 73 | c 74 | c adjust delta-x for lower bound 75 | c 76 | delx = -delx1 77 | xtest = xhere + delx 78 | if (xtest .lt. xlb(inext)) delx = xlb(inext) - xhere 79 | c 80 | 90 continue 81 | x(inext) = x0(inext) + delx 82 | go to 110 83 | c 84 | c reset inext to zero when finished 85 | c 86 | 100 continue 87 | inext = 0 88 | 110 continue 89 | c 90 | return 91 | end 92 | -------------------------------------------------------------------------------- /pyOpt/pyKSOPT/source/kshess.f: -------------------------------------------------------------------------------- 1 | subroutine kshess (hess,obj,fscale,offset,df,g,dg,rho, 2 | 1 ndv,ncon,nobj,temp1,temp2,nodim,ncdim) 3 | implicit double precision (a-h,o-z) 4 | dimension hess(*),obj(*),fscale(*),offset(*),df(nodim,*) 5 | dimension g(*),dg(ncdim,*),temp1(*),temp2(2,*) 6 | data toler /-40.0/ 7 | c 8 | c routine to compute approximate hessian matrix from 9 | c first order gradient information 10 | c 11 | c author - Gregory A. Wrenn 12 | c location - Lockheed Engineering and Sciences Co. 13 | c 144 Research Drive 14 | c Hampton, Va. 23666 15 | c 16 | c last modification - 19 July 1996 17 | c 18 | do 10 i = 1,nobj 19 | temp1(i) = obj(i) / fscale(i) + offset(i) 20 | 10 continue 21 | j = nobj 22 | if (ncon .le. 0) go to 30 23 | do 20 i = 1,ncon 24 | j = j + 1 25 | temp1(j) = g(i) 26 | 20 continue 27 | 30 continue 28 | c 29 | kk = 0 30 | do 140 m = 1,ndv 31 | c 32 | do 40 i = 1,nobj 33 | temp2(1,i) = df(i,m) / fscale(i) 34 | 40 continue 35 | j = nobj 36 | if (ncon .le. 0) go to 60 37 | do 50 i = 1,ncon 38 | j = j + 1 39 | temp2(1,j) = dg(i,m) 40 | 50 continue 41 | 60 continue 42 | c 43 | do 130 n = 1,m 44 | c 45 | do 70 i = 1,nobj 46 | temp2(2,i) = df(i,n) / fscale(i) 47 | 70 continue 48 | j = nobj 49 | if (ncon .le. 0) go to 90 50 | do 80 i = 1,ncon 51 | j = j + 1 52 | temp2(2,j) = dg(i,n) 53 | 80 continue 54 | 90 continue 55 | c 56 | sum1 = 0.0 57 | sum2 = 0.0 58 | sum3 = 0.0 59 | sum4 = 0.0 60 | ng = nobj + ncon 61 | gmax = temp1(1) 62 | if (ng .lt. 2) go to 110 63 | do 100 i = 2,ng 64 | if (temp1(i) .gt. gmax) gmax = temp1(i) 65 | 100 continue 66 | 110 continue 67 | do 120 i = 1,ng 68 | d2grad = 0.0 69 | if (n .eq. m) d2grad = 1.0 70 | val = rho * (temp1(i) - gmax) 71 | if (val .lt. toler) go to 120 72 | sum1 = sum1 + exp(val) 73 | sum2 = sum2 + exp(val) * temp2(1,i) 74 | sum3 = sum3 + exp(val) * rho * temp2(2,i) 75 | sum4 = sum4 + exp(val) * (rho * temp2(1,i) * temp2(2,i) 76 | 1 + d2grad) 77 | 120 continue 78 | c 79 | kk = kk + 1 80 | if (n .eq. m) hess(kk) = (sum4 / sum1) - 81 | 1 (sum2 * sum3) / (sum1 * sum1) 82 | if (n .ne. m) hess(kk) = 0.0 83 | c 84 | 130 continue 85 | 140 continue 86 | c 87 | return 88 | end 89 | -------------------------------------------------------------------------------- /pyOpt/pyKSOPT/source/kshmul.f: -------------------------------------------------------------------------------- 1 | subroutine kshmul (a,b,x,nrow) 2 | implicit double precision (a-h,o-z) 3 | dimension a(*),b(*),x(*) 4 | c 5 | c routine to perform matrix multiplication a * b = x 6 | c for a triangular matrix a 7 | c 8 | c author - Gregory A. Wrenn 9 | c location - Lockheed Engineering and Sciences Co. 10 | c 144 Research Drive 11 | c Hampton, Va. 23666 12 | c 13 | c last modification - 17 July 1996 14 | c 15 | k = 0 16 | do 10 i = 1,nrow 17 | x(i) = 0.0 18 | 10 continue 19 | do 20 i = 1,nrow 20 | do 20 j = 1,i 21 | k = k + 1 22 | x(i) = x(i) + a(k) * b(j) 23 | if (j .lt. i) x(j) = x(j) + a(k) * b(i) 24 | 20 continue 25 | c 26 | return 27 | end 28 | -------------------------------------------------------------------------------- /pyOpt/pyKSOPT/source/ksinfo.f: -------------------------------------------------------------------------------- 1 | subroutine ksinfo (iout,rout) 2 | implicit double precision (a-h,o-z) 3 | common /kscomm/ rdf ,adf ,fdl ,fdm ,rho ,drho ,rhomax, 4 | 1 fun0 ,slope ,delx ,alpha ,alpmax,a1 ,a2 , 5 | 2 a3 ,a4 ,f1 ,f2 ,f3 ,f4 ,alim , 6 | 3 atest ,ftest ,ifscl ,ifoff ,isx ,isx0 ,isxlb , 7 | 4 isxub ,iscl ,ig0 ,idf ,islp ,iobj0 ,iy , 8 | 5 ip ,ih ,ihess ,iside ,isact ,idobj ,idg , 9 | 6 itmp1 ,itmp2 ,inext ,jnext ,jsel ,itcnt ,icntr , 10 | 7 icnta ,isdflg,isdrst,ifncl ,nunit ,ndv ,ncon , 11 | 8 nobj ,nside ,nscale,iprnt ,itmax ,igrad ,limit 12 | dimension iout(15),rout(25) 13 | c 14 | c This user called routine returns the current values of 15 | c several common block variables to satisfy the curiosity 16 | c of the user. This routine may be called at any time after 17 | c routine ksinit is executed. 18 | c 19 | c author - Gregory A. Wrenn 20 | c location - Lockheed Engineering and Sciences Co. 21 | c 144 Research Drive 22 | c Hampton, Va. 23666 23 | c 24 | c last modification - 30 August 1991 25 | c 26 | iout(1) = inext 27 | iout(2) = jnext 28 | iout(3) = jsel 29 | iout(4) = itcnt 30 | iout(5) = icntr 31 | iout(6) = icnta 32 | iout(7) = isdflg 33 | iout(8) = isdrst 34 | iout(9) = ifncl 35 | iout(10) = limit 36 | iout(11) = -1 37 | iout(12) = -1 38 | iout(13) = -1 39 | iout(14) = -1 40 | iout(15) = -1 41 | c 42 | rout(1) = rho 43 | rout(2) = drho 44 | rout(3) = fun0 45 | rout(4) = slope 46 | rout(5) = delx 47 | rout(6) = alpha 48 | rout(7) = alpmax 49 | rout(8) = a1 50 | rout(9) = a2 51 | rout(10) = a3 52 | rout(11) = a4 53 | rout(12) = f1 54 | rout(13) = f2 55 | rout(14) = f3 56 | rout(15) = f4 57 | rout(16) = alim 58 | rout(17) = atest 59 | rout(18) = ftest 60 | rout(19) = -1.0 61 | rout(20) = -1.0 62 | rout(21) = -1.0 63 | rout(22) = -1.0 64 | rout(23) = -1.0 65 | rout(24) = -1.0 66 | rout(25) = -1.0 67 | c 68 | return 69 | end 70 | -------------------------------------------------------------------------------- /pyOpt/pyKSOPT/source/ksmain.f: -------------------------------------------------------------------------------- 1 | SUBROUTINE KSMAIN (NDV,NOBJ,NCON,X,XLB,XUB,OBJ,G, 2 | 1 WORK,NWORK, 3 | 2 ITMAX,RDFUN,RHOMIN,RHOMAX,IOUT,IPRINT,INAME, 4 | 3 NFEVAL,NGEVAL,OBJFUN,GRDFUN) 5 | C 6 | IMPLICIT DOUBLE PRECISION(A-H,O-Z) 7 | C 8 | DIMENSION WORK(NWORK) 9 | DIMENSION X(NDV),OBJ(NOBJ),G(NCON) 10 | DIMENSION XLB(NDV),XUB(NDV),SCALE(NDV) 11 | DIMENSION DF(NOBJ,NDV),DG(NCON,NDV) 12 | CHARACTER*(*) INAME 13 | EXTERNAL OBJFUN,GRDFUN 14 | C 15 | C PARAMETERS 16 | C 17 | NSIDE=1 18 | NSCALE=1 19 | IF (IPRINT.EQ.0) IPRNT=000 20 | IF (IPRINT.EQ.1) IPRNT=001 21 | IF (IPRINT.EQ.2) IPRNT=012 22 | IF (IPRINT.EQ.3) IPRNT=013 23 | IGRAD=1 24 | ISDRST=0 25 | ADFUN=0.0 26 | FDELT=0.0 27 | FDMIN=0.0 28 | RHODEL=0.0 29 | C 30 | C OPEN WRITE FILE 31 | C 32 | IF (IPRINT.EQ.0) GO TO 5 33 | OPEN(UNIT=IOUT,FILE=INAME,STATUS='UNKNOWN') 34 | 5 CONTINUE 35 | C 36 | C 37 | C INITIALIZE 38 | C 39 | CALL KSINIT(X,XLB,XUB,SCALE,WORK,NDV,NCON,NOBJ,NSIDE, 40 | 1 NSCALE,IPRNT,ITMAX,IGRAD,ISDRST,RDFUN,ADFUN,FDELT, 41 | 2 FDMIN,RHOMIN,RHOMAX,RHODEL,IOUT,IREQ) 42 | C 43 | NOMAX=NOBJ 44 | NGMAX=NCON 45 | C 46 | C OPTIMIZE 47 | C 48 | ISEL=-1 49 | 10 CONTINUE 50 | CALL KSOPT(ISEL,X,OBJ,G,DF,DG,NOMAX,NGMAX,WORK) 51 | IF (ISEL.EQ.0) GO TO 50 52 | IF (ISEL.EQ.1) GO TO 20 53 | IF (ISEL.EQ.2) GO TO 30 54 | C 55 | C EVALUATE OBJECTIVE AND CONSTRAINTS 56 | C 57 | 20 CONTINUE 58 | CALL OBJFUN(NDV,NOBJ,NCON,X,OBJ,G) 59 | NFEVAL=NFEVAL+1 60 | GO TO 10 61 | C 62 | C EVALUATE GRADIENTS 63 | C 64 | 30 CONTINUE 65 | CALL GRDFUN(NDV,NOBJ,NCON,X,OBJ,G,DF,DG) 66 | NGEVAL=NGEVAL+1 67 | GO TO 10 68 | C 69 | 50 CONTINUE 70 | C 71 | C PRINT FINAL RESULTS 72 | C 73 | IF (IPRINT.EQ.0) GO TO 60 74 | WRITE(IOUT,1650) NFEVAL 75 | WRITE(IOUT,1750) NGEVAL 76 | 60 CONTINUE 77 | C 78 | RETURN 79 | C ------------------------------------------------------------------ 80 | C FORMATS 81 | C ------------------------------------------------------------------ 82 | 1650 FORMAT(//8X,'NUMBER OF FUNC-CALLS: NFUN =',I5) 83 | 1750 FORMAT(/8X,'NUMBER OF GRAD-CALLS: NGRD =',I5) 84 | C 85 | END 86 | -------------------------------------------------------------------------------- /pyOpt/pyKSOPT/source/ksprnt.diff: -------------------------------------------------------------------------------- 1 | 9c9 2 | < 5 ip ,ih ,ihess ,sidee ,isact ,idobj ,idg , 3 | --- 4 | > 5 ip ,ih ,ihess ,iside ,isact ,idobj ,idg , 5 | 115a116 6 | > if (iprnt1 .eq. 0) go to 300 7 | -------------------------------------------------------------------------------- /pyOpt/pyKSOPT/source/ksqmin.f: -------------------------------------------------------------------------------- 1 | subroutine ksqmin (a1,a2,a3,a4,alpha,f1,f2,f3,f4,fun) 2 | implicit double precision (a-h,o-z) 3 | c 4 | c routine to place alpha and fun in the appropriate 5 | c position relative to the three or four previously 6 | c defined points a1,f1 through a4,f4, dropping the 7 | c most distant point from the current minimum. 8 | c 9 | c author - Gregory A. Wrenn 10 | c location - Lockheed Engineering and Sciences Co. 11 | c 144 Research Drive 12 | c Hampton, Va. 23666 13 | c 14 | c last modification - 26 April 1989 15 | c 16 | if (a4 .gt. 0.0) go to 20 17 | c 18 | if (alpha .lt. a2) go to 10 19 | a4 = a3 20 | f4 = f3 21 | a3 = alpha 22 | f3 = fun 23 | go to 50 24 | 10 continue 25 | a4 = a3 26 | f4 = f3 27 | a3 = a2 28 | f3 = f2 29 | a2 = alpha 30 | f2 = fun 31 | go to 50 32 | 20 continue 33 | if (alpha .le. a2) go to 10 34 | if (alpha .lt. a3) go to 30 35 | a1 = a2 36 | f1 = f2 37 | a2 = a3 38 | f2 = f3 39 | a3 = alpha 40 | f3 = fun 41 | go to 50 42 | 30 continue 43 | if ( (alpha - a1) .gt. (a4 - alpha) ) go to 40 44 | a4 = a3 45 | f4 = f3 46 | a3 = alpha 47 | f3 = fun 48 | go to 50 49 | 40 continue 50 | a1 = a2 51 | f1 = f2 52 | a2 = alpha 53 | f2 = fun 54 | c 55 | 50 continue 56 | return 57 | end 58 | -------------------------------------------------------------------------------- /pyOpt/pyKSOPT/source/ksquad.f: -------------------------------------------------------------------------------- 1 | subroutine ksquad (a1,a2,a3,f1,f2,f3,astar,fstar) 2 | implicit double precision (a-h,o-z) 3 | c 4 | c routine to compute the minimum of a quadratic 5 | c curve through points a1,f1 a2,f2 and a3,f3. 6 | c f2 must be less than f1 and f3. 7 | c 8 | c author - Gregory A. Wrenn 9 | c location - Lockheed Engineering and Sciences Co. 10 | c 144 Research Drive 11 | c Hampton, Va. 23666 12 | c 13 | c last modification - 27 April 1989 14 | c 15 | f21 = f2 - f1 16 | a21 = a2 - a1 17 | if (a21 .lt. 1.0e-12) go to 10 18 | f31 = f3 - f1 19 | a31 = a3 - a1 20 | a3121 = a31 / a21 21 | a21s = a2 * a2 - a1 * a1 22 | a31s = a3 * a3 - a1 * a1 23 | c 24 | d = a31s - a21s * a3121 25 | if (d .lt. 1.0e-12) go to 10 26 | c 27 | a = (f31 - f21 * a3121) / d 28 | b = (f21 - a * a21s) / a21 29 | c = f1 - b * a1 - a * a1 * a1 30 | c 31 | if (a .lt. 1.0e-12) go to 10 32 | astar = -b / (2.0 * a) 33 | if (astar .lt. a1 .or. astar .gt. a3) go to 10 34 | fstar = a * astar * astar + b * astar + c 35 | go to 30 36 | c 37 | 10 continue 38 | astar = a1 39 | fstar = f1 40 | if (f2 .ge. fstar) go to 20 41 | astar = a2 42 | fstar = f2 43 | 20 continue 44 | if (f3 .ge. fstar) go to 30 45 | astar = a3 46 | fstar = f3 47 | c 48 | 30 continue 49 | return 50 | end 51 | -------------------------------------------------------------------------------- /pyOpt/pyKSOPT/source/ksscal.f: -------------------------------------------------------------------------------- 1 | subroutine ksscal (x,x0,xlb,xub,scale,ndv,nside,nscale) 2 | implicit double precision (a-h,o-z) 3 | dimension x(*),x0(*),xlb(*),xub(*),scale(ndv,2) 4 | c 5 | c routine to compute new scaling vector and re-scale 6 | c design variables and lower and upper bounds 7 | c 8 | c author - Gregory A. Wrenn 9 | c location - Lockheed Engineering and Sciences Co. 10 | c 144 Research Drive 11 | c Hampton, Va. 23666 12 | c 13 | c last modification - 17 July 1996 14 | c 15 | do 10 i = 1,ndv 16 | xx = x(i) 17 | xx0 = x0(i) 18 | sold = scale(i,1) 19 | snew = sold 20 | if (nscale .gt. 0) snew = abs(xx * sold) 21 | if (nscale .lt. 0) snew = abs(scale(i,2)) 22 | if (snew .lt. 1.0e-08) snew = 1.0 23 | scale(i,1) = snew 24 | x(i) = xx * sold / snew 25 | x0(i) = xx0 * sold / snew 26 | if (nside .le. 0) go to 10 27 | xlb(i) = xlb(i) * sold / snew 28 | xub(i) = xub(i) * sold / snew 29 | 10 continue 30 | c 31 | return 32 | end 33 | -------------------------------------------------------------------------------- /pyOpt/pyKSOPT/source/ksside.f: -------------------------------------------------------------------------------- 1 | subroutine ksside (x,xlb,xub,side,dfun,ndv,nside) 2 | implicit double precision (a-h,o-z) 3 | dimension x(*),xlb(*),xub(*),side(*),dfun(*) 4 | c 5 | c routine to compute a vector of flags side(i),i=1,ndv 6 | c side(i) = 0 -- d.v. i is not at a side constraint 7 | c = -1 -- d.v. i is at a lower bound 8 | c = +1 -- d.v. i is at an upper bound 9 | c = 999 -- d.v. i is at both upper and lower bounds 10 | c 11 | c also zero components of dfun that would violate 12 | c side constraints 13 | c 14 | c author - Gregory A. Wrenn 15 | c location - Lockheed Engineering and Sciences Co. 16 | c 144 Research Drive 17 | c Hampton, Va. 23666 18 | c 19 | c last modification - 19 July 1996 20 | c 21 | do 10 i = 1,ndv 22 | side(i) = 0.0 23 | if (nside .eq. 0) go to 10 24 | c 25 | xl = abs(xlb(i)) 26 | if (xl .lt. 1.0) xl = 1.0 27 | xx = (xlb(i) - x(i)) / xl 28 | if (xx .ge. -1.0e-6) side(i) = -1.0 29 | if (side(i) .lt. 0.0 .and. dfun(i) .gt. 0.0) dfun(i) = 0.0 30 | c 31 | xu = abs(xub(i)) 32 | if (xu .lt. 1.0) xu = 1.0 33 | xx = (x(i) - xub(i)) / xu 34 | if (xx .ge. -1.0e-6 .and. side(i) .ne. 0.0) side(i) = 999.0 35 | if (xx .ge. -1.0e-6 .and. side(i) .eq. 0.0) side(i) = 1.0 36 | if (side(i) .gt. 0.0 .and. dfun(i) .lt. 0.0) dfun(i) = 0.0 37 | 10 continue 38 | c 39 | return 40 | end 41 | -------------------------------------------------------------------------------- /pyOpt/pyKSOPT/source/ksunsc.f: -------------------------------------------------------------------------------- 1 | subroutine ksunsc (x,sx,scale,ndv) 2 | implicit double precision (a-h,o-z) 3 | dimension x(*),sx(*),scale(ndv,2) 4 | c 5 | c routine to un-scale design variables before returning 6 | c to the real world 7 | c 8 | c author - Gregory A. Wrenn 9 | c location - Lockheed Engineering and Sciences Co. 10 | c 144 Research Drive 11 | c Hampton, Va. 23666 12 | c 13 | c last modification - 17 July 1996 14 | c 15 | do 10 i = 1,ndv 16 | ss = scale(i,1) 17 | x(i) = sx(i) * ss 18 | 10 continue 19 | c 20 | return 21 | end 22 | -------------------------------------------------------------------------------- /pyOpt/pyKSOPT/source/ksvprd.f: -------------------------------------------------------------------------------- 1 | subroutine ksvprd (x,y,prod,nrow) 2 | implicit double precision (a-h,o-z) 3 | dimension x(*),y(*) 4 | c 5 | c routine to multiply vectors x and y 6 | c 7 | c author - Gregory A. Wrenn 8 | c location - Lockheed Engineering and Sciences Co. 9 | c 144 Research Drive 10 | c Hampton, Va. 23666 11 | c 12 | c last modification - 17 July 1996 13 | c 14 | prod = 0.0 15 | do 10 i = 1,nrow 16 | prod = prod + x(i) * y(i) 17 | 10 continue 18 | c 19 | return 20 | end 21 | -------------------------------------------------------------------------------- /pyOpt/pyKSOPT/source/ksxlim.f: -------------------------------------------------------------------------------- 1 | subroutine ksxlim (x,xlb,xub,ndv,nside) 2 | implicit double precision (a-h,o-z) 3 | dimension x(*),xlb(*),xub(*) 4 | c 5 | c routine to insure x-vector does not violate 6 | c upper or lower bounds 7 | c 8 | c author - Gregory A. Wrenn 9 | c location - Lockheed Engineering and Sciences Co. 10 | c 144 Research Drive 11 | c Hampton, Va. 23666 12 | c 13 | c last modification - 17 July 1996 14 | c 15 | if (nside .eq. 0) go to 20 16 | do 10 i = 1,ndv 17 | xx = x(i) 18 | xl = xlb(i) 19 | xu = xub(i) 20 | if (xx .lt. xl) xx = xl 21 | if (xx .gt. xu) xx = xu 22 | x(i) = xx 23 | 10 continue 24 | 20 continue 25 | c 26 | return 27 | end 28 | -------------------------------------------------------------------------------- /pyOpt/pyKSOPT/source/openunit.f: -------------------------------------------------------------------------------- 1 | C Helper subroutine to open files in the Fortran world 2 | subroutine openunit(unitnum,filename,filestatus,fileaction,ierror) 3 | 4 | integer unitnum 5 | Cf2py intent(in) unitnum 6 | character*(*) filename 7 | Cf2py intent(in) filename 8 | character*(*) filestatus 9 | Cf2py intent(in) filestatus 10 | character*(*) fileaction 11 | Cf2py intent(in) fileaction 12 | integer ierror 13 | Cf2py intent(out) ierror 14 | 15 | open(unit=unitnum,file=filename,status=filestatus, 16 | &access=fileaction,iostat=ierror) 17 | 18 | return 19 | end 20 | 21 | C Helper routine to flush buffers to files 22 | subroutine pyflush(unitnum) 23 | 24 | integer unitnum 25 | 26 | call flush(unitnum) 27 | 28 | return 29 | end 30 | -------------------------------------------------------------------------------- /pyOpt/pyMIDACO/LICENSE: -------------------------------------------------------------------------------- 1 | MIDACO - Mixed Integer Distributed Ant Colony Optimization 2 | Copyright (c) 2009, Martin Schlueter (info@midaco-solver.com) 3 | MIDACO interface for pyOpt - 2012, Ruben E. Perez 4 | 5 | MIDACO is a licensed software, it is redistributed within 6 | pyOpt with a limited license that enable optimizations with 7 | up to four variables. To obtain an unlimited license, as 8 | well as for term and conditions of use, please refer to 9 | the specific commercial or academic agreement made with 10 | the code developers. 11 | -------------------------------------------------------------------------------- /pyOpt/pyMIDACO/README: -------------------------------------------------------------------------------- 1 | This directory contains the midaco class definition 2 | and the midaco shared library, midaco.so or midaco.pyd. 3 | -------------------------------------------------------------------------------- /pyOpt/pyMIDACO/__init__.py: -------------------------------------------------------------------------------- 1 | try: 2 | from .pyMIDACO import MIDACO 3 | __all__ = ['MIDACO'] 4 | except: 5 | __all__ = [] 6 | -------------------------------------------------------------------------------- /pyOpt/pyMIDACO/setup.py: -------------------------------------------------------------------------------- 1 | import os 2 | 3 | 4 | def configuration(parent_package='', top_path=None): 5 | from numpy.distutils.misc_util import Configuration 6 | 7 | config = Configuration('pyMIDACO', parent_package, top_path) 8 | config.add_library('midaco', 9 | sources=[os.path.join('source', '*.f')]) 10 | config.add_extension('midaco', 11 | sources=['source/f2py/midaco.pyf'], 12 | libraries=['midaco']) 13 | config.add_data_files('LICENSE', 'README') 14 | 15 | return config 16 | 17 | 18 | if __name__ == '__main__': 19 | from numpy.distutils.core import setup 20 | 21 | setup(**configuration(top_path='').todict()) 22 | -------------------------------------------------------------------------------- /pyOpt/pyMIDACO/source/README: -------------------------------------------------------------------------------- 1 | This directory contains the Fortran source for MIDACO where 2 | the original print subroutine has been modified for pyOpt. 3 | The directory also contains a wrapping routine for pyOpt, 4 | midaco_wrap.f, and two helper files called openunit.f and 5 | closeunit.f to manipulate Fortran units from Python. 6 | -------------------------------------------------------------------------------- /pyOpt/pyMIDACO/source/closeunit.f: -------------------------------------------------------------------------------- 1 | C Helper subroutine to close files in the Fortran world 2 | subroutine closeunit(unitnum) 3 | 4 | integer unitnum 5 | Cf2py intent(in) unitnum 6 | 7 | close(unitnum) 8 | 9 | return 10 | end 11 | -------------------------------------------------------------------------------- /pyOpt/pyMIDACO/source/f2py/README: -------------------------------------------------------------------------------- 1 | This directory contains the f2py signature file. 2 | Do not edit these file unless you really know what you are doing. 3 | -------------------------------------------------------------------------------- /pyOpt/pyMIDACO/source/openunit.f: -------------------------------------------------------------------------------- 1 | C Helper subroutine to open files in the Fortran world 2 | subroutine openunit(unitnum,filename,filestatus,fileaction,ierror) 3 | 4 | integer unitnum 5 | Cf2py intent(in) unitnum 6 | character*(*) filename 7 | Cf2py intent(in) filename 8 | character*(*) filestatus 9 | Cf2py intent(in) filestatus 10 | character*(*) fileaction 11 | Cf2py intent(in) fileaction 12 | integer ierror 13 | Cf2py intent(out) ierror 14 | 15 | open(unit=unitnum,file=filename,status=filestatus, 16 | > access=fileaction,iostat=ierror) 17 | 18 | return 19 | end 20 | 21 | C Helper routine to flush buffers to files 22 | subroutine pyflush(unitnum) 23 | 24 | integer unitnum 25 | 26 | call flush(unitnum) 27 | 28 | return 29 | end 30 | -------------------------------------------------------------------------------- /pyOpt/pyMMA/LICENSE: -------------------------------------------------------------------------------- 1 | MMA - Method of Moving Asymptotes 2 | Copyright (c) 2000, Krister Svanberg (krille@math.kth.se) 3 | Modified for pyOpt - 2008, Ruben E. Perez (Ruben.Perez@rmc.ca) 4 | 5 | MMA is a licensed software, for term and conditions of use 6 | please refer to the specific commercial or academic agreement 7 | made with Professor Svanberg. 8 | -------------------------------------------------------------------------------- /pyOpt/pyMMA/README: -------------------------------------------------------------------------------- 1 | This directory contains the mma class definition 2 | and the mma shared library, mma.so or mma.pyd. 3 | -------------------------------------------------------------------------------- /pyOpt/pyMMA/__init__.py: -------------------------------------------------------------------------------- 1 | try: 2 | from .pyMMA import MMA 3 | __all__ = ['MMA'] 4 | except: 5 | __all__ = [] 6 | -------------------------------------------------------------------------------- /pyOpt/pyMMA/setup.py: -------------------------------------------------------------------------------- 1 | import os 2 | 3 | 4 | def configuration(parent_package='', top_path=None): 5 | from numpy.distutils.misc_util import Configuration 6 | 7 | config = Configuration('pyMMA', parent_package, top_path) 8 | config.add_library('mma', 9 | sources=[os.path.join('source', '*.f')]) 10 | config.add_extension('mma', 11 | sources=['source/f2py/mma.pyf'], 12 | libraries=['mma']) 13 | config.add_data_files('LICENSE', 'README') 14 | 15 | return config 16 | 17 | 18 | if __name__ == '__main__': 19 | from numpy.distutils.core import setup 20 | 21 | setup(**configuration(top_path='').todict()) 22 | -------------------------------------------------------------------------------- /pyOpt/pyMMA/source/README: -------------------------------------------------------------------------------- 1 | This directory contains the Fortran 77 source for MMA, 2 | the main routine of the original program has been modified 3 | to enable Python interfacing by Mr. Andrew Lambe with 4 | updated functionality added by Dr. Ruben E. Perez. 5 | -------------------------------------------------------------------------------- /pyOpt/pyMMA/source/closeunit.f: -------------------------------------------------------------------------------- 1 | C Helper subroutine to close files in the Fortran world 2 | subroutine closeunit(unitnum) 3 | 4 | integer unitnum 5 | Cf2py intent(in) unitnum 6 | 7 | close(unitnum) 8 | 9 | return 10 | end 11 | -------------------------------------------------------------------------------- /pyOpt/pyMMA/source/f2py/README: -------------------------------------------------------------------------------- 1 | This directory contains the f2py signature file. 2 | Do not edit these file unless you really know what you are doing. 3 | -------------------------------------------------------------------------------- /pyOpt/pyMMA/source/openunit.f: -------------------------------------------------------------------------------- 1 | C Helper subroutine to open files in the Fortran world 2 | subroutine openunit(unitnum,filename,filestatus,fileaction,ierror) 3 | 4 | integer unitnum 5 | Cf2py intent(in) unitnum 6 | character*(*) filename 7 | Cf2py intent(in) filename 8 | character*(*) filestatus 9 | Cf2py intent(in) filestatus 10 | character*(*) fileaction 11 | Cf2py intent(in) fileaction 12 | integer ierror 13 | Cf2py intent(out) ierror 14 | 15 | open(unit=unitnum,file=filename,status=filestatus, 16 | > access=fileaction,iostat=ierror) 17 | 18 | return 19 | end 20 | 21 | C Helper routine to flush buffers to files 22 | subroutine pyflush(unitnum) 23 | 24 | integer unitnum 25 | 26 | call flush(unitnum) 27 | 28 | return 29 | end 30 | -------------------------------------------------------------------------------- /pyOpt/pyMMFD/LICENSE: -------------------------------------------------------------------------------- 1 | ADS - Automated Design Synthesis Optimization Program 2 | Copyright (c) 1982, Gary N. Vanderplaats 3 | ADS/MMFD interface for pyOpt - 2010, Ruben E. Perez (Ruben.Perez@rmc.ca) 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a 6 | copy of this software and associated documentation files (the 7 | "Software"), to deal in the Software without restriction, including 8 | without limitation the rights to use, copy, modify, merge, publish, 9 | distribute, sublicense, and/or sell copies of the Software, and to 10 | permit persons to whom the Software is furnished to do so, subject to 11 | the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be included 14 | in all copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY OF ANY KIND, 17 | EITHER EXPRESSED, IMPLIED, OR STATUTORY, INCLUDING, BUT NOT LIMITED 18 | TO, ANY WARRANTY THAT THE SOFTWARE WILL CONFORM TO SPECIFICATIONS, 19 | ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR 20 | PURPOSE, AND FREEDOM FROM INFRINGEMENT, AND ANY WARRANTY THAT THE 21 | DOCUMENTATION WILL CONFORM TO THE SOFTWARE, OR ANY WARRANTY THAT 22 | THE SOFTWARE WILL BE ERROR FREE. IN NO EVENT SHALL NASA BE LIABLE 23 | FOR ANY DAMAGES, INCLUDING, BUT NOT LIMITED TO, DIRECT, INDIRECT, 24 | SPECIAL OR CONSEQUENTIAL DAMAGES, ARISING OUT OF, RESULTING FROM, 25 | OR IN ANY WAY CONNECTED WITH THIS SOFTWARE, WHETHER OR NOT BASED 26 | UPON WARRANTY, CONTRACT, TORT , OR OTHERWISE, WHETHER OR NOT INJURY 27 | WAS SUSTAINED BY PERSONS OR PROPERTY OR OTHERWISE, AND WHETHER OR 28 | NOT LOSS WAS SUSTAINED FROM, OR AROSE OUT OF THE RESULTS OF, OR USE 29 | OF, THE SOFTWARE OR SERVICES PROVIDED HEREUNDER. 30 | -------------------------------------------------------------------------------- /pyOpt/pyMMFD/README: -------------------------------------------------------------------------------- 1 | This directory contains the mmfd class definition 2 | and the mmfd shared library, mmfd.so or mmfd.pyd. 3 | -------------------------------------------------------------------------------- /pyOpt/pyMMFD/__init__.py: -------------------------------------------------------------------------------- 1 | try: 2 | from .pyMMFD import MMFD 3 | __all__ = ['MMFD'] 4 | except: 5 | __all__ = [] 6 | -------------------------------------------------------------------------------- /pyOpt/pyMMFD/setup.py: -------------------------------------------------------------------------------- 1 | import os 2 | 3 | 4 | def configuration(parent_package='', top_path=None): 5 | from numpy.distutils.misc_util import Configuration 6 | 7 | config = Configuration('pyMMFD', parent_package, top_path) 8 | config.add_library('mmfd', 9 | sources=[os.path.join('source', '*.f')]) 10 | config.add_extension('mmfd', 11 | sources=['source/f2py/mmfd.pyf'], 12 | libraries=['mmfd']) 13 | config.add_data_files('LICENSE', 'README') 14 | 15 | return config 16 | 17 | 18 | if __name__ == '__main__': 19 | from numpy.distutils.core import setup 20 | 21 | setup(**configuration(top_path='').todict()) 22 | -------------------------------------------------------------------------------- /pyOpt/pyMMFD/source/README: -------------------------------------------------------------------------------- 1 | This directory contains the Fortran 77 source for 2 | MMFD, plus two helper files called openunit.f and 3 | closeunit.f to manipulate Fortran units from Python. 4 | -------------------------------------------------------------------------------- /pyOpt/pyMMFD/source/closeunit.f: -------------------------------------------------------------------------------- 1 | C Helper subroutine to close files in the Fortran world 2 | subroutine closeunit(unitnum) 3 | 4 | integer unitnum 5 | Cf2py intent(in) unitnum 6 | 7 | close(unitnum) 8 | 9 | return 10 | end 11 | -------------------------------------------------------------------------------- /pyOpt/pyMMFD/source/f2py/README: -------------------------------------------------------------------------------- 1 | This directory contains the f2py signature file. 2 | Do not edit these file unless you really know what you are doing. 3 | -------------------------------------------------------------------------------- /pyOpt/pyMMFD/source/openunit.f: -------------------------------------------------------------------------------- 1 | C Helper subroutine to open files in the Fortran world 2 | subroutine openunit(unitnum,filename,filestatus,fileaction,ierror) 3 | 4 | integer unitnum 5 | Cf2py intent(in) unitnum 6 | character*(*) filename 7 | Cf2py intent(in) filename 8 | character*(*) filestatus 9 | Cf2py intent(in) filestatus 10 | character*(*) fileaction 11 | Cf2py intent(in) fileaction 12 | integer ierror 13 | Cf2py intent(out) ierror 14 | 15 | open(unit=unitnum,file=filename,status=filestatus, 16 | &access=fileaction,iostat=ierror) 17 | 18 | return 19 | end 20 | 21 | C Helper routine to flush buffers to files 22 | subroutine pyflush(unitnum) 23 | 24 | integer unitnum 25 | 26 | call flush(unitnum) 27 | 28 | return 29 | end 30 | -------------------------------------------------------------------------------- /pyOpt/pyNLPQL/LICENSE: -------------------------------------------------------------------------------- 1 | NLPQL - Non-Linear Programming by Quadratic Lagrangian 2 | Copyright (c) 1991, Klaus Schittkowski (Klaus.Schittkowski@uni-bayreuth.de) 3 | Patch for pyOpt - 2010, Ruben E. Perez (Ruben.Perez@rmc.ca) 4 | 5 | NLPQL is a licensed software, to obtain the program sources and 6 | for term and conditions of use please refer to the specific 7 | commercial or academic agreement made with Professor Schittkowski. 8 | -------------------------------------------------------------------------------- /pyOpt/pyNLPQL/README: -------------------------------------------------------------------------------- 1 | This directory contains the nlpql class definition 2 | and the nlpql shared library, nlpql.so or nlpql.pyd. 3 | -------------------------------------------------------------------------------- /pyOpt/pyNLPQL/__init__.py: -------------------------------------------------------------------------------- 1 | try: 2 | from .pyNLPQL import NLPQL 3 | __all__ = ['NLPQL'] 4 | except: 5 | __all__ = [] 6 | -------------------------------------------------------------------------------- /pyOpt/pyNLPQL/setup.py: -------------------------------------------------------------------------------- 1 | import os 2 | 3 | 4 | def configuration(parent_package='', top_path=None): 5 | from numpy.distutils.misc_util import Configuration 6 | 7 | config = Configuration('pyNLPQL', parent_package, top_path) 8 | config.add_library('nlpql', 9 | sources=[os.path.join('source', '*.f')]) 10 | config.add_extension('nlpql', 11 | sources=['source/f2py/nlpql.pyf'], 12 | libraries=['nlpql']) 13 | config.add_data_files('LICENSE', 'README') 14 | 15 | return config 16 | 17 | 18 | if __name__ == '__main__': 19 | from numpy.distutils.core import setup 20 | 21 | setup(**configuration(top_path='').todict()) 22 | -------------------------------------------------------------------------------- /pyOpt/pyNLPQL/source/README: -------------------------------------------------------------------------------- 1 | This directory contains the Fortran 77 source for 2 | NLPQL, plus two helper files called openunit.f and 3 | closeunit.f to manipulate Fortran units from Python. 4 | -------------------------------------------------------------------------------- /pyOpt/pyNLPQL/source/closeunit.f: -------------------------------------------------------------------------------- 1 | C Helper subroutine to close files in the Fortran world 2 | subroutine closeunit(unitnum) 3 | 4 | integer unitnum 5 | Cf2py intent(in) unitnum 6 | 7 | close(unitnum) 8 | 9 | return 10 | end 11 | -------------------------------------------------------------------------------- /pyOpt/pyNLPQL/source/f2py/README: -------------------------------------------------------------------------------- 1 | This directory contains the f2py signature file. 2 | Do not edit these file unless you really know what you are doing. 3 | -------------------------------------------------------------------------------- /pyOpt/pyNLPQL/source/nlpql1.diff: -------------------------------------------------------------------------------- 1 | 2,3c2,3 2 | < 1 C,D,ACC,SCBOU,MAXFUN,MAXIT,IPRINT,MODE,IOUT,IFAIL,WA,LWA, 3 | < 2 KWA,LKWA,ACTIVE,LACTIV,LMERIT,LQL) 4 | --- 5 | > 1 C,D,ACC,SCBOU,MAXFUN,MAXIT,IPRINT,MODE,IOUT,IFILE,IFAIL, 6 | > 2 WA,LWA,KWA,LKWA,ACTIVE,LACTIV,LMERIT,LQL,EPS,NLFUNC,NLGRAD) 7 | 286a287,291 8 | > C 9 | > DOUBLE PRECISION EPS 10 | > EXTERNAL NLFUNC,NLGRAD 11 | > C 12 | > CHARACTER*(*) IFILE 13 | 294a300 14 | > COMMON/CMACHE/EPS0 15 | 298a305,308 16 | > C PROVIDE MACHINE PRECISION PARAMETER 17 | > C 18 | > EPS0=EPS 19 | > C 20 | 319a330 21 | > OPEN(UNIT=IOUT,FILE=IFILE(1:LEN_TRIM(IFILE)),STATUS='UNKNOWN') 22 | 475c486,487 23 | < 7 ACTIVE(M3),ACTIVE(M4),ACTIVE(M5),ACTIVE(M6),ACTIVE(M7)) 24 | --- 25 | > 7 ACTIVE(M3),ACTIVE(M4),ACTIVE(M5),ACTIVE(M6),ACTIVE(M7), 26 | > 8 NLFUNC,NLGRAD) 27 | 493c505 28 | < END 29 | \ No newline at end of file 30 | --- 31 | > END 32 | -------------------------------------------------------------------------------- /pyOpt/pyNLPQL/source/nlpql2.diff: -------------------------------------------------------------------------------- 1 | 6c6 2 | < 5 LLINE,LREST,LALSD,LRECO,LBEST) 3 | --- 4 | > 5 LLINE,LREST,LALSD,LRECO,LBEST,NLFUNC,NLGRAD) 5 | 37a38,39 6 | > C 7 | > EXTERNAL NLFUNC,NLGRAD 8 | 421c423 9 | < 1280 FORMAT(8X,33HOBJECTIVE FUNCTION VALUE: F(X) =,D16.8) 10 | --- 11 | > 1280 FORMAT(8X,33HOBJECTIVE FUNCTION VALUE: F(X) =,D20.12) 12 | -------------------------------------------------------------------------------- /pyOpt/pyNLPQL/source/openunit.f: -------------------------------------------------------------------------------- 1 | C Helper subroutine to open files in the Fortran world 2 | subroutine openunit(unitnum,filename,filestatus,fileaction,ierror) 3 | 4 | integer unitnum 5 | Cf2py intent(in) unitnum 6 | character*(*) filename 7 | Cf2py intent(in) filename 8 | character*(*) filestatus 9 | Cf2py intent(in) filestatus 10 | character*(*) fileaction 11 | Cf2py intent(in) fileaction 12 | integer ierror 13 | Cf2py intent(out) ierror 14 | 15 | open(unit=unitnum,file=filename,status=filestatus, 16 | > access=fileaction,iostat=ierror) 17 | 18 | return 19 | end 20 | 21 | C Helper routine to flush buffers to files 22 | subroutine pyflush(unitnum) 23 | 24 | integer unitnum 25 | 26 | call flush(unitnum) 27 | 28 | return 29 | end 30 | -------------------------------------------------------------------------------- /pyOpt/pyNLPQLP/LICENSE: -------------------------------------------------------------------------------- 1 | NLPQLP - Nonlinear Programming with Non-Monotone and Distributed Line Search 2 | Copyright (c) 2010, Klaus Schittkowski (Klaus.Schittkowski@uni-bayreuth.de) 3 | NLPQLP interface for pyOpt - 2011, Ruben E. Perez (Ruben.Perez@rmc.ca) 4 | 5 | NLPQLP is a licensed software, to obtain the program sources and 6 | for term and conditions of use please refer to the specific 7 | commercial or academic agreement made with Professor Schittkowski. 8 | -------------------------------------------------------------------------------- /pyOpt/pyNLPQLP/README: -------------------------------------------------------------------------------- 1 | This directory contains the nlpqlp class definition 2 | and the nlpqlp shared library, nlpqlp.so or nlpqlp.pyd. 3 | -------------------------------------------------------------------------------- /pyOpt/pyNLPQLP/__init__.py: -------------------------------------------------------------------------------- 1 | try: 2 | from .pyNLPQLP import NLPQLP 3 | __all__ = ['NLPQLP'] 4 | except: 5 | __all__ = [] 6 | -------------------------------------------------------------------------------- /pyOpt/pyNLPQLP/setup.py: -------------------------------------------------------------------------------- 1 | import os 2 | 3 | 4 | def configuration(parent_package='', top_path=None): 5 | from numpy.distutils.misc_util import Configuration 6 | 7 | config = Configuration('pyNLPQLP', parent_package, top_path) 8 | 9 | config.add_library('nlpqlp', 10 | sources=[os.path.join('source', '*.for')]) 11 | config.add_extension('nlpqlp', 12 | sources=['source/f2py/nlpqlp.pyf'], 13 | libraries=['nlpqlp']) 14 | config.add_data_files('LICENSE', 'README') 15 | 16 | return config 17 | 18 | 19 | if __name__ == '__main__': 20 | from numpy.distutils.core import setup 21 | 22 | setup(**configuration(top_path='').todict()) 23 | -------------------------------------------------------------------------------- /pyOpt/pyNLPQLP/source/README: -------------------------------------------------------------------------------- 1 | This directory contains the Fortran 77 source for NLPQLP; 2 | it also contains a wrapping routine nlpqlp_wrap.for developed 3 | by Dr. Ruben E. Perez and two helper files called openunit.for 4 | and closeunit.for to manipulate Fortran units from Python. 5 | -------------------------------------------------------------------------------- /pyOpt/pyNLPQLP/source/closeunit.for: -------------------------------------------------------------------------------- 1 | C Helper subroutine to close files in the Fortran world 2 | subroutine closeunit(unitnum) 3 | 4 | integer unitnum 5 | Cf2py intent(in) unitnum 6 | 7 | close(unitnum) 8 | 9 | return 10 | end 11 | -------------------------------------------------------------------------------- /pyOpt/pyNLPQLP/source/f2py/README: -------------------------------------------------------------------------------- 1 | This directory contains the f2py signature file. 2 | Do not edit these file unless you really know what you are doing. 3 | -------------------------------------------------------------------------------- /pyOpt/pyNLPQLP/source/nlpqlp_wrap.for: -------------------------------------------------------------------------------- 1 | SUBROUTINE NLPQLP_WRAP (L,M,ME,MMAX,N,NMAX,MNN2, 2 | / X,F,G,DF,DG,U,XL,XU,C,D, 3 | / ACC,ACCQP,STPMIN,MAXFUN,MAXIT,MAXNM,RHOB,MODE, 4 | / IFAIL,IPRINT,IOUT,IFILE, 5 | / WA,LWA,KWA,LKWA,ACTIVE,LACTIV,LQL, 6 | / NFUN,NGRD,NLFUNC,NLGRAD) 7 | C 8 | IMPLICIT NONE 9 | INTEGER NMAX, MMAX, MNN2, LWA, LKWA, LACTIV, 10 | / KWA(LKWA), N, ME, M, L, MAXIT, MAXFUN, 11 | / IPRINT,MAXNM,IOUT,MODE,IFAIL,NFUN,NGRD 12 | DOUBLE PRECISION X(NMAX,L), F(L), G(MMAX,L), DF(NMAX), 13 | / DG(MMAX,NMAX), U(MNN2), XL(NMAX), XU(NMAX), 14 | / C(NMAX,NMAX), D(NMAX), WA(LWA), ACC, ACCQP, 15 | / STPMIN, RHOB 16 | LOGICAL ACTIVE(LACTIV), LQL 17 | CHARACTER*(*) IFILE 18 | EXTERNAL QL 19 | EXTERNAL NLFUNC,NLGRAD 20 | C 21 | C OPEN WRITE FILE 22 | C 23 | IF (IPRINT.NE.0) THEN 24 | OPEN(UNIT=IOUT,FILE=IFILE,STATUS='UNKNOWN') 25 | ENDIF 26 | C 27 | C EVALUATE OBJECTIVE AND CONSTRAINTS 28 | C 29 | 30 CONTINUE 30 | CALL NLFUNC(L,NMAX,MMAX,X,LACTIV,ACTIVE,F,G) 31 | NFUN=NFUN+1 32 | IF (IFAIL.EQ.-1) GOTO 50 33 | C 34 | C EVALUATE GRADIENTS OF OBJECTIVE AND CONSTRAINTS 35 | C 36 | 40 CONTINUE 37 | CALL NLGRAD(L,NMAX,MMAX,X,LACTIV,ACTIVE,F,G,DF,DG) 38 | NGRD=NGRD+1 39 | C 40 | C CALL NLPQLP 41 | C 42 | 50 CONTINUE 43 | CALL NLPQLP ( L, M, ME, MMAX, N, 44 | / NMAX, MNN2, X, F, G, 45 | / DF, DG, U, XL, XU, 46 | / C, D, ACC, ACCQP, STPMIN, 47 | / MAXFUN, MAXIT, MAXNM, RHOB, IPRINT, 48 | / MODE, IOUT, IFAIL, WA, LWA, 49 | / KWA, LKWA, ACTIVE, LACTIV, LQL, 50 | / QL) 51 | C 52 | C EVALUATIONS 53 | C 54 | IF (IFAIL.EQ.-1) GOTO 30 55 | IF (IFAIL.EQ.-2) GOTO 40 56 | C 57 | RETURN 58 | END 59 | -------------------------------------------------------------------------------- /pyOpt/pyNLPQLP/source/openunit.for: -------------------------------------------------------------------------------- 1 | C Helper subroutine to open files in the Fortran world 2 | subroutine openunit(unitnum,filename,filestatus,fileaction,ierror) 3 | 4 | integer unitnum 5 | Cf2py intent(in) unitnum 6 | character*(*) filename 7 | Cf2py intent(in) filename 8 | character*(*) filestatus 9 | Cf2py intent(in) filestatus 10 | character*(*) fileaction 11 | Cf2py intent(in) fileaction 12 | integer ierror 13 | Cf2py intent(out) ierror 14 | 15 | open(unit=unitnum,file=filename,status=filestatus, 16 | > access=fileaction,iostat=ierror) 17 | 18 | return 19 | end 20 | 21 | C Helper routine to flush buffers to files 22 | subroutine pyflush(unitnum) 23 | 24 | integer unitnum 25 | 26 | call flush(unitnum) 27 | 28 | return 29 | end 30 | -------------------------------------------------------------------------------- /pyOpt/pyNSGA2/LICENSE: -------------------------------------------------------------------------------- 1 | NSGA2 - Non Sorting Genetic Algorithm II 2 | Copyright (c) 2005, Kalyanmoy Deb (deb@iitk.ac.in) 3 | Modified for pyOpt - 2008, Ruben E. Perez (Ruben.Perez@rmc.ca) 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a 6 | copy of this software and associated documentation files (the 7 | "Software"), to deal in the Software without restriction, including 8 | without limitation the rights to use, copy, modify, merge, publish, 9 | copies of the Software, and to permit persons to whom the Software 10 | is furnished to do so, subject to the following conditions: 11 | 12 | Distribution, sublicense, and/or sell of this code for any commercial 13 | purpose is permissible ONLY BY DIRECT ARRANGEMENT WITH THE COPYRIGHT OWNER. 14 | 15 | The above copyright notice and this permission notice shall be included 16 | in all copies or substantial portions of the Software. 17 | 18 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 19 | OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 20 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 21 | IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 22 | CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 23 | TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 24 | SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 25 | -------------------------------------------------------------------------------- /pyOpt/pyNSGA2/README: -------------------------------------------------------------------------------- 1 | This directory contains the nsga2 class definition 2 | and the nsga2 shared library, _nsga2.so or _nsga2.pyd. 3 | -------------------------------------------------------------------------------- /pyOpt/pyNSGA2/__init__.py: -------------------------------------------------------------------------------- 1 | try: 2 | from .pyNSGA2 import NSGA2 3 | __all__ = ['NSGA2'] 4 | except: 5 | __all__ = [] 6 | -------------------------------------------------------------------------------- /pyOpt/pyNSGA2/source/README: -------------------------------------------------------------------------------- 1 | This directory contains the C source for 2 | NSGA2, the main routine of the original 3 | program has been modified to enable Python 4 | interfacing by Dr. Ruben E. Perez. 5 | -------------------------------------------------------------------------------- /pyOpt/pyNSGA2/source/allocate.c: -------------------------------------------------------------------------------- 1 | /* Memory allocation and deallocation routines */ 2 | 3 | # include 4 | # include 5 | # include 6 | 7 | # include "nsga2.h" 8 | # include "rand.h" 9 | 10 | /* Function to allocate memory to a population */ 11 | void allocate_memory_pop (population *pop, int size, Global global) 12 | { 13 | int i; 14 | pop->ind = (individual *)malloc(size*sizeof(individual)); 15 | for (i=0; iind[i]), global); 18 | } 19 | return; 20 | } 21 | 22 | /* Function to allocate memory to an individual */ 23 | void allocate_memory_ind (individual *ind, Global global) 24 | { 25 | int j; 26 | if (global.nreal != 0) 27 | { 28 | ind->xreal = (double *)malloc(global.nreal*sizeof(double)); 29 | } 30 | if (global.nbin != 0) 31 | { 32 | ind->xbin = (double *)malloc(global.nbin*sizeof(double)); 33 | ind->gene = (int **)malloc(global.nbin*sizeof(int)); 34 | for (j=0; jgene[j] = (int *)malloc(global.nbits[j]*sizeof(int)); 37 | } 38 | } 39 | ind->obj = (double *)malloc(global.nobj*sizeof(double)); 40 | if (global.ncon != 0) 41 | { 42 | ind->constr = (double *)malloc(global.ncon*sizeof(double)); 43 | } 44 | return; 45 | } 46 | 47 | /* Function to deallocate memory to a population */ 48 | void deallocate_memory_pop (population *pop, int size, Global global) 49 | { 50 | int i; 51 | for (i=0; iind[i]), global); 54 | } 55 | free (pop->ind); 56 | return; 57 | } 58 | 59 | /* Function to deallocate memory to an individual */ 60 | void deallocate_memory_ind (individual *ind, Global global) 61 | { 62 | int j; 63 | if (global.nreal != 0) 64 | { 65 | free(ind->xreal); 66 | } 67 | if (global.nbin != 0) 68 | { 69 | for (j=0; jgene[j]); 72 | } 73 | free(ind->xbin); 74 | free(ind->gene); 75 | } 76 | free(ind->obj); 77 | if (global.ncon != 0) 78 | { 79 | free(ind->constr); 80 | } 81 | return; 82 | } 83 | -------------------------------------------------------------------------------- /pyOpt/pyNSGA2/source/auxiliary.c: -------------------------------------------------------------------------------- 1 | /* Some utility functions (not part of the algorithm) */ 2 | 3 | # include 4 | # include 5 | # include 6 | 7 | # include "nsga2.h" 8 | # include "rand.h" 9 | 10 | /* Function to return the maximum of two variables */ 11 | double maximum (double a, double b) 12 | { 13 | if (a>b) 14 | { 15 | return(a); 16 | } 17 | return (b); 18 | } 19 | 20 | /* Function to return the minimum of two variables */ 21 | double minimum (double a, double b) 22 | { 23 | if (a 4 | # include 5 | # include 6 | 7 | # include "nsga2.h" 8 | # include "rand.h" 9 | 10 | /* Function to decode a population to find out the binary variable values based on its bit pattern */ 11 | void decode_pop (population *pop, Global global) 12 | { 13 | int i; 14 | if (global.nbin!=0) 15 | { 16 | for (i=0; iind[i]),global); 19 | } 20 | } 21 | return; 22 | } 23 | 24 | /* Function to decode an individual to find out the binary variable values based on its bit pattern */ 25 | void decode_ind (individual *ind, Global global) 26 | { 27 | int j, k; 28 | int sum; 29 | if (global.nbin!=0) 30 | { 31 | for (j=0; jgene[j][k]==1) 37 | { 38 | sum += pow(2,global.nbits[j]-1-k); 39 | } 40 | } 41 | ind->xbin[j] = global.min_binvar[j] + (double)sum*(global.max_binvar[j] - global.min_binvar[j])/(double)(pow(2,global.nbits[j])-1); 42 | } 43 | } 44 | return; 45 | } 46 | -------------------------------------------------------------------------------- /pyOpt/pyNSGA2/source/dominance.c: -------------------------------------------------------------------------------- 1 | /* Domination checking routines */ 2 | 3 | # include 4 | # include 5 | # include 6 | 7 | # include "nsga2.h" 8 | # include "rand.h" 9 | 10 | /* Routine for usual non-domination checking 11 | It will return the following values 12 | 1 if a dominates b 13 | -1 if b dominates a 14 | 0 if both a and b are non-dominated */ 15 | 16 | int check_dominance (individual *a, individual *b, Global global) 17 | { 18 | int i; 19 | int flag1; 20 | int flag2; 21 | flag1 = 0; 22 | flag2 = 0; 23 | if (a->constr_violation<0 && b->constr_violation<0) 24 | { 25 | if (a->constr_violation > b->constr_violation) 26 | { 27 | return (1); 28 | } 29 | else 30 | { 31 | if (a->constr_violation < b->constr_violation) 32 | { 33 | return (-1); 34 | } 35 | else 36 | { 37 | return (0); 38 | } 39 | } 40 | } 41 | else 42 | { 43 | if (a->constr_violation < 0 && b->constr_violation == 0) 44 | { 45 | return (-1); 46 | } 47 | else 48 | { 49 | if (a->constr_violation == 0 && b->constr_violation <0) 50 | { 51 | return (1); 52 | } 53 | else 54 | { 55 | for (i=0; iobj[i] < b->obj[i]) 58 | { 59 | flag1 = 1; 60 | 61 | } 62 | else 63 | { 64 | if (a->obj[i] > b->obj[i]) 65 | { 66 | flag2 = 1; 67 | } 68 | } 69 | } 70 | if (flag1==1 && flag2==0) 71 | { 72 | return (1); 73 | } 74 | else 75 | { 76 | if (flag1==0 && flag2==1) 77 | { 78 | return (-1); 79 | } 80 | else 81 | { 82 | return (0); 83 | } 84 | } 85 | } 86 | } 87 | } 88 | } 89 | -------------------------------------------------------------------------------- /pyOpt/pyNSGA2/source/eval.c: -------------------------------------------------------------------------------- 1 | /* Routine for evaluating population members */ 2 | 3 | # include 4 | # include 5 | # include 6 | 7 | # include "nsga2.h" 8 | # include "rand.h" 9 | 10 | /* Routine to evaluate objective function values and constraints for a population */ 11 | int evaluate_pop (population *pop, Global global) 12 | { 13 | int i, res; 14 | for (i=0; iind[i]),global); 17 | if (res) 18 | { 19 | return res; 20 | } 21 | } 22 | return 0; 23 | } 24 | 25 | /* Routine to evaluate objective function values and constraints for an individual */ 26 | int evaluate_ind (individual *ind, Global global) 27 | { 28 | int j, res; 29 | res = nsga2func (global.nreal, global.nbin, global.nobj, global.ncon, ind->xreal, ind->xbin, ind->gene, ind->obj, ind->constr); 30 | if (res) 31 | { 32 | return res; 33 | } 34 | if (global.ncon==0) 35 | { 36 | ind->constr_violation = 0.0; 37 | } 38 | else 39 | { 40 | ind->constr_violation = 0.0; 41 | for (j=0; jconstr[j]<0.0) 44 | { 45 | ind->constr_violation += ind->constr[j]; 46 | } 47 | } 48 | } 49 | return res; 50 | } 51 | -------------------------------------------------------------------------------- /pyOpt/pyNSGA2/source/initialize.c: -------------------------------------------------------------------------------- 1 | /* Data initializtion routines */ 2 | 3 | # include 4 | # include 5 | # include 6 | 7 | # include "nsga2.h" 8 | # include "rand.h" 9 | 10 | /* Function to initialize a population randomly */ 11 | void initialize_pop (population *pop, Global global) 12 | { 13 | int i; 14 | for (i=0; iind[i]),global); 17 | } 18 | return; 19 | } 20 | 21 | /* Function to initialize an individual randomly */ 22 | void initialize_ind (individual *ind, Global global) 23 | { 24 | int j, k; 25 | if (global.nreal!=0) 26 | { 27 | for (j=0; jxreal[j] = rndreal (global.min_realvar[j], global.max_realvar[j]); 30 | } 31 | } 32 | if (global.nbin!=0) 33 | { 34 | for (j=0; jgene[j][k] = 0; 41 | } 42 | else 43 | { 44 | ind->gene[j][k] = 1; 45 | } 46 | } 47 | } 48 | } 49 | return; 50 | } 51 | -------------------------------------------------------------------------------- /pyOpt/pyNSGA2/source/list.c: -------------------------------------------------------------------------------- 1 | /* A custom doubly linked list implemenation */ 2 | 3 | # include 4 | # include 5 | # include 6 | 7 | # include "nsga2.h" 8 | # include "rand.h" 9 | 10 | /* Insert an element X into the list at location specified by NODE */ 11 | void insert (list *node, int x) 12 | { 13 | list *temp; 14 | if (node==NULL) 15 | { 16 | printf("\n Error!! asked to enter after a NULL pointer, hence exiting \n"); 17 | exit(1); 18 | } 19 | temp = (list *)malloc(sizeof(list)); 20 | temp->index = x; 21 | temp->child = node->child; 22 | temp->parent = node; 23 | if (node->child != NULL) 24 | { 25 | node->child->parent = temp; 26 | } 27 | node->child = temp; 28 | return; 29 | } 30 | 31 | /* Delete the node NODE from the list */ 32 | list* delnode (list *node) 33 | { 34 | list *temp; 35 | if (node==NULL) 36 | { 37 | printf("\n Error!! asked to delete a NULL pointer, hence exiting \n"); 38 | exit(1); 39 | } 40 | temp = node->parent; 41 | temp->child = node->child; 42 | if (temp->child!=NULL) 43 | { 44 | temp->child->parent = temp; 45 | } 46 | free (node); 47 | return (temp); 48 | } 49 | -------------------------------------------------------------------------------- /pyOpt/pyNSGA2/source/merge.c: -------------------------------------------------------------------------------- 1 | /* Routine for mergeing two populations */ 2 | 3 | # include 4 | # include 5 | # include 6 | 7 | # include "nsga2.h" 8 | # include "rand.h" 9 | 10 | /* Routine to merge two populations into one */ 11 | void merge(population *pop1, population *pop2, population *pop3, Global global) 12 | { 13 | int i, k; 14 | for (i=0; iind[i]), &(pop3->ind[i]), global); 17 | } 18 | for (i=0, k=global.popsize; iind[i]), &(pop3->ind[k]), global); 21 | } 22 | return; 23 | } 24 | 25 | /* Routine to copy an individual 'ind1' into another individual 'ind2' */ 26 | void copy_ind (individual *ind1, individual *ind2, Global global) 27 | { 28 | int i, j; 29 | ind2->rank = ind1->rank; 30 | ind2->constr_violation = ind1->constr_violation; 31 | ind2->crowd_dist = ind1->crowd_dist; 32 | if (global.nreal!=0) 33 | { 34 | for (i=0; ixreal[i] = ind1->xreal[i]; 37 | } 38 | } 39 | if (global.nbin!=0) 40 | { 41 | for (i=0; ixbin[i] = ind1->xbin[i]; 44 | for (j=0; jgene[i][j] = ind1->gene[i][j]; 47 | } 48 | } 49 | } 50 | for (i=0; iobj[i] = ind1->obj[i]; 53 | } 54 | if (global.ncon!=0) 55 | { 56 | for (i=0; iconstr[i] = ind1->constr[i]; 59 | } 60 | } 61 | return; 62 | } 63 | -------------------------------------------------------------------------------- /pyOpt/pyNSGA2/source/mutation.c: -------------------------------------------------------------------------------- 1 | /* Mutation routines */ 2 | 3 | # include 4 | # include 5 | # include 6 | 7 | # include "nsga2.h" 8 | # include "rand.h" 9 | 10 | /* Function to perform mutation in a population */ 11 | void mutation_pop (population *pop, Global global,int *nrealmut,int *nbinmut) 12 | { 13 | int i; 14 | for (i=0; iind[i]),global,nrealmut,nbinmut); 17 | } 18 | return; 19 | } 20 | 21 | /* Function to perform mutation of an individual */ 22 | void mutation_ind (individual *ind, Global global,int *nrealmut,int *nbinmut) 23 | { 24 | if (global.nreal!=0) 25 | { 26 | real_mutate_ind(ind, global, nrealmut); 27 | } 28 | if (global.nbin!=0) 29 | { 30 | bin_mutate_ind(ind, global, nbinmut); 31 | } 32 | return; 33 | } 34 | 35 | /* Routine for binary mutation of an individual */ 36 | void bin_mutate_ind (individual *ind, Global global,int *nbinmut) 37 | { 38 | int j, k; 39 | double prob; 40 | for (j=0; jgene[j][k] == 0) 48 | { 49 | ind->gene[j][k] = 1; 50 | } 51 | else 52 | { 53 | ind->gene[j][k] = 0; 54 | } 55 | nbinmut+=1; 56 | } 57 | } 58 | } 59 | return; 60 | } 61 | 62 | /* Routine for real polynomial mutation of an individual */ 63 | void real_mutate_ind (individual *ind, Global global,int *nrealmut) 64 | { 65 | int j; 66 | double rnd, delta1, delta2, mut_pow, deltaq; 67 | double y, yl, yu, val, xy; 68 | for (j=0; jxreal[j]; 73 | yl = global.min_realvar[j]; 74 | yu = global.max_realvar[j]; 75 | delta1 = (y-yl)/(yu-yl); 76 | delta2 = (yu-y)/(yu-yl); 77 | rnd = randomperc(); 78 | mut_pow = 1.0/(global.eta_m+1.0); 79 | if (rnd <= 0.5) 80 | { 81 | xy = 1.0-delta1; 82 | val = 2.0*rnd+(1.0-2.0*rnd)*(pow(xy,(global.eta_m+1.0))); 83 | deltaq = pow(val,mut_pow) - 1.0; 84 | } 85 | else 86 | { 87 | xy = 1.0-delta2; 88 | val = 2.0*(1.0-rnd)+2.0*(rnd-0.5)*(pow(xy,(global.eta_m+1.0))); 89 | deltaq = 1.0 - (pow(val,mut_pow)); 90 | } 91 | y = y + deltaq*(yu-yl); 92 | if (yyu) 95 | y = yu; 96 | ind->xreal[j] = y; 97 | nrealmut+=1; 98 | } 99 | } 100 | return; 101 | } 102 | -------------------------------------------------------------------------------- /pyOpt/pyNSGA2/source/rand.c: -------------------------------------------------------------------------------- 1 | /* Definition of random number generation routines */ 2 | 3 | # include 4 | # include 5 | # include 6 | 7 | # include "nsga2.h" 8 | # include "rand.h" 9 | 10 | double oldrand[55]; 11 | int jrand; 12 | 13 | /* Get seed number for random and start it up */ 14 | void randomize(double seed) 15 | { 16 | int j1; 17 | for(j1=0; j1<=54; j1++) 18 | { 19 | oldrand[j1] = 0.0; 20 | } 21 | jrand=0; 22 | warmup_random (seed); 23 | return; 24 | } 25 | 26 | /* Get randomize off and running */ 27 | void warmup_random (double seed) 28 | { 29 | int j1, ii; 30 | double new_random, prev_random; 31 | oldrand[54] = seed; 32 | new_random = 0.000000001; 33 | prev_random = seed; 34 | for(j1=1; j1<=54; j1++) 35 | { 36 | ii = (21*j1)%54; 37 | oldrand[ii] = new_random; 38 | new_random = prev_random-new_random; 39 | if(new_random<0.0) 40 | { 41 | new_random += 1.0; 42 | } 43 | prev_random = oldrand[ii]; 44 | } 45 | advance_random (); 46 | advance_random (); 47 | advance_random (); 48 | jrand = 0; 49 | return; 50 | } 51 | 52 | /* Create next batch of 55 random numbers */ 53 | void advance_random () 54 | { 55 | int j1; 56 | double new_random; 57 | for(j1=0; j1<24; j1++) 58 | { 59 | new_random = oldrand[j1]-oldrand[j1+31]; 60 | if(new_random<0.0) 61 | { 62 | new_random = new_random+1.0; 63 | } 64 | oldrand[j1] = new_random; 65 | } 66 | for(j1=24; j1<55; j1++) 67 | { 68 | new_random = oldrand[j1]-oldrand[j1-24]; 69 | if(new_random<0.0) 70 | { 71 | new_random = new_random+1.0; 72 | } 73 | oldrand[j1] = new_random; 74 | } 75 | } 76 | 77 | /* Fetch a single random number between 0.0 and 1.0 */ 78 | double randomperc() 79 | { 80 | jrand++; 81 | if(jrand>=55) 82 | { 83 | jrand = 1; 84 | advance_random(); 85 | } 86 | return((double)oldrand[jrand]); 87 | } 88 | 89 | /* Fetch a single random integer between low and high including the bounds */ 90 | int rnd (int low, int high) 91 | { 92 | int res; 93 | if (low >= high) 94 | { 95 | res = low; 96 | } 97 | else 98 | { 99 | res = low + (randomperc()*(high-low+1)); 100 | if (res > high) 101 | { 102 | res = high; 103 | } 104 | } 105 | return (res); 106 | } 107 | 108 | /* Fetch a single random real number between low and high including the bounds */ 109 | double rndreal (double low, double high) 110 | { 111 | return (low + (high-low)*randomperc()); 112 | } 113 | -------------------------------------------------------------------------------- /pyOpt/pyNSGA2/source/rand.h: -------------------------------------------------------------------------------- 1 | /* Declaration for random number related variables and routines */ 2 | 3 | # ifndef _RAND_H_ 4 | # define _RAND_H_ 5 | 6 | /* Variable declarations for the random number generator */ 7 | extern double oldrand[55]; 8 | extern int jrand; 9 | 10 | /* Function declarations for the random number generator */ 11 | void randomize(double seed); 12 | void warmup_random (double seed); 13 | void advance_random (void); 14 | double randomperc(void); 15 | int rnd (int low, int high); 16 | double rndreal (double low, double high); 17 | 18 | # endif 19 | -------------------------------------------------------------------------------- /pyOpt/pyNSGA2/source/report.c: -------------------------------------------------------------------------------- 1 | /* Routines for storing population data into files */ 2 | 3 | # include 4 | # include 5 | # include 6 | 7 | # include "nsga2.h" 8 | # include "rand.h" 9 | 10 | /* Function to print the information of a population in a file */ 11 | void report_pop (population *pop, FILE *fpt, Global global) 12 | { 13 | int i, j, k; 14 | for (i=0; iind[i].obj[j]); 19 | } 20 | if (global.ncon!=0) 21 | { 22 | for (j=0; jind[i].constr[j]); 25 | } 26 | } 27 | if (global.nreal!=0) 28 | { 29 | for (j=0; jind[i].xreal[j]); 32 | } 33 | } 34 | if (global.nbin!=0) 35 | { 36 | for (j=0; jind[i].gene[j][k]); 41 | } 42 | } 43 | } 44 | fprintf(fpt,"%e\t",pop->ind[i].constr_violation); 45 | fprintf(fpt,"%d\t",pop->ind[i].rank); 46 | fprintf(fpt,"%e\n",pop->ind[i].crowd_dist); 47 | } 48 | return; 49 | } 50 | 51 | /* Function to print the information of feasible and non-dominated population in a file */ 52 | void report_feasible (population *pop, FILE *fpt, Global global) 53 | { 54 | int i, j, k; 55 | for (i=0; iind[i].constr_violation == 0.0 && pop->ind[i].rank==1) 58 | { 59 | for (j=0; jind[i].obj[j]); 62 | } 63 | if (global.ncon!=0) 64 | { 65 | for (j=0; jind[i].constr[j]); 68 | } 69 | } 70 | if (global.nreal!=0) 71 | { 72 | for (j=0; jind[i].xreal[j]); 75 | } 76 | } 77 | if (global.nbin!=0) 78 | { 79 | for (j=0; jind[i].gene[j][k]); 84 | } 85 | } 86 | } 87 | fprintf(fpt,"%e\t",pop->ind[i].constr_violation); 88 | fprintf(fpt,"%d\t",pop->ind[i].rank); 89 | fprintf(fpt,"%e\n",pop->ind[i].crowd_dist); 90 | } 91 | } 92 | return; 93 | } 94 | -------------------------------------------------------------------------------- /pyOpt/pyNSGA2/source/sort.c: -------------------------------------------------------------------------------- 1 | /* Routines for randomized recursive quick-sort */ 2 | 3 | # include 4 | # include 5 | # include 6 | 7 | # include "nsga2.h" 8 | # include "rand.h" 9 | 10 | /* Randomized quick sort routine to sort a population based on a particular objective chosen */ 11 | void quicksort_front_obj(population *pop, int objcount, int obj_array[], int obj_array_size) 12 | { 13 | q_sort_front_obj (pop, objcount, obj_array, 0, obj_array_size-1); 14 | return; 15 | } 16 | 17 | /* Actual implementation of the randomized quick sort used to sort a population based on a particular objective chosen */ 18 | void q_sort_front_obj(population *pop, int objcount, int obj_array[], int left, int right) 19 | { 20 | int index; 21 | int temp; 22 | int i, j; 23 | double pivot; 24 | if (leftind[obj_array[right]].obj[objcount]; 31 | i = left-1; 32 | for (j=left; jind[obj_array[j]].obj[objcount] <= pivot) 35 | { 36 | i+=1; 37 | temp = obj_array[j]; 38 | obj_array[j] = obj_array[i]; 39 | obj_array[i] = temp; 40 | } 41 | } 42 | index=i+1; 43 | temp = obj_array[index]; 44 | obj_array[index] = obj_array[right]; 45 | obj_array[right] = temp; 46 | q_sort_front_obj (pop, objcount, obj_array, left, index-1); 47 | q_sort_front_obj (pop, objcount, obj_array, index+1, right); 48 | } 49 | return; 50 | } 51 | 52 | /* Randomized quick sort routine to sort a population based on crowding distance */ 53 | void quicksort_dist(population *pop, int *dist, int front_size) 54 | { 55 | q_sort_dist (pop, dist, 0, front_size-1); 56 | return; 57 | } 58 | 59 | /* Actual implementation of the randomized quick sort used to sort a population based on crowding distance */ 60 | void q_sort_dist(population *pop, int *dist, int left, int right) 61 | { 62 | int index; 63 | int temp; 64 | int i, j; 65 | double pivot; 66 | if (leftind[dist[right]].crowd_dist; 73 | i = left-1; 74 | for (j=left; jind[dist[j]].crowd_dist <= pivot) 77 | { 78 | i+=1; 79 | temp = dist[j]; 80 | dist[j] = dist[i]; 81 | dist[i] = temp; 82 | } 83 | } 84 | index=i+1; 85 | temp = dist[index]; 86 | dist[index] = dist[right]; 87 | dist[right] = temp; 88 | q_sort_dist (pop, dist, left, index-1); 89 | q_sort_dist (pop, dist, index+1, right); 90 | } 91 | return; 92 | } 93 | -------------------------------------------------------------------------------- /pyOpt/pyNSGA2/source/swig/.gitignore: -------------------------------------------------------------------------------- 1 | nsga2_wrap.c 2 | -------------------------------------------------------------------------------- /pyOpt/pyNSGA2/source/swig/README: -------------------------------------------------------------------------------- 1 | This directory contains the swig signature file. 2 | Do not edit these file unless you really know what you are doing. 3 | -------------------------------------------------------------------------------- /pyOpt/pyNSGA2/source/tourselect.c: -------------------------------------------------------------------------------- 1 | /* Tournamenet Selections routines */ 2 | 3 | # include 4 | # include 5 | # include 6 | 7 | # include "nsga2.h" 8 | # include "rand.h" 9 | 10 | /* Routine for tournament selection, it creates a new_pop from old_pop by performing tournament selection and the crossover */ 11 | void selection (population *old_pop, population *new_pop, Global global, int *nrealcross, int *nbincross) 12 | { 13 | int *a1, *a2; 14 | int temp; 15 | int i; 16 | int rand; 17 | individual *parent1, *parent2; 18 | a1 = (int *)malloc(global.popsize*sizeof(int)); 19 | a2 = (int *)malloc(global.popsize*sizeof(int)); 20 | for (i=0; iind[a1[i]], &old_pop->ind[a1[i+1]], global); 38 | parent2 = tournament (&old_pop->ind[a1[i+2]], &old_pop->ind[a1[i+3]], global); 39 | crossover (parent1, parent2, &new_pop->ind[i], &new_pop->ind[i+1], global, nrealcross, nbincross); 40 | parent1 = tournament (&old_pop->ind[a2[i]], &old_pop->ind[a2[i+1]], global); 41 | parent2 = tournament (&old_pop->ind[a2[i+2]], &old_pop->ind[a2[i+3]], global); 42 | crossover (parent1, parent2, &new_pop->ind[i+2], &new_pop->ind[i+3], global, nrealcross, nbincross); 43 | } 44 | free (a1); 45 | free (a2); 46 | return; 47 | } 48 | 49 | /* Routine for binary tournament */ 50 | individual* tournament (individual *ind1, individual *ind2, Global global) 51 | { 52 | int flag; 53 | flag = check_dominance (ind1, ind2, global); 54 | if (flag==1) 55 | { 56 | return (ind1); 57 | } 58 | if (flag==-1) 59 | { 60 | return (ind2); 61 | } 62 | if (ind1->crowd_dist > ind2->crowd_dist) 63 | { 64 | return(ind1); 65 | } 66 | if (ind2->crowd_dist > ind1->crowd_dist) 67 | { 68 | return(ind2); 69 | } 70 | if ((randomperc()) <= 0.5) 71 | { 72 | return(ind1); 73 | } 74 | else 75 | { 76 | return(ind2); 77 | } 78 | } 79 | -------------------------------------------------------------------------------- /pyOpt/pyPSQP/README: -------------------------------------------------------------------------------- 1 | This directory contains the psqp class definition 2 | and the psqp shared library, psqp.so or psqp.pyd. 3 | -------------------------------------------------------------------------------- /pyOpt/pyPSQP/__init__.py: -------------------------------------------------------------------------------- 1 | try: 2 | from .pyPSQP import PSQP 3 | __all__ = ['PSQP'] 4 | except: 5 | __all__ = [] 6 | -------------------------------------------------------------------------------- /pyOpt/pyPSQP/setup.py: -------------------------------------------------------------------------------- 1 | import os 2 | 3 | 4 | def configuration(parent_package='', top_path=None): 5 | from numpy.distutils.misc_util import Configuration 6 | 7 | config = Configuration('pyPSQP', parent_package, top_path) 8 | config.add_library('psqp', 9 | sources=[os.path.join('source', '*.f')], 10 | ) 11 | config.add_extension('psqp', 12 | sources=['source/f2py/psqp.pyf'], 13 | libraries=['psqp'], 14 | ) 15 | config.add_data_files('LICENSE', 'README') 16 | 17 | return config 18 | 19 | 20 | if __name__ == '__main__': 21 | from numpy.distutils.core import setup 22 | 23 | setup(**configuration(top_path='').todict()) 24 | -------------------------------------------------------------------------------- /pyOpt/pyPSQP/source/README: -------------------------------------------------------------------------------- 1 | This directory contains the Fortran 77 source for 2 | PSQP, plus a pyOpt interfacing file called psqpw.f, 3 | and two helper files called openunit.f and 4 | closeunit.f to manipulate Fortran units from Python. 5 | -------------------------------------------------------------------------------- /pyOpt/pyPSQP/source/closeunit.f: -------------------------------------------------------------------------------- 1 | C Helper subroutine to close files in the Fortran world 2 | subroutine closeunit(unitnum) 3 | 4 | integer unitnum 5 | Cf2py intent(in) unitnum 6 | 7 | close(unitnum) 8 | 9 | return 10 | end 11 | -------------------------------------------------------------------------------- /pyOpt/pyPSQP/source/f2py/README: -------------------------------------------------------------------------------- 1 | This directory contains the f2py signature file. 2 | Do not edit these file unless you really know what you are doing. 3 | -------------------------------------------------------------------------------- /pyOpt/pyPSQP/source/openunit.f: -------------------------------------------------------------------------------- 1 | C Helper subroutine to open files in the Fortran world 2 | subroutine openunit(unitnum,filename,filestatus,fileaction,ierror) 3 | 4 | integer unitnum 5 | Cf2py intent(in) unitnum 6 | character*(*) filename 7 | Cf2py intent(in) filename 8 | character*(*) filestatus 9 | Cf2py intent(in) filestatus 10 | character*(*) fileaction 11 | Cf2py intent(in) fileaction 12 | integer ierror 13 | Cf2py intent(out) ierror 14 | 15 | open(unit=unitnum,file=filename,status=filestatus, 16 | > access=fileaction,iostat=ierror) 17 | 18 | return 19 | end 20 | 21 | C Helper routine to flush buffers to files 22 | subroutine pyflush(unitnum) 23 | 24 | integer unitnum 25 | 26 | call flush(unitnum) 27 | 28 | return 29 | end 30 | -------------------------------------------------------------------------------- /pyOpt/pySDPEN/README: -------------------------------------------------------------------------------- 1 | This directory contains the sdpen class definition 2 | and the sdpen shared library, sdpen.so or sdpen.pyd. 3 | -------------------------------------------------------------------------------- /pyOpt/pySDPEN/__init__.py: -------------------------------------------------------------------------------- 1 | try: 2 | from .pySDPEN import SDPEN 3 | __all__ = ['SDPEN'] 4 | except: 5 | __all__ = [] 6 | -------------------------------------------------------------------------------- /pyOpt/pySDPEN/setup.py: -------------------------------------------------------------------------------- 1 | import os 2 | 3 | 4 | def configuration(parent_package='', top_path=None): 5 | from numpy.distutils.misc_util import Configuration 6 | 7 | config = Configuration('pySDPEN', parent_package, top_path) 8 | config.add_library('sdpen', 9 | sources=[os.path.join('source', '*.f90')]) 10 | config.add_extension('sdpen', 11 | sources=['source/f2py/sdpen.pyf'], 12 | libraries=['sdpen']) 13 | config.add_data_files('LICENSE', 'README') 14 | 15 | return config 16 | 17 | 18 | if __name__ == '__main__': 19 | from numpy.distutils.core import setup 20 | 21 | setup(**configuration(top_path='').todict()) 22 | -------------------------------------------------------------------------------- /pyOpt/pySDPEN/source/README: -------------------------------------------------------------------------------- 1 | This directory contains the Fortran 90 source of 2 | SDPEN extended to work with pyOpt, plus two helper 3 | files called openunit.f90 and closeunit.f90 to 4 | manipulate Fortran units from Python. 5 | -------------------------------------------------------------------------------- /pyOpt/pySDPEN/source/closeunit.f90: -------------------------------------------------------------------------------- 1 | subroutine closeunit(unitnum) 2 | 3 | implicit none 4 | 5 | integer unitnum 6 | 7 | close(unitnum) 8 | 9 | return 10 | end 11 | -------------------------------------------------------------------------------- /pyOpt/pySDPEN/source/f2py/README: -------------------------------------------------------------------------------- 1 | This directory contains the f2py signature file. 2 | Do not edit these file unless you really know what you are doing. 3 | -------------------------------------------------------------------------------- /pyOpt/pySDPEN/source/funct.f90: -------------------------------------------------------------------------------- 1 | subroutine funct(n,m,x,eps,f) 2 | 3 | implicit none 4 | 5 | integer n,m,i 6 | real*8 x(n),f,fob,fmax 7 | real*8 constr(m), eps(m) 8 | 9 | call fobcon(n,m,x,fob,constr) 10 | 11 | fmax = 0.d0 12 | 13 | do i = 1,m 14 | fmax = fmax + (max(0.d0,constr(i))**1.1d0)/eps(i) 15 | enddo 16 | 17 | f = fob + fmax 18 | 19 | return 20 | end 21 | -------------------------------------------------------------------------------- /pyOpt/pySDPEN/source/openunit.f90: -------------------------------------------------------------------------------- 1 | subroutine openunit(unitnum,filename,filestatus,fileaction,ierror) 2 | 3 | implicit none 4 | 5 | integer unitnum 6 | character*(*) filename 7 | character*(*) filestatus 8 | character*(*) fileaction 9 | integer ierror 10 | 11 | open(unit=unitnum,file=filename,status=filestatus,& 12 | access=fileaction,iostat=ierror) 13 | 14 | return 15 | end 16 | 17 | 18 | subroutine pyflush(unitnum) 19 | 20 | implicit none 21 | 22 | integer unitnum 23 | 24 | call flush(unitnum) 25 | 26 | return 27 | end 28 | -------------------------------------------------------------------------------- /pyOpt/pySDPEN/source/stop.f90: -------------------------------------------------------------------------------- 1 | subroutine stop(n,alfa_d,istop,alfa_max,nf,& 2 | ni,fstop,f,alfa_stop,nf_max) 3 | 4 | implicit none 5 | 6 | integer :: n,istop,i,nf,ni,nf_max 7 | real*8 :: alfa_d(n),alfa_max,fstop(n+1),ffstop,ffm,f,alfa_stop 8 | 9 | istop=0 10 | 11 | alfa_max=alfa_d(1) 12 | do i=1,n 13 | if(alfa_d(i).gt.alfa_max) then 14 | alfa_max=alfa_d(i) 15 | end if 16 | end do 17 | 18 | if(ni.ge.(n+1)) then 19 | ffm=f 20 | do i=1,n 21 | ffm=ffm+fstop(i) 22 | enddo 23 | ffm=ffm/dfloat((n+1)) 24 | 25 | ffstop=(f-ffm)*(f-ffm) 26 | do i=1,n 27 | ffstop=ffstop+(fstop(i)-ffm)*(fstop(i)-ffm) 28 | enddo 29 | 30 | ffstop=dsqrt(ffstop/dfloat(n+1)) 31 | 32 | ! if(ffstop.le.alfa_stop) then 33 | ! istop = 1 34 | ! end if 35 | 36 | endif 37 | 38 | if(alfa_max.le.alfa_stop) then 39 | istop = 1 40 | end if 41 | 42 | if(nf.gt.nf_max) then 43 | istop = 2 44 | end if 45 | 46 | return 47 | end 48 | -------------------------------------------------------------------------------- /pyOpt/pySLSQP/LICENSE: -------------------------------------------------------------------------------- 1 | SLSQP - Sequential Least Squares Programming 2 | Copyright (c) 1988, Dieter Kraft (kraft@hm.edu) 3 | Copyright (c) 1994, Association for Computing Machinery 4 | Patched for pyOpt - 2008, Ruben E. Perez (Ruben.Perez@rmc.ca) 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining a 7 | copy of this software and associated documentation files (the 8 | "Software"), to deal in the Software without restriction, including 9 | without limitation the rights to use, copy, modify, merge, publish, 10 | distribute, sublicense, and/or sell copies of the Software, and to 11 | permit persons to whom the Software is furnished to do so, subject to 12 | the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be included 15 | in all copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 18 | OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 19 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 20 | IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 21 | CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 22 | TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 23 | SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 24 | -------------------------------------------------------------------------------- /pyOpt/pySLSQP/README: -------------------------------------------------------------------------------- 1 | This directory contains the slsqp class definition 2 | and the slsqp shared library, slsqp.so or slsqp.pyd. 3 | -------------------------------------------------------------------------------- /pyOpt/pySLSQP/__init__.py: -------------------------------------------------------------------------------- 1 | try: 2 | from .pySLSQP import SLSQP 3 | __all__ = ['SLSQP'] 4 | except: 5 | __all__ = [] 6 | -------------------------------------------------------------------------------- /pyOpt/pySLSQP/setup.py: -------------------------------------------------------------------------------- 1 | import os 2 | 3 | 4 | def configuration(parent_package='', top_path=None): 5 | from numpy.distutils.misc_util import Configuration 6 | 7 | config = Configuration('pySLSQP', parent_package, top_path) 8 | config.add_library('slsqp', 9 | sources=[os.path.join('source', '*.f')]) 10 | config.add_extension('slsqp', 11 | sources=['source/f2py/slsqp.pyf'], 12 | libraries=['slsqp']) 13 | config.add_data_files('LICENSE', 'README') 14 | 15 | return config 16 | 17 | 18 | if __name__ == '__main__': 19 | from numpy.distutils.core import setup 20 | 21 | setup(**configuration(top_path='').todict()) 22 | -------------------------------------------------------------------------------- /pyOpt/pySLSQP/source/README: -------------------------------------------------------------------------------- 1 | This directory contains the Fortran 77 source for 2 | SLSQP, plus two helper files called openunit.f and 3 | closeunit.f to manipulate Fortran units from Python. 4 | -------------------------------------------------------------------------------- /pyOpt/pySLSQP/source/closeunit.f: -------------------------------------------------------------------------------- 1 | C Helper subroutine to close files in the Fortran world 2 | subroutine closeunit(unitnum) 3 | 4 | integer unitnum 5 | Cf2py intent(in) unitnum 6 | 7 | close(unitnum) 8 | 9 | return 10 | end 11 | -------------------------------------------------------------------------------- /pyOpt/pySLSQP/source/daxpy.f: -------------------------------------------------------------------------------- 1 | SUBROUTINE DAXPY(N,DA,DX,INCX,DY,INCY) 2 | 3 | C CONSTANT TIMES A VECTOR PLUS A VECTOR. 4 | C USES UNROLLED LOOPS FOR INCREMENTS EQUAL TO ONE. 5 | C JACK DONGARRA, LINPACK, 3/11/78. 6 | 7 | DOUBLE PRECISION DX(*),DY(*),DA 8 | INTEGER I,INCX,INCY,IX,IY,M,MP1,N 9 | 10 | IF(N.LE.0)RETURN 11 | IF(DA.EQ.0.0D0)RETURN 12 | IF(INCX.EQ.1.AND.INCY.EQ.1)GO TO 20 13 | 14 | C CODE FOR UNEQUAL INCREMENTS OR EQUAL INCREMENTS 15 | C NOT EQUAL TO 1 16 | 17 | IX = 1 18 | IY = 1 19 | IF(INCX.LT.0)IX = (-N+1)*INCX + 1 20 | IF(INCY.LT.0)IY = (-N+1)*INCY + 1 21 | DO 10 I = 1,N 22 | DY(IY) = DY(IY) + DA*DX(IX) 23 | IX = IX + INCX 24 | IY = IY + INCY 25 | 10 CONTINUE 26 | RETURN 27 | 28 | C CODE FOR BOTH INCREMENTS EQUAL TO 1 29 | 30 | C CLEAN-UP LOOP 31 | 32 | 20 M = MOD(N,4) 33 | IF( M .EQ. 0 ) GO TO 40 34 | DO 30 I = 1,M 35 | DY(I) = DY(I) + DA*DX(I) 36 | 30 CONTINUE 37 | IF( N .LT. 4 ) RETURN 38 | 40 MP1 = M + 1 39 | DO 50 I = MP1,N,4 40 | DY(I) = DY(I) + DA*DX(I) 41 | DY(I + 1) = DY(I + 1) + DA*DX(I + 1) 42 | DY(I + 2) = DY(I + 2) + DA*DX(I + 2) 43 | DY(I + 3) = DY(I + 3) + DA*DX(I + 3) 44 | 50 CONTINUE 45 | RETURN 46 | END 47 | -------------------------------------------------------------------------------- /pyOpt/pySLSQP/source/drot.f: -------------------------------------------------------------------------------- 1 | SUBROUTINE DROT (N,DX,INCX,DY,INCY,C,S) 2 | 3 | C APPLIES A PLANE ROTATION. 4 | C JACK DONGARRA, LINPACK, 3/11/78. 5 | 6 | DOUBLE PRECISION DX(*),DY(*),DTEMP,C,S 7 | INTEGER I,INCX,INCY,IX,IY,N 8 | 9 | IF(N.LE.0)RETURN 10 | IF(INCX.EQ.1.AND.INCY.EQ.1)GO TO 20 11 | 12 | C CODE FOR UNEQUAL INCREMENTS OR EQUAL INCREMENTS NOT EQUAL 13 | C TO 1 14 | 15 | IX = 1 16 | IY = 1 17 | IF(INCX.LT.0)IX = (-N+1)*INCX + 1 18 | IF(INCY.LT.0)IY = (-N+1)*INCY + 1 19 | DO 10 I = 1,N 20 | DTEMP = C*DX(IX) + S*DY(IY) 21 | DY(IY) = C*DY(IY) - S*DX(IX) 22 | DX(IX) = DTEMP 23 | IX = IX + INCX 24 | IY = IY + INCY 25 | 10 CONTINUE 26 | RETURN 27 | 28 | C CODE FOR BOTH INCREMENTS EQUAL TO 1 29 | 30 | 20 DO 30 I = 1,N 31 | DTEMP = C*DX(I) + S*DY(I) 32 | DY(I) = C*DY(I) - S*DX(I) 33 | DX(I) = DTEMP 34 | 30 CONTINUE 35 | RETURN 36 | END 37 | -------------------------------------------------------------------------------- /pyOpt/pySLSQP/source/drotg.f: -------------------------------------------------------------------------------- 1 | SUBROUTINE DROTG(DA,DB,C,S) 2 | 3 | C CONSTRUCT GIVENS PLANE ROTATION. 4 | C JACK DONGARRA, LINPACK, 3/11/78. 5 | C MODIFIED 9/27/86. 6 | 7 | DOUBLE PRECISION DA,DB,C,S,ROE,SCALE,R,Z,ONE,ZERO 8 | DATA ONE, ZERO /1.0D+00, 0.0D+00/ 9 | 10 | ROE = DB 11 | IF( ABS(DA) .GT. ABS(DB) ) ROE = DA 12 | SCALE = ABS(DA) + ABS(DB) 13 | IF( SCALE .NE. ZERO ) GO TO 10 14 | C = ONE 15 | S = ZERO 16 | R = ZERO 17 | GO TO 20 18 | 10 R = SCALE*SQRT((DA/SCALE)**2 + (DB/SCALE)**2) 19 | R = SIGN(ONE,ROE)*R 20 | C = DA/R 21 | S = DB/R 22 | 20 Z = S 23 | IF( ABS(C) .GT. ZERO .AND. ABS(C) .LE. S ) Z = ONE/C 24 | DA = R 25 | DB = Z 26 | RETURN 27 | END 28 | -------------------------------------------------------------------------------- /pyOpt/pySLSQP/source/dscal.f: -------------------------------------------------------------------------------- 1 | SUBROUTINE DSCAL(N,DA,DX,INCX) 2 | 3 | C SCALES A VECTOR BY A CONSTANT. 4 | C USES UNROLLED LOOPS FOR INCREMENT EQUAL TO ONE. 5 | C JACK DONGARRA, LINPACK, 3/11/78. 6 | 7 | DOUBLE PRECISION DA,DX(*) 8 | INTEGER I,INCX,M,MP1,N,NINCX 9 | 10 | IF(N.LE.0)RETURN 11 | IF(INCX.EQ.1)GO TO 20 12 | 13 | C CODE FOR INCREMENT NOT EQUAL TO 1 14 | 15 | NINCX = N*INCX 16 | DO 10 I = 1,NINCX,INCX 17 | DX(I) = DA*DX(I) 18 | 10 CONTINUE 19 | RETURN 20 | 21 | C CODE FOR INCREMENT EQUAL TO 1 22 | 23 | C CLEAN-UP LOOP 24 | 25 | 20 M = MOD(N,5) 26 | IF( M .EQ. 0 ) GO TO 40 27 | DO 30 I = 1,M 28 | DX(I) = DA*DX(I) 29 | 30 CONTINUE 30 | IF( N .LT. 5 ) RETURN 31 | 40 MP1 = M + 1 32 | DO 50 I = MP1,N,5 33 | DX(I) = DA*DX(I) 34 | DX(I + 1) = DA*DX(I + 1) 35 | DX(I + 2) = DA*DX(I + 2) 36 | DX(I + 3) = DA*DX(I + 3) 37 | DX(I + 4) = DA*DX(I + 4) 38 | 50 CONTINUE 39 | RETURN 40 | END 41 | -------------------------------------------------------------------------------- /pyOpt/pySLSQP/source/f2py/README: -------------------------------------------------------------------------------- 1 | This directory contains the f2py signature file. 2 | Do not edit these file unless you really know what you are doing. 3 | -------------------------------------------------------------------------------- /pyOpt/pySLSQP/source/lsi.f: -------------------------------------------------------------------------------- 1 | SUBROUTINE LSI(E,F,G,H,LE,ME,LG,MG,N,X,XNORM,W,JW,MODE) 2 | 3 | C FOR MODE=1, THE SUBROUTINE RETURNS THE SOLUTION X OF 4 | C INEQUALITY CONSTRAINED LINEAR LEAST SQUARES PROBLEM: 5 | 6 | C MIN ||E*X-F|| 7 | C X 8 | 9 | C S.T. G*X >= H 10 | 11 | C THE ALGORITHM IS BASED ON QR DECOMPOSITION AS DESCRIBED IN 12 | C CHAPTER 23.5 OF LAWSON & HANSON: SOLVING LEAST SQUARES PROBLEMS 13 | 14 | C THE FOLLOWING DIMENSIONS OF THE ARRAYS DEFINING THE PROBLEM 15 | C ARE NECESSARY 16 | C DIM(E) : FORMAL (LE,N), ACTUAL (ME,N) 17 | C DIM(F) : FORMAL (LE ), ACTUAL (ME ) 18 | C DIM(G) : FORMAL (LG,N), ACTUAL (MG,N) 19 | C DIM(H) : FORMAL (LG ), ACTUAL (MG ) 20 | C DIM(X) : N 21 | C DIM(W) : (N+1)*(MG+2) + 2*MG 22 | C DIM(JW): LG 23 | C ON ENTRY, THE USER HAS TO PROVIDE THE ARRAYS E, F, G, AND H. 24 | C ON RETURN, ALL ARRAYS WILL BE CHANGED BY THE SUBROUTINE. 25 | C X STORES THE SOLUTION VECTOR 26 | C XNORM STORES THE RESIDUUM OF THE SOLUTION IN EUCLIDIAN NORM 27 | C W STORES THE VECTOR OF LAGRANGE MULTIPLIERS IN ITS FIRST 28 | C MG ELEMENTS 29 | C MODE IS A SUCCESS-FAILURE FLAG WITH THE FOLLOWING MEANINGS: 30 | C MODE=1: SUCCESSFUL COMPUTATION 31 | C 2: ERROR RETURN BECAUSE OF WRONG DIMENSIONS (N<1) 32 | C 3: ITERATION COUNT EXCEEDED BY NNLS 33 | C 4: INEQUALITY CONSTRAINTS INCOMPATIBLE 34 | C 5: MATRIX E IS NOT OF FULL RANK 35 | 36 | C 03.01.1980, DIETER KRAFT: CODED 37 | C 20.03.1987, DIETER KRAFT: REVISED TO FORTRAN 77 38 | 39 | INTEGER I,J,LE,LG,ME,MG,MODE,N,JW(LG) 40 | DOUBLE PRECISION E(LE,N),F(LE),G(LG,N),H(LG),X(N),W(*), 41 | . DDOT,XNORM,DNRM2,EPMACH,T,ONE 42 | DATA EPMACH/2.22D-16/,ONE/1.0D+00/ 43 | 44 | C QR-FACTORS OF E AND APPLICATION TO F 45 | 46 | DO 10 I=1,N 47 | J=MIN(I+1,N) 48 | CALL H12(1,I,I+1,ME,E(1,I),1,T,E(1,J),1,LE,N-I) 49 | 10 CALL H12(2,I,I+1,ME,E(1,I),1,T,F ,1,1 ,1 ) 50 | 51 | C TRANSFORM G AND H TO GET LEAST DISTANCE PROBLEM 52 | 53 | MODE=5 54 | DO 30 I=1,MG 55 | DO 20 J=1,N 56 | IF (ABS(E(J,J)).LT.EPMACH) GOTO 50 57 | 20 G(I,J)=(G(I,J)-DDOT(J-1,G(I,1),LG,E(1,J),1))/E(J,J) 58 | 30 H(I)=H(I)-DDOT(N,G(I,1),LG,F,1) 59 | 60 | C SOLVE LEAST DISTANCE PROBLEM 61 | 62 | CALL LDP(G,LG,MG,N,H,X,XNORM,W,JW,MODE) 63 | IF (MODE.NE.1) GOTO 50 64 | 65 | C SOLUTION OF ORIGINAL PROBLEM 66 | 67 | CALL DAXPY(N,ONE,F,1,X,1) 68 | DO 40 I=N,1,-1 69 | J=MIN(I+1,N) 70 | 40 X(I)=(X(I)-DDOT(N-I,E(I,J),LE,X(J),1))/E(I,I) 71 | J=MIN(N+1,ME) 72 | T=DNRM2(ME-N,F(J),1) 73 | XNORM=SQRT(XNORM*XNORM+T*T) 74 | 75 | C END OF SUBROUTINE LSI 76 | 77 | 50 END 78 | -------------------------------------------------------------------------------- /pyOpt/pySLSQP/source/openunit.f: -------------------------------------------------------------------------------- 1 | C Helper subroutine to open files in the Fortran world 2 | subroutine openunit(unitnum,filename,filestatus,fileaction,ierror) 3 | 4 | integer unitnum 5 | Cf2py intent(in) unitnum 6 | character*(*) filename 7 | Cf2py intent(in) filename 8 | character*(*) filestatus 9 | Cf2py intent(in) filestatus 10 | character*(*) fileaction 11 | Cf2py intent(in) fileaction 12 | integer ierror 13 | Cf2py intent(out) ierror 14 | 15 | open(unit=unitnum,file=filename,status=filestatus, 16 | > access=fileaction,iostat=ierror) 17 | 18 | return 19 | end 20 | 21 | C Helper routine to flush buffers to files 22 | subroutine pyflush(unitnum) 23 | 24 | integer unitnum 25 | 26 | call flush(unitnum) 27 | 28 | return 29 | end 30 | -------------------------------------------------------------------------------- /pyOpt/pySNOPT/LICENSE: -------------------------------------------------------------------------------- 1 | SNOPT - Sparse NOlinear OPTimizer 2 | Copyright (c) 2008, Philip Gill (pgill@ucsd.edu), 3 | Walter Murray (walter@leland.stanford.edu), 4 | and Michael Saunders (saunders@stanford.edu) 5 | 6 | SNOPT is a licensed software, to obtain the program sources and for 7 | term and conditions of use please refer to the specific commercial 8 | or academic agreement with Stanford Business Software Inc. 9 | -------------------------------------------------------------------------------- /pyOpt/pySNOPT/README: -------------------------------------------------------------------------------- 1 | This directory contains the snopt class definition 2 | and the snopt shared library, snopt.so or snopt.pyd. 3 | -------------------------------------------------------------------------------- /pyOpt/pySNOPT/__init__.py: -------------------------------------------------------------------------------- 1 | try: 2 | from .pySNOPT import SNOPT 3 | __all__ = ['SNOPT'] 4 | except: 5 | __all__ = [] 6 | -------------------------------------------------------------------------------- /pyOpt/pySNOPT/setup.py: -------------------------------------------------------------------------------- 1 | import os 2 | 3 | 4 | def configuration(parent_package='', top_path=None): 5 | from numpy.distutils.misc_util import Configuration 6 | 7 | config = Configuration('pySNOPT', parent_package, top_path) 8 | config.add_library('snopt', 9 | sources=[os.path.join('source', '*.f')]) 10 | config.add_extension('snopt', 11 | sources=['source/f2py/snopt.pyf'], 12 | libraries=['snopt']) 13 | config.add_data_files('LICENSE', 'README') 14 | 15 | return config 16 | 17 | 18 | if __name__ == '__main__': 19 | from numpy.distutils.core import setup 20 | 21 | setup(**configuration(top_path='').todict()) 22 | -------------------------------------------------------------------------------- /pyOpt/pySNOPT/source/README: -------------------------------------------------------------------------------- 1 | This directory contains the Fortran 77 source for 2 | SNOPT, plus two helper files called openunit.f and 3 | closeunit.f to manipulate Fortran units from Python. 4 | -------------------------------------------------------------------------------- /pyOpt/pySNOPT/source/closeunit.f: -------------------------------------------------------------------------------- 1 | C Helper subroutine to close files in the Fortran world 2 | subroutine closeunit(unitnum) 3 | 4 | integer unitnum 5 | Cf2py intent(in) unitnum 6 | 7 | close(unitnum) 8 | 9 | return 10 | end 11 | -------------------------------------------------------------------------------- /pyOpt/pySNOPT/source/f2py/README: -------------------------------------------------------------------------------- 1 | This directory contains the f2py signature file. 2 | Do not edit these file unless you really know what you are doing. 3 | -------------------------------------------------------------------------------- /pyOpt/pySNOPT/source/openunit.f: -------------------------------------------------------------------------------- 1 | C Helper subroutine to open files in the Fortran world 2 | subroutine openunit(unitnum,filename,filestatus,fileaction,ierror) 3 | 4 | integer unitnum 5 | Cf2py intent(in) unitnum 6 | character*(*) filename 7 | Cf2py intent(in) filename 8 | character*(*) filestatus 9 | Cf2py intent(in) filestatus 10 | character*(*) fileaction 11 | Cf2py intent(in) fileaction 12 | integer ierror 13 | Cf2py intent(out) ierror 14 | 15 | open(unit=unitnum,file=filename,status=filestatus, 16 | > access=fileaction,iostat=ierror) 17 | 18 | return 19 | end 20 | 21 | C Helper routine to flush buffers to files 22 | subroutine pyflush(unitnum) 23 | 24 | integer unitnum 25 | 26 | call flush(unitnum) 27 | 28 | return 29 | end 30 | -------------------------------------------------------------------------------- /pyOpt/pySOLVOPT/LICENSE: -------------------------------------------------------------------------------- 1 | SOLVOPT - SOLver for local OPTimization problems 2 | Copyright (c) 1997, Alexei V. Kuntsevich (alex@bedvgm.kfunigraz.ac.at), 3 | and Franz Kappel (franz.kappel@kfunigraz.ac.at) 4 | Patched for pyOpt - 2009, Ruben E. Perez (Ruben.Perez@rmc.ca) 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining a 7 | copy of this software and associated documentation files (the 8 | "Software"), to deal in the Software without restriction, including 9 | without limitation the rights to use, copy, modify, merge, publish, 10 | distribute, sublicense, and/or sell copies of the Software, and to 11 | permit persons to whom the Software is furnished to do so, subject to 12 | the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be included 15 | in all copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 18 | OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 19 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 20 | IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 21 | CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 22 | TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 23 | SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 24 | -------------------------------------------------------------------------------- /pyOpt/pySOLVOPT/README: -------------------------------------------------------------------------------- 1 | This directory contains the solvopt class definition 2 | and the solvopt shared libraries, solvopt.so or solvopt.pyd. 3 | -------------------------------------------------------------------------------- /pyOpt/pySOLVOPT/__init__.py: -------------------------------------------------------------------------------- 1 | try: 2 | from .pySOLVOPT import SOLVOPT 3 | __all__ = ['SOLVOPT'] 4 | except: 5 | __all__ = [] 6 | -------------------------------------------------------------------------------- /pyOpt/pySOLVOPT/setup.py: -------------------------------------------------------------------------------- 1 | import os 2 | 3 | 4 | def configuration(parent_package='', top_path=None): 5 | from numpy.distutils.misc_util import Configuration 6 | 7 | config = Configuration('pySOLVOPT', parent_package, top_path) 8 | config.add_library('solvopt', 9 | sources=[os.path.join('source', '*.f')], 10 | include_dirs=['source']) 11 | config.add_extension('solvopt', 12 | sources=['source/f2py/solvopt.pyf'], 13 | libraries=['solvopt']) 14 | config.add_data_files('LICENSE', 'README') 15 | 16 | return config 17 | 18 | 19 | if __name__ == '__main__': 20 | from numpy.distutils.core import setup 21 | 22 | setup(**configuration(top_path='').todict()) 23 | -------------------------------------------------------------------------------- /pyOpt/pySOLVOPT/source/README: -------------------------------------------------------------------------------- 1 | This directory contains the Fortran 90 source for 2 | SOLVOPT, plus two helper files called openunit.f and 3 | closeunit.f to manipulate Fortran units from Python. 4 | -------------------------------------------------------------------------------- /pyOpt/pySOLVOPT/source/apprgrdn.f: -------------------------------------------------------------------------------- 1 | subroutine apprgrdn(n,g,x,f,fun,deltax,obj) 2 | c Subroutine APPRGRDN performs the finite difference approximation 3 | c of the gradient at a point . 4 | c f is the calculated function value at a point , 5 | c is the name of a subroutine that calculates function values, 6 | c deltax is an array of the relative stepsizes. 7 | c obj is the flag indicating whether the gradient of the objective 8 | c function (1) or the constraint function (0) is to be calculated. 9 | c 10 | implicit none 11 | double precision x(*), g(*), f, deltax(*) 12 | double precision lowbndobj,lowbndcnt,d,y,fi,one,ten,half 13 | integer n, i, j 14 | logical center,obj 15 | external fun 16 | data lowbndobj /2.d-10/, lowbndcnt /5.d-15/ 17 | data one /1.d0/, ten /1.d1/, half /.5d0/ 18 | do i=1,n 19 | y=x(i) 20 | d=dmax1(lowbndcnt,dabs(y)) 21 | d=deltax(i)*d 22 | if (obj) then 23 | if (dabs(d).lt.lowbndobj) then 24 | d=lowbndobj*dsign(one,deltax(i)) 25 | center=.true. 26 | else 27 | center=.false. 28 | endif 29 | else 30 | if (dabs(d).lt.lowbndcnt) then 31 | d=lowbndcnt*dsign(one,deltax(i)) 32 | endif 33 | endif 34 | x(i)=y+d 35 | call fun(x,fi) 36 | if (obj) then 37 | if (fi.eq.f) then 38 | do j=1,3 39 | d=d*ten 40 | x(i)=y+d 41 | call fun(x,fi) 42 | if (fi.ne.f) exit 43 | enddo 44 | endif 45 | endif 46 | g(i)=(fi-f)/d 47 | if (obj) then 48 | if (center) then 49 | x(i)=y-d 50 | call fun(x,fi) 51 | g(i)=half*(g(i)+(f-fi)/d) 52 | endif 53 | endif 54 | x(i)=y 55 | enddo 56 | end 57 | -------------------------------------------------------------------------------- /pyOpt/pySOLVOPT/source/closeunit.f: -------------------------------------------------------------------------------- 1 | C Helper subroutine to close files in the Fortran world 2 | subroutine closeunit(unitnum) 3 | 4 | integer unitnum 5 | Cf2py intent(in) unitnum 6 | 7 | close(unitnum) 8 | 9 | return 10 | end 11 | -------------------------------------------------------------------------------- /pyOpt/pySOLVOPT/source/f2py/README: -------------------------------------------------------------------------------- 1 | This directory contains the f2py signature file. 2 | Do not edit these file unless you really know what you are doing. 3 | -------------------------------------------------------------------------------- /pyOpt/pySOLVOPT/source/messages.inc: -------------------------------------------------------------------------------- 1 | c This is an include file to compile with solvopt.f(or) 2 | character*(*) errmes,wrnmes,error2,error32,error42,error43 3 | character*(*) error52,error62,error63,error5,error6 4 | character*(*) warn1,warn20,warn21,warn4,warn31,warn32 5 | character*(*) warn09,warn08,termwarn0,termwarn1,appwarn 6 | character*(*) endwarn1, endwarn2, endwarn3, endwarn4 7 | parameter (errmes='SolvOpt error:') 8 | parameter (wrnmes='SolvOpt warning:') 9 | parameter (error2='Improper space dimension.') 10 | parameter (error32='Function equals infinity at the point.') 11 | parameter ( 12 | * error42='Gradient equals infinity at the starting point.', 13 | * error43='Gradient equals zero at the starting point.') 14 | parameter ( 15 | * error52=' returns infinite value at the point.', 16 | * error62=' returns infinite vector at the point.', 17 | * error63=' returns zero vector at an infeasible point.') 18 | parameter ( 19 | * error5='Function is unbounded.', 20 | * error6='Choose another starting point.') 21 | parameter (warn1= 22 | * 'Gradient is zero, but stopping criteria are not fulfilled.', 23 | * warn20='Normal re-setting of a transformation matrix.', 24 | * warn21= 25 | * 'Re-setting due to the use of a new penalty coefficient.') 26 | parameter ( 27 | * warn4='Iterations limit exceeded.', 28 | * warn31='The function is flat in certain directions.', 29 | * warn32='Trying to recover by shifting insensitive variables.', 30 | * warn09='Re-run from recorded point.', 31 | * warn08='Ravine with a flat bottom is detected.') 32 | parameter ( 33 | * termwarn0='SolvOpt: Normal termination.', 34 | * termwarn1='SolvOpt: Termination warning:', 35 | * appwarn='The above warning may be reasoned'// 36 | * ' by inaccurate gradient approximation', 37 | * endwarn1='Premature stop is possible.'// 38 | * ' Try to re-run the routine from the obtained point.', 39 | * endwarn2='Result may not provide the optimum.'// 40 | * ' The function apparently has many extremum points.', 41 | * endwarn3='Result may be inaccurate in the coordinates.'// 42 | * ' The function is flat at the solution.', 43 | * endwarn4='Stopping criteria are not fulfilled.'// 44 | * ' The function is very steep at the solution.') 45 | -------------------------------------------------------------------------------- /pyOpt/pySOLVOPT/source/openunit.f: -------------------------------------------------------------------------------- 1 | C Helper subroutine to open files in the Fortran world 2 | subroutine openunit(unitnum,filename,filestatus,fileaction,ierror) 3 | 4 | integer unitnum 5 | Cf2py intent(in) unitnum 6 | character*(*) filename 7 | Cf2py intent(in) filename 8 | character*(*) filestatus 9 | Cf2py intent(in) filestatus 10 | character*(*) fileaction 11 | Cf2py intent(in) fileaction 12 | integer ierror 13 | Cf2py intent(out) ierror 14 | 15 | open(unit=unitnum,file=filename,status=filestatus, 16 | > access=fileaction,iostat=ierror) 17 | 18 | return 19 | end 20 | 21 | C Helper routine to flush buffers to files 22 | subroutine pyflush(unitnum) 23 | 24 | integer unitnum 25 | 26 | call flush(unitnum) 27 | 28 | return 29 | end 30 | -------------------------------------------------------------------------------- /pyOpt/pySOLVOPT/source/soptions.f: -------------------------------------------------------------------------------- 1 | subroutine soptions(default) 2 | c SOPTIONS returns the default values for the optional parameters 3 | c used by SolvOpt. 4 | double precision default(13) 5 | default(1)=-1.d0 6 | default(2)=1.d-4 7 | default(3)=1.d-6 8 | default(4)=15.d3 9 | default(5)=0.d0 10 | default(6)=1.d-8 11 | default(7)=2.5d0 12 | default(8)=1.d-11 13 | default(9)=0.d0 14 | default(10)=0.d0 15 | default(11)=0.d0 16 | default(12)=0.d0 17 | default(13)=0.d0 18 | end 19 | -------------------------------------------------------------------------------- /pyOpt/setup.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | import os 4 | 5 | 6 | def configuration(parent_package, top_path): 7 | from numpy.distutils.misc_util import Configuration 8 | 9 | config = Configuration('pyOpt', parent_package, top_path) 10 | 11 | # need: auto add_subpackage from source availability 12 | config.add_subpackage('pyALGENCAN') 13 | config.add_subpackage('pyALHSO') 14 | config.add_subpackage('pyALPSO') 15 | config.add_subpackage('pyCOBYLA') 16 | config.add_subpackage('pyCONMIN') 17 | config.add_subpackage('pyFILTERSD') 18 | config.add_subpackage('pyFSQP') 19 | config.add_subpackage('pyGCMMA') 20 | # config.add_subpackage('pyIPOPT') 21 | config.add_subpackage('pyKSOPT') 22 | config.add_subpackage('pyMIDACO') 23 | config.add_subpackage('pyMMA') 24 | config.add_subpackage('pyMMFD') 25 | config.add_subpackage('pyNLPQL') 26 | config.add_subpackage('pyNLPQLP') 27 | config.add_subpackage('pyNSGA2') 28 | config.add_subpackage('pyPSQP') 29 | config.add_subpackage('pySDPEN') 30 | config.add_subpackage('pySLSQP') 31 | config.add_subpackage('pySNOPT') 32 | config.add_subpackage('pySOLVOPT') 33 | 34 | for fn in 'LICENSE', 'README.md': 35 | config.add_data_files(os.path.join(os.path.dirname(os.path.dirname(os.path.realpath(__file__))), fn)) 36 | 37 | return config 38 | 39 | 40 | if __name__ == '__main__': 41 | from numpy.distutils.core import setup 42 | 43 | setup(**configuration(top_path='').todict()) 44 | -------------------------------------------------------------------------------- /pyproject.toml: -------------------------------------------------------------------------------- 1 | [build-system] 2 | requires = [ 3 | "setuptools>=42", 4 | "wheel", 5 | "numpy==1.13.3; python_version<'3.7'", 6 | "oldest-supported-numpy; python_version>='3.7'", 7 | "setuptools>=42", 8 | "setuptools_scm[toml]>=3.4", 9 | ] 10 | 11 | 12 | [tool.setuptools_scm] 13 | write_to = "pyOpt/version.py" 14 | 15 | build-backend = "setuptools.build_meta" 16 | -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- 1 | numpy 2 | -------------------------------------------------------------------------------- /setup.cfg: -------------------------------------------------------------------------------- 1 | [metadata] 2 | name = pyOpt 3 | description = Python package for formulating and solving nonlinear constrained optimization problems 4 | long_description = file: README.md 5 | long_description_content_type = text/markdown 6 | url = http://pyopt.org/ 7 | author = Ruben E. Perez, Peter W. Jansen 8 | author_email = Ruben.Perez@rmc.ca; Peter.Jansen@rmc.ca 9 | maintainer = pyOpt Developers 10 | maintainer_email = Ruben.Perez@rmc.ca; Peter.Jansen@rmc.ca 11 | license = GNU LGPL 12 | license_files = LICENSE 13 | platforms = Windows,Linux,Mac OS-X,Unix 14 | classifiers = 15 | Development Status :: 5 - Production/Stable 16 | Environment :: Console 17 | Intended Audience :: Developers 18 | Intended Audience :: Education 19 | Intended Audience :: Science/Research 20 | License :: LGPL 21 | Operating System :: MacOS 22 | Operating System :: Microsoft :: Windows 23 | Operating System :: POSIX :: Linux 24 | Operating System :: Unix 25 | Programming Language :: Python 26 | Programming Language :: Python :: 3 27 | Programming Language :: Python :: 3 :: Only 28 | Topic :: Education 29 | Topic :: Scientific/Engineering 30 | Topic :: Software Development 31 | download_url = https://github.com/madebr/pyOpt 32 | keywords = optimization 33 | 34 | [options] 35 | install_requires = 36 | numpy>=1.13.3 37 | python_requires = >=3.8 38 | include_package_data = True 39 | zip_safe = False 40 | -------------------------------------------------------------------------------- /setup.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | import os 4 | import sys 5 | 6 | from numpy.distutils.command.build_ext import build_ext 7 | 8 | if sys.version_info[:2] < (3, 7): 9 | raise RuntimeError('pyOpt requires Python version 3.7 or later ({:d}.{:d} detected).'.format( 10 | sys.version_info[:2])) 11 | sys.exit(-1) 12 | 13 | 14 | class build_opt(build_ext): 15 | def build_extension(self, ext): 16 | try: 17 | build_ext.build_extension(self, ext) 18 | except: 19 | self.announce(f'*** WARNING: Building of optimizer {ext.name} failed: {sys.exc_info()[1]}') 20 | 21 | 22 | def configuration(parent_package='', top_path=None): 23 | 24 | from numpy.distutils.misc_util import Configuration 25 | 26 | config = Configuration(None, parent_package, top_path) 27 | config.set_options( 28 | ignore_setup_xxx_py=True, 29 | assume_default_configuration=True, 30 | delegate_options_to_subpackages=True, 31 | quiet=True, 32 | ) 33 | 34 | config.add_subpackage('pyOpt') 35 | 36 | return config 37 | 38 | extras={ 39 | "test": ["pytest"], 40 | } 41 | extras['dev'] = extras['test'] 42 | 43 | extras["all"] = sum(extras.values(), []) 44 | 45 | 46 | if __name__ == '__main__': 47 | from numpy.distutils.core import setup 48 | 49 | # from distutils.command.sdist import sdist 50 | setup( 51 | configuration=configuration, 52 | cmdclass = {"build_ext": build_opt, 53 | # 'sdist': sdist # TODO: why does this not work? Why need manifest to include pyOpt? 54 | }, 55 | extras_require=extras 56 | 57 | ) 58 | -------------------------------------------------------------------------------- /tests/test_init.py: -------------------------------------------------------------------------------- 1 | def test_hello_world(): 2 | import pyOpt 3 | -------------------------------------------------------------------------------- /tests/test_minimizers1.py: -------------------------------------------------------------------------------- 1 | def test_rosenbrock(): 2 | # !/usr/bin/env python 3 | """Solves Rosenbrock's Unconstrained Problem. 4 | 5 | min 100*(x2-x1^2)**2 + (1-x1)^2 6 | s.t.: -10 <= xi <= 10, i = 1,2 7 | 8 | f* = 0 , x* = [1, 1] 9 | """ 10 | 11 | from pyOpt import Optimization 12 | 13 | def objfunc(x): 14 | f = 100 * (x[1] - x[0] ** 2) ** 2 + (1 - x[0]) ** 2 15 | g = [] 16 | 17 | fail = 0 18 | return f, g, fail 19 | 20 | def getlastsolution(prob: Optimization): 21 | new_index = prob.firstavailableindex(prob.getSolSet()) 22 | return prob.getSol(new_index - 1) 23 | 24 | # Instantiate Optimization Problem 25 | opt_prob = Optimization('Rosenbrock Unconstraint Problem', objfunc) 26 | opt_prob.addVar('x1', 'c', lower=-10.0, upper=10.0, value=-3.0) 27 | opt_prob.addVar('x2', 'c', lower=-10.0, upper=10.0, value=-4.0) 28 | opt_prob.addObj('f') 29 | 30 | # Instantiate Optimizer (PSQP) & Solve Problem 31 | from pyOpt import PSQP 32 | 33 | psqp = PSQP() 34 | psqp.setOption('IPRINT', 0) 35 | psqp(opt_prob, sens_type='FD') 36 | 37 | # Instantiate Optimizer (SLSQP) & Solve Problem 38 | from pyOpt import SLSQP 39 | 40 | slsqp = SLSQP() 41 | slsqp.setOption('IPRINT', -1) 42 | slsqp(opt_prob, sens_type='FD') 43 | 44 | # Instantiate Optimizer (CONMIN) & Solve Problem 45 | from pyOpt import CONMIN 46 | 47 | conmin = CONMIN() 48 | conmin.setOption('IPRINT', 0) 49 | conmin(opt_prob, sens_type='CS') 50 | 51 | # Instantiate Optimizer (COBYLA) & Solve Problem 52 | from pyOpt import COBYLA 53 | 54 | cobyla = COBYLA() 55 | cobyla.setOption('IPRINT', 0) 56 | cobyla(opt_prob) 57 | 58 | # Instantiate Optimizer (SOLVOPT) & Solve Problem 59 | from pyOpt import SOLVOPT 60 | 61 | solvopt = SOLVOPT() 62 | solvopt.setOption('iprint', -1) 63 | solvopt(opt_prob, sens_type='FD') 64 | 65 | # Instantiate Optimizer (KSOPT) & Solve Problem 66 | from pyOpt import KSOPT 67 | 68 | ksopt = KSOPT() 69 | ksopt.setOption('IPRINT', 0) 70 | ksopt(opt_prob, sens_type='FD') 71 | 72 | # Instantiate Optimizer (NSGA2) & Solve Problem 73 | # TODO: reactivate, currently NSGA2 fails (when building the wheels and then testing) 74 | # from pyOpt import NSGA2 75 | # 76 | # nsga2 = NSGA2() 77 | # nsga2.setOption('PrintOut', 0) 78 | # nsga2(opt_prob) 79 | 80 | # Instantiate Optimizer (SDPEN) & Solve Problem 81 | from pyOpt import SDPEN 82 | 83 | sdpen = SDPEN() 84 | sdpen.setOption('iprint', -1) 85 | sdpen(opt_prob) 86 | -------------------------------------------------------------------------------- /util/env/build-env.yml: -------------------------------------------------------------------------------- 1 | name: pyopt-env 2 | channels: 3 | - conda-forge 4 | - defaults 5 | dependencies: 6 | - compilers 7 | - numpy 8 | - pip 9 | - swig 10 | - wheel 11 | --------------------------------------------------------------------------------