18#ifndef PDLP_SHARDED_OPTIMIZATION_UTILS_H_
19#define PDLP_SHARDED_OPTIMIZATION_UTILS_H_
28#include "ortools/pdlp/solve_log.pb.h"
51 void Add(
const Eigen::VectorXd& datapoint,
double weight);
61 double Weight()
const {
return sum_weights_; }
71 Eigen::VectorXd average_;
72 double sum_weights_ = 0.0;
78QuadraticProgramStats
ComputeStats(
const ShardedQuadraticProgram& qp);
95 int num_iterations, Eigen::VectorXd& row_scaling_vec,
96 Eigen::VectorXd& col_scaling_vec);
104 Eigen::VectorXd& row_scaling_vec,
105 Eigen::VectorXd& col_scaling_vec);
135 const Eigen::VectorXd& dual_product);
150 double constraint_upper_bound,
double dual,
151 double primal_product);
161 const Eigen::VectorXd& dual_solution,
162 const Eigen::VectorXd& primal_product);
182 const std::optional<Eigen::VectorXd>& dual_solution,
183 double desired_relative_error,
double failure_probability,
184 std::mt19937& mt_generator);
196 Eigen::VectorXd& primal,
197 bool use_feasibility_bounds =
false);
202 Eigen::VectorXd& dual);
ShardedWeightedAverage & operator=(ShardedWeightedAverage &&)=default
bool HasNonzeroWeight() const
void Add(const Eigen::VectorXd &datapoint, double weight)
double Weight() const
Returns the sum of the weights of the datapoints added so far.
ShardedWeightedAverage(const Sharder *sharder)
Eigen::VectorXd ComputeAverage() const
void Clear()
Clears the sum to zero, i.e., just constructed.
ShardedWeightedAverage(ShardedWeightedAverage &&)=default
Validation utilities for solvers.proto.
LagrangianPart ComputeDualGradient(const ShardedQuadraticProgram &sharded_qp, const VectorXd &dual_solution, const VectorXd &primal_product)
QuadraticProgramStats ComputeStats(const ShardedQuadraticProgram &qp)
Returns a QuadraticProgramStats for a ShardedQuadraticProgram.
LagrangianPart ComputePrimalGradient(const ShardedQuadraticProgram &sharded_qp, const VectorXd &primal_solution, const VectorXd &dual_product)
void LInfRuizRescaling(const ShardedQuadraticProgram &sharded_qp, const int num_iterations, VectorXd &row_scaling_vec, VectorXd &col_scaling_vec)
SingularValueAndIterations EstimateMaximumSingularValueOfConstraintMatrix(const ShardedQuadraticProgram &sharded_qp, const std::optional< VectorXd > &primal_solution, const std::optional< VectorXd > &dual_solution, const double desired_relative_error, const double failure_probability, std::mt19937 &mt_generator)
void ProjectToPrimalVariableBounds(const ShardedQuadraticProgram &sharded_qp, VectorXd &primal, const bool use_feasibility_bounds)
void ProjectToDualVariableBounds(const ShardedQuadraticProgram &sharded_qp, VectorXd &dual)
double DualSubgradientCoefficient(const double constraint_lower_bound, const double constraint_upper_bound, const double dual, const double primal_product)
void L2NormRescaling(const ShardedQuadraticProgram &sharded_qp, VectorXd &row_scaling_vec, VectorXd &col_scaling_vec)
bool HasValidBounds(const ShardedQuadraticProgram &sharded_qp)
ScalingVectors ApplyRescaling(const RescalingOptions &rescaling_options, ShardedQuadraticProgram &sharded_qp)
int l_inf_ruiz_iterations
Eigen::VectorXd col_scaling_vec
Eigen::VectorXd row_scaling_vec
double estimated_relative_error