Chapter-6 (Sania Bhatti-MA Hashmani-Naheed Shaikh).pmd The Specification of an Expert System for Building Bylaws Compliance SANIA BHATTI*, MANZOOR AHMED HASHMANI**, AND NAHEED SHAIKH*** RECEIVED ON 25.05.201 ACCEPTED ON 01.12.2011 ABSTRACT An Expert System is a computer program that simulates the human intelligence and behaviour in specific and limited domains. It is used to solve problems with tricks, shortcuts and heuristics i.e. rules of thumb. Checking a Plan (Map) to verify its compliance with building bylaws is a complex task mainly due to various rules and the exceptions to those rules. Humans are prone to make errors in such situations. Due to the problems faced by Building Control Department, HDA ( Hyderabad Development Authority) there is a strong need to develop a computerized system. In this research we have developed a prototype named as ESBBC (Expert System for Building Bylaws Compliance) for HDA that can help in their building plan checking system. The proposed solution is merging three frameworks, i.e. Java an OOP (Object Oriented Programming) language, Prolog- a rule based language and MS Access- for database. The solution is fulfilling the three main requirements of the HDA, i.e. (1) Determination of whether a particular plan is in compliance with predefined building bylaws or not. (2) Offering search facility. (3) Maintaining records of plans which are entered for compliance checking. We have checked plans of 20 properties according to HDA building regulations using ESBBC and presented their results. The results show that ESBBC has capability to identify errors made by humans. Key Words: Expert System, Plan, Bylaws, Java, Prolog. * Assistant Professor, Department of Software Engineering, Mehran University of Engineering & Technology, Jamshoro. * * Professor, Iqra University Main Campus, Karachi. * * * Assistant Professor, Department of Architecture, Mehran University of Engineering & Technology, Jamshoro. 1. INTRODUCTION based on different parameters like locality, plot size etc. After development these plans are submitted to Building Control authorities for approval. The Building Control authorities in Pakistan are still using the manual system for plan checking. There are many shortcomings of this system such as, many persons are involved, many Mehran University Research Journal of Engineering & Technology, Volume 31, No. 2, April, 2012 [ISSN 0254-7821] 2 4 3 When an architect develops design of abuilding called "Plan" then he has to followcertain rules, which are pre defined by Building Control authorities. Preparation of certain rules and regulations for controlling development of areas is known as "Building bylaws". These rules are defined Mehran University Research Journal of Engineering & Technology, Volume 31, No. 2, April, 2012 [ISSN 0254-7821] 2 4 4 The Specification of an Expert System for Building Bylaws Compliance corrective steps are involved in case of any mistake, more prone to errors, more time consumption in record maintenance and searching previous records. To overcome these problems, there is a need to develop computerized system which can solve the problems happening due to human errors. In this work we have developed ESBBC in which at the back end rule based inference engine is working which is based on knowledge base of rules. Modelling of rules as data rather than as code is one the challenges addressed in this work. Another challenge is the provision of hybrid approach which combines the strengths of expert system and object oriented programming language. The user interface developed in object oriented programming language allows control of rule based engine and data base. ESBBC is based on building regulations for zonal plan HDA scheme 1, 2 and 3. The dimensions of maps are entered as parameters and are checked by the rule based inference engine. In case of violation of any rule, appropriate messages are given by the program. The interface of ESBBC is flexible to take inputs. It is also maintaining the records of plans being entered and is able to search the particular plan. This section presents an overview of the existing system, its short comings and why a computerized system is needed. Section 2 discusses rule based system and its implementation in different applications. Section 3 states the proposed solution, its prerequisites and advantages. In Section 4, the output of the proposed solution is discussed along with comparison with existing system to show its reliability. In Section 5 conclusion is presented. 1.1 Analysis of Existing System HDA [1] was created with the enactment of Sindh Act XIII in the year 1976 with its preamble for development, improvement and beautification of urban areas of Hyderabad division. However, the working area of HDA was limited to only 200 square miles around Hyderabad city only, including a portion of Dadu District out of Hyderabad Division. Following steps are taken by HDA for authorization of residential plans: (i) Building plans in prescribed file containing Original Tracing, 4 copies (Ammonia) along with allied documents is submitted at reception. (ii) Issuance of advance scrutiny challan by bill clerk to the department is done. (iii) Then challan is deposited in a bank. (iv) After payment of scrutiny fees to the building clerk, file is submitted to registrar of concerned ward/Area. (v) File is sent to draughtsman for report. (vi) Sub Inspector building visits site for verification and does scrutiny of building plan. (vii) Then Building plan is passed to assistant director for approval. (viii) Further permission letter of building plan is prepared and send to the sub inspector and assistant director for signature. (ix) Finally building plan is released. 1.2 Results of Unnecessary Delay in Approval The permission to occupy the building is granted only after the verification of the fact that it is constructed as per detail of the approved plan. Procedures laid out by the authority should be easy, simple and should not lead to unnecessary delay in granting the permission for the construction of building. The unnecessary delay in approval process may lead to the following undesirable consequences: (i) Increase in housing shortage that will result in increase of house rents. Mehran University Research Journal of Engineering & Technology, Volume 31, No. 2, April, 2012 [ISSN 0254-7821] 2 4 5 The Specification of an Expert System for Building Bylaws Compliance (ii) Formation of more slums that will result in more financial burden on the local authority for their removal or improvement. (iii) The enthusiasm of the owner who wants to construct the building quickly may slow down because of changes of circumstances with the passage of time. (iv) The local authority may also suffer loss in revenue from various taxes such as water tax, sanitation tax, betterment charges etc. (v) The open space remains idle for long time resulting in under hardship and loss of revenue to the landowner. (vi) Considerable depression in construction industry as a whole. 1.3 Significance of Developing a Computerized System Due to the problems faced by building control authorities there is firm need to develop a computerized system to check building bylaws. The following benefits can be obtained from a computerized system: (i) It will take less time to check a building plan as compared to human experts. (ii) Instead of involving many experts in checking process only one person will be sufficient. (iii) Proper checking can be done and in case of any mistake proper guidance will be given by the system. (iv) It will be simple to maintain record of all plans. (v) Searching of a particular record will become straightforward. 2. RULE BASED SYSTEM AND ITS IMPLEMENTATIONS A rule Based system is an expert system based on a set of rules that a human expert would follow in diagnosing a problem. It is also known as "production system" or "expert system" [2]. Rules represent possible actions which are taken when specified conditions hold on items in the working memory. In a rule based system, the separation of knowledge from control further simplifies development of expert systems by enabling an iterative development process where the engineer acquires, implements and tests individual rules. Rule-based systems are one of the most successful AI paradigms. They are used for synthesis type systems and diagnostic or classification type systems [3]. In this section we discuss some of the implementations of rule based system. A client server architecture consisting of Java based client and Prolog [4-5] based server is discussed in [6]. This is an interesting development of internet Prolog applications which are using Java as front end. It presents application architecture along with image search application and an expert system application for diagnosing car faults. The function of image search application is to search images for remote client depending on the input observations. This application consists of a static server component and a mobile client component. The function of expert system application is to accept a set of observations as input and provide the diagnosis as the output. Using the architecture presented in this paper, various Prolog applications could be ported to the internet. An interesting example to automatically develop web- based expert systems from XML parser which consist of knowledge base is discussed in [7]. The domain specific XML parser changes the knowledge base into Prolog code. A case study of university course rules is presented which relies on XML data definition file of common rules related with courses. Web pages dynamically execute Prolog code to provide responses to the user queries. The Prolog predicates for detecting patterns and antipatterns are Mehran University Research Journal of Engineering & Technology, Volume 31, No. 2, April, 2012 [ISSN 0254-7821] 2 4 6 The Specification of an Expert System for Building Bylaws Compliance defined in [8]. The detection methods are proposed for both structural and behavioural features of patterns and antipatterns. Roventa, et. al. [9] a medical expert system is designed which gives help to a medical expert in making appropriate diagnosis of a patient. A knowledge base of twenty seven kidney diseases from nine different categories is developed based on symptoms of kidney diseases. Expert system diagnoses a particular disease using the knowledge of symptoms and laboratory tests. The system is incomplete in the sense that limited number of kidney diseases is considered. A similar expert system application for identification of dolphin's species in Malaysian fisheries using PROLOG is discussed in [10]. A rule based expert system for electrical distribution network steady state is discussed in [11]. The developed model is providing the facility to take real time decisions during system operation. The use of Prolog for building robust commercial applications is discussed in [12]. It has been successfully implemented in environmental system to predict weather, analyze water supplies and heavyweight applications. Prolog has been applied by Youbet.com in the advancement of its ebusiness structure [3]. Youbet.com provides detailed information about four different vendors to horse racing customers. It uses a Java based application server which is integrated with Prolog rule base engine. Another applicability of Prolog using RDF library for semantic web applications is discussed in [13]. 3. EXPERT SYSTEM FOR CHECKING BUILDING BYLAWS COMPLIANCE The proposed solution is developed using the combination of an Object Oriented Language Java [14] and a Rule Based Language Prolog [15-18]. Following are the major components of the system as shown in Fig. 1. (i) User Interface Subsystem (JSwing) (ii) Plan Rule Based Engine (Prolog) (iii) Plan Database Management System The ESBBC supports the bylaws collected from HDA for residential buildings of following sizes: (i) Plot sizes up to 120 Square Yards (ii) Plot sizes up to 150 Square Yards (iii) Plot sizes up to 200 Square Yards (iv) Plot sizes up to 240 Square Yards FIG. 1. SYSTEM DIAGRAM OF ESBBC Mehran University Research Journal of Engineering & Technology, Volume 31, No. 2, April, 2012 [ISSN 0254-7821] 2 4 7 The Specification of an Expert System for Building Bylaws Compliance (v) Plot sizes up to 400 Square Yards (vi) Plot sizes up to 600 and above Square Yards The ESBBC is provides following options as shown in Fig. 2. (i) Checking of plan (ii) Saving of record (iii) Searching of property. 3.1 Prerequisites ESBBC requires Windows System with JDK1.3 or higher, SICSTUS Prolog and Jasper package to operate. If Java is used as parent application then there are a couple of things that need to be taken care of. The first is to specify the correct class path so that Java can find the jasper classes (SICStus, SPTerm, and so on). This is done by specifying the pathname of the file 'jasper.jar'. The second is to specify where Java should find the Jasper native library ('libspnative.so' or 'spnative.dll'), which the SICStus class loads into the JVM by invoking the method System.loadLibrary ("spnative"). Under Windows, Java must be able to find 'spnative.dll' through the PATH environment variable. 3.2 Java Interfacing with Prolog The low-level interface uses the JNI (Java Native Interface) to call Prolog from Java. The JNI is a native interface standard developed by Sun Microsystems. It permits Java programmers to integrate native code (currently C and C++, Prolog) into their Java applications by loading proper library. Calling Prolog from Java is done by using the Java package se.sics.jasper. This package contains a set of Java classes, which can be used to create and manipulate terms, ask queries and request one or more solutions. Jasper is a bi- directional interface between programs written in Java and programs written in Prolog. The Java-side of the interface consists of a Java package (jasper) containing classes representing the SICStus emulator [19]. The following example shows how one bylaw is checked from 'Bylws.pl' and response is given. FIG. 2. USE CASE MODEL OF ESBBC Mehran University Research Journal of Engineering & Technology, Volume 31, No. 2, April, 2012 [ISSN 0254-7821] 2 4 8 The Specification of an Expert System for Building Bylaws Compliance import se.sics.jasper.*; import java.io.*; public class SimpleA { Static { System.loadLibrary("spnative"); } public static void main(String argv[]) throws Exception { SICStus sp; SPPredicate pred; SPTerm way; SPQuery query; int i; sp = new SICStus(argv,null); sp.load("e:/jdk1.4/bin/Bylaws.pl"); pred = new SPPredicate(sp, "covered_at_ground", 2, ""); way = new SPTerm(sp).putVariable(); query = sp.Query(pred, new SPTerm(way) ); System.out.println(way.toString()); } } 3.3 Implementation The class ExpertSystem works as the Control manager. The objects of following classes are used in ExpertSystem class. Build Complaint Plan WelcomePanel SearchForm AboutDialog Fig. 3 shows the plan entry form of the ESBBC in which first details of the plan are entered which are checked against defined bylaws. The form also provides the option to modify previous plan, delete non required plan and search the required plan. 3.4 Advantages (i) Although both database programs and expert systems feature the retrieval of stored information, a database program cannot draw conclusions from facts in its domain while an expert system containing both declarative and procedural knowledge can emulate the behaviour of human reasoning. Therefore the use of Prolog for developing bylaws is beneficial. (ii) Proposed solution is secure, robust and portable due to Java. (iii) Logic based languages are able to represent the real world more accurately. (iv) Prolog is able to derive new rules from the existing rules contained within the knowledge base. FIG. 3. PLAN INTERFACE Mehran University Research Journal of Engineering & Technology, Volume 31, No. 2, April, 2012 [ISSN 0254-7821] 2 4 9 The Specification of an Expert System for Building Bylaws Compliance (v) Jasper is a bi-directional interface between Java and SICStus Prolog providing complete functionality to deal with Prolog predicates from Java. 4. RESULTS AND DISCUSSION In this section bylaws of few submission drawings are analysed via ESBBC. To confirm the reliability of ESBBC, submission drawings are also checked via manual system and finally both results are compared. 4.1 Analysis of Submission Drawings Table 1 presents the summary of results after checking the submission drawings using ESBBC. It is evident from Table 1 and Fig. 4 that only 15% of the submission drawings are violating the building regulations which are defined by HDA. 4.2 Discussion After the analysis of results which are presented in Section 4.1, it is identified that out of 20 properties 3 properties are violating the bylaws defined by HDA. It is really necessary to evaluate the results in order to identify which rule is violated. After analysis of results, it identified that following rules are violated by different properties: It is revealed from Table 2 that out of 3 properties, 1 property is violating the bylaw related to the compulsory open space which must be left at the rear and 2 properties are violating the bylaw related to the compulsory open space which must be left at the first floor. These rules are necessary to follow because in case of disobedience of these bylaws, shadowing problems are created. TABLE 1. NUMBER OF BYLAWS VIOLATED BY DIFFERENT PROPERTIES No. Property Area Covered Address No. of Total No. No. (SYD) Violated Bylaws 1 . H. No. 62 1 2 0 62/D Unit-10 Latifabad 0 4 2 . H. No. 63 1 2 0 63/C Unit-7 Latifabad 0 4 3 . H. No. 52 1 2 0 52/B Unit-3 Latifabad 0 4 4 . H. No. 44 1 2 0 44/A Unit-2 Latifabad 0 4 5 . H. No. 36 1 5 0 36/A Unit-1 Latifabad 1 4 6 . H. No. 76 1 5 0 76/B Unit-6 Latifabad 0 4 7 . B. No. 88 1 5 0 88/A Unit-5 Latifabad 0 4 8 . B. No. 121 1 5 0 121/D Unit-8 Latifabad 0 4 9 . B. No. 57 2 0 0 57/B Unit-2 Latifabad 0 6 1 0 . B. No. 28 2 0 0 28/B Unit-1 Latifabad 0 6 1 1 . B. No. 123 2 0 0 123/D Unit-7 Latifabad 0 6 1 2 . B. No. 129 2 0 0 129/D Unit-9 Latifabad 0 6 1 3 . B. No. 96 2 4 0 96/A Unit-1 Latifabad 1 6 1 4 . B. No. 112 2 4 0 112/D Unit-11 Latifabad 0 6 1 5 . B. No. 133 2 4 0 133/C Unit-4 Latifabad 0 6 1 6 . B. No. 149 2 4 0 149/A Unit-2 Latifabad 0 6 1 7 . B. No. 192 4 0 0 192/C Unit-2 Latifabad 0 6 1 8 . B. No. 152 4 0 0 153/D Unit-4 Latifabad 1 6 1 9 . B. No. 75 4 0 0 75/A Unit-1 Latifabad 0 6 2 0 . B. No. 93 4 0 0 93/B Unit-3 Latifabad 0 6 Mehran University Research Journal of Engineering & Technology, Volume 31, No. 2, April, 2012 [ISSN 0254-7821] 2 5 0 The Specification of an Expert System for Building Bylaws Compliance 4.3 Comparison To demonstrate that ESBBC is giving reliable results, a comparison of manual system and ESBBC is performed. Manual system is chosen for comparison because of the unavailability of any other computerized system for HDA. The plans which are being checked by ESBBC in Section 4.1 are checked through manual system. Table 3 shows the comparison of manual checking and ESBBC. It is evident from the table that out of 20 plans ESBBC is able to identify that 15% of properties are violating rules and manual system is identifying that 10% of the properties are violating rules. In order to verify which results are correct, manual verification is performed again. As the result of that; it has been proved that the results given by ESBBC are correct which confirms the reliability of ESBBC. 5. CONCLUSIONS In this paper, ESBBC is proposed after analysis of current building control department system. This is first time that a solution based on expert system has been presented for HDA. The proposed solution presents clear idea about the working of building control department and makes it easier to understand for non-professional persons. It shows how HDA functionality can be best implemented using expert system. The proposed solution is able to verify building compliance of plans by implementing rules in Prolog and checking them from Java. It is maintaining records of plans by implementing database and providing their access from Java. Further, it is providing the facility to search a particular plan by entering owner name. Moreover, we have also analysed submission drawing of twenty properties and presented results. The results show that 15% of the submission drawings are violating the rules defined by HDA because of error prone nature of humans. Currently the solution is based on the implementation of bylaws for zonal plan HDA scheme 1, 2 and 3. The bylaws of other wards can also be implemented in the future extension. TABLE 2. BYLAWS VIOLATED BY DIFFERENT PROPERTIES Property No. Area Covered (SYD) Address No. of Bylaws Violated Bylaw Violated H. No. 36 1 5 0 36/A Unit-1 Latifabad 1 5 feet compulsory space shall be left open at the rear B. No. 96 2 4 0 96/A Unit-1 Latifabad 1 Compulsory open space on first floor 50% B. No. 152 4 0 0 153/D Unit-4 Latifabad 1 Compulsory open space on first floor 50% FIG. 4. NUMBER OF BYLAWS VIOLATED BY DIFFERENT PROPERTIES TABLE 3. COMPARISON OF ESBBC AND MANUAL SYSTEM Property No. Results of ESBBC Results of Manual System No. of Bylaws Violated H. No. 36 1 0 B. No. 96 1 1 B. No. 152 1 0 Mehran University Research Journal of Engineering & Technology, Volume 31, No. 2, April, 2012 [ISSN 0254-7821] 2 5 1 The Specification of an Expert System for Building Bylaws Compliance ACKNOWLEDGEMENTS The authors would like to thank Mehran University of Engineering & Technology, Jamshoro, Pakistan, for providing required resources to complete this project. Authors also appreciate the guidance and support of Engr. Mohsin Ali Memon, Lecturer, Department of Software Engineering, Mehran University of Engineering & Technology, Jamshoro. REFERENCES [1] Information Technology Cell, WASA, HDA, "Hyderabad Development Authority", [Accessed December, 2010] Available from: http://hda-wasa.com/ [2] Engelmore, R.S., and Feigenbaum, E., "Expert System and Artificial Intelligence", [Accessed November, 2010] Available from: http://www.wtec.org/loyola/kb/ c1_s1.htm. [3] Tung, D., "Practical Application of Prolog to eBusiness: A Racing Case Study", PC AI Magazine, April 2001, [Accessed December, 2010] Available from: http:// www.amzi.com/articles/youbet.htm [4] Brakto, I., "Prolog Programming for Artificial Intelligence", Addison Wesley, 2000. [5] Krzysztof, R.A., "From Logic Programming to Prolog", Prentice-Hall, 1997. [6] El-Beltagy, S.R., Rafea, M., and Rafea, A., "Practical Development of Internet Prolog Applications using Java Front End", 2nd International Workshop on Logic Programming Tools for Internet Applications in Conjunction with ICLP'97, July, 1997. [7] Dunstan, N., "Generating Domain-Specific Web-Based Expert Systems", Expert Systems with Applications, Volume 35, pp. 686-690, 2008. [8] Stoianov, A., and Sora, I., "Detecting Patterns and Antipatterns in Software Using Prolog Rules", Proceedings of International Joint Conference on Computational Cybernetics and Technical Informatics, pp. 253-258, 2010. [9] Roventa, E., and Rosu, G., "The Diagnosis of Some Kidney Diseases in a Small Prolog Expert System", IEEE Proceedings of Third International Workshop on Soft Computing Applications, pp. 219-224, 2009. [10] Mohamad, R., Daut, N., Barukang, L., and Jaaman, S.A., "Development of Expert System for Identifying Dolphin's Species in Malaysian Fisheries Using PROLOG", International Symposium on Information Technology (ITSim), Kuala Lumpur, Malaysia, 26-29 August, 2008. [11] Borlea, I., Vuc, G., Jigoria-Oprea, D., Kilyeni, A., Barbulescu, C., and Slavici, T., "A Rule-Based Expert System for Steady State Diagnosis of Electrical Distribution Networks", IEEE Proceedings of 15th Mediterranean Electrotechnical Conference, pp. 142-147, 2010. [12] Roth, A.I., "The Practical Application of Prolog", December 10, 2002, [Accessed December, 2010] Available from: http://drdobbs.com/high-performance- computing/184405220. [13] Wielemaker, J., Hildebrand, M., and Ossenbruggen, J.V., "Prolog as the Fundament for Applications on the Semantic Web", Second International workshop of Logic Programming to the Web, Semantic Web and Semantic Web Services, ALPSWS 2007. [14] Oracle, "Java Native Interface", [Accessed November, 2010] Available from: http://java.sun.com/j2se/1.4.2/ docs/guide/jni/ [15] Carlsson, M., and Mildner, P., "Sicstus Prolog-the First 25 Years", Theory and Practice of Logic Programming, 2010. Mehran University Research Journal of Engineering & Technology, Volume 31, No. 2, April, 2012 [ISSN 0254-7821] 2 5 2 The Specification of an Expert System for Building Bylaws Compliance [16] Agren, M., "Tracing and Explaining the Execution of CLP (FD) Programs in SICStus Prolog", Master's Thesis, Uppsala University, 2002. [17] Gupta, G., Pontelli, E., Ali, K., Carlsson, M., and Hermenegildo, M., "Parallel Execution of Prolog Programs", ACM Transaction on Programming Languages and Systems, Volume 23, No. 4, pp. 1-13, 2001. [18] Intelligent Systems Laboratory, Swedish Institute of Computer Science, "Sicstus Prolog", [Accessed November, 2010] Available from: http://www.sics.se/isl/ sicstuswww/site/index.html [19] Intelligent Systems Laboratory, Swedish Institute of Computer Science, "Mixing Java and Prolog", October, 1998 [Accessed December, 2010] Available from: http:/ /www.sics.se/sicstus/docs/3.7.1/html/sicstus_12.html