Skip to main content

Introduction

With the rapid advancements in compute, the need for a comprehensive toolkit that bridges various optimization is evident. The strangeworks-optimization Python SDK addresses this by offering a seamless interface to tap into a myriad of optimization backends, both simulated and physical.

Overview

Strangeworks delivers an optimization platform designed for developers, aiming to harness the power of quantum inspired algorithms across diverse backend systems. This SDK encapsulates various optimization tasks. The abstraction layer ensures a hassle-free experience for users while retaining the freedom to pick the most appropriate backend for any given task.

Usage

Prerequisites

  1. Python 3.10: Ensure you have Python 3.10 installed.
  2. Virtual Environments: Be familiar with setting up and using virtual environments.

Installation

pip install -U pip && pip install strangeworks-optimization

Authentication

Before you start making API calls, you'll need to authenticate your requests. To do this, you'll use an API key.

Getting Your API Key

Once you have created your account with Strangeworks, navigate to your profile settings. Under the Portal homepage, you'll find your unique API key.

Your API key is associated with the workspace you are currently using. If your account is associated with multiple workspaces please ensure you are using the correct API key.

Setting Up Your API Key

import strangeworks as sw
sw.authenticate('YOUR_API_KEY')

Warning: Keep your API key secure. Avoid hardcoding it directly into scripts, especially if you're pushing to public repositories. Consider using environment variables or secret management tools.

Resources

In the Strangeworks portal, activate the Optimization Service to create a resource.

Most users will only have a single optimization resource, in which case it is not necessary to specify the resource when creating the optimizer.

Throughout the rest of this tutorial, we will assume that you have a single optimization resource.

Multiple resources

If you have multiple optimization resources, simply specify the resource_slug when creating the optimizer:

from strangeworks_optimization import StrangeworksOptimizer

optimizer = StrangeworksOptimizer(
model=model, solver=solver, resource_slug=resource_slug
)

Note: This may be useful if you are managing multiple resources or if you are using the SDK in a multi-user environment.