(*********************************************************************** This file was generated automatically by the Mathematica front end. It contains Initialization cells from a Notebook file, which typically will have the same name as this file except ending in ".nb" instead of ".m". This file is intended to be loaded into the Mathematica kernel using the package loading commands Get or Needs. Doing so is equivalent to using the Evaluate Initialization Cells menu command in the front end. DO NOT EDIT THIS FILE. This entire file is regenerated automatically each time the parent Notebook file is saved in the Mathematica front end. Any changes you make to this file will be overwritten. ***********************************************************************) \!\(BeginPackage["\", "\", \ "\"]\n CddIF::usage = "\"\[IndentingNewLine] SetCddCmd::usage = "\"\n CddFormat::usage = "\"\n ToCddExtFile::usage = \ "\"\n TruthTable::usage = "\"\n RunCdd::usage = "\"\n ShowVRep::usage = "\"\n ConvToHRep::usage = \ "\"\n ReadInHRep::usage = "\"\n GetInequFromHRep::usage = "\"\n InequToRead::usage = "\"\n GetViolInequalities::usage = \ \[IndentingNewLine]\*"\"\ True you see the violated ones printed out \ immediately.\>\""\n PlotInequalities::usage = \ \*"\"\\""\n ContPlotInequalities::usage = \ \*"\"\\""\n Cdd::usage = "\"\[IndentingNewLine]\ \n Begin["\<`Private`\>"]\n Off[General::spell1]\n Off[Graphics`MultipleListPlot`Star::shdw]\[IndentingNewLine] Options[CddIF] := {CddCmd \[Rule] "\"}\n Options[CddFormat] := {}\n Options[TruthTable] := {IncludeVars \[Rule] True}\n Options[PlotList] := {PlotPoints \[Rule] 25}\n Options[PlotInequalities] := {PlotJoined \[Rule] True, Graphics`MultipleListPlot`SymbolShape \[Rule] None, PlotStyle \[Rule] {Dashing[{}]}}\n Options[GetViolInequalities] := {PrintOut \[Rule] False}\n Options[ContPlotList] := {PrintOut \[Rule] False, PlotPoints \[Rule] 25}\n Options[ContPlot] := {PlotRange \[Rule] {\(-0. \), 1}, ColorFunction \[Rule] \((GrayLevel[1 - #] &)\), Contours \[Rule] 30, ContourLines \[Rule] False}\n\n SetCddCmd[cmd_String] := \ SetOptions[CddIF, CddCmd \[Rule] cmd]\n (*\ Looks, \ if\ there\ is\ any\ "\<1\>" - value\ in\ list, \ then\ value\ is\ taken\ as\ true\ *) \n LogAnd[prop_List] := Times @@ prop\n\[IndentingNewLine] (*\ Gives\ any\ possible\ combination\ of\ 1 \.b4s\ and\ 0 \.b4s\ of\ \ length\ 2^n\ *) \n CreateTrueVal[ elements_Integer] := \[IndentingNewLine]Reverse\ /@ \((Map[\ \[IndentingNewLine]PadLeft[#, elements] &, \[IndentingNewLine]IntegerDigits[ Range[0, Power[2, elements] - 1], 2]\[IndentingNewLine]])\)\n\[IndentingNewLine] (*\ Gives\ a\ list, \ where\ all\ joint\ events\ are\ taken\ into\ consideration\ *) \n EventList[ SingleEvents_List] \ := \[IndentingNewLine]Flatten[\[IndentingNewLine]\(Flatten[\[IndentingNewLine]\ Apply[Outer, \[IndentingNewLine]\(Insert[#, List, 1] &\) /@ \ \ \[IndentingNewLine]DiscreteMath`Combinatorica`KSubsets[ SingleEvents, #], \[IndentingNewLine]{1}], \ \[IndentingNewLine]#] &\) /@ \ Range[Length[ SingleEvents]], \[IndentingNewLine]1]\[IndentingNewLine]\ \[IndentingNewLine] (*\ yields\ the\ truthtable\ for\ the\ events\ "\"\ *) \n TruthT[part_Integer, angles_Integer] := \[IndentingNewLine]Module[\[IndentingNewLine]{events \ = Table[Unique[], {part}, {angles}]}, \[IndentingNewLine]Map[ LogAnd, \[IndentingNewLine]\(\((EventList[ events] /. #)\) &\) /@ \[IndentingNewLine]\((\ \[IndentingNewLine]\(Inner[Rule, Flatten[events], #, List] &\) /@ \ \[IndentingNewLine]CreateTrueVal[ Length[Flatten[ events]]]\[IndentingNewLine])\), \[IndentingNewLine]{2}]]\ \[IndentingNewLine]\n TruthTable[part_Integer, angles_Integer, opts___] := \[IndentingNewLine]\(\((Prepend[TruthT[part, angles], MakeVariablesTT[part, angles]] // MatrixForm)\)\(/;\)\((\(IncludeVars\ \ /. {opts}\) /. Options[TruthTable])\)\(\[IndentingNewLine]\)\)\[IndentingNewLine] TruthTable[part_Integer, angles_Integer, opts___] := \[IndentingNewLine]TruthT[part, angles] /; \(\(\[Not]\)\((\(IncludeVars\ /. {opts}\) /. Options[TruthTable])\)\(\[IndentingNewLine]\)\(\[IndentingNewLine]\ \)\( (*\ takes\ a\ list\ of\ vertices\ \((i . e . \ v - representation)\)\ and\ yields\ the\ representation\ ready\ \ to\ use\ with\ cdd\ *) \)\)\n CddFormat[vertices_List, opts___List] := \[IndentingNewLine]Append[\[IndentingNewLine]Insert[\ \[IndentingNewLine]Insert[\[IndentingNewLine]Insert[\[IndentingNewLine]\ vertices, 1, Table[{i, 1}, {i, 1, Length[vertices]}]], \[IndentingNewLine]Append[ Plus[Dimensions[vertices], {0, 1}], "\"], {1}], \ \[IndentingNewLine]"\", {1}], \ \[IndentingNewLine]"\" <> \[IndentingNewLine]\((\(StringJoin[#, "\<\n\ \>"] &\) /@ \[IndentingNewLine]\(ToString\ /@ \ \[IndentingNewLine]Union[ opts, Options[ CddFormat]]\))\)]\[IndentingNewLine]\[IndentingNewLine] (*\ excludes\ comments\ from\ cdd - files\ *) \n TestImportTable[ strings_List] := \[IndentingNewLine]True\ \ /; \[IndentingNewLine]\(\((strings[\([1]\)] \[NotEqual] "\<*\>")\)\(&&\)\(\ \[IndentingNewLine]\)\((\((StringTake[strings[\([1]\)], 1] \[NotEqual] "\<*\>")\) || NumericQ[ strings[\([1]\)]])\)\(\[IndentingNewLine]\)\(\[IndentingNewLine]\ \)\( (*\ writes\ vertices\ into\ file\ including\ options\ for\ cdd\ if\ a\ \ list\ of\ vertices\ is\ given \((more\ general\ form)\)*) \)\)\n ToCddExtFile[file_String, vertices_List, opts___List] := \[IndentingNewLine]Export[\[IndentingNewLine]file <> \ "\<.ext\>", \[IndentingNewLine]CddFormat[vertices, opts], \[IndentingNewLine]"\"]\[IndentingNewLine]\ \[IndentingNewLine] (*\ writes\ vertices\ into\ file\ including\ options\ for\ cdd\ if\ a\ \ configuration\ \((x - particles, \ y - angles)\)\ is\ given\ \((special\ form\ for\ boole - bell - type\ inequalities)\)\ *) \n ToCddExtFile[file_String, part_Integer, angles_Integer, opts___List] := \[IndentingNewLine]Export[\[IndentingNewLine]file <> \ "\<.ext\>", \[IndentingNewLine]CddFormat[ TruthT[part, angles]], \[IndentingNewLine]"\"]\[IndentingNewLine]\ \[IndentingNewLine] (*\ runs\ cdd\ on\ given\ file\ and\ yields\ result\ as\ h - representation\ \((for\ use\ in\ further\ functions)\)\ *) \n RunCdd[file_String, part_Integer, angles_Integer] \ := \[IndentingNewLine]Select[\[IndentingNewLine]CompoundExpression[\ \[IndentingNewLine]Run[\((CddCmd /. Options[CddIF])\) <> "\< \>" <> file <> "\<.ext\>"], \[IndentingNewLine]PutAppend[ OutputForm["\"\ <> ToString[part]\ <> \ "\< \>"\ <> ToString[angles]]\ , StringJoin[file, "\<.ine\>"]], \[IndentingNewLine]Import[ file <> "\<.ine\>", "\"]], \ \[IndentingNewLine]TestImportTable]\n\n RunCdd[file_String] \ := \[IndentingNewLine]Select[\[IndentingNewLine]CompoundExpression[\ \[IndentingNewLine]Run[\((CddCmd /. Options[CddIF])\) <> "\< \>" <> file <> "\<.ext\>"], \[IndentingNewLine]Import[ file <> "\<.ine\>", "\"]], \ \[IndentingNewLine]TestImportTable]\[IndentingNewLine]\[IndentingNewLine]\ \[IndentingNewLine] (*\ shows\ v - representation\ *) \n ShowVRep[part_, angles_] := \[IndentingNewLine]CddFormat[ TruthT[part, angles]]\[IndentingNewLine]\[IndentingNewLine] (*\ gets\ vertices\ list\ from\ v - representation\ *) \n GetMatrixFromVRep[ vrep_List] := \[IndentingNewLine]Module[\[IndentingNewLine]{m = vrep[\([Range[3, Length[vrep] - 1]]\)]}, \[IndentingNewLine]m[\([All, Range[2, Length[m[\([1]\)]]]]\)]]\[IndentingNewLine]\[IndentingNewLine] \ (*\ converts\ particles - angles - configuration\ to\ h - representation\ using\ cdd\ *) \n ConvToHRep[part_, angles_, file_String: "\", opts___] := \[IndentingNewLine]CompoundExpression[\[IndentingNewLine]\ ToCddExtFile[file, TruthT[part, angles], opts], \[IndentingNewLine]RunCdd[ file, part, angles]]\[IndentingNewLine]\n ConvToHRep[vertices_List, file_String: "\", opts___] := \[IndentingNewLine]CompoundExpression[\[IndentingNewLine]\ ToCddExtFile[file, vertices, opts], \[IndentingNewLine]RunCdd[ file]]\[IndentingNewLine]\[IndentingNewLine] (*\ reads\ h - representation\ from\ file . ine\ *) \n ReadInHRep[ file_String] := \[IndentingNewLine]Select[\[IndentingNewLine]Import[ file <> "\<.ine\>", "\"], \[IndentingNewLine]TestImportTable]\ \[IndentingNewLine]\[IndentingNewLine]\n Concatenate[arg__] := Symbol[StringJoin[ToString /@ \ {arg}]]\n Concatenate[arg_List] := Symbol[StringJoin[ToString /@ \ arg]]\n ClearAttributes[Concatenate, Listable]\[IndentingNewLine]\[IndentingNewLine] (*\ makes\ variables\ according\ to\ boole - bell - type\ \(events : \[IndentingNewLine]\(a1\ ... \)\ particle\ a\ in\ \ detector\ 1\); \ \[IndentingNewLine]\(a1b1\ ... \)\ particle\ a\ and\ \ particle\ b\ in\ detector\ 1\ \((joint\ event)\)\[IndentingNewLine]*) \n MakeVariables[part_, angles_] := \[IndentingNewLine]\(\(Concatenate\)\(\ \)\(/@\)\(\ \[IndentingNewLine]\)\(EventList[\[IndentingNewLine]Outer[\[IndentingNewLine]\ Concatenate, \[IndentingNewLine]FromCharacterCode[ List\ /@ Range[97, 97 + part - 1]], \[IndentingNewLine]Range[ angles]]]\)\(\[IndentingNewLine]\)\)\[IndentingNewLine] MakeVariablesTT[part_, angles_] := \[IndentingNewLine]DisplayForm /@ \ \((\[IndentingNewLine]\(RowBox[#] &\) /@ \[IndentingNewLine]EventList[\ \[IndentingNewLine]Outer[\[IndentingNewLine]Subscript[ Symbol[#1], #2] &, \[IndentingNewLine]FromCharacterCode[ List\ /@ Range[97, 97 + part - 1]], \[IndentingNewLine]Range[ angles]]])\)\[IndentingNewLine]\[IndentingNewLine] (*only\ \ relevant\ data\ \((A . x \[LessEqual] b)\)\ from\ H - Representation\ is\ taken*) \n GetMatrixFromHRep[ hrep_List] := \ \ \ \[IndentingNewLine]Module[\[IndentingNewLine]{m = hrep[\([Range[4, Length[hrep] - 2]]\)], \[IndentingNewLine]part = hrep[\([\(-1\), 2]\)], \[IndentingNewLine]angles = hrep[\([\(-1\), 3]\)]\ }, \[IndentingNewLine]List[\[IndentingNewLine]m[\([Range[ Length[m]], Range[2, Length[m[\([1]\)]]]]\)], \[IndentingNewLine]m[\([All, 1]\)], \[IndentingNewLine]part, \[IndentingNewLine]angles]]\ \[IndentingNewLine]\[IndentingNewLine] GetMatrixFromHRepMod[ hrep_List] := \[IndentingNewLine]Module[\[IndentingNewLine]{m = hrep[\([Range[4, Length[hrep] - 2]]\)]}, \ \[IndentingNewLine]List[\[IndentingNewLine]m[\([Range[Length[m]], Range[2, Length[m[\([1]\)]]]]\)], \[IndentingNewLine]m[\([All, 1]\)]]]\[IndentingNewLine]\[IndentingNewLine]\[IndentingNewLine] \ (*\ inequalities\ from\ h - representation\ are\ equipped\ with\ variables\ *) \n GetInequFromHRep[ hrep_List\ /; \ hrep[\([Length[ hrep]]\)] != {"\"}] := \ \ \[IndentingNewLine]Module[\ \[IndentingNewLine]{rawmatrix = GetMatrixFromHRep[ hrep]}, \[IndentingNewLine]Module[\[IndentingNewLine]{A = rawmatrix[\([1]\)], \[IndentingNewLine]b = rawmatrix[\([2]\)], \[IndentingNewLine]x = MakeVariables[rawmatrix[\([3]\)], rawmatrix[\([4]\)]]}, \[IndentingNewLine]Inner[ List, \(-A . x\), b, List]]]\[IndentingNewLine]\n GetInequFromHRep[ hrep_List] := \[IndentingNewLine]Module[\[IndentingNewLine]{rawmatrix = hrep[\([Range[4, Length[hrep] - 1]]\)]}, \[IndentingNewLine]Module[\[IndentingNewLine]{A = rawmatrix[\([All, Range[2, Length[rawmatrix[\([1]\)]]]]\)], \[IndentingNewLine]b = rawmatrix[\([All, 1]\)], \[IndentingNewLine]x = Symbol /@ \(FromCharacterCode /@ Range[97, 97 + Length[rawmatrix[\([1]\)]] - 2]\)}, \[IndentingNewLine]Inner[List, \(-A . x\), b, List]]]\[IndentingNewLine]\[IndentingNewLine]\[IndentingNewLine] \ (*Inequalities\ from' rawmatrix' - data\ obtained\ by\ GetMatrixFromHRep\ are\ produced\ here\ *) \n GetInequFromMatrix[{A_, b_, part_, angles_}] := \[IndentingNewLine]A . MakeVariables[part, angles] \[GreaterEqual] \ \(-b\)\[IndentingNewLine]\[IndentingNewLine] (*\ more\ readable\ form\ of\ inequalities\ obtained\ by\ GetInequFromHRep\ \ *) \n InequToRead[ineq_List] := \(LessEqual[#[\([1]\)], #[\([2]\)]] &\) /@ ineq // MatrixForm\[IndentingNewLine]\n PartSymbol[ sym_Symbol] := \(Symbol[StringTake[SymbolName[sym], {#, # + 1}]] &\) /@ Range[1, StringLength[SymbolName[sym]], 2]\[IndentingNewLine]\n NotNull[x_Integer] := True\ /; x \[NotEqual] 0\[IndentingNewLine]\[IndentingNewLine] (*\ not\ really\ applicable\ - \ further\ improvement\ of\ this\ function\ in\ future\ versions\ *) \n ReduceInequ[ hrep_List] := \[IndentingNewLine]Module[\[IndentingNewLine]{rawmatrix = GetMatrixFromHRep[ hrep]}, \[IndentingNewLine]Module[\[IndentingNewLine]{A = rawmatrix[\([1]\)], \[IndentingNewLine]b = rawmatrix[\([2]\)], \[IndentingNewLine]x = MakeVariables[rawmatrix[\([3]\)], rawmatrix[\([4]\)]]}, \[IndentingNewLine]\(\((#1 . x \[GreaterEqual] #2)\) &\)\[IndentingNewLine]Sequence \ @@ \[IndentingNewLine]\((\(Delete[#, \[IndentingNewLine]Position[A, x_ /; Length[ Cases[x, y_?\((NotNull[#] &)\)]] \[LessEqual] 1, {1}, Heads -> False]\ (*\ triviale\ weg\ *) \[IndentingNewLine]] &\) \ /@ \[IndentingNewLine]{A, b})\)]]\[IndentingNewLine]\[IndentingNewLine] (*\ functions\ are\ applied\ to\ h - representation, \ angles\ of\ detectors\ must\ be\ given\ and\ functions\ must\ be\ \ predefined\ in\ buffer\ *) \n ApplyFunctions[ hrep_List\ /; \((StringPosition[\(hrep[\([\(-1\)]\)]\)[\([1]\)], \ "\"] \[NotEqual] {})\)\ , angles_List, func_ /; ValueQ[ func[{_}]]] \ := \[IndentingNewLine]Module[\[IndentingNewLine]{rawmatrix = GetMatrixFromHRep[ hrep]}, \[IndentingNewLine]Module[\[IndentingNewLine]{A = rawmatrix[\([1]\)], \[IndentingNewLine]b = rawmatrix[\([2]\)], \[IndentingNewLine]x = func /@ EventList[angles], \[IndentingNewLine]vars = MakeVariables[rawmatrix[\([3]\)], rawmatrix[\([4]\)]]}, \[IndentingNewLine]{GetInequFromHRep[ hrep], \(-A . x\)}]]\[IndentingNewLine]\[IndentingNewLine] ApplyFunctions[hrep_List, angles_List, func_ /; ValueQ[ func[{_}]]] \ := \[IndentingNewLine]Module[\[IndentingNewLine]{rawmatrix = GetMatrixFromHRepMod[ hrep]}, \[IndentingNewLine]Module[\[IndentingNewLine]{A = rawmatrix[\([1]\)], \[IndentingNewLine]b = rawmatrix[\([2]\)], \[IndentingNewLine]x = func /@ EventList[angles], \[IndentingNewLine]vars = Symbol /@ \(FromCharacterCode /@ Range[97, 97 + Length[rawmatrix[\([1]\)]] - 2]\)}, \[IndentingNewLine]{GetInequFromHRep[ hrep], \(-A . x\)}]]\[IndentingNewLine]\[IndentingNewLine] (*\ plot\ inequalities\ *) \n\n NotNullAppend[l_List, expr_ /; \[Not] expr === Null] := Flatten[{l, expr}, 1]\n NotNullAppend[l_List, expr_ /; expr === Null] := l\[IndentingNewLine]\n\n PlotList[function_, r : {var_, varmin_, varmax_}, violation_Real] := \[IndentingNewLine]Module[\[IndentingNewLine]{points \ = N[PlotPoints /. Options[PlotList]]}, \[IndentingNewLine]Module[\ \[IndentingNewLine]{plist = \[IndentingNewLine]Table[\[IndentingNewLine]{var, function}, \[IndentingNewLine]Evaluate[ Append[r, \((varmax - varmin)\)/ points]]]}, \[IndentingNewLine]{plist} /; Max[plist[\([All, 2]\)]] > violation]]\[IndentingNewLine]\n PlotList[function_, r : {var_, varmin_, varmax_}, violation_Real, opts___] := Null\[IndentingNewLine]\n PlotInequalities[hrep_List, limit_List, angles_List, func_ /; ValueQ[func[{_}]], opts___] := \[IndentingNewLine]Module[\[IndentingNewLine]{data = ApplyFunctions[hrep, angles, func]}, \[IndentingNewLine]Plot[\[IndentingNewLine]Evaluate[ data[\([2]\)] - \(data[\([1]\)]\)[\([All, 2]\)]], \[IndentingNewLine]limit, opts]]\[IndentingNewLine]\[IndentingNewLine]\n PlotInequalities[file_String, limit_List, angles_List, func_ /; ValueQ[func[{_}]], equnr_ /; \((VectorQ[equnr] || equnr == All)\), violation_Real: 0. , opts___] := \[IndentingNewLine]Module[\[IndentingNewLine]{strFile = OpenRead[file], plotfunctions}, \[IndentingNewLine]Off[ Read::readn]; \[IndentingNewLine]plotfunctions = \ \[IndentingNewLine]Module[\[IndentingNewLine]{strInput = Read[strFile, Record], \[IndentingNewLine]i = 0, min, max, \[IndentingNewLine]cols, \[IndentingNewLine]result = {}, \ \[IndentingNewLine]readform = Record, \[IndentingNewLine]vars = MakeVariables[ Sequence @@ Dimensions[angles]], \[IndentingNewLine]x = func /@ EventList[angles]}, \[IndentingNewLine]If[ equnr === All, \[IndentingNewLine]min = 0; max = Infinity, \[IndentingNewLine]min = First[equnr]; max = Last[ equnr]]; \ \[IndentingNewLine]\[IndentingNewLine]While[\((\[Not] \((strInput === EndOfFile)\)\ && \[Not] \((strInput === $Failed)\)\ && \ \((i <= max)\))\), \[IndentingNewLine]result = NotNullAppend[ result, \[IndentingNewLine]If[\[IndentingNewLine]strInput == \ "\", \[IndentingNewLine]strInput = Read[strFile, {Number, Number, String}]; \[IndentingNewLine]cols = strInput[\([2]\)]; \[IndentingNewLine]readform = Table[Number, {cols}];, \[IndentingNewLine]Null, \(i++\); \ \[IndentingNewLine]If[\((i >= min)\) && \((i <= max)\), \[IndentingNewLine]Module[\ \[IndentingNewLine]{inequ = Times[Drop[strInput, 1], \(-1\)], \[IndentingNewLine]bound = strInput[\([1]\)]}, \[IndentingNewLine]PlotList[ inequ . x - bound, limit, violation]]]]]; \[IndentingNewLine]strInput = Read[strFile, readform];]; result]; \[IndentingNewLine]On[ Read::readn]; \[IndentingNewLine]Close[file]; \[IndentingNewLine]If[ plotfunctions \[NotEqual] {}, \ \[IndentingNewLine]Graphics`MultipleListPlot`MultipleListPlot[ Sequence @@ plotfunctions, Sequence @@ Join[{opts}, Options[PlotInequalities]]], \[IndentingNewLine]{}]]\ \[IndentingNewLine]\[IndentingNewLine] (*\ violated\ inequalites\ are\ obtained\ *) \ \n GetViolInequalities[hrep_List, angles_List, func_ /; ValueQ[func[{_}]], equnr_ /; \((VectorQ[equnr] || equnr \[Equal] All)\), violation_Real: 0. ] := \ \[IndentingNewLine]Module[\[IndentingNewLine]{data = ApplyFunctions[hrep, N /@ angles, func], \[IndentingNewLine]datarange = equnr /. \((equnr \[RuleDelayed] Range[Sequence @@ equnr]\ /; \ \[Not] \((equnr === All)\))\)}, \[IndentingNewLine]Module[\ \[IndentingNewLine]{iequ = \(data[\([1]\)]\)[\([datarange, 1]\)], \[IndentingNewLine]limit = \ \(data[\([1]\)]\)[\([datarange, 2]\)], \[IndentingNewLine]qmsolution = \ \(data[\([2]\)]\)[\([datarange]\)]}, \[IndentingNewLine]\(List[ LessEqual[iequ[\([#]\)], limit[\([#]\)]], qmsolution[\([#]\)]] &\) /@ \[IndentingNewLine]Flatten[\ \[IndentingNewLine]Position[\[IndentingNewLine]Inner[Plus, qmsolution, \(-limit\), List], \[IndentingNewLine]x_ /; Greater[x, violation]]]]]\[IndentingNewLine]\[IndentingNewLine]\n GetViolInequalities[file_String, angles_List, func_ /; ValueQ[func[{_}]], equnr_ /; \((VectorQ[equnr] || equnr \[Equal] All)\), violation_Real: 0. , opt___] := \[IndentingNewLine]Module[\[IndentingNewLine]{strFile = OpenRead[file], retval}, \[IndentingNewLine]Off[ Read::readn]; \[IndentingNewLine]retval = Module[\[IndentingNewLine]{strInput = Read[strFile, Record], \[IndentingNewLine]i = 0, min, max, \[IndentingNewLine]cols, \[IndentingNewLine]result = {}, \ \[IndentingNewLine]readform = Record, \[IndentingNewLine]vars = MakeVariables[ Sequence @@ Dimensions[angles]], \[IndentingNewLine]x = func /@ EventList[ angles]}, \[IndentingNewLine]\[IndentingNewLine]If[ equnr === All, \[IndentingNewLine]min = 0; \ max = Infinity, \[IndentingNewLine]min = First[equnr]; \ max = Last[ equnr]]; \ \[IndentingNewLine]\[IndentingNewLine]While[\((\[Not] \((strInput === EndOfFile)\) && \[Not] \((strInput === $Failed)\) && \ \((i \[LessEqual] max)\))\), \[IndentingNewLine]result = NotNullAppend[result, If[\[IndentingNewLine]strInput \[Equal] "\", \ \[IndentingNewLine]strInput = Read[strFile, {Number, Number, String}]; \[IndentingNewLine]cols = strInput[\([2]\)]; \[IndentingNewLine]readform = Table[Number, {cols}], \[IndentingNewLine]Null, \(i++\); \ \[IndentingNewLine]If[\((i \[GreaterEqual] min)\) && \((i \[LessEqual] max)\), \[IndentingNewLine]Module[\ \[IndentingNewLine]{inequ = Times[Drop[strInput, 1], \(-1\)], \[IndentingNewLine]limit = strInput[\([1]\)]}, \[IndentingNewLine]If[\((inequ \ . x - limit)\) > violation, \[IndentingNewLine]If[\(PrintOut /. {opt}\) /. Options[ GetViolInequalities], \ \[IndentingNewLine]Print[{inequ . vars \[LessEqual] limit, inequ . x // N}]]; \[IndentingNewLine]{inequ . vars \[LessEqual] limit, inequ . x // N}]]]]]; \[IndentingNewLine]strInput = Read[strFile, readform];\[IndentingNewLine]]; result]; \[IndentingNewLine]On[ Read::readn]; \[IndentingNewLine]Close[ file]; \[IndentingNewLine]DeleteCases[retval, x_ /; Length[x] \[NotEqual] 2]\[IndentingNewLine]]\[IndentingNewLine]\[IndentingNewLine] ContPlotList[function_, r1 : {var1_, var1min_, var1max_}, r2 : {var2_, var2min_, var2max_}, opts___] := \[IndentingNewLine]Module[\[IndentingNewLine]{points = N[\(PlotPoints\ /. {opts}\) /. \ Options[ContPlotList]]}, \[IndentingNewLine]List[\ \[IndentingNewLine]Table[\[IndentingNewLine]function, \ \[IndentingNewLine]Evaluate[ Append[r1, \((var1max - var1min)\)/ points]], \[IndentingNewLine]Evaluate[ Append[r2, \((var2max - var2min)\)/ points]]], \ \[IndentingNewLine]Flatten[\[IndentingNewLine]Prepend[\[IndentingNewLine]\ Options[ContourGraphics], \[IndentingNewLine]{opts, Options[ContPlot], MeshRange \[Rule] {{var1min, var1max}, {var2min, var2max}}}]]]]\n\[IndentingNewLine] (*\ contour\ plot\ from\ h - representation\ of\ violated\ inequalities\ *) \[IndentingNewLine] ContPlotInequalities[hrep_List, range1_, range2_, angles_, func_ /; ValueQ[func[{_}]], equnr_ /; \ VectorQ[equnr]\ || \ equnr \[Equal] All, violation_Real: 0. , opts___] := \[IndentingNewLine]Module[\[IndentingNewLine]{data = ApplyFunctions[hrep, angles, func], \[IndentingNewLine]isize = \(ImageSize /. {opts}\) /. ImageSize \[Rule] 288, \[IndentingNewLine]fsize = \(\(FontSize /. {opts}\) /. \ $TextStyle\) /. FontSize \[Rule] 12}, \[IndentingNewLine]\(ContourGraphics[ Sequence @@ #] &\) /@ \[IndentingNewLine]Select[\ \[IndentingNewLine]\((\(ContPlotList[#[\([1]\)], range1, range2, opts, PlotLabel \[Rule] \[IndentingNewLine]DisplayForm[\ \[IndentingNewLine]StyleBox[\[IndentingNewLine]GridBox[{{#[\([2]\)]}}, ColumnWidths -> IntegerPart[ isize/fsize]], \[IndentingNewLine]LineSpacing \ \[Rule] {N[fsize/12], 2}, LineIndent \[Rule] 0]]\[IndentingNewLine]]\[IndentingNewLine] &\) \ /@ \[IndentingNewLine]Part[\[IndentingNewLine]\((Inner[\[IndentingNewLine]\ List, \[IndentingNewLine]data[\([2]\)] - \(data[\([1]\)]\)[\([All, 2]\)], \[IndentingNewLine]LessEqual @@@ data[\([1]\)], \[IndentingNewLine]List])\), \ \[IndentingNewLine]equnr /. \((equnr \[RuleDelayed] Range[Sequence @@ equnr] /; \[Not] \((equnr === All)\))\)])\), \ \[IndentingNewLine]Max[#[\([1]\)]] > violation &]]\[IndentingNewLine]\[IndentingNewLine] ContPlotInequalities[file_String, range1_List, range2_List, angles_List, func_ /; ValueQ[func[{_}]], equnr_ /; \ VectorQ[equnr] || equnr == All, violation_Real: 0.001, opts___] := \[IndentingNewLine]Module[\[IndentingNewLine]{strFile = OpenRead[file], contplots}, \[IndentingNewLine]\[IndentingNewLine]If[ strFile === $Failed, Abort[]]; \[IndentingNewLine]Off[ Read::readn]; \[IndentingNewLine]contplots = Module[\[IndentingNewLine]{strInput = Read[strFile, Record], \[IndentingNewLine]result = {}, \[IndentingNewLine]i \ = 0, min, max, \[IndentingNewLine]symInput, \[IndentingNewLine]cols, rows, \[IndentingNewLine]contopts = DeleteCases[{opts}, x_ /; MemberQ[x, PrintOut]], \[IndentingNewLine]readform = Record, \[IndentingNewLine]vars = MakeVariables[ Sequence @@ Dimensions[angles]], \[IndentingNewLine]x = func /@ EventList[ angles], \[IndentingNewLine]isize = \(ImageSize /. {opts}\) \ /. ImageSize \[Rule] 288, \[IndentingNewLine]fsize = \(\(FontSize /. {opts}\) /. \ $TextStyle\) /. FontSize \[Rule] 12}, \[IndentingNewLine]\[IndentingNewLine]\ \[IndentingNewLine]\[IndentingNewLine]While[\((strInput \[NotEqual] \ "\")\)\ && \ \[Not] \((strInput === EndOfFile)\)\ && \[Not] \((strInput === $Failed)\), \ \ \[IndentingNewLine]strInput = Read[strFile, readform]]; \[IndentingNewLine]\[IndentingNewLine]strInput = Read[strFile, {Number, Number, String}]; \[IndentingNewLine]cols = strInput[\([2]\)]; \[IndentingNewLine]rows = strInput[\([1]\)]; \[IndentingNewLine]readform = Table[Number, {cols}]; \ \[IndentingNewLine]If[equnr === All, min = 0; \ max = rows, min = First[equnr]; \ max = Last[equnr]]; \ \ \ \[IndentingNewLine]For[i = 0, i < min - 1, \(i++\), Read[strFile, readform]]; \[IndentingNewLine]\[IndentingNewLine]For[i = min, i <= max, \(i++\), \[IndentingNewLine]strInput = Read\ [strFile, readform]; \[IndentingNewLine]result = NotNullAppend[ result, \[IndentingNewLine]Module[\[IndentingNewLine]{graph = ContPlotList[\[IndentingNewLine]Times[ Drop[strInput, 1] . x, \(-1\)] - strInput[\([1]\)], \[IndentingNewLine]range1, \ \[IndentingNewLine]range2, \[IndentingNewLine]Sequence @@ contopts]}, \[IndentingNewLine]If[ Max[graph[\([1]\)]] > violation, \[IndentingNewLine]If[\(PrintOut /. {opts}\) \ /. Options[ContPlotList], \[IndentingNewLine]Show[ ContourGraphics[ graph[\([1]\)], \[IndentingNewLine]PlotLabel \ \[Rule] ToString[Times[Drop[strInput, 1] . vars, \(-1\)] <= strInput[\([1]\)], PageWidth \[Rule] 50], \[IndentingNewLine]graph[\([2]\)]]]]; \ \[IndentingNewLine]ContourGraphics[graph[\([1]\)], PlotLabel \[Rule] \[IndentingNewLine]DisplayForm[\ \[IndentingNewLine]StyleBox[\[IndentingNewLine]GridBox[{{Times[ Drop[strInput, 1] . vars, \(-1\)] <= strInput[\([1]\)]}}, ColumnWidths -> IntegerPart[ isize/ fsize]], \[IndentingNewLine]LineSpacing \ \[Rule] {N[fsize/12], 2}, LineIndent \[Rule] 0]], graph[\([2]\)]]]\[IndentingNewLine]]]]; result]; \[IndentingNewLine]\[IndentingNewLine]Close[ strFile]; \[IndentingNewLine]On[ Read::readn]; \[IndentingNewLine]contplots]\[IndentingNewLine]\ \[IndentingNewLine]\[IndentingNewLine] (*\ general\ interface\ to\ cdd\ *) \n Cdd[input_List, cmd_String: \((CddCmd /. Options[CddIF])\)] := \[IndentingNewLine]Module[\ \[IndentingNewLine]{calculation}, \[IndentingNewLine]If[ Position[input, x_\ /; ToLowerCase[ ToString[ x]] \[Equal] "\"] \[NotEqual] {}, \ \[IndentingNewLine]Export["\", input, "\"]; \[IndentingNewLine]Run[ cmd <> "\< \>" <> \ "\"]; \[IndentingNewLine]calculation \ = Import["\", "\"], \[IndentingNewLine]file = Export["\", input, "\"]; \[IndentingNewLine]Run[ cmd\ <> \ "\< tmp.ine\>"]; \[IndentingNewLine]calculation = Import["\", "\"]]; \[IndentingNewLine]Return[ calculation\ ];]\[IndentingNewLine]\n SetDirectory["\<.\>"]\[IndentingNewLine] SetCddCmd["\"]\n End[]\[IndentingNewLine] EndPackage[]\)