Skip to content

Commit

Permalink
Now producing positive terms in simplex cost function
Browse files Browse the repository at this point in the history
  • Loading branch information
jajhall committed Dec 5, 2024
1 parent 593ec7b commit a3d3fb5
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 20 deletions.
14 changes: 14 additions & 0 deletions src/lp_data/HighsSolverStats.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,19 @@ enum HighsSolverStatsReport {
HighsSolverStatsReportCsvData
};

enum HighsSimplexWorkTerm {
HighsSimplexWorkTermInvertNumRow = 0,
HighsSimplexWorkTermInvertNumNz,
HighsSimplexWorkTermComputePD,
HighsSimplexWorkTermBtran,
HighsSimplexWorkTermPrice,
HighsSimplexWorkTermFtran,
HighsSimplexWorkTermFtranDse,
HighsSimplexWorkTermCount
};

const std::vector<double> kSimplexWorkCoefficients = {1.0,2.0,3.0,4.0,5.0,6.0,7.0};

struct HighsSimplexStats {
bool valid;
HighsInt num_col;
Expand All @@ -37,6 +50,7 @@ struct HighsSimplexStats {
double row_ep_density;
double row_ap_density;
double row_DSE_density;
void workTerms(double* terms) const;
double workEstimate() const;
void report(FILE* file, const std::string message = "",
const HighsInt style = HighsSolverStatsReportPretty) const;
Expand Down
41 changes: 21 additions & 20 deletions src/simplex/HEkk.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4483,25 +4483,26 @@ void HighsSimplexStats::initialise(const HighsInt iteration_count_) {
row_DSE_density = 0;
}

void HighsSimplexStats::workTerms(double* terms) const {
const double nonbasic_nz = double(this->num_nz + this->num_row - this->last_factored_basis_num_el);
terms[HighsSimplexWorkTermInvertNumRow] = double(this->num_invert) * double(this->num_row);
terms[HighsSimplexWorkTermInvertNumNz] = double(this->num_invert) * this->last_factored_basis_num_el;
terms[HighsSimplexWorkTermComputePD] = double(this->num_invert) * double(this->last_invert_num_el + nonbasic_nz);
terms[HighsSimplexWorkTermBtran] = double(this->iteration_count) * double(this->last_invert_num_el) * this->row_ep_density;
terms[HighsSimplexWorkTermPrice] = double(this->iteration_count) * nonbasic_nz * this->row_ep_density;
terms[HighsSimplexWorkTermFtran] = double(this->iteration_count) * double(this->last_invert_num_el) * this->col_aq_density;
terms[HighsSimplexWorkTermFtranDse] = double(this->iteration_count) * double(this->last_invert_num_el) * this->row_DSE_density;
}


double HighsSimplexStats::workEstimate() const {
double work = 0;
// INVERT
work += num_invert * (2 * last_factored_basis_num_el + 2 * num_row);
// Compute primal
work +=
num_invert * (last_invert_num_el + num_nz - last_factored_basis_num_el);
// Compute dual
work +=
num_invert * (last_invert_num_el + num_nz - last_factored_basis_num_el);
// BTRAN
work += iteration_count * num_row * row_ep_density;
// PRICE
work +=
iteration_count * row_ep_density * (num_nz - last_factored_basis_num_el) +
num_col * row_ap_density;
// FTRAN
work += iteration_count * num_row * col_aq_density;
// FTRAN_DSE
work += iteration_count * num_row * row_DSE_density;
return work;
double* terms = new double[HighsSimplexWorkTermCount];
this->workTerms(terms);
double work = 0;
for (HighsInt iX = 0; iX < HighsSimplexWorkTermCount; iX++) {
assert(terms[iX]>0);
work += terms[iX] * kSimplexWorkCoefficients[iX];
}
delete[] terms;
return work;
}

0 comments on commit a3d3fb5

Please sign in to comment.