Sun Mar 25 17:29:34 CEST 2012
Evaluation of equation network
- set of nodes
- set of relations that refer nodes
- subset of nodes with initial values
- compute the corresponding output values or fail.
It's important to not change the form of the algorithm when the subset
of specified values changes. I.e. in the problem at hand, what is
important is the value of all nodes. Which nodes that serve as input
should be shielded from the code that uses the node values.
However, it might be useful to perform the search in 2 steps: compile
I/O config to function, then use function multiple times.
Thinking about this, it seems that the most important part here is to
actually specify the inputs. How to do this without loosing
composition? I.e. if it's encoded in types then the types already
specify the structure..
I lack experience to find a way to express this properly..
( input spec ? )
-> X..XX.XX... partially completed
-> XXXXXXXXXXX fully completed, after evaluating equations
The structure is known at compile time.
f x y =
[a,b,c] <- nodes 3
in a x
sum [a, b, c] -- sum == 0
prod [a, b] -- product == 1
'solve' returns a structure of all the nodes, currently a list
(of floats) but this should probably be a heterogenous type
'nodes' creates a list of node variables
'in' initializes a node value
'sum' and 'prod' are multi-directional constraints.
Trouble with this approach is that it doesn't compose: the whole
network needs to be defined at once. Well, maybe not. Let's try to
implement this with the ST monad and see where it breaks.
EDIT: it seems there is definitely some advantage here to separate
content from structure, which in Haskell can often be done using type
classes. It seems that the whole "network building" could be done as
a compile-time computation. Would this make it easier, or is this
just one of those neat side-tracks that doesn't add much to the end