Вы находитесь на странице: 1из 6

See discussions, stats, and author profiles for this publication at: https://www.researchgate.

net/publication/286679509

Solution of a Classical Cryptarithmetic Problem by using parallel genetic


algorithm

Conference Paper · October 2014


DOI: 10.1109/ICRITO.2014.7014715

CITATIONS READS

2 3,676

2 authors, including:

Ajay vikram Singh


Middle East College
32 PUBLICATIONS   136 CITATIONS   

SEE PROFILE

Some of the authors of this publication are also working on these related projects:

wireless sensor networks View project

All content following this page was uploaded by Ajay vikram Singh on 26 May 2017.

The user has requested enhancement of the downloaded file.


Solution of a Classical Cryptarithmetic Problem
by using Parallel Genetic Algorithm
Aadil Minhaz1, Ajay Vikram Singh2
1,2
Amity Institute of Information Technology, Amity University
Uttar Pradesh, Noida, India

1
aadilminhaz@hotmail.com
2
avsingh@amity.edu

Abstract— The term CryptArithm: it is a mathematical


puzzle which involves the replacement of digits with alphabets, Assigning digits or numbers to letters in the following way,
symbols and letters. The art and science of solving this would be an acceptable solution which is arithmetically
CryptArithms is known as Cryptarithmetic. CryptArithmetic is
related to constraint satisfaction problems (CSP) which uses correct as well.
Operators (Arithmetic) e.g +, -, between relevant words to make O=0, M=1, Y=2, E=5, N=6, D=7, R=8 and S=9.
mathematical relations in a way that final outcome is logically
true. It also ensures that the assigning of values every letter of
each word and numbers will produce the accurate result. The
numbers are assigned in such a way that no letter should have
two numbers (0…9), each letter should contain different
number from 0 to 9. Solving CryptArithmetic generally includes
a mixed approach of derivation and huge possibility tests. This
paper is an effort to find a solution of a Classical
CryptArithmetic Problem (CAT+RAN=AWAY) which is
computationally expensive and time consuming by using
parallel genetic algorithm.
Fig. 2 Solution of the stated CryptArithmetic Problem
Keywords— Artificial Intelligence, CryptArithmetic, Parallel
Genetics Algorithm, AI CryptArithmetic is related to constraint satisfaction
problems (CSP) which uses Operators (Arithmetic) e.g +, -,
I. INTRODUCTION between relevant words to make mathematical relations in a
The art and science of solving CryptArithms is known as way that final outcome is logically true. It also ensures that the
Crypt arithmetic. It is a class of mathematical puzzle which assigning of values every letter of each word and numbers will
involves the replacement of digits with alphabets, symbols produce the accurate result. A constraint satisfaction problem
and letters. Earlier it was known as letter arithmetic. The first (CSP) is a problem of search in which values of a set of
CryptArithms was emerged in USA in 1864, the American variables define the states and the goal specifies the
Agriculturist, M.Vatriquant introduced the word ‘Crypt constraints that has to be followed by the value.
Arithmetic’ ("cryptarithmie" in French language); writing Here we are discussing some of the constraints which can
under the Minos, in the month of May in 1931 issue of Sphinx. be used to solve CryptArithmetic problems
The most famous puzzle is SEND + MORE = MONEY; 1. No two letters can have the same digits or a unique digit
created by Mr. H. E. Dudeney, and published in July’1924, in should be allocated to all the letters. Like, M,O,R,N,Y,S,E,
Strand Magazine issue, associated with the kidnappers story N,D, all should be represent with the unique digit.
of ransom demand. [1] 2. We cannot assign 0 to the first letter of the word. Like, in
Example: the above problem, we cannot assign 0 to S or M letters.
3. The resulting number i.e. third number should be as per the
mathematical operation applied to the first two numbers.
Like, the MONEY i.e. 10652 should match the sum of
SEND (9567) and MORE (1085).
4. We can allocate the numbers or digits from 0 to 9 only or
the problem may have the maximum of 10 different letters.
[2]

Fig. 1 The CryptArithmetic (CA) Problem

978-1-4799-6896-1/14/$31.00 ©2014 IEEE


This section introduce about CryptArithmetic. Section II
is about Genetic Algorithm and why we use Genetic
Algorithm? Section III will introduce Parallel Genetic
Algorithm. Section IV will help us to understand the
Implementation and Pseudo code of Genetic Algorithm.
Discussion about classical problem is in section V. Results are
in Section VI, conclusion is in section VII and section VIII is
about future work. Last section is reference/bibliography.

II. GENETIC ALGORITHM


In 1970s John Holland introduced the Genetic
Algorithms at University of Michigan, United States. The
improvement in the performance & price of the different
Systems of Computation has made them a tool for several of
Optimizations. For combinatorial and mixed problems the
Genetic Algorithm works well. The problem of getting stuck
at local optima is less that the methods of gradient search. But
they are very expensive. To solve a problem the Genetic
Fig. 3 Genetic Algorithm Cycle
Algorithm depicts a solution as Chromosome (i.e. thread-like
structure). The Genetic Algorithm then creates the solutions A. Why Genetic Algorithm
and applies Genetic Operators such as crossover and mutation
It is better than the conventional Artificial Intelligence,
to evolve solutions, in order to find the best ones. [3]
as this algorithm is more sturdy and strong. Unlike, older
Genetic Algorithm is a search heuristic algorithm that
Artificial Intelligence system, they do not break easily, even if
imitates the process of natural selection. To generate the
the parameters are changed marginally, or even in the
useful solutions to optimize problems, this heuristic is used. existence of noise. In the scrutiny of a large state-space, n-
Genetic Algorithm (GA) belongs to a larger class of dimensional surface, or multi-modal state-space, a Genetic
evolutionary algorithms which generate the solutions using
Algorithm (GA) offer significant betterment over the typical
techniques such as Selection, Mutation, Inheritance and
scrutiny of maximization methods.
Crossover.
The Genetic algorithms (GAs) are persuasive procedures,
To represent the solutions a cluster (or population) that is
which are used to iron out the problems in peculiar practices.
a collection of Chromosomes is used by the Genetic Parallel GAs (Genetic Algorithm) is notably easy to use and
Algorithm. The solutions in the problem domain can be then guarantee significant hike in the pursuance, and as such there
encoded into the chromosome (i.e. thread-like structure) in the
has been encompassing researches in this domain. Genetic
Genetic Algorithm domain and vice-versa. Generation of
algorithms (GA’s) are based on the innate election explored
population is happened at the very first stage. After that, to
by Mr. Charles Darwin. They bring to bear the innate election
evaluate the quality (or fitness) or every chromosome,
of competent entity as maximization hitches are unfolded.
objective values are taken from objective function by the Maximization is operated through innate swap of genetic
fitness function. During the evolution process; the
incarnate between the parents. Descendant’s are brought about
chromosome in the healthiest condition has the greater
from the parent genes. The fitness of descendant’s are checked
survivor chance. The objective function is specific to problem,
out. Only the fittest individual is allowed to breed.
and system performance index can be represented by its
Descendant’s are then brought into being during the process
objective value. Next; for parents of the population a specific
of crossover and mutation. Thus, these descendant’s, form
chromosome group is chosen. Then, Genetic Operation is used new genesis, which swaps the previous one’s. [2]
to produce the offspring, these operations are normally
The success of maximization firmly depends on the
mutation & crossover. Like the parents; offspring’s fitness is
selected chromosome (i.e. thread-like structure) encoding
calculated and also use in the replacement process to replace
scheme, and the mutation & crossover, strategies as well as
the chromosomes (i.e. thread-like structure) in the current
gathering (or population) by selected offspring. Then, until an the fitness objective.
anticipated criterion is satisfied, the Genetic Algorithm cycle
is repeated for e.g. the generation reached its maximum III. PARALLEL GENETIC ALGORITHM
number, or objective value is less than the threshold. The Parallel Genetic Algorithm (PGA) is used to divide
Designing Genetic Algorithm includes several techniques. the problem into smaller tasks. In Parallel Genetic Algorithm,
These are the genetic operations, fitness evaluation, encoding the tasks are solved parallel on different processors. Parallel
schemes, replacement strategies and parent selection. The Genetic Algorithm can be classified in four major types:
Genetic Algorithm cycle is shown in Figure-2.1, where coding • Fine grained GA
scheme is the phenotype; that represents the chromosomes. • Single Population master slave GA,
• Multiple population GA,
• Hierarchical hybrids 2. The Crossover Operator
Fine grained Genetic Algorithm consists of single 3. The Mutation Operator
structure population, which are two dimensional. Here, the 1. Selection Operator: It allows the preference to
fitness evaluation is performed parallel for all individuals. individuals to pass their genes to next generation. Each
Single population Genetic Algorithms can have only individual fitness quality is depending on objective function.
single population. The GA (crossover, mutation, selection) is 2. Crossover Operator: This is distinguished from other
executes by one master node, and fitness is evaluated by slave Optimization techniques. This operator is used to select
node. individuals from the population. The bit strings is randomly
Multiple populations Genetic Algorithm, consists of few choose along the crossover site. In this operator the better
sub-populations that exchange individuals. This exchange individual is created by re-combining portions of individuals.
process is called migration and controlled by few parameters 3. Mutation Operator: The purpose of Mutation Operator
like, destination, frequency and selection of migrants. is; inhibit premature convergence & maintain diversity within
Hierarchical Genetic Algorithm consists of multiple deme the population. The random walk can be stimulated through
algorithms. The hierarchical genetic algorithm is a search space. Selection and Mutation operators are used to
combination of components benefits. This algorithm suits on create the algorithms like, parallel hill climbing, and noise
symmetric multi-processor. tolerant algorithm.
The populations of strings in a Genetic Algorithm conceal Pseudo code for Genetic Algorithm:
the candidate fixes, which is called entity, to a maximization GA(n, a, u)
issue, emerges towards better quick fix. Traditionally, the // Initialize generation value equal to 0
fixes are used to represent in binary form i.e. 0 and 1. Other v := 0;
types of schemes are also possible. Progression usually starts Pop := n randomly generated, individuals population;
from populations of singletons that apply to Generation. The // Assess Pop
singleton fitness is evaluated in generation, where individuals Compute fitness(i) for each i ∈ Pop;
are selected from the population, and altered to form an do
entirely new population. The freshly generated population is {
then used in the next iteration of the algorithm. It has been // Create generation v + 1
noticed that the algorithm terminates, when a maximum no. of // 1. Copy it
generations has been produced; or a satisfying level is reached Select (1 − a) × n members of Pop and insert into the
for the population. In case, the algorithm was ended due to Pop+1;
maximum number of generations; a sufficing solution may be // 2. Crossover it
or may not have been accomplished. Genetic Algorithms (GA) Select a × Pop n members;
find the application in manufacturing, bioinformatics pair selected members up ;
chemistry, engineering computational science, physics , produce the offspring ;
economics & mathematics and some related fields. insert this offspring to Pop+1;
// 3. Mutate operator
A typical genetic algorithm needs: Select u × pop+1 n members;
reverse, randomly select bit in each one;
i. A Genetic representation of the quick fix domain // then, Evaluate Pop+1
ii. Fitness function to evaluate solution domain Compute the fitness(i) for each i ∈ Pop;
// then, Increment
v := v + 1;
A classic representation of the fix is, as an array of bits. The }
arrays of any other type and structure can be used effectively
in the same way. The main factor that makes these while fittest individual health in Pop is not high;
representations favourable is that their parts are easily aligned return, the fittest individual from Pop;
due to their rigid size, which speed ups the simple crossover Here, number of individuals in the population is n, a is
progressions. fraction of population that has to be replaced by crossover in
The objective of fitness is to define over the Genetic each iteration and mutation rate is u.
portrayal and calculate the virtue of represented fix.
After the Genetic portrayal and fitness objectives are V. DISCUSSION
described, Genetic Algorithm (GA) moves on to initialize a
population of solutions, and upgrade it through the continual In this paper, we have tried to analyze the efficient
application of inversion, mutation, selection, and crossover algorithm to solve a classical CryptArithmetic problem. This
operators.[3], [4], [5] paper objective is to understand the solution of
CryptArithmetic (CA) problems in an effective way. The use
IV. IMPLEMENTATION OF GENETIC ALGORITHM of Genetic Algorithm (GA) showed; that within an efficient
The algorithm develops gradually through these operators: amount of time we can get the output of big instances.
1. The Selection Operator
CryptArithmetic is a Constraint Satisfaction Problem (CSP) Now, we cannot allocate 0, 1, 3, 7 and 9 and we have only
in which the letters are replaced by digits or numbers (0...9), 2, 4, 5, 6, and 8 are remaining. We have scenario like:
such that a unique digit has been assigned to each letter, the 1+C+R=W. If we take C=2 and R=8, then the value of W will
challenge is to find the digit’s sequence that is assigned to be 1 which is already occupied by A. If we take C=4 and R=8,
other letters, and finally satisfy the Arithmetic operations then the value of W will be 3 which is already occupied by N.
conditions. We cannot also take C=4 and R=5 because the sum will be 10
Here we consider our classical cryptarithmetic problem: and the value of W will be 0 which is already the value of Y.
We can assume the value of C=5 and R=6, the sum will be 12
and the value of W will become 2 which is not the value of
any variable.
The final output will be:

The objective is to calculate each letters value. No two


letters cannot be represent the same digit (If C=2 then A
cannot be 2) and the first letter should not be 0.
Here A must be 1. Here, we are adding only two three digits
number and their first value can be maximum upto 9 or 8 and
if we adding these values (i.e. C and R), the sum is only 17. VI. RESULT
This 1 is carry and become the value of A. So now we have: Parallel Genetic Algorithm is implemented by using JAVA
language. As JAVA support multithread environment so
implement of PGA have work as multiple threads of solution
for getting the values of unknown variables for solving the
problem. In this implementation for PGA
Number of variables- 08 (C, A, T, R, U, N, W, Y)
Number of generator threads- 05
Number of Iterations- 100
TABLE: 1
Now, U value become 9 because we have A=1, and if we COMPARISON RESULT
add, 1+9+1 (A=1, A=1, U=9) then only 1 will move as a carry
and the value of A will remain 1 in the below addition. Now Problem: CAT+RUN= AWAY
we have: Solution: 517+693= 1210
Number of Variable=08
PGA DFS
Minimum Time (ms) 510 9050
Maximum Time (ms) 2130 45400
Average Time (ms) 1155 22800
Memory Requirement (MB) 30.6 70.8
at the time of execution

In case of DFS (Depth First Search) approach only one


Now we cannot allocate 1 and 9 to any of the remaining
thread of execution works. We have taken the worst case of
variable. Assume T=7 and N=3 as we cannot assume T=8 and
blind search results into account.
N=3, otherwise the value of Y will be 1, which is already the
value of A. Now the value of Y=0 (7+3) and we have the VI. CONCLUSIONS
following scenario:
This paper concentrated on solving the classiacl
CryptArithmetic problem in an efficient way. The use of
Genetic Algorithm using selection, crossover and mutation
operators showed that it is possible to find the large instance’s
result in required (or acceptable) time. Clearly by searching in
a systematic manner the possible assignments of values to the
letters by deduction of search space we can easily find the
solutions to CryptArithmetic problems.
VII. FUTURE WORK REFERENCES
As a further dimension in future, we will try to develop [1] Shedge Kishor N., Sravan Kumar G : Solving Verbal Crypto-Arithmetic
Problem by Parallel Genetic Algorithm(PGA), International Journal of
more effective implementation of Genetic Algorithm to Computer Technology and Electronics Engineering (IJCTEE) Volume
reduce the calculation time and which will be more efficient 2, Issue 4,pp. 51-56, August 2012.
and general. [2] Hardik Soni & Nidhi Arora : Solving Crypt-Arithmetic Problems via
Genetic Algorithm, JMIJIT, Volume -1 Issue 1, pp. 12-17, January,
ACKNOWLEDGEMENT 2011, ISSN: Print 2229-6115.
[3] Reza Abbasian & Masoud Mazloom: Solving Cryptarithmetic Problems
Authors express their deep sense of gratitude to the Founder Using Parallel Genetic Algorithm, ICCEE’09 Proceedings of Second
President of Amity University, Dr. Ashok K Chauhan and Director International Conference on Computer and Electrical Engineering ,
AIIT, Amity University Dr. Sunil K Khatri for their keen interest in USA,Volume 01, pp. 308-312, 2009.
promoting research in the Amity University and have always be [4] Sally C. Brailsford , Chris N. Potts , Barbara M. Smith : Constraint
inspirational for achieving great heights. Satisfaction Problems: Algorithms and Applications, European Journal
of Operational Research 119 (1999) pp. 557-581, Elesvier.
[5] Konfrst, Z, "Parallel Genetic Algorithms: Advances, Computing Trends,
Applications and Perspectives," Parallel and Distributed Processing
Symposium, 2004. Proceedings. 18th International 26-30 April 2004
Page(s):162

View publication stats

Вам также может понравиться