|
20 | 20 |
|
21 | 21 | namespace cudaq { |
22 | 22 |
|
23 | | -/// Form the SerializedCodeExecutionContext |
24 | | -// static SerializedCodeExecutionContext |
25 | | -// get_serialized_code(std::string &source_code) { |
26 | | -// SerializedCodeExecutionContext ctx; |
27 | | -// try { |
28 | | -// py::object json = py::module_::import("json"); |
29 | | -// auto var_dict = get_serializable_var_dict(); |
30 | | -// ctx.scoped_var_dict = py::str(json.attr("dumps")(var_dict)); |
31 | | -// ctx.source_code = source_code; |
32 | | -// } catch (py::error_already_set &e) { |
33 | | -// throw std::runtime_error("Failed to serialized data: " + |
34 | | -// std::string(e.what())); |
35 | | -// } |
36 | | -// return ctx; |
37 | | -// } |
38 | | - |
39 | | -// static std::string |
40 | | -// get_required_raw_source_code(const int dim, const py::function &func, |
41 | | -// const std::string &optimizer_var_name) { |
42 | | -// // Get source code and remove the leading whitespace |
43 | | -// std::string source_code = get_source_code(func); |
44 | | - |
45 | | -// // Form the Python call to optimizer.optimize |
46 | | -// std::ostringstream os; |
47 | | -// auto obj_func_name = func.attr("__name__").cast<std::string>(); |
48 | | -// os << "energy, params_at_energy = " << optimizer_var_name << ".optimize(" |
49 | | -// << dim << ", " << obj_func_name << ")\n"; |
50 | | -// // The _json_request_result dictionary is a special dictionary where |
51 | | -// outputs |
52 | | -// // are saved. Must be serializable to JSON using the JSON structures. |
53 | | -// os << "_json_request_result['executionContext']['optResult'] = [energy, " |
54 | | -// "params_at_energy]\n"; |
55 | | -// auto function_call = os.str(); |
56 | | - |
57 | | -// // Return the combined code |
58 | | -// return source_code + "\n" + function_call; |
59 | | -// } |
60 | | - |
61 | 23 | /// @brief Bind the `cudaq::optimization_result` typedef. |
62 | 24 | void bindOptimizationResult(py::module &mod) { |
63 | 25 | py::class_<optimization_result>(mod, "OptimizationResult"); |
|
0 commit comments