diff options
| author | CoprDistGit <infra@openeuler.org> | 2023-04-23 08:02:52 +0000 |
|---|---|---|
| committer | CoprDistGit <infra@openeuler.org> | 2023-04-23 08:02:52 +0000 |
| commit | 87f3d98b221410cb7d45bb098e5f98aa075c4882 (patch) | |
| tree | 63b4e0c024714a7049d07f49ef67f62e6ea0a3e8 /python-amplpy.spec | |
| parent | 893a52bd7c1166db008156df90a08532fbe16d3c (diff) | |
automatic import of python-amplpyopeneuler20.03
Diffstat (limited to 'python-amplpy.spec')
| -rw-r--r-- | python-amplpy.spec | 98 |
1 files changed, 94 insertions, 4 deletions
diff --git a/python-amplpy.spec b/python-amplpy.spec index c4bec18..e745e50 100644 --- a/python-amplpy.spec +++ b/python-amplpy.spec @@ -1,11 +1,11 @@ %global _empty_manifest_terminate_build 0 Name: python-amplpy -Version: 0.9.2 +Version: 0.9.3 Release: 1 Summary: Python API for AMPL License: BSD-3 URL: http://ampl.com/ -Source0: https://mirrors.nju.edu.cn/pypi/web/packages/df/d0/91d8cc0bbf91db951b00a5005ee6bd85015a896b74551a7725d5152fe6a7/amplpy-0.9.2.tar.gz +Source0: https://mirrors.nju.edu.cn/pypi/web/packages/cf/22/5b01cf9c3cc1a70c81f3fc27901121a544a5e75eea08a20c9953565ac9d2/amplpy-0.9.3.tar.gz Requires: python3-future Requires: python3-ampltools @@ -30,6 +30,36 @@ $ python >>> ampl = AMPL() # instantiate AMPL object ``` +```python +# Minimal example: +from amplpy import AMPL +import pandas as pd +ampl = AMPL() +ampl.eval(r""" + set A ordered; + param S{A, A}; + param lb default 0; + param ub default 1; + var w{A} >= lb <= ub; + minimize portfolio_variance: + sum {i in A, j in A} w[i] * S[i, j] * w[j]; + s.t. portfolio_weights: + sum {i in A} w[i] = 1; +""") +tickers, cov_matrix = # ... pre-process data in Python +ampl.set["A"] = tickers +ampl.param["S"] = pd.DataFrame( + cov_matrix, index=tickers, columns=tickers +).unstack() +ampl.option["solver"] = "gurobi" +ampl.option["gurobi_options"] = "outlev=1" +ampl.solve() +assert ampl.get_value("solve_result") == "solved" +sigma = ampl.get_value("sqrt(sum {i in A, j in A} w[i] * S[i, j] * w[j])") +print(f"Volatility: {sigma*100:.1f}%") +# ... post-process solution in Python +``` + [[Documentation](https://amplpy.readthedocs.io/)] [[AMPL Modules for Python](https://dev.ampl.com/ampl/python/modules.html)] [[Available on Google Colab](https://colab.ampl.com/)] [[AMPL Community Edition](http://ampl.com/ce)] `amplpy` is an interface that allows developers to access the features of [AMPL](https://ampl.com) from within Python. For a quick introduction to AMPL see [Quick Introduction to AMPL](https://dev.ampl.com/ampl/introduction.html). @@ -79,6 +109,36 @@ $ python >>> ampl = AMPL() # instantiate AMPL object ``` +```python +# Minimal example: +from amplpy import AMPL +import pandas as pd +ampl = AMPL() +ampl.eval(r""" + set A ordered; + param S{A, A}; + param lb default 0; + param ub default 1; + var w{A} >= lb <= ub; + minimize portfolio_variance: + sum {i in A, j in A} w[i] * S[i, j] * w[j]; + s.t. portfolio_weights: + sum {i in A} w[i] = 1; +""") +tickers, cov_matrix = # ... pre-process data in Python +ampl.set["A"] = tickers +ampl.param["S"] = pd.DataFrame( + cov_matrix, index=tickers, columns=tickers +).unstack() +ampl.option["solver"] = "gurobi" +ampl.option["gurobi_options"] = "outlev=1" +ampl.solve() +assert ampl.get_value("solve_result") == "solved" +sigma = ampl.get_value("sqrt(sum {i in A, j in A} w[i] * S[i, j] * w[j])") +print(f"Volatility: {sigma*100:.1f}%") +# ... post-process solution in Python +``` + [[Documentation](https://amplpy.readthedocs.io/)] [[AMPL Modules for Python](https://dev.ampl.com/ampl/python/modules.html)] [[Available on Google Colab](https://colab.ampl.com/)] [[AMPL Community Edition](http://ampl.com/ce)] `amplpy` is an interface that allows developers to access the features of [AMPL](https://ampl.com) from within Python. For a quick introduction to AMPL see [Quick Introduction to AMPL](https://dev.ampl.com/ampl/introduction.html). @@ -122,6 +182,36 @@ $ python >>> ampl = AMPL() # instantiate AMPL object ``` +```python +# Minimal example: +from amplpy import AMPL +import pandas as pd +ampl = AMPL() +ampl.eval(r""" + set A ordered; + param S{A, A}; + param lb default 0; + param ub default 1; + var w{A} >= lb <= ub; + minimize portfolio_variance: + sum {i in A, j in A} w[i] * S[i, j] * w[j]; + s.t. portfolio_weights: + sum {i in A} w[i] = 1; +""") +tickers, cov_matrix = # ... pre-process data in Python +ampl.set["A"] = tickers +ampl.param["S"] = pd.DataFrame( + cov_matrix, index=tickers, columns=tickers +).unstack() +ampl.option["solver"] = "gurobi" +ampl.option["gurobi_options"] = "outlev=1" +ampl.solve() +assert ampl.get_value("solve_result") == "solved" +sigma = ampl.get_value("sqrt(sum {i in A, j in A} w[i] * S[i, j] * w[j])") +print(f"Volatility: {sigma*100:.1f}%") +# ... post-process solution in Python +``` + [[Documentation](https://amplpy.readthedocs.io/)] [[AMPL Modules for Python](https://dev.ampl.com/ampl/python/modules.html)] [[Available on Google Colab](https://colab.ampl.com/)] [[AMPL Community Edition](http://ampl.com/ce)] `amplpy` is an interface that allows developers to access the features of [AMPL](https://ampl.com) from within Python. For a quick introduction to AMPL see [Quick Introduction to AMPL](https://dev.ampl.com/ampl/introduction.html). @@ -143,7 +233,7 @@ With `amplpy` you can model and solve large scale optimization problems in Pytho %prep -%autosetup -n amplpy-0.9.2 +%autosetup -n amplpy-0.9.3 %build %py3_build @@ -183,5 +273,5 @@ mv %{buildroot}/doclist.lst . %{_docdir}/* %changelog -* Tue Apr 11 2023 Python_Bot <Python_Bot@openeuler.org> - 0.9.2-1 +* Sun Apr 23 2023 Python_Bot <Python_Bot@openeuler.org> - 0.9.3-1 - Package Spec generated |
