Kaiwu SDK Enterprise
Kaiwu SDK Enterprise is a Python SDK for building and solving QUBO and Ising optimization problems with Kaiwu classical optimizers and CIM services.
This package is the enterprise distribution. A valid license is required before using licensed features.
Requirements
- Python >= 3.10
- Windows, Linux, or macOS
Installation
- Python 3.10 https://www.python.org/downloads/release/python-31011/ 。
- pip3 install -i https://mirrors.aliyun.com/pypi/simple -r requirements/devel.txt
pip install kaiwu
Install a specific version:
pip install kaiwu==1.4.3
Quick Start
Solve an Ising Matrix
import numpy as np
import kaiwu as kw
matrix = -np.array(
[
[0.0, 1.0, 0.0, 1.0, 1.0],
[1.0, 0.0, 0.0, 1.0, 1.0],
[0.0, 0.0, 0.0, 1.0, 1.0],
[1.0, 1.0, 1.0, 0.0, 1.0],
[1.0, 1.0, 1.0, 1.0, 0.0],
]
)
optimizer = kw.classical.SimulatedAnnealingOptimizer(
initial_temperature=100,
alpha=0.99,
cutoff_temperature=0.001,
iterations_per_t=10,
size_limit=10,
)
solutions = optimizer.solve(matrix)
print(solutions)
Solve a QUBO Matrix
solve_qubo() accepts a QuboModel. If you already have a QUBO matrix, convert it first:
import numpy as np
import kaiwu as kw
qubo_matrix = -np.array(
[
[0.0, -1.0, 0.0, 1.0, 1.0],
[-1.0, 0.0, 0.0, 1.0, 1.0],
[0.0, 0.0, 0.0, 1.0, 1.0],
[1.0, 1.0, 1.0, 0.0, 1.0],
[1.0, 1.0, 1.0, 1.0, 0.0],
]
)
# QUBO matrix conversion uses the upper-triangular convention.
qubo_model = kw.core.qubo_matrix_to_qubo_model(np.triu(qubo_matrix))
optimizer = kw.classical.SimulatedAnnealingOptimizer(
initial_temperature=100,
alpha=0.99,
cutoff_temperature=0.001,
iterations_per_t=10,
size_limit=10,
)
solution, objective = optimizer.solve_qubo(qubo_model)
print(solution)
print(objective)
Use CIMOptimizer
CIMOptimizer submits or queries CIM tasks. Set a checkpoint directory before creating the optimizer.
import numpy as np
import kaiwu as kw
kw.common.CheckpointManager.save_dir = "tmp"
qubo_matrix = np.array(
[
[0.0, 1.0, 0.0],
[0.0, 0.0, -2.0],
[0.0, 0.0, 0.0],
]
)
qubo_model = kw.core.qubo_matrix_to_qubo_model(np.triu(qubo_matrix))
optimizer = kw.cim.CIMOptimizer(
task_name="qubo_cim_example",
wait=False,
task_mode=kw.cim.TaskMode.OPTIMIZATION,
)
solution, objective = optimizer.solve_qubo(qubo_model)
print(solution, objective)
When wait=False, unfinished tasks may return (None, None). Use wait=True if the program should wait for the task result.
Main Modules
kaiwu.classical: classical optimizers, including simulated annealing, tabu search, and brute force searchkaiwu.cim: CIM task optimizer and task modeskaiwu.preprocess: matrix precision analysis and precision reduction toolskaiwu.hybrid: hybrid optimization toolskaiwu.sampler: sampler implementationskaiwu.hobo: higher-order binary optimization tools
Logging
Enable debug logs when needed:
import kaiwu as kw
kw.common.set_log_level("DEBUG")
Metadata
Release files for kaiwu 1.4.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Built distributions (wheels)
| File | Reset | |||
|---|---|---|---|---|
| kaiwu-1.4.3-cp310-none-win_amd64.whl | CPython 3.10 | none | Windows x86-64 | Details |
| kaiwu-1.4.3-cp310-none-manylinux1_x86_64.whl | CPython 3.10 | none | Linux glibc 2.5+ x86-64 | Details |
| kaiwu-1.4.3-cp310-none-macosx_12_0_arm64.whl | CPython 3.10 | none | macOS 12.0+ ARM64 | Details |
| kaiwu-1.4.3-cp310-none-macosx_10_15_x86_64.whl | CPython 3.10 | none | macOS 10.15+ x86-64 | Details |
Total release size: 2.9 MB
Release files / kaiwu-1.4.3-cp310-none-win_amd64.whl
| Download URL | kaiwu-1.4.3-cp310-none-win_amd64.whl |
|---|---|
| Size | 656.6 kB |
| Tags | CPython 3.10 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
b06bd14d0967a66e31e332f98f72d0afc84c67e937a9fc97d22d101e644408a1
|
|
BLAKE2b-256 checksum How to use checksums |
c6ec78aea672c657bd1a99608251d1c0ce69f74c02c6644089d0c784fdc984ed
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.10.20
|
Release files / kaiwu-1.4.3-cp310-none-manylinux1_x86_64.whl
| Download URL | kaiwu-1.4.3-cp310-none-manylinux1_x86_64.whl |
|---|---|
| Size | 854.8 kB |
| Tags | CPython 3.10 Linux glibc 2.5+ x86-64 |
|
SHA-256 checksum How to use checksums |
4496dcce20604198a957385f80ba1dca35381b250e850908f3012472d55a993d
|
|
BLAKE2b-256 checksum How to use checksums |
bfbf4ad947cf333e53b9b48502f4069f61522ade5a968e2100cfc26235a27459
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.10.20
|
Release files / kaiwu-1.4.3-cp310-none-macosx_12_0_arm64.whl
| Download URL | kaiwu-1.4.3-cp310-none-macosx_12_0_arm64.whl |
|---|---|
| Size | 705.5 kB |
| Tags | CPython 3.10 macOS 12.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
5a2fc43d7c9e54f56393fd08478a9d3969e7734961d398eff6d0a43974fe6370
|
|
BLAKE2b-256 checksum How to use checksums |
cf623e7ad2ce8a25b41f6e9e38a2088bd303acf1ae09bcf28c1ffea5c8a559a5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.10.20
|
Release files / kaiwu-1.4.3-cp310-none-macosx_10_15_x86_64.whl
| Download URL | kaiwu-1.4.3-cp310-none-macosx_10_15_x86_64.whl |
|---|---|
| Size | 707.0 kB |
| Tags | CPython 3.10 macOS 10.15+ x86-64 |
|
SHA-256 checksum How to use checksums |
cf498377cfaf099ecab8f4ede9a5cd8081d3b67dcb80ca40d43ad277b43bd93b
|
|
BLAKE2b-256 checksum How to use checksums |
5dedbf825a3e9232ec59e74958389d0e77eb2cc06517f9739c7fda9eac9d1b41
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.10.20
|