Skip to content

Commit 346933f

Browse files
committed
prune md readme and add link to release
1 parent 249807b commit 346933f

File tree

5 files changed

+11
-209
lines changed

5 files changed

+11
-209
lines changed

README.md

Lines changed: 1 addition & 202 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ The implementation of the two-objective archive is heavily based on the [`bisect
6363

6464

6565
## Releases
66-
- 1.0.0 addition of MOArchive classes for 3 and 4 objectives, as well as a class for handling solutions to constrained problems
66+
- [1.0.0](https://github.com/CMA-ES/moarchiving/releases/tag/r1.0.0) addition of MOArchive classes for 3 and 4 objectives, as well as a class for handling solutions to constrained problems
6767
- 0.7.0 reimplementation of `BiobjectiveNondominatedSortedList.hypervolume_improvement` by extracting a sublist first.
6868
- 0.6.0 the `infos` attribute is a `list` with corresponding (arbitrary) information, e.g. for keeping the respective solutions.
6969
- 0.5.3 fixed assertion error when not using `fractions.Fraction`
@@ -302,204 +302,3 @@ print(moa3_nofr.hypervolume)
302302
15.899999999999999
303303

304304

305-
### 11. Additional functions
306-
MOArchive also implements additional functions to check whether a given point is in the archive:
307-
- `in_domain`: Is the point in the domain?
308-
- `dominates`: Is the point dominated by the archive?
309-
- `dominators`: Which points (and how many) dominate the given point?
310-
311-
312-
```python
313-
points_list = [[5, 5, 0], [2, 2, 3], [0, 2, 3]]
314-
print("archive:", list(moa), "\n")
315-
print("point | in domain | dominates | num of dominators | dominators")
316-
print("----------|-----------|-----------|-------------------|-----------")
317-
for point in points_list:
318-
print(f"{point} | {moa.in_domain(point):9} | {moa.dominates(point):9} | "
319-
f"{moa.dominators(point, number_only=True):17} | {moa.dominators(point)}")
320-
```
321-
322-
archive: [[1, 3, 0], [3, 2, 1], [2, 2, 2], [1, 2, 3]]
323-
324-
point | in domain | dominates | num of dominators | dominators
325-
----------|-----------|-----------|-------------------|-----------
326-
[5, 5, 0] | 0 | 1 | 1 | [[1, 3, 0]]
327-
[2, 2, 3] | 1 | 1 | 2 | [[2, 2, 2], [1, 2, 3]]
328-
[0, 2, 3] | 1 | 0 | 0 | []
329-
330-
331-
### 12. Visualization of indicator values
332-
By saving the values of indicators for each solution added to the archive, we can visualize their change over time.
333-
334-
335-
```python
336-
import matplotlib.pyplot as plt
337-
import random
338-
339-
n_obj = 3
340-
341-
indicators_cmoa = []
342-
indicators_moa = []
343-
cmoa = get_cmo_archive(reference_point=[0.5] * n_obj, n_obj=n_obj, tau=0.2)
344-
moa = get_mo_archive(reference_point=[0.1] * n_obj, n_obj=n_obj)
345-
346-
for i in range(2000):
347-
objectives = [random.random() for _ in range(n_obj)]
348-
constraints = [max(random.random() - 0.1, 0), max(random.random() - 0.1, 0)]
349-
350-
cmoa.add(objectives, constraints, info=f"point_{i}")
351-
moa.add(objectives, info=f"point_{i}")
352-
353-
indicators_cmoa.append((cmoa.hypervolume_plus_constr, cmoa.hypervolume_plus, cmoa.hypervolume))
354-
indicators_moa.append((moa.hypervolume_plus, moa.hypervolume))
355-
356-
```
357-
358-
359-
```python
360-
fig, axs = plt.subplots(1, 2, figsize=(10, 5))
361-
axs[0].plot([x[2] for x in indicators_cmoa], label="hypervolume")
362-
axs[0].plot([x[1] for x in indicators_cmoa], label="hypervolume_plus")
363-
axs[0].plot([x[0] for x in indicators_cmoa], label="hypervolume_plus_constr")
364-
axs[0].axhline(0, color="black", linestyle="--", zorder=0)
365-
axs[0].axhline(-cmoa.tau, color="black", linestyle="--", zorder=0)
366-
axs[0].set_title("Constrained MOArchive")
367-
axs[0].legend()
368-
369-
axs[1].plot([x[1] for x in indicators_moa], label="hypervolume")
370-
axs[1].plot([x[0] for x in indicators_moa], label="hypervolume_plus")
371-
axs[1].set_title("MOArchive")
372-
axs[1].axhline(0, color="black", linestyle="--", zorder=0)
373-
axs[1].legend()
374-
plt.show()
375-
```
376-
377-
378-
379-
![png](README_files/README_31_0.png)
380-
381-
382-
383-
### 13. Performance tests
384-
385-
386-
```python
387-
import time
388-
from moarchiving.tests.point_sampling import get_non_dominated_points
389-
test_archive_sizes = [0] + [2 ** i for i in range(21)]
390-
391-
get_mo_archive.hypervolume_computation_float_type = fractions.Fraction
392-
get_mo_archive.hypervolume_final_float_type = fractions.Fraction
393-
```
394-
395-
#### 13.1. Initializing the archive
396-
397-
398-
```python
399-
n_repeats = 100
400-
time_limit = 10
401-
402-
for n_obj in [2, 3, 4]:
403-
print(f"Testing {n_obj} objectives")
404-
times = []
405-
archive_sizes = []
406-
407-
for archive_size in test_archive_sizes:
408-
points = get_non_dominated_points(archive_size, n_dim=n_obj)
409-
t0 = time.time()
410-
moa = [get_mo_archive(points, [1] * n_obj, n_obj=n_obj)
411-
for _ in range(n_repeats)]
412-
hv = [m.hypervolume for m in moa]
413-
t1 = time.time()
414-
415-
times.append(max((t1 - t0) / n_repeats, 10e-4))
416-
print(".", end="")
417-
archive_sizes.append(archive_size)
418-
419-
if t1 - t0 > time_limit:
420-
break
421-
print()
422-
423-
plt.plot(archive_sizes, times, '-o', label=f"{n_obj} objectives")
424-
425-
plt.title("Initialization and hypervolume computation")
426-
plt.xlabel("Archive size")
427-
plt.ylabel("Time [s]")
428-
plt.yscale("log")
429-
plt.xscale("log")
430-
plt.grid(True)
431-
plt.legend()
432-
plt.show()
433-
```
434-
435-
Testing 2 objectives
436-
...............
437-
Testing 3 objectives
438-
.............
439-
Testing 4 objectives
440-
.........
441-
442-
443-
444-
445-
![png](README_files/README_35_1.png)
446-
447-
448-
449-
#### 13.2. Adding a solution to an existing archive
450-
451-
452-
```python
453-
n_repeats = 10
454-
time_limit = 10
455-
456-
for n_obj in [2, 3, 4]:
457-
print(f"Testing {n_obj} objectives")
458-
times = []
459-
archive_sizes = []
460-
461-
for archive_size in test_archive_sizes:
462-
463-
points = get_non_dominated_points(archive_size, n_dim=n_obj)
464-
add_points = get_non_dominated_points(n_repeats, n_dim=n_obj)
465-
moa = [get_mo_archive(points, [1] * n_obj, n_obj=n_obj) for _ in range(n_repeats)]
466-
467-
t0 = time.time()
468-
for i, m in enumerate(moa):
469-
m.add(add_points[i])
470-
t1 = time.time()
471-
472-
times.append(max((t1 - t0) / n_repeats, 10e-4))
473-
print(".", end="")
474-
archive_sizes.append(archive_size)
475-
476-
if t1 - t0 > time_limit:
477-
break
478-
print()
479-
time.sleep(1)
480-
481-
plt.plot(archive_sizes, times, '-o', label=f"{n_obj} objectives")
482-
483-
plt.title("Adding a point to the archive")
484-
plt.xlabel("Archive size")
485-
plt.ylabel("Time [s]")
486-
plt.yscale("log")
487-
plt.xscale("log")
488-
plt.grid(True)
489-
plt.legend()
490-
plt.show()
491-
```
492-
493-
Testing 2 objectives
494-
......................
495-
Testing 3 objectives
496-
................
497-
Testing 4 objectives
498-
...........
499-
500-
501-
502-
503-
![png](README_files/README_37_1.png)
504-
505-

howto/release.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,11 @@ Make distribution
3131
3232
```sh
3333
cd install-folder
34-
python -c "open('README.md', 'w').write(open('../README.md', 'r').read().split('### 11')[0])"
34+
python -c "s = open('../README.md', 'r').read().split('### 11')[0]; open('README.md', 'w').write(s)"
3535
python -m build > dist_call_output.txt
3636
less dist_call_output.txt # not very informative
3737
ll dist # just checking creation date
38-
tar -tf dist/moarchiving-1.0.0.tar.gz | tree --fromfile # check that the distribution folders are clean
38+
tar -tf dist/moarchiving-1.0.0.tar.gz | tree --fromfile | less # check that the distribution folders are clean
3939
```
4040
4141
Check distribution and project description:

howto/update_readme.md

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
1-
Files `README.md` and `index.html` are created from the notebook `moarchiving.ipynb`
1+
# How to update readme and index.html files
2+
3+
The files `README.md` and `index.html` are created from the notebook `moarchiving.ipynb`.
24
To update the files, make changes in the notebook, and then run the following commands:
35

46
```bash
5-
jupyter nbconvert --to markdown --output README moarchiving.ipynb
67
jupyter nbconvert --to html --output index moarchiving.ipynb
7-
```
8+
jupyter nbconvert --to markdown --output README moarchiving.ipynb
9+
python -c "s = open('README.md', 'r').read().split('### 11')[0]; open('README.md', 'w').write(s)"
10+
```

index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14620,7 +14620,7 @@ <h2 id="Links">Links<a class="anchor-link" href="#Links">&#182;</a></h2><ul>
1462014620
<h2 id="Details">Details<a class="anchor-link" href="#Details">&#182;</a></h2><p><code>moarchiving</code> with 2 objectives uses the <a href="https://docs.python.org/3/library/fractions.html"><code>fractions.Fraction</code></a> type to avoid rounding errors when computing hypervolume differences, but its usage can also be easily switched off by assigning the respective class attributes <code>hypervolume_computation_float_type</code> and <code>hypervolume_final_float_type</code>. The Fraction type can become prohibitively computationally expensive with increasing precision.</p>
1462114621
<p>The implementation of the two-objective archive is heavily based on the <a href="https://docs.python.org/3/library/bisect.html"><code>bisect</code></a> module, while in three and four objectives it is based on the <a href="https://pypi.org/project/sortedcontainers/"><code>sortedcontainers</code></a> module.</p>
1462214622
<h2 id="Releases">Releases<a class="anchor-link" href="#Releases">&#182;</a></h2><ul>
14623-
<li>1.0.0 addition of MOArchive classes for 3 and 4 objectives, as well as a class for handling solutions to constrained problems</li>
14623+
<li><a href="https://github.com/CMA-ES/moarchiving/releases/tag/r1.0.0">1.0.0</a> addition of MOArchive classes for 3 and 4 objectives, as well as a class for handling solutions to constrained problems</li>
1462414624
<li>0.7.0 reimplementation of <code>BiobjectiveNondominatedSortedList.hypervolume_improvement</code> by extracting a sublist first.</li>
1462514625
<li>0.6.0 the <code>infos</code> attribute is a <code>list</code> with corresponding (arbitrary) information, e.g. for keeping the respective solutions.</li>
1462614626
<li>0.5.3 fixed assertion error when not using <code>fractions.Fraction</code></li>

moarchiving.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@
6969
"\n",
7070
"\n",
7171
"## Releases\n",
72-
"- 1.0.0 addition of MOArchive classes for 3 and 4 objectives, as well as a class for handling solutions to constrained problems\n",
72+
"- [1.0.0](https://github.com/CMA-ES/moarchiving/releases/tag/r1.0.0) addition of MOArchive classes for 3 and 4 objectives, as well as a class for handling solutions to constrained problems\n",
7373
"- 0.7.0 reimplementation of `BiobjectiveNondominatedSortedList.hypervolume_improvement` by extracting a sublist first.\n",
7474
"- 0.6.0 the `infos` attribute is a `list` with corresponding (arbitrary) information, e.g. for keeping the respective solutions.\n",
7575
"- 0.5.3 fixed assertion error when not using `fractions.Fraction`\n",

0 commit comments

Comments
 (0)