
[](LICENSE)
[](https://www.python.org/downloads/)
[](https://pypi.org/project/coords-nsga2/)
[](https://github.com/ZXF1001/coords-nsga2/tags)
[English](README.md) | [中文](README_CN.md)
> **⚠️ Important Notice**: This documentation and README files are AI-generated based on the source code analysis. While we strive for accuracy, there may be inconsistencies or issues. We are actively working to improve and verify all content. Please report any problems you encounter.
A Python library implementing a coordinate-based NSGA-II (Non-dominated Sorting Genetic Algorithm II) for multi-objective optimization. This library is specifically designed for optimizing coordinate point layouts, featuring specialized constraints, crossover, and mutation operators that work directly on coordinate points.
## Features
- **Coordinate-focused optimization**: Designed specifically for optimizing layouts of coordinate points
- **Multi-objective optimization**: Supports 2 or more objective functions using NSGA-II algorithm
- **Parallel computation**: Accelerate optimization with parallel processing for computationally intensive problems
- **Specialized constraints**: Built-in support for point spacing, boundary limits, and custom constraints
- **Tailored genetic operators**: Custom crossover and mutation operators that directly act on coordinate points
- **Flexible region definition**: Support for both polygon and rectangular regions
- **Lightweight and extensible**: Easy to customize operators and constraints
- **Progress tracking**: Built-in progress bars and optimization history
- **Save/Load functionality**: Save and restore optimization states
## Installation
### From PyPI
```bash
pip install coords-nsga2
```
### From Source
```bash
git clone https://github.com/ZXF1001/coords-nsga2.git
cd coords-nsga2
pip install -e .
```
## Quick Start
Here's a minimal example demonstrating how to run a coordinate-based NSGA-II optimization with multiple objectives:
```python
import numpy as np
from scipy.spatial import distance
from coords_nsga2 import CoordsNSGA2, Problem
from coords_nsga2.spatial import region_from_points
# Define the optimization region
region = region_from_points([
[0, 0],
[1, 0],
[2, 1],
[1, 1],
])
# Define objective functions
def objective_1(coords):
"""Maximize sum of x and y coordinates"""
return np.sum(coords[:, 0]) + np.sum(coords[:, 1])
def objective_2(coords):
"""Maximize spread of points"""
return np.std(coords[:, 0]) + np.std(coords[:, 1])
# Define constraints
spacing = 0.05
def constraint_1(coords):
"""Minimum spacing between points"""
dist_list = distance.pdist(coords)
penalty_list = spacing - dist_list[dist_list < spacing]
return np.sum(penalty_list)
# Setup the problem
problem = Problem(
objectives=[objective_1, objective_2], # List of objective functions
n_points=10,
region=region,
constraints=[constraint_1]
)
# Initialize the optimizer
optimizer = CoordsNSGA2(
problem=problem,
pop_size=20,
prob_crs=0.5,
prob_mut=0.1
)
# Run optimization
result = optimizer.run(1000)
# Visualize optimal layouts for each objective
optimizer.plot.optimal_coords()
# Access results
print(f"Result shape: {result.shape}")
print(f"Number of objectives: {len(optimizer.values_P)}")
print(f"Optimization history length: {len(optimizer.P_history)}")
```
## Documentation
Complete documentation is available in the [docs/](docs) folder.
To start the documentation server locally:
```bash
mkdocs serve
```
To build the documentation:
```bash
mkdocs build
```
## Contributing
Contributions are welcome! Please feel free to submit a Pull Request. For major changes, please open an issue first to discuss what you would like to change.
1. Fork the repository
2. Create your feature branch (`git checkout -b feature/AmazingFeature`)
3. Commit your changes (`git commit -m 'Add some AmazingFeature'`)
4. Push to the branch (`git push origin feature/AmazingFeature`)
5. Open a Pull Request
## License
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
## Citation
If you use this library in your research, please cite:
```bibtex
@software{Coords-NSGA2,
title={Coords-NSGA2: A Python library for coordinate-based multi-objective optimization},
author={Zhang, Xiaofeng},
year={2025},
url={https://github.com/ZXF1001/coords-nsga2}
}
```
Raw data
{
"_id": null,
"home_page": null,
"name": "coords-nsga2",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.8",
"maintainer_email": null,
"keywords": "coordinates, genetic-algorithm, nsga2, optimization",
"author": null,
"author_email": "Xiaofeng Zhang <xiaofeng1001@outlook.com>",
"download_url": "https://files.pythonhosted.org/packages/4b/36/d1e2c2ad8edba662e02d8506c1ba166f2e182623927a6880a776a1c1bb22/coords_nsga2-2.3.0.tar.gz",
"platform": null,
"description": "\n\n[](LICENSE)\n[](https://www.python.org/downloads/)\n[](https://pypi.org/project/coords-nsga2/)\n[](https://github.com/ZXF1001/coords-nsga2/tags)\n\n[English](README.md) | [\u4e2d\u6587](README_CN.md)\n\n> **\u26a0\ufe0f Important Notice**: This documentation and README files are AI-generated based on the source code analysis. While we strive for accuracy, there may be inconsistencies or issues. We are actively working to improve and verify all content. Please report any problems you encounter.\n\nA Python library implementing a coordinate-based NSGA-II (Non-dominated Sorting Genetic Algorithm II) for multi-objective optimization. This library is specifically designed for optimizing coordinate point layouts, featuring specialized constraints, crossover, and mutation operators that work directly on coordinate points.\n\n## Features\n\n- **Coordinate-focused optimization**: Designed specifically for optimizing layouts of coordinate points\n- **Multi-objective optimization**: Supports 2 or more objective functions using NSGA-II algorithm\n- **Parallel computation**: Accelerate optimization with parallel processing for computationally intensive problems\n- **Specialized constraints**: Built-in support for point spacing, boundary limits, and custom constraints\n- **Tailored genetic operators**: Custom crossover and mutation operators that directly act on coordinate points\n- **Flexible region definition**: Support for both polygon and rectangular regions\n- **Lightweight and extensible**: Easy to customize operators and constraints\n- **Progress tracking**: Built-in progress bars and optimization history\n- **Save/Load functionality**: Save and restore optimization states\n\n## Installation\n\n### From PyPI\n```bash\npip install coords-nsga2\n```\n\n### From Source\n```bash\ngit clone https://github.com/ZXF1001/coords-nsga2.git\ncd coords-nsga2\npip install -e .\n```\n\n## Quick Start\n\nHere's a minimal example demonstrating how to run a coordinate-based NSGA-II optimization with multiple objectives:\n\n```python\nimport numpy as np\nfrom scipy.spatial import distance\nfrom coords_nsga2 import CoordsNSGA2, Problem\nfrom coords_nsga2.spatial import region_from_points\n\n# Define the optimization region\nregion = region_from_points([\n [0, 0],\n [1, 0],\n [2, 1],\n [1, 1],\n])\n\n# Define objective functions\ndef objective_1(coords):\n \"\"\"Maximize sum of x and y coordinates\"\"\"\n return np.sum(coords[:, 0]) + np.sum(coords[:, 1])\n\ndef objective_2(coords):\n \"\"\"Maximize spread of points\"\"\"\n return np.std(coords[:, 0]) + np.std(coords[:, 1])\n\n# Define constraints\nspacing = 0.05\ndef constraint_1(coords):\n \"\"\"Minimum spacing between points\"\"\"\n dist_list = distance.pdist(coords)\n penalty_list = spacing - dist_list[dist_list < spacing]\n return np.sum(penalty_list)\n\n# Setup the problem\nproblem = Problem(\n objectives=[objective_1, objective_2], # List of objective functions\n n_points=10,\n region=region,\n constraints=[constraint_1]\n)\n\n# Initialize the optimizer\noptimizer = CoordsNSGA2(\n problem=problem,\n pop_size=20,\n prob_crs=0.5,\n prob_mut=0.1\n)\n\n# Run optimization\nresult = optimizer.run(1000)\n\n# Visualize optimal layouts for each objective\noptimizer.plot.optimal_coords()\n\n# Access results\nprint(f\"Result shape: {result.shape}\")\nprint(f\"Number of objectives: {len(optimizer.values_P)}\")\nprint(f\"Optimization history length: {len(optimizer.P_history)}\")\n```\n\n## Documentation\n\nComplete documentation is available in the [docs/](docs) folder.\n\nTo start the documentation server locally:\n```bash\nmkdocs serve\n```\n\nTo build the documentation:\n```bash\nmkdocs build\n```\n\n## Contributing\n\nContributions are welcome! Please feel free to submit a Pull Request. For major changes, please open an issue first to discuss what you would like to change.\n\n1. Fork the repository\n2. Create your feature branch (`git checkout -b feature/AmazingFeature`)\n3. Commit your changes (`git commit -m 'Add some AmazingFeature'`)\n4. Push to the branch (`git push origin feature/AmazingFeature`)\n5. Open a Pull Request\n\n## License\n\nThis project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.\n\n## Citation\n\nIf you use this library in your research, please cite:\n\n```bibtex\n@software{Coords-NSGA2,\n title={Coords-NSGA2: A Python library for coordinate-based multi-objective optimization},\n author={Zhang, Xiaofeng},\n year={2025},\n url={https://github.com/ZXF1001/coords-nsga2}\n}\n```\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "A Python library implementing a coordinate-based NSGA-II for multi-objective optimization.",
"version": "2.3.0",
"project_urls": {
"Homepage": "https://github.com/ZXF1001/coords-nsga2"
},
"split_keywords": [
"coordinates",
" genetic-algorithm",
" nsga2",
" optimization"
],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "56657e747b825acd15822f543af92911efa2fe36e1f7fa80e893c46229e354b3",
"md5": "1f26acaa5cb899bbba5d29067e99d162",
"sha256": "959897a0a100e6b3d96a258f516ad85a0e91f89de1fa98f7fa1244808ee10c15"
},
"downloads": -1,
"filename": "coords_nsga2-2.3.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "1f26acaa5cb899bbba5d29067e99d162",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.8",
"size": 16697,
"upload_time": "2025-08-17T13:30:12",
"upload_time_iso_8601": "2025-08-17T13:30:12.956612Z",
"url": "https://files.pythonhosted.org/packages/56/65/7e747b825acd15822f543af92911efa2fe36e1f7fa80e893c46229e354b3/coords_nsga2-2.3.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "4b36d1e2c2ad8edba662e02d8506c1ba166f2e182623927a6880a776a1c1bb22",
"md5": "924f2984f2439c959090b8d6901519c5",
"sha256": "5e88d937fc7f0f9ed3f9956235f7c171e6f442786808aaabe6c2859129ac4c4b"
},
"downloads": -1,
"filename": "coords_nsga2-2.3.0.tar.gz",
"has_sig": false,
"md5_digest": "924f2984f2439c959090b8d6901519c5",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.8",
"size": 271442,
"upload_time": "2025-08-17T13:30:13",
"upload_time_iso_8601": "2025-08-17T13:30:13.903030Z",
"url": "https://files.pythonhosted.org/packages/4b/36/d1e2c2ad8edba662e02d8506c1ba166f2e182623927a6880a776a1c1bb22/coords_nsga2-2.3.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-08-17 13:30:13",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "ZXF1001",
"github_project": "coords-nsga2",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "coords-nsga2"
}