官方示例代码个人运行报错

13147086285
2025-04-20 17:52:29

代码:

import numpy as np
import kaiwu as kw

# Import the plotting library
import matplotlib.pyplot as plt

# invert input graph matrix
matrix = -np.array([
[0, 1, 0, 1, 1, 0, 0, 1, 1, 0],
[1, 0, 1, 0, 0, 1, 1, 1, 0, 0],
[0, 1, 0, 1, 1, 0, 0, 0, 1, 0],
[1, 0, 1, 0, 0, 1, 1, 0 ,1, 0],
[1, 0, 1, 0, 0, 1, 0, 1, 0, 1],
[0, 1, 0, 1, 1, 0, 0, 0, 1, 1],
[0, 1, 0, 1, 0, 0, 0, 0, 0, 1],
[1, 1, 0, 0, 1, 0, 0, 0, 1, 0],
[1, 0, 1, 1, 0, 1, 0, 1, 0, 1],
[0, 0, 0, 0, 1, 1, 1, 0, 1, 0]])
worker = kw.classical.SimulatedAnnealingOptimizer(initial_temperature=100,
alpha=0.99,
cutoff_temperature=0.001,
iterations_per_t=10,
size_limit=100)
output = worker.solve(matrix)
opt = kw.sampler.optimal_sampler(matrix, output, 0)
best = opt[0][0]
max_cut = (np.sum(-matrix)-np.dot(-matrix,best).dot(best))/4
print("The obtained max cut is " + str(max_cut) + ".")


报错:
Traceback (most recent call last):
  File "E:\pythonwork\p1\MPB\Main.py", line 24, in <module>
    output = worker.solve(matrix)
  File "target\kaiwu\classical\_simulated_annealing.py", line 184, in kaiwu.classical._simulated_annealing.SimulatedAnnealingOptimizer.solve
  File "target\kaiwu\common\_util.py", line 112, in kaiwu.common._util.track_data.decorator.wrapper
  File "E:\pythonwork\p1\MPB\.venv\lib\site-packages\nest_asyncio.py", line 98, in run_until_complete
    return f.result()
  File "C:\Users\20494\AppData\Local\Programs\Python\Python38\lib\asyncio\futures.py", line 178, in result
    raise self._exception
  File "C:\Users\20494\AppData\Local\Programs\Python\Python38\lib\asyncio\tasks.py", line 280, in __step
    result = coro.send(None)
  File "target\kaiwu\common\_util.py", line 101, in async_workflow
  File "target\kaiwu\common\_util.py", line 81, in kaiwu.common._util.track_data.decorator.wrapper.async_workflow
  File "target\kaiwu\classical\_simulated_annealing.py", line 117, in kaiwu.classical._simulated_annealing.SimulatedAnnealingOptimizer.single_process_solve
  File "target\kaiwu\license\_license_utils.py", line 145, in kaiwu.license._license_utils.verify_license
ValueError: Please follow the tutorial to generate the license first. If there is no sdk authorization code, please log in to platform.qboson.com for support.


49
0
1
0
最新回答
13147086285 2025-04-20 17:55:58

贴错了 代码和报错是这个

关于作者
在本版发帖返回顶部
快速回复 返回顶部 返回列表
玻色有奖小调研
填写问卷,将免费赠送您5个100bit真机配额
(单选) 您是从哪个渠道得知我们的?*
您是从哪个社交媒体得知我们的?*
您是通过哪个学校的校园宣讲得知我们的呢?
取消

提交成功

真机配额已发放到您的账户,可前往【云平台】查看