Skip to content

Commit da5fc73

Browse files
committed
Added file header to defs.hpp, and added defs.hpp to sources.cmake and sources-python.cmake
2 parents 19c16e7 + 649a36c commit da5fc73

File tree

18 files changed

+255
-212
lines changed

18 files changed

+255
-212
lines changed

cmake/sources-python.cmake

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -374,6 +374,7 @@ set(highs_headers_python
374374
highs/parallel/HighsTaskExecutor.h
375375
highs/pdlp/CupdlpWrapper.h
376376
highs/pdlp/HiPdlpWrapper.h
377+
highs/pdlp/hipdlp/defs.hpp
377378
highs/pdlp/hipdlp/linalg.hpp
378379
highs/pdlp/hipdlp/logger.hpp
379380
highs/pdlp/hipdlp/pdhg.hpp

cmake/sources.cmake

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -461,6 +461,7 @@ set(highs_headers
461461
parallel/HighsTaskExecutor.h
462462
pdlp/CupdlpWrapper.h
463463
pdlp/HiPdlpWrapper.h
464+
pdlp/hipdlp/defs.hpp
464465
pdlp/hipdlp/linalg.hpp
465466
pdlp/hipdlp/logger.hpp
466467
pdlp/hipdlp/pdhg.hpp

highs/pdlp/HiPdlpWrapper.cpp

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ HighsStatus solveLpHiPdlp(const HighsOptions& options, HighsTimer& timer,
5050
logger.print_header();
5151

5252
Timer total_timer;
53-
/*** Order of operations
53+
/*** Order of operations
5454
* Preprocess with HiPdlp
5555
* Scale with HiPdlp
5656
* Solve with HiPdlp
@@ -62,22 +62,23 @@ HighsStatus solveLpHiPdlp(const HighsOptions& options, HighsTimer& timer,
6262
pdlp.setParams(options, timer);
6363
HighsLp preprocessed_lp;
6464
pdlp.passLp(&lp);
65-
//logger_.info("Preprocessing LP to handle ranged constraints...");
65+
// logger_.info("Preprocessing LP to handle ranged constraints...");
6666
pdlp.PreprocessLp();
6767

6868
// 3. Scale with HiPdlp
6969
pdlp.scaling_.ScaleProblem();
7070

7171
// 4. Solve with HiPdlp
7272
std::vector<double> x, y;
73-
pdlp.Solve(x,y);
73+
pdlp.Solve(x, y);
7474

7575
// 5. Unscale with HiPdlp
7676
pdlp.scaling_.UnscaleSolution(x, y);
7777

7878
// 6. Postprocess with HiPDLP
7979
HighsSolution pdlp_solution;
80-
//pdlp.Postsolve(presolved_lp, preprocessed_lp, x, y, pdlp_solution); // return x, y
80+
// pdlp.Postsolve(presolved_lp, preprocessed_lp, x, y, pdlp_solution); //
81+
// return x, y
8182

8283
// --- Print Summary ---
8384
logger.print_summary(pdlp.GetResults(), pdlp.GetIterationCount(),
@@ -141,8 +142,6 @@ HighsStatus solveLpHiPdlp(const HighsOptions& options, HighsTimer& timer,
141142
return HighsStatus::kOk;
142143
}
143144

144-
145-
146145
void PrimalDualParams::initialise() {
147146
this->eta = 0;
148147
this->omega = 0;

highs/pdlp/HiPdlpWrapper.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,6 @@
1515
#include <cassert>
1616

1717
#include "lp_data/HighsSolution.h"
18-
// #include "pdlp/cupdlp/cupdlp.h"
19-
20-
// typedef enum CONSTRAINT_TYPE { EQ = 0, LEQ, GEQ, BOUND } constraint_type;
21-
2218
HighsStatus solveLpHiPdlp(HighsLpSolverObject& solver_object);
2319

2420
HighsStatus solveLpHiPdlp(const HighsOptions& options, HighsTimer& timer,

highs/pdlp/hipdlp/defs.hpp

Lines changed: 32 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,19 @@
1-
#ifndef HIGHS_PDLP_DEFS_HPP
2-
#define HIGHS_PDLP_DEFS_HPP
1+
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2+
/* */
3+
/* This file is part of the HiGHS linear optimization suite */
4+
/* */
5+
/* Available as open-source under the MIT License */
6+
/* */
7+
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
8+
/**@file pdlp/hipdlp/defs.hpp
9+
* @brief
10+
*/
11+
#ifndef PDLP_HIPDLP_DEFS_HPP
12+
#define PDLP_HIPDLP_DEFS_HPP
313

414
#include <cmath>
515
#include <vector>
16+
617
#include "Highs.h"
718

819
enum class Device { CPU, GPU };
@@ -62,7 +73,7 @@ struct PrimalDualParams {
6273
};
6374

6475
struct PdlpIterate {
65-
// Primary variables
76+
// Primary variables
6677
std::vector<double> x;
6778
std::vector<double> y;
6879

@@ -75,11 +86,15 @@ struct PdlpIterate {
7586
// Constructors
7687
PdlpIterate() = default;
7788
PdlpIterate(int num_cols, int num_rows)
78-
: x(num_cols, 0.0), y(num_rows, 0.0), Ax(num_rows, 0.0), Aty(num_cols, 0.0) {}
79-
PdlpIterate(const std::vector<double>& x_init, const std::vector<double>& y_init)
89+
: x(num_cols, 0.0),
90+
y(num_rows, 0.0),
91+
Ax(num_rows, 0.0),
92+
Aty(num_cols, 0.0) {}
93+
PdlpIterate(const std::vector<double>& x_init,
94+
const std::vector<double>& y_init)
8095
: x(x_init), y(y_init), Ax(y_init.size(), 0.0), Aty(x_init.size(), 0.0) {}
8196

82-
// Arithmetic operations
97+
// Arithmetic operations
8398
// z = alpha * this + beta * other
8499
void LinearCombination(const PdlpIterate& other, double alpha, double beta);
85100

@@ -95,8 +110,9 @@ struct PdlpIterate {
95110

96111
// Norms and metrics
97112
double PrimalNorm() const; // ||x||_2
98-
double DualNorm() const; // ||y||_2
99-
double WeightedNorm(double omega) const; // sqrt(||x||_2^2 + omega^2 * ||y||_2^2)
113+
double DualNorm() const; // ||y||_2
114+
double WeightedNorm(
115+
double omega) const; // sqrt(||x||_2^2 + omega^2 * ||y||_2^2)
100116

101117
// Distance metrics
102118
double Distance(const PdlpIterate& other, double omega = 1.0) const;
@@ -105,28 +121,28 @@ struct PdlpIterate {
105121
void ComputeAx(const HighsLp& lp) const;
106122
void ComputeATy(const HighsLp& lp) const;
107123
void InvalidateProducts(); // Call when x or y change
108-
124+
109125
const std::vector<double>& GetAx(const HighsLp& lp) const;
110126
const std::vector<double>& GetATy(const HighsLp& lp) const;
111127

112128
// For block-structured problems
113129
struct BlockStructure {
114-
std::vector<int> x_block_sizes;
115-
std::vector<int> y_block_sizes;
116-
// std::vector<std::vector<double>> x_blocks; // Future: for block problems
117-
// std::vector<std::vector<double>> y_blocks;
130+
std::vector<int> x_block_sizes;
131+
std::vector<int> y_block_sizes;
132+
// std::vector<std::vector<double>> x_blocks; // Future: for block problems
133+
// std::vector<std::vector<double>> y_blocks;
118134
};
119135

120136
// Optional: block structure for future extensions
121137
std::unique_ptr<BlockStructure> block_structure = nullptr;
122138

123-
private:
139+
private:
124140
void EnsureAxComputed(const HighsLp& lp) const;
125141
void EnsureATyComputed(const HighsLp& lp) const;
126142
};
127143

128144
namespace pdlp_iterate_ops {
129-
// Compute z_new = z_old -
145+
// Compute z_new = z_old -
130146
};
131147

132-
#endif
148+
#endif

highs/pdlp/hipdlp/linalg.cc

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1-
/*
2-
* @Author: Zhou Yanyu(周妍妤) [email protected]
3-
* @Date: 2025-07-09 14:54:26
4-
* @LastEditors: Zhou Yanyu(周妍妤) [email protected]
5-
* @LastEditTime: 2025-08-05 14:47:19
6-
* @FilePath: /cupdlp-CPP/src/linalg.cpp
7-
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置
8-
* 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
1+
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2+
/* */
3+
/* This file is part of the HiGHS linear optimization suite */
4+
/* */
5+
/* Available as open-source under the MIT License */
6+
/* */
7+
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
8+
/**@file pdlp/hipdlp/linalg.cc
9+
* @brief
910
*/
1011
#include "linalg.hpp"
1112

highs/pdlp/hipdlp/linalg.hpp

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
1-
/*
2-
* @Author: Zhou Yanyu(周妍妤) [email protected]
3-
* @Date: 2025-07-14 12:06:25
4-
* @LastEditors: Zhou Yanyu(周妍妤) [email protected]
5-
* @LastEditTime: 2025-08-05 14:47:53
6-
* @FilePath: /cupdlp-CPP/include/linalg.hpp
7-
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置
8-
* 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
1+
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2+
/* */
3+
/* This file is part of the HiGHS linear optimization suite */
4+
/* */
5+
/* Available as open-source under the MIT License */
6+
/* */
7+
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
8+
/**@file pdlp/hipdlp/linalg.hpp
9+
* @brief
910
*/
10-
#ifndef LINALG_HPP
11-
#define LINALG_HPP
11+
#ifndef PDLP_HIPDLP_LINALG_HPP
12+
#define PDLP_HIPDLP_LINALG_HPP
1213

1314
#include <vector>
1415

@@ -51,4 +52,4 @@ std::vector<double> compute_row_norms(
5152
const HighsLp& lp, double p = std::numeric_limits<double>::infinity());
5253
} // namespace linalg
5354

54-
#endif // LINALG_HPP
55+
#endif // PDLP_HIPDLP_LINALG_HPP

highs/pdlp/hipdlp/logger.cc

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
1+
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2+
/* */
3+
/* This file is part of the HiGHS linear optimization suite */
4+
/* */
5+
/* Available as open-source under the MIT License */
6+
/* */
7+
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
8+
/**@file pdlp/hipdlp/logger.cc
9+
* @brief
10+
*/
111
#include "logger.hpp"
212

313
#include <iostream>

highs/pdlp/hipdlp/logger.hpp

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
1-
/*
2-
* @Author: Zhou Yanyu(周妍妤) [email protected]
3-
* @Date: 2025-08-11 10:52:55
4-
* @LastEditors: Zhou Yanyu(周妍妤) [email protected]
5-
* @LastEditTime: 2025-08-11 10:53:02
6-
* @FilePath: /cupdlp-CPP/include/logger.hpp
7-
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置
8-
* 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
1+
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2+
/* */
3+
/* This file is part of the HiGHS linear optimization suite */
4+
/* */
5+
/* Available as open-source under the MIT License */
6+
/* */
7+
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
8+
/**@file pdlp/hipdlp/logger.hpp
9+
* @brief
910
*/
10-
#ifndef LOGGER_HPP
11-
#define LOGGER_HPP
11+
#ifndef PDLP_HIPDLP_LOGGER_HPP
12+
#define PDLP_HIPDLP_LOGGER_HPP
1213

1314
#include <chrono>
1415
#include <fstream>
@@ -63,4 +64,4 @@ class Logger {
6364
std::ofstream log_file_;
6465
};
6566

66-
#endif // LOGGER_HPP
67+
#endif // PDLP_HIPDLP_LOGGER_HPP

0 commit comments

Comments
 (0)