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.
Metadata
Release files for morphantic-core 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| morphantic_core-0.1.1.tar.gz | 7.0 kB | Without provenance | Details for morphantic_core-0.1.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| morphantic_core-0.1.1-py3-none-any.whl | Python 3 | none | any | Details for morphantic_core-0.1.1-py3-none-any.whl |
Total release size: 13.4 kB
Release files / morphantic_core-0.1.1.tar.gz
| Download URL | morphantic_core-0.1.1.tar.gz |
|---|---|
| Size | 7.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
4f01fbc4291a4ed7d45115423042c62ab3aa62637c231c2e3eb2875686f76049
|
|
BLAKE2b-256 checksum How to use checksums |
f150801a544a4fdce34cc3eeb8404475976aefe86716c051fc0baf2ab8e13e8d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.8
|
Release files / morphantic_core-0.1.1-py3-none-any.whl
| Download URL | morphantic_core-0.1.1-py3-none-any.whl |
|---|---|
| Size | 6.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
15f83dab9472d5b6ab83da9df110813297bfaf8e827631247c38a69a3ce0c732
|
|
BLAKE2b-256 checksum How to use checksums |
babab473f15d57c8fc956b5d90a417a989d3cb2135e23ca1c6c55244f3d7d9da
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.8
|
Security for morphantic-core 0.1.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.