@@ -36,7 +36,14 @@ Graphics::Graphics(bool coarse,
3636 block_(block),
3737 logger_(logger)
3838{
39- gui::Gui::get ()->registerRenderer (this );
39+ gui::Gui* gui = gui::Gui::get ();
40+ gui->registerRenderer (this );
41+
42+ // Setup the chart
43+ chart_ = gui->addChart (" MPL" , " Iteration" , {" Area" , " Outline" , " WireLength" });
44+ chart_->setXAxisFormat (" %d" );
45+ chart_->setYAxisFormats ({" %.2e" , " %.2e" , " %.2e" });
46+ chart_->setYAxisMin ({0 , 0 , 0 });
4047}
4148
4249void Graphics::startCoarse ()
@@ -49,7 +56,9 @@ void Graphics::startFine()
4956 active_ = fine_;
5057}
5158
52- void Graphics::startSA ()
59+ void Graphics::startSA (const char * type,
60+ const int max_num_step,
61+ const int num_perturb_per_step)
5362{
5463 if (!active_) {
5564 return ;
@@ -63,9 +72,14 @@ void Graphics::startSA()
6372 return ;
6473 }
6574
66- logger_->report (" ------ Start ------" );
75+ logger_->report (" ------ Start {} ------" , type);
76+ logger_->report (" max_num_step = {} num_perturb_per_step = {}" ,
77+ max_num_step,
78+ num_perturb_per_step);
6779 best_norm_cost_ = std::numeric_limits<float >::max ();
6880 skipped_ = 0 ;
81+ chart_->clearPoints ();
82+ iter_ = 0 ;
6983}
7084
7185void Graphics::endSA (const float norm_cost)
@@ -85,7 +99,7 @@ void Graphics::endSA(const float norm_cost)
8599 if (skipped_ > 0 ) {
86100 logger_->report (" Skipped to end: {}" , skipped_);
87101 }
88- logger_->report (" ------ End ------" );
102+ logger_->report (" ------ End (Iter {}) ------" , iter_ );
89103 report (norm_cost);
90104 gui::Gui::get ()->pause ();
91105}
@@ -195,6 +209,7 @@ void Graphics::penaltyCalculated(float norm_cost)
195209 if (!active_) {
196210 return ;
197211 }
212+ iter_++;
198213
199214 if (is_skipping_) {
200215 return ;
@@ -207,7 +222,13 @@ void Graphics::penaltyCalculated(float norm_cost)
207222 bool drawing_last_step = skip_steps_ && !is_skipping_;
208223
209224 if (norm_cost < best_norm_cost_ || drawing_last_step) {
210- logger_->report (" ------ Penalty ------" );
225+ const float area = area_penalty_ ? area_penalty_.value ().value : 0 ;
226+ const float outline = outline_penalty_ ? outline_penalty_.value ().value : 0 ;
227+ const float wirelength
228+ = wirelength_penalty_ ? wirelength_penalty_.value ().value : 0 ;
229+ chart_->addPoint (iter_, {area, outline, wirelength});
230+
231+ logger_->report (" ------ Penalty (Iter {}) ------" , iter_);
211232 report (norm_cost);
212233
213234 if (skipped_ > 0 ) {
0 commit comments