Skip to content

Commit

Permalink
Merge pull request #1017 from ERGO-Code/fix-bdry2
Browse files Browse the repository at this point in the history
Fix bdry2
  • Loading branch information
jajhall authored Nov 29, 2022
2 parents b6d4b3d + 77cce93 commit d85660e
Show file tree
Hide file tree
Showing 19 changed files with 68 additions and 48 deletions.
2 changes: 1 addition & 1 deletion app/RunHighs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* @brief HiGHS main
*/
#include "Highs.h"
//#include "io/HighsIO.h"
// #include "io/HighsIO.h"
#include "lp_data/HighsRuntimeOptions.h"

void reportModelStatsOrError(const HighsLogOptions& log_options,
Expand Down
2 changes: 1 addition & 1 deletion check/TestHighsHessian.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#include "lp_data/HighsOptions.h"
#include "model/HighsHessian.h"
#include "model/HighsHessianUtils.h"
//#include "<cstdio>"
// #include "<cstdio>"

const bool dev_run = false;

Expand Down
2 changes: 1 addition & 1 deletion check/TestHighsParallel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ void matrix_multiplication_omp(unsigned nthreads) {
}
#endif
void matrix_multiplication_highs(unsigned nthreads) {
//#pragma omp parallel for private(i, j)
// #pragma omp parallel for private(i, j)
parallel::for_each(0, N, [&](HighsInt start, HighsInt end) {
for (int i = start; i < end; ++i) {
for (int j = 0; j < N; j++) {
Expand Down
4 changes: 2 additions & 2 deletions check/TestThrow.cpp
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
//#include "Highs.h"
// #include "Highs.h"
#include <iostream>
#include <stdexcept> //Used in HiGHS

#include "catch.hpp"
//#include <exception>
// #include <exception>
const bool dev_run = false;

void invalidArgument() {
Expand Down
2 changes: 1 addition & 1 deletion src/io/HMpsFF.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@

#include "io/HighsIO.h"
#include "model/HighsModel.h"
//#include "util/HighsInt.h"
// #include "util/HighsInt.h"
#include "util/stringutil.h"

using Triplet = std::tuple<HighsInt, HighsInt, double>;
Expand Down
2 changes: 1 addition & 1 deletion src/lp_data/HighsDebug.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
#include "lp_data/HConst.h"
#include "lp_data/HighsStatus.h"

//#include "lp_data/HighsOptions.h"
// #include "lp_data/HighsOptions.h"

HighsStatus debugDebugToHighsStatus(const HighsDebugStatus debug_status);

Expand Down
2 changes: 1 addition & 1 deletion src/lp_data/HighsInfoDebug.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
#include "lp_data/HighsInfo.h"
#include "lp_data/HighsLp.h"
#include "lp_data/HighsOptions.h"
//#include "lp_data/HighsLp.h"
// #include "lp_data/HighsLp.h"

HighsDebugStatus debugInfo(const HighsOptions& options, const HighsLp& lp,
const HighsBasis& basis,
Expand Down
12 changes: 6 additions & 6 deletions src/lp_data/HighsModelUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@
#ifndef LP_DATA_HIGHSMODELUTILS_H_
#define LP_DATA_HIGHSMODELUTILS_H_

//#include "Highs.h"
//#include "lp_data/HighsStatus.h"
// #include "Highs.h"
// #include "lp_data/HighsStatus.h"
#include "lp_data/HighsInfo.h"
#include "model/HighsModel.h"
//#include "lp_data/HStruct.h"
//#include "lp_data/HighsInfo.h"
//#include "lp_data/HighsLp.h"
//#include "lp_data/HighsOptions.h"
// #include "lp_data/HStruct.h"
// #include "lp_data/HighsInfo.h"
// #include "lp_data/HighsLp.h"
// #include "lp_data/HighsOptions.h"

// Analyse lower and upper bounds of a model
void analyseModelBounds(const HighsLogOptions& log_options, const char* message,
Expand Down
14 changes: 7 additions & 7 deletions src/simplex/HApp.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@
#define SIMPLEX_HAPP_H_

// todo: clear includes.
//#include <cstring>
//#include <fstream>
//#include <iomanip>
//#include <iostream>
//#include <map>
//#include <set>
//#include <vector>
// #include <cstring>
// #include <fstream>
// #include <iomanip>
// #include <iostream>
// #include <map>
// #include <set>
// #include <vector>

#include "lp_data/HighsLpSolverObject.h"
#include "lp_data/HighsLpUtils.h"
Expand Down
14 changes: 7 additions & 7 deletions src/simplex/HEkkDual.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1264,25 +1264,25 @@ void HEkkDual::iterateTasks() {
if (1.0 * row_ep.count / solver_num_row < 0.01) slice_PRICE = 0;

analysis->simplexTimerStart(Group1Clock);
//#pragma omp parallel
//#pragma omp single
// #pragma omp parallel
// #pragma omp single
{
//#pragma omp task
// #pragma omp task
highs::parallel::spawn([&]() {
col_DSE.copy(&row_ep);
updateFtranDSE(&col_DSE);
});
//#pragma omp task
// #pragma omp task
{
if (slice_PRICE)
chooseColumnSlice(&row_ep);
else
chooseColumn(&row_ep);
//#pragma omp task
// #pragma omp task
highs::parallel::spawn([&]() { updateFtranBFRT(); });
//#pragma omp task
// #pragma omp task
updateFtran();
//#pragma omp taskwait
// #pragma omp taskwait
highs::parallel::sync();
}

Expand Down
18 changes: 9 additions & 9 deletions src/simplex/HEkkDualMulti.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ void HEkkDual::iterateMulti() {
slice_PRICE = 0;

if (slice_PRICE) {
//#pragma omp parallel
//#pragma omp single
// #pragma omp parallel
// #pragma omp single
chooseColumnSlice(multi_finish[multi_nFinish].row_ep);
} else {
chooseColumn(multi_finish[multi_nFinish].row_ep);
Expand Down Expand Up @@ -200,7 +200,7 @@ void HEkkDual::majorChooseRowBtran() {
}
std::vector<double>& edge_weight = ekk_instance_.dual_edge_weight_;
// 4.2 Perform BTRAN
//#pragma omp parallel for schedule(static, 1)
// #pragma omp parallel for schedule(static, 1)
// printf("start %d tasks for btran\n", multi_ntasks);
// std::vector<HighsInt> tmp(multi_ntasks);
highs::parallel::for_each(0, multi_ntasks, [&](HighsInt start, HighsInt end) {
Expand Down Expand Up @@ -491,7 +491,7 @@ void HEkkDual::minorUpdateRows() {
}

// Perform tasks
//#pragma omp parallel for schedule(dynamic)
// #pragma omp parallel for schedule(dynamic)
// printf("minorUpdatesRows: starting %d tasks\n", multi_nTasks);
highs::parallel::for_each(
0, multi_nTasks, [&](HighsInt start, HighsInt end) {
Expand Down Expand Up @@ -650,7 +650,7 @@ void HEkkDual::majorUpdateFtranParallel() {
}

// Perform FTRAN
//#pragma omp parallel for schedule(dynamic, 1)
// #pragma omp parallel for schedule(dynamic, 1)
// printf("majorUpdateFtranParallel: starting %d tasks\n", multi_ntasks);
highs::parallel::for_each(0, multi_ntasks, [&](HighsInt start, HighsInt end) {
for (HighsInt i = start; i < end; i++) {
Expand Down Expand Up @@ -714,7 +714,7 @@ void HEkkDual::majorUpdateFtranFinal() {
// The FTRAN regular buffer
if (fabs(pivotX1) > kHighsTiny) {
const double pivot = pivotX1 / pivotAlpha;
//#pragma omp parallel for
// #pragma omp parallel for
highs::parallel::for_each(
0, solver_num_row,
[&](HighsInt start, HighsInt end) {
Expand All @@ -727,7 +727,7 @@ void HEkkDual::majorUpdateFtranFinal() {
// The FTRAN-DSE buffer
if (fabs(pivotX2) > kHighsTiny) {
const double pivot = pivotX2 / pivotAlpha;
//#pragma omp parallel for
// #pragma omp parallel for
highs::parallel::for_each(
0, solver_num_row,
[&](HighsInt start, HighsInt end) {
Expand Down Expand Up @@ -774,7 +774,7 @@ void HEkkDual::majorUpdatePrimal() {
// non-pivotal edge weights
const double* mixArray = &col_BFRT.array[0];
double* local_work_infeasibility = &dualRHS.work_infeasibility[0];
//#pragma omp parallel for schedule(static)
// #pragma omp parallel for schedule(static)
highs::parallel::for_each(
0, solver_num_row,
[&](HighsInt start, HighsInt end) {
Expand Down Expand Up @@ -805,7 +805,7 @@ void HEkkDual::majorUpdatePrimal() {
// Update steepest edge weights
const double* dseArray = &multi_finish[iFn].row_ep->array[0];
const double Kai = -2 / multi_finish[iFn].alpha_row;
//#pragma omp parallel for schedule(static)
// #pragma omp parallel for schedule(static)
highs::parallel::for_each(
0, solver_num_row,
[&](HighsInt start, HighsInt end) {
Expand Down
4 changes: 2 additions & 2 deletions src/simplex/HSimplex.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
#include <cmath>
#include <vector>

//#include "lp_data/HighsLpUtils.h"
//#include "util/HighsSort.h"
// #include "lp_data/HighsLpUtils.h"
// #include "util/HighsSort.h"

using std::max;
using std::min;
Expand Down
2 changes: 1 addition & 1 deletion src/simplex/HSimplexNlaDebug.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
#include "simplex/HSimplexNla.h"
#include "util/HighsRandom.h"

//#include <stdio.h>
// #include <stdio.h>

const double kResidualLargeError = 1e-8;
const double kResidualExcessiveError = sqrt(kResidualLargeError);
Expand Down
2 changes: 1 addition & 1 deletion src/simplex/HSimplexNlaProductForm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
*/
#include "simplex/HSimplexNla.h"

//#include <stdio.h>
// #include <stdio.h>
#include <algorithm>

using std::fabs;
Expand Down
2 changes: 1 addition & 1 deletion src/simplex/HighsSimplexAnalysis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* @brief
*/
#include <cmath>
//#include <cstdio>
// #include <cstdio>
#include <iomanip>

#include "HConfig.h"
Expand Down
2 changes: 1 addition & 1 deletion src/simplex/SimplexStruct.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
#include <cstdint>
#include <vector>

//#include "lp_data/HighsLp.h"
// #include "lp_data/HighsLp.h"
#include "lp_data/HConst.h"
#include "simplex/SimplexConst.h"

Expand Down
26 changes: 23 additions & 3 deletions src/util/HFactor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -879,7 +879,10 @@ HighsInt HFactor::buildKernel() {

const bool progress_report = false; // num_basic != num_row;
const HighsInt progress_frequency = 10000;
const HighsInt timer_frequency = 100;
// Initial timer frequency: may be reduced if iterations get slow
HighsInt timer_frequency = 100;
double previous_iteration_time = 0;
double average_iteration_time = 0;
const bool check_for_timeout = this->time_limit_ < kHighsInf;
HighsInt search_k = 0;

Expand All @@ -890,9 +893,26 @@ HighsInt HFactor::buildKernel() {
reportAsm();
}
// Detemine whether to return due to exceeding the time limit
if (check_for_timeout && search_k % timer_frequency == 0)
if (build_timer_->readRunHighsClock() > this->time_limit_)
if (check_for_timeout && search_k % timer_frequency == 0) {
double current_time = build_timer_->readRunHighsClock();
double time_difference = current_time - previous_iteration_time;
previous_iteration_time = current_time;
double iteration_time = time_difference / (1.0 * timer_frequency);
average_iteration_time =
0.9 * average_iteration_time + 0.1 * iteration_time;

if (time_difference > this->time_limit_ / 1e3)
timer_frequency = std::max(HighsInt(1), timer_frequency / 10);
HighsInt iterations_left = kernel_dim - search_k + 1;
double remaining_time_bound = average_iteration_time * iterations_left;
double total_time_bound = current_time + remaining_time_bound;
printf("%d; Iter: Time %11.4g; average = %11.4g; Bound = %11.4g\n",
search_k, iteration_time, average_iteration_time,
total_time_bound);
if (current_time > this->time_limit_ ||
total_time_bound > this->time_limit_)
return kBuildKernelReturnTimeout;
}

/**
* 1. Search for the pivot
Expand Down
2 changes: 1 addition & 1 deletion src/util/HSet.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

#include "util/HighsInt.h"

//#include <iostream>
// #include <iostream>

using std::vector;

Expand Down
2 changes: 1 addition & 1 deletion src/util/HighsMatrixUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
#include <cassert>
#include <vector>

//#include "lp_data/HighsStatus.h"
// #include "lp_data/HighsStatus.h"
#include "lp_data/HighsOptions.h"

using std::vector;
Expand Down

0 comments on commit d85660e

Please sign in to comment.