home *** CD-ROM | disk | FTP | other *** search
/ GEMini Atari / GEMini_Atari_CD-ROM_Walnut_Creek_December_1993.iso / files / math / lpsolves / write.c < prev    next >
C/C++ Source or Header  |  1993-07-28  |  2KB  |  82 lines

  1. #include "defines.h"
  2. #include "globals.h"
  3. #include <stdarg.h>
  4.  
  5. /* this is the ansi version ... */
  6.  
  7. void print_solution(FILE *stream, double *sol)
  8. {
  9.   int i;
  10.  
  11.   if(Verbose)
  12.     for (i = 0; i <= Sum; i++)
  13.       fprintf(stream, "%-10s%16.5g\n", Names[i], sol[i]);
  14.   else
  15.     {
  16.       fprintf(stream, "Value of objective function: %16.5g\n", sol[0]);
  17.       for (i = Rows + 1; i <= Sum; i++)
  18.     fprintf(stream, "%-10s%16.5g\n", Names[i], sol[i]);
  19.     }
  20. } /* print_solution */
  21.  
  22.  
  23. void print_indent(void)
  24. {
  25.   int i;
  26.  
  27.   fprintf(stderr, "%2d", Level);
  28.   for(i = Level; i > 0; i--)
  29.     fprintf(stderr, "--");
  30.   fprintf(stderr, "> ");
  31. } /* print_indent */
  32.  
  33.  
  34. void debug_print_solution(double *sol)
  35. {
  36.   int i;
  37.  
  38.   if(Debug)
  39.     for (i = 0; i <= Sum; i++)
  40.       {
  41.     print_indent();
  42.     fprintf(stderr, "%-10s%16.5g\n", Names[i], sol[i]);
  43.       }
  44. } /* debug_print_solution */
  45.  
  46.  
  47. void debug_print_bounds(double *upbo, double *lowbo)
  48. {
  49.   int i;
  50.  
  51.   if(Debug)
  52.     for(i = Rows + 1; i <= Sum; i++)
  53.       {
  54.     if(lowbo[i] != 0)
  55.       {
  56.         print_indent();
  57.         fprintf(stderr, "%s > %10.3g\n", Names[i], lowbo[i]);
  58.       }
  59.     if(upbo[i] != INFINITE)
  60.       {
  61.         print_indent();
  62.         fprintf(stderr, "%s < %10.3g\n", Names[i], upbo[i]);
  63.       }
  64.       }
  65. } /* debug_print_bounds */
  66.  
  67.  
  68. void debug_print(char *format, ...)
  69. {
  70.   va_list ap;
  71.  
  72.   if(Debug)
  73.     {
  74.       va_start(ap, format);
  75.       print_indent();
  76.       vfprintf(stderr, format, ap);
  77.       fputc('\n', stderr);
  78.       va_end(ap);
  79.     }
  80. } /* debug_print */
  81.  
  82.