@@ -56,7 +56,7 @@ lp_core_solver_base(static_matrix<T, X> & A,
56
56
m_column_types (column_types),
57
57
m_lower_bounds (lower_bound_values),
58
58
m_upper_bounds (upper_bound_values),
59
- m_basis_sort_counter (0 ),
59
+ m_nbasis_sort_counter (0 ),
60
60
m_tracing_basis_changes (false ),
61
61
m_touched_rows (nullptr ),
62
62
m_look_for_feasible_solution_only (false ) {
@@ -133,37 +133,6 @@ print_statistics(char const* str, X cost, std::ostream & out) {
133
133
<< " , nonzeros = " << m_A.number_of_non_zeroes () << std::endl;
134
134
}
135
135
136
- template <typename T, typename X> bool lp_core_solver_base<T, X>::
137
- print_statistics_with_iterations_and_check_that_the_time_is_over (std::ostream & str) {
138
- unsigned total_iterations = inc_total_iterations ();
139
- if (m_settings.report_frequency != 0 ) {
140
- if (m_settings.print_statistics && (total_iterations % m_settings.report_frequency == 0 )) {
141
- print_statistics (" " , X (), str);
142
- }
143
- }
144
- return time_is_over ();
145
- }
146
-
147
- template <typename T, typename X> bool lp_core_solver_base<T, X>::
148
- print_statistics_with_iterations_and_nonzeroes_and_cost_and_check_that_the_time_is_over (char const * str, std::ostream & out) {
149
- unsigned total_iterations = inc_total_iterations ();
150
- if (m_settings.report_frequency != 0 )
151
- if (m_settings.print_statistics && (total_iterations % m_settings.report_frequency == 0 )) {
152
- print_statistics (str, get_cost (), out);
153
- }
154
- return time_is_over ();
155
- }
156
-
157
- template <typename T, typename X> bool lp_core_solver_base<T, X>::
158
- print_statistics_with_cost_and_check_that_the_time_is_over (X cost, std::ostream & out) {
159
- unsigned total_iterations = inc_total_iterations ();
160
- if (m_settings.report_frequency != 0 )
161
- if (m_settings.print_statistics && (total_iterations % m_settings.report_frequency == 0 )) {
162
- print_statistics (" " , cost, out);
163
- }
164
- return time_is_over ();
165
- }
166
-
167
136
template <typename T, typename X> bool lp_core_solver_base<T, X>::
168
137
column_is_dual_feasible (unsigned j) const {
169
138
switch (m_column_types[j]) {
@@ -194,18 +163,6 @@ d_is_not_positive(unsigned j) const {
194
163
return m_d[j] <= numeric_traits<T>::zero ();
195
164
}
196
165
197
-
198
- template <typename T, typename X> bool lp_core_solver_base<T, X>::
199
- time_is_over () {
200
- if (m_settings.get_cancel_flag ()) {
201
- m_status = lp_status::TIME_EXHAUSTED;
202
- return true ;
203
- }
204
- else {
205
- return false ;
206
- }
207
- }
208
-
209
166
template <typename T, typename X> void lp_core_solver_base<T, X>::
210
167
rs_minus_Anx (vector<X> & rs) {
211
168
unsigned row = m_m ();
@@ -360,15 +317,42 @@ basis_is_correctly_represented_in_heading() const {
360
317
return true ;
361
318
}
362
319
template <typename T, typename X> bool lp_core_solver_base<T, X>::
363
- non_basis_is_correctly_represented_in_heading () const {
320
+ non_basis_is_correctly_represented_in_heading (std::list< unsigned >* non_basis_list ) const {
364
321
for (unsigned i = 0 ; i < m_nbasis.size (); i++)
365
322
if (m_basis_heading[m_nbasis[i]] != - static_cast <int >(i) - 1 )
366
323
return false ;
367
324
368
325
for (unsigned j = 0 ; j < m_A.column_count (); j++)
369
326
if (m_basis_heading[j] >= 0 )
370
327
lp_assert (static_cast <unsigned >(m_basis_heading[j]) < m_A.row_count () && m_basis[m_basis_heading[j]] == j);
371
-
328
+
329
+ if (non_basis_list == nullptr ) return true ;
330
+
331
+ std::unordered_set<unsigned > nbasis_set (this ->m_nbasis .size ());
332
+ for (unsigned j : this ->m_nbasis )
333
+ nbasis_set.insert (j);
334
+
335
+ if (non_basis_list->size () != nbasis_set.size ()) {
336
+ TRACE (" lp_core" , tout << " non_basis_list.size() = " << non_basis_list->size () << " , nbasis_set.size() = " << nbasis_set.size () << " \n " ;);
337
+ return false ;
338
+ }
339
+ for (auto it = non_basis_list->begin (); it != non_basis_list->end (); it++) {
340
+ if (nbasis_set.find (*it) == nbasis_set.end ()) {
341
+ TRACE (" lp_core" , tout << " column " << *it << " is in m_non_basis_list but not in m_nbasis\n " ;);
342
+ return false ;
343
+ }
344
+ }
345
+
346
+ // check for duplicates in m_non_basis_list
347
+ nbasis_set.clear ();
348
+ for (auto it = non_basis_list->begin (); it != non_basis_list->end (); it++) {
349
+ if (nbasis_set.find (*it) != nbasis_set.end ()) {
350
+ TRACE (" lp_core" , tout << " column " << *it << " is in m_non_basis_list twice\n " ;);
351
+ return false ;
352
+ }
353
+ nbasis_set.insert (*it);
354
+ }
355
+
372
356
return true ;
373
357
}
374
358
@@ -390,7 +374,7 @@ template <typename T, typename X> bool lp_core_solver_base<T, X>::
390
374
if (!basis_is_correctly_represented_in_heading ())
391
375
return false ;
392
376
393
- if (!non_basis_is_correctly_represented_in_heading ())
377
+ if (!non_basis_is_correctly_represented_in_heading (nullptr ))
394
378
return false ;
395
379
396
380
return true ;
0 commit comments