Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
73d160e
code dump
dance858 Nov 17, 2025
a5ba673
workflows
dance858 Nov 17, 2025
92da177
Merge branch 'main' into development
dance858 Nov 17, 2025
81d895c
ran formatter
dance858 Nov 17, 2025
ee95f82
Merge branch 'main' into development
dance858 Nov 17, 2025
8fc1360
readme
dance858 Nov 17, 2025
2f43e3f
workflow
dance858 Nov 17, 2025
510f8cb
Merge branch 'main' into development
dance858 Nov 17, 2025
93e11b5
removed old workflows
dance858 Nov 17, 2025
5c88a67
Merge branch 'development' of github.com:dance858/PSLP into development
dance858 Nov 17, 2025
c21ca6c
Merge branch 'main' into development
dance858 Nov 17, 2025
69792c0
new workflow
dance858 Nov 17, 2025
288c5ee
c++ workflow
dance858 Nov 17, 2025
44d962a
C++ workflow
dance858 Nov 17, 2025
8b23209
new line at eof to formatter
dance858 Nov 17, 2025
40f2419
improved interface
dance858 Nov 17, 2025
0f18367
Merge branch 'main' into development
dance858 Nov 17, 2025
9337691
new workflow
dance858 Nov 17, 2025
184b73a
Merge branch 'development' of github.com:dance858/PSLP into development
dance858 Nov 17, 2025
6e8106c
Merge branch 'main' into development
dance858 Nov 17, 2025
9f5cd68
new workflow
dance858 Nov 17, 2025
e1e0ff4
Merge branch 'development' of github.com:dance858/PSLP into development
dance858 Nov 17, 2025
11f17c7
new workflow
dance858 Nov 17, 2025
6feeaf7
Merge branch 'main' into development
dance858 Nov 17, 2025
8094063
updated default settings
dance858 Nov 18, 2025
df92d45
small changes to API
dance858 Nov 18, 2025
528be6d
added one test
dance858 Nov 18, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 22 additions & 16 deletions include/PSLP/PSLP_API.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,9 @@
* limitations under the License.
*/

/* Public header containing the outward facing API. It includes all the
input/output data structs and the API functions. Make sure this file is
somewhere appropriate and then use `#include <PSLP/"API.h"
>` to access the
public API. */
/* Public header containing the outward facing API. Together with the other
files in the folder "PSLP", it includes the input/output data structs
and the API functions. */
#ifndef PRESOLVER_H
#define PRESOLVER_H

Expand All @@ -29,8 +27,8 @@ extern "C"
{
#endif

#include "PresolveStatus.h"
#include "Sol.h"
#include "PSLP_sol.h"
#include "PSLP_status.h"
#include <stdbool.h>

/* forward declaration */
Expand Down Expand Up @@ -69,13 +67,21 @@ extern "C"
double *rhs;
double *c;

// variable bounds bounds[k].lb <= x_k <= bounds[k].ub
// Bound *bounds;
// variable bounds lbs <= x <= ubs
double *lbs;
double *ubs;
} PresolvedProblem;

/* struct corresponding to the presolver*/
/* struct corresponding to the presolver:
- 'stats' contains statistics about the presolving process
- 'stgs' contains the settings used for presolving
- 'prob' contains the internal problem representation used during
presolving
- 'reduced_prob' contains the presolved problem after running
'run_presolver'
- 'sol' contains the solution to the original problem after running
'postsolve'
*/
typedef struct
{
struct PresolveStats *stats;
Expand All @@ -85,16 +91,15 @@ extern "C"
Solution *sol;
} Presolver;

/* The user is responsible for freeing the settings struct using standard free.
*/
/* The user is responsible for freeing the settings using 'free_settings'. */
Settings *default_settings();
void free_settings(Settings *stgs);
void set_settings_true(Settings *stgs);
void set_settings_false(Settings *stgs);

/* Initialize presolver, allocate memory, and build internal data structures.
The presolver maintains internal deep copies of Ax, Ai, Ap, lhs, rhs, lbs,
ubs, and c. The user is responsible for freeing this memory using
ubs, and c. The user is responsible for freeing the presolver using
'free_presolver'. If the allocation fails, the function returns NULL. */
Presolver *new_presolver(const double *Ax, const int *Ai, const int *Ap, int m,
int n, int nnz, const double *lhs, const double *rhs,
Expand All @@ -104,13 +109,14 @@ extern "C"
/* Free the memory allocated for the presolver. */
void free_presolver(Presolver *presolver);

/* Runs the presolver. At completion, the 'problem' field of the presolver
contains the presolved problem. */
/* Runs the presolver. At completion, the 'reduced_prob' field of the
presolver contains the presolved problem. */
PresolveStatus run_presolver(Presolver *presolver);

/* Postsolve the problem given the primal-dual solution (x, y, z) of the
reduced problem. The optimal value of the reduced problem is 'obj'.
The function populates presolver->sol. */
The function populates presolver->sol, so if you're looking for the
solution to the original problem, you should look there. */
void postsolve(Presolver *presolver, const double *x, const double *y,
const double *z, double obj);

Expand Down
18 changes: 0 additions & 18 deletions include/PSLP/PSLP_infs.h

This file was deleted.

File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion include/core/CoreTransformations.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
#ifndef CORE_TRANSFORMATIONS_H
#define CORE_TRANSFORMATIONS_H

#include "PSLP_status.h"
#include "Postsolver.h"
#include "PresolveStatus.h"
#include "Tags.h"
#include "debug_macros.h"
#include "glbopts.h"
Expand Down
2 changes: 1 addition & 1 deletion include/core/Postsolver.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
#include <stdbool.h>
#include <stdint.h>

#include "Sol.h"
#include "PSLP_sol.h"
#include "Tags.h"

struct u16Vec;
Expand Down
2 changes: 1 addition & 1 deletion include/core/glbopts.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,6 @@
#define SIZE_INACTIVE_ROW -1
#define SIZE_INACTIVE_COL -1
#define MAX_RATIO_PIVOT 1e3
#define CVX_PRESOLVE_VERSION "0.0.1"
#define PSLP_presolve_VERSION "0.0.1"

#endif
3 changes: 2 additions & 1 deletion include/data_structures/iVec.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
// This macro defines a vector of integers.
DEFINE_VECTOR(int, i)

/*
__attribute__((unused)) static void print_ivec(iVec *vec)
{
for (size_t i = 0; i < vec->len; ++i)
Expand All @@ -34,5 +35,5 @@ __attribute__((unused)) static void print_ivec(iVec *vec)
}
printf("\n");
}

*/
#endif // IVEC_H
2 changes: 2 additions & 0 deletions include/data_structures/u16Vec.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
// This macro defines a vector of uint16_t.
DEFINE_VECTOR(uint16_t, u16)

/*
__attribute__((unused)) static void print_u16Vec(const u16Vec *vec)
{
for (int i = 0; i < vec->len; ++i)
Expand All @@ -29,3 +30,4 @@ __attribute__((unused)) static void print_u16Vec(const u16Vec *vec)
}
printf("\n");
}
*/
2 changes: 1 addition & 1 deletion include/explorers/DTonsEq.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
#ifndef DTONS_EQ_H
#define DTONS_EQ_H

#include "PresolveStatus.h"
#include "PSLP_status.h"
struct Matrix;
struct Problem;
struct PostsolveInfo;
Expand Down
2 changes: 1 addition & 1 deletion include/explorers/Parallel_cols.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
#ifndef PARALLEL_COLS_H
#define PARALLEL_COLS_H

#include "PresolveStatus.h"
#include "PSLP_status.h"

// forward declaration
struct Problem;
Expand Down
2 changes: 1 addition & 1 deletion include/explorers/Parallel_rows.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
#ifndef PARALLEL_ROWS_H
#define PARALLEL_ROWS_H

#include "PresolveStatus.h"
#include "PSLP_status.h"
#include "Tags.h"

// forward declarations
Expand Down
2 changes: 1 addition & 1 deletion include/explorers/Primal_propagation.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

#include <stdbool.h>

#include "PresolveStatus.h"
#include "PSLP_status.h"
#include "Tags.h"

struct Constraints;
Expand Down
2 changes: 1 addition & 1 deletion include/explorers/SimpleReductions.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
#ifndef SIMPLEREDUCTIONS_H
#define SIMPLEREDUCTIONS_H

#include "PresolveStatus.h"
#include "PSLP_status.h"
#include "Tags.h"

// forward declarations
Expand Down
2 changes: 1 addition & 1 deletion include/explorers/Simple_dual_fix.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
#ifndef SIMPLE_DUAL_FIX_H
#define SIMPLE_DUAL_FIX_H

#include "PresolveStatus.h"
#include "PSLP_status.h"

// forward declaration
struct Problem;
Expand Down
2 changes: 1 addition & 1 deletion include/explorers/StonCols.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
#ifndef STONCOLS_HPP
#define STONCOLS_HPP

#include "PresolveStatus.h"
#include "PSLP_status.h"

// forward declaration
struct Problem;
Expand Down
9 changes: 4 additions & 5 deletions src/core/Presolver.c
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ Settings *default_settings()
stgs->parallel_cols = true;
stgs->primal_propagation = true;
stgs->dual_fix = true;
stgs->clean_small_coeff = true;
stgs->clean_small_coeff = false;
stgs->finite_bound_tightening = true;
stgs->relax_bounds = true;
stgs->max_shift = 10;
Expand Down Expand Up @@ -336,6 +336,7 @@ static inline bool update_termination(int nnz_after_cycle, int nnz_before_cycle,

if (GET_ELAPSED_SECONDS(outer_timer) >= max_time)
{
printf("Maximum time limit of %.2f seconds reached.\n", max_time);
return true;
}

Expand Down Expand Up @@ -370,6 +371,7 @@ static inline Complexity update_complexity(Complexity curr_complexity,
{
assert(false);
}

return FAST; // to suppress compiler warning
}

Expand Down Expand Up @@ -409,7 +411,6 @@ static inline PresolveStatus run_trivial_explorers(Problem *prob,
assert(prob->constraints->state->ston_rows->len == 0);
assert(prob->constraints->state->empty_rows->len == 0);
assert(prob->constraints->state->empty_cols->len == 0);

return UNCHANGED;
}

Expand Down Expand Up @@ -437,12 +438,10 @@ static inline PresolveStatus run_fast_explorers(Problem *prob, const Settings *s
if (stgs->dton_eq)
{
status |= remove_dton_eq_rows(prob, stgs->max_shift);

// after removing doubleton equality rows, there can be new empty rows,
// new singleton rows, and new empty columns
status |= run_trivial_explorers(prob, stgs);
}

return status;
}

Expand Down Expand Up @@ -557,7 +556,7 @@ static inline void print_start_message(const PresolveStats *stats)
{
printf("\n\t PSLP v%s - LP presolver \n\t(c) Daniel "
"Cederberg, Stanford University, 2025\n",
CVX_PRESOLVE_VERSION);
PSLP_presolve_VERSION);
printf("Original problem: %d rows, %d columns, %d nnz\n",
stats->n_rows_original, stats->n_cols_original, stats->nnz_original);
}
Expand Down
6 changes: 3 additions & 3 deletions src/explorers/DtonsEq.c
Original file line number Diff line number Diff line change
Expand Up @@ -236,9 +236,9 @@ static inline void modify_bounds(Constraints *constraints, int i, double aij,
#ifndef TESTING
static inline
#endif
Old_and_new_coeff
update_row_A_dton(Matrix *A, int i, int q, int j, int k, double aij, double aik,
int *row_size, PostsolveInfo *postsolve_info)
Old_and_new_coeff update_row_A_dton(Matrix *A, int i, int q, int j, int k,
double aij, double aik, int *row_size,
PostsolveInfo *postsolve_info)
{
int ii, start, end, insertion;
double old_val = 0.0;
Expand Down
2 changes: 0 additions & 2 deletions src/explorers/StonCols.c
Original file line number Diff line number Diff line change
Expand Up @@ -617,8 +617,6 @@ PresolveStatus remove_ston_cols__(Problem *prob)
{
printf("debug warning: large coefficient when eliminating col ston\n");
}
// This happens on map10 (miplib)
// assert(!IS_HUGE(Aik) && !IS_HUGE(1 / Aik) && "Be aware of this!");
#endif

// If two column singletons appear in the same constraint, the
Expand Down
Loading