Skip to content

Commit

Permalink
Merge branch 'latest' of https://github.com/ERGO-Code/HiGHS into mino…
Browse files Browse the repository at this point in the history
…rStuffAgainAndAgain
  • Loading branch information
fwesselm committed Oct 3, 2024
2 parents a1ec3c2 + daf6672 commit d40867c
Show file tree
Hide file tree
Showing 8 changed files with 107 additions and 1 deletion.
13 changes: 13 additions & 0 deletions check/TestNames.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -118,3 +118,16 @@ TEST_CASE("highs-names", "[highs_names]") {

std::remove(solution_file.c_str());
}

TEST_CASE("highs-model-name", "[model_names]") {

Highs highs;
const HighsLp& lp = highs.getLp();

std::string name = lp.model_name_;
REQUIRE(name == "");

highs.passModelName("new_name");
name = lp.model_name_;
REQUIRE(name == "new_name");
}
5 changes: 5 additions & 0 deletions src/Highs.h
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,11 @@ class Highs {
*/
HighsStatus passRowName(const HighsInt row, const std::string& name);

/**
* @brief Pass a model name to the incumbent model
*/
HighsStatus passModelName(const std::string& name);

/**
* @brief Read in a model
*/
Expand Down
8 changes: 7 additions & 1 deletion src/highspy/highs.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from __future__ import annotations
import sys
import numpy as np
from numbers import Integral
from itertools import product
Expand All @@ -15,6 +16,11 @@
kHighsInf,
)

# backwards typing support information for HighspyArray
if sys.version_info >= (3, 9):
ndarray_object_type = np.ndarray[Any, np.dtype[np.object_]]
else:
ndarray_object_type = np.ndarray

class Highs(_Highs):
"""
Expand Down Expand Up @@ -1471,7 +1477,7 @@ def fire(
fn(e)


class HighspyArray(np.ndarray[Any, np.dtype[np.object_]]):
class HighspyArray(ndarray_object_type):
"""
A numpy array wrapper for highs_var/highs_linear_expression objects.
Expand Down
4 changes: 4 additions & 0 deletions src/interfaces/highs_c_api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,10 @@ HighsInt Highs_passColName(const void* highs, const HighsInt col,
return (HighsInt)((Highs*)highs)->passColName(col, std::string(name));
}

HighsInt Highs_passModelName(const void* highs, const char* name) {
return (HighsInt)((Highs*)highs)->passModelName(std::string(name));
}

HighsInt Highs_readOptions(const void* highs, const char* filename) {
return (HighsInt)((Highs*)highs)->readOptions(filename);
}
Expand Down
10 changes: 10 additions & 0 deletions src/interfaces/highs_c_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -581,6 +581,16 @@ HighsInt Highs_passRowName(const void* highs, const HighsInt row,
HighsInt Highs_passColName(const void* highs, const HighsInt col,
const char* name);

/**
* Pass the name of the model.
*
* @param highs A pointer to the Highs instance.
* @param name The name of the model.
*
* @returns A `kHighsStatus` constant indicating whether the call succeeded.
*/
HighsInt Highs_passModelName(const void* highs, const char* name);

/**
* Read the option values from file.
*
Expand Down
10 changes: 10 additions & 0 deletions src/lp_data/Highs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -618,6 +618,16 @@ HighsStatus Highs::passRowName(const HighsInt row, const std::string& name) {
return HighsStatus::kOk;
}

HighsStatus Highs::passModelName(const std::string& name) {
if (int(name.length()) <= 0) {
highsLogUser(options_.log_options, HighsLogType::kError,
"Cannot define empty model names\n");
return HighsStatus::kError;
}
this->model_.lp_.model_name_ = name;
return HighsStatus::kOk;
}

HighsStatus Highs::readModel(const std::string& filename) {
this->logHeader();
HighsStatus return_status = HighsStatus::kOk;
Expand Down
48 changes: 48 additions & 0 deletions src/pdlp/CupdlpWrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,54 @@ HighsStatus solveLpCupdlp(const HighsOptions& options, HighsTimer& timer,
#if CUPDLP_DEBUG
analysePdlpSolution(options, lp, highs_solution);
#endif

free(cost);
free(lower);
free(upper);
free(csc_beg);
free(csc_idx);
free(csc_val);
free(rhs);

free(x_origin);
free(y_origin);

free(constraint_new_idx);

free(prob->cost);
free(prob->lower);
free(prob->upper);
free(prob->rhs);

free(prob->hasLower);
free(prob->hasUpper);

free(prob->data->csr_matrix->rowMatBeg);
free(prob->data->csr_matrix->rowMatIdx);
free(prob->data->csr_matrix->rowMatElem);
free(prob->data->csr_matrix);

free(prob->data->csc_matrix->colMatBeg);
free(prob->data->csc_matrix->colMatIdx);
free(prob->data->csc_matrix->colMatElem);
free(prob->data->csc_matrix);

free(prob->data);

free(prob);

free(csc_cpu->colMatBeg);
free(csc_cpu->colMatIdx);
free(csc_cpu->colMatElem);

free(csc_cpu);

if (scaling->rowScale != nullptr)
free(scaling->rowScale);
if (scaling->colScale != nullptr)
free(scaling->colScale);
free(scaling);

return HighsStatus::kOk;
}

Expand Down
10 changes: 10 additions & 0 deletions src/pdlp/cupdlp/cupdlp_utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,16 @@ cupdlp_int PDHG_Clear(CUPDLPwork *w) {
vec_clear(w->buffer);
}

if (w->buffer2 != NULL) {
// CUPDLP_FREE_VEC(w->buffer);
free(w->buffer2);
}

if (w->buffer3) {
// CUPDLP_FREE_VEC(w->buffer);
free(w->buffer3);
}

if (problem) {
// problem_clear(problem);
problem = cupdlp_NULL;
Expand Down

0 comments on commit d40867c

Please sign in to comment.