Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Optimizer] Change the timeout type from int to double #172

Merged
merged 1 commit into from
Mar 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading