Skip to content

Commit

Permalink
Release 0.0.1
Browse files Browse the repository at this point in the history
  • Loading branch information
rohanmohapatra committed May 8, 2021
1 parent 64c7fe5 commit bf4fe95
Show file tree
Hide file tree
Showing 14 changed files with 65 additions and 28 deletions.
9 changes: 8 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,9 @@
.idea
**/__pycache__
**/__pycache__

# Setuptools distribution folder.
/dist/
/build/

# Python egg metadata, regenerated from source files by setuptools.
/*.egg-info
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2021 Rohan Mohapatra

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
8 changes: 4 additions & 4 deletions examples/cubic_optimization.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
# Integration Test
import torch

from swarmoptimizer import SwarmOptimizer
from torchswarm.swarmoptimizer import SwarmOptimizer


class CubicFunction:
def evaluate(self, x):
return x ** 2 + torch.exp(x)

pso = SwarmOptimizer(1, 100, swarm_optimizer_type="exponentially_weighted", max_iterations=10)
pso.optimize(CubicFunction())
empso = SwarmOptimizer(1, 100, swarm_optimizer_type="exponentially_weighted", max_iterations=10)
empso.optimize(CubicFunction())

print(pso.run(verbosity=True).__dict__)
print(empso.run(verbosity=True).__dict__)
23 changes: 23 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
from setuptools import setup, find_packages

with open("README.md", "r") as fh:
long_description = fh.read()

setup(
name='torchswarm',
version='0.0.1',
description='A fast implementation of Particle Swarm Optimization using PyTorch',
url='https://github.com/rohanmohapatra/torchswarm',
author='Rohan Mohapatra',
license='MIT',
install_requires=['torch'],
long_description=long_description,
long_description_content_type="text/markdown",
classifiers=[
"Programming Language :: Python :: 3",
"License :: OSI Approved :: MIT License",
"Operating System :: OS Independent",
],
packages=find_packages(),
python_requires=">=3.6",
)
14 changes: 0 additions & 14 deletions tests/__init__.py

This file was deleted.

File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions particle/__init__.py → torchswarm/particle/__init__.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import torch
import numpy as np

from utils.rotation_utils import get_rotation_matrix, get_inverse_matrix, get_phi_matrix
from utils.parameters import SwarmParameters
from torchswarm.utils.rotation_utils import get_rotation_matrix, get_inverse_matrix, get_phi_matrix
from torchswarm.utils.parameters import SwarmParameters


class Particle:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from particle import Particle, RotatedParticle, ExponentiallyWeightedMomentumParticle, RotatedEWMParticle
from torchswarm.particle import Particle, RotatedParticle, ExponentiallyWeightedMomentumParticle, RotatedEWMParticle


def get_particle_instance(swarm_optimizer_type):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
import torch
import copy

from particle.particle_factory import get_particle_instance
from utils.parameters import SwarmParameters
from torchswarm.particle.particle_factory import get_particle_instance
from torchswarm.utils.parameters import SwarmParameters

class SwarmOptimizer:
def __init__(self, dimensions, swarm_size, swarm_optimizer_type="standard", particle=None, **kwargs):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

import torch

from particle import Particle, ExponentiallyWeightedMomentumParticle
from swarmoptimizer import SwarmOptimizer
from utils.parameters import SwarmParameters
from utils.rotation_utils import get_rotation_matrix, get_inverse_matrix, get_phi_matrix
from torchswarm.particle import Particle, ExponentiallyWeightedMomentumParticle
from torchswarm.swarmoptimizer import SwarmOptimizer
from torchswarm.utils.parameters import SwarmParameters
from torchswarm.utils.rotation_utils import get_rotation_matrix, get_inverse_matrix, get_phi_matrix
import numpy as np


Expand Down
Empty file added torchswarm/utils/__init__.py
Empty file.
File renamed without changes.
File renamed without changes.

0 comments on commit bf4fe95

Please sign in to comment.