Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to GLPK 4.65 #28

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ This repository contains a stripped-down version of the
[mccs solver](http://www.i3s.unice.fr/~cpjm/misc/mccs.html), taken from snapshot
1.1, with a binding as an OCaml library, and building with `dune`. The
[GLPK](https://www.gnu.org/software/glpk/glpk.html) source it links against is
also included within src/glpk, at version 4.63 (unmodified, apart from many
also included within src/glpk, at version 4.65 (unmodified, apart from many
removed modules, corresponding to the parts that we don't use).

The binding enables interoperation with binary CUDF data from
Expand Down
12 changes: 2 additions & 10 deletions src/glpk/api/cpxbas.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
/***********************************************************************
* This code is part of GLPK (GNU Linear Programming Kit).
*
* Copyright (C) 2008-2017 Andrew Makhorin, Department for Applied
* Copyright (C) 2008-2018 Andrew Makhorin, Department for Applied
* Informatics, Moscow Aviation Institute, Moscow, Russia. All rights
* reserved. E-mail: <[email protected]>.
*
Expand All @@ -21,10 +21,6 @@
* along with GLPK. If not, see <http://www.gnu.org/licenses/>.
***********************************************************************/

#ifdef HAVE_CONFIG_H
#include <config.h>
#endif

#include "env.h"
#include "prob.h"

Expand All @@ -36,11 +32,7 @@ struct var
/* penalty value */
};

#ifndef _MSC_VER
static int fcmp(const void *ptr1, const void *ptr2)
#else
static int __cdecl fcmp(const void *ptr1, const void *ptr2)
#endif
static int CDECL fcmp(const void *ptr1, const void *ptr2)
{ /* this routine is passed to the qsort() function */
struct var *col1 = (void *)ptr1, *col2 = (void *)ptr2;
if (col1->q < col2->q) return -1;
Expand Down
4 changes: 2 additions & 2 deletions src/glpk/api/prob1.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
/***********************************************************************
* This code is part of GLPK (GNU Linear Programming Kit).
*
* Copyright (C) 2000-2013 Andrew Makhorin, Department for Applied
* Copyright (C) 2000-2018 Andrew Makhorin, Department for Applied
* Informatics, Moscow Aviation Institute, Moscow, Russia. All rights
* reserved. E-mail: <[email protected]>.
*
Expand All @@ -22,7 +22,7 @@
***********************************************************************/

#include "env.h"
#include "glpios.h"
#include "ios.h"

/* CAUTION: DO NOT CHANGE THE LIMITS BELOW */

Expand Down
122 changes: 122 additions & 0 deletions src/glpk/api/wrmip.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
/* wrmip.c (write MIP solution in GLPK format) */

/***********************************************************************
* This code is part of GLPK (GNU Linear Programming Kit).
*
* Copyright (C) 2010-2016 Andrew Makhorin, Department for Applied
* Informatics, Moscow Aviation Institute, Moscow, Russia. All rights
* reserved. E-mail: <[email protected]>.
*
* GLPK is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* GLPK is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
* License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GLPK. If not, see <http://www.gnu.org/licenses/>.
***********************************************************************/

#include "env.h"
#include "prob.h"

/***********************************************************************
* NAME
*
* glp_write_mip - write MIP solution in GLPK format
*
* SYNOPSIS
*
* int glp_write_mip(glp_prob *P, const char *fname);
*
* DESCRIPTION
*
* The routine glp_write_mip writes MIP solution to a text file in GLPK
* format.
*
* RETURNS
*
* If the operation was successful, the routine returns zero. Otherwise
* it prints an error message and returns non-zero. */

int glp_write_mip(glp_prob *P, const char *fname)
{ glp_file *fp;
GLPROW *row;
GLPCOL *col;
int i, j, count, ret = 1;
char *s;
#if 0 /* 04/IV-2016 */
if (P == NULL || P->magic != GLP_PROB_MAGIC)
xerror("glp_write_mip: P = %p; invalid problem object\n", P);
#endif
if (fname == NULL)
xerror("glp_write_mip: fname = %d; invalid parameter\n", fname)
;
xprintf("Writing MIP solution to '%s'...\n", fname);
fp = glp_open(fname, "w"), count = 0;
if (fp == NULL)
{ xprintf("Unable to create '%s' - %s\n", fname, get_err_msg());
goto done;
}
/* write comment lines */
glp_format(fp, "c %-12s%s\n", "Problem:",
P->name == NULL ? "" : P->name), count++;
glp_format(fp, "c %-12s%d\n", "Rows:", P->m), count++;
glp_format(fp, "c %-12s%d\n", "Columns:", P->n), count++;
glp_format(fp, "c %-12s%d\n", "Non-zeros:", P->nnz), count++;
switch (P->mip_stat)
{ case GLP_OPT: s = "INTEGER OPTIMAL"; break;
case GLP_FEAS: s = "INTEGER NON-OPTIMAL"; break;
case GLP_NOFEAS: s = "INTEGER EMPTY"; break;
case GLP_UNDEF: s = "INTEGER UNDEFINED"; break;
default: s = "???"; break;
}
glp_format(fp, "c %-12s%s\n", "Status:", s), count++;
switch (P->dir)
{ case GLP_MIN: s = "MINimum"; break;
case GLP_MAX: s = "MAXimum"; break;
default: s = "???"; break;
}
glp_format(fp, "c %-12s%s%s%.10g (%s)\n", "Objective:",
P->obj == NULL ? "" : P->obj,
P->obj == NULL ? "" : " = ", P->mip_obj, s), count++;
glp_format(fp, "c\n"), count++;
/* write solution line */
glp_format(fp, "s mip %d %d ", P->m, P->n), count++;
switch (P->mip_stat)
{ case GLP_OPT: glp_format(fp, "o"); break;
case GLP_FEAS: glp_format(fp, "f"); break;
case GLP_NOFEAS: glp_format(fp, "n"); break;
case GLP_UNDEF: glp_format(fp, "u"); break;
default: glp_format(fp, "?"); break;
}
glp_format(fp, " %.*g\n", DBL_DIG, P->mip_obj);
/* write row solution descriptor lines */
for (i = 1; i <= P->m; i++)
{ row = P->row[i];
glp_format(fp, "i %d %.*g\n", i, DBL_DIG, row->mipx), count++;
}
/* write column solution descriptor lines */
for (j = 1; j <= P->n; j++)
{ col = P->col[j];
glp_format(fp, "j %d %.*g\n", j, DBL_DIG, col->mipx), count++;
}
/* write end line */
glp_format(fp, "e o f\n"), count++;
if (glp_ioerr(fp))
{ xprintf("Write error on '%s' - %s\n", fname, get_err_msg());
goto done;
}
/* MIP solution has been successfully written */
xprintf("%d lines were written\n", count);
ret = 0;
done: if (fp != NULL)
glp_close(fp);
return ret;
}

/* eof */
2 changes: 1 addition & 1 deletion src/glpk/context_flags.ml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
match Sys.argv.(1) with
| "clibs" ->
if Sys.win32 && Config.ccomp_type = "msvc" then
print_string "(glpk_4_63.lib)"
print_string "(glpk_4_65.lib)"
else
let glpk =
if Array.length Sys.argv > 2 && Sys.argv.(2) = "static" then
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
6 changes: 3 additions & 3 deletions src/glpk/glpapi06.c → src/glpk/draft/glpapi06.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* This code is part of GLPK (GNU Linear Programming Kit).
*
* Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
* 2009, 2010, 2011, 2013 Andrew Makhorin, Department for Applied
* 2009, 2010, 2011, 2013, 2018 Andrew Makhorin, Department for Applied
* Informatics, Moscow Aviation Institute, Moscow, Russia. All rights
* reserved. E-mail: <[email protected]>.
*
Expand All @@ -23,8 +23,8 @@
***********************************************************************/

#include "env.h"
#include "glpios.h"
#include "glpnpp.h"
#include "ios.h"
#include "npp.h"
#if 0 /* 07/XI-2015 */
#include "glpspx.h"
#else
Expand Down
10 changes: 7 additions & 3 deletions src/glpk/glpapi09.c → src/glpk/draft/glpapi09.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* This code is part of GLPK (GNU Linear Programming Kit).
*
* Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
* 2009, 2010, 2011, 2013 Andrew Makhorin, Department for Applied
* 2009, 2010, 2011, 2013, 2018 Andrew Makhorin, Department for Applied
* Informatics, Moscow Aviation Institute, Moscow, Russia. All rights
* reserved. E-mail: <[email protected]>.
*
Expand All @@ -24,8 +24,8 @@

#include "draft.h"
#include "env.h"
#include "glpios.h"
#include "glpnpp.h"
#include "ios.h"
#include "npp.h"

/***********************************************************************
* NAME
Expand Down Expand Up @@ -686,8 +686,12 @@ void glp_init_iocp(glp_iocp *parm)
parm->save_sol = NULL;
parm->alien = GLP_OFF;
#endif
#if 0 /* 20/I-2018 */
#if 1 /* 16/III-2016; not documented--should not be used */
parm->flip = GLP_OFF;
#endif
#else
parm->flip = GLP_ON;
#endif
return;
}
Expand Down
File renamed without changes.
File renamed without changes.
8 changes: 6 additions & 2 deletions src/glpk/glpapi13.c → src/glpk/draft/glpapi13.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* This code is part of GLPK (GNU Linear Programming Kit).
*
* Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
* 2009, 2010, 2011, 2013 Andrew Makhorin, Department for Applied
* 2009, 2010, 2011, 2013, 2018 Andrew Makhorin, Department for Applied
* Informatics, Moscow Aviation Institute, Moscow, Russia. All rights
* reserved. E-mail: <[email protected]>.
*
Expand All @@ -23,7 +23,7 @@
***********************************************************************/

#include "env.h"
#include "glpios.h"
#include "ios.h"

/***********************************************************************
* NAME
Expand Down Expand Up @@ -457,7 +457,11 @@ int glp_ios_pool_size(glp_tree *tree)
if (tree->reason != GLP_ICUTGEN)
xerror("glp_ios_pool_size: operation not allowed\n");
xassert(tree->local != NULL);
#ifdef NEW_LOCAL /* 02/II-2018 */
return tree->local->m;
#else
return tree->local->size;
#endif
}

/**********************************************************************/
Expand Down
Loading