mrsonne / hubit

BSD 3-Clause "New" or "Revised" License
3 stars 0 forks source link

create input lists from parameter #34

Open mrsonne opened 3 years ago

mrsonne commented 3 years ago

currently lists in the results need to have a list in the input with the same length. For e.g. meshing problems it would be nice to allow a component to generate lists based on an input parameter. E.g. number of nodes.

mrsonne commented 3 years ago

Not sure this is so relevant but I will try to explain the use-case I think I recall. The input could look like this

input = {"number_of_nodes": 5, other_data: {....}}

If the model looks like this all nodes can be generated in the component in v0.3.0

consumes_input:
    - name: number_of_nodes
       path: input.number_of_nodes
provides_results:
    - name: nodes
       path: nodes# list of (x,y) values generated in one step

This would allow the coordinates of one node to depend on the coordinates for the other nodes. If we, however, assume that the node generator can create a node independently from the other nodes (only based on the knowledge that there are five nodes in total) we might want to actually generate each node independently. This would allow queries for e.g. "nodes[3]" and "nodes[:]" and would allow downstream components to use the node coordinates for further analysis before all nodes were generated. It would be tempting to craft a model like this

consumes_input:
    - name: number_of_nodes
       path: input.number_of_nodes
provides_results:
    - name: nodes
       path: nodes[@IDX_NODE]

But this will not work since the index context is not defined. So this feature would be about somehow allowing the index context IDX_NODE. Especially handling the query "nodes[:]" will be tricky since the LengthTree would need to be constructed based on the value of an input field rather than the length of an input field as is currently the case. Something like this might work

consumes_input:
    - name: number_of_nodes
       path: input.number_of_nodes
       defines: IDX_NODE
provides_results:
    - name: nodes
       path: nodes[@IDX_NODE]
mrsonne commented 2 years ago

For now this behavior can be achieved by generating the required input data in a preprocessing step before the Hubit model is executed