关于mathematica的初级问题(研读分享一看就会的图文教程-Mathematica)

分享兴趣、传播快乐、增长见闻、留下美好,大家好,这里是LearningYard学苑,今天小编为大家带来文章:一看就会的图文教程-Mathematica(4)。

Share your interests, spread happiness, increase your knowledge, and stay good. Hello, everyone. This is LearningYard Academy. Today, the editor brings you an article: A graphic tutorial-Mathematica (4).

关于mathematica的初级问题(研读分享一看就会的图文教程-Mathematica)(1)

01 今日内容介绍:Introduction of today's content:

上一期为大家介绍了用Mathematica建立政府-企业的两方演化博弈模型,并进行了计算(附上链接「研读分享」一看就会的图文教程-Mathematica(3)),今天我们一起学习如何用Matlab实现演化博弈的仿真。

In the last issue, I introduced the use of Mathematica to build a government-enterprise two-party evolutionary game model, and performed calculations (attach the link). Today we will learn how to use Matlab to realize evolutionary game simulation.

02 为什么要仿真Why emulate?

案例1(见下文):我们对之前建立博弈模型仿真,是为了直观地观察政府(y=政府决定管制企业的逆向物流的概率)、企业决策的概率(x=企业决定构建逆向物流的概率)之间的关系。

案例2(见下文):引入时间t作为自变量,观察随着时间的变化,政府和企业会倾向于哪种决策。

案例3(见下文):更进一步地,我们可以增加新的供应链参与者(如消费者)考察,消费者企业-政府的三方博弈如何进行。

Case 1 (see below): We established the game model simulation before, in order to intuitively observe the government (y=the probability that the government decides to regulate the reverse logistics of the enterprise) and the probability of corporate decision-making (x=the probability that the enterprise decides to construct the reverse logistics) The relationship between.

Case 2 (see below): Introduce time t as an independent variable, and observe which decisions the government and enterprises prefer over time.

Case 3 (see below): Further, we can add new supply chain participants (such as consumers) to examine how the consumer-business-government tripartite game is conducted.

03 如何仿真How to simulate?

上期结论

首先需要解释一下上一期提到的“复制动态方程”的含义。First, I need to explain the meaning of the "copy dynamic equation" mentioned in the previous issue.

关于mathematica的初级问题(研读分享一看就会的图文教程-Mathematica)(2)

(附上上一期算例分析中得到的结果。)

(Attach the results obtained in the analysis of the previous calculation.)

关于mathematica的初级问题(研读分享一看就会的图文教程-Mathematica)(3)

常微分方程

其次,我们要了解如何求解常微分方程?Second, we need to understand how to solve ordinary differential equations?

众所周知,对一些典型的常微分方程,能求解出它们的一般表达式,并用初始条件确定表达式中的任意常数。但实际中存在有这种解析解的常微分方程的范围十分狭窄,往往只局限在线性常系数微分方程(含方程组),以及少数的线性变系数方程。对于更加广泛的、非线性的一般的常微分方程,通常不存在初等函数解析解。由于实际问题求解的需要,求近似的数值解成为了解决问题的主要手段。常见的求数值解的方法有欧拉折线法、阿当姆斯法、龙格-库塔法与吉尔法等。其中由于龙格-库塔法的精度较高,计算量适中,所以使用得较广泛。

数值解的最大优点是不受方程类型的限制,即可以求任何形式常微分方程的特解(在解存在的情况下),但是求出的解只能是数值解。

As we all know, some typical ordinary differential equations can be solved in their general expressions, and initial conditions can be used to determine any constants in the expressions. However, in practice, the scope of ordinary differential equations with such analytical solutions is very narrow, often limited to linear constant coefficient differential equations (including equations), and a few linear variable coefficient equations. For more extensive, non-linear general ordinary differential equations, there is usually no analytical solution of elementary functions. Due to the need for solving practical problems, seeking approximate numerical solutions has become the main method to solve problems. Common methods for finding numerical solutions include Euler's broken line method, Adams method, Runge-Kutta method and Gil method. Among them, the Runge-Kutta method has high accuracy and moderate calculation amount, so it is widely used.

The biggest advantage of numerical solution is that it is not limited by the type of equation, that is, it can find the special solution of any form of ordinary differential equation (when the solution exists), but the solution obtained can only be a numerical solution.

Ode45函数:

说明:ode45函数是基于龙格库塔法(Runge-Kutta法),专门用于解微分方程的功能函数。

格式:[T,Y] = ode45(‘定义常微分函数的文件名(该函数文件必须返回一个列向量)’,T的范围,y的初始值)。其中,T为离散的自变量值,Y为离散的函数值。

意义:ode函数是基于T的变化,将常微分方程的求解结果,展示在Y中,Y会以列向量的格式输出为结果。所以,T被称为返回列向量的时间点,Y被称为返回对应T的求解列向量。

Ode45 function:

Description: The ode45 function is based on the Runge-Kutta method (Runge-Kutta method), and is specifically used to solve the functional function of differential equations.

Format: [T,Y] = ode45 ('the file name that defines the ordinary differential function (the function file must return a column vector)', the range of T, the initial value of y). Among them, T is the value of the discrete independent variable, and Y is the value of the discrete function.

Significance: The ode function is based on the change of T, and displays the solution result of the ordinary differential equation in Y, and Y will be output as a result in the format of a column vector. Therefore, T is called the time point of returning the column vector, and Y is called returning the solution column vector corresponding to T.

04 本期方法总结Summary of methods in this issue

1. 首先,无论是两方博弈还是三方博弈的仿真,需要先定义常微分函数,运用matlab中的function函数来定义。

比如在两方博弈中,存在由概率x,y表示的一组微分方程(对应本算例中得到的复制动态方程),我们需要先将原微分方程转做换元处理。下图中用一个例子来帮助理解。

1. First of all, whether it is a two-party game or a three-party game simulation, you need to define the ordinary differential function first, and use the function function in matlab to define it.

For example, in a two-party game, there is a set of differential equations represented by probabilities x and y (corresponding to the replicated dynamic equation obtained in this example). We need to first convert the original differential equation into a conversion element. An example is used in the figure below to help understand.

关于mathematica的初级问题(研读分享一看就会的图文教程-Mathematica)(4)

2.然后,进行绘图工作(用plot命令绘制命令)。

Then, carry out the drawing work (use the plot command to draw the command).

05 基于两方博弈的仿真Simulation based on two-party game

案例1:基于企业和政府的两方博弈仿真

Case 1: Two-party game simulation based on enterprise and government.

关于mathematica的初级问题(研读分享一看就会的图文教程-Mathematica)(5)

关于mathematica的初级问题(研读分享一看就会的图文教程-Mathematica)(6)

关于mathematica的初级问题(研读分享一看就会的图文教程-Mathematica)(7)

案例2:引入时间t的两方博弈仿真

Case 2: Two-party game simulation at time t is introduced.

关于mathematica的初级问题(研读分享一看就会的图文教程-Mathematica)(8)

关于mathematica的初级问题(研读分享一看就会的图文教程-Mathematica)(9)

关于mathematica的初级问题(研读分享一看就会的图文教程-Mathematica)(10)

06 基于三方博弈的仿真Simulation based on the tripartite game

案例3:基于企业、政府、消费者的三方博弈

Case 3: Based on the three-party game simulation of enterprises, governments, and consumers.

关于mathematica的初级问题(研读分享一看就会的图文教程-Mathematica)(11)

关于mathematica的初级问题(研读分享一看就会的图文教程-Mathematica)(12)

关于mathematica的初级问题(研读分享一看就会的图文教程-Mathematica)(13)

07 将案例3用二维图表示Represent Case 3 in a two-dimensional diagram

关于mathematica的初级问题(研读分享一看就会的图文教程-Mathematica)(14)

关于mathematica的初级问题(研读分享一看就会的图文教程-Mathematica)(15)

关于mathematica的初级问题(研读分享一看就会的图文教程-Mathematica)(16)

往期精彩:

一看就会的图文教程-Mathematica(1)

一看就会的图文教程-Mathematica(2)

「研读分享」一看就会的图文教程-Mathematica(3)

-END-

今天的分享就到这里啦!

感兴趣的同学可以留言与小编交流,

咱们下周见!

参考资料:

[1] 田琦师姐的学习文档。

[2] matlab中常微分方法,MATLAB常微分方程https://blog.csdn.net/weixin_35812582/article/details/115814959.

[3] matlab求解常微分方程(组)---dsolve、ode系列函数详解(含例程)https://blog.csdn.net/lynn15600693998/article/details/86597068.

[4] 知乎:浅谈用Matlab求解微分方程https://zhuanlan.zhihu.com/p/162296418.

翻译:Google翻译。

本文由LearningYard学苑整理并发出,部分资料来自网络,若有侵权请联系!

,

免责声明:本文仅代表文章作者的个人观点,与本站无关。其原创性、真实性以及文中陈述文字和内容未经本站证实,对本文以及其中全部或者部分内容文字的真实性、完整性和原创性本站不作任何保证或承诺,请读者仅作参考,并自行核实相关内容。文章投诉邮箱:anhduc.ph@yahoo.com

    分享
    投诉
    首页