diff --git a/.Rbuildignore b/.Rbuildignore index ac9fde9..7376393 100755 --- a/.Rbuildignore +++ b/.Rbuildignore @@ -5,4 +5,4 @@ ^docs/.*$ ^.*\.o$ ^.*\.a$ -^\.github$ \ No newline at end of file +^\.github$ diff --git a/.github/.gitignore b/.github/.gitignore new file mode 100644 index 0000000..2d19fc7 --- /dev/null +++ b/.github/.gitignore @@ -0,0 +1 @@ +*.html diff --git a/.github/workflows/R-CMD-check.yaml b/.github/workflows/R-CMD-check.yaml new file mode 100644 index 0000000..d14f641 --- /dev/null +++ b/.github/workflows/R-CMD-check.yaml @@ -0,0 +1,62 @@ +# Workflow derived from https://github.com/r-lib/actions/tree/v2/examples +# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help +on: + push: + branches: [main, master] + pull_request: + +name: R-CMD-check.yaml + +permissions: read-all + +jobs: + R-CMD-check: + runs-on: ${{ matrix.config.os }} + + name: ${{ matrix.config.os }} (${{ matrix.config.r }}) + + strategy: + fail-fast: false + matrix: + config: + - {os: macos-latest, r: 'release'} + - {os: windows-latest, r: 'release'} + - {os: ubuntu-latest, r: 'devel', http-user-agent: 'release'} + - {os: ubuntu-latest, r: 'release'} + - {os: ubuntu-latest, r: 'oldrel-1'} + + env: + GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} + R_KEEP_PKG_SOURCE: yes + + steps: + - uses: actions/checkout@v4 + + - uses: r-lib/actions/setup-pandoc@v2 + + - uses: r-lib/actions/setup-r@v2 + with: + r-version: ${{ matrix.config.r }} + http-user-agent: ${{ matrix.config.http-user-agent }} + use-public-rspm: true + + - uses: r-lib/actions/setup-r-dependencies@v2 + with: + extra-packages: any::rcmdcheck + needs: check + + #- name: Build + # run: | + # R CMD build . + + - uses: r-lib/actions/check-r-package@v2 + with: + upload-results: true + upload-snapshots: true + build_args: 'c("--no-manual","--compact-vignettes=gs+qpdf")' + + # - name: Upload test results + # uses: actions/upload-artifact@v4 + # with: + # name: samplelim_${{ matrix.config.os }} + # path: samplelim*.tar.gz \ No newline at end of file diff --git a/DESCRIPTION b/DESCRIPTION index 73a7bd5..60cea0b 100755 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -32,5 +32,5 @@ Suggests: GGally, testthat (>= 3.0.0) Config/testthat/edition: 3 -RoxygenNote: 7.2.3 +RoxygenNote: 7.3.1 VignetteBuilder: knitr diff --git a/NAMESPACE b/NAMESPACE index bb20a21..bda342f 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -1,5 +1,6 @@ # Generated by roxygen2: do not edit by hand +S3method(plot,lim) export(Hpolytope) export(df2lim) export(full2red) @@ -14,6 +15,8 @@ importFrom(Rcpp,evalCpp) importFrom(Rcpp,loadModule) importFrom(Rcpp,sourceCpp) importFrom(Rglpk,Rglpk_solve_LP) +importFrom(igraph,graph_from_adjacency_matrix) +importFrom(igraph,plot.igraph) importFrom(limSolve,lsei) importFrom(methods,new) importFrom(stats,cov) diff --git a/R/plot_lim.R b/R/plot_lim.R index 2f02e9b..04fbb99 100644 --- a/R/plot_lim.R +++ b/R/plot_lim.R @@ -1,37 +1,50 @@ -plot.lim <- function(lim, seed=NULL, ...) { +#' Plot a metabolic network +#' +##' @param x An object of class `lim` containing a component `Flowmatrix`. +#' @param seed The seed for the PRNG of the R session +#' @param ... Additionnal arguments to be passed to the function \code{plot.igraph()} from the package \code{\\{igraph\\}}. +#' +#' @return Returns NULL, invisibly. +#' @method plot lim +#' +#' @examples +#' DF <- system.file("extdata", "DeclarationFileBOWF-short.txt", package = "samplelim") +#' BOWF <- df2lim(DF) +#' plot(BOWF) +plot.lim <- function(x, seed=NULL, ...) { # Check if 'Flowmatrix' exists in the object 'lim' - if (!exists("Flowmatrix", where = lim)) { + if (!exists("Flowmatrix", where = x)) { stop("'Flowmatrix' does not exist in used 'lim' object.") } # Check if 'Flowmatrix' is a matrix - if (!is.matrix(lim$Flowmatrix)) { + if (!is.matrix(x$Flowmatrix)) { stop("'Flowmatrix' from 'lim' object is not a matrix. ") } # Check if the dimensions of the matrix are equal to the expected dimensions # As dimensions depends of NComponents and NExternal we first check if they exist and are integers - if (!exists("NComponents", where = lim)){ + if (!exists("NComponents", where = x)){ stop("'NComponents' does not exist in used 'lim' object.") } - if (!is.integer(lim$NComponents)){ + if (!is.integer(x$NComponents)){ stop("'NComponents' from 'lim' object must be an integer.") } - if (!exists("NExternal", where = lim)){ + if (!exists("NExternal", where = x)){ stop("'NExternal' does not exist in used 'lim' object.") } - if (!is.integer(lim$NExternal)){ + if (!is.integer(x$NExternal)){ stop("'NExternal' from 'lim' object must be an integer.") } # Calculate the number of nodes - N_nodes <- lim$NComponents + lim$NExternal + N_nodes <- x$NComponents + x$NExternal expected_dim <- c(N_nodes, N_nodes) - if (all(dim(lim$Flowmatrix) != expected_dim)) { + if (all(dim(x$Flowmatrix) != expected_dim)) { stop("Flowmatrix from 'lim' object does not match the expected dimension.") } @@ -40,8 +53,8 @@ plot.lim <- function(lim, seed=NULL, ...) { set.seed(seed) } - adjacency_matrix <- as.matrix(lim$Flowmatrix > 0) - model_graph <- graph_from_adjacency_matrix(adjacency_matrix) - plot.igraph(model_graph, ...) + adjacency_matrix <- as.matrix(x$Flowmatrix > 0) + model_graph <- igraph::graph_from_adjacency_matrix(adjacency_matrix) + igraph::plot.igraph(model_graph, ...) } diff --git a/R/samplelim.R b/R/samplelim.R new file mode 100644 index 0000000..f0b2112 --- /dev/null +++ b/R/samplelim.R @@ -0,0 +1,35 @@ +#' MCMC sampling algorithms for linear inverse models +#' +#' @description +#' The package provides efficient implementations (C++ encoded) of +#' Monte Carlo Markov Chains (MCMC) algorithms for uniformly sampling high-dimensional polytopes. +#' It is particularly aimed at handling linear inverse models (LIM) in metabolic +#' (trophic, biochemical or urban) networks. +#' Some support functions are also included to facilitate its use by practitioners. +#' @keywords +#' polytope +#' sampling +#' mcmc +#' lim +#' mirror-walk +#' billard-walk +#' trophic-network +#' urban-network +#' biochemical-network +#' metabolic-network +#' @references { +#' D. Van Oevelen, K. Van den Meersche, F. J. R. Meysman, K. Soetaert, +#' J. J. Middelburg and A. F. Vézina, +#' \emph{Quantifying Food Web Flows Using Linear Inverse Models}, +#' Ecosystems \strong{13}, 32-45 (2010). +#' +#' B.T. Polyak and E.N. Gryazina, +#' \emph{Billiard walk - a new sampling algorithm for control and optimization}, +#' IFAC Proceedings Volumes, \strong{47(3)}, 6123-6128 (2014). +#' +#' V. Girardin, T. Grente, N. Niquil and P. Regnault, +#' \emph{Comparing and updating R packages of MCMC Algorithms for +#' Linear Inverse Modeling of Metabolic Networks}, to appear in +#' Communications in Statistics - Simulation and Computation (2025) +#' } +"_PACKAGE" \ No newline at end of file diff --git a/README.Rmd b/README.Rmd index 32f0aad..9e5b063 100644 --- a/README.Rmd +++ b/README.Rmd @@ -11,6 +11,7 @@ knitr::opts_chunk$set(echo = TRUE, eval = TRUE) ![](https://img.shields.io/badge/lifecycle-maturing-blue.svg) [![Project Status: Active – The project has reached a stable, usable state and is being actively developed.](http://www.repostatus.org/badges/latest/active.svg)](http://www.repostatus.org/#active) [![License: LGPL v3](https://img.shields.io/badge/License-LGPL%20v3-blue.svg)](https://www.gnu.org/licenses/lgpl-3.0) +[![R-CMD-check](https://github.com/pregnault/samplelim/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/pregnault/samplelim/actions/workflows/R-CMD-check.yaml) [![CRAN_Status_Badge](http://www.r-pkg.org/badges/version/regexplain)](https://cran.r-project.org/package=samplelim) The package `{samplelim}` for the R statistical software provides efficient implementations (C++ encoded) of Monte Carlo Markov Chains (MCMC) algorithms for uniformly sampling high-dimensional polytopes. diff --git a/man/plot.lim.Rd b/man/plot.lim.Rd new file mode 100644 index 0000000..cf17d65 --- /dev/null +++ b/man/plot.lim.Rd @@ -0,0 +1,26 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/plot_lim.R +\name{plot.lim} +\alias{plot.lim} +\title{Plot a metabolic network} +\usage{ +\method{plot}{lim}(x, seed = NULL, ...) +} +\arguments{ +\item{x}{A list of class `lim` containing a component `Flowmatrix`.} + +\item{seed}{The seed for the PRNG of the R session} + +\item{...}{Additionnal arguments to be passed to the function \code{plot.igraph()} from the package \code{\\{igraph\\}}.} +} +\value{ +Returns NULL, invisibly. +} +\description{ +Plot a metabolic network +} +\examples{ +DF <- system.file("extdata", "DeclarationFileBOWF-short.txt", package = "samplelim") +BOWF <- df2lim(DF) +plot(BOWF) +} diff --git a/man/samplelim-package.Rd b/man/samplelim-package.Rd old mode 100755 new mode 100644 index a9abbb5..0e32fb4 --- a/man/samplelim-package.Rd +++ b/man/samplelim-package.Rd @@ -1,34 +1,67 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/samplelim.R +\docType{package} \name{samplelim-package} -\alias{samplelim-package} \alias{samplelim} -\docType{package} -\title{ - A short title line describing what the package does -} +\alias{samplelim-package} +\title{MCMC sampling algorithms for linear inverse models} \description{ - A more detailed description of what the package does. A length - of about one to five lines is recommended. +The package provides efficient implementations (C++ encoded) of +Monte Carlo Markov Chains (MCMC) algorithms for uniformly sampling high-dimensional polytopes. +It is particularly aimed at handling linear inverse models (LIM) in metabolic +(trophic, biochemical or urban) networks. +Some support functions are also included to facilitate its use by practitioners. } -\details{ - This section should provide a more detailed overview of how to use the - package, including the most important functions. -} -\author{ -Your Name, email optional. +\references{ +{ +D. Van Oevelen, K. Van den Meersche, F. J. R. Meysman, K. Soetaert, +J. J. Middelburg and A. F. Vézina, +\emph{Quantifying Food Web Flows Using Linear Inverse Models}, + Ecosystems \strong{13}, 32-45 (2010). + +B.T. Polyak and E.N. Gryazina, +\emph{Billiard walk - a new sampling algorithm for control and optimization}, +IFAC Proceedings Volumes, \strong{47(3)}, 6123-6128 (2014). -Maintainer: Your Name +V. Girardin, T. Grente, N. Niquil and P. Regnault, +\emph{Comparing and updating R packages of MCMC Algorithms for +Linear Inverse Modeling of Metabolic Networks}, to appear in +Communications in Statistics - Simulation and Computation (2025) } -\references{ - This optional section can contain literature or other references for - background information. } -\keyword{ package } \seealso{ - Optional links to other man pages +Useful links: +\itemize{ + \item \url{https://github.com/pregnault/samplelim.git} + \item Report bugs at \url{https://github.com/pregnault/samplelim/issues} +} + } -\examples{ - \dontrun{ - ## Optional simple examples of the most important functions - ## These can be in \dontrun{} and \donttest{} blocks. - } +\author{ +\strong{Maintainer}: Philippe Regnault \email{philipperegnault@hotmail.com} (\href{https://orcid.org/0000-0002-7086-9030}{ORCID}) + +Authors: +\itemize{ + \item Jacques Bréhélin \email{breheli241@unicaen.fr} + \item Matthieu Dien \email{matthieu.dien@unicaen.fr} + \item Théo Grente \email{theo.grente@gmail.com} +} + +Other contributors: +\itemize{ + \item Valérie Girardin \email{valerie.girardin@unicaen.fr} (\href{https://orcid.org/0000-0001-9934-3561}{ORCID}) [contributor] + \item Nathalie Niquil \email{nathalie.niquil@unicaen.fr} [contributor] + \item Quentin Noguès [data contributor] +} + } +\keyword{billard-walk} +\keyword{biochemical-network} +\keyword{lim} +\keyword{mcmc} +\keyword{metabolic-network} +\keyword{mirror-walk} +\keyword{polytope} +\keyword{sampling} +\keyword{trophic-network} +\keyword{urban-network} diff --git a/src/external/lpsolve/build/lp_solve/colamd.c b/src/external/lpsolve/build/lp_solve/colamd.c index f48c6f5..2d94531 100644 --- a/src/external/lpsolve/build/lp_solve/colamd.c +++ b/src/external/lpsolve/build/lp_solve/colamd.c @@ -32,7 +32,7 @@ floating point operations than A. Symamd constructs a matrix M such that M'M has the same nonzero pattern of A, and then orders the columns of M using colmmd. The column ordering of M is then returned as the - row and column ordering P of A. + row and column ordering P of A. Authors: @@ -120,7 +120,7 @@ * TRUE and FALSE are predefined on some systems, so they are defined here only if not already defined. - + * web site changed * UNIX Makefile modified, to handle the case if "." is not in your path. @@ -186,7 +186,7 @@ Colamd: rows with more than (knobs [COLAMD_DENSE_ROW] * n_col) entries are removed prior to ordering. Columns with more than (knobs [COLAMD_DENSE_COL] * n_row) entries are removed prior to - ordering, and placed last in the output column ordering. + ordering, and placed last in the output column ordering. Symamd: uses only knobs [COLAMD_DENSE_ROW], which is knobs [0]. Rows and columns with more than (knobs [COLAMD_DENSE_ROW] * n) @@ -219,7 +219,7 @@ (AQ)'AQ=LL' have less fill-in and require fewer floating point operations than factorizing the unpermuted matrix A or A'A, respectively. - + Returns: TRUE (1) if successful, FALSE (0) otherwise. @@ -249,8 +249,8 @@ We do, however, guarantee that Alen >= colamd_recommended (nnz, n_row, n_col) - - or equivalently as a C preprocessor macro: + + or equivalently as a C preprocessor macro: Alen >= COLAMD_RECOMMENDED (nnz, n_row, n_col) @@ -388,7 +388,7 @@ Future versions may return more statistics in the stats array. Example: - + See http://www.cise.ufl.edu/research/sparse/colamd/example.c for a complete example. @@ -449,12 +449,12 @@ int A [nnz] ; Input argument. A is an integer array of size nnz, where nnz = p [n]. - + The row indices of the entries in column c of the matrix are held in A [(p [c]) ... (p [c+1]-1)]. The row indices in a given column c need not be in ascending order, and duplicate row indices may be present. However, symamd will run faster - if the columns are in sorted order with no duplicate entries. + if the columns are in sorted order with no duplicate entries. The matrix is 0-based. That is, rows are in the range 0 to n-1, and columns are in the range 0 to n-1. Symamd @@ -496,7 +496,7 @@ Symamd returns FALSE if stats is not present. stats [0]: number of dense or empty row and columns ignored - (and ordered last in the output permutation + (and ordered last in the output permutation perm). Note that a row/column can become "empty" if it contains only "dense" and/or "empty" columns/rows. @@ -703,7 +703,7 @@ #define ONES_COMPLEMENT(r) (-(r)-1) /* -------------------------------------------------------------------------- */ -/* Change for version 2.1: define TRUE and FALSE only if not yet defined */ +/* Change for version 2.1: define TRUE and FALSE only if not yet defined */ /* -------------------------------------------------------------------------- */ #ifndef TRUE @@ -859,11 +859,11 @@ PRIVATE void print_report PRIVATE int colamd_debug ; /* debug print level */ -#define DEBUG0(params) { (void) PRINTF params ; } -#define DEBUG1(params) { if (colamd_debug >= 1) (void) PRINTF params ; } -#define DEBUG2(params) { if (colamd_debug >= 2) (void) PRINTF params ; } -#define DEBUG3(params) { if (colamd_debug >= 3) (void) PRINTF params ; } -#define DEBUG4(params) { if (colamd_debug >= 4) (void) PRINTF params ; } +#define DEBUG0(params) { /*(void) PRINTF params*/ ; } +#define DEBUG1(params) { /*if (colamd_debug >= 1) (void) PRINTF params*/ ; } +#define DEBUG2(params) { /*if (colamd_debug >= 2) (void) PRINTF params*/ ; } +#define DEBUG3(params) { /*if (colamd_debug >= 3) (void) PRINTF params*/ ; } +#define DEBUG4(params) { /*if (colamd_debug >= 4) (void) PRINTF params*/ ; } #ifdef MATLAB_MEX_FILE #define ASSERT(expression) (mxAssert ((expression), "")) @@ -960,7 +960,7 @@ PUBLIC int colamd_recommended /* returns recommended value of Alen. */ int n_col /* number of columns in A */ ) { - return (COLAMD_RECOMMENDED (nnz, n_row, n_col)) ; + return (COLAMD_RECOMMENDED (nnz, n_row, n_col)) ; } @@ -1041,7 +1041,7 @@ PUBLIC int symamd /* return TRUE if OK, FALSE otherwise */ int nnz ; /* number of entries in A */ int i ; /* row index of A */ int j ; /* column index of A */ - int k ; /* row index of M */ + int k ; /* row index of M */ int mnz ; /* number of nonzeros in M */ int pp ; /* index into a column of A */ int last_row ; /* last row seen in the current column */ @@ -1508,7 +1508,7 @@ PUBLIC int colamd /* returns TRUE if successful, FALSE otherwise*/ stats [COLAMD_DENSE_ROW] = n_row - n_row2 ; stats [COLAMD_DENSE_COL] = n_col - n_col2 ; stats [COLAMD_DEFRAG_COUNT] = ngarbage ; - DEBUG0 (("colamd: done.\n")) ; + DEBUG0 (("colamd: done.\n")) ; return (TRUE) ; } @@ -1570,7 +1570,7 @@ PRIVATE int init_rows_cols /* returns TRUE if OK, or FALSE otherwise */ Colamd_Col Col [], /* of size n_col+1 */ int A [], /* row indices of A, of size Alen */ int p [], /* pointers to columns in A, of size n_col+1 */ - int stats [COLAMD_STATS] /* colamd statistics */ + int stats [COLAMD_STATS] /* colamd statistics */ ) { /* === Local variables ================================================== */ @@ -3043,125 +3043,7 @@ PRIVATE void print_report char *method, int stats [COLAMD_STATS] ) -{ - - int i1, i2, i3 ; - - if (!stats) - { - PRINTF ("%s: No statistics available.\n", method) ; - return ; - } - - i1 = stats [COLAMD_INFO1] ; - i2 = stats [COLAMD_INFO2] ; - i3 = stats [COLAMD_INFO3] ; - - if (stats [COLAMD_STATUS] >= 0) - { - PRINTF ("%s: OK. ", method) ; - } - else - { - PRINTF ("%s: ERROR. ", method) ; - } - - switch (stats [COLAMD_STATUS]) - { - - case COLAMD_OK_BUT_JUMBLED: - - PRINTF ("Matrix has unsorted or duplicate row indices.\n") ; - - PRINTF ("%s: number of duplicate or out-of-order row indices: %d\n", - method, i3) ; - - PRINTF ("%s: last seen duplicate or out-of-order row index: %d\n", - method, INDEX (i2)) ; - - PRINTF ("%s: last seen in column: %d", - method, INDEX (i1)) ; - - /* no break - fall through to next case instead */ - - case COLAMD_OK: - - PRINTF ("\n") ; - - PRINTF ("%s: number of dense or empty rows ignored: %d\n", - method, stats [COLAMD_DENSE_ROW]) ; - - PRINTF ("%s: number of dense or empty columns ignored: %d\n", - method, stats [COLAMD_DENSE_COL]) ; - - PRINTF ("%s: number of garbage collections performed: %d\n", - method, stats [COLAMD_DEFRAG_COUNT]) ; - break ; - - case COLAMD_ERROR_A_not_present: - - PRINTF ("Array A (row indices of matrix) not present.\n") ; - break ; - - case COLAMD_ERROR_p_not_present: - - PRINTF ("Array p (column pointers for matrix) not present.\n") ; - break ; - - case COLAMD_ERROR_nrow_negative: - - PRINTF ("Invalid number of rows (%d).\n", i1) ; - break ; - - case COLAMD_ERROR_ncol_negative: - - PRINTF ("Invalid number of columns (%d).\n", i1) ; - break ; - - case COLAMD_ERROR_nnz_negative: - - PRINTF ("Invalid number of nonzero entries (%d).\n", i1) ; - break ; - - case COLAMD_ERROR_p0_nonzero: - - PRINTF ("Invalid column pointer, p [0] = %d, must be zero.\n", i1) ; - break ; - - case COLAMD_ERROR_A_too_small: - - PRINTF ("Array A too small.\n") ; - PRINTF (" Need Alen >= %d, but given only Alen = %d.\n", - i1, i2) ; - break ; - - case COLAMD_ERROR_col_length_negative: - - PRINTF - ("Column %d has a negative number of nonzero entries (%d).\n", - INDEX (i1), i2) ; - break ; - - case COLAMD_ERROR_row_index_out_of_bounds: - - PRINTF - ("Row index (row %d) out of bounds (%d to %d) in column %d.\n", - INDEX (i2), INDEX (0), INDEX (i3-1), INDEX (i1)) ; - break ; - - case COLAMD_ERROR_out_of_memory: - - PRINTF ("Out of memory.\n") ; - break ; - - case COLAMD_ERROR_internal_error: - - /* if this happens, there is a bug in the code */ - PRINTF - ("Internal error! Please contact authors (davis@cise.ufl.edu).\n") ; - break ; - } -} +{} diff --git a/src/external/lpsolve/build/lp_solve/commonlib.c b/src/external/lpsolve/build/lp_solve/commonlib.c index c53a752..f0f0c44 100644 --- a/src/external/lpsolve/build/lp_solve/commonlib.c +++ b/src/external/lpsolve/build/lp_solve/commonlib.c @@ -861,63 +861,15 @@ double timeNow(void) /* List a vector of INT values for the given index range */ void blockWriteINT(FILE *output, char *label, int *myvector, int first, int last) -{ - int i, k = 0; - - fprintf(output, "%s", label); - fprintf(output, "\n"); - for(i = first; i <= last; i++) { - fprintf(output, " %5d", myvector[i]); - k++; - if(k % 12 == 0) { - fprintf(output, "\n"); - k = 0; - } - } - if(k % 12 != 0) - fprintf(output, "\n"); -} +{} /* List a vector of MYBOOL values for the given index range */ void blockWriteBOOL(FILE *output, char *label, MYBOOL *myvector, int first, int last, MYBOOL asRaw) -{ - int i, k = 0; - - fprintf(output, "%s", label); - fprintf(output, "\n"); - for(i = first; i <= last; i++) { - if(asRaw) - fprintf(output, " %1d", myvector[i]); - else - fprintf(output, " %5s", my_boolstr(myvector[i])); - k++; - if(k % 36 == 0) { - fprintf(output, "\n"); - k = 0; - } - } - if(k % 36 != 0) - fprintf(output, "\n"); -} +{} /* List a vector of LPSREAL values for the given index range */ void blockWriteREAL(FILE *output, char *label, LPSREAL *myvector, int first, int last) -{ - int i, k = 0; - - fprintf(output, "%s", label); - fprintf(output, "\n"); - for(i = first; i <= last; i++) { - fprintf(output, " %18g", myvector[i]); - k++; - if(k % 4 == 0) { - fprintf(output, "\n"); - k = 0; - } - } - if(k % 4 != 0) - fprintf(output, "\n"); -} +{} /* CONSOLE vector and matrix printing routines */ @@ -926,13 +878,6 @@ void printvec( int n, LPSREAL *x, int modulo ) int i; if (modulo <= 0) modulo = 5; - for (i = 1; i<=n; i++) { - if(mod(i, modulo) == 1) - printf("\n%2d:%12g", i, x[i]); - else - printf(" %2d:%12g", i, x[i]); - } - if(i % modulo != 0) printf("\n"); } diff --git a/src/external/lpsolve/build/lp_solve/ini.c b/src/external/lpsolve/build/lp_solve/ini.c index c157b9c..3abb098 100644 --- a/src/external/lpsolve/build/lp_solve/ini.c +++ b/src/external/lpsolve/build/lp_solve/ini.c @@ -34,24 +34,13 @@ FILE *ini_open(char *filename) } void ini_writecomment(FILE *fp, char *comment) -{ - fprintf(fp, "; %s\n", comment); -} +{} void ini_writeheader(FILE *fp, char *header, int addnewline) -{ - if((addnewline) && (ftell(fp) > 0)) - fputs("\n", fp); - fprintf(fp, "[%s]\n", header); -} +{} void ini_writedata(FILE *fp, char *name, char *data) -{ - if(name != NULL) - fprintf(fp, "%s=%s\n", name, data); - else - fprintf(fp, "%s\n", data); -} +{} int ini_readdata(FILE *fp, char *data, int szdata, int withcomment) { diff --git a/src/external/lpsolve/build/lp_solve/lp_MPS.c b/src/external/lpsolve/build/lp_solve/lp_MPS.c index 3c737de..1f18d9e 100644 --- a/src/external/lpsolve/build/lp_solve/lp_MPS.c +++ b/src/external/lpsolve/build/lp_solve/lp_MPS.c @@ -1093,7 +1093,7 @@ MYBOOL __WINAPI MPS_readex(lprec **newlp, void *userhandle, read_modeldata_func /* lp_solve needs a name for the SOS */ if(variant == 0) { if(strlen(field3) == 0) /* CPLEX format does not provide a SOS name; create one */ - sprintf(field3, "SOS_%d", SOS_count(lp) + 1); + ;//sprintf(field3, "SOS_%d", SOS_count(lp) + 1); } else { /* Remap XPRESS format name */ strcpy(field3, field1); @@ -1185,7 +1185,7 @@ static void number(char *str,LPSREAL value) do { n--; - i=sprintf(_str,"%*.*E",n,n-6,(double) value); + i=0;//sprintf(_str,"%*.*E",n,n-6,(double) value); if (i>12) { char *ptr=strchr(_str,'E'); @@ -1203,11 +1203,11 @@ static void number(char *str,LPSREAL value) int n=13; do { - i=sprintf(_str,"%*.0f",--n,(double) value); + i=0;//sprintf(_str,"%*.0f",--n,(double) value); } while (i>12); } else { - if (((i=sprintf(_str,"%12.10f",(double) value))>12) && (_str[12]>='5')) { + if (((i=0/*sprintf(_str,"%12.10f",(double) value)*/)>12) && (_str[12]>='5')) { for (i=11;i>=0;i--) if (_str[i]!='.') { if (++_str[i]>'9') _str[i]='0'; @@ -1225,7 +1225,7 @@ static void number(char *str,LPSREAL value) do { n--; - i=sprintf(_str,"%*.*E",n,n-7,(double) value); + i=0;//sprintf(_str,"%*.*E",n,n-7,(double) value); if (i>12) { char *ptr=strchr(_str,'E'); @@ -1243,11 +1243,11 @@ static void number(char *str,LPSREAL value) int n=13; do { - i=sprintf(_str,"%*.0f",--n,(double) value); + i=0;//sprintf(_str,"%*.0f",--n,(double) value); } while (i>12); } else - if (((i=sprintf(_str,"%12.9f",(double) value))>12) && (_str[12]>='5')) { + if (((i=0/*sprintf(_str,"%12.9f",(double) value)*/)>12) && (_str[12]>='5')) { for (i=11;i>=1;i--) if (_str[i]!='.') { if (++_str[i]>'9') _str[i]='0'; @@ -1275,7 +1275,7 @@ static char *formatnumber12(char *numberbuffer, double a) STATIC char *MPSnameFIXED(char *name0, char *name) { - sprintf(name0, "%-8.8s", name); + //sprintf(name0, "%-8.8s", name); return(name0); } @@ -1580,23 +1580,7 @@ static int __WINAPI write_lpdata(void *userhandle, char *buf) MYBOOL MPS_writefile(lprec *lp, int typeMPS, char *filename) { - FILE *output = stdout; - MYBOOL ok; - - if (filename != NULL) { - ok = ((output = fopen(filename, "w")) != NULL); - if(!ok) - return(ok); - } - else - output = lp->outstream; - - ok = MPS_writefileex(lp, typeMPS, (void *) output, write_lpdata); - - if (filename != NULL) - fclose(output); - - return(ok); +return 1; } MYBOOL MPS_writehandle(lprec *lp, int typeMPS, FILE *output) @@ -1788,68 +1772,5 @@ MYBOOL MPS_readBAS(lprec *lp, int typeMPS, char *filename, char *info) MYBOOL MPS_writeBAS(lprec *lp, int typeMPS, char *filename) { - int ib, in; - MYBOOL ok; - char name1[100], name2[100]; - FILE *output = stdout; - char * (*MPSname)(char *name0, char *name); - char name0[9]; - - /* Set name formatter */ - if((typeMPS & MPSFIXED) == MPSFIXED) - MPSname = MPSnameFIXED; - else if((typeMPS & MPSFREE) == MPSFREE) - MPSname = MPSnameFREE; - else { - report(lp, IMPORTANT, "MPS_writeBAS: unrecognized MPS name type.\n"); - return(FALSE); - } - - /* Open the file for writing */ - ok = (MYBOOL) ((filename == NULL) || ((output = fopen(filename,"w")) != NULL)); - if(!ok) - return(ok); - if(filename == NULL && lp->outstream != NULL) - output = lp->outstream; - - fprintf(output, "NAME %s Rows %d Cols %d Iters %.0f\n", - get_lp_name(lp), lp->rows, lp->columns, (double) get_total_iter(lp)); - - ib = lp->rows; - in = 0; - while ((ib < lp->sum) || (in < lp->sum)) { - - /* Find next basic variable (skip slacks) */ - ib++; - while((ib <= lp->sum) && !lp->is_basic[ib]) - ib++; - - /* Find next non-basic variable (skip lower-bounded structural variables) */ - in++; - while((in <= lp->sum) && (lp->is_basic[in] || - ((in > lp->rows) && lp->is_lower[in]))) - in++; - - /* Check if we have a basic/non-basic variable pair */ - if((ib <= lp->sum) && (in <= lp->sum)) { - strcpy(name1, MPSname(name0, (ib <= lp->rows ? get_row_name(lp, ib) : - get_col_name(lp, ib-lp->rows)))); - strcpy(name2, MPSname(name0, (in <= lp->rows ? get_row_name(lp, in) : - get_col_name(lp, in-lp->rows)))); - fprintf(output, " %2s %s %s\n", (lp->is_lower[in] ? "XL" : "XU"), name1, name2); - } - - /* Otherwise just write the bound state of the non-basic variable */ - else if(in <= lp->sum) { - strcpy(name1, MPSname(name0, (in <= lp->rows ? get_row_name(lp, in) : - get_col_name(lp, in-lp->rows)))); - fprintf(output, " %2s %s\n", (lp->is_lower[in] ? "LL" : "UL"), name1); - } - - } - fprintf(output, "ENDATA\n"); - - if(filename != NULL) - fclose(output); - return( ok ); +return 1; } diff --git a/src/external/lpsolve/build/lp_solve/lp_lib.c b/src/external/lpsolve/build/lp_solve/lp_lib.c index 268898d..34651b5 100644 --- a/src/external/lpsolve/build/lp_solve/lp_lib.c +++ b/src/external/lpsolve/build/lp_solve/lp_lib.c @@ -146,24 +146,12 @@ STATIC int yieldformessages(lprec *lp) } void __WINAPI set_outputstream(lprec *lp, FILE *stream) -{ - if((lp->outstream != NULL) && (lp->outstream != stdout)) { - if(lp->streamowned) - fclose(lp->outstream); - else - fflush(lp->outstream); - } - if(stream == NULL) - lp->outstream = stdout; - else - lp->outstream = stream; - lp->streamowned = FALSE; -} +{} MYBOOL __WINAPI set_outputfile(lprec *lp, char *filename) { MYBOOL ok; - FILE *output = stdout; + FILE *output = NULL; ok = (MYBOOL) ((filename == NULL) || (*filename == 0) || ((output = fopen(filename,"w")) != NULL)); if(ok) { @@ -5529,7 +5517,7 @@ lprec * __WINAPI read_XLI(char *xliname, char *modelname, char *dataname, char * lp->verbose = verbose; if(!set_XLI(lp, xliname)) { free_lp(&lp); - printf("read_XLI: No valid XLI package selected or available.\n"); + //printf("read_XLI: No valid XLI package selected or available.\n"); } else { if(!lp->xli_readmodel(lp, modelname, (dataname != NULL) && (*dataname != 0) ? dataname : NULL, options, verbose)) @@ -6093,10 +6081,6 @@ char * __WINAPI get_origrow_name(lprec *lp, int rownr) if (!allocCHAR(lp, &lp->rowcol_name, 20, FALSE)) return(NULL); ptr = lp->rowcol_name; - if(newrow) - sprintf(ptr, ROWNAMEMASK2, rownr); - else - sprintf(ptr, ROWNAMEMASK, rownr); } return(ptr); } @@ -6161,10 +6145,6 @@ char * __WINAPI get_origcol_name(lprec *lp, int colnr) if (!allocCHAR(lp, &lp->rowcol_name, 20, FALSE)) return(NULL); ptr = lp->rowcol_name; - if(newcol) - sprintf(ptr, COLNAMEMASK2, colnr); - else - sprintf(ptr, COLNAMEMASK, colnr); } return(ptr); } @@ -9679,7 +9659,7 @@ STATIC int prepare_GUB(lprec *lp) /* Add the GUB */ j = GUB_count(lp) + 1; - sprintf(GUBname, "GUB_%d", i); + //sprintf(GUBname, "GUB_%d", i); add_GUB(lp, GUBname, j, k, members); /* Unmark the GUBs */ @@ -9892,7 +9872,7 @@ int preprocess(lprec *lp) if(lp->names_used && (lp->col_name[j] == NULL)) { char fieldn[50]; - sprintf(fieldn, "__AntiBodyOf(%d)__", j); + //sprintf(fieldn, "__AntiBodyOf(%d)__", j); if(!set_col_name(lp, lp->columns, fieldn)) { /* if (!set_col_name(lp, lp->columns, get_col_name(lp, j))) { */ ok = FALSE; diff --git a/src/external/lpsolve/build/lp_solve/lp_matrix.c b/src/external/lpsolve/build/lp_solve/lp_matrix.c index ce585e2..d88b538 100644 --- a/src/external/lpsolve/build/lp_solve/lp_matrix.c +++ b/src/external/lpsolve/build/lp_solve/lp_matrix.c @@ -3033,14 +3033,10 @@ STATIC MYBOOL __WINAPI invert(lprec *lp, MYBOOL shiftbounds, MYBOOL final) lp->bfp_finishfactorization(lp); /* Recompute the RHS ( Ref. lp_solve inverse logic and Chvatal p. 121 ) */ -#ifdef DebugInv - blockWriteLREAL(stdout, "RHS-values pre invert", lp->rhs, 0, lp->rows); -#endif + recompute_solution(lp, shiftbounds); restartPricer(lp, AUTOMATIC); -#ifdef DebugInv - blockWriteLREAL(stdout, "RHS-values post invert", lp->rhs, 0, lp->rows); -#endif + Cleanup: /* Check for numerical instability indicated by frequent refactorizations */ diff --git a/src/external/lpsolve/build/lp_solve/lp_params.c b/src/external/lpsolve/build/lp_solve/lp_params.c index ef96137..c605289 100644 --- a/src/external/lpsolve/build/lp_solve/lp_params.c +++ b/src/external/lpsolve/build/lp_solve/lp_params.c @@ -323,7 +323,7 @@ static void write_params1(lprec *lp, FILE *fp, char *header, int newline) ini_writeheader(fp, header, newline); lp_solve_version(&majorversion, &minorversion, &release, &build); - sprintf(buf, "lp_solve version %d.%d settings\n", majorversion, minorversion); + //sprintf(buf, "lp_solve version %d.%d settings\n", majorversion, minorversion); ini_writecomment(fp, buf); for(i = 0; i < sizeof(functions) / sizeof(*functions); i++) { switch(functions[i].type) { @@ -354,10 +354,10 @@ static void write_params1(lprec *lp, FILE *fp, char *header, int newline) case intfunction: case longfunction: case MYBOOLfunction: - sprintf(buf, "%d", ret); + //sprintf(buf, "%d", ret); break; case REALfunction: - sprintf(buf, "%g", a); + //sprintf(buf, "%g", a); break; } } diff --git a/src/external/lpsolve/build/lp_solve/lp_presolve.c b/src/external/lpsolve/build/lp_solve/lp_presolve.c index abd7ac1..d972730 100644 --- a/src/external/lpsolve/build/lp_solve/lp_presolve.c +++ b/src/external/lpsolve/build/lp_solve/lp_presolve.c @@ -32,8 +32,6 @@ initial version of column aggregation code. ------------------------------------------------------------------------- */ -//Modified by Apostolos Chalkis in May of 2020. - #include #include "commonlib.h" #include "lp_lib.h" @@ -170,13 +168,17 @@ STATIC MYBOOL presolve_rebuildUndo(lprec *lp, MYBOOL isprimal) if(isprimal) { if(psdata->primalundo != NULL) mat = psdata->primalundo->tracker; - //solution = lp->full_solution + lp->presolve_undo->orig_rows; // Comment out by Apostolos Chalkis + if(mat == NULL) + return( FALSE ); + solution = lp->full_solution + lp->presolve_undo->orig_rows; slacks = lp->full_solution; } else { if(psdata->dualundo != NULL) mat = psdata->dualundo->tracker; - //solution = lp->full_duals; // Comment out by Apostolos Chalkis + if(mat == NULL) + return( FALSE ); + solution = lp->full_duals; slacks = lp->full_duals + lp->presolve_undo->orig_rows; } if(mat == NULL) @@ -3608,42 +3610,7 @@ STATIC MYBOOL presolve_finalize(presolverec *psdata) STATIC MYBOOL presolve_debugdump(lprec *lp, presolverec *psdata, char *filename, MYBOOL doappend) { - FILE *output = stdout; - int size; - MYBOOL ok; - - ok = (MYBOOL) ((filename == NULL) || ((output = fopen(filename, my_if(doappend, "a", "w"))) != NULL)); - if(!ok) - return(ok); - if((filename == NULL) && (lp->outstream != NULL)) - output = lp->outstream; - - fprintf(output, "\nPRESOLVE - Status at loop %d:%d:%d\n", - psdata->outerloops, psdata->middleloops, psdata->innerloops); - fprintf(output, "Model size: %d rows (%d equalities, %d less than), %d columns\n", - psdata->rows->varmap->count, psdata->EQmap->count, psdata->LTmap->count, psdata->cols->varmap->count); - - fprintf(output, "\nMAPPERS\n-------\n\n"); - size = 1; - blockWriteINT(output, "colmap", psdata->cols->varmap->map, 0, size*psdata->cols->varmap->size); - blockWriteINT(output, "rowmap", psdata->rows->varmap->map, 0, size*psdata->rows->varmap->size); - blockWriteINT(output, "EQmap", psdata->EQmap->map, 0, size*psdata->EQmap->size); - blockWriteINT(output, "LTmap", psdata->LTmap->map, 0, size*psdata->LTmap->size); - - fprintf(output, "\nCOUNTS\n------\n\n"); - blockWriteINT(output, "plucount", psdata->rows->plucount, 0, lp->rows); - blockWriteINT(output, "negcount", psdata->rows->negcount, 0, lp->rows); - blockWriteINT(output, "pluneg", psdata->rows->pluneg, 0, lp->rows); - - fprintf(output, "\nSUMS\n----\n\n"); - blockWriteREAL(output, "pluupper", psdata->rows->pluupper, 0, lp->rows); - blockWriteREAL(output, "negupper", psdata->rows->negupper, 0, lp->rows); - blockWriteREAL(output, "plulower", psdata->rows->pluupper, 0, lp->rows); - blockWriteREAL(output, "neglower", psdata->rows->negupper, 0, lp->rows); - - if(filename != NULL) - fclose(output); - return(ok); + return 1; } int CMP_CALLMODEL compRedundant(const UNIONTYPE QSORTrec *current, const UNIONTYPE QSORTrec *candidate) @@ -4788,7 +4755,7 @@ STATIC int presolve_SOS1(presolverec *psdata, int *nCoeffChanged, int *nConRemov /* Define a new SOS instance */ ix = SOS_count(lp) + 1; - sprintf(SOSname, "SOS_%d", ix); + //sprintf(SOSname, "SOS_%d", ix); ix = add_SOS(lp, SOSname, 1, ix, 0, NULL, NULL); if(jx == EQ) SOS_set_GUB(lp->SOS, ix, TRUE); @@ -5758,14 +5725,6 @@ write_lp(lp, "test_in.lp"); /* Write to lp-formatted file for debugging */ } else if((status == RUNNING) && (i >= NORMAL)) { char lonum[20], upnum[20]; - if(my_infinite(lp, Value1)) - sprintf(lonum, "%13s", "-Inf"); - else - sprintf(lonum, "%+12g", Value1); - if(my_infinite(lp, Value2)) - sprintf(upnum, "%-13s", "Inf"); - else - sprintf(upnum, "%+-12g", Value2); report(lp, i, "%20s [ %s < Z < %s ]\n", "", lonum, upnum); } diff --git a/src/external/lpsolve/build/lp_solve/lp_report.c b/src/external/lpsolve/build/lp_solve/lp_report.c index f38fa3b..efb84bb 100644 --- a/src/external/lpsolve/build/lp_solve/lp_report.c +++ b/src/external/lpsolve/build/lp_solve/lp_report.c @@ -59,7 +59,7 @@ void __VACALL report(lprec *lp, int level, char *format, ...) if(lp == NULL) { va_start(ap, format); - vfprintf(stderr, format, ap); + //vfprintf(stderr, format, ap); va_end(ap); } else if(level <= lp->verbose) { @@ -71,10 +71,10 @@ void __VACALL report(lprec *lp, int level, char *format, ...) } if(lp->outstream != NULL) { va_start(ap, format); - vfprintf(lp->outstream, format, ap); + //vfprintf(lp->outstream, format, ap); va_end(ap); - if(lp->outstream != stdout) - fflush(lp->outstream); + //if(lp->outstream != stdout) + // fflush(lp->outstream); } } #ifdef xParanoia @@ -105,9 +105,9 @@ STATIC void debug_print(lprec *lp, char *format, ...) if (lp == NULL) { va_start(ap, format); - vfprintf(stderr, format, ap); + //vfprintf(stderr, format, ap); va_end(ap); - fputc('\n', stderr); + //fputc('\n', stderr); } else if(lp->debuginfo != NULL) { @@ -164,18 +164,18 @@ void blockWriteLREAL(FILE *output, char *label, LREAL *vector, int first, int la { int i, k = 0; - fprintf(output, "%s", label); - fprintf(output, "\n"); + //fprintf(output, "%s", label); + //fprintf(output, "\n"); for(i = first; i <= last; i++) { - fprintf(output, " %18g", vector[i]); + //fprintf(output, " %18g", vector[i]); k++; if(my_mod(k, 4) == 0) { - fprintf(output, "\n"); + //fprintf(output, "\n"); k = 0; } } if(my_mod(k, 4) != 0) - fprintf(output, "\n"); + ;//fprintf(output, "\n"); } /* List the current user data matrix columns over the selected row range */ @@ -193,21 +193,21 @@ void blockWriteAMAT(FILE *output, const char *label, lprec* lp, int first, int l if(last < 0) last = lp->rows; - fprintf(output, "%s", label); - fprintf(output, "\n"); + //fprintf(output, "%s", label); + //fprintf(output, "\n"); if(first == 0) { for(j = 1; j <= lp->columns; j++) { hold = get_mat(lp, 0, j); - fprintf(output, " %18g", hold); + //fprintf(output, " %18g", hold); k++; if(my_mod(k, 4) == 0) { - fprintf(output, "\n"); + //fprintf(output, "\n"); k = 0; } } if(my_mod(k, 4) != 0) { - fprintf(output, "\n"); + //fprintf(output, "\n"); k = 0; } first++; @@ -231,20 +231,20 @@ void blockWriteAMAT(FILE *output, const char *label, lprec* lp, int first, int l else jb = lp->columns+1; } - fprintf(output, " %18g", hold); + //fprintf(output, " %18g", hold); k++; if(my_mod(k, 4) == 0) { - fprintf(output, "\n"); + //fprintf(output, "\n"); k = 0; } } if(my_mod(k, 4) != 0) { - fprintf(output, "\n"); + //fprintf(output, "\n"); k = 0; } } if(my_mod(k, 4) != 0) - fprintf(output, "\n"); + ;//fprintf(output, "\n"); } /* List the current basis matrix columns over the selected row range */ @@ -258,8 +258,8 @@ void blockWriteBMAT(FILE *output, const char *label, lprec* lp, int first, int l if(last < 0) last = lp->rows; - fprintf(output, "%s", label); - fprintf(output, "\n"); + //fprintf(output, "%s", label); + //fprintf(output, "\n"); for(i = first; i <= last; i++) { for(j = 1; j <= lp->rows; j++) { @@ -275,152 +275,40 @@ void blockWriteBMAT(FILE *output, const char *label, lprec* lp, int first, int l if(i == 0) modifyOF1(lp, jb, &hold, 1); hold = unscaled_mat(lp, hold, i, jb); - fprintf(output, " %18g", hold); + ;//fprintf(output, " %18g", hold); k++; if(my_mod(k, 4) == 0) { - fprintf(output, "\n"); + ;//fprintf(output, "\n"); k = 0; } } if(my_mod(k, 4) != 0) { - fprintf(output, "\n"); + ;//fprintf(output, "\n"); k = 0; } } if(my_mod(k, 4) != 0) - fprintf(output, "\n"); + ;//fprintf(output, "\n"); } /* Do a generic readable data dump of key lp_solve model variables; principally for run difference and debugging purposes */ MYBOOL REPORT_debugdump(lprec *lp, char *filename, MYBOOL livedata) { - FILE *output = stdout; - MYBOOL ok; - - ok = (MYBOOL) ((filename == NULL) || ((output = fopen(filename,"w")) != NULL)); - if(!ok) - return(ok); - if((filename == NULL) && (lp->outstream != NULL)) - output = lp->outstream; - - fprintf(output, "\nGENERAL INFORMATION\n-------------------\n\n"); - fprintf(output, "Model size: %d rows (%d equalities, %d Lagrangean), %d columns (%d integers, %d SC, %d SOS, %d GUB)\n", - lp->rows, lp->equalities, get_Lrows(lp), lp->columns, - lp->int_vars, lp->sc_vars, SOS_count(lp), GUB_count(lp)); - fprintf(output, "Data size: %d model non-zeros, %d invB non-zeros (engine is %s)\n", - get_nonzeros(lp), my_if(lp->invB == NULL, 0, lp->bfp_nonzeros(lp, FALSE)), lp->bfp_name()); - fprintf(output, "Internal sizes: %d rows allocated, %d columns allocated, %d columns used, %d eta length\n", - lp->rows_alloc, lp->columns_alloc, lp->columns, my_if(lp->invB == NULL, 0, lp->bfp_colcount(lp))); - fprintf(output, "Memory use: %d sparse matrix, %d eta\n", - lp->matA->mat_alloc, my_if(lp->invB == NULL, 0, lp->bfp_memallocated(lp))); - fprintf(output, "Parameters: Maximize=%d, Names used=%d, Scalingmode=%d, Presolve=%d, SimplexPivot=%d\n", - is_maxim(lp), lp->names_used, lp->scalemode, lp->do_presolve, lp->piv_strategy); - fprintf(output, "Precision: EpsValue=%g, EpsPrimal=%g, EpsDual=%g, EpsPivot=%g, EpsPerturb=%g\n", - lp->epsvalue, lp->epsprimal, lp->epsdual, lp->epspivot, lp->epsperturb); - fprintf(output, "Stability: AntiDegen=%d, Improvement=%d, Split variables at=%g\n", - lp->improve, lp->anti_degen, lp->negrange); - fprintf(output, "B&B settings: BB pivot rule=%d, BB branching=%s, BB strategy=%d, Integer precision=%g, MIP gaps=%g,%g\n", - lp->bb_rule, my_boolstr(lp->bb_varbranch), lp->bb_floorfirst, lp->epsint, lp->mip_absgap, lp->mip_relgap); - - fprintf(output, "\nCORE DATA\n---------\n\n"); - blockWriteINT(output, "Column starts", lp->matA->col_end, 0, lp->columns); - blockWriteINT(output, "row_type", lp->row_type, 0, lp->rows); - blockWriteREAL(output, "orig_rhs", lp->orig_rhs, 0, lp->rows); - blockWriteREAL(output, "orig_lowbo", lp->orig_lowbo, 0, lp->sum); - blockWriteREAL(output, "orig_upbo", lp->orig_upbo, 0, lp->sum); - blockWriteINT(output, "row_type", lp->row_type, 0, lp->rows); - blockWriteBOOL(output, "var_type", lp->var_type, 0, lp->columns, TRUE); - blockWriteAMAT(output, "A", lp, 0, lp->rows); - - if(livedata) { - fprintf(output, "\nPROCESS DATA\n------------\n\n"); - blockWriteREAL(output, "Active rhs", lp->rhs, 0, lp->rows); - blockWriteINT(output, "Basic variables", lp->var_basic, 0, lp->rows); - blockWriteBOOL(output, "is_basic", lp->is_basic, 0, lp->sum, TRUE); - blockWriteREAL(output, "lowbo", lp->lowbo, 0, lp->sum); - blockWriteREAL(output, "upbo", lp->upbo, 0, lp->sum); - if(lp->scalars != NULL) - blockWriteREAL(output, "scalars", lp->scalars, 0, lp->sum); - } - - if(filename != NULL) - fclose(output); - return(ok); + return 1; } /* High level reports for model results */ void REPORT_objective(lprec *lp) -{ - if(lp->outstream == NULL) - return; - if(fabs(lp->best_solution[0]) < 1e-5) - fprintf(lp->outstream, "\nValue of objective function: %g\n", (double)lp->best_solution[0]); - else - fprintf(lp->outstream, "\nValue of objective function: %.8f\n", (double)lp->best_solution[0]); - fflush(lp->outstream); -} +{} void REPORT_solution(lprec *lp, int columns) -{ - int i, j, n; - LPSREAL value; - presolveundorec *psundo = lp->presolve_undo; - MYBOOL NZonly = (MYBOOL) ((lp->print_sol & AUTOMATIC) > 0); - - if(lp->outstream == NULL) - return; - - fprintf(lp->outstream, "\nActual values of the variables:\n"); - if(columns <= 0) - columns = 2; - n = 0; - for(i = 1; i <= psundo->orig_columns; i++) { - j = psundo->orig_rows + i; - value = get_var_primalresult(lp, j); - if(NZonly && (fabs(value) < lp->epsprimal)) - continue; - n = (n+1) % columns; - fprintf(lp->outstream, "%-20s %12g", get_origcol_name(lp, i), (double) value); - if(n == 0) - fprintf(lp->outstream, "\n"); - else - fprintf(lp->outstream, " "); - } - - fflush(lp->outstream); -} /* REPORT_solution */ +{} /* REPORT_solution */ void REPORT_constraints(lprec *lp, int columns) -{ - int i, n; - LPSREAL value; - MYBOOL NZonly = (MYBOOL) ((lp->print_sol & AUTOMATIC) > 0); - - if(lp->outstream == NULL) - return; - - if(columns <= 0) - columns = 2; - - fprintf(lp->outstream, "\nActual values of the constraints:\n"); - n = 0; - for(i = 1; i <= lp->rows; i++) { - value = (double)lp->best_solution[i]; - if(NZonly && (fabs(value) < lp->epsprimal)) - continue; - n = (n+1) % columns; - fprintf(lp->outstream, "%-20s %12g", get_row_name(lp, i), value); - if(n == 0) - fprintf(lp->outstream, "\n"); - else - fprintf(lp->outstream, " "); - } - - fflush(lp->outstream); -} +{} void REPORT_duals(lprec *lp) { @@ -432,16 +320,18 @@ void REPORT_duals(lprec *lp) return; ret = get_ptr_sensitivity_objex(lp, &objfrom, &objtill, &objfromvalue, NULL); + /* if(ret) { - fprintf(lp->outstream, "\nObjective function limits:\n"); - fprintf(lp->outstream, " From Till FromValue\n"); - for(i = 1; i <= lp->columns; i++) - if(!is_splitvar(lp, i)) - fprintf(lp->outstream, "%-20s %15.7g %15.7g %15.7g\n", get_col_name(lp, i), - (double)objfrom[i - 1], (double)objtill[i - 1], (double)objfromvalue[i - 1]); - } + //fprintf(lp->outstream, "\nObjective function limits:\n"); + //fprintf(lp->outstream, " From Till FromValue\n"); + //for(i = 1; i <= lp->columns; i++) + // if(!is_splitvar(lp, i)) + //fprintf(lp->outstream, "%-20s %15.7g %15.7g %15.7g\n", get_col_name(lp, i), + // (double)objfrom[i - 1], (double)objtill[i - 1], (double)objfromvalue[i - 1]); + }*/ ret = get_ptr_sensitivity_rhs(lp, &duals, &dualsfrom, &dualstill); + /* if(ret) { fprintf(lp->outstream, "\nDual values with from - till limits:\n"); fprintf(lp->outstream, " Dual value From Till\n"); @@ -450,7 +340,7 @@ void REPORT_duals(lprec *lp) (i <= lp->rows) ? get_row_name(lp, i) : get_col_name(lp, i - lp->rows), (double)duals[i - 1], (double)dualsfrom[i - 1], (double)dualstill[i - 1]); fflush(lp->outstream); - } + }*/ } /* Printing of sensitivity analysis reports */ @@ -509,70 +399,7 @@ void REPORT_extended(lprec *lp) /* A more readable lp-format report of the model; antiquated and not updated */ void REPORT_lp(lprec *lp) -{ - int i, j; - - if(lp->outstream == NULL) - return; - - fprintf(lp->outstream, "Model name: %s\n", get_lp_name(lp)); - fprintf(lp->outstream, " "); - - for(j = 1; j <= lp->columns; j++) - fprintf(lp->outstream, "%8s ", get_col_name(lp,j)); - - fprintf(lp->outstream, "\n%simize ", (is_maxim(lp) ? "Max" : "Min")); - for(j = 1; j <= lp->columns; j++) - fprintf(lp->outstream, "%8g ", get_mat(lp, 0, j)); - fprintf(lp->outstream, "\n"); - - for(i = 1; i <= lp->rows; i++) { - fprintf(lp->outstream, "%-9s ", get_row_name(lp, i)); - for(j = 1; j <= lp->columns; j++) - fprintf(lp->outstream, "%8g ", get_mat(lp, i, j)); - if(is_constr_type(lp, i, GE)) - fprintf(lp->outstream, ">= "); - else if(is_constr_type(lp, i, LE)) - fprintf(lp->outstream, "<= "); - else - fprintf(lp->outstream, " = "); - fprintf(lp->outstream, "%8g", get_rh(lp, i)); - - if(is_constr_type(lp, i, GE)) { - if(get_rh_upper(lp, i) < lp->infinite) - fprintf(lp->outstream, " %s = %8g", "upbo", get_rh_upper(lp, i)); - } - else if(is_constr_type(lp, i, LE)) { - if(get_rh_lower(lp, i) > -lp->infinite) - fprintf(lp->outstream, " %s = %8g", "lowbo", get_rh_lower(lp, i)); - } - fprintf(lp->outstream, "\n"); - } - - fprintf(lp->outstream, "Type "); - for(i = 1; i <= lp->columns; i++) { - if(is_int(lp,i)) - fprintf(lp->outstream, " Int "); - else - fprintf(lp->outstream, " Real "); - } - - fprintf(lp->outstream, "\nupbo "); - for(i = 1; i <= lp->columns; i++) - if(get_upbo(lp, i) >= lp->infinite) - fprintf(lp->outstream, " Inf "); - else - fprintf(lp->outstream, "%8g ", get_upbo(lp, i)); - fprintf(lp->outstream, "\nlowbo "); - for(i = 1; i <= lp->columns; i++) - if(get_lowbo(lp, i) <= -lp->infinite) - fprintf(lp->outstream, " -Inf "); - else - fprintf(lp->outstream, "%8g ", get_lowbo(lp, i)); - fprintf(lp->outstream, "\n"); - - fflush(lp->outstream); -} +{} /* Report the scaling factors used; extremely rarely used */ void REPORT_scales(lprec *lp) @@ -583,7 +410,7 @@ void REPORT_scales(lprec *lp) if(lp->outstream == NULL) return; - + /* if(lp->scaling_used) { fprintf(lp->outstream, "\nScale factors:\n"); for(i = 0; i <= lp->rows + colMax; i++) @@ -592,6 +419,7 @@ void REPORT_scales(lprec *lp) (double)lp->scalars[i]); } fflush(lp->outstream); + */ } /* Report the traditional tableau corresponding to the current basis */ @@ -599,7 +427,7 @@ MYBOOL REPORT_tableau(lprec *lp) { int j, row_nr, *coltarget; LPSREAL *prow = NULL; - FILE *stream = lp->outstream; + FILE *stream;// = lp->outstream; if(lp->outstream == NULL) return(FALSE); @@ -614,43 +442,17 @@ MYBOOL REPORT_tableau(lprec *lp) return(FALSE); } - fprintf(stream, "\n"); - fprintf(stream, "Tableau at iter %.0f:\n", (double) get_total_iter(lp)); - - for(j = 1; j <= lp->sum; j++) - if (!lp->is_basic[j]) - fprintf(stream, "%15d", (j <= lp->rows ? - (j + lp->columns) * ((lp->orig_upbo[j] == 0) || - (is_chsign(lp, j)) ? 1 : -1) : j - lp->rows) * - (lp->is_lower[j] ? 1 : -1)); - fprintf(stream, "\n"); - coltarget = (int *) mempool_obtainVector(lp->workarrays, lp->columns+1, sizeof(*coltarget)); if(!get_colIndexA(lp, SCAN_USERVARS+USE_NONBASICVARS, coltarget, FALSE)) { mempool_releaseVector(lp->workarrays, (char *) coltarget, FALSE); return(FALSE); } for(row_nr = 1; (row_nr <= lp->rows + 1); row_nr++) { - if (row_nr <= lp->rows) - fprintf(stream, "%3d", (lp->var_basic[row_nr] <= lp->rows ? - (lp->var_basic[row_nr] + lp->columns) * ((lp->orig_upbo[lp->var_basic [row_nr]] == 0) || - (is_chsign(lp, lp->var_basic[row_nr])) ? 1 : -1) : lp->var_basic[row_nr] - lp->rows) * - (lp->is_lower[lp->var_basic [row_nr]] ? 1 : -1)); - else - fprintf(stream, " "); bsolve(lp, row_nr <= lp->rows ? row_nr : 0, prow, NULL, lp->epsmachine*DOUBLEROUND, 1.0); prod_xA(lp, coltarget, prow, NULL, lp->epsmachine, 1.0, prow, NULL, MAT_ROUNDDEFAULT); - for(j = 1; j <= lp->rows + lp->columns; j++) - if (!lp->is_basic[j]) - fprintf(stream, "%15.7f", prow[j] * (lp->is_lower[j] ? 1 : -1) * - (row_nr <= lp->rows ? 1 : -1)); - fprintf(stream, "%15.7f", lp->rhs[row_nr <= lp->rows ? row_nr : 0] * - (double) ((row_nr <= lp->rows) || (is_maxim(lp)) ? 1 : -1)); - fprintf(stream, "\n"); } - fflush(stream); mempool_releaseVector(lp->workarrays, (char *) coltarget, FALSE); FREE(prow); @@ -699,92 +501,6 @@ void REPORT_modelinfo(lprec *lp, MYBOOL doName, char *datainfo) If colndx is NULL, then the full constraint matrix is assumed. */ MYBOOL REPORT_mat_mmsave(lprec *lp, char *filename, int *colndx, MYBOOL includeOF, char *infotext) { - int n, m, nz, i, j, k, kk; - MATrec *mat = lp->matA; - MM_typecode matcode; - FILE *output = stdout; - MYBOOL ok; - LPSREAL *acol = NULL; - int *nzlist = NULL; - - /* Open file */ - ok = (MYBOOL) ((filename == NULL) || ((output = fopen(filename,"w")) != NULL)); - if(!ok) - return(ok); - if((filename == NULL) && (lp->outstream != NULL)) - output = lp->outstream; - - /* Compute column and non-zero counts */ - if(colndx == lp->var_basic) { - if(!lp->basis_valid) - return( FALSE ); - m = lp->rows; - } - else if(colndx != NULL) - m = colndx[0]; - else - m = lp->columns; - n = lp->rows; - nz = 0; - - for(j = 1; j <= m; j++) { - k = (colndx == NULL ? n + j : colndx[j]); - if(k > n) { - k -= lp->rows; - nz += mat_collength(mat, k); - if(includeOF && is_OF_nz(lp, k)) - nz++; - } - else - nz++; - } - kk = 0; - if(includeOF) { - n++; /* Row count */ - kk++; /* Row index offset */ - } - - /* Initialize */ - mm_initialize_typecode(&matcode); - mm_set_matrix(&matcode); - mm_set_coordinate(&matcode); - mm_set_real(&matcode); - - mm_write_banner(output, matcode); - mm_write_mtx_crd_size(output, n+kk, m, nz+(colndx == lp->var_basic ? 1 : 0)); - - /* Allocate working arrays for sparse column storage */ - allocREAL(lp, &acol, n+2, FALSE); - allocINT(lp, &nzlist, n+2, FALSE); - - /* Write the matrix non-zero values column-by-column. - NOTE: matrixMarket files use 1-based indeces, - i.e. first row of a vector has index 1, not 0. */ - if(infotext != NULL) { - fprintf(output, "%%\n"); - fprintf(output, "%% %s\n", infotext); - fprintf(output, "%%\n"); - } - if(includeOF && (colndx == lp->var_basic)) - fprintf(output, "%d %d %g\n", 1, 1, 1.0); - for(j = 1; j <= m; j++) { - k = (colndx == NULL ? lp->rows + j : colndx[j]); - if(k == 0) - continue; - nz = obtain_column(lp, k, acol, nzlist, NULL); - for(i = 1; i <= nz; i++) { - if(!includeOF && (nzlist[i] == 0)) - continue; - fprintf(output, "%d %d %g\n", nzlist[i]+kk, j+kk, acol[i]); - } - } - fprintf(output, "%% End of MatrixMarket file\n"); - - /* Finish */ - FREE(acol); - FREE(nzlist); - fclose(output); - - return(ok); +return 1; } diff --git a/src/external/lpsolve/build/lp_solve/lp_rlp.c b/src/external/lpsolve/build/lp_solve/lp_rlp.c index e2ec726..d8ea98d 100644 --- a/src/external/lpsolve/build/lp_solve/lp_rlp.c +++ b/src/external/lpsolve/build/lp_solve/lp_rlp.c @@ -845,12 +845,9 @@ while (YYID (0)) # endif # define YYDPRINTF(Args) \ -do { \ - if (lp_yydebug) \ - YYFPRINTF Args; \ -} while (YYID (0)) # define YY_SYMBOL_PRINT(Title, Type, Value, Location) \ +/* do { \ if (lp_yydebug) \ { \ @@ -860,7 +857,7 @@ do { \ YYFPRINTF (stderr, "\n"); \ } \ } while (YYID (0)) - +*/ /*--------------------------------. | Print this symbol on YYOUTPUT. | @@ -917,13 +914,8 @@ lp_yy_symbol_print (lp_yyoutput, lp_yytype, lp_yyvaluep, parm, scanner) void *scanner; #endif { - if (lp_yytype < YYNTOKENS) - YYFPRINTF (lp_yyoutput, "token %s (", lp_yytname[lp_yytype]); - else - YYFPRINTF (lp_yyoutput, "nterm %s (", lp_yytname[lp_yytype]); - lp_yy_symbol_value_print (lp_yyoutput, lp_yytype, lp_yyvaluep, parm, scanner); - YYFPRINTF (lp_yyoutput, ")"); + //YYFPRINTF (lp_yyoutput, ")"); } /*------------------------------------------------------------------. @@ -942,10 +934,10 @@ lp_yy_stack_print (bottom, top) lp_yytype_int16 *top; #endif { - YYFPRINTF (stderr, "Stack now"); - for (; bottom <= top; ++bottom) - YYFPRINTF (stderr, " %d", *bottom); - YYFPRINTF (stderr, "\n"); + //YYFPRINTF (stderr, "Stack now"); + //for (; bottom <= top; ++bottom) + //YYFPRINTF (stderr, " %d", *bottom); + //YYFPRINTF (stderr, "\n"); } # define YY_STACK_PRINT(Bottom, Top) \ @@ -975,16 +967,16 @@ lp_yy_reduce_print (lp_yyvsp, lp_yyrule, parm, scanner) int lp_yynrhs = lp_yyr2[lp_yyrule]; int lp_yyi; unsigned long int lp_yylno = lp_yyrline[lp_yyrule]; - YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n", - lp_yyrule - 1, lp_yylno); + //YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n", + // lp_yyrule - 1, lp_yylno); /* The symbols being reduced. */ for (lp_yyi = 0; lp_yyi < lp_yynrhs; lp_yyi++) { - fprintf (stderr, " $%d = ", lp_yyi + 1); - lp_yy_symbol_print (stderr, lp_yyrhs[lp_yyprhs[lp_yyrule] + lp_yyi], - &(lp_yyvsp[(lp_yyi + 1) - (lp_yynrhs)]) - , parm, scanner); - fprintf (stderr, "\n"); + ;//fprintf (stderr, " $%d = ", lp_yyi + 1); + //lp_yy_symbol_print (stderr, lp_yyrhs[lp_yyprhs[lp_yyrule] + lp_yyi], +// &(lp_yyvsp[(lp_yyi + 1) - (lp_yynrhs)]) +// , parm, scanner); + //fprintf (stderr, "\n"); } } @@ -1374,7 +1366,7 @@ int lp_yynerrs; Keep to zero when no symbol should be popped. */ int lp_yylen = 0; - YYDPRINTF ((stderr, "Starting parse\n")); + //YYDPRINTF ((stderr, "Starting parse\n")); lp_yystate = 0; lp_yyerrstatus = 0; @@ -1460,14 +1452,14 @@ int lp_yynerrs; lp_yyvsp = lp_yyvs + lp_yysize - 1; - YYDPRINTF ((stderr, "Stack size increased to %lu\n", - (unsigned long int) lp_yystacksize)); + //YYDPRINTF ((stderr, "Stack size increased to %lu\n", + // (unsigned long int) lp_yystacksize)); if (lp_yyss + lp_yystacksize - 1 <= lp_yyssp) YYABORT; } - YYDPRINTF ((stderr, "Entering state %d\n", lp_yystate)); + //YYDPRINTF ((stderr, "Entering state %d\n", lp_yystate)); goto lp_yybackup; @@ -1489,14 +1481,14 @@ int lp_yynerrs; /* YYCHAR is either YYEMPTY or YYEOF or a valid look-ahead symbol. */ if (lp_yychar == YYEMPTY) { - YYDPRINTF ((stderr, "Reading a token: ")); + //YYDPRINTF ((stderr, "Reading a token: ")); lp_yychar = YYLEX; } if (lp_yychar <= YYEOF) { lp_yychar = lp_yytoken = YYEOF; - YYDPRINTF ((stderr, "Now at end of input.\n")); + //YYDPRINTF ((stderr, "Now at end of input.\n")); } else { @@ -2078,7 +2070,7 @@ int lp_yynerrs; char buf[16]; pv->SOSweight++; - sprintf(buf, "SOS%d", pv->SOSweight); + //sprintf(buf, "SOS%d", pv->SOSweight); storevarandweight(pp, buf); check_int_sec_sos_free_decl(pp, (int) pv->Within_int_decl, (int) pv->Within_sec_decl, 2, (int) pv->Within_free_decl); @@ -2130,7 +2122,7 @@ int lp_yynerrs; char buf[16]; pv->SOSweight++; - sprintf(buf, "SOS%d", pv->SOSweight); + //sprintf(buf, "SOS%d", pv->SOSweight); storevarandweight(pp, buf); check_int_sec_sos_free_decl(pp, (int) pv->Within_int_decl, (int) pv->Within_sec_decl, 2, (int) pv->Within_free_decl); diff --git a/src/external/lpsolve/build/lp_solve/lp_wlp.c b/src/external/lpsolve/build/lp_solve/lp_wlp.c index 30e2a16..f838737 100644 --- a/src/external/lpsolve/build/lp_solve/lp_wlp.c +++ b/src/external/lpsolve/build/lp_solve/lp_wlp.c @@ -68,7 +68,7 @@ STATIC int write_lprow(lprec *lp, int rowno, void *userhandle, write_modeldata_f nchars += write_data(userhandle, write_modeldata, " "); else first = FALSE; - sprintf(buf, "%+.12g", (double)a); + //sprintf(buf, "%+.12g", (double)a); if(strcmp(buf, "-1") == 0) nchars += write_data(userhandle, write_modeldata, "-"); else if(strcmp(buf, "+1") == 0) @@ -331,28 +331,12 @@ MYBOOL __WINAPI write_lpex(lprec *lp, void *userhandle, write_modeldata_func wri static int __WINAPI write_lpdata(void *userhandle, char *buf) { - return(fprintf((FILE *) userhandle, "%s", buf)); + return(0); } MYBOOL LP_writefile(lprec *lp, char *filename) { - FILE *output = stdout; - MYBOOL ok; - - if (filename != NULL) { - ok = (MYBOOL) ((output = fopen(filename, "w")) != NULL); - if(!ok) - return(ok); - } - else - output = lp->outstream; - - ok = write_lpex(lp, (void *) output, write_lpdata); - - if (filename != NULL) - fclose(output); - - return(ok); + return(0); } MYBOOL LP_writehandle(lprec *lp, FILE *output) @@ -362,7 +346,7 @@ MYBOOL LP_writehandle(lprec *lp, FILE *output) if (output != NULL) set_outputstream(lp, output); - output = lp->outstream; + //output = lp->outstream; ok = write_lpex(lp, (void *) output, write_lpdata); diff --git a/src/external/lpsolve/build/lp_solve/lusol.c b/src/external/lpsolve/build/lp_solve/lusol.c index 5573fe8..e157205 100644 --- a/src/external/lpsolve/build/lp_solve/lusol.c +++ b/src/external/lpsolve/build/lp_solve/lusol.c @@ -63,6 +63,17 @@ void *clean_realloc(void *oldptr, int width, int newsize, int oldsize) { newsize *= width; oldsize *= width; + /* this works around valgrind reporting a realloc(3) call with size = 0. + According to https://linux.die.net/man/3/realloc glibc frees the + memory in this case, and (maybe?) returns NULL: + > if size is equal to zero, and ptr is not NULL, then the call + > is equivalent to free(ptr). */ +#ifdef __linux__ + if (oldptr != NULL && newsize == 0) { + free(oldptr); + return NULL; + } +#endif oldptr = LUSOL_REALLOC(oldptr, newsize); if(newsize > oldsize) /* MEMCLEAR(oldptr+oldsize, newsize-oldsize); */ @@ -254,7 +265,7 @@ LUSOLrec *LUSOL_create(FILE *outstream, int msgfil, int pivotmodel, int updateli return( newLU ); newLU->luparm[LUSOL_IP_SCALAR_NZA] = LUSOL_MULT_nz_a; - newLU->outstream = outstream; + //newLU->outstream = outstream; newLU->luparm[LUSOL_IP_PRINTUNIT] = msgfil; newLU->luparm[LUSOL_IP_PRINTLEVEL] = LUSOL_MSG_SINGULARITY; @@ -629,7 +640,7 @@ void LUSOL_report(LUSOLrec *LUSOL, int msglevel, char *format, ...) if(LUSOL == NULL) { va_start(ap, format); - vfprintf(stderr, format, ap); + //vfprintf(stderr, format, ap); va_end(ap); } else if(msglevel >= 0 /*LUSOL->luparm[2]*/) { @@ -637,15 +648,15 @@ void LUSOL_report(LUSOLrec *LUSOL, int msglevel, char *format, ...) char buff[255]; va_start(ap, format); - vsprintf(buff, format, ap); + //vsprintf(buff, format, ap); va_end(ap); - LUSOL->writelog(LUSOL, LUSOL->loghandle, buff); + //LUSOL->writelog(LUSOL, LUSOL->loghandle, buff); } if(LUSOL->outstream != NULL) { va_start(ap, format); - vfprintf(LUSOL->outstream, format, ap); + //vfprintf(LUSOL->outstream, format, ap); va_end(ap); - fflush(LUSOL->outstream); + //fflush(LUSOL->outstream); } } } diff --git a/src/external/lpsolve/build/lp_solve/lusol6a.c b/src/external/lpsolve/build/lp_solve/lusol6a.c index 41c09f9..6b65b65 100644 --- a/src/external/lpsolve/build/lp_solve/lusol6a.c +++ b/src/external/lpsolve/build/lp_solve/lusol6a.c @@ -327,11 +327,11 @@ void LU6CHK(LUSOLrec *LUSOL, int MODE, int LENA2, int *INFORM) if(LUSOL->luparm[LUSOL_IP_SINGULARITIES]>0) { *INFORM = LUSOL_INFORM_LUSINGULAR; NDEFIC = LUSOL->n-NRANK; - if((LUSOL->outstream!=NULL) && (LPRINT>=LUSOL_MSG_SINGULARITY)) { - LUSOL_report(LUSOL, 0, "Singular(m%cn) rank:%9d n-rank:%8d nsing:%9d\n", - relationChar(LUSOL->m, LUSOL->n),NRANK,NDEFIC, - LUSOL->luparm[LUSOL_IP_SINGULARITIES]); - } + //if((LUSOL->outstream!=NULL) && (LPRINT>=LUSOL_MSG_SINGULARITY)) { + // LUSOL_report(LUSOL, 0, "Singular(m%cn) rank:%9d n-rank:%8d nsing:%9d\n", + // relationChar(LUSOL->m, LUSOL->n),NRANK,NDEFIC, + // LUSOL->luparm[LUSOL_IP_SINGULARITIES]); + //} } /* Exit. */ LUSOL->luparm[LUSOL_IP_INFORM] = *INFORM; @@ -583,8 +583,8 @@ void LU6LT(LUSOLrec *LUSOL, int *INFORM, LPSREAL V[], int NZidx[]) #else TEMP = V[LUSOL->indr[L1]] + SUM; SUM += LUSOL->a[L]*V[J]; - printf("V[%3d] = V[%3d] + L[%d,%d]*V[%3d]\n", LUSOL->indr[L1], LUSOL->indr[L1], J,LUSOL->indr[L1], J); - printf("%6g = %6g + %6g*%6g\n", V[LUSOL->indr[L1]] + SUM, TEMP, LUSOL->a[L], V[J]); + //printf("V[%3d] = V[%3d] + L[%d,%d]*V[%3d]\n", LUSOL->indr[L1], LUSOL->indr[L1], J,LUSOL->indr[L1], J); + //printf("%6g = %6g + %6g*%6g\n", V[LUSOL->indr[L1]] + SUM, TEMP, LUSOL->a[L], V[J]); #endif } #endif @@ -617,11 +617,6 @@ void print_L0(LUSOLrec *LUSOL) } } - for(I = 1; I <= LUSOL->n; I++) { - for(J = 1; J <= LUSOL->m; J++) - fprintf(stdout, "%10g", denseL0[(LUSOL->n+1)*(J-1) + I]); - fprintf(stdout, "\n"); - } LUSOL_FREE(denseL0); } diff --git a/src/external/lpsolve/build/lp_solve/lusol6l0.c b/src/external/lpsolve/build/lp_solve/lusol6l0.c index c7555e2..977184c 100644 --- a/src/external/lpsolve/build/lp_solve/lusol6l0.c +++ b/src/external/lpsolve/build/lp_solve/lusol6l0.c @@ -156,8 +156,8 @@ void LU6L0T_v(LUSOLrec *LUSOL, LUSOLmat *mat, LPSREAL V[], int NZidx[], int *INF #else TEMP = V[J]; V[J] += VPIV * mat->a[L]; - printf("V[%3d] = V[%3d] + L[%d,%d]*V[%3d]\n", J, J, KK,J, KK); - printf("%6g = %6g + %6g*%6g\n", V[J], TEMP, mat->a[L], VPIV); + //printf("V[%3d] = V[%3d] + L[%d,%d]*V[%3d]\n", J, J, KK,J, KK); + //printf("%6g = %6g + %6g*%6g\n", V[J], TEMP, mat->a[L], VPIV); #endif } #endif diff --git a/src/external/lpsolve/build/lp_solve/lusol6u.c b/src/external/lpsolve/build/lp_solve/lusol6u.c index 5e1e3bf..30ab370 100644 --- a/src/external/lpsolve/build/lp_solve/lusol6u.c +++ b/src/external/lpsolve/build/lp_solve/lusol6u.c @@ -164,8 +164,8 @@ void LU6U0_v(LUSOLrec *LUSOL, LUSOLmat *mat, LPSREAL V[], LPSREAL W[], int NZidx #else TEMP = V[J]; V[J] += T * mat->a[L]; - printf("V[%3d] = V[%3d] + L[%d,%d]*V[%3d]\n", J, J, I,J, I); - printf("%6g = %6g + %6g*%6g\n", V[J], TEMP, mat->a[L], T); + //printf("V[%3d] = V[%3d] + L[%d,%d]*V[%3d]\n", J, J, I,J, I); + //printf("%6g = %6g + %6g*%6g\n", V[J], TEMP, mat->a[L], T); #endif } #endif diff --git a/src/external/lpsolve/build/lp_solve/mmio.c b/src/external/lpsolve/build/lp_solve/mmio.c index 185ef51..2e4cc51 100644 --- a/src/external/lpsolve/build/lp_solve/mmio.c +++ b/src/external/lpsolve/build/lp_solve/mmio.c @@ -31,8 +31,8 @@ int mm_read_unsymmetric_sparse(const char *fname, int *M_, int *N_, int *nz_, if (mm_read_banner(f, &matcode) != 0) { - printf("mm_read_unsymetric: Could not process Matrix Market banner "); - printf(" in file [%s]\n", fname); + //printf("mm_read_unsymetric: Could not process Matrix Market banner "); + //printf(" in file [%s]\n", fname); return -1; } @@ -41,9 +41,9 @@ int mm_read_unsymmetric_sparse(const char *fname, int *M_, int *N_, int *nz_, if ( !(mm_is_real(matcode) && mm_is_matrix(matcode) && mm_is_sparse(matcode))) { - fprintf(stderr, "Sorry, this application does not support "); - fprintf(stderr, "Market Market type: [%s]\n", - mm_typecode_to_str(matcode)); + //fprintf(stderr, "Sorry, this application does not support "); + //fprintf(stderr, "Market Market type: [%s]\n", + // mm_typecode_to_str(matcode)); return -1; } @@ -51,7 +51,7 @@ int mm_read_unsymmetric_sparse(const char *fname, int *M_, int *N_, int *nz_, if (mm_read_mtx_crd_size(f, &M, &N, &nz) !=0) { - fprintf(stderr, "read_unsymmetric_sparse(): could not parse matrix size.\n"); + //fprintf(stderr, "read_unsymmetric_sparse(): could not parse matrix size.\n"); return -1; } @@ -182,10 +182,7 @@ int mm_read_banner(FILE *f, MM_typecode *matcode) int mm_write_mtx_crd_size(FILE *f, int M, int N, int nz) { - if (fprintf(f, "%d %d %d\n", M, N, nz) < 0) - return MM_COULD_NOT_WRITE_FILE; - else - return 0; + return 0; } int mm_read_mtx_crd_size(FILE *f, int *M, int *N, int *nz ) @@ -247,10 +244,7 @@ int mm_read_mtx_array_size(FILE *f, int *M, int *N) int mm_write_mtx_array_size(FILE *f, int M, int N) { - if (fprintf(f, "%d %d\n", M, N) < 0) - return MM_COULD_NOT_WRITE_FILE; - else - return 0; + return 0; } @@ -384,57 +378,20 @@ int mm_read_mtx_crd(char *fname, int *M, int *N, int *nz, int **I, int **J, int mm_write_banner(FILE *f, MM_typecode matcode) { - char *str = mm_typecode_to_str(matcode); - int ret_code; + //char *str = mm_typecode_to_str(matcode); + //int ret_code = -1; - ret_code = fprintf(f, "%s %s\n", MatrixMarketBanner, str); + //ret_code = fprintf(f, "%s %s\n", MatrixMarketBanner, str); /* free(str); This is a bug from the official distribution - KE fixed */ - if (ret_code < 0 ) + //if (ret_code < 0 ) return MM_COULD_NOT_WRITE_FILE; - else - return 0; + //else + // return 0; } int mm_write_mtx_crd(char fname[], int M, int N, int nz, int I[], int J[], double val[], MM_typecode matcode) { - FILE *f; - int i; - - if (strcmp(fname, "stdout") == 0) - f = stdout; - else - if ((f = fopen(fname, "w")) == NULL) - return MM_COULD_NOT_WRITE_FILE; - - /* print banner followed by typecode */ - fprintf(f, "%s ", MatrixMarketBanner); - fprintf(f, "%s\n", mm_typecode_to_str(matcode)); - - /* print matrix sizes and nonzeros */ - fprintf(f, "%d %d %d\n", M, N, nz); - - /* print values */ - if (mm_is_pattern(matcode)) - for (i=0; iHash_tab)) == NULL) { char buf[256]; - sprintf(buf, "Unknown variable %s declared integer, ignored", name); + //sprintf(buf, "Unknown variable %s declared integer, ignored", name); error(pp, NORMAL, buf); } else if(pp->coldata[hp->index].must_be_int) { char buf[256]; - sprintf(buf, "Variable %s declared integer more than once, ignored", name); + //sprintf(buf, "Variable %s declared integer more than once, ignored", name); error(pp, NORMAL, buf); } else { @@ -187,14 +187,14 @@ static void add_int_var(parse_parm *pp, char *name, short int_decl) if(pp->coldata[hp->index].lowbo != -DEF_INFINITE * (LPSREAL) 10.0) { char buf[256]; - sprintf(buf, "Variable %s: lower bound on variable redefined", name); + //sprintf(buf, "Variable %s: lower bound on variable redefined", name); error(pp, NORMAL, buf); } pp->coldata[hp->index].lowbo = 0; if(pp->coldata[hp->index].upbo < DEF_INFINITE) { char buf[256]; - sprintf(buf, "Variable %s: upper bound on variable redefined", name); + //sprintf(buf, "Variable %s: upper bound on variable redefined", name); error(pp, NORMAL, buf); } pp->coldata[hp->index].upbo = 1; @@ -213,13 +213,13 @@ static void add_sec_var(parse_parm *pp, char *name) if((hp = findhash(name, pp->Hash_tab)) == NULL) { char buf[256]; - sprintf(buf, "Unknown variable %s declared semi-continuous, ignored", name); + //sprintf(buf, "Unknown variable %s declared semi-continuous, ignored", name); error(pp, NORMAL, buf); } else if(pp->coldata[hp->index].must_be_sec) { char buf[256]; - sprintf(buf, "Variable %s declared semi-continuous more than once, ignored", name); + //sprintf(buf, "Variable %s declared semi-continuous more than once, ignored", name); error(pp, NORMAL, buf); } else @@ -233,7 +233,7 @@ int set_sec_threshold(parse_parm *pp, char *name, LPSREAL threshold) if((hp = findhash(name, pp->Hash_tab)) == NULL) { char buf[256]; - sprintf(buf, "Unknown variable %s declared semi-continuous, ignored", name); + //sprintf(buf, "Unknown variable %s declared semi-continuous, ignored", name); error(pp, NORMAL, buf); return(FALSE); } @@ -242,7 +242,7 @@ int set_sec_threshold(parse_parm *pp, char *name, LPSREAL threshold) char buf[256]; pp->coldata[hp->index].must_be_sec = FALSE; - sprintf(buf, "Variable %s declared semi-continuous, but it has a non-negative lower bound (%f), ignored", name, pp->coldata[hp->index].lowbo); + //sprintf(buf, "Variable %s declared semi-continuous, but it has a non-negative lower bound (%f), ignored", name, pp->coldata[hp->index].lowbo); error(pp, NORMAL, buf); } if (threshold > pp->coldata[hp->index].lowbo) @@ -258,13 +258,13 @@ static void add_free_var(parse_parm *pp, char *name) if((hp = findhash(name, pp->Hash_tab)) == NULL) { char buf[256]; - sprintf(buf, "Unknown variable %s declared free, ignored", name); + //sprintf(buf, "Unknown variable %s declared free, ignored", name); error(pp, NORMAL, buf); } else if(pp->coldata[hp->index].must_be_free) { char buf[256]; - sprintf(buf, "Variable %s declared free more than once, ignored", name); + //sprintf(buf, "Variable %s declared free more than once, ignored", name); error(pp, NORMAL, buf); } else @@ -446,7 +446,7 @@ static int store(parse_parm *pp, char *variable, if(value == 0) { char buf[256]; - sprintf(buf, "(store) Warning, variable %s has an effective coefficient of 0, Ignored", variable); + //sprintf(buf, "(store) Warning, variable %s has an effective coefficient of 0, Ignored", variable); error(pp, NORMAL, buf); /* return(TRUE); */ } @@ -514,7 +514,7 @@ static int storefirst(parse_parm *pp) else { char buf[256]; - sprintf(buf, "Warning, variable %s has an effective coefficient of 0, ignored", pp->tmp_store.name); + //sprintf(buf, "Warning, variable %s has an effective coefficient of 0, ignored", pp->tmp_store.name); error(pp, NORMAL, buf); } } @@ -556,7 +556,7 @@ int store_re_op(parse_parm *pp, char OP, int HadConstraint, int HadVar, int Had_ { char buf[256]; - sprintf(buf, "Error: unknown relational operator %c", OP); + //sprintf(buf, "Error: unknown relational operator %c", OP); error(pp, CRITICAL, buf); } return(FALSE); @@ -768,14 +768,14 @@ int store_bounds(parse_parm *pp, int warn) if((pp->tmp_store.rhs_value == 0) || ((pp->tmp_store.rhs_value > 0) && (pp->tmp_store.relat == LE)) || ((pp->tmp_store.rhs_value < 0) && (pp->tmp_store.relat == GE))) { - sprintf(buf, "Variable %s has an effective coefficient of 0 in bound, ignored", - pp->tmp_store.name); + //sprintf(buf, "Variable %s has an effective coefficient of 0 in bound, ignored", + // pp->tmp_store.name); if(warn) error(pp, NORMAL, buf); } else { - sprintf(buf, "Error, variable %s has an effective coefficient of 0 in bound", - pp->tmp_store.name); + //sprintf(buf, "Error, variable %s has an effective coefficient of 0 in bound", + // pp->tmp_store.name); error(pp, CRITICAL, buf); return(FALSE); } @@ -1136,75 +1136,6 @@ static int readinput(parse_parm *pp, lprec *lp) /* the following should be replaced by a call to the MPS print routine MB */ -#if 0 - if(pp->Verbose) { - int j; - - printf("\n"); - printf("**********Data read**********\n"); - printf("Rows : %d\n", pp->Rows); - printf("Columns : %d\n", pp->Columns); - printf("Nonnuls : %d\n", pp->Non_zeros); - printf("NAME LPPROB\n"); - printf("ROWS\n"); - for(i = 0; i <= pp->Rows; i++) { - if(pp->relat[i] == LE) - printf(" L "); - else if(pp->relat[i] == EQ) - printf(" E "); - else if(pp->relat[i] == GE) - printf(" G "); - else if(pp->relat[i] == OF) - printf(" N "); - printf("%s\n", get_row_name(lp, i)); - } - - printf("COLUMNS\n"); - j = 0; - for(i = 0; i < pp->Non_zeros; i++) { - if(i == lp->col_end[j]) - j++; - printf(" %-8s %-8s %g\n", get_col_name(lp, j), - get_row_name(lp, lp->mat[i].row_nr), (double)lp->mat[i].value); - } - - printf("RHS\n"); - for(i = 0; i <= pp->Rows; i++) { - printf(" RHS %-8s %g\n", get_row_name(lp, i), - (double)lp->orig_rhs[i]); - } - - printf("RANGES\n"); - for(i = 1; i <= pp->Rows; i++) - if((lp->orig_upbo[i] != lp->infinite) && (lp->orig_upbo[i] != 0)) { - printf(" RGS %-8s %g\n", get_row_name(lp, i), - (double)lp->orig_upbo[i]); - } - else if((lp->orig_lowbo[i] != 0)) { - printf(" RGS %-8s %g\n", get_row_name(lp, i), - (double)-lp->orig_lowbo[i]); - } - - printf("BOUNDS\n"); - for(i = pp->Rows + 1; i <= pp->Rows + pp->Columns; i++) { - if((lp->orig_lowbo[i] != 0) && (lp->orig_upbo[i] < lp->infinite) && - (lp->orig_lowbo[i] == lp->orig_upbo[i])) { - printf(" FX BND %-8s %g\n", get_col_name(lp, i - pp->Rows), - (double)lp->orig_upbo[i]); - } - else { - if(lp->orig_upbo[i] < lp->infinite) - printf(" UP BND %-8s %g\n", get_col_name(lp, i - pp->Rows), - (double)lp->orig_upbo[i]); - if(lp->orig_lowbo[i] > 0) - printf(" LO BND %-8s %g\n", get_col_name(lp, i - pp->Rows), - (double)lp->orig_lowbo[i]); - } - } - - printf("ENDATA\n"); - } -#endif FREE(row); FREE(rowno); diff --git a/src/external/lpsolve/headers/include/commonlib.h b/src/external/lpsolve/headers/include/commonlib.h index d5fe84b..500f827 100644 --- a/src/external/lpsolve/headers/include/commonlib.h +++ b/src/external/lpsolve/headers/include/commonlib.h @@ -132,24 +132,24 @@ #ifndef CALLOC #define CALLOC(ptr, nr)\ if(!((void *) ptr = calloc((size_t)(nr), sizeof(*ptr))) && nr) {\ - printf("calloc of %d bytes failed on line %d of file %s\n",\ - (size_t) nr * sizeof(*ptr), __LINE__, __FILE__);\ + //printf("calloc of %d bytes failed on line %d of file %s\n",\ + // (size_t) nr * sizeof(*ptr), __LINE__, __FILE__);\ } #endif #ifndef MALLOC #define MALLOC(ptr, nr)\ if(!((void *) ptr = malloc((size_t)((size_t) (nr) * sizeof(*ptr)))) && nr) {\ - printf("malloc of %d bytes failed on line %d of file %s\n",\ - (size_t) nr * sizeof(*ptr), __LINE__, __FILE__);\ + //printf("malloc of %d bytes failed on line %d of file %s\n",\ + // (size_t) nr * sizeof(*ptr), __LINE__, __FILE__);\ } #endif #ifndef REALLOC #define REALLOC(ptr, nr)\ if(!((void *) ptr = realloc(ptr, (size_t)((size_t) (nr) * sizeof(*ptr)))) && nr) {\ - printf("realloc of %d bytes failed on line %d of file %s\n",\ - (size_t) nr * sizeof(*ptr), __LINE__, __FILE__);\ + //printf("realloc of %d bytes failed on line %d of file %s\n",\ + // (size_t) nr * sizeof(*ptr), __LINE__, __FILE__);\ } #endif diff --git a/src/external/lpsolve/headers/include/lp_rlp.h b/src/external/lpsolve/headers/include/lp_rlp.h index 058b452..db80db3 100644 --- a/src/external/lpsolve/headers/include/lp_rlp.h +++ b/src/external/lpsolve/headers/include/lp_rlp.h @@ -40,7 +40,7 @@ #if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L /* C99 says to define __STDC_LIMIT_MACROS before including stdint.h, - * if you want the limit (max/min) macros for int types. + * if you want the limit (max/min) macros for int types. */ #ifndef __STDC_LIMIT_MACROS #define __STDC_LIMIT_MACROS 1 @@ -57,7 +57,7 @@ typedef uint32_t flex_uint32_t; typedef signed char flex_int8_t; typedef short int flex_int16_t; typedef int flex_int32_t; -typedef unsigned char flex_uint8_t; +typedef unsigned char flex_uint8_t; typedef unsigned short int flex_uint16_t; typedef unsigned int flex_uint32_t; #endif /* ! C99 */ @@ -182,7 +182,7 @@ typedef struct lp_yy_buffer_state *YY_BUFFER_STATE; /* Note: We specifically omit the test for lp_yy_rule_can_match_eol because it requires * access to the local variable lp_yy_act. Since lp_yyless() is a macro, it would break - * existing scanners that call lp_yyless() from OUTSIDE lp_yylex. + * existing scanners that call lp_yyless() from OUTSIDE lp_yylex. * One obvious solution it to make lp_yy_act a global. I tried that, and saw * a 5% performance hit in a non-lp_yylineno scanner, because lp_yy_act is * normally declared as a register variable-- so it is not worth it. @@ -194,7 +194,7 @@ typedef struct lp_yy_buffer_state *YY_BUFFER_STATE; if ( lp_yytext[lp_yyl] == '\n' )\ --lp_yylineno;\ }while(0) - + /* Return all but the first "n" matched characters back to the input stream. */ #define lp_yyless(n) \ do \ @@ -256,7 +256,7 @@ struct lp_yy_buffer_state int lp_yy_bs_lineno; /**< The line count. */ int lp_yy_bs_column; /**< The column count. */ - + /* Whether to try to fill the input buffer when we reach the * end of it. */ @@ -582,7 +582,7 @@ static lp_yyconst flex_int16_t lp_yy_chk[426] = /* Table of booleans, true if rule could match eol. */ static lp_yyconst flex_int32_t lp_yy_rule_can_match_eol[34] = { 0, -0, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 1, 1, 0, 0, +0, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }; /* The intent behind this definition is that it'll catch @@ -664,7 +664,7 @@ static int lp_yy_init_globals (lp_yyscan_t lp_yyscanner ); /* This must go here because YYSTYPE and YYLTYPE are included * from bison output in section 1.*/ # define lp_yylval lp_yyg->lp_yylval_r - + int lp_yylex_init (lp_yyscan_t* scanner); int lp_yylex_init_extra (YY_EXTRA_TYPE user_defined,lp_yyscan_t* scanner); @@ -715,7 +715,7 @@ extern int lp_yywrap (lp_yyscan_t lp_yyscanner ); #endif static void lp_yyunput (int c,char *buf_ptr ,lp_yyscan_t lp_yyscanner); - + #ifndef lp_yytext_ptr static void lp_yy_flex_strncpy (char *,lp_yyconst char *,int ,lp_yyscan_t lp_yyscanner); #endif @@ -859,8 +859,8 @@ YY_DECL if ( ! lp_yyin ) lp_yyin = stdin; - if ( ! lp_yyout ) - lp_yyout = stdout; + //if ( ! lp_yyout ) + // lp_yyout = stdout; if ( ! YY_CURRENT_BUFFER ) { lp_yyensure_buffer_stack (lp_yyscanner); @@ -921,7 +921,7 @@ YY_DECL int lp_yyl; for ( lp_yyl = 0; lp_yyl < lp_yyleng; ++lp_yyl ) if ( lp_yytext[lp_yyl] == '\n' ) - + do{ lp_yylineno++; lp_yycolumn=0; }while(0) @@ -1726,7 +1726,7 @@ static int lp_yy_get_next_buffer (lp_yyscan_t lp_yyscanner) YY_CURRENT_BUFFER_LVALUE->lp_yy_at_bol = (c == '\n'); if ( YY_CURRENT_BUFFER_LVALUE->lp_yy_at_bol ) - + do{ lp_yylineno++; lp_yycolumn=0; }while(0) @@ -1809,7 +1809,7 @@ static void lp_yy_load_buffer_state (lp_yyscan_t lp_yyscanner) YY_BUFFER_STATE lp_yy_create_buffer (FILE * file, int size , lp_yyscan_t lp_yyscanner) { YY_BUFFER_STATE b; - + b = (YY_BUFFER_STATE) lp_yyalloc(sizeof( struct lp_yy_buffer_state ) ,lp_yyscanner ); if ( ! b ) YY_FATAL_ERROR( "out of dynamic memory in lp_yy_create_buffer()" ); @@ -1853,7 +1853,7 @@ static void lp_yy_load_buffer_state (lp_yyscan_t lp_yyscanner) #ifndef __cplusplus extern int isatty (int ); #endif /* __cplusplus */ - + /* Initializes or reinitializes a buffer. * This function is sometimes called more than once on the same buffer, * such as during a lp_yyrestart() or at EOF. @@ -1879,7 +1879,7 @@ extern int isatty (int ); } b->lp_yy_is_interactive = file ? (isatty( fileno(file) ) > 0) : 0; - + errno = oerrno; } @@ -1985,9 +1985,9 @@ static void lp_yyensure_buffer_stack (lp_yyscan_t lp_yyscanner) , lp_yyscanner); if ( ! lp_yyg->lp_yy_buffer_stack ) YY_FATAL_ERROR( "out of dynamic memory in lp_yyensure_buffer_stack()" ); - + memset(lp_yyg->lp_yy_buffer_stack, 0, num_to_alloc * sizeof(struct lp_yy_buffer_state*)); - + lp_yyg->lp_yy_buffer_stack_max = num_to_alloc; lp_yyg->lp_yy_buffer_stack_top = 0; return; @@ -2016,12 +2016,12 @@ static void lp_yyensure_buffer_stack (lp_yyscan_t lp_yyscanner) * @param base the character buffer * @param size the size in bytes of the character buffer * @param lp_yyscanner The scanner object. - * @return the newly allocated buffer state object. + * @return the newly allocated buffer state object. */ YY_BUFFER_STATE lp_yy_scan_buffer (char * base, lp_yy_size_t size , lp_yyscan_t lp_yyscanner) { YY_BUFFER_STATE b; - + if ( size < 2 || base[size-2] != YY_END_OF_BUFFER_CHAR || base[size-1] != YY_END_OF_BUFFER_CHAR ) @@ -2057,7 +2057,7 @@ YY_BUFFER_STATE lp_yy_scan_buffer (char * base, lp_yy_size_t size , lp_yyscan_ */ YY_BUFFER_STATE lp_yy_scan_string (lp_yyconst char * lp_yystr , lp_yyscan_t lp_yyscanner) { - + return lp_yy_scan_bytes(lp_yystr,strlen(lp_yystr) ,lp_yyscanner); } @@ -2074,7 +2074,7 @@ YY_BUFFER_STATE lp_yy_scan_bytes (lp_yyconst char * lp_yybytes, int _lp_yybyte char *buf; lp_yy_size_t n; int i; - + /* Get memory for full buffer, including space for trailing EOB's. */ n = _lp_yybytes_len + 2; buf = (char *) lp_yyalloc(n ,lp_yyscanner ); @@ -2104,8 +2104,8 @@ YY_BUFFER_STATE lp_yy_scan_bytes (lp_yyconst char * lp_yybytes, int _lp_yybyte static void lp_yy_fatal_error (lp_yyconst char* msg , lp_yyscan_t lp_yyscanner) { - (void) fprintf( stderr, "%s\n", msg ); - exit( YY_EXIT_FAILURE ); + // (void) fprintf( stderr, "%s\n", msg ); + //exit( YY_EXIT_FAILURE ); } /* Redefine lp_yyless() so it works in section 3 code. */ @@ -2142,10 +2142,10 @@ YY_EXTRA_TYPE lp_yyget_extra (lp_yyscan_t lp_yyscanner) int lp_yyget_lineno (lp_yyscan_t lp_yyscanner) { struct lp_yyguts_t * lp_yyg = (struct lp_yyguts_t*)lp_yyscanner; - + if (! YY_CURRENT_BUFFER) return 0; - + return lp_yylineno; } @@ -2155,10 +2155,10 @@ int lp_yyget_lineno (lp_yyscan_t lp_yyscanner) int lp_yyget_column (lp_yyscan_t lp_yyscanner) { struct lp_yyguts_t * lp_yyg = (struct lp_yyguts_t*)lp_yyscanner; - + if (! YY_CURRENT_BUFFER) return 0; - + return lp_yycolumn; } @@ -2219,8 +2219,8 @@ void lp_yyset_lineno (int line_number , lp_yyscan_t lp_yyscanner) /* lineno is only valid if an input buffer exists. */ if (! YY_CURRENT_BUFFER ) - lp_yy_fatal_error( "lp_yyset_lineno called with no buffer" , lp_yyscanner); - + lp_yy_fatal_error( "lp_yyset_lineno called with no buffer" , lp_yyscanner); + lp_yylineno = line_number; } @@ -2234,8 +2234,8 @@ void lp_yyset_column (int column_no , lp_yyscan_t lp_yyscanner) /* column is only valid if an input buffer exists. */ if (! YY_CURRENT_BUFFER ) - lp_yy_fatal_error( "lp_yyset_column called with no buffer" , lp_yyscanner); - + lp_yy_fatal_error( "lp_yyset_column called with no buffer" , lp_yyscanner); + lp_yycolumn = column_no; } @@ -2330,20 +2330,20 @@ int lp_yylex_init_extra(YY_EXTRA_TYPE lp_yy_user_defined,lp_yyscan_t* ptr_lp_yy_ errno = EINVAL; return 1; } - + *ptr_lp_yy_globals = (lp_yyscan_t) lp_yyalloc ( sizeof( struct lp_yyguts_t ), &dummy_lp_yyguts ); - + if (*ptr_lp_yy_globals == NULL){ errno = ENOMEM; return 1; } - + /* By setting to 0xAA, we expose bugs in lp_yy_init_globals. Leave at 0x00 for releases. */ memset(*ptr_lp_yy_globals,0x00,sizeof(struct lp_yyguts_t)); - + lp_yyset_extra (lp_yy_user_defined, *ptr_lp_yy_globals); - + return lp_yy_init_globals ( *ptr_lp_yy_globals ); } @@ -2368,7 +2368,7 @@ static int lp_yy_init_globals (lp_yyscan_t lp_yyscanner) /* Defined in main.c */ #ifdef YY_STDINIT lp_yyin = stdin; - lp_yyout = stdout; + //lp_yyout = stdout; #else lp_yyin = (FILE *) 0; lp_yyout = (FILE *) 0; diff --git a/src/external/lpsolve/headers/include/lp_types.h b/src/external/lpsolve/headers/include/lp_types.h index 1f166a6..206bac3 100644 --- a/src/external/lpsolve/headers/include/lp_types.h +++ b/src/external/lpsolve/headers/include/lp_types.h @@ -227,7 +227,7 @@ #define my_precision(val, eps) restoreINT(val, eps) #endif #define my_reldiff(x, y) (((x) - (y)) / (1.0 + fabs((LPSREAL) (y)))) -#define my_boundstr(x) (fabs(x) < lp->infinite ? sprintf("%g",x) : ((x) < 0 ? "-Inf" : "Inf") ) +#define my_boundstr(x) (fabs(x) < lp->infinite ? ;/*sprintf("%g",x)*/ : ((x) < 0 ? "-Inf" : "Inf") ) #ifndef my_boolstr #define my_boolstr(x) (!(x) ? "FALSE" : "TRUE") #endif diff --git a/src/external/lpsolve/headers/include/lusol.h b/src/external/lpsolve/headers/include/lusol.h index 56e9b9e..644dcff 100644 --- a/src/external/lpsolve/headers/include/lusol.h +++ b/src/external/lpsolve/headers/include/lusol.h @@ -1,4 +1,5 @@ // Copyright(c) 2016-2018 Kjell Konis . +// Copyright(c) 2024 Vissarion Fisikopoulos . // Version: 5.5.2.0-17 // Description: The lpSolveAPI package provides an R interface to 'lp_solve', // a Mixed Integer Linear Programming (MILP) solver with support for pure @@ -32,7 +33,7 @@ #else #define LUSOL_MALLOC(bytesize) malloc(bytesize) #define LUSOL_CALLOC(count, recsize) calloc(count, recsize) - #define LUSOL_REALLOC(ptr, bytesize) realloc((void *) ptr, bytesize) + #define LUSOL_REALLOC(ptr, bytesize) realloc((void *) ptr, (unsigned int)bytesize) #define LUSOL_FREE(ptr) {free(ptr); ptr=NULL;} #endif diff --git a/src/external/lpsolve/headers/run_headers/lp_Hash.h b/src/external/lpsolve/headers/run_headers/lp_Hash.h old mode 100644 new mode 100755 diff --git a/src/external/lpsolve/headers/run_headers/lp_SOS.h b/src/external/lpsolve/headers/run_headers/lp_SOS.h old mode 100644 new mode 100755 diff --git a/src/external/lpsolve/headers/run_headers/lp_lib.h b/src/external/lpsolve/headers/run_headers/lp_lib.h old mode 100644 new mode 100755 diff --git a/src/external/lpsolve/headers/run_headers/lp_matrix.h b/src/external/lpsolve/headers/run_headers/lp_matrix.h old mode 100644 new mode 100755 diff --git a/src/external/lpsolve/headers/run_headers/lp_mipbb.h b/src/external/lpsolve/headers/run_headers/lp_mipbb.h old mode 100644 new mode 100755 diff --git a/src/external/lpsolve/headers/run_headers/lp_types.h b/src/external/lpsolve/headers/run_headers/lp_types.h old mode 100644 new mode 100755 index e98fbe3..ee1caaf --- a/src/external/lpsolve/headers/run_headers/lp_types.h +++ b/src/external/lpsolve/headers/run_headers/lp_types.h @@ -227,7 +227,7 @@ #define my_precision(val, eps) restoreINT(val, eps) #endif #define my_reldiff(x, y) (((x) - (y)) / (1.0 + fabs((REAL) (y)))) -#define my_boundstr(x) (fabs(x) < lp->infinite ? sprintf("%g",x) : ((x) < 0 ? "-Inf" : "Inf") ) +#define my_boundstr(x) (fabs(x) < lp->infinite ? ;/*sprintf("%g",x)*/ : ((x) < 0 ? "-Inf" : "Inf") ) #ifndef my_boolstr #define my_boolstr(x) (!(x) ? "FALSE" : "TRUE") #endif diff --git a/src/external/lpsolve/headers/run_headers/lp_utils.h b/src/external/lpsolve/headers/run_headers/lp_utils.h old mode 100644 new mode 100755