[PYTHON] The problem becomes easier to solve depending on the formulation method

Sometimes when you're solving a certain problem, you can't really improve it anymore. This is an unavoidable part as long as you choose that method. In such a case, let's think about whether it can be solved well by using another framework.

** In most cases, an example that closely resembles the problem you are thinking of is an already known problem. ** ** Often only a few parts are special in my case. Such an idea is common to the idea that even in problem solving, hints can be obtained from existing problem solving cases. TRIZ

Even in the case of math problems, many problems are often formulated as minimization problems. If it is a well-known problem, a formulation to solve it has already been considered, and there are many completely different approaches.

** Many people will have a distressed experience in math geometry classes. But that is training to know that there are many ways to solve the problem, not just one. ** **

The yen is ・ A collection of flat points that are equidistant from one point, ・ Plane figure when inflated to maximize the area with a certain circumference ・ A figure in which the normals of tangents always intersect at one point It can be described in various forms. By changing the formulation of such a problem, the ease of solving the problem changes indefinitely.

Even the phenomenon of refraction [Snell's Law](https://ja.wikipedia.org/wiki/%E3%82%B9%E3%83%8D%E3%83%AB%E3%81%AE%E6%B3%95%E5 It can be written in an expression that includes a sin function called% 89% 87). Minimum Time Principle ([Fermat's Principle](https://ja.wikipedia.org/wiki/%E3%83%95%E3%82%A7%E3%83%AB%E3%83%9E%E3% 83% BC% E3% 81% AE% E5% 8E% 9F% E7% 90% 86): Of the paths connecting two points, the path that takes the shortest time to pass by light refracts light) It can also be described by. If we try to consider refraction in a situation where the index of refraction changes continuously, it is more likely that the principle of minimum time is easier to solve than Snell's law. [Principle of Whistle Fence](https://ja.wikipedia.org/wiki/%E3%83%9B%E3%82%A4%E3%83%98%E3%83%B3%E3%82%B9% EF% BC% 9D% E3% 83% 95% E3% 83% AC% E3% 83% 8D% E3% 83% AB% E3% 81% AE% E5% 8E% 9F% E7% 90% 86) Can also be thought of as a wave.

In this way, the ease of solving a problem changes depending on the type of problem formulation.

** Even if the problem is the same, the ease of solving it depends on how it is formulated. ** ** Whether to find an exact solution or a reasonable match Whether you want stability when including incorrect inputs. The formulation to be used depends on them.

The same is true for the least squares method used in student experiments. At first, I used to draw a straight line by hand with "Eiya" (a science experiment in junior high school). Next, an era in which we know a little statistics and draw fitting results using the method of least squares of straight lines. Furthermore, the era of fitting polynomial approximation with multivariable parameters. An era in which outliers are considered to be mixed in the input of statistical data, and processing (robust processing) that is not easily affected by outliers is performed.

The key to solving problems is how to formulate things and make them easier to solve.

As long as the content realized by software is some kind of problem solving, the ease of solving will change dramatically depending on how the content realized by the software is formulated. Design patterns must be an example of such a formulation. Let's increase the standard of problem solving to the tool box you have. They will empower you in the challenges you face.


** Machine learning is also a minimization problem **

Machine learning problems are most problems and are often defined as problems that minimize a single quantity. https://www.csie.ntu.edu.tw/~cjlin/papers/guide/guide.pdf Let's look at Eq. (1) in p1. It is defined as the problem of minimizing the value of the expression.

Boltzmann Machine (https://en.wikipedia.org/wiki/%E3%83%9C%E3%83%AB%E3%83%84%E3%83%9E%E3%83%B3%E3%83 % 9E% E3% 82% B7% E3% 83% B3) Energy for the entire network E Is defined as a minimization problem.

** Loss function ** Much of deep learning is expressed as minimizing the loss function for the training dataset in a given network configuration. It describes what kind of post-optimization results will be obtained depending on what kind of loss function is adopted. The type of loss function to be adopted depends on what kind of result you expect to obtain in the process you want to do.

You can learn from slideShare Theory and Practice of Machine Learning.

Loss function that should be suppressed by machine learning (classification)

** Optimization problem with constraints ** The constrained optimization problem is To the optimization problem for a new quantity by adding a term derived from the constraint condition to the quantity to be minimized Can be replaced.

The method is [Lagrange's undetermined multiplier method](https://ja.wikipedia.org/wiki/%E3%83%A9%E3%82%B0%E3%83%A9%E3%83%B3%E3% 82% B8% E3% 83% A5% E3% 81% AE% E6% 9C% AA% E5% AE% 9A% E4% B9% 97% E6% 95% B0% E6% B3% 95) It has become a mathematical method widely used in various fields.

Lagrange's undetermined multiplier method http://www.neuro.sfc.keio.ac.jp/~masato/study/SVM/lagrange.htm

In an era when computer power was poor, Utilizing the same phenomenon of mathematical behavior, Physically measure the resulting value and convert it I have read in a book that I have analyzed the behavior of the object I want to know. It ’s about how to formulate the problem, and how you can enjoy it. I think it was obtained by thinking through it.

Recommended Posts

The problem becomes easier to solve depending on the formulation method
How to solve the bin packing problem
Try to solve the fizzbuzz problem with Keras
Try to solve the Python class inheritance problem
Try to solve the internship assignment problem with Python
I tried to solve the problem with Python Vol.1
In Python, change the behavior of the method depending on how it is called
The problem becomes easier to solve depending on the formulation method
The one who is not on DVD
If branch depending on whether there is a specific element in the list
Solve the Monty Hall problem
How to solve the problem that time goes wrong every time you turn on the power in Linux
I wanted to solve the ABC164 A ~ D problem with Python
Solve the Python knapsack problem with a branch and bound method
I tried to solve the shift scheduling problem by various methods
Try to solve the function minimization problem using particle swarm optimization
Use Raspberry Pi to solve the problem of insufficient mobile Wi-Fi connection
The 16th offline real-time how to write reference problem to solve with Python
Try to solve the traveling salesman problem with a genetic algorithm (Theory)
The 19th offline real-time how to write reference problem to solve with Python
I tried to solve the E qualification problem collection [Chapter 1, 5th question]
I tried to solve the inverted pendulum problem (Cart Pole) by Q-learning.
TLE seemed to be scary depending on how the input was received
Want to solve a simple classification problem?
Easier div tags on the Trac wiki
Solve the maximum subarray problem in Python
Try to solve the traveling salesman problem with a genetic algorithm (Python code)
Try to solve the traveling salesman problem with a genetic algorithm (execution result)
In Python, change the behavior of the method depending on how it is called
Solve the Python asymmetric traveling salesman problem with a branch and bound method