Skip to content

Commit

Permalink
[Optimizer] Change the timeout type from int to double (#172)
Browse files Browse the repository at this point in the history
  • Loading branch information
xumingkuan authored Mar 13, 2024
1 parent 3058f8d commit 8923578
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
10 changes: 5 additions & 5 deletions src/quartz/tasograph/tasograph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1895,13 +1895,13 @@ std::shared_ptr<Graph> Graph::optimize_legacy(
// }
bestGraph->constant_and_rotation_elimination();
return bestGraph;
} // namespace quartz
}

std::shared_ptr<Graph>
Graph::optimize(Context *ctx, const std::string &equiv_file_name,
const std::string &circuit_name, bool print_message,
std::function<float(Graph *)> cost_function,
double cost_upper_bound, int timeout) {
double cost_upper_bound, double timeout) {
if (cost_function == nullptr) {
cost_function = [](Graph *graph) { return graph->total_cost(); };
}
Expand Down Expand Up @@ -1964,7 +1964,7 @@ std::shared_ptr<Graph>
Graph::optimize(const std::vector<GraphXfer *> &xfers, double cost_upper_bound,
const std::string &circuit_name,
const std::string &log_file_name, bool print_message,
std::function<float(Graph *)> cost_function, int timeout) {
std::function<float(Graph *)> cost_function, double timeout) {
if (cost_function == nullptr) {
cost_function = [](Graph *graph) { return graph->total_cost(); };
}
Expand Down Expand Up @@ -2041,8 +2041,8 @@ Graph::optimize(const std::vector<GraphXfer *> &xfers, double cost_upper_bound,
auto new_graph =
graph->apply_xfer(xfer, node, context->has_parameterized_gate());
auto end = std::chrono::steady_clock::now();
if ((int)std::chrono::duration_cast<std::chrono::milliseconds>(end -
start)
if ((double)std::chrono::duration_cast<std::chrono::milliseconds>(end -
start)
.count() /
1000.0 >
timeout) {
Expand Down
4 changes: 2 additions & 2 deletions src/quartz/tasograph/tasograph.h
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ class Graph {
const std::string &circuit_name, bool print_message,
std::function<float(Graph *)> cost_function = nullptr,
double cost_upper_bound = -1 /*default = current cost * 1.05*/,
int timeout = 3600 /*1 hour*/);
double timeout = 3600 /*1 hour*/);
/**
* Optimize this circuit.
* @param xfers The circuit transformations.
Expand All @@ -258,7 +258,7 @@ class Graph {
const std::string &circuit_name, const std::string &log_file_name,
bool print_message,
std::function<float(Graph *)> cost_function = nullptr,
int timeout = 3600 /*1 hour*/);
double timeout = 3600 /*1 hour*/);
void constant_and_rotation_elimination();
void rotation_merging(GateType target_rotation);
std::string to_qasm(bool print_result = false, bool print_id = false) const;
Expand Down

0 comments on commit 8923578

Please sign in to comment.