diff --git a/scripts/eval_monodromy_demo.m2 b/scripts/eval_monodromy_demo.m2 index b58643a..92c6d9b 100644 --- a/scripts/eval_monodromy_demo.m2 +++ b/scripts/eval_monodromy_demo.m2 @@ -1,3 +1,5 @@ +-- Integrated into ~/tutorial/ +-- -- code for generating various evaluators restart needsPackage "SLPexpressions" diff --git a/tutorial/MinusUtility.m2 b/tutorial/MinusUtility.m2 index 7206d9d..6c87512 100644 --- a/tutorial/MinusUtility.m2 +++ b/tutorial/MinusUtility.m2 @@ -17,3 +17,25 @@ cCode (String, List,List) := (outfile, outputs,inputs) -> ( cCode (String, GateMatrix,GateMatrix) := (outfile, M,I) -> cCode(outfile, flatten entries M, flatten entries I) + +-- from original Chicago parser.m2 +readStartSys = filename -> ( + l := separate("\n", get filename); + p0 := value(l#1); + sols := for i from 3 to #l-2 list value(l#i); + (transpose matrix p0, sols/(x->transpose matrix x)) + ) + +-- from original common.m2 +-- write starting parameters and solutions to file +writeStartSys = method(Options=>{Filename=>"startSys"}) +writeStartSys (Matrix, List) := o -> (M, sols) -> writeStartSys(point M, sols, o) +writeStartSys (Point, List) := o -> (p, sols) -> ( + assert(instance(o.Filename,String)); + f := openOut o.Filename; + f << "Parameter values: " << endl; + f << toExternalString p << endl; + f << "Solutions : " << endl; + for s in sols do f << toExternalString s << endl; + close f; + ) diff --git a/tutorial/README.md b/tutorial/README.md index 0ef1b4a..1f37ee9 100644 --- a/tutorial/README.md +++ b/tutorial/README.md @@ -1,5 +1,25 @@ -# TODO -## 4Tim +# CVPR 204 fast Homotopy Continuation tutorial + + + + +# Developer Internal Notes + +## Starting files +The tutorial started from Chicago trifocal problem code + +mostly + +minus/m2/chicago/formulation-minors-original-in-minus/t +minus/scripts/eval_monodromy_demo.m2 + +and the code after "end" in +/Users/rfabbri/cprg/vxlprg/lemsvpe/minus/M2/chicago/formulation-minors-original-in-minus/chicago.m2 + + + +## TODO +### 4Tim - createSeedPair vs fabricateChicago exactly? @@ -10,7 +30,7 @@ C = { makeSLProgram(matrix{cameraParams},P3) } -## Evaluate to check equation +### Evaluate to check equation - How can we evaluate the the equations on the system? - evaluate(F,x0||p0) only for F gatematrix, diff --git a/tutorial/ex-run.m2 b/tutorial/ex-run.m2 new file mode 100644 index 0000000..fe9e563 --- /dev/null +++ b/tutorial/ex-run.m2 @@ -0,0 +1,53 @@ +-- EX-RUN Homotopy Continuation Tutorial EX-RUN +-- +-- NAME +-- Fast HC Code Inteligencer - exactly how to craft your fast HC +-- Module: Final, fast solver. +-- +-- DESCRIPTION +-- +-- This script shows how to craft a fast solver for your problem +-- +-- It is broken down into Generic and Pro blocks, the pro blocks you can +-- and adapt if needed +-- +-- The design-goal of the file is to closely match what will be in the fast C++ +-- solver, so you can start with a generic and incrementally craft and test out the pro features +-- +-- The file is not based on generic tutorial scripts. Rather, it is rather technical +-- based on techniques that originally solved a very hard problem and for the +-- first time ever before, trifical pose from points and tangents Fabbri, etal, CVPR'10. +-- It is important to keep in mind that, while there are novelties in the -- associated m2 +-- scripts of PLMP, this version of them is the definitive account +-- of what matterscarefully for writing a fast C++ solver +-- +-- Run ex-start first once +-- +-- LEGEND +-- - Ex and Pro marked bellow mean Example (simple) and Pro (fast) +-- - YOU shows where can you make it faster for your problem + +-- OTHERS +-- - Think of this as a prompt precise enough for LLM to help generate a fast solver +-- +-- TODO +-- - update with PLMP versions of common, etc, making _sure_ it +-- doesn't impact performance +-- +-- AUTHORS +-- Ricardo Fabbri (C++ and M2) and Timothy Duff (M2) +-- + +restart +needs "parser.m2" +elapsedTime needs "chicago.m2" + +(p0,sols) = readStartSys "startSys"; +-- verify options are set as desired +netList((keys options trackHomotopy)/(opt ->(opt, getDefault opt))) +NAGtrace 3 +setRandomSeed 0 + + +-- (pLines, x) = parseFile(1,Tests=>true); +-- elapsedTime K = solveChicago(p0, pLines, sols);