Utility function getting too long

17 views
Skip to first unread message

Tom Eagle

unread,
Jan 8, 2023, 3:48:56 PMJan 8
to Biogeme
Is there an example of where I can write an extremely long utility function, but break it up into parts so I do not get into parsing restrictions?

Thank you in advance for any examples!

Tom Eagle

Bierlaire Michel

unread,
Jan 8, 2023, 4:00:01 PMJan 8
to tce...@gmail.com, Bierlaire Michel, Biogeme
Hi Tom,

In Python, you can write a long expression on several lines by placing it into parentheses: 

V = (
  beta_1 * x_1 +
  beta_2 * x_2 + 
  …
)

Also, I would recommend to use loops as much as possible instead of very long expressions.

Finally, if you have a long sum, prefer the bioMultSum operator to a long list of binary “+”. 



--
You received this message because you are subscribed to the Google Groups "Biogeme" group.
To unsubscribe from this group and stop receiving emails from it, send an email to biogeme+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/biogeme/88f82e87-c772-4509-9e36-12e7f8ad5e66n%40googlegroups.com.

Thomas Eagle

unread,
Jan 10, 2023, 5:17:51 AMJan 10
to Bierlaire Michel, Biogeme
Thank you.  I'll study up on bioMultSum

Tom

On Jan 8, 2023, at 12:59 PM, Bierlaire Michel <michel.b...@epfl.ch> wrote:


Reply all
Reply to author
Forward
0 new messages