Morphantic Core: modular evolutionary optimization with safe exploration, drift guard, and Optuna integration.
Project description
Morphantic Optimizer Client SDK
This package provides a Python client for interacting with the Morphantic (Advanced Archipelago Evolution) Optimizer as a Service. It allows you to leverage the power of the Morphantic algorithm to solve complex, multi-objective optimization problems without exposing your proprietary evaluation logic.
How It Works
The Morphantic 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:
- You define your optimization problem using
ObjectiveSpecobjects. - You provide your
metrics_fn, which takes a solution vector and returns a dictionary of performance metrics. - When you call
client.optimize(), the SDK starts a temporary, local web server (a "worker") that wraps yourmetrics_fn. - The SDK sends the problem definition and the URL of your local worker to the Morphantic server.
- The Morphantic server runs the optimization, calling back to your worker to evaluate each candidate solution.
- 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 morphantic-core
Quickstart Example
Here is a simple example of optimizing a 2D function.
import numpy as np
from Morphantic_client import MorphanticClient, 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
Morphantic_SERVER_URL = "https://testserver.morphantic.com"
client = MorphanticClient(server_url=Morphantic_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
MorphanticClient(server_url: str)
The main client class.
client.optimize(...)
Starts and manages an optimization job.
Arguments:
objectives(List[ObjectiveSpec]): A list ofObjectiveSpecobjects 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 to8081.worker_host(str, optional): The public IP or hostname of the machine running the client. Required for non-local servers (e.g., cloud, Docker). IfNone, a local IP is auto-detected.pop_size,max_generations,n_islands,seed: Standard parameters to configure the Morphantic optimizer.poll_interval(int, optional): Seconds to wait between polling for results. Defaults to10.
Returns:
A dictionary containing the final job status, best solution, and final metrics.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file morphantic_core-0.1.1.tar.gz.
File metadata
- Download URL: morphantic_core-0.1.1.tar.gz
- Upload date:
- Size: 7.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4f01fbc4291a4ed7d45115423042c62ab3aa62637c231c2e3eb2875686f76049
|
|
| MD5 |
388af36d5669364e4e4c208e83ed07a3
|
|
| BLAKE2b-256 |
f150801a544a4fdce34cc3eeb8404475976aefe86716c051fc0baf2ab8e13e8d
|
File details
Details for the file morphantic_core-0.1.1-py3-none-any.whl.
File metadata
- Download URL: morphantic_core-0.1.1-py3-none-any.whl
- Upload date:
- Size: 6.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
15f83dab9472d5b6ab83da9df110813297bfaf8e827631247c38a69a3ce0c732
|
|
| MD5 |
8b3f8bbc18a5ae9c976c74678812a98d
|
|
| BLAKE2b-256 |
babab473f15d57c8fc956b5d90a417a989d3cb2135e23ca1c6c55244f3d7d9da
|