Skip to content

Commit 8923578

Browse files
authored
[Optimizer] Change the timeout type from int to double (#172)
1 parent 3058f8d commit 8923578

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

src/quartz/tasograph/tasograph.cpp

+5-5
Original file line numberDiff line numberDiff line change
@@ -1895,13 +1895,13 @@ std::shared_ptr<Graph> Graph::optimize_legacy(
18951895
// }
18961896
bestGraph->constant_and_rotation_elimination();
18971897
return bestGraph;
1898-
} // namespace quartz
1898+
}
18991899

19001900
std::shared_ptr<Graph>
19011901
Graph::optimize(Context *ctx, const std::string &equiv_file_name,
19021902
const std::string &circuit_name, bool print_message,
19031903
std::function<float(Graph *)> cost_function,
1904-
double cost_upper_bound, int timeout) {
1904+
double cost_upper_bound, double timeout) {
19051905
if (cost_function == nullptr) {
19061906
cost_function = [](Graph *graph) { return graph->total_cost(); };
19071907
}
@@ -1964,7 +1964,7 @@ std::shared_ptr<Graph>
19641964
Graph::optimize(const std::vector<GraphXfer *> &xfers, double cost_upper_bound,
19651965
const std::string &circuit_name,
19661966
const std::string &log_file_name, bool print_message,
1967-
std::function<float(Graph *)> cost_function, int timeout) {
1967+
std::function<float(Graph *)> cost_function, double timeout) {
19681968
if (cost_function == nullptr) {
19691969
cost_function = [](Graph *graph) { return graph->total_cost(); };
19701970
}
@@ -2041,8 +2041,8 @@ Graph::optimize(const std::vector<GraphXfer *> &xfers, double cost_upper_bound,
20412041
auto new_graph =
20422042
graph->apply_xfer(xfer, node, context->has_parameterized_gate());
20432043
auto end = std::chrono::steady_clock::now();
2044-
if ((int)std::chrono::duration_cast<std::chrono::milliseconds>(end -
2045-
start)
2044+
if ((double)std::chrono::duration_cast<std::chrono::milliseconds>(end -
2045+
start)
20462046
.count() /
20472047
1000.0 >
20482048
timeout) {

src/quartz/tasograph/tasograph.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ class Graph {
240240
const std::string &circuit_name, bool print_message,
241241
std::function<float(Graph *)> cost_function = nullptr,
242242
double cost_upper_bound = -1 /*default = current cost * 1.05*/,
243-
int timeout = 3600 /*1 hour*/);
243+
double timeout = 3600 /*1 hour*/);
244244
/**
245245
* Optimize this circuit.
246246
* @param xfers The circuit transformations.
@@ -258,7 +258,7 @@ class Graph {
258258
const std::string &circuit_name, const std::string &log_file_name,
259259
bool print_message,
260260
std::function<float(Graph *)> cost_function = nullptr,
261-
int timeout = 3600 /*1 hour*/);
261+
double timeout = 3600 /*1 hour*/);
262262
void constant_and_rotation_elimination();
263263
void rotation_merging(GateType target_rotation);
264264
std::string to_qasm(bool print_result = false, bool print_id = false) const;

0 commit comments

Comments
 (0)