274 {
275 if (optimization_initialized_) {
276 return;
277 }
278 width_ = costs_.width();
279 if (width_ > 0) {
280 height_ = costs_.height();
281 } else {
282 height_ = 0;
283 }
284
285 matrix_size_ = std::max(height_, width_);
286 max_cost_ = 0;
287
288
289
290
291 costs_.Resize(matrix_size_, matrix_size_);
292 for (size_t row = 0; row < matrix_size_; ++row) {
293 for (size_t col = 0; col < matrix_size_; ++col) {
294 if ((row >= height_) || (col >= width_)) {
295 costs_(row, col) = 0;
296 } else {
297 max_cost_ = std::max(max_cost_, costs_(row, col));
298 }
299 }
300 }
301
302
303 marks_.
Resize(matrix_size_, matrix_size_);
304 for (size_t row = 0; row < matrix_size_; ++row) {
305 for (size_t col = 0; col < matrix_size_; ++col) {
306 marks_(row, col) = Mark::NONE;
307 }
308 }
309
310 stars_in_col_.assign(matrix_size_, 0);
311
312 rows_covered_.assign(matrix_size_, false);
313 cols_covered_.assign(matrix_size_, false);
314
315 assignments_.resize(matrix_size_ * 2);
316
317 optimization_initialized_ = true;
318}
void Resize(const size_t resize_height, const size_t resize_width)