version 1.1, 2005/05/25 04:42:20 |
version 1.2, 2007/09/12 07:07:36 |
|
|
/* $OpenXM$ */ |
/* $OpenXM: OpenXM/src/ox_cdd/ox_cdd.c,v 1.1 2005/05/25 04:42:20 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 263 void my_lpsolve( int resulttype, int index ) |
|
Line 287 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 309 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 327 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 382 void my_lpsolve( int resulttype, int index ) |
|
|
|
} |
} |
|
|
|
if( index == LP_INTPT ) { |
|
tmp = lpintpt(row, col, matrix); |
|
if ( tmp ) |
|
cmoint = vector2cmo(tmp,col); |
|
else |
|
cmoint = new_cmo_zero(); |
|
for ( i = 0; i < col; i++ ) |
|
mpq_clear( (mpq_ptr)tmp[i] ); |
|
} |
|
|
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 401 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 397 int sm_executeFunction() |
|
Line 435 int sm_executeFunction() |
|
} 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; |
return 0; |
|
#if defined GMPRATIONAL |
|
} else if( strcmp( func->s, "intpt" ) == 0 ){ |
|
my_lpsolve(LP_Q,LP_INTPT); |
|
return 0; |
|
#endif |
} else if( strcmp( func->s, "debugprint" ) == 0 ){ |
} else if( strcmp( func->s, "debugprint" ) == 0 ){ |
pop(); |
pop(); |
debug_print = get_i(); |
debug_print = get_i(); |