1.1 --- a/lemon/Makefile.am Mon Apr 03 16:34:23 2006 +0000
1.2 +++ b/lemon/Makefile.am Mon Apr 03 19:47:37 2006 +0000
1.3 @@ -9,7 +9,10 @@
1.4 lp_base.cc \
1.5 lp_skeleton.cc \
1.6 base.cc \
1.7 - eps.cc
1.8 + eps.cc \
1.9 + bits/mingw32_rand.cc \
1.10 + bits/mingw32_time.cc
1.11 +
1.12 libemon_la_CXXFLAGS = $(GLPK_CFLAGS) $(CPLEX_CFLAGS)
1.13 libemon_la_LDFLAGS = $(GLPK_LIBS) $(CPLEX_LIBS)
1.14
1.15 @@ -99,6 +102,8 @@
1.16 bits/item_writer.h \
1.17 bits/traits.h \
1.18 bits/utility.h \
1.19 + bits/mingw32_rand.h \
1.20 + bits/mingw32_time.h \
1.21 concept/bpugraph.h \
1.22 concept/graph.h \
1.23 concept/graph_component.h \
2.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
2.2 +++ b/lemon/bits/mingw32_rand.cc Mon Apr 03 19:47:37 2006 +0000
2.3 @@ -0,0 +1,83 @@
2.4 +#ifdef WIN32
2.5 +
2.6 +#include <lemon/bits/mingw32_rand.h>
2.7 +
2.8 +
2.9 +static unsigned short _mingw_rand_state[10];
2.10 +
2.11 +void _mingw_rand_next_state(unsigned short xsubi[3]) {
2.12 + _mingw_rand_state[8] = _mingw_rand_state[9] = 0;
2.13 + _mingw_rand_state[7] = _mingw_rand_state[6];
2.14 + for (int i = 0; i < 3; ++i) {
2.15 + unsigned long val = 0;
2.16 + for (int j = 0; i + j < 3; ++j) {
2.17 + val += (unsigned long)_mingw_rand_state[7 + i + j]
2.18 + + (unsigned long)xsubi[i] * (unsigned long)_mingw_rand_state[3 + j];
2.19 + _mingw_rand_state[7 + i + j] = val;
2.20 + val >>= 16;
2.21 + }
2.22 + }
2.23 + xsubi[0] = _mingw_rand_state[6];
2.24 + xsubi[1] = _mingw_rand_state[7];
2.25 + xsubi[2] = _mingw_rand_state[8];
2.26 +}
2.27 +
2.28 +long int lrand48(void) {
2.29 + return nrand48(_mingw_rand_state);
2.30 +}
2.31 +
2.32 +long int nrand48(unsigned short xsubi[3]) {
2.33 + _mingw_rand_next_state(xsubi);
2.34 + return ((long)(xsubi[2] & ( (1 << 15) - 1) ) << 16) | (long)xsubi[1];
2.35 +}
2.36 +
2.37 +double drand48(void) {
2.38 + return erand48(_mingw_rand_state);
2.39 +}
2.40 +
2.41 +double erand48(unsigned short xsubi[3]) {
2.42 + return (double)nrand48(xsubi) / (1 << 31);
2.43 +}
2.44 +
2.45 +
2.46 +long int mrand48(void) {
2.47 + return jrand48(_mingw_rand_state);
2.48 +}
2.49 +
2.50 +long int jrand48(unsigned short xsubi[3]) {
2.51 + _mingw_rand_next_state(xsubi);
2.52 + return ((long)xsubi[2] << 16) | (long)xsubi[1];
2.53 +}
2.54 +
2.55 +void srand48(long int seedval) {
2.56 + _mingw_rand_state[0] = 0x330E;
2.57 + _mingw_rand_state[1] = seedval & ( (1 << 16) - 1);
2.58 + _mingw_rand_state[2] = seedval >> 16;
2.59 + _mingw_rand_state[3] = 0xE66D;
2.60 + _mingw_rand_state[4] = 0xDEEC;
2.61 + _mingw_rand_state[5] = 0x0005;
2.62 + _mingw_rand_state[6] = 0x000B;
2.63 +}
2.64 +
2.65 +unsigned short *seed48(unsigned short seed16v[3]) {
2.66 + _mingw_rand_state[7] = _mingw_rand_state[0];
2.67 + _mingw_rand_state[8] = _mingw_rand_state[1];
2.68 + _mingw_rand_state[9] = _mingw_rand_state[2];
2.69 + _mingw_rand_state[0] = seed16v[0];
2.70 + _mingw_rand_state[1] = seed16v[1];
2.71 + _mingw_rand_state[2] = seed16v[2];
2.72 + return _mingw_rand_state + 7;
2.73 +}
2.74 +
2.75 +void lcong48(unsigned short param[7]) {
2.76 + _mingw_rand_state[0] = param[0];
2.77 + _mingw_rand_state[1] = param[1];
2.78 + _mingw_rand_state[2] = param[2];
2.79 + _mingw_rand_state[3] = param[3];
2.80 + _mingw_rand_state[4] = param[4];
2.81 + _mingw_rand_state[5] = param[5];
2.82 + _mingw_rand_state[6] = param[6];
2.83 +}
2.84 +
2.85 +
2.86 +#endif
3.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
3.2 +++ b/lemon/bits/mingw32_rand.h Mon Apr 03 19:47:37 2006 +0000
3.3 @@ -0,0 +1,37 @@
3.4 +/* -*- C++ -*-
3.5 + *
3.6 + * This file is a part of LEMON, a generic C++ optimization library
3.7 + *
3.8 + * Copyright (C) 2003-2006
3.9 + * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
3.10 + * (Egervary Research Group on Combinatorial Optimization, EGRES).
3.11 + *
3.12 + * Permission to use, modify and distribute this software is granted
3.13 + * provided that this copyright notice appears in all copies. For
3.14 + * precise terms see the accompanying LICENSE file.
3.15 + *
3.16 + * This software is provided "AS IS" with no warranty of any kind,
3.17 + * express or implied, and with no claim as to its suitability for any
3.18 + * purpose.
3.19 + *
3.20 + */
3.21 +
3.22 +#ifndef LEMON_BITS_MINGW32_RAND_H
3.23 +#define LEMON_BITS_MINGW32_RAND_H
3.24 +
3.25 +
3.26 +#ifdef WIN32
3.27 +
3.28 +double drand48(void);
3.29 +double erand48(unsigned short xsubi[3]);
3.30 +long int lrand48(void);
3.31 +long int nrand48(unsigned short xsubi[3]);
3.32 +long int mrand48(void);
3.33 +long int jrand48(unsigned short xsubi[3]);
3.34 +void srand48(long int seedval);
3.35 +unsigned short *seed48(unsigned short seed16v[3]);
3.36 +void lcong48(unsigned short param[7]);
3.37 +
3.38 +#endif
3.39 +
3.40 +#endif
4.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
4.2 +++ b/lemon/bits/mingw32_time.cc Mon Apr 03 19:47:37 2006 +0000
4.3 @@ -0,0 +1,104 @@
4.4 +#ifdef WIN32
4.5 +
4.6 +#include <lemon/bits/mingw32_time.h>
4.7 +
4.8 +#include <windows.h>
4.9 +#include <ctime>
4.10 +#include "dos.h"
4.11 +
4.12 +static const char days[] =
4.13 +"Sun Mon Tue Wed Thu Fri Sat ";
4.14 +static const char months[] =
4.15 +"Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec ";
4.16 +
4.17 +void num2str(char *c,int i) {
4.18 + c[0]=i/10+'0';
4.19 + c[1]=i%10+'0';
4.20 +}
4.21 +
4.22 +char *asctime_r(const struct tm *t, char *buf) {
4.23 + *(int*)buf=*(int*)(days+(t->tm_wday<<2));
4.24 + *(int*)(buf+4)=*(int*)(months+(t->tm_mon<<2));
4.25 + num2str(buf+8,t->tm_mday);
4.26 + if (buf[8]=='0') buf[8]=' ';
4.27 + buf[10]=' ';
4.28 + num2str(buf+11,t->tm_hour);
4.29 + buf[13]=':';
4.30 + num2str(buf+14,t->tm_min);
4.31 + buf[16]=':';
4.32 + num2str(buf+17,t->tm_sec);
4.33 + buf[19]=' ';
4.34 + num2str(buf+20,(t->tm_year+1900)/100);
4.35 + num2str(buf+22,(t->tm_year+1900)%100);
4.36 + buf[24]='\n'; buf[25]='\0';
4.37 + return buf;
4.38 +}
4.39 +
4.40 +struct tm * localtime_r (const time_t *t, struct tm *tm) {
4.41 + struct tm *tmp;
4.42 +
4.43 + if ((tmp = localtime(t)) && tm)
4.44 + *tm = *tmp;
4.45 + else
4.46 + return 0;
4.47 +
4.48 + return tm;
4.49 +}
4.50 +
4.51 +char *ctime_r(const time_t * tim_p , char * result) {
4.52 + struct tm tm;
4.53 + return asctime_r (localtime_r (tim_p, &tm), result);
4.54 +}
4.55 +
4.56 +
4.57 +int gettimeofday(struct timeval * tp, struct timezone *) {
4.58 + SYSTEMTIME systime;
4.59 +
4.60 + if (tp) {
4.61 + struct tm tmrec;
4.62 + time_t theTime = time(NULL);
4.63 +
4.64 +
4.65 + tmrec = *localtime(&theTime);
4.66 + tp->tv_sec = mktime(&tmrec);
4.67 + GetLocalTime(&systime); /* system time */
4.68 +
4.69 + tp->tv_usec = systime.wMilliseconds * 1000;
4.70 + }
4.71 + return 0;
4.72 +}
4.73 +
4.74 +long filetime_to_clock(FILETIME *ft)
4.75 +{
4.76 + __int64 qw = ft->dwHighDateTime;
4.77 + qw <<= 32;
4.78 + qw |= ft->dwLowDateTime;
4.79 + qw /= 10000;
4.80 + return (long) qw;
4.81 +
4.82 +}
4.83 +
4.84 +int times(struct tms *tmbuf)
4.85 +{
4.86 + FILETIME create, exit, kernel, user;
4.87 + if (GetProcessTimes(GetCurrentProcess(),&create, &exit, &kernel, &user)) {
4.88 + tmbuf->tms_utime = filetime_to_clock(&user);
4.89 + tmbuf->tms_stime = filetime_to_clock(&kernel);
4.90 + tmbuf->tms_cutime = 0;
4.91 + tmbuf->tms_cstime = 0;
4.92 + }
4.93 + else {
4.94 + tmbuf->tms_utime = clock();
4.95 + tmbuf->tms_stime = 0;
4.96 + tmbuf->tms_cutime = 0;
4.97 + tmbuf->tms_cstime = 0;
4.98 + }
4.99 + return 0;
4.100 +}
4.101 +
4.102 +int sysconf(int)
4.103 +{
4.104 + return 1;
4.105 +}
4.106 +
4.107 +#endif
5.1 --- a/lemon/bits/mingw32_time.h Mon Apr 03 16:34:23 2006 +0000
5.2 +++ b/lemon/bits/mingw32_time.h Mon Apr 03 19:47:37 2006 +0000
5.3 @@ -22,72 +22,13 @@
5.4 #ifdef WIN32
5.5
5.6 #include <windows.h>
5.7 -#include <time.h>
5.8 +#include <ctime>
5.9 #include "dos.h"
5.10
5.11 -static const char days[] =
5.12 -"Sun Mon Tue Wed Thu Fri Sat ";
5.13 -static const char months[] =
5.14 -"Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec ";
5.15 -
5.16 -inline void num2str(char *c,int i) {
5.17 - c[0]=i/10+'0';
5.18 - c[1]=i%10+'0';
5.19 -}
5.20 -
5.21 -inline char *asctime_r(const struct tm *t, char *buf) {
5.22 - /* "Wed Jun 30 21:49:08 1993\n" */
5.23 - *(int*)buf=*(int*)(days+(t->tm_wday<<2));
5.24 - *(int*)(buf+4)=*(int*)(months+(t->tm_mon<<2));
5.25 - num2str(buf+8,t->tm_mday);
5.26 - if (buf[8]=='0') buf[8]=' ';
5.27 - buf[10]=' ';
5.28 - num2str(buf+11,t->tm_hour);
5.29 - buf[13]=':';
5.30 - num2str(buf+14,t->tm_min);
5.31 - buf[16]=':';
5.32 - num2str(buf+17,t->tm_sec);
5.33 - buf[19]=' ';
5.34 - num2str(buf+20,(t->tm_year+1900)/100);
5.35 - num2str(buf+22,(t->tm_year+1900)%100);
5.36 - buf[24]='\n'; buf[25]='\0';
5.37 - return buf;
5.38 -}
5.39 -
5.40 -inline struct tm * localtime_r (const time_t *t, struct tm *tm) {
5.41 - struct tm *tmp;
5.42 -
5.43 - if ((tmp = localtime(t)) && tm)
5.44 - *tm = *tmp;
5.45 - else
5.46 - return 0;
5.47 -
5.48 - return tm;
5.49 -}
5.50 -
5.51 -inline char *ctime_r(const time_t * tim_p , char * result) {
5.52 - struct tm tm;
5.53 - return asctime_r (localtime_r (tim_p, &tm), result);
5.54 -}
5.55 -
5.56 -
5.57 -inline int gettimeofday(struct timeval * tp, struct timezone *) {
5.58 - SYSTEMTIME systime;
5.59 -
5.60 - if (tp) {
5.61 - struct tm tmrec;
5.62 - time_t theTime = time(NULL);
5.63 -
5.64 -
5.65 - tmrec = *localtime(&theTime);
5.66 - tp->tv_sec = mktime(&tmrec);
5.67 - GetLocalTime(&systime); /* system time */
5.68 -
5.69 - tp->tv_usec = systime.wMilliseconds * 1000;
5.70 - }
5.71 - return 0;
5.72 -}
5.73 -
5.74 +char *asctime_r(const struct tm *t, char *buf);
5.75 +struct tm * localtime_r (const time_t *t, struct tm *tm);
5.76 +char *ctime_r(const time_t * tim_p , char * result);
5.77 +int gettimeofday(struct timeval * tp, struct timezone *);
5.78
5.79 struct tms {
5.80 long tms_utime;
5.81 @@ -96,42 +37,14 @@
5.82 long tms_cstime;
5.83 };
5.84
5.85 -inline long filetime_to_clock(FILETIME *ft)
5.86 -{
5.87 - __int64 qw = ft->dwHighDateTime;
5.88 - qw <<= 32;
5.89 - qw |= ft->dwLowDateTime;
5.90 - qw /= 10000; /* File time ticks at 0.1uS, clock at 1mS */
5.91 - return (long) qw;
5.92 +long filetime_to_clock(FILETIME *ft);
5.93
5.94 -}
5.95 -
5.96 -inline int times(struct tms *tmbuf)
5.97 -{
5.98 - FILETIME create, exit, kernel, user;
5.99 - if (GetProcessTimes(GetCurrentProcess(),&create, &exit, &kernel, &user)) {
5.100 - tmbuf->tms_utime = filetime_to_clock(&user);
5.101 - tmbuf->tms_stime = filetime_to_clock(&kernel);
5.102 - tmbuf->tms_cutime = 0;
5.103 - tmbuf->tms_cstime = 0;
5.104 - }
5.105 - else {
5.106 - tmbuf->tms_utime = clock();
5.107 - tmbuf->tms_stime = 0;
5.108 - tmbuf->tms_cutime = 0;
5.109 - tmbuf->tms_cstime = 0;
5.110 - }
5.111 - return 0;
5.112 -}
5.113 +int times(struct tms *tmbuf);
5.114
5.115 #define _SC_CLK_TCK 1
5.116
5.117 -inline int sysconf(int)
5.118 -{
5.119 - return 1;
5.120 -}
5.121 +int sysconf(int);
5.122
5.123 #endif
5.124
5.125 -
5.126 #endif
6.1 --- a/lemon/simann.h Mon Apr 03 16:34:23 2006 +0000
6.2 +++ b/lemon/simann.h Mon Apr 03 19:47:37 2006 +0000
6.3 @@ -32,6 +32,10 @@
6.4 #include <limits>
6.5 #include <lemon/time_measure.h>
6.6
6.7 +#ifdef WIN32
6.8 +#include <lemon/bits/mingw32_rand.h>
6.9 +#endif
6.10 +
6.11 namespace lemon {
6.12
6.13 /// \addtogroup experimental