Skip to content

Commit 6fdb7ef

Browse files
author
Julian Blank
committed
Remote Loader Update
1 parent 533d0f8 commit 6fdb7ef

File tree

11 files changed

+91
-55
lines changed

11 files changed

+91
-55
lines changed

MANIFEST.in

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
recursive-include pymoo *.py *.cpp *.pf
2-
recursive-exclude pymoo *.so *.pyx *.pxd
3-
recursive-exclude pymoo/problems/pf/DASCMOP *.pf
4-
1+
recursive-include pymoo *.py *.cpp
2+
recursive-exclude pymoo *.so *.pyx *.pxd *.pf
3+
recursive-exclude pymoo/cache *
54
include LICENSE Makefile

README.rst

Lines changed: 16 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,30 @@
1-
.. |travis| image:: https://travis-ci.com/msu-coinlab/pymoo.svg?branch=master
2-
:alt: build status
3-
:target: https://travis-ci.com/msu-coinlab/pymoo
41

5-
.. |python| image:: https://img.shields.io/badge/python-3.6-blue.svg
6-
:alt: python 3.6
2+
.. |python| image:: https://img.shields.io/badge/python-3.9-blue.svg
3+
:alt: python 3.9
74

85
.. |license| image:: https://img.shields.io/badge/license-apache-orange.svg
96
:alt: license apache
107
:target: https://www.apache.org/licenses/LICENSE-2.0
118

129

13-
.. |logo| image:: https://github.com/msu-coinlab/pymoo//raw/master/doc/source/_theme/custom_theme/static/img/pymoo_banner_github.png
10+
.. |logo| image:: https://github.com/anyoptimization/pymoo//raw/master/doc/source/_theme/custom_theme/static/img/pymoo_banner_github.png
1411
:target: https://pymoo.org
1512
:alt: pymoo
1613

1714

18-
.. |animation| image:: https://github.com/msu-coinlab/pymoo//raw/master/doc/source/_theme/custom_theme/static/img/animation.gif
15+
.. |animation| image:: https://github.com/anyoptimization/pymoo//raw/master/doc/source/_theme/custom_theme/static/img/animation.gif
1916
:target: https://pymoo.org
2017
:alt: pymoo
2118

2219

23-
.. _Github: https://github.com/msu-coinlab/pymoo
20+
.. _Github: https://github.com/anyoptimization/pymoo
2421
.. _Documentation: https://www.pymoo.org/
25-
.. _Paper: https://arxiv.org/abs/2002.04504
22+
.. _Paper: https://ieeexplore.ieee.org/document/9078759
2623

2724

2825

2926

30-
|travis| |python| |license|
27+
|python| |license|
3128

3229

3330
|logo|
@@ -63,7 +60,7 @@ For the current developer version:
6360

6461
.. code:: bash
6562
66-
git clone https://github.com/msu-coinlab/pymoo
63+
git clone https://github.com/anyoptimization/pymoo
6764
cd pymoo
6865
pip install .
6966
@@ -88,7 +85,7 @@ However, for instance, executing NSGA2:
8885
.. code:: python
8986
9087
91-
from pymoo.algorithms.nsga2 import NSGA2
88+
from pymoo.algorithms.moo.nsga2 import NSGA2
9289
from pymoo.factory import get_problem
9390
from pymoo.optimize import minimize
9491
from pymoo.visualization.scatter import Scatter
@@ -101,7 +98,7 @@ However, for instance, executing NSGA2:
10198
algorithm,
10299
('n_gen', 200),
103100
seed=1,
104-
verbose=False)
101+
verbose=True)
105102
106103
plot = Scatter()
107104
plot.add(problem.pareto_front(), plot_type="line", color="black", alpha=0.7)
@@ -116,29 +113,29 @@ A representative run of NSGA2 looks as follows:
116113

117114

118115

119-
120116
.. _Citation:
121117

122118
Citation
123119
********************************************************************************
124120

125-
We are currently working on a journal publication for *pymoo*.
126-
Meanwhile, if you have used our framework for research purposes, please cite us with:
121+
If you have used our framework for research purposes, you can cite our publication by:
122+
123+
| `J. Blank and K. Deb, pymoo: Multi-Objective Optimization in Python, in IEEE Access, vol. 8, pp. 89497-89509, 2020, doi: 10.1109/ACCESS.2020.2990567 <https://ieeexplore.ieee.org/document/9078759>`_
124+
|
125+
| BibTex:
127126
128127
::
129128

130129
@ARTICLE{pymoo,
131130
author={J. {Blank} and K. {Deb}},
132131
journal={IEEE Access},
133-
title={Pymoo: Multi-Objective Optimization in Python},
132+
title={pymoo: Multi-Objective Optimization in Python},
134133
year={2020},
135134
volume={8},
136135
number={},
137136
pages={89497-89509},
138137
}
139138

140-
141-
142139
.. _Contact:
143140

144141
Contact

pymoo/config.py

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
from os.path import dirname, realpath
2+
3+
from pymoo.version import __version__
4+
5+
6+
class Config:
7+
"""
8+
The configuration of this package in general providing the place
9+
for declaring global variables.
10+
"""
11+
12+
# the root directory where the package is located at
13+
root = dirname(realpath(__file__))
14+
15+
# whether a warning should be printed if compiled modules are not available
16+
show_compile_hint = True
17+
18+
# whether when import a file the doc should be parsed - only activate when creating doc files
19+
parse_custom_docs = False
20+
21+
@classmethod
22+
def data(cls):
23+
repo = "master"
24+
if 'rc' in __version__:
25+
repo = 'release'
26+
elif 'dev' in __version__:
27+
repo = 'develop'
28+
29+
return f"https://raw.githubusercontent.com/anyoptimization/pymoo/{repo}/pymoo/data/"
30+
31+
32+
# returns the directory to be used for imports
33+
def get_pymoo():
34+
return dirname(Config.root)

pymoo/configuration.py

Lines changed: 0 additions & 12 deletions
This file was deleted.

pymoo/docs.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
import inspect
44
import re
5-
from pymoo.configuration import Configuration
5+
from pymoo.config import Config
66

77
# =========================================================================================================
88
# Docstrings Dictionary
@@ -146,7 +146,7 @@
146146
# =========================================================================================================
147147

148148
def parse_doc_string(source, dest=None, other={}):
149-
if not Configuration.parse_custom_docs:
149+
if not Config.parse_custom_docs:
150150
return
151151

152152
if dest is None:

pymoo/factory.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import re
22

3-
from pymoo.configuration import Configuration
3+
from pymoo.config import Config
44
from pymoo.problems.many import *
55
from pymoo.problems.multi import *
66
from pymoo.problems.single import *
@@ -516,7 +516,7 @@ def options_to_string(l):
516516
return ", ".join(["'%s'" % k[0] for k in l])
517517

518518

519-
if Configuration.parse_custom_docs:
519+
if Config.parse_custom_docs:
520520
from pymoo.docs import parse_doc_string
521521

522522
from pymoo.factory import get_algorithm_options, get_selection_options, get_crossover_options, \

pymoo/problems/multi/modact.py

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
1-
import os
2-
31
import numpy as np
42

53
from pymoo.core.problem import Problem
6-
from pymoo.problems.util import load_pareto_front_from_file
7-
from pymoo.util.remote import Remote
84

95

106
class MODAct(Problem):
@@ -27,7 +23,7 @@ class MODAct(Problem):
2723
C. Picard and J. Schiffmann, “Realistic Constrained Multi-Objective Optimization Benchmark Problems from Design,”
2824
IEEE Transactions on Evolutionary Computation, pp. 1–1, 2020.
2925
"""
30-
def __init__(self, function, **kwargs):
26+
def __init__(self, function, pf=None, **kwargs):
3127
try:
3228
import modact.problems as pb
3329
except:
@@ -46,6 +42,7 @@ def __init__(self, function, **kwargs):
4642

4743
self.weights = np.array(self.fct.weights)
4844
self.c_weights = np.array(self.fct.c_weights)
45+
self.pf = pf
4946

5047
super().__init__(n_var=n_var, n_obj=n_obj, n_constr=n_constr, xl=xl,
5148
xu=xu, elementwise_evaluation=True, type_var=np.double,
@@ -57,6 +54,8 @@ def _evaluate(self, x, out, *args, **kwargs):
5754
out["G"] = np.array(g)*self.c_weights
5855

5956
def _calc_pareto_front(self, *args, **kwargs):
60-
F = Remote.get_instance().load("modact", f"{self.fct.name}.pf")
61-
if F is not None:
62-
return F*self.weights*-1
57+
# download the pf files from https://zenodo.org/record/3824302#.YUCfJS2z2JA
58+
# then pass the path to it to the constructor of the problem
59+
# they are not included because of their size >700 MB
60+
return np.loadtxt(self.pf)
61+

pymoo/util/function_loader.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import importlib
22

3-
from pymoo.configuration import Configuration
3+
from pymoo.config import Config
44

55

66
def get_functions():
@@ -54,13 +54,13 @@ def __init__(self) -> None:
5454
super().__init__()
5555
self.is_compiled = is_compiled()
5656

57-
if Configuration.show_compile_hint and not self.is_compiled:
57+
if Config.show_compile_hint and not self.is_compiled:
5858
print("\nCompiled modules for significant speedup can not be used!")
5959
print("https://pymoo.org/installation.html#installation")
6060
print()
6161
print("To disable this warning:")
62-
print("from pymoo.configuration import Configuration")
63-
print("Configuration.show_compile_hint = False\n")
62+
print("from pymoo.config import Config")
63+
print("Config.show_compile_hint = False\n")
6464

6565
def load(self, func_name=None, _type="auto"):
6666

pymoo/util/remote.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
import os
22
import urllib.request
33
from os.path import join, dirname, abspath
4-
from urllib.parse import urljoin
54

65
import numpy as np
76

8-
from pymoo.configuration import Configuration
7+
from pymoo.config import Config
98

109

1110
class Remote:
11+
1212
# -------------------------------------------------
1313
# Singleton Pattern
1414
# -------------------------------------------------
@@ -17,7 +17,7 @@ class Remote:
1717
@staticmethod
1818
def get_instance():
1919
if Remote.__instance is None:
20-
server = Configuration.server
20+
server = Config.data()
2121
folder = join(dirname(dirname(abspath(__file__))), 'cache')
2222
Remote.__instance = Remote(server, folder)
2323
return Remote.__instance

tests/misc/test_crowding_distance.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import pytest
55

66
from pymoo.algorithms.moo.nsga2 import calc_crowding_distance
7-
from pymoo.configuration import get_pymoo
7+
from pymoo.config import get_pymoo
88

99

1010
@pytest.mark.skip(reason="check if this is supposed to work or not at all")

0 commit comments

Comments
 (0)