| 67 | | We need a notion of a ''parametrized model''. So we only have to write a single model {{{laplace}}} (for example), and not {{{laplace_2_2}}}, {{{laplace_2_3}}}, etc. |
| 68 | | |
| 69 | | Should the parameters be dealt with like pre-processor directives ({{{#define N 3}}})? |
| 70 | | |
| 71 | | A parametrized model should basically be a function which takes some parameter values and returns a {{{ModelIF}}}. It could have a method |
| 72 | | |
| 73 | | {{{ModelIF instantiate(Map<P,V> parameterValues);}}} |
| 74 | | |
| 75 | | or something like that, where the map assigns a value to each parameter. The MiniMP representation might look something like: |
| 76 | | |
| 77 | | {{{ |
| 78 | | parameter int N = 7; /* default value */ |
| 79 | | parameter bool BLACK; |
| 80 | | #ifdef BLACK |
| 81 | | ... |
| 82 | | #endif |
| 83 | | }}} |
| 84 | | |
| 85 | | To add: |
| 86 | | * ParameterIF |
| 87 | | * TypeIF type(); |
| 88 | | * String name(); |
| 89 | | * int id(); |
| 90 | | * Parameter |
| 91 | | * ParameterExpressionIF |
| 92 | | * ParameterExpression |
| 93 | | |
| 94 | | Add methods: |
| 95 | | |
| 96 | | * ModelFactoryIF |
| 97 | | * ParameterIF newParameter(TypeIF type, String name); |
| 98 | | * creates a new parameter with given name |
| 99 | | * ParameterExpressionIF parameterExpression(ParameterIF parameter); |
| 100 | | * ExpressionIF substitute(ExpressionIF expression, Map<ParameterIF,Object> parameterValueMap); |
| 101 | | * each ParameterExpression gets replaced by a LiteralExpression for the value given in the map. If the parameter does not occur in the map, it remains a ParameterExpression |
| 102 | | |
| 103 | | * ModelIF |
| 104 | | * void addParameter(ParameterIF parameter) |
| 105 | | * adds a parameter to this model. Parameters are numbered in the order they are added to model, starting from 0. |
| 106 | | * Collection<ParameterIF> parameters(); |
| 107 | | * returns the list of parameters for this model |
| 108 | | * ParameterIF getParameter(int i); |
| 109 | | * returns the i-th parameter for this model. |
| 110 | | * ModelIF instantiate(Map<ParameterIF,Object> parameterValueMap) |
| 111 | | * returns the model obtained by substituting the values for the corresponding parameters. Not every parameter need occur as a key in the map. The resulting model will have parameter set that is the difference between the original parameter set and the parameters occurring as keys the map |
| 112 | | * boolean isParametrized() |
| 113 | | * equivalent to !parameters.isEmpty() |
| 114 | | * Expression |
| 115 | | |
| 116 | | Thought of better way to do this. Much simpler. Do not add new notion of parameters. Just make them all inputs. And add the ability to specify concrete values for inputs. |
| 117 | | |
| 118 | | Modify methods: |
| 119 | | |
| 120 | | * complete: needs to determine if model is parameterized |
| 121 | | |
| 122 | | |
| 123 | | |
| 124 | | |