Idea

Serge A avatar image
2 Likes"
Serge A suggested Serge A edited

Implement tgamma and other special functions in Flexscript

Flexscript standard library has built-in functions to draw random samples from many probability distributions, but is surprisingly lacks some common math functions:

The lack of the hyperbolic functions is a minor annoyance: there are exp and log functions after all.

The lack of the gamma function is more difficult to accept. It is necessary to calculate the parameters of the Weibull distribution with a given mean, which, I suppose, is a pretty common thing in the discrete event simulation.

Fortunately, most of these functions are already implemented in the standard C++ library. Even more are supported in C++17.

My current workaround to run std::tgamma() or similar is to create a module with a DLL library, export a wrapper for each of the standard functions like

_declspec(dllexport) Variant tgamma_wrapper(FLEXSIMINTERFACE) {
    return std::tgamma(param(1));
}

then create a corresponding usercommand in FlexSim, change its code node to DLL type, and point it to tgammer_wrapper. That's a lot of work, and a lot of unnecessary overhead. I suppose the built-in Flexscript functions can do it more efficiently.

It would be nice if tgamma and other special functions were available in Flexscript.

Another group of standard math functions that Flexscript needs are functions like

  • isinf and INFINITY literal
  • isnan and NAN literal
  • isnormal

They're already in the C++ standard library.

flexscriptstatisticsfeature request
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

No Comments

Your Opinion Counts

Share your great idea, or help out by voting for other people's ideas.