Skip to content

Commit

Permalink
Merge branch 'anyoptimization:main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
oliverweissl authored Jan 21, 2025
2 parents d3dd987 + 5da15ca commit 49beb65
Show file tree
Hide file tree
Showing 23 changed files with 281 additions and 54 deletions.
37 changes: 37 additions & 0 deletions .github/workflows/wheels.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@

name: Build

on:
push:
branches:
- deploy


jobs:
build_wheels:
name: Build wheels on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-13, macos-latest]

steps:
- uses: actions/checkout@v4

- uses: actions/setup-python@v5

- name: Install cibuildwheel
run: python -m pip install cibuildwheel==2.22.0

- name: Build wheels
run: python -m cibuildwheel --output-dir wheelhouse

- uses: actions/upload-artifact@v4
with:
name: cibw-wheels-${{ matrix.os }}-${{ strategy.job-index }}
path: ./wheelhouse/*.whl

concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true

128 changes: 128 additions & 0 deletions CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
# Contributor Covenant Code of Conduct

## Our Pledge

We as members, contributors, and leaders pledge to make participation in our
community a harassment-free experience for everyone, regardless of age, body
size, visible or invisible disability, ethnicity, sex characteristics, gender
identity and expression, level of experience, education, socio-economic status,
nationality, personal appearance, race, religion, or sexual identity
and orientation.

We pledge to act and interact in ways that contribute to an open, welcoming,
diverse, inclusive, and healthy community.

## Our Standards

Examples of behavior that contributes to a positive environment for our
community include:

* Demonstrating empathy and kindness toward other people
* Being respectful of differing opinions, viewpoints, and experiences
* Giving and gracefully accepting constructive feedback
* Accepting responsibility and apologizing to those affected by our mistakes,
and learning from the experience
* Focusing on what is best not just for us as individuals, but for the
overall community

Examples of unacceptable behavior include:

* The use of sexualized language or imagery, and sexual attention or
advances of any kind
* Trolling, insulting or derogatory comments, and personal or political attacks
* Public or private harassment
* Publishing others' private information, such as a physical or email
address, without their explicit permission
* Other conduct which could reasonably be considered inappropriate in a
professional setting

## Enforcement Responsibilities

Community leaders are responsible for clarifying and enforcing our standards of
acceptable behavior and will take appropriate and fair corrective action in
response to any behavior that they deem inappropriate, threatening, offensive,
or harmful.

Community leaders have the right and responsibility to remove, edit, or reject
comments, commits, code, wiki edits, issues, and other contributions that are
not aligned to this Code of Conduct, and will communicate reasons for moderation
decisions when appropriate.

## Scope

This Code of Conduct applies within all community spaces, and also applies when
an individual is officially representing the community in public spaces.
Examples of representing our community include using an official e-mail address,
posting via an official social media account, or acting as an appointed
representative at an online or offline event.

## Enforcement

Instances of abusive, harassing, or otherwise unacceptable behavior may be
reported to the community leaders responsible for enforcement at
blankjul [at] msu.edu.
All complaints will be reviewed and investigated promptly and fairly.

All community leaders are obligated to respect the privacy and security of the
reporter of any incident.

## Enforcement Guidelines

Community leaders will follow these Community Impact Guidelines in determining
the consequences for any action they deem in violation of this Code of Conduct:

### 1. Correction

**Community Impact**: Use of inappropriate language or other behavior deemed
unprofessional or unwelcome in the community.

**Consequence**: A private, written warning from community leaders, providing
clarity around the nature of the violation and an explanation of why the
behavior was inappropriate. A public apology may be requested.

### 2. Warning

**Community Impact**: A violation through a single incident or series
of actions.

**Consequence**: A warning with consequences for continued behavior. No
interaction with the people involved, including unsolicited interaction with
those enforcing the Code of Conduct, for a specified period of time. This
includes avoiding interactions in community spaces as well as external channels
like social media. Violating these terms may lead to a temporary or
permanent ban.

### 3. Temporary Ban

**Community Impact**: A serious violation of community standards, including
sustained inappropriate behavior.

**Consequence**: A temporary ban from any sort of interaction or public
communication with the community for a specified period of time. No public or
private interaction with the people involved, including unsolicited interaction
with those enforcing the Code of Conduct, is allowed during this period.
Violating these terms may lead to a permanent ban.

### 4. Permanent Ban

**Community Impact**: Demonstrating a pattern of violation of community
standards, including sustained inappropriate behavior, harassment of an
individual, or aggression toward or disparagement of classes of individuals.

**Consequence**: A permanent ban from any sort of public interaction within
the community.

## Attribution

This Code of Conduct is adapted from the [Contributor Covenant][homepage],
version 2.0, available at
https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.

Community Impact Guidelines were inspired by [Mozilla's code of conduct
enforcement ladder](https://github.com/mozilla/diversity).

[homepage]: https://www.contributor-covenant.org

For answers to common questions about this code of conduct, see the FAQ at
https://www.contributor-covenant.org/faq. Translations are available at
https://www.contributor-covenant.org/translations.
69 changes: 69 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
# Contributing Guidelines
🎉 Thanks for your interest in helping improve pymoo! 🎉

**If you are looking for pymoo's documentation, go here instead: https://www.pymoo.org/**

These guidelines are for people who want to contribute to pymoo. There are many ways to contribute, such as contributing code, reporting bugs, creating feature requests, helping other users [in our Discussions](https://github.com/anyoptimization/pymoo/discussions) or [in our Discord](https://discord.gg/DUCGrvqWEM), etc.

## Before Contributing
**Before you start coding a bug fix or feature request, please post in the respective GitHub Issue to express your intent to volunteer and wait for a positive response** And if there is no issue created yet, please create one first.

This ensures:
- Multiple developers aren't unknowingly working on the same issue
- The issue is something pymoo's maintainers believe should be implemented
- Any architectural changes that need to be implemented have been sufficiently planned by the community in collaboration with pymoo's maintainers
- Your time is well spent

Please note: Opening a pull request to add a new feature--not just a bug fix or similar--without prior approval from the pymoo team has a very low likelihood of being merged. Introducing new features involves extensive considerations, such as ensuring they meet our standards and support future maintenance.

## Style Guide
We currently do not have a specific style guide for the project, but do follow [PEP-8](https://peps.python.org/pep-0008/) and [PEP-257](https://peps.python.org/pep-0257/)

## Code Standards
Writing good code isn't just about the content; it's also about the style. During Continuous Integration testing, various tools will check your code for stylistic errors, and any warnings will cause the test to fail. Therefore, adhering to good style is essential for submitting code to pymoo.

Additionally, given the widespread use of our library, it's crucial to avoid sudden changes that might break existing user code. We strive to maintain backward compatibility to prevent widespread disruptions.

## Finding an Issue to Contribute To

If you're new to pymoo or open-source development, we suggest exploring the GitHub “Issues” tab to find topics that interest you. Unassigned issues labeled "good first issue" are typically suitable for newer contributors.

After identifying an interesting issue, it’s wise to assign it to yourself to avoid duplicated efforts.

If you can't continue working on the issue, please unassign it so others know it's available again. You can also check the list of assigned issues, as some may not be actively worked on. If you're interested in an assigned issue, kindly ask the current assignee if you can take over.

## Bug Reporting

To help all developers understand the scope of the issue, please be sure to include the following details in your Bug Report issues:

- Summary with a clear and concise description of the problem
- Reproducible Code Example, as self-contained and minimal as possible
- Steps To Reproduce the bug
- Expected Behavior assuming there were no bugs
- Current Behavior of the buggy experience, error messages, stack traces, etc.
- Versioning related to the environment, OS, dependencies, etc. that you are running

## Making a Pull Request
To enhance the likelihood of your pull request being reviewed, you should:

- **Reference an Open Issue:** For significant changes, link to an existing issue to clarify the PR’s purpose.
- **Include Appropriate Tests:** Make sure tests are included; these should be the initial part of any PR.
- **Keep It Simple:** Ensure your pull requests are straightforward; larger PRs require more time to review.
- **Maintain CI Green State:** Ensure continuous integration tests are passing.
- **Regular Updates:** Keep updating your pull request, either upon request or every few days.

## Topics of Interest
Some topics that are, in our opinion, interesting to incorporate in the future:

- **New features:** For instance, new test problems, algorithms, or any other multi-objective related implementation.

- **Constraint Handling:** So far, mostly parameter-less constraint handling is used. Many different strategies of handling constraints have been studied, and some state of the art methods should be provided in pymoo as well.

- **Interactive Visualization:** Our framework provides static visualization for the objective space in higher dimensions. However, it would be nice to make it possible to explore solutions interactively. A suitable choice would be a web-based application with a javascript/typescript based interface using pymoo to answer requests necessary for plotting or optimization

- **Other Topics:** Those are topics that came to our mind. However, there are many more things related to multi-objective optimization that are interesting and standard implementation in a framework would be useful!

If you are interested in any of those topics, please let us know.

## Attribution
These Contributing Guidelines are adapted from [GitHub's Building communities](https://docs.github.com/en/communities/setting-up-your-project-for-healthy-contributions/setting-guidelines-for-repository-contributors), [Contributing to pandas](https://pandas.pydata.org/docs/dev/development/contributing.html), and [Streamlit's Contributing](https://github.com/streamlit/streamlit/wiki/Contributing).
2 changes: 1 addition & 1 deletion docs/source/algorithms/moo/kgb.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@
"- **perc_diversity (float, optional):** Proportion of the population allocated for introducing diversity. \n",
"- **c_size (int, optional):** Cluster size.\n",
"- **eps (float, optional):** Threshold for detecting changes. Default: \n",
"- **pertub_dev (float, optional):** Deviation for perturbation in diversity introduction. "
"- **perturb_dev (float, optional):** Deviation for perturbation in diversity introduction. "
]
},
{
Expand Down
4 changes: 1 addition & 3 deletions docs/source/algorithms/moo/nsga2.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,7 @@
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Furthermore, to increase some selection pressure, NSGA-II uses a binary tournament mating selection. Each individual is first compared by rank and then crowding distance. There is also a variant in the original C code where instead of using the rank, the domination criterium between two solutions is used."
]
"source": "Furthermore, to increase some selection pressure, NSGA-II uses a binary tournament mating selection. Each individual is first compared by rank and then crowding distance. There is also a variant in the original C code where instead of using the rank, the domination criterion between two solutions is used."
},
{
"cell_type": "markdown",
Expand Down
4 changes: 1 addition & 3 deletions docs/source/getting_started/part_2.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -166,9 +166,7 @@
{
"cell_type": "markdown",
"metadata": {},
"source": [
"If you use **pymoo** as a researcher trying to improve existing algorithms, you might want to have a look at the varierity of single- and many-objective optimization test problems already implemented. "
]
"source": "If you use **pymoo** as a researcher trying to improve existing algorithms, you might want to have a look at the variety of single- and many-objective optimization test problems already implemented. "
},
{
"cell_type": "markdown",
Expand Down
2 changes: 1 addition & 1 deletion docs/source/mcdm/index.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@
"plot.add(F, color=\"blue\", alpha=0.2, s=10)\n",
"plot.add(F[I], color=\"red\", s=30)\n",
"plot.do()\n",
"plot.apply(lambda ax: ax.arrow(0, 0, 0.5, 0.5, color='black', \n",
"plot.apply(lambda ax: ax.arrow(0, 0, *weights, color='black', \n",
" head_width=0.01, head_length=0.01, alpha=0.4))\n",
"plot.show()"
]
Expand Down
4 changes: 2 additions & 2 deletions pymoo/algorithms/moo/ctaea.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
from pymoo.util.display.multi import MultiObjectiveOutput
from pymoo.util.dominator import Dominator
from pymoo.util.function_loader import load_function
from pymoo.util.misc import has_feasible, random_permuations
from pymoo.util.misc import has_feasible, random_permutations
from pymoo.util.nds.non_dominated_sorting import NonDominatedSorting


Expand Down Expand Up @@ -63,7 +63,7 @@ def _do(self, problem, Hm, n_select, n_parents, **kwargs):
n_random = n_select * n_parents * self.pressure
n_perms = math.ceil(n_random / n_pop)
# get random permutations and reshape them
P = random_permuations(n_perms, n_pop)[:n_random]
P = random_permutations(n_perms, n_pop)[:n_random]
P = np.reshape(P, (n_select * n_parents, self.pressure))
if Pc <= Pd:
# Choose from DA
Expand Down
18 changes: 9 additions & 9 deletions pymoo/algorithms/moo/kgb.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@ def __init__(
c_size=13,
eps=0.0,
ps={},
pertub_dev=0.1,
perturb_dev=0.1,
save_ps=False,
**kwargs,
):

super().__init__(**kwargs)
self.PERTUB_DEV = pertub_dev
self.PERTURB_DEV = perturb_dev
self.PERC_DIVERSITY = perc_diversity
self.PERC_DETECT_CHANGE = perc_detect_change
self.EPS = eps
Expand Down Expand Up @@ -258,11 +258,11 @@ def check_boundaries(self, pop):
:param pop: Population to check and fix boundaries
:return: Population with corrected boundaries
"""
# check wether numpy array or pymoo population is given
# check whether numpy array or pymoo population is given
if isinstance(pop, Population):
pop = pop.get("X")

# check if any solution is outside of the bounds
# check if any solution is outside the bounds
for individual in pop:
for i in range(len(individual)):
if individual[i] > self.problem.xu[i]:
Expand All @@ -281,7 +281,7 @@ def random_strategy(self, N_r):
# TODO: Check boundaries
random_pop = np.random.random((N_r, self.problem.n_var))

# check if any solution is outside of the bounds
# check if any solution is outside the bounds
for individual in random_pop:
for i in range(len(individual)):
if individual[i] > self.problem.xu[i]:
Expand Down Expand Up @@ -341,16 +341,16 @@ def _advance(self, **kwargs):
X_test = self.random_strategy(self.nr_rand_solutions)

# introduce noise to vary previously useful solutions
noise = np.random.normal(0, self.PERTUB_DEV, self.problem.n_var)
noise = np.random.normal(0, self.PERTURB_DEV, self.problem.n_var)
noisy_useful_history = np.asarray(pop_useful) + noise

# check wether solutions are within bounds
# check whether solutions are within bounds
noisy_useful_history = self.check_boundaries(noisy_useful_history)

# add noisy useful history to randomly generated solutions
X_test = np.vstack((X_test, noisy_useful_history))

# predict wether random solutions are useful or useless
# predict whether random solutions are useful or useless
Y_test = model.predict(X_test)

# create list of useful predicted solutions
Expand Down Expand Up @@ -391,7 +391,7 @@ def _advance(self, **kwargs):
# if there are still not enough solutions in init_pop randomly sample previously useful solutions directly without noise to init_pop
if len(init_pop) < self.pop_size:

# fill up init_pop with randomly sampled solutions from pop_usefull
# fill up init_pop with randomly sampled solutions from pop_useful
if len(pop_useful) >= self.pop_size - len(init_pop):

nr_sampled_pop_useful = self.pop_size - len(init_pop)
Expand Down
4 changes: 2 additions & 2 deletions pymoo/algorithms/moo/nsga3.py
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ def niching(pop, n_remaining, niche_count, niche_of_individuals, dist_to_niche):
# the minimum niche count
min_niche_count = next_niche_count.min()

# all niches with the minimum niche count (truncate if randomly if more niches than remaining individuals)
# all niches with the minimum niche count (truncate randomly if there are more niches than remaining individuals)
next_niches = next_niches_list[np.where(next_niche_count == min_niche_count)[0]]
next_niches = next_niches[np.random.permutation(len(next_niches))[:n_select]]

Expand Down Expand Up @@ -303,7 +303,7 @@ def get_extreme_points_c(F, ideal_point, extreme_points=None):
weights = np.eye(F.shape[1])
weights[weights == 0] = 1e6

# add the old extreme points to never loose them for normalization
# add the old extreme points to never lose them for normalization
_F = F
if extreme_points is not None:
_F = np.concatenate([extreme_points, _F], axis=0)
Expand Down
Loading

0 comments on commit 49beb65

Please sign in to comment.