Hi, I have a symbolic function that I would like to simplify and I do not see how.
Here is the test case. The function has 8 inputs and 2 outputs. In Python it is
simple to define :
def functionCrue(X) :
Q, Ks, Zv, Zm, Hd, Zb, L, B = X
alpha = (Zm - Zv)/L
H = (Q/(Ks*B*sqrt(alpha)))**(3.0/5.0)
Zc = H + Zv
Zd = Zb + Hd
S = Zc - Zd
return [H,S]
myFunction = PythonFunction(8, 2, functionCrue)
As you can see, the code is simplified by intermediate variables which are used
by subsequent Python statements. For exemple, the slope of the river alpha is
first computed, then the height H is computed depending on the slope. Then the
variable S is computed based on Zc and Zd, where Zc is computed depending on
the height H.
When I define the function as a symbolic function, the current definition is
more involved.
inputs = ['Q', 'Ks', 'Zv', 'Zm', 'Hd', 'Zb', 'L', 'B']
formulas = ['(Q/(Ks*B*sqrt((Zm - Zv)/L)))^(3.0/5.0)','(Q/(Ks*B*sqrt((Zm -
Zv)/L)))^(3.0/5.0)+Zv-(Zb + Hd)']
myFunction = SymbolicFunction(inputs, formulas)
As you can see, I cannot reuse the value of the first output into the second
output.
The following interface would be much easier to use. The formulas variable is a
list of couples, where the first item is the name of the output variable and
the second item is the string to evaluate it.
inputs = ['Q', 'Ks', 'Zv', 'Zm', 'Hd', 'Zb', 'L', 'B']
output1 = ['alpha', '(Zm - Zv)/L']
output2 = ['H', '(Q/(Ks*B*sqrt(alpha)))^(3.0/5.0)']
output3 = ['Zc', 'H + Zv']
output4 = ['Zd', 'Zb + Hd']
output5 = ['S', 'Zc - Zd']
formulas = [output1,output2,output3,output4,output5]
myFunction = SymbolicFunction(inputs, formulas)
Is there another way of doing this ? Do you agree that the suggestion is worth
being developed ?
Best regards,
Michaël
Ce message et toutes les pièces jointes (ci-après le 'Message') sont établis à
l'intention exclusive des destinataires et les informations qui y figurent sont
strictement confidentielles. Toute utilisation de ce Message non conforme à sa
destination, toute diffusion ou toute publication totale ou partielle, est
interdite sauf autorisation expresse.
Si vous n'êtes pas le destinataire de ce Message, il vous est interdit de le
copier, de le faire suivre, de le divulguer ou d'en utiliser tout ou partie. Si
vous avez reçu ce Message par erreur, merci de le supprimer de votre système,
ainsi que toutes ses copies, et de n'en garder aucune trace sur quelque support
que ce soit. Nous vous remercions également d'en avertir immédiatement
l'expéditeur par retour du message.
Il est impossible de garantir que les communications par messagerie
électronique arrivent en temps utile, sont sécurisées ou dénuées de toute
erreur ou virus.
____________________________________________________
This message and any attachments (the 'Message') are intended solely for the
addressees. The information contained in this Message is confidential. Any use
of information contained in this Message not in accord with its purpose, any
dissemination or disclosure, either whole or partial, is prohibited except
formal approval.
If you are not the addressee, you may not copy, forward, disclose or use any
part of it. If you have received this message in error, please delete it and
all copies from your system and notify the sender immediately by return message.
E-mail communication cannot be guaranteed to be timely secure, error or
virus-free.
crue-8I3O-propagation-simple.py
Description: crue-8I3O-propagation-simple.py
_______________________________________________ OpenTURNS users mailing list [email protected] http://openturns.org/mailman/listinfo/users
