Skip to content

Commit 1cd2d60

Browse files
committed
mpl: ignore fixed objects in boundary penalty computation
and format Signed-off-by: Arthur Koucher <[email protected]>
1 parent 0e30391 commit 1cd2d60

File tree

2 files changed

+21
-11
lines changed

2 files changed

+21
-11
lines changed

src/mpl/src/SACoreSoftMacro.cpp

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -416,12 +416,17 @@ void SACoreSoftMacro::calBoundaryPenalty()
416416
return;
417417
}
418418

419-
int tot_num_macros = 0;
419+
int number_of_movable_macros = 0;
420420
for (const auto& macro_id : pos_seq_) {
421-
tot_num_macros += macros_[macro_id].getNumMacro();
421+
const SoftMacro& soft_macro = macros_[macro_id];
422+
if (soft_macro.isFixed()) {
423+
continue;
424+
}
425+
426+
number_of_movable_macros += soft_macro.getNumMacro();
422427
}
423428

424-
if (tot_num_macros <= 0) {
429+
if (number_of_movable_macros == 0) {
425430
return;
426431
}
427432

@@ -430,23 +435,28 @@ void SACoreSoftMacro::calBoundaryPenalty()
430435
float x_dist_from_root = 0.0f, y_dist_from_root = 0.0f;
431436

432437
for (const auto& macro_id : pos_seq_) {
433-
if (macros_[macro_id].getNumMacro() > 0) {
434-
global_lx = macros_[macro_id].getX() + outline_.xMin() - root_->getX();
435-
global_ly = macros_[macro_id].getY() + outline_.yMin() - root_->getY();
436-
global_ux = global_lx + macros_[macro_id].getWidth();
437-
global_uy = global_ly + macros_[macro_id].getHeight();
438+
const SoftMacro& soft_macro = macros_[macro_id];
439+
if (soft_macro.isFixed()) {
440+
continue;
441+
}
442+
443+
if (soft_macro.getNumMacro() > 0) {
444+
global_lx = soft_macro.getX() + outline_.xMin() - root_->getX();
445+
global_ly = soft_macro.getY() + outline_.yMin() - root_->getY();
446+
global_ux = global_lx + soft_macro.getWidth();
447+
global_uy = global_ly + soft_macro.getHeight();
438448

439449
x_dist_from_root
440450
= std::min(global_lx, std::abs(root_->getWidth() - global_ux));
441451
y_dist_from_root
442452
= std::min(global_ly, std::abs(root_->getHeight() - global_uy));
443453

444454
boundary_penalty_ += std::min(x_dist_from_root, y_dist_from_root)
445-
* macros_[macro_id].getNumMacro();
455+
* soft_macro.getNumMacro();
446456
}
447457
}
448458
// normalization
449-
boundary_penalty_ = boundary_penalty_ / tot_num_macros;
459+
boundary_penalty_ = boundary_penalty_ / number_of_movable_macros;
450460
if (graphics_) {
451461
graphics_->setBoundaryPenalty({"Boundary",
452462
boundary_weight_,

src/mpl/src/SimulatedAnnealingCore.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -772,7 +772,7 @@ template <class T>
772772
bool SimulatedAnnealingCore<T>::resultFitsInOutline() const
773773
{
774774
return (width_ <= std::ceil(outline_.getWidth()))
775-
&& (height_ <= std::ceil(outline_.getHeight()));
775+
&& (height_ <= std::ceil(outline_.getHeight()));
776776
}
777777

778778
template <class T>

0 commit comments

Comments
 (0)