建模和仿真编程语言

发布于 2024-07-22 05:12:49 字数 167 浏览 8 评论 0原文

我使用许多不同的模型和模拟。 一些较旧的模型和模拟是用 FORTRAN 编写的。 其中一些模型已转换为 C++,但当前的趋势是使用 MATLAB/SIMULINK 创建这些模型。 从计算机科学的角度来看,我一直觉得 MATLAB/SIMULINK 不是一个好的解决方案。 您使用什么语言来创建模型和模拟?为什么?

I work with many different models and simulations. Some of the older models and simulations are written in FORTRAN. Some of those models have been converted to C++, but the current trend is to create these models using MATLAB/SIMULINK. From a computer science perspective I have always felt MATLAB/SIMULINK was not a good solution. What language do you use to create models and simulations and why?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(6

静水深流 2024-07-29 05:12:49

我总是尝试使用最好的建模和模拟工具(或库,如果您愿意的话)提供的语言来为我完成这项工作。

这个问题实际上只能通过考虑您想要实现的模型类型来回答。 连续(例如 ODE)、离散(例如 StateCharts、Petri Nets)还是组合(即混合模型,可以使用 Simulink+StateFlow 实现)? 每种模型都有不同的工具。

另一个重要方面是您工作的。 Simulink 拥有相当广泛的电气工程、金融或计算生物学库(不过,它们中的大多数都包含在附加软件包中) - 如果您在这些领域之一工作,可能根本就没有更好的(即完整的、有效的)组件库。 其他商业仿真包也是如此,例如 AnyLogicArena 等。可能还有一些开源模拟工具,具体取决于您的建模问题。

最后,您可能更喜欢某种特定的编程语言而不是另一种,并且您可能有其他要求,例如支持

  • (模型参数的优化)
  • 验证
  • 输出分析(统计、绘图、统计测试)
  • 支持并行和分布式仿真
  • 模型检查
  • ...

所以我目前正在使用Java,它具有众所周知的优点——速度相当快、对多线程的良好支持、使用相对简单等等。但是如果“相当快”还不够快,那么除了下降之外可能别无选择一层抽象:-)

I would always try to use the language that is provided by the best modeling and simulation tool (or library, if you like) to do the job for me.

And this question can really only be answered by taking into account what kinds of models you want to implement. Continuous (e.g. ODEs), discrete (e.g. StateCharts, Petri Nets), or a combination (i.e. a hybrid model, as can be implemented with Simulink+StateFlow)? There are various tools for each kind of model.

Another important aspect would be the domain in which you are working. Simulink has pretty extensive libraries for electrical engineering, finance, or computational biology (most of them are included in additional packages, though) - if you work in one of those fields, there might simply be no better (i.e. complete, valid) component library. The same goes for other commercial simulation packages, such as AnyLogic, Arena, etc. There might also be some open-source simulation tools, depending on your modeling problem.

Finally, you might prefer a specific programming language over another, and you might have additional requirements, e.g. support for

  • Optimization (of model parameters)
  • Validation
  • Output analysis (statistics, plots, statistical tests)
  • Support for parallel and distributed simulation
  • Model checking
  • ...

So I'm currently working with Java with the well-known advantages - reasonably fast, good support for multi-threading, relatively simple to use etc. But if 'reasonably fast' is not fast enough, there might be no option but going down one level of abstraction :-)

装迷糊 2024-07-29 05:12:49

我还使用大量遗留代码,其中大部分是 Fortran 语言。 我真的不介意使用 Fortran - 所有现代编译器都允许变量名大于旧的和愚蠢的 6 个字符限制。 此外,使用 Fortran 95,如果您认为对现有代码库的修改会受益,您甚至可以进行 OOP。

此外,Fortran 有非常好的代码编辑器,但对于更专业的脚本语言来说并不总是如此。

C++ 在内存方面有很大的缺点。 我已经从事 C/C++ 编程 20 多年了,但我仍然忘记删除对象并正确填充析构函数。

最后一点,如果您使用的是 Windows,如果您想将 Fortran 迁移到托管环境,可以使用 Fortran.NET 编译器(我想来自 Lahey-Fujitsu?)。

祝你好运!

I also work with a lot of legacy code, most of it in Fortran. I really don't mind using Fortran - all the modern compilers allow variable names greater than the old and silly 6 character limit. Also, with Fortran 95, you can even do OOP if you feel that your modifications to the existing codebase would benefit.

Also, there are very good code editors for Fortran, which isn't always the case for more specialized script languages.

C++ has the great disadvantage of memory considerations. I have been programming C/C++ for 20+ years now, and I still forget to delete objects and properly fill in destructors.

On a final note, if you're using Windows, there is a Fortran.NET compiler (I think from Lahey-Fujitsu?) if you want to move your Fortran to a managed environment.

Good luck!

半透明的墙 2024-07-29 05:12:49

当然是模拟!! :-)

SIMULA of course !! :-)

混浊又暗下来 2024-07-29 05:12:49

我从 MATLAB 中得到的好处是它能够让我快速构建算法原型。 通过绘制数据并使用内置的统计函数,我确实可以很好地了解数据。 当尝试新事物时,我可以做一些快速而肮脏的事情来获得一些初步结果,然后返回并清理东西以完善我的结果。 对于编译语言,我还需要做很多事情才能让模拟运行。 使用 MATLAB,我花更多的时间思考真正的问题,而不是花在编译、链接、内存管理等方面。

然而,有很多问题 MATLAB 无法解决。 对于大型数据集,几乎肯定需要具有用户定义数据结构的编译语言。

What I've gotten out of MATLAB is it's ability to let me quickly prototype an algorithm. I can really get a good feel for the data by plotting it and using the built in statistics functions. When trying something new out, I can do something quick and dirty to get some initial results, then go back and clean things up to refine my results. With compiled languages, there's a lot more I have to do just to get the simulation to run. With MATLAB, I spend more time thinking about the real problem, and less about compiling, linking, memory management, etc.

However, there are many problems that MATLAB is just ill-equipped to solve. For large data sets, a compiled language with user defined data structures is almost certainly necessary.

浊酒尽余欢 2024-07-29 05:12:49

粒子物理学已经转向 C++ 和 Python。 这不是通用的,如果没有 ROOT 的普遍存在,可能甚至不会接近。

Root 对 cint 的使用意味着当你思考一个新想法时,你需要费心处理内存管理,它的编译运行能力可以让你提高速度,混合模式的能力非常有帮助,并且 python 和其他模式的绑定RAD 语言具有很大的灵活性。

从真正意义上来说,这可以归结为对roland<的认可/strong>的观点

Particle physics has been moving to C++ and python. This is not universal, and probably wouldn't even be close were it not for the ubiquity of ROOT.

Root's use of cint means you needed bother with memory management when you're dinking around with a new idea, it's capacity to run compiled allows you to have speed, the ability to mix the modes is very helpful, and the bindings for python and other RAD languages allow for great flexibility.

In a very real sense, this comes down to an endorsement of roland's point.

扭转时空 2024-07-29 05:12:49

您可以使用 s-funcuin 块将 fortran(c,c++) 与 matlab 链接。

you can use s-funcuin block for linking fortran(c,c++) with matlab.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文