highs-sys 1.14.2

Rust binding for the HiGHS linear programming solver. See http://highs.dev.
Documentation
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/*                                                                       */
/*    This file is part of the HiGHS linear optimization suite           */
/*                                                                       */
/*    Available as open-source under the MIT License                     */
/*                                                                       */
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
#include "qpsolver/perturbation.hpp"

#include <random>

void perturb(Runtime& rt) {
  rt.perturbed = rt.instance;
  if (!rt.settings.perturbation) {
    return;
  }

  std::uniform_real_distribution<double> randomperturb(1e-5, 1e-4);
  std::default_random_engine re;

  for (HighsInt i = 0; i < rt.perturbed.num_con; i++) {
    if (rt.perturbed.con_lo[i] != rt.perturbed.con_up[i]) {
      if (rt.perturbed.con_lo[i] != -std::numeric_limits<double>::infinity()) {
        rt.perturbed.con_lo[i] -= randomperturb(re);
      }
      if (rt.perturbed.con_up[i] != std::numeric_limits<double>::infinity()) {
        rt.perturbed.con_up[i] += randomperturb(re);
      }
    }
  }
  for (HighsInt i = 0; i < rt.perturbed.num_var; i++) {
    if (rt.perturbed.var_lo[i] != rt.perturbed.var_up[i]) {
      if (rt.perturbed.var_lo[i] != -std::numeric_limits<double>::infinity()) {
        rt.perturbed.var_lo[i] -= randomperturb(re);
      }
      if (rt.perturbed.var_up[i] != std::numeric_limits<double>::infinity()) {
        rt.perturbed.var_up[i] += randomperturb(re);
      }
    }
  }
}