Skip to content

Commit a974573

Browse files
committed
Add test: task_scheduling_problem
1 parent ef084a4 commit a974573

File tree

2 files changed

+35
-8
lines changed

2 files changed

+35
-8
lines changed

applications/logistics/task_scheduling_problem/task_scheduling_problem.ipynb

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1501,16 +1501,16 @@
15011501
"\n",
15021502
"optimizer_config = OptimizerConfig(max_iteration=1, alpha_cvar=0.6)\n",
15031503
"\n",
1504-
"qmod = construct_combinatorial_optimization_model(\n",
1504+
"qmod_large = construct_combinatorial_optimization_model(\n",
15051505
" pyo_model=tasks_model_large,\n",
15061506
" qaoa_config=qaoa_config,\n",
15071507
" optimizer_config=optimizer_config,\n",
15081508
")\n",
15091509
"\n",
1510-
"qmod = set_execution_preferences(\n",
1511-
" qmod, backend_preferences=ClassiqBackendPreferences(backend_name=\"simulator\")\n",
1510+
"qmod_large = set_execution_preferences(\n",
1511+
" qmod_large, backend_preferences=ClassiqBackendPreferences(backend_name=\"simulator\")\n",
15121512
")\n",
1513-
"write_qmod(qmod, \"task_scheduling_problem_large\")"
1513+
"write_qmod(qmod_large, \"task_scheduling_problem_large\")"
15141514
]
15151515
},
15161516
{
@@ -1539,8 +1539,8 @@
15391539
}
15401540
],
15411541
"source": [
1542-
"qprog = synthesize(qmod)\n",
1543-
"show(qprog)"
1542+
"qprog_large = synthesize(qmod_large)\n",
1543+
"show(qprog_large)"
15441544
]
15451545
},
15461546
{
@@ -1558,7 +1558,7 @@
15581558
},
15591559
"outputs": [],
15601560
"source": [
1561-
"result = execute(qprog).result_value()"
1561+
"result_large = execute(qprog_large).result_value()"
15621562
]
15631563
},
15641564
{
@@ -1688,7 +1688,7 @@
16881688
"\n",
16891689
"solution = get_optimization_solution_from_pyo(\n",
16901690
" tasks_model_large,\n",
1691-
" vqe_result=result,\n",
1691+
" vqe_result=result_large,\n",
16921692
" penalty_energy=qaoa_config.penalty_energy,\n",
16931693
")\n",
16941694
"optimization_result = pd.DataFrame.from_records(solution)\n",
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
from tests.utils_for_testbook import (
2+
validate_quantum_program_size,
3+
validate_quantum_model,
4+
wrap_testbook,
5+
)
6+
from testbook.client import TestbookNotebookClient
7+
8+
9+
@wrap_testbook("task_scheduling_problem", timeout_seconds=840)
10+
def test_notebook(tb: TestbookNotebookClient) -> None:
11+
# test models
12+
validate_quantum_model(tb.ref("qmod"))
13+
validate_quantum_model(tb.ref("qmod_large"))
14+
# test quantum programs
15+
validate_quantum_program_size(
16+
tb.ref("qprog"),
17+
expected_width=8, # actual width: 6
18+
expected_depth=120, # actual depth: 92
19+
)
20+
validate_quantum_program_size(
21+
tb.ref("qprog_large"),
22+
expected_width=30, # actual width: 24
23+
expected_depth=500, # actual depth: 428
24+
)
25+
26+
# test notebook content
27+
pass # todo

0 commit comments

Comments
 (0)