Skip to main content

Morphantic Core: modular evolutionary optimization with safe exploration, drift guard, and Optuna integration.

Project description

AEA Optimizer Client SDK

This package provides a Python client for interacting with the AEA (Advanced Archipelago Evolution) Optimizer as a Service. It allows you to leverage the power of the AEA algorithm to solve complex, multi-objective optimization problems without exposing your proprietary evaluation logic.

How It Works

The AEA Optimizer runs on a remote server, while your proprietary evaluation function (the metrics_fn) runs securely on your own machine. The client SDK facilitates this interaction through a secure callback mechanism:

  1. You define your optimization problem using ObjectiveSpec objects.
  2. You provide your metrics_fn, which takes a solution vector and returns a dictionary of performance metrics.
  3. When you call client.optimize(), the SDK starts a temporary, local web server (a "worker") that wraps your metrics_fn.
  4. The SDK sends the problem definition and the URL of your local worker to the AEA server.
  5. The AEA server runs the optimization, calling back to your worker to evaluate each candidate solution.
  6. Once complete, the SDK retrieves the final result and shuts down the local worker.

This ensures your intellectual property (the metrics_fn) never leaves your infrastructure.

Installation

pip install aea-optimizer-client

Quickstart Example

Here is a simple example of optimizing a 2D function.

import numpy as np
from aea_client import AEAClient, ObjectiveSpec

# 1. Define your proprietary metrics function
def my_metrics_fn(x: np.ndarray) -> dict:
    # Objective 1: Minimize a sphere function
    cost = np.sum(x**2)
    # Objective 2: Maximize a linear function
    performance = np.sum(x)
    return {"cost": cost, "performance": performance}

# 2. Define your objectives for the API
objectives = [
    ObjectiveSpec(name="cost", weight=0.7, baseline=50.0, target=0.1, direction="min"),
    ObjectiveSpec(name="performance", weight=0.3, baseline=0.0, target=10.0, direction="max")
]

# 3. Initialize the client and run the optimization
# Replace with your production server URL
AEA_SERVER_URL = "http://api.your-aea-service.com"
client = AEAClient(server_url=AEA_SERVER_URL)

# Note: For cloud/Docker environments, you must provide your public IP
# via the `worker_host` argument.
final_result = client.optimize(
    objectives=objectives,
    metrics_fn=my_metrics_fn,
    dimension=2,
    bounds=(-5.0, 5.0),
    max_generations=50,
    pop_size=100
)

print(final_result)

API Reference

AEAClient(server_url: str)

The main client class.

client.optimize(...)

Starts and manages an optimization job.

Arguments:

  • objectives (List[ObjectiveSpec]): A list of ObjectiveSpec objects defining the problem.
  • metrics_fn (Callable): Your evaluation function. Must accept a NumPy array and return a dictionary of metrics.
  • dimension (int): The number of parameters in your solution vector.
  • bounds (Tuple[float, float]): The (min, max) bounds for each parameter.
  • worker_port (int, optional): The local port for the callback worker. Defaults to 8081.
  • worker_host (str, optional): The public IP or hostname of the machine running the client. Required for non-local servers (e.g., cloud, Docker). If None, a local IP is auto-detected.
  • pop_size, max_generations, n_islands, seed: Standard parameters to configure the AEA optimizer.
  • poll_interval (int, optional): Seconds to wait between polling for results. Defaults to 10.

Returns:

A dictionary containing the final job status, best solution, and final metrics.

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

morphantic_core-0.1.0.tar.gz (9.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

morphantic_core-0.1.0-py3-none-any.whl (8.4 kB view details)

Uploaded Python 3

File details

Details for the file morphantic_core-0.1.0.tar.gz.

File metadata

  • Download URL: morphantic_core-0.1.0.tar.gz
  • Upload date:
  • Size: 9.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.8

File hashes

Hashes for morphantic_core-0.1.0.tar.gz
Algorithm Hash digest
SHA256 c354a23b6a49665009c68e32f94addaee458c2bed6f8205df6620400dda45729
MD5 853ea1c25a8466019392676e7441ac58
BLAKE2b-256 8a7560655f0910a8469fe256a075c4746bec50711e26d5e1e5a6da108a988ffc

See more details on using hashes here.

File details

Details for the file morphantic_core-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for morphantic_core-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 3b21d389eed3a589394bd19f5997695ebb6a3fa768f9b41b756a4ec988952208
MD5 c09b4738ec4517e9ec3f913a0a7535d1
BLAKE2b-256 30dcf2a842e9b1d738f647b855ac1f77b33d21c8c2c717c123cb381c98e544b6

See more details on using hashes here.

Supported by

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