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

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

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