Closed Giannis1993 closed 3 years ago
I have not tried to run the code, so just some comments based on reading these functions:
It would be great to have a default option available, or some other way to specify the application of subproblems to a bunch of combinations directly. For instance, in the example the combinations (1,0), (1,1), (1,2)
are all Linear & Taylor1
. Maybe we can wrap this subproblem map in a (very small) class where we can pass a such a map and a default instance. Inside that class, we can then call self.map.get(key, self.default)
as fallback to the default.
I am wondering if there is a way to avoid the duplication of code for accessing the individual variables, notice how get_bounds, g, dg, ddg
all perform the same nested for loop across the combinations of variable and response sets. There are of course many ways to resolve that, we could store all indices on class initialisation as the outer product of var_set.keys()
and resp_set.keys()
Note this does not necessarily have to be a prebuild matrix, that can also be done by some iterator, you could think of
def problems(self):
for p in range(...):
for l in range(...):
yield (p, l)
# inside functions
for (p, l) in self.problems:
# apply operation to each problem
Do we want to have var_set
inside, or outside? What I mean is prob.xmin[var_set[1]]
versus problem_set[index].xmin
? Maybe if we flip the current structure inside out, we have less nesting of the indexing for the problems?
I would have to take a bit more in depth look though, to really suggest other implementations. Maybe it's good to discuss the current structure and possible alternatives this Friday? I doubt I can take more detailed look before, but perhaps in the weekend I can
My suggestion for the initialisation is as follows
# Default initialize all to MMA, Taylor1
mix = Mixed(var_sets, resp_sets, default_intervening=MMA, default_approximation=Taylor1, default_movelimit=...)
# Specify a few sets
mix.set_group(0, 1, intervening=ConLin, approximation=Taylor2, ...)
mix.set_group(1, range(5), approximation=Taylor2)
mix.set_group(1, 2, intervening=Linear)
In this way a default uniform mixed scheme is initialized, and by using the set_group
method, specific groups are altered.
Intervening variables, approximation, and move limit should be able to set independently, e.g.:
# One variable set, three response sets
mix = Mixed(var_sets, resp_sets, default_intervening=MMA, default_approximation=Taylor1, default_movelimit=...)
mix.set_group(0, [0, 1], intervening=ConLin)
mix.set_group(0, 1, approximation=Taylor2)
Which results in (0,0 - ConLin, Taylor1) and (0,1 - ConLin, Taylor2) and (0,2 - MMA, Taylor1).
Let's continue this discussion on #52
This is to discuss how to implement/assemble mixed schemes. I am a fan of dictionaries, so here is how I implemented it. I remember however that you guys had some other thoughts with a list/tuple of
subproblems
.In the
main
function I would write (ifn=4
):Whereas the
Mixed
class would be as: