1
0
mirror of https://github.com/Interlisp/maiko.git synced 2026-01-31 13:52:29 +00:00

Reformat all C source files with Clang-format in Google style w/ 100 col width.

This commit is contained in:
Nick Briggs
2017-05-28 18:08:18 -07:00
parent 691645d048
commit 156c3292f8
167 changed files with 40520 additions and 48069 deletions

224
src/lpmain.c Executable file → Normal file
View File

@@ -1,9 +1,7 @@
/* $Id: lpmain.c,v 1.2 1999/01/03 02:07:19 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */
/* $Id: lpmain.c,v 1.2 1999/01/03 02:07:19 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved
*/
static char *id = "$Id: lpmain.c,v 1.2 1999/01/03 02:07:19 sybalsky Exp $ Copyright (C) Venue";
/************************************************************************/
/* */
/* (C) Copyright 1989, 1990, 1990, 1991, 1992, 1993, 1994, 1995 Venue. */
@@ -19,8 +17,6 @@ static char *id = "$Id: lpmain.c,v 1.2 1999/01/03 02:07:19 sybalsky Exp $ Copyri
#include "version.h"
#include <signal.h>
#include "lpkit.h"
#include "lpglob.h"
@@ -38,19 +34,21 @@ static char *id = "$Id: lpmain.c,v 1.2 1999/01/03 02:07:19 sybalsky Exp $ Copyri
#include "adr68k.h"
#include "arith.h"
#define CFREE(x) \
if (x) { \
free(x); \
(x) = (void *)0; \
}
#define CFREE(x) if (x) { free(x); (x) = (void *)0; }
lprec *Medley_lp = NULL; /* The lp description for us */
int SolveCount = 0; /* Counter for interrupting periodically */
lprec *Medley_lp = NULL; /* The lp description for us */
int SolveCount = 0; /* Counter for interrupting periodically */
jmp_buf LP_jmpbuf;
static lprec *initmilp(lprec *lp)
{
int i,j, rownr;
static lprec *initmilp(lprec *lp) {
int i, j, rownr;
int *num, *rownum;
sstate *st; /* for saving state at timeouts */
sstate *st; /* for saving state at timeouts */
if (!lp) CALLOC(lp, 1, lprec);
/* Done already in lisp. Rows--; */
@@ -123,15 +121,14 @@ static lprec *initmilp(lprec *lp)
CFREE(lp->lowbo);
CALLOC(lp->lowbo, Sum + 1, REAL);
for(i = 0; i <= Sum; i++)
{
lp->orig_upbo[i] = lp->infinite;
lp->orig_lowbo[i] = 0;
}
for (i = 0; i <= Sum; i++) {
lp->orig_upbo[i] = lp->infinite;
lp->orig_lowbo[i] = 0;
}
lp->basis_valid = TRUE;
CFREE(lp->bas);
CALLOC(lp->bas, Rows+1, int);
CALLOC(lp->bas, Rows + 1, int);
CFREE(lp->basis);
CALLOC(lp->basis, Sum + 1, short);
@@ -139,20 +136,17 @@ static lprec *initmilp(lprec *lp)
CFREE(lp->lower);
CALLOC(lp->lower, Sum + 1, short);
for(i = 0; i <= Rows; i++)
{
lp->bas[i] = i;
lp->basis[i] = TRUE;
}
for(i = Rows + 1; i <= Sum; i++)
lp->basis[i] = FALSE;
for(i = 0 ; i <= Sum; i++)
lp->lower[i] = TRUE;
for (i = 0; i <= Rows; i++) {
lp->bas[i] = i;
lp->basis[i] = TRUE;
}
for (i = Rows + 1; i <= Sum; i++) lp->basis[i] = FALSE;
for (i = 0; i <= Sum; i++) lp->lower[i] = TRUE;
lp->eta_valid = TRUE;
lp->eta_size = 0;
lp->eta_alloc = 10000;
lp->max_num_inv=DEFNUMINV;
lp->max_num_inv = DEFNUMINV;
CFREE(lp->eta_value);
CALLOC(lp->eta_value, 10000, REAL);
@@ -182,48 +176,40 @@ static lprec *initmilp(lprec *lp)
CALLOC(lp->ch_sign, Rows + 1, short);
for(i = 0; i <= Rows; i++)
lp->ch_sign[i] = FALSE;
for (i = 0; i <= Rows; i++) lp->ch_sign[i] = FALSE;
st = lp->solve_states = NULL;
for (i=0; i < Sum + 2; i++)
{
if (st) /* There's an old state-saver to use; re-use it. */
{
st->saved = 0; /* clear the in-use field */
st->notint = 0; /* And the not-integer field */
st = st->next;
}
else
{
st = (sstate *) malloc(sizeof(sstate));
if (!st) ERROR(ERR_NOMEM); /* Tell the guy there's no memory */
st->next = lp->solve_states;
st->saved = 0;
st->notint = 0; /* And the not-integer field */
lp->solve_states = st;
st = (sstate *)NULL;
}
for (i = 0; i < Sum + 2; i++) {
if (st) /* There's an old state-saver to use; re-use it. */
{
st->saved = 0; /* clear the in-use field */
st->notint = 0; /* And the not-integer field */
st = st->next;
} else {
st = (sstate *)malloc(sizeof(sstate));
if (!st) ERROR(ERR_NOMEM); /* Tell the guy there's no memory */
st->next = lp->solve_states;
st->saved = 0;
st->notint = 0; /* And the not-integer field */
lp->solve_states = st;
st = (sstate *)NULL;
}
}
lp->valid = FALSE;
lp->valid = FALSE;
return(lp);
return (lp);
}
int lpmain (LispPTR lispresults)
{
int i, failure;
float* results = (float *)Addr68k_from_LADDR(lispresults);
int lpmain(LispPTR lispresults) {
int i, failure;
float *results = (float *)Addr68k_from_LADDR(lispresults);
/* solve it */
SolveCount = 0; /* reset the "timer", to limit length of a run */
SolveCount = 0; /* reset the "timer", to limit length of a run */
if(failure = setjmp(LP_jmpbuf)) return (S_POSITIVE | failure);
if (failure = setjmp(LP_jmpbuf)) return (S_POSITIVE | failure);
/* solve it */
@@ -231,101 +217,73 @@ int lpmain (LispPTR lispresults)
failure = milpsolve(Medley_lp->solve_states, Orig_upbo, Orig_lowbo, Basis, Lower, Bas);
Medley_lp->eta_size = Eta_size;
Medley_lp->eta_alloc = Eta_alloc;
Medley_lp->num_inv = Num_inv;
Medley_lp->eta_size = Eta_size;
Medley_lp->eta_alloc = Eta_alloc;
Medley_lp->num_inv = Num_inv;
if ((failure == INT_SOLN) || (failure == OPTIMAL))
for (i=0; i < Sum+1; i++) results[i] = Best_solution[i];
for (i = 0; i < Sum + 1; i++) results[i] = Best_solution[i];
return(S_POSITIVE | failure); /* Tell him what happened so far. */
return (S_POSITIVE | failure); /* Tell him what happened so far. */
} /* main */
#ifdef OS4
int lpsetup(rows, cols, nonnuls, rhs, relns, cend, mat, ints, lowbo, upbo, objbound)
int rows, cols, nonnuls, rhs, relns, cend, mat, ints, lowbo, upbo, objbound;
int lpsetup(rows, cols, nonnuls, rhs, relns, cend, mat, ints, lowbo, upbo, objbound) int rows, cols,
nonnuls, rhs, relns, cend, mat, ints, lowbo, upbo, objbound;
#else
int lpsetup (int rows, int cols, int nonnuls,
int rhs, int relns, int cend, int mat, int ints,
int lowbo, int upbo, int objbound)
int lpsetup(int rows, int cols, int nonnuls, int rhs, int relns, int cend, int mat, int ints,
int lowbo, int upbo, int objbound)
#endif /* OS4 */
{
double obj_bound = -Infinite;
int failure, i, autoscale;
if(failure = setjmp(LP_jmpbuf)) return (S_POSITIVE | failure);
if (failure = setjmp(LP_jmpbuf)) return (S_POSITIVE | failure);
/* mallopt(M_DEBUG, 1);*/ /*debugging!!!!*/
Rows = rows&0xFFFF;
Columns = cols&0xFFFF;
Non_zeros = nonnuls&0xFFFF;
Rows = rows & 0xFFFF;
Columns = cols & 0xFFFF;
Non_zeros = nonnuls & 0xFFFF;
printf("Rows = %d. Cols = %d. Non-zeros = %d.\n", Rows, Columns, Non_zeros);
Medley_lp = initmilp(Medley_lp);
readlispinput(Medley_lp,
Addr68k_from_LADDR(rhs),
Addr68k_from_LADDR(relns),
Addr68k_from_LADDR(cend),
Addr68k_from_LADDR(mat),
Addr68k_from_LADDR(ints),
Addr68k_from_LADDR(lowbo),
Addr68k_from_LADDR(upbo));
readlispinput(Medley_lp, Addr68k_from_LADDR(rhs), Addr68k_from_LADDR(relns),
Addr68k_from_LADDR(cend), Addr68k_from_LADDR(mat), Addr68k_from_LADDR(ints),
Addr68k_from_LADDR(lowbo), Addr68k_from_LADDR(upbo));
auto_scale(Medley_lp); /* Scale values */
auto_scale(Medley_lp); /* Scale values */
Medley_lp->total_iter = 0;
Medley_lp->max_level = 1;
Medley_lp->total_iter = 0;
Medley_lp->max_level = 1;
Medley_lp->total_nodes = 0;
set_globals(Medley_lp); /* Set global vars for the run */
if(Isvalid(Medley_lp))
{
if (objbound)
{
Medley_lp->obj_bound = Best_solution[0] = *((float *) Addr68k_from_LADDR(objbound));
}
else if(Maximise && Medley_lp->obj_bound == Infinite)
Best_solution[0]=-Infinite;
else if(!Maximise && Medley_lp->obj_bound==-Infinite)
Best_solution[0] = Infinite;
else
Best_solution[0] = Medley_lp->obj_bound;
set_globals(Medley_lp); /* Set global vars for the run */
if (Isvalid(Medley_lp)) {
if (objbound) {
Medley_lp->obj_bound = Best_solution[0] = *((float *)Addr68k_from_LADDR(objbound));
} else if (Maximise && Medley_lp->obj_bound == Infinite)
Best_solution[0] = -Infinite;
else if (!Maximise && Medley_lp->obj_bound == -Infinite)
Best_solution[0] = Infinite;
else
Best_solution[0] = Medley_lp->obj_bound;
Level = 0;
Level = 0;
if(!Medley_lp->basis_valid)
{
for(i = 0; i <= Medley_lp->rows; i++)
{
Medley_lp->basis[i] = TRUE;
Medley_lp->bas[i] = i;
}
for(i = Medley_lp->rows+1; i <= Medley_lp->sum; i++)
Medley_lp->basis[i] = FALSE;
for(i = 0; i <= Medley_lp->sum; i++)
Medley_lp->lower[i] = TRUE;
Medley_lp->basis_valid = TRUE;
}
Medley_lp->eta_valid = FALSE;
if (!Medley_lp->basis_valid) {
for (i = 0; i <= Medley_lp->rows; i++) {
Medley_lp->basis[i] = TRUE;
Medley_lp->bas[i] = i;
}
for (i = Medley_lp->rows + 1; i <= Medley_lp->sum; i++) Medley_lp->basis[i] = FALSE;
for (i = 0; i <= Medley_lp->sum; i++) Medley_lp->lower[i] = TRUE;
Medley_lp->basis_valid = TRUE;
}
Medley_lp->eta_valid = FALSE;
}
return (0);
} /* lpsetup */