Skip to main content

No project description provided

Project description

Optirustic Py

This is a Python package that let users import serialised data from JSON files exported with the optirustic crate. It lets you:

  • import data into Python classes for easy manipulation;
  • calculate the population hyper-volume;
  • plot 2D, 3D or parallel coordinate charts of the Pareto front.

Installation

The package can be installed from Pypi:

pip install optirustic_py

Usage

These are two example scripts to fetch data and plot the Pareto fronts of the optirustic example files

Python API

All Python API are available in your editor via type hints:

from optirustic import NSGA3

# Load the NSGA3 data first
data = NSGA3(r"../examples/results/DTLZ1_3obj_NSGA3_gen400.json")

# Fetch the problem data
p = data.problem
print(p.number_of_variables)
print(p.variables)
# Fetch the lower bound of X!
print(p.variables["x1"].min_value)

# Get the objective stored into the problem
print(p.objectives)
# Fetch the direction of objective f1
print(p.objectives["f1"].direction)

# Fetch the problem constraints
print(p.constraints)

# Fetch other data such as the algorithm name or generation
print(f"Algorithm name: {data.algorithm}")
print(f"Population reached generation: {data.generation}")
print(f"Algorithm took: {data.took}")
print(f"JSOn file exported on: {data.exported_on}")

# Fetch data for the first individual
print(data.individuals[0])
print(data.individuals[0].constraint_violation)
print(f"Objective values: {data.individuals[0].objectives}")
print(f"Objective f2 value is: {data.individuals[0].get_objective_value("f2")}")
print(f"Variable values: {data.individuals[0].variables}")
print(f"Additional stored data: {data.individuals[0].data}")

# Calculate the hyper-volume
print(f"Hyper-volume is: {data.hyper_volume(reference_point=[100, 100, 100])}")

Generate Pareto front chart

import matplotlib.pyplot as plt
from optirustic import NSGA2, NSGA3

# Plot a 2D charts for a 2-objective problem
NSGA2(r"../examples/results/SCH_2obj_NSGA2_gen250.json").plot()
plt.show()

# Plot a 3D charts for a 3-objective problem
NSGA3(r"../examples/results/DTLZ1_3obj_NSGA3_gen400.json").plot()
plt.show()

# Plot a parallel coordinate chart for an 8-objective problem
NSGA3(r"../examples/results/DTLZ1_8obj_NSGA3_gen750.json").plot()
plt.show()

Generate convergence chart

This template script plots the algorithm convergence by calculating the hyper-volumes at different generations:

import matplotlib.pyplot as plt
from optirustic import NSGA2

# provide the folder where optimistic exported the JSON files
# and a reference point to use in the hyper-volume calculation
NSGA2.plot_convergence(
    folder=r"../examples/results/convergence",
    reference_point=[10000, 10000]
)
plt.show()

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

optirustic-0.2.0.tar.gz (114.5 kB view details)

Uploaded Source

Built Distribution

optirustic-0.2.0-cp312-cp312-macosx_11_0_arm64.whl (451.8 kB view details)

Uploaded CPython 3.12 macOS 11.0+ ARM64

File details

Details for the file optirustic-0.2.0.tar.gz.

File metadata

  • Download URL: optirustic-0.2.0.tar.gz
  • Upload date:
  • Size: 114.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: maturin/1.7.0

File hashes

Hashes for optirustic-0.2.0.tar.gz
Algorithm Hash digest
SHA256 85562977ed75c02102b4dfc4f685d2056dc26a4b509ab2786e3423633039fab0
MD5 9710fc84708ed15243db05094dc3dbf9
BLAKE2b-256 6454a979ba96d35b64a133a7be4f281cfd1eb79079b82b0af4aa858d0c4255ac

See more details on using hashes here.

File details

Details for the file optirustic-0.2.0-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for optirustic-0.2.0-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 50ad525e9e23b65d424eeefae38414da20e14848602c1387c9aa4608078d8d1d
MD5 7e15df8bcd8c7c77bcfafb51ac5aceb1
BLAKE2b-256 f24b35416fab9dfefed9ed939568615159e81d9ecf3ebd83e1b5dd270b29a367

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page