[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.6

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

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