src/HOL/Matrix/cplex/CplexMatrixConverter.ML
changeset 17412 e26cb20ef0cc
parent 17261 193b84a70ca4
child 22951 dfafcd6223ad
equal deleted inserted replaced
17411:664434175578 17412:e26cb20ef0cc
    55 	      
    55 	      
    56 fun convert_prog (cplexProg (s, goal, constrs, bounds)) = 
    56 fun convert_prog (cplexProg (s, goal, constrs, bounds)) = 
    57     let	
    57     let	
    58 	fun build_naming index i2s s2i [] = (index, i2s, s2i)
    58 	fun build_naming index i2s s2i [] = (index, i2s, s2i)
    59 	  | build_naming index i2s s2i (cplexBounds (cplexNeg cplexInf, cplexLeq, cplexVar v, cplexLeq, cplexInf)::bounds)
    59 	  | build_naming index i2s s2i (cplexBounds (cplexNeg cplexInf, cplexLeq, cplexVar v, cplexLeq, cplexInf)::bounds)
    60 	    = build_naming (index+1) (Inttab.curried_update (index, v) i2s) (Symtab.curried_update_new (v, index) s2i) bounds
    60 	    = build_naming (index+1) (Inttab.update (index, v) i2s) (Symtab.update_new (v, index) s2i) bounds
    61 	  | build_naming _ _ _ _ = raise (Converter "nonfree bound")
    61 	  | build_naming _ _ _ _ = raise (Converter "nonfree bound")
    62 
    62 
    63 	val (varcount, i2s_tab, s2i_tab) = build_naming 0 Inttab.empty Symtab.empty bounds
    63 	val (varcount, i2s_tab, s2i_tab) = build_naming 0 Inttab.empty Symtab.empty bounds
    64 
    64 
    65 	fun i2s i = case Inttab.curried_lookup i2s_tab i of NONE => raise (Converter "index not found")
    65 	fun i2s i = case Inttab.lookup i2s_tab i of NONE => raise (Converter "index not found")
    66 						     | SOME n => n
    66 						     | SOME n => n
    67 	fun s2i s = case Symtab.curried_lookup s2i_tab s of NONE => raise (Converter ("name not found: "^s))
    67 	fun s2i s = case Symtab.lookup s2i_tab s of NONE => raise (Converter ("name not found: "^s))
    68 						     | SOME i => i
    68 						     | SOME i => i
    69 	fun num2str positive (cplexNeg t) = num2str (not positive) t
    69 	fun num2str positive (cplexNeg t) = num2str (not positive) t
    70 	  | num2str positive (cplexNum num) = if positive then num else "-"^num			
    70 	  | num2str positive (cplexNum num) = if positive then num else "-"^num			
    71 	  | num2str _ _ = raise (Converter "term is not a (possibly signed) number")
    71 	  | num2str _ _ = raise (Converter "term is not a (possibly signed) number")
    72 
    72