24 const ColIndex num_cols = matrix_.
num_cols();
29 if (lower_bounds_ == new_lower_bounds && upper_bounds_ == new_upper_bounds) {
33 lower_bounds_ = new_lower_bounds;
34 upper_bounds_ = new_upper_bounds;
36 for (ColIndex
col(0);
col < num_cols; ++
col) {
37 variable_type_[
col] = ComputeVariableType(
col);
42 void VariablesInfo::ResetStatusInfo() {
43 const ColIndex num_cols = matrix_.
num_cols();
59 boxed_variables_are_relevant_ =
true;
60 num_entries_in_relevant_columns_ = 0;
65 ColIndex num_new_cols,
69 RowIndex num_basic_variables(0);
70 const ColIndex num_cols = lower_bounds_.
size();
71 const RowIndex num_rows =
ColToRowIndex(num_cols - first_slack_col);
73 const ColIndex first_new_col(first_slack_col - num_new_cols);
77 for (ColIndex
col(0);
col < num_cols; ++
col) {
82 }
else if (
col >= first_slack_col &&
94 if (num_basic_variables == num_rows) {
95 VLOG(1) <<
"Too many basic variables in the warm-start basis."
96 <<
"Only keeping the first ones as VariableStatus::BASIC.";
99 ++num_basic_variables;
110 if (lower_bounds_[
col] == upper_bounds_[
col]) {
114 ? DefaultVariableStatus(
col)
119 if (lower_bounds_[
col] == upper_bounds_[
col]) {
123 ? DefaultVariableStatus(
col)
135 const ColIndex num_cols = lower_bounds_.
size();
136 for (ColIndex
col(0);
col < num_cols; ++
col) {
144 if (lower_bounds_[
col] == upper_bounds_[
col]) {
154 return std::abs(lower_bounds_[
col]) <= std::abs(upper_bounds_[
col])
160 if (
value == boxed_variables_are_relevant_)
return;
161 boxed_variables_are_relevant_ =
value;
163 for (
const ColIndex
col : non_basic_boxed_variables_) {
167 for (
const ColIndex
col : non_basic_boxed_variables_) {
168 SetRelevance(
col,
false);
174 if (in_dual_phase_one_) {
179 variable_type_[
col] = ComputeVariableType(
col);
183 not_basic_.
Set(
col,
false);
184 can_increase_.
Set(
col,
false);
185 can_decrease_.
Set(
col,
false);
186 non_basic_boxed_variables_.
Set(
col,
false);
187 SetRelevance(
col,
false);
193 variable_status_[
col] = status;
194 is_basic_.
Set(
col,
false);
195 not_basic_.
Set(
col,
true);
203 non_basic_boxed_variables_.
Set(
col, boxed);
205 (boxed_variables_are_relevant_ || !boxed);
206 SetRelevance(
col, relevance);
210 return variable_type_;
214 return variable_status_;
218 return can_increase_;
222 return can_decrease_;
236 return non_basic_boxed_variables_;
240 return num_entries_in_relevant_columns_;
252 }
else if (lower_bounds_[
col] == upper_bounds_[
col]) {
259 void VariablesInfo::SetRelevance(ColIndex
col,
bool relevance) {
260 if (relevance_.
IsSet(
col) == relevance)
return;
272 void VariablesInfo::UpdateStatusForNewType(ColIndex
col) {
273 switch (variable_status_[
col]) {
278 if (lower_bounds_[
col] == upper_bounds_[
col]) {
290 if (lower_bounds_[
col] == upper_bounds_[
col]) {
310 DCHECK(!in_dual_phase_one_);
311 in_dual_phase_one_ =
true;
312 saved_lower_bounds_ = lower_bounds_;
313 saved_upper_bounds_ = upper_bounds_;
319 const ColIndex num_cols = matrix_.
num_cols();
320 for (ColIndex
col(0);
col < num_cols; ++
col) {
321 switch (variable_type_[
col]) {
324 lower_bounds_[
col] = 0.0;
325 upper_bounds_[
col] = 0.0;
329 lower_bounds_[
col] = 0.0;
330 upper_bounds_[
col] = 1.0;
334 lower_bounds_[
col] = -1.0;
335 upper_bounds_[
col] = 0.0;
339 lower_bounds_[
col] = -1000.0;
340 upper_bounds_[
col] = 1000.0;
348 if (reduced_costs[
col] > dual_feasibility_tolerance) {
350 }
else if (reduced_costs[
col] < -dual_feasibility_tolerance) {
355 UpdateStatusForNewType(
col);
361 DCHECK(in_dual_phase_one_);
362 in_dual_phase_one_ =
false;
363 std::swap(saved_lower_bounds_, lower_bounds_);
364 std::swap(saved_upper_bounds_, upper_bounds_);
373 const ColIndex num_cols = matrix_.
num_cols();
374 for (ColIndex
col(0);
col < num_cols; ++
col) {
375 variable_type_[
col] = ComputeVariableType(
col);
384 if (reduced_costs[
col] > dual_feasibility_tolerance) {
386 }
else if (reduced_costs[
col] < -dual_feasibility_tolerance) {
391 UpdateStatusForNewType(
col);
#define DCHECK_LE(val1, val2)
#define DCHECK_NE(val1, val2)
#define DCHECK_GE(val1, val2)
#define DCHECK_LT(val1, val2)
#define DCHECK(condition)
#define DCHECK_EQ(val1, val2)
#define VLOG(verboselevel)
void ClearAndResize(IndexType size)
bool IsSet(IndexType i) const
ColIndex num_cols() const
EntryIndex ColumnNumEntries(ColIndex col) const
void resize(IntType size)
const DenseBitRow & GetIsBasicBitRow() const
EntryIndex GetNumEntriesInRelevantColumns() const
const DenseBitRow & GetNonBasicBoxedVariables() const
const DenseBitRow & GetCanIncreaseBitRow() const
const DenseBitRow & GetCanDecreaseBitRow() const
const VariableTypeRow & GetTypeRow() const
void EndDualPhaseI(Fractional dual_feasibility_tolerance, const DenseRow &reduced_costs)
void MakeBoxedVariableRelevant(bool value)
void UpdateToNonBasicStatus(ColIndex col, VariableStatus status)
const DenseBitRow & GetNotBasicBitRow() const
void InitializeToDefaultStatus()
VariablesInfo(const CompactSparseMatrix &matrix)
const VariableStatusRow & GetStatusRow() const
void UpdateToBasicStatus(ColIndex col)
const DenseBitRow & GetIsRelevantBitRow() const
void InitializeFromBasisState(ColIndex first_slack, ColIndex num_new_cols, const BasisState &state)
bool LoadBoundsAndReturnTrueIfUnchanged(const DenseRow &new_lower_bounds, const DenseRow &new_upper_bounds)
void TransformToDualPhaseIProblem(Fractional dual_feasibility_tolerance, const DenseRow &reduced_costs)
@ UPPER_AND_LOWER_BOUNDED
bool IsFinite(Fractional value)
RowIndex ColToRowIndex(ColIndex col)
void swap(IdMap< K, V > &a, IdMap< K, V > &b)
Collection of objects used to extend the Constraint Solver library.
VariableStatusRow statuses