You are searching about How Much Math Do I Need To Know For Progrmaming, today we will share with you article about How Much Math Do I Need To Know For Progrmaming was compiled and edited by our team from many sources on the internet. Hope this article on the topic How Much Math Do I Need To Know For Progrmaming is useful to you.
Muc lục nội dung
Solving the Sudoku Using Integer Programming
A 9 X 9 SUDOKU puzzle has the following rules. Each row and column must have the numbers between 1 and 9 and each of the inner cells must have the numbers between 1 and 9. Each number in each column and row and in each small cell must only be once
We define Xijk so that all the values of I, jik from 1 to 9 are 1. If the cell (I,j) contains the number k where I, jik range between 1 and 9. Here I denotes the row iij denote column jik denotes an integer between 1 and 9. When X134 = 1, it means that cell (1,3) contains the number 4. This would also imply that none of the other elements in the 1st row or 3rd column except cell (1,3) can be equal to 4.
To model the SUDOKU we will use a total of 729 variables.
We now formulate each of the three classes of rules algebraically.
Each row must contain a number between 1 and 9 exactly once.
For the first row, this rule would appear as ( called “Constraint” in integer programming language).
for each I from 1 to 9 and for each k from 1 to 9 (I is a mathematical representation of a counter variable)
sum (Xijk) for all j from 1 to 9 = 1;
Written in detailed form for the 1st row for each number between 1 and 9
X111 + X121 + X131 + X141 + X151 + X161 + X171 + X181 + X191 = 1.
X112 + X122 + X132 + X142 + X152 + X162 + X172 + X182 + X192 = 1.
X113 + X123 + X133 + X143 + X153 + X163 + X173 + X183 + X193 = 1.
X114 + X124 + X134 + X144 + X154 + X164 + X174 + X184 + X194 = 1.
These equations follow for variables starting with X115 through X119.
Similarly, we formulate equations for the rules of each number between 1 and 9 occurring only once in each of the 9 columns.
Written in mathematical notation,
sum X for each j from 1 to 9 (for all I ik between 1 and 9) = 1
Written in detailed form for a few columns for each number between 1 and 9
Column 1
X111 + X211 + X311 + X411 + X511 + X611 + X711 + X811 + X911 = 1.
X112 + X212 + X312 + X412 + X512 + X612 + X712 + X812 + X912 = 1.
X113 + X213 + X313 + X413 + X513 + X613 + X713 + X813 + X913 = 1.
This must be filled in for the remaining numbers 4 to 9.
Column 2
X121 + X221 + X321 + X421 + X521 + X621 + X721 + X821 + X921 = 1.
X122 + X222 + X322 + X422 + X522 + X622 + X722 + X822 + X922 = 1.
X123 + X223 + X323 + X423 + X523 + X623 + X723 + X823 + X923 = 1.
It must be filled in for the rest of the numbers 4 to 9.
We now represent the small boxes (3 x 3) with a total of 9 squares.
So in each 3 x 3 square, there must be only one 1 or 2 or 3 or 4 or 5 or 6 or 7 or 8 or 9, etc.
Cells are between columns (1-3) and rows (1-3), columns (4-6) and rows (1-3) the columns (from 7 to 9) the rows (from 1 to 3). Also for the same set of columns they appear in rows (4 to 6) and (6 to 9). Therefore, we formulate the equations for a single small square located between columns (1 to 3) and rows (1 to 3). The corresponding decision variables for the digit “1” are (9 in total)
X111, X121, X131, X211, X221, X231, X311, X321, X331.
Let’s formulate the equation that this square (3 x 3) contains only one “1”.
So the equation is
X111 + X121+ X131 + X211 +X221+ X231+ X311 + X321 + X331 = 1.
The above equation would imply that only one of these 9 variables or only one of these nine cells can take the value 1.
Similarly, constraints should be formulated for digit ‘2’, digit ‘3’ and so on up to 9.
For integer programming problems, in addition to the equations describing the constraints, there should also be integer constraints imposed on each and every variable so that eventually when the system of equations, a 0 or a 1 is obtained as the solution of the Xijk variable. .
The geometric equivalent of a linear programming problem with an objective function and some constraints is nothing more than a one-dimensional polyhedron where n represents the number of constraints in the problem. Usually the optimal solution will be found at the vertices of the polytope, also the rules of some method like SIMPLEX will require the polytope to be convex so that you can traverse from vertex to vertex along the edges and find the optimal solution.
Imposing integer constraints would also mean that the optimal solution will not be at the vertices of the polytope since a solution that is at the vertex may not be an integer. So, after considering that the optimal solution must be 0 or 1, it will mean that geometrically the solution will be somewhere inside the feasible region of the convex polytope and on one of the many straight lines that originate from the hyperplane equivalent to Xi jk that has an integer. values.
Note that the above solution used 729 decision variables and 81 row constraints. 81 column constraints and 729 least square constraints for a total of 901 constraints. There can be many objective functions, but one objective function can be formulated as finding the min of (sum of all 729 variables). The number of constraints can be reduced by finding some redundancy.
These above equations cannot be solved using programming languages such as Visual Basic, Pascal, or C. Integer programming problems can be solved using optimization software such as the CPLEX optimizer, an Excel add-in for solving linear programming problems , Lingo, etc.
Video about How Much Math Do I Need To Know For Progrmaming
You can see more content about How Much Math Do I Need To Know For Progrmaming on our youtube channel: Click Here
Question about How Much Math Do I Need To Know For Progrmaming
If you have any questions about How Much Math Do I Need To Know For Progrmaming, please let us know, all your questions or suggestions will help us improve in the following articles!
The article How Much Math Do I Need To Know For Progrmaming was compiled by me and my team from many sources. If you find the article How Much Math Do I Need To Know For Progrmaming helpful to you, please support the team Like or Share!
Rate Articles How Much Math Do I Need To Know For Progrmaming
Rate: 4-5 stars
Ratings: 6481
Views: 83854248
Search keywords How Much Math Do I Need To Know For Progrmaming
How Much Math Do I Need To Know For Progrmaming
way How Much Math Do I Need To Know For Progrmaming
tutorial How Much Math Do I Need To Know For Progrmaming
How Much Math Do I Need To Know For Progrmaming free
#Solving #Sudoku #Integer #Programming
Source: https://ezinearticles.com/?Solving-the-Sudoku-Using-Integer-Programming&id=9107720