For example,
Given a list of symbolic expressions:
ClearAll[a,o,t];
myexpr =
{
1 - t + 2 a[1] + (2 - t + 2 a[1]) (-1 + t + a[1] + o[1]) + (1 + a[1]) (-1 + t + a[1] + o[1])^2,
-1 + t + a[1] + o[1]
}
Given conditions on those symbols:
mycond = (1 <= t <= 3 && a[1] == t && o[1] > 3 - 2 t + a[1]) || (t > 3 && a[1] == t && o[1] >= 0)
And given "transformation" function foo
,
How can I "apply" those conditions to the expression and generate examples?
By "apply", I mean:
Every case of conditions separated by ||
is handled on its own.
In every case, for subcondition of form X == Y
, all X
get replaced by Y
(or the other way around) so only one of the two remains in the expressions.
In case of a >=,>
or <=,<
subconditions, those set up the relative bounds for symbols, lets call them boundLow,boundHigh
. If no bound is set, the extreme bounds are used.
The final bounds depend on given extreme bounds boundMin,boundMax
which restrict bounds boundLow,boundHigh
by having final bounds for every symbol: Max[boundLow,boundMin],Min[boundHigh,boundMax]
.
That is, the desired output is in this example: (After ==
substitutions in myexpr
and myconds
)
{Table[foo[myexpr],{t,Max[1,boundMin],Min[3,boundMax]},{o[1],Max[4-t,boundMin],boundMax}],
Table[foo[myexpr],{t,Max[4,boundMin],boundMax},{o[1],Max[0,boundMin],boundMax}]}
Where we have tables of examples generated by applying the myconds
(which consist of two cases separated by ||
and thus we have two tables) to myexpr
.
In the above example, I manually did the ==
replacements with /. ->
and manually set the bounds - how can I automate this process of "applying" conditions to expressions to generate examples?
Motivation
The above example is an actual output from an algorithm I'm trying to make that solves a problem I'm trying to solve - in this question, I'm wondering how can I generate examples from such outputs, to analyze them.