[BACK]Return to ox_cdd.c CVS log [TXT][DIR] Up to [local] / OpenXM / src / ox_cdd

Diff for /OpenXM/src/ox_cdd/ox_cdd.c between version 1.1 and 1.3

version 1.1, 2005/05/25 04:42:20 version 1.3, 2007/09/15 06:31:59
Line 1 
Line 1 
 /*      $OpenXM$        */  /*      $OpenXM: OpenXM/src/ox_cdd/ox_cdd.c,v 1.2 2007/09/12 07:07:36 noro Exp $        */
   
 #include <stdio.h>  #include <stdio.h>
 #include <stdlib.h>  #include <stdlib.h>
Line 37  extern int debug_print;
Line 37  extern int debug_print;
 void init_cdd(void);  void init_cdd(void);
 int **redcheck(int row,int col,int **matrix,int *presult_row);  int **redcheck(int row,int col,int **matrix,int *presult_row);
 mytype *lpsolve(dd_LPObjectiveType type,int row,int col,int **matrix,int *obj);  mytype *lpsolve(dd_LPObjectiveType type,int row,int col,int **matrix,int *obj);
   mytype *lpintpt(int row, int col, int **matrix);
   
   
 void dprint( int level, char *string )  void dprint( int level, char *string )
 {  {
         if( debug_print >= level ){          if( debug_print >= level ){
Line 51  void dprint( int level, char *string )
Line 53  void dprint( int level, char *string )
 #define LP_MAX 0  #define LP_MAX 0
 #define LP_MIN 1  #define LP_MIN 1
 #define LP_MAXMIN 2  #define LP_MAXMIN 2
   #define LP_INTPT 3
   
 int initialize_stack()  int initialize_stack()
 {  {
Line 184  cmo *matrix2cmo( int **matrix, int row, int col )
Line 187  cmo *matrix2cmo( int **matrix, int row, int col )
         return (cmo *)result;          return (cmo *)result;
 }  }
   
   cmo_qq* new_cmo_qq_set_mpq(mpq_ptr q);
   
   cmo *vector2cmo( mytype *vector, int len)
   {
           cmo_list *result;
           cmo *tmp;
           int j;
   
           result = new_cmo_list();
           for(j=0;j<len;j++){
                   if( vector[j] != 0 ){
                           tmp = (cmo*) new_cmo_qq_set_mpq( (mpq_ptr)vector[j] );
                   } else {
                           tmp = (cmo*) new_cmo_zero();
                   }
                   result = list_append( result, tmp );
           }
   
           return (cmo *)result;
   }
   
 int mytype2int( mytype a, int i )  int mytype2int( mytype a, int i )
 {  {
 #if defined GMPRATIONAL  #if defined GMPRATIONAL
Line 254  void my_redcheck(void)
Line 278  void my_redcheck(void)
         push( matrix2cmo(result,result_row,col) );          push( matrix2cmo(result,result_row,col) );
 }  }
   
   cmo_qq* new_cmo_qq_set_mpq(mpq_ptr q);
   
 void my_lpsolve( int resulttype, int index )  void my_lpsolve( int resulttype, int index )
 {  {
         int row,col;          int row,col;
Line 263  void my_lpsolve( int resulttype, int index )
Line 289  void my_lpsolve( int resulttype, int index )
         int **matrix,*object;          int **matrix,*object;
         int lpmax,lpmin;          int lpmax,lpmin;
         mytype *tmp;          mytype *tmp;
         cmo *cmomin,*cmomax;          cmo *cmomin,*cmomax,*cmoint;
   
         pop();  /*      for argc        */          pop();  /*      for argc        */
         row = get_i();  /*      row size        */          row = get_i();  /*      row size        */
Line 285  void my_lpsolve( int resulttype, int index )
Line 311  void my_lpsolve( int resulttype, int index )
                 }                  }
         }          }
   
         /*      For object      */          if ( index != LP_INTPT ) {
         object = MALLOC( col * sizeof(int) );                  /*      For object      */
         a = pop();                  object = MALLOC( col * sizeof(int) );
                   a = pop();
         for(i=0;i<col;i++){  
                 c = list_nth( (cmo_list*)a, i );                  for(i=0;i<col;i++){
                           c = list_nth( (cmo_list*)a, i );
                 object[i] = cmo2int( c );  
                           object[i] = cmo2int( c );
                   }
         }          }
   
         if( index == LP_MAX ){          if( index == LP_MAX ){
Line 301  void my_lpsolve( int resulttype, int index )
Line 329  void my_lpsolve( int resulttype, int index )
                 dprint( 1, "lpsolve(min)...");                  dprint( 1, "lpsolve(min)...");
         } else if( LP_MAXMIN ){          } else if( LP_MAXMIN ){
                 dprint( 1, "lpsolve(maxmin)...");                  dprint( 1, "lpsolve(maxmin)...");
           } else if( LP_INTPT ){
                   dprint( 1, "lpsolve(intpt)...");
         }          }
   
         if( index == LP_MAX || index == LP_MAXMIN ){          if( index == LP_MAX || index == LP_MAXMIN ){
Line 354  void my_lpsolve( int resulttype, int index )
Line 384  void my_lpsolve( int resulttype, int index )
   
         }          }
   
           if( index == LP_INTPT ) {
                   tmp = lpintpt(row, col, matrix);
                   if ( tmp ) {
                           cmoint = (cmo *)new_cmo_list();
                           for(j=0;j < col;j++){
                                   if( tmp[j] != 0 ){
   #if defined GMPRATIONAL
                                           a = (cmo*) new_cmo_qq_set_mpq( (mpq_ptr)tmp[j] );
   #else
                                           a = (cmo*) new_cmo_double( *tmp[j] );
   #endif
                                   } else {
                                           a = (cmo*) new_cmo_zero();
                                   }
                                   cmoint = (cmo *)list_append( (cmo_list *) cmoint, a );
                           }
                   } else
                           cmoint = new_cmo_zero();
   #if defined GMPRATIONAL
                   for ( i = 0; i < col; i++ )
                           mpq_clear( (mpq_ptr)tmp[i] );
   #endif
           }
   
         if( index == LP_MAX ){          if( index == LP_MAX ){
                 push( cmomax );                  push( cmomax );
         } else if( index == LP_MIN ){          } else if( index == LP_MIN ){
Line 363  void my_lpsolve( int resulttype, int index )
Line 417  void my_lpsolve( int resulttype, int index )
                 ret = list_append( ret, cmomin );                  ret = list_append( ret, cmomin );
                 ret = list_append( ret, cmomax );                  ret = list_append( ret, cmomax );
                 push( (cmo*) ret );                  push( (cmo*) ret );
         }          } else if ( index == LP_INTPT )
                   push( cmoint );
 }  }
   
 int sm_executeFunction()  int sm_executeFunction()
Line 396  int sm_executeFunction()
Line 450  int sm_executeFunction()
                 return 0;                  return 0;
         } else if( strcmp( func->s, "lpmaxmin" ) == 0 ){          } else if( strcmp( func->s, "lpmaxmin" ) == 0 ){
                 my_lpsolve(LP_Q,LP_MAXMIN);                  my_lpsolve(LP_Q,LP_MAXMIN);
                   return 0;
           } else if( strcmp( func->s, "intpt" ) == 0 ){
                   my_lpsolve(LP_Q,LP_INTPT);
                 return 0;                  return 0;
         } else if( strcmp( func->s, "debugprint" ) == 0 ){          } else if( strcmp( func->s, "debugprint" ) == 0 ){
                 pop();                  pop();

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.3

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>