@@ -85,6 +85,7 @@ void RepairSetup::init()
8585bool RepairSetup::repairSetup (const float setup_slack_margin,
8686 const double repair_tns_end_percent,
8787 const int max_passes,
88+ int max_iterations,
8889 const int max_repairs_per_pass,
8990 const bool verbose,
9091 const std::vector<MoveType>& sequence,
@@ -448,6 +449,9 @@ bool RepairSetup::repairSetup(const float setup_slack_margin,
448449 end = worst_vertex;
449450 }
450451 pass++;
452+ if (max_iterations > 0 && opto_iteration >= max_iterations) {
453+ break ;
454+ }
451455 } // while pass <= max_passes
452456 if (verbose || opto_iteration == 1 ) {
453457 printProgress (opto_iteration, true , false , false , num_viols);
@@ -459,6 +463,9 @@ bool RepairSetup::repairSetup(const float setup_slack_margin,
459463 // clang-format on
460464 break ;
461465 }
466+ if (max_iterations > 0 && opto_iteration >= max_iterations) {
467+ break ;
468+ }
462469 } // for each violating endpoint
463470
464471 if (!skip_last_gasp) {
@@ -473,7 +480,7 @@ bool RepairSetup::repairSetup(const float setup_slack_margin,
473480 skip_vt_swap);
474481 params.iteration = opto_iteration;
475482 params.initial_tns = initial_tns;
476- repairSetupLastGasp (params, num_viols);
483+ repairSetupLastGasp (params, num_viols, max_iterations );
477484 }
478485
479486 if (!skip_crit_vt_swap && !skip_vt_swap
@@ -865,7 +872,9 @@ bool RepairSetup::terminateProgress(const int iteration,
865872
866873// Perform some last fixing based on sizing only.
867874// This is a greedy opto that does not degrade WNS or TNS.
868- void RepairSetup::repairSetupLastGasp (const OptoParams& params, int & num_viols)
875+ void RepairSetup::repairSetupLastGasp (const OptoParams& params,
876+ int & num_viols,
877+ int max_iterations)
869878{
870879 move_sequence.clear ();
871880 if (!params.skip_vt_swap ) {
@@ -926,6 +935,10 @@ void RepairSetup::repairSetupLastGasp(const OptoParams& params, int& num_viols)
926935 float fix_rate_threshold = inc_fix_rate_threshold_;
927936
928937 for (const auto & end_original_slack : violating_ends) {
938+ if (max_iterations > 0 && opto_iteration >= max_iterations) {
939+ break ;
940+ }
941+
929942 fallback_ = false ;
930943 Vertex* end = end_original_slack.first ;
931944 Slack end_slack = sta_->vertexSlack (end, max_);
@@ -1015,6 +1028,9 @@ void RepairSetup::repairSetupLastGasp(const OptoParams& params, int& num_viols)
10151028 end = worst_vertex;
10161029 }
10171030 pass++;
1031+ if (max_iterations > 0 && opto_iteration >= max_iterations) {
1032+ break ;
1033+ }
10181034 } // while pass <= max_last_gasp_passes_
10191035 if (params.verbose || opto_iteration == 1 ) {
10201036 printProgress (opto_iteration, true , false , true , num_viols);
0 commit comments