VendingMachine usingTOC

You might also like

You are on page 1of 6

2015 17th UKSIM-AMSS International Conference on Modelling and Simulation

Automata Design with Time Complexity for Intelligent Vending Machine based on
Visual Automata Simulator

Vijey Thayananthan, Ashwag Alrehily and Ruqiah Fallatah


Computer Science Department,
Faculty of Computing and Information Technology,
King Abdul Aziz University, Jeddah 21589,
Saudi Arabia
thayananthan@live.co.uk, ashwagalrehily@yahoo.com and rfallatah0008@stu.kau.edu.sa

Abstract—Automata theory and design are core areas of most mobile features. Perhaps, we can extend these machines into
of the software developments which improves the efficiency of different services as well.
the vending machines used in all sectors including academic Some problems are computationally hard and others are
environments. We have studied and identified many problems easy because the computational complexity is dominating in
of vending machines which are convertible to intelligent
all designs, developments and implementations. In all these
approach without increasing complexity. In this research,
improving efficiency and complexity reduction are considered cases, the theories of computability and complexity are
using appropriate automata design. In order to solve these closely related. Handling of complexity in all automata
problems, we have employed efficient automata design and design problems requires a precise definition of appropriate
visual automata simulator which allows us to increases the computations used in the applications which include vending
efficiency of the vending machine. To verify our results, we machine. Reducibility and decidability in automata designs
tested our design with different word lengths. As early results, play the important role in reducing complexity [6-7].
we have simulated the final design with selected feature which Intelligent vending machines (IVM) provide a number of
adds intelligence to the existing automata design of vending facilities with advanced features. They are anti-theft, facial
machine. In the overall conclusion, we prove that intelligent
recognition etc. but they are controlled by the touch screen
feature can be added without increasing the complexity.
which increases the efficiency of steps used in IVM.
Keywords-automata theory; finite state machines; vending Applications of Deterministic Finite Automata (DFA) are
machine; complexity; visual automata simulator; communication protocol and microcontroller designs used
in electro-mechanical devices [8]. Intelligent approach to
I. INTRODUCTION design used in modern vending machines depends on the
efficient protocols and microcontrollers.
Alan Turing is the great scientist and he solved many The rest of the paper is organized as follows. Section II
problems in automata design. Cash dispensers, vending explains the quick literature review of basic and modern
machines and other self-servicing machines depend on the vending machines which use conventional and intelligent
automata design. Computational development and automata features. In section III, we provide necessary points about
simulator tools also play a significant role in the efficient the theory of automata design which is relevant to this
designs. These days, computer video games are also research. Section IV provides the steps of the algorithm
expecting significant changes which are not only in the which we employ in this research. Implementation and
design and development but also in the improvement of necessary results obtained from VASs are organized in
intelligent. These automata designs are implemented using section V. In section VI, overall conclusions are written
different simulators but we have considered visual automata based on the theoretical analysis and results.
simulator (VAS) which is a new tool for this design. Also,
it's compatibility allows us to integrate with other tools. II. LITERATURE REVIEW
Vending Machines are used to dispense various items Many researches have been investigated the architecture
which are cash withdrawal, purchasing tickets, collecting of the vending machines. A few of them are discussed here
quick foods etc [1-3]. The first commercial coin-operated as: Fauziah Zainuddin [9] proposes a vending machine for
machine was introduced in London and England used for serving food in appropriate way. Here, researcher used three
selling post cards. The vending machines are available to different features in his design they are user selection state,
which people are in working environments and other areas freezer state and steaming state.
such as public and private places. In future, vending In complexity theory, we classify computational
machines become mobile and intelligent approach because problems of vending machine design and increasing features
they are more accessible and practical than the ordinary coin according to their time complexity. In some designs, the
operating machines [4-5]. Further, these machines are very same language takes different time requirements during the
important for the medical services which need intelligent and processing. Here, design of the vending machines may be a

978-1-4799-8713-9/15 $31.00 © 2015 IEEE 159


DOI 10.1109/UKSim.2015.75
different approach. Space complexity of the vending controller changes from one state to several states.
machines shares many of the features. Here, the time Generally, NFA increases the efficiency and power saving
complexity depends on the features we add in our designs. during the operations. If time complexity is increased, we
Features based on intelligent approaches may be added need more power depended on the features based on
without increasing the complexities. automata design.
Mealy vending machine is basic approach used in oldest B. Time complexity
coin operating machines. Still, existing and conventional
Generally, length of the word used during the operation is
vending machines depend on Mealy approach. In this
considered for calculating the time complexity. According to
approach [10], output and input are dependants each other. [14], we define the nondeterministic time complexity class
Conventional vending machine used in this research is also
t (n) NT as analogous to the deterministic time complexity
based on Mealy approach. In most of the vending machines,
DFA is considered to describe the behavior of the features class t (n) T .
which depend on the nature of business and organization.
According to [10], multi-select vending machine is Definition: t (n) NT = {L|L is a language decided by a
proposed using Mealy approach. In this study, authors O(t(n)) time nondeterministic vending machine}.
observed the behavior of the design and implementation
used in the approach. Through this observation, time In our IVM design, the input to the algorithm is a
analysis is compared during the operations [11]. This study nondeterministic finite automaton M  ( K , , , s, F ) ; thus,
has helped us to continue our research which focuses on the
we must calculate its complexity as a function of the
time complexity.
cardinalities of K ,  and  .
According to the [12], IVMs are available but still
controlling complexity is the biggest problems. According to
the recent research, few important points were suggested to The best method is known for solving languages in NP
enhance the IVM. They are touch screen displays, cashless deterministically uses exponential time (eT). In other words,
system, telemetry system, voice recognition etc. we can prove that
In previous automata designs, many software tools are
employed to analyze the results related to the complexity and
necessary parameters which reduce the cost of the IVM.
NP  eT   T (2
k
nk
) (1)
Here, we have introduced the VAS which allows us to
k
simplify the programming procedures. Commercially, some In (1), string length is assumed as at most n when k nodes
existing designs based on automata theory are being are used in the design. The class NP is insensitive to the
developed using VAS as in [13]. choice of reasonable nondeterministic computational model
because all such models are polynomially equivalent.
III. AUTOMATA THEORY AND T IME COMPLEXITIES
We assume that randomized FSM of IVM design M has
Automata theory is used in many disciplines and M
applications based on mathematical models represented by time complexity Tc (n)
finite state machines (FSM) or automata. In this paper,
Tc (n)maxn  Tc ( z ) 
cashless system is considered as an example of intelligent M M
(2)
approach. Cashless system means that we are allowed to use z  
mobile phones and bank cards.
M
A. Definitions Using (2), we can calculate Tc (n) which, is the maximal
To express the DFA as a 5-tuple, the components are expected running time of M over all words of length n.
defined as follows:
1. K is the set of states (Saudi and other foreign
 should be within the range.
n
Hence, on any input word z
currencies. (SR, dollars, pounds, etc.) )
2.  is the alphabet or language When shorter strings are used during the transitions, the
3.  is the transition function, is described by the state time complexity decreases. It depends on the design of
diagram. features used in the vending machines. In IVM, operations
4. s is the start state of the features can be reduced using automata theory [15-
5. F is the set of accept states 16]. Basically, the time complexity depends on the upper
and lower bound of the word-lengths design which
In our design, FSA are classified as deterministic (DFA) influences with the number of steps used in the algorithms
and nondeterministic (NFA). In DFA, the controller can and processing.
change from one state to another state but controller should
not be used in more than one state at any time. In NFA,

160
IV. ALGORITHM DESCRIPTION AND PROPOSED DESIGN machine’s finite state diagram will visualize and simulated
After the design and analysis, we have developed using VAS. In this proposed design, VAS and its operations
following algorithms which could be applicable not only in take important roles in our time-complexity analysis.
the specific vending machine but also other developments Although vending machines already exist, analysis of time
such as games provided through mobile and wireless service complexity will improve the functionalities of future IVM.
providers. C. Methodology
A. Algorithm In this paper, we prefer to use VAS tool to describe the
The cashless is one of the example features used for design methodology of proposed vending machines which
making IVM. Necessary steps are given below. include IVM. Using our algorithm, the time complexity is
analyzed for different word lengths used in our approaches.
Input: user selection and desired currency ={K1, K2…} Although VAS is a helpful tool for simulating FSA, we have
used this tool for experiments which are comparisons of
Output: proposed vending machine which accepts (a) or
basic and intelligent features. In these two approaches,
rejects (r) string. average time complexity is calculated using selected
Initialize: initial state, count =0. features, counted word-lengths, steps, processing and other
1. User, select one book from the four available books parameters used in the automata theory.
2. If the user enters e then
3. Go to “select 1“state. (Language)
4. Else If user enters a then V. IMPLEMENTATION AND RESULTS
5. Go to “select 2“state. (Main category or field) The proposed vending machine is simulated using the
6. Else If user enters n then latest version of VAS tool which allows us to handle the
7. Go to “select 3“state. (Topic) intelligent feature. Each word used in the transition of FSM
8. Else If user enters a then represents the behavior of the conventional and proposed
9. Go to “select 4“state. (Specific) design with corresponding states and transitions. As soon as
10. Else the machine reaches accepting state, the IVM delivers the
11. Reject the message. book. In order to understand the processing, basic coin
12. End if operation is used in each transition of conventional vending
13. Repeat{ machine. In these operations, we can add this intelligent
14. If the user enters first total: feature "cashless payment" without changing main
15. Count=count + first total {c} architecture. In this design, states which have two circles, are
16. Go to “count” state and word length. accepting state.
17. Else user enters second total: A. Implementation of accepting operation
18. Count=count + second total {c}
The user select Arabic book and enter 10,10,10,10 and
19. Go to “count” state and word length.
ten respectively and table 1 shows this transition table for
20. End If
serving book using the book vending. Thus, the string is
21. } until (no money in the bank);
a11111b. The Final b inserted refer to the end of the
22. If count = book price then
operation; it is only used for explains the debug steps until
23. Accept (a) message with total word length.
accept state. Table I shows the transition states for accept
24. Else
operation; the user will implement the flowing transition in
25. Reject (r) the message with total word length.
order to receive the book he wants. In this processing, we
26. End If
observed time complexity with other existing software tools.
27. End
To analyze the time complexity, automata technique and
.
each operation used in the design studied with different
strings.
B. Description of vending machine
TABLE I. TRANSITION DETAILS FOR SERVING BOOK
Here, basic operation of vending machine is described with
necessary features. It is a multi-select books machine with Selected string a11111b
FSM based. It is improved to deliver books depending on the symbol Remaining string States
user selection for a specific type of available books, and then a 11111b [Select 2], accepting = false
touch the screen which shows the amount of money in Saudi 1 1111b [10SR], accepting = false
Riyal (SR) or other foreign currency. Cancel feature; that 111b
1 [20SR], accepting = false
means the customer can discard the ordering of product and
1 11b [30SR], accepting = false
end the buying operation. The user does not need to insert
the money which is equal to the price of the book he/she 1 1b [40SR], accepting = false
wants. This intelligent approach allows us to increase some 1 b [50SR], accepting = True
more intelligent features without increasing complexity. Our

161
For instance, four books and two Saudi Riyals (10 and As shown in figure 1, basic coin operation of vending
20) are considered to show this processing which needs machine can be built. In the conventional vending machine,
twenty states. Assume that the price of the Arabic book and basic features mentioned in [10] are used. The user can still
English book is the same. Thus; the transition from Select 2 select different operations which allow him/her to choose
goes to the same transition of select 1. So the state diagram either intelligent or conventional feature. Each case, word
only shows the 16 states excluding the five states of select 2. length should be considered carefully. Otherwise overall
The Initial State, when the machine is ready to perform time complexity will be increased.
the sale operation. Assume that the machine uses fixed In figure 1, the transition from the initial state (v0) to
length of the word for which selected abbreviation is used other states (v1, v2 and v3), which represents some behavior
during the sales. After the selection of book type, the user of Mealy vending machine. In this, there is no accepting or
has to insert the money which is the amount of the specific rejecting state, but one of the states should be assumed as an
book. In this case an Arabic book requires 50 SR. At the output state. In this example, q0, n and d are inputs, and c0,
first time, the user may insert 10SR and continue or user can c1, c2 and c3 are outputs. Letter "e" represents empty
use a single payment. transition.

Figure 1. Example of Mealy vending machine behaviors

the transition with number 1 (symbol for 10 SR.) and the


B. Implementation of rejecting operation
remaining amount will equal to 20 SR.
When intelligent feature is used, rejections operations
will be considered in different ways. But, we have
illustrated this operation through the conventional vending TABLE II. TRANSITION DETAILS FOR SERVING BOOK
machine. The example of rejecting scenario is the user Selected string n11c
select notebook and enters 10, 10 and cancel the order. symbol Remaining string States
Table II shows this transition table for serving note using
n 11c [Select 3], accepting = false
vending machine. Thus, the string is n11c.After the
1 1c [10SR], accepting = false
selection of book type, the user has to insert the money
1 c [20SR], accepting = false
amount of a specific book. In this case notebook requires
30SR. At the first time, the user has to insert 10SR. Using

162
Again time complexity is analyzed as in automat theory of using coins, we can use credit cards or mobile phones
and VAS. These existing designs encourage us to add the which link with the banks. In this paper, the specific
intelligent feature which not only provides the intelligent processing of IVM is not considered because we assume
action but also reduce the cost. The user still inserting that steps for the intelligent feature “cashless” are equal to
another 10 SR. and the reminder of the note price 30 will coin operation. Although steps are same in each case, word
equal to 10 SR. Figure 2 can be used to show the transition length which we use in these operations may be different.
of second 10 SR. Then the user decides to cancel the Each operation may have different processing which
operation; because of that the operation was rejected. The depends on the features. Overall, types of feature,
cancel operation accepted only when the user decides to operations, steps and processing are very important to
cancel the operation before inserting money. analyze the complexity. We assume that the bank pays the
final total through cashless payment method when state
C. Cashless operation of intelligent behavior
diagram reaches the accepting state.
As shown in figure 2, we have designed the IVM with
same number of states and transitions. In this design, instead

Figure 2. State diagram of IVM with a cashless feature

complexity depends on the number of iterations and steps


D. Results of Simulations we use in the automata design of IVM. Even though same
Our simulation takes string from the user; the string number of states we use in both coin operation and cashless
includes the selected book, money (all type of currencies), operation designs, language and word length of the
and cancels if user wants to cancel. The summation runs the corresponding operation may be different. These differences
string in the state diagram and as a result it accepts or rejects certainly affect the time complexity which we have
for the entered string, if the string is accepted the book analyzed using necessary graphs. Note that an automaton
delivered otherwise it will not deliver the book. Regarding with time complexity T(n) must have expected running time
the complexity, when we increase the features, a number of at most T(n) on any word of length n. In other words, a fast
states used in the IVM design should be increased but some randomized automaton must work fast also for words not in
cases, design may be possible without increasing states the solved language.
using automata theory. Here, the time complexity is From the results, we can prove that reduction of the time
calculated for each word length. When 100 bits are used complexity will increase processing speed because steps
used in our designs and simulations are minimized using
average time complexity almost 10. When more than 600
appropriate word lengths. Instead of using cash (coin),
bits are used average time complexity is between 60 and 70.
intelligent feature “cashless” will increase the safety and
As shown in figure 3, the time complexity is compared security. As reviewers advised, we should have covered
to both existing and proposed methods. Different word some more points such as experiments and proves on speed,
lengths are considered to analyze the time complexity of safety and security. Because of the page limitation, we will
both machines. In the conventional vending machine, the add necessary experiments and proves in our extended paper
time complexity is increased. existing method, The time very soon.

163
Time complexity of conventional vending machine Time complexity of intelligent vending machine
80 70
Existing Existing
Proposed Proposed
70 60

60 50
Complexity T(n)

Complexity T(n)
50 40

40 30

30 20

20 10

10 0
100 200 300 400 500 600 700 800 900 100 200 300 400 500 600 700 800 900
Lengths of words (n) Lengths of words (n)

Figure 3. Time complexity comparisons for conventional (left figure) and intelligent vending machine (right figure)

VI. CONCLUSIONS [6] Hopcroft, John E. and Jeffrey D. Ullman, "Introduction to Automata
Theory, Languages, and Computation", Reading, MA, Addison-
The design of vending machine based on automata theory Wesley, 1979.
is studied. We have identified few intelligent features which [7] Michael Sipser, "Introduction to the Theory of Computation",
are very useful and profitable because it not only minimizes Second Edition Massachusetts Institute of Technology, ISBN 0-534-
the cost and complexity but also it increases the processing 95097-3, 2006, USA
speed, safety and security. We studied the VAS and its [8] Qureshi, M., Aziz, A., Rasool, H., Ibrahim, M., Ghani, U. and Abbas,
features which monitor the time complexity dynamically. H, "Design and Implementation of Vending Machine using Verilog
HDL". 17, 2011.
Through these designs and implementations, we identified
[9] Fauziah Zainuddin, Norlin Mohd Ali, Roslina Mohd Sidek, Awanis
that VAS could be a reliable tool to improve the efficiency Romli, Nooryati Talib & Mohd. Izham Ibrahim, “Conceptual
and accuracy of intelligent features expected to integrate Modeling for Simulation: Steaming frozen Food Processing in
with future vending machines. In future work, we will have Vending Machine” International Conference on Computer Science
to analyze the time complexity of other features which are and Information Technology,University Malaysia Pahang, pp.145-
applicable to future IVM. 149, 2009.
[10] Varkey, M. and Sunny, J. "Design and Implementation of Multi
REFERENCES Select Smart Vending Machine". International Journal of Computer
Networks and Wireless Communications (IJCNWC), ISSN: 2250-
[1] Zhang Wen & Zhang Xin Long, “Design and Implementation of 3501, 2014.
automatic vending machine Based on the short massage payment”
[11] Ana Monga, Balwinder Singh. "Finite State Machine based Vending
International Conference on Information and Communications
Machine Controller with Auto-Billing Features. International Journal
technology in Electrical Sciences, Neijiang, Sichuan, China.pp.978-
of VLSI design & Communication Systems (VLSICS) Vol.3, No.2,
981, 2010.
2012.
[2] B. Caulfield & M.O Mahony, “Passenger Requirements of a Public
[12] Frost & Sullivan*, “Assessment of the Intelligent Vending Machines
Transport Ticketing System” Proceedings of the 8th International
Market, November 2011.
IEEE Conference on Intelligent Transportation Systems Vienna,
Austria, pp-32-37, 2005. [13] Jean Bovet, “visual automata simulator tool”, laboratory manual,
USA.
[3] Biplab Roy & Biswarup Mukherjee “Design of Coffee Vending
Machine using Single Electron Devices” Proceedings of 2010 [14] Cynthia Dwork and Larry J. Stockmeyer. A time complexity gap for
International Symposium on Electronic System Design. Pp. 38-43, twoway probabilistic fnite-state automata. SIAM Journal on
2010. Computing, 19(6):1011-1123, 1990.
[4] M.Bhuvaneswari, S.Sukhumar, N.Divya, S.Kalpanadevi, [15] Dash, T. and Nayak, T. "Quantum Finite Automata: a Language
N.SuthanthiraVanitha, "Embedded System Based Automatic Ticket Acceptor Model", International Journal of Advanced Research in
Vending Machine for Modern Transport System", International Computer Science and Software Engineering, Volume 2, Issue 9,
Journal of Advanced Research in Computer and Communication September 2012.
Engineering Vol. 2, Issue 11, 2013. [16] John E. Hopcroft, Rajeev Motwani, Jeffrey D. Ullman, “Introduction
[5] Sakshi Sharma, Ana Monga, "Implementation of Reverse Vending to Automata Theory Languages and Computation”. Ch-1, 27-29, 3rd
Machine Based on FPGA", International Journal of Emerging Edition Cornell University, Stanford University, California, 2001,
Technologies in Computational and Applied Sciences (IJETCAS), USA.
2011.

164

You might also like