[BACK]Return to polymake.sm1 CVS log [TXT][DIR] Up to [local] / OpenXM / src / kan96xx / trans

Annotation of OpenXM/src/kan96xx/trans/polymake.sm1, Revision 1.7

1.7     ! takayama    1: % $OpenXM: OpenXM/src/kan96xx/trans/polymake.sm1,v 1.6 2013/09/21 04:48:36 takayama Exp $
1.1       takayama    2: % It is a polymake interface
                      3:
1.7     ! takayama    4: /@@@polymake.ask.which 1 def
1.1       takayama    5: /polymake.start {
                      6:   (ox.k0.loaded) boundp {  }
1.3       takayama    7:   { [(parse) (ox.sm1) pushfile] extension
                      8:     /@@@polymake.k0.ccc [ ] def
                      9:   } ifelse
                     10:   @@@polymake.k0.ccc [ ] eq {
                     11:      k0connectr /@@@polymake.k0.ccc oxk0.ccc def /oxk0.ccc [ ] def
                     12:      @@@polymake.k0.ccc oxsetmathcap @@@polymake.k0.ccc oxmathcap
1.1       takayama   13:   } {  } ifelse
1.3       takayama   14:   @@@polymake.k0.ccc 0 get (closed) eq {
                     15:      k0connectr /@@@polymake.k0.ccc oxk0.ccc def /oxk0.ccc [ ] def
                     16:      @@@polymake.k0.ccc oxsetmathcap @@@polymake.k0.ccc oxmathcap
1.1       takayama   17:   } {  } ifelse
1.6       takayama   18:   [(parse) ( 1 )] extension pop % BUG, dummy to avoid bus error on mac.2013.09.21
1.7     ! takayama   19:  @@@polymake.ask.which {
1.1       takayama   20:   [(which) (polymake)] oxshell tag 0 eq {
                     21:      [(export) (PATH) (=) (/usr/local/polymake/bin:${PATH})] oxshell
                     22:      [(which) (polymake)] oxshell tag 0 eq {
                     23:        (Polymake is not installed in this system.) error
                     24:      } {  } ifelse
                     25:   } {  } ifelse
1.7     ! takayama   26:  } { } ifelse
1.1       takayama   27:   [(which) (polymake2tfb)] oxshell tag 0 eq {
                     28:      (polymake2tfb is not installed in this system.) error
                     29:   } {  } ifelse
                     30: } def
                     31:
                     32: %[(FACETS) (polymake.data(polymake.POINTS([[1,0,0],[1,1,0],[1,0,1],[1,0,0]])))]
                     33: % doPolymake
                     34: % [ tfb-string tree error]
                     35: [(doPolymake)
1.4       takayama   36: [(It calls polymake via oxshell and ox_k0 to make several construction for polytopes.)
1.1       takayama   37:  ([action data_in_polymake_tfb_format] doPolymake )
                     38:  (         [result_in_tfb result_in_tree errors])
                     39:  (polymake, polymake2tfb, ox_k0 must be installed.)
1.4       takayama   40:  (cf. @@@polymake.k0.ccc, kan96xx/Doc/oxshell.*, kan96xx/trans/polymake.sm1, oxshell )
                     41:  (The variable @@@doPolymake.vars keeps session logs with the polymake)
1.1       takayama   42:  (Example:)
                     43: % ( [(export) (PATH) (=) (/usr/local/polymake/bin:${PATH})] oxshell )
1.5       takayama   44:  $ [(FACETS) (polymake.data(polymake.POINTS([[1,0,0],[1,1,0],[1,0,1],[1,1,1/2]])))]$
1.1       takayama   45:  (         doPolymake /rr set )
1.5       takayama   46:  ( Keys---properties are FACETS, CONE_DIM, LINEARITY_DIM, FEASIBLE, AFFINE_FULL, ... )
1.1       takayama   47: ]] putUsages
                     48: /doPolymake {
                     49:   /arg1 set
                     50:   [/in-doPolymake  /pAction /pData /pNative /ptree
                     51:    /pResult  /pError
                     52:   ] pushVariables
                     53:   [
                     54:     arg1 0 get /pAction set
                     55:     arg1 1 get /pData set
                     56:     polymake.start
                     57:
                     58:     /pError [ ] def
                     59: %% step 1:  polymake tfb ===> polymake native data
1.3       takayama   60:     @@@polymake.k0.ccc ( polymake=Object; ) oxexecutestring
                     61:     @@@polymake.k0.ccc ( QuoteMode(1); ) oxexecutestring
                     62:     @@@polymake.k0.ccc [pData ( ;)] cat oxexecutestring
                     63:     @@@polymake.k0.ccc oxpopcmo /ptree set
                     64:     @@@polymake.k0.ccc ( QuoteMode(0); ) oxexecutestring
1.1       takayama   65:     [(treeToPolymake) ptree] extension /pNative set
1.5       takayama   66:     [ptree pNative pAction] /@@@doPolymake.vars set %for debug
1.1       takayama   67: %% step 2: calling the polymake
1.4       takayama   68:     [(polymake) (stringInOut://pNative) pAction] addStdoutStderr
1.1       takayama   69:     oxshell pop
                     70:     pError [@@@stdout @@@stderr] append /pError set
1.4       takayama   71:     @@@doPolymake.vars [pNative @@@stdout] append /@@@doPolymake.vars set %for debug
                     72:     @@@stdout /pNative set  %output file of polymake is XML file. Use old output format.
1.1       takayama   73: %% step 3: polymake native data to polymake tfb
                     74:     [(polymake2tfb) (<) (stringIn://pNative) (>) (stringOut://pResult)
                     75:      (2>) (stringOut://@@@stderr)] oxshell pop
                     76:     pError [@@@stderr] append /pError set
                     77: %% step 4: get also tree style data.
1.3       takayama   78:     @@@polymake.k0.ccc ( polymake=Object; ) oxexecutestring
                     79:     @@@polymake.k0.ccc ( QuoteMode(1); ) oxexecutestring
                     80:     @@@polymake.k0.ccc [pResult ( ;)] cat oxexecutestring
                     81:     @@@polymake.k0.ccc oxpopcmo /ptree set
                     82:     @@@polymake.k0.ccc ( QuoteMode(0); ) oxexecutestring
1.1       takayama   83:     [pResult ptree pError] /arg1 set
1.3       takayama   84:   ] pop
                     85:   popVariables
                     86:   arg1
                     87: } def
                     88:
                     89: [(tfbToTree)
                     90: [(tfb-expression-in-string tfbToTree tree)
                     91:  (tfbToTree translates expressions in tfb/2 into tree form.)
                     92:  (Bug: the input is parsed by k0, so the symbol name given agrees with)
                     93:  (     a k0 symbol, it returns a strange answer.)
                     94:  $Example:  ( C+intpath.circle(0,1/2) ) tfbToTree :: $
                     95: ]] putUsages
                     96:
                     97: /tfbToTree {
                     98:   /arg1 set
                     99:   [/in-tfbToTree  /pAction /pData /pNative /ptree
                    100:    /pResult  /pError /i
                    101:   ] pushVariables
                    102:   [
                    103:     arg1 /pData set
                    104:     polymake.start
                    105:
                    106:     /pError [ ] def
                    107: %%  tfb ===> CMO tree.
                    108:     @@@polymake.k0.ccc ( QuoteMode(1); ) oxexecutestring
                    109:     @@@polymake.k0.ccc [pData ( ;)] cat oxexecutestring
                    110:     @@@polymake.k0.ccc oxpopcmo /ptree set
                    111:     @@@polymake.k0.ccc ( QuoteMode(0); ) oxexecutestring
                    112:     /arg1 ptree def
1.1       takayama  113:   ] pop
                    114:   popVariables
                    115:   arg1
                    116: } def

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