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

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

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