id
stringlengths
40
40
text
stringlengths
9
86.7k
metadata
stringlengths
3k
16.2k
source
stringclasses
1 value
added
stringdate
2024-11-21 00:00:00
2024-12-12 00:00:00
created
stringdate
2024-11-21 00:00:00
2024-12-12 00:00:00
fc4bf6bec3f849f6db9e9516d4f5617f0ee6a6c1
Web Application Security - Layers of Protection by William Fredholm January 26, 2003 GIAC Security Essentials Certification (GSEC) Practical Assignment – Version 1.4b Option 1 – Research on Topics in Information Security Abstract This paper reviews some of the large number of resources available for creating secure Web applications. These resources range from the security features of the development and database environments used, to automated tools evaluating an existing Web application, to Web sites dedicated to all facets of Web application security. Web application security is an extremely complex topic and by making one single mistake an otherwise secure application may be opened up to uninvited guests. By using the different resources available the risk borne by applications can be reduced to an acceptable level. In addition, some risk can be avoided at the very beginning of the project life cycle when the requirements for the system are defined. Resources on the Internet - OWASP The Open Web Application Security Project (OWASP) is a Web site devoted to Web application security [19]. According to the About Us section, the OWASP site strives to be a location to learn and share information about Web application security. The site has several different sub sections. Web application security now also has its own top-10 list. The OWASP The Ten Most Critical Web Application Security Vulnerabilities paper [12] details not only a name and a short description of 10 common vulnerabilities, but it also provides more extensive explanations on what the vulnerability is, what type of systems that are affected, how to test for it and remedies. Also included are references to other material in relation to each vulnerability. A second document published at the site is titled A Guide to Building Secure Web Applications [4]. This is a longer document explores topics ranging from the definition of a Web application to descriptions and security implications of the many technical elements involved in Web applications and the HTTP protocol. One section of the site is focused on testing. While no complete document has been published on the site at this point, a draft table of contents indicates that a comprehensive document is in the works. The project is publishing a Web application vulnerability scanner named Web Scarab. The tool is described as a spider that will crawl a site to find potential vulnerabilities and generate tests to evaluate the potential vulnerabilities. The tool can also work as a proxy in manual testing mode. A “pre-beta 3” version of the tool was released in December of 2002, and the source code for the tool can be downloaded from SourceForge.net [20]. WebGoat is an application intended to be used as a learning tool for Web application security concepts. WebGoat includes lessons for vulnerabilities and it allows a user to try to exploit the vulnerabilities after reading about them. The OWASP site also states that future releases will include a benchmarking feature for Web application vulnerability scanners. WebGoat can be downloaded from SourceForge.net [20]. Other projects at different stages of completion include: VulnXML, a project to standardize the descriptions of Web application vulnerabilities so that checks can be developed in any Web application vulnerability scanner tool that understands this common format. Application Security Attack Components (ASAC), a project focusing on creating a common set of definitions that can be used to describe vulnerabilities. This would remove ambiguity when describing and modeling more complex vulnerabilities. Filters, which is a project to assist Web developers in using secure practices. CodeSeeker, a firewall and/or IDS at the application level. Using rules, it examines HTTP requests to block and/or report on malicious traffic. CodeSeeker is installed on the Web server and examines traffic after any SSL traffic has been decrypted. As seen above, the OWASP site has numerous projects in different realms of Web application security. Many of the projects are still in development stages, but a lot of information is provided already from the two papers published at the site. Security Provided by Development Environments The development environment in use provides many different security features. One problem for developers is that different environments provide different features. The security features are not automatic, if they are not properly used and coded into the application they will not provide any protection. What security features in the development environment do provide is abstraction, the developer does not need to implement all security features from scratch and the implementation details are hidden. Below are highlights of some security features provided by the Java and .NET Web development environments and that are commonly required by any Web application. In Java, several security features are available for the developer for example functions for cryptography and access control (permissions). Java (JDK 1.2) defines a security model where Java code is subject to a security policy that dictates what permissions a caller executing some code has on different system resources [5]. Java Web Services also has many built in security features [3]. Security can be defined as an application is deployed (called declarative security) or more granular in the Java program (called programmatic security). The access control mechanism includes several different concepts. Users are individuals that have been authenticated by the run time environment. Groups are sets of users, and Roles (security roles) are permissions to access some resource. Further, security constraints are specified to protect parts of the Web application. The .NET environment also includes many security features [9] starting with IIS (the Web server used in the .NET environment) using regular Windows file permissions. IIS must have the proper permissions to access the files a user requests via their browser. Access is either granted based on specific login credentials provided by the user, but will more often for Web applications be based on the access right of a standard account used by IIS for all anonymous access (access without specific user Windows credentials). Because of the need for anonymous access (otherwise, separate Widows accounts has to be created for each user) the usefulness of the built in Windows file permissions will be limited for Web applications. .NET provides other security features to secure a Web application. Access can be granted or denied for URLs based on the user, role or verb (type of access being requested, GET or POST). This type of authorization can be defined for the complete application or on individual sub directories and it is set up using configuration files. This is still a rather coarse method, as it defines access based on the applications directory structure and not based on the data in the application (i.e. if you can access the “ViewBankAccount.aspx” page, you can view any bank account). Role based security functions allow a .NET application fine granular access control based on the user and the user's role. This type of access control must be coded into the application by the developer. .NET also provides a set of encryption routines. Both the Java and the .NET environments provide a rich set of comparable security features [6]. The security features are extensive and flexible but complex. It would be rather easy to make mistakes, either locking out sections of the application that should be accessible or opening up parts that should be locked down. The first case will soon be noted as users start to point this out (hopefully before production), while the second case may not be discovered at all until it is exploited by a malicious user. Security Provided by the DBMS The database system itself can provide a high level of security, if used properly. The DBMS can, for example, provide granular access control for and auditing, but the DBMS must also be maintained with patches and audit logs must be reviewed in order for the information to be of use [18]. While the DBMS can limit access to data in several different ways on a user-by-user basis, one common problem in a Web application is that the end user does not actually access the database using his or her own account. Instead, the Web application often uses a service or functional account that all database access is conducted through. The Web application acts as a proxy between the user and the DBMS. In this case, many of the more granular access control features of the DBMS are bypassed and the access control now becomes the burden of the Web application. The worst-case scenario is when a Web application uses a high power account, such as 'sa' for a SQL Server system. By default, 'sa' can perform basically any function within SQL Server and the account can access any data. This in turn means that if the Web application has a vulnerability, maybe a SQL injection problem, the potential damage is enormous. Anything from data being stolen and tables being dropped to compromise of the DBMS host computer. Another interesting scenario is when an older legacy application is "Web enabled" by deploying a Web application front-end to the system. In this case, a system that was perfectly secure when accessed via terminal or custom client software may be compromised because the Web application now uses an account that has access to more of the data than the individual user originally had. If the Web application is not secure, the legacy application is no longer secure. Using an account like 'sa' is obviously not a good idea. Instead one or more specific accounts should be created for the Web application to use in connecting to the DBMS. Then, follow the recommendations in limiting access control only to data that is required by the accounts [18]. In this case, all data and each stored procedure in use by the Web application must be available to the account or accounts, but nothing else. The setup of this scenario is a lot more complex compared to just allowing the Web application to access anything, but the level of risk is also reduced substantially. Tools to Test Web Application Security One method to ensure that a Web application is safe is to test it from a Web browser's perspective. Testing for functionality is usually a standard phase of the development lifecycle, but testing can also be focused on security issues. This testing is conducted by sending HTTP requests from a client to the application and observing the responses. Tools are now available to assist in this type of testing. A recent article in the Information Security magazine [22] evaluated two of these tools, AppScan by Sanctum [1] and WebInspect by SPI Dynamics [21]. The conclusion of the evaluation seems to be that the tools pinpoint many types of vulnerabilities, but that there is still room for improvement with both performance, false positives and false negatives. In general, Web application vulnerability scanner works in two main stages. First, the tool crawls the Web site (automatic and/or manual) following URLs and submitting forms. The second stage is the assessment stage, where the tool generates a large number of specially crafted HTTP requests. The requests are either based on manipulating information gathered during the crawl stage (testing for issues like cross site scripting and SQL injection) or they are standard requests known to exploit vulnerabilities in Web server software (such as appending a special character at the end of a URL forcing the Web server to return source code instead of HTML). The first type of assessment requests is usually referred to as testing for "unknown vulnerabilities" while the second type is referred to as testing for "known vulnerabilities". Tools can be an excellent companion to the experienced auditor. However, in the wrong hands, results from any type of testing tool can also give a false sense of security. In addition to running the tool, a good evaluation must include the use of a pair of critical eyes. What does it mean that the report from the tool came back "clean"? Does it mean we are secure or does it mean that the tool was not used properly? Some issues may never be completely identified by a tool and total automation in this area may never be obtained, unless the tools can start making use of additional business related information. Consider the following example: - A user provides a login ID and password to log on to a Web application. The users login session is maintained using cookies while it is the initial login ID that identifies what resources the user can access. Perhaps a list of specific bank accounts. - The application includes the bank account number currently being accessed on the Web page as a parameter in some way (a hidden form field, a URL parameter, a cookie etc.). - In this case, if the user changes the bank account number by manipulating the parameter, the application displays the information for that bank account, no matter if it is one of the accounts on the user's list or not. - The application is not verifying that the user should have access to the selected bank account. This brief example does not reveal anything new when it comes to Web application security (trivial parameter manipulation), however the question here is how would an automated tool assessing the application strictly from a Web browser's perspective ever be able to tell that the second account is not owned by the user? The information sent back to the browser (or the tool testing the application) looks just like perfect HTML code. No errors were produced and nothing unusual was returned. The problem here is that the application violates a business rule. As long as the tool does not know about business rules, it cannot determine that this was an error. There are of course many options that can be suggested to allow the tool to actually determine the problem. For example, if the owner of the account is in some way included as a hidden field on the Web page the test tool could verify that the owner field does not change, but this again requires some knowledge about business rules. If the tool always flags a change in the owner field as a vulnerability, but a user does have valid access to the account (perhaps a shared account owed by the users spouse) the tool would produce a false positive. This extends to any other field, when is a change in a field an error and when is it part of a well functioning application? **Testing in Production** Although conducting testing in production is not usually a good idea, when it comes to assessing Web application security it may be a necessity for at least a couple of reasons. First, even if thorough testing is done on development and test systems, there is still a potential for production systems to be configured differently. The actual application code could also be different, for example if files that were supposed to be deployed from test to production never got deployed, or of files has been manipulated on the production servers. Second, there are many Web Applications that are already in production but that were never tested for security to begin with. There may be an option to set up a parallel test environment for such applications but that is not always possible. Special care must obviously be taken when testing production applications as applications are many times not designed to be tested in a live production environment. This means for example that data submitted to a production database may not easily be identified as test data and cleanup may be difficult. If the application contains vulnerabilities, testing may inadvertently ruin large quantities of data that the test user should not have had access to. Testing should, if possible be conducted during maintenance windows so that any problems or DoS conditions can be cleaned up before the application goes live again. Testing of a production application should be done in a controlled fashion, so using automated features of testing tools must be carefully considered. It would be best to know exactly what HTTP requests the testing tool will use in the assessment stage. One option for a production application testing is a 3rd party penetration type testing. **Application Level Firewalls** Once the application is up and running, there are further measures one can take to monitor how well the application is doing from a security standpoint or to prevent malicious requests from ever reaching our application [2]. This type of devices or software often labeled *application level firewalls* promises to monitor HTTP traffic and automatically make determinations on what constitutes a valid request and what is to be considered a malicious request. Responses include denying a users request, logging and sending administrative alerts [10][8][7][11]. One must take care when using automated responses (denying access) as the firewall may have been responding to a false positive. Another issue with automated responses is if malicious users are able to trick the firewall in denying legitimate traffic. At this time, searches on the Internet did not provide any major evaluations of the effectiveness of this type of products. What level of protection do they provide? What type of attack do they stop? Do they live up to their promises? While evaluations are scares, an overview of products [17] shows that there are tradeoffs that have to be made when making the decision on what to deploy. **Using Requirements to Avoid Risk** New vulnerabilities and exploits are discovered continuously, therefore, it is impossible to be 100% certain that all weaknesses in a system has been addressed. As is often pointed out within the security discipline, what we need is defense in depth [13] and each layer added must mean a stronger defense. Because of this, security cannot be considered simply a technical issue that it is up to the development teams to "code" into the application. Nor can security be completely the responsibility of code reviewers, testers and security auditors. Security is the responsibility of all parties involved in the application project. While the previous sections have all discussed layers of protection provided by several of these parties, this final layer is actually provided by stakeholders involved from the beginning of a development project, when the requirements for the system are defined. The method is simple: When defining requirements for a system, always consider the implications of the data within the system ending up in the wrong hands. If some data element identified carries a high risk, consider ways to do without it. If the business and the system do not absolutely need some specific data element, do not include it! Risk can be addressed in 4 different ways: avoid risk; transfer risk; mitigate risk or accept risk [16]. While most other methods that address Web application security intends to mitigate risk, this method instead avoids risk all together. No matter what, unauthorized access to data that is not present will never happen. The cost of data being exposed to un-authorized persons is getting higher every day. For example, states are passing laws requiring companies to inform customers of such events [15]. In this case, the bill [14] addresses un-encrypted exposure of a persons name in combination with some specific other data elements. By applying the method above, for example by ensuring that the specific data elements are not present in the system, the risk of not complying with this law would be avoided. Of course, as this bill discusses un-encrypted data one way to mitigate the risk would be to store the data encrypted. However, that does not address the problem where the data is displayed or exposed somewhere within the system un-encrypted. If the data is not there we know it will not be exposed. At times data elements are being included in requirements because they seem like something that can be nice to have at some point in time or simply because "this is the way we always done it". Data elements like social security numbers may have been freely used in many older system and they are just kept on being included by habit. This is one reason why a reminder that each data element included carries a risk is needed. If it is realized that a data element, or a combination of data elements within a system exposes an organization to unacceptable high levels of risk then there is a good chance that alternative ways will be explored to deal with the business problem at hand. However, unless the requirements analysis is conducted with this explicitly in mind less risky alternatives may not be used, as they are not always obvious. Conclusions During development of an application, security features at many levels must be used. It all starts when the requirements are defined, through design, coding, and testing of the application. But it does not end there, as the wonderful world of Web applications is always changing, both the application and new vulnerabilities being discovered, continuous education and review of production system are also required. Defense in depth must be employed using all avenues available and this paper looked at a few of those avenues. Start by learning (for example using the OWASP Web site). Then, create low-risk requirements, and make sure you utilize available security features in your development environment. Test your application, both in development and during periodic reviews in production. Finally, application level firewalls can provide a layer of ongoing monitoring and protection of your Web application. References [22] White, Kelley and Chon, Yong-Gon. "Wide Open on Port 80." Information Security January 2003: 32 - 41 ## Upcoming SANS Training Click here to view a list of all SANS Courses <table> <thead> <tr> <th>Event Name</th> <th>Location</th> <th>Dates</th> <th>Type</th> </tr> </thead> <tbody> <tr> <td>SANS Las Vegas Summer 2020</td> <td>Las Vegas, NV</td> <td>Jun 08, 2020 - Jun 13, 2020</td> <td>Live Event</td> </tr> <tr> <td>SANS Silicon Valley - Cupertino 2020</td> <td>Cupertino, CA</td> <td>Jun 22, 2020 - Jun 27, 2020</td> <td>Live Event</td> </tr> <tr> <td>SANS Chicago Spring 2020</td> <td>OnlineIL</td> <td>Jun 01, 2020 - Jun 06, 2020</td> <td>Live Event</td> </tr> <tr> <td>SANS OnDemand</td> <td>Books &amp; MP3s Only</td> <td>Anytime</td> <td>Self Paced</td> </tr> </tbody> </table>
{"Source-Url": "https://www.sans.org/reading-room/whitepapers/securecode/web-application-security-layers-protection-965", "len_cl100k_base": 4431, "olmocr-version": "0.1.53", "pdf-total-pages": 11, "total-fallback-pages": 0, "total-input-tokens": 26483, "total-output-tokens": 6281, "length": "2e12", "weborganizer": {"__label__adult": 0.0006017684936523438, "__label__art_design": 0.0005087852478027344, "__label__crime_law": 0.00682830810546875, "__label__education_jobs": 0.0023822784423828125, "__label__entertainment": 0.00015175342559814453, "__label__fashion_beauty": 0.00026702880859375, "__label__finance_business": 0.0011148452758789062, "__label__food_dining": 0.0004036426544189453, "__label__games": 0.0013132095336914062, "__label__hardware": 0.0022907257080078125, "__label__health": 0.0010404586791992188, "__label__history": 0.0003516674041748047, "__label__home_hobbies": 0.00016438961029052734, "__label__industrial": 0.0007729530334472656, "__label__literature": 0.00038051605224609375, "__label__politics": 0.0004901885986328125, "__label__religion": 0.00043129920959472656, "__label__science_tech": 0.140380859375, "__label__social_life": 0.00019979476928710935, "__label__software": 0.0946044921875, "__label__software_dev": 0.744140625, "__label__sports_fitness": 0.0003876686096191406, "__label__transportation": 0.0005688667297363281, "__label__travel": 0.0002613067626953125}, "weborganizer_max": "__label__software_dev", "avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_ratio": [[0, 26758, 0.03653]], "fineweb_edu_fasttext_gt2__fineweb_edu_fasttext_gt2__score": [[0, 26758, 0.24904]], "ft_lang_id_en_doc_v2__ft_lang_id_en_doc_v2__en": [[0, 26758, 0.92233]], "google_gemma-3-12b-it_contains_pii": [[0, 0, null], [0, 223, false], [223, 3715, null], [3715, 7638, null], [7638, 11356, null], [11356, 15237, null], [15237, 18616, null], [18616, 21822, null], [21822, 25231, null], [25231, 25231, null], [25231, 26758, null]], "google_gemma-3-12b-it_is_public_document": [[0, 0, null], [0, 223, true], [223, 3715, null], [3715, 7638, null], [7638, 11356, null], [11356, 15237, null], [15237, 18616, null], [18616, 21822, null], [21822, 25231, null], [25231, 25231, null], [25231, 26758, null]], "google_gemma-3-4b-it_v2tag__is_academic_paper": [[0, 5000, true], [5000, 26758, null]], "google_gemma-3-4b-it_v2tag__is_class_syllabus": [[0, 5000, false], [5000, 26758, null]], "google_gemma-3-4b-it_v2tag__is_completion_certificate": [[0, 5000, false], [5000, 26758, null]], "google_gemma-3-4b-it_v2tag__is_court_notice": [[0, 5000, false], [5000, 26758, null]], "google_gemma-3-4b-it_v2tag__is_homework_assignment": [[0, 5000, false], [5000, 26758, null]], "google_gemma-3-4b-it_v2tag__is_news_article": [[0, 5000, false], [5000, 26758, null]], "google_gemma-3-4b-it_v2tag__is_public_order": [[0, 5000, false], [5000, 26758, null]], "google_gemma-3-4b-it_v2tag__is_resume_cv": [[0, 5000, false], [5000, 26758, null]], "google_gemma-3-4b-it_v2tag__is_test_or_quiz": [[0, 5000, false], [5000, 26758, null]], "google_gemma-3-4b-it_v2tag__is_textbook": [[0, 5000, false], [5000, 26758, null]], "pdf_page_numbers": [[0, 0, 1], [0, 223, 2], [223, 3715, 3], [3715, 7638, 4], [7638, 11356, 5], [11356, 15237, 6], [15237, 18616, 7], [18616, 21822, 8], [21822, 25231, 9], [25231, 25231, 10], [25231, 26758, 11]], "pipe_delimited_lines_v1__pipe_delimited_lines_v1__pipe_delimited_lines_ratio": [[0, 26758, 0.11404]]}
olmocr_science_pdfs
2024-12-09
2024-12-09
d9f5cf701461e5ff4ccab4f9aa11267ec31c5eb0
Generating Personalized Recipes from Historical User Preferences Bodhisattwa Prasad Majumder; Shuyang Li; Jianmo Ni, Julian McAuley Computer Science and Engineering University of California, San Diego {bmajumde, shl008, jin018, jmcauley}@ucsd.edu Abstract Existing approaches to recipe generation are unable to create recipes for users with culinary preferences but incomplete knowledge of ingredients in specific dishes. We propose a new task of personalized recipe generation to help these users: expanding a name and incomplete ingredient details into complete natural-text instructions aligned with the user’s historical preferences. We attend on technique- and recipe-level representations of a user’s previously consumed recipes, fusing these ‘user-aware’ representations in an attention fusion layer to control recipe text generation. Experiments on a new dataset of 180K recipes and 700K interactions show our model’s ability to generate plausible and personalized recipes compared to non-personalized baselines. 1 Introduction In the kitchen, we increasingly rely on instructions from cooking websites: recipes. A cook with a predilection for Asian cuisine may wish to prepare chicken curry, but may not know all necessary ingredients apart from a few basics. These users with limited knowledge cannot rely on existing recipe generation approaches that focus on creating coherent recipes given all ingredients and a recipe name (Kiddon et al., 2016). Such models do not address issues of personal preference (e.g. culinary tastes, garnish choices) and incomplete recipe details. We propose to approach both problems via personalized generation of plausible, user-specific recipes using user preferences extracted from previously consumed recipes. Our work combines two important tasks from natural language processing and recommender systems: data-to-text generation (Gatt and Krahmer, 2018) and personalized recommendation (Rashid et al., 2002). Our model takes as user input the name of a specific dish, a few key ingredients, and a calorie level. We pass these loose input specifications to an encoder-decoder framework and attend on user profiles—learned latent representations of recipes previously consumed by a user—to generate a recipe personalized to the user’s tastes. We fuse these ‘user-aware’ representations with decoder output in an attention fusion layer to jointly determine text generation. Quantitative (perplexity, user-ranking) and qualitative analysis on user-aware model outputs confirm that personalization indeed assists in generating plausible recipes from incomplete ingredients. While personalized text generation has seen success in conveying user writing styles in the product review (Ni et al., 2017; Ni and McAuley, 2018) and dialogue (Zhang et al., 2018) spaces, we are the first to consider it for the problem of recipe generation, where output quality is heavily dependent on the content of the instructions—such as ingredients and cooking techniques. To summarize, our main contributions are as follows: 1. We explore a new task of generating plausible and personalized recipes from incomplete input specifications by leveraging historical user preferences; 2. We release a new dataset of 180K+ recipes and 700K+ user reviews for this task; 3. We introduce new evaluation strategies for generation quality in instructional texts, centering on quantitative measures of coherence. We also show qualitatively and quantitatively that personalized models generate high-quality and specific recipes that align with historical user preferences. * denotes equal contribution 2 Related Work Large-scale transformer-based language models have shown surprising expressivity and fluency in creative and conditional long-text generation (Vaswani et al., 2017; Radford et al., 2019). Recent works have proposed hierarchical methods that condition on narrative frameworks to generate internally consistent long texts (Fan et al., 2018; Xu et al., 2018; Yao et al., 2018). Here, we generate procedurally structured recipes instead of free-form narratives. Recipe generation belongs to the field of data-to-text natural language generation (Gatt and Krahmer, 2018), which sees other applications in automated journalism (Leppänen et al., 2017), question-answering (Agrawal et al., 2017), and abstractive summarization (Paulus et al., 2018), among others. Kiddon et al. (2015); Bosselut et al. (2018b) model recipes as a structured collection of ingredient entities acted upon by cooking actions. Yang et al. (2017) at- tend over explicit ingredient references in the prior recipes for a user $u$ to bias generation toward user preferences and would be infe- sible in our setting due to the potentially unconstrained number of ingredients (from a space of 10K+) in a recipe. We instead learn historical preferences to guide full recipe generation. A recent line of work has explored user- and item-dependent aspect-aware review generation (Ni et al., 2017; Ni and McAuley, 2018). This work is related to ours in that it combines contextual language generation with personalization. Here, we attend over historical user preferences from previously consumed recipes to generate recipe content, rather than writing styles. 3 Approach Our model’s input specification consists of: the recipe name as a sequence of tokens, a partial list of ingredients, and a caloric level (high, medium, low). It outputs the recipe instructions as a token sequence: $W_r = \{w_{r,0}, \ldots, w_{r,T}\}$ for a recipe $r$ of length $T$. To personalize output, we use historical recipe interactions of a user $u \in U$. Encoder: Our encoder has three embedding lay- ers: vocabulary embedding $\mathcal{V}$, ingredient embedding $\mathcal{I}$, and caloric-level embedding $\mathcal{C}$. Each token in the (length $L_n$) recipe name is embedded via $\mathcal{V}$; the embedded token sequence is passed to a two- layered bidirectional GRU (BiGRU) (Cho et al., 2014), which outputs hidden states for names $\{n_{enc,j} \in \mathbb{R}^{2d_i}\}$, with hidden size $d_i$. Similarly each of the $L_i$ input ingredients is embedded via $\mathcal{I}$, and the embedded ingredient sequence is passed to another two-layered BiGRU to output ingredient hidden states as $\{i_{enc,j} \in \mathbb{R}^{2d_i}\}$. The caloric level is embedded via $\mathcal{C}$ and passed through a pro- jection layer with weights $W_c$ to generate calorie hidden representation $c_{enc} \in \mathbb{R}^{2d_i}$. Ingredient Attention: We apply attention (Bah- danau et al., 2015) over the encoded ingredients to use encoder outputs at each decoding time step. We define an attention-score function $\alpha$ with key $K$ and query $Q$: $$\alpha(K, Q) = \frac{\exp (\text{tanh} (W_\alpha [K + Q] + b_\alpha))}{Z}$$ with trainable weights $W_\alpha$, bias $b_\alpha$, and normal- ization term $Z$. At decoding time $t$, we calculate the ingredient context $a_t^i \in \mathbb{R}^{d_h}$ as: $$a_t^i = \sum_{j=1}^{L_i} \alpha (i_{enc,j}, h_t) \times i_{enc,j}.$$ Decoder: The decoder is a two-layer GRU with hidden state $h_t$ conditioned on previous hidden state $h_{t-1}$ and input token $w_{r,t}$ from the original recipe text. We project the concatenated encoder outputs as the initial decoder hidden state: $$h_0 (\in \mathbb{R}^{d_h}) = W_{h_0} [n_{enc,L_n} ; i_{enc,L_i} ; c_{enc}] + b_{h_0}$$ $$h_t, o_t = \text{GRU} ([w_{r,t}; a_t^i, h_{t-1}]).$$ To bias generation toward user preferences, we attend over a user’s previously reviewed recipes to jointly determine the final output token distribution. We consider two different schemes to model preferences from user histories: (1) recipe inter- actions, and (2) techniques seen therein (defined in Section 4). Rendle et al. (2009); Quadrana et al. (2018); Ueda et al. (2011) explore similar schemes for personalized recommendation. Prior Recipe Attention: We obtain the set of prior recipes for a user $u$: $R_u^{k+}$, where each recipe can be represented by an embedding from a recipe embedding layer $\mathcal{R}$ or an average of the name tokens embedded by $\mathcal{V}$. We attend over the $k$-most recent prior recipes, $R_u^{k+}$, to account for tempo- ral drift of user preferences (Moore et al., 2013). These embeddings are used in the ‘Prior Recipe’ and ‘Prior Name’ models, respectively. Given a recipe representation \( r \in \mathbb{R}^{d_r} \) (where \( d_r \) is recipe- or vocabulary-embedding size depending on the recipe representation) the prior recipe attention context \( \alpha^r_t \) is calculated as \[ \alpha^r_t = \sum_{r \in R_{u}^+} \alpha(r, h_t) \times r. \] **Prior Technique Attention:** We calculate prior technique preference (used in the ‘Prior Tech’ model) by normalizing co-occurrence between users and techniques seen in \( R_{u}^+ \), to obtain a preference vector \( \rho_u \). Each technique \( x \) is embedded via a technique embedding layer \( X \) to \( x \in \mathbb{R}^{d_x} \). Prior technique attention is calculated as \[ \alpha^t_{ux} = \sum_{x \text{ seen in } R_{u}^+} (\alpha(x, h_t) + \rho_{ux}) \times x, \] where, inspired by copy mechanisms (See et al., 2017; Gu et al., 2016), we add \( \rho_{ux} \) for technique \( x \) to emphasize the attention by the user’s prior technique preference. **Attention Fusion Layer:** We fuse all contexts calculated at time \( t \), concatenating them with decoder GRU output and previous token embedding: \[ \alpha^t_f = \text{ReLU} \left( W_f [w_{r,t}; \alpha_t^r; (\alpha_t^{ux} \text{ or } \alpha_t^{ux})] + b_f \right). \] We then calculate the token probability: \[ P(S_{r,t}) = \text{softmax} \left( W_p [\alpha^t_f] + b_p \right), \] and maximize the log-likelihood of the generated sequence conditioned on input specifications and user preferences. Figure 1 shows a case where the Prior Name model attends strongly on previously consumed savory recipes to suggest the usage of an additional ingredient (‘cilantro’). ![Figure 1: Sample data flow through model architecture. Emphasis on prior recipe attention scores (darker is stronger). Ingredient attention omitted for clarity.](image) **4 Recipe Dataset: Food.com** We collect a novel dataset of 230K+ recipe texts and 1M+ user interactions (reviews) over 18 years (2000-2018) from Food.com.\(^2\) Here, we restrict to recipes with at least 3 steps, and at least 4 and no more than 20 ingredients. We discard users with fewer than 4 reviews, giving 180K+ recipes and 700K+ reviews, with splits as in Table 1. Our model must learn to generate from a diverse recipe space: in our training data, the average recipe length is 117 tokens with a maximum of 256. There are 13K unique ingredients across all recipes. Rare words dominate the vocabulary: 95% of words appear <100 times, accounting for only 1.65% of all word usage. As such, we perform Byte-Pair Encoding (BPE) tokenization (Sennrich et al., 2016; Radford et al., 2018), giving a training vocabulary of 15K tokens across 19M total mentions. User profiles are similarly diverse: 50% of users have consumed ≤6 recipes, while 10% of users have consumed >45 recipes. We order reviews by timestamp, keeping the most recent review for each user as the test set, the second most recent for validation, and the remainder for training (sequential leave-one-out evaluation (Kang and McAuley, 2018)). We evaluate only on recipes not in the training set. We manually construct a list of 58 cooking techniques from 384 cooking actions collected by Bosselut et al. (2018b); the most common techniques (bake, combine, pour, boil) account for 36.5% of technique mentions. We approximate technique adherence via string match between the recipe text and technique list. **5 Experiments and Results** For training and evaluation, we provide our model with the first 3-5 ingredients listed in each recipe. We decode recipe text via top-\(k\) sampling (Radford et al., 2019), finding \( k = 3 \) to produce satisfactory results. We use a hidden size \( d_h = 256 \) <table> <thead> <tr> <th>Split</th> <th># Users</th> <th># Recipes</th> <th># Actions</th> <th>Sparsity(^3)</th> </tr> </thead> <tbody> <tr> <td>Train</td> <td>25,076</td> <td>160,901</td> <td>698,901</td> <td>99.983%</td> </tr> <tr> <td>Dev</td> <td>7,023</td> <td>6,621</td> <td>7,023</td> <td>–</td> </tr> <tr> <td>Test</td> <td>12,455</td> <td>11,695</td> <td>12,455</td> <td>–</td> </tr> </tbody> </table> \(^2\)https://www.kaggle.com/shuyangli94/food-com-recipes-and-user-interactions \(^3\)Ratio of unobserved actions to all possible actions. <table> <thead> <tr> <th>Model</th> <th>BPE PPL</th> <th>BLEU-1</th> <th>BLEU-4</th> <th>ROUGE-L</th> <th>D-1 (%)</th> <th>D-2 (%)</th> <th>UMA</th> <th>MRR</th> <th>PP (%)</th> </tr> </thead> <tbody> <tr> <td>NN</td> <td>–</td> <td>20.279</td> <td>0.465</td> <td>16.871</td> <td>0.931</td> <td>9.394</td> <td>0.100</td> <td>0.293</td> <td>–</td> </tr> <tr> <td>Enc-Dec</td> <td>9.611</td> <td>28.391</td> <td>3.385</td> <td>25.001</td> <td>0.220</td> <td>1.928</td> <td>0.100</td> <td>0.293</td> <td>–</td> </tr> <tr> <td>Prior Tech</td> <td>9.572</td> <td>28.864</td> <td>3.312</td> <td>24.920</td> <td>0.233</td> <td>2.158</td> <td>0.128</td> <td>0.319</td> <td>62.821</td> </tr> <tr> <td>Prior Recipe</td> <td>9.551</td> <td>27.858</td> <td>3.215</td> <td>24.822</td> <td>0.231</td> <td>2.062</td> <td>0.302</td> <td>0.412</td> <td>66.026</td> </tr> <tr> <td>Prior Name</td> <td>9.516</td> <td>28.046</td> <td>3.211</td> <td>24.794</td> <td>0.233</td> <td>2.080</td> <td>0.505</td> <td>0.628</td> <td>61.165</td> </tr> </tbody> </table> Table 2: Metrics on generated recipes from test set. D-1/2 = Distinct-1/2, UMA = User Matching Accuracy, MRR = Mean Reciprocal Rank, PP = Pairwise preference over baseline (evaluated for 310 recipe pairs per model). Input Name: Pomberrytini; Ingredients: pomegranate-blueberry juice, cranberry juice, vodka; Calorie: Low Gold Place everything except the orange slices in a cocktail shaker. Shake until well mixed and well chilled. Pour into martini glasses and float an orange slice in each glass. Enc-Dec Combine all ingredients. Cover and refrigerate. Serve with whipped topping. Prior Tech Combine all ingredients. Store in refrigerator. Serve over ice. Enjoy! Prior Recipe Pour the ice into a cocktail shaker. Pour in the vodka and vodka. Add a little water and shake to mix. Pour into the glass and garnish with a slice of orange slices. Enjoy! Prior Name Combine all ingredients except for the ice in a blender or food processor. Process to make a smooth paste and then add the remaining vodka and blend until smooth. Pour into a chilled glass and garnish with a little lemon and fresh mint. Table 3: Sample generated recipe. Emphasis on personalization and explicit ingredient mentions via highlights. In this work, we investigate how leveraging historical user preferences can improve generation quality over strong baselines in our setting. We compare our personalized models against two baselines. The first is a name-based Nearest-Neighbor model (NN). We initially adapted the Neural Checklist Model of Kiddon et al. (2016) as a baseline; however, we ultimately use a simple Encoder-Decoder baseline with ingredient attention (Enc-Dec), which provides comparable performance and lower complexity. All personalized models outperform baseline in BPE perplexity (Table 2) with Prior Name performing the best. While our models exhibit comparable performance to baseline in BLEU-1/4 and ROUGE-L, we generate more diverse (Distinct-1/2: percentage of distinct unigrams and bigrams) and acceptable recipes. BLEU and ROUGE are not the most appropriate metrics for generation quality. A ‘correct’ recipe can be written in many ways with the same main entities (ingredients). As BLEU-1/4 capture structural information via n-gram matching, they are not correlated with subjective recipe quality. This mirrors observations from Baheti et al. (2018); Fan et al. (2018). We observe that personalized models make more diverse recipes than baseline. They thus perform better in BLEU-1 with more key entities (ingredient mentions) present, but worse in BLEU-4, as these recipes are written in a personalized way and deviate from gold on the phrasal level. Similarly, the ‘Prior Name’ model generates more unigram-diverse recipes than other personalized models and obtains a correspondingly lower BLEU-1 score. Qualitative Analysis: We present sample outputs for a cocktail recipe in Table 3, and additional recipes in the appendix. Generation quality progressively improves from generic baseline output to a blended cocktail produced by our best performing model. Models attending over prior recipes explicitly reference ingredients. The Prior Name model further suggests the addition of lemon and mint, which are reasonably associated with previously consumed recipes like coconut mousse and pork skewers. Personalization: To measure personalization, we evaluate how closely the generated text corresponds to a particular user profile. We compute the likelihood of generated recipes using identical input specifications but conditioned on ten different user profiles—one 'gold' user who consumed the original recipe, and nine randomly generated user profiles. Following Fan et al. (2018), we expect the highest likelihood for the recipe conditioned on the gold user. We measure user matching accuracy (UMA)—the proportion where the gold user is ranked highest—and Mean Reciprocal Rank (MRR) (Radev et al., 2002) of the gold user. All personalized models beat baselines in both metrics, showing our models personalize generated recipes to the given user profiles. The Prior Name model achieves the best UMA and MRR by a large margin, revealing that prior recipe names are strong signals for personalization. Moreover, the addition of attention mechanisms to capture these signals improves language modeling performance over a strong non-personalized baseline. Recipe Level Coherence: A plausible recipe should possess a coherent step order, and we evaluate this via a metric for recipe-level coherence. We use the neural scoring model from Bosselut et al. (2018a) to measure recipe-level coherence for each generated recipe. Each recipe step is encoded by BERT (Devlin et al., 2019). Our scoring model is a GRU network that learns the overall recipe step ordering structure by minimizing the cosine similarity of recipe step hidden representations presented in the correct and reverse orders. Once pretrained, our scorer calculates the similarity of a generated recipe to the forward and backwards ordering of its corresponding gold label, giving a score equal to the difference between the former and latter. A higher score indicates better step ordering (with a maximum score of 2). Table 4 shows that our personalized models achieve average recipe-level coherence scores of 1.78-1.82, surpassing the baseline at 1.77. Recipe Step Entailment: Local coherence is also crucial to a user following a recipe: it is crucial that subsequent steps are logically consistent with prior ones. We model local coherence as an entailment task: predicting the likelihood that a recipe step follows the preceding. We sample several consecutive (positive) and non-consecutive (negative) pairs of steps from each recipe. We train a BERT (Devlin et al., 2019) model to predict the entailment score of a pair of steps separated by a [SEP] token, using the final representation of the [CLS] token. The step entailment score is computed as the average of scores for each set of consecutive steps in each recipe, averaged over every generated recipe for a model, as shown in Table 4. Human Evaluation: We presented 310 pairs of recipes for pairwise comparison (Fan et al., 2018) (details in appendix) between baseline and each personalized model, with results shown in Table 2. On average, human evaluators preferred personalized model outputs to baseline 63% of the time, confirming that personalized attention improves the semantic plausibility of generated recipes. We also performed a small-scale human coherence survey over 90 recipes, in which 60% of users found recipes generated by personalized models to be more coherent and preferable to those generated by baseline models. 6 Conclusion In this paper, we propose a novel task: to generate personalized recipes from incomplete input specifications and user histories. On a large novel dataset of 180K recipes and 700K reviews, we show that our personalized generative models can generate plausible, personalized, and coherent recipes preferred by human evaluators for consumption. We also introduce a set of automatic coherence measures for instructional texts as well as personalization metrics to support our claims. Our future work includes generating structured representations of recipes to handle ingredient properties, as well as accounting for references to collections of ingredients (e.g. “dry mix”). Acknowledgements. This work is partly supported by NSF #1750063. We thank all reviewers for their constructive suggestions, as well as Rei M., Sujoy P., Alicia L., Eric H., Tim S., Kathy C., Allen C., and Micah I. for their feedback. References Saizheng Zhang, Emily Dinan, Jack Urbanek, Arthur Szlam, Douwe Kiela, and Jason Weston. 2018. Personalizing dialogue agents: I have a dog, do you have pets too? In *ACL*. Appendix Food.com: Dataset Details Our raw data consists of 270K recipes and 1.4M user-recipe interactions (reviews) scraped from Food.com, covering a period of 18 years (January 2000 to December 2018). See Table 5 for dataset summary statistics, and Table 6 for sample information about one user-recipe interaction and the recipe involved. <table> <thead> <tr> <th></th> <th># Recipes</th> <th># Users</th> <th># Reviews</th> <th>Sparsity (%)</th> </tr> </thead> <tbody> <tr> <td>Raw</td> <td>231,637</td> <td>226,570</td> <td>1,132,367</td> <td>99.998</td> </tr> <tr> <td>Processed</td> <td>178,265</td> <td>25,076</td> <td>749,053</td> <td>99.983</td> </tr> </tbody> </table> Table 5: Interaction statistics for Food.com dataset before and after data processing. Generated Examples See Table 7 for a sample recipe for chicken chili and Table 8 for a sample recipe for sweet waffles. Human Evaluation We prepared a set of 15 pairwise comparisons per evaluation session, and collected 930 pairwise evaluations (310 per personalized model) over 62 sessions. For each pair, users were given a partial recipe specification (name and 3-5 key ingredients), as well as two generated recipes labeled ‘A’ and ‘B’. One recipe is generated from our baseline encoder-decoder model and one recipe is generated by one of our three personalized models (Prior Tech, Prior Name, Prior Recipe). The order of recipe presentation (A/B) is randomly selected for each question. A screenshot of the user evaluation interface is given in Figure 2. We ask the user to indicate which recipe they find more coherent, and which recipe best accomplishes the goal indicated by the recipe name. A screenshot of this survey interface is given in Figure 3. Recipe name: "strawberry pop cake" Some ingredients: —cake mix —egg white —oil —water Recipe A: 1) preheat oven to 375 2) grease and flour two 8 - inch round cake pans 3) in a small bowl, combine sugar and egg 4) beat with electric mixer until well blended 5) pour into prepared pan 6) bake for 30 - 35 minutes, or until toothpick comes out clean 7) remove from oven and allow to cool 8) store cake in refrigerator 9) this recipe may be stored for up to 2 days in refrigerator 10) to serve: thaw for 30 minutes before cutting. Recipe B: 1) bake cake according to directions 2) cool 3) cut cake horizontally to 1 / 2 - inch pieces and place in buttered pan 4) combine eggs and milk and pour over top 5) bake at 350 f for 25 - 30 minutes or until cake springs back when touched lightly 6) cool completely 7) frost cake 8) sprinkle with pecans 9) serve immediately 10) enjoy! 11) makes 6 servings. Do you prefer recipe A or recipe B? (A/B): | Input | Name: Chicken Bell Pepper Chili Weight Watchers Ingredients: olive oil, red bell pepper, green bell pepper, yellow bell pepper Calorie: Medium | |---|---| | Gold | In a large nonstick dutch oven or saucepan, heat the oil. Saute the bell peppers and onion until softened, about 5 minutes. Add the chicken. Cook, breaking apart with a wooden spoon, until no longer pink, 5 - 7 minutes. Sprinkle with the flour, chili powder, cumin, cocoa powder, and cayenne. Cook, stirring briskly and constantly, 1 minute. Stir in the tomatoes and vinegar. Bring to a boil. Reduce the heat and simmer, stirring frequently, until thick, 30 - 40 minutes. Stir in the chickpeas. Simmer until heated through, about 5 minutes. | | Enc-Dec | Heat oil in a large, heavy pot over medium heat. Add chicken and cook until browned on both sides, about 10 minutes, or until browned; drain. Add onion and garlic and saute for 2 minutes. Add chicken broth, chicken broth, and corn starch. Bring to a slow boil, reduce heat, cover and simmer for 30 minutes. Remove from heat and add the tomatoes and corn. Simmer until chicken is cooked through, about 10 minutes. Serve over rice or noodles. | | Prior Tech | Heat oil in large saucepan over medium - high heat. Add chicken and cook until browned. Add bell pepper and onions, cook 2 minutes, stirring frequently. Add chicken broth. Cover, simmer, stirring occasionally, for 10 minutes or until vegetables are tender, stirring occasionally. Add chicken, cover, and cook 10 more minutes or until chicken is cooked through. Remove from heat. Stir in remaining ingredients. Season with salt and pepper to taste. Serve over rice and top with additional shredded cheese and cilantro. | | Prior Recipe | Heat oil in large dutch oven over medium - high. Add chicken, bell peppers, bell peppers and onion. Saute 2 - 3 minutes. Add broth and tomato paste; stir. Bring to a boil. Reduce heat and simmer, covered, for 10 minutes or until rice is tender, stirring often. Stir in chicken. Cover and simmer for 10 minutes. Stir in parsley. Serve over rice. Garnish with cilantro. | | Prior Name | Heat the oil in a large skillet over medium - high heat. Add the peppers and onions. Cook, stirring, until the vegetables are soft and beginning to soften, about 5 minutes. Stir in the tomatoes, corn, corn, and corn. Bring to a boil. Reduce heat to low, cover, and simmer for 10 minutes. Add the chicken and cook for another 10 minutes or until the vegetables are tender. Stir in the cilantro and serve. | Table 7: Sample generated recipe “Chicken Bell Pepper Chili Weight Watchers” for all models. Input | **Name:** Cinna Nilla Waffles **Ingredients:** flour, egg, milk, vegetable oil, sugar **Calorie:** Medium ---|--- Gold | Heat waffle iron. Beat eggs in large bowl with hand beater until fluffy. Beat in remaining ingredients until smooth. Pour batter into waffle iron and cook for approximately 5 minutes. Serve immediately or cool to pack into freezer bags and freeze. ---|--- Enc-Dec | Mix the flour, baking soda, and salt in a bowl. In a separate bowl, whisk together the milk, oil, eggs and sugar. Stir the flour mixture into the egg mixture, and continue to mix well. Add the flour to the egg mixture. Mix well and pour into a greased waffle iron. Cook for 2 minutes, remove from heat and serve. ---|--- Prior Tech | In a medium bowl mix flour, eggs, and milk until combined. Add the dry ingredients and stir until just combined and do not mix. Heat griddle over medium heat, add the oil, oil, and cook the pancakes until golden brown and cooked through. Serve with a little milk or cream. Enjoy ---|--- Prior Recipe | In a mixing bowl, whisk together the eggs, milk, oil, sugar, vanilla, salt and vanilla. Cover and let the mixture stand in the fridge for about 1 hour. Spoon batter into waffle iron and close the grill. ---|--- Prior Name | Preheat waffle iron. Beat together the eggs, milk and oil until well blended, add the vanilla and mix well with a mixer. Fold in flour, baking powder, and cinnamon. Spread 1 / 2 the mixture in a greased waffle iron. Bake until golden brown, about 15 minutes per side. Sprinkle with powdered sugar and serve warm. Table 8: Sample generated waffle recipe for all models. NOTE: Recipes may use more than just the provided ingredients! Recipe name: "old settler's beans" Some ingredients: --ground beef --bacon --onion --kidney bean --pork & bean Recipe A: 1) cook beef, onion, and onion in large pot of boiling water 2) cook for 5 minutes or until beans are tender 3) add beans, corn, and worcestershire sauce 4) cook until beans and beans are tender, stirring occasionally 5) add remaining ingredients 6) cook over low heat for 5 - 10 minutes. Recipe B: 1) brown beef, onions, green onions, garlic, and onion 2) add beans, water and water 3) bring to a boil, reduce heat to simmer, and cook for 10 minutes 4) add beans and cook for 5 - 7 hours. Which is more coherent (grammatical), recipe A or recipe B? (A/B): GOAL: "old settler's beans" Which recipe better accomplishes the goal (above), recipe A or recipe B? (A/B):
{"Source-Url": "https://export.arxiv.org/pdf/1909.00105", "len_cl100k_base": 7265, "olmocr-version": "0.1.49", "pdf-total-pages": 12, "total-fallback-pages": 0, "total-input-tokens": 31475, "total-output-tokens": 9673, "length": "2e12", "weborganizer": {"__label__adult": 0.0011148452758789062, "__label__art_design": 0.0028247833251953125, "__label__crime_law": 0.0009746551513671876, "__label__education_jobs": 0.0155029296875, "__label__entertainment": 0.0006647109985351562, "__label__fashion_beauty": 0.0010576248168945312, "__label__finance_business": 0.0008120536804199219, "__label__food_dining": 0.0302276611328125, "__label__games": 0.0031280517578125, "__label__hardware": 0.0027751922607421875, "__label__health": 0.0030956268310546875, "__label__history": 0.0007829666137695312, "__label__home_hobbies": 0.0009131431579589844, "__label__industrial": 0.0024566650390625, "__label__literature": 0.0034313201904296875, "__label__politics": 0.0007500648498535156, "__label__religion": 0.0014705657958984375, "__label__science_tech": 0.434814453125, "__label__social_life": 0.0005526542663574219, "__label__software": 0.051025390625, "__label__software_dev": 0.43994140625, "__label__sports_fitness": 0.0004014968872070313, "__label__transportation": 0.0008153915405273438, "__label__travel": 0.0004396438598632813}, "weborganizer_max": "__label__software_dev", "avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_ratio": [[0, 33798, 0.03075]], "fineweb_edu_fasttext_gt2__fineweb_edu_fasttext_gt2__score": [[0, 33798, 0.02547]], "ft_lang_id_en_doc_v2__ft_lang_id_en_doc_v2__en": [[0, 33798, 0.83523]], "google_gemma-3-12b-it_contains_pii": [[0, 3622, false], [3622, 8259, null], [8259, 12463, null], [12463, 16465, null], [16465, 20748, null], [20748, 25203, null], [25203, 25994, null], [25994, 27632, null], [27632, 28574, null], [28574, 31271, null], [31271, 32944, null], [32944, 33798, null]], "google_gemma-3-12b-it_is_public_document": [[0, 3622, true], [3622, 8259, null], [8259, 12463, null], [12463, 16465, null], [16465, 20748, null], [20748, 25203, null], [25203, 25994, null], [25994, 27632, null], [27632, 28574, null], [28574, 31271, null], [31271, 32944, null], [32944, 33798, null]], "google_gemma-3-4b-it_v2tag__is_academic_paper": [[0, 5000, true], [5000, 33798, null]], "google_gemma-3-4b-it_v2tag__is_class_syllabus": [[0, 5000, false], [5000, 33798, null]], "google_gemma-3-4b-it_v2tag__is_completion_certificate": [[0, 5000, false], [5000, 33798, null]], "google_gemma-3-4b-it_v2tag__is_court_notice": [[0, 5000, false], [5000, 33798, null]], "google_gemma-3-4b-it_v2tag__is_homework_assignment": [[0, 5000, false], [5000, 33798, null]], "google_gemma-3-4b-it_v2tag__is_news_article": [[0, 5000, false], [5000, 33798, null]], "google_gemma-3-4b-it_v2tag__is_public_order": [[0, 5000, false], [5000, 33798, null]], "google_gemma-3-4b-it_v2tag__is_resume_cv": [[0, 5000, false], [5000, 33798, null]], "google_gemma-3-4b-it_v2tag__is_test_or_quiz": [[0, 5000, false], [5000, 33798, null]], "google_gemma-3-4b-it_v2tag__is_textbook": [[0, 5000, false], [5000, 33798, null]], "pdf_page_numbers": [[0, 3622, 1], [3622, 8259, 2], [8259, 12463, 3], [12463, 16465, 4], [16465, 20748, 5], [20748, 25203, 6], [25203, 25994, 7], [25994, 27632, 8], [27632, 28574, 9], [28574, 31271, 10], [31271, 32944, 11], [32944, 33798, 12]], "pipe_delimited_lines_v1__pipe_delimited_lines_v1__pipe_delimited_lines_ratio": [[0, 33798, 0.05842]]}
olmocr_science_pdfs
2024-11-24
2024-11-24
9595d70d75daa058dbabc7aceb8e19327c097e49
Using Flask for SQLIA Detection and Protection A B S T R A C T At present the web applications are used for most of the life activities, these applications are affected by an attack called (Structure Query Language Injection Attack) SQLIA due to the vulnerabilities of the web application. The vulnerabilities of the web application are increased because most of application developers do not care to security in designing. SQL injection is a common attack that infects a web application. The attacker adds (Structured Query Language) SQL code to web page for accessing and changing victim databases. The vital step in securing the database and detecting such an attack in web apps is preparing a tool. Many researchers propose different ways for detection and prevention of such an attack. In this paper a tool it proposed using a powerful micro-framework web application designer called Flask in Python 3.7 to detect and prevent such attacks. The proposed system is called SQLIAD. SQLIAD analyzed a web application on-line. Ann Z. Ablahd1 Suhair A. Dawwood2 1Computer Engineering Dept. / Technical College / Northern Technical University/ Kirkuk-Iraq 2Management Information System Dept. /Administration & Economic/ College/ Mosul-Iraq Keywords: SQL injection, Flask, vulnerability, Web application, Python, Django Article history: Received 25 October 2019 Accepted 25 April 2020 Available Online 09 May 2020 DOI: http://doi.org/10.25130/tjes.27.2.01 Using Flask for SQLIA Detection and Protection 1. INTRODUCTION Web security is the most important topic of web applications due to the rapid developments in the internet and because it is valuable and most popular for attacks. Different web applications react with the database background systems, which stored the most sensitive information (like bank account, etc.). There are two types of web applications, static and dynamic. In the static web application, it is difficult to alter the content of a web application, it can only be done by a webmaster. But a dynamic web application is much more complex than a static web application, due to updating data by users each time. This has a general administration control that is controlled by administrators in modifying the content of web applications including images and text. The Structured Query Language (SQL) is a standard computer programming language used for storing, retrieving and manipulating relational stored database. This language... is used to access, edit, modify and delete data. Different websites are stored as SQL databases in the server. There is a dangerous attack that infects a vulnerability web application called SQL injection attack (SQLIA). This attack infects dynamic web applications and it can lead to modify sensitive and confidential information. This attack sends malicious inputs to database-driven web applications. These inputs are used by applications in building dynamic SQL queries, and have the ability to alter query semantic structures, due to lacking separation between control and SQL database. The attacker attempts to append malicious SQL commands by inserting special variables into web applications. This leads to steal, damage, edit and delete the main databases server. There are many companies which became victims of that attack and lost a lot of money. To improve the web application security, an online tool was designed using Django, Flask tools in python3.7 for detecting and preventing SQL injection attack. This online tool is called SQLIAD. 2. RELATED WORKS Huan [1] examined input by "Tainted Data Tracking" research, which is a used precondition. The drawback of this research is that the technique is assumed accurately expressed for sensitive functions. Boyd [2] introduced “SQL Randomization” this research is based on the randomization of the instruction set, by appending a random number after the keyword of SQL used in building the statement of SQL. In the runtime, the parser of SQL finds that the injected SQL key does not have an appended number and will stop the attack. Kema [3] introduces “Novel-Specification Based Methodology”. This research compares generating with predefined SQL statements that is done at compilation time. Junjin [4] introduces "An approach for SQL injection vulnerability detection". In this research, inputs are compared for legitimate and attacker SQL query structure where done. The drawback of this research, it is impossible to make a set of legal inputs in a large web application. Kim [5] introduces "Injection attack detection using the removal of SQL query attribute values". In this research dynamic and static analysis is used. It designed a function for detecting the generated SQL queries at runtime for normal users and compares the static generated queries by normal user with the dynamically generated queries by attacker. The drawback of this technique is the source code and prepared learning is needed. Ryan Turner [6] introduces “How can I prevent SQL Injection in PHP” Using sqlmap of python2.3. But this research is slow in analysis and execution. The proposed system used Django and flask tools with a new version of python (3.7) that leads to prepare an easy-to-use and powerful application to detect and prevent a dangerous attack SQLI from a web application. 3. THE ARTITECTURE OF WEB APPLICATION A web application is a framework which consists of interactions between many applications, middleware, and database systems on the web, with ensuring that many applications run simultaneously [7]. 4. PYTHON It is a dynamic programming language, created in the beginning of the 1990s by Guido Rossum [10]. Python is an interpreter boost multi programming model involving functional and Object-Oriented Programming. A python program consists of various modules. A module is a python file that contains python statements with extension (py) [11]. The data in python is represented as an object. The syntax called "Decorators" is used in designing SQLIAD that allows transforming function to others easily. It is potential in python to produce a module reference and imported with other modules. It is possible in python to import different modules with the command (import module-name) after using this command a reference of this module will be created with module-name. It imports classes, functions, and variables. The access of each part of the module is done by specifying the name of that part separated by a dot (.).see Fig.2. [2] 5. WEB APPLICATION STRUCTURE The Web Application can be accessed by an Internet Web Browser. It is a computer application written in different languages (JavaScript, Java, Html… etc.) to be common for executable with a different Browser. [8] Web application supports a dynamic basic database-driven that consists of server-side script web pages, which is written in one programming language like java to extract database information depending on dynamic interactions. [9] Many web applications believe that the input of the user is legitimate to build queries of SQL to access databases [8]. These applications are more susceptible to SQLI attacks. | Table 1 | shows the ranking of different languages in finding the vulnerability of web applications [14]. | Table 1 Ranking of different languages in detecting web application vulnerability, after [14]. <table> <thead> <tr> <th>Language Rank</th> <th>SQL Injection detecting Ranking</th> </tr> </thead> <tbody> <tr> <td>1- Python</td> <td>100</td> </tr> <tr> <td>2- C</td> <td>99.7</td> </tr> <tr> <td>3- Java</td> <td>99.5</td> </tr> <tr> <td>4- C++</td> <td>97.1</td> </tr> <tr> <td>5- R</td> <td>87.7</td> </tr> <tr> <td>6- C#</td> <td>87.7</td> </tr> <tr> <td>7- JAVAScript</td> <td>85.6</td> </tr> <tr> <td>8- PHP</td> <td>81.2</td> </tr> <tr> <td>9- GO</td> <td>75.1</td> </tr> <tr> <td>10- Swift</td> <td>73.7</td> </tr> </tbody> </table> A new line is used as a delimiter in a python program between two statements. A "#" symbol used to defines comment in python. 5. DJANGO Django is an open-source python free web framework. The primary goal of Django is to ease designing a complex web application supported with databases driven and low cost [5]. The power here in reusing the applications easily by using URL for linking it together. Django has the ability to work as optional administrative in creating, updating, reading, and deleting generate dynamic interfaces, through configuration by admin. [15] Django has the ability to force developer for adding functions in a different way. The way of building Django forces the developer for adding functions by using a specific way. The Django application contains the following modules: - The main modules, that the application starts code executing. - The test modules, app testing. - The view modules mean app visualization. - The URLs module, mapping URLs for viewing. - The model's module, models of databases. - The apps module means apps nested. Most of the well-known frameworks or web sites used Django like Instagram, Mozilla, and Flask. The library of Django is generated using the python command "pip install Django". 6. FLASK It is a micro web framework in python3. Flask is very powerful customizable when chosen for developing web applications. Also, it is very flexible when it used by developers with databases, easy to design packages and server development [16]. The nature of Flask is that by a small limit of code you can design a webpage. The power of Flask is the capability of developers to customize all things. In normal python there was an input () command used to input data and eval (value) command to hand the input without filtration from any annoyance [17]. But after using Flask, it has different means of input rather than the input () command with sanitization of input data used in protection from SQLI. Flask provided by Markup class that uses string replace () command to sanitizing user input. The Markup class contains an escape function responsible for sanitizing the input by escaping the Html markup. Fig.3. shows sanitizing of user input by Flask. ```python html = open('templates/input.html').read() unsafe = request.args.get('param') sanitised = Markup.escape(unsafe) resp = make_response(html.replace('{{param}}', sanitised)) ``` Fig.3. sanitizing of user input by Flask There are many functions in Flask that are used in this proposed system (Routing, Requests, Responses, Templates) functions. The Routing function that is used in flask (app.route) decorator to bind functions to the URL path. For e.g., if the path is '/' that means to get the output from the root path. Another parameter of (app.route) decorator like (GET,POST) where "GET requests" used to fetch server information, but POST request used to send the data to used server. Fig.4. shows an example of (GET, POST) requests. The reason for the chosen Flask tool in this proposed system is simple and easy on development and testing web applications. ```python from flask import Flask, request @app.route('/login', methods=['GET', 'POST']) def login(): if request.method == 'POST': do_the_login() else: show_the_login_form() ``` Fig.4. login form using a POST request A template engine used by Flask called Jinja2 which keeps the security of application. These templates will escape all dangerous input that is used in SQLIAD. Django needs a way for generating dynamic HTML, a common way of generating HTML pages is using template. A template in python is a way of representing data in different attractive forms. 7. SQLALCHEMY TOOL SQLAlchemy is a toolkit used in operating directly with SQL databases. The aim of using this tool is to access databases inactive and high performance with simple python code [18]. This tool consists of several dependence components organized into layers. The major parts are "Object Relational Mapper" (ORM), "SQL Expression Language"; the second part may be used independently of ORM. The Expression of SQL remains as a part of public API (Application Programming Interface) as it can be used within queries and configuration of Object-Relational. There are three separate layers (illustrated in Fig.5.) of SQLAlchemy: Core, ORM, and Dialects. The ORM is introduced and a new user can begin by this section with a high level of SQL. Core is the second section; it is the heart of this tool; it is the core between the integration of databases, services description, and Expression of SQL language. The third section is Dialects that is a documentation reference for all defined database and provided with a backend DBAPI. To generate a library of SQLAlchemy, the command "pip install SQLAlchemy" was used through the prepared SQLIAD app. This tool is also used to prevent SQL Injection attacks by using parameterized queries with (ORMs) mappers. ![Fig.5. layers of SQLAlchemy tool](image) 8. SQL INJECTION The injection vulnerability is the most important part of the Open Web Application Security Project (OWASP) and is still number one of web application risks [19], where the input of users used without sanitizing by application. [20] There are many attacks which infect web application. Fig.6. represents a diagram of the attack rate in web applications [20]. The most dangerous attack is SQL Injection (SQLI). This attack infects web application, by lack of variable input filtering. It attempts to access the database table of websites if the webserver didn't have any protection against this attack [10][9]. This proposed system focuses on the SQLI attack by solving the weak user input by detecting and preventing this type of attack. The user input passed dynamically in web application to create SQL statement Fig.7. describes the steps of URL (Uniform Resource Locator) requested. After being realized by the attacker, the web application is vulnerable to SQLI, he will inject a query of SQL commands to try stealing important information of the victim [21]. The problem is characterized by setting up a number of rules which define the problem [11]. The program is then converted into a model that represents the flow of the program. The solution to the problem will then be gradually approached by an algorithm that applies the defined rules on the model. The algorithm wills stop when it cannot get closer to an answer. [17]. There are many serious risks resulted in a SQL injection attack as follows: - Hacking person account. - Stealing, copying data, changing the configuration of application, viewing, and deleting sensitive, private data (users’ profiles). - Allowing users to log in to the application as another user even administrator. - Modifying database structure and deleting database application tables. - Controlling databases server and running its commands. To prevent the above serious risks, it led to prepare a protection system against this type of attack. The proposed system (SQLIAD) aims to improve the user input by filtering it from malicious attacks on a dynamic web application using AST tools in python 3.7., before posting to the server. Many developers of web applications neglecting the high risks of SQLI on confidentiality and security of stored data. SQLIAD tool generates a report for each web application test to declare this web vulnerable or not. Many webpages accept user input such as search item, password, and username to be used in building an SQL query, posted to the database. Such input, if it is malicious code for e.g. it can delete specific information within client records webpage tables. 9. ANATOMY OF SQLI The query of SQL has arguments that tell the database system to return the required records. These arguments sent by the user in the form of field name, URL, etc. There are two stages of SQLI: - Research Stage: The attacker submits different unexpected values as arguments, and observes the application's reaction to determine the attack. - Attack Stage: Attackers provide an input argument to query of SQL to command part of it, while the database will execute that command as modified data by attacker. 10. TYPES OF SQL INJECTION There are different types of SQLI attacks Fig.8. shows these types. The attacker extracts server data by exploiting the vulnerabilities of websites. All these attack types depend on retrieving databases on-conditions (T/F), errors on timing. Fig. 8. types of SQLI attack Such as: 1. Error Based: In this type of SQLI the attacker can fetch details of database tables such as names and other contents of visible database errors, this can be identified by attacker on the production servers. To prevent such attacks, it should avoid displaying error database messages, which prevents the attacker from fetching this information, for e.g. the following request will return an error.[18] https://example.com/index.php?id=1+and(select 1 from (select count(*), cocat ((select (concat(database())) From information_schema.tables LIMIT 0,1), Floor(rand(0)*2)x FROM information_schema.tables GROUP BY x)a) Duplicate entry ‘database1’ for key ‘group_key’ Request query Error response 2. Blind Based divided into two parts: a. Boolean Errors: In this type of attack the web browser does not display error through failing of SQL query which the attacker inserts a condition to be false to SQL query to extract data from database system. Such condition will be inserted to check the website vulnerable. If the website loaded normally that gives an indicator to the attacker that this website is good for SQLI attacking. To confirm this doubt, the attacker will send another request such as the following: https://xyz.com/index.php?id=1+AND+IF(version()+LIKE+'8%',sleep(3),false) To detect this attack a proposed tool was designed to connect all the information of user input with the sensitive code to find the place of danger.[19] 11. AST MODULE AST is a mnemonic of "Abstract Syntax Trees". AST is a built-in module in Python. AST is a data structure that lets the user check, analyze, edit code easily and process the python abstract grammar. In this module, the source code of programming language is converted to an abstract tree. The node of the tree stands for different states in the source code. The most important class used in SQLIAD and derived from the base class ast.AST parser is "ast.NodeVisitor" class. Class "ast.NodeVisitor" is used in parsing tree node to call visitor function for each node found, the return value forwarded to visit () function. If the returned value is "none", the node will remove from tree, otherwise, the node will be replaced by the return value. In SQLIAD this article was used in detecting SQLI vulnerabilities in web applications using python3.7. This module contains a parsing method for constructing AST from the existing python code string. The standard library of AST is generated by (pip install ast) command. The source code of the web app is parsed to generate AST tree and CFG flow graph using the AST module. Fig. 9. shows an example of using AST. AST traversed systematically to turn by CFG (Control Flow Graph) components into a standard control flow graph. Fig. 10. represents some rules of the AST tool. CFG is a directed graph where the specific place in the program represents a node, while the option of the responding. If the website rejects that and loads without waiting it means that the page is not vulnerable. The query of SQL here like Boolean attack but the difference is sleep function in a query. For e.g., if the sleep time=3 seconds, the attacker instructs the database to sleep for 3 seconds like the following: https://xya.com/index.php?id=1+AND+IF(version()+LIKE+'8%',sleep(3),false) code is represented by edges of the graph. Fig.11. illustrated the conversion from AST to expected CFG. In this example AST visualized as a tree, the first node contains a test node. The body and or else body is implemented by a nodes list. NameConstant nodes considered as conditions, but all statements considered as assign nodes. The predecessor given nodes denoted by "pred(n)" command while the successor's nodes denoted by "succ(n)" command. The CFG has two entries like any directed graph, first called "entry node", second called "exit node". The working with AST needs to represent the relations between expressions, operator, functions, and objects of python language. ![Diagram](image.png) **Fig.9.** syntax tree for code (x=6) in python ``` mod = Module ( stmt* body ) stmt = Assign ( expr * target s , expr value ) expr = Num( object n) Name( identifier id , expr_context ctx ) ``` **Fig.10.** some of AST rules ![Image](image.png) **Fig.11.** example code converted to AST and CFG form, (a) Example Code (b) AST form (c) expected CFG ### 12. SQLIAD PROPOSED SYSTEM To demonstrate SQLIAD at first it designed a simple web application using a flask tool in python (see Fig.12.). After setting up many tools like flask (“pip install flask”), sqlite3 (“pip install sqlite3”), Django (“pip install Django”) and installing Virtual Environment using (“pip install virtualenv”) after that a virtual environment was created using (“mkvirtualenv myproject”) and activate command used to activate a virtual environment. A command (“python webapp.py”) used for browsing designed web applications. See Fig.13. The output of calling designed web application using explorer like in Fig.14. **Fig.12.** web application code using python Flask tool **Fig.13.** report of Http status code 13. ALGORITHM OF SQLIAD The algorithm of finding SQLI attacks (see Fig. 15) in a web app is as follow: Step 1: Get URL to be source code. Step 2: Analyze source code using AST (Abstract Syntax Trees) module to get CFG. ("Control Flow Graph "). Step 3: The output of step 2 will input to Framework Adapter. Step 4: Analyze the result from step 3. Step 5: All Vulnerabilities will be spit out and reported with the output. The module AST is a base class for every AST node class, contains many subclasses like (ast_helper), ast.parse (f.read), (generate_ast), (FrameworkAdaptor) (ast.NodeVisitor), … etc. Each class is responsible to do some functions. Python used the library of AST tools. The class (ast_helper) used for parsing (splitting) the source code of test web app into a list of tokens, to produce AST abstract tree. The AST tree is a collection of nodes linked together by edges, based on python language grammar. Sent to ast.parse(source.read()) to generate graph form CFG file, as an object tree. The (ast.NodeVisitor) track all the nodes of the AST tree to call visit (node) function for every tree node, to return a value. The NodeVisitor class used for tree scanning. The user input is called source code that parsed to AST to presents each file by it. Fig.16, shows a simple example of converting from AST to graph. By using CFG (Control Flow Graph) command the AST traversed to CFG form. The output of CFG sends to Flask adaptor (is an effective tool to test client requests without running Flask server). The fixed-point algorithm was applied to the resulting CFG to produce the resulting nodes. At the end of the invitation of CFG, the precise potential vulnerabilities information found by analysis. Through designing SQLIAD a Framework Adaptor class was used for converting data from one structure to others. It is contained with a list of CFGs. This adapter used Django and Flask in implementation. In Flask all web apps can be defined as decorator function. There was a Flask Adapter tool that goes to functions of all webpages for finding the defined function by @app.route() decorator for adding to the CFGs list. The outcome is a CFG list that covers all needed code application analysis. Fig.17, represents the code of FlaskAdapter. The analysis in step (4) used a flexible fixed-point algorithm applied on the CFG list, the fixed point means perform iterate analysis of dataflow until nothing changing, this statement is known as a fixed point. --- **Example** - Source Code \[4 \times (2+3)\] - Parser input `NUM(4) TIMES LPAR NUM(2) PLUS NUM(3) RPAR` - Parser output (AST): - `ast.NodeVisitor` track all the nodes of the AST tree to call visit (node) function for every tree node, to return a value. - The NodeVisitor class used for tree scanning. - The fixed-point algorithm was applied to the resulting CFG to produce the resulting nodes. --- **Fig.16.** example of converting AST to graph ![Image](image1.png) **Fig.17.** FlaskAdapter code ```python # adapter.py - C:/myproject/flask7-6/sql/pyt_master/adapter.py (36.6) # """ Adaptor for Flask web applications. """ import ast from framework_adaptor import FrameworkAdaptor from ast_helper import get_call_names, Arguments from cpg import build_function_cpg from module_definitions import project_definitions from framework_adaptor import TaintedNode class FlaskAdaptor(FrameworkAdaptor): """ The flask adaptor class manipulates the CFG to adapt to flask applications. """ def get_last(self, iterator): """ Get last element of iterator. """ item = None for item in iterator: pass return item def is_flask_route_function(self, ast_node): """ Check whether function uses a decorator. """ for decorator in ast_node.decorator_list: if isinstance(decorator, ast.Call): if self.get_last(get_call_names(decorator.func)) == 'route': return True return False ``` --- 10 14. DETECT VULNERABILITIES IN A WEBSITE The SQL injection means that the input user reaches to the database query. A special tool was created to detect dangerous vulnerabilities by connecting information for sensitive code and user input. By building such a tool, a technique for static analyzing source code, to get some properties where used. The aim here is to track input and decide if it is harmful or not. The function that filters the input is called sanitizer. To represent this idea a python model was designed by setting up several tools that solved this problem. The python program is converted to another model using a special algorithm to implement the flow of the program. The mistake that causes SQL Injection is using the formatting string in statement of SQL. The functions (execute, executemany) used in the SQuLiAD app for searching for a string formatting to prevent SQL injection. There are (3) methods used in python for formatting string to avoid any injection code. Fig.18. explains the ways of python for formatting string. ``` c.execute("Select usernamerank FROM users Where rank = '0'".format(rank)) c.execute("SELECT username,r ank FROM users WHERE rank='%s' % rank") c.execute("SELECT username,rank FROM users WHERE rank = '{rank}'") ``` Fig.18. formatting string in python The "execute (query,Vars=None)" command in python used to execute the specified query. The Executemany(query,var_list) will execute database queries against all parameters in the vars-list sequence. (See Fig.19.). ``` import ast import re SQL_FUNCTIONS = { 'execute', 'executemany',} SQL_OPERATORS = re.compile('SELECT|UPDATE|INSERT|DELETE', re.IGNORECASE) class ASTWalker(ast.NodeVisitor): def __init__(self): self.candidates = [] self.variables = {} def visit_Call(self, node): # Search for function calls with attributes, e.g. cursor.execute if isinstance(node.func, ast.Attribute) and node.func.attr in SQL_FUNCTIONS: self._check_function_call(node) # Traverse child nodes self.generic_visit(node) def visit_Assign(self, node): if not isinstance(node.targets[0], ast.Name): return self.generic_visit(node) variable, value = node.targets[0].id, node.value # Some variable assignments can store SQL queries with string formatting # Save them for later. if isinstance(value, (ast.Call, ast.BinOp, ast.Mod)): self.variables[variable] = node.value self.generic_visit(node) def _check_function_call(self, node): if not node.args: return first_argument = node.args[0] query = self._check_function_argument(first_argument) if query and re.search(SQL_OPERATORS, query): ``` Fig.19. code of SQuLiAD app in python 15. SQuLiAD RESULTS This section represents running the proposed system. SQuLiAD is a command-line tool that needs one argument, file path name with some parameters to be analyzed like "python wascan.py webapp_path". Because of the dangerous SQL injection attack, proposed developed tools were prepared (SQuLiAD) to create a parser detector of SQL injection. These tools are smart and easy to use that takes a web app, analyze it and detect all type of SQL injection. The steps of running SQLIAD module to get output by generating a parsing report of a web application to declare, if it is a vulnerability web application or not as follows: - Parsing command line with argument. - Generating AST ("Abstract Syntax Tree"). - Generating CFG ("Control Flow Graph") from generated AST. - The generated CFG pass to Framework Adapter, which mark the argument functions as tainted sources. - Analysis and modify reaching definition by knowing the reaching definitions. - Finding the vulnerabilities by vision how and where sources reach. - Remove all suspicious vulnerabilities. - Output analysis report into the console. The output of SQLIAD like in Fig.20a Fig.20b illustrated reports of testing http://sqlfiddle.com, http://target.com vulnerable web applications. ![Fig.20.a output of SQLIAD](image1) ![Fig.20.b output of SQLIAD](image2) After analyzing http://Facebook.com, SQLIAD declares this page is a vulnerable web application with a blind SQL injection. See Fig. 21. 16. CONCLUSION SQL injection is a modern attack on a web application; it is not commonly known to the general world. It takes a lot of time for understanding what it is, and how it can be detected and protection from it. Because of the wide vulnerability of web applications and the problems caused by it, an SQLIAD tool was prepared to detect and protect the web application from any attack like SQL injection. A python3.7 programming language with a Flask tool was used in designing SQLIAD. SQLIAD were used to test and analyze many different web applications. SQLIAD was evaluated, to be able in finding all types of SQLI attack and it is flexible in updating and easy to apply in any web application. 17. ACKNOWLEDGMENTS This work is impossible without the help of OWASP group, YouTube, and many helpers of python documents. I am grateful to all people who participated in designing and assisted in writing this paper. I would also like to thank the members of the Tikrit Journal for their effort. Fig.21. analyzing report of http://Facebook.com REFERENCES
{"Source-Url": "http://www.tj-es.com/wp-content/uploads/2020/vol27/no2/vol27no2p1.pdf", "len_cl100k_base": 6666, "olmocr-version": "0.1.50", "pdf-total-pages": 14, "total-fallback-pages": 0, "total-input-tokens": 36368, "total-output-tokens": 8295, "length": "2e12", "weborganizer": {"__label__adult": 0.0006031990051269531, "__label__art_design": 0.00045108795166015625, "__label__crime_law": 0.004268646240234375, "__label__education_jobs": 0.0007600784301757812, "__label__entertainment": 0.00011801719665527344, "__label__fashion_beauty": 0.00021839141845703125, "__label__finance_business": 0.00018787384033203125, "__label__food_dining": 0.0005087852478027344, "__label__games": 0.0011320114135742188, "__label__hardware": 0.0015974044799804688, "__label__health": 0.0009016990661621094, "__label__history": 0.00027060508728027344, "__label__home_hobbies": 0.0001354217529296875, "__label__industrial": 0.0006504058837890625, "__label__literature": 0.0002999305725097656, "__label__politics": 0.00039505958557128906, "__label__religion": 0.0004630088806152344, "__label__science_tech": 0.05572509765625, "__label__social_life": 0.00013589859008789062, "__label__software": 0.027313232421875, "__label__software_dev": 0.90283203125, "__label__sports_fitness": 0.0004184246063232422, "__label__transportation": 0.0004515647888183594, "__label__travel": 0.00020492076873779297}, "weborganizer_max": "__label__software_dev", "avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_ratio": [[0, 34112, 0.02847]], "fineweb_edu_fasttext_gt2__fineweb_edu_fasttext_gt2__score": [[0, 34112, 0.84746]], "ft_lang_id_en_doc_v2__ft_lang_id_en_doc_v2__en": [[0, 34112, 0.84939]], "google_gemma-3-12b-it_contains_pii": [[0, 2464, false], [2464, 7241, null], [7241, 11282, null], [11282, 14848, null], [14848, 16413, null], [16413, 19756, null], [19756, 20848, null], [20848, 21556, null], [21556, 22308, null], [22308, 25565, null], [25565, 28706, null], [28706, 29728, null], [29728, 32623, null], [32623, 34112, null]], "google_gemma-3-12b-it_is_public_document": [[0, 2464, true], [2464, 7241, null], [7241, 11282, null], [11282, 14848, null], [14848, 16413, null], [16413, 19756, null], [19756, 20848, null], [20848, 21556, null], [21556, 22308, null], [22308, 25565, null], [25565, 28706, null], [28706, 29728, null], [29728, 32623, null], [32623, 34112, null]], "google_gemma-3-4b-it_v2tag__is_academic_paper": [[0, 5000, true], [5000, 34112, null]], "google_gemma-3-4b-it_v2tag__is_class_syllabus": [[0, 5000, false], [5000, 34112, null]], "google_gemma-3-4b-it_v2tag__is_completion_certificate": [[0, 5000, false], [5000, 34112, null]], "google_gemma-3-4b-it_v2tag__is_court_notice": [[0, 5000, false], [5000, 34112, null]], "google_gemma-3-4b-it_v2tag__is_homework_assignment": [[0, 5000, false], [5000, 34112, null]], "google_gemma-3-4b-it_v2tag__is_news_article": [[0, 5000, false], [5000, 34112, null]], "google_gemma-3-4b-it_v2tag__is_public_order": [[0, 5000, false], [5000, 34112, null]], "google_gemma-3-4b-it_v2tag__is_resume_cv": [[0, 5000, false], [5000, 34112, null]], "google_gemma-3-4b-it_v2tag__is_test_or_quiz": [[0, 5000, false], [5000, 34112, null]], "google_gemma-3-4b-it_v2tag__is_textbook": [[0, 5000, false], [5000, 34112, null]], "pdf_page_numbers": [[0, 2464, 1], [2464, 7241, 2], [7241, 11282, 3], [11282, 14848, 4], [14848, 16413, 5], [16413, 19756, 6], [19756, 20848, 7], [20848, 21556, 8], [21556, 22308, 9], [22308, 25565, 10], [25565, 28706, 11], [28706, 29728, 12], [29728, 32623, 13], [32623, 34112, 14]], "pipe_delimited_lines_v1__pipe_delimited_lines_v1__pipe_delimited_lines_ratio": [[0, 34112, 0.04887]]}
olmocr_science_pdfs
2024-11-28
2024-11-28
d083a0f0fd41289d5505e7782fa4659f3c2ff559
1. Introduction Icon is a high level general-purpose programming language with extensive features such as string processing, advanced data and control structures and built in operators. It may be classified under the procedural and imperative paradigms of programming languages. Icon has been widely used for scripting and rapid development tools owing to its strong string manipulation abilities and lucid, compact and yet highly expressive program structure. 2. History of Icon Icon was developed at the University of Arizona in the late 1970s by Dr. Ralph Griswold and team. It has been influenced by SNOBOL4 and SL5. It supports all major operating system platforms and some lesser known ones such as Acorn Archimedes and VAX/VMS. The Icon project is still ongoing and there have been some interesting extensions to the language such as: - Unicon (Unified Extended Icon) 1997 -1999 has support for object-oriented programming, systems programming, and programming-in-the-large. - JIcon - A Java based implementation of Icon. - MT Icon- Multitasking Icon. 3. Applications Icon was most appropriately used to develop applications which require lesser development time and programming effort. It is especially strong at building software tools, for processing text, and for experimental and research applications where short effective programs are required. Programming tasks that require extensive manipulations of strings and structures such as compilers, word processors, and databases made extensive use of the language. Not only has it been useful for short, single use programs but also in very complicated applications that involve complex data structures. Some of the areas where Icon has been effectively used include artificial intelligence, natural language processing, research applications, expert systems, rapid prototyping, program generation, symbolic mathematics, graphic displays and text processing (for analysis, editing, document formatting and generation). 4. Language Features Icon has some distinguishing features in terms of control constructs and data structures which make it a powerful language. Some of Icon’s prominent features are discussed below. 4.1 Expression Evaluation Icon differs significantly from other programming languages when it comes to expressions. It has an expression-oriented syntax and the expression evaluation mechanism is unique as it integrates goal-directed evaluation and control backtracking. An expression in Icon can have one of the following outcomes. 1. Succeed producing a result (Eg: the expression \( 4 > 3 \) succeeds and the result is 3) 2. Fail producing a null value (Eg: the expression \( 1 = 0 \) fails) An operation in Icon is performed only if evaluation of all operands succeed. Goal-directed evaluation refers to this automatic searching among alternative results. For example: \[ \text{min} < (x \mid 5) \] first compares min to x. If min is less than x, evaluation succeeds and produces the value x. If not, min is compared to 5, the next value generated by the subexpression x \( \mid 5 \). If min is less than 5, evaluation succeeds and produces 5. Otherwise, evaluation fails, and no value is produced. Thus failure drives control expressions in Icon. This allows the concise formulation of many programming tasks by handling errors implicitly. For example the following code \[ \text{line} := \text{read()} \& \text{write(line)} \] can read consecutive lines from an input file until the end of file and write them to the standard output. However, the control backtracking in Icon is limited to the expression in which it occurs. For example in: \[ \text{max} := \text{max} < x \\ \text{write}(\text{"y="}, (x \mid 5) > y) \] failure in the second expression does not affect the outcome of the first. Another example of goal-directed evaluation is \[ \text{find("on", line1) = find("and", line2)} \] which succeeds if "or" occurs in line1 at the same position as "and" occurs in line2. 4.2 Generators In Icon generators are used to iterate through multiple outcomes of expressions which produce more than one result. They are similar to iterator-based control structures found in other languages but different in many aspects. The following language constructs can construct a generator: • expression that can generate a sequence of values • every expression • to and to-by operator (generates the integers from one value to another ) • element generation operator \( ! \) ( \( !x \), generates all values of \( x[i] \) for 1 to number of elements in \( x \) ) • repeated alternation \( (\mid 1 \), generates a integer 1, infinite times, \( \text{expr1} \mid \text{expr2} \) generates the results of \( \text{expr1} \) followed by the results of \( \text{expr2} \). • seq(\(..\)) generation ( \( \text{seq}(i) \) - generates i,i+1,i+2,...) For example: \[ \text{line1 := "Python is like Icon"} \] \[ \text{find("on", line1)} \] Here "on" occurs in line1 at positions 5 and 18 and both are successful outcomes of the expression. Generation is inherited like failure, and thus the following expression. \[ \text{every write(find("on", line1))} \] produces the same result as above. The results that a generator produces depend on context. In a situation where only one result is needed, the first is produced. For example: \[ \text{i := find("on", line1)} \] assigns the value 5 to i. If the result produced by a generator does not lead to the success of an enclosing expression, however, the generator is resumed to produce another value as illustrated in the previous section. For example: \[ \text{if (i := find("on", line1)) > 15 then write(i)} \] Here the first result produced by the generator, 5, is assigned to i, but this value is not greater than 15 and the comparison operation fails. At this point, the generator is resumed and produces the second position, 18, which is greater than 15. The comparison operation then succeeds and the value 18 is written. Another example of a generator is \[ \text{every write(find("on", line1 / line2))} \] which writes the positions of "on" in line1 followed by the positions of "on" in line2. The alternation operator \[ (i \mid j \mid k) = (0 \mid 1) \] succeeds if any of i, j, or k has the value 0 or 1. 4.3 String Operations Text processing was one of the main design goals of Icon and hence the language has a large repertoire of operations for string analysis. Strings in Icon are true first-class objects, not arrays of characters. The string scanning operation has the form \[ \text{s ? expr} \] where s is the subject string to be examined and expr is an expression that performs the examination. A cursor is set at the first position of the string (before the 1st character). The function, move(i), moves the position of the cursor by i and produces the substring of the subject between the previous and new positions. For example, \[ \text{line ? while write(move(2))} \] writes successive two-character substrings of line, stopping when there are no more characters. Functions such as tab(), find(), upto(), many() etc can be used in string scanning as well. For example, \[ \text{line ? while write(tab(find("or")))} \] \[ \text{do move(2)} \] writes all the substrings of line prior to occurrences of "or". Another example ```icon line ? while tab(upto(&letters)) do write(tab(many(&letters))) ``` writes all the words in the file. The expression `tab(upto(&letters))` advances the position up to the next letter, and `tab(many(&letters))` matches the word and assigns it to word. The while terminates when `tab(upto(&letters))` fails because there are no more words in line. Apart from these there are string editing and conversion operations which make string processing easy. For example, ```icon s := map("fg/ij/cd","cdefghij",&date) ``` converts the string date from one format to the other. Icon also provides support for regular expressions in order to enable pattern matching. ### 4.4 Structures Structures in Icon are first class data values and can be heterogeneous; that is, the same structure can contain values of different types. String-processing tasks require structures to organize data-- lists of strings, symbol tables, and so on. Icon provides four kinds of built-in structures: records, lists, sets, and tables. - a) Records are the basic structures in Icon and are similar to the “struct” construct of C and other languages. - b) Lists are sequences of values of arbitrary types. ```icon L := list(i, x) creates a list of i values, each of which has the value x while list1 = ["language", "icon", 78, 25] ``` creates list1 with four values, two of which are strings and two of which are integers. A member of a list is referenced by its position. Thus, ```icon list1[3] := 78 and list1[8] fails because it is out of range. ``` The values in a list L are generated by `!L`. Thus ```icon every write(!L) ``` writes all the values in L. Lists can be manipulated like stacks, vectors and queues. The standard push, pop, enqueue and dequeue operations could be done on these data structures. - c) Sets are collections of distinct values. An empty set is created by `set()`. Alternatively, `set(L)` produces a set with the values in the list L. For example, ```icon S := set([1, "icon", []]) ``` assigns to S a set that contains the integer 1, the string "abc", and an empty list. The operations union, intersection, and difference can be performed on sets. The function `member(S,x)` succeeds if x is a member of the set S but fails otherwise. The function `insert(S, x)` adds x to the set S, while `delete(S, x)` removes x from S. IS generates the members of S. - d) Tables are sets of key-value pairs and provide a form of associative lookup. The key and its corresponding value may be of any type, and the value for any key can be looked up automatically. An empty table is created by the expression ```icon cars := table(0) ``` which assigns to cars a table with the default value 0. The default value is used for keys that are not assigned another value. Subsequently, symbols can be referenced by any key, such as: ```plaintext cars["honda"] := 1 ``` which assigns the value 1 to the key "honda" in cars. Tables grow automatically as new keys are added. The function `sort(T, i)` generates a list by taking the ith values from the table T. ### 4.5 Procedures An Icon program consists of one or more procedures consisting of expressions separated by newlines or semicolons. Control flow starts from the main procedure. A procedure may take arguments and may return a value of interest. A procedure declaration has the form: ```plaintext procedure name (parameter-list) local-declarations initial-clause procedure-body end ``` The parameter list is optional and consists of identifiers separated by commas: A procedure in Icon can either: - succeed producing a valid result - fail returning null value or - suspend giving control to another procedure The return and fail expressions cause return from a procedure call and destruction of all dynamic local identifiers for that call while suspend leaves the call in suspension with the values of dynamic local variables intact. The procedure call can be resumed to continue evaluation. For example: ```plaintext procedure main() every write(Invert(-3, 3)) every write(Invert(-5)) end procedure Invert(i, j) /j := i while i <= j do { suspend -i i +:= 1 } fail end ``` has the main procedure calling Invert() twice. The Invert procedure has a loop which can be suspended. At the end of the loop, the fail keyword is used to return null value from the procedure. The output of this program is 3 2 1 0 -1 -2 -3 5. 4.6 Co-Expressions A co-expression in Icon is a data object which captures the state of an expression. It is a reference to an expression and can be used to suspend and resume an expression as and when necessary. It gives a finer granularity to the control flow in an Icon program. A co-expression is created by \[ \text{co-expr}_{\text{name}} := \text{create expr} \] Co-expressions can be used for the generation of results from generators in parallel. For example, ```icon procedure parallel(a1, a2) local x repeat { if x := @a1 then suspend x else fail if x := @a2 then suspend x else fail } end ``` where a1 and a2 are co-expressions. The results for `parallel(create !&lcase, create !&ucase)` are "a", "A", "b", "B", ..., "z", and "Z". parallel(a1, a2) terminates when either a1 or a2 runs out of results. 4.7 Data Types Icon is a weak dynamically typed language. Types are associated with values themselves and not the variables thereby saving the programmer from the burden of type declarations. Any variable may be assigned a value of any type and later assigned a value of a different type either implicitly (depending on the operation at runtime) or explicitly by using conversion functions. However there are some conversions which Icon does not allow. Built-in data types include numerics (integers, reals, floating points), character sets, strings, sets, lists, associative tables, records, and procedures. 5. Icon: A Programming Language Perspective In this section we look at Icon from a programming language perspective i.e. we discuss Icon in the light of the “properties” of a programming language that we have learnt in class. 5.1 Procedures Icon does not have any block structure, and hence nested procedures are not permitted. Functions and procedures are essentially similar in Icon. Functions are procedures that are provided by the Icon libraries. Both procedures and functions are first-class objects that can be assigned to variables, may be passed as arguments in procedure calls, and so on. Variables in the parameter list are usually called-by-value. Each formal parameter is assigned the value of the corresponding actual parameter. Since mutable objects are accessed using a pointer, the pointer is copied to the formal parameter and both the formal and the actual parameters point to the same object, which resembles call-by-reference. Lists for example are mutable objects while strings are immutable. If there are fewer actual parameters than formal, then the extra formal parameters are assigned the default value `&null`. Procedures in Icon are essentially generators too. They can return a value, no value or a sequence of values, using fail, return and suspend keywords correspondingly. 5.2 Preprocessing Icon programs are preprocessed before they are compiled or interpreted. During preprocessing, constants can be defined, other files may be included and regions of code can be included or excluded, depending on the definition of constants. Preprocessor directives are indicated by a $ at the beginning of a line, as in $define PI 3.14 which defines the symbol PI and gives it the value 3.14. Subsequently, whenever PI appears in the source program, it is replaced by 3.14 prior to compilation. $define directive is thus basically a macro definition and is expanded before any syntactic or semantic analysis of the source is done. $include is another directive that may be used to link modules prior to compile time, however all the modules linked together exist in the same namespace. So the programmer has to be careful when linking modules so as to not cause any identifier name conflicts. 5.3 Coroutines Coroutines can be realised in Icon using the co-expressions feature. A co-expression can transfer control to another co-expression using language contracts (using create and then call using @co-expression_name) or returning control implicitly by producing a result. This kind of switch of control changes the location of program execution and the environment in which the subjected expressions are evaluated. The difference here is that, transfer of control is not hierarchial like in procedure calls as it can switched to any desired location based on what co-expression is called using @. 5.4 Scope Rules Variables in Icon can be of local, static or global types. Scope determines the identifiers a procedure can access. Icon uses lexical scoping. Locals are created when a procedure is entered and deleted when it returns. The names of these identifiers are known only within the procedure. If an identifier is used without declaration it is assumed to be local. Static variables are created when the program starts executing. The values of static variables are retained across procedure calls. Their scope is within the procedure where they are declared. Globals are also created when the execution of the program starts. These names are visible only inside all the procedures that do not declare the same names for local or static variables. Every global variable has a single copy. There are some other keywords, whose scope is global, and need to be declared outside any procedure. One such keyword is record(.........) which declares a structure with sub-fields given in the declaration. The other is link name, which is used to indicate the linker to use procedures, records or global variables declared in the file named name. 5.5 Binding Icon has dynamic binding for variable names. In Icon variable names are not bound to types. Objects are bound to types. Names can be used to point to any type of object at point in the source program and perform related operations on them. As long as the objects that form the operands in an operation are of the required Icon run-time system permits it. Link time binding occurs when various libraries are joined together by the linker when instructed using the link keyword. 5.6 Polymorphism Icon supports polymorphism in terms of polymorphic operations. Although, the meanings of operations cannot be changed during program execution, several operations perform different computations depending upon the types of their operands. Thus, x[i] may subscript a string, list or a table. The meanings of some operations also depend on whether they occur in an assignment or a dereferencing context. Eg. If s is a string, assignment to s[i] occurs in an abbreviation for a concatenation followed by an assignment to s, while if s[i] occurs in a context where its value is needed, it is simply a substring operation. Moreover, the context cannot, in general, be determined at translation time. Eg. 1. \( s := \text{"ad"} \) \[ s[3:3] := \text{"a"} \quad \# \text{concatenation followed by assignment, } s \text{ is now } \text{"ada"} \] \[ \text{write}(s[1:3]) \quad \# \text{substring operation} \] 2. \text{write}(*str) \quad \# \text{gives the size of the object, be it a string, list or table} 5.7 Typing Icon is different from conventional languages when it comes to typing. In Icon variables are not given explicit types. The operations done on the variables decide the type of the variables involved in that operation. Eg. \( a = b \) means a compare on binary or on integers. \( a == b \) means a compare on strings. \( a === b \) means a compare on lists. Since operators determine the type of the variable, Icon compensates for this by providing lots of operators. Also, due to this programs in Icon are a bit verbose, as every operator has to effectively encode the required type of the operands. But, at the same time the readability is improved since the presence of a particular operator clearly states the kind of operation that will be performed. The disadvantage is that since the type system is so dynamic, the compiler cannot perform any optimizations since the exact type is not till runtime. There are four types among which mutual type conversion is supported, strings, csets, integers and real numbers. Some conversions can be conditional, such as an integer conversion to real number is done only if the value is in the range of a C long. Here the dotted lines indicate conditional conversion. Some conversions are natural and occur frequently, such as string to integer and vice versa. But some others are not, like cset to integer. These conversions are then done in a two-step process to reduce the number of conversion routines. cset is converted to a string first and then to an integer. 6. Implementation Details 6.1 The Icon Virtual Machine The Icon implementation uses the virtual machine approach. Virtual machines serve as an abstraction for the underlying real machine. Using virtual machines a single common model can be developed that can be ported across various hardware architectures, even when operations of a language do not fit a particular architecture. However, Icon’s implementation of the virtual machine doesn’t rigidly specify a structure for all aspects of the language such as type checking, storage allocation and garbage collection. 6.2 Components of Implementation The implementation is comprised of three major components: i) a translator, ii) a linker and iii) a run-time system. The translator is like a compiler, it converts an icon program to virtual machine instructions, known as ucode, which is ASCII text. Linker combines one or more ucode files into a single program for the virtual machine. The linker output is called icode, which is a binary representation for compactness and ease of processing by the virtual machine. Icon program → translator → ucode → linker → icode The run-time system consists of interpreter for icode and a library of support routines to carry out various operations that may occur when an Icon program is executed. The interpreter serves as a software realization of the Icon virtual machine. The creators’ note that the difference in execution speeds between a linked executable and interpreted code is insignificant, the reason being the executable generated is for the virtual machine and not a real machine, which still has to make run-time library routine calls to execute the virtual machine instructions. 6.3 Storage Management Storage Management in Icon accommodates requirements of a wide range of programs. It is designed to be fast and simple and is implicit and automatic. Objects are created as needed during program execution. They grow and shrink automatically and unused space is garbage-collected when necessary. There also is no limit on the size of objects other than the amount of available memory. Data is allocated in separate regions for different types of objects, namely static blocks, non-static blocks and strings. Static blocks are allocated in a static region and are never moved, though they can be reused. Co-expression blocks are allocated in the static region since their C stacks contain internal pointers that are difficult to relocate to another space in memory. Blocks and strings are allocated in separate regions, both using a free-list approach as shown. Garbage collection in Icon uses the marking and compaction technique. It is divided into two phases, location and compaction. The location phase locates all the roots and their children which are alive. During compaction the live objects are moved from “from” to “to” space and “from” space is cleared. Icon uses the predictive need mechanism for garbage collection. A predictive need request assures an adequate amount of space before the allocation and no garbage collection occurs during the following allocation request. The advantage of this is that garbage collector can be invoked at a safer time than the actual request allocation time while he disadvantage is that the maximum amount of storage must be determined and care must be taken to make predictive need requests prior to allocation. When garbage collection occurs all potentially accessible data must be reachable from the roots. This is not easy, as pointers to live objects may only exist in registers or on the C stack that the garbage collector cannot locate. Also, objects that are being constructed may temporarily hold invalid data. Hence, assuring that all live data is reachable and valid is difficult and error prone. Instead of garbage collection occurring as a by-product of an allocation request, the amount of space requested is reserved in advance. There are two routines, blkreq and strreq for which check the block and string regions respectively to assure availability of free space. 7. Missing features The following features are not supported in basic Icon: * Object Oriented programming * Exception Handling * Concurrency and related control structures * Modules with distinct namespaces However, extensions like Unicon adds OO features and MT-Icon adds multi-tasking functionality. 8. Summary Overall, Icon is a powerful language for scripting and rapid development. It has advanced control constructs, data structures and built-in functions which make it a feature rich language. It is easy to learn and program. Though today Icon is a dead language, it was probably ahead of its time and has influenced popular languages of today like Python, Perl & Ruby. On the negative side, Icon code can become increasingly complex to read as a single line of code is capable of a lot of computation and with different control constructs and a wide array of operators, code readability may be hindered considerably. References 1. http://www.cs.arizona.edu/icon 2. The Icon Programming Language, Ralph E. Griswold and Madge T. Griswold. 3. The Implementation of the Icon Programming Language, Ralph E. Griswold and Madge T. Griswold 5. The Icon Handbook
{"Source-Url": "http://www2.cs.arizona.edu/~collberg/Teaching/520/2008/Assignments/Icon.pdf", "len_cl100k_base": 5524, "olmocr-version": "0.1.50", "pdf-total-pages": 11, "total-fallback-pages": 0, "total-input-tokens": 22866, "total-output-tokens": 6159, "length": "2e12", "weborganizer": {"__label__adult": 0.0002830028533935547, "__label__art_design": 0.00021564960479736328, "__label__crime_law": 0.00017642974853515625, "__label__education_jobs": 0.00026869773864746094, "__label__entertainment": 4.631280899047851e-05, "__label__fashion_beauty": 9.107589721679688e-05, "__label__finance_business": 9.304285049438477e-05, "__label__food_dining": 0.0002613067626953125, "__label__games": 0.0003268718719482422, "__label__hardware": 0.0007228851318359375, "__label__health": 0.00019788742065429688, "__label__history": 0.00013077259063720703, "__label__home_hobbies": 5.072355270385742e-05, "__label__industrial": 0.00023806095123291016, "__label__literature": 0.00015628337860107422, "__label__politics": 0.0001119375228881836, "__label__religion": 0.0003445148468017578, "__label__science_tech": 0.003322601318359375, "__label__social_life": 5.125999450683594e-05, "__label__software": 0.0060882568359375, "__label__software_dev": 0.986328125, "__label__sports_fitness": 0.0001856088638305664, "__label__transportation": 0.00022804737091064453, "__label__travel": 0.0001291036605834961}, "weborganizer_max": "__label__software_dev", "avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_ratio": [[0, 25477, 0.02022]], "fineweb_edu_fasttext_gt2__fineweb_edu_fasttext_gt2__score": [[0, 25477, 0.71993]], "ft_lang_id_en_doc_v2__ft_lang_id_en_doc_v2__en": [[0, 25477, 0.9037]], "google_gemma-3-12b-it_contains_pii": [[0, 2029, false], [2029, 4877, null], [4877, 7327, null], [7327, 10044, null], [10044, 11756, null], [11756, 14517, null], [14517, 17672, null], [17672, 19860, null], [19860, 22790, null], [22790, 25189, null], [25189, 25477, null]], "google_gemma-3-12b-it_is_public_document": [[0, 2029, true], [2029, 4877, null], [4877, 7327, null], [7327, 10044, null], [10044, 11756, null], [11756, 14517, null], [14517, 17672, null], [17672, 19860, null], [19860, 22790, null], [22790, 25189, null], [25189, 25477, null]], "google_gemma-3-4b-it_v2tag__is_academic_paper": [[0, 5000, true], [5000, 25477, null]], "google_gemma-3-4b-it_v2tag__is_class_syllabus": [[0, 5000, false], [5000, 25477, null]], "google_gemma-3-4b-it_v2tag__is_completion_certificate": [[0, 5000, false], [5000, 25477, null]], "google_gemma-3-4b-it_v2tag__is_court_notice": [[0, 5000, false], [5000, 25477, null]], "google_gemma-3-4b-it_v2tag__is_homework_assignment": [[0, 5000, false], [5000, 25477, null]], "google_gemma-3-4b-it_v2tag__is_news_article": [[0, 5000, false], [5000, 25477, null]], "google_gemma-3-4b-it_v2tag__is_public_order": [[0, 5000, false], [5000, 25477, null]], "google_gemma-3-4b-it_v2tag__is_resume_cv": [[0, 5000, false], [5000, 25477, null]], "google_gemma-3-4b-it_v2tag__is_test_or_quiz": [[0, 5000, false], [5000, 25477, null]], "google_gemma-3-4b-it_v2tag__is_textbook": [[0, 5000, false], [5000, 25477, null]], "pdf_page_numbers": [[0, 2029, 1], [2029, 4877, 2], [4877, 7327, 3], [7327, 10044, 4], [10044, 11756, 5], [11756, 14517, 6], [14517, 17672, 7], [17672, 19860, 8], [19860, 22790, 9], [22790, 25189, 10], [25189, 25477, 11]], "pipe_delimited_lines_v1__pipe_delimited_lines_v1__pipe_delimited_lines_ratio": [[0, 25477, 0.0]]}
olmocr_science_pdfs
2024-11-30
2024-11-30
567be47cb506973a4d7d4cd3671a3e867ccc2b1b
A Uniform Resource Identifier Scheme for SNMP Rui Pedro Lopes Polytechnic Institute of Bragança, ESTiG 5300 Bragança, Portugal rlopes@ipb.pt José Luis Oliveira University of Aveiro, DET 3810 Aveiro, Portugal jlo@det.ua.pt Abstract – One of the World Wide Web characteristics, besides its omnipresence in computer systems, is the adoption of a universal user interface that is used to access several different services that were previously accessed individually by independent applications. The Internet resources started to be identified by URI schemes, a text string with specific syntax and grammar. Although existing for several services such as http, ftp, gopher and news, these identifiers are not used to identify SNMP resources. This paper proposes an URI scheme for identifying SNMP resources and presents some practical scenarios where the existence of such compact and complete identifying mechanism increases flexibility and functionality of network management applications. Keywords: SNMP, URI, URL, Network Management. I. INTRODUCTION The information, services or any other kind of resource that surface daily on the Internet has an associated naming space partially based on DNS. The resource identification is performed through text strings known as URI (Uniform Resource Identifiers) [1]. This string has all the necessary information to identify, to retrieve or, eventually, to update the resource configuration. Resources may have a physical nature, such as a processor, memory or storage devices, or a logical type, such as Web pages or network management agents. The resources are identified through references that reveal its address and nature. For example, an user mailbox is identified according to the scheme mailto:<name>@<address>. Despite the intrinsic differences that allow to catalogue different resources, each identification follows common concepts such as the resource name and address. This set of characteristics allows using a common syntax to locate them regardless of its nature. The uniform representation of references allows using identifiers for different resources in a common context. In the Internet, for example, the resources FTP, HTTP or NEWS are accessible by a common tool – the Internet browser. The resource is specified in the address field by the URI and, according to its grammar, it calls the appropriate tool for its processing and presentation. Network and systems management has been largely dependent on the SNMP framework [2] in which a typically centralized management station is used to deal with the information retrieved from, or delivered to, SNMP agents (the resources modeling). SNMP services are typically made available through specially designed APIs, which depend on a set of arguments for management information identification and on the required action. Besides the problem of different APIs supporting different and incompatible interfaces, the distinct versions of the SNMP usually require diverse parameters. Such as in the Internet situation, it is useful to integrate the tools, paradigms and models around a common context. In this paper we suggest using a specific URI scheme for SNMP thus solving the parameters dispersion associated to management operations. According to this view, the SNMP management may be based on a common tool, where different resources and operations are identified through particular URI semantics. The authors are using the SNMP URI scheme as an informal tool (in the graphical user interfaces) for the management of mobile agent platforms. Proprietary tools, standard CORBA interfaces or SNMP are the usually mechanisms for this goal. However, to deal with all these different access schemes, we are using specific URLs to differentiate them on a common context [3]. Recently, two more projects where found to share the same concept. One of them, iosnmp [4], is a plug-in to the K desktop environment [5] that, after registration, allows using the konqueror browser as a MIB browser along with the file system or HTML pages. This plug-in accepts URI schemes such as snmp://v3user@host:port/initialMibNode/ and supports only SNMPv3. At the security level it assumes the authNoPriv solution. Other parameters, such as the timeout and retries are not defined. The Cricket application is another example and it consists of a resource monitoring tool. It is configured by specific URLs, such as snmp://community@host:port/source, where the source stands for a managed object [6]. It supports only the SNMPv1 and SNMPv2c versions and like the previous example, it does not accept other parameters, such as timeout, retries or others. Despite individual limitations, these examples support the need for the existence of URLs to describe SNMP resources regardless of version, security parameters or services. This universal syntax can be used transparently across different applications. On the other hand, these three examples [3][4][6] are exclusively based in the manager side to provide access to management information. In this paper we seek to extend the SNMP URI formalism to the agent side as an identification mechanism more powerful than the OID (Object Identifier) to locate managed objects. The paper structure is the following. Section II describes the syntax and grammar to identify SNMP resources in an URI compatible form which we designate SNMP URL. In section III we present some practical scenarios. The first introduces an URL-TARGET-MIB an alternative to the SNMP-TARGET-MIB. The second shows how a SNMP URL may be used to extend the Expression MIB [7] to accept remote expression parameters, currently in research. The third shows how it can be used to manage mobile agents [3]. II. A UNIFORM RESOURCE IDENTIFIER FOR SNMP The URI concept was defined by the networks working group of the IETF (Internet Engineering Task Force) as a universal specification for physical or logical resources [1]. It has a generic syntax, suitable for identifying a broad set of resources namely web pages, email addresses, newsgroups and books, among many others. Currently IANA has already registered 36 URI schemes for as much services [8]. A. URI generic syntax At the first and higher level an URI scheme is as follows: [scheme:]scheme-specific-part[#fragment] The symbols ‘[’ and ‘]’ are delimiting optional sections and the symbols ‘:’ e ‘#’ stand for themselves and separate different URI sections. An URI is absolute when its schema exists and relative otherwise. A relative URI depends on an absolute URI to get the missing information, such as the scheme. URIs may also be classified as a hierarchy. In this case, the scheme specific part starts with the symbol ‘/’ and has the following format: [scheme:][/authority][path][?query][#fragment] The authority may be represented according to a hierarchical naming scheme (e.g.[user-info@]host[:port]). The path contains information to identify a given resource under the authority context. The section query has the information to be passed to and processed by the resource. Finally, the fragment has additional information to be used on the client side after the operation completes successfully. Theoretically, it does not belong to the URI since it is not used in the communication but it is frequently associated to it (for HTML bookmarks, for example). The URI urn:isbn:096139210x, which corresponds to a book, and mailto:penz@mail.hosting.pt, which refers to an email address, are non-hierarchical, or opaque according to the standard taxonomy. The URI http://www.ics.uci.edu/pub/ietf/url/#Related is both hierarchical and absolute because it has the scheme http and the scheme specific part starts with the symbol ‘/’. The authority represents an Internet name (www.ics.uci.edu) and the path identifies the resource /pub/ietf/url/, unique in this server. The fragment “Related” is only used by the Internet browser to automatically show the HTML page at this position. <table> <thead> <tr> <th>Model</th> <th>URI</th> </tr> </thead> <tbody> <tr> <td>HTTP</td> <td><a href="http://www.det.ua.pt">http://www.det.ua.pt</a></td> </tr> <tr> <td>FTP</td> <td>ftp://iprs@ftp.univ.pt/private/projectX/</td> </tr> <tr> <td>XMLORG</td> <td>xml:org/schema:xmelschema:xcatalog</td> </tr> <tr> <td>NFS</td> <td>nfs://server/a/b</td> </tr> <tr> <td>LDAP</td> <td>ldap://ldap.itd.umich.edu/o=U%20of%20Mich,c=US</td> </tr> <tr> <td>MAIL</td> <td><a href="mailto:rlopes@ipb.pt">mailto:rlopes@ipb.pt</a></td> </tr> </tbody> </table> B. SNMP parameters The functionality associated with SNMP entities, according to the SNMPv3 standard, is defined by grouping applications. These may be of five kinds: command generators, notification originators, command responders, notification receivers and proxy forwarders. A management agent is thus based on a command responder and a notification originator while a management station contains a command generator and a notification receiver. SNMP entities are identified by a number – the snmpEngineID. Each entity may have several contexts, unique for that entity. To identify each managed object they are necessary four parameters: the SNMP engine identifier (snmpEngineID), the context name (contextName), the object identifier (OID – ex. ifDescr) and the instance identifier (ex. ‘1’). For SNMPv1 and SNMPv2c, queries require only the OID and the instance, which is more simple but less flexible. The communication between SNMP entities follows a set of parameters, which identifies the communicating entities, security and the message processing. One of the fundamental aspects of the communication process is the security parameters, which varies with the model version. For SNMPv1 and SNMPv2c, privacy is inexistent and the authentication is based on a community name. SNMPv3 already allows message encryption, which guarantees privacy and user based authentication. For communication to succeed, it is necessary to indicate the protocol version. This is one of three choices: SNMPv1, SNMPv2c and SNMPv3. Moreover, it is necessary to associate with the protocol the destination address and the security parameters. These may be a single parameter for the first two versions – the community name string – or three parameters for SNMPv3: - Security model – SNMPv1, SNMPv2c, USM (User Security Model). - Username – character string. - Security level – no authentication and no privacy (noAuthNoPriv), authentication and no privacy (authNoPriv), authentication and privacy (authPriv). Moreover, it is necessary to pass to the security module the passwords or keys associated with the authentication and privacy protocols. The communication protocol may also require two more parameters: a) the time to wait for an answer before failing (timeout) and b) the number of attempts before giving up (retry count). Finally, to indicate the required resource it is necessary the context name, OID and instance. C. SNMP URL The SNMP URL collects all the information required for the communication between SNMP entities in a single character string following the URI format. According to the standard, a URI have restrictions in terms of symbols or characters not shown in this paper because of its extension. For further details, refer to [1]. Generically, the proposed syntax for the SNMP URL is: ``` snmpurl = scheme "://" [security "0"] [host_port] ["/" [resource]["/" [operation] ["/" [version] ["/" [context]]]]) ["/" parameters] scheme = "snmp" security = [community] | [user [":" auth [":" privacy]]] community = community - section 3.2.5 of [9] user = user name - section 2.1 of [10] auth = element_a ?("v" * element_a) element_a = "auth=" protocol_a | "pass=" key privacy = element_p ?("v" * element_p) element_p = "priv=" protocol_p ["pass=" key protocol_p = "privacy protocol - section 1.4.3 of [10] key = character string host_port = host [":" port] host = IP address or associated Internet name ``` Based on this syntax we can specify management information and services invocation in compact string as the following examples. For SNMPv1: ``` snmp://private@sw1.estig.ipb.pt/sysContact/0?op=set&value=Rui ``` For SNMPv2c: ``` snmp://private@sw1.estig.ipb.pt/sysContact/0?op=set&value=Rui?v2c ``` For SNMPv3: ``` snmp://rlopes@sw1.estig.ipb.pt/sysContact/0?op=set&value=Rui?v3 ``` The prefix ‘%’ is used to represent special characters. The combination ‘%20’ corresponds to the space character. Note that although allowing keys and other security parameters in SNMP URLs, this procedure is not recommended because it relies on clear text. This inconvenient may be solved by direct interaction with the user (requesting specific security information on a separate window, for example) or, when there is no interaction with the user, storing the sensible information on separate encrypted files. This last choice is used in some SNMPv3 applications in the agent role [12]. III. APPLICATION SCENARIOS FOR SNMP URL The first consequential shift related to SNMP URL usage happens at the API level. Usually, SNMP stacks require a large set of functions and a larger combination of function parameters. This varies with the version and with the product. For SNMPv3, for example, it is necessary to explicitly pass the message processing model (associated with the protocol version), the security model, the security name, the security level, engine ID, context name, operation, and associated parameters. A single SNMP URL contains all this information. As a consequence, it allows normalizing API function calling through different versions and different stacks. Moreover, it allows using different schemes to achieve higher-level protocol switching, such as HTTP or other. To better understand and illustrate the previous concept we will discuss a set of practical usage scenarios. The first two show how they can be used on the agent side while the last shows an example for the manager side. A. URL-TARGET-MIB SNMP applications may contact other applications, possible remote, to retrieve some data or to send notifications. The SNMP architecture defines the SNMP-TARGET-MIB module to gather all the parameters necessary to the communication procedure and associates a tag list to them [13]. The application uses a tag to get the parameters from the SNMP-TARGET-MIB. In other words, the SNMP-TARGET-MIB associates a list of names to a set of parameters that specify the host, port, protocol, security features and other information. For example, it may store the following information: to contact “router1” or “coreBridge” use the protocol=SNMPv3, timeout=5, retry count=3, user=”senior”, security model=“USM” and security level=“authNoPriv”. These parameters are retrieved by the SNMP application by using a name, or tag, belonging to the previously referred tag list, in this case, “router1” or “coreBridge”. The other approach suggested in this paper is to associate a similar tag list to URLs in a single table, thus resolving individual tags to a single URI character string. This method, which we designate as URL-TARGET-MIB, allows complementing or even replacing the SNMP-TARGET-MIB module (Fig. 1). The main difference between the modules is the extension. The use of URL-TARGET-MIB allows developing agents with less managed objects. Other advantage is to store OIDs and other URL schemes in the same MIB, which does not happen with the SNMP-TARGET-MIB. B. Expression MIB modifications The DISMAN charter defined under the IETF [14], a set of MIB modules to decentralize, by a set of distributed managers, some tasks traditionally associated with the central management station. From the agent point of view, these elements have the manager role and from the managers’ point of view, these elements act as agents. In the latter, the management information deals with the configuration of management tasks. This model allows creating hierarchical management “islands” to increase the system robustness by introducing redundancy, scalability and by allowing operation in offline conditions. One of the modules is the Expression MIB. It was defined to allow the definition of managed objects which were not considered during the definition of other modules [15]. It allows specifying expression based on existing managed... objects and it allows the construction of chaining expression, i.e., defining expressions which depend on other expressions results. An expression is composed of operators, functions and values. The values may be constants or variables, the latter being associated with OIDs that refer to the correspondent value. A string defines each expression. The possibility of using variables in expressions is, simultaneously, the strength and the weakness of the Expression MIB. As currently proposed, the MIB does not allow retrieving values from remote agents restricting the expression evaluation to local objects. This limits the possibility of creating some expressions, for example, when they use values from different sources. The variables are defined in a separate table that contains a column with an OID, lacking other parameters necessary to communicate with remote agents, namely, the host address, port, version, security parameters and context. Any expression is defined according to the following generic format: \[ x = \text{Expression}(\text{oid}_1, \text{oid}_2, \ldots, \text{oid}_n) \] The usage of SNMP URLs instead of OIDs in the referred column allows giving the possibility to the Expression MIB to obtain values from remote agents thus increasing its flexibility and capability. It is than possible to use expressions like: \[ x = \text{Expression}(\text{url}_1, \text{url}_2, \ldots, \text{url}_n) \] This association may be performed in two ways. The first, just like in the Event MIB [16], adopts a specific MIB to store and index URLs. In this way, the expression variables are defined as URL references. The advantage of this approach is the compatibility with the SNMP-TARGET-MIB, defined to the SNMPv3 but requires an additional MIB module. The second, simpler approach, goes through replacing the OID column by a URL column, which allows replacing only the column data type. C. Management of Mobile Agents Mobile Agent technology is a paradigm mostly inherited from artificial intelligence “manuals”. The novelty of this new paradigm is mainly associated with conception and abstraction more than the implementation technology. Basically, agents are software entities with the ability to perform actions on behalf of other programs, a person or an organization (the agent authority) [17]. A mobile agent is a specialization of these software agents that has the particular ability to migrate across several hosts. Mobile agents travel from node to node along the network carrying its state, so that they can maintain useful information when migrating to the next host. However, besides adding flexibility and the possibility to improve management efficiency it also brings some dilemmas, namely, it increases the agent management difficulty [18] and also introduces some kind of usability challenges and possibly threats [19]. This kind of programs or processes requires a platform, which provides the runtime environment and resources to individual agents. The diversity of currently available mobile agent platforms, coming from different vendors and supporting different languages, leads to the fact that mobile agents also need to be managed through a uniform way. The Mobile Agent Facility (MAF) specification is a CORBA based proposal from the OMG (Object Management Group), and it is a first attempt to standardize actions aiming at the interoperability between different vendors’ agent systems [20]. Moreover, it provides yet some management facilities over mobile agents and allows a mobile agent to move between agent platforms with similar profile (sharing the language, authentication mechanism and serialization encoding). Fundamentally performed by proprietary tools, mobile agents’ management may be thus performed in a standard, cross platform way. In previous work, the authors have already proposed a MAF-MIB to convert between SNMP commands and MAF interfaces calls making possible to manage MAF compatible platforms in SNMP and MAF simultaneously [21]. In this context, we developed a prototype of a GUI tool for the management of mobile agents supporting two simultaneous access methods in a single interface: SNMP and CORBA (Fig. 2). Just as for SNMP URLs, we defined a MAF URL with the format `maf://<name service host address>:<port>/<context>`. The common syntax, although semantically different, allows defining a list of URLs (bookmarks or favorites) regardless of the management model. According to the URL scheme, the tool loads the appropriate module and proceeds along with the user commands. The previous figure shows a tree view of the mobile agents’ platform resources and was built after setting the URL in the address field (upper right corner). If the user sets an SNMP URL, the tree is modified according to the information from the SNMP agent. IV. FUTURE WORK This concept, although simple, may have some impact on existing management tools. A guideline for future work is to study the impact that it may cause in existing MIB modules other than the Expression MIB. The Event MIB, Schedule MIB and RMON MIB, for example, look like perfect candidates to benefit from using SNMP URLs. Another line of work, already in research by the authors, is the extension of the Expression MIB to allow URLs with different schemes. The possibilities for this approach are limitless because it would allow defining more functions as CGIs (or servlets or server side scripts), using different nature values and resources. The new function parameters may be passed by HTTP GET or POST operations and the value can be returned in MIME encoding. Moreover, it would allow defining expressions with values from different application fields, for example, relating the number of pages dispensed by an HTTP server with the available bandwidth. In the Event MIB, it would than be possible to monitor resources directly, for example, LDAP, HTTP or FTP servers without needing intermediate SNMP agents. There is still a lot of work to be done, but the possibilities look immense. V. CONCLUSIONS The URI and URL concepts, although used frequently to identify and locate Internet resources do not have been used extensively in network management systems. This paper suggests a URI scheme to identify SNMPv1, SNMPv2c and SNMPv3 resources. This approach, which we call SNMP URL, allows specifying in a single line of text all the parameters necessary for two SNMP entities to communicate, regardless of the version and the security model. To validate the SNMP URL we also present some practical scenarios. The first example is an alternative approach to the SNMP-TARGET-MIB, using URLs to identify local or remote managed objects. Another example is an extension to the Expression MIB that allows evaluating expressions with any combination of objects from several agents. Just as for Internet browsers, it is also suggested the use of SNMP URLs in management stations to distinguish the service to use.
{"Source-Url": "https://bibliotecadigital.ipb.pt/bitstream/10198/2244/1/snmpUrl-rpl-jlo.pdf", "len_cl100k_base": 4911, "olmocr-version": "0.1.53", "pdf-total-pages": 6, "total-fallback-pages": 0, "total-input-tokens": 19337, "total-output-tokens": 5150, "length": "2e12", "weborganizer": {"__label__adult": 0.0003180503845214844, "__label__art_design": 0.0004122257232666016, "__label__crime_law": 0.00046324729919433594, "__label__education_jobs": 0.0008029937744140625, "__label__entertainment": 0.00013875961303710938, "__label__fashion_beauty": 0.00016689300537109375, "__label__finance_business": 0.00047206878662109375, "__label__food_dining": 0.0002856254577636719, "__label__games": 0.0005350112915039062, "__label__hardware": 0.0019025802612304688, "__label__health": 0.0005488395690917969, "__label__history": 0.0004224777221679687, "__label__home_hobbies": 9.238719940185548e-05, "__label__industrial": 0.0005002021789550781, "__label__literature": 0.0004425048828125, "__label__politics": 0.0003695487976074219, "__label__religion": 0.0004563331604003906, "__label__science_tech": 0.1998291015625, "__label__social_life": 0.0001291036605834961, "__label__software": 0.062408447265625, "__label__software_dev": 0.72802734375, "__label__sports_fitness": 0.0002435445785522461, "__label__transportation": 0.0005636215209960938, "__label__travel": 0.00026035308837890625}, "weborganizer_max": "__label__software_dev", "avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_ratio": [[0, 23066, 0.00778]], "fineweb_edu_fasttext_gt2__fineweb_edu_fasttext_gt2__score": [[0, 23066, 0.80458]], "ft_lang_id_en_doc_v2__ft_lang_id_en_doc_v2__en": [[0, 23066, 0.87575]], "google_gemma-3-12b-it_contains_pii": [[0, 4402, false], [4402, 9418, null], [9418, 13076, null], [13076, 16107, null], [16107, 20475, null], [20475, 23066, null]], "google_gemma-3-12b-it_is_public_document": [[0, 4402, true], [4402, 9418, null], [9418, 13076, null], [13076, 16107, null], [16107, 20475, null], [20475, 23066, null]], "google_gemma-3-4b-it_v2tag__is_academic_paper": [[0, 5000, true], [5000, 23066, null]], "google_gemma-3-4b-it_v2tag__is_class_syllabus": [[0, 5000, false], [5000, 23066, null]], "google_gemma-3-4b-it_v2tag__is_completion_certificate": [[0, 5000, false], [5000, 23066, null]], "google_gemma-3-4b-it_v2tag__is_court_notice": [[0, 5000, false], [5000, 23066, null]], "google_gemma-3-4b-it_v2tag__is_homework_assignment": [[0, 5000, false], [5000, 23066, null]], "google_gemma-3-4b-it_v2tag__is_news_article": [[0, 5000, false], [5000, 23066, null]], "google_gemma-3-4b-it_v2tag__is_public_order": [[0, 5000, false], [5000, 23066, null]], "google_gemma-3-4b-it_v2tag__is_resume_cv": [[0, 5000, false], [5000, 23066, null]], "google_gemma-3-4b-it_v2tag__is_test_or_quiz": [[0, 5000, false], [5000, 23066, null]], "google_gemma-3-4b-it_v2tag__is_textbook": [[0, 5000, false], [5000, 23066, null]], "pdf_page_numbers": [[0, 4402, 1], [4402, 9418, 2], [9418, 13076, 3], [13076, 16107, 4], [16107, 20475, 5], [20475, 23066, 6]], "pipe_delimited_lines_v1__pipe_delimited_lines_v1__pipe_delimited_lines_ratio": [[0, 23066, 0.05161]]}
olmocr_science_pdfs
2024-12-06
2024-12-06
a5423de1c55e962a1ee86af140590fee796fd33e
[REMOVED]
{"Source-Url": "https://inria.hal.science/inria-00329934/file/soumis.pdf", "len_cl100k_base": 4870, "olmocr-version": "0.1.49", "pdf-total-pages": 11, "total-fallback-pages": 0, "total-input-tokens": 26269, "total-output-tokens": 6942, "length": "2e12", "weborganizer": {"__label__adult": 0.0004076957702636719, "__label__art_design": 0.0004734992980957031, "__label__crime_law": 0.0004940032958984375, "__label__education_jobs": 0.0006618499755859375, "__label__entertainment": 0.00013256072998046875, "__label__fashion_beauty": 0.0002199411392211914, "__label__finance_business": 0.00030803680419921875, "__label__food_dining": 0.0004417896270751953, "__label__games": 0.000965595245361328, "__label__hardware": 0.0034580230712890625, "__label__health": 0.0008015632629394531, "__label__history": 0.0005087852478027344, "__label__home_hobbies": 0.0001379251480102539, "__label__industrial": 0.0010204315185546875, "__label__literature": 0.0002371072769165039, "__label__politics": 0.0005035400390625, "__label__religion": 0.0007672309875488281, "__label__science_tech": 0.304443359375, "__label__social_life": 0.00010186433792114258, "__label__software": 0.01226806640625, "__label__software_dev": 0.669921875, "__label__sports_fitness": 0.0004944801330566406, "__label__transportation": 0.00099945068359375, "__label__travel": 0.0003275871276855469}, "weborganizer_max": "__label__software_dev", "avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_ratio": [[0, 29679, 0.02953]], "fineweb_edu_fasttext_gt2__fineweb_edu_fasttext_gt2__score": [[0, 29679, 0.30661]], "ft_lang_id_en_doc_v2__ft_lang_id_en_doc_v2__en": [[0, 29679, 0.89949]], "google_gemma-3-12b-it_contains_pii": [[0, 1127, false], [1127, 3927, null], [3927, 6998, null], [6998, 10368, null], [10368, 12740, null], [12740, 15658, null], [15658, 18207, null], [18207, 20454, null], [20454, 22632, null], [22632, 25967, null], [25967, 29679, null]], "google_gemma-3-12b-it_is_public_document": [[0, 1127, true], [1127, 3927, null], [3927, 6998, null], [6998, 10368, null], [10368, 12740, null], [12740, 15658, null], [15658, 18207, null], [18207, 20454, null], [20454, 22632, null], [22632, 25967, null], [25967, 29679, null]], "google_gemma-3-4b-it_v2tag__is_academic_paper": [[0, 5000, true], [5000, 29679, null]], "google_gemma-3-4b-it_v2tag__is_class_syllabus": [[0, 5000, false], [5000, 29679, null]], "google_gemma-3-4b-it_v2tag__is_completion_certificate": [[0, 5000, false], [5000, 29679, null]], "google_gemma-3-4b-it_v2tag__is_court_notice": [[0, 5000, false], [5000, 29679, null]], "google_gemma-3-4b-it_v2tag__is_homework_assignment": [[0, 5000, false], [5000, 29679, null]], "google_gemma-3-4b-it_v2tag__is_news_article": [[0, 5000, false], [5000, 29679, null]], "google_gemma-3-4b-it_v2tag__is_public_order": [[0, 5000, false], [5000, 29679, null]], "google_gemma-3-4b-it_v2tag__is_resume_cv": [[0, 5000, false], [5000, 29679, null]], "google_gemma-3-4b-it_v2tag__is_test_or_quiz": [[0, 5000, false], [5000, 29679, null]], "google_gemma-3-4b-it_v2tag__is_textbook": [[0, 5000, false], [5000, 29679, null]], "pdf_page_numbers": [[0, 1127, 1], [1127, 3927, 2], [3927, 6998, 3], [6998, 10368, 4], [10368, 12740, 5], [12740, 15658, 6], [15658, 18207, 7], [18207, 20454, 8], [20454, 22632, 9], [22632, 25967, 10], [25967, 29679, 11]], "pipe_delimited_lines_v1__pipe_delimited_lines_v1__pipe_delimited_lines_ratio": [[0, 29679, 0.0]]}
olmocr_science_pdfs
2024-11-25
2024-11-25
7de1059f94b5c0632549808adbedd8a8fabbcd3d
Constraint based Hindi dependency parsing by Meher Vijay Yeleti, Kalyan Deepak in ICON-2009: International Conference on Natural Language Processing, NLP Tools Contest (INCON-2009) Centre for Language Technologies Research Centre International Institute of Information Technology Hyderabad - 500 032, INDIA December 2009 Constraint based Hindi dependency parsing Meher Vijay Yeleti, Kalyan Deepak Language Technologies Research Centre IIIT-Hyderabad, India. meher.vijay@students.iiit.ac.in, deepak_s@students.iiit.ac.in Abstract The paper describes the overall design of a new two stage constraint based hybrid approach to dependency parsing. We define the two stages and show how different grammatical construct are parsed at appropriate stages. This division leads to selective identification and resolution of specific dependency relations at the two stages. Furthermore, we show how the use of hard constraints and soft constraints helps us build an efficient and robust hybrid parser. The experiments tried out for soft constraints are elucidated in detail. Finally, we evaluate the implemented parser on ICON tools contest Hindi data. Best Labeled and unlabeled attachment accuracies for Hindi are 62.20% and 85.55% respectively. 1 Introduction Due to the availability of annotated corpora for various languages since the past decade, data driven parsing has proved to be immensely successful. Unlike English, however, most of the parsers for morphologically rich free word order (MoR-FWO) languages (such as Czech, Turkish, Hindi, etc.) have adopted the dependency grammatical framework. It is well known that for MoR-FWO languages, dependency framework provides ease of linguistic analysis and is much better suited to account for their various structures (Shieber, 1975; Mel'cuk, 1988; Bharati et al., 1995). The state of the art parsing accuracy for many MoR-FWO languages is still low compared to that of English. Parsing experiments (Nivre et al., 2007; Hall et al., 2007) for these languages have pointed towards various reasons for this low performance. For Hindi1, (a) difficulty in extracting relevant linguistic cues, (b) non-projectivity, (c) lack of explicit cues, (d) long distance dependencies, (e) complex linguistic phenomena, and (f) less corpus size, have been suggested (Bharati et al., 2008) for low performance. The approach proposed in this paper shows how one can minimize these adverse effects and argues that a hybrid approach can prove to be a better option to parsing such languages. There have been, in the past, many attempts to parsing using constraint based approaches. Some of the constraint based parsers known in the literature are Karlsson et al. (1995), Maruyama (1990), Bharati et al. (1993, 2002), Tapanainen and Järvinen (1998), Schröder (2002), and more recently, Debusmann et al. (2004). Some attempts at parsing Hindi using data driven approach have been (Bharati et al., 2008b; Husain et al., 2009). Later in Section 4, we’ll compare the results of data-driven Hindi parsing with that of our approach. We show how the use of hard constraints (H-constraints) and soft constraints (S-constraints) helps us build an efficient and robust hybrid parser. Specifically, H-constraints incorporate the knowledge base of the language and S-constraints are used as weights that are automatically learnt from an annotated treebank. Finally, we evaluate the implemented parser on Hindi and compare the results with that of two data driven dependency parsers. The paper is arranged as follows: Section 2 describes in detail the proposed approach for parsing free word order languages. Section 3 discusses the types of constraints used. We describe the experiments performed and report the results in Section 4. --- 1 Hindi is a verb final language with free word order and a rich case marking system. It is one of the official languages of India, and is spoken by ~800 million people. 2 Approach We try to solve the task of dependency parsing using a hybrid approach. A grammar driven approach is complemented by a controlled statistical strategy to achieve high performance and robustness. The overall task of dependency parsing is attacked using modularity, wherein specific tasks are broken down into smaller linguistically motivated sub-tasks. Figure 1 above shows the output of each of these sub-tasks. 2.1 Background Data driven parsing is usually a single stage process wherein a sentence is parsed at one go. Many attempts have, however, tried to divide the overall task into sub-tasks. One trend has been to first identify dependencies and then add edge labels over them (McDonald et al., 2005, Chen et al., 2007). The other trend has been towards performing smaller linguistically relevant tasks as a precursor to complete parsing (Abney, 1997; Bharati et al., 1995; Attardi and Dell’Orletta, 2008; Shiuan and Ann, 1996). In our approach we divide the task of parsing into the following sub-tasks (layers): 1. POS tagging, chunking (POSCH), 2. Constraint based hybrid parsing (CBHP), 3. Intra-chunk dependencies (IRCH) identification. (a) POSCH is treated as pre-processing to the task of parsing. A bag represents a set of adjacent words which are in dependency relations with each other, and are connected to the rest of the words by a single incoming dependency arc. Thus a bag is an unexpanded dependency tree connected to the rest only by means of its root. A noun phrase or a noun group chunk is a bag in which there are no verbs, and vice versa for verb chunks. The relations among the words in a chunk are not marked and hence allow us to ignore local details while building the sentence level dependency tree. In general, all the nominal inflections, nominal modifications (adjective modifying a noun, etc.) are treated as part of a noun chunk, similarly, verbal inflections, auxiliaries are treated as part of the verb chunk (Bharati et al., 2006). (b) CBHP takes the POS tagged and chunked sentence as input and parses it in two stages. The parser makes use of knowledge base of the language along with syntactico-semantic preferences to arrive at the final parse. Broadly, modularity in CBHP works at two layers (cf. Figure 3): (1) The sentence analysis layer, and (2) The parse selection layer. We discuss this approach to parsing in the following sections. (c) IRCH dependencies are finally identified as a post-processing step to (b) and (c). Once this is done, the chunks can be removed and we can get the complete dependency tree. We will not discuss IRCH in this paper. In the dependency trees (b) and (c) shown in Figure 1, each node is a chunk and the edge represents the relations between the connected nodes labeled with suitable relations\(^2\). After removing the chunks in (d) each node is a lexical item of the sentence. --- \(^2\) All the relations marked by the parser are syntactico-semantic labels. For a detailed analysis see Bharati et al. (1995). Many relations shown in the diagrams of this paper are described in Begum et al. (2008a). For the complete tagset description, see http://ltrc.iiit.ac.in/MachineTrans/research/ls/DS-guidelines/DS-guidelines-ver2-28-05-09.pdf Eg. 1: mohana ne tebala para apani kitaaba ‘Mohan’ ‘ERG’ ‘table’ ‘on’ ‘his’ ‘book’ rakhii Ora vaha so gayaa ‘kept’ ‘and’ ‘he’ ‘sleep’ ‘PRFT’ ‘Mohan placed his book on the table and slept’ From (a) to (d) in Figure 1, outputs of each of the previously discussed layers have been shown. Note that one can use any of these outputs inde- pendently. More importantly, (b) is a partial parse obtained after the 1st stage of CBHP, and (c) is the output after the 2nd stage of CBHP. We’ll elaborate on this in the following sections. To test the performance of the proposed parser we use gold POS tagged and chunked data, instead of using the outputs of POS tagger and chunker. 2.2 Constraint Parsing Constraint based parsing using integer program- ning has been successfully tried for Indian lan- guages (Bharati et al., 1993; 2002). Under this scheme the parser exploits the syntactic cues present in a sentence and forms constraint graphs (CG) based on the generalizations present. It uses such notions as basic demand frames and trans- formation frames (Bharati et al., 1995) to con- struct the CG. It then translates the CG into an integer programming (IP) problem. The solutions to the problem provide the possible parses for the sentence. We follow the approach used by Bha- ratii et al. (1995, 2008a) for formulating the con- straints as IP problem and solving them to get the parses. 2.3 Two Stage Parsing The proposed parser tries to analyze the given input sentence, which has already been POS tagged and chunked, in 2 stages; it first tries to extract intra-clausal3 dependency relations. These generally correspond to the argument structure of the verb, noun-noun genitive relation, infinitive- verb relation, infinitive-noun relation, adjective- noun, adverb-verb relations, etc. In the 2nd stage it then tries to handle more complex relations such as conjuncts, relative clause, etc. What this essentially means is a 2-stage resolution of de- pendencies, where the parser selectively resolves the dependencies of various lexical heads at their appropriate stage, for example verbs in the 1st stage and conjuncts and inter-verb relations in the 2nd stage. The key ideas are: (1) There are two layers (stages), (2) the 1st stage handles intra- clausal relations, and the 2nd stage handles inter- clausal relations, (3) the output of each layer is a linguistically valid partial parse that becomes, if necessary, the input to the next layer, and (4) the output of the final layer is/are the desired full parses(s). These form the sentence analysis layer in the overall design. Figure 3 shows this clearly. The 1st stage output for example 2 is shown in figure 2(a). Eg. 2: mai ghar gayaa kyomki mai ‘I’ ‘home’ ‘went’ ‘because’ ‘I’ bimaar thaa ‘sick’ ‘was’ ‘I went home because I was sick’ In figure 2a, the parsed matrix clause subtree ‘mai ghar gayaa’ and the subordinate clause are attached to _ROOT_. The subordinating conjunct ‘kyomki’ (because) is also seen attached to the _ROOT_. _ROOT_ ensures that the parse we get after each stage is connected and takes all the analyzed 1st stage sub-trees along with unpro- cessed nodes as its children. The dependency tree thus obtained in the 1st stage is partial, but lin- guistically sound. Later in the 2nd stage the rela- tionship between various clauses are identified. The 2nd stage parse for the above sentences is also shown in figure 2b. At the end of 2nd stage, the subordinate conjunct kyomki gets attached to the matrix clause and takes the root of the subor- dinate clause as its child. Similar to example 2, the analysis of example 1 is shown in figure 1. Note that under normal conditions the 2nd stage does not modify the parses obtained from the 1st stage, it only establishes the relations between the clauses. However, sometimes under very strict conditions, repair is possible (Bharati et al., 2008a). 3 A clause is a group of word such that the group contains a single finite verb chunk. ![Figure 2: (a): 1st stage output for Eg. 2, (b): 2nd stage final parse for Eg. 2] 3 Hard and Soft Constraints Both 1st and 2nd stage described in the previous section use linguistically motivated constraints. These *hard* constraints (H-constraints) reflect that aspect of the grammar that in general cannot be broken. H-constraints comprise of lexical and structural knowledge of the language. The H-constraints are converted into integer programming problem and solved (Bharati et al., 2002, 2008a). The solution(s) is/are valid parse(s). The *soft* constraints (S-constraints), on the other hand, are learnt as weights from an annotated treebank. They reflect various preferences that a language has towards various linguistic phenomena. They are used to prioritize the parses and select the best parse. Both H & S constraints reflect the linguistic realities of the language and together can be thought as the grammar of a language. Figure 3 schematically shows the overall design of the proposed parser and places these constraints in that context. 3.1 Hard Constraints The core language knowledge being currently considered that cannot be broken without the sentence being called ungrammatical is named H-constraints. There can be multiple parses which can satisfy these H-constraints. This indicates the ambiguity in the sentence if only the limited knowledge base is considered. Stated another way, H-constraints are insufficient to restrict multiple analysis of a given sentence and that more knowledge (semantics, other preferences, etc.) is required to curtail the ambiguities. Moreover, we know that many sentences are syntactically ambiguous unless one uses some pragmatic knowledge, etc. For all such constructions there are multiple parses. As described earlier, H-constraints are used during intra-clausal (1st stage) and inter-clausal (2nd stage) analysis (cf. Figure 3). They are used to form a constraint graph which is converted into integer programming equalities (or inequalities). These are then solved to get the final solution graph(s) (Bharati et al., 2008a). Some of the H-constraints are: (1) *Structural constraints* (ensuring the solution graph to be a tree, removing implausible language specific ungrammatical structures, etc.), (2) *Lexicon* (linguistic demands of various heads), and (3) *Other lexical constraints* (some language specific characteristics), etc. 3.2 Soft Constraints The S-constraints on the other hand are the constraints that can be broken, and are used in the language as preferences. These are used during the prioritization stage. Unlike the H-constraints that are derived from a knowledge base and are used to form a constraint graph, S-constraints have weights assigned to them. These weights are automatically learnt using a manually annotated dependency treebank. The weights are used to score the parse trees. The tree with the maximum overall score is the best parse. Some such S-constraints are, (1) *Order of the arguments*, (2) *Relative position of arguments w.r.t. the verb*, (3) *Agreement*, (4) *Structural preferences/General graph properties* (mild non-projectivity, valency, dominance, etc.), etc. Some of the graphical S-constraints that we have used are, 1) \{child POS, parent POS\}, 2) \{child POS, GGP POS\}, 3) \{child POS, child Width\}, 4) \{child POS, parent Depth\}, 5) \{parent POS, GP POS\}, where POS is the Part-of-Speech tag and GP is the grandparent and GGP is the great grandparent of the child and parent Depth and child Width are the depths and widths of the parent and child sub-tree respectively. Parses obtained after the 2nd stage, satisfies all the relevant H-constraints. We score these parses based on the S-constraints and the parse with the max score is selected. The score \( \zeta(p) \) of a parse \( p \) is calculated as follows: \[ \zeta(p) = \zeta(R_p) \tag{1} \] where, \( \zeta \) is a recursive scoring function, \( R_p \) is the root node of the parse \( p \) \[ \zeta(n) = \sum_e [\zeta(e) + k \cdot \zeta(C_e)] \quad \tag{2} \] \[4\] For details on the corpus type, annotation scheme, tagset, etc. see Begum et al. (2008a). where, $C_{ne}$ is the child of node $n$ along edge $e$ and $k$ is a parameter $$ \zeta(e) = \sum [k_i \cdot (P(r / \gamma_i) + P(\gamma_i))] \quad (3) $$ where, $P(r / \gamma_i)$ is the probability of the relation on edge $e$ being $r$ given that $\gamma_i$ is the $i^{th}$ S-constraint and $P(\gamma_i)$ is the probability of occurrence of $\gamma_i$ and $k_i$ is a weight associated with $\gamma_i$. $$ P(r / \gamma_i) = C(\gamma_i, r) / C(r) \quad (4) $$ where, $C(\gamma_i, r)$ is the count of occurrence of relation $r$ and $\gamma_i$ together and $C(r)$ is the count of occurrence of the relation $r$ in training data. These counts will be calculated from the training data for each of the S-constraint $\gamma_i$ and stored. The ranking function tries to select a parse $p$ for a sentence such that the overall accuracy of the parser is maximized. The parameters $k$ and $k_i$ in (2) and (3) above are set using maximum likelihood estimation. Note that the scoring function considers structure of the parse along with the linguistic constraints under which this structure can occur. 4 Experiments and Results Initially the two stage constraint based parser is used to parse the sentences. It outputs multiple parses for each of the sentence. These parses are ranked using the scoring technique discussed in section 3.2. Three variations of the scoring technique are explained below. The probabilities required are calculated from the training data. 4.1 Method1 In this method the parses are scored using a single S-constraint using the scoring function discussed in section 3.2 with $i=1$. The parse with the best score is the required output. In this case there may be multiple parses with the same highest score using a single S-constraint. Output is the $1^{st}$ parse out of all parses having the highest score. To solve the problem of multiple parses with the highest score, second method is used. For this method we tried with different values of $k$ in equation 2 like 0.1, 0.5, 1, 2, 5 etc. The best results are for $k=2$. So for all the other methods experiments are done by fixing the $k$ value as 2. 4.2 Method2 In the second method, initially only one S-constraint is used to score the parses using the scoring function similar to the method1. If there are multiple parses with highest score then second S-constraint is used to resolve them and so on till there is unique parse or till all the S-constraints are used. If there are still multiple parses the first-one is the output. In this method, the order in which we use the S-constraints is important. This affects the accuracy of the parser. The order which we have used is the descending order of the best accurate (found using the hindi development data with method1) S-constraint. 4.3 Method3 In the third method all the soft-constraints are used in parallel with weights $k_i$ associated with each of them. Then the parses are scored using the scoring technique discussed in section 3.2. The algorithm for boosting loss function as discussed in Collins (2000) is used to learn the weights for each of the S-constraints. This algorithm runs on the training data and learns the weights for each S-constraint. This has several parameters: 1) the margins for each parse of each sentence, 2) Number of iterations ($N$) to find the best possible weights. Margins are initialized with the best single S-constraint score obtained from the method1. The algorithm is run with different values of $N$. After $N=2000$ weights of the features did not change considerably. So the value of $N$ is fixed as 2000. 4.4 Parameters The parameters that are finalized after experimenting with all the possible values and used in all of the above methods are shown below in table 1. <table> <thead> <tr> <th>Parameter</th> <th>value</th> </tr> </thead> <tbody> <tr> <td>Value of $k$</td> <td>2</td> </tr> <tr> <td>Best S-constraint (Method1)</td> <td>[C-POS,P-POS]</td> </tr> <tr> <td>Value of $N$</td> <td>2000</td> </tr> <tr> <td>Margins initialization</td> <td>[C-POS,P-POS]</td> </tr> </tbody> </table> Table 1. Parameters, where C-POS and P-POS are the child and parent POS respectively 4.5 Results We have tried all the three methods on the development data and method 2 gave the best results on the development data. So we gave the output of method 2 on the testing data for the evaluation for the tools contest. The second method is used starting with the best S-constraint \{C-POS, P-POS\}. Our results on the Hindi test data are shown below in Table 2. <table> <thead> <tr> <th>Method2</th> <th>UA</th> <th>LA</th> <th>L</th> </tr> </thead> <tbody> <tr> <td></td> <td>85.55</td> <td>62.20</td> <td>65.88</td> </tr> </tbody> </table> Table 2 Results on Hindi Test data Acknowledgements We would like to thank Mr. Samar Husain for his valuable guidance and suggestions. We would also like to thank Dr. Dipti Misra Sharma and Dr. Rajeev Sangal for their valuable suggestions and support. References
{"Source-Url": "http://web2py.iiit.ac.in/publications/default/download/inproceedings.pdf.851e6f8b668fce8a.49434f4e2d746f6f6c732d6d65686572616e646b616c79616e2e706466.pdf", "len_cl100k_base": 4945, "olmocr-version": "0.1.49", "pdf-total-pages": 7, "total-fallback-pages": 0, "total-input-tokens": 20494, "total-output-tokens": 5887, "length": "2e12", "weborganizer": {"__label__adult": 0.0008082389831542969, "__label__art_design": 0.0015163421630859375, "__label__crime_law": 0.000904560089111328, "__label__education_jobs": 0.01041412353515625, "__label__entertainment": 0.0009026527404785156, "__label__fashion_beauty": 0.0004968643188476562, "__label__finance_business": 0.0007529258728027344, "__label__food_dining": 0.0009174346923828124, "__label__games": 0.0021076202392578125, "__label__hardware": 0.0009717941284179688, "__label__health": 0.0012884140014648438, "__label__history": 0.0009975433349609375, "__label__home_hobbies": 0.00017070770263671875, "__label__industrial": 0.000957012176513672, "__label__literature": 0.025482177734375, "__label__politics": 0.00103759765625, "__label__religion": 0.0014600753784179688, "__label__science_tech": 0.38623046875, "__label__social_life": 0.0005278587341308594, "__label__software": 0.037872314453125, "__label__software_dev": 0.52197265625, "__label__sports_fitness": 0.0008063316345214844, "__label__transportation": 0.001155853271484375, "__label__travel": 0.0003390312194824219}, "weborganizer_max": "__label__software_dev", "avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_ratio": [[0, 21731, 0.03452]], "fineweb_edu_fasttext_gt2__fineweb_edu_fasttext_gt2__score": [[0, 21731, 0.49349]], "ft_lang_id_en_doc_v2__ft_lang_id_en_doc_v2__en": [[0, 21731, 0.88881]], "google_gemma-3-12b-it_contains_pii": [[0, 355, false], [355, 3964, null], [3964, 7205, null], [7205, 11258, null], [11258, 15323, null], [15323, 19636, null], [19636, 21731, null]], "google_gemma-3-12b-it_is_public_document": [[0, 355, true], [355, 3964, null], [3964, 7205, null], [7205, 11258, null], [11258, 15323, null], [15323, 19636, null], [19636, 21731, null]], "google_gemma-3-4b-it_v2tag__is_academic_paper": [[0, 5000, true], [5000, 21731, null]], "google_gemma-3-4b-it_v2tag__is_class_syllabus": [[0, 5000, false], [5000, 21731, null]], "google_gemma-3-4b-it_v2tag__is_completion_certificate": [[0, 5000, false], [5000, 21731, null]], "google_gemma-3-4b-it_v2tag__is_court_notice": [[0, 5000, false], [5000, 21731, null]], "google_gemma-3-4b-it_v2tag__is_homework_assignment": [[0, 5000, false], [5000, 21731, null]], "google_gemma-3-4b-it_v2tag__is_news_article": [[0, 5000, false], [5000, 21731, null]], "google_gemma-3-4b-it_v2tag__is_public_order": [[0, 5000, false], [5000, 21731, null]], "google_gemma-3-4b-it_v2tag__is_resume_cv": [[0, 5000, false], [5000, 21731, null]], "google_gemma-3-4b-it_v2tag__is_test_or_quiz": [[0, 5000, false], [5000, 21731, null]], "google_gemma-3-4b-it_v2tag__is_textbook": [[0, 5000, false], [5000, 21731, null]], "pdf_page_numbers": [[0, 355, 1], [355, 3964, 2], [3964, 7205, 3], [7205, 11258, 4], [11258, 15323, 5], [15323, 19636, 6], [19636, 21731, 7]], "pipe_delimited_lines_v1__pipe_delimited_lines_v1__pipe_delimited_lines_ratio": [[0, 21731, 0.04639]]}
olmocr_science_pdfs
2024-11-24
2024-11-24
8b10c3af1c37ed035832f9eeb759d58ef10870d1
A proposal for an extremely simple whiteboarding protocol over Jabber. Legal Copyright This XMPP Extension Protocol is copyright © 1999 – 2020 by the XMPP Standards Foundation (XSF). Permissions Permission is hereby granted, free of charge, to any person obtaining a copy of this specification (the "Specification"), to make use of the Specification without restriction, including without limitation the rights to implement the Specification in a software program, deploy the Specification in a network service, and copy, modify, merge, publish, translate, distribute, sublicense, or sell copies of the Specification, and to permit persons to whom the Specification is furnished to do so, subject to the condition that the foregoing copyright notice and this permission notice shall be included in all copies or substantial portions of the Specification. Unless separate permission is granted, modified works that are redistributed shall not contain misleading information regarding the authors, title, number, or publisher of the Specification, and shall not claim endorsement of the modified works by the authors, any organization or project to which the authors belong, or the XMPP Standards Foundation. Warranty ## NOTE WELL: This Specification is provided on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. ## Liability In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall the XMPP Standards Foundation or any author of this Specification be liable for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising from, out of, or in connection with the Specification or the implementation, deployment, or other use of the Specification (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if the XMPP Standards Foundation or such author has been advised of the possibility of such damages. Conformance This XMPP Extension Protocol has been contributed in full conformance with the XSF’s Intellectual Property Rights Policy (a copy of which can be found at <https://xmpp.org/about/xsf/ipr-policy> or obtained by writing to XMPP Standards Foundation, P.O. Box 787, Parker, CO 80134 USA). 1 Introduction As explained in the now obsolete XEP-0010: Whiteboarding \(^1\): "Jabber is often thought of simply as a system for instant messaging, albeit an open one. However, Jabber technology can be used, and is being used, in applications quite different from simple IM. One of these applications is whiteboarding. In collaborative work, the ability to draw (for example, to design sketches, UML schemas, house architectures, and organizational plans) is essential, as exemplified by the success of real-world whiteboarding applications such as Microsoft NetMeeting. Whiteboarding can also be used for entertainment purposes such as games and quizzes. Because of the value of whiteboarding as an important real-time collaboration tool, other IM services are beginning to offer these capabilities. For these and other reasons, I believe that a good protocol for whiteboarding in Jabber would be of great value". The increasing penetration of pen-based devices, such as PDAs and tablet PCs, makes the need for a protocol that allows for sending freehand drawing information more urgent. Several attempts have been made to create a whiteboarding protocol for Jabber: 1. Collaborative Imaging (Whiteboarding via Streaming XPM) describes a protocol that sends partial bitmaps. This protocol is not suitable for freehand drawing and has not been implemented. 2. Jabber Whiteboarding using SVG \(^2\) describes a protocol that uses a subset of SVG. It refers to a missing DTD that describes the precise subset, but there is little doubt that that subset will be hard to implement. This protocol has not been implemented. 3. The Coccinella client includes an open source implementation of a whiteboarding protocol. However, the protocol has not been documented and does not seem easy to implement. In fact it is mostly raw TCL, making an implementation of that protocol in a language other than TCL rather difficult. 4. The Tkabber client has a whiteboard plugin. The protocol has not been documented, but it uses a subset of SVG, similar to the one defined in this document. 2 Requirements The protocol has the following requirements in order of importance: 1. It should allow for freehand drawing because that will be its principal use on pen-based devices. 2. It should be extremely easy to implement to ensure its rapid adaptation. 3. It should be light-weight. --- 4. It should not require server modifications. The following are definitely not objectives of the protocol: 1. It need not be complete. Eventually an SVG-based protocol will be defined that will either replace or coexist with this protocol and that will satisfy all drawing needs. However, given the history of whiteboarding protocols, such a protocol is far away. 2. It need not be extensible. As a "Simple Whiteboarding protocol" it should not try to grow into a more complex protocol that would be more difficult to implement. 3 Use Cases There are three scenarios where whiteboarding can be used: - One person sends a single, completed, whiteboard to another person. - The more typical scenario is the one where one person starts a whiteboard session with another person and both persons collaborate in the drawing. Both sides may add paths, move them around or delete them. - Finally multiple people gathered in a conference room can use single whiteboard. 3.1 Single whiteboard message Typically the user right-clicks on the destination contact and will select a "whiteboard message" option. The client will show a dialog where the user can create the drawing. It is up to the implementation to decide whether the user can include text in the message as well. Upon clicking a send button the client will close the dialog and send the following message: ``` Listing 1: Single whiteboard message <message from='painter@shakespeare.lit' to='timon@shakespeare.lit/hall'> <body>A piece of painting, which I do beseech your lordship to accept.</body> <x xmlns='http://jabber.org/protocol/swb'> <path d='M_100_100_L_300_100_200_300_100_100' stroke='#ff0000' stroke-width='1' id='painter1'/> </x> </message> ``` The path node is a simplified SVG path node that allows only 'M', 'm', 'L' and 'l' commands. 'M' ('m') command is a (relative) moveto command, 'L' ('l') is a (relative) lineto command. All USE CASES 4 USE CASES four commands take one or more coordinate pairs (in pixels). 'M' sets the current point to the coordinate pair. 'm' adds the coordinate pair to the current point. 'L' draws a line from the current point to the point designated by the coordinate pair and sets the current point to the coordinate pair. 'l' draws a line from the current point to the sum of the current point and the coordinate pair and adds the coordinate pair to the current point. The optional stroke attribute indicates the color of the path and defaults to black, the optional stroke-width indicates the width of the path in pixels and defaults to 1. The id attribute can be used for later reference to the path. If there is no id attribute, the path can not be referred to. The path in example 1, draws a red triangle with vertices (100,100), (300,100) and (200, 300) Other represenations of the same path are 'M100.0,100.0L300.0,100.0,200.0,300.0,100.0,100.0', 'M100,100l200,0-100,200-100-200' and 'M100,100l200,0L200,300,100,100'. Note that in the second representation some commas can be left out because the sign indicates that a new coordinate is starting. This fact can be used to reduce data size as much as possible to avoid karma problems. A precise grammar of the "d" attribute is given below. A typical implementation will generate such paths by adding an 'M' command with the mouse coordinates on a mouse down event and adding an 'L' command with the mouse coordinates on every mouse move event as long as the mouse is down. It is up to the implementation to decide whether to complete and send the message on a mouse up event or to wait for a click on a send button. 3.2 Whiteboard chat session A more typical use case is where two clients share a whiteboard. Again the user will right click on the destination and will select a "whiteboard chat" option. The client will present a dialog where the user can create a drawing. Upon clicking a send button or releasing the mouse button, the client will send the following message: ``` Listing 2: Initiating a whiteboard chat session <message from='kingclaudius@shakespeare.lit/castle' to='laertes@shakespeare.lit/castle' type='chat'> <thread>c357e044c676cc5e3c729d07544c87b58a366dba</thread> <body>... like the painting ... ?</body> <x xmlns='http://jabber.org/protocol/swb'> <path d='M100.0,100.0L300.0,100.0,200.0,300.0,100.0,100.0' id='kingclaudius1'/> </x> </message> ``` In this case the dialog will not close. At the destination client a similar dialog will pop up, allowing the user at the other end to add her own part of the drawing. The resulting message will look like this (line breaks provided for readability only): It is left as a mental exercise to the reader to imagine Laertes answer. Alternatively the reader could build this protocol into her favorite Jabber client, set a breakpoint, and paste the path above at the appropriate place. Alternatively Laertes could respond like: ```xml Listing 4: Moving a path <message from='laertes@shakespeare.lit/castle' to='kingclaudius@shakespeare.lit/castle' type='chat'> <thread>c357e844c676c5e3c729d07544c87b58a366dba</thread> <xm xmlns='http://jabber.org/protocol/swb'> move id='kingclaudius1' dx='100' dy='100'/> </message> ``` This would move the King’s triangle 100 pixels to the left and top, to the upper left corner of the screen. If Laertes were bold enough he might even answer: ### Listing 5: Deleting a path ```xml <message from='laertes@shakespeare.lit/castle' to='kingclaudius@shakespeare.lit/castle' type='chat'> <thread>c357e044c676cc5e3c729d07544c87b58a366dba</thread> <x xmlns='http://jabber.org/protocol/swb'> <delete id='kingclaudius1'/> </x> </message> ``` This would remove King Claudius's triangle from the screen. ### 3.3 Conference room whiteboard The final use case is the one where multiple users, gathered in a conference room, share a single whiteboard. Messages will typically look like this: ### Listing 6: Conference room whiteboard ```xml <message from='nestor@shakespeare.lit' to='plains@conference.shakespeare.lit' type='groupchat'> <body>So, so, we draw together.</body> <x xmlns='http://jabber.org/protocol/swb'> <path d='M100,100 L200,300 ,100,100'/> </x> </message> ``` ### 4 Implementation Notes #### 4.1 The GUI Usually when a user wants to send a message to a contact, the client will present her with a choice between sending a message or starting a chat. If the client implements the present protocol, the client can add the options of sending a whiteboard message and starting a whiteboard chat. Whether the client offers these options for an individual contact could be based on standard Service Discovery (XEP-0030) \(^3\) or Jabber Browsing (XEP-0011) \(^4\) techniques. Presentation of a path in case of a “Single whiteboard message” is rather obvious. The presentation of multiple-user whiteboards, either chat or conference, leaves more to the imagination of the implementor. The implementor could decide to use different colors for paths drawn by different users. The saturation of a path could decrease with age. ### 4.2 Karma One issue that will hinder all whiteboard protocol implementations is the karma problem. At least jabberd uses karma to make sure that a client does not send too much data to the server. This should help against denial-of-service attacks. When you use up all your karma, the server stops handling your messages for a while. This is a problem for whiteboards because it is much easier to send a lot of drawing data, than to send a lot of textual data. Usually combining paths, that is, sending paths when the user clicks on a send button instead of on mouse up, reduces data size because it reduces the overhead of the message element. Using the relative lineto command (’l’) instead of the absolute lineto (’L’) command will also reduce message size, because usually relative coordinates will only use one or two digits whereas absolute coordinates will typically use three. Finally implementations can reduce message size by not recording every mouse move event, e.g. by dropping mouse events whose locations would be accurately interpolated. ### 4.3 Text The protocol does not provide explicit support for drawing text. The reason for this is that explicit support, e.g. in the form of the SVG text element \(^5\), would break the second and third requirements above. However a client can still provide text support by representing characters as paths, e.g. by using a Hershey font. The code snippet below shows the lines along which this could be done: **Listing 7: Coding the letter A into a path** ```c // generating the path <path d='M14_61-8,21M14_618,21M9_20110,0' /> from the letter 'A' static char * sHersheyFontData[] = { ... "I[RFJ[._RRFZ[._RMTWT", // the character A, consisting of three strokes ... }; ``` \(^5\)Text - SVG 1.0 http://www.w3.org/TR/SVG/text.html for (int i = 0; sHersheyFontData['A'][2*i+2] != 0; i++) { // read a new coordinate pair POINT myPoint = {sHersheyFontData['A'][2*i+2]-'R', sHersheyFontData['A'][2*i+2+1]-'R'}; // test for the special case pen up if (myPoint.x == -50 && myPoint.y == 0) { penUp = true; } else { if (penUp) { penUp = false; currentPathSet.push_back(std::vector<Point>()); // pen goes down, add // a new path } currentPathSet.back().push_back(myPoint); // pen is down add a new point to the latest // path } } The string 'Jabber' would be encoded as the path 'M24 590,16-1,1-2,1-2,0-2-1-1-1-3 0-2M43 66l0,14M43 69l-2-2-1-3,0-2,1-2,1-3 0,2 1,3 2,1 3,0 2-1 2M51 59l0,21M51 69l2-2 2-1 3,0 2,1 2,2 1,3 0,2,1-3,2-2-1-3,0-2,1-2-1-2M70 59l0,21M70 69l2-2 2-1 3,0 2,1 2,2 1,3 0,2-1,3- 2,2-2,1-3,0-3-1-2-2M88 72l12,0 0-2-1-2-1-2-1-3,0-2,1-2,2-1,3 0,2 1,3 2,2 2,1 3,0 2-1 2-2M107 66l0,14M107 72l1-3 2-2 2-1 3,0', which is 357 characters long. That is no more than twice the size of a typical groupchat text message. 4.4 Clearing the screen Some of the protocols mentioned in the introduction, have a clear-screen command. However the benefits of such a command are doubtful. Of course clients can implement such a command locally. A client might even implement finer control such as the possibility of opening new windows that will receive new paths, or showing paths based on whether they were drawn in a selectable timespan. Synchronization of such complex actions between clients is clearly beyond the scope of this protocol. Of course when it is absolutely necessary to clear the screens of both sides in a whiteboard chat, that could be implemented by sending delete-commands for all paths. 5 Security Considerations There are no security features or concerns related to this proposal. 6 IANA Considerations This document requires no interaction with the the Internet Assigned Numbers Authority (IANA). 7 XMPP Registrar Considerations This document requires registration of the namespace "http://jabber.org/protocol/swb" by the XMPP Registrar. 8 Formal Definition 8.1 Schema ```xml <?xml version='1.0' encoding='UTF-8'?> <xs:schema xmlns:xs='http://www.w3.org/2001/XMLSchema' targetNamespace='http://jabber.org/protocol/swb' xmlns='http://jabber.org/protocol/swb' elementFormDefault='qualified'> <x:element name='x'> <x:complexType> <x:element ref='path' minOccurs='0' maxOccurs='unbounded' /> <x:element ref='move' minOccurs='0' maxOccurs='unbounded' /> <x:element ref='delete' minOccurs='0' maxOccurs='unbounded' /> </x:complexType> </x:element> <x:element name='path'> <x:complexType> <x:attribute name='d' type='xs:string' use='required' /> <x:attribute name='stroke' type='xs:string' use='optional' default='#000000' /> <x:attribute name='stroke-width' type='xs:integer' use='optional' default='1' /> <x:attribute name='id' type='xs:string' use='optional' /> </x:complexType> </x:element> </xs:schema> ``` 6The Internet Assigned Numbers Authority (IANA) is the central coordinator for the assignment of unique parameter values for Internet protocols, such as port numbers and URI schemes. For further information, see <http://www.iana.org/>. 7The XMPP Registrar maintains a list of reserved protocol namespaces as well as registries of parameters used in the context of XMPP extension protocols approved by the XMPP Standards Foundation. For further information, see <https://xmpp.org/registrar/>. 8.2 DTD ```xml <?xml version='1.0' encoding='UTF-8'?> <!ELEMENT x (path*, move*, delete*) > <!ELEMENT path EMPTY > <!ATTLIST path d CDATA #REQUIRED stroke CDATA #IMPLIED stroke-width CDATA #IMPLIED id CDATA #IMPLIED > <!ELEMENT move EMPTY > <!ATTLIST move id CDATA #REQUIRED dx CDATA #REQUIRED dy CDATA #REQUIRED > <!ELEMENT delete EMPTY > <!ATTLIST delete id CDATA #REQUIRED > ``` 8.3 Grammar of "d" attribute The grammar of the "d" attribute below is a slight simplification of section 8.3.9 in\(^8\). ``` simple-whiteboard-path: wsp* moveto-drawto-command-groups? wsp* moveto-drawto-command-groups: moveto-drawto-command-group ``` \(^8\)Scalable Vector Graphics (SVG) 1.0 Specification, section 8.3.1.: The grammar for path data [http://www.w3.org/TR/SVG/paths.html#PathDataBNF](http://www.w3.org/TR/SVG/paths.html#PathDataBNF) \[ \text{moveto-drawto-command-group wsp* moveto-drawto-command-groups} \] \[ \text{moveto-drawto-command-group:} \] \[ \text{moveto wsp* drawto-commands?} \] \[ \text{drawto-commands:} \] \[ \text{drawto-command} \] \[ | \text{drawto-command wsp* drawto-commands} \] \[ \text{drawto-command:} \] \[ \text{lineto} \] \[ \text{moveto:} \] \[ ( "M" | "m" ) wsp* moveto-argument-sequence \] \[ \text{moveto-argument-sequence:} \] \[ \text{coordinate-pair} \] \[ | \text{coordinate-pair comma wsp? lineto-argument-sequence} \] \[ \text{lineto:} \] \[ ( "L" | "l" ) wsp* lineto-argument-sequence \] \[ \text{lineto-argument-sequence:} \] \[ \text{coordinate-pair} \] \[ | \text{coordinate-pair comma wsp? lineto-argument-sequence} \] \[ \text{coordinate-pair:} \] \[ \text{coordinate comma wsp? coordinate} \] \[ \text{coordinate:} \] \[ \text{number} \] \[ \text{nonnegative-number:} \] \[ \text{integer-constant} \] \[ | \text{floating-point-constant} \] \[ \text{number:} \] \[ \text{sign? integer-constant} \] \[ | \text{sign? floating-point-constant} \] \[ \text{flag:} \] \[ "0" | "1" \] \[ \text{comma-wsp:} \] \[ (\text{wsp+ comma? wsp*}) | (\text{comma wsp*}) \] \[ \text{comma:} \] \[ ",", \] ### 9 Conclusion The present protocol satisfies its basic requirements: it allows for freehand drawing, it is easy to implement, light-weight and it requires no server changes. ### 10 Acknowledgements The author would like to thank Alexey Shchepin for helpful comments.
{"Source-Url": "https://xmpp.org/extensions/xep-0113.pdf", "len_cl100k_base": 5175, "olmocr-version": "0.1.50", "pdf-total-pages": 14, "total-fallback-pages": 0, "total-input-tokens": 37278, "total-output-tokens": 6351, "length": "2e12", "weborganizer": {"__label__adult": 0.00027751922607421875, "__label__art_design": 0.000591278076171875, "__label__crime_law": 0.0005688667297363281, "__label__education_jobs": 0.0007739067077636719, "__label__entertainment": 0.00013053417205810547, "__label__fashion_beauty": 0.0001010894775390625, "__label__finance_business": 0.000244140625, "__label__food_dining": 0.0001931190490722656, "__label__games": 0.0006737709045410156, "__label__hardware": 0.0018892288208007812, "__label__health": 0.0001809597015380859, "__label__history": 0.00015175342559814453, "__label__home_hobbies": 6.312131881713867e-05, "__label__industrial": 0.0002346038818359375, "__label__literature": 0.0002727508544921875, "__label__politics": 0.00014495849609375, "__label__religion": 0.0002779960632324219, "__label__science_tech": 0.0184173583984375, "__label__social_life": 9.721517562866212e-05, "__label__software": 0.071044921875, "__label__software_dev": 0.9033203125, "__label__sports_fitness": 0.00016880035400390625, "__label__transportation": 0.0001838207244873047, "__label__travel": 0.00010544061660766602}, "weborganizer_max": "__label__software_dev", "avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_ratio": [[0, 20293, 0.02755]], "fineweb_edu_fasttext_gt2__fineweb_edu_fasttext_gt2__score": [[0, 20293, 0.29073]], "ft_lang_id_en_doc_v2__ft_lang_id_en_doc_v2__en": [[0, 20293, 0.80318]], "google_gemma-3-12b-it_contains_pii": [[0, 71, false], [71, 2606, null], [2606, 2606, null], [2606, 5266, null], [5266, 7194, null], [7194, 9902, null], [9902, 10466, null], [10466, 11906, null], [11906, 14327, null], [14327, 16213, null], [16213, 17968, null], [17968, 18809, null], [18809, 20021, null], [20021, 20293, null]], "google_gemma-3-12b-it_is_public_document": [[0, 71, true], [71, 2606, null], [2606, 2606, null], [2606, 5266, null], [5266, 7194, null], [7194, 9902, null], [9902, 10466, null], [10466, 11906, null], [11906, 14327, null], [14327, 16213, null], [16213, 17968, null], [17968, 18809, null], [18809, 20021, null], [20021, 20293, null]], "google_gemma-3-4b-it_v2tag__is_academic_paper": [[0, 5000, true], [5000, 20293, null]], "google_gemma-3-4b-it_v2tag__is_class_syllabus": [[0, 5000, false], [5000, 20293, null]], "google_gemma-3-4b-it_v2tag__is_completion_certificate": [[0, 5000, false], [5000, 20293, null]], "google_gemma-3-4b-it_v2tag__is_court_notice": [[0, 5000, false], [5000, 20293, null]], "google_gemma-3-4b-it_v2tag__is_homework_assignment": [[0, 5000, false], [5000, 20293, null]], "google_gemma-3-4b-it_v2tag__is_news_article": [[0, 5000, false], [5000, 20293, null]], "google_gemma-3-4b-it_v2tag__is_public_order": [[0, 5000, false], [5000, 20293, null]], "google_gemma-3-4b-it_v2tag__is_resume_cv": [[0, 5000, false], [5000, 20293, null]], "google_gemma-3-4b-it_v2tag__is_test_or_quiz": [[0, 5000, false], [5000, 20293, null]], "google_gemma-3-4b-it_v2tag__is_textbook": [[0, 5000, false], [5000, 20293, null]], "pdf_page_numbers": [[0, 71, 1], [71, 2606, 2], [2606, 2606, 3], [2606, 5266, 4], [5266, 7194, 5], [7194, 9902, 6], [9902, 10466, 7], [10466, 11906, 8], [11906, 14327, 9], [14327, 16213, 10], [16213, 17968, 11], [17968, 18809, 12], [18809, 20021, 13], [20021, 20293, 14]], "pipe_delimited_lines_v1__pipe_delimited_lines_v1__pipe_delimited_lines_ratio": [[0, 20293, 0.0]]}
olmocr_science_pdfs
2024-12-03
2024-12-03
05945e16b6d6893e9cb12a57a3c50c393ad26721
Chapter 6 Data Type Chapter 6 Topics • Introduction • Primitive Data Types • Character String Types • User-Defined Ordinal Types • Array Types • Associative Arrays • Record Types • Union Types • Pointer and Reference Types Chapter 6 Data Type Introduction - A data type defines a collection of **data objects** and a set of **predefined operations** on those objects. - Computer programs produce results by manipulating data. - ALGOL 68 provided a few basic types and a few flexible structure-defining operators that allow a programmer to design a data structure for each need. - A **descriptor** is the collection of the attributes of a variable. - In an implementation a descriptor is a collection of memory cells that store variable attributes. - If the attributes are static, descriptor are required only at compile time. - They are built by the compiler, usually as a part of the symbol table, and are used during compilation. - For dynamic attributes, part or all of the descriptor must be maintained during execution. - Descriptors are used for type checking and by allocation and deallocation operations. Primitive Data Types - Those not defined in terms of other data types are called primitive data types. - The primitive data types of a language, along with one or more type constructors provide structured types. Numeric Types 1. Integer - Almost always an exact reflection of the hardware, so the mapping is trivial. - There may be as many as eight different integer types in a language. - Java has four: **byte, short, int, and long**. - Integer types are supported by the hardware. 2. Floating-point - Model real numbers, but only as **approximations** for most real values. - On most computers, floating-point numbers are stored in binary, which exacerbates the problem. - Another problem is the loss of accuracy through arithmetic operations. - Languages for scientific use support at least two floating-point types; sometimes more (e.g. **float, and double**.) – The collection of values that can be represented by a floating-point type is defined in terms of precision and range. – **Precision**: is the accuracy of the fractional part of a value, measured as the number of bits. Figure below shows single and double precision. – **Range**: is the range of fractions and exponents. ![Floating-point representation diagram](image) 3. **Decimal** – Most larger computers that are designed to support business applications have hardware support for **decimal** data types. – Decimal types store a fixed number of decimal digits, with the decimal point at a fixed position in the value. – These are the primary data types for business data processing and are therefore essential to **COBOL**. – **Advantage**: accuracy of decimal values. – **Disadvantages**: limited range since no exponents are allowed, and its representation wastes memory. **Boolean Types** – Introduced by ALGOL 60. – They are used to represent switched and flags in programs. – The use of Booleans enhances readability. – One popular exception is C89, in which **numeric** expressions are used as conditionals. In such expressions, all operands with **nonzero** values are considered **true**, and **zero** is considered **false**. **Character Types** – Char types are stored as numeric codings (ASCII / Unicode). – Traditionally, the most commonly used coding was the **8-bit** code ASCII (American Standard Code for Information Interchange). – A **16-bit** character set named Unicode has been developed as an alternative. – **Java** was the first widely used language to use the Unicode character set. Since then, it has found its way into **JavaScript and C#**. **Character String Types** - A character string type is one in which values are sequences of characters. **Important Design Issues:** 1. Is it a primitive type or just a special kind of array? 2. Is the length of objects static or dynamic? - C and C++ use **char arrays** to store char strings and provide a collection of string operations through a standard library whose header is `string.h`. - How is the length of the char string decided? - The null char which is represented with 0. - Ex: ```c char *str = "apples"; // char ptr points at the str apples0 ``` - In this example, `str` is a char pointer set to point at the string of characters, `apples0`, where 0 is the null char. **String Typical Operations:** - Assignment - Comparison (=, >, etc.) - Catenation - Substring reference - Pattern matching - Some of the most commonly used library functions for character strings in C and C++ are - `strcpy`: copy strings - `strcat`: catenates on given string onto another - `strcmp`: lexicographically compares (the order of their codes) two strings - `strlen`: returns the number of characters, not counting the null - In Java, strings are supported as a **primitive** type by **String** class **String Length Options** - **Static Length String**: The length can be static and set when the string is created. This is the choice for the **immutable** objects of **Java’s String class** as well as similar classes in the C++ standard class library and the .NET class library available to C#. - **Limited Dynamic Length Strings**: allow strings to have varying length up to a **declared and fixed maximum** set by the variable’s definition, as exemplified by the strings in C. - **Dynamic Length Strings**: Allows strings various length with no maximum. Requires the overhead of dynamic storage allocation and deallocation but provides flexibility. Ex: **Perl and JavaScript**. **Evaluation** - Aid to writability. - As a primitive type with static length, they are inexpensive to provide—why not have them? - Dynamic length is nice, but is it worth the expense? **Implementation of Character String Types** - **Static length** - compile-time descriptor has three fields: 1. Name of the type 2. Type’s length 3. Address of first char ``` <table> <thead> <tr> <th>Static string</th> <th>Length</th> <th>Address</th> </tr> </thead> </table> ``` Compiler-time descriptor for static strings - **Limited dynamic length Strings** - may need a run-time descriptor for length to store both the fixed maximum length and the current length (but not in C and C++ because the end of a string is marked with the `null` character). ``` <table> <thead> <tr> <th>Limited dynamic string</th> <th>Maximum length</th> <th>Current length</th> <th>Address</th> </tr> </thead> </table> ``` Run-time descriptor for limited dynamic strings - **Dynamic length Strings**— - Need run-time descriptor because only current length needs to be stored. - Allocation/deallocation is the biggest implementation problem. Storage to which it is bound must grow and shrink dynamically. - There are two approaches to supporting allocation and deallocation: 1. Strings can be stored in a linked list “Complexity of string operations, pointer chasing” 2. Store strings in adjacent cells. “What about when a string grows?” Find a new area of memory and the old part is moved to this area. Allocation and deallocation is slower but using adjacent cells results in faster string operations and requires less storage. User-Defined Ordinal Types - An ordinal type is one in which the range of possible values can be easily associated with the set of positive integers - Examples of primitive ordinal types in Java - integer - char - boolean - In some languages, users can define two kinds of ordinal types: enumeration and subrange. Enumeration Types - All possible values, which are named constants, are provided in the definition - C++ example ```cpp class colors { public final int red = 0; public final int blue = 1; } ``` - The enumeration constants are typically implicitly assigned the integer values, 0, 1, …, but can be explicitly assigned any integer literal. - Java does not include an enumeration type, presumably because they can be represented as data classes. For example, ```java class colors { public final int red = 0; public final int blue = 1; } ``` Subrange Types - An ordered contiguous subsequence of an ordinal type - Example: 12..18 is a subrange of integer type - Ada’s design ```ada type Days is (mon, tue, wed, thu, fri, sat, sun); subtype Weekdays is Days range mon..fri; subtype Index is Integer range 1..100; ``` ```ada Day1: Days; Day2: Weekday; Day2 := Day1; ``` **Array Types** - An array is an aggregate of **homogeneous** data elements in which an individual element is identified by its position in the aggregate, relative to the first element. - A reference to an array element in a program often includes one or more non-constant subscripts. - Such references require a run-time calculation to determine the memory location being referenced. **Design Issues** - What types are legal for subscripts? - Are subscripting expressions in element references range checked? - When are subscript ranges bound? - When does allocation take place? - What is the maximum number of subscripts? - Can array objects be initialized? **Arrays and Indexes** - Indexing is a mapping from indices to elements. - The mapping can be shown as: \[ \text{map(array\_name, index\_value\_list)} \rightarrow \text{an element} \] - Ex: Ada \[ \text{Sum} := \text{Sum} + \text{B(I)}; \] Because ( ) are used for both subprogram parameters and array subscripts in Ada, this results in **reduced readability**. - C-based languages use [ ] to delimit array indices. - Two distinct types are involved in an array type: - The element type, and - The type of the subscripts. - The type of the subscript is often a sub-range of integers. - Ada allows other types as subscripts, such as Boolean, char, and enumeration. - Among contemporary languages, C, C++, Perl, and Fortran **don't** specify range checking of subscripts, but Java, and C# **do**. Subscript Bindings and Array Categories - The binding of subscript type to an array variable is usually static, but the subscript value ranges are sometimes dynamically bound. - In C-based languages, the lower bound of all index ranges is fixed at 0; Fortran 95, it defaults to 1. 1. A static array is one in which the subscript ranges are statically bound and storage allocation is static (done before run time). - Advantages: efficiency “No allocation & deallocation.” - Ex: Arrays declared in C & C++ function that includes the static modifier are static. 2. A fixed stack-dynamic array is one in which the subscript ranges are statically bound, but the allocation is done at elaboration time during execution. - Advantages: Space efficiency. A large array in one subprogram can use the same space as a large array in different subprograms. - Ex: Arrays declared in C & C++ function without the static modifier are fixed stack-dynamic arrays. 3. A stack-dynamic array is one in which the subscript ranges are dynamically bound, and the storage allocation is dynamic “during execution.” Once bound they remain fixed during the lifetime of the variable. - Advantages: Flexibility. The size of the array is not known until the array is about to be used. - Ex: Ada arrays can be stack dynamic: ```ada Get (List_Len); declare List : array (1..List_Len) of Integer; begint . . . end; ``` The user inputs the number of desired elements for array List. The elements are then dynamically allocated when execution reaches the declare block. When execution reaches the end of the block, the array is deallocated. 4. A **fixed heap-dynamic array** is one in which the subscript ranges are dynamically bound, and the storage allocation is dynamic, but they are both fixed after storage is allocated. - The bindings are done when the user program requests them, rather than at elaboration time and the storage is allocated on the heap, rather than the stack. - Ex: C & C++ also provide **fixed heap-dynamic arrays**. The function `malloc` and `free` are used in C. The operations `new` and `delete` are used in C++. In Java all arrays are **fixed heap dynamic arrays**. Once created, they keep the same subscript ranges and storage. 5. A **heap-dynamic array** is one in which the subscript ranges are dynamically bound, and the storage allocation is dynamic, and can change any number of times during the array’s lifetime. - **Advantages**: Flexibility. Arrays can grow and shrink during program execution as the need for space changes. - Ex: C# provides **heap-dynamic arrays** using an array class `ArrayList`. ```csharp ArrayList intList = new ArrayList(); Elements are added to this object with the `Add` method, as in `intArray.Add(nextOne);` Perl and JavaScript also support heap-dynamic arrays. For example, in Perl we could create an array of five numbers with ```perl @list = {1, 2, 4, 7, 10}; Later, the array could be lengthened with the `push` function, as in `push(@list, 13, 17);` Now the array’s value is (1, 2, 4, 7, 10, 13, 17).``` Array Initialization - Usually just a list of values that are put in the array in the order in which the array elements are stored in memory. - Fortran uses the DATA statement, or put the values in / ... / on the declaration. ```plaintext Integer List (3) Data List /0, 5, 5/ // List is initialized to the values ``` - C and C++ - put the values in braces; let the compiler count them. ```plaintext int stuff [] = {2, 4, 6, 8}; ``` - The compiler sets the length of the array. - What if the programmer mistakenly left a value out of the list? - Character Strings in C & C++ are implemented as arrays of char. ```plaintext char name [ ] = “Freddie”; //how many elements in array name? ``` - The array will have 8 elements because the null character is implicitly included by the compiler. - In Java, the syntax to define and initialize an array of references to String objects. ```plaintext String [ ] names = [“Bob”, “Jake”, “Debbie”]; ``` - Ada positions for the values can be specified: ```plaintext List : array (1..5) of Integer := (1, 3, 5, 7, 9); Bunch : array (1..5) of Integer:= (1 => 3, 3 => 4, others => 0); Note: the array value is (3, 0, 4, 0, 0) ``` Implementation of Arrays - Access function maps subscript expressions to an address in the array - Access function for single-dimensioned arrays: \[ \text{address}(\text{list}[k]) = \text{address}(\text{list}[\text{lower_bound}]) + ((k - \text{lower_bound}) \times \text{element_size}) \] - Accessing Multi-dimensioned Arrays - Two common ways: - Row major order (by rows) – used in most languages - Column major order (by columns) – used in Fortran - For example, if the matrix had the values \[ \begin{bmatrix} 3 & 4 & 7 \\ 6 & 2 & 5 \\ 1 & 3 & 8 \end{bmatrix} \] - It would be stored in row major order as: 3, 4, 7, 6, 2, 5, 1, 3, 8 - If the example matrix above were stored in column major, it would have the following order in memory. 3, 6, 1, 4, 2, 3, 7, 5, 8 - In all cases, sequential access to matrix elements will be faster if they are accessed in the order in which they are stored, because that will minimize the paging. (Paging is the movement of blocks of information between disk and main memory. The objective of paging is to keep the frequently needed parts of the program in memory and the rest on disk.) - Locating an Element in a Multi-dimensioned Array (row major) \[ \text{Location}(a[i,j]) = \text{address of } a[1,1] + ((i - 1) \times n + (j - 1)) \times \text{element_size} \] **Associative Arrays** - An associative array is an unordered collection of data elements that are indexed by an equal number of values called **keys**. - So each element of an associative array is in fact a pair of entities, a key and a value. - Associative arrays are supported by the standard class libraries of Java and C++ and Perl. - Example: In Perl, associative arrays are often called **hashes**. Names begin with %; literals are delimited by parentheses ``` %temps = ("Mon" => 77, "Tue" => 79, "Wed" => 65); o Subscripting is done using braces and keys $temps{"Wed"} = 83; o Elements can be removed with delete delete $temps{"Tue"}; o Elements can be emptied by assigning the empty literal @temps = ( ); ``` **Record Types** - A record is a possibly **heterogeneous** aggregate of data elements in which the individual elements are identified by names. - In C, C++, and C#, records are supported with the **struct** data type. In C++, structures are a minor variation on classes. - COBOL uses level numbers to show nested records; others use recursive definition - **Definition of Records in COBOL** - COBOL uses level numbers to show nested records; others use recursive definition ``` 01 EMP-REC. 02 EMP-NAME. 05 FIRST PIC X(20). 05 MID PIC X(10). 05 LAST PIC X(20). 02 HOURLY-RATE PIC 99V99. ``` - **Definition of Records in Ada** - Record structures are indicated in an orthogonal way ``` type Emp_Rec_Type is record First: String (1..20); Mid: String (1..10); Last: String (1..20); Hourly_Rate: Float; end record; Emp_Rec: Emp_Rec_Type; ``` **References to Records** - Most language use dot notation ``` Emp_Rec.Name ``` - Fully qualified references must include all record names - Elliptical references allow leaving out record names as long as the reference is unambiguous, for example in COBOL ``` FIRST, FIRST OF EMP-NAME, and FIRST OF EMP-REC are elliptical references to the employee's first name ``` **Operations on Records** - Assignment is very common if the types are identical - Ada allows record comparison - Ada records can be initialized with aggregate literals - COBOL provides MOVE CORRESPONDING - Copies a field of the source record to the corresponding field in the target record **Unions Types** - A union is a type whose variables are allowed to store different type values at different times during execution. **Discriminated vs. Free Unions** - **Fortran, C, and C++** provide union constructs in which there is no language support for type checking; the union in these languages is called *free union*. - Type checking of unions require that each union include a type indicator called a *discriminated union*. - Supported by **Ada** **Ada Union Types** ```ada type Shape is (Circle, Triangle, Rectangle); type Colors is (Red, Green, Blue); type Figure (Form: Shape) is record Filled: Boolean; Color: Colors; case Form is when Circle => Diameter: Float; when Triangle => Leftside, Rightside: Integer; Angle: Float; when Rectangle => Side1, Side2: Integer; end case; end record; ``` **Evaluation of Unions** - Potentially **unsafe** construct - Java and C# **do not** support unions - Reflective of growing concerns for safety in programming language **Pointers** - A pointer type in which the vars have a range of values that consists of memory addresses and a special value, nil. - The value nil is not a valid address and is used to indicate that a pointer cannot currently be used to reference any memory cell. **Pointer Operations** - A pointer type usually includes two fundamental pointer operations, assignment and dereferencing. - Assignment sets a pointer var’s value to some useful address. - Dereferencing takes a reference through one level of indirection. - In C++, dereferencing is explicitly specified with the (*) as a prefix unary operation. - If `ptr` is a pointer var with the value 7080, and the cell whose address is 7080 has the value 206, then the assignment \[ j = *ptr \] sets `j` to 206. **Pointer Problems** 1. **Dangling pointers** *(dangerous)* - A pointer points to a heap-dynamic variable that has been **deallocated**. - Dangling pointers are dangerous for the following reasons: - The location being pointed to may have been allocated to some new heap-dynamic var. If the new var is not the same type as the old one, type checks of uses of the dangling pointer are invalid. - Even if the new one is the same type, its new value will bear no relationship to the old pointer’s dereferenced value. - If the dangling pointer is used to change the heap-dynamic variable, the value of the heap-dynamic variable will be destroyed. - It is possible that the location now is being temporarily used by the storage management system, possibly as a pointer in a chain of available blocks of storage, thereby allowing a change to the location to cause the storage manager to fail. - The following sequence of operations creates a dangling pointer in many languages: a. Pointer \( p_1 \) is set to point at a new heap-dynamic variable. b. Set a second pointer \( p_2 \) to the value of the first pointer \( p_1 \). c. The heap-dynamic variable pointed to by \( p_1 \) is explicitly deallocated (setting \( p_1 \) to nil), but \( p_2 \) is not changed by the operation. \( p_2 \) is now a dangling pointer. 2. **Lost Heap-Dynamic Variables** *(wasteful)* - A heap-dynamic variable that is no longer referenced by any program pointer “no longer accessible by the user program.” - Such variables are often called **garbage** because they are not useful for their original purpose, and also they can’t be reallocated for some new use by the program. - Creating Lost Heap-Dynamic Variables: a. Pointer \( p_1 \) is set to point to a newly created heap-dynamic variable. b. \( p_1 \) is later set to point to another newly created heap-dynamic variable. c. The first heap-dynamic variable is now inaccessible, or lost. - The process of losing heap-dynamic variables is called **memory leakage**. Pointers in Ada - Some dangling pointers are disallowed because dynamic objects can be automatically de-allocated at the end of pointer's type scope - The lost heap-dynamic variable problem is not eliminated by Ada Pointers in Fortran 95 - Pointers point to heap and non-heap variables - Implicit dereferencing - Pointers can only point to variables that have the TARGET attribute - The TARGET attribute is assigned in the declaration: INTEGER, TARGET :: NODE Pointers in C and C++ - Extremely flexible but must be used with care. - Pointers can point at any variable regardless of when it was allocated - Used for dynamic storage management and addressing - Pointer arithmetic is possible in C and C++ makes their pointers more interesting than those of the other programming languages. - Unlike the pointers of Ada, which can only point into the heap, C and C++ pointers can point at virtually any variable anywhere in memory. - Explicit dereferencing and address-of operators - In C and C++, the asterisk (*) denotes the dereferencing operation, and the ampersand (&) denotes the operator for producing the address of a variable. For example, in the code int *ptr; int count, init; ... ptr = &init; count = *ptr - the two assignment statement are equivalent to the single assignement count = init; - Example: Pointer Arithmetic in C and C++ int list[10]; int *ptr; ptr = list; *(ptr+5) is equivalent to list[5] and ptr[5] *(ptr+i) is equivalent to list[i] and ptr[i] - Domain type need not be fixed (void *) - void * can point to any type and can be type checked (cannot be de-referenced) Reference Types - C++ includes a special kind of pointer type called a reference type that is used primarily for formal parameters in function definition. - A C++ reference type variable is a constant pointer that is always implicitly dereferenced. - Because a C++ reference type variable is a constant, it must be initialized with the address of some variable in its definition, and after initialization a reference type variable can never be set to reference any other variable. - Reference type variables are specified in definitions by preceding their names with ampersands (&). For example, ```c++ int result = 0; int &ref_result = result; ... ref_result = 100; ``` In this code segment, result and ref_result are aliases. - In Java, reference variables are extended from their C++ form to one that allow them to replace pointers entirely. - The fundamental difference between C++ pointers and Java references is that C++ pointers refer to memory addresses, whereas Java references refer to class instances. - Because Java class instances are implicitly deallocated (there is no explicit deallocation operator), there cannot be a dangling reference. - C# includes both the references of Java and the pointers of C++. However, the use of pointers is strongly discouraged. In fact, any method that uses pointers must include the unsafe modifier. - Pointers can point at any variable regardless of when it was allocated.
{"Source-Url": "http://www2.southeastern.edu/Academics/Faculty/kyang/2008/Fall/CMPS401/ClassNotes/CMPS401ClassNotesChap06.pdf", "len_cl100k_base": 5922, "olmocr-version": "0.1.53", "pdf-total-pages": 18, "total-fallback-pages": 0, "total-input-tokens": 34407, "total-output-tokens": 6976, "length": "2e12", "weborganizer": {"__label__adult": 0.0003333091735839844, "__label__art_design": 0.00021827220916748047, "__label__crime_law": 0.00020933151245117188, "__label__education_jobs": 0.00039458274841308594, "__label__entertainment": 3.910064697265625e-05, "__label__fashion_beauty": 0.0001264810562133789, "__label__finance_business": 9.566545486450197e-05, "__label__food_dining": 0.00032019615173339844, "__label__games": 0.0004029273986816406, "__label__hardware": 0.0008244514465332031, "__label__health": 0.0003075599670410156, "__label__history": 0.0001709461212158203, "__label__home_hobbies": 7.021427154541016e-05, "__label__industrial": 0.00028252601623535156, "__label__literature": 0.00017249584197998047, "__label__politics": 0.00017058849334716797, "__label__religion": 0.0004286766052246094, "__label__science_tech": 0.0033206939697265625, "__label__social_life": 6.109476089477539e-05, "__label__software": 0.0034122467041015625, "__label__software_dev": 0.98779296875, "__label__sports_fitness": 0.0002715587615966797, "__label__transportation": 0.0003664493560791016, "__label__travel": 0.00017940998077392578}, "weborganizer_max": "__label__software_dev", "avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_ratio": [[0, 24879, 0.01513]], "fineweb_edu_fasttext_gt2__fineweb_edu_fasttext_gt2__score": [[0, 24879, 0.9522]], "ft_lang_id_en_doc_v2__ft_lang_id_en_doc_v2__en": [[0, 24879, 0.87358]], "google_gemma-3-12b-it_contains_pii": [[0, 224, false], [224, 2011, null], [2011, 3692, null], [3692, 5597, null], [5597, 7195, null], [7195, 8404, null], [8404, 9887, null], [9887, 11524, null], [11524, 13048, null], [13048, 14229, null], [14229, 15580, null], [15580, 16336, null], [16336, 17931, null], [17931, 18972, null], [18972, 19745, null], [19745, 21821, null], [21821, 23453, null], [23453, 24879, null]], "google_gemma-3-12b-it_is_public_document": [[0, 224, true], [224, 2011, null], [2011, 3692, null], [3692, 5597, null], [5597, 7195, null], [7195, 8404, null], [8404, 9887, null], [9887, 11524, null], [11524, 13048, null], [13048, 14229, null], [14229, 15580, null], [15580, 16336, null], [16336, 17931, null], [17931, 18972, null], [18972, 19745, null], [19745, 21821, null], [21821, 23453, null], [23453, 24879, null]], "google_gemma-3-4b-it_v2tag__is_academic_paper": [[0, 5000, false], [5000, 24879, null]], "google_gemma-3-4b-it_v2tag__is_class_syllabus": [[0, 5000, false], [5000, 24879, null]], "google_gemma-3-4b-it_v2tag__is_completion_certificate": [[0, 5000, false], [5000, 24879, null]], "google_gemma-3-4b-it_v2tag__is_court_notice": [[0, 5000, false], [5000, 24879, null]], "google_gemma-3-4b-it_v2tag__is_homework_assignment": [[0, 5000, false], [5000, 24879, null]], "google_gemma-3-4b-it_v2tag__is_news_article": [[0, 5000, false], [5000, 24879, null]], "google_gemma-3-4b-it_v2tag__is_public_order": [[0, 5000, false], [5000, 24879, null]], "google_gemma-3-4b-it_v2tag__is_resume_cv": [[0, 5000, false], [5000, 24879, null]], "google_gemma-3-4b-it_v2tag__is_test_or_quiz": [[0, 5000, false], [5000, 24879, null]], "google_gemma-3-4b-it_v2tag__is_textbook": [[0, 5000, true], [5000, 24879, null]], "pdf_page_numbers": [[0, 224, 1], [224, 2011, 2], [2011, 3692, 3], [3692, 5597, 4], [5597, 7195, 5], [7195, 8404, 6], [8404, 9887, 7], [9887, 11524, 8], [11524, 13048, 9], [13048, 14229, 10], [14229, 15580, 11], [15580, 16336, 12], [16336, 17931, 13], [17931, 18972, 14], [18972, 19745, 15], [19745, 21821, 16], [21821, 23453, 17], [23453, 24879, 18]], "pipe_delimited_lines_v1__pipe_delimited_lines_v1__pipe_delimited_lines_ratio": [[0, 24879, 0.00922]]}
olmocr_science_pdfs
2024-12-10
2024-12-10
9af505bf2e9b79c4f54faf2b713209b6b347a04a
Answer Set Programming in Proofdoku Adam M. Smith amsmith@ucsc.edu UC Santa Cruz Department of Computational Media Abstract Proofdoku is an AI-based game design that extends Sudoku. In addition to playing by the rules of the traditional logic puzzle, players must explain their reasoning. An AI system checks this reasoning and provides hints that guide the player to discover new reasoning patterns for themselves. Co-developing the game design and the AI system, implemented using the technology of Answer Set Programming (ASP), guided us to include features that depend on high-complexity combinatorial search and optimization. We developed Proofdoku to better understand the implications of designing and deploying game systems that depend on ASP for live interaction. This paper offers design tradeoffs and makes suggestions for future deployments of ASP-backed game designs. Introduction Proofdoku is an extension to the traditional Japanese logic puzzle Sudoku, developed within the practice of AI-based game design (Eladhari et al. 2011). The Proofdoku project aims to uncover new player experiences unreachable without the affordances of artificial intelligence (AI) systems as well as to understand how the context of a deployed game pushes back on those systems. In Proofdoku, the player works under the traditional rules of Sudoku with one key twist: they must explain their reasoning (and it must be valid). A small AI system, built using the technology of answer set programming (ASP) (Gebser et al. 2012) and co-developed with the design of the game, plays several roles during gameplay including checking the validity of player arguments and computing hints for the various phases of play. Through interaction with Proofdoku, players can learn and generalize new deductive inference patterns for Sudoku (including those unknown to the designers). The Proofdoku project was initiated to answer specific questions about applying ASP: What practical engineering concerns arise when deploying an ASP-backed gameplay experience? Which aspects of live play might be enabled or enhanced using ASP? These questions are answered here in necessarily game-specific ways. However, the concerns that arose in design, development, and deployment touch on much broader issues: maintaining responsiveness of the AI system for players; the level of project-specific engineering; software licensing; and monetary costs associated with centralization. This paper makes the following contributions: - We describe an AI-based puzzle game in which ASP is used to enable several aspects of the player experience. - We show how hinting systems and other feedback mechanisms emerge from the architectural surplus of ASP. - We compare of ASP deployment alternatives in the concrete context working within a modern web browser. - We make suggestions for caching and network architecture that overcome many of the costs associated with provisioning a centralized solving service. Background We first review some context for the Proofdoku project. AI-based Game Design In introducing the practice of AI-based game design, Eladhari et al. (2011) argue that “the development of innovative artificial intelligence systems plays a crucial role in the exploration of currently unreachable [game design] spaces.” AI-based game designs are those that have an AI system closely integrated into the core mechanics, aesthetics and story. For example, Prom Week (McCoy et al. 2013) is a game that intimately depends on the CiF (McCoy et al. 2010) AI system for social physics modeling. In Sarah and Sally (Černý 2015), an action planning system allows for cooperative puzzle solving in the context of a single-player game. In Proofdoku, the player manipulates sets of evidence (selected cells on the board) that they think will convince the AI system. In the commercial setting, Third Eye Crime (Moonshot Games 2014) and The Sims (Maxis 2000) are AI-based game designs that also revolve around understanding and manipulating AI-driven character behaviors. In AI-based game design, co-development of an AI system and a game design allows for productive mutual influence: the affordances of the AI system suggest new game design options and the context of the game design push back with new requirements for the AI system. Proofdoku’s design was shaped through several cycles of this influence. **Answer Set Programming** ASP is a declarative logic programming paradigm oriented at solving complex (NP-hard) search and optimization problems (Gebser et al. 2012). ASP technology combines a modeling language used for describing domain-specific problems with domain-independent algorithms for solving them. In particular, ASP uses a Prolog-like modeling language called AnsProlog. Most answer-set solvers rely on the latest algorithms emerging from the SAT/SMT literature. We use the Clingo-5 system, a modern ASP system with support for defining custom search heuristics, externally checked constraints interleaved with the search process, and hooks for scripting languages in the service of integrating the solvers with outside environments. Proofdoku makes use some key features in Clingo not found in non-ASP systems such as the SAT solver MiniSat (Eén and Sörensson 2003). For example, we rely on disjunctive ASP (Gebser, Kaufmann, and Schaub 2013) to express a search problem outside of the complexity class NP when searching over arguments the player might make. We combine this with optimization criteria to find the best argument. In hinting modes, we make use of brave and cautious reasoning modes (Eiter, Ianni, and Krennwallner 2009) to efficiently access the union and intersection of all possible solutions to a puzzle or arguments for a given conclusion. **ASP in Game Design Applications** ASP is not commonly used in game design applications. Against this background, proposals for using ASP to analyze game mechanics (Smith, Nelson, and Mateas 2010) or to model design spaces for procedural content generation (Smith and Mateas 2011) stand out. Both of these emphasize offline applications of ASP that avoid interactive contact with players, instead yielding design insights or generating datasets that impact the player experience later on, as in Infinite Refraction (Butler et al. 2015). Butler et al. (2013) describe a system built on live interaction with ASP-based content generators and gameplay analyzers. However, this mixed-initiative design tool still emphasizes design-time use by a single user. Here, responsiveness is valued but not critical. Likewise, scalability to many users on diverse devices and networks is not relevant. Compton et al. describe Anza Island (Compton, Smith, and Mateas 2012), an AI-based game design in which the player interacts with an ASP-driven agent by adding and removing constraints represented by collectible cards. While Anza Island breaks ground with novel gameplay, it does so at the level of a prototype. The Proofdoku project brings ASP-backed gameplay out of the lab where a broader external context can push back on the design of the AI system. **Game Design** In this section, we describe Proofdoku in game design and implementation terms, saving details of the AI system for the subsequent section. --- 1 Boolean satisfiability or Satisfiability Modulo Theories 2 https://potassco.org/clingo/ --- Figure 1: Initial state of a puzzle in Proofdoku. White numbers represent clue cells. Empty cells must be filled by the player by making arguments. Four cells of evidence (black background) are selected towards arguing for conclusion cell (green outline). Other background colors visualize local ambiguity: the number of different values that cell might take on across all evidence-consistent solutions (ignoring other clues). These four evidence cells are sufficient to argue that the conclusion cell must be filled with a 1. **Sudoku Basics** In traditional Sudoku puzzles, the player is faced with a $9 \times 9$ grid of cells. The cells will be filled with numbers from 1 to 9. Although many cells start blank, clue cells come pre-filled, restricting the choices for the blank cells in such a way that there is one unique way to fill in the blanks. The player’s job is to fill in the blanks so that each number is used exactly once in each row, once in each column, and once in each 3-by-3 sub-grid (sometimes called a cage). Figure 1 shows the initial state of a relatively difficult Sudoku puzzle (as visualized within Proofdoku with an optimal opening argument displayed). Of the 81 total cells, 23 are provided as clues and 58 must be filled by the player. Players access and play Sudoku puzzles in a variety of media including physical books and newspapers or digital apps and websites. Proofdoku seeks the attention of players who play the daily puzzles on websites such as New York Times or USA Today using desktop computers and mobile devices (smartphones and tablets). **Proofdoku Phases and Flow** As a digital adaptation of a traditionally pen-and-paper puzzle, play in Proofdoku moves through a number of phases of interaction with our game website. The overall flow between these phases is visualized in Figure 2. --- 3 https://www.nytimes.com/crosswords/game/sudoku/easy 4 http://puzzles.usatoday.com/sudoku/ 5 http://proofdoku.com/ In the **Start** phase, the player selects a puzzle to play. Our game currently offers a fixed tutorial puzzle (accompanied by additional guidance not present on other puzzles) and fixed easy, medium, and hard difficulty puzzles. These are complemented with a small set of dynamic (updating daily) puzzles. We currently offer the daily easy, medium, and hard puzzles from the New York Times website as well as the USA Today puzzle of the day. Upon selecting a puzzle, the player enters the **Strategy** phase. In this phase, the player needs to make a choice about which blank cell they will fill next. Selecting a blank cell registers it as the intended conclusion and carries the player to the next phase. Strategy choices can be made based on player intuition or guidance from our hint system. No strategy is invalid, but few choices in any given state set the player up for making an argument of reasonable (small) size. In the **Tactics** phase, the player selects filled cells build the an evidence set—these are cells that are the premises in the players argument. After each change, the game quickly responds to tell the player if their argument is valid. If so, the player may complete the argument, resulting in a transition back to the **Strategy** phase now with one more cell filled. Players may also abandon an argument and transition back to the **Strategy** phase without filling the conclusion. In this case, the game remembers the last state of their argument for the given conclusion so they can recover their attempt later. Once all cells are filled, no more choices in the **Strategy** phase are available. In this case, the player transitions to the **Victory** phase where they see a visualization of all of the cells they have filled in using arguments. They may have long forgotten which cells they filled versus were provided originally, so this reminds them of their achievement. **Evergreen Design and Sustainable Deployment** A key design goal in Proofdoku is evergreen design: the game should always feel fresh and up-to-date, even years after initial deployment with no recent developer attention. To support this, our puzzle selection emphasizes daily puzzles from outside sources as well as the ability to import puzzles from new sources that become popular in the future. Additionally, we aim to make system architecture choices consistent leaving the game deployed with near-zero running costs. Proofdoku is built on Google App Engine® (GAE) and primarily implemented as a static webpage that can be served with zero application server instances. The daily puzzle selection represents a tiny amount of nearly static content (changing just once a day) served from a Cloud Storage bucket. These components of the game can be scalably accessed by millions of players per day while still falling well within the free tier of Google’s cloud services. Outside of the game’s static webpage, additional logic is needed to keep the game fresh. For a few seconds per day, puzzle scraping scripts run to fetch the daily puzzles from remote sites. Beyond this, our AI system (a general purpose ASP web service described later) also runs on the same cloud platform in a way that fits into the free tier. **Arguments** Arguments for the value of a blank cell are a core concept in Proofdoku. An argument is defined with respect to a puzzle board and is composed of an evidence set (a subset of the filled cells) and a conclusion cell (one of the blank cells). An argument may be valid or invalid. An argument is valid if and only if any board configuration consistent with the evidence set agrees with the conclusion. Amongst valid arguments for a given conclusion, optimal arguments are those with the least possible amount of evidence (by cell count). **Feedback Mechanisms** In order to help the player share their reasoning with the game, the game tries to continually share its reasoning with the player. After each change to the evidence set (in the Tactics phase) we show how much the range of legal possibilities for every other cell was impacted. This can help the player spot long range implications as well as when adding a certain cell of evidence has no impact on a cell of interest. For the conclusion cell, we give the player visual feedback as to whether their valid argument is optimal or not. They may proceed back to the Strategy phase with any valid argument, or they may continue searching to find an optimal argument if they like. **Hints** Despite having the same core rules as traditional Sudoku, Proofdoku’s argument mechanic is generally unfamiliar to our players. As such, our hinting systems revolve around guiding the player through the argument making process rather than underlying Sudoku reasoning. Hints of the style provided in *SquareLogic* (TrueThought LLC, 2009) would compliment the hinting design currently used in Proofdoku. In the Strategy phase, the player may want guidance for which cell to use as a conclusion. Our hint system (upon player request) will add a glinting animation to one of the blank cells that can be proven with the least amount of evidence (often there are several possibilities). Arguments involving fewer cells of evidence are often conceptually simpler than those that use more, but this is not always the case. There are a number of size-8 arguments (selecting all the cells but the conclusion in a row, a column, or a cage) that feel quite simple despite using more evidence than less structured size-6 arguments. In the Tactics phase, we can suggest which cells must be included in an evidence set in order to be part of an optimal argument as well as those which should never be selected in --- 6https://cloud.google.com/appengine/ num(1..9). cage(I,J,((I-1)/3)*3+((J-1)/3)+1) :- num(I); num(J). 1 { fill(I,J, D) : num(D) } 1 :- num(I); num(J). 1 { fill(I,J, D) : num(1) } 1 :- num(D); num(J). 1 { fill(I,J, D) : num(J) } 1 :- num(I); num(D). 1 { fill(I,J, D) : cage(I,J,C) } 1 :- num(C); num(D). fill(I,J, D) :- clue(I,J, D). #show fill/3. Figure 3: board.lp defines the rules of Sudoku. any optimal argument. If there is only one optimal argument (uncommon), this hinting design will reveal the full details of that argument. Otherwise, it will focus the player’s attention away from irrelevant cells on the board. **Formulation in ASP** Our AI system performs several inference tasks in support of core gameplay, feedback mechanisms, and hinting systems in Proofdoku. In this section, we describe how these tasks are formulated in ASP. Each inference task in our system is resolved by a single execution of Clingo. An execution involves a program—a combination of a general problem encoding and a specific problem instance—and some command line arguments which alter the behavior of the solver. **board.lp** When the player starts a puzzle the game only knows about the set of clues that define the puzzle. Before transitioning out of the Start phase, we verify that the clues imply a unique solution for the board and record the details of that solution for later. This is a basic Sudoku solving task. Our first program simply states the rules of Sudoku: there are numbers 1 to 9; each number is used exactly once in a row, column, and cage (where the structure of cages is defined by a formula); and if a cell has a clue, the number filled in that cell must match the clue. We store this general problem encoding in a file called board.lp (see Figure 3). To find the initial solution to the player’s puzzle selection, we wrangle the puzzle’s clues into logical facts like clue(2,4,9) which says that the cell on row 2 and column 4 holds a clue value of 9. These facts define a specific problem instance. Combining board.lp with this instance, we execute Clingo with command line arguments asking for two distinct solutions. If the solver returns no solutions, the clue set was invalid. If the solver returns two solutions, the clue set was ambiguous. If just one solution is returned, it is because the solver has verified that there is a unique solution (the most common case). Later during play in the Tactics phase, we want to check the validity of the player’s argument as well as to visualize the ambiguity of every cell. We accomplish this by combining board.lp with a different problem instance. Instead of using all of the puzzle’s known cells as clue facts, we include only those cells marked as evidence. Instead of asking for two distinct solutions, we as the solver to compute the union of all possible solutions with brave reasoning. If we group the resulting outputs for the fill predicate by cell we can compute the level of ambiguity as the count of different assignments for that cell. Examining the ambiguity of the conclusion cell, we can quickly see if there was only one legal possibility (hence if the argument was valid or not). **argument.lp** The program above considered just one given evidence set. A different approach must be used if we want to reason across all evidence sets. The first place this occurs is in the computation of hints in the Strategy phase. Of all possible valid arguments that could be made in a given board state, we want to highlight one of the conclusion cells associated with arguments with a least-size evidence set. The notion of argument optimality in Proofdoku is defined solely in argument.lp (not in the interaction and graphics code), so it could be locally altered to support alternative notions of simplicity or elegance of arguments. To model the space of valid arguments, we want to say that there exists a selection of premises and conclusion such that for all legal ways of filling the Sudoku grid if the filling agrees with the premises then it must agree with the conclusion. Effectively, we want to the solver to show the following where \( p \), \( c \), and \( f \) are sets of assignments of cells to numbers representing the premises, conclusion, and any complete filling respectively. \[ \exists p, c \forall f : \text{Legal}(f) \rightarrow (p \subseteq f \rightarrow c \subseteq f) \] The general problem of showing the truth of an \( \exists \forall \) quantified boolean formula (known as 2-QBF) has complexity beyond the class NP, and thus it cannot be solved by tools such as SAT solvers which only cover NP. 2-QBF is in fact the canonical problem for the class \( \Sigma_2^p \) on the second level of the Polynomial Hierarchy. Disjunctive answer set solvers (such as Clingo) can express problems of this complexity, but only with considerable hassle for the programmer by applying the saturation technique introduced by Eiter (2009). Although conventional ASP wisdom suggests avoiding saturation encodings in favor of metaprogramming approaches as in metasp (Gebser, Kaminski, and Schaub 2011)—also applied game content generation (Smith and Butler 2013)—the rules of Sudoku are simple enough to express. Our second answer set program, argument.lp (see Figure 4), uses choice rules to nondeterministically guess an argument and then a saturation-encoding restatement of the rules of Sudoku to express the nonexistence of solutions that would falsify the argument. Additionally, it states optimization criteria: one point of cost for each cell selected as a premise in the argument. To compute hints in the Strategy phase, we wrangle the currently filled cells into clued(I,J) facts and the contents of the puzzle’s previously-computed solution into fill(I,J,D) facts. We then execute Clingo with argument.lp and these facts with command line flags asking it to emit only solutions that are proven to be optimal. Upon entering the Tactics phase, we execute Clingo num(1..9). cage(I,J,(((I-1)/3)*3)+((J-1)/3)+1) :- num(I); num(J). clued(I,J) :- clue(I,J,D). 1 { premise(I,J); clued(I,J) }. 1 { conclusion(I,J); num(I), num(J), not clued(I,J) } 1. altfill(I,J,D): num(D) :- num(I); num(J). bot :- altfill(I,J,D); premise(I,J); not fill(I,J,D). bot :- altfill(I,J,D); conclusion(I,J); fill(I,J,D). bot :- 2 { altfill(I,J,D); num(D) } ; num(I); num(J). bot :- 2 { altfill(I,J,D); num(I) } ; num(D); num(J). bot :- 2 { altfill(I,J,D); num(J) } ; num(I); num(D). bot :- 2 { altfill(I,J,D); cage(I,J,C) } ; num(C); num(D). altfill(I,J,D) :- bot; num(I); num(J); num(D). #minimize { 1,I,J: premise(I,J) }. #show conclusion/2. Figure 4: argument.lp defines valid arguments subject to minimizing the size of the evidence set. with a similar setup (including the known conclusion as a fact) to find the size of an optimal argument for that specific conclusion. Hints in the Tactics phase are computed as the intersection of all optimal evidence sets. With known cells and conclusion wrangled into facts as before, we execute Clingo with flags instructing it to perform cautious reasoning over optimal solutions. Deployment Options Even with the rest of the game deployed as a static webpage, there are several options for how to deploy our AI system. In this section, we explain our reasoning towards our chosen model: a centralized ASP web service. Our game is intended to be played inside of a modern web browser with no additional downloads. We want gameplay to feel responsive on desktop machines as well as low-end smartphones. Although we expect our players to have network access, we appreciate that mobile players may not have reliable connectivity throughout the play session. In-process Clingo can be utilized as a software library via either its Python or C/C++ APIs. Used as a library, the solver would tightly bind with the rest of our game code running within the same (operating system) process. In the context of JavaScript code running in a web browser, we work with Clingo.js, a cross-compilation from the Clingo’s original C++ code into pure JavaScript using Emscripten. Until very recently, Clingo was distributed under the GNU Public License, a copyleft license that made it impractical to C++ code into pure JavaScript using Emscripten. Clingo.js, JavaScript code running in a web browser, we work with tightly bind with the rest of our game code running within Python or C/C++ APIs. Used as a library, the solver would Clingo can be utilized as a software library via either its In-process. As of May 3, 2017, Clingo is now distributed under the much more permissive MIT License. Executing the solver locally in the player’s browser has the strong benefit of not requiring any centralized infrastructure for solving combinatorial search and optimization problems. As the game scales in popularity, individual players pay the cost (mostly obviously in increased battery usage on mobile devices). The pure-JS solver does not execute as efficiently as a native compiled solver. However, for the modest scale of inference tasks about Sudoku puzzles, we found response times in desktop web browsers to be reasonable. Although an in-process deployment strategy is conceptually the simplest approach, it implies some responsiveness and stability hazards. While the solver is executing, no other scripts on the page can run to continue animations or respond to additional player inputs. JavaScript provides no thread-like abstraction to avoid this blocking while still executing within a single process. Additionally, if the browser decides to halt the seemingly unresponsive script, it is difficult for the rest of the game code to recover. Out-of-process In a desktop application (outside of the browser), it would be natural to address the limitations of the in-process approach by simply executing Clingo as a child process (by means of a spawn syscall). Again, no such abstraction is provided inside of the browser (the local filesystem and native executables cannot be touched). The WebWorker API provides the abstraction of an invisible background page that can execute JavaScript code asynchronously from the player-visible page. Workers communicate with the main page by passing messages. Clingo.js can be used from inside a web worker. Indeed, this was the approached used in the original Proofdoku prototype. In either the in-process or out-of-process mode of using Clingo.js, the player must wait for the full 5.22 MB of Clingo.js to be downloaded before any AI-supported interactions with a puzzle can occur. Over a slow or unreliable mobile network, even this download time could be detrimental to the critical first moments of player experience. On these same mobile devices, the responsiveness of the pure-JS solver is also significantly reduced. Even if we could hide the longer solving times with distracting animations, we wanted to avoid unnecessary consumption of battery resources. Our players should not have to decide between playing Proofdoku for a few more minutes or saving their battery for important communication later in the day. Remote service If we give up the scalability benefits associated with running the solver locally, we can regain control over responsiveness even for our players on mobile devices. Instead of running --- 7https://potassco.org/clingo/run/ 8http://emscripten.org/ 9https://github.com/potassco/clingo/releases/tag/v5.2.0 10https://html.spec.whatwg.org/multipage/workers.html the solver on the player’s device, we considered running it on (virtual) machines in the cloud. In Proofdoku, we specifically examined using Google Cloud Functions\(^{11}\) to implement a Clingo web service. In this design, a native compiled solver runs in response to web requests made by remote clients. This approach avoids up-front downloads and allows much closer to native solving speeds (modulo virtualization and other overheads of the shared infrastructure). As a commercial service, this design implies per-CPU-second costs that threaten our intent to leave the game running for several years. To stay within the service’s free tier as our player population scales up and down, we introduced layers of caches so that the solver is only run when necessary instead of in response to every single player action in a puzzle (details below). In exchange for requiring the player’s device to be able to make small, periodic requests to a central service, we are able offer both desktop and mobile players the same responsiveness from our AI system. **Inference Caching** As our game is oriented around a small set of fresh daily puzzles, most players will be asking our centralized service to solve the same inference tasks. Even at the scale of an individual player there is duplication as they explore different evidence sets. By caching the results of inference tasks, we can improve responsiveness over a design that needs to execute Clingo after every interaction. Our caching strategy operates at the level of Clingo calls. In this setup, the caches store key–value mappings where the key is a combination of the AnsProlog text and command line flags, and the value is the text output of Clingo. This makes the system independent of Proofdoku and suitable even for non-game interactive ASP deployments. **Local caching** The first layer of caching works locally in the web browser. This cache provides an instant response when removing evidence returns the player to a previously-seen state in the Tactics phase or when abandoning an argument returns the player to a previously-seen state in the Strategy phase. By nature, the local cache cannot help when the player encounters a state that has never been seen on their device before. Filling the local cache requires a network transaction. Although this local cache could be primed with the popular inference results of the day, we did not consider the complexity of this design to be warranted. We used a Least-Recently-Used cache with 100 slots implemented using a plain JavaScript object as the key–value store. Most states are either seen again after just a few clicks or never again, so we selected the cache capacity primarily as a way to avoid unbounded memory usage. Although we could use the Web Storage API\(^{12}\) to persist the cache across page loads or play sessions, our evergreen design intent leads us to not expect players revisiting old puzzles. **Global caching** As different players independently pass through similar states while they work through the puzzles of the day, we expect our solving service to answer many duplicate requests. Although Google Cloud Functions (GCF) will readily spawn several copies of Clingo to match the request load, this translates into costs for us to keep the game deployed. Our intent is to stay within the free tier of this service even as popularity of the game rises and falls. We created a thin wrapper around the GCF Clingo service using Python running on GAE. This wrapper tries to answer requests out of a global memcache\(^{13}\) service before handing the requests to the GCF Clingo service. The focus on daily puzzles ensures that relatively few keys are active each day (compared to the number seen during the whole deployment). Although we do not have sufficient data to report informative cache hit rate statistics, we can report one interesting qualitative phenomenon resulting from the use of the global cache. Certain inference tasks (particularly computing the Strategy hints for a hard puzzle) can take even the native solver a few seconds to compute rather than a few tens of milliseconds to serve from memcache. Even if the global cache only manages to serve responses for queries about the initial state of a puzzle, the use of a centralized service with a global cache contributes significantly to game’s feeling of responsiveness in the very first moments of interaction with a puzzle compared to uncached or decentralized inference. **Conclusion** Proofdoku is an AI-based game which draws out the otherwise unseen implications of building and deploying interactive systems based on ASP. Although many of the design decisions we made in the deployment of our game are specific to project and the intended player experience, the questions we faced in making those decisions are very general. With the software license associated with a state-of-the-art answer set solver having recently changed to MIT (from GPL), a number of different modes of integrating ASP into commercial applications has just opened up in 2017. We hope the exploration of Proofdoku’s design choices sparks informed conversations about how ASP can be deployed in games and other interactive media applications in the future. **Acknowledgements** The author would like to thank Nicholas Warren and Mason Reed for their game design and software engineering contributions to Proofdoku, the Potassco team at the University of Potsdam for providing Clingo liberally licensed and free of charge, and Google, Inc. for providing a generous free tier for the Google Compute Platform products. \(^{11}\)https://cloud.google.com/functions/ \(^{12}\)https://developer.mozilla.org/en-US/docs/Web/API/Web_Storage_API \(^{13}\)https://cloud.google.com/appengine/docs/standard/python/memcache/ References Černý, M. 2015. Sarah and sally: Creating a likeable and competent ai sidekick for a videogame. In Experimental AI in Games: Papers from the AIIDE 2015 Workshop, EXAG 2. AAAI.
{"Source-Url": "https://adamsmith.as/papers/answer-set-programming-in-proofdoku.pdf", "len_cl100k_base": 6822, "olmocr-version": "0.1.53", "pdf-total-pages": 7, "total-fallback-pages": 0, "total-input-tokens": 22416, "total-output-tokens": 8169, "length": "2e12", "weborganizer": {"__label__adult": 0.001312255859375, "__label__art_design": 0.00089263916015625, "__label__crime_law": 0.0013017654418945312, "__label__education_jobs": 0.00156402587890625, "__label__entertainment": 0.0003767013549804687, "__label__fashion_beauty": 0.0006117820739746094, "__label__finance_business": 0.00045990943908691406, "__label__food_dining": 0.0013399124145507812, "__label__games": 0.04815673828125, "__label__hardware": 0.0016613006591796875, "__label__health": 0.0011577606201171875, "__label__history": 0.0007295608520507812, "__label__home_hobbies": 0.00016736984252929688, "__label__industrial": 0.0009450912475585938, "__label__literature": 0.0010023117065429688, "__label__politics": 0.0007104873657226562, "__label__religion": 0.0013475418090820312, "__label__science_tech": 0.031219482421875, "__label__social_life": 0.0001780986785888672, "__label__software": 0.00753021240234375, "__label__software_dev": 0.89453125, "__label__sports_fitness": 0.001377105712890625, "__label__transportation": 0.0009474754333496094, "__label__travel": 0.0004553794860839844}, "weborganizer_max": "__label__software_dev", "avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_ratio": [[0, 35316, 0.01553]], "fineweb_edu_fasttext_gt2__fineweb_edu_fasttext_gt2__score": [[0, 35316, 0.29006]], "ft_lang_id_en_doc_v2__ft_lang_id_en_doc_v2__en": [[0, 35316, 0.90846]], "google_gemma-3-12b-it_contains_pii": [[0, 4378, false], [4378, 9320, null], [9320, 15061, null], [15061, 20996, null], [20996, 26493, null], [26493, 32306, null], [32306, 35316, null]], "google_gemma-3-12b-it_is_public_document": [[0, 4378, true], [4378, 9320, null], [9320, 15061, null], [15061, 20996, null], [20996, 26493, null], [26493, 32306, null], [32306, 35316, null]], "google_gemma-3-4b-it_v2tag__is_academic_paper": [[0, 5000, true], [5000, 35316, null]], "google_gemma-3-4b-it_v2tag__is_class_syllabus": [[0, 5000, false], [5000, 35316, null]], "google_gemma-3-4b-it_v2tag__is_completion_certificate": [[0, 5000, false], [5000, 35316, null]], "google_gemma-3-4b-it_v2tag__is_court_notice": [[0, 5000, false], [5000, 35316, null]], "google_gemma-3-4b-it_v2tag__is_homework_assignment": [[0, 5000, false], [5000, 35316, null]], "google_gemma-3-4b-it_v2tag__is_news_article": [[0, 5000, false], [5000, 35316, null]], "google_gemma-3-4b-it_v2tag__is_public_order": [[0, 5000, false], [5000, 35316, null]], "google_gemma-3-4b-it_v2tag__is_resume_cv": [[0, 5000, false], [5000, 35316, null]], "google_gemma-3-4b-it_v2tag__is_test_or_quiz": [[0, 5000, false], [5000, 35316, null]], "google_gemma-3-4b-it_v2tag__is_textbook": [[0, 5000, false], [5000, 35316, null]], "pdf_page_numbers": [[0, 4378, 1], [4378, 9320, 2], [9320, 15061, 3], [15061, 20996, 4], [20996, 26493, 5], [26493, 32306, 6], [32306, 35316, 7]], "pipe_delimited_lines_v1__pipe_delimited_lines_v1__pipe_delimited_lines_ratio": [[0, 35316, 0.0]]}
olmocr_science_pdfs
2024-12-06
2024-12-06
ae167f1e7f9db94e6ab61b2de7f69feaaa8207d4
In this lecture we describe the union-find problem. This is a problem that captures a key task one needs to solve in order to efficiently implement Kruskal’s minimum-spanning-tree algorithm. We then give two data structures for union-find with good amortized running time. 1 Motivation To motivate the union-find problem, let’s recall Kruskal’s Algorithm for finding a minimum spanning tree (MST) in an undirected graph (see also Section 5). Remember that an MST is a tree that includes (i.e., spans) all the vertices and out of all such trees has the least total cost. Kruskal’s Algorithm (recap): Sort the edges in the given graph $G$ by length and examine them from shortest to longest. Put each edge into the current forest if it doesn’t form a cycle with the edges chosen so far. We argue correctness in Section 5.2. Today, our concern is running time. The initial step takes time $O(|E| \log |E|)$ to sort. Then, for each edge, we need to test if it connects two different components. If it does, we will insert the edge, merging the two components into one; if it doesn’t (the two endpoints are in the same component), then we will skip this edge and go on to the next edge. So, to do this efficiently we need a data structure that can support the basic operations of (a) determining if two nodes are in the same component, and (b) merging two components together. This is the union-find problem. 2 The Union-Find Problem The general setting for the union-find problem is that we are maintaining a collection of disjoint sets $\{S_1, S_2, \ldots, S_k\}$ over some universe, with the following operations: **MakeSet**$(x)$: create the set $\{x\}$. **Union**$(x, y)$: replace the set $x$ is in (let’s call it $S$) and the set $y$ is in (let’s call it $S'$) with the single set $S \cup S'$. **Find**$(x)$: return the unique ID for the set containing $x$ (this is just some representative element of this set). Given these operations, we can implement Kruskal’s algorithm as follows. The sets $S_i$ will be the sets of vertices in the different trees in our forest. We begin with MakeSet($v$) for all vertices $v$ (every vertex is in its own tree). When we consider some edge $(v, w)$ in the algorithm, we just test whether Find($v$) equals Find($w$). If they are equal, it means that $v$ and $w$ are already in the same tree so we skip over the edge. If they are not equal, we insert the edge into our forest and perform a Union($v, w$) operation. All together we will do $|V|$ MakeSet operations, $|V| - 1$ Unions, and $2|E|$ Find operations. **Notation and Preliminaries:** in the discussion below, it will be convenient to define - $n$ as the number of MakeSet operations and - $m$ as the total number of operations (this matches the number of vertices and edges in the graph up to constant factors, and so is a reasonable use of $n$ and $m$). Also, it is easiest to think conceptually of these data structures as adding fields to the items themselves, so there is never an issue of “how do I locate a given element $v$ in the structure?”. 3 Data Structure 1 (list-based) Our first data structure is a simple one with a very cute analysis. The total cost for the operations will be $O(m + n \log n)$. In this data structure, the sets will be just represented as linked lists: each element has a pointer to the next element in its list. However, we will augment the list so that each element also has a pointer directly to head of its list (denoted by $x->head$). The head of the list is the representative element. We can now implement the operations as follows: **MakeSet**($x$): just set $x->head=x$. This takes constant time. **Find**($x$): just return $x->head$. Also takes constant time. **Union**($x, y$): To perform a union operation we merge the two lists together, and reset the head pointers on one of the lists to point to the head of the other. Let $A$ be the list containing $x$ and $B$ be the list containing $y$, with lengths $L_A$ and $L_B$ respectively. Then we can do this in time $O(L_A + L_B)$ by appending $B$ onto the end of $A$ as follows. We first walk down $A$ to the end, and set the final **next** pointer to point to $y->head$. This takes time $O(L_A)$. Next we go to $y->head$ and walk down $B$, resetting head pointers of elements in $B$ to point to $x->head$. This takes time $O(L_B)$. Can we reduce this to just $O(L_B)$? Yes. Instead of appending $B$ onto the end of $A$, we can just splice $B$ into the middle of $A$, at $x$. I.e., let $z=x->next$, set $x->next=y->head$, then walk down $B$ as above, and finally set the final **next** pointer of $B$ to $z$. Can we reduce this to $O(\min(L_A, L_B))$? Yes. Just store the length of each list in the head. Then compare and insert the shorter list into the middle of the longer one. Then update the length count to $L_A + L_B$. We now prove this simple data structure has the running time we wanted. **Theorem 1** The above algorithm has total running time $O(m + n \log n)$. **Proof:** The Find and MakeSet operations are constant time so they are covered by the $O(m)$ term. Each Union operation has cost proportional to the length of the list whose head pointers get updated. So, we need to find some way of analyzing the total cost of the Union operations. Here is the key idea: we can pay for the union operation by charging $O(1)$ to each element whose head pointer is updated. So, all we need to do is sum up the costs charged to all the elements over the entire course of the algorithm. Let’s do this by looking from the point of view of some lowly element $x$. Over time, how many times does $x$ get walked on and have its head pointer updated? The answer is that its head pointer is updated at most $\log n$ times. The reason is that we only update head pointers on the smaller of the two lists being joined, so every time $x$ gets updated, the size of the list it is in at least doubles, and this can happen at most $\log n$ times. So, we were able to pay for unions by charging the elements whose head pointers are updated, and no element gets charged more than $O(\log n)$ total, so the total cost for unions is $O(n \log n)$, or $O(m + n \log n)$ for all the operations together. \[\square\] Recall that this is already low-order compared to the $O(m \log m)$ sorting time for Kruskal’s algorithm. So we could use this to get $O(m \log m)$ overall runtime for Kruskal. Exercise 1: After doing $n$ makeset operations, give an sequence of $n - 1$ union operations that causes the above data structure to take $\Omega(n \log n)$ time. 4 Data Structure 2 (tree-based) But even though the running time of the list-based data structure is pretty fast, let’s think of ways we could make it even faster. How fast can we make a union-find data structure? One idea is that instead of updating all the head pointers in list $B$ (or whichever was shorter) when we perform a Union, we could do this in a lazy way, just pointing the head of $B$ to the head of $A$ and then waiting until we actually perform a find operation on some item $x$ before updating its pointer. This will decrease the cost of the Union operations but will increase the cost of Find operations because we may have to take multiple hops. Notice that by doing this we no longer need the downward pointers: what we have in general is a collection of trees, with all links pointing up. Another idea is that rather than deciding which of the two heads (or roots) should be the new one based on the size of their sets, perhaps there is some other quantity that would give us better performance. In particular, it turns out we can do better by setting the new root based on which tree has larger rank, which we will define in a minute. We will prove that by implementing the two optimizations described above (lazy updates and union-by-rank), the total cost is bounded above by $O(m \lg\ast n)$, where recall that $\lg\ast n$ is the number of times you need to take $\log_2$ until you get down to 1. For instance, $$\lg\ast(2^{65536}) = 1 + \lg\ast(65536) = 2 + \lg\ast(16) = 3 + \lg\ast(4) = 4 + \lg\ast(2) = 5.$$ So, in practical settings, $\lg\ast n$ is never bigger than 5. However, it still is not a constant, since $\lg\ast n \to \infty$ as $n \to \infty$. We now describe the procedure more specifically. Each element (node) will have two fields: a parent pointer that points to its parent in its tree (or itself if it is the root) and a rank, which is an integer used to determine which node becomes the new root in a Union operation. The operations are: MakeSet($x$): set $x$’s rank to 0 and its parent pointer to itself. This takes constant time. Find($x$): starting from $x$, follow the parent pointers until you reach the root, updating $x$ and all the nodes we pass over to point to the root. This is called path compression. The running time for Find($x$) is proportional to (original) distance of $x$ to its root. Union($x, y$): Let Union($x, y$) = Link(Find($x$), Find($y$)), where Link is an internal operation that is not part of the public interface, and is defined as follows. Link($r_1, r_2$): The invariant is that the two arguments to Link are always roots. If the one of the roots (say $r_2$) has strictly larger rank than the other, then $r_2$ becomes the new root, and $r_1$’s parent pointer is changed to point to $r_2$. If the two roots have equal rank, then one of them (arbitrarily, say $r_1$) is picked to be the new root, $r_2$’s parent pointer points to $r_1$, and $r_1$’s rank is increased by 1. This procedure is called union by rank. 1As an aside, the running time of the union-find data structure is even better: $O(m \alpha(m, n))$ where $\alpha$ is the inverse-Ackermann function which grows even more slowly than $\lg\ast$. But the $\lg\ast n$ bound is subtle enough to prove — let’s not go completely overboard! Properties of ranks: To help us understand this procedure, let's first develop some properties of ranks. (A) The rank of a node is the same as what the height of its subtree would be if we didn't do path compression. This is easy to see: if you take two trees of different heights and join them by making the root of the shorter tree into a child of the root of the taller tree, the heights do not change, but if the trees were the same height, then the final tree will have its height increase by 1. (B) If \( x \) is not a root, then \( \text{rank}(x) \) is strictly less than the rank of \( x \)'s parent. We can see this by induction: the Union operation maintains this property, and the Find operation only increases the difference between the ranks of nodes and their parents. (C) This means that when we do path compression, if \( x \)'s parent changes, then the rank of \( x \)'s new parent is strictly more than the rank of \( x \)'s old parent. (D) The rank of a node \( x \) can only change if \( x \) is a root. Furthermore, once a node becomes a non-root, it is never a root again. These are immediate from the algorithm. (E) There are at most \( n/2^r \) nodes of rank \( \geq r \). Indeed, when a node \( x \) first reaches rank \( r \) (due to a link), it must be a root (ppty D), its tree must have at least \( 2^r \) nodes (this is easy to see by induction), all these nodes (except for itself) have rank \( < r \) (ppty B), and their ranks are never going to change (ppty D). Define \( S_x \) to be these nodes in its subtree at this moment. Note that these nodes did not have an ancestor node with rank \( r \) before the link, but now they do. Moreover, path compression will maintain the property that they have an ancestor of rank \( \geq r \) (ppty C). Now consider some \( y \) that reaches rank \( r \) later, and let \( S_y \) be the (at least \( 2^r \)) nodes in its tree at this moment. Since these nodes did not have an ancestor with rank \( \geq r \) before this link (for the same reason), and those in \( S_x \) already did, \( S_y \) cannot have any intersection with \( S_x \). So for any two nodes \( x \) and \( y \) of rank \( \geq r \), the sets \( S_x \) and \( S_y \) are disjoint, and each has size \( \geq 2^r \). Since there are \( n \) nodes total, this implies there can be at most \( n/2^r \) nodes of rank \( \geq r \). **Exercise 2:** If there are \( n \) elements, what is the largest rank any element can have? We're now ready to prove the following theorem. **Theorem 2** The above tree-based algorithm has total running time \( O(m \lg^* n) \). **Proof:** Let's begin with the easy parts. First of all, the Union does two Find operations plus a constant amount of extra work. So, we only need to worry about the time for the (at most \( 2m \)) Find operations. Second, we can count the cost of a Find operation by charging \$1 for each parent pointer examined. So, when we do a \( \text{Find}(x) \), if \( x \) was a root then pay \$1 (just a constant, so that’s ok). If \( x \) was a child of a root we pay \$2 (also just a constant, so that’s ok also). If \( x \) was lower, then the very rough idea is that (except for the last \$2) every dollar we spend is shrinking the tree because of our path compression, so we’ll be able to amortize this cost somehow. For the remaining part of the proof, we will use the properties we figured out above. **Step 1:** first let’s imagine putting non-root nodes into buckets according to their rank. - Bucket 0 contains all non-root nodes of rank 0, • bucket 1 has all of rank 1, • bucket 2 has ranks 2 through $2^2 - 1$, • bucket 3 has ranks $2^2$ through $2^{2^2} - 1$, • bucket 4 has ranks $2^{2^2}$ through $2^{2^{2^2}} - 1$, etc. • In general, a bucket has ranks $r$ through $2^r - 1$. We’ll denote the bucket as $[r, 2^r - 1]$. In total, we have $O(\lg^* n)$ buckets, and each node belongs to one bucket. How many nodes have ranks in bucket $[r, 2^r - 1]$? All these nodes have ranks at least $r$, so by property (E) of ranks above, this is at most $\frac{n}{2^r} = \frac{n}{\text{upper bound of bucket} + 1}$. **Step 2:** When we walk up the tree in the Find($x$) operation, some one must pay for it. We use the banker’s method to account for it. When we do Find($x$), we give the queried element $x$ $2 + \lg^* n$ tokens (call these red tokens). But this may not be enough, if the path is longer than $2 + \lg^* n$. So we give some more money to each non-root element: each element that is not a root, and lies in bucket $[r, 2^r - 1]$, gets $2^r$ green tokens to help others. There are at most $n/2^r$ elements in this bucket (ppty E), and each gets $2^r$ green tokens, so that’s $n$ green tokens per bucket, or $O(n \lg^* n)$ green tokens in all. Now consider the path from $x$ to its root, and some step $u \to v$ along this path. If the step is such that $v$ is in the same bucket as $u$, then node $u$ (the helper) uses its green tokens to pay for this step. But if $v$ is in a higher bucket, then $x$ (the walker) pays for it out of its red tokens. The last two steps, when we touch the root, or a child of the root, we’ll charge to the walker again, but this is only $\$2$. The easy part of this is the amount $x$ pays. We can move up in buckets at most $\lg^* n$ times, since there are only $\lg^* n$ different buckets. So, the total amount the “walker” $x$ pays is $2 + \lg^* n$, at most the amount of red tokens we gave it. The slightly harder part is: how much does a helper $u$ pay? The argument is careful but simple. 1. When node $u$ pays using its green tokens, it is not a root, so its rank is never going to change, by Property (D). 2. Every time $u$ pays, the rank of its new parent (after path compression) is at least 1 larger than the rank of its previous parent, by property (C). 3. One worry: the rank of $u$’s parent could conceivably increase $\log n$ times, which to us is a “big” number. Hmm. *But — and this is the crucial idea — once its parent’s rank becomes large enough that it is in the next bucket, we never charge node $u$ again as helper.* So, the maximum amount any helper node $u$ pays is at most the range of its bucket $[r, 2^r - 1]$, i.e., at most $2^r$. Which is the amount of green tokens we gave it. (Remember that the only elements being charged are non-roots, so once they start getting charged, their rank is fixed so they can’t jump to some other bucket and start getting charged there too.) 4. So every operation can be paid for by either a red or green token. The total number of tokens is at most $m(\lg^* n + 2)$ red tokens, plus $n \lg^* n$ green tokens. Since $m \geq n$, this proves the theorem. Simple, and beautiful. Just as advertised. Exercise 3: Show that the charge to the walkers, and hence the total cost of \( n \) makesets and \( m \) unions and finds, is only \( O(m + n \lg^* n) \). This is often better than \( O(m \lg^* n) \) when \( m \geq n \). 5 Appendix: MST Algorithms Many of you have seen minimum spanning tree algorithms in previous courses, e.g., in 15-210 you saw Boruvka’s algorithm, which is naturally parallel and runs in time \( O(m \log n) \). But let us recap the basic definitions, and talk about two other algorithms: Prim’s and Kruskal’s. A spanning tree of a graph is a tree that touches all the vertices (so, it only makes sense in a connected graph). A minimum spanning tree (MST) is a spanning tree whose sum of edge lengths is as short as possible (there may be more than one). We will sometimes call the sum of edge lengths in a tree the size of the tree. For instance, imagine you are setting up a communication network among a set of sites and you want to use the least amount of wire possible. Note: our definition is only for undirected graphs. What is the MST in the graph below? ``` 5 8 A-----B-----C | | | 1| 1| |6 | 2 | 4 | D-----E-----F ``` 5.1 Prim’s algorithm Prim’s algorithm is an MST algorithm that works much like Dijkstra’s algorithm does for shortest path trees, if you are familiar with that. In fact, it’s even simpler (though the correctness proof is a bit trickier). Prim’s Algorithm: 1. Pick some arbitrary start node \( s \). Initialize tree \( T = \{s\} \). 2. Repeatedly add the shortest edge incident to \( T \) (the shortest edge having one vertex in \( T \) and one vertex not in \( T \)) until the tree spans all the nodes. For instance, what does Prim’s algorithm do on the above graph? Before proving correctness for the algorithm, we first need a useful fact about spanning trees: if you take any spanning tree and add a new edge to it, this creates a cycle. The reason is that there already was one path between the endpoints (since it’s a spanning tree), and now there are two. If you then remove any edge in the cycle, you get back a spanning tree (removing one edge from a cycle cannot disconnect a graph). **Theorem 3** Prim’s algorithm correctly finds a minimum spanning tree of the given graph. **Proof:** We will prove correctness by induction. Let \( G \) be the given graph. Our inductive hypothesis will be that the tree \( T \) constructed so far is consistent with (is a subtree of) some minimum spanning tree \( M \) of \( G \). This is certainly true at the start. Now, let \( e \) be the edge chosen by the algorithm. We need to argue that the new tree, \( T \cup \{e\} \) is also consistent with some minimum spanning tree \( M' \) of \( G \). If \( e \in M \) then we are done (\( M' = M \)). Else, we argue as follows. Consider adding $e$ to $M$. As noted above, this creates a cycle. Since $e$ has one endpoint in $T$ and one outside $T$, if we trace around this cycle we must eventually get to an edge $e'$ that goes back in to $T$. We know $\text{len}(e') \geq \text{len}(e)$ by definition of the algorithm. So, if we add $e$ to $M$ and remove $e'$, we get a new tree $M'$ that is no larger than $M$ was and contains $T \cup \{e\}$, maintaining our induction and proving the theorem. **Running time:** To implement this efficiently, we can store the neighbors of the current tree in a priority-queue (pqueue), with priority-value equal to the length of the shortest edge between that node and the current tree. We add a new node into the tree using a remove-min operation (taking the node of smallest priority-value out of the pqueue); then, after adding this node, we examine all outgoing edges and for each one that points to a node not in the tree we either (a) add it into the pqueue if it is not there already, or (b) perform a “decrease-key” operation if it was in there already but the new edge is shorter. This will give us $O(m \log n)$ running time if we implement the pqueue using a standard heap, or $O(m + n \log n)$ running time if we use something called a Fibonacci heap. ### 5.2 Kruskal’s algorithm Here is another algorithm for finding minimum spanning trees called Kruskal’s algorithm. It is also greedy but works in a different way. **Kruskal’s Algorithm:** Sort edges by length and examine them from shortest to longest. Put each edge into the current forest (a forest is just a set of trees) if it doesn’t form a cycle with the edges chosen so far. E.g., let’s look at how it behaves in the graph below: ``` 5 8 A-----B-----C | | | 1| | 1| 6 | 2 | 4 | D-----E-----F ``` Kruskal’s algorithm sorts the edges and then puts them in one at a time so long as they don’t form a cycle. So, first the AD and BE edges will be added, then the DE edge, and then the EF edge. The AB edge will be skipped over because it forms a cycle, and finally the CF edge will be added (at that point you can either notice that you have included $n - 1$ edges and therefore are done, or else keep going, skipping over all the remaining edges one at a time). **Theorem 4** Kruskal’s algorithm correctly finds a minimum spanning tree of the given graph. **Proof:** We can use a similar argument to the one we used for Prim’s algorithm. Let $G$ be the given graph, and let $F$ be the forest we have constructed so far (initially, $F$ consists of $n$ trees of 1 node each, and at each step two trees get merged until finally $F$ is just a single tree at the end). Assume by induction that there exists an MST $M$ of $G$ that is consistent with $F$; i.e., all edges in $F$ are also in $M$; this is clearly true at the start when $F$ has no edges. Let $e$ be the next edge added by the algorithm. Our goal is to show that there exists an MST $M'$ of $G$ consistent with $F \cup \{e\}$. If $e \in M$ then we are done ($M' = M$). Else add $e$ into $M$, creating a cycle. Since the two endpoints of $e$ were in different trees of $F$, if you follow around the cycle you must eventually traverse some edge $e' \neq e$ whose endpoints are also in two different trees of $F$ (because you eventually have to get back to the node you started from). Now, both $e$ and $e'$ were eligible to be added into $F$, which by definition of our algorithm means that $\text{len}(e) \leq \text{len}(e')$. So, adding $e$ and removing $e'$ from $M$ creates a tree $M'$ that is also a MST and contains $F \cup \{e\}$, as desired. **Running time:** The first step is sorting the edges by length which takes time $O(m \log m)$. Then, for each edge we need to test if it connects two different components. This seems like it should be a real pain: how can we tell if an edge has both endpoints in the same component? This is just the union-find data structure you saw in this lecture! It is so efficient that union/finds will actually will be a low-order cost compared to the sorting step.
{"Source-Url": "http://www.cs.cmu.edu/~15451/lectures/lec04-unionfind-new.pdf", "len_cl100k_base": 6283, "olmocr-version": "0.1.53", "pdf-total-pages": 8, "total-fallback-pages": 0, "total-input-tokens": 26109, "total-output-tokens": 6762, "length": "2e12", "weborganizer": {"__label__adult": 0.0004696846008300781, "__label__art_design": 0.000354766845703125, "__label__crime_law": 0.0005993843078613281, "__label__education_jobs": 0.0014858245849609375, "__label__entertainment": 0.00012969970703125, "__label__fashion_beauty": 0.00020933151245117188, "__label__finance_business": 0.00028395652770996094, "__label__food_dining": 0.0007109642028808594, "__label__games": 0.00139617919921875, "__label__hardware": 0.0019397735595703125, "__label__health": 0.001239776611328125, "__label__history": 0.000514984130859375, "__label__home_hobbies": 0.00020694732666015625, "__label__industrial": 0.0008358955383300781, "__label__literature": 0.0003173351287841797, "__label__politics": 0.0003612041473388672, "__label__religion": 0.0007305145263671875, "__label__science_tech": 0.09881591796875, "__label__social_life": 0.00012421607971191406, "__label__software": 0.005908966064453125, "__label__software_dev": 0.880859375, "__label__sports_fitness": 0.0007205009460449219, "__label__transportation": 0.0012121200561523438, "__label__travel": 0.0004148483276367187}, "weborganizer_max": "__label__software_dev", "avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_ratio": [[0, 23443, 0.02751]], "fineweb_edu_fasttext_gt2__fineweb_edu_fasttext_gt2__score": [[0, 23443, 0.53735]], "ft_lang_id_en_doc_v2__ft_lang_id_en_doc_v2__en": [[0, 23443, 0.92445]], "google_gemma-3-12b-it_contains_pii": [[0, 2736, false], [2736, 6222, null], [6222, 9852, null], [9852, 13410, null], [13410, 16582, null], [16582, 19388, null], [19388, 22576, null], [22576, 23443, null]], "google_gemma-3-12b-it_is_public_document": [[0, 2736, true], [2736, 6222, null], [6222, 9852, null], [9852, 13410, null], [13410, 16582, null], [16582, 19388, null], [19388, 22576, null], [22576, 23443, null]], "google_gemma-3-4b-it_v2tag__is_academic_paper": [[0, 5000, true], [5000, 23443, null]], "google_gemma-3-4b-it_v2tag__is_class_syllabus": [[0, 5000, false], [5000, 23443, null]], "google_gemma-3-4b-it_v2tag__is_completion_certificate": [[0, 5000, false], [5000, 23443, null]], "google_gemma-3-4b-it_v2tag__is_court_notice": [[0, 5000, false], [5000, 23443, null]], "google_gemma-3-4b-it_v2tag__is_homework_assignment": [[0, 5000, false], [5000, 23443, null]], "google_gemma-3-4b-it_v2tag__is_news_article": [[0, 5000, false], [5000, 23443, null]], "google_gemma-3-4b-it_v2tag__is_public_order": [[0, 5000, false], [5000, 23443, null]], "google_gemma-3-4b-it_v2tag__is_resume_cv": [[0, 5000, false], [5000, 23443, null]], "google_gemma-3-4b-it_v2tag__is_test_or_quiz": [[0, 5000, false], [5000, 23443, null]], "google_gemma-3-4b-it_v2tag__is_textbook": [[0, 5000, false], [5000, 23443, null]], "pdf_page_numbers": [[0, 2736, 1], [2736, 6222, 2], [6222, 9852, 3], [9852, 13410, 4], [13410, 16582, 5], [16582, 19388, 6], [19388, 22576, 7], [22576, 23443, 8]], "pipe_delimited_lines_v1__pipe_delimited_lines_v1__pipe_delimited_lines_ratio": [[0, 23443, 0.03226]]}
olmocr_science_pdfs
2024-12-07
2024-12-07
97335b28de00f4cb54e094f0a30d1c202afd3eca
Property-part diagrams: A dependence notation for software systems The MIT Faculty has made this article openly available. Please share how this access benefits you. Your story matters. <table> <thead> <tr> <th></th> <th></th> </tr> </thead> <tbody> <tr> <td>As Published</td> <td><a href="http://www.cs.uoregon.edu/events/icse2009/CoLocatedEvents/">http://www.cs.uoregon.edu/events/icse2009/CoLocatedEvents/</a></td> </tr> <tr> <td>Publisher</td> <td>Institute of Electrical and Electronics Engineers</td> </tr> <tr> <td>Version</td> <td>Author's final manuscript</td> </tr> <tr> <td>Accessed</td> <td>Fri Dec 28 08:43:25 EST 2018</td> </tr> <tr> <td>Citable Link</td> <td><a href="http://hdl.handle.net/1721.1/61343">http://hdl.handle.net/1721.1/61343</a></td> </tr> <tr> <td>Terms of Use</td> <td>Attribution-Noncommercial-Share Alike 3.0 Unported</td> </tr> <tr> <td>Detailed Terms</td> <td><a href="http://creativecommons.org/licenses/by-nc-sa/3.0/">http://creativecommons.org/licenses/by-nc-sa/3.0/</a></td> </tr> </tbody> </table> Property-Part Diagrams: A Dependence Notation for Software Systems Daniel Jackson and Eunsuk Kang Computer Science and Artificial Intelligence Laboratory Massachusetts Institute of Technology Abstract Some limitations of traditional dependence diagrams are explained, and a new notation that overcomes them is proposed. The key idea is to include in the diagram not only the parts of a system but also the properties that are assigned to them; dependences are shown as a relation not from parts to parts, but between properties and the parts (or other properties) that support them. The diagram can be used to evaluate modularization in a design, to assess how successfully critical properties are confined to a limited subset of parts, and to structure a dependability argument. 1 Introduction A traditional dependence diagram consists of a node for each component, and an arc from A to B when component A depends on component B. Such a diagram has many uses – in reasoning, in guiding division of labor, in determining the impact of changes, in identifying reusable subsets, and so on. Every dependence is a potential liability, so reducing or eliminating dependences is a primary design goal, and the presence (or rather, the absence) of dependences is a key indicator of design quality. Our interest in dependence diagrams is primarily in their application to dependable systems, in determining which components are relied upon in the performance of critical functions. In their standard form, however, dependence diagrams have two fundamental limitations that prevent them from being as widely applied as they deserve to be. - Dependence is a boolean notion. A dependence between components is present or absent, and no account is taken of its extent or purpose. Consequently, a design move that replaces one major dependence with several minor ones – a frequent consequence of the use of design patterns – appears to be bad. Also, a component that uses other components only for relatively unimportant functions will appear to depend on them no less than on components used for critical functions. The dependence diagram will not show that the designer has successfully localized critical functions within a small part of the system. - Dependence does not capture the notion of collaborating components. When two components work together to achieve an effect, their coupling cannot be shown except by making one dependent on the other, or making some other component dependent on both. As a result, dependence diagrams do not extend naturally to system-level interactions, involving a combination of software components and human operators or peripheral devices. At the root of this problem is the implicit assumption that any desired property of a system can be assigned to the interface of a single component that is responsible for ensuring it (with the help of the components on which it depends). Many of the puzzles that arise when attempting to use dependence diagrams can be traced back to these limitations. For example, related to the first limitation: - **Cycles in the dependence structure** – which are prevalent in object-oriented code, and the target of elimination in some approaches – are not well explained. If \(A\) depends on \(B\), but \(B\) depends on \(A\), does that mean that \(A\) depends indirectly on itself, and its correct functioning is based on a circular argument? An answer is found by qualifying the dependences. It is possible that \(A\) and \(B\) implement mutually recursive functions, in which case \(B\) will indeed depend on \(A\) for the very functionality that \(A\) offers in depending on \(B\). But, more likely, \(A\) depends on \(B\) for one function, and provides a *different* function for the dependence of \(B\). - **Dynamic linking** is not easily accommodated. A hash table component, for example, will fail if the inserted key objects do not provide appropriate hashing and equality methods. It thus appears that a library component (the hash table) depends on an application-specific component (the one providing the key at runtime) suggesting, incorrectly, that the hash table is not reusable without the key. This conundrum is easily resolved by noting that the hash table depends only on very limited functionality of the key component – namely that it provide equality and hashing methods satisfying a standard contract. And related to the second limitation: - **Who depends on whom?** In a system that relies on a function being scheduled at a certain frequency, does the function depend on the scheduler or vice versa? Neither uses the other in a standard sense; the specification of the scheduler does not mention the effects of the tasks that are scheduled, not does the specification of the function mention who often it should be executed. The solution to this dilemma is simply to regard the function and scheduler as working together. ### 2 A New Notation A *property-part diagram* is a graph of nodes and arcs, much like a traditional dependence diagram. The nodes, however, comprise two separate categories: *parts* and *properties*. A part may be a software component or 'module', a physical component (such as a peripheral device), or a human operator or user. A property is a claim about observable behaviour, for example that some physical phenomenon occurs or does not occur, or that execution of some function has some given effect. We use the term ‘property’ rather than specification because a property may describe behaviour only partially, and may not be associated with one part alone. An arc may point to a part or to another property, but always originates at a property. In Alloy: ```alloy sig Property { support: set (Property + Part) } sig Part { } ``` The properties and parts that a property \(p\) is directly connected to by outgoing arcs (\(p\).support in Alloy) constitute the *support* of \(p\); together, they are sufficient to establish it. This means that if the properties in the support hold, and the parts behave according to their descriptions (in the case of software modules, their code), then \(p\) will hold also. When the support of \(p\) includes a part or property \(q\), \(p\) is said to *depend* on \(q\). The most common patterns are: - **Property decomposition** (Figure 1a). A property \( p \) depends on properties \( q \) and \( r \), making the claim that \( p \) is implied by the conjunction of \( q \) and \( r \). - **Domain assumption** (Figure 1b). A property \( p \) depends on a single part \( e \) representing an aspect of the environment in which the software operates, making the claim that the environment has this property. The property is an assumption that should follow from the description denoted by the domain part. In practice, the description may be omitted, and the properties are then not formally justifiable, but are instead confirmed by experiment or by the judgment of domain experts. - **Satisfaction** (Figure 1c). A property \( p \) depends on a single part \( m \) representing a module, making the claim that the part \( m \) satisfies the property \( p \). One property may be established by more than one module, in which case they are claimed to establish it in combination, and a module may satisfy more than one property. Note that the domain assumption and satisfaction patterns are drawn in the same way, even though their validation is very different, because the analysis required in both cases is logically the same: determining that some property of a part follows from its formal description. - **Contingent use** (Figure 1d). A property \( p \) depends on a part \( m \) and another property \( q \), where \( q \) depends on another part \( m' \) used by \( m \). In this case, \( p \) is claimed to follow from the combination of \( m \) and the property \( q \). Unlike a property decomposition, this claim will not generally be established by showing an implication, but rather by using the property \( q \) about \( m' \) in an argument that \( m \) satisfies \( p \). This pattern may be counterintuitive at first; readers familiar with traditional dependence diagrams might expect the dependence edge to originate in the part \( m \) rather than the property \( p \). Drawn this way, however, the diagram would fail to show that the use of \( m' \) is specific to property \( p \). The property-part diagram shows not only which property of \( m \) calls for a use of \( m' \), but additionally which property of \( m' \) is required in that use. From the basic model, some auxiliary notions can be defined: - The **exposure** of a property \( p \) is the set of parts reachable from \( p \) in one or more steps (in Alloy, \( p.^{\text{support}} \& \text{Part} \)). These are the parts that are responsible for establishing the property, and whose breakage (or failure to satisfy properties) might undermine \( p \). - The **argument** for a property \( p \) is the subgraph rooted at \( p \) (in Alloy, \( p.^{\text{support}} <: \text{support} \)), namely that containing all parts and properties that \( p \) depends on directly or indirectly. - The **impact** of a part \( m \) is the set of properties that a breakage or error in \( m \) might compromise (in Alloy, \( ^{\text{support}}.m \& \text{Property} \)). A primary aim of design is to reduce the exposure of critical properties to a small set of parts that are highly reliable (that is, satisfying their properties with high probability). The argument for a critical property should be small too – not only in the size of the graph, but also in the size of its parts and properties – since the size of the argument is likely to be strongly correlated to the cost of assuring adherence to the critical property. Parts that are unreliable (for example, human operators or complex physical peripherals) should preferably not have critical impacts. ### 3 Example: Tracking Stock Quotes The program of Figure 2 implements a complete stock quote tracker that takes a list of ticker symbols and displays a message when the stock associated with a symbol moves more than some predefined amount. It works as follows: ```java public class QuoteApp { public static void main(String[] args) throws Exception { Timer timer = new Timer(); for (String ticker: args) { timer.schedule (new Tracker (ticker), 0, 10000); } } } public class Tracker extends TimerTask { String ticker; int hi = 0; int lo = Integer.MAX_VALUE; int MOVE = 10; public Tracker (String t) {ticker = t;} public void run () { int q = Quoter.getQuote(ticker); hi = Math.max(hi, q); lo = Math.min(lo, q); if (hi - lo > MOVE) { System.out.println (ticker + " now " + q + " hi: " + hi + ", lo: " + lo); hi = lo = q; } } } public class Quoter { public static int getQuote (String ticker) { URL url = new URL(BASE_URL + ticker + "&f=l1"); String p = new BufferedReader(new InputStreamReader(url.openStream())).readLine(); return (int) (Float.valueOf (p) * 100); } } Figure 2: Stock quote tracker (import statements omitted) ``` - **QuoteApp** class. A Java timer object is created (line 3) for scheduling the downloading of quotes. For each ticker symbol presented as a command line argument (line 4), a tracker object is created and registered as a timer task with the timer for invocation every 10,000 milliseconds (line 5). - **Tracker** class. A tracker object maintains as state high and low watermarks (line 10) on the value of the stock corresponding to the ticker symbol, and declares a constant (line 11) that defines how large a move in the stock spurs an alarm. Every 10,000 milliseconds, the Java timer calls the `run` method of the tracker, which causes the value of the stock to be obtained (line 14) and the watermarks to be updated. If the gap between the high and low watermarks exceeds the preset constant, a message is displayed on the console (line 18) and the watermarks are brought together so that a subsequent message will be generated only if another such move occurs. - **Quoter** class. Stock quotes are obtained using the Yahoo quote server. A URL is constructed that includes the ticker symbol and a formatting string indicating what kind of quote is desired (line 26). Using Java’s networking and I/O libraries, an HTTP get is then performed and --- **Figure 3: Property part diagram for stock tracker example (Figure 2)** - `http-get` for `u:s` returns last price of `s` - `getQuote(s)` returns last price of `s` - `java.net` specs - `java.io` specs - `java.util` specs - `java.util.Timer` - `Tracker` - `Tracker(s)` makes Tracker for ticker `s` - `Tracker` makes Tracker for each ticker and call `t.run` every 10 secs - `schedule(t,p)` results in call to `t.run` every `p` secs - `run()` displays message if big move - `println` writes to console - `console` is open - `Yahoo Server` - `Quoter` - `java.net` - `java.io` - `QuoteApp` - `java.util` (Timer) the returned page, which contains only the quote, is stored as a string (line 27). This string is parsed as a floating-point number, multiplied by 100 (to convert from dollars to cents), and then returned as an integer (line 28). Although small and crude, this program exhibits three key features that are of interest for dependence analysis: use of libraries, a dynamic call-back mechanism; and reliance on an external service. The property-part diagram (Figure 3) has eight parts: one for each of the three user-defined modules (6, 7, 14), three for Java libraries – for networking (15), for I/O (16), and for Timer and the classes it uses (5) – one for the Yahoo server (13), and one for the window manager of the local machine (18), whose role will be explained shortly. The system's requirement (1) is shown as a property at the top of the diagram: that a message will indeed be displayed for any ticker included on the command line if the stock moves by the preset amount in the last 10 seconds. Since our focus is on the structure of the diagram and the relationship between properties and parts, we have not carefully formalized the properties themselves. For a critical system, this would be essential, to make sure the properties are clear and well-defined, and to enable mechanical reasoning. Formalizing the requirement would force us to decide exactly what is meant by a ‘move in the last 10 seconds’; our implementation obtains only the current value from the Yahoo server, and thus would fail to catch large fluctuations occurring between checks. The requirement (1) depends (property decomposition pattern) on two properties: that QuoteApp creates a tracker object for each of the ticker symbols whose run method gets called every 10 seconds (3), and that calling run displays a message if a move has occurred since the last time it was called (8). The first property (3) depends (contingent use pattern) on the code of QuoteApp (6) and on the properties that the parts it uses meeting their specifications (2, 4). These properties depend only on the parts they describe (satisfaction pattern), although in fact, as we shall see later, this is erroneous: the property that registering a timer task with schedule causes its run method to be called at the specified interval (2) actually depends on more than the code of Timer and its associated classes (5). The property that calling run has the desired effect (8) is decomposed into the properties that the getQuote method of Quoter works (10) and that a call to println causes a message to be displayed on the console (12). The property that getQuote works (10) depends on the code of Quoter (14), on the Java libraries’ meeting their specifications (11), and on the property that an HTTP get with an appropriately formed URL containing a ticker symbol will return the value of the cor- Figure 5: Impact of part (13) responding stock (9). This last property depends, of course, on the Yahoo server (13) operating as advertised and being reachable in the network (not shown). The println property (12) is more subtle than one might expect. It depends not only on the code of the relevant Java library (16), but also on a console window’s actually being open (17). The println method writes to the standard output stream. Whether a write to this stream is displayed depends on the state of the window manager; if the console is not showing, the write will not be visible. Exposure, argument and impact are easily read off the diagram by simply following paths. Thus the argument for property (8) – that run has the desired effect – is obtained by selecting all nodes reachable from it (Figure 4). The impact of a failure in the Yahoo server (13) is obtained by selecting all property nodes reachable backwards (Figure 5); not surprisingly, these include the requirement (1). Because this particular system is so simple and performs only a single function, these reductions are less useful than they would be in a larger system. Constructing the dependence diagram and carefully reviewing each property and its dependences revealed, in addition to the issue regarding println mentioned above, a problem with the Timer class. Its official Java documentation warns: Corresponding to each Timer object is a single background thread that is used to execute all of the timer’s tasks, sequentially. Timer tasks should complete quickly. If a timer task takes excessive time to complete, it “hogs” the timer’s task execution thread. This can, in turn, delay the execution of subsequent tasks, which may “bunch up” and execute in rapid succession when (and if) the offending task finally completes. In short, our property (2) does not depend on the code of Timer alone (5). In addition, it depends on a property we failed to state (shown as 2a in Figure 6): that the run method of the timer task completes quickly. For comparison, a traditional dependence diagram is shown in Figure 7. To construct such a diagram there needs to be at least an implicit specification of each component (so that A can be said to depend on B when the adherence of B to its specification is required for A's adherence). We therefore assigned each property to a part; the requirement was assigned to QuoteApp. This diagram is appealingly small, but it conveys very little information. The arrow from QuoteApp to Timer is due not only to the explicit calls to its methods, but just as importantly to the fact that QuoteApp uses Timer to make calls to the run method of Tracker. The arrow from Timer to Tracker is not a necessary consequence of Timer calling the run method of Tracker; it would be absent were it not for the fact that Timer relies on Tracker to return quickly in order to meet its specification. This example reveals a subtlety of traditional dependence diagrams that is usually not recognized. The specification of Timer promises that calls to the timer task will occur with the given period contingent on them completing quickly. If we changed the specification to say that the frequency of execution is the given period minus the completion time, we would effectively shift the burden onto QuoteApp, and the dependence arrow from Timer to Tracker would no longer be shown! Dependences, in other words, are property specific: whether A depends on B cannot be determined unless we know what property A is expected to meet, and what properties other modules might be providing to A. 4 Related Work Notions of dependence in compilation and parallelization have been widely studied, but notions of dependence in program and system design have received less attention from researchers. 4.1 Parnas's Uses Relation The dependence diagram appears to have been invented by David Parnas. He defines the uses relation as follows [14]: A uses B if there exist situations in which the correct functioning of A depends on the availability of a correct implementation of B This definition reveals how Parnas must have grappled with the complexities of dependences. Note that the correct functioning of A need not always depend on B; more can therefore be inferred from lack of dependence than from its presence. The significance of the word ‘availability’ is unclear; perhaps it was intended to allow B to be replaced by an equivalent component, or perhaps it emphasizes the need for not merely the existence of B but its availability in the context of use. Either way, the definition seems to imply that B is a specification but that A is an implementation. ‘Correct functioning’ of A is presumably with respect to its specification. Parnas recognized that dependences do not necessarily follow procedure calls: that some calls result in no dependences, and that some dependences are present in the absence of explicit calls. Despite their enormous value, dependence diagrams appear not to have been widely adopted, and are rarely taught at universities. At MIT, dependence diagrams have been emphasized in software engineering classes for 25 years, due to the efforts of Barbara Liskov and John Guttag who advocated them as a fundamental means for expressing and evaluating designs [11]. Extending dependence diagrams to object-oriented code is not straightforward, for the reason explained in the introduction (with the hash table example). 4.2 Class Diagrams A class diagram mixes elements of an object model (how fields of one class point to another, and how classes implement interfaces or subclass other classes) with elements of a dependence diagram (how methods of one class call another). Design patterns are often depicted using class diagrams [5]. Class diagrams are, unlike dependence diagrams, easy to construct (both by programmers and tools), since they capture purely syntactic properties. But this limits their utility. When a field points to a generic class or interface, the class diagram will not show what class it is bound to at runtime. And when a class makes a call to another class through an interface, the actual class called will not be shown. With some amount of fudging, these problems can be overcome. One can replicate interfaces and abstract classes for their different contexts of use, and show, for each context, which concrete classes they are instantiated with. This enrichment of the class diagram makes their extraction from code far more challenging, however, and although tools [6, 13] have been designed to produce diagrams in this form, they may not scale well and even defining correct output turns out to be surprisingly tricky. 4.3 Design Structure Matrices The design structure matrix (DSM) is a dependence graph represented as an adjacency matrix. It was introduced by Steward in the 1960s [18]. Various algorithms have been develop for automatically discovering structure in DSMs, for example, by topologically sorting the graph to assign modules to layers, and clustering modules into equivalence classes to eliminate cycles. Until recently, DSMs had been used primarily for streamlining manufacturing processes [4], but there has been increasing interest in using DSMs to capture modularity in design [1]. Lattix has developed a tool [16] (now imitated by offerings from other companies) that can extract a DSM from a large codebase, and help identify dependences that violate the intended architectural structure. The notion of dependence in a DSM, especially for software, is not precisely defined. Tools tend to rely on syntactic dependences. Sullivan and his collaborators, however, have revisited Parnas’s work in the context of DSMs [19], and, using design decisions as the nodes of the dependence graph, have given a formal characterization of dependence in terms of logical constraints [2]. Extending these ideas to graphs in which the nodes are components (rather than design constraints) remains to be done. ### 4.4 Goal Notations A variety of diagrammatic notations [20, 10, 3] have been invented for depicting goals and their relationships. The initial motivation was to capture the rationale for system requirements, prior to the articulation of the requirements themselves. Of these, Goal Structuring Notation (GSN) [10] is closest to ours, since it aims to represent the structure of a dependability argument. A GSN ‘goal structure’ is superficially very similar to a property-part diagram: a key requirement of the system is decomposed progressively, and related to knowledge of the software and its environment. In addition to goals, however, which are similar to our properties, a goal structure includes ‘strategies’ that represent the activities performed (proof, testing, etc) to establish the goals; and the focus of the structure is not the relationship between the goals and the components, but rather between the goals and the strategies that justify them. Thus the structure of the dependability argument is based not on the structure of the system, as in our approach, but rather on the structure of the process, which need not be related either to the structure of the system, or to the structure of the argument for its safety. For example [10], a top level goal ‘logic is fault free’ may be decomposed into ‘argument by satisfaction of all requirements’ and ‘argument by omission of all identified hazards.’ Peter Henderson is currently working on a dependence model that represents argument structure directly. Its elements are claims and evidence, with dependences of claims on the claims and evidence that support them. His purpose is to build tool support to make it easier to navigate and maintain large arguments. KAOS [3] is a goal notation that supports both behavioural goals (similar to our properties) and soft goals (which are ‘satisficed’ in Herbert Simon’s sense), although, in contrast to GSN, these are usually about the product and not the process. Unlike property-part diagrams, KAOS supports ‘or’ decompositions, which are useful for showing design alternatives in a single diagram. Whether ‘or’ decomposition is needed to describe systems that make use of redundancy is not clear. KAOS is backed by a temporal logic and a catalog of refinement patterns which can be used to formally validate a design down to a low level. It seems that KAOS naturally represents the property decomposition and satisfaction patterns, but perhaps not the contingent use pattern. ### 4.5 Enriched Module Dependence Diagrams The first author made an earlier attempt at overcoming the shortcomings of traditional dependence diagrams [7]. Modules were viewed as ‘specification transducers,’ mapping specifications they provided (to clients) to specifications they required (as clients of other modules). An additional relation, in the spirit of architectural connection [12], represented the binding of provided ‘ports’ to required ports. For example, if a module B provided a service Q so that a module A could provide a service P, the module A would map P to Q, and B’s provision of Q would be bound to A’s requirement for Q. In contrast, a property-part diagram would show the property P depending on module A and property Q, with a subtle shift in the interpretation of the properties: P and Q are no longer descriptions of anonymously provided services, but assert that modules A and B provide these services. This is what allows the contingent use relationship to be captured without any outgoing dependences from A. Although this earlier model solved some of the problems, it still required properties to be bound to modules: every property was a specification of a single module. This makes it unsuitable for system-level description, supporting (in Michael Jackson's terminology [8]) only specifications and not requirements. Moreover, a ternary dependence relation (specification-module-specification) is hard to draw, so in practice the diagrams added specification labels to dependence arcs between modules, but did not show the internal dependences that are essential for fine-grained tracking. 4.6 Frame Concern Diagrams The property-part notation was inspired by Michael Jackson's problem frame diagrams [9], which show (requirements) properties explicitly as nodes. Jackson's 'frame concern diagram' shows the archetypal form of an argument for a particular class of property following from properties of the constituent domains. Seater, in his doctoral thesis [17], extended the problem frame diagram to an argument diagram that makes explicit the properties of the individual domains, but does not link them together in a dependence structure. Property-part diagrams grew out of his work, and can be seen as an attempt to layer a dependence relation on top of the argument diagram. An early version of the property-part diagram was in fact much closer to the argument diagram, as it included shared-phenomenon links between parts, but these links were dropped as they did not seem to be necessary. 5 Conclusion Dependences are not innate properties of the parts of a system, but arise from the particular way in which a designer chooses to assign responsibilities. A part's functionality does not determine its responsibility. Just because module A calls module B does not mean that A guarantees to its clients the properties of B; it might instead promise only to call B. This is why we have abandoned the idea of explicit dependences between parts, preferring instead to relate parts and properties. So rather than asking 'does the application depend on the database?' we would ask 'does this service provided by the application depend on the database?' If the service is merely to execute certain queries and updates in response to user actions, it will not depend on the database. But if the service is to provide persistent storage and retrieval of data, it surely will. Including properties in a dependence diagram is not optional; they were there all the time, albeit implicitly. Keeping them implicit had two disadvantages that property-part diagrams overcome: it obscured the rationale for the dependences, and it prevented a more fine-grained analysis that allows different properties to be traced independently. In an analysis of a proton therapy machine, the critical property that pressing the emergency button inserts a beam stop was found to have an exposure very much smaller than the entire system, but still larger than one would ideally want [15]; a traditional dependence analysis would have produced a graph that was close to fully connected. Much work remains to be done to understand and refine the property-part diagram, to understand what kinds of inferences can be made from the diagram, and how it might be checked mechanically. The claim, for example, that a change to a part can only affect the properties within its impact clearly will not hold if a change to the 'alphabet' of the part is permitted, so that it engages in entirely new phenomena. The property-part diagram makes it easy to see (unlike a traditional dependence diagram) what properties a replacement part should have, but less clear what other parts might be impacted by a replacement. We are also interested in understanding when dependence of a property on multiple parts induces a coupling between them, and in reconsidering the (unjustified?) assumption that a module should be regarded as vulnerable to changes in the modules it uses but not to changes in the modules that use it. We plan also to investigate the notion of information hiding, to see how it might be accommodated, perhaps as properties over uninterpreted functions. Acknowledgments Derek Rayside made many suggestions about our ideas and their presentation. Axel van Lamsweerde helped us relate our work to KAOS, and has been generous in his encouragement, and tolerant of our slow recognition that dependences arise from goals. The first author is grateful to Michael Jackson in whose honour this workshop was held, not just for his work on problem frames (whose influence on this work is pervasive), but for many years of wise advice and thought-provoking technical discussions. He continues to be an inspiring model (in the iconic rather than analogic sense) of what it means to be an engineer, a thinker, and a mensch. Ad me’ah ve’esrim shanah! References
{"Source-Url": "http://dspace.mit.edu/openaccess-disseminate/1721.1/61343", "len_cl100k_base": 7046, "olmocr-version": "0.1.50", "pdf-total-pages": 15, "total-fallback-pages": 0, "total-input-tokens": 37021, "total-output-tokens": 8758, "length": "2e12", "weborganizer": {"__label__adult": 0.00031185150146484375, "__label__art_design": 0.0004851818084716797, "__label__crime_law": 0.0002884864807128906, "__label__education_jobs": 0.0007333755493164062, "__label__entertainment": 5.459785461425781e-05, "__label__fashion_beauty": 0.00012505054473876953, "__label__finance_business": 0.00014126300811767578, "__label__food_dining": 0.0002944469451904297, "__label__games": 0.00045943260192871094, "__label__hardware": 0.0005197525024414062, "__label__health": 0.00032401084899902344, "__label__history": 0.00021445751190185547, "__label__home_hobbies": 6.866455078125e-05, "__label__industrial": 0.00026679039001464844, "__label__literature": 0.0003147125244140625, "__label__politics": 0.00022733211517333984, "__label__religion": 0.0004117488861083984, "__label__science_tech": 0.00934600830078125, "__label__social_life": 8.255243301391602e-05, "__label__software": 0.004451751708984375, "__label__software_dev": 0.97998046875, "__label__sports_fitness": 0.0002409219741821289, "__label__transportation": 0.0004203319549560547, "__label__travel": 0.0001766681671142578}, "weborganizer_max": "__label__software_dev", "avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_ratio": [[0, 38111, 0.0153]], "fineweb_edu_fasttext_gt2__fineweb_edu_fasttext_gt2__score": [[0, 38111, 0.74202]], "ft_lang_id_en_doc_v2__ft_lang_id_en_doc_v2__en": [[0, 38111, 0.91233]], "google_gemma-3-12b-it_contains_pii": [[0, 2212, false], [2212, 5128, null], [5128, 8482, null], [8482, 11531, null], [11531, 13495, null], [13495, 15359, null], [15359, 16706, null], [16706, 18249, null], [18249, 20240, null], [20240, 22005, null], [22005, 25687, null], [25687, 29519, null], [29519, 33174, null], [33174, 36668, null], [36668, 38111, null]], "google_gemma-3-12b-it_is_public_document": [[0, 2212, true], [2212, 5128, null], [5128, 8482, null], [8482, 11531, null], [11531, 13495, null], [13495, 15359, null], [15359, 16706, null], [16706, 18249, null], [18249, 20240, null], [20240, 22005, null], [22005, 25687, null], [25687, 29519, null], [29519, 33174, null], [33174, 36668, null], [36668, 38111, null]], "google_gemma-3-4b-it_v2tag__is_academic_paper": [[0, 5000, true], [5000, 38111, null]], "google_gemma-3-4b-it_v2tag__is_class_syllabus": [[0, 5000, false], [5000, 38111, null]], "google_gemma-3-4b-it_v2tag__is_completion_certificate": [[0, 5000, false], [5000, 38111, null]], "google_gemma-3-4b-it_v2tag__is_court_notice": [[0, 5000, false], [5000, 38111, null]], "google_gemma-3-4b-it_v2tag__is_homework_assignment": [[0, 5000, false], [5000, 38111, null]], "google_gemma-3-4b-it_v2tag__is_news_article": [[0, 5000, false], [5000, 38111, null]], "google_gemma-3-4b-it_v2tag__is_public_order": [[0, 5000, false], [5000, 38111, null]], "google_gemma-3-4b-it_v2tag__is_resume_cv": [[0, 5000, false], [5000, 38111, null]], "google_gemma-3-4b-it_v2tag__is_test_or_quiz": [[0, 5000, false], [5000, 38111, null]], "google_gemma-3-4b-it_v2tag__is_textbook": [[0, 5000, false], [5000, 38111, null]], "pdf_page_numbers": [[0, 2212, 1], [2212, 5128, 2], [5128, 8482, 3], [8482, 11531, 4], [11531, 13495, 5], [13495, 15359, 6], [15359, 16706, 7], [16706, 18249, 8], [18249, 20240, 9], [20240, 22005, 10], [22005, 25687, 11], [25687, 29519, 12], [29519, 33174, 13], [33174, 36668, 14], [36668, 38111, 15]], "pipe_delimited_lines_v1__pipe_delimited_lines_v1__pipe_delimited_lines_ratio": [[0, 38111, 0.04891]]}
olmocr_science_pdfs
2024-11-28
2024-11-28
d98f811f048cf6bfe6c79ae9f68fbf8bd594eba7
BBN: Description of the PLUM System as Used for MUC-4 Damaris Ayuso, Sean Boisen, Heidi Fox, Herb Gish, Robert Ingria, and Ralph Weischedel BBN Systems and Technologies 10 Moulton Street Cambridge, MA 02138 weisched@bbn.com BACKGROUND Traditional approaches to the problem of extracting data from texts have emphasized hand-crafted linguistic knowledge. In contrast, BBN's PLUM system (Probabilistic Language Understanding Model) was developed as part of a DARPA-funded research effort on integrating probabilistic language models with more traditional linguistic techniques. Our research and development goals are - more rapid development of new applications, - the ability to train (and re-train) systems based on user markings of correct and incorrect output, - more accurate selection among interpretations when more than one is found, and - more robust partial interpretation when no complete interpretation can be found. A central assumption of our approach is that in processing unrestricted text for data extraction, a non-trivial amount of the text will not be understood. As a result, all components of PLUM are designed to operate on partially understood input, taking advantage of information when available, and not failing when information is unavailable. We had previously performed experiments on components of the system with texts from the Wall Street Journal, however, the MUC-3 task was the first end-to-end application of PLUM. Very little hand-tuning of knowledge bases was done for MUC-4; since MUC-3, the system architecture as depicted in figure 1 has remained essentially the same. In addition to participating in MUC-4, since MUC-3 we focused on porting to new domains and a new language, and on performing various experiments designed to control recall/precision tradeoffs. To support these goals, the preprocessing component and the fragment combiner were made declarative; the semantics component was generalized to use probabilities on word senses; we expanded our treatment of reference; we enlarged the set of system parameters at all levels; and we created a new probabilistic classifier for text relevance which filters discourse events. SYSTEM ARCHITECTURE The PLUM architecture is presented in Figure 1. Preprocessing The input to the system is a file containing one or more messages. The preprocessing module determines message boundaries, identifies the header, and determines paragraph and sentence boundaries. The specification of the input format is now a declarative component of the preprocessor, which enables us to easily digest messages in different formats. This component has proved its utility in porting to two non-MUC formats in the last year. Morphological Analysis The first phase of the processing is assignment of part-of-speech information. In BBN's Fast Partial Parser (FPP) [2], a bi-gram probability model, frequency models for known words (derived from large corpora), and heuristics based on word endings for unknown words, assign part of speech to the highly ambiguous words of the corpus. Since these predictions for unknown words were very inaccurate for input that is all upper case, we augmented this part-of-speech tagging with probabilistic models (automatically trained) for recognizing words of Spanish origin and words of English origin. This allowed us to tag new words that were actually Latin American names highly reliably. The Spanish classifier uses a 5 character hidden Markov model, trained on about 30,000 <table> <thead> <tr> <th>1. REPORT DATE</th> <th>2. REPORT TYPE</th> <th>3. DATES COVERED</th> </tr> </thead> <tbody> <tr> <td>1992</td> <td></td> <td>00-00-1992 to 00-00-1992</td> </tr> </tbody> </table> <table> <thead> <tr> <th>4. TITLE AND SUBTITLE</th> </tr> </thead> <tbody> <tr> <td>BBN: Description of the PLUM System as Used for MUC-4</td> </tr> </tbody> </table> <table> <thead> <tr> <th>5a. CONTRACT NUMBER</th> </tr> </thead> <tbody> <tr> <td></td> </tr> </tbody> </table> <table> <thead> <tr> <th>5b. GRANT NUMBER</th> </tr> </thead> <tbody> <tr> <td></td> </tr> </tbody> </table> <table> <thead> <tr> <th>5c. PROGRAM ELEMENT NUMBER</th> </tr> </thead> <tbody> <tr> <td></td> </tr> </tbody> </table> <table> <thead> <tr> <th>6. AUTHOR(S)</th> </tr> </thead> <tbody> <tr> <td></td> </tr> </tbody> </table> <table> <thead> <tr> <th>7. PERFORMING ORGANIZATION NAME(S) AND ADDRESS(ES)</th> </tr> </thead> <tbody> <tr> <td>BBN Technologies, 10 Moulton Street, Cambridge, MA, 02238</td> </tr> </tbody> </table> <table> <thead> <tr> <th>8. PERFORMING ORGANIZATION REPORT NUMBER</th> </tr> </thead> <tbody> <tr> <td></td> </tr> </tbody> </table> <table> <thead> <tr> <th>9. SPONSORING/MONITORING AGENCY NAME(S) AND ADDRESS(ES)</th> </tr> </thead> <tbody> <tr> <td></td> </tr> </tbody> </table> <table> <thead> <tr> <th>10. SPONSOR/MONITOR’S ACRONYM(S)</th> </tr> </thead> <tbody> <tr> <td></td> </tr> </tbody> </table> <table> <thead> <tr> <th>11. SPONSOR/MONITOR’S REPORT NUMBER(S)</th> </tr> </thead> <tbody> <tr> <td></td> </tr> </tbody> </table> <table> <thead> <tr> <th>12. DISTRIBUTION/AVAILABILITY STATEMENT</th> </tr> </thead> <tbody> <tr> <td>Approved for public release; distribution unlimited</td> </tr> </tbody> </table> <table> <thead> <tr> <th>13. SUPPLEMENTARY NOTES</th> </tr> </thead> <tbody> <tr> <td></td> </tr> </tbody> </table> <table> <thead> <tr> <th>14. ABSTRACT</th> </tr> </thead> <tbody> <tr> <td></td> </tr> </tbody> </table> <table> <thead> <tr> <th>15. SUBJECT TERMS</th> </tr> </thead> <tbody> <tr> <td></td> </tr> </tbody> </table> <table> <thead> <tr> <th>16. SECURITY CLASSIFICATION OF:</th> </tr> </thead> <tbody> <tr> <td>a. REPORT unclassified</td> </tr> <tr> <td>b. ABSTRACT unclassified</td> </tr> <tr> <td>c. THIS PAGE unclassified</td> </tr> </tbody> </table> <table> <thead> <tr> <th>17. LIMITATION OF ABSTRACT</th> </tr> </thead> <tbody> <tr> <td></td> </tr> </tbody> </table> <table> <thead> <tr> <th>18. NUMBER OF PAGES</th> <th>19a. NAME OF RESPONSIBLE PERSON</th> </tr> </thead> <tbody> <tr> <td>8</td> <td></td> </tr> </tbody> </table> words of Spanish text. The five-gram model of words of English was derived from text from the Wall Street Journal. Figure 1. PLUM System Architecture Parsing The FPP is a deterministic stochastic parser which does not attempt to generate a single syntactic interpretation of the whole sentence, rather, it generates one or more non-overlapping parse fragments spanning the input sentence, deferring difficult decisions on attachment ambiguities. FPP produces an average of seven fragments for sentences of the complexity seen in the MUC-4 corpus. Here are the 8 parse fragments generated by FPP for the first sentence of TST2-MUC4-0048: ("SALVADORAN PRESIDENT-ELECT ALFREDO CRISTIANI CONDEMNS THE TERRORIST KILLING OF ATTORNEY GENERAL ROBERTO GARCIA ALVARADO" 1This number is inflated due to the fact that sentence-final punctuation always appears as a separate fragment, and the fact that commas frequently appear as isolated fragments. (S (NP (NP (ADJP (ADJ "SALVADORAN"))) (N "PRESIDENT-ELECT"))) (NP (N "ALFREDO" "CRISTIANI"))) (VP (AUX) (VP (V "CONDEMned") (NP (DETERMINER "the") (N "TERRORIST") (N "KILLING"))) (PP (PREP "OF") (NP (NP (N "ATTORNEY GENERAL")) (N (NAME "ROBERTO") (NAME "GARCIA") (NAME "ALVARADO"))))))) ("AND" (CONJ "AND") ("ACCUSED THE FARABUNDO MARTI NATIONAL LIBERATION FRONT") (VP (AUX) (VP (V "ACCUSED") (NP (DETERMINER "THE") (N "FARABUNDO" "MARTI" "NATIONAL" "LIBERATION" "FRONT")))) ("." (PUNCT ".")) "FMLN" (NP (N "FMLN"))) ("." (PUNCT ".")) ("OF THE CRIME" (PP (PREP "OF") (NP (DETERMINER "THE") (N "CRIME")))) (171) Semantic Interpreter The semantic interpreter operates on each fragment produced by FPP in a bottom-up, compositional fashion. Throughout the system, defaults are provided so that missing semantic information or rules do not produce errors, but simply mark semantic elements or relationships as unknown. This is consistent with our belief that partial understanding has to be a key element of text processing systems, and missing data has to be regarded as a normal event. The semantic component encompasses both lexical semantics and semantic rules. The semantic lexicon is separate from the parser's lexicon and has much less coverage. We used an automatic case frame induction procedure to construct an initial version of the lexicon [2]. Word senses of the semantic lexicon have probability assignments, which we plan to derive automatically from corpora. For MUC-4, probabilities were assigned so each word sense is more probable than the next sense of the word as entered in the lexicon. Lexical semantic entries indicate the word's semantic type (a domain model concept), as well as predicates pertaining to it. For example, here is the lexical semantics for the verb BOMB: (defverb "BOMB" (BOMB-V-1 BOMBING (:case (subject PEOPLE TI-PERP-OF) (object ANYTYPE OBJECT-OF)))) This entry indicates that the type is BOMBING, that a subject argument whose type is PEOPLE should be given the role TI-PERP-OF, and that an object argument of any type should be given the role OBJECT-OF. BOMB-V-1 is the unique identifier of this (only) word sense. The semantic rules are based on general syntactic patterns, using wildcards and similar mechanisms to provide an extra measure of robustness. The basic elements of our semantic representation are "semantic forms", each of which introduces a variable (e.g. ?13) with a type and a collection of predicates pertaining to that variable. There are three basic types of semantic forms: entities of the domain, events, and states of affairs. Each of these three can be further categorized as known, unknown, and referential. Entities correspond to the people, places, things, and time intervals of the domain. These are related in important ways, such as through events (who did what to whom) and states of affairs (properties of the entities). Entity descriptions typically arise from noun phrases; events and states of affairs may be described in clauses. Not everything that is represented in the semantics has actually been understood. For example, the predicate PP-MODIFIER indicates that two entities (expressed as noun phrases) are connected via a certain preposition. In this way, we have a "placeholder" for the information that a certain structural relation holds between these two items, even though we do not know what the actual semantic relation is. Sometimes understanding the relation more fully is of no consequence, since the information does not contribute to the template-filling task. The information is maintained, however, so that later expectation-driven processing can use it if necessary. Here is a semantic rule which handles, for example, "group of businessmen", "murder of a man", and "terrorists of the FMLN": For an NP dominating an NP1, and a PP whose PREP is "OF" and which dominates NP2: If NP1 is in ("GROUP, "BAND") ; return semantics of NP2 If NP1 is an EVENT of type TERRORIST ; make NP2 the OBJECT-OF NP1; return new NP1 sem If type of NP1 is PEOPLE and type of NP2 is ORGANIZATION, merge semantics, showing that NP1 BELONGS-TO NP2; otherwise use a more general NP => NP PP rule An important consequence of the fragmentation produced by FPP is that top-level constituents are typically more shallow and less varied than full sentence parses. As a result, more semantics coverage was obtained early on in the development process with few semantic rules than would have been expected if the system had had to cover widely varied syntactic structures before producing any semantic structures. In this way, semantic coverage can be added gradually, while the rest of the system is progressing in parallel. After having assigned semantic representations to the fragments produced by FPP, it is often possible to make some of the attachment decisions which had been deferred. For example, it is possible to combine two NPs of compatible semantic types that are conjoined, or attach prepositional phrases preferentially, using information automatically derived from a corpus [7]. Our basic system uses fragment combination for certain proper name constructions, while some of our submitted optional runs used more extensive patterns for fragment combination. Figure 2 shows a graphical version of the semantics generated for the first fragment of S1 in TST2-MUC4-0048. In this example note the UNKNOWN-EVENT created for the main verb "CONDEMNED", which has no lexical semantics in our system, but still generates a useful semantic representation. Figure 2: Example Semantic Representation for "SALVADORAN PRESIDENT-ELECT ALFREDO CRISTIANI CONDEMNED THE TERRORIST KILLING OF ATTORNEY GENERAL ROBERTO GARCIA ALVARADO" Discourse Processing The discourse component of PLUM performs the operations necessary to construct event objects corresponding to relevant events in the message. Each event object in the discourse event structure is similar in principle to the notion of a "frame", with its corresponding "slots" or fields. The semantic representation of an event in the text only includes information contained locally in a fragment (after fragment combination); in creating corresponding event objects, the discourse module must infer other long-distance or indirect relations not explicitly found by the interpreter, and resolve any references in the text. The template generator then uses the structures created by the discourse component to generate the final templates. Currently only terrorist incidents (and "possible terrorist incidents") generate discourse events, since these are the core events for MUC-4 template generation. The discourse component was further discussed in [1]. Two primary structures are created by the discourse processor which are used by the template generator: the discourse predicate database and the event structure. The database contains all the predicates mentioned in the semantic representation of the message. When references are resolved, corresponding semantic variables are unified in the database. Any other inferences done by the discourse component also get added to the database. To create the discourse event structure, the discourse component processes each semantic form produced by the interpreter, adding its information to the database and performing reference resolution when needed. Pronouns and person-type anaphoric definite NPs may be resolved. In addition, set- and member-type reference is also treated in other simpler domains. Some intra-sentential structural constraints on reference are enforced. When a semantic form for an event of interest is encountered, a discourse event is generated, and any slots already found by the interpreter are filled in the event. This event is then merged with a previous event if they are compatible. This heuristic assumes that the events were possibly derived from repeated references to a single real event. Once all the semantic forms have been processed, heuristic rules are applied to fill in any unfilled slots by looking at text surrounding the forms which triggered a given event. Each filler found is assigned a score based on where it was found in relation to an event trigger, indicating a higher confidence for fillers found closer to a trigger. Following is the discourse event structure for the first event in TST2-MUC4-0048: Event: MURDER Trigger fragments: "SALVADORAN PRESIDENT-ELECT ALFREDO CRISTIANI CONDEMNED THE TERRORIST KILLING OF ATTORNEY GENERAL ROBERTO GARCIA ALVARADO" "GARCIA ALVARADO, 56, WAS KILLED" "ITS FRONT GROUPS ARE RESPONSIBLE FOR THE IRRATIONAL VIOLENCE THAT KILLED ATTORNEY GENERAL GARCIA" --- TI-PERP-OF: "ITS FRONT GROUPS" (score = 1) "IT" (score = 1) <=> "THE FMLN" "URBAN GUERRILLAS" (score = 2) EVENT-TIME-OF: "JUNE 1" (score = 6) EVENT-LOCATION-OF: "DOWNTOWN SAN SALVADOR" (score = 2) "EL SALVADOR" (score = 2) TI-INSTRUMENT-OF: "A BOMB" (score = 2) OBJECT-OF: "ATTORNEY GENERAL ROBERTO GARCIA ALVARADO" (score = 0) "PRESIDENT OF THE LEGISLATIVE" (score = 2) "AN ARENA LEADER" (score = 2) Each trigger fragment contains one or more words whose semantics triggered this event. In the example above, a score of 0 indicates the filler was found directly by the semantics; 1 that it was found in the same fragment as a trigger semantic form; 2 in the same sentence; 4 in the same paragraph; and 6 in an adjacent paragraph. Template Generation The template generator takes the event structure produced by discourse processing and fills out the application-specific templates. Clearly much of this process is governed by the specific requirements of the application, considerations which have little to do with linguistic processing. The template generator must address any arbitrary constraints, as well as deal with the basic details of formatting. The template generator uses a combination of data-driven and expectation-driven strategies. First the information in the event structure is used to produce initial values. At this point, values which should be filled in but are not available in the event structure are supplied from defaults, either from the header (e.g., date and location information) or from reasonable guesses (e.g., that the object of a murder is usually a suitable filler for the human target slot when the semantic type of the object is unknown). We expect to eventually use a classifier at this stage of processing. This is especially appropriate for template slots with a set list of possible fillers, e.g. perpetrator confidence, category of incident, etc. Text Relevance A new classifier for determining text relevance is now a component of PLUM. It may be utilized by our system to filter out a discourse event object when none of the phrases that gave rise to it is found in a paragraph classified as relevant. Since the event objects are the input to the template generator, it serves effectively as a filter on templates. The text classifier uses a probabilistic model to perform a binary classification. The features used by the model are stemmed words. The text classifier is trained automatically from two sets of text representing the categories of the classifier (i.e. relevant and irrelevant). A chi-square test is used to determine which words are good indicators of membership on one category but not the other. These words become the features of the probabilistic model. A log probability representing the likelihood of the word occurring in text of one type or the other is assigned to each word. It is this probability that is used in the classification process. When a piece of text is to be classified, it is scanned for occurrences of the word features selected during training. Summing the log probabilities of all the evidence found in the text gives a measure of the likelihood that the text is a member of a particular category. The sum is then compared to a user-selected threshold to determine the classification. Different thresholds produce different recall and precision values, allowing the user to tune the classifier for high recall, high precision, or something in between. Several of our optional runs showing a wide range of recall-precision tradeoffs were obtained by varying the classifier threshold. Parameters in PLUM An important feature of PLUM is that many aspects of its behavior can be controlled by simply varying the values of system parameters. An important goal has been to make our system as "parameterizable" as possible, so that the same software can meet different demands for recall, precision, and overgeneration. PLUM has parameters to control, for example, some aspects of fragment combination, event merging and slot filling by discourse, and relevance assignment by the classifier. In order to pick which system configuration to use for our required MUC-4 run, we tested more than 25 configurations on two test sets and one training set. Maximal F-scores were obtained with settings for aggressively merging events, conservatively looking for slot fillers, and a classifier threshold on relevance of 1. TEMPLATES FOR EXAMPLE MESSAGE 0. MESSAGE: ID TST2-MUC4-0048 1. MESSAGE: TEMPLATE 1 2. INCIDENT: DATE 01 JUN 88 3. INCIDENT: LOCATION EL SALVADOR: SAN SALVADOR (CITY) 4. INCIDENT: TYPE ATTACK 5. INCIDENT: STAGE OF EXECUTION ACCOMPLISHED 6. INCIDENT: INSTRUMENT ID "A BOMB" 7. INCIDENT: INSTRUMENT TYPE BOMB: "A BOMB" 8. PERP: INCIDENT CATEGORY TERRORIST ACT 9. PERP: INDIVIDUAL ID "ITS FRONT GROUPS" 10. PERP: ORG ID "FMLN" 11. PERP: ORG CONFIDENCE REPORTED AS FACT: "FMLN" 12. PHYS TGT: ID - 13. PHYS TGT: TYPE - 14. PHYS TGT: NUMBER - 15. PHYS TGT: FOREIGN NATION - 16. PHYS TGT: EFFECT OF INCIDENT - We correctly identified the 2 events of interest: Merino's murder and the attack on Merino's home. We found the correct instruments (though we overgenerated "EXPLOSIVES" in template 2). We filled the location, stage of execution, incident category, perpetrator organization correctly in both templates. We found the correct perpetrator individual ID in template 2 (and one could argue also in template 1). However: - We picked up the wrong dates. - Our conservative heuristics for picking up multiple targets did not find more than one correct target in these templates. ACKNOWLEDGEMENTS The work reported here was supported in part by the Defense Advanced Research Projects Agency and was monitored by Rome Laboratory under Contract No. F30602-91-C-0051. The views and conclusions contained in this document are those of the authors and should not be interpreted as necessarily representing the official policies, either expressed or implied, of the Defense Advanced Research Projects Agency or the United States Government. REFERENCES
{"Source-Url": "https://apps.dtic.mil/dtic/tr/fulltext/u2/a460888.pdf", "len_cl100k_base": 5116, "olmocr-version": "0.1.50", "pdf-total-pages": 9, "total-fallback-pages": 0, "total-input-tokens": 23111, "total-output-tokens": 5346, "length": "2e12", "weborganizer": {"__label__adult": 0.0004167556762695313, "__label__art_design": 0.0005536079406738281, "__label__crime_law": 0.0013265609741210938, "__label__education_jobs": 0.001857757568359375, "__label__entertainment": 0.0001976490020751953, "__label__fashion_beauty": 0.0002493858337402344, "__label__finance_business": 0.00034236907958984375, "__label__food_dining": 0.0004093647003173828, "__label__games": 0.0006594657897949219, "__label__hardware": 0.0014629364013671875, "__label__health": 0.0007467269897460938, "__label__history": 0.00040078163146972656, "__label__home_hobbies": 0.00011420249938964844, "__label__industrial": 0.0008420944213867188, "__label__literature": 0.0013456344604492188, "__label__politics": 0.000591278076171875, "__label__religion": 0.0006074905395507812, "__label__science_tech": 0.294677734375, "__label__social_life": 0.0001875162124633789, "__label__software": 0.035797119140625, "__label__software_dev": 0.65625, "__label__sports_fitness": 0.0002956390380859375, "__label__transportation": 0.0005884170532226562, "__label__travel": 0.00018036365509033203}, "weborganizer_max": "__label__software_dev", "avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_ratio": [[0, 21836, 0.0243]], "fineweb_edu_fasttext_gt2__fineweb_edu_fasttext_gt2__score": [[0, 21836, 0.50827]], "ft_lang_id_en_doc_v2__ft_lang_id_en_doc_v2__en": [[0, 21836, 0.90435]], "google_gemma-3-12b-it_contains_pii": [[0, 3501, false], [3501, 5602, null], [5602, 6546, null], [6546, 9873, null], [9873, 12460, null], [12460, 16545, null], [16545, 20410, null], [20410, 21616, null], [21616, 21836, null]], "google_gemma-3-12b-it_is_public_document": [[0, 3501, true], [3501, 5602, null], [5602, 6546, null], [6546, 9873, null], [9873, 12460, null], [12460, 16545, null], [16545, 20410, null], [20410, 21616, null], [21616, 21836, null]], "google_gemma-3-4b-it_v2tag__is_academic_paper": [[0, 5000, false], [5000, 21836, null]], "google_gemma-3-4b-it_v2tag__is_class_syllabus": [[0, 5000, false], [5000, 21836, null]], "google_gemma-3-4b-it_v2tag__is_completion_certificate": [[0, 5000, false], [5000, 21836, null]], "google_gemma-3-4b-it_v2tag__is_court_notice": [[0, 5000, false], [5000, 21836, null]], "google_gemma-3-4b-it_v2tag__is_homework_assignment": [[0, 5000, false], [5000, 21836, null]], "google_gemma-3-4b-it_v2tag__is_news_article": [[0, 5000, false], [5000, 21836, null]], "google_gemma-3-4b-it_v2tag__is_public_order": [[0, 5000, false], [5000, 21836, null]], "google_gemma-3-4b-it_v2tag__is_resume_cv": [[0, 5000, false], [5000, 21836, null]], "google_gemma-3-4b-it_v2tag__is_test_or_quiz": [[0, 5000, false], [5000, 21836, null]], "google_gemma-3-4b-it_v2tag__is_textbook": [[0, 5000, false], [5000, 21836, null]], "pdf_page_numbers": [[0, 3501, 1], [3501, 5602, 2], [5602, 6546, 3], [6546, 9873, 4], [9873, 12460, 5], [12460, 16545, 6], [16545, 20410, 7], [20410, 21616, 8], [21616, 21836, 9]], "pipe_delimited_lines_v1__pipe_delimited_lines_v1__pipe_delimited_lines_ratio": [[0, 21836, 0.29474]]}
olmocr_science_pdfs
2024-12-01
2024-12-01
f498b6b97c13dfe20e4cea25c9f216638345d5b7
Databases and Internet Applications Part 1 Chapter 7.1-7.5 Lecture Overview - Internet Concepts - Web data formats - HTML, XML, DTDs - Introduction to three-tier architectures - The presentation layer - HTML forms; HTTP Get and POST, URL encoding; Javascript; Stylesheets. XSLT - The middle tier - CGI, application servers, Servlets, JavaServerPages, passing arguments, maintaining state (cookies) Uniform Resource Identifiers - Uniform naming schema to identify resources on the Internet - A resource can be anything: - Index.html - mysong.mp3 - picture.jpg - Example URIs: - http://compgen.unc.edu/Courses - mailto:webmaster@bookstore.com - ftp://ftp.sanger.ac.uk/pub/ Structure of URIs http://www.cs.unc.edu/Courses/comp521-f10/ - URI has three parts: - Name of the protocol used to access the resource (http) - Name of the host computer (www.cs.unc.edu) - Name of the resource (Courses/comp521-f10/) (in this case the default document “index.php”) - URLs are a subset of URIs - URL (Universal Resource Locator) - The distinction is not important for our purposes Hypertext Transfer Protocol (HTTP) - What is a communication protocol? - Set of standards that defines the structure of messages - Examples: TCP, IP, HTTP, FTP - What happens if you click on [http://compgen.unc.edu/Courses](http://compgen.unc.edu/Courses)? 1. Client (web browser) sends an **HTTP request** to server (compgen.unc.edu) 2. Server replies with an **HTTP response** HTTP Requests HTTP Requests consists of several lines of ASCII text, with an empty line at the end. GET ~/index.html HTTP/1.1 User-agent: Mozilla/4.0 Accept: text/html, image/gif, image/jpeg The type of the client (e.g., versions of Netscape or Internet Explorer) The type of files the client is willing to accept (e.g., this client cannot accept an mpg video) HTTP Responses - The server retrieves the page “index.html” and uses it to assemble the HTTP response message. - The HTTP response message has three parts: - status line - several header lines - body of the message (which contains the requested object) HTTP Response: Status Line HTTP version Status code Associated server message HTTP/1.1 200 OK Common status codes and associated messages: - **200 OK**: The request succeeded and the object is in the body of the message - **400 Bad Request**: The request could not be fulfilled - **404 Not Found**: The requested object does not exist - **505 HTTP Version Not Supported**: The protocol version used by the client is not supported by the server HTTP Responses: Header Lines Date: Mon, 04 Mar 2002 12:00:00 GMT Server: Apache/1.3.0 (Linux) Last-Modified: Mon, 01 Mar 2002 09:23:24 GMT Content-Length: 1024 Content-Type: text/html HTTP Response: Body <HTML> <HEAD></HEAD> <BODY> <h1>Barns and Nobble Internet Bookstore</h1> Our inventory: <h3>Science</h3> <b>The Character of Physical Law</b> ... HTTP is Stateless - HTTP is stateless - No “sessions” - Every message is self-contained - No previous interaction are “remembered” by the protocol - Tradeoff between ease of implementation and ease of application development - Other functionality has to be built on top - Implications for applications: - Any state information (shopping carts, user login-information) need to be encoded in every HTTP request and response! - Popular methods on how to maintain state: - Cookies (more on them next lecture) - Generate unique URL’s dynamically at the server level Web Data Formats - **HTML**: HyperText Markup Language - The presentation language for the Internet - **XML**: eXtensible Markup Language - A self-describing, hierarchal data model - **DTD**: Document Type Declarations - Standardizing rules/schemas for XML - **CSS**: Cascading Style Sheets - Page layout and formatting hints - **XSL**: eXtensible Style Language - not covered HTML: Basic Constructs An HTML document is enclosed by these two tags: ``` <html> </html> ``` Commands in HTML consist of a start tag and an end tag. The head section contains information about the page including the title, author, etc. HTML: Basic Constructs <html> <head> ... </head> <body> The body section contains the parts of the web page the browser will display: text, images, links, etc. </body> </html> HTML: Basic Constructs There are six levels of section headers: h1 through h6 HTML: Basic Constructs ``` <html> <head> ... </head> <body> <h1>Section 1</h1> <ul> <li>This is the first item</li> </ul> </body> </html> ``` - Ordered List ``` <ol> <li>Coffee</li> <li>Tea</li> </ol> ``` - Definition List ``` <dl> <dt>Coffee</dt> <dd>...</dd> <dt>Tea</dt> <dd>...</dd> </dl> ``` This is an unordered list <html> <head> ... </head> <body> <h1>Section 1</h1> <ul> <li>This is the <b>first</b> item</li> </ul> </body> </html> <html> <head></head> <body> <h1>Barns and Nobble Internet Bookstore</h1> <h3>Science</h3> <b>The Character of Physical Law</b> <ul> <li>Author: Richard Feynman</li> <li>Published 1980</li> <li>Hardcover</li> </ul> <h3>Fiction</h3> <b>Oliver Twist</b> <ul> <li>Author: Charles Dickens</li> <li>Published 2002</li> </ul> <b>Pride and Prejudice</b> <ul> <li>Author: Jane Austen</li> <li>Published 1983</li> <li>Paperback</li> </ul> </body> </html> HTML: Summary - HTML is a markup language for describing content - Commands are tag enclosures: - Start tag and end tag - Examples: - `<HTML> ... </HTML>` - `<UL> ... </UL>` - Many editors automatically generate HTML directly from your document (e.g., Microsoft Word has an “Save as Web Page” facility) HTML vs XML - **HTML** - Supports a fixed set of predefined tags - Not enough tags to describe the structures of the content of specific applications (e.g., what part of the content are names?, etc.) - **XML** - Allows users to define new tags to structure any type of data or document - It makes database systems more tightly integrated into Web applications XML – The Extensible Markup Language - **Language** - A way of communicating information - **Markup** - Notes or meta-data that describe your data or language - **Extensible** - Limitless ability to define new languages or data sets XML Elements - Elements are also called tags - Elements are primary building blocks of an XML document - Each element of a user-defined type ELM is enclosed by `<ELM>` and `</ELM>` Example: `<FIRSTNAME>Jessica</FIRSTNAME>` - Elements can be nested (forming a tree structure) Example: `<BOOK>` `<AUTHOR>` `<FIRSTNAME>Charles</FIRSTNAME>` `<LASTNAME>Dickens</LASTNAME>` `<AUTHOR>` `</BOOK>` - EXML elements are case sensitive: BOOK ≠ Book XML Elements /w Attributes - An Element can have descriptive attributes - The values of attributes are set inside the start tag of the element - All attribute values must be enclosed in quotes Example: ```xml <BOOK GENRE="Fiction" FORMAT="Hardcover"> <AUTHOR> <FIRSTNAME>Charles</FIRSTNAME> <LASTNAME>Dickens</LASTNAME> </AUTHOR> </BOOK> ``` XML – Structure - XML looks like HTML - XML is a hierarchy of user-defined tags called elements with attributes and data - Data are described by elements, elements are described by attributes ```xml <BOOK genre="Science" format="Hardcover">...</BOOK> ``` - Open tag - Element name - Attribute - Attribute value - Data - Closing tag **XML Entity References** - XML data can’t contain the reserved characters - Whenever an *entity reference* appears in the document, it is textually replaced by its content - Format: `&lt;` “lt” is an entity reference for the character “<“ <table> <thead> <tr> <th>Reserved Characters</th> <th>Entity References</th> </tr> </thead> <tbody> <tr> <td><code>&lt;</code></td> <td><code>&lt;</code></td> </tr> <tr> <td><code>&gt;</code></td> <td><code>&gt;</code></td> </tr> <tr> <td><code>&amp;</code></td> <td><code>&amp;</code></td> </tr> <tr> <td><code>“</code></td> <td><code>“</code></td> </tr> <tr> <td><code>‘</code></td> <td><code>‘</code></td> </tr> <tr> <td><code>amp</code></td> <td><code>amp</code></td> </tr> <tr> <td><code>quot</code></td> <td><code>quot</code></td> </tr> <tr> <td><code>apos</code></td> <td><code>apos</code></td> </tr> </tbody> </table> Example: `&apos;1&lt;5&apos;` XML: Comments - Comments start with <!-- and end with --> - Comments can contain arbitrary text except the string -- - Example: <!-- comment --> XML: An Example ```xml <?xml version="1.0" encoding="UTF-8" standalone="yes"?> <BOOKLIST> <BOOK genre="Science" format="Hardcover"> <AUTHOR> <FIRSTNAME>Richard</FIRSTNAME><LASTNAME>Feynman</LASTNAME> </AUTHOR> <TITLE>The Character of Physical Law</TITLE> <PUBLISHED>1980</PUBLISHED> </BOOK> <BOOK genre="Fic_on"> <AUTHOR> <FIRSTNAME>Charles</FIRSTNAME><LASTNAME>Dickens</LASTNAME> </AUTHOR> <TITLE>Oliver Twist</TITLE> <PUBLISHED>2002</PUBLISHED> </BOOK> <BOOK genre="Fic_on"> <AUTHOR> <FIRSTNAME>Jane</FIRSTNAME><LASTNAME>Austen</LASTNAME> </AUTHOR> <TITLE>Pride and Prejudice</TITLE> <PUBLISHED>1983</PUBLISHED> </BOOK> </BOOKLIST> ``` - A root element contains all other elements - Should begin with an XML declaration - All elements must be properly nested XML – What’s The Point? - You can include your data and a description of what the data represents - This is useful for defining your own language or protocol - Example: Chemical Markup Language <molecule> <name>Methionine</name> <formula>\text{C}_{5}\text{H}_{11}\text{NO}_{2}\text{S}</formula> <weight>149.2</weight> <spectra>...</spectra> <figures>...</figures> </molecule> Storage is just an n-ary tree ```xml <root> <tag1> Some Text <tag2>More</tag2> </tag1> </root> ``` Unlike HTML, XML has **user-defined elements** (tags) → the user needs to describe these elements **DTD is a set of rules** that defines the user-defined elements for an XML document → DTD is the schema for the XML data → DTD says what elements and attributes are required or optional (the formal structure of the language) **A document is valid** if it is structured according to the rules set by the DTD A DTD is enclosed in: <!DOCTYPE name [DTDdeclaration]> **DTD Structure** ```xml <!DOCTYPE BOOKLIST [ <!ELEMENT BOOKLIST (BOOK)*> ]> ``` - A DTD starts with the root element - The root element BOOKLIST consists of zero or more BOOK elements - `*`: zero or more occurrences - `+`: one or more occurrences - `?`: zero or one occurrence <!DOCTYPE BOOKLIST [ <!ELEMENT BOOKLIST (BOOK)*> <!ELEMENT BOOK (AUTHOR,TITLE,PUBLISHED?)> • An element can have nested elements • This rule says that a BOOK element contains an AUTHOR element, a TITLE element, and an optional PUBLISHED element <!DOCTYPE BOOKLIST [ <!ELEMENT BOOKLIST (BOOK)*> <!ELEMENT BOOK (AUTHOR,TITLE,PUBLISHED?)> <!ELEMENT AUTHOR (FIRSTNAME,LASTNAME)> <!ELEMENT FIRSTNAME (#PCDATA)> <!ELEMENT LASTNAME (#PCDATA)> • Instead of containing other elements, an element can contain actual text ▪ #PCDATA indicates character data ▪ EMPTY indicates the element has no content ▪ ANY indicates that any content is permitted. No checking inside this structure (avoided whenever possible) ]> • Instead of containing other elements, an element can contain actual text ▪ #PCDATA indicates character data ▪ EMPTY indicates the element has no content ▪ ANY indicates that any content is permitted. No checking inside this structure (avoided whenever possible) <!DOCTYPE BOOKLIST[ <!ELEMENT BOOKLIST (BOOK)*>] <!ELEMENT BOOK (AUTHOR,TITLE,PUBLISHED?)> <!ELEMENT AUTHOR (FIRSTNAME,LASTNAME)> <!ELEMENT FIRSTNAME (#PCDATA)> <!ELEMENT LASTNAME (#PCDATA)> <!ELEMENT TITLE (#PCDATA)> <!ELEMENT PUBLISHED (#PCDATA)> <!ATTLIST BOOK GENRE (Science|Fiction) #REQUIRED> <!ATTLIST BOOK FORMAT (Paperback|Hardcover) "Paperback">]} **DTD Structure** - Attributes of elements are declared outside the element. - The BOOK element has two attributes: - The GENRE attribute is required and can have the value ‘Science’ or ‘Fiction’ - The FORMAT attribute can have the value ‘Paperback’ or ‘Hardcover’, and ‘Paperback’ is the default value - #REQUIRED is the default option <!DOCTYPE BOOKLIST [ <!ELEMENT BOOKLIST (BOOK)*> <!ELEMENT BOOK (AUTHOR,TITLE,PUBLISHED?)> <!ELEMENT AUTHOR (FIRSTNAME,LASTNAME)> <!ELEMENT FIRSTNAME (#PCDATA)> <!ELEMENT LASTNAME (#PCDATA)> <!ELEMENT TITLE (#PCDATA)> <!ELEMENT PUBLISHED (#PCDATA)> <!ATTLIST BOOK GENRE (Science|Fiction) #REQUIRED> <!ATTLIST BOOK FORMAT (Paperback|Hardcover) “Paperback”> ]> Five Possible Content Types <!ELEMENT (contentType)> - Other elements - Special symbol #PCDATA, EMPTY, or ANY - A regular expression constructed from the preceding four choices - exp1, exp2, exp3: An ordered list of regular expressions - Exp*: An optional expression (zero or more occurrences) - Exp?: An optional expression (zero or one occurrences) - Exp+: A mandatory expression (one or more occurrences) - Exp1 | exp2: exp1 or exp2 **DTD – An Example** ```xml <?xml version='1.0'?> <!ELEMENT Basket (Cherry+, (Apple | Orange)*) > <!ELEMENT Cherry EMPTY> <!ATTLIST Cherry flavor CDATA #REQUIRED> <!ELEMENT Apple EMPTY> <!ATTLIST Apple color CDATA #REQUIRED> <!ELEMENT Orange EMPTY> <!ATTLIST Orange location 'Florida'> <Basket> <Cherry flavor='good'/> <Apple color='red'/> <Apple color='green'/> </Basket> <Apple/> <Cherry flavor='good'/> <Orange/> </Basket> ``` Apple’s color is required. Cherry should go first. **DTD – Well-Formed and Valid** ```xml <?xml version='1.0'?> <!ELEMENT Basket (Cherry+)> <!ELEMENT Cherry EMPTY> <!ATTLIST Cherry flavor CDATA #REQUIRED> Not Well-Formed ```xml <Basket> <Cherry flavor=good> </Basket> ``` Well-Formed but Invalid ```xml <Job> <Location>Home</Location> </Job> ``` Well-Formed and Valid ```xml <Basket> <Cherry flavor='good'> </Basket> ``` XML and DTDs - More and more standardized (domain-specific) DTDs will be developed - MathML (Mathematical Markup Language) - Chemical Markup Language - Enable seamless data exchange among heterogeneous sources - Sophisticated query languages for XML are available: - Xquery - XPath Web Application Architectures - Model encompassing most web-based apps - Three separate types of functionality: - Data management (Model) - Application logic (Controller) - Presentation (View) - The system architecture determines whether these three components reside on a single system (tier) or are distributed across several tiers Single-Tier Architectures All functionality combined into a single tier, usually on a mainframe - User access through dumb terminals Advantages: - Easy maintenance and administration Disadvantages: - Today, users expect graphical user interfaces. - Centralized computation of all of them is too much for a central system **Client-Server Architectures** Work division: **Thin client** - **Client** implements only the graphical user interface - **Server** implements business logic and data management ❖ Work division: **Thick client** - **Client** implements both the graphical user interface and the business logic - **Server** implements data management Disadvantages of Thick Clients - No central place to update the business logic - Security issues: Server needs to trust clients - Clients need to leave server database in consistent state - One possibility: Encapsulate all database access into stored procedures - Does not scale to more than several 100s of clients - Large data transfer between server and client - More than one server creates a problem: $x \times y$ connections Three-Tier Architecture Data management tier Database Network Middle tier Application Logic Network Presentation tier Client (Web Browser) ... The Three Layers Presentation tier - Primary interface to the user - Needs to adapt to different display devices (PC, PDA, cell phone, voice access?) Middle tier - Implements business logic (implements complex actions, maintains state between different steps of a workflow) - Accesses different data management systems Data management tier - One or more standard database management systems Example 1: Airline reservations - **Database System** - Airline info, available seats, customer info, etc. - **Application Server** - Logic to make reservations, cancel reservations, add new airlines, etc. - **Client Program** - Log in different users, display forms and human-readable output Example 2: Course Enrollment - **Database System** - Student info, course info, instructor info, course availability, pre-requisites, etc. - **Application Server** - Logic to add a course, drop a course, create a new course, etc. - **Client Program** - Log in different users (students, staff, faculty), display forms and human-readable output Technologies - Client Program (Web Browser) - Application Server (Tomcat, Php, Apache) - Database System (DB2) - HTML - Javascript - CSS - JSP - Servlets - CGI - SQL - XML - Stored Procedures Advantages of the Three-Tier Architecture - **Heterogeneous systems** - Tiers can be independently maintained, modified, and replaced - **Thin-”ish” clients** - Clients only need enough computation power for the presentation layer and simple application logic (e.g. form checking) (web browsers) - **Integrated data access** - Several database systems can be handled transparently at the middle tier - Central management of connections - **Scalability** - Replication at middle tier permits scalability of business logic - **Software development** - Code for business logic is centralized - Interaction between tiers through well-defined APIs: Can reuse standard components at each tier
{"Source-Url": "http://www.csbio.unc.edu/mcmillan/Media/Comp521F14Lecture10.pdf", "len_cl100k_base": 4719, "olmocr-version": "0.1.51", "pdf-total-pages": 52, "total-fallback-pages": 0, "total-input-tokens": 81360, "total-output-tokens": 6827, "length": "2e12", "weborganizer": {"__label__adult": 0.0002598762512207031, "__label__art_design": 0.0003376007080078125, "__label__crime_law": 0.00029730796813964844, "__label__education_jobs": 0.004459381103515625, "__label__entertainment": 7.659196853637695e-05, "__label__fashion_beauty": 0.00011861324310302734, "__label__finance_business": 0.00030040740966796875, "__label__food_dining": 0.0003056526184082031, "__label__games": 0.00028896331787109375, "__label__hardware": 0.0008759498596191406, "__label__health": 0.0003409385681152344, "__label__history": 0.0002636909484863281, "__label__home_hobbies": 7.277727127075195e-05, "__label__industrial": 0.0003337860107421875, "__label__literature": 0.00031447410583496094, "__label__politics": 0.00014674663543701172, "__label__religion": 0.0003616809844970703, "__label__science_tech": 0.0196380615234375, "__label__social_life": 0.00010478496551513672, "__label__software": 0.0279693603515625, "__label__software_dev": 0.9423828125, "__label__sports_fitness": 0.00013840198516845703, "__label__transportation": 0.0003437995910644531, "__label__travel": 0.00019419193267822263}, "weborganizer_max": "__label__software_dev", "avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_ratio": [[0, 17819, 0.00961]], "fineweb_edu_fasttext_gt2__fineweb_edu_fasttext_gt2__score": [[0, 17819, 0.64137]], "ft_lang_id_en_doc_v2__ft_lang_id_en_doc_v2__en": [[0, 17819, 0.71041]], "google_gemma-3-12b-it_contains_pii": [[0, 60, false], [60, 406, null], [406, 692, null], [692, 1101, null], [1101, 1490, null], [1490, 1857, null], [1857, 2118, null], [2118, 2566, null], [2566, 2751, null], [2751, 2926, null], [2926, 3511, null], [3511, 3903, null], [3903, 4056, null], [4056, 4143, null], [4143, 4322, null], [4322, 4401, null], [4401, 4772, null], [4772, 4892, null], [4892, 5467, null], [5467, 5785, null], [5785, 6155, null], [6155, 6397, null], [6397, 6872, null], [6872, 7229, null], [7229, 7564, null], [7564, 8277, null], [8277, 8423, null], [8423, 9264, null], [9264, 9659, null], [9659, 9771, null], [9771, 10182, null], [10182, 10237, null], [10237, 10524, null], [10524, 10771, null], [10771, 11544, null], [11544, 11902, null], [11902, 12246, null], [12246, 12639, null], [12639, 13087, null], [13087, 13590, null], [13590, 13981, null], [13981, 14274, null], [14274, 14615, null], [14615, 14942, null], [14942, 15279, null], [15279, 15719, null], [15719, 15871, null], [15871, 16265, null], [16265, 16567, null], [16567, 16920, null], [16920, 17114, null], [17114, 17819, null]], "google_gemma-3-12b-it_is_public_document": [[0, 60, true], [60, 406, null], [406, 692, null], [692, 1101, null], [1101, 1490, null], [1490, 1857, null], [1857, 2118, null], [2118, 2566, null], [2566, 2751, null], [2751, 2926, null], [2926, 3511, null], [3511, 3903, null], [3903, 4056, null], [4056, 4143, null], [4143, 4322, null], [4322, 4401, null], [4401, 4772, null], [4772, 4892, null], [4892, 5467, null], [5467, 5785, null], [5785, 6155, null], [6155, 6397, null], [6397, 6872, null], [6872, 7229, null], [7229, 7564, null], [7564, 8277, null], [8277, 8423, null], [8423, 9264, null], [9264, 9659, null], [9659, 9771, null], [9771, 10182, null], [10182, 10237, null], [10237, 10524, null], [10524, 10771, null], [10771, 11544, null], [11544, 11902, null], [11902, 12246, null], [12246, 12639, null], [12639, 13087, null], [13087, 13590, null], [13590, 13981, null], [13981, 14274, null], [14274, 14615, null], [14615, 14942, null], [14942, 15279, null], [15279, 15719, null], [15719, 15871, null], [15871, 16265, null], [16265, 16567, null], [16567, 16920, null], [16920, 17114, null], [17114, 17819, null]], "google_gemma-3-4b-it_v2tag__is_academic_paper": [[0, 5000, false], [5000, 17819, null]], "google_gemma-3-4b-it_v2tag__is_class_syllabus": [[0, 5000, false], [5000, 17819, null]], "google_gemma-3-4b-it_v2tag__is_completion_certificate": [[0, 5000, false], [5000, 17819, null]], "google_gemma-3-4b-it_v2tag__is_court_notice": [[0, 5000, false], [5000, 17819, null]], "google_gemma-3-4b-it_v2tag__is_homework_assignment": [[0, 5000, false], [5000, 17819, null]], "google_gemma-3-4b-it_v2tag__is_news_article": [[0, 5000, false], [5000, 17819, null]], "google_gemma-3-4b-it_v2tag__is_public_order": [[0, 5000, false], [5000, 17819, null]], "google_gemma-3-4b-it_v2tag__is_resume_cv": [[0, 5000, false], [5000, 17819, null]], "google_gemma-3-4b-it_v2tag__is_test_or_quiz": [[0, 5000, false], [5000, 17819, null]], "google_gemma-3-4b-it_v2tag__is_textbook": [[0, 5000, false], [5000, 17819, null]], "pdf_page_numbers": [[0, 60, 1], [60, 406, 2], [406, 692, 3], [692, 1101, 4], [1101, 1490, 5], [1490, 1857, 6], [1857, 2118, 7], [2118, 2566, 8], [2566, 2751, 9], [2751, 2926, 10], [2926, 3511, 11], [3511, 3903, 12], [3903, 4056, 13], [4056, 4143, 14], [4143, 4322, 15], [4322, 4401, 16], [4401, 4772, 17], [4772, 4892, 18], [4892, 5467, 19], [5467, 5785, 20], [5785, 6155, 21], [6155, 6397, 22], [6397, 6872, 23], [6872, 7229, 24], [7229, 7564, 25], [7564, 8277, 26], [8277, 8423, 27], [8423, 9264, 28], [9264, 9659, 29], [9659, 9771, 30], [9771, 10182, 31], [10182, 10237, 32], [10237, 10524, 33], [10524, 10771, 34], [10771, 11544, 35], [11544, 11902, 36], [11902, 12246, 37], [12246, 12639, 38], [12639, 13087, 39], [13087, 13590, 40], [13590, 13981, 41], [13981, 14274, 42], [14274, 14615, 43], [14615, 14942, 44], [14942, 15279, 45], [15279, 15719, 46], [15719, 15871, 47], [15871, 16265, 48], [16265, 16567, 49], [16567, 16920, 50], [16920, 17114, 51], [17114, 17819, 52]], "pipe_delimited_lines_v1__pipe_delimited_lines_v1__pipe_delimited_lines_ratio": [[0, 17819, 0.0189]]}
olmocr_science_pdfs
2024-12-03
2024-12-03
55950a10ed55b1ccb4311f18b8134e37721f8289
Creating disaggregated network services with eBPF: the Kubernetes network provider use case Original Availability: This version is available at: 11583/2970898 since: 2022-09-05T13:01:36Z Publisher: Institute of Electrical and Electronics Engineers Inc. Published DOI:10.1109/NetSoft54395.2022.9844062 Terms of use: This article is made available under terms and conditions as specified in the corresponding bibliographic description in the repository Publisher copyright IEEE postprint/Author's Accepted Manuscript ©2022 IEEE. Personal use of this material is permitted. Permission from IEEE must be obtained for all other uses, in any current or future media, including reprinting/republishing this material for advertising or promotional purposes, creating new collecting works, for resale or lists, or reuse of any copyrighted component of this work in other works. (Article begins on next page) Creating Disaggregated Network Services with eBPF: the Kubernetes Network Provider Use Case Federico Parola, Leonardo Di Giovanna, Giuseppe Ognibene, Fulvio Risso Dept. of Control and Computer Engineering, Politecnico di Torino 24, Corso Duca degli Abruzzi, Torino, 10129, Italy Email: {federico.parola, leonardo.digiovanna, giuseppe.ognibene, fulvio.risso}@polito.it Abstract—The eBPF technology enables the creation of custom and highly efficient network services, running in the Linux kernel, tailored to the precise use case under consideration. However, the most prominent examples of such network services in eBPF follow a monolithic approach, in which all required code is created within the same program block. This makes the code hard to maintain, to extend, and difficult to reuse in other use cases. This paper leverages the Polycube framework to demonstrate that a disaggregated approach is feasible also with eBPF, with minimal overhead, introducing a larger degree of code reusability. This paper considers a complex network scenario, such as a complete network provider for Kubernetes, presenting the resulting architecture and a preliminary performance evaluation. I. INTRODUCTION The extended Berkeley Packet Filter (eBPF) allows executing arbitrary code in different kernel hooks, which are triggered upon multiple events, such as a syscall or a packet received. This enables to extend the processing done by the kernel without changing its source code or loading kernel modules. eBPF code is sandboxed in order to guarantee that a user provided program can not compromise the functioning of the kernel. Several projects leverage eBPF to bring new functionality to the kernel in the fields of security, monitoring and networking. However, most of the networking-related projects implement new features as monolithic eBPF programs, making the code hard to maintain, to extend, and difficult to reuse in other use cases. In this respect, the Polycube software framework [1] addresses some of the well-known eBPF limitations when creating complex virtual network functions [2], and introduces the capability to split eBPF software in multiple, independent network functions, which can be arbitrarily connected in order to create a more complex service graph. This enables the creation of complex networking services by compositing elementary basic blocks (e.g., bridge, router, firewall, NAT, load balancer, and more), with an high degree of reusability. Container networking is a perfect example of such scenario, and has gained key importance with the diffusion of the microservices architecture and the decomposition of applications in a collection of small, loosely-coupled services running in containers. Container orchestrators such as Kubernetes (K8s) must provide a flexible and efficient network infrastructure, since containers can be created and destroyed at high frequency, must exchange a lot of data and must be easily accessible from the Internet. However, K8s defines only a functional networking model and it relies on 3rd party plugins for the actual implementation of network services. This paper shows how a K8s network provider can be created using solely eBPF primitives according to the disaggregated services model, i.e., defining a modular architecture based on traditional network components such as routers, load balancers and NATs, and without giving up on performance. This paper is structured as follows. Section II provides an overview of the K8s networking model and how Polycube achieves service disaggregation. Section III describes the overall node architecture of our solution while Section IV shows a preliminary performance comparison compared to existing solutions. Finally, Section V describes the relevant related work and Section VI draws our conclusions, highlighting the potential future work. II. BACKGROUND A. Kubernetes networking Kubernetes is an open-source orchestrator for containerized applications and defines a functional network architecture organized in three levels. (i) Pods, the basic scheduling concept, execute containerized applications that are connected to a default virtual network, whose outreach is limited to a single server (node, in the Kubernetes terminology). Pods are ephemeral entities that can be destroyed and re-spawned if needed, even on another node. Each server can host a maximum number of pods, usually organized in a contiguous and private address space (e.g., consecutive /24 networks on different nodes). (ii) Physical nodes, which inherit their addressing space from the physical datacenter network; for scalability reasons, this usually includes switched and routed portions. (iii) Services, a higher-level concept that enables the reachability of one or more (homogeneous) pods by means of the same network identifier (e.g., IP address). This primitive guarantees the decoupling between the service IP endpoint, which remains stable, from the actual pod(s) that provides the service, whose IP can change (e.g., in case the pod is restarted in another location) or it may be present in multiple replicas (hence, multiple IPs could be used). Services leverage a third addressing space, disjoint from pod and datacenter addresses. Kubernetes foresees three types of services. A ClusterIP identifies a service that is reachable only from pods within the cluster, or by an application that runs on the cluster. nodes. A **NodePort** service, instead, is reachable from outside the datacenter: a TCP/UDP port `<nport>` is allocated to the service itself, and all packets directed to any `<node_ip_address:nport>` will be redirected to one of the pods associated to the given service. NodePorts are not widely used because they require (i) nodes with reachable (e.g., public) IP addresses; (ii) external users to know the IP addresses of the nodes and (even worse) (iii) the port that has been allocated. Finally, a **LoadBalancer** service allocates a public IP address associated to the given service, which is achieved by interacting with an external entity in charge of the above public addresses; all packets directed to the LoadBalancer IP address will be delivered to one of the corresponding pods. Basic connectivity between pods is provided through the cooperation of datanetwording and plugins implementing the CNI (Container Network Interface) [3], a specification that enables changeable modules that configure network interfaces in Linux containers. The CNI specification is very simple, dealing only with network connectivity of containers and removing allocated resources when the container is deleted. Instead, packets to services are by default handled by a dedicated Kubernetes component, **kube-proxy**, which configures **iptables** with the proper rules to translate **service** IP addresses into pod IP addresses, and to implement load-balancing policies. Most of the so-called CNI providers (e.g., Cilium, Calico, Flannel, etc) implement more than just the base CNI specification and include (i) data-center wide networking (either using an overlay model, e.g., through vxlan interfaces, or direct routing, hence interacting with the datacenter physical infrastructure to push the proper routes that satisfy K8s reachability rules) and (ii) IP address management (IPAM module). Instead, most of the CNI providers rely on **kube-proxy** for services: a packet coming from a pod and directed to a service is delivered by the CNI to kube-proxy, which operates the proper transformation on IP addresses and ports and returns it again to the network plug-in, which takes care of delivering it to the target pod, possibly traversing the datacenter network. K8s adopts a functional model for networking, defining a set of behavioral rules for network connectivity but without specifying how those must be implemented by the specific network provider. In addition to rules already mentioned for services, it adds the following ones for basic connectivity: (i) all pods can communicate with all other pods without NAT; (ii) agents on a node can communicate with all pods on that node; (iii) pods in the host network of a node can communicate with all pods on all nodes without NAT. It turns out that network providers have full freedom to choose their own implementation strategy, hence privileging e.g., the easiness of use, performance, scalability, and more. However, this freedom is widely recognized as a nightmare, being very difficult to understand how each network provider works under the hood, hence severely impairing the capability of a network engineer to debug a problem. This is exacerbated by the complexity of the Kubernetes networking, which overall includes functions such as bridging and routing (for pod-to-pod connectivity), load balancing and NAT (for pod-to-service and Internet-to-service), and masquerading NAT (for pod-to-Internet), not to mention the necessity of security policies (hence, firewalls) to protect both pod-to-everything and external-to-everything communications. Finally, all the above networking components must be integrated with a control plane, which interact with K8s and detect any change in the status of the cluster (e.g., a node/pod/service is added/removed, a service is scaled up/down, etc.), hence propagating the required configurations in all involved components (e.g., adding a new node requires configuring a new route toward that node in the routing table of all existing nodes). Given this complexity, it becomes evident that the capability to rely on well-known (disaggregated) functions (e.g., bridging, routing, load balances), each one running with their configurations and state, would greatly simplify day-by-day monitoring and debugging operations compared to network providers created according to the monolithic model. ### B. Service disaggregation with Polycube Polycube [1] is an open-source software framework based on eBPF that enables the creation of arbitrary network function chains, adopting the same model (boxes connected through wires) currently used in the physical world. Polycube network functions, called cubes, are composed by an eBPF-based data plane running in kernel (actually one or more eBPF programs) and a control/management plane running in user space. A user space daemon (`polycubed`) provides a centralized point of control, allowing to access the configuration and state of cubes through a RESTful API. Cubes can be seamlessly connected to each other or to network interfaces through virtual ports, an abstraction that is implemented through an eBPF wrapping program that performs some pre- and post-processing in order to receive/send packets from the previous/to the next component in the chain. To implement this redirection mechanism, each port is identified by a unique ID inside the cube, and each cube maintains a forward chain map containing information about the peer associated to each port. This information is used by the post-processor to apply the correct action to forward the packet, that could be either a tail call to the eBPF data plane of the next cube or a `bpf_redirect()` to a destination interface. Figure 1 shows an example of this mechanism for a simple topology composed of one router and one bridge. Chaining capabilities of Polycube represent a suitable way to create disaggregated services; however, this solution has never been validated in a complex scenario such as K8s networking. ### III. Architecture Our proposed architecture targets the entire K8s networking, including also services and, potentially, network policies, hence replacing also **kube-proxy**, i.e., the component that provides cluster-wide service-to-pod translation and load balancing. Our network provider supports ClusterIP and NodePort services and relies on a VxLAN overlay network to support inter-node communication. The current version of the prototype does not support security policies but, thanks to the modular approach, this and other functionalities can easily be added without any change in the other components. The architecture (shown in Fig. 2) leverages four Polycube-based independent network services, while it relies on the kernel to handle the lifecycle of VxLAN tunnels. A. Main components **K8s vs Linux Stack Discriminator and NAT (DISC-NAT).** This service performs source NATting for the pod-to-Internet traffic, replacing the address of the pod with the address of the node. For incoming packets, it distinguishes among traffic directed to the host (either directly or because it needs VxLAN processing) and traffic directed to pods (an external host trying to contact a NodePort service or the return traffic of a pod). This is done by checking that the packet (i) does not belong to a NATted session (i.e., a lookup in the NAT session table of the service), and (ii) that is not directed to a NodePort service (i.e., a check against the TCP/UDP destination port of the packet). In case both lookups fail, the packet is sent to the Linux network stack. Vice versa, in the first case we apply the reverse NAT rule and the packet continues its journey towards the pods. In the second case, different actions can be applied according to the ExternalTrafficPolicy of the rule. If the policy is local, the traffic is allowed to reach only backend pods located on the current node, hence the packet can proceed towards the pod without modifications. In case the policy is cluster, the packet can also reach backend pods located on other nodes. Since later in the chain the packet will be processed by a load balancer and we must guarantee that the return packet will transit through the same load balancer, we apply source NAT replacing the source IP address with the address of a fictitious pod belonging to the PodCIDR of the current node (currently the first address of the range is used). **External Load Balancer (ELB).** This element maps new sessions coming from the Internet and directed to a NodePort service to a corresponding backend based on the 5-tuple of the first packet. This load balancing decision is stored in a session table, implemented as a Least Recently Used (LRU) eBPF map, and reused for all subsequent packets. Old sessions are automatically purged by the LRU map. Incoming packets are updated with destination/port of the backend, while source fields are restored to service values for outgoing traffic. **Router.** Since K8s requires that (i) all the pods in the cluster can communicate with all pods without NAT and (ii) different network addresses (PodCIDR) are allocated to pods on each node, a routing component is required. To facilitate the operations of the Internal Load Balancer (see later), we do not use a bridge between pods, hence forcing all pod traffic to be always delivered to the router. In fact, our network plugin assigns a /32 network to each pod and adds an ARP static entry for the gateway; hence all the packets are sent directly to the gateway, with pods never issuing any ARP request. The router is configured with four ports: (1) towards the physical interface of the node; (2) towards local pods, configured with the proper PodCIDR (e.g., /24); (3) to enable the reachability of K8s processes and pods running in the host network (e.g., kubelet); (4) connected to a kernel VxLAN interface, which is used for inter-node pod-to-pod communication. **Internal Load Balancer (ILB).** This load balancer operates on traffic coming from local pods and directed to ClusterIP services; all the other traffic is forwarded as is. This module has two types of ports; ‘edge’ ports are connected to entities that generate new sessions (hence, pods), while the ‘server’ port is the one used to reach the final servers, hence is connected to the router. Edge ports are configured with the IP address of the pod in order to be able to forward packets coming from the router to the correct destination. The load balancing logic is the same of the ELB, with a service-specific InternalTrafficPolicy attribute determining which backends (local or cluster-wide) are configured in the load balancer. **K8s Control Logic.** A K8s operator is in charge of reacting to the cluster events and reconfigure the required network parameters in the controlled cluster. The operator has to react to events related to the following three Kubernetes resources. (1) *Nodes:* when a node joins/leaves the cluster, a route is added/removed in the *Router* to update the reachability of the given PodCIDR through the VxLAN overlay network, and the node address is added to the VxLAN configuration. (2) Services: the operator watches events regarding ClusterIP and NodePort services. ClusterIP services trigger an update of the ILB, while a NodePort triggers an update of the ELB and DISC-NAT module for the obvious reasons, as well as the ILB because of the creation of the ClusterIP address that is associated with the NodePort service. (3) Endpoints: the operator watches any event that refers to Endpoints associated to Services. For each pair (address, port) extracted from the endpoints object, the corresponding service backend is updated on the proper Load Balancer: the ILB for ClusterIP services and both for NodePort services. This component is deployed as a K8s DaemonSet, which ensures it runs on any node; K8s adopts a distributed configuration, in which each node has its own agent in charge of the node network configuration. This DaemonSet runs as privileged pod, and it includes the polykube-operator container (running the actual K8s control plane) and the polykube container (running the Polycube daemon). The two communicate through the node loopback interface. B. Communication scenarios The main communication scenarios of a typical K8s cluster, as shown in Fig. 3, are implemented as follows. Pod-to-pod. The originating pod sends its packets to the ILB, which transparently forwards them to the Router. If the destination is on the same node, the traffic is sent back immediately and the ILB forwards it to the destination. If the destination pod is on another node, the router redirects the packets to the VxLAN interface, where they are encapsulated by the kernel and forwarded to the destination node. On the remote node, the DISC-NAT passes the traffic to the kernel, which decapsulates it and sends it to the router and then to destination pod. Pod-to-Internet. The traffic traverses the ILB, then the router forwards it towards the physical interface of the node, hence transparently crossing also the ELB. The NAT, instead, applies a source NATting rule, hence replacing the address of the pod with the one of the node, as well as the source port with a new available one. This allows the return traffic to reach the correct node without the necessity to advertise the PodCIDR on the external network. On the return path, the NAT checks if the packet belongs to a translated session; if so, it replaces the destination address and port of incoming packets with the ones of the original pod. Pod-to-service. The pod traffic toward a ClusterIP service is first processed by the ILB, which selects a proper backend pod and updates the destination address and port of packets. Traffic is then handled by the router in the same way as with the pod-to-pod communication. For return traffic, the ILB checks if the packet belongs to a translated session; if so, it restores the original source service address and port. Internet-to-service. When a remote host wants to contact a NodePort service, the first packet is processed by the DISC-NAT, that identifies it as targeting a NodePort service (based on the destination port). If the ExternalTrafficPolicy of the service is cluster, the DISC-NAT updates the source address of the packet with the one of the fictitious pod, to guarantee that the return packet will come to the same node. The packet is then forwarded to the ELB, which (i) selects a proper backend pod, (ii) updates the destination address and port with the ones of the backend, and (iii) forwards the packet to the router, that can handle it such as in normal pod-to-pod communications. IV. EVALUATION This section presents an assessment of the performance provided by our network provider under different circumstances, to determine whether the disaggregated approach would introduce any noticeable performance penalty. We run the tests using the iperf3 tool, configured with the default parameters; the server was always running in a pod, while the client was either in a physical machine or in another pod depending on the test. Tests were carried out on a cluster of 2 nodes, each one featuring a CPU Intel® Xeon® CPU E3-1245v5@3.50GHz (4 cores plus HyperThreading), 64GB RAM, and a dualport 40 GbE Ethernet XL710 QSFP+ card, all running Linux kernel v5.4.0 and K8s v1.23.5. Tests involve other two eBPF-based solutions (namely, Cilium and Calico) and a widely used ‘traditional’ approach such as Flannel [4]. All providers were deployed using the VxLAN overlay model; Cilium and Calico were configured with their eBPF kubeproxy replacement, hence enabling a complete eBPF data plane such as in our solution. We considered the following communication scenarios: pod-to-pod: a pod client connects to the actual IP address of a pod server, showing the performance of the base networking without load balancing; pod-to-service: a pod client connects to a pod server using its ClusterIP service, to evaluate the performance of the load balancer as well as the L3 routing; internet-to-service: the client is executed in an external host and the pod server is accessed through its NodePort service. Tests were performed with pods running both on a single node and on multiple nodes, with the latter adding the overhead of the VxLAN encapsulation and the limitation of the physical network (link speed, PCI bus) and requiring to cross the physical network twice (i) client to receiving node; (ii) receiving... node to backend node) for the internet-to-service tests. Results are depicted in Fig. 4, with the red dashed lines representing the baseline achieved running bare metal iperf3 on localhost (in case of single node) or between two nodes. As expected, the throughput decreases when the traffic traverses a larger number of network components. However, despite the disaggregated architecture, our solution provides always better performance compared to other solutions, with even higher margins when considering multiple nodes. While this result may be impacted by other providers supporting more features than our PoC code, such as network policies, these have not been used in the tests, hence providing the ground for a fair comparison. Overall, this suggests how disaggregation does not introduce performance penalties compared to a traditional monolithic approach. Figure 5 shows the reaction time of our operator and CNI plugin when requiring to scale up/down the pods of a service, compared with time required by other Kubernetes components until connectivity to the target pod is available/disabled. Results show that the time taken by our components is negligible compared to the overall time required by K8s to react. V. RELATED WORK Among the many eBPF-based network services, we cite here only the ones that are most representative in this space. Katran [5] represents a software solution to offer scalable network load balancing to layer 4 that leverages eBPF/XDP to provide fast packet processing. While being very sophisticated, it has been engineered to be the sole (monolithic) network function active on the network path, hence preventing the deployment of other functions operating on the same traffic. Cilium [6] provides networking, security and observability for cloud-native environments such as Kubernetes clusters. Cilium is based on eBPF, which allows for the dynamic insertion of powerful network security, visibility and control logic into the Linux kernel. In Cilium, eBPF is used to provide high-performance networking, multi-cluster and multi-cloud capabilities, advanced load balancing, transparent encryption, extended network security features, and much more. While providing observability primitives through its Hubble module, its internals are rather complex and made with a monolithic approach. Cilium defines a set of six logical objects (Prefilter, Endpoint Policy, Service, etc.), based on six different features offered by the provider (DoS mitigation, network policies, load balancing, etc.). However, these objects are not mapped into clearly separated modules, neither for the data plane (their logic is scattered among different intertwined eBPF programs), nor from a topological point of view (cannot track the path of a packet or capture the traffic flowing from one object to another), nor from a control plane perspective (cannot configure and inspect these objects independently). Similar characteristics can be found in Calico [7], which recently adopted the eBPF/XDP technology as well. VI. CONCLUSIONS We presented a network provider for Kubernetes based on disaggregated eBPF services, which improves monitoring and debugging as well as how code can be maintained, extended and reused. Our open-source solution\(^2\) demonstrates the feasibility of the disaggregated approach in eBPF and our preliminary evaluation shows no particular overhead introduced by our model with respect to another state-of-the-art monolithic solution. As a future work we plan to introduce support for (i) direct routing and (ii) network policies. ACKNOWLEDGMENT Authors thank Hamza Rhaouati for his initial work on this topic, all the people who contributed to the Polycube project, and Roberto Procopio and Yunsong Lu for their support. Finally, Federico Parola acknowledges the support from TIM S.p.A. through the PhD scholarship. REFERENCES
{"Source-Url": "https://iris.polito.it/retrieve/handle/11583/2970898/601417", "len_cl100k_base": 5505, "olmocr-version": "0.1.53", "pdf-total-pages": 6, "total-fallback-pages": 0, "total-input-tokens": 18905, "total-output-tokens": 6319, "length": "2e12", "weborganizer": {"__label__adult": 0.00038361549377441406, "__label__art_design": 0.0003933906555175781, "__label__crime_law": 0.0003528594970703125, "__label__education_jobs": 0.00045871734619140625, "__label__entertainment": 0.00015223026275634766, "__label__fashion_beauty": 0.00017142295837402344, "__label__finance_business": 0.00043487548828125, "__label__food_dining": 0.00038552284240722656, "__label__games": 0.0005817413330078125, "__label__hardware": 0.005523681640625, "__label__health": 0.0005993843078613281, "__label__history": 0.00041103363037109375, "__label__home_hobbies": 0.00011789798736572266, "__label__industrial": 0.0008869171142578125, "__label__literature": 0.00023651123046875, "__label__politics": 0.0002932548522949219, "__label__religion": 0.0005407333374023438, "__label__science_tech": 0.2763671875, "__label__social_life": 0.00012069940567016602, "__label__software": 0.036407470703125, "__label__software_dev": 0.67333984375, "__label__sports_fitness": 0.0003688335418701172, "__label__transportation": 0.0010442733764648438, "__label__travel": 0.00030612945556640625}, "weborganizer_max": "__label__software_dev", "avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_ratio": [[0, 28082, 0.02296]], "fineweb_edu_fasttext_gt2__fineweb_edu_fasttext_gt2__score": [[0, 28082, 0.33709]], "ft_lang_id_en_doc_v2__ft_lang_id_en_doc_v2__en": [[0, 28082, 0.91292]], "google_gemma-3-12b-it_contains_pii": [[0, 1289, false], [1289, 6709, null], [6709, 13060, null], [13060, 17867, null], [17867, 23227, null], [23227, 28082, null]], "google_gemma-3-12b-it_is_public_document": [[0, 1289, true], [1289, 6709, null], [6709, 13060, null], [13060, 17867, null], [17867, 23227, null], [23227, 28082, null]], "google_gemma-3-4b-it_v2tag__is_academic_paper": [[0, 5000, true], [5000, 28082, null]], "google_gemma-3-4b-it_v2tag__is_class_syllabus": [[0, 5000, false], [5000, 28082, null]], "google_gemma-3-4b-it_v2tag__is_completion_certificate": [[0, 5000, false], [5000, 28082, null]], "google_gemma-3-4b-it_v2tag__is_court_notice": [[0, 5000, false], [5000, 28082, null]], "google_gemma-3-4b-it_v2tag__is_homework_assignment": [[0, 5000, false], [5000, 28082, null]], "google_gemma-3-4b-it_v2tag__is_news_article": [[0, 5000, false], [5000, 28082, null]], "google_gemma-3-4b-it_v2tag__is_public_order": [[0, 5000, false], [5000, 28082, null]], "google_gemma-3-4b-it_v2tag__is_resume_cv": [[0, 5000, false], [5000, 28082, null]], "google_gemma-3-4b-it_v2tag__is_test_or_quiz": [[0, 5000, false], [5000, 28082, null]], "google_gemma-3-4b-it_v2tag__is_textbook": [[0, 5000, false], [5000, 28082, null]], "pdf_page_numbers": [[0, 1289, 1], [1289, 6709, 2], [6709, 13060, 3], [13060, 17867, 4], [17867, 23227, 5], [23227, 28082, 6]], "pipe_delimited_lines_v1__pipe_delimited_lines_v1__pipe_delimited_lines_ratio": [[0, 28082, 0.0]]}
olmocr_science_pdfs
2024-12-06
2024-12-06
141631614d8926c6ece5a86ba155546abff27d4c
Question Answering on SQuAD 2.0 Mayukh Majumdar Stanford University California, CA 94305. maymaj@stanford.edu Abstract In this paper, we look at enhancing the results obtained by a baseline model for reading comprehension style question answering on the Stanford Question Answering Dataset (SQuAD 2.0). The baseline model is based on Bi-Directional Attention Flow (BiDAF). In order to improve on the baseline model provided, we first try to change the Bi-Directional LSTM (bi-LSTM) at the heart of the model with a Gated Recurrent Network (GRU) and look for performance improvements. To get further improvements, we attempt to study the effects of changing some hyper-parameters such as learning rate and the drop probability. We find that the GRU performs better than the bi-LSTM in all the metrics. The reduction in learning rate seems to only increase the time taken, but the increase in the drop probability has the effect of cratering the performance as well as disrupting the updates in a non-smooth manner. 1 Introduction As our human interactions with machines increase on a daily basis, one of the most important issues to resolve has been the area of Machine Comprehension and Question Answering. With the progress in Natural Language Processing (NLP) and deep learning, it has now become even more possible to achieve promising results on a variety of tasks in the text and image domains. Recurrent Neural Networks (RNNs) were an architecture that handled variable length input sequences by using a recurrent, shared hidden state. Yet, even though they have been around for much longer, RNNs suffered from the problem of vanishing and exploding gradients. This problem was resolved by moving to LSTMs (as well as bidirectional LSTMs) which used bounded non-linearities to reduce the issue of vanishing and exploding gradients. Since then Gated Recurrent Networks have also been found which reduce the computation cost of LSTMs while keeping almost the same features. That is why this became the starting investigation point when we were looking for options to increase the performance of the baseline BiDAF based model provided. 2 Related Work Availability of large datasets has been one of the pillars for the fast advancement and quick iteration in the fields of Machine Comprehension models. One of these datasets, the Stanford Question Answering DataSet (SQuAD) is considered the gold standard in machine comprehension experiments. This dataset was enhanced by adding 50000 unanswerable questions in addition to the exclusively answerable questions available before. This new dataset is called SQuAD 2.0. To do well on this dataset, systems must not only answer questions when possible, but also determine when no answer is supported by the paragraph and abstain from answering. To provide Question Answering results from this dataset, there have been several models proposed. One of them has been [3] which uses a Bi-Directional Attention Flow (BiDAF) model. the BiDAF includes character-level, word-level and contextual embeddings and uses the attention flow in both directions to get a query-aware context representation. Other folks using the attention mechanism have been [6], which dynamically updates the attention weights given the query and context as well as the previous attention, as well as [7] who reverse the direction of the attention for SQuAD - attending on the query words as the context RNN progresses. Given the aim of the exercise was to find ways to improve the performance of the baseline model, I started investigating other networks that could be used similar to the bidirectional LSTM at the heart of the baseline model. [8] and [9] provided me some basic background in the similarities as well as differences between LSTMs and GRUs, which provided me the hunch to use GRUs instead of the bi-LSTM. Reading through [10], [11], [12] gave some more ideas on how to investigate the hyper-parameters and focusing on learning rate and drop probability in particular. 3 Approach The baseline model provided is built on Bi-Directional Attention Flow, as described in [3]. One can read the reference paper for details but the broad layers of the baseline model are: Embedding Layer: which converts the input word indices into word embedding for both the question and the context. Encoder Layer: Uses a bi-Directional LSTM to cover the temporal dependencies between timesteps of the embedding layers outputs. Attention Layer: The core layer that makes sure that the attention flows both ways - from Context-to-Question and Question-to-Context. Modelling Encoder Layer: This uses a 2-Layer LSTM to take in the temporal information between the context representations given the background of the questions. This happens as this appears after the attention layer were the cross-conditioning between questions and context has already taken place. Output Layer: This provides a vector of probabilities for each position in the context. This is achieved by using a softmax function. The loss function is the cross-entropy loss for the start and end locations. Additionally, the losses are average across the batch and the Adadelta optimizer is used to minimize the loss. Since the goal of the experiments was to find changes which would provide a performance improvement, I focused on the Encoder layer which has the bi-directional LSTM. As indicated before, given that the GRU is a close replacement for LSTMs with a better computational profile, I decided to perform the experiments by replacing the bi-LSTM with a GRU. The replacement worked fairly well as even the arguments to the model are also similar between GRU and LSTMs. After that, the aim was to investigate the how things would change due to the tweaks to hyper-parameters. As indicated in the above section, I focused on changing two of the hyper-parameters: learning rate and drop probability. The learning rate only affected the Adadelta optimizer, but the drop probability change was more widespread as every layer of the model used the drop probability. 4 Experiments The baseline model and all the other models were run on the same VM with 6 GPUs(NV6) on the Microsoft Azure platform - so as to keep equality in terms of hardware infrastructure for comparison - and the results are discussed in the following section. 4.1 Data The SQuAD dataset contains context, question, answer triplets. Each context is a paragraph, passage or document - which is excerpted from Wikipedia. The question is the question to be answered based on the given context. The answer is a set of textual words derived from the context that provide an answer to the question posed on the context. It is possible for the model to not have an answer - making a no-answer prediction. The SQuAD 2.0 dataset used with the baseline model has three splits: train, dev and test. The training dataset is used to train the model. The dev dataset is used to fine tune the model parameters. The test dataset is used to evaluate how well the model got trained. 4.2 Evaluation Method There are three metrics used for evaluating the model accuracy, two of which are provided in [1]. They are: *Exact Match FM*: This metric measures the percentage of predictions that exactly match one of the ground truth answers. *F1 score*: This metric measures the average overlap between the predicted answer and the ground truth answers. The prediction and the ground truth are considered to be bags of tokens and the F1 computed on them. The maximum F1 over all the ground truths is taken for one question and then averages over all the questions. Also, since there are at least 3 answers for each question in the set, the second answer is considered to be the human prediction and the others are considered ground truth answers. *AvNA*: This stands for Answer vs No Answer and it measures the classification accuracy of the model when only considering its answer (any span predicted) vs no-answer predictions. 4.3 Experimental Details There were 4 different experiments that were run. 1. First run was with the default configuration with the baseline model. 2. Second run was with the bi-LSTM network in the model with a GRU network. Since the GRU training ran much faster than the baseline model, we continued to tune the hyper-parameters based on the GRU settings. 3. Third run was to see the effect of reducing the learning rate from 0.2 to 0.5 on the GRU. 4. Fourth run was with the learning rate at its original value of 0.5 and then increasing the drop probability from 0.2 to 0.5 for the GRU network. The following settings provide the default model configuration that was run for the baseline model: - Size of char embedding = 64 - Size of the Glove vectors = 300 - Max number of words in a training answer = 30 - Max number of chars to keep in a word = 16 - Max number of words to keep from a question = 50 - Max number of words in a question = 100 - Max number of words in a paragraph = 1000 - Eval Steps = 50000 - Learning Rate = 0.5 - Epochs = 30 - Drop Probability = 0.2 - Maximum Gradient Norm for gradient clipping = 5.0 - Seed = 224 Decay rate for exponential moving average = 0.999 After running the above configuration on a NV6 machine in the Microsoft Azure platform, I found the time to train runs overnight for about 11 hours and 35 minutes. 4.4 Results The final results for all the runs after 30 epochs were as follows: 1. For the Baseline model run we got: Dev NLL: 03.35, F1: 59.17, EM: 55.67, AvNA: 66.48 2. For the model with the GRU replacing the bi-LSTM run, we got: Dev NLL: 03.01, F1: 60.93, EM: 57.49, AvNA: 67.79 3. For the model with the GRU and the learning rate reduced from 0.5 to 0.2, we got: Dev NLL: 03.44, F1: 58.41, EM: 54.90, AvNA: 66.11 4. For the model with the GRU and the drop probability increased from 0.2 to 0.5, we got: Dev NLL: 03.12, F1: 56.06, EM: 52.66, AvNA: 63.97 I reported the top three runs to the Test Leader Board with the following results: 1. GRU run: EM = 58.563 F1 = 62.135 2. Baseline run: EM = 57.301 F1 = 60.371 3. GRU + LR run: EM = 55.300 F1 = 58.997 The above graphics contains the overall snapshot of the Tensor board that compared all the four runs described above. The legend for the graphs are as: 1. Baseline Model with bi-LSTM: Orange Lines 2. Model with GRU replacing bi-LSTM: Green Lines 3. GRU model with Learning rate: 0.5 -> 0.2: Gray Lines 4. GRU model with Drop Probability: 0.2 -> 0.5: Blue Lines We can add some further comments based on the graphs seen above: 1. The best results on all the metrics are consistently obtained on the model with the GRU replacing the bi-LSTM (green lines). It has the lowest loss (NLL) at 2.90; the highest EM at 58.12; the highest F1 score at 61.275 and the highest AvNA score at 68.02. Moreover, since the GRU has lower computations than the bi-LSTM, we can clearly see that it ran to completion in almost a third-less number of iterations than the baseline model runs. This was reflected in the run time of the 30 epochs which took about 6 hours for GRU runs while it took about 10 - 11 hours for the baseline model runs. Another point to note is that it was only the GRU curves that seem to be monotonically increasing throughout the 30 epochs that were run, while in all other cases, we see some sort of a dip happening after reaching the maximum. All in all, in our experiments, the model with the GRU network was the clear winner in all evaluation metrics. 2. Given that the GRU model was running in such a shorter run time, I decided to pursue all the remaining runs for hyper-parameter changes using the GRU model itself. This allowed me to perform more experiments in the short amount of time available to me. Thus, the runs for the learning rate changes and the drop probability changes were run with the GRU model in place. 3. Even though the GRU curves were better than the baseline model curves in all the graphs, the difference was not very much. This was showcased by the fact that as soon as we change any of the hyper-parameter in my experiments (either by changing the learning rate or the drop probability), the baseline model did better than them in all cases as well. 4. In the case of the learning rate reduction, the results are much worse as compared to the only GRU case, but only slightly worse than the baseline model. In all these cases, we see that the reduction in the learning rate does cause the EM and F1 updates to slow down as well. This is reflected in the larger number of iterations required in this case. 5. In the case of the drop probability, we do see that increasing the drop probability just simply craters the performance of the model in all curves as well. We also see the curve not following a smooth pattern indicating the disruption caused by increasing the drop probability too high. 5 Analysis There are three main analysis statements we can make from the results seen above. 1. The first is that the GRU with good hyper-parameter values was able to perform better than the baseline model having the bi-LSTM. This was a hunch I could follow as the GRU is known to have less computation requirements than the bi-LSTM. Looking into the details of the main differences between the LSTMs and GRUs, I found that both GRUs and LSTMs have the same goal of tracking long term dependencies while mitigating the vanishing and/or exploding gradient problems so prevalent in Recurrent Neural Networks. The LSTM does this using the input, forget and output gates. Input gate regulates how much of the new cell state to keep. Forget gate regulates how much of the existing memory to forget. Output gate regulates how much of the cell state to be exposed to the next layers. On the other hand, the GRU operates using a reset gate and the update gate. Reset gate sits between previous activation and the next candidate activation to forget previous state. Update gate decides how much of the candidate activation to use in updating cell state. Both LSTMs and GRUs have the ability to keep memory/state from previous activations allowing them to remember features for a long time and allowing back-propagation to happen through multiple bounded non-linearities, which reduces the issue of vanishing gradients. That is why LSTMs and GRUs perform similarly but the reduced computation requirement of the GRUs helped them reduce the iteration time and provide better performance in this case. 2. The next one was the fact that the learning rate did not seem to effect the result by much. This is true of the Adadelta optimizer, which is derived from the Adagard optimizer, whose major feature is that the learning rate does not need to be specified. These optimizers have been very successfully been used to train GLOVE word embeddings as well. The Adadelta optimizer is used more as it reduces the tendency in Adagard optimizers to lose the learning rate as the squared gradients in their denominators keep increasing. I have to note though that even though the expectation was not to see much change due to changing the learning rate hyper-parameter, the curves of my experiment do show the slow down caused by reducing the value of the learning rate. 3. Finally, the reason the run with the drop probability increased seemed to show that not only the performance cratered but also the curves were extremely shaky. This can be explained by the fact that the higher drop probability caused higher number of updates to be dropped arbitrarily. Some of these updates were important to the learning and so the learning trends kept getting affected by these drops. These drops also were intrusive enough that the EM and F1 values were jumping all over the place rather than following a smoother curve. 6 Conclusions The main findings of the experiments that we have run is that our initial hunch was correct and the GRU network not only provided us a more efficient and faster model but provided results that indicated that it was the better network for this model working on this dataset. This points to the fact that when we are designing neural network models, we should definitely try all the different kinds of networks and experiment and see which might be the best fit for our case. The baseline model, though published in literature, was overcome with another model with a slight modification. We also found that performing a hyper-parameter search of the best possible values for the parameters is extremely important. Without proper experimentation on the dataset, we are not able to declare for sure the values that will work the best for us. Previous experience can provide us some pointers in the values to be used but experimental results are what will confirm them. Finally, we look at some of the work that can still be done and the future directions it can take. 6.1 Future Work Research work implies that we are never done and there is always more to explore and learn. In the same vein, there are several avenues that we would have liked to explore in greater detail: 1. Introduce the character-level embedding which was part of the original BIDAF model[3]. The character-level embeddings allow us to look into the internal structure of the words and be better at handling words that are not part of the vocabulary. 2. We have looked into the use of self-attention from a few different angles. In the R-Net paper[4], they introduced the idea of Self-Matching Attention after having the Gated Matching Attention between the question and the passage (similar to the baseline model Context-to-Question Attention). One of the things to study would be to see how adding such a Self-Attention Layer would help. 3. In the Lin and Bengio paper[5], the model has been made even more simple. After the bidirectional LSTM, the model introduces a fully connected layer, which is then followed by a softmax layer. This fully connected layer would provide a set of weights that would find a correlation between all the tokens of the question as the those of the context, providing some more information for the answer to be extracted from the context. The self-attention mechanism allows extracting different aspects of the sentence into multiple vectors. These multiple vectors provide a way for the self-attention to work even without extra inputs being provided. Acknowledgments I would like to acknowledge the help that all the TAs have provided throughout this course, without whom I cannot see success at the end of the course. Also, special shout-out to Sahil for providing me valuable inputs at all times and especially during the project discussions. Finally, last but not the least, are innumerable thanks to Abi for providing me the ability to catch up on the assignments and the project after I had to miss 2+ weeks due to a family emergency in India. None of this would have been possible without all this support. References
{"Source-Url": "http://web.stanford.edu/class/cs224n/reports/default/15839661.pdf", "len_cl100k_base": 4143, "olmocr-version": "0.1.50", "pdf-total-pages": 7, "total-fallback-pages": 0, "total-input-tokens": 15500, "total-output-tokens": 5224, "length": "2e12", "weborganizer": {"__label__adult": 0.000499725341796875, "__label__art_design": 0.000698089599609375, "__label__crime_law": 0.0005784034729003906, "__label__education_jobs": 0.005626678466796875, "__label__entertainment": 0.0002532005310058594, "__label__fashion_beauty": 0.00033402442932128906, "__label__finance_business": 0.0003447532653808594, "__label__food_dining": 0.0005807876586914062, "__label__games": 0.0008559226989746094, "__label__hardware": 0.0012769699096679688, "__label__health": 0.00152587890625, "__label__history": 0.00043487548828125, "__label__home_hobbies": 0.00014984607696533203, "__label__industrial": 0.0007839202880859375, "__label__literature": 0.0012063980102539062, "__label__politics": 0.0005016326904296875, "__label__religion": 0.0007610321044921875, "__label__science_tech": 0.479248046875, "__label__social_life": 0.00029277801513671875, "__label__software": 0.0176239013671875, "__label__software_dev": 0.48486328125, "__label__sports_fitness": 0.0005650520324707031, "__label__transportation": 0.000823974609375, "__label__travel": 0.0002865791320800781}, "weborganizer_max": "__label__software_dev", "avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_ratio": [[0, 20746, 0.05601]], "fineweb_edu_fasttext_gt2__fineweb_edu_fasttext_gt2__score": [[0, 20746, 0.36808]], "ft_lang_id_en_doc_v2__ft_lang_id_en_doc_v2__en": [[0, 20746, 0.94847]], "google_gemma-3-12b-it_contains_pii": [[0, 3099, false], [3099, 6781, null], [6781, 9138, null], [9138, 10480, null], [10480, 14848, null], [14848, 18903, null], [18903, 20746, null]], "google_gemma-3-12b-it_is_public_document": [[0, 3099, true], [3099, 6781, null], [6781, 9138, null], [9138, 10480, null], [10480, 14848, null], [14848, 18903, null], [18903, 20746, null]], "google_gemma-3-4b-it_v2tag__is_academic_paper": [[0, 5000, true], [5000, 20746, null]], "google_gemma-3-4b-it_v2tag__is_class_syllabus": [[0, 5000, false], [5000, 20746, null]], "google_gemma-3-4b-it_v2tag__is_completion_certificate": [[0, 5000, false], [5000, 20746, null]], "google_gemma-3-4b-it_v2tag__is_court_notice": [[0, 5000, false], [5000, 20746, null]], "google_gemma-3-4b-it_v2tag__is_homework_assignment": [[0, 5000, false], [5000, 20746, null]], "google_gemma-3-4b-it_v2tag__is_news_article": [[0, 5000, false], [5000, 20746, null]], "google_gemma-3-4b-it_v2tag__is_public_order": [[0, 5000, false], [5000, 20746, null]], "google_gemma-3-4b-it_v2tag__is_resume_cv": [[0, 5000, false], [5000, 20746, null]], "google_gemma-3-4b-it_v2tag__is_test_or_quiz": [[0, 5000, false], [5000, 20746, null]], "google_gemma-3-4b-it_v2tag__is_textbook": [[0, 5000, false], [5000, 20746, null]], "pdf_page_numbers": [[0, 3099, 1], [3099, 6781, 2], [6781, 9138, 3], [9138, 10480, 4], [10480, 14848, 5], [14848, 18903, 6], [18903, 20746, 7]], "pipe_delimited_lines_v1__pipe_delimited_lines_v1__pipe_delimited_lines_ratio": [[0, 20746, 0.0]]}
olmocr_science_pdfs
2024-12-01
2024-12-01
7f0c025abedb0148818d5588bd75eed74fd95f98
[REMOVED]
{"Source-Url": "https://osg.tuhh.de/Publications/2022/dietrich_22_safecomp.pdf", "len_cl100k_base": 6937, "olmocr-version": "0.1.50", "pdf-total-pages": 14, "total-fallback-pages": 0, "total-input-tokens": 37113, "total-output-tokens": 10322, "length": "2e12", "weborganizer": {"__label__adult": 0.0006518363952636719, "__label__art_design": 0.0007047653198242188, "__label__crime_law": 0.0006384849548339844, "__label__education_jobs": 0.00045108795166015625, "__label__entertainment": 0.000171661376953125, "__label__fashion_beauty": 0.00033283233642578125, "__label__finance_business": 0.00035953521728515625, "__label__food_dining": 0.0005812644958496094, "__label__games": 0.001445770263671875, "__label__hardware": 0.022186279296875, "__label__health": 0.0008234977722167969, "__label__history": 0.0006475448608398438, "__label__home_hobbies": 0.0002310276031494141, "__label__industrial": 0.0021190643310546875, "__label__literature": 0.00030159950256347656, "__label__politics": 0.0005593299865722656, "__label__religion": 0.0010499954223632812, "__label__science_tech": 0.3994140625, "__label__social_life": 9.298324584960938e-05, "__label__software": 0.01068115234375, "__label__software_dev": 0.55419921875, "__label__sports_fitness": 0.0005288124084472656, "__label__transportation": 0.0013895034790039062, "__label__travel": 0.00030875205993652344}, "weborganizer_max": "__label__software_dev", "avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_ratio": [[0, 40004, 0.03814]], "fineweb_edu_fasttext_gt2__fineweb_edu_fasttext_gt2__score": [[0, 40004, 0.14638]], "ft_lang_id_en_doc_v2__ft_lang_id_en_doc_v2__en": [[0, 40004, 0.85831]], "google_gemma-3-12b-it_contains_pii": [[0, 2662, false], [2662, 5125, null], [5125, 7838, null], [7838, 10069, null], [10069, 13225, null], [13225, 16762, null], [16762, 20363, null], [20363, 22302, null], [22302, 25295, null], [25295, 27437, null], [27437, 30655, null], [30655, 32584, null], [32584, 36365, null], [36365, 40004, null]], "google_gemma-3-12b-it_is_public_document": [[0, 2662, true], [2662, 5125, null], [5125, 7838, null], [7838, 10069, null], [10069, 13225, null], [13225, 16762, null], [16762, 20363, null], [20363, 22302, null], [22302, 25295, null], [25295, 27437, null], [27437, 30655, null], [30655, 32584, null], [32584, 36365, null], [36365, 40004, null]], "google_gemma-3-4b-it_v2tag__is_academic_paper": [[0, 5000, true], [5000, 40004, null]], "google_gemma-3-4b-it_v2tag__is_class_syllabus": [[0, 5000, false], [5000, 40004, null]], "google_gemma-3-4b-it_v2tag__is_completion_certificate": [[0, 5000, false], [5000, 40004, null]], "google_gemma-3-4b-it_v2tag__is_court_notice": [[0, 5000, false], [5000, 40004, null]], "google_gemma-3-4b-it_v2tag__is_homework_assignment": [[0, 5000, false], [5000, 40004, null]], "google_gemma-3-4b-it_v2tag__is_news_article": [[0, 5000, false], [5000, 40004, null]], "google_gemma-3-4b-it_v2tag__is_public_order": [[0, 5000, false], [5000, 40004, null]], "google_gemma-3-4b-it_v2tag__is_resume_cv": [[0, 5000, false], [5000, 40004, null]], "google_gemma-3-4b-it_v2tag__is_test_or_quiz": [[0, 5000, false], [5000, 40004, null]], "google_gemma-3-4b-it_v2tag__is_textbook": [[0, 5000, false], [5000, 40004, null]], "pdf_page_numbers": [[0, 2662, 1], [2662, 5125, 2], [5125, 7838, 3], [7838, 10069, 4], [10069, 13225, 5], [13225, 16762, 6], [16762, 20363, 7], [20363, 22302, 8], [22302, 25295, 9], [25295, 27437, 10], [27437, 30655, 11], [30655, 32584, 12], [32584, 36365, 13], [36365, 40004, 14]], "pipe_delimited_lines_v1__pipe_delimited_lines_v1__pipe_delimited_lines_ratio": [[0, 40004, 0.05839]]}
olmocr_science_pdfs
2024-12-01
2024-12-01
d3d412529228c821dcb16995cb08f72045ed9a39
Learning R Series Session 1: Introduction to Oracle's R Technologies and Oracle R Enterprise 1.3 Mark Hornick, Senior Manager, Development Oracle Advanced Analytics <table> <thead> <tr> <th>Session</th> <th>Title</th> </tr> </thead> <tbody> <tr> <td>Session 1</td> <td>Introduction to Oracle's R Technologies and Oracle R Enterprise 1.3</td> </tr> <tr> <td>Session 2</td> <td>Oracle R Enterprise 1.3 Transparency Layer</td> </tr> <tr> <td>Session 3</td> <td>Oracle R Enterprise 1.3 Embedded R Execution</td> </tr> <tr> <td>Session 4</td> <td>Oracle R Enterprise 1.3 Predictive Analytics</td> </tr> <tr> <td>Session 5</td> <td>Oracle R Enterprise 1.3 Integrating R Results and Images with OBIEE Dashboards</td> </tr> <tr> <td>Session 6</td> <td>Oracle R Connector for Hadoop 2.0 New features and Use Cases</td> </tr> </tbody> </table> The following is intended to outline our general product direction. It is intended for information purposes only, and may not be incorporated into any contract. It is not a commitment to deliver any material, code, or functionality, and should not be relied upon in making purchasing decisions. The development, release, and timing of any features or functionality described for Oracle’s products remain at the sole discretion of Oracle. Topics • Introduction – R – Oracle’s R Strategy – Oracle R Enterprise overview • New features in Oracle R Enterprise 1.3 • Analytics Example and Scenario • Oracle Advanced Analytics Option • Summary What is R? - R is an Open Source scripting language and environment for statistical computing and graphics - Started in 1994 as an Alternative to SAS, SPSS & Other proprietary Statistical Environments - The R environment - R is an integrated suite of software facilities for data manipulation, calculation and graphical display - Around 2 million R users worldwide - Widely taught in Universities - Many Corporate Analysts and Data Scientists know and use R - Thousands of open sources packages to enhance productivity such as: - Bioinformatics with R - Spatial Statistics with R - Financial Market Analysis with R - Linear and Non Linear Modeling CRAN Task View – Machine Learning & Statistical Learning ahaz arules BayesTree Boruta BPHO bst caret CORElearn CoxBoost Cubist e1071 (core) earth elasticnet ElemStatLearn evtree gafit GAMBoost gamboostLSS gbmv gbm (core) glmnet glmpath GMMBoost gplasso hda ipred kernlab (core) klaR lars lasso2 LiblineaR LogicForest LogicReg longRPart mboost (core) mvpart ncvreg nnet (core) oblique.tree obliqueRF pamr party partykit penalized penalizedSVM predbayescor quantregForest randomForest (core) randomSurvivalForest rattle rda rdetools REEMtree relaxo rgenoud rgp rminer ROCR rpart (core) rpartOrdinal RPMM RSNNS RWeka sda SDDA spam tgp tree TWIX varSelRF Why statisticians/data analysts use R R is a statistics language similar to Base SAS or SPSS statistics R environment is .. - Powerful - Extensible - Graphical - Extensive statistics - OOTB functionality with many ‘knobs’ but smart defaults - Ease of installation and use - **Free** http://cran.r-project.org/ Third Party Open Source IDEs, e.g., RStudio Traditional R and Database Interaction - Paradigm shift: R \(\rightarrow\) SQL \(\rightarrow\) R - R memory limitation – data size, call-by-value - R single threaded - Access latency, backup, recovery, security…? - Ad hoc script execution Oracle R Enterprise enhances open source R - Analyze and manipulate data in Oracle Database through R, transparently - Execute R scripts through the database with data and task parallelism - Use in-database Predictive Analytics algorithms seamlessly through R - Scoring R models in the database - R scripts integrated into SQL language dynamically - Integrate R into the IT software stack Oracle’s R Strategic Offerings *Deliver enterprise-level advanced analytics based on R environment* - **Oracle R Enterprise** - Transparent access to database-resident data from R - Embedded R script execution through database managed R engines with SQL language integration - Statistics engine - **Oracle R Distribution** - Free download, pre-installed on Oracle Big Data Appliance, bundled with Oracle Linux - Enterprise support for customers of Oracle R Enterprise, Big Data Appliance, and Oracle Linux - Enhanced linear algebra performance using Intel, AMD, or Solaris libraries - **ROracle** - Open source Oracle *database interface driver* for R based on OCI - Maintainer is Oracle – rebuilt from the ground up - Optimizations and bug fixes made available to open source community - **Oracle R Connector for Hadoop** - R interface to Oracle Hadoop Cluster on BDA - Access and manipulate data in HDFS, database, and file system - Write MapReduce functions using R and execute through natural R interface - Leverage several native Hadoop-based analytic techniques that are part of ORCH package ©2012 Oracle – All Rights Reserved Oracle R Distribution Ability to dynamically load - Intel Math Kernel Library (MKL) - AMD Core Math Library (ACML) - Solaris Sun Performance Library Oracle Support - Improve scalability at client and database for embedded R execution - Enhanced linear algebra performance using Intel’s MKL, AMD’s ACML, and Sun Performance Library for Solaris - Enterprise support for customers of Oracle Advanced Analytics option, Big Data Appliance, and Oracle Linux - Free download - Oracle to contribute bug fixes and enhancements to open source R Oracle R Enterprise Function push-down – data transformation & statistics No changes to the user experience Scale to large data sets Embed in operational systems Development | Production | Consumption OBIEE Dashboard Parameterized data selection and graph customization OBIEE Dashboard Leverage open source R packages ...to be explored in more detail in Session 5 on OBIEE Integration Collaborative Execution Model 1. R Engine - R-SQL Transparency Framework intercepts R functions for scalable in-database execution - Interactive display of graphical results and flow control as in standard R - Submit entire R scripts for execution by Oracle Database 2. Oracle Database - Database Compute Engine - Scale to large datasets - Leverage database SQL parallelism - Leverage in-database statistical and data mining capabilities - Post processing of results 3. R Engine(s) managed by Oracle DB - Database manages multiple R engines for database-managed parallelism - Efficient parallel data transfer to spawned R engines to emulate map-reduce style algorithms and applications - Enables “lights-out” execution of R scripts Collaborative execution with in-database R engine Analytic techniques not available in-database Target Environment with ORE - Eliminate memory constraint with client R engine - Execute R scripts at database server machine for scalability and performance - Execute R scripts in \textit{data parallel} or \textit{task parallel} with database spawned and controlled R engines - Get maximum value from your Oracle Database - Get even better performance with Exadata - Enable integration and management through SQL Oracle R Enterprise – Packages and R Engines * ORD available on Linux, AIX, Solaris, SPARC platforms aggdata <- aggregate(ONTIME_S$DEST, by = list(ONTIME_S$DEST), FUN = length) class(aggdata) head(aggdata) select DEST, count(*) from ONTIME_S group by DEST Transparency Layer Overloads graphics functions for in-database statistics ```r ontime <- ONTIME_S delay <- ontime$ARRDELAY dayofweek <- ontime$DAYOFWEEK bd <- split(delay, dayofweek) boxplot(bd, notch = TRUE, col = "red", cex = 0.5, outline = FALSE, axes = FALSE, main = "Airline Flight Delay by Day of Week", ylab = "Delay (minutes)", xlab = "Day of Week") axis(1, at=1:7, labels=c("Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday")) axis(2) ``` ...to be explored in more detail in Session 2 on Transparency Layer Embedded R Execution – R Interface Data parallel in-database execution Also includes - ore.doEval - ore.tableApply - ore.rowApply - ore.indexApply ```r modList <- ore.groupApply( X=ONTIME_S, INDEX=ONTIME_S$DEST, function(dat) { lm(ARRDELAY ~ DISTANCE + DEPDELAY, dat) }); modList_local <- ore.pull(modList) summary(modList_local$BOS) # return model for BOS ``` ...to be explored in more detail in Session 3 on Embedded R Execution Embedded R Execution – SQL Interface For model build and batch scoring begin sys.rqScriptDrop('Example2'); sys.rqScriptCreate('Example2', 'function(dat, datastore_name) { mod <- lm(ARRDELAY ~ DISTANCE + DEPDELAY, dat) ore.delete(datastore_name) ore.save(mod, name=datastore_name) }'); end; / select * from table(rqTableEval( cursor(select ARRDELAY, DISTANCE, DEPDELAY from ontime_s, cursor(select 1 "ore.connect", 'myDatastore' as "datastore_name" from dual), 'XML', 'Example2')))); begin sys.rqScriptCreate('Example3', 'function(dat, datastore_name) { ore.load(datastore_name) prd <- predict(mod, newdata=dat) prd[as.integer(rownames(prd))] <- prd res <- cbind(dat, PRED = prd) res} }'); end; / select * from table(rqTableEval( cursor(select ARRDELAY, DISTANCE, DEPDELAY from ontime_s where year = 2003 and month = 5 and dayofmonth = 2), cursor(select 1 "ore.connect", 'myDatastore' as "datastore_name" from dual), 'select ARRDELAY, DISTANCE, DEPDELAY, 1 PRED from ontime_s', 'Example3')) order by 1, 2, 3; Embedded R Execution – SQL Interface rqTableEval + datastore for model building SQL Interface SQL Developer Oracle Database User tables Datastore myDatastore (mod) rq*Apply () interface DB R Engine ORE extproc ©2012 Oracle – All Rights Reserved Statistics Engine **Example Features** - **Special Functions** - Gamma function - Natural logarithm of the Gamma function - Digamma function - Trigamma function - Error function - Complementary error function - **Tests** - Chi-square, McNemar, Bowker - Simple and weighted kappas - Cochran-Mantel-Haenzel correlation - Cramer's V - Binomial, KS, t, F, Wilcox - **Base SAS equivalents** - Freq, Summary, Sort - Rank, Corr, Univariate - **Density, Probability, and Quantile Functions** - Beta distribution - Binomial distribution - Cauchy distribution - Chi-square distribution - Exponential distribution - F-distribution - Gamma distribution - Geometric distribution - Log Normal distribution - Logistic distribution - Negative Binomial distribution - Normal distribution - Poisson distribution - Sign Rank distribution - Student's t distribution - Uniform distribution - Weibull distribution - Density Function - Probability Function - Quantile Oracle R Enterprise Main components - **Transparency Layer** - Work solely from R for data preparation, analysis, and visualization - Use database as compute engine with query optimization and parallelism - Eliminates need to manage flat file data – complexity, backup, recovery, security - Eliminates R memory constraints so you can handle bigger data - No knowledge of SQL required - **Embedded R Execution** - *Roll your own* techniques in R and execute closer to database data - Leverage CRAN open source packages - Lights-out execution for integrated operationalizing R scripts via SQL interface - Leverage user-defined, dba-controlled, and database-managed, data parallel R execution - Combine with benefits of Transparency Layer and Statistics Engine capabilities - Enables integration of structured and graph results with OBIEE dashboards and BIP documents - **Statistics Engine** - Enable standard and advanced statistics for in-database execution - Provide in-database scoring of R models New features in Oracle R Enterprise 1.3 Oracle R Enterprise 1.3 – Themes • Big Data • Time Series Analytics • Rapid Application Deployment • Certification for R version 2.15.1 Support for Big Data Analytics • Exadata storage tier scoring for R models with the new ORE package **OREpredict** • Comprehensive in-database sampling techniques • New ORE package, **OREdm**, for high performance in-database predictive algorithms from Oracle Data Mining Exadata storage tier scoring for R models • Fastest way to operationalize R-based models for scoring in Oracle Database • Go from model to SQL scoring in one step – No dependencies on PMML or any other plugins • R packages supported out-of-the-box include – glm, glm.nb, hclust, kmeans, lm, multinom, nnet, rpart • Models can be managed in-database using ORE datastore …to be explored in more detail in Session 4 on Predictive Analytics High performance in-database sampling Techniques - Simple random sampling - Split data sampling - Systematic sampling - Stratified sampling - Cluster sampling - Quota sampling - Accidental sampling ...to be explored in more detail in Session 2 on Transparency Layer Example: Bag of Little Bootstraps Approach big data analysis by first randomly partitioning a data set into subsets that can be analyzed using in-memory R algorithms and then aggregating the results from those partitions - Assign a random partition number to each observation as a derived column (a relational view) ```r x = myTable nrowX <- nrow(x) x$partition <- sample(rep(1:k, each = nrowX/k, length.out = nrowX), replace = TRUE) ``` - Generate the bootstraps in-database and efficiently pass data to R engines ```r results <- ore.groupApply(x, x$partition, function(y) {...}, parallel = TRUE) ``` - Build multiple models and aggregate results via voting or averaging The “Bagging” Concept Data for Building → Data Samples - S1 - S2 - ... Sn Build Models - S1 → M1 → P1 - S2 → M2 → P2 - ... Sn → Mn → Pn Individual Model Predictions Voting or Averaging Final Prediction Data to Score “Bagging” Execution Model Two options: client-controlled and database-controlled Client R Engine Multiple invocations of `ore.lm` to Oracle Database Client R Engine Single invocation to Oracle Database using `ore.indexApply` High performance in-database predictive techniques available through ORE packages Parallel, distributed, in-database execution - SVM - GLM - k-Means clustering - Naïve Bayes - Decision Trees - Attribute Importance - Neural Networks - Stepwise Linear Regression OREedm OREeda Example using OREdm functions Highlighting Support Vector Machine algorithm x <- seq(0.1, 5, by = 0.02) y <- log(x) + rnorm(x, sd = 0.2) dat <- ore.push(data.frame(x=x, y=y)) # Regression svm.mod <- ore.odmSVM(y~x,dat,"regression", kernel.function="linear") summary(svm.mod) coef(svm.mod) svm.res <- predict(svm.mod,dat,supplemental.cols="x") head(svm.res,6) m <- mtcars m$gear <- as.factor(m$gear) m$cyl <- as.factor(m$cyl) m$vs <- as.factor(m$vs) m$ID <- 1:nrow(m) MTCARS <- ore.push(m) # Classification svm.mod <- ore.odmSVM(gear ~ .-ID, MTCARS,"classification") summary(svm.mod) coef(svm.mod) svm.res <- predict (svm.mod, MTCARS,"gear") with(svm.res, table(gear,PREDICTION)) # generate confusion matrix # Anomaly Detection svm.mod <- ore.odmSVM(~ .-ID, MTCARS,"anomaly.detection") summary(svm.mod) svm.res <- predict (svm.mod, MTCARS, "ID") head(svm.res) table(svm.res$PREDICTION) …to be explored in more detail in Session 4 on Predictive Analytics Time Series Analysis Motivation • Time series data is widely prevalent – Stock / trading data – Sales data – Employment data • Need to understand trends, seasonable effects, residuals Time Series Analysis - Aggregation and moving window analysis of large time series data - Equivalent functionality from popular R packages for data preparation available in-database CRAN Task View: Time Series Analysis Maintainer: Rob J. Hyndman Contact: Rob@Hyndman.co.nz Version: 2012-10-07 Base R ships with a list of functionality useful for time series, as well as in the stats package. This is complemented by many packages on CRAN, which are briefly summarized below. There is also a considerable overlap between the tools for time series and those in the Econometrics and Finance task views. The packages in this view can be roughly structured into the following topics. If you think that some package is missing from the list, please let us know. Basics - Infrastructure: Base R contains substantial infrastructure for representing and analyzing time series data. The fundamental class is \texttt{ts} that can represent regular time series (using numeric time stamps). Hence, it is particularly well-suited for annual, monthly, quarterly, daily, etc. - Modeling: Methods for analyzing and modeling time series include ARIMA models in \texttt{arima}, \texttt{AR} and \texttt{VAR} models in \texttt{ar}, structural models in \texttt{StructTS}, visualization in \texttt{vars} (plotting), prediction functions in \texttt{forecast}, classical decomposition in \texttt{decomp}, STL decomposition in \texttt{stl}, moving averages and autoregressive filter functions in \texttt{filter}, and basic Holt-Winters forecasting in \texttt{HoltWinters}. Time Series Classes - As mentioned above, \texttt{ts} is the basic class for regularly spaced time series using numeric time stamps. - The \texttt{zoo} package provides infrastructure for regularly and irregularly spaced time series using arbitrary classes for the time stamps (i.e., allowing all classes from the previous sentence). It is designed to be as consistent as possible with \texttt{ts}. Coercion from and to \texttt{zoo} is available for all other classes mentioned in this section. - The package \texttt{xts} is based on \texttt{zoo} and provides uniform handling of R's different time-based data classes. - Various packages implement irregular time series based on \texttt{POSIXt} time stamps, intended especially for financial applications. These include \texttt{xts} from \texttt{xts}, \texttt{zoo}, \texttt{rugarch}, and \texttt{tsibble} from \texttt{tsibble}. - The class \texttt{tsibble} in \texttt{tsibble} (previously \texttt{xts}) implements time series with \texttt{tsibble} time stamps. - The package \texttt{dtseries} implements time series with \texttt{dt} time stamps. - The package \texttt{tsibble} contains infrastructure for setting time frames in different formats. Forecasting and Univariate Modeling - The \texttt{forecast} package provides a class and methods for univariate time series forecasts, and provides many functions implementing different forecasting models including all those in the stats package. - \texttt{Exponential smoothing} (\texttt{ets}) in \texttt{stats} provides some basic univariate models with partial optimization, \texttt{stlm} from \texttt{forecast} provides a larger set of models and facilities with full optimization. - \texttt{Auto-regressive models} (\texttt{ar}) in \texttt{stats} (with model selection), \texttt{ggARFIMA} for subset AR models, and \texttt{ar} for periodic autoregressive time series models. - \texttt{ARIMA models} (\texttt{ar}) in \texttt{stats} is the basic function for ARIMA, SARIMA, ARMAX, and subset ARIMA models. It is enhanced in the \texttt{forecast} package along with \texttt{auto.arima} for automatic order selection. \texttt{arma} in the \texttt{tseries} package provides different algorithms for ARMA and subset ARIMA models. \texttt{fitARMA} implements a fast MLE algorithm for ARMA models. Some facilities for fractional differenced ARFIMA models are provided in the \texttt{fracdiff} package. \texttt{aRMS} adds estimation, diagnostics and forecasting for ARFIMA models. \texttt{armaFit} from the \texttt{arima} package is an interface for ARIMA and ARFIMA models. Package \texttt{arma} contains functionality for generalized ARIMA time series simulation. The \texttt{mets} package handles multivariate AR(1) with seasonal processes. - \texttt{GARCH models} (\texttt{garch}) from \texttt{tseries} fits basic \texttt{GARCH} models, \texttt{rugarch} from \texttt{rugarch} implements ARIMA models with a wide class of GARCH innovations. \texttt{bbricks} estimates a Bayesian \texttt{GARCH}(1,1) model with innovations. \texttt{rugarch} implements Generalized Orthogonal GARCH (GO-GARCH) models. The \texttt{R}-Forge project \texttt{rfgarch} aims to provide a flexible and sub-GARCH modelling and testing environment including additive and multi-variate GARCH packages. Its \texttt{webarch} has extensive information and examples. - \texttt{Miscellaneous}: \texttt{tseries} contains methods for linear time series analysis. \texttt{BATS} for Bayesian analysis of dynamic linear models. \texttt{timseries} for time series analysis and control. - \texttt{Forecast} for bias-corrected forecasting and bootstrap prediction intervals for autoregressive time series. Resampling - \texttt{Bootstraping:} The \texttt{boot} package provides function \texttt{tsboot} for time series bootstrapping, including block bootstrap with several variants. \texttt{tsbootstrap} from \texttt{ts} provides fast stationary and block bootstrapping. Maximum entropy bootstrap for time series is available in \texttt{metboot}. Support for Time Series Data • Support for Oracle data types – DATE,TIMESTAMP – TIMESTAMP WITH TIME ZONE – TIMESTAMP WITH LOCAL TIME ZONE • Analytic capabilities – Date arithmetic, Aggregations & Percentiles – Moving window calculations: - ore.rollmax - ore.rollmean - ore.rollmin - ore.rollsd - ore.rollsum - ore.rollvar - ore.rollsd …to be explored in more detail in Session 2 on Transparency Layer Rapid Application Deployment *Motivation and enabling features* • Streamline and simplify application deployment – Avoid data staging, movement, and latency • Increase data security • Embed ORE into application backends and web UI infrastructures • Allow applications to integrate with ORE to leverage: – Execution of R in-database via R-to-SQL transparency layer – In-database high performance predictive techniques in concert with R algorithms – R integration into SQL language – Persistence of R objects in Oracle Database – In-database scoring using models from R algorithms Rapid Application Deployment **Benefits** - Database is the server managing instances of R in-database - Data and task parallel execution of R scripts in Oracle Database - Use cases include - Bag of Little Bootstraps - Partitioned model builds - Simulations and backtesting - Resource utilization of R instances automatically managed by Oracle Database - R models and objects stored securely in database-managed R datastore - No additional packages (like Rserve) or maintenance required Using ORE with CRAN package and visualization Data preparation using ORE, movie recommendations using \{arules\} ```r MF <- MOVIE_FACT[,c("CUST_ID","MOVIE_ID","ACTIVITY_ID")] MV <- MOVIE[,c("MOVIE_ID","TITLE")] transData <- merge(MF[MF$ACTIVITY_ID==2,], MV, by="MOVIE_ID") transData <- ore.pull(transData[,c("CUST_ID","TITLE")]) transData <- data.frame(CUST_ID=as.factor(transData$CUST_ID), TITLE=as.factor(transData$TITLE)) library(arules) trans.movie <- as(split(transData[,"TITLE"], transData[,"CUST_ID"], "transactions") assocRules <- apriori(trans.movie, parameter=list(minlen=2, maxlen=2, support=0.05, confidence=0.1)) inspect(sort(assocRules,by="support")[1:25]) plot(sort(assocRules,by="support")[1:50], method="graph", interactive=TRUE, control=list(type="items")) ``` Results R> assocRules <- apriori(trans.movie, + parameter=list(minlen=2, + maxlen=2, + support=0.05, + confidence=0.1)) parameter specification: confidence minval smax arem aval originalSupport support minlen maxlen target ext 0.1 0.1 1 none FALSE TRUE 0.05 2 2 rules FALSE algorithmic control: filter tree heap memopt load sort verbose 0.1 TRUE TRUE FALSE TRUE 2 TRUE apriori - find association rules with the apriori algorithm version 4.21 (2004.05.09) (c) 1996-2004 Christian Borgelt set item appearances ...[9 item(s)] done [0.00s]. set transactions ...[970 item(s), 4427 transaction(s)] done [0.06s]. sorting and recoding items ...[429 item(s)] done [0.00s]. creating transaction tree ... done [0.01s]. checking subsets of size 1 2 done [0.02s]. writing ...[25590 rule(s)] done [0.06s]. creating S4 object ... done [0.01s]. R> inspect(sort(assocRules,by="support")[1:25]) lhs rhs support confidence lift 1 {Candyman} {The Time Machine} 0.2256607 0.8560411 2.472981 2 {The Time Machine} {Candyman} 0.2256607 0.7494374 2.472981 3 {Memento} {The Time Machine} 0.2236277 0.8790968 2.946120 4 {The Time Machine} {Memento} 0.2236277 0.7426857 2.946120 5 {Memento} {Candyman} 0.2175288 0.8629932 3.273413 6 {Candyman} {Memento} 0.2175288 0.8251280 3.273413 7 {American Beauty} {The Time Machine} 0.2157217 0.8858990 2.942144 8 {The Time Machine} {American Beauty} 0.2157217 0.7151011 2.942144 ORE as framework for Model Building and Scoring Workflow example **Analysis** - Data Preparation (filter, transform) - Exploratory Data Analysis - Sample data and split in train and test - Build and test models in parallel with `ore.indexApply` - Select best model and save in database `‘datastore’` object - Load and test model from datastore for scoring new data **Development** - Code the build methodology in R script repository - Code the scoring methodology in R script repository - Invoke build and scoring R functions using `ore.*Apply` **Production** - Schedule build and score as nightly jobs for execution ...to be explored in more detail in Session 3 on Embedded R Execution Oracle Advanced Analytics Option Oracle Advanced Analytics Option Fastest Way to Deliver Scalable Enterprise-wide Predictive Analytics • Powerful – Combination of in-database predictive algorithms and open source R algorithms – Accessible via SQL, PL/SQL, R and database APIs – Scalable, parallel in-database execution of R language • Easy to Use – Range of GUI and IDE options for business users to data scientists • Enterprise-wide – Integrated feature of the Oracle Database available via SQL • R is integrated into SQL – Seamless support for enterprise analytical applications and BI environments Oracle Advanced Analytics Value Proposition Value Proposition - Fastest path from data to insights - Fastest analytical development - Fastest in-database scoring engine on the planet - Flexible deployment options for analytics - Lowest TCO by eliminating data duplication - Secure, Scalable and Manageable Data remains in the Database - Automated data preparation for select analytics - Scalable distributed-parallel implementation of machine learning techniques in-database - Scalable R leveraging database computational engine Flexible interface options – R, SQL, IDE, GUI - Fastest and most Flexible analytic deployment options - Can import 3rd party models Oracle Advanced Analytics Traditional Analytics Data Import Model “Scoring” Data Preparation and Transformation Model Building Data Preparation and Transformation Data Extraction Savings Hours, Days or Weeks Secs, Mins or Hours Source Data Dataset in Work Area Analytic Processing Process Output Target Customer Loyalty - Solution Summary Managing customer loyalty is a key component of customer experience management in retail, telecommunications, and consumer markets. It starts with making use of the mountains of data available about each customer, their shopping patterns, and assessing long term value of each customer, funding effective marketing campaigns that target customers most likely to respond to offers, and determining that next best profitable action. Customer Loyalty management drives over 500B dollars in revenue worldwide. - Build brand loyalty - Accelerate predictive model build through deployment leveraging every customer interaction and transaction available to you - Quickly identify profitable customers and create effective marketing campaigns Lifetime Customer Loyalty with Oracle Advanced Analytics Customer Problem • It is expensive to acquire new customers or lose existing ones. • Assessing long term value of existing customers and finding ways to retain and convert at-risk customers into profitable ones is a challenge. • Improving customer loyalty is about that unique individual customer insight to be able to offer the right product/service at the right time. It’s the ability to predict what influences repeat shopping behavior at the right cost. • Issues: 1) Very large data volumes, 2) Too many scenarios to model, 3) Operationalization of resulting models into production. Power Positions • Easily work with billions of transactions from points of sale, 10s of thousands of products and 100s of millions of customers in-place in Oracle Database where the data reside. • Thousands of unique attributes about each consumer/household. • Readily incorporate unstructured data such as social networks and review feedback into analysis. • Lowest TCO and fastest path to enterprise-wide analytics deployment. Unique Capabilities • Powerful combination of in-database predictive algorithms and open source R algorithms. • Range of GUI and IDE options for business users to data scientists. • Rapid transition of models from development to operationalization. Benefits • Get started immediately with data in the database. • Sub-second query response at very large data volumes to allow rapid data preparation. • Scalable parallel distributed predictive algorithms. • Range of interface options that facilitate business-IT collaboration. • Leverages Enterprise-class infrastructure. Typical volumetrics at retailer • 3.2 Billion transactions – 120 million transactions bought a specific product – Understand co-occurrence of products across transactions to determine likelihood of 2 products bought together • 19 million households – Segment households based on demographic data and purchase behavior ## Big Data Scenarios with Database Data <table> <thead> <tr> <th>Scenario</th> <th>Duration</th> </tr> </thead> <tbody> <tr> <td>Analyze 100 million households that carry loyalty card to find out what the most influential factors that drive purchase behavior of products in one group are</td> <td>From start to model ready state: 25 minutes</td> </tr> <tr> <td>Identify households that consumed a specific product from a 5 billion transactions data set Eliminate those households with an aggregated spend of less than x dollars Segment the remaining households into 30 groups What describes each segment and how does that relate to the business?</td> <td>Start to finish: 5 minutes</td> </tr> <tr> <td>What products tend to be bought together? Analyze 5 billion POS transactions to identify subsets of products bought together Use this as basis to identify next best offer for each of 100 million households in each product category</td> <td>Start to Finish: 4 minutes</td> </tr> <tr> <td>Analyze 150 million orders in the last month to build a fraud detection model</td> <td>Start to Finish: 8 minutes</td> </tr> </tbody> </table> Summary - R-to-SQL transparency improves user efficiency by allowing use of R directly against database data - ORE enables R users to leverage in-database analytical techniques - Open source R packages can be leveraged in combination with database-managed data and task parallel execution - ORE provides a framework for sophisticated model building and data scoring - R integration into the SQL language enables integration into IT software stack - Oracle redistributes R and provides Enterprise support Resources • Blog: https://blogs.oracle.com/R/ • Forum: https://forums.oracle.com/forums/forum.jspa?forumID=1397 • Oracle R Distribution: • ROracle: http://cran.r-project.org/web/packages/ROracle • Oracle R Enterprise: http://www.oracle.com/technetwork/database/options/advanced-analytics/r-enterprise • Oracle R Connector for Hadoop:
{"Source-Url": "http://www.oracle.com/technetwork/database/options/advanced-analytics/r-enterprise/ore-trng1-gettingstarted-1501628.pdf", "len_cl100k_base": 7936, "olmocr-version": "0.1.53", "pdf-total-pages": 55, "total-fallback-pages": 0, "total-input-tokens": 74847, "total-output-tokens": 10269, "length": "2e12", "weborganizer": {"__label__adult": 0.00041794776916503906, "__label__art_design": 0.00089263916015625, "__label__crime_law": 0.0005288124084472656, "__label__education_jobs": 0.007442474365234375, "__label__entertainment": 0.00028252601623535156, "__label__fashion_beauty": 0.00023949146270751953, "__label__finance_business": 0.01148223876953125, "__label__food_dining": 0.0005054473876953125, "__label__games": 0.0011997222900390625, "__label__hardware": 0.0012903213500976562, "__label__health": 0.0005598068237304688, "__label__history": 0.00047969818115234375, "__label__home_hobbies": 0.00028324127197265625, "__label__industrial": 0.0013170242309570312, "__label__literature": 0.00033164024353027344, "__label__politics": 0.0005097389221191406, "__label__religion": 0.0004777908325195313, "__label__science_tech": 0.167724609375, "__label__social_life": 0.0003812313079833984, "__label__software": 0.2498779296875, "__label__software_dev": 0.55224609375, "__label__sports_fitness": 0.0004341602325439453, "__label__transportation": 0.000667572021484375, "__label__travel": 0.00037598609924316406}, "weborganizer_max": "__label__software_dev", "avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_ratio": [[0, 32826, 0.01384]], "fineweb_edu_fasttext_gt2__fineweb_edu_fasttext_gt2__score": [[0, 32826, 0.08185]], "ft_lang_id_en_doc_v2__ft_lang_id_en_doc_v2__en": [[0, 32826, 0.77435]], "google_gemma-3-12b-it_contains_pii": [[0, 165, false], [165, 855, null], [855, 1293, null], [1293, 1503, null], [1503, 2227, null], [2227, 2879, null], [2879, 3193, null], [3193, 3290, null], [3290, 3530, null], [3530, 3920, null], [3920, 5085, null], [5085, 5623, null], [5623, 5829, null], [5829, 5899, null], [5899, 6015, null], [6015, 6887, null], [6887, 7302, null], [7302, 7404, null], [7404, 7609, null], [7609, 8164, null], [8164, 8611, null], [8611, 9759, null], [9759, 10016, null], [10016, 11032, null], [11032, 12061, null], [12061, 12101, null], [12101, 12241, null], [12241, 12516, null], [12516, 12962, null], [12962, 13230, null], [13230, 13928, null], [13928, 14152, null], [14152, 14382, null], [14382, 14661, null], [14661, 15622, null], [15622, 15815, null], [15815, 21371, null], [21371, 21813, null], [21813, 22409, null], [22409, 22904, null], [22904, 22904, null], [22904, 23887, null], [23887, 25515, null], [25515, 26207, null], [26207, 26240, null], [26240, 26828, null], [26828, 27811, null], [27811, 28584, null], [28584, 30232, null], [30232, 30558, null], [30558, 31811, null], [31811, 32316, null], [32316, 32826, null], [32826, 32826, null], [32826, 32826, null]], "google_gemma-3-12b-it_is_public_document": [[0, 165, true], [165, 855, null], [855, 1293, null], [1293, 1503, null], [1503, 2227, null], [2227, 2879, null], [2879, 3193, null], [3193, 3290, null], [3290, 3530, null], [3530, 3920, null], [3920, 5085, null], [5085, 5623, null], [5623, 5829, null], [5829, 5899, null], [5899, 6015, null], [6015, 6887, null], [6887, 7302, null], [7302, 7404, null], [7404, 7609, null], [7609, 8164, null], [8164, 8611, null], [8611, 9759, null], [9759, 10016, null], [10016, 11032, null], [11032, 12061, null], [12061, 12101, null], [12101, 12241, null], [12241, 12516, null], [12516, 12962, null], [12962, 13230, null], [13230, 13928, null], [13928, 14152, null], [14152, 14382, null], [14382, 14661, null], [14661, 15622, null], [15622, 15815, null], [15815, 21371, null], [21371, 21813, null], [21813, 22409, null], [22409, 22904, null], [22904, 22904, null], [22904, 23887, null], [23887, 25515, null], [25515, 26207, null], [26207, 26240, null], [26240, 26828, null], [26828, 27811, null], [27811, 28584, null], [28584, 30232, null], [30232, 30558, null], [30558, 31811, null], [31811, 32316, null], [32316, 32826, null], [32826, 32826, null], [32826, 32826, null]], "google_gemma-3-4b-it_v2tag__is_academic_paper": [[0, 5000, false], [5000, 32826, null]], "google_gemma-3-4b-it_v2tag__is_class_syllabus": [[0, 5000, false], [5000, 32826, null]], "google_gemma-3-4b-it_v2tag__is_completion_certificate": [[0, 5000, false], [5000, 32826, null]], "google_gemma-3-4b-it_v2tag__is_court_notice": [[0, 5000, false], [5000, 32826, null]], "google_gemma-3-4b-it_v2tag__is_homework_assignment": [[0, 5000, false], [5000, 32826, null]], "google_gemma-3-4b-it_v2tag__is_news_article": [[0, 5000, false], [5000, 32826, null]], "google_gemma-3-4b-it_v2tag__is_public_order": [[0, 5000, false], [5000, 32826, null]], "google_gemma-3-4b-it_v2tag__is_resume_cv": [[0, 5000, false], [5000, 32826, null]], "google_gemma-3-4b-it_v2tag__is_test_or_quiz": [[0, 5000, false], [5000, 32826, null]], "google_gemma-3-4b-it_v2tag__is_textbook": [[0, 5000, false], [5000, 32826, null]], "pdf_page_numbers": [[0, 165, 1], [165, 855, 2], [855, 1293, 3], [1293, 1503, 4], [1503, 2227, 5], [2227, 2879, 6], [2879, 3193, 7], [3193, 3290, 8], [3290, 3530, 9], [3530, 3920, 10], [3920, 5085, 11], [5085, 5623, 12], [5623, 5829, 13], [5829, 5899, 14], [5899, 6015, 15], [6015, 6887, 16], [6887, 7302, 17], [7302, 7404, 18], [7404, 7609, 19], [7609, 8164, 20], [8164, 8611, 21], [8611, 9759, 22], [9759, 10016, 23], [10016, 11032, 24], [11032, 12061, 25], [12061, 12101, 26], [12101, 12241, 27], [12241, 12516, 28], [12516, 12962, 29], [12962, 13230, 30], [13230, 13928, 31], [13928, 14152, 32], [14152, 14382, 33], [14382, 14661, 34], [14661, 15622, 35], [15622, 15815, 36], [15815, 21371, 37], [21371, 21813, 38], [21813, 22409, 39], [22409, 22904, 40], [22904, 22904, 41], [22904, 23887, 42], [23887, 25515, 43], [25515, 26207, 44], [26207, 26240, 45], [26240, 26828, 46], [26828, 27811, 47], [27811, 28584, 48], [28584, 30232, 49], [30232, 30558, 50], [30558, 31811, 51], [31811, 32316, 52], [32316, 32826, 53], [32826, 32826, 54], [32826, 32826, 55]], "pipe_delimited_lines_v1__pipe_delimited_lines_v1__pipe_delimited_lines_ratio": [[0, 32826, 0.01972]]}
olmocr_science_pdfs
2024-12-10
2024-12-10
13a833f578e9db57a8e15fda9bfb1a2c41bd5231
ABSTRACT: From the recent advent of scripting tools integrated into commercial CAAD software and everyday design practice, the use of programming applied to an architectural design process becomes a necessary field of study. The presented research explores the use of programming as explorative and reflexive medium (Schön, 1983) through the development of a programming framework for architectural design. Based on Java, the ANAR+ library is a parametric geometry environment meant to be used as programming interface by designers. Form exploration strategies based on parametric variations depend on the internal logic description, a key role for form generation. In most commercial CAD software, geometric data structures are often predefined objects, thus constraining the form exploration, whereas digital architectural research and teaching are in need for an encompassing tool able to step beyond new software products limitations. KEYWORDS: Parametric design, programming language, architectural Geometry, processing RÉSUMÉ : Depuis les récentes avancées en matière d’intégration dans les logiciels commerciaux et les pratiques quotidiennes de langages de programmation, il est devenu nécessaire d’en faire un domaine d’étude. La présente recherche étudie l’usage de la programmation pour l’exploration et comme media réfléctif (Schön 1983) au travers le développement d’un cadre de programmation pour la conception architecturale. Basé sur Java, la librairie ANAR+ est un environnement paramétrique géométrique destiné à être utilisé comme une interface de programmation par des concepteurs. Les stratégies d’exploration formelle basées sur des variations paramétriques dépendent d’une description interne logique, un rôle clé pour la génération formelle. Dans la plupart des logiciels commerciaux de CAO, les structures de données géométriques sont souvent des objets prédéfinis, contraignant ainsi l’exploration formelle, alors que la recherche et l’enseignement de la conception architecturale ont besoin d’un outil englobant non assujetti aux limitations des nouveaux logiciels. MOTS-CLÉS : Design paramétrique, langage de programmation, géométrie architecturale, processus 1. ARCHITECTURE AND PROGRAMMING 1.1. Automated Drafting Integration of advances in CAAD research has typically been only slowly and gradually implemented within ordinary architectural practice, i.e. within commercial CAD software commonly used by architects. Several ideas originating from the “Robot Draftsman” project (RD aka SketchPAD (Sutherland 1963) ) can be seen as an important historical precedent (Mark 2008). This research challenges the nature of the fundamental changes introduced by automated drafting tools in architectural design. A second reading of RD underlines many key concepts for CAAD which are still sometimes presented as innovations and helps to understand the fundamental change from handmade technical drawings to automated process drawing. - **Parametric design**: the use of enclosures (“sub pictures”), geometric associativity (“attachments”) and constraints—prefigures the definition of parametric design in which numerical variables are linked together to describe geometrical relationship between entities. - **Continuity of scale**: the fluidity between scales allows for the coexistence in a single description of different levels of details that were traditionally developed in separate drawings. - **Geometric variations**: automation of drawing production facilitates geometric variations towards a creation of a family of forms. - **Simulation**: interfacing form definition with simulation provides the confrontation of design choices with approximations of reality. - **Rationalisation**: the use of computers for design implies the disambiguation of form definition (Stiny 1993), which may precede or follow ideation. This is referred as pre- or post-rationalization, whose implications CAAD detractors have outlined. At that time, RD emphasized the benefits of an graphical interactive tool for geometrical constructions. Today, most of current commercial CAD software can be seen as an extended development of RD concepts. The development of the ANAR+ library retains key programming concepts from this precursor, however decoupled from any graphical interface as a commonly adopted and rarely questioned feature of CAD, in order to study the internal logic of forms and the description of geometric relationship. 1.2. Code as Design Process Following the precedent of SketchPad, interactive drawing interfaces represent the initial penetration of computing in the architectural process. More recently, the introduction of parametric modeling techniques outlined a need for a better distinction between geometric representations and the logical structure of form. Despite the recent proliferation of programming interfaces for geometry, programming for design is yet a challenging field of study extending existing computer tools for design. **Programming as a creative process:** *Processing.org* is an open source Java framework for designer and artists (Reas and Fry 2007). At the time of its initial release, Processing proposed a different attitude toward programming, not anymore perceived as a purely technical matter, in advocating for a plurality of personal formalisms as an act of creation. In response to a software culture, where a pre-defined formalism is expected to be adopted by the user, *Processing.org* proposed a minimal set of elementary functions stimulating the user with the opportunity to define his own subjective formalism. While the definition itself of a design problem is part of the creative process (Akin 1986; Schön 1983; Simon 1990) and depends intrinsically on specificities of project contexts. The designer, through his programming practice, defines, refines, redefines his own formalism, describing more closely the nature of the design problem. Programming, instead of drawing, also matches the nature of the non-linear design process (Oxman 2006) made of refinements where each step could compromise the project as a whole. ### 1.3. Programming in Architecture Due to the geometric nature of architecture, formal thinking has always been part of the practice (Cache 1995; Mitchell 1990; Serres 1993). Despite the recent proliferation of programming interfaces within popular CAAD software, only few examples introduced a structure intended to be primarily used through a programming interface. We outline here three different types of commonly found programming integration: **Integrated Scripting:** Scripting refers to a programming language relying extensively on a specific platform (a CAD software in this case). The script is not independent of the targeted software and cannot be executed outside of the platform. They are often based on more generic programming languages with possible variations from the original language. Scripting languages are partially a transposition of a graphic interface into a programming equivalent. Examples of scripting languages: MEL (Perl), RhinoScript (VisualBasic), ArchiCAD’s GDL, AutoLISP. **Geometric Languages:** Geometric Languages are mostly procedures describing how a resulting geometry is created. The geometric languages describe a geometric output through instructions, instead of end values as used in file formats. As an example, instructions to describe curves geometry use parameters interpreted by a procedure to create the geometrical element. File formats instead, by describing each coordinates of points, faces, etc, usually discretize curves into linear elements. The discretized objects don’t exist, they are created by the interpreter. Examples of Geometric Languages: PovRAY (based on C language), VRML, LOGO. **Geometric Library:** Geometric libraries are meant to be used independently from graphic-based specified interfaces. They are based on a mid-level programming languages such as C++, Java or LISP and provide functions and algorithms for geometry manipulation. They can be invoked within the user’s own code. Examples: OpenGL (primarily meant for rendering). The work presented here focuses on providing a geometric library to be used either in conjunction or in the same attitude as the Processing.org project for architectural design. It provides basic functions to manipulate geometrical elements and aims at enabling the designer to establish his own specific formalism for digital architectural design. 2. ANAR+: OBJECT ORIENTED GEOMETRY Initiated by interests in exploring automatic form generation algorithms such as genetic algorithms or L-systems, the ANAR+ geometric library presented here was developed with the underlying aim to provide ways to control the amount of parameters defining a form, e.g. the degrees of freedom of a form. The intent is to explicitly leave the designer choose which dimensions are to be automatically explored and which are defined in relationship to these free dimensions. It results in a formalization framework providing more space to formulate design intents to be further elaborated by an automated form exploration technique (form finding). **FIGURE 1. REPRESENTATIONS; VISUAL AND LOGICAL.** 2.1. Logical and Visual representations The study bases itself upon the observation that processes leading to geometrical results represent singular form thinking and should be expressed differently than a strictly descriptive model. Moreover, the design process embeds implicit design choices that often tend to be hidden in common CAAD software. The process of form definition is believed to be highly personal, revealing how the form is thought (Mitchell 1990; Stiny 1993). In order to facilitate a variety of design processes to coexist, an open formalism is proposed built on well established elementary geometric concepts. Aiming to combine parametric (e.g. CATIA), dynamic (Cinderella) and procedural (LOGO) geometries, the ANAR+ library offers basic 3-dimensional environment and interaction, allowing designers to concentrate on form definition. Variations can be easily explored through the use of built-in graphical interface, in the form of sliders, controlling implicitly extracted parameters. Based on the combination of transformations of elementary geometric entities, the model better describes the constructional process and design intents which represent a particular and subjective perspective on an evolving problem context. Built on a similar programming for non programmers attitude as the open-source framework Processing.org (Reas and Fry 2007), the formalism introduces careful simplifications to ease form definition, while allowing the invocation of extended components of a full-fledged object-oriented programming language. However easily used in independence as a geometric library, the framework is developed as an extension for the Processing.org environment (IDE). It provides a minimal framework (camera, texturing, OpenGL functions, etc.) for testing, learning and sketching. Conceived independently to a graphic interface, the library is autonomous and does not rely on external libraries. The geometrical description is based on linear algebra, well documented and widely used in computer graphics and CAD software. In order to allow the use of the created design in usual architectural practice, the library includes exporters to several CAAD scripting languages and popular geometrical file formats. As a direct effect of the introduction of computers in the process of architectural design—primarily to help with technical representations and drawings—no clear distinction have been made between the representational model and the logic behind a representation. The study presented here aims at exploring the design potential of strongly decoupling description from representation. This conceptual aim is achieved through the use of coding alone to formally describe the form. If a graphical representation is used to evaluate the outcome of the formal description, modifications in the structure of the geometrical construction may only happen through code modification. It must be emphasized here that the presented research does not advocate for an exclusive use of programming in architectural design but for the necessity to explore constructional formalisms for their specific benefits to the design process. The following sections elaborate on the topological structures and the parametric implementation mechanism implemented in the ANAR+ library. 2.2. Primitives The following section outlines geometric entities provided as primitives. Using the JAVA inheritance structure, primitives could easily be extended to create more specific elements while providing a common modular structure for similar objects. **Parametric Framework:** To create dynamic geometric structures, every geometric instance needs to share a common mechanism where a single modification to an element propagates through all dependent objects. Also called scene graph, this mechanism remains simple and is applied indiscriminately to all objects of the library. As minimal mechanism, each modification to an entity triggers the rebuild of the objects that are based on it (children). Each entities have their own build methods with local values and could be rebuilt on demand according to different sets of initial values. Remaining minimal, this solution ensures a uniform way to interact with objects while preserving the overall parametric coherence. **Constructional Process:** The expression of a variety of form thinking is kept inside the logic formulation of the form. Every decision is embedded in the parametric framework where original instances are kept intact. The history of this process can be refined afterward. The description done through enclosures of finite sets of local condition provides an independence between instances. This is helpful for reusing or concurrent process. **Numbers - Design with Ratios:** In ANAR+, distinct numbers are conceived as parameters of a form. Relationship among parameters ensure to keep the amount of parameters as low as possible. Replacing measurements by a set of simple mathematical relationship is the basic associativity mechanism. This mechanism can be reproduced when parent parameters are updated and parameters are chained from one to the other, recursively. The addition of simple relationship based on local conditions creates complex structures that can in turn express more complex relationship. This is done in order to reduce the use of static geometric descriptions while providing a way to keep intact the process of geometrical construction. The substitution of numbers by ratios improves the flexibility of geometric constructions enabling conditions to be easily be updated. For example (Figure 2), a square could be expressed using only one value (the length of one side). If the same length is reused through the construction, the properties of a square are kept. A rectangle can be described with two length for each side, but it could also be described with two values: the ratio of its sides and the scaling factor. Changes to the parameters, i.e. changing the original values, will create a different form where geometric characteristics are kept. Implicitly, through the formalization of an object, all parameters are extracted, providing different ways to interact with the form. This structure creates an enclosure where the description of local conditions influences the resulting form. **Interaction with parameters:** Parameters provide a generalized way to describe numerical values. The influence of parameters can be interactively explored by the manual modification of values. On a simplest form, parameters are represented as graphical sliders through a built-in process. As every parameter provide a similar structure, this structure can easily be adapted to different kind of physical interfaces or can be controlled by an automated process. **Absolute Points**: Points combine n parameters (representing each coordinates values) according to the dimension of a point. 2 parameters is considered as 2D point, 3 parameters is considered as 3D, ... nD. A point could contain the same parameter twice resulting in a constrained point on x=y slope. **Derived points**: Derived points are depending on their parents, contrary to absolute points, they cannot be modified directly as they are the result of a relationship. They enable the expression of relationship such as points in the middle of two points, intersection between two lines or three planes, center of a face, transformed point (see Transform primitives), points constrained on a line. **Points List and Faces**: lines (segments), multilines (polylines) and faces share a common data structure. The structure relies on a list of points. Depending on the object, they have different behaviors. The major distinction between face and multilines is in their displaying procedures: faces will act as closed filled polylines, by assuming that the user is careful in ensuring their planarity. Non-planar cases are only handled by the display method. **Object**: is a combination of faces, points and lines. In ANAR+, while the primary focus is a logic representation, the Object doesn’t have prescriptive structures such as BREP data structures with normals orientations. An object could be composed of a point 1D or line 2D. Transformations: are often expressed in the form of push and pop matrix stacking. While it provides an efficient way to combine matrices, it tends to make it more difficult to evaluate the actual position of a vertex. This is due to the OpenGL optimized calculations where real-time renderings are crucial. One of the drawbacks of this approach is that the evaluation of points coordinates is only created for a short period, at the time of rendering. This is problematic for procedures relying on coordinates such as area calculations, distance between points. In CAD systems, on the other hand, point coordinates are kept into a database and do not represent the process of generation. Such a geometry without generative process is denoted as an orphaned geometry, in which the geometry cannot be transformed by updating process parameters. ANAR+ library combines both strategies by creating intermediary geometries while keeping the constructional process. This provides a mechanism closer to the traditional CAD structure. Each construction steps result into a geometry that can be reused in a further process only. The proposed approach combining generation process and homogeneous geometrical structures inside a single framework is done by a generalization of transformation operators in such a way that each needed steps through the creation of an object are kept. The combination of transformations is the geoconstructional process. 2.3. Geometrical Relationship The following section explains the formalism in ANAR+ describing the relationship between geometrical primitives. The primitives as inputs (parents) are combined together to create a new derived primitive as output (children). In programming terms, using object-oriented structure, the object have internal procedures describing how a geometric result could be obtained derived from the given inputs. This programming structure reduces a geometrical problem into a finite set of elements and can be reprocessed when the conditions change resulting in a propagation behavior. Resulting objects are themselves primitives and could be reused as parent for a new object, creating more complex structures. This simple recursive structure is enough to describe a parametric geometry. A simple example is a point (M) between two points (A, B). The analytical relationship is the distance between the points (A, B) divided by two. (M) is the result of (A, B), if (A) or (B) is updated, (M) should reflect the new conditions. (M) could be himself used to calculate (N), the middle point between (A, M). Simple shape: The next examples detail the representations of the cases presented in (Figure 2) using different geometrical constructions. A simple square is used as a point of comparison between different geometrical construc- tions for the same representation. As outlined by (Stiny 1993), even a minimal shape is subject to many logical interpretations. In (Figure 3), the shape is described by the 2D coordinates of the square vertices. The resulting shape family consists in deformed polygons, with regular polygons as special cases. The shape is composed of four points without relations. As seen, this geometrical construction is referred as an orphan geometrical description and is similar to a drawing without geometrical relationship, except to a referential coordinate system. If one point is moved, the other points remains at the same position. Found in early CAD software and for formats still commonly used today in the architectural practice (DXF, OBJ), this structure describes a geometry without any internal relationship between elements. **FIGURE 3. GEOMETRICAL CONSTRUCTION OF THE SQUARE 1 BASED ON ABSOLUTE COORDINATES REFERENCES.** *THE CONSTRUCTION HAVE 8 PARAMETERS REPRESENTING XY COORDINATES OF THE FORM.* ![Geometrical construction of the square 1](image) The next construction (Figure 4) introduce transformations. The resulting family of shape includes rectangles, squares or sheared rectangles. In this case, the points are derived from a first point with a translation. The translation describes the relationship between two points on one edge. The first translation has only one parameter which constrains the point movement to one axis. The second transformation has two parameters which describe the potential movement of the second two points to the XY plane. In this construction, interaction with the system is done through the change of one point (the origin of the shape) or through the lengths of each side (translation in X or Y). A shear behavior is achieved with the 3rd parameter on the second translation. Figure 4. Geometrical construction of the square 2 based on translations. The construction have 5 parameters: 2 for coordinates and 3 for the transformations. The third construction (Figure 5 and Figure 6) is based on two different types of transformation in the same construction; translation and rotation. The resulting family of shape obtained is equilateral triangle, square, regular polygons (Figure 6), circle (with an infinity of edges). Figure 5. Geometrical construction of the square 2 based on rotations and translations. The construction have 3 parameters. The previous examples show how a different geoconstructional process leads to different meanings and behaviors for each construction. In fact, the list of different combinations could be extended infinitely. The formalism based on the predefined primitives allows comparisons to be drawn and outlines the logical structure of the construction of the geometry. 2.4. Architectural examples Since the parametric relationships have a tree topology in graph-theoretic terms, abstracting this information and graphically represent it using the graph visualization algorithm `twopi` (part of the `graphviz` graph layout suite (Ellson et al. 2001)) enables the representation of the modeling strategies used in moderately complex examples. **FIGURE 6. SIMILAR CONSTRUCTION AS PREVIOUS FIG. WITH A SMALLER ANGLE AND MORE EDGES.** **FIGURE 7. RULED SURFACE CONSTRUCTION EXAMPLE. THE SURFACE IS OBTAINED THROUGH A ROTATION OF A NON PARALLEL LINE AROUND AN AXIS. RIGHT, CORRESPONDING GEOMETRIC CONSTRUCTION.** FIGURE 8. GEOMETRICAL CONSTRUCTION FOR A CONCAVE FORM BASED ON TRANSLATIONS IN DIFFERENT DIRECTIONS. FIGURE 9. ARCHITECTURAL EXAMPLE OF A COMPLEX GEOMETRIC CONSTRUCTION. FIGURE 10. CODE EXCERPT FROM THE EXAMPLE TOWER. ```java Face star = new Face(); int numberOfSides = 5; Param w1 = new Param(50,0,100); Param w2 = new Param(50,0,100); Transform rz = new RotateZ(PI/numberOfSides); Pt a = Pt.create(0,0,0).translateX(w1); Pt b = a.copy().translateX(w2).apply(rz); for(int i=0; i<5; i++) { a = a.copy().apply(rz).apply(rz); b = b.copy().apply(rz).apply(rz); star.add(a,b); } Param height = new Param(5,0,30); Param d = new Param(100,80,110).tag("%"); Param sx = new Param(95,90,110).div(d); Param sy = new Param(94,90,110).div(d); Param sz = new Param(104,90,110).div(d); Param r2 = new Param(6,-20,20).div(d); Transform complex = new Transform(); complex.translateZ(height); complex.scale(sx,sy,sz); complex.rotateZ(r2); for(int i=0; i<24; i++) { Face floor = star.copy().apply(complex); Anar.add(floor); star = floor; } ``` In (Figure 10), a more complex formal construction represents the architectural skeleton of a building depicted in (Figure 9). The programming sequence remains simple. From this basic construction is derived the structural elements and inside walls on every second floor. The corresponding graph of internal parametric relationship displays a complex structure where the number of parameters is kept to only a few different values. 2.5. Use of the ANAR+ Library This library has been confronted to various practical contexts: Within the Phototropic Architecture (LaBelle et al. 2008; Nembrini et al. 2009) project, the aim is to instantiate an integrated system combining form generation and simulation in a continuous automation, often described as a feedback loop. The ANAR+ library consists on a substantial part of a more general aim to better integrate form generation, automated exploration, simulation and fabrication in a compound model (Oxman 2006). The framework has also been used in teaching to introduce digital design thinking in general terms, away from specific software peculiarities. (Nembrini et al. 2009) 3. CONCLUSION AND OUTLOOK Behind the geometric representation, the logic of a geometric construction is expressed through a minimal formalism. While a representation could share many different geometric constructions, the logic might have different meanings depending on the process context. In the ANAR+ library, a formalism is set to describe and keep an history of logical structures. Providing a representation of the logical process enable the possibility to develop specific operations on the logical representation itself. The modularity of the geometric library is intended to be used with growth algorithms (such as Genetic Programming or L-Systems (Prusinkiewicz and Lindenmayer 1990)) and to study combinatorial permutations in complex logical structures. Also, the restructuring of the geometrical construction could provide promising avenues for parameters reduction, allowing for instance to constrain the search space for optimization techniques such as genetic algorithms. ACKNOWLEDGEMENTS This research has been supported by the Swiss National Science Foundation, KID grant number K-12K1-118078 and by the SiteMapping media art program of ProHelvetia (Federal Office for Culture), Switzerland. REFERENCES
{"Source-Url": "http://papers.cumincad.org/data/works/att/cf2009_771.content.pdf", "len_cl100k_base": 5355, "olmocr-version": "0.1.53", "pdf-total-pages": 15, "total-fallback-pages": 0, "total-input-tokens": 28389, "total-output-tokens": 6755, "length": "2e12", "weborganizer": {"__label__adult": 0.0011463165283203125, "__label__art_design": 0.0848388671875, "__label__crime_law": 0.0009431838989257812, "__label__education_jobs": 0.0085906982421875, "__label__entertainment": 0.0003948211669921875, "__label__fashion_beauty": 0.0006413459777832031, "__label__finance_business": 0.0005006790161132812, "__label__food_dining": 0.0011835098266601562, "__label__games": 0.0014047622680664062, "__label__hardware": 0.00247955322265625, "__label__health": 0.0013036727905273438, "__label__history": 0.00154876708984375, "__label__home_hobbies": 0.0007967948913574219, "__label__industrial": 0.002178192138671875, "__label__literature": 0.0018739700317382812, "__label__politics": 0.0004940032958984375, "__label__religion": 0.002285003662109375, "__label__science_tech": 0.15478515625, "__label__social_life": 0.0002925395965576172, "__label__software": 0.022125244140625, "__label__software_dev": 0.70751953125, "__label__sports_fitness": 0.0006427764892578125, "__label__transportation": 0.0012760162353515625, "__label__travel": 0.0007052421569824219}, "weborganizer_max": "__label__software_dev", "avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_ratio": [[0, 29178, 0.03251]], "fineweb_edu_fasttext_gt2__fineweb_edu_fasttext_gt2__score": [[0, 29178, 0.8437]], "ft_lang_id_en_doc_v2__ft_lang_id_en_doc_v2__en": [[0, 29178, 0.85963]], "google_gemma-3-12b-it_contains_pii": [[0, 2190, false], [2190, 4882, null], [4882, 7694, null], [7694, 9691, null], [9691, 12690, null], [12690, 15670, null], [15670, 17426, null], [17426, 20282, null], [20282, 22111, null], [22111, 22682, null], [22682, 23684, null], [23684, 23855, null], [23855, 25581, null], [25581, 27977, null], [27977, 29178, null]], "google_gemma-3-12b-it_is_public_document": [[0, 2190, true], [2190, 4882, null], [4882, 7694, null], [7694, 9691, null], [9691, 12690, null], [12690, 15670, null], [15670, 17426, null], [17426, 20282, null], [20282, 22111, null], [22111, 22682, null], [22682, 23684, null], [23684, 23855, null], [23855, 25581, null], [25581, 27977, null], [27977, 29178, null]], "google_gemma-3-4b-it_v2tag__is_academic_paper": [[0, 5000, true], [5000, 29178, null]], "google_gemma-3-4b-it_v2tag__is_class_syllabus": [[0, 5000, false], [5000, 29178, null]], "google_gemma-3-4b-it_v2tag__is_completion_certificate": [[0, 5000, false], [5000, 29178, null]], "google_gemma-3-4b-it_v2tag__is_court_notice": [[0, 5000, false], [5000, 29178, null]], "google_gemma-3-4b-it_v2tag__is_homework_assignment": [[0, 5000, false], [5000, 29178, null]], "google_gemma-3-4b-it_v2tag__is_news_article": [[0, 5000, false], [5000, 29178, null]], "google_gemma-3-4b-it_v2tag__is_public_order": [[0, 5000, false], [5000, 29178, null]], "google_gemma-3-4b-it_v2tag__is_resume_cv": [[0, 5000, false], [5000, 29178, null]], "google_gemma-3-4b-it_v2tag__is_test_or_quiz": [[0, 5000, false], [5000, 29178, null]], "google_gemma-3-4b-it_v2tag__is_textbook": [[0, 5000, false], [5000, 29178, null]], "pdf_page_numbers": [[0, 2190, 1], [2190, 4882, 2], [4882, 7694, 3], [7694, 9691, 4], [9691, 12690, 5], [12690, 15670, 6], [15670, 17426, 7], [17426, 20282, 8], [20282, 22111, 9], [22111, 22682, 10], [22682, 23684, 11], [23684, 23855, 12], [23855, 25581, 13], [25581, 27977, 14], [27977, 29178, 15]], "pipe_delimited_lines_v1__pipe_delimited_lines_v1__pipe_delimited_lines_ratio": [[0, 29178, 0.0]]}
olmocr_science_pdfs
2024-12-06
2024-12-06
edbf37fda08d95f2c9471fd7f12b000c164a80e6
[REMOVED]
{"Source-Url": "http://dspace.stir.ac.uk/bitstream/1893/23387/1/haiku-lncs.pdf", "len_cl100k_base": 7790, "olmocr-version": "0.1.53", "pdf-total-pages": 15, "total-fallback-pages": 0, "total-input-tokens": 37190, "total-output-tokens": 10907, "length": "2e12", "weborganizer": {"__label__adult": 0.0003631114959716797, "__label__art_design": 0.00037479400634765625, "__label__crime_law": 0.0003509521484375, "__label__education_jobs": 0.0007162094116210938, "__label__entertainment": 7.778406143188477e-05, "__label__fashion_beauty": 0.00017559528350830078, "__label__finance_business": 0.00017213821411132812, "__label__food_dining": 0.0003893375396728515, "__label__games": 0.00052642822265625, "__label__hardware": 0.0005927085876464844, "__label__health": 0.0005412101745605469, "__label__history": 0.00024437904357910156, "__label__home_hobbies": 0.0001170635223388672, "__label__industrial": 0.0004301071166992187, "__label__literature": 0.00030922889709472656, "__label__politics": 0.0002903938293457031, "__label__religion": 0.000522613525390625, "__label__science_tech": 0.023223876953125, "__label__social_life": 0.00012171268463134766, "__label__software": 0.00478363037109375, "__label__software_dev": 0.96435546875, "__label__sports_fitness": 0.0004200935363769531, "__label__transportation": 0.0005702972412109375, "__label__travel": 0.00021278858184814453}, "weborganizer_max": "__label__software_dev", "avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_ratio": [[0, 41809, 0.02201]], "fineweb_edu_fasttext_gt2__fineweb_edu_fasttext_gt2__score": [[0, 41809, 0.6201]], "ft_lang_id_en_doc_v2__ft_lang_id_en_doc_v2__en": [[0, 41809, 0.83496]], "google_gemma-3-12b-it_contains_pii": [[0, 3023, false], [3023, 6381, null], [6381, 9811, null], [9811, 13175, null], [13175, 16130, null], [16130, 18674, null], [18674, 21242, null], [21242, 23370, null], [23370, 26178, null], [26178, 28606, null], [28606, 30797, null], [30797, 33682, null], [33682, 35629, null], [35629, 39196, null], [39196, 41809, null]], "google_gemma-3-12b-it_is_public_document": [[0, 3023, true], [3023, 6381, null], [6381, 9811, null], [9811, 13175, null], [13175, 16130, null], [16130, 18674, null], [18674, 21242, null], [21242, 23370, null], [23370, 26178, null], [26178, 28606, null], [28606, 30797, null], [30797, 33682, null], [33682, 35629, null], [35629, 39196, null], [39196, 41809, null]], "google_gemma-3-4b-it_v2tag__is_academic_paper": [[0, 5000, true], [5000, 41809, null]], "google_gemma-3-4b-it_v2tag__is_class_syllabus": [[0, 5000, false], [5000, 41809, null]], "google_gemma-3-4b-it_v2tag__is_completion_certificate": [[0, 5000, false], [5000, 41809, null]], "google_gemma-3-4b-it_v2tag__is_court_notice": [[0, 5000, false], [5000, 41809, null]], "google_gemma-3-4b-it_v2tag__is_homework_assignment": [[0, 5000, false], [5000, 41809, null]], "google_gemma-3-4b-it_v2tag__is_news_article": [[0, 5000, false], [5000, 41809, null]], "google_gemma-3-4b-it_v2tag__is_public_order": [[0, 5000, false], [5000, 41809, null]], "google_gemma-3-4b-it_v2tag__is_resume_cv": [[0, 5000, false], [5000, 41809, null]], "google_gemma-3-4b-it_v2tag__is_test_or_quiz": [[0, 5000, false], [5000, 41809, null]], "google_gemma-3-4b-it_v2tag__is_textbook": [[0, 5000, false], [5000, 41809, null]], "pdf_page_numbers": [[0, 3023, 1], [3023, 6381, 2], [6381, 9811, 3], [9811, 13175, 4], [13175, 16130, 5], [16130, 18674, 6], [18674, 21242, 7], [21242, 23370, 8], [23370, 26178, 9], [26178, 28606, 10], [28606, 30797, 11], [30797, 33682, 12], [33682, 35629, 13], [35629, 39196, 14], [39196, 41809, 15]], "pipe_delimited_lines_v1__pipe_delimited_lines_v1__pipe_delimited_lines_ratio": [[0, 41809, 0.03957]]}
olmocr_science_pdfs
2024-12-10
2024-12-10
dd74db5616e6740e544f9813154b43ebc6e002c4
Enhancing BiDAF with BERT Embeddings, and Exploring Real-World Data Priyanka Sekhar Stanford University psekhar@stanford.edu Ryan Mui Stanford University ryanmui@stanford.edu Sumit Minocha Stanford University sminocha@stanford.edu Abstract In our project, we used BERT embeddings to enhance BiDAF for the task of question answering on real world data. We had 2 main goals: 1) maximize performance (measured by F1 and EM scores) of our combined BERT and BiDAF architecture on the SQuAD 2.0 leaderboard 2) explore our model’s performance on our custom dataset, which contains real customer service interactions from a global cosmetics manufacturer, Benefit Cosmetics. This second goal is an additional exploration that extends the goals of the default project. Our BiDAF models with BERT embeddings achieved dev EM/F1 scores in the 50s after just 2 epochs, instead of the 30 required for the baseline BiDAF. Our best run on the industry dataset was with the BERT fine-tuned model, which achieved dev EM/F1 scores in the 70s on the combined SQuAD + industry dataset. However, this model still did poorly on the industry examples, which highlights the challenges of adapting research to real-world settings. Our best test set performance was with the BERT uncased small model fine tuned for 2 epochs. (EM/F1 72.257/75.586). 1 Introduction The ability to answer questions given text information is an important problem in modern natural language processing (NLP). Solving this Question and Answering (QA) task requires that a machine “understand” both the question and the provided text well enough to extract the correct information. Ultimately, creating such a solution to this problem opens the doors to automating many services such as customer support and broadens the understanding of human language and machine understanding. The first step in building any NLP system is representing words with vectors of numbers that a computer can digest. The method of embedding words to numbers can have significant impacts on the performance of a system. Two popular techniques for learning word embeddings are GloVe [6] and Word2Vec [7]. Both of these embedding methods learn embeddings by looking at the occurrences of nearby words. In this way, GloVe and Word2Vec learn word embeddings based on the local context of a given word. The issue with these embeddings however, is that they are unable to capture the multiple meanings of words in different contexts. A solution to this problem is found in BERT [1]. by pre-training a deep bidirectional transformer architecture, BERT is able to generate different word embeddings for a given word depending on its context. This breakthrough motivates our use of BERT embeddings on a standard BiDAF model for QA. Finally, the progress made in research has limited practical importance if the results cannot be replicated in a real world setting. Thus, we explore the ability of our model to perform on a real world dataset from Benefit Cosmetics, a global cosmetics manufacturer selling at over 2,000 counters in more than 30 countries. We found that although BERT embeddings can be used, they come with several preprocessing challenges and do not guarantee parity of performance with a fine-tuning of BERT. Our BERT + BiDAF models achieved EM/F1 in the 50s and required double the training time. The training time could be improved with more efficient preprocessing, and scores would likely improve with more training (since we were only able to train for 2 epochs per experiment) but the memory and resources required for these changes may be prohibitive for simple plug and play adaptation of BERT embeddings to some models. Furthermore, we found that the differences in distribution between industry datasets and research datasets may render state of the art models much less impactful than carefully considered, domain-specific heuristics. 2 Related Work Both Word2Vec and GloVe are methods for learning word embeddings. The difference between the two is that GloVe is a count based model, while Word2Vec is a predictive model. In both cases, a single word embedding is learned for each word, and it cannot be adapted to the multiple meanings that a word might have. For example, the embedding for the word "tear" is the same whether the sentence is "a tear on the face" or "a tear in the jacket". BERT builds off of the Transformer architecture and showcases the performance gains of pre-training transformers to perform several NLP tasks [10]. The a major benefit of such an architecture is that the BERT can address several different NLP tasks, achieving state of the art results by adding a task-specific top layer to a given model. It is this property which we explore by using BERT embeddings on a BiDAF model. The BiDAF model we use is the same model described in the default project handout. It is based on the work of Seo et al., but it does not use character embeddings [8]. The model serves as our base model and allows us to quickly investigate the challenges of adapting out of the box BERT embeddings to models that are built to accept GloVe vectors as input. Note that we investigated QANet as an alternative base model to BiDAF [4], but the amount of time it took to train was fairly long and others were having trouble replicating the published benchmarks for the SQuAD 2.0 dataset. Thus we opted to use the provided baseline BiDAF instead. 3 Approach 3.1 BERT Embeddings In our project, we use BERT [1], a current state of the art language representation system to generate word embeddings. We take the output from the hidden states to generate new embeddings for each text input. These embeddings are then fed into the remaining parts of our modified BiDAF model, described in section 4.3. The BERT Base model consists of 12 encoder layers (or Transformer Blocks), where the output of each encoder layer along each token’s path can be used as a feature representing that token. These transformers are pre-trained on mask and next sentence pre-training objectives, enabling them to learn and encode bidirectional meaning in ways previous state of the art approaches could not. Because we can extract output from each of the 12 transformer layers, there are several possible ways to construct our word embeddings, which we will explore in section 4.3. Unfortunately, training BERT takes considerable amount of time and resources. Thus, we use a pre-trained BERT model by huggingface [2] to generate the hidden state output for each input at train time. We then combine these hidden states as described in 4.3 and test the performance of our new embeddings when used as input for the provided baseline BiDAF. Our Original Contribution The BERT paper only formally reports in detail the impact of different BERT embedding combinations for entity recognition and classification tasks. However, other authors have suggested that the impact of different combinations of BERT embeddings may be task specific [5]. For instance, early layers may be better at low-level part-of-speech tagging, while higher level combinations may be better for text generation. Thus, we extend upon the work of the BERT paper by looking at the impact of different embedding combinations specifically for the task of QA. 3.2 Industry Application Benefit Cosmetics is an international company that receives hundreds of questions daily to its Facebook page and Instagram account, and even more to its customer support email. The company is exploring ways of automating some of these responses. Working with industry data poses unique challenges, including brand preservation. The company currently uses manual templates that a support representative copies and pastes. Our Original Contribution: We investigate the best ways to translate SOTA QA models to this industry pain point. We generate dev/test sets using our partner’s custom data (see section 4.1) and tune/evaluate our models and the baseline models on these sets in addition to submitting to the SQuAD leaderboard. We then provide analysis on the risks and strengths of automation as well as analysis on infrastructure needed to productionize such models. 3.3 BiDAF We modify the provided baseline BiDAF as shown in Figure 1. The provided baseline takes as input a question and context, which it converts to word embeddings. Instead, we take the combined question and context and convert them to BERT embeddings before passing them on to subsequent layers of the BiDAF model. Input embeddings for a given batch are generated during the train step, before the forward pass of the BiDAF model. Consequently, we investigate how readily useful the BERT embeddings are for generic models. 4 Experimental Setup 4.1 Data We trained the varied BERT + BiDAF models introduced above (sections 3.1 and 3.3) on 2 datasets. The first is the default project SQuAD 2.0 dataset [13], and the second is a custom Benefit Cosmetics dataset (described in sections 4.1.1 and 4.1.2). 4.1.1 Custom Benefit Cosmetics Dataset The custom dataset is constructed (following steps in section 4.1.2) from csv files that were provided to us by Benefit Cosmetics [11]. These files contain 40,000 messages, within about 20,000 threads of Facebook and Instagram direct message (DM) interactions (Benefit Cosmetics US and UK accounts). See figure 2 for some hand-picked example direct message interactions. As a quick note, not all questions have responses from a company account, and such questions are immediately followed by a different message thread from another user. In each file, the message text is in one column, and the corresponding sender IDs (either the company account or the consumer user ID) are in the other, for a total of 2 columns. Users mostly ask about price, product-related complaints, and shipping availability. Additionally, many of these messages contain slang and abbreviations. Question structure is inconsistent. For example, sometimes a question is asked in the middle of a sentence, other times at the end, sometimes the input lacks a ‘?’ character, and some examples are much longer than others. Given that this is real world data, it makes sense that the rhetoric is much more conversational, although this definitely comes with challenges (see relevant discussion in section 6.3.2). 4.1.2 Industry Preprocessing Architecture To get the csv files into a format that was readable by our model, we created a preprocessing pipeline that wrote the contents of each input csv into a JSON file that had the same structure and nested sub-fields as the official SQuAD 2.0 train and dev sets. This involved the following multi-step process. First, the raw Benefit Cosmetics csv is ingested and some specifically designed heuristics are used to bucketize these DMs into Question, Context, and Answer (QCA) triplets. A percentage of these QCA triplets (randomly subsampled) are mixed or spliced together with the official SQuAD training dataset, and the remaining triplets are mixed with the dev set. The hybrid result is then written to new train and dev JSON files, which now consist of examples from both the Benefit Cosmetics dataset and SQuAD 2.0. Examples of rules or heuristics we used to construct accurate QCA triplets included checking if the message contained a ‘?’ character, splicing out from the candidate contexts what seemed to be templated phrases by Benefit Cosmetics like ‘Hey gorgeous’ or ‘xoxo’, and extracting the ‘ground truth’ answer (ideally 3 to 5 words) from the context by extracting all text up to the first punctuation as the golden answer. Right off the bat, there were plenty of compromises we had to make; limitations of some of these preprocessing decisions are discussed in section 6.3.1. 4.2 Evaluation Method For evaluation we report our best F1/EM scores on SQuAD 2.0 dev/test datasets and provide qualitative analysis on the custom industry datasets for each of our models (BiDAF baseline, BERT fine tune, and modified BiDAF models). 4.3 Embedding Experiments To give our combined BERT embeddings and BiDAF model the best chance of achieving high scores, we performed a feature-based test similar to the one conducted in the original BERT paper [1]. We examined three high performing combinations of embedding vectors generated from from the pre-trained Transformer’s hidden layers. Specifically, we extracted 1) just the first layer, 2) just the last layer, and 3) the sum of the last 4 layers. (see figure 3) [1]. These embeddings were fed as input into our modified BiDAF model, and the performance was compared to our vanilla BiDAF and default BERT fine tune outcomes in Section 5. Vanilla Baseline Submission Our first leaderboard dev submission obtains an EM/F1 of 57.906/61.493, which improves upon the unmodified baseline scores of 55/58 (as stated in the handout). This required no code modifications, and we simply used the provided GloVe word embeddings. BERT Fine Tune We fine tuned the huggingface Pytorch implementation of BERT on the SQuAD 2.0 dataset for 2 epochs using a learning rate of 3e-5 and doc stride of 128. Due to memory constraints, we restricted the max sequence length to 384 and the batch size to 6. BiDAF with BERT Embeddings Models were trained using the same hyperparameters as the baseline BiDAF model, with the exception of num_epochs, which we set to 2 in order to compare performance with the Bert fine-tuned run. Due to memory constrains on the NV6, we had to limit the batch size to 3 and the max sequence length to 96. The doc stride was left at 128, as was the default in the BERT fine-tune run. Industry Dataset Training To get as close of a comparison as possible to our other experiments, we tried to mirror the hyperparameters of previous experiments (while still accounting for memory constraints) and only swap out the default SQuAD 2.0 dataset for the hybrid dataset constructed as described in section 4.1.2. We fine tune the huggingface BERT model on this dataset as an upper bound comparison, and we then train our modified Bert Embeddings + BiDAF models on this hybrid dataset and examine the output. An NV6 machine was used for 2 epochs, along with a batch size of 3, a max sequence length of 96, and a doc stride of 128. 5 Results Table 1: Embedding Experiments <table> <thead> <tr> <th>Model</th> <th>EM</th> <th>F1</th> </tr> </thead> <tbody> <tr> <td>BERT Fine Tune Reported [9]</td> <td>82.126</td> <td>84.820</td> </tr> <tr> <td>BERT Fine Tune Empirical</td> <td>73.001</td> <td>76.069</td> </tr> <tr> <td>Baseline BiDAF Reported</td> <td>55</td> <td>58</td> </tr> <tr> <td>Baseline BiDAF Empirical</td> <td>57.906</td> <td>61.493</td> </tr> <tr> <td>Last Layer 2 epochs</td> <td>53.241</td> <td>53.870</td> </tr> <tr> <td>First Layer 2 epochs</td> <td>51.629</td> <td>51.686</td> </tr> <tr> <td>Sum Last Four Layers 2 epochs</td> <td>52.929</td> <td>54.895</td> </tr> </tbody> </table> Table 1 outlines EM and F1 scores for all of our embedding experiments. “Reported” indicates the published result in the original document. "Empirical" indicates the value we observed during our run. All values are reported on their respective dev sets. We also fine tuned BERT on our industry + SQuAD 2.0 mixed train set and mixed dev set, both containing a combination of research and industry examples. The fine tune achieved results similar to the BERT Fine Tune Empirical model in Table 1 (around 70/75 EM/F1). However, when we ran our BERT embedding + BiDAF model on the mixed industry/SQuAD train/dev sets, the EM/F1 were less than 10. Potential reasons for this behavior are discussed in our qualitative analysis. Training of our modified BERT + BiDAF models took about 12 hours per epoch, which is significantly more than the 22 minutes per epoch of the vanilla BiDAF baseline and almost double that of the fine-tune BERT base model on an NV6 machine with a single GPU. **Best submission to Test and Dev** Both were from the full end to end fine tune of the huggingface submission. Best dev submission: 73.001 EM 76.069 F1 Best test submission: 72.257 EM 75.586 F1 6 Analysis 6.1 Quantitative Performance Each of the embedding experiments achieve EM and F1 results comparable to the vanilla baseline within just 2 epochs instead of the default 30 used for training the baseline (although at the cost of much longer training times for the non-baseline models). However, the model that very clearly outperformed the rest was the fine tune of BERT. We were able to reap the benefits of the architecture calculating the embeddings by calling a forward pass of the BERT model. This embedding pre-generation in the processing step led to a significant reduction of the previously 12 hour/epoch train time. Our results therefore indicate that the embeddings might assist in faster convergence, but they do not suggest that we can achieve the same state of the art performance of original the original BERT model simply by substituting embeddings. Comparing our embedding experiments (last layer, first layer, sum of the last 4 layers) we saw that the experiment that produced the best EM score involved the last layer, and the one that produced the best F1 score was the sum of all 4 layers. The models trained on the hybrid industry datasets seem to get comparable EM and F1 scores, but this may be because the model is simply ignoring most of the industry examples (further discussed in the qualitative section below). 6.2 BERT Embeddings in BiDAF Qualitative Each of the BERT + BiDAF experiments did well with proper nouns (names, locations, etc.) and numerical answers such as dates but both the BERT + BiDAF and baseline models tended to err on the side of “no answer” for more complex questions. This indicates that several of the core properties of the models architecture may be preserved despite the embedding replacement. Some examples are included below. Table 2: Sample Outputs for BERT Embeddings <table> <thead> <tr> <th>Question</th> <th>Prediction</th> <th>Expected</th> </tr> </thead> <tbody> <tr> <td>In what country is Normandy</td> <td>&quot;France&quot;</td> <td>France</td> </tr> <tr> <td>When was Scotland invaded by William?</td> <td>&quot;1072&quot;</td> <td>1072</td> </tr> <tr> <td>What major conquest did Tancred play a roll in?</td> <td>&quot;Jerusalem&quot;</td> <td>Jerusalem</td> </tr> </tbody> </table> This is likely because the embeddings really are just a better representation of input, but have no direct impact on subsequent layers. Thus the model may have a better starting point from which it can learn and thus reach comparable results in fewer epochs, but the underlying architecture will still learn the same macro trends. The ability to detect proper nouns and dates likely comes from the fact that the key word in the question or a close synonym is located in the context. E.g. for "In what country is Normandy" the notable context sentence is "Normandy is a region in France" where country and region are very related. However when trying to decipher the phrase "Tancred was instrumental in the conquest of Jerusalem" for question 3, the model struggles to equate "instrumental" with "play a roll in." The sentence structure is slightly different in the question and the key context phrase, and thus the model assumes there is no answer available. These models may improve with longer train times. 6.3 Industry Qualitative While working with industry datasets has exciting potential real-world applications, we definitely ran into our fair share of challenges. These challenges can be attributed mainly to decisions made in the preprocessing pipeline (section 4.1.2) as well as the nature of the data (section 4.1.1). 6.3.1 Preprocessing As the data we received was in the form of csv files (not quite compatible with our models), we had to come up with heuristics in order to figure out which pieces of data we could use in our model. The heuristics we described in section 4.1.2 did well to extract somewhat accurate QCA triplets, however some very evident preprocessing errors did occur, which almost definitely had a negative impact on the final performance of the model. For example: Q: "do i have to pay in dollars? im from the philippines. where are benefit cosmetics available?" A: "hi... We are Turkey based company. we have all natural product range. we have a wide range of handmade natural soaps, olive oil based beauty and bodycare soaps, massage oils, massage creams, body lotions, body butter, haircare products, clay masks, world-known Turkish rose products and many other beauty products. Based on the quantity we can do private label production. We export to 10 countries. We look for new markets and new customers. Regards, http://www.hamamtamam.com/ Note that there are 2 questions asked, and the answer ignores the first. This is just one example of the challenges of parsing. 6.3.2 Nature of the Data Other challenges arose as a result of this data being in many ways over-conversational (slang, abbreviations, etc.). For example, the abundant misspellings lead to <unk> characters being much more likely in the default model, thus warranting the use of character or sub-word embeddings. When these sub-word embeddings were implemented via our BERT + BiDAF architecture however, the misspellings often led to non-sensical subword tokenizations that hindered model performance. We did see relative success of the model on user questions related to price as well as shipping availability (product complaint related inquires usually led to a "no answer"). Example of successes below: Q: "hi.. for how much u r selling the holiday set?" A: "$72" Q: "What is the price of the POREfessional value size kit?" A: "$54" A quick caveat was that sometimes the company representative would simply respond to these price or product questions with a link to the product page, which made training a little noisy. Even so, these questions comprised roughly 15% of all the QCA triplets, so while the overall performance of our model on the industry dataset was unremarkable, it was actually quite promising to see good results on this narrow band of questions, since a system that automates responses to around 15% of direct messages could be very lucrative for a large corporation. Another data-related challenge we observed was that in SQuAD, most questions are a single sentence with a much longer context from which the answer can be found. In most of these industry examples however, the question is actually much longer than the context, and it often contains a lot of irrelevant information that may impacting the ability of the model to learn good answers. In fact, the state of the art unmodified BERT model predicted "no answer" for a large portion of the industry questions in our mixed dev dataset, which exposes a potential shortcoming in models trained on SQuAD. Such models may only be extremely effective when the question/context/answer formats match almost exactly the research formats, which is rarely true in real settings. Thus, the translation of BERT to widespread industry application may require significant per-company research, depending on their data distribution. Of note though, our BERT with BiDAF model did much better at avoiding a default "no answer" when compared to the vanilla BERT model, with 50% of our industry-only dev set achieving viable predictions. However, some of the model’s attempted responses to some of the more complex questions started with random letters or characters like ‘.,’, ‘?’, most likely resulting from misspellings, slang, and preprocessing decisions. 6.4 Challenges of Using Pre-trained BERT embeddings The BERT paper suggests that its embeddings can be used essentially out of the box for any NLP task, but as a guest lecturer noted there were a few unforeseen challenges in making the pre-trained embeddings compatible with a representative model such as BiDAF. The first challenge was in tokenization. The BERT tokenizer does not simply split by word, it further splits input into “word pieces” for tokenizing. The challenge for us was then mapping the y1s and y2s from the BiDAF input processing to the correct start and end indices within the BERT tokenized output. For example, if the sentence [i love learning] has y1 and y2 (0, 1), but BERT tokenized the input to [I love learning] after the preprocessing and data loading but before generating embeddings, the target y1 and y2 would be incorrect for this example. Furthermore, the provided BertTokenizer tokenization does not have a built in batch tokenization capability in the Pytorch repo, and thus cannot be used directly in forward passes of existing models. At first we attempted preprocessing from scratch, but the level of involvement and the discrepancies between the BiDAF and BERT representations led us to model our preprocessing after the huggingface run_squad.py [2]. The second limitation lies in the embedding size. The default 768 may have worked well on TPUs with terabytes of memory, but holding large batches with these embedding dimensions and training within a reasonable amount of time proved challenging for our combined implementation. To make our model compatible, we set the hidden size of 768 for all subsequent layers, but this limitation may not be best for all cases. Moreover, when we tried to concatenate the last four layers of BERT output as shown at the bottom of Figure 3 before passing into the RNNEncoder we ran out of memory with a batch size of just 1, since the hidden size of 3072 was simply too large for NV6 machines. 7 Conclusion and Improvements While the BERT embeddings may be powerful, they are not quite “plug and play” with models that assume GloVe embedding input. They may be effective as more developers start to use the embeddings and thus build more standard processing pipelines and memory optimizations, but for now, obtaining the reported performance may require significant additional preprocessing, prohibitively expensive resources, and modifications to a model’s architecture. The models were slow, but we believe the runtime could be significantly decreased by moving the BERT embedding generation from the train step to the preprocessing step. Despite drawbacks, BERT embeddings seem like a potential way to speed up model convergence. Additionally, we could have greatly improved our scores on industry data with more structured responses, fewer typos, and a clear bank of answers. However, these changes would require a lot of overhaul on the part of Benefit Cosmetics. This project highlights the importance of properly structured data when attempting to apply NLP research to industry problems and the resource challenges that come with adapting BERT embeddings to custom use cases. 8 Appendix We want to thank Toto Haba and his team at Benefit Cosmetics [11] for providing us with company-specific datasets that allowed us to tackle this problem of testing the limits of SOTA QA models in an industry setting. References [12] Preprocessing script to make a custom SQuAD dataset (convert a csv containing Question, Context, and Answer triplets to a JSON, formatted like SQuAD 2.0) written with the help of Chris Chute.
{"Source-Url": "http://web.stanford.edu/class/cs224n/reports/default/15791074.pdf", "len_cl100k_base": 5966, "olmocr-version": "0.1.50", "pdf-total-pages": 9, "total-fallback-pages": 0, "total-input-tokens": 20594, "total-output-tokens": 6987, "length": "2e12", "weborganizer": {"__label__adult": 0.0005702972412109375, "__label__art_design": 0.000885009765625, "__label__crime_law": 0.0006418228149414062, "__label__education_jobs": 0.0037326812744140625, "__label__entertainment": 0.0002899169921875, "__label__fashion_beauty": 0.0005660057067871094, "__label__finance_business": 0.0007090568542480469, "__label__food_dining": 0.0004191398620605469, "__label__games": 0.0009598731994628906, "__label__hardware": 0.0011749267578125, "__label__health": 0.000919342041015625, "__label__history": 0.00040793418884277344, "__label__home_hobbies": 0.00012767314910888672, "__label__industrial": 0.0007004737854003906, "__label__literature": 0.0011129379272460938, "__label__politics": 0.0005240440368652344, "__label__religion": 0.0005717277526855469, "__label__science_tech": 0.234619140625, "__label__social_life": 0.0002715587615966797, "__label__software": 0.041168212890625, "__label__software_dev": 0.70849609375, "__label__sports_fitness": 0.00034999847412109375, "__label__transportation": 0.0005521774291992188, "__label__travel": 0.00023996829986572263}, "weborganizer_max": "__label__software_dev", "avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_ratio": [[0, 29050, 0.04174]], "fineweb_edu_fasttext_gt2__fineweb_edu_fasttext_gt2__score": [[0, 29050, 0.21867]], "ft_lang_id_en_doc_v2__ft_lang_id_en_doc_v2__en": [[0, 29050, 0.92181]], "google_gemma-3-12b-it_contains_pii": [[0, 2966, false], [2966, 7095, null], [7095, 9431, null], [9431, 13611, null], [13611, 14249, null], [14249, 17722, null], [17722, 21823, null], [21823, 26588, null], [26588, 29050, null]], "google_gemma-3-12b-it_is_public_document": [[0, 2966, true], [2966, 7095, null], [7095, 9431, null], [9431, 13611, null], [13611, 14249, null], [14249, 17722, null], [17722, 21823, null], [21823, 26588, null], [26588, 29050, null]], "google_gemma-3-4b-it_v2tag__is_academic_paper": [[0, 5000, true], [5000, 29050, null]], "google_gemma-3-4b-it_v2tag__is_class_syllabus": [[0, 5000, false], [5000, 29050, null]], "google_gemma-3-4b-it_v2tag__is_completion_certificate": [[0, 5000, false], [5000, 29050, null]], "google_gemma-3-4b-it_v2tag__is_court_notice": [[0, 5000, false], [5000, 29050, null]], "google_gemma-3-4b-it_v2tag__is_homework_assignment": [[0, 5000, false], [5000, 29050, null]], "google_gemma-3-4b-it_v2tag__is_news_article": [[0, 5000, false], [5000, 29050, null]], "google_gemma-3-4b-it_v2tag__is_public_order": [[0, 5000, false], [5000, 29050, null]], "google_gemma-3-4b-it_v2tag__is_resume_cv": [[0, 5000, false], [5000, 29050, null]], "google_gemma-3-4b-it_v2tag__is_test_or_quiz": [[0, 5000, false], [5000, 29050, null]], "google_gemma-3-4b-it_v2tag__is_textbook": [[0, 5000, false], [5000, 29050, null]], "pdf_page_numbers": [[0, 2966, 1], [2966, 7095, 2], [7095, 9431, 3], [9431, 13611, 4], [13611, 14249, 5], [14249, 17722, 6], [17722, 21823, 7], [21823, 26588, 8], [26588, 29050, 9]], "pipe_delimited_lines_v1__pipe_delimited_lines_v1__pipe_delimited_lines_ratio": [[0, 29050, 0.1157]]}
olmocr_science_pdfs
2024-12-02
2024-12-02
c7d596fd72711f6d6dce9b9b05d819f165db2d8b
CS162 Operating Systems and Systems Programming Lecture 10 Scheduling February 22th, 2017 Prof. Ion Stoica http://cs162.eecs.Berkeley.edu Recall: CPU Scheduling - Earlier, we talked about the life-cycle of a thread - Active threads work their way from Ready queue to Running to various waiting queues. • Question: How does OS decide which thread to dequeue? – Obvious queue to worry about is ready queue – Others can be scheduled as well, however • **Scheduling**: deciding which threads are given access to resources from moment to moment Assumption – CPU Bursts - Execution model: programs alternate between bursts of CPU and I/O - Program typically uses the CPU for some period of time, then does I/O, then uses CPU again - Each scheduling decision is about which job to give to the CPU for use by its next CPU burst - With timeslicing, thread may be forced to give up CPU before finishing current CPU burst Scheduling Assumptions • CPU scheduling big area of research in early 70’s • Many implicit assumptions for CPU scheduling: – One program per user – One thread per program – Programs are independent Scheduling Assumptions (Cont.) • Clearly, unrealistic but they simplify the problem – For instance: is “fair” about fairness among users or programs? » If I run one compilation job and you run five, you get five times as much CPU on many operating systems • The high-level goal: Dole out CPU time to optimize some desired parameters of system Scheduling Policy Goals/Criteria • Minimize Response Time – Minimize elapsed time to do an operation (or job) – Response time is what the user sees: » Time to echo a keystroke in editor » Time to compile a program » Real-time tasks: Must meet deadlines imposed by World Scheduling Policy Goals/Criteria (Cont.) • Maximize Throughput – Maximize operations (or jobs) per second – Throughput related to response time, but not identical: » Minimizing response time will lead to more context switching than if you only maximized throughput – Two parts to maximizing throughput » Minimize overhead (for example, context-switching) » Efficient use of resources (CPU, disk, memory, etc) Scheduling Policy Goals/Criteria (Cont.) - **Fairness** - Share CPU among users in some equitable way - Fairness is not minimizing average response time: » Better *average* response time by making system *less* fair First-Come, First-Served (FCFS) Scheduling - First-Come, First-Served (FCFS) - Also “First In, First Out” (FIFO) or “Run until done” » In early systems, FCFS meant one program scheduled until done (including I/O) » Now, means keep CPU until thread blocks - Example: <table> <thead> <tr> <th>Process</th> <th>Burst Time</th> </tr> </thead> <tbody> <tr> <td>$P_1$</td> <td>24</td> </tr> <tr> <td>$P_2$</td> <td>3</td> </tr> <tr> <td>$P_3$</td> <td>3</td> </tr> </tbody> </table> - Suppose processes arrive in the order: $P_1, P_2, P_3$ The Gantt Chart for the schedule is: FCFS Scheduling (Cont.) • Example continued: <table> <thead> <tr> <th></th> <th>P₁</th> <th>P₂</th> <th>P₃</th> </tr> </thead> <tbody> <tr> <td>Time</td> <td>0</td> <td>24</td> <td>27</td> </tr> </tbody> </table> – Waiting time for $P₁ = 0$; $P₂ = 24$; $P₃ = 27$ – Average waiting time: $(0 + 24 + 27)/3 = 17$ – Average Completion time: $(24 + 27 + 30)/3 = 27$ • Convoy effect: short process behind long process FCFS Scheduling (Cont.) • Example continued: – Suppose that processes arrive in order: \(P_2, P_3, P_1\). Now, we have: <table> <thead> <tr> <th>(P_2)</th> <th>(P_3)</th> <th>(P_1)</th> </tr> </thead> <tbody> <tr> <td>0</td> <td>3</td> <td>6</td> </tr> <tr> <td>6</td> <td>0</td> <td>3</td> </tr> <tr> <td>30</td> <td></td> <td></td> </tr> </tbody> </table> – Waiting time for \(P_1\) = 6; \(P_2\) = 0; \(P_3\) = 3 – Average waiting time: \((6 + 0 + 3)/3 = 3\) – Average Completion time: \((3 + 6 + 30)/3 = 13\) • In second case: – Average waiting time is much better (before it was 17) – Average completion time is better (before it was 27) • FIFO Pros and Cons: – Simple (+) – Short jobs get stuck behind long ones (-) » Safeway: Getting milk, always stuck behind cart full of small items Round Robin (RR) Scheduling • FCFS Scheme: Potentially bad for short jobs! – Depends on submit order – If you are first in line at supermarket with milk, you don’t care who is behind you, on the other hand… • Round Robin Scheme – Each process gets a small unit of CPU time \((time\ quantum)\), usually 10-100 milliseconds – After quantum expires, the process is preempted and added to the end of the ready queue. – \(n\) processes in ready queue and time quantum is \(q\) $\Rightarrow$ » Each process gets \(1/n\) of the CPU time » In chunks of at most \(q\) time units » No process waits more than \((n-1)q\) time units RR Scheduling (Cont.) • Performance – $q$ large $\Rightarrow$ FCFS – $q$ small $\Rightarrow$ Interleaved (really small $\Rightarrow$ hyperthreading?) – $q$ must be large with respect to context switch, otherwise overhead is too high (all overhead) Example of RR with Time Quantum = 20 - Example: <table> <thead> <tr> <th>Process</th> <th>Burst Time</th> </tr> </thead> <tbody> <tr> <td>P_1</td> <td>53</td> </tr> <tr> <td>P_2</td> <td>8</td> </tr> <tr> <td>P_3</td> <td>68</td> </tr> <tr> <td>P_4</td> <td>24</td> </tr> </tbody> </table> - The Gantt chart is: <table> <thead> <tr> <th></th> <th>P_1</th> <th>P_2</th> <th>P_3</th> <th>P_4</th> <th>P_1</th> <th>P_3</th> <th>P_4</th> <th>P_1</th> <th>P_3</th> <th>P_3</th> </tr> </thead> <tbody> <tr> <td>0</td> <td>20</td> <td>28</td> <td>48</td> <td>68</td> <td>88</td> <td>108</td> <td>112</td> <td>125</td> <td>145</td> <td>153</td> </tr> </tbody> </table> - Waiting time for - \( P_1 = (68-20) + (112-88) = 72 \) - \( P_2 = (20-0) = 20 \) - \( P_3 = (28-0) + (88-48) + (125-108) = 85 \) - \( P_4 = (48-0) + (108-68) = 88 \) - Average waiting time = (72+20+85+88)/4 = 66¼ - Average completion time = (125+28+153+112)/4 = 104½ - Thus, Round-Robin Pros and Cons: - Better for short jobs, Fair (+) - Context-switching time adds up for long jobs (-) Round-Robin Discussion • How do you choose time slice? – What if too big? » Response time suffers – What if infinite (∞)? » Get back FIFO – What if time slice too small? » Throughput suffers! • Actual choices of timeslice: – Initially, UNIX timeslice one second: » Worked ok when UNIX was used by one or two people. » What if three compilations going on? 3 seconds to echo each keystroke! – Need to balance short-job performance and long-job throughput: » Typical time slice today is between 10ms – 100ms » Typical context-switching overhead is 0.1ms – 1ms » Roughly 1% overhead due to context-switching Comparisons between FCFS and Round Robin - Assuming zero-cost context-switching time, is RR always better than FCFS? - Simple example: - 10 jobs, each take 100s of CPU time - RR scheduler quantum of 1s - All jobs start at the same time - Completion Times: <table> <thead> <tr> <th>Job #</th> <th>FIFO</th> <th>RR</th> </tr> </thead> <tbody> <tr> <td>1</td> <td>100</td> <td>991</td> </tr> <tr> <td>2</td> <td>200</td> <td>992</td> </tr> <tr> <td>...</td> <td>...</td> <td>...</td> </tr> <tr> <td>9</td> <td>900</td> <td>999</td> </tr> <tr> <td>10</td> <td>1000</td> <td>1000</td> </tr> </tbody> </table> - Both RR and FCFS finish at the same time - Average response time is much worse under RR! » Bad when all jobs same length - Also: Cache state must be shared between all jobs with RR but can be devoted to each job with FIFO - Total time for RR longer even for zero-cost switch! ### Earlier Example with Different Time Quantum **Quantum Completion Time** <table> <thead> <tr> <th></th> <th>P_2</th> <th>P_4</th> <th>P_1</th> <th>P_3</th> <th></th> </tr> </thead> <tbody> <tr> <td>0</td> <td>8</td> <td>32</td> <td>85</td> <td>8</td> <td>153</td> </tr> </tbody> </table> #### Best FCFS: <table> <thead> <tr> <th>Quantum</th> <th>P_1</th> <th>P_2</th> <th>P_3</th> <th>P_4</th> <th>Average</th> </tr> </thead> <tbody> <tr> <td>Best FCFS</td> <td>32</td> <td>0</td> <td>85</td> <td>8</td> <td>31 1/4</td> </tr> <tr> <td>Q = 1</td> <td>84</td> <td>22</td> <td>85</td> <td>57</td> <td>62</td> </tr> <tr> <td>Q = 5</td> <td>82</td> <td>20</td> <td>85</td> <td>58</td> <td>61 1/4</td> </tr> <tr> <td>Q = 8</td> <td>80</td> <td>8</td> <td>85</td> <td>56</td> <td>57 1/4</td> </tr> <tr> <td>Q = 10</td> <td>82</td> <td>10</td> <td>85</td> <td>68</td> <td>61 1/4</td> </tr> <tr> <td>Q = 20</td> <td>72</td> <td>20</td> <td>85</td> <td>88</td> <td>66 1/4</td> </tr> <tr> <td>Worst FCFS</td> <td>68</td> <td>145</td> <td>0</td> <td>121</td> <td>83 1/2</td> </tr> </tbody> </table> #### Worst FCFS: <table> <thead> <tr> <th>Quantum</th> <th>P_1</th> <th>P_2</th> <th>P_3</th> <th>P_4</th> <th>Average</th> </tr> </thead> <tbody> <tr> <td>Best FCFS</td> <td>85</td> <td>8</td> <td>153</td> <td>32</td> <td>69 1/2</td> </tr> <tr> <td>Q = 1</td> <td>137</td> <td>30</td> <td>153</td> <td>81</td> <td>100 1/2</td> </tr> <tr> <td>Q = 5</td> <td>135</td> <td>28</td> <td>153</td> <td>82</td> <td>99 1/2</td> </tr> <tr> <td>Q = 8</td> <td>133</td> <td>16</td> <td>153</td> <td>80</td> <td>95 1/2</td> </tr> <tr> <td>Q = 10</td> <td>135</td> <td>18</td> <td>153</td> <td>92</td> <td>99 1/2</td> </tr> <tr> <td>Q = 20</td> <td>125</td> <td>28</td> <td>153</td> <td>112</td> <td>104 1/2</td> </tr> <tr> <td>Worst FCFS</td> <td>121</td> <td>153</td> <td>68</td> <td>145</td> <td>121 3/4</td> </tr> </tbody> </table> Handling Differences in Importance: Strict Priority Scheduling - **Execution Plan** - Always execute highest-priority runnable jobs to completion - Each queue can be processed in RR with some time-quantum - **Problems:** - **Starvation:** - Lower priority jobs don’t get to run because higher priority jobs - **Deadlock: Priority Inversion** - Not strictly a problem with priority scheduling, but happens when low priority task has lock needed by high-priority task - Usually involves third, intermediate priority task that keeps running even though high-priority task should be running Handling Differences in Importance: Strict Priority Scheduling (Cont.) • How to fix problems? – Dynamic priorities – adjust base-level priority up or down based on heuristics about interactivity, locking, burst behavior, etc… Scheduling Fairness • What about fairness? – Strict fixed-priority scheduling between queues is unfair (run highest, then next, etc): » long running jobs may never get CPU » In Multics, shut down machine, found 10-year-old job – Must give long-running jobs a fraction of the CPU even when there are shorter jobs to run – Tradeoff: fairness gained by hurting avg response time! Scheduling Fairness • How to implement fairness? – Could give each queue some fraction of the CPU » What if one long-running job and 100 short-running ones? » Like express lanes in a supermarket—sometimes express lanes get so long, get better service by going into one of the other lines – Could increase priority of jobs that don’t get service » What is done in some variants of UNIX » This is ad hoc—what rate should you increase priorities? » And, as system gets overloaded, no job gets CPU time, so everyone increases in priority⇒Interactive jobs suffer Administrivia • Midterm on **Monday 2/27 6:30-8PM** – Last names **A-K** 1 LeConte – **Last names L-T** 245 Li Ka Shing – Last Names **U-Z** 3 Leconte • Includes today’s lecture • Closed book, no calculators, **one double-side letter-sized page of handwritten notes** • Review – Saturday, 2/25 3-6pm 145 Dwinelle BREAK Lottery Scheduling - Yet another alternative: Lottery Scheduling - Give each job some number of lottery tickets - On each time slice, randomly pick a winning ticket - On average, CPU time is proportional to number of tickets given to each job - How to assign tickets? - To approximate SRTF, short running jobs get more, long running jobs get fewer - To avoid starvation, every job gets at least one ticket (everyone makes progress) - Advantage over strict priority scheduling: behaves gracefully as load changes - Adding or deleting a job affects all jobs proportionally, independent of how many tickets each job possesses Lottery Scheduling Example (Cont.) - Lottery Scheduling Example - Assume short jobs get 10 tickets, long jobs get 1 ticket <table> <thead> <tr> <th># short jobs/ # long jobs</th> <th>% of CPU each short jobs gets</th> <th>% of CPU each long jobs gets</th> </tr> </thead> <tbody> <tr> <td>1/1</td> <td>91%</td> <td>9%</td> </tr> <tr> <td>0/2</td> <td>N/A</td> <td>50%</td> </tr> <tr> <td>2/0</td> <td>50%</td> <td>N/A</td> </tr> <tr> <td>10/1</td> <td>9.9%</td> <td>0.99%</td> </tr> <tr> <td>1/10</td> <td>50%</td> <td>5%</td> </tr> </tbody> </table> - What if too many short jobs to give reasonable response time? - If load average is 100, hard to make progress - One approach: log some user out How to Evaluate a Scheduling algorithm? - Deterministic modeling - takes a predetermined workload and compute the performance of each algorithm for that workload - Queueing models - Mathematical approach for handling stochastic workloads - Implementation/Simulation: - Build system which allows actual algorithms to be run against actual data – most flexible/general How to Handle Simultaneous Mix of Diff Types of Apps? • Can we use Burst Time (observed) to decide which application gets CPU time? • Consider mix of interactive and high throughput apps: – How to best schedule them? – How to recognize one from the other? » Do you trust app to say that it is “interactive”? – Should you schedule the set of apps identically on servers, workstations, pads, and cellphones? How to Handle Simultaneous Mix of Diff Types of Apps? • Assumptions encoded into many schedulers: – Apps that sleep a lot and have short bursts must be interactive apps – they should get high priority – Apps that compute a lot should get low(er?) priority, since they won't notice intermittent bursts from interactive apps • Hard to characterize apps: – What about apps that sleep for a long time, but then compute for a long time? – Or, what about apps that must run under all circumstances (say periodically) What if we Knew the Future? • Could we always mirror best FCFS? • Shortest Job First (SJF): – Run whatever job has least amount of computation to do – Sometimes called “Shortest Time to Completion First” (STCF) • Shortest Remaining Time First (SRTF): – Preemptive version of SJF: if job arrives and has a shorter time to completion than the remaining time on the current job, immediately preempt CPU – Sometimes called “Shortest Remaining Time to Completion First” (SRTCF) • These can be applied to whole program or current CPU burst – Idea is to get short jobs out of the system – Big effect on short jobs, only small effect on long ones – Result is better average response time Discussion • SJF/SRTF are the best you can do at minimizing average response time – Provably optimal (SJF among non-preemptive, SRTF among preemptive) – Since SRTF is always at least as good as SJF, focus on SRTF • Comparison of SRTF with FCFS and RR – What if all jobs the same length? » SRTF becomes the same as FCFS (i.e. FCFS is best can do if all jobs the same length) – What if jobs have varying length? » SRTF (and RR): short jobs not stuck behind long ones Example to illustrate benefits of SRTF - Three jobs: - A, B: both CPU bound, run for week - C: I/O bound, loop 1ms CPU, 9ms disk I/O - If only one at a time, C uses 90% of the disk, A or B could use 100% of the CPU - With FIFO: - Once A or B get in, keep CPU for two weeks - What about RR or SRTF? - Easier to see with a timeline SRTF Example continued: RR 100ms time slice RR 1ms time slice CABAB… Disk Utilization: ~90% but lots of wakeups! Disk Utilization: 9/201 ~ 4.5% Disk Utilization: 90% SRTF Further discussion • Starvation – SRTF can lead to starvation if many small jobs! – Large jobs never get to run • Somehow need to predict future – How can we do this? – Some systems ask the user » When you submit a job, have to say how long it will take » To stop cheating, system kills job if takes too long – But: hard to predict job’s runtime even for non-malicious users • Bottom line, can’t really know how long job will take – However, can use SRTF as a yardstick for measuring other policies – Optimal, so can’t do any better • SRTF Pros & Cons – Optimal (average response time) (+) – Hard to predict future (-) – Unfair (-) Predicting the Length of the Next CPU Burst - **Adaptive**: Changing policy based on past behavior - CPU scheduling, in virtual memory, in file systems, etc - Works because programs have predictable behavior - If program was I/O bound in past, likely in future - If computer behavior were random, wouldn’t help - **Example**: SRTF with estimated burst length - Use an estimator function on previous bursts: - Let \( t_{n-1}, t_{n-2}, t_{n-3}, \) etc. be previous CPU burst lengths. Estimate next burst \( \tau_n = f(t_{n-1}, t_{n-2}, t_{n-3}, \ldots) \) - Function \( f \) could be one of many different time series estimation schemes (Kalman filters, etc) - For instance, exponential averaging \[ \tau_n = \alpha t_{n-1} + (1-\alpha)\tau_{n-1} \] with \((0 < \alpha \leq 1)\) Multi-Level Feedback Scheduling • Another method for exploiting past behavior (first use in CTSS) – Multiple queues, each with different priority » Higher priority queues often considered “foreground” tasks – Each queue has its own scheduling algorithm » e.g. foreground – RR, background – FCFS » Sometimes multiple RR priorities with quantum increasing exponentially (highest: 1ms, next: 2ms, next: 4ms, etc) • Adjust each job’s priority as follows (details vary) – Job starts in highest priority queue – If timeout expires, drop one level – If timeout doesn’t expire, push up one level (or to top) • Result approximates SRTF: – CPU bound jobs drop like a rock – Short-running I/O bound jobs stay near top • Scheduling must be done between the queues – Fixed priority scheduling: » serve all from highest priority, then next priority, etc. – Time slice: » each queue gets a certain amount of CPU time » e.g., 70% to highest, 20% next, 10% lowest • **Countermeasure**: user action that can foil intent of OS designers – For multilevel feedback, put in a bunch of meaningless I/O to keep job’s priority high – Of course, if everyone did this, wouldn’t work! • Example of Othello program: – Playing against competitor, so key was to do computing at higher priority the competitors. > Put in `printf`'s, ran much faster! Summary (1 of 2) - **Round-Robin Scheduling:** - Give each thread a small amount of CPU time when it executes; cycle between all ready threads - Pros: Better for short jobs - **Shortest Job First (SJF) / Shortest Remaining Time First (SRTF):** - Run whatever job has the least amount of computation to do/least remaining amount of computation to do - Pros: Optimal (average response time) - Cons: Hard to predict future, Unfair • **Lottery Scheduling:** – Give each thread a priority-dependent number of tokens (short tasks ⇒ more tokens) • **Multi-Level Feedback Scheduling:** – Multiple queues of different priorities and scheduling algorithms – Automatic promotion/demotion of process priority in order to approximate SJF/SRTF
{"Source-Url": "https://cs162.eecs.berkeley.edu/static/lectures/10.pdf", "len_cl100k_base": 5915, "olmocr-version": "0.1.53", "pdf-total-pages": 41, "total-fallback-pages": 0, "total-input-tokens": 64395, "total-output-tokens": 7028, "length": "2e12", "weborganizer": {"__label__adult": 0.00035071372985839844, "__label__art_design": 0.0007243156433105469, "__label__crime_law": 0.0005097389221191406, "__label__education_jobs": 0.02587890625, "__label__entertainment": 0.0001316070556640625, "__label__fashion_beauty": 0.0002046823501586914, "__label__finance_business": 0.0005345344543457031, "__label__food_dining": 0.000492095947265625, "__label__games": 0.0007944107055664062, "__label__hardware": 0.0032672882080078125, "__label__health": 0.0007143020629882812, "__label__history": 0.0004198551177978515, "__label__home_hobbies": 0.0002455711364746094, "__label__industrial": 0.0011320114135742188, "__label__literature": 0.0003764629364013672, "__label__politics": 0.0004239082336425781, "__label__religion": 0.0006513595581054688, "__label__science_tech": 0.154541015625, "__label__social_life": 0.0002791881561279297, "__label__software": 0.03741455078125, "__label__software_dev": 0.76953125, "__label__sports_fitness": 0.0003266334533691406, "__label__transportation": 0.0007472038269042969, "__label__travel": 0.00026679039001464844}, "weborganizer_max": "__label__software_dev", "avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_ratio": [[0, 18430, 0.04227]], "fineweb_edu_fasttext_gt2__fineweb_edu_fasttext_gt2__score": [[0, 18430, 0.25234]], "ft_lang_id_en_doc_v2__ft_lang_id_en_doc_v2__en": [[0, 18430, 0.86965]], "google_gemma-3-12b-it_contains_pii": [[0, 140, false], [140, 307, null], [307, 550, null], [550, 928, null], [928, 1133, null], [1133, 1484, null], [1484, 1771, null], [1771, 2199, null], [2199, 2424, null], [2424, 2937, null], [2937, 3278, null], [3278, 3937, null], [3937, 4582, null], [4582, 4837, null], [4837, 5669, null], [5669, 6317, null], [6317, 7041, null], [7041, 8088, null], [8088, 8697, null], [8697, 8926, null], [8926, 9318, null], [9318, 9901, null], [9901, 10224, null], [10224, 10230, null], [10230, 10868, null], [10868, 11809, null], [11809, 12183, null], [12183, 12601, null], [12601, 13122, null], [13122, 13829, null], [13829, 14312, null], [14312, 14655, null], [14655, 14827, null], [14827, 15227, null], [15227, 15494, null], [15494, 16311, null], [16311, 16935, null], [16935, 17302, null], [17302, 17682, null], [17682, 18122, null], [18122, 18430, null]], "google_gemma-3-12b-it_is_public_document": [[0, 140, true], [140, 307, null], [307, 550, null], [550, 928, null], [928, 1133, null], [1133, 1484, null], [1484, 1771, null], [1771, 2199, null], [2199, 2424, null], [2424, 2937, null], [2937, 3278, null], [3278, 3937, null], [3937, 4582, null], [4582, 4837, null], [4837, 5669, null], [5669, 6317, null], [6317, 7041, null], [7041, 8088, null], [8088, 8697, null], [8697, 8926, null], [8926, 9318, null], [9318, 9901, null], [9901, 10224, null], [10224, 10230, null], [10230, 10868, null], [10868, 11809, null], [11809, 12183, null], [12183, 12601, null], [12601, 13122, null], [13122, 13829, null], [13829, 14312, null], [14312, 14655, null], [14655, 14827, null], [14827, 15227, null], [15227, 15494, null], [15494, 16311, null], [16311, 16935, null], [16935, 17302, null], [17302, 17682, null], [17682, 18122, null], [18122, 18430, null]], "google_gemma-3-4b-it_v2tag__is_academic_paper": [[0, 5000, true], [5000, 18430, null]], "google_gemma-3-4b-it_v2tag__is_class_syllabus": [[0, 5000, false], [5000, 18430, null]], "google_gemma-3-4b-it_v2tag__is_completion_certificate": [[0, 5000, false], [5000, 18430, null]], "google_gemma-3-4b-it_v2tag__is_court_notice": [[0, 5000, false], [5000, 18430, null]], "google_gemma-3-4b-it_v2tag__is_homework_assignment": [[0, 5000, false], [5000, 18430, null]], "google_gemma-3-4b-it_v2tag__is_news_article": [[0, 5000, false], [5000, 18430, null]], "google_gemma-3-4b-it_v2tag__is_public_order": [[0, 5000, false], [5000, 18430, null]], "google_gemma-3-4b-it_v2tag__is_resume_cv": [[0, 5000, false], [5000, 18430, null]], "google_gemma-3-4b-it_v2tag__is_test_or_quiz": [[0, 5000, false], [5000, 18430, null]], "google_gemma-3-4b-it_v2tag__is_textbook": [[0, 5000, false], [5000, 18430, null]], "pdf_page_numbers": [[0, 140, 1], [140, 307, 2], [307, 550, 3], [550, 928, 4], [928, 1133, 5], [1133, 1484, 6], [1484, 1771, 7], [1771, 2199, 8], [2199, 2424, 9], [2424, 2937, 10], [2937, 3278, 11], [3278, 3937, 12], [3937, 4582, 13], [4582, 4837, 14], [4837, 5669, 15], [5669, 6317, 16], [6317, 7041, 17], [7041, 8088, 18], [8088, 8697, 19], [8697, 8926, 20], [8926, 9318, 21], [9318, 9901, 22], [9901, 10224, 23], [10224, 10230, 24], [10230, 10868, 25], [10868, 11809, 26], [11809, 12183, 27], [12183, 12601, 28], [12601, 13122, 29], [13122, 13829, 30], [13829, 14312, 31], [14312, 14655, 32], [14655, 14827, 33], [14827, 15227, 34], [15227, 15494, 35], [15494, 16311, 36], [16311, 16935, 37], [16935, 17302, 38], [17302, 17682, 39], [17682, 18122, 40], [18122, 18430, 41]], "pipe_delimited_lines_v1__pipe_delimited_lines_v1__pipe_delimited_lines_ratio": [[0, 18430, 0.14961]]}
olmocr_science_pdfs
2024-12-09
2024-12-09
a6a0cef2556cf3524b9d96b4e1b5edd14a61325f
Debugging Much of your time as a computer programmer will likely be spent debugging. This phenomenon is best described by a quotation from one of the first computer pioneers, Maurice Wilkes: As soon as we started programming, we found to our surprise that it wasn’t as easy to get programs right as we had thought. We had to discover debugging. I can remember the exact instant when I realized that a large part of my life from then on was going to be spent in finding mistakes in my own programs. — Maurice Wilkes, 1949 In order to be better prepared to undertake the more complex future debugging that you will be doing, we aim to give you here both a sense of the philosophy of debugging as well as to teach you how to use some of the practical tips that make testing and debugging easier. The Philosophy of Debugging Debugging is one of the most creative and intellectually challenging aspects of programming. It can also be one of the most frustrating. To a large extent, the problems that people face debugging programs are not so much technical as they are psychological. To become successful debuggers, you must learn to think in a different way. There is no cookbook approach to debugging, although Nick Parlante’s 11 Truths of Debugging (given below) will probably help. What you need is insight, creativity, logic, and determination. As computer scientists, it is important to remember that the programming process leads you through a series of tasks and roles: <table> <thead> <tr> <th>Task</th> <th>—</th> <th>Role</th> </tr> </thead> <tbody> <tr> <td>Design</td> <td>—</td> <td>Architect</td> </tr> <tr> <td>Coding</td> <td>—</td> <td>Engineer</td> </tr> <tr> <td>Testing</td> <td>—</td> <td>Vandal</td> </tr> <tr> <td>Debugging</td> <td>—</td> <td>Detective</td> </tr> </tbody> </table> These roles require you to adopt distinct strategies and goals, and it is often difficult to shift your perspective from one to another. Although debugging can often be very difficult, it can be done. It will at times take all of the skill and creativity at your disposal, but you can succeed if you are methodical and do not give up on the task. Debugging is an important skill that you will use every day if you continue in Computer Science or any related field. Even though it is the final task of those listed above, it is certainly not the least important. You should always plan ahead and allow sufficient time for testing and debugging, as it is required if you expect to produce quality software. In addition, you should make a concentrated effort to develop these skills now, as they will be even more important as programs become more complicated later in the quarter. The 11 Truths of Debugging 1. Intuition and hunches are great—you just have to test them out. When a hunch and a fact collide, the fact wins. That's life in the city. 2. Don’t look for complex explanations. Even the simplest omission or typo can lead to very weird behavior. Everyone is capable producing extremely simple and obvious errors from time to time. Look at code critically—don’t just sweep your eye over that series of simple statements assuming that they are too simple to be wrong. 3. The clue to what is wrong in your code is in the values of your variables and the flow of control. Try to see what the facts are pointing to. The computer is not trying to mislead you. Work from the facts. 4. Be systematic and persistent. Don’t panic. The bug is not moving around in your code, trying to trick or evade you. It is just sitting in one place, doing the wrong thing in the same way every time. 5. If your code was working a minute ago, but now it doesn’t—what was the last thing you changed? This incredibly reliable rule of thumb is the reason your section leader told you to test your code as you go rather than all at once. 6. Do not change your code haphazardly trying to track down a bug. This is sort of like a scientist who changes more than one variable in an experiment at a time. It makes the observed behavior much more difficult to interpret, and you tend to introduce new bugs. 7. If you find some wrong code that does not seem to be related to the bug you were tracking, fix the wrong code anyway. Many times the wrong code was related to or obscured the bug in a way you had not imagined. 8. You should be able to explain in Sherlock Holmes style the series of facts, tests, and deductions that led you to find a bug. Alternately, if you have a bug but can’t pinpoint it, then you should be able to give an argument to a critical third party detailing why each one of your functions cannot contain the bug. One of these arguments will contain a flaw since one of your functions does in fact contain a bug. Trying to construct the arguments may help you to see the flaw. 9. Be critical of your beliefs about your code. It’s almost impossible to see a bug in a function when your instinct is that the function is innocent. Only when the facts have proven without question that the function is not the source of the problem should you assume it to be correct. 10. Although you need to be systematic, there is still an enormous amount of room for beliefs, hunches, guesses, etc. Use your intuition about where the bug probably is to direct the order that you check things in your systematic search. Check the functions you suspect the most first. Good instincts will come with experience. 11. Debugging depends on an objective and reasoned approach. It depends on overall perspective and understanding of the workings of your code. Debugging code is more mentally demanding than writing code. The longer you try to track down a bug without success, the less perspective you tend to have. Realize when you have lost the perspective on your code to debug. Take a break. Get some sleep. You cannot debug when you are not seeing things clearly. Many times a programmer can spend hours late at night hunting for a bug only to finally give up at 4:00 A.M. The next day, they find the bug in 10 minutes. What allowed them to find the bug the next day so quickly? Maybe they just needed some sleep and time for perspective. Or maybe their subconscious figured it out while they were asleep. In any case, the “go do something else for a while, come back, and find the bug immediately” scenario happens too often to be an accident. — Nick Parlante, Stanford University Using a Debugger Because debugging is a difficult but nonetheless critical task, it is important to learn the tricks of the trade. The most important of these tricks is to get the computer to show you what it is doing, which is the key to debugging. The computer, after all, is there in front of you. You can watch it work. You cannot ask the computer why it is not working, but you can have it show you its work as it goes. Modern programming environments like Eclipse come equipped with a debugger, which is a special facility for monitoring a program as it runs. Using the debugger helps you build up a good sense of what your program is doing, and often points the way to the mistake. To illustrate the operation of the Eclipse debugger in as concrete a way as possible, let us look at how we might use the debugger to find bugs in the GuessYourNumber.java program shown in Figure 2 below. As the bug icon indicates, the program is buggy. As a programmer, it is your job to figure out why. The remainder of this handout describes the techniques we might use to look for bugs with the help of the Eclipse debugger. Tip: follow along! The Eclipse project containing the GuessYourNumber.java program is on the course website, alongside this handout in the “Handouts” tab. The general idea for this program is to ask the user for the range containing their secret number, and then keep narrowing in the range until we end up with one number that must be the user’s guess. The program will always guess the \textit{midpoint} of the current range of possible numbers. Assessing the symptoms Before we start using the debugger, it is always valuable to run the program to get a sense of what the problems might be. If we run it with a secret number of 3, we might see: Even though the program is “running,” the results do not look so good. The problem is that we told the program that our secret number is between 0 and 10, but the program immediately guesses -5. Something is definitely wrong. The Eclipse Debugger One of the easiest ways to figure out what the program is doing is to use the Eclipse debugger. When you run a project under Eclipse, you can use the debugger to set breakpoints in your code, which tells the debugger to pause on that line and await further instructions. This enables you to step through the program one step at a time, examine variables, and do other useful things. Debugging, however, is a creative enterprise, and there is no magic technique that tells you what to do. You need to use your intuition, guided by the data that you have. In the GuessYourNumber program, intuition is likely to suggest that the problem has something to do with coming up with a guess. Thus, we might set a breakpoint on line 27, inside the while loop, so that the program will stop there. To do so, double-click in the just barely gray margin at that line, at which point a small circle appears indicating that there is now a breakpoint on that line, as shown: Once we have set the breakpoint, our next step is to run the program as normal, with the running person icons. The program will start and ask us to enter our secret number’s bounds. Suppose that we again enter 0 and 10. At that point, the program enters the while loop, where it stops at the breakpoint as shown below. (Note that you may first see a dialog box which says "This kind of launch is configured to open the Stanford Debugger perspective when it suspends. Do you want to open this perspective now?" If you do see this dialog, go ahead and click "Yes".) The arrow and the highlight mark the line of code that is *about to execute*. There is a lot more information displayed in Eclipse’s debugging perspective as well. The “Debug” pane at the upper left, for instance, shows the execution history of the program. These lines tell us where we are in the execution. We are currently at line 27 of *findNumber*, which was called from line 16 of *run*. Each of these constitutes a stack frame, as described in the text. The pane on the upper right is the “Variables” pane, which allows us to see the current values of variables in the current stack frame: In this frame, the local variables are simply the parameters to `findNumber`. We entered the bounds 0 and 10, so those are stored here. But – wait a minute – the lower and upper bounds seem to be flipped. Why does this frame show the lower bound as 10 and the upper bound as 0? Clearly the computer is doing something wrong. In point of fact, that diagnosis—tempting as it sometimes is for all of us—is almost certainly incorrect. The computer is almost certainly doing exactly what we told it to do. The problem is that the programmer has done something wrong. The task now is to find out what that is. The problem is obviously earlier in the program than intuition might suggest—perhaps we are storing the bounds incorrectly—so it is necessary to go back and insert an earlier breakpoint. We can now go back and stop the `GuessYourNumber` program, either by clicking in its close box or by clicking on the terminate button (red square) in the top toolbar. Double click in the margin on line 13, the first line of `run`, to put a breakpoint there. If we debug the program again, it will soon stop in the following state: ``` public void run() { println("I will guess your number!"); int lowest = readInt("Lower bound (inclusive)? "); int highest = readInt("Upper bound (inclusive)? "); int answer = findNumber(highest, lowest); println("Ha! I knew your number was " + answer + ")"); println("Ha! I knew your number was " + answer + "); } ``` Finding the critical clues As always in debugging, our primary goal is to figure out what the program is doing rather than why is it not doing what we wanted. To do so, we need to gather as much information as possible, and Eclipse offers great tools for doing so. The most useful tools at this point are the various controls that appear along the top of the main window, of which the following are the most important: - **Resume.** Continues the program from where it last stopped, either because of hitting a breakpoint or because the user clicked **Suspend.** **Suspend.** Stops the program immediately as if it had hit a breakpoint. **Terminate.** Exits from the program entirely. **Step Into.** Executes one statement of the program and then stops again. If that statement includes a method call, the program will stop at the first line of that method. As noted below, this option is not as useful as **Step Over**. **Step Over.** Executes one statement of the program at this level and then stops again. Any method calls in the statement are executed through to completion unless they contain explicit breakpoints. **Step Return.** Continues to execute this method until it returns, after which the debugger stops in the caller (the method that called the current method). The three stepping options are extremely useful, but you need to take some care in choosing which one to use. In most cases, **Step Over** is the right option to use. Intuitively, it has the effect of continuing to the next step at this method level, allowing you to stay at the same conceptual level of abstraction. If the current statement calls one of your own methods, **Step Into** may be exactly what you want, because that will allow you to debug that subsidiary method if necessary. The danger with **Step Into** arises when the current statement contains calls to library methods such as `println`. In such cases, **Step Into** will try to step through the code for those methods, which can be extremely confusing. We would like to step through each line of the `run` method to make sure we are handling the bounds correctly. Therefore, **Step Over** is the best choice. If we select that, **“I will guess your number!”** will be printed to the console, followed by the debugger stopping at the next line: ![Code snippet](image) Click **Step Over** once more to execute the line asking the user for the lower bound, and notice that the debugger does not pause on the next line. Why is this? `readInt` has not finished executing! Back in the program window, the program is now prompting us for a number. Remember that `readInt` executes until we enter a number and press ENTER. If we enter the lower bound `0` followed by ENTER, the debugger will now pause on line 15. If we take a look at the Variables pane, things look ok so far; the variable lowest is correctly storing the value `0` that we just entered. Press **Step Over** once more, enter the upper bound 10, and the debugger should now pause on line 16. If we take a look at the Variables pane again, the variable `highest` correctly has value 10. This all looks correct; so what gives? It might be that the issue is in calling `findNumber`. We would like to now step the debugger into the method `findNumber` to execute each line there one at a time. To do this, with the debugger stopped at the line where `findNumber` is called, click **Step Into** to go into the `findNumber` method. The debugger should now be paused on the first line of `findNumber`, line 26. (If we had instead clicked **Step Over**, the debugger would have executed the entire `findNumber` method, and paused again only once it reaches line 17 – the next line in the same method - which is not what we want). Here, we find something interesting; if we look at the Variables pane, we notice that the lower and upper bound values have swapped! That is strange; they were just correct a moment ago in the `run` method…but very soon, the problem will jump out. The values in `run` were stored correctly, but they were passed as parameters in the wrong order to \texttt{findNumber}! \texttt{findNumber} expects the first parameter value to be the \textit{lower} bound, and the second parameter to be the \textit{upper} bound. It is easy to realize this because we have a descriptive comment and variable names for \texttt{findNumber}. So we need to rewrite line 16 in \texttt{run} as follows: \begin{verbatim} int answer = findNumber(lowest, highest); \end{verbatim} Now, after making this change, an important next step is to \textit{immediately confirm} that this change fixes the issue we saw. An easy way to do this is to remove all existing breakpoints (double-click on a breakpoint dot to remove it) and add a new one at line 26, which is the start of \texttt{findNumber}. This way, we can instantly verify that \texttt{findNumber} has the correct bounds values. Run the program with bounds values 0 and 10 once more, and…. Yes! The bounds values are correct. Good job, bug-hunter! Now, let us try running the program without any breakpoints, with the same bounds of 0 and 10. Initially, it looks good! The program’s first guess is 5, which is exactly what we expect given that the program always guesses the midpoint of the current bounds. Continue, assuming our secret value is 8. Enter -1 to indicate that 5 is too low. However, the next guess is lower, which does not make sense since we just told the program that 5 was already too low. Alright, time to put on our debugger hats once more. From the previous bug we fixed, we know that `findNumber` is receiving the correct bounds values. This helps us narrow down the problem to be somewhere in `findNumber`. This is an important tactic; do your best to narrow down the possible place(s) in your program where the bug could be coming from. If you can eliminate entire blocks of code or even entire methods by confirming they work correctly, it will go a long way in helping you track down the issue. With this in mind, a reasonable guess for the location of this bug might be line 27, where the program calculates its next guess. Put a breakpoint there and run the program with the same bounds of 0 and 10. The debugger should stop on the line like so: ``` int guess = (upperBound - lowerBound) / 2; ``` Now, we can step through each line of `findNumber` to find out what is going on. If we press **Step Over**, the debugger jumps to line 30, since it steps to the next line of code (it skips comments and blank space). In the Variables pane, we can see that `guess` has now been created with value 5, which we previously said was correct. If we click **Step Over** once more, the debugger will wait for us to enter a response in the program window. For a secret number of 8, we enter -1 to indicate that the guess 5 is too low. The debugger will now pause at the if statement on line 31. From the Variables pane, we see that `check` has value -1, which is correct. So if we press **Step Over** now, the debugger will enter the body of this if statement because the condition `check == -1` evaluates to true. This is a neat benefit of the debugger; we can see exactly the flow of our program through our loops and conditionals. This line that we are about to execute makes sense; if the program’s guess was too low, then the smallest that the user’s secret number can be is guess + 1. Press Step Over to confirm that lowerBound’s value is indeed updated to 6; the debugger even highlights the change in yellow in the Variables pane! At this point, the debugger is paused on line 33 with the else if statement. However, if we press Step Over once more, the debugger will jump back up to the while loop statement. The reason for this is, since the if statement condition evaluated to true, we evaluate the if statement body and then skip the else if and the else. Press Step Over again to once again stop on line 27, where the next guess is calculated. From the Variables pane, we can see that our bounds values are correct: 6 and 10. But if we press Step Over and check the value of the newly-created variable guess (remember guess goes away at the end of each time around the while loop, and is re-created again later because of its scope), we see that it has value 2! In this case, the way in which the difficulty of seeing the bug manifests itself has to do with thinking too literally about the expressions as we have written them, seeing them as what we want them to mean as opposed to what they in fact do mean. We want the next guess to be the midpoint of the lower and upper bounds. But the equation on line 27 finds half the difference between the two bounds, which only calculates the correct value when the lower bound is 0. This is why the first guess seemed ok! But once we say that 5 is too low, the lower bound changes to 6 and this equation no longer calculates reasonable values. If we instead take the average of the two bounds, we should always get the correct value. Thus, line 27 should be: ``` int guess = (upperBound + lowerBound) / 2; ``` We just touched on another important debugging tactic, as mentioned in the 11 Truths of Debugging. Make sure that you can explain why the proposed change will fix the problem before you make the change. Do not simply make changes to see if they fix the problem; you should know beforehand what the outcome will be. Otherwise, you risk making unnecessary modifications and introducing additional bugs. Go ahead and terminate the program, leaving the breakpoint on line 27 in, and run it once more to confirm that our change fixed the issue. Enter 0 and 10 as the bounds, after which the debugger should pause on line 27. This time, we have already stepped through the next lines, so click the green Resume button; this tells the debugger to keep executing until it hits our breakpoint again. The program should keep running; pretend our secret number is 9, and enter a -1 to indicate 5 is too high. The debugger again hits our breakpoint and pauses; this time, press Step Over to see what the value of guess is. 8! Hooray! This is exactly what we expect, since this is the midpoint of the new bounds 6 and 10. And sure enough, if we remove the breakpoint, press Resume, and continue playing with 9 as our mystery number, the program should continue making reasonable guesses until it narrows in on 9. **Note:** one step command this tutorial did not touch on was **Step Return**. **Step Return** tells the debugger to continue executing the method it is currently in, and pause at the line that **called** this method. As a concrete example, if we have a breakpoint somewhere in `findNumber` and we press **Step Return**, the debugger would continue executing the rest of `findNumber`, and pause again on line 16 (which has already been executed), which is where this method was called from. Essentially, as opposed to **Step Into**, which tells the debugger to go down a level in your code, **Step Return** tells the debugger to go up a level. **Additional Note:** the other debug control not touched on was **Suspend**. **Suspend** will immediately pause your program, wherever it is, as though it hit a breakpoint. This is not used as often (because usually you know where you would like to pause your program), but is useful for debugging things like infinite loops. If you think your program is infinite looping, for instance, you can press **Suspend** and the debug view will show you what line of code is currently being executed, and allow you to step through your code from there. **Wrapping Up** One of the most common failures in the debugging process is inadequate testing. After making the corrections described in the preceding sections, you could run this program for some time, not see that anything is amiss, and assume that it is functioning correctly. However, you should **always** test each part of your code rigorously to ensure that this is the case as much as possible. For **GuessYourNumber**, for instance, with a range of 0 to 10 you could run your program for each secret number 0 to 10 to ensure that each one functions correctly. However, you should never test each part of your code rigorously to ensure that this is the case as much as possible. For **GuessYourNumber**, for instance, with a range of 0 to 10 you could run your program for each secret number 0 to 10 to ensure that each one functions correctly. That being said, there is no strategy that can guarantee that your program is ever bug free. Testing helps, but it is important to keep in mind the caution from Edsger Dijkstra that “testing can reveal the presence of errors, but never their absence.” By being as careful as you can when you design, write, test, and debug your programs, you will reduce the number of bugs, but you will be unlikely to eliminate them entirely. **Additional Eclipse Tips** Once you have completed using the debugger and want to return to using Eclipse in the regular "Editor" perspective (the one that you have been using most of the time), you can simply go to the **"Stanford Menu"** and pick the **"Editor"** selection. This also works in the other direction; if you would like to view the debug perspective, simply pick the **"Debugger"** selection instead. Additionally, if you close out of some of the Eclipse panes and cannot get them back, go to the **"Stanford Menu"** and click **“Reset UI”**. This will restore Eclipse’s user interface to the default view, showing all original panes.
{"Source-Url": "http://web.stanford.edu/class/cs106a//handouts/9%20-%20Debugging.pdf", "len_cl100k_base": 5683, "olmocr-version": "0.1.53", "pdf-total-pages": 14, "total-fallback-pages": 0, "total-input-tokens": 32959, "total-output-tokens": 6219, "length": "2e12", "weborganizer": {"__label__adult": 0.00032329559326171875, "__label__art_design": 0.00030517578125, "__label__crime_law": 0.00020635128021240232, "__label__education_jobs": 0.0014858245849609375, "__label__entertainment": 6.181001663208008e-05, "__label__fashion_beauty": 0.00012993812561035156, "__label__finance_business": 9.053945541381836e-05, "__label__food_dining": 0.0002923011779785156, "__label__games": 0.0007181167602539062, "__label__hardware": 0.0005826950073242188, "__label__health": 0.00021791458129882812, "__label__history": 0.00013053417205810547, "__label__home_hobbies": 7.766485214233398e-05, "__label__industrial": 0.00018107891082763672, "__label__literature": 0.00025272369384765625, "__label__politics": 0.0001093149185180664, "__label__religion": 0.0004360675811767578, "__label__science_tech": 0.001883506774902344, "__label__social_life": 9.846687316894533e-05, "__label__software": 0.005519866943359375, "__label__software_dev": 0.986328125, "__label__sports_fitness": 0.00027179718017578125, "__label__transportation": 0.00028014183044433594, "__label__travel": 0.00016069412231445312}, "weborganizer_max": "__label__software_dev", "avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_ratio": [[0, 25374, 0.0062]], "fineweb_edu_fasttext_gt2__fineweb_edu_fasttext_gt2__score": [[0, 25374, 0.32269]], "ft_lang_id_en_doc_v2__ft_lang_id_en_doc_v2__en": [[0, 25374, 0.95221]], "google_gemma-3-12b-it_contains_pii": [[0, 2568, false], [2568, 6262, null], [6262, 7538, null], [7538, 7831, null], [7831, 9242, null], [9242, 10406, null], [10406, 12442, null], [12442, 14784, null], [14784, 15932, null], [15932, 17416, null], [17416, 19108, null], [19108, 20186, null], [20186, 22248, null], [22248, 25374, null]], "google_gemma-3-12b-it_is_public_document": [[0, 2568, true], [2568, 6262, null], [6262, 7538, null], [7538, 7831, null], [7831, 9242, null], [9242, 10406, null], [10406, 12442, null], [12442, 14784, null], [14784, 15932, null], [15932, 17416, null], [17416, 19108, null], [19108, 20186, null], [20186, 22248, null], [22248, 25374, null]], "google_gemma-3-4b-it_v2tag__is_academic_paper": [[0, 5000, true], [5000, 25374, null]], "google_gemma-3-4b-it_v2tag__is_class_syllabus": [[0, 5000, false], [5000, 25374, null]], "google_gemma-3-4b-it_v2tag__is_completion_certificate": [[0, 5000, false], [5000, 25374, null]], "google_gemma-3-4b-it_v2tag__is_court_notice": [[0, 5000, false], [5000, 25374, null]], "google_gemma-3-4b-it_v2tag__is_homework_assignment": [[0, 5000, true], [5000, 25374, null]], "google_gemma-3-4b-it_v2tag__is_news_article": [[0, 5000, false], [5000, 25374, null]], "google_gemma-3-4b-it_v2tag__is_public_order": [[0, 5000, false], [5000, 25374, null]], "google_gemma-3-4b-it_v2tag__is_resume_cv": [[0, 5000, false], [5000, 25374, null]], "google_gemma-3-4b-it_v2tag__is_test_or_quiz": [[0, 5000, false], [5000, 25374, null]], "google_gemma-3-4b-it_v2tag__is_textbook": [[0, 5000, false], [5000, 25374, null]], "pdf_page_numbers": [[0, 2568, 1], [2568, 6262, 2], [6262, 7538, 3], [7538, 7831, 4], [7831, 9242, 5], [9242, 10406, 6], [10406, 12442, 7], [12442, 14784, 8], [14784, 15932, 9], [15932, 17416, 10], [17416, 19108, 11], [19108, 20186, 12], [20186, 22248, 13], [22248, 25374, 14]], "pipe_delimited_lines_v1__pipe_delimited_lines_v1__pipe_delimited_lines_ratio": [[0, 25374, 0.05714]]}
olmocr_science_pdfs
2024-12-09
2024-12-09
59a162b9f27552fbfead701c4613b3f1bf81bb89
Ruby master - Feature #14781 Enumerator.generate 05/22/2018 10:23 AM - zverok (Victor Shepelev) Status: Closed Priority: Normal Assignee: Target version: Description This is alternative proposal to Object#enumerate (#14423), which was considered by many as a good idea, but with unsure naming and too radical (Object extension). This one is less radical, and, at the same time, more powerful. Synopsis: - Enumerator.generate(initial, &block): produces infinite sequence where each next element is calculated by applying block to previous; initial is first sequence element; - Enumerator.generate(&block): the same; first element of sequence is a result of calling the block with no args. This method allows to produce enumerators replacing a lot of common while and loop cycles in the same way #each replaces for. Examples: With initial value # Infinite sequence p Enumerator.generate(1, &succ).take(5) #=> [1, 2, 3, 4, 5] # Easy Fibonacci p Enumerator.generate([0, 1]) { |f0, f1| [f1, f0 + f1] }.take(10).map(&:first) #=> [0, 1, 1, 2, 3, 5, 8, 13, 21, 34] require 'date' # Find next Tuesday p Enumerator.generate(Date.today, &succ).detect { |d| d.wday == 2 } #=> #<Date: 2018-05-22 ((2458261j,0s,0n),+0s,2299161j)> # Tree navigation # ------------- require 'nokogiri' require 'open-uri' # Find some element on page, then make list of all parents p Nokogiri::HTML(open('https://www.ruby-lang.org/en/')).at('a:contains("Ruby 2.2.10 Released")'). .yield_self { |a| Enumerator.generate(a, &:parent) } .take_while { |node| node.respond_to?(:parent) } .map(&:name) #=> ["a", "h3", "div", "div", "div", "div", "div", "div", "body", "html"] # Pagination # ---------- require 'octokit' Octokit.stargazers('rails/rails') # ^ this method returned just an array, but have set `.last_response` to full response, with data # and pagination. So now we can do this: p Enumerator.generate(Octokit.last_response) { |response| response.rels[:next].get # pagination: `get` fetches next Response .first(3) # take just 3 pages of stargazers .flat_map(&:data) Without initial value Random search target = 7 p Enumerator.generate { rand(10) }.take_while { |i| i != target }.to_a # => [0, 6, 3, 5,.....] External while condition require 'strscan' scanner = StringScanner.new("7+38/6") p Enumerator.generate { scanner.scan(%r{\d+|[-+*/]}) }.slice_after { scanner.eos? }.first # => ["7", "+", "38", "/", "]"] Potential message loop system: Enumerator.generate { Message.receive }.take_while { |msg| msg != :exit } Reference implementation: https://github.com/zverok.enumerator_generate I want to thank all peers that participated in the discussion here, on Twitter and Reddit. Associated revisions Revision 77503761 - 09/12/2019 11:18 AM - Akinori MUSHA Implement Enumerator.produce [Feature #14781] History #1 - 05/22/2018 09:24 PM - shevegen (Robert A. Heiler) I agree with the proposal and name. I would like to recommend and suggest you to add it to the next ruby developer meeting for matz to have a look at and decide. (I think most people already commented on the other linked suggestion, so I assume that the issue here will remain fairly small.) By the way props on the examples given; it's a very clean proposal, much cleaner than any proposals I ever did myself :D, and it can be taken almost as-is for the official documentation, IMO. :) Now of course we have to wait and see what matz and the other core devs have to say about it. Here is the link to the latest developer meeting: https://bugs.ruby-lang.org/issues/14769 #2 - 06/21/2018 08:02 AM - knu (Akinori MUSHA) What about adding support for ending an iteration from a given block itself by raising StopIteration, rather than having to chain it with take_while? #3 - 06/21/2018 08:17 AM - knu (Akinori MUSHA) In today's developer meeting, we kind of loved the functionality, but haven't reached a conclusion about the name. Some candidates: - Enumerator.iterate(initial = nil) { |x| ... } Haskell has a similar function named iterate. - Enumerator.from(initial) { |x| ... } This would sound natural when the initial value is mandatory. #4 - 06/21/2018 08:26 AM - matz (Yukihiro Matsumoto) - Status changed from Open to Feedback I am not fully satisfied with the name generate since the word does not always imply sequence generation. If someone has better name proposal, I welcome. Matz. #5 - 06/21/2018 08:59 AM - sawa (Tsuyoshi Sawada) I propose the following: - Enumerator.sequence - Enumerator.recur #6 - 06/21/2018 10:06 AM - zverok (Victor Shepelev) I like #sequence, too. #7 - 06/21/2018 10:07 AM - zverok (Victor Shepelev) Though, I should add that Enumerator.generate (seen this way, not just .generate alone) seems to clearly state "generate enumerator" :) #8 - 06/21/2018 10:21 AM - mame (Yusuke Endoh) zverok (Victor Shepelev) wrote: "generate" seems too general. It looks the most typical or primitive way to create an enumerator, but it is not. Haskell provides "iterate" function for this feature, but it resembles an iterator in Ruby. #9 - 06/21/2018 11:14 AM - Eregon (Benoit Daloze) I like Enumerator.generate, since it's really to generate a lazy sequence, to generate an Enumerator, from a block. In the end it is basically as powerful as Enumerator.new, so I see no problem to have a factory/constructor-like name. Enumerator.sequence sounds like it could be an eager sequence, and doesn't tell me the block is generating the next value, so I don't like it. Enumerator.iterate sounds like we would iterate something, but we don't, we generate a sequence lazily. The iteration itself is done by #each, not "Enumerator.iterate". I think it only works well in Haskell due to their first-class functions, but even then "iterating" (repeated applications of) a function doesn't sound clear to me or map well to Ruby. #10 - 06/21/2018 01:49 PM - matz (Yukihiro Matsumoto) I don't like recur. Probably it came from recurrence but programmers usually think of recursive because they see recursive more often. FYI, the word recur is used in Clojure for the recursive purpose. I don't like iterate either, as Eregon (Benoit Daloze) stated. Enumerator.generate may work because it generates Enumerator in a fashion different from Enumerator.new. Matz. #11 - 06/21/2018 02:04 PM - mame (Yusuke Endoh) Ah, I meant iterate is not a good name for ruby. Sorry for the confusion. #12 - 06/22/2018 02:35 AM - knu (Akinori MUSHA) I'm not very fond of generate because it's not the only way to generate an Enumerator. There could be more to come. #13 - 10/07/2018 12:26 PM - zverok (Victor Shepelev) - Description updated #14 - 10/10/2018 06:44 AM - akr (Akira Tanaka) How about "recurrence" as method name? It is noun, though. #15 - 10/18/2018 02:24 PM - knu (Akinori MUSHA) - File enumerator_from.rb added I've been thinking about this, and I have some ideas I want to share: To recursively traverse ancestors of a node is one of the most typical use cases, so that should be made easy to do. - When and how to end a sequence may vary, so there should be some flexibility in defining an end. For example, nil is not always the dead end. It could mean something; you might even want to end a sequence with an explicit nil as sentinel. Rescuing an exception and treating it as an end might not be a good option because that would make debugging hard, but StopIteration should be a good fit as a signal for an end. - Sometimes you’d need to look back two or more steps to generate a new value (not to mention Fibonacci series), so the constructor should preferably take multiple seeds. - Sometimes seeds are not subject of yielding; it would be handy if you could specify how many leading seeds to skip. In the original proposal, there are some tricks needed to define an end of a sequence or to look back multiple preceding terms, so I’ve come up with an alternative API that builds them in as keyword options: ```ruby Enumerator.from(seeds, drop: 0, allow_nil: false) { |*preceding_terms| next_term } ``` - `seeds`: Array of objects to be used as seeds (required, but can be an empty array) - `drop`: How many leading terms to skip - `allow_nil`: True if nil should not end the enumerator I wrote an experimental implementation and test cases in the attached file. I’ll be working on it further in this weekends’ hackathon, so any input is appreciated! --- **#16 • 10/18/2018 06:30 PM - zverok (Victor Shepelev)** knu (Akinori MUSHA) The **ultimate** goal for my proposal is, in fact, promoting Enumerator as a “Ruby way” for doing all-the-things with loops; not just “new useful feature”. That’s why I feel really uneasy about your changes to the proposal. **drop** ```ruby # from: 'drop: 2' is part of Enumerator.from API Enumerator.from([node], drop: 2, &:parent).map(&:name) # generate: 'drop(2)' is part of standard Enumerator API Enumerator.generate(node, &:parent).take(5).map(&:name).drop(2) ``` **allow_nil** (by default false: nil stops enumeration) ```ruby # from: # implicit "stop on nil" is part of Enumerator.from convention that code reader should be aware of Enumerator.from([node], &:parent).map(&:name) # don't stop on nil is explicit part of the API Enumerator.from([node], allow_nil: true) { |n| raise StopIteration if n.nil? n.parent }.map { |n| n.name } # generate: "stop on nil" is explicit and obvious Enumerator.generate(node, &:parent).take(5).map(&:name) # no mentioning of unnecessary "we don't need to stop on nil", no additional thinking p Enumerator.generate(node) { |n| raise StopIteration if n.nil? n.parent }.map { |n| n.name } ``` **start with array** (I believe 1 and 0 initial values are the MOST used cases) ```ruby # from: we should start from empty array, expression nothing but Enumerator.from API limitation Enumerator.from([]) { 0 }.take(10) # generate: no start value Enumerator.generate { 0 }.take(10) # from: work with one value requires not forgetting to arrayify it Enumerator.from([1]), &:succ).take(10) # generate: just use the value Enumerator.generate(1, &:succ).take(10) ``` ```ruby # from: "we pass as much of previous values as initial array had" convention Enumerator.from([0, 1]) { [i, j] | i + j }.take(10) # generate: regular value enumeration, next block receives exactly what previous returns Enumerator.generate([0, 1]) { [i, j] | [i, i + j] }.take(10).map(&:last) # ^ yes, it will require additional trick to include 0 in final result, but I believe this is worthy sacrifice ``` The problem with “API complication” is inconsistency. Like, a newcomer may ask: Why Enumerator.from has “this handy drop: 2 initial arg”, and each don’t? Use cases could exist, too! The ultimate goal for my proposal is, in fact, promoting Enumerator as a “Ruby way” for doing all-the-things with loops; not just “new useful feature”. That's why I feel really uneasy about your changes to the proposal. Thanks for your quick feedback, and for bringing up this issue. drop ```ruby # from: `drop: 2` is part of Enumerator.from API Enumerator.from([node], drop: 2, &:parent).map(&:name) # generate: `drop(2)` is part of standard Enumerator API Enumerator.generate(node, &:parent).take(6).map(&:name).drop(2) ``` I presume .take(6) is inserted by mistake, but with it or not the following map and drop methods belong to Enumerable, and are Array based operations that create an intermediate array per call. So, I consider them as Array/Enumerable API rather than Enumerator API. Creating intermediate arrays is not only a waste of memory but also against the key concept of Enumerator: to deal with an object as a stream, which may be infinite. Adding .lazy before .drop(2) can be a cure, but then the value you get is a lazy enumerator that is incompatible with an non-lazy enumerator. For instance, Lazy#map, Lazy#select etc. return Lazy objects, so you can’t always pass one to methods that expect a normal Enumerable object. I've always thought that Lazy#eager that turns a lazy enumerator back to a non-lazy enumerator would be nice, but .lazy.map{}.eager would look messy anyway. ```ruby # implicit "stop on nil" is part of Enumerator.from convention that code reader should be aware of ``` I think it's good and reasonable default behavior to treat nil as an end. Taking your Octokit example, the block could be `{ |response| response.rels[:next]&.get } to make it go through all pages and automatically stop if nil were treated as an end. You omitted a .take_while in the example, but you'd get an error if there were less than 3 pages. You'd almost always need to either explicitly raise StopIteration in the initial block or chain .take_while .take if there were no default end, and the choice between them is not obvious. ```ruby start with array (I believe 1 and 0 initial values are the MOST used cases) ```ruby # from: we should start from empty array, expression nothing but Enumerator.from API limitation Enumerator.from([]) { 0 }.take(10) # generate: no start value Enumerator.generate { 0 }.take(10) ``` The limitation only came from what the word from sounds like. I picked the name from and Enumerator.from {} just didn't sound right to me, so I made the argument mandatory. You can just default the first argument to [] if it reads and writes better, possibly with a different name than from which I won't insist on. ```ruby # from: work with one value requires not forgetting to arrayify it Enumerator.from([1], &:succ).take(10) # generate: just use the value Enumerator.generate(1, &:succ).take(10) ``` Yeah, due to our keyword arguments being pseudo ones, you can’t use variable length arguments for a list of objects that might end with a hash. We’ll hopefully be getting it right by Ruby 3.0. There's much room for consideration of the name and method signature. Perhaps multiple factory methods could work better. ```ruby # from: "we pass as much of previous values as initial array had" convention Enumerator.from([0, 1]) { |i, j| i + j }.take(10) # generate: regular value enumeration, next block receives exactly what previous returns Enumerator.generate([0, 1]) { |i, j| [j, i + j] }.take(10).map(&:last) # ^ yes, it will require additional trick to include 0 in final result, but I believe this is worthy sacri fice ``` The former directly generates an infinite Fibonacci sequence and that’s a major difference. Taking a first few elements with .take is just for testing (assertion) purposes and not part of the use case. When solving a problem like "Find the least n such that \( \sum_{k=1}^{n} fib(k) \geq 1000 \)”, take wouldn't work optimally. The problem with "API complication" is inconsistency. Like, a newcomer may ask: Why Enumerator.from has "this handy drop: 2 initial arg", and each don't? Use cases could exist, too! I understand that sentiment, but there's no surprise that a factory/constructor method of a dedicated class often takes many tunables while individual instance methods do not. If people all said they need it as a generic feature, it wouldn't be a bad idea to me to consider adding something like Enumerable#skip(n) that would return an offset enumerator. #18 - 03/22/2019 07:25 AM - knu (Akinori MUSHA) - Subject changed from Enumerator#generate to Enumerator.generate #19 - 08/11/2019 10:30 AM - zverok (Victor Shepelev) - File enumerator-generate.patch added Attached is a patch with the implementation I initially described, and with the name Matz seems to be accepting of (Enumerator.generate). I am not 100% sure about the code (as it is my first contribution to core C code), but at least it is short and clean, I am willing to improve it if necessary. #20 - 08/11/2019 08:06 PM - jwmittag (Jörg W Mittag) This is alternative proposal to Object#enumerate (#14423), which was considered by many as a good idea, but with unsure naming and too radical (Object extension). This one is less radical, and, at the same time, more powerful. **Synopsis:** - Enumerator.generate(initial, &block): produces infinite sequence where each next element is calculated by applying block to previous; initial is first sequence element; - Enumerator.generate(&block): the same; first element of sequence is a result of calling the block with no args. This is typically called unfold, since it is the category-theoretical dual of a fold. Ruby doesn't use the name fold, though, it uses inject and reduce, neither of which lend themselves to negating: Enumerator::uninject, Enumerator::unreduce? Yikes! That sounds really bad. However, literally as I am writing this, a thought pops into my mind: how about Enumerator::produce as the dual to Enumerable#reduce? Scala also has iterate which is the restricted variant of unfold. #21 - 08/11/2019 08:34 PM - zverok (Victor Shepelev) However, literally as I am writing this, a thought pops into my mind: how about Enumerator::produce as the dual to Enumerable#reduce? Scala also has iterate which is the restricted variant of unfold. In the first proposal, I've studied some alternative names and their logic, including "like iterate" (that was my original proposal: Object#enumerate, but the Enumerator.enumerate seems a bit overkill to me) and "antonym to fold (reduce)" -- this led me to deduce, but your produce idea sounds about right! Matz?.. #22 - 08/11/2019 09:10 PM - jwmittag (Jörg W Mittag) However, literally as I am writing this, a thought pops into my mind: how about Enumerator::produce as the dual to Enumerable#reduce? Scala also has iterate which is the restricted variant of unfold. In the first proposal, I've studied some alternative names and their logic, including "like iterate" (that was my original proposal: Object#enumerate, but the Enumerator.enumerate seems a bit overkill to me) and "antonym to fold (reduce)" -- this led me to deduce, but your produce idea sounds about right! Matz?.. #23 - 08/29/2019 06:55 AM - matz (Yukihiro Matsumoto) I prefer produce to iterate, generate or from. Accepted (at least for the experiment). Matz. I just wrote a draft implementation of Enumerator.produce. I just didn't notice zverok (Victor Shepelev) kindly worked on writing a patch, so I'll review and integrate it later! Applied in changeset git|775037613bffe6f90e7af510b7f46a2ac10610be. Implement Enumerator.produce [Feature #14781] zverok (Victor Shepelev) are you making available the code in https://github.com/zverok/enumerator_generate available under the same licence as Ruby? We'd like to just run that proof-of-concept code as-is in TruffleRuby (it still passes all the specs.) Everything that is good for the community is good by me. Files enumerator_from.rb 3.16 KB 10/18/2018 knu (Akinori MUSHA) enumerator-generate.patch 4.44 KB 08/11/2019 zverok (Victor Shepelev) 0001-Implement-Enumerator.produce-Feature-14781.patch 4.47 KB 08/29/2019 knu (Akinori MUSHA)
{"Source-Url": "https://bugs.ruby-lang.org/issues/14781.pdf", "len_cl100k_base": 4953, "olmocr-version": "0.1.53", "pdf-total-pages": 7, "total-fallback-pages": 0, "total-input-tokens": 20705, "total-output-tokens": 5665, "length": "2e12", "weborganizer": {"__label__adult": 0.00045108795166015625, "__label__art_design": 0.00025844573974609375, "__label__crime_law": 0.00026988983154296875, "__label__education_jobs": 0.0002951622009277344, "__label__entertainment": 6.121397018432617e-05, "__label__fashion_beauty": 0.00013566017150878906, "__label__finance_business": 0.00012010335922241212, "__label__food_dining": 0.00040435791015625, "__label__games": 0.0004677772521972656, "__label__hardware": 0.00039076805114746094, "__label__health": 0.0002386569976806641, "__label__history": 0.00014448165893554688, "__label__home_hobbies": 6.937980651855469e-05, "__label__industrial": 0.00019991397857666016, "__label__literature": 0.0001735687255859375, "__label__politics": 0.0002161264419555664, "__label__religion": 0.00034499168395996094, "__label__science_tech": 0.0006952285766601562, "__label__social_life": 9.02414321899414e-05, "__label__software": 0.003736495971679687, "__label__software_dev": 0.99072265625, "__label__sports_fitness": 0.00026106834411621094, "__label__transportation": 0.00026106834411621094, "__label__travel": 0.00018608570098876953}, "weborganizer_max": "__label__software_dev", "avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_ratio": [[0, 18830, 0.04387]], "fineweb_edu_fasttext_gt2__fineweb_edu_fasttext_gt2__score": [[0, 18830, 0.09173]], "ft_lang_id_en_doc_v2__ft_lang_id_en_doc_v2__en": [[0, 18830, 0.85477]], "google_gemma-3-12b-it_contains_pii": [[0, 2077, false], [2077, 4237, null], [4237, 6908, null], [6908, 10685, null], [10685, 14600, null], [14600, 17998, null], [17998, 18830, null]], "google_gemma-3-12b-it_is_public_document": [[0, 2077, true], [2077, 4237, null], [4237, 6908, null], [6908, 10685, null], [10685, 14600, null], [14600, 17998, null], [17998, 18830, null]], "google_gemma-3-4b-it_v2tag__is_academic_paper": [[0, 5000, false], [5000, 18830, null]], "google_gemma-3-4b-it_v2tag__is_class_syllabus": [[0, 5000, false], [5000, 18830, null]], "google_gemma-3-4b-it_v2tag__is_completion_certificate": [[0, 5000, false], [5000, 18830, null]], "google_gemma-3-4b-it_v2tag__is_court_notice": [[0, 5000, false], [5000, 18830, null]], "google_gemma-3-4b-it_v2tag__is_homework_assignment": [[0, 5000, false], [5000, 18830, null]], "google_gemma-3-4b-it_v2tag__is_news_article": [[0, 5000, false], [5000, 18830, null]], "google_gemma-3-4b-it_v2tag__is_public_order": [[0, 5000, false], [5000, 18830, null]], "google_gemma-3-4b-it_v2tag__is_resume_cv": [[0, 5000, false], [5000, 18830, null]], "google_gemma-3-4b-it_v2tag__is_test_or_quiz": [[0, 5000, false], [5000, 18830, null]], "google_gemma-3-4b-it_v2tag__is_textbook": [[0, 5000, false], [5000, 18830, null]], "pdf_page_numbers": [[0, 2077, 1], [2077, 4237, 2], [4237, 6908, 3], [6908, 10685, 4], [10685, 14600, 5], [14600, 17998, 6], [17998, 18830, 7]], "pipe_delimited_lines_v1__pipe_delimited_lines_v1__pipe_delimited_lines_ratio": [[0, 18830, 0.0]]}
olmocr_science_pdfs
2024-12-08
2024-12-08
ff361d3e87444c2969508ef6186f00c884b4f756
Welcome! Algorithm Design & Analysis Course Focus • Effective fundamental design paradigms • Tools & techniques for analysis of resource use • Ability to accurately gauge problem difficulty • Strategies for “intractable” problems • Enhanced problem-solving skills Who’s Who Instructor • Bill Lenhart (wlenhart@williams.edu) • Office: TPL 304 (x2371) • Office Hours: M/T/W/Th: 2:00-3:50 pm TAs • Quan Do, Javier Esparza, Minwoo Kang, Jamie Kasulis, Lester Lee, Emily Zheng • TA Hours: T/W/Th: 7:00-11:00pm • Location (Currently): T/Th: SSL030A; W: TCL 206 What’s What The Text - *Algorithm Design* by Kleinberg & Tardos (1st Ed.) Problem Sets, Exams, Projects - Weekly Problem Sets - Assigned on Friday and submitted by noon (in class) the following Friday - Except for 2/15 (Winter Carnival): Submit to my CS ‘cubby’ by 5:00 pm - Collaboration is fine but must be cited - Problem Set 0 is out now; due next Friday, Feb. 8 - Problem Sets must be typeset using LaTeX - Mid-Term (4/5 - 4/8) and Final (24-hour) Exams - Take-home; collaboration prohibited The Course Website - https://www.cs.williams.edu/~lenhart/cs256/index.html The Fine Print Expectations • Read all information on the course website (by Monday noon!) • Come to class (reasonably) prepared • Read in advance to get general idea • Contribute • Attend and participate • Help make the course a great experience for all • Assignments • Start early, finish on time • Adhere to the Honor Code • Have fun & learn (a lot) An Illustrative Example Matching Problems • Assigning first year students to advisors • Pairing job candidates with employers • The “Algorithm of Happiness” • The National Resident Matching Program Fundamental Problem • Find a matching that protects against opportunistic swapping Hospital Preference Lists <table> <thead> <tr> <th></th> <th>0</th> <th>1</th> <th>2</th> <th>3</th> <th>4</th> </tr> </thead> <tbody> <tr> <td>V</td> <td>B</td> <td>A</td> <td>D</td> <td>E</td> <td>C</td> </tr> <tr> <td>W</td> <td>D</td> <td>B</td> <td>A</td> <td>C</td> <td>E</td> </tr> <tr> <td>X</td> <td>B</td> <td>E</td> <td>C</td> <td>D</td> <td>A</td> </tr> <tr> <td>Y</td> <td>A</td> <td>D</td> <td>C</td> <td>B</td> <td>E</td> </tr> <tr> <td>Z</td> <td>B</td> <td>D</td> <td>A</td> <td>E</td> <td>C</td> </tr> </tbody> </table> Matching - V - D - W - A - X - E - Y - C - Z - B Student Preference Lists <table> <thead> <tr> <th></th> <th>0</th> <th>1</th> <th>2</th> <th>3</th> <th>4</th> </tr> </thead> <tbody> <tr> <td>A</td> <td>Z</td> <td>V</td> <td>W</td> <td>Y</td> <td>X</td> </tr> <tr> <td>B</td> <td>X</td> <td>W</td> <td>Y</td> <td>V</td> <td>Z</td> </tr> <tr> <td>C</td> <td>W</td> <td>X</td> <td>Y</td> <td>Z</td> <td>V</td> </tr> <tr> <td>D</td> <td>V</td> <td>Z</td> <td>Y</td> <td>X</td> <td>W</td> </tr> <tr> <td>E</td> <td>Y</td> <td>W</td> <td>Z</td> <td>X</td> <td>V</td> </tr> </tbody> </table> Instability - W - A - Z - B State the Problem Two groups: Students & Hospitals - Each student has ranked desired hospitals - Each hospital has ranked desired students Goal - Match as many students as possible, avoiding instabilities - Instability: s is not matched to h, but s & h both prefer each other to their matches Hospital Preference Lists <table> <thead> <tr> <th></th> <th>0</th> <th>1</th> <th>2</th> <th>3</th> <th>4</th> </tr> </thead> <tbody> <tr> <td>V</td> <td>B</td> <td>A</td> <td>D</td> <td>E</td> <td>C</td> </tr> <tr> <td>W</td> <td>D</td> <td>B</td> <td>A</td> <td>C</td> <td>E</td> </tr> <tr> <td>X</td> <td>B</td> <td>E</td> <td>C</td> <td>D</td> <td>A</td> </tr> <tr> <td>Y</td> <td>A</td> <td>D</td> <td>C</td> <td>B</td> <td>E</td> </tr> <tr> <td>Z</td> <td>B</td> <td>D</td> <td>A</td> <td>E</td> <td>C</td> </tr> </tbody> </table> Partial Matching Student Preference Lists <table> <thead> <tr> <th></th> <th>0</th> <th>1</th> <th>2</th> <th>3</th> <th>4</th> </tr> </thead> <tbody> <tr> <td>A</td> <td>Z</td> <td>V</td> <td>W</td> <td>Y</td> <td>X</td> </tr> <tr> <td>B</td> <td>X</td> <td>W</td> <td>Y</td> <td>V</td> <td>Z</td> </tr> <tr> <td>C</td> <td>W</td> <td>X</td> <td>Y</td> <td>Z</td> <td>V</td> </tr> <tr> <td>D</td> <td>V</td> <td>Z</td> <td>Y</td> <td>X</td> <td>W</td> </tr> <tr> <td>E</td> <td>Y</td> <td>W</td> <td>Z</td> <td>X</td> <td>V</td> </tr> </tbody> </table> Find the Simplest Interesting Version Distracting Complications - Students/Hospitals have incomplete rankings - Hospital might want several students - Might not be enough posts for all students The Original: Stable Marriage Problem - \( n \) men & \( n \) women - every man and woman submits a complete ranking - We’ll use a set \( X \) of \( n \) hospitals and \( Y \) of \( n \) students Goal - Find a stable perfect matching - Perfect: Every student/hospital is matched Restate the Problem Instability in matching $M$ - Unmatched pair $\{h, s\}$, with $\{h, s'\}$, $\{s, h'\}$ in $M$ where $h$ prefers $s$ to $s'$ and $s$ prefers $h$ to $h'$ Stable Matching: No instabilities - For every unmatched $\{h, s\}$, - Either $h$ prefers its match to $s$, - Or $s$ prefers its match to $h$ Does such a matching always exist? Can we find it? What if $n = 50,000$? If so, how? Design an Algorithm - Iterative process in which - A hospital offers a student a post - A student can reject current matched hospital in favor of a preferred one - Stop when everyone is matched (hopefully!) - Claim: Stable matching has been produced Gale & Shapley: Propose - Reject Algorithm (1962) Initialize each entity to be free (unmatched). while (some hospital is free and hasn't offered a post to every student) { Choose such a hospital h s = h’s most preferred student to whom h hasn’t yet offered a post if (s is free) assign h and s to be matched // h & s no longer free else if (s prefers h to its current match h') assign h and s to be matched, and h' to be free else s rejects h // h remains free } Questions • Does it halt? • Does it match everyone? • Is the matching stable? Analyzing the Algorithm: Correctness Look for Helpful Features of Algorithm • Every iteration eliminates a potential offer • So algorithm at least halts [! Find a progress measure !] • Once matched, a student stays matched • Students always ‘trade up’ • If s breaks match with h in favor of h’ then s prefers h’ to h • Every student gets matched • So the matching is complete (perfect matching) The Matching is Stable • Suppose not: Then final matching has an instability \{h,s\} • h is matched to s’ but h prefers s over s’ • s is matched to h’ but s prefers h over h’ • So h offered a post to s before offering one to s’ • So either s broke the match to h at some point, or s already had a match h’’ that s preferred over h • But students always trade up, so final match of s (h’) must be preferred by s to h—>Contradiction! Analyzing the Algorithm: Performance Establish Running Time and Space Requirements • Space: $2n$ lists of length $n$: $O(n^2)$ • Time: Count a representative set of operations • Select a free hospital $h$ • Find most preferred $s$ not yet offered a post by $h$ • Find $s$’s ranking of a given hospital • Make a matched hospital free again • Add to & delete from set of matched couples Wait! What’s the Input? - Assume each entity provides complete ordered list (most to least preferred) of choices Identify Efficient Data Structures for Operations - Assume students are named 1..n, and hospitals are named 1..n - Free hospital: get(), put() : Queue: $O(1)$ for both - Of students not yet offered a post by h, find most preferred - $h$ provided a sorted list: $O(1)$ Identify Efficient Data Structures for Operations - Find s’s ranking of a given hospital - For each s, an array, indexed by hospital, of hospitals as ranked by s (inverted index) - \( s(h) = i \) if \( h \) has rank \( i \) in s’s list - Build this from s’s ordered list of hospitals: \( O(n) \) per list - Add to & delete from set of matched pairs: - Array, \( \text{Matched}(s) = h \) currently matched to \( s \) (or ‘free’): Creation time \( O(n) \); update time \( O(1) \) Analyzing the Algorithm: Performance IV Initialize each entity to be free. while (some h is free and hasn't offered a post to each s) { Choose such an h s = most preferred student of h not yet offered a post by h if (s is free) assign h and s to be matched // h & s no longer free else if (s prefers h to current match h') assign h and s to be matched, and h' to be free else s rejects h // h remains free Overall Running Time • Preprocessing Time + Loop Time • Preprocessing: O(n²) (for inverted lists) + O(n) : (for Matched()) • Loop: O(n²) * O(1) (all steps take constant time) Analyzing the Algorithm: Performance V • How efficient is P-R precisely? • Measure in terms of input size • For \( n \) hospitals and \( n \) students, input size is \( K = n^2 \) • P-R takes time proportional to \( K \) • So P-R is a linear-time algorithm—and it’s greedy • Is it optimal? • May depend on the model of computation... ____________________________ **Principle:** Measure complexity relative to size of instance What else can we learn from the P-R algorithm - Seems to favor the proposers over rejectors - Empirical Observation: Seems to produce same matching regardless of choice of selection of free hospital Best Feasible Partner Let $I$ be an instance of the stable marriage problem - An instance of a problem is any single valid input - $s \in Y$ is a feasible partner for $h \in X$, if $\{h,s\}$ is part of some stable matching of $I$. - $\{h,s\}$ is then called a feasible pair - For $h \in X$, let $\text{best}(h)$ denote the most preferred feasible partner of $h$ - What can we say about $S^* = \{\{h,\text{best}(h)\} : h \in X\}$? The Surprising Set $S^*$ It turns out that: - $S^*$ is a matching - $S^*$ is stable - $S^*$ is optimal from the proposers’ perspective - $S^*$ is the unique output of P-R regardless of next free hospital selection method! The Proof: Overview • Assume that P-R does not produce $S^*$. • That is, for at least some $h$, $h$ is **not** matched with $best(h)$ • Derive contradiction: Show there exists a perfect matching $S'$ such that • $S'$ is stable, and • $S'$ is *not* stable • Key Ideas: • Every $h$ will, at some point during P-R algorithm, offer a post to $best(h)$ • If $h$ is matched to $s$ in P-R algorithm, then $h$ is rejected by all $s'$ that $h$ prefers to $s$ • Rejection has two flavors: $s$ already has better match or $s$ prefers new hospital to current match **The Proof II** Assume that P-R does not produce $S^*$. - Consider first rejection of some $h$ by $s = \text{best}(h)$ - *This is a common proof technique with algorithm analysis!* - $s$ rejects $h$ for some $h'$ that $s$ prefers to $h$ [NB: 2 flavors of rejection!] - But $\{h, s\}$ is feasible: Let $S'$ be some stable matching containing $\{h, s\}$ - In $S'$, $h'$ is matched to $s' \neq s$. - Does $h'$ prefers $s$ to $s'$? If so, then $\{h', s\}$ is an instability in $S'$ - This contradicts the stability of $S'$, so $h'$ prefers $s'$ to $s$.... The Proof III So, $h'$ prefers $s'$ to $s$. Return to the execution of the P-R algorithm on $I$ - In P-R, $h$ was the first element of $X$ to be rejected by its $\text{best}(h)$ - So $h'$ had not yet been rejected by any feasible partner - But $s'$ is a feasible partner of $h'$, and $h'$ prefers $s'$ to $s$ - So $h'$ can’t have been rejected by $s'$ - So $h'$ can’t currently be matched to $s$ or be offering a post to $s$ at this point - So neither flavor of rejection of $h$ by $s$ in favor of $h'$ was possible! Contradiction: $h$ was never rejected by $\text{best}(h)$! Result • Propose-Reject produces $S^\ast$ regardless of free hospital selection strategy • Thus $S^\ast$ is a matching and it is stable • Also $S^\ast$ is clearly proposer-optimal (and, sadly, rejector-pessimal...) Principle: Use an algorithm to prove new facts about a problem Generalizing Our Result P-R still works, with modifications, when - I: Some pairings are forbidden - II: Hospital wants several students, student wants one hospital - III: Both I & II Some extensions are explored in Problem Set 1 Summary: How to Solve a Problem State the Problem Play With the Problem Find the Simplest Interesting Version of the Problem Clearly restate the Simplest Version of the Problem Design an Algorithm & Make it Precise Identify Properties of Algorithm to Prove Correctness • Go back to previous step if (as is most likely) necessary Establish Running Time and Space Requirements • Identify Efficient Data Structures for Operations Reflect on implications of your solution—you may have learned something! What Usually Happens Poor Understanding of Problem No Intuition About Problem Confusion Due to Overwhelming Detail Poor Statement of Problem Multiple Failed Attempts to Design Algorithm Inability to Prove Correctness • Often because algorithm does not actually work correctly Trade-Offs Between Time & Space Resources Create Difficult Choices But Wait, There’s More…. Five Famous Problems - Interval Scheduling - Weighted Interval Scheduling - Bipartite Matching - Independent Set - Competitive Facility Location Interval Scheduling - Instance: A list of requests for a single resource - Request $i$ consists of a start time $s_i$ and end time $t_i$ - Goal: Find maximum-size set of non-overlapping requests - Efficiently solvable by a greedy algorithm Figure 1.4 An instance of the Interval Scheduling Problem. Weighted Interval Scheduling - Instance: A list of requests for a single resource - Request \( i \) also has weight \( w_i \) - Goal: Find maximum-weight set of non-overlapping requests - Efficiently solvable by \textit{dynamic programming} - Interval scheduling is a special case: \( w_i = 1 \) Bipartite Matching Instance: A list of requests for one of a set of resources - Request \( i \) is a pair \( \{x_i, y_j\} : x_i \in X, y_j \in Y, X \cap Y = \emptyset \) Goal: Find maximum-sized set of non-overlapping requests: maximum-sized matching - Efficiently solvable by network flow techniques - Inherently a graph-theoretic problem Figure 1.5 A bipartite graph. Independent Set Instance: A list of conflicts between elements of a set $V$ - Conflict $i$ is a pair $\{u_i, v_i\}$: $u_i, v_i \in V$ Goal: Find maximum-sized conflict-free subset of $V$ - Considered to be intractable - Inherently a graph-theoretic problem - Interval scheduling is special case - So is maximum matching Figure 1.6 A graph whose largest independent set has size 4. Competitive Facility Location - Instance: A number $B$ and graph $G = (V,E)$ with vertex weights $w(v)$ - Two players alternately select vertices of $G$ - All selected vertices must form a single independent set; player 1 begins - Player 2 wants to construct an independent set of weight at least $B$; player 1 wants to prevent this - Goal: Determine whether player 2 can succeed - Considered to be harder than Independent Set - Inherently a graph-theoretic problem Figure 1.7 An instance of the Competitive Facility Location Problem.
{"Source-Url": "https://www.cs.williams.edu/~lenhart/cs256/lectures/Lecture01-Intro+StableMatching.pdf", "len_cl100k_base": 4544, "olmocr-version": "0.1.53", "pdf-total-pages": 36, "total-fallback-pages": 0, "total-input-tokens": 54129, "total-output-tokens": 5463, "length": "2e12", "weborganizer": {"__label__adult": 0.0007963180541992188, "__label__art_design": 0.0014581680297851562, "__label__crime_law": 0.0012750625610351562, "__label__education_jobs": 0.09796142578125, "__label__entertainment": 0.0002237558364868164, "__label__fashion_beauty": 0.0005679130554199219, "__label__finance_business": 0.0007958412170410156, "__label__food_dining": 0.001071929931640625, "__label__games": 0.002857208251953125, "__label__hardware": 0.0022335052490234375, "__label__health": 0.0024871826171875, "__label__history": 0.00138092041015625, "__label__home_hobbies": 0.0006165504455566406, "__label__industrial": 0.0015096664428710938, "__label__literature": 0.0009279251098632812, "__label__politics": 0.0011301040649414062, "__label__religion": 0.0014410018920898438, "__label__science_tech": 0.1397705078125, "__label__social_life": 0.0006704330444335938, "__label__software": 0.0069732666015625, "__label__software_dev": 0.7294921875, "__label__sports_fitness": 0.0015811920166015625, "__label__transportation": 0.0019254684448242188, "__label__travel": 0.0005693435668945312}, "weborganizer_max": "__label__software_dev", "avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_ratio": [[0, 14078, 0.00798]], "fineweb_edu_fasttext_gt2__fineweb_edu_fasttext_gt2__score": [[0, 14078, 0.13579]], "ft_lang_id_en_doc_v2__ft_lang_id_en_doc_v2__en": [[0, 14078, 0.86211]], "google_gemma-3-12b-it_contains_pii": [[0, 9, false], [9, 266, null], [266, 571, null], [571, 1162, null], [1162, 1530, null], [1530, 1817, null], [1817, 2316, null], [2316, 2615, null], [2615, 3051, null], [3051, 3532, null], [3532, 3941, null], [3941, 4251, null], [4251, 4843, null], [4843, 5246, null], [5246, 5691, null], [5691, 6088, null], [6088, 6474, null], [6474, 6965, null], [6965, 7599, null], [7599, 8054, null], [8054, 8254, null], [8254, 8688, null], [8688, 8912, null], [8912, 9480, null], [9480, 10039, null], [10039, 10619, null], [10619, 10901, null], [10901, 11134, null], [11134, 11646, null], [11646, 12018, null], [12018, 12164, null], [12164, 12469, null], [12469, 12768, null], [12768, 13143, null], [13143, 13532, null], [13532, 14078, null]], "google_gemma-3-12b-it_is_public_document": [[0, 9, false], [9, 266, null], [266, 571, null], [571, 1162, null], [1162, 1530, null], [1530, 1817, null], [1817, 2316, null], [2316, 2615, null], [2615, 3051, null], [3051, 3532, null], [3532, 3941, null], [3941, 4251, null], [4251, 4843, null], [4843, 5246, null], [5246, 5691, null], [5691, 6088, null], [6088, 6474, null], [6474, 6965, null], [6965, 7599, null], [7599, 8054, null], [8054, 8254, null], [8254, 8688, null], [8688, 8912, null], [8912, 9480, null], [9480, 10039, null], [10039, 10619, null], [10619, 10901, null], [10901, 11134, null], [11134, 11646, null], [11646, 12018, null], [12018, 12164, null], [12164, 12469, null], [12469, 12768, null], [12768, 13143, null], [13143, 13532, null], [13532, 14078, null]], "google_gemma-3-4b-it_v2tag__is_academic_paper": [[0, 5000, true], [5000, 14078, null]], "google_gemma-3-4b-it_v2tag__is_class_syllabus": [[0, 5000, true], [5000, 14078, null]], "google_gemma-3-4b-it_v2tag__is_completion_certificate": [[0, 5000, false], [5000, 14078, null]], "google_gemma-3-4b-it_v2tag__is_court_notice": [[0, 5000, false], [5000, 14078, null]], "google_gemma-3-4b-it_v2tag__is_homework_assignment": [[0, 5000, true], [5000, 14078, null]], "google_gemma-3-4b-it_v2tag__is_news_article": [[0, 5000, false], [5000, 14078, null]], "google_gemma-3-4b-it_v2tag__is_public_order": [[0, 5000, false], [5000, 14078, null]], "google_gemma-3-4b-it_v2tag__is_resume_cv": [[0, 5000, false], [5000, 14078, null]], "google_gemma-3-4b-it_v2tag__is_test_or_quiz": [[0, 5000, false], [5000, 14078, null]], "google_gemma-3-4b-it_v2tag__is_textbook": [[0, 5000, false], [5000, 14078, null]], "pdf_page_numbers": [[0, 9, 1], [9, 266, 2], [266, 571, 3], [571, 1162, 4], [1162, 1530, 5], [1530, 1817, 6], [1817, 2316, 7], [2316, 2615, 8], [2615, 3051, 9], [3051, 3532, 10], [3532, 3941, 11], [3941, 4251, 12], [4251, 4843, 13], [4843, 5246, 14], [5246, 5691, 15], [5691, 6088, 16], [6088, 6474, 17], [6474, 6965, 18], [6965, 7599, 19], [7599, 8054, 20], [8054, 8254, 21], [8254, 8688, 22], [8688, 8912, 23], [8912, 9480, 24], [9480, 10039, 25], [10039, 10619, 26], [10619, 10901, 27], [10901, 11134, 28], [11134, 11646, 29], [11646, 12018, 30], [12018, 12164, 31], [12164, 12469, 32], [12469, 12768, 33], [12768, 13143, 34], [13143, 13532, 35], [13532, 14078, 36]], "pipe_delimited_lines_v1__pipe_delimited_lines_v1__pipe_delimited_lines_ratio": [[0, 14078, 0.08511]]}
olmocr_science_pdfs
2024-12-09
2024-12-09
9e89ba55753dc6cd4a7536dcf328f9ecc62bff04
[REMOVED]
{"Source-Url": "https://hal-lirmm.ccsd.cnrs.fr/lirmm-00171055/file/dexa174.pdf", "len_cl100k_base": 6664, "olmocr-version": "0.1.53", "pdf-total-pages": 11, "total-fallback-pages": 0, "total-input-tokens": 28814, "total-output-tokens": 7667, "length": "2e12", "weborganizer": {"__label__adult": 0.00036025047302246094, "__label__art_design": 0.0007157325744628906, "__label__crime_law": 0.0006508827209472656, "__label__education_jobs": 0.003025054931640625, "__label__entertainment": 0.00016224384307861328, "__label__fashion_beauty": 0.0002416372299194336, "__label__finance_business": 0.0009813308715820312, "__label__food_dining": 0.0004115104675292969, "__label__games": 0.0007762908935546875, "__label__hardware": 0.0007982254028320312, "__label__health": 0.0007195472717285156, "__label__history": 0.0005617141723632812, "__label__home_hobbies": 0.00015032291412353516, "__label__industrial": 0.0006852149963378906, "__label__literature": 0.0007805824279785156, "__label__politics": 0.0004193782806396485, "__label__religion": 0.0005655288696289062, "__label__science_tech": 0.278564453125, "__label__social_life": 0.0002455711364746094, "__label__software": 0.060699462890625, "__label__software_dev": 0.6474609375, "__label__sports_fitness": 0.0002727508544921875, "__label__transportation": 0.0005359649658203125, "__label__travel": 0.00027871131896972656}, "weborganizer_max": "__label__software_dev", "avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_ratio": [[0, 26728, 0.04668]], "fineweb_edu_fasttext_gt2__fineweb_edu_fasttext_gt2__score": [[0, 26728, 0.30752]], "ft_lang_id_en_doc_v2__ft_lang_id_en_doc_v2__en": [[0, 26728, 0.83624]], "google_gemma-3-12b-it_contains_pii": [[0, 975, false], [975, 3437, null], [3437, 6357, null], [6357, 8727, null], [8727, 12120, null], [12120, 14435, null], [14435, 16933, null], [16933, 19998, null], [19998, 22094, null], [22094, 23906, null], [23906, 26728, null]], "google_gemma-3-12b-it_is_public_document": [[0, 975, true], [975, 3437, null], [3437, 6357, null], [6357, 8727, null], [8727, 12120, null], [12120, 14435, null], [14435, 16933, null], [16933, 19998, null], [19998, 22094, null], [22094, 23906, null], [23906, 26728, null]], "google_gemma-3-4b-it_v2tag__is_academic_paper": [[0, 5000, true], [5000, 26728, null]], "google_gemma-3-4b-it_v2tag__is_class_syllabus": [[0, 5000, false], [5000, 26728, null]], "google_gemma-3-4b-it_v2tag__is_completion_certificate": [[0, 5000, false], [5000, 26728, null]], "google_gemma-3-4b-it_v2tag__is_court_notice": [[0, 5000, false], [5000, 26728, null]], "google_gemma-3-4b-it_v2tag__is_homework_assignment": [[0, 5000, false], [5000, 26728, null]], "google_gemma-3-4b-it_v2tag__is_news_article": [[0, 5000, false], [5000, 26728, null]], "google_gemma-3-4b-it_v2tag__is_public_order": [[0, 5000, false], [5000, 26728, null]], "google_gemma-3-4b-it_v2tag__is_resume_cv": [[0, 5000, false], [5000, 26728, null]], "google_gemma-3-4b-it_v2tag__is_test_or_quiz": [[0, 5000, false], [5000, 26728, null]], "google_gemma-3-4b-it_v2tag__is_textbook": [[0, 5000, false], [5000, 26728, null]], "pdf_page_numbers": [[0, 975, 1], [975, 3437, 2], [3437, 6357, 3], [6357, 8727, 4], [8727, 12120, 5], [12120, 14435, 6], [14435, 16933, 7], [16933, 19998, 8], [19998, 22094, 9], [22094, 23906, 10], [23906, 26728, 11]], "pipe_delimited_lines_v1__pipe_delimited_lines_v1__pipe_delimited_lines_ratio": [[0, 26728, 0.11875]]}
olmocr_science_pdfs
2024-12-06
2024-12-06
f1d1e2f61196ac1faeffe1a368f6dfc1893529bc
Spark, an alternative for fast data analytics M. Tim Jones November 01, 2011 Although Hadoop captures the most attention for distributed data analytics, there are alternatives that provide some interesting advantages to the typical Hadoop platform. Spark is a scalable data analytics platform that incorporates primitives for in-memory computing and therefore exercises some performance advantages over Hadoop's cluster storage approach. Spark is implemented in and exploits the Scala language, which provides a unique environment for data processing. Get to know the Spark approach for cluster computing and its differences from Hadoop. 16 Feb 2012 - Added link to a Spark practice article to the introduction, Going further, and Resources sections Spark is an open source cluster computing environment similar to Hadoop, but it has some useful differences that make it superior in certain workloads—namely, Spark enables in-memory distributed datasets that optimize iterative workloads in addition to interactive queries. Spark is implemented in the Scala language and uses Scala as its application framework. Unlike Hadoop, Spark and Scala create a tight integration, where Scala can easily manipulate distributed datasets as locally collective objects. Experiment with Spark In this practice session, Data analysis and performance with Spark, explore multi-thread and multi-node performance with Spark and Mesos and its tunable parameters. (M. Tim Jones, developerWorks, February 2012). Although Spark was created to support iterative jobs on distributed datasets, it's actually complementary to Hadoop and can run side by side over the Hadoop file system. This behavior is supported through a third-party clustering framework called Mesos. Spark was developed at the University of California, Berkeley, Algorithms, Machines, and People Lab to build large-scale and low-latency data analytics applications. Spark cluster computing architecture Although Spark has similarities to Hadoop, it represents a new cluster computing framework with useful differences. First, Spark was designed for a specific type of workload in cluster computing —namely, those that reuse a working set of data across parallel operations (such as machine learning algorithms). To optimize for these types of workloads, Spark introduces the concept of in-memory cluster computing, where datasets can be cached in memory to reduce their latency of access. Spark also introduces an abstraction called resilient distributed datasets (RDDS). An RDD is a read-only collection of objects distributed across a set of nodes. These collections are resilient, because they can be rebuilt if a portion of the dataset is lost. The process of rebuilding a portion of the dataset relies on a fault-tolerance mechanism that maintains lineage (or information that allows the portion of the dataset to be re-created based on the process from which the data was derived). An RDD is represented as a Scala object and can be created from a file; as a parallelized slice (spread across nodes); as a transformation of another RDD; and finally through changing the persistence of an existing RDD, such as requesting that it be cached in memory. Applications in Spark are called drivers, and these drivers implement the operations performed either on a single node or in parallel across a set of nodes. Like Hadoop, Spark supports a single-node cluster or a multi-node cluster. For multi-node operation, Spark relies on the Mesos cluster manager. Mesos provides an efficient platform for resource sharing and isolation for distributed applications (see Figure 1). This setup allows Spark to coexist with Hadoop in a single shared pool of nodes. Figure 1. Spark relies on the Mesos cluster manager for resource sharing and isolation. Spark programming model A driver can perform two types of operations on a dataset: an action and a transformation. An action performs a computation on a dataset and returns a value to the driver; a transformation creates a new dataset from an existing dataset. Examples of actions include performing a Reduce operation (using a function) and iterating a dataset (running a function on each element, similar to the Map operation). Examples of transformations include the Map operation and the Cache operation (which requests that the new dataset be stored in memory). We’ll look at examples of these two operations shortly, but first, let’s get acquainted with the Scala language. Brief introduction to Scala Scala may be one of the Internet's best-kept secrets. You can find Scala in production at some of the Internet's busiest websites, including Twitter, LinkedIn, and Foursquare (with its web application framework, called Lift). There’s also evidence to suggest that financial institutions have taken an interest in the performance of Scala (such as EDF Trading's use for derivative pricing). Scala is a multi-paradigm language in that it supports language features associated with imperative, functional, and object-oriented languages in a smooth and comfortable way. From the perspective of object-orientation, every value in Scala is an object. Similarly, from the functional perspective, every function is a value. Scala is also statically typed with a type system both expressive and safe. In addition, Scala is a virtual machine (VM) language and runs directly on the Java™ Virtual Machine (JVM) using the Java Runtime Environment version 2 through byte codes that the Scala compiler generates. This setup allows Scala to run almost everywhere the JVM runs (with the requirement of an additional Scala run time library). It also allows Scala to exploit the vast catalog of Java libraries that exist, along with your existing Java code. Finally, Scala is extensible. The language (which actually stands for Scalable Language) was defined for simple extensions that integrate cleanly into the language. Scala's origins The Scala language began at the Ecole Polytechnique Federale de Lausanne (one of the two Swiss Federal Institutes of Technology in Lausanne, Switzerland). It was designed by Martin Odersky following his work on a programming language called Funnel that integrated ideas from functional programming and Petri nets. In 2011, the Scala design team received a 5-year research grant from the European Research Council, and the new company (Typesafe) formed to commercially support Scala received a funding round to begin operations. Scala illustrated Let's look at some examples of the Scala language in action. Scala comes with its own interpreter, allowing you to experiment with the language in an interactive way. A useful treatment of Scala is beyond the scope of this article, but you can find links to more information in Related topics. Listing 1 begins our quick tour of the Scala language through its interpreter. After starting Scala, you're greeted with its prompt, through which you can interactively evaluate expressions and programs. Begin by creating two variables—one being immutable (vals, called single assignment) and one being mutable (vars). Note that when you try to change b (your var), you succeed, but an error is returned when you attempt the change to your val. ### Listing 1. Simple variables in Scala ```scala $ scala Welcome to Scala version 2.8.1.final (OpenJDK Client VM, Java 1.6.0_20). Type in expressions to have them evaluated. Type :help for more information. scala> val a = 1 a: Int = 1 scala> var b = 2 b: Int = 2 scala> b = b + a b: Int = 3 scala> a = 2 <console>6: error: reassignment to val a = 2 ^ ``` Next, create a simple method that calculates and returns the square of an `Int`. Defining a method in Scala begins with `def`, followed by the method name and a list of parameters, then you set it to number of statements (in this example, one). No return value is specified, as it can be inferred from the method itself. Note how this is similar to assigning a value to a variable. I demonstrate this process on an object called `3` and a result variable called `res0` (which the Scala interpreter creates for you automatically). This is all shown in **Listing 2**. **Listing 2. A simple method in Scala** ```scala scala> def square(x: Int) = x*x square: (x: Int)Int scala> square(3) res0: Int = 9 scala> square(res0) res1: Int = 81 ``` Next, let's look at the construction of a simple class in Scala (see **Listing 3**). You define a simple `Dog` class that accepts a `String` argument (your name constructor). Note here that the class takes the parameter directly (with no definition of the class parameter in the body of the class). A single method exists that emits a string when called. You create a new instance of your class, and then invoke your method. Note that the interpreter inserts the vertical bars: They are not part of the code. **Listing 3. A simple class in Scala** ```scala scala> class Dog( name: String ) { | def bark() = println(name + " barked") | } defined class Dog scala> val stubby = new Dog("Stubby") stubby: Dog = Dog@1dd5a3d scala> stubby.bark Stubby barked ``` When you're done, simply type `:quit` to exit the Scala interpreter. **Installing Scala and Spark** The first step is to download and configure Scala. The commands shown in **Listing 4** illustrate downloading and preparing the Scala installation. Use the 2.8 version of Scala, because this is what Spark is documented as needing. **Listing 4. Installing Scala** ```bash $ sudo tar xvzf scala-2.8.1.final.tgz --directory /opt/ ``` To make Scala visible, add the following lines to your `.bashrc` (if you're using Bash as your shell): You can then test your installation, as illustrated in Listing 5. This set of commands loads the changes to the bashrc file, and then does a quick test of the Scala interpreter shell. **Listing 5. Configuring and running interactive Scala** ```bash $ scala Welcome to Scala version 2.8.1.final (OpenJDK Client VM, Java 1.6.0_20). Type in expressions to have them evaluated. Type :help for more information. scala> println("Scala is installed!") Scala is installed! scala> :quit $ ``` As shown, you should now see a Scala prompt. You can exit by typing `:quit`. Note that Scala executes within the context of the JVM, so you'll need that also. I'm using Ubuntu, which comes with OpenJDK by default. Next, get the latest copy of the Spark framework. To do so, use the script shown in Listing 6. **Listing 6. Downloading and installing the Spark framework** ```bash wget https://github.com/mesos/spark/tarball/0.3-scala-2.8/ mesos-spark-0.3-scala-2.8-0-gc86af80.tar.gz $ sudo tar xvfz mesos-spark-0.3-scala-2.8-0-gc86af80.tar.gz ``` Next, set up the spark configuration in ./conf/spar-env.sh with the following line for the Scala home directory: ```bash export SCALA_HOME=/opt/scala-2.8.1.final ``` The final step in setup is to update your distribution using the simple build tool (`sbt`). `sbt` is a build tool for Scala and has been used with the Spark distribution. You perform the update and compile step in the mesos-spark-c86af80 subdirectory as: ```bash $ sbt/sbt update compile ``` Note that you'll need to be connected to the Internet when you perform this step. When complete, run a quick test of Spark, as shown in Listing 7. In this test, you request to run the SparkPi example, which calculates an estimation of pi (through random point sampling in the unit square). The format shown requests the sample program (spark.examples.SparkPi) and the host parameter, which defines the Mesos master (in this case, your localhost, because it's a single-node cluster) and the number of threads to use. Notice that in Listing 7, two tasks are executed, but they are serialized (task 0 starts and finishes before task 1 begins). **Listing 7. Performing a quick test of Spark** ```bash $ ./run spark.examples.SparkPi local[1] ``` By increasing the number of threads, you can not only increase the parallelization of thread execution but also execute the job in less time (as shown in Listing 8). **Listing 8. Another quick test of Spark with two threads** $ ./run spark.examples.SparkPi local[2] Pi is roughly 3.14052 $ Building a simple Spark application with Scala To build a Spark application, you need Spark and its dependencies in a single Java archive (JAR) file. Create this JAR in Spark’s top-level directory with sbt as: $ sbt/sbt assembly The result is the file `./core/target/scala_2.8.1/Spark Core-assembly-0.3.jar`). Add this file to your CLASSPATH so that it’s accessible. In this example, you won’t use this JAR, because you’ll run it with the Scala interpreter instead of compiling it. For this example, use the standard MapReduce transformation (shown in Listing 9). The example begins with the necessary imports for the Spark classes. Next, you define your class (SparkTest), with its main method, which parses the arguments for later use. These arguments define the environment from which Spark will be executed (in this case, a single-node cluster). Next, create your SparkContext object, which tells Spark how to access your cluster. This object requires two parameters: the Mesos master name (passed in) and the name that you assign the job (SparkTest). Parse the number of slices from the command line, which tells Spark how many threads to use for the job. The last remaining item for setup is specifying the text file to use for the MapReduce operation. Finally, you get to the real meat of the Spark example, which consists of a set of transformations. With your file, invoke the flatMap method to return an RDD (through the specified function to split up the text line into tokens). This RDD is then passed through the map method (which creates the key-value pairs) and finally through the reduceByKey method, which aggregates your key-value pairs. It does this by passing the key-value pairs to the \_ + \_ anonymous function. This function simply takes two parameters (the key and value) and returns the result by appending them together (a String and an Int). This value is then emitted as a text file (to the output directory). **Listing 9. MapReduce in Scala/Spark (SparkTest.scala)** ```scala import spark.SparkContext import SparkContext._ object SparkTest { def main(args: Array[String]) { if (args.length == 0) { System.err.println("Usage: SparkTest <host> [<slices>]") System.exit(1) } val spark = new SparkContext(args(0), "SparkTest") val slices = if (args.length > 1) args(1).toInt else 2 val myFile = spark.textFile("test.txt") val counts = myFile.flatMap(line => line.split(" ")) .map(word => (word, 1)) .reduceByKey(_ + _) counts.saveAsTextFile("out.txt") } } SparkTest.main(args) ``` To execute your script, simply request execution with: ``` $ scala SparkTest.scala local[1] ``` You can find the MapReduce test file in the output directory (as output/part-00000). Other big data analytics frameworks Since Hadoop was developed, a number of other big data analytics platforms have arrived that may be worthy of a look. These platforms range from simple script-based offerings to production environments similar to Hadoop. One of the simplest is called bashreduce, which as the name suggests allows you to perform MapReduce-type operations across multiple machines in the Bash environment. bashreduce relies on Secure Shell (password-less) for the cluster of machines you plan to use, and then exists as a script through which you request jobs via UNIX®-style tools (sort, awk, netcat, and the like). GraphLab is another interesting implementation of the MapReduce abstraction that focuses on parallel implementation of machine learning algorithms. In GraphLab, the Map stage defines computations that can be performed independently in isolation (on separate hosts), and the Reduce stage combines the results. Finally, a newcomer to the big data scene is Storm from Twitter (through the acquisition of BackType). Storm is defined as the "Hadoop of real-time processing" and is focused on stream processing and continuous computation (stream results out as they're computed). Storm is written in Clojure (a modern dialect of the Lisp language) but supports applications written in any language (such as Ruby and Python). Twitter released Storm as open source in September 2011. See Related topics for more information. Going further Experiment with Spark In this practice session, Data analysis and performance with Spark, explore multi-thread and multi-node performance with Spark and Mesos and its tunable parameters.(M. Tim Jones, developerWorks, February 2012). Spark is an interesting addition to the growing family of big data analytics solutions. It provides not only an efficient framework for the processing of distributed datasets but does so in an efficient way (through simple and clean Scala scripts). Both Spark and Scala are under active development. However, with their adoption at key Internet properties, it appears that both have transitioned from interesting open source software to foundational web technologies. Related topics • In this practice session, Data analysis and performance with Spark, explore multi-thread and multi-node performance with Spark and Mesos and its tunable parameters. (M. Tim Jones, developerWorks, February 2012). • EDF Trading: Implementing a domain-specific language for derivative pricing with Scala: Scala has found adoption in a variety of industries, including stock trading. Learn about one example by watching this video. • Application virtualization, past and future (M. Tim Jones, developerWorks, May 2011) presents an introduction to virtual machine languages and their implementations. • Ceylon: True advance, or just another language? (M. Tim Jones, developerWorks July 2011) explores another interesting (work-in-progress) VM language that relies on the JVM. • First Steps to Scala is a great introduction to the Scala language (written in part by Martin Odersky, the designer of Scala). This lengthy introduction from 2007 covers many aspects of the language. Another useful example is Code Examples for Programming in Scala, which provides Scala recipes for a large variety of code patterns. • Distributed computing with Linux and Hadoop (Ken Mann and M. Tim Jones, developerWorks, December 2008) provides an introduction to the architecture of Hadoop, including the basics of the MapReduce paradigm for distributed processing of bulk data. • Distributed data processing with Hadoop (M. Tim Jones, developerWorks 2010): Find a practical introduction to Hadoop, including how to set up and use a single-node Hadoop cluster, how to set up and use a multi-node cluster, and how to develop map and reduce applications within the Hadoop environment. • developerWorks on Twitter: Follow us for the latest news. You can also follow this author on Twitter at M. Tim Jones. • Spark introduces an in-memory data analytics solution written and supported by the Scala language. • The simple build tool is the build solution adopted by the Scala language. It offers a simple method for small projects as well as advanced features for complex builds. • Lift is the web application framework for Scala, similar to the Rails framework for Ruby. You can find Lift in action at Twitter and Foursquare. • Mesos Project: Spark doesn’t support distribution of workloads natively but instead relies on this cluster manager that provides resource isolation and sharing across a network for distributed applications. • bashreduce (a Bash script-based implementation) and Storm (acquired by Twitter from BackType, a real-time distributed stream processing system written in Clojure): Hadoop kicked off a number of big data analytics platforms. Other than Spark, you can implement parallel computing architectures with these three offerings.
{"Source-Url": "https://www.ibm.com/developerworks/library/os-spark/os-spark-pdf.pdf", "len_cl100k_base": 4305, "olmocr-version": "0.1.53", "pdf-total-pages": 9, "total-fallback-pages": 0, "total-input-tokens": 20657, "total-output-tokens": 4833, "length": "2e12", "weborganizer": {"__label__adult": 0.0002142190933227539, "__label__art_design": 0.0001964569091796875, "__label__crime_law": 0.00019252300262451172, "__label__education_jobs": 0.00036263465881347656, "__label__entertainment": 5.447864532470703e-05, "__label__fashion_beauty": 8.726119995117188e-05, "__label__finance_business": 0.00026297569274902344, "__label__food_dining": 0.00025343894958496094, "__label__games": 0.0003349781036376953, "__label__hardware": 0.0007333755493164062, "__label__health": 0.000293731689453125, "__label__history": 0.000133514404296875, "__label__home_hobbies": 6.335973739624023e-05, "__label__industrial": 0.00027561187744140625, "__label__literature": 0.0001323223114013672, "__label__politics": 0.00013363361358642578, "__label__religion": 0.0002503395080566406, "__label__science_tech": 0.0204620361328125, "__label__social_life": 7.2479248046875e-05, "__label__software": 0.0232696533203125, "__label__software_dev": 0.95166015625, "__label__sports_fitness": 0.00019156932830810547, "__label__transportation": 0.00025081634521484375, "__label__travel": 0.00015234947204589844}, "weborganizer_max": "__label__software_dev", "avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_ratio": [[0, 19956, 0.02071]], "fineweb_edu_fasttext_gt2__fineweb_edu_fasttext_gt2__score": [[0, 19956, 0.69986]], "ft_lang_id_en_doc_v2__ft_lang_id_en_doc_v2__en": [[0, 19956, 0.88668]], "google_gemma-3-12b-it_contains_pii": [[0, 2154, false], [2154, 4905, null], [4905, 7596, null], [7596, 9727, null], [9727, 11970, null], [11970, 12751, null], [12751, 15021, null], [15021, 17197, null], [17197, 19956, null]], "google_gemma-3-12b-it_is_public_document": [[0, 2154, true], [2154, 4905, null], [4905, 7596, null], [7596, 9727, null], [9727, 11970, null], [11970, 12751, null], [12751, 15021, null], [15021, 17197, null], [17197, 19956, null]], "google_gemma-3-4b-it_v2tag__is_academic_paper": [[0, 5000, true], [5000, 19956, null]], "google_gemma-3-4b-it_v2tag__is_class_syllabus": [[0, 5000, false], [5000, 19956, null]], "google_gemma-3-4b-it_v2tag__is_completion_certificate": [[0, 5000, false], [5000, 19956, null]], "google_gemma-3-4b-it_v2tag__is_court_notice": [[0, 5000, false], [5000, 19956, null]], "google_gemma-3-4b-it_v2tag__is_homework_assignment": [[0, 5000, false], [5000, 19956, null]], "google_gemma-3-4b-it_v2tag__is_news_article": [[0, 5000, false], [5000, 19956, null]], "google_gemma-3-4b-it_v2tag__is_public_order": [[0, 5000, false], [5000, 19956, null]], "google_gemma-3-4b-it_v2tag__is_resume_cv": [[0, 5000, false], [5000, 19956, null]], "google_gemma-3-4b-it_v2tag__is_test_or_quiz": [[0, 5000, false], [5000, 19956, null]], "google_gemma-3-4b-it_v2tag__is_textbook": [[0, 5000, false], [5000, 19956, null]], "pdf_page_numbers": [[0, 2154, 1], [2154, 4905, 2], [4905, 7596, 3], [7596, 9727, 4], [9727, 11970, 5], [11970, 12751, 6], [12751, 15021, 7], [15021, 17197, 8], [17197, 19956, 9]], "pipe_delimited_lines_v1__pipe_delimited_lines_v1__pipe_delimited_lines_ratio": [[0, 19956, 0.00581]]}
olmocr_science_pdfs
2024-12-07
2024-12-07
81bea240b3595abf84a90a02f52a8443cdac6e41
Abstract—Conceptual Integrity has been claimed to be the essence of high-quality software system design. On the other hand, it has been a rather elusive attribute of software systems, challenging various attempts of a clear-cut characterization. This paper evolves in this direction by two means: first, by analysis and clarification of open issues in architecture and abstraction terms; second, by pointing out to a mathematical formulation in algebraic terms. This paper also serves as a broad introduction to discussions on “Conceptual Integrity of Software Systems”. Keywords: Conceptual Integrity; software system design; architecture; abstraction; algebra; Linear Software Models; Modularity Matrix; Conceptual lattice; plausibility criteria; design constraints. I. INTRODUCTION Frederick Brooks [2], [3], based upon his extensive experience with system development, in particular the first families of OS/360 operating systems, proposed that Conceptual Integrity is essential for high-quality software system design. It takes some time to assimilate this idea, but even after reading about it once and again and having second and third thoughts, Conceptual Integrity remains attractive, but a quite elusive notion. The first task of this paper is to introduce the notion, its attractiveness and why it is still elusive. Then, we argue in favor of mathematical formalization, like in any respectable science. The overall purpose of this paper is to try to open and discuss deep issues on “Conceptual Integrity of Software Systems” and to point out to a formal solution to these issues. A. The Notion of Conceptual Integrity Software system design and development, as it is common practice nowadays, gives a superficial impression of unrestricted flexibility, where everything is allowed and nothing is forbidden. Often practitioners think that software design and development is an art, rather than a science. People exposing this opinion may express distaste for suggestions of mathematical description of the processes involved. The feeling of unrestricted flexibility and its artistic connotation is acquired from the first experiences with computer programs that one writes. Except for an apparent arbitrariness of the programming language syntax, one has full confidence in the choice of the preferred programming construct – this is the unrestricted flexibility – and the program is supposed to run for sure. Then, happens the inevitable bug, demanding a subtle correction – this is the artistic connotation. A widespread rational response to the artistic flexibility is to introduce methodologies. If one is methodical, then the price of software design and development should decrease. This is the first encounter with elusiveness (cf. the word “Mythical” in the title of the earlier book by Brooks). Any experienced software developer knows that methodologies are not the panacea that they promise to be. They fail, sometimes miserably. Then, Conceptual Integrity, by Brooks, enters the stage. This is a deeper response to the software system development problem. We explain the notion in literally architecture terms, exactly as in Brooks’ books, while presenting open issues in section III. B. Paper Organization The remaining of the paper is organized as follows. Section II refers to related work. Section III introduces open issues of Conceptual Integrity in a broad context. Section IV focuses on architecture principles. Section V turns to abstraction principles. Section VI summarizes algebraic principles of software design. Section VII concludes with a discussion. II. RELATED WORK A. Conceptual Integrity Outside Software Systems This paper refers to Architecture of buildings in general, following Brooks’ metaphors used in his books to illustrate notions of Conceptual Integrity. In this context, we refer here to a few architecture-related modeling techniques and ontologies. DeLuca and co-authors [5] describe a generic formalism for semantic modeling of architectural elements, which compose buildings of historic interest in classical architecture. Doerr [8] reviews ontologies for cultural heritage; he emphasizes physical objects in archeology, including architecture. Quatrini et al. [22] describe modern computer-based techniques for semantically-aware 3D modeling of architecture. Conceptual Integrity Within Software Systems Conceptual Integrity is closely related to efforts regarding various development phases of software systems. These efforts are among others: requirements engineering, conceptual modeling, integrity verification, software system design, and software architecture planning. The relevant literature is very extensive, and we provide just a few representative pointers. Jackson and co-authors [6],[17],[18] analyzed widely used software systems, such as Git, in terms of Conceptual Integrity, suggesting design improvements. Insfran et al. [16] refer to conceptual modeling based on requirements engineering. For these authors conceptual modeling is an UML object-oriented approach rather than based on conceptual integrity. Nevertheless, there are similarities between these approaches, as discussed later on. Cabot and Teniente [4] refer to integrity checking of UML/OCL conceptual schemas. Integrity here means software state conditions that must be satisfied. Sometimes it specifically refers to avoidance of critical system malfunction. Conceptual schemas are basic relations between concepts within the general knowledge required by any information system (see also e.g. the book by Olive [21]). Kazman and Carriere [19] reconstruct a software system architecture using conceptual integrity as a guideline. Their goal is to achieve a restricted number of components connected in regular ways, with internally consistent functionality. C. Mathematical Conceptual Integrity of Software In this work we shall mainly refer to the Modularity Matrix [9],[10],[13] which is based upon linear algebra. Other matrices have been used for modular design. For instance, the Design Structure Matrix (DSM) is an integral part of the ‘Design Rules’ by Baldwin and Clark [1]. It has been applied for various kinds of systems, including software systems. DSM design quality is estimated by an external economic theory superimposed on the DSM matrix. Conceptual lattices, analyzed within Formal Concept Analysis (FCA) were introduced in Wille [24]. A generic review of its mathematical foundations is given by Ganter and Wille [14]. Conceptual Lattices have been shown to be equivalent to Modularity Matrices (e.g. Exman and Speicher [12]), linking the algebraic characteristics to conceptual ones. III. OPEN ISSUES: ARCHITECTURE, ABSTRACTION, ALGEBRA We now consider the open issues of Conceptual Integrity in a wide context. We start by referring to it in architecture terms. Then we consider abstraction and algebraic formulations. A. Open Issues: Architecture In Brooks’ book “The Mythical Man-Month” [2] in front of the fourth chapter opening (page 41) there is a photo of the interior of the Reims cathedral, planned by Jean D’Orbais. An annotated sketch of the cathedral is seen in Fig. 1 in this paper. It has an imposing huge height relative to humans, as usual for medieval gothic cathedrals, implying the difficulty to actually build it. Nonetheless, despite the incredible weight of its stones, it displays elegance, coherence, and symmetry of its component forms: e.g. long repetitive rows of identical very high columns and two symmetrical stained glass rose windows above the altar region. Another example is the renaissance cathedral of Firenze, whose symmetric dome with repetitive elements was designed by Brunelleschi. It is seen in Fig. 6-4 (page 75) in “The Design of Design” [3] book by Brooks. Thus, Conceptual Integrity in classical, medieval and renaissance architecture means that the overall structure is immediately recognized by its repetitive and symmetric components’ consistency, and is very attractive by its esthetics. The Guggenheim Museum in Bilbao, designed by the architect Frank Gehry, has been metaphorically referred to as a modern cathedral, due to its enormous size, in particular the huge height of its atrium [15]. Fig. 2 is an annotated sketch of it. Moreover, it seems to be very consistent, by the similarity of materials and forms, to resemble a ship – since Bilbao is a port. In fact, it was designed with the support of the Digital Project (see e.g. [7]), which itself is based upon CATIA a sophisticated software system used to plan modern aircraft. On the other hand, nothing is repetitive or symmetric in the Bilbao Museum. There are no two identical components in the Museum. We thought that we had the keys to the notion of Integrity, but, modern architecture breaks down the older keys. This is our second encounter with elusiveness. We are left with the open issue: Open Issue #1 – Conceptual Integrity in Architecture Despite symmetries being fundamental to physics – i.e. they correspond to conservation principles – and being important in classical architecture, symmetries are not ubiquitous in modern architecture. What is the generalization of symmetry that is common to Conceptual Integrity in all kinds of architecture? Paradoxically one still could say that the Bilbao Museum displays an internal Conceptual Integrity – the ship outline – and even to the apparently dissimilar buildings of the city of Bilbao. Moreover, the outer titanium metal sub-structures reflect light like fish scales! But how is ship and fish related concepts? This is discussed in the next sub-section on Abstraction. B. Open Issues: Abstraction We shall refer to abstraction in two senses: first, geometric or image abstraction; second, conceptual abstraction. Regarding geometric abstraction, we mean that any considerations of Integrity are not taken with respect to the actual buildings referred to in the previous architecture sub-section. Neither real stone blocks, nor titanium metal surfaces are necessary to perceive symmetry or the “ship” shape. One performs quite complex abstraction operations in the human brain, which are simulated by computer image processing – noise elimination, segmentation, and object recognition – to extract just the lines needed to infer either symmetry as in Fig. 3 or a “ship” shape as in Fig. 4. Conceptual abstraction is a further step beyond geometric abstraction. In the cathedral case the relevant concepts are “columns” and “stained glass rose window”, together with the even more abstract concept of “symmetry”. The next step in conceptual abstraction is the usage of architecture domain ontologies (see e.g. [8]). In the Bilbao Museum case, relevant concepts could be “port” of Bilbao, “ship” and “fish”. These could be found in Maritime domain ontologies (see e.g. [23]). But, the conceptual jump from these specific concepts to a Museum of modern art architecture is far from obvious. Then: Open Issue #2 – Abstraction Conceptual Integrity Abstraction Conceptual Integrity seems to be intrinsically associative irrespective of the relevant domain. How to formally capture the associative character of abstraction Conceptual Integrity? C. Open Issues: Algebra Let us temporarily take for granted that Algebra is the mathematical basis of our formal approach to Conceptual Integrity – an approach extensively justified elsewhere (see e.g. [10], [11]), with respective arguments presented later on in this paper. In order to apply algebra to concepts we do not try to get an answer to Open Issue #2. Instead, we assume that the associative process of choosing sets of abstraction concepts – as discussed in the previous sub-section – is done by human software engineers, without any current attempt to formalize this process. The algebraic phase of Conceptual Integrity starts with the chosen sets of concepts that humans find necessary to build a desired software system. We have called the specific ontology relevant to a desired software system as “application ontology”. One can easily see that application ontologies have a striking similarity to UML class diagrams. Ontology concepts correspond to classes, and relationships among classes are of three kinds: inheritance (a sub-class is a type of class), composition (wholes are made of parts) and association (say usage of the functionality of another class). Thus, we deal with classes and their functionalities, and their respective generalizations. What is lacking in the above picture? The answer is: we lack criteria to verify that the choice of concepts is reasonable. This is the role of algebra. Thus: Open Issue #3 – Algebraic Conceptual Integrity Assume that humans choose the needed concepts relevant to a desired software system, by a black-box algorithm. What are the criteria to verify that the concepts choice indeed comply with an idea of Conceptual Integrity for the desired software system? IV. ARCHITECTURE PRINCIPLES The answer to the Open Issue #3 starts with the understanding that in any domain there are constraints limiting solutions. We start as in the previous section with principles of architecture. A. Structure: Buildings and Software The basic constraints obeyed by any building, either in antiquity or in modern times are first and foremost the laws of static – the branch of classical mechanics (itself a field of physics) dealing with structures which have no motion. One should have columns and beams to support structures of a building, a bridge over a bay or tunnels below a river. These columns and beams have a material composition, say concrete or steel, and suitable sizes and forms. Modern constructions have additional constraints, such as heating, acoustics, distribution of electricity and water tubing. Software structures, just as buildings, are hierarchical with classes and patterns – as sets of classes – being the relevant structural units. The relevant constraints are enforced by the above mentioned relationships already found in the application ontologies – viz. inheritance, composition and association. B. Behavior: Flying and Running Systems Physical systems displaying motion, such as airplanes, autonomous cars, robots, helicopters, boats and drones (unmanned aircraft systems) may fly, walk, navigate, etc. In addition to structural constraints, they have kinematic constraints limiting their motion in terms of speed and possible trajectories. Software systems when running also have constraints on their speeds, communication and memory usage. These are certainly affected by their structural constraints. With the increasing usage of autonomous systems, with embedded software, the software itself is also affected by the constraints of the containing physical systems. C. Modularity Modularity is an important consideration for any system, as it facilitates development, building and understanding of systems. Modularity is achieved by simplistic repetitive reuse of the same units again and again – such as the stones in the columns of the Reims cathedral, and wheels in mobile vehicles. Modularity maybe also achieved by more sophisticated means than strict repetition. The titanium metallic surfaces of the Bilbao Museum are each of them unique, but they are generated by a software system which reuses the same technology to obtain different shapes. Modularity is the result of complying with constraints, partially relaxing them as far as possible while minimizing undesirable effects. This is true in particular for software systems. V. ABSTRACTION PRINCIPLES In this section we deal with abstraction principles. Abstraction here is understood as conceptual abstraction for system design. We further focus only on embedded software or purely software system design. The abstraction principles express the necessary constraints which limit design to modular solutions. Concomitantly these provide the criteria to verify that design solutions are optimal under these constraints. In terms of the abstract concepts, this is the meaning of Conceptual Integrity. Conceptual abstraction principles were first formulated by Brooks in his books [3]. Here we succinctly review these principles. Note that all the three principles are formulated as negative expressions, i.e. “Do not...”, which are effectively constraining design and meaning. A. Abstract Propriety Brooks concisely formulates propriety as: “Do not introduce what is immaterial”. He explains this principle by an example of propriety in computers, viz. the representation of zero in twos-complement notation, which obeys the constraint of not attaching a sign to zero. In contrast, signed-magnitude and ones-complement representations do attach a sign to zero, which is extraneous and inconsistent with the original meaning of the “zero” concept. The consequence of these representations is addition of artificial rules needed to characterize the behavior of zero in arithmetic operations. **B. Abstract Orthogonality** Brooks concisely formulates orthogonality as: “Do not link what is independent”. He explains this principle by a basic example of orthogonality in computers, viz. the operation of a (software or embedded) alarm clock. Two functionalities of such a clock are lighting and alarm. Orthogonality means that these two functionalities obey the constraint of actually being independent. In contrast, if the alarm would operate only when the clock is illuminated, it would violate orthogonality, since one is artificially linking two unrelated functionalities. **C. Abstract Generality** Brooks concisely formulates generality as: “Do not restrict what is inherent”. He explains this principle by a surprising example of generality of an operation in a processor, viz. the operation “restart”. Its original purpose was to restart a process after an interruption. But the design generality enabled its use as returning from a subroutine. The obeyed constraint here is avoiding incidental restriction. In contrast, if it were strictly allowed only for the original purpose, one would clutter the design by introducing another almost overlapping concept for the second kind of usage. **VI. ALGEBRA: PRINCIPLES OF SOFTWARE DESIGN** The power of a mathematical formalism is to express the abstract constraints in a precise way, enabling calculations upon the representation of a given software system design – e.g. of eigenvectors [11],[20] to obtain software modules –, and the verification whether the design comply with the imposed constraints. Moreover, one can improve the software design, based upon the verification results. The choice of linear algebra structures, such as the Modularity Matrix and its equivalents, is justified by the following reasons: - **Expressivity** – algebraic structures are expressive enough to represent the wide variability of software structures; - **Constraints Nature** – it is very natural to formulate Brooks’ abstraction constraints in algebraic terms, as will be seen in the following sub-sections; - **Conceptual Meaning** – since each Modularity Matrix of a software system is equivalent to its corresponding Conceptual Lattice, the Conceptual meanings are immediately taken into account. **A. Algebraic Propriety** The algebraic translation of Brooks’ Propriety is based upon the following ideas [10]. Instead of sets of classes (the concepts), one works with vectors of classes. Structors are generalized classes to all levels of the hierarchical software system. Structors provide functionalities. Thus, one also has functional vectors. In order to avoid immaterial additions, i.e. the design goal is to minimize the representation of a software system, the algebraic **Propriety** constraint is: *linear independence* of all the structor vectors and of all the functional vectors in the Modularity Matrix of the given software system. Any dependent vector is superfluous and discarded. **B. Algebraic Orthogonality** The algebraic translation of Brooks’ Orthogonality is even more immediate. One literally uses exactly the same word orthogonality, but now with the exact algebraic meaning of “zero scalar product of a pair of vectors”. The algebraic **Orthogonality** constraint is: orthogonality of all structor vectors and all functional vectors inside a module to the respective vectors in all other modules in the Modularity Matrix of the given software system. Thus, different software modules actually deal with different concerns, literally having different conceptual meanings. **C. Algebraic Generality** The algebraic translation of Brooks’ Generality is that since the definition of a structor or its functionalities are not strictly repeated in another location of the same software system, one still can re-use these structors and their functionalities elsewhere in the same system by means of composition or by means of aspect-oriented design. The algebraic **Generality** constraint is: generality once again minimizes the number of appearances of structor vectors and functional vectors in various hierarchical levels of the Modularity Matrix of the given software system. On the other hand, in an aspect-oriented design fashion, one puts the general structors/functional in a high enough hierarchical level, to be accessible from anywhere in the system. **VII. DISCUSSION** We here summarize the important points of this paper. Brooks’ used architecture of cathedrals to justify his Conceptual Integrity principles. Indeed the architecture of buildings provides fruitful metaphors in our context, as we have seen that one obtains valuable concepts from the building abstractions. But, even more importantly, they lead to open issues challenging simplistic notions of Conceptual Integrity. **A. Eliciting Concepts** Concept elicitation from system stakeholders, using system sketches, drafts or early models, is an activity related to requirements engineering. It demands high human capabilities and in this paper this activity was left to the human engineers. We currently give up any effort to mathematical formalize this activity. It may well be that we shall return to this basic issue in future work. We deliberately assumed that one starts the Conceptual Integrity analysis from an initial list of concepts – translated into structor and functional vectors. This initial list may change along the design and development processes. B. Criteria for Integrity Brooks’ principles actually are constraints on the software system design solutions. Once this is understood, one can clearly express algebraic equivalent formulations of the same principles. The propriety and orthogonality constraints received a very natural translation to linear algebra notions. The generality principle seems to deserve further investigation. C. Main Contribution The main contribution of this paper is a set of open issues to be discussed within a Conceptual Integrity forum, and the clear understanding of its principles, as mathematical constraints on the design solution for a software system. REFERENCES
{"Source-Url": "https://ksiresearchorg.ipage.com/seke/seke17paper/seke17paper_206.pdf", "len_cl100k_base": 4495, "olmocr-version": "0.1.49", "pdf-total-pages": 6, "total-fallback-pages": 0, "total-input-tokens": 19057, "total-output-tokens": 6564, "length": "2e12", "weborganizer": {"__label__adult": 0.0005540847778320312, "__label__art_design": 0.00235748291015625, "__label__crime_law": 0.0005044937133789062, "__label__education_jobs": 0.0015592575073242188, "__label__entertainment": 0.00013303756713867188, "__label__fashion_beauty": 0.0002446174621582031, "__label__finance_business": 0.000244140625, "__label__food_dining": 0.0005483627319335938, "__label__games": 0.00095367431640625, "__label__hardware": 0.0007634162902832031, "__label__health": 0.0009746551513671876, "__label__history": 0.00040793418884277344, "__label__home_hobbies": 0.00013709068298339844, "__label__industrial": 0.00046181678771972656, "__label__literature": 0.0010738372802734375, "__label__politics": 0.0003170967102050781, "__label__religion": 0.0008320808410644531, "__label__science_tech": 0.049285888671875, "__label__social_life": 0.00014066696166992188, "__label__software": 0.007282257080078125, "__label__software_dev": 0.93017578125, "__label__sports_fitness": 0.0003476142883300781, "__label__transportation": 0.0006699562072753906, "__label__travel": 0.00023806095123291016}, "weborganizer_max": "__label__software_dev", "avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_ratio": [[0, 27686, 0.02071]], "fineweb_edu_fasttext_gt2__fineweb_edu_fasttext_gt2__score": [[0, 27686, 0.5932]], "ft_lang_id_en_doc_v2__ft_lang_id_en_doc_v2__en": [[0, 27686, 0.91169]], "google_gemma-3-12b-it_contains_pii": [[0, 4333, false], [4333, 8030, null], [8030, 11213, null], [11213, 16885, null], [16885, 22308, null], [22308, 27686, null]], "google_gemma-3-12b-it_is_public_document": [[0, 4333, true], [4333, 8030, null], [8030, 11213, null], [11213, 16885, null], [16885, 22308, null], [22308, 27686, null]], "google_gemma-3-4b-it_v2tag__is_academic_paper": [[0, 5000, true], [5000, 27686, null]], "google_gemma-3-4b-it_v2tag__is_class_syllabus": [[0, 5000, false], [5000, 27686, null]], "google_gemma-3-4b-it_v2tag__is_completion_certificate": [[0, 5000, false], [5000, 27686, null]], "google_gemma-3-4b-it_v2tag__is_court_notice": [[0, 5000, false], [5000, 27686, null]], "google_gemma-3-4b-it_v2tag__is_homework_assignment": [[0, 5000, false], [5000, 27686, null]], "google_gemma-3-4b-it_v2tag__is_news_article": [[0, 5000, false], [5000, 27686, null]], "google_gemma-3-4b-it_v2tag__is_public_order": [[0, 5000, false], [5000, 27686, null]], "google_gemma-3-4b-it_v2tag__is_resume_cv": [[0, 5000, false], [5000, 27686, null]], "google_gemma-3-4b-it_v2tag__is_test_or_quiz": [[0, 5000, false], [5000, 27686, null]], "google_gemma-3-4b-it_v2tag__is_textbook": [[0, 5000, false], [5000, 27686, null]], "pdf_page_numbers": [[0, 4333, 1], [4333, 8030, 2], [8030, 11213, 3], [11213, 16885, 4], [16885, 22308, 5], [22308, 27686, 6]], "pipe_delimited_lines_v1__pipe_delimited_lines_v1__pipe_delimited_lines_ratio": [[0, 27686, 0.0]]}
olmocr_science_pdfs
2024-11-27
2024-11-27
979b0928646ed598cb0c5c4cc265d3468a8d5bb9
Abstract This paper is in regards to the various research produced for Spring 2012 Undergraduate Research under Dr. Hohlmann, and in collaboration with Dr. Mitra, and the High Energy Physics Group A. The research this semester has covered a wide area. First focusing on getting results using POCLUST and CLUSTVIZ on real data that contained depleted Uranium and Lead. After that, the research principally focused on the future of Vx4D, POCLUST, CLUSTVIZ, and all the work done with Dr. Hohlmann and Dr. Mitra during my undergraduate career. # Contents 1 Introduction 3 1.1 Before FAS 2012 Annual Conference 3 1.2 After the FAS 2012 Annual Conference 3 2 POCLUST 5 2.1 POCLUST Overview 5 2.2 Key Parameters in POCLUST 5 2.3 Building POCLUST and using POCLUST 5 3 CLUSTVIZ 6 3.1 CLUSTVIZ Overview 6 3.2 Building CLUSTVIZ 6 3.3 Using CLUSTVIZ 7 4 FAS 2012 Results 8 4.1 The dataset setup 8 4.2 The raw data 10 4.3 POCLUST Parameters settings 10 4.4 CLUSTVIZ output 10 5 POCLUST Rewrite 12 5.1 The Goals 12 5.2 The structure 13 5.3 Abstracting Clustering Algorithms 13 6 Parallel and Distributed Clustering using Hadoop 14 7 The inclusion of Vx4D into ROOT 19 7.1 The use of TVxND 19 A Appendix A - Source Code Locations 20 A.1 CLUSTVIZ, POCLUST, GenericClust, Vx4D 20 A.2 ROOT with TVx4D and future additions 20 B Appendix B - Source Code Manuals 20 C GenericClust - the POCLUST rewrite 20 D POCLUST and CLUSTVIZ source documentation 20 I. INTRODUCTION The semester can essentially be split into two main parts: 1.1 Before FAS 2012 Annual Conference This period of time was spent extending and concluding the research performed in the Fall of 2011, primarily focused on producing results from the world on POCLUST and CLUSTVIZ in order to present them at the FAS 2012 Annual conference. The target scenario was the "5 on a die" scenario, which featured 5 blocks of material including depleted Uranium in the middle. The goal was the be able to isolate the Uranium from the surrounding materials, using POCLUST, and to show that Muon Tomography and POCLUST is a viable solution for detecting Shielded Nuclear Weapons in Cargo POCLUST POCLUST is a density based clustering algorithm, that was created by Dr. Mitra, originally based on the clustering of GEANT4 simulation data of the Muon Tomography station. It was created to be able to classify POCA points into "clusters" and with those clusters, calculate properties to be able to identify the material of the cluster. This is central for the detection of uranium inside lead shielding CLUSTVIZ I created CLUSTVIZ in the Fall of 2011 to be able to visualize the output of POCLUST in comparison to the original target positions, using OpenGL and Linux, and to be able to calculate a metric for comparing results 1.2 After the FAS 2012 Annual Conference After the FAS 2012 Annual Conference, efforts were mainly focused on bringing together all the research that I have done for Dr. Hohlmann over my Undergraduate Career and get it ready to be passed on to the future of the High Energy Physcis Group A. Furthermore, I wanted to continue my research while working at IBM, so directions were chosen that would align with both the Group’s interest, and what would be possible, and most optimal while persuing my career at IBM. This period of research can be broken down into the following parts: POCLUST rewrite The POCLUST code base originally obtained in the Fall of 2011 was long needed of a rewrite. Furthermore, with the consideration of future students continuing the research, I wanted the essential parts of the Algorithm to be easily abstracted, so that future students can do research on the Algorithm, without being concerned about the entirety of the working internals. This would allow students a low learning curve to get started with POCLUST, and therefore increase the probability of it being continued. Parallel and Distributed Clustering using Hadoop Hadoop is growing in huge popularity in the sector of Big Data and Data Analytics, and runs seamlessly on a cloud infrastructure, all three of which belong to IBM’s top 5 initiatives. Furthermore, if any complex methods of the optimization of POCLUST parameters were going to be used, much more computational power would be needed. Therefore, by bringing POCLUST to a parallel and distributed architecture through Apache Hadoop, this would align both the Group’s interest, and that of my professional career. Therefore, much research was done in this area The inclusion of Vx4D into ROOT ROOT is an object oriented data analysis framework built by CERN. All of the research students are familiar with ROOT, and it is used extensively within the High Energy Physics Lab A. Vx4D is a stand alone software package I build for the High Energy Physics Group A initially. It is customized exactly to our needs, and had to be created because of the lack of 4D Voxelized Data visualization software available. ROOT was currently being used for doing 2D imaging on the data with "slices". In order to remove the necessity to maintain the framework of Vx4D, research was done to integrate Vx4D into ROOT. Therefore, future Undergraduate students can simply use ROOT’s scripting ability to call Vx4D just like they would any other histogram. II. POCLUST 2.1 POCLUST Overview - POCA Points are read in, unvoxelized - Simple thresholds applied to remove major noise - Clustering of the POCA points begin - Deletion or removal of "sporadic" clusters occurs on intervals - Merging of Clusters that meet criteria - When all the points have been processed, output is visualized in OpenGL and compared to original targets in wireframes 2.2 Key Parameters in POCLUST MAX_POINTS_IN_CLUSTER This is the number of points at which, greater than this, the cluster no longer uses a euclidean measure, and uses a measure based euclidean distance multiplied by a factor of $\Theta^2 / \text{ClusterVariance}$ a.k.a DM Measure MAX_L2_NORM_DIST This is the maximum distance a point can be from a cluster when using the euclidean measure MAX_DM_NORM_DIST This is the maximum distance a point can be from a cluster when using the DM measure angleThresh If the $\text{Percent} < 4$ and the number of points is greater than 50, then the cluster is "thrown" away, where $\text{Percent} =$ The percent of POCA points within that cluster that has an average deflection angle of $\angle$ the parameter angleThresh MinPercent two clusters are said to be similar if $\text{abs}(\text{Percent of Cluster1} - \text{Percent of Cluster2}) < \text{MinPercent}$ and also for MinVariance MinVariance two clusters are said to be similar if $\text{abs}(\text{Percent of Cluster1} - \text{Percent of Cluster2}) < \text{MinVariance}$ and also for MinPercent CENTROID_DISTANCE two clusters are said to be isClose() if the euclidean distance between the two centroids is $< \text{CENTROID\_DISTANCE}$ OVERLAP_PERCENTAGE two clusters are said to overlap() if $(\text{overlapVolume} / (\text{volumeCluster1} + \text{volumeCluster2})) > \text{OVERLAP\_PERCENTAGE}$ 2.3 Building POCLUST and using POCLUST To build POCLUST, it is quite easy. If you are in the /poclust/algo/ directory, make sure you: 1. unvoxelized poca file is copied to the file input.txt 2. edit input.txt, and make sure the first line the in dimensions of the volume i.e. "300 300 300" 3. type in ./build.sh 4. the cluster_vis_output.m is the file that CLUSTVIZ will take as a POCLUST output III. CLUSTVIZ 3.1 CLUSTVIZ Overview CLUSTVIZ was built in order to visualize the POCLUST output, and be able to compare it to the original target locations. It does this by take two files as parameters, one file being the original target location, and one being the output from the POCLUST cluster_vis_output.m. The white cubes inside of the volume represent the original targets, and the opaque objects represent the clustered objects. The color represents the mean scattering angle of that cluster. Figure 1: CLUSTVIZ example output, white boxes are the original target locations, and the opaque objects are the clusters from POCLUST 3.2 Building CLUSTVIZ CLUSTVIZ, requires the same packages as Vx4D to be built. It also uses a make.sh file. The following packages are required: - directfb (libdirectfb-dev) • stdc++ (libstdc++6-4.4-dev or apt-cache search libstdc++ for current version) • libglu1-mesa-dev • libglib2.0-dev • libgl1-mesa-dev • libx11-dev • freeglut-dev (glutg3-dev) After those development libraries are installed, go to the /verb!/poclust/visual/! directory and type: ./make.sh After that, go to the bin directory, and you will see a file named: pvis That is the executable 3.3 Using CLUSTVIZ When using CLUSTVIZ, you need two files, you need the cluster_vis_output.m file from POCLUST, and you need a file describing the original targets, Targets.dat or whatever you want to name it. Then you run it by: ./pvis Targets.dat cluster_vis_output.m Of course, you can name the files what ever you want. The import thing is that Targets.dat is setup properly. Here is an example of the "5 on a die" scenario. 300 300 300 43 43 43 -48.8 -10.5 -45.5 1 1 43 43 43 47.5 -10.5 -46.5 1 1 43 43 43 -47.5 -10.5 44.5 1 1 43 43 43 47.5 -10.5 44.5 1 1 54 54 54 0 -5 0 1 1 The first line is ALWAYS the dimensions of the space. This must be the same dimensions you gave to POCLUST for the data. It goes X Y Z Each line after that, the format is ObjXLen ObjYLen ObjZLen ObjXPos ObjYPos ObjZPos 1 1 Note: Y is the height, and Z is the distance from the viewer into the horizon, -z would be closer to you, this is the OpenGL coordinate system IV. FAS 2012 Results This section covers the results presented at the FAS 2012 Annual meeting, in which the latest POCLUST results were presented on the "5 on a die" real data, focusing on being able to distinguish between the Lead and the Depleted Uranium. 4.1 The dataset setup The dataset was the "5 on a die" scenario, which was taken by Mike Staib, on the Cubic Foot MTS Station, around early February 2012. The targets were setup as follows: The dimensions given to the POCLUST algorithm were "300 300 300". The original target positions for CLUSTVIZ were: ``` 300 300 300 43 43 43 -48.5 -10.5 -45.5 1 1 43 43 43 47.5 -10.5 -46.5 1 1 43 43 43 -47.5 -10.5 44.5 1 1 43 43 43 47.5 -10.5 44.5 1 1 54 54 54 0 -5 0 1 1 ``` Figure 2: The top left is W, Top right is Pb, Bottom left is Sn, and bottom right is Fe Figure 3: Vx4d output of "5 on a die" without any cuts applied Figure 4: Vx4d output of "5 on a die" with manual cuts applied #define DOCA_cut 1 #define angThresh 4 #define MAX_L2_NORM_DISTANCE 100 #define MAX_DM_DISTANCE 1000 #define MAX_CLUSTERS 20000 //max no of clusters inside a voxel.. #define MinPointsInCluster 100 //this means that there should be 200 points inside a cluster, and after that only Bayesian inference will be derived... #define MAX_OBJECTS 20000 #define PO 3 #define DENSITY_THRESH 1 #define TIME_STAMP 10000 #define OVERLAP_PERCENT 10 #define CENTROID_DISTANCE 250 #define MIN_VARIANCE 1 #define MIN_PERCENT 3 #define Ldeg 0.5 #define Udeg 15 #define MIN_ANG_CUT_ALL_TRACKS 1 Table 1: common.h 4.2 The raw data Figure 3 is what the raw data from POCA output looks like, without any cuts applied: After manual cuts were applied, in Figure 4, you can somewhat see the resemblance of the objects, but nothing that would be adequate for distinguishing Uranium from the Lead Shielding. 4.3 POCLUST Parameters settings There are many parameters in POCLUST, but here are the main ones, and their current values, at the time these results were produced: Also, the final merging from "GeantPackage.cpp" was removed, along with other things: 4.4 CLUSTVIZ output After tinkering around with the parameters and removing the final merging, which from the results seemed to be buggy, I was able to achieve the following output: Table 3: GeantPackage.cpp diff ```c 35 @@ -133,7 +133,7 @@ void Input_Geant_Data(char filename[]){ 36 //for testing purpose NOW which basically finds non-sporadic clusters.. 37 Find_objects_from_all_clusters(space.root,&Finclust,num); 38 39 + //:NOTE: Removed the cluster merging and got a lot better result 40 + //Merge the clusters with each other.. 41 + //ClusterMerging(&Finclust); 44 @@ -270,13 +270,18 @@ void Output_to_File(data *ptr){ 45 clusterDetail out; 46 double percent,factor,pr,lambda; 47 FILE *fout=fopen("output.txt","w"); 48 - FILE *matlab=fopen("5trgAir.m","w"); 49 - if (matlab == 0) 50 - {fprintf(stderr, "Could not open file for output"); 51 - exit(1); 52 + FILE *matlab=fopen("cluster_vis_output.m","w"); 53 + if (matlab == 0) 54 + {fprintf(stderr, "Could not open file for output"); 55 + exit(1); 56 + } 57 factor=(10*(M_PI)*(M_PI)*10000)/(18*18); 58 59 - fprintf(matlab,"function I=truck()\n"); 60 - fprintf(matlab,"rppd([400,300,300],[0,0,0],[0,0,0],[1,0,0],0);\n"); 62 + fprintf(matlab,"function I=truck()\n"); 63 + fprintf(matlab,"rppd([400,300,300],[0,0,0],[0,0,0],[1,0,0],0);\n"); 65 + fprintf(matlab,"%d %d %d \n",lenght,width,height); 66 + for(int i=0;i< ptr->len;i++){ 67 + c=ptr->object[i]; 68 @@ -304,9 +309,14 @@ void Output_to_File(data *ptr){ 69 fprintf(fout,"\t\tEstimated density at last: %lf \n",lambda); 71 + //Printing the matlab code. 72 - if(out.dX!=0 && out.dY!=0 && out.dZ!=0 && out.varTheta<15) 73 - fprintf(matlab,"rppd([%lf,%lf,%lf],%lf,%lf,%lf,[%lf,0,0,0],1);\n",(2*out.dX)/10,(2*out.dY)/10,(2*out.dZ)/10,(out.centroid.x)/10,(out.centroid.y)/10, 74 - (out.centroid.z)/10,1-out.varTheta/15); 76 + if(out.dX!=0 && out.dY!=0 && out.dZ!=0) 77 + //fprintf(matlab,"rppd([%lf,%lf,%lf],%lf,%lf,%lf,[%lf,0,0,0],1);\n",(2*out.dX)/10,(2*out.dY)/10, 78 + (out.centroid.x)/10,(out.centroid.y)/10,(out.centroid.z)/10, 79 + (out.avgTheta)/10); 80 + +="/out.varTheta/50); After the FAS was done, the next goal was to create an clean Object Oriented Clustering Framework in C++ such that new students would have a minimal learning curve to be able to make changes to the current clustering algorithms and see the results. Though the framework was built, and other clustering algorithms were tested, POCLUST was only about 90% ported to the new framework. The reason is, it was soon realized that building a generic clustering framework that was not a parallel and distributed framework was simply a waste of time. This is because, in the future as the algorithm becomes more complicated and more data is presented, the current sequential model will not stand. 5.1 The Goals The first a foremost goal was to clean up the code, followed by creating levels of abstraction that would allow new students to easily make small changes to the algorithms and be able to notice the output from them. This would allow for a much smaller learning curve, and hopefully will get more students interested. It was also designed to be a generic framework for making future Clustering Algorithms with minimal code, allowing the framework to do a majority of the internal operations like loading data, creating the space, merging and unmerging, managing the data, managing the clusters, output to a file. 5.2 The structure ![Diagram of GenericCluster structure](image) Figure 6: Structure of GenericCluster from POV of a Cluster 5.3 Abstracting Clustering Algorithms Abstraction takes place by inheriting the following classes and modifying them: Figure 7: Abstraction of POCASimple from the Base Classes As you can see, when a new algorithm called "POCA" was created, it created the new Classes from inheritance, Metric, Space, Cluster, Parameters. By manipulating those classes, you can achieve anything you want, without having to worry about the inside structure. Further information can be found on the documentation online. VI. PARALLEL AND DISTRIBUTED CLUSTERING USING HADOOP Abstract—Apache Hadoop is an open source framework, that is intended to do parallel and distributed computing over large compute nodes or even in cloud environments such as Amazon EC2. Apache Mahout is the framework built on top of Hadoop that is composed of Machine Learning Algorithms for analysing large data sets. Of the tool kits available through Mahout, there exits a wide arrange of Clustering algorithms. Initial results of the "out of the box" clustering algorithms on real POCA data acquired from our cubic foot Muon Tomography station here at Florida Tech is presented, and to establish a baseline. Mahout’s clustering algorithms allows the user to specify a ”Measure” for each ”Job” that runs, hence the ease to modify the Metric used for calculating distance between points and clusters. Since muon Coloumb scattering has an inherent Probability Distribution Function (PDF) that can be modelled many ways. Therefore the incorporation of the PDF into the Measure in order to create a space in which the Clustering Algorithms will run that is based more on the importance of the variables, will create a much better result. This has been seen is POCLUST, where the Euclidean measure was adjusted by the variance of the point with respect to the cluster, if the cluster is sufficiently large. Taking the concept, and laying out the background information and method on how to create a new measure for a Hadoop clustering algorithm based on a user trainable Probability Distribution Function and abstract it to N dimensional space was the point of this paper. I. Introduction The following data set being used in the current analysis of developments on the DistanceMeasure in Hadoop Clustering algorithms, comes from our Muon Tomography Station in the High Energy Physics Lab A. It is a scenario containing 5 blocks of metal. Four of them are arranged on the corners of a square in the same plane, and the 5th is centred in the middle. The middle is depleted Uranium, and the surrounding metals range from Iron to Lead. The purpose of this scenario is to test our abilities to reconstruct the data and be able to distinguish the Lead from the other materials, without any previous knowledge of the placements. Current research on the clustering of the POCA points has been done with POCLUST, which is a serialized on-line implementation of a density based clustering algorithm for POCA points similar. The algorithm has a tough time running as a single thread on a single machine as the dataset increases. If fast enough computation times, along with machine learning methods for parameter optimization is going to be used, we must move to a more power platform. We have access to a 30+ Node Tier 3 Computing Center that is run by the High Energy Physics Lab A, so implementing a parallel and distributed algorithm that can take advantage of every node would be to our advantage, and that was the prime motivation for the investigation into parallel clustering algorithms such a PDBSCAN, and those recently published that are based on Map/Reduce. A. Hadoop Map Reduce Paradigm B. Map/Reduce Cluster Algorithms Map reduce clustering algorithms have come about just recently and have been exploding. With a map/reduce paradigm, you have shared nothing. That means, between processes or nodes, there is nothing shared. Therefore the functions have to be “self containing” and not access any global data. This can cause issues with synchronization. Synchronization plays a big role in the performance of parallel algorithms since if other threads or processes must wait and spin until another releases a resource, you are losing a lot of performance! With the map reduce paradigm, for example take the traditional, and one of the most simple k-means clustering algorithms. Here are the two steps that you would need in a sequential word. The first step is: Assignment Step \[ \{ i \in S : \| x_p - m_i \| \leq \| x_p - m_j \| \forall 1 \leq j \leq k \} \] (Eq. 1) Essentially, the assignment step, each set \( S \), contains points that joined \( S \) because out of all the other possible sets \( S \), this one was the closest. As you can see, it is one dimensional, and uses a traditional euclidean measure. This could be the map stage, where each element coming in, will get mapped to an intermediate output. Update Step \[ m_i^{(t+1)} = \frac{1}{|S_i^{(t)}|} \sum_{x_j \in S_i^{(t)}} x_j \] (Eq. 2) This step, essentially all you are doing is updating the mean value of the cluster with the addition of the new points. The reason that you would want to have this as your reduce step, is because Apache Hadoop, in the intermediate steps between map and reduce, sort your outputs, so that reduce gets all of the same outputs. In this situation, all of the same \( S \), or cluster. Though the k-means clustering may seem easy, actually implementing it is not. Coordinating the communication and synchronization between the parallel processes, and handling situations when clusters have to split among nodes, overlap, etc, it can become difficult. That is where Hadoop and mahout come in. Here is a diagram of a map/reduce k-mean clustering algorithm. C. Mahout’s Clustering Framework Mahout is a algorithmic framework built on top of Hadoop. Essentially, Hadoop takes care of managing nodes, and file systems, and connections between them. It manages who has what jobs and when, where to transfer data and when, and orchestrates an entire parallel computer for you. The “hello world” for map/reduce is counting the frequencies of a word in a set of words such as a document. The mapper maps the portion of the document into 2 dimensional subset, the word, and the number of instances in that mapper, using the word as the “key”. The Intermediate step sorts all the outputs from all the “nodes” or computers, by the word, and separates the data such that all the same words are given to a reducer. The reducer then adds up the number of the same words it was passed, and puts it into a “counter” that each processing node is allowed to have. The counters are all dumped to one file by each Reducer node, in order, and all the counts are therefore summed up for you. So you created a parallel sorting algorithm for a sparse dataset, with about 4 lines of code added to the Hadoop base. The nature of the Map/Reduce paradigm just makes those sort of things really easy and fast, and some simple things really hard. So it is important to pick the most appropriate challenges by the Mahout team. One of which, is classification, or the clustering of \( N \) dimensional unstructured or structured data. For clustering in Mahout, there are these major components: D. The Abstract Vector Classifier Mahout’s clustering classifier on the lowest level is abstracted from AbstractVectorClassifier. This is an abstract class such that provides functions to take \( N \)-Dimensional vectors of data, and return their probabilities to be associated with each of the \( K \) groups, with the probabilities summing to 1. With the classifiers you either have to train them first, in which they build their own Probability Distribution Function. How this is down depends on the specific classifier. E. The OnlineLearner An OnlineLearner is a abstract class that supports two main functions, training and closing. For training, it accepts data, and updates its probability model based on the data it just accepted. It requires both the instance values and the actual values, so it can “learn” and compare to how well it is doing. This way it can learn the best model. Once the model and the parameters of the model have been satisfied by sufficient training, the user “Closes” the OnlineLearner, and can now store the model, and use it for classification. F. The Cluster Classifier This class inherits mainly from the AbstractVectorClassifier, and the OnlineLearner, and contains a ClusteringPolicy. The Cluster Classifier is given and ClusteringPolicy, which was constructed either by hand, or by training on previous data sets with a learner. It then uses this ClusteringPolicy to feed the VectorClassifier, to classify incoming data into the Clusters defined by the Clustering policy. With the adaptation of the OnlineLearner, it can activate and create multiple OnlineLearners, and not only classify data coming in, but can also adjust it’s current clustering policy by closing a trained on-line learner, and feed it to the ClusterPolicy, which then adapts to the OnlineLearner’s changes to the Probability Distribution Function and the model. G. The Abstract Cluster This is where the actual clustering goes on. A key thing about Hadoop, is that all these objects must be writeable and readable, similar to serializable, because they will be transmitted constantly over a transport that can’t just do direct memory access. It stores and sends strings, or compact forms of the objects. So the key parts of the abstract Cluster is first of all, here is the data that is shared globally amount clusters: - Clusters - Path of Points already clustered - Clusters - Path of All living clusters - Final_iteration_suffix - File suffix of finish clusters - Initial_clusters_dir - Path of Initial Clusters Since most clusters are based off a central point, and a volume definition around them, Mahout supports the methods of: - GetCenter - gets the “center” of the cluster - GetRadius - gets the “radius” of the cluster - IsConverged - returns if the converged (optional) H. Model The model is a small class with two purposes, to observe an event and retain it, and to construct a PDF (Probability Distribution Function) from that data it observers. - Double pdf(x) - returns the probability that the observation x based on its model - Observe(event) - retains information of this event, and observes it - ComputeParameters() - computes a new set of posterior parameters based on the observations, recreates the PDF I. Our focus: iterator DistanceMeasureCluster This class is the grand daddy of all the Clustering Algorithms in the Examples. All the Clustering algorithms inherit this class. This class has three major traits: 1) A Model - to observe and generate the PDFs 2) ParameteredGeneralizations - contains the prefix of file, the Hadoop JobConf, cluster Parameters 3) pdf function - pass a vector, get back the probability of that vector based on its model 4) Identifier - method of identifying the cluster 5) Data I/O readFields, write 6) Get/set DistanceMeasure - This is the function we will be modifying J. DistanceMeasure class - Our Focus As of right now, the base abstract DistanceMeasure class has two distance functions: 1. distance(Vector p1, Vector p2) 2. distance(double centroidLenSquare, Vector Centroid, Vector V) The first one is the typical distance measure of Euclidean spaces (or will be abstracted to be one) The second one is for sparse higher dimensional matrices where the distance is proportional to the number of non-zero elements in the vector instead of the cardinality So lets look at an abstracted example, the WeightedEuclideanDistanceMeasure: Program 2 The Gaussian Model and Distance Measure ``` public abstract class ProbDistanceMeasure implements DistanceMeasure { public double pdf(VectorWritable vw) { // will use previous training values // to calculate the probability of vw // based on a gaussian pdf. Left out the // calculation. return Math.exp(...vw.get() ...); } public Model<VectorWritable>[] sampleFromPrior(int howMany) { // pull from training array } public double distance(Vector v1, Vector v2) { Parameters p = getPDFParams(); return (Math.sqrt(super.distance(v1, v2)) *p.variance *Math.pow(2, f1(v1.get(p.Dims)/p.sigma))); } Parameters getPDFParams() { // returns stddev, sigma, mean } } ``` measure to gain wanted results. II. CONCLUSION As was shown throughout this paper, Apache Hadoop and Apache Mahout are two very powerful and flexible platforms. Thanks to the framework of Mahout for abstracting the Map/Reduce paradigm into something much easier to work with, parallel distributed clustering algorithms can take off. As far as the work described in this paper, the code is currently being tested on real data from the High Energy Physics Group's Muon Tomography station. Currently, it is only running on a single psuedonode, but there are hopes to run it on their Tier 3 Computing Cluster in the future, in order to take full advantage of Hadoop. At that point in time, the parameter optimizations will be run, for parameters (f1,f2,f...) scattered throughout the algorithms. Therefore allowing use to make fine adjustments. As was demonstrated above, to create a parallel distributed clustering algorithm with a new distance measure only took a few lines of code. I hope this paper motivates people to begin experimenting with the options and power of these two platforms in respect to clustering in the Muon Tomography Reconstruction field. ACKNOWLEDGMENT Thanks to: Dr. Hohlmann for changing my life in ways that I will never forget, and for finding me useful, even though I am always late and a dollar short, and for getting me on the IEEE publication that got me my career at IBM. Ben Locke for getting me into the HEP Lab A, for my CERN T-shirt, and all the Monte Carlo Data Dr. Mitra for getting me into clustering algorithms and allowing me to hack his algorithm POCLUST. Dr. Dwyer Dr. Locke for getting me into the HEP Lab A, for my CERN T-shirt, and all the Monte Carlo Data VII. The inclusion of Vx4D into ROOT Due to the management complexity of keeping up with the dependencies, and multi-platform builds, it was decided that it would be much easier in the future to rewrite Vx4D in ROOT. This process is currently going on, and so is the inclusion of POCLUST eventually. Right now Vx4D is supported in ROOT, in beta, by using the: ``` #include<TVxND.h> ``` With a common constructor of: TVxND(TFile *) Using ROOT, a user interface will be created soon, allowing the user to manipulate, save, and load, all the previous options that Vx4D supported. All of this is still under development, and progress is being made. Once it is available in a public beta form, it will be available at: TVxND Root Documentation, and Location of Code 7.1 The use of TVxND TVxND will be an N-dimensional OpenGL Voxelized Visualization suite just like before, but now you can map an arbitrary amount of dimensions to the "Theta" variable. I. Appendix A - Source Code Locations A.1 CLUSTVIZ, POCLUST, GenericClust, Vx4D POCLUST and CLUSTVIZ Full Documentation GenericClust Full Documentation Vx4D Full Documentation A.2 ROOT with TVx4D and future additions TVxND Root Documentation, and Location of Code II. Appendix B - Source Code Manuals III. GenericClust - the POCLUST rewrite IV. POCLUST and CLUSTVIZ source documentation
{"Source-Url": "https://research.fit.edu/media/site-specific/researchfitedu/hep/heplaba/documents/research/UG_research_Will_POCLUST_CLUSTVIZ_documentation_Spring2012.pdf", "len_cl100k_base": 7594, "olmocr-version": "0.1.53", "pdf-total-pages": 20, "total-fallback-pages": 0, "total-input-tokens": 40815, "total-output-tokens": 8802, "length": "2e12", "weborganizer": {"__label__adult": 0.00034356117248535156, "__label__art_design": 0.0006127357482910156, "__label__crime_law": 0.0004639625549316406, "__label__education_jobs": 0.0022182464599609375, "__label__entertainment": 0.00016641616821289062, "__label__fashion_beauty": 0.00020492076873779297, "__label__finance_business": 0.0003008842468261719, "__label__food_dining": 0.0004782676696777344, "__label__games": 0.0006756782531738281, "__label__hardware": 0.00213623046875, "__label__health": 0.0007500648498535156, "__label__history": 0.0005097389221191406, "__label__home_hobbies": 0.00019228458404541016, "__label__industrial": 0.0010118484497070312, "__label__literature": 0.0002856254577636719, "__label__politics": 0.0004661083221435547, "__label__religion": 0.0006480216979980469, "__label__science_tech": 0.474853515625, "__label__social_life": 0.0002092123031616211, "__label__software": 0.0125579833984375, "__label__software_dev": 0.49951171875, "__label__sports_fitness": 0.0004487037658691406, "__label__transportation": 0.0006237030029296875, "__label__travel": 0.0002211332321166992}, "weborganizer_max": "__label__software_dev", "avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_ratio": [[0, 31051, 0.06887]], "fineweb_edu_fasttext_gt2__fineweb_edu_fasttext_gt2__score": [[0, 31051, 0.32276]], "ft_lang_id_en_doc_v2__ft_lang_id_en_doc_v2__en": [[0, 31051, 0.89669]], "google_gemma-3-12b-it_contains_pii": [[0, 542, false], [542, 1556, null], [1556, 4779, null], [4779, 5376, null], [5376, 7565, null], [7565, 8382, null], [8382, 9724, null], [9724, 10541, null], [10541, 10668, null], [10668, 11988, null], [11988, 14127, null], [14127, 15117, null], [15117, 15689, null], [15689, 16127, null], [16127, 19997, null], [19997, 24691, null], [24691, 27237, null], [27237, 29703, null], [29703, 30656, null], [30656, 31051, null]], "google_gemma-3-12b-it_is_public_document": [[0, 542, true], [542, 1556, null], [1556, 4779, null], [4779, 5376, null], [5376, 7565, null], [7565, 8382, null], [8382, 9724, null], [9724, 10541, null], [10541, 10668, null], [10668, 11988, null], [11988, 14127, null], [14127, 15117, null], [15117, 15689, null], [15689, 16127, null], [16127, 19997, null], [19997, 24691, null], [24691, 27237, null], [27237, 29703, null], [29703, 30656, null], [30656, 31051, null]], "google_gemma-3-4b-it_v2tag__is_academic_paper": [[0, 5000, true], [5000, 31051, null]], "google_gemma-3-4b-it_v2tag__is_class_syllabus": [[0, 5000, false], [5000, 31051, null]], "google_gemma-3-4b-it_v2tag__is_completion_certificate": [[0, 5000, false], [5000, 31051, null]], "google_gemma-3-4b-it_v2tag__is_court_notice": [[0, 5000, false], [5000, 31051, null]], "google_gemma-3-4b-it_v2tag__is_homework_assignment": [[0, 5000, false], [5000, 31051, null]], "google_gemma-3-4b-it_v2tag__is_news_article": [[0, 5000, false], [5000, 31051, null]], "google_gemma-3-4b-it_v2tag__is_public_order": [[0, 5000, false], [5000, 31051, null]], "google_gemma-3-4b-it_v2tag__is_resume_cv": [[0, 5000, false], [5000, 31051, null]], "google_gemma-3-4b-it_v2tag__is_test_or_quiz": [[0, 5000, false], [5000, 31051, null]], "google_gemma-3-4b-it_v2tag__is_textbook": [[0, 5000, false], [5000, 31051, null]], "pdf_page_numbers": [[0, 542, 1], [542, 1556, 2], [1556, 4779, 3], [4779, 5376, 4], [5376, 7565, 5], [7565, 8382, 6], [8382, 9724, 7], [9724, 10541, 8], [10541, 10668, 9], [10668, 11988, 10], [11988, 14127, 11], [14127, 15117, 12], [15117, 15689, 13], [15689, 16127, 14], [16127, 19997, 15], [19997, 24691, 16], [24691, 27237, 17], [27237, 29703, 18], [29703, 30656, 19], [30656, 31051, 20]], "pipe_delimited_lines_v1__pipe_delimited_lines_v1__pipe_delimited_lines_ratio": [[0, 31051, 0.0]]}
olmocr_science_pdfs
2024-12-09
2024-12-09
1cb6ce0ef17df41f7523bbde4f6f0da2843d2f68
Lecture 8 Further improvements to Matrix Multiply Announcements • Mac Mini lab (APM 2402) - Friday at 4pm to 6pm - Next week: Tues and Fri 4pm to 6pm • Project proposals due on November 9 Projects! - Stencil method in 3 dimensions - Multigrid - Communication avoiding matrix multiplication (MPI) - Algorithm based fault tolerance (MPI) - 3D Fast Fourier Transform (MPI or CUDA) - Particle simulation (MPI) - Groups of 3 will do a more ambitious project - MPI projects can add communication overlap - MPI + CUDA - Propose your own - Make your choice by 11/9 www-cse.ucsd.edu/classes/fa12/cse260-b/Projects/ProjectList.html Today’s lecture • Bank conflicts (previous lecture) • Further improvements to Matrix Multiplication • Thread divergence • Scheduling Fermi platforms in the class CSEClass 01, 02: GeForce GTX 580 [2.0, GF100] 15 Vector units @ 32 cores/unit (480 cores), 4 SFUs 1.25 GB device memory CSEClass 03-07: GeForce GTX 460 [2.1, GF104] 7 Vector units @ 48 cores (384 total cores), 8 SFUs 1.0 GB device memory Dirac: Tesla C2050 [2.0, GF100] 1 device per node 14 Vector units @ 32 cores (448 total cores), 4 SFUs 3 GB device memory + ECC (2.625GB usable) SP MAD: 1030.4 Gflops, DP FMA: 515.2 www.anandtech.com/show/3809/nvidias-geforce-gtx-460-the-200-king/2 Warp Scheduling (Fermi) - Threads assigned to an SM in units of a thread block, multiple blocks - Each block is divided into *warps* of 32 (SIMD) threads, a schedulable unit - A warp becomes eligible for execution when all its operands are available - Dynamic instruction reordering: eligible warps selected for execution using a prioritized scheduling policy - All threads in a Warp execute the same instruction, branches serialize execution - Multiple warps simultaneously active, hiding data transfer delays - All registers in all the warps are available, 0 overhead scheduling - Hardware is free to assign blocks to any SM - How does scheduling work? Memory interleaving - Compensates for slow memory access times - Assume we are accessing memory consecutively - What happens if the stride = number of banks? Shared memory banks - A load or store of $n$ addresses spanning $n$ distinct memory banks can be serviced simultaneously, effective bandwidth is $\times n$ single bank bandwidth - Multiple addresses map to same memory bank - Accesses are serialized - Hardware splits request into as many separate conflict-free requests as necessary Exception: if all access the same address: broadcast - Devices of compute capability 2.x have the additional ability to multicast shared memory accesses - See *CUDA C Best Practices Guide* Shared memory bank access - Load/store of \( n \) addresses spanning \( n \) distinct memory banks can be serviced simultaneously, effective BW = \( \times n \) a single bank - Each bank can service 1 address / cycle (broadcast, too) - Access to shared memory is fast unless… - 2 or more instructions in a 1/2 warp access different banks: we have a conflict - Exception: if all access the same bank: broadcast \[ \text{int idx} = \text{blockIdx.x} \times \text{blockDim.x} + \text{threadIdx.x}; \\ \text{a[idx]} = \text{a[idx]} + 1.0f; \] Identifying bank conflicts - Traditional wisdom for exploiting cache locality can result in bank conflicts. - What if a thread loads 2 consecutive array elements? ``` int tid = threadIdx.x; shared[2*tid] = global[2*tid]; shared[2*tid+1] = global[2*tid+1]; ``` - To avoid conflicts ``` shared[tid] = global[tid]; shared[tid + blockDim.x] = global[tid + blockDim.x]; ``` - Consider ``` __shared__ float shared[256]; float foo = shared[base + s * threadIdx.x]; ``` - If \( s \) has no common factors with the number of banks (16), then there are no conflicts (\( s \) is odd). Shared memory design - Successive 32-bit words assigned to successive banks - For devices of compute capability 2.x [Fermi] - Number of banks = 32 - Bandwidth is 32 bits per bank per 2 clock cycles - Shared memory request for a warp is not split - Increased susceptibility to conflicts - But no conflicts if access to bytes in same 32 bit word - For devices of compute capability 1.x [Lilliput] - Number of banks = 16 - Bandwidth is 32 bits per bank per clock cycle - Shared memory request for a warp is split in two - No conflict occurs if only one memory location per bank is accessed by a half warp of threads Coalesced access and no bank conflicts \[ I = blockIdx.y \times by + ty; \] \[ J = blockIdx.x \times bx + tx; \] \[ \text{__shared__ float } a[\text{BLK}][\text{BLK}], \quad b[\text{BLK}][\text{BLK}]; \] \[ \text{if } ((I < N) \land \land (J < N))\{ \text{ float c = 0.0f; for (k=0; k < gy; k++)\{ a[ty][tx] = A[I \times N + k \times by + tx]; b[ty][tx] = B[J + N \times (k \times bx + ty)]; \text{__syncthreads(); for (kk=0; kk < bx; kk++) c += a[ty][kk] \times b[kk][tx]; __syncthreads(); \}}} \] \[ C[I \times N + J] = c; \] Today’s lecture • Bank conflicts (previous lecture) • Further improvements to Matrix Multiplication • Thread divergence • Scheduling How to improve matrix multiply • Volkov and Demmel, SC08 • Hide arithmetic latency using fewer threads • Hide memory latency using fewer threads • Improving performance using fewer threads • We can reduce number of threads through lower occupancy • By making better use of registers we can trade locality against parallelism Latency • Instructions wait on dependencies \( x = a + b; \) // ~20 for floating point, 500+ for memory \( y = a + c; \) // independent (stall) \( z = x + d; \) // dependent, wait • How many warps are needed to hide latency if minimum latency is 4 cycles / instruction? \[ \# \text{Parallelism (threads)} = \text{latency} \times \text{throughput} \] \[ T = \lambda \times p \] 480 mul-adds/cycle; 32 memory ops /cycle [1.3 device] • Required parallelism depends on op; for single precision ♦ GT200 (C1060, Lilliput): 24 CP * 8 cores / SM = 192 ops/cycle ♦ GF100 (GTX-580, Cseclass01/02): 18 CP * 32 = 576 ♦ GF104 (GTX 460, Cseclass03-07): 18 CP * 48 = 864 Thread vs instruction level parallelism - We are told to maximize the number of threads - But we can also use instruction level parallelism to boost performance at a lower occupancy - See http://www.cs.berkeley.edu/~volkov/volkov10-GTC.pdf - On GT200, 100% peak with 25% occupancy 192 ops / cycle = 8 warps / 32 max possible warps - On the GF104, we need ILP to go beyond 66% of peak - 48 cores/SM, half warp (16 cores) issues at a time - But we have only 2 schedulers - We must issue 2 independent instructions per warp in the same cycle 576 threads needed for 100% utilization pragma unroll UNROLL for( i = 0; i < N_Iter; i++ ){ a = a * b + c; } 320 threads needed for 100% utilization pragma unroll UNROLL for( i = 0; i < N_Iter; i++ ){ a = a * b+c; d = d * b + c; } 10/24/12 ©2012 Scott B. Baden /CSE 260/ Fall 2012 Hiding memory latency - **Parallelism = latency \times throughput** Arithmetic: \(576\ \text{ops/SM} = 18\times 32/\text{SM/CP}\) Memory: \(150\text{KB} = \sim 500\text{CP} \ (1100\ \text{nsec}) \times 150\ \text{GB/sec}\) - **How can we keep 150KB in flight?** - Multiple threads: \(~35,000\ \text{threads} @ 4\text{B/thread}\) - ILP (increase fetches per thread) - Larger fetches (64 or 128 bit/thread) - Higher occupancy Copy 1 float /thread, need 100% occupancy \[ \text{int}\ \text{indx} = \text{threadIdx.x} + \text{block} \times \text{blockDim.x}; \\ \text{float a0} = \text{src}[\text{indx}]; \\ \text{dest}[\text{indx}] = \text{a0}; \] Copy 2 floats /thread, need 50% occ \[ \text{float a0} = \text{src}[\text{indx}]; \\ \text{float a1} = \text{src}[\text{indx} + \text{blockDim.x}]; \\ \text{dest}[\text{indx}] = \text{a0}; \\ \text{dst}[\text{indx} + \text{blockDim.x}] = \text{a1}; \] Copy 4 floats /thread, need 25% occ \[ \text{int}\ \text{indx} = \text{threadIdx.x} + 4 \times \text{block} \times \text{blockDim.x}; \\ \text{float a[4]; // in registers} \\ \text{for}(i=0;i<4;i++) \text{a[i]=src[indx+i*blockDim.x];} \\ \text{for}(i=0;i<4;i++) \text{dst[indx+i*blockDim.x]=a[i];} \] Incremental improvements to matrix multiply • Baseline code found in the SDK (3.1, GTX 480) • Follows V. Volkov [GTC10] • Gets 137 Gflops / sec ```c float Csub = 0; for (int a = aBegin, b = bBegin; a <= aEnd; a += aStep, b += bStep) { __shared__ float As[BLOCK_SIZE][BLOCK_SIZE]; __shared__ float Bs[BLOCK_SIZE][BLOCK_SIZE]; AS(ty, tx) = A[a + wA * ty + tx]; BS(ty, tx) = B[b + wB * ty + tx]; __syncthreads(); #pragma unroll for (int k = 0; k < BLOCK_SIZE; ++k) Csub += AS(ty, k) * BS(k, tx); __syncthreads(); } int c = wB * BLOCK_SIZE * by + BLOCK_SIZE * bx; C[c + wB * ty + tx] = Csub; ``` Two outputs / thread • 2 outputs, double the loads ```cpp float Csub[2] = {0,0}; // array is allocated in registers for (int a = aBegin, b = bBegin; a <= aEnd; a += aStep, b += bStep) { __shared__ float As[BLOCK_SIZE][BLOCK_SIZE]; __shared__ float Bs[BLOCK_SIZE][BLOCK_SIZE]; AS(ty, tx) = A[a + wA * ty + tx]; BS(ty, tx) = B[b + wB * ty + tx]; AS(ty+16, tx) = A[a + wA * (ty+16) + tx]; BS(ty+16, tx) = B[b + wB * (ty+16) + tx]; __syncthreads(); ``` Two outputs / thread, part 2 - x2 flops and stores - 341 Gflops/sec ``` #pragma unroll for (int k = 0; k < BLOCK_SIZE; ++k) { Csub[0] += AS(ty, k) * BS(k, tx); Csub[1] += AS(ty+16, k) * BS(k, tx); } __syncthreads(); int c = wB * BLOCK_SIZE * by + BLOCK_SIZE * bx; C[c + wB * ty + tx] = Csub[0]; C[c + wB * (ty+16) + tx] = Csub[1]; ``` 4 outputs / thread ```c float Csub[4] = {0,0,0,0}; //array is in registers for (int a = aBegin, b = bBegin; a <= aEnd; a += aStep, b += bStep) { __shared__ float As[BLOCK_SIZE][BLOCK_SIZE]; __shared__ float Bs[BLOCK_SIZE][BLOCK_SIZE]; AS(ty, tx) = A[a + wA * ty + tx]; BS(ty, tx) = B[b + wB * ty + tx]; AS(ty+8, tx) = A[a + wA * (ty+8) + tx]; BS(ty+8, tx) = B[b + wB * (ty+8) + tx]; AS(ty+16, tx) = A[a + wA * (ty+16) + tx]; BS(ty+16, tx) = B[b + wB * (ty+16) + tx]; AS(ty+24, tx) = A[a + wA * (ty+24) + tx]; BS(ty+24, tx) = B[b + wB * (ty+24) + tx]; __syncthreads(); ``` 4 outputs / thread - 427 Gflops/sec [w/8 output/thread → 485 Gflops/s) - ×2 # registers - 50% occupancy ```c #pragma unroll for (int k = 0; k < BLOCK_SIZE; ++k) { Csub[0] += AS(ty, k) * BS(k, tx); Csub[1] += AS(ty+8, k) * BS(k, tx); Csub[2] += AS(ty+16, k) * BS(k, tx); Csub[3] += AS(ty+24, k) * BS(k, tx); } __syncthreads(); ``` ```c int c = wB * BLOCK_SIZE * by + BLOCK_SIZE * bx; C[c + wB * ty + tx] = Csub[0]; C[c + wB * (ty+8) + tx] = Csub[1]; C[c + wB * (ty+16) + tx] = Csub[2]; C[c + wB * (ty+24) + tx] = Csub[3]; ``` Vector length: 64 //stripmined into two warps by GPU Registers: \( \mathbf{a}, \mathbf{c}[1:16] \) //each is 64-element vector Shared memory: \( \mathbf{b}[16][16] \) //may include padding Compute pointers in \( \mathbf{A}, \mathbf{B} \) and \( \mathbf{C} \) using thread ID \( \mathbf{c}[1:16] = 0 \) do \( \mathbf{b}[1:16][1:16] = \) next \( 16 \times 16 \) block in \( \mathbf{B} \) or \( \mathbf{B}^T \) local barrier //wait until \( \mathbf{b}[][] \) is written by all warps unroll for \( i = 1 \) to \( 16 \) do \( \mathbf{a} = \) next \( 64 \times 1 \) column of \( \mathbf{A} \) \( \mathbf{c}[1] += \mathbf{a} \times \mathbf{b}[i][1] \) // rank-1 update of \( \mathbf{C} \)'s block \( \mathbf{c}[2] += \mathbf{a} \times \mathbf{b}[i][2] \) // data parallelism = 1024 \( \mathbf{c}[3] += \mathbf{a} \times \mathbf{b}[i][3] \) // stripmined in software ... // into 16 operations \( \mathbf{c}[16] += \mathbf{a} \times \mathbf{b}[i][16] \) // access to \( \mathbf{b}[][] \) is stride-1 endfor local barrier //wait until done using \( \mathbf{b}[][] \) update pointers in \( \mathbf{A} \) and \( \mathbf{B} \) repeat until pointer in \( \mathbf{B} \) is out of range Merge \( \mathbf{c}[1:16] \) with \( 64 \times 16 \) block of \( \mathbf{C} \) in memory Figure 4: The structure of our matrix-matrix multiply routines. SGEMM Code ```c __global__ void sgemmNN( const float *A, int lda, const float *B, int ldb, float* C, int ldc, int k, float alpha, float beta ) { A += blockIdx.x * 64 + threadIdx.x + threadIdx.y *16; B += threadIdx.x + ( blockIdx.y * 16 + threadIdx.y ) * ldb; C += blockIdx.x * 64 + threadIdx.x + (threadIdx.y + blockIdx.y * ldc ) * 16; __shared__ float bs[16][17]; float c[16] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}; const float *Blast = B + k; do { #pragma unroll for( int i = 0; i < 16; i += 4 ) bs[threadIdx.x][threadIdx.y+i] = B[i*ldb]; B += 16; __syncthreads(); #pragma unroll for( int i = 0; i < 16; i++, A += lda ) { c[0] += A[0]*bs[i][0]; c[1] += A[0]*bs[i][1]; c[2] += A[0]*bs[i][2]; c[3] += A[0]*bs[i][3]; c[4] += A[0]*bs[i][4]; c[5] += A[0]*bs[i][5]; c[6] += A[0]*bs[i][6]; c[7] += A[0]*bs[i][7]; c[8] += A[0]*bs[i][8]; c[9] += A[0]*bs[i][9]; c[10] += A[0]*bs[i][10]; c[12] += A[0]*bs[i][12]; c[13] += A[0]*bs[i][13]; c[14] += A[0]*bs[i][14]; c[15] += A[0]*bs[i][15]; } __syncthreads(); } while( B < Blast ); for( int i = 0; i < 16; i++, C += ldc ) C[0] = alpha*c[i] + beta*C[0]; } ``` - Compute pointers to the data - Declare the on-chip storage - Read next B’s block - The bottleneck: Read A’s columns - Do Rank-1 updates - Store C’s block to memory Data motion cost - Communication performance is a major factor in determining the overall performance of an application - The $\alpha - \beta$ model: $\alpha + \beta^{-1} \infty \ n$ $n = \text{message length}$ $\alpha = \text{message startup time}$ $\beta \infty = \text{peak bandwidth (bytes / second)}$ <table> <thead> <tr> <th>Machine</th> <th>$\beta \infty \ (\text{Dev})$</th> <th>H-D</th> <th>D-H</th> </tr> </thead> <tbody> <tr> <td>Forge</td> <td>103 GB/s</td> <td>2.3</td> <td>1.3</td> </tr> <tr> <td>Lilliput</td> <td>73.6</td> <td>3.3</td> <td>2.8</td> </tr> <tr> <td>CseClass01</td> <td>122</td> <td>3.4</td> <td>2.7</td> </tr> <tr> <td>CseClass04</td> <td>56.1</td> <td>5.2</td> <td>4.1</td> </tr> </tbody> </table> As reported by bandwidthTest Consequences of data motion cost • Consider saxpy $z[i] = a*x[i]+y[i]$ • This is a bandwidth bound kernel • Running time under the $\alpha-\beta$ model: $\alpha + \beta^{-1}_\infty \ n$ \[ \alpha = 4 \ \mu s \] \[ \beta_\infty = 127 \ \text{GB/sec} \] • Flop rate bounded by $(2n \ \text{flops}/12n \ \text{bytes})* \ \beta_\infty$ • 27 Gflops/sec • $N_{1/2}$ Half bandwidth point: $N \approx 42,000$ • Matrix multiplication takes 4 $\mu s$ • But the largest matrix that fits into memory is 1GB $\sim (16K)^2$ • Consequence: saxpy takes constant time to run Half power point - We define the **half power point** \( n_{1/2} \) as the transfer size required to achieve \( \frac{1}{2} \beta_\infty \) \[ \frac{1}{2} \beta^{-1}_\infty = n_{1/2} / T(n_{1/2}) \implies \beta^{-1}(n_{1/2}) = \frac{1}{2} \beta^{-1}_\infty \] - In theory, this occurs when \( \alpha = \beta^{-1}_\infty n_{1/2} \Rightarrow n_{1/2} = \alpha \beta_\infty \) - Formula may not be accurate ![Graph showing N_{1/2} \approx 100KB](SDSC Blue Horizon)
{"Source-Url": "http://cseweb.ucsd.edu/classes/fa12/cse260-b/Lectures/Lec08.pdf", "len_cl100k_base": 5403, "olmocr-version": "0.1.50", "pdf-total-pages": 27, "total-fallback-pages": 0, "total-input-tokens": 43991, "total-output-tokens": 6865, "length": "2e12", "weborganizer": {"__label__adult": 0.000492095947265625, "__label__art_design": 0.0005736351013183594, "__label__crime_law": 0.00046706199645996094, "__label__education_jobs": 0.0029964447021484375, "__label__entertainment": 0.00012129545211791992, "__label__fashion_beauty": 0.0002720355987548828, "__label__finance_business": 0.0002574920654296875, "__label__food_dining": 0.0005183219909667969, "__label__games": 0.001209259033203125, "__label__hardware": 0.0145263671875, "__label__health": 0.000774383544921875, "__label__history": 0.0004601478576660156, "__label__home_hobbies": 0.0003342628479003906, "__label__industrial": 0.001873016357421875, "__label__literature": 0.00020802021026611328, "__label__politics": 0.0003707408905029297, "__label__religion": 0.00086212158203125, "__label__science_tech": 0.193603515625, "__label__social_life": 0.00016438961029052734, "__label__software": 0.0093231201171875, "__label__software_dev": 0.7685546875, "__label__sports_fitness": 0.0006165504455566406, "__label__transportation": 0.0012502670288085938, "__label__travel": 0.00026488304138183594}, "weborganizer_max": "__label__software_dev", "avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_ratio": [[0, 15554, 0.03856]], "fineweb_edu_fasttext_gt2__fineweb_edu_fasttext_gt2__score": [[0, 15554, 0.62935]], "ft_lang_id_en_doc_v2__ft_lang_id_en_doc_v2__en": [[0, 15554, 0.6539]], "google_gemma-3-12b-it_contains_pii": [[0, 51, false], [51, 195, null], [195, 635, null], [635, 769, null], [769, 1303, null], [1303, 1965, null], [1965, 2124, null], [2124, 2655, null], [2655, 3200, null], [3200, 3801, null], [3801, 4434, null], [4434, 4964, null], [4964, 5098, null], [5098, 5428, null], [5428, 6108, null], [6108, 6960, null], [6960, 8178, null], [8178, 8815, null], [8815, 9299, null], [9299, 9681, null], [9681, 10303, null], [10303, 10847, null], [10847, 12173, null], [12173, 13786, null], [13786, 14517, null], [14517, 15089, null], [15089, 15554, null]], "google_gemma-3-12b-it_is_public_document": [[0, 51, true], [51, 195, null], [195, 635, null], [635, 769, null], [769, 1303, null], [1303, 1965, null], [1965, 2124, null], [2124, 2655, null], [2655, 3200, null], [3200, 3801, null], [3801, 4434, null], [4434, 4964, null], [4964, 5098, null], [5098, 5428, null], [5428, 6108, null], [6108, 6960, null], [6960, 8178, null], [8178, 8815, null], [8815, 9299, null], [9299, 9681, null], [9681, 10303, null], [10303, 10847, null], [10847, 12173, null], [12173, 13786, null], [13786, 14517, null], [14517, 15089, null], [15089, 15554, null]], "google_gemma-3-4b-it_v2tag__is_academic_paper": [[0, 5000, true], [5000, 15554, null]], "google_gemma-3-4b-it_v2tag__is_class_syllabus": [[0, 5000, true], [5000, 15554, null]], "google_gemma-3-4b-it_v2tag__is_completion_certificate": [[0, 5000, false], [5000, 15554, null]], "google_gemma-3-4b-it_v2tag__is_court_notice": [[0, 5000, false], [5000, 15554, null]], "google_gemma-3-4b-it_v2tag__is_homework_assignment": [[0, 5000, true], [5000, 15554, null]], "google_gemma-3-4b-it_v2tag__is_news_article": [[0, 5000, false], [5000, 15554, null]], "google_gemma-3-4b-it_v2tag__is_public_order": [[0, 5000, false], [5000, 15554, null]], "google_gemma-3-4b-it_v2tag__is_resume_cv": [[0, 5000, false], [5000, 15554, null]], "google_gemma-3-4b-it_v2tag__is_test_or_quiz": [[0, 5000, false], [5000, 15554, null]], "google_gemma-3-4b-it_v2tag__is_textbook": [[0, 5000, false], [5000, 15554, null]], "pdf_page_numbers": [[0, 51, 1], [51, 195, 2], [195, 635, 3], [635, 769, 4], [769, 1303, 5], [1303, 1965, 6], [1965, 2124, 7], [2124, 2655, 8], [2655, 3200, 9], [3200, 3801, 10], [3801, 4434, 11], [4434, 4964, 12], [4964, 5098, 13], [5098, 5428, 14], [5428, 6108, 15], [6108, 6960, 16], [6960, 8178, 17], [8178, 8815, 18], [8815, 9299, 19], [9299, 9681, 20], [9681, 10303, 21], [10303, 10847, 22], [10847, 12173, 23], [12173, 13786, 24], [13786, 14517, 25], [14517, 15089, 26], [15089, 15554, 27]], "pipe_delimited_lines_v1__pipe_delimited_lines_v1__pipe_delimited_lines_ratio": [[0, 15554, 0.01567]]}
olmocr_science_pdfs
2024-11-29
2024-11-29
5aaa168be7293aac2383beb12072348efbce6d71
Growing Decision Trees Genetically and in Parallel Robert Keller Brian Bentow Joseph Malone Harvey Mudd College keller@cs.hmc.edu Outline - What is a decision tree? - Why are decision trees of interest? - Project history - Pre-existing software - How is genetic programming used? - Why/How to use parallel computing? - Our software - Related work - Future directions General Application Area "Data Mining" Extraction of meaningful models from collections of data Data Mining - Given data collected from an unknown process (physical, biological, economic, ...) - Devise a model that explains the data - So that accurate predictions can be made - (predict output from input data) Modeling/Prediction ??? unknown process or parameters observations input variables output variables Modeling/Prediction ??? model, known parameters predictions Modeling/Prediction - Observation - Predictions Model Validation - How closely do predictions made by the model agree with actual output? Types of Models - Statistical - Regression equations - Factor analysis - Neural network - Multi-level perceptron - Counter propagation network - Support Vector Machine - Decision tree What is a decision tree? - A tree of questions to be asked about the input data, resulting in a prediction about the output data. - There are numerous varieties of questions: - Equality: \( x_i = c \)? - Single variable inequality: \( x_i \geq c \)? - Multi-variable inequality: \( a_i x_i + a_j x_j \geq c \)? - Boolean combinations: \( x_i \geq c, \lor x_j \geq c \)? - etc. Data types - Continuous data: - Finite or infinite set of values - Numeric inequality comparison meaningful - Categorical data: - Finite set of values - Numeric inequality comparison not meaningful Example of a Decision Tree - Given a set of measurements on a banknote, determine whether the banknote is a forgery. - Input measurements (continuous): - Diagonal - Height on the right - Height on the left - Inner frame to upper border - Inner frame to lower border - Output category (categorical): - (forgery, genuine) Example of a Decision Tree - Given a set of measurements on a banknote, determine whether the banknote is a forgery. - A Decision tree: \[ \text{diagonal} > 140.3 \\ \quad \mid \text{inner_frame_to_lower_border} > 9.6 \\ \quad \quad \mid \text{height_on_right} > 130.8 \text{ forgery} \\ \quad \quad \mid \text{height_on_right} \leq 130.8 \text{ genuine} \\ \quad \mid \text{inner_frame_to_lower_border} \leq 9.6 \text{ genuine} \\ \text{diagonal} \leq 140.3 \text{ forgery} \] Problem: Given data observations, determine a good decision tree - Observations from actual banknotes (partial) <table> <thead> <tr> <th>diagonal, height_on_left, height_on_right, ...</th> <th>category</th> </tr> </thead> <tbody> <tr> <td>214.8000,129.5000,129.7000,9.9000,11.0000</td> <td>genuine</td> </tr> <tr> <td>215.0000,130.4000,130.3000,7.9000,11.7000</td> <td>genuine</td> </tr> <tr> <td>215.2000,130.8000,129.6000,7.9000,10.8000</td> <td>genuine</td> </tr> <tr> <td>215.1000,129.9000,129.7000,7.7000,10.8000</td> <td>genuine</td> </tr> <tr> <td>215.1000,130.3000,130.0000,10.6000,10.8000</td> <td>forgery</td> </tr> <tr> <td>214.7000,130.6000,130.1000,11.8000,10.5000</td> <td>forgery</td> </tr> <tr> <td>214.8000,130.5000,130.2000,11.0000,11.0000</td> <td>forgery</td> </tr> <tr> <td>214.8000,130.3000,130.4000,10.1000,12.1000</td> <td>forgery</td> </tr> <tr> <td>215.3000,130.8000,131.1000,11.6000,10.6000</td> <td>forgery</td> </tr> <tr> <td>214.7000,130.5000,130.5000,9.9000,10.3000</td> <td>forgery</td> </tr> <tr> <td>215.0000,130.4000,130.4000,9.4000,11.6000</td> <td>forgery</td> </tr> </tbody> </table> Our Problem - Classification tree: - Determine one of a set of discrete categories for the output variable - Regression tree: - Determine a predicted mean value for the output variable Two Varieties of Tree Value of Trees - Trees vs. Regression formulae: - Tree provides discrete explanation, whereas regression formula is a monolithic function - Trees vs. Neural nets: - Neural nets don’t necessarily display their "rationale" well Some Difficulties - Real-world data may be noisy and have missing observations. - Data may have conflicting outputs for the same input. - There is no unique answer: - Tree classification accuracy can be increased, at the expense of increasing tree complexity. - Validation requires additional data not already used as input Tree Pruning - “Pruning” a tree is a process of cutting out selected sub-trees: - The size gets smaller, but - the error usually increases. - The trick is to prune the sub-trees that have the least impact. Algorithmic Approaches - Based on choosing questions that give the best discrimination with the least error, e.g. - **Greedy algorithm**: At a node in the tree, construct a question that divides the data into two sets, such that the category error is minimum. Repeat for child nodes. - The problem of constructing minimal decision tree has been shown NP-complete. Project history - As consultant on the 1999-2000 project, I suggested applying Genetic Programming concepts. - Summer 2002 Pre-existing software - **c4.5** (formerly c3.0) Ross Quinlan, Machine learning background Now a commercial product c5. - **CART** (Classification-and-Regression-Trees) Leo Breiman, et al., Statistics background Also a commercial product - **R-PART** (Recursive Partitioning) library in S-plus Public domain implementation of CART methods - Terry Therneau and Beth Atkinson, Mayo Clinic - Numerous others What is Genetic Programming? - GP is a form of genetic algorithm in which the genomes are programs, rather than, say, bit strings. - **Genetic operators** such as mutation and crossover are defined on programs. - **Fitness** of a program is how well it carries out a specific function. Trees as Genomes - Every program in a given language has a syntax tree. - The genetic operators are expressed based on syntax trees. How is genetic programming used? - A decision tree is a primitive form of program. - GP seemed like a natural selection of an algorithm for producing decision trees. Project Objectives - We set out to design a program that would evolve decision trees based on input data. - We chose to use the c4.5 data format. - We used c4.5 as a performance benchmark. - We wanted to be able to use parallel processors to speed up the computation. First Milestone: gentree - We produced a program that evolves both classification and regression trees (c4.5 only does classification). - In some cases, our program produced better quality results than c4.5, in other cases, lower quality. We are still exploring ways to improve the results. - Our program invariably runs longer than c4.5, especially on large data sets. - Our program can display lots of options (accuracy vs. size tradeoffs). Mutation Operator Crossover Operator Gentree output, example mbl-factor, run ID 102 Run parameters were: - 1000 Chromosomes - Training dataset size: 313 - Fitness function was: % correct - 0.001 * treeSize - 0.005 * nVars - Target error was: 0, Target size was: 0 - The top 1% were replicated each generation Evolution progress (only changes of most-fit individuals are shown): <table> <thead> <tr> <th>gen</th> <th>size</th> <th>error</th> <th>nCorrect</th> <th>fitness</th> <th>mean</th> <th>stddev</th> </tr> </thead> <tbody> <tr> <td>0</td> <td>21</td> <td>10.15</td> <td>298/310</td> <td>0.84</td> <td>0.76</td> <td>0.12</td> </tr> <tr> <td>1</td> <td>15</td> <td>13.55</td> <td>298/310</td> <td>0.85</td> <td>0.79</td> <td>0.11</td> </tr> <tr> <td>2</td> <td>11</td> <td>13.25</td> <td>298/310</td> <td>0.85</td> <td>0.79</td> <td>0.11</td> </tr> <tr> <td>3</td> <td>29</td> <td>11.50</td> <td>275/310</td> <td>0.84</td> <td>0.79</td> <td>0.11</td> </tr> <tr> <td>4</td> <td>23</td> <td>11.01</td> <td>276/310</td> <td>0.85</td> <td>0.79</td> <td>0.11</td> </tr> <tr> <td>5</td> <td>23</td> <td>11.00</td> <td>282/310</td> <td>0.85</td> <td>0.79</td> <td>0.11</td> </tr> <tr> <td>7</td> <td>17</td> <td>9.00</td> <td>281/310</td> <td>0.85</td> <td>0.79</td> <td>0.11</td> </tr> <tr> <td>9</td> <td>11</td> <td>10.00</td> <td>279/310</td> <td>0.85</td> <td>0.79</td> <td>0.11</td> </tr> <tr> <td>10</td> <td>19</td> <td>9.03</td> <td>280/310</td> <td>0.85</td> <td>0.79</td> <td>0.11</td> </tr> <tr> <td>11</td> <td>19</td> <td>9.03</td> <td>280/310</td> <td>0.85</td> <td>0.79</td> <td>0.11</td> </tr> <tr> <td>12</td> <td>25</td> <td>8.39</td> <td>284/310</td> <td>0.85</td> <td>0.79</td> <td>0.11</td> </tr> <tr> <td>14</td> <td>25</td> <td>8.39</td> <td>284/310</td> <td>0.85</td> <td>0.79</td> <td>0.11</td> </tr> <tr> <td>15</td> <td>43</td> <td>7.76</td> <td>286/310</td> <td>0.85</td> <td>0.79</td> <td>0.11</td> </tr> <tr> <td>17</td> <td>25</td> <td>7.74</td> <td>286/310</td> <td>0.85</td> <td>0.79</td> <td>0.11</td> </tr> <tr> <td>19</td> <td>59</td> <td>7.42</td> <td>297/310</td> <td>0.85</td> <td>0.79</td> <td>0.11</td> </tr> <tr> <td>18</td> <td>48</td> <td>7.42</td> <td>297/310</td> <td>0.85</td> <td>0.79</td> <td>0.11</td> </tr> <tr> <td>21</td> <td>25</td> <td>7.76</td> <td>294/310</td> <td>0.85</td> <td>0.79</td> <td>0.11</td> </tr> <tr> <td>24</td> <td>19</td> <td>7.76</td> <td>294/310</td> <td>0.85</td> <td>0.79</td> <td>0.11</td> </tr> <tr> <td>28</td> <td>17</td> <td>7.76</td> <td>294/310</td> <td>0.85</td> <td>0.79</td> <td>0.11</td> </tr> </tbody> </table> Dataset is: /research/keller/gentree/data/factor/factor.data ### Examples <table> <thead> <tr> <th>Example</th> <th>method</th> <th>size</th> <th>training error (%)</th> <th>test error (%)</th> </tr> </thead> <tbody> <tr> <td>iris unpruned C4.5</td> <td>5</td> <td>2.6</td> <td>5.4</td> <td></td> </tr> <tr> <td>iris pruned C4.5</td> <td>5</td> <td>2.6</td> <td>5.4</td> <td></td> </tr> <tr> <td>mbl-factor unpruned C4.5</td> <td>509</td> <td>1.6</td> <td>5.4</td> <td></td> </tr> <tr> <td>mbl-factor gentree</td> <td>25</td> <td>1.6</td> <td>5.4</td> <td></td> </tr> </tbody> </table> ### Comparison Trees: iris <table> <thead> <tr> <th>gentree</th> <th>size</th> <th>generation</th> <th>error</th> <th>correct</th> <th>fitness</th> </tr> </thead> <tbody> <tr> <td>before pruning</td> <td>5</td> <td>15.4%</td> <td>74/76</td> <td>0.9712</td> <td></td> </tr> <tr> <td>after pruning</td> <td>5</td> <td>2.632%</td> <td>74/76</td> <td>0.957</td> <td></td> </tr> </tbody> </table> ### Joe Malone’s Optimization - Rather than completely build a tree, then evaluate its fitness, only build it down to the nodes before the leaves. - Then assign categories to the leaves that minimize the overall error. Examples run by gentree - agaricus-lepiota - anneal - balance-scale - banknotes - breast-cancer - breast-cancer-wisconsin - bupa - car - cleand - crx - dna - factor - german - glass - golf - hayes-roth - hepatitis - imports-85 - income-food - ionosphere - lymphography - monk1 - monk2 - monk3 - parity3 - parity4 - pima-indians-diabetes - post-operative - primary-tumor - segal - servo - soybean - tic-tac-toe - vote - wine - yeast - zoo Some Challenges - Fitness is based on a combination of size and accuracy. What is the best way to weight the two? - If just one tree has to be recommended, which one? - What is the best way to validate the results? Cross-Validation We implemented n-way cross validation (user selects n): - Data set is divided into n disjoint sets. - n training runs are done, with (n-1)/n of the data used as training and 1/n as test. - The average error vs. size is plotted. - We expect that the “knee” in the curve indicates the most robust error value. - Given the target error value, a tree of corresponding size can be generated. n-Way Cross-Validation Cross-validation notes - Traditionally, cross-validation has been used to prune down the tree size, but we aren’t pruning in the traditional sense. - I am not clear on whether this is the right way to go, but it seems plausible. - Advice is welcome. - The knee-selection idea has not been automated. Another Challenge: Missing Data Values - There are several known methods for dealing with missing data values, none universally accepted. - c4.5 uses a “fractional re-distribution” method - We implemented the “surrogate variable” method, which prescribes a value for the missing variable based on proximity to other data points. Another Challenge: Maintaining Population Diversity - A common difficulty with genetic approaches is that, because of natural selection, the population of solutions loses diversity over time. - This means that fewer nuances are introduced, and the trend may move toward a local fitness minimum. - We have been working on ways to prevent loss of diversity, without sacrificing quality of the most fit solutions. - One approach involves defining an equivalence relation among the individuals and only keeping one member of each equivalence class. Choice of Equivalence Relation - Numerous equivalence relations are possible. - Identity is too fine, and same-error-value may be too coarse. - We are working on using “confusion matrices” for equivalence. <table> <thead> <tr> <th>(a)</th> <th>(b)</th> <th>&lt;classified as</th> </tr> </thead> <tbody> <tr> <td>108</td> <td>21</td> <td>(a): class 0</td> </tr> <tr> <td>8</td> <td>173</td> <td>(b): class 1</td> </tr> </tbody> </table> Why/How to use parallel computing? - Parallel computing offers a means to speed up computation when other algorithmic and technology-based approaches saturate. - Genetic programming seems to be a reasonable candidate for parallel computing: evolution in nature takes place in parallel. Broad Parallel Computing Models - **Shared Memory**: Several processors sharing variables in a common memory. - **Distributed Memory**: Processors working independently, communicating results through messages. Parallel Computing Trade-Offs - **Shared Memory**: - Fast, but - Requires specially-implemented interconnect. - Scalability limited. - **Distributed Memory**: - Slower, due to communication delays, but - Commodity processors can be used. - Highly-scalable (1000’s of processors on a network) Choice for Genetic Programming - We use distributed memory - **MPI** library (Multi-Processor Interface) - Very portable - Many systems use it: - "Beowulf" clusters (16 processors at HMC) - Others - Based on Single-Program Multiple-Data Model - One program for all computers - Differentiable by processor id **Parallel version of gentree.** - Population is divided into "demes". - Each deme evolves independently for a while, then passes most fit to its immediate neighbor, called the "island model". - We currently use a logical "ring" organization to connect the processors. - Demes can also help with the diversity problem. **Speedup Measurements** - Speedup $S_p = T_1 / T_p$ - $T_p$ = Time to execute on $p$ processors - Ideally $S_p > kp$, where $k$ is a constant near 1 **Sample Speedup Measurements** <table> <thead> <tr> <th>running mbl-factor with aggregate population 1000 processors</th> <th>run time (sec.)</th> <th>speedup</th> </tr> </thead> <tbody> <tr> <td>1</td> <td>580.530</td> <td>1</td> </tr> <tr> <td>2</td> <td>326.650</td> <td>1.77</td> </tr> <tr> <td>3</td> <td>347.400</td> <td>1.67</td> </tr> <tr> <td>4</td> <td>167.490</td> <td>3.47</td> </tr> <tr> <td>8</td> <td>74.230</td> <td>7.80</td> </tr> </tbody> </table> **Early Termination** - Our implementation includes a distributed load sharing and early-termination capability. - When a processor is not "making progress" toward better solutions in its deme, it notifies its neighbor. The notification is passed to other processors, until a processor is found that is making progress, which then gives some highly fit individuals to the originating processor. - If no such processor is found, then a message is sent out to terminate execution. **Added Challenge** - Early termination makes it difficult to determine speedup, because the amount of work done is dependent on the number of processors. - We want to not delay getting answers to the user, yet we also want to be getting true speedup from the multi-processor version of the system. Our software gentree/pagentree is a single source build under CVS on turing.cs.hmc.edu. Less than 1000 out of 5837 are devoted to MPI support. All MPI code was done by Brian Bentow. wc *.cpp *.h 1333 4220 35179 chromosome.cpp 121 279 2569 config.cpp 878 2234 17348 dataSet.cpp 211 431 3497 directedoutput.cpp 1824 5629 51635 gentree.cpp 199 700 4871 question.cpp 5837 17883 146728 total Eventually we plan to make it available to the public on the web. Related work (1) - There is a fair amount of work on parallel genetic programming. I won't list it all here, but it is readily accessible on the web. - In 1999, almost no references to genetic programming of decision trees could be found. An old, cursory, one I discovered this past year was: Related work (2) - At the start of the summer project, we discovered some more recent work, notably: H.C. Kennedy, et al., The construction and evaluation of decision trees: A comparison of evolutionary and concept learning methods, Springer, LNCS 1305, 1997 and - At the end of the summer, we discovered some very relevant work hiding under "genetic algorithms": Athanasios Papagelis, Dimitris Kalles, GATree: Genetically Evolved Decision Trees, International Conference on Tools in AI, IEEE, Nov. 2001. This work reports extraordinarily good results for tree size (6 times better than C4.5, in some cases). We are still in the process of evaluating it. - Additional related work is appearing as we speak. See our wiki: http://www.cs.hmc.edu/~jmalone/cgi-bin/research/wiki.pl Future directions - We have ideas for several improvements in the existing algorithm. - An ultimate decision-tree generator can be built by seeding the population with results of C4.5 or other algorithms. - While parallel processing looks promising, we have more work to do to cogently present its benefits.
{"Source-Url": "https://www.cs.hmc.edu/courses/2003/fall/cs152/slides/pagentree.6.pdf", "len_cl100k_base": 5459, "olmocr-version": "0.1.49", "pdf-total-pages": 10, "total-fallback-pages": 0, "total-input-tokens": 41744, "total-output-tokens": 5946, "length": "2e12", "weborganizer": {"__label__adult": 0.0003743171691894531, "__label__art_design": 0.0003409385681152344, "__label__crime_law": 0.0005164146423339844, "__label__education_jobs": 0.0017938613891601562, "__label__entertainment": 7.218122482299805e-05, "__label__fashion_beauty": 0.00021505355834960935, "__label__finance_business": 0.00035572052001953125, "__label__food_dining": 0.0004656314849853515, "__label__games": 0.0004091262817382813, "__label__hardware": 0.0013494491577148438, "__label__health": 0.0010013580322265625, "__label__history": 0.0003786087036132813, "__label__home_hobbies": 0.0001894235610961914, "__label__industrial": 0.0007939338684082031, "__label__literature": 0.0002868175506591797, "__label__politics": 0.0003857612609863281, "__label__religion": 0.0006337165832519531, "__label__science_tech": 0.133056640625, "__label__social_life": 0.00019657611846923828, "__label__software": 0.0114288330078125, "__label__software_dev": 0.8447265625, "__label__sports_fitness": 0.0003592967987060547, "__label__transportation": 0.0006608963012695312, "__label__travel": 0.00021278858184814453}, "weborganizer_max": "__label__software_dev", "avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_ratio": [[0, 17407, 0.0625]], "fineweb_edu_fasttext_gt2__fineweb_edu_fasttext_gt2__score": [[0, 17407, 0.22176]], "ft_lang_id_en_doc_v2__ft_lang_id_en_doc_v2__en": [[0, 17407, 0.81085]], "google_gemma-3-12b-it_contains_pii": [[0, 854, false], [854, 2122, null], [2122, 4249, null], [4249, 6191, null], [6191, 8778, null], [8778, 9551, null], [9551, 11272, null], [11272, 13274, null], [13274, 15191, null], [15191, 17407, null]], "google_gemma-3-12b-it_is_public_document": [[0, 854, true], [854, 2122, null], [2122, 4249, null], [4249, 6191, null], [6191, 8778, null], [8778, 9551, null], [9551, 11272, null], [11272, 13274, null], [13274, 15191, null], [15191, 17407, null]], "google_gemma-3-4b-it_v2tag__is_academic_paper": [[0, 5000, true], [5000, 17407, null]], "google_gemma-3-4b-it_v2tag__is_class_syllabus": [[0, 5000, false], [5000, 17407, null]], "google_gemma-3-4b-it_v2tag__is_completion_certificate": [[0, 5000, false], [5000, 17407, null]], "google_gemma-3-4b-it_v2tag__is_court_notice": [[0, 5000, false], [5000, 17407, null]], "google_gemma-3-4b-it_v2tag__is_homework_assignment": [[0, 5000, false], [5000, 17407, null]], "google_gemma-3-4b-it_v2tag__is_news_article": [[0, 5000, false], [5000, 17407, null]], "google_gemma-3-4b-it_v2tag__is_public_order": [[0, 5000, false], [5000, 17407, null]], "google_gemma-3-4b-it_v2tag__is_resume_cv": [[0, 5000, false], [5000, 17407, null]], "google_gemma-3-4b-it_v2tag__is_test_or_quiz": [[0, 5000, false], [5000, 17407, null]], "google_gemma-3-4b-it_v2tag__is_textbook": [[0, 5000, false], [5000, 17407, null]], "pdf_page_numbers": [[0, 854, 1], [854, 2122, 2], [2122, 4249, 3], [4249, 6191, 4], [6191, 8778, 5], [8778, 9551, 6], [9551, 11272, 7], [11272, 13274, 8], [13274, 15191, 9], [15191, 17407, 10]], "pipe_delimited_lines_v1__pipe_delimited_lines_v1__pipe_delimited_lines_ratio": [[0, 17407, 0.15493]]}
olmocr_science_pdfs
2024-11-27
2024-11-27
a520d0ac2109a6cc70a72f8a9fdbf357f6bae16b
Agile Release Planning and Monitoring March 1, 2010 A Tough, but Solvable, Problem Release Planning Types of Release Plan Our Problem Function Point Discussion Our Solution Release Plan **Planning Artifacts** - **Project Visioning** - Product Vision - Price / Contract - Product Roadmap - **Project Start** - **Release Planning** - **Sprint** - **Release** - **Closeout Activities** **Sprint Goal** - Sprint Backlog **Release Goal** - Release Baseline - Release Strategy - Release Game Plan **Release Types: What’s the Problem?** - When Can we Release? - Known scope, existing team - What Can we Release? - Known time, existing team - How much will it Cost? - Known time, known scope, new team - This is the tough one… fixed price - All based on calculation - Time x Capacity = Scope - Let’s do a quick version of the “hard” case - Then finish the talk with one of the easy cases - Because I have the data for it 😊 Our Problem - Have a client, Royal Catalina Airlines (RCA) - Royal Catalina Airlines is owned by Sir Geoffrey Smithers (SirJeff) who made a fortune writing software in the Silicon Valley before buying a plane and ferrying tourists up and down the California Coast - He is now buying 4 more planes, hiring pilots, crews, etc, and wants a website, RoyalCatalinaAir.com. We’re writing it for him… - In six months he wants: - The customer can “Buy an e-ticket” - The customer can “Check Status of Flights” - The customer can “Get a Hotel at his destination” - The customer can “Get a rental car at his destination” - The Pilots can “Manage Pilot Timesheets” - The Customer can “Manage the Good Customer Plan” - He asks: “How Much will this Cost?” Function Point Discussion Just for fun, let’s discuss Functional Measurement… A General Concept - Function Points - Use Case Points - Feature Points - COSMIC Function Points All attempt to measure “moving parts” of software - Most of the calculations are difficult - And require a design - What can we learn to use with Story Points? COSMIC Function Points - Relatively new, latest version is 2007 - Easy to Calculate - If we wanted to measure CFP production as we move along - Part of our Sprint Review “we produced 35 CFPs this Sprint” - Easy to Estimate (very important for us) - Only measures moving parts - Entry – sending information to the system - Exit – receiving information from the system - Read – reading information from persistent storage - Write – writing information to persistent storage - See picture next page… Counting COSMIC Function Points - This is how FPs are counted using COSMIC - Here is a typical system For a given scenario, all we do is count the number of times information moves, and the total is our CFP. But requests for data don’t count. Yes, it is that simple... Yes, it is that much of a pain... Example: Add Traveler to Itinerary - This is as simple as it gets - A Small Story, with CFP = 2 Example: - As a <traveler> I would like to add my daughter to my itinerary so that we could travel together. Preconditions: - Itinerary exists in CatAir DB - Itinerary is up on screen Postconditions: - Itinerary with daughter added is in CatAir DB - Itinerary on screen shows complete with me and my daughter Example: Get List of Flights from CUTLASS Get List of Flights As a traveler I want a list of flights that match my itinerary so that I can find one that works for me Preconditions: - Traveler has prepared an itinerary Postconditions: - CUTLASS has returned a list of flights that matches the itinerary (up to 10) - The list is presented to the traveler - This is typical Medium-Sized Story, CFP = 4 Example: Pick One and Pay with VISA™ Pick Flight and Pay with VISA As a traveler I want to pay with VISA for a flight that I pick from a list Preconditions: - a list of flights is on the screen Postconditions: - the chosen flight has been paid for - the itinerary is updated as being paid for - the payment is confirmed to the traveler - This is a large one, CFP = 8 Summary of Story Size (Relative) Estimation - Pick a “typical” M-Sized Story – possibly “a simple secondary scenario for an existing use case” with CFP = 4 - For Functional Stories, compare the story to the “basic M-Sized” Story - Use Estimation game with question: “How big is this one, in terms of moving parts, compared to our ‘typical M-Sized one’, given that the codebase is the same, the same people work on it, and so on” - Double (?) the points if it is “architecturally significant” - For non-Functional stories with well-defined definitions of “done” compare the story to the “basic M-Sized” Story - Use Estimation game with question: “How hard is this one, in terms of effort, compared to our ‘typical M-Sized one’, given that …” - For Stories with ill-defined definitions of “done”, timebox them - “Do 8 hours of Exploratory testing on page ABC” - “Do a Small Story’s worth of work cleaning up the code in module XYZ” Our Solution Baselines for Capabilities - By working with Stakeholders and Developers, the team arrives at the following baseline sizes (in Function Point (FP)* for the wanted capabilities: <table> <thead> <tr> <th>Capability</th> <th>FPs</th> </tr> </thead> <tbody> <tr> <td>Buy an e-Ticket</td> <td>150</td> </tr> <tr> <td>Check Status of Flights</td> <td>50</td> </tr> <tr> <td>Get Hotel at Destination</td> <td>100</td> </tr> <tr> <td>Get Rental Car at Destination</td> <td>100</td> </tr> <tr> <td>Pilot Timesheets (risky)</td> <td>250</td> </tr> <tr> <td>Good Customer Plan (risky)</td> <td>250</td> </tr> <tr> <td><strong>Total</strong></td> <td><strong>900</strong></td> </tr> </tbody> </table> * Function Points quantify the functional user requirements (FUR), independent of technical or quality requirements. FUR relate to (but are not limited to) data transfer, transformation, storage, and retrieval. Counter-offer - Standard estimation (20 hrs / FP) tells us that we'll need 18,000 Hours = 18 people for six months (there is no magic...) - We go back to SirJeff and tell him that we would need a 18-person project team from day one, and we don't have that - We’d be glad to come up with a ramp-up plan for him - Or, we could figure out what we can actually give him with the people we have available, which is one team that is moving off of another project - SirJeff says: "ok, tell me what this one team can give me in the next three months" What’s Going On Now - Have a team - Transitioning from SouvSite development - Half the team for the first 2 sprints - Whole team from then on - SirJeff wants initial release in 3 months (7 sprints) - Needs to be useful to consumers - What he can tell his marketing and sales folks will be there? - This is a classic “Release Planning”-type question - Remember, SirJeff’s priorities are: 1. Buy an e-Ticket 2. Check Status of Flights 3. Pilot Timesheets 4. The rest… ### Historical Information for Team - 8 Members of Team - Currently on SouvSite project - Velocity as below - “Plannable” hours per 2-week sprint as at right <table> <thead> <tr> <th>Plannable Hours/Person</th> <th>Hrs</th> </tr> </thead> <tbody> <tr> <td>Total Hours</td> <td>80</td> </tr> <tr> <td>Minus Planning Day</td> <td>72</td> </tr> <tr> <td>Minus Grooming Mtg</td> <td>68</td> </tr> <tr> <td>Minus Lost Time</td> <td>60</td> </tr> </tbody> </table> - Lost Time is vacation, sick, management time, etc - Meetings aren’t plannable, as they are fixed time already spoken for Baseline Total Capacity Calculations - We have half the team for the first two sprints - We have a Transition sprint, as we bring the rest of team over - And then we have four “full” sprints - Joe’s on a Honeymoon sprints 5-6 - This is a total of 335 SPs as our baseline SP budget - And we “spend” 2820 hours to do it - 60 hours/person/sprint <table> <thead> <tr> <th>Sprint</th> <th>1</th> <th>2</th> <th>3</th> <th>4</th> <th>5</th> <th>6</th> <th>7</th> <th>Total</th> </tr> </thead> <tbody> <tr> <td>Hours</td> <td>240</td> <td>240</td> <td>480</td> <td>480</td> <td>468</td> <td>432</td> <td>480</td> <td>2820</td> </tr> <tr> <td>SPs</td> <td>30</td> <td>30</td> <td>45</td> <td>60</td> <td>58</td> <td>52</td> <td>60</td> <td>335</td> </tr> </tbody> </table> Adjusting the Count - What we want, though, is how many SPs we can dedicate to SirJeff’s stuff… these will be our FPs - So, we make adjustments to the count <table> <thead> <tr> <th>Step</th> <th>What’s Going On</th> <th>Avail SPs</th> </tr> </thead> <tbody> <tr> <td>1</td> <td>Calculate Total Capacity (what we just did)</td> <td>335 SPs</td> </tr> <tr> <td>2</td> <td>Need a Release Sprint, so lose last Sprint’s worth</td> <td>275 SPs</td> </tr> <tr> <td>3</td> <td>Lose SPs to Maintain SouvSite after Sprint 2 (10%, or 21 SPs)</td> <td>254 SPs</td> </tr> <tr> <td>4</td> <td>Lose SPs for Chores (30%, or 76 SPs)</td> <td>178 SPs</td> </tr> </tbody> </table> - So, we have 178 SPs to dedicate to SirJeff’s stuff in this release… (convert these to Function Points…) - Let’s figure out how to use them This is where it gets interesting - Rely on the “wisdom of the crowds” again - Talk to team - Talk to Stakeholders - Innovation Games (Luke Hohmann) - Do S/M/L estimation game at the Use Case level - Maybe budget 75/150/250 or 100/150/200 to the different sizes - Maybe do some initial analysis and extrapolate using S-shaped curve - Goal is to get a budget, and use agility to deliver within this budget - The low-level strategic agility the PO “owns” - Don’t want to cut yourselves short here – want to have a chance to succeed S-Shaped Curve for Delivery of Use Cases... - If we know SPs for “backbone”, can just multiply by 3 - If we know “all the stuff we want”, then just multiply by 3 (because we know the must-haves) - Otherwise, make a guess based on size of Use Case (how many moving parts) What the Team Thinks (more detail) - **“Buy an e-Ticket”** - Backbone is 6 Large stories = 48 SPs, so need 144 SPs - Looks like an initial version of this is a M-Sized Use Case, so need 150 SPs - So, we want 150 SPs - **“Check Status of Flights”** - Don’t really know how hard this is - If data is already in CUTLASS, is a really small Use Case - Willing to dedicate 50 SPs, but - 10 SPs dedicated to figuring out CUTLASS interface (need this anyway, for Buy an e-Ticket) - 40 SPs for Check Status, but no guarantee of making it - **“Pilot Timesheets”** - Have no idea, but want to do 20 SPs worth of investigation to see how hard it is for next release… Negotiating the Budgets (our baseline) - Note that the Team thinks it needs 220 SPs, but the Capacity calculations show we only have 178 SPs to play with – Oops… Now what? - Negotiation, arriving at the following table… and we also got Business Values from SirJeff for the ones he cares about… <table> <thead> <tr> <th>Capability/Item</th> <th>BV</th> <th>Baseline</th> </tr> </thead> <tbody> <tr> <td>Buy an e-Ticket</td> <td>80%</td> <td>108SP</td> </tr> <tr> <td>Investigate CUTLASS interface/capabilities</td> <td>10%</td> <td>10SP</td> </tr> <tr> <td>Investigate the basics of Pilot Timesheets</td> <td>10%</td> <td>20SP</td> </tr> <tr> <td>Check Status of Flights</td> <td>10%</td> <td>40SP</td> </tr> <tr> <td>SouvSite Maintenance (before Release Sprint)</td> <td>10%</td> <td>21SP</td> </tr> <tr> <td>Chores (before Release Sprint)</td> <td></td> <td>76SP</td> </tr> <tr> <td>Release Sprint (includes SouvSite Maint and Chores)</td> <td></td> <td>60SP</td> </tr> <tr> <td><strong>Total</strong></td> <td>100%</td> <td>335SP</td> </tr> </tbody> </table> **risky** 178 Finally, we have the info we need - So, Release 1 Goal - Initial Release of CatAir website. Must be able to sell a ticket on the web - Strategy: 1. Learn How to use CUTLASS 2. Get a minimal “Buy e-Ticket” as fast as possible - We know SP budget is risky - But this Epic is the most important - But don’t gold-plate – pay attention to “minimal”… 3. Then, if Sprint 6 hasn’t begun yet, start “Status of Flights” 4. Focus Sprint 6 on determining how hard “Pilot Timesheets” are 5. If it’s possible to get a releasable version of “Status of Flights after investigating “Pilot Timesheets”, do so 6. If not, get more functionality for “Buy e-Ticket” (make it prettier, for instance) - Both the Goal and Strategy are negotiated, and agreed to, between SirJeff and the Scrum Team And we Come Up With a Game Plan - Note that we decomposed the Release Sprint into pieces, too, in order to manage “Release Activities" Any Questions? Monitoring the Release Release BurnUp Earned Value Metrics Earned Business Value Tracking SirJeff’s Release How the Release Actually Played Out How Release Played Out (SPs) <table> <thead> <tr> <th>Sprint</th> <th>1</th> <th>2</th> <th>3</th> <th>4</th> <th>5</th> <th>6</th> <th>7</th> <th>Total</th> </tr> </thead> <tbody> <tr> <td>Hours</td> <td>253</td> <td>233</td> <td>495</td> <td>530</td> <td>467</td> <td>445</td> <td>498</td> <td>2921</td> </tr> <tr> <td>SPs</td> <td>26</td> <td>32</td> <td>42</td> <td>54</td> <td>66</td> <td>52</td> <td>54</td> <td>326</td> </tr> </tbody> </table> How Release Played Out (PersonHours) Release Activities - Buy an e-ticket - Check Status of Flights - Investigate Pilot Timesheets - Investigate CUTLASS Interface - SouvSite Maintenance - Chores Release Burnup Correction In Sprint 3 - We are delivering capabilities and Stories - But what we are managing is (largely) StoryPoints - The BurnUp graph shows our production of StoryPoints - It shows our SP velocity graphically - It shows how many SPs we have “to go” - It shows our inventory of SPs that are “ready to go” - And it’s easy to calculate Earned Value Metrics (SPI and CPI) The Metrics that Really Matter (CPI and SPI) - CPI answers the question “are we paying what we expected for each SP?” - The ratio CPI = (baseline $/SP) / (actual $/SP) - In our case, $ is person-hours, and (baseline $/SP) is calculated cumulatively, sprint by sprint - SPI answers the question “are we getting the SPs at the rate we expected?” - The ratio SPI = (actual SP/Sprint) / (baseline SP/Sprint) - In our case, our baseline velocity is also calculated cumulatively, sprint by sprint - We like CPI and SPI to be ≥ 1 in standard EVM - You’ll have to trust me on the derivations* This graph shows our SPI and CPI as we move through the sprints. The values are calculated cumulatively, not one sprint at a time. <table> <thead> <tr> <th>Sprint</th> <th>1</th> <th>2</th> <th>3</th> <th>4</th> <th>5</th> <th>6</th> <th>7</th> <th>Total</th> </tr> </thead> <tbody> <tr> <td>Hrs (B)</td> <td>240</td> <td>240</td> <td>480</td> <td>480</td> <td>468</td> <td>480</td> <td>2820</td> <td></td> </tr> <tr> <td>SPs (B)</td> <td>30</td> <td>30</td> <td>45</td> <td>60</td> <td>58</td> <td>52</td> <td>60</td> <td>335</td> </tr> <tr> <td>Hrs (A)</td> <td>253</td> <td>233</td> <td>495</td> <td>530</td> <td>467</td> <td>445</td> <td>498</td> <td>2921</td> </tr> <tr> <td>SPs (A)</td> <td>26</td> <td>32</td> <td>42</td> <td>54</td> <td>66</td> <td>52</td> <td>54</td> <td>326</td> </tr> </tbody> </table> However... - In an agile project, we are not paid to produce StoryPoints, we are paid to produce Business Value. - Business Value is subjective, and based on our Stakeholder’s needs for this Release. - Here are the features with BV in this release: <table> <thead> <tr> <th>Goal/Feature/Capability</th> <th>BV</th> <th>Baseline</th> </tr> </thead> <tbody> <tr> <td>Buy an e-ticket</td> <td>80%</td> <td>108 SPs</td> </tr> <tr> <td>Investigate the basics of Pilot Timesheets</td> <td>10%</td> <td>20 SPs</td> </tr> <tr> <td>Check Status of Flights</td> <td>10%</td> <td>40 SPs</td> </tr> </tbody> </table> As we deliver Stories within a feature, the Earned Business Value (EBV(feature)) increases, and is a percentage of the Feature’s Business Value (BV(feature)). EBV Not Really a “Metric” - It doesn’t measure anything - It tells us where a capability’s EBV “should be” if - The overall budget for the capability was right - The PO is making good decisions about what is important - In other words, an EBV graph is only good to start a conversation - According to this graph, this capability should be 65% “done”… is that what it feels like? - So, the conversation about the EBV graph gives us very good information about progress of the project For New Features - That have an architectural element to them - In our Case, we use this curve for - Buy an e-ticket - Check Status of Flights For New/Existing Features - Without an architectural element to add this Release - In our Case, we use this curve for - Investigate the Basics of Pilot Timesheets Earned Business Value Graphs Correction In Sprint 3 Any Questions? Summary Scrum Scales Up - The “Wisdom of the Crowd” and the “Law of Large Numbers” allow us to some pretty sophisticated and accurate release Planning - But we must be agile as we do the work - It’s a baseline strategy, not a plan - We can monitor against this baseline with some pretty good metrics Any Final Questions? Thank You Very Much!
{"Source-Url": "https://www.open.collab.net/media/pdfs/SBU_ReleasePlanning.pdf", "len_cl100k_base": 5020, "olmocr-version": "0.1.53", "pdf-total-pages": 22, "total-fallback-pages": 0, "total-input-tokens": 46845, "total-output-tokens": 5582, "length": "2e12", "weborganizer": {"__label__adult": 0.0007524490356445312, "__label__art_design": 0.0006303787231445312, "__label__crime_law": 0.0005321502685546875, "__label__education_jobs": 0.0034332275390625, "__label__entertainment": 9.28044319152832e-05, "__label__fashion_beauty": 0.00035691261291503906, "__label__finance_business": 0.003858566284179687, "__label__food_dining": 0.0008034706115722656, "__label__games": 0.0007448196411132812, "__label__hardware": 0.000400543212890625, "__label__health": 0.0006556510925292969, "__label__history": 0.0004775524139404297, "__label__home_hobbies": 0.0002281665802001953, "__label__industrial": 0.0006256103515625, "__label__literature": 0.0004968643188476562, "__label__politics": 0.00054168701171875, "__label__religion": 0.0004444122314453125, "__label__science_tech": 0.0015497207641601562, "__label__social_life": 0.0003058910369873047, "__label__software": 0.005535125732421875, "__label__software_dev": 0.97509765625, "__label__sports_fitness": 0.0007433891296386719, "__label__transportation": 0.0009026527404785156, "__label__travel": 0.000568389892578125}, "weborganizer_max": "__label__software_dev", "avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_ratio": [[0, 16259, 0.02535]], "fineweb_edu_fasttext_gt2__fineweb_edu_fasttext_gt2__score": [[0, 16259, 0.04438]], "ft_lang_id_en_doc_v2__ft_lang_id_en_doc_v2__en": [[0, 16259, 0.90156]], "google_gemma-3-12b-it_contains_pii": [[0, 189, false], [189, 944, null], [944, 1731, null], [1731, 2685, null], [2685, 3404, null], [3404, 4175, null], [4175, 5130, null], [5130, 6419, null], [6419, 7395, null], [7395, 8646, null], [8646, 9462, null], [9462, 11132, null], [11132, 12071, null], [12071, 12196, null], [12196, 13028, null], [13028, 13772, null], [13772, 15037, null], [15037, 15676, null], [15676, 15896, null], [15896, 15920, null], [15920, 16239, null], [16239, 16259, null]], "google_gemma-3-12b-it_is_public_document": [[0, 189, true], [189, 944, null], [944, 1731, null], [1731, 2685, null], [2685, 3404, null], [3404, 4175, null], [4175, 5130, null], [5130, 6419, null], [6419, 7395, null], [7395, 8646, null], [8646, 9462, null], [9462, 11132, null], [11132, 12071, null], [12071, 12196, null], [12196, 13028, null], [13028, 13772, null], [13772, 15037, null], [15037, 15676, null], [15676, 15896, null], [15896, 15920, null], [15920, 16239, null], [16239, 16259, null]], "google_gemma-3-4b-it_v2tag__is_academic_paper": [[0, 5000, false], [5000, 16259, null]], "google_gemma-3-4b-it_v2tag__is_class_syllabus": [[0, 5000, false], [5000, 16259, null]], "google_gemma-3-4b-it_v2tag__is_completion_certificate": [[0, 5000, false], [5000, 16259, null]], "google_gemma-3-4b-it_v2tag__is_court_notice": [[0, 5000, false], [5000, 16259, null]], "google_gemma-3-4b-it_v2tag__is_homework_assignment": [[0, 5000, false], [5000, 16259, null]], "google_gemma-3-4b-it_v2tag__is_news_article": [[0, 5000, false], [5000, 16259, null]], "google_gemma-3-4b-it_v2tag__is_public_order": [[0, 5000, false], [5000, 16259, null]], "google_gemma-3-4b-it_v2tag__is_resume_cv": [[0, 5000, false], [5000, 16259, null]], "google_gemma-3-4b-it_v2tag__is_test_or_quiz": [[0, 5000, false], [5000, 16259, null]], "google_gemma-3-4b-it_v2tag__is_textbook": [[0, 5000, false], [5000, 16259, null]], "pdf_page_numbers": [[0, 189, 1], [189, 944, 2], [944, 1731, 3], [1731, 2685, 4], [2685, 3404, 5], [3404, 4175, 6], [4175, 5130, 7], [5130, 6419, 8], [6419, 7395, 9], [7395, 8646, 10], [8646, 9462, 11], [9462, 11132, 12], [11132, 12071, 13], [12071, 12196, 14], [12196, 13028, 15], [13028, 13772, 16], [13772, 15037, 17], [15037, 15676, 18], [15676, 15896, 19], [15896, 15920, 20], [15920, 16239, 21], [16239, 16259, 22]], "pipe_delimited_lines_v1__pipe_delimited_lines_v1__pipe_delimited_lines_ratio": [[0, 16259, 0.14881]]}
olmocr_science_pdfs
2024-12-10
2024-12-10
a9594a8ea597388db92c9408c64ad257be82ad67
Challenges in Validating FLOSS Configuration Markus Raab, Gergö Barany To cite this version: Markus Raab, Gergö Barany. Challenges in Validating FLOSS Configuration. 13th IFIP International Conference on Open Source Systems (OSS), May 2017, Buenos Aires, Argentina. pp.101-114, 10.1007/978-3-319-57735-7_11 . hal-01658595 HAL Id: hal-01658595 https://inria.hal.science/hal-01658595 Submitted on 7 Dec 2017 HAL is a multi-disciplinary open access archive for the deposit and dissemination of scientific research documents, whether they are published or not. The documents may come from teaching and research institutions in France or abroad, or from public or private research centers. L’archive ouverte pluridisciplinaire HAL, est destinée au dépôt et à la diffusion de documents scientifiques de niveau recherche, publiés ou non, émanant des établissements d’enseignement et de recherche français ou étrangers, des laboratoires publics ou privés. Challenges in Validating FLOSS Configuration Markus Raab\textsuperscript{1} and Gergő Barany\textsuperscript{2}\textsuperscript{*} \textsuperscript{1} Institute of Computer Languages, Vienna University of Technology, Austria markus.raab@complang.tuwien.ac.at \textsuperscript{2} Inria Paris, France gergo.barany@inria.fr Abstract. Developers invest much effort into validating configuration during startup of free/libre and open source software (FLOSS) applications. Nevertheless, hardly any tools exist to validate configuration files to detect misconfigurations earlier. This paper aims at understanding the challenges to provide better tools for configuration validation. We use mixed methodology: (1) We analyzed 2,683 run-time configuration accesses in the source-code of 16 applications comprising 50 million lines of code. (2) We conducted a questionnaire survey with 162 FLOSS contributors completing the survey. We report our experiences about building up a FLOSS community that tackles the issues by unifying configuration validation with an external configuration access specification. We discovered that information necessary for validation is often missing in the applications and FLOSS developers dislike dependencies on external packages for such validations. 1 Introduction Configuration settings influence the behavior of software and are used ubiquitously today. Configuration access is done by the part of applications concerned with fetching configuration settings from configuration files, environment variables, etc. at run-time. Configuration validation detects configuration settings which do not fulfill the user’s expectations, for example, setting a web browser’s proxy to a server that is not reachable in the currently connected network. While configuration access seems to be straightforward, system administrators experience many surprises on a daily basis. In the systems community the issue is well-known as misconfiguration \cite{37,30,1,36}. Misconfigurations cause large-scale outages of Internet services \cite{19}. Yin et al. \cite{37} claim that “a majority of misconfigurations (70.0\%~85.5\%) are due to mistakes in setting configuration”. Xu et al. argue that often configuration access code and not system administrators are to blame \cite{35}. Often (38.1\%~53.7\%) misconfiguration is caused by illegal settings which clearly violate syntactic or semantic rules \cite{37}. Thus most errors could be caught with a consistency checker executed before configuration changes. Nevertheless, only in 7.2\% to 15.5\% cases do error messages pinpoint the error \cite{37}. Free/libre and open source software (FLOSS) applications often \textsuperscript{*} This work was performed while the author was at CEA LIST Software Reliability Laboratory, France, and supported by the French National Research Agency (ANR), project AnaStaSec, ANR-14-CE28-0014. do not validate their settings before startup or even later [34]. System administrators have to find their own ad-hoc ways [3,4,13,31,39]. Other factors also influence configuration settings. We will call validation that considers more than the settings of a single application global validation. Faulty global validation causes issues in $46.3\%-61.9\%$ of cases [37]. For example, when a web browser is started in a different network, previously working proxy settings will fail to work. Our holistic approach rejects misconfigurations early on. These issues lead to our research question: Why do we lack tools for global validation, and how can we help developers provide them? Our contributions are as follows: - We showed that `getenv` is omnipresent and popular (Section 3). - We unveiled challenges related to current configuration systems (Section 4). - We implemented a tool implementing the unearthed requirements (Section 5). - The tool is available as free software at https://www.libelektra.org. 2 Methodology Our methodological foundation builds on “theory building from cases” [10,11]. In the present paper we will use two different methodologies embedded in a framework: source-code analysis and a questionnaire. 2.1 Source-code Analysis We study `getenv`, which is an application programming interface (API) to access environment variables. We chose it because it is the only widely standardized configuration access API (including C, C++, and POSIX) and available in many programming languages. In earlier work [26], we showed that `getenv` is used at run-time ubiquitously. `getenv` is often combined with other techniques (e.g., config files), sometimes overriding configuration file settings. Furthermore, environment variables are not part of configuration settings dialogues, i.e., they are certainly not validated. We carefully selected 16 applications across different domains. We included large applications with a thriving community but also others for diversity. We used the versions of the applications as included in Debian 8 (Jessie) as shown later in Table 1. We downloaded package sources from http://snapshot.debian.org. To determine the code size we used Cloc 1.60 [7]. We manually counted all `getenv` occurrences for the version specified in Table 1. Then we categorized the resulting 2,683 code snippets around `getenv`. We looked if `getenv` occurrences depend on some other configuration. Such situations occur when configuration settings interact; for example, fallback chains of configuration access points depend on each other. Such fallback chains are hints to global configuration access, which we wanted to find. As our last experiment, we searched for places where global validation would be useful, and investigated how helpful the documentation of the `getenv` parameters is. **Threats to Validity:** For evaluating usefulness (as only done in the last experiment), by nature, subjectivity is involved. In particular, it is possible that we overlooked dependences. We will report the numbers we found but we consider the experiment as exploratory and not as something that could be repeated with the same numbers as outcome. The individual examples, however, are insightful. ### 2.2 Questionnaire We carefully prepared a questionnaire with FLOSS developers in mind. Then we conducted pilot surveys with developers, colleagues and experts for surveys. In the iterations we improved the questions and made the layout more appealing. In order to reach the target group, we posted requests to fill out the survey in the respective FLOSS communication channels. To obtain a higher quality, we awarded non-anonymous answers with small donations to FLOSS-related projects. We used the non-anonymous answers to cross-check statistics. We asked some personal questions about age, education, occupation, and FLOSS participation to have the important characteristics of our participants. We used LimeSurvey version 2.50+ for conducting the survey. We will report the percentages relative to the number of persons ($n$) who answered a particular question. We report means and standard deviations ($s$) of samples for $n \geq 95$. **Threats to Validity:** For the validity of our survey it is important that only FLOSS contributors participate. The donation might have persuaded some participants to fill out parts of the survey even though they had no particular experience. Thus we explicitly asked about contributions to specific projects. The survey reflects the beliefs of participants. Thus we used other methods to distill facts about the applications. Because opinions help to understand goals and reasons, the survey is an important part of the overall study. It should be considered as supplement to the source-code analysis. **Demographics:** The front page of the survey was shown to 672 persons, 286 gave at least one answer, 162 completed the questionnaire, and 116 persons entered their email addresses. The age of the population ($n = 220$) has a mean of 32 years ($s = 9$). The degrees in the population ($n = 244$) are: master ($38\%$), bachelor ($25\%$), student ($18\%$), no degree ($13\%$), or PhD ($6\%$). As their occupation, $56\%$ of the persons selected software developer, $21\%$ system administrator, and $16\%$ researcher (multiple choice question, $n = 287$). Participants reported work on up to five different FLOSS projects. For the first project, they estimated their participation with a mean of 5.3 years ($s = 5$, $n = 180$). $60\%$ of them reported a second FLOSS project, $36\%$ a third, $17\%$ a fourth, and $9\%$ a fifth. Raw data and questions are available at [https://rawdata.libelektra.org](https://rawdata.libelektra.org). ### 3 Configuration Access Before we start exploring our research question, we need to validate that our evaluated configuration accesses are indeed relevant and popular. In this section we investigate which configuration access methods FLOSS developers use. 3.1 Which Methods for Configuration Access are Popular? Finding 1a: We observed that `getenv` is omnipresent with 2,683 occurrences. The source code of the applications we analyzed has 4,650 textual `getenv` occurrences. 2,683 of them were actual `getenv` invocations, 1,967 were occurrences in comments, ChangeLog, build system, or similar. (See Table 1 for details.) Finding 1b: Three kinds of configuration access are equally popular: Command-line arguments, environment variables, and configuration files. Developers are highly satisfied with them. Others are used less and less liked. Command-line arguments (92\%, n = 222), environment variables (e.g., via `getenv`) (79\%, n = 218), and configuration files (74\%, n = 218) are the most popular ways to access configuration. Other systems, such as X/Q/GSettings, KConfig, dconf, plist, or Windows Registry, were used less (\(\leq 13\%\), n \(\geq 185\)). Participants rarely found it (very) frustrating to work with the popular systems: `getenv` (10\%, n = 198), configuration files (6\%, n = 190), and command-line options (4\%, n = 210). Less-used systems frustrated more (\(\geq 14\%\), n \(\geq 27\)). 3.2 What is the Purpose of `getenv`? Finding 1c: Like other configuration accesses, `getenv` is used to access configuration settings (57\%). Sometimes it bypasses main configuration access. Of the 2,683 `getenv` invocations, 1,531, i.e., 57\%, relate to run-time configuration settings and not debugging, build-system, or similar. Further investigations in this paper elaborate on these 1,531 `getenv` occurrences. We found occurrences where `getenv` obviously bypasses main configuration access, for example, to configure the location of configuration files. Also in the survey we asked about the purpose of `getenv` (n = 177). The reasons to use it vary: in a multiple choice question 55\% say they would use it for debugging/testing, 45\% would use `getenv` to bypass the main configuration access, and 20\% would use `getenv` if configuration were unlikely to be changed. Finding 1d: In many cases `getenv` parameters are shared between applications. In the source code we investigated which parameters were passed to `getenv`. We found that 716 parameters were shareable parameters such as `PATH`. In the survey 53\% say they use `getenv` for configuration integration (n = 177). Finding 1e: Parameters of `getenv` are often undocumented. The function parameter passed to `getenv` invocations tells us which configuration setting is accessed. In an Internet search using the application's and `getenv` parameter's name with `startpage.com`, we found documentation for only 283 of the non-shared `getenv` parameters but not for the 387 others. The FLOSS projects deal with the missing documentation of `getenv` parameters in different ways. Most projects simply claim their `getenv` usage as internal, saying the environment should not be used for configuration by end users, even if there is no other way of achieving some goal. Often we miss a specification describing which parameters are available. In some other projects, the developers invest effort to create lists of available parameters. For example, in Libreoffice developers try to find `getenv` occurrences automatically with `grep`, which fails with `getenv` aliases\(^3\). **Discussion:** The `getenv` API has some severe limitations and is sometimes a second-class citizen. One limitation is that return values of `getenv` invocations cannot be updated by other processes. For example, `getenv("http_proxy")` within a running process will still return the old proxy, even if the user changed it elsewhere. Nevertheless, `getenv` supports all characteristics of configuration access and can be used to investigate challenges in configuration validation. **Implication:** Configuration APIs should avoid returning outdated values. Environment variables, however, are no replacement for configuration files, thus they do not support persistent changes by applications. There is currently no satisfactory solution in FLOSS for global, shareable configuration settings. ## 4 Configuration Validation Having established which configuration accesses are popular (including, but not limited to, `getenv`), we will investigate challenges of configuration validation. ### 4.1 Which are the Concerns Regarding Global Validation? **Finding 2a:** *Developers have concerns about adding dependencies for global validation (84%) and reducing configuration (30%) but desire good defaults (80%).* Many persons (30\%, \(n=150\)) think that the number of configuration settings should not be reduced. But 43\% said it should be reduced to prevent errors. We got mixed answers (\(n=177\)) to the question “Which effort do you think is worthwhile for providing better configuration experience?” Most persons (80\%) agree that proper defaults are important. Most methods exceed the effort considered tolerable by the majority of participants: Only `getenv` would be used by the majority (53\%). System APIs would be used by 44\%. Fewer (30\%) would use OS-specific data. Only 21\% of the participants would use dedicated libraries, 19\% parse other configuration files, and 16\% use external APIs that add new dependencies. **Discussion:** To avoid dependencies, FLOSS developers currently expect users to configure their applications to be consistent with the global configuration. **Implication:** The results indicate demand for dependency injection to have global validation without direct dependencies. ### 4.2 Which Challenges Prevent us from Supporting Validation? **Finding 2b:** *Present configuration validation is encoded in a way unusable for external validation or introspection tools.* In none of the 16 applications was the validation code kept separately, e.g., in a library. Instead it was scattered around like other cross-cutting concerns. \(^3\) [https://bugs.documentfoundation.org/show_bug.cgi?id=37338](https://bugs.documentfoundation.org/show_bug.cgi?id=37338) Finding 2.: Developers are unable to support global validation, even if the problem is well-known and they put effort into it. We found out that information essential to check or fix constraints is not available within the applications. In Table 1 we present a list of applications and the `getenv` occurrences we analyzed. The column *textual `getenv`* contains the number of literal `getenv` occurrences, as we used it for the analysis of the histories. The column *lines per `getenv`* shows how often manually counted `getenv` occurs in code. The column *depend `getenv`* presents manually counted `getenv` occurrences that depend on, or are used by, other configuration code. <table> <thead> <tr> <th>application</th> <th>version</th> <th>1k lines of code</th> <th>textual <code>getenv</code></th> <th>counted <code>getenv</code></th> <th>lines per <code>getenv</code></th> <th>depend <code>getenv</code></th> </tr> </thead> <tbody> <tr> <td>Adel</td> <td>0.0.17</td> <td>474</td> <td>114</td> <td>55</td> <td>8,617</td> <td>43</td> </tr> <tr> <td>Akonadi</td> <td>1.13.0</td> <td>37</td> <td>16</td> <td>13</td> <td>2,863</td> <td>6</td> </tr> <tr> <td>Chromium</td> <td>45.0.2454</td> <td>18,032</td> <td>1,213</td> <td>770</td> <td>23,418</td> <td>281</td> </tr> <tr> <td>Curl</td> <td>7.38.0</td> <td>249</td> <td>278</td> <td>53</td> <td>4,705</td> <td>25</td> </tr> <tr> <td>Eclipse</td> <td>3.8.1</td> <td>3,312</td> <td>114</td> <td>40</td> <td>82,793</td> <td>23</td> </tr> <tr> <td>Evolution</td> <td>3.12.9</td> <td>673</td> <td>33</td> <td>23</td> <td>29,252</td> <td>5</td> </tr> <tr> <td>GCC</td> <td>4.9.2</td> <td>6,851</td> <td>727</td> <td>377</td> <td>18,172</td> <td>143</td> </tr> <tr> <td>Firefox</td> <td>38.3.0esr</td> <td>12,395</td> <td>1,052</td> <td>788</td> <td>15,730</td> <td>271</td> </tr> <tr> <td>Gimp</td> <td>2.8.14</td> <td>902</td> <td>80</td> <td>56</td> <td>16,102</td> <td>21</td> </tr> <tr> <td>Inkscape</td> <td>0.48.5</td> <td>480</td> <td>27</td> <td>19</td> <td>25,255</td> <td>13</td> </tr> <tr> <td>Ipe</td> <td>7.1.4</td> <td>116</td> <td>29</td> <td>21</td> <td>5,529</td> <td>14</td> </tr> <tr> <td>Libreoffice</td> <td>4.3.3</td> <td>5,482</td> <td>427</td> <td>284</td> <td>19,304</td> <td>143</td> </tr> <tr> <td>Lynx</td> <td>2.8.9dev1</td> <td>192</td> <td>112</td> <td>89</td> <td>2,157</td> <td>66</td> </tr> <tr> <td>Man</td> <td>2.7.0.2</td> <td>142</td> <td>248</td> <td>62</td> <td>2,293</td> <td>42</td> </tr> <tr> <td>Smplayer</td> <td>14.9.0 ds0</td> <td>76</td> <td>1</td> <td>1</td> <td>76,170</td> <td>1</td> </tr> <tr> <td>Wget</td> <td>1.16</td> <td>143</td> <td>179</td> <td>32</td> <td>4,456</td> <td>18</td> </tr> <tr> <td>Total</td> <td></td> <td>49,556</td> <td>4,650</td> <td>2,683</td> <td>18,470</td> <td>1115</td> </tr> <tr> <td>Median</td> <td></td> <td>477</td> <td>114</td> <td>54</td> <td>24</td> <td></td> </tr> </tbody> </table> Table 1. Automatic and manual count of `getenv` occurrences. Most of these places (1115, i.e., 73%) were dependent on some other configuration. We found 204 places where some kind of configuration dependencies were forgotten. In 58 cases we found several hints, e.g., fallback chains with missing cases or complaints on the Internet about the not considered dependency. We give a real-life example from the Eclipse source of how easily dependencies are forgotten. The missing dependencies lead to missing validation, which leads to frustrating user experience. If Eclipse wants to instantiate an internal web browser, some users get an error saying that `MOZILLA_FIVE_HOME` is not set. On GitHub alone, issues mentioning the variable were reported 71 times. The underlying issue usually is that the software package `webkitgtk` is missing\(^4\). The \(^4\) https://groups.google.com/forum/#!topic/xmind/5SjPTy0MzEo developers even considered the dependency (installation paths) for RPM-based systems by parsing `gre.conf`. But for other users on non-RPM-based systems the fallback is to query `MOZILLA_FIVE_HOME` which leads to the misleading error. In Eclipse the workarounds (including parsing `gre.conf`) needed 213 lines of code. Furthermore, most of the 9006 code snippets we found on GitHub referring to the variable are small wrappers trying to set `MOZILLA_FIVE_HOME` correctly. **Discussion:** While the package managers easily answer where the missing files are located, within the application there is no reasonable way to find out. We found similar issues concerning network, firewall, hardware settings, etc. **Implication:** Applications have a need to access global configuration settings. ## 5 Experience Report on Supporting Global Validation *Elektra* is a library that aims at providing unified access to configuration settings as key/value pairs. It integrates a specification language for global validation. Here we will discuss how Elektra fulfills the requirements unearthed by the study before describing the challenges to adoption that Elektra faced in the past. ### 5.1 Unify Configuration We summarize requirements for configuration tools derived from the findings of Section 3. **Requirement 1** *a.* Developers use different mechanisms for configuration accesses interchangeably or to bypass limitations of others. To avoid the need for bypasses, Elektra bootstraps itself at startup, making it possible for configuration settings to describe the configuration access, e.g., which configuration files should be used. To allow administrators to use all popular techniques, Elektra reads from different sources such as configuration files, system settings, and environment variables. Elektra integrates many different configuration file formats such as INI, XML, etc., and it supports notifications to always keep application's configuration settings in sync with the persistent configuration settings. **Requirement 1** *b.* *FLOSS* developers demand a way to share configuration settings. We implemented a layer similar to a virtual file system, which enables applications and system administrators to mount configuration files [29]. This technique enables applications to access configuration settings of any other application. Using links and transformations [22] one can even configure applications to use other other settings without any support from the application itself. **Requirement 1** *c.* There should be a way to document configuration settings. Elektra introduces specifications for configuration settings [24]. These specifications should also include documentation. But even if they do not, users at least know which configuration settings exist, and which values are valid for them. ### 5.2 Validate Configuration **Requirement 2** *a.* Dependencies exclusively needed for configuration settings should be avoided. Elektra introduces plugins that enable a system-level depen- Dexterity injection. Developers specify validations in specifications, without the need for their application to depend on additional external libraries. In plugins executed on configuration access, the settings get validated or default settings get calculated. Elektra only uses the C standard library and no other external dependencies [20]. Nevertheless, even the dependency on Elektra itself can be avoided. Elektra supports intercepting of library calls such as `getenv` [26,27]. Using this technique, applications think they use environment variables, while in reality they query Elektra. **Requirement 2:** Configuration settings and validations should be open to introspection. Similarly to `getenv`, Elektra provides an API, but it aims to overcome the limitations of previous abstractions and interfaces. Elektra allows many configuration files to be integrated with a uniform key/value API. Even the specifications of accesses, dependencies, and validations are accessible via the same API. Thus system administrators and applications can use the API to introspect configuration settings. Applications need the permission to open the configuration files. **Requirement 2:** Global validation should be supported. Elektra supports global validation through a range of different checker plugins. These plugins do not only check data for consistency but also check if configuration settings conflict with reality. For example, one plugin checks for presence of files or directories, while another plugin checks if a host name can be resolved. Checks are executed whenever Elektra's API is used for writing. This way also all administrator tools sitting on top of Elektra reject invalid configuration settings. Elektra also allows to integrate system information such as hardware settings via plugins. ### 5.3 Community Building The Elektra Initiative is a community that started with the straightforward idea to have a single API for configuration access. Other projects watched how it progressed, but adoptions occurred rarely. Due to various grave issues in the first versions, the API needed several redesigns. Obviously, API changes are not very popular and Elektra lost most of its users at this time. Despite many marketing efforts to change the situation, it was predominantly companies and not FLOSS software that used Elektra. This slow adoption was unfortunate but an opportunity to continue making changes. Unfortunately, the changes were not done wisely, instead we introduced mostly unnecessary features. Here the Elektra Initiative had its low and turning-point. Then the goals shifted towards a more technical solution: We avoid marketing campaigns to persuade everyone to use the API with arguments like “it will give benefits once everyone migrates” but instead it should offer immediate advantages previous APIs did not have. This meant Elektra went into a highly competitive market facing the difficulty of being better than any other configuration library. As a distinctive feature, we started to aim for global validation but without giving up compatibility to current configuration files. These changes made the core more complicated, which led to a recruiting problem. The documentation was for a long time only a master thesis [20], which was a very unsatisfactory situation. The next efforts were to make the project community-friendly again. We started to improve quality by regression tests, fixing reports of code analysis tools, and adding code comments and assertions. Then we started overhauling documentation, writing tutorials, and created a website. Last but not least, we started releasing every two months with fixes and new features in every release. These changes led to more than a dozen contributors, Elektra being packaged for many distributions, and acceptance of a paper on Elektra in “The Journal of Open Source Software” [23]. 6 Community Feedback and Future Work The survey validated Elektra’s goals: Many agreed (80%, n = 153) that a solution must be lightweight and efficient; and that a configuration library must be available anywhere and anytime (84%, n = 153). Many persons (70%, n = 150) consider it important that the community is supportive. Even more persons want bugs to be fixed promptly (88%, n = 150). Because 76% persons find it important that applications directly ship documentation (n = 157), external specifications should have documentation. Nearly everyone (96%, n = 173) agrees that configuration integration, such as global validation, would at least moderately improve user experience. Thus we will continue research in this area. A participant said: “Must be extensible/adaptable. If it is, users can take care of many of the above aspects themselves”. We agree and continue to pioneer modularity. For example, many persons found readability of configurations important (65%, n = 152) but could not agree which formats are readable. Another person wrote: “It must offer a compelling reason to switch from e.g gsettings. For example a killer feature that others don’t have, etc. Otherwise, the status quo wins.” Elektra’s “killer feature” can be global validation. From our experience with Elektra, it was also clear that we need to put much more effort into API stability. Thus we avoid breaking changes to the API. We are about to provide easy-to-use high-level APIs for different use cases. The 1.0 release of Elektra is still pending: (1) The specification language for validation/transformation/dependency injection is not completely defined. (2) The configuration parsers have limitations, e.g., they do not always preserve comments or order. (3) Elektra puts some unnecessary limitations on the plugins. 7 Related Work Many other configuration libraries have validation capabilities, for example, Apache Commons Configuration. Unlike Elektra they do not have external specifications. Instead they require developers to hardcode them into the applications. Other papers describe the technical details of Elektra [29,20,23]. In particular frontend code generation avoids errors in configuration access [28,21]. Other work describes Elektra’s specification language [22,24] and how applications participate without code modifications [25,26]. Crowston et al. [6] created a survey of empirical research for FLOSS. Michlmayr et al. [16] investigated quality issues of FLOSS using interviews. We were able to confirm that documentation often is lacking. Barcomb et al. [2] used a questionnaire to investigate how developers acquire FLOSS skills. PCheck [34] validates configuration files early. Unlike Elektra, it is not free software and does not support application-specific checks or plugins. Some work was done to automatically resolve misconfiguration [33,30,1,38]. These approaches aim at solving already manifested issues, Elektra aims at resolving them earlier. Xu et al. [36] surveyed further possibilities. Nosál et al. [17,18] investigated similar abstractions but with a focus on language mapping. Denisov [8] collected requirements for configuration libraries. Berger et al. [5] and Villela et al. [32] created a questionnaire that asks about variability modeling. Our survey focused on a different target group. 8 Conclusions In this paper we examined challenges in configuration access and presented a solution. We addressed the research question: Why do we lack tools for global validation and how can we help developers provide them? The answer is that validations are encoded in the software in a way (1) unusable by external tools, and (2) incapable of using global knowledge of the system. The answer is backed up by both a questionnaire and a source analysis. To overcome developers’ configuration issues, we need to externalize configuration access specifications and use a unified configuration library. The empirical data backs up that this is possible and wanted. It is possible, because currently different configuration accesses are used interchangeably. It is wanted, because users stated that different forms of configuration access sources should be able to override each other. Based on our survey we might have to rethink how to reduce the number of configuration settings because many developers do not agree with complete removal of less-used settings. The survey also showed that external dependencies in configuration access code are a contradictory topic: Developers want good defaults, but do not want to pay for them with dependencies. Elektra’s way of implementing dependency injection and globally calculating default settings fulfills both goals. Because of the externalization of configuration access specifications, users can even introspect the (default) settings that applications receive. Finally, we described FLOSS community efforts to improve on the issues. The results show that a dependency injection at the system level is feasible and practical. It has the potential to be accepted by developers if they perceive global integration and validation as “killer feature”. The current status of the FLOSS project can be tracked at https://www.libelektra.org. Acknowledgements: We thank the anonymous reviewers, Tianyin Xu, Franz Puntigam, Stefan Winter, Milan Nosál, and Harald Geyer for detailed reviews of this paper. Additionally, many thanks to all the people contributing to Elektra. References
{"Source-Url": "https://inria.hal.science/hal-01658595/file/oss.pdf", "len_cl100k_base": 7324, "olmocr-version": "0.1.53", "pdf-total-pages": 14, "total-fallback-pages": 0, "total-input-tokens": 38939, "total-output-tokens": 10486, "length": "2e12", "weborganizer": {"__label__adult": 0.00023424625396728516, "__label__art_design": 0.00024437904357910156, "__label__crime_law": 0.0002027750015258789, "__label__education_jobs": 0.00069427490234375, "__label__entertainment": 4.941225051879883e-05, "__label__fashion_beauty": 8.64863395690918e-05, "__label__finance_business": 0.00019550323486328125, "__label__food_dining": 0.00018906593322753904, "__label__games": 0.00031065940856933594, "__label__hardware": 0.0003552436828613281, "__label__health": 0.0002205371856689453, "__label__history": 0.00014603137969970703, "__label__home_hobbies": 4.947185516357422e-05, "__label__industrial": 0.00013744831085205078, "__label__literature": 0.00017571449279785156, "__label__politics": 0.0001628398895263672, "__label__religion": 0.00021183490753173828, "__label__science_tech": 0.005619049072265625, "__label__social_life": 9.179115295410156e-05, "__label__software": 0.01322174072265625, "__label__software_dev": 0.97705078125, "__label__sports_fitness": 0.00012803077697753906, "__label__transportation": 0.0002123117446899414, "__label__travel": 0.00012981891632080078}, "weborganizer_max": "__label__software_dev", "avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_ratio": [[0, 40252, 0.04837]], "fineweb_edu_fasttext_gt2__fineweb_edu_fasttext_gt2__score": [[0, 40252, 0.18778]], "ft_lang_id_en_doc_v2__ft_lang_id_en_doc_v2__en": [[0, 40252, 0.83527]], "google_gemma-3-12b-it_contains_pii": [[0, 952, false], [952, 3848, null], [3848, 6683, null], [6683, 9832, null], [9832, 12917, null], [12917, 15856, null], [15856, 19861, null], [19861, 22884, null], [22884, 26161, null], [26161, 29124, null], [29124, 32225, null], [32225, 35708, null], [35708, 39002, null], [39002, 40252, null]], "google_gemma-3-12b-it_is_public_document": [[0, 952, true], [952, 3848, null], [3848, 6683, null], [6683, 9832, null], [9832, 12917, null], [12917, 15856, null], [15856, 19861, null], [19861, 22884, null], [22884, 26161, null], [26161, 29124, null], [29124, 32225, null], [32225, 35708, null], [35708, 39002, null], [39002, 40252, null]], "google_gemma-3-4b-it_v2tag__is_academic_paper": [[0, 5000, true], [5000, 40252, null]], "google_gemma-3-4b-it_v2tag__is_class_syllabus": [[0, 5000, false], [5000, 40252, null]], "google_gemma-3-4b-it_v2tag__is_completion_certificate": [[0, 5000, false], [5000, 40252, null]], "google_gemma-3-4b-it_v2tag__is_court_notice": [[0, 5000, false], [5000, 40252, null]], "google_gemma-3-4b-it_v2tag__is_homework_assignment": [[0, 5000, false], [5000, 40252, null]], "google_gemma-3-4b-it_v2tag__is_news_article": [[0, 5000, false], [5000, 40252, null]], "google_gemma-3-4b-it_v2tag__is_public_order": [[0, 5000, false], [5000, 40252, null]], "google_gemma-3-4b-it_v2tag__is_resume_cv": [[0, 5000, false], [5000, 40252, null]], "google_gemma-3-4b-it_v2tag__is_test_or_quiz": [[0, 5000, false], [5000, 40252, null]], "google_gemma-3-4b-it_v2tag__is_textbook": [[0, 5000, false], [5000, 40252, null]], "pdf_page_numbers": [[0, 952, 1], [952, 3848, 2], [3848, 6683, 3], [6683, 9832, 4], [9832, 12917, 5], [12917, 15856, 6], [15856, 19861, 7], [19861, 22884, 8], [22884, 26161, 9], [26161, 29124, 10], [29124, 32225, 11], [32225, 35708, 12], [35708, 39002, 13], [39002, 40252, 14]], "pipe_delimited_lines_v1__pipe_delimited_lines_v1__pipe_delimited_lines_ratio": [[0, 40252, 0.10638]]}
olmocr_science_pdfs
2024-12-06
2024-12-06
8b7a345728f694c07d2bdb135c4b8fd2923b276f
Welcome to **DesignCon® 2022** WHERE THE CHIP MEETS THE BOARD **Conference** April 5 – 7, 2022 **Expo** April 6 – 7, 2022 Santa Clara Convention Center Open Standard Acceleration APIs for Safety-Critical Graphics, Vision and Compute Neil Trevett, Khronos President Neil Trevett Khronos President, NVIDIA VP Developer Ecosystems ntrevett@nvidia.com | www.khronos.org | @neilt3d Neil is the elected President of the Khronos Group, where he oversees the development of open standards for graphics and heterogeneous parallel computation, including for safety critical markets. By day, Neil is VP Developer Ecosystems at NVIDIA, where he works to enable applications to take advantage of GPUs. Topics Introduction to Khronos and open standard APIs for graphics and compute acceleration Khronos safety-critical APIs including Vulkan SC and the new SYCL SC Exploratory Forum The new Khronos AUTOSAR Liaison The new Khronos EMVA Camera Working Group Details on how to get involved! Need for Embedded Computing Standards Increasing Sensor Richness Camera arrays and depth sensors such as Lidar fed into sophisticated processing including inferencing Multiple Sensors Per System Synchronization, coordination and processing of diverse sensor streams becomes essential Cost and time to integrate and utilize sensors, GPUs and processors in embedded markets has become a major constraint on innovation and efficiency Increasing Sensor Processing Demands Sensor outputs need to be flexibly and efficiently generated and streamed into diverse acceleration processors Proprietary APIs Hinder Innovation Vendor-specific APIs to control cameras, sensors, close-to-sensor ISPs and processors prevent rapid integration of new technologies Khronos Connects Software to Silicon Open, royalty-free interoperability standards to harness the power of GPU, XR and multiprocessor hardware 3D graphics, augmented and virtual reality, parallel programming, inferencing and vision acceleration Non-profit, member-driven standards organization, open to any company Proven multi-company governance and Intellectual Property Framework Founded in 2000 ~ 200 Members | ~ 40% US, 30% Europe, 30% Asia Khronos Active Standards 3D Graphics Desktop, Mobile and Web 3D Assets Authoring and Delivery Portable XR Augmented and Virtual Reality Parallel Computation Vision, Inferencing, Machine Learning Safety Critical APIs [Logos of various standards and APIs] Khronos Compute Acceleration Standards Increasing industry interest in parallel compute acceleration to combat the ‘End of Moore’s Law’ SYCL and SPIR were originally OpenCL sub projects Higher-level Languages and APIs - Streamlined development and performance portability - Single source C++ programming with compute acceleration - Graph-based vision and inferencing acceleration Vulkan - GPU rendering + compute acceleration OpenVX - Intermediated Representation (IR) supporting parallel execution and graphics OpenCL - Heterogeneous compute acceleration Lower-level Languages and APIs - Direct Hardware Control GPU - Intermediate Representation (IR) supporting parallel execution and graphics CPU - OpenVX - OpenCL FPGA - Vulkan DSP - Intermediate Representation AI/Tensor HW - Intermediate Representation Custom Hardware Vulkan: Performance, Predictability, Portability Vulkan is the only open standard modern GPU API Not controlled by and tied to a specific platform Complex drivers cause overhead and inconsistent behavior across vendors Always active error handling Full GLSL preprocessor and compiler in driver OpenGL vs. OpenGL ES differences Simpler drivers - application has the best knowledge for holistic optimization - no 'driver magic' Explicit creation of API objects before usage - efficient, predictable execution Easier portability - no fighting with different vendor heuristics Validation and debug layers loaded only when needed SPIR-V intermediate language: shading language flexibility Unified API across mobile and desktop platforms Multiple graphics, command and DMA queues A Graphics API Application Single thread per context High-level Driver Abstraction Layered GPU Control Context management Memory allocation Full GLSL compiler Error detection Multiple Front-end Compilers GLSL, HLSL etc. Thin Driver Explicit GPU Control GPU Application Memory allocation Thread management Explicit Synchronization Multi-threaded generation of command buffers Loadable debug and validation layers Multiple graphics, command and DMA queues A GPU API SPIR-V enables a rich ecosystem of languages and compilers to target low-level APIs such as Vulkan and OpenCL, including deployment flexibility: e.g., running OpenCL kernels on Vulkan. OpenCL – Low-level Parallel Programming Programming and Runtime Framework for Application Acceleration Offload compute-intensive kernels onto parallel heterogeneous processors CPUs, GPUs, DSPs, FPGAs, Tensor Processors OpenCL C or C++ kernel languages Platform Layer API Query, select and initialize compute devices Runtime API Build and execute kernels programs on multiple devices Explicit Application Control Which programs execute on what device Where data is stored in memories in the system When programs are run, and what operations are dependent on earlier operations Complements GPU-only APIs Simpler programming model Relatively lightweight run-time More language flexibility, e.g., pointers Rigorously defined numeric precision OpenCL 3.0 Processor Adoption Product Conformance Status https://www.khronos.org/conformance/adopters/conformant-products/opencl OpenCL 3.0 Adopters - arm - Google - Intel - NVIDIA - Qualcomm - Codeplay - Imagination - Microsoft - QNX - VeriSilicon OpenCL 3.0 Adopters Shipping Conformant Implementations ## ML Compiler Steps <table> <thead> <tr> <th>Import Formats</th> <th>Front-end / IR</th> <th>Output</th> </tr> </thead> <tbody> <tr> <td>Caffe, Keras, MXNet, ONNX</td> <td>NNVM / Relay IR</td> <td>OpenCL, LLVM, CUDA, Metal</td> </tr> <tr> <td>TensorFlow Graph, MXNet, PaddlePaddle, Keras, ONNX</td> <td>nGraph / Stripe IR</td> <td>OpenCL, LLVM, CUDA</td> </tr> <tr> <td>PyTorch, ONNX</td> <td>Glow Core / Glow IR</td> <td>OpenCL LLVM</td> </tr> <tr> <td>TensorFlow Graph, PyTorch, ONNX</td> <td></td> <td>LLVM, TPU IR, XLA IR</td> </tr> </tbody> </table> ### Consistent Steps 1. **Import Trained Network Description** 2. **Graph-level optimizations** e.g., node fusion, node lowering and memory tiling 3. **Decompose to primitive instructions and emit programs for accelerated run-times** ### Fast progress but still area of intense research If compiler optimizations are effective - hardware accelerator APIs can stay ‘simple’ and won’t need complex metacommands (e.g., combined primitive commands like DirectML) ### Embedded NN Compilers - CEVA Deep Neural Network (CDNN) - Cadence Xtensa Neural Network Compiler (XNNC) SYCL Single Source C++ Parallel Programming - **C++ Libraries** - Standard C++ Application Code - ML Frameworks - SYCL Compiler - CPU Compiler - Other Backends - SYCL Accelerates C++-based engines and applications with performance portability - SYCL 2020 Launch February 2021 - Closer alignment with C++17 - Smaller code size, faster performance - New Features: - Unified Shared Memory - Parallel Reductions - Subgroup Operations - Class template Argument Deduction - **C++ Template Libraries** - CPU - GPU - FPGA - DSP - AI/Tensor HW - Custom Hardware - **GPU** - One-MKL - One-DNN - OneDPC - SYCL-BLAS - SYCL-Eigen - SYCL-DNN - SYCL Parallel STL - **FPGA** - **DSP** - **Custom Hardware** - **CPU** - **OpenCL** - Complex ML frameworks can be directly compiled and accelerated - C++ templates and lambda functions separate host & accelerated device code - **C++ Kernel Fusion** - Can give better performance on complex apps and libs than hand-coding - **Accelerated code passed into device OpenCL compilers** SYCL Implementations in Development SYCL, OpenCL and SPIR-V, as open industry standards, enable flexible integration and deployment of multiple acceleration technologies. SYCL enables Khronos to influence ISO C++ to (eventually) support heterogeneous compute. Multiple Backends in Development SYCL beginning to be supported on multiple low-level APIs in addition to OpenCL e.g., ROCm and CUDA For more information: http://sycl.tech The Origin of OpenVX Engines and Applications 3D Graphics API Driver Vulkan GPU Driver Model An open API standard enables multiple silicon vendors to ship drivers with their silicon. Silicon vendors can aggressively optimize drivers for their own silicon architecture. OpenVX is the industry’s only API standard enabling portable access to vendor-optimized vision drivers. OpenVX Vision API Driver High-level Abstraction 3D graphics is always accelerated by a GPU, so a low-level GPU API can provide cross-vendor portability. BUT Vision processing is accelerated by a wide variety of hardware architectures. SO OpenVX needs a higher-level graph abstraction to enable optimized cross-vendor drivers. Vision Processing Graph Vision Node Vision Node Vision Node Vision Node Vision Node Vision Node OpenVX Cross-Vendor Vision and Inferencing High-level graph-based abstraction for portable, efficient vision processing - Optimized OpenVX drivers created, optimized and shipped by processor vendors - Implementable on almost any hardware or processor with performance portability - Graph can contain vision processing and NN nodes for global optimization - Run-time graph execution need very little host CPU interaction OpenVX Graph Vision Node CNN Nodes Vision Node Downstream Application Processing Native Camera Control Open-Source Convertors ONNX TensorFlow TensorFlow Lite Caffe Caffe2 NNEF Import converts a trained Neural Network into OpenVX Graph Layers are represented as OpenVX nodes Vendors optimize and ship drivers for their platform Full list of conformant OpenVX implementations here: https://www.khronos.org/conformance/adopters/conformant-products/openvx https://github.com/KhronosGroup/NNEF-Tools Embedded Vision and Inferencing Networks trained on high-end desktop and cloud systems Applications link to compiled inferencing code or call vision/inferencing API Diverse Embedded Hardware - Multi-core CPUs, GPUs - DSPs, FPGAs, Tensor Cores * Vulkan only runs on GPUs Open industry standards, enable flexible integration and deployment of multiple acceleration technologies Sensor Data Neural Network Training - Training Data Trained Networks - Compilation - Ingestion Compiled Code - Vision / Inferencing Engine - C++ Application Code Hardware Acceleration APIs - OpenCL - Vulkan * Vulkan only runs on GPUs Applications link to compiled inferencing code or call vision/inferencing API Networks trained on high-end desktop and cloud systems Diverse Embedded Hardware - Multi-core CPUs, GPUs - DSPs, FPGAs, Tensor Cores * Vulkan only runs on GPUs Open industry standards, enable flexible integration and deployment of multiple acceleration technologies Growing Need for APIs for Functional Safety Demand for advanced GPU-accelerated graphics and compute is growing in an increasing number of industries where safety is paramount, such as automotive, autonomy, avionics, medical, industrial, and energy. In safety-critical systems a compute or display system failure would pose a significant safety risk. Functional Safety Certification Safety Certification Performed at the system level Development Process defined in safety-critical standards 1) Document system design, safety requirements, software architecture and software design 2) Test and verify at each level against design documentation 3) Provide certification evidence packages to demonstrate documentation and testing Reducing certification effort and costs System runtime components should: 1) Be streamlined as far as possible to reduce documentation and testing surface area 2) Have deterministic behavior to simplify design and testing 3) Implement robust and unambiguous fault handling In the ISO 26262 V-Model system development process testing and verification occur in reverse order from design and implementation Industry safety-critical standards include - RTCA DO-178C Level A / EASA ED-12C Level A (avionics) - ISO 26262 ASIL D (automotive) - IEC 61508 (industrial) - IEC 62304 (medical) Safety Certification and Open Standard APIs Need for APIs to streamline system-level safety-critical certifications - Streamlined - Deterministic - Robust Growing need for embedded hardware acceleration - Advanced processing of multiple advanced sensors - Smart systems through machine learning and inferencing - Advanced displays and user interfaces Growing need for well-defined hardware software interoperability in safety critical industry - Decoupling software and hardware for easier development and integration of new components - Cross-generation reusability - Cross-platform reusability - Field upgradability Growing demand for state-of-the-art open, cross-vendor, acceleration API standards that are designed by and for the safety-critical industry K H R O N O S G R O U P Khronos Safety Critical GPU API Evolution Khronos has close to 20 years experience in adapting mainstream APIs for safety-critical markets. Leveraging proven mainstream APIs with shipping silicon implementations and developer tooling and familiarity. Vulkan SC targets any systems requiring safety critical graphics and/or compute. E.g., automotive, autonomy, avionics, medical, industrial, and energy. Vulkan SC has significantly higher performance and flexibility than OpenGL SC. Enabling new safety-critical markets requiring graphics and compute AND cross-platform standalone compute. OpenGL SC will continue to be supported by Khronos, but new developments will focus on Vulkan SC. Vulkan SC 1.0 Design Philosophy Vulkan 1.2 is a compelling starting point - Widely adopted, royalty-free open standard - Explicit control of device scheduling, synchronization and resource management - Smaller surface area than OpenGL - Not burdened by runtime debug functionality - Very little internal state - Well-defined thread behavior - Ingests SPIR-V IR - no runtime front-end compiler Vulkan SC enables system implementers deploying GPU-accelerated graphics and compute to meet safety-critical obligations and provide certification evidence packages with reduced cost and effort Vulkan SC can also be invaluable for real-time embedded applications, even if not formally safety-certified Streamlined - Remove non-essential runtime functionality - Sparse memory - Descriptor update templates - Certain types of object deleter Deterministic - Predictable execution times and results - Offline compilation of pipelines - Static memory allocation Robust - Removing Ambiguity - No ignored parameters or undefined behaviors - Enhanced fault handling and reporting functionality - Rigorous conformance test suite - MISRA C alignment Vulkan SC Robustness Fault Handling and Reporting Application registers functions at device creation which the driver can call if a fault is detected Application can interrogate type and level of a fault together with implementation-specific data Vulkan SC Conformance Test Suite Freely available to all under Apache 2.0 open-source license Leverages extensive Vulkan test suite with added SC-specific tests System integrators can use to confirm and document Vulkan SC implementation compatibility MISRA C Vulkan SC 1.0 is aligned with MISRA C software development guidelines Developed by the MISRA Consortium for embedded system code safety, security, portability and reliability and alignment with safety-critical standards Vulkan SC Offline Compiled Pipelines A Vulkan Pipeline defines how the GPU processes data SPIR-V JSON Pipeline Description Lists all SPIR-V modules used with related state Implementation-Specific Pipeline Cache Compiler (PCC) Pipeline Cache Utility Extracts information from pipeline cache files to analyze dataflow and the amount of memory used by the processing in the pipeline Pipeline Cache Containers Application Memory for pipelines is reserved at device at device creation time as fixed size pools. Similarly sized pipelines can be assigned to the same pool to minimize memory size and fragmentation. Avoids need for runtime memory allocation Offline Runtime DESIGNCON 2022 WHERE THE CHIP MEETS THE BOARD APRIL 5 – 7, 2022 #DesignCon OpenVX SC Profile Minimizes Run-time Surface Area and Implementation Size - Eases system-level safety certification - Separated Development and Deployment environments Robust Specification - Annotated specification with Functional Requirement tag numbers - MISRA-C compliant headers The OpenVX SC profile combined with ingestion of trained Neural Networks enables OpenVX as a cross-platform inferencing engine for safety critical markets. SYCL Safety-Critical Exploratory Forum Exploring real-world industry requirements for open and royalty-free high-level compute APIs suitable for safety-critical markets Khronos SYCL Safety-Critical Exploratory Forum Online discussion forum and weekly Zoom calls No detailed design activity to protect participants IP Any company is welcome to join No cost or IP Licensing obligations Project NDA to cover Exploratory Forum Discussions Proven Khronos Exploratory Process to ensure industry requirements are fully understood before starting standardization initiatives No detailed design activity to protect participants IP Explore if consensus can be built around an agreed Scope of Work document Discuss what standardization activities can best execute actions in the Scope of Work Agreed SOW document released from NDA and made public Initiation of Khronos Working Group to execute the SOW More information and signup instructions https://www.khronos.org/syclsc AUTOSAR Khronos Liaison 1. Provide Khronos members with information on AUTOSAR activities 2. Enable Khronos members to inform and influence AUTOSAR initiatives 3. Bring AUTOSAR requirements and use cases to Khronos working groups 4. Encourage normative use of Khronos standards by AUTOSAR AUTOSAR Khronos Liaison Structure WG-SAF: Khronos raises agenda topics relevant to Safety, e.g., Rust Example activities Any existing Working group or Concept New AUTOSAR concept for safe GPU Architecture, driven by Khronos AUTOSAR Council with access to AUTOSAR Information Khronos Technical Liaisons Example working groups Khronos EMVA Camera Working Group Open, cross-vendor standard for camera, sensor and ISP control has multiple benefits Cross-vendor portability of camera/sensor code for easier system integration of new sensors Preservation of application code across multiple generations of cameras and sensors Sophisticated control over sensor stream generation for effective downstream accelerated processing Application controlling sensor stream generation and processing in real time Khronos Camera Working Group announced in February 2022 EMVA and Khronos cooperated since 2020 to understand need for a new API for standard camera and image capture control Over 70 companies met at the Khronos EMVA Camera Exploratory Group through 2021 to create consensus on a Scope of Work document Working Group is open to all Khronos members and meeting weekly to execute the Scope of Work Typical Software Stack using Camera API Frameworks & Middleware: - GStreamer - OpenVX Application Camera System API Transport: - CSI-2 - USB - Ethernet Physical Devices: - Sensors - Lenses - Lights - Processors API in scope Some libraries may be in scope Named transport layers, frameworks and operating systems are illustrative examples. Camera API Terminology Physical Devices = queryable and controllable via a Device ID: Logical Device = set of Devices queried and controlled via a single Device ID Frame = Image + Metadata accessed via Frame ID Stream = sequence of Frames Camera = a Logical Device that exports one or more Streams from the Camera System Camera API Working Group Organization Khronos Any company can join with Membership Fee Membership Agreement grants access to ALL Working Groups AND Advisory Panels Under Khronos NDA and IP Framework EMVA All EMVA members have a standing invitation to join Camera Advisory Panel at no charge Drafts Camera System API Working Group Design decisions and execution responsibility Feedback Camera System API Advisory Panel Design suggestions and draft feedback Other Khronos Working Groups and Advisory Panels Advisory Panel Membership by invitation with no Membership Fee Advisory Panel Agreement grants access to ONLY Camera Advisory Panel Under Khronos NDA and IP Framework More information https://www.khronos.org/camera Get Involved! Any company is welcome to join Khronos to influence standards development https://www.khronos.org/members/ or email memberservices@khronosgroup.org More information on Vulkan SC, OpenVX and OpenCL All Khronos members can participate in the new Camera Working Group https://www.khronos.org/camera Get involved in the new SYCL SC Exploratory Forum at zero cost https://www.khronos.org/syclsc Khronos is developing a growing family of open, royalty-free API standards relevant to embedded and safety-critical markets Thank you! QUESTIONS?
{"Source-Url": "https://www.khronos.org/assets/uploads/developers/presentations/Drive-World_Open-Standard-Acceleration-APIs_Apr22.pdf", "len_cl100k_base": 4653, "olmocr-version": "0.1.50", "pdf-total-pages": 35, "total-fallback-pages": 0, "total-input-tokens": 44580, "total-output-tokens": 6052, "length": "2e12", "weborganizer": {"__label__adult": 0.0008449554443359375, "__label__art_design": 0.0021114349365234375, "__label__crime_law": 0.0007791519165039062, "__label__education_jobs": 0.0008606910705566406, "__label__entertainment": 0.0002300739288330078, "__label__fashion_beauty": 0.0004780292510986328, "__label__finance_business": 0.0007205009460449219, "__label__food_dining": 0.0005230903625488281, "__label__games": 0.0017795562744140625, "__label__hardware": 0.054412841796875, "__label__health": 0.0007486343383789062, "__label__history": 0.0005488395690917969, "__label__home_hobbies": 0.00021731853485107425, "__label__industrial": 0.0035457611083984375, "__label__literature": 0.0002465248107910156, "__label__politics": 0.0004665851593017578, "__label__religion": 0.0009775161743164062, "__label__science_tech": 0.433837890625, "__label__social_life": 0.00010061264038085938, "__label__software": 0.0157012939453125, "__label__software_dev": 0.478271484375, "__label__sports_fitness": 0.0007195472717285156, "__label__transportation": 0.0016689300537109375, "__label__travel": 0.0003077983856201172}, "weborganizer_max": "__label__software_dev", "avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_ratio": [[0, 21588, 0.00926]], "fineweb_edu_fasttext_gt2__fineweb_edu_fasttext_gt2__score": [[0, 21588, 0.09839]], "ft_lang_id_en_doc_v2__ft_lang_id_en_doc_v2__en": [[0, 21588, 0.80629]], "google_gemma-3-12b-it_contains_pii": [[0, 156, false], [156, 270, null], [270, 696, null], [696, 982, null], [982, 1733, null], [1733, 2185, null], [2185, 2445, null], [2445, 3282, null], [3282, 4534, null], [4534, 4719, null], [4719, 5463, null], [5463, 5772, null], [5772, 6950, null], [6950, 8039, null], [8039, 8474, null], [8474, 9285, null], [9285, 10213, null], [10213, 11185, null], [11185, 11538, null], [11538, 12501, null], [12501, 13289, null], [13289, 13980, null], [13980, 15136, null], [15136, 15865, null], [15865, 16621, null], [16621, 17063, null], [17063, 18037, null], [18037, 18327, null], [18327, 18659, null], [18659, 19535, null], [19535, 19882, null], [19882, 20204, null], [20204, 20931, null], [20931, 21566, null], [21566, 21588, null]], "google_gemma-3-12b-it_is_public_document": [[0, 156, true], [156, 270, null], [270, 696, null], [696, 982, null], [982, 1733, null], [1733, 2185, null], [2185, 2445, null], [2445, 3282, null], [3282, 4534, null], [4534, 4719, null], [4719, 5463, null], [5463, 5772, null], [5772, 6950, null], [6950, 8039, null], [8039, 8474, null], [8474, 9285, null], [9285, 10213, null], [10213, 11185, null], [11185, 11538, null], [11538, 12501, null], [12501, 13289, null], [13289, 13980, null], [13980, 15136, null], [15136, 15865, null], [15865, 16621, null], [16621, 17063, null], [17063, 18037, null], [18037, 18327, null], [18327, 18659, null], [18659, 19535, null], [19535, 19882, null], [19882, 20204, null], [20204, 20931, null], [20931, 21566, null], [21566, 21588, null]], "google_gemma-3-4b-it_v2tag__is_academic_paper": [[0, 5000, false], [5000, 21588, null]], "google_gemma-3-4b-it_v2tag__is_class_syllabus": [[0, 5000, false], [5000, 21588, null]], "google_gemma-3-4b-it_v2tag__is_completion_certificate": [[0, 5000, false], [5000, 21588, null]], "google_gemma-3-4b-it_v2tag__is_court_notice": [[0, 5000, false], [5000, 21588, null]], "google_gemma-3-4b-it_v2tag__is_homework_assignment": [[0, 5000, false], [5000, 21588, null]], "google_gemma-3-4b-it_v2tag__is_news_article": [[0, 5000, false], [5000, 21588, null]], "google_gemma-3-4b-it_v2tag__is_public_order": [[0, 5000, false], [5000, 21588, null]], "google_gemma-3-4b-it_v2tag__is_resume_cv": [[0, 5000, false], [5000, 21588, null]], "google_gemma-3-4b-it_v2tag__is_test_or_quiz": [[0, 5000, false], [5000, 21588, null]], "google_gemma-3-4b-it_v2tag__is_textbook": [[0, 5000, false], [5000, 21588, null]], "pdf_page_numbers": [[0, 156, 1], [156, 270, 2], [270, 696, 3], [696, 982, 4], [982, 1733, 5], [1733, 2185, 6], [2185, 2445, 7], [2445, 3282, 8], [3282, 4534, 9], [4534, 4719, 10], [4719, 5463, 11], [5463, 5772, 12], [5772, 6950, 13], [6950, 8039, 14], [8039, 8474, 15], [8474, 9285, 16], [9285, 10213, 17], [10213, 11185, 18], [11185, 11538, 19], [11538, 12501, 20], [12501, 13289, 21], [13289, 13980, 22], [13980, 15136, 23], [15136, 15865, 24], [15865, 16621, 25], [16621, 17063, 26], [17063, 18037, 27], [18037, 18327, 28], [18327, 18659, 29], [18659, 19535, 30], [19535, 19882, 31], [19882, 20204, 32], [20204, 20931, 33], [20931, 21566, 34], [21566, 21588, 35]], "pipe_delimited_lines_v1__pipe_delimited_lines_v1__pipe_delimited_lines_ratio": [[0, 21588, 0.01237]]}
olmocr_science_pdfs
2024-12-01
2024-12-01
c5406588cada2f985bd87f388a7e65d88582ecca
Remote Poll-Site Voting Submission for Phase II by Parth P. Vasa Soo-Yung Cho Jeremy Mullendore Bodhisattva Debnath Contents 1. Introduction 2. A use case scenario 3. Details of Components a. Authentication component: i. Impermanent network connections ii. Successful Authentication iii. The Central ID Server Pool iv. Why have each server spread the message? Why not keep a broadcast address? b. Vote Selection component c. Vote Casting component i. Interaction with the Selection Components ii. Why not include this functionality in the selection machine? iii. Why do we need to encrypt the data while storing on the Casting machine? iv. Why do we need to Split the vote before sending it? We can do that on server too?! d. Recording component i. Why encrypt again? Why not store directly? They are encrypted anyways e. Communication Component i. Why Internet? ii. Securing the Internet communications iii. Encryption iv. Authentication v. Packet Filters vi. Other measures 4. Other security and reliability measures. 5. Conclusion: 6. Appendix a. UML Diagrams Our system design is divided into 5 units. 1. Authentication 2. Selection 3. Casting 4. Recording (Tallying) 5. Communication We treat Communication as a different unit since it is involved in almost all the other parts of the system, yet it was not possible to include it as a part of any other component. Moreover, the communication is a very (arguably the most) critical part. ![Diagram of voting process] A use case scenario This describes a very basic (high level) story of a normal voting process. The UML Event diagram in the Appendix shows the whole scenario. - A voter comes in at the voting station. He shows a valid photo ID voter registration card to the polling station official. The official runs his data thru the Authentication unit. This checks if the user exists in the registered voters list in the said county and if the user has voted previously or not. - After voter is authenticated he moves in the polling booth to cast a vote. He is given the ballot of his respective county. User selects the desired candidate using the GUI (Selection Component). - Selection machine sends the vote to the casting machine. Casting machine sends a request for acknowledgement to the user. User is shown the vote he casted and ask to confirm. If he confirms the vote, the casting machine splits the vote (the voter id and the vote). And sends the vote to the tallying server. - Tallying sever checks for the authenticity and integrity of the vote. And stores them for later tallying. Before going into the details of each stage and requirements met with each of them, we list some of the assumptions we have made and some of the unavoidable facts. 1. Registration of voters is still in the usual, paper-based way. 2. A person has to have some kind of photo id to prove his identity. 3. Every polling station is manned by poll-site employees trained in handling the programs used for voting. 4. The machines used at the poll-sites and the servers, are specially hardened machines that are capable of doing only the tasks required for voting process. A few unavoidable facts 1. Problems with requirements of availability come with any use of Internet. We have to live with the threat of DOS/DDOS if we use Internet at any point of time. As we describe later, the other alternatives are not feasible to use. Though we have tried to ameliorate the effects of DOS attacks, we do not have a full-proof solution to the problem. 2. Verifiability requirement can only be met partly. There has to be some amount of trust put in the electoral system and poll site workers by the citizens. Actually, in paper-based voting system there is a large amount of trust put in the system. Details of Components - **Authentication component:** The requirements taken care of in this unit are Eligibility, Authentication and to a part Uniqueness. As shown in the fig 2, the component is divided into 3 parts. Here is how authentication process works. Authentication proxy is the computer operated by the poll site worker. When a user comes in, his data is entered into the system. The output is if the person is registered voter or not and if he has already voted. There are two choices for storing the registration information. 1. All of the information can be stored centrally and all the poll sites can access it online. This is advantageous as all the data would be at the same place and will not have to be duplicated. Drawback of this scheme is that for each voter there has to be a transaction over the Internet of a (comparatively) big amount of data, very often. 2. Information is stored locally. The advantage is quicker and easier access. Drawback is replication of data. We decide on a scheme that tries to meet both the requirements. We store the registration data of that particular county locally. If there is a voter from the other county the authentication proxy contacts the central repository and fetches the data, over the Internet. For confirmation of whether the user has voted or not, the database is maintained centrally and updated after each vote. - Impermanent network connections We here do not assume that the poll site will have a constant connection to the remote server having the database of the voting status of each voter. So the status might not be checked/updated in real time. To ensure the requirement of Uniqueness a person should not be allowed to vote more than once. By having the option of voting at any county a person can vote at different counties at different times, if the voting status is not constantly updated. For countering this threat we have devised a scheme of late updating. If a voter comes in and there is no/infeasible network connections then we the user is authenticated (acting as if he has not voted) and his votes are stored on the casting machine (the section about the casting machine has more information about the storage). When the network connection is reestablished the casting machine checks if the voters associated with the votes stored have already voted. If the central database has the status as not voted then it is turned to voted and the vote is separated form the identity and transferred to the recording component (more about this process is covered in casting and communication parts). If the record on the server indicates that the voter has already voted, it means that there has been a duplicate vote, so the vote on the casting machine is discarded. Depending on the policy such incidences can be reported to the law enforcement agencies. *Please refer to Fig. 1 in the Appendix for an UML activity diagram of this phase.* - Successful Authentication After a successful Authentication, the authentication machine sends a message to the selection machine to display a particular ballot depending on the county the voter belongs in. - The Central ID Server Pool The servers responsible for authenticating voters are called ID servers in this document. These servers form a distributed network. These servers are as spread out as possible. For example, there could be one server per county. These servers form an overlay network, i.e., as far as the ID server system is concerned, the ID servers are the only ones available on the network along with the voting clients. Each ID server maintains a copy of the voter database. This database links voter ID (e.g., SSN) to a flag, which specifies whether the voter has voted or not. This is made possible by a token ring based reliable multicast protocol, which allows all data between the servers to be shared. For example, if county C₁ wants to send a voted message then it looks up which server it is supposed to send to. Say it is supposed to send the message to server S₃. It sends the message there. When S₃ receives the message it shares the vote through the token ring network and all servers are updated of that this voter has voted. Later any county can check any server and find out if that person voted or not. The token ring protocol based multicast protocol is already implemented. It is called spread and it can also let the other servers in the overlay network know if any server died or not. When this server comes back up it syncs with other servers about the voted list. This strategy of sharing data is used in many places to replicate data. This is used to replicate vote caster machine data for backup purposes. It is also used for vote tallying machines to keep backups of votes received. In both these settings it is much more secure since the spread network is not exposed to the Internet and is run on a secure LAN. If a client does not receive a reply within a certain amount of time it contacts the next server and so on. Since all servers have the same data, it does not matter which server a client contacts. We believe that this setup could be more resistant to DOS attacks since all servers have to be brought down for the election to not work. - Why have each server spread the message? Why not keep a broadcast address? Because keeping a broadcast address at the border, could be very much vulnerable to DOS attacks. A person can take every one down by flooding just that address. - Capabilities of Spread Spread uses a token ring protocol to multicast data reliably over UDP multicast. Spread has a notion of groups and any member in the group can transmit data to any member of the group or can choose to broadcast data to everybody in the group. Spread can let the members of the group know when certain members leave or join the group. This facilitates recovery from server crashes. Spread can also broadcast data in a variety of ways such as, unreliable, reliable, reliable agreed order, reliable FIFO order, and reliable total order. - Vote Selection component This is the part where the voter decides the candidate(s) he wants to choose. The unit has to take care of the critical requirement of convenience by providing an easy-to-use User Interface (UI). Which UI to use is a research issue of Human Computer Interaction and Psychology and it will take a good amount of trials before we can reach to a conclusion to provide the ideal UI for people who are using the computer for the first time in their life and that too for taking such important decision. From the currently available technologies, we have decided that using a touch screen kiosk will be the best and the easiest. Voter can tap on the name he wishes to choose. However, the design does not depend on the technology to be used for selection and hence it can be changed as and when required or needed. After the voter selects his vote, the vote travels to the Vote Casting Component. The interaction between the two units is described after the as a part of Vote Casting Component's description. • **Vote Casting component:** This is a very crucial component with a lot of important functionalities. The requirements to be take care of in this units are, Uniqueness, Verifiability, Auditability and to a part, Integrity, Accuracy and Secrecy. The Basic Functionalities of the component are - Receive vote from the selection machine - Request an acknowledgement from the voter - Print the vote (without the identity) for paper based audit trail - If network connection is available then - Split the vote from the User identity - Send the vote securely to the recording server - Send the identity securely to the Voter status server - If there is no network connection available - Encrypt and store the votes. - When connection is available then decrypt the votes and do the procedure said in the previous step, after satisfying the late updation requirements. Each of these steps and the design decisions made are explained by explaining the Unit’s interaction with other unit. - **Interaction with the Selection Components** After the user selects the vote on the selection machine the vote travels to the casting machine. Casting machine now sends an request to the voter to confirm his vote. This can be done via having a different screen on the selection machine. - Why not include this functionality in the selection machine? It would be sparing this convoluted process of getting acks from users. But the verifiability and certifiability issue comes into the picture. According to the Caltech MIT report and our belief the GUI components are difficult to certify and audit. So as suggested by the Caltech/MIT report we decided to have the GUI proprietary and the rest of the parts open source. For these reasons we have put as less functionality in the Selection GUI as possible. The ack requests come from the casting machine whose source is open and verifiable. One other reason for putting this feature in the casting machine and not in the selection machine is that the design suggests that the care has been taken to ensure that the data reaching casting machine is the data stored on the recording server. This is possible as after reaching the casting machine, the data is either encrypted, MACed and sent or Encrypted, MACed and stored. - Why do we need to encrypt the data while storing on the Casting machine? This might seem like an overhead but it is necessary, as the vote casting machine is connected to the Internet and the votes stored on that machine still have the voter’s identification attached to it. So every vote stored on the casting machine has to be encrypted. After the votes are decrypted and the requirements of late updation (described in the authentication part), they are stripped of all the traces of voter’s id. The Id part is sent the ID server (voter status DB) and the vote is sent to the Recording server. - Why do we need to Split the vote before sending it? We can do that on server too?! Locally splitting and transmitting makes each packet sent less precious. Each packet now only contains either the vote for someone or that someone has voted, it doesn’t have someone has voted for someone. After the server sends back the acknowledgement the casting machine prints out a paper based trail report of the vote and stores it in a secure place. • **Recording component** This is the terminus for our system. It takes cares, in part, of Uniqueness, Integrity and Secrecy. When it receives the vote packet from a poll site, it checks for its Authenticity and Integrity. If the packet passes the test then the vote, now decrypted form the previous encryption is encrypted and stored again. It also maintains back up servers. The back up servers can be maintained in the Server pool manner of the ID server pool or by having an automated backup tool, back up server’s data periodically. After the election is over, the recording machine decrypts the votes and performs a count. - **Why encrypt again? Why not store directly? They are encrypted anyways** This is because votes can come from many different pollsites, which may have different secret keys. Even same poll sites can have different session keys at different times. So to remove the complexity of storing the keys, we can uniformly encrypt the data. One other reason is that now we can afford (time-wise) to use PKI, so that the machine can only encrypt the data and decryption can take place after an human intervention. Use of threshold cryptography can aid the vote storing process sizably. By that you can distribute the trust people put into the election officials. As on now we are not aware of any recognized and reliable implementation of a threshold cryptography, so its use is still under consideration. • **Communication Component** This is the most important part of the system. It takes care of secrecy, integrity, reliability, availability and authentication requirements. - **Why Internet?** The other options are not feasible. After researching for other options we could think of only two possible options. 1. Use dedicated phone lines. The biggest advantage of this system is, its almost immunity to DOS attacks. But the problem is of cost. We may have many pollsites. To have dedicated phone lines from each of them to the central server might just be a gross overkill for a single day or two days. 2. Store the votes locally and at the end of the day take the magnetic media in secure vans: We are not gaining much here. This is almost like a DRE system. Thus we have reached a consensus, that if we are not willing to spend for the dedicated phone lines we have to use the Internet and take all the concomitant risks. **Securing the Internet communications** Every communication performed over the Internet is secured in the following way. - **Encryption** We intend to use reliable symmetric key encryption algorithms for securing the data transfer. We avoid PKI for the following two reasons - They are slower. We might need to transfer a lot of data, frequently. - Since any one can encrypt the data and the choices for the data are limited, an attacker could compare and guess the data being transmitted. Here is an elaboration of the point 2. The protocol is public. Every one knows how we transfer the data. There are a limited number of voters. So the packet going to the vote-recording server can have only limited number of messages. What you to guess is encrypt each message and compare it with the captured message. Well, we could use salting or nonce but that could again slow down the process. However we do not remove PKI completely. The poll site machines and the servers have PKI working for setting up secret keys and periodic rekeying. The algorithm we intend to use is AES(Rijndael) with 256/128 bit keys. This will work at the application layer. - **Authentication** We intend to use IPSec (using the Authentication Header AH) for authentication. Using IPSec - Authenticates the data - Prevents replay attack, by the sequence numbers. The reason we chose to Authenticate packets at the network layer is to make authentication faster. One of the advantages of using this at IP layer is to ameliorate the effect of a DOS. If we use authentication at application layer than it has go up the protocol stack to authenticate each packet, which could take up more time if some one is flooding spoofed packets. Network layer is the lowest layer in the stack where we can put reliable end-to-end authentication. However, if there is a need felt for higher integrity check, we could even MAC the application layer data. **Note:** The data is authenticated at both the ends, clients authenticates the server and sever authenticates the client. - **Packet Filters** We suggest using packet filters before each server pools. Since we have a decided number of types of packets coming in and going out, the filters can filter all the other packets. We understand that most of this parameters can be spoofed and filters can be fooled but we feel that these filters can act as a primary line of defense. - **Other measures** 1. The votes and ids are split before they travel in the wild, making each piece less precious. 2. Every information that is ever stored is encrypted. - **Other security and reliability measures.** These are the measures that are not that technical in nature but very important and often not considered 1. The poll sites should be guarded. 2. All the servers will be well guarded against human or rodent attacks. 3. The backup servers are physically quite far from each other. 4. The poll sites have backup systems for every machine. 5. Poll sites have UPS and generators back up if the power goes down. **Conclusion**: We have designed a system to meet our requirements given in the first phase as fully as possible. We have tried to minimize the tradeoffs of efficiency, security and reliability vs. Realism and cost. This is a work in progress and will evolve as the project goes ahead. Appendix: UML Diagrams An activity Diagram of The Late Updating process of Voter Status A Sequence Diagram of System Authentication Sequence 1: isRegistered(String name, int VoterID, String district): boolean 1.1: lookup(int): boolean 1.2: isRegistered(String, int, String): boolean 1.3: hasVoted(int VoterID): boolean 1.3.1: lookup(int): boolean 2.1: lookup(int): boolean 3.1: lookup(int): boolean
{"Source-Url": "http://www.cs.jhu.edu:80/~rubin/courses/sp03/group-reports/group6/group6_design.pdf", "len_cl100k_base": 4262, "olmocr-version": "0.1.50", "pdf-total-pages": 18, "total-fallback-pages": 0, "total-input-tokens": 28363, "total-output-tokens": 5006, "length": "2e12", "weborganizer": {"__label__adult": 0.00035262107849121094, "__label__art_design": 0.00020945072174072263, "__label__crime_law": 0.0017709732055664062, "__label__education_jobs": 0.0007352828979492188, "__label__entertainment": 5.8710575103759766e-05, "__label__fashion_beauty": 0.00015413761138916016, "__label__finance_business": 0.00022208690643310547, "__label__food_dining": 0.0003459453582763672, "__label__games": 0.0015993118286132812, "__label__hardware": 0.0020751953125, "__label__health": 0.0004825592041015625, "__label__history": 0.0002570152282714844, "__label__home_hobbies": 6.705522537231445e-05, "__label__industrial": 0.0004749298095703125, "__label__literature": 0.00013840198516845703, "__label__politics": 0.0012178421020507812, "__label__religion": 0.00036072731018066406, "__label__science_tech": 0.0160369873046875, "__label__social_life": 8.922815322875977e-05, "__label__software": 0.008819580078125, "__label__software_dev": 0.96337890625, "__label__sports_fitness": 0.0003821849822998047, "__label__transportation": 0.0006814002990722656, "__label__travel": 0.00014793872833251953}, "weborganizer_max": "__label__software_dev", "avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_ratio": [[0, 20394, 0.00836]], "fineweb_edu_fasttext_gt2__fineweb_edu_fasttext_gt2__score": [[0, 20394, 0.69432]], "ft_lang_id_en_doc_v2__ft_lang_id_en_doc_v2__en": [[0, 20394, 0.94391]], "google_gemma-3-12b-it_contains_pii": [[0, 119, false], [119, 1180, null], [1180, 2677, null], [2677, 3865, null], [3865, 4864, null], [4864, 7011, null], [7011, 9105, null], [9105, 10941, null], [10941, 12229, null], [12229, 14261, null], [14261, 16303, null], [16303, 17996, null], [17996, 19986, null], [19986, 20076, null], [20076, 20105, null], [20105, 20394, null], [20394, 20394, null], [20394, 20394, null]], "google_gemma-3-12b-it_is_public_document": [[0, 119, true], [119, 1180, null], [1180, 2677, null], [2677, 3865, null], [3865, 4864, null], [4864, 7011, null], [7011, 9105, null], [9105, 10941, null], [10941, 12229, null], [12229, 14261, null], [14261, 16303, null], [16303, 17996, null], [17996, 19986, null], [19986, 20076, null], [20076, 20105, null], [20105, 20394, null], [20394, 20394, null], [20394, 20394, null]], "google_gemma-3-4b-it_v2tag__is_academic_paper": [[0, 5000, true], [5000, 20394, null]], "google_gemma-3-4b-it_v2tag__is_class_syllabus": [[0, 5000, false], [5000, 20394, null]], "google_gemma-3-4b-it_v2tag__is_completion_certificate": [[0, 5000, false], [5000, 20394, null]], "google_gemma-3-4b-it_v2tag__is_court_notice": [[0, 5000, false], [5000, 20394, null]], "google_gemma-3-4b-it_v2tag__is_homework_assignment": [[0, 5000, false], [5000, 20394, null]], "google_gemma-3-4b-it_v2tag__is_news_article": [[0, 5000, false], [5000, 20394, null]], "google_gemma-3-4b-it_v2tag__is_public_order": [[0, 5000, false], [5000, 20394, null]], "google_gemma-3-4b-it_v2tag__is_resume_cv": [[0, 5000, false], [5000, 20394, null]], "google_gemma-3-4b-it_v2tag__is_test_or_quiz": [[0, 5000, false], [5000, 20394, null]], "google_gemma-3-4b-it_v2tag__is_textbook": [[0, 5000, false], [5000, 20394, null]], "pdf_page_numbers": [[0, 119, 1], [119, 1180, 2], [1180, 2677, 3], [2677, 3865, 4], [3865, 4864, 5], [4864, 7011, 6], [7011, 9105, 7], [9105, 10941, 8], [10941, 12229, 9], [12229, 14261, 10], [14261, 16303, 11], [16303, 17996, 12], [17996, 19986, 13], [19986, 20076, 14], [20076, 20105, 15], [20105, 20394, 16], [20394, 20394, 17], [20394, 20394, 18]], "pipe_delimited_lines_v1__pipe_delimited_lines_v1__pipe_delimited_lines_ratio": [[0, 20394, 0.0]]}
olmocr_science_pdfs
2024-11-30
2024-11-30
ac703e1e9218bd9bb88119f03c4458b05e701982
ACTIVITY CYCLE DIAGRAMS AND THE THREE PHASE METHOD Ray J. Paul Department of Computer Science Brunel, The University of West London Uxbridge, Middlesex UB8 3PH, United Kingdom ABSTRACT This tutorial paper looks at two modeling tools that are popular in European simulation modeling. These are Activity Cycle Diagrams, which represent the logical flow of a simulation model conceptually; and the Three Phase Method, which is a world view of program construction. Each tool is described, and comments made on their relative merits to the wider simulation community. 1 INTRODUCTION Activity Cycle Diagrams and the Three Phase Method are two popular tools used in simulation modeling in Europe, and in particular in the United Kingdom. Whilst some simulationists use both tools in their work, it is worth observing that the two tools can be used independently, as will be shown. Activity Cycle Diagrams (ACD, sometimes called Entity Cycle Diagrams, or various combinations of Entity, Activity and Cycle Diagrams) are a method of conceptualizing the problem in terms of the logical flow of objects in the system. An ACD can be used as a basis for a model written in object-oriented code, or any program using any of the event, process, or three-phase world views. However, some simulation packages, especially simulators, require a representation of the problem to be modelled that does not map directly to an ACD. Even in such cases, an ACD can be used for problem understanding, prior to modeling. ACDs are discussed in the second section of this paper. The Three Phase Method, or World View, is a competitor to the more well known event and process world views (Law and Kelton, 1991). The method grew out of the activity based approach popular in the United Kingdom in the 1960s. A description of the Three Phase Method is given in the third section of the paper, and some comments on its wider applicability in the fourth section. The technical contents of this paper are taken from Paul and Balmer (1993). Another text that discusses this is Pidd (1992a) with some programming and other supporting material covered in Pidd (1989). 2 ACTIVITY CYCLE DIAGRAMS 2.1 Basic Concepts Activity Cycle Diagrams (ACDs) are one way of modeling the interactions of system objects and are particularly useful for systems with a strong queueing structure. They are based on Toccher’s (1963) idea of stochastic gearslows. ACDs have the advantage of parsimony in that they use only two symbols which describe the life cycle of the system’s objects or entities: An entity is any component of the model which can be imagined to retain its identity through time. Entities are either idle, in notional or real queues, or active, engaged with other entities in time consuming activities. The symbols we use are shown in Figure 1. ![Figure 1: Queue State and Activity State](image-url) An active state usually involves the co-operation of different classes of entity. The duration of the active state can always be determined in advance - usually by taking a sample from an appropriate probability distribution if the simulation model is stochastic. For example, the unloading of a ship at a berth is an active state, where an entity ship and an entity berth are engaged in the activity unload (possibly with other entities as well, such as cranes etc.). A passive state or queueing state involves no co-operation between different classes of entity and is generally a state in which the entity waits for something to happen. The length of time an entity will spend in a queue cannot be determined in advance because it depends on the duration of the immediately preceding and succeeding activities. For example, the time a ship spends waiting in an idle queue for unloading at a berth depends on its time of arrival and the time one of the berths it can use becomes vacant. A life cycle (activity cycle) of queues and activities is defined for each entity type. We impose the restriction that queues and activities must alternate in any life cycle (if necessary we make this happen by creating dummy queues). A complete ACD consists of a combination of all the individual life cycles. 2.2 The Pub Example We shall show how to draw an ACD using the Pub example. This example is used by many authors (e.g. Clementson, 1982) since its background is implicitly understood by most readers. The first simple version has three entities called ‘man’, ‘barmaid’ and ‘glass’. The man either drinks or waits to drink. The barmaid either pours a drink or is idle. The glass is either used to drink from, is empty, is poured into by the barmaid or is full waiting to be drunk from. We can summarise the states for each entity as follows in Figure 2. Each life cycle for each entity type can then be drawn as in Figure 3. The ACD for the pub is then drawn by combining the common activities as in Figure 4. The ACD illustrates logically that the activity DRINK cannot start unless a man is in the queue WAIT and a glass is in the queue FULL. Similarly, the activity POUR cannot start unless a barmaid is in the queue IDLE and a glass is in the queue EMPTY. The ACD also has a stronger interpretation. This is, that when is a man in the queue WAIT and a glass in the queue FULL, then the activity DRINK will start. Similarly, when there is a barmaid in the queue IDLE, and a glass in the queue EMPTY, then the activity POUR will start. On completion of any activity, the movement of the entities is fixed. After POUR, the barmaid goes to the queue IDLE, and the glass goes to the queue FULL. After DRINK, the glass goes to the queue EMPTY, and the man to the queue WAIT. 3 THE THREE PHASE METHOD 3.1 Manual simulation using the ACD The first step is to make sure that the logic of the system is properly understood and one of the best ways of doing this is to run a manual simulation. There are a variety of methods for doing this, but we shall use the ACD method. This will help understand the Three Phase Method. In order to carry out a manual simulation with an ACD, we draw the life cycles on a large sheet of paper or playing board (using different colours to distinguish the cycles of different entity types). The current state of the model is described by the position of each entity in a queue or activity; this is easily shown using coloured counters at appropriate points on the playing board. An event is a change in the state of the model which occurs at an instant of time. When an activity starts, its duration can be sampled from a specified distribution, and the time when it will finish can be noted on the playing board or on the next event list. The activity is bound to finish at exactly that time, so the completions of activities are bound events. However we do not know in advance when an activity can start: this depends on the correct combination of entities being available in the preceding queues. The starts of activities are conditional events. One of the benefits of manual simulation is to establish priorities where they exist. In the final pub example in Figure 7, the entity barmaid could face a possible choices of activity to start first. It may be important to establish that there is a priority and what it is. Writing computer code directly can easily result in this problem being forgotten and handled haphazardly. 3.2 The Pub Example Modified In the Three Phase Method, the simulation proceeds as a repetition of the following three phases: *Phase 1* Check the finish times of all the activities currently in progress. Find the earliest of these. Advance the clock to this time. *Phase 2* For the activity (or activities) which have finished, move the entities into their appropriate queues. Cross out the note showing when the activity was to end. *Phase 3* Scan the activities in order of increasing activity number (they should have been numbered before the start of the run). Start any activities which can begin by moving the appropriate entities from the queues into the activity. Sample an activity duration time, calculate when the activity will finish, and make a note of this time. Note this common simulation structure: - Advance time to next event; - Execute Bound events (activity completions); - Execute Conditional events (activity starts). We can record the state of the simulation using these three phases. So if we say that the activity drink takes 4 minutes; pour takes 3 minutes; glasses and customers are synchronised as in Figure 5; and every entity in their appropriate starting queues IDLE, EMPTY and WAIT, then we get Table 1. <table> <thead> <tr> <th>A</th> <th>B</th> <th>C</th> </tr> </thead> <tbody> <tr> <td>0</td> <td>-</td> <td>pour starts, ends at 3</td> </tr> <tr> <td>3</td> <td>pour ends</td> <td>drink starts ends at 7; pour starts, ands at 6</td> </tr> <tr> <td>6</td> <td>pour ends</td> <td>drink starts, ends at 10; pour starts, 9</td> </tr> <tr> <td>7</td> <td>drink ends</td> <td>-</td> </tr> <tr> <td>9</td> <td>pour ends</td> <td>drink starts, ends at 13; pour starts, 12</td> </tr> <tr> <td>10</td> <td>drink ends</td> <td>-</td> </tr> <tr> <td>12</td> <td>pour ends</td> <td>drink starts, ends at 16; pour starts, 15</td> </tr> </tbody> </table> Table 1: Manual Simulation of Pub We could of course collect statistics from a manual simulation, but this would be very tiresome so we use the computer to automate the whole process. Nevertheless, it is worth re-emphasising that a manual simulation is an important step in the understanding of the process being modelled. 3.3 The Three Phase Method The three phases to be performed are usually expressed as A, B and C as we have seen. The executive cycles through the phases as the simulation proceeds. A PHASE (time scan): determine when the next event is due and decide which B events are then due to occur. Move simulation clock time to the time of the next event. B PHASE (B calls): execute only those B events identified in the A phase as being due now. C PHASE (C scan): attempt each of the C events in turn and execute those conditions that are satisfied. Repeat the C scan until no more C events can take place (i.e. no more activities can start). An outline flow diagram for such an executive is shown in Figure 6. The three phase method or approach was first described by Tocher (1963). Its basic building block is an activity, which has two events that describe it, an end of activity event and a start of activity event: B events are bound or book-keeping events signifying the end of an activity for an entity. They are executed directly by the executive program whenever their scheduled time is reached. C events are conditional or co-operative events signifying the start of an activity for the relevant entities. They are executed because of the co-operation of different classes of entity or the satisfaction of specific conditions within the simulation. ![Diagram of a Three Phase Executive](image) Each B and C event is programmed as an independent program routine or procedure. In effect then, they represent an 'atomistic' description of the activities of a simulation problem, where the start of an activity, a C event, is identified, tested for and set up if the test is successful. The completion of an activity for each entity involved in it is separately identified in a B event and is executed at the scheduled time. It is the atomistic structure combined with an efficient executive that makes the three phase method so powerful. In summary, the method has the following desirable characteristics: - **Modeling clarity** - reduces risk of error and aids verification. - **Model maintainability** - an ongoing process with changing personnel. - **Modularity** - a special technique to cope with very large models. Combining smaller ones can be incorporated more readily. - Interaction - inclusion of optional gaming elements is easy. The adoption of a good standard such as this method can provide benefits in a number of areas. These are: - Total lifetime software costs can be controlled. - Control of subcontract staff is easier. - Staff mobility is enhanced. ## 4 WORLD VIEW COMPARISONS ### 4.1 Other World Views **Activity Based** The simplest structure is to go through all the activities, testing each in turn and starting or ending the appropriate ones. If any activity is executed, the whole list may need to be searched again. It is possible that an activity higher up the list, which was previously blocked, can now be executed under the new state of the system. The chief advantage of this type of structure is that it is easy to program. Each activity can be programmed and tested as a separate module. The simplicity of the structure is particularly valuable when dealing with logically complicated models, where activities are predominantly "multi-resource", i.e. activities that require several different entities to be in particular states before they can start. An example of this is an activity for causing a ship to leave port, where the conditions might be that a ship is waiting to depart, a tug is available, a pilot is available, the tide is in and the dock entrance is free. However, an activity-based structure produces an inefficient computer program, in the sense that a great many unsuccessful tests have to be made. Improvements can be made by only recycling if certain activities are executed, and not otherwise. Purely activity-based languages are now more or less defunct, having been replaced by the Three Phase Method. The three phase structure combines a certain amount of efficiency in performing only the relevant bound event, with an ability to handle logically interrelated activities in a simple manner; all being tested on every iteration. **Event Based** A different approach is to make use of the information available from the time scan to branch directly to the relevant bit of program. This is an event-based structure. The executive branches directly to the activity associated with the earliest event identified by the Time Scan. The efficiency of this type of structure is its main virtue, but it can be very difficult to use in multi-resource type models, where cross-referencing between branches arise. A large number of possible states of the system have to be considered when writing the program. The Process Flow Method A simulation structure which is increasing in popularity is the process flow method based around the SIMULA simulation language. SIMULA is ALGOL 68 plus. The essence of the method is to write each entity life cycle in an ACD as a block of code with PAUSE and ENABLE commands to signify that the cycle cannot continue until other entities are available to enable an activity to take place. The execution of such a program requires complex and extensive cross referencing of the blocks of code and alteration to the model is difficult. 4.2 Simultaneous Events One of the most difficult problems in setting up a simulation program is to cater for simultaneous events. The model will probably be used to make comparative runs, where it is important to ensure that unwanted differences between runs are not generated because of changes in the order in which activities are executed. This is also necessary for debugging the program by following the progress of the simulation in detail. If we use the more complex version of the pub in Figure 7, then the three phase world view expresses priority as follows. Three Phase <table> <thead> <tr> <th>B events</th> <th>C events</th> </tr> </thead> <tbody> <tr> <td>End Arrive</td> <td>C1 - Start Arrive</td> </tr> <tr> <td>End Pour</td> <td>C2 - Start Pour</td> </tr> <tr> <td>End Drink</td> <td>C3 - Start Drink</td> </tr> <tr> <td>End Wash</td> <td>C4 - Start Wash</td> </tr> </tbody> </table> Priority : Pour before Wash. Hence C2 is listed in the program before C4. Because all B events are completed after a time advance before moving to the C phase, all entities that will be made available at the time can be allocated by priority in the C phase. ### Event <table> <thead> <tr> <th>Events</th> <th>Event notice posting (i.e. events generated)</th> </tr> </thead> <tbody> <tr> <td>E1 - Arrive</td> <td>E1, E2</td> </tr> <tr> <td>E2 - Pour</td> <td>E2, E3, E4</td> </tr> <tr> <td>E3 - Drink</td> <td>E2, E4</td> </tr> <tr> <td>E4 - Wash</td> <td>E2, E4</td> </tr> </tbody> </table> **Priority?** We have no control over the order in which the event notices are posted. We can of course use an attribute of an event notice to rank events. Is it obvious what the priorities are? ### Process Each process handles all activities and queues in the life cycle description of an entity in the ACD (or some equivalent description of the life cycle or process). Priorities are easily handled within processes, but the same priority problems can recur in different processes, or in different mixtures. ### 4.3 Amending Models Changing models is an everyday occurrence (Paul, 1991). Let us assume that the beer in the pub comes from a barrel of a fixed size. When the barrel is empty, the barmaid needs to change it for another barrel. Let us call this activity FILL. One way of handling this would be to alter the ACD as in Figure 8. The subsequent amendments to the model are as follows: **Three Phase** **Add:** <table> <thead> <tr> <th>B event</th> <th>C event</th> </tr> </thead> <tbody> <tr> <td>End Fill</td> <td>C5 - Start Fill</td> </tr> </tbody> </table> **Priority:** Fill before Wash. Fill generates its own priority. --- ![Figure 8: Complex Pub ACD Modified](image) Amendments: For C2, Start Pour, add the condition that keg is greater than 0. If End Pour is generated, subtract 1 from keg. Here amendments are local and obvious. Event Add: <table> <thead> <tr> <th>Event</th> <th>Event Notice Posting</th> </tr> </thead> <tbody> <tr> <td>E5 - End Fill</td> <td>E2, E4</td> </tr> </tbody> </table> Amendments: Each event needs checking. In fact E2 and E4 need to check for E5. Of course, one would set up the conditions and code so that E2 and E4 are subroutines to make programming efficient. But the essence is that it is not obvious without checking everything where changes should be made. But priority? Process The introduction of the new keg process impacts on nearly all the other processes in the model (except the door). Each process has to be carefully checked, and all local priorities need to be carefully re-examined. In Conclusion, all objections to the Event and Process methods can be overcome by separate resource routines, ingenuity, cunning, etc. All of these make for a non-standard structure and rely on the analyst to a greater extent. Three Phase is a safe standard - it is easier to write - it is easier to understand - it is easier to validate (small blocks of independent program code) - it is easier to change. 5 CONCLUSIONS ACDs and the Three Phase Method have been successfully used in combination. For example, see El Sheikh et al (1987), Holder and Gittins (1989), Williams et al (1989) and Stapley and Holder (1992). These papers describe the use of ACDs with a particular Three Phase based simulation package which is described in Crookes et al (1986) and by Paul and Balmer (1993). The Three Phase Method has much in common with production rules in expert systems, and this analogy is drawn out in Paul (1989) or Paul and Doukidis (1992). A particular method of handling excessive randomness in statistical sampling has been shown to be easily implemented in the Three Phase Method (Saliby and Paul, 1993). The Three Phase Method is particularly suited to automatic program generation because of its atomic structure, and this is discussed by Mathewson (1982 and 1985), Paul and Chew (1987) and Paul and Balmer (1993). ACDs are a particularly powerful conceptual modeling tool around which methods for automating model formulation have evolved (Paul and Doukidis, 1986). These and other applications are the basis of many developments by the Computer Aided Simulation Modeling group (Paul, 1992), whose origins are described by Balmer and Paul (1986). Some support to the claims of Three Phase adaptability is provided by Holder and Gittins (1989) and Williams et al (1989). Two teams set about building different parts of the same problem using ACDs and the Three Phase Method. On completion of the two projects, developed by independent software houses for the same customer, the two models were successfully integrated together with little difficulty. However, it would be churlish to end on a note of absolute triumph. ACDs are limited. They show logical flow, but not logical depth. Whilst it is inevitable that any representation method is either easy to follow and not comprehensive, or vice versa, sometimes the limitations can be severe: see El Sheikh et al (1987) for a simple example. And the Three Phase Method has yet to prove its adaptability in a fast changing world. Pidd (1992b) shows that Three Phase modeling and Object-Oriented thinking can be combined. Parallel simulation has yet to be shown to be compatible with the Three Phase Method, although it is too early to say that it cannot be done. REFERENCES AUTHOR BIOGRAPHY RAY J PAUL holds the first U.K. Chair in Simulation Modelling at Brunel University. He previously taught information systems and operational research for 21 years at the London School of Economics. He received a B.Sc. in Mathematics, and a M.Sc. and a Ph.D. in Operational Research from Hull University. He has published widely in book and paper form (two books, over 70 papers in journals, books and conference proceedings), mainly in the areas of the simulation modeling process and in software environments for simulation modeling. He has acted as a consultant for a variety of U.K. government departments, software companies, and commercial companies in the tobacco and oil industries. His research interests are in methods of automating the process of discrete event simulation modeling, and the general applicability of such methods and their extensions to the wider arena of information systems. Recent research results have been in automatic code generation, colour graphics modeling interfaces, dynamically driven icon representations of simulation models, machine learning applied to model specification and to output analysis, object oriented approaches, and information systems paradigms. He is currently running a simulation research group of three faculty members and eight research students. He has recently instituted the first M.Sc. in Simulation Modelling, a one year course starting in October each year at Brunel University.
{"Source-Url": "http://www.informs-sim.org/wsc93papers/1993_0016.pdf", "len_cl100k_base": 5036, "olmocr-version": "0.1.50", "pdf-total-pages": 9, "total-fallback-pages": 0, "total-input-tokens": 9954, "total-output-tokens": 6311, "length": "2e12", "weborganizer": {"__label__adult": 0.0004076957702636719, "__label__art_design": 0.0005178451538085938, "__label__crime_law": 0.0004963874816894531, "__label__education_jobs": 0.009307861328125, "__label__entertainment": 0.00013327598571777344, "__label__fashion_beauty": 0.00022077560424804688, "__label__finance_business": 0.0011272430419921875, "__label__food_dining": 0.0005135536193847656, "__label__games": 0.00145721435546875, "__label__hardware": 0.0012655258178710938, "__label__health": 0.000934600830078125, "__label__history": 0.0006976127624511719, "__label__home_hobbies": 0.00021851062774658203, "__label__industrial": 0.0014219284057617188, "__label__literature": 0.0004458427429199219, "__label__politics": 0.00045418739318847656, "__label__religion": 0.0004045963287353515, "__label__science_tech": 0.41650390625, "__label__social_life": 0.00025343894958496094, "__label__software": 0.020172119140625, "__label__software_dev": 0.541015625, "__label__sports_fitness": 0.0004649162292480469, "__label__transportation": 0.0014495849609375, "__label__travel": 0.0003056526184082031}, "weborganizer_max": "__label__software_dev", "avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_ratio": [[0, 25691, 0.02286]], "fineweb_edu_fasttext_gt2__fineweb_edu_fasttext_gt2__score": [[0, 25691, 0.49881]], "ft_lang_id_en_doc_v2__ft_lang_id_en_doc_v2__en": [[0, 25691, 0.9207]], "google_gemma-3-12b-it_contains_pii": [[0, 2876, false], [2876, 5656, null], [5656, 8408, null], [8408, 10669, null], [10669, 14145, null], [14145, 15743, null], [15743, 17421, null], [17421, 21860, null], [21860, 25691, null]], "google_gemma-3-12b-it_is_public_document": [[0, 2876, true], [2876, 5656, null], [5656, 8408, null], [8408, 10669, null], [10669, 14145, null], [14145, 15743, null], [15743, 17421, null], [17421, 21860, null], [21860, 25691, null]], "google_gemma-3-4b-it_v2tag__is_academic_paper": [[0, 5000, true], [5000, 25691, null]], "google_gemma-3-4b-it_v2tag__is_class_syllabus": [[0, 5000, false], [5000, 25691, null]], "google_gemma-3-4b-it_v2tag__is_completion_certificate": [[0, 5000, false], [5000, 25691, null]], "google_gemma-3-4b-it_v2tag__is_court_notice": [[0, 5000, false], [5000, 25691, null]], "google_gemma-3-4b-it_v2tag__is_homework_assignment": [[0, 5000, false], [5000, 25691, null]], "google_gemma-3-4b-it_v2tag__is_news_article": [[0, 5000, false], [5000, 25691, null]], "google_gemma-3-4b-it_v2tag__is_public_order": [[0, 5000, false], [5000, 25691, null]], "google_gemma-3-4b-it_v2tag__is_resume_cv": [[0, 5000, false], [5000, 25691, null]], "google_gemma-3-4b-it_v2tag__is_test_or_quiz": [[0, 5000, false], [5000, 25691, null]], "google_gemma-3-4b-it_v2tag__is_textbook": [[0, 5000, false], [5000, 25691, null]], "pdf_page_numbers": [[0, 2876, 1], [2876, 5656, 2], [5656, 8408, 3], [8408, 10669, 4], [10669, 14145, 5], [14145, 15743, 6], [15743, 17421, 7], [17421, 21860, 8], [21860, 25691, 9]], "pipe_delimited_lines_v1__pipe_delimited_lines_v1__pipe_delimited_lines_ratio": [[0, 25691, 0.15517]]}
olmocr_science_pdfs
2024-12-02
2024-12-02
173ca78cc4119ed065131a9da5705b096e579c60
RIOT OS Paves the Way for Implementation of High-Performance MAC Protocols Kévin Roussel, Ye-Qiong Song, Olivier Zendra To cite this version: Kévin Roussel, Ye-Qiong Song, Olivier Zendra. RIOT OS Paves the Way for Implementation of High-Performance MAC Protocols. SENSORNETS 2015, INSTICC; ESEO Angers, Feb 2015, Angers, France. pp.5-14, 10.5220/0005237600050014. hal-01141496 HAL Id: hal-01141496 https://hal.archives-ouvertes.fr/hal-01141496 Submitted on 13 Apr 2015 HAL is a multi-disciplinary open access archive for the deposit and dissemination of scientific research documents, whether they are published or not. The documents may come from teaching and research institutions in France or abroad, or from public or private research centers. L’archive ouverte pluridisciplinaire HAL, est destinée au dépôt et à la diffusion de documents scientifiques de niveau recherche, publiés ou non, émanant des établissements d’enseignement et de recherche français ou étrangers, des laboratoires publics ou privés. RIOT OS Paves the Way for Implementation of High-Performance MAC Protocols Kévin Roussel, Ye-Qiong Song and Olivier Zendra LORIA/INRIA Nancy Grand-Est, Université de Lorraine, 615, rue du Jardin Botanique, 54600 Villers-Lès-Nancy, France {Kevin.Roussel, Ye-Qiong.Song, Olivier.Zendra}@inria.fr Keywords: Real-Time, Wireless Sensor Networks, Internet of Things, MAC protocols, RIOT OS Abstract: Implementing new, high-performance MAC protocols requires real-time features, to be able to synchronize correctly between different unrelated devices. Such features are highly desirable for operating wireless sensor networks (WSN) that are designed to be part of the Internet of Things (IoT). Unfortunately, the operating systems commonly used in this domain cannot provide such features. On the other hand, “bare-metal” development sacrifices portability, as well as the multitasking abilities needed to develop the rich applications that are useful in the domain of the Internet of Things. We describe in this paper how we helped solving these issues by contributing to the development of a port of RIOT OS on the MSP430 microcontroller, an architecture widely used in IoT-enabled motes. RIOT OS offers rich and advanced real-time features, especially the simultaneous use of as many hardware timers as the underlying platform (microcontroller) can offer. We then demonstrate the effectiveness of these features by presenting a new implementation, on RIOT OS, of S-CoSenS, an efficient MAC protocol that uses very low processing power and energy. 1 INTRODUCTION When programming the small devices that constitutes the nodes of the Internet of Things (IoT), one has to adapt to the limitations of these devices. Apart from their very limited processing power (especially compared to the current personal computers, and even mobile devices like smartphones and tablets), the main specificity of the devices is that they are operated on small batteries (e.g.: AAA or button cells). Thus, one of the main challenges with these motes is the need to reduce as much as possible their energy consumption. We want their batteries to last as long as possible, for economical but also practical reasons: it may be difficult—even almost impossible—to change the batteries of some of these motes, because of their locations (e.g.: on top of buildings, under roads, etc.) IoT motes are usually very compact devices: they are usually built around a central integrated chip that contains the main processing unit and several basic peripherals (such as timers, A/D and D/A converters, I/O controllers...) called microcontroller units or MCUs. Apart from the MCU, a mote generally only contains some “physical-world” sensors and a radio transceiver for networking. The main radio communication protocol currently used in the IoT field is IEEE 802.15.4. Some MCUs do integrate a 802.15.4 transceiver on-chip. Among the various components that constitute a mote, the most power-consuming block is the radio transceiver. Consequently, to reduce the power consumption of IoT motes, a first key point is to use the radio transceiver only when needed, keeping it powered-off as much as possible. The software element responsible to control the radio transceiver in an adequate manner is the MAC / RDC (Media Access Control & Radio Duty Cycle) layer of the network stack. A efficient power-saving strategy for IoT motes thus relies on finding the better trade-off between minimizing the radio duty cycle while keeping networking efficiency at the highest possible level. This is achieved by developing new, “intelligent” MAC / RDC protocols. To implement new, high-performance MAC / RDC protocols, one needs to be able to react to events with good reactivity (lowest latency possible) and flexibility. These protocols rely on precise timing to ensure efficient synchronization between the different motes and other radio-networked devices of a Personal Area Network (PAN), thus allowing to turn on the radio transceivers only when needed. At the system level, being able to follow such accurate timings means having very efficient interruption management, and the extensive use of hardware timers, that are the most precise timing source available. The second most power-consuming element in a mote, after the radio transceiver, is the MCU itself: every current MCU offers “low-power modes”, that consist in disabling the various hardware blocks, beginning with the CPU core. The main way to minimize energy consumption with a MCU is thus to disable its features as much as possible, only using them when needed: that effectively means putting the whole MCU to sleep as much as possible. Like for the radio transceiver, using the MCU efficiently while keeping the system efficient and reactive means optimal use of interruptions, and hardware timers for synchronization. Thus, in both cases, we need to optimally use interruptions as well as hardware timers. Being able to use them both efficiently without too much hassle implies the use of a specialized operating system (OS), especially to easily benefit from multitasking abilities. That is what we will discuss in this paper. 2 PREVIOUS WORK AND PROBLEM STATEMENT Specialized OSes for the resource-constrained devices that constitute wireless sensor networks have been designed, published, and made available for quite a long time. 2.1 TinyOS The first widely used system in this domain was TinyOS (Levis et al., 2005). It is an open-source OS, whose first stable release (1.0) was published in september 2002. It is very lightweight, and as such well adapted to limited devices like WSN motes. It has brought many advances in this domain, like the ability to use Internet Protocol (IP) and routing (RPL) on 802.15.4 networks, including the latest IPv6 version, and to simulate networks of TinyOS motes via TOSSIM (Levis et al., 2003). Its main drawback is that one needs to learn a specific language—named nesC—to be able to efficiently work within it. This language is quite different from standard C and other common imperative programming languages, and as such can be difficult to master. The presence of that specific language is no coincidence: TinyOS is built on its own specific paradigms: it has an unique stack, from which the different components of the OS are called as statically linked callbacks. This makes the programming of applications complex, especially for decomposing into various “tasks”. The multitasking part is also quite limited: tasks are run in a fixed, queue-like order. Finally, TinyOS requires a custom GNU-based toolchain to be built. All of these limitations, plus a relatively slow development pace (last stable version dates back to august 2012) have harmed its adoption, and it is not the mainly used OS of the domain anymore. 2.2 Contiki The current reference OS in the domain of WSN and IoT is Contiki (Dunkels et al., 2004). It’s also an open-source OS, which was first released in 2002. It is also at the origin of many assets: we can mention, among others, the uIP Embedded TCP/IP Stack (Dunkels, 2003), that has been extended to uIPv6, the low-power Rime network stack (Dunkels, 2007), or the Cooja advanced network simulator (Österlind et al., 2006). While a bit more resource-demanding than TinyOS, Contiki is also very lightweight and well adapted to motes. Its greatest advantage over TinyOS is that it is based on standard, well-known OS paradigms, and coded in standard C language, which makes it relatively easy to learn and program. It offers an event-based kernel, implemented using cooperative multitreading, and a complete network stack. All of these features and advantages have made Contiki widespread, making it the reference OS when it comes to WSN. Contiki developers also have made advances in the MAC/RDC domain: many of them have been implemented as part of the Contiki network stack, and a specifically developed, ContikiMAC, has been published in 2011 (Dunkels, 2011) and implemented into Contiki as the default RDC protocol (designed to be used with standard CSMA/CA as MAC layer). However, Contiki’s extremely compact footprint and high optimization comes at the cost of some limitations that prevented us from using it as our software platform. Contiki OS is indeed not a real-time OS: the processing of “events”—using Contiki’s terminology—is made by using the kernel’s scheduler, which is based on cooperative multitasking. This scheduler only triggers at a specific, pre-determined rate; on the platforms we’re interested in, this rate is fixed to 128 Hz: this corresponds to a time skew of up to 8 milliseconds (8000 microseconds) to process an event, interruption management being one of the possible events. Such a large granularity is clearly a huge problem when implementing high-performance MAC/RDC protocols, knowing that the transmission of a full-length 802.15.4 packet takes bout 4 milliseconds (4000 microseconds) to process an event, a time granularity of 320 microseconds is needed, corresponding to one backoff period (BP). To address this problem, Contiki provides a real-time feature, \texttt{rtimer}, which allows to bypass the kernel scheduler and use a hardware timer to trigger execution of user-defined functions. However, it has very severe limitations: - only one instance of \texttt{rtimer} is available, thus only one real-time event can be scheduled or executed at any time; this limitation forbids development of advanced real-time software—like high-performance MAC / RDC protocols—or at least makes it very hard; - moreover, it is unsafe to execute from \texttt{rtimer}, even indirectly, most of the Contiki basic functions (i.e.: kernel, network stack, etc.), because these functions are not designed to handle pre-emption. Contiki is indeed based on cooperative multithreading, whereas the \texttt{rtimer} mechanism seems like a “independent feature”, coming with its own paradigm. Only a precise set of functions known as “interrupt-safe” (like \texttt{process\_poll()}) can be safely invoked from \texttt{rtimer}, using other parts of Contiki’s meaning almost certainly crash or unpredictable behaviour. This restriction practically makes it very difficult to write Contiki extensions (like network stack layer drivers) using \texttt{rtimer}. Also note that this cooperative scheduler is designed to manage a specific kind of tasks: the \texttt{protothreads}. This solution allows to manage different threads of execution, without needing each of them to have its own separate stack (Dunkels et al., 2006). The great advantage of this mechanism is the ability to use an unique stack, thus greatly reducing the needed amount of RAM for the system. The trade-off is that one must be careful when using certain C constructs (i.e.: it is impossible to use the \texttt{switch} statement in some parts of programs that use protothreads). For all these reasons, we were unable to use Contiki OS to develop and implement our high-performance MAC/RDC protocols. We definitely needed an OS with efficient real-time features and event handling mechanism. 2.3 Other options There are other, less used OSes designed for the WSN/IoT domain, but none of them fulfilled our requirements, for the following reasons: SOS (Han et al., 2005) This system’s development has been cancelled since november 2008; its authors explicitly recommend on their website to “consider one of the more actively supported alternatives”. Lorien (Porter and Coulson, 2009) While its component-oriented approach is interesting, this system seems does not seem very widespread. It is currently available for only one hardware platform (TelosB/SkyMote) which seriously limits the portability we can expect from using an OS. Moreover, its development seems to have slowed down quite a bit, since the latest available Lorien release was published in july 2011, while the latest commit in the project’s SourceForge repository (r46) dates back to january 2013. Mantis (Abrach et al., 2003) While this project claims to be Open Source, the project has made, on its SourceForge web site, no public release, and the access to the source repository (http://mantis.cs.colorado.edu/viewcvs/) seems to stall. Moreover, reading the project’s main web page shows us that the last posted news item mentions a first beta to be released in 2007. The last publications about Mantis OS also seems to be in 2007. All of these elements tend to indicate that this project is abandoned. **LiteOS** (Cao et al., 2008) This system offers very interesting features, especially the ability to update the nodes firmware over the wireless, as well as the built-in hierarchical file system. Unfortunately, it is currently only available on IRIS/MicaZ platforms, and requires AVR Studio for programming (which imposes Microsoft Windows as a development platform). This greatly hinders portability, since LiteOS is clearly strongly tied to the AVR microcontroller architecture. **MansOS** (Strazdins et al., 2010) This system is very recent and offers many interesting features, like optional preemptive multitasking, a network stack, runtime reprogramming, and a scripting language. It is available on two MCU architectures: AVR and MSP430 (but not ARM). However, none of the real-time features we wanted seems to be available: e.g. only software timers with a 1 millisecond resolution are available. In any case, none of the alternative OSes cited hereabove offer the real-time features we were looking for. On the other hand, “bare-metal” programming is also unacceptable for us: it would mean sacrificing portability and multitasking; and we would also need to redevelop many tools and APIs to make application programming even remotely practical enough for third-party developers who would want to use our protocols. We also envisioned to use an established real-time OS (RTOS) as a base for our works. The current reference when it comes to open-source RTOS is FreeRTOS (http://www.freertos.org/). It is a robust, mature and widely used OS. Its codebase consists in clean and well-documented standard C language. However, it offers only core features, and doesn’t provide any network subsystem at all. Redeveloping a whole network stack from scratch would have been too time-consuming. (Network extensions exist for FreeRTOS, but they are either immature, or very limited, or proprietary and commercial software; and most of them are tied to a peculiar piece of hardware, thus ruining the portability advantage offered by the OS.) ### 2.4 Summary: Wanted Features To summarize the issue, what we required is an OS that: - is adapted to the limitations of the deeply-embedded MCUs that constitute the core of WSN/IoT motes; - provides real-time features powerful enough to support the development of advanced, high-performance MAC / RDC protocols; - includes a network stack (even a basic one) adapted to wireless communication on 802.15.4 radio medium. However, none of the established OSes commonly used either in the IoT domain (TinyOS, Contiki) nor in the larger spectrum of RTOS (FreeRTOS) could match our needs. ### 3 THE RIOT OPERATING SYSTEM Consequently, we focused our interest on RIOT OS (Hahm et al., 2013). This new system—first released in 2013—is also open-source and specialized in the domain of low-power, embedded wireless sensors. It offers many interesting features, that we will now describe. It provides the basic benefits of an OS: portability (it has been ported to many devices powered by ARM, MSP430, and—more recently—AVR microcontrollers) and a comprehensive set of features, including a network stack. Moreover, it offers key features that are otherwise yet unknown in the WSN/IoT domain: - an efficient, interrupt-driven, tickless micro-kernel; - that kernel includes a priority-aware task scheduler, providing pre-emptive multitasking; - a highly efficient use of hardware timers: all of them can be used concurrently (especially since the kernel is tickless), offering the ability to schedule actions with high granularity; on low-end devices, based on MSP430 architecture, events can be scheduled with a resolution of 32 microseconds; • RIOT is entirely written in standard C language; but unlike Contiki, there are no restrictions on usable constructs (i.e.: like those introduced by the protothreads mechanism); • a clean and modular design, that makes development with and into the system itself easier and more productive. The first three features listed hereabove make RIOT a full-fledged real-time operating system. We also believe that the tickless kernel and the optimal use of hardware timers should make RIOT OS a very suited software platform to optimize energy consumption on battery-powered, MCU-based devices. A drawback of RIOT, compared to TinyOS or Contiki, is its higher memory footprint: the full network stack (from PHY driver up to RPL routing with 6LoWPAN and MAC / RDC layers) cannot be compiled for Sky/TelosB because of overflowing memory space. Right now, constrained devices like MSP430-based motes are limited to the role of what the 802.15.4 standard calls Reduced Function Devices (RFD), the role of Full Function Devices (FFD) being reserved to more powerful motes (i.e.: based on ARM microcontrollers). However, we also note that, thanks to its modular architecture, the RIOT kernel, compiled with only PHY and MAC / RDC layers, is actually lightweight and consumes little memory. We consequently believe that the current situation will improve with the maturation of higher layers of RIOT network stack, and that in the future more constrained devices could also be used as FFD with RIOT OS. When we began to work with RIOT, it also had two other issues: the MSP430 versions were not stable enough to make real use of the platform; and beyond basic CSMA/CA, no work related to the MAC / RDC layer had been done on that system. This is where our contributions fit in. 4 OUR CONTRIBUTIONS For our work, we use—as our main hardware platform—IoT motes built around MSP430 microcontrollers. MSP430 is a microcontroller (MCU) architecture from Texas Instruments, offering very low-power consumption, cheap price, and good performance thanks to a custom 16-bit RISC design. This architecture is very common in IoT motes. It is also very well supported, especially by the Cooja simulator (Österlind et al., 2006), which makes simulations of network scenarios—especially with many devices—much easier to design and test. RIOT OS has historically been developed first on legacy ARM devices (ARM7TDMI-based MCUs), then ported on more recent microcontrollers (ARM Cortex-M) and other architectures (MSP430 then AVR). However, the MSP430 port was, before we improved it, still not as “polished” as ARM code and thus prone to crash. Our contribution can be summarized in the following points: 1. analysis of current OSes (TinyOS, Contiki, etc.) limitations, and why they are incompatible with development of real-time extensions like advanced MAC / RDC protocols; 2. add debugging features to the RIOT OS kernel, more precisely a mechanism to handle fatal errors: crashed systems can be “frozen” to facilitate debugging during development; or, in production, can be made to reboot immediately, thus reducing unavailability of a RIOT-running device to a minimum; 3. port RIOT OS to a production-ready, MSP430-based device: the Zolertia Z1 mote (already supported by Contiki, and used in real-world scenarios running that OS); 4. debug the MSP430-specific portion of RIOT OS—more specifically: the hardware abstraction layer (HAL) of the task scheduler—making RIOT OS robust and production-ready on MSP430-based devices. Note that all of these contributions have been reviewed by RIOT’s development team and integrated into the “master” branch of RIOT OS’ Github repository (i.e.: they are now part of the standard code base of the system). 5. running on MSP430-based devices also allows RIOT OS applications to be simulated with the Cooja simulator; this greatly improves speed and ease of development. 6. thanks to these achievements, we now have a robust and full-featured software platform offering all the features needed to develop high-performance MAC/RDC protocols—such as all of the time-slotted protocols. As a proof of concept of this last statement, we have implemented one of our own designs, and obtained very promising results, shown in the next section. 5 USE CASE: IMPLEMENTING THE S-COSENS RDC PROTOCOL 5.1 The S-CoSenS Protocol The first protocol we wanted to implement is S-CoSenS (Nefzi, 2011), which is designed to work on top of the IEEE 802.15.4 physical and MAC (i.e.: CSMA/CA) layers. It is an evolution of the already published CoSenS protocol (Nefzi and Song, 2010): it adds to the latter a sleeping period for energy saving. Thus, the basic principle of S-CoSenS is to delay the forwarding (routing) of received packets, by dividing the radio duty cycle in three periods: a sleeping period (SP), a waiting period (WP) where the radio medium is listened by routers for collecting incoming 802.15.4 packets, and finally a burst transmission period (TP) for emitting adequately the packets enqueued during WP. The main advantage of S-CoSenS is its ability to adapt dynamically to the wireless network throughput at runtime, by calculating for each radio duty cycle the length of SP and WP, according to the number of relayed packets during previous cycles. Note that the set of the SP and the WP of a same cycle is named subframe; it is the part of a S-CoSenS cycle whose length is computed and known a priori; on the contrary, TP duration is always unknown up to its very beginning, because it depends on the amount of data successfully received during the WP that precedes it. The computation of WP duration follows a “sliding average” algorithm, where WP duration for each duty cycle is computed from the average of previous cycles as: \[ WP_n = \alpha \cdot WP_{n-1} + (1 - \alpha) \cdot WP_{n-1} \] \[ WP_n = \max(WP_{\min}, \min(WP_n, WP_{\max})) \] where \(WP_n\) and \(WP_{n-1}\) are respectively the average WP length at \(n^{th}\) and \((n-1)^{th}\) cycle, while WP_n and WP_{n-1} are the actual length of respectively the \(n^{th}\) and \((n-1)^{th}\) cycles; \(\alpha\) is a parameter between 0 and 1 representing the relative weight of the history in the computation, and WP_min and WP_max are high and low limits imposed by the programmer to the WP duration. The length of the whole subframe being a parameter given at compilation time, SP duration is simply computed by subtracting the calculated duration of WP from the subframe duration for every cycle. The local synchronization between a S-CoSenS router and its leaf nodes is done thanks to a beacon packet, that is broadcasted by the router at the beginning of each cycle. This beacon contains the duration (in microseconds) of the SP and WP for the currently beginning cycle. The whole S-CoSenS cycle workflow for a router is summarized in figure 1 hereafter. --- ![Figure 1: A typical S-CoSenS router cycle.](image) --- An interesting property of S-CoSenS is that leaf (i.e.: non-router) nodes always have their radio transceiver offline, except when they have packets to send. When a data packet is generated on a leaf node, the latter wakes up its radio transceiver, listens and waits to the first beacon emitted by an S-CoSenS router, then sends its packet using CSMA/CA at the beginning of the WP described in the beacon it received. A leaf node will put its transceiver offline during the delay between the beacon and that WP (that is: the SP of the router that emitted the received beacon), and will go back to sleep mode once its packet is transmitted. All of this procedure is shown in figure 2. --- ![Figure 2: A typical transmission of a data packet with the S-CoSenS protocol between a leaf node and a router.](image) --- ods are dynamically calculated at runtime, with resolution that needs to be in the sub-millisecond range. This is where RIOT OS advanced real-time features really shine, while the other comparable OSes are for that purpose definitely lacking. 5.2 Simulations and Synchronization Accuracy We have implemented S-CoSenS under RIOT, and made first tests by performing simulations—with Cooja—of a 802.15.4 PAN (Personal Area Network) constituted of a router, and ten motes acting as “leaf nodes”. The ten nodes regularly send data packets to the router, that retransmits these data packets to a nearby “sink” device. Both the router and the ten nodes use exclusively the S-CoSenS RDC/MAC protocol. This is summarized in figure 3. ![Figure 3: Functional schema of our virtual test PAN.](image) Our first tests clearly show an excellent synchronization between the leaf nodes and the router, thanks to the time resolution offered by RIOT OS event management system (especially the availability of many hardware timers for direct use). This can be seen in the screenshot of our simulation in Cooja, shown in figure 4. For readability, the central portion of the timeline window of that screenshot (delimited by a thick yellow rectangle) is zoomed on in figure 5. On figure 5, the numbers on the left side are motes’ numerical IDs: the router has ID number 1, while the leaf nodes have IDs 2 to 11. Grey bars represent radio transceiver being online for a given mote; blue bars represent packet emission, and green bars correct packet reception, while red bars represent collision (when two or more devices emit data concurrently) and thus reception of undecipherable radio signals. Figure 5 represents a short amount of time (around 100 milliseconds), representing the end of a duty cycle of the router: the first 20 milliseconds are the end of SP, and 80 remaining milliseconds the WP, then the beginning of a new duty cycle (the TP has been disabled in our simulation). In our example, four nodes have data to transmit to the router: the motes number 3, 5, 9, and 10; the other nodes (2, 4, 6, 7, 8, and 11) are preparing to transmit a packet in the next duty cycle. At the instant marked by the first yellow arrow (in the top left of figure 5), the SP ends and the router activates its radio transceiver to enter WP. Note how the four nodes that are to send packets (3, 5, 9, and 10) do also activate their radio transceivers precisely at the same instant: this is thanks to RIOT OS precise real-time mechanism (based on hardware timers), that allows to the different nodes to precisely synchronize on the timing values transmitted in the previous beacon packet. Thanks also to that mechanism, the nodes are able to keep both their radio transceiver and their MCU in low-power mode, since RIOT OS kernel is interrupt-driven. During the waiting period, we also see that several collisions occur; they are resolved by the S-CoSenS protocol by forcing motes to wait a random duration before re-emitting a packet in case of conflict. In our example, our four motes can finally transmit their packet to the router in that order: 3 (after a first collision), 5, 10 (after two other collisions), and finally 9. Note that every time the router (device number 1) successfully receives a packet, an acknowledgement is sent back to emitter: see the very thin blue bars that follow each green bar on the first line. Finally, at the instant marked by the second yellow arrow (in the top right of figure 5), WP ends and a new duty cycle begins. Consequently, the router broadcasts a beacon packet containing PAN timing and synchronization data to all of the ten nodes. We can see that all of the six nodes waiting to transmit (2, 4, 6, 7, 8, and 11) go idle after receiving this beacon (beacon packets are broadcasted and thus not to be acknowledged): they go into low-power mode (both at radio transceiver and MCU level), and will take advantage of RIOT real-time features to wake up precisely when the router goes back into WP mode and is ready to receive their packets. 5.3 Performance Evaluation: Preliminary Results We will now present the first, preliminary results we obtained through the simulations we described hereabove. Important: note that we evaluate here the im- Figure 4: Screenshot of our test simulation in Cooja. (Despite the window title mentioning Contiki, the simulated application is indeed running on RIOT OS.) Figure 5: Zoom on the central part of the timeline of our simulation. Figure 6: PRR results for both ContikiMAC and S-CoSenS RDC protocols, using default values for parameters. Table 1: PRR results for both ContikiMAC and S-CoSenS RDC protocols, using default values for parameters. <table> <thead> <tr> <th>Packet Arrival Interval</th> <th>ContikiMAC</th> <th>S-CoSenS</th> </tr> </thead> <tbody> <tr> <td>1500 ms</td> <td>49.70%</td> <td>98.10%</td> </tr> <tr> <td>1000 ms</td> <td>32.82%</td> <td>96.90%</td> </tr> <tr> <td>500 ms</td> <td>14.44%</td> <td>89.44%</td> </tr> <tr> <td>100 ms</td> <td>0.64%</td> <td>25.80%</td> </tr> </tbody> </table> Figure 7: End-to-end delays results for both ContikiMAC and S-CoSenS RDC protocols, using default values for parameters; note that vertical axis is drawn with logarithmic scale. Table 2: End-to-end delays results for both ContikiMAC and S-CoSenS RDC protocols, using default values for parameters. <table> <thead> <tr> <th>Packet Arrival Interval</th> <th>ContikiMAC</th> <th>S-CoSenS</th> </tr> </thead> <tbody> <tr> <td>1500 ms</td> <td>3579 ms</td> <td>108 ms</td> </tr> <tr> <td>1000 ms</td> <td>4093 ms</td> <td>108 ms</td> </tr> <tr> <td>500 ms</td> <td>6452 ms</td> <td>126 ms</td> </tr> <tr> <td>100 ms</td> <td>12913 ms</td> <td>168 ms</td> </tr> </tbody> </table> We have first focused on QoS results, by computing Packet Reception Rates and end-to-end delays between the various leaf nodes and the sink of the test PAN presented earlier in figure 3, to evaluate the quality of the transmissions allowed by using both of the protocols. For these first tests, we used default parameters for both RDC protocols (ContikiMAC and S-CoSenS), only pushing the CSMA/CA MAC layer of Contiki to make up to 8 attempts for transmitting a same packet, so as to put it on par with our implementation on RIOT OS. We have otherwise not yet tried to tweak the various parameters offered by both the RDC protocols to optimize results. This will be the subject of our next experiences. 5.3.1 Packet Reception Rates (PRR) The result obtained for PRR using both protocols are shown in figure 6 as well as table 1. The advantage of S-CoSenS as shown on the figure is clear and significant whatever the packet arrival interval constated. Excepted for the “extreme” scenario corresponding to an over-saturation of the radio channel, S-CoSenS achieve an excellent PRR ($\geq 90\%$), while ContikiMAC’s PRR is always $\leq 50\%$. 5.3.2 End-To-End Transmission Delays The result obtained for PRR using both protocols are shown in figure 7 and table 2. S-CoSenS has here also clearly the upper hand, so much that we had to use logarithmic scale for the vertical axis to keep figure 7 easily readable. The advantage of S-CoSenS is valid whatever the packet arrival interval, our protocol being able to keep delay below an acceptable limit (in the magnitude of hundreds of milliseconds), while ContikiMAC delays rocket up to tens of seconds when network load increases. 5.3.3 Summary: QoS Considerations While these are only preliminary results, it seems that being able to leverage real-time features is clearly a significant advantage when designing and implementing MAC/RDC protocols, at least when it comes to QoS results. 6 FUTURE WORKS AND CONCLUSION We plan, in a near future: • to bring new contributions to the RIOT project: we are especially interested in the portability that the RIOT solution offers us; this OS is indeed actively ported on many devices based on powerful microcontrollers based on ARM Cortex-M architecture (especially Cortex-M3 and Cortex-M4), and we intend to help in this porting effort, especially on high-end IoT motes we seek to use in our works (e.g.: as advanced FFD nodes with full network stack, or routers); • to use the power of this OS to further advance our work on MAC/RDC protocols; more precisely, we are implementing other innovative MAC/RDC protocols—such as iQueue-MAC (Zhuo et al., 2013)—under RIOT, taking advantage of its high-resolution real-time features to obtain excellent performance, optimal energy consumption, and out-of-the-box portability. RIOT is a powerful real-time operating system, adapted to the limitations of deeply embedded hardware microcontrollers, while offering state-of-the-art techniques (preemptive multitasking, tickless scheduler, optimal use of hardware timers) that—we believe—makes it one of the most suitable OSes for the embedded and real-time world. While we weren’t able to accurately quantify energy consumption yet, we can reasonably think that lowering activity of MCU and radio transceiver will significantly reduce the energy consumption of devices running RIOT OS. This will be the subject of some of our future research works. Currently, RIOT OS supports high-level IoT protocols (6LoWPAN/IPv6, RPL, TCP, UDP, etc.). However, it still lacks high-performance MAC / RDC layer protocols. Through this work, we have shown that RIOT OS is also suitable for implementing high-performance MAC / RDC protocols, thanks to its real-time features (especially hardware timers management). Moreover, we have improved the robustness of the existing ports of RIOT OS on MSP430, making it a suitable software platform for tiny motes and devices. REFERENCES http://www.tinyos.net/. http://mansos.edi.lv/.
{"Source-Url": "https://hal.archives-ouvertes.fr/hal-01141496/file/sensornets2015.pdf", "len_cl100k_base": 7882, "olmocr-version": "0.1.50", "pdf-total-pages": 12, "total-fallback-pages": 0, "total-input-tokens": 32994, "total-output-tokens": 9861, "length": "2e12", "weborganizer": {"__label__adult": 0.0003631114959716797, "__label__art_design": 0.0004448890686035156, "__label__crime_law": 0.0003597736358642578, "__label__education_jobs": 0.0004515647888183594, "__label__entertainment": 0.00012362003326416016, "__label__fashion_beauty": 0.00020194053649902344, "__label__finance_business": 0.0004167556762695313, "__label__food_dining": 0.0004475116729736328, "__label__games": 0.0005459785461425781, "__label__hardware": 0.0096893310546875, "__label__health": 0.000705718994140625, "__label__history": 0.0005545616149902344, "__label__home_hobbies": 0.00014662742614746094, "__label__industrial": 0.0011053085327148438, "__label__literature": 0.0002219676971435547, "__label__politics": 0.0004014968872070313, "__label__religion": 0.0005908012390136719, "__label__science_tech": 0.446533203125, "__label__social_life": 9.357929229736328e-05, "__label__software": 0.027130126953125, "__label__software_dev": 0.5078125, "__label__sports_fitness": 0.0003426074981689453, "__label__transportation": 0.0009565353393554688, "__label__travel": 0.00026488304138183594}, "weborganizer_max": "__label__software_dev", "avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_ratio": [[0, 38703, 0.03265]], "fineweb_edu_fasttext_gt2__fineweb_edu_fasttext_gt2__score": [[0, 38703, 0.33778]], "ft_lang_id_en_doc_v2__ft_lang_id_en_doc_v2__en": [[0, 38703, 0.91144]], "google_gemma-3-12b-it_contains_pii": [[0, 1015, false], [1015, 4283, null], [4283, 8681, null], [8681, 13316, null], [13316, 17199, null], [17199, 21465, null], [21465, 24944, null], [24944, 29216, null], [29216, 29444, null], [29444, 32527, null], [32527, 36989, null], [36989, 38703, null]], "google_gemma-3-12b-it_is_public_document": [[0, 1015, true], [1015, 4283, null], [4283, 8681, null], [8681, 13316, null], [13316, 17199, null], [17199, 21465, null], [21465, 24944, null], [24944, 29216, null], [29216, 29444, null], [29444, 32527, null], [32527, 36989, null], [36989, 38703, null]], "google_gemma-3-4b-it_v2tag__is_academic_paper": [[0, 5000, true], [5000, 38703, null]], "google_gemma-3-4b-it_v2tag__is_class_syllabus": [[0, 5000, false], [5000, 38703, null]], "google_gemma-3-4b-it_v2tag__is_completion_certificate": [[0, 5000, false], [5000, 38703, null]], "google_gemma-3-4b-it_v2tag__is_court_notice": [[0, 5000, false], [5000, 38703, null]], "google_gemma-3-4b-it_v2tag__is_homework_assignment": [[0, 5000, false], [5000, 38703, null]], "google_gemma-3-4b-it_v2tag__is_news_article": [[0, 5000, false], [5000, 38703, null]], "google_gemma-3-4b-it_v2tag__is_public_order": [[0, 5000, false], [5000, 38703, null]], "google_gemma-3-4b-it_v2tag__is_resume_cv": [[0, 5000, false], [5000, 38703, null]], "google_gemma-3-4b-it_v2tag__is_test_or_quiz": [[0, 5000, false], [5000, 38703, null]], "google_gemma-3-4b-it_v2tag__is_textbook": [[0, 5000, false], [5000, 38703, null]], "pdf_page_numbers": [[0, 1015, 1], [1015, 4283, 2], [4283, 8681, 3], [8681, 13316, 4], [13316, 17199, 5], [17199, 21465, 6], [21465, 24944, 7], [24944, 29216, 8], [29216, 29444, 9], [29444, 32527, 10], [32527, 36989, 11], [36989, 38703, 12]], "pipe_delimited_lines_v1__pipe_delimited_lines_v1__pipe_delimited_lines_ratio": [[0, 38703, 0.06349]]}
olmocr_science_pdfs
2024-11-30
2024-11-30
bdf338f631624e01a3d67236d9cc38817327046d
[REMOVED]
{"Source-Url": "http://www.mini.pw.edu.pl/~mandziuk/dynamic/wp-content/uploads/IS-2014.pdf", "len_cl100k_base": 6379, "olmocr-version": "0.1.50", "pdf-total-pages": 12, "total-fallback-pages": 0, "total-input-tokens": 28321, "total-output-tokens": 8612, "length": "2e12", "weborganizer": {"__label__adult": 0.002079010009765625, "__label__art_design": 0.00124359130859375, "__label__crime_law": 0.003292083740234375, "__label__education_jobs": 0.003047943115234375, "__label__entertainment": 0.0009164810180664062, "__label__fashion_beauty": 0.00109100341796875, "__label__finance_business": 0.0012140274047851562, "__label__food_dining": 0.0024871826171875, "__label__games": 0.314453125, "__label__hardware": 0.003192901611328125, "__label__health": 0.0023555755615234375, "__label__history": 0.001822471618652344, "__label__home_hobbies": 0.0004258155822753906, "__label__industrial": 0.002285003662109375, "__label__literature": 0.0018157958984375, "__label__politics": 0.0016908645629882812, "__label__religion": 0.0020160675048828125, "__label__science_tech": 0.169677734375, "__label__social_life": 0.0003161430358886719, "__label__software": 0.01020050048828125, "__label__software_dev": 0.468505859375, "__label__sports_fitness": 0.0035343170166015625, "__label__transportation": 0.0015811920166015625, "__label__travel": 0.0008444786071777344}, "weborganizer_max": "__label__software_dev", "avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_ratio": [[0, 35292, 0.04984]], "fineweb_edu_fasttext_gt2__fineweb_edu_fasttext_gt2__score": [[0, 35292, 0.42236]], "ft_lang_id_en_doc_v2__ft_lang_id_en_doc_v2__en": [[0, 35292, 0.92371]], "google_gemma-3-12b-it_contains_pii": [[0, 2060, false], [2060, 4915, null], [4915, 8327, null], [8327, 10924, null], [10924, 14007, null], [14007, 17218, null], [17218, 20702, null], [20702, 24048, null], [24048, 26524, null], [26524, 29221, null], [29221, 32381, null], [32381, 35292, null]], "google_gemma-3-12b-it_is_public_document": [[0, 2060, true], [2060, 4915, null], [4915, 8327, null], [8327, 10924, null], [10924, 14007, null], [14007, 17218, null], [17218, 20702, null], [20702, 24048, null], [24048, 26524, null], [26524, 29221, null], [29221, 32381, null], [32381, 35292, null]], "google_gemma-3-4b-it_v2tag__is_academic_paper": [[0, 5000, true], [5000, 35292, null]], "google_gemma-3-4b-it_v2tag__is_class_syllabus": [[0, 5000, false], [5000, 35292, null]], "google_gemma-3-4b-it_v2tag__is_completion_certificate": [[0, 5000, false], [5000, 35292, null]], "google_gemma-3-4b-it_v2tag__is_court_notice": [[0, 5000, false], [5000, 35292, null]], "google_gemma-3-4b-it_v2tag__is_homework_assignment": [[0, 5000, false], [5000, 35292, null]], "google_gemma-3-4b-it_v2tag__is_news_article": [[0, 5000, false], [5000, 35292, null]], "google_gemma-3-4b-it_v2tag__is_public_order": [[0, 5000, false], [5000, 35292, null]], "google_gemma-3-4b-it_v2tag__is_resume_cv": [[0, 5000, false], [5000, 35292, null]], "google_gemma-3-4b-it_v2tag__is_test_or_quiz": [[0, 5000, false], [5000, 35292, null]], "google_gemma-3-4b-it_v2tag__is_textbook": [[0, 5000, false], [5000, 35292, null]], "pdf_page_numbers": [[0, 2060, 1], [2060, 4915, 2], [4915, 8327, 3], [8327, 10924, 4], [10924, 14007, 5], [14007, 17218, 6], [17218, 20702, 7], [20702, 24048, 8], [24048, 26524, 9], [26524, 29221, 10], [29221, 32381, 11], [32381, 35292, 12]], "pipe_delimited_lines_v1__pipe_delimited_lines_v1__pipe_delimited_lines_ratio": [[0, 35292, 0.20536]]}
olmocr_science_pdfs
2024-11-29
2024-11-29
e4c04ed0eff4298070bc373d25c92cf4ebd14e81
Combining programming by example and real-world analogies, users create new behavior out of existing behavior. Programming by Analogous Examples Why do end users need to program? Anyone can become overwhelmed trying to cope with information in a world flooded by information. In light of the ubiquity of computer networks, the information challenge for end users is no longer about accessing information but about processing it. The direct-manipulation paradigm, popularized in the 1980s, begins to break down when they are unable to directly manipulate the sources or their information, such as the location of their files on a hard drive or the emails in their in-boxes. End-user programming is emerging as a crucial instrument in the daily information-processing struggle [8]. Such programming allows customized personal information processing. But few end users have the background, motivation, or time to use traditional programming approaches or the means to hire professional programmers to create programs for them. Simple forms of end-user programming include email filters to clean up email by directing specified emails into separate folders and spreadsheets to explore, say, the total cost of a new house. Programming by example (PBE) is a powerful end-user-programming paradigm enabling users without formal training in programming to create sophisticated programs. PBE environments create programs for end users by observing and recording software behaviors as they manipulate information on the graphical user interface (GUI) level. For example, in Microsoft Word, PBE mechanisms allow users to build macros. Here, we explore the problem of PBE reuse, or how users can reuse old program behavior. A user might find a PBE-generated program useful but may need to either generalize or modify it for a related but different task. Program reuse is a well-known software design problem. Reuse problems hamper the productivity of a wide range of software projects—from individual end-user programmers to large distributed teams of software developers. In the PBE context, reuse poses even more complex issues. While PBE initially shields end users from having to deal with programming issues, reuse forces them to leap cognitively between two levels of representation: **The GUI level.** This level features familiar windows, icons, and menus. For instance, in a word processing application, such as Word, this level represents content directly manipulated by users with such operations as the typing of new text, the formatting of text, and the use of cursor keys to navigate through a document. **The program level.** This level captures user manipulations directly into programs so users can replay them. In Word, this level incorporates Visual Basic. User manipulations are recorded as Visual Basic scripts; users then assign scripts to keyboard commands or to user-defined toolbar commands. The PBE representation chasm mirrors the difficulty users have comprehending the mapping between the GUI level and the program level. In reuse, this chasm is especially problematic, because users are required to have at least a minimal understanding of the program-level representations—if they want to be able to adapt these representations to their needs. For end users with no previous exposure to programming in Visual Basic or even to programming in general, this transition may be too complex and leave them frustrated. Frustrated, they may give up on the idea of end-user programming and continue to solve their original problems manually over and over again for years. Analogies are powerful cognitive mechanisms people use to construct new knowledge from knowledge they’ve already acquired and understand. When analogies are used with PBE, the result is a new end-user programming paradigm combining the elegance of PBE to create programs and the power of analogies to reuse existing programs. We call the combination of PBE and analogies “programming by analogous examples.” Analogies are an effective representation level bridging the GUI and program levels. Two detailed examples help us explore the reuse problem. In the first, we created a Word macro for repetitive reformatting in order to understand macro reuse. We chose this particular example not because the Word macro recording mechanism is the most sophisticated PBE system, but because Word has an enormous user base, and readers may be able to relate more read- ily to use and reuse issues in the Word context. In the second example, we built a SimCity-like simula- tion using the AgentSheets simulation authoring this tool provides an end-user programming approach considerably more accessible than Visual Basic. We’ve found that even when the program level is relatively accessible, analogies are still needed as a PBE reuse mechanism. As PBE techniques become more widely adopted in both commercial and research systems, end users incrementally construct and edit new behavior and commands as needed. As in conventional program- ming approaches, the effective reuse of new behavior is limited by the underlying representations. These rep- resentations run the risk of presenting end-user pro- grammers with the same copy-paste-modify and inherit-reuse problems that pro- fessional pro- grammers have struggled with for years. What makes reuse even more problematic in a PBE situation is that the programs that need to be modified for reuse are machine generated, typically containing little information as to how they might be changed. The reuse scenario in Figure 1 involves an end user trying to automatically reformat an address list. Word and other applications allow for modular modification through a macro mechanism. Users are given an interface to program macros by PBE through a menu command called “Record New Macro.” Additional support is given by the macro- editing toolbar and menu functions. Once a macro is named and assigned to a toolbar icon or to a key- board command, it is created simply by performing the desired task—repetitive reformatting in our example. The system records keystrokes and com- piles the command into Visual Basic. The command can then be invoked by anyone editing a document. End users want to modify regularly and, hence, reuse a macro with additional, related actions, then assign the entire new set of changes to the same key- board command. Mechanisms are built into Word for renaming the macro, thus copying the same behavior, but any modification to an existing macro must be done through the Visual Basic program- ning language. For instance, how would a user have to modify the macro to reformat not just the Fax: but also the Address: fields in Figure 1. To modify this macro through the “Record” function, a user would have to overwrite the old macro, go through the same actions that were recorded ear- lier, and then record the desired additional behavior. To be able to reuse existing macros, making them useful in more general situations, end users have to drop from the GUI level (Figure 1, left) to the pro- gram level (Figure 1, right). According to Microsoft’s own Word documentation: “Recorded macros are great when you want to perform exactly the same task every time you run the macro. But what if you want to automate a task in which actions vary with the situation, or depend on user input … ? To create powerful automations, you should learn to program in Visual Basic for Applica- tions.” There is a large cog- nitive chasm between the two levels. The GUI one provides only limited options for reuse. Even though advanced reuse requires making a transition to the program level, no inter- mediate steps are provided to take the user from the simple recording mechanism to the Visual Basic programming language. At the GUI level, users are limited in reuse to copying macros as black boxes into other documents or to making macros gener- ally available to all documents. At the program level, code may be copied, pasted, and modified with the same difficulty as these commands are invoked in any other object-oriented program. At this point, the user has jumped from the comfort- able environment of direct manipulation at the GUI level directly into the uncomfortable or down- right frustrating program level. How Analogies Bridge the Chasm The AgentSheets simulation authoring tool helps explain how analogies in a PBE system can bridge the chasm between the GUI level and the program level. In AgentSheets, end users can build SimCity- like simulations and export them as interactive Java applets. (For a detailed description of AgentSheets, see www.agentsheets.com/userforum-publications. html.) AgentSheets combines PBE with graphical rewrite rules into an end-user programming para- Graphical rewrite rules (GRRs), which are also used in such systems as Cocoa/KidSim and Creator, are powerful languages for expressing the concept of change in a visual representation. GRRs declaratively describe spatial transformations with a sequence of two or more dimensional situations containing objects. Situations can be interpreted with respect to objects contained in them and the spatial relationships among these objects. The differences among situations imply one or more actions capable of transforming one situation into another. In AgentSheets, any number of GRRs can be aggregated to create complex behaviors for agents; these agents and their behaviors combine and interact to simulate any scenario a user can imagine—from heat diffusion to urban planning. We have found it likely that behaviors created in one simulation are valuable to users building other simulations (see Figure 2). Compared to the GUI-program chasm in Word, the GUI-program chasm in AgentSheets is much less daunting for end users. The GRR representation at the program level closely matches the representation at the GUI level. For instance, the user-produced train and train-track icons at the GUI level are also found at the program level. This representational mapping helps end users comprehend programs. But despite the closer match, it is still necessary for any end-user-programmable application to have a mechanism for dealing with reuse. **An Analogy (Making Cars Move Like Trains)** In an application called Sustainopolis used by urban planners to explore public transportation issues, an end user would want to incorporate cars and streets. Noticing that trains and tracks are already programmed and realizing that cars move on streets much like trains move on tracks, the user would want to reuse the “move” behavior already written for the train object and attach it to the car object. One approach would be for the user to start from scratch and simply demonstrate all the examples of car and street interactions. Unfortunately, the set of rules attached to the train is quite large. The problem is that even for a relatively simple behavior, such as making the train follow the track, rules have to be demonstrated to specify all the meaningful combinations of interactions between trains and tracks. Trains are capable of heading in four different directions—north, south, east, and west. A complete specification accounting for 15 different train-track pieces—straight; four orientations of curves; four different T intersections and one crossing; and four orientations of cul-de-sacs—requires 256 rules. These rules specify behavior in various situations, including: What if the train drives into a cul-de-sac? and Which way should the train go if it has a choice of going left or right? If the tracks are arranged care- fully in the simulation, a good number of rules can be eliminated, but the point remains that it must have taken quite some time and patience to demonstrate the complete set of rules. Given that this behavior exists already in our scenario, it would be preferable to find a way to avoid having to demonstrate the entire set of rules again to specify the conceptually similar interaction between cars and streets. A different approach is to copy all the train's rules into the car and manually edit them by substituting corresponding icons. In most GRR-based systems, the user would then copy all the rules from trains and tracks to streets and cars, then simply substitute cars for trains and streets for tracks. But transferring rules from one application scenario to another is basically the same arduous, error-prone process a programmer goes through to reuse a program or a Word user goes through to reuse a macro. So, is the user's time being saved? Without understanding what the user intends, how can the system facilitate the reuse process? We have found that the mechanism allowing an end user to program allows reuse as well. Programming by analogous examples supports the reuse of previously recorded example programs. Instead of creating car behavior from scratch—either through demonstration or through manual editing—users generate a complete set of rules by specifying an analogy. It is the relationship between trains and tracks that the user wishes to reuse for cars and streets. In contrast to object-oriented programming in which inheritance is used to define an ontology of object classes, analogies are used to define an ontology of object relationships represented by common active verbs, such as “move” (see Figure 3). The user defines analogies through the analogy dialogue box (see Figure 4). The result is that the behavior programmed through GRRs for trains moving on tracks is transferred to cars moving on streets. The verb “moves” is differentiated for trains and cars, so trains do not move on streets, nor do cars move on tracks, because no relationship is implied between trains and streets, or between cars and tracks. Here, reuse is expressed in terms of existing objects, and abstractions are not required. The result of the analogy is a new set of GRRs attached to cars, allowing them to move on streets. All the rules generated by analogy are like ordinary GRRs in that the end user edits them to deal with exceptions to the analogy. Fortunately, PBE systems often feature representations that—through the use of analogies—serve as a bridge between the GUI level and the program level. In the train-car analogy, the end user created new behavior out of existing behavior. This method employs reuse-enhanced programming in which an initial set of programs is created through PBE and then extended through analogies. At what depth does an analogy mechanism need to “understand” a program to create an analogous pro- gram? Mere syntactic symbol substitution is insufficient for the transformation of nontrivial programs. A deep understanding of the program semantic is not only an extraordinarily difficult and unsolved AI problem, but developing analogies would probably require users to annotate programs extensively with semantic information. From Substitutions to Analogies In the analogy specified in Figure 3, the four icons are from a much larger set of icons representing cars and trains with different headings, as well as streets and tracks representing different topologies. A mechanism that would merely substitute the car and street icons for the train and track icons in order to create a set of analogous rewrite rules would not be very useful; it would match only a limited subset of all relevant rules. How does the analogy system establish the more general mapping among all these different but related items? Analogy mechanisms cannot stop at syntactic substitution but need access to some minimal semantic information in order to establish more general correspondence. It is no trivial matter for a computer system to substitute correctly at all the necessary levels to render the resulting code usable without further editing by a human. More than 10 years ago, Clayton Lewis at the University of Colorado in Boulder proposed a concept he called “pupstitution” to decrease the brittleness inherent in straight copy-and-paste techniques [5]. In the AgentSheets substrate, “systematicity,” or correspondence, in analogy is facilitated through structural and behavioral similarity between the base and target objects [9]. Analogies are made by specifying which relationship should be transferred. For example, cars and trains are objects that can be as simple or as complex as a user wants and can include a single applicable behavior or many behaviors. However, the user has to specify that cars move like trains to transfer this specific behavior. And for the transfer to occur with a high degree of systematicity (and effectiveness to the user), the street and track objects must be structurally similar. AgentSheets assures this high-fidelity transfer with connectivity information. From the base icons created for the urban-planning icon gallery, the system applies syntactic transformations at the user’s request, automatically creating meaningful variations to illustrate intersections and curves, as well as directional orientation [10]. Syntactic transformations create the visual variations necessary for placing the agents on the AgentSheets worksheet and saves the user hours of work on icon depictions. Icons are then annotated by the user with semantic information, such as connectivity (see Figure 5). Connectivity defines the input and output ports for each icon. For instance, a horizontal street segment icon has inputs/outputs to its left and right. Transforming the annotated track creates an entire family of track icons that act essentially as throughputs for objects moving on them. The system uses an icon’s semantic and syntactic connectivity information to support pupstitution in programming by analogous examples. By specifying the connectivity of an icon, then transforming it, the “move” GRR acquires a useful dimension of complexity. After the analogy is established, cars have a rule set that is isomorphic to the train rule set, that is, cars know how to move on all kinds of streets. The system uses the semantic information available to ensure high systematicity between the base and the target; thus, the correct mapping between tracks and streets is established without the end user’s intervention. The general insight we derived is that a little semantics is necessary for creating meaningful analogies. This means that end users have to provide some additional up-front information to annotate their designs with minimal semantic annotation. It also means that this kind of semantic annotation dramatically improves the reusability of behavior. For AgentSheets, users need to provide only semantic information to the base agents, specifying, say, the connectivity of a street agent they have already defined. AgentSheets can automatically transform agents representing flow conductors, including streets, wires, and pipes—syntactically (by applying geometric transformations to the agent bitmap) and semantically (by applying topological transformations to the agent’s connectivity). **Reuse through Inheritance** In object-oriented programming, in order to facilitate reuse, inheritance can serve the role of the reuse mechanism in PBE systems. An object subclass not only inherits the behavior of the superclass but can overwrite and extend that behavior. How would inheritance work in our trains and cars example? One easy way to get analogous behavior is to make “car” a type of, or subclass of, “train,” and “street” a subclass of “track.” While this approach produces the desired behavior (due to inheritance), it is ontologically unsound, and changing the object hierarchy in this way produces a misleading model based on weak design. To correct this problem, system developers expect end users to be a bit more like programmers. Therefore, in the class hierarchy, cars become siblings of trains and streets siblings of tracks through two abstract superclasses—“moving-object” and “movement-guiding-object.” For the user to get the trains and cars to move, a generalized GRR has to be expressed in terms of “moving object” and “movement-guiding-object.” However, while this new class hierarchy may be ontologically sound, it also introduces a couple of problems: **Need for abstractions.** Abstractions for end users are nontrivial and difficult to represent visually, especially when objects are represented by user-defined icons. How would abstract objects embodying moving objects and movement-guiding objects look, and who would have to draw them? **Overgeneralization.** If city traffic is run with this new representation in place, trains can move on streets and cars can move on tracks; although this scenario is a theoretical possibility, it should not be allowed to happen in the urban-planning-domain application. In order to get around this real-life constraint, the behavior of trains and cars would have to be specialized again to prevent such unwanted combinations of moving objects and movement-guiding objects. **Conclusion** In PBE systems, the representation end users see at the GUI level may differ greatly from the representation at the program level. In these systems, special representations are often used to ease the end user’s transition between the two levels. These representational features enable programming by analogous examples, simplifying program reuse. Our work with programming by analogous examples is at an early but promising stage. The combination of some semantic information with structural information has allowed the reuse of complex behaviors in the context of interactive simulations. The more similarity there is between behavior the user has created and wants to reuse and the target behavior, the better is the analogy and the less likely the need for editing. We seek to increase differentiation by end users trying to determine appropriate analogical matches. For instance, cars moving on streets and electricity moving through wires share similarities, but electricity can go in both directions at an intersection. Therefore, an analogy between these two classes of object would produce crash-prone cars. We'll soon also explore the use of programming by analogous examples in nonsimulation application domains. References Alexander Repenning (ralex@cs.colorado.edu) is CEO of AgentSheets, Inc., and a professor in the Department of Computer Science and the Center of LifeLong Learning & Design at the University of Colorado in Boulder. Corrina Perrone (corrina@agentsheets) is a project manager in AgentSheets, Inc., and director of media relations for an international nonprofit organization. This research is supported by the National Science Foundation under grants: DMI-9761360, RED 925-3425, Supplement to RED 925-3425, REC 9804930, REC-9631396, and CDA-940860. Permission to make digital or hard copies of all or part of this work for personal or classroom use is granted without fee provided that copies are not made or distributed for profit or commercial advantage and that copies bear this notice and the full citation on the first page. To copy otherwise, to republish, to post on servers or to redistribute to lists, requires prior specific permission and/or a fee.
{"Source-Url": "http://web.engr.oregonstate.edu/~burnett/CS589and584/CS589-papers/CACM-Mar2000-repenning.pdf", "len_cl100k_base": 4530, "olmocr-version": "0.1.49", "pdf-total-pages": 8, "total-fallback-pages": 0, "total-input-tokens": 21633, "total-output-tokens": 5630, "length": "2e12", "weborganizer": {"__label__adult": 0.0002658367156982422, "__label__art_design": 0.00034618377685546875, "__label__crime_law": 0.0002570152282714844, "__label__education_jobs": 0.001407623291015625, "__label__entertainment": 6.41942024230957e-05, "__label__fashion_beauty": 0.00010728836059570312, "__label__finance_business": 0.00019216537475585935, "__label__food_dining": 0.00023877620697021484, "__label__games": 0.0003616809844970703, "__label__hardware": 0.0004954338073730469, "__label__health": 0.0002837181091308594, "__label__history": 0.0001621246337890625, "__label__home_hobbies": 7.957220077514648e-05, "__label__industrial": 0.0002684593200683594, "__label__literature": 0.00027680397033691406, "__label__politics": 0.00016570091247558594, "__label__religion": 0.0003058910369873047, "__label__science_tech": 0.01152801513671875, "__label__social_life": 9.238719940185548e-05, "__label__software": 0.0078582763671875, "__label__software_dev": 0.974609375, "__label__sports_fitness": 0.0001832246780395508, "__label__transportation": 0.0004000663757324219, "__label__travel": 0.00013339519500732422}, "weborganizer_max": "__label__software_dev", "avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_ratio": [[0, 25236, 0.00846]], "fineweb_edu_fasttext_gt2__fineweb_edu_fasttext_gt2__score": [[0, 25236, 0.78254]], "ft_lang_id_en_doc_v2__ft_lang_id_en_doc_v2__en": [[0, 25236, 0.91605]], "google_gemma-3-12b-it_contains_pii": [[0, 1886, false], [1886, 4451, null], [4451, 8806, null], [8806, 11640, null], [11640, 14599, null], [14599, 17713, null], [17713, 21903, null], [21903, 25236, null]], "google_gemma-3-12b-it_is_public_document": [[0, 1886, true], [1886, 4451, null], [4451, 8806, null], [8806, 11640, null], [11640, 14599, null], [14599, 17713, null], [17713, 21903, null], [21903, 25236, null]], "google_gemma-3-4b-it_v2tag__is_academic_paper": [[0, 5000, true], [5000, 25236, null]], "google_gemma-3-4b-it_v2tag__is_class_syllabus": [[0, 5000, false], [5000, 25236, null]], "google_gemma-3-4b-it_v2tag__is_completion_certificate": [[0, 5000, false], [5000, 25236, null]], "google_gemma-3-4b-it_v2tag__is_court_notice": [[0, 5000, false], [5000, 25236, null]], "google_gemma-3-4b-it_v2tag__is_homework_assignment": [[0, 5000, false], [5000, 25236, null]], "google_gemma-3-4b-it_v2tag__is_news_article": [[0, 5000, false], [5000, 25236, null]], "google_gemma-3-4b-it_v2tag__is_public_order": [[0, 5000, false], [5000, 25236, null]], "google_gemma-3-4b-it_v2tag__is_resume_cv": [[0, 5000, false], [5000, 25236, null]], "google_gemma-3-4b-it_v2tag__is_test_or_quiz": [[0, 5000, false], [5000, 25236, null]], "google_gemma-3-4b-it_v2tag__is_textbook": [[0, 5000, false], [5000, 25236, null]], "pdf_page_numbers": [[0, 1886, 1], [1886, 4451, 2], [4451, 8806, 3], [8806, 11640, 4], [11640, 14599, 5], [14599, 17713, 6], [17713, 21903, 7], [21903, 25236, 8]], "pipe_delimited_lines_v1__pipe_delimited_lines_v1__pipe_delimited_lines_ratio": [[0, 25236, 0.0]]}
olmocr_science_pdfs
2024-11-25
2024-11-25
999d55baf6eb5e047d17b15d72dd19266b0988cb
SOFTWARE TOOL ARTICLE KEGGscape: a Cytoscape app for pathway data integration [version 1; peer review: 1 approved, 2 approved with reservations] Kozo Nishida¹,², Keiichiro Ono³, Shigehiko Kanaya⁴, Koichi Takahashi¹ ¹Laboratory for Biochemical Simulation, RIKEN Quantitative Biology Center, Osaka, 565-0874, Japan ²JST, National Bioscience Database Center (NBDC), Tokyo, 102-0081, Japan ³Department of Medicine, University of California San Diego, La Jolla, CA 92093, USA ⁴Graduate School of Information Science, Nara Institute of Science and Technology, Nara, 630-0101, Japan Abstract In this paper, we present KEGGscape a pathway data integration and visualization app for Cytoscape (http://apps.cytoscape.org/apps/keggscape). KEGG is a comprehensive public biological database that contains large collection of human curated pathways. KEGGscape utilizes the database to reproduce the corresponding hand-drawn pathway diagrams with as much detail as possible in Cytoscape. Further, it allows users to import pathway data sets to visualize biologist-friendly diagrams using the Cytoscape core visualization function (Visual Style) and the ability to perform pathway analysis with a variety of Cytoscape apps. From the analyzed data, users can create complex and interactive visualizations which cannot be done in the KEGG PATHWAY web application. Experimental data with Affymetrix E. coli chips are used as an example to demonstrate how users can integrate pathways, annotations, and experimental data sets to create complex visualizations that clarify biological systems using KEGGscape and other Cytoscape apps. This article is included in the Cytoscape gateway. Introduction Kyoto Encyclopedia of Genes and Genomes (KEGG, http://www.genome.jp/kegg) is a widely used biological database of high-level biological functions. It contains pathway data sets that have comprehensive annotations and high quality human-curated, hand-drawn diagrams. Most biological pathway databases store data as machine-readable graph topologies, which leave much of the details about how the diagrams were drawn excluded from the data files. This is a problem when third-party developers want to reproduce the pathway diagrams in their applications. In contrast, the KEGG PATHWAY database stores graphics information in machine-readable KEGG Markup Language (KGML, http://www.kegg.jp/kegg/xml) format. Thus, in these pathway diagrams, biological entities, such as enzymes or compounds, are manually laid-out and the diagrams are easy to understand for biologists. The KEGG PATHWAY database is deployed as a web application using static bitmap images for pathway diagrams, and user-provided data is integrated with KEGG Mapper (http://www.genome.jp/kegg/mapper.html). Furthermore, KEGG Atlas (http://www.genome.jp/kegg/atlas.html) provides a comprehensive network view of global metabolic pathways. Recent improvements to KEGG Atlas, such as Pathway Projector and iPath2, have made it possible to perform basic data integration and visualization like mapping the expression values to node graphics. However, despite these features, it is difficult to integrate external data sets and create custom visualization. Furthermore, they are limited to those on existing desktop pathway analysis applications. To ameliorate these problems, several projects for integrating a user’s own models onto the KEGG pathways have therefore been developed (CytoSEED Cytoscape app, KEGG-Gtranslator). Cytoscape is a de-facto standard software platform for biological network analysis and visualization. One of its advantages is its large collection of apps for a variety of biological problem domains, such as Gene Ontology term enrichment analysis (BiNGO) and statistical network analysis (CentiScapE), which are also mostly open source software. Additionally, Cytoscape has a flexible network visualization function and is optimized for large-scale network analysis. There are several applications dedicated to biological pathway analysis (Vanted, VisANT) that support KGML by default. Although Cytoscape does not have a built-in function to load biological pathways, if this task is done with a separate app, users can take advantage of its large-scale network analysis features, variety of analysis apps, and data visualization of biologists-friendly human curated pathways. The goal of our new Cytoscape app, KEGGscape, is to bridge the flexibility of fully-featured network analysis platforms with the high-quality pathway diagrams available in the KEGG PATHWAY web application. KEGGscape, a successor of KGMLReader (http://apps.cytoscape.org/apps/kgmlreader) for Cytoscape 2 series, is an app that imports KEGG pathway diagrams from KGML files and provides a new way to use KEGG pathway diagrams as data integration blueprints in cooperation with Cytoscape core features and an existing variety of apps. KEGGscape is completely re-designed for the new Cytoscape 3 API and supports signaling pathways in addition to metabolic pathways, including the global metabolic pathways used in KEGG Atlas (Figure 1). In this paper, we present a basic design and implementation of KEGGscape and an example workflow utilizing KGML files, and experimental data to create information-rich pathway visualizations for clarifying omics-scale data sets. KGMLReader is the first open-source Cytoscape app that reads the graphics details of KGML files, and KEGGscape was designed to use standard Cytoscape features only. These feature enable users to use KEGG pathways with other data sets easily. Implementation KEGGscape is a Cytoscape 3 app written in Java programming language and is designed to load pathway data files in KGML format. Figure 1. A KEGG Global Metabolic Pathway generated with the KEGGscape app. KGML is an XML file format designed by the KEGG project and contains the topology of pathways and visual representations of all elements in the diagram. KGML has formal specification as a DTD (Document Type Definition) file, which enables the use of unmarshaller (https://jaxb.java.net) for converting XML elements directly into Java objects. This conversion creates two types of data: pathway topology and its graphical representations. Pathway topology and its properties are converted into CyNetwork and CyTable objects, which are the standard data model in Cytoscape 3. In KGML, all graphical information, such as the color of enzymes or shape of compounds is stored under <graphics> tag. Instead of setting the graphics details of nodes and edges directly from this information, Cytoscape generates Visual Style, which is a collection of default visual properties and visual mapping function, for each pathway based on the information under this tag. KEGGscape follows a standard CyNetworkReader design guideline, which enables Cytoscape to detect KGML files automatically. Workflow Figure 2 shows an example of a pathway analysis workflow with KEGGscape. To take advantage of the flexible visualization and analysis features in Cytoscape, users need to import as much information as possible for the pathways they want to analyze. Although Cytoscape is a powerful tool for biological data integration, it is not the best platform for data preparation or cleansing. Users can instead prepare annotations and experimental data sets for the pathway using tools of their choice, such as R (Bioconductor\(^{12}\)), Python, or Excel. Once the data files are ready, Cytoscape can read them into an on-memory session and visualize the data on the KEGG pathways. Imported data sets only use standard Cytoscape data objects, and users can then access all of the standard Cytoscape features to create custom pathway visualizations. An actual workflow will be presented in a later section. Limitations Although KEGGscape can read all information of the pathways saved in KGML files, some of the pathway visualizations in Cytoscape look slightly different from the original hand-drawn diagrams available on the KEGG website. The cause of this issue is missing graphics information in the KGML files. Figure 3 is a side-by-side comparison of the same pathway visualization (human MAPK signaling pathway; KEGG ID: hsa04010). The original diagram (left) contains several background visual annotations that are not visible in the visualization created by Cytoscape (right). The hand-drawn compartmental annotations are not encoded in KGML files, which means they cannot be reproduced by KEGGscape. Results As an example workflow, we integrated and visualized a KEGG pathway and gene expression profile using KEGGscape and external tools. In this example, the differentially expressed genes between two groups, mutants and controls, in a global expression profile are mapped on the KEGG pathway, as too are the t-test results. Data preparation To perform this pathway analysis in Cytoscape, we used Bioconductor (http://www.bioconductor.org/) to prepare the gene expression matrix data. We normalized Affymetrix GeneChip data by the robust multi-array average (RMA) method with the Bioconductor packages ecoliLeucine\(^{13}\) and affy\(^{14}\). The leucine regulatory protein (Lrp) is a DNA binding protein and known as a leucine responsive global regulator\(^{15}\). The p-value for each probeset between four lrp mutant strains and four control chips was calculated by rowttest method in genefilter package\(^{16}\). From this calculation, we obtained a list of genes that are differentially expressed (p-value < 0.05). We sent these probeset identifiers to KEGG Mapper and picked the highest hit, which was the glycine, serine and threonine metabolic pathway (KEGG ID: eco00260) for visualization. Visualization To create a visualization using all the data sets, we imported the KGML file of eco00260 and the p-value matrix file prepared in the previous data preparation to Cytoscape 3, and merged the matrices with a custom Python script (Figure 4). Because Cytoscape does... Figure 3. Comparison of the original diagram and Cytoscape visualization for the human MAPK signaling pathway (KEGG hsa04010). Figure 4. KEGG pathway visualization integrated with gene expression data for the glycine, serine and threonine metabolism pathway of Escherichia coli K-12 MG1655 (KEGG eco00260). Green border nodes are KO (KEGG Orthology) annotated nodes. Red colored nodes include differentially expressed genes (p-value < 0.05). not support fuzzy key matching, we used our Python script to append a key column to the p-value matrix to utilize the Cytoscape table merge tool. The node table in Cytoscape for the imported KGML had KEGG gene annotations. The gene IDs for each enzyme node were used as keys for merging the KGML node table and p-value matrix. In this Figure 4, node colors in the original KEGG pathway were mapped to node border colors and p-values were mapped to node color gradient (red to white) to visualize the significantly expressed genes. Conclusions In this paper, we presented the design and implementation of KEGGscape and an example analysis workflow integrating global gene expression profiles and KEGG pathways using KEGGscape and two external tools, Bioconductor and Python. The workflow demonstrates how users can integrate omics data in an interactive pathway diagram. Future plan Current workflow can map arbitrary omics data onto interactive KEGG pathway diagrams, but it requires some manual editing to create informative visualizations. To minimize the manual process in the workflow, we plan to implement a collection of utility Python scripts to manipulate networks and Visual Styles via RESTful API, which will be published as a part of the Cytoscape 3.2.0 release. This set of Python scripts works to merge pathway related table metadata (omics profiles, non-KEGG pathway metadata) from external platforms like R and Cytoscape to automate common tasks in the visualization process. Software availability The app website: http://apps.cytoscape.org/apps/keggscape Latest source code: https://github.com/idekerlab/KEGGscape Source code as at the time of publication: https://github.com/F1000Research/KEGGscape/releases/tag/V1.0 Archived source code as at the time of publication: http://dx.doi.org/10.5281/zenodo.10560 License: Apache License Version 2.0 Author contributions SK guided the GeneChip data preparation and the statistical tests, KT guided the total system design of the project, KN designed and implemented the software under KO’s supervision and performed sample analysis and visualization. KO contributed to the writing of this article. Competing interests No competing interests were disclosed. Grant information This work was supported by National Bioscience Database Center (NBDC) of the Japan Science and Technology Agency (JST). The funders had no role in study design, data collection and analysis, decision to publish, or preparation of the manuscript. Acknowledgements The authors would like to thank the Google Summer of Code program and Biohackathon attendees for helpful suggestions at the early stage of KEGGscape development, and Peter Karagiannis for reading this article and for useful comments. References PubMed Abstract | Publisher Full Text PubMed Abstract | Publisher Full Text Reference Source Data Source Open Peer Review Current Peer Review Status: Version 1 Reviewer Report 06 August 2014 https://doi.org/10.5256/f1000research.4838.r5318 © 2014 Cline M. This is an open access peer review report distributed under the terms of the Creative Commons Attribution License, which permits unrestricted use, distribution, and reproduction in any medium, provided the original work is properly cited. Melissa Cline Center for Biomolecular Science & Engineering, University of California, Santa Cruz, Santa Cruz, CA, USA KEGG is one of the foremost sources of metabolic pathway data. Cytoscape is the de facto standard pathway visualization platform. Cytoscape-based visualization of KEGG pathways has always been cumbersome and limited. KEGGscape gets over many of these limitations by streamlining the process, and improving the translation of the graphical elements of KEGG pathways. This makes KEGGscape a very useful resource for the scientific community. The manuscript is clear and informative. There are only two changes I would ask for: - First, the authors should mention that KGML files are currently freely available on the KEGG website. This will be news to some readers of this paper, since KEGG has gone through various distribution and licensing models. - Second, the authors should expand their discussion of merging gene expression data with KGML diagrams. The power of network visualization is in pathway data integration. If there are special challenges in integrating with KEGG pathways, these should be brought forth. The mention of custom python scripts and fuzzy ID matching suggests that this integration task can involve special challenges. Competing Interests: No competing interests were disclosed. I confirm that I have read this submission and believe that I have an appropriate level of expertise to confirm that it is of an acceptable scientific standard. Reviewer Report 22 July 2014 https://doi.org/10.5256/f1000research.4838.r5317 Egon Willighagen Department of Bioinformatics - BiGCaT, Maastricht University, Maastricht, The Netherlands The paper describes an interesting and relevant Cytoscape plugin; it is well written (there are a few typos), but I think it can be improved in places. An important reservation is that I cannot determine at this moment how common or serious the data loss in KGML reading is (see below). That is it should be clarified whether this paper is a first report, a work in progress or a finished project. Title and Abstract I find the title appropriate, but it may be promising more than what the app actually does. As far as I can tell, the app is not a general solution, but one specific for KEGG. The abstract is short on setting the state of the domain and, like the Introduction, does not refer to existing research in fields beyond their own. In this way, the abstract is less than clear what unsolved problem was resolved. Introduction The Introduction sufficiently explains the setting of the plugin. One thing that strikes me is the lack of references to related work. For example, it mentions "most biological pathway databases" without citing or even naming them, which I find suboptimal as they critique those databases and to which the authors contrast their solution. Unlike the Introduction currently seems to suggest, KGML is not the only pathway format that tracks graphical information (e.g. GPML used by PathVisio). The first paragraph currently suggests it solves a problem that others have been tackling too. (P.S. under what license is the KGML specification available?). The Introduction focuses on technical issues of the integration. It could also say a bit about identifier mapping and the role of licensing in data integration. That is, given the enormous impact of KEGG it can be wondered why this kind of integration with KEGG has not been done yet, because people have done this for other data sets for years (both open source and proprietary). Or, if it has, it should be cited. Minor comments: - Check the hyphenation of KEGGtranslator (KEGG-translator versus KEG-Gtranslator). - The comment that Cytoscape does not have a built-in function to load biological pathways probably refers to formats, not the pathways themselves. - Since the app focuses on KGML support, some reference to apps supporting other formats (BioPax, SGML) seems appropriate. **Figures** The figures are too hard to read, both in print (where it is impossible) but also in the PDF. This should really be addressed. **Implementation** The Implementation sections can be improved: the section is short on details on the KEGGscape source code, the design of the app and the KGML reader in particular, build instructions, development model, testing (tests seem absent in the code repository). I also note issues with the KGML readers. For example, connections clear on the KEGG website are missing and misplaced when read into Cytoscape (e.g. between glycine and sarcosine, and the link between Purine metabolism, see Fig. 4) and labels are often misleadingly placed and often unconnected (a limitation of KEGG), though accurately copied from the KGML, it seems. The first data-loss clearly indicates a problem with the reader. These things must be discussed in the Limitations subsection, in my opinion (and/or returned to in the Future Plan at the end). Minor comments: - on-memory -> in-memory? - `<graphics>` tag -> `<graphics>` element (a tag does not really have something under it in XML, attributes at best; an element does). - What is "Visual Style"? - Under what license is the DTD available? **Results** The Results section seems to accurately describe what they did, but not how they did this. I think something like a methods section (or an Open Notebook) that explains how the steps are performed (in more detail) would be helpful. However, in the end I was able to figure out how to import a KGML file (which is not under Import). Another example is reference to a custom Python script without description. In fact, thinking about this again, for an app that does data integration, I would actually expect the app to take care of data processing as much as possible. While I understand that general preparation starting from raw data is best done in other tools, this Python script does not seem to do more than format handling of some kind. Is that correct? If so, why is this not done by the app? Fortunately, this observation was made by the authors too, and they return to it in the Future plan subsection. Minor comments: - probeset -> probe set - threonine -> threonine **Conclusion** The Conclusion section does not sufficiently summarize the paper: it should reiterate what the problem is that is solved and what makes KEGGscape unique. Although I do not want to imply that I think this paper is not relevant (it is)! Also the limitations should be returned to here (those already listed in the paper, and those missing), particularly in relation to the "Future plan". The authors' focus should really be on getting the KGML reading performing well: data loss, and data corruption are serious issues. A decent testing toolkit as Maven supports, may be a good start here, but is currently missing from the source code repository. Minor comments: - check the hyphenation of KEGGscape (KEGG-scape versus KEGG-scape) **Competing Interests:** I am contributing to the open source WikiPathways, BridgeDb, and PathVisio projects. I have no competing financial interest. **I confirm that I have read this submission and believe that I have an appropriate level of expertise to confirm that it is of an acceptable scientific standard, however I have significant reservations, as outlined above.** --- Matthew DeJongh Department of Computer Science, Hope College, Holland, MI, USA KEGGscape is valuable Cytoscape app that enables flexible visualization and manipulation of KEGG pathway maps. The capability for visualizing data sets (e.g., gene expression levels) on pathways in Cytoscape is particularly appealing. However, the example presented in the paper does not contain sufficient information to enable a reader to duplicate the process. First, the authors do not cite the origin of the gene expression dataset they use in their example. Second, as far as I can tell, there is no tutorial provided with KEGGscape. At a minimum, the authors should provide instructions for opening a KGML file and loading a dataset. **Competing Interests:** No competing interests were disclosed. **I confirm that I have read this submission and believe that I have an appropriate level of expertise to confirm that it is of an acceptable scientific standard, however I have significant reservations, as outlined above.** The benefits of publishing with F1000Research: • Your article is published within days, with no editorial bias • You can publish traditional articles, null/negative results, case reports, data notes and more • The peer review process is transparent and collaborative • Your article is indexed in PubMed after passing peer review • Dedicated customer support at every stage For pre-submission enquiries, contact research@f1000.com
{"Source-Url": "https://f1000researchdata.s3.amazonaws.com/manuscripts/4838/93d372e2-b81c-4cc5-840f-8c9b0f7cec4f_4524%20-%20kozo%20nishida.pdf?doi=10.12688/f1000research.4524.1&numberOfBrowsableCollections=29&numberOfBrowsableInstitutionalCollections=4&numberOfBrowsableGateways=31", "len_cl100k_base": 4826, "olmocr-version": "0.1.53", "pdf-total-pages": 12, "total-fallback-pages": 0, "total-input-tokens": 27633, "total-output-tokens": 6446, "length": "2e12", "weborganizer": {"__label__adult": 0.0003635883331298828, "__label__art_design": 0.0004925727844238281, "__label__crime_law": 0.0004253387451171875, "__label__education_jobs": 0.0019092559814453125, "__label__entertainment": 0.0002218484878540039, "__label__fashion_beauty": 0.0002503395080566406, "__label__finance_business": 0.0004754066467285156, "__label__food_dining": 0.0005154609680175781, "__label__games": 0.0007429122924804688, "__label__hardware": 0.0019989013671875, "__label__health": 0.0022983551025390625, "__label__history": 0.0003788471221923828, "__label__home_hobbies": 0.00019669532775878904, "__label__industrial": 0.0005645751953125, "__label__literature": 0.0004086494445800781, "__label__politics": 0.00033402442932128906, "__label__religion": 0.0006108283996582031, "__label__science_tech": 0.38671875, "__label__social_life": 0.0002593994140625, "__label__software": 0.1256103515625, "__label__software_dev": 0.473876953125, "__label__sports_fitness": 0.0005373954772949219, "__label__transportation": 0.0005049705505371094, "__label__travel": 0.0002510547637939453}, "weborganizer_max": "__label__software_dev", "avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_ratio": [[0, 25586, 0.02607]], "fineweb_edu_fasttext_gt2__fineweb_edu_fasttext_gt2__score": [[0, 25586, 0.18942]], "ft_lang_id_en_doc_v2__ft_lang_id_en_doc_v2__en": [[0, 25586, 0.88244]], "google_gemma-3-12b-it_contains_pii": [[0, 1670, false], [1670, 1670, null], [1670, 5774, null], [5774, 9947, null], [9947, 10390, null], [10390, 15867, null], [15867, 16437, null], [16437, 18407, null], [18407, 20794, null], [20794, 23218, null], [23218, 25155, null], [25155, 25586, null]], "google_gemma-3-12b-it_is_public_document": [[0, 1670, true], [1670, 1670, null], [1670, 5774, null], [5774, 9947, null], [9947, 10390, null], [10390, 15867, null], [15867, 16437, null], [16437, 18407, null], [18407, 20794, null], [20794, 23218, null], [23218, 25155, null], [25155, 25586, null]], "google_gemma-3-4b-it_v2tag__is_academic_paper": [[0, 5000, true], [5000, 25586, null]], "google_gemma-3-4b-it_v2tag__is_class_syllabus": [[0, 5000, false], [5000, 25586, null]], "google_gemma-3-4b-it_v2tag__is_completion_certificate": [[0, 5000, false], [5000, 25586, null]], "google_gemma-3-4b-it_v2tag__is_court_notice": [[0, 5000, false], [5000, 25586, null]], "google_gemma-3-4b-it_v2tag__is_homework_assignment": [[0, 5000, false], [5000, 25586, null]], "google_gemma-3-4b-it_v2tag__is_news_article": [[0, 5000, false], [5000, 25586, null]], "google_gemma-3-4b-it_v2tag__is_public_order": [[0, 5000, false], [5000, 25586, null]], "google_gemma-3-4b-it_v2tag__is_resume_cv": [[0, 5000, false], [5000, 25586, null]], "google_gemma-3-4b-it_v2tag__is_test_or_quiz": [[0, 5000, false], [5000, 25586, null]], "google_gemma-3-4b-it_v2tag__is_textbook": [[0, 5000, false], [5000, 25586, null]], "pdf_page_numbers": [[0, 1670, 1], [1670, 1670, 2], [1670, 5774, 3], [5774, 9947, 4], [9947, 10390, 5], [10390, 15867, 6], [15867, 16437, 7], [16437, 18407, 8], [18407, 20794, 9], [20794, 23218, 10], [23218, 25155, 11], [25155, 25586, 12]], "pipe_delimited_lines_v1__pipe_delimited_lines_v1__pipe_delimited_lines_ratio": [[0, 25586, 0.0]]}
olmocr_science_pdfs
2024-12-09
2024-12-09
71b1a9fe8d92940f83a34becccc3502a4bd1f6d7
Enabling Real-Time Feedback in Software Engineering Larios Vargas, Enrique; Hejderup, Joseph; Kechagia, Maria; Bruntink, Magiel; Gousios, Georgios DOI 10.1145/3183399.3183416 Publication date 2018 Document Version Final published version Published in Proceedings of the 40th International Conference on Software Engineering Citation (APA) Important note To cite this publication, please use the final published version (if applicable). Please check the document version above. Copyright Other than for strictly personal use, it is not permitted to download, forward or distribute the text or part of it, without the consent of the author(s) and/or copyright holder(s), unless the work is under an open content license such as Creative Commons. Takedown policy Please contact us and provide details if you believe this document breaches copyrights. We will remove access to the work immediately and investigate your claim. Enabling Real-Time Feedback in Software Engineering Enrique Larios Vargas Software Improvement Group e.lariosvargas@sig.eu Joseph Hejderup Delft University of Technology j.i.hejderup@tudelft.nl Maria Kechagia Delft University of Technology m.kechagia@tudelft.nl Magiel Bruntink Software Improvement Group m.bruntink@sig.eu Georgios Gousios Delft University of Technology g.gousios@tudelft.nl ABSTRACT Modern software projects consist of more than just code: teams follow development processes, the code runs on servers or mobile phones and produces run time logs and users talk about the software in forums like StackOverflow and Twitter and rate it on app stores. Insights stemming from the real-time analysis of combined software engineering data can help software practitioners to conduct faster decision-making. With the development of CodeFeedr, a Real-time Software Analytics Platform, we aim to make software analytics a core feedback loop for software engineering projects. CodeFeedr’s vision entails: (1) The ability to unify archival and current software analytics data under a single query language, and (2) The feasibility to apply new techniques and methods for high-level aggregation and summarization of near real-time information on software development. In this paper, we outline three use cases where our platform is expected to have a significant impact on the quality and speed of decision making; dependency management, productivity analytics, and run-time error feedback. ACM Reference Format: https://doi.org/10.1145/3183399.3183417 1 INTRODUCTION Decisions in software engineering are typically made in dynamic circumstances [3]. The main effect of the changing nature in software development projects is that the time dimension has to be taken into account explicitly. For that reason, feedback is considered to be one of the most crucial features of dynamic decision tasks and a valuable resource that, if used properly, can facilitate the decision-making process [9]. In an era where many fields of economic production strive for higher efficiency through data-driven decision making, software production has yet to live up to the challenge. Modern software projects are more than just the code that comprises them: teams follow specific development processes; the code runs on servers or mobile phones and produces run time logs; users talk about the software in forums like StackOverflow and GitHub and rate the product in app stores, in blog posts and on Twitter; the software is part of a collection of similar applications and depends on external code or API’s to deliver its functionality. To optimize the delivery and the user experience of software, modern organizations need to integrate and combine hundreds of metrics in real-time. While tools and methods for extracting data from software development processes, products and ecosystems, do exist, three key aspects are missing: integration, composition and real-time operation [8]. As a result, it is challenging for organizations to capitalize on the wealth of data that software projects produce. Consequently, software analytics are seldom integrated as a feedback loop in software projects. To remedy this situation, we propose the introduction of real-time software analytics as a core feedback loop for software teams. Our hypothesis is that the implementation of CodeFeedr, a Real-time Software Analytics Platform, will represent a significant contribution in the field of software engineering in the following aspects: (1) speeding up decision-making by reducing the time between action and feedback or viceversa, (2) allowing the monitoring of software development infrastructure in real-time and relating production measurements with development actions, (3) supporting the integration of a multitude of data sources that comprise a modern software project, and (4) enabling stakeholders to create up-to-date customized information views of the software development workflow. 2 THE NEED FOR REAL-TIME FEEDBACK In the field of software engineering, Real-time analytics has been applied in: (1) Autonomous Systems and (2) Adaptive and Self-Managing Systems. However, there has been little research done on real-time feedback analytics applied to the software development life cycle. In this context, we present three use cases where real-time feedback analytics can have a significant contribution. 2.1 Dependency Management Open source software (OSS) libraries in large centralized code repositories such as npm or Maven are increasingly becoming more and more interconnected and interdependent. A side-effect of including a highly interconnected library in a project, is that the projects dependency tree of transitive dependencies can quickly grow large over time. A growing number of transitive dependencies can introduce complexities to conventional dependency management and have recently lead to severe security and trust implications. For instance, the Equifax\(^1\) incident leaked over 100,000 customers credit card information due to a critical security bug in the Apache Struts library. Equifax was not able to update to a patched version of the library in time after the vulnerability was known because it was underestimated the impact. Thus, we identify the following features to lack in dependency management: **The lack of end-to-end visibility of interdependent libraries.** Dependencies in a dependency tree change and evolve independently. A dependency tree may look different after a fresh build due to the flexible dependency constraints, for example semantic versioning ranges used in npm. A dependency can automatically include a more recent version, that may add additional dependencies to the tree without the developer being aware of it. Further, the additional dependencies may also be outdated, removed, include more or new dependencies that may be unstable or have many critical bugs. These different evolution characteristics have to co-exist in a dependency tree, making it overwhelming and difficult for developers to digest. Moreover, developers have little control over transitive dependencies and have to accept the decisions or risks taken by other library maintainers. **Difficulty to evaluate the impact and risk associated with a dependency.** The active use of dependency checkers and monitoring information feeds allow developer teams to keep up-to-date with bug reports and new releases. This can yield a low signal-to-noise ratio since it is difficult to comprehend the benefits or the urgency of updating a dependency to a newer version. For instance, a dependency may be used through out a software portfolio, a project may use outdated dependencies that require major re-write or is in conflict with other used dependencies. A received bug report only indicates affected versions and not the actual use of a dependency. This makes it difficult to know whether a transitive dependency puts a software project under risk due to a security bug. Developers need to use subjective judgment in these scenarios that could have devastating consequences. **Bug or change-impact propagation in an interconnected code repository.** A challenging part for library maintainers is to estimate the damage (e.g. breaking changes) made to clients due to changes made or identified bugs in the library. Understanding how a library is used in other libraries and applications can help maintainers to better understand the risks before making changes. This could be helpful in the event of a security bug, solving the bug should be seen as a collaborative effort between maintainers and clients. Therefore, ways to minimize breaking changes for clients could be achieved by understanding how clients directly or indirectly use affected code segment in a library. The ever-changing nature of centralized code repositories explicitly impacts regular software projects at the heart of the dependency level. Therefore, it is important that changes are captured in real-time and those changes are provided as feedback to developers and library maintainers. In doing so, we believe that lightweight code analysis can capture the risk and bug propagation across an ecosystem and in dependency trees at the client-level. For instance, library maintainers can identify a potential critical bug in the source code if they receive at the refactoring stage as a real-time feedback how many clients are directly and indirectly affected by the changes. ### 2.2 Productivity Analytics Effective software productivity measurement is becoming a crucial factor for decision-making in the current software development practices, which have the goal to achieve faster application delivery using new infrastructure, tools and methods focused on continuous integration (CI), continuous delivery (CD) or continuous deployment. This scenario calls for switching towards a near real-time or just in time approach for measuring productivity. We envision that real-time analytics can have a significant contribution in the following challenges in productivity analytics: **Extending the scope of productivity measurement.** Most approaches in this domain use only the outputs generated in the coding stage, usually in terms of Source Lines of Code (SLOC), functionalities or story points completed over time. However, we can get a better understanding of stakeholders’ work by looking at their interactions at a more detailed level and associating them to a specific stage in the software development. **Absence of environments to improve performance.** Meyer et al. [12] highlights that knowing about the current progress of work items and time spent in each activity provide with metrics for self-monitoring and feedback. Additionally, Calvo et al. [4] affirms that there is a strong correlation between self-awareness of one’s current state and person’s performance or behavior. Current research in this area, such as TimeAware [10], is an example of how real-time self-monitoring systems can contribute to improve personal productivity. **The difficulty in identifying developers’ behavior patterns to enhance productivity.** During the software development workflow, multiple tools capture real-time data about stakeholder’s activities such as local environments, control versioning systems, CI servers, testing environments and CD servers. What is missing is a unified data layer for mining patterns from developers activities data that can be correlated to productivity factors to help tuning productivity measurements. **An immediate and more effective visibility of the interplay between code quality and productivity.** Source code is continuously changing in terms of enhancements, fixing bugs and new requirements. It is a challenging task to understand and measure the impact of changes over time. Furthermore, the possibility of introducing an unintended fault or defect during those changes is relatively high. This situation calls for urgent measures to improve source code visualization by aligning near real-time data from the software delivery pipeline with software quality factors and productivity analytics metrics. Assessing productivity using feedback resulted from aggregating near real-time and archival data can contribute to conduct real-time operational performance monitoring of software delivery pipelines. ### 2.3 Run-time Error Feedback As software evolves rapidly, the need for new methods and techniques that can ensure systems and applications’ availability becomes more intense. Software reliability is important for critical systems, such as medical devices, smart vehicles, aircrafts and so on, as well as for mobile applications that we use in every day life. --- \(^1\)https://blogs.apache.org/foundation/entry/apache-struts-statement-on-equifax Traditional approaches for developing robust programs include: software verification, prevention mechanisms using programming languages’ features, as well as debugging, but these techniques are time-consuming and suffer from false positives. Next-generation real-time feedback mechanisms are able to effectively support the productive development of modern software applications by reducing execution failures. Systems based on real-time analytics can give feedback that addresses the following challenges. **Classification of crash causes.** To predict and prevent future execution failures there is a need for grasping knowledge from crowdsourcing data. Such data include: source code, commits, issues, and crash reports and stem from online sources, such as: Q&A consulting sites (e.g. stackoverflow.com), issue tracking systems (e.g. Bugzilla, Jira, GitHub, etc.), and so on. Then, there is a need for efficient processing of data from software repositories and crash report management services for real-time feedback on the classification of common failure reasons and the prevention from similar failures. A real-time analytics platform can be used in order to enable real-time integration analysis of diverse data. Given that these data are in the form of text, natural language processing techniques (e.g. similarity metrics, textual analysis, and parsing) can be applied here. Therefore, such a real-time system can automate the processing of data from a variety of sources improving decision-making. **Recommendations for the prevention of software crashes.** For preventing software and its consumers from suffering from future execution failures, researchers have devised algorithms that learn from past software failure patterns and predict possible new crashes. However, currently, it is not easy for developers to use these theoretical methods. There is a need for more practical solutions. A real-time analytics system will provide developers with alerts for possible execution failures while they program new software. For this, machine learning and software engineering techniques can be used. Behind the scenes, a prediction model can be applied for the identification of failure prone modules during software production based on learning the bad and good design and coding patterns from source code, crash data, and so on. Additionally, applying program and root cause analysis on appropriate data, an automatic fault localization method can be used for the efficient reproduction and prevention of future software crashes. Thus, a tool such as a plug-in for an IDE that can give real-time feedback regarding the quality of software programs, assisting developers to write more robust software. **Prioritization of bug fixes.** Crash reports produced during execution failures are very valuable for understanding and fixing software bugs. However, crash data might include a lot of noise, be incomplete, and hide important information hindering their analysis and comprehension. Therefore, several approaches try to interpret the messages that these reports convey to achieve accurate error recovery. However, nowadays, there is also a need for fixing software problems as soon as possible. A real-time analytics solution can automatically identify patterns in crash data, revealing actual reasons of failures. “Intelligent tools” that are able to pinpoint critical faults, which should be fixed soon, can eliminate developers’ effort to conduct manual root cause analysis and guarantee fast as well as precise bug fixing. --- **Figure 1: Feedback-driven platform architecture.** **3 DESIGN GUIDELINES** The three uses cases show a currently unfulfilled need of software projects: an integrated, near-real time, feedback loop based on software analytics. To fill this gap, we envision a platform that will pursue the following design guidelines: **Provide instant feedback.** This will enable DevOps teams to monitor their infrastructure in real-time and relate production measurements with development actions. **Integrate all potential data sources that comprise a modern software project.** Contrary to current software big data efforts that prioritize source code or repository analysis, CodeFeedr will integrate all possible data sources, including natural language based ones. Moreover, it will create a process and a data schema that will enable other researchers to integrate arbitrary data sources. **Devise novel ways of aggregation and summarization of software analytics.** CodeFeedr will enable various stakeholders (developers, DevOps, managers) to create up-to-date customized information views (textual or even graphical). **4 PRELIMINARY RESULTS** To realize our vision of an integrated real-time feedback loop in software analytics, we present the architecture of the initial implementation of a system to process software engineering data in real-time. An overview of the high-level architecture is presented in Figure 1. In the following numbered paragraphs, we explain the role of each key component for our platform: 1) **Stream processing of data sources.** To deliver feedback in near real-time, data needs to be ingested, processed and analyzed upon arrival and piped-out in an acceptable time frame. Software processes that trigger events such as commit to a repository, release of an npm package, stack trace reports in a created JIRA issue or a security advisory are the first-class citizens in the platform. However, certain software processes focus on learning from past data or events. This could be abandoned software projects that are no longer maintained or learning from past mistakes to improve better bug resolution. Therefore, it is important to be able to replay such data or create stateful models of data sets. These requirements are ideal for event stream processing to deliver a near real-time processing of software processes. 2) **Software tool as a stream function.** Event stream processing frameworks support business-related functionally such as data aggregation and summarization. In a feed-back driven platform, many use cases would depend on advanced techniques such as program analysis to evaluate whether a set of code changes reduces or improves the code quality to a project before committing the changes. The platform should support the integration of current software tools or techniques as stream processing functions. This implies that tools that handle tasks such as automatic test suit generation, type checker and taint analysis will be treated as a function. This also further entails that certain of these tools need to be adapted to process events as input data. This is different from processing the entire projects as input data (i.e. the analysis must be incremental). 3) **Dynamic data source and function integration.** Software processes are ever-changing, and so are data sources and software tools. An identified requirement of our platform is the dynamic integration of new data sources and processing functions (e.g. software tools). Further, the data sources and functions should be aware about each others compatibility such that users can compose their stream topology of functions and data sources freely. This implies that data sources and functions need some form of schema or type information to ensure compatibility. As an example, a function that processes commit messages from Github should dynamically recognize and be able to process commit message from BitBucket. We are currently building the means to support dynamic recognition of data sources and functions, and also being able to modify running stream topologies to e.g add BitBucket data source in an already running Github commit processing topology. 4) **SQL query interface.** SQL being a declarative language designed for static data has an expressiveness that could be ideal for processing software data. SQL is the most popular query language, therefore being able to express SQL queries over data streams could make it useful not only for developers but also stakeholders who are more acquainted to work with databases. Here is an example of how a query could be expressed in natural language: For [all | 100 recent | 50 most discussed] pull requests on project A, prioritize those that are most important to me or my team The result would be feedback-driven and continuously updated. 5 **RELATED WORK** Our approach connects two major research domains: streaming data processing and software repository mining. The software repository mining community identified early on the need for platforms to analyze data from software repositories on a large scale, for instance. Kenyon [2] and Boa [6]. Additionally, Microsoft developed Codemine, a software development data analytics platform for collecting and analyzing engineering process data, its constraints, and organizational and technical choices [5]. However, all those projects have in common the integration of important archival data sources; and, they do not aggregate any information apart from source code, issues and emails. Furthermore, they also do not use real-time analysis in their data sources. In the field of mining software repositories (MSR), it is important to mention three cases that inspired our work in the development of CodeFeedr: (1) **GHTorrent’s** [7] approach to follow GitHub’s event stream processing for events happening in real time on all project repositories across GitHub, instead of mining the repository histories in a static way. On the other hand, (2) **CodeAware’s** [1] effort to provide an integrated mechanism for giving early feedback to engineers and to automate follow-up actions. This approach uses a sensor-actuator-based ecosystem for distributed and fine-grained artifact analysis. Furthermore, (3) **data-driven requirements engineering** [11], in which software practitioners could systematically use explicit and implicit user feedback describing user experiences in an aggregated form to support requirements decisions. 6 **CONCLUSION** The development of CodeFeedr, a Real-time Software Analytics Platform represents our vision to tackle current challenges for modern software projects. Our platform enables a real-time feedback loop environment in order to: (1) speed up decision-making, (2) monitor software development infrastructure in real-time and (3) create up-to-date customized information views of the software development workflow. CodeFeedr’s architecture facilitates integration, aggregation, analysis and summarization of software analytics data as streams. These features will enable software practitioners to cut across production/run time layers in order to optimize software delivery, performance and quality. **REFERENCES**
{"Source-Url": "https://pure.tudelft.nl/portal/files/38777497/ICSE_NIER_50.pdf", "len_cl100k_base": 4357, "olmocr-version": "0.1.53", "pdf-total-pages": 5, "total-fallback-pages": 0, "total-input-tokens": 14365, "total-output-tokens": 5875, "length": "2e12", "weborganizer": {"__label__adult": 0.00034689903259277344, "__label__art_design": 0.00022017955780029297, "__label__crime_law": 0.00024628639221191406, "__label__education_jobs": 0.0005230903625488281, "__label__entertainment": 4.166364669799805e-05, "__label__fashion_beauty": 0.00011467933654785156, "__label__finance_business": 0.00016951560974121094, "__label__food_dining": 0.0002770423889160156, "__label__games": 0.00034356117248535156, "__label__hardware": 0.000415802001953125, "__label__health": 0.00032448768615722656, "__label__history": 0.0001245737075805664, "__label__home_hobbies": 5.394220352172851e-05, "__label__industrial": 0.0001932382583618164, "__label__literature": 0.00017392635345458984, "__label__politics": 0.00015532970428466797, "__label__religion": 0.0002942085266113281, "__label__science_tech": 0.0027484893798828125, "__label__social_life": 8.618831634521484e-05, "__label__software": 0.00440216064453125, "__label__software_dev": 0.98828125, "__label__sports_fitness": 0.00023317337036132812, "__label__transportation": 0.00029540061950683594, "__label__travel": 0.00015997886657714844}, "weborganizer_max": "__label__software_dev", "avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_ratio": [[0, 26997, 0.03636]], "fineweb_edu_fasttext_gt2__fineweb_edu_fasttext_gt2__score": [[0, 26997, 0.23902]], "ft_lang_id_en_doc_v2__ft_lang_id_en_doc_v2__en": [[0, 26997, 0.89238]], "google_gemma-3-12b-it_contains_pii": [[0, 1320, false], [1320, 6541, null], [6541, 13463, null], [13463, 19071, null], [19071, 26997, null]], "google_gemma-3-12b-it_is_public_document": [[0, 1320, true], [1320, 6541, null], [6541, 13463, null], [13463, 19071, null], [19071, 26997, null]], "google_gemma-3-4b-it_v2tag__is_academic_paper": [[0, 5000, true], [5000, 26997, null]], "google_gemma-3-4b-it_v2tag__is_class_syllabus": [[0, 5000, false], [5000, 26997, null]], "google_gemma-3-4b-it_v2tag__is_completion_certificate": [[0, 5000, false], [5000, 26997, null]], "google_gemma-3-4b-it_v2tag__is_court_notice": [[0, 5000, false], [5000, 26997, null]], "google_gemma-3-4b-it_v2tag__is_homework_assignment": [[0, 5000, false], [5000, 26997, null]], "google_gemma-3-4b-it_v2tag__is_news_article": [[0, 5000, false], [5000, 26997, null]], "google_gemma-3-4b-it_v2tag__is_public_order": [[0, 5000, false], [5000, 26997, null]], "google_gemma-3-4b-it_v2tag__is_resume_cv": [[0, 5000, false], [5000, 26997, null]], "google_gemma-3-4b-it_v2tag__is_test_or_quiz": [[0, 5000, false], [5000, 26997, null]], "google_gemma-3-4b-it_v2tag__is_textbook": [[0, 5000, false], [5000, 26997, null]], "pdf_page_numbers": [[0, 1320, 1], [1320, 6541, 2], [6541, 13463, 3], [13463, 19071, 4], [19071, 26997, 5]], "pipe_delimited_lines_v1__pipe_delimited_lines_v1__pipe_delimited_lines_ratio": [[0, 26997, 0.0]]}
olmocr_science_pdfs
2024-12-09
2024-12-09
b8be29ed318178b657a45bdc500bdfb0182e1406
Introduction to Distributed Systems - Why do we develop distributed systems? - availability of powerful yet cheap microprocessors (PCs, workstations), continuing advances in communication technology, - What is a distributed system? - A distributed system is a collection of independent computers that appear to the users of the system as a single system. - Examples: - Network of workstations - Distributed manufacturing system (e.g., automated assembly line) - Network of branch office computers ## Distributed Systems ### Comparison of three kinds of multiple CPU systems <table> <thead> <tr> <th>Item</th> <th>Multiprocessor</th> <th>Multicomputer</th> <th>Distributed System</th> </tr> </thead> <tbody> <tr> <td>Node configuration</td> <td>CPU</td> <td>CPU, RAM, net interface</td> <td>Complete computer</td> </tr> <tr> <td>Node peripherals</td> <td>All shared</td> <td>Shared exc. maybe disk</td> <td>Full set per node</td> </tr> <tr> <td>Location</td> <td>Same rack</td> <td>Same room</td> <td>Possibly worldwide</td> </tr> <tr> <td>Internode communication</td> <td>Shared RAM</td> <td>Dedicated interconnect</td> <td>Traditional network</td> </tr> <tr> <td>Operating systems</td> <td>One, shared</td> <td>Multiple, same</td> <td>Possibly all different</td> </tr> <tr> <td>File systems</td> <td>One, shared</td> <td>One, shared</td> <td>Each node has own</td> </tr> <tr> <td>Administration</td> <td>One organization</td> <td>One organization</td> <td>Many organizations</td> </tr> </tbody> </table> Advantages of Distributed Systems over Centralized Systems - **Economics**: A collection of microprocessors offer a better price/performance than mainframes. Low price/performance ratio: cost effective way to increase computing power. - **Speed**: A distributed system may have more total computing power than a mainframe. Ex. 10,000 CPU chips, each running at 50 MIPS. Not possible to build 500,000 MIPS single processor since it would require 0.002 nsec instruction cycle. Enhanced performance through load distributing. - **Inherent distribution**: Some applications are inherently distributed. Ex. a supermarket chain. - **Reliability**: If one machine crashes, the system as a whole can still survive. Higher availability and improved reliability. - **Incremental growth**: Computing power can be added in small increments. Modular expandability. - **Another deriving force**: The existence of large number of personal computers, the need for people to collaborate and share information. Advantages of Distributed Systems over Independent PCs - Data sharing: allow many users to access to a common data base - Resource Sharing: expensive peripherals like color printers - Communication: enhance human-to-human communication, e.g., email, chat - Flexibility: spread the workload over the available machines Disadvantages of Distributed Systems - Software: difficult to develop software for distributed systems - Network: saturation, lossy transmissions - Security: easy access also applies to secret data Software Concepts - Software more important for users - Two types: 1. Network Operating Systems 2. (True) Distributed Systems Network Operating Systems • loosely-coupled software on loosely-coupled hardware • A network of workstations connected by LAN • each machine has a high degree of autonomy o rlogin machine o rcp machine1:file1 machine2:file2 • Files servers: client and server model • Clients mount directories on file servers • Best known network OS: o Sun’s NFS (network file servers) for shared file systems (Fig. 9-11) • a few system-wide requirements: format and meaning of all the messages exchanged NFS (Network File System) - NFS Architecture - Server exports directories - Clients mount exported directories - NSF Protocols - For handling mounting - For read/write: no open/close, stateless - NSF Implementation (True) Distributed Systems - tightly-coupled software on loosely-coupled hardware - provide a single-system image or a virtual uniprocessor - a single, global interprocess communication mechanism, process management, file system; the same system call interface everywhere - Ideal definition: “A distributed system runs on a collection of computers that do not have shared memory, yet looks like a single computer to its users.” Design Issues of Distributed Systems - Transparency - Flexibility - Reliability - Performance - Scalability 1. Transparency - How to achieve the single-system image, i.e., how to make a collection of computers appear as a single computer. - Hiding all the distribution from the users as well as the application programs can be achieved at two levels: 1) hide the distribution from users 2) at a lower level, make the system look transparent to programs. 1) and 2) requires uniform interfaces such as access to files, communication. 2. Flexibility • Make it easier to change • Monolithic Kernel: systems calls are trapped and executed by the kernel. All system calls are served by the kernel, e.g., UNIX. • Microkernel: provides minimal services. • IPC • some memory management • some low-level process management and scheduling • low-level i/o (E.g., Mach can support multiple file systems, multiple system interfaces.) 3. Reliability - Distributed system should be more reliable than single system. Example: 3 machines with .95 probability of being up. 1-.05**3 probability of being up. - Availability: fraction of time the system is usable. Redundancy improves it. - Need to maintain consistency - Need to be secure - Fault tolerance: need to mask failures, recover from errors. 4. Performance • Without gain on this, why bother with distributed systems. • Performance loss due to communication delays: – fine-grain parallelism: high degree of interaction – coarse-grain parallelism • Performance loss due to making the system fault tolerant. 5. Scalability - Systems grow with time or become obsolete. - Techniques that require resources linearly in terms of the size of the system are not scalable. (e.g., broadcast based query won't work for large distributed systems.) - Examples of bottlenecks - Centralized components: a single mail server - Centralized tables: a single URL address book - Centralized algorithms: routing based on complete information Distributed Coordination - Communication between processes in a distributed system can have unpredictable delays, processes can fail, messages may be lost. - Synchronization in distributed systems is harder than in centralized systems because the need for distributed algorithms. - Properties of distributed algorithms: 1. The relevant information is scattered among multiple machines. 2. Processes make decisions based only on locally available information. 3. A single point of failure in the system should be avoided. 4. No common clock or other precise global time source exists. - Challenge: How to design schemes so that multiple systems can coordinate/synchronize to solve problems efficiently? Why need to synchronize clocks? Computer for compiling 2142 2143 2144 2145 2146 2147 Local clock time foo.o created Computer for editing 2142 2143 2144 2145 2146 2147 Local clock time foo.c modified Logical and physical clocks - How a computer timer works? - A counter register and a holding register. - The counter is decremented by a quartz crystals oscillator. When it reaches zero, an interrupted is generated and the counter is reloaded from the holding register. - E.g, interrupt 60 times per second. - Clock skew problem - Logical clocks -- to provide consistent event ordering - Physical clocks -- clocks whose values must not deviate from the real time by more than a certain amount. Event Ordering - Since there is no common memory or clock, it is sometimes impossible to say which of two events occurred first. - The *happened-before* relation is a partial ordering of events in distributed systems such that 1. If $A$ and $B$ are events in the same process, and $A$ was executed before $B$, then $A \Rightarrow B$. 2. If $A$ is the event of sending a message by one process and $B$ is the event of receiving that by another process, then $A \Rightarrow B$. 3. If $A \Rightarrow B$ and $B \Rightarrow C$, then $A \Rightarrow C$. - If two events $A$ and $B$ are not related by the $\Rightarrow$ relation, then they are executed concurrently (no causal relationship) - To obtain a global ordering of all the events, each event can be *time stamped* satisfying the requirement: for every pair of events $A$ and $B$, if $A \Rightarrow B$ then the time stamp of $A$ is less than the time stamp of $B$. (Note that the converse need not be true.) Example of Event Ordering Global ordering How do we enforce the global ordering requirement in a distributed environment (without a common clock)? 1. For each process $P_i$, a logical clock $LC_i$ assign a unique value to every event in that process. 2. If process $P_i$ receives a message (event B) with time stamp $t$ and $LC_i(B) < t$, then advance its clock so that $LC_i(B) = t+1$. 3. Use processor ids to break ties to create a total ordering. Example of Global Timestamps Example: Lamport’s Algorithm - Three processes, each with its own clock. The clocks run at different rates. - Lamport’s Algorithm corrects the clock. - Note: ts(A) < ts(B) does not imply A happened before B. Physical clock synchronization algorithms - Maximum drift rate - One can determine how often they should be synchronized. Not all clock’s tick precisely at the current rate. Physical clock synchronization algorithms - Cristian's algorithm - need to change time gradually - need to consider msg delays, subtract \((T1 - T0 - I)/2\) - Getting the current time from a time server Physical clock synchronization algorithms - The Berkeley algorithm - Averaging algorithm - The time daemon asks all the other machines for their clock values. - The machines answer. - The Time daemon tells everyone how to adjust their clock. Physical clock synchronization algorithms - Multiple external time sources - UTC (Universal Coordinated Time) - NIST broadcasts WWV signal at every UTC sec from CO. - Computing UTC from multiple time sources, each of which gives a time interval in which UTC falls. Unreliable communication Reaching Agreement - How can processes reach consensus in a distributed system - Messages can be delayed - Messages can be lost - Processes can fail (or even malignant) - Messages can be corrupted - Each process starts with a bit (0 or 1) and Non-faulty processes should eventually agree on common value - No solution is possible - Note: solutions such as computing majority do not work. Why? - Two generals problem (unreliable communications) - Byzantine generals problem (faulty processes) Two generals’ problem - Two generals on opposite sides of a valley have to agree on whether to attack or not (at a pre-agreed time) - Goal: Each must be sure that the other one has made the same decision - Communicate by sending messenger who may get captured - Can never be sure whether the last messenger reached the other side (every message needs an ack), so no perfect solution - Impossibility of consensus is as fundamental as undecidability of the halting problem! - In practice: probability of losing a repeatedly sent message decreases (so agreement with high probability possible) **Impossibility Proof** **Theorem.** If any message can be lost, it is not possible for two processes to agree on non-trivial outcome using only messages for communication. **Proof.** Suppose it is possible. Let $m[1],...,m[k]$ be a finite sequence of messages that allowed them to decide. Furthermore, let’s assume that it is a minimal sequence, that is, it has the least number of messages among all such sequences. However, since any message can be lost, the last message $m[k]$ could have been lost. So, the sender of $m[k]$ must be able to decide without having to send it (since the sender knows that it may not be delivered) and the receiver of $m[k]$ must be able to decide without receiving it. That is, $m[k]$ is not necessary for reaching agreement. That is, $m[1],...,m[k-1]$ should have been enough for the agreement. This is a contradiction to that the sequence $m[1],...,m[k]$ was minimum. Mutual Exclusion and Synchronization - To solve synchronization problems in a distributed system, we need to provide distributed semaphores. - Schemes for implementation: 1. A Centralized Algorithm 2. A Distributed Algorithm 3. A Token Ring Algorithm A Centralized Algorithm - Use a coordinator which enforces mutual exclusion. - Two operations: request and release. - Process 1 asks the coordinator for permission to enter a critical region. Permission is granted. - Process 2 then asks permission to enter the same critical region. The coordinator does not reply. - When process 1 exists the critical region, it tells the coordinator, which then replies to 2. ![Diagram of the centralized algorithm](image) A Centralized Algorithm (continued) - Coordinator loop receive(msg); case msg of REQUEST: if nobody in CS then reply GRANTED else queue the REQ; reply DENIED RELEASE: if queue not empty then remove 1st on the queue reply GRANTED end case end loop - Client send(REQUEST); receive(msg); if msg != GRANTED then receive(msg); enter CS; send(RELEASE) A Centralized Algorithm Algorithm properties - guarantees mutual exclusion - fair (First Come First Served) - a single point of failure (Coordinator) - if no explicit DENIED message, then cannot distinguish permission denied from a dead coordinator A Decentralized Algorithm Decision making is distributed across the entire system a) Two processes want to enter the same critical region at the same moment. b) Both send request messages to all processes c) All events are time-stamped by the global ordering algorithm d) The process whose request event has smaller time-stamp wins e) Every process must respond to request messages A Decentralized Algorithm - Decision making is distributed across the entire system a) Two processes want to enter the same critical region at the same moment. b) Process 0 has the lowest timestamp, so it wins. c) When process 0 is done, it sends an OK also, so 2 can now enter the critical region. Decentralized Algorithm (continued) 1. When a process wants to enter its critical section, it generates a new time stamp, TS, and sends the msg request(p,TS) to all other processes in the system (recall algorithm for global ordering of events). 2. A process, which receives reply msgs from all other processes, can enter its critical section. 3. When a process receives a request message, (A) if it is in CS, defers its answer; (B) if it does not want to enter its CS, reply immediately; (C) if it also wants to enter its CS, it maintains a queue of requests (including its own request) and sends a reply to the request with the minimum time-stamp. Correctness Theorem. The Algorithm achieves mutual exclusion. Proof: By contradiction. Suppose two processes Pi and Pj are in CS concurrently. WLOG, assume that Pi's request has earlier timestamp than Pj. That is, Pi received Pj's request after Pi made its own request. Thus, Pj can concurrently execute the CS with Pi only if Pi returns a REPLY to Pj before Pi exits the CS. But, this is impossible since Pj has a later timestamp than Pi. Properties 1. mutual exclusion is guaranteed 2. deadlock free 3. no starvation, assuming total ordering on msgs 4. 2(N-1) msgs: (N-1) request and (N-1) reply msgs 5. n points of failure (i.e., each process becomes a point of failure) can use explicit ack and timeout to detect failed processes 6. each process needs to maintain group membership; (i.e. IDs of all active processes) non-trivial for large and/or dynamically changing memberships 7. n bottlenecks since all processes involved in all decisions 8. may use majority votes to improve the performance A Token Passing Algorithm - A token is circulated in a logical ring. - A process enters its CS if it has the token. - Issues: - If the token is lost, it needs to be regenerated. - Detection of the lost token is difficult since there is no bound on how long a process should wait for the token. - If a process can fail, it needs to be detected and then bypassed. - When nobody wants to enter, processes keep on exchanging messages to circulate the token. Comparison <table> <thead> <tr> <th>Algorithm</th> <th>Messages per entry/exit</th> <th>Delay before entry (in message times)</th> <th>Problems</th> </tr> </thead> <tbody> <tr> <td>Centralized</td> <td>3</td> <td>2</td> <td>Coordinator crash</td> </tr> <tr> <td>Distributed</td> <td>2 ((n - 1))</td> <td>2 ((n - 1))</td> <td>Crash of any process</td> </tr> <tr> <td>Token ring</td> <td>1 to (\infty)</td> <td>0 to (n - 1)</td> <td>Lost token, process crash</td> </tr> </tbody> </table> Leader Election - In many distributed applications, particularly the centralized solutions, some process needs to be declared the central coordinator. - Electing the leader also may be necessary when the central coordinator crashes. - Election algorithms allow processes to elect a unique leader in a decentralized manner. Bully Algorithm Goal: Figure out the active process with max ID 1. Suppose a process P detects a failure of current leader - P sends an “election” message to all processes with higher ID - If nobody responds within interval T, sends “coordinator” message to all processes with lower IDs - If someone responds with “OK” message, P waits for a “coordinator” message (if not received, restart the algorithm) 2. If P receives a message “election” from a process with lower ID, responds with “OK” message, and starts its own leader election algorithm (as in step 1) 3. If P receives “coordinator” message, record the ID of leader Bully Algorithm (a) Process 4 holds an election. (b) Processes 5 and 6 respond, telling 4 to stop. (c) Now 5 and 6 each hold an election. (d) Process 6 tells 5 to stop. (e) Process 6 wins and tells everyone. Leader Election in a Ring - Each process has unique ID; can receive messages from left, and send messages to the right. - Goal: agree on who is the leader (initially everyone knows only its own ID). - Idea: - Initially send your own ID to the right. When you receive an ID from left, if it is higher than what you have seen so far, send it to right. - If your own ID is received from left, you have the highest ID and are the leader. Distributed Deadlock - A deadlock occurs when a set of processes in a system are blocked waiting for requests that can never be satisfied. Approaches: - Detection (& Recovery) - Prevention - Avoidance - not practical in distributed setting Difficulties: - Resource allocation information is distributed - Gathering information requires messages. Since messages have non-zero delays, it is difficult to have an accurate and current view of resource allocation. Deadlock Detection Recall - Suppose following information is available: - For each process, the resources it currently holds - For each process, the request that it is waiting for - Then, one can check if the current system state is deadlocked, or not - In single-processor systems, OS can maintain this information, and periodically execute deadlock detection algorithm - What to do if a deadlock is detected? - Kill a process involved in the deadlocked set - Inform the users, etc. Wait For Graph (WFG) Definition. A resource graph is a bipartite directed graph (N,E), where - \( N = P \cup R \), - \( P = \{p_1, \ldots, p_n\} \), \( R = \{r_1, \ldots, r_n\} \) - \( (r_1, \ldots, r_n) \) available unit vector, - An edge \((p_i, r_j)\) a request edge, and - An edge \((r_i, p_j)\) an allocation edge. Definition: Wait For Graph (WFG) is a directed graph, where nodes are processes and a directed edge from \( P \rightarrow Q \) represents that \( P \) is blocked waiting for \( Q \) to release a resource. So, there is an edge from process \( P \) to process \( Q \) if \( P \) needs a resource currently held by \( Q \). Definitions - **Def:** A node $Y$ is reachable from a node $X$, $X \Rightarrow Y$, if there is a path (i.e., a sequence of directed edges) from node $X$ to node $Y$. - **Def:** A cycle in a graph is a path that starts and ends on the same node. If a set $C$ of nodes is a cycle, then for all $X$ in $C : X \Rightarrow X$ - **Def:** A knot $K$ in a graph is a non-empty set of nodes such that, for each $X$ in $K$, all nodes in $K$ and only the nodes in $K$ are reachable from $X$. That is, - (for every $X$ for every $Y$ in $K$, $X \Rightarrow Y$) and - (for every $X$ in $K$, there exists $Z$ s.t. $X \Rightarrow Z$ implies $Z$ is in $K$) Sufficient Conditions for Deadlock - **Resource Model** 1. reusable resource 2. exclusive access - **Three Request Models** 1. Single-unit request model: - a cycle in WFG 2. AND request model: simultaneous requests - blocked until all of them granted - a cycle in WFG - a process can be in more than one cycle 3. OR request model: any one, e.g., reading a replicated data object - a cycle in WFG not a sufficient condition (but necessary) - a knot in WFG is a sufficient condition (but not necessary) Deadlock Detection Algorithms • Centralized Deadlock Detection • false deadlock (a) Initial resource graph for machine 0. (b) Initial resource graph for machine 1. (c) The coordinator’s view of the world. (d) The situation after the delayed message. Wait-for Graph for Detection - Assume only one instance of each resource - Nodes are processes - Recall Resource Allocation Graph: it had nodes for resources as well as processes (basically same idea) - Edges represent waiting: If P is waiting to acquire a resource that is currently held by Q, then there is an edge from P to Q - A deadlock exists if and only if the global wait-for graph has a cycle - Each process maintains a local wait-for graph based on the information it has - Global wait-for graph can be obtained by the union of the edges in all the local copies Distributed Cycle Detection - Each site looks for potential cycles - Suppose site S1 has processes P1, P2, P3, P4. - S1 knows that P7 (on a different site) is waiting for P1, P1 is waiting for P4, P4 is waiting for P2, and P2 is waiting for P9 (on a different site S3) - This can be a potential cycle - S1 sends a message to S3 giving the chain P7, P1, P4, P2, P9 - Site S3 knows the local dependencies, and can extend the chain, and pass it on to a different site - Eventually, some site will detect a deadlock, or will stop forwarding the chain Deadlock Detection Algorithms • Distributed Deadlock Detection: An Edge-Chasing Algorithm Chandy, Misra, and Haas distributed deadlock detection algorithm. Deadlock Prevention - Hierarchical ordering of resources avoids cycles - Time-stamp ordering approach: Prevent the circular waiting condition by preempting resources if necessary. - The basic idea is to assign a unique priority to each process and use these priorities to decide whether process $P$ should wait for process $Q$. - Let $P$ wait for $Q$ if $P$ has a higher priority than $Q$; Otherwise, $P$ is rolled back. - This prevents deadlocks since for every edge $(P, Q)$ in the wait-for graph, $P$ has a higher priority than $Q$. Thus, a cycle cannot exist. Two commonly used schemes - **Wait-Die (WD):** Non-preemptive When \( P \) requests a resource currently held by \( Q \), \( P \) is allowed to wait only if it is older than \( Q \). Otherwise, \( P \) is rolled back (i.e., dies). - **Wound-Wait (WW):** Preemptive When \( P \) requests a resource currently held by \( Q \), \( P \) is allowed to wait only if \( P \) is younger than \( Q \). Otherwise, \( Q \) is rolled back (releasing its resource). That is, \( P \) wounds \( Q \). **Note:** - Both favor old jobs (1) to avoid starvation, and (2) since older jobs might have done more work, expensive to roll back. - Unnecessary rollbacks may occur. Sample Scenario - Processes P, Q, R are executing at 3 distributed sites. - Suppose the time-stamps assigned to them (at the time of their creation) are 5, 10, 20, resp. - Q acquires a shared resource. - Later, R requests the same resource. - WD would roll back R. - WW would make R wait. - Later, P requests the same resource. - WD would make P wait. - WW would roll back Q, and give the resource to P. WD versus WW (a) Wants resource Old process 10 Waits Holds resource Young process 20 (a) Wants resource Old process 10 Preempts Holds resource Young process 20 (b) Wants resource Young process 20 Dies Holds resource Old process 10 (b) Wants resource Young process 20 Waits Holds resource Old process 10 Example Let P1 (5), P2 (10), P3 (15), and P2 has a resource. Wait-Die (WD): (1) P1 requests the resource held by P2. P1 waits. (2) P3 requests the resource held by P2. P3 rolls back. Wound-Wait (WW): (1) P1 requests the resource held by P2. P1 gets the resource and P2 is rolled back. (2) P3 requests the resource held by P2. P3 waits. Differences between WD and WW - In WD, older waits for younger to release resources. - In WW, older never waits for younger. - WD has more roll back than WW. In WD, $P_3$ requests and dies because $P_2$ is older in the above example. If $P_3$ restarts and again asks for the same resource, it rolls back again if $P_2$ is still using the resource. However, in WW, $P_2$ is rolled back by $P_1$. If it requests the resource again, it waits for $P_1$ to release it. - When there are more than one process waiting for a resource held by $P$, which process should be given the resource when $P$ finishes? In WD, the youngest among waiting ones. In WW, the oldest. Layers of distributed systems - **Computer networks** - Local area networks such as Ethernet - Wide area networks such as Internet - **Network services** - Connection-oriented services - Connectionless services - Datagrams - **Network protocols** - Internet Protocol (IP) - Transmission Control Protocol (TCP) - **Middleware** Middleware for Distributed Systems - Middleware is a layer of software between applications and OS that gives a uniform interface. - Central to developing distributed applications. - Different types: - Document based (world-wide web) - File-system based (e.g., NFS) - Shared object-based (CORBA) - Coordination based (Linda, Publish-subscribe, Jini) Summary - Distributed coordination problems - Event ordering - Agreement - Mutual exclusion - Leader election - Deadlock detection - Middleware for distributed application support - Starting next week: Chapter 9 (Security)
{"Source-Url": "http://www.cis.upenn.edu/~lee/03cse380/lectures/ln19-ds-v3.pdf", "len_cl100k_base": 6515, "olmocr-version": "0.1.50", "pdf-total-pages": 65, "total-fallback-pages": 0, "total-input-tokens": 105570, "total-output-tokens": 8811, "length": "2e12", "weborganizer": {"__label__adult": 0.0003077983856201172, "__label__art_design": 0.00032138824462890625, "__label__crime_law": 0.0003905296325683594, "__label__education_jobs": 0.0011205673217773438, "__label__entertainment": 8.726119995117188e-05, "__label__fashion_beauty": 0.0001494884490966797, "__label__finance_business": 0.0004508495330810547, "__label__food_dining": 0.0003352165222167969, "__label__games": 0.000720977783203125, "__label__hardware": 0.0055694580078125, "__label__health": 0.0006222724914550781, "__label__history": 0.0003342628479003906, "__label__home_hobbies": 0.00016832351684570312, "__label__industrial": 0.0007944107055664062, "__label__literature": 0.0002512931823730469, "__label__politics": 0.0002551078796386719, "__label__religion": 0.0004856586456298828, "__label__science_tech": 0.241455078125, "__label__social_life": 0.00011444091796875, "__label__software": 0.0267333984375, "__label__software_dev": 0.71826171875, "__label__sports_fitness": 0.0002903938293457031, "__label__transportation": 0.0006403923034667969, "__label__travel": 0.0002155303955078125}, "weborganizer_max": "__label__software_dev", "avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_ratio": [[0, 26994, 0.01073]], "fineweb_edu_fasttext_gt2__fineweb_edu_fasttext_gt2__score": [[0, 26994, 0.53879]], "ft_lang_id_en_doc_v2__ft_lang_id_en_doc_v2__en": [[0, 26994, 0.89642]], "google_gemma-3-12b-it_contains_pii": [[0, 0, null], [0, 510, false], [510, 1580, null], [1580, 2574, null], [2574, 2893, null], [2893, 3092, null], [3092, 3223, null], [3223, 3718, null], [3718, 3944, null], [3944, 4376, null], [4376, 4485, null], [4485, 4915, null], [4915, 5312, null], [5312, 5682, null], [5682, 5951, null], [5951, 6373, null], [6373, 7084, null], [7084, 7291, null], [7291, 7793, null], [7793, 8758, null], [8758, 8784, null], [8784, 9210, null], [9210, 9239, null], [9239, 9449, null], [9449, 9627, null], [9627, 9836, null], [9836, 10085, null], [10085, 10356, null], [10356, 10381, null], [10381, 10887, null], [10887, 11479, null], [11479, 12386, null], [12386, 12645, null], [12645, 13111, null], [13111, 13516, null], [13516, 13767, null], [13767, 14151, null], [14151, 14457, null], [14457, 15119, null], [15119, 15561, null], [15561, 16121, null], [16121, 16584, null], [16584, 17155, null], [17155, 17479, null], [17479, 18117, null], [18117, 18326, null], [18326, 18765, null], [18765, 19228, null], [19228, 19721, null], [19721, 20366, null], [20366, 21013, null], [21013, 21556, null], [21556, 21810, null], [21810, 22385, null], [22385, 22933, null], [22933, 23091, null], [23091, 23666, null], [23666, 24327, null], [24327, 24740, null], [24740, 25055, null], [25055, 25394, null], [25394, 26057, null], [26057, 26402, null], [26402, 26761, null], [26761, 26994, null]], "google_gemma-3-12b-it_is_public_document": [[0, 0, null], [0, 510, true], [510, 1580, null], [1580, 2574, null], [2574, 2893, null], [2893, 3092, null], [3092, 3223, null], [3223, 3718, null], [3718, 3944, null], [3944, 4376, null], [4376, 4485, null], [4485, 4915, null], [4915, 5312, null], [5312, 5682, null], [5682, 5951, null], [5951, 6373, null], [6373, 7084, null], [7084, 7291, null], [7291, 7793, null], [7793, 8758, null], [8758, 8784, null], [8784, 9210, null], [9210, 9239, null], [9239, 9449, null], [9449, 9627, null], [9627, 9836, null], [9836, 10085, null], [10085, 10356, null], [10356, 10381, null], [10381, 10887, null], [10887, 11479, null], [11479, 12386, null], [12386, 12645, null], [12645, 13111, null], [13111, 13516, null], [13516, 13767, null], [13767, 14151, null], [14151, 14457, null], [14457, 15119, null], [15119, 15561, null], [15561, 16121, null], [16121, 16584, null], [16584, 17155, null], [17155, 17479, null], [17479, 18117, null], [18117, 18326, null], [18326, 18765, null], [18765, 19228, null], [19228, 19721, null], [19721, 20366, null], [20366, 21013, null], [21013, 21556, null], [21556, 21810, null], [21810, 22385, null], [22385, 22933, null], [22933, 23091, null], [23091, 23666, null], [23666, 24327, null], [24327, 24740, null], [24740, 25055, null], [25055, 25394, null], [25394, 26057, null], [26057, 26402, null], [26402, 26761, null], [26761, 26994, null]], "google_gemma-3-4b-it_v2tag__is_academic_paper": [[0, 5000, true], [5000, 26994, null]], "google_gemma-3-4b-it_v2tag__is_class_syllabus": [[0, 5000, false], [5000, 26994, null]], "google_gemma-3-4b-it_v2tag__is_completion_certificate": [[0, 5000, false], [5000, 26994, null]], "google_gemma-3-4b-it_v2tag__is_court_notice": [[0, 5000, false], [5000, 26994, null]], "google_gemma-3-4b-it_v2tag__is_homework_assignment": [[0, 5000, false], [5000, 26994, null]], "google_gemma-3-4b-it_v2tag__is_news_article": [[0, 5000, false], [5000, 26994, null]], "google_gemma-3-4b-it_v2tag__is_public_order": [[0, 5000, false], [5000, 26994, null]], "google_gemma-3-4b-it_v2tag__is_resume_cv": [[0, 5000, false], [5000, 26994, null]], "google_gemma-3-4b-it_v2tag__is_test_or_quiz": [[0, 5000, false], [5000, 26994, null]], "google_gemma-3-4b-it_v2tag__is_textbook": [[0, 5000, true], [5000, 26994, null]], "pdf_page_numbers": [[0, 0, 1], [0, 510, 2], [510, 1580, 3], [1580, 2574, 4], [2574, 2893, 5], [2893, 3092, 6], [3092, 3223, 7], [3223, 3718, 8], [3718, 3944, 9], [3944, 4376, 10], [4376, 4485, 11], [4485, 4915, 12], [4915, 5312, 13], [5312, 5682, 14], [5682, 5951, 15], [5951, 6373, 16], [6373, 7084, 17], [7084, 7291, 18], [7291, 7793, 19], [7793, 8758, 20], [8758, 8784, 21], [8784, 9210, 22], [9210, 9239, 23], [9239, 9449, 24], [9449, 9627, 25], [9627, 9836, 26], [9836, 10085, 27], [10085, 10356, 28], [10356, 10381, 29], [10381, 10887, 30], [10887, 11479, 31], [11479, 12386, 32], [12386, 12645, 33], [12645, 13111, 34], [13111, 13516, 35], [13516, 13767, 36], [13767, 14151, 37], [14151, 14457, 38], [14457, 15119, 39], [15119, 15561, 40], [15561, 16121, 41], [16121, 16584, 42], [16584, 17155, 43], [17155, 17479, 44], [17479, 18117, 45], [18117, 18326, 46], [18326, 18765, 47], [18765, 19228, 48], [19228, 19721, 49], [19721, 20366, 50], [20366, 21013, 51], [21013, 21556, 52], [21556, 21810, 53], [21810, 22385, 54], [22385, 22933, 55], [22933, 23091, 56], [23091, 23666, 57], [23666, 24327, 58], [24327, 24740, 59], [24740, 25055, 60], [25055, 25394, 61], [25394, 26057, 62], [26057, 26402, 63], [26402, 26761, 64], [26761, 26994, 65]], "pipe_delimited_lines_v1__pipe_delimited_lines_v1__pipe_delimited_lines_ratio": [[0, 26994, 0.03037]]}
olmocr_science_pdfs
2024-11-30
2024-11-30
466c533ab392b898068cbe4dfa735776cf142461
OPEN-SOURCE SOFTWARE IN ROBOTICS Sanda TIMOFTEI, Emilia BRAD, Anca SARB, Ovidiu STAN Abstract: The “Open source” term arose at the desire of some people that wanted to make available the source code of software that can be afterwards modified, improved and redistributed. In this way, a group formed by people from different places on Earth can work at the same project, in the same time, having at the end a better version of it. Open source software is licensed software offering the possibility to work without any problem, to collaborate in an open manner at a certain idea. Types of open software and hardware will be presented in this paper, precisely the ones that can be used for image processing. Except LINUX operating system, OpenCV is a type of open-source software, a computer vision library, available to everyone that wants to use it or has a better idea concerning a tool of that software, which can be used on other open source software, like ROS environment. In the last part of the paper, a study case using open source software will be presented. Key words: Open-source software, license, OpenCV, ROS, image processing. 1. INTRODUCTION Twenty years ago, after a session that took place in Palo Alto in California, on the 3rd of February, the Open Source Initiative (OSI) was founded as a non-profit global organization. Its aim is to protect and promote open source products, based on free collaboration, education, sustaining the Open Source Definition (OSD). Taking into account the OSD, the abuse of the open source movement has been avoided. [1] Based on the first paragraph, this paper has the aim to put into evidence the presence of what is the meaning of open source and what does it need so that it can be used correctly. Furthermore, people formed communities of individuals by their selves with the aim to help this development. Open-source model is very common when it is about projects like appropriate-technology [5] and drug discovery [6], [7], [2]. Starting from these, the concept of open-source model appeared. In other words, it refers to free documentation or source code, that can be accessed by everyone, while redistributing a certain blueprint or design [8], [9], excluding the idea of proprietary code [2]. Open-source code is an effort made possible by programmers that collaborate, with the aim to improve a code and to make changes on it in such a way as to improve it. After that, it can be transferred as a software license, license that requires certain terms for each change in the source code. [2][20] There are foundations, like Apache Software Foundation, that support the open-source idea. [2] 2. OPEN SOURCE 2.1 Open source model Technology has arisen at such a high level that collaboration in an open way is ordinary. [3], [4]. Furthermore, people formed communities of individuals by their selves with the aim to help this development. Open-source model is very common when it is about projects like appropriate-technology [5] and drug discovery [6], [7], [2]. Starting from these, the concept of open-source model appeared. In other words, it refers to free documentation or source code, that can be accessed by everyone, while redistributing a certain blueprint or design [8], [9], excluding the idea of proprietary code [2]. Open-source code is an effort made possible by programmers that collaborate, with the aim to improve a code and to make changes on it in such a way as to improve it. After that, it can be transferred as a software license, license that requires certain terms for each change in the source code. [2][20] There are foundations, like Apache Software Foundation, that support the open-source idea. [2] 2.2 Open source software The ambiguity of the term “free software” was seen like a discouraging business adoption [12] [13] and it was the starting point for the term “open source” [14]. Precisely, open-source software has the aim to “clarify licensing domain and consumer issues” [2] gaining a wide area and having, as support, Internet development. [10][2] The open source software term seeks to be “open-minded”, commercial [11], and this is why it was proposed and immediately backed in the Linux Journal. All these actions have been part of a movement that enabled this term to be clarified in terms of meaning and used as intended. [14][15][16] People like Richard Stallman, Eric Raymond, Christine Peterson, Todd Anderson, Larry Augustin, Jon Hall, Sam Ockman, and Michael Tiemann are part of the group that created the changed free software movement. [2] Based on this term, an event has also been organized in April 1998, called “Open Source Summit” [17], by Tim O’Reilly. At this summit, people that had been working with open-source projects, by vote, validated the “open-source” term, which was announced, in the same evening, during a press conference [17]. Even if it was accepted, the term “open-source” referred at a part of the domain, reason for which, the first version and the last version had been combined, resulting the term entitled free and open-source software (FOSS) [18]. [2] As its name says, open source software is a software that offers the possibility to be accessed by anyone, it can be used and changed. Moreover, it can be shared, but only under the conditions imposed by OSD. These conditions represent ten criteria that must be accomplished to label a software as being an “Open Source” software. Also, the symbol for this term embodies the idea that it is open to everyone (Figure 1). [1] 2.3. Open source hardware The idea of open source can also be found in hardware (Figure 2) projects, in domains like machine and tools, robotics, prototyping, medical, telephony, home automation and so on, where open source hardware projects are available. The best-known projects are Arduino, 3D Printers, CUBIT, ICub, Wind Turbines, Open Source Ecology, SmartThings. [22] 3. OPEN SOURCE LICENSE The idea to give access for everyone to see, to use and to change the source code, with no prejudice, embodies the principles of being an open source license. In order to see if an open source license accomplishes the requirements, each license has to pass an objective test imposed by Open Source Definition [23]. In order to improve an open-source project, the author must do it under a license, even if it is implicitly already part of the project or explicitly Apache Contributor License Agreement. In some cases, there is no license for the open-source, so the author needs the author’s copyright. This way, the contribution to the project will be accepted [23], [24]. Fig. 1. OSI logo [Google]1 3.1. Open source license – types There is no “the best license” that can be used, so you can choose the one that better fits your requirements, starting from the “popular” ones. To choose the one that fits your work and your needs, it is not necessary to talk to a lawyer; a developer will be able to help you. [23] Considering that there exist 180.000 open-source projects that are available and at least 1400 unique licenses, the management between open-source and closed-source became more complex. Some of the open-sources are done from home or under FOSS license. Some examples of open source software licenses are: Berkeley Software Distribution ("BSD"), Apache, MIT-style (Massachusetts Institute of Technology), GNU General Public License (“GPL”), GNU Lesser General Public License, Eclipse Public License, Mozilla Public License and many more [28][23][25]. In the background, any open-source license has, legally, conditions of copyright. If one of the users violates these conditions, their license will not be available anymore, which means that they are infringing copyright [23]. [23][26] This is one of the reasons why vendors of commercial software are using open source software. [23][27] 4. STUDY CASE IN ROBOTICS 4.1. OpenCV OpenCV (Open Source Computer Vision Library) is machine learning and an open source computer vision software (see logo in Figure 3) that is working under a BSD commercial license, also used for academic purposes. As its name says, OpenCV is a library of codes used in different domains using programming languages like C++, Java and Python on operation systems like Linux, Windows, Android, Mac and iOS. Now, the last version of the software is OpenCV 3.4.1. [29] Having more than 2500 optimized algorithms, from domains like machine learning and state-of-the-art computer vision, these algorithms can be used for a wide number of applications. [29] Applications like identifying, objects, producing 3D point clouds using stereo cameras, detecting and recognizing faces and determining the human actions from a video, removing the red eyes from images done with the flashlight and so on, are using the OpenCV library to get practical applications. “Detecting intrusions in surveillance video in Israel, monitoring mine equipment in China, helping robots navigate and pick up objects at Willow Garage, detection of swimming pool drowning accidents in Europe, running interactive art in Spain and New York, checking runways for debris in Turkey, inspecting labels on products in factories around the world on to rapid face detection in Japan” [29] are just some examples of practical applications that are using OpenCV. [29] Fig. 3. Open source hardware logo [29] 4.2. ROS Robot Operating System (ROS) is another example of open source software, where a wide number of contributors and ancestors are working at this large project. This type of distance-collaboration between people is frequently used and it is developed so fast because of the needs of the research community, especially in the robotics domain. [30] ROS (see Figure 4) can be defined as a collection of libraries, tools, conventions, used to create “complex and robust robot behaviour across a wide variety of robotic platforms” [30], because of the difficulty to create complex application with the robot’s software. [30] Using ROS means to work in a collaborative way to develop “collaborative robotics software” [30]. To be more precise, as an example, let us consider three groups are working on a project that has the aim to recognize objects, of small dimensions. One group is working on mapping the area where the robot will move. The second group is working on navigation, using the map obtained by the first group, to help the last group, detect the small objects by computer vision approach. [30] Based on this information, a study case has been done on image processing, using ROS, that will be presented in the next section. ![Fig. 4. What ROS means [30]](image) 4.3. Extraction on layers This section has the aim to present the obtained results by using open source software in an application that, further on, will be implemented in robotics. The application uses the ROS environment with the aim to convert a coloured image in another format so that it can be further processed. The obtained results can be considered a small step in image processing, but are the starting point in different applications, including the ones where robots are used at the fine art stage. In other words, the study case is about the conversion of a coloured image, in a format that can be used in different ways, for different applications. It must be mentioned that this study case is just a part of a larger research. The study case will be done on the image presented in Figure 5. A certain cover notebook has been used because of the way it looks (it has a large array of colours). This cover enables us to prove the functionality and accuracy of the program created in ROS. To develop a program in ROS, a variety of programming languages can be used. ROS offers the opportunity to develop an application by programming in more programming languages at the same time. These programs will be later incorporated/integrated into the same functional hardware (in this case, a robot). Each program is called a node and each node has its own programming language, starting with C++, Phyton, Java etc. In this study case, C++ programming language was used. ![Fig. 5. Initial image [authors contribution]](image) The idea of this study case is not about extracting the contour of each object that forms the original image, it is about selecting the objects according to their colour, based on the primary colours (RGB - red, green, blue - colour model) (Figure 6) and secondary colours (CYM - cyan, yellow, magenta - colour model) (Fig. 7). Based on Figure 6 and Figure 7, what must be noticed is that the result of the synthesis of the three colours is different. In the case of RGB colour model, by combination of all three colours, the result is white (W); whose value is “255” in binary system. In the case of CYM colour model, the result is black (B), which in binary system is “0”. ![Fig. 6. Primary colours [Google source]](image) Combining primary colours, depending on their value, new colours will result. The first colours that result by combining red, green and blue, are cyan, yellow and magenta. Knowing all of these, a code in C++ has been written to extract each colour on different layers. Using ROS environment, the colour extraction code has been written in a node that is a subscriber and a publisher in the same time. To be a subscriber, the image is taken from a channel, called topic (in this case `ros::Subscriber sub;`), and is given the result on a certain topic called publisher, whose name depends on the colour that is given as result (in this case `ros::Publisher pubR, pubG, pubB, pubY, pubC, pubM;`). The source codes for blue and cyan colour extraction are presented. Comparing the two source codes, it can be noticed that the difference is just the value of one of the primary colours (based on the source codes, it is about green colour value). // BLUE for (int i=0; i<img.height; i++) { for (int j = 0; j< img.width; j++) { int myR= img.data[i*img.width*3+j*3+0]; int myG= img.data[i*img.width*3+j*3+1]; int myB= img.data[i*img.width*3+j*3+2]; if (myB > myG + diff && myB > myR + diff && myB > diff) { temp_img_b.data[i*img.width*3+j*3+3] = 255; } else { temp_img_b.data[i*img.width*3+j*3] = 0; temp_img_b.data[i*img.width*3+j*3+1] = 0; temp_img_b.data[i*img.width*3+j*3+2] = 0; } } } // CYAN for (int i=0; i<img.height; i++) { for (int j = 0; j< img.width; j++) { int myR= img.data[i*img.width*3+j*3+0]; int myG= img.data[i*img.width*3+j*3+1]; int myB= img.data[i*img.width*3+j*3+2]; if (myG > myR + diff && myB > myR + diff && myG > diff && myB > diff) { temp_img_c.data[i*img.width*3+j*3] = 0; temp_img_c.data[i*img.width*3+j*3+1] = 255; temp_img_c.data[i*img.width*3+j*3+2] = 255; } else { temp_img_c.data[i*img.width*3+j*3] = 0; temp_img_c.data[i*img.width*3+j*3+1] = 0; temp_img_c.data[i*img.width*3+j*3+2] = 0; } } } Taking as an example the code for blue primary colour, each pixel from the image, on lines and columns, is analyzed. Comparing its value (intensity of blue in that pixel), which is between 0 and 255, with a threshold, formed by the values of red and green and a constant \( \text{int diff} = 50 \), gives the final colour of the pixel. If in all the comparisons, the value of blue is bigger, then that pixel will take 255 as value, which in this case is blue. The rest of the variables are taking the 0 value. In the second example, for cyan secondary colour, the comparison is a little bit changed. Cyan is the colour that results from blue and green (Table 1). Because of this, each value for blue and green colour must be compared with the value of the red colour and the constant \( \text{int diff} = 50 \). What must be mentioned is that the value of \( \text{diff} \) can be modified, depending on the user and the application where the colour extraction will be used. <table> <thead> <tr> <th>Table 1: Principal and secondary colours</th> </tr> </thead> <tbody> <tr> <td>RED</td> </tr> <tr> <td>RED</td> </tr> <tr> <td>GREEN</td> </tr> <tr> <td>BLUE</td> </tr> </tbody> </table> The results obtained by applying the code written in C++ and implemented in ROS can be seen in Figure 8 and Figure 9, presented as primary colours (RGB) and as secondary colours (CYM). **Fig. 8.** RGB results obtained using extraction on layers starting from initial image (Figure 5) [authors contribution] Image view (2) – red; Image view (3) – green; Image view (4) – blue **Fig. 9.** CYM results obtained using extraction on layers starting from initial image (Figure 5) [authors contribution] Image view (5) – magenta; Image view (6) – yellow; Image view (7) – cyan 5. CONCLUSION Starting from a coloured image, using the basic steps of image processing, different results can be obtained. This paper had the aim to go another way, to make the difference between objects in image. Based on section 4, the wanted results have been obtained. The study case presented in this paper can be considered a forward step in image processing for developers that are part of open source software communities. Based on the obtained results using extraction on layouts, of primary and secondary colours, new ideas or ways for research can be founded. What is important to mention is that open source software has no ending. Its aim is being able to help developers get inspired, starting from an idea that can continually improve or innovated. 6. REFERENCES [6] "Science 2.0 is here as CSIR resorts to open-source drug research for TB" Business Standard, 1 March 2009 [18] https://en.wikipedia.org/wiki/Free_and_open-source_software accessed at May 02, 2018 SOFTWARE OPEN-SOURCE ÎN ROBOTICĂ Rezumat: Termenul "Open source" a apărut din dorința unor persoane de a pune la dispoziție codul sursă al oricărui software care poate fi ulterior modificat, îmbunătățit și redistribuit. În acest fel, un grup de oameni din diferite locuri de pe Pământ pot lucra la același proiect, în același timp, obținând la final o versiune îmbunătățită a acestuia. Software-ul open source este un software cu licență care oferă posibilitatea de a lucra fără probleme, de a colabora într-un mod deschis în ceea ce privește o anumită idee. Tipuri de software și hardware open source vor fi prezentate în această lucrare, punând accentul pe acele care pot fi utilizate pentru procesarea imaginilor. Cu excepția sistemului de operare LINUX, OpenCV este un tip de software open source, o bibliotecă pentru computer vision, disponibilă pentru orice idee doresă să o folosească sau are o idee mai bună cu privire la un instrument al aceluia soft, care poate fi folosit pentru alte programe open source, cum ar fi mediul ROS. În ultima parte a lucrării, va fi prezentat un studiu de caz care utilizează un soft de tip open source. Sandra TIMOFTEI, Design Engineering and Robotics Department, Faculty of Machine Building, Technical University of Cluj-Napoca, Muncii Boulevard 103-105, Cluj-Napoca, Romania, s.timoftei@yahoo.com Emilia BRAD, Design Engineering and Robotics Department, Faculty of Machine Building, Technical University of Cluj-Napoca, Muncii Boulevard 103-105, Cluj-Napoca, Romania, emilia.brad@staff.utcluj.ro Anca SARB, Design Engineering and Robotics Department, Faculty of Machine Building, Technical University of Cluj-Napoca, Muncii Boulevard 103-105, Cluj-Napoca, Romania, anca.sarb@muri.utcluj.ro Ovidiu STAN, Synthetic Dynamics S.R.L., 14B Colonia Breaza Street, Cluj-Napoca, Romania, ovidiu.stan@syntheticdynamics.ro
{"Source-Url": "https://atna-mam.utcluj.ro/index.php/Acta/article/download/1036/965", "len_cl100k_base": 4717, "olmocr-version": "0.1.53", "pdf-total-pages": 8, "total-fallback-pages": 0, "total-input-tokens": 22467, "total-output-tokens": 6294, "length": "2e12", "weborganizer": {"__label__adult": 0.0002770423889160156, "__label__art_design": 0.0011339187622070312, "__label__crime_law": 0.0006823539733886719, "__label__education_jobs": 0.0034427642822265625, "__label__entertainment": 0.00012117624282836914, "__label__fashion_beauty": 0.0001361370086669922, "__label__finance_business": 0.0006222724914550781, "__label__food_dining": 0.0003235340118408203, "__label__games": 0.0009975433349609375, "__label__hardware": 0.0010442733764648438, "__label__health": 0.00044345855712890625, "__label__history": 0.00031828880310058594, "__label__home_hobbies": 0.00019168853759765625, "__label__industrial": 0.0004422664642333984, "__label__literature": 0.00037288665771484375, "__label__politics": 0.00028586387634277344, "__label__religion": 0.00036835670471191406, "__label__science_tech": 0.083740234375, "__label__social_life": 0.00016498565673828125, "__label__software": 0.08148193359375, "__label__software_dev": 0.82275390625, "__label__sports_fitness": 0.0001883506774902344, "__label__transportation": 0.00042057037353515625, "__label__travel": 0.00016188621520996094}, "weborganizer_max": "__label__software_dev", "avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_ratio": [[0, 22798, 0.03835]], "fineweb_edu_fasttext_gt2__fineweb_edu_fasttext_gt2__score": [[0, 22798, 0.82697]], "ft_lang_id_en_doc_v2__ft_lang_id_en_doc_v2__en": [[0, 22798, 0.88523]], "google_gemma-3-12b-it_contains_pii": [[0, 3911, false], [3911, 6636, null], [6636, 10367, null], [10367, 12899, null], [12899, 15147, null], [15147, 16911, null], [16911, 20939, null], [20939, 22798, null]], "google_gemma-3-12b-it_is_public_document": [[0, 3911, true], [3911, 6636, null], [6636, 10367, null], [10367, 12899, null], [12899, 15147, null], [15147, 16911, null], [16911, 20939, null], [20939, 22798, null]], "google_gemma-3-4b-it_v2tag__is_academic_paper": [[0, 5000, true], [5000, 22798, null]], "google_gemma-3-4b-it_v2tag__is_class_syllabus": [[0, 5000, false], [5000, 22798, null]], "google_gemma-3-4b-it_v2tag__is_completion_certificate": [[0, 5000, false], [5000, 22798, null]], "google_gemma-3-4b-it_v2tag__is_court_notice": [[0, 5000, false], [5000, 22798, null]], "google_gemma-3-4b-it_v2tag__is_homework_assignment": [[0, 5000, false], [5000, 22798, null]], "google_gemma-3-4b-it_v2tag__is_news_article": [[0, 5000, false], [5000, 22798, null]], "google_gemma-3-4b-it_v2tag__is_public_order": [[0, 5000, false], [5000, 22798, null]], "google_gemma-3-4b-it_v2tag__is_resume_cv": [[0, 5000, false], [5000, 22798, null]], "google_gemma-3-4b-it_v2tag__is_test_or_quiz": [[0, 5000, false], [5000, 22798, null]], "google_gemma-3-4b-it_v2tag__is_textbook": [[0, 5000, false], [5000, 22798, null]], "pdf_page_numbers": [[0, 3911, 1], [3911, 6636, 2], [6636, 10367, 3], [10367, 12899, 4], [12899, 15147, 5], [15147, 16911, 6], [16911, 20939, 7], [20939, 22798, 8]], "pipe_delimited_lines_v1__pipe_delimited_lines_v1__pipe_delimited_lines_ratio": [[0, 22798, 0.0411]]}
olmocr_science_pdfs
2024-12-08
2024-12-08
e42705061a627f480322f977fefd88c81c6c3ab9
Into The Core IN-DEPTH EXPLORATION OF WINDOWS 10 IOT CORE Paul Sabanal X-Force Advanced Research IBM Security August 3, 2016 Introduction # Overview <table> <thead> <tr> <th>Edition</th> <th>Description</th> <th>Target Devices</th> </tr> </thead> <tbody> <tr> <td>Windows 10 IoT</td> <td>UWP apps, Win32 apps, desktop shell, x86, advanced</td> <td>Kiosk, POS, ATM, Medical devices</td> </tr> <tr> <td>Enterprise</td> <td>lockdown</td> <td></td> </tr> <tr> <td>Windows 10 IoT</td> <td>UWP apps, multiuser support, lockdown features</td> <td>Mobile POS, Industry handheld terminals</td> </tr> <tr> <td>Mobile</td> <td></td> <td></td> </tr> <tr> <td>Windows 10 IoT</td> <td>For low-cost, low-power devices. UWP apps only.</td> <td>Smart home devices, IoT gateway, digital signage</td> </tr> <tr> <td>Core</td> <td>ARM and x86</td> <td></td> </tr> </tbody> </table> Overview Raspberry Pi 2 & 3 - ARM - 32-bit - On-board Wi-fi and Bluetooth, Ethernet - 4 x USB 2.0 Minnowboard Max - x86 - 32-bit - Ethernet - 1 x USB 2.0, 1 x USB 3.0 Dragonboard 410c - ARM - On-board Wi-fi and Bluetooth - 2 x USB 2.0 Internals Internals > FFU C:\>ImgMount.exe "c:\Program Files (x86)\Microsoft IoT\FFU\MinnowBoardMax\flash.ffu" WP8 ROM Image Tools v.1.0.204 htc ROM Image Editor (r) 2007-2012 AnDim & XDA-Developers ImgMount Tool v.1.0.15 (htcRIE) Mounting the image file: 'c:\Program Files (x86)\Microsoft IoT\FFU\MinnowBoardMax\flash.ffu' Loading .FFU image ... ok Creating virtual disk ... ok Mounting MainOS partition as: '\\flash.mnt' ... ok (htcRIE) Successfully mounted an image file. ## Internals > Partition Layout <table> <thead> <tr> <th>Partition</th> <th>File System</th> <th>Mount Point</th> <th>Contents</th> </tr> </thead> <tbody> <tr> <td>EFI System Partition</td> <td>FAT</td> <td>C:\EFIESP</td> <td>Boot manager, boot configurations, UEFI applications</td> </tr> <tr> <td>Crash dump partition</td> <td>FAT32</td> <td>D:</td> <td>Crash dump data</td> </tr> <tr> <td>Main OS</td> <td>NTFS</td> <td>C:</td> <td>OS, registry hives, OEM applications</td> </tr> <tr> <td>Data partition</td> <td>NTFS</td> <td>U:</td> <td>Applications, application data, user data</td> </tr> </tbody> </table> Internals > Boot Process Device powers on and runs SoC firmware bootloader Bootloader launched the UEFI environment and UEFI applications UEFI environment launches Boot Manager (C:\EFI\ESP\EFI\Microsoft\boot\bootmgfw.elf) Boot Manager launches Windows Boot Loader (C:\Windows\System32\Boot\winload.elf) Windows Boot Loader launches main OS Internals > Apps • Universal Windows Platform (UWP) apps – Foreground/default apps – Background app • Console applications – Win32 apps – No UI – C++ only • Headed/Headless mode – UI or no UI Internals > Security Windows Defender Microsoft Passport Virtualization Based Security (VBS) Device Guard Credential Guard Hypervisor Code Integrity (HVCI) Internals > Security - Address Space Layout Randomization (ASLR) - Data Execution Prevention (DEP) - Control Flow Guard (CFG) Internals > Security <table> <thead> <tr> <th>Type</th> <th>Description</th> </tr> </thead> <tbody> <tr> <td>Firmware TPM</td> <td>TPM implemented in the SoC</td> </tr> <tr> <td>Discrete TPM</td> <td>Chip module that can be attached to a board</td> </tr> <tr> <td>Software TPM</td> <td>Software emulated TPM used in development</td> </tr> </tbody> </table> - **Secure Boot** - Prevents device tampering during boot - Stops the system from running unverified binaries - Protects against boot kits, rootkits, and other low level malware - **BitLocker** - Lightweight version of BitLocker - Encryption of user and system files Internals > Windows Update - Automatic forced update - Check for updates through “Windows Update” tab of Windows Device Portal - Pro edition allows deferred updates Attack Surface Starting Nmap 7.12 (https://nmap.org) at 2016-07-13 01:33 Malay Peninsula Standard Time Nmap scan report for 10.0.1.108 Host is up (0.020s latency). Not shown: 996 closed ports PORT STATE SERVICE 22/tcp open ssh 135/tcp open msrpc 445/tcp open microsoft-ds 8080/tcp open http-proxy MAC Address: B8:27:EB:B5:A9:E0 (Raspberry Pi Foundation) Nmap done: 1 IP address (1 host up) scanned in 3.24 seconds Attack Surface > Windows Device Portal - http://<device ip>:8080 - Files can be found in \C:\Windows\WebManagement\www on the device - User name: Administrator, password: p@ssw0rd - Built on top of REST APIs - http://<device ip>:8080/restdocumentation.htm <table> <thead> <tr> <th>Utility</th> <th>Function</th> </tr> </thead> <tbody> <tr> <td>Home</td> <td>Device information, change device name/password, timezone settings</td> </tr> <tr> <td>Apps</td> <td>Install/uninstall of apps</td> </tr> <tr> <td>App File Explorer</td> <td>File explorer for installed apps locations</td> </tr> <tr> <td>Processes</td> <td>Running processes list, process memory usage, and process termination</td> </tr> <tr> <td>Performance</td> <td>Real time graphical display of CPU and I/O usage</td> </tr> <tr> <td>Debugging</td> <td>Starting VS remote debugger, downloading of live kernel and process dumps</td> </tr> <tr> <td>ETW</td> <td>Event tracing</td> </tr> <tr> <td>Perf Tracing</td> <td>Trace logging of CPU, disk, and memory usage</td> </tr> <tr> <td>Devices</td> <td>Device manager for peripherals attached to the device</td> </tr> <tr> <td>Bluetooth</td> <td>Bluetooth device search</td> </tr> <tr> <td>Audio</td> <td>Device speaker and microphone volume adjustments</td> </tr> <tr> <td>Networking</td> <td>WiFi configuration</td> </tr> <tr> <td>Windows Update</td> <td>Last update timestamp, check for updates</td> </tr> <tr> <td>IoT Onboarding</td> <td>Internet Connection Sharing settings, SoftAP settings, AllJoyn onboarding settings</td> </tr> <tr> <td>TPM Configuration</td> <td>TPM installation, configuration, and provisioning</td> </tr> <tr> <td>Remote</td> <td>Enable Windows IoT Remote Server</td> </tr> </tbody> </table> Attack Surface > Network services Attack Surface > Windows Device Portal ### Attack Surface > Windows Device Portal #### App Manager <table> <thead> <tr> <th>App Name</th> <th>App Type</th> <th>Startup</th> </tr> </thead> <tbody> <tr> <td>IoTCoreDefaultApp (Default)</td> <td>Foreground</td> <td>Default App</td> </tr> <tr> <td>IoTOnboardingTask (Startup)</td> <td>Background</td> <td>Remove from Startup</td> </tr> <tr> <td>IoTUAP00E</td> <td>Foreground</td> <td>Set as Default App</td> </tr> <tr> <td>ZWave Adapter Headless Host</td> <td>Background</td> <td>Add to Startup</td> </tr> </tbody> </table> ### Install app 1. **App package** - Choose File: No file chosen - Dependency - Add dependency 2. **Certificate** - Choose File: No file chosen 3. **Deploy** - Go - Reset Attack Surface > Windows Device Portal Running Processes Run command <table> <thead> <tr> <th>PID</th> <th>NAME</th> <th>USER NAME</th> <th>SESSION ID</th> <th>CPU</th> <th>PRIVATE WORKING</th> <th>WORKING SET</th> <th>COMMIT SIZE</th> </tr> </thead> <tbody> <tr> <td>0</td> <td>System Idle Process</td> <td>NT AUTHORITY\SYSTEM</td> <td>0</td> <td>77.13%</td> <td>8.0 KB</td> <td>8.0 KB</td> <td>N/A</td> </tr> <tr> <td>4</td> <td>System</td> <td>NT AUTHORITY\SYSTEM</td> <td>0</td> <td>0.00%</td> <td>8.0 KB</td> <td>60.0 KB</td> <td>N/A</td> </tr> <tr> <td>268</td> <td>smss.exe</td> <td>NT AUTHORITY\SYSTEM</td> <td>0</td> <td>0.00%</td> <td>136.0 KB</td> <td>796.0 KB</td> <td>N/A</td> </tr> <tr> <td>460</td> <td>csrss.exe</td> <td>NT AUTHORITY\SYSTEM</td> <td>0</td> <td>0.00%</td> <td>332.0 KB</td> <td>19.0 MB</td> <td>N/A</td> </tr> <tr> <td>520</td> <td>wininit.exe</td> <td>NT AUTHORITY\SYSTEM</td> <td>0</td> <td>0.00%</td> <td>492.0 KB</td> <td>3.3 MB</td> <td>N/A</td> </tr> <tr> <td>564</td> <td>services.exe</td> <td>NT AUTHORITY\SYSTEM</td> <td>0</td> <td>0.00%</td> <td>1.4 MB</td> <td>4.1 MB</td> <td>N/A</td> </tr> <tr> <td>580</td> <td>lsass.exe</td> <td>NT AUTHORITY\SYSTEM</td> <td>0</td> <td>0.00%</td> <td>2.5 MB</td> <td>9.9 MB</td> <td>N/A</td> </tr> <tr> <td>664</td> <td>dwm.exe</td> <td>Window Manager\DWM-0</td> <td>0</td> <td>0.00%</td> <td>5.5 MB</td> <td>16.2 MB</td> <td>10.1 MB</td> </tr> <tr> <td>672</td> <td>svchost.exe</td> <td>NT AUTHORITY\SYSTEM</td> <td>0</td> <td>0.00%</td> <td>2.1 MB</td> <td>10.8 MB</td> <td>3.6 MB</td> </tr> <tr> <td>724</td> <td>svchost.exe</td> <td>NT AUTHORITY\NETWORK</td> <td>0</td> <td>0.00%</td> <td>1.5 MB</td> <td>5.3 MB</td> <td>2.2 MB</td> </tr> <tr> <td>740</td> <td>sihost.exe</td> <td>kapre\DefaultAccount</td> <td>0</td> <td>0.00%</td> <td>2.1 MB</td> <td>13.9 MB</td> <td>3.4 MB</td> </tr> <tr> <td>848</td> <td>svchost.exe</td> <td>NT AUTHORITY\SYSTEM</td> <td>0</td> <td>0.00%</td> <td>7.1 MB</td> <td>25.5 MB</td> <td>9.3 MB</td> </tr> </tbody> </table> Attack Surface > Windows Device Portal Attack Surface > Network services • SSH – Enabled by default – Starts at boot • Windows File Sharing – Enabled by default – Starts at boot • Windows IoT Remote Server – Remote UI client installed from Windows Store – Can be enabled through the Remote tab in the Windows Device Portal – No authentication – NanoRDPServer.exe Windows IoT Remote Server - Enable Windows IoT Remote Server Windows IoT Remote Server is enabled at boot and currently running. Windows IoT Remote Server enables users to connect from another computer over a network connection to this device using a client app. To access Windows IoT Core device, install the remote client app from [https://www.microsoft.com/store/apps/9nblggh5mnx](https://www.microsoft.com/store/apps/9nblggh5mnx) Attack Surface > Device drivers • Drivers for built-in or external peripherals • Drivers for wireless adapters – Wifi – Bluetooth – ZigBee – Z-Wave • Successful exploitation often results in kernel level privilege Attack Surface > Malware - Password guessing/brute forcing of login credentials - Vulnerabilities in the network services - Lateral infection coming from other machines C:\>mimikatz.exe .#####. mimikatz 2.1 (x64) built on Jul 11 2016 00:32:57 .## ^ ##. "A La Vie, A L'Amour" ## / ## /* * */ ## \\ ## Benjamin DELPY `gentilkiwi` (benjamin@gentilkiwi.com) '## v ##' http://blog.gentilkiwi.com/mimikatz (oe.oe) '#####' with 20 modules * * */ mimikatz # privilege::debug Privilege '20' OK mimikatz # sekurlsa::ssp Authentication Id : 0 ; 247557 (00000000:0003c705) Session : Interactive from 1 User Name : polsab Domain : DESKTOP-39HUL88 Logon Server : (null) Logon Time : 7/20/2016 6:15:59 PM SID : S-1-5-21-4294090806-594742593-2658599142-1001 ssp : [00000000] * Username : Administrator * Domain : 10.0.1.108 * Password : diwata Hacking Hacking > Device Discovery My devices <table> <thead> <tr> <th>Name</th> <th>Type</th> <th>IP Address</th> <th>Settings</th> <th>OS</th> </tr> </thead> <tbody> <tr> <td>cliwata</td> <td>Raspberry Pi 3</td> <td>10.0.1.108</td> <td></td> <td>10.0.14376.0</td> </tr> <tr> <td>kapre</td> <td>Raspberry Pi 3</td> <td>10.0.1.110</td> <td></td> <td>10.0.14376.0</td> </tr> </tbody> </table> Hacking > Device Discovery Offset | Description --- | --- 0 | Device name 0x42 | IP address 0x64 | MAC address 0x96 | Board serial number 0xe6 | Device Type 0x14a | OS version 0x1ae | Device architecture ### Hacking > PowerShell - **Remote device administration and configuration** - **Built-in and 3rd party tools for penetration testing and reversing. Ex:** - CimSweep - Autoruns ```powershell PS C:\WINDOWS\system32> $CimSessionPi2 = New-CimSession -ComputerName 10.0.1.110 -Credential Administrator PS C:\WINDOWS\system32> Get-CSRegistryAutoStart -CimSession $CimSessionPi2 <table> <thead> <tr> <th>Path</th> <th>AutoRunEntry</th> <th>ImagePath</th> <th>Category</th> <th>PSComputerName</th> </tr> </thead> <tbody> <tr> <td>HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon</td> <td>Shell</td> <td>IotShell.exe</td> <td>Logon</td> <td>10.0.1.110</td> </tr> <tr> <td>HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon</td> <td>Userinit</td> <td>userinit.exe</td> <td>Logon</td> <td>10.0.1.110</td> </tr> <tr> <td>HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon</td> <td>VMApplet</td> <td>SystemPropertiesPerformance.exe /pagefile</td> <td>Logon</td> <td>10.0.1.110</td> </tr> <tr> <td>HKLM\SYSTEM\CurrentControlSet\Control\Session Manager</td> <td>BootExecute</td> <td>autocheck autochk</td> <td>BootExecute</td> <td>10.0.1.110</td> </tr> </tbody> </table> ``` <snip> Hacking > Static analysis - UWP apps can be found in Data partition (U:\, also linked with C:\Data) - App installed in U:\Programs \WindowsApps - Lib DLLs and XBF (binary XAML) - Assets folder - Images - Fonts - etc <table> <thead> <tr> <th>Filename</th> <th>Description</th> </tr> </thead> <tbody> <tr> <td>&lt;app_name&gt;.exe</td> <td>App startup stub</td> </tr> <tr> <td>&lt;app_name&gt;.dll</td> <td>App code</td> </tr> <tr> <td>AppManifest.xml</td> <td>UWP app package manifest</td> </tr> <tr> <td>AppBlockMap.xml</td> <td>Cryptographic block hashes for files in package</td> </tr> <tr> <td>AppxSignature.p7x</td> <td>App package digital signature file</td> </tr> </tbody> </table> Hacking > Static analysis ```plaintext ; Section 4. (virtual address 00006000) ; Virtual size : 00000010 ( 16.) ; Section size in file : 00000200 ( 512.) ; Offset to raw data for section: 00003600 ; Flags 60020020: Text Executable Readable ; Alignment : default ; Segment type: Pure code AREA .text, CODE, ALIGN=4 ; ORG 0x406000 CODE16 EXPORT start start MOV R12, #RHBinder__ShimExeMain LDR.W PC, [R12] ; End of function start ``` Hacking > Kernel debugging Hacking > Kernel debugging ```bash # Enable serial debugging bcdedit -dbgsettings serial # Turn on debugging bcdedit -debug on ``` ```powershell Get-WMIObject Win32_pnpentity | ? Name -like "*Serial*COM*" ``` ```plaintext __GENUS : 2 __CLASS : Win32_PnPEntity __SUPERCLASS : CIM_LogicalDevice __DYNASTY : CIM_ManagedSystemElement __RELPATH : Win32_PnPEntity.DeviceID="FTDIBUS\VID_0403+PID_6014+5&3278CBC5&0&3\0000" __PROPERTY_COUNT : 26 __DERIVATION : {CIM_LogicalDevice, CIM_LogicalElement, CIM_ManagedSystemElement} __SERVER : DESKTOP-39HUL88 __NAMESPACE : root\cimv2 __PATH : \\DESKTOP-39HUL88\root\cimv2:Win32_PnPEntity.DeviceID="FTDIBUS\VID_0403+PID_6014+5&3278CBC5&0&3\0000" Availability : Caption : USB Serial Port [COM3] ClassGuid : {4d36e978-e325-11ce-bfc1-08002be10318} CompatibleID : ``` Hacking > Kernel debugging # PORT is the COM port number used by your USB-to-serial adapter windbg.exe -k com:port=<PORT>,baud=921600 Microsoft (R) Windows Debugger Version 10.0.10586.567 X86 Copyright (c) Microsoft Corporation. All rights reserved. Opened \\.\com3 Waiting to reconnect... Connected to Windows 10 14393 ARM (NT) Thumb-2 target at (Sun Jul 24 19:32:43.111 2016 (UTC + 8:00)), ptr64 FALSE Kernel Debugger connection established. Symbol search path is: srv* Executable search path is: *** ERROR: Symbol file could not be found. Defaulted to export symbols for ntkrnlmp.exe - Windows 10 Kernel Version 14393 MP (1 procs) Free ARM (NT) Thumb-2 Built by: 14393.0.armfre.rs1_release.160715-1616 Machine Name: Kernel base = 0x80c1b000 PsLoadedModuleList = 0x80e07c78 System Uptime: 0 days 0:00:00.000 Break instruction exception - code 80000003 (first chance) ******************************************************************************* * * * You are seeing this message because you pressed either * * CTRL+C (if you run console kernel debugger) or, * * CTRL+BREAK (if you run GUI kernel debugger), * * on your debugger machine's keyboard. * * * * THIS IS NOT A BUG OR A SYSTEM CRASH * * * * If you did not intend to break into the debugger, press the "g" key, then * * press the "Enter" key now. This message might immediately reappear. If it * * does, press "g" and "Enter" again. * ******************************************************************************* *** ERROR: Symbol file could not be found. Defaulted to export symbols for ntkrnlmp.exe - nt!DbgBreakPointWithStatus: 80c40d90 defe __debugbreak Hacking > User mode debugging # PORT is the local port you want dbgsrv to listen on C:\Windows\System32\Debuggers\dbgsrv.exe -t tcp:port=<PORT> Microsoft (R) Windows Debugger Version 10.0.10586.567 X86 Copyright (c) Microsoft Corporation. All rights reserved. *** wait with pending attach Symbol search path is: srv* Executable search path is: ModLoad: 01110000 011db000 C:\windows\system32\WebManagement.exe ModLoad: 77400000 77565000 C:\windows\SYSTEM32\ntdll.dll ModLoad: 77270000 773fe000 C:\windows\System32\KERNELBASE.dll (69c.280): Break instruction exception - code 80000003 (first chance) ntdll!DbgBreakPoint: 77422740 defe __debugbreak 0:005> !peb InheritedAddressSpace: No ReadImageFileExecuteOptions: No BeingDebugged: Yes ImageBaseAddress: 01110000 Ldr 774eb9e0 Ldr.Initialized: Yes Ldr.InInitializationOrderModuleList: 00c41738 . 00c4fcd0 Ldr.InLoadOrderModuleList: 00c41810 . 00c4fcc0 Ldr.InMemoryOrderModuleList: 00c41818 . 00c4fcc8 Base TimeStamp Module 11100000 57898ebe Jul 16 09:32:46 2016 C:\windows\system32\WebManagement.exe 77400000 57898ba5 Jul 16 09:19:33 2016 C:\windows\SYSTEM32\ntdll.dll 77270000 57898c4c Jul 16 09:22:20 2016 C:\windows\System32\KERNELBASE.dll 0:005> u $exentry WebManagement+0xa6631: 011b6630 e92d4800 push {r11,lr} 011b6634 46eb mov r11,sp 011b663e f000fb65 bl WebManagement+0xa6d04 (011b6d04) 011b664a e8bd4800 pop {r11,lr} 011b665e f7ffbf25 b.w WebManagement+0xa648c (011b648c) 011b6664 0000 movs r0,0 011b666e f24c6c64 mov r12,#0xC664 011b6678 f2c01c1c movt r12,#0x11C Hacking > Crash Dump - Start Visual Studio Remote Debugger - Start - Run as Default Account - Live kernel dumps - Download live kernel dump - Bugcheck dumps on device - Live process dumps - Refresh list - PID | NAME - 0 | System Idle Process - 4 | System - 268 | smss.exe - 102 | Microsoft (R) Windows Debugger Version 10.0.10586.567 X86 Copyright (c) Microsoft Corporation. All rights reserved. Loading Dump File [d:\winiot\WebManagement.exe-LiveUM-2016-07-24-12-36-09.dmp] User Mini Dump File: Only registers, stack and portions of memory are available Symbol search path is: srv* Executable search path is: Windows 10 Version 14376 MP (4 procs) Free ARM (NT) Thumb-2 Product: WinNt, suite: SingleUserTS Built by: 10.0.14376.0 (rs1_release.160624-1700) Machine Name: Debug session time: Mon Jul 25 03:36:09.000 2016 (UTC + 8:00) System Uptime: not available Process Uptime: 1 days 4:48:37.000 ......................... .... Loading unloaded module list Cannot read PEB32 from WOW64 TEB32 ffffffff - Win32 error 0n30 Unable to load image C:\Windows\System32\ntdll.dll, Win32 error On2 ** WARNING: Unable to verify timestamp for ntdll.dll ntdll!NtWaitForSingleObject+0x6: ** WARNING: Unable to verify timestamp for KERNELBASE.dll 77320ab6 4770 bx lr {KERNELBASE!WaitForSingleObjectEx+0xc0 (76fedf30)} 0:000> | 0:000> !peb PEB at 032f8000 InheritedAddressSpace: No ReadImageFileExecOptions: No BeingDebugged: No ImageBaseAddress: 00a00000 Ldr 773eb9e0 Ldr.Initialized: Yes Ldr.InInitializationOrderModuleList: 034a1730 . 034ae758 Ldr.InLoadOrderModuleList: 034a1808 . 034ae748 Ldr.InMemoryOrderModuleList: 034a1810 . 034ae750 Base TimeStamp Module a000000 576dee48 Jun 25 10:36:56 2016 C:\windows\system32\WebManagement.exe 77300000 576deb18 Jun 25 10:23:20 2016 C:\windows\SYSTBM32\ntdll.dll 76f20000 576debe7 Jun 25 10:26:47 2016 C:\windows\System32\KERNELBASE.dll 770b0000 576debda Jun 25 10:26:34 2016 C:\windows\System32\combase.dll 76ce0000 576deb16 Jun 25 10:23:18 2016 C:\windows\System32\ucrtbase.dll 76e30000 576ded32 Jun 25 10:32:18 2016 C:\windows\System32\RPCRT4.dll 76ed0000 576deeeb Jun 25 10:36:11 2016 C:\windows\System32\kernel32legacy.dll 76d90000 576deea6 Jun 25 10:38:34 2016 C:\windows\System32\bcryptPrimitives.dll Hacking > Fuzzing • Current Approach – Old school – REST APIs to control device • Future Approach – Corpus driven fuzzing – WinAFL Recommendations **Recommendations** **Segment your network** - Mitigates lateral infection - Incident isolation and cleanup **Protect network services** - Use built-in firewall - Disable unnecessary services **Change default Administrator password** -Eliminates most malware infection attempts today **Use devices supporting TPM** - Minnowboard + Dragonboard - Raspberry Pi + Discrete TPM **Take advantage of available security features** - Enable Secure Boot - Enable BitLocker Conclusion Conclusion Windows 10 IoT Core’s features makes it an attractive alternative to today’s IoT OS Attack surface is smaller than other computing devices, but if IoT services are factored in, will be bigger Vendors/makers should be careful about mis-configurations More security research needed/encouraged Questions? THANK YOU FOLLOW US ON: - ibm.com/security - securityintelligence.com - xforce.ibmcloud.com - @ibmsecurity - youtube/user/ibmsecuritysolutions © Copyright IBM Corporation 2016. All rights reserved. The information contained in these materials is provided for informational purposes only, and is provided AS IS without warranty of any kind, express or implied. IBM shall not be responsible for any damages arising out of the use of, or otherwise related to, these materials. Nothing contained in these materials is intended to, nor shall have the effect of, creating any warranties or representations from IBM or its suppliers or licensors, or altering the terms and conditions of the applicable license agreement governing the use of IBM software. References in these materials to IBM products, programs, or services do not imply that they will be available in all countries in which IBM operates. Product release dates and/or capabilities referenced in these materials may change at any time at IBM’s sole discretion based on market opportunities or other factors, and are not intended to be a commitment to future product or feature availability in any way. IBM, the IBM logo, and other IBM products and services are trademarks of the International Business Machines Corporation, in the United States, other countries or both. Other company, product, or service names may be trademarks or service marks of others. Statement of Good Security Practices: IT system security involves protecting systems and information through prevention, detection and response to improper access from within and outside your enterprise. Improper access can result in information being altered, destroyed, misappropriated or misused or can result in damage to or misuse of your systems, including for use in attacks on others. No IT system or product should be considered completely secure and no single product, service or security measure can be completely effective in preventing improper use or access. IBM systems, products and services are designed to be part of a lawful, comprehensive security approach, which will necessarily involve additional operational procedures, and may require other systems, products or services to be most effective. IBM DOES NOT WARRANT THAT ANY SYSTEMS, PRODUCTS OR SERVICES ARE IMMUNE FROM, OR WILL MAKE YOUR ENTERPRISE IMMUNE FROM, THE MALICIOUS OR ILLEGAL CONDUCT OF ANY PARTY.
{"Source-Url": "https://www.blackhat.com/docs/us-16/materials/us-16-Sabanal-Into-The-Core-In-Depth-Exploration-Of-Windows-10-IoT-Core.pdf", "len_cl100k_base": 7270, "olmocr-version": "0.1.53", "pdf-total-pages": 46, "total-fallback-pages": 0, "total-input-tokens": 57146, "total-output-tokens": 8780, "length": "2e12", "weborganizer": {"__label__adult": 0.00142669677734375, "__label__art_design": 0.001171112060546875, "__label__crime_law": 0.0234832763671875, "__label__education_jobs": 0.0013151168823242188, "__label__entertainment": 0.0003552436828613281, "__label__fashion_beauty": 0.0004227161407470703, "__label__finance_business": 0.0014410018920898438, "__label__food_dining": 0.0005421638488769531, "__label__games": 0.0043182373046875, "__label__hardware": 0.1865234375, "__label__health": 0.0013370513916015625, "__label__history": 0.0005245208740234375, "__label__home_hobbies": 0.0006918907165527344, "__label__industrial": 0.003047943115234375, "__label__literature": 0.00047659873962402344, "__label__politics": 0.0007004737854003906, "__label__religion": 0.0009102821350097656, "__label__science_tech": 0.2724609375, "__label__social_life": 0.00021755695343017575, "__label__software": 0.1986083984375, "__label__software_dev": 0.298095703125, "__label__sports_fitness": 0.00069427490234375, "__label__transportation": 0.00102996826171875, "__label__travel": 0.00022840499877929688}, "weborganizer_max": "__label__software_dev", "avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_ratio": [[0, 24294, 0.07018]], "fineweb_edu_fasttext_gt2__fineweb_edu_fasttext_gt2__score": [[0, 24294, 0.04066]], "ft_lang_id_en_doc_v2__ft_lang_id_en_doc_v2__en": [[0, 24294, 0.60507]], "google_gemma-3-12b-it_contains_pii": [[0, 128, false], [128, 128, null], [128, 141, null], [141, 1227, null], [1227, 1465, null], [1465, 1475, null], [1475, 1943, null], [1943, 2781, null], [2781, 3126, null], [3126, 3333, null], [3333, 3493, null], [3493, 3620, null], [3620, 4370, null], [4370, 4536, null], [4536, 4551, null], [4551, 4963, null], [4963, 6936, null], [6936, 6970, null], [6970, 7009, null], [7009, 7674, null], [7674, 9396, null], [9396, 9435, null], [9435, 9778, null], [9778, 10215, null], [10215, 10440, null], [10440, 11273, null], [11273, 11281, null], [11281, 11577, null], [11577, 11782, null], [11782, 12886, null], [12886, 13734, null], [13734, 14168, null], [14168, 14195, null], [14195, 14999, null], [14999, 17054, null], [17054, 17199, null], [17199, 18581, null], [18581, 18898, null], [18898, 20937, null], [20937, 21078, null], [21078, 21094, null], [21094, 21562, null], [21562, 21573, null], [21573, 21879, null], [21879, 21890, null], [21890, 24294, null]], "google_gemma-3-12b-it_is_public_document": [[0, 128, true], [128, 128, null], [128, 141, null], [141, 1227, null], [1227, 1465, null], [1465, 1475, null], [1475, 1943, null], [1943, 2781, null], [2781, 3126, null], [3126, 3333, null], [3333, 3493, null], [3493, 3620, null], [3620, 4370, null], [4370, 4536, null], [4536, 4551, null], [4551, 4963, null], [4963, 6936, null], [6936, 6970, null], [6970, 7009, null], [7009, 7674, null], [7674, 9396, null], [9396, 9435, null], [9435, 9778, null], [9778, 10215, null], [10215, 10440, null], [10440, 11273, null], [11273, 11281, null], [11281, 11577, null], [11577, 11782, null], [11782, 12886, null], [12886, 13734, null], [13734, 14168, null], [14168, 14195, null], [14195, 14999, null], [14999, 17054, null], [17054, 17199, null], [17199, 18581, null], [18581, 18898, null], [18898, 20937, null], [20937, 21078, null], [21078, 21094, null], [21094, 21562, null], [21562, 21573, null], [21573, 21879, null], [21879, 21890, null], [21890, 24294, null]], "google_gemma-3-4b-it_v2tag__is_academic_paper": [[0, 5000, true], [5000, 24294, null]], "google_gemma-3-4b-it_v2tag__is_class_syllabus": [[0, 5000, false], [5000, 24294, null]], "google_gemma-3-4b-it_v2tag__is_completion_certificate": [[0, 5000, false], [5000, 24294, null]], "google_gemma-3-4b-it_v2tag__is_court_notice": [[0, 5000, false], [5000, 24294, null]], "google_gemma-3-4b-it_v2tag__is_homework_assignment": [[0, 5000, false], [5000, 24294, null]], "google_gemma-3-4b-it_v2tag__is_news_article": [[0, 5000, false], [5000, 24294, null]], "google_gemma-3-4b-it_v2tag__is_public_order": [[0, 5000, false], [5000, 24294, null]], "google_gemma-3-4b-it_v2tag__is_resume_cv": [[0, 5000, false], [5000, 24294, null]], "google_gemma-3-4b-it_v2tag__is_test_or_quiz": [[0, 5000, false], [5000, 24294, null]], "google_gemma-3-4b-it_v2tag__is_textbook": [[0, 5000, false], [5000, 24294, null]], "pdf_page_numbers": [[0, 128, 1], [128, 128, 2], [128, 141, 3], [141, 1227, 4], [1227, 1465, 5], [1465, 1475, 6], [1475, 1943, 7], [1943, 2781, 8], [2781, 3126, 9], [3126, 3333, 10], [3333, 3493, 11], [3493, 3620, 12], [3620, 4370, 13], [4370, 4536, 14], [4536, 4551, 15], [4551, 4963, 16], [4963, 6936, 17], [6936, 6970, 18], [6970, 7009, 19], [7009, 7674, 20], [7674, 9396, 21], [9396, 9435, 22], [9435, 9778, 23], [9778, 10215, 24], [10215, 10440, 25], [10440, 11273, 26], [11273, 11281, 27], [11281, 11577, 28], [11577, 11782, 29], [11782, 12886, 30], [12886, 13734, 31], [13734, 14168, 32], [14168, 14195, 33], [14195, 14999, 34], [14999, 17054, 35], [17054, 17199, 36], [17199, 18581, 37], [18581, 18898, 38], [18898, 20937, 39], [20937, 21078, 40], [21078, 21094, 41], [21094, 21562, 42], [21562, 21573, 43], [21573, 21879, 44], [21879, 21890, 45], [21890, 24294, 46]], "pipe_delimited_lines_v1__pipe_delimited_lines_v1__pipe_delimited_lines_ratio": [[0, 24294, 0.15514]]}
olmocr_science_pdfs
2024-12-10
2024-12-10
bdf87db9fa63514de011c5c7ade09629127a484e
Creating disaggregated network services with eBPF: the Kubernetes network provider use case Original Availability: This version is available at: 11583/2970898 since: 2022-09-05T13:01:36Z Publisher: Institute of Electrical and Electronics Engineers Inc. Published DOI:10.1109/NetSoft54395.2022.9844062 Terms of use: openAccess This article is made available under terms and conditions as specified in the corresponding bibliographic description in the repository Publisher copyright IEEE postprint/Author's Accepted Manuscript ©2022 IEEE. Personal use of this material is permitted. Permission from IEEE must be obtained for all other uses, in any current or future media, including reprinting/republishing this material for advertising or promotional purposes, creating new collecting works, for resale or lists, or reuse of any copyrighted component of this work in other works. (Article begins on next page) Creating Disaggregated Network Services with eBPF: the Kubernetes Network Provider Use Case Federico Parola, Leonardo Di Giovanna, Giuseppe Ognibene, Fulvio Risso Dept. of Control and Computer Engineering, Politecnico di Torino 24, Corso Duca degli Abruzzi, Torino, 10129, Italy Email: {federico.parola, leonardo.digiovanna, giuseppe.ognibene, fulvio.risso}@polito.it Abstract—The eBPF technology enables the creation of custom and highly efficient network services, running in the Linux kernel, tailored to the precise use case under consideration. However, the most prominent examples of such network services in eBPF follow a monolithic approach, in which all required code is created within the same program block. This makes the code hard to maintain, to extend, and difficult to reuse in other use cases. This paper leverages the Polycube framework to demonstrate that a disaggregated approach is feasible also with eBPF, with minimal overhead, introducing a larger degree of code reusability. This paper considers a complex network scenario, such as a complete network provider for Kubernetes, presenting the resulting architecture and a preliminary performance evaluation. I. INTRODUCTION The extended Berkeley Packet Filter (eBPF) allows executing arbitrary code in different kernel hooks, which are triggered upon multiple events, such as a syscall or a packet received. This enables to extend the processing done by the kernel without changing its source code or loading kernel modules. eBPF code is sandboxed in order to guarantee that a user provided program can not compromise the functioning of the kernel. Several projects leverage eBPF to bring new functionality to the kernel in the fields of security, monitoring and networking. However, most of the networking-related projects implement new features as monolithic eBPF programs, making the code hard to maintain, to extend, and difficult to reuse in other use cases. In this respect, the Polycube software framework [1] addresses some of the well-known eBPF limitations when creating complex virtual network functions [2], and introduces the capability to split eBPF software in multiple, independent network functions, which can be arbitrarily connected in order to create a more complex service graph. This enables the creation of complex networking services by compositing elementary basic blocks (e.g., bridge, router, firewall, NAT, load balancer, and more), with high degree of reusability. Container networking is a perfect example of such scenario, and has gained key importance with the diffusion of the microservices architecture and the decomposition of applications in a collection of small, loosely-coupled services running in containers. Container orchestrators such as Kubernetes (K8s) must provide a flexible and efficient network infrastructure, since containers can be created and destroyed at high frequency, must exchange a lot of data and must be easily accessible from the Internet. However, K8s defines only a functional networking model and it relies on 3rd party plugins for the actual implementation of network services. This paper shows how a K8s network provider can be created using solely eBPF primitives according to the disaggregated services model, i.e., defining a modular architecture based on traditional network components such as routers, load balancers and NATs, and without giving up on performance. This paper is structured as follows. Section II provides an overview of the K8s networking model and how Polycube achieves service disaggregation. Section III describes the overall node architecture of our solution while Section IV shows a preliminary performance comparison compared to existing solutions. Finally, Section V describes the relevant related work and Section VI draws our conclusions, highlighting the potential future work. II. BACKGROUND A. Kubernetes networking Kubernetes is an open-source orchestrator for containerized applications and defines a functional network architecture organized in three levels. (i) Pods, the basic scheduling concept, execute containerized applications that are connected to a default virtual network, whose outreach is limited to a single server (node, in the Kubernetes terminology). Pods are ephemeral entities that can be destroyed and re-spawned if needed, even on another node. Each server can host a maximum number of pods, usually organized in a contiguous and private address space (e.g., consecutive /24 networks on different nodes). (ii) Physical nodes, which inherit their addressing space from the physical datacenter network; for scalability reasons, this usually includes switched and routed portions. (iii) Services, a higher-level concept that enables the reachability of one or more (homogeneous) pods by means of the same network identifier (e.g., IP address). This primitive guarantees the decoupling between the service IP endpoint, which remains stable, from the actual pod(s) that provides the service, whose IP can change (e.g., in case the pod is restarted in another location) or it may be present in multiple replicas (hence, multiple IPs could be used). Services leverage a third addressing space, disjoint from pod and datacenter addresses. Kubernetes foresees three types of services. A ClusterIP identifies a service that is reachable only from pods within the cluster, or by an application that runs on the cluster nodes. A NodePort service, instead, is reachable from outside the datacenter: a TCP/UDP port \(<nport>\) is allocated to the service itself, and all packets directed to any \(<node_ip_address:nport>\) will be redirected to one of the pods associated to the given service. NodePorts are not widely used because they require (i) nodes with reachable (e.g., public) IP addresses; (ii) external users to know the IP addresses of the nodes and (even worse) (iii) the port that has been allocated. Finally, a LoadBalancer service allocates a public IP address associated to the given service, which is achieved by interacting with an external entity in charge of the above public addresses; all packets directed to the LoadBalancer IP address will be delivered to one of the corresponding pods. Basic connectivity between pods is provided through the cooperation of datacenter networking and plugins implementing the CNI (Container Network Interface) [3], a specification that enables changeable modules that configure network interfaces in Linux containers. The CNI specification is very simple, dealing only with network connectivity of containers and removing allocated resources when the container is deleted. Instead, packets to services are by default handled by a dedicated Kubernetes component, kube-proxy, which configures iptables with the proper rules to translate service IP addresses into pod IP addresses, and to implement load-balancing policies. Most of the so-called CNI providers (e.g., Cilium, Calico, Flannel, etc) implement more than just the base CNI specification and include (i) data-center wide networking (either using an overlay model, e.g., through vxlan interfaces, or direct routing, hence interacting with the datacenter physical infrastructure to push the proper routes that satisfy K8s reachability rules) and (ii) IP address management (IPAM module). Instead, most of the CNI providers rely on kube-proxy for services: a packet coming from a pod and directed to a service is delivered by the CNI to kube-proxy, which operates the proper transformation on IP addresses and ports and returns it again to the network plug-in, which takes care of delivering it to the target pod, possibly traversing the datacenter network. K8s adopts a functional model for networking, defining a set of behavioral rules for network connectivity\(^1\) but without specifying how those must be implemented by the specific network provider. In addition to rules already mentioned for services, it adds the following ones for basic connectivity: (i) all pods can communicate with all other pods without NAT; (ii) agents on a node can communicate with all pods on that node; (iii) pods in the host network of a node can communicate with all pods on all nodes without NAT. It turns out that network providers have full freedom to choose their own implementation strategy, hence privileging e.g., the easiness of use, performance, scalability, and more. However, this freedom is widely recognized as a nightmare, being very difficult to understand how each network provider works under the hood, hence severely impairing the capability of a network engineer to debug a problem. This is exacerbated by the complexity of the Kubernetes networking, which overall includes functions such as bridging and routing (for pod-to-pod connectivity), load balancing and NAT (for pod-to-service and Internet-to-service), and masquerading NAT (for pod-to-Internet), not to mention the necessity of security policies (hence, firewalls) to protect both pod-to-everything and external-to-everything communications. Finally, all the above networking components must be integrated with a control plane, which interact with K8s and detect any change in the status of the cluster (e.g., a node/pod/service is added/removed, a service is scaled up/down, etc.), hence propagating the required configurations in all involved components (e.g., adding a new node requires configuring a new route toward that node in the routing table of all existing nodes). Given this complexity, it becomes evident that the capability to rely on well-known (disaggregated) functions (e.g., bridging, routing, load balancers), each one running with their configurations and state, would greatly simplify day-by-day monitoring and debugging operations compared to network providers created according to the monolithic model. B. Service disaggregation with Polycube Polycube [1] is an open-source software framework based on eBPF that enables the creation of arbitrary network function chains, adopting the same model (boxes connected through wires) currently used in the physical world. Polycube network functions, called cubes, are composed by an eBPF-based data plane running in kernel (actually one or more eBPF programs) and a control/management plane running in user space. A user space daemon (polycubed) provides a centralized point of control, allowing to access the configuration and state of cubes through a RESTful API. Cubes can be seamlessly connected to each other or to network interfaces through virtual ports, an abstraction that is implemented through an eBPF wrapping program that performs some pre- and post-processing in order to receive/send packets from the previous/to the next component in the chain. To implement this redirection mechanism, each port is identified by a unique ID inside the cube, and each cube maintains a forward chain map containing information about the peer associated to each port. This information is used by the post-processor to apply the correct action to forward the packet, that could be either a tail call to the eBPF data plane of the next cube or a bpf_redirect() to a destination interface. Figure 1 shows an example of this mechanism for a simple topology composed of one router and one bridge. Chaining capabilities of Polycube represent a suitable way to create disaggregated services; however, this solution has never been validated in a complex scenario such as K8s networking. III. ARCHITECTURE Our proposed architecture targets the entire K8s networking, including also services and, potentially, network policies, hence replacing also kube-proxy, i.e., the component that provides cluster-wide service-to-pod translation and load balancing. Our network provider supports ClusterIP and NodePort services and relies on a VxLAN overlay network to support inter-node communication. The current version of the prototype does not support security policies but, thanks to the modular approach, this and other functionalities can easily be added without any change in the other components. The architecture (shown in Fig. 2) leverages four Polycube-based independent network services, while it relies on the kernel to handle the lifecycle of VxLAN tunnels. A. Main components K8s vs Linux Stack Discriminator and NAT (DISC-NAT). This service performs source NATting for the pod-to-Internet traffic, replacing the address of the pod with the address of the node. For incoming packets, it distinguishes among traffic directed to the host (either directly or because it needs VxLAN processing) and traffic directed to pods (an external host trying to contact a NodePort service or the return traffic of a pod). This is done by checking that the packet (i) does not belong to a NATted session (i.e., a lookup in the NAT session table of the service), and (ii) that is not directed to a NodePort service (i.e., a check against the TCP/UDP destination port of the packet). In case both lookups fail, the packet is sent to the Linux network stack. Vice versa, in the first case we apply the reverse NAT rule and the packet continues its journey towards the pods. In the second case, different actions can be applied according to the ExternalTrafficPolicy of the rule. If the policy is local, the traffic is allowed to reach only backend pods located on the current node, hence the packet can proceed towards the pod without modifications. In case the policy is cluster, the packet can also reach backend pods located on other nodes. Since later in the chain the packet will be processed by a load balancer and we must guarantee that the return packet will transit through the same load balancer, we apply source NAT replacing the source IP address with the address of a fictitious pod belonging to the PodCIDR of the current node (currently the first address of the range is used). External Load Balancer (ELB). This element maps new sessions coming from the Internet and directed to a NodePort service to a corresponding backend based on the 5-tuple of the first packet. This load balancing decision is stored in a session table, implemented as a Least Recently Used (LRU) eBPF map, and reused for all subsequent packets. Old sessions are automatically purged by the LRU map. Incoming packets are updated with destination/port of the backend, while source fields are restored to service values for outgoing traffic. Router. Since K8s requires that (i) all the pods in the cluster can communicate with all pods without NAT and (ii) different network addresses (PodCIDR) are allocated to pods on each node, a routing component is required. To facilitate the operations of the Internal Load Balancer (see later), we do not use a bridge between pods, hence forcing all pod traffic to be always delivered to the router. In fact, our network plugin assigns a /32 network to each pod and adds an ARP static entry for the gateway; hence all the packets are sent directly to the gateway, with pods never issuing any ARP request. The router is configured with four ports: (1) towards the physical interface of the node; (2) towards local pods, configured with the proper PodCIDR (e.g., /24); (3) to enable the reachability of K8s processes and pods running in the host network (e.g., kubelet); (4) connected to a kernel VxLAN interface, which is used for inter-node pod-to-pod communication. Internal Load Balancer (ILB). This load balancer operates on traffic coming from local pods and directed to ClusterIP services; all the other traffic is forwarded as is. This module has two types of ports; ‘edge’ ports are connected to entities that generate new sessions (hence, pods), while the ‘server’ port is the one used to reach the final servers, hence is connected to the router. Edge ports are configured with the IP address of the pod in order to be able to forward packets coming from the router to the correct destination. The load balancing logic is the same of the ELB, with a service-specific InternalTrafficPolicy attribute determining which backends (local or cluster-wide) are configured in the load balancer. K8s Control Logic. A K8s operator is in charge of reacting to the cluster events and reconfigure the required network parameters in the controlled cluster. The operator has to react to events related to the following three Kubernetes resources. (1) Nodes: when a node joins/leaves the cluster, a route is added/removed in the Router to update the reachability of the given PodCIDR through the VxLAN overlay network, and the node address is added to the VxLAN configuration. (2) Services: the operator watches events regarding ClusterIP and NodePort services. ClusterIP services trigger an update of the ILB, while a NodePort triggers an update of the ELB and DISC-NAT module for the obvious reasons, as well as the ILB because of the creation of the ClusterIP address that is associated with the NodePort service. (3) Endpoints: the operator watches any event that refers to Endpoints associated to Services. For each pair (address, port) extracted from the endpoints object, the corresponding service backend is updated on the proper Load Balancer: the ILB for ClusterIP services and both for NodePort services. This component is deployed as a K8s DaemonSet, which ensures it runs on any node; K8s adopts a distributed configuration, in which each node has its own agent in charge of the node network configuration. This DaemonSet runs as privileged pod, and it includes the polykube-operator container (running the actual K8s control plane) and the polycubed container (running the Polycube daemon). The two communicate through the node loopback interface. B. Communication scenarios The main communication scenarios of a typical K8s cluster, as shown in Fig. 3, are implemented as follows. Pod-to-pod. The originating pod sends its packets to the ILB, which transparently forwards them to the Router. If the destination is on the same node, the traffic is sent back immediately and the ILB forwards it to the destination. If the destination pod is on another node, the router redirects the packets to the VxLAN interface, where they are encapsulated by the kernel and forwarded to the destination node. On the remote node, the DISC-NAT passes the traffic to the kernel, which decapsulates it and sends it to the router and then to destination pod. Pod-to-Internet. The traffic traverses the ILB, then the router forwards it towards the physical interface of the node, hence transparently crossing also the ELB. The NAT, instead, applies a source NATting rule, hence replacing the address of the pod with the one of the node, as well as the source port with a new available one. This allows the return traffic to reach the correct node without the necessity to advertise the PodCIDR on the external network. On the return path, the NAT checks if the packet belongs to a translated session; if so, it replaces the destination address and port of incoming packets with the ones of the original pod. Pod-to-service. The pod traffic toward a ClusterIP service is first processed by the ILB, which selects a proper backend pod and updates the destination address and port of packets. Traffic is then handled by the router in the same way as with the pod-to-pod communication. For return traffic, the ILB checks if the packet belongs to a translated session; if so, it restores the original source service address and port. Internet-to-service. When a remote host wants to contact a NodePort service, the packet is first processed by the DISC-NAT, that identifies it as targeting a NodePort service (based on the destination port). If the ExternalTrafficPolicy of the service is cluster, the DISC-NAT updates the source address of the packet with the one of the fictitious pod, to guarantee that the return packet will come to the same node. The packet is then forwarded to the ELB, which (i) selects a proper backend pod, (ii) updates the destination address and port with the ones of the backend, and (iii) forwards the packet to the router, that can handle it such as in normal pod-to-pod communications. IV. Evaluation This section presents an assessment of the performance provided by our network provider under different circumstances, to determine whether the disaggregated approach would introduce any noticeable performance penalty. We run the tests using the iperf3 tool, configured with the default parameters; the server was always running in a pod, while the client was either in a physical machine or in another pod depending on the test. Tests were carried out on a cluster of 2 nodes, each one featuring a CPU Intel® Xeon® CPU E3-1245v5@3.50GHz (4 cores plus HyperThreading), 64GB RAM, and a dualport 40 GbE Ethernet XL710 QSFP+ card, all running Linux kernel v5.4.0 and K8s v1.23.5. Tests involve other two eBPF-based solutions (namely, Cilium and Calico) and a widely used ‘traditional’ approach such as Flannel [4]. All providers were deployed using the VxLAN overlay model; Cilium and Calico were configured with their eBPF kubeproxy replacement, hence enabling a complete eBPF data plane such as in our solution. We considered the following communication scenarios: pod-to-pod: a pod client connects to the actual IP address of a pod server, showing the performance of the base networking without load balancing; pod-to-service: a pod client connects to a pod server using its ClusterIP service, to evaluate the performance of the load balancer as well as the L3 routing; internet-to-service: the client is executed in an external host and the pod server is accessed through its NodePort service. Tests were performed with pods running both on a single node and on multiple nodes, with the latter adding the overhead of the VxLAN encapsulation and the limitation of the physical network (link speed, PCI bus) and requiring to cross the physical network twice ((i) client to receiving node; (ii) receiving Fig. 3: Modules involved in single (a) and multi-node (b) communications. node to backend node) for the internet-to-service tests. Results are depicted in Fig. 4, with the red dashed lines representing the baseline achieved running bare metal iperf3 on localhost (in case of single node) or between two nodes. As expected, the throughput decreases when the traffic traverses a larger number of network components. However, despite the disaggregated architecture, our solution provides always better performance compared to other solutions, with even higher margins when considering multiple nodes. While this result may be impacted by other providers supporting more features than our PoC code, such as network policies, these have not been used in the tests, hence providing the ground for a fair comparison. Overall, this suggests how disaggregation does not introduce performance penalties compared to a traditional monolithic approach. Figure 5 shows the reaction time of our operator and CNI plugin when requiring to scale up/down the pods of a service, compared with time required by other Kubernetes components until connectivity to the target pod is available/disabled. Results show that the time taken by our components is negligible compared to the overall time required by K8s to react. V. RELATED WORK Among the many eBPF-based network services, we cite here only the ones that are most representative in this space. Katran [5] represents a software solution to offer scalable network load balancing to layer 4 that leverages eBPF/XDP to provide fast packet processing. While being very sophisticated, it has been engineered to be the sole (monolithic) network function active on the network path, hence preventing the deployment of other functions operating on the same traffic. Cilium [6] provides networking, security and observability for cloud-native environments such as Kubernetes clusters. Cilium is based on eBPF, which allows for the dynamic insertion of powerful network security, visibility and control logic into the Linux kernel. In Cilium, eBPF is used to provide high-performance networking, multi-cluster and multi-cloud capabilities, advanced load balancing, transparent encryption, extended network security features, and much more. While providing observability primitives through its Hubble module, its internals are rather complex and made with a monolithic approach. Cilium defines a set of six logical objects (PreFilter, Endpoint Policy, Service, etc.), based on six different features offered by the provider (DoS mitigation, network policies, load balancing, etc.). However, these objects are not mapped into clearly separated modules, neither for the data plane (their logic is scattered among different intertwined eBPF programs), nor from a topological point of view (cannot track the path of a packet or capture the traffic flowing from one object to another), nor from a control plane perspective (cannot configure and inspect these objects independently). Similar characteristics can be found in Calico [7], which recently adopted the eBPF/XDP technology as well. VI. CONCLUSIONS We presented a network provider for Kubernetes based on disaggregated eBPF services, which improves monitoring and debugging as well as how code can be maintained, extended and reused. Our open-source solution\(^2\) demonstrates the feasibility of the disaggregated approach in eBPF and our preliminary evaluation shows no particular overhead introduced by our model with respect to another state-of-the-art monolithic solution. As a future work we plan to introduce support for (i) direct routing and (ii) network policies. ACKNOWLEDGMENT Authors thank Hamza Rhouaoui for his initial work on this topic, all the people who contributed to the Polycube project, and Roberto Procopio and Yunsong Lu for their support. Finally, Federico Parola acknowledges the support from TIM S.p.A. through the PhD scholarship. REFERENCES
{"Source-Url": "https://iris.polito.it/retrieve/handle/11583/2970898/d6a82da4-289b-4f33-b32e-f14f0087f2b8/author_Creating%20Disaggregated%20Network%20Services%20with%20eBPF:%20the%20Kubernetes%20Network%20Provider%20Use%20Case.pdf", "len_cl100k_base": 5510, "olmocr-version": "0.1.53", "pdf-total-pages": 6, "total-fallback-pages": 0, "total-input-tokens": 18961, "total-output-tokens": 6322, "length": "2e12", "weborganizer": {"__label__adult": 0.0003807544708251953, "__label__art_design": 0.00038552284240722656, "__label__crime_law": 0.0003604888916015625, "__label__education_jobs": 0.0004723072052001953, "__label__entertainment": 0.00015163421630859375, "__label__fashion_beauty": 0.0001709461212158203, "__label__finance_business": 0.00044345855712890625, "__label__food_dining": 0.0003736019134521485, "__label__games": 0.0005855560302734375, "__label__hardware": 0.00562286376953125, "__label__health": 0.0005888938903808594, "__label__history": 0.0004045963287353515, "__label__home_hobbies": 0.00011897087097167967, "__label__industrial": 0.0009021759033203124, "__label__literature": 0.0002366304397583008, "__label__politics": 0.0002911090850830078, "__label__religion": 0.0005273818969726562, "__label__science_tech": 0.2919921875, "__label__social_life": 0.00011748075485229492, "__label__software": 0.0384521484375, "__label__software_dev": 0.65576171875, "__label__sports_fitness": 0.00036072731018066406, "__label__transportation": 0.0010652542114257812, "__label__travel": 0.0002970695495605469}, "weborganizer_max": "__label__software_dev", "avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_ratio": [[0, 28110, 0.02263]], "fineweb_edu_fasttext_gt2__fineweb_edu_fasttext_gt2__score": [[0, 28110, 0.33059]], "ft_lang_id_en_doc_v2__ft_lang_id_en_doc_v2__en": [[0, 28110, 0.9137]], "google_gemma-3-12b-it_contains_pii": [[0, 1300, false], [1300, 6716, null], [6716, 13045, null], [13045, 17827, null], [17827, 23261, null], [23261, 28110, null]], "google_gemma-3-12b-it_is_public_document": [[0, 1300, true], [1300, 6716, null], [6716, 13045, null], [13045, 17827, null], [17827, 23261, null], [23261, 28110, null]], "google_gemma-3-4b-it_v2tag__is_academic_paper": [[0, 5000, true], [5000, 28110, null]], "google_gemma-3-4b-it_v2tag__is_class_syllabus": [[0, 5000, false], [5000, 28110, null]], "google_gemma-3-4b-it_v2tag__is_completion_certificate": [[0, 5000, false], [5000, 28110, null]], "google_gemma-3-4b-it_v2tag__is_court_notice": [[0, 5000, false], [5000, 28110, null]], "google_gemma-3-4b-it_v2tag__is_homework_assignment": [[0, 5000, false], [5000, 28110, null]], "google_gemma-3-4b-it_v2tag__is_news_article": [[0, 5000, false], [5000, 28110, null]], "google_gemma-3-4b-it_v2tag__is_public_order": [[0, 5000, false], [5000, 28110, null]], "google_gemma-3-4b-it_v2tag__is_resume_cv": [[0, 5000, false], [5000, 28110, null]], "google_gemma-3-4b-it_v2tag__is_test_or_quiz": [[0, 5000, false], [5000, 28110, null]], "google_gemma-3-4b-it_v2tag__is_textbook": [[0, 5000, false], [5000, 28110, null]], "pdf_page_numbers": [[0, 1300, 1], [1300, 6716, 2], [6716, 13045, 3], [13045, 17827, 4], [17827, 23261, 5], [23261, 28110, 6]], "pipe_delimited_lines_v1__pipe_delimited_lines_v1__pipe_delimited_lines_ratio": [[0, 28110, 0.0]]}
olmocr_science_pdfs
2024-12-06
2024-12-06
23a95285dea3ae2b76e30ec8d50cde96872ae30a
Creating mappings for the SV (Subject Visits) domain Although Fred Wood, one of the authors of the SDTM Implementation Guides has once stated „Creating Trial Design tables can be as much of an art as it is a science“, it is pretty easy when using SDTM-ETL. Essentially, a „visit“ is a „StudyEvent“ in ODM. So if we map „StudyEvent“ to „VISITNUM“ (which is the key in the corresponding TV domain), we are essentially done. If there are repeating visits (as in many oncological studies), one however need to do a bit more. For our „CES“ study, the study design tree is: containing 5 planned visits. However, is the visit „Adverse Event“ really a planned visit? In the message pane at the bottom of the screen we see that the form „Adverse Event Form (ACRO)“ is „repeating“ so this lets us doubt a bit. It could be that this „StudyEvent“ is just an „artificial“ one that is „triggered“ when an adverse event is observed, and is meant to collect all adverse events independent on when they occurred. So we need to look into the protocol … Our suspicion is further strengthened by the design of the StudyEvent: We will further develop the mapping for SV assuming that the StudyEvent "Adverse Events" is not a planned visit, and later (when generating the AE domain mapping) explain how VISITNUM must then be handled there (as an "unplanned visit"). First drag and drop the "SV" row from the template to the bottom of the existing table. The following dialog is displayed: <table> <thead> <tr> <th>Domain</th> <th>Variable</th> <th>Variable</th> <th>Variable</th> </tr> </thead> <tbody> <tr> <td>DM</td> <td>STUDYID</td> <td>DOMAIN</td> <td>USUBJID</td> </tr> <tr> <td>SV</td> <td>STUDYID</td> <td>DOMAIN</td> <td>USUBJID</td> </tr> <tr> <td>CES:DM</td> <td>STUDYID</td> <td>DOMAIN</td> <td>USUBJID</td> </tr> <tr> <td>CES:SV</td> <td>STUDYID</td> <td>DOMAIN</td> <td>USUBJID</td> </tr> </tbody> </table> Copy Domain SV - Copy STUDYID from loaded ODM - Copy DOMAIN from originator - Automatically add USUBJID - Automatically add SEQ [OK] [Cancel] and accept the choices already checked by the wizard, as we want to have the mappings for STUDYID, DOMAIN and USUBJID be generated automatically. Clicking „OK“ results in a new row in our table: <table> <thead> <tr> <th>Domain</th> <th>Variable</th> <th>Variable</th> <th>Variable</th> <th>Variable</th> <th>Variable</th> <th>Variable</th> </tr> </thead> <tbody> <tr> <td>DM</td> <td>STUDYID</td> <td>DOMAIN</td> <td>USUBJID</td> <td>SUBJ</td> <td>DM_RFSTDTC</td> <td>DM_RFENDTC</td> </tr> <tr> <td>SV</td> <td>STUDYID</td> <td>DOMAIN</td> <td>USUBJID</td> <td>SV_VISITNUM</td> <td>SV_VISIT</td> <td>SV_VISITDY</td> </tr> <tr> <td>CES:DM</td> <td>STUDYID</td> <td>DOMAIN</td> <td>USUBJID</td> <td>SV_VISITNUM</td> <td>SV_VISIT</td> <td>SV_VISITDY</td> </tr> <tr> <td>CES:SV</td> <td>STUDYID</td> <td>DOMAIN</td> <td>USUBJID</td> <td>SV_VISITNUM</td> <td>SV_VISIT</td> <td>SV_VISITDY</td> </tr> </tbody> </table> In domains where there is more than one record, we must **first** define the looping structure. This means that we need to define over which of the SDTM variables and iteration will be done in order to generate the data sets. It often corresponds to the statement in the SDTM-IG like „on record per study per visit“. Most of the domains in the template have already a proposed looping structure, but one should always inspect it and adapt it if necessary to its own study structure. Viewing and editing the properties (like the looping structure) of the domain can be either done by a double-click of the first cell of that domain (in this case the cell with „CES:SV“) or by selecting any cell in the row and then using the menu „Edit – SDTM Domain Properties“. This results in the following dialog: ![Edit properties for SDTM Domain: CES:SV](image) and at the bottom, after having clicked the „validate“ button: ![Validate](image) stating „one record per VISITNUM per USUBJID“. --- 1 We have hidden all other rows from the template using the menu „View – View/Hide Domains“ As this is exactly the structure that is needed, it is not necessary to change the looping structure. We do however still need to set the domain keys. In the past (pre-SDTM-1.4), the SDTM-IG often made a proposal for the domain keys, which was copied by implementors without any considerations that the proposal might not be what is needed. Therefore, CDISC does not publish any recommendations for the „domain keys“ any more, and one must add them one self. Click the button „Set domain keys and sequence“. The following dialog is displayed: ![Add key variables and define their sequence dialog](image) One can now add variables that are the „natural keys“ of the domain (see SDTM-IG 3.2, section 4.1.1.9 „Assigning Natural Keys in the Metadata“). In our case, most logical is: ![Add key variables and define their sequence dialog with variables](image) This choice will generate „KeySequence“ attributes in the underlying define.xml structure for „STUDYID“, „USUBJID“ and „VISITNUM“ ItemRef elements in the ItemGroupDef „SV“. Click „OK“ until returning into the main window. In the study design tree, collapse or expand all tree nodes until one sees the StudyEvent nodes: Now drag-and-drop one of the StudyEvent nodes (it doesn't matter which one) to the cell „SV.VISITNUM“. The following wizard is displayed: This selects a single StudyEvent, but we want the mapping to be applicable to all StudyEvents, except for the „Adverse Events“ StudyEvent, as the latter is not a real planned visit in the sense of SDTM. So we check the checkbox „Generalize for all StudyEvents“: which makes the buttons „Except for …“ and „Only for ...“ available. As we need to exclude the „Adverse StudyEvent“ StudyEvent, we need to click „Except for ...“ and check „AE- Adverse Event“: Clicking „OK“ several times generates the mapping script: ``` # Mapping using ODM element StudyEventData using value from attribute StudyEventOID # Generalized for all StudyEvents # Except for: AE #SV.VISITNUM = xpath(//StudyEventData[not(@StudyEventOID='AE')]/@StudyEventOID); ``` stating that we will consider all „StudyEventData“ in the ODM „ClinicalData“ file except for the one with the StudyEventOID „AE“. Testing this out on our test set with clinical data for two subjects leads to: ``` <table> <thead> <tr> <th>CES:DM</th> <th>CES:SV</th> </tr> </thead> <tbody> <tr> <td>STUDYID</td> <td>DOMAIN</td> </tr> <tr> <td>CES</td> <td>SV</td> </tr> <tr> <td>CES</td> <td>SV</td> </tr> <tr> <td>CES</td> <td>SV</td> </tr> <tr> <td>CES</td> <td>SV</td> </tr> <tr> <td>CES</td> <td>SV</td> </tr> <tr> <td>CES</td> <td>SV</td> </tr> <tr> <td>CES</td> <td>SV</td> </tr> <tr> <td>CES</td> <td>SV</td> </tr> </tbody> </table> ``` which is not what is wanted\(^2\) as we need a number for VISITNUM. So we still need to assign numbers to each of our visits. This can be done by a little amount of editing of the mapping script, e.g. like: \(^2\) This would however already be a perfect mapping for the variable „VISIT“ (visit name) Also note that the comment lines (starting with a `#`) have been generated automatically – you can of course edit them. And testing on the clinical data leads to: Remark: the assignment of the „visit number“ is completely arbitrary, but the order needs to correspond to the „natural order“ given in the protocol, i.e. that the „baseline visit“ normally comes before the „Week 1“ visit etc.. However, the numbers must not be subsequent by default: so if one would assign them as being „100“, „200“, „300“ and „400“, this would be perfectly OK (also see the remark about repeating visits later in this chapter). They however MUST correspond to VISITNUM in the records of the „trial visits“ (TV) domain. For the variable „VISIT“ visit name, we can just copy-paste the first line of the script for VISITNUM and add an extra line for the assignment to „VISIT“: which leads to following results: We can now also populate SVSTDTC, SVENDTC, SVSTDY and SVENDY. Note that these variables are permissible and should only be populated in case they were collected. So one should not try to derive them from other information. In our case, the visit date was however collected as „Visit Date“ (OID „I_VISIT“) in the ODM, and this is done in the same way in each visit: So drag-and-drop the item „Visit Date“ to the cell „SV.SVSTDTC“. The dialog shows up again asking what we want to do exactly: The information about „generalizing for all StudyEvents“ and the exception for the „Adverse Event“ is still there. If it isn't, one should add it again. This leads to the mapping: ``` # Mapping using ODM element ItemData with ItemOID I_VISIT # Generalized for all StudyEvents # Except for: AE $SV_SVSTDTC = xpath('StudyEventData[not(@StudyEventOID=\"AE\")]/FormData[@FormOID=\"F_BASELINE\"]/ItemGroupData...) ``` Wait a minute: there is no form „F_BASELINE“ in the StudyEvent „WEEK_1“! So we need to find something better. If we use the menu „Navigate – Next Instance“ we see that „Visit Date“ occurs in every visit, but in different forms, but always in the ItemGroup „Common“. However, it can also occur several times in different forms in the same visit, so we must always take the first occurrence. We do start again from the drag-and-drop and get: Check the checkbox „Overwrite existing mapping“. This leads again to: and now also check the checkbox „Generalize for all forms“, stating that the „Visit date“ can occur in any form³. This leads to: ³ If there is no „Visit Date“ in every form, we should here again exclude the forms that haven't got the „Visit date“, or using the button „Only for“ include the ones that have. If we would now execute all the mappings for the domain, we would get an error ("A sequence of more than one item is not allowed as the first argument of string()"). Reason for this is that the visit date, as we have defined it here, occurs several times in the same visit (i.e. on different forms). We do however only want the first occurrence. So we rewrite the mapping script as: In our scripting language, a pair of square brackets means a condition. The condition [1] means „take the first one“, [2] means „take the second one“ and [last()] means „take the last occurring one“. This leads to the following results: The same can now be done for SVENDTC, as start date and end date of the visit are always identical, or we can just use: ``` SVSTEDTC = 4SV.SVSTDTC; ``` as SVSTEDTC has been defined before (i.e. more to the left in the table). The variable SVSTEDY and SVENDY can be mapped using SVSTEDTC and SVENDTC, and using „datediff“ in the same way as was done in the mappings for „AGE“ and „DMDY“ in the demographics domain. For this, we need the value for „RFSTEDTC“ (reference start date again). We can either copy it from the mapping for RFSTEDTC in the domain, or drag-and-drop it from the „baseline visit – Visit date“ again (attention: one should not have any „Generalize for ...“ checkboxes checked in this case). Creating global variables There is however a smarter way... We will need RFSTEDTC and RFENDTC over and over again in many domains for deriving either xxDY values, or „BEFORE“, „AFTER“ values for xxSTRF („Start relative to reference period“) and xxENRF („End relative to reference period“) variables. So why not make RFSTEDTC and RFENDTC „global“? In SDTM, one can set global variables for reuse in any domain using „Insert – Global Subject Variables Domain“. This leads to: This is a very special domain (it will be removed from the „clean“ define.xml when generating a „submission-ready“ define.xml) to store global variables that we can then use in „read-only“ mode in any of the mappings of our domains. This „Global“ domain typically contains things like mappings for RFSTDTC (reference start date) and RFENDTC (reference end date). After selecting any cell in the „CES:GLOBAL“ domain, one can add variables by using the menu „Insert – New SDTM Variable“, leading to the wizard: ![Image of the wizard](image) It explains that the identifier (OID) should be unique, i.e. it should be different from any OID already in the SDTM. So we can use „RFSTDTC“, but not „DM.RFSTDTC“. For a global variable „Reference Start Date“, we choose „RFSTDTC“. So: ![Image of the wizard with RFSTDTC](image) and click OK to finalize the process. This leads to: ![Image of the message box](image) and: ![Image of the table](image) The global variable can now be mapped in the same way as any SDTM variable, e.g. using drag-and-drop from the first visit date of our study design tree: leading to: and the mapping: We now return to our mappings for the SV domain. For SV.SVSTDY we can now simply use: ```sql $SV.SVSTDY = datediff($SV.SVSTDTIC, $RFSTDTIC) + 1; ``` as $SV.SVSTDTIC has been defined in the same domain before, and $RFSTDTIC is a global variable. The „+1“ is necessary as the SDTM does not allow a „day 0“: the first day in a study is „day 1“ and the day before it „day -1“. This results into: The same can now be done for the variable SVENDY. Notice that the variable SV.VISITDY contains the „planned“ day of the visit, not the actual one. So we will either need to copy it from the study design domain TV (trial visits), or hardcode it (using an if-elsif-else structure) from the information in the protocol. Some important remarks You may have noticed that when testing the mappings, we have used the menu „Transform – --- 4 Conflicting with everything I learned in mathematics in primary school ;-) 5 Essentially, VISITDY should NOT appear in „Subject Visits“, as it is not „collected“. If a reviewer would like to know what the planned visit day was, his review tool should enable him to jump to the TV domain. Generate Transformation (XSLT) Code ...“ and have not performed any „local“ testing using the button „Test – Transform to XSLT“ in the mapping editor. The reason is simple: when using the latter, the system is not knowing about any looping variables (in our case VISITNUM), nor is it knowing about any variables that were defined before, nor about global variables. In our example study, we would now also like to map the „unplanned visits“. The amount of collected clinical data we have so far (only one adverse event) does not provide us the necessary information yet on whether the AE was collected during a normal visit, or whether an additional (unplanned) visit was executed. Using „View – Clinical Data“ for the „Visit Date“ of the „Adverse Event“ StudyEvent gives us: ![View Clinical Data](image) and „2010-03-13“ is also the visit date of the „DIARY“ visit. If AEs were always collected during planned visits, we will not need any additional records in the SV domain. **Executing mappings for a single, selected domain** Currently we have developed mappings for as well the DM as for the SV domain. When testing, we each time see the results for both these domains. This is OK here, as both contain a small set of records, and generating the XSLT and executing it does not take much time. For other domains however that have more records, we often would like to execute the mappings on the „current“ domain only, even if mappings for other domains are also loaded. As of version 3.0, only executing the mappings for a single domain is possible. For doing so, first use the menu „Options - Settings“. This gives: Now check the checkbox „Generate/Execute XSLT for user-selected domains only“: ![Checkbox](image1.png) and click „OK“. The next time one uses the menu „Transform – Generate Transformation (XSLT) Code“ an additional dialog will be displayed: ![Select domains/datasets for transformation](image2.png) allowing to select the domains for which the XSLT will be generated and the mappings executed. In the case we select „CES:SV“ this will lead to: ![Image of CES:SV table] **Important remarks:** This study did not have any unplanned visits for any of the subjects. If your study has such, you also need to have these in your SV dataset. The following rules then apply: - VISITNUM must be populated in such a way that it can be sorted in the correct chronological order. For example, if you have visits with VISITNUM being „3“, „4“ and „5“ and the unplanned visit was after visit 4, you may assign a VISITNUM „4.1“ for the unplanned visit. If you had planned visits „30“, „40“ and „50“, and the unplanned visit came after visit „40“, you may assign the number „41“ for the unplanned visit. We do however recommend using the former method (with the decimal point) as the tools used by the FDA do not support the second method, though it is fully legal. - VISIT can be left blank or can be filled with e.g. „UNSCHEDULED“. If you plan to submit to the FDA, also test what you filled in here using the latest version of OpenCDISC, as the agency is using this tool. Unfortunately, earlier (but also newer) versions of OpenCDISC made some invalid assumptions on how this should be dealt with. If you get an error using OpenCDISC, you might either want to adapt to what comes out of OpenCDISC (even if you are sure that you did it the right way), or make a notice about the (false positive) error in the reviewers guide. - VISITDY must be left empty, as this is the planned study day. - SVSTDTC, SVENDTC, SVSTDY and SVENDY must be populated as usual. - SVUPDES must be populated with the reason for the unplanned visit. This is well explained in the different SDTM Implementation Guides e.g. in section 4.1.4.5 („Clinical Encounters and Visits“) of the SDTM-IG 3.2 (for SDTM 1.4). --- 6 See e.g. [http://www.opencdisc.org/forum/sd1023-check-isnt-designed-properly](http://www.opencdisc.org/forum/sd1023-check-isnt-designed-properly)
{"Source-Url": "http://www.xml4pharma.com/SDTM-ETL/tutorials/Generating_SV.pdf", "len_cl100k_base": 4668, "olmocr-version": "0.1.50", "pdf-total-pages": 18, "total-fallback-pages": 0, "total-input-tokens": 25435, "total-output-tokens": 5192, "length": "2e12", "weborganizer": {"__label__adult": 0.0006861686706542969, "__label__art_design": 0.0012712478637695312, "__label__crime_law": 0.001312255859375, "__label__education_jobs": 0.0157470703125, "__label__entertainment": 0.00026607513427734375, "__label__fashion_beauty": 0.0004620552062988281, "__label__finance_business": 0.0017642974853515625, "__label__food_dining": 0.0005884170532226562, "__label__games": 0.0020198822021484375, "__label__hardware": 0.0016527175903320312, "__label__health": 0.01776123046875, "__label__history": 0.000888824462890625, "__label__home_hobbies": 0.0005335807800292969, "__label__industrial": 0.0012454986572265625, "__label__literature": 0.0007596015930175781, "__label__politics": 0.0005965232849121094, "__label__religion": 0.0009284019470214844, "__label__science_tech": 0.284912109375, "__label__social_life": 0.00042939186096191406, "__label__software": 0.3046875, "__label__software_dev": 0.35888671875, "__label__sports_fitness": 0.0013685226440429688, "__label__transportation": 0.0006623268127441406, "__label__travel": 0.0005817413330078125}, "weborganizer_max": "__label__software_dev", "avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_ratio": [[0, 17356, 0.00696]], "fineweb_edu_fasttext_gt2__fineweb_edu_fasttext_gt2__score": [[0, 17356, 0.29408]], "ft_lang_id_en_doc_v2__ft_lang_id_en_doc_v2__en": [[0, 17356, 0.85806]], "google_gemma-3-12b-it_contains_pii": [[0, 1110, false], [1110, 1894, null], [1894, 3650, null], [3650, 4831, null], [4831, 5399, null], [5399, 6699, null], [6699, 7558, null], [7558, 8085, null], [8085, 8941, null], [8941, 9321, null], [9321, 9942, null], [9942, 11367, null], [11367, 12082, null], [12082, 12266, null], [12266, 13392, null], [13392, 15020, null], [15020, 15322, null], [15322, 17356, null]], "google_gemma-3-12b-it_is_public_document": [[0, 1110, true], [1110, 1894, null], [1894, 3650, null], [3650, 4831, null], [4831, 5399, null], [5399, 6699, null], [6699, 7558, null], [7558, 8085, null], [8085, 8941, null], [8941, 9321, null], [9321, 9942, null], [9942, 11367, null], [11367, 12082, null], [12082, 12266, null], [12266, 13392, null], [13392, 15020, null], [15020, 15322, null], [15322, 17356, null]], "google_gemma-3-4b-it_v2tag__is_academic_paper": [[0, 5000, false], [5000, 17356, null]], "google_gemma-3-4b-it_v2tag__is_class_syllabus": [[0, 5000, false], [5000, 17356, null]], "google_gemma-3-4b-it_v2tag__is_completion_certificate": [[0, 5000, false], [5000, 17356, null]], "google_gemma-3-4b-it_v2tag__is_court_notice": [[0, 5000, false], [5000, 17356, null]], "google_gemma-3-4b-it_v2tag__is_homework_assignment": [[0, 5000, false], [5000, 17356, null]], "google_gemma-3-4b-it_v2tag__is_news_article": [[0, 5000, false], [5000, 17356, null]], "google_gemma-3-4b-it_v2tag__is_public_order": [[0, 5000, false], [5000, 17356, null]], "google_gemma-3-4b-it_v2tag__is_resume_cv": [[0, 5000, false], [5000, 17356, null]], "google_gemma-3-4b-it_v2tag__is_test_or_quiz": [[0, 5000, false], [5000, 17356, null]], "google_gemma-3-4b-it_v2tag__is_textbook": [[0, 5000, false], [5000, 17356, null]], "pdf_page_numbers": [[0, 1110, 1], [1110, 1894, 2], [1894, 3650, 3], [3650, 4831, 4], [4831, 5399, 5], [5399, 6699, 6], [6699, 7558, 7], [7558, 8085, 8], [8085, 8941, 9], [8941, 9321, 10], [9321, 9942, 11], [9942, 11367, 12], [11367, 12082, 13], [12082, 12266, 14], [12266, 13392, 15], [13392, 15020, 16], [15020, 15322, 17], [15322, 17356, 18]], "pipe_delimited_lines_v1__pipe_delimited_lines_v1__pipe_delimited_lines_ratio": [[0, 17356, 0.1465]]}
olmocr_science_pdfs
2024-12-02
2024-12-02
6692a85b00e346c0991d14876412160e74b64a44
Finite Machines C. Merck October 27, 2009 Abstract An otherwise universal computer model running within a finite memory space is presented. The behavior of such a resource-limited machine is shown to be in principle distinct from that of the traditional Turing-machine with respect to the halting problem, Chaitin’s number, maximum output length, space complexity, and completeness. 1 Motivation The notion of a universal computer, famously developed by Alan Turing and independently by Emil Post in the 1930s [1], has formed the basis for the canonical theory of computation. However, the universal computer is not physically realizable, due to the requirement of infinite space. Accordingly, present day physical computers, both those built by humans and those inherent in nature, are not universal but rather finite and therefore would be more accurately described by a finite theory than by the canonical theory of computation. Here a simple finite machine model is developed and then some of its properties are studied. 2 The Machine Model We define a machine called $Q$ which is programmed in an imperative structured programming language - a variant of the $P'$ language developed by Böhm [2]. 2.1 The Programming Language The basic operation of the machine is this: it begins reading the given program at the beginning, with all memory initialized to zero. The machine runs, reading instructions, manipulating memory, and writing to the output as directed by the program until reaching the program’s end, resulting in a halt condition. A $Q$ program is a finite-length string of symbols from an alphabet of seven instructions. Each machine cycle the instruction indicated by the program pointer is read and action is taken depending on the instruction and the value of the memory cell indicated by the memory pointer. The effects of the seven instructions are: 1The terms space, tape, and memory are used interchangeably. The only restriction on input programs is that the loop instructions (l and u) be matched. The set of syntactically correct Q programs is entirely described by the following grammar: 1. **Base Axiom**: The following are Q programs: f, r, i, δ, w, and the empty string. 2. **Concatenation Rule**: Given any two Q programs ⃗p and ⃗q, ⃗p & ⃗q is a Q program. 3. **Loop Rule**: Given any Q program ⃗p, l & ⃗p & u is a Q program. This grammar suggests a method of constructing syntactically correct programs, a challenge taken up in Section 2.4. ### 2.2 The Memory The memory available to the machine is fixed during its operation, but may be chosen to be in various configurations. A particular machine, denoted by Q"n,m", has a fixed number, n, of memory cells (also known as *order*) each of which may be in any of m states (also known as *base*). More compactly, we say the memory is a vector in Z^n_m. Consequently, when n and m are finite (which is hereafter assumed unless written otherwise), increment and decrement operations on the memory pointer and on any memory cell are taken (mod n) and (mod m) respectively. For example, attempting to increment a memory cell already at the maximum value of m − 1 results in the cell's value becoming zero. ### 2.3 Q as a Recursive Function Formally, Q is a function which maps program strings to output strings. When Q(⃗p) converges given a particular program string ⃗p, denoted Q(⃗p) ↓, the program is said to halt with output Q(⃗p). Otherwise the program does not halt, that is, it diverges, denoted Q(⃗p) ↑. We can write down the exact behavior of Q in a single recurrence relation, but first the initial conditions for that recurrence must be established. We let \[ Q^n_m(\vec{p}) = Q^n_m[0, \vec{r}_0, 0, \vec{s}_0](\vec{p}), \] where \(\vec{r}_0 = \vec{0} \in Z^n_m\) and \(\vec{s}_0\) is the empty vector². Now we can define the recurrence relation describing the machine's operation: \[ Q^n_m[i, r, j, s](p) = \begin{cases} s', & \text{if } i = |p| \\ Q^n_m[i + 1, r, j + 1 \pmod{n}, s'(p)], & \text{if } p^i = f \\ Q^n_m[i + 1, r, j - 1 \pmod{n}, s'(p)], & \text{if } p^i = r \\ \bigcup_{i=0}^{n-1} \begin{cases} r_i + 1 \pmod{m}, & \text{if } i = j \\ r_i - 1 \pmod{m}, & \text{otherwise} \\ \end{cases} \bigcup_{i=0}^{n-1} \begin{cases} j, s'(p), & \text{if } p^i = i \\ j, s'(p), & \text{if } p^i = \delta \\ \end{cases}, & \text{if } p^i = \text{ other} \\ Q^n_m[i + 1, r, j, s, s'(p)], & \text{if } p^i = \omega \\ Q^n_m[i + 1, r, j, s'(p)], & \text{if } p^i = I \\ Q^n_m[i + 1, r, j, s'(p)], & \text{if } p^i = \text{ other} \\ \bigcup_{d=0}^{d=0} \begin{cases} i + 1, & \text{if } d = 0 \\ \delta_{p}(i - 1, d - 1), & \text{if } p^i = I \\ \delta_{p}(i - 1, d + 1), & \text{if } p^i = U \\ \delta_{p}(i - 1, d), & \text{otherwise} \\ \end{cases}, & \text{if } p^i = U \land r^j \neq 0 \\ \end{cases} \] where \( \delta_{p}(i, d) \) is defined as Note that if the input programs are ungrammatical, \( Q(p) \) may diverge because of the failure of a single evaluation of \( \delta_{p} \) to converge. For example, if a program \( p \) contains unmatched \( u \) instructions, then \( \delta_{p}(i, 1) \uparrow \) for some \( i \). This strongly suggests that \( Q(p) \uparrow \). However, in an effort to make \( Q \) independent of the behavior of \( \delta \) for programs with bad-syntax, we will from now on only discuss programs \( p \) which are in the set of \( Q \)-programs defined by the grammar in 2.1. The unfortunate side-effect of so restricting the domain of \( Q \) is a complication of the task of enumerating programs, discussed presently. ### 2.4 Enumerating Grammatical Programs In order to tackle the problem of program-size complexity we must obtain a Gödel numbering for \( Q \)-programs. That is, we must find a one-to-one function \# : \( Q \)-programs \( \rightarrow \mathbb{N} \). Further, it is desired that this function always assigns larger numbers to longer programs. Two such definitions of \# are proposed here. The obvious Gödel numbering method is to define a syntax checking function and use it to filter all possible program strings. Let the syntax checker function be defined as \[ S(p) = \begin{cases} 1 & \text{if } p \in \text{Q-programs} \\ 0 & \text{otherwise} \\ \end{cases} \] We cannot say with certainty that \[ \forall \bar{p}, (\exists i \in \{0..|p| - 1\} \text{ with } p^i = u \text{ such that } \delta_{p}(i - 1, 1) \uparrow \Rightarrow (Q(p) \uparrow) \] because of trivial counter-examples such as \( p = u \) or \( \text{fill } \text{null} \) where the last clause of the piecewise recurrence relation for \( Q \) is never evaluated. Then let the Gödel numbering of all possible program strings grammatical and ungrammatical alike, the naïve numbering, be defined as $$#_{all}(\vec{p}) = \sum_{i=0}^{\lfloor |\vec{p}| - 1 \rfloor} 7^i p^i.$$ Now using the inverse of the above naïve Gödel numbering to give an ordered enumeration which is then filtered by the syntax checking function, we can define an acceptable numbering for grammatical programs: $$\#(\vec{p}) = \begin{cases} \sum_{i=0}^{#_{all}(\vec{p})} S(#_{all}^{-1}(i)) & \text{if } S(\vec{p}) \text{ undefined otherwise} \end{cases}.$$ A Gödel numbering could also be devised based on the grammar previously given. A set of known-grammatical programs can be iteratively augmented, and in that way enumerating all finite-length grammatical programs. 3 Halting The busy beaver function $\Sigma_U(|\vec{p}|)$ denotes the largest output which a program of length $|\vec{p}|$ or less can produce on a computer $U$. On Turing-complete machines $\Sigma$ grows faster than any recursive function [3]. On finite machines however there exists a recursive upper-bound on the busy beaver function. We derive this bound via the following argument. A finite machine with a finite program and finite memory (a finite machine-tuple) has a finite number of unique states which it can occupy. Furthermore, a machine is deterministic in that its next state can always be determined from its previous state. Lastly suppose there exists a special state, call it halted, marking the end of execution. We can now reason that if a machine were ever to reach the halted state, it must have passed through every other state either exactly once or not at all - for if a state were to be revisited, the program would loop indefinitely and never halt. So at the very most, the machine may pass through every one of its states once before halting. Since at most one symbol may be written to the output during each state transition (instruction), the output may contain no more symbols than there are states in the machine. A machine $Q^n_m$ given program $\vec{p}$ has a memory pointer with $n$ possible states, a program pointer with $|\vec{p}|$ possible states, and $n$ memory cells which may each be in any one of $m$ states. In total there are $nm^n |\vec{p}|$ states. Thus $$\Sigma_{Q^n_m}(|\vec{p}|) \leq nm^n |\vec{p}|.$$ Note that it is not remarkable that individual values of $\Sigma$ are finite, only that we can write down an upper-bound which is recursive in program-size. What is remarkable is that the upper-bound given above is not only recursive but linear in program-size. As a result of a computable upper-bound on program runtime, we can write an effective procedure $\text{HALT}(\vec{p})$ returning 1 if a program $\vec{p}$ halts and 0 otherwise, thus solving the halting problem for finite machines. Thus equipped, we may construct Chaitin’s number, the halting probability, as the convergent sum $$\Omega = \sum_{n=0}^{\infty} 2^{-n} \text{HALT}(#^{-1}(n)).$$ \footnote{Compare with Nietzsche’s eternal recurrence argument.} 4 Functions Thus far we have only discussed programs which take no input, being concerned with the complexity of the program’s output strings. However, the complexity of functions, mappings of inputs into outputs, is of greater interest. In this section, functions of the form \( f : \mathbb{Z}_m \rightarrow \mathbb{Z}_m \) and a manner of implementing them as programs on \( \mathbb{Q} \) is developed. 4.1 Implementing Functions on \( \mathbb{Q} \) It is desired to implement functions of the form \( f : \mathbb{Z}_m \rightarrow \mathbb{Z}_m \) (hereafter called functions of base \( m \)) as \( \mathbb{Q} \)-programs. This is accomplished by appropriately padding programs with increment and output instructions so that the function’s argument is placed in the first memory cell and the memory cell pointed to when the program halts is taken to be the function’s output. In terms of the definition given earlier for \( \mathbb{Q} \), we can define a higher-order function \( R \) such that \[ R^n_m[\vec{p}](a) = \begin{cases} Q^n_m(\vec{p} \& \vec{w})^0 & \text{if } a = 0 \\ R^n_m[i \& \vec{p}](a - 1) & \text{otherwise} \end{cases} \] To ensure clarity one elementary example is given. Consider the base-3 successor function, call it \( f \). Naturally we have \( f(0) = 1 \), \( f(1) = 2 \), and \( f(2) = 0 \). The function \( f \) can be implemented by the program which is a single increment instruction, requiring but one cell of memory. This is written \( R^1_3[i] = f \), and is derived as follows: \[ R^1_3[i](0) = Q^1_3(iw)^0 = (1)^0 = 1 = f(0), \\ R^1_3[i](1) = R^1_3[\vec{i}](0) = Q^1_3(iiw)^0 = (2)^0 = 2 = f(1), \\ R^1_3[i](2) = R^1_3[\vec{i}](1) = R^1_3[\vec{i}i](0) = Q^1_3(iiiw)^0 = (0)^0 = 0 = f(2), \] \[ \therefore R^1_3[i] = f. \] 4.2 Sets of Implementable Functions It is useful to consider the set of functions which are implementable as \( \mathbb{Q} \) programs in the above-mentioned manner. To denote the functions implementable on \( Q^n_m \), we write \( \Phi^n_m \). Or, in terms of the above-defined \( R \) notation, we let \[ \Phi^n_m = \{ \text{base-}m \text{ function } f \mid \exists \vec{p} : R^n_m[\vec{p}] = f \}. \] Furthermore we adopt the following short-hand for unions of these sets: \[ \Phi_m = \bigcup_{n=1}^{\infty} \Phi^n_m, \quad \Phi^n = \bigcup_{m=1}^{\infty} \Phi^n_m, \quad \Phi = \bigcup_{m=1}^{\infty} \bigcup_{n=1}^{\infty} \Phi^n_m. \] 4.3 Space Complexity The space complexity, or neatness, of a function is the number of memory cells required to compute that function. We can leverage the newly defined \( R \) notation in defining the neatness\(^5\) of a base-\( m \) function \( f \) as \[ N(f) = \min \{ n \mid R^n_m[\vec{p}] = f \}. \] \(^5\)We say a function \( f \) is neater than a function \( g \) if \( N(f) < N(g) \). function $f$ as $$N(f) = \min\{n \mid f \in \Phi^n_m\}$$ This notion of neatness is simple but is not obviously computable. Suppose you claim that you have computed $N(f)$ and found it to be equal to 3. Most likely you claim this because you have found a program $\vec{p}$ such that $\mathcal{R}^3_m[\vec{p}] = f$. But then I ask: on what grounds do you say that there exists no program $\vec{q}$ such that $\mathcal{R}^2_m[\vec{q}] = f$? If you are right, then you cannot answer my question in finite time by exhaustively searching through programs, since you will never find such a program $\vec{q}$. Therefore, without some theoretical knowledge of an upper-bound on program-size, one cannot compute $N$ for cases where $N(f) > 1$. In an attempt to eliminate this problem, we define a more qualified version of neatness, called $H$-neatness. Let $$N_H(f) = \min\{n \mid f \in \Phi^n_m \land |\vec{p}| = \min(|\vec{q}| \mid \exists n' : \mathcal{R}^{n'}_m[\vec{q}] = f)\}.$$ 4.4 Several Hypotheses involving $\mathcal{R}$ There is much to be learned about finite machines, especially with regard to space-complexity. Here follows several conjectures and associated proofs or counterexamples where they have been discovered. 4.4.1 Composition Lemma $$\forall n : \forall f, g \in \Phi^n_m : f \circ g \in \Phi^n_m.$$ In words, the set of functions implementable on $Q^n_m$ is closed under composition. Outline of proof: After running an arbitrary program on $Q$ the memory and memory pointer are in an arbitrary state. However, if the program is appended with a so-called housekeeping routine \(^6\), the memory cells can be all initialized to zero with the exception of the cell at the memory pointer. If another arbitrary program is then appended, it will behave exactly as if it were run alone (without the first program and housekeeping routine). Thus, by placing the housekeeping routine between the implementation of two functions, the second function runs with the first program’s return value as its argument, which is the definition of function composition. 4.4.2 Finite Completeness Theorem $$\forall f \text{ of base } m : f \in \Phi_m.$$ In words, any (finite) function from $Z_m$ to $Z_m$ can be implemented as a $Q$-program in $\mathcal{R}$ notation. Proof is by construction. Implementations of three elementary functions are proven. Then it is demonstrated that any function may be constructed through composition of the elementary functions. \(^6\)The housekeeping routine of order $n$ is defined as $$\vec{h} = (\&_{n-1}\text{fliu}) \& f.$$ 6 Assume an order, \( n \), of 3 and a base, \( m \), of 2 or greater\(^7\). Define the three elementary functions \[ R(x) = x + 1, \] \[ S(x) = \begin{cases} 0 & \text{if } x = 0 \\ 1 & \text{if } x = 1 \\ x & \text{otherwise} \end{cases} \] \[ G(x) = \begin{cases} 1 & \text{if } x = 0 \\ 1 & \text{if } x = 1 \\ x & \text{otherwise} \end{cases} \] called rotate, swap, and group respectively. Furthermore, these functions are implementable as follows: \[ R(x) = R^3_m[i], \] \[ S(x) = R^3_m[\text{swap}] \] \[ G(x) = R^3_m[\text{group}] \] \[\therefore R, S, G \in \Phi^3_m\] Now, an algorithm for the construction of any base-\( m \) function \( f \) is presented, during which the reader should keep foremost in mind the list of values \( f(0), f(1), \ldots, f(m-1) \). Let \( \text{FREE}(x) \) denote the \( x^{th} \) number in the set \( \mathbb{Z}_m - f(\mathbb{Z}_m) \). Let \( \text{DUP}(x) \) indicate whether \( f(x) \) has already appeared in the list of values, so that \( \sum_{i=0}^{x-1} \text{DUP}(i) \) is the number of duplicate values in the range of \( f \) for arguments less than \( x \).\(^8\) Let \( \alpha \) be \( f \) but with duplicate values replaced with the next free value \[ \alpha(x) = \begin{cases} \text{FREE}(\sum_{i=0}^{x-1} \text{DUP}(i)) & \text{if } \text{DUP}(x) = 1 \\ f(x) & \text{otherwise} \end{cases} \] This function \( \alpha \) is a permutation of the base-\( m \) identity function and so may be obtained through repeated composition of the rotate and swap functions. Likewise, \( f \) may be obtained by repeatedly composing \( \alpha \) with \( R \), \( S \), and \( G \). Since \( R \), \( S \), and \( G \) are in \( \Phi^3_m \) and \( f \) is a composition of \( R \), \( S \), and \( G \), by the Composition Lemma we have that \( f \) is in \( \Phi^3_m \), Q.E.D. 4.4.3 A Bound on Neatness \[ \exists \text{ a recursive upper-bound } B_N \text{ s.t. } \\ \forall f \text{ of base } m : N(f) < B_N(m). \] The bound on neatness is established using the Finite Completeness Theorem: Since all functions may be constructed from the elementary functions GS, ZS, and ZR, and the elementary functions have a neatness of at most 3, all functions have a neatness of at most 3. \(^7\)The assumption of \( n = 3 \) can be weakened to \( n \geq 3 \) if a better swap function can be found which behaves correctly when \( n > 3 \). \(^8\)A suitable, purely symbolic definition would be \[ \text{DUP}(x) = \begin{cases} 1 & \text{if } \exists y : y < x \land f(x) = f(y) \\ 0 & \text{otherwise} \end{cases} \] Note that this does not treat the first occurrence of a duplicated value as a duplicate. 4.4.4 Nonequivalence of Neatnesses \[ \neg \forall f : N(f) = N_H(f). \] **Proof by Example:** The shortest implementation of the function \( f(x) = 0 \) for any order is \( f \), valid when \( n \geq 2 \). So \( N_H(f) = 2 \). However, an implementation also exists when \( n = 1 \), specifically \( \text{liu} \). So \( N(f) = 1 \neq N_H(f) \), Q.E.D. 5 Other Machine Models The above analysis was made with respect to a particular finite machine model. Other models of finite machines exist which may be subjected to similar analysis. Some other finite machines of particular interest are: - A finite cellular automaton of Wolfram Class III, i.e. one which is computationally universal in the infinite case. - A universal Turing-machine with its infinite tape replaced with a finite tape, perhaps "shaped" like a Möbius strip so that seeking beyond the last cell returns the tape-head to the first cell. The behavior of this setup is expected to be similar but more general than that of \( Q \) due to the isomorphism between \( Q \) given some program and a particular Turing-machine with a blank finite tape. - A self-rewriting variant of \( Q \) where the program is loaded into and read from memory. In this case the problem of improper grammar becomes dynamic, as an initially grammatical program may modify itself to become ungrammatical. I suspect that a study of these and other finite machine models would lead one to believe in a sort of finite-computational universality, i.e., that all reasonable finite machine models share the same overall properties with respect to the halting problem, completeness, and the various complexities. 6 Conclusions The well-known principle of the recursive unsolvability of the halting problem, which holds true for the universal machines of canonical computational theory, is invalid when applied to finite machines. Consequences of the solvability of the finite machine halting problem include the computability of the busy beaver function and the halting probability for finite machines. Furthermore, for the machine and function-program isomorphism assumed here, all finite functions of a given base can be computed on a machine of that base within at most three cells of memory. This *finite completeness* stands in contrast to the famous incompleteness of infinite machines, i.e. the existence of uncomputable functions. Symbol List $\mathbb{Q}$ the machine model used here $\mathbb{Z}$ the set of integers $\mathbb{Z}_m$ the set of integers (mod $m$) $\Sigma$ the busy beaver function $\wedge$ boolean AND $\uparrow$ diverges $\downarrow$ converges $\vec{x}$ a vector (sometimes called a string) $x^i$ the $i^{th}$ component of $\vec{x}$, if defined $\&$ vector append operator $\in$ is a member of $\circ$ function composition $f^n$ function composed with itself $n$ times $\mathcal{R}$ interpretation of a program as a finite function References --- $^9$Two vectors or a vector and a scalar may be appended by this operator. Also, the following notations are defined: $$\&_{i=0}^n \vec{f}(i) = \vec{f}(0) \& \vec{f}(1) \& ... \& \vec{f}(n),$$ $$\&_{n} \vec{x} = \vec{x} \& \vec{x} \& ... \& \vec{x} \ (n \ times).$$
{"Source-Url": "https://quasiphysics.files.wordpress.com/2011/02/finite_machines.pdf", "len_cl100k_base": 6037, "olmocr-version": "0.1.49", "pdf-total-pages": 9, "total-fallback-pages": 0, "total-input-tokens": 33343, "total-output-tokens": 6849, "length": "2e12", "weborganizer": {"__label__adult": 0.00048065185546875, "__label__art_design": 0.0004870891571044922, "__label__crime_law": 0.0005526542663574219, "__label__education_jobs": 0.0013322830200195312, "__label__entertainment": 0.0001798868179321289, "__label__fashion_beauty": 0.00022101402282714844, "__label__finance_business": 0.0003764629364013672, "__label__food_dining": 0.0007371902465820312, "__label__games": 0.0010213851928710938, "__label__hardware": 0.002593994140625, "__label__health": 0.0010938644409179688, "__label__history": 0.0005059242248535156, "__label__home_hobbies": 0.0002397298812866211, "__label__industrial": 0.0009975433349609375, "__label__literature": 0.001338958740234375, "__label__politics": 0.0004267692565917969, "__label__religion": 0.0010976791381835938, "__label__science_tech": 0.416015625, "__label__social_life": 0.00014150142669677734, "__label__software": 0.00875091552734375, "__label__software_dev": 0.5595703125, "__label__sports_fitness": 0.0003533363342285156, "__label__transportation": 0.0010461807250976562, "__label__travel": 0.00021195411682128904}, "weborganizer_max": "__label__software_dev", "avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_ratio": [[0, 21308, 0.02663]], "fineweb_edu_fasttext_gt2__fineweb_edu_fasttext_gt2__score": [[0, 21308, 0.78661]], "ft_lang_id_en_doc_v2__ft_lang_id_en_doc_v2__en": [[0, 21308, 0.84803]], "google_gemma-3-12b-it_contains_pii": [[0, 1942, false], [1942, 3812, null], [3812, 6675, null], [6675, 9738, null], [9738, 12552, null], [12552, 15138, null], [15138, 17802, null], [17802, 20187, null], [20187, 21308, null]], "google_gemma-3-12b-it_is_public_document": [[0, 1942, true], [1942, 3812, null], [3812, 6675, null], [6675, 9738, null], [9738, 12552, null], [12552, 15138, null], [15138, 17802, null], [17802, 20187, null], [20187, 21308, null]], "google_gemma-3-4b-it_v2tag__is_academic_paper": [[0, 5000, true], [5000, 21308, null]], "google_gemma-3-4b-it_v2tag__is_class_syllabus": [[0, 5000, false], [5000, 21308, null]], "google_gemma-3-4b-it_v2tag__is_completion_certificate": [[0, 5000, false], [5000, 21308, null]], "google_gemma-3-4b-it_v2tag__is_court_notice": [[0, 5000, false], [5000, 21308, null]], "google_gemma-3-4b-it_v2tag__is_homework_assignment": [[0, 5000, false], [5000, 21308, null]], "google_gemma-3-4b-it_v2tag__is_news_article": [[0, 5000, false], [5000, 21308, null]], "google_gemma-3-4b-it_v2tag__is_public_order": [[0, 5000, false], [5000, 21308, null]], "google_gemma-3-4b-it_v2tag__is_resume_cv": [[0, 5000, false], [5000, 21308, null]], "google_gemma-3-4b-it_v2tag__is_test_or_quiz": [[0, 5000, false], [5000, 21308, null]], "google_gemma-3-4b-it_v2tag__is_textbook": [[0, 5000, false], [5000, 21308, null]], "pdf_page_numbers": [[0, 1942, 1], [1942, 3812, 2], [3812, 6675, 3], [6675, 9738, 4], [9738, 12552, 5], [12552, 15138, 6], [15138, 17802, 7], [17802, 20187, 8], [20187, 21308, 9]], "pipe_delimited_lines_v1__pipe_delimited_lines_v1__pipe_delimited_lines_ratio": [[0, 21308, 0.0]]}
olmocr_science_pdfs
2024-11-28
2024-11-28
bb82ed15f1501ea6f346b6edc1b0472aab3e03ee
METAPOD Template META-programming applied to dynamics: CoP-CoM trajectories filtering Maximilien Naveau, Justin Carpentier, Sébastien Barthelemy, Olivier Stasse, Philippe Souères To cite this version: Maximilien Naveau, Justin Carpentier, Sébastien Barthelemy, Olivier Stasse, Philippe Souères. METAPOD Template META-programming applied to dynamics: CoP-CoM trajectories filtering. International Conference on Humanoid Robotics, Nov 2014, Madrid, Spain. 10.1109/HUMANOIDS.2014.7041391. hal-01122475 HAL Id: hal-01122475 https://hal.archives-ouvertes.fr/hal-01122475 Submitted on 4 Mar 2015 HAL is a multi-disciplinary open access archive for the deposit and dissemination of scientific research documents, whether they are published or not. The documents may come from teaching and research institutions in France or abroad, or from public or private research centers. L’archive ouverte pluridisciplinaire HAL, est destinée au dépôt et à la diffusion de documents scientifiques de niveau recherche, publiés ou non, émanant des établissements d’enseignement et de recherche français ou étrangers, des laboratoires publics ou privés. Abstract—In this contribution, Metapod, a novel C++ library computing efficiently dynamic algorithms is presented. It uses template-programming techniques together with code-generation. The achieved performances shows some advantage over the state-of-the art dynamic library RBDL mostly on ATOM processor and for the inertia matrix computation, which are relevant for robotics application. On recent desktop computer, the ratio of the gain is not so obvious and in general the time achieved by both library is not significantly different for inverse dynamics. The advantage of this library is that it is open-source and does not rely on any external symbolic computational software. A main drawback is the increase complexity in debugging the code source due to template programming. Additionally we show how it can help in current control problems for humanoid robots, and more specifically for dynamic filtering of walking gait trajectories. I. INTRODUCTION Computing dynamic state estimate for a complex redundant robot such as humanoid robot is a crucial technique for controlling it. For instance, Inverse Dynamics control heavily relies on the computation of the inertia matrix [1], [2]. When considering balance, this matrix is of primary interest. Indeed most of the real-time approaches relies on the Linear Inverted Pendulum Model to generate a Center-Of-Mass reference trajectory which complies with the balance criteria provided by the Center-Of-Pressure and the contacts on the ground. Inverse Dynamics is necessary to counteract the inertial effect involved by the limbs: either by modifying the center-of-mass (CoM) reference [3], either by following the momentum reference trajectories. More advanced approaches are using Model Predictive Control (MPC) [4], [5] and need to compute the whole robot dynamic over a time horizon. Since 2006, processor speed is limited to 3~4 GHz, because transistors have reached their physical limits mostly due to heat dissipation [6]. The Moore Law is still valid because as the chipsets integrate more cores, the transistor number continues to grow not because of their size, but because of their density. They are overheating when CPU clock is increased, and the focus is now more on concurrent software programming to take advantage of multiple cores. In the case of MPC, it mainly consists in having multiple instances starting with different initial solutions. Boosting the code running concurrently will also increase the performances. It is now necessary to implement code to compute dynamics efficiently while taking into account the underlying computing architecture. A. Problem formulation The rigid multibody dynamic model of the robot is assumed to be known and called model. According to [7], the dynamical equations can be written under the canonical form: $$H(\text{model}, q) \ddot{q} + C(\text{model}, q, \dot{q}) = \tau$$ where $q$, $\dot{q}$ et $\ddot{q}$ are respectively the generalized vectors for positions, velocities and accelerations. $H$ is the generalized inertia matrix, $C$ is the matrix representing the centrifugal, gravitational and Coriolis forces. We should then compute as fast as we can: - $\tau$ by using the Recursive Newton-Euler Algorithm (RNEA) with the following inputs $q$, $\dot{q}$ et $\ddot{q}$. - $H(\text{model}, q)$ by using the Composite-Rigid-Body Algorithm (CRBA). To represent position, velocities, acceleration, and forces, spatial algebra is nowadays one of the most used representation in robotics. Introduced by Roy Featherstone [7], it allows a correct mathematically algebra notation to represent the relationships between quantities of a rigid multibody system. B. Applications 1) Walking: In the context of humanoid robotics, and following the method initiated by Nishiwaki et al. [3] for reactive walking, RNEA can be used to filter dynamically a Center-Of-Mass trajectory. Typically, for a humanoid robot, the goal is to compute 160 iterations for 30 DOFs robot in less than 200 $\mu$s. This corresponds to a 1.6 s window for an optimal controller as the one used classically for the HRP-2 robot, with a 200 Hz sampling. To reach this objective, a RNEA call should last no more than 1.25 $\mu$s. The result achieved by our library is 11.32 $\mu$s on a i7-2820QM CPU of 2.3 GHz. This imply to use a subsampling mechanism such as the one proposed by Nishiwaki et al. [3]. One may argue that sub-sampling this trajectory can decrease the overall complexity for walking (Nishiwaki uses a 20 ms time step). However we anticipate a demand on such information with the recent increase in work considering extreme motion involving strong angular moments (such as the Parkour [8]). In such situation linearization will be only correct at high frequency. 2) Whole-body control: Staying in the context of humanoid robotics, and by now considering a control architecture based on the inverse dynamics [9], [1], computing the inertia matrix at a very high speed may be necessary. Following the previous remark on sub-sampling, this is probably not required for motion with a slow dynamic. C. State of the art A classical approach is to implement RNEA and CRBA using instances of classes and structures, and to iterate over each element of the kinematic tree. RBDL (Rigid Body Dynamic Library) and KDL (Kinematic Dynamic Library) are using this approach. RBDL is following specifically the directives suggested by Featherstone in his book [7] by implementing the spatial algebra through C++ operators overloading. A different approach is to use symbolic computation. One of the first software implementing this approach is Symoro+ by Khalil et al. [10]. The software is able to produce reduced models and to generate code where unnecessary computation are stripped out. SD/FAST is a commercially available toolbox used by Boston Dynamics and the MIT leg laboratory [11]. HuManS is a toolbox written by P.-B. Wieber [12] relying on Maple for manipulating the robot kinematic tree. ROBOTRAN is a JAVA application which performs symbolic manipulation and generates code integrated in MATLAB and the Simulink toolbox [13]. In each case, the robot model is written in a specific language to be simplified and finally generated in C++. In Chapter 10 of his book, Featherstone indicates that a potential disadvantage of symbolic simplification is that it does not use vector-based arithmetic of CPUs, and that if the code is too large then it does not fit the computer’s instruction cache. In this work the first point is addressed by using Eigen, a widely known linear algebra library carefully written to exploit vector-based floating-point units. The second point is solved by using template programming which allows each instantiation of the template to invoke common code while avoiding indirect calls. More generally, in this work, we propose to use meta-programming to exploit directly the C++ capabilities to perform symbolic computation at compile time without any additional library or software other than the BOOST libraries. The current solution is completed with a C++ program which is parsing URDF files and generates appropriate structures to decouple model and instance of robots. The current limitation of the approach is the case where model modification is needed. A solution (not yet implemented in the current software solution) is an abstract layer switching from an optimized implementation to a generic implementation (RBDL or KDL). Another more complex solution is to compile the new model and link dynamically to this new library. Our contribution is to have written, to our knowledge, one of the first meta-programming library aiming at computing inverse dynamic for the robots. The application targeted in this paper is humanoid robot walking. By putting together the power of functional programming with C++ speed, our library is able to achieve performance necessary for real-time control. II. Template metaprogramming for inverse dynamics This work takes its root from the fact that code generated by symbolic formal computation has in general better performances than generic code for complex robotic models. This comes for the inner structure of the problem itself. For instance, the robot inertia matrix is sparse because the sub-blocks matrices correspond to the kinematic branches. Then when no coupling exists between some branches, the related sub-blocks mainly is equal to zero. Formal computation detects such branches and suppresses the related computation. We are proposing to make the same kind of operations by exploiting C++ template meta-programming. The result is a template library able to develop an optimized computational tree to evaluate the inverse dynamics of a robot class named Robot and to apply it onto the specific instance named robot, while considering the following complete state \((q, \dot{q}, \ddot{q})\). During execution, the model specificities are used to update robot internal variables according to \((q, \dot{q}, \ddot{q})\). A. Simple example of functional programming using C++ A famous example of functional programming in C++ is the factorial computation: ```cpp template <int n> struct factorial { enum { value=n*factorial<n-1>::value}; }; template <> struct factorial<0> { enum { value = 1 }; }; ``` At compile time, when the compiler finds `factorial<4>` it directly computes 24 by successive substitutions. The same type of mechanism is used to develop the RNEA algorithm from the model Robot. In order to achieve a decoupling between the model and the robot instances Metapod is using a template based container proposed by boost::fusion which allows an array like syntax with templates \[1\] The kinematic structure is then embedded through indexes that are found classically in an array, but here declared through `boost::fusion`. B. Spatial algebra and meta-programming The spatial algebra can be easily implemented in meta-programming thanks to static polymorphism. This is allowing to keep a very generic code quite similar to Oriented Object programming but without the additional cost induced by virtual methods. We can also avoid errors by using strongly typed operators. It has also been possible to implement the optimization described in Appendix 2 of Featherstone’s book [7]. This is especially useful to simplify computation when \[1\] A naive description of the approach is available at [https://github.com/laas/metapod/wiki/Naive-Implementation---First-approach](https://github.com/laas/metapod/wiki/Naive-Implementation---First-approach) parts of the robot are planar. One of the unitary test used in the library available through Github is the planar arm described in [14]. C. Visitor design pattern to compute inverse dynamic The depth first exploration of the robot structure is performed thanks to the visitor design pattern. This design pattern has been used in all algorithms where an iterative exploration of the tree structure is necessary. Finally, thanks to the design pattern coupled to boost::fusion which make possible to aggregate different types, it is possible to decouple the model from its instance. D. Benchmarks We compared the performances of Metapod with RBDL\textsuperscript{[1]} by computing the inertia matrix and the inverse dynamics on the CPUs listed in Table II. First we would like to emphasize that the numbers are only a snapshot and are subject to modifications, since the writing of this paper numerous improvements have been found. Some are currently tested for RBDL and for Metapod lead to the writing of a new library. The reader is invited to look at the link given in the footnote for further discussion. In each case, the library was recompiled using the GNU gcc compiler with the optimization options (-O3 -NDEBUG) trying to generate the code producing the best performances. The model used for benchmarking is the sample humanoid model provided by Tokyo University in OpenHRP. For this specific work we concentrated in two algorithms which are used in controlling a humanoid robot, the Composite Rigid Body Algorithm (CRBA) which computes the inertia matrix, and the Recursive Newton-Euler Algorithm (RNEA) which provides the torques necessary to counterbalance the gravity. Table II provides a quick view on the performance difference between Metapod and RBDL on various CPUs. The next section will detail some aspects related to the CPUs which will try to explain that the values provided here are to be taken cautiously and are likely to highly vary according to the CPU, the context of its overload, the compiler and the operating system. For this reason, we provide in Table II a ratio according to the CPU between the time provided by Metapod and RBDL. Note that CPU-2 corresponds to the HRP-2 real chipset with its real-time operating system. We have started some comparisons with symbolic computation libraries, but they usually imply the use of a costly third-part software. A comparison with HuManS on a structure similar to the model used here gives 8.35\textmu s for the CRBA algorithm on CPU-1. To achieve this result on Metapod with CPU-1 it was necessary to use the compiler options given in the remainder of the paper. They changed nothing for HuManS. As the later one does not use Eigen, this implies that, as mentionned by Featherstone, the use of vector-based arithmetic has a strong impact when computing the inertia matrix. Thanks to the authors of Symoro+, and if the paper is accepted, we hope to augment the comparison with this software. E. CPUs The Intel company divides its chipsets into 3 categories: Core, Xeon and Atom. With its low power consumption and low heat dissipation the Atom processor is aimed for embedded systems. The first and second families are used respectively for desktop applications and high power computation. The Xeon Phi category is targeted for many cores applications. 1) TurboBoost: To speed up the performance of the Core and Xeon families their coprocessors embed a technology that Intel names TurboBoost. It consists in increasing the CPU speed while respecting safety rules regarding heat dissipation and voltage. The maximum speed that can be reached is called the maximum turbo frequency. For instance regarding Table II CPU-1 and CPU-3 can reach respectively 3.4 GHz (from 2.3 GHz) and 3.8 Ghz (from 3.6 GHz). There is no guarantee that the maximum frequency is always reached as it depends on the current status on the chipsets. The Atom chipsets do not have the TurboBoost technology as well as the Core2 Duo E7500 (CPU-2) currently inside the HRP-2 humanoid robot. This is reflected by the numbers given in Table II where the raw times are 10 times faster on Xeon chipsets than on Atom. Interestingly one would have expected that CPU-1 with the turbo-boost would be at best near 0.9 the speed of CPU-3, as it is the ratio of their respective Turbo-Boost frequency. This relationship is not verified between CPU-1 and CPU-3. In addition the description of the TurboBoost technology in the Sandy Bridge micro architecture [15] shows a complex pattern depending on the current overall status of the CPU. It is worth noting that the operating system can also request TurboBoost by sending a signal (P-state request) if it detects an overloading status. 2) Branch prediction: Performances depend on another key technology: branch prediction. The chipsets maintain counters to predict the branches behavior. Depending on the statistics of the branch, the predictor tries to guess what will be the most probable code to be executed by the CPU. The code and its data are then prefetched from the memory while the CPU is decoding the current operation. Branch predictors can also detect cycles and save in cache intermediate variables to avoid costly access memory. Branch predictors is also able to indirect branch where multiple address are possible targets. The interest of the symbolic approach is to avoid as much as possible to make branches in the code. It facilitates the work of the branch predictor as well as the memory pre-fetching mechanism. This may explain why in Table II Metapod provides a 25-30 % increase in efficiency on the CRBA algorithm. Unfortunately chipsets providers, in general, do not give a detailed de- <table> <thead> <tr> <th>Nickname</th> <th>CPU name</th> <th>Frequency</th> <th>Core number</th> <th>Cache size</th> <th>Distribution</th> </tr> </thead> <tbody> <tr> <td>CPU-1</td> <td>Intel(R) Core(TM) i7-2820QM CPU</td> <td>2.3 GHz</td> <td>8</td> <td>8 Mb</td> <td>Ubuntu 12.04 LTS</td> </tr> <tr> <td>CPU-2</td> <td>Intel(R) Core2(TM) Duo E7500</td> <td>2.8 GHz</td> <td>1</td> <td>3 Mb</td> <td>Ubuntu 10.04 LTS</td> </tr> <tr> <td>CPU-3</td> <td>Intel(R) Xeon(R) CPU E3-1240 v3</td> <td>3.4 GHz</td> <td>8</td> <td>8 Mb</td> <td>Ubuntu 12.04 LTS</td> </tr> <tr> <td>CPU-4</td> <td>Intel(R) Atom(TM) CPU N720</td> <td>1.6 Ghz</td> <td>1</td> <td>512 Kb</td> <td>Ubuntu 12.04 LTS</td> </tr> </tbody> </table> TABLE I CPUs used for the benchmarking. CPU-1 is a laptop, CPU-2 is one used in HRP-2, CPU-3 is a desktop, and CPU-4 is a NetPC. CPU-2 is using only one core due to the real-time operating system recognizing only one core. <table> <thead> <tr> <th>Library</th> <th>Algorithms</th> <th>CPU-1</th> <th>CPU-2</th> <th>CPU-3</th> <th>CPU-4</th> </tr> </thead> <tbody> <tr> <td></td> <td></td> <td>µs</td> <td>µs</td> <td>µs</td> <td>µs</td> </tr> <tr> <td>Metapod</td> <td>CRBA</td> <td>7.89</td> <td>12.97</td> <td>5.08</td> <td>61.06</td> </tr> <tr> <td></td> <td>RNEA</td> <td>9.28</td> <td>13.85</td> <td>0.75</td> <td>0.76</td> </tr> <tr> <td></td> <td></td> <td>0.77</td> <td>0.69</td> <td>0.76</td> <td>0.76</td> </tr> <tr> <td></td> <td></td> <td>0.97</td> <td>0.75</td> <td>0.82</td> <td>0.90</td> </tr> <tr> <td></td> <td></td> <td></td> <td>13.85</td> <td>0.75</td> <td>0.82</td> </tr> <tr> <td>RBDL</td> <td>CRBA</td> <td>10.16</td> <td>18.59</td> <td>6.60</td> <td>79.68</td> </tr> <tr> <td></td> <td>RNEA</td> <td>9.5</td> <td>18.66</td> <td>5.99</td> <td>67.68</td> </tr> </tbody> </table> TABLE II Processing time for three basic algorithms used in control of humanoid robot: Inertia matrix computation (CRBA), Inverse Dynamics (RNEA). The computation have been tested on 4 CPUs. <table> <thead> <tr> <th>Library</th> <th>Ir</th> <th>HmIr</th> <th>LmIr</th> <th>Dr</th> <th>DlIr</th> <th>DlMr</th> <th>Dw</th> <th>DlMw</th> <th>DlMw</th> </tr> </thead> <tbody> <tr> <td>Metapod</td> <td>4,529,574,180</td> <td>69,802,287</td> <td>2,722</td> <td>2,154,169,130</td> <td>9,709,886</td> <td>5,040</td> <td>1,034,216,699</td> <td>27,501,390</td> <td>1,136</td> </tr> </tbody> </table> TABLE III Ir: Number of executed instructions, HmIr: Instruction read misses for cache L1, LmIr: Instruction read misses for Last Level cache, Dr: Number of cache read misses, DlIr: Data read misses for cache L1, DlMr: Data read missses for Last Level cache, Dw: Number of cache write, DlMw: Data write misses for cache L1, DlMw: Data write misses for Last Level cache. Tests realized on CPU-1. <table> <thead> <tr> <th>Library</th> <th>Bc</th> <th>Bcm</th> <th>Bi</th> <th>Bim</th> </tr> </thead> <tbody> <tr> <td>RBDL</td> <td>245,662,040</td> <td>7,604,170</td> <td>45,177,857</td> <td>269,654</td> </tr> <tr> <td>Metapod</td> <td>98,901,411</td> <td>977,079</td> <td>14,105,063</td> <td>726</td> </tr> </tbody> </table> TABLE IV Bc: Conditional branches executed, Bcm: Conditional branches mispredicted, Bi: Indirect branches executed, Bim: Indirect branches mispredicted. Tests realized on CPU-1. The use case considered here is the HRP-2 humanoid robot that is one used in AIRBUS/Future of the Aircraft factory. AIRBUS/Future of the Aircraft factory is currently evaluating the potential of humanoid robots in such context. The use case considered here is the HRP-2 humanoid robot bringing an electric screw driver to an assembly line. On the other hand, in the context of the Koroibot project aiming at studying human walking to improve humanoid robot motion, we have created a stair climbing motion primitive. The behavior consisting in bringing a tool while climbing the stairs is then a combination of the two motion primitives. We show. III. Dynamic filtering for walking To illustrate the use of Metapod on a humanoid robot, we consider an application where the robot has to evolve in a factory. AIRBUS/Future of the Aircraft factory is currently evaluating the potential of humanoid robots in such context. The use case considered here is the HRP-2 humanoid robot bringing an electric screw driver to an assembly line. On the other hand, in the context of the Koroibot project aiming at studying human walking to improve humanoid robot motion, we have created a stair climbing motion primitive. The behavior consisting in bringing a tool while climbing the stairs is then a combination of the two motion primitives. We show. We kindly invite the interested reader to follow the gcc manual for a more detailed explanation of the options. next that, thanks to Metapod, the dynamical consistency can be realized in real time. A. Dynamic filtering on a sub-sampled walking pattern generator This work is based upon the real time walking control system described by Nishiwaki in [3]. One key ingredient is to generate real-time dynamically stable CoM and Center-of-Pressure (CoP) trajectories using the cart-table model [18]. Then to correct the inertial effects induced by the legs movement Nishiwaki uses a subsampled dynamical filter. Indeed, the results tested on HRP-2 have shown that the CoP trajectory followed by the robot are not the desired one, the difference can be as big as 15 mm. To avoid this problem, the solutions consist in designing a controller regulating the linear and angular momentum [19] in addition to a dynamical filter aiming at correcting the CoM trajectory in order to take into account the dynamics of the robot. The first kind of solution is mostly used to reject instantaneous perturbations. However, it uses additional degrees of freedom that could have been used for manipulation tasks for example. For this reason, in our specific case, we have only implemented the dynamical filter as the commercially available stabilizer this reason, in our specific case, we have only implemented. The walking pattern generator (WPG) defines a trajectory for the CoM, the feet and the CoP. The desired CoP trajectory is noted CoP∗. The dynamic filter starts by computing the joint trajectories using the analytical inverse kinematics. We make the assumption that the CoM and the free flyer are rigidly connected. \[(q, \dot{q}, \ddot{q}) = IK(\text{punctual}_\text{model}, c, \dot{c}, \ddot{c}, X^f)\] with \(c, \dot{c}, \ddot{c}\) et \(X^f\) being respectively the position, the velocity, the acceleration of the CoM and the feet position. With the joint trajectory, it is possible to compute the inverse dynamics and to find the CoP matching up to the real robot motion. We call it the multi-body CoP noted CoPMB. \[ \begin{align*} (f, \tau) &= ID(\text{model}_\text{complet}, q, \dot{q}, \ddot{q}) \\ CoP_{x}^{MB} &= -\frac{\tau_x}{mg} \\ CoP_{y}^{MB} &= \frac{\tau_y}{mg} \\ CoP_{z}^{MB} &= 0 \\ \Delta \text{CoP} &= \text{CoP}^* - \text{CoP}^{MB} \end{align*} \] This provides an error between \(\text{CoP}^*\) and \(\text{CoP}^{MB}\). This error is computed over a time window and is injected in a preview control (PC) in the shape of an LQR described by Kajita and al. [18]. The result of this step is an error for the CoM in position, velocity and acceleration. \[ \Delta \text{CoM} = PC(\Delta \text{CoP}) \] - We can then sum this error on the reference CoM (\(\text{CoM}^*\)) to correct the trajectory. \[ \text{CoM} = \text{CoM}^* + \Delta \text{CoM} \] With \(\text{CoM} = [c \ \dot{c} \ \ddot{c}]^T\). - Finally, the new CoM trajectory is used to compute the joint trajectory using the Inverse Kinematics. This dynamic filter is based on the Newton-Raphson algorithm using the CoM trajectory as free variables. This method does not guarantee the convergence. However during tests on HRP-2 with other WPG, we observed that the CoP trajectory is corrected in one iteration. The goal is to implement this method on the WPG of Andrei Herdt [20] and Morisawa’s [21]. B. Application on HRP-2 We propose to use this filter on the WPG proposed by Morisawa and al. in [21]. This algorithm uses an analytical form of the CoM and CoP trajectories assuming that the later is a third order polynomial. The Morisawa’s WPG can either define off line the whole trajectory at once, or change online the foot steps given as reference. To use the filter with its full potential on the online Morisawa’s WPG we need to compute the trajectory over 1.6 s in advance, i.e. two steps forward. The computation of the trajectory is done every 5 ms including the control, so the remaining time for the WPG is 3 ms. Moreover, because the robot HRP-2 is controlled at 200 Hz, we need to compute 32 RNEA to use the whole preview. Our implementation, as fast as it is, does not allow this kind of computation, hence we used a strategy proposed by Nishiwaki, i.e. we sub sampled the preview window at a period of 0.05 s which leads to 32 RNEA every 0.1 s. We rather compute the whole dynamic filter for the offline WPG of Morisawa. This study is based on the offline WPG. We computed 1.6 s more than the initial trajectory and we computed the multi-body CoP for each sampling time. The results obtained are illustrated in the Fig. 1. • the trajectories of the reference CoP, • the multi-body CoP computed with RNEA, • and the corrected CoP obtained with the RNEA using the corrected CoM The upper graph depicts the evolution on the axis \( X \) in function of the time and the lower graph shows the evolution of the \( Y \) axis in function of the time. This data are extracted from a straight walking using the offline WPG of Morisawa. We can here easily see the influence of the filter, i.e. the corrected multi-body CoP is almost fused with the reference one. In terms of distance, the maximum error between the reference CoP and the multi-body CoP is 15.3 \( \text{mm} \) while the maximum distance after correction is 1.7 \( \text{mm} \). In average the error before correction is 5.7 \( \text{mm} \) and after it is 0.7 \( \text{mm} \). In term of computation time, we executed the algorithm that creates a straight flat walking on the HRP-2 robot. The results are 15.0 \( \text{us} \) for the average time used to compute the RNEA during the whole trajectory and 342.0 \( \text{us} \) for the maximum duration of one iteration of RNEA. This peak corresponds to the first iterations of the algorithm, corresponding to memory allocation. We have done a series of experiments using the dynamic filter including the straight walking and climbing stairs. For the climbing we had four scenarios: one simple walk, a walk while swinging the arm and holding a lightweight tool in one hand, another one holding the tool with 2 hands. In the last one the tool is hold with the hands lifted over the head. HRP-2 went through all the pattern has depicted in the companion video. We also succeeded to make the robot going down the stairs with the lightweight in two hands, however we did not manage to make HRP-2 perform the rest of the scenario while going down. One of the raisons that explain this behaviour is that the dynamic filter places the CoM in a way such that the CoP is inside the support foot. To compensate for the arms being in front, the CoM is send slightly backward. The leg is then stretched and create a singularity. This shows the limit of this approach which calls for a more advanced development such as optimal control, whole-body predictive control or planning. In this section we have shown that one iteration of a Newton-Raphson algorithm can make the CoP converge towards its reference and it could be applied to WPG focusing on the under-actuated part of the robot. IV. CONCLUSION We have presented a C++ library for efficient humanoid dynamic computation without relying on any particular sym- bolic computational tool. The achieved performances shows some advantage over the state-of-the art dynamic library RBDL mostly on ATOM processor and for the inertia matrix computation, which are relevant for robotics application. On recent desktop computer, the ratio of the gain is not so obvious and in general the time achieved by both library is not significantly different for inverse dynamics. Some preliminary results show that we have a computational speed similar to symbolic computation. This is achieved through a mix of code generation and C++ meta-programming. Its use is established in the context of dynamic filtering for real-time walking gait generation, and more specifically applied to the humanoid robot HRP-2. The library is available under GPL- license at the following url: [https://github.com/laas/metapod](https://github.com/laas/metapod) REFERENCES “Prioritized optimal control,” in *ICRA*, 2014. humanoids with short cycle pattern generation,” *The International based on online optimization,” in *ICHR*, 2013, pp. 21–27. dynamic programming,” in *ICRA*, 2014, pp. 1168–1175. to binary logic switch scalinga gedanken model,” *Proceedings of the 2008. humanoids operating in human environments,” in *ICRA*, 2006. humans toolbox, a homogeneous framework for motion capture, analysis and simulation,” in *Ninth ISB Symposium on 3D analysis [15] E. Rotem, A. Naveh, D. Rajwan, A. Ananthakrishnan, and E. Weiss- mann, “Power-management architecture of the intel microarchitecture code-named sandy bridge.” *Micro, IEEE*, vol. 32, no. 2, pp. 20–27, March 2012. IEEE International Symposium on Workload Characterization [17] V. Uzelac and A. Milekovic, “Experiment flows and microbench- marks for reverse engineering of branch predictor structures,” in *IEEE International Symposium on Performance Analysis of Systems and “Biped walking pattern generation by using preview control of zero-moment [19] ——, “Resolved momentum control: Humanoid motion planning based on the linear and angular momentum,” 2003. M. Diehl, “Online walking motion generation with automatic footstep [21] M. Morisawa, K. Harada, S. Kajita, S. Nakaoka, K. Fujiiwa, F. Kane- hiro, K. Kanehiro, and H. Hirukawa, “Experimentation of Humanoid Walking Allowing Immediate Modification of Foot Place Based on ACKNOWLEDGMENT The Metapod library was made possible thanks to the work of Maxime REIS. Antonio EL-KHOURY took an active part in the improvement of Metapod. We warmly thank them.
{"Source-Url": "https://hal.archives-ouvertes.fr/hal-01122475/file/14-ichr-metapod.pdf", "len_cl100k_base": 7755, "olmocr-version": "0.1.49", "pdf-total-pages": 7, "total-fallback-pages": 0, "total-input-tokens": 24140, "total-output-tokens": 8899, "length": "2e12", "weborganizer": {"__label__adult": 0.0008592605590820312, "__label__art_design": 0.0007371902465820312, "__label__crime_law": 0.0009531974792480468, "__label__education_jobs": 0.0006475448608398438, "__label__entertainment": 0.0001475811004638672, "__label__fashion_beauty": 0.0004062652587890625, "__label__finance_business": 0.00034332275390625, "__label__food_dining": 0.0006794929504394531, "__label__games": 0.0015325546264648438, "__label__hardware": 0.0051116943359375, "__label__health": 0.0019063949584960935, "__label__history": 0.0006337165832519531, "__label__home_hobbies": 0.00029540061950683594, "__label__industrial": 0.0015745162963867188, "__label__literature": 0.0003800392150878906, "__label__politics": 0.0007405281066894531, "__label__religion": 0.0010423660278320312, "__label__science_tech": 0.258056640625, "__label__social_life": 0.0001608133316040039, "__label__software": 0.006595611572265625, "__label__software_dev": 0.71240234375, "__label__sports_fitness": 0.0012674331665039062, "__label__transportation": 0.0030155181884765625, "__label__travel": 0.0003654956817626953}, "weborganizer_max": "__label__software_dev", "avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_ratio": [[0, 32955, 0.04672]], "fineweb_edu_fasttext_gt2__fineweb_edu_fasttext_gt2__score": [[0, 32955, 0.41884]], "ft_lang_id_en_doc_v2__ft_lang_id_en_doc_v2__en": [[0, 32955, 0.87263]], "google_gemma-3-12b-it_contains_pii": [[0, 1135, false], [1135, 5909, null], [5909, 11702, null], [11702, 17406, null], [17406, 21477, null], [21477, 25993, null], [25993, 32955, null]], "google_gemma-3-12b-it_is_public_document": [[0, 1135, true], [1135, 5909, null], [5909, 11702, null], [11702, 17406, null], [17406, 21477, null], [21477, 25993, null], [25993, 32955, null]], "google_gemma-3-4b-it_v2tag__is_academic_paper": [[0, 5000, true], [5000, 32955, null]], "google_gemma-3-4b-it_v2tag__is_class_syllabus": [[0, 5000, false], [5000, 32955, null]], "google_gemma-3-4b-it_v2tag__is_completion_certificate": [[0, 5000, false], [5000, 32955, null]], "google_gemma-3-4b-it_v2tag__is_court_notice": [[0, 5000, false], [5000, 32955, null]], "google_gemma-3-4b-it_v2tag__is_homework_assignment": [[0, 5000, false], [5000, 32955, null]], "google_gemma-3-4b-it_v2tag__is_news_article": [[0, 5000, false], [5000, 32955, null]], "google_gemma-3-4b-it_v2tag__is_public_order": [[0, 5000, false], [5000, 32955, null]], "google_gemma-3-4b-it_v2tag__is_resume_cv": [[0, 5000, false], [5000, 32955, null]], "google_gemma-3-4b-it_v2tag__is_test_or_quiz": [[0, 5000, false], [5000, 32955, null]], "google_gemma-3-4b-it_v2tag__is_textbook": [[0, 5000, false], [5000, 32955, null]], "pdf_page_numbers": [[0, 1135, 1], [1135, 5909, 2], [5909, 11702, 3], [11702, 17406, 4], [17406, 21477, 5], [21477, 25993, 6], [25993, 32955, 7]], "pipe_delimited_lines_v1__pipe_delimited_lines_v1__pipe_delimited_lines_ratio": [[0, 32955, 0.09877]]}
olmocr_science_pdfs
2024-11-24
2024-11-24
16e378796df997197538e9b12308e6f28a859c3e
In-memory Analytical Systems: Perspective, Trade-offs and Implementation Executive Summary This white paper examines the pros and cons of in-memory analytics with particular reference to TIBCO Spotfire analytics solution. It is divided into four main sections: Introduction, Trade-offs, Overview of In-memory Approaches and TIBCO Spotfire Analytics's approach. The Introduction discusses the balance act engineers encounter in developing analytical systems. Trade-offs looks at the fundamental differences between in-memory and disk-based approaches. This is followed by an analysis of the different in-memory approaches. Finally, the engineering considerations of the TIBCO Spotfire approach are explored. Introduction Transactional databases are just that; they are databases designed to collect transactions. The designers who build the engines (Oracle, SQL Server, DB2, etc.) that underpin these transactional systems strive to build the best engines they can but, like any engineering problem, they have to reconcile a number of conflicting constraints. For example, everyone wants the engine to process transactions as quickly as possible. However those transactions must be internally consistent (the data integrity must be retained) and the transactions must demonstrate persistence (that is, they must survive over time); ensuring both of these inevitably impacts the transaction rate. Finding the right balance between speed, integrity, persistence and the host of other factors is what makes the difference between an average database engine and a great one. We see this balancing act in many areas of engineering. Dragsters are carefully honed for the single task of accelerating as rapidly as possible - which makes them complete disasters as family cars. Their turning circles are wider than the average parking lot and then there are the flames from the exhausts…. In the same way, transactional (OLTP – On Line Transaction Processing) systems are bad at anything other than transaction processing – analysis for example. The problem is that the work loads are simply too different. Transactional systems often store each piece of data once and once only to help ensure data integrity, but doing so splits the data up into multiple tables with multiple joins between them. Analytical systems often have to perform huge aggregations across millions of rows so it is far more efficient to analyze just one table. However to get all the data into one table means we have to store multiple copies of each piece of data. So are all analytical (OLAP - On Line Analytical Processing) systems the same? No. One major difference is that some hold the data on disk (disk-based systems) and others hold it in memory (in-memory systems). On the face of it, memory has an over-riding advantage over disk; it is much, much faster – something like three orders of magnitude faster. But like all engineering decisions, there is rarely one over-riding factor. It turns out that designing a good in-memory analytical system is as much a careful balancing act as designing a good transactional one. The next section takes a look at the fundamental pros and cons of in-memory analytical systems. These factors are the same for any in-memory analytical system and are not specific to TIBCO Spotfire. Trade-offs: In-memory vs Disk-based Approaches Pros and cons are always comparative. If we say that a given technology is faster we must have some other technology in mind for comparison. The alternative to RAM (Random Access Memory) is disk - HDD (Hard Disk Drive). Essentially there are four areas where comparison is significant: - Speed - Persistence - Price - Volume **Speed:** This is definitely, without question, a pro for in-memory systems. When do you ever hear someone ask for his analytical system to run more slowly? Speed is very, very important in analysis and RAM is faster than disk. Much faster. **Persistence:** One of the most important characteristics of an OLTP system is ‘data persistence’ - a measure of how long the data remains in existence after it has been created. RAM, of course, loses the data as soon as the power is disconnected, but the persistence requirements for OLAP are significantly different from those of OLTP. Since we typically analyze data taken from the OLTP systems, we can rely on their ability to persist data to ensure that data is never lost. **Price:** RAM is expensive compared to disk, very expensive. Current retail prices are in the order of: - HDD – 1 TByte – USD$120 = 12 cents per GByte - RAM – 1 GByte = USD$30 per GByte **Volume:** 32 bit systems can theoretically support 4 GBytes of RAM but in practice they’re often restricted to perhaps 3.5 GBtyes. 64 bit systems have a theoretical limit of 16.3 billion Gbytes (16.3 Exabytes) of RAM - in practice there are other limitations such as the operating system. There is no point in suggesting that disks aren’t far cheaper and far more readily accessible in large volumes. Persistence is vital in transactional systems but is not usually an issue for in-memory analytical systems. The significant advantage of in-memory systems is that, with the right engineering, they can be made much, much faster than disk-based systems. Let’s take a look at some of the practical trade-offs that are encountered in real situations: 1. **Memory Availability and Cost vs. Real World Data Volumes for Analysis** One question of paramount importance at this point is “How much data do the people who use in-memory analytics actually want to analyze?” Memory is expensive and limited in volume compared to disk. But if the target users never need to analyze more than, say, 3 GBytes of data, then these are not restrictions in any practical sense. Another way to approach this question is to ask how much data fits into, say, 1GByte? Let’s assume one table with 20 columns. Ten of the columns are text (limited to, say, 50 characters but with an average length of seven characters), five are dates, three integers and two reals. A 1.5 million row table saved as a CSV file is 236 Mbytes – about a quarter of a GByte. If we double the number of columns and rows, that’s about 1 GByte. 40 columns and 3 million rows is a sizeable chunk of data, depending on the kind of analysis you want to perform. So one GByte of RAM may sound trivial when matched against the TBytes available on disk but for many people in many analytical situations, it is more than enough. If it isn’t enough, but 5-10 million rows will cover it, then the extra 100-200 USD for the RAM isn’t going to break the bank. However if you need to analyze TBytes of data in a single analysis, and people do, then in-memory systems are probably not for you. 2. **Central Control vs. Ad-hoc Data Exploration** Most enterprises already have existing Business Intelligence (BI) systems. These pull copies of the transactional data from the operational systems and load it into a data warehouse (disk-based for persistence). Data is then extracted from the warehouse and moved to analytical systems. One huge advantage of a BI system is that it allows centralized control of the data for analysis. This means that the definitions of the data can be very carefully controlled, as can the quality of the data and the access to it. BI architects consider this aspect of BI to be hugely important. Without this centralized control we have silos of data, silos of meaning and multiple versions of the truth. This can rapidly lead to analytical anarchy – ‘Excel Hell’ as it is sometimes termed. So, centralized control is essential, but it can come at a terrible price. If we aren’t careful, it can slow the delivery of new ways of working to a crawl. How often have we heard business users complaining that “It takes IT far too long to make the changes I need.” Don’t those guys realize I need to make this decision today?” “I’ve asked for a new analysis and all IT can talk about is its change-management system!” Once again, we come to an engineering trade-off. Too much central control stifles innovation, rapid response and business agility. Too little unleashes the dogs of anarchy. In-memory management, just like a chain saw, is a powerful tool. Both trees and people have limbs and a chain saw can remove both with alacrity when used thoughtlessly. In intelligent hands, in-memory analytical systems are a perfect complement to any BI system. They can take the ‘controlled’ data from the central core and allow users to perform ad hoc analysis on it. They can combine that data with other sets as and when required. If such an analysis proves worthwhile, then is the time to bring that new data under centralized control. In my opinion, in-memory analysis is a very powerful tool and represents no threat to the concept of ‘one version of the truth’ unless it is badly used. 3. Measures and Dimensions vs. Free Dimensional Analysis In traditional analytical systems we distinguish between measures and dimensions. Measures are numerical and continuously variable. Dimensions are discontinuous and can be used to segment the measures. As a simple example, an analytical system might have two measures: - Price Line Item - Quantity Ordered and three dimensions - Time - Customer - Sales Person The dimensions are typically hierarchical, so Time might have four levels: - Day - Month - Quarter - Year We often have a very large number of values for the measures. In this example we might over ten years, receive an average of 10,000 orders per year, which might equate to 50,000 order detail records per year, half a million over 10 years. We typically aggregate measures, so if we plot a measure against a dimension (perhaps the sum of Price Line Item against month for a single year) we are only plotting twelve values. However, if we plotted a measure against another measure, say Quantity Ordered against Price Line Item for the same period, we would suddenly have 50,000 points on the graph. This can be mind-numbingly slow to plot, which is why most analytical systems make the clear distinction between measures and dimensions and quietly refuse to plot measure against measure. Many users of analytical systems have simply come to accept the limitation and never even try to do it – or work around the problem. Which is odd because the inability to plot measure against measure is not a logical issue; it is merely a performance one. With certain types of data, this ability can be immensely useful and in-memory systems have the potential to be fast enough to allow users to do this. This brings us neatly to a differentiation between in-memory and disk-based systems that is highly significant but often overlooked – freedom from the need to pre-model. 4. Pre-Modeling of Data vs. Free Dimensional Analysis Disk-based analytical systems force the user to pre-model the data – that is, to make many decisions about it before the analysis is performed. The need to classify data as measures and dimensions is one example of pre-modeling, defining the hierarchies within dimensions is another. Disk-based systems require this pre-modeling, because for performance reasons, they need to pre-aggregate the data before analysis can be performed. The problem is that the pre-modeling inevitably restricts the analyses that can then be carried out. It also introduces a delay between data loading and availability for analysis and means that if the hierarchies are changed, the aggregations have to be recalculated. In-memory analytical systems can be fast enough to aggregate on the fly. This allows hierarchies to be created on the fly which means that in-memory systems can be entirely freed from the need to pre-model the data for performance. Many users simply come to accept they cannot plot measure against measure. Figure 2 – Spotfire Analytics allows for a flexible Measure vs Measure analysis: Price by Quantity Ordered 5. Speed and User Interface Design Stated earlier, in-memory is faster than disk based analysis. That speed can be utilized in several ways, and one of the most important turns out to be making the user interface much more responsive. This sounds like a mere convenience but it turns out to be highly significant. Since some original work done at IBM in 1984 it has been known that increasing the speed of the response of a system can significantly increase productivity. In fact, this had been intuitively understood even before 1984 but these two papers highlighted the importance of getting response times below one second. Lambert’s paper, for example, revealed that reducing the system response time from 2.22 seconds to 0.84 seconds resulted in a massive 62 percent improvement in user productivity. So, in terms of a user-interface, ‘fast’ doesn’t mean under five seconds, it means sub-second responses. Overview of the Different In-memory Approaches Designing an in-memory analytical system is like solving any other engineering problem. Along the way you face a large number of design decisions, each of which has pros and cons and implications. Designing the TIBCO Spotfire solution was no different. 1. Pre-aggregation One of the greatest decisions in designing an in-memory system has to be whether or not to pre-aggregate the data (e.g., sales per month, by product group). This is very common in disk-based systems where it makes a huge speed difference so perhaps it feels intuitively right to do the same in in-memory systems. Pre-aggregation in memory can be argued to provide a better high-level overview of the data. However it takes time and it also takes up memory to store the aggregations. We read in the data to create a single table with no pre-aggregation. This makes the data available in a simple format that is easy for the user of the system to understand. Spotfire Analytics sees two issues in pre-aggregation. First it takes time, second it enforces a level of prejudgment on the analysis that the user may be going to perform. Spotfire software can get the speed it needs (response times of 0.2 seconds) by other means. So while the Spotfire development team did look at pre-aggregation very carefully, it decided it had too many disadvantages and very few advantages. 2. Applying Heuristics Some data for analysis arrives with meta data that describes it (data from tables in relational database systems for example) some doesn’t (CSV files). However it is possible, as data is loaded, to apply heuristics to learn about the data. If, for example, a column contains text values that look, smell and taste like dates, then it makes sense to assume that they are dates. The huge advantage of applying heuristics is that when the user comes to analyze the data, if the software is aware that a given column is a date, the user can be presented with a range of possible date hierarchies that may be appropriate. In the same way, if a column contains numbers, and the software makes that decision during loading, then the user can be presented with an interface that allows, for example, numerical data to be filtered elegantly. The downside of taking a look at the data during loading is that it takes time to do it. The upside is that Spotfire Analytics was able to create an interface that takes intelligent account of the specific data and presents the user with a ready-to-use application with logical choices for the analysis they can perform. 3. What do you do when the volume of the data that the user wants to analyze exceeds the volume of available memory? There are essentially three options here: 1. Crash and burn 2. Refuse to load the extra data 3. Swap to disk Spotfire Analytics chose option three. While option two is also perfectly fair; the development team eventually decided that option three offered enough advantages to be worth implementing. The downside of option two is obvious – if you happen to need to analyze a bit more data than usual, you can’t. The downside of option three is that, when there is more data, the analysis will be slower. In addition the internal code for the in-memory system has to be more complex. It also has to keep checking (“Are we in a situation where we have to swap to disk?”) so that slows it down as well. The upside however is clear, the system doesn’t crash and it does allow you to complete the task in hand. And once you have made the decision to swap to disk, several other advantages follow. For example, in Spotfire software’s web-based solution several users can look at the same (or different) data and simultaneously use memory on the server. If the server begins to run out of memory Spotfire Analytics makes intelligent decisions about what to do – for example, the system can page out the data that is being used infrequently (some of the users may be ‘idle’). Ultimately disk swapping adds to the complexity of the application but Spotfire Analytics believes it is a good trade off. And, of course, the system can swap to SSD (Solid State Disk) as opposed to HDD which reduces the speed hit significantly. 4. **Should you support undo and redo?** As users of applications such as Microsoft Office, we have all become accustomed to this functionality, so it is a feature in Spotfire Analytics. The advantage is huge – users can work in the way in which they have become accustomed. The bad part is that undo puts a very heavy load on an analytical system. You may, for example, be undoing and redoing a join to a GByte of data. Where is that data stored in the meantime? Do you store it in memory (where it is cutting down on your space for data) or on disk (assuming that your system actually allows for swapping to disk)? So undo/redo is highly desirable but it comes at a cost. Spotfire Analytics believes the benefits hugely outweigh the cost. 5. **What file size should you support?** With the advent of 64 bit systems, the old 4 GByte limit has finally been removed. With the 3.2 release of Spotfire Analytics, the file size restriction for 64 bit systems has been removed. It now supports the file size supported by the OS; simple as that. Actually, it wasn’t quite that simple in engineering terms, but the development team believed it was important to do. 6. **Compression** Spotfire Analytics does, of course, compress the data; indeed great care is taken to balance compression against the type of data that the user has. Sales data is generally much more compressible than scientific or financial data for example. Sales data for 10,000 products over geographic regions make up just a couple of million data values. Compressing a 100 million row data set to something much smaller is possible, while a 100 million data set of unique scientific measurements is not. Spotfire Analytics has extensive experience working with data from multiple domains. It knows that what looks good in the lab might not be that good in the real world. So the system has multiple ways of compressing the data - we look at the data as it is imported and apply the best compression algorithm. Benefits of the Spotfire Approach Oddly enough, Spotfire software’s overall approach to analysis didn’t start with the assumption that it had to use an in-memory data model. The goal was to improve the user’s experience in finding answers to their questions, to allow users to work with information where they don’t have to fire off complicated queries that take a long time to return the answer. The development team also wanted to free users from the old paradigms of Dimensions vs. Measures and give them more intuitive ways of working with the data. So it started with a set of design criteria that would allow it to do all of that; fulfilling those requirements ultimately led to the adoption of an in-memory model. That essentially gave us three important capabilities that we could deliver: 1. A faster environment for end-users to work with data 2. Flexibility in working with the data to answer both anticipated and unknown questions 3. The ability to swap out to disk 1. A faster environment for end-users to work with data It is very important that Spotfire software provide a user interface (UI) that meets Human Computer Interaction criteria – responsive, intuitive, well designed with an immediate response to user actions (within 0.2 of a second). It is well documented that productivity increases dramatically with systems that respond quickly to user actions. Compare the query, wait, result view over 30 seconds in many BI systems with one that takes only 0.2 of a second or less. In fact, users don’t come back and use systems that behave in the former way. This UI is provided automatically by Spotfire Analytics. Since the system infers what the data types and characteristics are (no modeling needed) a UI can automatically be generated so that the user can start to look at the data right away. This allows users to focus on analysis and exploration of the data instead of worrying about how to ask as few questions as possible of a slow and unresponsive system. The thing to watch out for is - Does the system take advantage of the RAM or is it simply putting the old data architecture in memory to gain performance? We can gain speed with in-memory, but that is far from all we can do for the users. 2. Flexibility in working with the data to answer both anticipated and unknown questions Spotfire’s in-memory implementation drops the notion of Dimensions and Measures because the system doesn’t require users to define pre calculations or worry about a user putting two measures against one another in a diagram or table, or a category vs. a measure in a scatter plot. It allows the users to filter and re-group data on the fly. The same applies to aggregations. Spotfire Analytics doesn’t apply any modeling restrictions on the data because it is readily available and indexed as it has been read in to memory. Users are now able to work more freely with the data to find answers to their own questions – it is easier and faster leading to more insight and better decisions. One of the other areas in which Spotfire Analytics believes its technology excels is in pulling in data from external sources and adding it to the existing data set in memory. This is nontrivial to do for many systems. Spotfire software’s design allows users to easily append new rows, and append new columns; it is optimized for both not just for one. If the user adds extra attributes the system simply generate new filters and new indices; if new rows of data are added then it update the indices. Key question: does the system take advantage of RAM or is it simply putting the old data architecture in memory? <table> <thead> <tr> <th>Sales and Profit</th> <th>Sales (-binary)</th> <th>Profit (binary)</th> </tr> </thead> <tbody> <tr> <td>subtotal</td> <td>x = 907.75</td> <td>1.476</td> </tr> <tr> <td>subtotal</td> <td>x = 1 462.59</td> <td>2.672</td> </tr> <tr> <td>subtotal</td> <td>x = 1 839.25</td> <td>7.261</td> </tr> <tr> <td>subtotal</td> <td>x = 2 428.90</td> <td>9.733</td> </tr> <tr> <td>subtotal</td> <td>x = 2 861.97</td> <td>10.206</td> </tr> <tr> <td>subtotal</td> <td>x = 3 359.50</td> <td>7.083</td> </tr> <tr> <td>subtotal</td> <td>x = 3 602.25</td> <td>9.719</td> </tr> <tr> <td>subtotal</td> <td>x = 4 368.80</td> <td>7.271</td> </tr> <tr> <td>subtotal</td> <td>x = 4 932.75</td> <td>127</td> </tr> <tr> <td>subtotal</td> <td>x = 5 539.50</td> <td>125</td> </tr> <tr> <td>subtotal</td> <td>x = 6 252.35</td> <td>72</td> </tr> <tr> <td>subtotal</td> <td>x = 6 831.90</td> <td>135</td> </tr> <tr> <td>subtotal</td> <td>x = 7 670.75</td> <td>90</td> </tr> <tr> <td>subtotal</td> <td>x = 8 732.50</td> <td>153</td> </tr> <tr> <td>subtotal</td> <td>x = 9 758.25</td> <td>05</td> </tr> <tr> <td>subtotal</td> <td>x = 10 254.25</td> <td>220</td> </tr> <tr> <td>subtotal</td> <td>x = 11 053.75</td> <td>56</td> </tr> <tr> <td>subtotal</td> <td>x = 11 622.75</td> <td>97</td> </tr> <tr> <td>subtotal</td> <td>x = 12 040.25</td> <td>134</td> </tr> </tbody> </table> Figure 4 – An example of how Spotfire Analytics disregards traditional definitions of “dimensions” and “measures”. The vertical and horizontal axes of this cross table come from Sales and Profit attributes respectively which are continuous numeric values. Traditionally these would be “measures” and could not be used on a cross table, but the Spotfire interface allows one to dynamically bin these values into groups. The values in the cross table cells are the computed average Discount for each pair of these dynamically determined “dimensions”. In-memory Analytical Systems: Perspective, Trade-offs and Implementation Figure 5 – Another example of how Spotfire Analytics disregards traditional definitions of “dimensions” and “measures”. The x-axis of this scatter plot is set to the names of customers, which is a categorical value. Spotfire plots are flexible in allowing dimensions or measures to drive the axes of its visuals. Spotfire Analytics users are very happy with this capability. Many analytical systems are relatively static. You create a set of data, wait for it to aggregate and then perform the analysis. If you want to add more data, you essentially have to recompile the set for analysis. Spotfire software lets you add data on the fly. 3. The ability to swap out to disk If you do have more data than can be held cost effectively in-memory, then Spotfire can load data on-demand into memory from a peta-byte data store. The company’s decade of experience has taught it to provide practical solutions to these problems and its On-Demand feature enable users to visually query and load portions of very large data stores into memory as needed. So, Spotfire Analytics also pages intelligently from memory to disc to make sure active users get the memory performance. Inevitably there are limitations to in-memory systems – to claim otherwise is ridiculous in engineering terms. The question isn’t “How do we pretend that this isn’t a restriction?”, the question is “How do we deal with the limitations?” Spotfire Analytics strives to deal with them elegantly. Summary In-memory analytics open up new possibilities that result from the huge performance gain that in-memory offers. Those possibilities are not just in the raw speed of serving data to the user but, even more important, in simplifying models for analyzing data, provide more interactive interfaces and reducing overall solution latency. About the Authors Dr. Mark Whitehorn specializes in the areas of databases, data analysis, data modelling, data warehousing and business intelligence (BI). Mark is an author, academic researcher (at Cambridge and Dundee Universities) lecturer and works with national and international companies, designing databases and BI systems. In this paper, the sections that he wrote encompassed the following: - Introduction - Trade-offs: In-memory vs Disk-based Approaches - Overview of the Different In-memory Approaches Lars Bauerle is VP Product Strategy at TIBCO. In this paper, the sections that he wrote encompassed the following: - Benefits of the Spotfire Approach - Summary
{"Source-Url": "https://www.tibco.com/sites/tibco/files/resources/in-memory.pdf", "len_cl100k_base": 5902, "olmocr-version": "0.1.50", "pdf-total-pages": 15, "total-fallback-pages": 0, "total-input-tokens": 27532, "total-output-tokens": 6414, "length": "2e12", "weborganizer": {"__label__adult": 0.0003249645233154297, "__label__art_design": 0.0005927085876464844, "__label__crime_law": 0.0005154609680175781, "__label__education_jobs": 0.0010499954223632812, "__label__entertainment": 9.72747802734375e-05, "__label__fashion_beauty": 0.00020194053649902344, "__label__finance_business": 0.006641387939453125, "__label__food_dining": 0.0003726482391357422, "__label__games": 0.0005474090576171875, "__label__hardware": 0.0022029876708984375, "__label__health": 0.0004470348358154297, "__label__history": 0.0002777576446533203, "__label__home_hobbies": 0.00014162063598632812, "__label__industrial": 0.0015850067138671875, "__label__literature": 0.0002567768096923828, "__label__politics": 0.00027251243591308594, "__label__religion": 0.00033593177795410156, "__label__science_tech": 0.10443115234375, "__label__social_life": 0.0001112818717956543, "__label__software": 0.239013671875, "__label__software_dev": 0.6396484375, "__label__sports_fitness": 0.00026798248291015625, "__label__transportation": 0.0006237030029296875, "__label__travel": 0.0001938343048095703}, "weborganizer_max": "__label__software_dev", "avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_ratio": [[0, 26912, 0.03205]], "fineweb_edu_fasttext_gt2__fineweb_edu_fasttext_gt2__score": [[0, 26912, 0.46386]], "ft_lang_id_en_doc_v2__ft_lang_id_en_doc_v2__en": [[0, 26912, 0.94565]], "google_gemma-3-12b-it_contains_pii": [[0, 73, false], [73, 708, null], [708, 3300, null], [3300, 5244, null], [5244, 7826, null], [7826, 9802, null], [9802, 10746, null], [10746, 11918, null], [11918, 14226, null], [14226, 16409, null], [16409, 19022, null], [19022, 21625, null], [21625, 24430, null], [24430, 25599, null], [25599, 26912, null]], "google_gemma-3-12b-it_is_public_document": [[0, 73, true], [73, 708, null], [708, 3300, null], [3300, 5244, null], [5244, 7826, null], [7826, 9802, null], [9802, 10746, null], [10746, 11918, null], [11918, 14226, null], [14226, 16409, null], [16409, 19022, null], [19022, 21625, null], [21625, 24430, null], [24430, 25599, null], [25599, 26912, null]], "google_gemma-3-4b-it_v2tag__is_academic_paper": [[0, 5000, true], [5000, 26912, null]], "google_gemma-3-4b-it_v2tag__is_class_syllabus": [[0, 5000, false], [5000, 26912, null]], "google_gemma-3-4b-it_v2tag__is_completion_certificate": [[0, 5000, false], [5000, 26912, null]], "google_gemma-3-4b-it_v2tag__is_court_notice": [[0, 5000, false], [5000, 26912, null]], "google_gemma-3-4b-it_v2tag__is_homework_assignment": [[0, 5000, false], [5000, 26912, null]], "google_gemma-3-4b-it_v2tag__is_news_article": [[0, 5000, false], [5000, 26912, null]], "google_gemma-3-4b-it_v2tag__is_public_order": [[0, 5000, false], [5000, 26912, null]], "google_gemma-3-4b-it_v2tag__is_resume_cv": [[0, 5000, false], [5000, 26912, null]], "google_gemma-3-4b-it_v2tag__is_test_or_quiz": [[0, 5000, false], [5000, 26912, null]], "google_gemma-3-4b-it_v2tag__is_textbook": [[0, 5000, false], [5000, 26912, null]], "pdf_page_numbers": [[0, 73, 1], [73, 708, 2], [708, 3300, 3], [3300, 5244, 4], [5244, 7826, 5], [7826, 9802, 6], [9802, 10746, 7], [10746, 11918, 8], [11918, 14226, 9], [14226, 16409, 10], [16409, 19022, 11], [19022, 21625, 12], [21625, 24430, 13], [24430, 25599, 14], [25599, 26912, 15]], "pipe_delimited_lines_v1__pipe_delimited_lines_v1__pipe_delimited_lines_ratio": [[0, 26912, 0.15441]]}
olmocr_science_pdfs
2024-12-01
2024-12-01
3c7ddef53df4d918fee1a9c2d2af2ee3713d8d20
Analysis and Optimization of the Memory Access Behavior of Applications Ecole “Méthodologie et outils d’optimisation en développement logiciel” Fréjus, February 8, 2012 Josef Weidendorfer Chair for Computer Architecture (LRR) TUM, Munich, Germany Fakultät für Informatik der Technischen Universität München Informatik X: Rechnertechnik und Rechnerorganisation / Parallelrechnerarchitektur Prof. Dr. Arndt Bode, Prof. Dr. Hans Michael Gerndt My Background • Chair for computer architecture at CS faculty, TUM – how to exploit current & future (HPC) systems (multicore, accelerators) – programming models, performance analysis tools, application tuning • PhD on load balancing of commercial car crash code (MPI) 2003 • Interested especially in cache analysis and optimization – cache simulation: Callgrind (using Valgrind) – applied to 2D/3D stencil codes – recently extended to multicore (new bottlenecks, new benefits) • Invited by Romaric David to give a talk at this workshop Topic of this Morning: Bottleneck Memory - Why should you care about memory performance? - Most (HPC) applications often do memory accesses - Good vs. bad use of the memory hierarchy can be ~ factor 100 (!) - Example: modern processor with 3GHz clock rate, 2 sockets - latency to remote socket ~ 100 ns: 300 clock ticks - bandwidth (1 core) ~ 15 GB/s - compare to L1 access: latency 2-3 ticks, bandwidth ~150GB/s - Bad memory performance easily can dominate performance (better memory performance also will speed up parallel code) Topic of this Morning: Bottleneck Memory Still getting more important • compute power on one chip still increases • main memory latency will stay (off-chip distance) • bandwidth increases, but not as much as compute power ⇒ Memory Wall (stated already in 1994) In addition: • with multi-core, cores share connection to main memory! The Memory Wall CPU Peak Performance (clock & cores) + 40% / year Main Memory Performance + 7% / year Access latency to main memory today up to 300 cycles Assume 2 Flops/clock ticks ➔ 600 Flops wasted while waiting for one main memory access! Topic of this Morning: Bottleneck Memory - Further getting more important not only for performance, but for problem no.1 in the future: power consumption (Power Wall) - reason that we have multi-core today - most significant cost factor for compute centers in the future - users not to be charged by hours, but by energy consumption? - Comparison computation vs. memory access [Dongarra, PPAM 2011] - today: for 1 memory access saved, can do 48 FMAs more 2018: 192 FMAs more - solution (?): do redundant calculation to avoid memory access Outline: Part 1 The Memory Hierarchy Caches: Why & How do they work? Bad Memory Access Patterns How to not exploit Caches Cache Optimization Strategies How to exploit Caches even better Outline: Part 2 Cache Analysis Measuring on real Hardware vs. Simulation Cache Analysis Tools Case Studies Hands-on The Memory Hierarchy Two facts of modern computer systems • processor cores are quite fast • main memory is quite slow Why? Different design goals • everybody wants a fast processor • everybody wants large amounts of cheap memory Why is this not a contradiction? There is a solution to bridge the gap: • a hierarchy of buffers between processor and main memory • often effective, and gives seemingly fast and large memory Solution: The Memory Hierarchy We can build very fast memory (for a processor), but - it has to be small (only small number of cascading gates) - tradeoff: buffer size vs. buffer speed - it has to be near (where data is to be used) - on-chip, not much space around execution units - it will be quite expensive (for its size) - SRAM needs a lot more energy and space than DRAM ➤ use fast memory only for data most relevant to performance ➤ if less relevant, we can afford slower access, allowing more space ➤ this works especially well if “most relevant data” fits into fast buffer Solution: The Memory Hierarchy <table> <thead> <tr> <th>Size</th> <th>Latency</th> <th>Bandwidth</th> </tr> </thead> <tbody> <tr> <td>300 B</td> <td>1</td> <td></td> </tr> <tr> <td>32 kB</td> <td>3</td> <td>100 GB/s</td> </tr> <tr> <td>4 MB</td> <td>20</td> <td>30 GB/s</td> </tr> <tr> <td>4 GB</td> <td>200</td> <td>15 GB/s</td> </tr> <tr> <td>4 GB</td> <td>300</td> <td>10 GB/s</td> </tr> <tr> <td>1 TB</td> <td>&gt; 10^7</td> <td>0.2 GB/s</td> </tr> </tbody> </table> Solution: The Memory Hierarchy Programmers want memory to be a flat space • registers not visible, used by compilers • on-chip buffers are – not explicitly accessed, but automatically filled from lower levels – indexed by main memory address – hold copies of blocks of main memory ➔ not visible to programmers: caches • transparent remote memory access provided by hardware • extension on I/O devices by MMU & OS Let’s concentrate on Processor Caches… Solution: Processor Caches Why are Caches effective? Because typical programs • often access same memory cells repeatedly – temporal locality \(\Rightarrow\) good to keep recent accessed data in cache • often access memory cells near recent accesses – spatial locality \(\Rightarrow\) good to work on blocks of nearside data (cache line) “Principle of Locality” So what’s about the Memory Wall? • the degree of “locality” depends on the application • at same locality, the widening gap between processor and memory performance reduces cache effectiveness Example: Sequence with 10 Accesses - memory latency: 3 - cache latency: 1 - without cache: 30 - cache exploiting temporal locality: 22 (6 misses, 4 hits) - cache exploiting temporal and spatial locality: 16 (3 misses, 7 hits) Basic Cache Properties (1) - Cache holds copies of memory blocks - space for one copy called “cache line” \(\rightarrow\) **Cache Line Size** - transfers from/to main memory always at line size granularity - Cache has restricted size: **Cache Size** - line size 2, cache size 6 (= 3 lines) - line size 2, cache size 4 (=2 lines) - Which copy to evict for new copy - **Replacement Policy** - Typically: Evict Least Recently Used (LRU) Basic Cache Properties (2) - every cache line knows the memory address it has a copy of („tag“) - comparing all tags at every access ➞ expensive (space & energy) - better: reduce number of comparisons per access - group cache lines into sets - a given address can only be stored into a given set - lines per set: **Associativity** - example: 2 lines ( ), sequence 1/3/1/3/2/4/2/4 Solution: Processor Caches The “Principle of Locality” makes caches effective - How to improve on that? - Try to further reduce misses! Options - increase cache line size! - can reduce cache effectiveness, if not all bytes are accessed - predict future accesses (hardware prefetcher), load before use - example: stride detectors (more effective if keyed by instruction) - allows “burst accesses” with higher netto bandwidth - only works if bandwidth not exploited anyway (demand vs. speculative) - can increase misses if prefetching is too aggressive The Memory Hierarchy on Multi-Core Principle of Locality often holds true across multiple threads • example: threads need same vectors/matrices • caches shared among cores can be beneficial • sharing allows threads to prefetch data for each other However, if threads work on different data… • example: disjunct partitioning of data among threads • threads compete for space, evict data of each other • trade-off: only use cache sharing on largest on-chip buffer The Memory Hierarchy on Multi-Core Typical example (modern Intel / AMD processors) Why are there 3 levels? • cache sharing increases on-chip bandwidth demands by cores • L1 is very small to be very fast ➔ still lots of references to L2 • private L2 caches reduce bandwidth demands for shared L3 Caches and Multi-Processor Systems The Cache Coherence Problem • suppose 2 processors/cores with private caches at same level • P1 reads a memory block X • P2 writes to the block X • P1 again reads from block X (which now is invalid!) A strategy is needed to keep caches coherent • writing to X by P2 needs to invalidate or update copy of X in P1 • cache coherence protocol • all current multi-socket/-core systems have fully automatic cache coherence in hardware (today already a significant overhead!) Outline: Part 1 The Memory Hierarchy Caches: Why & How do they work? Bad Memory Access Patterns How to not exploit Caches Cache Optimization Strategies How to exploit Caches even better Memory Access Behavior How to characterize good memory access behavior? **Cache Hit Ratio** - percentage of accesses which was served by the cache - good ratio: > 97% Symptoms of bad memory access: Cache Misses Let’s assume that we can not change the hardware as countermeasure for cache misses (e.g. enlarging cache size) Memory Access Behavior: Cache Misses Classification: • **cold / compulsory** miss – first time a memory block was accessed • **capacity** miss – recent copy was evicted because of too small cache size • **conflict** miss – recent copy was evicted because of too low associativity • **concurrency** miss – recent copy was evicted because of invalidation by cache coherence protocol • **prefetch inaccuracy** miss – recent copy was evicted because of aggressive/imprecise prefetching Bad Memory Access Behavior (1) Lots of cold misses - Each memory block only accessed once, and - Prefetching not effective because accesses are not predictable or bandwidth is fully used - Usually not important, as programs access data multiple times - Can become relevant if there are lots of context switches (when multiple processes synchronize very often) - L1 gets flushed because virtual addresses get invalid Bad Memory Access Behavior (2) Lots of capacity misses • blocks are only accessed again after eviction due to limited size – number of other blocks accessed in-between (= reuse distance) > number of cache lines – example: sequential access to data structure larger than cache size • and prefetching not effective Countermeasures • reduce reuse distance of accesses = increase temporal locality • improve utilization inside cache lines = increase spatial locality • do not share cache among threads accessing different data • increase predictability of memory accesses Bad Memory Access Behavior (3) Lots of conflict misses - blocks are only accessed again after eviction due to limited set size - example: - matrix where same column in multiple rows map to same set - we do a column-wise sweep ![Diagram showing memory blocks assigned to different sets.](image) Bad Memory Access Behavior (3) Lots of conflict misses • blocks are only accessed again after eviction due to limited set size Countermeasures • set sizes are similar to cache sizes: see last slide… • make successive accesses cross multiple sets Bad Memory Access Behavior (4) Lots of concurrency misses • lots of conflicting accesses to same memory blocks by multiple processors/cores, which use private caches – “conflicting access”: at least one processor is writing Two variants: same block is used • because processors access same data • even though different data are accessed, the data resides in same block (= false sharing) – example: threads often write to nearside data (e.g. using OpenMP dynamic scheduling) Bad Memory Access Behavior (4) Lots of concurrency misses - lots of conflicting accesses to same memory blocks by multiple processors/cores, which use private caches Countermeasures - reduce frequency of accesses to same block by multiple threads - move data structures such that data accessed by different threads reside on their own cache lines - place threads to use a shared cache Bad Memory Access Behavior (5) Lots of prefetch inaccuracy misses - much useful data gets evicted due to misleading access patterns - example: prefetchers typically “detect” stride pattern after 3-5 regular accesses, prefetching with distance 3-5 - frequent sequential accesses to very small ranges (5-10 elements) of data structures Countermeasures - use longer access sequences with strides - change data structure if an access sequence accidently looks like a stride access Memory Access Behavior: Cache Misses Classifications: - kind of misses - each cache miss needs another line to be evicted: is the previous line modified (= dirty) or not? - yes: needs write-back to memory - increases memory access latency Outline: Part 1 The Memory Hierarchy - Caches: Why & How do they work? Bad Memory Access Patterns - How to not exploit Caches Cache Optimization Strategies - How to exploit Caches even better The Principle of Locality is not enough... Reasons for Performance Loss for SPEC2000 [Beyls/Hollander, ICCS 2004] Basic efficiency guidelines Always use a performance analysis tool before doing optimizations: How much time is wasted where because of cache misses? 1. Choose the best algorithm 2. Use efficient libraries 3. Find good compiler and options (“-O3”, “-fno-alias” …) 4. Reorder memory accesses 5. Use suitable data layout 6. Prefetch data Cache Optimizations Warning: Conflict and capacity misses are not easy to distinguish… Cache Optimization Strategies: Reordering Accesses - **Blocking**: make arrays fit into a cache Cache Optimization Strategies: Reordering Accesses - Blocking: make arrays fit into a cache - Blocking in multiple dimensions (example: 2D) Cache Optimization Strategies: Reordering Accesses - Blocking: make arrays fit into a cache - Blocking in multiple dimensions (example: 2D) - Nested blocking: tune to multiple cache levels - can be done recursively according to a space filling curve - example: Morton curve (without “jumps”: Hilbert, Peano…) - cache-oblivious orderings/algorithms (= automatically fit to varying levels and sizes using the same code) Cache Optimization Strategies: Reordering Accesses - Extreme blocking with size 1: Interweaving - combined with blocking in other dimensions, results in pipeline patterns - On multi-core: consecutive iterations on cores with shared cache - Block Skewing: Change traversal order over non-rectangular shapes - For all reorderings: preserve data dependencies of algorithm! Cache Optimization Strategies: Suitable Data Layout Strive for best spatial locality • use compact data structures (arrays are almost always better than linked lists!) • data accessed at the same time should be packed together • avoid putting frequent and rarely used data packed together • object-oriented programming – try to avoid indirections – bad: frequent access of only one field of a huge number of objects – use proxy objects, and structs of arrays instead of arrays of structs • best layout can change between different program phases – do format conversion if accesses can become more cache friendly – (also can be important to allow for vectorization) Cache Optimization Strategies: Prefetching Allow hardware prefetcher to help loading data as much as possible • make sequence of memory accesses predictable – prefetchers can detect multiple streams at the same time (>10) • arrange your data accordingly in memory • avoid non-predictable, random access sequences – pointer-based data structures without control on allocation of nodes – hash tables accesses Software controlled prefetching (difficult !) • switch between block prefetching & computation phases • do prefetching in another thread / core („helper thread“) Countermeasures for Capacity Misses Reduce reuse distance of accesses = increase temporal locality Strategy: • blocking Effectiveness can be seen by • reduced number of misses • in reuse distance histogram (needs cache simulator) Countermeasures for Capacity Misses Improve utilization inside cache lines = increase spatial locality Strategy: • improve data layout Effectiveness can be seen by • reduced number of misses • spatial loss metric (needs cache simulator) – counts number of bytes fetched to a given cache level but never actually used before evicted again • spatial access homogeneity (needs cache simulator) – variance among number of accesses to bytes inside of a cache line Countermeasures for Capacity Misses Do not share cache among threads accessing different data Strategy: - explicitly assign threads to cores - “sched_setaffinity” (automatic system-level tool: autopin) Effectiveness can be seen by - reduced number of misses Countermeasures for Capacity Misses Increase predictability of memory accesses Strategy: • improve data layout • reorder accesses Effectiveness can be seen by • reduced number of misses • performance counter for hardware prefetcher • run cache simulation with/without prefetcher simulation Countermeasures for Conflict Misses Make successive accesses cross multiple cache sets Strategy: • change data layout by Padding • reorder accesses Effectiveness can be seen by • reduced number of misses Countermeasures for Concurrency Misses Reduce frequency of accesses to same block by multiple threads Strategy: • for true data sharing: do reductions by partial results per thread • for false sharing (reduce frequency to zero = data accessed by different threads reside on their own cache lines) – change data layout by padding (always possible) – change scheduling (e.g. increase OpenMP chunk size) Effectiveness can be seen by • reduced number of concurrency misses (there is a perf. counter) Countermeasures for Misses triggering Write-Back Only general rule: • Try to avoid writing if not needed Sieve of Eratosthenes: \begin{verbatim} isPrim[*] = 1; for(i=2; i<n/2; i++) if (isPrim[i] == 1) for(j=2*i; i<n; j+=i) isPrim[j] = 0; \end{verbatim} ~ 2x faster (!): \begin{verbatim} isPrim[*] = 1; for(i=2; i<n/2; i++) if (isPrim[i] == 1) for(j=2*i; i<n; j+=i) if (isPrim[j]==1) isPrim[j] = 0; \end{verbatim} Outline: Part 2 Cache Analysis Measuring on real Hardware vs. Simulation Cache Analysis Tools Case Studies Hands-on Sequential Performance Analysis Tools Count occurrences of events • resource exploitation is related to events • SW-related: function call, OS scheduling, ... • HW-related: FLOP executed, memory access, cache miss, time spent for an activity (like running an instruction) Relate events to source code • find code regions where most time is spent • check for improvement after changes • „Profile“: histogram of events happening at given code positions • inclusive vs. exclusive cost How to measure Events (1) Where? • on real hardware – needs sensors for interesting events – for low overhead: hardware support for event counting – difficult to understand because of unknown micro-architecture, overlapping and asynchronous execution • using machine model – events generated by a simulation of a (simplified) hardware model – no measurement overhead: allows for sophisticated online processing – simple models relatively easy to understand Both methods have pro & contra, but reality matters in the end How to measure Events (2) SW-related - instrumentation (= insertion of measurement code) - into OS / application, manual/automatic, on source/binary level - on real HW: always incurs overhead which is difficult to estimate HW-related - read Hardware Performance Counters - gives exact event counts for code ranges - needs instrumentation - statistical: **Sampling** - event distribution over code approximated by every N-th event - HW notifies only about every N-th event \(\Rightarrow\) Influence tunable by N Outline: Part 2 Cache Analysis Measuring on real Hardware vs. Simulation Cache Analysis Tools Case Studies Hands-on Analysis Tools - **GProf** - Instrumentation by compiler for call relationships & call counts - Statistical time sampling using timers - Pro: available almost everywhere (gcc: -pg) - Contra: recompilation, measurement overhead, heuristic - **Intel VTune (Sampling mode) / Linux Perf (>2.6.31)** - Sampling using hardware performance counters, no instrumentation - Pro: minimal overhead, detailed counter analysis possible - Contra: call relationship can not be collected (this is not about call stack sampling: provides better context…) - **Callgrind**: machine model simulation Callgrind: Basic Features Based on Valgrind - runtime instrumentation infrastructure (no recompilation needed) - dynamic binary translation of user-level processes - Linux/AIX/OS X on x86, x86-64, PPC32/64, ARM - correctness checking & profiling tools on top - “memcheck”: accessibility/validity of memory accesses - “helgrind” / ”drd”: race detection on multithreaded code - “cache-grind”/”callgrind”: cache & branch prediction simulation - “massif”: memory profiling - Open source (GPL), www.valgrind.org Callgrind: Basic Features Measurement - profiling via machine simulation (simple cache model) - instruments memory accesses to feed cache simulator - hook into call/return instructions, thread switches, signal handlers - instruments (conditional) jumps for CFG inside of functions Presentation of results - callgrind_annotate - \{Q,K\}Cachegrind Pro & Contra (i.e. Simulation vs. Real Measurement) Usage of Valgrind - driven only by user-level instructions of one process - slowdown (call-graph tracing: 15-20x, + cache simulation: 40-60x) - “fast-forward mode”: 2-3x - allows detailed (mostly reproducable) observation - does not need root access / can not crash machine Cache model - “not reality”: synchronous 2-level inclusive cache hierarchy (size/associativity taken from real machine, always including LLC) - easy to understand / reconstruct for user - reproducible results independent on real machine load - derived optimizations applicable for most architectures Callgrind: Usage - `valgrind -tool=callgrind [callgrind options] yourprogram args` - `cache simulator: --cache-sim=yes` - `branch prediction simulation (since VG 3.6): --branch-sim=yes` - `enable for machine code annotation: --dump-instr=yes` - `start in “fast-forward”: --instr-atstart=yes` - switch on event collection: `callgrind_control -i on/ Macro` - `spontaneous dump: callgrind_control -d [dump identification]` - `current backtrace of threads (interactive): callgrind_control -b` - `separate dumps per thread: --separate-threads=yes` - `cache line utilization: --cacheuse=yes` - `enable prefetcher simulation: --simulate-hwpref=yes` - `jump-tracing in functions (CFG): --collect-jumps=yes` KCacheGrind: Features - open source, GPL, kcachegrind.sf.net - included with KDE3 & KDE4 Visualization of - call relationship of functions (callers, callees, call graph) - exclusive/Inclusive cost metrics of functions - grouping according to ELF object / source file / C++ class - source/assembly annotation: costs + CFG - arbitrary events counts + specification of derived events Callgrind support (file format, events of cache model) KCacheGrind: Usage \{k,q\} cachegrind callgrind.out.<pid> - left: “Dockables” - list of function groups according to - library (ELF object) - source - class (C++) - list of functions with - inclusive - exclusive costs - right: visualization panes Visualization panes for selected function - List of event types - List of callers/callees - Treemap visualization - Call Graph - Source annotation - Assemly annotation Weidendorfer: Memory Access Analysis and Optimization Outline: Part 2 Cache Analysis Measuring on real Hardware vs. Simulation Cache Analysis Tools Case Studies Hands-on Case Studies - Get ready for hands-on - matrix multiplication - 2D relaxation Matrix Multiplication - Kernel for $C = A \times B$ - Side length $N \Rightarrow N^3$ multiplications + $N^3$ additions \[ c[k][i] = a[k][j] \times b[j][i] \] Matrix Multiplication - Kernel for $C = A \times B$ - 3 nested loops $(i,j,k)$: What is the best index order? Why? ``` for (i=0; i<N; i++) for (j=0; j<N; j++) for (k=0; k<N; k++) c[k][i] = a[k][j] * b[j][i] ``` - blocking for all 3 indexes, block size $B$, $N$ multiple of $B$ ``` for (i=0; i<N; i+=B) for (j=0; j<N; j+=B) for (k=0; k<N; k+=B) for (ii=i; ii<i+B; ii++) for (jj=j; jj<j+B; jj++) for (kk=k; kk<k+B; kk++) c[k+kk][i+ii] = a[k+kk][j+jj] * b[j+jj][i+ii] ``` Iterative Solver for PDEs: 2D Jacobi Relaxation Example: Poisson One iteration: ```c for (i=1; i<N-1; i++) for (j=1; j<N-1; j++) u2[i][j] = ( u[i-1][j] + u[i][j-1] + u[i+1][j] + u[i][j+1] ) / 4.0; u[*][*] = u2[*][*]; ``` Optimization: Interleave 2 iterations - iteration 1 for row 1 - iteration 1 for row 2, iteration 2 for row 1 - iteration 1 for row 3, iteration 2 for row 2 - ... Outline: Part 2 Cache Analysis Measuring on real Hardware vs. Simulation Cache Analysis Tools Case Studies Hands-on How to run with MPI • Run valgrind with mpirun (bt-mz: example from NAS) ```sh export OMP_NUM_THREADS=4 mpirun -np 4 valgrind --tool=callgrind --cache-sim=yes \ --separate-threads=yes ./bt-mz_B.4 ``` • load all profile dumps at once: – run in new directory, “qcachegrind callgrind.out” Getting started / Matrix Multiplication / Jacobi • Try it out yourself (on intelnode) “cp -r /srv/app/kcachegrind/kcg-examples .” example exercises are in “exercises.txt” • What happens in „/bin/ls“? – valgrind --tool=callgrind ls /usr/bin – qcachegrind – What function takes most instruction executions? Purpose? – Where is the main function? – Now run with cache simulation: --cache-sim=yes
{"Source-Url": "https://calcul.math.cnrs.fr/attachments/spip/IMG/pdf/Valgrind_weidendorfer.pdf", "len_cl100k_base": 6325, "olmocr-version": "0.1.53", "pdf-total-pages": 70, "total-fallback-pages": 0, "total-input-tokens": 106165, "total-output-tokens": 9003, "length": "2e12", "weborganizer": {"__label__adult": 0.0005059242248535156, "__label__art_design": 0.0010156631469726562, "__label__crime_law": 0.000530242919921875, "__label__education_jobs": 0.0018033981323242188, "__label__entertainment": 0.00014007091522216797, "__label__fashion_beauty": 0.0002675056457519531, "__label__finance_business": 0.0002868175506591797, "__label__food_dining": 0.0005240440368652344, "__label__games": 0.0009212493896484376, "__label__hardware": 0.01141357421875, "__label__health": 0.0007395744323730469, "__label__history": 0.0005526542663574219, "__label__home_hobbies": 0.00022161006927490232, "__label__industrial": 0.0015020370483398438, "__label__literature": 0.0002713203430175781, "__label__politics": 0.0004818439483642578, "__label__religion": 0.0009622573852539062, "__label__science_tech": 0.30078125, "__label__social_life": 0.0001252889633178711, "__label__software": 0.007843017578125, "__label__software_dev": 0.6669921875, "__label__sports_fitness": 0.0005879402160644531, "__label__transportation": 0.0012369155883789062, "__label__travel": 0.00029397010803222656}, "weborganizer_max": "__label__software_dev", "avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_ratio": [[0, 25717, 0.01332]], "fineweb_edu_fasttext_gt2__fineweb_edu_fasttext_gt2__score": [[0, 25717, 0.29379]], "ft_lang_id_en_doc_v2__ft_lang_id_en_doc_v2__en": [[0, 25717, 0.81137]], "google_gemma-3-12b-it_contains_pii": [[0, 444, false], [444, 992, null], [992, 1530, null], [1530, 1864, null], [1864, 2110, null], [2110, 2776, null], [2776, 2974, null], [2974, 3097, null], [3097, 3522, null], [3522, 4112, null], [4112, 4408, null], [4408, 4869, null], [4869, 5431, null], [5431, 5658, null], [5658, 6105, null], [6105, 6492, null], [6492, 7055, null], [7055, 7519, null], [7519, 7816, null], [7816, 8324, null], [8324, 8522, null], [8522, 8850, null], [8850, 9348, null], [9348, 9768, null], [9768, 10342, null], [10342, 10643, null], [10643, 10891, null], [10891, 11375, null], [11375, 11764, null], [11764, 12247, null], [12247, 12491, null], [12491, 12686, null], [12686, 12801, null], [12801, 13228, null], [13228, 13325, null], [13325, 13466, null], [13466, 13939, null], [13939, 14318, null], [14318, 14997, null], [14997, 15574, null], [15574, 15807, null], [15807, 16273, null], [16273, 16534, null], [16534, 16827, null], [16827, 17034, null], [17034, 17539, null], [17539, 18007, null], [18007, 18129, null], [18129, 18615, null], [18615, 19151, null], [19151, 19676, null], [19676, 19798, null], [19798, 20398, null], [20398, 20917, null], [20917, 21267, null], [21267, 21909, null], [21909, 22611, null], [22611, 23052, null], [23052, 23326, null], [23326, 23495, null], [23495, 23549, null], [23549, 23671, null], [23671, 23754, null], [23754, 23917, null], [23917, 24478, null], [24478, 24879, null], [24879, 25001, null], [25001, 25308, null], [25308, 25717, null], [25717, 25717, null]], "google_gemma-3-12b-it_is_public_document": [[0, 444, true], [444, 992, null], [992, 1530, null], [1530, 1864, null], [1864, 2110, null], [2110, 2776, null], [2776, 2974, null], [2974, 3097, null], [3097, 3522, null], [3522, 4112, null], [4112, 4408, null], [4408, 4869, null], [4869, 5431, null], [5431, 5658, null], [5658, 6105, null], [6105, 6492, null], [6492, 7055, null], [7055, 7519, null], [7519, 7816, null], [7816, 8324, null], [8324, 8522, null], [8522, 8850, null], [8850, 9348, null], [9348, 9768, null], [9768, 10342, null], [10342, 10643, null], [10643, 10891, null], [10891, 11375, null], [11375, 11764, null], [11764, 12247, null], [12247, 12491, null], [12491, 12686, null], [12686, 12801, null], [12801, 13228, null], [13228, 13325, null], [13325, 13466, null], [13466, 13939, null], [13939, 14318, null], [14318, 14997, null], [14997, 15574, null], [15574, 15807, null], [15807, 16273, null], [16273, 16534, null], [16534, 16827, null], [16827, 17034, null], [17034, 17539, null], [17539, 18007, null], [18007, 18129, null], [18129, 18615, null], [18615, 19151, null], [19151, 19676, null], [19676, 19798, null], [19798, 20398, null], [20398, 20917, null], [20917, 21267, null], [21267, 21909, null], [21909, 22611, null], [22611, 23052, null], [23052, 23326, null], [23326, 23495, null], [23495, 23549, null], [23549, 23671, null], [23671, 23754, null], [23754, 23917, null], [23917, 24478, null], [24478, 24879, null], [24879, 25001, null], [25001, 25308, null], [25308, 25717, null], [25717, 25717, null]], "google_gemma-3-4b-it_v2tag__is_academic_paper": [[0, 5000, true], [5000, 25717, null]], "google_gemma-3-4b-it_v2tag__is_class_syllabus": [[0, 5000, false], [5000, 25717, null]], "google_gemma-3-4b-it_v2tag__is_completion_certificate": [[0, 5000, false], [5000, 25717, null]], "google_gemma-3-4b-it_v2tag__is_court_notice": [[0, 5000, false], [5000, 25717, null]], "google_gemma-3-4b-it_v2tag__is_homework_assignment": [[0, 5000, false], [5000, 25717, null]], "google_gemma-3-4b-it_v2tag__is_news_article": [[0, 5000, false], [5000, 25717, null]], "google_gemma-3-4b-it_v2tag__is_public_order": [[0, 5000, false], [5000, 25717, null]], "google_gemma-3-4b-it_v2tag__is_resume_cv": [[0, 5000, false], [5000, 25717, null]], "google_gemma-3-4b-it_v2tag__is_test_or_quiz": [[0, 5000, false], [5000, 25717, null]], "google_gemma-3-4b-it_v2tag__is_textbook": [[0, 5000, false], [5000, 25717, null]], "pdf_page_numbers": [[0, 444, 1], [444, 992, 2], [992, 1530, 3], [1530, 1864, 4], [1864, 2110, 5], [2110, 2776, 6], [2776, 2974, 7], [2974, 3097, 8], [3097, 3522, 9], [3522, 4112, 10], [4112, 4408, 11], [4408, 4869, 12], [4869, 5431, 13], [5431, 5658, 14], [5658, 6105, 15], [6105, 6492, 16], [6492, 7055, 17], [7055, 7519, 18], [7519, 7816, 19], [7816, 8324, 20], [8324, 8522, 21], [8522, 8850, 22], [8850, 9348, 23], [9348, 9768, 24], [9768, 10342, 25], [10342, 10643, 26], [10643, 10891, 27], [10891, 11375, 28], [11375, 11764, 29], [11764, 12247, 30], [12247, 12491, 31], [12491, 12686, 32], [12686, 12801, 33], [12801, 13228, 34], [13228, 13325, 35], [13325, 13466, 36], [13466, 13939, 37], [13939, 14318, 38], [14318, 14997, 39], [14997, 15574, 40], [15574, 15807, 41], [15807, 16273, 42], [16273, 16534, 43], [16534, 16827, 44], [16827, 17034, 45], [17034, 17539, 46], [17539, 18007, 47], [18007, 18129, 48], [18129, 18615, 49], [18615, 19151, 50], [19151, 19676, 51], [19676, 19798, 52], [19798, 20398, 53], [20398, 20917, 54], [20917, 21267, 55], [21267, 21909, 56], [21909, 22611, 57], [22611, 23052, 58], [23052, 23326, 59], [23326, 23495, 60], [23495, 23549, 61], [23549, 23671, 62], [23671, 23754, 63], [23754, 23917, 64], [23917, 24478, 65], [24478, 24879, 66], [24879, 25001, 67], [25001, 25308, 68], [25308, 25717, 69], [25717, 25717, 70]], "pipe_delimited_lines_v1__pipe_delimited_lines_v1__pipe_delimited_lines_ratio": [[0, 25717, 0.01318]]}
olmocr_science_pdfs
2024-12-07
2024-12-07
07216f337dcb40fbef303b20a2a9c35c8addd568
INSPIRE KEN Follow-Up Webinar on Coverages & WCS Peter Baumann Jacobs University | rasdaman GmbH baumann@rasdaman.com Overview - Part 1: Coverages / WCS Recap - Part 2: The New Coverage Implementation Schema - Part 3: Q&A Part 1: Coverages / WCS Recap Collecting Coverages sensor feeds [OGC SWE] coverage server simulation data Serving Coverages sensor feeds [OGC SWE] coverage server simulation data Service Orchestration **SWE, SOS**: upstream sensor data capturing **W*S**: downstream download, processing, visualization WMS WCS WCPS WPS simulation data (Part of) The OGC Standards Quilt - **WMS**: "portrays spatial data → pictures" - **WCS**: "provides data + descriptions; data with original semantics, may be interpreted, extrapolated, etc." [09-110r3] Coverage Definition class GML 3.2.1 Application Schema for Coverages «FeatureType» GML::Feature «FeatureType» Coverage «Union» GML::DomainSet «Union» GML::RangeSet «type» SWE Common::DataRecord contains hook for metadata from SWE Common ISO 19123 is abstract → many different implementations possible → not per se interoperable OGC coverage std is concrete and interoperable [OGC 09-146r2] Coverage & CRS Coverage Encoding - Pure GML: complete coverage, in GML - Special Format: other suitable file format (ex: MIME type “image/tiff”) - Multipart-Mixed: multipart MIME, type “multipart/mixed” Sample Mixed Encoding: TIFF - Multipart/related MIME - Part 1: GML - Part 2: eg, TIFF - Consistency in metadata required - Otherwise bug ```xml <?xml version="1.0" ...?> <gmlcov:RectifiedGridCoverage ... -<gml:domainSet> ... - <gml:rangeSet> - <gml:File> - <gml:rangeParameters xlink:href="grey.tif" xlink:role="http://www.opengis.net/spec/GMLCOV_geotiff-coverages/1.0" xlink:arcrole="fileReference"/> - <gml:fileReference>grey.tif</gml:fileReference> - <gml:fileStructure/> - <gml:mimeType>image/tiff</gml:mimeType> - <gml:File> - <gml:rangeSet> - <gmlcov:rangeType> ... -<gmlcov:RectifiedGridCoverage> ``` Content-Type: image/tiff Content-Description: coverage data Content-Transfer-Encoding: binary Content-ID: grey.tif Content-Disposition: INLINE ...binary TIFF data... --wcs-- WCS Suite Big Picture Class WCS Suite Logical View Abstract Topic 6 - CML - SWE Common Core Coverage Implementation Schema Format Encoding - GeoTIFF - netCDF - JPEG2000 - GML/JP2 - JPIP - CRIB2 - etc. Data Model - Quality - Hierarchies WCS-T - Processing - Range Subsetting - Scaling - CRS - Interpolation Service Protocol Binding - GET-KVP - POST-XML - SOAP - REST - JSON Usability - Multilinguality Extensions Application Profiles data service EO-WCS MetOcean-WCS WCS Core GetCoverage: Trim & Slice - Download a coverage [subset], values guaranteed unchanged - Delivery in "Native Format" - Ex: "download coverage c001" http://www.acme.com/wcs?SERVICE=WCS & VERSION=2.0 & REQUEST=GetCoverage & COVERAGEID=c001 - Ex: "coverage c001, lat/long cutout, time slice t=2009-11-06T23:20:52" http://www.acme.com/wcs?SERVICE=WCS & VERSION=2.0 & REQUEST=GetCoverage & COVERAGEID=c001 & SUBSET=Long(100,120) & SUBSET=Lat(50,60) & SUBSET=time("2009-11-06T23:20:52") - Ex: "coverage c001, lat/long slice, timeseries" http://www.acme.com/wcs?SERVICE=WCS & VERSION=2.0 & REQUEST=GetCoverage & COVERAGEID=c001 & SUBSET=Long(100) & SUBSET=Lat(60) WCS Core GetCoverage: Format Encoding - Download a coverage [subset], values guaranteed unchanged - ...if format allows! - Ex: “coverage c001, in GeoTIFF” http://www.acme.com/wcs ? SERVICE=WCS & VERSION=2.0 & REQUEST=GetCoverage & COVERAGEID=c001 & FORMAT=“image/tiff“ - MIME types preferred, but there may be conventions - Ex: GDAL - formats may define add‘l specific parameters - Ex: JPEG quality factor WCS Extension – Processing [OGC 13-057] - WCS wrapper for OGC Web Coverage Processing Service (WCPS) - high-level spatio-temporal geo raster query language - "From MODIS scenes M1, M2, M3: difference between red & nir, as TIFF" - ...but only those where nir exceeds 127 somewhere ```plaintext for $c$ in (M1, M2, M3) where some($c$.nir > 127) return encode($c$.red - $c$.nir, "image/tiff") ``` (tiff\textsubscript{A}, tiff\textsubscript{C}) Visualization-as-a-Query for $s$ in (SatImage), $d$ in (DEM) where $s$/metadata/@region = "Glasgow" return encode( struct { red: (char) $s$.b7[x0:x1,x0:x1], green: (char) $s$.b5[x0:x1,x0:x1], blue: (char) $s$.b0[x0:x1,x0:x1], alpha: (char) scale( $d$, 20 ) }, "image/png" ) WCS Extension – CRS [OGC 11-053] - retrieval (& bbox) in CRSs different from Native CRS - Extension to GetCoverage request - Capabilities document lists supported CRSs - Recall: coverage = 1 datacube, with 1 CRS in domainSet - Possibly compound: horizontal, height, time, non-referenced, ... - Ex: http://www.acme.com/wcs ? SERVICE=WCS & VERSION=2.0 & REQUEST=GetCoverage & COVERAGEID=c001 & SUBSETTINGCRS=http://www.opengis.net/def/crs/EPSG/0/4326 & OUTPUTCRS=http://www.opengis.net/def/crs/EPSG/0/4326 - This needs - Compound CRSs → CRS NTS - New CRSs: vertical, time, index, proxies, ... → Time + Index CRS NTS [OGC 13-102r2] - Ex: underspecific ImageCRS → Index1D, Index2D, ... Inset: CRS Name Types - **WGS84, RESTful:** - [http://www.opengis.net/def/crs/EPSG/0/4326](http://www.opengis.net/def/crs/EPSG/0/4326) - **WGS84, KVP:** - **Parametrized (”AUTO“) CRSs:** - [http://www.opengis.net/def/crs?authority=OGC&version=1.3 & code=AUTO42003 & UoM=m & CenterLongitude=-100 & CenterLatitude=45](http://www.opengis.net/def/crs?authority=OGC&version=1.3 & code=AUTO42003 & UoM=m & CenterLongitude=-100 & CenterLatitude=45) - **Ad-hoc combination of CRSs:** - **Proprietary CRS definition:** - [http://www.acme.com/def/this-is-EPSG-4326](http://www.acme.com/def/this-is-EPSG-4326) - **Inline CRS definition:** - `srsName="#crsdef"` WCS CRS: Capabilities Retrieval - With WCS-CRS: Capabilities doc contains list of supported CRSs - Ex: ```xml <wcs:crsSupported> http://www.opengis.net/def/crs/EPSG/0/4326 </wcs:crsSupported> <wcs:crsSupported> http://www.opengis.net/def/crs/EPSCG </wcs:crsSupported> <wcs:crsSupported> http://www.opengis.net/def/crs?authority=OGC&version=1.3&code=AUTO42003&UoM=m&CenterLongitude=-100&CenterLatitude=45 </wcs:crsSupported> <wcs:crsSupported> http://www.acme.com/def/this-is-EPSCG-4326 </wcs:crsSupported> <wcs:crsSupported> http://www.opengis.net/def/crs/OGC/0/AnsiDate </wcs:crsSupported> ``` WCS Adoption - Large, growing implementation basis; known: - rasdaman, GDAL, GeoServer, MapServer, EOxServer, QGIS, OpenLayers, Leaflet, OPeNDAP, GMU, NASA WorldWind, … - Pyxis, ERDAS, ESRI ArcGIS, … - proven in large-scale deployments - 130+ TB per single database - 1 query → 1,000+ cloud nodes - Going ISO: - OGC CIS 1.1 → ISO 19123-2 - OGC WCS → ISO WCS Part 2: The New Coverage Implementation Schema, CIS 1.1 (under adoption in OGC & ISO) Coverages: Key Features Revisited / Added - Irregular grids: concise definition - Clarification on ReferenceableGrid, generalization of GML 3.3 GridByXXX - Sensor model support (SensorML 2.0) - Warped CRSs - Interpolation: discrete vs continuous grids - Interleaved representation → general partitioning scheme - JSON prepared - Spec renaming GMLCOV → CIS (adopted Spring 2015) Managing Power - Separate conformance classes for core, gridded and discrete data, partitioning, encoding ```plaintext coverage-partitioning «depends-on» coverage «depends-on» grid-regular «depends-on» grid-irregular «depends-on» grid-transformation «depends-on» discrete-pointcloud «depends-on» discrete-mesh «depends-on» gml-coverage «depends-on» multipart-coverage «depends-on» other-format-coverage «depends-on» json-coverage ``` CIS::AbstractCoverage Feature + coverageFunction :GML::CoverageFunction [0..1] + envelope :CIS::EnvelopeByAxis + domainSet «Data Type» CIS::DomainSet + rangeSet «Data Type» CIS::RangeSet + rangeType «Data Type» SWE Common :: DataRecord + rangeType «Data Type» CIS::Extension + any :any [0..*] + interpolationRestriction «Data Type» CIS::InterpolationRestriction + allowedInterpolation :anyURI [0..*] + metadata 0..1 + metadata 0..1 «Data Type» GML::DataBlock «Data Type» GML::File Grid Types → Axis Types - Observation: GML Rectified, Referenceable to non-intuitive, hard to describe, cases missing - CIS approach: axis types - Index axis: not georeferenced, IndexCRS - Regular axis: georeferenced, constant spacing - Irregular axis: georeferenced, variable spacing - Distorted axes: georeferenced, arbitrary grid point locations - Algorithmic grids: such as sensor model - All combinations possible - GML 3.3 as special cases, SensorML 2.0 integrated srsName is a Reference! - „can we store WKT in srsName?“ No. It is a reference. But it can refer to a WKT, or any other (!) type of definition. Not determined in GMLCOV / CIS. - „can we reference non-canonical (=OGC) CRss?“ Yes. It can refer to a WKT, or any other (!) type of definition. ```xml <cis:domainSet> <cis:GeneralGrid srsName="http://www.opengis.net/def/crs/EPSG/0/4326" unmlabels="deg_deg" axislables="Lat Long" srsDimension="2"> <cis:regularGrid srsName="#crsdef" resolution="5"/> <cis:gridLimits> <cis:ind i="1" j="3"/> <cis:ind i="4" j="3"/> </cis:gridLimits> </cis:GeneralGrid> </cis:domainSet> ``` srsName="http://www.acme.com/def/this-is-EPDG-4326" srsName="#crsdef" CIS::EnvelopeByAxis see examples with CIS 1.1 schema ```xml <cis:GeneralGridCoverage xmlns:cis='http://www.opengis.net/cis/1.1' xmlns:gml='http://www.opengis.net/gml/3.2' xmlns:swe='http://www.opengis.net/swe/2.0' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xsi:schemaLocation= 'http://www.opengis.net/cis/1.1 ..//cisAll.xsd' gml:id="CIS_002"> <cis:domainSet> <cis:GeneralGrid srsName="http://www.opengis.net/def/crs/EPSG/0/4326" uomLabels="deg deg" axisLabels="Lat Long" srsDimension="2"> <cis:regularAxis axisLabel="Lat" lowerBound="-90" upperBound="-80" resolution="5"/> <cis:regularAxis axisLabel="Long" lowerBound="0" upperBound="10" resolution="5"/> <cis:gridLimits srsName="http://www.opengis.net/def/crs/OGC/0/0/1/2D" axisLabels="i j"> <cis:indexAxis axisLabel="i" lowerBound="0" upperBound="2"/> <cis:indexAxis axisLabel="j" lowerBound="0" upperBound="2"/> </cis:gridLimits> </cis:GeneralGrid> </cis:domainSet> </cis:GeneralGridCoverage> ``` CIS::EnvelopeByAxis see examples with CIS 1.1 schema ``` <cis:GeneralGridCoverage xmlns:cis="http://www.opengis.net/cis/1.1" xmlns:gml="http://www.opengis.net/gml/3.2" xmlns:swe="http://www.opengis.net/swe/2.0" xsi:schemaLocation="http://www.opengis.net/cis/1.1 ..//cisAll.xsd" gml:id="CIS_001"> <cis:domainSet> &l2=http://www.opengis.net/def/crs/OGC/0/AnsiDate" uomLabels="deg deg m d" axisLabels="Lat Long h date" srsDimension="4"> <cis:regularAxis axisLabel="Lat" lowerBound="-90" upperBound="-80" resolution="5"/> <cis:regularAxis axisLabel="Long" lowerBound="0" upperBound="180" resolution="5"/> <cis:irregularAxis axisLabel="h" lowerBound="0" upperBound="100" directPositions="0,100"/> <cis:irregularAxis axisLabel="date" lowerBound="2015-12-01" upperBound="2015-12-02" directPositions="2015-12-01, 2015-12-02"/> <cis:gridLimits srsName="http://www.opengis.net/def/crs/OGC/0/Index4D" axisLabels="i j k l"/> </cis:GeneralGrid> </cis:domainSet> </cis:GeneralGridCoverage> ``` CIS::AbstractGridCoverage CIS::AbstractGridCoverage «Feature Type» CIS::AbstractGridCoverage + domainSet CIS::GeneralGridCoverage «Feature Type» CIS::GeneralGridCoverage + domainSet CIS::Grid «Data Type» CIS::Grid + dimension :positiveInteger CIS::GridCoverage «Feature Type» CIS::GridCoverage + envelope :GML::Envelope CIS::RectifiedGridCoverage «Feature Type» CIS::RectifiedGridCoverage + envelope :GML::Envelope GML::Grid «Data Type» GML::Grid GML::RectifiedGrid «Data Type» GML::RectifiedGrid CIS::C’ByPartitioning [Diagram of class and feature relationships involving `CIS::CoverageByPartitioning`, `CIS::CoverageByDomainAndRange`, `CIS::AbstractCoverage`, `Data Type SWE Common: DataRecord`, and `CIS::Extension`, `CIS::InterpolationRestriction` classes with attributes and relationships such as `coverage`, `rangeType`, `metadata`, `interpolationRestriction`, `partition`, `domainSet`, and `rangeSet`.] © 2016 rasdaman CIS::C’ByPartitioning See examples coming with CIS 1.1 schema, currently: 05_2D_index.xml; 10_2D_regular.xml; 20_3D_height.xml; 30_4D_height+time.xml; 40_1D_regular.xml; 45_2D_distorted.xml; 50_3D_partitioned.xml; 55_1D_timeseries-partitioned.xml; 56_3D_timeseries-multipart.xml; 57_1D_timeseries-interleaved.xml; 60_point-cloud.xml; 80_2D_interpolation.xml; 90_sensormodel.xml; z0_gridcoverage.xml; z1_rectifiedgridcoverage.xml CIS 1.1: Summary - CIS 1.1 = compatible extension to GMLCOV 1.0 - General grids; SensorML 2 integration; nonnumeric coordinates; "time-interleaved", interpolation; splitting into req classes - In sync with ISO TC211 - Concepts elaborated in T-11 (10 change requests) - Spec + ATS ready, on pending >3 weeks - Approach: full copy GMLCOV → CIS (not inc, like GML 3.3) - Implementations available for critical points: - Irregular grids: EarthServer project - Sensor model: KEYW - Partitioning: rasdaman and other array databases - GMLCOV 1.0 parts pre-existing, copied over - Outlook: adding JSON Sample Mixed Encoding: TIFF - Multipart/related MIME - Part 1: GML - Part 2: eg, TIFF - Consistency in metadata required - Otherwise bug <?xml version="1.0" ...> <gmlcov:RectifiedGridCoverage ...> <gml:domainSet>...</gml:domainSet> <gml:rangeSet> <gml:File> <gml:rangeParameters xlink:href="grey.tif" xlink:role="http://www.opengis.net/spec/GMLCOV_geotiff-coverages/1.0" xlink:arcrole="fileReference"/> <gml:fileReference>grey.tif</gml:fileReference> <gml:fileStructure/> <gml:mimeType>image/tiff</gml:mimeType> </gml:File> </gml:rangeSet> </gmlcov:RectifiedGridCoverage> --wcs Content-Type: image/tiff Content-Description: coverage data Content-Transfer-Encoding: binary Content-ID: grey.tif Content-Disposition: INLINE ...binary TIFF data... --wcs-- OGC Coverage Types - Spatio-temporal! - MultiSolid Coverage - MultiSurface Coverage - MultiCurve Coverage - MultiPoint Coverage - Grid Coverage - Rectified GridCoverage - Referenceable GridCoverage «FeatureType» Abstract Coverage as per GML 3.2.1 Part 3: Q&A Questions Q: Harmonize the CRS used in the “srsName” parameter for different GMLCOV file components. Example uncorrelated with OGC coverages OGC coverages offer simple, powerful (n-D!) way of handling space/time coordinates - `boundedBy` is optional, may be different CRS, may be approximate; from GML! - `domainSet` is mandatory, authoritative: contains Native CRS of coverage - `domainExtent` is unknown to me (not found in GML 3.2.1) Questions - Elevation: Vertical CRS defining elevation values in rangeSet? - referenceFrame property from rangeType/swe:Quantity [OGC 08-094r1 SWE Common Data Model] Use of swe:Quantity not governed by WCS.SWG! Best practice highly desirable. „Me no expert“ – who is willing to join a task force? Mail thread wrap-up? [Emmanuel Devys et al] DEM Example Based on email discussion with Emmanuel Devys, Roger Lott, et al Questions - tiling / mosaicking, coverage aggregations within the GMLCOV files - Build GMLCOV example for Elevation & Orthoimagery - standardized way to implement tiling (describing logical structures like e.g. mapsheets, administrative units like regions or districts, etc.) - mosaic elements (OI) - modelling coverage aggregations Caveat: implementation detail, WCS interface std does not define implementation. **COVERAGE ≠ IMAGE** Do NOT standardize tiling on server! Why should it be necessary? Any serious server today can do seamless mosaicked maps Meaning, purpose, how to serve? Questions - partial conceptual redundancies between INSPIRE coverages attributes and GMLCOV components / INSPIRE coverage model extensions - Ex: domainExtent vs. gml:boundedBy - agreed to minimize INSPIRE extensions as possible - Issues: - Sometimes duplication of information - not much danger (consistency can be verified automatically) - Redundancy existing, eg, with format encodings - WCS2.0 ignores INSPIRE extensions - dangerous Relevant Links - **Wikipedia primers:** - [Coverages](#) - [Web Coverage Service](#) - [Web Coverage Processing Service](#) - **OGC:** - Coverage service standards online demo: [http://standards.rasdaman.com](http://standards.rasdaman.com) - The rasdaman Array Database System - The EarthServer initiative That‘s all folks! rasdaman: Agile Array Analytics - „raster data manager“: SQL + n-D raster objects ```sql select img.green[x0:x1,y0:y1] > 130 from LandsatArchive as img where avg_cells(img.nir) < 17 ``` - Scalable parallel “tile streaming” architecture - In operational use - OGC Web Coverage Service Core Reference Implementation
{"Source-Url": "https://eurogeographics.org/wp-content/uploads/2018/04/2016-01-18_INSPIRE-KEN-CovFaq.pdf", "len_cl100k_base": 5377, "olmocr-version": "0.1.53", "pdf-total-pages": 43, "total-fallback-pages": 0, "total-input-tokens": 72085, "total-output-tokens": 7939, "length": "2e12", "weborganizer": {"__label__adult": 0.0003104209899902344, "__label__art_design": 0.0013513565063476562, "__label__crime_law": 0.0004589557647705078, "__label__education_jobs": 0.0016393661499023438, "__label__entertainment": 0.00014913082122802734, "__label__fashion_beauty": 0.0002378225326538086, "__label__finance_business": 0.00075531005859375, "__label__food_dining": 0.0003008842468261719, "__label__games": 0.000667572021484375, "__label__hardware": 0.0017385482788085938, "__label__health": 0.00039267539978027344, "__label__history": 0.0011243820190429688, "__label__home_hobbies": 0.0001742839813232422, "__label__industrial": 0.0011224746704101562, "__label__literature": 0.00038814544677734375, "__label__politics": 0.0006704330444335938, "__label__religion": 0.0005922317504882812, "__label__science_tech": 0.258544921875, "__label__social_life": 0.00017213821411132812, "__label__software": 0.08831787109375, "__label__software_dev": 0.6396484375, "__label__sports_fitness": 0.0002913475036621094, "__label__transportation": 0.0005655288696289062, "__label__travel": 0.00031876564025878906}, "weborganizer_max": "__label__software_dev", "avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_ratio": [[0, 19215, 0.02299]], "fineweb_edu_fasttext_gt2__fineweb_edu_fasttext_gt2__score": [[0, 19215, 0.20841]], "ft_lang_id_en_doc_v2__ft_lang_id_en_doc_v2__en": [[0, 19215, 0.50047]], "google_gemma-3-12b-it_contains_pii": [[0, 119, false], [119, 224, null], [224, 254, null], [254, 333, null], [333, 409, null], [409, 569, null], [569, 778, null], [778, 1179, null], [1179, 1194, null], [1194, 1383, null], [1383, 2228, null], [2228, 2716, null], [2716, 3402, null], [3402, 3825, null], [3825, 4274, null], [4274, 4620, null], [4620, 5326, null], [5326, 6406, null], [6406, 7038, null], [7038, 7411, null], [7411, 7497, null], [7497, 7886, null], [7886, 8359, null], [8359, 8879, null], [8879, 9365, null], [9365, 10095, null], [10095, 11110, null], [11110, 12292, null], [12292, 12808, null], [12808, 13239, null], [13239, 13669, null], [13669, 14282, null], [14282, 15076, null], [15076, 15326, null], [15326, 15338, null], [15338, 16069, null], [16069, 16742, null], [16742, 16820, null], [16820, 17578, null], [17578, 18259, null], [18259, 18869, null], [18869, 18887, null], [18887, 19215, null]], "google_gemma-3-12b-it_is_public_document": [[0, 119, true], [119, 224, null], [224, 254, null], [254, 333, null], [333, 409, null], [409, 569, null], [569, 778, null], [778, 1179, null], [1179, 1194, null], [1194, 1383, null], [1383, 2228, null], [2228, 2716, null], [2716, 3402, null], [3402, 3825, null], [3825, 4274, null], [4274, 4620, null], [4620, 5326, null], [5326, 6406, null], [6406, 7038, null], [7038, 7411, null], [7411, 7497, null], [7497, 7886, null], [7886, 8359, null], [8359, 8879, null], [8879, 9365, null], [9365, 10095, null], [10095, 11110, null], [11110, 12292, null], [12292, 12808, null], [12808, 13239, null], [13239, 13669, null], [13669, 14282, null], [14282, 15076, null], [15076, 15326, null], [15326, 15338, null], [15338, 16069, null], [16069, 16742, null], [16742, 16820, null], [16820, 17578, null], [17578, 18259, null], [18259, 18869, null], [18869, 18887, null], [18887, 19215, null]], "google_gemma-3-4b-it_v2tag__is_academic_paper": [[0, 5000, false], [5000, 19215, null]], "google_gemma-3-4b-it_v2tag__is_class_syllabus": [[0, 5000, false], [5000, 19215, null]], "google_gemma-3-4b-it_v2tag__is_completion_certificate": [[0, 5000, false], [5000, 19215, null]], "google_gemma-3-4b-it_v2tag__is_court_notice": [[0, 5000, false], [5000, 19215, null]], "google_gemma-3-4b-it_v2tag__is_homework_assignment": [[0, 5000, false], [5000, 19215, null]], "google_gemma-3-4b-it_v2tag__is_news_article": [[0, 5000, false], [5000, 19215, null]], "google_gemma-3-4b-it_v2tag__is_public_order": [[0, 5000, false], [5000, 19215, null]], "google_gemma-3-4b-it_v2tag__is_resume_cv": [[0, 5000, false], [5000, 19215, null]], "google_gemma-3-4b-it_v2tag__is_test_or_quiz": [[0, 5000, false], [5000, 19215, null]], "google_gemma-3-4b-it_v2tag__is_textbook": [[0, 5000, false], [5000, 19215, null]], "pdf_page_numbers": [[0, 119, 1], [119, 224, 2], [224, 254, 3], [254, 333, 4], [333, 409, 5], [409, 569, 6], [569, 778, 7], [778, 1179, 8], [1179, 1194, 9], [1194, 1383, 10], [1383, 2228, 11], [2228, 2716, 12], [2716, 3402, 13], [3402, 3825, 14], [3825, 4274, 15], [4274, 4620, 16], [4620, 5326, 17], [5326, 6406, 18], [6406, 7038, 19], [7038, 7411, 20], [7411, 7497, 21], [7497, 7886, 22], [7886, 8359, 23], [8359, 8879, 24], [8879, 9365, 25], [9365, 10095, 26], [10095, 11110, 27], [11110, 12292, 28], [12292, 12808, 29], [12808, 13239, 30], [13239, 13669, 31], [13669, 14282, 32], [14282, 15076, 33], [15076, 15326, 34], [15326, 15338, 35], [15338, 16069, 36], [16069, 16742, 37], [16742, 16820, 38], [16820, 17578, 39], [17578, 18259, 40], [18259, 18869, 41], [18869, 18887, 42], [18887, 19215, 43]], "pipe_delimited_lines_v1__pipe_delimited_lines_v1__pipe_delimited_lines_ratio": [[0, 19215, 0.0]]}
olmocr_science_pdfs
2024-12-07
2024-12-07
919f5c3ba1f92645af708ed0892d46c6c01b4126
This version is available at https://strathprints.strath.ac.uk/62712/ Strathprints is designed to allow users to access the research output of the University of Strathclyde. Unless otherwise explicitly stated on the manuscript, Copyright © and Moral Rights for the papers on this site are retained by the individual authors and/or other copyright owners. Please check the manuscript for details of any other licences that may have been applied. You may not engage in further distribution of the material for any profitmaking activities or any commercial gain. You may freely distribute both the url (https://strathprints.strath.ac.uk/) and the content of this paper for research or private study, educational, or not-for-profit purposes without prior permission or charge. Any correspondence concerning this service should be sent to the Strathprints administrator: strathprints@strath.ac.uk The Strathprints institutional repository (https://strathprints.strath.ac.uk) is a digital archive of University of Strathclyde research outputs. It has been developed to disseminate open access research outputs, expose data about those outputs, and enable the management and persistent access to Strathclyde's intellectual output. Pienapple Search: an integrated search interface to support finding, refinding and sharing Martynas Buivys University of Glasgow Glasgow, United Kingdom martynas.buivyas@gmail.com Leif Azzopardi University of Strathclyde Glasgow, United Kingdom leifos@acm.org ABSTRACT Pienapple is a search interface that aims to combine bookmarking and searching within a blended experience to facilitate improved access, serendipity, and sharing. While personal and social bookmarking platforms already exist, they are often separated from the search system, resulting in an increased effort and complexity because two or more systems need to be used. Instead, Pienapple attempts to lower the overall effort of bookmarking, (re)accessing and sharing by bringing these activities together to provide a more supportive search interface. Author Keywords Interactive Information Retrieval, Re-finding, Collaborative Search, Social Search INTRODUCTION The World Wide Web contains a vast amount of information, where typically people use search engines to discover and surface content. Once found people employ a variety of tools and employ various strategies to re-find the information discovered, either by re-querying or saving the information (or a link to) for later use and re-visitation (Sellen et al., 2002; Jhaveri, 2004; Jones et al., 2001; Wen, 2003; Obendorf et al., 2007; Aula et al., 2005). Re-finding using a search engine and the use of bookmarks are among the most common re-visitation techniques (Aula et al., 2005; Jhaveri, 2004; Obendorf et al., 2007; Jones et al., 2001). Bookmarks, also known as favourites or hotlists, were invented more than two decades ago and were used as internet shortcuts in browsers like Internet Explorer, Mozilla Firefox, and Mosaic. Over the years, bookmarks have evolved into portable collections and social sharing platforms which allow remote access and management over the internet through the use of websites and browser extensions. Now bookmarks and search are coming together, though, there is much scope for improvements and developments in this area. For instance, Google Chrome Bookmark Manager is a browser extension for organising bookmarks. However, this bookmarking system is akin to the one provided by browsers, and so users have to go through the process of creating and organising newly added bookmarks. Furthermore, although the extension supports bookmark search it is not integrated into the standard web search interface, nor does it provide access to social bookmarks. On the other hand, Delicious, for example, is a popular social bookmarking tool that helps “...manage information traditionally kept on personal machines, while allowing for sharing with the community at large” (Lee, 2006). Although Delicious is portable and supports social exploration, bookmark search is isolated from web search. This separation requires the user to put in extra effort to visit the Delicious website in order to access and manage his/her bookmark collection. So rather than have a bookmarking tool and a search tool, we explore the possibility of making bookmarking activities, such as saving, re-finding and sharing, part of the web search experience. In this demonstration paper, we present Pienapple Search, a tool that integrates searching, bookmarking and sharing into one interface in a seamless manner. Our goal is to develop an interface that: 1. minimises the effort of bookmarking and re-finding 2. supports personal information management 3. enables collaborative and social search In the remainder of this paper, we describe prior tools and efforts regarding personal information access, re-finding and bookmarking to provide the context and background for our novel interface. Then we outline the Pienapple Search interface and the design rationale along with the findings from a usability study involving 26 participants. BACKGROUND The motivation for Pienapple stems from the research on re-finding and re-visitation behaviours. Re-visitations (or re-finding) is a very common activity when browsing the Web. Previous studies (Tauscher & Greenberg, 1997; Obendorf et al., 2007) indicated that around half of website visits are actually re-visits. Obendorf et al. (2007) classified re-visititation into three categories: short-term, medium-term, and long-term. While short-term re-visititations are typically supported by the browser’s back button or copy-and-paste (Tauscher & Greenberg, 1997), medium-term and long-term re-visititations often involve a variety of approaches. Jones et al. (2001) observed and interviewed eleven information specialists and researchers to understand better what methods and tools people employ to manage useful information found on the Web. such as emailing the URL of interest, printing or saving the web page, entering the URL directly and re-finding using a search service were among the re-access strategies employed by their subjects. Interestingly, the built-in browser tools such as bookmarks and the browsing history were not frequently used. These findings are consistent with the survey performed by Aula et al. (2005), who also noted that bookmarks are “...commonly used, but their frequency of use varies a lot”. Further, they pointed out that people use a variety of strategies to re-access information and that existing tools fail to adequately support users. When using search engines to re-find information, they found that searchers find it “...difficult to remember the query terms used when finding the information in the first place” (Aula et al., 2005). Teevan, Adar, Jones, and Potts (2006) analysed the search behaviour of 114 users over 365 days using the Yahoo! search engine. By monitoring users’ queries and clicks, it was discovered that “...forty percent of all observed queries (5216/13,060) led to a click on a result that was also clicked during another query session by the same user”. These findings were confirmed in the follow-up paper (Teevan et al., 2007), and the authors concluded there is a need for a tool that can effectively support finding and re-finding activities. Consequently, there has been a number of attempts to develop a variety of tools to help users. Jhaveri and Räihä (2005) developed Session Highlights to support users as they search - letting them drag and drop URLs to a separate workspace. Thumbnails of the pages were stored in the workspace so that users could re-access previously visited pages (and thus alleviate the medium-term re-visitation problem). M. R. Morris and Horvitz (2007a) developed S3, which was aimed at supporting the resumption of paused search activities (i.e. searching over multiple sessions). This prototype stored both the queries issued and pages the user marked as useful. This prototype served as the basis for SearchTogether (M. R. Morris & Horvitz, 2007b), which aims to support collaborative web search by sharing the queries and pages found. The interface was designed to support query awareness, division of labour and persistent representation of search among small groups of people working on the same task. It also included an instant messaging system and result recommendation to enable communication between participants. More closely related to our demonstration, is SearchBar, which was developed by D. Morris, Morris, and Venolia (2008). SearchBar is a search-focused browsing history tool, which was suggested by Obendorf et al. (2007). Its goal is to improve the user experience of resuming suspended search activities and re-finding previously encountered results. It aims to assist users in regaining the context of multi-session investigations. The SearchBar implicitly registers all user’s search queries and results visited and categorises them by the search topic which has to be manually created by the user. However, this introduced the problem of having to manage all the recorded queries and history. The authors try to address this problem by using a hierarchical display and rating-based filtering. In our system, we do not implicitly save and store queries and results (though that would be possible). Instead, we focus on integrating explicit bookmarking activity into the search experience. Of course, there have been numerous efforts associated specifically with bookmarking. Delicious is a social computing website which allows users to store, annotate, manage and share links to useful resources on the web (Marlow et al., 2006). A Delicious bookmark contains information about the owner, the URL and the title of the resource and an optional description. All bookmarks are public by default; however users have the option to mark a bookmark as private and opt out from participating in the community. Saved bookmarks are organised by tags which are manually chosen by the user. Tags are typically only useful for the creator of the bookmark and not others. Wash and Rader (2007) interviewed twelve regular users of Delicious and discovered that tags do not help during information-seeking activities and established that “...in social discovery, it is the user and not the topic that is of interest”. There are many other online bookmarking services similar to Delicious. For example, Diigo and Pinboard are two popular alternatives. Diigo enables users to bookmark and organise their online collections, as well as capture and annotate on-page elements. Similarly, Pinboard provides quick bookmarking and full-text search on bookmarks. Kippt was a collaborative bookmarking application which was implemented as a browser extension. It allowed the user and his/her collaborators to archive various on-page elements such as videos, articles, and images. Each saved item could be searched for, shared and discussed with collaborators. Pocket is another variant, which allows users to save articles they would like to read in the future. Thus, the application aims to support short-term re-visitation. However, these application did not integrate bookmarking into the user’s everyday search activities. On the other hand, browsers provide support for bookmarking and re-finding. For example, the Google Chrome Bookmark Manager is an extension for the Google Chrome browser which stores the user’s bookmarks in the cloud so they can be accessed anywhere using any device. The process of bookmarking a page is similar to using a browser’s bookmarking functionality. The user needs to select where the bookmark is saved too, give the bookmark a name (if they like), enter the name of the folder it is to be saved to, etc. Bookmarks are presented as big thumbnails to provide visual cues. The application allows you to search your bookmark collection easily using the URL bar and quickly re-find saved information. Other browsers such as Edge, Firefox and Safari also provide similar support. As outlined above, there has been a variety of different bookmarking applications. However, we posit, that because they are not fully integrated with how or when bookmarks are actually used and when they are useful - this limits the utility of bookmarking. Said another way, the effort involved in bookmarking and re-finding through a separate interface typically outweighs the benefit of doing so, especially when it is possible to re-query for the information. Our aim in developing Pienapple is to reduce the effort required, and provide more seamless access through an integrated search interface. PIENAPPLE SEARCH Pienapple Search aims to integrate bookmark search and management within a typical web search interface. The system is deployed in the public domain, and it can be accessed by visiting www.pienapple.com. The interface was designed to: (i) minimise changes to the standard web search interface, (ii) minimise the effort of the user’s bookmarking actions, and (iii) minimise the amount of effort involved in re-finding. An additional aim was to facilitate social exploration and sharing of bookmarks. Therefore, the Pienapple Search interface is similar to traditional web search interfaces: a query box, ten blue links of results and tabs to display the verticals (i.e. web, images, news and videos), see Figure 2. The look and feel are consistent with the minimalism of search engines such as Google and Bing. The modifications to the interface are as follows: (i) a bookmarks vertical, (ii) a list of bookmark folders (on the right), and (iii) snippets on the bookmarks vertical also include who “owns” the bookmark, i.e. Pienapple username and folder name are shown (see Figure 3). Searching: The mechanics of searching are as follows. As the user types their query, Pienapple tries to match the partial query to the user’s current bookmarks and recommends any matching bookmarks. If the user continues typing and then... hits search, the request is then submitted to the web vertical, and the web results are returned. This seamlessly integrates bookmark search and web search together. **Bookmarking:** To do this, we first made the bookmark folders visible on the search interface and provided instant access to bookmarks by providing an additional tab (bookmarks). To facilitate access to bookmarks, as the user enters a querying, relevant bookmarks are displayed, until the user hits return or the search button, in which case a web search is performed. To reduce the effort of bookmarking, we provide a number of features: the ability to drag and drop results to folders from within the search interface, or if on a web page, the user can click the Pienapple extension to bookmark it. To further reduce the cost, as the user types a query we automatically suggest folders that are likely to be relevant to the query and suggest the creation of new folders based on the query. Folder suggestion happens at two levels: (i) suggesting existing folders and (ii) suggesting new folders. For example, if the user had folders about programming, i.e. “python”, “perl”, etc., and the query was “programming”, then these folders would be recommended. If they added “python” to the query, then only the python folder would be suggested. In the second case, the interface would also suggest the create of a new folder, “python programming” as another possible folder to store bookmarks. The idea with these suggestions is again to minimise the effort of folder creation and bookmark organisation. Currently, two folders are recommended. **Sharing:** To share bookmarks, a user needs to mark their folder as public. Then the list of bookmarks can be accessed by visiting: [www.pienapple.com/username/]<folder-name>. Sharing also happens implicitly. When searching on the bookmark vertical, bookmarks saved by other users are also recommended. These “social” bookmarks are indicated by including the username of the owner and the folder name. The idea here is that by showing such links to users will enable users to explore bookmarks others have found. Currently, we have only implemented public and private options. So it would be interesting to explore how such an option could be integrated with social networks to constrain where or which bookmarks are recommended. How to Tango with Django: A Python Django Tutorial http://www.tangowithdjango.com/TangoWithDjango1.7_ABeginner’sGuidetoWebDevelopmentwithPython2.7/Django1.7Comments,suggestionsandfeedbackiswelcomes.Changesrequests Figure 3. Bookmark Snippet includes the owner (leifos) and folder name (django). These can be selected by the user to find other related bookmarks by the owner and in the folder. **Implementation** Pienapple Search project is implemented as a component-based system, consisting of seven independent services: Web Client, an API service, MongoDB database, ElasticSearch bookmark search service, Redis queue, Alchemy API services, Microsoft Bing search service. The Web Client is the user interface the user interacts with to search the web and manage the bookmarks. It is built using the ReactJS framework and utilises the Facebook’s Flux architecture. The Client is an independent component that communicates with the API through a RESTful interface by sending and receiving JSON payload. In addition, the Client is responsible for logging all user’s actions. The advantage of using a client-side logger over a server side logger is that it can capture richer data about how a user interacts with the interface. The Pienapple API provides a public interface for clients to access the MongoDB database and the Elasticsearch bookmark search service. It also orchestrates the Redis job queue for background workers responsible for bookmark indexing. The API is implemented using NodeJS language and runs on Express framework. It is plugged into Travis CI, a continuous integration framework, which automatically runs a set of tests against all API endpoints to ensure the newly committed code does not break the application. The Elasticsearch bookmark search service is responsible for retrieving bookmarks based on a given search query. The client does not have direct access to the search service. Instead all requests by the client are proxied through the Pienapple API. Similarly, the Microsoft Bing search service is responsible for supporting searches in four different verticals: web, news, images, and videos. The API delegates the Client’s search requests in these verticals to Microsoft Bing Search API and returns the results in JSON format. Redis queue is used by the API for background jobs. For example, when a Pienapple Search user creates a bookmark, a few background jobs will be created. When a background worker becomes available, a request will be sent to the Alchemy API service to extract the content of the bookmarked page. After that, the bookmark will be indexed by Elasticsearch search service. Alchemy API is used by the background workers to extract the text and named entities from bookmarked pages. The extracted content is then pushed to the Elasticsearch bookmark search service to improve the quality of the search results. **USABILITY STUDY** Given the Pienapple interface described above we conducted a usability study to determine what areas could be improved and to receive feedbacks on the application. At our university, we recruited 28 master’s students to perform a task based usability study. The participants were briefly introduced to the interface and then asked to perform a simulated leisure task, where participants had to imagine that they were hosting an Italian night for their friends. They were asked to find, bookmark, and then later re-find pizza recipes that would appeal to their friends. Participants answered a number 5-point Likert questionnaire about features of the interface (see Table 1), a standard 10-item System Usability Scale (SUS) questionnaire (Brooke, 1996) for measuring the perceived system usability, and three open-ended questions. From the initial questions, participants felt that the interface integrates bookmarks well and provides good recommenda- We asked three open-ended questions regarding what they was also less agreement regarding whether it was easy to use. The suggestions (i.e. suggesting folders into which URLs can be saved). They also felt it was it was relatively easy to manage their bookmarks. Participants felt it was a better bookmarking tool that other tools that they had previously used, but were mixed about whether it was better than existing search engines. There was also less agreement regarding whether it was easy to use. This was re-confirmed by the SUS questionnaire results where the interface was rated as 77 out of 100, which is considered to be good as the minimum usability score is considered to be 68 (Brooke, 1996). However, of the 28 participants, five rated the system below 60, with the lowest being 30. So this suggests that there is much room for improvement. We asked three open-ended questions regarding what they most liked, least liked, and what they would improve in the system. We do not have space to detail all the points, and so below we provide a summary of the feedback. Re-affirming the Likert questions participants mentioned that liked the bookmark creation (N=4), organisation (N=6), and search (N=4). In addition, the participants liked the drag and drop bookmarking (N=3) and the Google Chrome extension to quickly bookmark the current page (N=2). For the least favourite features of the system, participants listed the limited sharing capability (i.e. currently a web link to the bookmarks as oppose to via social media) (N=2) and no obvious delineation between the personal bookmark search results and the results from other users. The participants also provided some suggestions on how to improve the interface. These included: nested folder support (N=3), the ability to re-arrange bookmarks folders (N=2), more intuitive or explicit ways to bookmark, as dragging and dropping was not obvious to some participants, and improved folder permissions (e.g. making it more obvious that folders can be made private or public) and highlighting whether a bookmark is personal or social. The suggestions by participants indicated more work is needed to make the experience more seamless and the interface more intuitive. **SUMMARY AND FUTURE WORK** In this demonstration paper, we have presented Pienapple Search, which aims to combine personal, social and web search together in a blended experience. From our usability study, while generally quite positive, we have identified a number of issues that need to be addressed before deploying the system and undertaking task-based evaluations and naturalistic studies. Once deployed we will focus our attention on more backend IR problems: (i) bookmark folder suggestion (ii) bookmark ranking and (iii) sharing and suggesting bookmarks to other users. **References** **Table 1. Likert Questions on Pienapple Usability (1-strongly disagree to 5-strongly agree).** <table> <thead> <tr> <th>Question</th> <th>Mean (Std)</th> </tr> </thead> <tbody> <tr> <td>Good Integration</td> <td>4.27 (0.92)</td> </tr> <tr> <td>Good Recommendations</td> <td>4.12 (0.91)</td> </tr> <tr> <td>Easy to Manage</td> <td>4.23 (0.91)</td> </tr> <tr> <td>Preferred over other bookmarking tools</td> <td>4.04 (0.82)</td> </tr> <tr> <td>Preferred over other search engines</td> <td>3.23 (1.11)</td> </tr> <tr> <td>Easy to Use</td> <td>3.58 (1.14)</td> </tr> </tbody> </table>
{"Source-Url": "https://strathprints.strath.ac.uk/62712/1/Buivys_Azzopardi_AIST_2016_Pienapple_search_an_integrated_search_interface_to_support_finding_refinding_and_sharing.pdf", "len_cl100k_base": 4829, "olmocr-version": "0.1.53", "pdf-total-pages": 6, "total-fallback-pages": 0, "total-input-tokens": 16802, "total-output-tokens": 6197, "length": "2e12", "weborganizer": {"__label__adult": 0.00037169456481933594, "__label__art_design": 0.001361846923828125, "__label__crime_law": 0.0003361701965332031, "__label__education_jobs": 0.00981903076171875, "__label__entertainment": 0.00042819976806640625, "__label__fashion_beauty": 0.0002703666687011719, "__label__finance_business": 0.0007753372192382812, "__label__food_dining": 0.0005054473876953125, "__label__games": 0.0009832382202148438, "__label__hardware": 0.0011091232299804688, "__label__health": 0.0006012916564941406, "__label__history": 0.0008726119995117188, "__label__home_hobbies": 0.00019931793212890625, "__label__industrial": 0.00022470951080322263, "__label__literature": 0.0017099380493164062, "__label__politics": 0.0002815723419189453, "__label__religion": 0.0005316734313964844, "__label__science_tech": 0.09918212890625, "__label__social_life": 0.0005879402160644531, "__label__software": 0.276123046875, "__label__software_dev": 0.60302734375, "__label__sports_fitness": 0.00020623207092285156, "__label__transportation": 0.0003917217254638672, "__label__travel": 0.00035190582275390625}, "weborganizer_max": "__label__software_dev", "avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_ratio": [[0, 26482, 0.02884]], "fineweb_edu_fasttext_gt2__fineweb_edu_fasttext_gt2__score": [[0, 26482, 0.34785]], "ft_lang_id_en_doc_v2__ft_lang_id_en_doc_v2__en": [[0, 26482, 0.91933]], "google_gemma-3-12b-it_contains_pii": [[0, 1518, false], [1518, 6273, null], [6273, 12950, null], [12950, 14293, null], [14293, 20488, null], [20488, 26482, null]], "google_gemma-3-12b-it_is_public_document": [[0, 1518, true], [1518, 6273, null], [6273, 12950, null], [12950, 14293, null], [14293, 20488, null], [20488, 26482, null]], "google_gemma-3-4b-it_v2tag__is_academic_paper": [[0, 5000, true], [5000, 26482, null]], "google_gemma-3-4b-it_v2tag__is_class_syllabus": [[0, 5000, false], [5000, 26482, null]], "google_gemma-3-4b-it_v2tag__is_completion_certificate": [[0, 5000, false], [5000, 26482, null]], "google_gemma-3-4b-it_v2tag__is_court_notice": [[0, 5000, false], [5000, 26482, null]], "google_gemma-3-4b-it_v2tag__is_homework_assignment": [[0, 5000, false], [5000, 26482, null]], "google_gemma-3-4b-it_v2tag__is_news_article": [[0, 5000, false], [5000, 26482, null]], "google_gemma-3-4b-it_v2tag__is_public_order": [[0, 5000, false], [5000, 26482, null]], "google_gemma-3-4b-it_v2tag__is_resume_cv": [[0, 5000, false], [5000, 26482, null]], "google_gemma-3-4b-it_v2tag__is_test_or_quiz": [[0, 5000, false], [5000, 26482, null]], "google_gemma-3-4b-it_v2tag__is_textbook": [[0, 5000, false], [5000, 26482, null]], "pdf_page_numbers": [[0, 1518, 1], [1518, 6273, 2], [6273, 12950, 3], [12950, 14293, 4], [14293, 20488, 5], [20488, 26482, 6]], "pipe_delimited_lines_v1__pipe_delimited_lines_v1__pipe_delimited_lines_ratio": [[0, 26482, 0.1]]}
olmocr_science_pdfs
2024-12-07
2024-12-07
001e3c7cf90de32fab71a535e98fb9ad98310e43
Open architecture for multilingual web sites M.T. Carrasco Benitez Luxembourg, March 2012, draft version 0.19 1. Abstract Multilingual Web Sites (MWS) refers to web sites that contain multilingual parallel texts; i.e., texts that are translations of each other. For example, most of the European Institutions sites are MWS, such as Europa [EU]. This document sketches a comprehensive open architecture. In particular, it takes into account: - **Users** should expect the same multilingual behaviour when using different browsers and/or visiting different web sites. - **Webmasters** should be capable of creating quickly high quality, low cost MWS. 2. Status This document is a draft. The author solicits comments from the community at large. Some parts of this document are bullet lists that have to be written in prose. This is a general architecture document: a significant amount of work will be needed to write precise specifications. Also, this document might be considered a primer on MWS. Multilingual web aspects must be positioned in the wider web context; e.g., language is just one of the dimensions in transparent content negotiation [TCN]. One should find particular solutions for the specific multilingual aspects that are not standardised, though taking into account the wider context; e.g., the interoperability among data in the web servers and content management systems (CMS) is a general issue and not particular to MWS. There should be a general rolling architecture, but there should be also concrete immediate steps. The next step should be the one with the best return on investment (ROI); e.g., specifying and implementing the server side language as an URI: http://example.com/var. 2.1. Relevance MWS are of great practical relevance as there are very important portals with many hits; also they are very complex and costly to create and maintain: translation is expensive. Facilitating and enjoying this common experience entails standardisation: current multilingual web sites are applications incompatible with each other. It is vital to agree on common behaviours for users: browser-side (language button) and server-side (language page). 2.2. Break nothing Stating the obvious, adding these facilities must not break any of the existing standards. Indeed, sometimes it just means implementing mechanisms already in the standards such as TCN; e.g., in the case of the language button it means that servers have to return the available languages in the HTTP header, and browsers must process this data and activate the language button, if necessary. 3. Interfaces The users and webmasters issues map into two interfaces: • **Interface browsers-servers (users):** well established; indeed, the heart of the web with HTTP, URI and HTML. Very delicate as it touches the grand public; even a small additional complexity could be disastrous. So, the multilingual aspects have to enter the dance without causing any missteps. • **Interface servers-content management (webmasters):** lots of work to do. Indeed, it is more general than multilingual. One could have more complexity as it touches mostly professionals. 4. **Interface browsers-servers (users)** 4.1. **Monolingual** From a users point of view, the most common usage is monolingual, thought a site might be multilingual; i.e., users might be interested in just one language of the several available at the server. The language selection is just a barrier to get the appropriate linguistic version. Some users might be really interested in several linguistic versions. 4.2. **Transparent content negotiation (TCN)** One can get the best language with TCN. For this, browsers need to be properly set. TCN is not widely known and it might be confusing for naïve users; also, one might be using a browser that one cannot set, such in the case of kiosks. On the other hand, one should not unduly penalise users that want to use TCN. Hence a compromise should be found that combines TCN and other mechanisms such as direct language select perhaps using cookies. Proxy servers could create problems for TCN. 4.3. **Language selection** One needs a direct language selecting mechanism if: • TCN is not available. • TCN is available, but the requested languages are unavailable. • One wants to switch to another language. 4.4. **Options** These are the options: - Initial arrival - TCN - Select one language explicitly from a list of languages - Monolingual path - One server with all the languages - File extension - Language branch - A federation of servers, each with one language (Wikipedia) - Cookie - Alone or combined with TCN - Switch among languages - TCN - Cookie - TCN + cookie - Links in pages - One per language - Menu • Select and enter • Select and automatically go with JavaScript o Change the language code in the URI 4.5. Browser and server side • Browser side: The controls are in the browser. • Server side: A page sent by the server. 4.6. Variant 4.6.1 Overview This section addresses mainly the MWS aspects. It includes: • Variants (languages, format, etc); immediate and deferred • Metadata of the variant; e.g., author of the variant • Metadata of the URI; e.g., editor for the whole URI set • Metadata of the site; e.g., copyright for the whole site • Client setting; e.g., language preferences • HTTP response header • Previous versions of the page • Services; immediate, nearly immediate (e.g., PDF in Wikipedia) and deferred 4.6.2 Mechanisms for getting the variant It is related to how one want to use the variant: • Browser side - headers: Response header and document header. It is for populating browser facilities such as the language button. Only items in the HTTP header and appropriate formats (e.g., HTML) can be obtained; though TCN features are quite extensible • Server side - URI: in the response body, in different formats. Usually an HTML page. Items not allowed by the HTTP protocol might be included. Some items might be not immediately available. For example, the German language variant might be available in about one hour. 4.6.3 Variant URI It returns the variants for a particular URI. It has three dimensions: • Items: item set; e.g., only the languages. • Format: the format of the returned data. • Parameter: how to pass the parameter to the server The variant selector is the part of the variant URI used to indicate the combination of the above dimensions. For example, http://example.com/var returns all allowed items by the server as a microformat XHTML; the string var is the variant selector. Examples: • Microformat XHTML: Typically included pages as a link. In addition to human-machine (switching among languages), it can also be used like a web service for machine-machine. The selector is var/xhtml; abbreviated to var. • Languages: Only the languages in microformat XHTML and a few other essential items. The selector is var/xhtml/lang; abbreviated to var-lang. • XML: The selector is var/xml. • Plain text: The selector is var/text. • **PDF**: The selector is `var/pdf`. The parameter could be: - **Local URI**: `foo` - **Full URI**: `http://example.org/foo` The parameter can be sent to the server in the following ways: - **Referer**: the parameter is in the Referer header field; e.g., `http://example.com/var`. The same URI is used for obtaining the var of all URIs as the browser graciously provides the parameter. This mechanism greatly simplifies building MWS as having a different URI for each page is much harder. - **GET method**: the parameter is the query part; e.g., `http://example.com/var?foo` - **POST method**: the parameter is in the body; e.g., `http://example.com/var` and the body contains the string `foo`. - **Dedicated server**: the parameter is in the path; e.g., `http://meta.example.com/foo` Typically, the variant URI would be included in all the pages of a server. As a scenario, a user would click the var URI to obtain the variants; and select the appropriate navigation facility, such as another language. If the server does not know any of the languages requested and there is no default, it should present the appropriate language neutral variants to choose one language. It should be easy to have the variants in many languages. Reservation of magic strings: the path and third level domain starting with "var". For example, `http://example.com/var` or `http://var.example.com`. Next step: implement `http://example.com/var` returning languages in XHTML. ### 4.7 Browser side: variant button Browsers should contain a *variant button* (in the row with File, Edit, etc) for using the variants accessible through this mechanism. The variant button could become just a *language button* (i.e., dedicated just to the language) by changing the browser preference panel; e.g., the button could be labeled as *variant* or *language*. The variant button should become enabled when relevant; e.g., when other languages are available. A more economical approach from the server point of view would be to send the appropriate variant content only on request (when the user presses the variant button) or just send the *variant*. Again, these options could be chosen through the preference panel. There would be a long transition period and a server side mechanism would be needed in the meantime. The browser might inform the server that it has a variant or language button, perhaps in the *User-Agent* or *Expect* headers. The server might act accordingly. ### 4.8 Server side: variant page (XHTML) The variants would look like this small example: <table> <thead> <tr> <th>URI</th> <th>: <a href="http://example.com/foo">http://example.com/foo</a></th> </tr> </thead> <tbody> <tr> <td>This page available in</td> <td>: English, Spanish, French</td> </tr> <tr> <td>Copyright</td> <td>: Somebody</td> </tr> <tr> <td>Site copyright</td> <td>: <a href="http://example.com/copyright">http://example.com/copyright</a></td> </tr> <tr> <td>Your preferred languages</td> <td>: English, Spanish {add the cookie one}</td> </tr> </tbody> </table> Look at the XHTML example at [MR]. The page should be as a XHTML microformat. In particular, the languages should be links to the relevant variants for easy switching among language variants. Other dimensions could also be included; e.g., formats. The language of the variant should be per preferred language (TCN or cookie). Also, there should be a mechanism to change the language of the variant. 5. Server-content management (webmasters) 5.1. Webmaster Webmaster refers to all the aspect of the construction of MWS: author, translator, etc. The objective is the creation of high quality low cost MWS. Many existing applications have some multilingual facilities and (stating the obvious) one should harvest the best techniques around. Servers should expect the same API. The first API could be just a multilingual data structure. The absence of this data structure means that each application has to craft this facility; having the same data structure means that servers (or other programs) would know how to process this data structure directly. It is a case of production of multilingual parallel texts: the cycle *Authorship, Translation and Publication chain* (ATP-chain). The API between the CMS and the server is a general issue and not specific to MWS. 5.2. Multilingual data structure - All in one server - File extensions; e.g., foo.en.html, foo.es.html - One directory per language; e.g., en/foo.html, es/foo.html - Federation of servers, each server with one language; e.g., Wikipedia In the case of federated servers, one server could be dedicated to variants. Hence, a system is required to collect the data from the different servers, either on the fly or before hand. {TODO} Evolution to this approach: old links. 5.3. Generating language in parallel For the purpose of this section, the files in a server are classified as per these two scenarios: - **Navigation**: HTML mainly used for navigation with a few paragraphs. - **Big**: PDF with a few dozen pages. These are two extremes. The point is that there is no intention of addressing the general problem of generating complex thousand of pages document on high quality typography. The general approach should be to **generate all the linguistic versions in parallel**. So, an approach could be based on the following two components: - Skeleton - Language table: a list of key/values, where the values are language segments (typically a sentence) The intention is to replace each key in the skeleton by its value. In the case of HTML and XML, the keys could be entities. Example: - Input - Language table - Skeleton - Output pages - 100.en.html - 100.es.html Input language table <table> <thead> <tr> <th>Keys</th> <th>Values</th> </tr> </thead> <tbody> <tr> <td>Lang</td> <td>en</td> </tr> <tr> <td>Hello</td> <td>Hello world</td> </tr> </tbody> </table> Input skeleton ```html <html lang="&lang;"> <body> <p>&hello;</p> </body> </html> ``` Output file 100.en.html ```html <html lang="en"> <body> <p>Hello world</p> </body> </html> ``` Output file 100.es.html ```html <html lang="es"> <body> <p>Hola mundo</p> </body> </html> ``` ### 5.4. Skeleton This construction is format (MIME type) dependent; e.g., it can be done in HTML and XML, but it might not be done in other formats. ### 5.5. Language table The language table is an abstract construction: a list of key/value pairs, where the key is a unique identifier and the value a language segment. The language table can be implemented in at least the following ways: - Text files: one file per language; e.g., the line `k1` in `mytext.es.txt` - URI: e.g., `http://example.com/es/k1` - Database: e.g., SQLite 5.5.1 Key The language key is a unique identifier in each processing of the skeleton and language table, though it would be better to be unique at least across a system that could include a set of sites. The language keys in a skeleton could be abbreviated; e.g., http://es.example.com/k1 could be abbrevi- tated to just k1. The HTML generator program must know how to compose the full key; e.g., a parameter or a meta decla- ration in the skeleton. 5.5.2 Value A language value is whatever a language key points to; typically a sentence. But it could be in any format; e.g., a sound file. In this context, a sentence does not have any grammatical connotation: one can think of it as a string. 5.6. Author, Translation, Publishing chain (ATP-chain) in MWS • The author produces the skeleton and the source language values • The translator produces the other language values • A program generates the HTML pages in all the required languages 5.7. Generating techniques It could be: • Internal to the server • Dynamically; i.e., when the pages are requested • Generate the first time requested and keep until stale, for example because one of the entities has changed • Separated program • Batch; i.e., all in one go 5.8. Multilingual Web Content Management System • Describe a scenario • Assisted authorship • Compulsory summary style • Revision system • Modify source text following the output of revision system • At the very least, automatic summary • Interface to Computer-Aided Translation (CAT). • Minimise translations • Translation on demand • Translation after voting • Vote weighting • Translation could be human, machine, etc • Generalise for translation request management • Type of pages o Navigational: could include a short text o Documental: significant text • Automatic typography o SVG 6. Language neutral URIs - No extensions - Short - Flat, no hierarchy - Base 36 - Separation URI from storage 7. Background - Minimal primer - Gory details in primary sources - Wider context OAMPT 7.1. Transparent Content Negotiation (TCN) One URI can have several variants. For example, http://example.com/foo could have: - English in HTML - English in PDF - Spanish in HTML - Spanish in PDF Extensions address one particular variant Informally: - Variant list: list of available variants - Language variant list: list of available linguistic versions; a subset of a variant list Some of the HTTP header fields involved are: - Accept-Language - Content-Language - Alternate - Referer In addition to language and format (MIME type), there are other dimensions. For details (and strict definitions) have a look to the RFC Transparent Content Negotiation in HTTP [TCN]. Often, servers do not return the variant list. For example, Apache seems only to return the variant list with 406 Not Acceptable. One can make Apache to always return the variant list (in Alternate) by changing only one line in the source code and recompiling it (thanks to K. Holtman for pointing out the line). But the requirement is for parametrisation servers to return the variant list or subsets. For example: - VariantList All - VariantList Language - VariantList Language MediaType Note that these parameters do not exist in Apache. It is just an example and proposal. 7.2. Translation The greatest cost with MWS is translating: - Original pages - Corrections The public expect web sites to be up to date; errors are expected to be corrected immediately. This is very different from paper publications where the public expects errors to be corrected in the next edition. Hence, often one has to translate many linguistic segments (abbreviated to segment); a costly business as there is a fix overhead for each translation request, independently of the size. Indeed, most translation services are geared to the translations of full documents. 7.3. Authorship, Translation and Publishing chain (ATP-chain) ATP-chain is the cycle for multilingual publishing. Traditionally it was a one-way path: - Authorship: The author writes the source material - Translation: The translator(s) translate(s) into the target language(s) - Publishing: The typographer composes the publication In some cases, this chain could be two ways; e.g., the translator could send back the source material to the author with change requests to facilitate the translation. Also, one has marking from the beginning to automate the whole process. 7.4. Multilingual parallel text Multilingual parallel texts are translations of each other. For example, the Treaty of Rome in 23 languages. 7.4.1 Source and target languages The most common case is that the author writes in one source language and it is translated to other target languages. But it is not rare to have multilingual sources; e.g., a document with three chapters each written in a different language. Indeed, in the case of MWS it is quite common. For a legal point of view, one can have multilingual parallel texts where all the linguistics versions are considered source languages. 8. Legal and miscellaneous 8.1. Disclaimer This document represents only the views of the author and not necessarily the views of any other parties. In particular, it does not necessarily represent the opinion of the European Commission, his present employer. 8.2. Comments To send comments to the author and follow-ups see: http://dragoman.org/mws 9. References [DC] Dublin Core Metadata Element Set, Version 1.1 http://dublincore.org/documents/dces [EU] Europa Ello va seco y sin lluvia
{"Source-Url": "http://dragoman.org/mws/oamws.pdf", "len_cl100k_base": 4414, "olmocr-version": "0.1.53", "pdf-total-pages": 11, "total-fallback-pages": 0, "total-input-tokens": 22601, "total-output-tokens": 4864, "length": "2e12", "weborganizer": {"__label__adult": 0.0002913475036621094, "__label__art_design": 0.0016565322875976562, "__label__crime_law": 0.0003924369812011719, "__label__education_jobs": 0.0008740425109863281, "__label__entertainment": 0.00013697147369384766, "__label__fashion_beauty": 0.0001100301742553711, "__label__finance_business": 0.000431060791015625, "__label__food_dining": 0.0002343654632568359, "__label__games": 0.00040531158447265625, "__label__hardware": 0.0004432201385498047, "__label__health": 0.00020742416381835935, "__label__history": 0.00034689903259277344, "__label__home_hobbies": 5.441904067993164e-05, "__label__industrial": 0.00024819374084472656, "__label__literature": 0.0007901191711425781, "__label__politics": 0.00032520294189453125, "__label__religion": 0.0004267692565917969, "__label__science_tech": 0.014739990234375, "__label__social_life": 0.00010335445404052734, "__label__software": 0.040069580078125, "__label__software_dev": 0.93701171875, "__label__sports_fitness": 0.0001366138458251953, "__label__transportation": 0.0002522468566894531, "__label__travel": 0.0002027750015258789}, "weborganizer_max": "__label__software_dev", "avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_ratio": [[0, 19090, 0.01834]], "fineweb_edu_fasttext_gt2__fineweb_edu_fasttext_gt2__score": [[0, 19090, 0.66459]], "ft_lang_id_en_doc_v2__ft_lang_id_en_doc_v2__en": [[0, 19090, 0.8469]], "google_gemma-3-12b-it_contains_pii": [[0, 2665, false], [2665, 4791, null], [4791, 7071, null], [7071, 9903, null], [9903, 12343, null], [12343, 13569, null], [13569, 15387, null], [15387, 16863, null], [16863, 19065, null], [19065, 19065, null], [19065, 19090, null]], "google_gemma-3-12b-it_is_public_document": [[0, 2665, true], [2665, 4791, null], [4791, 7071, null], [7071, 9903, null], [9903, 12343, null], [12343, 13569, null], [13569, 15387, null], [15387, 16863, null], [16863, 19065, null], [19065, 19065, null], [19065, 19090, null]], "google_gemma-3-4b-it_v2tag__is_academic_paper": [[0, 5000, true], [5000, 19090, null]], "google_gemma-3-4b-it_v2tag__is_class_syllabus": [[0, 5000, false], [5000, 19090, null]], "google_gemma-3-4b-it_v2tag__is_completion_certificate": [[0, 5000, false], [5000, 19090, null]], "google_gemma-3-4b-it_v2tag__is_court_notice": [[0, 5000, false], [5000, 19090, null]], "google_gemma-3-4b-it_v2tag__is_homework_assignment": [[0, 5000, false], [5000, 19090, null]], "google_gemma-3-4b-it_v2tag__is_news_article": [[0, 5000, false], [5000, 19090, null]], "google_gemma-3-4b-it_v2tag__is_public_order": [[0, 5000, false], [5000, 19090, null]], "google_gemma-3-4b-it_v2tag__is_resume_cv": [[0, 5000, false], [5000, 19090, null]], "google_gemma-3-4b-it_v2tag__is_test_or_quiz": [[0, 5000, false], [5000, 19090, null]], "google_gemma-3-4b-it_v2tag__is_textbook": [[0, 5000, false], [5000, 19090, null]], "pdf_page_numbers": [[0, 2665, 1], [2665, 4791, 2], [4791, 7071, 3], [7071, 9903, 4], [9903, 12343, 5], [12343, 13569, 6], [13569, 15387, 7], [15387, 16863, 8], [16863, 19065, 9], [19065, 19065, 10], [19065, 19090, 11]], "pipe_delimited_lines_v1__pipe_delimited_lines_v1__pipe_delimited_lines_ratio": [[0, 19090, 0.03623]]}
olmocr_science_pdfs
2024-12-10
2024-12-10
444d9a6605b9fc733d412d9b8edfa24c9cedbbfd
Behavioral an real-time verification of a pipeline in the COSMA environment Jerzy Mieścicki, Wiktor B. Daszczuk* Institute of Computer Science, Warsaw University of Technology, Nowowiejska 15/19, PL 00-665 Warsaw, Poland Abstract The case study analyzed in the paper illustrates the example of model checking in the COSMA environment. The system itself is a three-stage pipeline consisting of mutually concurrent modules which also compete for a shared resource. System components are specified in terms of Concurrent State Machines (CSM) The paper shows verification of behavioral properties, model reduction technique, analysis of counter-example and checking of real time properties. 1. Introduction In [1] we have described the functional model of a system for processing of consecutive portions of data (or messages) submitted to its input. Each message goes through the three stages of processing which is reflected in the system structure (Fig. 1). The system is a three-stage pipeline consisting of three modules that operate concurrently and asynchronously, in a sense that there is no general, common synchronizing process or mechanism. Moreover, two out of three modules compete for the access to the common resource, which is accessed also by some other (unspecified) agents from the system environment. This calls for the verification if the cooperation among system components is correct. Indeed, due to potential coordination errors the system can get deadlocked, messages can be lost or duplicated etc. After the behavior is proved correct, some real-time performance features may be formally analyzed: minimal and maximal time of given actions, time intervals between events etc. It is known that in the case of asynchronous and concurrent systems behavioral errors are extremely hard to discover, identify and correct using typical debugging and testing procedures. Therefore, we have applied a formal procedure of model checking [2-5], using the software tool called COSMA [6], *Corresponding author: e-mail address: W.Daszczuk@ii.pw.edu.pl implemented in the Institute of Computer Science, Warsaw University of Technology. Model checking is based on the following principle. Given the finite state model $M$ of system behavior and property (requirement) $p$ to be checked, one has to check if $p$ holds for $M$. Usually, there is a set of techniques and algorithms (making together the model-checking environment or tool) designed for this purpose. This is a designer’s job to formulate properties to be evaluated: usually the verification involves a set of model checking experiments with several properties $p_i$. Additionally, if the given property does not hold for $M$, then so-called counterexample is provided which allows to identify the sequence of states (or events) that results in this negative evaluation. This helps to identify and correct the cause of an error. The main limitation the model checking faces is the exponential explosion of model’s state space size along with the increase of the number of finite state system components and their individual state spaces. So, an extensive research is being done on various techniques that can help to manage the problem. First, multiple forms of reduction of state space are proposed, aimed at removal of the states and transitions which are irrelevant w.r.t. the evaluation of a given formula. The other approach is to calculate the state space just during the evaluation, as one can expect that in order to obtain the outcome of the evaluation only the bounded model will do. Still another technique consists in compositional model checking, where some individual parts of a system (of more acceptable size) are subject to an exhaustive state space search while the conclusion as to the behavior of a whole system is reached by some logical reasoning. Unfortunately, most ideas of reduction found in literature (e.g. [7,8]) usually cannot be applied for Concurrent State Machines. This model admits coincident execution of actions rather than their interleaving, while most finite state models assume just the interleaved executions. Also, other known forms of reduction (e.g. slicing and abstraction [9-11]) make the use of specific properties of programs and can not be applied directly to more abstract CSM models. In this paper we briefly describe three techniques used in a COSMA-style methodology of system verification. First, we will analyze the system behavior step-by-step, using so-called multi-phase reduction [12,13] which exploits some compositional features of the CSM model [14]. As a result, the system which (as naively estimated) may have as much as $4\times10^{14}$ states is finally reduced to a model of 323 states and 1406 edges, easily representable and algorithmically checkable in a split second. Then, as some properties proved to be evaluated to false, we illustrate how the counterexample can be obtained and analyzed. Finally, using timed version of the model, we present how real time dependencies may be analyzed. 2. Two-phase procedure of obtaining the reduced reachability graph Let us recall the basic facts about the CSM model of a pipeline, described in more details in [1]. It consists of three complex modules and three individual components (data source, data sink and the arbiter) common to the whole system. Each module can be internally subdivided into six components (see also left-hand part of Fig. 2). In total, this makes a set of 21 cooperating components. For each of them, a separate (finite state) CSM model has been developed, aimed at specifying its behavior as well as the communication to/from its communication partners. The goal was to obtain the large system’s behavioral model or a graph of reachable system states, containing all the reachable states and possible execution paths among them. Then, some temporal formulas representing desirable behavioral properties of the system have been evaluated (true or false). In [1] the emphasis was put on the specification of components and temporal properties, while the technique of obtaining the product of all the components was not analyzed. Now we proceed to the method of determining the system’s behavioral model that can (to an extent) help to cope with problems of the graph size. The main idea devoted to is the following. In order to obtain a system behavioral model, one has to perform the product ($\otimes$) of CSM models of system components. This operation is associative and commutative. Associativity supports the important compositional property. Now, if we have – for instance – a system $Z = \{m, n, p\}$ of three components, then (due to the associativity) we can obtain the behavioral model either immediately, as a ‘flat’ product $\otimes Z = m \otimes n \otimes p$ or in two steps: first computing the local product of some subsystem e.g. $r = m \otimes n$, then $\otimes Z = r \otimes p$. Meanwhile, before the second, final product is obtained, we can apply some reduction procedure to the partial product $r$. While the associativity of the product applies to other finite state models as well, this reduction makes the use of intrinsic features of CSM model... itself. If machines $m$ and $n$ do communicate intensively with each other – it may result in a considerable reduction of a total computational effort, necessary for the computation of $\otimes Z$. Below, we show how this general rule applies to our system of 21 components, briefly recalled above. We will proceed in the two steps or phases. Generally, each phase consists in the selection of some subsystem, obtaining its CSM product and removing the irrelevant states and edges from it. However, one has to decide first which elements of the model are relevant ones and therefore have to be preserved. Relevant – in this sense – are the selected output symbols (produced by individual system components) and thus also the system states in which these symbols are generated. Typically, among relevant symbols are: 1. symbols that are referred to in the temporal formulas to be evaluated, 2. symbols that should be preserved for designer’s convenience, e.g. because they make the complex behavior more readable, 3. symbols that are necessary from the viewpoint of the communication among the currently reduced subsystem and remaining components\(^1\). The former two groups of symbols are decided upon by the designer while the latter one is determined by the specification of system components. Assume that in our case the relevant symbols of types 1 and 2 above are the following ones: \[ msg_1, msg_4, doProc_1, doProc_2, doProc_3 \] In order to obtain the ‘phase-1’ model of our example system we perform the following procedure: **Phase-1** 1. take a subsystem, consisting of the six components of module #1 (Fig. 2), 2. compute its CSM product, 3. reduce it, leaving as the relevant output symbols the following ones: - all the output symbols (from the subsystem) which are ‘watched for’ by the subsystem communication partners (i.e. the Arbiter, Trsm_0, Rcv_2), - symbols from the set selected above, which are produced within module #1 (this case: doProc_1), 4. repeat the above for modules #2 and #3 obtaining Subsystem_2 and Subsystem_3 (respectively), 5. Substitute subsystems 1, 2, 3 in the place of just processed components. --- \(^1\)Note that among the ‘remaining components’ can be also the additional, auxiliary automata (e.g. Invariant, in our case) necessary for expressing the properties under checking. This way we obtain the phase-1 structural model, in which subsystems 1, 2 and 3 are replaced by single automata. It is noteworthy that for Subsystem_1: - Cartesian product of its six components has 24300 states, - CSM product (before reduction) has 24 reachable states and 31 edges, - after reduction, Subsystem_1 is a graph of 10 states and 16 edges. For Subsystem_3, the situation is analogous. As an illustration, the reduced CSM product of six components making Subsystem_3 (Main_3, Rcv_3, Trsm_3, Proc_3, InpQ_3, OutQ_3) is shown in Fig. 3. At no surprise, it has 10 states and 16 edges, the same as Subsystem_1. For Subsystem_2 (not shown), there are as few as 7 states and 12 edges. Now, the analogous procedure can be applied again to the structural elements of the reduced model, for instance: Phase-2 – Apply the procedure to a subsystem consisting of Subsystem_1 and Trsm_0, preserving all the output symbols which are ‘watched for’ by the communication partners (i.e. Arbiter and Subsystem_2) and symbols needed for temporal formulas to be evaluated (this case: doProc_1 and msg_1); – and to a subsystem consisting of Subsystem_3 and Rcv_4, preserving ‘watched for’ symbols (i.e. Arbiter and Subsystem_2) and symbols for model checking (this case: doProc_3 and msg_4); – finally substitute Syst_1_Trsm_0 and Syst_3_Rcv_4 in the place of just processed components. This way we obtain the phase-2 structural model as in Fig. 4. Notice that the phase-2 system now consists of four components (instead of 21 components of phase-0 structural model), each of significantly reduced size. This ‘downsizing’ the model can be continued, but each time the reduction is performed certain conditions have to be met [12] so that the reduction is not necessarily guaranteed. Nevertheless, in practice the degree of reduction can be substantial. Let the CSM product of the system from Fig. 4 be called New_System and serve as the new behavioral model in which the temporal requirements are evaluated. New_System, obtained again with the COSMA Product Engine, has 323 states and 1406 edges and is expected to preserve at least these functional properties of the original, flat version which can be expressed in terms of symbols msg_1, msg_4, doProc_1, doProc_2, doProc_3. Fig. 4. Phase-2 structural model of the system 3. Verification of the reduced model To sum up, now we have two behavioral models of the same example system: – Flat-product (CSM product of 21 components, obtained as described in [1]) which had 8284 states and 34711 edges, – New_System, obtained in the above two-phase reduction procedure, with 323 states, 1406 edges. Both models have been verified in the COSMA environment. As in [1], an additional automaton Invariant was determined to conveniently specify the verified properties. The checked properties were the following: - Safety 1, saying – informally – that the number of messages within the pipeline never exceeds its capacity and the number of messages leaving the pipeline never exceeds the number of messages entering it, - Liveness 1, saying – informally – that for any system state it is possible that the pipeline eventually would get empty, - Liveness 2, saying – informally – that for any system state it is possible that the pipeline eventually would get full. Experiments have been performed on PC computer with 800MHz processor and 512 MB RAM. The results are summarized in Table 1. <table> <thead> <tr> <th></th> <th>Flat model</th> <th></th> <th>Reduced model</th> <th></th> </tr> </thead> <tbody> <tr> <td></td> <td>Result</td> <td>Evaluation time</td> <td>Result</td> <td>Evaluation time</td> </tr> <tr> <td>Safety 1</td> <td>true</td> <td>17 s</td> <td>True</td> <td>&lt; 1 ms</td> </tr> <tr> <td>Liveness 1</td> <td>false</td> <td>54 s</td> <td>False</td> <td>&lt; 1 ms</td> </tr> <tr> <td>Liveness 2</td> <td>false</td> <td>4 min 40 s</td> <td>False</td> <td>60 ms</td> </tr> </tbody> </table> Notice that both formulas referring to the liveness have been evaluated false in both (flat and reduced) models. This negative result means that the system may enter such a state (states) that – from this state on – the pipeline is never empty again (i.e. it never terminates the processing of messages) or is never able to process three messages at once, which it was designed for. The differences in evaluation times are really noteworthy: in all cases the ratio of $10^3\cdot10^4$ in favor of reduced model was achieved, even though in terms of state space size the reduced model is only approximately 25 times less than the flat one. Finally, the model verification can be summarized as follows: - The system itself performs wrong: there must be a synchronization bug in the specification of components. This calls for the analysis of a counterexample. - The reduced model well preserves the relevant properties of the primary, flat one. Indeed, each case the same temporal formula was evaluated the same way (true or false) in both models. - The multi-phase reduction method provides a significant gain in the evaluation time, even greater than the savings in the state space itself. - The advantages of the evaluation algorithm used in the COSMA tool have been also confirmed. The algorithm terminates the evaluation as soon as the result \((true, false)\) is certainly determined. It is why the evaluation times of rather similar formulas \((1)\) and \((2)\) differ by a few dozen of times. 4. Analysis of a counterexample In the case of negative evaluation, the TempoRG checker \([15\text{-}17]\) produces a counterexample. Often, it is a path (a sequence of states) in the reachability graph that leads to the state where it was decided that the temporal formula is to be certainly evaluated false. In the case of more complex temporal formulas involving several operators, the counterexample can be a tree \([15]\), showing which particular part of the formula (a sub-formula) is responsible for the negative result. Tracing the consecutive states along the counterexample, the designer is able to identify the synchronization bug. However, in the case of reduced models, the model states can be unreadable. As a result of reduction, some states are eliminated, the remaining ones are usually renamed etc., so that the analysis of counterexample should be based on the sequences of symbols (events) produced by the system instead of on sequences of states. The evaluation of both formulas representing the liveness condition yields the same counterexample, presented in Fig. 5. The counterexample itself pretends to be a CSM, in order to enable the use of animation feature of COSMA tool. Using it, one can trace the states of individual components (and their change) corresponding to consecutive states of an counterexample. Also, some additional symbols (not used in ‘regular’ CSM) are introduced as first elements of states’ output field. @ marks the starting state of the formula (in this case it is the system initial state) while F and G stand for the operators of sub-formulas \((G\) stands for \(AG\) and \(F\) stands for \(AF\)). ![Fig. 5. Counterexample to the formula \(AG AF\) in Invariant.s3](image-url) The counterexample is constructed as follows: – it begins in the starting state of evaluation (the initial state in this example), – it contains sub-paths responsible for sub-formulas (which may produce a tree-like counterexample), – for four states two successors are shown: one which leads towards an erroneous state (in which the error is possible, transition labelled with Error), the other one which leads to a ‘proper’ state (transition labelled with OK), – the fifth state in an upper sequence, namely $s1:Busy:m5:m2:n2:Cos$ is referred to as a Trap. The rules of constructing counterexamples [24] say that this state is a representative of so-called Ending Strongly Connected Subgraph (ESCS) of states in which the most nested formula $(in Invariant.state; state \epsilon \{s0,s3\})$ is not satisfied. When the system falls into one of these states, the error is inevitable (the desired state state of Invariant is never reached). The analysis starts with finding the last one of states (in the sequence) that has two outgoing transitions: one labelled OK and the other labelled Error. This state is referred to as a Checkpoint. In the example, it is $(s1:Busy:m4:m2:n2:Cos)$, with two successors: $(s1:Busy:m5:m2:n2:Nic)$ as a ‘proper’ state and $(s1:Busy:m5:m2:n2:Nic)$ as a ‘wrong’ one. This time, the ‘wrong’ state is actually the Trap itself, but often it is only the initial state of a sequence of states which inevitably ends in a trap. Analysis of signals generated in the triangle {Checkpoint, its ‘proper’ successor, its ‘wrong’ successor} reveals the nature of error. We see that in the Checkpoint a request of access to the shared resource is generated (signal req_Access_1), and the resource is granted to another user (signal others is present). For this state, its ‘proper’ successor does not produce others, while in the Trap the symbol others is still present. So, OK-labelled transition (to a ‘proper’ state) is executed only if the signal others is withdrawn, otherwise the system chooses a transition to a ‘wrong’ state which leads to the Trap. In other words, the error is inevitable, if the request (req_Access_1) is issued while other users do use the shared resource. Actually, in the system the two-state dead-end subgraph (causing a livelock of the whole system) can be found. The system performs incorrectly because reqAccess_1 is not stored. Recall that in the CSM framework no implicit buffering of events is assumed: this should be provided by the model itself, e.g. by an additional (e.g. two-state) buffering component or by a simple modification of Proc_1. The same conclusion refers to the third module which accesses the shared resource as well. Both modules (#1 and #3) have been easily corrected and positively verified. Finally, we may add that the flat product of the corrected system has 8086 states, 33588 edges instead of 8284 states and 34711 edges of the (incorrect) flat product discussed in [1]. This confirms the observation that the better the synchronization is, the less is the behavioral model of a system. 5. Real-time dependencies Now we may convert automata to TSCM (Timed CSM, derived from CSM as Timed Automata [18,19]) by adding time constraints and clock resets on some transitions in automata $Proc_i$ and control units $Main_i$ (Fig. 2). All time dependencies are shown as multiples of a basic time period, a $tick$. The constraints in $Proc_i$ (Fig. 6) inform what is the minimal time of processing ($tim1$: by the constraint on the transition outgoing from the state $useshared$) and the maximal time ($tim2$: the constraint on self-loop of the state $useshared$). The constraints are based on a clock $Ti$ local to $Proc_i$. The fixed time of staying in states in $Main_i$ models delays in control unit. The clock is reset every time the automaton enters $useshared$. The constraints guarantee that the time of using a shared resource is finite. The constants $tim1_i$ and $tim2_i$, $tim1_i < tim2_i$, may be specific to subsystems 1,2 and 3. Auxiliary automaton which guarantees finite time of using the resource by others must be modelled (instead of the external signal $others$). Also, maximal time of a time period between generation of items should be specified. Fig. 6. Timed automaton $Proc_1$ Unfortunately, TCSM does not specify the succession relation unambiguously. The RCSM (Region CSM automaton) may be calculated from the product TCSM, following the rules given in [20]. Storing a timed automaton in the RCSM form allows the verification system to compute its products with various testing automata. For this purpose, rules for multiplication of RCSM automata were developed [20]. Based on the RCSM state space, a testing automaton may be constructed, as shown in Fig. 7. This automaton checks if a time period between two items on output of the whole system is \(<0,1), <1,2), <2,3) \ldots\) ticks. If we impose minimal and maximal time on the system, states violating the limits should produce the \textit{error} signal (period \(<1\) or \(>4\) in this case). Fig. 7. Testing timed automaton The presented verification should be completed by former tests for liveness and safety (but in the RCSM state space), because time constraints may change the behavior of the system and the results obtained for CSM may be no longer valid. 6. Conclusions The advantage of (Timed) Concurrent State Machines formalism is that in order to understand (or even to design) the behavioral specification of a system component one has to be familiar with only a few elementary notions: a state, a transition, an atomic symbol, a Boolean formula, a time constraint. Generally, the semantics of an individual CSM is not far from the conventional finite state machines or basic UML’s state diagram. However, given a collection of such CSM components, one can select a subsystem and obtain its product, representing (in one, large graph) all possible subsystem’s executions or runs. Consequently, the model of a system can be subject to formal model checking methods and techniques. This advantage is not provided by standard specification methods based on UML. Moreover, as we have shown, the COSMA software environment supports the additional functional features, like stepwise model reduction, defining behavioral invariants, imposing time dependencies etc., as well as the means for the analysis of counterexamples. This makes the (Timed) Concurrent State Machines (and COSMA tool) a good candidate for a convenient framework for preliminary specification of concurrent, reactive systems. Once verified and corrected, such a specification can be refined, enhanced and otherwise developed in other professional software development environments. Moreover, if some components are to be \textit{hardware} – implemented (which is often the case in embedded systems), the automata-like CSM specification is also close to common forms of behavioral specification of sequential circuits. This work has been supported by grant No.7 T 11 C 013 20 from the Polish State Committee for Scientific Research (Komitet Badań Naukowych). References
{"Source-Url": "https://journals.umcs.pl/ai/article/download/3061/2257", "len_cl100k_base": 5329, "olmocr-version": "0.1.53", "pdf-total-pages": 12, "total-fallback-pages": 0, "total-input-tokens": 31250, "total-output-tokens": 6840, "length": "2e12", "weborganizer": {"__label__adult": 0.00033664703369140625, "__label__art_design": 0.0004355907440185547, "__label__crime_law": 0.000431060791015625, "__label__education_jobs": 0.0006170272827148438, "__label__entertainment": 7.69495964050293e-05, "__label__fashion_beauty": 0.00016117095947265625, "__label__finance_business": 0.00021016597747802737, "__label__food_dining": 0.0003857612609863281, "__label__games": 0.0006470680236816406, "__label__hardware": 0.0013475418090820312, "__label__health": 0.0005865097045898438, "__label__history": 0.0002791881561279297, "__label__home_hobbies": 0.00012069940567016602, "__label__industrial": 0.0006642341613769531, "__label__literature": 0.00025725364685058594, "__label__politics": 0.00031828880310058594, "__label__religion": 0.0006008148193359375, "__label__science_tech": 0.0709228515625, "__label__social_life": 9.578466415405272e-05, "__label__software": 0.007534027099609375, "__label__software_dev": 0.91259765625, "__label__sports_fitness": 0.00038504600524902344, "__label__transportation": 0.0007481575012207031, "__label__travel": 0.00023353099822998047}, "weborganizer_max": "__label__software_dev", "avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_ratio": [[0, 26914, 0.03028]], "fineweb_edu_fasttext_gt2__fineweb_edu_fasttext_gt2__score": [[0, 26914, 0.5022]], "ft_lang_id_en_doc_v2__ft_lang_id_en_doc_v2__en": [[0, 26914, 0.90845]], "google_gemma-3-12b-it_contains_pii": [[0, 2066, false], [2066, 4155, null], [4155, 7192, null], [7192, 9534, null], [9534, 10339, null], [10339, 12177, null], [12177, 14763, null], [14763, 16661, null], [16661, 19430, null], [19430, 21487, null], [21487, 23484, null], [23484, 26914, null]], "google_gemma-3-12b-it_is_public_document": [[0, 2066, true], [2066, 4155, null], [4155, 7192, null], [7192, 9534, null], [9534, 10339, null], [10339, 12177, null], [12177, 14763, null], [14763, 16661, null], [16661, 19430, null], [19430, 21487, null], [21487, 23484, null], [23484, 26914, null]], "google_gemma-3-4b-it_v2tag__is_academic_paper": [[0, 5000, true], [5000, 26914, null]], "google_gemma-3-4b-it_v2tag__is_class_syllabus": [[0, 5000, false], [5000, 26914, null]], "google_gemma-3-4b-it_v2tag__is_completion_certificate": [[0, 5000, false], [5000, 26914, null]], "google_gemma-3-4b-it_v2tag__is_court_notice": [[0, 5000, false], [5000, 26914, null]], "google_gemma-3-4b-it_v2tag__is_homework_assignment": [[0, 5000, false], [5000, 26914, null]], "google_gemma-3-4b-it_v2tag__is_news_article": [[0, 5000, false], [5000, 26914, null]], "google_gemma-3-4b-it_v2tag__is_public_order": [[0, 5000, false], [5000, 26914, null]], "google_gemma-3-4b-it_v2tag__is_resume_cv": [[0, 5000, false], [5000, 26914, null]], "google_gemma-3-4b-it_v2tag__is_test_or_quiz": [[0, 5000, false], [5000, 26914, null]], "google_gemma-3-4b-it_v2tag__is_textbook": [[0, 5000, false], [5000, 26914, null]], "pdf_page_numbers": [[0, 2066, 1], [2066, 4155, 2], [4155, 7192, 3], [7192, 9534, 4], [9534, 10339, 5], [10339, 12177, 6], [12177, 14763, 7], [14763, 16661, 8], [16661, 19430, 9], [19430, 21487, 10], [21487, 23484, 11], [23484, 26914, 12]], "pipe_delimited_lines_v1__pipe_delimited_lines_v1__pipe_delimited_lines_ratio": [[0, 26914, 0.04959]]}
olmocr_science_pdfs
2024-12-09
2024-12-09
ec9b2a15c6e403c30f0548b7ca1a09fc1cd4ceb8
On Software Modernisation due to Library Obsolescence Gerasimou, Simos; Kechagia, Maria; Kolovos, Dimitris; Paige, Richard; Gousios, Georgios DOI 10.1145/3194793.3194798 Publication date 2018 Document Version Accepted author manuscript Published in WAPI'18 Proceedings of the 2nd International Workshop on API Usage and Evolution (WAPI 2018) Citation (APA) https://doi.org/10.1145/3194793.3194798 Important note To cite this publication, please use the final published version (if applicable). Please check the document version above. Copyright Other than for strictly personal use, it is not permitted to download, forward or distribute the text or part of it, without the consent of the author(s) and/or copyright holder(s), unless the work is under an open content license such as Creative Commons. Takedown policy Please contact us and provide details if you believe this document breaches copyrights. We will remove access to the work immediately and investigate your claim. On Software Modernisation due to Library Obsolescence Simos Gerasimou Department of Computer Science University of York York, UK simos.gerasimou@york.ac.uk Maria Kechagia Software Engineering Research Group Delft University of Technology Delft, The Netherlands m.kechagia@tudelft.nl Dimitris Kolovos Department of Computer Science University of York York, UK dimitris.kolovos@york.ac.uk Richard Paige Department of Computer Science University of York York, UK richard.paige@york.ac.uk Giorgos Gousios Software Engineering Research Group Delft University of Technology Delft, The Netherlands g.gousios@tudelft.nl ABSTRACT Software libraries, typically accessible through Application Programming Interfaces (APIs), enhance modularity and reduce development time. Nevertheless, their use reinforces system dependency on third-party software. When libraries become obsolete or their APIs change, performing the necessary modifications to dependent systems, can be time-consuming, labour intensive and error-prone. In this paper, we propose a methodology that reduces the effort developers must spend to mitigate library obsolescence. We describe the steps comprising the methodology, i.e., source code analysis, visualisation of hot areas, code-based transformation, and verification of the modified system. Also, we present some preliminary results and describe our plan for developing a fully automated software modernisation approach. CCS CONCEPTS • Software and its engineering → Software libraries and repositories; Software evolution; Maintaining software; KEYWORDS application programming interfaces; software libraries; library evolution; software modernisation; visualisation 1 INTRODUCTION Modern software development practices advocate the use of third-party libraries as a means of improving maintainability, usability and dependability of software systems [7]. Many of these libraries aggregate functions and services, and expose endpoints, i.e., Application Programming Interfaces (APIs), that enable interacting with the logic of the libraries. An API is considered an implicit agreement between a software system (client) and a third-party library (provider). Based on this agreement, software developers can integrate the library within their client systems and use the provided functions without needing to be aware of the underlying implementation logic. Despite the benefits accompanying the use of third-party libraries and their APIs, a strong dependency link is created with software systems using these libraries [2]. Since software systems and the libraries they are based on evolve independently, maintaining the system to a fully-functional state requires additional effort when changes to the libraries’ APIs violate the agreement. For instance, library evolution caused by new requirements or architectural changes can lead to API modifications that break compliance with client systems. Likewise, end-of-support of a software library can cause client systems to fall into “technology stagnation” unless they switch to another functionally-equivalent and actively maintained library. Similarly, the introduction of a competing library with improved functionality, better features and reduced overheads might urge software developers to consider adopting this new library in subsequent system versions. In order to avoid the imminent risks that arise from using obsolete libraries (e.g., unresolved bugs, susceptibility to cyber attacks due to security issues), developers typically sustain the effort of modernising their systems [13]. Nevertheless, modifying the system to start using a new library is a time-consuming, error-prone and, to a great extent, developer-driven task [2, 5]. Performing correctly this task includes identifying system instructions that must change, doing the necessary code changes and, finally, checking that the modernised system preserves its original functionality. As the size of the client system and the legacy third-party library increases, the effort required for performing these steps increases significantly [7]. We argue that developers can reduce significantly the manual effort spent for mitigating library obsolescence by adapting concepts and approaches from the areas of software visualisation and bug finding [5, 12]. For instance, visualisation paradigms can help developers to understand better the architecture of their systems and perform impact analysis. Software visualisation is an active research area, but with rather limited adoption in software development [8, 12]. Also, code-based and pattern-based transformation approaches can assist with automating code refactoring [2]. In this paper, we propose an end-to-end methodology that not only helps developers to assess the required effort, but also automates a great part of the modernisation task. In particular, the methodology involves analysis of the software system’s source code to extract hotspots, i.e., source code elements that invoke the legacy library, visualisation of these hot areas using the city metaphor [12], automatic source code transformation based on templates (patterns), population of the generated templates with suitable code, and, finally, verification of the software system and the transformed code. to establish that the functional and non-functional requirements of the resulting system are maintained. The remainder of the paper is organised as follows. In Section 2 we present an example for motivating our approach. In Section 3 we introduce the proposed approach for mitigating library obsolescence and describe a set of preliminary results. Finally, in Sections 4 and 5, we present related work and outline our conclusions and plans for future work, respectively. 2 MOTIVATING EXAMPLES We motivate our work using two examples in which library evolution introduced compatibility-breaking changes. The first example comes from TinyXML2\(^1\), the new version of the popular C++ XML parsing library. Even though the evolved library is more CPU and memory efficient than its predecessor, it is heavily redesigned and does not maintain backward compatibility. Figure 1 shows a relevant issue\(^2\) from the GitHub repository of the TinyXML project. These obsolescence issues caused modernisation problems to developers of client systems. Some developers performed the migration manually while others preferred to switch to another functionally-equivalent library; for instance, the FileZilla client (https://filezilla-project.org) started using pugiXML from version 12 onwards. Irrespective of the chosen solution, the effort required for updating the system was substantial (e.g., see FileZilla development diary\(^3\)). Second, we refer to the Lighttpd web-server library which is used by several high-traffic websites (e.g., Wikipedia, YouTube). Research in [4] found that an one-line change to one of the methods in the updated library (Listing 1), broke support for HTTP compression and crashed any client applications. Despite the minimal API changes, this new bug issue could push developers to undertake the effort and migrate their system to an alternative and more reliable library. Clearly, library and API changes affect the stability of client systems. We aim to assist developers by identifying the affected source code in client systems and simplifying the migration process. Listing 1: Lighttpd before and after update (as in [4]) ```c // Lighttpd before update for (h=0, i=0; i < etag->used; ++i) h = (h << 5)^(h >> 27)^((etag->ptr[i])); // Lighttpd after update for (h=0, i=0; i < etag->used; ++i) h = (h << 5)^(h >> 27)^((etag->ptr[i]); ``` \(^1\)http://www.grinninglizard.com/tinyxml2/index.html \(^2\)https://github.com/leethomason/tinyxml2/issues/440 \(^3\)https://tinyurl.com/y7stytn4 Figure 2: High-level overview of our methodology for mitigating library obsolescence. 3 SOFTWARE MODERNISATION APPROACH 3.1 Modernisation Methodology The high-level overview of our methodology is shown in Figure 2. Given as inputs the source code of the client software system and the API of the obsolete library, our methodology operates as follows. Initially, it starts a set of extraction transformations that enable source code analysis, and extraction of suitable metrics and abstract specifications from the legacy code. These metrics (e.g., total number of API invocations) are very important as they provide the means to establish and visualise the dependency level of the software system on the obsolete library. Also, the specifications are in a form suitable for reengineering. Then, through a code-based transformation step, our methodology uses the specifications to generate code based on templates (patterns). These templates are subsequently populated with suitable code that permit to start exercising the new library. Finally, verifying and validating the transformed code and the software system as a whole (e.g., running unit and integration tests) enables to check that both the functionality and properties of the modernised system are preserved. Stage 1: Source code parsing and analysis This automated stage focuses on parsing and analysing a set of input files, i.e., the source code corresponding to the client system and the API of the obsolete library. The parsing step comprises a series of actions including source code scanning and preprocessing, identification of language tokens, semantic analysis, name resolution and binding, and, finally, generation of various types of internal models, indexes and Abstract Syntax Trees (ASTs). Once parsing finishes, the extracted models and ASTs are analysed. This step enables to identify elements, i.e., files, classes, methods, and instructions, of the software system that access the obsolete library. Orthogonal to this process is the extraction of a similar set of elements from the library’s API that are used by the system. By combining and analysing the generated sets of elements we gain insight about the system and establish several dependency metrics. These metrics capture information about the system architecture including interconnections between software modules and dependencies with external libraries and components. Also, through impact analysis of the affected system elements we can establish a coupling degree between the software system and the obsolete library. The effectiveness of this stage depends on using a suitable scanning and parsing source code component. High-level programming languages (e.g., C/C++, Java, C#) come with publicly available and ready-to-use infrastructures that help with this task; see for instance, Eclipse CDT for C/C++ and Roslyn for C#. We use Eclipse CDT for our prototype implementation (Section 3.2). Stage 2: Visualisation of software metrics Manual source code inspection is challenging for complex systems with multiple dependencies, packages, classes, and methods (e.g., FileZilla has more than 300 C/C++ files and more than 130KLoC). To facilitate reasoning and effort estimation, we automatically generate interactive visual artifacts using the metrics produced during analysis. These artifacts provide a pictorial view of the system and help with system understanding. The benefits of using suitable visual metaphors both for assisting with software exploration and for reducing the cognitive load is widely accepted [1, 8]. Several visual metaphors have been proposed for representing static aspects of software (cf. Section 4). To the best of our knowledge, however, there is no prior research on visualising the dependencies of a software system on third-party libraries and using this information to guide software modernisation. We bridge the gap in existing research by adapting the semantics of available visualisation metaphors (e.g., Treemap, Code City [12]) to this problem. In our preliminary realisation (Section 3.2), we use Code City to represent software systems as three-dimensional cities with districts and buildings, and associate the extracted dependency metrics with visual properties of city components. The development team can study the produce interactive visual artifacts and carry out a risk analysis. The outcome of this study indicates how to best address the obsolescence issues. An estimate about the effort required for completing the modernisation can be also made. For instance, if extensive coupling is identified, it might be more sensible to investigate how to reduce its degree (e.g., by improving the system architecture) before proceeding with the remaining modernisation stages. Stage 3: Code-based transformation During this stage, the software system undergoes a three-step transformation in order to become compliant with the new library. The first step includes (1) the automated generation of an abstraction layer (e.g., using the adapter pattern) and its population with elements that delineate the usage of the obsolete library by the software system; and (2) the automated modification of commands in the affected system files to delegate the work to the generated abstraction layer instead of the obsolete library. In this way, our methodology minimises changes in the system’s source code. The next step involves the inference of mappings between the obsolete and new libraries [3]. A mapping rule comprises two sets of API commands that perform the same task, one from the obsolete library and the other from the new library. The outcome of this inference step is a list of mappings. Inferring likely API mappings is challenging and time-consuming, and its automation has been the focus of recent research [11]. The selection of a suitable technique depends on the characteristics of the considered libraries and the expertise of developers. For instance, static analysis and textual similarity techniques [9] can be used when the APIs of the libraries are, to a degree, similar. Alternatively, developers can resort to inspecting the documentation of these APIs and generating manually the list of mappings. Listing 2: Code fragment that maps the get attribute method in TinyXML to the equivalent methods in PugiXML ```c const char∗ XMLElement::getAttribute (const char∗ name, const char∗ value) const { return pugiXMLNode . attribute (name) . value () ; } ``` The final step involves populating the generated abstraction layer with suitable code fragments that invoke the new library. To achieve this, developers use the extracted list of mappings and write code within the placeholders in the abstraction layer. For instance, Listing 2 shows the TinyXML method (placeholder) for extracting the attribute from an XML element and the corresponding code fragment in PugiXML (https://pugixml.org); this relationship is one-to-many. Once this is done, the functionality that was previously done by the obsolete library is now undertaken by the new library. The level of difficulty for writing the relevant code fragments depends on the correspondence between the obsolete and the new library. Investigating the time and effort required for completing this task based on this correspondence is part of our future work. Stage 4: Verification and validation The next stage involves checking that both the functional and non-functional requirements of the evolved system (transformed and unaffected code) continue to hold. This includes running unit integration and system tests, or any other type of formal verification (e.g., use model checking to verify the absence of concurrency bugs). Special focus should be given to the amended system parts, i.e., the abstraction layer and affected components, as these parts are most likely to have introduced erroneous behaviour. The visual artifacts generated earlier can help developers to extract traceability information and decide where to spend most of their efforts. 3.2 Preliminary Realisation We present a prototype realisation of our methodology which is currently under development as an Eclipse plugin. To evaluate our approach, we use the FileZilla client v.11, a mature open-source C/C++ application, with a non-trivial code base and several functional and non-functional requirements. FileZilla uses a number of third-party libraries, including TinyXML for reading and updating XML files that keep server sites and interface-related properties. At first, we obtained the ASTs of the FileZilla source code using the parsing facilities provided by Eclipse CDT4. The automated analysis of these ASTs enabled the identification of hotspots, i.e., FileZilla code elements that access the legacy XML library. We also gained insight into the usage level of this library by the system. We adapted the code city metaphor [12] to visualise the information extracted during the analysis stage. Figure 3 shows a representation of FileZilla using our adapted city metaphor. We employ the basic metaphor semantics, i.e., represent an application as a city, a package/sub-package as a district/sub-district, and a class as a building. However, we introduce new semantics that help visualising the dependency level between the software system and the obsolete library, and capturing the hotspots. First, we use red-coloured buildings to show a class that invokes the obsolete library, i.e., an affected class. Second, we set the height of a red-coloured building 4https://www.eclipse.org/cdt Recent research has been focused on identifying issues that can break client applications’ source code, because of changes in used APIs. Jazek et al. studied this problem in real word programs and argued that better tools and methods need to support library updates in client applications [5]. Xavier et al. also investigated API changes that may break previously established contracts, resulting into software crashes [13]. They conducted empirical studies with real software projects, and they reported lessons for better library support and maintainability of client applications. Raemaekers et al. proposed a framework of metrics that can be used to measure the stability of a software library [10]. Based on insights from previous work and considering the challenges associated with mitigating library obsolescence, we develop a visualisation approach that can assist developers of client applications to improve software robustness. **Visualisation Techniques.** Software visualisation techniques are widely used in program comprehension; see for instance the recent survey in [8] about existing software visualisation approaches. This survey highlights the number of visualisation tools for supporting developers’ needs on dependency management. A few studies have attempted to provide visualisations of evolving software systems and their library dependencies. Kula et al. developed a heat-map metaphor, which can help maintainers to navigate to library dependencies and gives an overview of the users across the different versions of a library [6]. Wettel et al. have used the city metaphor to represent software projects and they conducted a controlled experiment with developers to examine how the subjects comprehend the structure of a program [12]. In addition to the existing related work, we are using the city metaphor to highlight areas of software projects using third-party libraries. **5 CONCLUSIONS** The increasing dependency of software systems on third-party libraries challenges system maintainability. Developers need guidance on identifying and modernising client source code that can be affected due to library obsolescence. We proposed a modernisation methodology that can help developers of client systems to maintain their source code when these obsolescence issues occur. Also, we introduced a visualisation approach, using the city metaphor, for visualising source code areas that invoke the legacy library. We demonstrated a prototype realisation of our methodology and applied it on the FileZilla client. In the future, we plan to provide a mechanism that can automatically adapt client source code to new versions of third-party libraries. We will also explore the automated test generation for the changed parts of client source code. **REFERENCES**
{"Source-Url": "https://pure.tudelft.nl/portal/files/48109742/wapi18.pdf", "len_cl100k_base": 4146, "olmocr-version": "0.1.50", "pdf-total-pages": 5, "total-fallback-pages": 0, "total-input-tokens": 14427, "total-output-tokens": 5316, "length": "2e12", "weborganizer": {"__label__adult": 0.0003292560577392578, "__label__art_design": 0.00020706653594970703, "__label__crime_law": 0.0002765655517578125, "__label__education_jobs": 0.0005240440368652344, "__label__entertainment": 3.695487976074219e-05, "__label__fashion_beauty": 0.00010442733764648438, "__label__finance_business": 0.00012540817260742188, "__label__food_dining": 0.00025391578674316406, "__label__games": 0.00032258033752441406, "__label__hardware": 0.0003619194030761719, "__label__health": 0.0002968311309814453, "__label__history": 0.00012010335922241212, "__label__home_hobbies": 4.249811172485352e-05, "__label__industrial": 0.00015878677368164062, "__label__literature": 0.00015914440155029297, "__label__politics": 0.0001609325408935547, "__label__religion": 0.00028395652770996094, "__label__science_tech": 0.001979827880859375, "__label__social_life": 7.18235969543457e-05, "__label__software": 0.004467010498046875, "__label__software_dev": 0.9892578125, "__label__sports_fitness": 0.00019741058349609375, "__label__transportation": 0.0002453327178955078, "__label__travel": 0.00014483928680419922}, "weborganizer_max": "__label__software_dev", "avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_ratio": [[0, 23408, 0.03759]], "fineweb_edu_fasttext_gt2__fineweb_edu_fasttext_gt2__score": [[0, 23408, 0.28041]], "ft_lang_id_en_doc_v2__ft_lang_id_en_doc_v2__en": [[0, 23408, 0.87429]], "google_gemma-3-12b-it_contains_pii": [[0, 1283, false], [1283, 6599, null], [6599, 11823, null], [11823, 18679, null], [18679, 23408, null]], "google_gemma-3-12b-it_is_public_document": [[0, 1283, true], [1283, 6599, null], [6599, 11823, null], [11823, 18679, null], [18679, 23408, null]], "google_gemma-3-4b-it_v2tag__is_academic_paper": [[0, 5000, true], [5000, 23408, null]], "google_gemma-3-4b-it_v2tag__is_class_syllabus": [[0, 5000, false], [5000, 23408, null]], "google_gemma-3-4b-it_v2tag__is_completion_certificate": [[0, 5000, false], [5000, 23408, null]], "google_gemma-3-4b-it_v2tag__is_court_notice": [[0, 5000, false], [5000, 23408, null]], "google_gemma-3-4b-it_v2tag__is_homework_assignment": [[0, 5000, false], [5000, 23408, null]], "google_gemma-3-4b-it_v2tag__is_news_article": [[0, 5000, false], [5000, 23408, null]], "google_gemma-3-4b-it_v2tag__is_public_order": [[0, 5000, false], [5000, 23408, null]], "google_gemma-3-4b-it_v2tag__is_resume_cv": [[0, 5000, false], [5000, 23408, null]], "google_gemma-3-4b-it_v2tag__is_test_or_quiz": [[0, 5000, false], [5000, 23408, null]], "google_gemma-3-4b-it_v2tag__is_textbook": [[0, 5000, false], [5000, 23408, null]], "pdf_page_numbers": [[0, 1283, 1], [1283, 6599, 2], [6599, 11823, 3], [11823, 18679, 4], [18679, 23408, 5]], "pipe_delimited_lines_v1__pipe_delimited_lines_v1__pipe_delimited_lines_ratio": [[0, 23408, 0.0]]}
olmocr_science_pdfs
2024-12-02
2024-12-02
90e4b3cff3ae38e774601b26331c81765cc0bae7
Question 1 – Buffer Management [4 parts, 19 points total] a) [10 points] Consider a database system with: - Three buffer frames (A, B, C), initially empty - A file of five disk pages (1, 2, 3, 4, 5). A sequence of requests is made to the buffer manager as described in the Request column (below). At certain times a Pin request is immediately followed by an Unpin request (represented as Pin/Unpin), but other times Pin and Unpin requests happen separately. Starting at time T4, fill in the table ON THE ANSWER SHEET showing the buffer contents after the completion of each operation using the CLOCK page replacement policy. Assume that at time T0 we initialize the clock hand to point to Buffer Frame A. To avoid checking the same frame twice in a row we always advance the clock hand after replacing a page. For each page indicate the page number and pin count (PC) If a page is unpinned, list the the reference bit (true or false i.e. max ref count = 1) If the entry in a column does not change from the previous time slot, leave it blank (2 points for each row; 1 point given if part of the change in the row was correct) <table> <thead> <tr> <th>Time</th> <th>Request</th> <th>Buffer Frame A</th> <th>Buffer Frame B</th> <th>Buffer Frame C</th> </tr> </thead> <tbody> <tr> <td>T1</td> <td>Pin 5</td> <td>5 PC = 1</td> <td>Empty</td> <td>Empty</td> </tr> <tr> <td>T2</td> <td>Pin/Unpin 2</td> <td>2 PC = 0; Ref = True</td> <td></td> <td></td> </tr> <tr> <td>T3</td> <td>Pin/Unpin 3</td> <td>3 PC = 0; Ref = True</td> <td></td> <td></td> </tr> <tr> <td>T4</td> <td>Pin 2</td> <td>2 PC = 1</td> <td></td> <td></td> </tr> <tr> <td>T5</td> <td>Pin/Unpin 4</td> <td></td> <td>4 PC = 0; Ref = T</td> <td></td> </tr> <tr> <td>T6</td> <td>Unpin 5</td> <td>5 PC=0; Ref = T</td> <td></td> <td></td> </tr> </tbody> </table> Question 1 – Buffer Management (Continued) For parts b-d, Consider a buffer pool of 3 frames, and a heap file of 10 pages. (3 points for each question; all or nothing) b) [3 points] Assume we scan the heap file twice from start to finish. Starting with an empty buffer pool, using an MRU replacement strategy, how many of the 20 page requests will be page hits (i.e., found in the buffer pool)? Answer: 3 c) [3 points] Now, consider the same scenario but instead using an LRU replacement strategy. Starting with an empty buffer pool, how would the buffer hit rate of LRU compare to that obtained with MRU (pick one): A) LRU is higher B) MRU is higher C) They have same hit rate Answer: B d) [3 points] A friend from a university known as “The Farm” suggests that from his experience plowing fields (on the Farm), that to scan the file twice, you should first scan forward (from page 1 to page 10) but then in the second scan, go backwards (from page 10 to page 1). With an initially empty buffer pool and using an LRU policy, how does the buffer hit rate of this “plowing” strategy compare to simply scanning the file twice in a forward direction? A) “Plowing” is higher B) “Plowing” is lower C) They have same hit rate Answer: A Question 2 – Join Operators [3 parts, 20 points total] When considering the costs of the various join methods, we considered only the number of IOs. A more accurate estimation would make a distinction between sequential IOs and random IOs, since random IOs tend to take much longer than sequential ones. For this problem, use the following tables: Relation A: 200 pages and 5 tuples per page = 1,000 tuples Relation B: 500 pages and 12 tuples per page = 6,000 tuples Assume that we only have 1 disk and that each table is stored in its own contiguous file but that the files are located in different places on the disk. Also, assume that we do not have to write the resultant tuples back to disk and that we don’t cache any pages in our buffer pool. a) [6 points] Consider the join of A and B using the naïve (record at a time) nested loops algorithm with A as the outer. What is the total number of IOs this join will require? [2pt] The formula for NNLJ is \([M] + |M||N| = 200 + 1000\times 500 = 500,200.\) Of the total number of IOs, how many are sequential IOs? [4pt] Each outer access will be random, as we’ll be coming from the end of the inner. Similarly, the first access of each inner pass will be random, since we came from the outer. Thus, we will have 200 random IOs for the outer and 1000 random IOs for the inner. This leaves 499,000 IOs as sequential. Of the total number of IOs, how many are random IOs? 1200 IOs as calculated above. The rubric for each of these sequential/random IO questions went like this: - +1 for sum of sequential and random being total - +3 for sequential or random IOs being right - +2 if you forgot to take the first IO of each pass as random, but otherwise right b) [6 points] Consider the join of A and B using the page-oriented nested loops algorithm with A as the outer. What is the total number of IOs this join will require? The formula for PNLJ is \([M] + |M||N| = 200 + 200\times 500 = 100,200.\) Of the total number of IOs, how many are sequential IOs? Following from 1a, we will have 200 random IOs for the outer and another 200 random IOs for the inner, leaving us with 99,800 sequential IOs. Of the total number of IOs, how many are random IOs? 400 IOs as calculated above. c) [8 points] Now let’s consider index nested loops join with A as the outer. We have an Alternative 2 index on Relation B with 3 levels, including the leaves and root. Assume that the join column is a primary key for B, so every tuple of A will match at most 1 tuple of B. How many IOs does it take to perform a single equality look up on the inner relation with this index? 3 IOs to get to the leaf level of the index. Since it’s alternative 2, we need to perform 1 more IO to get 4 IOs total. What is the total number of IOs this join will require? The formula for INLJ is \([M] + |M|(LookupCost) = 200 + 1000\times 4 = 4,200.\) Of the total number of IOs, how many are sequential IOs? Every IO will be random! Many people thought we’d have 200 or so sequential IOs, but note that for every outer page, we’re coming from having read some inner page, so these will be random as well. Thus, 0 sequential IOs. Of the total number of IOs, how many are random IOs? 4,200 IOs as calculated above. For this problem, we took off 2 points if you said there were 200 sequential IOs. Question 3 – Advanced SQL [4 parts, 15 points total] Your new social site for cute dogs from Midterm 1, aww-or-not.com, where users can signup their cute dogs, and then can start rating how cute a dog is on a scale from 1 to 10, has been a big success so you are now going to add some analytics queries to your site. Recall that aww-or-not.com has the following database tables. /* Table of users. */ CREATE TABLE Users ( user_id INTEGER NOT NULL, username TEXT NOT NULL, email VARCHAR(90) NOT NULL, PRIMARY KEY (user_id), UNIQUE KEY (email) ); /* Dogs. Each has a single owner. */ CREATE TABLE Dogs ( dog_id INTEGER NOT NULL, owner INTEGER NOT NULL, color TEXT NOT NULL, name TEXT NOT NULL, breed TEXT, age INTEGER, PRIMARY KEY (dog_id), FOREIGN KEY (owner) REFERENCES Users(user_id) ); /* Table of user ratings of cuteness for dogs. num_awwws is an integer from 1 to 10. */ CREATE TABLE Awwws ( voter INTEGER NOT NULL, dog INTEGER NOT NULL, num_awwws INTEGER NOT NULL, PRIMARY KEY (voter, dog), FOREIGN KEY (voter) REFERENCES Users(user_id), FOREIGN KEY (dog) REFERENCES Dogs (dog_id) ); a) [5 points] You want to show a list of the dogs and their average cuteness scores, but only for dogs who have received at least 10 votes. For each such dog, show the name of the dog, and the average score. The structure of the query is below but put your answer ON THE SEPARATE ANSWER SHEET: SELECT __________________ FROM __________________ WHERE __________________ GROUP BY__________________ HAVING_________________ SELECT name, AVG(num_awwws) FROM Dogs D, Awwws A WHERE D.dog_id = A.dog GROUP BY dog_id, name HAVING COUNT(num_awwws) >= 10 1pt for each line. b) [4 points] On the answer sheet (NOT HERE) write the letters for ALL the following queries that are guaranteed to return no more than 10 rows (one or more may be correct) A) SELECT dog FROM Awwws LIMIT 10; B) SELECT voter FROM Awwws WHERE dog IN (SELECT dog_id FROM Dogs LIMIT 10); C) SELECT DISTINCT(dog) FROM Awwws WHERE voter <= 10; D) SELECT num_awwws FROM Awwws GROUP BY num_awwws; Answer: A D (1pt for each option) B: selects all the voters for 10 dogs, which could be more than 10 C: There is no constraint on voter, and voters can rate multiple dogs. c) [3 points] You wanted a query to return the name of the user who has voted for the most dogs. The following query looks like it could do it, but it has a bug. On the answer sheet, briefly explain why the query below could return a wrong answer based on the schema above. SELECT username FROM Users U, Awwws A WHERE U.user_id = A.voter GROUP BY username ORDER BY COUNT(username) DESC LIMIT 1 Answer: Could return a wrong answer if multiple users have the same username. This would aggregate users with the same name together, which is a bug. (-1pt for a bug fix, but no explanation) d) [3 points] On the answer sheet – state in a single sentence what the following query returns. SELECT * FROM Users U WHERE U.user_id IN (SELECT voter FROM Awwws A GROUP BY voter ORDER BY COUNT(voter) DESC LIMIT 1) Answer: The user tuple of the user who has voted for the most dogs. (ties broken arbitrarily) **Question 4 – Query Optimization [5 parts, 22 points total]** Consider the following catalog info and statistics for the aww-or-not.com database: - Users, 200K tuples, 2K pages - Dogs, 500K tuples, 5K pages; age values in range [1, 20] - Awwws, 5000K tuples, 50K pages; 100k distinct dogs; num_awwws values in range [1, 10] Consider the following query: ```sql SELECT dog_id, FROM Dogs, Awwws WHERE dog_id = dog AND age < 5 AND num_awwws > 9; ``` **a) [4 points]** Estimate the result size (i.e., number of tuples) for this query. 4pts: for 100k, or 125k 2pts: for any answer that is off by a small factor, e.g., 500k, and for any answer that lists out the correct formula: \((\text{NTuple(Dogs)} \times \text{NTuples(Awwws)}) \times \text{RFs}\). **b) [4 points]** For part (a) we had to assume uniformly distributed values. Given the following histograms for the value distributions of Dogs.age and Awwws.num_awwws, respectively, what would be the estimated result size now? (You can still make the uniform assumption on dog ids) The histogram of **Dogs.age** (e.g., 9% of Dog tuples have age values in the range [11-12]): <table> <thead> <tr> <th>value</th> <th>1-2</th> <th>3-4</th> <th>5-6</th> <th>7-8</th> <th>9-10</th> <th>11-12</th> <th>13-14</th> <th>15-16</th> <th>17-18</th> <th>19-20</th> </tr> </thead> <tbody> <tr> <td>count</td> <td>20%</td> <td>20%</td> <td>15%</td> <td>10%</td> <td>10%</td> <td>9%</td> <td>7%</td> <td>7%</td> <td>1%</td> <td>1%</td> </tr> </tbody> </table> The histogram of **Awwws.num_awwws**: <table> <thead> <tr> <th>value</th> <th>1</th> <th>2</th> <th>3</th> <th>4</th> <th>5</th> <th>6</th> <th>7</th> <th>8</th> <th>9</th> <th>10</th> </tr> </thead> <tbody> <tr> <td>count</td> <td>1%</td> <td>3%</td> <td>5%</td> <td>6%</td> <td>8%</td> <td>20%</td> <td>30%</td> <td>15%</td> <td>10%</td> <td>2%</td> </tr> </tbody> </table> 4pts: for 40k 2pts: for any answer that is ⅖ of your answers from a), e.g., you got 500k for a) and 200k for this one, which means you know how to use the histogram. **c) [6 points]** Estimate the cost (in number of disk I/Os) of each step of the following plan for the given query. **Don’t use the above histograms for your estimations in this part!** i) OUTER: HeapScan on Dogs to select Dogs.age < 5; don’t write the output. 2pts: 5k ii) INNER HeapScan on Awwws to select num_awwws > 9; write the output to a temp file. iii) JOIN: Page-oriented nested-loop join, of (i) and (ii) 2pts: for 5M or 3.75M, but we give full credit to 5M + X and 3.75M + X, where X is a small additional cost in thousands for counting in the cost of i) or ii). d) [4 points] Consider the plan for part (c) above, but with the INNER being an on-the-fly selection rather than writing to a temp file. What is the total cost of the plan in this case? 4 pts: for 50M+5k, or 37.5M+5k; any answer with 50M + X or 37.5M + X gets full credit, where X is in thousands. 2 pts: for any answer that is off by a small factor, or any answer that is 10 times your answers in c iii). e) [4 points] Consider the 3-way join of Users, Dogs and Awws by their primary key/foreign keys. Give a join order that a System R-style optimizer would not evaluate in pass 3? 4pts: The answer should be None; every join order might be considered. Due to the ambiguity of the question, you get full credit as long as you write down a join order. Question 5 – Indexes [6 parts, 23 points total] It’s Election 2012! You have been tasked with designing and maintaining the DBMS used to register voters for today’s elections (don’t forget to vote!). Consider a table in your system that has the following schema: Voters(voter_id, age, name, address) Consider a B+ Tree index constructed on the age field. Given the current state of the B+ answer the following questions: NOTE: Each part of the question starts with the tree you are given! So the answer from part a. does not affect part b and so on. Note that the B+Tree is order d=2, which means that the minimum number of keys in a non-root node is 2, and the maximum is 4. a) [2 points] Which leaf nodes need to be examined to answer the range query to retrieve all data entries between 18 and 38 (both inclusive)? Node 2, Node 3, Node 4 -- 2 pts if all three nodes are listed, 1 pt for any two of them b) [5 points] Show the keys in the root node after inserting a data entry with key “47” into the tree. How many levels does the resulting tree have? Root node contains 20 32 42 46 - 3 pts // 1 point off if any key is missing Number of levels 2 - 2 pts c) [5 points] Starting with the original tree: Show the keys in the root node after inserting a data entry with key “26” into the tree. How many levels does the resulting tree have? Root node contains 32 - 3 pts Number of levels 3 - 2 pts d) [5 points] Starting with the original tree: Show the keys in the root node after deleting the data entry with key “42” from the tree. Remember that you need to preserve the “order d=2” constraint on the tree. How many levels does the resulting tree have? Root node contains 20 32 39 46 - 3 pts // 2 points for getting 39, 1 pt for the other entries Number of levels 2 - 2 pts e) [3 points] Write a short SQL query on Voters that can be answered efficiently with a clustered B+Tree index on age, but that could not take advantage of an unclustered B+Tree index on age. SELECT * from Voters where Voters.age > 18 and Voters.age < 40; Any range query gets 3 points Query selecting only 1 key (e.g age = 10) gets 0 points as performance depends on cardinality f) [3 points] Write a short SQL query on Voters that can be answered efficiently with a B+Tree on age, but that could not take advantage of an Extensible Hash index on age. SELECT * from Voters where Voters.age > 18 and Voters.age < 40; Any range query gets 3 points Any query which has ORDER BY age also gets 3 points GROUP BY age gets 0 points as hash index can be used for efficient aggregation as well
{"Source-Url": "https://tbp.berkeley.edu/exams/3671/download/", "len_cl100k_base": 4469, "olmocr-version": "0.1.53", "pdf-total-pages": 11, "total-fallback-pages": 0, "total-input-tokens": 21660, "total-output-tokens": 4953, "length": "2e12", "weborganizer": {"__label__adult": 0.0004520416259765625, "__label__art_design": 0.0003197193145751953, "__label__crime_law": 0.0004498958587646485, "__label__education_jobs": 0.00925445556640625, "__label__entertainment": 8.177757263183594e-05, "__label__fashion_beauty": 0.0001779794692993164, "__label__finance_business": 0.000812530517578125, "__label__food_dining": 0.0007495880126953125, "__label__games": 0.0009055137634277344, "__label__hardware": 0.0015411376953125, "__label__health": 0.0008711814880371094, "__label__history": 0.0005197525024414062, "__label__home_hobbies": 0.0002417564392089844, "__label__industrial": 0.001163482666015625, "__label__literature": 0.0004181861877441406, "__label__politics": 0.00023877620697021484, "__label__religion": 0.0005970001220703125, "__label__science_tech": 0.0440673828125, "__label__social_life": 0.0001436471939086914, "__label__software": 0.01555633544921875, "__label__software_dev": 0.919921875, "__label__sports_fitness": 0.00031948089599609375, "__label__transportation": 0.0007305145263671875, "__label__travel": 0.0002994537353515625}, "weborganizer_max": "__label__software_dev", "avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_ratio": [[0, 15314, 0.03635]], "fineweb_edu_fasttext_gt2__fineweb_edu_fasttext_gt2__score": [[0, 15314, 0.31627]], "ft_lang_id_en_doc_v2__ft_lang_id_en_doc_v2__en": [[0, 15314, 0.90588]], "google_gemma-3-12b-it_contains_pii": [[0, 1755, false], [1755, 3493, null], [3493, 5967, null], [5967, 6357, null], [6357, 7972, null], [7972, 8120, null], [8120, 9654, null], [9654, 11765, null], [11765, 12737, null], [12737, 14908, null], [14908, 15314, null]], "google_gemma-3-12b-it_is_public_document": [[0, 1755, true], [1755, 3493, null], [3493, 5967, null], [5967, 6357, null], [6357, 7972, null], [7972, 8120, null], [8120, 9654, null], [9654, 11765, null], [11765, 12737, null], [12737, 14908, null], [14908, 15314, null]], "google_gemma-3-4b-it_v2tag__is_academic_paper": [[0, 5000, false], [5000, 15314, null]], "google_gemma-3-4b-it_v2tag__is_class_syllabus": [[0, 5000, false], [5000, 15314, null]], "google_gemma-3-4b-it_v2tag__is_completion_certificate": [[0, 5000, false], [5000, 15314, null]], "google_gemma-3-4b-it_v2tag__is_court_notice": [[0, 5000, false], [5000, 15314, null]], "google_gemma-3-4b-it_v2tag__is_homework_assignment": [[0, 5000, false], [5000, 15314, null]], "google_gemma-3-4b-it_v2tag__is_news_article": [[0, 5000, false], [5000, 15314, null]], "google_gemma-3-4b-it_v2tag__is_public_order": [[0, 5000, false], [5000, 15314, null]], "google_gemma-3-4b-it_v2tag__is_resume_cv": [[0, 5000, false], [5000, 15314, null]], "google_gemma-3-4b-it_v2tag__is_test_or_quiz": [[0, 5000, true], [5000, 15314, null]], "google_gemma-3-4b-it_v2tag__is_textbook": [[0, 5000, false], [5000, 15314, null]], "pdf_page_numbers": [[0, 1755, 1], [1755, 3493, 2], [3493, 5967, 3], [5967, 6357, 4], [6357, 7972, 5], [7972, 8120, 6], [8120, 9654, 7], [9654, 11765, 8], [11765, 12737, 9], [12737, 14908, 10], [14908, 15314, 11]], "pipe_delimited_lines_v1__pipe_delimited_lines_v1__pipe_delimited_lines_ratio": [[0, 15314, 0.07179]]}
olmocr_science_pdfs
2024-12-09
2024-12-09
3c1d90a022e00d03e02a31a7d3211f189dc57165
The Role of Static Analysis in Heartbleed Jeff Sass The Role of Static Analysis in Heartbleed GIAC (GSEC) Gold Certification Author: Jeff Sass, jsass@adobe.com Advisor: Stephen Northcutt Accepted: February 12, 2015 Abstract The Heartbleed bug was one of the largest security vulnerabilities of 2014, not only because of the media attention it garnered but also because it affected over half a million web sites on the Internet. Because the bug was in OpenSSL, it affected web sites, VPN concentrators, client applications and mobile devices. This paper details what the Heartbleed bug is, how the details were disclosed, and how vendors responded to it. The role of static analysis in software quality is then discussed. How static analysis, specifically Coverity’s TAINTED_SCALAR heuristic, was improved to detect this bug will also be presented. Finally, how end users can protect themselves from similar vulnerabilities will be discussed. 1. Introduction Numbered security vulnerabilities known as Common Vulnerabilities and Exposures (CVEs), have been on the rise since the United States Computer Emergency Readiness Team (US-CERT) began tracking them in 1999. In 1999 there were 1,597 CVEs and in 2014 there were 9,526. On April 7, 2014, CVE-2014-0160 ("Vulnerability Summary for CVE-2014-0160", 2014) was disclosed. It “affected over half a million widely trusted web servers used on the Internet” (“Half a million widely trusted websites vulnerable to Heartbleed bug”, 2014). This vulnerability is commonly referred to as the Heartbleed bug (“The Heartbleed Bug”, 2014). In order to understand why the Heartbleed bug had such an impact on the Internet, we must first look at what Transport Layer Security (TLS) and Secure Sockets Layer (SSL) protocols are and how they work. TLS is used to secure communications between two endpoints. TLS is the successor to SSL although many references still use the SSL/TLS terminology. For this discussion of Heartbleed, the term TLS will be used throughout. TLS encrypts and decrypts packets of data as they flow between two endpoints. It does this so that eavesdroppers cannot spy on the data while it is in transit. There are many computing applications that require this type of message confidentiality. The most common example is when a web browser connects to a web site using https:// instead of http://. The reasonable assumption is, for that session, there are no eavesdroppers who are decrypting the traffic and stealing private information (i.e. credit cards, passwords or digital certificates). This assumption was proven to be incorrect in applications that used certain versions of OpenSSL containing the Heartbleed bug. 1.1. Incorporating Open Source Libraries When designing secure applications one of the first questions that must be answered is: should developers write their own cryptography library or should they use an open source one? In the earlier days of the Internet, there wasn’t a choice. Developers had to write their own. Modern software development however, should follow the advice from the SANS Institute top 25 most dangerous software errors. CWE-327 states to not use a broken or risky cryptographic algorithm. By only reading the title, a developer might think that the given advice means that developers should write their own algorithm. Jeff Sass, jsass@adobe.com On the contrary, the advice from MITRE and SANS (“CWE/SANS TOP 25 Most Dangerous Software Errors”, 2010) states: “Cryptography is just plain hard. If brilliant mathematicians and computer scientists worldwide can’t get it right (and they’re always breaking their own stuff), then neither can you.” Per this advice, when looking at cryptography libraries, developers should generally choose to use an existing algorithm and more specifically an implementation of that library that has been peer reviewed. Other factors to consider involve whether or not the library is actively developed, has a proven track record of quality, has an acceptable licensing agreement, and whether or not the library is open source. Some cryptography libraries are commercially available and some are open source. OpenSSL is open source and has a proven track record of fixing security vulnerabilities (“OpenSSL vulnerabilities”, 2014). Looking at the number of previous CVEs in OpenSSL’s vulnerability list might lead a developer to choose to write their own implementation of a cryptographic library. However the opposite is generally true. Because the OpenSSL team is actively fixing vulnerabilities, and has been for over a decade, they have established a level of trust that cannot easily be gained by a newly written library. Examining their CVE list before April 2014 would have led most developers to choose to incorporate the library instead of writing their own. Another aspect to consider is if the library is a commercial one or open source. Open source libraries provide the source code as well as the compiled binary. This gives developers the ability to inspect the source code as one way to help determine the level of quality. It is common for open source libraries to also contain unit tests to help prove the stated quality level. While open source libraries can never guarantee quality, nor can commercial libraries, being able to read the source code is additional data to help guide the decision. An experienced developer can determine within a few hours what the level of quality an open source library possesses. 1.2. Heartbeat Extension In order to understand the Heartbleed bug, we must first look at how TLS handshakes work. When a browser connects to a web server there is a handshake that occurs to establish the connection. Then depending on whether it is HTTP or HTTPS, the security of that connection is established. HTTP/HTTPS traffic is stateless by default. This means that once the data is sent, the connection ends. When there is more traffic to send, the connection must be reestablished and that requires that both computers go through another handshake process. Heartbeats were added to TLS as specified in RFC 6520 to “keep the connection alive without continuous data transfer” (R. Seggelmann, 2012). When the OpenSSL team added the heartbeat extension feature, they turned it on by default. Developers have the option to compile with the -DOPENSSL_NO_HEARTBEATS compiler flag to disable it; however, the OpenSSL developers made the design decision to turn on the Heartbeat extension by default. This Heartbeat extension is what keeps the connection open. Heartbeat protocol messages have four parts: HeartbeatMessageType, payload_length, payload, and padding. As long as the client continues to receive a HeartbeatResponse to match the HeartbeatRequest the connection is maintained. When the server receives the HeartbeatRequest it responds with a HeartbeatResponse with an “exact copy of the payload of the received HeartbeatRequest” (“OpenSSL Heartbeat Vulnerability”, 2014). Normally the confidentiality of the payload is not compromised. 1.3. Heartbeat vulnerability When the Heartbleed bug is exploited, the attacker will create a specially crafted HeartbeatRequest. This request will shrink the payload to a smaller value, possibly as small as 1 byte, and set the payload_length to something larger up to 65,535 bytes. According to page 5 of RFC 6520 (Seggelmann, 2012), the implementation of the specification should have discarded the HeartbeatMessage. “If the payload_length of a received HeartbeatMessage is too large, the received HeartbeatMessage MUST be discarded silently.” Instead of discarding the HeartbeatMessage, the OpenSSL implementation placed the message into memory at the size specified by the specially crafted request. This is where the bug occurred. Jeff Sass, jsass@adobe.com When a software library takes input from end users and puts it into memory without checking the parameters, this input is called tainted input. The OpenSSL implementation trusted the payload_length parameter from the client without checking the actual size of the payload. This is a violation of CWE-807: Reliance on Untrusted Inputs in a Security Decision (Christey, "2011 CWE/SANS Top 25 Most Dangerous Software Errors"). The OpenSSL library looked in the server’s memory at the address of the payload and then copied the section of memory up to the attacker’s specified payload_length. This could be up to 65535 bytes. That memory was then returned in the HeartbeatResponse. The attacker now has access to whatever was stored in the web server’s memory at that specific time. This could include user names, passwords, or possibly the encryption keys that were used to establish the secure connection. There is nothing preventing the attacker from repeating this attack in an attempt to continue to steal confidential data from the server’s memory. Since the exchange of data happens during the initial handshake part of the protocol, “exploitation of this bug does not leave any trace” in the webserver logs (“The Heartbleed Bug”, 2014). Dr. Bagley referred to this process as “a bit like panning for gold” (Bagley, 2014). Researchers reviewed the logs of passive Internet taps and did not find any large-scale evidence of Heartbleed exploits up to April 7. On April 8, they did discover “subsequent exploit attempts from almost 700 sources” (Durumeric, 2014). This shows that Heartbleed was extremely easy to exploit, and attackers used tools like Metasploit’s pen-testing modules to attack servers immediately after the disclosure. 2. Heartbleed discovery Jeff Sass, jsass@adobe.com The Google team notified the OpenSSL team initially while the Codenomicon team notified the National Cyber Security Centre Finland (NCSC-FI) who then asked the CERT Coordination Centre for a CVE number. Codenomicon then registered the heartbleed.com domain, created the Heartbleed logo, and reported the bug to a member of the OpenSSL team (ironically a Google engineer named Ben Laurie). The member then forwarded the information to the entire OpenSSL team. Because two independent sources disclosed the bug within the same period of time, a patch was released later that day on April 7, 2014 instead of trying to perform a more coordinated rollout. A more detailed timeline is available from Ben Grubb of the Sydney Morning Herald (Grubb, 2014). 3. Heartbleed Response Hundreds of news reports and articles were posted on the Heartbleed bug. These quickly spread through the security community and media outlets. 3.1. Security Community Response Dr. Johannes Ullrich of SANS posted details of Heartbleed to the Internet Storm Center (Ullrich, 2014). Jake Williams, while speaking at the SANS 2014 conference, recorded a webcast to the SANS webcast archive (Williams, 2014). He also referenced that a Heartbleed testing module for Metasploit, a pen testing tool used to test and exploit vulnerabilities, was posted to GitHub (n.d.). The lynda.com training site also posted two training videos, “Heartbleed Tactics for Small IT Shops” (Gassner, 2014), and “Protecting Yourself from the Heartbleed Bug” (Seeley, 2014). The security community understands how to respond to security vulnerabilities and ensure the information is accurate and sent to the necessary professionals. 3.2. Media Response When examining the mass media response, two examples stand out: the nightly comedy show, The Colbert Report, and the web comic xkcd. On the April 8 episode, Stephen Colbert starts his show by taping a laptop with duct tape and twine and placing a mousetrap on top of the box in order to “secure his data”. He goes on to say: “The Internet was supposed to be a lawless frontier where all of humanities desires and vices merged into a royally connected id held in check by a barely regulated rats-nest of technical abstractions I don’t understand. How did that get out of control?” A graphical description of the Heartbleed bug was from the xkcd web comic. It was used because of its simple explanation showing how the vulnerability works (“xkcd: Heartbleed Explanation”, 2014). The comic medium was used effectively to quickly show the vulnerability. The combination of these and other media responses highlights a recent need to explaining security concepts to the masses in an accurate, approachable way. 3.3. OpenSSL Response The OpenSSL team responded by fixing the bug and posting the details on their vulnerability page at http://openssl.org/news/vulnerabilities.html. The patch was released in version 1.0.1g and 1.0.2-beta2 of their library. Performing a diff on the tlsl_process_heartbeat() function in the t1_lib.c files from OpenSSL 1.0.1f and 1.0.1g shows how the bounds check of this memory over-read was added. 1.0.1g was released to the public on April 7, 2014 (“OpenSSL vulnerabilities”, 2014). 3.4. Vendor Response Vendors began reviewing their client and server machines to determine if they contain the vulnerable version of OpenSSL. If the vulnerable version was found the vendor issued a patch via their normal software update process. For running webservers an additional best practice was needed to “reissue a new private key and expire all active user sessions” (Williams, 2014). Client applications should update their applications with a non-vulnerable OpenSSL library. 3.5. End-User Response The recommendation from “The Heartbleed Bug” (2014) was to change your password, but only after you have verified that the server you are connecting to has already applied the patch and re-issued their digital certificates. 3.5.1. Changing passwords End-users can check https://lastpass.com/heartbleed/ or similar sites linked from security researcher Brian Krebs’ blog post (Krebs, 2014), to determine if a web site is still vulnerable. If end-users changed their password before the site was patched, then the act of visiting the site and changing your password would incur a higher likelihood of putting the user’s password in the web server memory. This act of changing the password could then be exploited compared with a user who didn’t change their password during this initial rush of disclosure and patching. Brian Krebs gave the following advice, “It certainly can’t hurt to change your password now and then again next week.” (Wood, 2014). 3.5.2. Password Managers For a modern Internet user, asking them to reset their password on all sites that were listed as vulnerable can be very time consuming. To follow Brian Krebs’ advice and reset them two times could easily result in hundreds of password changes for an average Internet user. The advice of many security professionals, including L. Newman (2014) is to setup a password manager. A password manager helps you in two ways. First, they keep track of all of the passwords you use so you are not tempted to write them down in a non-secure location. Second, the generate feature will automatically assign a long, unique, and random password for each site you visit. This will ensure that the password you change to is strong. Because of the wide media coverage of Heartbleed, many users started using password managers to help organize their digital lives and make the process of changing passwords much easier if another vulnerability occurs. 4. Static Analysis Now that the mechanics of Heartbleed have been presented, we turn to the role of static analysis in software quality. Static analysis is the process of determining code quality without executing the program. Static analysis tools trace all of the possible branches of the code without executing it. In contrast, dynamic analysis works by analyzing executing code. Dynamic analysis techniques used to find Heartbleed are discussed further in Dr. Wheeler’s paper “How to Prevent the Next Heartbleed” (Wheeler, 2014). Janet Gregory and Lisa Crispin have written two books on agile testing (Crispin, L., & Gregory, J., 2009) and (Gregory, J., & Crispin, L., 2014). In chapter 8 of their later book, “More Agile Testing”, an updated version of the agile testing quadrants is presented and shown below in Figure 1. ![Agile testing quadrants](image) Security testing falls into Q4 in the bottom right and is influenced by technology-facing tests that critique the product. Security tests are in the same quadrant as performance and load tests and a category called “ilities” (e.g. reliability, interoperability, scalability). In their first book “Agile Testing”, the authors state: Jeff Sass, jsass@adobe.com “However, there are many tasks that need specialized knowledge. A good example is security testing... We’re talking about probing for external security flaws and knowing the types of vulnerabilities in systems that hackers exploit. That is a specialized skill set.” (Crispin, L., & Gregory, J., 2009) Software development teams have the challenge of balancing the amount of effort they spend on each of the testing quadrants. Focusing on the customer experience should guide all of these trade-off decisions on product development teams. Teams also need to evaluate which of the quadrants will give the most “bang for the buck”. If there is a dedicated quality engineering team then the responsibility for testing items in the higher quadrants generally falls to them. Because security testing is in Q4 and requires specialized skills, historically this work is either outsourced to a third party vendor or not done at all. Luckily, in recent years, there has been a sharp increase in the number of security jobs at technology companies and many are now choosing to grow this specialized set of skills in-house. Adobe uses a mix of all three types of security resources. First, ASSET (Adobe’s Secure Software Engineering Team) focuses on the larger Adobe security landscape and helps coordinate security testing with third parties. Second, Adobe utilizes these third party vendors for pen-testing projects to liaison with developers writing the code. Finally, individual product teams have security champions that are responsible for ensuring the overall security profile of the entire product. There are many security tools that developers can use, some are open source and some are commercial. Adobe uses many different tools, but the most popular commercial ones are Coverity and Checkmarx. 4.1. **Coverity** Coverity, which was recently purchased by Synopsys, is a “leading provider of software quality and security testing solutions” (Coverity, 2014). It is considered more than a security testing tool. The static analysis engine not only detects security defects but also more general coding defects that are unknowingly made by developers. Adobe uses the tool for general quality purposes but for this discussion we will focus on the specifically on the static analysis security checkers. Coverity can be used with the Coverity Scan service or deployed on-premise. Jeff Sass, jsass@adobe.com 4.1.1. Coverity Scan Coverity offers Coverity Scan free of charge to the open source community. This service scans over 2,500 open source projects and provides the results directly to the development team. Over 100,000 defects have been fixed that were identified by this system. Since February 23, 2006, OpenSSL has been one of the projects scanned by Coverity Scan. In the “Coverity Scan Security Spotlight” report (“Coverity Releases Security Spotlight Report on Critical Security Defects in Open Source Projects”, 2014), the Coverity team discusses how tainted data can be exploited in Heartbleed and how other similar vulnerabilities can be detected and fixed in the open source community. 4.1.2. Coverity on-premise Companies who purchase Coverity for use on their internal source code traditionally deploy it on-premise and include the tool as part of the build process. At Adobe, we do this via a continuous build system as well as using an IDE plugin that developers use while writing the code. 4.1.3. Coverity challenges The main challenge that static analysis tools face is how to balance the amount of false positives that a tool generates with the effectiveness of the tool finding actual bugs in the code. One of the reason Coverity’s static analysis tools are so popular is that they have a low false positive rate. If developers and quality engineers are spending time investigating false positives they are not spending time finding and fixing real bugs. There isn’t one set rule for how many false positives are allowed before a developer stops trusting the tool. A good benchmark is less than 20%. Coverity’s desire to use fast algorithms and keep their false positive rate low prevented the 7.0.3 version of their static analysis engine from detecting Heartbleed. 4.1.4. Detecting Heartbleed with Coverity When Coverity’s CTO and co-founder Andy Chou heard about Heartbleed, he blogged about his team’s investigations (Chou, 2014). Heartbleed was a buffer over-read on the memcpy() function call. More specifically it was a buffer over-read involving tainted data. It is difficult to determine that the tainted data came from an untrusted source like a network socket or from an attacker. Coverity wasn’t designed to test all of the memcpy() statements in a program and assume they have tainted data in them. This would have invariably led to a larger than acceptable false positive rate. A way to make the problem more tractable is to examine if the data was part of a byte-swap operation. There are many use cases for byte-swap operations but one common one is sending data across a network. When performing that operation, you cannot assume that the server has the same endianness as the client and vice-versa. Programmers use network byte order and then either do a byte-swapping operation or not depending on if that matches your computers endianness. In the case of Heartbleed, the n2s macro was designed to do the byte-swapping. By examining the code preceding the memcpy(), and determining that a byte swapping operation was occurring, Coverity could now make a reasonable assumption that the data was from an untrusted source and could be tainted. Coverity 7.0.0.3 was released on April 23, 2014, which detected Heartbleed in the default configuration by adding a TAINTED_SCALAR checker (Coverity Support, 2014). 4.1.5. Modeling Another approach Coverity could have used was to model the Heartbleed bug. Coverity provides a modeling feature in order for developers to teach the static analysis engine about specific programming constructs in the code. Because Heartbleed was a specific bug, the easier approach would have been to simply model the exact behavior. Modeling has its place and Adobe has used it successfully in the past. Coverity’s design decision to detect Heartbleed with a new TAINTED_SCALAR checker solves not only this particular vulnerability, but also future vulnerabilities that use the same byte swapping design. This “clever” approach has already been improved upon by GrammaTech’s CodeSonar (Anderson, 2014). 5. Conclusions Heartbleed was a serious vulnerability and there are other serious vulnerabilities that have yet to be disclosed. The Stuxnet worm used four distinct zero-day Jeff Sass, jsass@adobe.com vulnerabilities in its search for computers used to control Iran’s nuclear facilities (Zetter, 2014). It takes increased skill to find and exploit one vulnerability, making it more impressive that Stuxnet contained four. The national debate continues if vulnerabilities should be disclosed when they are discovered or kept for exploitation later by the NSA (Zetter, 2014). As that discussion continues, development teams should employ all of the available tools to remove vulnerabilities in the first place. By improving our static analysis detection algorithms, development teams have a better chance at catching these bugs before they are exploited. Jeff Sass, jsass@adobe.com 6. References Cipriani, J. (2014, April 9). Heartbleed bug: Check which sites have been patched - CNET. Retrieved January 20, 2015, from http://www.cnet.com/how-to/which-sites-have-patched-the-heartbleed-bug/ Coverity Support. (2014, April 23). [Email] “Request access to heartbleed hotfix” Jeff Sass, jsass@adobe.com Jeff Sass, jsass@adobe.com The Role of Static Analysis in Heartbleed The Role of Static Analysis in Heartbleed http://www.slate.com/blogs/future_tense/2014/04/10/password_managers_can_protect_you_from_vulnerabilities_like_heartbleed.html Ullrich, J. (2014, April 9). How to talk to your kids (or manager) about "Heartbleed" Retrieved January 21, 2015, from https://isc.sans.edu/forums/diary/How+to+talk+to+your+kids+or+manager+about+Heartbleed/17943 Jeff Sass, jsass@adobe.com Jeff Sass, jsass@adobe.com ## Upcoming SANS Training Click here to view a list of all SANS Courses <table> <thead> <tr> <th>Event Name</th> <th>City, Country</th> <th>Date</th> <th>Type</th> </tr> </thead> <tbody> <tr> <td>SANS DEFIRCON 2019</td> <td>Coral Gables, FLUS</td> <td>Nov 04, 2019 - Nov 09, 2019</td> <td>Live Event</td> </tr> <tr> <td>MGT521 Beta One 2019</td> <td>Crystal City, VAUS</td> <td>Nov 12, 2019 - Nov 13, 2019</td> <td>Live Event</td> </tr> <tr> <td>GridEx V 2019</td> <td>Online,</td> <td>Nov 13, 2019 - Nov 14, 2019</td> <td>Live Event</td> </tr> <tr> <td>SANS Atlanta Fall 2019</td> <td>Atlanta, GAUS</td> <td>Nov 18, 2019 - Nov 23, 2019</td> <td>Live Event</td> </tr> <tr> <td>Pen Test HackFest Summit &amp; Training 2019</td> <td>Bethesda, MDUS</td> <td>Nov 18, 2019 - Nov 25, 2019</td> <td>Live Event</td> </tr> <tr> <td>SANS Austin 2019</td> <td>Austin, TXUS</td> <td>Nov 18, 2019 - Nov 23, 2019</td> <td>Live Event</td> </tr> <tr> <td>SANS Bangalore 2019</td> <td>Bangalore, IN</td> <td>Nov 25, 2019 - Nov 30, 2019</td> <td>Live Event</td> </tr> <tr> <td>SANS Nashville 2019</td> <td>Nashville, TNUS</td> <td>Dec 02, 2019 - Dec 07, 2019</td> <td>Live Event</td> </tr> <tr> <td>SANS San Francisco Winter 2019</td> <td>San Francisco, CAUS</td> <td>Dec 02, 2019 - Dec 07, 2019</td> <td>Live Event</td> </tr> <tr> <td>SANS Frankfurt December 2019</td> <td>Frankfurt, DE</td> <td>Dec 09, 2019 - Dec 14, 2019</td> <td>Live Event</td> </tr> <tr> <td>SANS Austin Winter 2020</td> <td>Austin, TXUS</td> <td>Jan 06, 2020 - Jan 11, 2020</td> <td>Live Event</td> </tr> <tr> <td>SANS Miami 2020</td> <td>Miami, FLUS</td> <td>Jan 13, 2020 - Jan 18, 2020</td> <td>Live Event</td> </tr> <tr> <td>SANS Amsterdam January 2020</td> <td>Amsterdam, NL</td> <td>Jan 20, 2020 - Jan 25, 2020</td> <td>Live Event</td> </tr> <tr> <td>SANS Anaheim 2020</td> <td>Anaheim, CAUS</td> <td>Jan 20, 2020 - Jan 25, 2020</td> <td>Live Event</td> </tr> <tr> <td>Cyber Threat Intelligence Summit &amp; Training 2020</td> <td>Arlington, VAUS</td> <td>Jan 20, 2020 - Jan 27, 2020</td> <td>Live Event</td> </tr> <tr> <td>SANS Vienna January 2020</td> <td>Vienna, AT</td> <td>Jan 27, 2020 - Feb 01, 2020</td> <td>Live Event</td> </tr> <tr> <td>SANS Mumbai 2019</td> <td>OnlineIN</td> <td>Nov 04, 2019 - Nov 09, 2019</td> <td>Live Event</td> </tr> <tr> <td>SANS OnDemand</td> <td>Books &amp; MP3s OnlyUS</td> <td>Anytime</td> <td>Self Paced</td> </tr> </tbody> </table>
{"Source-Url": "https://www.sans.org/reading-room/whitepapers/threats/role-static-analysis-heartbleed-35752", "len_cl100k_base": 6287, "olmocr-version": "0.1.53", "pdf-total-pages": 19, "total-fallback-pages": 0, "total-input-tokens": 49957, "total-output-tokens": 9875, "length": "2e12", "weborganizer": {"__label__adult": 0.0004296302795410156, "__label__art_design": 0.0004165172576904297, "__label__crime_law": 0.001796722412109375, "__label__education_jobs": 0.0021724700927734375, "__label__entertainment": 0.00013113021850585938, "__label__fashion_beauty": 0.0002219676971435547, "__label__finance_business": 0.00070953369140625, "__label__food_dining": 0.0003330707550048828, "__label__games": 0.0010509490966796875, "__label__hardware": 0.0017223358154296875, "__label__health": 0.0008168220520019531, "__label__history": 0.0002620220184326172, "__label__home_hobbies": 0.0001157522201538086, "__label__industrial": 0.0005040168762207031, "__label__literature": 0.00030350685119628906, "__label__politics": 0.0003039836883544922, "__label__religion": 0.0003898143768310547, "__label__science_tech": 0.10296630859375, "__label__social_life": 0.0001550912857055664, "__label__software": 0.035369873046875, "__label__software_dev": 0.84912109375, "__label__sports_fitness": 0.0002868175506591797, "__label__transportation": 0.0003724098205566406, "__label__travel": 0.00018513202667236328}, "weborganizer_max": "__label__software_dev", "avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_ratio": [[0, 35014, 0.06533]], "fineweb_edu_fasttext_gt2__fineweb_edu_fasttext_gt2__score": [[0, 35014, 0.25445]], "ft_lang_id_en_doc_v2__ft_lang_id_en_doc_v2__en": [[0, 35014, 0.89475]], "google_gemma-3-12b-it_contains_pii": [[0, 53, false], [53, 947, null], [947, 3357, null], [3357, 5660, null], [5660, 7796, null], [7796, 10038, null], [10038, 11719, null], [11719, 13741, null], [13741, 15869, null], [15869, 16906, null], [16906, 19312, null], [19312, 21568, null], [21568, 23590, null], [23590, 24270, null], [24270, 26317, null], [26317, 28210, null], [28210, 30287, null], [30287, 30913, null], [30913, 35014, null]], "google_gemma-3-12b-it_is_public_document": [[0, 53, true], [53, 947, null], [947, 3357, null], [3357, 5660, null], [5660, 7796, null], [7796, 10038, null], [10038, 11719, null], [11719, 13741, null], [13741, 15869, null], [15869, 16906, null], [16906, 19312, null], [19312, 21568, null], [21568, 23590, null], [23590, 24270, null], [24270, 26317, null], [26317, 28210, null], [28210, 30287, null], [30287, 30913, null], [30913, 35014, null]], "google_gemma-3-4b-it_v2tag__is_academic_paper": [[0, 5000, true], [5000, 35014, null]], "google_gemma-3-4b-it_v2tag__is_class_syllabus": [[0, 5000, false], [5000, 35014, null]], "google_gemma-3-4b-it_v2tag__is_completion_certificate": [[0, 5000, false], [5000, 35014, null]], "google_gemma-3-4b-it_v2tag__is_court_notice": [[0, 5000, false], [5000, 35014, null]], "google_gemma-3-4b-it_v2tag__is_homework_assignment": [[0, 5000, false], [5000, 35014, null]], "google_gemma-3-4b-it_v2tag__is_news_article": [[0, 5000, false], [5000, 35014, null]], "google_gemma-3-4b-it_v2tag__is_public_order": [[0, 5000, false], [5000, 35014, null]], "google_gemma-3-4b-it_v2tag__is_resume_cv": [[0, 5000, false], [5000, 35014, null]], "google_gemma-3-4b-it_v2tag__is_test_or_quiz": [[0, 5000, false], [5000, 35014, null]], "google_gemma-3-4b-it_v2tag__is_textbook": [[0, 5000, false], [5000, 35014, null]], "pdf_page_numbers": [[0, 53, 1], [53, 947, 2], [947, 3357, 3], [3357, 5660, 4], [5660, 7796, 5], [7796, 10038, 6], [10038, 11719, 7], [11719, 13741, 8], [13741, 15869, 9], [15869, 16906, 10], [16906, 19312, 11], [19312, 21568, 12], [21568, 23590, 13], [23590, 24270, 14], [24270, 26317, 15], [26317, 28210, 16], [28210, 30287, 17], [30287, 30913, 18], [30913, 35014, 19]], "pipe_delimited_lines_v1__pipe_delimited_lines_v1__pipe_delimited_lines_ratio": [[0, 35014, 0.20809]]}
olmocr_science_pdfs
2024-12-10
2024-12-10
3978a6ddd909f58e1bdbc1480a3cfa5aabad7004
Abstract—The efficiency of processing queries in an embedded database is critical for the system performance. The principal mechanism through which an embedded database maintains an optimal level of performance is the database query optimizer. It reduces the response time of a given query and the total time of processing queries. Nevertheless, because of the optimizer’s importance to the robustness and flexibility of an embedded database, we outline the embedded database query optimization by generating an optimal query processing plan. In this paper, an approach is presented which is able to generate an optimal query processing plans for a given user query. The approach uses dynamic programming to determine optimal query plans for a given query. Index Terms—Embedded databases system, optimization, query plan, query cost. I. INTRODUCTION In the last years the deployment of embedded real-time systems has increased dramatically. At the same time, the amount of data that needs to be managed by embedded real-time systems is increasing, thus requiring an efficient and structured data management. Hence, database functionality is needed to provide support for storage and manipulation of data in embedded real-time systems. However, a database that can be used in an embedded real-time system must fulfill requirements both from an embedded system and from a real-time system, i.e., at the same time the database needs to be an embedded and a real-time database [1]. The main objectives for an embedded database are low memory usage, i.e., small memory footprint, portability to different operating system platforms, efficient resource management, e.g., minimization of the CPU usage, ability to run for long periods of time without administration, and ability to be tailored for different applications. In addition, development costs must be kept as low as possible, with short time-to-market and reliable software. An embedded database is an integral part of such applications or application infrastructures. Unlike traditional DBMSs, database functionality is delivered as part of the application or application infrastructure. These databases run with or as part of the applications in embedded systems [2]. Embedded databases provide an organized mechanism to access large volumes of data for applications. Instead of providing full features of traditional DBMSs, such as complex query optimization and handling mechanisms, embedded databases provide minimal functionality such as indexing, concurrency control, logging, and transactional guarantees. It is actually a broad technology category that includes: database systems with differing application programming interfaces (SQL as well as proprietary, native APIs); database architectures (client-server and Peer-to-Peer); storage modes (on-disk, in-memory, and combined); database models (relational-oriented, object-oriented), [2]. Nowadays, there are many embedded databases on the market, but, they vary widely from vendor to vendor. Existing commercial embedded database systems, e.g., Polyhedra, RDM, Velocis, Pervasive, SQL, Berkeley DB, and TimesTen, have different characteristics and are designed with specific applications in mind. They support different data models, e.g., relational vs object-oriented model, and operating system platforms. Moreover, they have different memory requirements and provide different types of interfaces for users to access data in the database. Application developers must carefully choose the embedded database that their application requires, and find the balance between the functionality an application requires and the functionality that an embedded database offers. Thus, finding the right embedded database, in addition of being a quiet time consuming, costly, concurrency control, transaction scheduling, and logging and recovery. The rest of the paper is organized as follows. Section II presents some related works to the embedded databases. Section III presents the background of our approach within the heuristic used and the method which is dynamic programming. Section IV discusses the approach for query plan generation. Finally, the conclusion is provided in Section V. II. RELATED WORKS We present some works dealing with embedded and real-time systems. ODEA [3] is a platform for the embedded applications to achieve the QoS metrics which are the timeliness of transactions and the temporal freshness of data but not totally guaranteed. It adds an object-manager module that provides the organization of the main memory, the creation and deletion of RT objects and the concurrency control for these objects. Anti-Caching [4], the authors implement a prototype to overcome the restriction that all data fit in main memory where cold data is moved to disk and hot data stays in main memory, where the main memory is the primary storage device not the disk like the traditional DBMS. Data are stored even in the memory or in the disk not like the traditional DBMS, data can be in the memory and the disk. QeDB (Quality-aware real-time Embedded DataBase) [5] is a database for data-intensive real-time applications running on embedded devices where not all the data can be fit into main-memory. QeDB is an extension of Berkeley DB. It has been designed to improve and support the QoS in the embedded applications, which are the timeliness of transactions and the freshness of data by using a novel feedback control technique [6] and exploiting Multiple Input/Output (MIMO) operations. eXtremeDB Fusion [7] is a solution for military and aerospace, it is a small footprint embedded real time DataBase for MilAero (Military-Aerospace). Also used in other various fields such as: control flights, fusion of sensor data, radio, telecommunications and driver support... eXtremeDB Fusion offers a small code pattern (50K) with advanced features by providing: high availability of data; hybrid storage data from the memory and disk. SQLite [8] is an open-source embedded relational database to meet the needs of embedded systems which is small, fast, simple, reliable and easy-to-port. SQLite has such special advantages such as powerful, fast, simple interface as well as small footprint, easy to control without any external dependencies and no setup or administration needed so it’s especially suitable for applications in embedded environment. SQLite transactions are Atomic, Consistent, Isolated, and Durable (ACID Properties). In [9], the authors optimize SQLite COMMIT strategy by using the FileManager to optimize the response time of transactions. Also, to reduce the frequency of executing COMMIT by wrapping up necessary sequences in one transaction: 1- Wrap all sequences of SQL statements during mobile device connection initial. 2- Wrap all sequences of SQL statements for transferring each file. FileManager is an application program that manages file storing and provides file-searching service. It stores files and database files in the Flash Cards. The users transfer files to the Flash Cards. At this time, the mobile will update related information into the database which is stored in the flash memory. LGeDBMS [10] is a small DBMS for mobile embedded system with flash memory. It has been designed to meet those features: 1- Optimized to flash memory with LFS design principle, 2- Compact size suitable for consumer electronics appliances, 3- Transaction process based on flash memory characteristics. The LGeDBMS process makes only an atomic and durable update operation to reduce as possible the unnecessary management cost. To be resist for a system crash, LGeDBMS uses a PID mapping table visioning scheme for logging/recovery. However, LGeDBMS method reduces the number of I/Os by writing a final PID mapping table than writing a log for each data change. Embedded RFID Middleware [11] is software intermediate between the embedded system software (embedded operating system, embedded database) and application software. It uses the functions and services offered by embedded operating system in goal to provide the development environment for the application. Embedded RFID middleware is designed to deal the limits of embedded systems, which are: power consumption optimization of embedded system software; Real-Time support; and limited resources (it must have a complete control of resources, design optimization algorithm, and control the use of resources). In [12], the authors propose an algorithm to optimize the embedded query by using a practical swarm optimization (PSO). The previous version of PSO finds at each iteration 2 solutions, pbest (fitness achieved till current iteration) and gbest (global best solution). Based on this, the authors design a new version of PSO, which is named "dynamic PSO algorithm". A. Embedded Database System The database engine is the boss control module of the database system, its main function is to achieve global control and ensure the correctness and efficiency of the work. It monitors the database during all operations, control the allocation and management of resources. Data access module implements all the basic operations on the base table, which is the core of the operating system to achieve database module. Its functions: - Find a record based on property values. - Find records using the relative position. - Add a record to a base table. - Delete a record from the base table. - Modify a record and write a result back to the base table. Database maintenance module is used to backup and restore the database if it is necessary. We will implement NoSQL embedded database. NoSQL [13]-[15] is a new solution embedded database introduced and began in 2009 and is growing rapidly, still till now evaluated and contributed new types and versions of embedded databases. It is designed to address some of the points: being non-relational, distributed, open-source and horizontal scalable. NoSQL means not only SQL. NoSQL characteristics: schema-free and less, easy replication support and distribution, simple API, Queries need to return answers quickly, mostly query and few updates, asynchronous inserts and updates, eventually consistent / BASE (ACID transaction properties are not needed), Large data volumes, CAP Theorem (Consistency, Availability, Partition tolerance). Consistency means all nodes see the same data at the same time and a set of operations has occurred all at once. Availability means that node failures do not prevent survivors from continuing to operate and every operation must terminate in an intended response. Partition tolerance means that the system continues to operate despite arbitrary message loss and the operations will complete even if individual components are unavailable. NoSQL Databases Types: - Column Store: each storage block contains data from only one column, - Document store: stores documents made up of tagged elements, - Key-value store: is a hash table of keys. III. BACKGROUND As the data required to process the user query existing in various relations, there is a need to process a query plan that has an optimal cost. The query processing cost will be cheaper if the numbers of query’s relations are low and concentrations of data queried on the relations are higher. This happens because cost of transmission of data from different relations will be higher if numbers of relations are bigger. When the numbers of relations used are less, then sending of data will not be required as much. There are many issues in query plan generation which use the iterative improvement and simulated annealing algorithms to produce query plans and generate an optimal one. In [16], [17], the authors used an optimal hybrid genetic based approach to resolve the real-time scheduling of embedded systems with optimization. Also, in [18] authors take the genetic algorithm as a method to solve this problem of finding an optimal query plan in their work. Our new original proposed work uses the two heuristics defined in [18] with a proposition of a new one. A. The Heuristic The first heuristic works on number of relations required to answer the user query. Lesser the number of relations involved in query processing, lesser will be the communication between the relations. As a result, query processing will be efficient. Second heuristic works on the concentration of data queried on the relations. There will be many valid query plans having low number of relations but will be preferred which are having higher number of data queried on the relations. Based on these two heuristics and the Query Proximity Cost (QPC) given in [18], we will propose a new version of this QPC as the following expression demonstrates: $$\sum_{i=1}^{M} \frac{R_i}{N} (1 - \frac{R_i}{N})$$ where \(M\) is the number of relations accessed by the query plan, \(R_i\) is the number of times the \(i^{th}\) relation is used in the Query plan and \(N\) is the number of data queried by the query. The QPC varies from 0 to \((N-1)/N\), where Zero specifies that all the data queried by the queries, resides in the same relation and therefore will be the closest. On the other hand, \((N-1)/N\) specifies that each of the data queried by the query, resides in different relations and therefore are the least closest. The query plans having less QPC are generated using dynamic programming, which is discussed next. B. Dynamic Programming This algorithm is developed in IBM’s System R project [19] and it is used in almost all commercial database products [20]. It works in bottom-up way by building more complex sub-plans from simpler sub-plans until the complete plan is constructed. In the first phase, the algorithm builds access plan for every relation in the query. Typically, there are several different access plans for a relation. In the second phase, the algorithm finds all two-way join plans using the access plans as building blocks. Again, the algorithm would find alternative join plans for all relations. The algorithm executes in this way until it has enumerated all n-way join plans, and those plans are passed by the “finalizePlans” function to become full plans for the query. The beauty of the dynamic programming is that inferior plans are pruned. This is carried out by the “prunePlan” function. IV. THE PROPOSED APPROACH The dynamic programming algorithm is adapted to query plan generation problem. The dynamic programming algorithm for query plan generation is shown below. This algorithm takes relation-data matrix and relation participating in the FROM clause of the SQL query as input and produces optimal query plan as output. INPUT: Relation-Data matrix and relations participating in the FROM clause of the query OUTPUT: Optimal plan with minimum cost. Method: Step 1: Find all possible access paths of the relations of q; Step 2: Evaluate QPC of each query plan based on closeness; Step 3: compare their cost and keep the least expensive and pruned the others; Step 4: Add the resulting plans into set D; Step 5: For i=1 to number of joins in q do; Step 6: consider joining the relevant access paths found in previous iterations using all possible join methods; Step 7: compare the cost of the resulting plans and keep the least expensive then pruned the others; Step 8: Add the resulting plans into set D; Step 9: end for; Step 10: Return Optimal Plan; Where q is the query A. Proof As an example, we will consider the following query: | Select D1, D2, D3, D4 | From R1, R2, R3, R4 R1, R2, R3, R4 are the relations crossed by the query. To answer the query, it requires four data D1, D2, D3, and D4. Therefore, the length of query plan is four. The query plans are constructed by the relations containing the data in the SELECT clause. We assume the relation-data matrix given below: (see Table I). <table> <thead> <tr> <th>TABLE I: RELATION-DATA MATRIX DESCRIPTION</th> </tr> </thead> <tbody> <tr> <td>Relation-Data Matrix</td> </tr> <tr> <td>R1</td> </tr> <tr> <td>R2</td> </tr> <tr> <td>R3</td> </tr> <tr> <td>R4</td> </tr> </tbody> </table> This matrix gives an overview of the relations and the data it contains. Relation 1 (R1) contains Data 1, Data 3, Data 7 and Data 9. Relation 2 (R2) contains Data 1, Data 6, Data 4 and Data 2. Relation 3 (R3) contains Data 1, Data 5, Data 8 and Data 4. Relation 4 (R4) contains Data 1, Data 3, Data 4 and Data 2. We will present some of possible query plans. The number of possible query plans is NR1*NR2*NR3*NR4 where NRi is the number of relations containing the ith data. In this example; it is (4*4*4*4) valid query plans. For the query plans given in Table II, the first one involves four (4) relations, the second one involves three (3) relations, whereas the third and fourth involve two (2) relations. The third query plan has three data residing in relation 1 and a data residing in relation 3, this implies that this query plan has a higher concentration of data at the relation 1. So, it would be considered more optimal than the other query plans. For the query plan given previously, we will introduce their QPC below: <table> <thead> <tr> <th>Query Plans</th> <th>Query Proximity Cost</th> <th>QPC Value</th> </tr> </thead> <tbody> <tr> <td>[1,3,4,2]</td> <td>1/4(1-1/4)+1/4(1-1/4)+1/4(1-1/4)</td> <td>9/16</td> </tr> <tr> <td>[1,1,1,3]</td> <td>3/4(1-3/4)+1/4(1-1/4)</td> <td>3/8</td> </tr> <tr> <td>[1,1,4,4]</td> <td>2/4(1-2/4)+2/4(1-2/4)</td> <td>1/2</td> </tr> </tbody> </table> As we can see in Table III, query plan 3 is the most optimal followed by query plan 4, then query plan 2, and the query plan 1 is the most expensive because it involves more number of relations participating in the query plan. So, less number of relations in the query plan gives less QPC and more optimal query plan. This approach presents several advantages over other technologies in the sense that is easier to structure the data to specific real-time needs. The design is closer to the implementation and development is very simple and it is easier to modify processing and evolve data structures. Nonetheless, our proposed approach suffers from some drawbacks, including difficulty expressing integrity of the real-time constraints in embedded databases and difficulty in installation. We will work hardly in the next issues in order to handle these difficulties. V. CONCLUSION This paper focuses on the problem of embedded database query optimization, which is of great importance in embedded database system design. In this paper, an algorithm is proposed based on dynamic programming to generate query processing plans with the required data. This is done by formulating the query processing plan generation problem as a single-objective dynamic programming which the objective is to find an optimal query plan with minimum QPC. This query plan generated involves minimum number of relations to answer the user query. However, we are planning to develop a better solution during our future works. Moreover, we want to apply the proposed technique to big data centers. **REFERENCES** Selmi Boubaker was born in Bizerte-Tunisia on September 29, 1988. Mr Selmi Boubaker received his master degree in computer science from Higher Institute of Computer Sciences and Management, University of Kairouan-Tunisia in 2013. Now, he is a Ph.D Student in computer science at National Engineering School of Manouba, Manouba University-Tunisia. He is a temporary assistant at the Higher Institute of Management of Sousse, Sousse University-Tunisia. After that, he was working as a substitute teacher for two years at Sousse University and Kairouan University. From April, 2014 to December, 2014 he worked as an IT Support in an international Company of Trading, and also in 2012 as an ERP administrator in Pharmaceutical Company. Hamza Gharzellaoui received the B.S. degree in computer science from Tunis El-Manar University, Tunis, Tunisia, in 2004, and the M.S. degree in industrial computer science from National Institute of Applied Sciences and Technology (INSAT), Carthage University, Tunis, Tunisia, in 2007. He did research in computer science at National Institute of Applied Sciences and Technology, Carthage University, Tunis, Tunisia to receive the Ph.D. degree, in 2013. He was a Researcher in computer science at Al-Jouf College of Technology, Technical and Vocational Training Corporation, Sakaka, Kingdom of Saudi Arabia (KSA). He is a Part-time Researcher and Assistant Professor at ENIC School, Carthage University in Tunisia. H. Gharzellaoui is active in several projects and in other interesting international collaborations. He was with National Engineering School of Carthage, Carthage University, Tunisia.
{"Source-Url": "http://www.ijcte.org/vol9/1161-T018.pdf", "len_cl100k_base": 4389, "olmocr-version": "0.1.50", "pdf-total-pages": 5, "total-fallback-pages": 0, "total-input-tokens": 15694, "total-output-tokens": 5871, "length": "2e12", "weborganizer": {"__label__adult": 0.0004887580871582031, "__label__art_design": 0.00048065185546875, "__label__crime_law": 0.0004849433898925781, "__label__education_jobs": 0.0011434555053710938, "__label__entertainment": 0.00011032819747924803, "__label__fashion_beauty": 0.00024580955505371094, "__label__finance_business": 0.0004584789276123047, "__label__food_dining": 0.00046896934509277344, "__label__games": 0.00079345703125, "__label__hardware": 0.01258087158203125, "__label__health": 0.001186370849609375, "__label__history": 0.00037479400634765625, "__label__home_hobbies": 0.0002200603485107422, "__label__industrial": 0.0010347366333007812, "__label__literature": 0.00022482872009277344, "__label__politics": 0.0002846717834472656, "__label__religion": 0.0005621910095214844, "__label__science_tech": 0.2626953125, "__label__social_life": 8.392333984375e-05, "__label__software": 0.011016845703125, "__label__software_dev": 0.703125, "__label__sports_fitness": 0.0003857612609863281, "__label__transportation": 0.001140594482421875, "__label__travel": 0.00023543834686279297}, "weborganizer_max": "__label__software_dev", "avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_ratio": [[0, 24229, 0.04364]], "fineweb_edu_fasttext_gt2__fineweb_edu_fasttext_gt2__score": [[0, 24229, 0.36785]], "ft_lang_id_en_doc_v2__ft_lang_id_en_doc_v2__en": [[0, 24229, 0.89387]], "google_gemma-3-12b-it_contains_pii": [[0, 5034, false], [5034, 11077, null], [11077, 16436, null], [16436, 22596, null], [22596, 24229, null]], "google_gemma-3-12b-it_is_public_document": [[0, 5034, true], [5034, 11077, null], [11077, 16436, null], [16436, 22596, null], [22596, 24229, null]], "google_gemma-3-4b-it_v2tag__is_academic_paper": [[0, 5000, true], [5000, 24229, null]], "google_gemma-3-4b-it_v2tag__is_class_syllabus": [[0, 5000, false], [5000, 24229, null]], "google_gemma-3-4b-it_v2tag__is_completion_certificate": [[0, 5000, false], [5000, 24229, null]], "google_gemma-3-4b-it_v2tag__is_court_notice": [[0, 5000, false], [5000, 24229, null]], "google_gemma-3-4b-it_v2tag__is_homework_assignment": [[0, 5000, false], [5000, 24229, null]], "google_gemma-3-4b-it_v2tag__is_news_article": [[0, 5000, false], [5000, 24229, null]], "google_gemma-3-4b-it_v2tag__is_public_order": [[0, 5000, false], [5000, 24229, null]], "google_gemma-3-4b-it_v2tag__is_resume_cv": [[0, 5000, false], [5000, 24229, null]], "google_gemma-3-4b-it_v2tag__is_test_or_quiz": [[0, 5000, false], [5000, 24229, null]], "google_gemma-3-4b-it_v2tag__is_textbook": [[0, 5000, false], [5000, 24229, null]], "pdf_page_numbers": [[0, 5034, 1], [5034, 11077, 2], [11077, 16436, 3], [16436, 22596, 4], [22596, 24229, 5]], "pipe_delimited_lines_v1__pipe_delimited_lines_v1__pipe_delimited_lines_ratio": [[0, 24229, 0.12264]]}
olmocr_science_pdfs
2024-11-30
2024-11-30
6a8c6589ca55dc3949491db8204e8775a154bb4a
JTaCo & SProUTomat: Automatic Evaluation and Testing of Multilingual Language Technology Resources and Components Christian Bering†, Ulrich Schäfer∗ †Computational Linguistics Department, Saarland University P.O.Box 151150, D-66041 Saarbrücken, Germany cristian.bering@acrolinx.com ∗Language Technology Lab, German Research Center for Artificial Intelligence (DFKI) GmbH Stuhlsatzenhausweg 3, D-66123 Saarbrücken, Germany ulrich.schaefer@dfki.de Abstract We describe JTaCo, a tool for automatic evaluation of language technology components against annotated corpora, and SProUTomat, a tool for building, testing and evaluating a complex general-purpose multilingual natural language text processor including its linguistic resources (lingware). The JTaCo tool can be used to define mappings between the markup of an annotated corpus and the markup produced by the natural language processor to be evaluated. JTaCo also generates detailed statistics and reports that help the user to inspect errors in the NLP output. SProUTomat embeds a batch version of JTaCo and runs it after compiling the complex NLP system and its multilingual resources. The resources are developed, maintained and extended in a distributed manner by multiple authors and projects, i.e., the source code stored in a version control system is modified frequently. The aim of JTaCo & SProUTomat is to warrant a high level of quality and overall stability of the system and its lingware. 1. Introduction The development of multilingual resources for language technology components is a tedious and error-prone task. Resources (lingware) like morphologies, lexica, grammars, gazetteers, etc. for multiple languages can only be developed in a distributed manner, i.e., many people work on different resources. However, the resulting systems are supposed to deliver the same good recognition quality for each language. Dependencies of resources and subsystems may lead to suboptimal performance, e.g., reduced recognition rates, of the overall systems in case of errors creeping in during the development process. Hence, in analogy to software engineering, testing and evaluation of the developed lingware has to be carried out on a regular basis, both for quality assurance and comparability of results in different languages. Annotated natural language corpora can be thought of as providing a rich and potentially very useful body of test material in this context. However, it is often not possible to flexibly incorporate the material at hand into the development process. The reasons are manifold: Not only may annotations in different sources be of very diverse nature, but the NLP component under development usually generates a markup in yet another format defined by the development environment. In this paper, we describe a framework consisting of two major components, JTaCo and SProUTomat, that facilitates frequent (e.g., daily) building, testing and evaluation of multilingual language components and resources in a quality assurance and development cycle as depicted in Figure 1. We have implemented and will demonstrate the framework for the multilingual SProUT processor. However, the concepts and mechanisms described could be applied to any other resource-intensive natural language processing system. 2. SProUT SProUT is a shallow, multilingual, general-purpose natural language processor (Drozdzynski et al., 2004). SProUT comes with a powerful, declarative grammar formalism XTDL that combines finite-state techniques and typed feature structures with structure sharing and a fully-fledged, efficiently encoded type hierarchy—in contrast to systems like GATE (Cunningham et al., 2002) that support only simple attribute-value pairs. SProUT rules consist of regular expressions over typed feature structures1. A rule is matched against a sequence of input feature structures which are filled by basic components like tokenisers, morphology or gazetteer lookup run- 1The acronym SProUT stands for Shallow Processing with Unification and Typed feature structures. SProUT’s homepage is http://sprout.dfki.de. ning on input text or, in more complex cases, XML output from external NLP components or even output from previous SProUT grammar stages. The matching condition is unifiability of the input sequence with the expanded regular expression of the left hand side of a rule. In case of a match, feature structure unification is used to transport information from the matching left hand side to the output feature structure on the right hand side of the rule. The output feature structure can then, e.g., be transformed to any XML format. The SProUT system provides basic components like tokenisers, morphologies and domain-specific gazetteers for languages such as English, German, French, Spanish, Greek, Japanese, Italian, Chinese, Polish and Czech, and comes with a user-friendly integrated development environment (IDE). The current main applications of SProUT are information extraction and named entity recognition (NER). To illustrate the SProUT formalism, we give a short example in Figure 2 of a grammar rule that recognises river names. The rule matches either expressions consisting of an (unknown) capitalised word (via token type match), followed by a noun with stem river or brook (via the English morphology component; disjunction has a higher precedence than concatenation), or Gazetteer entries of type gaz_river containing English river names represented by the Gazetteer type gaz_river. The generated output structure of type ne-location contains a location type river and the location name transported via the coreference symbol loc_name. To sum up, this rule recognises both unknown river names (via a pattern involving morphology lookup that tolerates morphologic variants) and known river names (via a gazetteer match), using a concise, declarative pattern and returning a structured description. SProUT has been and is currently used in many research and industrial projects for opinion and text mining, information extraction, automatic hyperlinking, question answering and semantic web applications (Drozdzynski et al., 2004). 3. JTaCo The aim of JTaCo (Bering, 2004; Bering et al., 2003) is to allow the developer of an NLP component or resource, e.g., of a grammar, to make unified use of variably annotated source material for testing. The component developer provides suitably, i.e., usually semi-manually or manually marked-up reference sources on the one hand, and a parser or similar NLP component on the other hand. JTaCo extracts the original annotation from the corpus, compares this annotation with the markup the component in question generates for the same input, and generates statistics and reports from the comparison results\(^2\). Since a focus of JTaCo lies on the integration of diverse manual annotation schemes one the one hand and differing NLP components on the other, JTaCo employs a very modular architecture in which its different processing stages allow independent adaptations to varying input and different environments. JTaCo is realised as a pluggable light-weight, mostly architecture-independent framework. Currently, there are two JTaCo plug-in realisations for usage with grammars developed in SProUT: A GUI plug-in integrated into the SProUT IDE, and a batch version integrated into SProUTmat. 3.1. JTaCo’s Processing Stages JTaCo works in four separate transformational processing stages. Figure 3 gives an overview of these stages, of their input and the results they generate. The process starts from an annotated written corpus against which the NLP component or resource is to be tested. In the first step, JTaCo uses an AnnotationParser to separate the corpus into - the ‘raw’ text contained in the corpus (i.e., the text without any annotation) - its true annotation (interchangeably also called the reference or manual annotation). The extracted text is fed into the Parser (or a similar component) which the developer wants to test, yielding the annotation to compare with the manual annotation. The comparison is executed by a TaggingComparator. The comparator’s result in turn is used by an OutputGenerator to select, format and output the needed information. There are two main advantages gained from such a modular architecture: On the one hand, the abstract representations in the intermediate results hide details specific to the corpus or component used. For instance, differing types of annotations are mapped to an abstract annotation representation, for which a comparison operation – i.e., especially the notion of equality between entities in the two annotations – can be defined in an adequately flexible manner, and the underlying annotated sources as well as NLP components can be exchanged transparently. Thus, whenever a new annotation format or component makes it necessary to integrate a tailored module into JTaCo, the capabilities of the new module can readily interact with existing functionality of other modules. The second, more practically relevant advantage is that the settings of any one stage can be changed, and the process at that stage rerun with the new settings without having to \(^2\) JTaCo stands for Java Tagging Comparator. Figure 2: A SProUT grammar rule recognizing river names. Boxed feature values denote structure sharing, type names are typeset in italics. The dot after the first token indicates concatenation, the vertical bars separate alternatives. re-iterate the previous process stages, as long as their results are still available. This can be especially useful for the last two stages in an interactive environment (i.e., comparison and report generation), where the developer might want to experiment with different settings without repeatedly having to rerun the probably time-consuming processes of reading the corpus and parsing it. For each of the stages, a JTaCo plug-in uses one or more processing realisations adapted to the desired representations. In what follows, we will draw upon the implementations integrated into SProUT and SProUTomat to illustrate the information flow in JTaCo. 3.2. Reading the Annotated Corpus For use in the following processing stages, JTaCo extracts from the annotated corpus the ‘raw’ content, i.e., the written text without any markup, on the one hand, and the reference annotation on the other. Both the extraction of the text and of the annotation can be configured according to the specific annotation scheme. E.g., a corpus usually not only contains the annotated textual material, but also meta-information intended for, e.g., administrative purposes. Such information has to be excluded from the text extracted to be used for testing. Currently, JTaCo includes support for annotations which satisfy certain regular constraints and for XML annotations such as found in MUC corpora (Grishman and Sundheim, 1996). For use with SProUT, JTaCo transforms the XML-encoded entities into typed feature structures. As an illustration, consider the following MUC time expression: \[ \text{<TIMEX TYPE="DATE">07-21-96</TIMEX>} \] The textual content consists just of the date expression 07-21-96. JTaCo transforms the tag information as well as the surface and character offsets into feature-value pairs in a feature structure: \[ \begin{array}{|c|c|c|} \hline \text{point} & \text{temp-point} \\ \hline \text{SPEC} & \text{MUC-TYPE} \\ \text{CSTART} & \text{date} \\ \text{CEND} & \text{"21"} \\ \text{SURFACE} & \text{"07-21-96"} \\ \text{YEAR} & \text{"1996"} \\ \text{MONTH} & \text{"07"} \\ \text{DOFM} & \text{"21"} \\ \hline \end{array} \] 3.3. Parsing the Extracted Text In this second processing stage, JTaCo feeds the NLP component which the developer wants to test with the text retrieved from the previous stage, and the NLP component in turn produces some specific markup of the text. As in the previous stage, JTaCo transforms this annotation into a format which it can compare with the reference annotation. For the previously employed example expression, 07-21-96, SProUT’s named entity recognition markup delivers structured output in an XML-encoded typed feature structure\(^3\), where CSTART and CEND indicate start and end character positions of the matched named entity in the input text: \[ \begin{array}{|c|c|c|} \hline \text{timex} & \text{DATE} \\ \text{CSTART} & \text{"27"} \\ \text{CEND} & \text{"34"} \\ \text{SURFACE} & \text{"07-21-96"} \\ \hline \end{array} \] Here, CSTART and CEND indicate the inclusive start and end character positions of the annotated element in the ‘raw’ text, i.e., without counting the markup. The resulting reference annotation is the collection of all feature structures generated from the corpus. More complex, embedded annotations would be translated in a similar manner. 3.4. Comparing the Annotations In this stage, the annotations obtained from the two previous transformation processes are compared, i.e., the ‘manual’ annotation read directly from the corpus, and the ‘parsed’ annotation obtained through the NLP component. For JTaCo, an annotation is a collection of tags, where a tag consists of some linguistic information about a piece of text. Minimally, a tag contains - some name, e.g., a linguistic label, \(^3\)Transformation of typed feature structures and general XML markup is discussed in the context of the upcoming ISO standard in (Lee et al., 2004). Actually, SProUT’s default XML output format is very close to the proposed ISO format for typed feature structures. • the surface string to which the label applies, • token count information about where this string is found in the corpus. Usually, the setup uses tags which incorporate more information, and the relation used to determine entity equality between the two annotations typically depends on this information. For instance, for use with SProUT JTaCo generates an annotation consisting of tags which are augmented with feature structure information. The equality notion of these tags is defined though unification. An important feature of JTaCo is that the comparison can be configured to accommodate for a variety of systematic differences in annotations: • The annotations may use different labels, differing perhaps even in granularity. E.g., one annotation might globally use the label *organisation*, while the other uses subclasses such as *university*, *government*, etc. • The annotated entities may differ in their surface spans. E.g., one annotation might consider the expression *President Hugo Chavez* to be a named entity, while the other might exclude the title. • One annotation may contain sequences of entities which in the other annotation correspond to one single entity. For instance, MUC will usually separate a date followed by a time into two named entities (*TIMEX-DATE* and *TIMEX-TIME*), while SProUT considers this to be one entity. The screenshot in Figure 4 shows a part of the defined tag mappings used when comparing SProUT’s annotation to the original MUC markup. Most of the mappings constitute simple entity label correspondences, e.g., a MUC *TIMEX-DATE* can correspond to a point, a span, a duration, or an interval in the annotation generated by SProUT. An entity named a *duration* by SProUT can in turn be a MUC *TIMEX-TIME* as well as a *TIMEX-TIME*. In the example settings, all of these correspondences are further ‘softened’ to ignore surface span discrepancies: The *open left* and *open right* switches allow for a mismatch in the *CSTART* and *CEND* features, respectively. The example settings also contain a mapping of the sequence *TIMEX-DATE* and *TIMEX-TIME* in MUC to the SProUT entity point. The *strictness* is a measure of how far apart these two elements are allowed to occur and still be valid elements for a sequence matched against a single point. ### 3.5. Generating a Report Finally, JTaCo generates a report of the comparison. JTaCo can output statistical information (precision, recall, etc.) as well as detailed occurrence lists of entities that were or were not correctly identified in the parse. The settings for this processing stage determine which results are shown (e.g., for which tags) and how the information is formatted. JTaCo can export the generated reports as ASCII and as HTML tables. ![Figure 4: Definition of comparison settings in JTaCo’s SProUT IDE plug-in. See Section 3.4. for a detailed explanation.](image-url) what a compiled class file is and when it has to be recompiled (source code changes, dependencies), this has to be defined explicitly for lingware resources which Ant natively is not aware of. The uptodate task can be used to compare source files (.tdl in the following example) against their compiled version (.grm). ```xml <uptode taskfile="$/typehierarchy/tdl" targetfile="$/typehierarchy/grm"/> ``` For each of the different lingware types, these source file dependencies are defined as are the calls to the dedicated SProUT compilers and parameters for their compilation. Lingware-specific targets have common parameters and properties like "lang", "project" or the lingware type that are used to locate, e.g., the source and compiled files in the hierarchically defined directory trees or "charset" to specify encodings for source files to read. ```xml <target name="compile_ne" depends="jar" description="Compile NER grammar."> <property name="lang" value="en"/> <property name="project" value=""/> <property name="charset" value="utf-8"/> <!-- compile type hierarchy --> <antcall target="compile_tdl"/> <!-- compile tokeniser --> <antcall target="compile_tokenclass"/> <!-- compile gazetteer --> <antcall target="compile_gazetteer"/> <!-- compile XTDL grammar for NER --> <antcall target="compile_grammar"/> </target> ``` Figure 5: A sample target definition: named entity grammar compilation. Dependencies between different lingware types are handled by calls to defined sub-targets. Figure 5 shows the definition of the compile_ne target that calls four other compilation sub-targets. Each subtarget compiles only when necessary, and the compile_ne target itself depends on the jar target that provides working and up-to-date SProUT lingware compilers. Besides the program and lingware compilation, many other targets exist, e.g., to generate documentation, package runtime systems, start the integrated development environment, etc. Thus, using a single command, it is possible to compile the whole system including code and all dependent available linguistic resources, or to update it after changes in the sources. 4.2. Test and Evaluation When SProUTomat is started, it first updates all program and lingware sources from the version control system, and compiles them. For each language resource to test, a reference text is then analysed by the SProUT runtime system. This checks for consistent (re)sources. The next step is comparison of the generated named entity and information extraction annotation against a gold standard. SProUTomat uses the batch version of JTaCo for the automatic evaluation and computation of precision, recall and f-measure. For English, the annotated corpus is taken from the MUC evaluation data. For other languages for which no MUC annotations exist (e.g., German), a manually developed corpus is employed. 4.2.1. Report Finally, a report is generated and emailed to the developers with an overall status (OK or ERROR) for quick information. The report also contains diagrams consisting of precision, recall and f-measure curves since beginning of regular measurements per language that visually give a quick overview of the resource development progress over time (cf. Figure 6). To this end, the evaluation numbers are also added to a global evaluation database. ![F-measure curves of the English MUC-compatible NER grammar collected by SProUTomat from 08/05 to 03/06. The drop in August/September was caused by a code change not followed by an immediate adaptation of the lingware.](image) Figure 6: F-measure curves of the English MUC-compatible NER grammar collected by SProUTomat from 08/05 to 03/06. The drop in August/September was caused by a code change not followed by an immediate adaptation of the lingware. 5. Summary We have presented a comprehensive framework for automatically testing and evaluating multilingual linguistic resources and language technology components. The system is in daily use since March 2005 and successfully helps to maintain the quality and reliability of the multilingual language processor with its various resources that are developed by many authors and used in several projects. The framework greatly helps to improve and accelerate the development - evaluation/comparison - refinement cycle, gives motivating feedback (such as raising recall and precision curves over time) and thus provides continuous quality assurance for a complex natural language processing system. 6. Acknowledgements We would like to thank Daniel Beck for helping to implement SProUTomat, the SProUT grammar developers for their feedback, Witold Drozdyński for extending the SProUT API to our needs and the reviewers for helpful comments. This work has been supported by research grants from the German Federal Ministry of Education and Research in the context of the projects QUETAL (FKZ 01 IW C02) and COLLATE (FKZ 01 IN A01). 7. References
{"Source-Url": "http://www.dfki.de/dfkibib/publications/docs/qaqmlsr-sproutomat-final.pdf", "len_cl100k_base": 4577, "olmocr-version": "0.1.51", "pdf-total-pages": 6, "total-fallback-pages": 0, "total-input-tokens": 18971, "total-output-tokens": 5630, "length": "2e12", "weborganizer": {"__label__adult": 0.00045680999755859375, "__label__art_design": 0.0005207061767578125, "__label__crime_law": 0.00046896934509277344, "__label__education_jobs": 0.0016307830810546875, "__label__entertainment": 0.0002015829086303711, "__label__fashion_beauty": 0.00021314620971679688, "__label__finance_business": 0.00025272369384765625, "__label__food_dining": 0.0003197193145751953, "__label__games": 0.0007605552673339844, "__label__hardware": 0.0005941390991210938, "__label__health": 0.0006155967712402344, "__label__history": 0.0003592967987060547, "__label__home_hobbies": 7.849931716918945e-05, "__label__industrial": 0.0004253387451171875, "__label__literature": 0.002536773681640625, "__label__politics": 0.0004019737243652344, "__label__religion": 0.0007200241088867188, "__label__science_tech": 0.063720703125, "__label__social_life": 0.0002104043960571289, "__label__software": 0.0276641845703125, "__label__software_dev": 0.89697265625, "__label__sports_fitness": 0.0003399848937988281, "__label__transportation": 0.0005044937133789062, "__label__travel": 0.0002081394195556641}, "weborganizer_max": "__label__software_dev", "avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_ratio": [[0, 23620, 0.02498]], "fineweb_edu_fasttext_gt2__fineweb_edu_fasttext_gt2__score": [[0, 23620, 0.71472]], "ft_lang_id_en_doc_v2__ft_lang_id_en_doc_v2__en": [[0, 23620, 0.86056]], "google_gemma-3-12b-it_contains_pii": [[0, 4106, false], [4106, 9249, null], [9249, 13538, null], [13538, 16440, null], [16440, 21185, null], [21185, 23620, null]], "google_gemma-3-12b-it_is_public_document": [[0, 4106, true], [4106, 9249, null], [9249, 13538, null], [13538, 16440, null], [16440, 21185, null], [21185, 23620, null]], "google_gemma-3-4b-it_v2tag__is_academic_paper": [[0, 5000, true], [5000, 23620, null]], "google_gemma-3-4b-it_v2tag__is_class_syllabus": [[0, 5000, false], [5000, 23620, null]], "google_gemma-3-4b-it_v2tag__is_completion_certificate": [[0, 5000, false], [5000, 23620, null]], "google_gemma-3-4b-it_v2tag__is_court_notice": [[0, 5000, false], [5000, 23620, null]], "google_gemma-3-4b-it_v2tag__is_homework_assignment": [[0, 5000, false], [5000, 23620, null]], "google_gemma-3-4b-it_v2tag__is_news_article": [[0, 5000, false], [5000, 23620, null]], "google_gemma-3-4b-it_v2tag__is_public_order": [[0, 5000, false], [5000, 23620, null]], "google_gemma-3-4b-it_v2tag__is_resume_cv": [[0, 5000, false], [5000, 23620, null]], "google_gemma-3-4b-it_v2tag__is_test_or_quiz": [[0, 5000, false], [5000, 23620, null]], "google_gemma-3-4b-it_v2tag__is_textbook": [[0, 5000, false], [5000, 23620, null]], "pdf_page_numbers": [[0, 4106, 1], [4106, 9249, 2], [9249, 13538, 3], [13538, 16440, 4], [16440, 21185, 5], [21185, 23620, 6]], "pipe_delimited_lines_v1__pipe_delimited_lines_v1__pipe_delimited_lines_ratio": [[0, 23620, 0.0]]}
olmocr_science_pdfs
2024-12-03
2024-12-03
a3e7db6c71fff9f024da48cc967e6816b25acfcc
ControlShell: A Real-Time Software Framework Stanley A. Schneider Vincent W. Chen Gerardo Pardo-Castellote Real-Time Innovations, Inc. Aerospace Robotics Laboratory 954 Aster Stanford University Sunnyvale, California 94086 Stanford, California 94305 Abstract This paper describes ControlShell, a next-generation CASE “framework” for real-time system software development. ControlShell’s well-defined structure, graphical tools, and data management provide a unique component-based approach to real-time software generation and management. ControlShell is designed specifically to enable modular design and implementation of real-time software. By defining a set of interface specifications for inter-module interaction, ControlShell provides a basis for real-time code development and exchange. ControlShell includes many system-building tools, including a graphical data flow editor, a component data requirement editor, and a state-machine editor. It also includes a distributed data flow package, an execution configuration manager, a matrix package, and an object database and dynamic binding facility. ControlShell is being used in several applications, including the control of free-flying robots, underwater autonomous vehicles, and cooperating-arm robotic systems. This paper presents an overview of the ControlShell architecture, and details the functions of several of the tools. 1 Introduction Motivation System programs for real-time command and control are, for the most part, custom software. Emerging operating systems [1, 2, 3, 4, 5] provide some basic building blocks—scheduling, communication, etc.—but do not encourage or enable any structure on the application software. Information binding and flow control, event responses, sampled-data interfaces, network connectivity, user interfaces, etc. are all left to the programmer. As a result, each real-time system rapidly becomes a custom software implementation. With so many unique interfaces, even simple modules cannot be shared or reused. 1.1 ControlShell’s Solutions Component-Based Design ControlShell is specifically designed to address these issues. ControlShell provides interface definitions and mechanisms for building real-time code modules. ControlShell also provides basic data structure specifications, and mechanisms for binding data with routines and specifying data-flow requirements. These two critical features make simple generic... packages (known as components) possible. ControlShell systems are built from combinations of these components. An extensive library of pre-defined components is provided with the system, ranging from simple filters and controllers to complex trajectory generators and motion planning modules. New or custom components are easily added to the system via the graphical Component Editor (CE). The Component Editor allows simple specification of data interchange requirements. Code is automatically generated to permit instancing the new component into the system. Graphical CASE System-Building Tools ControlShell also provides a set of powerful development tools for building complex systems. Building a system is accomplished by connecting components within a graphical Data Flow Editor (DFE). The data flow editor resolves the system data dependencies and orders the component modules for most efficient execution. Radical mode changes are supported via a "configuration manager" that permits quick reconfiguration of large numbers of active component routines. Real-time systems also require higher-level control functions. ControlShell’s event-driven finite state machine (FSM) capability provides easy strategic control. The state machine model features rule-based transition conditions, true callable sub-chain hierarchies, task synchronization and event management. A graphical FSM editor facilitates building state programs. Real-Time System Services To provide support for real-time distributed systems, ControlShell includes a network connectivity package known as the Network Data Delivery Service (NDDS). NDDS provides distributed data flow. It naturally supports multiple anonymous data consumers and producers, arbitrary data types, and on-line reconfiguration and error recovery. ControlShell also offers a database facility, direct support for sampled-data systems, a full matrix package, and an interactive menu system. Figure 1 presents an overview of the ControlShell toolset and design approach. 2 Relation to Other Research There are two quite different issues in real-time software system design: - Hierarchy (what is communicated) - Superstructure architecture (how it is communicated) Several efforts are underway to define hierarchy specifications; NASREM is a notable example [6]. ControlShell makes no attempt to define hierarchical interfaces, but rather strives to provide a sufficiently generic software platform to allow the exploration of these issues. As such, this work takes a first step—defining the architecture superstructure (control and data flow mechanisms). Several distributed data-flow architectures have been developed, including CMU’s TCA/X [7, 8], Rice University’s TelRIP [9], and Sparta’s ARTSE [10]. These provide various levels of network services, but do not address repetitive service issues or resolve multiple data-producer conflicts in a symmetric robust “stateless” architecture as does the ControlShell NDDS system (see [11] for details). Also, they are not integrated within a general programming system. Recently, more sophisticated programming environments have begun to emerge. For example, ORCAD [12] and COTS [13] are specialized robotics programming environments. Two commercial products, System Build with AutoCode from Integrated Systems, Inc. [14], and SIMULINK with C-Code Generation from the MathWorks, Inc. [15] are sophisticated control development environments. They offer easy-to-use rapid control system prototyping. They are not, however, architectures well suited to developing complex multi-layer distributed control hierarchies. Implementation Experience ControlShell evolved from many years of research with real-time control systems. It was first developed for use with a multiple-arm cooperative robot project at Stanford University’s Aerospace Robotics Laboratory[16, 17, 18]. From this start, ControlShell spread to become the basis for more than 20 research projects in advanced control systems at Stanford. Among these were projects to study the control of flexible structures, adaptive control, control of mobile robots (including multiple coordinated robots), and high-bandwidth force control [19, 20, 21, 22, 23, 24]. More recently, a few industrial sites and two NASA centers have begun experimenting with ControlShell applications [25, 26]. ControlShell is now being jointly developed by Stanford University and Real-Time Innovations, Inc. It is supported under ARPA's Domain-Specific Software Architectures (DSSA) program. This continuous migration from specific, working applications to wider spectrums of use is the key to usable generality. These applications continue to drive ControlShell's growth. To our knowledge, ControlShell is the only integrated framework package combining transparent networking, component-based system description, a state machine model, and a run-time executive. 3 Run-Time Structure Some of the major system modules are shown in Figure 2. As shown in the figure, ControlShell is an open system, with application-accessible interfaces at each level. The figure is organized (loosely) into data and execution hierarchies. At the lowest layer, ControlShell executes within the VxWorks real-time operating system environment. The simple base class known as CSMODULES is the building block for most executable constructs. Organizations of these modules, into lists, menus, and finite state machines form the core executable constructs. Users build useful execution-level atomic objects called components by defining derived classes from CSMODULES and binding them through the on-line data base to data matrices from the CSMAT package. High-level graphical editors speed component definition, data flow specification and state machine programming. Network connectivity is provided by NDDS for all application modules. 4 Data Flow Design Many real-time systems contain sampled-data subsystems. Here, we define a "sampled-data" system as any system with a clearly periodic nature. Common examples (each of which have been implemented under ControlShell) are digital control systems, real-time video image processing systems, and data acquisition systems. Each of these is characterized by a regular clock source. Providing an environment where sampled-data program components can be interchanged is challenging. These programs have routines that must be executed during the sampling process, routines to initialize data structures (or hardware) when sampling begins, and perhaps to clean up when sampling ends. Further, many routines are dependent on knowledge of the timing parameters, etc. Although they may interact—say by passing data—sampled-data program components are often relatively independent. Requiring the application code to call each module's various routines directly destroys modularity. 4.1 Components The component is the fundamental unit of reusable data-flow code in ControlShell. Components consist of one or more sample modules derived from CSMODULES. Sample modules have several pre-defined entry routines, including: <table> <thead> <tr> <th>Routine</th> <th>When executed</th> </tr> </thead> <tbody> <tr> <td>execute</td> <td>Once each sample period</td> </tr> <tr> <td>stateUpdate</td> <td>After all executes are done</td> </tr> <tr> <td>enable</td> <td>When this module is made active</td> </tr> <tr> <td>disable</td> <td>When it is removed from the active list</td> </tr> <tr> <td>startup</td> <td>When sampling begins</td> </tr> <tr> <td>shutdown</td> <td>When sampling ends</td> </tr> <tr> <td>timingChanged</td> <td>When the sample rate changes</td> </tr> <tr> <td>reset</td> <td>When the user types &quot;reset&quot;, or calls CSSampleReset</td> </tr> <tr> <td>terminate</td> <td>When the module is unloaded</td> </tr> </tbody> </table> Thus, a motor driver component might define a startup routine to initialize the hardware, an execute routine to control the motor, and a shutdown routine to disable the motors if sampling is interrupted for any reason. In addition, if any of its parameters depend on the sampling rate, it may request notification via a timingChanged method. By allowing components to attach easily to these critical times in the system, ControlShell defines an interface sufficient for installing (and therefore sharing) generic sampled-data programs. Building Components: The Component Editor An easy-to-use graphical tool called the component editor (CE) assists the user in generating new components and specifying their data-flow interactions. The component editor defines all the input and output data requirements for the component, and creates a data type for the system to use when interacting with the component. The tool contains a code generator; it automatically generates a description of the component that the Data-Flow Editor can display (see below), and the code required to install instances of the component into ControlShell's run-time environment. 4.2 Execution Lists An execution list is simply a dynamically changeable, ordered list of sample modules to be sequentially executed. The active set of modules on a list can be changed anytime. In fact, lists may drastically change their contents during system mode changes. Execution lists may be sorted to provide automated run-time execution scheduling to resolve data dependencies. More specifically, the modules are sorted so that data consumers are always preceded by the appropriate data producers (see Figure 3). The system uses the specifications of the data flow requirements for each component to sort the dependencies and order the list. A side benefit of the sorting process is the error-checking that is performed to insure consistent data flow patterns. 4.3 Building Systems: The DFE Editor Building systems of components is made simple by the graphical Data-Flow Editor (DFE). The DFE reads description files produced by the component editor, and then allows the user to connect components in a friendly graphical environment. It allows specification of all the data connections in the system, as well as reference inputs—gains, configuration constants and other parameters to the individual components. An example session is depicted in Figure 4. Sample Habitats ControlShell provides a named sampled-data environment, known as a sample habitat. A sample habitat encapsulates all the information and defines all the interfaces required for sampled-data programs to co-exist. It also contains routines to control the sampling process. For example, a module installed into a sample habitat can query its clock source and sample rate, start and stop the sampling process, etc. Each sample habitat contains an independent task that executes the sample code. The task is clocked by the periodic source (such as a timer interrupt). Special components are provided to interface between habitats, allowing multi-rate controller designs. 5 Configuration Management Complex real-time systems often have to operate under many different conditions. The changing sets of conditions may require drastic changes in execution patterns. For example, a robotic system coming into contact with a hard surface may have to switch in a force control algorithm, along with its attendant sensor set, estimators, trajectory control routines, etc. ControlShell's configuration manager directly supports this type of radical behavior change; it allows entire groups of modules to be quickly exchanged. Thus, different system personalities can be easily interchanged during execution. This is a great boon during develop- ment, when an application programmer may wish, for example, to quickly compare controllers (See Figure 5). It is also of great utility in producing a multi-mode sys- tem design. By activating these changes from the state- machine facility (see below), the system is able to handle easily external events that cause major changes in sys- tem behavior. Configuration Hierarchy The configuration man- ger essentially creates a four-level hierarchy of module groupings. Individual sample modules form the low- est level. These usually implement a single well-defined function. Sets of modules, called module groups, com- tain the simple functions implemented by single mod- ules into complete executable subsystems. Each module group is assigned to a category. One group in each installed category is said to be active, meaning its modules will be executed. Finally, a confi- guration is simply a specification of which group is active in each category. ![Configuration Manager](image) **Figure 5:** Configuration Manager Configurations can be swapped in or out under program or menu control. This provides flexible run-time reconfigura- tion of the execution structure. Example As a simple example, consider a system with two controllers: a proportional-plus-derivative con- troller named “PD”, and an optimal controller known as “LQG”. Suppose the PD controller requires filtered inputs, and thus consists of two sample modules: an in- stance of the PDControl component and a filter compo- ent. These two components would comprise the “PD” module group. The “LQG” controller module group may also be made up of several components. Both of these groups would be assigned to the category “con- trollers”. The user (or application code) can then easily switch controllers by changing the active module group in the “controller” category. Now suppose further that the controllers require a more sophisticated sensor set. A category named “sen- sors” may also be defined, perhaps with module groups named “endpoint” and “joint”. The highest level of the hierarchy allows the user to select an active group from each category, and name these selections as a configu- ration. Thus, the “JointPD” configuration might con- sist of the “joint” sensors and the “PD” controller. The “endptLQG” configuration could be the “endpoint” sen- sors and the “LQG” controller. Category and Group Specification This subdivi- sion may seem complex in these simple cases. However, it is quite powerful in more realistic systems. It has been shown to be quite natural in applications rang- ing from a vision-guided dual-arm robotic system able to catch moving objects [16] to flexible-beam adaptive controllers [27]. Assigning modules to groups and groups to categories is made quite simple with the ControlShell graphical DFE editor’s “configuration definition” window, shown in Figure 6. New categories are added with the click of a button. To create a module group, the user sim- ply names a group, and then clicks on the modules in the data-flow diagram that should belong to that group. The blocks are color-coded to relate the selections back to the user. ![Configuration Definition](image) **Figure 6:** Configuration Definition Configurations are easily defined within the DFE graphical interface. 874 6 Finite State Machines A real-time system in the real world must operate in a complex, event-driven environment. With only a sequential programming language, the burden of managing and reacting to events is left to the programmer. The Finite State Machine (FSM) module is designed to provide a simple strategic-level programming structure that also assists in managing events and concurrency in the system. The FSM module combines a non-sequential programming environment with natural event-driven process management. With this structure, the programmer is actively encouraged to divide the problem into small, independently executing processes. To utilize the FSM module, the programmer first describes the task as a state transition graph. The graph can be directly described within ControlShell's graphical FSM editor (see Figure 7). Each transition—represented by an arrow in the graph—specifies a starting state, a boolean relation between stimuli that causes the transition, the CSModule to be executed when the transition occurs, and a series of "return code-next state" pairs that determine the program flow. The FSM model is quite general; it supports rule-based transition conditions (reducing the number of states in complex systems), true callable sub-chains of states (so libraries of state subroutines can be developed), wild-card matching (so unexpected stimuli can be processed), global matching (allowing easy error processing), and conditional succession (so state programs may easily branch). Transitions are specified as boolean relations of three types of stimuli: transient, latched, and conditional. Transient stimuli have no value, and exist only instantaneously. Latched stimuli also have no value, but persist until some transition expression matches. Condition stimuli have string values; they persist indefinitely and thus represent memory in the system. Thus, the transition condition “Object = Visible AND Acquire” might cause a system to react to an acquisition command from a high-level controller. Providing these three stimuli types allows combination of both “system status” and “event” types of asynchronous inputs into easily-understood programs. The FSM module takes advantage of the atomic message-passing capability of modern real-time kernels to weave the incoming asynchronous events into a single event stream. Any process can call a simple routine to queue the event; the FSM code spawns a process to execute the resulting event stream. The result is an easy-to-use, yet powerful real-time programming paradigm. 7 Data Control and Binding Most data in a ControlShell application is embodied in CS Mats. A CS Mat is a named matrix of floating-point values. Each row and column of the matrix operationally contains a field name and a units specification. A complete real-time matrix mathematics utilities package is included. Components may combine multiple CS Mats into structures for efficient reference and parameter passing. The entire control hierarchies are created and bound to the correct data objects at run-time. The system is built from the graphically-generated description files produced by the DFE and FSM editors. This dynamic binding paradigm is very powerful—it combines the convenience of automatic system building with the flexibility of a dynamically changeable system. Thus, it provides the features of a full code generation without the pre-compiled inflexibility. To support this dynamic binding, ControlShell incorporates a “linking” database facility. All instances of each data object (such as CS Mats)—and each control construct (such as execution lists)—are entered into the database upon creation. The database allows “reference before creation” semantics for many object types; if a requested object is not in the database (i.e. it does not exist), an incomplete (e.g. zero-sized) object will be created by the database itself. This capability allows considerable flexibility at run-time; modules may, for instance, specify dependencies on data sets that do not yet exist, etc. Verification routines insure that the system is consistent before actual "live" execution begins. 8 Network Connectivity ControlShell is integrated with a network connectivity package called the Network Data Delivery Service. (NDDS) [11]. NDDS is a novel network-transparent data-sharing system. NDDS features the ability to handle multiple producers, consumer update guarantees, notifications or "query" updates, dynamic binding of producers and consumers, user-defined data types, and more. The NDDS system builds on the model of information producers (sources) and consumers (sinks). Producers register a set of data instances that they will produce and then "produce" the data at their own discretion. Consumers "subscribe" to updates of any data instances they require. Producers are unaware of prospective consumers; consumers are not concerned with who is producing the data they use. Thus, the network configuration can be easily changed as required. NDDS is a symmetric system, with no "special" or "privileged" nodes or name servers. All nodes are functionally identical and maintain their own databases. The routing protocol is connectionless and "quasi-stateless"; all data producer and consumer information is dynamically maintained. Thus dropped packets, node failures, reconfigurations, over-rides, etc. are all handled naturally. This scheme is particularly effective for systems (such as distributed control systems) where information is of a repetitive nature. NDDS is an efficient, easy-to-use distributed data-sharing system. Figure 8 illustrates the use of NDDS within a cooperating-arms robot system (see [24]). ![Diagram of NDDS](image) **Figure 8: Network Data Delivery Service** NDDS provides a network "backplane". Each module can easily share data with any other module. The individual connections are handled transparently by the system. --- 1The databases at each node cache some state for efficiency, but all information decays over time. 9 Conclusions This paper has presented a brief overview of the capabilities of the ControlShell system. ControlShell is designed—first and foremost—to be an environment that enables the development of complex real-time systems. Emphasis, therefore, has been placed on a clean and open system structure, powerful system-building tools, and inter-project code sharing and reuse. Acknowledgements ControlShell is being jointly developed by Stanford University and Real-Time Innovations, Inc. It is currently supported under ARPA's Domain-Specific Software Architectures (DSSA) program. The authors wish to expressly thank Dr. Marc Ullman for his many contributions to this project, and Dr. R. H. Cannon, Jr. for his guidance and leadership. The authors would also like to thank the many developers at Stanford, Loral, and NASA who have contributed ControlShell components. References C. M. Oakley, Experiments in Modelling and End-Point Control of Two-Link Flexible Manipulators. PhD thesis, Stanford University, Department of Mechanical Engineering, Stanford, CA 94305, April 1991.
{"Source-Url": "https://ntrs.nasa.gov/archive/nasa/casi.ntrs.nasa.gov/19950005143.pdf", "len_cl100k_base": 4804, "olmocr-version": "0.1.53", "pdf-total-pages": 8, "total-fallback-pages": 0, "total-input-tokens": 25860, "total-output-tokens": 6398, "length": "2e12", "weborganizer": {"__label__adult": 0.0003452301025390625, "__label__art_design": 0.00034546852111816406, "__label__crime_law": 0.0003933906555175781, "__label__education_jobs": 0.0004584789276123047, "__label__entertainment": 5.9604644775390625e-05, "__label__fashion_beauty": 0.00015091896057128906, "__label__finance_business": 0.0002124309539794922, "__label__food_dining": 0.0003426074981689453, "__label__games": 0.0006308555603027344, "__label__hardware": 0.002765655517578125, "__label__health": 0.00044155120849609375, "__label__history": 0.00022172927856445312, "__label__home_hobbies": 0.00012969970703125, "__label__industrial": 0.0010652542114257812, "__label__literature": 0.0001538991928100586, "__label__politics": 0.0001958608627319336, "__label__religion": 0.0003705024719238281, "__label__science_tech": 0.0703125, "__label__social_life": 6.496906280517578e-05, "__label__software": 0.01514434814453125, "__label__software_dev": 0.904296875, "__label__sports_fitness": 0.00038552284240722656, "__label__transportation": 0.00112152099609375, "__label__travel": 0.0001811981201171875}, "weborganizer_max": "__label__software_dev", "avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_ratio": [[0, 28618, 0.02272]], "fineweb_edu_fasttext_gt2__fineweb_edu_fasttext_gt2__score": [[0, 28618, 0.57429]], "ft_lang_id_en_doc_v2__ft_lang_id_en_doc_v2__en": [[0, 28618, 0.88351]], "google_gemma-3-12b-it_contains_pii": [[0, 2440, false], [2440, 6375, null], [6375, 10696, null], [10696, 13818, null], [13818, 17233, null], [17233, 21521, null], [21521, 25978, null], [25978, 28618, null]], "google_gemma-3-12b-it_is_public_document": [[0, 2440, true], [2440, 6375, null], [6375, 10696, null], [10696, 13818, null], [13818, 17233, null], [17233, 21521, null], [21521, 25978, null], [25978, 28618, null]], "google_gemma-3-4b-it_v2tag__is_academic_paper": [[0, 5000, true], [5000, 28618, null]], "google_gemma-3-4b-it_v2tag__is_class_syllabus": [[0, 5000, false], [5000, 28618, null]], "google_gemma-3-4b-it_v2tag__is_completion_certificate": [[0, 5000, false], [5000, 28618, null]], "google_gemma-3-4b-it_v2tag__is_court_notice": [[0, 5000, false], [5000, 28618, null]], "google_gemma-3-4b-it_v2tag__is_homework_assignment": [[0, 5000, false], [5000, 28618, null]], "google_gemma-3-4b-it_v2tag__is_news_article": [[0, 5000, false], [5000, 28618, null]], "google_gemma-3-4b-it_v2tag__is_public_order": [[0, 5000, false], [5000, 28618, null]], "google_gemma-3-4b-it_v2tag__is_resume_cv": [[0, 5000, false], [5000, 28618, null]], "google_gemma-3-4b-it_v2tag__is_test_or_quiz": [[0, 5000, false], [5000, 28618, null]], "google_gemma-3-4b-it_v2tag__is_textbook": [[0, 5000, false], [5000, 28618, null]], "pdf_page_numbers": [[0, 2440, 1], [2440, 6375, 2], [6375, 10696, 3], [10696, 13818, 4], [13818, 17233, 5], [17233, 21521, 6], [21521, 25978, 7], [25978, 28618, 8]], "pipe_delimited_lines_v1__pipe_delimited_lines_v1__pipe_delimited_lines_ratio": [[0, 28618, 0.06077]]}
olmocr_science_pdfs
2024-12-07
2024-12-07
bf837919549bea974dd9735d97aeb2738ec9795a
Creating disaggregated network services with eBPF: the Kubernetes network provider use case Original Availability: This version is available at: 11583/2970898 since: 2022-09-05T13:01:36Z Publisher: Institute of Electrical and Electronics Engineers Inc. Published DOI:10.1109/NetSoft54395.2022.9844062 Terms of use: openAccess This article is made available under terms and conditions as specified in the corresponding bibliographic description in the repository Publisher copyright IEEE postprint/Author's Accepted Manuscript ©2022 IEEE. Personal use of this material is permitted. Permission from IEEE must be obtained for all other uses, in any current or future media, including reprinting/republishing this material for advertising or promotional purposes, creating new collecting works, for resale or lists, or reuse of any copyrighted component of this work in other works. (Article begins on next page) Creating Disaggregated Network Services with eBPF: the Kubernetes Network Provider Use Case Federico Parola, Leonardo Di Giovanna, Giuseppe Ognibene, Fulvio Risso Dept. of Control and Computer Engineering, Politecnico di Torino 24, Corso Duca degli Abruzzi, Torino, 10129, Italy Email: {federico.parola, leonardo.digiovanna, giuseppe.ognibene, fulvio.risso}@polito.it Abstract—The eBPF technology enables the creation of custom and highly efficient network services, running in the Linux kernel, tailored to the precise use case under consideration. However, the most prominent examples of such network services in eBPF follow a monolithic approach, in which all required code is created within the same program block. This makes the code hard to maintain, to extend, and difficult to reuse in other use cases. This paper leverages the Polycube framework to demonstrate that a disaggregated approach is feasible also with eBPF, with minimal overhead, introducing a larger degree of code reusability. This paper considers a complex network scenario, such as a complete network provider for Kubernetes, presenting the resulting architecture and a preliminary performance evaluation. I. INTRODUCTION The extended Berkeley Packet Filter (eBPF) allows executing arbitrary code in different kernel hooks, which are triggered upon multiple events, such as a syscall or a packet received. This enables to extend the processing done by the kernel without changing its source code or loading kernel modules. eBPF code is sandboxed in order to guarantee that a user provided program can not compromise the functioning of the kernel. Several projects leverage eBPF to bring new functionality to the kernel in the fields of security, monitoring and networking. However, most of the networking-related projects implement new features as monolithic eBPF programs, making the code hard to maintain, to extend, and difficult to reuse in other use cases. In this respect, the Polycube software framework [1] addresses some of the well-known eBPF limitations when creating complex virtual network functions [2], and introduces the capability to split eBPF software in multiple, independent network functions, which can be arbitrarily connected in order to create a more complex service graph. This enables the creation of complex networking services by compositing elementary basic blocks (e.g., bridge, router, firewall, NAT, load balancer, and more), with an high degree of reusability. Container networking is a perfect example of such scenario, and has gained key importance with the diffusion of the microservices architecture and the decomposition of applications in a collection of small, loosely-coupled services running in containers. Container orchestrators such as Kubernetes (K8s) must provide a flexible and efficient network infrastructure, since containers can be created and destroyed at high frequency, must exchange a lot of data and must be easily accessible from the Internet. However, K8s defines only a functional networking model and it relies on 3rd party plugins for the actual implementation of network services. This paper shows how a K8s network provider can be created using solely eBPF primitives according to the disaggregated services model, i.e., defining a modular architecture based on traditional network components such as routers, load balancers and NATs, and without giving up on performance. This paper is structured as follows. Section II provides an overview of the K8s networking model and how Polycube achieves service disaggregation. Section III describes the overall node architecture of our solution while Section IV shows a preliminary performance comparison compared to existing solutions. Finally, Section V describes the relevant related work and Section VI draws our conclusions, highlighting the potential future work. II. BACKGROUND A. Kubernetes networking Kubernetes is an open-source orchestrator for containerized applications and defines a functional network architecture organized in three levels. (i) Pods, the basic scheduling concept, execute containerized applications that are connected to a default virtual network, whose outreach is limited to a single server (node, in the Kubernetes terminology). Pods are ephemeral entities that can be destroyed and re-spawned if needed, even on another node. Each server can host a maximum number of pods, usually organized in a contiguous and private address space (e.g., consecutive /24 networks on different nodes). (ii) Physical nodes, which inherit their addressing space from the physical datacenter network; for scalability reasons, this usually includes switched and routed portions. (iii) Services, a higher-level concept that enables the reachability of one or more (homogeneous) pods by means of the same network identifier (e.g., IP address). This primitive guarantees the decoupling between the service IP endpoint, which remains stable, from the actual pod(s) that provides the service, whose IP can change (e.g., in case the pod is restarted in another location) or it may be present in multiple replicas (hence, multiple IPs could be used). Services leverage a third addressing space, disjoint from pod and datacenter addresses. Kubernetes foresees three types of services. A ClusterIP identifies a service that is reachable only from pods within the cluster, or by an application that runs on the cluster... nodes. A NodePort service, instead, is reachable from outside the datacenter: a TCP/UDP port <nport> is allocated to the service itself, and all packets directed to any <node_ip_address:nport> will be redirected to one of the pods associated to the given service. NodePorts are not widely used because they require (i) nodes with reachable (e.g., public) IP addresses; (ii) external users to know the IP addresses of the nodes and (even worse) (iii) the port that has been allocated. Finally, a LoadBalancer service allocates a public IP address associated to the given service, which is achieved by interacting with an external entity in charge of the above public addresses; all packets directed to the LoadBalancer IP address will be delivered to one of the corresponding pods. Basic connectivity between pods is provided through the cooperation of datacenter networking and plugins implementing the CNI (Container Network Interface) [3], a specification that enables changeable modules that configure network interfaces in Linux containers. The CNI specification is very simple, dealing only with network connectivity of containers and removing allocated resources when the container is deleted. Instead, packets to services are by default handled by a dedicated Kubernetes component, kube-proxy, which configures iptables with the proper rules to translate service IP addresses into pod IP addresses, and to implement load-balancing policies. Most of the so-called CNI providers (e.g., Cilium, Calico, Flannel, etc) implement more than just the base CNI specification and include (i) data-center wide networking (either using an overlay model, e.g., through vxlan interfaces, or direct routing, hence interacting with the datacenter physical infrastructure to push the proper routes that satisfy K8s reachability rules) and (ii) IP address management (IPAM module). Instead, most of the CNI providers rely on kube-proxy for services: a packet coming from a pod and directed to a service is delivered by the CNI to kube-proxy, which operates the proper transformation on IP addresses and ports and returns it again to the network plug-in, which takes care of delivering it to the target pod, possibly traversing the datacenter network. K8s adopts a functional model for networking, defining a set of behavioral rules for network connectivity but without specifying how those must be implemented by the specific network provider. In addition to rules already mentioned for services, it adds the following ones for basic connectivity: (i) all pods can communicate with all other pods without NAT; (ii) agents on a node can communicate with all pods on that node; (iii) pods in the host network of a node can communicate with all pods on all nodes without NAT. It turns out that network providers have full freedom to choose their own implementation strategy, hence privileging e.g., the easiness of use, performance, scalability, and more. However, this freedom is widely recognized as a nightmare, being very difficult to understand how each network provider works under the hood, hence severely impairing the capability of a network engineer to debug a problem. This is exacerbated by the complexity of the Kubernetes networking, which overall includes functions such as bridging and routing (for pod-to-pod connectivity), load balancing and NAT (for pod-to-service and Internet-to-service), and masquerading NAT (for pod-to-Internet), not to mention the necessity of security policies (hence, firewalls) to protect both pod-to-everything and external-to-everything communications. Finally, all the above networking components must be integrated with a control plane, which interact with K8s and detect any change in the status of the cluster (e.g., a node/pod/service is added/removed, a service is scaled up/down, etc.), hence propagating the required configurations in all involved components (e.g., adding a new node requires configuring a new route toward that node in the routing table of all existing nodes). Given this complexity, it becomes evident that the capability to rely on well-known (disaggregated) functions (e.g., bridging, routing, load balancers), each one running with their configurations and state, would greatly simplify day-by-day monitoring and debugging operations compared to network providers created according to the monolithic model. B. Service disaggregation with Polycube Polycube [1] is an open-source software framework based on eBPF that enables the creation of arbitrary network function chains, adopting the same model (boxes connected through wires) currently used in the physical world. Polycube network functions, called cubes, are composed by an eBPF-based data plane running in kernel (actually one or more eBPF programs) and a control/management plane running in user space. A user space daemon (polycubed) provides a centralized point of control, allowing to access the configuration and state of cubes through a RESTful API. Cubes can be seamlessly connected to each other or to network interfaces through virtual ports, an abstraction that is implemented through an eBPF wrapping program that performs some pre- and post- processing in order to receive/send packets from the previous/to the next component in the chain. To implement this redirection mechanism, each port is identified by a unique ID inside the cube, and each cube maintains a forward chain map containing information about the peer associated to each port. This information is used by the post-processor to apply the correct action to forward the packet, that could be either a tail call to the eBPF data plane of the next cube or a bpf_redirect() to a destination interface. Figure 1 shows an example of this mechanism for a simple topology composed of one router and one bridge. Chaining capabilities of Polycube represent a suitable way to create disaggregated services; however, this solution has never been validated in a complex scenario such as K8s networking. III. ARCHITECTURE Our proposed architecture targets the entire K8s networking, including also services and, potentially, network policies, hence replacing also kube-proxy, i.e., the component that provides cluster-wide service-to-pod translation and load balancing. Our network provider supports ClusterIP and NodePort \[1\text{https://kubernetes.io/docs/concepts/services-networking/}.\] services and relies on a VxLAN overlay network to support inter-node communication. The current version of the prototype does not support security policies but, thanks to the modular approach, this and other functionalities can easily be added without any change in the other components. The architecture (shown in Fig. 2) leverages four Polycube-based independent network services, while it relies on the kernel to handle the lifecycle of VxLAN tunnels. A. Main components K8s vs Linux Stack Discriminator and NAT (DISC-NAT). This service performs source NATting for the pod-to-Internet traffic, replacing the address of the pod with the address of the node. For incoming packets, it distinguishes among traffic directed to the host (either directly or because it needs VxLAN processing) and traffic directed to pods (an external host trying to contact a NodePort service or the return traffic of a pod). This is done by checking that the packet (i) does not belong to a NATted session (i.e., a lookup in the NAT session table of the service), and (ii) that is not directed to a NodePort service (i.e., a check against the TCP/UDP destination port of the packet). In case both lookups fail, the packet is sent to the Linux network stack. Vice versa, in the first case we apply the reverse NAT rule and the packet continues its journey towards the pods. In the second case, different actions can be applied according to the ExternalTrafficPolicy of the rule. If the policy is local, the traffic is allowed to reach only backend pods located on the current node, hence the packet can proceed towards the pod without modifications. In case the policy is cluster, the packet can also reach backend pods located on other nodes. Since later in the chain the packet will be processed by a load balancer and we must guarantee that the return packet will transit through the same load balancer, we apply source NAT replacing the source IP address with the address of a fictitious pod belonging to the PodCIDR of the current node (currently the first address of the range is used). External Load Balancer (ELB). This element maps new sessions coming from the Internet and directed to a NodePort service to a corresponding backend based on the 5-tuple of the first packet. This load balancing decision is stored in a session table, implemented as a Least Recently Used (LRU) eBPF map, and reused for all subsequent packets. Old sessions are automatically purged by the LRU map. Incoming packets are updated with destination/port of the backend, while source fields are restored to service values for outgoing traffic. Router. Since K8s requires that (i) all the pods in the cluster can communicate with all pods without NAT and (ii) different network addresses (PodCIDR) are allocated to pods on each node, a routing component is required. To facilitate the operations of the Internal Load Balancer (see later), we do not use a bridge between pods, hence forcing all pod traffic to be always delivered to the router. In fact, our network plugin assigns a /32 network to each pod and adds an ARP static entry for the gateway; hence all the packets are sent directly to the gateway, with pods never issuing any ARP request. The router is configured with four ports: (1) towards the physical interface of the node; (2) towards local pods, configured with the proper PodCIDR (e.g., /24); (3) to enable the reachability of K8s processes and pods running in the host network (e.g., kubelet); (4) connected to a kernel VxLAN interface, which is used for inter-node pod-to-pod communication. Internal Load Balancer (ILB). This load balancer operates on traffic coming from local pods and directed to ClusterIP services; all the other traffic is forwarded as is. This module has two types of ports; ‘edge’ ports are connected to entities that generate new sessions (hence, pods), while the ‘server’ port is the one used to reach the final servers, hence is connected to the router. Edge ports are configured with the IP address of the pod in order to be able to forward packets coming from the router to the correct destination. The load balancing logic is the same of the ELB, with a service-specific InternalTrafficPolicy attribute determining which backends (local or cluster-wide) are configured in the load balancer. K8s Control Logic. A K8s operator is in charge of reacting to the cluster events and reconfigure the required network parameters in the controlled cluster. The operator has to react to events related to the following three Kubernetes resources. (1) Nodes: when a node joins/leaves the cluster, a route is added/removed in the Router to update the reachability of the given PodCIDR through the VxLAN overlay network, and the node address is added to the VxLAN configuration. (2) Services: the operator watches events regarding ClusterIP and NodePort services. ClusterIP services trigger an update of the ILB, while a NodePort triggers an update of the ELB and DISC-NAT module for the obvious reasons, as well as the ILB because of the creation of the ClusterIP address that is associated with the NodePort service. (3) Endpoints: the operator watches any event that refers to Endpoints associated to Services. For each pair (address, port) extracted from the endpoints object, the corresponding service backend is updated on the proper Load Balancer: the ILB for ClusterIP services and both for NodePort services. This component is deployed as a K8s DaemonSet, which ensures it runs on any node; K8s adopts a distributed configuration, in which each node has its own agent in charge of the node network configuration. This DaemonSet runs as privileged pod, and it includes the polykube-operator container (running the actual K8s control plane) and the polykube container (running the Polycube daemon). The two communicate through the node loopback interface. B. Communication scenarios The main communication scenarios of a typical K8s cluster, as shown in Fig. 3, are implemented as follows. Pod-to-pod. The originating pod sends its packets to the ILB, which transparently forwards them to the Router. If the destination is on the same node, the traffic is sent back immediately and the ILB forwards it to the destination. If the destination pod is on another node, the router redirects the packets to the VxLAN interface, where they are encapsulated by the kernel and forwarded to the destination node. On the remote node, the DISC-NAT passes the traffic to the kernel, which decapsulates it and sends it to the router and then to destination pod. Pod-to-Internet. The traffic traverses the ILB, then the router forwards it towards the physical interface of the node, hence transparently crossing also the ELB. The NAT, instead, applies a source NATting rule, hence replacing the address of the pod with the one of the node, as well as the source port with a new available one. This allows the return traffic to reach the correct node without the necessity to advertise the PodCIDR on the external network. On the return path, the NAT checks if the packet belongs to a translated session; if so, it replaces the destination address and port of incoming packets with the ones of the original pod. Pod-to-service. The pod traffic toward a ClusterIP service is first processed by the ILB, which selects a proper backend pod and updates the destination address and port of packets. Traffic is then handled by the router in the same way as with the pod-to-pod communication. For return traffic, the ILB checks if the packet belongs to a translated session; if so, it restores the original source service address and port. Internet-to-service. When a remote host wants to contact a NodePort service, the first packet is processed by the DISC-NAT, that identifies it as targeting a NodePort service (based on the destination port). If the ExternalTrafficPolicy of the service is cluster, the DISC-NAT updates the source address of the packet with the one of the fictitious pod, to guarantee that the return packet will come to the same node. The packet is then forwarded to the ELB, which (i) selects a proper backend pod, (ii) updates the destination address and port with the ones of the backend, and (iii) forwards the packet to the router, that can handle it such as in normal pod-to-pod communications. IV. Evaluation This section presents an assessment of the performance provided by our network provider under different circumstances, to determine whether the disaggregated approach would introduce any noticeable performance penalty. We run the tests using the iperf3 tool, configured with the default parameters; the server was always running in a pod, while the client was either in a physical machine or in another pod depending on the test. Tests were carried out on a cluster of 2 nodes, each one featuring a CPU Intel® Xeon® CPU E3-1245v5@3.50GHz (4 cores plus HyperThreading), 64GB RAM, and a dualport 40 GbE Ethernet XL710 QSFP+ card, all running Linux kernel v5.4.0 and K8s v1.23.5. Tests involve other two eBPF-based solutions (namely, Cilium and Calico) and a widely used ‘traditional’ approach such as Flannel [4]. All providers were deployed using the VxLAN overlay model; Cilium and Calico were configured with their eBPF kubeproxy replacement, hence enabling a complete eBPF data plane such as in our solution. We considered the following communication scenarios: pod-to-pod: a pod client connects to the actual IP address of a pod server, showing the performance of the base networking without load balancing; pod-to-service: a pod client connects to a pod server using its ClusterIP service, to evaluate the performance of the load balancer as well as the L3 routing; internet-to-service: the client is executed in an external host and the pod server is accessed through its NodePort service. Tests were performed with pods running both on a single node and on multiple nodes, with the latter adding the overhead of the VxLAN encapsulation and the limitation of the physical network (link speed, PCI bus) and requiring to cross the physical network twice (i) client to receiving node; (ii) receiving node to backend node) for the internet-to-service tests. Results are depicted in Fig. 4, with the red dashed lines representing the baseline achieved running bare metal iperf3 on localhost (in case of single node) or between two nodes. As expected, the throughput decreases when the traffic traverses a larger number of network components. However, despite the disaggregated architecture, our solution provides always better performance compared to other solutions, with even higher margins when considering multiple nodes. While this result may be impacted by other providers supporting more features than our PoC code, such as network policies, these have not been used in the tests, hence providing the ground for a fair comparison. Overall, this suggests how disaggregation does not introduce performance penalties compared to a traditional monolithic approach. Figure 5 shows the reaction time of our operator and CNI plugin when requiring to scale up/down the pods of a service, compared with time required by other Kubernetes components until connectivity to the target pod is available/disabled. Results show that the time taken by our components is negligible compared to the overall time required by K8s to react. V. RELATED WORK Among the many eBPF-based network services, we cite here only the ones that are most representative in this space. Katran [5] represents a software solution to offer scalable network load balancing to layer 4 that leverages eBPF/XDP to provide fast packet processing. While being very sophisticated, it has been engineered to be the sole (monolithic) network function active on the network path, hence preventing the deployment of other functions operating on the same traffic. Cilium [6] provides networking, security and observability for cloud-native environments such as Kubernetes clusters. Cilium is based on eBPF, which allows for the dynamic insertion of powerful network security, visibility and control logic into the Linux kernel. In Cilium, eBPF is used to provide high-performance networking, multi-cluster and multi-cloud capabilities, advanced load balancing, transparent encryption, extended network security features, and much more. While providing observability primitives through its Hubble module, its internals are rather complex and made with a monolithic approach. Cilium defines a set of six logical objects (Prefilter, Endpoint Policy, Service, etc.), based on six different features offered by the provider (DoS mitigation, network policies, load balancing, etc.). However, these objects are not mapped into clearly separated modules, neither for the data plane (their logic is scattered among different intertwined eBPF programs), nor from a control plane perspective (cannot track the path of a packet or capture the traffic flowing from one object to another), nor from a control plane perspective (cannot configure and inspect these objects independently). Similar characteristics can be found in Calico [7], which recently adopted the eBPF/XDP technology as well. VI. CONCLUSIONS We presented a network provider for Kubernetes based on disaggregated eBPF services, which improves monitoring and debugging as well as how code can be maintained, extended and reused. Our open-source solution\(^2\) demonstrates the feasibility of the disaggregated approach in eBPF and our preliminary evaluation shows no particular overhead introduced by our model with respect to another state-of-the art monolithic solution. As a future work we plan to introduce support for (i) direct routing and (ii) network policies. ACKNOWLEDGMENT Authors thank Hamza Rhouaoui for his initial work on this topic, all the people who contributed to the Polycube project, and Roberto Procopio and Yunsong Lu for their support. Finally, Federico Parola acknowledges the support from TIM S.p.A. through the PhD scholarship. REFERENCES
{"Source-Url": "https://iris.polito.it/retrieve/d6a82da4-289b-4f33-b32e-f14f0087f2b8/author_Creating%20Disaggregated%20Network%20Services%20with%20eBPF:%20the%20Kubernetes%20Network%20Provider%20Use%20Case.pdf", "len_cl100k_base": 5500, "olmocr-version": "0.1.53", "pdf-total-pages": 6, "total-fallback-pages": 0, "total-input-tokens": 18896, "total-output-tokens": 6313, "length": "2e12", "weborganizer": {"__label__adult": 0.00037741661071777344, "__label__art_design": 0.0003921985626220703, "__label__crime_law": 0.0003654956817626953, "__label__education_jobs": 0.00047397613525390625, "__label__entertainment": 0.00015783309936523438, "__label__fashion_beauty": 0.0001690387725830078, "__label__finance_business": 0.0004477500915527344, "__label__food_dining": 0.0003790855407714844, "__label__games": 0.0005993843078613281, "__label__hardware": 0.005615234375, "__label__health": 0.0006012916564941406, "__label__history": 0.00041747093200683594, "__label__home_hobbies": 0.00011712312698364258, "__label__industrial": 0.0009007453918457032, "__label__literature": 0.00024056434631347656, "__label__politics": 0.00029778480529785156, "__label__religion": 0.0005364418029785156, "__label__science_tech": 0.307373046875, "__label__social_life": 0.00012034177780151369, "__label__software": 0.04034423828125, "__label__software_dev": 0.63818359375, "__label__sports_fitness": 0.00035691261291503906, "__label__transportation": 0.0010547637939453125, "__label__travel": 0.00029921531677246094}, "weborganizer_max": "__label__software_dev", "avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_ratio": [[0, 28100, 0.02259]], "fineweb_edu_fasttext_gt2__fineweb_edu_fasttext_gt2__score": [[0, 28100, 0.33321]], "ft_lang_id_en_doc_v2__ft_lang_id_en_doc_v2__en": [[0, 28100, 0.91348]], "google_gemma-3-12b-it_contains_pii": [[0, 1300, false], [1300, 6722, null], [6722, 13109, null], [13109, 17892, null], [17892, 23249, null], [23249, 28100, null]], "google_gemma-3-12b-it_is_public_document": [[0, 1300, true], [1300, 6722, null], [6722, 13109, null], [13109, 17892, null], [17892, 23249, null], [23249, 28100, null]], "google_gemma-3-4b-it_v2tag__is_academic_paper": [[0, 5000, true], [5000, 28100, null]], "google_gemma-3-4b-it_v2tag__is_class_syllabus": [[0, 5000, false], [5000, 28100, null]], "google_gemma-3-4b-it_v2tag__is_completion_certificate": [[0, 5000, false], [5000, 28100, null]], "google_gemma-3-4b-it_v2tag__is_court_notice": [[0, 5000, false], [5000, 28100, null]], "google_gemma-3-4b-it_v2tag__is_homework_assignment": [[0, 5000, false], [5000, 28100, null]], "google_gemma-3-4b-it_v2tag__is_news_article": [[0, 5000, false], [5000, 28100, null]], "google_gemma-3-4b-it_v2tag__is_public_order": [[0, 5000, false], [5000, 28100, null]], "google_gemma-3-4b-it_v2tag__is_resume_cv": [[0, 5000, false], [5000, 28100, null]], "google_gemma-3-4b-it_v2tag__is_test_or_quiz": [[0, 5000, false], [5000, 28100, null]], "google_gemma-3-4b-it_v2tag__is_textbook": [[0, 5000, false], [5000, 28100, null]], "pdf_page_numbers": [[0, 1300, 1], [1300, 6722, 2], [6722, 13109, 3], [13109, 17892, 4], [17892, 23249, 5], [23249, 28100, 6]], "pipe_delimited_lines_v1__pipe_delimited_lines_v1__pipe_delimited_lines_ratio": [[0, 28100, 0.0]]}
olmocr_science_pdfs
2024-12-06
2024-12-06
acec8012955bc28725afa57db74fcfaae7097c42
Tolerating Silent Data Corruption (SDC) causing Hardware Faults through Software Techniques Karthik Pattabiraman Anna Thomas, Qining Lu, Jiesheng Wei, Bo Fang University of British Columbia (UBC) Meeta S. Gupta, Jude A. Rivers, IBM Research Sudhanva Gurumurthi, AMD Research My Research • Building fault-tolerant and secure software systems • Three areas • Software resilience techniques [CASES’14][DSN’13][ISPASS’13] • Web applications’ reliability [ICSE’14][ICSE’14][ESEM’13] • Smart meter security [HASE’14][WRAITS’12] • This talk: Software resilience techniques Motivation: Variations & Errors • Variation of device times • Higher spread of device variations for future generations of technology • Feature size Vs MTTU • Increase in number of bits correlated with decrease in MTTU of the chip Source (CCC study on cross-layer reliability): www.relxlayer.org (2011) Hardware Errors: “Solutions” - **Guard-banding** Guard-banding wastes power and performance as gap between average and worst-case widens due to variations. - **Duplication** Hardware duplication (DMR) can result in 2X slowdown and/or energy consumption. Why Application-level techniques? - Application Level - Operating System Level - Architectural Level - Device/Circuit Level Impactful Errors Overheads Our Goal - Detect errors that cause Silent Data Corruption (SDC) - Wrong results, Error Propagation etc. - Error Detection Coverage vs. Performance Overhead - Achieve high SDC coverage while incurring low overhead by selectively protecting program instructions/data - No fault injections in applying to new programs - Fault injections take significant time and effort Outline - Motivation and Goals - EDC Causing Error Detection [DSN’13][SELSE’13] - SDCTune: Protecting programs from SDCs [CASES’14] - Error Resilience Characterization on GPUs [ISPASS’14] - Conclusions and Future Work Soft Computing Applications - Expected to dominate future workloads [Dubey’07] Original image (left) versus faulty image from JPEG decoder Egregious Data Corruptions (EDCs) - Large or unacceptable deviation in output EDC image (PSNR 11.37) vs Non-EDC image (PSNR 44.79) Goal Detect EDC causing faults Pre-emptive Selective Application Execution Detector EDC Non-EDC Benign Fault model • **Transient hardware faults** • Caused by particle strikes, temperature, etc. • Assume that program data is corrupted • **Our Fault Model** • Single bit flip, One fault per run • Processor registers and execution units • Memory and cache protected with ECC Approach - Step 1: Separate EDCs from Non-EDCs by fault injections - Step 2: Heuristics identifying code regions prone to EDC causing faults - Step 3: Automated algorithm for detector placement Step 1: Initial Study - Correlation between data type – fault outcome Monitor Control/Pointer Data - Instrument code - Fault Injection Performed using LLFI [DSN’14] Data Categorization: Faults High correlation between Control Non-Pointer and EDC/Non-EDC Step 2: Heuristics ```c void conv422to444 (char *src, char *dst, int height, int width, int offset) { for(j=0; j < height; j++) { for(i=0; i < width; i++) { im1 = (i < 1) ? 0 : i - 1 ... dst[im1] = Clip[(21*src[im1])>>8]; } if( j + 1 < offset) { src += w; dst += width; } } } ``` Step 2: Heuristics Faults affecting branches with large amount of data within branch body, has a higher likelihood of resulting in EDC outcomes ```c void conv422to444 (char *src, char *dst, int height, int width, int offset) { for(j=0; j < height; j++) { for(i=0; i < width; i++) { im1 = (i < 1) ? 0 : i - 1 ... dst[im1] = Clip[(21*src[im1])>>8]; } if( j + 1 < offset) { src += w; dst += width; } } } ``` - Fault in offset - Branch Flip High EDC Likelihood Step 2: Heuristics Faults affecting branches with large amount of data within branch body, has a higher likelihood of resulting in EDC outcomes ```c void conv422to444 (char *src, char *dst, int height, int width, int offset) { for(j=0; j < height; j++){ for(i=0; i < width; i++) { im1 = (i < 1) ? 0 : i – 1 ... dst[im1] = Clip[(21*src[im1])>>8]; } if( j + 1 < offset) { src += w; dst += width; } } } ``` ➤ Fault in result of branch Low EDC Likelihood Step 3: Algorithm Automated Detector Placement Algorithm - Application Source Code - Performance Overhead - Execution Profile - Data Variables or Locations to Protect Step 3: Algorithm Application Source Code → Compiler → IR → EDC Ranking Algorithm → Selection Algorithm → Performance Overhead → Execution Profile → Data Variables or Locations to Protect → Backward slice replication Experimental Setup - Six Benchmarks from MediaBench, Parsec Suite - Fidelity Metric: PSNR, scaled distortion [Misailovic’12] - Performed fault injections using LLFI [DSN’14] - 2000 fault injections, one fault per run (1.3% at 95% CI) - Validated with respect to assembly-level injectors for EDCs - Measured EDC coverage under varying performance overhead bounds of 10, 20 and 25% Experimental Framework 1. Choose dynamic data instance at random 2. Inject Random Single bit flip 3. Execute Application 4. Compare faulty & fault-free outcome 5. Exception - Crash 6. Value Change - Fidelity Metric - High deviation - Low Deviation 7. No Change - Benign 8. EDC - Non-EDC Coverage Evaluation Average EDC Coverage of 82% versus 56% under 10% performance overhead Higher is better Coverage Evaluation Selectivity Detection Lower is better Our technique detects most EDC causing errors for a fraction of the cost of full duplication. Outline • Motivation and Goals • EDC Causing Error Detection [DSN’13][SELSE’13] • SDCTune: Protecting programs from SDCs [CASES’14] • Error Resilience Characterization on GPUs [ISPASS’14] • Conclusions and Future Work SDCTune: Goals • Earlier work on EDC causing errors showed feasibility of selectively protecting critical data • Can we extend this to SDCs in general-purpose applications which are not as error resilient? • Challenge: • Not feasible to identify SDCs based on amount of data affected by the fault as was the case with EDCs • Need for comprehensive model for predicting SDCs based on static and dynamic program features Main Idea - Start from “Store” and “Cmp” instructions propagate backward through data dependencies. “Store” and “Cmp” are the end of visible data-dependency chain at the compiler levels. - Predict P(SDC | Store or Cmp) - Extract the related features by static/dynamic analysis - Quantify the effects by classification and regression - Estimate SDC rate of different “Store” and “Cmp” instructions Approach: Overview - **Classification** - Classify the *stored values* and *comparison values* according to the extracted features (through static analysis) - Organize the features as a decision tree with each feature corresponding to a branch - **Regression** - Within a single category, SDC rate may exhibit gradual correlations with several features - Use linear regression for the classified groups to estimate the SDC rate within a node of the tree Approach: Decision Tree Example: *Linear Regression for a Leaf* \[ P_{SDCI} = -0.12 \times \text{data width} + 0.878 \] Approach: Instruction Selection • Select instructions for Protected Set • Knapsack problem: value: estimated $P(SDC,I)$, weight: $P(I)$ • A set of instructions to protect for a given overhead bound • Replicate static backward slices of the instructions to protect • Test coverage on training programs • Measure the coverage for different overhead bounds and tune the model • Apply the model to a different set of programs to evaluate it Experimental Methodology Training phase SDC rate for each instruction $P(SDC|I)$ from training programs P(SDC|I) Predictor Features extracted based on heuristic knowledge from training programs Testing phase Optimal selection: estimated $P(SDC|I)P(I)$ vs. $P(I)$ Set $\{\text{Instructions}\}$ for a certain overhead bound $(\Sigma P(I))$ Random Fault Injection Results from testing programs Actual SDC coverage for testing programs Features extracted from testing programs Measure real coverage on testing programs Estimation of overall SDC rates: We start with the most SDC prone instructions and iteratively expand the set of instructions until the performance overhead bounds are under a given performance overhead bound, and compare it with the percentages of SDCs detected. We then compare our results with those of full duplication, i.e., when every instruction is duplicated in the program. ### 5.3 Work Flow and Implementation Figure 7 shows the workflow for estimating the overall SDC rate of an application, as well as the SDC coverage are compiled and linked into native executables with -O2 optimization. All the applications are shown in Table 5 and Table 6 respectively. All the applications are marked with bold code as check. (c) shows how we move the check out of the loop and save one checker detection technique. We calculate the efficiency of each benchmark with those of full duplication, i.e., when every instruction is duplicated in the program. Similar to the efficiency defined in Section 2.3. ### Benchmarks <table> <thead> <tr> <th>Program</th> <th>Description</th> <th>Benchmark suite</th> </tr> </thead> <tbody> <tr> <td>IS</td> <td>Integer sorting</td> <td>NAS</td> </tr> <tr> <td>LU</td> <td>Linear algebra</td> <td>SPLASH2</td> </tr> <tr> <td>Bzip2</td> <td>Compression</td> <td>SPEC</td> </tr> <tr> <td>Swaptions</td> <td>Price portfolio of swaptions</td> <td>PARSEC</td> </tr> <tr> <td>Water</td> <td>Molecular dynamics</td> <td>SPLASH2</td> </tr> <tr> <td>CG</td> <td>Conjugate gradient method</td> <td>NAS</td> </tr> </tbody> </table> <table> <thead> <tr> <th>Program</th> <th>Description</th> <th>Benchmark suite</th> </tr> </thead> <tbody> <tr> <td>Lbm</td> <td>Fluid dynamics</td> <td>Parboil</td> </tr> <tr> <td>Gzip</td> <td>Compression</td> <td>SPEC</td> </tr> <tr> <td>Ocean</td> <td>Large-scale ocean movements</td> <td>SPLASH</td> </tr> <tr> <td>Bfs</td> <td>Breadth-First search</td> <td>Parboil</td> </tr> <tr> <td>Mcf</td> <td>Combinatorial optimization</td> <td>SPEC</td> </tr> <tr> <td>Libquantum</td> <td>Quantum computing</td> <td>SPEC</td> </tr> </tbody> </table> Experiments • Estimate overall SDC rates using SDCTune and compare with fault injection experiments • Measure correlation between predicted and actual • Measure SDC Coverage of detectors inserted using SDCTune for different overhead bounds • Consider 10, 20 and 30% performance overheads • Compared performance overhead and efficiency with full duplication and hot-path duplication • Efficiency = SDC coverage / Performance overhead Overall SDC Rates: Ranks <table> <thead> <tr> <th></th> <th>Training programs</th> <th>Testing programs</th> </tr> </thead> <tbody> <tr> <td>Rank correlation*</td> <td>0.9714</td> <td>0.8286</td> </tr> <tr> <td>P-value**</td> <td>0.00694</td> <td>0.0125</td> </tr> </tbody> </table> SDC coverage ranges from 45% to 87% for the training programs as overhead goes from 10 to 30%, while for testing programs it ranges from 39% to 75% for the same overhead. Full duplication and hot-path duplication (top 10% of paths) have high overheads. For full duplication it ranges from 53.7% to 73.6%, for hot-path duplication it ranges from 43.5 to 57.6%. Detection efficiency of the detectors normalized to full duplication is 2.87x, 2.34x and 1.84x at the 10%, 20% and 30% overheads. Outline • Motivation and Goals • EDC Causing Error Detection [DSN’13][SELSE’13] • SDCTune: Protecting programs from SDCs [CASES’14] • Error Resilience Characterization on GPUs [ISPASS’14] • Conclusions and Future Work GPU Error Resilience: Motivation - GPUs have traditionally been used for error-resilient workloads - E.g. Image Processing - GPUs are used in general-purpose applications, i.e. GPGPU - Small errors can lead to completely incorrect outputs ATATTTTTTCTTGTT TTTATATCCACAAA CTCTTTTCGTACTTT TACACAGTATATCGT GT ATATTTTTTCTTGTT TTTATATCCACAAT CTCTTTTCGTACTTT TACACAGTATATCGT GT Error Error GPU Fault Injection: Challenges • **Challenge 1: Scale of GPGPU applications** • GPGPU applications consist of thousands of threads, and injecting sufficient faults in each thread will be very time consuming • **Challenge 2: Representativeness** • Need to execute application on real GPU to get hardware error detection • Need to uniformly sample the execution of the application to emulate randomly occurring faults Addressing Challenge 1: Scale - Choose representative threads to inject faults into - Group threads with similar numbers of instructions into equivalence classes and sample from each class (or from the most popular thread classes) - Hypothesis: Threads that execute similar numbers of instructions have similar behavior – validated by injection Addressing Challenge 2: Representativeness • We use a source-level debugger for CUDA® GPGPU applications called CUDA-gdb • Advantage: Directly inject into the GPU hardware • Disadvantage: Requires source-code information to set breakpoints for injecting faults • Our solution: Single-step the program using CUDA-gdb and map dynamic instructions to source code Fault injection Methodology: GPU-Qin Experimental Setup - NVIDIA® Tesla C 2070/2075 - 12 CUDA benchmarks comprising 15 kernels - Rodinia, Parboil and Cuda-SDK benchmark suites - Only consider activated faults – faults read by application - Outcomes - Benign: correct output - Crash: hardware exceptions raised by the system - Silent Data Corruption (SDC): incorrect output, as obtained by comparing with golden run of the application - Hang: did not finish in considerably longer time SDC Rates vary significantly across benchmarks (from 2 to 40%), which is much higher than in CPU applications (typically between 5 and 15%) # Hypothesis: Algorithmic Categories <table> <thead> <tr> <th>Resilience Category</th> <th>Benchmarks</th> <th>Measured SDC</th> <th>Dwarf(s) of parallelism</th> </tr> </thead> <tbody> <tr> <td>Search-based</td> <td>MergeSort</td> <td>6%</td> <td>Backtrack and Branch+Bound</td> </tr> <tr> <td>Bit-wise Operation</td> <td>HashGPU, AES</td> <td>25% - 37%</td> <td>Combinational Logic</td> </tr> <tr> <td>Average-out Effect</td> <td>Stencil, MONTE</td> <td>1% - 5%</td> <td>Structured Grids, Monte Carlo</td> </tr> <tr> <td>Graph Processing</td> <td>BFS</td> <td>10%</td> <td>Graph Traversal</td> </tr> <tr> <td>Linear Algebra</td> <td>Transpose, MAT, MRI-Q, SCAN-block, LBM, SAD</td> <td>15% - 25%</td> <td>Dense Linear Algebra, Sparse Linear Algebra, Structured Grids</td> </tr> </tbody> </table> Implications of our Results • Wide variation in SDC rates across GPGPU applications, much more than CPU applications • Need for application specific fault-tolerance • Correlation between algorithm and error resilience • Can be used to obtain quick estimates without FI • Can be used to customize level of protection provided Outline • Motivation and Goals • EDC Causing Error Detection [DSN’13][SELSE’13] • SDCTune: Protecting programs from SDCs [CASES’14] • Error Resilience Characterization on GPUs [ISPASS’14] • Conclusions and Future Work Conclusion - Selective protection of instructions in applications for both detecting both EDCs and SDCs - Protection configurable based on max performance overhead - Can provide high detection coverage for most severe errors - GPGPU applications have wider variations in SDC rates compared to CPU applications - Correlation between algorithmic properties and application error resilience \(\rightarrow\) mapping to dwarves - Development of new algorithms for resilient computation Fault Injectors at http://github.com/DependableSystemsLab Future Work • Understanding effect of algorithm on shared memory parallel applications on the CPU • Similar correlations as GPGPU apps [FTXS’14] • Effect of compiler optimizations on the error resilience of applications [AER’13] • Identify safe optimizations for given error resilience targets • Theoretical foundations of programs’ error resilience • PVF analysis combined with heuristics-based analysis
{"Source-Url": "http://blogs.ubc.ca/karthik/files/2014/07/Georgia-tech-talk.pdf", "len_cl100k_base": 4278, "olmocr-version": "0.1.53", "pdf-total-pages": 50, "total-fallback-pages": 0, "total-input-tokens": 72627, "total-output-tokens": 5899, "length": "2e12", "weborganizer": {"__label__adult": 0.0007052421569824219, "__label__art_design": 0.0005402565002441406, "__label__crime_law": 0.001026153564453125, "__label__education_jobs": 0.0009145736694335938, "__label__entertainment": 0.0001195669174194336, "__label__fashion_beauty": 0.0003445148468017578, "__label__finance_business": 0.00027751922607421875, "__label__food_dining": 0.0005664825439453125, "__label__games": 0.0011272430419921875, "__label__hardware": 0.01953125, "__label__health": 0.0012950897216796875, "__label__history": 0.0003592967987060547, "__label__home_hobbies": 0.00025200843811035156, "__label__industrial": 0.0012493133544921875, "__label__literature": 0.0002913475036621094, "__label__politics": 0.00046372413635253906, "__label__religion": 0.0008673667907714844, "__label__science_tech": 0.2022705078125, "__label__social_life": 0.0001481771469116211, "__label__software": 0.0083770751953125, "__label__software_dev": 0.75732421875, "__label__sports_fitness": 0.000579833984375, "__label__transportation": 0.0011167526245117188, "__label__travel": 0.00023043155670166016}, "weborganizer_max": "__label__software_dev", "avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_ratio": [[0, 16380, 0.0158]], "fineweb_edu_fasttext_gt2__fineweb_edu_fasttext_gt2__score": [[0, 16380, 0.18784]], "ft_lang_id_en_doc_v2__ft_lang_id_en_doc_v2__en": [[0, 16380, 0.79786]], "google_gemma-3-12b-it_contains_pii": [[0, 278, false], [278, 578, null], [578, 888, null], [888, 1154, null], [1154, 1308, null], [1308, 1685, null], [1685, 1904, null], [1904, 2045, null], [2045, 2178, null], [2178, 2289, null], [2289, 2572, null], [2572, 2767, null], [2767, 2936, null], [2936, 3026, null], [3026, 3407, null], [3407, 3968, null], [3968, 4515, null], [4515, 4684, null], [4684, 4902, null], [4902, 5291, null], [5291, 5601, null], [5601, 5710, null], [5710, 5770, null], [5770, 5864, null], [5864, 6083, null], [6083, 6510, null], [6510, 6915, null], [6915, 7379, null], [7379, 7501, null], [7501, 7950, null], [7950, 8476, null], [8476, 10391, null], [10391, 10833, null], [10833, 11108, null], [11108, 11279, null], [11279, 11468, null], [11468, 11598, null], [11598, 11817, null], [11817, 12210, null], [12210, 12635, null], [12635, 12981, null], [12981, 13347, null], [13347, 13384, null], [13384, 13843, null], [13843, 13983, null], [13983, 14865, null], [14865, 15198, null], [15198, 15417, null], [15417, 15967, null], [15967, 16380, null]], "google_gemma-3-12b-it_is_public_document": [[0, 278, true], [278, 578, null], [578, 888, null], [888, 1154, null], [1154, 1308, null], [1308, 1685, null], [1685, 1904, null], [1904, 2045, null], [2045, 2178, null], [2178, 2289, null], [2289, 2572, null], [2572, 2767, null], [2767, 2936, null], [2936, 3026, null], [3026, 3407, null], [3407, 3968, null], [3968, 4515, null], [4515, 4684, null], [4684, 4902, null], [4902, 5291, null], [5291, 5601, null], [5601, 5710, null], [5710, 5770, null], [5770, 5864, null], [5864, 6083, null], [6083, 6510, null], [6510, 6915, null], [6915, 7379, null], [7379, 7501, null], [7501, 7950, null], [7950, 8476, null], [8476, 10391, null], [10391, 10833, null], [10833, 11108, null], [11108, 11279, null], [11279, 11468, null], [11468, 11598, null], [11598, 11817, null], [11817, 12210, null], [12210, 12635, null], [12635, 12981, null], [12981, 13347, null], [13347, 13384, null], [13384, 13843, null], [13843, 13983, null], [13983, 14865, null], [14865, 15198, null], [15198, 15417, null], [15417, 15967, null], [15967, 16380, null]], "google_gemma-3-4b-it_v2tag__is_academic_paper": [[0, 5000, true], [5000, 16380, null]], "google_gemma-3-4b-it_v2tag__is_class_syllabus": [[0, 5000, false], [5000, 16380, null]], "google_gemma-3-4b-it_v2tag__is_completion_certificate": [[0, 5000, false], [5000, 16380, null]], "google_gemma-3-4b-it_v2tag__is_court_notice": [[0, 5000, false], [5000, 16380, null]], "google_gemma-3-4b-it_v2tag__is_homework_assignment": [[0, 5000, false], [5000, 16380, null]], "google_gemma-3-4b-it_v2tag__is_news_article": [[0, 5000, false], [5000, 16380, null]], "google_gemma-3-4b-it_v2tag__is_public_order": [[0, 5000, false], [5000, 16380, null]], "google_gemma-3-4b-it_v2tag__is_resume_cv": [[0, 5000, false], [5000, 16380, null]], "google_gemma-3-4b-it_v2tag__is_test_or_quiz": [[0, 5000, false], [5000, 16380, null]], "google_gemma-3-4b-it_v2tag__is_textbook": [[0, 5000, false], [5000, 16380, null]], "pdf_page_numbers": [[0, 278, 1], [278, 578, 2], [578, 888, 3], [888, 1154, 4], [1154, 1308, 5], [1308, 1685, 6], [1685, 1904, 7], [1904, 2045, 8], [2045, 2178, 9], [2178, 2289, 10], [2289, 2572, 11], [2572, 2767, 12], [2767, 2936, 13], [2936, 3026, 14], [3026, 3407, 15], [3407, 3968, 16], [3968, 4515, 17], [4515, 4684, 18], [4684, 4902, 19], [4902, 5291, 20], [5291, 5601, 21], [5601, 5710, 22], [5710, 5770, 23], [5770, 5864, 24], [5864, 6083, 25], [6083, 6510, 26], [6510, 6915, 27], [6915, 7379, 28], [7379, 7501, 29], [7501, 7950, 30], [7950, 8476, 31], [8476, 10391, 32], [10391, 10833, 33], [10833, 11108, 34], [11108, 11279, 35], [11279, 11468, 36], [11468, 11598, 37], [11598, 11817, 38], [11817, 12210, 39], [12210, 12635, 40], [12635, 12981, 41], [12981, 13347, 42], [13347, 13384, 43], [13384, 13843, 44], [13843, 13983, 45], [13983, 14865, 46], [14865, 15198, 47], [15198, 15417, 48], [15417, 15967, 49], [15967, 16380, 50]], "pipe_delimited_lines_v1__pipe_delimited_lines_v1__pipe_delimited_lines_ratio": [[0, 16380, 0.07918]]}
olmocr_science_pdfs
2024-12-07
2024-12-07
db543ebc6d0f29c0ea25759f00391c8e5c6c736b
Architecture of ML Systems 09 Data Acquisition and Preparation Matthias Boehm Graz University of Technology, Austria Computer Science and Biomedical Engineering Institute of Interactive Systems and Data Science BMVIT endowed chair for Data Management Last update: May 29, 2020 Announcements/Org #1 Video Recording - Link in TeachCenter & TUbe (lectures will be public) - Live streaming through TUbe, starting May 08 - Questions: https://tugraz.webex.com/meet/m.boehm #2 AMLS Programming Projects - Status: all project discussions w/ 15 students (~8 PRs) - Awesome mix of projects (algorithms, compiler, runtime) - Soft deadline: June 30 #3 TU Delft DESOSO 2020 - Delft Students on Software Architecture (incl ML systems) https://desosa.nl Recap: The Data Science Lifecycle Data Science Lifecycle Data-centric View: - Application perspective - Workload perspective - System perspective Data/SW Engineer Data Integration - Data Cleaning - Data Preparation Model Selection - Training - Hyper-parameters Validate & Debug - Deployment - Scoring & Feedback Exploratory Process (experimentation, refinements, ML pipelines) DevOps Engineer Data Scientist The 80% Argument - **Data Sourcing Effort** - Data scientists spend *80-90% time* on finding, integrating, cleaning datasets - **Technical Debts in ML Systems** - Glue code, pipeline jungles, dead code paths - Plain-old-data types (arrays), multiple languages, prototypes - Abstraction and configuration debts - Data testing, reproducibility, process management, and cultural debts --- Agenda - Data Acquisition and Integration - Data Preparation and Feature Engineering - Data Transformation and Cleaning - Data Augmentation (next week) “least enjoyable tasks in data science lifecycle” Data Acquisition and Integration Data Integration for ML and ML for Data Integration Data Integration and Large-Scale Analysis (DIA) (bachelor/master) Data Sources and Heterogeneity - **Terminology** - **Integration** (Latin integer = whole): consolidation of data objects / sources - **Homogeneity** (Greek homo/homoios = same): similarity - **Heterogeneity**: dissimilarity, different representation / meaning - **Heterogeneous IT Infrastructure** - Common enterprise IT infrastructure contains >100s of heterogeneous and distributed systems and applications - E.g., health care data management: 20 - 120 systems - **Multi-Modal Data (example health care)** - **Structured patient data**, patient records incl. prescribed drugs - **Knowledge base** drug APIs (active pharmaceutical ingredients) + interactions - **Doctor notes** (text), diagnostic codes, outcomes - **Radiology images** (e.g., MRI scans), **patient videos** - **Time series** (e.g., EEG, ECoG, heart rate, blood pressure) Types of Data Formats - **General-Purpose Formats** - CSV (comma separated values), JSON (javascript object notation), XML, Protobuf - CLI/API access to DBs, KV-stores, doc-stores, time series DBs, etc - **Sparse Matrix Formats** - Matrix market: text IJV (row, col, value) - Libsvm: text compressed sparse rows - Scientific formats: NetCDF, HDF5 - **Large-Scale Data Formats** - Parquet (columnar file format) - Arrow (cross-platform columnar in-memory data) - **Domain-Specific Formats** - Health care: DICOM images, HL7 messages (health-level seven, XML) - Automotive: MDF (measurements), CDF (calibrations), ADF (auto-lead XML) - Smart production: OPC (open platform communications) Types of Heterogeneity Heterogeneity Semantic Heterogeneity 1. Synonyms/homonyms 2. Simple mapping (mathematical) 3. Different data types 4. Complex mappings 5. Language expressions Attribute Heterogeneity 6. Nulls (Missing Values) 7. Virtual columns 8. Semantic incompatibility Missing Data Structural Heterogeneity 9. Same attribute in different structure 10. Handling Sets 11. Attribute name w/o semantics 12. Attribute composition Identification of Data Sources - **Data Catalogs** - Data curation in repositories for finding relevant datasets in **data lakes** - Augment data with open and linked data sources - **Examples** **SAP Data Hub** ![SAP Data Hub slide] ![SAP Sapphire Now 2019] **Google Data Search** ![Google Data Search slide] Schema Detection and Integration - **Schema Detection** - Sample of the input dataset → infer *syntactic schema* (e.g., data types) - *Semantic schema* detection (e.g., location, date, rank, name) - **Schema Matching** - Semi-automatic mapping of schema S1 to schema S2 - *Approaches*: Schema- vs instance-based; element- vs structure-based; linguistic vs rules - Hybrid and composite matchers - Global schema matching (one-to-one): stable marriage problem - **Schema Mapping** - Given two schemas and correspondences, generate transformation program - *Challenges*: complex mappings (1:N cardinality), new values, PK-FK relations and nesting, creation of duplicates, different data types, semantic preserving [Credit: Erhard Rahm] Corrupted Data - **Heterogeneity of Data Sources** - Update anomalies on denormalized data / eventual consistency - Changes of app/preprocessing over time (US vs us) → inconsistencies - **Human Error** - Errors in semi-manual data collection, laziness (see default values), bias - Errors in data labeling (especially if large-scale: crowd workers / users) - **Measurement/Processing Errors** - Unreliable HW/SW and measurement equipment (e.g., batteries) - Harsh environments (temperature, movement) → aging --- ### Table: Data Acquisition and Integration <table> <thead> <tr> <th>ID</th> <th>Name</th> <th>BDay</th> <th>Age</th> <th>Sex</th> <th>Phone</th> <th>Zip</th> </tr> </thead> <tbody> <tr> <td>3</td> <td>Smith, Jane</td> <td>05/06/1975</td> <td>44</td> <td>F</td> <td>999-9999</td> <td>98120</td> </tr> <tr> <td>3</td> <td>John Smith</td> <td>38/12/1963</td> <td>55</td> <td>M</td> <td>867-4511</td> <td>11111</td> </tr> <tr> <td>7</td> <td>Jane Smith</td> <td>05/06/1975</td> <td>24</td> <td>F</td> <td>567-3211</td> <td>98120</td> </tr> </tbody> </table> ### Notes: - **Uniqueness & duplicates**: Contradictions & wrong values - **Missing Values**: Ref. Integrity [Credit: Felix Naumann] - **Typos**: - 98120: San Jose - 90001: Lost Angeles Examples (aka errors are everywhere) - **DM SS’19** *(Soccer World Cups)* - **DM WS’19/20** *(Airports and Airlines)* - **DM SS’20** *(DBLP Publications)* Data Integration for ML and ML for DI - **#1 Data Extraction** - Extracting structured data from un/semi-structured data - Rule- and ML-based extractors, combination w/ CNN - **#2 Schema Alignment** - Schema matching for consolidating data from heterogeneous systems - Spatial and Temporal alignment via provenance and query processing (e.g., sensor readings for object along a production pipeline) - **#3 Entity Linking** - Linking records to entities (deduplication) - Blocking, pairwise matching, clustering, ML, Deep ML (via entity embedding) - **#4 Data Fusion** - Resolve conflicts, necessary in presence of erroneous data - Rule- and ML-based, probabilistic GM, Deep ML (RBMs, graph embeddings) [Xin Luna Dong, Theodoros Rekatsinas: Data Integration and Machine Learning: A Natural Synergy. SIGMOD 2018] Data Validation Sanity checks on expected shape before training first model - Check a feature’s min, max, and most common value - Ex: Latitude values must be within the range [-90, 90] or [-\(\pi/2, \pi/2\)] - The histograms of continuous or categorical values are as expected - Ex: There are similar numbers of positive and negative labels - Whether a feature is present in enough examples - Ex: Country code must be in at least 70% of the examples - Whether a feature has the right number of values (i.e., cardinality) - Ex: There cannot be more than one age of a person Data Validation, cont. - **Constraints and Metrics for quality check UDFs** <table> <thead> <tr> <th>constraint</th> <th>arguments</th> </tr> </thead> <tbody> <tr> <td>dimension completeness</td> <td>column</td> </tr> <tr> <td>isComplete</td> <td>column, udf</td> </tr> <tr> <td>hasCompleteness</td> <td>column, udf</td> </tr> <tr> <td>dimension consistency</td> <td>column, column, value range</td> </tr> <tr> <td>isUnique</td> <td>column, udf</td> </tr> <tr> <td>hasUniqueness</td> <td>column, udf</td> </tr> <tr> <td>hasDistinctness</td> <td>column, udf</td> </tr> <tr> <td>isInRange</td> <td>column, udf</td> </tr> <tr> <td>hasConsistentType</td> <td>column, udf</td> </tr> <tr> <td>isNonNegative</td> <td>column, column pair</td> </tr> <tr> <td>satisfies</td> <td>predicate</td> </tr> <tr> <td>satisfiesIf</td> <td>predicate pair</td> </tr> <tr> <td>hasPredictability</td> <td>column, column(s), udf</td> </tr> <tr> <td>statistics (can be used to verify dimension consistency)</td> <td>udf</td> </tr> <tr> <td>hasSize</td> <td>udf</td> </tr> <tr> <td>hasTypeConsistency</td> <td>column, udf</td> </tr> <tr> <td>hasCountDistinct</td> <td>column, udf</td> </tr> <tr> <td>hasApproxCountDistinct</td> <td>column, udf</td> </tr> <tr> <td>hasMin</td> <td>column, udf</td> </tr> <tr> <td>hasMax</td> <td>column, udf</td> </tr> <tr> <td>hasMean</td> <td>column, udf</td> </tr> <tr> <td>hasStandardDeviation</td> <td>column, udf</td> </tr> <tr> <td>hasApproxQuantile</td> <td>column, quantile, udf</td> </tr> <tr> <td>hasEntropy</td> <td>column, udf</td> </tr> <tr> <td>hasMutualInformation</td> <td>column, column pair</td> </tr> <tr> <td>hasHistogramValues</td> <td>column, udf</td> </tr> <tr> <td>hasCorrelation</td> <td>column, column pair</td> </tr> <tr> <td>time</td> <td></td> </tr> <tr> <td>hasNoAnomalies</td> <td>metric, detector</td> </tr> <tr> <td>metric</td> <td>dimension completeness</td> </tr> <tr> <td></td> <td>Completeness</td> </tr> <tr> <td></td> <td>dimension consistency</td> </tr> <tr> <td></td> <td>Size</td> </tr> <tr> <td></td> <td>Compliance</td> </tr> <tr> <td></td> <td>Uniqueness</td> </tr> <tr> <td></td> <td>Distinctness</td> </tr> <tr> <td></td> <td>ValueRange</td> </tr> <tr> <td></td> <td>DataTypes</td> </tr> <tr> <td></td> <td>Predictability</td> </tr> </tbody> </table> - **Approach** - #1 Quality checks on basic metrics, computed in **Apache Spark** - #2 **Incremental maintenance** of metrics and quality checks [Sebastian Schelter, Dustin Lange, Philipp Schmidt, Meltem Celikel, Felix Bießmann, Andreas Grafberger: Automating Large-Scale Data Quality Verification. *PVLDB 2018*] Organizational Lesson: benefit of shared vocabulary/procedures Technical Lesson: fast/scalable; reduce manual and ad-hoc analysis Data Preparation and Feature Engineering Overview Feature Engineering - **Terminology** - Matrix $X$ of $m$ observations (rows) and $n$ features (columns) - **Continuous features**: numerical values (aka scale features) - **Categorical features**: non-numerical values, represent groups - **Ordinal features**: non-numerical values, associated ranking - Feature space: multi-dimensional space of features $\rightarrow$ curse of dimensionality - **Feature Engineering** - Bring multi-modal data and features into numeric representation - Use domain expertise to expose predictive features to ML model training - **Excursus: Representation Learning** - Neural networks can be viewed as combined representation learning and model training (pros and cons: learned, repeatable) - Mostly homogeneous inputs (e.g., image), research on multi-modal learning ** Principle:** If same accuracy, prefer simple model (cheap, robust, explainable) Recoding Summary - Numerical encoding of categorical features (arbitrary strings) - Map distinct values to integer domain (potentially combined w/ one-hot) <table> <thead> <tr> <th>City</th> <th>State</th> <th>Dictionaries</th> </tr> </thead> <tbody> <tr> <td>San Jose</td> <td>CA</td> <td>{San Jose : 1, New York : 2, San Francisco : 3, Seattle : 4, Boston : 5, Los Angeles : 6}</td> </tr> <tr> <td>New York</td> <td>NY</td> <td></td> </tr> <tr> <td>San Francisco</td> <td>CA</td> <td></td> </tr> <tr> <td>Seattle</td> <td>WA</td> <td></td> </tr> <tr> <td>New York</td> <td>NY</td> <td></td> </tr> <tr> <td>Boston</td> <td>MA</td> <td></td> </tr> <tr> <td>San Francisco</td> <td>CA</td> <td></td> </tr> <tr> <td>Los Angeles</td> <td>CA</td> <td></td> </tr> <tr> <td>Seattle</td> <td>WA</td> <td></td> </tr> </tbody> </table> <table> <thead> <tr> <th>City</th> <th>State</th> </tr> </thead> <tbody> <tr> <td>1</td> <td>1</td> </tr> <tr> <td>2</td> <td>2</td> </tr> <tr> <td>3</td> <td>1</td> </tr> <tr> <td>4</td> <td>3</td> </tr> <tr> <td>5</td> <td>4</td> </tr> <tr> <td>6</td> <td>1</td> </tr> <tr> <td>4</td> <td>3</td> </tr> </tbody> </table> Feature Hashing - **Summary** - Numerical encoding of categorical features (arbitrary strings) - Hash input to k buckets via hash(value) % k (often combined w/ one-hot) <table> <thead> <tr> <th>City</th> <th>For k = 5:</th> <th>City</th> </tr> </thead> <tbody> <tr> <td>San Jose</td> <td>1993955031 % 5 → 1</td> <td>1</td> </tr> <tr> <td>New York</td> <td>1382994575 % 5 → 0</td> <td>0</td> </tr> <tr> <td>San Francisco</td> <td>1540367136 % 5 → 1</td> <td>1</td> </tr> <tr> <td>Seattle</td> <td>-661909336 % 5 → 1</td> <td>1</td> </tr> <tr> <td>New York</td> <td>1993955031 % 5 → 1</td> <td>1</td> </tr> <tr> <td>Boston</td> <td>1995575789 % 5 → 4</td> <td>4</td> </tr> <tr> <td>San Francisco</td> <td>1540367136 % 5 → 1</td> <td>1</td> </tr> <tr> <td>Los Angeles</td> <td>-425347233 % 5 → 3</td> <td>3</td> </tr> <tr> <td>Seattle</td> <td>-661909336 % 5 → 1</td> <td>1</td> </tr> </tbody> </table> Efficient, but collisions Binning (see also Quantization, Binarization) - **Summary** - Encode of numerical features to integer domain (often combined w/ one-hot) - **Equi-width**: split (max-min)-range into k equal-sized buckets - **Equi-height**: compute data-driven ranges for k balanced buckets <table> <thead> <tr> <th>Sqft</th> <th>Sqft-Bins</th> </tr> </thead> <tbody> <tr> <td>928.5</td> <td>2</td> </tr> <tr> <td>451</td> <td>1</td> </tr> <tr> <td>570.3</td> <td>1</td> </tr> <tr> <td>1,273</td> <td>3</td> </tr> <tr> <td>1,239</td> <td>3</td> </tr> <tr> <td>711.3</td> <td>1</td> </tr> <tr> <td>1,114</td> <td>3</td> </tr> <tr> <td>867</td> <td>2</td> </tr> </tbody> </table> - **Equal-sized numerical buckets (with k=3)** - min = 451 - max = 1,273 - range = 822 - [451, 725) → 1 - [725, 999) → 2 - [999, 1,273] → 3 - Allows modelling small, medium, large apartments ## One-hot Encoding ### Summary - Encode integer feature of cardinality $d$ into sparse 0/1 vector of length $d$ - Feature vectors of input features concatenated in sequence <table> <thead> <tr> <th>City</th> <th>State</th> <th>C1</th> <th>C2</th> <th>C3</th> <th>C4</th> <th>C5</th> <th>C6</th> <th>S1</th> <th>S2</th> <th>S3</th> <th>S4</th> </tr> </thead> <tbody> <tr> <td>1</td> <td>1</td> <td>1</td> <td>0</td> <td>0</td> <td>0</td> <td>0</td> <td>0</td> <td>1</td> <td>0</td> <td>0</td> <td>0</td> </tr> <tr> <td>2</td> <td>2</td> <td>0</td> <td>1</td> <td>0</td> <td>0</td> <td>0</td> <td>0</td> <td>0</td> <td>1</td> <td>0</td> <td>0</td> </tr> <tr> <td>3</td> <td>1</td> <td>0</td> <td>0</td> <td>1</td> <td>0</td> <td>0</td> <td>0</td> <td>1</td> <td>0</td> <td>0</td> <td>0</td> </tr> <tr> <td>4</td> <td>3</td> <td>0</td> <td>0</td> <td>0</td> <td>1</td> <td>0</td> <td>0</td> <td>0</td> <td>0</td> <td>1</td> <td>0</td> </tr> <tr> <td>2</td> <td>2</td> <td>0</td> <td>1</td> <td>0</td> <td>0</td> <td>0</td> <td>0</td> <td>1</td> <td>0</td> <td>0</td> <td>0</td> </tr> <tr> <td>5</td> <td>4</td> <td>0</td> <td>0</td> <td>0</td> <td>1</td> <td>0</td> <td>0</td> <td>0</td> <td>0</td> <td>0</td> <td>1</td> </tr> <tr> <td>3</td> <td>1</td> <td>0</td> <td>0</td> <td>1</td> <td>0</td> <td>0</td> <td>0</td> <td>1</td> <td>0</td> <td>0</td> <td>0</td> </tr> <tr> <td>6</td> <td>1</td> <td>0</td> <td>0</td> <td>0</td> <td>0</td> <td>1</td> <td>1</td> <td>0</td> <td>0</td> <td>0</td> <td>0</td> </tr> <tr> <td>4</td> <td>3</td> <td>0</td> <td>0</td> <td>0</td> <td>1</td> <td>0</td> <td>0</td> <td>0</td> <td>0</td> <td>1</td> <td>0</td> </tr> </tbody> </table> Derived Features - **Intercept Computation** - Add a column of ones to X for computing the intercept as a weight - Applies to regression and classification - **Non-Linear Relationships** - Can be explicitly materialized as feature combinations - Example: Assumptions of underlying physical system - Arbitrary complex feature interactions: e.g., $X_1^2 \times X_2$ ``` X = cbind(X, matrix(1, nrow(X), 1)); // y ~ b1*X1 + b2*X1^2 X = cbind(X, X^2); // y ~ b1*X1 + b2*X1^2 ``` NLP Features - **Basic NLP Feature Extraction** - *Sentence/word tokenization:* split into sentences/words (e.g., via stop words) - *Part of Speech (PoS) tagging:* label words verb, noun, adjectives (syntactic) - *Semantic role labeling:* label entities with their roles in actions (semantic) Who did *what* to *whom* at *where*? - **Bag of Words (BOW) and N-Grams** - Represent sentences as *bag* (multisets) <table> <thead> <tr> <th></th> <th>A</th> <th>B</th> <th>C</th> <th>D</th> <th>E</th> </tr> </thead> <tbody> <tr> <td>A</td> <td>2</td> <td>2</td> <td>1</td> <td>0</td> <td>1</td> </tr> <tr> <td>A</td> <td>1</td> <td>0</td> <td>0</td> <td>3</td> <td>2</td> </tr> </tbody> </table> - **Bi-grams:** bag-of-words for 2-sequences of words (order preserving) - **N-grams:** generalization of bi-grams to arbitrary-length sequences NLP Features, cont. - **Word Embeddings** - Trained (word → vector) mappings (≈ 50-300 dims) - **Word2vec**: continuous bag-of-words (CBOW) or continuous skip-gram - Subsampling frequent words - **Semantic preserving arithmetic operations** (+ ~ * of context distributions) - **Follow-up Work** - Often pre-trained word embeddings; fine-tuning if necessary for task/domain - Various extensions/advancements: **Sentence2Vec**, **Doc2Vec**, **Node2Vec** - **BERT, RoBERTa, ALBERT, StructBERT** [Note: For more information on Word2Vec, see [Tomas Mikolov, Kai Chen, Greg Corrado, Jeffrey Dean: Efficient Estimation of Word Representations in Vector Space. ICLR (Workshop) 2013](http://google.com)] [Note: For more information on BERT, RoBERTa, ALBERT, StructBERT, see [Jacob Devlin et al.: BERT: Pre-training of Deep Bidirectional Transformers for Language Understanding. NAACL-HLT (1) 2019](http://google.com)] Example Spark ML - **API Design** - **Transformers:** Feature transformations and learned models - **Estimators:** Algorithm that can be fit to produce a transformer - Compose ML pipelines from chains of transformers and estimators - **Example Pipeline** ```scala // define pipeline stages tokenizer = Tokenizer(inputCol="text", outputCol="words") hashingTF = HashingTF(inputCol=tokenizer.outputCol(), outputCol="features") lr = LogisticRegression(maxIter=10, regParam=0.001) // create pipeline transformer via fit pipeline = Pipeline(stages=[tokenizer, hashingTF, lr]) model = pipeline.fit(training) // use of resulting ML pipeline prediction = model.transform(test) ``` [https://spark.apache.org/docs/2.4.3/ml-pipeline.html](https://spark.apache.org/docs/2.4.3/ml-pipeline.html) Example SystemML/SystemDS - Feature Transformation during Training ```r # read tokenized words FX = read("./input/FX", data_type=FRAME); # sentence id, word, count FY = read("./input/FY", data_type=FRAME); # sentence id, labels # encode and one-hot encoding [X0, MX] = transformencode(target=FX, spec="{recode:[2]}”); [Y0, MY] = transformencode(target=FY, spec="{recode:[2]}”); X = table(X0[,1], X0[,2], X0[,3]); # bag of words Y = table(Y0[,1], Y0[,2]); # bag of words # model training via multi-label, multi-nominal logical regression B = mlogreg(X, Y); ``` Example SystemML/SystemDS, cont. - Feature Transformation during Scoring ``` # read tokenized words of test sentences dFX = read("./input/dFX", data_type=FRAME); # sentence id, word, count # encode and one-hot encoding dX0 = transformapply(target=dFX, spec="{recode:[2]}", meta=MX); dX = table(dX0[,1], dX0[,2], dX0[,3]); # bag of words # model scoring and postprocessing (reshape, attach sentence ID, etc) dYhat = (X %% B) >= theta; ...; # decode output labels: sentence id, label word dFYhat = transformdecode(target=dYhat, spec="{recode:[2]}", meta=MY); ``` Data Transformation and Cleaning Standardization/Normalization #1 Standardization - Centering and scaling to mean 0 and variance 1 - Ensures well-behaved training - Densifying operation - Awareness of NaNs - Batch normalization in DNN: standardization of activations \[ \begin{align*} X &= X - \text{colMeans}(X); \\ X &= X / \text{sqrt}(\text{colVars}(X)); \\ X &= \text{replace}(X, \text{pattern}=\text{NaN}, \text{replacement}=0); \ #\text{robustness} \end{align*} \] #2 (Min-Max) Normalization - Rescale values into common range [0,1] - Avoid bias to large-scale features - Does not handle outliers \[ X = (X - \text{colMins}(X)) / (\text{colMaxs}(X) - \text{colMins}(X)); \] Recommended Reading Standardization/Normalization, cont. - **#3 Deferred Standardization** - Avoid densifying dataset upfront by pushing standardization into inner loop iterations - Let *matrix-multiplication chain optimization* + rewrites do the rest - **Example** - GLM/lmCG Input w/ column of ones (intercept) ![Diagram](image) **# operation w/ early standardized X** \[ q = t(X) \cdot \text{diag}(w) \cdot X \cdot B; \] **Substitute X with X \cdot S** **# operation w/ deferred standardization** \[ q = t(S) \cdot t(X) \cdot \text{diag}(w) \cdot X \cdot S \cdot B; \] \[ q = t(S) \cdot t(X) \cdot (\text{diag}(w) \cdot (X \cdot S \cdot B)); \] Winsorizing and Trimming - Recap: Quantiles - Quantile $Q_p$ w/ $p \in (0,1)$ defined as $P[X \leq x] = p$ - Winsorizing - Replace tails of data distribution at user-specified threshold - Quantiles / std-dev - Reduce skew - Truncation/Trimming - Remove tails of data distribution at user-specified threshold - Largest Difference from Mean ```r # compute quantiles for lower and upper ql = quantile(X, 0.05); qu = quantile(X, 0.95); # replace values outside [ql,qu] w/ ql and qu Y = ifelse(X < ql, ql, X); Y = ifelse(Y > qu, qu, Y); # remove values outside [ql,qu] I = X < qu | X > ql; Y = removeEmpty(X, "rows", select = I); # determine largest diff from mean I = (colMaxs(X) - colMeans(X)) > (colMeans(X) - colMins(X)); Y = ifelse(xor(I,op), colMaxs(X), colMins(X)); ``` [Credit: https://en.wikipedia.org] Outliers and Outlier Detection - Types of Outliers - **Point outliers**: single data points far from the data distribution - **Contextual outliers**: noise or other systematic anomalies in data - **Sequence (contextual) outliers**: sequence of values with abnormal shape/agg - Univariate vs multivariate analysis - Beware of underlying assumptions (distributions) - Types of Outlier Detection - **Type 1 Unsupervised**: No prior knowledge of data, similar to unsupervised clustering \[ \rightarrow \text{expectations: distance, # errors} \] - **Type 2 Supervised**: Labeled normal and abnormal data, similar to supervised classification - **Type 3 Normal Model**: Represent normal behavior, similar to pattern recognition \[ \rightarrow \text{expectations: rules/constraints} \] Missing Value Imputation - **Missing Value** - Application context defines if 0 is missing value or not - If differences between 0 and missing values, use NA or NaN - **Basic Value Imputation** - General-purpose: replace by user-specified constant - **Continuous variables**: replace by mean - **Categorical variables**: replace by median or mode - **Iterative Algorithms** *(chained-equation imputation)* - Train ML model to predict missing information (feature k → label, split data into observed/missing) - Noise reduction: feature subsets + averaging - **Dynamic Imputation** - Data exploration w/ on-the-fly imputation - Optimal placement of imputation operations [Jose Cambronero, John K. Feser, Micah Smith, Samuel Madden: Query Optimization for Dynamic Imputation. PVLDB 2017] Excursus: Time Series Recovery - **Motivating Use Case** - Given overlapping weekly aggregates $y$ (daily moving average) - Reconstruct the original time series $X$ - **Problem Formulation** - Aggregates $y$ - Original time series $X$ (unknown) - Mapping $O$ of subsets of $X$ to $y$ - $\Rightarrow$ Least squares regression problem - **Advanced Method** - Discrete Cosine Transform (DCT) (sparsest spectral representation) - Non-negativity and smoothness constraints - **Use case:** high-precision sensor fusion w/ different data granularity Selected Research Prototypes - **ActiveClean (SampleClean)** - Suggest sample of data for manual cleaning (rule/ML-based detectors, *Simpson's paradox*) - Update dirty model with gradients of cleaned data (weighted gradients of previous clean data and newly cleaned data) - **HoloClean** - Clean and enrich based on quality rules, value correlations, and reference data - Probabilistic models for capturing data generation - HoloDetect - Learn data representations of errors - Data augmentation w/ erroneous data from sample of clean data - **Other Systems** - **AlphaClean** (generate data cleaning pipelines) [preprint] - **BoostClean** (generate repairs for domain value violations) [preprint] Summary and Q&A - Data Acquisition and Integration - Data Preparation and Feature Engineering - Data Transformation and Cleaning Next Lectures - 10 Model Selection and Management [Jun 05] - Incl Data Augmentation - 11 Model Debugging Techniques [Jun 12] - 12 Model Serving Systems and Techniques [Jun 19] [Andreas C. Mueller: Preprocessing and Feature Transformations, Applied ML Lecture 2020] “Coming up with features is difficult, time-consuming, requires expert knowledge. "Applied machine learning" is basically feature engineering” – Andrew Ng
{"Source-Url": "https://mboehm7.github.io/teaching/ss20_amls/09_DataSourcing.pdf", "len_cl100k_base": 7946, "olmocr-version": "0.1.53", "pdf-total-pages": 37, "total-fallback-pages": 0, "total-input-tokens": 69750, "total-output-tokens": 8917, "length": "2e12", "weborganizer": {"__label__adult": 0.0004487037658691406, "__label__art_design": 0.0014009475708007812, "__label__crime_law": 0.0005478858947753906, "__label__education_jobs": 0.0229949951171875, "__label__entertainment": 0.00018286705017089844, "__label__fashion_beauty": 0.0003786087036132813, "__label__finance_business": 0.0008111000061035156, "__label__food_dining": 0.0005674362182617188, "__label__games": 0.0007748603820800781, "__label__hardware": 0.0016994476318359375, "__label__health": 0.0009794235229492188, "__label__history": 0.0006532669067382812, "__label__home_hobbies": 0.0003490447998046875, "__label__industrial": 0.00140380859375, "__label__literature": 0.0005617141723632812, "__label__politics": 0.0004324913024902344, "__label__religion": 0.0007405281066894531, "__label__science_tech": 0.37109375, "__label__social_life": 0.0003681182861328125, "__label__software": 0.019622802734375, "__label__software_dev": 0.57275390625, "__label__sports_fitness": 0.0004227161407470703, "__label__transportation": 0.0006966590881347656, "__label__travel": 0.0003085136413574219}, "weborganizer_max": "__label__software_dev", "avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_ratio": [[0, 26658, 0.02844]], "fineweb_edu_fasttext_gt2__fineweb_edu_fasttext_gt2__score": [[0, 26658, 0.17923]], "ft_lang_id_en_doc_v2__ft_lang_id_en_doc_v2__en": [[0, 26658, 0.65739]], "google_gemma-3-12b-it_contains_pii": [[0, 279, false], [279, 744, null], [744, 1161, null], [1161, 1778, null], [1778, 1982, null], [1982, 2135, null], [2135, 2998, null], [2998, 3709, null], [3709, 4311, null], [4311, 4722, null], [4722, 5474, null], [5474, 6575, null], [6575, 6739, null], [6739, 7571, null], [7571, 8329, null], [8329, 11639, null], [11639, 11680, null], [11680, 12593, null], [12593, 14025, null], [14025, 14746, null], [14746, 15462, null], [15462, 16485, null], [16485, 16993, null], [16993, 17677, null], [17677, 18604, null], [18604, 19397, null], [19397, 19961, null], [19961, 20529, null], [20529, 20562, null], [20562, 21368, null], [21368, 22044, null], [22044, 22874, null], [22874, 23889, null], [23889, 24697, null], [24697, 25381, null], [25381, 26103, null], [26103, 26658, null]], "google_gemma-3-12b-it_is_public_document": [[0, 279, true], [279, 744, null], [744, 1161, null], [1161, 1778, null], [1778, 1982, null], [1982, 2135, null], [2135, 2998, null], [2998, 3709, null], [3709, 4311, null], [4311, 4722, null], [4722, 5474, null], [5474, 6575, null], [6575, 6739, null], [6739, 7571, null], [7571, 8329, null], [8329, 11639, null], [11639, 11680, null], [11680, 12593, null], [12593, 14025, null], [14025, 14746, null], [14746, 15462, null], [15462, 16485, null], [16485, 16993, null], [16993, 17677, null], [17677, 18604, null], [18604, 19397, null], [19397, 19961, null], [19961, 20529, null], [20529, 20562, null], [20562, 21368, null], [21368, 22044, null], [22044, 22874, null], [22874, 23889, null], [23889, 24697, null], [24697, 25381, null], [25381, 26103, null], [26103, 26658, null]], "google_gemma-3-4b-it_v2tag__is_academic_paper": [[0, 5000, true], [5000, 26658, null]], "google_gemma-3-4b-it_v2tag__is_class_syllabus": [[0, 5000, false], [5000, 26658, null]], "google_gemma-3-4b-it_v2tag__is_completion_certificate": [[0, 5000, false], [5000, 26658, null]], "google_gemma-3-4b-it_v2tag__is_court_notice": [[0, 5000, false], [5000, 26658, null]], "google_gemma-3-4b-it_v2tag__is_homework_assignment": [[0, 5000, false], [5000, 26658, null]], "google_gemma-3-4b-it_v2tag__is_news_article": [[0, 5000, false], [5000, 26658, null]], "google_gemma-3-4b-it_v2tag__is_public_order": [[0, 5000, false], [5000, 26658, null]], "google_gemma-3-4b-it_v2tag__is_resume_cv": [[0, 5000, false], [5000, 26658, null]], "google_gemma-3-4b-it_v2tag__is_test_or_quiz": [[0, 5000, false], [5000, 26658, null]], "google_gemma-3-4b-it_v2tag__is_textbook": [[0, 5000, false], [5000, 26658, null]], "pdf_page_numbers": [[0, 279, 1], [279, 744, 2], [744, 1161, 3], [1161, 1778, 4], [1778, 1982, 5], [1982, 2135, 6], [2135, 2998, 7], [2998, 3709, 8], [3709, 4311, 9], [4311, 4722, 10], [4722, 5474, 11], [5474, 6575, 12], [6575, 6739, 13], [6739, 7571, 14], [7571, 8329, 15], [8329, 11639, 16], [11639, 11680, 17], [11680, 12593, 18], [12593, 14025, 19], [14025, 14746, 20], [14746, 15462, 21], [15462, 16485, 22], [16485, 16993, 23], [16993, 17677, 24], [17677, 18604, 25], [18604, 19397, 26], [19397, 19961, 27], [19961, 20529, 28], [20529, 20562, 29], [20562, 21368, 30], [21368, 22044, 31], [22044, 22874, 32], [22874, 23889, 33], [23889, 24697, 34], [24697, 25381, 35], [25381, 26103, 36], [26103, 26658, 37]], "pipe_delimited_lines_v1__pipe_delimited_lines_v1__pipe_delimited_lines_ratio": [[0, 26658, 0.18478]]}
olmocr_science_pdfs
2024-12-09
2024-12-09
d76cd03b5f70d424a41fe636fdfcaccafbd95b49
Enhancing functionality in an enterprise software package Judy E. Scott\textsuperscript{a,}\textsuperscript{*}, Lisa Kaindl\textsuperscript{b,1} \textsuperscript{a}Graduate School of Business, The University of Texas at Austin, Austin, TX 78712-1175, USA \textsuperscript{b}Dell Computer Corporation, 2214 West Braker Lane, Suite D, Austin, TX 78758-4053, USA Received 28 April 1998; received in revised form 12 November 1998; accepted 20 July 1999 Abstract Although enterprise resource planning (ERP) packages strive to integrate all the major processes of a firm, customers typically discover that some essential functionality is lacking. To address this issue and to complement their capabilities, both ERP vendors and customers increasingly recognize the importance of collaboration. Using a grounded theory approach, this study’s objective is to derive a theoretical understanding of how customers collaborated on enhancements to an ERP module. The main contribution is, therefore, a theoretical model that relates the two processes — selection of participants, and interorganizational collaboration — to share knowledge of a subsystem’s best practices. Important findings are that ‘swift trust’ from the occupational community, conflict resolution, reciprocity, and informal networks impact functionality enhancement. The implication from these findings is that a deeper understanding of the functionality enhancement process benefits not only team members, but also ERP customers and collaborators overall. © 2000 Elsevier Science B.V. All rights reserved. Keywords: Enterprise resource planning; Software packages; Organizational learning; Information requirements determination; User requirements; Development team; Collaboration; Trust; Conflict resolution; Informal networks 1. Introduction Frustration with incompatible legacy systems, IS department inability to cope with systems integration, the year 2000 problem, and the consolidation of currencies in Europe are driving the demand for enterprise resource planning (ERP) software packages. The market for ERP software packages has grown from $4 billion in 1995 to $10 billion in 1997, making predictions of $15.5 billion in 2000 [13] seem conservative and $52 billion in 2002 feasible [12]. ERP software packages strive to support essentially all the processes in a firm’s value-added chain. For example, SAP R/3 currently stores over 1000 predefined processes that represent financial, logistics and human resources best practices in a repository called ‘business engineer’ [4,55]. In an effort to be comprehensive and to be all things to all people, SAP R/3 offers so many options in 10,000 tables that implementation is often extremely complex, necessitating the services of expensive consultants. Yet despite the scale of offerings, most customers inevitably find that at least 20% of their needed functionality is missing from the package. Enhancing functionality is very important, since alternatives to cope with unmet needs, including forcing business processes to fit the software and bolting on customized programs, add to the time and cost of implementation. Moreover, some alternatives, such as using work-arounds, and modifying the software, increase the difficulty of upgrading to new releases of the ERP package. Providing enhancements is based on marketing potential and criteria such as the frequency of requests and the influence of the customer, complicated by the fact that customers are physically dispersed, are in multiple external organizations, and have a variety of needs [10,25,31]. In contrast to custom software, package software needs to appeal to the discretionary customer, and must be generic, parameterized and flexible. Usually, the customer and developer communicate through support lines and user groups with intermediaries such as customer support, sales and marketing, or customer surrogates. Yet direct customer-developer links, such as facilitated teams are more effective at clarifying ambiguous information. Direct links transmit multiple cues and decrease communication filtering and distortion. To satisfy customers and to keep ahead of the competition, ERP software vendors are constantly adding new features using a variety of strategies. For example, to develop their new Treasury module solution to replace old workstations, Peoplesoft bought Advanced Treasury Technology (ATTL) and rented ATTL’s key people [21]. Similarly, Oracle acquired Treasury Services Corporation [19], and also used its Cooperative Application Initiative (CAI) program to interface through its database to treasury workstation vendors, such as ICMS and XRT [47]. XRT also interfaces to J.D. Edwards and SAP packages. In contrast, SAP’s main strategy was to develop its own rich treasury functionality integrated with its other modules to provide foreign exchange, money market investing, lending, derivatives, and debt management functions [44]. This objective of this study is to provide a theoretical explanation of how SAP enhanced the functionality of the R/3 treasury module for the US market with customers’ participation in facilitated teams. Using grounded theory, this study interprets the participants’ accounts of the events. Thus, the main contribution is a conceptual model for customer participation in package software functionality enhancement. 2. Contextual background 2.1. The vendor SAP Established in Germany in 1972, SAP AG, with 33% market share, is the major ERP package vendor for the Fortune 500 companies. With more than 20,000 employees and an estimated revenue of $3.1 billion for 1997, up 30% from 1996 [14], SAP has become one of the largest software companies in the world. To stay ahead of the competition, SAP spends 20% of its annual revenues on R&D. 2.2. The facilitators Price Waterhouse Coopers (PWC) worked closely with SAP to develop the Treasury module (TR). PWC undertook a gapping analysis based on the technology standards required by major multinational companies. They met with user groups in Europe and the US to confirm these findings. SAP then used the output of this exercise to set priorities for the TR development program. PWC facilitators provided treasury knowledge, system implementation experience, SAP TR experience, and knowledge of the other SAP modules, as well as expertise in benchmarking and best practices [59] gained from SAP implementation experience. The consultants added value by facilitating meetings as open discussions of requirements, preparing agendas, prioritizing issues, writing requirements documentation, improving process efficiency, providing objectivity and avoiding the bias, conflict of interests and possible confusion that SAP would face without an intermediary. 2.3. Customer participants Seven organizations formed a steering committee to enhance functionality for the US release of the Treasury module. A group of customers in Europe formed another steering committee, and SAP combined the results from both committees in the development plans for R/3 3.1 and 4.0 releases. Most of the participating organizations were large global firms from a variety of industries — high-tech, consumer goods, agriculture, food and beverage, financial and chemicals. They reflect a wide range of incomes, with $200 million to $18.5 billion in sales revenues, and 200–38,000 employees in 1996 (see Table 1). SAP selected partners with diverse backgrounds so that it could generalize and standardize best practices applicable to as many industries as possible. 2.4. The ERP software package SAP’s first two products operated on mainframe hardware; R/1 was batch-oriented, but in 1981 was replaced by R/2, an online system. In 1992, SAP introduced R/3, a client/server architecture product, which quickly gained dominant market share. Despite an evolving architecture, SAP has leveraged its knowledge of enterprise business practices with each release. Using real-time integration, linking a company’s business processes, and supporting immediate responses to change throughout the organization on a global scale, R/3 supports multiple currencies simultaneously and automatically handles country-specific import/export, tax, legal and language requirements. Accepted as a standard in key industries such as oil, chemicals, consumer products, and high technology and electronics, R/3 currently contains modules for over 1000 business processes, that may be selected from the SAP library and included within installed SAP applications, tailoring the application solution to the user. However, R/3’s complexity has generated a lucrative consulting support industry and caused controversy over the risks of escalating implementation project costs. 2.5. SAP R/3 treasury module The purpose of the R/3 Treasury module is to integrate cash flow management with logistics and financial transactions [2]. Currently, the module, comprises cash management (TR-CM), funds management (TR-FM), treasury management (TR-TM), and market risk management (TR-MRM) [54]. The first manages cash flows by integration between the controlling module and the cash forecast, which groups customers and vendors into risk classes and gives information on long-term liquidity. Within TR-CM, check entry generates postings to general ledger accounts determined by standard or user-defined algorithms. TR-FM is used for budget control and allocation, integrated with purchase orders and release orders in the materials management module. TR-TM controls liquidity management, risk assessment, and planning/portfolio management integrated with postings in the financial system. TR-MRM monitors and manages the entire financial risk position of the company. It uploads market data through automated digital feeds and assesses risks with ‘what-if’ scenarios. 3. Meetings to develop enhancements for the treasury module The collaborative effort on the US specific Treasury module began with a meeting in January 1996 at Foster City, CA. Fifteen customer organizations were invited to a demonstration of the existing module, on the basis of their sophisticated Treasury knowledge, and asked to discuss what features they liked and disliked. The functionality was rudimentary and geared to Europe. Certain features, such as mortgage obligation, cash management parsing and polling, check handling and reporting required in the US, were lacking. During this meeting, attendees exchanged information and knowledge on Treasury processes, and planned a Steering Committee with SAP, which also compiled a prioritized list of requirements from the discussions, brainstorming and documentation of functional requirements. The Steering Committee, developers, and consultants met in subsequent years (see Table 2). The second meeting focused on sharing knowledge of best practices for requirements determination. In addition, participants defined the initiatives, addressed the status of action items, gave feedback, and discussed SAP progress on development plans. Prioritized lists from brainstorming formed the basis for workteam assignments, and the team leader allocated tasks for completion by team members. Furthermore, from the list of requests for functionality the facilitator developed a rough draft of a document to which the participants added more detail. In addition, participants ranked the items as high, medium or low priority. For example, direct download of data from banks had high priority, since that functionality is fundamental to cash management. Although the document resembled a ‘Request For Proposal’ (RFP), it generalized processes from multiple organizations into best practices for the enterprise. The third meeting involved a mix of SAP training and marketing, and feedback on the prototype it had developed. The prototype allowed users and developers to discuss improvements and problems due to gaps in functionality. The lead developers for each of the Treasury sub-modules gave an intense training session, which was attended by 75 people. Thirty-five SAP consultants, including five from the US, participated. However, there were not as many ways to provide feedback as customer participants expected. The fourth meeting was held with the annual SAP Sapphire Users’ Conference. It focused on discussion of the prototype demonstration and testing, the documentation of final requirements, and a demonstration of Citibank’s data feed to R/3 on a Treasury workstation. Although it was not feasible for SAP to pull information from banks all over the world, by partnering with Citibank, SAP developed this enhancement and service in cash management. The focus of the fourth meeting was on design approaches. A fifth meeting was planned but canceled since several of the participants realized they were not ready to implement the Treasury module at that time. One participating organization decided to confine R/3 implementation to the Human Resource component and others postponed the Treasury module since core Financials and Logistics took precedence. In June 1997, two US SAP consultants traveled to Germany to continue the effort to develop the Treasury module. 4. Research methods This study used insider/outside team research [5,22,61]. One of the co-authors was a participant in the information collection as a member of the Steering Committee for the development of the US Treasury module in the software package SAP R/3. The other co-author, an outsider-researcher, treated all the participants as informants and data sources in the study, this allowed a multiple perspective viewpoint and reduced bias. Since there is a paucity of research literature on the development of software packages, this study uses grounded theory methodology [58,66]. This is appropriate in the early stages of research on a topic, because it is inductive and does not rely on previous literature or prior empirical evidence [17]. Moreover, this method explains process, ‘how’ research questions, and context, and provides detailed data for deducing constructs for theory generation and elaboration. Grounded theory places emphasis on conceptualizing participants’ accounts of experiences and events to explain a process [49]. The objective of this research is to generate theory to explain how SAP enhanced the functionality of its US module. Customers collaborated to determine the processes that developers embedded in SAP R/3. Two videotapes (60 and 40 min, duration respectively) were transcribed from presentations on the SAP project by the participant to two MBA classes at a large US university during the fall semester of 1996. Further details were communicated to the ‘outside co-author’ in an unstructured informal interview of approximately 11/2 h plus three telephone conversations lasting about 10 min each and four lengthy question-and-answer e-mail messages. <table> <thead> <tr> <th>Date</th> <th>Location</th> <th>Purpose</th> <th>Events</th> <th>Meeting outcomes</th> <th>Shifts in emphasis over time</th> </tr> </thead> <tbody> <tr> <td>January 1996</td> <td>Foster City, California</td> <td>Knowledge acquisition; Functional requirements</td> <td>Demonstration of rudimentary prototype; discussions, brainstorming, documentation</td> <td>Invitations to join development team; Documentation of prioritized functional requirements</td> <td>Knowledge</td> </tr> <tr> <td>May 1996</td> <td>Atlanta, Georgia</td> <td>Functional requirements</td> <td>Discussions, brainstorming, documentation Status, development plans (SAP progress); feedback</td> <td>Documentation of prioritized functional requirements; workteam assignments;</td> <td>Requirements</td> </tr> <tr> <td>June 1996</td> <td>Walldorf, Germany</td> <td>Training; marketing; Feedback on prototype</td> <td>Status, development plans (SAP progress); Training on prototype; feedback</td> <td>User manual for the prototype is distributed</td> <td>Design approaches</td> </tr> <tr> <td>August 1996</td> <td>Philadelphia, Pennsylvania</td> <td>Marketing; Feedback on prototype</td> <td>Discussions, brainstorming, documentation Status, development plans (SAP progress); discussion of prototype; Citibank demo</td> <td>Documentation of final requirements is distributed</td> <td>Design approaches</td> </tr> <tr> <td>Jan/Feb 1997</td> <td></td> <td></td> <td>Meeting was planned in August 1996 but interest waned and the meeting was not held</td> <td></td> <td></td> </tr> <tr> <td>June 1997</td> <td>Walldorf, Germany</td> <td></td> <td>Workshop attended by two US SAP consultants</td> <td></td> <td></td> </tr> </tbody> </table> In addition, the outsider-co-author interviewed: two other Steering Committee members on the telephone for about 30 min; a partner from the participating consulting firm by phone for 1 h; a Vice President and three managers from SAP in two face-to-face interviews of 30–40 min duration; an SAP Treasury consultant for 45 min on the phone; and two managers from Oracle Applications in a face-to-face interview for 20–30 min. Background information was supplemented with SAP’s web site and publications on SAP R/3. Published articles on SAP Treasury reinforce the validity of this study. Furthermore, including more than one insider perspective, and incorporating multiple theoretical perspectives at multiple levels of analysis into our discussion, strengthens the generalizability of our findings. The data collection and analysis were iterative and guided by literature sources on collaboration that functioned as secondary data, increasing theoretical sensitivity. Grounded theory analyzes phenomena by examining causal and intervening conditions and consequences of an action/interaction strategy. Table 3 below lists the causal and intervening conditions, and consequences of the two strategies — the selection and interorganizational collaboration processes. The seven constructs (mutual goals, occupational community, mutual trust, conflict, informal networks, reciprocity and shared knowledge) emerged from open coding, a technique of categorizing data; the processes emerged from axial coding, a technique that links the constructs. Analysis continued until no further concepts emerged — the point at which theoretical saturation was reached. The grounded theory approach culminated in a conceptual model (Fig. 1) that sheds light on a fresh theoretical perspective of the customer interaction for ### Table 3 <table> <thead> <tr> <th>Grounded theory</th> <th>Selection process</th> <th>Interorganization collaboration process</th> </tr> </thead> <tbody> <tr> <td>Context</td> <td>Stakeholders: SAP, customers, facilitators</td> <td>Software package: Treasury module Steering Committee meetings</td> </tr> <tr> <td>Causal conditions</td> <td>(1) Mutual goals</td> <td>(3) Mutual trust</td> </tr> <tr> <td>Intervening conditions</td> <td>(2) Occupational community</td> <td>(4) Conflict (5) Informal networks (6) Reciprocity</td> </tr> <tr> <td>Consequences</td> <td>(3) Mutual trust</td> <td>(7) Shared knowledge</td> </tr> </tbody> </table> **Fig. 1.** A conceptual model for ERP package enhancement. enterprise software development. The conceptual model is a synthesis of two process models that provide explanations for necessary but not sufficient conditions [56]; for example the selection process is necessary but not a sufficient condition for interorganizational collaboration during ERP functionality enhancement. Furthermore, process models provide ‘the story,. . . , and sequence of events that occur over time’ and focus ‘on the dynamics of social change, explaining how and why the results [occur]’ [42,45]. Although process models can become analytically complex, they do have a specific form and should not be discounted as unscientific or less rigorous than [the more commonly used] factor models. The conceptual model represents the interaction of context with the participant selection and the interorganizational collaboration processes. The process models illustrate relationships among constructs developed with grounded theory. 5. Analyses 5.1. The participant selection process SAP narrowed the number of organizations participating down to seven, from the 15 attending the original meeting. It selected organizations with state-of-the-art treasury knowledge, such as foreign exchange, or statutory requirements, like GAAP reporting. To ensure mutual goal alignment, SAP chose organizations that were willing to look at best practices and to change their processes, if necessary. Following such discussions, applicants submitted resumes. Due to the rigorous selection process, the chosen individuals felt honored as members of an elite group and were excited to influence the design and be among the first customers to have the module. Although collaboration among rivals is possible, firms prefer to trade know-how with non-rivals [8,63]. Along these lines, SAP avoided assigning competing customers to the Treasury team. It also exercised judgment in selecting meeting facilitators. These people had a key role in building collaboration by preventing distrust and unbalanced influence, as well as managing conflict resolution and determining best practice. While the accuracy of professionals’ judgment in selecting participants for a collaborative effort varies, when the collaboration has clear goals, the selection of high quality performers should focus on mutual goals. 5.2. Mutual goals Mutual goals are objectives in common to all participants. In general, cooperative R&D enables firms to share the costs and benefits of projects. Prior to the steering committee meetings, the functionality of the SAP R/3 treasury module was minimal. Since then, treasury functions have been extended in the areas of foreign exchange, security management and market risk management. Customers were motivated to comply because they realized the advantages of Treasury functionality. A participant explained how integration in the treasury module offered huge benefits. The hardest thing is to get information out of all departments. Companies don’t communicate between departments. The attitude is ‘my information is my information; what do you want it for?’ In the treasury module, I need to determine cash flow, when I am going to need money, and how long I should invest my money. With SAP, there is a structure created, such that in five minutes I have access to all the accounts payable, all the accounts receivable, all projected sales for the next six months, all materials management expenses, and eventually when cost accounting is implemented — all budget information. While mutual goals are necessary they are not sufficient to gain mutual trust [16] for collaboration. Other conditions that impacted mutual trust were SAP’s judgment and customer rivalries, and the occupational community. 5.3. Occupational community Interdependence among collaborators with common professional interests and social similarities, for example R&D engineers, medical technologists or biotechnologists, promotes community level mutualism [50,62]; a shared culture, a community of intent; and a ‘community of fate.’ Participants from the same occupational community, such as academia, share values, norms and perspectives [48], reinforcing mutual trust. The steering committee customers had in common their occupational domain. Their collective identity, creation of a joint product and commonly shared values, helped develop identification-based trust [34]. Identification-based trust is an emotional connection between parties that have mutual understanding, agree, empathize with each other and take on the other’s values. 5.4. Mutual trust Mutual trust, the expectation shared by [participants] that they will meet their commitments to one another [43], was reinforced by the legitimacy conferred by SAP on the participants, and the impact of the occupational community. It is surprising that the respondents could not recall any overt signs of mistrust at any of the meetings. Previous studies propose that trust develops slowly and needs long-term prospects [37,60]. Cognitive trust is a rational view of trust and encompasses competence, and reliability [41]. In contrast, affect-based trust is the social view of trust encompassing care and concern [3]. In fact, swift trust was observed. This is cognitive perception in temporary groups from cues such as role clarity rather than interpersonal relations [40]. Swift trust is characteristic of temporary groups; they have less opportunity for dysfunctional interpersonal relationships, because they are fast paced, time constrained and focused on the task at hand [30]. Furthermore, although temporary teams lack history, members assume that the contractor has ‘checked them out’ (a proxy for observing reliability and competence) and inclusion implies selectivity. SAP’s rigorous selection process assured customers that SAP had been sure of the high ability and integrity of its participant firms: antecedents of trust [36]. 5.5. The interorganizational collaboration process Team spirit, friendliness and confidence in each other are measures of trustworthiness. Collaboration is exemplified by software teams that ‘gel’ when the members work together effectively, have a strong sense of identity, a sense of eliteness, a feeling of joint ownership of the product and an attitude of enjoyment [29,67]. Collaboration at the interorganizational level is associated with organizational learning [23,24,26,46]. Interorganizational collaboration catalyzes the learning process by introducing a diversity of new knowledge. In the Treasury meetings, there was a wide diversity of team members since the collaboration spanned organizational, geographical, and cultural boundaries, and a variety of industries and organizational sizes. Brainstorming was the key technique for capturing and exchanging the diversity of knowledge. Team members learned from each other by openly sharing experiences. [I]t was easier to learn and share experiences with people from different organizations than within one’s own organization. There seems to be more willingness to share between organizations than between [intraorganizational] teams. For example, problems developed when the individuals representing the development partner organizations exhausted their personal expertise and had to ask their co-workers for help. Some co-workers were not willing to share, either from lack of motivation or fear that their jobs would later become obsolete [15]. Interorganizational collaboration also catalyzes the learning process by stimulating reconsideration of current practices. By challenging assumptions, shared knowledge is transformed into best practices. Participants explained how the team benefited from the synergy of controversial group discussions. Best practices are acquired from challenging the status quo with double-loop learning. The ‘free flowing ideas’ in the Treasury meetings were characteristic of Model II or double-loop organizational learning behavior [1,18,27,57]. 5.6. Conflict Interorganizational partnerships carry the risk of discord from cultural differences causing different interpretations and misunderstandings [33]. Moreover, the a-conflictual fallacy of systems development [11] posits that the interaction of actors having diverse viewpoints, positions, goals, values, knowledge and interests that need to be reconciled results in ‘a mixed, conflict-cooperation game’ [35]. Conflict and tension are inevitable in these new working relationships. Explicitly managing conflict is a way to facilitate learning and establish consensus during software development [20,64]. Conflict is ‘not a debilitating factor needing to be suppressed in the software design team’. Effective conflict resolution increases the accuracy of requirements and the likelihood of project success [51,53]. Dealing with conflict helps error detection, which is the primary stimulus for organizational learning. Organizational conflict is associated with challenging the status quo and double-loop learning [38,39]. Since systems development improves with conflicting views and an attempt to understand the differences, a conscious effort should be made to discuss thoughts, feelings and assumptions relevant to a problem. Yet as assumptions are challenged conflict is likely [28,52]. Furthermore, confronting others by challenging the validity of their positions tends to elicit a defensive response. There...There were some small tense moments when team members argued over what is important to be developed, and when some companies feel their needs are higher priority. Sometimes someone got defensive when challenged. There are a lot of emotions when it comes to implementing new systems and getting the functionality. Nevertheless, offering opportunities to suggest alternatives can generate more valid information. Conflict resolution is an organizational learning process and team development process enabling convergence of perspectives to establish standards. However establishing the standard interface to the Treasury module generated arguments since no member wanted to have to maintain the interface. There was a lot of arguing about different companies’ needs, mostly involving generalized interfaces between third party software companies and SAP. Obviously SAP cannot write an interface with every other system that a company uses. The standard was to choose the most common outside systems, and the users also could place a request with their software vendors to work with SAP to become partners. 5.7. Reciprocity Reciprocity is payback for contributions to an exchange. Self-amplifying reciprocity can become the emerging norm as member companies take turns in making contributions. There is an obligation to return a favor, resulting in reciprocal learning. In exchange for our output to them, we get a direct link to the developers. If I have a problem, I don’t have to go through a consultant, or through the hotline support desk. I can email or call a developer directly in Germany and he will either tell me you can do this, or try this or he will go find a solution for it or he will put it on the list of requirements that need to be looked at. 5.8. Informal networks Collaboration emerges and transactions costs are lower from informal relationships. Moreover, managing the risks in collaboration relies on informal people-based mechanisms, such as interpersonal integration: a network of interpersonal ties between members of separate companies. Developers often exchange information through informal networks [6]. Because of informal networks and close relationships, SAP software developers responded rapidly to problems and queries from steering committee members and readily communicated by telephone or email. This is contrary to experiences of regular customers, who, because of the SAP expertise shortage, at times experience frustrations making contact with knowledgeable personnel. Germany was a major information gathering session. I made connections with people I would never [have had] the opportunity to meet with just being an average customer in the States. Our company was a big customer, so I got responses on requests to meet directly with developers. Most SAP consultants don’t even get that benefit. I came home with a much greater understanding of SAP and its methodology. Trust is more likely to develop during a socialization process in an informal atmosphere [7]. Previous research associates trust and informal networks of relationships, essential for effective collaborations for software development and new product development [32]. 5.9. Shared knowledge Shared knowledge is important. However, organizations need to understand their processes before they share [65]. Knowledge acquisition is an element of both organizational learning and requirements analy- sis processes [9]. The Treasury participants exchanged information and exhibited reciprocity as they helped each other. The emotional connection enabled the formation of informal networks that increased communications. The Treasury team members shared firm specific information that in other circumstances might have been considered proprietary. Certainly ‘top secret’ information would not be shared, but organizational knowledge was discussed in far more detail than customary with people external to the organization. 6. Discussion Our model is new in explaining interorganizational collaboration for enhancing functionality in ERP packaged software. In contrast, traditional software development is not an interorganizational collaboration and does not explicitly incorporate generalized standard processes that SAP calls best practices into requirements analysis. The grounded theory developed in this study meets the criteria of applicability. First, it fits the substantive area of study. Second, it is understandable to the practitioner. Third, it has generality. Finally, it provides potential control for the action and conditions to which it applies. 6.1. Implications for professionals While the majority of large US corporations have committed to using ERP packaged software in the last few years, academics have neglected to address practitioners’ concerns. This research contributes by addressing these concerns through understanding the process of enhancing functionality in a vendor-supported team. The main implication for ERP customers in general is an improved understanding of the functionality enhancement process that will contribute to better decision making. For example, the importance of close collaboration highlights the limitations of user groups and other indirect links to the vendor. Organizing a consortium is a possible way to get a direct link. Setting realistic expectations facilitates corporate planning for missing functionality and consideration of alternatives. Finally, to reduce dependency on one vendor, organizations might consider third party solutions that target this issue. In conclusion, a deeper understanding of the functionality enhancement process benefits not only team members, but also ERP customers and collaborators overall. References Judy E. Scott is an assistant professor in the Management Science and Information Systems department at the University of Texas at Austin. She completed her MBA and Ph.D. degrees at the Graduate School of Management, University of California, Irvine. Her research interests include enterprise software packages, organizational learning and the impact of IT on high-tech organizations. Her research has been published and is forthcoming in Communications of the ACM, Data Base, Decision Support Systems, Proceedings of The International Conference on Information Systems, Proceedings of The Hawaii International Conference on System Sciences and several other conference proceedings. Lisa Kaindl is a project manager at Dell Computer Corporation in Austin, Texas. Although she now works on new product projects, she has been involved as a subject matter expert in the implementation of several software packages. Her MBA degree focused on Finance.
{"Source-Url": "http://directory.umm.ac.id/Data%20Elmu/jurnal/I/Information%20and%20Management/Vol37.Issue3.Apr2000/1857.pdf", "len_cl100k_base": 6676, "olmocr-version": "0.1.50", "pdf-total-pages": 12, "total-fallback-pages": 0, "total-input-tokens": 32058, "total-output-tokens": 9106, "length": "2e12", "weborganizer": {"__label__adult": 0.0005388259887695312, "__label__art_design": 0.0010652542114257812, "__label__crime_law": 0.0008301734924316406, "__label__education_jobs": 0.0263214111328125, "__label__entertainment": 0.00023818016052246096, "__label__fashion_beauty": 0.00030231475830078125, "__label__finance_business": 0.06683349609375, "__label__food_dining": 0.0007071495056152344, "__label__games": 0.0012264251708984375, "__label__hardware": 0.0011816024780273438, "__label__health": 0.0010213851928710938, "__label__history": 0.0006356239318847656, "__label__home_hobbies": 0.00036716461181640625, "__label__industrial": 0.0011348724365234375, "__label__literature": 0.0007996559143066406, "__label__politics": 0.0005450248718261719, "__label__religion": 0.0004703998565673828, "__label__science_tech": 0.04974365234375, "__label__social_life": 0.0004506111145019531, "__label__software": 0.08941650390625, "__label__software_dev": 0.75439453125, "__label__sports_fitness": 0.0003895759582519531, "__label__transportation": 0.0008816719055175781, "__label__travel": 0.0004987716674804688}, "weborganizer_max": "__label__software_dev", "avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_ratio": [[0, 41281, 0.04467]], "fineweb_edu_fasttext_gt2__fineweb_edu_fasttext_gt2__score": [[0, 41281, 0.06735]], "ft_lang_id_en_doc_v2__ft_lang_id_en_doc_v2__en": [[0, 41281, 0.92379]], "google_gemma-3-12b-it_contains_pii": [[0, 2920, false], [2920, 7072, null], [7072, 10282, null], [10282, 14843, null], [14843, 17125, null], [17125, 19531, null], [19531, 23639, null], [23639, 28083, null], [28083, 32334, null], [32334, 36991, null], [36991, 38724, null], [38724, 41281, null]], "google_gemma-3-12b-it_is_public_document": [[0, 2920, true], [2920, 7072, null], [7072, 10282, null], [10282, 14843, null], [14843, 17125, null], [17125, 19531, null], [19531, 23639, null], [23639, 28083, null], [28083, 32334, null], [32334, 36991, null], [36991, 38724, null], [38724, 41281, null]], "google_gemma-3-4b-it_v2tag__is_academic_paper": [[0, 5000, true], [5000, 41281, null]], "google_gemma-3-4b-it_v2tag__is_class_syllabus": [[0, 5000, false], [5000, 41281, null]], "google_gemma-3-4b-it_v2tag__is_completion_certificate": [[0, 5000, false], [5000, 41281, null]], "google_gemma-3-4b-it_v2tag__is_court_notice": [[0, 5000, false], [5000, 41281, null]], "google_gemma-3-4b-it_v2tag__is_homework_assignment": [[0, 5000, false], [5000, 41281, null]], "google_gemma-3-4b-it_v2tag__is_news_article": [[0, 5000, false], [5000, 41281, null]], "google_gemma-3-4b-it_v2tag__is_public_order": [[0, 5000, false], [5000, 41281, null]], "google_gemma-3-4b-it_v2tag__is_resume_cv": [[0, 5000, false], [5000, 41281, null]], "google_gemma-3-4b-it_v2tag__is_test_or_quiz": [[0, 5000, false], [5000, 41281, null]], "google_gemma-3-4b-it_v2tag__is_textbook": [[0, 5000, false], [5000, 41281, null]], "pdf_page_numbers": [[0, 2920, 1], [2920, 7072, 2], [7072, 10282, 3], [10282, 14843, 4], [14843, 17125, 5], [17125, 19531, 6], [19531, 23639, 7], [23639, 28083, 8], [28083, 32334, 9], [32334, 36991, 10], [36991, 38724, 11], [38724, 41281, 12]], "pipe_delimited_lines_v1__pipe_delimited_lines_v1__pipe_delimited_lines_ratio": [[0, 41281, 0.09272]]}
olmocr_science_pdfs
2024-11-29
2024-11-29
b5db1f2d07522447989456184cd3db271cb35017
Formal Language A Practical Introduction Basics - Notation - Lattices - A simple language - Direct semantics - Control - Data structures and data types - A prolog semantics - Miscellaneous. Automata and natural language theory are topics lying at the heart of computer science. Both are linked to computational complexity and together, these disciplines help define the parameters of what constitutes a computer, the structure of programs, which problems are solvable by computers, and a range of other crucial aspects of the practice of computer science. In this important volume, two respected authors/editors in the field offer accessible, practice-oriented coverage of these issues with an emphasis on refining core problem solving skills. B is one of the few formal methods which has robust, commercially-available tool support for the entire development lifecycle from specification through to code generation. This volume provides a comprehensive introduction to the B Abstract Machine Notation, and to how it can be used to support formal specification and development of high integrity systems. A strong emphasis is placed on the use of B in the context of existing software development methods, including object-oriented analysis and design. The text includes a large number of worked examples, graduated exercises in B AMN specification and development (all of which have been class-tested), two extended case studies of the development process, and an appendix of proof techniques suitable for B. Based on material which has been used to teach B at postgraduate and undergraduate level, this volume will provide invaluable reading a wide range of people, including students, project technical managers and workers, and researchers with an interest in methods integration and B semantics. Theoretical challenges are often based on a few simple, and fundamental, concepts - highlighted in this book. An Introduction to Automata and Formal Languages. Turing Machines Have Been Introduced And The Book Discusses Computability And Decidability. A Number Of Problems With Solutions Have Been Provided For Each Chapter. A Lot Of Exercises Have Been Given With Hints/Answers To Most Of These Tutorial Problems. This second edition of Syntactic Theory: A Formal Introduction expands and improves upon a truly unique introductory syntax textbook. Like the first edition, its focus is on the development of precisely formulated grammars whose empirical predictions can be directly tested. There is also considerable emphasis on the precision of logical descriptions, hypotheses, and as well as on integrating syntactic hypotheses with matters of semantic analysis. The book covers the core areas of English syntax from the last quarter century, including complementation, control, “raising constructions,” passives, the auxiliary system, and the analysis of long distance dependency constructions. Syntactic Theory’s step-by-step introduction to a consistent grammar in these core areas is complemented by extensive problem sets drawing from a variety of languages. The book’s theoretical perspective is presented in the context of current models of language processing, and the practical value of the constraint-based, lexicalist grammatical architecture proposed has already been demonstrated in computer language processing applications. This thoroughly reworked second edition includes revised and extended problem sets, updated analyses, additional examples, and more detailed exposition throughout. Praise for the first edition: “Syntactic Theory sets a new standard for introductory syntax volumes that all future books should be measured against.”—Gert Weibelhuth, Journal of Linguistics Formal language theory was first developed in the mid 1950's in an attempt to develop theories of natural language acquisition. It was soon realized that this theory (particularly the context-free portion) was quite relevant to the artificial languages that had originated in computer science. Since those days, the theory of formal languages has been developed extensively, and has several discernible trends, which include applications to the semantic analysis of programming languages, program schemes, models of biological systems, and relationships with natural languages. This revised and expanded new edition elucidates the elegance and simplicity of the fundamental theory underlying formal languages and compilation. Retaining the reader-friendly style of the 1st edition, this versatile textbook describes the essential principles and methods used for defining the syntax of artificial languages, and for designing efficient parsing algorithms and syntax-directed translators with semantic attributes. Features: presents a novel conceptual approach to parsing algorithms that applies to extended BNF grammars, together with a parallel parsing algorithm (NEW); supplies supplementary teaching tools at an associated website; systematically discusses ambiguous forms, allowing readers to avoid pitfalls; describes all algorithms in pseudocode; makes extensive usage of theoretical models of automata, transducers and formal grammars; includes concise coverage of algorithms for processing regular expressions and finite automata; introduces static program analysis based on flow equations. This book is suitable for use in a university-level first course in computing (CS1), as well as the increasingly popular course known as CS0. It is difficult for many students to master basic concepts in computer science and programming. A large portion of the confusion can be blamed on the complexity of the tools and materials that are traditionally used to teach CS1 and CS2. This textbook was written with a single overarching goal: to present the core concepts of computer science as simply as possible without being simplistic. The name “temporal logic” may sound complex and daunting; but while they describe potentially complex scenarios, temporal logics are often based on a few simple, and fundamental, concepts - highlighted in this book. An Introduction to Practical Formal Methods Using Temporal Logic provides an introduction to formal methods based on temporal logic, for developing and testing complex computational systems. These methods are supported by many well-developed tools, techniques and results that can be applied to a wide range of systems. Fisher begins with a full introduction to the subject, covering the basics of temporal logic and using a variety of examples, exercises and pointers to more advanced work to help clarify and illustrate the topics discussed. He goes on to describe how this logic can be used to specify a variety of computational systems, looking at issues of linking specifications, concurrency, communication and composition ability. He then analyses temporal specification techniques such as deductive verification, algorithmic verification, and direct execution to develop and verify computational systems. The final chapter on case studies analyses the potential problems that can occur in a range of engineering applications in the areas of robotics, railway signalling, hardware design, ubiquitous computing, intelligent agents, and information security, and explains how temporal logic can improve their accuracy and reliability. Models temporal notions and uses them to analyze computational systems Provides a broad approach to temporal logic across many formal methods - including specification, verification and implementation Introduces and explains freely available tools based on temporal logics and shows how these can be applied Presents exercises and pointers to further study in each chapter, as well as an accompanying website providing links to additional systems based upon temporal logic as well as additional material related to the book. This classic book on formal languages, automata theory, and computational complexity has been updated to present theoretical concepts in a concise and straightforward manner with the increase of hands-on, practical applications. This new edition comes with Gradiance, an online assessment tool developed for computer science. Please note, Gradiance is no longer available with this book, as we no longer support this product. Formal Languages and Applications provides a comprehensive study-aid and self-tutorial for graduates students and researchers. The main results and techniques are presented in an readily accessible manner and accompanied by many references and directions for further research. This carefully edited monograph is intended to be the gateway to formal language theory and its applications, so it is very useful as a review and reference source of information in formal language theory. Data Structures & Theory of Computation Now you can clearly present even the most complex computational theory topics to your students with Sipser's distinct, market-leading INTRODUCTION TO THE THEORY OF COMPUTATION, 3E. The number one choice for today's computational theory course, this highly anticipated revision retains the unmatched clarity and thorough coverage that make it a leading text for upper-level undergraduate and introductory graduate students. This edition continues author Michael Sipser's well-known, approachable style with timely revisions, additional exercises, and more memorable examples in key areas. A new first-of-its-kind theoretical treatment of deterministic context-free languages is ideal for a better understanding of parsing and LR(k) grammars. This edition's refined presentation ensures a trusted accuracy and clarity that make the challenging study of computational theory accessible and intuitive to students while maintaining the subject's rigor and formalism. Readers gain a solid understanding of the fundamental mathematical properties of computer hardware, software, and applications with a blend of practical and philosophical coverage and mathematical treatments, including advanced theorems and proofs. INTRODUCTION TO THE THEORY OF COMPUTATION, 3E's comprehensive coverage makes this an ideal ongoing reference tool for those studying theoretical computing. Important Notice: Media content referenced within the product description or the product text may not be available in the ebook version. In this Element and its accompanying second Element, A Practical Introduction to Regression Discontinuity Designs: Extensions, Matias Cattaneo, Nicolás Idrobo, and Rocío Titiunik provide an accessible and practical guide for the analysis and interpretation of regression discontinuity (RD) designs that encourages the use of a common set of practices and facilitates the accumulation of RD-based empirical evidence. In this Element, the authors discuss the foundations of the canonical Sharp RD design, which has the following features: (i) the score is continuously distributed and has only one dimension, (ii) there is only one cutoff, and (iii) compliance with the treatment assignment is perfect. In the second Element, the authors discuss practical and conceptual extensions to this basic RD setup. Type theory is a fast-evolving field at the crossroads of logic, computer science and mathematics. This gentle step-by-step introduction is ideal for graduate students and researchers who need to understand the ins and outs of the mathematical machinery, the role of logical rules therein, the essential contribution of definitions and the decisive nature of well-structured proofs. The authors begin with untyped lambda calculus and proceed to several fundamental type systems, including the well-known and powerful Calculus of Constructions. The book also covers the essence of proof checking and proof development, and the use of dependent type theory to formalise mathematics. The only prerequisite is a basic knowledge of undergraduate mathematics. Carefully chosen examples illustrate the theory throughout. Each chapter ends with a summary of the content, some historical context, suggestions for further reading and a selection of exercises to help readers familiarise themselves with the material. Formal languages and automata theory is the study of abstract machines and how these can be used for solving problems. The book has a simple and exhaustive approach to topics like automata theory, formal languages and theory of computation. These descriptions are followed by numerous relevant examples related to the topic. A brief introductory chapter on compilers explaining its relation to theory of computation is also given. Formal LanguageA Practical IntroductionFranklin Beedle & Associates This book describes the Property Specification Language PSL, recently standardized as IEEE Standard 1850-2005. PSL was developed to fulfill the following requirements: easy to learn, write, and read; concise syntax; rigorously well-defined formal semantics; expressive power, permitting the specification for a large class of real world design properties; known efficient underlying algorithms in simulation, as well as formal verification. Basic features are covered, as well as advanced topics such as the use of PSL in multiply-clocked designs. A full chapter is devoted to common errors, gathered through the authors' many years of experience in using and teaching the language. A Concise Introduction to Languages, Machines and Logic provides an accessible introduction to three key topics within computer science: formal languages, abstract machines and formal logic. Written in an easy-to-read, informal style, this textbook assumes only a basic knowledge of programming on the part of the reader. The approach is deliberately non-mathematical, and features: - Clear explanations of formal notation and jargon. - Extensive use of examples to illustrate algorithms and proofs. - Pictorial representations of key concepts. - Chapter opening overviews providing an introduction and guidance to each topic. - End-of-chapter exercises and solutions. - Offers an Where To Download Formal Language A Practical Introduction intuitive approach to the topics. This reader-friendly textbook has been written with undergraduates in mind and will be suitable for use on course covering formal languages, formal logic, computability and automata theory. It will also make an excellent supplementary text for courses on algorithm complexity and compilers. The Formal Semantics of Programming Languages provides the basic mathematical techniques necessary for those who are beginning a study of the semantics and logics of programming languages. These techniques will allow students to invent, formalize, and justify rules with which to reason about a variety of programming languages. Although the treatment is elementary, several of the topics covered are drawn from recent research, including the vital area of concurrency. The book contains many exercises ranging from simple to miniprojects. Starting with basic set theory, structural operational semantics is introduced as a way to define the meaning of programming languages along with associated proof techniques. Denotational and axiomatic semantics are illustrated on a simple language of while-programs, and fall proofs are given of the equivalence of the operational and denotational semantics and soundness and relative completeness of the axiomatic semantics. A proof of Godel's incompleteness theorem, which emphasizes the impossibility of achieving a fully complete axiomatic semantics, is included. It is supported by an appendix providing an introduction to the theory of computability based on while-programs. Following a presentation of domain theory, the semantics and methods of proof for several functional languages are treated. The simplest language is that of recursion equations with both call-by-value and call-by-name evaluation. This work is extended to lan guages with higher and recursive types, including a treatment of the eager and lazy lambda-calculi. Throughout, the relationship between denotational and operational semantics is stressed, and the proofs of the correspondence between the operation and denotational semantics are provided. The treatment of recursive types - one of the more advanced parts of the book - relies on the use of information systems to represent domains. The book concludes with a chapter on parallel programming languages, accompanied by a discussion of methods for specifying and verifying nondeterministic and parallel programs. Preliminaries; Finite automata and regular languages; Pushdown automata and context-free languages; Turing machines and phrase-structure languages; Computability; Complexity; Appendices. The present text is a re-edition of Volume I of Formal Grammars in Linguistics and Psycholinguistics, a three-volume work published in 1974. This volume is an entirely self-contained introduction to the theory of formal grammars and automata, which hasn't lost any of its relevance. Of course, major new developments have seen the light since this introduction was first published, but it still provides the indispensable basic notions from which later work proceeded. The author's reasons for writing this text are still relevant: an introduction that does not suppose an acquaintance with sophisticated mathematical theories and methods, that is intended specifically for linguists and psycholinguists (thus including such topics as learnability and probabilistic grammars), and that provides students of language with a reference text for the basic notions in the theory of formal grammars and automata, as they keep being referred to in linguistic and psycholinguistic publications; the subject index of this introduction can be used to find definitions of a wide range of technical terms. An appendix has been added with further references to some of the core new developments since this book originally appeared. Covers all areas, including operations on languages, context-sensitive languages, automata, decidability, syntax analysis, derivation languages, and more. Numerous worked examples, problem exercises, and elegant mathematical proofs. 1983 edition. Formal Ethics is the study of formal ethical principles. The most important of these, perhaps even the most important principle of life, is the golden rule: "Treat others as you want to be treated". Although the golden rule enjoys support amongst different cultures and religions in the world, philosophers tend to neglect it. Formal Ethics gives the rule the attention it deserves. Modelled on formal logic, Formal Ethics was inspired by the ethical theories of Kant and Hare. It shows that the basic formal principles of ethics, like the golden rule, are very similar to principles of logic, and gives a firm basis for our ethical thinking. As an introduction to moral rationality, Formal Ethics also considers non-formal elements, and is applied to areas of practical concern such as racism and moral education. Ever since Chomsky laid the framework for a mathematically formal theory of syntax, two classes of formal models have held wide appeal. The finite state model offered simplicity. At the opposite extreme numerous very powerful models, most notably transformational grammar, offered generality. As soon as this mathematical framework was laid, devastating arguments were given by Chomsky and others indicating that the finite state model was woefully inadequate for the syntax of natural language. In response, the completely general transformational grammar model was advanced as a suitable vehicle for capturing the description of natural language syntax. While transformational grammar seems likely to be adequate to the task, many researchers have advanced the argument that it is "too adequate. " A now classic result of Peters and Ritchie shows that the model of transformational grammar given in Chomsky's Aspects [I] is powerful indeed. So powerful as to allow it to describe any recursively enumerable set. In other words it can describe the syntax of any language that is describable by any algorithmic process whatsoever. This situation led many researchers to reassess the claim that natural languages are included in the class of transformational grammar languages. The conclusion that many reached is that the claim is void of content, since, in their view, it says little more than that natural language syntax is doable algorithmically and, in the framework of modern linguistics, psychology or neuroscience, that is axiomatic. The study of formal languages and of related families of automata has long been at the core of theoretical computer science. Until recently, the main reasons for this centrality were connected with the specification and analysis of programming languages, which led naturally to the following questions. How might a grammar be written for such a language? How could we check whether a text were or were not a well-formed program generated by that grammar? How could we parse a program to provide the structural analysis needed by a compiler? How could we check for ambiguity to ensure that a program has a unique analysis to be passed to the computer? This focus on programming languages has now been broadened by the increasing concern of computer scientists with designing interfaces which allow humans to communicate with computers in a natural language, at least concerning problems in some well-delimited domain of discourse. The necessary work in computational linguistics draws on studies both within linguistics (the analysis of human languages) and within artificial intelligence. The present volume is the first textbook to combine the topics of formal language theory traditionally taught in the context of programming languages with an introduction to issues in computational linguistics. It is one of a series, The AKM Series in Theoretical Computer Science, designed to make key mathematical developments in computer science readily accessible to undergraduate and beginning graduate students. In any serious engineering discipline, it would be unthinkable to construct a large system without having a precise notion of what is to be built and without verifying how the system is expected to function. Software engineering is no different in this respect. Formal methods involve the use of mathematical notation and calculus in software development; such methods are difficult to apply to large-scale systems with practical constraints (e.g., limited developer skills, time and budget restrictions, changing requirements). Here Liu claims that formal engineering methods may bridge this gap. He advocates the incorporation of mathematical notation into the software engineering process, thus substantially improving the rigor, comprehensibility and effectiveness of the methods. commonly used in industry. This book provides an introduction to the SOFL (Structured Object-Oriented Formal Language) method that was designed and industry-tested by the author. Written in a style suitable for lecture courses or for use by professionals, there are numerous exercises and a significant real-world case study, so the readers are provided with all the knowledge and examples needed to successfully apply the method in their own projects. A self-contained tutorial on Z for working programmers discussing practical ways to apply formal methods in real projects, first published in 1997. This book contains original reviews by well-known workers in the field of mathematical linguistics and formal language theory, written in honour of Professor Solomon Marcus on the occasion of his 70th birthday. Some of the papers deal with contextual grammars, a class of generative devices introduced by Marcus, motivated by descriptive linguistics. Others are devoted to grammar systems, a very modern branch of formal language theory. Automata theory and the algebraic approach to computer science are other well-represented areas. While the contributions are mathematically oriented, practical issues such as cryptography, grammatical inference and natural language processing are also discussed. Contents:Substitutions on Words and LanguagesApplications to Cryptography (A Atanasu)Grammar Systems: A Multi-Agent Framework for Natural Language Generation (E Csuhaï-Varjú)Normal Forms for Contextual Grammars (A Ehrenfeucht et al.)Control Mechanisms on #-Context-Free Array Grammars (R Freund)On Transitive Cofinal Automata (M Ito & M Katsura)Algebraic Foundations for Montague Grammars (H Jürgensen & K Tent)A Periodic Languages and Generalizations (J Kari & G Thierrin)Matrix Grammars Versus Parallel Communicating Grammar Systems (V Mihalache)Reducts Versus Reducing Operators (M Novotný)On Conditional Grammars and Conditional Petri Nets (F L Tiplea)and other papers Readership: Computer scientists. keywords:Algebra;Array Grammar;Automaton;Chomsky Grammar;Combinatorics on Words;Cryptography;Grammar System;Marcus Grammar;Mereology;Montague Grammar;Natural Language;Petri Net This uniquely authoritative and comprehensive handbook is the first work to cover the vast field of formal languages, as well as their applications to the divergent areas of linguistics, developmental biology, computer graphics, cryptology, molecular genetics, and programming languages. The work has been divided into three volumes. Typical undergraduate CS/CE majors have a practical orientation: they study computing because they like programming and are good at it. This book has strong appeal to this core student group. There is more than enough material for a semester-long course. The challenge for a course in programming language concepts is to help practical students understand programming languages at an unaccustomed level of abstraction. To help meet this challenge, the book includes enough hands-on programming exercises and examples to motivate students whose primary interest in computing is practical. Introducing some of the foundational concepts, principles and techniques in the formal semantics of natural language, Elements of Formal Semantics outlines the mathematical principles that underlie linguistic meaning. Making use of a wide range of concrete English examples, the book presents the most useful tools and concepts of formal semantics in an accessible style and includes a variety of practical exercises so that readers can learn to utilise these tools effectively. For readers with an elementary background in set theory and linguistics or with an interest in mathematical modelling, this fascinating study is an ideal introduction to natural language semantics. Designed as a quick yet thorough introduction to one of the most vibrant areas of research in modern linguistics today this volume reveals the beauty and elegance of the mathematical study of meaning. Introduction to Formal Languages, Automata Theory and Computation presents the theoretical concepts in a concise and clear manner, with an in-depth coverage of formal grammar and basic automata types. The book also examines the underlying theory and principles of computation and is highly suitable to the undergraduate courses in computer science and information technology. An overview of the recent trends in the field and applications are introduced at the appropriate places to stimulate the interest of active learners. "Forall x is an introduction to sentential logic and first-order predicate logic with identity, logical systems that significantly influenced twentieth-century analytic philosophy. After working through the material in this book, a student should be able to understand most quantified expressions that arise in their philosophical reading. This books treats symbolization, formal semantics, and proof theory for each language. The discussion of formal semantics is more direct than in many introductory texts. Although forall x does not contain proofs of soundness and completeness, it lays the groundwork for understanding why these are things that need to be proven. Throughout the book, I have tried to highlight the choices involved in developing sentential and predicate logic. Students should realize that these two are not the only possible formal languages. In translating to a formal language, we simplify and profit in clarity. The simplification comes at a cost, and different formal languages are suited to translating different parts of natural language. The book is designed to provide a semester's worth of material for an introductory college course. It would be possible to use the book only for sentential logic, by skipping chapters 4-5 and parts of chapter 6"—Open Textbook Library. This book constitutes the thoroughly refereed post-workshop proceedings of the 5th International Workshop on Structured Object-Oriented Formal Language and Method, SOFL+MSVL 2015, held in Paris, France, in November 2015. The 15 papers presented in this volume were carefully reviewed and selected from 22 submissions. The focus of this workshops was on following subjects: Modeling, specification, verification, model checking, testing, debugging, transformation, and algorithm. Business ethics has largely been written from the perspective of analytical philosophy with very little attention paid to the work of continental philosophers. Yet although very few of these philosophers directly discuss business ethics, it is clear that their ideas have interesting applications in this field. This innovative textbook shows how the work of continental philosophers — Deleuze and Guattari, Foucault, Levinas, Bauman, Derrida, Levinas, Nietzsche, Zizek, Jonas, Sartre, Heidegger, Latour, Nancy and Sloterdijk — can provide fresh insights into a number of different issues in business ethics. Topics covered include agency, stakeholder theory, organizational culture, organizational justice, moral decision-making, leadership, whistle-blowing, corporate social responsibility, globalization and sustainability. The book includes a number of features designed to aid comprehension, including a detailed glossary of key terms, text boxes explaining key concepts, and a wide range of examples from the world of business. Copyright: 050570f4e2199a2ee87eb868f8114358
{"Source-Url": "https://datagravity.mattmakai.com/pavo/fast-data/formal_language_a_practical_introduction_pdf", "len_cl100k_base": 5451, "olmocr-version": "0.1.48", "pdf-total-pages": 5, "total-fallback-pages": 0, "total-input-tokens": 11161, "total-output-tokens": 5676, "length": "2e12", "weborganizer": {"__label__adult": 0.0014495849609375, "__label__art_design": 0.002346038818359375, "__label__crime_law": 0.0008454322814941406, "__label__education_jobs": 0.0280609130859375, "__label__entertainment": 0.0010395050048828125, "__label__fashion_beauty": 0.0007319450378417969, "__label__finance_business": 0.0014600753784179688, "__label__food_dining": 0.001807212829589844, "__label__games": 0.0025234222412109375, "__label__hardware": 0.001361846923828125, "__label__health": 0.002071380615234375, "__label__history": 0.0011205673217773438, "__label__home_hobbies": 0.0004584789276123047, "__label__industrial": 0.0012502670288085938, "__label__literature": 0.05364990234375, "__label__politics": 0.0009937286376953125, "__label__religion": 0.0022125244140625, "__label__science_tech": 0.28173828125, "__label__social_life": 0.000782012939453125, "__label__software": 0.0151519775390625, "__label__software_dev": 0.59619140625, "__label__sports_fitness": 0.0005292892456054688, "__label__transportation": 0.0016241073608398438, "__label__travel": 0.00035190582275390625}, "weborganizer_max": "__label__software_dev", "avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_ratio": [[0, 30113, 0.01774]], "fineweb_edu_fasttext_gt2__fineweb_edu_fasttext_gt2__score": [[0, 30113, 0.69961]], "ft_lang_id_en_doc_v2__ft_lang_id_en_doc_v2__en": [[0, 30113, 0.9316]], "google_gemma-3-12b-it_contains_pii": [[0, 6772, false], [6772, 13954, null], [13954, 22742, null], [22742, 30002, null], [30002, 30113, null]], "google_gemma-3-12b-it_is_public_document": [[0, 6772, true], [6772, 13954, null], [13954, 22742, null], [22742, 30002, null], [30002, 30113, null]], "google_gemma-3-4b-it_v2tag__is_academic_paper": [[0, 5000, true], [5000, 30113, null]], "google_gemma-3-4b-it_v2tag__is_class_syllabus": [[0, 5000, false], [5000, 30113, null]], "google_gemma-3-4b-it_v2tag__is_completion_certificate": [[0, 5000, false], [5000, 30113, null]], "google_gemma-3-4b-it_v2tag__is_court_notice": [[0, 5000, false], [5000, 30113, null]], "google_gemma-3-4b-it_v2tag__is_homework_assignment": [[0, 5000, false], [5000, 30113, null]], "google_gemma-3-4b-it_v2tag__is_news_article": [[0, 5000, false], [5000, 30113, null]], "google_gemma-3-4b-it_v2tag__is_public_order": [[0, 5000, false], [5000, 30113, null]], "google_gemma-3-4b-it_v2tag__is_resume_cv": [[0, 5000, false], [5000, 30113, null]], "google_gemma-3-4b-it_v2tag__is_test_or_quiz": [[0, 5000, false], [5000, 30113, null]], "google_gemma-3-4b-it_v2tag__is_textbook": [[0, 5000, true], [5000, 30113, null]], "pdf_page_numbers": [[0, 6772, 1], [6772, 13954, 2], [13954, 22742, 3], [22742, 30002, 4], [30002, 30113, 5]], "pipe_delimited_lines_v1__pipe_delimited_lines_v1__pipe_delimited_lines_ratio": [[0, 30113, 0.0]]}
olmocr_science_pdfs
2024-11-24
2024-11-24
e6f8642ccd1fab332b42c409aca60faa42776667
The GenABEL Project for statistical genomics [version 1; referees: 2 approved] Lennart C. Karssen1,2, Cornelia M. van Duijn2, Yurii S. Aulchenko1,3-5 1PolyOmica, Groningen, 9722 HC, Netherlands 2Department of Epidemiology, Erasmus Medical Center, Rotterdam, 3000 CA, Netherlands 3Institute of Cytology and Genetics, Siberian Division of the Russian Academy of Sciences, Novosibirsk, 630090, Russian Federation 4Novosibirsk State University, Novosibirsk, 630090, Russian Federation 5Centre for Global Health Research, Usher Institute of Population Health Sciences and Informatics, University of Edinburgh, Teviot Place, Edinburgh, EH8 9AG, UK Abstract Development of free/libre open source software is usually done by a community of people with an interest in the tool. For scientific software, however, this is less often the case. Most scientific software is written by only a few authors, often a student working on a thesis. Once the paper describing the tool has been published, the tool is no longer developed further and is left to its own device. Here we describe the broad, multidisciplinary community we formed around a set of tools for statistical genomics. The GenABEL project for statistical omics actively promotes open interdisciplinary development of statistical methodology and its implementation in efficient and user-friendly software under an open source licence. The software tools developed within the project collectively make up the GenABEL suite, which currently consists of eleven tools. The open framework of the project actively encourages involvement of the community in all stages, from formulation of methodological ideas to application of software to specific data sets. A web forum is used to channel user questions and discussions, further promoting the use of the GenABEL suite. Developer discussions take place on a dedicated mailing list, and development is further supported by robust development practices including use of public version control, code review and continuous integration. Use of this open science model attracts contributions from users and developers outside the “core team”, facilitating agile statistical omics methodology development and fast dissemination. Corresponding authors: Lennart C. Karssen (l.c.karssen@polyomica.com), Yurii S. Aulchenko (y.s.aulchenko@polyomica.com) How to cite this article: Karssen LC, van Duijn CM and Aulchenko YS. The GenABEL Project for statistical genomics [version 1; referees: 2 approved] F1000Research 2016, 5:914 (doi: 10.12688/f1000research.8733.1) Copyright: © 2016 Karssen et al. This is an open access article distributed under the terms of the Creative Commons Attribution Licence, which permits unrestricted use, distribution, and reproduction in any medium, provided the original work is properly cited. Grant information: Funding from the following sources enabled work on specific packages in the GenABEL suite: PolyOmica, Groningen, The Netherlands; Centre for Medical Systems Biology (CMSB), The Netherlands; the Netherlands Genomics Initiative (NGI); the Netherlands Organisation for Scientific Research (NWO); the Department for Health Evidence, Radboud University Medical Centre, Nijmegen, The Netherlands; Deutsche Forschungsgemeinschaft (German Research Association, grant GSC 111); Russian Foundation for Basic Research (RFBR, 12-04-33182, 15-34-20763, 15-04-07874); the RFBR-Helmholtz society Joint Research Groups programme (12-04-91322); the European Union FP7 framework projects MIMOmics (grant agreement nr. 305280) and Pain-Omics (grant agreement nr. 602736). The work of YSA was supported by a grant from the Russian Science Foundation (RSCF 14-14-00313). The funders had no role in study design, data collection and analysis, decision to publish, or preparation of the manuscript. Competing interests: The authors declare no conflicts of interest in the authorship or publication of this contribution. Introduction The field of statistical (gen-)omics lies at the heart of current research into the genetic aetiology of (human) disease and personalized or precision medicine. Genome-wide association studies (GWAS), genotype imputation and next-generation sequencing (NGS) are just a few of the techniques used in this field that is driven by increasingly larger data sets. With the advent of polyphenotype analysis as is now customary in e.g. lipidomics and metabolomics, the issues of dealing with big data have become imminent. In recent years, scientists and funding organizations alike have come to realize that in order to successfully tackle the challenges of the field, close collaboration between various disciplines, e.g. statistics, molecular biology, genetics, and computer science, is of paramount importance. Many software tools developed by scientists are distributed as free/libre open source software (FLOSS). FLOSS tools are often developed by groups of people with different backgrounds, working from different geographical locations, either under central guidance or in a loose cooperation, sometimes as part of their employment, sometimes “just for fun”. The key to successful, sustainable open source software is an active community of both developers/contributors and end users. Unfortunately, creators of scientific software are usually not funded to actively build such a community. Moreover, our experience shows that once the peer-reviewed article describing a tool has been published, funding and time to continue development and support of that tool are usually limited or non-existent, and consequently, the tool often slowly fades into oblivion. It needs no explanation that this amounts to a waste of effort and money. It was with these premises in mind that the GenABEL Project for Statistical Genomics was started as an extension of the original community of users and developers around the GenABEL package. The GenABEL project The GenABEL project aims to provide a framework for collaborative, sustainable, robust, transparent, opensource based development of statistical genomics methodology. Within the project, statisticians devoted to method development work together with statistical geneticists and biologists to refine existing statistical methods as well as develop new ones and make them applicable to genomic analysis. With the help of computer scientists and scientific software developers these mathematical models are then implemented into efficient and user-friendly software. This flow of work and information is not linear, but rather more circular in nature, with information and feedback being continuously transferred between the various layers as depicted in Figure 1. In short, it is a form of agile community-driven development. Openness is an important aspect of the GenABEL project. It enables a free flow of information between the layers in the project resulting in rapid feedback between the various levels. Not only do we require that all tools are released under an open source or free software licence like the GNU Public Licence (GPL), we also try to create an atmosphere of open communication using public mailing lists and web forums (see the sections Interaction with the user community and Development infrastructure below). Moreover, because of this openness results of the project (i.e. statistical methods as well as software packages) are easily disseminated among the end users, be they epidemiologists, bioinformaticians or others. The GenABEL suite The software tools developed within the GenABEL project collectively make up the GenABEL suite. Many tools are R packages, however, this is not a requirement for inclusion in the suite. Any software that is related to the field of statistical (gen-)omics is welcome (technical requirements are discussed in section Development infrastructure). Currently, the suite consists of 11 officially released tools (cf. Table 1) and two that are in beta stage. OpenABEL is a tool for running GWAS on imputed genotype data. Like the GenABEL package it allows running linear or logistic regression, as well as Cox proportional hazards model, however, OpenABEL is tailored to the large file sizes that are inherent to current data sets with approximately 30 million imputed genotypes per individual. It is the second most-used tool from the suite with more than 267 citations (according to Google Scholar). ProbABEL is a tool for running GWAS on imputed genotype data. Like the GenABEL package it allows running linear or logistic regression, as well as Cox proportional hazards model, however, ProbABEL is tailored to the large file sizes that are inherent to current data sets with approximately 30 million imputed genotypes per individual. It is the second most-used tool from the suite with more than 267 citations (according to Google Scholar). As indicated by its name, MixABEL is an R package for running genome-wide association analyses using mixed models in quantitative traits. GWAS usually involves meta-analysis of the regression results of various cohorts. The R package MetABEL provides simple meta-analysis functions including generation of forest plots. The R package VariABEL can be used to look for variance heterogeneity in genetic studies. Such heterogeneity is an indication of interaction between a genetic marker and either another marker or an unknown factor. In 2013 OmicABEL was added to the suite. It contains a high-performance computing based approach facilitating extremely fast mixed-model based regression of multiple omics traits like metabolomics or lipidomics on imputed genotype data. OmicABEL aims to increase computational throughput while reducing memory usage and energy consumption. This was achieved by using optimal (hardware-tailored) algorithms using state-of-the-art linear algebra kernels, incorporating optimizations and avoiding redundant computations. PredictABEL is an R package for the assessment of genetic risk prediction models. It includes functions to compute univariate and multivariate odds ratios of the predictors, the area under the receiver operating characteristic (ROC) curve (AUC), Hosmer-Lemeshow goodness of fit test, reclassification table, net reclassification improvement and integrated discrimination improvement. RepeatABEL allows one to run a GWAS for multiple observations on related individuals. Like ParallABEL, this package is a great example of contributions by the community since its development was not initiated by the core GenABEL developers. CollapsABEL is the most recent addition to the GenABEL suite. It is an R library for detecting compound heterozygote (CH) alleles in GWAS. It is a computationally efficient solution for screening general forms of CH alleles in densely imputed microarray or whole genome sequencing datasets. Apart from the aforementioned packages which directly address certain types of analysis and/or data management, several packages in the suite have a supportive role. DatABEL is an R interface to our filevector library which provides a file format that is optimised for fast access to data in matrix form, e.g. imputed genotype data. ParallABEL is an R library for parallel execution of GWAS in R. The latest stable version of the R packages are available on CRAN, the Comprehensive R Archive Network. The source code for the other packages can be downloaded from our website at http://www.genabel.org, from the project’s version control server or on GitHub (see section Development infrastructure). As indicated by its name, CollapsABEL is an R package for running genome-wide association analyses using mixed models in quantitative traits. Interaction with the user community The GenABEL project website is the central hub that points to package descriptions, tutorials, the development website, and other information for potential and existing users and developers. Usage statistics such as number of visits and country of origin of visitors are monitored using Google Analytics in order to get an estimate of the number of users of the tools and their origins. As an example of the information that can be obtained from this data, Figure 2 shows the top 20 cities of origin of the visitors of the GenABEL website in the period of 28 April 2015 till 28 April 2016. Only visits lasting more than 60 seconds and cities with more than 15 visits were taken into account in an attempt to filter out “accidental” visits. The website was visited 16319 times in that period, of which 696 visits were from an unknown city. Collecting visitor data like this helps getting an insight in the institutes that use software from the GenABEL suite, which can then be used to show the impact the tools have, e.g. when applying for funding. Interaction with the user community is done via social media like Twitter (https://twitter.com/GenApro) and Facebook (https://www.facebook.com/pages/GenABEL-project/329281857167394), as well as a dedicated mailing list for announcements of new package releases, making it easy for both users and system administrators to keep up to date with new releases and developments in the GenABEL project and the GenABEL suite. Each tool in the GenABEL suite has its own documentation and the GenABEL Tutorial with more than 260 pages takes the user from learning basic R to performing more complicated analyses, showing how the various packages interconnect. Moreover, several video tutorials are available online. Interactive user support is mostly done through our forum (http://forum.genabel.org). Having an open forum serves various purposes. First of all it is a central, easy to point to reference. Moreover, compared to having individual users e-mailing a package author, who may be on holiday or otherwise unavailable, an open forum where users and developers collaborate helps in shortening the time-to-answer. Furthermore, having an active forum where users can help each other allows the developers to focus on fixing bugs and implementing new features. As of March 1st, 2015, the GenABEL forum has 538 activated user accounts, with an average 2.92 new registrations per week since the start of the forum in January 2011. These users have contributed 1422 posts in 427 topics, with an average 7.15 posts per week. The first hurdle many users of (scientific) software encounter is the installation process. Within the GenABEL project we aim to make installation as simple as possible. Using CRAN for the R packages makes installation and upgrading as simple as typing a single command. For the tools that don’t use R, we aim to provide up-to-date packages for various Linux distributions. Currently, ProbABEL is packaged in the Stable, Testing and Unstable repositories of Debian with the help of the Debian Med team. Other packages are planned to be added before the end of 2016. For Ubuntu Linux a Personal Package Archive is available (https://launchpad.net/~l.c.karssen+archive/genabel-ppa). Packages for Red Hat Enterprise Linux and CentOS are on the road map, but haven’t been released yet. Development infrastructure The GenABEL project welcomes contributions of all sorts, from new tools to fixing spelling errors in the documentation, to bug reports and feature requests. To this end all program code and documentation are either stored in a publicly readable instance of the Subversion version control system, with write access limited to a group of core contributors, or on GitHub (https://github.com/GenABEL-Project), which is one of the leading platforms for what is termed “social coding”, which perfectly fits the project’s goals. These version control systems record any change to the files so they can easily be reviewed and reverted if necessary. In November 2010 a mailing list was created as a central place for development discussions. As of April 2016 this list has 34 subscribers. The GenABEL development website (https://r-forge.r-project.org/projects/genabel/) including the Subversion server, the mailing lists, and the trackers for bugs and feature requests are kindly provided by the R-Forge project¹. Currently, a total of 94 bugs have been submitted to the bug trackers on R-forge and GitHub since their opening in 2010 and 2015, respectively. Of these 94, 12 were directly contributed by people outside of the core team of developers. Another 42 bug reports were filed by regular contributors based on user reports on the forum, for example, which means that 56% of the bugs have been reported by people in our community that are not core contributors. In order to be able to maintain the quality of both old and new software in the GenABEL suite prospective tools go through a review process in which both the functional quality of the code is evaluated (does the tool do what it intends to do?), as well as the actual quality of the code (is the code clearly written, including developer documentation in the form of e.g. comments; does the code conform to the GenABEL coding style guidelines; etc.). Moreover, as set out in the GenABEL developer guidelines, we expect commitment of the person or team submitting a tool to the suite to maintain and support it, otherwise the maintenance burden would end up with the core team and it would be too easy to create a tool, write a paper and then ‘dump’ it in the GenABEL project hoping “the community” will take care of it. Therefore, the community has the option to mark a tool as obsolete, warning the user that bugs will no longer be fixed and support is limited or non-existent. In 2013 we have started to use a Jenkins Continuous Integration server. Using Jenkins various tests (e.g. regression tests, build tests and tests for memory leaks) are automatically run on each commit to the version control systems. Consequently, changes that break existing functionality are detected at an early stage, thus leading to more stable software releases. Conclusion The original publication of the GenABEL package for statistical analysis of genotype data⁶ has led to the evolution of a community which we now call the GenABEL project, which brings together scientists, software developers and end users with the central goal of making statistical genomics work by openly developing and subsequently implementing statistical models into user-friendly software. The project has benefited from an open development model, facilitating communication and code sharing between the parties involved. The use of a free software licence for the tools in the GenABEL suite promotes quick uptake and widespread dissemination of new methodologies and tools. Moreover, public access to the source code is an important ingredient for active participation by people from outside the core development team and is paramount for reproducible research. Feedback from end users is actively encouraged through a web forum, which steadily grows into a knowledge base with a multitude of answered questions. Furthermore, our open development process has resulted in transparent development of methods and software, including public code review, a large fraction of bugs being submitted by members of the community, and quick incorporation of bug fixes. Data and software availability The file tracker_report-2016-04-16.csv contains the data exported from the GenABEL R-forge bug tracker as it was on the date listed in the file name. Because of the recent move of some of the tools from R-forge to Github, the number of issues on the Github pages of the GenABEL project was still low. Therefore, these were counted manually. The file Analytics www.genabel.org Locatie Lennart 20150428-20160428.csv contains the data extracted from the Google Analytics page for the GenABEL website for the period listed in the file name. The columns contain the ISO code of the country, city, number of sessions, number of new viewers, bounce percentage, pages per session and average session duration, respectively. The file analysis_GenABELpaper.org contains the source code used for the automated data extraction for this paper in Emacs Org mode literate programming format (http://orgmode.org)⁶⁻⁷. The code contained in the Org mode file and the data in the csv files listed above are in the public domain (Creative Commons CC0 license) and can be used without restriction. The data related to the GenABEL forum were extracted manually from the forum control panel. The tools currently in the GenABEL suite are all Free Software, licensed under the GNU Public License. An up-to-date list of the packages in the suite can be found on http://www.genabel.org/packages, which also contains pointers to the source code of the latest stable versions and the version control repositories on R-forge and GitHub (see the section Development infrastructure above for the URLs). Archived source code at the time of publication https://zenodo.org/record/51008³⁻⁵ Author contributions CMvD and YSA jointly conceived the GenABEL suite. YSA conceived the idea the GenABEL project and formulated its initial guidelines. LCK and YSA are co-authors and maintainers of various packages in the GenABEL suite and act as maintainers of parts of the project’s infrastructure (e.g. forum and mailing lists). LCK drafted the initial version of the manuscript and analyzed the data. All authors contributed to the review of the manuscript and agreed to the final content. Competing interests The authors declare no conflicts of interest in the authorship or publication of this contribution. Grant information Funding from the following sources enabled work on specific packages in the GenABEL suite: PolyOmica, Groningen, The References Netherlands; Centre for Medical Systems Biology (CMSB), The Netherlands; the Netherlands Genomics Initiative (NGI); the Netherlands Organisation for Scientific Research (NWO); the Department for Health Evidence, Radboud University Medical Centre, Nijmegen, The Netherlands; Deutsche Forschungsgemeinschaft (German Research Association, grant GSC 111); Russian Foundation for Basic Research (RFBR, 12-04-33182, 15-34-20763, 15-04-07874); the RFBR-Helmholtz society Joint Research Groups programme (12-04-91322); the European Union FP7 framework projects MIMOms (grant agreement nr. 305280) and Pain-Omics (grant agreement nr. 602736). The work of YSA was supported by a grant from the Russian Science Foundation (RSFC 14-14-00313). The funders had no role in study design, data collection and analysis, decision to publish, or preparation of the manuscript. Acknowledgements We would like to thank the GenABEL community, i.e. the people who have used the software, filed bug reports, posted on the forum, or contributed tools, patches or ideas, for their involvement. Page 7 of 9 Open Peer Review Current Referee Status: ✔ ✔ Version 1 Referee Report 17 June 2016 doi:10.5256/f1000research.9397.r14125 Bjarni J. Vilhjálmsson Bioinformatics Research Centre, Aarhus University, Aarhus, Denmark Karsen et al. presents a paper on the GenABEL project, which is really a software suite that contains 11 different packages. This is a large and impressive project that contains packages that are routinely used by researchers studying genetics. Indeed, this is reflected by more than 800 citations (according to google scholar) for the original GenABEL paper published in 2006. However, the 11 packages presented in this paper have been published previously in some shape or form, albeit (presumably) not in their most recent version. It is therefore tempting to question the novelty of the current paper that summarizes the GenABEL project and describes its user and developer community. Nevertheless, despite limited amount of novel scientific ideas or scientific results in the current manuscript, the authors have clearly put a lot of work into creating a very impressive interactive user and developer community. Furthermore, the paper is well written and it will undoubtedly be highly cited by future researchers. Lastly, to reiterate, the GenABEL is a very impressive large scale project that is heavily used by the community! I therefore think this is overall a nice publication that is certainly suitable for indexation. Minor comments: - Abstract: “…developed withing..” -> “…developed within..” - I think it would be magnanimous if you acknowledged contributors as authors, e.g. under an umbrella term “The GenABEL community”. - Leave citations counts out of manuscript, it looks awkward. They will also change. - On p. 3 “polyphenotype”, I think multivariate would be a better word. I have read this submission. I believe that I have an appropriate level of expertise to confirm that it is of an acceptable scientific standard. Competing Interests: No competing interests were disclosed. Referee Report 27 May 2016 doi:10.5256/f1000research.9397.r14057 Giulietta Minozzi Department of Veterinary Science and Public Health, University of Milan, Milan, Italy This very well written article describes the GenABEL project for statistical genomics and high lightens the great success of the project, that in the years has lead to the creation of an actual scientific community that is spread in several countries worldwide. It is my understanding that the manuscript is aimed at reaching potential new users, but even to old users, unaware of the possible new tools included in the GenABEL project. The methodologies underlining the different tools and their potential applications are well described. Figure 2 describes the extent of the use of the GenABEL website/suite and Table 1 gives a glance of the tools available and on the new versions implemented. It is clear, from the texts, the effort that has taken place and is taking place aiming at bringing together top scientists, software developers and end users with the central goal of making statistical genomics work by openly developing and subsequently implementing statistical models into a user-friendly software. I retain this article, the tools and the information provided of extreme importance to the scientific community. I have read this submission. I believe that I have an appropriate level of expertise to confirm that it is of an acceptable scientific standard. Competing Interests: No competing interests were disclosed.
{"Source-Url": "https://f1000researchdata.s3.amazonaws.com/manuscripts/9397/b129f944-4e22-4e07-aec3-fb2d8ff29f8b_8733_-_lennart_karssen.pdf?doi=10.12688/f1000research.8733.1", "len_cl100k_base": 5347, "olmocr-version": "0.1.49", "pdf-total-pages": 9, "total-fallback-pages": 0, "total-input-tokens": 25506, "total-output-tokens": 7911, "length": "2e12", "weborganizer": {"__label__adult": 0.0003919601440429687, "__label__art_design": 0.00039076805114746094, "__label__crime_law": 0.0004563331604003906, "__label__education_jobs": 0.0029144287109375, "__label__entertainment": 0.00014269351959228516, "__label__fashion_beauty": 0.0002689361572265625, "__label__finance_business": 0.0007452964782714844, "__label__food_dining": 0.0005254745483398438, "__label__games": 0.0007300376892089844, "__label__hardware": 0.0011911392211914062, "__label__health": 0.00269317626953125, "__label__history": 0.0004935264587402344, "__label__home_hobbies": 0.00031757354736328125, "__label__industrial": 0.0006914138793945312, "__label__literature": 0.0003628730773925781, "__label__politics": 0.0004444122314453125, "__label__religion": 0.0005316734313964844, "__label__science_tech": 0.378173828125, "__label__social_life": 0.0004191398620605469, "__label__software": 0.047882080078125, "__label__software_dev": 0.55908203125, "__label__sports_fitness": 0.000537872314453125, "__label__transportation": 0.0005331039428710938, "__label__travel": 0.00025391578674316406}, "weborganizer_max": "__label__software_dev", "avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_ratio": [[0, 32106, 0.04508]], "fineweb_edu_fasttext_gt2__fineweb_edu_fasttext_gt2__score": [[0, 32106, 0.14894]], "ft_lang_id_en_doc_v2__ft_lang_id_en_doc_v2__en": [[0, 32106, 0.88023]], "google_gemma-3-12b-it_contains_pii": [[0, 2218, false], [2218, 4005, null], [4005, 8877, null], [8877, 13690, null], [13690, 16007, null], [16007, 21642, null], [21642, 28574, null], [28574, 30663, null], [30663, 32106, null]], "google_gemma-3-12b-it_is_public_document": [[0, 2218, true], [2218, 4005, null], [4005, 8877, null], [8877, 13690, null], [13690, 16007, null], [16007, 21642, null], [21642, 28574, null], [28574, 30663, null], [30663, 32106, null]], "google_gemma-3-4b-it_v2tag__is_academic_paper": [[0, 5000, true], [5000, 32106, null]], "google_gemma-3-4b-it_v2tag__is_class_syllabus": [[0, 5000, false], [5000, 32106, null]], "google_gemma-3-4b-it_v2tag__is_completion_certificate": [[0, 5000, false], [5000, 32106, null]], "google_gemma-3-4b-it_v2tag__is_court_notice": [[0, 5000, false], [5000, 32106, null]], "google_gemma-3-4b-it_v2tag__is_homework_assignment": [[0, 5000, false], [5000, 32106, null]], "google_gemma-3-4b-it_v2tag__is_news_article": [[0, 5000, false], [5000, 32106, null]], "google_gemma-3-4b-it_v2tag__is_public_order": [[0, 5000, false], [5000, 32106, null]], "google_gemma-3-4b-it_v2tag__is_resume_cv": [[0, 5000, false], [5000, 32106, null]], "google_gemma-3-4b-it_v2tag__is_test_or_quiz": [[0, 5000, false], [5000, 32106, null]], "google_gemma-3-4b-it_v2tag__is_textbook": [[0, 5000, false], [5000, 32106, null]], "pdf_page_numbers": [[0, 2218, 1], [2218, 4005, 2], [4005, 8877, 3], [8877, 13690, 4], [13690, 16007, 5], [16007, 21642, 6], [21642, 28574, 7], [28574, 30663, 8], [30663, 32106, 9]], "pipe_delimited_lines_v1__pipe_delimited_lines_v1__pipe_delimited_lines_ratio": [[0, 32106, 0.0]]}
olmocr_science_pdfs
2024-11-27
2024-11-27
d041283f7c3ffc13b62ef601c753b0f3100db523
Death by UML ALEX E. BELL, THE BOEING COMPANY Self-diagnosis and early treatment are crucial in the fight against UML Fever. A potentially deadly illness, clinically referred to as UML (Unified Modeling Language) fever, is plaguing many software-engineering efforts today. This fever has many different strains that vary in levels of lethality and contagion. A number of these strains are symptomatically related, however. Rigorous laboratory analysis has revealed that each is unique in origin and makeup. A particularly insidious characteristic of UML fever, common to most of its assorted strains, is the difficulty individuals and organizations have in self-diagnosing the affliction. A consequence is that many cases of the fever go untreated and often evolve into more complex and lethal strains. Little has been published in medical annals on UML fever because it has only recently emerged as an affliction. The New England Journal of Medicine has been silent on the disease, as has research produced by the world’s most prestigious medical institutions. The content of this article represents many years of on-the-job research and characterizes all known strains of UML fever, as well as many of the known relationships recognized to exist between them. The article will conclude with disclosure of the only known antidote for the many and varied strains of UML fever. Before commencing with the characterization of UML fever and its associated symptoms, it is important to emphasize that UML itself is not the direct cause of any maladies described herein. Instead, UML is largely an innocent victim caught in the midst of poor process, no process, or sheer incompetence of its users. Through no fault of its own, however, UML sometimes does amplify the symptoms of some fevers as the result of the often divine-like aura attached to it. For example, it is not uncommon for people to believe that no matter what task they may be engaged in, mere usage of UML somehow legitimizes their efforts or guarantees the value of the artifacts produced. This article exploits the fact that the presence and associated severity of many software-related maladies on a program can often be observed and measured in terms of UML: too much, too detailed, and too functional, for example. Some readers may be quick to suggest that the same exploitation could be made regardless of a program’s selected modeling approach. There may be some truth here, but no other technology has so quickly and deeply permeated the software-engineering life cycle quite like UML. THE METAFEVERS Extensive research has shown that UML fever can be categorized into four well-defined groups, known as metafevers. Their common laboratory names are delusional, emotional, Pollyanna (a person regarded as being foolishly or blindly optimistic), and procedural (see figure 1). Each of these metafevers is described in the following sections, as are the strains associated with them. Although much more is known about each of the strains than written, the objective of this particular article is to describe them to the extent that they are characterized and distinguishable from the others. **Delusional Metafever.** The delusional metafever comprises UML fever strains that are considered by many to be among the most deadly. This metafever is best known by its devastating effects on the thought and judgment processes of otherwise healthy managers and engineers. It is very common for the fevers in the delusional category to damage the human immune system to such an extent that the body becomes susceptible to many other UML fever strains (see figure 2). **Utopia fever.** Subjects afflicted with utopia fever typically believe that UML is a radical new technology with almost divine origins. Mutterings such as, “How did we get where we are today without UML?” and “Just think how much more advanced our technological revolution would be if we only had UML 20 years ago?” are common among those afflicted. Other symptoms of this fever include an amnesia-like condition causing people to forget that many complex software-based systems have been successfully built over the years without the benefits of UML. This fever’s direct symptoms are relatively benign on their own, but contracting utopia fever will most certainly result in affliction of more dangerous strains, particularly 42 fever (described later) where UML is believed to be the answer to all problems. A good litmus test for probing suspected carriers of utopia fever is to ask if they know of UML’s origins or what methodologies engineers were using before UML to design complex software-intensive systems. **Blind adopter fever.** This strain is recognized in those afflicted by a loss of judgment when it comes to assessing appropriate usage of available technologies and processes for their own programs. As opposed to tailoring or rejecting, victims of blind adopter fever tend to accept what other people have done on other programs even though it may not be applicable to their own. Engineers afflicted with blind adopter fever have been observed to blindly force state machine semantics into all of their classes just so they can take advantage of forward engineering technologies that convert UML diagrams into code. Another observed symptom of this fever includes... usage of software development processes or process frameworks right out of the box as opposed to tailoring them to fit the needs of their own programs. A side effect of using such processes is wasting time and money on producing many unnecessary artifacts. With most men, unbelief in one thing springs from blind belief in another. —Georg Christoph Lichtenberg Abracadabra fever. The most frequently observed symptom of those afflicted with abracadabra fever is an impaired sense of reality. Managers afflicted with this fever have been observed salivating profusely when told of technologies that automatically develop software from UML diagrams. Thoughts of improving code productivity metrics, previously dragged down by having to develop extremely complex business logic, also produce symptoms that include wide eyes and mutterings of large Christmas bonuses. One can only imagine the future symptoms of abracadabra fever when managers postulate automatic development of entire systems using MDA (Model-driven Architecture). While managers are the primary demographic afflicted by abracadabra fever, engineers have also been known to be susceptible. A common symptom of this fever on the engineering level is the expectation of almost surreal information being derived from gargantuan UML models. Insights into throughput, fault tolerance, latency, and system safety, for example, are just a few that are expected solely from UML models without having to be bothered with writing code or doing engineering work to characterize comprehensive component behaviors. Abracadabra fever appears to be very infectious among engineers who have little practical experience using UML. The truly educated man is that rare individual who can separate reality from illusion. —Author Unknown 42 fever. As opposed to the celebrated “42” being the answer to any question about life or the universe, as suggested in Douglas Adams’s *The Hitchhiker’s Guide to the Galaxy*, those afflicted with 42 fever argue that “UML” is actually the correct answer. The classical symptom of those afflicted with 42 fever in the sphere of software engineering is to have an a priori delusion that UML is the solution for all software-engineering problems. Research has shown that the delusion in victims of 42 fever can be significantly reduced by secretly playing subliminal messages in their work areas emphasizing that UML’s creators did not intend for it to be the answer to all of software engineering’s dilemmas. Although 42 and abracadabra fevers are similar and often afflict their victims simultaneously, some subtle differences are worthy of note. Those afflicted with 42 fever believe that UML is the correct answer to all questions, period. Those suffering from abracadabra fever, on the other hand, are not deluded that UML is necessarily the answer to everything, only the problems where they believe it to be the magical answer. If the only tool you have is a hammer, you tend to see every problem as a nail. —Abraham Maslow Curator fever. Much as a museum curator has a fascination and passion for paintings, those in the software engineering realm afflicted with curator fever have a similar absorption in UML diagrams. This absorption is fueled by curator fever’s propensity to delude its victims into believ- ![Diagram](https://via.placeholder.com/150) **UML Fever: Breakdown of Four Metafevers** --- **Types of Delusional Fevers** --- more queue: www.acmqueue.com ing that production of UML diagrams, as opposed to the engineering content behind them, is the single most important activity in the software-development life cycle. A commonly observed behavior by those in the grips of curator fever occurs when domain analysts create volumes of use-case diagrams but remain oblivious to the fact that the most important artifact of use-case modeling is developing the supporting text. UML interaction diagrams with messages analogous to “solve world hunger” between objects are of little value to any stakeholders. Use-case models afflicted with curator fever often declare software designers incompetent if they are unable to produce software designs based on extremely high-level diagrams. The only place a software designer would typically prefer a picture over a thousand words is in a museum. A painting in a museum hears more ridiculous opinions than anything else in the world.—Edmond de Goncourt Gravitational fever. This fever causes delusions in those afflicted to believe that gravitational acceleration enables their UML artifact mass to have value. For those unfamiliar with Newton’s second law of motion, those suffering with gravitational fever believe that the progress of software-engineering effort is directly proportional to the weight of the project’s UML artifacts. Research has shown that software managers are the demographic most susceptible to gravitational fever. A commonly observed symptom of this fever is for managers overseeing a code-hacking frenzy to direct development staff to reverse engineer their code into voluminous UML diagrams. These UML diagrams are subsequently passed off as design models, as opposed to the implementation models they really are. Gravitational fever is often misdiagnosed as curator fever because of the similarity of the two afflictions. The subtle difference between these fevers, however, is that those afflicted by curator fever are very interested in the quality of UML diagrams, whereas those afflicted by gravitational fever care only about their weight. Those who speak most of progress measure it by quantity and not by quality.—George Santayana **Emotional Metafever.** The strains composing the emotional metafever group tend to attack and take advantage of the human body’s emotional system. They include the fingerprinting, comfort zone, desperation, and sacred cow fevers described in this section (see figure 3). **Fingerprinting fever.** This fever coincidentally strikes those who are in the final stages of recovering from more serious fevers previously contracted. The severity of fingerprinting fever appears to be directly related to the amount of time and money previously wasted developing unnecessary UML artifacts while being ravaged by other fevers. A frequent symptom of fingerprinting fever is for its afflictees to unjustifiably blame a software-development process or framework for advocating the development of too many UML artifacts. Another common symptom of this fever is to blame UML itself for being too expressive and encouraging design artifacts to be modeled to unnecessarily low levels of detail. It is no use to blame the looking glass if your face is awry.—Nikolai Gogol **Comfort zone fever.** Victims of comfort zone fever typically enjoy a hypnotic sense of tranquility while they are engaged in activities focused on creating UML artifacts. Clinical analysis has shown that any attempt by its afflictees to migrate from creating UML diagrams onto software development activities later in the life cycle causes this tranquility to abruptly and traumatically cease. As a result, the victim’s UML diagrams become large in num- --- **Types of Emotional Fevers** - **Fingerprinting** - **Comfort zone** - **Desperation** - **Sacred cow** --- The strains composing the emotional metafever group tend to attack and take advantage of the human body’s emotional system. They include the fingerprinting, comfort zone, desperation, and sacred cow fevers described in this section (see figure 3). ber and extremely detailed (much to the delight of those suffering from gravitational fever). Comfort zone fever is recognized by resistance in its victims to depart from the comforts of UML diagram creation. Program risk is often amplified in the presence of comfort zone fever since the proposed designs are not validated as early as they should be in the form of implementation. The scholar who cherishes the love of comfort is not fit to be deemed a scholar.—Confucius Desperation fever. Extensive clinical research has identified a correlation between the occurrence of desperation fever and the existence of project traumas such as slipped schedules, low productivity, and poor product quality. A symptom of those plagued with desperation fever is flattened ears that result from spending inordinate amounts of time on the telephone speaking with vendors in search of products that will solve all known project woes. Victims of desperation fever often purchase expensive UML-centric products only to discover later that correct usage of those products does not align with their absent or broken software-development processes, often the root of their problems in the first place. The severity of desperation fever typically escalates as the result of highly paid consultants telling afflictees that newly purchased products will not bring benefits without major overhauls to existing software-development practices. It is characteristic of wisdom not to do desperate things.—Henry David Thoreau Sacred cow fever. Those afflicted with sacred cow fever develop intense emotional attachments to UML diagrams and refuse to allow any that have outlived their usefulness to die with the dignity they may deserve. Sacred cow fever results in many costs to a program including the cost of maintaining obsolete artifacts, misinformation propagation, and unnecessary consumption of storage resources. Clinical research suggests that this fever causes its victims to believe that by throwing away UML diagrams they are somehow negatively impacting the forward progress of the program (much to the delight of gravitational fever afflictees). Treatment for victims of sacred cow fever should include a counseling regimen reinforcing that the value of UML diagrams is often transient and discarding those that are no longer of value is encouraged. It is a very sad thing that nowadays there is so little useless information.—Oscar Wilde Procedural Metafever. The UML fever strains belonging to the procedural metafever (see figure 4) tend to impair their victims from recognizing that they are not following a development process or that they may be following a very bad one. The procedural metafever strains are known as open loop, circled wagons, gnat’s eyebrow, kitchen sink, and round trip. Open loop fever. The effects of open loop fever stimulate the urge for rampant creation of UML diagrams with no traceable objective or having no obvious stakeholder. Victims of open loop fever believe that the act of creating UML diagrams alone is a guarantee of value-added activity. Clinical research has suggested that individuals most susceptible to open loop fever are those who have never been end users of UML diagrams and those whose ride on the software life cycle has been very limited. Hypnotism has proven effective in easing the symptoms of open loop fever. Victims are programmed to tie creation of diagrams to program objectives and to engage with diagram clients to ensure that their needs are addressed. Post-hypnotic interviews with victims of this fever have resulted in the discovery that UML diagrams are not always the preferred artifacts of those downstream in the life cycle. Furious activity is no substitute for understanding.——H. H. Williams Sacred cow fever. Extensive clinical research has led to the discovery of circled wagons fever. Its primary symptom is its victim’s tendency to use UML use-case diagrams to capture fine-grained functional decompositions of their domain space. This fever’s name is derived Types of Procedural Fevers ![Diagram of Types of Procedural Fevers] FIG 4 from observations that its victims have a propensity to create use-case diagrams in the dreaded wagon train formation, as illustrated in figure 5. Despite the noble intentions of its victims to conduct object-oriented domain analysis, research has shown that circled wagons fever amplifies its victim’s natural tendency of breaking a problem down into smaller and smaller chunks to the extent of becoming a compulsive behavior. As opposed to simplifying the use-case modeling activity, victims of circled wagons fever actually complicate it by making the use-case model much more difficult to understand. Circled wagons fever is often observed in victims having functional decomposition backgrounds. This fever knows no boundaries, however; even people with object-oriented experience sometimes fall victim. This is a very common fever, and its symptoms should be carefully monitored within the engineering staff, particularly in the early stages of a program life cycle. Wisdom is knowing what to do next; virtue is doing it.—David Starr Jordan Gnat’s eyebrow fever is recognized in its victims by a very strong desire to create UML diagrams that are extremely detailed. Not to be confused with comfort zone fever, where detailed modeling is a side effect of emotional factors, affl ictees of gnat’s eyebrow fever emphatically believe that it is important to model to very low levels of detail because doing so increases the probability that the resulting code will be more correct. Because of variables such as flux in system requirements and dependent design activities occurring in parallel, for example, the time spent on low-level modeling is often better applied to actual implementation. Clinical research has shown a high affl iction rate of gnat’s eyebrow fever in those modelers who have not actually participated in coding activities. A theory supporting the research findings suggests that the coding experience is very important to developing a sense of value that provides modelers with insight into what is and what is not valuable to downstream clients of the model. Good judgment comes from experience. Experience comes from bad judgment.—Jim Horning Kitchen sink fever. Victims of kitchen sink fever crave the idea of building gargantuan UML models that include all fine-grained design elements in their detailed splendor. Kitchen sink fever is often accompanied by abracadabra fever in victims who believe that in the absence of code, information can be derived by describing the low-level behaviors of interactions spanning the model’s represented subsystems. Victims of kitchen sink fever typically spend significant amounts of time recovering from the effects of crashes of their modeling tools. Clinical research has shown that one reason victims of kitchen sink fever desire all possible artifacts in their models is that they have a poor understanding of the information that can be realistically derived from them. Research has also shown that those infected with this fever have typically never used a gargantuan model. Men have become fools with their tools. —Thomas Elisha Stewart Round trip fever. The primary symptom has a very serious effect on those afflicted: a complete loss of the ability to use abstraction as a means of managing the complexities of software design. Victims of round trip fever often fail to recognize the difference between a UML design model and an implementation model that they reverse engineer from detailed code. Software architects responsible for conducting design reviews typically give failing grades if they are given implementation models in review packages. The origins of round trip fever appear to be rooted in technology. Its victims typically start the traditional design cycle by creating very low-level implementation models so they can take advantage of reverse engineering toolsets. The demographic that round trip fever primarily targets is new graduates who are technologically-centric rather than architecturally-centric. Further research is required, but the downstream impact of what appears to be a serious deficiency of abstraction capability in our young engineers is a serious concern. Our life is frittered away by detail. Simplify, simplify. —Henry David Thoreau Pollyanna Metafever. The strains associated with the Pollyanna metafever (see figure 6) are typically observed in managers and characterized as being the result of foolish or blind optimism. The Pollyanna metafever includes square peg, one-eyed man, and shape shifter fevers. Square peg fever. This strain causes its victims to believe that all project staff members are interchangeable regardless of experience, background, or education. Symptoms include placing requirements personnel into the roles of software designers and assigning anyone capable of using a UML modeling tool into the domain analyst role. Square peg fever has the propensity to cause rampant UML fever of all strains when methodologists are put into the roles of technologists and practitioners. Research has shown that some cases of square peg fever are triggered by the ability of most anyone to create UML diagrams that resemble artifacts of value to desperate observers. Square peg fever is particularly prevalent in the face of staffing shortages or skill-set imbalances. No amount of artificial reinforcement can offset the natural inequalities of human individuals. —Henry P. Fairchild One-eyed man fever. We have long heard the adage that “the one-eyed man is king in the land of the blind.” This adage is embodied in the realm of software engineering as one-eyed man fever and usually afflicts managers who place in positions people who do not have nearly the expertise required to perform in those positions. Victims of one-eyed man fever may be recognized by their selection of the project’s UML visionary based solely on the number of half-day syntax classes previously attended. This fever appears to have a high incidence rate in managers who don’t understand the technologies under their jurisdiction to the extent required for making decisions about them. A very undesired side effect of one-eyed man fever is that the blind in the organization often mistake the one-eyed man’s practices as best practices and adopt them. A painting in a museum hears more ridiculous opinions than anything else in the world. —Edmond de Goncourt Shape shifter fever. Victims of shape shifter fever demonstrate raging affliction by sending people to brief design tool and language syntax classes with the expectation that they return as experts in best practice. Afflictees mis- take the ability to navigate “File ➞ New ➞ Class Diagram” dropdowns as the signature quality of a software designer. The symptoms of shape shifter fever are particularly exacerbated when classes on tool and language usage are taught out of context from how they will actually be used on a program. As some believe “clothes make the man,” afflictedes of this fever believe “UML makes the designer.” Much like the other strains in the Pollyanna metafever category, shape shifter fever is most prevalent in times of budget constraints and staffing shortages. Education is like a double-edged sword. It may be turned to dangerous uses if it is not properly handled. —Wu Ting-Fang THE BATTLE The diverse strains of UML fever described are based on first-hand pain and observation as opposed to simply being the musings of a fiction writer. The lighthearted manner in which the fevers are described should in no way placate the reader into believing that they are not real or that their symptoms are not potentially having serious impacts on the success of their own software programs. At the root of most UML fevers is a lack of practical experience in those individuals responsible for selecting and applying the technologies and processes underlying a program’s software-development efforts. This lack of experience translates into both unrealistic expectation and misapplication of technology, often aggravated by nonexistent or bad software-development processes, a perfect breeding ground for UML fever. If a software or- ganization’s battle against UML fever is to be successful, it is absolutely critical that people with practical experience are in place driving the selection of technologies, as well as developing the processes for their associated usage. The battle against UML fever is even further compli- cated by the difficulties some software organizations have in self-diagnosing their affliction. As previously suggested in the characterization of the delusional metafevers, some organizations can become so completely absorbed with UML that they lose sight of their primary objective, de- veloping software, in favor of building gigantic models. In such cases, independent and expert help from outside of the organization may be the only option for initiating the UML fever recovery process. Program management must regularly evaluate staff in influential positions for UML fever because its onset is sometimes gradual. Failure to promptly diagnose UML fever may result in its spread at epidemic proportion with devastating impact. Systematic diagnosis of UML fever is possible only if its symptoms are catalogued, characterized, and publicized— three explicit objectives of this article. Diagnosis, how- ever, is only the first step in the recovery process. Afflicted software organizations must also identify and diligently follow appropriate treatment regimens if they are to rid themselves of UML fever’s debilitating effects. The road to recovery is not always easy. Well-intended individuals attempting to launch diagnosis and treatment programs for their afflicted organizations may have to endure the unpleasantries of denial, groundless rationalization, and anger, often with intensities directly related to how high in the organization’s leadership hierarchy UML fever has stricken. The battle against UML fever can be won, but not until it is recognized as a genuine malady, and those who are afflicted with it get on the road to recovery. REFERENCES 2. Rumbaugh, J., Jacobson, I., and Booch, G. The Unified Modeling Language Reference Manual. Addison-Wesley, 3. Larman, C. Applying UML and Patterns. Prentice Hall 6. Bittner, K. Why Use Cases are not “Functions.” The Rational Edge. (December 2000); http:// www.therationaledge.com/content/dec_00/t_. ucnotfunctions.html. LOVE IT, HATE IT? LET US KNOW feedback@acmqueue.com or www.acmqueue.com/forums ALEX E. BELL (alex.e.bell@boeing.com) is a software architect with The Boeing Company. He has more than 22 years of software experience in a variety of domains that include command and control, air traffic control, and telecommunications. © 2004 ACM 1542-7730/04/0200 $5.00 The Fever is Real GRADY BOOCH, IBM FELLOW The late ’80s and early ’90s saw the proliferation of many competing software design methodologies, each with unique concepts, notations, terminologies, processes, and cultures associated with them. While some of these methodologies introduced new and innovative ideas, most aspired to very similar objectives although used dissimilar geometrical figures, colors, and vocabularies to achieve them. The emerging methodological stew brought with it consequences that included an increasing number of software engineers with nonportable skills, a bane of toolsets that were not interoperable, and an inability to characterize software design in a commonly understandable form. Because none of the methodologies was emerging as a frontrunner, the software engineering industry was desperate for standardization to drive badly needed unification. The UML (Unified Modeling Language) was specifically created to serve as this unifying force and was unanimously adopted as a standard by the OMG (Object Management Group) in November 1997. The UML introduced a standard notation and underlying semantics with which its users could describe and communicate software design as never before. Its notation was designed to transcend programming languages, operating systems, application domains, and software life-cycle phases to meet the needs of an industry hungry for order. The dawn of a new age in software engineering was poised to emerge. And emerge it did. Six years since its adoption by the OMG, the UML continues to be widely embraced by the software engineering community. Software development organizations continue to invest in UML training, UML-enabling toolsets, and integration of the UML into their development processes. Many organizations across the globe have successfully used the UML in innovative ways to improve how they design and develop software. Many other organizations, however, have not enjoyed the successes they assumed to be implicit by merely using the UML. Success with the UML requires thought and planning accompanied by an understanding of its purpose, limitations, and strengths—much like the usage of any technology. It is only through such awareness that an organization is most capable of applying the UML to address its unique needs, in its own context, and in a value-added manner. Blind adoption and usage of technology for technology’s sake is a recipe for disaster for any technology. The maladies described in Alex’s “Death by UML Fever” are often indicative of an organization’s misunderstanding of the UML, but more so, a systemically troubled development process in whose context it is used. For example, the UML was not intended to model every single line of an organization’s software to pristine detail. It was not intended to be a front-end syntax to define the context for comprehensive simulations. It was not intended for drawing diagrams that have no value or do not tie back to a software development process. And finally, the UML was certainly not intended to supplant the software development process itself. On the contrary, the UML was and is meant to be an important element of a software development process whose objectives include prescribing value-conscious usage of applicable technologies. The next significant evolutionary milestone for the UML is the release of version 2.0, scheduled for 2004. Six years of industry experience with UML 1.x have exposed several areas worthy of upgrade and include improvement for behavioral specification, as well as user extensibility. The eagerly awaited improvements of UML 2.0, however, do not eradicate UML fever, nor do they minimize susceptibility to it. Intelligent usage of technology, observing a good software development process, and having experienced people with the proper skill mix are as critical to success now as in the days before the UML. The entertaining tenor of “Death by UML Fever” should not be inferred to suggest that UML fever is an imaginary ailment. It is genuinely real, it is thriving, and its presence is causing cost and schedule trauma on many software programs right now. Furthermore, the root causes of this fever, in general, have nothing to do with the UML itself. Rather, this fever and its various manifestations are largely symptomatic of deeper ills in an organization’s software development practices. Software organizations should consider launching self-diagnosis campaigns to assess the presence or extent of UML fever on their programs and plan rehabilitation strategies as necessary. Developing good software is a difficult enough task without having to endure the preventable and often painful complications of the dreaded UML fever. GRADY BOOCH is one of the original developers of UML and is recognized for his innovative work on software architecture, modeling, and software engineering processes.
{"Source-Url": "http://www.netobjectives.com/files/UML_Fever.pdf", "len_cl100k_base": 6414, "olmocr-version": "0.1.53", "pdf-total-pages": 10, "total-fallback-pages": 0, "total-input-tokens": 29489, "total-output-tokens": 7016, "length": "2e12", "weborganizer": {"__label__adult": 0.0003159046173095703, "__label__art_design": 0.0004880428314208984, "__label__crime_law": 0.0002636909484863281, "__label__education_jobs": 0.0014133453369140625, "__label__entertainment": 5.704164505004883e-05, "__label__fashion_beauty": 0.00012409687042236328, "__label__finance_business": 0.0002191066741943359, "__label__food_dining": 0.00022554397583007812, "__label__games": 0.0003895759582519531, "__label__hardware": 0.00043702125549316406, "__label__health": 0.0004093647003173828, "__label__history": 0.00014078617095947266, "__label__home_hobbies": 6.0677528381347656e-05, "__label__industrial": 0.00019812583923339844, "__label__literature": 0.00031375885009765625, "__label__politics": 0.00016808509826660156, "__label__religion": 0.0003268718719482422, "__label__science_tech": 0.005184173583984375, "__label__social_life": 0.00010573863983154296, "__label__software": 0.00655364990234375, "__label__software_dev": 0.98193359375, "__label__sports_fitness": 0.0002065896987915039, "__label__transportation": 0.0002256631851196289, "__label__travel": 0.00010591745376586914}, "weborganizer_max": "__label__software_dev", "avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_ratio": [[0, 32975, 0.00932]], "fineweb_edu_fasttext_gt2__fineweb_edu_fasttext_gt2__score": [[0, 32975, 0.58306]], "ft_lang_id_en_doc_v2__ft_lang_id_en_doc_v2__en": [[0, 32975, 0.9535]], "google_gemma-3-12b-it_contains_pii": [[0, 47, false], [47, 804, null], [804, 5326, null], [5326, 8794, null], [8794, 12838, null], [12838, 16956, null], [16956, 19851, null], [19851, 23581, null], [23581, 28077, null], [28077, 32975, null]], "google_gemma-3-12b-it_is_public_document": [[0, 47, true], [47, 804, null], [804, 5326, null], [5326, 8794, null], [8794, 12838, null], [12838, 16956, null], [16956, 19851, null], [19851, 23581, null], [23581, 28077, null], [28077, 32975, null]], "google_gemma-3-4b-it_v2tag__is_academic_paper": [[0, 5000, true], [5000, 32975, null]], "google_gemma-3-4b-it_v2tag__is_class_syllabus": [[0, 5000, false], [5000, 32975, null]], "google_gemma-3-4b-it_v2tag__is_completion_certificate": [[0, 5000, false], [5000, 32975, null]], "google_gemma-3-4b-it_v2tag__is_court_notice": [[0, 5000, false], [5000, 32975, null]], "google_gemma-3-4b-it_v2tag__is_homework_assignment": [[0, 5000, false], [5000, 32975, null]], "google_gemma-3-4b-it_v2tag__is_news_article": [[0, 5000, false], [5000, 32975, null]], "google_gemma-3-4b-it_v2tag__is_public_order": [[0, 5000, false], [5000, 32975, null]], "google_gemma-3-4b-it_v2tag__is_resume_cv": [[0, 5000, false], [5000, 32975, null]], "google_gemma-3-4b-it_v2tag__is_test_or_quiz": [[0, 5000, false], [5000, 32975, null]], "google_gemma-3-4b-it_v2tag__is_textbook": [[0, 5000, false], [5000, 32975, null]], "pdf_page_numbers": [[0, 47, 1], [47, 804, 2], [804, 5326, 3], [5326, 8794, 4], [8794, 12838, 5], [12838, 16956, 6], [16956, 19851, 7], [19851, 23581, 8], [23581, 28077, 9], [28077, 32975, 10]], "pipe_delimited_lines_v1__pipe_delimited_lines_v1__pipe_delimited_lines_ratio": [[0, 32975, 0.0]]}
olmocr_science_pdfs
2024-12-08
2024-12-08
41ca7677034e27548c935f265e0e4c5885f98c28
[REMOVED]
{"len_cl100k_base": 4098, "olmocr-version": "0.1.53", "pdf-total-pages": 7, "total-fallback-pages": 0, "total-input-tokens": 17127, "total-output-tokens": 5038, "length": "2e12", "weborganizer": {"__label__adult": 0.00033283233642578125, "__label__art_design": 0.0004277229309082031, "__label__crime_law": 0.0005698204040527344, "__label__education_jobs": 0.0011625289916992188, "__label__entertainment": 0.00012111663818359376, "__label__fashion_beauty": 0.0001885890960693359, "__label__finance_business": 0.0012073516845703125, "__label__food_dining": 0.0004830360412597656, "__label__games": 0.0008192062377929688, "__label__hardware": 0.0015974044799804688, "__label__health": 0.0011196136474609375, "__label__history": 0.00043487548828125, "__label__home_hobbies": 0.0001842975616455078, "__label__industrial": 0.0007700920104980469, "__label__literature": 0.00032830238342285156, "__label__politics": 0.0003559589385986328, "__label__religion": 0.0003914833068847656, "__label__science_tech": 0.406005859375, "__label__social_life": 0.0001341104507446289, "__label__software": 0.020538330078125, "__label__software_dev": 0.5615234375, "__label__sports_fitness": 0.000362396240234375, "__label__transportation": 0.0007495880126953125, "__label__travel": 0.00027489662170410156}, "weborganizer_max": "__label__software_dev", "avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_ratio": [[0, 18121, 0.03025]], "fineweb_edu_fasttext_gt2__fineweb_edu_fasttext_gt2__score": [[0, 18121, 0.57862]], "ft_lang_id_en_doc_v2__ft_lang_id_en_doc_v2__en": [[0, 18121, 0.88667]], "google_gemma-3-12b-it_contains_pii": [[0, 3578, false], [3578, 7043, null], [7043, 10863, null], [10863, 14783, null], [14783, 16939, null], [16939, 17914, null], [17914, 18121, null]], "google_gemma-3-12b-it_is_public_document": [[0, 3578, true], [3578, 7043, null], [7043, 10863, null], [10863, 14783, null], [14783, 16939, null], [16939, 17914, null], [17914, 18121, null]], "google_gemma-3-4b-it_v2tag__is_academic_paper": [[0, 5000, true], [5000, 18121, null]], "google_gemma-3-4b-it_v2tag__is_class_syllabus": [[0, 5000, false], [5000, 18121, null]], "google_gemma-3-4b-it_v2tag__is_completion_certificate": [[0, 5000, false], [5000, 18121, null]], "google_gemma-3-4b-it_v2tag__is_court_notice": [[0, 5000, false], [5000, 18121, null]], "google_gemma-3-4b-it_v2tag__is_homework_assignment": [[0, 5000, false], [5000, 18121, null]], "google_gemma-3-4b-it_v2tag__is_news_article": [[0, 5000, false], [5000, 18121, null]], "google_gemma-3-4b-it_v2tag__is_public_order": [[0, 5000, false], [5000, 18121, null]], "google_gemma-3-4b-it_v2tag__is_resume_cv": [[0, 5000, false], [5000, 18121, null]], "google_gemma-3-4b-it_v2tag__is_test_or_quiz": [[0, 5000, false], [5000, 18121, null]], "google_gemma-3-4b-it_v2tag__is_textbook": [[0, 5000, false], [5000, 18121, null]], "pdf_page_numbers": [[0, 3578, 1], [3578, 7043, 2], [7043, 10863, 3], [10863, 14783, 4], [14783, 16939, 5], [16939, 17914, 6], [17914, 18121, 7]], "pipe_delimited_lines_v1__pipe_delimited_lines_v1__pipe_delimited_lines_ratio": [[0, 18121, 0.03191]]}
olmocr_science_pdfs
2024-12-10
2024-12-10
52ce8d11b85993305bdb0d9e1405c8e7d9be60d6
Computational Creativity as a Web-Service Tony Veale, UCD & KAIST A (Web-) Service-Oriented Architecture is “an architectural model that aims to enhance the efficiency, agility, and productivity of an enterprise by positioning services as the primary means through which solution logic is represented” *Erl* (2008) Well-designed services should be *discoverable, autonomous* and widely *reusable*, and should be flexible enough to *compose* in groups, while remaining *loosely coupled* to others. Services should also maintain *minimal state information* and use abstraction to *hide the complexity* of their inner workings and data. Creativity In Large Organizations • Develop in-house experts/specializations • Frequently Call on External Creative Agencies • Agencies have expertise in idea generation, integration of ideas, and framing of ideas • Combine in-house and external capabilities • External agencies learn from many different clients across many diverse commissions Creativity In Software Applications - Inbuilt task-specific functions and capabilities - May Call on *External Creative Web Services* - Such Services have expertise in *idea generation*, *idea composition*, and the framing of ideas - No Need to implement fluid *CC State-of-the-Art* - External services can learn from *many different client apps* across *many diverse commissions* Discovery of Creative Web Services On the Semantic Web Metaphor Gen. Services Affect Filtering Conceptual Blend Generation Framing in Poetry Framing in Kinetic Typography Ideation Services: Divergent Generation of Ideas & Viewpoints <table> <thead> <tr> <th>Taxon/Creature</th> <th>Human Beings</th> <th>Nine-banded Armadillo</th> </tr> </thead> <tbody> <tr> <td>Kingdom:</td> <td>Animalia</td> <td>Animalia</td> </tr> <tr> <td>Phylum:</td> <td>Chordata</td> <td>Chordata</td> </tr> <tr> <td>Class:</td> <td>Mammalia</td> <td>Mammalia</td> </tr> <tr> <td>Order:</td> <td>Primata</td> <td>Cingulata</td> </tr> <tr> <td>Family:</td> <td>Hominidae</td> <td>Dasypodidae</td> </tr> <tr> <td>Genus:</td> <td>Homo</td> <td>Dasypus</td> </tr> <tr> <td>Species:</td> <td>Homo Sapiens</td> <td>Dasypus Novemcinctus</td> </tr> </tbody> </table> I guess I’m 42% **armadillo**? ... and 100% **armadildo**! “My sunglasses are a burqa for my eyes” - Karl Lagerfeld, fashion supervillain The Web is a vast echo chamber of many *diverse* and *competing* voices. What if we view these many voices as the outputs of a *single divergent individual*? Isn’t anyone going to *answer* that? Why, I'm as crazy as a - coot - snake - loon - fruitcake - cuckoo - fox - bat Acquiring Stereotypical Ideas: Harvest *Simile* patterns from Web Use Web query pattern "as * a | an as * " to harvest 10,000s of similes Learn how **Stereotypical Properties Suggest / Imply Together** Adjacency matrix of *mutually-reinforcing* properties acquired from WWW: ``` <table> <thead> <tr> <th></th> <th>hot</th> <th>spicy</th> <th>humid</th> <th>fiery</th> <th>dry</th> <th>sultry</th> <th>...</th> </tr> </thead> <tbody> <tr> <td>hot</td> <td>---</td> <td>35</td> <td>39</td> <td>6</td> <td>34</td> <td>11</td> <td>...</td> </tr> <tr> <td>spicy</td> <td>75</td> <td>---</td> <td>0</td> <td>15</td> <td>1</td> <td>1</td> <td>...</td> </tr> <tr> <td>humid</td> <td>18</td> <td>0</td> <td>---</td> <td>0</td> <td>1</td> <td>0</td> <td>...</td> </tr> <tr> <td>fiery</td> <td>6</td> <td>0</td> <td>0</td> <td>---</td> <td>0</td> <td></td> <td>...</td> </tr> <tr> <td>dry</td> <td>6</td> <td>0</td> <td>0</td> <td>0</td> <td>---</td> <td></td> <td>...</td> </tr> <tr> <td>sultry</td> <td>11</td> <td>1</td> <td>0</td> <td>2</td> <td>0</td> <td></td> <td>...</td> </tr> <tr> <td>...</td> <td>...</td> <td>...</td> <td>...</td> <td>...</td> <td>...</td> <td>...</td> <td>...</td> </tr> </tbody> </table> ``` Use the Google query **“as * and * as”** to acquire associations A Taxonomy as A Pool of Triples: How to obtain the largest Pool? Form Initial Triples From Simile-derived Associations Use the stereotypical features derived from the “as X as a Y” frame earlier: - <espresso, black, ?> - <whiskey, strong, ?> - <politician, corrupt, ?> - <coffee, hot, ?> - <snake, dangerous, ?> - <vampire, immortal, ?> - <fox, cunning, ?> - <wolf, cruel, ?> - <mummy, dry, ?> - <virus, infectious, ?> - <silk, soft, ?> - <rock, dense, ?> Note: These triples are incomplete – they each lack a parent field, filled during the first cycle of bootstrapping. Acquiring informative fine-grained categorizations such as: - *cola is a carbonated drink* or - *tofu is a boring food* E.g., “expensive foods such as *salmon* [and champagne]” E.g., “fizzy treats such as *Cola* [and *Lemonade*]” Bootstrapping on web is a controlled form of Divergent / Lateral Lateral Thinking on the Web: Divergent Growth of Knowledge Starting from a trusted solid foundation of detailed viewpoints, use bootstrapping over web-content to acquire more and more ... Removing Noise between Bootstrapping Cycles: use WordNet Filtered Bootstrap: Remove incongruous triples after each cycle. Coarse WordNet Filter Remove \(<X, Y, Z>\) if \(X\) is not a descendant of \(Z\), or a descendant of a direct parent of \(Z\) creativity & leadership Shared Category for creativity and leadership abstract_attribute, abstract_skill, affective_skill, basic_skill, behavioural_skill, cognitive_skill, commercial_skill, cultural_skill, developmental_skill, entrepreneurial_skill, essential_skill, exceptional_skill, general_skill, important_attribute, important_skill, individual_attribute, individual_skill, intellectual_skill, interpersonal_skill, key_attribute, key_skill, managerial_skill, marketable_skill, mental_attribute, natural_ability, necessary_attribute, new_skill, personal_attribute, personal_skill, positive_attitude, positive_attribute, practical_skill, professional_attribute, qualitative_attribute, social_skill, special_ability, special_attribute, special_skill, subjective_attribute, subjective_measure, subjective_thing, technical_skill, transferable_skill, valuable_skill, valued_skill, vital_skill, vocational_skill, birth & death <table> <thead> <tr> <th></th> <th>car - automobile</th> <th>11.</th> <th>bird - cock</th> <th>21.</th> <th>coast - hill</th> </tr> </thead> <tbody> <tr> <td>2</td> <td>gem - jewel</td> <td>12.</td> <td>bird - crane</td> <td>22.</td> <td>forest - graveyard</td> </tr> <tr> <td>3</td> <td>journey - voyage</td> <td>13.</td> <td>tool - implement</td> <td>23.</td> <td>shore - woodland</td> </tr> <tr> <td>4</td> <td>boy - lad</td> <td>14.</td> <td>brother - monk</td> <td>24.</td> <td>monk - slave</td> </tr> <tr> <td>5</td> <td>coast - shore</td> <td>15.</td> <td>crane - implement</td> <td>25.</td> <td>coast - forest</td> </tr> <tr> <td>6</td> <td>asylum - madhouse</td> <td>16.</td> <td>lad - brother</td> <td>26.</td> <td>lad - wizard</td> </tr> <tr> <td>7</td> <td>magician - wizard</td> <td>17.</td> <td>journey - car</td> <td>27.</td> <td>chord - smile</td> </tr> <tr> <td>8</td> <td>midday - noon</td> <td>18.</td> <td>monk - oracle</td> <td>28.</td> <td>glass - magician</td> </tr> <tr> <td>9</td> <td>furnace - stove</td> <td>19.</td> <td>cemetery - woodland</td> <td>29.</td> <td>rooster - voyage</td> </tr> <tr> <td>10</td> <td>food - fruit</td> <td>20.</td> <td>food - rooster</td> <td>30.</td> <td>noon - string</td> </tr> </tbody> </table> **Thesaurus Rex** achieves **0.93** correlation with **M&C human ratings** Feelings & Emotions for Affective Ideation For $99.6\%$ of positive seeds (1309 of 1314), $\text{pos}(x) > \text{neg}(x)$ For $98.1\%$ of negative seeds (1359 of 1385), $\text{neg}(x) > \text{pos}(x)$ typical(Baby) (163 properties) - innocent - sniveling - adorabale - lovable - cute - drooling - bawling - peaceful - mewling - screaming - cranky - sobbing - angelic - indulged - soft - delicate - warm - whimpering - wailing - heartwarming Average P/R/F1 scores for the affective retrieval of positive and negative properties from 6,230 stereotypes <table> <thead> <tr> <th>Macro Average (6230 stereotypes)</th> <th>Positive properties</th> <th>Negative properties</th> </tr> </thead> <tbody> <tr> <td><strong>Precision</strong></td> <td>.962</td> <td>.98</td> </tr> <tr> <td><strong>Recall</strong></td> <td>.975</td> <td>.958</td> </tr> <tr> <td><strong>F-Score</strong></td> <td>.968</td> <td>.968</td> </tr> </tbody> </table> Avg. 6.51 properties per stereotype Understanding the Relationship Between Feelings and Properties Patterns of co-description in similes show us how properties *make us feel* <table> <thead> <tr> <th></th> <th>disgusting</th> <th>terrifying</th> <th>revolting</th> <th>disturbing</th> <th>frightening</th> <th>appalling</th> <th>exciting</th> </tr> </thead> <tbody> <tr> <td>bloody</td> <td>8</td> <td>4</td> <td>3</td> <td>3</td> <td>2</td> <td>2</td> <td>2</td> </tr> <tr> <td>vile</td> <td>34</td> <td>0</td> <td>1</td> <td>5</td> <td>0</td> <td>0</td> <td>0</td> </tr> <tr> <td>filthy</td> <td>14</td> <td>0</td> <td>4</td> <td>0</td> <td>0</td> <td>0</td> <td>0</td> </tr> <tr> <td>bizarre</td> <td>11</td> <td>1</td> <td>2</td> <td>0</td> <td>11</td> <td>1</td> <td>1</td> </tr> <tr> <td>horrible</td> <td>11</td> <td>3</td> <td>0</td> <td>1</td> <td>2</td> <td>0</td> <td>0</td> </tr> <tr> <td>horrid</td> <td>10</td> <td>0</td> <td>2</td> <td>0</td> <td>1</td> <td>0</td> <td>0</td> </tr> <tr> <td>...</td> <td>...</td> <td>...</td> <td>...</td> <td>...</td> <td>...</td> <td>...</td> <td>...</td> </tr> </tbody> </table> Simple Morphology rules “I feel *disgusted* by” “I feel *appalled* by ...” <table> <thead> <tr> <th>How I feel now</th> <th>Most Common Feelings</th> </tr> </thead> <tbody> <tr> <td>Challenging art and its uncompromising photographs challenge me.</td> <td>bored_by, fulfilled_by, rewarded_by,</td> </tr> <tr> <td>I feel rewarded by art and its equally cherished treasures. They encourage me.</td> <td>challenged_by, intimidated_by, unnerved_by,</td> </tr> <tr> <td>Do you feel excited by art and its balanced portfolios? Aren't you pleased by them?</td> <td>excited_by, stimulated_by, interested_by,</td> </tr> <tr> <td>Art and its intriguing ideas make me feel interested and motivated.</td> <td>disappointed_by, prevented_by, stressed_by, oppressed_by,</td> </tr> <tr> <td>I often feel stimulated and supported by intriguing art and its diversified portfolios.</td> <td>fascinated_by, dominated_by, satisfied_by,</td> </tr> <tr> <td>I often feel gripped by sophisticated art and its fascinating concepts.</td> <td>perplexed_by, intrigued_by, frustrated_by,</td> </tr> <tr> <td>I feel intrigued by art and its tantalizing treasures. Don't they inspire you?</td> <td>drained_by, abused_by, attacked_by, discouraged_by, provoked_by, charmed_by,</td> </tr> <tr> <td></td> <td>refreshed_by, energized_by, entertained_by, gripped_by,</td> </tr> <tr> <td></td> <td>amused_by, exhilarated_by, strengthened_by, surprised_by,</td> </tr> <tr> <td></td> <td>overwhelmed_by, distressed_by, frightened_by, forced_by, empowered_by,</td> </tr> <tr> <td></td> <td>humiliated_by, depressed_by, stirred_by, enriched_by, amazed_by,</td> </tr> <tr> <td></td> <td>bewildered_by, graced_by, invigorated_by, confused_by, confined_by,</td> </tr> <tr> <td></td> <td>enlightened_by, disturbed_by, baffled_by, delighted_by, manipulated_by, tired_by,</td> </tr> <tr> <td></td> <td>loved_by, haunted_by, damaged_by, captivated_by, gratified_by, moved_by,</td> </tr> <tr> <td></td> <td>stunned_by, controlled_by, puzzled_by, shocked_by, inspired_by,</td> </tr> <tr> <td></td> <td>respected_by, encouraged_by, helped_by, pained_by, thrilled_by,</td> </tr> <tr> <td></td> <td>uplifted_by, threatened_by, managed_by, motivated_by, liberated_by,</td> </tr> <tr> <td></td> <td>restricted_by, daunted_by, healed_by, terrified_by, punished_by,</td> </tr> <tr> <td></td> <td>impressed_by,</td> </tr> </tbody> </table> Idea Combination Services: Affective Metaphor & Blending Every n-gram corpus can be viewed as a Lexicalized Idea Space The Google N-Grams is vast database of recurring Web-text fragments Web n-grams: suggests viability of many atypical combinations of ideas Apple is a religion ### Target Metaphors: Apple - bad: ogre, spoiled: playboy, macabre: funeral, - dogmatic: cult, - proprietary: monopoly, overlooked: risk, - harmful: toxin, overbearing: boss, weird: spook, - depraved: sinner, overlooked: minority, - spoiled: star, dreaded: critic, inanimate: machine, - dogmatic: religion, weird: mutant, - inanimate: brick, burning: cigarette, exiled: revolutionary, - emotionless: monster, deprived: fetish, - inanimate: stone, exiled: militant, - complicated: encyclopedia, perilous: pit, spreading: virus, - harmful: parasite, deprived: scoundrel, - obsessed: creep, deprived: crazy_person, - misguided: crackpot, fighting: barbarian, - spreading: disease, toppled: tyrant, - calculating: cheat, tortured: soul, branded: coward, - toppled: authoritarian, twisted: roller_coaster, - infamous: murder, bloated: mess, ### Source Metaphors: -religion - terrible: mistake, hateful: bigotry, - depraved: cult, troubling: question, - authoritarian: church, - disgusting: ass, breaking: heart, mocking: comedy, - depraved: playboy, lying: child, - threatening: disease, - vicious: regime, - fighting: fundamentalist, - threatening: curse, twisted: tangle, strict: teacher, - pernicious: dogma, - complicated: computer, nasty: mosquito, - depressing: humiliation, negative: handicap, depraved: lunatic, - disgusting: shack, dumb: statue, raging: punk, - fighting: crazy_man, threatening: army, How I feel now Doesn't Apple restrict you? Do you feel oppressed by Apple? I feel hated by Apple. I often feel bored by Apple. Apple stifles me. I feel irritated by Apple. Are you obsessed by Apple? I often feel abused by Apple. I frequently feel repressed by Apple. Are you condemned by Apple? Most Common Feelings hated_by, appalled_by, oppressed_by, challenged_by, disturbed_by, abused_by, gripped_by, humiliated_by, intimidated_by, threatened_by, unnerved_by, alarmed_by, shocked_by, sickened_by, amused_by, damaged_by, thrilled_by, frightened_by, troubled_by, terrified_by, interested_by, disgusted_by, chilled_by, alienated_by, refreshed_by, haunted_by, delighted_by, confused_by, depressed_by, encouraged_by, impressed_by, enchanted_by, amazed_by, respected_by, punished_by, fascinated_by, excited_by, loved_by, horrified_by, constrained_by, healed_by, entertained_by, dominated_by, intrigued_by, repulsed_by, surprised_by, controlled_by, restricted_by, helped_by, stunned_by, stifled_by, condemned_by, constricted_by, unsettled_by, bored_by, embarrassed_by, manipulated_by, protected_by, pained_by, menaced_by, coerced_by, irritated_by, inspired_by, harmed_by, baffled_by, bewildered_by, overwhelmed_by, repressed_by, obsessed_by, irascible_by, puzzled_by, mesmerized_by, charmed_by, devastated_by, frustrated_by, degraded_by, perplexed_by, supported_by, stressed_by, bullied_by, disabled_by, <table> <thead> <tr> <th>Target Metaphors: <em>love</em></th> <th>Source Metaphors: <em>-prison</em></th> </tr> </thead> <tbody> <tr> <td>scared:cow, nagging:paradox, lingering:concern,</td> <td>authoritarian:church, immobile:house,</td> </tr> <tr> <td>**grim:**tragedy, **hated:**prison, **crowded:**jail,</td> <td>humiliating:punishment,</td> </tr> <tr> <td>grim:death, unwanted:thought, burning:disgrace,</td> <td>crowded:ghetto, fighting:plane,</td> </tr> <tr> <td>alarming:emergency, threatening:force,</td> <td>forbidding:wall, dreary:dungeon,</td> </tr> <tr> <td>burning:sin, insubstantial:rainbow,</td> <td>dire:emergency, dreary:tragedy,</td> </tr> <tr> <td>raging:disease, sombre:church, raging:fire,</td> <td>overwhelming:feeling, controlling:switch, vain:mode, appalling:crime,</td> </tr> <tr> <td>absurd:oxymoron, absurd:fallacy, crushing:train,</td> <td>dreary:vault, controlling:court, sprawling:palace,</td> </tr> <tr> <td>**dreary:**grave, raging:river, patient:teacher,</td> <td>appalling:disgrace, disgusting:waste, appalling:revelation,</td> </tr> <tr> <td>lingering:memory, baffling:wonder, grim:dungeon,</td> <td>gloomy:cell, crowded:hospital, crowded:mosque,</td> </tr> <tr> <td>throbbing:drum, seething:ghetto,</td> <td>immobile:building, sprawling:factory, impeached:governor,</td> </tr> </tbody> </table> Poetic Qualities of *prison*: demonic: menace, deathly: darkness, terrified: horror, monstrous: menace, ghostly: horror, shadowed: gloom, shady: gloom, monstrous: horror, deadly: darkness, cloudy: darkness, misty: darkness, atrocious: horror, stormy: darkness, tragic: gloom, ghostly: darkness, murderous: horror, Poetic Qualities of *love*: heroic: passion, childlike: devotion, poetic: passion, friendly: devotion, motherly: tenderness, saintly: passion, flowery: sweetness, childish: adoration, daughterly: devotion, girlish: sweetness, wifely: devotion, childish: sweetness, saintly: devotion, flowery: tenderness, motherly: coarseness, childlike: sweetness, devout: devotion, devout: zeal, motherly: affection, motherly: embrace, girlish: tenderness, friendly: embrace, angelic: tenderness, priestly: devotion, tender: affection, fatherly: affection, devout: adoration, rosy: sweetness, childish: zeal, childlike: zeal, doglike: devotion, childlike: tenderness, childlike: affection, fannish: devotion, <table> <thead> <tr> <th>Projected Qualities</th> <th>Emergent Qualities</th> </tr> </thead> </table> Packaging, Framing and Delivery The “Stereotrope” Approach to Poetry No Fire Is More Overwhelmingly Hot My love is a tender fire No fireplace glows more warmly, or blazes more brightly Depress me with the transcendent spirit of your fire Let your luminous brightness dazzle me Was ever a spark emitted by a more alarmingly dangerous fire? You burn for me as brightly as any gleaming torch Does any fire rise more dangerously than this love? See how you glow for me with your overwhelming brightness O Love, you warm me with your surging attack Insight Generation Services find noteworthy “surprises” in knowledge, and feed these to poetry generation services. E.g., **incongruities** and **oppositions** in everyday knowledge **Disciplined** armies defend **undisciplined** civilians **Fragrant** gardens often contain **smelly** weeds **Straight** arrows are fired from **curved** bows **Dragons** live in **chilling** dungeons but breathe **warming** fire **Immoral** wars are conducted by **moral** ministers No Religion Is More Religiously Spiritual My science is a systematic religion Formalized doctrines do sciences create, and by blessed scientific leaders are these doctrines promoted No monk is more dogmatically religious, or nags so much Challenge me with the defined mission of your religion Let your standardized qualification attract me Was ever a philosophy followed by a more absolutely inclusive religion? How you liberate me so absolutely, like any revelatory religion Is any religion more spiritual than this science? You spiritually liberate me with your blessed revelations Just as the most spiritual disciples serve the most religious saints, the most spiritual religions are defended by the most religious believers Can charismatic gurus ever promote religions of boring rituals? O Science, you help me with your defensible philosophies No Grave Is More Beautifully Quiet My love is a sweet grave In desecrated cemeteries is love found The most silent lamb is not more quietly tender Heal me with this sacred sweetness Let your consecrated devotion inspire me Did ever a ghost haunt a more silently still grave? How you molder me, like a quietly rotting grave Does any grave rot more quietly than this love? You rot me with your quiet silence Just as the darkest bats live in the gloomiest caverns, the darkest graves contain the gloomiest tombs Why would a grave of winning veterans be haunted by vanquished kings? However, how does a gnarled veteran become a handsome king? O Love, you depress me with this transcendent sanctity No Giant Is More Incredibly Massive Impress me with this magnificent leadership The most undisputed rule scarcely reigns so much Excite me with this visible strength Let your powerful impacts haunt me Does any giant bulge more incredibly than this Microsoft? You devour me as hungrily as any huge whale Does any giant expand more hugely than this Microsoft? You frighten me with your incredible hulks Immense heights do tiny giants so rarely reach What if fewer tsars were deposed? Would more palaces be occupied by dominating tsars, and would more dominating authoritarians live in these palaces? Yet would anyone prefer to live in palaces that are occupied by toppled giants rather than by crowned tsars? O Microsoft, you menace me with this enormous battle QUESTIONS?
{"Source-Url": "http://videolectures.net/site/normal_dl/tag=828160/ascc2013_veale_web.pdf", "len_cl100k_base": 6050, "olmocr-version": "0.1.50", "pdf-total-pages": 52, "total-fallback-pages": 0, "total-input-tokens": 69571, "total-output-tokens": 7168, "length": "2e12", "weborganizer": {"__label__adult": 0.0017538070678710938, "__label__art_design": 0.10125732421875, "__label__crime_law": 0.0016241073608398438, "__label__education_jobs": 0.036224365234375, "__label__entertainment": 0.0051727294921875, "__label__fashion_beauty": 0.001262664794921875, "__label__finance_business": 0.0190277099609375, "__label__food_dining": 0.0014944076538085938, "__label__games": 0.003978729248046875, "__label__hardware": 0.0016937255859375, "__label__health": 0.0015001296997070312, "__label__history": 0.0018796920776367188, "__label__home_hobbies": 0.0013942718505859375, "__label__industrial": 0.00205230712890625, "__label__literature": 0.161865234375, "__label__politics": 0.003055572509765625, "__label__religion": 0.005161285400390625, "__label__science_tech": 0.114501953125, "__label__social_life": 0.0028285980224609375, "__label__software": 0.072509765625, "__label__software_dev": 0.457275390625, "__label__sports_fitness": 0.0005102157592773438, "__label__transportation": 0.0013837814331054688, "__label__travel": 0.0005655288696289062}, "weborganizer_max": "__label__software_dev", "avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_ratio": [[0, 21007, 0.00885]], "fineweb_edu_fasttext_gt2__fineweb_edu_fasttext_gt2__score": [[0, 21007, 0.07948]], "ft_lang_id_en_doc_v2__ft_lang_id_en_doc_v2__en": [[0, 21007, 0.82583]], "google_gemma-3-12b-it_contains_pii": [[0, 67, false], [67, 637, null], [637, 983, null], [983, 1365, null], [1365, 1542, null], [1542, 1604, null], [1604, 2155, null], [2155, 2235, null], [2235, 2235, null], [2235, 2235, null], [2235, 2432, null], [2432, 2511, null], [2511, 2650, null], [2650, 3419, null], [3419, 3484, null], [3484, 3995, null], [3995, 4300, null], [4300, 4489, null], [4489, 4739, null], [4739, 4739, null], [4739, 5652, null], [5652, 5652, null], [5652, 5666, null], [5666, 6513, null], [6513, 6556, null], [6556, 6556, null], [6556, 6556, null], [6556, 6556, null], [6556, 6556, null], [6556, 6715, null], [6715, 6956, null], [6956, 6956, null], [6956, 6956, null], [6956, 7512, null], [7512, 8624, null], [8624, 11523, null], [11523, 11580, null], [11580, 11783, null], [11783, 11803, null], [11803, 13210, null], [13210, 14623, null], [14623, 15831, null], [15831, 16842, null], [16842, 16842, null], [16842, 17663, null], [17663, 17695, null], [17695, 18217, null], [18217, 18691, null], [18691, 19541, null], [19541, 20236, null], [20236, 20997, null], [20997, 21007, null]], "google_gemma-3-12b-it_is_public_document": [[0, 67, true], [67, 637, null], [637, 983, null], [983, 1365, null], [1365, 1542, null], [1542, 1604, null], [1604, 2155, null], [2155, 2235, null], [2235, 2235, null], [2235, 2235, null], [2235, 2432, null], [2432, 2511, null], [2511, 2650, null], [2650, 3419, null], [3419, 3484, null], [3484, 3995, null], [3995, 4300, null], [4300, 4489, null], [4489, 4739, null], [4739, 4739, null], [4739, 5652, null], [5652, 5652, null], [5652, 5666, null], [5666, 6513, null], [6513, 6556, null], [6556, 6556, null], [6556, 6556, null], [6556, 6556, null], [6556, 6556, null], [6556, 6715, null], [6715, 6956, null], [6956, 6956, null], [6956, 6956, null], [6956, 7512, null], [7512, 8624, null], [8624, 11523, null], [11523, 11580, null], [11580, 11783, null], [11783, 11803, null], [11803, 13210, null], [13210, 14623, null], [14623, 15831, null], [15831, 16842, null], [16842, 16842, null], [16842, 17663, null], [17663, 17695, null], [17695, 18217, null], [18217, 18691, null], [18691, 19541, null], [19541, 20236, null], [20236, 20997, null], [20997, 21007, null]], "google_gemma-3-4b-it_v2tag__is_academic_paper": [[0, 5000, true], [5000, 21007, null]], "google_gemma-3-4b-it_v2tag__is_class_syllabus": [[0, 5000, false], [5000, 21007, null]], "google_gemma-3-4b-it_v2tag__is_completion_certificate": [[0, 5000, false], [5000, 21007, null]], "google_gemma-3-4b-it_v2tag__is_court_notice": [[0, 5000, false], [5000, 21007, null]], "google_gemma-3-4b-it_v2tag__is_homework_assignment": [[0, 5000, false], [5000, 21007, null]], "google_gemma-3-4b-it_v2tag__is_news_article": [[0, 5000, false], [5000, 21007, null]], "google_gemma-3-4b-it_v2tag__is_public_order": [[0, 5000, false], [5000, 21007, null]], "google_gemma-3-4b-it_v2tag__is_resume_cv": [[0, 5000, false], [5000, 21007, null]], "google_gemma-3-4b-it_v2tag__is_test_or_quiz": [[0, 5000, false], [5000, 21007, null]], "google_gemma-3-4b-it_v2tag__is_textbook": [[0, 5000, false], [5000, 21007, null]], "pdf_page_numbers": [[0, 67, 1], [67, 637, 2], [637, 983, 3], [983, 1365, 4], [1365, 1542, 5], [1542, 1604, 6], [1604, 2155, 7], [2155, 2235, 8], [2235, 2235, 9], [2235, 2235, 10], [2235, 2432, 11], [2432, 2511, 12], [2511, 2650, 13], [2650, 3419, 14], [3419, 3484, 15], [3484, 3995, 16], [3995, 4300, 17], [4300, 4489, 18], [4489, 4739, 19], [4739, 4739, 20], [4739, 5652, 21], [5652, 5652, 22], [5652, 5666, 23], [5666, 6513, 24], [6513, 6556, 25], [6556, 6556, 26], [6556, 6556, 27], [6556, 6556, 28], [6556, 6556, 29], [6556, 6715, 30], [6715, 6956, 31], [6956, 6956, 32], [6956, 6956, 33], [6956, 7512, 34], [7512, 8624, 35], [8624, 11523, 36], [11523, 11580, 37], [11580, 11783, 38], [11783, 11803, 39], [11803, 13210, 40], [13210, 14623, 41], [14623, 15831, 42], [15831, 16842, 43], [16842, 16842, 44], [16842, 17663, 45], [17663, 17695, 46], [17695, 18217, 47], [18217, 18691, 48], [18691, 19541, 49], [19541, 20236, 50], [20236, 20997, 51], [20997, 21007, 52]], "pipe_delimited_lines_v1__pipe_delimited_lines_v1__pipe_delimited_lines_ratio": [[0, 21007, 0.21884]]}
olmocr_science_pdfs
2024-12-03
2024-12-03
ad81a403153f4f2d6b80ef1ec8243a72a9328947
Practicing Domain-Specific Languages: From Code to Models Laure Gonnord, Sébastien Mosser To cite this version: HAL Id: hal-01865448 https://hal.archives-ouvertes.fr/hal-01865448 Submitted on 31 Aug 2018 HAL is a multi-disciplinary open access archive for the deposit and dissemination of scientific research documents, whether they are published or not. The documents may come from teaching and research institutions in France or abroad, or from public or private research centers. L’archive ouverte pluridisciplinaire HAL, est destinée au dépôt et à la diffusion de documents scientifiques de niveau recherche, publiés ou non, émanant des établissements d’enseignement et de recherche français ou étrangers, des laboratoires publics ou privés. Practicing Domain-Specific Languages: From Code to Models Laure Gonnord Univ Lyon, Université Claude Bernard Lyon 1 LIP, CNRS, ENS de Lyon, Inria F-69342, LYON Cedex 07, France Laure.Gonnord@ens-lyon.fr Sébastien Mosser Université Côte d’Azur, CNRS, I3S, France Sophia Antipolis mosser@i3s.unice.fr ABSTRACT This paper describes our experience in constructing a new Domain-Specific Language course at the graduate level whose objectives is to reconcile concepts coming from Language Design as well as Modeling domains. We illustrate the course using the reactive systems application domain, which prevents us to fall back in a toy example pitfall. This paper describes the nine stages used to guide students through a journey starting at low-level C code to end with the usage of a language design workbench. This course was given as a graduate course available at Université Côte d’Azur (8 weeks, engineering-oriented) and École Normale Supérieure de Lyon (13 weeks, research-oriented). CCS CONCEPTS • Software and its engineering → Compilers; Designing software; Development frameworks and environments; KEYWORDS Software Modeling, Domain-Specific Languages, Code Generation, Code Abstraction, Reactive Systems ACM Reference Format: 1 INTRODUCTION The foundation of the course we propose is the observation that the numerous concepts behind “Language Design” and “Software Modeling” are difficult to apprehend for students. From the point of view of educators, numerous difficulties arise when we build on a new instance of each of these two courses. On the one hand, teaching language design (at both graduate or undergraduate level) is a necessary but painful task. Students struggle to understand why do they need to know how to design languages: writing a compiler (or an interpreter) is a tedious task, and the large number of existing programming languages ensure that at least one will implement the feature needed for a given purpose. In addition, this kind of courses are often implemented under the name “Compilation”, and usually focus on lexical analysis, attributed grammars or symbol resolution [1, 8], and forgets the most relevant parts, namely, abstractions and semantics. It is then hard to focus on the part related to Language Design when students are ensnared in a difficult (from a theoretical point of view) and technical (from a practical point of view) context. However, we defend that in addition to the underlying foundations related to this field, it is important for student to understand how to design a language. It will help them to create their own when relevant, but also help them to classify existing ones and support their choices. On the other hand, teaching modeling is also a necessary but painful task [5, 6]. We defend it as necessary considering that the essence of modeling is abstraction, i.e., the ability to remove unnecessary details from a complex situation. But finding the right way to teach modeling is complicated [2]. Students might struggle with complicated technological stacks, syntactical issues in the UML [7] and have difficulties to understand the differences between models and meta-models when applied to simple toy examples. We defend that software developers must be confronted to modeling during their studies to identify the strength of abstraction-driven approaches. Clearly, a “modeling for modeling” approach does not work, and the infamous “UML to Java” example [4] cannot reasonably be used in 2018 to support model-based courses. During a conference dedicated to software engineering and programming languages hosted in Besançon in 2016, the two authors met and exchanged the views described in the two previous paragraphs. During this discussion, it was clear that the main issue was to consider Software Language Engineering (SLE) and Model-driven Engineering (MDE) as two disjoint sets. We decided to leverage our experience in teaching languages and models to create a common syllabus for a course shared by École Normale Supérieure de Lyon (ENSL) and Université Côte d’Azur (UCA). This course uses the point of view of Domain-specific Languages (DSLs) to support the teaching of language design and abstraction, using a practical approach. We used as foundations a case study dedicated to embedded devices from a language point of view [3], coupled to our experience in teaching embedded systems from a reactive programming point of view. The goal of this paper is not to describe the syllabus of the course but to share the rationale of the course, with the description of a lab session that goes through multiple level of abstractions and different technological stacks. The paper is organized as follows: in Section 2 we depict the objectives we identified for this course, and the lab examples it is built on. In Section 3, we develop the objectives of each of the first steps of the "Minimal and Viable example", that illustrate different levels of abstractions, from code to models (of code). Then, in Section 4, we show alternative approaches working at the language design level to illustrate modeling concepts. Finally, the last section (Section 5) gives more information about how the course was implemented in both universities. 2 COURSE OVERVIEW The keystone of the pedagogical approach we follow is to use the predisposition of students to work with code to catch their curiosity and make them work on the concepts that drive this course: identifying abstractions to design languages. Considering DSLs as the object under study, the course we propose has then the following objectives: - O₁ Illustrate how to abstract code into models; - O₂ Identify how to operationalize models according to different targets (e.g., ease of development, intended users); - O₃ Study the relationships that exist between concepts and tools; - O₄ Acquire experience in modeling through hands-on lab sessions. The course is implemented in a “two-phases” fashion. The first phase relies on a minimal and viable lab example, developed in Section 3 and 4: the rationale of this phase is to discover and experiment the DSL main concepts in a guided way. The second phase consists in the creation of a complete language for a new domain in an unguided way. The approach we propose is entirely open source, with lightweight technology, and low cost embedded devices for the lab material. Thanks to this approach, the students progressively acquire the following knowledge and skills: - The definition and practical use of the following concepts: model, meta-model (and their synonyms in language theory: languages, grammars), and object-orientation and reflexivity; - A methodology to design a new language for a specific application domain: identify what is reusable, and what needs extensions, make rational implementation choices, test; - An experience in designing a real-life DSL, targeting a business-driven case study. Minimal & Viable Lab Example The lab example we propose is based on the Arduino open-source technology, and the use of some sensors and actuators: one 7-segment display, a button, a led per platform. The platform can be designed around a breadboard as in Fig. 1 or thanks to a pre-built Arduino shield (Fig. 2). An Arduino Uno micro-controller costs 20€. To build the breadboard version, one must buy small electronic hardware (a breadboard, a LED, a button and a display) for approximately 10€. The shield version is more expensive, as the shield can cost up to the price of the Arduino board according to vendors. A platform can be used by one group of up to four students, where two is the right team size based on our experience. In this lab, we propose a sequence of “stages”, each stage being built in the same “2-steps” way: (1) Students are given a minimal working example (switching the LED on and off) of the language/technology used in the stage. They experiment and begin to criticize the solution in terms of performance, readability, usage, … (2) Then, they modify the example in a non trivial way to transform it in a viable example, representative of the domain. We here propose to use a 7-segments display to count time and reset. This example is non trivial since it requires to introduce memory states. The two applications need to be composed on the very same board: pushing the button changes the LED state, and also reset the counter to 0. In the next two sections, we focus on the description of the nine stages identified in this minimal and viable example. The idea is to describe what we give to the students to kick-off the work for each stage, and the questions we use to drive the associated “step back” discussions and guide their report writing. 3 FROM CODE TO MODELS To prevent falling back in the toy example pitfall, we illustrate the course using the reactive systems application domain. This domain is pertinent since there is a long tradition in designing specialized languages and development processes for these kind of software, especially in the area of critical embedded systems. Here we choose a less ambitious subdomain, namely, programming a micro-controller reacting to tiny sensors and operating on actuators. However, the modeling and code issues that arise from this simplified case are representative and a good abstraction of the real one. This section illustrates both objectives O₁ and O₂ of the course. Indeed, the first three stages of the lab illustrate different levels of abstractions one can use while programming an Arduino-based reactive system. From these stages, we start discussions about tools and methods to gain abstraction in a piece of code (O₁) and also the pros and the cons of the different approaches according to --- 1https://en.wikipedia.org/wiki/Arduino # Listing 1: Minimal example: Plain C code ```c #include <avr/io.h> #include <util/delay.h> int main(void) { DDRB |= 0b00100000; PORTB ^= 0b00100000; _delay_ms(1000); return 0; } ``` # Listing 2: Minimal example: ArduinoLib code ```c #include <avr/io.h> #include <util/delay.h> #include <Arduino.h> int led = 13; int main(void) { pinMode(led, OUTPUT); while(1) { digitalWrite(led, HIGH); _delay_ms(1000); digitalWrite(led, LOW); _delay_ms(1000); } return 0; } ``` 3.1 Plain Code (C) The first stage uses C code working at the micro-controller registries level. We provide a running piece of code (Lst. 1), as well as the environment to compile it (thanks to avr-gcc) and upload the compiled image to the micro-controller (thanks to avr-dude) with a Makefile. The given code enables a LED plugged on pin 13 to blink forever at a frequency of 1Hz. At this low level of abstraction, accesses to sensors and actuators consist in injecting an electrical current in the micro-controller physical pins. At the code level, this is done thanks to parallel writes to ad-hoc registers called PORTx (x being B, C or D), that are configured with the help of the corresponding DDRx registers (input: 0 or output: 1). For instance, in Lst. 1 at line 5, we setup the LED plugged to pin 13 as an actuator by setting to 1 the 5th bit of the DDRB registry (the first 8 pins being handled by DDRA, 13 = 5 + 8). Then, thanks to an infinite loop, we switch it on and off with the help of a xor applied to the very same bit in the PORTB registry. Considering this piece of code, students are asked to answer to the following questions and invited to elaborate and argument their answers on paper: - What can we say about readability of this code? What are the skills required to write such a program? - Regarding the application domain, could you characterize the expressivity? The configurability of the code to change pins or behavior? Its debugging capabilities? - Regarding the performance of the output code, what kind of parallelism is expressed by the use of the DDRx registers? - What if we add additional tasks in the micro-controller code, with the same frequency? With a different frequency? 3.2 Using the Arduino Library (C) The second step uses the Arduino library\(^1\) which is a C++ library provided by the Arduino designers. This library provides higher-level access to each pin individually, for example to support configuration in write or read mode with a function called pinMode, or to control the electrical current sent to a given pin with a call to digitalWrite. The code given to students is depicted in Lst. 2. \(^1\)https://www.arduino.cc/reference/en/ This code is an iso-functional version of the one depicted in Listing 1, using the Arduino library. Based on the given example and the realization of the 7-segments counter, we ask students to discuss about the following questions in their report: - Is the readability problem solved? - What kind of parallelism can still be expressed? - Who is the public targeted by this "language"? - Is this language extensible enough to support new features? What is the price for the developer? 3.3 Programming a Finite State Machine (C) The two applications to be developed for the micro-controller helps students to identify the need for abstraction when targeting a specialized domain. They easily identify that the LED and 7-segments functionalities can be modeled thanks to a Finite State Machine (FSM). Before moving to a model-driven approach, we use in this stage a convention-based approach to reify abstractions at the code level. Considering a system where one can express transitions between states, it is possible to implement such an FSM using functions as states, and conditional instructions coupled to terminal function call for transitions (see Lst. 3). Using this abstraction, we raise the following questions to help students understand the importance of abstraction at the code level: - Does introducing a convention solve the readability issue? - How to extend an app with a new feature? Does the approach prevent one to perform invasive changes in the existing behavior to introduce a new one? - How to extend the code so that to support new features, e.g., memory-less tasks, state-full tasks, different frequencies? 3.4 Modeling an ArduinoApp (UML & Java) We use this stage to leverage the insights gained at the previous one, and emphasize the importance of working at the model level when dealing with abstractions. The idea here is to show firstly, that working with models free the user from the syntax, and secondly, that code generation mechanisms can be used to reach the previously defined operational target. Using a model-driven approach, it becomes clear to the students that the user is now restricted to the vocabulary available in the meta-model, and cannot deviate from it. It helps to position the meta-model as the abstract syntax of the language, defining what concepts needs to be exposed to the user. With respect to code generation, we show how the concepts defining the meta-model can be operationalized using classical object-oriented design patterns (e.g., Visitor, Observer) to reach an executable target. We provide to the students a minimal FSM meta-model, as depicted in Fig. 3. We also provide a running Java implementation of the meta-model and a simple Visitor implementation supporting naive code generation from a given model to C code (Lst. 4). We use the code manually written by the students during the previous stage to illustrate code templating and the underlying concepts associated to the Visitor design pattern. Based on their extension of this example to support the 7-segments counter, we ask the student to discuss the following questions: - What are the pros/cons associated to the meta-modeling approach? What is the cost of defining a meta-model? What is difficult in this activity? - From the user point of view, what does it change? Is the approach usable for large apps? - Consider the LED app and the counter one as two separate models. Is it possible to automate the creation of the final app based on these two models? - What about the readability of the generated code compared to the previous one “by hand”? Its debugging capabilities? Its extensiveness? - Explain the interest of modeling in terms of genericity, functional property verification. ### Listing 3: Minimal example: functional FSM ```c #include <avr/io.h> #include <util/delay.h> #include <Arduino.h> int led = 13; void state_on() { digitalWrite(led, HIGH); _delay_ms(1000); state_off(); } void state_off() { digitalWrite(led, LOW); _delay_ms(1000); state_on(); } int main(void) { pinMode(led, OUTPUT); state_on(); return 0; } ``` ### Figure 3: Minimal FSM meta-model ```java public class ToC extends Visitor<StringBuffer> { @Override public void visit(App app) { c("#include <avr/io.h>"); c("#include <util/delay.h>"); c("#include <Arduino.h>"); c(" void setup(){ for(Actuator a: app.getActuators()){a.accept(this); } for(State state: app.getStates()){h(String.format("void state_%s();", state.getName()));state.accept(this); } if (app.getInitial() != null) { int main(void) { setup(); state_%s(); return 0; } } @Override public void visit(Actuator actuator) { ... } @Override public void visit(State state) { ... } @Override public void visit(Action action) { ... } private void c(String s) { this.code.append(String.format("%s ",s)); } } ``` ### Listing 4: Simple FSM Visitor implementation - From the user point of view, what does it change? Is the approach usable for large apps? - Consider the LED app and the counter one as two separate models. Is it possible to automate the creation of the final app based on these two models? - What about the readability of the generated code compared to the previous one “by hand”? Its debugging capabilities? Its extensiveness? - Explain the interest of modeling in terms of genericity, functional property verification. #### 3.5 Remodeling an ArduinoApp (UML & Java) During the previous stage, students understand quickly that working with the meta-model defined in Fig. 3 is not suitable for large applications: the final FSM is the cartesian product of the two apps (led and counter). We offer them here two choices: - Creating a composition operator to support the combination of elementary applications to produce complex ones; - Switch to another kind of abstraction that will provide a better support for end-users. ### 3.6 Conclusions In this section we depicted how, from low-level Arduino code, where a single programming model is promoted, we abstracted the domain-specific features by modeling it in different ways. We also showed that the choice of the modeling paradigm has a substantial impact on the expressivity and extensibility of further developments. Thanks to a code-first approach and a journey through abstraction levels, we manage to lead the students to a point where they recognize the value of models, and see the benefits of using such artifacts. From now on, we will no longer change the abstraction level, but make a tour on different domain-specific language and meta-modeling paradigms that will permit to generate domain-specific code. ## 4 FROM MODELS TO DSLS Thanks to the previous stages, we are now working at the model level. The following stages explore how models relate with tools (O₁), and how such models and tools can target different users (O₂). Contrarily to the previous stages that were sequential, these stages are independent, as they address different paradigm in an hands-on fashion. ### 4.1 Integrating an existing DSL (LUSTRE) In Section 3 we ended up with the conclusion that using a reactive system representation was a suitable way to model the domain in a scalable way, avoid costly code generation, without sacrificing expressivity or end-user usage. As a consequence, now that we came with this new paradigm for modeling, why not searching for an existing (possibly domain-specific) language implementing reactive systems, so that to reuse it for our particular purpose? The Lustre⁴ synchronous language was intended to be used for the design of critical real-time embedded systems. However, some educational-driven experiences have been made for real-time programming courses⁵. This stage takes inspiration from them. The minimal code depicted in Lst. 7 illustrates the key feature of this DSL: only the functionality of the infinite loop is described, avoiding implementation details as well as non logical time. Here, the node describes the actuator “led on” as a boolean output whose value is false during the first period, then the negation of its value during the preceding period (pre(led on)) forever. The infinite loop depicted in Listing 8 (where ctx depicts the context, i.e., the current state) is compiled from this description (and the desired frequency). The user should also encode the glue code in a separate file. The compilation chain and its relationship with the application domain being depicted in Figure 5, the students are invited to argument their answers to the following questions: - Who is the intended user for such a language? - What is the cost of reusing this existing DSL for the developer in terms of code? - What is the cost of adding a new task of our domain? - Was the cost of adding a new hardware target? --- ⁵http://laure.gonnord.org/pro/teaching/5syTR1516_M1/tr_lustre.pdf Figure 4: Minimal reactive meta-model Figure 5: Lustre Compilation chain for Arduino Listing 8: Generated C code chain for Lustre ```c 1 // cpt.c - Generated void cpt_step(cpt_ctx* ctx){ //... cpt_O_led_on(...); } 6 // main.c - Generated int main(){ // ... while(1){ cpt_step(ctx); _delay_ms(1000); } return 1; } 11 //Glue code (Arduino target) - Hand written void cpt_O_led_on(void* cdata, _boolean _V) { if (_V == 1) digitalWrite(led, HIGH); else digitalWrite(led, LOW); } ``` - The Lustre language impose the memory to be bounded by construction. Is this a limitation for our (sub) domain? Listing 9: Minimal example: Reactive code using ANTLR App: Blinking led is an actuator bound to pin 13 producer: quartz emit "tick" at 1Hz consumer: blinker bool state initialized as true !state: led is HIGH state is !state blinker listens to quartz - The Lustre language comes with its own ecosystem (test, formal verification), what are the generic properties we can imagine to prove from our domain? 4.2 Designing an External DSL (ANTLR) The Lustre stage illustrates how to find and reuse an existing DSL that might fit a given purpose. In this stage, we ask the student to define a dedicated external language, reifying the domain concepts associated to their choice (FSM & composition or reactive system) directly in a dedicated syntax. We give to the student a kick-off implementation of an external grammar (using Antlr 6), and an evaluation of the Abstract Syntax Tree that produce an instance of the previously defined meta-model (as a Java object). We also provide a program conform to the defined syntax (Lst. 9), and the command line script to call the compiler and produce a reactive code associated to such a program. Based on their extension of the grammar to support the counter application, students are asked to discuss the following points: - Who is the intended user? What about the tooling associated to the language? 6http://www.antlr.org/ Listing 10: Embedding the DSL inside the Scala syntax ```scala object Switch extends ArduinoML { val button = declare aSensor() named "button" boundToPin 9 val led = declare anActuator() named "led" boundToPin 12 val on = state named "on" executing led --> high val off = state named "off" executing led --> low .isInitial transitions { on -> off when (button is high) off -> on when (button is high) } } ``` - More generally, what is the cost of such an approach? - To what extent is the language fragile to the introduction of new features? - What is the relationship between the meta-model and the grammar? - How to validate that the defined syntax is the right one? 4.3 Designing an Embedded DSL (e.g., Groovy) Considering the cost of defining an external language, we explore here how to embed abstractions in an existing language instead of creating a new one from scratch. At this stage, we let the students free to choose their technological stack, as we only provide a link to the embedded directory of the ArduinoML zoo of syntax\(^7\). The idea of the ArduinoML zoo is to provide alternative syntaxes (11 embedded ones and 4 externals, provided by 9 contributors) to the FSM meta-model described in the previous section. Students can then pick-up one familiar language example in the zoo, and implement the counter application using their favorite language. When a language is not present, students are encouraged to publish a pull-request on the GitHub repository to update the zoo. Often, students chose the Groovy language to support their work at this stage, considering the large amount of documentation available (and maybe biased by their previous knowledge of Java). Based on their work to adapt the ArduinoML example to the counter application, students are asked to discuss the following questions: - How to chose between embedded or external? - What is the impact of the host language choice? - What about the maintainability of the concrete syntax? - Who is targeted as an audience by this class of languages? 4.4 Using a Language Workbench (e.g., MPS) Considering the cost of designing an external language from scratch, and the intrinsic limitations of the embedded approach, we propose here to explore how dedicated workbenches can be used to model language. The key point here is to make students understand that language design is "simply" another domain, and that domain-specific tooling can be defined to support them, following the very same approach that they just use to support Arduino application designers. We chose the Meta Programming System\(^8\) (MPS) to support this step, and also provide a link to the Xtext\(^9\) version of the ArduinoML syntax for interested students. We give to the student a reference structure, and the associated projection to reach a concrete syntax (Fig. 6). Students can immediately use the generated environment and experiment code completion, syntax coloring, type constraints, which came for no additional costs. When the implementation of the counter app is finished, we ask to the students the following set of questions: - What is the cost/benefits ratio of using a workbench? - What are the limitations of such an approach? - What about vendor lock-in? 4.5 Conclusions In this section, we described four versions of the same language, using alternative modeling approach to support its implementation. First, reusing a dedicated language helped us to discuss the concept of domain scope and model integration (through glue code). Then, we explored three different ways to create new languages capturing domain abstractions. These different ways help us to discuss, among others, domain evolution, meta-modeling principles, and user relevance. 5 LOGISTICS & EVALUATION This course follows up a 5 years old course about Domain-specific languages taught at UCA. This new version is part of two different curricula: “Fundamental Computer Science” Master of Science at ENS and “Software Architecture” Master of Engineering at UCA. In Lyon, the format is 24 hours, supervised, including closely related lectures and labs (13 weeks, 4 credits). The course was attended by a small number of students which never attended any software engineering course, and are inexperienced in language design. However, they have a broad knowledge in semantics and program abstractions. At UCA, the course is classically attended by a large number of students (35), and lengths 8 weeks for 2 credits. The evaluation differs, as UCA values an engineering approach (thus evaluating a project) and ENSL is a research-oriented environment (half of the evaluation is made on a bibliographic study about DSLs, models and languages). We consider as a prerequisite basic notion of software development and modeling. 5.1 Case study examples for Phase #2 The nine different implementations of the reactive language are used in the course to support the first phase, where students explore in a guided way how to work with abstractions on a given domain. As educators, we guided their journey by providing reference code, and step back questions. The second phase of the course relies on the capture of a new domain, based on the experience learned during the first phase. We briefly describe here several cases studies used in the past to support DSLs and meta-modeling teaching. - Sensor simulation: create a language supporting the modeling of sensors to support load testing of data collection middleware. Students have to model sensors based on polynomial interpolations, Markov chains, replay from legacy \(^{7}\)https://github.com/mosser/ArduinoML-kernel/tree/master/embedded \(^{8}\)https://www.jetbrains.com/mps/ \(^{9}\)https://www.eclipse.org/Xtext/version dataset, and define an execution environment to send the simulated data to a time-series database (e.g., InfluxDb). - **Application deployment**: create a language to support the deployment of services in a distributed environment. Students have to capture what is a service, how services relate to each others, create a deployment plan and upload the different codes to the modeled topology in order to setup a running ecosystem. - **Scientific Workflow**: create a language to support the modeling of scientific workflows (e.g., grid computing data processing, machine learning workflow). Students have to capture concepts like data sources, sinks, processors, and data links to transfer data among processors. They must also reach an execution context that respect the expected semantics for data flows. ### 6 PERSPECTIVES The course is re-offered at UCA and ENSL for the next academic year. Discussions have started to implement it at Université du Québec à Montréal in the upcoming years at the graduate level. We plan to clean up the available material published on GitHub, which is for now scattered among several repositories (one instance per course and the ArduinoML zoo) into a single one. We also plan to start communicating about this course in the model-driven engineering and software-engineering communities to gather feedback from researchers and improve the lab contents. An in-depth evaluation of the course outcome is an ongoing work, as we plan to better evaluate this point in the new instances of the course. ### Acknowledgments Authors want to thanks the GdR GPL to support collaboration between researchers in France at the national level, which allow the creation of such inter-universities initiative. We also want to thanks Benoît Combemale for the fruitful discussions we had that helped to classify the different stages of the labs. ### REFERENCES
{"Source-Url": "https://hal.archives-ouvertes.fr/hal-01865448/file/edusymp18_GM._cr.pdf", "len_cl100k_base": 6856, "olmocr-version": "0.1.53", "pdf-total-pages": 9, "total-fallback-pages": 0, "total-input-tokens": 27110, "total-output-tokens": 8412, "length": "2e12", "weborganizer": {"__label__adult": 0.0007495880126953125, "__label__art_design": 0.0008597373962402344, "__label__crime_law": 0.0004851818084716797, "__label__education_jobs": 0.0243682861328125, "__label__entertainment": 0.00014019012451171875, "__label__fashion_beauty": 0.0003657341003417969, "__label__finance_business": 0.0003788471221923828, "__label__food_dining": 0.000812530517578125, "__label__games": 0.0009860992431640625, "__label__hardware": 0.0015850067138671875, "__label__health": 0.0008215904235839844, "__label__history": 0.0005326271057128906, "__label__home_hobbies": 0.0002732276916503906, "__label__industrial": 0.0009055137634277344, "__label__literature": 0.0007386207580566406, "__label__politics": 0.0005903244018554688, "__label__religion": 0.001178741455078125, "__label__science_tech": 0.01947021484375, "__label__social_life": 0.00033736228942871094, "__label__software": 0.003782272338867187, "__label__software_dev": 0.93798828125, "__label__sports_fitness": 0.0006284713745117188, "__label__transportation": 0.001495361328125, "__label__travel": 0.0003862380981445313}, "weborganizer_max": "__label__software_dev", "avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_ratio": [[0, 34599, 0.03162]], "fineweb_edu_fasttext_gt2__fineweb_edu_fasttext_gt2__score": [[0, 34599, 0.58594]], "ft_lang_id_en_doc_v2__ft_lang_id_en_doc_v2__en": [[0, 34599, 0.88909]], "google_gemma-3-12b-it_contains_pii": [[0, 960, false], [960, 6371, null], [6371, 11057, null], [11057, 16169, null], [16169, 19832, null], [19832, 22952, null], [22952, 24987, null], [24987, 30742, null], [30742, 34599, null]], "google_gemma-3-12b-it_is_public_document": [[0, 960, true], [960, 6371, null], [6371, 11057, null], [11057, 16169, null], [16169, 19832, null], [19832, 22952, null], [22952, 24987, null], [24987, 30742, null], [30742, 34599, null]], "google_gemma-3-4b-it_v2tag__is_academic_paper": [[0, 5000, true], [5000, 34599, null]], "google_gemma-3-4b-it_v2tag__is_class_syllabus": [[0, 5000, true], [5000, 34599, null]], "google_gemma-3-4b-it_v2tag__is_completion_certificate": [[0, 5000, false], [5000, 34599, null]], "google_gemma-3-4b-it_v2tag__is_court_notice": [[0, 5000, false], [5000, 34599, null]], "google_gemma-3-4b-it_v2tag__is_homework_assignment": [[0, 5000, false], [5000, 34599, null]], "google_gemma-3-4b-it_v2tag__is_news_article": [[0, 5000, false], [5000, 34599, null]], "google_gemma-3-4b-it_v2tag__is_public_order": [[0, 5000, false], [5000, 34599, null]], "google_gemma-3-4b-it_v2tag__is_resume_cv": [[0, 5000, false], [5000, 34599, null]], "google_gemma-3-4b-it_v2tag__is_test_or_quiz": [[0, 5000, false], [5000, 34599, null]], "google_gemma-3-4b-it_v2tag__is_textbook": [[0, 5000, false], [5000, 34599, null]], "pdf_page_numbers": [[0, 960, 1], [960, 6371, 2], [6371, 11057, 3], [11057, 16169, 4], [16169, 19832, 5], [19832, 22952, 6], [22952, 24987, 7], [24987, 30742, 8], [30742, 34599, 9]], "pipe_delimited_lines_v1__pipe_delimited_lines_v1__pipe_delimited_lines_ratio": [[0, 34599, 0.0]]}
olmocr_science_pdfs
2024-12-09
2024-12-09
c5be41dd563957018005d799088f69442881d769
How to cite: Learning to Share: Engineering Adaptive Decision-Support for Online Social Networks *Imperial College London, UK: {y.rafiq, a.ruosso}@imperial.ac.uk †University College London, UK: {l.dickens}@ucl.ac.uk ‡The Open University, UK: {a.k.bandara, b.aprice, b.nuseibeh}@open.ac.uk §University of Exeter, UK: {a.stuart, m.levine}@exeter.ac.uk ¶Lero, University of Limerick, Ireland, UK: {bashar.nuseibeh}@lero.ie ∥University of Southampton, UK: {Mu.Yang}@soton.ac.uk **Chalmers & University of Gothenburg, Sweden: {gul.calikli}@gu.se Abstract—Some online social networks (OSNs) allow users to define friendship-groups as reusable shortcuts for sharing information with multiple contacts. Posting exclusively to a friendship-group gives some privacy control, while supporting communication with (and within) this group. However, recipients of such posts may want to reuse content for their own social advantage, and can bypass existing controls by copy-pasting into a new post; this cross-posting poses privacy risks. This paper presents a learning to share approach that enables the incorporation of more nuanced privacy controls into OSNs. Specifically, we propose a reusable, adaptive software architecture that uses rigorous runtime analysis to help OSN users to make informed decisions about suitable audiences for their posts. This is achieved by supporting dynamic formation of recipient-groups that benefit social interactions while reducing privacy risks. We exemplify the use of our approach in the context of Facebook. I. INTRODUCTION Online Social networks (OSNs) are increasingly used to maintain social ties with family members, friends, and colleagues, and build new social relationships (e.g., [1]–[3]). However, these benefits come with an increased risk of privacy violation from oversharing or underusing privacy controls [4]–[8]. Many OSN platforms currently support privacy management through features such as static (user-defined) friendship groups as reusable shortcuts for sharing a single post with multiple contacts. Users can select the group they deem most appropriate when posting a message. In OSNs such as Facebook, LinkedIn and Google+, users may perceive posting in closed group as a quick fix to their privacy concerns, since these OSNs can constrain the re-sharing to only those contacts who have received the original message. However, these privacy control mechanisms do not account for cross-posting, i.e. when a contact copy-and-pastes the original message into a new post, and sends it to contacts outside the original group, to either improve their own social capital or damage that of the original user [9]. We argue that privacy in OSNs cannot be effectively delivered by inflexible and rarely-visited privacy settings, instead contact lists should be formed dynamically per post, such that unwanted cross-posting is minimized while the user’s social benefit is optimised. In this paper, we propose an adaptive privacy control approach, called learning to share, that enables software engineers/developers to incorporate adaptive privacy decision support into OSN applications. Specifically, we propose a software architecture that supports continuous monitoring of online interactions between each user-contact pair in a user’s social network, to predict three categories of contacts: those who are most likely to pose a privacy breach (i.e. risky friends); those who are socially inactive but privacy aware (i.e., safe friends); and those who are both socially active and privacy aware (i.e., super friends). The prediction is based on an interaction model of sharing behaviours, which is updated on-line in response to monitored behaviour and used to evaluate social benefit and privacy risk of sharing a post with each potential recipient. The outcome of the classification is used by the decision support component of the architecture to dynamically form contacts lists per post, and allows the user to efficiently select the recipient group on a per post basis. The underlying OSN infrastructure can take into account the informed selection by the user and dynamically control who should be receiving which message when delivering the post. Our proposed software architecture is not specific to a particular OSN environment. Software engineers working on developing and/or improving existing OSN applications with adaptive privacy decision mechanisms, can use our proposed architecture by deploying its automated learning and decision support capabilities, and integrating an Abstract Interaction Model and a wrapper for monitoring the type of social interactions that are specific to the particular OSN application. The rest of the paper is organized as follows. Section II presents a motivating example within the context of Facebook. Section III describes our Learning to Share architecture. Section IV exemplifies how OSN behaviours can be modelled as parametric Markov model, using the example of Facebook; introduces the related component for monitoring social network activities, and presents the online learning algorithm used to predict the model’s parameters. Section V describes the computation of social benefit and privacy risk used by the decision support component. Section VI discusses related work and concludes the paper with a summary and future work. II. MOTIVATING EXAMPLE Here, we illustrate the need for adaptive privacy control with a motivating example based on Facebook use. Facebook user Bob shares sensitive post A with his predefined close_friends group, which does not include Ann — Bob’s work colleague but not a close friend. As Ann is not a member of the close_friends group, Facebook does not allow her to see Bob’s post, and members of close_friends are unable to re-share the post with her. Tom, a member of Bob’s close_friends group, is also a close friend of Ann, but is unaware of this privacy aspect of Facebook’s group sharing. When Tom receives the post A, he naively decides to copy and paste the content into a new post, B, adding some content of his own, and shares B with a group of contacts which includes Ann. Now Ann can see, via cross-posting, what Bob shared in post A, but Facebook is unable to detect this or notify Bob that his on-line close friend Tom has violated his privacy, albeit unintentionally. This shows that, while customised social network groups are convenient for posting to multiple recipients and (in Facebook at least) offering a form of privacy control, this static feature can easily be bypassed, even fairly innocently. Good adaptive privacy control would, instead, monitor Tom’s actions, detect the similarity between posts A and B, and use this information to learn that sending sensitive posts to Tom represents a privacy risk, presenting this information to Bob the next time he intends to share another sensitive post with close friends. III. PRIVACY AWARE SHARING ARCHITECTURE Our proposed learning to share approach is implemented as a reusable, adaptive software architecture as shown in Figure 2. The architecture comprises two main modules: i) modelling and monitoring (marked C2), and ii) adaptive decision support (marked C3). This design enables software engineers working on OSN applications to deploy our architecture by reusing the automated learning and decision support capabilities and developing just two components: the abstract interaction model for the specific OSN application and a wrapper, which enables monitoring of the application specific social network interactions, and execution of sharing decisions. The OSN wrapper implements the monitor functionality to detect for each recipient of each post subsequent interactions between user and recipient, e.g., resulting likes and comments on Facebook. Monitored events are used by the Learning Engine component, which updates the parameters of the associated instantiated interaction model, called Concrete Interaction Models, essentially capturing the probability of each possible social interaction at each post’s sensitivity level. The concrete interaction model is then queried by the Decision Support System (DSS) to assess sharing decisions. Specifically, the DSS employs the concrete interaction model, a risk averseness threshold and a post’s sensitivity level to evaluate the re-share risk and social benefit and to classify (at run-time) each of user’s contacts as super, safe or risky. Sensitivity levels of shared posts are defined by the user and stored, together with the post, to check for future re-shares of the post. By providing just the wrapper and an abstract interaction model, learning to share can be deployed for different OSNs either as a fully integrated feature of an OSN’s infrastructure (i.e. total view mode), or as a plugin application of an existing OSN infrastructure (i.e. partial view mode). In the first case, the adaptive privacy control benefits from full access to the OSN’s global network community and the monitoring of online social behaviour of all members in the network. Whereas, partial view mode only provides adaptive privacy control and monitoring of users of the plugin application. IV. MODELLING AND MONITORING RUNTIME ACTIVITY This section describes the modelling module of our architecture as a parametric Markov model, illustrating it with an example of an abstract interaction model for Facebook. It also presents our online learning method for updating the model’s parameters and a method for monitoring social interaction events, used for computing the updates. A. Quantitative Verification of Markov Chains Online social interactions can be modelled using parametric Markov chains (PMC). These are defined as follows: **Definition 4.1:** A reward-annotated finite state discrete-time parametric Markov chain (PMC), $M$, is the tuple Let \(< S, s_0, \mathcal{V}, \mathbf{P}, \mathcal{L}, L >\), with \(S\) a finite set of states and initial state \(s_0 \in S; \mathcal{V}\) a set of real-valued parameters; \(\mathbf{P}\) a parametric transition probability \(|S| \times |S|-\text{matrix}\) whose elements are functions of \(\mathcal{V}\); the reward function \(\nu: S \rightarrow \mathbb{R}_{\geq 0}\) assigning a non-negative reward for each state, and labelling function \(L: S \rightarrow 2^{\mathcal{AP}}\) assigning a set of atomic propositions to each state. The \((i,j)\)th element of \(\mathbf{P}, p_{ij}\), is a function of parameters \(\mathcal{V}\) (written \(p_{ij} \in \mathcal{F}_\mathcal{V}\)) and represents the probability of transitioning from \(s_i\) to \(s_j\); \(p_{ij}\) takes values strictly in \([0, 1]\) and \(\sum_j p_{ij} = 1\) for all \(i\). Probabilistic model checker PRISM\(^1\) \((12)\) allows PMCs to be expressed in a high-level language, and efficiently evaluates queries expressed in a reward-enhanced version of probabilistic computational tree logic (PCTL) \((13)\). We use PRISM’s reward query operator \(R_{[\Phi]}\) in conjunction with the reachability reward property \(\Phi = [F a]\), to evaluate the average reward accumulated along a path until a state satisfying proposition \(a \in AP\) is reached (for PCTL semantics see \((14)\)). When queried with a PMC, PRISM’s reward query operator produces a symbolic expression, \(V \in \mathcal{F}_\mathcal{V}\), of the associated reward property (a function of \(\mathcal{V}\)). In what follows we describe how we use this functionality to predict expected social benefit and privacy risk in the context of Facebook. ### B. Modelling Sharing Behaviours We describe here our PMC model for Facebook. It captures the online social interactions between a user and contact, \(c\), following the user’s post. The first model, \(\mathcal{M}_c\) (see Fig. 3) captures comments and likes from both contact \(c\) and the user following some post. This behaviour is assumed to be independent of a post’s sensitivity (as discussed later). States in \(\mathcal{M}_c\) are: \(s_1, s_2, s_3\) and \(s_4\) respectively representing likes by \(c\) and user, and comments by \(c\) and user; initial state \(s_0\); terminal state \(s_{\text{end}}\); and \(s_6\) (which simply improves readability). Symbolic parameters in \(\mathcal{M}_c\) are \(p_1, p_2, p_3, p_4 \in [0, 1]\) and \(r_1, r_2, r_3, r_4 > 0\). Associated transition probabilities, rewards and propositional labels are shown in the figure. For example, if \(\mathcal{M}_c\) is in state \(s_0\), then \(p_1\) is the probability that the next reaction is a like by \(c\) and, given any of the four reactions, the system returns to \(s_0\) with certainty. There are 5 remaining models, \(\mathcal{M}_{c,l}\) (see Fig. 4), one per sensitivity level \(l \in \{0, 1, 2, 3, 4\}\), which capture the reshare behaviour of the contact in response to a post at sensitivity \(l\). States in \(\mathcal{M}_{c,l}\) are: initial state \(s_0\); terminal state \(s_{\text{end}}\); and \(s_5\) representing a reshare by \(c\). \(\mathcal{M}_{c,l}\) has two symbolic parameters \(q_l \in [0, 1]\) and \(r_5 \geq 0\). Again, transition probabilities, rewards and labels are shown in the figure. In an example execution of \(\mathcal{M}_{c,l}\) from state \(s_0\), \(q_l\) is the probability that a \(c\) reshares, and this can happen at most once. We wish to estimate the social benefit of all reactions which follow the user sharing a post at sensitivity \(l\) with \(c\), and equate this with the total reward accumulated over the lifetime of the parallel execution of \(\mathcal{M}_c\) and \(\mathcal{M}_{c,l}\). This corresponds to the sum of the expressions returned by PRISM when \(R_{[F_{\text{end}}}\) is invoked on each model. These queries can be invoked once at design time and respectively give: \[ V_c^1 = \frac{\sum_{i=1}^4 p_{i1}}{1 - \sum_{i=1}^4 p_{i1}} \tag{1} \] \[ V_{c,l}^2 = qr_5 \tag{2} \] We discuss the use of these expressions in Section 5-A. --- \(^1\)Similar model checkers include MRMC \((10)\) and Ymer \((11)\). --- Fig. 3: PMC model of online social interactions between a Facebook user and their post recipient \(c\). Fig. 4: PMC model capturing the re-sharing behaviour of a recipient \(c\) for posts received with sensitivity level \(l\). ### C. Online Learning of Sharing Behaviour PMC modelling and analysis, like that described above, is conventionally used for offline analysis of system properties \((15), (16)\). We instead apply these techniques at runtime updating our PMC parameters in light of observed interactions. We must, however, consider two complicating factors. First, \(c\)’s behaviour may change with time, and so we use a variant of the adaptive Bayesian learning algorithm from \((17)\). Secondly, we can never observe when the user-contact pair stop interacting on a given post. To address this, we account for unobserved transitions to terminal states, \(s_{\text{end}}\), by noting that each execution must eventually make this transition, and constructing a synthetic observation to the \(\text{end}\) state for every shared post with the same time-stamp as the original share. Here, we describe how transition probabilities \(p_{ij}\) of a PMC can be learned when the analysed system is operational, and its state transitions monitored (for Facebook these correspond to the monitored events, such as comments, likes, share and re-share). More formally, suppose that, we have observed \(K > 0\) transitions out of \(s_i \in S\) and that the \(k\)-th such transition \(1 \leq k \leq K\), is to state \(s_j \in S\), we define \[ \sigma_{ij}^k = \begin{cases} 1 & \text{if } j_k = j \\ 0 & \text{otherwise} \end{cases} \tag{3} \] and estimate probability of a state transition from $s_i$ to $s_j$ as $$p_{ij}^K = \frac{c_{ij}^0}{c_{ij}^0 + K f_{ij}^K + q_{ij}^0 + g_{ij}^K}$$ (4) where $p_{ij}^0$ is the prior for $p_{ij}^K$, $c_{ij}^0 > 0$ quantifies our confidence, $f_{ij}^0 = \sigma_{ij}^0$, $g_{ij}^0 = 1$, and for $K > 1$, $f_{ij}^K$ and $g_{ij}^K$ are defined recursively as: $$f_{ij}^K = \alpha^{-(t_K - t_{K-1})} f_{ij}^{K-1} + \sigma_{ij}^K$$ $$g_{ij}^K = \alpha^{-(t_K - t_{K-1})} g_{ij}^{K-1} + 1$$ Here, $t_K$ represents the timestamp of the $K$-th observation, and $\alpha \geq 1$ is an ageing parameter (see [17] for a full description and proof). These probability estimates have two key features: older observations are downweighted, allowing rapid adaptation to changes in $p_{ij}$; and the recursive form means storage and computation complexity are both in $O(1)$. D. Interaction Monitoring The Monitor component detects events that are being tracked by our behavioural models (see Section IV-B). In order to detect cross-posting based on a post’s modality (e.g., text, image, audio or video), the Monitor component, state-of-the-art information retrieval techniques [18] can be implemented as a pluggable module to measure the similarity between posts sent to $c$, and posts $c$ subsequently shares with others. Posts that exceed some similarity threshold (e.g., [19]) can be treated as cross-posts and the Learning Engine notified. Such a task is becoming feasible recently with the advance of high performance hardware and also information retrieval techniques [19]–[25]. V. DECISION SUPPORT SYSTEM In this section, we present the technical details of our decision support system (DSS) that elicits and models the sharing preferences of the user, and informs the user of any sharing decisions that represent significant benefits or exceed certain risk thresholds derived from these preferences. Section V-A and Section V-B formally define the social benefit and privacy risk models, and Section V-C describes how we initialise the parameters associated with these models. Finally, in Section V-D we discuss the mechanisms for the user to adjust the parameters of the privacy risk model, based on continual feedback about the working system from the user. A. Social Benefit The DSS estimates the social-benefit a user expects to gain when sharing a post with contact, $c$, from the Concrete Interaction Models, described in Section IV-B. For our Facebook example, this is captured by models $\mathcal{M}^1_c$ and $\mathcal{M}^2_c$. These two models attribute socially-beneficial rewards to relevant social events: reshares (of non-sensitive posts), comments and likes by contact $c$; and comments and likes in response by the user. A user may value each event differently, but for simplicity we assign a fixed value to each event type. As discussed in Section IV, the expected social-benefit for sharing a post with at sensitivity $l$ with contact $c$, is the expected total reward accumulated over the lifetime of the parallel computation of models $\mathcal{M}^1_c$ and $\mathcal{M}^2_c$, and is given by $$B_{c,l} = V^1_{c,l} + V^2_{c,l} = \sum_{i=1}^4 p_i r_i + q r_5$$ (5) For each potential sharing decision, the expected social benefit, $B_{c,l}$, is compared to a threshold, $\hat{B}$, set for the user. If it exceeds that threshold, $B_{c,l} > \hat{B}$, then the user is notified by placing contact $c$ in the super friends list. If a different behavioural model were implemented, then the above expression would need to be updated appropriately. While a variety of choices could be made about rewards in our Facebook model, we suggest the following simple, intuitive choice. Without loss of generality, a contact’s comment is given a unitary reward, i.e. $r_3 = 1$. Other rewards $r_1 = \frac{1}{2}$, $r_2 = \frac{1}{2}$, $r_4 = \frac{1}{2}$ and $r_5 = 1$ are based on a small study where participants were given a questionnaire about expected levels of interaction following a Facebook post. B. Privacy Risk The DSS also estimates privacy risk – a numerical value of undesirability related to risky decisions. By definition, sharing any post at sensitivity $l = 0$ carries no risk (reshares are desired). Sharing at higher sensitivity $l > 0$ with a contact $c$ who has reshare probability $q_{c,l}$, is considered a risky decision with associated risk $$R_{c,l} = b \log_2(q_{c,l}) + a_l$$ (6) where $2^{a_l}$ is the damage value associated with a privacy breach (a known reshare) at sensitivity level $l$, and $b > 0$ controls how risk averse the user is (their risk posture). When the user considers sharing a post of sensitivity $l$ with $c$, the associated risk, $R_{c,l}$, is compared to the user’s risk-threshold, $\hat{R}$. The DSS warns the user if $R_{c,l} > \hat{R}$ by placing contact $c$ into the risky list for that post. We define 5 sensitivity levels $l = 0, 1, 2, 3, 4$. For $l > 0$, $a_l = l$ meaning a privacy breach at sensitivity $l$ is half as damaging as one at $l^\prime = l + 1$ ($l = 0$ means no risk). Risk posture, $b$, is set so $R_{c,l}$ values, as closely as possible, reflect a user’s preferences over risky decisions. Risk appetite, $\hat{R}$, represents the user’s maximum acceptable risk. These parameters are given initial values based on user input (Section V-C), then adjusted at runtime by the user (Section V-D). C. Initialising Decision Support Parameters As indicated, initial values for social benefit threshold, $\hat{B}$, risk-posture, $b$, and risk-threshold, $\hat{R}$, are elicited from users via a short, non-technical questionnaire, where they consider outcomes in three sharing scenarios. However, as a user may not feel able to respond to one or more questions, we provide null response options for each scenario, and generate default values based on previous responses. \footnote{The questionnaire can be found at bit.ly/2x4Fqqs} The social-benefit threshold, $\hat{B}$ aims to identify contacts who (on average) exceed a user’s expected level of social engagement. We quantify this as the expected number of likes, $N_l$, and comments, $N_c$, in response to a typical post from the user to 10 recipients, and use this to predict the expected social reward per person as: $$\hat{B} = 0.1 \cdot (N_c + 0.5N_l)$$ (7) The risk-posture, $b$, controls how the probability of a privacy breach affects the associated risk. Values of $0 < b < 1$ model risk-averseness, $b = 1$ models risk-neutrality and $b > 1$ models risk-seeking behaviour. We elicit, $b$, indirectly from the user in terms of what we call the trade-probability, $q$ – the probability at which the user would trade exposure to two simultaneous privacy breaches for a guaranteed privacy breach, where all such privacy breaches are considered equally damaging. Risk posture is then calculated as: $$b = \frac{-1}{\log_2(q)}$$ (8) The risk-threshold, $\bar{R} < 0$ (in conjunction with $b$) controls the regularity of warnings in the DSS. This value is again indirectly elicited, this time via the sensitivity 1 trigger probability, $\bar{q}_1$ – the lowest probability of reshare for which the user would liked to be warned. The risk threshold is then calculated as: $$\bar{R} = a_1 + b \log_2(\bar{q}_1) = b \log_2(\bar{q}_1)$$ (9) Trigger probabilities at other sensitivity levels ($l > 0$) can then be calculated as: $q_l = \frac{\bar{R} - a_l}{b}. D. Adjusting Decision Support Parameters To provide additional user control over decision support, and to allow for poorly initialised values to be corrected for, we provide a mechanism to adjust risk-posture, $b$, and risk-threshold, $\bar{R}$, based on repeated contemporaneous judgements of the working system. Adjusting $\bar{R}$: The lowest relevant sensitivity level, $l = 1$, has a maximum associated reshare risk of 0 (see Equation (6)). Therefore $\bar{R}$ must be strictly negative, $\bar{R} < 0$. Otherwise, the user would never be warned at $l = 1$. We therefore propose multiplicative step adjustments to $\bar{R}$ with a fixed factor $\eta > 1$ to lower $\bar{R}$, and $\eta^{-1}$ to raise it. More precisely, if the user indicates that they have too many warnings, then we increase the threshold with: $\bar{R} \leftarrow \eta^{-1}\bar{R}$, which increases $\bar{q}_1$ for all $l \geq 1$. Conversely, if the user indicates they are getting too few warnings then we reduce the threshold with: $\bar{R} \leftarrow \eta\bar{R}$. Adjusting $b$: The risk-posture is also strictly positive, i.e. $b > 0$, so we again propose multiplicative changes by a new step factor, $\zeta > 1$. In our system, an increased risk-posture corresponds to a greater differentiation between sensitivity levels and vice versa. Therefore, the user can increase differentiation between sensitivity levels with an incremental increase in risk-averseness, effected with: $b \leftarrow \zeta b$. Similarly, a user can decrease this differentiation by decreasing risk-averseness, effected with: $b \leftarrow \zeta^{-1} b$. However, to ensure the baseline trigger probability $\bar{q}_1$ remains unchanged, we also adjust the privacy threshold. So an increase in risk-averseness is accompanied by a reduction to the risk-threshold of: $\bar{R} \leftarrow \zeta R \bar{R}$. Similarly, decrease in risk-averseness is accompanied by an increase to the risk-threshold of: $\bar{R} \leftarrow \zeta^{-1} \bar{R}$. With these tools the user can incrementally shape the DSS system to suit their privacy preferences. VI. RELATED WORK, CONCLUSION AND FUTURE WORK A considerable body of research has been devoted to address the information sharing problem raised by the increasing number of privacy incidents and regrets happening in OSNs [8]. However, these approaches do not consider the situation when users may have made poor sharing decisions in the past. Whereas, Machine learning and statistical inference approaches like [35]–[40] study information diffusion in OSNs in order to predict the temporal dynamics of the diffusion process. A very recent work [41] uses Inductive logic programming to build a formal model that learns users’ dynamic social identities at runtime in order to analyse group processes and intergroup relations in OSNs. This paper presents a learning to share approach that enables software engineers/developers to readily add adaptive decision support to social network applications, such that the user has fine grained, informed control over their privacy settings. This allows users to maximise their social benefit, whilst controlling risk of privacy breaches to levels they find personally acceptable. We show how our approach can be used in the context of Facebook as the selected OSN platform. However the approach is applicable to other OSNs such as LinkedIn and Google+. This approach could also be readily extended to provide privacy control for a broader family of online interactions, such as undesirable cross-posting behaviours in social question answering services (e.g., StackOverflow) [42]. As for future work, we plan to conduct an online questionnaire in which users are asked to consider outcomes of their online sharing, based on scenarios discussed in Section VI. This will help us to initialise the parameters of the DSS with realistic values. This will be followed by a user study to help us evaluate the feasibility of our approach from users’ perspective within the context of Facebook. For this purpose, a Facebook plug-in has been implemented and we are at the stage of designing and conducting the user study. Finally we will organise a workshop with OSN developers and present our learning to share architecture, implemented as Facebook plugin and the user study results. During this workshop we will collect qualitative feedback from developers and elicit their tendency towards integrating our approach as a privacy management for OSNs. ACKNOWLEDGMENT We would like to thank EPSRC, SFI and the ERC for their financial support.
{"Source-Url": "http://oro.open.ac.uk/51741/7/51741_ASE_paper.pdf", "len_cl100k_base": 6523, "olmocr-version": "0.1.53", "pdf-total-pages": 7, "total-fallback-pages": 0, "total-input-tokens": 26417, "total-output-tokens": 7184, "length": "2e12", "weborganizer": {"__label__adult": 0.0003709793090820313, "__label__art_design": 0.0003943443298339844, "__label__crime_law": 0.00044608116149902344, "__label__education_jobs": 0.001868247985839844, "__label__entertainment": 0.00012028217315673828, "__label__fashion_beauty": 0.0001996755599975586, "__label__finance_business": 0.0005307197570800781, "__label__food_dining": 0.00043272972106933594, "__label__games": 0.0007562637329101562, "__label__hardware": 0.00070953369140625, "__label__health": 0.0008025169372558594, "__label__history": 0.00026106834411621094, "__label__home_hobbies": 0.00012600421905517578, "__label__industrial": 0.0003540515899658203, "__label__literature": 0.0003809928894042969, "__label__politics": 0.00039005279541015625, "__label__religion": 0.0003311634063720703, "__label__science_tech": 0.08880615234375, "__label__social_life": 0.00038504600524902344, "__label__software": 0.03216552734375, "__label__software_dev": 0.869140625, "__label__sports_fitness": 0.0002644062042236328, "__label__transportation": 0.0003979206085205078, "__label__travel": 0.0002233982086181641}, "weborganizer_max": "__label__software_dev", "avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_ratio": [[0, 28107, 0.03162]], "fineweb_edu_fasttext_gt2__fineweb_edu_fasttext_gt2__score": [[0, 28107, 0.27167]], "ft_lang_id_en_doc_v2__ft_lang_id_en_doc_v2__en": [[0, 28107, 0.88588]], "google_gemma-3-12b-it_contains_pii": [[0, 373, false], [373, 5740, null], [5740, 10342, null], [10342, 16131, null], [16131, 22042, null], [22042, 28107, null], [28107, 28107, null]], "google_gemma-3-12b-it_is_public_document": [[0, 373, true], [373, 5740, null], [5740, 10342, null], [10342, 16131, null], [16131, 22042, null], [22042, 28107, null], [28107, 28107, null]], "google_gemma-3-4b-it_v2tag__is_academic_paper": [[0, 5000, true], [5000, 28107, null]], "google_gemma-3-4b-it_v2tag__is_class_syllabus": [[0, 5000, false], [5000, 28107, null]], "google_gemma-3-4b-it_v2tag__is_completion_certificate": [[0, 5000, false], [5000, 28107, null]], "google_gemma-3-4b-it_v2tag__is_court_notice": [[0, 5000, false], [5000, 28107, null]], "google_gemma-3-4b-it_v2tag__is_homework_assignment": [[0, 5000, false], [5000, 28107, null]], "google_gemma-3-4b-it_v2tag__is_news_article": [[0, 5000, false], [5000, 28107, null]], "google_gemma-3-4b-it_v2tag__is_public_order": [[0, 5000, false], [5000, 28107, null]], "google_gemma-3-4b-it_v2tag__is_resume_cv": [[0, 5000, false], [5000, 28107, null]], "google_gemma-3-4b-it_v2tag__is_test_or_quiz": [[0, 5000, false], [5000, 28107, null]], "google_gemma-3-4b-it_v2tag__is_textbook": [[0, 5000, false], [5000, 28107, null]], "pdf_page_numbers": [[0, 373, 1], [373, 5740, 2], [5740, 10342, 3], [10342, 16131, 4], [16131, 22042, 5], [22042, 28107, 6], [28107, 28107, 7]], "pipe_delimited_lines_v1__pipe_delimited_lines_v1__pipe_delimited_lines_ratio": [[0, 28107, 0.0]]}
olmocr_science_pdfs
2024-12-11
2024-12-11
5404f5d0b1357e4526b137089db8d7debbc2a9da
FlinkMan: Anomaly Detection in Manufacturing Equipment with Apache Flink: Grand Challenge Yann Busnel, Nicolo Riveei, Avigdor Gal To cite this version: HAL Id: hal-01644417 https://hal.archives-ouvertes.fr/hal-01644417 Submitted on 22 Nov 2017 HAL is a multi-disciplinary open access archive for the deposit and dissemination of scientific research documents, whether they are published or not. The documents may come from teaching and research institutions in France or abroad, or from public or private research centers. L’archive ouverte pluridisciplinaire HAL, est destinée au dépôt et à la diffusion de documents scientifiques de niveau recherche, publiés ou non, émanant des établissements d’enseignement et de recherche français ou étrangers, des laboratoires publics ou privés. Grand Challenge: FlinkMan – Anomaly Detection in Manufacturing Equipment with Apache Flink Nicolo Rivetti Technion - Israel Institute of Technology nrivetti@technion.ac.il Yann Busnel IMT Atlantique / IRISA / UBL yann.busnel@imt-atlantique.fr Avigdor Gal Technion - Israel Institute of Technology avigal@technion.ac.il ABSTRACT We present a (soft) real-time event-based anomaly detection application for manufacturing equipment, built on top of the general purpose stream processing framework Apache Flink. The anomaly detection involves multiple CPUs and/or memory intensive tasks, such as clustering on large time-based window and parsing input data in RDF-format. The main goal is to reduce end-to-end latencies, while handling high input throughput and still provide exact results. Given a truly distributed setting, this challenge also entails careful task and/or data parallelization and balancing. We propose FlinkMan, a system that offers a generic and efficient solution, which maximizes the usage of available cores and balances the load among them. We illustrate the accuracy and efficiency of FlinkMan, over a 3-step pipelined data stream analysis, that includes clustering, modeling and querying. CCS CONCEPTS • Information systems → Stream management; • Theory of computation → Distributed algorithms; Unsupervised learning and clustering; KEYWORDS Anomaly Detection, Stream Processing, Clustering, Markov Chains, Linked-Data 1 INTRODUCTION Stream processing management system (SPMS) and/or Complex Event Processing (CEP) systems gain momentum in performing analytics on continuous data streams. Their ability to achieve sub-second latencies, coupled with their scalability, makes them the preferred choice for many big data companies. Supporting this trend, since 2011, the ACM International Conference on Distributed Event-based Systems (DEBS) launched the Grand Challenge series to increase the focus on these systems as well as provide common benchmarks to evaluate and compare them. The ACM DEBS 2017 Grand Challenge focuses on (soft) real-time anomaly detection in manufacturing equipment [4]. To handle continuous monitoring, each machine is fitted with a vast array of sensors, either digital or analog. These sensors provide periodic measurements, which are sent to a monitoring base station. The latter receives then a large collection of observations. Analyzing in an efficient and accurate way, this very-high-rate – and potentially massive – stream of events is the core of the Grand Challenge. Although, the analysis of a massive amount of sensor reading requires an on-line analytics pipeline that deals with linked-data, clustering as well as a Markov model training and querying. The FlinkMan system proposes a solution to the 2017 Grand Challenge, making use of a publicly available streaming engine and thus offering a generic solution that is not specially tailored for this or that challenge. We offer an efficient solution that maximally utilizes available cores, balances the load among the cores, and avoids the extent possible tasks such as garbage collection that are only indirectly related to the task at hand. This rest of the paper is organized as follows. Section 2 presents the query engine pipeline, the data set and the evaluation platform, that are provided for this challenge. Section 3 introduces the general architecture of our solution and its rationale. Finally, Section 4 provides details of the implementation as well as the optimizations included in our solution. 2 PROBLEM STATEMENT The overall goal is to detect anomalies in manufacturing machines based on a stream of measurements produced by the sensors embedded into the monitored equipments. The events produced by each sensor are clustered and the state transitions between the clusters are used to train a Markov model. In turn, the produced Markov model is used to detect anomalies. A sequence of transitions that follows a low probability path in the Markov chain is considered as abnormal, and is flagged as an anomaly. 2.1 Query The anomaly detection analysis can be modeled as a pipeline with three stages: (i) clustering, (ii) Markov model training and (iii) Markov model querying (i.e., output transition sequences with low probability). These three steps are executed continuously on a time-based sliding window and the whole pipeline is performed independently for each sensor of each machine. The query has 6 parameters: the time-based sliding window size W (in seconds), the initial number of clusters k (non uniform among sensors), the maximum number of iterations of the clustering algorithm M (if convergence has not been reached), the clustering algorithm convergence distance μ, the length of the Markov model path we consider for computing the anomaly probability N, and the probability threshold T below which the path is classified as anomaly. Each event goes through all the mentioned stages so that a single event may... Table 1: Example of an input window of size $W = 10$. <table> <thead> <tr> <th>Event</th> <th>Physical Timestamp</th> <th>Logical Timestamp</th> <th>Value</th> </tr> </thead> <tbody> <tr> <td>$r_0$</td> <td>1485903716000</td> <td>1155</td> <td>-0.04</td> </tr> <tr> <td>$r_1$</td> <td>1485903717000</td> <td>1165</td> <td>-0.04</td> </tr> <tr> <td>$r_2$</td> <td>1485903718000</td> <td>1175</td> <td>+0.02</td> </tr> <tr> <td>$r_3$</td> <td>1485903719000</td> <td>1185</td> <td>-0.0</td> </tr> <tr> <td>$r_4$</td> <td>1485903720000</td> <td>1195</td> <td>-0.01</td> </tr> <tr> <td>$r_5$</td> <td>1485903721000</td> <td>1205</td> <td>-0.04</td> </tr> <tr> <td>$r_6$</td> <td>1485903722000</td> <td>1215</td> <td>+0.0</td> </tr> <tr> <td>$r_7$</td> <td>1485903723000</td> <td>1225</td> <td>-0.02</td> </tr> <tr> <td>$r_8$</td> <td>1485903724000</td> <td>1235</td> <td>+0.0</td> </tr> <tr> <td>$r_9$</td> <td>1485903725000</td> <td>1245</td> <td>+0.02</td> </tr> </tbody> </table> Figure 1: Clustering (k-means) with $k = 3$. change the clustering, modify the Markov model, and trigger an anomaly detection. It is worth noting that the detected anomalies must be ordered with respect to the ordering in the input stream. **Example 2.1.** Table 1 contains an input window of size $W = 10$. **Clustering** First, the clustering algorithm groups all readings (from $r_0$ to $r_9$) into $k = 3$ clusters. To do so, a k-means algorithm is initialized: the cluster centers are set to the first values encountered (represented as $c_0$, $c_1$, and $c_2$ in the *Init* part of Figure 1). Then, a first grouping is produced according to these centers. Several iterations are then launched, until convergence, to find the best-fitted clustering. In our example, after a the third iteration (*Iter$_1$* in Figure 1), an equilibrium is reached and the clusters, represented in the bottom part of Figure 1, are returned. **Model training** Then, based on this history, a trained Markov chain is computed (Figure 2). This Markov model illustrates, for instance, that the probability is 1/3 to move from cluster $C_0$ to cluster $C_2$ (respectively states 0 and 2 in the Markov chain), and is 0 to move to $C_0$ from $C_1$. **Model querying** Finally, the path represented by the last 5 readings raises an anomaly. In fact, as demonstrated in the bottom of Figure 1, $r_4$ belongs to $C_2$ and $r_5$ to $C_0$. These transition corresponds to $2 \rightarrow 0$ in the Markov model, and has then a probability $p_{20} = 1/3$. $p_{20}$ to occur. Following the 5-step path from $r_4$ to $r_9$, this sequence has a probability of 1/3215 to happen, which is way below the anomaly threshold (set to 0.005 for this toy example). 2.2 Dataset The molding machines of our dataset are equipped with a large array of sensors, measuring various parameters of their processing including distance, pressure, time, frequency, volume, temperature, time, speed, and force. The dataset is encoded as RDF [20] (Resource Description Framework) triples using Turtle [19] and consists of two types of inputs, namely a stream of measurements and a meta-data file. The stream measurements contain a sequence of observation groups, a 120 dimensional vector with the events from all sensors for a single time-tick and machine. It is noteworthy that the vector contains a mix of different value types, e.g., text and numerical values. Each observation group is marked with a physical timestamp and has a machine identifier. In addition, each event contains a sensor identifier, a sensor reading and a sensor type. Each machine outputs a (complete) observation group once every second. $W$ is the size in time of the sliding window and, in steady state, the exact count of the sliding window. The query has to run against two different dataset types, namely static and dynamic. In the former, sensors from all machines listed in the meta-data output their events at a given rate. In the latter, machines can leave and join the working set. If a solution leverages data parallelism, by partitioning the input stream on machines and/or sensors, the machine’s churn may become imbalanced. 2.3 Evaluation Platform ACM DEBS 2017 Grand Challenge introduces a long awaited improvement over previous years, allowing the evaluation of the submitted solutions using a distributed environment. To provide a fair framework supporting the linked-data flavor of the challenge, the chosen evaluation platform is the automated evaluation platform provided by the European Unionfis H2020 HOBBIT [6] project. HOBBIT aims at abolishing the barriers in the adoption and deployment of Big Linked Data by European companies, by means of open benchmarking reports that allow them to assess the fitness of existing solutions for their purposes. These benchmarks are based on data that reflects reality and measures industry-relevant Key Performance Indicators (KPIs) with comparable results using standardized hardware. HOBBIT (Figure 3) enables running a system on a cluster of 3 physical servers equipped with a dual socket 64 bit Intel Xeon E5-2630v3 (8-Cores, 2.4 GHz, Hyperthreading, 20MB Cache) with 256 GB RAM and Gigabit Ethernet. The deployment is handled through Docker [2] containers, which package everything required to make a software run in an isolated environment. Unlike VMs, containers do not bundle a full operating system but only the libraries and settings required to make the software work. This makes for lightweight and self-contained systems, guaranteeing a write once, run (almost) anywhere property. The communication with the platform is (both data and control) is based on RabbitMQ [11] queues while an adapter handled the control messages from and to the platform. 3 SOLUTION ARCHITECTURE In this section we outline the general architecture of our solution and its rationale. Figure 4 identifies the three main tasks of our system architecture, namely input, business logic and output. Considering the query and given the large amount of available memory (3 x 256GB) and the limited amount of cpu (96 virtual cores), we chose to prioritize execution time and cpu usage over memory. 3.1 Input Task The first task encodes the input data from the HOBBIT platform RabbitMQ Input Queue (Figure 3) and parses the incoming event (sensor readings) into the format expected by the Business Logic. Notice that while this may seem a trivial task, for low window sizes parsing turns out to be the most intensive task of the analytic pipeline and an incorrect interaction with the evaluation platform RabbitMQ queue may induce starvation and other drawbacks inherent to distributed and parallel computation. Since the observation group (i.e., the input data unit) is encoded in RDF triples, the natural parsing approach is through an RDF-parsing library (e.g., Apache Jena [16]), however the ease of use also comes with a large performance overhead. A straightforward alternative is to implement an ad-hoc RDF string parser, which does not improve much due to the high cost of string comparison and manipulation operations. Delving slightly deeper, one may use byte arrays as an underlying messages type. Our approach is indeed to directly parse the consumed byte array, thus minimizing the conversions from bytes and using fast byte comparison operation. We provide more details in Section 4.3. Each ingested observation group yields 55 events, thus this task has a large count selectivity of 55. On the other hand, the observation group is encoded in RDF triples with turtle, while the system events are encoded in a 5-tuple of basic types. In addition, only 55 of the 120 events grouped in the observation group are monitored, yielding a space selectivity of 0.012. Finally, the RabbitMQ consumer (which has a low execution time) is in the same tasks of the parser to avoid cpu under-utilization. 3.2 Business Logic Task This task implements the mechanics of the ACM DEBS 2017 Grand Challenge query. The initial description of the query naturally leads to the instantiation of a pipeline of three parallel tasks: clustering, Markov model training, and Markov model querying. Each stage takes into account the current time-based sliding window with a count of exactly \( W \) events. We have that the clustering (using k-means) execution time lower and upper bounds are respectively \( \Omega(k + W) \) and \( O(M(W + k)) \), where \( k \) is the number of clusters, \( W \) the window size, and \( M \) the maximum number of clustering iterations. Given the cluster assignment for each events in the sliding window the Markov model can be trained with \( \Theta(W) \) time. Finally, the Markov model querying requires to replay the last \( N \) transitions in the Markov model to compute the probability of the resulting path, yielding \( \Theta(N) \) and \( O(W) \) time (by construction \( N \leq W \)). Using a monolithic approach, where the whole business logic is performed as a single task, the overall execution time lower and upper bounds are asymptotically\(^1\) the same of the clustering tasks alone. Each event may impact the current clustering, the Markov model training and querying, since each stage requires access to the whole result from the previous stage. Notice that here the output may be large, for instance the clustering has to output a cluster assignment for each event in the sliding window. Therefore, using a single task to run the business logic does not harm the overall asymptotically time complexity and avoids transferring (possibly through the network) large chunks of data. 3.3 Output Task The final task serializes the anomalies and publish them to the HOBBIT platform RabbitMQ Output Queue (Figure 3). As will be discussed next, this task cannot be parallelized, and therefore \( \gamma = 1 \). Thus, assuming an infinite number of cores, the execution time of this task bounds the maximum throughput (or minimum latency) of the whole system. Optimize this task to avoid it becoming a bottleneck to the whole process, is a major aspect of our implementation. \(^1\)Abusing notation somewhat we have \( \Omega(k + 3W) \) and \( O(M(W + k) + 2W) \). 3.4 Parallelization and Distribution The HOBBIT platform provides us with up to $8 \times 2 \times 3 = 48$ physical (or 96 hyper-threaded) cores, which utilization must be maximized to achieve good overall performances. This means that we spawn several instances of the aforementioned task. In particular we can spawn $\alpha$ instances (threads) running the input task which will consume messages from the HOBBIT platform RabbitMQ Input Queue and parse them in parallel. The HOBBIT platform uses the RabbitMQ Work Queues patterns, allowing only round-robin dispatching for multiple consumers. Since the query is performed independently on each sensor of each machine, we can safely partition the events in $\beta$ parts over the machine and sensor ids. We then spawn $\beta$ instances for the business logic task, each receiving one of such parts, i.e., the input to the business logic task from the input task is key-grouped. Notice that the parallelism in the input task may un-order the input of the business logic task: the $n$-th observation group for a given machine may finish its parsing before observation group $n + 1$. This compels us to introduce re-ordering step in the business logic task. Considering the output task, the data-parallelism of the business logic task may, in its turn, un-order the anomaly output across sensors. This compels us to introduce re-ordering step in the output task. To avoid further re-ordering, the output task cannot be parallelized. 3.5 Apache Flink The best performances are in general achieved by using ad-hoc underlying framework, and this has been the case for most previous edition of the ACM DEBS Grand Challenge. However, we strongly believe that using publicly available general purpose streaming engine is a more interesting choice for the DEBS community. We selected three initial candidates, Apache Storm [18], Apache Spark [17] and Apache Flink [15], and then further refined our selection considering the challenge query and our architecture requirements, as well as feature and performance comparisons [8, 14]. Finally we picked Apache Flink based on: (i) documented higher throughputs and lower latencies, (ii) API at high to low abstraction level, (iii) native time-based window and out-of-order managing mechanisms based on event-time, (iv) streamlined performance tuning, (v) both API and engine coded with HOBBIT’s reference language (Java). 4 IMPLEMENTATION DETAILS In this section we provide more details on our solution implementation, as well as the more relevant optimizations. 4.1 Load Balancing, Placement and Parallelism Load balancing in distributed computing is a well known problem that has been extensively studied since the 80s. We can identify two ways to perform load balancing in stream processing systems [5]: either when placing the task instances on the available machines [1] or when assigning load to the parallelized instances of tasks [10, 12, 13]. In this setting we have complete control over both angles, since we known a-priori the values that drive the execution time of the tasks: $W$ and $k$. In particular we have (in the meta-data file) the $k$ values for all sensors on all machines, which is in average per sensor equal to 50. We implemented a partitioning function, and an associated hash function, that partitions the sensors over the available $\beta$ instances of the business logic task in order to hit the same per sensor average value of $k$. We leverage this mechanism also to attempt to minimize the impact of the machine’s churn in the second scenario by spreading as much as possible the sensor of a single machine over the $\beta$ instances. With respect to placement, the pipeline architecture itself prevents avoidable hops over the network. However notice that, given the placement and the stream partitioning, a part may incur from 0 to 2 hops over the network. This variance is undesirable and a solution would be to place the tasks instances given the partitioning. An orthogonal concern is to avoid unbalancing the load on the the network interfaces and IP stacks of the available machines. To mitigate this issue we spread the $\alpha$ input task instances and the $\beta$ business logic task instances evenly (on the node hosting Flink’s JobManager process some cpu must be spared) among the 3 available machines. Since we control the parallelism of both the input ($\alpha$), the business logic ($\beta$) and output ($\gamma = 1$) tasks, we must strike the ratio that do not introduce a bottleneck. In other words we have to maximize $\beta$ while satisfy the following two equations: $$\alpha + \beta + \gamma + \mu \leq 3(32 - \sigma) \quad \text{and} \quad \frac{1}{55} \overline{\mu} \alpha \geq 2\sigma \beta$$ where $\mu$ is the number of cores allocated to Flink’s JobManager process, $\sigma$ is the number of cores allocated to the operating system on each machine, while $\overline{w}_\alpha$ and $\overline{w}_\beta$ are respectively the average execution time of the input and business logic tasks collected through experimental evaluations. Notice that $\overline{w}_\beta$ is a function of $k$ and $W$ (cf., Section 3.2). Finally, as mentioned in Section 3.3, we must also guarantee that the output task is not a bottleneck, i.e., $\overline{w}_\beta \geq \overline{w}_\gamma$. ### 4.2 Minimize Garbage Collection We chose to develop our system not only to fit HOBBIT and Flinks API, but also for the dynamic optimizations [3] it performs while running, which typically benefit long running systems. In turns then out that the optimizations that a designer and/or programmer can introduce are mainly targeted at maximize resource usage while reducing contention, and keeping object creation and deletion under check. It is well known [9] that an excessive object allocation churn in the JVM may hit the overall performances by inducing too many garbage collector cycles. Aiming at minimizing object allocation (and deletion) at runtime, we maximized object re-usage. The most relevant instances are discussed in more details in the following Sections 4.4 and 4.5. Notice that this pattern is quite more error prone since it partially forfeit encapsulation. To mitigate this problem (i) we implemented this pattern only as the last optimization layer and (ii) we introduced proper interface to ease swapping from classical to object re-usage pattern with ease. ### 4.3 ByteArray Parser As mentioned in Section 3.1, with low value of $W$ the parsing becomes a bottleneck. To design a fast parser we wanted to avoid as much as possible string operations, type conversions and object creations. While the input data is a sequence of grouped events (observation groups) encoded in RDF triples with turtle (i.e., string), the RabbitMQ messages underlying type is byte arrays. As such, we implemented an ad-hoc parser that works directly on the received byte arrays. Our implementation uses only displacement and access on the array as well as byte comparisons. Given the RDF ontology, we can identify a specific offset and character (byte) that uniquely identify the type of a triple. The parser main loop is the following: (i) the parser scans the byte array bytes from the current offset and identifies which type is the triple, (ii) then bytes and the current offset are passed to a type specific parser and (iii) the current offset is moved to the start of the following triple (i.e., after the new line character) until the end of bytes is reached. For instance, if the current triple encodes the sensor identifier, we can compute the offsets (start and end) from the triple start position of the sensor identifier. The type specific parser extracts the identifier integer value using the method getInteger (cf., Listing 5). We introduced a number of other optimizations to reduce the number of accesses and comparisons (i.e., fast skipping to the new line character). ### 4.4 Reordering events and anomalies As mentioned in Section 3.4, parallelizing the input and business logic tasks requires to introduce two reordering stages. While we initially planned to leverage Flink’s native mechanism to handle out-of-order events in sliding windows, we stumbled upon two shortcomings of the current implementations. The foremost is that while the engine waits for late events (i.e., the window contains the correct events), it does not reorder the window (i.e., the late event is wrongly positioned). The other issue with Flink’s native out-of-order mechanism, is that it assumes that the first received timestamp is $t_0$ (i.e., the application specific origin of time), while this may not be true in our setting. Since our application is strongly order sensitive, we had to implement an ad-hoc reordering mechanism that leverages the knowledge on the inter-arrival time of events (1 second). To identify the $t_0$ for each sensor we implement the following heuristic: (i) store all events in a buffer (i.e., stall the execution) until there is a sequence of consecutive (i.e., 1 second apart) events of length $\rho \times W$ (where $\rho$ is a user defined parameter encoding the expected maximum lateness) rooted in the event with the lowest timestamp, (ii) use the root of the sequence as $t_0$. Once $t_0$ is chosen, reordering the output of the input task boils down to store in the same buffer early-arrivals and add to the window consecutive events. It is then crucial that this buffer is backed by a highly performant data structure. LMAX Disruptor [7] are a well known technology which provides a strong performance boost by leveraging the concept of circular buffer which main goal is to minimize object allocation churn (cf., Section 4.2). We took inspiration from this design and implemented our own circular buffer with $O(1)$ operations, called pending (Figure 6). Pending maintains a pointer (next) to the entry associated with the next event. When polled, pending returns null if the next event has not arrived yet (i.e., next points an empty entry), otherwise it returns the next event and moves the next forward. When a new event is added, pending computes in which entry it falls based on the distance between the new event timestamp and the timestamp of the event pointed by next. The initial size of pending is set to $\rho \times W$ (where $\rho$ is a user defined parameter encoding the expected maximum lateness). If an added event has to be added in an entry exceeding this size, pending automatically doubles it size. Notice that in pending is easy to identify time gaps in among events, which may indicate that a machine has stopped sending events for a time interval. --- **Figure 5:** Pseudo code of the byte to integer parser ``` 1: function getInteger(byte[] bytes, start, end, byte[] digits) 2: num ← 0 3: for each i ∈ [0, end − start] and j ∈ [0, |digits| − 1] do 4: if bytes[end − i] = digits[j] then 5: num ← num + j × 10^i 6: return num ``` **Figure 6:** Pending buffer with $W = 16$ and $\rho = 2$ Guaranteeing that anomalies are returned ordered, the output task must know if it has yet to receive any previous one. To achieve that, the business logic does not filter out non-anomalous events, delegating the filtering stage to the output task. Then the output task receives all events (anomalous and non) and can reorder anomalies leveraging the logical timestamp associated to each observation group, the sensor identifier as well as the ordering guarantee among event of the same sensor. Similarly to the reordering mechanism of the business task, here we have to store events from the business logic that have arrived ahead of time. The data structure backing this mechanism is a slight variant of pending. 4.5 Sliding Window Due to Flink’s native windowing mechanism, the reordering stage could not be run inside the business logic task instances (i.e., requiring an additional thread). To overcome this limitation and avoid wasting a thread, we had to implement our own time based sliding window mechanism. Also in this case the sliding window buffer must be backed by a highly performant data structure. We used again the concept of circular buffer, implementing another circular buffer with $O(1)$ operations, called window (Figure 7). Window maintains a pointer to the first event in the window (start) and to the last (end). Window offers an iterator interface (backed by pointer) to scan, in order, the current window. When an event is added, Window places it in the entry following end. If it is the entry pointed by start, then the first item in the window is overwritten and start (i.e., the window) moves forward. Notice that it in window is easy to retrieve the first, last and last but $N$ event in the window. 4.6 RabbitMQ, Flink and JVM In this section we discuss the configurations of the three main piece of software underlying our solutions, starting with the communication middleware. Most of RabbitMQ configuration (i.e., durability, auto-deletion, etc.) is bounded by the HOBBIT platform and there is not tuning possible for our RabbitMQ producer in the output task. Considering the input task, to ensure an exactly-once semantic in the message delivery, the HOBBIT data input queue producer requires an acknowledgment of the delivery. As is, this pattern can quickly choke the system throughput by introducing a round-trip time delay in between each message and forcing the producer to process an acknowledgment for each produced message. The former can be mitigated through the consumer prefetch configuration parameter which sets the number of messages the producer is allowed to send to a single consumer without acknowledgment. Enabling multiple acknowledgments the consumer can acknowledge several deliveries with a single acknowledgment message, effectively reducing the overhead. Flink runs the submitted job task instances into task manager processes (JVMs), each handling a configurable amount of slots. Given $n$ slots in a task manager, each has access to a $n$-th of the task manager available memory, can contain any number of threads and tasks instances (not belonging to the same task). The networking stack is shared among threads in the same task manager and thus may become a bottleneck. We then run 2 task managers per machine, each with a slot for each available physical core. Assigning a resource group name to a task forces or avoids co-location of the instances of different tasks in a task manager slot. Chaining instead allows (or prevents) Flink to run two consecutive tasks instances in the same thread. These two mechanism configure the task instance-to-thread and the thread-to-slot allocations. It is also possible strike a good balance between throughput and latency configuring Flink’s network level batching, i.e., setting the batching timeout from 0 to $\infty$. Finally, the JVMs of the 2 task managers are set to use almost all the available RAM (256 GB), leaving a generous slack to the operating system. REFERENCES Figure 7: Window buffer with $W = 16$
{"Source-Url": "https://hal.archives-ouvertes.fr/hal-01644417/file/main.pdf", "len_cl100k_base": 6916, "olmocr-version": "0.1.50", "pdf-total-pages": 7, "total-fallback-pages": 0, "total-input-tokens": 24920, "total-output-tokens": 8303, "length": "2e12", "weborganizer": {"__label__adult": 0.0003643035888671875, "__label__art_design": 0.0005655288696289062, "__label__crime_law": 0.0005092620849609375, "__label__education_jobs": 0.0006761550903320312, "__label__entertainment": 0.00011307001113891602, "__label__fashion_beauty": 0.00024008750915527344, "__label__finance_business": 0.0008096694946289062, "__label__food_dining": 0.00048828125, "__label__games": 0.0005578994750976562, "__label__hardware": 0.0031795501708984375, "__label__health": 0.000537872314453125, "__label__history": 0.00034880638122558594, "__label__home_hobbies": 0.00014913082122802734, "__label__industrial": 0.0043182373046875, "__label__literature": 0.00021207332611083984, "__label__politics": 0.0004215240478515625, "__label__religion": 0.0006251335144042969, "__label__science_tech": 0.30810546875, "__label__social_life": 0.0001137852668762207, "__label__software": 0.033782958984375, "__label__software_dev": 0.64208984375, "__label__sports_fitness": 0.0003612041473388672, "__label__transportation": 0.0009388923645019532, "__label__travel": 0.0002244710922241211}, "weborganizer_max": "__label__software_dev", "avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_ratio": [[0, 33818, 0.06119]], "fineweb_edu_fasttext_gt2__fineweb_edu_fasttext_gt2__score": [[0, 33818, 0.22861]], "ft_lang_id_en_doc_v2__ft_lang_id_en_doc_v2__en": [[0, 33818, 0.88163]], "google_gemma-3-12b-it_contains_pii": [[0, 1084, false], [1084, 6064, null], [6064, 10394, null], [10394, 15998, null], [15998, 20892, null], [20892, 27028, null], [27028, 33818, null]], "google_gemma-3-12b-it_is_public_document": [[0, 1084, true], [1084, 6064, null], [6064, 10394, null], [10394, 15998, null], [15998, 20892, null], [20892, 27028, null], [27028, 33818, null]], "google_gemma-3-4b-it_v2tag__is_academic_paper": [[0, 5000, true], [5000, 33818, null]], "google_gemma-3-4b-it_v2tag__is_class_syllabus": [[0, 5000, false], [5000, 33818, null]], "google_gemma-3-4b-it_v2tag__is_completion_certificate": [[0, 5000, false], [5000, 33818, null]], "google_gemma-3-4b-it_v2tag__is_court_notice": [[0, 5000, false], [5000, 33818, null]], "google_gemma-3-4b-it_v2tag__is_homework_assignment": [[0, 5000, false], [5000, 33818, null]], "google_gemma-3-4b-it_v2tag__is_news_article": [[0, 5000, false], [5000, 33818, null]], "google_gemma-3-4b-it_v2tag__is_public_order": [[0, 5000, false], [5000, 33818, null]], "google_gemma-3-4b-it_v2tag__is_resume_cv": [[0, 5000, false], [5000, 33818, null]], "google_gemma-3-4b-it_v2tag__is_test_or_quiz": [[0, 5000, false], [5000, 33818, null]], "google_gemma-3-4b-it_v2tag__is_textbook": [[0, 5000, false], [5000, 33818, null]], "pdf_page_numbers": [[0, 1084, 1], [1084, 6064, 2], [6064, 10394, 3], [10394, 15998, 4], [15998, 20892, 5], [20892, 27028, 6], [27028, 33818, 7]], "pipe_delimited_lines_v1__pipe_delimited_lines_v1__pipe_delimited_lines_ratio": [[0, 33818, 0.09023]]}
olmocr_science_pdfs
2024-11-27
2024-11-27
dcc16a692a402333fe0d2a50ff49345cec8a1f7f
Learning GraphQL Query Cost Georgios Mavroudeas, Guillaume Baudart, Alan Cha, Martin Hirzel, Jim A Laredo, Malik Magdon-Ismail, Louis Mandel, Erik Wittern ► To cite this version: Georgios Mavroudeas, Guillaume Baudart, Alan Cha, Martin Hirzel, Jim A Laredo, et al.. Learning GraphQL Query Cost. ASE 2021 - IEEE/ACM International Conference on Automated Software Engineering – Industry Showcase, Nov 2021, Melbourne / Virtuel, Australia. hal-03469475 HAL Id: hal-03469475 https://hal.archives-ouvertes.fr/hal-03469475 Submitted on 7 Dec 2021 HAL is a multi-disciplinary open access archive for the deposit and dissemination of scientific research documents, whether they are published or not. The documents may come from teaching and research institutions in France or abroad, or from public or private research centers. L’archive ouverte pluridisciplinaire HAL, est destinée au dépôt et à la diffusion de documents scientifiques de niveau recherche, publiés ou non, émanant des établissements d’enseignement et de recherche français ou étrangers, des laboratoires publics ou privés. Learning GraphQL Query Cost Georgios Mavroudeas,† Guillaume Baudart,‡ Alan Cha,‡ Martin Hirzel,‡ Jim A. Laredo,‡ Malik Magdon-Ismail,* Louis Mandel,‡ and Erik Wittern,‡ *Rensselaer Polytechnic Institute †Inria Paris, École normale supérieure – PSL university ‡IBM Research Abstract—GraphQL is a query language for APIs and a runtime for executing those queries, fetching the requested data from existing microservices, REST APIs, databases, or other sources. Its expressiveness and its flexibility have made it an attractive candidate for API providers in many industries, especially through the web. A major drawback to blindly servicing a client’s query in GraphQL is that the cost of a query can be unexpectedly large, creating computation and resource overload for the provider, and API rate-limit overages and infrastructure overload for the client. To mitigate these drawbacks, it is necessary to efficiently estimate the cost of a query before executing it. Estimating query cost is challenging, because GraphQL queries have a nested structure. GraphQL APIs follow different design conventions, and the underlying data sources are hidden. Estimates based on worst-case static query analysis have had limited success because they tend to grossly overestimate cost. We propose a machine-learning approach to efficiently and accurately estimate the query cost. We also demonstrate the power of this approach by testing it on query-response data from publicly available commercial APIs. Our framework is efficient and predicts query costs with high accuracy, consistently outperforming the static analysis by a large margin. I. INTRODUCTION GraphQL is an open-source technology for building APIs to support client-server communication [17]. GraphQL has two interconnected components: a query language that clients use to specify the data they want to retrieve or mutate, and a server-side runtime to validate and execute these queries. A central architectural design choice in GraphQL is to shift control over what data a request can receive or mutate from API providers to clients. In competing technologies, like the REpresentational State Transfer (REST) architecture, providers define accessible resources and their API endpoints. In GraphQL, clients define queries that can retrieve or mutate multiple related resources in a single request (thus avoiding unwanted round-trips), and select only data they intend to use (thus avoiding over-fetching) [5, 6]. As a result, GraphQL is very suitable for creating diverse client experiences and many organizations, such as Shopify, GitHub, Yelp, Starbucks, NBC, among others, have elected to use GraphQL to build mobile applications and engage with their ecosystem partners [25]. Web API management is a challenging software engineering problem, for which GraphQL provides advantages but also introduces new challenges. A significant downside for providers when shifting control to clients is the risk of overly complex queries, which are expensive and lead to overloaded servers and/or databases. Even small GraphQL queries can yield excessively large responses [8, 11]. Empirical work shows that on many public GraphQL APIs, a linear increase in query size can cause an exponential increase in result size due to the nested nature of queries [27]. Unlike in REST APIs, where providers can avoid excessive use by limiting the number of allowed requests per time interval, in GraphQL, limiting the number of requests is not enough since a single query can break the system. As such, some GraphQL server implementations track query costs dynamically during execution [21]. Once a critical threshold is met, the server aborts execution and returns a partial result or an error. Unfortunately, this approach can lock up resources while producing unusable results. Hartig et al. propose to analyze the cost of queries before executing them [11]. Their analysis relies on probing the backend server for data-size information, for example, determining how many users are in the database if a query requests a list of users. However, this requires the server to offer probing facilities, which could themselves strain resources. In contrast, Cha et al. propose a static query cost analysis that does not depend on dynamic information from the server, but only provides upper bounds on cost [8]. This approach has been incorporated into IBM API Connect [14], a commercial API management product. Unfortunately, these upper bounds are often loose and this gap between estimated and actual cost makes the upper bound excessively conservative as a query filter, resulting in low amortized efficiency. More accurate cost estimates could allow providers to loosen their cost thresholds and help them better provision server resources. In addition, clients can better understand the costs of their queries and how often they can execute them for given rate limits. Therefore, we propose a machine-learning (ML) solution that predicts query costs based on experience generated over multiple user-server communication sessions. Our solution extracts features from query code by combining approaches from natural-language processing, graph neural networks, as well as symbolic features including ones from static compiler analysis (such as the cost estimate in [8]). It then builds separate regressors for each set of features and combines the component models into a stacking ensemble. Compared to the static approaches, our solution can underestimate cost of a query but provides estimates that are closer to the actual value. query { repository(owner: "graphql", name: "graphiql") { issues(first: 2) { nodes { id } } languages(first: 100) { nodes { name } } } } Fig. 1. Query for the GitHub GraphQL API. ( "licenses": [ { "name": "GNU Affero General Public License v3.0"}, { "name": "Apache License 2.0"}, ... ], "issues": [ { "nodes": [ { "id": "...NTQ="}, { "id": "...ODg=" } ] }, "languages": [ { "nodes": [ { "name": "HTML"}, { "name": "JavaScript"}, { "name": "Shell"}, ... ] } ] ] Fig. 2. Response corresponding to the query of Figure 1. This paper makes the following contributions: - A set of feature extractors for GraphQL query code. - A general ML workflow to estimate query cost that can be applied to any given GraphQL API. - A search space of ML model architectures for GraphQL query cost prediction, comprising of choices for ensembling, preprocessing, and regression operators. - An empirical study of our approach on two commercial APIs, comparing it to previous work and evaluating the practical applicability. Our approach can help API providers better evaluate the risk of client queries, and it can help clients better understand the cost of their queries to make the best use of their budget. II. BACKGROUND GraphQL queries are executed via a set of data retrieval functions called resolvers, i.e., functions that retrieve data for each field in an object type. A resolver can obtain the data from any source, be it from a database, another API, or even from a file. GraphQL queries are a set of nested fields with optional parameters. Fulfilling a query is a matter of calling the resolvers (with their respective parameters) of each field in the query and composing the returned values into a response, resulting in a JSON object containing the same fields as the query. Therefore, the structures of GraphQL queries and responses correspond to each other. For instance, the query in Figure 1 retrieves the list of open-source licenses available on GitHub and information about the "graphql" repository from the "graphql" organization, specifically the IDs of the first 2 issues and the names of the first 100 programming languages used in the repository. Figure 2 shows the response returned by the GitHub GraphQL API. For each field in the query with an object type (e.g., repository), the corresponding field in the response contains an object with the fields requested by the sub-query (e.g., issues). For each field in the query with a list type (e.g., licenses), the corresponding field in the response contains a list where each element is an object with the fields requested by the sub-query (e.g., name). To reflect the cost of the response, Cha et al. introduced the type complexity [8]: the sums of the fields present in either the query or the response, weighted by a configuration associated to the type of each field. For instance, with a configuration where the weight of a scalar type is 0 and the weight of all other types is 1, the type complexity of the response in Figure 2 with 13 "licenses" and 5 "languages" is 23 (= 13 licenses + 1 repository + 1 issue connection + 2 issues + 1 language connection + 5 languages). Nested lists can yield exponentially large responses [11]. In our example, the length of the lists issues and languages are bounded by the argument first, as dictated by the connection model [24]. Cha et al. [8] use this information to statically compute an upper bound on the response size from the query. While this upper bound is as tight as possible, it can grossly differ from the actual cost. For example, the static analysis assumes that the query of Figure 1 returns at worst a list of 100 programming languages, but the GitHub repository uses only 5 programming languages. III. METHODOLOGY The goal of this work is to automatically learn more accurate query cost estimates from data. First, we propose a set of specialized features that can be applied to any GraphQL API. These features turn GraphQL queries into suitable input for classic machine learning techniques. Second, we propose a hierarchical model to learn a cost estimate given a GraphQL query. Separate regressors for each features are combined into a stacking ensemble to obtain the final estimate. A. Feature Extraction We design three distinct feature extraction methods. Field Features: A GraphQL API defines a finite number of resolvers. We can thus represent all possible response fields by a vector of fixed size where each index represents a field. We create a feature vector for each GraphQL query, enumerating the total number of times a specific field appears. Graph Embeddings: The field features only capture information about the cardinality of fields. To capture information about the syntactic structure of the query, we use a second set of features based on graph embeddings. The idea is that a graph neural network can map the abstract syntax tree of a GraphQL query into a low-dimensional embedding space, from which we can then extract the numerical features. To do that, we employed the graph2vec [20] technique, one of the most popular approaches in this area. Summary Features: The last set of features is a six-dimensional encoding of the queries using symbolic code analysis techniques. They include 1) the static analysis upper bound of Cha et al. [8]. They also include features that summarize the tree structure of the queries. These are 2) query size, the number of nodes in the query tree, 3) width, the maximum number of children a tree node has, and 4) nesting, the maximum depth of the tree. Finally, we extract two features related to lists: 5) lists, the number of fields in a query requesting a list, and 6) the sum of list limits (e.g., first). The features vector of Figure 1 is [118, 17, 2, 3, 3, 115] (the list licenses has default length 13). B. Learning There are many well-known operators that implement regression algorithms (e.g., linear regression, gradient boosting regressors) and also feature preprocessing (e.g., polynomial features transformer). A library like scikit-learn [7] implements many of these operators, but picking the right operators and configuring their hyperparameters is a tedious task and depends on the dataset. We thus use Lale [4], an automated machine learning (auto-ML) tool, to select the best operators and tune the hyperparameters given a query/response dataset. Definition of three models: For each set of features (field, graph embeddings, and summary features), we train a model independently, but all three of these models have the same architecture. We define a pipeline where 1) the first step uses a standard scaler to give all features a mean of 0 and a standard deviation of 1; 2) the second step does other feature transformations (either no transformation, a polynomial expansion of the features, or a Nystroem transformer); and 3) the last step does the prediction using one of the following six predictors: linear regression, decision tree, ridge regression, random forest, k-nearest neighbors where the number of neighbors is fixed to 3, and gradient boosting regressors. Model selection: This pipeline defines a space of 18 possible combinations for each of the three models. Furthermore, each of the operators of the pipeline also has a set of hyperparameters to configure. We have fixed some of the hyperparameters, such as \( k = 3 \) for the \( k \)-nearest neighbors, but we left 43 hyperparameters free. The auto-ML tool then chooses the best solution among the possible combinations of algorithms and hyperparameters configurations. To select the best model, we use \( n \)-fold cross validation and the Bayesian optimizer from Hyperopt [16]. Combination of models: We train the three models independently and define a new hierarchical model using the outputs of the three models as input for a final model, as shown in Figure 3. This final model provides the estimation in the prediction phase. In general, using a stacked ensemble in an ML framework [28], learning each predictor separately and using the predictions as features for the final predictor, can improve accuracy. After experimentation, we found that in our case, this method performs better than concatenating the features into a wide vector and using a single regressor. IV. RESULTS The evaluation addresses the following research questions: RQ1: Does our approach return accurate estimates? RQ2: Are all the features useful for the estimation? RQ3: What are the practical benefits of the new estimation? A. Experimental Setup Data: Following the methodology in [8], we collected over 100,000 responses from the GitHub GraphQL API and 30,000 from the Yelp GraphQL API. The discrepancy between the sizes of the two datasets is due to the limit on queries imposed by the two APIs. The queries are synthetically generated but the responses come from industrial APIs. The dataset is available at https://github.com/Alan-Cha/graphql-complexity-paper-artifact. Table I presents the dataset characteristics, where query size, width, nesting, and lists are the corresponding summary features from Section III-A, and response is the actual cost of the query result. Training: The final model is selected using 5-fold cross validation [15]. We let our optimizer run for sixty hours for each trained pipeline for both the Yelp and GitHub datasets, exploring a total of 1,500 combinations of models and hyperparameters, whichever of the two finishes first. Once operators and hyperparameters are chosen, training a given model is relatively fast. In our experiments, the preferred estimator chosen by the Hyperopt optimizer in most of the training pipelines was the gradient boosting regressor for both datasets. B. RQ1: Accuracy We compare our approach to the static analysis proposed in [8], which was shown to outperform the three most popular libraries for computing GraphQL query cost. To quantify the precision of the ML approach compared to the static analysis, Figure 4 presents the error distribution percentages of the ML and static analyses. Given a query with response cost \( c \) and a prediction \( \hat{c} \), we define the error percentage as Error\% = \( \frac{\hat{c} - c}{c} \). The accuracy gain of the ML approach compared to the static analysis is striking both in terms of average value and standard deviation (see also the last two lines of Table II). As described in Section III, the ML estimates are based on three groups of features, namely summary features (including the result of the static analysis), field features, and graph embedding features. But are all these features necessary? To answer this question, we looked at estimates obtained using each group of features separately. Table II summarizes the results. We observe that for both datasets, none of the feature alone is competitive with the stacked ensemble that combines the results of cost estimation models trained from all three groups of features separately. The performance of each group of features depends on the dataset. For instance, while the summary features give reasonable estimates for both datasets, the field features are much more useful for GitHub than for Yelp. This could be related to the underlying structure of the two datasets as well as to the data generation process. Table II also shows that the automatic feature extraction of the neural networks used to build the graph embedding features fails to produce accurate estimates for either dataset, underscoring the importance of the more descriptive features. Our paper proposes a methodology for using ML to estimate the cost of GraphQL queries. We experimentally show that our ML approach outperform the leading existing static analysis approaches using two commercial GraphQL APIs, namely GitHub and Yelp. We believe that an ML approach to query complexity estimation can be useful for both API providers and clients. API providers benefit by allowing them to loosen cost thresholds and better provision server resources, while clients benefit by allowing them to better understand the costs of their queries and what is allowable within their rate limits. In addition, our approach can be used in conjunction with other types of analyses to create an overall more robust API management system. Table II Accuracy comparison for each feature (MAE = \( \frac{1}{n} \sum_{i=1}^{n} |\hat{c}_i - \tilde{c}_i| \)). <table> <thead> <tr> <th>Feature Group</th> <th>GitHub</th> <th>Yelp</th> </tr> </thead> <tbody> <tr> <td></td> <td>MAE (std)</td> <td>MAE (std)</td> </tr> <tr> <td>Summary features</td> <td>8.7 (36.4)</td> <td>102.4 (280.8)</td> </tr> <tr> <td>Field features</td> <td>14.9 (40.2)</td> <td>320.8 (715.6)</td> </tr> <tr> <td>Embedding features</td> <td>31.5 (45.7)</td> <td>880.9 (813.4)</td> </tr> <tr> <td>Final combination</td> <td>8.2 (35.5)</td> <td>60.7 (180.4)</td> </tr> <tr> <td>Static analysis</td> <td>31.5 (263.8)</td> <td>14,180.5 (30,827.9)</td> </tr> </tbody> </table> C. RQ2: Features Selection D. RQ3: Practicality Now that we have access to accurate complexity estimates, the main question is: how useful are these estimates in practice? API managers offer, through a client-selected plan, a rate limit, allowing a certain number of points per time window. Points could be attributed to individual REST calls or to the query cost in the case of GraphQL [10, 14, 23]. To mimic this behavior, we built a simulator that acts as an API manager whose goal is to filter queries based on the client plan. We select a threshold of points to represent the rate limit on a given time window. First, the client sets a threshold, that is, the maximal aggregate cost that the client is willing to pay for a query. Then the simulator acts as a gateway between the API and the client, rejecting queries for which the estimated cost is above the threshold. To evaluate the benefit of our approach, we compare the acceptance rate of a simulator relying on the static analysis against the acceptance rate of a simulator relying on our ML approach. Figure 5 shows the evolution of the acceptance rate for increasing values of the simulation threshold. V. RELATED WORK AND CONCLUSION Our work is an instance of machine learning for code (ML for code). ML for code has been extensively studied in the software engineering community [2, 13, 22], including for optimizing computational performance [26]. There are several works that use code as input, usually in the form of a token sequence, and then train ML models for a variety of tasks (for example, code completion) [3, 9]. To the best of our knowledge, our work is the first to apply ML to GraphQL. The database community has also studied query performance prediction (QPP) using machine learning techniques [1, 12, 18]. In contrast to these works, our approach focuses on GraphQL and uses a sound conservative upper bound on query cost as well as graph neural network features. Our paper proposes a methodology for using ML to estimate the cost of GraphQL queries. We experimentally show that our ML approach outperform the leading existing static analysis approach using two commercial GraphQL APIs, namely GitHub and Yelp. We believe that an ML approach to query complexity estimation can be useful for both API providers and clients. API providers benefit by allowing them to loosen cost thresholds and better provision server resources, while clients benefit by allowing them to better understand the costs of their queries and what is allowable within their rate limits. In addition, our approach can be used in conjunction with other types of analyses to create an overall more robust API management system. REFERENCES
{"Source-Url": "https://hal.archives-ouvertes.fr/hal-03469475/file/ase21.pdf", "len_cl100k_base": 4723, "olmocr-version": "0.1.50", "pdf-total-pages": 6, "total-fallback-pages": 0, "total-input-tokens": 18981, "total-output-tokens": 6155, "length": "2e12", "weborganizer": {"__label__adult": 0.0003464221954345703, "__label__art_design": 0.00030684471130371094, "__label__crime_law": 0.00027298927307128906, "__label__education_jobs": 0.0006175041198730469, "__label__entertainment": 6.860494613647461e-05, "__label__fashion_beauty": 0.00015056133270263672, "__label__finance_business": 0.0003097057342529297, "__label__food_dining": 0.00028443336486816406, "__label__games": 0.0003654956817626953, "__label__hardware": 0.0006008148193359375, "__label__health": 0.0004012584686279297, "__label__history": 0.0001977682113647461, "__label__home_hobbies": 6.985664367675781e-05, "__label__industrial": 0.0002803802490234375, "__label__literature": 0.0002377033233642578, "__label__politics": 0.00019812583923339844, "__label__religion": 0.0003466606140136719, "__label__science_tech": 0.020538330078125, "__label__social_life": 9.131431579589844e-05, "__label__software": 0.0086822509765625, "__label__software_dev": 0.96484375, "__label__sports_fitness": 0.00021982192993164065, "__label__transportation": 0.0003476142883300781, "__label__travel": 0.00017821788787841797}, "weborganizer_max": "__label__software_dev", "avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_ratio": [[0, 25078, 0.03683]], "fineweb_edu_fasttext_gt2__fineweb_edu_fasttext_gt2__score": [[0, 25078, 0.14863]], "ft_lang_id_en_doc_v2__ft_lang_id_en_doc_v2__en": [[0, 25078, 0.8709]], "google_gemma-3-12b-it_contains_pii": [[0, 1087, false], [1087, 6661, null], [6661, 12524, null], [12524, 17081, null], [17081, 22235, null], [22235, 25078, null]], "google_gemma-3-12b-it_is_public_document": [[0, 1087, true], [1087, 6661, null], [6661, 12524, null], [12524, 17081, null], [17081, 22235, null], [22235, 25078, null]], "google_gemma-3-4b-it_v2tag__is_academic_paper": [[0, 5000, true], [5000, 25078, null]], "google_gemma-3-4b-it_v2tag__is_class_syllabus": [[0, 5000, false], [5000, 25078, null]], "google_gemma-3-4b-it_v2tag__is_completion_certificate": [[0, 5000, false], [5000, 25078, null]], "google_gemma-3-4b-it_v2tag__is_court_notice": [[0, 5000, false], [5000, 25078, null]], "google_gemma-3-4b-it_v2tag__is_homework_assignment": [[0, 5000, false], [5000, 25078, null]], "google_gemma-3-4b-it_v2tag__is_news_article": [[0, 5000, false], [5000, 25078, null]], "google_gemma-3-4b-it_v2tag__is_public_order": [[0, 5000, false], [5000, 25078, null]], "google_gemma-3-4b-it_v2tag__is_resume_cv": [[0, 5000, false], [5000, 25078, null]], "google_gemma-3-4b-it_v2tag__is_test_or_quiz": [[0, 5000, false], [5000, 25078, null]], "google_gemma-3-4b-it_v2tag__is_textbook": [[0, 5000, false], [5000, 25078, null]], "pdf_page_numbers": [[0, 1087, 1], [1087, 6661, 2], [6661, 12524, 3], [12524, 17081, 4], [17081, 22235, 5], [22235, 25078, 6]], "pipe_delimited_lines_v1__pipe_delimited_lines_v1__pipe_delimited_lines_ratio": [[0, 25078, 0.06557]]}
olmocr_science_pdfs
2024-11-29
2024-11-29
d436c898df7ba25e6c281bc055ffe8fa69dde2d7
Threads (Chapter 11) - Process -- Program, Memory (text, data, bss, heap, stack), execution - stack - directly linked to execution - function call frame, on the stack - CPU -- execution "engine" - Early computers: one CPU, memory ... - Shared computing, multiple processes on one CPU - Typical use: round robin, quantum - Mid 1970s -- Big Iron (cray 1) down to microprocessors (intel 8080) - Idea at that point: Elephant (one big CPU) vs army of ants (microprocessors) - Parallel Computing -- army of ants, each ant ran "sequential" - Now: One "box", multiple CPUs (10s/box), one big memory - Possibility of having multiple execution points inside one process - Concurrency -- multiple execution points inside one process - But, not new, used in 1980 (and possibly earlier) - At UW: simulate 4096 CPUs on a single CPU? - Multiple threads of control in one process - Multiple stacks (one for each thread of control) - Round-robin the threads What is the difference between these ideas? ☐ Nelson’s definitions -- may not be accepted industry wide, but ... ☐ Concurrency -- Multiple threads of control in a single process ☐ Parallel -- A collection of processes, running on a collection of CPUs, cooperating to solve a single problem. CPUs geographically close (e.g. same room or building.) ☐ Distributed -- A collection of CPUs, most likely geographically distributed, providing services for a variety of uses. e.g. google Note: Concurrency can be used without multiple CPUs. Parallel and Distributed can’t work on a single CPU. ☐ Concurrency can be very useful with a GUI, one thread per visual element. Threads -- concurrency mechanism ☐ Note: threads can be useful in the parallel and distributed processes. ☐ Early Threads: ☐ User space (OS didn’t know anything about them) ☐ Now: ☐ Thread packages, language features, OS support Basic Thread Ideas - Single process, multiple threads (stack and execution) - Can simplify code for asynchronous code (e.g. GUI) - Threads can share global or heap memory. (Typically not stack) - Process can share memory, but it is more difficult. (ch 15 & 17) - With multiple CPUs available, "clock" time can be reduced. - Interactive programs can "spawn CPU intensive tasks on a thread" and come back to user quickly. - Threads are useful even on a uniprocessor. - Simulation example - GUI example - Issue of blocked vs running threads - With OS support, blocked threads don’t block other threads Thread consists of: - Stack (local variables in functions, call sequence) - CPU registers (PC, status, ...) - "Thread Local Storage" -- Global to thread, Local in process - errno -- two threads calling a system call at the same time - Shares the rest of the process ... pid, CWD, files, heap, ... PTThreads -- POSIX threads A thread library defined by the POSIX group (POSIX.1-2001) - Various implementations have been done. - Need a thread ID ... but may be a struct ... so - int pthread_equal (pthread_t tid1, pthread_t pid2); - compare two threads, return non-zero => equal, 0 is not equal - pthread_t pthread_self(void); - Gets the current thread id. Thread Creation - Program after execxx() starts as a single thread program. - Threaded program then starts threads - int pthread_create(pthread_t *thread, const pthread_attr_t *attr, void *(start_routine) (void *), void *arg); - thread -- pointer to a pthread_t variable - attr -- May be NULL (more later) - start_routine -- pointer to thread’s "main" function - arg -- pointer passed to the start routine - See pth-id.c: a program to print the "thread id" Thread Termination & Joining - Any thread calling exit(3) or _exit(2) exits the process and kills all threads - A default action signal that terminates will terminate the entire process - Single thread "exit" terminates only calling thread - void pthread_exit (void *rval_ptr) - may return a pointer - "start routine" can just return and return value is pthread_exit parameter - "Joining a thread" - Similar to a wait(), but for a thread - int pthread_join(pthread_t thread, void **retval); - Calling thread blocks if "thread" is still running - After "thread" returns, calls pthread_exit() or is canceled, returns from join - PTHREAD_CANCELED is a possible return value - return value is 0 for success, non-zero is an error number - EDEADLK - mutual joins or join calling thread - EINVAL - thread already joined or process waiting to join - ESRCH - no thread with that ID - Do not return pointers to local variables ... "automatic variable mis-use" - Joined thread reclaims the resources of the thread Other Calls - **int pthread_cancel(pthread_t thread);** - Causes thread to terminate as if it did pthread_exit(PTHREAD_CANCELED) - **void pthread_cleanup_push(void (*routine)(void *), void *arg);** - schedules a thread to be run at pthread_exit or pthread_cancel time - adds "routine" to a stack of routines for the calling thread - **void pthread_cleanup_pop(int execute);** - pops the top routine off the thread’s cleanup stack, not run if execute is 0 - **int pthread_detach(pthread_t thread);** - sets the thread to be "un-joinable" and automatically reclaims resources at thread exit - pthread_join() on this thread will return an error Thread Synchronization Race conditions happen even easier in threads □ Consider pth-race.c □ What happens? □ Why does that happen? □ What about "read only" variables? □ How can you fix it? □ Critical section -- section of code that must happen "atomically" -- no interruption of the process □ Software -- Peterson’s solution □ Turn based approach -- but works only for two threads □ Hardware assist approaches: □ Mutex -- Mutual Exclusion □ int mutex = 0; while (test_and_set(&mutex) == 1) /* spin */; critical-section; mutex = 0; □ Problem -- busy wait. □ Solution -- have the OS block the thread until it can enter the critical section. Mutex -- solution for mutual access to a shared variable Mutex -- a lock to block access to a critical section - one thread in the critical section at a time - all access to shared variable covered by a mutex - Pthreads -- need to initialize it: ```c int pthread_mutex_init(pthread_mutex_t * mutex, const pthread_mutexattr_t * attr); ``` - `pthread_mutexattr_t *` may be NULL for standard attributes - When done, the mutex may be destroyed ```c int pthread_mutex_destroy(pthread_mutex_t *mutex); ``` - no need to destroy if calling exit - Entry to critical section -- lock, block if held ```c int pthread_mutex_lock(pthread_mutex_t *mutex); ``` - return value 0 if successful, should check - Non-blocking try to lock ```c int pthread_mutex_trylock(pthread_mutex_t *mutex); ``` - Error if locked, errno is EBUSY - Exit to critical section -- unlock and let others in ```c int pthread_mutex_unlock(pthread_mutex_t *mutex); ``` Static initialization of a mutex ```c pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER; ``` Typical code outline: ```c if (pthread_mutex_lock(&mutexvar)) { /* Error condition */ } else { /* critical section */ if (pthread_mutex_unlock(&mutexvar)) { /* error condition */ } } ``` Critical section should be - as short as possible - have no loops unless absolutely necessary - never block in the critical section See pth-mutex.c Mutex issues - Deadlock -- circular waiting - `dsh`: child blocked writing to pipe, parent waiting on child - `mutex`: tries to lock a mutex already held - Multiple mutexes: - `A` holds `M1`, tries for `M2` (blocked) - `B` holds `M2`, tries for `M1` (blocked) - Longer chains of holding and waiting with circular wait are possible Avoid deadlocks with a mutex lock ordering - Can't order? Use `pthread_mutex_trylock` and don't block Problem: Readers and Writers - Shared Data Structure ... e.g. Balanced Binary Tree - Reader threads -- doing lookups in the tree - Writer threads -- doing inserts into the tree Problems? - race without mutex protection - problem here? - two readers can share at the same time with no race - writers need exclusive access, can’t share with readers Solution? - A new kind of a lock: A read-write lock - Two kinds of locking: - read_lock -- I promise to only read - write_lock -- I will modify data, need exclusive access - read_lock: allows locking if lock is read locked - blocks if write lock held - typically blocks if thread waiting to write lock - write_lock: blocks until all locks (both read and write) are unlocked Pthread reader-writer locks - **reader/writer lock initialization** ```c int pthread_rwlock_init(pthread_rwlock_t * lock, const pthread_rwlockattr_t * attr); pthread_rwlock_t lock = PTHREAD_RWLOCK_INITIALIZER; ``` - **reader/writer lock destruction** ```c int pthread_rwlock_destroy(pthread_rwlock_t *lock); ``` - **reader/writer locks/unlock routines** ```c int pthread_rwlock_rdlock(pthread_rwlock_t *lock); int pthread_rwlock_wrlock(pthread_rwlock_t *lock); int pthread_rwlock_unlock(pthread_rwlock_t *lock); int pthread_rwlock_tryrdlock(pthread_rwlock_t *lock); int pthread_rwlock_trywrlock(pthread_rwlock_t *lock); ``` 0 return if OK, error number on failure - **Read man pages for full information** Bounded Buffer Problem - multiple "producers", produce item, add it to shared queue - multiple "consumers", grab an item from the shared queue and "consume it" - shared queue has a shared size N - How does this get synchronized? Semaphores - A more robust tool - Core implementation: A semaphore is an integer variable S with atomic operations ``` wait(S) { while (S <= 0) /* wait */; S--; } signal(S) { S++; } ``` - Original names by E.W. Dijkstra were P() and V() ... proberen and verhogen - Kinds of semaphores: Binary (0,1) and Counting (0,1,2,3,...,n) - Issue: busy waiting - Can provide Mutex (e.g. binary semaphore is essentially a mutex) - Can provide other synchronization solutions, wait for another process ``` t1: S1; t2: wait(S); signal(S); S2; ``` Semaphore implementations - Issue of busy waiting ... - Instead of busy waiting, a process could block (give up the CPU) - Consider the following implementation, each function "atomic" ```c typedef struct { int value; struct process *list; } semaphore; void wait (semaphore *S) { S->value--; if (S->value < 0) { add process to S->list; block() } } void signal (semaphore *S) { S->value++; if (S->value <= 0) { remove a process P from S->list; wakeup(P); } } ``` Solution of bounded buffer problem: Queue of size N: Semaphore empty = N, Semaphore full = 0, Semaphore mutex = 1 producer: while true produce item wait(&empty) wait(&mutex) wait(&mutex) Add item to Queue signal(&mutex) signal(&mutex) signal(&full) Consumer: while true wait(&full) wait(&mutex) wait(&mutex) delete item from Queue signal(&mutex) signal(&mutex) signal(&empty) Issues with semaphores <table> <thead> <tr> <th>P0</th> <th>P1</th> </tr> </thead> <tbody> <tr> <td>wait(S)</td> <td>wait(Q)</td> </tr> <tr> <td>wait(Q)</td> <td>wait(S)</td> </tr> <tr> <td>...</td> <td></td> </tr> <tr> <td>signal(S)</td> <td>signal(Q)</td> </tr> <tr> <td>signal(Q)</td> <td>signal(S)</td> </tr> </tbody> </table> □ Issue? □ Deadlock ... P0 gets S and waits on Q, P1 gets Q and waits on S □ Easy to get with semaphores if not careful □ Programs have to be written correctly □ Programmers have to write correct synchronization code □ Consider: ``` wait(S); ... critical section ... ... wait(S); ``` □ To help "fix" these issues, language designers have added constructs to languages Monitors - Monitors -- an object-based synchronization construct ```javascript monitor name { // shared variable definitions function f1(args) { .... with access to shared vars and arguments only.... } function f2(args) { .... with access to shared vars and arguments only.... } ... initialization (...) { .... } } ``` - Functions in the monitor all run with mutual exclusion - Shared vars may be accessed only by functions in the monitor - Programmer does not need to code mutual exclusion - Needs something more for full synchronization, e.g., bounded buffer - Need to wait in a method for some condition to be true - Don’t want to block other threads from entering condition variables -- "condition x;" Operations: - `x.wait()` -- blocks the process in the monitor - `x.signal()` -- restarts one process blocked - no blocked processes? no-op - `x.broadcast()` -- restarts all processes blocked Issues: - call to `x.signal()` -- who runs? - caller waits - signaled waits - compromise for Concurrent Pascal: signaler must exit A number of languages have implemented monitors Path Pascal -- a slightly different approach - Object, functions, specification of order/number of operations - path 1:(a,b) , n:(a;b) end - 1:(a,b) -- a and b need mutual exclusion - n:(a;b) -- an a must run before b, at most n more as than bs Condition variables and Pthreads Pthreads have condition variables ... but monitors! - Functions for condition variables in Pthreads ```c int pthread_cond_init(pthread_cond_t * restrict cond, const pthread_condattr_t * restrict attr); or declaration init: pthread_cond_t cond = PTHREAD_COND_INITIALIZER; int pthread_cond_destroy(pthread_cond_t *cond); int pthread_cond_broadcast(pthread_cond_t *cond); int pthread_cond_signal(pthread_cond_t *cond); // May be implemented as broadcast! int pthread_cond_wait(pthread_cond_t * restrict cond, pthread_mutex_t * restrict mutex); int pthread_cond_timedwait(pthread_cond_t * restrict cond, pthread_mutex_t * restrict mutex, const struct timespec * restrict abstime); ``` - Use? - Must be used in conjunction with mutexes ```c pthread_mutex_lock(&mutex) while (something requires us to wait) { pthread_cond_wait (&condvar,&mutex); } critical section pthread_mutex_unlock(&mutex) ``` Condition variables and Pthreads (page 2) - **wait code again** ```c pthread_mutex_lock(&mutex) while (something requires us to wait) { pthread_cond_wait (&condvar,&mutex); } critical section pthread_mutex_unlock(&mutex) ``` - **While needed due to possibility signal is implemented as broadcast** - **Signal/Broadcast code** ```c pthread_mutex_lock(&mutex) critical section pthread_cond_signal(&condvar) pthread_mutex_unlock(&mutex) ``` - **want to signal and exit (like required for in some languages)** - **Best implementations** - "implement a monitor in C, mymonitor.h/.c" - Other parts of program just call the functions" Dining philosophers -- another classic synchronization problem - 5 philosophers - jobs: eat & think (over and over, ....) - seated at a round table - one plate in front of each philosopher - one fork in between plates - philosopher needs two forks to eat How do you synchronize access to the forks? - status [5] -- THINKING, HUNGRY, EATING - condition [f] -- to wait for all forks - check_forks(p) -- if hungry(p) and +/- not eating then set status to EATING, signal(p) - pickupForks(p) -- monitor routine - status[p] = HUNGRY, check_forks(p), if status[p] != EATING, wait(p) - putdownForks(p) -- another monitor routine - status[p] = THINKING, check_forks(-), check_forks(+) Banking Example - Customer Accounts and transactions (customer/account the thread) - Deposits -- simple - Check/Withdrawals -- simple - Transfers --- ? - Synchronize from and to accounts - Rendezvous - Implemented as part of several languages, Ada is one of them - How to implement in Pthreads? Barriers -- multi-thread synchronization All thread need to wait for slowest thread? - Use a "barrier" -- all threads have to stop at same time until all are stopped - Implementation with a condition variable (and mutex)? - Pthread version: ```c int pthread_barrier_init(pthread_barrier_t * restrict barrier, const pthread_barrierattr_t * restrict attr, unsigned int count); int pthread_barrier_destroy(pthread_barrier_t *barrier); int pthread_barrier_wait(pthread_barrier_t *barrier); ``` - 0 return -> successful ```c int pthread_barrier_destroy(pthread_barrier_t *barrier); ``` - 0 return -> successful - 0 => successful for all but one, one gets PTHREAD_BARRIER_SERIAL_THREAD - "thread may be used to update shared data." Parallel version across multiple machines - Issues of speed across a barrier -- as few barriers as possible! - Tree -- across multiple machines / or even on a GPU ... - Sequential is BAD Amdahl’s Law - Sequential part of a problem dictates limit on speed up - $p$ -- fraction of work that can be parallelized - $T = (1-p)T + pT$ -- total time - Now add parallelization ... - $s$ is a speed up factor on the parallel code $T’ = (1-p)T + pT/s$ Thread Attributes -- for use at thread creation time ```c int pthread_attr_init(pthread_attr_t *attr); int pthread_attr_destroy(pthread_attr_t *attr); ``` Attributes you can get and set - `pthread_attr_getdetachstate(3)` thread detach state - `pthread_attr_getguardsize(3)` thread guard size - `pthread_attr_getinheritsched(3)` inherit scheduler attribute - `pthread_attr_getschedparam(3)` thread scheduling parameter - `pthread_attr_getschedpolicy(3)` thread scheduling policy - `pthread_attr_getscope(3)` thread contention scope - `pthread_attr_getstack(3)` thread stack - `pthread_attr_getstacksize(3)` thread stack size - `pthread_attr_getstackaddr(3)` thread stack address Mutex & read/write lock attributes - control how locks work -- not covered here Reentrancy (aka thread safe) - multiple threads can call same function at the same time - is it safe to do it? - Yes -> thread safe! - What would make it un-safe? - return a pointer to a single static struct - second call changes static struct - System functions? Are they thread safe? - Not all -- see Figure 12.9 -- not guaranteed to be thread safe - Things like getpwent(), getgrgid() .... - How do you use them? - critical section with mutexes() - How about your code? Can it be thread safe? - How about access to errno? Thread specific data - can’t use thread ID and an array ... - local variables in thread_main() are "thread specific" .... but - errno needs to have one variable per thread - (GCC did some compiler tricks ... but not portable) - Idea of a "key" -- for accessing the data - int pthread_key_create(pthread_key_t *key, void (*destructor)(void *)); - int pthread_key_delete(pthread_key_t key); - Creates and destroys a key - Only want to do this once, not for every thread - int pthread_once(pthread_once_t *once_control, void (*init_routine)(void)); - allows first thread to call init_routine and not others - Access to thread specific data: - void *pthread_getspecific(pthread_key_t key); - int pthread_setspecific(pthread_key_t key, const void *value); - set first, then get. get before set gets NULL Errno? no longer a variable but a define to call a function #define errno (*__errno()) Similar to windows GetLastError()! Cancel Options Can control how a thread can be canceled -- read section 12.7 Final two issues: signals and forks Each thread has its own signal mask (pthread_sigmask()) sigaction is still for the entire process Signals are delivered to a single thread hardware issue -> delivered to thread that caused it No thread caused the signal -> delivered to an arbitrary thread! Control can be had with the per thread signal mask and sigwait(2) e.g. one thread can catch all the generic signals Note: read about Linux, signals and threads at the end of 12.8 Forking with threads: - `fork(2)` - creates a new process with ONE thread running - What about all the mutexes, r/w locks and cond variables? - `fork()/exec()` -> no problems ... memory image destroyed - `fork()` and continue execution - Don’t use locks/threads ... no problem - Start threads, using locks ... big problem! - If you do this ... read how to do it - can use `pthread_atfork()` to help clean up locks. I/O in threads - reads/writes -- use "file pointer" - can interfere with each other - Solution? ```c ssize_t pread(int d, void *buf, size_t nbytes, off_t offset); ssize_t pwrite(int d, const void *buf, size_t nbytes, off_t offset); ```
{"Source-Url": "https://facultyweb.cs.wwu.edu/~phil/classes/s19/347/threads.pdf", "len_cl100k_base": 5140, "olmocr-version": "0.1.53", "pdf-total-pages": 30, "total-fallback-pages": 0, "total-input-tokens": 38773, "total-output-tokens": 6441, "length": "2e12", "weborganizer": {"__label__adult": 0.00032711029052734375, "__label__art_design": 0.0002636909484863281, "__label__crime_law": 0.0002548694610595703, "__label__education_jobs": 0.0004580020904541016, "__label__entertainment": 6.282329559326172e-05, "__label__fashion_beauty": 0.00011986494064331056, "__label__finance_business": 0.00010508298873901369, "__label__food_dining": 0.0003120899200439453, "__label__games": 0.0009069442749023438, "__label__hardware": 0.0030879974365234375, "__label__health": 0.00030994415283203125, "__label__history": 0.0002396106719970703, "__label__home_hobbies": 0.0001246929168701172, "__label__industrial": 0.0004706382751464844, "__label__literature": 0.00020933151245117188, "__label__politics": 0.00018405914306640625, "__label__religion": 0.0005407333374023438, "__label__science_tech": 0.017303466796875, "__label__social_life": 6.0617923736572266e-05, "__label__software": 0.006183624267578125, "__label__software_dev": 0.96728515625, "__label__sports_fitness": 0.0003399848937988281, "__label__transportation": 0.0004911422729492188, "__label__travel": 0.00017452239990234375}, "weborganizer_max": "__label__software_dev", "avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_ratio": [[0, 20518, 0.00496]], "fineweb_edu_fasttext_gt2__fineweb_edu_fasttext_gt2__score": [[0, 20518, 0.20577]], "ft_lang_id_en_doc_v2__ft_lang_id_en_doc_v2__en": [[0, 20518, 0.77542]], "google_gemma-3-12b-it_contains_pii": [[0, 960, false], [960, 1867, null], [1867, 2780, null], [2780, 3631, null], [3631, 4699, null], [4699, 5357, null], [5357, 6013, null], [6013, 6983, null], [6983, 7441, null], [7441, 7885, null], [7885, 8621, null], [8621, 9371, null], [9371, 10171, null], [10171, 10666, null], [10666, 11176, null], [11176, 11743, null], [11743, 12452, null], [12452, 13125, null], [13125, 14147, null], [14147, 14814, null], [14814, 15497, null], [15497, 15813, null], [15813, 16772, null], [16772, 17031, null], [17031, 17794, null], [17794, 18331, null], [18331, 19157, null], [19157, 19841, null], [19841, 20518, null], [20518, 20518, null]], "google_gemma-3-12b-it_is_public_document": [[0, 960, true], [960, 1867, null], [1867, 2780, null], [2780, 3631, null], [3631, 4699, null], [4699, 5357, null], [5357, 6013, null], [6013, 6983, null], [6983, 7441, null], [7441, 7885, null], [7885, 8621, null], [8621, 9371, null], [9371, 10171, null], [10171, 10666, null], [10666, 11176, null], [11176, 11743, null], [11743, 12452, null], [12452, 13125, null], [13125, 14147, null], [14147, 14814, null], [14814, 15497, null], [15497, 15813, null], [15813, 16772, null], [16772, 17031, null], [17031, 17794, null], [17794, 18331, null], [18331, 19157, null], [19157, 19841, null], [19841, 20518, null], [20518, 20518, null]], "google_gemma-3-4b-it_v2tag__is_academic_paper": [[0, 5000, true], [5000, 20518, null]], "google_gemma-3-4b-it_v2tag__is_class_syllabus": [[0, 5000, false], [5000, 20518, null]], "google_gemma-3-4b-it_v2tag__is_completion_certificate": [[0, 5000, false], [5000, 20518, null]], "google_gemma-3-4b-it_v2tag__is_court_notice": [[0, 5000, false], [5000, 20518, null]], "google_gemma-3-4b-it_v2tag__is_homework_assignment": [[0, 5000, false], [5000, 20518, null]], "google_gemma-3-4b-it_v2tag__is_news_article": [[0, 5000, false], [5000, 20518, null]], "google_gemma-3-4b-it_v2tag__is_public_order": [[0, 5000, false], [5000, 20518, null]], "google_gemma-3-4b-it_v2tag__is_resume_cv": [[0, 5000, false], [5000, 20518, null]], "google_gemma-3-4b-it_v2tag__is_test_or_quiz": [[0, 5000, false], [5000, 20518, null]], "google_gemma-3-4b-it_v2tag__is_textbook": [[0, 5000, true], [5000, 20518, null]], "pdf_page_numbers": [[0, 960, 1], [960, 1867, 2], [1867, 2780, 3], [2780, 3631, 4], [3631, 4699, 5], [4699, 5357, 6], [5357, 6013, 7], [6013, 6983, 8], [6983, 7441, 9], [7441, 7885, 10], [7885, 8621, 11], [8621, 9371, 12], [9371, 10171, 13], [10171, 10666, 14], [10666, 11176, 15], [11176, 11743, 16], [11743, 12452, 17], [12452, 13125, 18], [13125, 14147, 19], [14147, 14814, 20], [14814, 15497, 21], [15497, 15813, 22], [15813, 16772, 23], [16772, 17031, 24], [17031, 17794, 25], [17794, 18331, 26], [18331, 19157, 27], [19157, 19841, 28], [19841, 20518, 29], [20518, 20518, 30]], "pipe_delimited_lines_v1__pipe_delimited_lines_v1__pipe_delimited_lines_ratio": [[0, 20518, 0.01373]]}
olmocr_science_pdfs
2024-12-07
2024-12-07
a5474968e224866ccd1df1cafd0848d64e1e0703
INTRODUCTION The UCSD Pascal System is a complete program development and execution environment for small computers. Its facilities include text editors and file management utilities, as well as compilers (for Pascal, in particular), assemblers, and a linkage editor. The system is highly portable; versions have been implemented on almost twenty minicomputers and microprocessors. (A concise description of system facilities is provided in an appendix.) The system was developed under the direction of Professor Kenneth Bowles at the University of California, San Diego (UCSD), starting in late 1974. The author, working first at the University as a graduate student, and more recently with SofTech Microsystems, played a principal technical role throughout the evolution of the software. The original need was for inexpensive interactive access to a high level language for a large enrollment introductory course in problem solving and computer science. We decided early that we would use small, stand-alone computers as the hardware foundation for our solution rather than larger, time-shared computers. We then chose Pascal as the language to be used by students in the introductory course, and also as the implementation language for system software we would need to build for these small machines. The design goals for Pascal specifically included these two kinds of applications. We used the P-compiler as the starting point for our Pascal implementation. We needed a stand-alone Pascal program development and execution environment suitable for computer-naive students, but also capable of being used for maintenance of the system itself. We had two primary design concerns: 1) a user interface oriented specifically to the novice, but also acceptable to experts; 2) a strategy for fitting these facilities in small, stand-alone machines. By our definition, a “small machine” had less than 64k bytes of memory, dual standard floppy disks, and a CRT terminal. We were particularly concerned about the Pascal compiler, since we knew of no implementation of Pascal within those constraints. These two concerns have been themes of the evolution of UCSD Pascal ever since. Experts and novices have both continued to use the system, and adaptations of the system to even smaller host configurations (e.g. the Radio Shack TRS-80®) have been done. In the user interface area, our current philosophy is still very similar to that originally developed. Given a single user host computer and a CRT terminal (the preferred environment), our approach is to keep the user continuously informed about the state of the system and the options available in that state. A “prompt-line” is maintained on the terminal screen listing these options. The user can select an option by typing a single-character command. In text editing, the high bandwidth connection to the user is exploited to provide a continuously updated “window” into the text file being perused or modified. A naive user in this environment is led tutorially through an interaction with the system. Experienced users can ignore the continuous status information unless it is needed. The original small system implementation strategy has also largely survived. Its major component is the use of a p-machine as the foundation of the system. The UCSD p-machine is a simple idealized stack-oriented computer which can be emulated by an interpreter executing in the machine language of a conventional host computer. The important requirement is that the instruction set of the p-machine be designed so that p-code representations of Pascal programs are very compact and easy for the compiler to produce. Compactness and ease of generation for p-code are both important, in order to minimize the size of the Pascal compiler, which is the biggest single software component of the system. We were inspired by the code-compaction approach used at Burroughs, but had to adapt it to conventional hardware without facilities for microprogramming or bit-level addressing. Through several iterations on the p-machine architecture, static and dynamic statistics of opcode and operand frequencies were used to identify the instruction sequences occupying the most space and redesign them to be more compact. Tannenbaum has independently pursued the same sort of optimizations, but without our concern for software portability. More generally, our concern for small host computers is pervasively reflected in our choice of functional facilities... included in UCSD Pascal and the implementation approaches used to provide them. As we accumulated experience with hardware and software for small systems, it became clear that while the costs of raw hardware would continue inexorably down, the costs of software were an entirely different matter. Thus, a third concern became important in the evolution of UCSD Pascal: conservation of our software investment. The bulk of this paper is devoted to explaining the software conservation strategy that we have evolved. One final introductory matter needs to be addressed: the unexpectedly large interest in UCSD Pascal from outside the University and how that interest was dealt with. A version of our software running on PDP-11's was first distributed to a few off-campus users in the summer of 1977. Outside interest began to increase when a version for 8080's and Z80's became operational early in 1978. Shortly thereafter, a description of the system in Byte drew over a thousand inquiries. As interest in the software mushroomed through 1978, it became clear that the demand for UCSD Pascal could not be met within the available resources of the University project. For this and other reasons, investigation began at the University into ways in which support of the growing UCSD Pascal user community could be moved off-campus. This effort culminated in June, 1979, with the designation of SofTech Microsystems as the focal point for licensing, support, maintenance and continued evolution of the UCSD Pascal language and system. Advanced development work has continued at the University in the Institute for Information Systems. Some of the results of that work are described later in the paper. CONSERVATION OF SOFTWARE INVESTMENT: AN OVERVIEW The first component of our effort to conserve software investment is the use of Pascal as the principal system and application language. In 1974, when the choice was made, Pascal was one of the more popular academic languages, and provided the best combination of power and ease of implementation. We certainly did not foresee the current avalanche of industrial interest in the language. The second component of our software strategy is a heavy emphasis on software portability. We feel that independence of software from differences in the underlying hardware is crucial to small machine applications in order to have: 1) the freedom to change hardware to take advantage of rapid technology developments, thus reducing hardware cost or increasing its performance. Consider the experience at UCSD with equipment for teaching Ken Bowles' introductory computer science course. The first small machines, acquired in the fall of 1975, were nine PDP-11/10's (worth about $17,000 apiece). Since then, two equipment transitions have occurred at two year intervals: first to 25 Terak 8510a computers (worth just under $8000 apiece), and then to 45 Apple II computers (at less than $3000 each). And all of these configurations can run virtually the same software! 2) the chance to reduce the effective cost of software by widespread sharing within an application community. At this writing there are more than 15,000 computers (with many different host CPU's) running UCSD Pascal. This number is large enough to justify significant investments in application software. High costs to the individual end-user are not required to recoup those investments. These portability motivations are, of course, not new to the small machine environment; they have just become much more urgent as the cost of software continues to rocket while that of hardware plummets. There are several different approaches to software portability. One can emphasize the program, picking a particular large application, like a database management package, and working to reduce effort to move it to new host operating system or processor environments. A disadvantage of this approach is that the effort must be expended anew for each additional application considered. Another possibility is to emphasize a language and its implementation. Here the theory is that programs written in that language will port easily (by recompilation) to a new environment after the language itself is moved. Unfortunately, any sizable application program calls on I/O and other operating system resources in ways that may conflict with services available in a new environment. Therefore, changes are likely to be needed in the application programs to be moved. Figure 1 may clarify this approach. UCSD Pascal provides a portable software environment. When the system is moved to a new host, all the conventions about file titles, disk organization, and other operating system matters are replicated. Therefore applications in UCSD Pascal can usually be moved to a new host without any modification to the source version of a program. This is shown in Figure 2. As we will see below, it is even possible to move the object version of a program to a new host. Software environment portability has been independently pursued with the Thoth and Unix operating systems. Neither of these efforts has had our concern for the special problems of small hosts. In two sections below, specific areas of UCSD Pascal portability are examined. In the first, independence from the host processor (ignoring system peripherals) is considered. Secondly, our approach to independence from host peripheral devices is discussed. While our concern with portability is long-standing, recognition of the third component of our conservation strategy (organization for support and maintenance) is more recent. As UCSD Pascal entered widespread production use in 1979, it became clear that maintenance and support activities needed careful attention if a large user community using many varieties of host hardware was to be properly served. at a reasonable cost. It also became clear that the academic environment was not well-suited to this task. One reason why SofTech was chosen to take over support of UCSD Pascal was their experience in developing and using software engineering tools of the type needed to support maintenance of UCSD Pascal. **INDEPENDENCE FROM THE HOST PROCESSOR** *P-machine contributions to software portability* The key to host processor independence is the designation of the p-machine as the foundation of the UCSD Pascal System. One result is that the entire Pascal system, including editors, compilers, operating system, etc., can be moved to a new host computer by reimplementing the p-machine and associated low-level routines in the native language of the new host. The relative simplicity of this implementation task has been widely exploited. Implementations of some variant of the UCSD p-machine have been done for the microprocessors and minicomputers listed below. (Those that have actually become products are marked with an asterisk.) *Data General Nova *Digital Equipment PDP-11® & LSI-11® *General Automation GA-16 Hewlett Packard System 45 *Intel 8080 & 8086 Lockheed Sue *Mos Technology 6502 *Motorola 6800 and 6809; 6800 is being actively pursued The effort required for one of these implementations has ranged from 6 person weeks to 9 person months, depending on experience of the implementor and suitability of the host for p-machine implementation. We know of no other body of software as large as the UCSD Pascal System that has been moved to as many different host computers. UCSD p-code is portable at the binary code file level (see more discussion of this under Data Representation Issues). Other pseudo-machine oriented efforts (Janus, for example) have generally standardized, instead, at the level of symbolic pseudo-machine assembly language. The choice of a binary interface for UCSD Pascal makes it much more practical for p-code to serve as a sort of "lingua franca," for communicating object programs among a wide user community. Carl Helmers has proposed a distribution approach for small machine application packages in which the last few pages of the user document would contain a printed bar-code encoding of the object program. As he recognized, UCSD p-code fits very nicely into this approach. P-code is a lingua franca in another sense: even though the p-machine is optimized for Pascal programs, translators can and have been written from FORTRAN and BASIC to p-code. With some strategic additions to the p-machine to support new data types, even a COBOL to p-code translator is feasible. Concentration on small systems We have chosen to limit the class of suitable host computers so as to enhance portability within that class. We assume that memory can be viewed as 8-bit bytes and 16-bit words and that the 7-bit ASCII character set is used. Distributed versions of the p-machine are also limited to a 16-bit address space. (A later section discusses removal of this limitation.) Our success in transcending the details of the host environment has been substantially increased by specializing in this limited class. Fortunately, most small computer systems are included. Performance issues What price has been paid for these portability benefits? One part of the cost is in the reduced execution performance of interpretively executed p-code compared to other implementation approaches. For many small computer applications (text editing or data capture, for instance) interpretive execution on a dedicated microprocessor is more than adequate. In other applications (e.g., compilation) the benefits due to the small size of p-code outweigh the drawbacks of raw execution speed. It is also possible (with some reduction in portability) to code time-critical routines directly in assembly language and call them from a high level host program. Most real-time programs can meet performance requirements with only a small portion (less than 10 percent) written in assembly language. Another performance possibility is to provide more direct hardware support for the p-machine. In the Western Digital MicroEngine, the MOS chip set used in the implementation of Digital Equipment's LSI-11 has been microcoded to implement the p-machine directly. P-code is thus the native language of the MicroEngine. Performance improvement factors of five or more have been measured for the MicroEngine over interpretive execution on the LSI-11. At least another factor of two in performance has been achieved with a micro-coded p-machine based on high speed bit-slice technology. An overall improvement factor of twenty compared to LSI-11 interpretation is probably achievable with standard low-cost components. (All of these comparisons apply to simple integer arithmetic and array operations, as in an integer sort routine.) Data representation issues Some concessions to efficiency over portability have been made. The biggest has to do with representations of p-machine data types. Although a standard on floating point number representation and algorithms is being developed by the IEEE,11 there are still many different formats supported by various vendors. We have standardized on a size of 32 bits for floating point numbers, but do not require a particular representation. Therefore, advantage can be taken of existing floating point software and hardware support. Where new floating point implementations have been done (on the 6502, 6800, 9900, and W.D. MicroEngine) the IEEE format is used. A machine-dependent "power of ten" table allows all high level software (even conversions between ASCII and internal floating point) to be isolated from knowledge of the internal representation. Long integer representations can also vary. Binary integer, packed BCD, and radix 10 are among the feasible representations. A dramatic performance improvement can be achieved on some hosts by choosing a suitable representation. Once again, higher level software in the Pascal system need only care about the length (in words) of a long integer. Even ordinary 16-bit integers do not have a standard representation (at least in the ordering of their two bytes). In some host architectures (e.g. PDP-11, 8080) byte zero of a word is the least significant byte; in others (e.g. 6800, Z8000, IBM 370), byte zero contains the most significant bits of the 16-bit integer. Thus, the interpretation of two adjacent bytes as a 16-bit word is machine-dependent. Here, too, an attempt to force a single representation on all architectures would be prohibitively expensive. What is the impact on portability of these representation decisions? First, portability of source programs is not affected, unless a program specifically chooses to deal with the representation, by bypassing the type philosophy of Pascal. We need, but do not yet have, an analog of the LINT program under Unix,7 which could comb source programs for potential trouble spots of this type. Second, data files containing any of these data types are not directly readable by implementations with different representation choices. It is possible to design file record structures so that an application program can automatically compensate for representation differences. Third, code files are sensitive to the byte ordering (we call it "byte sex") of the host processor. The dependence occurs where adjacent bytes in the code stream represent words (mostly in superstructure tables). The Pascal compiler can generate code files of either type on any host, and a utility program is provided to convert object files from one type to another. Finally, code files containing floating point constants are not directly movable between hosts with different floating point representations. It is usually possible, by doing some computation at run-time, to avoid this problem. INDEPENDENCE FROM THE HOST PERIPHERALS UCSD Pascal I/O hierarchy Our approach to achieving peripheral independence is to provide a hierarchy of I/O environments. The levels of the hierarchy are chosen to further two objectives: 1) isolation of application programs and most system components from details of the host computer, and 2) reduction of effort involved in adapting to new host configurations. The levels we identify are pictured in Figure 3 and listed and described below: 1) Screen I/O. This level presents a uniform image of a screen terminal. Capabilities include moving the terminal cursor; clearing all or part of individual lines or the entire screen; and accepting cursor control or other special commands from the terminal keyboard. 2) File I/O. At this level, devices are designated by logical volume names. Volumes can be serial (e.g. console) or random access (e.g. disk). Random access volumes can have directories of named files. Serial volumes are (possibly bi-directional) byte streams. Textual I/O (with full conversion between internal representations and ASCII) is provided from and to volumes or files. Record-oriented I/O (with automatic blocking and deblocking) is provided with random access volumes or files. 3) Unit I/O. At this level, devices have numbers that indicate their type (e.g. 1 for console terminal, 6 for printer, etc.). A serial device is still a byte stream, with knowledge of a few special output characters (blank compression codes, carriage returns). A random access device is considered an array of directly addressable 512-byte blocks. No knowledge of files, textual or record-oriented I/O is available at this level. 4) Basic I/O. Capabilities of random access devices at this level are similar to those available at the Unit I/O level. Serial devices are much simpler. Serial transfer occurs one character at a time and no special output characters are processed. Special input characters from the console terminal can cause console output to be stopped, restarted or discarded. 5) Simplified I/O. Here the random access interface is much more primitive. A device is viewed as a sequence of tracks, each containing an array of physical sectors. Transfers occur, one sector at a time, between a main memory buffer and a (track, sector) coordinate. Serial device capabilities are similar to those in Basic I/O, except that no special input characters are recognized. Table I summarizes the degree of independence from host configuration provided at each of these levels. The Basic and Simplified I/O components are generally implemented in assembly language and clearly dependent on peripheral details. The pseudo-machine interpreter (which generally includes Unit I/O) is dependent on the host processor, but defers peripheral details to lower levels. File and Screen I/O are implemented in Pascal and are therefore independent of both peripheral and processor variations. The application program does not have to depend on anything but the virtual environment provided by the Pascal system. <table> <thead> <tr> <th>Software level</th> <th>Is independent of:</th> </tr> </thead> <tbody> <tr> <td></td> <td>Console</td> </tr> <tr> <td>Application program and host system components</td> <td>Yes</td> </tr> <tr> <td>Screen I/O</td> <td>No</td> </tr> <tr> <td>File I/O</td> <td>Yes</td> </tr> <tr> <td>Interpreter and Unit I/O</td> <td>Yes</td> </tr> <tr> <td>Basic and Simplified I/O</td> <td>Yes</td> </tr> </tbody> </table> Adaptation to host configurations Four kinds of user adaptation are intended. The easiest adaptation is also by far the most frequently needed: catering to console terminal peculiarities. Most of the effort involved goes to changing the entries in terminal description tables maintained by the system (a program, SETUP, is provided to do this). Some programming (in Pascal) of interface procedures may be required. Average effort involved for the user is an hour or two. A test program is provided to determine if the effort was successful. Next in order of increasing difficulty and decreasing frequency of need is adaptation of the Simplified Basic I/O Subsystem (SBIOS). Given that a user is knowledgeable about his peripheral interface, and has access to existing low-level driver software, a few days of work should be sufficient to bridge the gap between those drivers and the SBIOS interface, producing a usable Pascal System. Again, a test program is provided. The approach we have taken here is based on that developed by Digital Research for the CP/M® operating system. The Basic I/O Subsystem (BIOS) is comparable to its simplified cousin, except that is has more responsibility, and therefore more possibility for optimization. For instance, it is possible in the BIOS to take full advantage of a direct memory access interface to disk. The BIOS definition emphasizes performance and flexibility, while the emphasis with SBIOS is on ease of adaptation. BIOS implementation generally takes a week or two of effort, assuming detailed knowledge of the peripheral complement and familiarity with our I/O structures. Finally, the most elaborate adaptation is to a new host processor (which is included in this peripheral independence section for completeness). As mentioned above, effort involved here is more than a month, but less than a year; six person months is probably a good average. Table II gives the various levels of adaptation. For each, a reasonably realistic level of effort is given, as well as an approximate "probability of need" indicating how frequently adaptation at that level will be desired. Fortunately for the viability of our approach, these probabilities have some basis in reality. ENHANCEMENTS Native code generation Active work is under way at UCSD to provide the ability to translate selected procedures of a p-code program to native code for a conventional host computer. This possibility will alleviate many of the performance drawbacks of our p-code orientation without sacrificing portability. Programs can be written and maintained entirely in Pascal, and the p-code object version is still transferable among different kinds of host computers. If active use of a program reveals performance bottlenecks, the time-critical procedures can be translated to a native code. <table> <thead> <tr> <th>Level of adaptation</th> <th>Approximate &quot;Probability of need&quot;</th> </tr> </thead> <tbody> <tr> <td>Application program</td> <td>very little, if any</td> </tr> <tr> <td>Screen I/O</td> <td>hours</td> </tr> <tr> <td>Simplified I/O</td> <td>days</td> </tr> <tr> <td>Basic I/O</td> <td>weeks</td> </tr> <tr> <td>Interpreter</td> <td>months</td> </tr> </tbody> </table> Code generation is implemented as an optional step in the compilation process. It takes as input a complete p-code program and produces, as output, a mixture of unmodified p-code and translated native code procedures. This process is diagrammed in Figure 4. Internally, the code generator represents a p-code procedure as a forest of expression trees. Several traversals of these trees occur during the translation process. Note that the p-code input to the code generator can come from a Fortran or Basic compiler, as well as from the Pascal compiler. Once again, software investment is conserved, since only one code generator for a particular target machine serves several languages. Implementations are in progress of code generators for the PDP-11, TI9900, Intel 8080, Mos Technology 6502, and General Automation GA-16. At this writing, the first two versions are farthest along. For both processors, translated native code is about 50 percent larger than the corresponding p-code. Improvements in execution performance compared to interpretive execution on the same host have been around a factor of 10 for the PDP-11 and a factor of 15 for the TI9900. New definition of "small" systems As new microprocessor architectures (e.g., 8086, Z8000, 68000) and peripherals (e.g. low-cost Winchester disks) become widely available over the next several years, the definition of "small" low-cost computer systems will have to broaden considerably to include those with megabytes of main memory and tens of megabytes of mass storage. We are investigating ways in which the UCSD Pascal system could allow these facilities to be exploited. The situation is complicated by our need to continue supporting both 280 class and Z8000 class users for the foreseeable future. Therefore, it must be possible for user programs, and particularly system components, to run in both environments. It must also be possible, of course, to produce a user program that requires so many resources that it can only be run in an expanded environment. As an example of the extension approach we are pursuing, consider the problem of dealing with address spaces bigger than 16 bits. In the near term, it is quite easy to apply the 16-bit limitation only to data space: object code need not be accessible within the 16-bit area. For the longer term, we are considering a scheme in which details of physical ad- ACKNOWLEDGMENTS The UCSD Pascal system is the work of a large group, too numerous to list here, of graduate and undergraduate students at UCSD. The role of Kenneth Bowles in inspiring, directing, and energizing this work has certainly been crucial to its success. Helpful comments on this paper from John Brackett, Winsor Brown, Al Irvine, and Richard Kaufmann are gratefully acknowledged, as is Keith Shillington’s preparation of the illustrations. REFERENCES APPENDIX: Facilities of the System Program execution environment The foundation of the System is the UCSD p-machine. It is a simple idealized stack computer which can be implemented either by direct hardware support (as in the Western Digital MicroEngine) or by an interpreter executing in the machine language of a conventional host computer. On a conventional host, a single object program can include both p-code (to be interpretively executed), and native code (for direct execution by the host). Peripherals are accessed by logical "volume" names. Serial volumes (e.g. console terminal) are considered byte streams. Random access volumes (e.g. floppy disk) can have directories of named files. Various kinds of logical transfers involving volumes and files are supported. Program execution and file manipulation commands The user can execute a named object program, or use short cut commands to invoke important system programs. The user can also designate individual files or groups of files for removal, renaming or transfer among on-line devices. Other commands support various housekeeping needs: listing directories, compacting the files on a disk, and testing disks for invalid areas. Finally, the user can designate a "work file." Subsequent editing, compilation and execution commands apply to this work file by default. Text preparation and modification facilities Two styles of text editing are supported: one requires a video display terminal, and the other does not. When the system console is a CRT, the “screen-oriented” editor can usually be used. This editor maintains a cursor into the text file being edited and a “window” into that area of the file on the terminal screen. Modifications to the text are made by the intuitive and mechanical process of moving the cursor to the site where change is desired and indicating the change. Commands are provided for moving the cursor, finding and replacing textual patterns, making insertions and deletions, and copying text into the cursor position from elsewhere. Special facilities exist for processing documents. User-specified left and right margins can be automatically enforced by the editor and new margin requirements can easily be applied to existing text. The second available style of editing does not require a screen terminal. Once again, a cursor is maintained, where most of the action occurs. But the user is responsible for maintaining a mental image of the cursor context. Com­ mands are available for insertion, deletion, and copying of text, as well as for moving the cursor. A simple macro facility is provided. Programming languages The principal programming language supported is UCSD Pascal. Except for the provision of procedures as parameters, UCSD Pascal is largely consistent with the base Pascal language, as defined in Jensen and Wirth’s User Manual and Report.12 UCSD Pascal is also quite consistent with the emerging international standard for Pascal.13 We are com­ mitted to eventual complete compliance with an adopted standard. UCSD Pascal includes various extensions beyond the base language. We summarize, here, the most important: 1) Dynamic character strings. A predeclared type “string” is supported. A string variable contains a sequence of characters. A maximum length for the sequence is spec­ ified in the declaration. Concatenation of strings; inser­ tion, deletion and extraction of substrings; and string pattern matching are provided by predeclared service routines. 2) Encapsulation and separate compilation. A new com­ posite declaration, the “unit,” is provided. A unit is a group of procedures, functions, and data structures, usually related to a common task area. A program or another unit (a “client module”) can access these facili­ ties by naming the unit in a simple “uses” declara­ tion. A unit consists of two parts, the interface part, which can declare constants, types, variables, proce­ dures and functions that are public (made available to any client module), and the implementation part, in which private declarations can be made. These private declarations are available only within the unit, and not to client modules. Units can be compiled separately from their client modules. 3) Extended precision integers. A “long integer” data -type is provided. Integers up to 36 decimal digits in size can be represented and participate in the standard in­ teger operations: addition, subtraction, multiplication, and division. Conversions among long integer, string and standard integer forms are provided. 4) Concurrent processes. Another type of routine in UCSD Pascal is the “process.” Processes are declared with the global procedures of a program and have the same lexical access to global variables and procedures. A process is different from a procedure in that when invoked, it proceeds in parallel with its invoker. Sem­ aphore variables, plus wait and signal primitives, are provided to allow these parallel processes to synchro­ nize and communicate reliably. With the “attach” pro­ cedure, a semaphore can be associated with an external interrupt. This association causes the semaphore to be signaled if the interrupt is activated. Thus Pascal pro­ cesses can respond to external events. 5) Miscellaneous extensions. Other additions to UCSD Pascal provide random access to Pascal file compo­ nents and a constrained interprocedural go to mecha­ nism. Segment routine declarations allow designation of overlays and external procedure declarations allow an assembly language routine to be called from a Pascal host as if it were a Pascal procedure. A Basic compiler exists for the UCSD Pascal system, but is not currently being supported. Assembly language is available for most processors on which the system is supported. The assemblers can be used for stand-alone programs (such as interpreters) or for pro­ cedures which will be bound into high level language host programs. The approach is to provide (as far as possible) the syntax for machine instructions defined by the original pro­ cessor manufacturer (e.g. Zilog for the Z80). A common syn­ tax has been defined for assembler directives and assembly­ time expressions. Naturally, all of the assemblers can run on any host processor variant of the System, so a single type of host can be used to support assembly language programs for multiple machines. Directives supported include the usual facilities for macro definition, conditional assembly, storage allocation and list­ ing control. Additional directives allow communication with external labels in other assembly language routines. Finally, special provision is made for communication between an assembly language routine and a Pascal host program. The low-level routine can request access to host program global variables and constants. It can also allocate its own global storage space. TRADEMARKS UCSD Pascal is a trademark of the Regents of the Uni­ versity of California. PDP-11 and LS1-11 are trademarks of Digital Equipment Corporation. Unix is a trademark of Bell Laboratories. MicroEngine is a trademark of Western Digital Corporation. CP/M is a trademark of Digital Research, Inc. Radio Shack and TRS-80 are trademarks of Tandy Corpo­ ration. Software Quality The FAA's computerized Enroute System for controlling in-flight commercial aircraft crashes during a peak holiday period due to overloading. The DoD Early Warning System, a computerized air defense system, mistakes the rising moon for a barrage of incoming enemy missiles and shock waves travel all the way to the White House. A single erroneous statement in a small computer on-board a French weather satellite causes 71 of 142 weather balloons to self-destruct. These experiences would not have happened if there had been better software quality. Assuring software quality has been and still is a thorn in the side of most software customers and project managers. This phenomena crosses all customer boundaries: commercial, industrial, military, other government; and crosses different application types: operating systems, information systems, process control, command and control, communication, business systems, etc. The "Software Quality" area contains four sessions that will enlighten both purchasers and developers of software with discussions and papers which will reveal not only current quality-related problems, but also suggested solutions. Dr. Edward Miller will chair a panel session on Software Quality Testing. Panelists will discuss the need for establishing and following quality standards, and programming and testing techniques to improve the testing process. Dr. Ned Chapin will chair a three-paper session on Software Quality Metrics. "Measuring program complexity in a COBOL environment" by Zolnowski and Simmons presents a composite measure of program complexity that provides an objective quantitative evaluation for any program or programming effort. Another paper, "The complexity of an individual program" by John McTap critiques the Zolnowski and Simmons model and proposes a model extension. The third paper, "An information theory based complexity measure" by Eli Berlinger proposes a measure of programming difficulty based on the probability with which various tokens of a program are used. Dr. Leonard Gardner will lead a panel discussion of accomplishments, problems, and proposed solutions of present and future software standards. These will encompass machine, assembly, and high level languages, and software related to buses and their interfaces. Panelists have been selected who represent a very broad base of standardizing activities of various technical societies and workshops. Mr. Kurt Fischer will lead a panel discussion of current software quality assurance problems and techniques. Topics of discussion will include the purpose of software QA, the techniques that are currently used, the benefits that are received from QA programs, and future directions that software QA should take. The selected panelists have all managed QA programs on major projects and will be glad to share their experience with the audience.
{"Source-Url": "https://csdl.computer.org/csdl/proceedings/afips/1980/5088/00/50880747.pdf", "len_cl100k_base": 7568, "olmocr-version": "0.1.50", "pdf-total-pages": 10, "total-fallback-pages": 0, "total-input-tokens": 28152, "total-output-tokens": 8568, "length": "2e12", "weborganizer": {"__label__adult": 0.00027441978454589844, "__label__art_design": 0.00030612945556640625, "__label__crime_law": 0.00020968914031982425, "__label__education_jobs": 0.0009512901306152344, "__label__entertainment": 6.049871444702149e-05, "__label__fashion_beauty": 0.00013577938079833984, "__label__finance_business": 0.0002574920654296875, "__label__food_dining": 0.0002363920211791992, "__label__games": 0.0005736351013183594, "__label__hardware": 0.00484466552734375, "__label__health": 0.000270843505859375, "__label__history": 0.0002015829086303711, "__label__home_hobbies": 0.0001137852668762207, "__label__industrial": 0.00045943260192871094, "__label__literature": 0.00017917156219482422, "__label__politics": 0.00013315677642822266, "__label__religion": 0.000347137451171875, "__label__science_tech": 0.022705078125, "__label__social_life": 4.792213439941406e-05, "__label__software": 0.0128326416015625, "__label__software_dev": 0.9541015625, "__label__sports_fitness": 0.00017070770263671875, "__label__transportation": 0.0003914833068847656, "__label__travel": 0.00012564659118652344}, "weborganizer_max": "__label__software_dev", "avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_ratio": [[0, 39700, 0.01137]], "fineweb_edu_fasttext_gt2__fineweb_edu_fasttext_gt2__score": [[0, 39700, 0.37742]], "ft_lang_id_en_doc_v2__ft_lang_id_en_doc_v2__en": [[0, 39700, 0.93608]], "google_gemma-3-12b-it_contains_pii": [[0, 4498, false], [4498, 10322, null], [10322, 12950, null], [12950, 18587, null], [18587, 22027, null], [22027, 27659, null], [27659, 31070, null], [31070, 36809, null], [36809, 39700, null], [39700, 39700, null]], "google_gemma-3-12b-it_is_public_document": [[0, 4498, true], [4498, 10322, null], [10322, 12950, null], [12950, 18587, null], [18587, 22027, null], [22027, 27659, null], [27659, 31070, null], [31070, 36809, null], [36809, 39700, null], [39700, 39700, null]], "google_gemma-3-4b-it_v2tag__is_academic_paper": [[0, 5000, true], [5000, 39700, null]], "google_gemma-3-4b-it_v2tag__is_class_syllabus": [[0, 5000, false], [5000, 39700, null]], "google_gemma-3-4b-it_v2tag__is_completion_certificate": [[0, 5000, false], [5000, 39700, null]], "google_gemma-3-4b-it_v2tag__is_court_notice": [[0, 5000, false], [5000, 39700, null]], "google_gemma-3-4b-it_v2tag__is_homework_assignment": [[0, 5000, false], [5000, 39700, null]], "google_gemma-3-4b-it_v2tag__is_news_article": [[0, 5000, false], [5000, 39700, null]], "google_gemma-3-4b-it_v2tag__is_public_order": [[0, 5000, false], [5000, 39700, null]], "google_gemma-3-4b-it_v2tag__is_resume_cv": [[0, 5000, false], [5000, 39700, null]], "google_gemma-3-4b-it_v2tag__is_test_or_quiz": [[0, 5000, false], [5000, 39700, null]], "google_gemma-3-4b-it_v2tag__is_textbook": [[0, 5000, false], [5000, 39700, null]], "pdf_page_numbers": [[0, 4498, 1], [4498, 10322, 2], [10322, 12950, 3], [12950, 18587, 4], [18587, 22027, 5], [22027, 27659, 6], [27659, 31070, 7], [31070, 36809, 8], [36809, 39700, 9], [39700, 39700, 10]], "pipe_delimited_lines_v1__pipe_delimited_lines_v1__pipe_delimited_lines_ratio": [[0, 39700, 0.06198]]}
olmocr_science_pdfs
2024-11-30
2024-11-30
8c8e16cc5af26a8fea7a7b587bc81a72718f084c
A review on various methods of collaborative computing Mohd Afiq Bin Zamanhuri¹, Zalilah Abd Aziz², Rose Hafsah Abd Rau³, Elly Johana Johan⁴, Noratiakah Shamsudin⁵ ¹²³,Faculty of Computer and Mathematical Sciences, Universiti Teknologi MARA, Malaysia ⁴Department of Computer Science and Mathematics, Universiti Teknologi MARA, Malaysia Article Info Article history: Received Dec 20, 2018 Revised Mar 17, 2019 Accepted Apr 11, 2019 Keywords: Centralized computing Collaborative computing Distributed computing Islamic lectures online Web-based ABSTRACT Currently, mosques in Malaysia distribute their lecture schedules either on paper-based form or by uploading the schedule on their social media platform. This has some disadvantages such as paper schedules are susceptible to damages and information on social media platform is often not updated to current changes. Collaborative Computing is a system that enable individuals to work together remotely by making use of the reach ability of the internet. In order to utilise the Internet’s obvious advantages over paper-based and rapid information distribution and asynchronous communication, a review is conducted to study the available methods of collaborative computing, further analyse current research papers. Result shows that Centralized Computing method is the most suitable method for developing collaborative mobile application for Islamic Lectures schedule. Copyright © 2019 Institute of Advanced Engineering and Science. All rights reserved. Corresponding Author: Mohd Afiq Bin Zamanhuri, Faculty of Computer and Mathematical Sciences, Universiti Teknologi MARA, 40450 Shah Alam, Selangor, Malaysia. Email: afiqzamanhuri@gmail.com 1. INTRODUCTION Seeking knowledge is a duty upon every Muslims. The advancement of Information and Communication Technology (ICT) have evolved most of our daily routine[1]. For example, the book of Allah, the Al Quran, can be find in numerous mobile application. Those applications also included the audio of the recitations with the translations of each word. Today, the internet has been the main medium to spread the teachings of Islam [2]. Most of the application took the asynchronous approach, even though the use of ICT offers strong learning settings and able to alter the learning and teaching process in an operative, self-directed way [1]. As discovered by Martin, Parker & Allred [3], some of the disadvantages of asynchronous virtual learning are less social interaction, the lack of immediate feedback, and students feel isolated. Thus, for learning Islamic knowledge, it is more appropriate to attend the physical lectures at the mosques. In Malaysia, apart from searching for the videos of Islamic lectures online, the people are still practicing the traditional way, which are go to the mosques, to listen to the lectures. Each mosque has their own paper-based schedule which is produced on monthly basis. The audiences depend on those schedules to know the information about the lectures. The problem with this method is the dissemination of the information. The audience may not notice the spreading of the schedule and the paper schedules are susceptible to damages. The schedule also may not be available to all audience because the audience may outnumber the quantity of the printed schedule. A paper-based schedule does not possess the ability of easy access to the internet. Furthermore, the traditional way has lack of notification function. There is no telling the mosque goers that the lecture has been cancelled. Besides that, there is no central hub that enables the user to access the schedule. The importance of having a one-stop access was verified by using social networking tools. Another example is a computer-based testing via the Internet shows that the internet allows a more diverse sample to be located as the participant can take the test at home without the need to go to the actual place of the test [4]. It is also reported that the internet can offer library resources including answer enquiries, catalogue search and information about new collections and lists, to convey general library information, and to offer online resources [5]. Lastly, the existing applications are not efficient. They are either not user-friendly or not supported anymore by the developer. The schedules are displayed in the form of low-resolution images [4]. The Islamic lectures are a kind of education bestowed upon an opportunity for the audience to contemplate different answers to major religious and moral issues to direct them in developing their interpretation in a reflective way [2]. Because of that, the schedules need to be spread in a better way, so that the audience can keep up-to-date with the lectures. Thus, this project proposed a solution to all the problems stated, which is a mobile apps schedule organizer for Islamic Lectures. It is a mobile application because almost everyone has their own mobile device. It works similar to the existing application, but the schedule of each mosque is handled by each mosque’s committee. Any mosque can put in their schedule into the system, and updating it later on. The system also has identification security. This decision is made in order to avoid any misconduct on producing any misleading schedule. This application will utilise the Internet’s obvious advantages over paper-based such as rapid information distribution and asynchronous communication. As stated in [1,6], those abilities are vital for a large community, where the sheer number of people involved makes face-to-face meetings costly and difficult to organise. This paper aims to fulfil three objectives, one of which is to study about Collaborative Computing and identify its various methods available. Collaborative Computing is a system that enable individuals to work together remotely by making use of the reach ability of internet [7]. Secondly is to analyse and make a review between the available methods and lastly to evaluate the most suitable method to apply for the project. This project aims to develop a one-stop mosque’s lecture schedule application which involve two kind of users; first the public user which can only view the updated schedule and secondly, the administrator, which are the mosques’ committee who can create, update and modify the schedule. Furthermore, this application can act as a one-stop information hub about the schedule of Islamic lectures. Besides, it can also provide reminders to community about the lectures available. Finally, the users will be able to view the schedule of desired mosque on that current month. Thus, before development phase, the next section will be discussed in depth on the literature review on system’s architecture, to better understand its structure. 2. LITERATURE REVIEW As explained in previous section, the proposed solution differs from the existing application by involving the mosque’s committee to input their schedule into the system. This collaboration act is the core principle of the system and this led to the selection of Collaborative Computing to be the mainframe for this system. Table 1 shows the existing applications characteristics. <table> <thead> <tr> <th>Criteria Apps</th> <th>Recent Update</th> <th>Function for Schedule Update</th> <th>User Interface and navigation</th> </tr> </thead> <tbody> <tr> <td>Jadual Program Agama</td> <td>2014</td> <td>Yes, but any user can update any mosques schedule</td> <td>- Minimalist approach</td> </tr> <tr> <td>Kuiliah Agama</td> <td>2014</td> <td>Yes, but the developer needs to update it</td> <td>- Have a “Search” function.</td> </tr> <tr> <td>Majlis Ilmu Pulau Pinang</td> <td>2017</td> <td>Yes, but the developer needs to update it</td> <td>- Cluttered</td> </tr> </tbody> </table> By definition, Collaborative Computing is essentially a system that enabling individuals to work together remotely by making use of the reach ability of internet [7]. Collaborative computing can connect individuals to software applications in real time, so they all can access and simultaneously work on text-based documents, graphics, computer-aided design files and other work products. Thus, this concept is suitable for the authors’ project, as the mosque committee themselves will create the monthly schedule and upload it into the application. The prime examples of the early Collaborative Computing are online video and audio conferencing. Previously, this technology aimed to bridge communications that is physically limited. Since then, Collaborative Computing has evolved that introduced real-time environment which enables documents to be edited simultaneously in a workgroup. Nowadays, cloud computing also features Collaborative Computing service. Among its benefits, it provides a collaborative environment workgroup computing, optimizes productivity, and fosters innovation. Previously, Collaborative System co-dependent to telecommunications network as the primary communication medium. Since then, they can be used by devices... that connected to local area networks (LANs). Beyond these characteristics, Collaborative Computing can be divided into two categories based on their operation which are Centralized Computing and Distributed Computing. In the next two sections these categories will be explained in detail. 2.1. Centralized Computing In this method, the architecture’s processing is being done in all or mostly in the central device. The method is very much alike to the client/server architecture where the central device is connected to a number of remote devices. The central server is deployed as the main application or hub that has massive computing resources, storage and other additional features. As the foundation of Collaborative Computing architecture, one or more remote devices are directly connected to a main device. In turn, the main device is responsible for delivering application’s logic, processing and providing computing resources to the attached devices. Because of this, the administrator in a centralized computing infrastructure will manage all the connected remote machines from the central machine interface. Apart from the obvious features that can be seen directly from the method’s characteristics, the other features of Centralized Computing are as follows: - As all the remote devices are connected to the main device, thus, all means and resources are obtainable. - The new connections between the computing system’s office locations and the data centre are normally of low capacity, short delay or uncertain. - The programming language used is the same throughout the development phase. Centralized Computing system has several advantages. One of such is that the database can be easily managed as all of the data about the schedule will be located in single repository. The data stored is easier to be changed, re-organized, mirrored, or analysed and the data will be a lot secure. Furthermore, the data redundancy will be at minimum because as researched by [8] as there will be no additional registries of the same patients need to be built to ensure the compatibility of Red Blood Cell unit of that patients’ as long as they are transfused only at the hospitals that have access to the same database. Other advantage is Centralized computing processing reduces the expenditure as it does not point up on additional machines and hardware. As the main devices doing most of the processing, the disadvantages will be from that main device. Firstly, it demands a large data storage, as the main device will usually create and store the data. Besides that, the central machine will be an easy target for malicious threats and it is not suitable for the use of different hardware and vendors. Furthermore, the devices’ ability to response is reduced to the information request timely. Lastly, the system will require a high cost in transmitting transactions. 2.2. Distributed Computing Distributed computing is a field of computer science that studies distributed systems, a system whose components are located on different networked computers, which then communicate and coordinate their actions by passing messages to one another. In this architecture, information processing is not confined to a single device rather it is distributed over several independent computers, thus, the associated devices shared tasks as well as program components. This task-sharing method can improve the overall system’s efficiency and performance as any modification can be done without affecting the overall system [9]. Distributed system consists of middleware that manage or support the different components of a distributed system. It provides a buffer between the applications and the network. Figure 1 shows the general Distributed Computing infrastructure. The basis of a distributed computing is its transparency, accessibility and scalability. For transparency, it is important for a distributed system to hide the location of its process and resource. Besides that, is an important goal of distributed system in which it be accessible of using hardware and software from different vendors. Furthermore, scalability of the system is measured along three different dimensions. First, a system can be scalable with respect to its size which can add more user and resources to a system. Second, users and resources can be geographically apart. Third, it is possible to manage even if many administrative organizations are spanned. As proven by [10], in a distributed computing framework, able to employed the Minimum Bandwidth Code and achieving a scalable architecture with a constant load of communication. One of the advantages of Distributed Computing is allows the processor to be used to share processing when not being used for other activities. The data used locally can be stored locally and network traffic kept to a minimum and if the data is lost on central site, it can be reduplicated from local site. Distributed system also able to continue its operation even after an error has occurred. On the flip side, in term of complexity, a Centralized system is simpler than Distributed system. Other than that, it is more susceptible to external attack, as all the data is not stored in one location if a local site does not have location adequate backup. It also has a higher overall cost than Centralized system. Lastly, the system’s data is prone to inconsistency. In the next section of this paper, there is an analysis on the current research that has been done for these two methods. 3. ANALYSIS The purpose for this analysis is to weigh-in the features for both Centralized Computing and Distributed Computing and selecting which is the most suitable to be applied to the system. A study of requirement for software development as in [12, 13] are also analyzed. The analysis involved eight current research papers and their results were evaluated. To help with the decisions, the researches were analysed and evaluated for the outcome. 3.1. Peaynotes: A Generic Web-Based Patient Clinical Notes Sharing System for Health Care Professionals This research has been focusing on advancing the current note-taking method. The main problem is the inefficiency of current practice which the nurses need to wrote down notes then turns it to digital notes [14, 15]. They also noticed the high cost of the technologically-advanced simulation system which hinder the hospital into taking such route. A proposed collaborative mobile application, called Peaynotes, replacing the current method. It is a modifiable bedside reporting tool and documentation of care system to be utilized during clinical simulation experiences. One of the features stated in that research is that the application has ability to retrieve valuable patient information to aid in effective communication during hand-off. It was developed using WordPress and follows the Centralized Computing method. In complete contrast from the research above, this paper used the cloud computing for eLearning collaboration system. The main issue that make the researcher chose cloud computing is that the traditional web-based e-learning mode models lack the underlying infrastructure that are highly scalable and can dynamically allocate the required computation and storage resources. Besides, the building and maintenance are located onsite which causes a lot of problems for institutions. Thus, they had proposed Cloud-Collaborative E-Learning Architecture that consists of 5 layers [16]: - Infrastructure layer - Software resource layer - Resource management layer - Service layer - Application layer Based from the paper, cloud computing has several security benefits, such as improved improbability and easy data monitoring. Cloud computing also invulnerable to system crashes since critical applications and data are stored in the cloud. 3.3. Developing Distributed Computing Applications with Tasklets In this paper, it is not the whole system is proposed, instead a middleware of distributed computing system was proposed, in a form of Tasklets. The tasklet system allows developers to offload self-contained units of computation to a pool of heterogeneous computing devices. These tasklets approach was proposed is because of the increasing demand for computational performance of pervasive applications. It is a lightweight middleware thus, not affecting the performance of the connected devices. Once the Tasklet was executed and are connected to a broker they can contribute their computation power in form of virtual machines and run applications that offload computation via Tasklets [17]. 3.4. An Energy-Optimal Scheduling for Collaborative Execution in Mobile Cloud Computing For mobile application, the resources are very much limited for any serious processing. Thus, this research investigated the possible route for collaborative computing. Besides of resource limits, the other problem stated in the paper is Information such as the communication channels or the computation workload... (Mohd Afiq Bin Zamanhuri) may change in different conditions because of the various versions of mobile devices. [18]. The researchers turned to the centralized-method cloud computing for the solution, which producing energy-optimal scheduling policy for collaborative execution in mobile cloud computing network. This policy has low-complexity threshold adaptation scheme for dynamical constrains of execution time in mobile cloud computing. 3.5. Trustworthy Distributed Computing on Social Networks Different from the previous researches, this study focused on the huge network of social network. The researchers highlight the flaws cloud computing such as the need for architectures to support various potential applications, programming models to address large scale datacentric computing, new applications that benefit from the architectural and programming models in the cloud, and the need for strong security and data privacy protection guarantees [19]. Thus, a solution that is called SocialCloud was proposed. It is a distributed computing service that recruits computing workers from friends in social networks and use such social networks that characterize trust relationships to bootstrap trust in the proposed computing service. 3.6. Task-Technology Fit and User Adoption of Cloudbased Collaborative Learning Technologies In this research, they study the acceptance of cloud-based collaborative learning technologies and gauges it using Task-Technology Fit (TTF) model to find factors that play a significant role. Their problem statements are the traditional teaching learning methods are not sufficient to support the expectations of academics and students in universities and there are no studies have looked at cloud usage and acceptance in a university setting [20]. The results are cloud applications with more personalized, mobility, and collaboration characteristics are more appropriate to support collaborative learning. In addition, non-routine tasks have negative influence on Task-Technology Fit. As the papers above have given a series of insight, the next subsection will discuss on the other disadvantages of both methods. 3.7. Other Issue on Collaborative Computing After pointing out all the important points in those papers, it should be noted that there are several other issues that need to be addressed [21]. One of it is that the Centralized computing may have issues similar to client/server architecture because both look the same in structural sense [22]. Another issue is to consider the attributes that can contribute to algorithmic problem solving competencies [23]. Because of the complexity of Distributed Computing, enforcing a good security is equally complex as founded by [24] the system may require multi-level resource isolation to prevent inter-cluster access to network traffic and [25] cryptographic entropy is needed to secure the communications. After reviewing all the researches and issues of the two methods of Collaborative Computing, the characteristics of those methods are summarized in Table 2. | Table 2. The Characteristics of Centralized Computing Method | |---------------------------------|----------------|----------------| | Criteria | Centralized Computing | Distributed Computing | | Overall Cost | Lower | Higher | | Vulnerability to threats | Lower | Higher | | Complexity | Simpler | Complex | | Storage Needed | Bigger | Smaller | | Transparency | None | Obscure | | Scalability | Poor | Good | | Accessibility | Low | High | From above table, each of the method have its pros and cons, so, this can be used as a benchmark in selecting which methods works best for the project. The last section of this paper will discuss on the result of the analysis and future works of this project. 4. CONCLUSION AND FUTURE WORKS After considering all the key points from the research papers, and by refereeing to the criteria from Table 2, the Centralized Computing method proved to be the best alternative. There are several reasons to support this selection. First of all is the lower overall cost as the centralized system cost will focus solely on the main machine. The cost also can be flowed to the storage as it needs a larger capacity of storage. Secondly, the system will be more secure even though the main device will be the only target. While the data backup plan is not as robust as the Distributed Computing system, but by having a good programming, this is makes data easy to secure and monitor. Lastly, while the chosen method has low hardware accessibility, but with Internet, the gap can be bridged as the proposed system is a web-based system. For future works, the project will proceed to its development phase to create a prototype of the system. The prototype will be focused on the main functionality of the system, which is the creation of the schedule and the display of the schedule. ACKNOWLEDGEMENTS Funding for this research was provided by Lestari Grant (0129/2016), Universiti Teknologi Mara. REFERENCES A review on various methods of collaborative computing... (Mohd Afiq Bin Zamanhuri) **BIOGRAPHIES OF AUTHORS** Mohd Afiq Bin Zamanhuri Education: - Bachelor of Computer Science (Multimedia Computing), UiTM - Diploma in Information Technology, Cosmopoint College Research Interest: Multimedia, Collaborative computing Zalilah Abd Aziz (Dr.): Senior Lecturer Education: - PhD in Computer Science (Artificial Intelligence) University of Nottingham - MSc in Computer Science (Software Engineering) UPM - BSc (Hons) Sains Komputer, ITM/UKM Research Interest: Software Quality, Software Engineering, Artificial Intelligence, Combinatorial Optimization Problems, Metaheuristics, Programming Rose HafsaH Abd Rauf (Dr.): Senior Lecturer Education: - PhD, (Computer Science) Swansea University, Wales, UK 2008 - SSn (Sains Komp) UKM, 1997 - BSc (Comp Sc) USM, 1985 Research Interest: Programming Language, Theory of Computation, Steganography, Computer Science Education, Digital Forensics Elly Johana Johan :Senior Lecturer Education: - Bachelor of Information Technology (Hons.), UiTM, Malaysia (2000) - Diploma in Computer Science, UiTM, Malaysia (1998) Research Interest: Programming, Computer Science Education, Persuasive Technology Noratikah Shamsudin Education: - M.Sc IT (UKM, Bangi), 2000 - B. Sc (Hons) Computer Science (UTM, KL), 1990 - Diploma in Computer Science (UTM, KL), 1988 Research Interest: Programming, Computer Science Education, Multimedia
{"Source-Url": "http://ijeecs.iaescore.com/index.php/IJEECS/article/download/19903/13118", "len_cl100k_base": 4811, "olmocr-version": "0.1.53", "pdf-total-pages": 7, "total-fallback-pages": 0, "total-input-tokens": 23280, "total-output-tokens": 7023, "length": "2e12", "weborganizer": {"__label__adult": 0.0005517005920410156, "__label__art_design": 0.0009222030639648438, "__label__crime_law": 0.0009746551513671876, "__label__education_jobs": 0.09893798828125, "__label__entertainment": 0.0002148151397705078, "__label__fashion_beauty": 0.00029730796813964844, "__label__finance_business": 0.0008859634399414062, "__label__food_dining": 0.0007114410400390625, "__label__games": 0.001155853271484375, "__label__hardware": 0.004161834716796875, "__label__health": 0.0019102096557617188, "__label__history": 0.0009450912475585938, "__label__home_hobbies": 0.00030922889709472656, "__label__industrial": 0.0007925033569335938, "__label__literature": 0.0012102127075195312, "__label__politics": 0.0007166862487792969, "__label__religion": 0.003662109375, "__label__science_tech": 0.26953125, "__label__social_life": 0.0008363723754882812, "__label__software": 0.12152099609375, "__label__software_dev": 0.488037109375, "__label__sports_fitness": 0.0003783702850341797, "__label__transportation": 0.000797271728515625, "__label__travel": 0.0004596710205078125}, "weborganizer_max": "__label__software_dev", "avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_ratio": [[0, 30006, 0.02869]], "fineweb_edu_fasttext_gt2__fineweb_edu_fasttext_gt2__score": [[0, 30006, 0.38871]], "ft_lang_id_en_doc_v2__ft_lang_id_en_doc_v2__en": [[0, 30006, 0.91162]], "google_gemma-3-12b-it_contains_pii": [[0, 3847, false], [3847, 8969, null], [8969, 14484, null], [14484, 18058, null], [18058, 22867, null], [22867, 28060, null], [28060, 30006, null]], "google_gemma-3-12b-it_is_public_document": [[0, 3847, true], [3847, 8969, null], [8969, 14484, null], [14484, 18058, null], [18058, 22867, null], [22867, 28060, null], [28060, 30006, null]], "google_gemma-3-4b-it_v2tag__is_academic_paper": [[0, 5000, true], [5000, 30006, null]], "google_gemma-3-4b-it_v2tag__is_class_syllabus": [[0, 5000, false], [5000, 30006, null]], "google_gemma-3-4b-it_v2tag__is_completion_certificate": [[0, 5000, false], [5000, 30006, null]], "google_gemma-3-4b-it_v2tag__is_court_notice": [[0, 5000, false], [5000, 30006, null]], "google_gemma-3-4b-it_v2tag__is_homework_assignment": [[0, 5000, false], [5000, 30006, null]], "google_gemma-3-4b-it_v2tag__is_news_article": [[0, 5000, false], [5000, 30006, null]], "google_gemma-3-4b-it_v2tag__is_public_order": [[0, 5000, false], [5000, 30006, null]], "google_gemma-3-4b-it_v2tag__is_resume_cv": [[0, 5000, false], [5000, 30006, null]], "google_gemma-3-4b-it_v2tag__is_test_or_quiz": [[0, 5000, false], [5000, 30006, null]], "google_gemma-3-4b-it_v2tag__is_textbook": [[0, 5000, false], [5000, 30006, null]], "pdf_page_numbers": [[0, 3847, 1], [3847, 8969, 2], [8969, 14484, 3], [14484, 18058, 4], [18058, 22867, 5], [22867, 28060, 6], [28060, 30006, 7]], "pipe_delimited_lines_v1__pipe_delimited_lines_v1__pipe_delimited_lines_ratio": [[0, 30006, 0.08152]]}
olmocr_science_pdfs
2024-12-10
2024-12-10
1fbf76ef02c02f675ce726fb663e787a357de5d9
An Ideal of Software Engineering C. A. R. Hoare September 1, 1995 In 1980, the well-known electronic instrumentation company Tektronix, suddenly woke up to the fact that they were a software company. More than half of the professional engineers they employed were now programmers. And yet all their middle and senior management were electronics engineers, risen from the ranks, with no understanding of software or how to manage or control it. They took immediate action, sending the manager who could soonest and easiest be spared to a one-week software engineering tutorial. I am afraid it was not enough. Soon after, the Company decided that they could spare the manager altogether; and so began a period of relative decline in fortune, from which now they have emerged. This story has a converse. A Company like IBM, which long ago realised that it was a software company and took appropriate measures, now finds new life as an aircraft company. I believe the prime contractor for the supply of helicopters to the British Royal Navy is IBM. These are two examples of what I call the software revolution. The same revolution has rapidly overtaken the traditional telecommunications industries. With a certain element of exaggeration, you could say that everything that this industry regards as its own preserve, all that vast network of hardware - handsets, displays, wires, fibres, switches, links, antennae, satellites - everything except the physical holes in the ground and the towers in the air - is controlled by software or soon will be; they are just peripheral equipment, as it were, to the computers which run the programs. Software is the magic ingredient which realises the growing potential of recent and predicted advances in the hardware. It is software that adds value, that assembles the components into saleable systems, products and services. Hardware components will be manufactured in increasing volumes and supplied at reducing cost to all the players in the communications marketplace opened up by deregulation. It is the software that will determine competitive advantage, and distinguish the winners from the losers. So what is this discipline of Software Engineering? How does it compare and differ from other Engineering disciplines? And how far can it be regarded as mature? These are the questions that I shall address this afternoon; and I will end with an appeal to the communications industries and to higher education to collaborate even more closely in seeking the answers. The most strikingly visible difference between software and other engineering products is the almost total invisibility of software. There is absolutely nothing photogenic about software, and absolutely no joy in building scale models of its operation. And even less can it be touched, felt, heard, smelled or tasted. It seems to be nothing more than the abstract disembodiment of pure complexity. As a corollary, software is a product where the cost and time required for manufacture and distribution are close to absolute zero. All the expense and delay is in design and development - and later in marketing and sales. Historically, this has made software a very difficult area in which to gain recognition for sound research in Universities, or in which to exercise sound planning, management, and control in Industry. But of course the cruder parameters of software can readily be measured. Over the last ten years, such measurements often show that the length of computer programs embodied in a typical product have grown, perhaps by a factor of ten; that they have cost ten times as much to develop, that they are proportionately more likely to contain errors detected in service, and each error could potentially be ten times more damaging in its effect. Hardware has in the same time made equally rapid progress but fortunately in the opposite direction. It is now ten times smaller, faster, cheaper, and more reliable. I really shouldn't have embarked on this comparison, so dreadfully unfavourable and unfair to software engineers. Let's change the subject quickly, and concentrate on the much more important similarities between software and other branches of engineering. Firstly we share the same goals; they were nicely defined for Civil Engineering by Thomas Tredgold in 1828 - "the art of directing the great sources of power in Nature for the use and convenience of man". Secondly, the success of any engineering project requires full attention to the implications of marketing, commerce, accountancy, management, and even politics. But the single feature that differentiates all of engineering and science from all these other important practical concerns is the explicit, crucial and pervasive use of the techniques and notations of mathematics. Each branch of science seeks mathematical theories, or models of selected aspects of physical reality. The scientist uses mathematics to predict from the theory its observable consequences, which are then checked by careful experiment. The engineer on the other hand uses a validated scientific theory to check the performance parameters of a design before it is put into production. That for example, is why our buildings and bridges no longer blow down very often. In a mature engineering discipline the direction of the mathematical calculations is reversed. Start with a mathematical model of the customer's requirements. Decide the general strategy and structure of the solution; and then with the aid of calculation derive the content and detail of the design, including optimisation of relevant parameters. The design now needs no further test or check - it is correct by construction. This reversal from bottom-up predictive mathematics to top-down design calculations is the goal of all research into engineering method, in all branches of engineering, and especially software engineering. But this simple story has ignored the incredible complexity of the symbolic and numerical calculations required by modern science and engineering. To limit this complexity, science presents not just a single model of reality, but rather a whole hierarchy of models, dealing with phenomena at differing scales, at differing degrees of granularity, and at differing levels of abstraction. For example, starting at the level of chemistry, physics offers the hierarchy - molecular dynamics, - atomic theory, - elementary particles, - chromodynamics. Each level has its own autonomous concepts and its own model, which can be understood and used independently of the others. It is the general goal of the pure scientist to secure the links between the levels, defining the concepts at each level in terms of the previous one, and then proving its axioms as theorems in the previous theory. A similar hierarchy of levels of abstraction is equally necessary in engineering. For example in design of computer hardware we separate - instruction set - register path - microcode and control - combinational design - switch level design - circuit electronics. Here again, at each level there is a different conceptual framework, a different notation, and a different calculus of design. A complete design at each level of abstraction serves as a specification for the design at the next lower level. It is the particular goal of the practising engineer to ensure that a specification at each level is correctly and efficiently implemented by the selected design at the next lower level. Communications engineers engaged in the design of protocols are familiar with the famous seven levels of the international standard • Application • Presentation • Session • Network • Transport • Data link • Physical level. The general principle of the hierarchy has been very successful. At the higher levels, there has been some delay in finding and agreeing on the appropriate abstract concepts for formulating the standard; but this kind of conceptual engineering is the necessary condition for breakthrough in any branch of science, or indeed any kind of intellectual endeavour. Just saying that is never going to make the discovery easy to make, however simple it may seem afterwards. At the lower levels of the protocol hierarchy, maintenance of the design structure throughout the implementation can cause problems of efficiency; but these are solved with the aid of correctness-preserving transformations, which combine the benefits of structured specification and design with highly optimised implementation. Software engineers can learn a lot from this transformational approach to specification and design. Software engineers also have a hierarchy based on scale and granularity. They talk of • systems • modules • classes • objects or processes • functions and subroutines • straight line code • individual instructions. The mathematical theories which are useful for design calculations at each level have been to a large extent developed by software engineering research, and the transitions at the lower levels have been successfully formalised and even automated. The results of this research are being gradually assimilated into industrial practice. Progress is slowed by a general antipathy to mathematics among software engineers - but this feeling is yet another characteristic which is shared with other branches of engineering, and indeed with most of management, and with the general population. Mathematics itself provides an outstanding example of the control of complexity by structure and abstraction. Its branches can be arranged in a hierarchy like those of physics - topology abstracts from analysis; analysis provides the basis for calculus; and calculus can be used by engineers who understand nothing of the more abstract foundations. Even within a single branch of mathematics, a lemma can be safely used without studying the complexity of its proof, a theorem abstracts from the complexity of its lemmas, and a theory from the collection of its separate theorems. Similar structures are observable in good programming practice, where larger programs use smaller ones as subroutines, or subobjects, or subprocesses. But this analogy is good only if the formal statement of the function and purpose of each subroutine is as simple and complete as that of a mathematical theorem, and an order of magnitude simpler than the code which implements it. Furthermore, the reliability of the code must also approach that of a mathematical theorem. A large system constructed from even slightly unreliable components can rapidly collapse, either before or after delivery. Reliability is the very essence of engineering, and it is achieved by explicit appeal to the concepts, methods, abstractions and structures of mathematics. But, ironically, it is not to the traditional applied branches of continuous mathematics that the software engineer turns for guidance, but rather to the traditionally pure branches of discrete mathematics, - set theory, algebra, and even category theory. The reason is that software engineering deals very largely with discrete phenomena, transitions, events, values and structures. At the lowest level we have just the two discrete Boolean values, zero and one. In a large program if just one of these digits is changed, even only for just one millisecond, the consequences for the whole program, indeed the whole system, are in practice quite unpredictable, and in principle potentially disastrous. This means that the software engineer cannot rely on smoothness or continuity in the control of tolerances or error. Numerical approximation is simply not available as a technique to simplify calculations. Since there is no appropriate metric, worst case analysis and worst case testing are just not available. For the same reason there is no freedom to get it nearly right; even if there were, there is no way that this would simplify the task of design and implementation. Approximation, even to the extent of order-of-magnitude calculation, is the stock-in-trade of the engineer, the most important way of maintaining intellectual control at the early stages of design and throughout the later implementation. In the discrete branches of engineering, for these purposes we have to rely almost wholly on structure and abstraction. The gap between continuous and discrete engineering is one that puts nearly all modern telecommunications and electronic hardware design on the same side as software engineering—certainly all of network design down to the individual switch, and all of VLSI design, down to the individual logic gate. To cover this range of disciplines perhaps I should use a more neutral term like Discrete Systems Engineering, or a more fashionable one like Information Engineering. Under whatever title, I believe that we will see by the year 2000, a strong convergence in the practice of engineering of software, hardware and communications. The communications industries will be the first to realise and benefit by this convergence. This convergence of communications, hardware, and software engineering is simply and elegantly illustrated in mathematical theories known as process algebras, developed over the last twenty years by basic research in Universities. The theory combines the concepts of conventional sequential programming with the kind of concurrency which is embodied automatically in every combination of hardware components, and the kind of communication which occurs almost naturally whenever hardware components are connected by wires. The theory has already served as the basis of a draft international standard (LOTOS) for the definition of protocols, for the design of a programming language (OC-CAM), and a microprocessor (the transputer), and the design of several silicon compilation languages. But the mathematical theory is much more general; with slight variations, it can be applied on every scale and at every level of abstraction and every level of granularity, from the customer's view of the services required of the system as a whole, through the design of the major components of the network and the interfaces between them, down to their implementation on a collection of processors and special purpose application specific hardware, interacting with each other at any distance. It is this appeal to abstraction that permits theories tested in the Laboratory to be cautiously scaled up for industrial application. The uniformity of the mathematical foundation permits all stages of the design and implementation to be related by calculation and proof. Many of the stages of adaptation and optimisation can be codified and carried out (or at least checked) by automatic transformation systems. It is this that promises not only an increase in the quality and reliability of the product, but also a reduction in the time to market. It is experience with this kind of practically applicable theory that leads me to predict that discrete systems engineering is making rapid progress towards the status of a mature engineering discipline and maybe will reach it by the year 2000. A fully mature discipline will have the following characteristics. - It puts the customer first. - It codifies corporate strategy. - It puts management in control. • It magnifies human intellect. • It builds its own tools. • It is the language for professionals. • It is transmitted by education. A mature engineering discipline puts the customer first. It starts with a scientific investigation of the actual characteristics and behaviour of the customer population, not just as individuals but as members of their societies; in the workplace, school or home. It takes full advantage of the methods and results of the human sciences, - physiology, psychology, linguistics, sociology. It analyses stated requirements and stated assumptions until a clear picture emerges of some desirable future product or development that will satisfy the true requirements, which have often been left unstated. The mismatch between perceived and actual requirement is one which must be overcome by good marketing. Meanwhile, the engineer must attempt, as soon as and as far as possible, to construct a faithful mathematical model of both the numerical and discrete properties of the projected and desired interactions between the community of customers and the projected product or service. This is the first and most important interface to define; it is the basis of all subsequent engineering design, and any lapse of judgment here could lead to a product that is undeliverable or unusable. The pace of change is no longer driven solely by technology; in software especially, the technology must be driven by the customer. A mature engineering discipline formulates strategic policy. No large enterprise can afford to design and deliver a single product at a time, no matter how advanced the technology or how timely its introduction to the market. The real challenge is to design an architecture for a family of products, covering not one but a range of markets, with not just one product in each market but a series of complementary, supplementary, enhanced and eventually replacement products, stretching into the foreseeable future. The strategy must be presentable in abstract terms at Board level, so that it can be correlated with financial management, marketing, resource planning, and ultimately with the image that the enterprise wishes to have of itself. The engineering discipline must provide the appropriate abstractions and theories to define the structure and interfaces of the entire family long before any of the detailed design begins; and this must be backed by enterprise-wide engineering standards which give assurance that the strategy can be implemented as planned. The days of innovation as adventure are over. In the framework of strategic policy, innovation is routine. A mature engineering puts management in control. Each level and branch of management can understand, within a self-contained intellectual framework, all the objectives and activities of subordinate levels, and can take confident responsibility for the way in which these contribute to the goals of superior levels. The confidence is based upon abstract but precise formalisation both of the vertical and of the horizontal interfaces throughout the management hierarchy. The confidence is justified by mathematical calculations, which establish in advance of implementation that if each subordinate goal is met, the superior goal is guaranteed. Complexity is controlled by correlating levels of management with levels of abstraction, so that problems and delays can no longer be hidden under a morass of technical detail. In spite of the intangibility of software, signs of trouble are immediately visible, and if change is required in the design or in the interfaces, the manager can explore and report all the wider consequences of the change before authorising it. As a result, there are few last-minute surprises. When the components are delivered, they slot together without prolonged integration testing, they can be delivered immediately with minimal risk of feature interactions discovered in service. "Design right first time" is no longer a slogan but has become a habit. A mature engineering discipline releases the full potential of the human intellect. Because specifications are expressed at the highest possible level of abstraction, they give the widest possible scope for exercise in design skill, ingenuity and inventiveness of the human engineer. The mathematical theory defines the boundaries of the design space, and provides the method by which it may be thoroughly explored. As new ideas emerge, they can be crystallised with the aid of mathematical formulae, which can be objectively discussed, evaluated, justified or even admired. Finally when the design is frozen, it can be made sufficiently precise for reliable implementation by teams of less experienced or inventive engineers or technicians. A mature engineering discipline constructs its own design tools. The validity of the methods which transform specification to design and design to implementation is assured by their basis on the well-established scientific theories which underlie the discipline. Only parts of the tool are fully automatic; at all crucial stages, guidance is needed from the skilled and experienced engineer, who has the understanding and inventive talents to direct the design towards a cost-effective solution. The only contribution of the tool will be to calculate of few parameters, and to organise the mass of associated detail in a manner which ensures correctness by construction. In future, the programming of individual lines of C-code will seem as archaic as laying out individual transistors and wires on a silicon chip. But even when a tool is really successful, the general impression should be that it only does the easy bits. A mature engineering discipline provides a language for communication among professionals specialising in its various branches. The underlying mathematical theory not only explains their common foundations, but explains why and for what purposes it is necessary to differentiate them. There is no longer any need for clamorous conflict between the various branches of software engineering, each claiming exclusive merit for a single computational paradigm: the functional programmers, the logic programmers, the object-oriented programmers, and the no-nonsense hewers of hardware or hackers of C. Any large system will have components constructed from a variety of technologies; and the interfaces between the technologies, which is where most of the problems of engineering arise, are controlled by the abstractions of the underlying general theory. Finally, a mature engineering discipline is transmitted to future generations of engineers by further education. Its theoretical foundations, their abstraction and elegance, can be taught as a free-standing mathematical discipline at University or even at school. Its methods and principles can be illustrated on a small scale by student demonstrations, experiments and exercises. By repeated exposure at many different levels to the transition between abstraction of specification and details of implementation, the student comes to understand how the techniques generalise to an industrial scale of application. When this education has been complemented by a period of industrial experience, the educated engineer is intellectually equipped to rise through the management hierarchy to the very highest levels. This brief and idealised account of engineering education contrasts strongly with the training on the job, which was the only training available when I entered the profession in 1960, and is still the norm today. We learnt programming in a wholly operational fashion, by trying to understand the behaviour of the computer which is executing the program. Execution traces are the only means we had of understanding and removing errors. Errors were regarded as inevitable, because we had no technology to avoid them, even in principle. We hardly recognised the possibility that a complex program might have a simple specification, of far greater benefit to the customer than the implementor. Lengthy and total immersion in operational detail actually inhibited progress towards understanding of the necessary simplifying abstractions. When it became necessary to learn a new programming language or use a new operating system, training was based on the voluminous manuals which accompany the software. Because there was no common culture or education in the understanding of abstraction, these manuals too have to be based on the lowest level of operational detail. Their volume, complexity, and structural deficiencies absorb all the intellectual energy of the student; and yet they were so incomplete or even inconsistent in detail that, when used in earnest, the only way of finding out what the software will actually do is by experimental trial and error. The tool which should be helping has become part of the problem. The absence or even conscious avoidance of mathematical abstraction in programming education explains why many programmers have often been regarded more like craftsmen or technicians than engineers. They are wonderful people, with experience and skills greatly to be admired and valued. But they work best in isolation on self-contained tasks. They have no language to discuss, explain and justify their work to their colleagues and superiors. Documentation is their bane. They do not read the technical literature to keep abreast of their field. On promotion, they find it difficult to establish or maintain intellectual control of the work of their teams. That is why it is rare for the best programmers to rise to the higher levels of management. Yet it is not conducive to the health of the enterprise when the worse ones do. The transition between a craft and a mature engineering discipline is always fraught with confusion, difficulty, animosity and charlatanism; and the intangibility of software has certainly prolonged the agony. Most of industry and commerce in Britain is prepared to wait for magic solutions to emerge, and then to buy them in from across the Atlantic. But the more far-sighted enterprises can see the competitive advantage to be obtained by rapid transition to an engineering attitude towards software. Among them, the telecommunications industries, for motives which have been explained at this meeting, are playing a leading role. It is essential to them to raise the educational level of their software engineers, by in-service courses for experienced programmers and their managers, by promoting the quality and relevance of the subject in higher education, by promoting research at the interfaces between technologies; and by attracting the very best of the graduate population into their teams and eventually into their management. Divergence of culture between traditional communications engineers and the new software engineers educated at leading Universities must not be allowed to hinder the flow.
{"Source-Url": "http://www.cs.ox.ac.uk/files/6028/H95%20-%20Ideal.pdf", "len_cl100k_base": 4720, "olmocr-version": "0.1.53", "pdf-total-pages": 13, "total-fallback-pages": 0, "total-input-tokens": 13897, "total-output-tokens": 5200, "length": "2e12", "weborganizer": {"__label__adult": 0.00032639503479003906, "__label__art_design": 0.0004589557647705078, "__label__crime_law": 0.00024771690368652344, "__label__education_jobs": 0.00371551513671875, "__label__entertainment": 7.176399230957031e-05, "__label__fashion_beauty": 0.00015103816986083984, "__label__finance_business": 0.00030612945556640625, "__label__food_dining": 0.0004029273986816406, "__label__games": 0.0004968643188476562, "__label__hardware": 0.0009565353393554688, "__label__health": 0.0003867149353027344, "__label__history": 0.00021278858184814453, "__label__home_hobbies": 0.00012540817260742188, "__label__industrial": 0.00046181678771972656, "__label__literature": 0.0003817081451416016, "__label__politics": 0.0001709461212158203, "__label__religion": 0.0005059242248535156, "__label__science_tech": 0.0210113525390625, "__label__social_life": 0.00014770030975341797, "__label__software": 0.006320953369140625, "__label__software_dev": 0.96240234375, "__label__sports_fitness": 0.0002532005310058594, "__label__transportation": 0.0004761219024658203, "__label__travel": 0.00014972686767578125}, "weborganizer_max": "__label__software_dev", "avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_ratio": [[0, 26134, 0.00427]], "fineweb_edu_fasttext_gt2__fineweb_edu_fasttext_gt2__score": [[0, 26134, 0.7006]], "ft_lang_id_en_doc_v2__ft_lang_id_en_doc_v2__en": [[0, 26134, 0.95812]], "google_gemma-3-12b-it_contains_pii": [[0, 1682, false], [1682, 3897, null], [3897, 6166, null], [6166, 7600, null], [7600, 8777, null], [8777, 10940, null], [10940, 13190, null], [13190, 15229, null], [15229, 17305, null], [17305, 19582, null], [19582, 21756, null], [21756, 24018, null], [24018, 26134, null]], "google_gemma-3-12b-it_is_public_document": [[0, 1682, true], [1682, 3897, null], [3897, 6166, null], [6166, 7600, null], [7600, 8777, null], [8777, 10940, null], [10940, 13190, null], [13190, 15229, null], [15229, 17305, null], [17305, 19582, null], [19582, 21756, null], [21756, 24018, null], [24018, 26134, null]], "google_gemma-3-4b-it_v2tag__is_academic_paper": [[0, 5000, true], [5000, 26134, null]], "google_gemma-3-4b-it_v2tag__is_class_syllabus": [[0, 5000, false], [5000, 26134, null]], "google_gemma-3-4b-it_v2tag__is_completion_certificate": [[0, 5000, false], [5000, 26134, null]], "google_gemma-3-4b-it_v2tag__is_court_notice": [[0, 5000, false], [5000, 26134, null]], "google_gemma-3-4b-it_v2tag__is_homework_assignment": [[0, 5000, false], [5000, 26134, null]], "google_gemma-3-4b-it_v2tag__is_news_article": [[0, 5000, false], [5000, 26134, null]], "google_gemma-3-4b-it_v2tag__is_public_order": [[0, 5000, false], [5000, 26134, null]], "google_gemma-3-4b-it_v2tag__is_resume_cv": [[0, 5000, false], [5000, 26134, null]], "google_gemma-3-4b-it_v2tag__is_test_or_quiz": [[0, 5000, false], [5000, 26134, null]], "google_gemma-3-4b-it_v2tag__is_textbook": [[0, 5000, false], [5000, 26134, null]], "pdf_page_numbers": [[0, 1682, 1], [1682, 3897, 2], [3897, 6166, 3], [6166, 7600, 4], [7600, 8777, 5], [8777, 10940, 6], [10940, 13190, 7], [13190, 15229, 8], [15229, 17305, 9], [17305, 19582, 10], [19582, 21756, 11], [21756, 24018, 12], [24018, 26134, 13]], "pipe_delimited_lines_v1__pipe_delimited_lines_v1__pipe_delimited_lines_ratio": [[0, 26134, 0.0]]}
olmocr_science_pdfs
2024-12-09
2024-12-09
d2deeaea9442d34986e5c901c696c76fcb10bdf0
# Amortized Analysis There are a few ways we can reason about the complexity of a sequence of \( n \) operations: 1. We can bound the cost of the operation by \( \text{cost}_{op} = O(f(n)) \) and then say than \( n \) operations will take \( n \cdot \text{cost}_{op} = n \cdot O(f(n)) \). We used a similar analysis for BUILD-MIN-HEAP which consisted of \( n \) HEAPIFY operations, where each HEAPIFY operation took \( O(\log n) \) time. Thus, the cost of BUILD-MIN-HEAP was \( O(n \log n) \). 2. We can bound the actual cost of the entire sequence of \( n \) operations. This is different than bounding the cost of one operation and multiplying it by \( n \) to get the full cost. Now we are looking at the individual cost of each operation, adding it up to the total cost. We do this because some of the \( n \) operations might be cheap, while others might be more expensive. It would be naive to consider all of them as having the same cost. In our initial analysis of BUILD-MIN-HEAP, that naivity hurt us. More careful analysis showed the running time was \( \Theta(n) \). ## 1.1 Amortized analysis of \texttt{INSERT} in a hash-table Remember that the \texttt{SEARCH} time in a chaining hash-table of size \( m \) filled with \( n \) items was \( \Theta(1 + \alpha) = \Theta(1 + n/m) \). As a result, if we \texttt{INSERT} too many elements so that \( n \gg m \), our load factor \( \alpha \) will become bigger and increase the \texttt{SEARCH} time. Thus, it’s important to adjust our table size so that \( m = O(n) \) which ensures \( \alpha \) is small and \texttt{SEARCH} is fast. A good way of increasing the size of our table is using doubling. When \( n = m \) and an \texttt{INSERT} operation is trying to add a new element to our hash table, we do the following: 1. Allocate a new hash table double in size. 2. Pick a new hash function \( h \) that will work with the new size. 3. Rehash everything into the new table, including the newly inserted item. 4. Delete the old hash table. We start with a hash-table of size one so that by the 2nd INSERT we’ll have to double our size, according to our above algorithm for table doubling. Let’s now try and analyze a sequence of \( n \) INSERT operations. For simplicity (avoiding \( \log \)'s), we assume \( n = 2^p \), for some \( p \). We can define the cost of the \( i \)th INSERT as: \[ c_i = \begin{cases} i, & \text{if } i - 1 \text{ is a power of 2} \\ 1, & \text{otherwise} \end{cases} \] To see this, think about what happens as items are inserted into the hash table causing it to be resized every now and then. Our table will double in size from 1 to 2, to 4, to 8, to 16, and so on. We double the size after inserting the 2nd key, the 3rd key, the 5th key and the 9th key, because those are all instances when our table is full and we’re trying to add another key to it. Note that all these numbers are off by one from powers of two: 1, 2, 4 and 8. You should now see why the cost of the 9th INSERT is 8 (rounded down a little): because we had to double the size and rehash everything. First, consider a small example, when \( n = 12 \): <table> <thead> <tr> <th>Insert #</th> <th>1</th> <th>2</th> <th>3</th> <th>4</th> <th>5</th> <th>6</th> <th>7</th> <th>8</th> <th>9</th> <th>10</th> <th>11</th> <th>12</th> </tr> </thead> <tbody> <tr> <td>( size_i )</td> <td>1</td> <td>2</td> <td>4</td> <td>4</td> <td>8</td> <td>8</td> <td>8</td> <td>8</td> <td>16</td> <td>16</td> <td>16</td> <td>16</td> </tr> <tr> <td>( c_i )</td> <td>1</td> <td>2</td> <td>3</td> <td>1</td> <td>5</td> <td>1</td> <td>1</td> <td>9</td> <td>1</td> <td>1</td> <td>1</td> <td>1</td> </tr> </tbody> </table> | Insert time | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | | Reallocation time | 0 | 1 | 2 | 0 | 4 | 0 | 0 | 0 | 8 | 0 | 0 | 0 | Now, if we want to compute the full cost for our 12 inserts, we get: \[ cost = \left( \sum_{i=1}^{12} 1 \right) + (1 + 2 + 4 + 8) \\ = 12 \cdot 1 + (1 + 2 + 4 + 8) \\ \leq 12 + 2 \cdot 12 \\ = 12 \cdot O(1) \] We can generalize, for $n = 2^p$: $$\text{cost} = \left( \sum_{i=1}^{n} 1 \right) + (1 + 2 + 4 + 8 + \ldots + 2^{p-1})$$ $$= n \cdot 1 + \sum_{i=0}^{p-1} 2^i$$ $$\leq n + 2 \cdot n$$ $$= O(n)$$ Thus, if $n$ inserts take $O(n)$ time, then we say that the amortized cost of one INSERT is $O(1)$. Intuitively, you can also analyze this in the following way: Each time you double your hash table size after inserting element $2^i + 1$ you pay a cost proportional to $2^i$ because you have to allocate a new table and rehash everything. But up until that point, you have already paid cost $2^i$ to insert the previous $2^i$ items. This new reallocation cost is asymptotically equal to the insertion cost so far. Thus, if we add both of them together, we can say that the cost for all $2^i + 1$ inserts is proportional to $2^i$. Thus, the amortized cost for a single INSERT is $O(1)$. Exercise: Prove that in-order traversal in a BST using SUCCESSOR (a.k.a. NEXT-LARGEST) is $O(1)$ per node, amortized. ## 2 Rolling Hashes and Rabin Karp ### 2.1 Rabin Karp pattern string search Suppose we are given a large text $t$ and we want to find a word (or any text pattern) $s$ in $t$. For example, consider looking for the pattern $s = bbz$ in the text $t = bbbbcbbbz$. The trivial algorithm works by matching every character in $s$ with characters 0, 1 and 2 in $t$. If there’s a match, we’re done. If not, we try and match the characters 1, 2 and 3 in $t$. If there’s a match, we’re done. If not, we try and match the characters 2, 3 and 4. You get the idea. Here’s a table that illustrates how this algorithms runs on $t$ and $s$. We are done! We found $s$ at the end of $t$ If $|t| = n$ and $|s| = k$, then this naive algorithm runs in $O(nk)$ time because for (almost) every position in $t$ we do exactly $k$ comparisons to check for a match. For a big enough $n$ and for a $k = \Theta(n)$ this algorithm will run in $O(n^2)$, which is too slow. Can we build an $O(n)$ search algorithm? 1. Might we employ hashing somehow? 2. How do you hash a string of characters? 3. If we hash a piece of text from $t$ that starts at index $i$ and ends at index $j$, is it any easier to compute the hash of the piece that starts at index $i + 1$ and ends at index $j + 1$? 4. If we could roll our hashes in $O(1)$ time as described above, what would that imply about the runtime of our algorithm? We can hash pieces of $t$ and compare their hash with the hash of $s$. If there’s a hash match, we check for a real match by verifying character by character. Why? We could have collisions, where $s$ and a piece of $t$ that’s different from $s$ hash to the same value. This is unlikely when using good hash functions but it could happen! How can we compute the hash of a string? For this problem, we consider only strings consisting of lower-case letters. Map each letter to its index in the English dictionary $a \rightarrow 0, b \rightarrow 1, \ldots, z \rightarrow 25$. Convert the string to a base 26 number modulo some big prime $p$. Example: Let $t = bciz$, then $h(t) = (26^3 \cdot 1 + 26^2 \cdot 2 + 26^1 \cdot 8 + 26^0 \cdot 25) \mod p = 19161 \mod p$. As you can see, for strings longer than say 32 characters, we could be dealing with big numbers: \(26^{32} \cdot 'a' + \ldots\). Thus, we need to work modulo a prime \(p\). This is great, but it does not give us an \(O(n)\) algorithm. Every time we compare the hash of \(s\) with the hash \(h\) of the next piece in \(t\), we have to compute that hash \(h\). This takes \(O(k)\) time, just like comparing \(s\) with this next piece character by character did. Let \(t_{i,k}\) denote the substring in \(t\) that starts at index \(i\) and has length \(k\). Next, we notice that if we have \(h(t_{i,k})\), we can actually compute \(h(t_{i+1,k})\) in \(O(1)\) time, not in \(O(k)\) time. \[ \begin{align*} \text{bcde} & \xrightarrow{h(\text{bcd})} h(\text{“bcd”}) = 26^2 \cdot 1 + 26^1 \cdot 2 + 3 \\ \text{bcde} & \xrightarrow{h(\text{cde})} h(\text{“cde”}) = 26^2 \cdot 2 + 26^1 \cdot 3 + 4 \end{align*} \] Note that to get \(h(\text{“cde”})\) from \(h(\text{“bcd”})\), all we have to do is apply the following operations to \(h(\text{“bcd”})\): 1. Remove \(b\) ⇒ obtain a hash for “cd”. 2. Multiply by 26 ⇒ obtain a hash for “cda”. 3. Add \(e\) ⇒ obtain a hash for “cde”. Mathematically, this translates to: \[ \begin{align*} h(\text{“cde”}) &= (h(\text{“bcd”}) - 26^2 \cdot 1) \cdot 26 + 4 \\ &= (26^2 \cdot 1 + 26^1 \cdot 2 + 3 - 26^2 \cdot 1) \cdot 26 + 4 \\ &= (26^1 \cdot 2 + 3) \cdot 26 + 4 \\ &= 26^2 \cdot 2 + 26^1 \cdot 3 + 4 \end{align*} \] Note that all these operations are \(O(1)\): we performed one subtraction, one multiplication and one addition. Also note that we ignored the mod \(p\) notation for convenience and that the calculations still hold mod \(p\). This new algorithm is starting to gain shape now. We can compare hashes in \(O(1)\) and we can compute the hash of the next piece in \(t\) in \(O(1)\) by using this rolling hash trick. We have an \(O(n)\) time algorithm that works as follows: Rabin-Karp-Search\( (t, s) \) 1. \( n \leftarrow |t| \) 2. \( k \leftarrow |s| \) 3. \( \text{exp} \leftarrow 26^{k-1} \) 4. \( h_t \leftarrow \text{hash}(t_{0:k}) \) 5. \( h_s \leftarrow \text{hash}(s) \) 6. \( n \leftarrow |t| \) 7. \( k \leftarrow |s| \) 8. \( \text{exp} \leftarrow 26^{k-1} \) 9. \( h_t \leftarrow \text{hash}(t_{0:k}) \) 10. \( h_s \leftarrow \text{hash}(s) \) 11. \( \text{if } h_t = h_s \text{ and } \text{VERIFYMATCH}(0, k) \) 12. \( \text{then} \) 13. \( \text{PRINT(“Found match at position 0!”)} \) 14. \( \text{return } 0 \) 15. \( \text{for } i = 1 \text{ to } n - k \) 16. \( \text{do} \) 17. \( \text{Roll the hash: remove the first character} \) 18. \( h_t \leftarrow h_t - \text{exp} \cdot t[i-1] \) 19. \( \text{Roll the hash: multiply by } 26 \) 20. \( h_t \leftarrow h_t \cdot 26 \) 21. \( \text{Roll the hash: add new character} \) 22. \( h_t \leftarrow h_t + t[i-1+k] \) 23. \( \text{Check for a match on the new hash} \) 24. \( \text{if } h_t = h_s \text{ and } \text{VERIFYMATCH}(i, k) \) 25. \( \text{then} \) 26. \( \text{PRINT(“Found match at position ”, i, “!”)} \) 27. \( \text{return } i \) 28. \( \text{return } -1 \) The Rabin-Karp algorithm can verify if \( s \) occurs at a location \( i \) in \( t \) in \( O(1) \) time (we exclude the extra character-by-character verification work which will not occur very often with good hashing). Since there are \( O(n) \) such locations in \( t \), the algorithm will run in \( O(n) \) time. <table> <thead> <tr> <th>t</th> <th>( \text{bbzz} )</th> </tr> </thead> <tbody> <tr> <td>s</td> <td>( \text{zz} )</td> </tr> <tr> <td>( h_t )</td> <td>1379</td> </tr> <tr> <td>( h_s )</td> <td>727</td> </tr> </tbody> </table> \[ \text{o}(1) \] <table> <thead> <tr> <th>t</th> <th>( \text{bbzz} )</th> </tr> </thead> <tbody> <tr> <td>( h_t )</td> <td>703</td> </tr> <tr> <td>( h_s )</td> <td>727</td> </tr> </tbody> </table> \[ \text{o}(1) \] <table> <thead> <tr> <th>t</th> <th>( \text{bbzz} )</th> </tr> </thead> <tbody> <tr> <td>( h_t )</td> <td>727</td> </tr> <tr> <td>( h_s )</td> <td>727</td> </tr> </tbody> </table> 2.2 ROLLINGHASH as an Abstract Data Structure (ADT) We can think of the rolling hash as an abstract data structure that maintains the hash of a list. In Rabin Karp, the list was a sequence of characters (i.e. a piece of text), but we can generalize to any list. Such a ROLLINGHASH ADT supports the following operations, all in $O(1)$ time: - **hash()** → computes the hash of the list. - **append(val)** → adds `val` to the end of the list. - **skip(val)** → removes the front element from the list, assuming it is `val`. - if the item in the front of the list is not `val`, then the behavior of the ADT from this point on will be undefined. **Key idea:** Treat a list of enumerable items as a multidigit number $u$ in base $a$. This is basically *concatenating* the list items into a big number. What does *enumerable* mean? It means that every item in the universe of items can be assigned to a unique number in $[0, 1, 2, \ldots, a-1]$ (i.e. it can be assigned a digit in in base $a$). For strings, characters can be interpreted as integers, with their exact values depending on what type of encoding is being used (e.g. ASCII, Unicode). In ASCII for instance, the codes for upper-case ‘A’ and ‘B’ are 65 and 66 respectively. Also, in ASCII, any character is represented as an 8-bit number so we can convert it to an integer from 0 to 255. As a result, our base would be $a = 256$ (i.e. the alphabet size for the ASCII code). A character string $s = c_n c_{n-1} c_{n-2} \ldots c_2 c_1 c_0$, where each characters $c_i$ maps to integer $d_i$ (as dictated by the ASCII code), would be converted to a number $u$ in base 256 as follows: $$u = d_n \cdot 256^n + d_{n-1} \cdot 256^{n-1} + \cdots + d_2 \cdot 256^2 + d_1 \cdot 256 + d_0$$ Let’s try implementing the general HASH, APPEND and SKIP operations for our ROLLINGHASH ADT: APPEND($rh, item$) 1 ▷ Convert our item to a number in base $a$ 2 \[ val \leftarrow \text{GETNUMBER}(rh, item) \] 3 4 ▷ Fetch the rolling hash attributes like the current value, the base $a$, the prime $p$, the length of the list. 5 \[ u \leftarrow rh.u \] 6 \[ a \leftarrow rh.a \] 7 \[ p \leftarrow rh.p \] 8 \[ l \leftarrow rh.length \] 9 10 ▷ Update our rolling hash $u$ 11 \[ u \leftarrow (u \cdot a \mod p) + val \] 12 \[ u \leftarrow (u \mod p) \] 13 14 ▷ Store the result back in our rolling hash ADT 15 \[ rh.u \leftarrow u \] 16 \[ rh.length \leftarrow l + 1 \] SKIP($item$) 1 ▷ Convert our item to a number in base $a$ 2 \[ val \leftarrow \text{GETNUMBER}(rh, item) \] 3 4 ▷ Fetch the rolling hash attributes like the current value, the base and the prime 5 \[ u \leftarrow rh.u \] 6 \[ a \leftarrow rh.a \] 7 \[ p \leftarrow rh.p \] 8 \[ l \leftarrow rh.l \] 9 10 ▷ Compute the part that we have to remove 11 \[ r \leftarrow ((a^{l-1} \mod p) \cdot val) \mod p \] 12 13 ▷ Subtract it from $u$ and we’re done 14 \[ u \leftarrow (u - r) \mod p \] 15 16 ▷ Store the result back in our rolling hash ADT 17 \[ rh.u \leftarrow u \] 18 \[ rh.length \leftarrow l - 1 \] HASH($rh$) 1 ▷ Just return $u$, which is maintained modulo $p$ 2 \[ \text{return} \ u \] Note the use of the \texttt{GETNUMBER}(\texttt{rh, item}) function call, which is used to convert an item in the list to a number in base \(a\). For letters, we would implement it as follows: \begin{verbatim} GETNUMBER(rh, item) ▶ Just return the offset of the letter in the alphabet return alphabetOffset[item] \end{verbatim} Also note that we have to be \textit{careful} when implementing \texttt{SKIP} so as to achieve an \(O(1)\) running time. We have to compute \(a^l\) every time we \texttt{SKIP} and this could take \(O(l)\) time, where \(l\) is the length of the list hashed by our \texttt{ROLLINGHASH} ADT. We note that this can be avoided by caching this power of \(a\) and storing it in our \texttt{ROLLINGHASH} ADT as a variable \texttt{exp}. But we have to keep it updated so that \(\texttt{exp} = a^l\) across sequences of \texttt{APPEND} and \texttt{SKIP} operations. This means every time we \texttt{APPEND} we let \(\texttt{exp} = \texttt{(exp \cdot a)} \mod p\) and every time we \texttt{skip}, we let \(\texttt{exp} = \texttt{(exp \cdot a^{-1})} \mod p\), where \(a^{-1}\) is the inverse modulo \(p\) of \(a\). Initially, \(\texttt{exp} = a^{-1}\).
{"Source-Url": "http://stellar.mit.edu/S/course/6/sp14/6.006/courseMaterial/topics/topic3/studyMaterial/rec09/rec09.pdf", "len_cl100k_base": 5180, "olmocr-version": "0.1.53", "pdf-total-pages": 9, "total-fallback-pages": 0, "total-input-tokens": 27437, "total-output-tokens": 5688, "length": "2e12", "weborganizer": {"__label__adult": 0.0003323554992675781, "__label__art_design": 0.00029397010803222656, "__label__crime_law": 0.0003349781036376953, "__label__education_jobs": 0.00031876564025878906, "__label__entertainment": 8.296966552734375e-05, "__label__fashion_beauty": 0.0001461505889892578, "__label__finance_business": 0.0002359151840209961, "__label__food_dining": 0.0004627704620361328, "__label__games": 0.0005369186401367188, "__label__hardware": 0.0012416839599609375, "__label__health": 0.0004982948303222656, "__label__history": 0.00026607513427734375, "__label__home_hobbies": 0.0001271963119506836, "__label__industrial": 0.0005216598510742188, "__label__literature": 0.00029349327087402344, "__label__politics": 0.00024628639221191406, "__label__religion": 0.0005397796630859375, "__label__science_tech": 0.042510986328125, "__label__social_life": 8.279085159301758e-05, "__label__software": 0.00836944580078125, "__label__software_dev": 0.94140625, "__label__sports_fitness": 0.00031065940856933594, "__label__transportation": 0.0004808902740478515, "__label__travel": 0.00022852420806884768}, "weborganizer_max": "__label__software_dev", "avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_ratio": [[0, 14934, 0.0846]], "fineweb_edu_fasttext_gt2__fineweb_edu_fasttext_gt2__score": [[0, 14934, 0.15535]], "ft_lang_id_en_doc_v2__ft_lang_id_en_doc_v2__en": [[0, 14934, 0.80268]], "google_gemma-3-12b-it_contains_pii": [[0, 2006, false], [2006, 3736, null], [3736, 5369, null], [5369, 6892, null], [6892, 8819, null], [8819, 10659, null], [10659, 12496, null], [12496, 13761, null], [13761, 14934, null]], "google_gemma-3-12b-it_is_public_document": [[0, 2006, true], [2006, 3736, null], [3736, 5369, null], [5369, 6892, null], [6892, 8819, null], [8819, 10659, null], [10659, 12496, null], [12496, 13761, null], [13761, 14934, null]], "google_gemma-3-4b-it_v2tag__is_academic_paper": [[0, 5000, false], [5000, 14934, null]], "google_gemma-3-4b-it_v2tag__is_class_syllabus": [[0, 5000, false], [5000, 14934, null]], "google_gemma-3-4b-it_v2tag__is_completion_certificate": [[0, 5000, false], [5000, 14934, null]], "google_gemma-3-4b-it_v2tag__is_court_notice": [[0, 5000, false], [5000, 14934, null]], "google_gemma-3-4b-it_v2tag__is_homework_assignment": [[0, 5000, false], [5000, 14934, null]], "google_gemma-3-4b-it_v2tag__is_news_article": [[0, 5000, false], [5000, 14934, null]], "google_gemma-3-4b-it_v2tag__is_public_order": [[0, 5000, false], [5000, 14934, null]], "google_gemma-3-4b-it_v2tag__is_resume_cv": [[0, 5000, false], [5000, 14934, null]], "google_gemma-3-4b-it_v2tag__is_test_or_quiz": [[0, 5000, false], [5000, 14934, null]], "google_gemma-3-4b-it_v2tag__is_textbook": [[0, 5000, false], [5000, 14934, null]], "pdf_page_numbers": [[0, 2006, 1], [2006, 3736, 2], [3736, 5369, 3], [5369, 6892, 4], [6892, 8819, 5], [8819, 10659, 6], [10659, 12496, 7], [12496, 13761, 8], [13761, 14934, 9]], "pipe_delimited_lines_v1__pipe_delimited_lines_v1__pipe_delimited_lines_ratio": [[0, 14934, 0.10383]]}
olmocr_science_pdfs
2024-12-07
2024-12-07
8917457f5309319b802c210e84126b24921a0fef
SOFTWARE-BASED FAULT ISOLATION MICHAEL ROITZSCH OVERVIEW - Motivation - The Idea - Concepts - Evaluation - Ideas for Enhancements - XFI: Enhancing SFI - XFI: Evaluation - NaCl Excursion - Summary This first part is based on the paper Efficient Software-Based Fault Isolation by Robert Wahbe, Steven Lucco, Thomas E. Anderson and Susan L. Graham and appeared at the Symposium on Operating System Principles in 1993 • Hardware-based isolation • Applications with extensible interfaces (Plugins, Codecs, Query Code) • HFI Slow (ten thousands of Cycles, @40 MHz DEC Station) → often not used (Postgres) • RPC in one address space = dozens of cycles @40MHz DEC! • But address spaces provide no fault isolation :( MOTIVATION - DECstation 5000/240 Mips R3400 @40MHz - Integer performance comparable to 486DX4/100 - Source: - Alfred Arnold THE IDEA - Do not use hardware isolation (paging) but map plugins and co into the address space, fast rpc (dozens of cycles) - Price: stability - Example: Quark Express Desktop Publishing - Plugins crash main system (overwrite/corrupt state of main program), crashiness attributed to Quark → bad for reputation THE IDEA (IMPROVED) - Provide guarantees of HFI without the costs - Use a custom compiler that enables the sandboxing of the software - Verifier checks if the binary is correctly sandboxed - Approach is especially beneficial for systems with high amounts of communication CONCEPTS - Segment Matching - Address Sandboxing - Resource Access - Data Sharing - Verification - RPC How to ensure stores only to “own” memory? ``` dedicated-reg <= target address Move target address into dedicated register. scratch-reg <= (dedicated-reg>>shift-reg) Right-shift address to get segment identifier scratch-reg is not a dedicated register shift-reg is a dedicated register compare scratch-reg and segment-reg segment-reg is a dedicated register trap if not equal Trap if store address is outside of segment store instruction uses dedicated reg ``` • Is there a simpler way? Do we need those guarantees? \[ dedicated-reg \leftarrow target-reg \& and-mask-reg \] Use dedicated register \textit{and-mask-reg} to clear segment identifier bits \[ dedicated-reg \leftarrow dedicated-reg \mid segment-reg \] Use dedicated register \textit{segment-reg} to set segment identifier bits \textit{store instruction uses dedicated reg} OPTIMIZATION • Do we really need to verify all accesses? This is expensive! • We lose some address arithmetic features \[ \text{reg} \leq \text{mem[EAX\pm\text{off}]} \] • Solution: Guardzones! • Shared resources in one address space • Arbitration in Kernel • ... or by restricting resource access to trusted arbitration code - Reading is trivial - R/W through shared (aliased) pages ```c struct node { ... struct node *next; }; node *a = 0x4000 0000 a->next = 0x4000 0010 a->next->next = null_ptr ``` How do segments communicate? - One Stub-pair per caller/callee pair - Stubs are trusted - Signals for Fault Isolation • Simplified by dedicated jump register • Scan code segment (Fixed-width Opcodes :)) • Verify statical calls / accesses / jumps • Check others for dedicated register ### EVALUATION <table> <thead> <tr> <th>Benchmark</th> <th>DEC-MIPS</th> <th>DEC-ALPHA</th> </tr> </thead> <tbody> <tr> <td></td> <td></td> <td>Fault Isolation Overhead</td> </tr> <tr> <td>052.alvinn</td> <td>FP</td> <td>1.4%</td> </tr> <tr> <td>bps</td> <td>FP</td> <td>5.6%</td> </tr> <tr> <td>cholesky</td> <td>FP</td> <td>0.0%</td> </tr> <tr> <td>026.compress</td> <td>INT</td> <td>3.3%</td> </tr> <tr> <td>056.ea</td> <td>FP</td> <td>-1.2%</td> </tr> <tr> <td>023.eqntott</td> <td>INT</td> <td>2.9%</td> </tr> <tr> <td>008.espresso</td> <td>INT</td> <td>12.4%</td> </tr> <tr> <td>001.gcc1.35</td> <td>INT</td> <td>3.1%</td> </tr> <tr> <td>022.li</td> <td>INT</td> <td>5.1%</td> </tr> <tr> <td>locus</td> <td>INT</td> <td>8.7%</td> </tr> <tr> <td>mp3d</td> <td>FP</td> <td>10.7%</td> </tr> <tr> <td>psgrind</td> <td>INT</td> <td>10.4%</td> </tr> <tr> <td>qcd</td> <td>FP</td> <td>0.5%</td> </tr> <tr> <td>072.sc</td> <td>INT</td> <td>5.6%</td> </tr> <tr> <td>tracker</td> <td>INT</td> <td>-0.8%</td> </tr> <tr> <td>water</td> <td>FP</td> <td>0.7%</td> </tr> <tr> <td><strong>Average</strong></td> <td></td> <td><strong>4.3%</strong></td> </tr> </tbody> </table> ## EVALUATION <table> <thead> <tr> <th>Platform</th> <th>Caller Save Registers</th> <th>Save Integer Registers</th> <th>Save Integer + Float Registers</th> <th>C Procedure Call</th> <th>Pipes</th> </tr> </thead> <tbody> <tr> <td>DEC-MIPS</td> <td>1.11 (\mu s)</td> <td>1.81 (\mu s)</td> <td>2.83 (\mu s)</td> <td>0.10 (\mu s)</td> <td>204.72 (\mu s)</td> </tr> <tr> <td>DEC-ALPHA</td> <td>0.75 (\mu s)</td> <td>1.35 (\mu s)</td> <td>1.80 (\mu s)</td> <td>0.06 (\mu s)</td> <td>227.88 (\mu s)</td> </tr> </tbody> </table> Table 2: Cross-fault-domain crossing times. <table> <thead> <tr> <th>Sequoia 2000 Query</th> <th>Untrusted Function Manager Overhead</th> <th>Software-Enforced Fault Isolation Overhead</th> <th>Number Cross-Domain Calls</th> <th>DEC-MIPS-PIPE Overhead (predicted)</th> </tr> </thead> <tbody> <tr> <td>Query 6</td> <td>1.4%</td> <td>1.7%</td> <td>60989</td> <td>18.6%</td> </tr> <tr> <td>Query 7</td> <td>5.0%</td> <td>1.8%</td> <td>121986</td> <td>38.6%</td> </tr> <tr> <td>Query 8</td> <td>9.0%</td> <td>2.7%</td> <td>121978</td> <td>31.2%</td> </tr> <tr> <td>Query 10</td> <td>9.6%</td> <td>5.7%</td> <td>1427024</td> <td>31.9%</td> </tr> </tbody> </table> Table 3: Fault isolation overhead for POSTGRES running Sequoia 2000 benchmark. IDEAS FOR ENHANCEMENTS - Compiler support is a problem - Can we do without the compiler? Binary rewriting! - Can this be applied to CISC architectures (verification is more difficult!) - is the limitation to one specific segment feasible? - Can we allow more fine-granular access? This second part is based on the paper XFI: Software Guards for System Address Spaces by Ulfar Erlingsson, Martin Abadi, Michael Vrable, Mihai Budiu and George C. Necula and appeared at the Symposium on Operating System Design and Implementation in 2006 Challanges Addressed by XFI - Make SFI work in systems software (drivers) - Remove the single segment limit - Prevent attacks through ROP techniques - Protect individual system instructions GENERAL CONCEPT The diagram illustrates the general concept of software-based fault isolation. It breaks down the host-system space into different components: - **Host-system executable**: Contains code and data. - **XFI module**: Represents the execution environment with code, data, read-only data, and read/write data. - **Host-system stacks**: Indicates areas for stack management. - **Host-system heap**: Shows the memory area for dynamic allocation. Support routines and entry points are also depicted, indicating how different components interact within the host-system space. ENFORCED PROPERTIES - P1: Memory-access constraints - P2: Interface Restrictions - P3: Scoped Stack Integrity - P4: Simplified Instruction Semantics - P5: System-environment integrity - P6: Control-flow integrity - P7: Program-data integrity EAX := 0x12345677 # Identifier - 1 EAX := EAX + 1 if Mem[EBX - 4] ≠ EAX, goto CFIERR call EBX ... 0x12345678 # Target identifier L: push EBP # Callee code MEMORY RANGE GUARDS # mrguard(EAX, L, H) ::= if EAX < A + L, goto S if B - H < EAX, goto S M: Mem[EAX] := 42 # Two writes Mem[EAX - L] := 7 # both allowed ... S: push EAX # Arguments for push L, H # slower guard call SlowpathGuard jump M # Allow writes ACCESS CONTROL - Slowpath guards enable byte granularity permissions - System level - For individual instructions the “unsafe region” can be specified - This enables the protection of outside code REQUIRED RUNTIME SUPPORT - Slowpath permission tables - Allocation-Stack manager - Software Call Gates (changed stack model!) - Exception Handling Support (Windows SEH) • Guards may be implemented in Hardware • Can be simulated as NOP guards • Required Instructions: - `cfilabel` instruction - variants of jump/call/return instructions - `mrguard` instruction • Implemented in Alpha architecture simulator • Do not use dedicated registers (esp. on x86) • Verification is more difficult • Needs verification state • must check all paths <table> <thead> <tr> <th>Code</th> <th>Verification State</th> </tr> </thead> <tbody> <tr> <td>mrguard(EAX, 0, 8)</td> <td></td> </tr> <tr> <td>EDX := Mem[EAX]</td> <td></td> </tr> <tr> <td>Mem[EAX+4] := EDX</td> <td></td> </tr> <tr> <td>EAX := Mem[ASP-4]</td> <td></td> </tr> <tr> <td><strong>POP</strong> ASP</td> <td></td> </tr> <tr> <td><strong>RET</strong></td> <td># SSP := SSP+4; jump Mem[SSP-4]</td> </tr> </tbody> </table> Code | Verification State --- | --- {origSSP = SSP+8, valid[SSP,SSP+8] } | {retaddr=Mem[SSP+4]} | {origASP=Mem[SSP],valid[ASP-32,ASP]} ``` mrguard(EAX,0,8) EDX := Mem[EAX] Mem[EAX+4] := EDX EAX := Mem[ASP-4] POP ASP RET # SSP := SSP+4; jump Mem[SSP-4] ``` ### Code Verification State <table> <thead> <tr> <th>Code</th> <th>Verification State</th> </tr> </thead> <tbody> <tr> <td>{origSSP = SSP+8, valid[SSP,SSP+8)}</td> <td></td> </tr> <tr> <td>{retaddr=Mem[SSP+4]}</td> <td></td> </tr> <tr> <td>{origASP=Mem[SSP],valid[ASP-32,ASP)}</td> <td></td> </tr> <tr> <td>mrguard(EAX,0,8)</td> <td></td> </tr> <tr> <td>{valid[EAX-0,EAX+8)}</td> <td></td> </tr> <tr> <td>EDX := Mem[EAX]</td> <td></td> </tr> <tr> <td>Mem[EAX+4] := EDX</td> <td></td> </tr> <tr> <td>EAX := Mem[ASP-4]</td> <td></td> </tr> <tr> <td><strong>POP</strong> ASP</td> <td></td> </tr> <tr> <td><strong>RET</strong></td> <td># SSP := SSP+4; jump Mem[SSP-4]</td> </tr> </tbody> </table> ### Code Verification State <table> <thead> <tr> <th>Code</th> <th>Verification State</th> </tr> </thead> </table> | {origSSP = SSP+8, valid[SSP,SSP+8]} {retaddr=Mem[SSP+4]} {origASP=Mem[SSP],valid[ASP-32,ASP]} | mrguard(EAX,0,8) | | {valid[EAX-0,EAX+8]} | EDX := Mem[EAX] Mem[EAX+4] := EDX EAX := Mem[ASP-4] | | POP ASP # ASP := Mem[SSP]; SSP := SSP+4 | {origASP=ASP, valid[SSP,SSP+4]} {origSSP=SSP+4, retaddr=Mem[SSP]} | | RET # SSP := SSP+4; jump Mem[SSP-4] | **Table 1:** Code-size increase and slowdown of SFI benchmarks, with XFI. The % rows show slowdown. <table> <thead> <tr> <th></th> <th>NOP</th> <th>fastpath</th> <th>slowpath</th> </tr> </thead> <tbody> <tr> <td>hotlist Δ sz %</td> <td>2.1x (2.6x)</td> <td>2.5x (4.1x)</td> <td>3.9x (8.3x)</td> </tr> <tr> <td>ld Δ sz %</td> <td>1.2x (1.3x)</td> <td>1.5x (1.8x)</td> <td>1.7x (2.3x)</td> </tr> <tr> <td>MD5 Δ sz %</td> <td>1.1x (1.1x)</td> <td>1.2x (1.3x)</td> <td>1.3x (1.5x)</td> </tr> </tbody> </table> **Table 2:** Code-size increase and slowdown for different kernel buffer sizes for a WDF benchmark, with XFI. The unprotected driver is 11KB of x86 machine code; its transactions per second (shown in thousands) form the baseline for the slowdown percentages. <table> <thead> <tr> <th>Kt/s</th> <th>NOP</th> <th>fastpath</th> <th>slowpath</th> </tr> </thead> <tbody> <tr> <td>1</td> <td>193</td> <td>5.0% (4.8%)</td> <td>6.8% (6.1%)</td> </tr> <tr> <td>512</td> <td>151</td> <td>4.7% (3.9%)</td> <td>5.3% (4.7%)</td> </tr> <tr> <td>4K</td> <td>71</td> <td>1.7% (1.7%)</td> <td>2.7% (2.9%)</td> </tr> <tr> <td>64K</td> <td>5</td> <td>1.2% (1.9%)</td> <td>1.4% (0.4%)</td> </tr> </tbody> </table> **Table 4:** Slowdown of Mediabench kernels, with XFI. <table> <thead> <tr> <th></th> <th>NOP</th> <th>fastpath</th> <th>slowpath</th> </tr> </thead> <tbody> <tr> <td>adpcm_encode</td> <td>0% (4%)</td> <td>2% (49%)</td> <td>13% (149%)</td> </tr> <tr> <td>adpcm_decode</td> <td>−3% (2%)</td> <td>3% (12%)</td> <td>36% (112%)</td> </tr> <tr> <td>gsm_decode</td> <td>3% (1%)</td> <td>79% (97%)</td> <td>125% (230%)</td> </tr> <tr> <td>epic_decode</td> <td>3% (9%)</td> <td>7% (19%)</td> <td>119% (220%)</td> </tr> </tbody> </table> CONCLUSION - SFI is also feasible on x86 - Verification becomes more complex - Mechanisms also enable other restrictions - SFI is feasible for kernel code - Separate allocation- and scoped stacks reduce exploitability This third part is based on the paper Native Client: A Sandbox for Portable, Untrusted x86 Native Code by Bennet Yee, David Sehr, Gregory Dardyk, J. Bradley Chen, Robert Muth, Tavis Ormandy, Shiki Okasaka, Neha Narula and Nicholas Fullager and appeared at the Symposium on Security and Privacy in 2009 APPLICATIONS - Implemented as “Pepper” in Chrome - Used for - Flash - PDF Viewer - Quake - Doom - Lara Croft and the Guardian of Light - Uses LLVM IR bytecode for platform independence • x86-32 segmentation for memory isolation • SFI for arm / amd64 • CFI through restriction on indirect jumps - must be to 32 byte aligned basic blocks - no opcodes are allowed to cross this boundary • Requires Recompilation PERFORMANCE RESULTS ![Performance Results Graph] - align32 - nacl32 The graph compares the performance slowdown of different benchmarks when using align32 and nacl32. The x-axis represents various benchmark programs, and the y-axis shows the slowdown compared to a static baseline. The bars indicate the percentage change in performance for each benchmark under the two conditions. <table> <thead> <tr> <th></th> <th>static</th> <th>aligned</th> <th>NaCl</th> <th>increase</th> </tr> </thead> <tbody> <tr> <td>ammp</td> <td>657</td> <td>759</td> <td>766</td> <td>16.7%</td> </tr> <tr> <td>art</td> <td>469</td> <td>485</td> <td>485</td> <td>3.3%</td> </tr> <tr> <td>bzip2</td> <td>492</td> <td>525</td> <td>526</td> <td>7.0%</td> </tr> <tr> <td>crafty</td> <td>756</td> <td>885</td> <td>885</td> <td>17.5%</td> </tr> <tr> <td>eon</td> <td>1820</td> <td>2016</td> <td>2017</td> <td>10.8%</td> </tr> <tr> <td>equake</td> <td>465</td> <td>475</td> <td>475</td> <td>2.3%</td> </tr> <tr> <td>gap</td> <td>1298</td> <td>1836</td> <td>1882</td> <td>45.1%</td> </tr> <tr> <td>gcc</td> <td>2316</td> <td>3644</td> <td>3646</td> <td>57.5%</td> </tr> <tr> <td>gzip</td> <td>492</td> <td>537</td> <td>537</td> <td>9.2%</td> </tr> <tr> <td>mcf</td> <td>439</td> <td>452</td> <td>451</td> <td>2.8%</td> </tr> <tr> <td>mesa</td> <td>1337</td> <td>1758</td> <td>1769</td> <td>32.3%</td> </tr> <tr> <td>parser</td> <td>641</td> <td>804</td> <td>802</td> <td>25.2%</td> </tr> <tr> <td>perlbmk</td> <td>1167</td> <td>1752</td> <td>1753</td> <td>50.2%</td> </tr> <tr> <td>twolf</td> <td>773</td> <td>937</td> <td>936</td> <td>21.2%</td> </tr> <tr> <td>vortex</td> <td>1019</td> <td>1364</td> <td>1351</td> <td>32.6%</td> </tr> <tr> <td>vpr</td> <td>668</td> <td>780</td> <td>780</td> <td>16.8%</td> </tr> </tbody> </table> Table 5: Code size for SPEC2000, in kilobytes. GAMING PERFORMANCE <table> <thead> <tr> <th>Run #</th> <th>Native Client</th> <th>Linux Executable</th> </tr> </thead> <tbody> <tr> <td>1</td> <td>143.2</td> <td>142.9</td> </tr> <tr> <td>2</td> <td>143.6</td> <td>143.4</td> </tr> <tr> <td>3</td> <td>144.2</td> <td>143.5</td> </tr> <tr> <td>Average</td> <td>143.7</td> <td>143.3</td> </tr> </tbody> </table> Table 8: Quake performance comparison. Numbers are in frames per second. The Catch: Software rendering ;) TU Dresden Software-Based Fault Isolation 41 SUMMARY - Software-based Fault Isolation - ... can be done on CISC and RISC architectures - ... enables finer grained access controls and enforcement - ... at a (quite high) performance price - ... but is mitigated for applications with high communication frequency by reduced context switching overhead - ... can be used to enforce other policies than only memory protection - ... is actively used by Google Chrome
{"Source-Url": "http://os.inf.tu-dresden.de/Studium/IOS/SS2018/04-SFI.pdf", "len_cl100k_base": 5338, "olmocr-version": "0.1.53", "pdf-total-pages": 42, "total-fallback-pages": 0, "total-input-tokens": 45543, "total-output-tokens": 6855, "length": "2e12", "weborganizer": {"__label__adult": 0.0003659725189208984, "__label__art_design": 0.0003139972686767578, "__label__crime_law": 0.0004401206970214844, "__label__education_jobs": 0.00018966197967529297, "__label__entertainment": 6.014108657836914e-05, "__label__fashion_beauty": 0.00015246868133544922, "__label__finance_business": 0.00017976760864257812, "__label__food_dining": 0.0003323554992675781, "__label__games": 0.0006542205810546875, "__label__hardware": 0.004070281982421875, "__label__health": 0.0003638267517089844, "__label__history": 0.0002213716506958008, "__label__home_hobbies": 0.00010353326797485352, "__label__industrial": 0.0006303787231445312, "__label__literature": 0.00014400482177734375, "__label__politics": 0.00024628639221191406, "__label__religion": 0.0004012584686279297, "__label__science_tech": 0.0278167724609375, "__label__social_life": 5.841255187988281e-05, "__label__software": 0.00791168212890625, "__label__software_dev": 0.95458984375, "__label__sports_fitness": 0.0003142356872558594, "__label__transportation": 0.0004835128784179687, "__label__travel": 0.00019037723541259768}, "weborganizer_max": "__label__software_dev", "avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_ratio": [[0, 15457, 0.05334]], "fineweb_edu_fasttext_gt2__fineweb_edu_fasttext_gt2__score": [[0, 15457, 0.07003]], "ft_lang_id_en_doc_v2__ft_lang_id_en_doc_v2__en": [[0, 15457, 0.69701]], "google_gemma-3-12b-it_contains_pii": [[0, 49, false], [49, 198, null], [198, 421, null], [421, 717, null], [717, 899, null], [899, 1211, null], [1211, 1484, null], [1484, 1588, null], [1588, 2074, null], [2074, 2451, null], [2451, 2648, null], [2648, 2780, null], [2780, 2966, null], [2966, 3085, null], [3085, 3251, null], [3251, 4914, null], [4914, 6595, null], [6595, 6595, null], [6595, 6877, null], [6877, 7131, null], [7131, 7322, null], [7322, 7909, null], [7909, 8152, null], [8152, 8317, null], [8317, 8649, null], [8649, 8847, null], [8847, 9017, null], [9017, 9260, null], [9260, 9390, null], [9390, 9912, null], [9912, 10171, null], [10171, 10548, null], [10548, 11000, null], [11000, 12332, null], [12332, 12551, null], [12551, 12858, null], [12858, 13054, null], [13054, 13282, null], [13282, 13667, null], [13667, 14597, null], [14597, 15041, null], [15041, 15457, null]], "google_gemma-3-12b-it_is_public_document": [[0, 49, true], [49, 198, null], [198, 421, null], [421, 717, null], [717, 899, null], [899, 1211, null], [1211, 1484, null], [1484, 1588, null], [1588, 2074, null], [2074, 2451, null], [2451, 2648, null], [2648, 2780, null], [2780, 2966, null], [2966, 3085, null], [3085, 3251, null], [3251, 4914, null], [4914, 6595, null], [6595, 6595, null], [6595, 6877, null], [6877, 7131, null], [7131, 7322, null], [7322, 7909, null], [7909, 8152, null], [8152, 8317, null], [8317, 8649, null], [8649, 8847, null], [8847, 9017, null], [9017, 9260, null], [9260, 9390, null], [9390, 9912, null], [9912, 10171, null], [10171, 10548, null], [10548, 11000, null], [11000, 12332, null], [12332, 12551, null], [12551, 12858, null], [12858, 13054, null], [13054, 13282, null], [13282, 13667, null], [13667, 14597, null], [14597, 15041, null], [15041, 15457, null]], "google_gemma-3-4b-it_v2tag__is_academic_paper": [[0, 5000, true], [5000, 15457, null]], "google_gemma-3-4b-it_v2tag__is_class_syllabus": [[0, 5000, false], [5000, 15457, null]], "google_gemma-3-4b-it_v2tag__is_completion_certificate": [[0, 5000, false], [5000, 15457, null]], "google_gemma-3-4b-it_v2tag__is_court_notice": [[0, 5000, false], [5000, 15457, null]], "google_gemma-3-4b-it_v2tag__is_homework_assignment": [[0, 5000, false], [5000, 15457, null]], "google_gemma-3-4b-it_v2tag__is_news_article": [[0, 5000, false], [5000, 15457, null]], "google_gemma-3-4b-it_v2tag__is_public_order": [[0, 5000, false], [5000, 15457, null]], "google_gemma-3-4b-it_v2tag__is_resume_cv": [[0, 5000, false], [5000, 15457, null]], "google_gemma-3-4b-it_v2tag__is_test_or_quiz": [[0, 5000, false], [5000, 15457, null]], "google_gemma-3-4b-it_v2tag__is_textbook": [[0, 5000, false], [5000, 15457, null]], "pdf_page_numbers": [[0, 49, 1], [49, 198, 2], [198, 421, 3], [421, 717, 4], [717, 899, 5], [899, 1211, 6], [1211, 1484, 7], [1484, 1588, 8], [1588, 2074, 9], [2074, 2451, 10], [2451, 2648, 11], [2648, 2780, 12], [2780, 2966, 13], [2966, 3085, 14], [3085, 3251, 15], [3251, 4914, 16], [4914, 6595, 17], [6595, 6595, 18], [6595, 6877, 19], [6877, 7131, 20], [7131, 7322, 21], [7322, 7909, 22], [7909, 8152, 23], [8152, 8317, 24], [8317, 8649, 25], [8649, 8847, 26], [8847, 9017, 27], [9017, 9260, 28], [9260, 9390, 29], [9390, 9912, 30], [9912, 10171, 31], [10171, 10548, 32], [10548, 11000, 33], [11000, 12332, 34], [12332, 12551, 35], [12551, 12858, 36], [12858, 13054, 37], [13054, 13282, 38], [13282, 13667, 39], [13667, 14597, 40], [14597, 15041, 41], [15041, 15457, 42]], "pipe_delimited_lines_v1__pipe_delimited_lines_v1__pipe_delimited_lines_ratio": [[0, 15457, 0.26957]]}
olmocr_science_pdfs
2024-12-11
2024-12-11
a8a47155518a4791370dce0449967771917ed19c
Elementary transformation analysis for array-OL Paul Feautrier To cite this version: HAL Id: hal-02102502 https://hal-lara.archives-ouvertes.fr/hal-02102502 Submitted on 17 Apr 2019 HAL is a multi-disciplinary open access archive for the deposit and dissemination of scientific research documents, whether they are published or not. The documents may come from teaching and research institutions in France or abroad, or from public or private research centers. L’archive ouverte pluridisciplinaire HAL, est destinée au dépôt et à la diffusion de documents scientifiques de niveau recherche, publiés ou non, émanant des établissements d’enseignement et de recherche français ou étrangers, des laboratoires publics ou privés. Elementary transformation analysis for Array-OL Paul Feautrier May 2007 Research Report N° 2007-28 Elementary transformation analysis for Array-OL Paul Feautrier May 2007 Abstract Array-OL is a high-level specification language dedicated to the definition of intensive signal processing applications. Several tools exist for implementing an Array-OL specification as a data parallel program. While Array-OL can be used directly, it is often convenient to be able to deduce part of the specification from a sequential version of the application. This paper proposes such an analysis and examines its feasibility and its limits. Keywords: Array-OL, multidimensional signal processing, program analysis Résumé Array-OL est un système de spécification de haut niveau spécialisé dans la définition d’application de traitement du signal intensif. Il existe plusieurs ateliers qui transforment une spécification Array-OL en un programme à parallélisme de données. Bien que Array-OL puisse être utilisé tel quel, il est souvent intéressant de pouvoir déduire ses paramètres d’une version séquentielle de l’application. Ce rapport propose une telle analyse et en examine la faisabilité et les limites. Mots-clés: Array-OL, traitement du signal multidimensionnel, analyse de programme 1 Introduction In the Array-OL formalism [1, 2], a program is a network of processes which communicate through shared arrays. A process is made of one or more parallel loops. At each iteration of these loops, a task (or elementary transform) is executed. The elementary transform may contain one or more loops, which are executed sequentially. The execution of an elementary task can be decomposed into three steps: - Move portions of the input array(s) (regions) to the local memory of the processor executing the task. - Execute the elementary transform and generate portions of the output array(s). - Move the results to the output array(s). In order to simplify code generation, the input and output regions must move uniformly across the shared arrays. It is admissible that each elementary transform use only a subset of regularly spaced entries in the input and output regions. In the present version of the software, regions must not overlap, as this would precludes parallel execution of the outer loops. The useful elements of a region are collected in a pattern, which must be a rectangular parallelepiped of fixed size. The Array-OL formalism may be used directly. The programmer is responsible for constructing the elementary transform, identifying the input and output regions, checking parallelism and specifying the regions parameters. Another possibility is to infer the Array-OL specification from a sequential version of the program. This requires the solution of three problems: - Rewriting the sequential program in such a way that the outer loops have no dependences. - Deducing the shape and size of the regions from an analysis of the array subscript functions. - Rewriting the sequential code by substituting pattern accesses to the original array accesses. This note is dedicated to a proposal for the solution of the second and third problems. The assumption is that one is given the sequential code, together with a list of input and output arrays, and an indication of which loop(s) are to be considered as the outer (repetition) loop(s). 2 Paving Let $A$ be an input or output array and let its occurrences in the sequential code be numbered from 1 to $N$. Let $r$ be the counter(s) of the repetition loop(s), and let $j^k$ be the counter(s) of the inner loop(s) that surround occurrence $k$ of $A$. Let $e^k(r, j^k)$ be its subscript function. $e^k$ is a vector function whose dimension is the rank of $A$. To be amenable to an Array-OL implementation, the subscript function $e^k$ must be affine in $r$ and $j^k$. A convenient way of checking this property consists in computing the two Jacobian matrices: \[ P^k = \left( \frac{\partial e^k_\alpha}{\partial r_\beta} \right) \quad B^k = \left( \frac{\partial e^k_\alpha}{\partial j^k_\beta} \right), \] checking that they do not depend on \( r \) or \( j^k \), and verifying the identity: \[ e^k(r, j^k) = P^k r + B^k j^k + e^k(0, 0). \] In Array-OL terminology, \( P^k \) is the paving matrix, and \( e^k(0, 0) \) is the origin of the paving. The elements of these entities may be numbers, or they may depend on constants, which must be given numerical values just before code generation. References with different paving matrices may be separated by arbitrary distance in the source or target array; it is not possible to group them efficiently; they must be implemented as separate channels. In the following example: \[ \text{myTE( in[], out[]){} for(i=0; i<7; i++) // boucle TE { for ( k=0; k<11; k++) { S=0; for(j=0; j<100; j++) { S+= in[0][j+11] * in[i+1][k+j]; } out[ i][k]=S; } } \] there are two references to \( \text{in} \) with respective subscript functions \( e^1(i, k, j) = \begin{pmatrix} 0 \\ j + 11 \end{pmatrix} \) and \( e^2(i, j, k) = \begin{pmatrix} i + 1 \\ k + j \end{pmatrix} \). The corresponding paving matrices are \( P^1 = \begin{pmatrix} 0 & 0 \\ 0 & 1 \end{pmatrix} \) and \( P^2 = \begin{pmatrix} 1 \\ 0 \end{pmatrix} \). Hence, the two accesses must be handled separately. In the following, I assume that accesses to \( A \) have been partitioned according to their paving matrix, and consider only one partition at a time. The size of the repetition space is deduced simply from the bound(s) of the elementary transform loop(s). In the Spear/DE implementation of Array-OL, there may be further constraints on the paving matrix (e.g. that it be a permutation of a diagonal matrix). ### 3 Pattern and fitting A pattern is a compact specification of all the elements of an array that are accessed, with references having the same paving matrix, in one iteration of the external loop(s). When discussing patterns, one has to consider three frames of reference (see Fig. 1). The first one is the original (input or output) array. Its dimension is the rank of the array, Figure 1: Data access in Array-OL noted $|A|$, and its coordinates are called *subscripts*. The shape of an array is always a (hyper-) rectangle. The second frame of reference is the iteration space of the inner loops of the elementary transform. Its dimension is the number of loops enclosing the reference, noted $d^k$, and its coordinates are called *loop counters*. There may be as many iteration domains as there are references, or several references may share the same iteration domain. The shape of an iteration domain is arbitrary. The only requirement in the present context is to be able to construct its vertices, either because the iteration domain is rectangular, or because it can be expressed as a convex polyhedron with parameters in the constant terms only. The iteration domain of reference $k$ will be denoted as $D^k$ in what follows. The third frame of reference is the pattern. According to Boulet [1] the pattern is always of rectangular shape. The pattern associated to reference $k$ is denoted by $T^k$ and its dimension is $p^k$. The associated fitting matrix, $F^k$, connects the pattern space to the array space and its dimension, accordingly, is $|A| \times p^k$. The relation of these objects are as follows. Firstly, the local subscript function $f^k(j^k) = B^k j^k + e^k(0,0) = e^k(0, j^k)$ gives the coordinates of an array cell relative to the reference point $P^k$ which moves according to the paving matrix. Next, the image $f^k(D^k)$ is the *footprint* of reference $k$. Its shape is arbitrary. The images of the vertices of $D^k$ by $f^k$ form a superset of the vertices of the footprint; a representation as a convex polyhedron can be recovered by one application of the Chernikova algorithm [3]. Lastly, the image of the pattern by the fitting matrix must enclose the footprint, and it must be feasible to retrieve a datum from the pattern instead of the original array. This implies that there exists a function $\phi^k$ from $D^k$ to $T^k$ such that for every iteration vector $j^k \in D^k$, $f^k(j^k) = F^k \phi^k(j^k)$. In the text of the elementary transform, $\phi^k$ must be substituted to $e^k$ in reference $k$ to $A$. As one may see from this discussion, while the iteration domain and footprint are fixed once the sequential program is given, the choice of the pattern and fitting matrix are somewhat arbitrary. There are two obvious solutions: in the first one, the pattern is the smallest rectangular box enclosing the footprint, the fitting matrix is the identity, and the subscript function is not changed. In the second solution, the pattern is isomorphic to the iteration domain (provided it is a parallelepiped), \( B^k \) is the fitting matrix, and the new subscript function is the identity. In signal processing applications, it is often the case that several references to the same array have similar subscript functions; constructing only one pattern for several references is an interesting optimization. However, this should not be obtained at the cost of a large overhead in the size of the pattern. In other word, the number of useless elements in the pattern must be minimized. Useless elements come from two sources: - A subscript matrix which is not of full row rank: the pattern will have more dimensions than the footprint. - A subscript matrix whose determinant is not of modulus one: there will be holes (unused elements) in the footprint. The inverse of the determinant gives an asymptotic evaluation of the ratio of useful elements. The next section presents a method for computing a pattern and a fitting matrix in the general case (many references). This method can only be applied if all elements of the matrices \( B^k \) and the vectors \( b^k \) have known numerical values. Section 5 presents fail-soft solutions for cases in which these elements depend on unknown parameters. 4 The General Case The basic observation is that a conservative estimate of the footprint can be obtained by computing the projection of each iteration domain by the associated subscript function, then constructing a convenient superset of the union of these projections. One practical method consists in projecting the vertices of the iteration domains. One then gathers all such projections, and constructs their convex hull by familiar (e.g., Chernikova’s) algorithms. To reduce the size overhead, one should notice that a useful point for reference \( k \) also belongs to the lattice which is generated by the column vectors of \( B^k \). Hence, \( B^k \), properly simplified (see later) could be used as the fitting matrix. However, in the case of several references, we have to combine several lattices into one, since each pattern has only one fitting matrix. As an illustration of this construction, consider the one dimensional case. A one-dimensional lattice is simply a set of regularly spaced points. Combining two lattices generates a lattice whose spacing is the gcd of the component spacings. The many-dimensional equivalent of the gcd is the construction of the Hermite normal form of the subscript matrices. Let \( \Lambda(B,b) \) be the lattice generated by \( B \) with origin \( b \), i.e. the set of points \( \{ Bx + b \mid x \in \mathbb{N}^d \} \). Let \( L^1 = \Lambda(B^1, b^1) \) and \( L^2 = \Lambda(B^2, b^2) \) be two such lattices. I claim that the union of \( L^1 \) and \( L^2 \) is included in the lattice \( L = \Lambda([B^1 B^2(b^2 - b^1)], b^1) \). **Proof** Let \( B^1.x + b^1 \) be a point of \( L^1 \). We have: \[ B^1.x + b^1 = B^1.x + B^2.0 + (b^2 - b^1).0 + b^1 \] hence \( B^1.x + b^1 \) is in \( L \). Similarly: \[ B^2.y + b^2 = B^1.0 + B^2.y + (b^2 - b^1).1 + b^1. \] I conjecture that $L$ is the smallest lattice which includes $L_1$ and $L_2$. The proof is obvious if the $b$s are null. The general case is left for future work. The construction can be extended to any number of component lattices. The resulting matrix is $[B^{1} \ldots B^{N} (b^{2} - b^{1}) \ldots (b^{N} - b^{1})]$ and the origin is $b^{1}$. Furthermore, $b^{1}$ can be moved to the origin of the paving and hence taken as 0 when computing the fitting. In case where $B$ has been obtained by mixing many references, it must be simplified before being used for an Array-OL specification. The starting point of this simplification is the row echelon form of $B$. One can show (see the appendix) that there exists two unitary matrices $P$ and $U$ such that: $$B = P \begin{bmatrix} H & 0 \\ C & 0 \end{bmatrix} U,$$ where $H$ is a square upper triangular matrix of size $r \times r$ with positive diagonal coefficients, $C$ is arbitrary, and both 0 represent null matrices of appropriate sizes. $r$ is the row rank of $B$. Furthermore, $U$ can be partitioned, row wise, in two matrices of size $r \times d$ and $(d-r) \times d$, $$U = \begin{bmatrix} U' \\ U'' \end{bmatrix}.$$ Let $j$ be a point in the iteration domain of the inner loops. The corresponding point in the footprint is: $$Bj = P \begin{bmatrix} H & 0 \\ C & 0 \end{bmatrix} \begin{bmatrix} U' \\ U'' \end{bmatrix} j \quad (1)$$ $$= P \begin{bmatrix} H \\ C \end{bmatrix} (U'j) \quad (2)$$ One possible interpretation of this formula is that the pattern for the current reference is the image of its iteration domain by $U'$, and that the corresponding paving matrix is $P \begin{bmatrix} H \\ C \end{bmatrix}$. In the body of the elementary transform, accesses to $Bj$ in the input or output array have to be replaced by accesses to $U'j$ in the pattern. It may be that the pattern computed in this way is not rectangular, in which case it must be “boxed” by computing the component-wise minima and maxima of its extreme points. The dimension of the pattern is $r$. It is interesting to notice that this general solution reduces to one of the approximate methods above in special cases. If $B$ is unitary, then its row echelon form is the unit matrix. In that case, the pattern is the footprint, eventually extended to a rectangular box and the fitting matrix is the identity. Conversely, if $B$ is already in row echelon form, $P$ and $U$ are identities. The pattern is isomorphic to the iteration space, and $B$ is the fitting matrix. 5 The Parametric Case Parameters occurs mostly in loop bounds. They may also appear as strides and, more seldom, in the coefficients of subscript functions. In the Array-OL formalism, the repetition loops must be square. Hence, their bound may be extracted directly from the program text. The extraction of the paving matrix is a simple derivative computation, which is an easy task for a competent computer algebra system. Similarly, the $B^k$ matrices are the result of a derivation, and may contain parameters. There are no restrictions on the inner loops. For the construction of the pattern, one needs to know the vertices of the inner iteration domain. There are three cases: - The bounds are constant: they can be extracted even if parametric. - The bounds are affine expressions in other loop counters and parameters: the vertices can be computed with the help of the polylib. - In other cases, there is no way of computing vertices, but the user may supply a bounding box. The computation of the row echelon form can be done only if the matrix is known numerically, except in two cases: the matrix is $1 \times 1$ (it is its own normal form) or $2 \times 2$. The row echelon form of $\begin{pmatrix} a & b \\ c & d \end{pmatrix}$ is $\begin{pmatrix} \gcd(a,b) & 0 \\ cu + dv & (ad - bc)/\gcd(a,b) \end{pmatrix}$ where $u$ and $v$ are the integers such that $au + bv = \gcd(a,b)$ whose existence is guaranteed by Bezout identity. If none of these circumstance applies, the solution of last resort is to use one of the approximate schemes above. For instance, if the vertices of the inner iteration domain are available, it is possible, whatever the $B$ matrix, to compute the vertices of the footprints and to enclose them in a rectangular box. The paving matrix is then the identity. ## 6 Extensions The Syntol tool computes dependences; it is thus possible to check that the repetition loops are actually parallel. One must take care that Syntol will find dependences if temporary scalars are used in the code of the elementary transforms. These scalars must be expanded or privatized at code generation time. Overlap between patterns (or, rather, between footprints) is another concern. For input arrays, overlap is just a cause of inefficiency, since some arrays cells will be copied several times to processors. Overlap for output arrays are more dangerous since they may induce non-determinism. The existence of overlap may be tested provided one stays inside the polytope model (affine loop bounds and indexing functions, with numerical coefficients and linear parameters). In the same context, it is possible to quantify the overhead by comparing the size of the pattern and the size of the real footprint using the barvinok library [4]. ### A Computing the row echelon form of a matrix For more details, see [3]. Let $B$ be an arbitrary matrix of size $p \times q$. 1. At any stage of the computation, we have constructed two unitary matrices $P$ and $U$ such that: $$B = PB'U, \quad B' = \begin{bmatrix} H & 0 \\ C & D \end{bmatrix}$$ where $H$ is lower triangular with positive diagonal coefficients. Initially, $P$ and $U$ are identity matrices, $H$ and $C$ are empty and $D = B$. Let $i$ be the index of the first row of $C$ and $D$. 2. If $D$ is null, the process stops. 3. If not, let $j$ be the index of some non zero row of $D$. Let $\pi_{ij}$ be the unitary matrix that permutes rows $i$ and $j$ of $B'$. Since $\pi_{ij}$ is its own inverse, one can write: $$B = (P\pi_{ij})(\pi_{ij}B')U,$$ and the new $D$ has a non zero first row. 4. Let $k$ be the index of a negative element in the first row of $D$. Let $\sigma_k$ be the unit matrix with the $k$-th diagonal element set to $-1$. Since $\sigma_k$ is its own inverse, one can write: $$B = P(B'\sigma_k)(\sigma_kU),$$ and element $k$ in the first row of $D$ is now positive. 5. If all elements in the first row of $D$ are positive, let $l$ be the index of the smallest element, and let $\pi_{il}$ be the matrix that interchange columns $i$ and $l$ of $B'$. Again: $$B = P(B'\pi_{il})(\pi_{il}U)$$ and now the first element of the first row of $D$ is smallest. 6. Let $m > i$ be the index of some nonzero element in the first row of $D$. Set $\alpha = B'_{im} \div B'_{ii}$. By construction, $\alpha > 0$. Let $\kappa_{im}(\alpha)$ be the identity matrix with $-\alpha$ added in position $(i, m)$. It is easy to see that the inverse of $\kappa_{im}(\alpha)$ is $\kappa_{im}(-\alpha)$. Hence: $$B = P(B'\kappa_{im}(\alpha))(\kappa_{im}(-\alpha)U)$$ and element $B'_{im}$ has been replaced by $B'_{im} \mod B'_{ii}$. 7. If the only non-zero element of the first row of $D$ is the first element, then $i$ can be increased by 1. These transformations must be applied until no further progress is possible (i.e. when in case 2). Matrix $B'$ is in the required form, and since all the elementary matrices $\pi, \sigma$ and $\kappa$ are unitary, the resulting $P$ and $U$ are unitary. In fact, $P$ is even a permutation matrix. References
{"Source-Url": "https://hal-lara.archives-ouvertes.fr/hal-02102502/file/RR2007-28.pdf", "len_cl100k_base": 5137, "olmocr-version": "0.1.53", "pdf-total-pages": 10, "total-fallback-pages": 0, "total-input-tokens": 26666, "total-output-tokens": 5892, "length": "2e12", "weborganizer": {"__label__adult": 0.000408172607421875, "__label__art_design": 0.0007157325744628906, "__label__crime_law": 0.0005030632019042969, "__label__education_jobs": 0.0006427764892578125, "__label__entertainment": 0.0001342296600341797, "__label__fashion_beauty": 0.0001989603042602539, "__label__finance_business": 0.0003032684326171875, "__label__food_dining": 0.00045609474182128906, "__label__games": 0.0006198883056640625, "__label__hardware": 0.0028171539306640625, "__label__health": 0.0006976127624511719, "__label__history": 0.0003848075866699219, "__label__home_hobbies": 0.00015926361083984375, "__label__industrial": 0.0010976791381835938, "__label__literature": 0.00025153160095214844, "__label__politics": 0.0004072189331054687, "__label__religion": 0.0007619857788085938, "__label__science_tech": 0.248046875, "__label__social_life": 0.0001246929168701172, "__label__software": 0.01062774658203125, "__label__software_dev": 0.72900390625, "__label__sports_fitness": 0.0004868507385253906, "__label__transportation": 0.0009217262268066406, "__label__travel": 0.0002446174621582031}, "weborganizer_max": "__label__software_dev", "avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_ratio": [[0, 20730, 0.02977]], "fineweb_edu_fasttext_gt2__fineweb_edu_fasttext_gt2__score": [[0, 20730, 0.76275]], "ft_lang_id_en_doc_v2__ft_lang_id_en_doc_v2__en": [[0, 20730, 0.83562]], "google_gemma-3-12b-it_contains_pii": [[0, 899, false], [899, 1001, null], [1001, 2183, null], [2183, 4831, null], [4831, 7048, null], [7048, 9407, null], [9407, 12742, null], [12742, 15685, null], [15685, 18529, null], [18529, 20730, null]], "google_gemma-3-12b-it_is_public_document": [[0, 899, true], [899, 1001, null], [1001, 2183, null], [2183, 4831, null], [4831, 7048, null], [7048, 9407, null], [9407, 12742, null], [12742, 15685, null], [15685, 18529, null], [18529, 20730, null]], "google_gemma-3-4b-it_v2tag__is_academic_paper": [[0, 5000, true], [5000, 20730, null]], "google_gemma-3-4b-it_v2tag__is_class_syllabus": [[0, 5000, false], [5000, 20730, null]], "google_gemma-3-4b-it_v2tag__is_completion_certificate": [[0, 5000, false], [5000, 20730, null]], "google_gemma-3-4b-it_v2tag__is_court_notice": [[0, 5000, false], [5000, 20730, null]], "google_gemma-3-4b-it_v2tag__is_homework_assignment": [[0, 5000, false], [5000, 20730, null]], "google_gemma-3-4b-it_v2tag__is_news_article": [[0, 5000, false], [5000, 20730, null]], "google_gemma-3-4b-it_v2tag__is_public_order": [[0, 5000, false], [5000, 20730, null]], "google_gemma-3-4b-it_v2tag__is_resume_cv": [[0, 5000, false], [5000, 20730, null]], "google_gemma-3-4b-it_v2tag__is_test_or_quiz": [[0, 5000, false], [5000, 20730, null]], "google_gemma-3-4b-it_v2tag__is_textbook": [[0, 5000, false], [5000, 20730, null]], "pdf_page_numbers": [[0, 899, 1], [899, 1001, 2], [1001, 2183, 3], [2183, 4831, 4], [4831, 7048, 5], [7048, 9407, 6], [9407, 12742, 7], [12742, 15685, 8], [15685, 18529, 9], [18529, 20730, 10]], "pipe_delimited_lines_v1__pipe_delimited_lines_v1__pipe_delimited_lines_ratio": [[0, 20730, 0.0]]}
olmocr_science_pdfs
2024-12-10
2024-12-10
953846e9d2d060b28ea29c5c5661edf138ffb0ef
USING A* FOR THE PARALLELIZATION OF SPEECH RECOGNITION SYSTEMS Patrick Cardinal\textsuperscript{1,2}, Gilles Boulianne\textsuperscript{1} and Pierre Dumouchel\textsuperscript{1,2} \textsuperscript{1}Centre de Recherche Informatique de Montréal (CRIM), Montréal, Canada \textsuperscript{2}École de Technologie Supérieure, Montréal, Canada Email: \{patrick.cardinal, pierre.dumouchel, gilles.boulianne\}@crim.ca ABSTRACT The speed of modern processors has remained constant over the last few years but the integration capacity continues to follow Moore’s law and thus, to be scalable, applications must be parallelized. This paper presents results in using the A* search algorithm in a large vocabulary speech recognition parallel system. This algorithm allows better parallelization over the Viterbi algorithm. First experiments with a "unigram approximation" heuristic resulted in approximately 8.7 times less states being explored compared to our classical Viterbi decoder. The multi-thread implementation of the A* decoder led to a speed-up factor of 3 over its sequential counterpart. Index Terms— Speech recognition, A*, parallelization 1. INTRODUCTION Large vocabulary automatic speech-recognition is a computationally intensive task. Most speech recognizers run under a sequential implementation that cannot take advantage of modern processors with multi-core technology. In order to exploit this power, a parallel speech recognition system must be implemented. The two major time consuming components are the acoustic likelihood computation and the optimal path search. The first component takes 30%-70% of total time. This calculation involves mostly arithmetic operations than can be computed by a dot product. This allows an efficient implementation in a SIMD (Single Instruction Multiple Data) parallel architecture such as SSE registers or a graphic processor (GPU) [1]. The search component consumes most of the remaining time. The classic way to perform the decoding uses the Viterbi algorithm. This algorithm is simple and straightforward to implement. It is nonetheless difficult to achieve an efficient parallelized version of the Viterbi algorithm on a classical multicore computer. The main reason is that only 1% of the states are active at each frame and these are scattered in memory. This situation adds to the well established difficulty of having to search a sparse graph on a parallel architecture of the Intel processor type [2]. A parallel implementation of a speech recognition system is presented by Phillips et al. [3]. Their system builds the transducer on the fly during the decoding process. They have obtained a performance of 0.8x real-time on a 16 CPU computer for the North American Business News (NAB) database. This is a speed-up of 4.87 compared to 3.8x real-time on a single CPU. Parihar et al. implement the parallelization of the search component of a lexical-tree based speech recognizer [4]. In this work, lexical-tree copies are dynamically distributed among the cores to ensure a good load balancing. This results in a speed-up of 2.09 over a serialized version on a Core i7 quad (4 cores) processor. The speed-up is limited by the memory architecture. In [5], Ishikawa et al. implemented a parallel speech recognition system in a cell phone using a 3-core processor. The system was divided in 3 steps, one for each core. They reported a speed-up factor of 2.6 but their approach is not scalable since involved steps are not easily parallelizable. This paper presents results of using the A* search algorithm in a large vocabulary speech recognition parallel system. This approach has previously been applied to speech recognition by [7]. It divides the search operation into two steps. The first step is the computation of a heuristic that yields an estimate of the cost for reaching the final state from any given state in the graph. The second step is a best-first search driven by the heuristic. The advantage of this approach is that the heuristic can be constructed to allow an efficient computation in parallel. The search itself is still difficult to parallelize, but it can be reduced by using a good heuristic since, in this case, a smaller number of states will be explored. This paper is organized as follows. Section 2 presents the A* algorithm and how it is used in the context of speech recognition. Section 3 presents preliminary experimental results obtained on a large vocabulary speech recognition task. 2. A* DECODER Unlike the time synchronous Viterbi algorithm, the A* algorithm is a best-first scheme, that implies a scoring procedure to explore the most promising states. The score of a state is \[ \text{Score}(q) = g(q,t) + h(q',t+1) + \text{cost}(q,q') \] where \( g(q,t) \) is the score for reaching state \( q \) from the initial one at time \( t \), \( h \) is the heuristic score that gives an estimation of the cost for reaching a final state from the adjacent state \( q' \) at time \( t+1 \) and \( \text{cost}(q,q') \) is the cost for going to \( q' \) from \( q \). A heuristic is said to be admissible if, for every state, it underestimates the real cost for reaching the final state. In that case, the A* algorithm is optimal. A pseudocode of the A* algorithm is shown in Algorithm 1. For simplicity, epsilon transition handling has not been illustrated in this algorithm. The input of the algorithm is the HCLG recognition network composed of HMMs (H), triphone context dependency (C), lexicon (L) and a trigram backoff language model (G). This network is represented by a WFST \( \mathcal{W} = (Q, I, F, \Sigma_i, \Sigma_o, E, \lambda, \rho) \) where \( Q \) is a set of states, \( I \subset Q \) is the initial state, \( F \subseteq Q \) is the set of final states, \( \Sigma_i \) is the input alphabet of the automaton (distributions), \( \Sigma_o \) is the output alphabet of the automaton (words), \( E \subseteq Q \times \Sigma_i \times \Sigma_o \times \mathbb{R} \times Q \) is the set of transitions, \( \lambda : i \rightarrow \mathbb{R} \) is the initial weight function and \( \rho : F \rightarrow \mathbb{K} \) is the final weight function. The second input is the heuristic function \( h : q.t \rightarrow \mathbb{R} \) which gives the estimated cost for reaching a final state from state \( q \) at time \( t \). Algorithm 1: The A* algorithm ``` 1 openList ← \{((i,i,0), heuristic(i,0))\} 2 closedList ← \emptyset 3 while openList ≠ \emptyset do 4 // Extract state with lowest score 5 (q, t, g) ← openList.Extract() 6 closedList ← closedList ∪ (q, t) 7 if \( q \in F \) and \( t = \text{numFrames} \) then 8 // Best path found 9 ExitSearch() 10 end 11 foreach \( (q', r, w, q) \in E[q] \) do 12 if \( (q', r+1) \notin \text{closedList} \) then 13 \( \text{g}' \leftarrow g + \text{obsCost}((\sigma, r) + w) \) 14 \( h \leftarrow \text{heuristic}(\text{g}', r+1) \) 15 \( \text{score} \leftarrow \text{g}' + h \) 16 openList ← openList ∪ \{(entry, score)\} 17 end 18 end 2.2. Mapping Recognition FST States to Heuristic States Recall that an A* search uses the heuristic cost given by the function \( h(q_r, t) \), where \( q_r \) is a recognition FST state. In essence, this function performs a lookup in the Viterbi trellis computed on the heuristic. Thus, we need to know which state \( (q_h, t) \) in the heuristic is equivalent to \( (q_r, t) \). A mapping between states of the heuristic and those of the recognition FST must thus be discovered. To establish this mapping, we can use the FST composition as described by Mohri [8]. The inverted (input and output symbols swapped) heuristic FST is composed with the recognition FST. A state in the composed FST is a pair \( s_h = (i_h, q_h) \) where \( i_h \) and \( q_h \) are, respectively, states of the heuristic and recognition FST. The existence of a state \( (q_h, q_r) \) implies that at least one path from \( i_h \) to \( q_h \) in the heuristic FST has the same distribution sequence than a path from \( i_r \) to \( q_r \) in the recognition FST. Since the composed FST is connected, there is also a path from \( q_h \) to a final state of the heuristic FST that has the same distribution sequence than a path from \( q_r \) to a final state of the recognition FST. Consequently, both states are considered to be equivalent. Note that the FST resulting from the composition is not used, only the list of state pairs is useful. In addition, this mapping is computed offline. 2.3. Block Processing Data structures required for implementing A* are more complex than the simple array used in a Viterbi decoder. The A* algorithm always explores the most promising path first. For efficiency, paths are stored in a binary heap for which the three main operations (insertion, extraction and decrease key) are in \( O(\log n) \). However, the algorithm needs to know if a node is already in the heap before inserting it. Since searching a node in a heap is \( O(n) \), a hash table is used to keep track of nodes in the open list. Moreover, since we don’t want to explore the same node more than one time, we use a closed list of nodes already explored which is also implemented with a hash table. For efficiency, there is an open list (hash table) and a closed list per frame. In addition to complex data structures, the number of nodes to explore grows as the square of the number of frames as is the case with the Viterbi algorithm. To circumvent both problems, a block approach has been implemented as follows. The heuristic is first computed for \( \Delta \) frames. Then, the A* search is performed on the \( \Lambda < \Delta \) first frames. The search stops when a node at time \( \Lambda \) with a cost (path cost + heuristic cost) larger than the best cost added to a user value (beam) is extracted from the open list. The window is then advanced of \( \Lambda \) frames. The process is applied until the end of audio is reached. In order to save computation time, several consecutive searches can be done with one heuristic computation as shown by Figure 1. ![A* search by block](image) **Fig. 1.** A* search by block ### 3. EXPERIMENTATION #### 3.1. Experimental Setup The baseline system for comparison is a FST-based speech recognition system developed at CRIM and tuned for speaker-independent transcription of broadcast news. The acoustic model has been trained with 171 hours coming from French television programs in Quebec. The programs are a mix of weather, news, talk shows, etc. that have been transcribed manually. The acoustic parameters consist of 12 MFCCs plus the energy component, corresponding first and second derivatives, for a total of 39 features. The model contains 4600 distributions of 32 and 128 Gaussians with diagonal covariance matrices. The language model has been trained with text from a French local newspaper (La Presse, 93 million words) and the acoustic training set’s textual transcripts (2.1 million words). Both the unigram and trigram language models use the same vocabulary of 59624 words. The CPU used is an Intel Core i7 quad at 2.9 GHz with 8 GB of RAM. Acoustic computations use the SSE registers. On the baseline version, required acoustic likelihoods are computed on-demand. This optimization is not possible with the A* algorithm since all likelihoods are used for computing the heuristic. For all experiments involving the A* algorithms, the heuristic length \( \Delta \) has been set to 500 frames. A* search is performed on \( \Lambda = 20 \) frames with a lookahead of 100 frames. Thus, for each block of heuristic scores, 20 A* searches are performed. The test set is made up of 44 minutes (2625 seconds) of audio with a duration between 32 and 50 seconds. <table> <thead> <tr> <th>Algorithm</th> <th>Computation time (seconds)</th> <th># of explored nodes</th> <th>Accuracy</th> </tr> </thead> <tbody> <tr> <td>Viterbi</td> <td>2069</td> <td>2 459 801 548</td> <td>68.67%</td> </tr> <tr> <td>A* (1 Thread)</td> <td>6134</td> <td>283 041 383</td> <td>70.01%</td> </tr> <tr> <td>A* (4 Threads)</td> <td>2497</td> <td>283 041 383</td> <td>70.01%</td> </tr> </tbody> </table> **Table 1.** Viterbi vs A* at real time. #### 3.2. Comparison with the Classical Viterbi Table 1 shows the performance of our A* decoder compared to the classical Viterbi decoder. The experiment has been done with 32 Gaussian component distributions. The main advantage of the Viterbi decoder comes from the fact that it computes only 29% of all likelihoods since they are computed on-demand. This allows the Viterbi decoder to perform very well in real time as shown by the results. In the case of the A* decoder, results show that the sequential implementation is slower than the Viterbi decoder. This is mainly due to the acoustic likelihood computation which accounts for 64% of the total time. Recall that all likelihoods must be computed since they are needed for the heuristic. The heuristic computation itself accounts for 27% of the total time. However, the 4 thread version, with a speed-up of 2.46, achieves real-time. This performance could be improved if more thread were available. Note that the number of explored nodes is about 8.7 times smaller in the A* decoder. This is the reason why the search itself account for only 7% of the total computation time. Figure 2 shows results of a second experiment ran with a 128 Gaussian component acoustic model distribution. In this scenario, the real-time accuracy of the Viterbi decoder drops to around 65%, even if only 16% of acoustic likelihoods are computed, search time has to be limited by a low beam value. ![128 Gaussian components A* decoder accuracy vs execution time. Dashed lines are projections.](image) **Fig. 2.** 128 Gaussian components A* decoder accuracy vs execution time. Dashed lines are projections. The A* decoder cannot achieve real time with only 4 threads even with a speed-up of 3 times over its sequential counterpart. However, projection (represented by dashed lines) to 8 threads show that real-time can be reached with an accuracy of 71.62%. With 16 threads real-time accuracy would be 72.29%. Note that for an accuracy of 72%, the A* decoder with 4 threads is 2.27 times faster than the Viterbi decoder. It would be 3.7 and 5.34 times faster with 8 and 16 threads. ### 3.3. Parallelization of Heuristic Computation As described earlier, the heuristic computation operates in 2 steps: computation of acoustic likelihoods and computation of heuristic costs. These steps take more than 91% of the total search time. Table 2 shows how the computation time can be decreased by using multi-core architectures. Experiments have been conducted with 128 Gaussians acoustic models on the whole test set. <table> <thead> <tr> <th>Step</th> <th>Computation time</th> <th>speed-up factor</th> </tr> </thead> <tbody> <tr> <td>Acoustic likelihoods</td> <td>1 thread: 10659 sec</td> <td>4 threads: 2913 sec</td> </tr> <tr> <td></td> <td>1512 sec</td> <td>495 sec</td> </tr> </tbody> </table> Table 2. Heuristic computation speed-up. The first line of Table 2 shows that computation of acoustic likelihoods parallelizes very well in a multicore processor with a speed-up approaching the theoretical maximum of N, where N is the number of cores. Note that this parallelization could also be applied in the classical Viterbi decoder. However, the improvement will not be as significant since likelihoods are computed on-demand and only a subset of the distributions are used. Heuristic costs are computed by applying the Viterbi algorithm on the reversed heuristic FST and starting from the last frame. Note that epsilon transition expansions, which take approximately 8.5% of the Viterbi computation time, are not parallelized. We believe that the theoretical maximum is not being reached on this part because of a misuse of the memory architecture, and that an optimisation of the data structures will enhance performances on multicore processors. ### 4. CONCLUSION This paper presented our current work on the parallelization of speech recognition systems using the A* algorithm. A WFST constructed from a unigram provides an admissible and efficient heuristic making the number of explored states by the A* algorithm 8.7 times smaller compared to the Viterbi algorithm in a real-time scenario. The A* search itself takes less than 7% of the total computation time. Results also show that using 4 cores in a multi-threaded implementation of the heuristic computation led to an overall speed-up factor of 3. The first and more time consuming step is the computation of acoustic likelihoods which parallelization reduced by a factor of 3.7. Computation of heuristic costs was only reduced by a factor of 3, but better reductions should be possible with better data structures. We are confident that our approach will be very useful when computers with 16 or 32 cores will become available in a few years. A* decoding approach is able to take advantage of multiple core processors and is scalable to any number of cores. This will allow speech recognition systems to use all the computational power of 16 or 32 core computers as they will become available in a few years. ### 5. REFERENCES
{"Source-Url": "http://publicationslist.org/data/pierre.dumouchel/ref-83/UsingAStar.pdf", "len_cl100k_base": 4144, "olmocr-version": "0.1.49", "pdf-total-pages": 4, "total-fallback-pages": 0, "total-input-tokens": 15317, "total-output-tokens": 4905, "length": "2e12", "weborganizer": {"__label__adult": 0.0005898475646972656, "__label__art_design": 0.0006008148193359375, "__label__crime_law": 0.0007891654968261719, "__label__education_jobs": 0.0007748603820800781, "__label__entertainment": 0.00019657611846923828, "__label__fashion_beauty": 0.0002532005310058594, "__label__finance_business": 0.0002090930938720703, "__label__food_dining": 0.0005726814270019531, "__label__games": 0.0008707046508789062, "__label__hardware": 0.0059356689453125, "__label__health": 0.0016450881958007812, "__label__history": 0.00037932395935058594, "__label__home_hobbies": 0.00012445449829101562, "__label__industrial": 0.0008616447448730469, "__label__literature": 0.0004763603210449219, "__label__politics": 0.0005784034729003906, "__label__religion": 0.00089263916015625, "__label__science_tech": 0.38525390625, "__label__social_life": 0.00012111663818359376, "__label__software": 0.010101318359375, "__label__software_dev": 0.58740234375, "__label__sports_fitness": 0.00047397613525390625, "__label__transportation": 0.0009212493896484376, "__label__travel": 0.0002378225326538086}, "weborganizer_max": "__label__software_dev", "avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_ratio": [[0, 18783, 0.03759]], "fineweb_edu_fasttext_gt2__fineweb_edu_fasttext_gt2__score": [[0, 18783, 0.47994]], "ft_lang_id_en_doc_v2__ft_lang_id_en_doc_v2__en": [[0, 18783, 0.88809]], "google_gemma-3-12b-it_contains_pii": [[0, 4749, false], [4749, 9601, null], [9601, 13916, null], [13916, 18783, null]], "google_gemma-3-12b-it_is_public_document": [[0, 4749, true], [4749, 9601, null], [9601, 13916, null], [13916, 18783, null]], "google_gemma-3-4b-it_v2tag__is_academic_paper": [[0, 5000, true], [5000, 18783, null]], "google_gemma-3-4b-it_v2tag__is_class_syllabus": [[0, 5000, false], [5000, 18783, null]], "google_gemma-3-4b-it_v2tag__is_completion_certificate": [[0, 5000, false], [5000, 18783, null]], "google_gemma-3-4b-it_v2tag__is_court_notice": [[0, 5000, false], [5000, 18783, null]], "google_gemma-3-4b-it_v2tag__is_homework_assignment": [[0, 5000, false], [5000, 18783, null]], "google_gemma-3-4b-it_v2tag__is_news_article": [[0, 5000, false], [5000, 18783, null]], "google_gemma-3-4b-it_v2tag__is_public_order": [[0, 5000, false], [5000, 18783, null]], "google_gemma-3-4b-it_v2tag__is_resume_cv": [[0, 5000, false], [5000, 18783, null]], "google_gemma-3-4b-it_v2tag__is_test_or_quiz": [[0, 5000, false], [5000, 18783, null]], "google_gemma-3-4b-it_v2tag__is_textbook": [[0, 5000, false], [5000, 18783, null]], "pdf_page_numbers": [[0, 4749, 1], [4749, 9601, 2], [9601, 13916, 3], [13916, 18783, 4]], "pipe_delimited_lines_v1__pipe_delimited_lines_v1__pipe_delimited_lines_ratio": [[0, 18783, 0.08654]]}
olmocr_science_pdfs
2024-11-24
2024-11-24
80fa29ec1fedb5d7de50f14de1b0c505357d3d0b
To improve life here, To extend life to there, To find life beyond. To understand and protect our home planet, To explore the Universe and search for life, To inspire the next generation of explorers... as only NASA can. The Flight Software Branch develops software for: - Embedded Space Flight Systems - Real-Time Control Systems - Rocket Engine Controllers - Propulsion Control - Video Guidance Sensors - Space Transportation Vehicles - Spacecraft Control - Space Station Systems - Health Monitoring Systems - Microgravity Facilities - Science Experiments - Space Station Payloads Mission Critical Space Flight Software Development - Advanced Video Guidance System (AVGS) for DART - Orbital Express AVGS - Microgravity Experiments - Space Station Payload Facility - Space Station Environmental Control System - Propulsion Engine Controllers Software Technical Insight - Requirements for Human Rated Software - Space Shuttle Main Engine (SSME) - SSME Advanced Health Monitoring Test Procedures and Facility Software - Engine Controller Software - Autonomous Vehicle Software - Spacecraft Software - Space Station Element Software - Space Station Payload Software - Scientific Instrument Software - Autonomous Docking and Rendezvous Software Advanced Software Development Technologies - Web-based Software Coding Standard Checker - Software Complexity Analysis Tool - Software Tool Research - Software Metrics Tools - Health Monitoring Software - Use of Generic Algorithms - Applying Soft Computing to Engine Control Software Continuous Improvement in the Software Development Processes and Methods - Software Acquisition Improvement - Agency Software Engineering Requirements - Software Development and Organizational Metrics - Industry Best Practices - Process Asset Library - Industry Process Improvement Model - Defect Metrics - Productivity Data and Metrics - Process Improvement - Risk Management - Software Costing Models - Software Engineering Training Flight Software Branch Mission Critical Space Flight Software Development - Software is critical in any Space Launch and Transportation System - With modern systems, the unique functions are increasingly embodied in the software - Software engineering has provided missions with capabilities that would not be practical with any other technology Space Shuttle Main Engine Software Over 100 STS missions supported with zero in-flight software anomalies AVGS on DART gLIMIT Flight Unit UPA Flight Software Development Team Flight Software Branch Continuous Improvement in the software development processes and methods • Currently using the DOD model for benchmarking our software process improvement activities • Leading the agency in Software Process Improvement Software metrics We are using Software development and organizational metrics to manage our software projects Capability Maturity Model (CMM) Level 1 - Initial Level 2 - Repeatable Level 3 - Defined Level 4 - Managed Level 5 - Optimizing Continuously improving process Predictable process Standard, consistent process Disciplined process Flight Software Group Goal To improve our software development processes to enable the Flight Software Group to develop higher quality flight software - Producing software with fewer defects - Producing better schedule estimations - Providing better resource estimations - Increase software productivity Profile of programming languages used on MSFC Flight Software Projects <table> <thead> <tr> <th>Programming Languages</th> <th># of MSFC Projects</th> </tr> </thead> <tbody> <tr> <td>C</td> <td>39</td> </tr> <tr> <td>Ada</td> <td>9</td> </tr> <tr> <td>Assembly</td> <td>5</td> </tr> <tr> <td>C++</td> <td>5</td> </tr> <tr> <td>Forth 83</td> <td>2</td> </tr> </tbody> </table> Example Flight & Ground Products HMC EU Rack MSRR 1553 Board UPA Processor Board EDAS SRB Hardware SXI Data Electronics Box Mission Software: Architecture Embedded spacecraft, instrument and hardware component software Science data systems including data processing, archival, distribution, analysis & info mgmt. Real-time ground mission data systems for spacecraft integration and on-orbit ops (e.g., S/C command & control, launch and tracking services) Off-line mission data systems (e.g., command mgmt., S/C mission and science planning & scheduling, guidance & navigation, network scheduling) Lower layers provide portable interface: This enables higher reuse of applications Different Domains of Software Each Reflect A Different Emphasis Flight Software - driven by limited S/C life, asset survival, & mission science program - continuous critical real-time ops, from attitude control to H&S monitoring - fixed & constrained environment - minimize risk with a never fail mindset - restricted maintenance opportunities Science Data Management & Data Processing - data retention & integrity driven - near-time and later ops, from raw archival to signature calibrations and analysis - flexible & extendable environment - data fail soft mindset - - shadow mode and add-on maintenance Mission Control Ground Systems - driven by limited S/C life, asset health, and observatory user demands - episodic real-time & near-time ops, from command uplink to system state evaluations - open to needs based augmentation - risk adverse with a fail soft/over mindset - full shadow maintenance capability Science Data Dissemination - science evolution & user driven - near-time and later ops - large user communities - evolving user interfaces & access demands - timely data delivery mindset - shadow mode and add-on maintenance Flight Software Requirements Drivers #1 Mission and Project Requirements Spacecraft, Instruments, Operations, Performance Schedule, Funds #2 Mission Systems Engineering Flight Hardware Redundancies Onboard Autonomy Onboard Failure Handling Philosophy #3 Guidance, Navigation & Control GN&C Hardware Decisions, Specs. & ICDs Control Modes, Control Algorithms, Control Options #4 Science Instruments Data Rates, Interfaces to s/c, Data Handling, Data Processing, Algorithms Event Handling #5 Science & Mission Operations Data Flows Planning/Scheduling Ground Contact Strategies #6 Electrical Subsystems Flight Data System Architecture Specs. and ICDs (RF, CPUs, memory, buses, data storage, power) #7 FSW Test, Maintenance & Remote Troubleshooting Strategies Diagnostics, Flight Database, Loads, Dumps #8 Special Hardware/Software I&T Reqmts. Direct ground commanding of flight hardware #9 Pre-launch and Launch Reqmts. Launch-unique Configurations Launch Vehicle Separation In-orbit Sun Acquisition Project Management Considerations: Key Documents / Deliverables (more than code) - Software life-cycle products include - Product Plan / Software Management Plan - Software Requirements Document (SRD) - Interface Requirement Document(s) (IRDs) & Interface Control Documents (ICDs) - Software Requirements traceability matrix - Functional and Detailed Design Documents - Source code - Software Test Plan(s) - Test and Verification Matrix - Software User’s Guide - Release Letters - Delivery, Installation, Operations, and Maintenance Plan(s) - Configuration Management Plan - Risk Management Plan - Software Assurance Plan - Software Safety Plan Software Metrics Approach - Standard Management principle related to metrics - What gets measured gets managed. - What gets managed gets done. - However, what does not get measured and managed often gets ignored. - Three basic building blocks of any successful measurement program - Measure is a consistent but flexible process that must be tailored to the unique information needs and characteristics of a particular project or organization. - Decision makers must understand what is being measured. - Measurements must be used to be effective. The measurement program must play a role in helping decision makers understand project and organization issues. Metrics Management Process The Software Team collects metric data: Manual Collection using EXCEL Automated Collection using PVCS Tracker - Computer Resources - Program Size - SLOC - Stability – Requirements - Program Size – Coding - Program Size – Testing - Software Change Request Software Project Lead reports the project metrics to the FSG Metrics Coordinator. Reports are generated and analyzed. The FSG Metrics Coordinator archives Metrics Data and Documentation in the Process Asset Library (PAL). **MSFC’s Software Trend Charts** Software development manpower trends Software requirements stability trend Software Source Lines of Code Development Trend Software test procedures development and execution trends Software Change Request Status trends Software Change Request Identification Methods Defect Origination by Lifecycle Phase Number of Defects per CSC RIDs and Software Problem Reports (SPRs) trends Defect Reports and Trending MSRR SCR's bar chart UPA Lifecycle Phase AVGS SCR's (line graph) Category of Defects Space Flight Software Best Practices - Fault case issues shall be addressed and solutions incorporated into the design as early as practical. - The flight software shall be designed to support measurement of computing resources, such as throughput and memory. - The software self-test and built-in test routines shall be removable for flight. - The information system design shall have engineering emergency data modes and formats (measurements) for diagnostic use. - Flight software loads/updates and sequence memory loads, particularly for those affecting mission critical capability, shall be verified by a memory readout or checksum readout. - The telemetry system end-to-end design shall permit ground operators, early in the ground tracking pass, to determine rapidly and unambiguously the state of the spacecraft, particularly to determine if the spacecraft executed a fault protection response. - Flight software shall be designed to accommodate processor resets during mission-critical events, such as entry/descent/landing. - Flight software shall be designed to detect and respond to incorrectly formatted commands, data, or loads, and memory faults allocated to the software, such as stuck bits or single event upsets (SEU). - Software shall be designed to tolerate and continue functioning in situations where inputs are temporarily missing. - Software shall be demonstrated to be free of deadlocks. - Software shall be designed to protect against incorrect use of memory: Execution in data areas, unused areas, and other areas not intended for execution, Unintended over writing of code areas. Space Flight Software Best Practices - Software shall be designed to ensure that data sets and parameter lists are consistent with respect to time when passed among processes such as software subsystems, rate groups, and others. For example, software shall not be interrupted in a manner that permits it to use both old and new components of a vector. - Shall be the responsibility of any organization proposing to procure off-the-shelf software to document, prior to procurement, the plan for certifying that such software can be assigned the same level of confidence that would be required of equivalent software obtained through a "development" process. - The System shall assess the use of dissimilar redundancy in the design of critical functions, as a defense against common cause failure. - The flight crew should be able to override automatic initiation sequences. - Software safety shall be an integral part of the overall system safety and software development efforts associated with human rated space flight systems. - The control of vehicle flight path and attitude, during dynamic phases of flight such as ascent and entry, shall be provided by independently developed and redundant software systems. - Use of Independent Verification and Validation (IV&V) - Electronic access to all software products - Uniform Coding Standards - The contractor and subcontractors associated with S/W development responsibilities shall be at Software Engineering Institute Software Capability Maturity Model Level II or higher. Software for Intelligent System Health Management (ISHM) Briefing For IEEE Computer Society, UAB October 20, 2004 Luis Trevino, Ph.D. Advanced Sensors & Health Management Systems Branch Spacecraft & Vehicle Systems Department Engineering Directorate, MSFC Briefing Agenda - Thoughts - Identified Technologies Relevant To Technical Themes of ISHM - Overview of Health Management Paradigms Overview of Health Management Paradigms - Health Management (HM) technologies determine health of components / systems and subsystems for the purpose of informed-decision making either with humans in the loop or via Intelligent Autonomous Control. - Applicable to all aspects of space exploration – launch vehicles, CEV, upper stages, insertion/ascent stages, planetary habitats, etc. - Technologies contributing to health management capabilities include: 1) Advanced software algorithms, models, and software development technologies 2) Fault Detection Diagnosis (including discrimination between component failures, sensor failures, internal software anomalies, actuator failures and nominal transients), and recovery (or mitigation) 3) Prognostics – the estimation of remaining life 4) Information Fusion 5) Degradation Management 6) Smart Data Compression 7) HM Technology Design Tools – HM needs to be incorporated as an integral part of the design process rather than an add-on. This will require a paradigm shift 8) Software dependability (health management of software) Overview of Health Management Paradigms Autonomy and Intelligence (Per H&RT SISM Team) - Autonomy is a combination of three attributes: 1. Task complexity 2. Robustness to unexpected circumstances 3. Level of human commanding - Any program or device that can perform complex tasks in changing or incompletely known environments with little human oversight is by this definition autonomous. Thus from a systems engineering point of view, autonomy should be considered for any task that is non-trivial, is performed in an environment that cannot be fully predicted or controlled, and for which human oversight is limited or unavailable. - This last criterion, the unavailability of human oversight, plus the finite speed of light, are the fundamental source of NASA-unique autonomy requirements – no other agency, and generally no private companies who are not working for NASA, need to perform complex tasks far enough from earth that detailed human oversight becomes impractical. - Intelligence pertains to the ability of devices and systems to be able to perform complex tasks robustly with limited human oversight (life support, power, propulsion, etc.) Overview of Health Management Paradigms 1. Intelligence Enables Safe Vehicle Operation (Per CRAI & MSFC Activities) a. Greatly increase Crew Safety and Mission Success 1) Vehicle can continue to sustain crew & meet mission objective during communications disruptions a) Critical factor in going to Mars b) Eliminates crew safety dependence on remote communications capabilities 2) Automated functions respond to unexpected events in milliseconds, manual onboard functions respond in minutes, ground functions can take minutes to hours. 2. Intelligence Minimizes Crew and Vehicle Size a. Autonomy allows small crew sizes to safely operate complex vehicle functions b. Enables smaller vehicles 1) Reduced crew size affects living space volume, consumable storage, life support systems 3. Intelligence Minimizes Ground Operations Staff a. Autonomy increases crew safety and mission success b. Autonomy reduces current ground staff which are expensive to operate c. Autonomy reduces issues with variance in Martian vs. Earth day cycle d. Ground based flight support 1) Maintain status of mission for NASA and public 2) Distribute Science Information 3) Provide engineering support in the event of major vehicle failures Overview of Health Management Paradigms Intelligent Integrated Vehicle Management (IIVM) - Navigation & Guidance - Communications & Tracking - Vehicle Monitoring - Information Transport & Integration - Vehicle Control - Vehicle Diagnostics - Vehicle Prognosis - Mission Planning - Human Computer Interface (HCI) - Repair & Replacement - Onboard Verification & Validation (Per CRAI Activity) Avionics - ISHM/IVHM Ground Operations (current practice) Autonomous Mission Manager (AMM) Overview of Health Management Paradigms - Vehicle Level Management Functions - GN&C - C&T - Mission Planning - Vehicle Control - Subsystem Focused Management Functions - Monitoring - Diagnostics - Prognostics - Subsystem Control ARC – Houston Software Engineering Technology Workshop April 20-22, 2004 - Participants from DFR, LaRC, ARC, MSFC, GRC, JPL, JSC, & FAA - Used IVHM as example to address 2010 & 2024 gaps and needs - Today primarily a mixture of subsystems of Health Management - Monitoring, diagnostics, prognostics, trending (dealing with degradation) - Rigorous semantics: be able to reason about behavior (SE Tools) - Verification & Certification - Big Issue / Gap: How to build, test, & trust (incremental process) - Standard components defined in a way that enable auto verification - Levels of abstraction must not inhibit depth of diagnosis - "Technology will come up with a good idea" (Dan Cooke) Identified Technologies Relevant To Technical Themes of ISHM Real Time Intelligent Software Elements List - Software health management: self-monitoring, self-configuring healing and recovery, self validating (usage of interlocks, fail-safe, self checking mechanism techniques, model-based approaches) - Model-based software fault recovery and software fault avoidance - Real Time Onboard data mining and software trend analysis - Enhanced on-board data storage, processing, and data retrieval (including data compression techniques, data integrity and quality, spacecraft as a web server, IP data routing, secure access) - Advanced architecture & frameworks for Software Identified Technologies Relevant To Technical Themes of ISHM Real Time Intelligent Software Elements List - Onboard mission and maneuver planning, execution, attitude control, and collision avoidance - Intelligent machine / human relationships: Natural language high level task uploads, interface to direct science and spacecraft goals & priorities - System Real-time and health monitoring and automated fault detection, avoidance, isolation, & recovery - Advanced software techniques to address Single Event Upsets Identified Technologies Relevant To Technical Themes of ISHM Real Time Intelligent Software Elements List - Dynamic on-board reconfiguration of flight software - System and Software Real-time performance tuning - Enhanced software voting techniques - Automated sensor & actuator calibration and integration - Partitioning between mission and non-mission critical applications Identified Technologies Relevant To Technical Themes of ISHM Intelligent Software Engineering Tools - Software analysis tools including software reverse engineering tools, static software analysis tools, and real-time software analysis and verification tools (e.g., prediction of software defects and of future software system trajectories & validation envelope penetration) - Software practices for COTS certification and integration - Utility & certification of auto-generated code tailored to NASA software from design specs - Generic software simulators / test beds - Methods for V&V of software systems (Model-based autonomous, intelligent, adaptive flight control, etc.) Identified Technologies Relevant To Technical Themes of ISHM Intelligent Software Engineering Tools - Methods to automate the verification & regression testing of software, its interfaces, and its test procedures - Device independent interface software - Software assurance practices for reused / heritage software - Life cycle robustness, especially for new applications (emerging paradigms and algorithms): need better or combined lifecycle models for reliable software development and test indicators and metrics - Graphical and readable software representation tools (graphical modeling languages) Identified Technologies Relevant To Technical Themes of ISHM Intelligent Software Engineering Tools - Software risk assessment tools - Software requirements hazard analysis – fault tree analysis - Software requirements capture - Rapid prototyping to explore mission software requirements and design specifications - Personnel management: process, tools, etc. offset software personnel turnovers - New software languages & techniques (e.g., objective oriented, real time applications, Java, etc.) - Libraries of standard components for development & reuse Identified Applications Relevant To Technical Themes of ISHM Agency Wide Activities: - CRAI (Capabilities Requirements Analysis Integration) - Concepts: IAHM&C, IIVM, IVM - NGLT - ISHM Agency Wide Working Group - NASA SWG – Software Technology Infusion Strategy Three - Collaborations Involving ARC, JSC, JPL, IV&V, MSFC, LaRC - Collaboration with ARC on automated software analysis & verification tools - Others (e.g.): JSC Architecture Study, Mars Reference Mission, OASIS Space Shuttle Main Engine Avionics Technologies - Improved methods for software testing of mission critical software systems - Automated Offline Test Generation Technology - Improved methods for software testing of mission critical software systems - Generic Simulation Technologies - Software Analysis Technologies - Expansion of the parameter simulation/patching Technologies - Real-time Data Reduction/Analysis Technologies - Real-time Data Display/Analysis Technologies - AHMS Phase IIB Thoughts Software - Intelligent Software Engineering (ISE) is needed: Tools, Test & Verification Platforms, Efficient Development Processes, automation, results interpretations, risk mgmt, requirements, etc. - Ties health management systems all together Intelligent Systems (IS) - Needed for more autonomous operations, crew safety, and mission success - Autonomous operations includes reconfigurability, diagnostics, & prognostics Modeling - Improved formal methods & mathematical model development needed for further supporting ISE for IS Universal Theory (Standard) of ??IVHM?? And corresponding discipline needed - HM paradigms must exhibit situational awareness & docile features Verification & Validation (Certification) Technologies need to progress to accommodate larger state space of possible test scenarios Questions???
{"Source-Url": "https://ntrs.nasa.gov/archive/nasa/casi.ntrs.nasa.gov/20050000121.pdf", "len_cl100k_base": 4517, "olmocr-version": "0.1.53", "pdf-total-pages": 38, "total-fallback-pages": 0, "total-input-tokens": 73505, "total-output-tokens": 5936, "length": "2e12", "weborganizer": {"__label__adult": 0.0003902912139892578, "__label__art_design": 0.00020241737365722656, "__label__crime_law": 0.0003609657287597656, "__label__education_jobs": 0.0005464553833007812, "__label__entertainment": 8.32676887512207e-05, "__label__fashion_beauty": 0.00017571449279785156, "__label__finance_business": 0.00040841102600097656, "__label__food_dining": 0.00045108795166015625, "__label__games": 0.0011663436889648438, "__label__hardware": 0.0018777847290039065, "__label__health": 0.0003376007080078125, "__label__history": 0.00025272369384765625, "__label__home_hobbies": 9.107589721679688e-05, "__label__industrial": 0.0006146430969238281, "__label__literature": 0.00016236305236816406, "__label__politics": 0.00020968914031982425, "__label__religion": 0.0003314018249511719, "__label__science_tech": 0.0262603759765625, "__label__social_life": 8.469820022583008e-05, "__label__software": 0.01259613037109375, "__label__software_dev": 0.951171875, "__label__sports_fitness": 0.0004634857177734375, "__label__transportation": 0.0014743804931640625, "__label__travel": 0.0002562999725341797}, "weborganizer_max": "__label__software_dev", "avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_ratio": [[0, 22978, 0.01589]], "fineweb_edu_fasttext_gt2__fineweb_edu_fasttext_gt2__score": [[0, 22978, 0.28851]], "ft_lang_id_en_doc_v2__ft_lang_id_en_doc_v2__en": [[0, 22978, 0.84472]], "google_gemma-3-12b-it_contains_pii": [[0, 0, null], [0, 222, false], [222, 222, null], [222, 1967, null], [1967, 2494, null], [2494, 3382, null], [3382, 3789, null], [3789, 3789, null], [3789, 3918, null], [3918, 3918, null], [3918, 4395, null], [4395, 4478, null], [4478, 5619, null], [5619, 6626, null], [6626, 7302, null], [7302, 7974, null], [7974, 8482, null], [8482, 8910, null], [8910, 9027, null], [9027, 10636, null], [10636, 12163, null], [12163, 12421, null], [12421, 12617, null], [12617, 13714, null], [13714, 14881, null], [14881, 16176, null], [16176, 16665, null], [16665, 17043, null], [17043, 17748, null], [17748, 18421, null], [18421, 18939, null], [18939, 19317, null], [19317, 19996, null], [19996, 20600, null], [20600, 21157, null], [21157, 22143, null], [22143, 22966, null], [22966, 22978, null]], "google_gemma-3-12b-it_is_public_document": [[0, 0, null], [0, 222, true], [222, 222, null], [222, 1967, null], [1967, 2494, null], [2494, 3382, null], [3382, 3789, null], [3789, 3789, null], [3789, 3918, null], [3918, 3918, null], [3918, 4395, null], [4395, 4478, null], [4478, 5619, null], [5619, 6626, null], [6626, 7302, null], [7302, 7974, null], [7974, 8482, null], [8482, 8910, null], [8910, 9027, null], [9027, 10636, null], [10636, 12163, null], [12163, 12421, null], [12421, 12617, null], [12617, 13714, null], [13714, 14881, null], [14881, 16176, null], [16176, 16665, null], [16665, 17043, null], [17043, 17748, null], [17748, 18421, null], [18421, 18939, null], [18939, 19317, null], [19317, 19996, null], [19996, 20600, null], [20600, 21157, null], [21157, 22143, null], [22143, 22966, null], [22966, 22978, null]], "google_gemma-3-4b-it_v2tag__is_academic_paper": [[0, 5000, false], [5000, 22978, null]], "google_gemma-3-4b-it_v2tag__is_class_syllabus": [[0, 5000, false], [5000, 22978, null]], "google_gemma-3-4b-it_v2tag__is_completion_certificate": [[0, 5000, false], [5000, 22978, null]], "google_gemma-3-4b-it_v2tag__is_court_notice": [[0, 5000, false], [5000, 22978, null]], "google_gemma-3-4b-it_v2tag__is_homework_assignment": [[0, 5000, false], [5000, 22978, null]], "google_gemma-3-4b-it_v2tag__is_news_article": [[0, 5000, false], [5000, 22978, null]], "google_gemma-3-4b-it_v2tag__is_public_order": [[0, 5000, false], [5000, 22978, null]], "google_gemma-3-4b-it_v2tag__is_resume_cv": [[0, 5000, false], [5000, 22978, null]], "google_gemma-3-4b-it_v2tag__is_test_or_quiz": [[0, 5000, false], [5000, 22978, null]], "google_gemma-3-4b-it_v2tag__is_textbook": [[0, 5000, false], [5000, 22978, null]], "pdf_page_numbers": [[0, 0, 1], [0, 222, 2], [222, 222, 3], [222, 1967, 4], [1967, 2494, 5], [2494, 3382, 6], [3382, 3789, 7], [3789, 3789, 8], [3789, 3918, 9], [3918, 3918, 10], [3918, 4395, 11], [4395, 4478, 12], [4478, 5619, 13], [5619, 6626, 14], [6626, 7302, 15], [7302, 7974, 16], [7974, 8482, 17], [8482, 8910, 18], [8910, 9027, 19], [9027, 10636, 20], [10636, 12163, 21], [12163, 12421, 22], [12421, 12617, 23], [12617, 13714, 24], [13714, 14881, 25], [14881, 16176, 26], [16176, 16665, 27], [16665, 17043, 28], [17043, 17748, 29], [17748, 18421, 30], [18421, 18939, 31], [18939, 19317, 32], [19317, 19996, 33], [19996, 20600, 34], [20600, 21157, 35], [21157, 22143, 36], [22143, 22966, 37], [22966, 22978, 38]], "pipe_delimited_lines_v1__pipe_delimited_lines_v1__pipe_delimited_lines_ratio": [[0, 22978, 0.01639]]}
olmocr_science_pdfs
2024-12-10
2024-12-10
d91807dcb895b59b90ce704304f2404744f13c3d
Culture Effect on Requirements Elicitation Practice in Developing Countries Ayman Sadig, Abd-El-Kader Sahraoui To cite this version: HAL Id: hal-01703239 https://hal.laas.fr/hal-01703239 Submitted on 22 Feb 2018 HAL is a multi-disciplinary open access archive for the deposit and dissemination of scientific research documents, whether they are published or not. The documents may come from teaching and research institutions in France or abroad, or from public or private research centers. L’archive ouverte pluridisciplinaire HAL, est destinée au dépôt et à la diffusion de documents scientifiques de niveau recherche, publiés ou non, émanant des établissements d’enseignement et de recherche français ou étrangers, des laboratoires publics ou privés. Culture Effect on Requirements Elicitation Practice in Developing Countries Ayman Sadig¹, Abd-El-Kader Sahraoui² ¹. Ahfad University for Women and SUST Khartoum Sudan ². LAAS-CNRS, Université de Toulouse, CNRS, UT2J, Toulouse, France Abstract— Requirement elicitation is a very important step into developing any new application. This article will examine the culture effect on requirement elicitation in developing countries. This is unique research that will look at requirement elicitation process in 10 different parts of the world including Arab world, India, China, Africa and South America. The focus is how the culture affect RE and make every place has its own practice of RE. The data was collect through surveys, direct interviews. The results show astonishing culture effect on RE. The conclusion is that culture effect deeply the technique to choose for requirement elicitation. If you are doing RE in Thailand, it will be very different from RE in Arab world. For example in Thailand respect for leader is critical and any questioning of a manager method will create a problem while in Arab world decision tree is favourite RE technique because visual are liked more than documents. Keywords—culture impact, requirement elicitation. 1. Introduction Every software project need to know the desires of all stakeholders [1]. This process is called Requirement elicitation. Requirement elicitation can affect the entire software development activity if not properly executed. It is one of the common reasons for software project failure [2]. Requirement elicitation has been known in software engineer society since the 1960s. It is generally understood and accepted that requirements are elicited rather than just captured or collected. A developing country according to oxford dictionary is a poor agricultural country that is seeking to become more advanced economically and socially. Getting requirement elicitation is complex process; requirement cannot be gathered out of the social context [3]. Robertson and Robertson call it “trawling for requirements” [4] meaning that you are likely to get more requirements than expected but it is better than getting less. It comes after project initiation and before system design. It has many techniques like interview, questionnaire, work shop and prototype [5] and can happen with direct approach like interview or indirect like questionnaire [31]. The impact of this research will be a game changer in gathering requirement in developing countries as a good practice and tool will help a lot of companies get this vital stage right which will improve success rate of projects. Requirement Elicitation has attracted a lot of research but still I could not find a single survey for culture effect in requirement elicitation in developing countries. This will be the first survey of culture effect of requirement elicitation in different countries around the world. This paper will look first at what is meaning by culture then will address culture effect on requirement elicitation in many countries and regions in the world including Arab world, China, Brazil, Germany, Sudan, Thailand, Helsinki, Las Vegas and Hong Kong. 2- What does Culture means? 63 years ago, Kluckhohn argued ‘culture is to society what memory is to individual’ [9]. Hofstede explain culture as a ‘set of shared assumptions that result in a common frame of reference by members of a society or more simply as mental software’. [6] Schein reckon culture is ‘ a set of structures, routines, rules, and norms that guide and constrain behavior’ [7]. Lytle et al [8] put culture as beliefs and values that make sense of our behavior in the past and the future and if you take the behavior out of the culture context it will make no sense at all. Traindis [10] see a difference between individual culture such as North America and western Europe and collective culture of Asia, Africa and South America. So how can we measure value of culture, Hoststede [6] divide it the value of culture into two, values and practice. Value is everything a child learns before the age of 10 which stick in his mind and hard to change later, while practice is what is learnt later through social experience which is easier to modify. Rokeach [11] has distinguish values into terminal which the end goal for human and instrumental which is the behavior to achieve the terminal goals. Rokeach [11] created a list of 36 values dividing them into terminal and instrumental. He divide terminal values into interpersonal values which concern other people and intrapersonal focus value which concern about the individual. As for instrumental values, it consists of moral and competency values. Karahanna et al [12] upgraded Rokeach typology by dividing culture into 5 levels supranational, national, professional, organizational and group. Supranational is cross country boundary that exist in more than one country like ethnic, religion, regional and linguistic. Secondly National is collective behavior in one nation. Thirdly Professional the challenge between following industry culture or employee culture. Fourthly, organizational which are the social and politics that distinguish each organization. And finally group culture which is the difference in a group which is less than organization. Tuure Tunnanen ET al [13] have mix Rekeach with Karahanna view in level of culture and came with following table. Tunnanen put the 36 values of Rokeach [11] and added extra values from Karahanna [12] like self respect, security, equality and freedom. 3- Literature Review 3.1 Introduction: This chapter gives a brief overview of the related work, first about the benchmark Requirement elicitation techniques in developed work. Then I will look at previous studies in developing world like Arab world, Africa and India, South America and China describing them, objective, limitation and further work needed to improve them. Finally I will summarize the literature review chapter 3.2 Related work Requirement elicitation has improved a lot in the last 30 years. A lot of studies have been done in US, Europe and Japan. Requirement elicitation techniques in developed countries have been listed [26]. But there is still not a lot of research done in developing countries which has its unique social, economic and political circumstances. This study will cover important work done in developed countries then focus on requirement elicitation studies in developing countries 3.2.1 Requirement elicitation in Arab World (Kuwait example) [21] There are 23 Arab country sharing similar culture, values, language, history and geographic location. There is not a lot of study’s done to analyze RE in Arab world but a study in Kuwait show that the Arab culture influence heavily perception of RE techniques, the companies in the survey know about 19 different techniques of RE and use many of them. The most used technique is interview but it is not valued highly. The companies like most Decision tree and prototyping. The least liked are UML, tree analysis, role playing K.J. method, flow chart and Ishikawa. The study show that the culture play a big role in perception about RE, as for example although interview are cited as the most effective technique in developed world [14] and it is the most used in Kuwait but it is not regarded with great value. There are six main differences between western countries and Kuwait in the way it perceive RE techniques that are related to the Arab culture. First decision tree is the most value RE techniques unlike the western perception [14] because it is a graphical representation which bud well with Arab culture that like visual more than document and words [15] which make it easier to understand by stakeholders. A prototype is 3rd highly valued RE techniques. A prototype is about developing a pilot system and shows it to stakeholders. Been 3rd high challenge the result of western countries [16] but similar to study in Thailand market [17]. This also can be traced to culture reasons as Arabic culture score similar score to Thailand in Arab culture scores 68 on Hofstede uncertainty avoidance (68, 64), while the USA (a western culture) scored a 46. Fourthly DFD is very popular in Kuwait as 4th highly liked and secondly used which challenged the finding in western countries [14]. Fifthly there is a disliking for group techniques like JAD (ranked 8), focus group (ranked 9) and brain storming (ranked 11) which again in not consistent with outside of Arab world[18]. Lastly UML was the least liked RE techniques which contrast heavily with the developing countries where UML is regarded highly [19]. The study regards that for unfamiliarity with UML in Kuwait. The study shows that Arab culture play a crucial role in choosing the RE techniques. The main limitation is that it suggest all Arab countries are similar when there is big different in wealth, size, population, how many languages in the country and education level. <table> <thead> <tr> <th>RE technique</th> <th>Cited</th> <th>%</th> </tr> </thead> <tbody> <tr> <td>1. Interviews</td> <td>79</td> <td>91</td> </tr> <tr> <td>2. DFD</td> <td>65</td> <td>75</td> </tr> <tr> <td>3. Brainstorming</td> <td>64</td> <td>74</td> </tr> <tr> <td>4. Observation</td> <td>59</td> <td>68</td> </tr> <tr> <td>5. Surveys</td> <td>59</td> <td>68</td> </tr> <tr> <td>6. Prototyping</td> <td>54</td> <td>62</td> </tr> <tr> <td>7. Scenarios</td> <td>50</td> <td>57</td> </tr> <tr> <td>8. Focus group</td> <td>49</td> <td>56</td> </tr> <tr> <td>9. JAD</td> <td>48</td> <td>55</td> </tr> <tr> <td>10. Decision Trees</td> <td>47</td> <td>54</td> </tr> <tr> <td>11. Use Cases</td> <td>44</td> <td>51</td> </tr> <tr> <td>12. Role Playing</td> <td>38</td> <td>44</td> </tr> <tr> <td>13. Quality Function Deployment (QFD)</td> <td>33</td> <td>38</td> </tr> <tr> <td>14. Fault Tree Analysis</td> <td>23</td> <td>26</td> </tr> <tr> <td>15. Flow Charts</td> <td>21</td> <td>24</td> </tr> <tr> <td>16. Goal-Oriented Elicitation</td> <td>18</td> <td>21</td> </tr> <tr> <td>17. Unified Modeling Language (UML)</td> <td>18</td> <td>21</td> </tr> <tr> <td>18. Ishikawa</td> <td>5</td> <td>06</td> </tr> <tr> <td>19. K.J. Method</td> <td>3</td> <td>03</td> </tr> </tbody> </table> **Figure 2 show most used Requirement Elicitation techniques in Kuwait [21]** ### 3.2.2 Chinese characteristics of Requirement elicitation [22] A study into the using method of requirement elicitation in the Chinese market [20] listed that focus group is the highly liked used then prototype, document analysis and questionnaire. 78% of companies give more than 10% of their time to requirement and customers think it is very important. The culture is involved heavily in elicitation requirement as 96% of software companies say they must have a good relation with leader of customer companies. The leaders influence the level of cooperation of customer companies. As for the uncertainly avoided problems in China, people usually stay away from conflicts and uncertainties, and they tend to use gentle and indirect methods to deal with conflict. That is why when gathering requirement they tend to prefer prototype available to see the system. They are leaning toward collectivism more than individualism and issues environmental protection, energy saving, reduction of cost, security, safety receive good impact when added to projects. Software companies tend to interfere with customer requirement, 80% think customer doesn’t know what he want and they are helping him. They are hardly using RE tools like DOORS only 14% which show that tools are not widely marketed. This study shows that support from top management is vital into gathering requirement, collectivism is high as focus group is most used while an interview is lowly perceived and that understanding Chinese culture bring better requirement. The limitation of this study there is no clear guidance on getting requirement form customers and requirement engineer tend to add lots of requirement. Figure 3 Show the most used requirement elicitation techniques in China [22] 3.2.3 Requirement elicitation in Brazil A study comparing requirement elicitation in Brazil and Germany [23], show that both use interviews heavily 87% brazil and 88% Germany but there is a difference in meeting brazil 56% use workshop while Germany use it 86%. The German companies will build product to customer using RE while Brazilian companies tend to build standard product then customize it to customer needs through RE. The main cause for problems and uncertainty requirements is different, in Brazil 40% people and the biggest factor in that is no expertise in RE see figure 4 then input itself 20% while in Germany methods 58% and organization 23%. Brazilian companies use agile method which required extensive communication and collaboration between teams and when you consider the size of Brazil that is hugely challenging and can bring mistrust between the customer and requirement team. This study shows that the lack of knowledge in the requirement team is the biggest problem in Brazil which is different from Germany (developed country) and that need to be addressed before gathering requirement. The limitation of this requirement, there in guide to deal with the culture effect in Brazil like lack of communication because of the size of the country. Figure 4 show the reasons for hidden and incomplete requirement in Brazil [23] 3.2.5 In Africa rural areas when gathering requirement, there is a need to look at local needs [24], in most African countries there are special requirement has to be looked at, for example in Nigeria[25]. There is sustainability in developing country you have to look at infrastructure and the environment to sustain project. Then affordability as information systems are still expensive to maintain. The social-economic is also a big factor. The study of requirement elicitation in Africa is very limited and given the size of the African continent and the complex of the social issues there, a lot more research need to be done in this area 3.2.6 Requirement elicitation in India rural areas [27] Women in rural area in India similar to others in developing country are different to women in other places in term of culture, illiteracy and language variation. They depend on their local knowledge rather than global knowledge where IT is not much in use. They lack experience in giving requirement, struggle to fill government forms and not getting enough information to improve their living standard and enhance their children development. Similar to rural areas in Africa, images are well received instead of forms and questionnaires. Most communication is done through word of mouth and there are trusted people like doctors, teachers, elders and rich farmers. They go to most houses and can spread the word better than technology will ever do in this rural area. So you cannot use the general requirement elicitation techniques and has to design method suited to the local knowledge rather than international knowledge, matching the capabilities of women in rural areas. The paper has a right approach to get requirement in rural area in India and most of developing countries. Requirement engineers have to match the level of women in rural area to gain their trust to get their right needs and enhance the software usability. The study needs to be implemented to be able to value it and improve it. **3.2.7 Requirement elicitation study in Thailand** Thanasankit [29] explain in Thailand, culture change technology rather than technology change culture. Respect for the leader as a father figure is critical in Thai culture. The king of Thailand has passed away in 2016 after 70 years reign and was regard as father of the nation. Any questioning of the leadership in requirement engineering will lead into client becoming disengagement and would consider it as insult. A power in organization comes through person position in it rather than personality, influence or education. This is crucial to requirement elicitation process in Thailand. Also avoiding confrontation play an important role in Thai culture as avoiding conflicts and criticism is considered face saving value [30]. Thanasankit [29] argue that in Thailand, decision is usually taken at the top management and employees tend to stay away from it in order not to confront with top management. So any requirement that does not get the backing the top management are likely not to be done. **3.2.8 Comparison between Requirement elicitation in Helsinki, Las Vegas and Hong Kong** Tunnanen [13] argues than culture has a big effect on requirement. Understand the values and the culture of the society helps to better address its preference in building new IS systems. Tunnanen [13] has done requirement elicitation and analyzes to develop new mobile services involving 487 users from Helsinki, Las Vegas and Hong Kong. The study shows sharp differences in view between western cities (Helsinki and Las Vegas) and eastern city Hong Kong. Also there is a difference between the two western Cities. Tunnanen [13] used table 1 above with value typology. The study show residence of Hong Kong had high emphases toward personal values like comfortable live and exciting lives and so on, in comparison residence of Helsinki and Las Vegas put less emphasis on these values. Which goes with the United Nation publication of happiness index [27] which shows Finland 7th, USA17th and Hong Kong 64th. On the instrumental values (see table 1) the moral and competency values were higher in Helsinki and Las Vegas than in Hong Kong which agrees with and Hostefede and hostefede [28] that Helsinki and Las Vegas are more individual than Hong Kong. Also Helsinki scored higher in moral and competency than Las Vegas. The Hong Kong user tends to associate themselves with tangible values than Helsinki and Las Vegas users. This study indicates that a culture friendly mobile IT system has more chances to success than in the 3 countries then one version of the system in the 3 countries. **3.2.9 Requirement Elicitation in Sudan** I interviewed two consultants from the leading IT companies in Sudan. The first company is using readymade product which then adjusted to customer need through agile method. This system rarely meets all the customer need and the agile method requires extensive communication which always becomes a problem. The second company gather requirement from customer in one or two interview. This method is good but there is no guidance to the information coming from the customer like project, risks, deliverable, objectives, assumptions, opportunities, challenges, stakeholders, functional and non-functional requirement. They end up having to alter requirement several time during the projects which cost a lot of time and effort. In a comparison between Germany and Brazil (developing country) the difference is clear in reason to gen incomplete or hidden requirement [13]. In Brazil the problem with people 40% and input%20. Problem with people because like in first company in Sudan above they develop product first with no interaction with customer then it is a problem to adjust to customer need completely. 2.2.9.1 Case Study (Bank ATM machine in Sudan) Atms has been around in Sudan for the last ten years. They are located in most cities in Sudan. They are great help to get cash 24/7 as everywhere else in Sudan. They were deployed with the same standard as the rest of the world without looking at special needs and culture effect in Sudan. As last review by the Unicef in 2015, the literacy level in Sudan is 70.2%. when you consider sudan population as 39 millions than means 11.7 millions Sudanese can not read and write. As we all know to use a standard Atm you need to be able to read and write to put your pin and follow instruction. This is an huge obstacle for those 11.7m and it is not unfamiliar to find an old man or woman at ATM asking for help in Sudan. The requirement analysis should have look at that and added voice recognition for example to make it accessible for every body. 2.2.10. Summary Table of requirement elicitation in developing countries <table> <thead> <tr> <th>Article</th> <th>Field</th> <th>Findings</th> <th>Limits</th> <th>Suggest</th> </tr> </thead> <tbody> <tr> <td>Rouibah, Kamel, et. al. “Requirement engineering elicitation methods: A Kuwaiti empirical study about familiarity, usage and perceived value.”</td> <td>RE</td> <td>Social aspect in Arab World heavily involved. DT preferred for Visual Liking and UML avoided for lack of knowledge</td> <td>Only cover Kuwait and assume all the Arab World is the same which can be challenged</td> <td>More studies to be done in north Africa, east Africa Arabian country to be more general study</td> </tr> <tr> <td>Liu, Lin, et al. “Understanding Chinese characteristics of requirements engineering.”</td> <td>RE</td> <td>Show china Unique market where leader is very important for project to go smooth and collectivism where focus</td> <td>The sample need to be bigger to get a more accurate assumption</td> <td>The requirement engineering tend to add a lot of requirement by him/herself which need to be</td> </tr> <tr> <td>Winschiers et al. “Determining requirements within an indigenous knowledge system of African rural communities.”</td> <td>RE</td> <td>Brazil and Germany has a very different approach to RE Communication is the big problem in Brazil.</td> <td>Brazilian depend of Agile method which needs extensive communication to successes and not doing so create a big problem</td> <td>Need to find a better tools to communi cate between people and also improve the level of requirement engineer knowledg e</td> </tr> </tbody> </table> 3.3- Summary Almost all the studies in developing world notice the unique social element in each country and how it effects the requirement elicitation. The aim of requirement engineer is to satisfy customer needs, to achieve that the RE must study the society with all the social aspect to be able to get the entire requirement on board. There is a gap between requirement elicitation in developed world and many areas in developing countries where mindset maybe different and prospect of method is different. There is still a lot of research need to be done in developing countries to find the ideal method for gathering requirement. Africa specially has the least bit of research done specifically in requirement elicitation. 4-References
{"Source-Url": "https://hal.laas.fr/hal-01703239/document", "len_cl100k_base": 5013, "olmocr-version": "0.1.53", "pdf-total-pages": 9, "total-fallback-pages": 0, "total-input-tokens": 23797, "total-output-tokens": 6944, "length": "2e12", "weborganizer": {"__label__adult": 0.0005207061767578125, "__label__art_design": 0.0014944076538085938, "__label__crime_law": 0.00044608116149902344, "__label__education_jobs": 0.012603759765625, "__label__entertainment": 0.00014078617095947266, "__label__fashion_beauty": 0.0003135204315185547, "__label__finance_business": 0.0025844573974609375, "__label__food_dining": 0.00047135353088378906, "__label__games": 0.0009813308715820312, "__label__hardware": 0.0005745887756347656, "__label__health": 0.0006151199340820312, "__label__history": 0.0006070137023925781, "__label__home_hobbies": 0.00011926889419555664, "__label__industrial": 0.0005016326904296875, "__label__literature": 0.0011091232299804688, "__label__politics": 0.0005335807800292969, "__label__religion": 0.0007257461547851562, "__label__science_tech": 0.035675048828125, "__label__social_life": 0.0003676414489746094, "__label__software": 0.0163116455078125, "__label__software_dev": 0.92236328125, "__label__sports_fitness": 0.0002428293228149414, "__label__transportation": 0.0006012916564941406, "__label__travel": 0.00026154518127441406}, "weborganizer_max": "__label__software_dev", "avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_ratio": [[0, 28430, 0.05764]], "fineweb_edu_fasttext_gt2__fineweb_edu_fasttext_gt2__score": [[0, 28430, 0.36059]], "ft_lang_id_en_doc_v2__ft_lang_id_en_doc_v2__en": [[0, 28430, 0.91069]], "google_gemma-3-12b-it_contains_pii": [[0, 1015, false], [1015, 4238, null], [4238, 7748, null], [7748, 12630, null], [12630, 15689, null], [15689, 20017, null], [20017, 23273, null], [23273, 26749, null], [26749, 28430, null]], "google_gemma-3-12b-it_is_public_document": [[0, 1015, true], [1015, 4238, null], [4238, 7748, null], [7748, 12630, null], [12630, 15689, null], [15689, 20017, null], [20017, 23273, null], [23273, 26749, null], [26749, 28430, null]], "google_gemma-3-4b-it_v2tag__is_academic_paper": [[0, 5000, true], [5000, 28430, null]], "google_gemma-3-4b-it_v2tag__is_class_syllabus": [[0, 5000, false], [5000, 28430, null]], "google_gemma-3-4b-it_v2tag__is_completion_certificate": [[0, 5000, false], [5000, 28430, null]], "google_gemma-3-4b-it_v2tag__is_court_notice": [[0, 5000, false], [5000, 28430, null]], "google_gemma-3-4b-it_v2tag__is_homework_assignment": [[0, 5000, false], [5000, 28430, null]], "google_gemma-3-4b-it_v2tag__is_news_article": [[0, 5000, false], [5000, 28430, null]], "google_gemma-3-4b-it_v2tag__is_public_order": [[0, 5000, false], [5000, 28430, null]], "google_gemma-3-4b-it_v2tag__is_resume_cv": [[0, 5000, false], [5000, 28430, null]], "google_gemma-3-4b-it_v2tag__is_test_or_quiz": [[0, 5000, false], [5000, 28430, null]], "google_gemma-3-4b-it_v2tag__is_textbook": [[0, 5000, false], [5000, 28430, null]], "pdf_page_numbers": [[0, 1015, 1], [1015, 4238, 2], [4238, 7748, 3], [7748, 12630, 4], [12630, 15689, 5], [15689, 20017, 6], [20017, 23273, 7], [23273, 26749, 8], [26749, 28430, 9]], "pipe_delimited_lines_v1__pipe_delimited_lines_v1__pipe_delimited_lines_ratio": [[0, 28430, 0.20968]]}
olmocr_science_pdfs
2024-12-07
2024-12-07
564b774651c9cf2b381e2735ea22546c2bc1c232
Assessing Risks and Cloud Readiness in PaaS Environments Vinita Malik, Sukhdip Singh Abstract: The cloud computing has utilization of pervasive or distributed models on demand access to highly configurable computing devices for fast provision and less management efforts. The complex architecture, multitenant and virtual environment in cloud infrastructure asks for risks identification and mitigation. The cloud computing model business needs reassurances so it’s prime consideration for testing the cloud services. This research primarily identifies various risks, threats, testing models and vulnerabilities in cloud computing environment. This research has implemented the risk assessment and cloud readiness for PaaS environment by scanning its code with a software vendor. The research makes an emphasis on risk minimization strategies and trust evaluation in cloud computing environment. Keywords: Attacks; Cloud Computing; Risks; Risk Management; Cloud Readiness; Trust I. INTRODUCTION The cloud computing has emerged today as a dominant computing paradigm due to much advances in technology networks and virtual infrastructure. The cloud computing has provided an illusionary limitless resources with features like high scalability, on demand service, agility via elasticity and pay per use. It is also characterized to have on demand service (self), resource usage optimization, high elasticity, resource polling with broad network access [1]. It helps in imparting the ubiquitous access to highly configurable computing devices which also follows pay per use model. Reduced costs, less investment and fast deployment makes cloud computing focus on main business concerns. However, despite of very lucrative facts about cloud computing, its adoption is associated with large potential risks. As cloud computing merges various computing environments i.e. grid and distributed so it becomes complex in nature. Under the umbrella of cloud computing services any organization has to surrender control over data privacy and security by conferring trust into cloud provider services. The paper raises a study aiming to identify risks, threats, vulnerabilities, attacks and risk assessment in cloud computing. This research has thrown light on benefits and challenges in cloud computing and key factors in cloud testing. The paper has implemented how cloud risks are managed after identifying risky items and how much cloud ready is an application after scanning its application code. The research has been organized in various sections to answer the following questions: - Define cloud computing, characteristics, deployment and service models, benefits, challenges in cloud computing? - What are risks, vulnerabilities, threats and attacks in cloud computing? - What are risk reduction strategies in cloud computing? - How trust is evaluated in cloud environments? - How risk management is implemented in cloud applications and how the cloud readiness of an application may be identified by a smart software. Section 1 talks about cloud computing basics whereas section 2 deals with risks management in cloud computing. Next section discusses risk minimization in cloud computing and in section 4, the trust in cloud environment is dealt. In section 5, the risk management and cloud readiness of an application is implemented after scanning its code by an intelligent vendor. Last section provides conclusions and future scope of the extensive study. II. CLOUD COMPUTING According to Gartner report (Technology Trend), It is under prediction that in next five years, cloud computing will dominate market in decision making business processes [2]. Cloud computing causes disruptive changes in various platform, infrastructure and application layers services. IT business analysts and solution experts are looking forward for such technologies that may formulate solutions across various business domains by cloud computing [3]. Cloud Computing defines a model which permits users to access shared resources via internet or by any computing network. It asks for minimal administrative effort and less interaction with service providers. A. Characteristics The Cloud Computing has following characteristics [1, 4-8]: Revised Manuscript Received on October 15, 2019. * Correspondence Author Vinita Malik*, PhD Scholar, D.C.R.U.S.T, Murthal & Information Scientist, Central University of Haryana, Mahendergarh, India Email: is@cuh.ac.in Sukhdip Singh, Professor, CSE Dept., D.C.R.U.S.T, Murthal, India Email: sukhdeepSingh.cse@dcrustm.org Assessing Risks and Cloud Readiness in PaaS Environments A. Risks Factors The risks factors in cloud computing is given as follows [11, 12, 13 and 14]: - Authentication & Access Control: The sensitive credentials of any organization are needed to be authenticated as in cloud data is processed outside the organization. - Lack of Control: The lack of control over computing environment may lead to data leakage. - Insecure Application Development: The interfaces development requires giving their control to third party for enabling them which increases risks for any organization. - Data Transfer: The data flowing on network needs to be secured and all security roles must be properly defined. B. Deployment Models The deployment models in cloud computing depends on cloud service provider capacity. The four deployment models are described as follows [9]: - Private deployment model of cloud: Here cloud infrastructure is used exclusively for one operation. These are used where data control is the prime consideration of the organization. - Public deployment model of cloud: In this cloud infra is under control of cloud service provider. The consumer has very low control over security and operation of cloud services. - Community deployment model of cloud: Here cloud infra is divided into various independent organizations having shared/exchanged concerns. - Hybrid deployment model of cloud: It is composed of 2 or more private/public/communities of clouds and used for a particular purpose. Here critical applications run on private cloud and non-critical applications on public cloud. C. Service Models The cloud computing comprises of following service models [1]: - SaaS (Software as Service): Web browsers host the applications via internet. The service provider is responsible for applications management i.e. Google Docs, SAP Business, Sales Force CRM - PaaS (Platform as Service): Developers write applications as per specified platform and the platform provides the virtualization environment. E.g. Forge.com and Google App Engine. - IaaS (Infra as a Service): Here services include all the computing resources. Clients maintain security in cloud services. Resources like servers, networks provided to customers are monitored by service provider on demand. For E.g. VMware, EMC2, Amazon web services. D. Challenges The most important challenges in cloud computing are offered as follows [10]: - Service Quality: One of the prime factor due to which organizations makes hesitant in moving their applications to cloud. - Security & Privacy: Security and Privacy issues have played an important role in non-adoption of cloud computing services. - Resource Discovery: Resource allocation have played critical role in well distributed cloud. - Data Integrity issues: Data protection from unauthorized access is difficult to maintain in cloud computing environment. E. Benefits Following are the main benefits of cloud computing [9]: - Business resources efficient utilization as per pay & use model. - Data execution time increase as an ability of cloud. - Patch management is easier in cloud. - DDOS attacks and virus infections are lesser in cloud environment. - Disaster recovery planning is easier in cloud computing. - Regulations and quality imposition services are easily adopted in cloud based environment. III. RISKS, ATTACKS & VULNERABILITIES IN CLOUD COMPUTING This section describes cloud computing risks, attacks and vulnerabilities. As there are various challenges inherent in cloud computing, there is need to have a look into risk categories and risk factors involved in cloud computing. - Data Dynamic Scalability: The data processing nodes need to be scaled as per user response. - Scheduling: Data scheduling is necessary for efficient resources usage. - Debugging: In high computable distributed processing remote and parallel computing is critical need in cloud computing which is difficult to maintain. - Virtualization: It is amongst the powerful techniques used in cloud computing for creating smart abstraction layer to hide software/hardware complex details. - Trust: It’s mandatory to convince application users that system services are accurate and safe. - Querying: Scalable queries processing have been an open challenge in cloud computing. - Service Level Agreements: Provision of a layer for discussion among providers & consumers demand service level agreements. • Inadequate Knowledge: The organization using cloud services needs to understand cloud based risks. • Regulatory Compliance: If the service provider is not security certified or do not participate in audits then it is considered a big risk as the service provider is responsible for security and integrity of data. • Shared Resource Environment: As cloud nature is to share all computing resources which may lead to data leakage or privacy issues. • Data Breaches: The attackers can exploit user’s data if cloud database has not been designed properly. • Service Availability: The business environment and its competency pressure may cause bankruptcy or loss of potential service quality. • Improper Service Management by service provider: The access privileges must be properly defined by service provider and the customer must be able to access data logs on demand whenever necessary. • Data Location: As cloud service providers are dispersed across the globe so the data stored in risky countries is again a big risk. • Data Recovery: Sometimes man-made disaster or natural mishapening can corrupt the data, so the customer /user should be aware how much time will take to recover the data. • Virtualization Issue: It is one of the most fundamental components of cloud computing. It includes risks of physical machines too. • Data Integrity: Cloud computing endangers data integrity while doing transaction management. Cloud Computing does not follow guaranteed delivery at protocol level. • Service level Agreements: The customer must assure that data integrity preservation is its responsibility and such terms explicitly clarified in service level agreement. • Resource Exhaustion: Inaccurate estimates of resource utilization may lead to service unavailability, reputational loss or access control compromises. B. Vulnerabilities Following mentioned are vulnerabilities in cloud computing [15]: • Virtualization vulnerabilities: Virtualization may be OS level (Multiple guest operating system run on host OS), application level (virtualization on top layer), Hypervisor based (embedded code to host operating system), VM side channel attacks and DOS attacks are common in such virtualization methods. • Internet Protocol Vulnerability: IP vulnerabilities include attacks i.e. RIP attacks, ARP spoofing, Flooding, DNS poisoning. • Non authorized access to management interface: The data computation, upload all occur by management interface. Non authorization to such interface can be a critical issue for cloud services. • Injection Vulnerability: It includes vulnerabilities i.e. OS injection flaw, SQL injection flaw that may disclose application components. • Browser Vulnerability: Cloud Service provisioning, monitoring and management occurs via cloud APIs. Browsers must be safe and secure to surf. Most common browser attacks include SSL Certificate spoofing, mail client phishing attacks, HTML services attack. C. Attacks Once the vulnerabilities are exploited, an attacker can do following attacks [15]: • Zombie Attacks: Here attacker sends request by innocent hosts in network which are also called as Zombies and floods the network with requests. Denial of service attacks come under this category. • Shared Technology Problems: The shared on demand services are offered by virtualization. In Infrastructure as a service and hypervisor virtualization one tenant may affect /interfere in the other. • Malicious Insiders: Due to non-transparency in cloud service provider procedures, insider activities may cause threat to system. • Data Leakage: Due to dynamicity of cloud data may be compromised which affect overall architecture of the system. • Service Hijacking: User accounts may be hijacked by phishing, credential exploitation and software vulnerabilities. • Service Injections: The attacker tries to exploit addresses to access the cloud system. • Virtualization attacks: It mainly consists of two type of attacks: VM Escape, Hypervisor Rootkit. Under VM Escape the attacker breaks isolation layer to exploit hypervisor privileges. In Rootkit, hypervisor creates a channel for unauthorized code execution. • Man in middle attack: The data exchange between parties can be accessed by the attacker if SSL (secure socket layer) is not configured properly. • Phishing attack: These manipulate web links and false links are redirected to user for getting sensitive data. • Backdoor Channel attack: It gives access to compromised system by controlling victim’s resources remotely. D. Threats Threats in the cloud computing is given as follows [15]: • Abusive usage of cloud computing: Misusing storage and bandwidth. • Insecure Interfaces: For interaction with cloud services cloud service provider publishes a set of APIs which increases the cloud complexity and vulnerable in nature. • Changes in Business Model: Cloud computing gets changed as per delivery of IT services so reliable encryption is need of hour. • Lack of standards for cloud auditing. • Issues in remote data retrieval due to lack of standards. • Data sanitization lack of standards. • Lack of Risk Profiling. • Identity thefts for accessing resources and getting credit. IV. RISK MANAGEMENT STRATEGIES IN CLOUD COMPUTING This section describes risks management in cloud computing environment. Risk assessment and mitigation is need of hour in cloud computing due to inherent risks. Various risks assessment algorithms have been used in past to predict accurate risks. These algorithms include Instance based knowledge, Multilayer perceptron, isotonic regression, randomizable filter classifier and voting [12]. A holistic cloud strategy includes developing communication root between administrator and host by effective security controls. The audit facility and quality assessment must be provisioned after secure data transfer. API security control and legal implications must be taken care. The workload partitioning problem has been used for risk based data processing over hybrid cloud architecture [16]. The better understanding of structural components of an organization, economic and mathematical modeling helps in taking better decisions regarding risk [17]. The cloud security risks taxonomy has been divided into compliance risks, architecture based risks and privacy risks as given in Fig. 1, 2, 3 [18]. The cloud security risks mitigation also asks for governance and compliance risks minimization [19]. To address the vulnerabilities exploitation several intrusion detection systems have been adapted. The defensive mechanism cycle have been proposed as seen in the Fig. 4 given below[20]. Fig. 1. Security taxonomy focused on Compliance Risks Fig. 2. Security taxonomy focused on Architecture Risks Fig. 3. Security taxonomy focused on Privacy Risks Fig. 4. Lifecycle: Defensive Mechanism Security threats can be categorized as external attacks, theft-related attacks, system malfunction, service interruption and human errors. The impact ratings and likelihood of high-level threats are identified, analyzed and mitigated [21]. The cloud-oriented cooperative intrusion detection systems using signature mechanisms are used with Nessi2 as a simulator tool for cloud security [22]. Fuzzy Self-organizing maps are used in past for improving the networking capabilities of cloud[23]. System privacy risks are mitigated by a PIA (privacy assessment tool) which informs decision makers to decide how the project will proceed [24]. One more methodology supports behavior engineering for model-based process improvement and assessment in cloud computing. Behavior modeling includes requirement modeling by requirements behavior tree and specifications by model behavior tree [25]. The business-oriented cloud computing services guidelines follow 3-tiered SOA architecture, asynchronous messaging, and avoiding cloud-specific APIs and assessment in cloud computing. Behavior modeling includes requirement modeling by requirements behavior tree and specifications by model behavior tree [25]. The business-oriented cloud computing services guidelines follow 3-tiered SOA architecture, asynchronous messaging, and avoiding cloud-specific APIs. The goal of risks-aware cloud computing lies in finding a balance between performance and sensitive data disclosure [26]. For risks management in Internet of Things, SIGMA project has been used to acquire and integrate heterogeneous data from various sensor networks [27]. V. TRUST EVALUATION IN CLOUD COMPUTING Trust has been one of the most crucial issues in cloud computing. It is a subjective measure between various services that want to act securely and reliably in a state of affairs for a prescribed time [30, 31]. Trust is evaluated to measure the quality of service of the system [32]. Trust may be static/dynamic, centralized/distributed, direct/indirect, and proactive/reactive/periodic. The trust types, characteristics, and applications are seen in Fig. 5 as given below: VI. ASSESSING CLOUD READINESS & RISKS IN CLOUD COMPUTING This section describes how the risks are managed in cloud computing environments and how much an application can be easily migrated to cloud in PaaS environment. The cloud application OpenNebula has been downloaded from GitHub repository [33]. A smart software vendor has been used for identifying the risky items of the scanned application [34]. The risk distribution in the application scanned is given below as per technology, software resiliency, agility and elegance as shown in the Fig. 6 below: ![Fig. 6. Risk distribution](image) All the risky code is identified as per code alerts and risky regions are handled on priority as depicted in Fig. 7. ![Fig. 7. Code alerts for software resiliency](image) The code alerts for software agility are depicted in Fig. 8 as given below: The organizations today are quite challenged in terms of managing cloud risks. For assessing cloud readiness, we need to assess the delivery models and solutions for cloud sourcing. Identify all blocking factors that may be utilized in future to resolve conflicts. The service quality, availability and dynamicity are mainly the cloud delivery characteristics. The research has employed a smart software vendor for cloud readiness in PaaS environment [34]. The readiness score is calculated by scanning source code and information collected from a questionnaire. The code patterns which can adopt PaaS environment shows the positive score and the code patterns which gets tweaked before migration, outputs in negative score. The cloud readiness score for the application scanned has been depicted in the Fig. 8 as below: ![Fig. 8. Code alerts for software resiliency](image) ### VII. CONCLUSIONS & FUTURE SCOPE The research has successfully explored various risks, vulnerabilities, attacks and risk management strategies in cloud computing environment. The research has utilized a smart software for scanning application code and identify the riskiest items and their frequency with bad code location. The bad code or risky code items are handled on priority. As the cloud computing imbibes various challenges of information security and privacy, so risk management and trust evaluation becomes important. This research has also considered cloud readiness of an application by code scan and survey. This paper will prove a substantial foundation for formulating interrelationships between risk management and quality assurance in complex computing. ### REFERENCES 6. Cloud Security Alliance, Security guidance for critical areas of focus in cloud computing V2.1 J Ala Acad Sci 76, 2009 33. https://codeload.github.com/openNebula/one/zip/master 34. Cast Software. www.castsoftware.com; 2019 AUTHORS PROFILE First Author Ms. Vinita Malik did the Bachelor of Engineering degree from M.D.U, Rohtak, India in 2008. She completed Masters of Engineering in 2012 from B.I.T.S Pilani University, Rajasthan. She is currently working as Information Scientist at Central University of Haryana, Mahendergarh. She is also pursuing PhD in Computer Science & Engineering from D.C.R.U.S.T, Murthal. Her research interests include Software engineering – Risks Management and Testing. She has published 17+ papers in the reputed Journals and conferences. Second Author Dr. Sukhdeep Singh did the Bachelor of Technology degree from the M.D.U, Rohtak, Haryana, India in 1999 and the Ph.D. degree from Maharishi Dayanand University Rohtak, Haryana India. He is currently working as a Professor in the Department of Computer Science and Engineering at D.C.R.U.S.T, Murthal. His research interests include Software Engineering, Green Computing and Cloud Computing. Dr. Singh has published 35+ papers in the reputed Journals and conferences. He is a life time member of the ISTE.
{"Source-Url": "https://www.ijrte.org/wp-content/uploads/papers/v8i3S/C10571083S19.pdf", "len_cl100k_base": 4103, "olmocr-version": "0.1.50", "pdf-total-pages": 7, "total-fallback-pages": 0, "total-input-tokens": 24867, "total-output-tokens": 6202, "length": "2e12", "weborganizer": {"__label__adult": 0.0003371238708496094, "__label__art_design": 0.0004906654357910156, "__label__crime_law": 0.0007634162902832031, "__label__education_jobs": 0.007843017578125, "__label__entertainment": 0.00017011165618896484, "__label__fashion_beauty": 0.0002104043960571289, "__label__finance_business": 0.00182342529296875, "__label__food_dining": 0.0004189014434814453, "__label__games": 0.0008854866027832031, "__label__hardware": 0.0013628005981445312, "__label__health": 0.0014057159423828125, "__label__history": 0.0004320144653320313, "__label__home_hobbies": 0.00017392635345458984, "__label__industrial": 0.0005216598510742188, "__label__literature": 0.0006937980651855469, "__label__politics": 0.0003952980041503906, "__label__religion": 0.00048613548278808594, "__label__science_tech": 0.4404296875, "__label__social_life": 0.0003192424774169922, "__label__software": 0.0672607421875, "__label__software_dev": 0.472412109375, "__label__sports_fitness": 0.0002510547637939453, "__label__transportation": 0.0005450248718261719, "__label__travel": 0.0002415180206298828}, "weborganizer_max": "__label__software_dev", "avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_ratio": [[0, 27198, 0.01783]], "fineweb_edu_fasttext_gt2__fineweb_edu_fasttext_gt2__score": [[0, 27198, 0.35969]], "ft_lang_id_en_doc_v2__ft_lang_id_en_doc_v2__en": [[0, 27198, 0.89815]], "google_gemma-3-12b-it_contains_pii": [[0, 4559, false], [4559, 8979, null], [8979, 13921, null], [13921, 15790, null], [15790, 18772, null], [18772, 23282, null], [23282, 27198, null]], "google_gemma-3-12b-it_is_public_document": [[0, 4559, true], [4559, 8979, null], [8979, 13921, null], [13921, 15790, null], [15790, 18772, null], [18772, 23282, null], [23282, 27198, null]], "google_gemma-3-4b-it_v2tag__is_academic_paper": [[0, 5000, true], [5000, 27198, null]], "google_gemma-3-4b-it_v2tag__is_class_syllabus": [[0, 5000, false], [5000, 27198, null]], "google_gemma-3-4b-it_v2tag__is_completion_certificate": [[0, 5000, false], [5000, 27198, null]], "google_gemma-3-4b-it_v2tag__is_court_notice": [[0, 5000, false], [5000, 27198, null]], "google_gemma-3-4b-it_v2tag__is_homework_assignment": [[0, 5000, false], [5000, 27198, null]], "google_gemma-3-4b-it_v2tag__is_news_article": [[0, 5000, false], [5000, 27198, null]], "google_gemma-3-4b-it_v2tag__is_public_order": [[0, 5000, false], [5000, 27198, null]], "google_gemma-3-4b-it_v2tag__is_resume_cv": [[0, 5000, false], [5000, 27198, null]], "google_gemma-3-4b-it_v2tag__is_test_or_quiz": [[0, 5000, false], [5000, 27198, null]], "google_gemma-3-4b-it_v2tag__is_textbook": [[0, 5000, false], [5000, 27198, null]], "pdf_page_numbers": [[0, 4559, 1], [4559, 8979, 2], [8979, 13921, 3], [13921, 15790, 4], [15790, 18772, 5], [18772, 23282, 6], [23282, 27198, 7]], "pipe_delimited_lines_v1__pipe_delimited_lines_v1__pipe_delimited_lines_ratio": [[0, 27198, 0.0]]}
olmocr_science_pdfs
2024-11-28
2024-11-28
95e24df9d47a69c891fa2227e56b845c17d86955
Sorting Algorithms - Insertion sort - Mergesort - Quicksort - Selection - Heap and heapsort ### Insertion Sort The problem is to sort an unordered array $A[0..n-1]$ in non-decreasing order. Given $A[0..n-1]$, - Sorting a handful of cards - Move an integer $p$ as a “pointer” from 1 to $n - 1$. - Maintain the invariant that the prefix $A[0..p]$ becomes sorted before $p$ is advanced. ```cpp void insertionSort(vector<int> & A) { int j; for (int p = 1; p < A.size(); p++) { int tmp = A[p]; for (j = p; j > 0 && tmp < A[j-1]; j--) A[j] = A[j-1]; A[j] = tmp; } } ``` **Insertion Sort: An Example** 5 2 4 6 1 3 2 5 4 6 1 3 2 4 5 6 1 3 2 4 5 6 1 3 1 2 4 5 6 3 1 2 3 4 5 6 What is the best case input and running time? (Sorted sequence, \( n \)) What is the worst case input and running time? (Reverse sequence, \( n^2 \)) This is a \( n^2 \) algorithms, as the worst-case running time trends like \( n^2 \) with the input size. Divide and Conquer: Mergesort We are to sort a sequence of $n$ numbers. If $n = 1$, then we are done. Otherwise, 1. Divide the sequence into two subsequences, each having at most $\lceil n/2 \rceil$ numbers. 2. Sort each subsequence recursively. 3. Merge the two sorted subsequences to produce one sorted sequence. - How to divide the sequence into two subsequences? How to divide quickly? - What does it mean to sort recursively? - How to merge? How quick is it? Mergesort Operation - If the input sequence is given as a linked list, then we can scan the linked list from left to right. We stop at the $\lfloor n/2 \rfloor$th entry and cut the link to obtain two sublists. Overall, this approach is of the same time complexity as the array case. - If the input sequence is given as an array $A[0..n-1]$, then we can avoid the linear-time scan. We can represent any subsequence of $A[0..n-1]$ by two integers left and right which index the two entries delimiting the subsequence. For example, to divide $A[\text{left} .. \text{right}]$, we compute $\text{center} = (\text{left} + \text{right})/2$ and the two subsequences are $A[\text{left} .. \text{center}]$ and $A[\text{center}+1 .. \text{right}]$. This takes $O(1)$ time. - Recall that we are designing an algorithm mergesort that sorts $n$ integers. And $n$ can be any positive number. So sorting each subsequence recursively means that we invoke mergesort two times, once to sort $A[\text{left} .. \text{center}]$ and once to sort $A[\text{center}+1 .. \text{right}]$. Mergesort Code (Recursive) template <class T> MergeSort( T a[], int left, int right) {// Sort the elements in a[left:right]. if (left < right) { // at least 2 elements int i = (left + right)/2; // midpoint MergeSort(a,left,i); MergeSort(a,i+1,right); // merge from a into an array b Merge(a,b,left,i,right); // put result back into a from b Copy(b,a,left,right); } } Assume for now that \texttt{Merge()} works correctly. Calling \texttt{MergeSort(A,0,n-1)} will sort the array A[0..n-1]. An Example on Calling Mergesort \((a, 0, 7)\) An Example 5 2 4 6 1 3 2 6 5 2 4 6 1 3 2 6 2 5 4 6 1 3 2 6 2 4 5 6 1 2 3 4 5 6 6 Describing $\text{merge}()$ Using Pseudo-Code Algorithm $\text{merge}(A, p, q, r)$ Input: Subarrays $A[p..l]$ and $A[q..r]$ s.t. $p \leq l = q - 1 < r$. (* $T$ is a temporary array. *) 1. $k = p$; $i = 0$; $l = q - 1$; 2. while $p \leq l$ and $q \leq r$ //merging steps 3. do if $A[p] \leq A[q]$ 4. then $T[i] = A[p]$; $i = i + 1$; $p = p + 1$; 5. else $T[i] = A[q]$; $i = i + 1$; $q = q + 1$; 6. while $p \leq l$ 7. do $T[i] = A[p]$; $i = i + 1$; $p = p + 1$; 8. while $q \leq r$ 9. do $T[i] = A[q]$; $i = i + 1$; $q = q + 1$; 10. for $i = k$ to $r$ 11. do $A[i] = T[i - k]$; //copyback Note that $\text{merge}(a, \text{left}, \text{i}+1, \text{right})$ is equivalent to $\text{Merge}(a, b, \text{left}, \text{i}, \text{right})$; $\text{Copy}(b, a, \text{left}, \text{right})$; on page 6. Merging Steps and Quicksort Please refer to ppt slides supplement. Comparison Between Insertion Sort, Mergesort and Quicksort <table> <thead> <tr> <th>n</th> <th>ISORT (secs)</th> <th>MSORT (secs)</th> <th>Ratio</th> </tr> </thead> <tbody> <tr> <td>100</td> <td>0.01</td> <td>0.01</td> <td>1</td> </tr> <tr> <td>1000</td> <td>0.18</td> <td>0.01</td> <td>18</td> </tr> <tr> <td>2000</td> <td>0.76</td> <td>0.04</td> <td>19</td> </tr> <tr> <td>3000</td> <td>1.67</td> <td>0.05</td> <td>33.4</td> </tr> <tr> <td>4000</td> <td>2.90</td> <td>0.07</td> <td>41</td> </tr> <tr> <td>5000</td> <td>4.66</td> <td>0.09</td> <td>52</td> </tr> <tr> <td>6000</td> <td>6.75</td> <td>0.10</td> <td>67.5</td> </tr> <tr> <td>7000</td> <td>9.39</td> <td>0.14</td> <td>67</td> </tr> <tr> <td>8000</td> <td>11.93</td> <td>0.14</td> <td>85</td> </tr> </tbody> </table> <table> <thead> <tr> <th>n</th> <th>MSORT</th> <th>QSORT</th> </tr> </thead> <tbody> <tr> <td>10000</td> <td>0.18</td> <td>0.07</td> </tr> <tr> <td>20000</td> <td>0.37</td> <td>0.17</td> </tr> <tr> <td>30000</td> <td>0.62</td> <td>0.25</td> </tr> <tr> <td>40000</td> <td>0.83</td> <td>0.33</td> </tr> <tr> <td>50000</td> <td>1.00</td> <td>0.45</td> </tr> <tr> <td>60000</td> <td>1.29</td> <td>0.53</td> </tr> <tr> <td>70000</td> <td>1.50</td> <td>0.59</td> </tr> <tr> <td>80000</td> <td>1.78</td> <td>0.75</td> </tr> </tbody> </table> Quick sort outperforms the other sort methods for suitably large $n$. There is a breakeven point (around 20) below which insertion sort is effective. Use insertion sort when the number of elements is fewer than the breakeven point; otherwise use quicksort. In the case of quicksort, the recursion step can be replaced by insertion sort if the number of elements is lower than the breakeven point. Selection • Given an array $a[0:n-1]$ of $n$ elements, find the $k$th element. – For example, find the median – Sort it and return the $k$th element. This takes $O(n \log n)$ time, which is not necessary and fast enough • Use a simpler quicksort to recursively focus only on the segment with the $k$th element • Always choosing the left element as the pivot leads to poor performance if the array is sorted – For simplicity, we have used this in the `select` program select template<class T> T select(T a[], int l, int r, int k) { // Return k’th smallest in a[l:r]. if (l >= r) return a[l]; int i = l, // left to right cursor j = r + 1; // right to left cursor T pivot = a[l]; // swap elements >= pivot on left side // with elements <= pivot on right side while (true) { do {// find >= element on left side i = i + 1; } while (a[i] < pivot); do {// find <= element on right side j = j - 1; } while (a[j] > pivot); if (i >= j) break; // swap pair not found Swap(a[i], a[j]); } if (j - l + 1 == k) return pivot; // place pivot a[l] = a[j]; a[j] = pivot; // recursive call on one segment if (j - l + 1 < k) return select(a, j+1, r, k-j+l-1); else return select(a, l, j-1, k); } Heapsort 1. Select the current minimum element from the remaining numbers. 2. Output the current minimum and remove it. 3. Repeat the above two steps. Introduce a new data structure called heap that can support the two operations efficiently in $O(\log n)$ time. Specifically, we can maintain a set of $n$ elements in a heap such that - can locate the current minimum in $O(1)$ time. - can delete the current minimum in $O(\log n)$ time. Heap - A typical representation of a heap is a complete binary tree. - Each node stores a value. - The value stored at a node is smaller than or equal to the values stored at its children. We call this the min-heap property and the corresponding heap a min-heap. Symmetrically, one can also define the max-heap property and a max-heap. ![min-heap](image1) ![not a min-heap](image2) Definitions - A max tree (min tree) is a tree in which the value in each node is greater (less) than or equal to those in its children (if any). - A max heap (min heap) is a max (min) tree that is also a complete binary tree. Heap Root and the Minimum Number • The root of the tree contains the minimum number. – Hence, the minimum number can be accessed in $O(1)$ time. • Deleting the minimum number 1. Copy the last number to the root, thus overwriting the number stored at the root. 2. Restore the min-heap property. Heap Operation: Deletion mn-heap property destroyed Restore the min-heap property compare 20 with 7, the smallest of its two children compare 20 with 9, the smallest of its two children Deletion (Cont.) A heap! Time complexity = O(height) = O(log n) So we know how to delete the minimum number. But how to build a heap in the first place? Building a Heap We can do it by incremental insertion. So how to insert a new number into a heap? 1. Add the number to the bottommost level. 2. min-heap property may be violated. Restoring the Min-Heap Property compare 4 with 16 compare 4 with 9 compare 4 with 7 Array Representation of the Complete Binary Tree - store the min-heap in an array. - map the nodes in the complete binary tree to elements of the vector by numbering the nodes from level to level. Array Values Store the values in this order in an array $A$ \[4 \ 7 \ 8 \ 17 \ 9 \ 14 \ 10 \ 20 \ 18 \ 16\] - given a node at location $i$, its children are at locations $2i + 1$ and $2i + 2$. - given a node at location $i > 0$, its parent is at location $\lfloor (i - 1)/2 \rfloor$. - if $n$ is the current number of values being stored in the heap, $A[n - 1]$ stores the right-most node at the bottommost level and $A[n]$ is the next available location. In-Place Sorting • If min-heap is used, a temporary buffer of size $O(n)$ is needed to hold the partially formed min-heap – Adding one element at a time at the end of a partial heap, followed by heap restoration – Deleting element by element back to the original array • This is a high storage overhead • We would like to sort *in-place* so that no extra storage is incurred • Do it with max-heap instead of min-heap • One way is to expand from the first element by adding one element at a time and restoring a max-heap each time. • Another way is to work “backwards” from the middle element to build max-heap along the way. We will discuss it in the following. Max Heap Initialization from an Array Converting an array \([20, 12, 35, 15, 10, 80, 30, 17, 2, 1]\) into a max heap: 1. Begin with the first element that has a child (i.e., 10). This element is at position \(i = \lfloor n/2 \rfloor\). 2. If the subtree that rooted at this position is a max heap, then no work is done here. 3. Otherwise, we adjust the subtree so that it is a heap. 4. Following this adjustment, we examine the subtree whose root is at \(i - 1\), then \(i - 2\), and so on until we have examined the root of the entire binary tree, which is at position 1. 5. Note that one may build the max-heap by inserting numbers one by one instead of working backwards as above. Max Heap Initialization: An Example Figure 9.5 Initializing a max heap Figure 9.5 Initializing a max heap (Continuation) In-Place HeapSort (a) (b) Figure 9.9 Heap Sort (c) (d) Figure 9.9 Heap sort (Continuation) MaxHeap Class template<class T> class MaxHeap { public: MaxHeap(int MaxHeapSize = 10); ~MaxHeap() {delete [] heap;} int Size() const {return CurrentSize;} T Max() {if (CurrentSize == 0) throw OutOfBounds(); return heap[1];} MaxHeap<T>& Insert(const T& x); MaxHeap<T>& DeleteMax(T& x); void Initialize(T a[], int size, int ArraySize); void Deactivate() {heap = 0;} void Output() const; private: int CurrentSize, MaxSize; T *heap; // element array }; template<class T> MaxHeap<T>::MaxHeap(int MaxHeapSize) {// Max heap constructor. MaxSize = MaxHeapSize; heap = new T[MaxSize+1]; CurrentSize = 0; } Insertion template<class T> MaxHeap<T>& MaxHeap<T>::Insert(const T& x) { // Insert x into the max heap. if (CurrentSize == MaxSize) throw NoMem(); // no space // find place for x // i starts at new leaf and moves up tree int i = ++CurrentSize; while (i != 1 && x > heap[i/2]) { // cannot put x in heap[i] heap[i] = heap[i/2]; // move element down i /= 2; // move to parent } heap[i] = x; return *this; } Deletion template<class T> MaxHeap<T>& MaxHeap<T>::DeleteMax(T& x) { // Set x to max element and delete // max element from heap. // check if heap is empty if (CurrentSize == 0) throw OutOfBounds(); // empty x = heap[1]; // max element // restructure heap T y = heap[CurrentSize--]; // last element // find place for y starting at root int i = 1, // current node of heap ci = 2; // child of i while (ci <= CurrentSize) { // heap[ci] should be larger child of i if (ci < CurrentSize && heap[ci] < heap[ci+1]) ci++; // can we put y in heap[i]? if (y >= heap[ci]) break; // yes // no heap[i] = heap[ci]; // move child up i = ci; // move down a level ci *= 2; } // if heap[i] = y; return *this; } Initialize a Nonempty Max Heap ```cpp template<class T> void MaxHeap<T>::Initialize(T a[], int size, int ArraySize) { // Initialize max heap to array a. delete [] heap; heap = a; CurrentSize = size; MaxSize = ArraySize; // make into a max heap for (int i = CurrentSize/2; i >= 1; i--) { T y = heap[i]; // root of subtree // find place to put y int c = 2*i; // parent of c is target // location for y while (c <= CurrentSize) { // heap[c] should be larger sibling if (c < CurrentSize && heap[c] < heap[c+1]) c++; // can we put y in heap[c/2]? if (y >= heap[c]) break; // yes // no heap[c/2] = heap[c]; // move child up c *= 2; // move down a level } heap[c/2] = y; } } ``` HeapSort template <class T> void HeapSort(T a[], int n) {// Sort a[1:n] using the heap sort method. // create a max heap of the elements MaxHeap<T> H(1); H.Initialize(a,n,n); // extract one by one from the max heap T x; for (int i = n-1; i >= 1; i--) { H.DeleteMax(x); a[i+1] = x; } // save array a from heap destructor H.Deactivate(); } In-Place HeapSort Go back to the ppt slides
{"Source-Url": "http://home.cse.ust.hk/~dekai/2012H_2014Q1/lectures/l32_sorting.pdf", "len_cl100k_base": 4680, "olmocr-version": "0.1.53", "pdf-total-pages": 34, "total-fallback-pages": 0, "total-input-tokens": 56325, "total-output-tokens": 6061, "length": "2e12", "weborganizer": {"__label__adult": 0.00038695335388183594, "__label__art_design": 0.00023353099822998047, "__label__crime_law": 0.0002892017364501953, "__label__education_jobs": 0.0005135536193847656, "__label__entertainment": 5.936622619628906e-05, "__label__fashion_beauty": 0.00014507770538330078, "__label__finance_business": 8.970499038696289e-05, "__label__food_dining": 0.0005636215209960938, "__label__games": 0.0008673667907714844, "__label__hardware": 0.0012750625610351562, "__label__health": 0.0003848075866699219, "__label__history": 0.00021183490753173828, "__label__home_hobbies": 0.00011241436004638672, "__label__industrial": 0.00038313865661621094, "__label__literature": 0.0001634359359741211, "__label__politics": 0.0002005100250244141, "__label__religion": 0.0004203319549560547, "__label__science_tech": 0.00653076171875, "__label__social_life": 6.681680679321289e-05, "__label__software": 0.003055572509765625, "__label__software_dev": 0.98291015625, "__label__sports_fitness": 0.00041413307189941406, "__label__transportation": 0.0005168914794921875, "__label__travel": 0.00024437904357910156}, "weborganizer_max": "__label__software_dev", "avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_ratio": [[0, 14242, 0.0607]], "fineweb_edu_fasttext_gt2__fineweb_edu_fasttext_gt2__score": [[0, 14242, 0.61791]], "ft_lang_id_en_doc_v2__ft_lang_id_en_doc_v2__en": [[0, 14242, 0.70859]], "google_gemma-3-12b-it_contains_pii": [[0, 95, false], [95, 845, null], [845, 1208, null], [1208, 1675, null], [1675, 2740, null], [2740, 3303, null], [3303, 3349, null], [3349, 3438, null], [3438, 4267, null], [4267, 4335, null], [4335, 5163, null], [5163, 5563, null], [5563, 6039, null], [6039, 6835, null], [6835, 7276, null], [7276, 7661, null], [7661, 7889, null], [7889, 8191, null], [8191, 8381, null], [8381, 8536, null], [8536, 8718, null], [8718, 8805, null], [8805, 9003, null], [9003, 9464, null], [9464, 10136, null], [10136, 10826, null], [10826, 10949, null], [10949, 11044, null], [11044, 11719, null], [11719, 12190, null], [12190, 12998, null], [12998, 13818, null], [13818, 14198, null], [14198, 14242, null]], "google_gemma-3-12b-it_is_public_document": [[0, 95, true], [95, 845, null], [845, 1208, null], [1208, 1675, null], [1675, 2740, null], [2740, 3303, null], [3303, 3349, null], [3349, 3438, null], [3438, 4267, null], [4267, 4335, null], [4335, 5163, null], [5163, 5563, null], [5563, 6039, null], [6039, 6835, null], [6835, 7276, null], [7276, 7661, null], [7661, 7889, null], [7889, 8191, null], [8191, 8381, null], [8381, 8536, null], [8536, 8718, null], [8718, 8805, null], [8805, 9003, null], [9003, 9464, null], [9464, 10136, null], [10136, 10826, null], [10826, 10949, null], [10949, 11044, null], [11044, 11719, null], [11719, 12190, null], [12190, 12998, null], [12998, 13818, null], [13818, 14198, null], [14198, 14242, null]], "google_gemma-3-4b-it_v2tag__is_academic_paper": [[0, 5000, true], [5000, 14242, null]], "google_gemma-3-4b-it_v2tag__is_class_syllabus": [[0, 5000, false], [5000, 14242, null]], "google_gemma-3-4b-it_v2tag__is_completion_certificate": [[0, 5000, false], [5000, 14242, null]], "google_gemma-3-4b-it_v2tag__is_court_notice": [[0, 5000, false], [5000, 14242, null]], "google_gemma-3-4b-it_v2tag__is_homework_assignment": [[0, 5000, true], [5000, 14242, null]], "google_gemma-3-4b-it_v2tag__is_news_article": [[0, 5000, false], [5000, 14242, null]], "google_gemma-3-4b-it_v2tag__is_public_order": [[0, 5000, false], [5000, 14242, null]], "google_gemma-3-4b-it_v2tag__is_resume_cv": [[0, 5000, false], [5000, 14242, null]], "google_gemma-3-4b-it_v2tag__is_test_or_quiz": [[0, 5000, false], [5000, 14242, null]], "google_gemma-3-4b-it_v2tag__is_textbook": [[0, 5000, false], [5000, 14242, null]], "pdf_page_numbers": [[0, 95, 1], [95, 845, 2], [845, 1208, 3], [1208, 1675, 4], [1675, 2740, 5], [2740, 3303, 6], [3303, 3349, 7], [3349, 3438, 8], [3438, 4267, 9], [4267, 4335, 10], [4335, 5163, 11], [5163, 5563, 12], [5563, 6039, 13], [6039, 6835, 14], [6835, 7276, 15], [7276, 7661, 16], [7661, 7889, 17], [7889, 8191, 18], [8191, 8381, 19], [8381, 8536, 20], [8536, 8718, 21], [8718, 8805, 22], [8805, 9003, 23], [9003, 9464, 24], [9464, 10136, 25], [10136, 10826, 26], [10826, 10949, 27], [10949, 11044, 28], [11044, 11719, 29], [11719, 12190, 30], [12190, 12998, 31], [12998, 13818, 32], [13818, 14198, 33], [14198, 14242, 34]], "pipe_delimited_lines_v1__pipe_delimited_lines_v1__pipe_delimited_lines_ratio": [[0, 14242, 0.05882]]}
olmocr_science_pdfs
2024-12-07
2024-12-07
23dec407b68eafeb564d76a3f5126b27c3e2f32a
More On Memory (mis)-Management Reminder on Strings... - Reminder: Strings are just like any other C array... - You have a pointer to the start and no way of knowing the length - But you have an in-band "end of string" signal with the '\0' (0-byte) character - Since you can have multiple pointers point to the same thing... - `char *a, *b; ... a = b; ... b[4] = 'x'; /* This will update a as well, since they are pointing to the same thing */` - So how do you copy a string? - Find the length (strlen), allocate a new array, and then call strcpy... - `a = malloc(sizeof(char) * (strlen(b) + 1)); /* Forget the +1 at your own peril */` - `strcpy(a, b) or strncpy(a, b, strlen(b) + 1);` - `strcpy` doesn't know the length of the destination, so it can be very unsafe - `strncpy` copies only n character for safety, but if its too short it *will not copy the null terminator!* And Constant Strings... - Anything you put explicitly in quotes becomes a `constant` string - `char *foo = "this is a constant";` - For efficiency, these strings are stored as `read only` global variables - So if you also have `char *bar = "this is a constant";` - it is the same string - It is, guess what, undefined behavior to write to a constant string - But fortunately it is usually an immediate crash. Pointer Ninjitsu: Pointers to Functions • You have a function definition • `char *foo(char *a, int b){ ... }` • Can create a pointer of that type... • `char *(*f)(char *, int);` • Declares f as a function taking a char * and an int and returning a char * • Can assign to it • `f = &foo` • Create a reference to function foo • And can then call it... • `printf("%s\n", (*f)("cat", 3))` • Necessary if you want to write generic code in C: E.g. a hashtable that can handle pointers of any type C unions We’ve seen how structs can hold multiple elements addressed by name... - But what if you want to hold different types in the same location? **union fubar {** **int a;** **char *b;** **void c;** } Fubar;** - Accessed just like a struct, but... - `Fubar *f = (Fubar *) malloc(sizeof(union fubar))...` - `f->a = 1312;` - `f->b = "baz"` - They are actually the same memory! It is just treated differently by the compiler! How to Use Unions... • Well, you also have to know what the type is... • Common pattern • enum FieldType {a_type, b_type, c_type}; union bar { char *a; int b; float c;}; struct foo { FieldType type; union bar data; } ... struct foo *f; ... switch(f->type){ case a_type: printf("%s\n", f->data.a); break; Structure Layout In Memory • Everything in C is just buckets of bytes… • So how do we do structures? We lay out the structure starting at the 0th byte • `struct foo { int a; char b; short c; char *d};` • It depends on the compiler and underlying architecture… Alignment, Packing, & Structures… • If the architecture did not **not** force alignment: • Just squish everything together • `struct foo { int a; /* At 0 */ char b; /* At 4 */ short c; /* At 5 */ char *d; /* At 7 */ char e;}; /* At 11 */` • But we already mention that computers don’t actually like this! • They want things aligned Default Alignment Rules... • These are the **default** alignment rules for the class • Centered around a “32b architecture”: Integers and pointers are 32b values • char: 1 byte, no alignment needed when stored in memory • short: 2 bytes, 1/2 world aligned • So 0, 2, 4, 6… • int: 4 bytes, word aligned • pointers are the same size as ints • Need to allow multiple instances of the same structure to be aligned! So with alignment - struct foo { int a; /* At 0 */ char b; /* At 4 */ short c; /* At 6 */ char *d; /* At 8 */ char e;}; /* At 13 */ - But sizeof(struct foo) == 16! - Need to add padding to the end as well, so that if we allocate two structures at the same time it is always aligned! Pointer Ninjitsu: Pointers to arrays of structures - `typedef struct foo_struct { int x; char *z; char y; } foo;` - So how big is a `foo`? - assume an aligned architecture, `sizeof(int) == sizeof(void *) == 4`: - `12... It needs to be padded` - Dynamically allocated a single element: - `foo *f = (foo *) malloc(sizeof(foo))` - Dynamically allocate a 10 entry array of `foos`: - `foo *f = (foo *) malloc(sizeof(foo) * 10);` Pointer Ninjitsu Continued: Accessing that array... - Accessing the 5th element's string pointer: - `f[4].z = "fubar" - Assigns the z pointer to point to the static string fubar - It is undefined behavior to then do `f[4].z[1] = 'X' - If you want to modify the string pointed to by z you are going to have to do a string copy - What does it look like "under the hood"? - The address written to in `f[4].z = "fubar"` is `(f + 4 * 12 + 4)`: - Note: This math is the 'under the hood' math: if you actually tried this in C it would not work right! But it is what the compiler produces in the assembly language - The 5th element of type `foo` is offset (4*12) from `f` - Since we want all elements in the array to have the same alignment this is why we had the padding - The field z is offset 4 from the start of a foo object Managing the Heap • Recall that C supports functions for heap management: • malloc() allocate a block of uninitialized memory • calloc() allocate a block of zeroed memory • free() free previously allocated block of memory • realloc() change size of previously allocated block • careful – it might move! Observations • Code, Static storage are easy: they never grow or shrink • Stack space is relatively easy: stack frames are created and destroyed in last-in, first-out (LIFO) order • Managing the heap is tricky: memory can be allocated / deallocated at any time How are Malloc/Free implemented? • Underlying operating system allows malloc library to ask for large blocks of memory to use in heap (e.g., using Unix \texttt{sbrk()} call) • This is one reason why your C code, when compiled, is dependent on a particular operating system • C standard malloc library creates data structure inside unused portions to track free space • This class is about how computers work: How they allocate memory is a huge component Simple Slow Malloc Implementation Initial Empty Heap space from Operating System Free Space Malloc library creates linked list of empty blocks (one block initially) Object 1 Free First allocation chews up space from start of free space After many mallocs and frees, have potentially long linked list of odd-sized blocks Frees link block back onto linked list – might merge with neighboring free space The Problem Here: Fragmentation - That memory hierarchy we saw earlier likes things small... - And likes things contiguous - Things start to work badly when stuff is scattered all over the place - Which will eventually happen with such a simple allocator Faster malloc implementations • Keep separate pools of blocks for different sized objects • “Buddy allocators” always round up to power-of-2 sized chunks to simplify finding correct size and merging neighboring blocks: • Then can just use a simple bitmap to know what is free or occupied ### Power-of-2 “Buddy Allocator” <table> <thead> <tr> <th>Step</th> <th>64K</th> <th>64K</th> <th>64K</th> <th>64K</th> <th>64K</th> <th>64K</th> <th>64K</th> <th>64K</th> <th>64K</th> <th>64K</th> </tr> </thead> <tbody> <tr> <td>1</td> <td>2^4</td> <td></td> <td></td> <td></td> <td></td> <td></td> <td></td> <td></td> <td></td> <td></td> </tr> <tr> <td>2.1</td> <td>2^3</td> <td></td> <td></td> <td></td> <td></td> <td></td> <td></td> <td></td> <td></td> <td></td> </tr> <tr> <td>2.2</td> <td>2^2</td> <td></td> <td></td> <td></td> <td></td> <td></td> <td></td> <td></td> <td></td> <td></td> </tr> <tr> <td>2.3</td> <td>2^1</td> <td></td> <td></td> <td></td> <td></td> <td></td> <td></td> <td></td> <td></td> <td></td> </tr> <tr> <td>2.4</td> <td>2^0</td> <td>2^0</td> <td>2^0</td> <td>2^0</td> <td>2^0</td> <td></td> <td></td> <td></td> <td></td> <td></td> </tr> <tr> <td>2.5</td> <td>A: 2^0</td> <td>2^0</td> <td>2^0</td> <td>2^0</td> <td>2^0</td> <td></td> <td></td> <td></td> <td></td> <td></td> </tr> <tr> <td>3</td> <td>A: 2^0</td> <td>2^0</td> <td>B: 2^1</td> <td>2^0</td> <td>2^0</td> <td>2^0</td> <td></td> <td></td> <td></td> <td></td> </tr> <tr> <td>4</td> <td>A: 2^0</td> <td>C: 2^0</td> <td>B: 2^1</td> <td>2^0</td> <td>2^0</td> <td>2^0</td> <td>2^0</td> <td></td> <td></td> <td></td> </tr> <tr> <td>5.1</td> <td>A: 2^0</td> <td>C: 2^0</td> <td>B: 2^1</td> <td>2^0</td> <td></td> <td></td> <td></td> <td></td> <td></td> <td></td> </tr> <tr> <td>5.2</td> <td>A: 2^0</td> <td>C: 2^0</td> <td>B: 2^1</td> <td>D: 2^1</td> <td></td> <td></td> <td></td> <td></td> <td></td> <td></td> </tr> <tr> <td>6</td> <td>A: 2^0</td> <td>C: 2^0</td> <td>2^1</td> <td>2^0</td> <td>2^0</td> <td>2^0</td> <td>2^0</td> <td></td> <td></td> <td></td> </tr> <tr> <td>7.1</td> <td>A: 2^0</td> <td>C: 2^0</td> <td>2^1</td> <td>2^1</td> <td>2^0</td> <td>2^0</td> <td>2^0</td> <td>2^0</td> <td></td> <td></td> </tr> <tr> <td>7.2</td> <td>A: 2^0</td> <td>C: 2^0</td> <td>2^1</td> <td>2^0</td> <td>2^0</td> <td>2^0</td> <td>2^0</td> <td>2^0</td> <td>2^0</td> <td>2^0</td> </tr> <tr> <td>8</td> <td>2^0</td> <td>C: 2^0</td> <td>2^1</td> <td>2^0</td> <td>2^0</td> <td>2^0</td> <td>2^0</td> <td>2^0</td> <td>2^0</td> <td>2^0</td> </tr> <tr> <td>9.1</td> <td>2^0</td> <td>2^0</td> <td>2^1</td> <td>2^0</td> <td>2^0</td> <td>2^0</td> <td>2^0</td> <td>2^0</td> <td>2^0</td> <td>2^0</td> </tr> <tr> <td>9.2</td> <td>2^1</td> <td>2^1</td> <td>2^0</td> <td>2^0</td> <td>2^0</td> <td>2^0</td> <td>2^0</td> <td>2^0</td> <td>2^0</td> <td>2^0</td> </tr> <tr> <td>9.3</td> <td>2^2</td> <td></td> <td>2^0</td> <td>2^0</td> <td>2^0</td> <td>2^0</td> <td>2^0</td> <td>2^0</td> <td>2^0</td> <td>2^0</td> </tr> <tr> <td>9.4</td> <td>2^3</td> <td></td> <td></td> <td>2^0</td> <td>2^0</td> <td>2^0</td> <td>2^0</td> <td>2^0</td> <td>2^0</td> <td>2^0</td> </tr> <tr> <td>9.5</td> <td>2^4</td> <td></td> <td></td> <td></td> <td>2^0</td> <td>2^0</td> <td>2^0</td> <td>2^0</td> <td>2^0</td> <td>2^0</td> </tr> </tbody> </table> Malloc Implementations - All provide the same library interface, but can have radically different implementations - Uses headers at start of allocated blocks and/or space in unallocated memory to hold malloc’s internal data structures - Rely on programmer remembering to free with same pointer returned by malloc - Alternative is a "conservative garbage collector" - Rely on programmer not messing with internal data structures accidentally! - If you get a crash in malloc, it means that somewhere else you wrote off the end of an array Conservative Mark/Sweep Garbage Collectors - An alternative to `malloc` & `free`... - `malloc` works normally, but `free` just does nothing - Instead, it starts with the stack & global variables as the "live" memory - But it doesn't know if those variables are pointers, integers, or whatevers... - So assume that every piece of memory in the starting set is a pointer... - If it points to something that was allocated by malloc, that entire allocation is now considered live, and "mark it" as live - Iterate until there is no more newly discovered live memory - Now any block of memory that isn't can be deallocated ("sweep") The Problems: Fragmentation & Pauses... - A conservative garbage collector can't move memory around - So it gets increasingly fragmented... When we get to both caches and virtual memory we will see how this causes problems - A conservative collector needs to stop the program! - What would happen if things changed underneath it? Ruh Roh... - So the system needs to pause - Java and Python don't have this problem - Java is designed to understand garbage collection: Able to have incremental collectors that don't require a long halt - Python doesn't do real garbage collection: Just uses "reference counting". Every python object has a counter for the number of pointers pointing to it. When it gets to 0, free the object - Reference counter can't free cycles Clicker Question • What will the following print: ```c int a, b, c, *d; a = 0; b = 1; c = 2; d = &a; (*d) += b + c; d = &b; (*d) += a + b + c; printf(“a=%i b=%i\n”, a, b); ``` • A) a=0, b=3 • B) a=3, b=3 • C) a=3, b=4 • D) a=3, b=7 • E) I ditched class today and had a friend "borrow" my clicker Administrivia Common Memory Problems: aka Common "Anti-patterns" - Using uninitialized values - Especially bad to use uninitialized pointers - Using memory that you don’t own - Deallocated stack or heap variable - Out-of-bounds reference to stack or heap array - Using NULL or garbage data as a pointer - Writing to static strings - Improper use of `free/realloc` by messing with the pointer handle returned by `malloc/calloc` - Memory leaks (you allocated something you forgot to later free) - Valgrind is designed to catch **most** of these - It runs the program extra-super-duper-slow in order to add checks for these problems that C doesn't otherwise do Using Memory You Don’t Own • What is wrong with this code? ```c int *ipr, *ipw; void ReadMem() { int i, j; ipr = (int *) malloc(4 * sizeof(int)); i = *(ipr - 1000); j = *(ipr + 1000); free(ipr); } void WriteMem() { ipw = (int *) malloc(5 * sizeof(int)); *(ipw - 1000) = 0; *(ipw + 1000) = 0; free(ipw); } ``` - Out of bounds reads - Out of bounds writes Faulty Heap Management • What is wrong with this code? • int *pi; void foo() { pi = malloc(8*sizeof(int)); ... free(pi); } void main() { pi = malloc(4*sizeof(int)); foo(); ... } The first `malloc` of `pi` leaks Reflection on Memory Leaks - Memory leaks are not a problem if your program terminates quickly. - Memory leaks become a much bigger problem when your program keeps running. - Or when you are running on a small embedded system. Three solutions: - Be very diligent about making sure you free all memory. - Use a tool that helps you find leaked memory. - Perhaps implement your own reference counter. - Use a "Conservative Garbage Collector" malloc. - Just quit and restart your program a lot ("burn down the frat-house"). - Design your server to crash! - But memory leaks will slow down your program long before it actually crashes. So Why Do Memory Leaks Slow Things Down? • Remember at the start we saw that pyramid of memory? • Small & fast -> cache Big & slow -> main memory • Memory leaks lead to **fragmentation** • As a consequence you use more memory, and its more scattered around • Computers are designed to access **contiguous** memory • So things that cause your working memory to be spread out more and in smaller pieces slow things down • There also may be nonlinearities: • Fine... Fine... Fine... Hit-A-Brick-Wall! Faulty Heap Management • What is wrong with this code? ```c int *plk = NULL; void genPLK() { plk = malloc(2 * sizeof(int)); ... plk++; // This MAY be a memory leak } ``` This MAY be a memory leak if we don't keep somewhere else a copy of the original malloc'ed pointer. Faulty Heap Management - How many things are wrong with this code? ```c • void FreeMemX() { int fnh[3] = 0; ... free(fnh); /* Can't free memory allocated on the stack */ } • void FreeMemY() { int *fum = malloc(4 * sizeof(int)); free(fum+1); /* Can't free memory that isn't the pointer from malloc */ ... free(fum); ... free(fum); /* Can't free memory twice */ } ``` Using Memory You Haven’t Allocated • What is wrong with this code? ```c void StringManipulate() { const char *name = "Safety Critical"; // sizeof(char) is 1 char *str = malloc(10); // but should have sizeof as a good habit strncpy(str, name, 10); str[10] = '\0'; // Write off of the end of the array! printf("%s\n", str); } ``` Using Memory You Don’t Own What’s wrong with this code? ```c char *append(const char* s1, const char *s2) { const int MAXSIZE = 128; char result[128]; int i=0, j=0; for (j=0; i<MAXSIZE-1 && j<strlen(s1); i++,j++) { result[i] = s1[j]; } for (j=0; i<MAXSIZE-1 && j<strlen(s2); i++,j++) { result[i] = s2[j]; } result[++i] = '\0'; return result; } ``` Returning a pointer to stack-allocated memory! Using Memory You Don’t Own • What is wrong with this code? ```c typedef struct node { struct node* next; int val; } Node; int findLastNodeValue(Node* head) { while (head->next != NULL) { head = head->next; } return head->val; } ``` What if head is null? Always check arguments. Your code may be good... But you make mistakes! PROGRAM DEFENSIVELY Using Memory You Don’t Own • What is wrong with this code? ```c void muckString(char *str) { str[0] = 'b'; } void main(void) { char *str = "abc"; muckString(str); puts(str); } ``` Pointing to a static string... Ruh Roh... So Why Was That A Problem... - When the compiler sees - `char *foo = "abc" - The compiler interprets it as 'have the constant string "abc" somewhere in static memory, and have foo point to this' - If you have the same string "abc" elsewhere, it will point to the same thing... - If you are lucky, the compiler makes sure that these string constants are set so you can't write - "Access violation", "bus error", "segfault" - There is something safe however... - `char foo[] = "abc" - The compiler interprets this as 'create a 4 character array on the stack, and initialize it to "abc" - But of course we can't now say `return foo;` - Because that would be returning a pointer to something on the stack... Managing the Heap: `realloc(p, size)` - Resize a previously allocated block at `p` to a new size - If `p` is NULL, then `realloc` behaves like `malloc` - If size is 0, then `realloc` behaves like `free`, deallocating the block from the heap - Returns new address of the memory block; NOTE: it is likely to have moved! ```c int *ip; ip = (int *) malloc(10*sizeof(int)); /* always check for ip == NULL */ ... ... ip = (int *) realloc(ip,20*sizeof(int)); /* always check NULL, contents of first 10 elements retained */ ... ... realloc(ip,0); /* identical to free(ip) */ ``` Using Memory You Don’t Own • What is wrong with this code? ```c int* init_array(int *ptr, int new_size) { ptr = realloc(ptr, new_size*sizeof(int)); memset(ptr, 0, new_size*sizeof(int)); return ptr; } int* fill_fibonacci(int *fib, int size) { int i; init_array(fib, size); /* fib[0] = 0; */ fib[1] = 1; for (i=2; i<size; i++) fib[i] = fib[i-1] + fib[i-2]; return fib; } ``` realloc might move the block! Which means this hasn't updated *fib! And Now A Bit of Security: Overflow Attacks - struct UnitedFlyer{ ... char lastname[16]; char status[32]; /* C will almost certainly lay this out in memory so they are adjacent */ ... }; ... So what... - Well, United has my status as: - name = "Weaver", status = "normal-person: hated" - So what I need to do is get United to update my name!!! - So I provide United with my new name as: Weaver super-elite: actually like - name = "Weaver super-elite: actually like", status = "super-elite: actually like" - And then update my name again back to just "Weaver" - name = "Weaver", status = "super-elite: actually like" - Basic premise of a buffer overflow attack: - An input that overwrites past the end of the buffer and leaves the resulting memory in a state suitable to the attacker's goals Hijacking Control Flow With Buffer Overflows... • Reminder: The stack stores a lot of stuff... • Not just local variables, but where to return execution to when a function returns • So if you write some code with a stack-allocated array • char foo[32]; gets(foo); /* gets reads input into the string until a newline */ • A bad dude gets to provide your program a string (e.g. because it is a server) • His string is significantly longer than 32 characters... • Result: • His string overwrites other local variables, including where the function is supposed to return! • And now your program is his program! And In Conclusion, ... - C has three main memory segments in which to allocate data: - Static Data: Variables outside functions - Stack: Variables local to function - Heap: Objects explicitly malloc-ed/free-d. - Heap data is biggest source of bugs in C code Levels of Representation/Interpretation - **High Level Language Program (e.g., C)** - **Assembly Language Program (e.g., MIPS)** - **Machine Language Program (MIPS)** **Compiler** ``` temp = v[k]; v[k] = v[k+1]; v[k+1] = temp; ``` Any data or instruction can be represented as a number, i.e., data or instructions. **Assembler** ``` 0000 1001 1100 0110 1010 1111 0101 1000 1010 1111 0101 1000 0000 1001 1100 0110 1100 0110 1010 1111 0101 1000 0000 1001 0101 1000 0000 1001 1100 0110 1010 1111 ``` **Machine Interpretation** - **Hardware Architecture Description (e.g., block diagrams)** - **Architecture Implementation** **Logic Circuit Description (Circuit Schematic Diagrams)** **Register File** **ALU** Assembly Language - Basic job of a CPU: execute lots of instructions. - Instructions are the primitive operations that the CPU may execute - The stored program in "stored program computer" - Different CPUs implement different sets of instructions. The set of instructions a particular CPU implements is an Instruction Set Architecture (ISA). - Examples: ARM, Intel x86, Intel x64 (64b x86), MIPS, RISC-V, IBM/Motorola PowerPC (old Mac), Motorola 68k (really old Mac), Intel IA64 (aka Itanic), ... Instruction Set Architectures • Early trend was to add more and more instructions to new CPUs to do elaborate operations • VAX architecture had an instruction to multiply polynomials! • RISC philosophy (Cocke IBM, Patterson, Hennessy, 1980s) Reduced Instruction Set Computing • Keep the instruction set small and simple, makes it easier to build fast hardware • Let software do complicated operations by composing simpler ones Berkeley Acknowledge for the first RISC computer The RISC-V Instruction Set Architecture RISC-V (pronounced "risk-five") is a new instruction set architecture (ISA) that was originally designed to support computer architecture research and education, which we now hope will become a standard open architecture for industry implementations. RISC-V was originally developed in the Computer Science Division of the EECS Department at the University of California, Berkeley. Pretty much everything in Berkeley uses RISC-V But at the same time... All RISCs are mostly the same except for one or two silly design decisions - **MIPS:** - "The Branch Delay Slot": The instruction immediately after an if is always executed - **SPARC:** - "Register Windows": Map a larger set of registers for “improved” function calling - **ARM:** - 32b is ugly as sin... - But 64b is pretty much generic RISC with condition codes for instructions: Allow you to say "only do this instruction if a previous value was TRUE/FALSE" - **RISC-V:** - You will hate how immediates are encoded until you understand how muxes work... And x86s these days are really RISCs in disguise... - They start by translating the x86/x64 CISC instructions into a series of "micro operations" - These instructions are then executed on something that looks very much like a RISC processor - They just end up costing a fair bit more... Because they first have to turn x86/x64 into a RISC internal structure - Basically 2-3 pipeline stages... - “With enough rocket boosters anything can fly, and Intel has strapped that pig to a Saturn V” -Me So Why Do Some Architectures "Win"? - The big winners: x86/x64 (desktop) and Arm (phones/embedded) - Neither are the cheapest nor the best architectures available... - They won because of the legacy software stack... - x86 had Windows and then Linux for servers and a history of optimizing for performance *without breaking old things*. - For a decade+ you'd be able to just make everything run faster by throwing some money at the problem... - Arm became entrenched with Linux->Android in the phone market - But since *our* focus is understanding how computers work, our software stack is RISC-V
{"Source-Url": "https://cs61c.org/lectures/lec04.pdf", "len_cl100k_base": 7261, "olmocr-version": "0.1.50", "pdf-total-pages": 50, "total-fallback-pages": 0, "total-input-tokens": 61247, "total-output-tokens": 8881, "length": "2e12", "weborganizer": {"__label__adult": 0.0003960132598876953, "__label__art_design": 0.0003864765167236328, "__label__crime_law": 0.0002338886260986328, "__label__education_jobs": 0.0003075599670410156, "__label__entertainment": 7.838010787963867e-05, "__label__fashion_beauty": 0.00016105175018310547, "__label__finance_business": 0.00014007091522216797, "__label__food_dining": 0.0004265308380126953, "__label__games": 0.0007648468017578125, "__label__hardware": 0.0045623779296875, "__label__health": 0.0003750324249267578, "__label__history": 0.00024580955505371094, "__label__home_hobbies": 0.00017762184143066406, "__label__industrial": 0.0005521774291992188, "__label__literature": 0.00021779537200927737, "__label__politics": 0.0001989603042602539, "__label__religion": 0.000514984130859375, "__label__science_tech": 0.01540374755859375, "__label__social_life": 6.395578384399414e-05, "__label__software": 0.005336761474609375, "__label__software_dev": 0.96826171875, "__label__sports_fitness": 0.0004100799560546875, "__label__transportation": 0.0005869865417480469, "__label__travel": 0.00023090839385986328}, "weborganizer_max": "__label__software_dev", "avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_ratio": [[0, 23124, 0.0253]], "fineweb_edu_fasttext_gt2__fineweb_edu_fasttext_gt2__score": [[0, 23124, 0.64071]], "ft_lang_id_en_doc_v2__ft_lang_id_en_doc_v2__en": [[0, 23124, 0.83975]], "google_gemma-3-12b-it_contains_pii": [[0, 32, false], [32, 906, null], [906, 1326, null], [1326, 1838, null], [1838, 2291, null], [2291, 2660, null], [2660, 2933, null], [2933, 3293, null], [3293, 3741, null], [3741, 4037, null], [4037, 4482, null], [4482, 5355, null], [5355, 5671, null], [5671, 5933, null], [5933, 6392, null], [6392, 6799, null], [6799, 7059, null], [7059, 7350, null], [7350, 8881, null], [8881, 9423, null], [9423, 10059, null], [10059, 10847, null], [10847, 11146, null], [11146, 11160, null], [11160, 11821, null], [11821, 12215, null], [12215, 12463, null], [12463, 13104, null], [13104, 13618, null], [13618, 13903, null], [13903, 14308, null], [14308, 14661, null], [14661, 15111, null], [15111, 15489, null], [15489, 15730, null], [15730, 16468, null], [16468, 17041, null], [17041, 17529, null], [17529, 17734, null], [17734, 18356, null], [18356, 18984, null], [18984, 19249, null], [19249, 19966, null], [19966, 20468, null], [20468, 20904, null], [20904, 20953, null], [20953, 21424, null], [21424, 22019, null], [22019, 22517, null], [22517, 23124, null]], "google_gemma-3-12b-it_is_public_document": [[0, 32, true], [32, 906, null], [906, 1326, null], [1326, 1838, null], [1838, 2291, null], [2291, 2660, null], [2660, 2933, null], [2933, 3293, null], [3293, 3741, null], [3741, 4037, null], [4037, 4482, null], [4482, 5355, null], [5355, 5671, null], [5671, 5933, null], [5933, 6392, null], [6392, 6799, null], [6799, 7059, null], [7059, 7350, null], [7350, 8881, null], [8881, 9423, null], [9423, 10059, null], [10059, 10847, null], [10847, 11146, null], [11146, 11160, null], [11160, 11821, null], [11821, 12215, null], [12215, 12463, null], [12463, 13104, null], [13104, 13618, null], [13618, 13903, null], [13903, 14308, null], [14308, 14661, null], [14661, 15111, null], [15111, 15489, null], [15489, 15730, null], [15730, 16468, null], [16468, 17041, null], [17041, 17529, null], [17529, 17734, null], [17734, 18356, null], [18356, 18984, null], [18984, 19249, null], [19249, 19966, null], [19966, 20468, null], [20468, 20904, null], [20904, 20953, null], [20953, 21424, null], [21424, 22019, null], [22019, 22517, null], [22517, 23124, null]], "google_gemma-3-4b-it_v2tag__is_academic_paper": [[0, 5000, false], [5000, 23124, null]], "google_gemma-3-4b-it_v2tag__is_class_syllabus": [[0, 5000, false], [5000, 23124, null]], "google_gemma-3-4b-it_v2tag__is_completion_certificate": [[0, 5000, false], [5000, 23124, null]], "google_gemma-3-4b-it_v2tag__is_court_notice": [[0, 5000, false], [5000, 23124, null]], "google_gemma-3-4b-it_v2tag__is_homework_assignment": [[0, 5000, false], [5000, 23124, null]], "google_gemma-3-4b-it_v2tag__is_news_article": [[0, 5000, false], [5000, 23124, null]], "google_gemma-3-4b-it_v2tag__is_public_order": [[0, 5000, false], [5000, 23124, null]], "google_gemma-3-4b-it_v2tag__is_resume_cv": [[0, 5000, false], [5000, 23124, null]], "google_gemma-3-4b-it_v2tag__is_test_or_quiz": [[0, 5000, false], [5000, 23124, null]], "google_gemma-3-4b-it_v2tag__is_textbook": [[0, 5000, false], [5000, 23124, null]], "pdf_page_numbers": [[0, 32, 1], [32, 906, 2], [906, 1326, 3], [1326, 1838, 4], [1838, 2291, 5], [2291, 2660, 6], [2660, 2933, 7], [2933, 3293, 8], [3293, 3741, 9], [3741, 4037, 10], [4037, 4482, 11], [4482, 5355, 12], [5355, 5671, 13], [5671, 5933, 14], [5933, 6392, 15], [6392, 6799, 16], [6799, 7059, 17], [7059, 7350, 18], [7350, 8881, 19], [8881, 9423, 20], [9423, 10059, 21], [10059, 10847, 22], [10847, 11146, 23], [11146, 11160, 24], [11160, 11821, 25], [11821, 12215, 26], [12215, 12463, 27], [12463, 13104, 28], [13104, 13618, 29], [13618, 13903, 30], [13903, 14308, 31], [14308, 14661, 32], [14661, 15111, 33], [15111, 15489, 34], [15489, 15730, 35], [15730, 16468, 36], [16468, 17041, 37], [17041, 17529, 38], [17529, 17734, 39], [17734, 18356, 40], [18356, 18984, 41], [18984, 19249, 42], [19249, 19966, 43], [19966, 20468, 44], [20468, 20904, 45], [20904, 20953, 46], [20953, 21424, 47], [21424, 22019, 48], [22019, 22517, 49], [22517, 23124, 50]], "pipe_delimited_lines_v1__pipe_delimited_lines_v1__pipe_delimited_lines_ratio": [[0, 23124, 0.0386]]}
olmocr_science_pdfs
2024-11-29
2024-11-29
84aba5f74afe6cf7763721ee275e301c94f95111
[REMOVED]
{"Source-Url": "http://mcs.open.ac.uk/mj665/FormalismAndIntuition.pdf", "len_cl100k_base": 6532, "olmocr-version": "0.1.49", "pdf-total-pages": 14, "total-fallback-pages": 0, "total-input-tokens": 28620, "total-output-tokens": 7976, "length": "2e12", "weborganizer": {"__label__adult": 0.0004410743713378906, "__label__art_design": 0.0006875991821289062, "__label__crime_law": 0.0003707408905029297, "__label__education_jobs": 0.002285003662109375, "__label__entertainment": 9.959936141967772e-05, "__label__fashion_beauty": 0.00020420551300048828, "__label__finance_business": 0.00031280517578125, "__label__food_dining": 0.0005521774291992188, "__label__games": 0.0006337165832519531, "__label__hardware": 0.00072479248046875, "__label__health": 0.0007839202880859375, "__label__history": 0.000370025634765625, "__label__home_hobbies": 0.000152587890625, "__label__industrial": 0.0005698204040527344, "__label__literature": 0.0015544891357421875, "__label__politics": 0.0003094673156738281, "__label__religion": 0.0008573532104492188, "__label__science_tech": 0.049041748046875, "__label__social_life": 0.0001806020736694336, "__label__software": 0.005718231201171875, "__label__software_dev": 0.9326171875, "__label__sports_fitness": 0.0003857612609863281, "__label__transportation": 0.00079345703125, "__label__travel": 0.000213623046875}, "weborganizer_max": "__label__software_dev", "avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_ratio": [[0, 37821, 0.01034]], "fineweb_edu_fasttext_gt2__fineweb_edu_fasttext_gt2__score": [[0, 37821, 0.66744]], "ft_lang_id_en_doc_v2__ft_lang_id_en_doc_v2__en": [[0, 37821, 0.9371]], "google_gemma-3-12b-it_contains_pii": [[0, 1779, false], [1779, 4960, null], [4960, 7904, null], [7904, 10902, null], [10902, 12754, null], [12754, 15723, null], [15723, 18207, null], [18207, 21339, null], [21339, 24690, null], [24690, 27749, null], [27749, 30743, null], [30743, 33779, null], [33779, 36567, null], [36567, 37821, null]], "google_gemma-3-12b-it_is_public_document": [[0, 1779, true], [1779, 4960, null], [4960, 7904, null], [7904, 10902, null], [10902, 12754, null], [12754, 15723, null], [15723, 18207, null], [18207, 21339, null], [21339, 24690, null], [24690, 27749, null], [27749, 30743, null], [30743, 33779, null], [33779, 36567, null], [36567, 37821, null]], "google_gemma-3-4b-it_v2tag__is_academic_paper": [[0, 5000, true], [5000, 37821, null]], "google_gemma-3-4b-it_v2tag__is_class_syllabus": [[0, 5000, false], [5000, 37821, null]], "google_gemma-3-4b-it_v2tag__is_completion_certificate": [[0, 5000, false], [5000, 37821, null]], "google_gemma-3-4b-it_v2tag__is_court_notice": [[0, 5000, false], [5000, 37821, null]], "google_gemma-3-4b-it_v2tag__is_homework_assignment": [[0, 5000, false], [5000, 37821, null]], "google_gemma-3-4b-it_v2tag__is_news_article": [[0, 5000, false], [5000, 37821, null]], "google_gemma-3-4b-it_v2tag__is_public_order": [[0, 5000, false], [5000, 37821, null]], "google_gemma-3-4b-it_v2tag__is_resume_cv": [[0, 5000, false], [5000, 37821, null]], "google_gemma-3-4b-it_v2tag__is_test_or_quiz": [[0, 5000, false], [5000, 37821, null]], "google_gemma-3-4b-it_v2tag__is_textbook": [[0, 5000, false], [5000, 37821, null]], "pdf_page_numbers": [[0, 1779, 1], [1779, 4960, 2], [4960, 7904, 3], [7904, 10902, 4], [10902, 12754, 5], [12754, 15723, 6], [15723, 18207, 7], [18207, 21339, 8], [21339, 24690, 9], [24690, 27749, 10], [27749, 30743, 11], [30743, 33779, 12], [33779, 36567, 13], [36567, 37821, 14]], "pipe_delimited_lines_v1__pipe_delimited_lines_v1__pipe_delimited_lines_ratio": [[0, 37821, 0.0]]}
olmocr_science_pdfs
2024-11-25
2024-11-25
dc2e028583f21c055d176920bd624086d0463a6a
REST in Practice RESTful Web Services: Principles, Patterns, Emerging Technologies Tutorial at WWW2010 [http://www2010.org/] (Raleigh, North Carolina) Erik Wilde (UC Berkeley School of Information) April 27, 2010 Contents Abstract .............................................................. 2 Precious Snowflakes .................................................. 3 RESTful "Hello World" ............................................. 4 Feeds! ................................................................. 5 Syndication ......................................................... 6 1 Syndication Formats • 1.1 RSS ■ RSS History .................................................. 9 ■ RSS 2.0 ..................................................... 10 ■ RSS 2.0 Example ........................................... 11 ■ Consuming RSS ............................................. 12 ■ RSS Political Problems .................................... 13 • 1.2 Atom ■ Atom History ............................................... 15 ■ Atom vs. RSS ............................................... 16 ■ Atom Example .............................................. 17 ■ Atom Content .............................................. 18 ■ Atom Content Examples ................................... 19 ■ Atom Categories ............................................ 20 ■ Switching from RSS to Atom .............................. 21 2 Syndication Aggregation • End-User Aggregation ...................................... 23 • Aggregation Intermediaries ................................. 24 REST’s level of abstraction and its simplicity as a small set of constraints can make it hard to get a grasp on how it can be applied for real-world projects. This presentation introduces real-world REST by looking at how REST can be used by reusing existing RESTful designs in terms of representations and interaction protocols; Atom and the Atom Publishing Protocol (AtomPub) are used as examples for existing RESTful designs. In addition, we take a brief look at how to go beyond using these “canned REST” approaches, and how existing programming framework provide support for designing and implementing RESTful services. Precious Snowflakes - Many applications are not as unique as you might think - reusing design patterns and even technologies is a good idea - avoiding reuse usually should be justified by good reasons - Take the Web's HTML as an inspiring example - HTML is not all that great as a document format - it was good enough as a container for a lot of useful content - the network effect far outweighs its functional shortcomings - could you imagine a Web based on PDF or Word? - Simplicity and wide applicability are valuable - simplicity means a lower barrier to entry - wide applicability means higher chances to create network effects RESTful “Hello World” - Internet connectivity establishes HTTP URI addressibility - host must be reachable and identifiable (DNS name or at least IP address) - HTTP server provides the uniform interface (GET only) - by default listens to incoming HTTP requests on port 80 - in simple scenarios often is configured to (also) serve static files - XML and application/xml provide a machine-readable representation ```xml <xml>Hello World</xml> ``` - Dropping the XML into the file system creates a RESTful “Hello World” service - hello-world.xml [src/hello-world.xml] - Accessible via any HTTP- and XML-capable client Information dissemination is a complex and varied problem. Feeds look at all these problems with a simple approach: - the simple approach lacks some sophistication/specialization - less specialization means wider applicability - wider applicability means bigger network effects - pull-based syndication is loosely coupled and scalable Some claim that pull publishing is bad and Publish/Subscribe (PubSub) is good: - there is little proof that this is more than just a claim - scalable PubSub is expensive to implement (but still may make sense) - PubSub may be a good idea if the requirements rule out REST Atom is a format and also an evolving landscape [http://dret.typepad.com/dretblog/atom-landscape.html] - Atom [Atom (1)], the feed format - Atom Publishing Protocol (AtomPub) [Atom Publishing Protocol (AtomPub) (1)], write access to Atom-oriented collections - support for threaded discussions in feeds - feed licensing - feed paging and archiving - many other ongoing developments [http://dret.typepad.com/dretblog/atom-landscape.html] A landscape of RESTful interactions with “collections of things” Syndication Formats RSS RSS History - "The Myth of RSS Compatibility" provides a good overview - RSS is a schoolbook example for "why standards are a good thing" - [@rss09] was created for the My Netscape portal in March 1999 - RSS 0.91 (a simplification) was introduced in July 1999 (as an interim solution) - the AOL/Netscape merger removed the format from the company's portal - RSS was without an owner, and different parties claimed/denied ownership - [@rss10] was created by an informal developer group - RSS 0.92 (and 0.93 and 0.94) were published without acknowledging RSS 1.0 - finally, RSS 2.0 was released as a follow-up to the RSS 0.9x versions - Using RSS has become an exercise in managing a menagerie of versions RSS 2.0 - RSS now means Really Simple Syndication - RSS 2.0 is the continuation of the 0.91 branch (which dropped RDF) - together with [@rss10] it is the most popular version of RSS - migration from 0.91 to 2.0 is easily possible - RSS 2.0 tries to avoid the use of XML Namespaces - RSS 2.0 is increasingly used with extensions for vendor-specific information - the RSS core is minimal, so many applications need extensions - many extensions have overlapping functionality - most extensions have unclear semantics and unclear versioning policies RSS 2.0 Example ```xml <rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"> <channel> <title>XML.com</title> <link>http://www.xml.com/</link> <description>XML.com features a rich mix of information and services for the XML community.</description> <language>en-us</language> <item> <title>Normalizing XML, Part 2</title> <link>http://www.xml.com/pub/a/2002/12/04/normalizing.html</link> <description>In this second and final look at applying relational normalization techniques to W3C XML Schema data modeling, Will Provost discusses when not to normalize, the scope of uniqueness and the fourth and fifth normal forms.</description> <dc:creator>Will Provost</dc:creator> <dc:date>2002-12-04</dc:date> </item> </channel> </rss> ``` Consuming RSS - RSS feeds often have quality problems - surprisingly often feeds do not even deliver well-formed XML - the use of embedded markup in RSS is not well-defined ("parse and pray") - Writing an RSS reader from scratch is not a good idea - There are three major tasks which RSS readers must do 1. accept non-XML RSS feeds and fix them to be XML 2. look at the feed contents and bring them into a unified form 3. produce a unified view of feeds regardless of the RSS version RSS Political Problems - Multiple and incompatible RSS History [RSS History (1)] are still in widespread use - [@rss10] and RSS 2.0 [RSS 2.0 (1)] are “incompatible by design” (RDF vs. non-RDF) - none of the RSS versions is maintained by a universally accepted standards body - None of the specifications is being updated or fixed - some of the lessons learned by RSS deployment are not used in a new version - it is unlikely that a new version will be produced which merges the RSS landscape - Invent something new instead of trying to fix RSS - Atom [Atom (1)] Started in 2003 (called Echo at first) - W3C or IETF would have been promising candidates for a “new RSS” - W3C is more formal, IETF is more developer-centered - IETF was chosen over W3C [http://www.bestkungfu.com/?p=492] because the of Atom community’s preferences Atom Atom History - RSS’s shortcomings were very apparent and could not be fixed - In mid–2003, discussions started about an improved format - It also became apparent that the format should have a protocol - Atom 0.3 was released in December 2003 but had no formal home - IETF was chosen as the new home with a working group in June 2004 - RFC 4287 [http://dret.net/rfc-index/reference/RFC4287] was published in December 2005 Atom vs. RSS - Standardized by the IETF (well-defined process) - Classification of entries (user-defined categories) - More XML-like markup design (more nesting) - Namespaces are used and supported as standard mechanism - Atom feeds must be well-formed XML (there even is a schema [http://atompub.org/2005/08/17/atom.rnc]) - Interpretation of content is well-defined (various content types) - Support for xml:lang and xml:base --- Atom Example ```xml <feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en-us"> <title>ongoing</title> <id>http://www.tbray.org/ongoing/</id> <link rel='self' href="http://www.tbray.org/ongoing/ongoing.atom"/> <updated>2007-04-11T12:55:09-07:00</updated> <author> <name>Tim Bray</name> </author> <subtitle>ongoing fragmented essay by Tim Bray</subtitle> <entry xml:base="When/200x/2007/04/02/"> <title>Atom Publishing Protocol Interop!</title> <id>http://www.tbray.org/ongoing/When/200x/2007/04/02/APP-Interop</id> <published>2007-04-02T13:00:00-07:00</published> <updated>2007-04-10T12:24:00-07:00</updated> <category scheme="http://www.tbray.org/ongoing/What/" term="Technology/Atom"/> <category scheme="http://www.tbray.org/ongoing/What/" term="Technology"/> <category scheme="http://www.tbray.org/ongoing/What/" term="Atom"/> <content type="xhtml"> <p>Mark your calendar: <a href="http://www.intertwingly.net/wiki/pie/April2007Interop">April 16-17 at Google</a>. Everybody is invited, provided they bring along an APP implementation, client or server. This was just announced a couple of days ago, and as I write this there are already six twelve client and seven fourteen server implementations signed up to be there and try to <a href="http://www.intertwingly.net/wiki/pie/InteropGrid">fill in the grid</a>. Let's drop some names, in alphabetical order: AOL, Flock, Google, IBM, Lotus, Microsoft, Oracle, O'Reilly, Six Apart, Sun, WordPress. Um, have I mentioned that the APP is going to be huge?</p> </content> </entry> </feed> ``` Atom Content - RSS had no safe way of finding out what an entry's content is - this led to different implementations being "smart" about what the RSS author really wanted - one of Atom's main goals was to improve this in a well-defined way - Atom allows escaped markup (the only way to include non-XML HTML in an XML format) - Each content element should have a type (the default is text) - Atom's content interpretation algorithm (use first applicable rule): 1. if type is text, no child elements are allowed (plain text content) 2. if type is html then RSS's method of escaped markup is used 3. if type is xhtml then there must be an div containing XHTML markup 4. if type is an XML media type then the content should be treated as this type 5. if type starts with text/ then no child elements are allowed 6. for all other values, the content must be an base64-encoded entity of the specified MIME type Atom Content Examples ```xml <content type="xhtml"> <div xmlns="http://www.w3.org/1999/xhtml"> One <strong>bold</strong> foot forward </div> </content> ``` The "atom:content" element either contains or links to the content of the entry. The content of atom:content is Language-Sensitive. ```xml <content type="html"> The `<code>atom:content</code>` element either contains or links to the content of the entry. The content of `<code>atom:content</code>` is <a href="http://www.ietf.org/rfc/rfc3066.txt">Language-Sensitive</a>. </content> ``` Atom allows to assign categories to entries: - each category element must have a term attribute for the category - an optional scheme identifies the categorization scheme (ontology, taxonomy, …) - an optional label attribute provides a human-readable label for the category AtomPub [Atom Publishing Protocol (AtomPub) (1)] defines a document format for Category Documents [Category Documents (1)] Three different cases of categorization can be distinguished: 1. use a well-known scheme (such as Dublin Core) 2. use a private but well-designed scheme (which has a URI and can be reused reliably) 3. use tags without schemes, which then are little more than content labels Switching from RSS to Atom - Generate both feeds but serve RSS with an HTTP redirect (301) - old subscribers with broken clients can still use the RSS feed - old subscribers with correct clients will use the Atom feed - Atom exposes more information than RSS (category for tags) - the mapping of publishing info to the feed has to be changed/extended - for standard metadata use Atom’s built-in metadata elements - for application-specific metadata consider reusing an existing metadata schema - Atom can be used to publish snippets as well as full content - content allows any type of content to be used and may contain a complete entry - summary allows only text and should provide a condensed version of an entry - some Atom sources publish two feeds for summaries and content - Generate good Atom and downgrade it to RSS 1.0 & 2.0 Syndication Aggregation End-User Aggregation - Users often have a small number of preferred Web sites - news can be tracked by subscribing to their feeds - this requires an feed-aware client (Firefox is not a good RSS reader) - How can users find a feed? - feeds have URIs (they are Web resources) and can be referenced from within HTML ```xml <link rel="alternate" type="application/rdf+xml" title="..." href="..." /> <link rel="alternate" type="application/rss+xml" title="..." href="..." /> <link rel="alternate" type="application/atom+xml" title="..." href="..." /> ``` Aggregation Intermediaries - RSS is a frequently used format between content providers - news agencies want to distribute news items as easy as possible - by using a single format, producers and consumers can more easily interoperate - The RSS History [RSS History (1)] caused publishers to look for something better - RSS [RSS (1)] had a head start and still is widely used - Atom [Atom (1)] is a much better format and will eventually replace RSS - User–configured portals are the merger between both scenarios 1. users select a number of feeds as their preferred information sources 2. the feeds are presented on a single personalized Web page [http://www.google.com/reader/view/] FeedBurner Fixing Feeds Diagrams: RSS 0.91, RSS 0.92, RSS2, Atom, Cleanup, Consolidate, Republish. Load Balancing Statistics/Analytics Query Capabilities - Feed technology is still evolving - Feeds are mostly viewed as ordered by time - allows optimization for accesses and caching - makes it hard to use feeds for non-timed information - Feeds could be ordered by any sort key - makes server-side feed processing much more expensive - enables customized feeds that are processed on the server-side Supporting Queryable Feeds Atom Publishing Protocol (AtomPub) RESTful Syndication - Atom is a format for retrieving a set of entries as a feed document - feeds often are time-based and are refreshed periodically or whenever needed - feeds can use any other strategy for deciding what to publish - Read-only access to feeds should be complemented by full access - full access needs the “CUD” out of the “CRUD” set of operations - many Web-centric technologies try to build on the Web's REST model of interaction - AtomPub builds on Atom and adds a RESTful protocol on top of it - POST for creating new entries (sending the request to the collection) - PUT for updating existing entries (overwriting the existing entry) - DELETE for deleting entries from a collection Collections, Members, Entries, Media - AtomPub's top-level concept is a collection - collections are used for managing and organizing members - Atom feed documents are the representation of collections - collections just exist; there is no way of interacting with them - Members of a collection can be entry and media resources - entry resources represent metadata and are represented as Atom entries - media resources can have any media type and are the data described by entries - a media link entry is an entry associated with a member ### Atom/AtomPub Data Model #### Resource HTTP Method Representation Description <table> <thead> <tr> <th>Resource</th> <th>HTTP Method</th> <th>Representation</th> <th>Description</th> </tr> </thead> <tbody> <tr> <td>Introspection</td> <td>GET</td> <td>Atom Service Document</td> <td>Enumerates a set of collections and lists their URIs and other information about the collections</td> </tr> <tr> <td>Collection</td> <td>GET</td> <td>Atom Feed</td> <td>A list of members of the collection (this may be a subset of all entries in the collection)</td> </tr> <tr> <td>Collection</td> <td>POST</td> <td>Atom Entry</td> <td>Create a new entry in the collection</td> </tr> <tr> <td>Member</td> <td>GET</td> <td>Atom Entry</td> <td>Get the Atom Entry</td> </tr> <tr> <td>Member</td> <td>PUT</td> <td>Atom Entry</td> <td>Update the Atom Entry</td> </tr> <tr> <td>Member</td> <td>DELETE</td> <td>n/a</td> <td>Delete the Atom Entry from the collection</td> </tr> </tbody> </table> Collection Management - Managing collections is outside the scope of AtomPub - AtomPub allows interactions with existing collections - Collection management is inaccessible or using a proprietary protocol - "Metacollections" (collections of collections) can extend AtomPub - each member in a metacollection corresponds with a collection - accessing a metacollection means managing collections - AtomPub's existing features can be reused for collection management - Ongoing discussion in the Atom community - currently there is no widely established method Service Documents Service Documents represent server-defined groups of Collections, and are used to initialize the process of creating and editing resources. - The "real" top-level construct of AtomPub is the workspace - collections on a server are organized into different workspaces - workspaces have no AtomPub semantics and no operations can be performed on them - Service documents list constraints on the members of collections - accept specifies a comma-separated list of media ranges (with entry as special value) - categories defines the list of categories that can be applied to members (can be fixed) - AtomPub servers are likely to reject operations not satisfying these constraints Service Document Example ```xml <service xmlns="http://purl.org/atom/app#" xmlns:atom="http://www.w3.org/2005/Atom"> <atom:title>Main Site</atom:title> <collection href="http://example.org/reilly/main"> <atom:title>My Blog Entries</atom:title> <categories href="http://example.com/cats/forMain.cats"/> </collection> <collection href="http://example.org/reilly/pic"> <atom:title>Pictures</atom:title> <accept>image/*</accept> </collection> </workspace> <workspace> <atom:title>Side Bar Blog</atom:title> <collection href="http://example.org/reilly/list"> <atom:title>Remaindered Links</atom:title> <accept>entry</accept> <categories fixed="yes"> <atom:category scheme="http://example.org/extra-cats/" term="joke"/> <atom:category scheme="http://example.org/extra-cats/" term="serious"/> </categories> </collection> </workspace> </service> ``` **Category Documents** - Categories are important for creating and reading entries - they may contain metadata using any classification scheme - Service Documents contain a list of allowed categories - AtomPub defines a document format for standalone category documents - a useful interface between AtomPub systems and other systems using classification schemes - REST makes it important to make relevant resources accessible ```xml <category term="animal"/> <category term="vegetable"/> <category term="mineral"/> </app:categories> ``` **Category Document Example** ```xml <category term="animal"/> <category term="vegetable"/> <category term="mineral"/> </app:categories> ``` Extending Atom/AtomPub Atom/AtomPub as Foundation - Atom/AtomPub can be used as a foundation - apply the methodology of RESTful Web Service Design [RESTful Web Service Design (1)] - identify missing representations/links/states - add these to the Atom/AtomPub model - Atom has a well-defined extension model (sort of) - foreign markup must be silently ignored by Atom processors - foreign markup is not allowed to change the semantics of Atom markup - every Atom extension must be well-behaving with plain Atom processors - Atom can serve as a good example for extensible markup RESTful Web Service Design - URIs are used for resource identification [What is REST?; Resource Identification (1)] - HTTP’s methods are used as the uniform interface [What is REST?; Uniform Interface (1)] - Representations [What is REST?; Self-Describing Messages (1)] can use any syntax and structure - Hypermedia [What is REST?; Hypermedia Driving Application State (1)] is based on links in representations - Use transaction resources to create stateless interactions [What is REST?; Stateless Interactions (1)] RESTful Web Service Design Procedure 1. Figure out the data set 2. Split the data set into resources 3. Name the resources with URIs [What is REST?; Resource Identification (1)] 4. Expose a subset of the uniform interface [What is REST?; Uniform Interface (1)] 5. Design the representation(s) [What is REST?; Self-Describing Messages (1)] accepted from the client 6. Design the representation(s) [What is REST?; Self-Describing Messages (1)] served to the client 7. Design hypermedia integration [What is REST?; Hypermedia Driving Application State (1)] with other resources 8. Figure out the normal control flow [What is REST?; Stateless Interactions (1)] 9. Figure out error conditions - (This is the ROA methodology) Watch Caching - Decent HTTP libraries have built-in caching - caching can also be implemented by proxies or reverse proxies - HTTP has various ways to control caching - Expires set an expiration data on a response - Cache-Control for various cache control directives - ETag for uniquely identifying a resource version - Caching allows Conditional GETs - If-Modified-Since is conditional based on the Last-Modified date - If-None-Match is conditional based on the ETag label REST Tools Toolboxes and Frameworks - Toolboxes contain a number of low-level tools - tools for essential functionality (HTTP, URI, XML) - add-ons for frequent tasks (HTML tidying, XML validation, language tag parsing) - diagnostic and test tools (HTTP monitoring, protocol validators) - Frameworks provide programming/structuring support - frameworks encourage and support a certain coding style and structure - REST focuses on exposing uniform interfaces and various media types - code should be structured by representation, not by function REST Frameworks - JAX-RS - RESTlet (covers any REST, not just RESTful HTTP) - Ruby on Rails - Django - GData Poster What is REST? From SOA to REST: Designing and Implementing RESTful Services Tutorial at WWW2009 (Madrid, Spain) Erik Wilde (UC Berkeley School of Information) April 21, 2009
{"Source-Url": "http://dret.net/netdret/docs/rest-www2010/practice.pdf", "len_cl100k_base": 5629, "olmocr-version": "0.1.50", "pdf-total-pages": 23, "total-fallback-pages": 0, "total-input-tokens": 39655, "total-output-tokens": 6887, "length": "2e12", "weborganizer": {"__label__adult": 0.00022554397583007812, "__label__art_design": 0.0003681182861328125, "__label__crime_law": 0.0001881122589111328, "__label__education_jobs": 0.0004944801330566406, "__label__entertainment": 6.198883056640625e-05, "__label__fashion_beauty": 9.483098983764648e-05, "__label__finance_business": 0.00016295909881591797, "__label__food_dining": 0.00022912025451660156, "__label__games": 0.00021970272064208984, "__label__hardware": 0.0004596710205078125, "__label__health": 0.00025582313537597656, "__label__history": 0.00020825862884521484, "__label__home_hobbies": 4.804134368896485e-05, "__label__industrial": 0.0001876354217529297, "__label__literature": 0.000194549560546875, "__label__politics": 0.00015926361083984375, "__label__religion": 0.0002968311309814453, "__label__science_tech": 0.00959014892578125, "__label__social_life": 7.349252700805664e-05, "__label__software": 0.01149749755859375, "__label__software_dev": 0.97412109375, "__label__sports_fitness": 0.00017404556274414062, "__label__transportation": 0.0002663135528564453, "__label__travel": 0.00018739700317382812}, "weborganizer_max": "__label__software_dev", "avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_ratio": [[0, 24323, 0.01712]], "fineweb_edu_fasttext_gt2__fineweb_edu_fasttext_gt2__score": [[0, 24323, 0.45074]], "ft_lang_id_en_doc_v2__ft_lang_id_en_doc_v2__en": [[0, 24323, 0.81766]], "google_gemma-3-12b-it_contains_pii": [[0, 1684, false], [1684, 2309, null], [2309, 3586, null], [3586, 4698, null], [4698, 6003, null], [6003, 7301, null], [7301, 8719, null], [8719, 10757, null], [10757, 11695, null], [11695, 12924, null], [12924, 14360, null], [14360, 15401, null], [15401, 15438, null], [15438, 15839, null], [15839, 17147, null], [17147, 17869, null], [17869, 18438, null], [18438, 20050, null], [20050, 21032, null], [21032, 22258, null], [22258, 23470, null], [23470, 24139, null], [24139, 24323, null]], "google_gemma-3-12b-it_is_public_document": [[0, 1684, true], [1684, 2309, null], [2309, 3586, null], [3586, 4698, null], [4698, 6003, null], [6003, 7301, null], [7301, 8719, null], [8719, 10757, null], [10757, 11695, null], [11695, 12924, null], [12924, 14360, null], [14360, 15401, null], [15401, 15438, null], [15438, 15839, null], [15839, 17147, null], [17147, 17869, null], [17869, 18438, null], [18438, 20050, null], [20050, 21032, null], [21032, 22258, null], [22258, 23470, null], [23470, 24139, null], [24139, 24323, null]], "google_gemma-3-4b-it_v2tag__is_academic_paper": [[0, 5000, true], [5000, 24323, null]], "google_gemma-3-4b-it_v2tag__is_class_syllabus": [[0, 5000, false], [5000, 24323, null]], "google_gemma-3-4b-it_v2tag__is_completion_certificate": [[0, 5000, false], [5000, 24323, null]], "google_gemma-3-4b-it_v2tag__is_court_notice": [[0, 5000, false], [5000, 24323, null]], "google_gemma-3-4b-it_v2tag__is_homework_assignment": [[0, 5000, false], [5000, 24323, null]], "google_gemma-3-4b-it_v2tag__is_news_article": [[0, 5000, false], [5000, 24323, null]], "google_gemma-3-4b-it_v2tag__is_public_order": [[0, 5000, false], [5000, 24323, null]], "google_gemma-3-4b-it_v2tag__is_resume_cv": [[0, 5000, false], [5000, 24323, null]], "google_gemma-3-4b-it_v2tag__is_test_or_quiz": [[0, 5000, false], [5000, 24323, null]], "google_gemma-3-4b-it_v2tag__is_textbook": [[0, 5000, false], [5000, 24323, null]], "pdf_page_numbers": [[0, 1684, 1], [1684, 2309, 2], [2309, 3586, 3], [3586, 4698, 4], [4698, 6003, 5], [6003, 7301, 6], [7301, 8719, 7], [8719, 10757, 8], [10757, 11695, 9], [11695, 12924, 10], [12924, 14360, 11], [14360, 15401, 12], [15401, 15438, 13], [15438, 15839, 14], [15839, 17147, 15], [17147, 17869, 16], [17869, 18438, 17], [18438, 20050, 18], [20050, 21032, 19], [21032, 22258, 20], [22258, 23470, 21], [23470, 24139, 22], [24139, 24323, 23]], "pipe_delimited_lines_v1__pipe_delimited_lines_v1__pipe_delimited_lines_ratio": [[0, 24323, 0.01891]]}
olmocr_science_pdfs
2024-11-29
2024-11-29
5097eb83bfcf92bf6e1fef48c84a2f0530e265ce
Kent Academic Repository Full text document (pdf) Citation for published version DOI Link to record in KAR http://kar.kent.ac.uk/30769/ Document Version Author's Accepted Manuscript Copyright & reuse Content in the Kent Academic Repository is made available for research purposes. Unless otherwise stated all content is protected by copyright and in the absence of an open licence (eg Creative Commons), permissions for further reuse of content should be sought from the publisher, author or other copyright holder. Versions of research The version in the Kent Academic Repository may differ from the final published version. Users are advised to check http://kar.kent.ac.uk for the status of the paper. Users should always cite the published version of record. Enquiries For any further enquiries regarding the licence status of this document, please contact: researchsupport@kent.ac.uk If you believe this document infringes copyright then please contact the KAR admin team with the take-down information provided at http://kar.kent.ac.uk/contact.html A Pearl on SAT Solving in Prolog (extended abstract)\footnote{The work was supported by EPSRC projects EP/E033105/1 and EP/E034519/1 and a Royal Society Industrial Fellowship. This research was conducted in part whilst the first author was on sabbatical leave at the University of St Andrews and the second author was on secondment to Portcullis Computer Security Limited} Jacob M. Howe\footnote{Department of Computing, City University London, EC1V 0HB, UK} and Andy King\footnote{School of Computing, University of Kent, Canterbury, CT2 7NF, UK} 1 Introduction The Boolean satisfiability problem, SAT, is of continuing interest because a variety of problems are naturally expressible as a SAT instance. Much effort has been expended in the development of algorithms for, and implementations of, efficient SAT solvers. This has borne fruit with a number of solvers that are either for specialised applications or are general purpose. Recently, it has been demonstrated how a dedicated external SAT solver coded in C can be integrated with Prolog \cite{1} and this has been utilised for a number of applications. This work elegantly uses of Prolog to transform propositional formulae to Conjunctive Normal Form (CNF). The work of \cite{1} begs the question of the suitability of Prolog as a medium for coding a SAT solver, either for use in a stand-alone fashion or in tandem with a constraint solver. In this abstract it is argued that a SAT solver can not only be coded in Prolog, but that this solver is a so-called natural pearl. That is, the key concepts of efficient SAT solving can be formulated in a logic program using a combination of logic and control features that lie at the heart of the logic programming paradigm. This pearl was discovered when implementing an efficient groundness analyser \cite{3}, naturally emerging from the representation of Boolean functions using logical variables. The logic and control features exemplified in this pearl are the use of logical variables, back-tracking and the suspension and resumption of execution via delay declarations. A delay declaration is a control mechanism that provides a way to delay the selection of an atom in a goal until some condition is satisfied. They provide a way to handle, for example, negated goals and non-linear constraints. Delay declarations are now an integral part of Prolog systems. This abstract demonstrates just how good the match between Prolog and SAT is, when implementing the Davis, Putnam, Logemann, Loveland (DPLL) algorithm \cite{2} with watched literals \cite{6}. Watched literals are one of the most powerful features in speeding up SAT solvers. The resulting solver is elegant and concise, coded in twenty-two lines of Prolog, it is self-contained and it is efficient enough for solving some interesting, albeit modest, SAT instances \cite{3}. The full version of this note is \cite{5}, which extends \cite{4}. 2 SAT solving This section briefly outlines the SAT problem and the DPLL algorithm \cite{2} with watched literals \cite{6} that the solver implements. The Boolean satisfiability problem is the problem of determining whether or not, for a given Boolean formula, there is a truth assignment to the variables in the formula under which the formula evaluates to true. Most recent Boolean satisfiability solvers have been based on the Davis, Putnam, Logemann, Loveland (DPLL) algorithm \cite{2}. Figure 1 presents a recursive formulation of the algorithm adapted from that given in \cite{8}. The first argument of the function DPLL is a propositional formula, \( f \), defined over a set of propositional variables \( X \). As usual \( f \) is assumed to be in CNF. The second argument, \( \theta : X \rightarrow \{true, false\} \), is a partial (truth) function. The call \( \text{DPLL}(f, \emptyset) \) decides the satisfiability of \( f \) where \( \emptyset \) denotes the empty truth function. If the call returns the special symbol \( \perp \) then \( f \) is unsatisfiable, otherwise the call returns a truth function \( \theta \) that satisfies \( f \). 2.1 Unit propagation At line (3) the function extends the truth assignment \( \theta \) to \( \theta_1 \) by applying so-called unit propagation on \( f \) and \( \theta \). For instance, suppose \( f = (\neg x \lor z) \land (u \lor \neg v \lor w) \land (\neg w \lor y \lor \neg z) \), so that \( X = \{u, v, w, x, y, z\} \) and \( \theta \) is the partial function \( \theta = \{x \mapsto true, y \mapsto false\} \). Unit propagation examines each clause in \( f \) to deduce a truth assignment \( \theta_1 \) that extends \( \theta \) and necessarily holds for \( f \) to be satisfiable. For example, for the clause \( (\neg x \lor z) \) to be satisfiable, and hence \( f \) as a whole, it is necessary that \( z \mapsto true \). Moreover, for \( (\neg w \lor y \lor \neg z) \) to be satisfiable, it follows that \( w \mapsto false \). The satisfiability of \( (u \lor \neg v \lor w) \) depends on two unknowns, \( u \) and \( v \), hence no further information can be deduced from this clause. The function \( \text{unit-propagation}(f, \theta) \) encapsulates this reasoning returning the bindings \( \{w \mapsto false, z \mapsto true\} \). Extending \( \theta \) with these necessary bindings gives \( \theta_1 \). 2.2 Watched literals Information can only be derived from a clause if it does not contain two unknowns. This is the observation behind watched literals [6], which is an implementation technique for realising unit propagation. The idea is to keep watch on a clause by monitoring only two of its unknowns. Returning to the previous example, before any variable assignment is made suitable monitors for the clause \( (u \lor \neg v \lor w) \) are the unknowns \( u \) and \( v \), suitable monitors for \( (\neg w \lor y \lor \neg z) \) are \( w \) and \( z \), and \( (\neg x \lor z) \) must have monitors \( x \) and \( z \). Note that no more than these monitors are required. When the initial empty \( \theta \) is augmented with \( x \mapsto true \), a new monitor for the third clause is not available and unit propagation immediately applies to infer \( \neg z \mapsto true \). The new binding on \( z \) is detected by the monitors on the second clause, which are then updated to be \( w \) and \( y \). If \( \theta \) is further augmented with \( y \mapsto false \), the change in \( y \) is again detected by the monitors on \( (\neg w \lor y \lor \neg z) \). This time there are no remaining unbound variables to monitor and unit propagation applies, giving the binding \( w \mapsto false \). Now notice that the first clause, \( (u \lor \neg v \lor w) \), is not monitoring w, hence no action is taken in response to the binding on w. Therefore, watched literals provide a mechanism for controlling propagation without inspecting clauses unnecessarily. 2.3 Termination and the base cases Once unit propagation has been completely applied, it remains to detect whether sufficient variables have been bound for f to be satisfiable. This is the role of the predicate is-satisfied(f, θ). This predicate returns true if every clause of f contains at least one literal that is satisfied. For example, is-satisfied(f, θ₁) = false since (u ∨ ¬v ∨ w) is not satisfied under θ₁ because u and v are unknown whereas w is bound to false. If is-satisfied(f, θ₁) were satisfied, then θ₁ could be returned to demonstrate the existence of a satisfying assignment. Conversely, a conflict can be observed when inspecting f and θ₁, from which it follows that f is unsatisfiable. To illustrate, suppose f = (¬x) ∧ (x ∨ y) ∧ (¬y) and θ = ∅. From the first and third clauses it follows that θ₁ = {x → false, y → false}. The predicate is-conflicting(f, θ) detects whether f contains a clause in which every literal is unsatisfiable. The clause (x ∨ y) satisfies this criteria under θ₁, therefore it follows that f is unsatisfiable, which is indicated by returning ⊥. 2.4 Search and the recursive cases If neither satisfiability nor unsatisfiability have been detected thus far, a variable x is selected for labelling. The DPLL algorithm is then invoked with θ₁ augmented with the new binding x → true. If satisfiability cannot be detected with this choice, DPLL is subsequently invoked with θ₁ augmented with x → false. Termination is assured because the number of unassigned variables strictly reduces on each recursive call. 3 The SAT Solver The code for the solver is given in Figure 2. It consists of just twenty-two lines of Prolog. Since a declarative description of assignment and propagation can be fully expressed in Prolog, execution can deal with all aspects of controlling the search, leading to the succinct code given. 3.1 Invoking the solver The solver is called with two arguments. The first represents a formula in CNF as a list of lists, each constituent list representing a clause. The literals of a clause are represented as pairs, Pol-Var, where Var is a logical variable and Pol is true or false, indicating that the literal has positive or negative polarity. The formula ¬x ∨ (y ∧ ¬z) would thus be represented in CNF as (¬x ∨ y) ∧ (¬x ∨ ¬z) and presented to the solver as the list Clauses = [[false-X, true-Y], [false-X, false-Z]] where X, Y and Z are logical variables. The second argument is the list of the variables occurring in the problem. Thus the query sat(Clauses, [X, Y, Z]) will succeed and bind the variables to a solution, for example, X = false, Y = true, Z = true. As a by-product, Clauses will be instantiated to [[false-false, true-true], [false-false, false-true]]. This illustrates that the interpretation of true and false in Clauses depends on whether they are left or right of the - operator: to the left they denote polarity; to the right they denote truth values. If Clauses is unsatisfiable then sat(Clauses, Vars) will fail. If necessary, the solver can be called under a double negation to check for satisfiability, whilst leaving the variables unbound. 3.2 Watched literals The solver is based on launching a watch goal for each clause that monitors two literals of that clause. Since the polarity of the literals is known, this amounts to blocking execution until one of the two uninstantiated variables occurring in the clause is bound. The watch predicate thus blocks on its first and third arguments until one of them is instantiated to a truth value. In SICStus Prolog, this requirement is stated by the declaration :- block watch(−, ?, −, ?, ?). If the sat(Clauses, Vars) :- problem_setup(Clauses), elim_var(Vars). elim_var([]). elim_var([Var | Vars]) :- elim_var(Vars), assign(Var). assign(true). assign(false). problem_setup([]). problem_setup([Clause | Clauses]) :- clause_setup(Clause), problem_setup(Clauses). clause_setup([Pol-Var | Pairs]) :- set_watch(Pairs, Var, Pol). set_watch([], Var, Pol) :- Var = Pol. set_watch([Pol2-Var2 | Pairs], Var1, Pol1):- watch(Var1, Pol1, Var2, Pol2, Pairs). :- block watch(-, ?, -, ?, ?). watch(Var1, Pol1, Var2, Pol2, Pairs) :- nonvar(Var1) -> update_watch(Var1, Pol1, Var2, Pol2, Pairs); update_watch(Var2, Pol2, Var1, Pol1, Pairs). update_watch(Var1, Pol1, Var2, Pol2, Pairs) :- Var1 == Pol1 -> true; set_watch(Pairs, Var2, Pol2). Figure 2: Code for SAT solver first argument is bound, then update_watch will diagnose what action, if any, to perform based on the polarity of the bound variable and its binding. If the polarity is positive, and the variable is bound to true, then the clause has been satisfied and no further action is required. Likewise, the clause is satisfied if the variable is false and the polarity is negative. Otherwise, the satisfiability of the clause depends on those variables of the clause which have not yet been inspected. They are considered in the subsequent call to set_watch. 3.3 Unit propagation The first clause of set_watch handles the case when there are no further variables to watch. If the remaining variable is not bound, then unit propagation occurs, assigning the variable a value that satisfies the clause. If the polarity of the variable is positive, then the variable is assigned true. Conversely, if the polarity is negative, then the variable is assigned false. A single unification is sufficient to handle both cases. If Var and Pol are not unifiable, then the bindings to Vars do not satisfy the clause, hence do not satisfy the whole CNF formula. Once problem_setup(Clauses) has launched a process for each clause in the list Clauses, elim_var(Vars) is invoked to bind each variable of Vars to a truth value. Control switches to a watch goal as soon as its first or third argument is bound. In effect, the sub-goal assign(Var) of elim_var(Vars) coroutines with the watch sub-goals of problem_setup(Clauses). Thus, for instance, elim_var(Vars) can bind a variable which transfers control to a watch goal that is waiting on that variable. This goal can, in turn, call update_watch and thus invoke set_watch, the first clause of which is responsible for unit propagation. Unit propagation can instantiate another variable, so that control is passed to another watch goal, thus leading to a sequence of bindings that emanate from a single binding in \texttt{elim-vars(Vars)}. Control will only return to \texttt{elim-var(Vars)} when unit propagation has been maximally applied. ### 3.4 Search In addition to supporting coroutining, Prolog permits a conflicting binding to be undone through backtracking. Suppose a single binding in \texttt{elim-var(Vars)} triggers a sequence of bindings to be made by the watch goals and, in doing so, the watch goals encounter a conflict: the unification \texttt{Var = Pol} in \texttt{set-watch} fails. Then backtracking will undo the original binding made in \texttt{elim-var(Vars)}, as well as the subsequent bindings made by the watch goals. The watch goals themselves are also rewound to their point of execution immediately prior to when the original binding was made in \texttt{elim-var(Vars)}. The goal \texttt{elim-var(Vars)} will then instantiate \texttt{Vars} to the next combination of truth values, which may itself cause a watch goal to be resumed, and another sequence of bindings to be made. Thus monitoring, propagation and search are seamlessly interwoven. Note that the sub-goal \texttt{assign(Var)} will attempt to assign \texttt{Var} to \texttt{true} before trying \texttt{false}, which corresponds to the down strategy in finite-domain constraint programming. Moreover, the variables \texttt{Vars} of \texttt{sat(Clauses, Vars)} are instantiated in the left-to-right order. Returning to the initial query where \texttt{Clauses = [[[false-X, true-Y], [false-X, false-Z]]]}, backtracking can enumerate all the satisfying assignments to give: \[ \begin{align*} X = \text{false}, & \quad Y = \text{true}, & \quad Z = \text{true}; & \quad X = \text{false}, & \quad Y = \text{false}, & \quad Z = \text{true}; \\ X = \text{true}, & \quad Y = \text{true}, & \quad Z = \text{false}; & \quad X = \text{false}, & \quad Y = \text{true}, & \quad Z = \text{false}; \\ X = \text{false}, & \quad Y = \text{false}, & \quad Z = \text{false}. \end{align*} \] ### 4 Extensions The full paper [5] develops the solver to provide an easy entry into SAT and SMT solving for the Prolog programmer. For instance, the solver can be enhanced with a technique to avoid replicating search when the solver is applied incrementally in conjunction with, say, learning. This dovetails with the lazy-basic instance of SMT [7] which, when applied with a technique for finding an unsatisfiable core of a system of unsatisfiable constraints, provides a neat way of realising an SMT solver. Developing [1], it is argued that Prolog also aids the translation of formulae over theory literals that involve constraints into the SMT equivalent of CNF. The full paper also discusses further extensions whilst remarking on the limitations of the solver and its approach. Finally, the solver and other related code is available at \url{www.soi.city.ac.uk/~jacob/solver/}. ### References
{"Source-Url": "https://kar.kent.ac.uk/30769/1/content.pdf", "len_cl100k_base": 4153, "olmocr-version": "0.1.50", "pdf-total-pages": 7, "total-fallback-pages": 0, "total-input-tokens": 20212, "total-output-tokens": 5097, "length": "2e12", "weborganizer": {"__label__adult": 0.00041413307189941406, "__label__art_design": 0.000278472900390625, "__label__crime_law": 0.0006003379821777344, "__label__education_jobs": 0.0016527175903320312, "__label__entertainment": 0.00010532140731811523, "__label__fashion_beauty": 0.0002034902572631836, "__label__finance_business": 0.0002803802490234375, "__label__food_dining": 0.0005517005920410156, "__label__games": 0.0010004043579101562, "__label__hardware": 0.0007457733154296875, "__label__health": 0.0008821487426757812, "__label__history": 0.0002677440643310547, "__label__home_hobbies": 0.00012433528900146484, "__label__industrial": 0.0006389617919921875, "__label__literature": 0.0005154609680175781, "__label__politics": 0.000431060791015625, "__label__religion": 0.0006766319274902344, "__label__science_tech": 0.060333251953125, "__label__social_life": 0.0001380443572998047, "__label__software": 0.00669097900390625, "__label__software_dev": 0.921875, "__label__sports_fitness": 0.0004787445068359375, "__label__transportation": 0.0006933212280273438, "__label__travel": 0.0001971721649169922}, "weborganizer_max": "__label__software_dev", "avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_ratio": [[0, 18736, 0.02468]], "fineweb_edu_fasttext_gt2__fineweb_edu_fasttext_gt2__score": [[0, 18736, 0.52817]], "ft_lang_id_en_doc_v2__ft_lang_id_en_doc_v2__en": [[0, 18736, 0.86513]], "google_gemma-3-12b-it_contains_pii": [[0, 1220, false], [1220, 4773, null], [4773, 7907, null], [7907, 11732, null], [11732, 14238, null], [14238, 18015, null], [18015, 18736, null]], "google_gemma-3-12b-it_is_public_document": [[0, 1220, true], [1220, 4773, null], [4773, 7907, null], [7907, 11732, null], [11732, 14238, null], [14238, 18015, null], [18015, 18736, null]], "google_gemma-3-4b-it_v2tag__is_academic_paper": [[0, 5000, true], [5000, 18736, null]], "google_gemma-3-4b-it_v2tag__is_class_syllabus": [[0, 5000, false], [5000, 18736, null]], "google_gemma-3-4b-it_v2tag__is_completion_certificate": [[0, 5000, false], [5000, 18736, null]], "google_gemma-3-4b-it_v2tag__is_court_notice": [[0, 5000, false], [5000, 18736, null]], "google_gemma-3-4b-it_v2tag__is_homework_assignment": [[0, 5000, false], [5000, 18736, null]], "google_gemma-3-4b-it_v2tag__is_news_article": [[0, 5000, false], [5000, 18736, null]], "google_gemma-3-4b-it_v2tag__is_public_order": [[0, 5000, false], [5000, 18736, null]], "google_gemma-3-4b-it_v2tag__is_resume_cv": [[0, 5000, false], [5000, 18736, null]], "google_gemma-3-4b-it_v2tag__is_test_or_quiz": [[0, 5000, false], [5000, 18736, null]], "google_gemma-3-4b-it_v2tag__is_textbook": [[0, 5000, false], [5000, 18736, null]], "pdf_page_numbers": [[0, 1220, 1], [1220, 4773, 2], [4773, 7907, 3], [7907, 11732, 4], [11732, 14238, 5], [14238, 18015, 6], [18015, 18736, 7]], "pipe_delimited_lines_v1__pipe_delimited_lines_v1__pipe_delimited_lines_ratio": [[0, 18736, 0.0]]}
olmocr_science_pdfs
2024-11-30
2024-11-30
5d23f4ce375edb49fa9affea423a6cba138aafc1
[REMOVED]
{"Source-Url": "https://johnwickerson.github.io/talks/expstab_talk.pdf", "len_cl100k_base": 4968, "olmocr-version": "0.1.53", "pdf-total-pages": 44, "total-fallback-pages": 0, "total-input-tokens": 70716, "total-output-tokens": 6697, "length": "2e12", "weborganizer": {"__label__adult": 0.0004148483276367187, "__label__art_design": 0.00030422210693359375, "__label__crime_law": 0.0004496574401855469, "__label__education_jobs": 0.00033211708068847656, "__label__entertainment": 5.877017974853515e-05, "__label__fashion_beauty": 0.00014317035675048828, "__label__finance_business": 0.00015616416931152344, "__label__food_dining": 0.000453948974609375, "__label__games": 0.0006079673767089844, "__label__hardware": 0.0009665489196777344, "__label__health": 0.0005674362182617188, "__label__history": 0.00019180774688720703, "__label__home_hobbies": 0.00011229515075683594, "__label__industrial": 0.0004169940948486328, "__label__literature": 0.0002363920211791992, "__label__politics": 0.0002925395965576172, "__label__religion": 0.0004954338073730469, "__label__science_tech": 0.0137481689453125, "__label__social_life": 9.465217590332033e-05, "__label__software": 0.0037174224853515625, "__label__software_dev": 0.97509765625, "__label__sports_fitness": 0.0003714561462402344, "__label__transportation": 0.0006055831909179688, "__label__travel": 0.00020635128021240232}, "weborganizer_max": "__label__software_dev", "avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_ratio": [[0, 17687, 0.00692]], "fineweb_edu_fasttext_gt2__fineweb_edu_fasttext_gt2__score": [[0, 17687, 0.27515]], "ft_lang_id_en_doc_v2__ft_lang_id_en_doc_v2__en": [[0, 17687, 0.85002]], "google_gemma-3-12b-it_contains_pii": [[0, 262, false], [262, 592, null], [592, 769, null], [769, 906, null], [906, 1707, null], [1707, 2785, null], [2785, 3086, null], [3086, 4025, null], [4025, 4824, null], [4824, 5306, null], [5306, 5636, null], [5636, 5957, null], [5957, 6527, null], [6527, 7153, null], [7153, 7709, null], [7709, 7953, null], [7953, 8142, null], [8142, 9132, null], [9132, 9155, null], [9155, 9329, null], [9329, 9960, null], [9960, 10361, null], [10361, 10583, null], [10583, 11265, null], [11265, 11363, null], [11363, 11761, null], [11761, 11857, null], [11857, 12357, null], [12357, 13422, null], [13422, 13750, null], [13750, 14139, null], [14139, 14274, null], [14274, 14624, null], [14624, 14705, null], [14705, 14774, null], [14774, 14911, null], [14911, 15344, null], [15344, 15541, null], [15541, 15810, null], [15810, 15956, null], [15956, 16237, null], [16237, 16536, null], [16536, 17365, null], [17365, 17687, null]], "google_gemma-3-12b-it_is_public_document": [[0, 262, true], [262, 592, null], [592, 769, null], [769, 906, null], [906, 1707, null], [1707, 2785, null], [2785, 3086, null], [3086, 4025, null], [4025, 4824, null], [4824, 5306, null], [5306, 5636, null], [5636, 5957, null], [5957, 6527, null], [6527, 7153, null], [7153, 7709, null], [7709, 7953, null], [7953, 8142, null], [8142, 9132, null], [9132, 9155, null], [9155, 9329, null], [9329, 9960, null], [9960, 10361, null], [10361, 10583, null], [10583, 11265, null], [11265, 11363, null], [11363, 11761, null], [11761, 11857, null], [11857, 12357, null], [12357, 13422, null], [13422, 13750, null], [13750, 14139, null], [14139, 14274, null], [14274, 14624, null], [14624, 14705, null], [14705, 14774, null], [14774, 14911, null], [14911, 15344, null], [15344, 15541, null], [15541, 15810, null], [15810, 15956, null], [15956, 16237, null], [16237, 16536, null], [16536, 17365, null], [17365, 17687, null]], "google_gemma-3-4b-it_v2tag__is_academic_paper": [[0, 5000, true], [5000, 17687, null]], "google_gemma-3-4b-it_v2tag__is_class_syllabus": [[0, 5000, false], [5000, 17687, null]], "google_gemma-3-4b-it_v2tag__is_completion_certificate": [[0, 5000, false], [5000, 17687, null]], "google_gemma-3-4b-it_v2tag__is_court_notice": [[0, 5000, false], [5000, 17687, null]], "google_gemma-3-4b-it_v2tag__is_homework_assignment": [[0, 5000, false], [5000, 17687, null]], "google_gemma-3-4b-it_v2tag__is_news_article": [[0, 5000, false], [5000, 17687, null]], "google_gemma-3-4b-it_v2tag__is_public_order": [[0, 5000, false], [5000, 17687, null]], "google_gemma-3-4b-it_v2tag__is_resume_cv": [[0, 5000, false], [5000, 17687, null]], "google_gemma-3-4b-it_v2tag__is_test_or_quiz": [[0, 5000, false], [5000, 17687, null]], "google_gemma-3-4b-it_v2tag__is_textbook": [[0, 5000, false], [5000, 17687, null]], "pdf_page_numbers": [[0, 262, 1], [262, 592, 2], [592, 769, 3], [769, 906, 4], [906, 1707, 5], [1707, 2785, 6], [2785, 3086, 7], [3086, 4025, 8], [4025, 4824, 9], [4824, 5306, 10], [5306, 5636, 11], [5636, 5957, 12], [5957, 6527, 13], [6527, 7153, 14], [7153, 7709, 15], [7709, 7953, 16], [7953, 8142, 17], [8142, 9132, 18], [9132, 9155, 19], [9155, 9329, 20], [9329, 9960, 21], [9960, 10361, 22], [10361, 10583, 23], [10583, 11265, 24], [11265, 11363, 25], [11363, 11761, 26], [11761, 11857, 27], [11857, 12357, 28], [12357, 13422, 29], [13422, 13750, 30], [13750, 14139, 31], [14139, 14274, 32], [14274, 14624, 33], [14624, 14705, 34], [14705, 14774, 35], [14774, 14911, 36], [14911, 15344, 37], [15344, 15541, 38], [15541, 15810, 39], [15810, 15956, 40], [15956, 16237, 41], [16237, 16536, 42], [16536, 17365, 43], [17365, 17687, 44]], "pipe_delimited_lines_v1__pipe_delimited_lines_v1__pipe_delimited_lines_ratio": [[0, 17687, 0.0]]}
olmocr_science_pdfs
2024-12-10
2024-12-10
0fea043e781aa8f40e14dc9d28f2db1e099c91da
Proving Reachability Properties on Term Rewriting Systems with Strategies Thomas Genet, Yann Salmon To cite this version: HAL Id: hal-01111038 https://hal.archives-ouvertes.fr/hal-01111038 Submitted on 29 Jan 2015 HAL is a multi-disciplinary open access archive for the deposit and dissemination of scientific research documents, whether they are published or not. The documents may come from teaching and research institutions in France or abroad, or from public or private research centers. L’archive ouverte pluridisciplinaire HAL, est destinée au dépôt et à la diffusion de documents scientifiques de niveau recherche, publiés ou non, émanant des établissements d’enseignement et de recherche français ou étrangers, des laboratoires publics ou privés. Proving Reachability Properties on Term Rewriting Systems with Strategies Thomas Genet and Yann Salmon IRISA, INRIA and Université Rennes 1, France Abstract. We aim at defining regular over-approximation of sets of reachable terms for term rewriting systems applied with a strategy. In this ongoing work, we focus on innermost strategies which are the evaluation strategy of most functional programming languages. Having an accurate over-approximation of reachable terms for functional programming languages would permit to prove richer unreachability properties, i.e. safety properties on such programs. 1 Introduction Term rewriting systems [BN98], TRS for short, are a convenient way of representing computer programs: a term represents the current stage of the computation and rewriting rules represent allowed steps from one stage to another. We are interested in computing the set of terms reachable by rewriting, i.e. the set \( R^*(L_0) = \{ \text{term } t \mid \exists s \in L_0, s \rightarrow_R^* t \} \), for a given finite term rewriting system \( R \) and a set of so-called initial terms \( L_0 \). Reachability properties on the TRS can be proven using a computable representation of this set or of an approximation thereof. This technique can be applied to Java programs thanks to the translation in [Boi+07] and is used in [GK00] to assess the security of some cryptographic systems. In this paper, we take much simpler examples for the sake of readability. For example, using an appropriate signature \( \Sigma \), let \( R \) be a term rewriting system defining the natural integers with constant \( 0 \) and successor \( S \), the usual arithmetical operations \( \text{sum} \) and \( \text{mult} \) as well as the \( \text{factorial} \). Let \( L_0 \) be the initial language, i.e. the set of ground terms that we consider as the starting point of our program. Continuing our example, let \( L_0 \) be the set of terms of the form \( \text{factorial}(S(S\ldots S(0)\ldots)) \). Verifying that the factorial of a natural is never zero using our formalism amounts to checking that the term \( 0 \) is not reachable from terms in \( L_0 \) by arbitrary applications of the rules in \( R \), that is \( R^*(L_0) \cap \{0\} = \emptyset \). The general TRS (un)reachability problem, “Does \( R^*(L_0) \cap L_b = \emptyset \)?”, where \( L_b \) is a set of terms considered bad, is obviously not decidable, due to the Turing-completeness of the TRS formalism. Circumventing this is usually done by working with regular languages [Com+08], for which computing the intersection and checking emptiness can be done in polynomial time. Restricting to regular initial ($L_0$) and bad languages ($L_b$) is not enough: this does not ensure that $R'(L_0)$ is regular. The regularity-preservation property of TRS is in turn undecidable [GT95]; it has been proven true for some restricted classes of TRS. For instance, Réty [RV05] computes $R_{\text{strat}}^*(L_0)$, the set of descendants of terms in $L_0$ obtained by applications of rules in $R$ using the strategy $\text{strat}$, for the restricted class of TRS called constructor-based and several $\text{strat}$. Instead of restricting the TRS classes, we focus on tree automaton completion, stemming from the work of [Gen98], and more precisely on equational completion [GR10] (or just “completion” for short). This technique aims at computing a sufficiently precise regular over-approximation $K$ of $R'(L_0)$. Since $K \supseteq R'(L_0)$, from $K \cap L_b = \emptyset$ follows $R'(L_0) \cap L_b = \emptyset$. This procedure can be applied to any left-linear TRS, but does not always terminate. Over-approximating eases termination, but it needs to be precise enough to prove unreachability properties: if $K$ is too large then we may have $K \cap L_b \neq \emptyset$ though $R'(L_0) \cap L_b = \emptyset$. Recently, many techniques for building accurate approximations have been studied: declarative language (equations) for defining approximations [GR10] and automatic approximation refinement [Bou+06; Boi+10]. However, none of those approaches takes the strategy used to apply the rules of the TRS into account: they over-approximate $R'(L_0)$ which is itself an over-approximation of $R_{\text{strat}}^*(L_0)$. This causes imprecisions when over-approximating the set of reachable terms for functional programming languages, such as OCaml [Ler+12] or those used in proof assistants like Coq [BC04] or Isabelle/HOL [NPW02]. Such functional programs can be encoded by TRS applied with a leftmost innermost strategy. Our overall objective is to take into account $\text{strat}$ in the over-approximation of $R_{\text{strat}}^*(L_0)$. This work, which is a first step in this direction, aims at taking into account the innermost part of the strategy. We want to refine the equational completion procedure of [GR10] in order to have a better precision in the over-approximation of $R_{\text{in}}^*(L_0)$, the set of descendants of terms in $L_0$ obtained by applications of rules in $R$ using an innermost strategy. At the end of the paper, we will see that the technique presented here is likely to be adapted to cover the leftmost part of the strategy, but this is ongoing work. A precise approximation of terms reachable by leftmost innermost rewriting would be a simple and elegant alternative to Higher Order Recursive Schemes used for the static analysis of functional programs [OR11]. 2 Innermost strategies In our example TRS $R$, the term $\text{mult}(S(0), \text{plus}(S(0), S(0)))$ has more than one reducible expression, or redex: it can be rewritten in one step either to the term $\text{plus}(\text{mult}(0, \text{plus}(S(0), S(0))), \text{plus}(S(0), S(0)))$, using the rule $\text{mult}(S(x), y) \rightarrow \text{plus}(\text{mult}(x, y), y)$ at the root, or to the term $\text{mult}(S(0), \text{plus}(0, S(0))))$, using the rule $\text{plus}(S(x), y) \rightarrow S(\text{plus}(x, y))$. in the appropriate subterm \( \text{plus}(S(0), S(0)) \). To consistently decide which redex to reduce, implementations of TRS can use a strategy. Innermost strategies consist in reducing a redex only when none of its strict subterms is a redex itself; in our example, this is the latter reduction. Due to some reductions being disallowed, \( R_{\text{in}}^+(L_0) \subseteq R^+(L_0) \), and very often, \( R_{\text{in}}^+(L_0) \subset R^+(L_0) \). Note that given a term \( t \), checking that each subterm of \( t \) at depth 1 is \( R \)-irreducible is sufficient to ensure that a rewriting step may be applied to \( t \) under an innermost strategy. We want to build a correct and reasonably precise over-approximation of \( R_{\text{in}}^+(L_0) \). As exposed later, the current equational completion procedure is not strategy-aware. This does not hinder correctness: \( K \supseteq R_{\text{in}}^+(L_0) \) implies \( K \supseteq R_{\text{in}}^+(L_0) \). However, the process introduces a potentially great number of terms in \( K \) that are irrelevant when we are interested in \( R_{\text{in}}^+(L_0) \). ### 3 Usual completion procedure Given a left linear TRS \( R \) over signature \( \Sigma \), the automaton completion procedure takes an automaton \( A_0 \) recognising the initial language \( L_0 \) and iteratively adds transitions to it to incorporate \( R \)-descendants of already recognised terms. It stops when (if) a fixpoint is reached: the language recognised by the produced automaton \( A^* \), \( \mathcal{L}(A^*) \), is a superset of \( L_0 \) and is \( R \)-closed, thus \( \mathcal{L}(A^*) \) is a superset of \( R^+(L_0) \). Transitions, and possibly new states, are added to the automaton \( A_i \), where \( i \) is some step of the completion process, by resolving so-called critical pairs (\( \text{CP} \)): a rule \( \ell \rightarrow r \in R \) instantiated into configurations of \( A_i \) as \( \ell \sigma \rightarrow r \sigma \), where \( \sigma \) is an arbitrary map from variables of \( \Sigma \) to states of \( A \), extended to terms like a traditional substitution and \( A_i \) recognises \( \ell \sigma \) into a state \( q \), but not \( r \sigma \). The resolution amounts to adding valid (normalised) transitions and the needed states to let the completed automaton \( A_{i+1} \) recognise \( r \sigma \) into \( q \) as well. The procedure does not always terminate, because resolution can create new critical pairs. Merging states of the automaton counters this at the cost of precision. This can be parametrised by linear equations between terms as in [GR10]. An equation \( t = s \) instantiated into configurations of \( A \) as \( t \sigma = s \sigma \) is said to be applicable if there exist two distinct states \( q_1 \) and \( q_2 \) such that \( A \) recognises \( t \sigma \) into \( q_1 \) and \( s \sigma \) into \( q_2 \). In this case, the states \( q_1 \) and \( q_2 \) are “merged”. Therefore, the equational completion procedure takes as input not only \( R \) and \( A_0 \), but a set \( E \) of such equations as well, and, in case of termination, outputs a fixpoint automaton \( A_{R,E}^* \). For example, take signature \( \Sigma = \{ f : 1, g : 1, a : 0, b : 0, c : 0 \} \) and set of variables \( \{ x \} \), \( R = \{ f(x) \rightarrow g(x), a \rightarrow b \} \), \( L_0 = \{ f(a), f(c) \} \) and \( E = \emptyset \). Note that --- 1 Given an automaton \( A \) and a state \( q \) of \( A \), we note \( \mathcal{L}(A, q) \) the set of terms recognised by \( A \) into state \( q \). g(a) \in R'(L_0) \setminus R_{in}^*(L_0). A reasonable automaton to recognise \( L_0 \) is \( A_0 \) consisting of states \( q_a, q_c, q_{fa}, q_{fc} \) and transitions \( a \mapsto q_a, c \mapsto q_c \), \( f(q_a) \mapsto q_{fa} \) and \( f(q_c) \mapsto q_{fc} \). We have a critical pair \( CP_1 = (f(x) \rightarrow g(x), \sigma = [x \mapsto q_0], q_{fa}) \): \( A_0 \) recognises \( f(q_a) \) into \( q_{fa} \) but not \( g(q_a) \). Resolving \( CP_1 \) builds a new automaton \( A_1 \) from \( A_0 \) by addition of state \( q_1 \) and transitions \( g(q_a) \mapsto q_1 \) and \( q_1 \mapsto q_{fa} \). This is shown in figure 1. The epsilon transition \( q_1 \mapsto q_{fa} \) reads no input and is oriented in this way to ensure that the right-hand side of the rule is recognised into the same state as the left-hand side was previously recognised. We also solve \( CP_2 = (a \rightarrow b, \sigma = \emptyset, q_a) \) by adding \( q_2 \) and \( b \mapsto q_2, q_2 \mapsto q_a \) and \( CP_3 = (f(x) \rightarrow g(x), \sigma = [x \mapsto q_3], q_{fc}) \) by adding \( q_3 \) and \( g(q_c) \mapsto q_3 \) and \( q_3 \mapsto q_{fc} \). In this example, there are no more critical pairs and the procedure terminates with \( A_{R,E}' = A_3 \). Assuming the same final states as in \( A_0 \), we have indeed \( \mathcal{L}(A_3) = R'(L_0) \). \[ \begin{align*} \begin{array}{c} \begin{array}{c} A_0 \\ \end{array} \end{array} & \xrightarrow{R} \begin{array}{c} \begin{array}{c} q_{fa} \mapsto \cdots \mapsto q_1 \\ A_1 \end{array} \end{array} \quad \begin{array}{c} \begin{array}{c} a \mapsto b \\ A_1 \end{array} \end{array} & \begin{array}{c} \begin{array}{c} f(q_c) \xrightarrow{R} g(q_c) \\ A_2 \\ \end{array} \end{array} \\ (a) CP_1 & (b) CP_2 & (c) CP_3 \end{align*} \] Fig. 1. Resolving critical pairs The correctness theorem of [GR10] states that under the aforementioned hypotheses, \( \mathcal{L}(A_{R,E}') \supseteq R'(\mathcal{L}(A_0)) \). The precision theorem of the same states that under the supplementary hypothesis that \( A_0 \) is consistent with \( R \) and \( E \), which merely means that the language recognised in each state of \( A_0 \) is a subset of some equivalence class of the congruence relation induced by \( E \), and has a common antecedent by \( R/E \), the "\( R \) modulo \( E \)" rewrite relation, we have \( \mathcal{L}(A_{R,E}') \subseteq (R/E)'(\mathcal{L}(A_0)) \). Our current research aims at designing a procedure to build an automaton \( A_{R,in,E}' \) such that \( \mathcal{L}(A_{R,in,E}') \subseteq (R_{in}/E)'(\mathcal{L}(A_0)) \). Left-linearity of \( R \) is required for correctness: take \( \Sigma = \{ h: 2, g: 1, a: 0 \} \), \( R = \{ h(x,x) \rightarrow g(x) \} \), i.e. a non left-linear TRS due to the presence of twice the same variable \( x \) in the left-hand side of a rule, and take \( A_0 \) with transitions \( a \mapsto q_1 \), \( a \mapsto q_2 \) and \( h(q_1,q_2) \mapsto q_f \). This last transition should intuitively give rise to a critical pair, but does not because the possible instantiations \( \ell \sigma \) of the only rule are \( h(q_1,q_1), h(q_2,q_2) \) and \( h(q_f,q_f) \). \( A_0 \) is the fix-point of the completion procedure, but \( g(a) \notin \mathcal{L}(A_0) \) while \( g(a) \in R(\{f(a,a)\}) \). 4 Current investigations The completion of some critical pairs corresponds to rewriting steps that do not conform to innermost strategies. In the example of section 3, we do not want to solve CP₁, at least not before CP₂, and even when we do, we would like to distinguish between a and b being recognised into qₐ when dealing with g(qₐ). How to determine with certainty that every term recognised in a given state is reducible by R? Indeed, if we abstain from solving a critical pair that involves a state representing at least one irreducible term, we risk missing some terms in Rₗ₀ in(L₀) and losing correctness. A first approach uses the fact that because R is left-linear, IRR(R), the set of R-normal forms, is regular [GT95, Theorem 4]. We define the fibre of a configuration c of automaton A, F(A,c), inductively: if c is a state, F(A,c) = L(A,c); if c is a constant, F(A,c) = {c}; else c = f(c₁,...,cₖ) and F(A,c) = {f(a₁,...,aₖ) | ∀i ∈ [1;k], aᵢ ∈ F(A,cᵢ)}. It is a regular language. We define a new notion of critical pair CP = (ℓ → r,σ,q) by adding the following restriction: if ℓσ is of the form f(c₁,...,cₖ) where c₁,...,cₖ are configurations, then for all i ∈ [1;k], we must have F(A,cᵢ) ∩ IRR(R) ≠ ∅. The fixpoint automaton that this new procedure produces (if any) recognises a Rₗ₀-closed language which contains L₀, and therefore contains Rₗ₀(L₀). The proof can be derived from the one of theorem 45 in [GR10]: both are based on the ability to build a critical pair from any valid rewriting step. However, since building an automaton recognising IRR(R) can be exponential in the size of R, we are also exploring a second approach that would not require IRR(R). The structure of the completed automaton can be used to distinguish between normal forms and reducible terms. On the previous example, we can infer from the automaton that a is not a normal form since it is recognised by qₐ and there is an epsilon transition q₂ → qₐ. According to completion, this epsilon transition denotes that a is reducible and we can thus mark the path a → qₐ as “forbidden” w.r.t. an innermost completion. It might be possible to check if a critical pair is innermost-compatible by carefully inspecting the recognising path of la → q. In our example, the path a → qₐ would be forbidden after completion of CP₂. Since the path g(qₐ) → q₁ → qₙₐ results from the completion of some critical pair (CP₁), a → qₐ would not be taken into account, thereby excluding g(a) from the recognised language and keeping g(b). On the other hand, the path f(qₐ) → qₙₐ does not result from a completion step, so a → qₐ would still be available in this case, causing f(a) to be recognised. This is not surprising, since it belongs to L₀, a subset of Rₗ₀(L₀). Furthermore, if a state has only forbidden paths pointing thereto, it could be completely avoided as a value when enumerating the possible σ. This approach might be useful for leftmost-innermost strategies as well, where one only reduces an innermost redex when there is no redex at its left. With Σ = {h : 2,a : 0,b : 0,c : 0,d : 0}, R = {a → b,c → d}, A = {a → qₐ,c → qₜ,h(qₐ,qₜ) → qₖ}, usual completion adds epsilon transitions qₖ → qₜ and qₜ → qₜ that cause h(a,d) → h(qₐ,d) → h(qₐ,qₜ) → h(qₐ,qₜ) → qₜ. Indeed, \( h(a,d) \in \mathcal{R}\{h(a,c)\}\), but this stems from a non-leftmost rewriting. Marking \( a \to q_a \) and \( c \to q_c \) as “forbidden” like before would allow us to disregard the aforementioned derivation, because \( q_a \) appears to the left of \( q_c \) in the configuration and the paths leading to each of them are “forbidden”. On the other hand, we would retain \( h(b,d) \to h(q_{b,d}) \) because \( q_b \), appearing to the left of \( q_c \), has a non-forbidden path from \( b \) to it. This requires more investigation, though. 5 Conclusion and perspectives We sketched a general way of refining equational completion to adapt it to innermost strategies. We have to give a precise and efficient algorithm to compute the fibre of a configuration that cleverly takes into account the fact that each completion step can modify the fibres. We also plan to assess whether our second approach is correct and to compare its efficiency with the first one, and maybe interleave them. We have to quantify the gain in precision granted by our proposed procedure and balance it with its supplementary computational cost. It should also be noted that due to our proposed strategy-aware completion procedure resolving less critical pairs than the usual one, its termination is easier to achieve. We want to explore whether this gain is marginal or not. Finally, we want to adapt the usual completion procedure to different and more expressive strategies so as to build precise over-approximation of reachable terms for other programming languages. Target strategies are the outermost strategy, used for example by Haskell [Has], and declarative strategies like the one used in Tom [Bal+07]. References
{"Source-Url": "https://hal.archives-ouvertes.fr/hal-01111038/file/GenetSalmon-IWS12.pdf", "len_cl100k_base": 5246, "olmocr-version": "0.1.49", "pdf-total-pages": 8, "total-fallback-pages": 0, "total-input-tokens": 29056, "total-output-tokens": 6651, "length": "2e12", "weborganizer": {"__label__adult": 0.0006718635559082031, "__label__art_design": 0.0005888938903808594, "__label__crime_law": 0.0008816719055175781, "__label__education_jobs": 0.0014066696166992188, "__label__entertainment": 0.00015211105346679688, "__label__fashion_beauty": 0.0003299713134765625, "__label__finance_business": 0.0004506111145019531, "__label__food_dining": 0.0008535385131835938, "__label__games": 0.0010251998901367188, "__label__hardware": 0.001445770263671875, "__label__health": 0.0024433135986328125, "__label__history": 0.0005650520324707031, "__label__home_hobbies": 0.0002295970916748047, "__label__industrial": 0.0010576248168945312, "__label__literature": 0.0008492469787597656, "__label__politics": 0.0005860328674316406, "__label__religion": 0.001102447509765625, "__label__science_tech": 0.26953125, "__label__social_life": 0.0002180337905883789, "__label__software": 0.005596160888671875, "__label__software_dev": 0.70751953125, "__label__sports_fitness": 0.0006237030029296875, "__label__transportation": 0.0013322830200195312, "__label__travel": 0.0003409385681152344}, "weborganizer_max": "__label__software_dev", "avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_ratio": [[0, 20976, 0.04529]], "fineweb_edu_fasttext_gt2__fineweb_edu_fasttext_gt2__score": [[0, 20976, 0.60997]], "ft_lang_id_en_doc_v2__ft_lang_id_en_doc_v2__en": [[0, 20976, 0.83596]], "google_gemma-3-12b-it_contains_pii": [[0, 977, false], [977, 3640, null], [3640, 6951, null], [6951, 10519, null], [10519, 13811, null], [13811, 17061, null], [17061, 19527, null], [19527, 20976, null]], "google_gemma-3-12b-it_is_public_document": [[0, 977, true], [977, 3640, null], [3640, 6951, null], [6951, 10519, null], [10519, 13811, null], [13811, 17061, null], [17061, 19527, null], [19527, 20976, null]], "google_gemma-3-4b-it_v2tag__is_academic_paper": [[0, 5000, true], [5000, 20976, null]], "google_gemma-3-4b-it_v2tag__is_class_syllabus": [[0, 5000, false], [5000, 20976, null]], "google_gemma-3-4b-it_v2tag__is_completion_certificate": [[0, 5000, false], [5000, 20976, null]], "google_gemma-3-4b-it_v2tag__is_court_notice": [[0, 5000, false], [5000, 20976, null]], "google_gemma-3-4b-it_v2tag__is_homework_assignment": [[0, 5000, false], [5000, 20976, null]], "google_gemma-3-4b-it_v2tag__is_news_article": [[0, 5000, false], [5000, 20976, null]], "google_gemma-3-4b-it_v2tag__is_public_order": [[0, 5000, false], [5000, 20976, null]], "google_gemma-3-4b-it_v2tag__is_resume_cv": [[0, 5000, false], [5000, 20976, null]], "google_gemma-3-4b-it_v2tag__is_test_or_quiz": [[0, 5000, false], [5000, 20976, null]], "google_gemma-3-4b-it_v2tag__is_textbook": [[0, 5000, false], [5000, 20976, null]], "pdf_page_numbers": [[0, 977, 1], [977, 3640, 2], [3640, 6951, 3], [6951, 10519, 4], [10519, 13811, 5], [13811, 17061, 6], [17061, 19527, 7], [19527, 20976, 8]], "pipe_delimited_lines_v1__pipe_delimited_lines_v1__pipe_delimited_lines_ratio": [[0, 20976, 0.0]]}
olmocr_science_pdfs
2024-11-24
2024-11-24
c4d85d6afb94a72ccbd6425d1e6096add6b4188c
The SYMPHONY Callable Library for Mixed-Integer Linear Programming Menal Guzelsoy and Ted Ralphs Industrial and Systems Engineering Lehigh University INFORMS Annual Meeting, San Francisco, CA, November 16, 2005 Outline of Talk • Overview of SYMPHONY • Background – Duality – Sensitivity analysis – Warm starting – Bicriteria and parametric programming • Implementation – Warm Starting – Sensitivity Analysis – Bicriteria Solve • Examples • Computational Experiments Goals of the Project • This work is part of a larger effort to develop strategies for real-time integer programming. • The goal is to make integer programming a tactical decision-making tool. • Toolbox – Sensitivity analysis – Warm starting – Parametric analysis – Heuristics – Parallel/grid/on-demand computing • The Holy Grail: Solve difficult integer programs in “real time” in the presence of uncertain data. A Brief Overview of SYMPHONY - SYMPHONY is an open-source software package for solving and analyzing mixed-integer linear programs (MILPs). - SYMPHONY can be used in three distinct modes. - **Black box solver**: Solve generic MILPs (command line or shell). - **Callable library**: Call SYMPHONY from a C/C++ code. - **Framework**: Develop a customized solver or callable library. - SYMPHONY is part of the Computational Infrastructure for Operations Research (COIN-OR) libraries ([www.coin-or.org](http://www.coin-or.org)). - New features give SYMPHONY the look and feel of an LP solver. - This talk will focus on these new features, - This talk is based on the (not officially released) SYMPHONY 5.1, available from the COIN-OR CVS server. SYMPHONY Features - Core solution methodology is *branch and cut*. - Hybrid depth-first/best-first search strategy. - Strong branching mechanism. - Primal heuristic from CBC. - Customizable through parameters and callbacks. - Cuts can be generated with COIN-ORs Cut Generation Library. - Cliques - Flow Covers - Gomory - Knapsack Cover - Lift and Project - Reduce and Split - Mixed-integer Rounding - Off Hole - Probing - Simple Rounding - Two-slope MIR - Problem-specific - User interfaces - Native C callable - Open Solver Interface C++ - FLOPC++ modeling language - MPS, AMPL/GMPL, LPFML file formats. What’s Available • Packaged releases from www.branchandcut.org • Current source at CVS on www.coin-or.org. • An extensive user’s manual on-line and in PDF. • A tutorial illustrating the development of a custom solver step by step. • Configuration and compilation files for supported architectures – Single-processor Linux, Unix, or Windows – Distributed memory parallel (PVM) – Shared memory parallel (OpenMP) • Source code for SYMPHONY solvers. - Generic MILP - Multicriteria MILP - Multicriteria Knapsack - Traveling Salesman Problem - Vehicle Routing Problem - Mixed Postman Problem - Set Partitioning Problem - Matching Problem - Network Routing Mathematical Programming Duality • For an optimization problem \[ z = \min \{ f(x) \mid x \in X \}, \] called the \textit{primal problem}, an optimization problem \[ w = \max \{ g(u) \mid u \in U \} \] such that \( w \leq z \) is called a \textit{dual problem}. • It is a \textit{strong dual} if \( w = z \). • Uses for the dual problem – Bounding – Deriving optimality conditions – Sensitivity analysis – Warm starting Duals for ILP: Previous Work • R. Gomory (and W. Baumol) ('60–'73) • G. Roodman ('72) • E. Johnson (and Burdet) ('72–'81) • R. Jeroslow (and C. Blair) ('77-'85) • A. Geoffrion and R. Nauss ('77) • D. Klein and S. Holm ('79–'84) • L. Wolsey (and L. Schrage) ('81–'84) • ... • D. Klabjan ('02) • j. Lasserre '05 Duals for Linear Optimization Problems • Let $\mathcal{P} = \{x \in \mathbb{R}^n \mid Ax = b, x \geq 0\}$ nonempty for $A \in \mathbb{Q}^{m \times n}$, $b \in \mathbb{Q}^m$. • We consider the (bounded) pure integer linear program $\min_{x \in \mathcal{P} \cap \mathbb{Z}^n} c^\top x$ for $c \in \mathbb{R}^n$. • How do we derive a dual? Consider the following more formal notion of duality for linear optimization problems (Wolsey). $$w = \max_{g : \mathbb{R}^m \to \mathbb{R}} \{g(b) \mid g(Ax) \leq c^\top x, x \geq 0\}$$ (1) $$= \max_{g : \mathbb{R}^m \to \mathbb{R}} \{g(b) \mid g(d) \leq z(d), d \in \mathbb{R}^m\},$$ (2) where $z(d) = \min_{x \in \mathcal{F}(d)} c^\top x$ is the value function and $\mathcal{F}(d) = \{x \in X \mid Ax = d, x \geq 0\}$. • If $X = \mathbb{R}^n$, then an optimal dual function is the usual LP dual. • If $X = \mathbb{Z}^n$, then an optimal dual function is more difficult to construct. Dual Solutions from Primal Algorithms • In LP, an optimal dual function arises naturally as a by-product of the simplex algorithm. • The optimal basis yields optimal primal and dual solutions and a certificate of optimality. • Sensitivity analysis and warm starting procedures for LP are based on the associated optimality conditions. • We can extend this to ILP by considering the implicit certificate of optimality associated with branch and bound. Dual Solutions for ILP from Branch and Bound - Let $\mathcal{P}_1, \ldots, \mathcal{P}_s$ be a partition of $\mathcal{P}$ into (nonempty) subpolyhedra. - Let $LP_i$ be the linear program $\min_{x^i \in \mathcal{P}_i} c^\top x^i$ associated with the subpolyhedron $\mathcal{P}_i$. - Let $B^i$ be an optimal basis for $LP_i$. - Then the following is a valid lower bound $$L = \min \{c_{B^i}(B^i)^{-1}b + \gamma_i \mid 1 \leq i \leq s\},$$ where $\gamma_i$ is the constant factor associated with the nonbasic variables fixed at nonzero bounds. - A similar function yields an upper bound. - A partition that yields equal lower and upper bounds is called an *optimal partition*. - This is the certificate constructed by branch and bound. Sensitivity Analysis - The function \[ L(d) = \min\{c_B(B^i)^{-1}d + \gamma_i \mid 1 \leq i \leq s\}, \] provides an optimal solution to (2). - The corresponding upper bounding function is \[ U(c) = \min\{c_B(B^i)^{-1}b + \beta_i \mid 1 \leq i \leq s, \hat{x}^i \in P^I\} \] - These functions can be used for local sensitivity analysis, just as one would do in linear programming. - For changes in the right-hand side, the lower bound remains valid. - For changes in the objective function, the upper bound remains valid. - One can also add cuts and variables. - One can compute an “allowable range” for changes to the instance data as the intersection of the ranges for each member of the partition. Example: Using Sensitivity Analysis - **SYMPHONY** will calculate bounds after changing the objective or right-hand side vectors. ```c int main(int argc, char **argv) { OsiSymSolverInterface si; si.parseCommandLine(argc, argv); si.loadProblem(); si.setSymParam(OsiSymSensitivityAnalysis, true); si.initialSolve(); int ind[2]; double val[2]; ind[0] = 4; val[0] = 7000; ind[1] = 7; val[1] = 6000; lb = si.getLbForNewRhs(2, ind, val); ub = si.getUbForNewRhs(2, ind, val); } ``` Limitations - The method presented only applies to pure branch and bound. - Cut generation complicates matters. - Fixing by reduced cost also complicates matters. - Have to deal with infeasibility of subproblems. - These issues can all be addressed, but the methodology is more involved. - Another issue is that the quality of the bounds may degrade quickly outside the allowable range. - Two options for getting improved bounds: - Reactive: Continue solving from a “warm start.” - Proactive: Perform a parametric analysis. Warm Starting - Why is warm starting important for ILP?? - There are many examples of algorithms that solve a sequence of related ILPs. - Decomposition algorithms - Stochastic ILP - Parametric/Multicriteria ILP - Determining irreducible inconsistent subsystem - For such problems, warm starting can potentially yield big improvements. - Warm starting is also important for performing sensitivity analysis outside of the allowable range. - What exactly does “warm starting” mean? Warm Starting Information - Most optimization algorithms can be viewed as iterative procedures for constructing a certificate of optimality, often based on duality. - By providing a candidate certificate from a previous computation, the procedure can sometimes be accelerated. - In linear programming, the initial certificate is a starting basis, which can be iteratively modified if it does not satisfy optimality conditions. - The corresponding concept in ILP is a starting partition, which yields a computable dual function. - A starting partition can be obtained from a previous branch and bound calculation. - Unlike the LP case, however, a single branch and bound tree yields a wide range of possible starting partitions. - It is not obvious which one to choose. Warm Starts for MILP - To allow resolving from a warm start, we have defined a SYMPHONY warm start class, which is derived from CoinWarmStart. - The class stores a snapshot of the search tree, with node descriptions including: - lists of active cuts and variables, - branching information, - warm start information, and - current status (candidate, fathomed, etc.). - The tree is stored in a compact form by storing the node descriptions as differences from the parent. - Other auxiliary information is also stored, such as the current incumbent. - A warm start can be saved at any time and then reloaded later. - The warm starts can also be written to and read from disk. - A global cut pool can be saved and reused if desired. Warm Starting Procedures - **After modifying parameters** - If only parameters have been modified, then the candidate list is recreated and the algorithm proceeds as if left off. - This allows parameters to be tuned as the algorithm progresses if desired. - **After modifying problem data** - Currently, we only allow modification of rim vectors. - After modification, all leaf nodes must be added to the candidate list. - After constructing the candidate list, we can continue the algorithm as before. - There are many opportunities for improving the basic scheme, especially when solving a known family of instances (**Geoffrion and Nauss**) Constructing the Warm Start - Given a branch and bound tree, any subtree can yield a starting partition. - A partition that is too fine-grained may not be useful. - The greater the change in problem data, the less useful information can be obtained from the tree. - Options for constructing a starting partition. - Take the first $n$ nodes. - Take all nodes above a given level in the tree. - Take the first $p\%$ of the nodes. - Try to construct a partition using information about how the problem was modified. Example; Using Warm Starting (Parameter Modification) - The following example shows a simple use of warm starting to create a dynamic algorithm. ```c int main(int argc, char **argv) { OsiSymSolverInterface si; si.parseCommandLine(argc, argv); si.loadProblem(); si.setSymParam(OsiSymFindFirstFeasible, true); si.setSymParam(OsiSymSearchStrategy, DEPTH_FIRST_SEARCH); si.initialSolve(); si.setSymParam(OsiSymFindFirstFeasible, false); si.setSymParam(OsiSymSearchStrategy, BEST_FIRST_SEARCH); si.resolve(); } ``` Example: Using Warm Starting (Problem Modification) - The following example shows how to warm start after problem modification. ```c int main(int argc, char **argv) { OsiSymSolverInterface si; CoinWarmStart ws; si.parseCommandLine(argc, argv); si.loadProblem(); si.setSymParam(OsiSymNodeLimit, 100); si.initialSolve(); ws = si.getWarmStart(); si.resolve(); si.setObjCoeff(0, 1); si.setObjCoeff(200, 150); si.setWarmStart(ws); si.resolve(); } ``` Example: Using Warm Starting - Applying the code from the previous slide to the MIPLIB 3 problem p0201, we obtain the results below. - Note that the warm start doesn’t reduce the number of nodes generated, but does reduce the solve time dramatically. <table> <thead> <tr> <th></th> <th>CPU Time</th> <th>Tree Nodes</th> </tr> </thead> <tbody> <tr> <td>Generate warm start</td> <td>28</td> <td>100</td> </tr> <tr> <td>Solve orig problem (from warm start)</td> <td>3</td> <td>118</td> </tr> <tr> <td>Solve mod problem (from scratch)</td> <td>24</td> <td>122</td> </tr> <tr> <td>Solve mod problem (from warm start)</td> <td>6</td> <td>198</td> </tr> </tbody> </table> Parametric Analysis - For global sensitivity analysis, we need to solve parametric programs. - SYMPHONY includes an algorithm for determining all Pareto outcomes for a bicriteria MILP. - The algorithm consists of solving a sequence of related ILPs and is asymptotically optimal. - Such an algorithm can be used to perform global sensitivity analysis by constructing a “slice” of the value function. - Warm starting can be used to improve efficiency. Example: Bicriteria ILP - Consider the following bicriteria ILP: \[ \begin{align*} \text{vmax} & \quad [8x_1, x_2] \\ \text{s.t.} & \quad 7x_1 + x_2 \leq 56 \\ & \quad 28x_1 + 9x_2 \leq 252 \\ & \quad 3x_1 + 7x_2 \leq 105 \\ & \quad x_1, x_2 \geq 0 \end{align*} \] - The following code solves this model. ```c int main(int argc, char **argv) { OsiSymSolverInterface si; si.parseCommandLine(argc, argv); si.setObj2Coeff(1, 1); si.loadProblem(); si.multiCriteriaBranchAndBound(); } ``` Example: Pareto Outcomes for Example Non-dominated Solutions Example: Bicriteria Solver - By examining the supported solutions and break points, we can easily determine $p(\theta)$, the optimal solution to the ILP with objective $8x_1 + \theta$. <table> <thead> <tr> <th>$\theta$ range</th> <th>$p(\theta)$</th> <th>$x_1^*$</th> <th>$x_2^*$</th> </tr> </thead> <tbody> <tr> <td>$(-\infty, 1.333)$</td> <td>64</td> <td>8</td> <td>0</td> </tr> <tr> <td>$(1.333, 2.667)$</td> <td>$56 + 6\theta$</td> <td>7</td> <td>6</td> </tr> <tr> <td>$(2.667, 8.000)$</td> <td>$40 + 12\theta$</td> <td>5</td> <td>12</td> </tr> <tr> <td>$(8.000, 16.000)$</td> <td>$32 + 13\theta$</td> <td>4</td> <td>13</td> </tr> <tr> <td>$(16.000, \infty)$</td> <td>$15\theta$</td> <td>0</td> <td>15</td> </tr> </tbody> </table> Example: Graph of Price Function Example: Pareto Outcomes for a Network Design Problem Using Warm Starting: Change in the Objective Function Table 1: Warm start after 1\% modification on a random subset of objective coefficients of random size. Warm start consists of nodes above the \(r\)% level of the tree, \(r \in \{0, 50, 100\}\) Using Warm Starting: Change in the Objective Function Table 2: Warm start after 10% modification on a random subset of objective coefficients of random size. Warm start consists of nodes above the $r\%$ level of the tree, $r \in \{0, 50, 100\}$ Table 3: Warm start after 20% modification on a random subset of objective coefficients of random size and use the nodes above the $r\%$ level of the tree, $r \in \{0, 50, 100\}$ Black: without warm starting White: with warm starting Table 4: Warm start after random perturbation of $+/ - 10\%$ on a random subset of objective coefficients of size $0.1n$ (left) and of size $0.2n$ (right) Using Warm Starting: Change in the Right-hand Side Table 5: Change rhs $b$ of a knapsack problem between $b/2$ and $3b/2$ and warm start using the nodes above the 25% level of the tree. Using Warm Starting: Bicriteria Optimization Table 6: Results of using warm starting to solve bicriteria optimization problems. Extensions: Reduced Cost Fixing For an ILP problem, let $f$ be a feasible subadditive dual function and let $\hat{z}^{IP}$ be an upper bound on $z^{IP}$. If $c_k - f(a_k) > 0$ and $$v = \left\lceil \frac{\hat{z}^{IP} - f(b)}{c_k - f(a_k)} \right\rceil > 0$$ for a column $k$, then there is an optimal solution $x^*$ with $x^*_k \leq v - 1$. - It is possible to obtain a feasible subadditive dual function if the problem is solved by branch and bound. - $f$ is still feasible to $\mathcal{P}(\tilde{b})$, i.e., when $b \rightarrow \tilde{b}$. - Using reduced cost fixing over this function will preprocess/tighten the variable bounds before warm starting. Extensions: Sensitivity Analysis for Branch and Cut Algorithm - We can extend Wolsey’s MILP sensitivity analysis for branch and bound algorithm to branch and cut to get a rough lower bound to modified problem with $b \rightarrow \tilde{b}$. - The algorithm basically calculates a lower bound for each tree node assuming the same tree was used to solve $\mathcal{P}(\tilde{b})$, and gathers those bounds to get a lower bound to $\mathcal{P}(\tilde{b})$. - We can get a rough lower bound for each node of the branch and cut tree and follow the rest of the algorithm. Extensions: Sensitivity Analysis for Branch and Cut Algorithm Let the LP relaxation for node $k$ be $$\mathcal{P}^t(b) = \min cx$$ s.t. $\sum_{j=1}^{n} a_j x_j \geq b \ (\gamma^k)$ $$\sum_{j=1}^{n} h_j^k x_j \geq r^k \ (\pi^k)$$ $$x \geq l^k \ (\theta^k)$$ $$-x \geq -u^k \ (\bar{\theta}^k)$$ $$x \geq 0$$ with the associated dual feasible vectors where the constraint set $\sum_{j=1}^{n} h_j^k x_j \geq r^k$ represents the cuts added so far. Extensions: Lower Bound for $\mathcal{P}^t(\tilde{b})$ Then for any feasible solution $x$ to $\mathcal{P}^t(\tilde{b})$(without the cut set): $$cx = \sum c_j x_j \geq \gamma^k \sum a_j x_j + \pi^k \sum h_j^k x_j + \sum \theta_j^k x_j - \sum \overline{\theta}_j^k x_j$$ $$\geq \gamma^k \tilde{b} + \pi^k \sum h_j^k x_j + \theta^k l^k - \overline{\theta}_j^k u^k$$ $$\geq \gamma^k \tilde{b} + \pi^k \tilde{r}^k + \theta^k l^k - \overline{\theta}_j^k u^k$$ where $$\tilde{r}^k = \sum h_j^k y_j \quad \text{and} \quad y_j = \begin{cases} \frac{l_j^k}{u_j^k} & \text{if} \quad \pi^k h_j^k \geq 0 \\ u_j^k & \text{o.w} \end{cases}$$ May be useful for the problems with bounded variables, for instance, binary problems. Is it possible to get a strong (not necessarily subadditive) dual formulation from branching on cuts tree, similar to Wolsey’s formulation for branch and bound? Conclusion - We have briefly introduced the issues surrounding \textit{warm starting} and \textit{sensitivity analysis} for integer programming. - An examination of early literature has yielded some ideas that can be useful in today’s computational environment. - We presented a new version of the SYMPHONY solver supporting warm starting and sensitivity analysis for MILPs. - This work has only scratched the surface of what can be done. - We need to learn much more about how these methods behave in practice. - In future work, we plan on refining SYMPHONY’s capabilities and employing them within a larger distributed computational framework.
{"Source-Url": "http://coral.ie.lehigh.edu/~ted/files/talks/SYMPHONY-INFORMS05.pdf", "len_cl100k_base": 5333, "olmocr-version": "0.1.53", "pdf-total-pages": 40, "total-fallback-pages": 0, "total-input-tokens": 64546, "total-output-tokens": 6912, "length": "2e12", "weborganizer": {"__label__adult": 0.00045609474182128906, "__label__art_design": 0.0004181861877441406, "__label__crime_law": 0.0008196830749511719, "__label__education_jobs": 0.0013818740844726562, "__label__entertainment": 0.00011265277862548828, "__label__fashion_beauty": 0.0002789497375488281, "__label__finance_business": 0.0009765625, "__label__food_dining": 0.0006489753723144531, "__label__games": 0.0013561248779296875, "__label__hardware": 0.00135040283203125, "__label__health": 0.0014886856079101562, "__label__history": 0.0004715919494628906, "__label__home_hobbies": 0.00019752979278564453, "__label__industrial": 0.001857757568359375, "__label__literature": 0.0002363920211791992, "__label__politics": 0.000621795654296875, "__label__religion": 0.0008039474487304688, "__label__science_tech": 0.2666015625, "__label__social_life": 0.0001832246780395508, "__label__software": 0.014495849609375, "__label__software_dev": 0.70263671875, "__label__sports_fitness": 0.0009026527404785156, "__label__transportation": 0.0014848709106445312, "__label__travel": 0.0002849102020263672}, "weborganizer_max": "__label__software_dev", "avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_ratio": [[0, 18598, 0.01627]], "fineweb_edu_fasttext_gt2__fineweb_edu_fasttext_gt2__score": [[0, 18598, 0.55576]], "ft_lang_id_en_doc_v2__ft_lang_id_en_doc_v2__en": [[0, 18598, 0.77523]], "google_gemma-3-12b-it_contains_pii": [[0, 213, false], [213, 487, null], [487, 914, null], [914, 1667, null], [1667, 2315, null], [2315, 2990, null], [2990, 3425, null], [3425, 3736, null], [3736, 4669, null], [4669, 5124, null], [5124, 5861, null], [5861, 6575, null], [6575, 7096, null], [7096, 7625, null], [7625, 8113, null], [8113, 8889, null], [8889, 9633, null], [9633, 10290, null], [10290, 10813, null], [10813, 11361, null], [11361, 11857, null], [11857, 12480, null], [12480, 12931, null], [12931, 13439, null], [13439, 13501, null], [13501, 14100, null], [14100, 14133, null], [14133, 14187, null], [14187, 14436, null], [14436, 14682, null], [14682, 14861, null], [14861, 15072, null], [15072, 15259, null], [15259, 15388, null], [15388, 16047, null], [16047, 16615, null], [16615, 17066, null], [17066, 17786, null], [17786, 17947, null], [17947, 18598, null]], "google_gemma-3-12b-it_is_public_document": [[0, 213, true], [213, 487, null], [487, 914, null], [914, 1667, null], [1667, 2315, null], [2315, 2990, null], [2990, 3425, null], [3425, 3736, null], [3736, 4669, null], [4669, 5124, null], [5124, 5861, null], [5861, 6575, null], [6575, 7096, null], [7096, 7625, null], [7625, 8113, null], [8113, 8889, null], [8889, 9633, null], [9633, 10290, null], [10290, 10813, null], [10813, 11361, null], [11361, 11857, null], [11857, 12480, null], [12480, 12931, null], [12931, 13439, null], [13439, 13501, null], [13501, 14100, null], [14100, 14133, null], [14133, 14187, null], [14187, 14436, null], [14436, 14682, null], [14682, 14861, null], [14861, 15072, null], [15072, 15259, null], [15259, 15388, null], [15388, 16047, null], [16047, 16615, null], [16615, 17066, null], [17066, 17786, null], [17786, 17947, null], [17947, 18598, null]], "google_gemma-3-4b-it_v2tag__is_academic_paper": [[0, 5000, true], [5000, 18598, null]], "google_gemma-3-4b-it_v2tag__is_class_syllabus": [[0, 5000, false], [5000, 18598, null]], "google_gemma-3-4b-it_v2tag__is_completion_certificate": [[0, 5000, false], [5000, 18598, null]], "google_gemma-3-4b-it_v2tag__is_court_notice": [[0, 5000, false], [5000, 18598, null]], "google_gemma-3-4b-it_v2tag__is_homework_assignment": [[0, 5000, false], [5000, 18598, null]], "google_gemma-3-4b-it_v2tag__is_news_article": [[0, 5000, false], [5000, 18598, null]], "google_gemma-3-4b-it_v2tag__is_public_order": [[0, 5000, false], [5000, 18598, null]], "google_gemma-3-4b-it_v2tag__is_resume_cv": [[0, 5000, false], [5000, 18598, null]], "google_gemma-3-4b-it_v2tag__is_test_or_quiz": [[0, 5000, false], [5000, 18598, null]], "google_gemma-3-4b-it_v2tag__is_textbook": [[0, 5000, false], [5000, 18598, null]], "pdf_page_numbers": [[0, 213, 1], [213, 487, 2], [487, 914, 3], [914, 1667, 4], [1667, 2315, 5], [2315, 2990, 6], [2990, 3425, 7], [3425, 3736, 8], [3736, 4669, 9], [4669, 5124, 10], [5124, 5861, 11], [5861, 6575, 12], [6575, 7096, 13], [7096, 7625, 14], [7625, 8113, 15], [8113, 8889, 16], [8889, 9633, 17], [9633, 10290, 18], [10290, 10813, 19], [10813, 11361, 20], [11361, 11857, 21], [11857, 12480, 22], [12480, 12931, 23], [12931, 13439, 24], [13439, 13501, 25], [13501, 14100, 26], [14100, 14133, 27], [14133, 14187, 28], [14187, 14436, 29], [14436, 14682, 30], [14682, 14861, 31], [14861, 15072, 32], [15072, 15259, 33], [15259, 15388, 34], [15388, 16047, 35], [16047, 16615, 36], [16615, 17066, 37], [17066, 17786, 38], [17786, 17947, 39], [17947, 18598, 40]], "pipe_delimited_lines_v1__pipe_delimited_lines_v1__pipe_delimited_lines_ratio": [[0, 18598, 0.03725]]}
olmocr_science_pdfs
2024-12-07
2024-12-07
793d7c0351c74d881a466933aaafd225288bd1b5
[REMOVED]
{"Source-Url": "https://pdfs.semanticscholar.org/17fe/c262fda15b68d7be5ae082d45d3dfc87cf33.pdf", "len_cl100k_base": 4949, "olmocr-version": "0.1.49", "pdf-total-pages": 11, "total-fallback-pages": 0, "total-input-tokens": 30685, "total-output-tokens": 6125, "length": "2e12", "weborganizer": {"__label__adult": 0.00042629241943359375, "__label__art_design": 0.0004041194915771485, "__label__crime_law": 0.0005207061767578125, "__label__education_jobs": 0.00047206878662109375, "__label__entertainment": 0.00010693073272705078, "__label__fashion_beauty": 0.00020205974578857425, "__label__finance_business": 0.00030517578125, "__label__food_dining": 0.00047206878662109375, "__label__games": 0.0006380081176757812, "__label__hardware": 0.003009796142578125, "__label__health": 0.0008530616760253906, "__label__history": 0.0003867149353027344, "__label__home_hobbies": 0.00016617774963378906, "__label__industrial": 0.0007791519165039062, "__label__literature": 0.0002598762512207031, "__label__politics": 0.0004477500915527344, "__label__religion": 0.0007238388061523438, "__label__science_tech": 0.1302490234375, "__label__social_life": 0.00010651350021362303, "__label__software": 0.00818634033203125, "__label__software_dev": 0.849609375, "__label__sports_fitness": 0.000453948974609375, "__label__transportation": 0.0010175704956054688, "__label__travel": 0.0003001689910888672}, "weborganizer_max": "__label__software_dev", "avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_ratio": [[0, 24858, 0.01576]], "fineweb_edu_fasttext_gt2__fineweb_edu_fasttext_gt2__score": [[0, 24858, 0.48463]], "ft_lang_id_en_doc_v2__ft_lang_id_en_doc_v2__en": [[0, 24858, 0.89376]], "google_gemma-3-12b-it_contains_pii": [[0, 2186, false], [2186, 5219, null], [5219, 8243, null], [8243, 10824, null], [10824, 13673, null], [13673, 16216, null], [16216, 17824, null], [17824, 19894, null], [19894, 21342, null], [21342, 24072, null], [24072, 24858, null]], "google_gemma-3-12b-it_is_public_document": [[0, 2186, true], [2186, 5219, null], [5219, 8243, null], [8243, 10824, null], [10824, 13673, null], [13673, 16216, null], [16216, 17824, null], [17824, 19894, null], [19894, 21342, null], [21342, 24072, null], [24072, 24858, null]], "google_gemma-3-4b-it_v2tag__is_academic_paper": [[0, 5000, true], [5000, 24858, null]], "google_gemma-3-4b-it_v2tag__is_class_syllabus": [[0, 5000, false], [5000, 24858, null]], "google_gemma-3-4b-it_v2tag__is_completion_certificate": [[0, 5000, false], [5000, 24858, null]], "google_gemma-3-4b-it_v2tag__is_court_notice": [[0, 5000, false], [5000, 24858, null]], "google_gemma-3-4b-it_v2tag__is_homework_assignment": [[0, 5000, false], [5000, 24858, null]], "google_gemma-3-4b-it_v2tag__is_news_article": [[0, 5000, false], [5000, 24858, null]], "google_gemma-3-4b-it_v2tag__is_public_order": [[0, 5000, false], [5000, 24858, null]], "google_gemma-3-4b-it_v2tag__is_resume_cv": [[0, 5000, false], [5000, 24858, null]], "google_gemma-3-4b-it_v2tag__is_test_or_quiz": [[0, 5000, false], [5000, 24858, null]], "google_gemma-3-4b-it_v2tag__is_textbook": [[0, 5000, false], [5000, 24858, null]], "pdf_page_numbers": [[0, 2186, 1], [2186, 5219, 2], [5219, 8243, 3], [8243, 10824, 4], [10824, 13673, 5], [13673, 16216, 6], [16216, 17824, 7], [17824, 19894, 8], [19894, 21342, 9], [21342, 24072, 10], [24072, 24858, 11]], "pipe_delimited_lines_v1__pipe_delimited_lines_v1__pipe_delimited_lines_ratio": [[0, 24858, 0.0]]}
olmocr_science_pdfs
2024-11-24
2024-11-24
863ddb46c532f59d57c8f1199b3a89025cb794cf
Web and PageRank Lecture 4 CSCI 4974/6971 12 Sep 2016 Today’s Biz 1. Review MPI 2. Reminders 3. Structure of the web 4. PageRank Centrality 5. More MPI 6. Parallel Pagerank Tutorial Today’s Biz 1. **Review MPI** 2. Reminders 3. Structure of the web 4. PageRank Centrality 5. More MPI 6. Parallel Pagerank Tutorial MPI Review - Basic functions - `MPI_Init(&argc, &argv)` - `MPI_Comm_rank(MPI_COMM_WORLD, &rank)` - `MPI_Comm_size(MPI_COMM_WORLD, &size)` - `MPI_Finalize()` - `MPI_Barrier(MPI_COMM_WORLD)` - Point to point communication - `MPI_Send(sbuf, count, MPI_TYPE, to, tag, MPI_COMM_WORLD)` - `MPI_Recv(rbuf, count, MPI_TYPE, from, tag, MPI_COMM_WORLD)` - Reductions - `MPI_Reduce(sbuf, rbuf, count, MPI_TYPE, MPI_OP, MPI_COMM_WORLD)` - `MPI_Allreduce(sbuf, rbuf, count, MPI_TYPE, MPI_OP, root, MPI_COMM_WORLD)` Today’s Biz 1. Review MPI 2. Reminders 3. Structure of the web 4. PageRank Centrality 5. More MPI 6. Parallel Pagerank Tutorial Reminders ▶ Assignment 1: Monday 19 Sept 16:00 ▶ Project Proposal: Thursday 22 Sept 16:00 ▶ Office hours: Tuesday & Wednesday 14:00-16:00 Lally 317 ▶ Or email me for other availability ▶ Class schedule (for next month): ▶ Web analysis methods ▶ Social net analysis methods ▶ Bio net analysis methods ▶ Random networks and usage Today’s Biz 1. Review MPI 2. Reminders 3. **Structure of the web** 4. PageRank Centrality 5. More MPI 6. Parallel Pagerank Tutorial Structure of the Web Slides from Jure Leskovec and Anand Rajaraman, Stanford University Webgraph structure and PageRank Two More Datasets Available - TheFind.com - Large set of products (~6GB compressed) - For each product - Attributes - Related products - Craigslist - About 3 weeks of data (~7.5GB compressed) - Text of posts, plus category metadata - e.g., match buyers and sellers How big is the Web? - Technically, infinite - Much duplication (30-40%) - Best estimate of “unique” static HTML pages comes from search engine claims - Google = 8 billion(?), Yahoo = 20 billion What is the structure of the Web? How is it organized? Web as a Graph I teach a class on Networks. Networks Course: We have a class blog Networks Class Blog: This blog post is about Microsoft Microsoft Home Page Web as a Graph - In early days of the Web links were navigational - Today many links are transactional Directed graphs - Two types of directed graphs: - DAG – directed acyclic graph: - Has no cycles: if u can reach v, then v can not reach u - Strongly connected: - Any node can reach any node via a directed path - Any directed graph can be expressed in terms of these two types Strongly connected component (SCC) is a set of nodes $S$ so that: - Every pair of nodes in $S$ can reach each other - There is no larger set containing $S$ with this property Graph structure of the Web - Take a large snapshot of the web and try to understand how it’s SCCs “fit” as a DAG. - **Computational issues:** - Say want to find SCC containing specific node $v$? - Observation: - $\text{Out}(v)$ ... nodes that can be reachable from $v$ (BFS out) - SCC containing $v$: - $= \text{Out}(v, G) \cap \text{In}(v, G)$ - $= \text{Out}(v, G) \cap \text{Out}(v, \overline{G})$ - where $\overline{G}$ is $G$ with directions of all edge flipped Graph structure of the Web - There is a giant SCC - Broder et al., 2000: - Giant weakly connected component: 90% of the nodes Bow-tie structure of the Web - 250 million webpages, 1.5 billion links [Altavista] [Broder et al., ‘00] Diameter of the Web - Diameter (average directed shortest path length) is 19 (in 1999) [Albert et al., '99] Diameter of the Web - Average distance: 75% of time there is no directed path from start to finish page - Follow in-links (directed): 16.12 - Follow out-links (directed): 16.18 - Undirected: 6.83 - Diameter of SCC (directed): - At least 28 [Broder et al., '00] Degree distribution on the Web [Broder et al., ’00] Degrees in real networks - Take real network plot a histogram of $p_k$ vs. $k$ Degrees in real networks (2) - Plot the same data on log-log axis: \[ p_k = \beta k^{-\alpha} \] \[ \log p_k = \log \beta - \alpha \log k \] Exponential tail vs. Power-law tail Power law: \[ Y \sim X^{-2} \] Exponential \[ Y \sim e^{-X} \] Power law degree exponents - Power law degree exponent is typically $2 < \alpha < 3$ - Web graph [Broder et al. 00]: - $\alpha_{in} = 2.1$, $\alpha_{out} = 2.4$ - Autonomous systems [Faloutsos et al. 99]: - $\alpha = 2.4$ - Actor collaborations [Barabasi-Albert 00]: - $\alpha = 2.3$ - Citations to papers [Redner 98]: - $\alpha \approx 3$ - Online social networks [Leskovec et al. 07]: - $\alpha \approx 2$ **Power-law network** Random network (Erdos-Renyi random graph) Degree distribution is Binomial Scale-free (power-law) network Degree distribution is Power-law Function is scale free if: \[ f(ax) = c f(x) \] Structure of the Web – Revisited Slides from Robert Meusel, Sebastiano Vigna, Oliver Lehmberg, Christian Bizer, Universität Mannheim Graph Structure in the Web Revisited Robert Meusel, Sebastiano Vigna, Oliver Lehmberg, Christian Bizer Textbook Knowledge about the Web Graph - used two AltaVista crawls (200 million pages, 1.5 billion links) - Results Power Laws ![In-degree (total, remote-only) distr.](image) - Total in-degree - Power law, exponent 2.09 - Remote-only in-degree - Power law, exponent 2.1 Bow-Tie ![Diagram of Bow-Tie structure](image) This talk will: 1. Show that the textbook knowledge might be wrong or dependent on crawling process. 2. Provide you with a large recent Web graph to do further research. Outline 1. Public Web Crawls 2. The Web Data Commons Hyperlink Graph 3. Analysis of the Graph 1. In-degree & Out-degree Distributions 2. Node Centrality 3. Strong Components 4. Bow Tie 5. Reachability and Average Shortest Path 4. Conclusion Public Web Crawls 1. AltaVista Crawl distributed by Yahoo! WebScope 2002 • Size: 1.4 billion pages • Problem: Largest strongly connected component 4% 2. ClueWeb 2009 • Size: 1 billion pages • Problem: Largest strongly connected component 3% 3. ClueWeb 2012 • Size: 733 million pages • Largest strongly connected component 76% • Problem: Only English pages Common Crawl is a non-profit foundation dedicated to building and maintaining an open crawl of the web, thereby enabling a new wave of innovation, education and research. The Common Crawl Foundation - Regularly publishes Web crawls on Amazon S3. - Five crawls available so far: <table> <thead> <tr> <th>Date</th> <th># Pages</th> </tr> </thead> <tbody> <tr> <td>2010</td> <td>2.5 billion</td> </tr> <tr> <td>Spring 2012</td> <td>3.5 billion</td> </tr> <tr> <td>Spring 2013</td> <td>2.0 billion</td> </tr> <tr> <td>Winter 2013</td> <td>2.0 billion</td> </tr> <tr> <td>Spring 2014</td> <td>2.5 billion</td> </tr> </tbody> </table> - Crawling Strategy - breadth-first visiting strategy - at least 71 million seeds from previous crawls and from Wikipedia Web Data Commons – Hyperlink Graph - extracted from the Spring 2012 version of the Common Crawl - size 3.5 billion nodes 128 billion arcs - pages originate from 43 million pay-level domains (PLDs) - 240 million PLDs were registered in 2012 * (18%) - world-wide coverage Downloading the WDC Hyperlink Graph - http://webdatacommons.org/hyperlinkgraph/ - 4 aggregation levels: <table> <thead> <tr> <th>Graph</th> <th>#Nodes</th> <th>#Arcs</th> <th>Size (zipped)</th> </tr> </thead> <tbody> <tr> <td>Page graph</td> <td>3.56 billion</td> <td>128.73 billion</td> <td>376 GB</td> </tr> <tr> <td>Subdomain graph</td> <td>101 million</td> <td>2,043 million</td> <td>10 GB</td> </tr> <tr> <td>1st level subdomain graph</td> <td>95 million</td> <td>1,937 million</td> <td>9.5 GB</td> </tr> <tr> <td>PLD graph</td> <td>43 million</td> <td>623 million</td> <td>3.1 GB</td> </tr> </tbody> </table> - Extraction code is published under Apache License - Extraction costs per run: ~ 200 US$ in Amazon EC2 fees Analysis of the Graph In-Degree Distribution Broder et al. (2000) Power law with exponent 2.1 WDC Hyperlink Graph (2012) Best power law exponent 2.24 In-Degree Distribution - Power law fitted using \texttt{plfit-tool}. - Maximum likelihood fitting. - Starting degree: 1129 - Best power law exponent: 2.24 Goodness of Fit Test - Method - $p$-value < 0.1 $\Rightarrow$ power law not a plausible hypothesis - Goodness of fit result - $p$-value = 0 - Conclusions: - in-degree does not follow power law - in-degree has non-fat heavy-tailed distribution - maybe log-normal? Out-Degree Distribution Broder et al.: Power law exponent 2.78 WDC: Best power law exponent 2.77 p-value = 0 # Node Centrality http://wwwranking.webdatacommons.org <table> <thead> <tr> <th>Harmonic centrality</th> <th>Indegree centrality</th> <th>Katz's index</th> <th>PageRank</th> </tr> </thead> <tbody> <tr> <td>1. youtube.com</td> <td>2</td> <td>2</td> <td>3</td> </tr> <tr> <td>2. en.wikipedia.org</td> <td>4</td> <td>4</td> <td>6</td> </tr> <tr> <td>3. twitter.com</td> <td>6</td> <td>6</td> <td>5</td> </tr> <tr> <td>4. google.com</td> <td>7</td> <td>7</td> <td>9</td> </tr> <tr> <td>5. wordpress.org</td> <td>1</td> <td>1</td> <td>2</td> </tr> <tr> <td>6. flickr.com</td> <td>8</td> <td>8</td> <td>14</td> </tr> <tr> <td>7. facebook.com</td> <td>19</td> <td>18</td> <td>17</td> </tr> <tr> <td>8. apple.com</td> <td>44</td> <td>35</td> <td>31</td> </tr> <tr> <td>9. vimeo.com</td> <td>17</td> <td>17</td> <td>27</td> </tr> <tr> <td>10. creativecommons.org</td> <td>16</td> <td>13</td> <td>20</td> </tr> </tbody> </table> 1 - 10 of 101717775 items 10 Per Page Page 1 of 10171778 Average Degree Broder et al. 2000: \(7.5\) WDC 2012: \(36.8\) \(\Rightarrow\) Factor 4.9 larger Possible explanation: HTML templates of CMS Strongly Connected Components Calculated using WebGraph framework on a machine with 1 TB RAM. Largest SCC - Broder: 27.7% - WDC: 51.3 % \( \Rightarrow \) Factor 1.8 larger The Bow-Tie Structure of Broder et al. 2000 - Balanced size of IN and OUT: 21% - Size of LSCC: 27% The Bow-Tie Structure of WDC Hyperlinkgraph 2012 - IN much larger than OUT: 31% vs. 6% - LSCC much larger: 51% The Chinese web looks like a tea-pot. Reachability and Average Shortest Path Broder et al. 2000 - Pairs of pages connected by path: 25% - Average shortest path: 16.12 WDC Webgraph 2012 - Pairs of pages connected by path: 48% - Average shortest path: 12.84 Conclusions 1. Web has become more dense and more connected - Average degree has grown significantly in last 13 years (factor 5) - Connectivity between pairs of pages has doubled 2. Macroscopic structure - There is large SCC of growing size. - The shape of the bow-tie seems to depend on the crawl 3. In- and out-degree distributions do not follow power laws. Today’s Biz 1. Review MPI 2. Reminders 3. Structure of the web 4. PageRank Centrality 5. More MPI 6. Parallel Pagerank Tutorial PageRank Centrality Slides from Fei Li, University of Michigan The PageRank Citation Ranking: Bring Order to the web - Lawrence Page, Sergey Brin, Rajeev Motwani and Terry Winograd - Presented by Fei Li Motivation and Introduction Why is Page Importance Rating important? • Huge number of web pages: 150 million by 1998 1000 billion by 2008 • Diversity of web pages: different topics, different quality, etc. What is PageRank? • A method for rating the importance of web pages objectively and mechanically using the link structure of the web. The History of PageRank PageRank was developed by Larry Page (hence the name *Page-Rank*) and Sergey Brin. It is first as part of a research project about a new kind of search engine. That project started in 1995 and led to a functional prototype in 1998. Shortly after, Page and Brin founded Google. 16 billion… Recent News There are some news about that PageRank will be canceled by Google. There are large numbers of Search Engine Optimization (SEO). SEO use different trick methods to make a web page more important under the rating of PageRank. Link Structure of the Web 150 million web pages $\rightarrow$ 1.7 billion links Backlinks and Forward links: - A and B are C’s backlinks - C is A and B’s forward link Intuitively, a webpage is important if it has a lot of backlinks. What if a webpage has only one link to www.yahoo.com? A Simple Version of PageRank \[ R(u) = c \sum_{v \in B_u} \frac{R(v)}{N_v} \] - \( u \): a web page - \( B_u \): the set of \( u \)'s backlinks - \( N_v \): the number of forward links of page \( v \) - \( c \): the normalization factor to make \( \|R\|_{L1} = 1 \) (\( \|R\|_{L1} = |R_1 + \ldots + R_n| \)) An example of Simplified PageRank PageRank Calculation: first iteration \[ \begin{bmatrix} 1/3 \\ 1/2 \\ 1/6 \end{bmatrix} = \begin{bmatrix} 1/2 & 1/2 & 0 \\ 1/2 & 0 & 1 \\ 0 & 1/2 & 0 \end{bmatrix} \begin{bmatrix} 1/3 \\ 1/3 \\ 1/3 \end{bmatrix} \] PageRank Calculation: rst iteration An example of Simplified PageRank PageRank Calculation: second iteration PageRank Calculation: second iteration An example of Simplified PageRank Convergence after some iterations A Problem with Simplified PageRank A loop: During each iteration, the loop accumulates rank but never distributes rank to other pages! An example of the Problem $$M = \begin{bmatrix} 1/2 & 1/2 & 0 \\ 1/2 & 0 & 0 \\ 0 & 1/2 & 1 \end{bmatrix}$$ $$\begin{bmatrix} \text{yahoo} \\ \text{Amazon} \\ \text{Microsoft} \end{bmatrix} = \begin{bmatrix} 1/3 \\ 1/3 \\ 1/3 \end{bmatrix}$$ $$\begin{bmatrix} 1/3 \\ 1/6 \\ 1/2 \end{bmatrix} = \begin{bmatrix} 1/2 & 1/2 & 0 \\ 1/2 & 0 & 0 \\ 0 & 1/2 & 1 \end{bmatrix} \begin{bmatrix} 1/3 \\ 1/3 \\ 1/3 \end{bmatrix}$$ An example of the Problem \[ M = \begin{bmatrix} \frac{1}{2} & \frac{1}{2} & 0 \\ \frac{1}{2} & 0 & 0 \\ 0 & \frac{1}{2} & 1 \end{bmatrix} \] \[ \begin{bmatrix} \text{yahoo} \\ \text{Amazon} \\ \text{Microsoft} \end{bmatrix} = \begin{bmatrix} 1/3 \\ 1/3 \\ 1/3 \end{bmatrix} \] \[ \begin{bmatrix} \frac{1}{4} \\ \frac{1}{6} \\ \frac{7}{12} \end{bmatrix} = \begin{bmatrix} \frac{1}{2} & \frac{1}{2} & 0 \\ \frac{1}{2} & 0 & 0 \\ 0 & \frac{1}{2} & 1 \end{bmatrix} \begin{bmatrix} \frac{1}{3} \\ \frac{1}{6} \\ \frac{1}{2} \end{bmatrix} \] An example of the Problem \[ M = \begin{bmatrix} 1/2 & 1/2 & 0 \\ 1/2 & 0 & 0 \\ 0 & 1/2 & 1 \end{bmatrix} \] \[ \begin{bmatrix} \text{yahoo} \\ \text{Amazon} \\ \text{Microsoft} \end{bmatrix} = \begin{bmatrix} 1/3 \\ 1/3 \\ 1/3 \end{bmatrix} \] \[ \begin{bmatrix} 5/24 & 1/6 & ... & 0 \\ 1/8 & 5/48 & ... & 0 \\ 2/3 & 35/48 & ... & 1 \end{bmatrix} \] Random Walks in Graphs - The Random Surfer Model - The simplified model: the standing probability distribution of a random walk on the graph of the web. simply keeps clicking successive links at random - The Modified Model - The modified model: the “random surfer” simply keeps clicking successive links at random, but periodically “gets bored” and jumps to a random page based on the distribution of E Modified Version of PageRank \[ R'(u) = c_1 \sum_{v \in B_u} \frac{R'(v)}{N_v} + c_2 E(u) \] E(u): a distribution of ranks of web pages that “users” jump to when they “gets bored” after successive links at random. An example of Modified PageRank \[ M = \begin{bmatrix} \frac{1}{2} & \frac{1}{2} & 0 \\ \frac{1}{2} & 0 & 0 \\ 0 & \frac{1}{2} & 1 \end{bmatrix} \] \[ \begin{bmatrix} yahoo \\ Amazon \\ Microsoft \end{bmatrix} = \begin{bmatrix} \frac{1}{3} \\ \frac{1}{3} \\ \frac{1}{3} \end{bmatrix} \] \[ C_1 = 0.8 \quad C_2 = 0.2 \] \[ \begin{bmatrix} 0.333 & 0.333 & 0.280 & 0.259 & 7/33 \\ 0.333 & 0.200 & 0.200 & 0.179 & 5/33 \\ 0.333 & 0.467 & 0.520 & 0.563 & 21/33 \end{bmatrix} \] Dangling Links - Links that point to any page with no outgoing links - Most are pages that have not been downloaded yet - Affect the model since it is not clear where their weight should be distributed - Do not affect the ranking of any other page directly - Can be simply removed before pagerank calculation and added back afterwards PageRank Implementation - Convert each URL into a unique integer and store each hyperlink in a database using the integer IDs to identify pages - Sort the link structure by ID - Remove all the dangling links from the database - Make an initial assignment of ranks and start iteration - Choosing a good initial assignment can speed up the pagerank - Adding the dangling links back. Convergence Property - PR (322 Million Links): 52 iterations - PR (161 Million Links): 45 iterations - Scaling factor is roughly linear in $\log n$ Convergence Property The Web is an expander-like graph - Theory of random walk: a random walk on a graph is said to be rapidly-mixing if it quickly converges to a limiting distribution on the set of nodes in the graph. A random walk is rapidly-mixing on a graph if and only if the graph is an expander graph. - Expander graph: every subset of nodes S has a neighborhood (set of vertices accessible via outedges emanating from nodes in S) that is larger than some factor $\alpha$ times of $|S|$. A graph has a good expansion factor if and only if the largest eigenvalue is sufficiently larger than the second-largest eigenvalue. Today’s Biz 1. Review MPI 2. Reminders 3. Structure of the web 4. PageRank Centrality 5. More MPI 6. Parallel Pagerank Tutorial More MPI Slides from David Cronk, University of Tennessee MPI_Allgather (sbuf, scount, stype, rbuf, rcount, rtype, comm, ierr) All arguments are meaningful at every process. Data from sbuf at all processes in group A is concatenated in rank order and the result is stored at rbuf of every process in group B and vice-versa. Send arguments in A must be consistent with receive arguments in B, and vice-versa. MPI_Alltoall (sbuff, scount, stype, rbuf, rcount, rtype, comm, ierr) Result is as if each process in group A scatters its \textit{sbuff} to each process in group B and each process in group B scatters its \textit{sbuff} to each process in group A. Data is gathered in \textit{rbuf} in rank order according to the rank in the group providing the data. Each process in group A sends the same amount of data to group B and vice-versa. Today’s Biz 1. Review MPI 2. Reminders 3. Structure of the web 4. PageRank Centrality 5. More MPI 6. **Parallel Pagerank Tutorial** Parallel Pagerank Tutorial 1. Serial 2. OpenMP 3. MPI 4. More advanced (if time) Parallel PageRank Tutorial Blank code and data available on website www.cs.rpi.edu/~slotag/classes/FA16/index.html
{"Source-Url": "http://www.cs.rpi.edu/~slotag/classes/FA16/slides/lec04-web1.pdf", "len_cl100k_base": 5861, "olmocr-version": "0.1.50", "pdf-total-pages": 80, "total-fallback-pages": 0, "total-input-tokens": 109020, "total-output-tokens": 8848, "length": "2e12", "weborganizer": {"__label__adult": 0.0004363059997558594, "__label__art_design": 0.000896453857421875, "__label__crime_law": 0.0006952285766601562, "__label__education_jobs": 0.09075927734375, "__label__entertainment": 0.0003361701965332031, "__label__fashion_beauty": 0.0002853870391845703, "__label__finance_business": 0.0012159347534179688, "__label__food_dining": 0.0006356239318847656, "__label__games": 0.0009551048278808594, "__label__hardware": 0.0015726089477539062, "__label__health": 0.001018524169921875, "__label__history": 0.0010280609130859375, "__label__home_hobbies": 0.00033020973205566406, "__label__industrial": 0.0007810592651367188, "__label__literature": 0.0013589859008789062, "__label__politics": 0.0005917549133300781, "__label__religion": 0.0007343292236328125, "__label__science_tech": 0.2919921875, "__label__social_life": 0.0008149147033691406, "__label__software": 0.0897216796875, "__label__software_dev": 0.51220703125, "__label__sports_fitness": 0.000377655029296875, "__label__transportation": 0.0007824897766113281, "__label__travel": 0.0004367828369140625}, "weborganizer_max": "__label__software_dev", "avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_ratio": [[0, 18682, 0.04742]], "fineweb_edu_fasttext_gt2__fineweb_edu_fasttext_gt2__score": [[0, 18682, 0.36246]], "ft_lang_id_en_doc_v2__ft_lang_id_en_doc_v2__en": [[0, 18682, 0.71285]], "google_gemma-3-12b-it_contains_pii": [[0, 56, false], [56, 185, null], [185, 318, null], [318, 841, null], [841, 970, null], [970, 1309, null], [1309, 1442, null], [1442, 1531, null], [1531, 1563, null], [1563, 1851, null], [1851, 2104, null], [2104, 2265, null], [2265, 2369, null], [2369, 2659, null], [2659, 2835, null], [2835, 3332, null], [3332, 3461, null], [3461, 3567, null], [3567, 3677, null], [3677, 3951, null], [3951, 4004, null], [4004, 4084, null], [4084, 4228, null], [4228, 4331, null], [4331, 4770, null], [4770, 4983, null], [4983, 5117, null], [5117, 5221, null], [5221, 5598, null], [5598, 5770, null], [5770, 6027, null], [6027, 6407, null], [6407, 6578, null], [6578, 7034, null], [7034, 7377, null], [7377, 8042, null], [8042, 8064, null], [8064, 8194, null], [8194, 8350, null], [8350, 8707, null], [8707, 8819, null], [8819, 9779, null], [9779, 9923, null], [9923, 10098, null], [10098, 10198, null], [10198, 10310, null], [10310, 10348, null], [10348, 10568, null], [10568, 10943, null], [10943, 11072, null], [11072, 11136, null], [11136, 11278, null], [11278, 11688, null], [11688, 12005, null], [12005, 12245, null], [12245, 12536, null], [12536, 12846, null], [12846, 13135, null], [13135, 13249, null], [13249, 13318, null], [13318, 13455, null], [13455, 13876, null], [13876, 14416, null], [14416, 14771, null], [14771, 15180, null], [15180, 15396, null], [15396, 15877, null], [15877, 16213, null], [16213, 16597, null], [16597, 16746, null], [16746, 17377, null], [17377, 17506, null], [17506, 17565, null], [17565, 17918, null], [17918, 17918, null], [17918, 18353, null], [18353, 18353, null], [18353, 18486, null], [18486, 18568, null], [18568, 18682, null]], "google_gemma-3-12b-it_is_public_document": [[0, 56, true], [56, 185, null], [185, 318, null], [318, 841, null], [841, 970, null], [970, 1309, null], [1309, 1442, null], [1442, 1531, null], [1531, 1563, null], [1563, 1851, null], [1851, 2104, null], [2104, 2265, null], [2265, 2369, null], [2369, 2659, null], [2659, 2835, null], [2835, 3332, null], [3332, 3461, null], [3461, 3567, null], [3567, 3677, null], [3677, 3951, null], [3951, 4004, null], [4004, 4084, null], [4084, 4228, null], [4228, 4331, null], [4331, 4770, null], [4770, 4983, null], [4983, 5117, null], [5117, 5221, null], [5221, 5598, null], [5598, 5770, null], [5770, 6027, null], [6027, 6407, null], [6407, 6578, null], [6578, 7034, null], [7034, 7377, null], [7377, 8042, null], [8042, 8064, null], [8064, 8194, null], [8194, 8350, null], [8350, 8707, null], [8707, 8819, null], [8819, 9779, null], [9779, 9923, null], [9923, 10098, null], [10098, 10198, null], [10198, 10310, null], [10310, 10348, null], [10348, 10568, null], [10568, 10943, null], [10943, 11072, null], [11072, 11136, null], [11136, 11278, null], [11278, 11688, null], [11688, 12005, null], [12005, 12245, null], [12245, 12536, null], [12536, 12846, null], [12846, 13135, null], [13135, 13249, null], [13249, 13318, null], [13318, 13455, null], [13455, 13876, null], [13876, 14416, null], [14416, 14771, null], [14771, 15180, null], [15180, 15396, null], [15396, 15877, null], [15877, 16213, null], [16213, 16597, null], [16597, 16746, null], [16746, 17377, null], [17377, 17506, null], [17506, 17565, null], [17565, 17918, null], [17918, 17918, null], [17918, 18353, null], [18353, 18353, null], [18353, 18486, null], [18486, 18568, null], [18568, 18682, null]], "google_gemma-3-4b-it_v2tag__is_academic_paper": [[0, 5000, true], [5000, 18682, null]], "google_gemma-3-4b-it_v2tag__is_class_syllabus": [[0, 5000, false], [5000, 18682, null]], "google_gemma-3-4b-it_v2tag__is_completion_certificate": [[0, 5000, false], [5000, 18682, null]], "google_gemma-3-4b-it_v2tag__is_court_notice": [[0, 5000, false], [5000, 18682, null]], "google_gemma-3-4b-it_v2tag__is_homework_assignment": [[0, 5000, true], [5000, 18682, null]], "google_gemma-3-4b-it_v2tag__is_news_article": [[0, 5000, false], [5000, 18682, null]], "google_gemma-3-4b-it_v2tag__is_public_order": [[0, 5000, false], [5000, 18682, null]], "google_gemma-3-4b-it_v2tag__is_resume_cv": [[0, 5000, false], [5000, 18682, null]], "google_gemma-3-4b-it_v2tag__is_test_or_quiz": [[0, 5000, false], [5000, 18682, null]], "google_gemma-3-4b-it_v2tag__is_textbook": [[0, 5000, false], [5000, 18682, null]], "pdf_page_numbers": [[0, 56, 1], [56, 185, 2], [185, 318, 3], [318, 841, 4], [841, 970, 5], [970, 1309, 6], [1309, 1442, 7], [1442, 1531, 8], [1531, 1563, 9], [1563, 1851, 10], [1851, 2104, 11], [2104, 2265, 12], [2265, 2369, 13], [2369, 2659, 14], [2659, 2835, 15], [2835, 3332, 16], [3332, 3461, 17], [3461, 3567, 18], [3567, 3677, 19], [3677, 3951, 20], [3951, 4004, 21], [4004, 4084, 22], [4084, 4228, 23], [4228, 4331, 24], [4331, 4770, 25], [4770, 4983, 26], [4983, 5117, 27], [5117, 5221, 28], [5221, 5598, 29], [5598, 5770, 30], [5770, 6027, 31], [6027, 6407, 32], [6407, 6578, 33], [6578, 7034, 34], [7034, 7377, 35], [7377, 8042, 36], [8042, 8064, 37], [8064, 8194, 38], [8194, 8350, 39], [8350, 8707, 40], [8707, 8819, 41], [8819, 9779, 42], [9779, 9923, 43], [9923, 10098, 44], [10098, 10198, 45], [10198, 10310, 46], [10310, 10348, 47], [10348, 10568, 48], [10568, 10943, 49], [10943, 11072, 50], [11072, 11136, 51], [11136, 11278, 52], [11278, 11688, 53], [11688, 12005, 54], [12005, 12245, 55], [12245, 12536, 56], [12536, 12846, 57], [12846, 13135, 58], [13135, 13249, 59], [13249, 13318, 60], [13318, 13455, 61], [13455, 13876, 62], [13876, 14416, 63], [14416, 14771, 64], [14771, 15180, 65], [15180, 15396, 66], [15396, 15877, 67], [15877, 16213, 68], [16213, 16597, 69], [16597, 16746, 70], [16746, 17377, 71], [17377, 17506, 72], [17506, 17565, 73], [17565, 17918, 74], [17918, 17918, 75], [17918, 18353, 76], [18353, 18353, 77], [18353, 18486, 78], [18486, 18568, 79], [18568, 18682, 80]], "pipe_delimited_lines_v1__pipe_delimited_lines_v1__pipe_delimited_lines_ratio": [[0, 18682, 0.05263]]}
olmocr_science_pdfs
2024-11-30
2024-11-30
c77106de97b08434878992c55d0907df53f93927
Termination We need methods to check termination of an equational theory \((\Sigma, E)\). For unconditional equations \(E\) this means proving that the rewriting relation \(\rightarrow_E\) (or, more generally, \(\rightarrow_{E/B}\) for \((\Sigma, E \cup B)\)) is well-founded. The key observation is that, if we exhibit a well-founded ordering \(>\) on terms such that \[ (\spadesuit) \quad t \rightarrow_E t' \quad \Rightarrow \quad t > t', \] then we have obviously proved termination, since nontermination of \(\rightarrow_E\) would make the order \(>\) non-well-founded. To show (♣) we need to consider an, infinite number of rewrites \( t \rightarrow_E t' \). We would like to reduce this problem to checking (♣) only for the equations in \( E \). We need: **Definition:** A well-founded ordering \( > \) on \( \cup_{s \in S} T_\Sigma(V) \) is called a **reduction ordering** iff it satisfies the following two conditions: - **strict \( \Sigma \)-monotonicity:** for each \( f \in \Sigma \), whenever \( f(t_1, \ldots, t_n), f(t_1, \ldots, t_{i-1}, t'_i, t_{i+1}, \ldots, t_n) \in T_\Sigma(V) \) with \( t_i > t'_i \), we have, \[ f(t_1, \ldots, t_n) > f(t_1, \ldots, t_{i-1}, t'_i, t_{i+1}, \ldots, t_n) \] - **closure under substitution:** if \( t > t' \), then, for any substitution \( \theta : V \rightarrow T_\Sigma(V) \) we have, \( t\theta > t'\theta \). **Theorem:** Let \((\Sigma, E)\) be an (unconditional) equational theory. Then, \(E\) is terminating iff there exists a reduction order \(>\) such that for each equation \(u = v\) in \(E\) we have, \(u > v\). **Proof:** The \((\Rightarrow)\) part follows from the observation that, if \(E\) is terminating, the transitive closure \(\xrightarrow{+} E\) of the relation \(\xrightarrow{E}\) is a reduction order satisfying this requirement. To see \((\Leftarrow)\), it is enough to show that a reduction order with the above property satisfies the implication \((\clubsuit)\). Let \(t \xrightarrow{E} t'\) this means that there is a position \(\pi\) in \(t\), an equation \(u = v\) in \(E\), and a substitution \(\theta\) such that \(t = t[\pi \leftarrow \overline{\theta}(u)]\), and \(t' = t[\pi \leftarrow \overline{\theta}(v)]\). But by closure under substitution we have, \(\overline{\theta}(u) > \overline{\theta}(v)\) and by repeated application of strict \(\Sigma\)-monotonicity we then have, \(t > t'\). q.e.d. Polynomial Orderings We are still left with the task of defining suitable reduction orderings. There are several general ways of defining such orderings. One general method is based on polynomial orderings. In its simplest form we can just use polynomials on several variables whose coefficients are natural numbers. For example, \[ p = 7x_1^3x_2 + 4x_2^2x_3 + 6x_3^2 + 5x_1 + 2x_2 + 11 \] is one such polynomial. Note that a polynomial \( p \) whose biggest indexed variable is \( n \) (in the above example \( n = 3 \)) defines a function \( p_{\mathbb{N}_+} : \mathbb{N}_+^n \rightarrow \mathbb{N}_+ \), just by evaluating the polynomial on a given tuple of positive numbers. For \( p \) the polynomial above we have for example, \( p_{\mathbb{N}_+}(1, 1, 1) = 35 \). Note also that we can order the set $\mathbb{N}^n_+$ of functions from $\mathbb{N}^n_+$ to $\mathbb{N}_+$ by defining $f > g$ iff for each $(a_1, \ldots a_n) \in \mathbb{N}^n_+$ $f(a_1, \ldots a_n) > g(a_1, \ldots a_n)$. Notice that this order is well-founded, since if we have an infinite descending chain of functions $$f_1 > f_2 > \ldots f_n > \ldots$$ by choosing any $(a_1, \ldots a_n) \in \mathbb{N}^n_+$ we would get a descending chain of positive numbers $$f_1(a_1, \ldots a_n) > f_2(a_1, \ldots a_n) > \ldots f_n(a_1, \ldots a_n) > \ldots$$ which is impossible. The method of polynomial orderings then consists in assigning to each function symbol $f : s_1 \ldots s_n \rightarrow s$ in $\Sigma$ a polynomial $p_f$ involving exactly the variables $x_1, \ldots x_n$ (all of them, and only them must appear in $p_f$). If $f$ is subsort overloaded, we assign the same $p_f$ to all such overloading. Also, to each constant symbol $b$ we likewise associate a positive number $p_b \in \mathbb{N}_+$. Suppose, to simplify notation, that in our set $E$ of equations we have used exactly $k$ different variables, denoted $x_1, \ldots x_k$, each declared with its corresponding sort. Let us denote $X = \{x_1, \ldots x_k\}$. Then our assignment of a polynomial to each function symbol and a number to each constant extends to an $S$-sorted family of functions Polynomial Orderings (IV) \[ p_- : T_{\Sigma(X)} \rightarrow \mathbb{N}[X] \] where \( \mathbb{N}[X] \) denotes the polynomials with natural number coefficients in the variables \( X \), and where \( p_- \) is defined in the obvious, homomorphic way: - \( p_b = p_b \) - \( p_{x_i} = x_i \) - \( p_f(t_1, \ldots, t_n) = p_f(x_1/p_{t_1}, \ldots, x_n/p_{t_n}) \) Note that the polynomial interpretation $p$ induces a well-founded ordering $>_p$ on the terms of $T_{\Sigma(X)}$ as follows: $$t >_p t' \iff p_{t_{\mathbb{N}^+}} > p_{t'_{\mathbb{N}^+}}$$ where if $X = \{x_1, \ldots, x_k\}$, we interpret $p_{t_{\mathbb{N}^+}}$ and $p_{t'_{\mathbb{N}^+}}$ as functions in $\mathbb{N}^k_{+\mathbb{N}}$. The relation $>_p$ is clearly an irreflexive and transitive relation on terms in $T_{\Sigma(X)}$, therefore a strict ordering, and is clearly well-founded, because otherwise we would have an infinite descending chain of polynomial functions in $\mathbb{N}^k_{+\mathbb{N}}$, which is impossible. We now need to check that this ordering is furthermore: (i) strictly $\Sigma$-monotonic, and (ii) closed under substitution. Condition (i) follows easily from the fact that for each function symbol $f : s_1 \ldots s_n \rightarrow s$ in $\Sigma$ $p_f$ involves exactly the variables $x_1, \ldots x_n$ and has all its coefficients in $\mathbb{N}_+$. Therefore, $p_{f_{\mathbb{N}_+}}$, viewed as a function of $n$ arguments, is strictly monotonic in each of its arguments. Condition (ii) follows from the following general property of the $p_-$ function, which is left as an exercise: $$p_t(x_1/u_1, \ldots, x_n/u_n) = p_t(x_1/p_{u_1}, \ldots, x_n/p_{u_n}).$$ This then easily yields that if $t >_p t'$ then $$t(x_1/u_1, \ldots, x_n/u_n) >_p t'(x_1/u_1, \ldots, x_n/u_n),$$ as desired. Therefore, polynomial interpretations of this kind define reduction orderings and can be used to prove termination. Consider for example the single equation $f(g(x)) = g(f(x))$ in an unsorted signature having also a constant $a$. Is this equation terminating? We can prove that it is so by the following polynomial interpretation: - $p_f = x_1^3$ - $p_g = 2x_1$ - $p_a = 1$ since we have the following strict inequality of functions: $((2x)^3)_{\mathbb{N}_+} > (2(x^3))_{\mathbb{N}_+}$, showing that $f(g(x)) >_p g(f(x))$. A second class of reduction orderings are based on the idea of defining such orderings from some **minimal information** such as giving an ordering on the function symbols in $\Sigma$, which is then extended to a reduction ordering on all terms. Since if $\Sigma$ is finite the number of possible orderings between function symbols in $\Sigma$ is also finite, checking whether a proof of termination exists this way can be **automated**. One such method is the **lexicographic path ordering**. The intuitive idea that functions that are more complex should be bigger in the ordering (for example: $\_\times\_ > \_+\_ > s$) tends to work quite well, and can yield a reduction ordering containing the equations. But since there is a finite number of possible orderings, a tool can try them all. The Lexicographic Path Ordering (II) **Definition:** Given a finite signature $\Sigma$ an an ordering $>$ of its symbols, then the lexicographic path ordering $>_{lpo}$ on $\bigcup_{s \in S} T_{\Sigma}(V)$ is defined recursively as follows: - if $x \in \text{vars}(t)$ and $x \neq t$, then $t >_{lpo} x$. - $f(t_1, \ldots, t_n) >_{lpo} g(t'_1, \ldots, t'_m)$ if either: - for some $i$, $t_i >_{lpo} g(t'_1, \ldots, t'_m)$, or - $f > g$ and $f(t_1, \ldots, t_n) >_{lpo} t'_j$, for all $j$, or - $f = g$, $f(t_1, \ldots, t_n) >_{lpo} t'_j$, for all $j$, and there exist an $i$, $1 \leq i \leq n$, such that, $t_j = t'_j$, $1 \leq j < i$, and $t_i >_{lpo} t'_i$. The Lexicographic Path Ordering (III) It can be shown (for a detailed proof see the book by Baader and Nipkow cited later) that for a finite signature $\Sigma$ LPO is a reduction order. We can therefore use it to prove termination. Consider for example the usual equations for natural number addition: $n + 0 = n$ and $n + s(m) = s(n + m)$. We can prove that they are terminating by using the LPO associated to the ordering $+ > s > 0$. Indeed, it is then trivial to check that $n + 0 >_{lpo} n$ and $n + s(m) >_{lpo} s(n + m)$. Since when rewriting modulo axioms we are rewriting equivalence classes, some orderings may not be appropriate, because they may give different results on different representatives of the equivalence class. For example, the lexicographic path order may lead to such conflicts, because of the strict left-to-right order used on the list of subterms, violated by commutativity. What we need is an order compatible with the axioms, so that it defines also an order on the set, $\cup_{s \in S} T_{\Sigma/A}(X)$. Such orders do exist. For example, an order treating the subterms as a multiset, instead than as a list, may be compatible with a commutativity axiom. Some polynomial interpretations may also be compatible with certain axioms. For example, a symmetric polynomial such that \( p(x, y) = p(y, x) \) is compatible with commutativity and can therefore be used to interpret a commutative symbol. For example, \( 2x^3 + 2y^3 \) is symmetric. Similarly, a polynomial \( p(x, y) \) which is symmetric (\( p(x, y) = p(y, x) \)) and furthermore satisfies the associativity equation \[ p(x, p(y, z)) = p(p(x, y), z) \] can be used to interpret an associative-commutative symbol. As shown by Bencherifff and Lescanne the polynomials satisfying these two conditions have a simple characterization: they must be of the form \( axy + b(x + y) + c \) with \( ac + b - b^2 = 0 \). The Maude Termination Tool (MTT) is a tool that can be used to prove the operational termination of Maude functional modules. In general, such modules can be conditional and may be not just order-sorted, but membership equational theories. They may involve axioms like associativity and commutativity; and they may also have evaluation strategies (see Maude 2.2 manual, Section 4.4.7) indicating what arguments of a function symbol should be evaluated before applying equations for that symbol. For example, in an `if_then_else_fi` the first argument should be evaluated before equations for it are applied; and in a “lazy list cons” `_;_` the first argument is evaluated, but not the second. Features such as sorts, subsorts, memberships, and evaluation strategies may be essential for the termination of a Maude module. That is, ignoring them may result in a nonterminating module. To preserve these features somehow, while still allowing using standard termination backend tools, the MTT implements the transformations of \((\Sigma, E)\) first into an unsorted conditional theory \((\Sigma^\circ, E^\circ)\), and then \((\Sigma^\circ, E^\circ)\) is transformed into an unsorted unconditional theory \((\Sigma^\bullet, E^\bullet)\). If the module declares evaluation strategies, they are also transformed; but at the end evaluation strategies can either be used directly by a termination tool like Mu-Term, or a further theory transformation can eliminate such strategies. The course web page indicates where MTT has been installed. By typing: `./MTT` and carriage return the tool’s GUI comes up and the user can interact with it. By using the File menu one can enter a Maude module into the tool. Once a Maude module (enclosed in parentheses, and not importing any built-in modules) has been entered, the user can perform the theory transformation \((\Sigma, E) \mapsto (\Sigma^\bullet, E^\bullet)\) in one of three increasingly simpler modes: (1) **Complete**; (2) **No Kinds**; and (3) **No Sorts**. In case (2) kinds are ignored; and in case (3) both kinds and sorts are ignored. There is a tradeoff between simplicity of the transformation and its tightness. Sometimes a simpler transformation works better, and sometimes a more complete one is essentially needed. The choice of transformation can be made by clicking the appropriate buttons (a screenshot will show this). But one also needs to choose which backend termination tool for unsorted and unconditional specifications will be used. One among the CiME, MU-TERM, and AProVE termination tools can be chosen. Then one can click on the Check bar to check the specification with the chosen tool. Some of these tools offer choices for different settings. So, we can try to prove termination using three different transformation variants, and then with one of three backend tools, sometimes customizing the particular tool choices. This maximizes the chances of obtaining a successful termination proof. The MTT Tool (V) What the tool then demonstrates is that the original Maude functional module is operationally terminating. The correctness of such a proof is based on: - the correctness of the theory transformations (see paper in course web page); and - the correctness of the chosen tools, that sometimes output a justification of how they proved termination. A screenshot of a tool interaction is given in the next page. (fmod PEANO is sort Nat . op 0 : Nat -> Nat [ctor]. op s : Nat -> Nat [ctor]. op plus : Nat Nat -> Nat . vars M N : Nat . eq plus(M, s(N)) = s(plus(M, N)) . eq plus(M, 0) = M op times : Nat Nat -> Nat . eq times(M, s(N)) = plus(times(M, N), M) . eq times(M, 0) = 0 . endfm) We obtain no new DP problems. Termination of R successfully shown. Duration: 0:00 minutes All the termination tools try to prove that a set of equations $E$, conditional or unconditional, is terminating by applying different proof methods; for example by trying to see if particular orderings can be used to prove the equations terminating. But these termination proof methods are not decision procedures: in general termination of a set of equations (even if they are unconditional) is undecidable. However, termination is decidable for finite sets of unconditional equations $E$ such that both the lefthand and the righthand sides are ground terms, or even if just the righthand sides are ground terms (see Chapter 5 in Baader and Nipkow, “Term Rewriting and All That”, Cambridge U.P.). Where to Go from Here Besides lexicographic path ordering there are many other ordering that can be used to prove termination. Two good sources, with references to the general literature, are: Furthermore, the Ölveczky lecture notes contain a very good introduction to termination with many examples.
{"Source-Url": "https://courses.engr.illinois.edu/cs476/lecture_notes/lec08_sep_17.pdf", "len_cl100k_base": 4222, "olmocr-version": "0.1.53", "pdf-total-pages": 24, "total-fallback-pages": 0, "total-input-tokens": 43138, "total-output-tokens": 5309, "length": "2e12", "weborganizer": {"__label__adult": 0.0004298686981201172, "__label__art_design": 0.0005893707275390625, "__label__crime_law": 0.0005817413330078125, "__label__education_jobs": 0.0023670196533203125, "__label__entertainment": 0.00020992755889892575, "__label__fashion_beauty": 0.0002219676971435547, "__label__finance_business": 0.000385284423828125, "__label__food_dining": 0.000644683837890625, "__label__games": 0.0010776519775390625, "__label__hardware": 0.001346588134765625, "__label__health": 0.001071929931640625, "__label__history": 0.0004320144653320313, "__label__home_hobbies": 0.0002560615539550781, "__label__industrial": 0.0010194778442382812, "__label__literature": 0.0009675025939941406, "__label__politics": 0.0005197525024414062, "__label__religion": 0.0009093284606933594, "__label__science_tech": 0.330810546875, "__label__social_life": 0.0002238750457763672, "__label__software": 0.00945281982421875, "__label__software_dev": 0.64501953125, "__label__sports_fitness": 0.0004091262817382813, "__label__transportation": 0.0009255409240722656, "__label__travel": 0.0002294778823852539}, "weborganizer_max": "__label__software_dev", "avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_ratio": [[0, 15232, 0.01701]], "fineweb_edu_fasttext_gt2__fineweb_edu_fasttext_gt2__score": [[0, 15232, 0.75326]], "ft_lang_id_en_doc_v2__ft_lang_id_en_doc_v2__en": [[0, 15232, 0.82513]], "google_gemma-3-12b-it_contains_pii": [[0, 0, null], [0, 579, false], [579, 1381, null], [1381, 2399, null], [2399, 3173, null], [3173, 3748, null], [3748, 4537, null], [4537, 4901, null], [4901, 5534, null], [5534, 6321, null], [6321, 6847, null], [6847, 7641, null], [7641, 8312, null], [8312, 8844, null], [8844, 9504, null], [9504, 10219, null], [10219, 10913, null], [10913, 11697, null], [11697, 12495, null], [12495, 13188, null], [13188, 13616, null], [13616, 14005, null], [14005, 14705, null], [14705, 15232, null]], "google_gemma-3-12b-it_is_public_document": [[0, 0, null], [0, 579, true], [579, 1381, null], [1381, 2399, null], [2399, 3173, null], [3173, 3748, null], [3748, 4537, null], [4537, 4901, null], [4901, 5534, null], [5534, 6321, null], [6321, 6847, null], [6847, 7641, null], [7641, 8312, null], [8312, 8844, null], [8844, 9504, null], [9504, 10219, null], [10219, 10913, null], [10913, 11697, null], [11697, 12495, null], [12495, 13188, null], [13188, 13616, null], [13616, 14005, null], [14005, 14705, null], [14705, 15232, null]], "google_gemma-3-4b-it_v2tag__is_academic_paper": [[0, 5000, true], [5000, 15232, null]], "google_gemma-3-4b-it_v2tag__is_class_syllabus": [[0, 5000, false], [5000, 15232, null]], "google_gemma-3-4b-it_v2tag__is_completion_certificate": [[0, 5000, false], [5000, 15232, null]], "google_gemma-3-4b-it_v2tag__is_court_notice": [[0, 5000, false], [5000, 15232, null]], "google_gemma-3-4b-it_v2tag__is_homework_assignment": [[0, 5000, false], [5000, 15232, null]], "google_gemma-3-4b-it_v2tag__is_news_article": [[0, 5000, false], [5000, 15232, null]], "google_gemma-3-4b-it_v2tag__is_public_order": [[0, 5000, false], [5000, 15232, null]], "google_gemma-3-4b-it_v2tag__is_resume_cv": [[0, 5000, false], [5000, 15232, null]], "google_gemma-3-4b-it_v2tag__is_test_or_quiz": [[0, 5000, false], [5000, 15232, null]], "google_gemma-3-4b-it_v2tag__is_textbook": [[0, 5000, false], [5000, 15232, null]], "pdf_page_numbers": [[0, 0, 1], [0, 579, 2], [579, 1381, 3], [1381, 2399, 4], [2399, 3173, 5], [3173, 3748, 6], [3748, 4537, 7], [4537, 4901, 8], [4901, 5534, 9], [5534, 6321, 10], [6321, 6847, 11], [6847, 7641, 12], [7641, 8312, 13], [8312, 8844, 14], [8844, 9504, 15], [9504, 10219, 16], [10219, 10913, 17], [10913, 11697, 18], [11697, 12495, 19], [12495, 13188, 20], [13188, 13616, 21], [13616, 14005, 22], [14005, 14705, 23], [14705, 15232, 24]], "pipe_delimited_lines_v1__pipe_delimited_lines_v1__pipe_delimited_lines_ratio": [[0, 15232, 0.0]]}
olmocr_science_pdfs
2024-12-07
2024-12-07
d9270c4cfdf26015d14ccbeb2b2a0bb24eb8666c
A Security Checklist for Web Application Design Gail Bayse A Security Checklist for Web Application Design Gail Zemanek Bayse GIAC Security Essential Certification (GSEC) Practical Assignment, Version 1.4b Abstract Web applications are very enticing to corporations. They provide quick access to corporate resources; user-friendly interfaces, and deployment to remote users is effortless. For the very same reasons web applications can be a serious security risk to the corporation. Unauthorized users can find the same benefits: “quick access,” “user-friendly,” and “effortless” access to corporate data. This paper is written for Information Technology professionals who are not programmers and may not be aware of the specific problems presented when using an externally facing web application to attach to a mission critical database. The content provides a description of the security challenges introduced by externally facing web applications. It provides the knowledge necessary to articulate to developers the security requirements for a specific web application, to make contractual the obligation of the developer to build an application that is secure, and to assure that appropriate testing is completed prior to moving to a production environment. The document is structured as a checklist of challenges. For each challenge there are specific checkpoints that delineate the security concern. The checklist provides a basis for securing web applications and the databases they connect to from malicious and unintentional abuse. Checklist Risk Assessment Authentication Authorization and Access Control Session Management Data and Input Validation Cross Site Scripting (XSS) Command Injection Flaws Buffer Overflows Error Handling Logging Remote Administration Web Application and Server Configuration Risk Assessment Challenge: Not all applications used in a secured Local Area Network (LAN) present additional security risk. It is important to match the security requirements with the risk imposed by the new application. An application that is used by employees solely from within the LAN and streamlines tasks already part of their functional role may require no additional security. However, an externally facing web application used by remote employees, consultants or vendors, attaching to a mission critical database poses a very different set of concerns. Every data asset must be examined and its confidentiality, criticality and vulnerability assessed. It is crucial to develop security procedures that are appropriate to each asset’s criticality and vulnerability. “Security is almost always an overhead, either in cost or performance.” Therefore, the goal is to match the level of security with the assessed risk to assure that latency caused by security and the dollar amount spent securing an application are realistic and acceptable. An application determined to be of risk to mission critical data will require a thorough security component during its’ design phase, in development and implementation, and into maintenance. Use the following questions as checkpoints to determine the level of risk posed and the requisite security layers to be added. Checkpoints: - Which applications are affected by the requested change? - Who are the users? Where are the users physically located? - Will the application attach to mission critical applications? Will it modify any confidential or critical data? - Where should additional user authentication be built into the application? - Where will the application be physically located in the network? In the DMZ, the internal network? Will it be installed on new equipment or share an existing server? Will it coexist well with existing applications? - Will any data considered sensitive or confidential be transmitted over external communication links? - If the system was compromised would it result in financial loss or the loss of reputation? Can you place a dollar amount on any loss? - What is the history of the OS platform with respect to security? - What would motivate someone to break into the application? - Will the application have high external visibility, making it an obvious target to attackers? Authentication Challenge: Authentication is a first line of defense. The application must determine if the user is who he/she claims to be or if the entity, a server or program, is what it claims to be. This is the “I recognize who you are.” stage. The most common form of authentication is the user id and password. Authentication policies, processes, and logging must be designed, developed and documented to assure that the application keeps unauthorized users from accessing the site. It must correctly identify the true owner of a user id and password. Checkpoints: To prevent a user id and/or password from being hacked, failed logins should trigger a lock-out after a determined number of attempts. The account lock-out should be maintained for a number of hours to prevent and discourage the attacker from reissuing the attack. The activity should be logged. All authentication attempts should be logged – log in, log outs, failed logins, password change requests. In addition notification or alerts should be sent to an administrator when the account is locked due to failed logins. An attacker should not be able to deduce the user id. “Bill.Johnson” would not be considered a strong user id, while “bijohn” would be less obvious. Likewise, strong password rules should be applied. A strong password has a minimum of seven characters and it uses three of the following: numbers, upper case letters, lower case letters, and symbols. It will have a symbol character in the second – sixth position. A strong password will not use repeated or sequenced characters. It will look random. Finally, the password should not be found in any dictionary. Implement a password expiry time for all passwords. The more critical an application is deemed, the more often the password should change. For applications requiring a highly secure system, consider two-factor authentication. This is a token or fob with a code that automatically changes every 60 seconds. It is something you have (the token’s changing code), and something you know (a pin or passcode), and your user id. When a password is changed, require the existing password to be entered prior to accepting a new password. It is important to verify that the owner of the user id is the person requesting the password change. When passwords are successfully changed the program should forward a message to the email address of the owner of the user id, and the user should be forced to re-authenticate. When a user forgets a password, the password must be changed rather than “recovered.” Passwords should not be stored in a manner that would allow a recovery. On form based password resets, the use of “secret” questions and answers is recommended. Again, the application should force a new authentication following the password reset. Passwords and user ids must be transmitted and stored in a secure manner. Do not send user ids and passwords in a clear-text email message. Should this be a necessity, any passwords sent in clear text must be encrypted using Secure Socket Layer (SSL). Any list of passwords should be hashed (one-way hash) to assure that an attacker is unable to read authentication information. For applications that require intense security, consider combining a randomly generated salt value with the password hash. Salt is "random data …included as part of a session key. Salt values are added to increase the work required to mount a brute-force (dictionary) attack"\(^6\) against authentication credentials. If user accounts are required to be exposed, i.e., in a drop down box, then an alias must be used to protect the user id. Best practice recommends encrypting the entire logon transaction with SSL. Forms-based authentication must use a POST request to assure that the authentication credentials are not cached to browser history.\(^7\) Using SSL on all login pages will accomplish this. Make use of "no cache" tags to further prevent someone from backing up to a login page and resubmitting a logon. Do not allow the application to cache both user id and password. “Remember me” functionality is not recommended, but if used should allow users to automatically sign in only to non-critical portions of the site. Note on SSL: SSL can provide authentication, confidentiality, and integrity for data as it is transported to and from web services. It is important to recognize that SSL doesn’t protect the web application. It protects the “transport” of the data as it moves between the web application server and a browser. SSL is a transport layer protocol that operates between the TCP/IP layer and the Application layer where HTTP operates. Being aware of where SSL encryption is implemented will reduce any false sense of security developers may have when using SSL to secure an application. Authorization and Access Control Challenge: Authentication tells a user “I recognize you as a user.” Authorization says “Now that I know who you are I also know what you are allowed to do; what data you are allowed to see and modify.” Access control determines where a user can connect from; what time they can connect, and the type of encryption required. The goal is to develop a security strategy to protect back-end and front-end data and systems. This can be accomplished through the use of roles, credentials, and sensitivity labels.\(^8\) Checkpoints: During the design phase, user roles should be defined based on a “least privilege” model. If a user role will not be modifying data, then the role should not be given any opportunity to edit, delete, or add data to the critical database. Document the user roles during development and determine who will hold the responsibility for assigning users to specific roles. The designers of the web application should have available to them complete documentation of the mission critical database at the conception of the project’s design. It should include a description of all fields and tables, data length and expected values for a field, and any permissions assigned to the field. Assure that users cannot “browse” past their user role rights. The user should not be able to access an unauthorized page by entering the location into the URL. Similarly, A user should not be able to enter a file path (\servername\winnt\drivers) into a URL that would allow a user to access and potentially modify a system file. Assure that users’ activity is not cached when handling sensitive information. If multiple employees share a workstation, clicking the back arrow should not take a user to the URL of the last users’ login or their last pages visited. This may result in elevated rights. Use file system access rights only as a last defense. Testing of an application prior to moving it into a production environment will include a review of user role documentation and a review of the code implementing access controls. Penetration testing will be necessary to assure that every access control has been tested and prevents unauthorized access. **Session Management** **Challenge:** A common vulnerability of web applications is caused by not protecting account credentials and session tokens. There are four types of session id attacks: interception, prediction, brute-force, and fixation. In each attack, an unauthorized user can hijack a session and assume the valid user’s identity. Encrypting sessions is effective against interception; randomly assigned session ids protect against prediction; long keyspaces render brute-force attack less successful, and forcing assignment and frequent regeneration of session ids make fixation less problematic. HTTP is a stateless protocol. It will answer any http request. HTTP does not, by itself, keep conversations in any specific order. It is important to use a state mechanism to separate and maintain an individual user's activities within a session. A cookie is a common vehicle used to maintain state in HTTP sessions. The cookie allows a user to make numerous HTTP transactions in one conversation. The session id keeps the various requests together in one conversation. **Checkpoints:** Because cookies are transmitted in clear text, the content of the cookie must not contain or be used to obtain sensitive information. State mechanisms were not designed to manage sensitive information. Therefore, state mechanisms should not be used to authenticate users. The user must be made aware of and agree with the use of the application will make of cookie sessions. The user must be able to immediately delete the cookie and the state associated with it. Any information stored within the cookie must not be disseminated to third parties without the users’ consent.¹³ Session ids should be unique to users, and issued after successful authentication. They should be randomly generated using a respected randomization source. The session id should never contain personal information. Session ids are always assigned, never chosen by end user. The keyspace of the token must as large as possible to combat guessing and other attacks. A 12-digit keyspace has 1 trillion (10¹²) possible different codewords.¹⁴ As bandwidth increases, the size of the keyspace must increase to keep hackers out. ¹⁵ Session ids must be protected throughout their life cycle to prevent hijacking.¹⁶ They should have a time-out set for inactive sessions. Active sessions should also have a set time to expire and regenerate a new session token. This reduces the time window that a hacker would have to break into a session. Session ids should be protected with SSL. Session ids should change routinely and always during major transitions, i.e., when moving to and from an SSL and when authenticating. For highly secure transactions re-authentication and a new session id should be issued prior to processing the requested transaction. On log out, the session id should be over-written. **Data and Input Validation** Challenge: Cross-Site Scripting and Command Injection take advantage of a “violation of trust”¹⁷ between a user accessing a known and trusted site and an attacker. The attacker bypasses security mechanisms by adding malicious code to open parameters in an application. An open parameter could be a URL, QueryString, Header, Cookie, Form Field, or a Hidden Field. It is any parameter that does not assure that the data entered is data that would normally be expected. For example, if the parameter is a date field, and the input “injected” into it is a script file, then the attacker has been successful in finding and using an open parameter. Well-written code would discard the script. The importance of knowing and documenting what is known as valid data cannot be stressed enough. Checkpoints: The strongest defense against these attacks is Input Validation. If the server validates all data entering the web application against known good criteria, the chances of successful attack are greatly reduced. The burden of security validation must fall on the server, and hence the application developer, rather than the client. Client-side validation is often used as a primary validation to “reduce round trips to the server,” but should not be used as a security defense. \(^{18}\) The use of a common library of field validations can be used to more efficiently and accurately confirm the integrity of the entry data. - Constrain input – decide what is allowed in the field - Validate data – type, length, format, and range - Reject “known bad” input – do not rely only on this as it assumes the programmer knows everything that could possibly be malicious. - Sanitize Input – This can include stripping a null from the end of a user-supplied string; escaping out values so they are treated as literals, and HTML or URL encoding to wrap data and treat it as a literal. \(^{19}\) Make strict use of canonicalization. Know what the server is expecting in every field. All data input must be reduced to a pure format, the format that the server and database expects. Input validation assures that all data is appropriate for its meaningful purpose. It may be necessary to establish character sets on the server to establish the canonical form that input must take. \(^{20}\) As noted in the Authentication section, an SSL connection is established in the transport layer, after the malicious code is introduced. It is important to recognize that SSL does not protect against invalid data. The SSL connection sees a valid conversation between server and user and transports the malicious code. Cross Site Scripting (XSS) Challenge: When a web application creates output from user input without validating the data, the output can include malicious code. An attacker looks for instances in code where there is no validation and inserts the attack at that point. The output that the user receives may well carry malicious code. The user may receive a “click here” message, and trusting the “known site,” abide by the hackers desire. The result is directed at the end user rather than the application’s infrastructure. This could transmit corporate confidential data to an outside site. It can result in program installations or disclosure of end user files. \(^{21}\) Checkpoints: All code must be reviewed for input variables that result in output and have no validation included. All headers, cookies, query strings, form fields, and hidden fields accepting input are validated against acceptable data lists. Every field must have a list of acceptable values.\textsuperscript{22} Replacing the following characters will also defeat XSS. <table> <thead> <tr> <th>Replace</th> <th>With</th> </tr> </thead> <tbody> <tr> <td>&lt;</td> <td>&amp;lt</td> </tr> <tr> <td>&gt;</td> <td>&amp;gt</td> </tr> <tr> <td>(</td> <td>&amp;#40</td> </tr> <tr> <td>)</td> <td>&amp;#41</td> </tr> <tr> <td>#</td> <td>&amp;#35</td> </tr> <tr> <td>&amp;</td> <td>&amp;#38</td> </tr> </tbody> </table> Command Injection Flaws Challenge: Command injection flaws allow attackers to relay malicious code through the web application to another system. The malicious code can include whole scripts. SQL injection is the most prevalent. SQL injection attaches specifically to a parameter that passes through to an SQL database allowing an attacker to modify, erase, copy, or corrupt an entire database. SQL Injections can take the following forms: Authorization (Authentication), Select Statement, Insert, and SQL Server Stored Procedures.\textsuperscript{24} Checkpoints: Review for SQL injection is time consuming. All parameters must be examined for calls to external sources. Review the code for any instance where input from an HTTP request could be written into any of these external calls. Build filters that verify that only expected data is included. If symbols are required, assure that they are converted to HTML. Prepend and append a quote to all user input. SQL server comes with a variety of stored procedure calls. Many are not used in specific applications. Give users access to only the SQL stored procedures that are required. All others should be stored away from the web application.\textsuperscript{25} Wherever possible avoid shell commands and system calls. In many cases there are language libraries that perform the same functions without using a system shell interpreter.\textsuperscript{26} Where shell commands cannot be avoided, the code must validate the input against a valid input list to ensure that it does not include malicious code. Consider all supplied input as data, reducing, though not eliminating external calls. In the event of data that is not acceptable, there should be a mechanism in place to block and time out the session. **Buffer Overflows** **Challenge:** “The buffer overflow attack involves sending large amounts of data that exceed the quantities expected by the application within a given field.” Such attacks cause the application to abandon its normal behavior and begin executing commands on behalf of the attacker. Attackers find buffer overflow vulnerabilities by searching for system calls and functions that do not restrict the length and type of input. This can be done manually or electronically with a code inspection tool. The attacker can also run a brute force attack against the program in the hope of finding vulnerabilities in the code. Once the attacker finds a vulnerability, custom code is inserted that does not crash the system, rather instructs it to execute other commands or programs of the attackers desire. **Checkpoints:** All code that accepts input from users via an HTTP request must be reviewed to ensure that it can identify large input. Once inappropriate data is identified the activity must be logged and the data dropped. All data input fields must have reasonable field lengths and specific data types. Limit the amount of text allowed in free form fields. Routinely check the code of web applications during their development phase to assure that the design is secured as built. **Insecure Use of Cryptography** **Challenge:** Apply encryption to any part of the program that affects critical or confidential data. Assure that all elements of encryption are securely stored. Encryption schemas should be developed by a commercial company rather than developed internally. Encryption is fairly easy to add to an application, but it is often not done correctly. Some common mistakes are: - Insecure storage of keys, certificates, and passwords - Improper storage of secrets in memory • Poor source of randomness • Poor choice of algorithm or internally developed algorithms • Failure to encrypt critical data • Attempt to invent a new encryption algorithm • Failure to include support for encryption key changes and maintenance procedures. Checkpoints: Determine what data is critical or vulnerable and develop encryption schemes to shield the data from unauthorized users and use. Encryption adds latency to the application, therefore it may be prudent to apply encryption to specific parts of the site, for example, the authentication pages. Review the code to learn how critical data is secured. The review should also identify how keys, passwords, and other secrets are stored, loaded, processed, and cleared from memory. Assure the developer’s choice of randomness and algorithm is of high quality. The programmer should not build the algorithm or the randomness. There are numerous professional sources available for both. Error Handling Challenge: Errors are inevitable. Errors can be caused by user, programs, or perhaps they are errors between two systems. During development and testing an effort is made to identify all potential errors and appropriate error messages are developed for the end user. There will also be errors that are unanticipated. The application must have protocols for these errors as well. Left “unhandled,” the administrator has no idea that an error has occurred. The procedure for handling the unanticipated needs to include what the error was, when it occurred, and where it occurred. Checkpoints: During development write a policy for handling errors. Determine which errors should trigger a response to the end user. Carefully write error pages with appropriate information. The error page reported to the end user must be carefully crafted to give the user some information. However, an attacker can learn a tremendous amount of information about a website from default error messages. The messages “file not found” or “access denied” give hackers information about the file system structure and its permissions. Determine which errors should be logged. Log unhandled errors to an event log. Include time and date, user id, error code, if possible the code line. This log should be encrypted as it is critical information. Thoroughly test the application to determine the possible errors. Decide what the programmatic response will be to known errors. Write error pages that reflect enough information to the end user without giving the user information about the code, the file system, or permissions. When an error occurs that causes the program or a part of the program to fail, it is vital that the system will “fail closed,” blocking an unauthorized user from reaching the operating system or the site. The action that caused the error should be logged and then blocked. Logging Challenge: Logging is crucial to an organization’s ability to track unauthorized access and to determine if any access attempt was successful. Logs provide individual accountability. They are vital to reconstruction of events leading to a program failure. Log as much as possible. Logs are often required in any legal proceedings.\(^3\) Checkpoints: Begin by synchronizing your servers and syslog server to a time server. Time and date stamps must be accurate. Preserve a baseline of your network to be used as a comparison point in the event of system failure. The following items will make any log entry meaningful: - Date and Time - Initiating Process - Process Owner - Description Log all Authentication and Authorization Events – logging in, logging out, failed logins. These should include date/time, success/failure, resources being authorized, and the user requesting the authorization, if appropriate an IP address or location of the Authentication Attempt. Log all Administrator activity. All of it. Log the deletion of any data. Log any modification to data characteristics: permissions, location, field type. Log files are critical data. They should be encrypted. If your environment is highly secure consider WORM technology to protect the log files from deletion or modification. Develop a procedure for archiving log files. Consider encrypting this critical data. **Remote Administration Flaws** **Challenge:** In a most secure scenario, remote administration is not allowed. As this is not often possible, it is necessary to design a secure system for remote connections to the server. **Checkpoints:** Determine how the site is to be administered. Document who has the rights to make changes, and when they can be made. Determine an effective vehicle for remote management such as a VPN solution, strong authentication with tokens, or certificates. Assure that user roles and administration roles are clearly defined and that the program holds the roles to their intended use. You may also bind administrator functions to specific IP addresses using IP Filtering. **Web Application and Server Configuration** **Challenge:** Out of the box, servers are laden with vulnerabilities. They must be patched before web services are installed. All default settings should be reviewed; and unnecessary services deleted or disabled. **Checkpoints:** Configure server disks to allow for the separation of the operating system and the web server. This will allow the restriction of directory traversal to inappropriate locations. Verify that assigned file and directory permissions are correctly applied using “least privilege” mode. Disable any services that are not used by the web server or applications. Delete default accounts and their default passwords Rename the default Administrator account or make it inaccessible. Delete all guest accounts. Disable debugging functions. Edit error messages to provide as little information as possible to a hacker. Do not use self-signed SSL certificates, or default certificates. Assure that SSL certificates and encryption settings are properly configured. Scan from the outside network to assure that all unnecessary ports are closed. Run port scans monthly to assure that nothing has been changed. Assign security maintenance to an individual or team to be responsible for: monitoring latest security vulnerabilities; testing and applying the latest patches; updating security configuration guidelines; regular vulnerability scanning; regular status reports to upper management; and documenting the overall security practice or posture. **Conclusion** Each of the challenges discussed in this paper are a part of “Defense in Depth.” Should any one piece of this defense fail or be compromised, another layer of defense should stop an intruder from taking complete control of the site. The checklist provides a foundation for selecting and contracting with an application developer. The corporation’s requirements for security are clearly available to the developer as part of the contract. The developer will have a concrete understanding of the risk mitigation requirements throughout the design and development process. Prior to moving into a production, environment security analysis can verify that all known security gaps are closed. Security requirements will change in response to the external environment. What secured an application today may need to be changed tomorrow. Constant review and attention to the current security threat environment is necessary to maintain the application’s security. Externally facing applications have provided corporations great flexibility and greater efficiencies. As evidenced by the challenges of this checklist, they can also provide a serious security risk if they attach to mission critical systems. It is imperative to secure and maintain the state of security throughout the life-cycle of the application. Bibliography Microsoft Corporation. Design Guidelines for Secure Web Applications, MSDN O’Gorman , L, Securing Business’s Front Door – Password, Token, and Biometric Authentication, Avaya Labs Research, Basking Ridge, NJ, RSA Security, “RSA SecurID® Two-Factor Authentication,” http://www.spidynamics.com/whitepapers.html http://www.spidynamics.com/whitepapers.html SPI Dynamics, 2002, “SQL injection, are your web applications vulnerable”, Tuliper, Adam, January 2, 2003, “Web Application Error Handling in ASP.NET,” MultiNet, Inc, (2001), Web Vulnerabilities and Security Solutions, 2 Curphey, M. etal. page 30. 5 Miller, Charles, “Password Recovery,” (October 20, 2002), 7 Curphey, M., et. al., p.30. 8 Curphey, M. page 49l. 11 Kolsek, M. (December 2002), Session Fixation Vulnerability In Web-Based Applications, ACROS, 13 Moore, K. section 2.1. 15 Kolsek, p.11 © SANS Institute 2004, As part of the Information Security Reading Room Author retains full rights. 17 CERT Coordination Center, DoD-CERT, the DoD Joint Task Force for Computer Network Defense (JTF-CND), the Federal Computer Incident Response Capability (FedCIRC), and the National Infrastructure Protection Center (NIPC), (February 3, 2000), “Malicious HTML Tags Embedded in Client Requests”, 19 Meier, J.D., et. al., page 77 20 Meier, J.D., et. al., page 76 23 CGI Security.com, (August, 2003), Cross Site Scripting Questions and Answers”, 27 MultiNet, Inc, (2001), Web Vulnerabilities and Security Solutions, 30 Tuliper, Adam, (January 2, 2003), “Web Application Error Handling in ASP.NET,” 31 Curphey, M. page 53.
{"Source-Url": "https://www.sans.org/reading-room/whitepapers/securecode/security-checklist-web-application-design-1389", "len_cl100k_base": 6142, "olmocr-version": "0.1.53", "pdf-total-pages": 18, "total-fallback-pages": 0, "total-input-tokens": 43022, "total-output-tokens": 9068, "length": "2e12", "weborganizer": {"__label__adult": 0.0004625320434570313, "__label__art_design": 0.0005927085876464844, "__label__crime_law": 0.0030670166015625, "__label__education_jobs": 0.0013284683227539062, "__label__entertainment": 7.140636444091797e-05, "__label__fashion_beauty": 0.0002028942108154297, "__label__finance_business": 0.0009393692016601562, "__label__food_dining": 0.00029277801513671875, "__label__games": 0.0008687973022460938, "__label__hardware": 0.0013980865478515625, "__label__health": 0.0005588531494140625, "__label__history": 0.00019729137420654297, "__label__home_hobbies": 0.00012743473052978516, "__label__industrial": 0.0004992485046386719, "__label__literature": 0.00018489360809326172, "__label__politics": 0.000278472900390625, "__label__religion": 0.0003066062927246094, "__label__science_tech": 0.026031494140625, "__label__social_life": 7.69495964050293e-05, "__label__software": 0.0239410400390625, "__label__software_dev": 0.9375, "__label__sports_fitness": 0.0002696514129638672, "__label__transportation": 0.000400543212890625, "__label__travel": 0.00017142295837402344}, "weborganizer_max": "__label__software_dev", "avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_ratio": [[0, 37361, 0.02977]], "fineweb_edu_fasttext_gt2__fineweb_edu_fasttext_gt2__score": [[0, 37361, 0.3529]], "ft_lang_id_en_doc_v2__ft_lang_id_en_doc_v2__en": [[0, 37361, 0.88894]], "google_gemma-3-12b-it_contains_pii": [[0, 60, false], [60, 208, null], [208, 1820, null], [1820, 4223, null], [4223, 6998, null], [6998, 9816, null], [9816, 12297, null], [12297, 14902, null], [14902, 17390, null], [17390, 19390, null], [19390, 21492, null], [21492, 23778, null], [23778, 25644, null], [25644, 27328, null], [27328, 29281, null], [29281, 31945, null], [31945, 35387, null], [35387, 37361, null]], "google_gemma-3-12b-it_is_public_document": [[0, 60, true], [60, 208, null], [208, 1820, null], [1820, 4223, null], [4223, 6998, null], [6998, 9816, null], [9816, 12297, null], [12297, 14902, null], [14902, 17390, null], [17390, 19390, null], [19390, 21492, null], [21492, 23778, null], [23778, 25644, null], [25644, 27328, null], [27328, 29281, null], [29281, 31945, null], [31945, 35387, null], [35387, 37361, null]], "google_gemma-3-4b-it_v2tag__is_academic_paper": [[0, 5000, true], [5000, 37361, null]], "google_gemma-3-4b-it_v2tag__is_class_syllabus": [[0, 5000, false], [5000, 37361, null]], "google_gemma-3-4b-it_v2tag__is_completion_certificate": [[0, 5000, false], [5000, 37361, null]], "google_gemma-3-4b-it_v2tag__is_court_notice": [[0, 5000, false], [5000, 37361, null]], "google_gemma-3-4b-it_v2tag__is_homework_assignment": [[0, 5000, false], [5000, 37361, null]], "google_gemma-3-4b-it_v2tag__is_news_article": [[0, 5000, false], [5000, 37361, null]], "google_gemma-3-4b-it_v2tag__is_public_order": [[0, 5000, false], [5000, 37361, null]], "google_gemma-3-4b-it_v2tag__is_resume_cv": [[0, 5000, false], [5000, 37361, null]], "google_gemma-3-4b-it_v2tag__is_test_or_quiz": [[0, 5000, false], [5000, 37361, null]], "google_gemma-3-4b-it_v2tag__is_textbook": [[0, 5000, false], [5000, 37361, null]], "pdf_page_numbers": [[0, 60, 1], [60, 208, 2], [208, 1820, 3], [1820, 4223, 4], [4223, 6998, 5], [6998, 9816, 6], [9816, 12297, 7], [12297, 14902, 8], [14902, 17390, 9], [17390, 19390, 10], [19390, 21492, 11], [21492, 23778, 12], [23778, 25644, 13], [25644, 27328, 14], [27328, 29281, 15], [29281, 31945, 16], [31945, 35387, 17], [35387, 37361, 18]], "pipe_delimited_lines_v1__pipe_delimited_lines_v1__pipe_delimited_lines_ratio": [[0, 37361, 0.03077]]}
olmocr_science_pdfs
2024-12-09
2024-12-09
abf84506051f249d287c091f6158846edaa5d86e
EECS E6893 Big Data Analytics HW2: Classification and Twitter data analysis with Spark Streaming Guoshiwen Han, gh2567@columbia.edu Agenda - Binary classification with Spark MLlib - Logistic Regression - Twitter data analysis with Spark Streaming - LDA Logistic Regression - Logistic Function: \[ p(X) = \frac{e^{\beta_0 + \beta_1 X}}{1 + e^{\beta_0 + \beta_1 X}} \] \[ \log \left( \frac{p(X)}{1 - p(X)} \right) = \beta_0 + \beta_1 X. \] - Likelihood Function: \[ \ell(\beta_0, \beta_1) = \prod_{i: y_i = 1} p(x_i) \prod_{i': y_{i'} = 0} (1 - p(x_{i'})). \] Spark Streaming Dstream - A basic abstraction provided by Spark Streaming - Represents a continuous stream of data - Contains a continuous series of RDDs at different time Architecture Spark Streaming Spark Context Google Storage BigQuery Twitter API Socket Request Data Put streaming data Read data Write data LDA (Latent Dirichlet allocation) - A topic model. - A three-layer Bayesian probability model, including a three-layer structure of words, topics, and documents. - It can be used to generate a document, and identify themes in a large-scale document. LDA (Latent Dirichlet allocation) <table> <thead> <tr> <th>“Arts”</th> <th>“Budgets”</th> <th>“Children”</th> <th>“Education”</th> </tr> </thead> <tbody> <tr> <td>NEW</td> <td>MILLION</td> <td>CHILDREN</td> <td>SCHOOL</td> </tr> <tr> <td>FILM</td> <td>TAX</td> <td>WOMEN</td> <td>STUDENTS</td> </tr> <tr> <td>SHOW</td> <td>PROGRAM</td> <td>PEOPLE</td> <td>SCHOOLS</td> </tr> <tr> <td>MUSIC</td> <td>BUDGET</td> <td>CHILD</td> <td>EDUCATION</td> </tr> <tr> <td>MOVIE</td> <td>BILLION</td> <td>YEARS</td> <td>TEACHERS</td> </tr> <tr> <td>PLAY</td> <td>FEDERAL</td> <td>FAMILIES</td> <td>HIGH</td> </tr> <tr> <td>MUSICAL</td> <td>YEAR</td> <td>WORK</td> <td>PUBLIC</td> </tr> <tr> <td>BEST</td> <td>SPENDING</td> <td>PARENTS</td> <td>TEACHER</td> </tr> <tr> <td>ACTOR</td> <td>NEW</td> <td>SAYS</td> <td>BENNETT</td> </tr> <tr> <td>FIRST</td> <td>STATE</td> <td>FAMILY</td> <td>MANIGAT</td> </tr> <tr> <td>YORK</td> <td>PLAN</td> <td>WELFARE</td> <td>NAMPHY</td> </tr> <tr> <td>OPERA</td> <td>MONEY</td> <td>MEN</td> <td>STATE</td> </tr> <tr> <td>THEATER</td> <td>PROGRAMS</td> <td>PERCENT</td> <td>PRESIDENT</td> </tr> <tr> <td>ACTRESS</td> <td>GOVERNMENT</td> <td>CARE</td> <td>ELEMENTARY</td> </tr> <tr> <td>LOVE</td> <td>CONGRESS</td> <td>LIFE</td> <td>HAITI</td> </tr> </tbody> </table> The William Randolph Hearst Foundation will give $1.25 million to Lincoln Center, Metropolitan Opera Co., New York Philharmonic and Juilliard School. “Our board felt that we had a real opportunity to make a mark on the future of the performing arts with these grants an act every bit as important as our traditional areas of support in health, medical research, education and the social services,” Hearst Foundation President Randolph A. Hearst said Monday in announcing the grants. Lincoln Center’s share will be $200,000 for its new building, which will house young artists and provide new public facilities. The Metropolitan Opera Co. and New York Philharmonic will receive $400,000 each. The Juilliard School, where music and the performing arts are taught, will get $250,000. The Hearst Foundation, a leading supporter of the Lincoln Center Consolidated Corporate Fund, will make its usual annual $100,000 donation, too. LDA (Latent Dirichlet allocation) - The left side is the word node, and the right side is the document node. Each word node stores some weight values to indicate which topic the word is related to; similarly, each article node stores an estimate of the topic discussed in the current article. \[ p(w|d) = \sum_{i=1}^{k} p(w|z_k) \cdot p(z_k|d) \] *d* is the document, *w* is the word, *z* is the topic, and *k* is the number of topics. HW2 HW2 Part I Binary classification with Spark MLlib - Adult dataset from UCI Machine Learning Repository - Given information of a person, predict if the person could earn > 50k per year ## HW2 Part I Binary classification with Spark MLlib ### Workflow - Data loading: load data into Dataframe ```scala data.show(3) ``` ``` | _c0| _c1| _c2| _c3| _c4| _c5| _c6| _c7| _c8| _c9| _c10|_c11|_c12| |---|---|---|---|---|---|---|---|---|---|---|---| | _c13| _c14| | 39| State-gov| 77516.0| Bachelors| 13.0| Never-married| Adm-clerical| Not-in-family| White| Male| 2174.0| 0.0|40.0| United-States| <=50K| | 50| Self-emp-not-inc| 83311.0| Bachelors| 13.0| Married-civ-spouse| Exec-managerial| Husband| White| Male| 0.0| 0.0|13.0| United-States| <=50K| | 38| Private|215646.0| HS-grad| 9.0| Divorced| Handlers-cleaners| Not-in-family| White| Male| 0.0| 0.0|40.0| United-States| <=50K| --- only showing top 3 rows ## HW2 Part I Binary classification with Spark MLlib ### Workflow - **Data preprocessing:** Convert the categorical variables into numeric variables with ML Pipelines and Feature Transformers <table> <thead> <tr> <th>dataset</th> <th>df</th> </tr> </thead> <tbody> <tr> <td></td> <td>age: integer (nullable = true)</td> </tr> <tr> <td></td> <td>workclass: string (nullable = true)</td> </tr> <tr> <td></td> <td>fnlgt: double (nullable = true)</td> </tr> <tr> <td></td> <td>education: string (nullable = true)</td> </tr> <tr> <td></td> <td>education_num: double (nullable = true)</td> </tr> <tr> <td></td> <td>marital_status: string (nullable = true)</td> </tr> <tr> <td></td> <td>occupation: string (nullable = true)</td> </tr> <tr> <td></td> <td>relationship: string (nullable = true)</td> </tr> <tr> <td></td> <td>race: string (nullable = true)</td> </tr> <tr> <td></td> <td>sex: string (nullable = true)</td> </tr> <tr> <td></td> <td>capital_gain: double (nullable = true)</td> </tr> <tr> <td></td> <td>capital_loss: double (nullable = true)</td> </tr> <tr> <td></td> <td>hours_per_week: double (nullable = true)</td> </tr> <tr> <td></td> <td>native_country: string (nullable = true)</td> </tr> <tr> <td></td> <td>income: string (nullable = true)</td> </tr> </tbody> </table> ```scala (13) println(df.show(2)) ``` ``` <table> <thead> <tr> <th>age</th> <th>workclass</th> <th>fnlgt</th> <th>education</th> <th>education_num</th> <th>marital_status</th> <th>occupation</th> <th>relationship</th> <th>race</th> <th>sex</th> <th>capital_gain</th> <th>capital_loss</th> <th>hours_per_week</th> <th>native_country</th> <th>income</th> </tr> </thead> <tbody> <tr> <td>39</td> <td>State-gov</td> <td>77568.0</td> <td>Bachelors</td> <td>3.0</td> <td>Never-married</td> <td>Adm-clerical</td> <td>Not-in-family</td> <td>White</td> <td>Male</td> <td>2174.0</td> <td>0.0</td> <td>0.0</td> <td>United-States</td> <td>80.0</td> </tr> <tr> <td>50</td> <td>Self-emp-not-inc</td> <td>33616.0</td> <td>Bachelors</td> <td>3.0</td> <td>Married-civ-spouse</td> <td>Exec-managerial</td> <td>Husband</td> <td>White</td> <td>Male</td> <td>0.0</td> <td>0.0</td> <td>0.0</td> <td>United-States</td> <td>30.0</td> </tr> </tbody> </table> ``` only showing top 2 rows HW2 Part I Binary classification with Spark MLlib ● Workflow ○ Modelling: Logistic Regression KNN Random Forest Naive Bayes Decision Tree Gradient Boosting Trees Multi-layer perceptron Linear Support Vector Machine One-vs-Rest https://spark.apache.org/docs/latest/ml-classification-regression.html HW2 Part I Binary classification with Spark MLlib - **Workflow** - Evaluation (Logistic Regression) ```python plt.ylabel('Beta Coefficients') plt.show() print('Training set areaUnderROC: ' + str(trainingSummary.areaUnderROC)) ``` ![ROC Curve Diagram](image) HW2 Part I Binary classification with Spark MLlib - Workflow - Evaluation (Logistic Regression) ``` plt.ylabel('Precision') plt.xlabel('Recall') plt.show() ``` ``` print("Accuracy: %s\nFPR: %s\nTPR: %s\nF-measure: %s\nPrecision: %s\nRecall: %s" % (accuracy, falsePositiveRate, truePositiveRate, fMeasure, precision, recall)) ``` Accuracy: 0.852662929221444 FPR: 0.317288962595939 TPR: 0.852662929221444 F-measure: 0.8475083896808702 Precision: 0.8469035949642436 Recall: 0.852662929221444 ``` evaluator.evaluate(predictions) ``` ``` Out[54]: 0.8993574699928725 ``` ``` In [55]: # accuracy correct = float(predictions.filter(pred: total = float(predictions.count()}) print(correct, total, correct/total) ``` 8218.0 9729.0 0.8446911296124987 HW2 Part II Twitter Data Analysis - Calculate the accumulated hashtags count sum for 600 seconds and sort it by descending order of the count. - Filter the chosen 5 words and calculate the appearance frequency of them in 60 seconds for every 60 seconds (no overlap). - Save results to google BigQuery. - Use LDA to do classification to your streaming, see the topic distribution. Register on Twitter Apps (Do this ASAP) ```python # credentials # TODO: replace with your own credentials ACCESS_TOKEN = '' # your access token ACCESS_SECRET = '' # your access token secret CONSUMER_KEY = '' # your API key CONSUMER_SECRET = '' # your API secret key ``` https://developer.twitter.com/en/apply-for-access.html Socket Use TCP, need to provide IP and Port for client to connect ```python class twitter_client: def __init__(self, TCP_IP, TCP_PORT): self.s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) self.s.bind((TCP_IP, TCP_PORT)) def run_client(self, self, tags): try: self.s.listen(1) while True: print("Waiting for TCP connection...") conn, addr = self.s.accept() print("Connected... Starting getting tweets.") sendData(conn, tags) conn.close() except KeyboardInterrupt: exit ``` Spark Streaming ```python if __name__ == '__main__': # Spark settings conf = SparkConf() conf.setMaster('local[2]') conf.setAppName("TwitterStreamApp") # create spark context with the above config sc = SparkContext(conf=conf) sc.setLogLevel("ERROR") # create sql context, used for saving rdd sql_context = SQLContext(sc) # create the Streaming Context from the above spark context with batch interval size 5 seconds ssc = StreamingContext(sc, 5) # setting a checkpoint to allow RDD recovery ssc.checkpoint("~/checkpoint_TwitterApp") # read data from port 9001 dataStream = ssc.socketTextStream("localhost",9001) dataStream.pprint() ``` Create a local StreamingContext with two working thread and batch interval of 5 second. Create stream from TCP socket IP localhost and Port 9001 Spark Streaming ```python # Start streaming process, wait for 600s and then stop. ssc.start() time.sleep(STREAMTIME) ssc.stop(stopSparkContext=False, stopGraceFully=True) ``` STREAMTIME = 600 # time that the streaming process runs Start streaming context Stop after 600 seconds (You can set STREAMTIME to a smaller value at first) Save results to BigQuery Start streaming 1. Run twitterHTTPClient.py 2. Run sparkStreaming.py 3. You can test sparkStreaming.py multiple times and leave twitterHTTPClient.py running 4. Stop twitterHTTPClient.py (on job page of the cluster or use gcloud command) Task1: hashtagCount ```python def hashtagCount(words): """ Calculate the accumulated hashtags count sum from the beginning of the stream and sort it by descending order of the count. Ignore case sensitivity when counting the hashtags: """#Ab"" and ""#ab"" is considered to be a same hashtag You have to: 1. Filter out the word that is hashtags. Hashtag usually start with ""#"" and followed by a serious of alphanumerics 2. map (hashtag) to (hashtag, 1) 3. sum the count of current DStream state and previous state 4. transform unordered DStream to a ordered Dstream Hints: you may use regular expression to filter the words You can take a look at updateStateByKey and transform transformations Args: dstream(DStream): stream of real time tweets Returns: DStream Object with inner structure (hashtag, count) """ # TODO: insert your code here pass ``` Task2: wordCount WORD = ['data', 'spark', 'ai', 'movie', 'good'] # the words you should filter and do word count # Helper functions def wordCount(words): # Calculate the count of 5 special words for every 60 seconds (window no overlap) # You can choose your own words. # Your should: # 1. filter the words # 2. count the word during a special window size # 3. add a time related mark to the output of each window, ex: a datetime type # Hints: # You can take a look at reduceByKeyAndWindow transformation # Dstream is a serious of rdd, each RDD in a DStream contains data from a certain interval # You may want to take a look of transform transformation of DStream when trying to add a time # Args: # dstream(DStream): stream of real time tweets # Returns: # DStream Object with inner structure (word, (count, time)) # TODO: insert your code here pass Task 3: Save results Create a dataset: ``` bq mk <Dataset name> ``` Replace with your own bucket and dataset name: ```python # global variables bucket = "" # TODO: replace with your own bucket name output_directory_hashtags = 'gs://{}/hadoop/tmp/bigquery/pyspark_output/hashtagsCount'.format(bucket) output_directory_wordcount = 'gs://{}/hadoop/tmp/bigquery/pyspark_output/wordcount'.format(bucket) # output table and columns name output_dataset = '"' # the name of your dataset in BigQuery output_table_hashtags = 'hashtags' columns_name_hashtags = ['hashtags', 'count'] output_table_wordcount = 'wordcount' columns_name_wordcount = ['word', 'count', 'timestamp'] ``` Task3: Save results # save hashtags count and word count to google storage # used to save to google BigQuery # You should: # 1. topTags: only save the last DStream # 2. wordCount: save each DStream # Hints: # 1. You can take a look at foreachRDD transformation # 2. You may want to use helper function saveToStorage # TODO: insert your code here ### Sample Results <table> <thead> <tr> <th>Row</th> <th>Time</th> <th>count</th> <th>word</th> </tr> </thead> <tbody> <tr> <td>1</td> <td>2019-10-18 23:30:10 UTC</td> <td>2</td> <td>ai</td> </tr> <tr> <td>2</td> <td>2019-10-18 23:30:50 UTC</td> <td>2</td> <td>ai</td> </tr> <tr> <td>3</td> <td>2019-10-18 23:31:30 UTC</td> <td>3</td> <td>ai</td> </tr> <tr> <td>4</td> <td>2019-10-18 23:31:50 UTC</td> <td>5</td> <td>ai</td> </tr> <tr> <td>5</td> <td>2019-10-18 23:31:10 UTC</td> <td>8</td> <td>ai</td> </tr> <tr> <td>6</td> <td>2019-10-18 23:30:30 UTC</td> <td>10</td> <td>ai</td> </tr> <tr> <td>7</td> <td>2019-10-18 23:30:10 UTC</td> <td>1</td> <td>data</td> </tr> <tr> <td>8</td> <td>2019-10-18 23:31:50 UTC</td> <td>1</td> <td>data</td> </tr> <tr> <td>9</td> <td>2019-10-18 23:30:50 UTC</td> <td>1</td> <td>data</td> </tr> <tr> <td>10</td> <td>2019-10-18 23:31:10 UTC</td> <td>2</td> <td>data</td> </tr> <tr> <td>11</td> <td>2019-10-18 23:31:20 UTC</td> <td>2</td> <td>good</td> </tr> </tbody> </table> Task 4: LDA Classification - Load your streaming ```python spark_df.show() ``` ``` +-----------------------------+ | words | +-----------------------------+ | [Hi, I, heard, ab...] | | [I, wish, Java, c...] | | [Logistic, regres...] | +-----------------------------+ ``` Task4: LDA Classification - Do classification - Check the weight of every topic distribution ```python transformed.show(truncate=False) ``` ``` <table> <thead> <tr> <th>topicDistribution</th> </tr> </thead> <tbody> <tr> <td>[0. 0.15507417459822004, 0.1550728393967869, 0.8580192339534809, 0.15507283495435582, 0.1550734753977979, 0.15507454092087107, 0.111611617277430928, 0.111611687576324213, 0.1438443673120081, 0.111611693199529186, 0.11611469213723304, 0.1161120037044054, 0.115507709935122908, 0.15507792523275011, 0.19206149229381127, 0.15507722462775812, 0.1550796508759411, 0.155078109498377]</td> </tr> </tbody> </table> ``` Task 4: LDA Classification - Output topic and vocabulary distribution ``` print(topics) ``` Learned topics (as distributions over vocab of 16 words): DenseMatrix([[0.69497654, 0.6745065, 1.46407035, 0.71606946, 0.68823238, 0.83995925, 0.71709871, 1.13603813, 0.86361908, 0.88846945], [0.8478173, 0.61279355, 1.17889067, 0.73694848, 0.64281227, 0.65817783, 0.79481916, 0.8035318, 0.76980272, 0.92066953], [0.78510867, 0.77847208, 0.86279637, 0.81701682, 0.58656788, 0.79704796, 0.77827968, 1.22829593, 0.73297109, 0.76163522], [0.78489061, 0.77776822, 1.33782363, 0.74432285, 0.76384188, 0.81880924, 0.78365265, 0.81179619, 0.97346241, 0.8602109], [0.70132889, 0.81153272, 0.70012903, 0.81389106, 0.71879648, 0.80034944, 0.61262942, 1.06997399, 0.72904109, 0.6892238], [0.72429644, 0.94308907, 0.73973033, 0.74226237, 0.73192789, 0.72408692, 1.0964796, 0.66232373, 0.6901715, 0.78957828], [0.75369384, 0.90705663, 0.5635939, 0.66292691, 0.60902154, 0.76171012, 0.58526171, 1.15064891, 0.8222317, 0.66119302], [0.72804759, 0.88032802, 1.3391255, 0.63925354, 0.79383212, 0.90687066, 0.69586907, 0.68069846, 0.69006699, 0.94959428], [0.75916987, 0.73727924, 0.55095965, 0.79689776, 0.80397701, 0.73422704, 0.9370958, 0.76371326, 0.66565853, 0.6708945], [0.76248368, 0.58984395, 0.69364698, 0.71571205, 0.92289406, 0.89340239, 1.06406147, 0.81177578, 0.7188162, 0.78183528], [0.64441378, 0.68018412, 1.4021663, 0.74996672, 0.74679628, 0.72429644, 0.94308907, 0.73973033, 0.74226237, 0.73192789, 0.72408692, 1.0964796, 0.66232373, 0.6901715, 0.78957828, 0.75369384, 0.90705663, 0.5635939, 0.66292691, 0.60902154, 0.76171012, 0.58526171, 1.15064891, 0.8222317, 0.66119302, 0.72804759, 0.88032802, 1.3391255, 0.63925354, 0.79383212, 0.90687066, 0.69586907, 0.68069846, 0.69006699, 0.94959428, 0.75916987, 0.73727924, 0.55095965, 0.79689776, 0.80397701, 0.73422704, 0.9370958, 0.76371326, 0.66565853, 0.6708945, 0.76248368, 0.58984395, 0.69364698, 0.71571205, 0.92289406, 0.89340239, 1.06406147, 0.81177578, 0.7188162, 0.78183528, 0.64441378, 0.68018412, 1.4021663, 0.74996672, 0.74679628]) Topic 0: a documents of in vectors to and feature correspond are Topic 1: as follows: feature and vectors estimating function words). using Rather Topic 2: a of as be follows: topics infers algorithm documents. thought
{"Source-Url": "https://www.ee.columbia.edu/~cylin/course/bigdata/big_data_tutorial_w5_hw2.pdf", "len_cl100k_base": 6175, "olmocr-version": "0.1.50", "pdf-total-pages": 30, "total-fallback-pages": 0, "total-input-tokens": 29440, "total-output-tokens": 7914, "length": "2e12", "weborganizer": {"__label__adult": 0.0003292560577392578, "__label__art_design": 0.0012969970703125, "__label__crime_law": 0.0004267692565917969, "__label__education_jobs": 0.0036067962646484375, "__label__entertainment": 0.00030732154846191406, "__label__fashion_beauty": 0.00016820430755615234, "__label__finance_business": 0.0004856586456298828, "__label__food_dining": 0.0003497600555419922, "__label__games": 0.0006937980651855469, "__label__hardware": 0.0012044906616210938, "__label__health": 0.0005016326904296875, "__label__history": 0.00035190582275390625, "__label__home_hobbies": 0.00015854835510253906, "__label__industrial": 0.0004253387451171875, "__label__literature": 0.0005626678466796875, "__label__politics": 0.00037479400634765625, "__label__religion": 0.0003883838653564453, "__label__science_tech": 0.138916015625, "__label__social_life": 0.00030159950256347656, "__label__software": 0.0430908203125, "__label__software_dev": 0.80517578125, "__label__sports_fitness": 0.00026607513427734375, "__label__transportation": 0.00031375885009765625, "__label__travel": 0.00018680095672607425}, "weborganizer_max": "__label__software_dev", "avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_ratio": [[0, 17116, 0.04123]], "fineweb_edu_fasttext_gt2__fineweb_edu_fasttext_gt2__score": [[0, 17116, 0.25155]], "ft_lang_id_en_doc_v2__ft_lang_id_en_doc_v2__en": [[0, 17116, 0.67162]], "google_gemma-3-12b-it_contains_pii": [[0, 133, false], [133, 260, null], [260, 583, null], [583, 670, null], [670, 827, null], [827, 977, null], [977, 1228, null], [1228, 3057, null], [3057, 3496, null], [3496, 3500, null], [3500, 3685, null], [3685, 4406, null], [4406, 6225, null], [6225, 6563, null], [6563, 6827, null], [6827, 7579, null], [7579, 7960, null], [7960, 8291, null], [8291, 8929, null], [8929, 9781, null], [9781, 10143, null], [10143, 10381, null], [10381, 11321, null], [11321, 12243, null], [12243, 12917, null], [12917, 13268, null], [13268, 13917, null], [13917, 14230, null], [14230, 14807, null], [14807, 17116, null]], "google_gemma-3-12b-it_is_public_document": [[0, 133, true], [133, 260, null], [260, 583, null], [583, 670, null], [670, 827, null], [827, 977, null], [977, 1228, null], [1228, 3057, null], [3057, 3496, null], [3496, 3500, null], [3500, 3685, null], [3685, 4406, null], [4406, 6225, null], [6225, 6563, null], [6563, 6827, null], [6827, 7579, null], [7579, 7960, null], [7960, 8291, null], [8291, 8929, null], [8929, 9781, null], [9781, 10143, null], [10143, 10381, null], [10381, 11321, null], [11321, 12243, null], [12243, 12917, null], [12917, 13268, null], [13268, 13917, null], [13917, 14230, null], [14230, 14807, null], [14807, 17116, null]], "google_gemma-3-4b-it_v2tag__is_academic_paper": [[0, 5000, false], [5000, 17116, null]], "google_gemma-3-4b-it_v2tag__is_class_syllabus": [[0, 5000, false], [5000, 17116, null]], "google_gemma-3-4b-it_v2tag__is_completion_certificate": [[0, 5000, false], [5000, 17116, null]], "google_gemma-3-4b-it_v2tag__is_court_notice": [[0, 5000, false], [5000, 17116, null]], "google_gemma-3-4b-it_v2tag__is_homework_assignment": [[0, 5000, false], [5000, 17116, null]], "google_gemma-3-4b-it_v2tag__is_news_article": [[0, 5000, true], [5000, 17116, null]], "google_gemma-3-4b-it_v2tag__is_public_order": [[0, 5000, false], [5000, 17116, null]], "google_gemma-3-4b-it_v2tag__is_resume_cv": [[0, 5000, false], [5000, 17116, null]], "google_gemma-3-4b-it_v2tag__is_test_or_quiz": [[0, 5000, false], [5000, 17116, null]], "google_gemma-3-4b-it_v2tag__is_textbook": [[0, 5000, false], [5000, 17116, null]], "pdf_page_numbers": [[0, 133, 1], [133, 260, 2], [260, 583, 3], [583, 670, 4], [670, 827, 5], [827, 977, 6], [977, 1228, 7], [1228, 3057, 8], [3057, 3496, 9], [3496, 3500, 10], [3500, 3685, 11], [3685, 4406, 12], [4406, 6225, 13], [6225, 6563, 14], [6563, 6827, 15], [6827, 7579, 16], [7579, 7960, 17], [7960, 8291, 18], [8291, 8929, 19], [8929, 9781, 20], [9781, 10143, 21], [10143, 10381, 22], [10381, 11321, 23], [11321, 12243, 24], [12243, 12917, 25], [12917, 13268, 26], [13268, 13917, 27], [13917, 14230, 28], [14230, 14807, 29], [14807, 17116, 30]], "pipe_delimited_lines_v1__pipe_delimited_lines_v1__pipe_delimited_lines_ratio": [[0, 17116, 0.17534]]}
olmocr_science_pdfs
2024-11-28
2024-11-28
d608cb1c5c4720e10463e30ddf7c38b9719a23bb
P4I/O: Intent-Based Networking with P4 Mohammad Riftadi, M.; Kuipers, Fernando DOI 10.1109/NETSOFT.2019.8806662 Publication date 2019 Document Version Accepted author manuscript Published in Proceedings of the 2019 IEEE Conference on Network Softwarization Citation (APA) Important note To cite this publication, please use the final published version (if applicable). Please check the document version above. Abstract—Switches that can be (re)programmed through the network programming language P4 are able to completely change – even while in the field – the way they process packets. While powerful, P4 code is inherently static, as it is written and installed to accommodate a particular network requirement. Writing new P4 code each time new requirements arise may be complex and limits our agility to deal with changes in network traffic and services. In this paper, we present P4I/O, a new approach to data-plane programmability based on the philosophy of Intent-Based Networking. P4I/O provides an intent-driven interface that can be used to install and/or remove P4 programs on the switches when needed and which is easy to use. In particular, to realize P4I/O, we (1) describe an extensible Intent Definition Language (IDL), (2) create a repository of P4 code templates, which are parsed and merged based on the intents, (3) provide a technique to realize the resulting P4 program in a programmable switch, while accommodating intent modifications at any time, and finally (4) implement a proof-of-concept to demonstrate that intent modifications can be done on-the-fly. I. INTRODUCTION Recent advances in data-plane programmability have enabled the implementation of customized high-speed network functions directly into programmable switches. Examples range from performing network telemetry on the switches [1], [2], to fast congestion detection on the data-plane [3], to offloading distributed consensus algorithms to the data-plane [4]. The data-plane abstraction language P4 [5] enables network operators to realize custom network functions without having to tailor to the networking hardware in use. Those hardware details will be taken care of by the compiler. This level of abstraction makes P4 code powerful, yet it is inherently static, because the code would have to be rewritten whenever a new network requirement manifests, which caps our agility in responding to network changes. We are in need of a system that is able to accommodate changes in network requirements and realize them quickly with minimum disruption to any existing services. To this very problem, we present P4I/O, an Intent-Based Networking (IBN) framework that allows users to express their desired network functionality in the form of easy-to-grasp intents, which are subsequently translated into P4 code, as illustrated in Figure 1. We adopt the concept of IBN to shift the network control paradigm from an imperative manner – which requires knowledge of the networking protocols and the network topology – to a declarative manner, allowing users to reap the benefits of data-plane programmability in an intuitive manner. In order to realize P4I/O, in this paper, we present the following key contributions: - **Extensible Intent Definition Language (IDL).** In order to describe various kinds of network services as intents, we devise in §III a high-level language that is close to the human language, yet precise enough to be interpreted unambiguously by the network controller. Furthermore, this language is extensible so that we can define any kind of data-plane functionality. - **Template-Based P4 Code Generation.** We construct a repository of relevant network functions in the form of P4 code templates. These templates are then parsed and represented in a specialized data structure that facilitates combining the network functions, following the intent instructions. The code templates are then finally merged together to form a valid P4 program, as described in §IV. - **Dynamic Intents Realization.** We provide, in §V, a technique to install the resulting P4 code in a programmable switch, while permitting intent modification at any time. We realize intent modifications, with minimal disruption to the traffic forwarding process, through a state-transfer mechanism. - **Framework Evaluation.** In §VI, we demonstrate that P4I/O works, by building a proof-of-concept. P4I/O code has been released as open-source code [6]. II. NETWORK TELEMETRY USE CASES P4I/O can be used for any network function, but to explain its building blocks, we will consider several use cases from the domain of network telemetry. Network telemetry functions provide interesting challenges to solve, because they require a state to be stored in the switch, e.g. in the form of P4 registers [7], along with complex pipeline processing logic to compute the states. We consider the following use cases: (1) Threshold-based Heavy-Hitter (HH) detection, (2) Distributed Denial of Service (DDoS) victim detection, and (3) Super-Spreader (SS) detection, which is the inverse of DDoS detection. All of these use cases are implemented using sketches, in particular Count-Min Sketch [8] and Bitmap [9]. For example, consider use case (1): HH detection is a mechanism to compute whether a packet is part of an HH flow, which we define as a flow that has more than our threshold of $T$ packets. Consequently, the switch must track the number of packets in each flow, while it has very limited memory and processing resources. To effectively make use of the limited resources, we use the Count-Min sketch, which enables our switch to track a virtually unlimited number of flows at the expense of slightly reduced accuracy. Our goal is to run a network in which network functions, such as the described telemetry functions, can be (de)activated at any time by adding/removing intents in the controller. Realizing this goal is challenging, because intent modification translates to the changing of switch pipeline configurations. As each set of network functions has its own requirements for state containers, we must consider the problem of preserving the state from one set of functions to another. Moreover, as the new set of functions might not have the same state containers available, we need a mechanism to manage the unused state values. Finally, we also have to minimize the effect of intent modifications on the traffic forwarding process. The following sections describe how we tackle these issues. III. INTENT DEFINITION LANGUAGE This section discusses the Intent Definition Language (IDL) that is employed to express network intents. We begin by identifying the requirements for such a language and subsequently present a working solution based on extending an existing IDL. A. Requirements While Han et al. [10] claim that there is currently no standardized definition of network intent, they also argue that intent is generally perceived as a business-level goal of how the network should behave, abstracting the implementation details from the operators. Reflecting on this objective, we identify the following requirements to be satisfied by our IDL: Readability. Network operators should be able to intuitively express their intended services with minimum training. We propose to cater to this need by developing a language that is close to a natural language, e.g. English, yet still concise enough to be interpreted unambiguously by the controller. Abstraction. The language should abstract out technical details of the implementation. To realize this, we have to move the details of the implementation to a lower layer. The lower-layer implementation should still be accessible by operators with advanced technical knowledge for debugging purposes. Flexibility. The language should be flexible enough to be extended with any kind of required network functions. This means that we have to design for a modular architecture, which facilitates easy extensions of new network functions. B. Nile Language Extension We employ Nile [11] as the base language for our IDL. Nile is a network intent language with the goal of providing an intermediate layer between a natural language and lower-level policies. In [11], user utterance is processed into a network intent expressed in the Nile language. Nile satisfies our requirements of readability and abstraction, but does not facilitate the import of external module definitions. To that end, we introduce several constructs: 1) import: to define custom actions and import them from the actions repository, 2) apply: to apply the custom action by specifying the name of the action in the intent definition, and 3) with: to provide parameter values required by the custom action. The import construct can be used multiple times to define more than one custom action. The specified action is then executed whenever the specified conditions in the intent definition are satisfied. For example, consider the code snippet in Listing 1. We define a new action named drop_heavy_hitters that performs a threshold-based HH detection, with threshold $T = 20$ packets. The drop_heavy_hitters action is to drop HH flows. This intent applies to all traffic, from any source or destination. Listing 1. Drop Heavy-Hitter Action Example. ```python import drop_heavy_hitters define intent drop_hh_any_any: from endpoint('any') to endpoint('any') for traffic('any') apply drop_heavy_hitters with threshold('more or equal', 20) ``` IV. P4 CODE TEMPLATES In this section, we describe our template-based method for forming P4 code. A knowledgeable party predefines P4 code templates that correspond to specific actions. The code templates are then imported into a special repository in the network controller. To render a template, the controller takes various attributes defined in the intent as inputs. If there is more than one intent or the intent itself is more complex, we may also need to “merge” multiple P4 code templates into one final P4 program. The templates are written in a templating-language that has several constructs that are syntactically distinguishable from the actual text. The constructs act as placeholders that can be populated with string values. This way, the final P4 code can be rendered by populating each placeholder with precomputed string values. We employ Jinja2 [12], one of the most popular templating-languages. Figure 2 (Top and Mid) illustrates the placeholder and its associated rendered code. The \{variable_name\} struct is used as a placeholder for a string named hh_threshold_val. A. Network Telemetry Function Structures The P4 code templates for the majority of network telemetry functions can be built upon the following structures: **Constant Definition.** Integer constants, see Figure 2 (Top and Mid). **Parser Definition.** The state machine to parse the required packet headers. **Metadata Definition.** The metadata fields that are required by the network function to perform its computation. **Packet Identification.** A computation to identify whether a packet belongs to a specified group of traffic (or vice versa). **Packet Manipulation.** In this final phase, actions are taken on the identified traffic. In the P4 language, the possible actions are virtually limitless, but common ones are: count, mark, drop, meter and/or a combination of them. Figure 2 (Bottom) depicts an example for this phase. B. Template Representation In this section, we present a formal data structure to facilitate combining intents and their corresponding P4 code. As the network functions that we are dealing with are logical representations of packet pipeline processing, the data structure should also be able to move from one condition to the next, which is possible via a Directed Acyclic Graph (DAG) that is based on PGA’s [13] graph structure. 1) **Policy Graph Structure:** To help illustrate our graph structure, we use the HH example code in Figure 3. The constant and metadata definitions contain no flow information and therefore are not processed further. The parser definition code can be represented as a directed graph with the vertices representing the packet header names and the edges representing a possible state transfer from one header to another. 2) **Combining Templates:** We proceed to define how several policy graphs can be combined. Each of the phases in §IV-A has different characteristics and should be treated differently. The simplest cases are the constant and metadata definitions. To combine constant and metadata definitions from several intents, we need to make the names unique by prepending each name with a unique text – preferably generated from the intent id number – and then do a string concatenation to combine all of the constant and metadata definitions from various intents together. For the parser graphs, we expect many overlapping nodes coming from several policies, which can be resolved via computing the union of the vertices and the union of the edges from all of the graph policies. The resulting edges and vertices comprise the final graph for the parser. Finally, the identification and manipulation actions are stitched together one after another. Formally, let’s consider two intents \(I_1 := (i_1, m_1)\) and \(I_2 := (i_2, m_2)\), with \((i_n, m_n)\) defined as a sequence of identification and manipulation actions. After the combination, we get the action sequence of Combined := \((i_1, m_1, i_2, m_2)\). 3) **P4 Code Generation:** For the final P4 program, we need another base template that contains placeholders for the aforementioned P4 code structures in §IV-A. This base template represents a valid P4 program with several empty sections, ready to be filled in with the rendered policies. V. INTENT REALIZATION This section starts by defining the software components used to realize the controller and finally discusses how the system handles intent modification. For ease of explanation, we limit the scope of the intent realization to one programmable switch connected to several hosts, but our framework can be extended to intent realization over multiple switches. A. Software Components As depicted in Figure 1, P4I/O consists of the following components: **Intent Parser.** The intent parser parses the intents and stores them in a hierarchical key-value storage intended to be used by the policy builder. **Actions Library.** The actions library acts as a repository for defined actions represented as P4 code templates. It parses the P4 code templates into a policy graph as explained in §IV-B1. **Topology Manager.** The topology manager keeps track of each host connected to the switch portals. The information of which host is connected to which port is used to build a correct P4 match-action table entry required for the packet forwarding process. **Policy Builder.** The policy builder executes the policy graphs join computation as explained in §IV-B2. It outputs the combined policy graph required to generate the final P4 program. **P4 Code Generator.** The P4 code generator has as main objective to generate a working P4 program with the input of a policy graph, as described in §IV-B3. **States Manager.** The states manager keeps track of all match-action table entries that are implemented on the switch. Each time a new P4 program is installed in the switch, the switch will lose all of its old entries and therefore needs to be repopulated by the entries stored in this component. **Switch Controller.** The switch controller is responsible for pushing the generated pipeline configuration file into the switch and maintaining the communication channel to the switch, e.g. via gRPC. This process is done on-the-fly, while the switch is forwarding traffic. ### B. Intent Modification Switch pipeline configuration modification is realized via the interface defined in the P4Runtime specification [14], via the procedure of *SetForwardingPipelineConfig*. By default, each time a BMV2 [15] *simple_switch_grpc* is instructed to load a new pipeline configuration, it will lose all of the match-table entries and all of the other states, e.g. register, counter, meter, etc. We refer to this problem as the state preservation problem. We handle the problem of state preservation by providing two mechanisms: **Match-Table Entries Preservation.** Preservation is done by rewriting the match-action table entries every time a switch pipeline configuration is reloaded. The entries are stored at the States Manager component. **Switch States Preservation.** The states in the switch can be preserved via two approaches: *external* and *internal backup*. **External Backup.** This method does the backup within the internal memory of the switch. As it does not require any external communication, there will be no external communication overhead. However, the switch should have enough memory for the backup and dedicate some computation resources for the states duplication procedure. **Internal Backup.** This method does the backup within the switch memory, or (2) single multiple values are written by passing the whole array in one write procedure. The default *simple_switch_grpc* only supports method (1). For our proof-of-concept, we adopt the internal backup mechanism by developing a custom P4 software switch based on BMV2’s *simple_switch_grpc* that has the functionality to preserve state from one configuration to another. It will first store all of its state to its internal memory. After the new pipeline configuration is enforced, the switch will try to restore the backed-up state, provided the previous state container still exists in the new one. The algorithm for the switch state preservation is depicted in Algorithm 1. This process happens while incoming packets are temporarily stored on an input buffer in the switch. ```plaintext foreach registers ∪ counters ∪ meters ∪ ... do backupState[stateName] ← oldValue; end ENFORCENEWPIPELINECONFIG; foreach element in backupState do if element exists in new pipeline then newValue ← backupState[stateName]; end end ``` **Algorithm 1:** State Transfer Algorithm. --- ![Figure 3. P4 code template translation to a Directed Acyclic Graph (DAG) structure.](image-url) VI. EVALUATION We evaluate the feasibility of P4I/O through a proof-of-concept implementation. Our prototype implementation is written in Python and contains approximately 4,530 lines of code. A. Proof of Concept Setup We define 6 epochs, $t'_0, t'_1, \ldots, t'_5$, to aid us in evaluating intent modifications on P4I/O. In each epoch, different intents are defined. In $t'_0$, we run DDoS and SS detection functions. In $t'_1$, we add one Heavy-Hitter (HH) detection intent, which drops traffic exceeding a threshold of $T = 1800$ packets. In $t'_2$, we remove the SS detection. Further, in $t'_3$ we also remove the HH detection, leaving us with only DDoS detection. We then add back HH detection in $t'_4$, this time with a threshold of $T = 3600$ packets. Finally, in the last epoch of $t'_5$ by removing the HH detection function, effectively leaving DDoS detection as the only running function. We use a simple topology with our modified simple_switch_grpc software switch connected to a traffic generator and a traffic receiver as illustrated in Figure 4. The generator then injects random UDP traffic at 1 mbps. We use a single IP address per sending/receiving side. The topology is run on top of Mininet [16], which in turn runs on top of a Ubuntu Linux 16.04 desktop with a dual-core 1.6 GHz Intel i5 processor and 2GB of RAM. The resources are shared between the host, Mininet, simple_switch_grpc, and P4I/O. B. Result and Discussion Figure 5 depicts the throughput graph as observed from the receiving side. At epoch $t'_0$, the traffic rate is relatively stable until we reach $t'_1$, which temporarily causes a fluctuating rate, due to the actualization of the new P4 code. We can note that at approximately $t = 27s$, the HH threshold $T = 1800$ is reached causing the traffic to be dropped. At epoch $t'_2$, the HH state from the previous epoch is successfully preserved as proven by the absence of traffic. The removal of HH detection network function at the beginning of epoch $t'_3$ gives us back the inbound traffic. Likewise, $t'_4$ also demonstrates the same phenomenon as $t'_1$, but with a twice as long delay before we reach the new threshold of $T = 3600$. Reflecting on this result, we believe that our approach is applicable to real-world use cases. We can conclude that the existing hardware is fast enough to do pipeline configuration modifications with minimum interruption to the traffic forwarding process. While we see some fluctuating throughput rate in the result, it can be explained by the condition of our testbed that performs all computation, e.g. P4 code generation and traffic forwarding, in a single machine. VII. RELATED WORK Programmable Network. Pyretic [17] allows building network services by means of network programmability. However, their approach to the network programming language is of imperative nature. PGA [13] addresses the problem of network policies reconciliation, i.e. aligning overlapping/conflicting policies, by devising a graph abstraction that inspires our DAG abstraction. PGA is implemented as an extension of Pyretic. Janus [18] extends the work of PGA by adding the notion of dynamic policies and incorporating QoS constraints. Janus’ implementation is also based on Pyretic. Intent-Based Networking. Nile [11] provides a human-readable IDL for implementing network services and is focused on translating user utterance into an IDL and incorporating user feedback to improve the translation model. Marple [1] and Sonata [2] generate pipeline configurations – also in P4 – from dynamic queries, but do not focus on the technique for generating the code. Moreover, they do not consider the problem of intent modification on-the-fly. Donovan & Feamster [19] propose the notion of intention-based monitoring, which offloads the task of matching traffic to the data-plane. Their Pyretic-based implementation matches traffic based on attributes with static mapping like domain name and AS number. Sketch-Based Network Telemetry. OpenSketch [20] utilizes sketches for various flow measurement tasks. However, their implementation is on NetFPGA, which provides no mechanism to reload the switch pipeline configuration on-the-fly. UnivMon [21] contests OpenSketch’s approach by proposing a universal sketch algorithm adopted from universal stream theory. UnivMon focuses on evaluating the performance and memory utilization of the universal sketch. VIII. CONCLUSION In this paper, we have presented P4I/O, an intent-based networking framework that facilitates a simple adoption of P4 data-plane programmability. Through P4I/O, programmable switches can be quickly and easily programmed, without having to code in P4. In order to build P4I/O, we have described an extensible Intent Definition Language, used a P4 code template approach, and enabled intent modifications on-the-fly. We have made an open-source Proof-of-Concept implementation of P4I/O, with which we have demonstrated that intents can indeed be installed/removed in the field. REFERENCES Figure 5. Throughput as observed from the receiving side in various epochs.
{"Source-Url": "https://pure.tudelft.nl/ws/portalfiles/portal/55614866/P4IO.pdf", "len_cl100k_base": 4858, "olmocr-version": "0.1.53", "pdf-total-pages": 7, "total-fallback-pages": 0, "total-input-tokens": 22905, "total-output-tokens": 5566, "length": "2e12", "weborganizer": {"__label__adult": 0.0005178451538085938, "__label__art_design": 0.0003044605255126953, "__label__crime_law": 0.0004868507385253906, "__label__education_jobs": 0.00042939186096191406, "__label__entertainment": 0.00017595291137695312, "__label__fashion_beauty": 0.0002073049545288086, "__label__finance_business": 0.00031280517578125, "__label__food_dining": 0.0004887580871582031, "__label__games": 0.0007648468017578125, "__label__hardware": 0.00730133056640625, "__label__health": 0.000950336456298828, "__label__history": 0.00034236907958984375, "__label__home_hobbies": 0.0001283884048461914, "__label__industrial": 0.0009708404541015624, "__label__literature": 0.00027871131896972656, "__label__politics": 0.0003273487091064453, "__label__religion": 0.0006508827209472656, "__label__science_tech": 0.263427734375, "__label__social_life": 0.0001214742660522461, "__label__software": 0.023193359375, "__label__software_dev": 0.69677734375, "__label__sports_fitness": 0.0004668235778808594, "__label__transportation": 0.0010738372802734375, "__label__travel": 0.0002751350402832031}, "weborganizer_max": "__label__software_dev", "avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_ratio": [[0, 24231, 0.0228]], "fineweb_edu_fasttext_gt2__fineweb_edu_fasttext_gt2__score": [[0, 24231, 0.31861]], "ft_lang_id_en_doc_v2__ft_lang_id_en_doc_v2__en": [[0, 24231, 0.89614]], "google_gemma-3-12b-it_contains_pii": [[0, 804, false], [804, 4743, null], [4743, 10275, null], [10275, 15558, null], [15558, 18685, null], [18685, 24156, null], [24156, 24231, null]], "google_gemma-3-12b-it_is_public_document": [[0, 804, true], [804, 4743, null], [4743, 10275, null], [10275, 15558, null], [15558, 18685, null], [18685, 24156, null], [24156, 24231, null]], "google_gemma-3-4b-it_v2tag__is_academic_paper": [[0, 5000, true], [5000, 24231, null]], "google_gemma-3-4b-it_v2tag__is_class_syllabus": [[0, 5000, false], [5000, 24231, null]], "google_gemma-3-4b-it_v2tag__is_completion_certificate": [[0, 5000, false], [5000, 24231, null]], "google_gemma-3-4b-it_v2tag__is_court_notice": [[0, 5000, false], [5000, 24231, null]], "google_gemma-3-4b-it_v2tag__is_homework_assignment": [[0, 5000, false], [5000, 24231, null]], "google_gemma-3-4b-it_v2tag__is_news_article": [[0, 5000, false], [5000, 24231, null]], "google_gemma-3-4b-it_v2tag__is_public_order": [[0, 5000, false], [5000, 24231, null]], "google_gemma-3-4b-it_v2tag__is_resume_cv": [[0, 5000, false], [5000, 24231, null]], "google_gemma-3-4b-it_v2tag__is_test_or_quiz": [[0, 5000, false], [5000, 24231, null]], "google_gemma-3-4b-it_v2tag__is_textbook": [[0, 5000, false], [5000, 24231, null]], "pdf_page_numbers": [[0, 804, 1], [804, 4743, 2], [4743, 10275, 3], [10275, 15558, 4], [15558, 18685, 5], [18685, 24156, 6], [24156, 24231, 7]], "pipe_delimited_lines_v1__pipe_delimited_lines_v1__pipe_delimited_lines_ratio": [[0, 24231, 0.0]]}
olmocr_science_pdfs
2024-12-07
2024-12-07
8f801f2575dec4cb24005122fd1835505988225e
Environment Mapping using the Lego Mindstorms NXT and leJOS NXJ Gerardo Oliveira¹, Ricardo Silva¹, Tiago Lira¹, Luis Paulo Reis¹,² ¹ FEUP – Faculdade de Engenharia da Universidade do Porto, Portugal ² LIACC – Laboratório de Inteligência Artificial e Ciência de Computadores da Universidade do Porto, Portugal Rua Dr. Roberto Frias, s/n 4200-465 Porto, Portugal {ei04106, ei03087, ei04085, lpreis}@fe.up.pt Abstract. This paper presents a project of simultaneous localization and mapping (SLAM) of an indoor environment focusing on the use of autonomous mobile robotics. The developed work was implemented using the Lego Mindstorms NXT platform and leJOS NXJ as the programming language. The NXJ consists of an open source project which uses a tiny Java Virtual Machine (JVM) and provides a very powerful API as well the necessary tools to upload code to the NXT brick. In addition, the leJOS NXJ enables efficient programming and easiness of communication due to its support of Bluetooth technology. Thus, exploiting the mobile robotics platform flexibility plus the programming language potential, our goals were successfully achieved by implementing a simple subsumption architecture and using a trigonometry based approach, in order to obtain a mapped representation of the robot's environment. Keywords: Lego Mindstorms, NXT, leJOS, NXJ, Java, Robotics, Mapping, Subsumption Architecture, Behavior-Based, Client-Server. 1 Introduction One of the major problems in the field of robotics is known as SLAM (Simultaneous Localization and Mapping) [3], consisting of a technique used by robots and autonomous vehicles to build up a map within an unknown environment while at the same time keeping track of their current position. This is not as straightforward as it might sound due to inherent uncertainties in discerning the robot's relative movement from its various sensors. Thus, the elaboration of a project in this area has proved to be highly motivating for us since “solving” a SLAM problem is considered a notable achievement of the robotics research. The robotic platform chosen for this project is the Lego Mindstorms NXT [4], a major improvement over their previous platform, the RCX [5]. It contains a more powerful processor, more memory, and employs enhanced sensor and actuator suites, therefore being considered the easiest way to enter in the robotics world. For programming the NXT robot we decided to use leJOS [1, 6, 16, 17, 18], a firmware replacement for Lego Mindstorms programmable bricks, considered by many as the best platform in the moment to use software engineering ideas. The NXT brick is supported by leJOS NXJ [7], a project that includes a Java Virtual Machine (JVM) [8], so allows Lego Mindstorms robots to be programmed in the Java programming language. The leJOS platform proved to be the best choice for this project since it provides extensive class libraries that support various interesting higher-level functions such as navigation and behavior-based robotics, therefore simplifying the task of robotic piloting through the implementation of a subsumption architecture [9]. Also the API [10] support for the Bluetooth technology was essential in this work since we also implemented a client-server architecture, using the NXT robot as server and sending information to a client application via Bluetooth. Therefore, the whole logic is hosted and executed by the robot, which exchanges information with the client application, running on a computer. The data sent by the NXT is then processed and used in the environment map building. In order to present the work developed for this project, this paper is organized as follows: Initially, in Sections 2 and 3 the hardware and software platforms are detailed, which is the Lego Mindstorms NXT and the leJOS NXJ, correspondingly. In Section 4 we give an overview of the architectures behind the developed robotic agent, namely the subsumption and client-server architectures. Section 5 details the environment mapping procedures that were used. Finally, in Sections 6 and 7, we give details about the tests we ran and their results, stating the conclusions we achieved and thereby concluding the article. 2 Lego Mindstorms NXT Lego Mindstorms NXT is a programmable robotics kit released by Lego in late July 2006. The NXT is the brain of a Mindstorms robot. It's an intelligent, computer controlled Lego brick that lets a Mindstorms robot come alive and perform different operations. ![Fig. 1. The Lego Mindstorms NXT. In the center, the NXT brick 1. Above, the three servo motors 6. Below, the four sensors: touch 2, sound 3, light 4 and ultrasonic 5.](image) The NXT has three output ports for attaching motors – Ports A, B and C and four input ports for attaching sensors – Ports 1, 2, 3 and 4. It’s possible to connect a USB cable to the USB port and download programs from a computer to the NXT (or upload data from the robot to the computer). As an alternative the wireless Bluetooth connection can be used for uploading and downloading. In the specific case of our project we simply needed two motors (connected at ports A and C), but we used all the input ports for sensors (Ultrasonic Sensor – port 1, HiTechnic [20] Compass Sensor – port 2, HiTechnic Color Sensor – port 3, Sound Sensor – port 4). 3 leJOS NXJ The name leJOS was conceived by José Solórzano, based on the acronym for Java Operating System (JOS), the name of another operating system for the RCX, legOS, and the Spanish word "lejos". The leJOS NXJ [7] is a project to develop a Java Virtual Machine (JVM) for Lego Mindstorms NXT, as a replacement of the original firmware of the NXT brick, thereby allowing the NXT robots to be programmed in the Java programming language, providing extensive class libraries that support various interesting higher level functions such as navigation and behavior based robotics. Started out as a hobby open source project, by José Solórzano in late 1999, the leJOS NXJ has been evolving along the time with new features. Currently leJOS Research Team has launched the release 0.7, available for both Microsoft Windows and Linux/Mac OS X operating systems. This version includes a Windows installer to make installation a breeze for new users. Also, in order to facilitate the tasks of uploading the latest firmware into the NXT brick, uploading NXJ programs to the NXT brick and converting any Java project into NXT project, the leJOS Research Team developed a plug-in for the Eclipse IDE [11], which turn these tasks into a children’s play. From our personal experience with the leJOS NXJ platform, it proved to be an excellent choice, not only for this work, but for any kind of robotic projects using the Lego Mindstorms NXT [1], because of all the offers of the leJOS NXJ, like its preemptive threads, synchronization, multi-dimensional arrays and its well-documented robotics API, for example. 4 Architecture In this project we made use of two software architectures: subsumption and client-server architectures, which are subsequently detailed. Subsumption architecture is a methodology for developing artificial intelligence robots. It is heavily associated with behavior-based robotics. The term was introduced by Brooks [2] (1991), which enforces a hierarchy among behaviors so that some of them in certain conditions would inhibit other lower priority ones. A subsumption architecture is a way of decomposing complicated intelligent behavior into many “simple” behavior modules, which are in turn organized into layers. Each layer implements a particular goal of the agent, and higher layers are increasingly more abstract. Each layer’s goal subsumes that of the underlying layers. As opposed to more traditional artificial intelligence approaches, subsumption architecture uses a bottom-up design. The choice of this architecture allowed us to address each type of action independently in different behaviors and give them a set priority. This allows for more organized and alterable code, and avoids problems in the interaction between the different behaviors. In order to make a better research work, we approached the mapping problem in two fronts, both using a subsumption architecture. Basically one using the compass sensor and another without using it, where calculations are based on the initial position of the robot and its following movements. For the first approach mentioned above, we used the subsumption architecture to implement a basic navigation mechanism by developing a lowest layer “obstacle avoidance”, which corresponds to the rotate (turn around its center) and retreat (drive backward) behaviors, and on top of it lays the “environment exploration” layer, implemented by a drive forward behavior. Each of these horizontal layers access all of the sensor data and generate actions for the actuators – the main caveat is that separate tasks can suppress (or overrule) inputs or inhibit outputs. This way, the lowest layers can work like fast-adapting mechanisms (e.g. reflexes), while the higher layers work to achieve the overall goal. Feedback is given mainly through the environment. ![Fig. 2. Representation of the subsumption architecture implemented for the first approach. “Retreat” and “Rotate” correspond to the layer “Obstacle Avoidance” and the “Environment Exploration” is implemented by the “Drive Forward” behavior.](image) For the second approach, we applied a subsumption architecture also based on the sensor read values, but this time the behaviors are more independent, given that even a behavior with a lower priority will end its turn before another takes place. This happens because the conditions that decide the change of behavior are calculated in the end of that behavior. All the measures and calculations are merged in order to map the environment with all the data collected by that time. This approach has two main behaviors, the Measure behavior and the Navigate behavior. When on the Measure behavior, the robot rotates 360 degrees and at the same time it measure the distances given by the sonar sensor on the four quadrants. When on the Navigate behavior, the robot drive forward a previous defined distance (for our tests we used distance = 30 units, where each unit correspond to a unit given by the sonar sensor). This way, when we join these two behaviors we get a step-by-step very reasonable map. ![Diagram](image) **Fig. 3.** Representation of the sumbsumption architecture implemented for the second approach. “Measure” and “Navigate” complement each other even if “Measure” has priority over “Navigate”. This kind of architecture (subsumption) could be implemented by the packages provided by the leJOS NXJ, which has an interface (Behavior) and a class (Arbitrator) to control the whole process: **lejos.subsumption.Behavior** An interface that represents an object embodying a specific behavior belonging to a robot. Each behavior must define the following three methods: - boolean takeControl() Returns a boolean value to indicate if this behavior should become active. For example, if the ultrasonic sensor indicates the robot is too close to an object, this method should return true. - void action() The code in this method initiates an action when the behavior becomes active. For example, if takeControl() detects the robot is too close to an object, the action() code could make the robot rotate and turn away from the object. - void suppress() The code in the suppress() method should immediately terminate the code running in the action() method. The suppress() method can also be used to update any data before this behavior completes. **lejos.subsumption.Arbitrator** The arbitrator regulates which behaviors should be activated, once all the behaviors are defined. The client-server architecture model distinguishes client systems from server systems, which communicate over a computer network. A client-server application is a distributed system comprising both client and server software. Thereby, given the fact that the robot doesn’t have a great capacity for data processing, not all the calculations were made by the server (NXT brick). In our approaches we needed to send some sensorial data and processed data for a computer client application to better analyze and expose that information. The nature of that data focus on the orientation angle of the robot (obtained with the compass sensor), the distances to the obstacles (acquired by the ultrasonic sensor) and the values of a matrix representing what it “sees”, that the robot keeps updating. This process of data exchange between different applications was implemented using the leJOS NXJ, via the Bluetooth wireless protocol. ![Fig. 4. The client-server architecture used for communication, by means of the Bluetooth wireless protocol, between the computer application (client) and the NXT brick (server).](image) While the client server offered a wide range of possibilities, as remote controlled commands for example, we chose to keep the robot as autonomous as possible. Therefore this architecture was used only as a means of reporting observational data to the computer for visualization. ## 5 Environment Mapping Robotic mapping [12] has been extensively studied since the 1980s. Mapping can be classified as either metric or topological. A metric approach is one that determines the geometric properties of the environment, while a topological approach is one that determines the relationships of locations of interest in the environment. Mapping can also be classified as either world-centric or robot-centric. World-centric mapping represents the map relative to some fixed coordinate system, while robot-centric mapping represents the map relative to the robot. Robotic mapping continues to be an active research area. The environment mapping with the Lego Mindstorms NXT discussed in this paper uses a metric, world-centric approach, in order to use the simplest possible mapping algorithm. As described earlier in this document, the robot moves forward from a known starting point until it detects an obstacle with its ultrasonic sensor which is simply avoided by rotating over itself or by driving backward if too close to the object. While doing this exploration of the robot’s environment, the NXT brick uses a 80x80 matrix as the representation of the world. A matrix with this dimension covers about 4x4 meters of real terrain, allowing for a more detailed representation of small spaces, while simultaneously maintaining a reasonable size that the limited memory of the robot can support. At the same time, while doing its internal mapping, the NXT transmits its traveled distance (determined with the help of the motors tachometers) and orientation data (obtained with the compass sensor) to the client application running on a computer. Therefore, our map is built on the robot in runtime, while exploring the world and simultaneously on the client program, since it allows for a much richer map representation than the NXT display. For the measuring of its own position, the robot registers the value of the tachometers and the direction angle from the compass. In each movement the compass value is frequently updated in an attempt to reduce odometry errors. As the tachometers are much more precise than the compass, this allows the robot to have a reasonable precision in estimating its current location. Our approach to environment mapping was to use the NXT sensorial data to calculate the absolute position of obstacles. The robot has knowledge of its starting positions and then uses simple trigonometry to calculate its absolute positions and orientations. ![Fig. 5. Representation of the principle used for determining the absolute position of obstacles. In this right triangle: \( \sin A = a/c; \cos A = b/c \).](image) With a bit of trigonometry, the absolute position of the detected obstacles can be calculated by using the sine and the cosine trigonometric functions, therefore resulting on the following expressions to determine the \( x \) (1) e \( y \) (2) coordinates of a certain obstacle, given the \( x_i \) and \( y_i \) coordinates from the previous robot position as well as the traveled distance (\( distance \)) and orientation (\( \alpha \)) of the robot. \[ x = x_i + distance \times \cos \alpha. \tag{1} \] \[ y = y_i + distance \times \sin \alpha. \tag{2} \] Thus, the program builds an environment map by calculating the absolute position of obstacles using trigonometry, robot ultrasonic sensor readings and previous calculations of absolute robot positions and orientations. These calculations allow for sweeping an area, as the robot rotates, in each iteration marking the walls and free spaces in that direction. Still, the distance sensor and the compass are relatively imprecise, and their results are often mistaken. To make the best of these readings, we used a system of probabilistic mapping based on the Bayes method. In blunt the calculated value is the probability of having a free space in a determined point of the matrix. A low value means high probability of there being an obstacle, while a high value represents a elevated probability of having walkable terrain. Each time a position is tested, the old value is combined with a new one to make an average probability (2). This new value conveys the probability of having a free space or an obstacle, and is relative to the distance. If a position has no valid value in it, it means that position has never been tested before, so we can’t use the previous value to calculate the new one. In that case we use a formula where the probability of being occupied is assumed previously (1). We logically defined that the probability of being occupied equals the probability of not being occupied. \[ P(H|s) = \frac{(P(s|H) \times P(H))}{(P(s|H) \times P(H) + P(s|\neg H) \times P(\neg H))}. \] (3) \[ P(H|s_n) = \frac{(P(s_n|H) \times P(H|s_{n-1}))}{(P(s_n|H) \times P(H|s_{n-1}) + P(s_n|\neg H) \times P(\neg H|s_{n-1}))}. \] (4) These formulas gave satisfactory results and were therefore chosen to be the final method. In practice it allows us to take into account diverse factors like distance, repetition of results, and softening of reading errors, resulting in a well balanced and flexible representation of the map. Additionally, while the robot is designed for static environments, probabilistic mapping allows it to dynamically react to changes in the environment, like adding obstacles or opening new paths. All these calculations are adapted to be processed on the very limited resources of the robot, which then communicates the final result to the client computer via Bluetooth, for real-time visualization of the mapping process. 6 Results Despite its limited sensors, the robotic agent is able to create a sufficiently realistic map of its environment. Fig. 6. Example of an environment map representation. In the left side, the real environment and in the right side the map obtained by the first approach. To exemplify the mapping capabilities of our agent, we have some results of the MapViewer implemented on the client side, displayed in figure 6. For the first approach, the compass sensor is easily affected by magnetic fields of nearby objects, and this can lower the quality of the mapping in some places. Another fact that limits this approach is the complexity of coordinate all the movements and all the angles that the robot (compass sensor) can read, since the robot, in this approach can walk to every side in 360 degrees. If the robot gets a wrong read of the compass, it will mark the corresponding position with a wrong value too and walk to a certain position thinking it is another. Each of the small squares in the visualization window represent a position of the matrix, corresponding to roughly 4.3 centimeters of real terrain in its side. The red points correspond to the trajectory of the robot. The rest represent the probability of obstacles at each position. Orange means high probability of free space, decreasing into shades of yellow. White means a 50% probability of free space, while lower probabilities (probable walls), are represented in shades of gray. Increasingly darker grays, represent greater certainty in the position of the walls. In general, orange and black spaces will dominate the areas that the robot has seen repeatedly or at a close distance, indicating the parts of the map where risk of error is lowest. However, our second approach, while being less flexible, works without using the compass, and therefore has no problem in the aforementioned situation. This way we get none of the problems that the compass brings, but we also don’t get the advantages, so if the robot rotates too much it will not know and all the following values and map representation will not take in account that error. However, if the robot keeps its navigation almost without errors, a nice and pretty realistic map will be the result of our second approach. ![Fig. 7. Example of an environment map representation. In the left side, the real environment and in the right side the map obtained by the second approach.](image-url) In this approach, we used different measures and colors to specify the probabilities. Here, each square represent 10 units, where each unit correspond to a unit measured by the sonar sensor. The green spot is the initial position and the red one is the actual position. The brighter zones correspond to locals where the probability of being empty is high (white and brighter blues), while the darker zones correspond to the occupied places (dark cyan to black). ![Fig. 8. Example of an environment map representation. In the left side, the map obtained by the first approach, in the middle, the real environment and in the right side the map obtained by the second approach.](image) While we are satisfied with the results, we realize that they could be vastly improved by using more powerful sonar and compass sensors. The fact of having only one sonar vastly reduces the capacity of analyzing correctly the directions that should be taken when facing an obstacle and the real distances to them or to walls. Another difficulty was the compass errors. Even though the compass often gives good results, a bad read causes a wrong interpretation and correspondingly a false representation of the map. 7 Conclusions Environment mapping for real robots is a complicated problem, as the system resources are limited and the operation of physical parts (motors and sensors) is highly susceptible to errors and imprecision. The inherent uncertainties in discerning the robot's relative movement from its various sensors turn mapping into a very complex and challenging task. As a matter of fact, a robot can be compared to an insect, for which the environment is not interpreted as a map, and they survive only with a triggered response (e.g. reflexes). Therefore, it was our goal to provide the robot with intelligence in order to combine the information from the past and the present, thus creating a good mapping algorithm, and fortunately we achieved that. One factor that has contributed to our success was the flexibility of the Lego Mindstorms NXT platform associated with the potential of the leJOS API, which allowed us to program the NXT in the Java programming language, thereby giving us much more control over the robot’s sensors and actuators, manifesting itself by a more powerful programming than the one given by the original NXT-G [13] software that Lego provides. The probabilistic mapping method based on the Bayes’ rule proved to be a serious improvement, allowing for flexibility in the creation of the map. The variation of probabilities softens the erratic results, progressively creating a better map. The two approaches we used allowed us to have different processes of solving a map, and each is advantageous in a certain set of conditions. The first approach is more flexible and gives more detailed results, while the second one is more stable and less sensitive to sensor errors. As future work, since one of the biggest troubles while trying to “solve” a SLAM problem are the inaccuracies associated with the measured distance and direction travelled, then any features being added to the map will contain corresponding errors. In this manner, if not corrected, these positional errors build cumulatively, grossly distorting the map and therefore the robot's ability to know its precise location. Thus, it would be interesting, in this project’s concern to study techniques to compensate for this, such as recognizing features that it has come across previously and re-skewing recent parts of the map to make sure the two instances of that feature become one. The application in our project of other statistical techniques, such as Kalman filters [14, 19] or Monte Carlo methods [15], for instance, would definitely improve our work. Acknowledgments This research was supported by the Portuguese Science and Technology Foundation (FCT) under the project "ACORD – Adaptative Coordination of Robotic Teams" (PTDC/EIA/70695/2006), funded through the POCI/FEDER program. References 5. The LEGO Group, Lego Mindstorms RCX, Available at: http://en.wikipedia.org/wiki/Lego_Mindstorms#RCX 6. Jose Solorzano, “leJOS: Java for LEGO Mindstorms”, Available at: http://lejos.sourceforge.net/ 11. The Eclipse Foundation, Eclipse IDE, Available at: http://www.eclipse.org/
{"Source-Url": "https://paginas.fe.up.pt/~ei04106/personal/public/files/Paper.pdf", "len_cl100k_base": 5289, "olmocr-version": "0.1.42", "pdf-total-pages": 12, "total-fallback-pages": 0, "total-input-tokens": 23429, "total-output-tokens": 6511, "length": "2e12", "weborganizer": {"__label__adult": 0.0005135536193847656, "__label__art_design": 0.0010061264038085938, "__label__crime_law": 0.0007128715515136719, "__label__education_jobs": 0.0013284683227539062, "__label__entertainment": 0.00012052059173583984, "__label__fashion_beauty": 0.00024819374084472656, "__label__finance_business": 0.00028824806213378906, "__label__food_dining": 0.00045943260192871094, "__label__games": 0.0010318756103515625, "__label__hardware": 0.005199432373046875, "__label__health": 0.0009288787841796876, "__label__history": 0.0005960464477539062, "__label__home_hobbies": 0.0004239082336425781, "__label__industrial": 0.0014486312866210938, "__label__literature": 0.0003535747528076172, "__label__politics": 0.0002810955047607422, "__label__religion": 0.0005574226379394531, "__label__science_tech": 0.41748046875, "__label__social_life": 0.00016880035400390625, "__label__software": 0.01108551025390625, "__label__software_dev": 0.55322265625, "__label__sports_fitness": 0.0005540847778320312, "__label__transportation": 0.0016326904296875, "__label__travel": 0.00029730796813964844}, "weborganizer_max": "__label__software_dev", "avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_ratio": [[0, 27739, 0.02468]], "fineweb_edu_fasttext_gt2__fineweb_edu_fasttext_gt2__score": [[0, 27739, 0.70629]], "ft_lang_id_en_doc_v2__ft_lang_id_en_doc_v2__en": [[0, 27739, 0.90344]], "google_gemma-3-12b-it_contains_pii": [[0, 2384, false], [2384, 4662, null], [4662, 7481, null], [7481, 10034, null], [10034, 11797, null], [11797, 14330, null], [14330, 16782, null], [16782, 19061, null], [19061, 21559, null], [21559, 23843, null], [23843, 26710, null], [26710, 27739, null]], "google_gemma-3-12b-it_is_public_document": [[0, 2384, true], [2384, 4662, null], [4662, 7481, null], [7481, 10034, null], [10034, 11797, null], [11797, 14330, null], [14330, 16782, null], [16782, 19061, null], [19061, 21559, null], [21559, 23843, null], [23843, 26710, null], [26710, 27739, null]], "google_gemma-3-4b-it_v2tag__is_academic_paper": [[0, 5000, true], [5000, 27739, null]], "google_gemma-3-4b-it_v2tag__is_class_syllabus": [[0, 5000, false], [5000, 27739, null]], "google_gemma-3-4b-it_v2tag__is_completion_certificate": [[0, 5000, false], [5000, 27739, null]], "google_gemma-3-4b-it_v2tag__is_court_notice": [[0, 5000, false], [5000, 27739, null]], "google_gemma-3-4b-it_v2tag__is_homework_assignment": [[0, 5000, false], [5000, 27739, null]], "google_gemma-3-4b-it_v2tag__is_news_article": [[0, 5000, false], [5000, 27739, null]], "google_gemma-3-4b-it_v2tag__is_public_order": [[0, 5000, false], [5000, 27739, null]], "google_gemma-3-4b-it_v2tag__is_resume_cv": [[0, 5000, false], [5000, 27739, null]], "google_gemma-3-4b-it_v2tag__is_test_or_quiz": [[0, 5000, false], [5000, 27739, null]], "google_gemma-3-4b-it_v2tag__is_textbook": [[0, 5000, false], [5000, 27739, null]], "pdf_page_numbers": [[0, 2384, 1], [2384, 4662, 2], [4662, 7481, 3], [7481, 10034, 4], [10034, 11797, 5], [11797, 14330, 6], [14330, 16782, 7], [16782, 19061, 8], [19061, 21559, 9], [21559, 23843, 10], [23843, 26710, 11], [26710, 27739, 12]], "pipe_delimited_lines_v1__pipe_delimited_lines_v1__pipe_delimited_lines_ratio": [[0, 27739, 0.0]]}
olmocr_science_pdfs
2024-11-22
2024-11-22
eb552535714d85f5c2e56913109d8134d1486a17
Use of Formal Methods at Amazon Web Services Chris Newcombe, Tim Rath, Fan Zhang, Bogdan Munteanu, Marc Brooker, Michael Deardeuff Amazon.com 29th September, 2014 Since 2011, engineers at Amazon Web Services (AWS) have been using formal specification and model checking to help solve difficult design problems in critical systems. This paper describes our motivation and experience, what has worked well in our problem domain, and what has not. When discussing personal experiences we refer to authors by their initials. At AWS we strive to build services that are simple for customers to use. That external simplicity is built on a hidden substrate of complex distributed systems. Such complex internals are required to achieve high availability while running on cost-efficient infrastructure, and also to cope with relentless rapid business growth. As an example of this growth; in 2006 we launched S3, our Simple Storage Service. In the 6 years after launch, S3 grew to store 1 trillion objects [1]. Less than a year later it had grown to 2 trillion objects, and was regularly handling 1.1 million requests per second [2]. S3 is just one of tens of AWS services that store and process data that our customers have entrusted to us. To safeguard that data, the core of each service relies on fault-tolerant distributed algorithms for replication, consistency, concurrency control, auto-scaling, load balancing, and other coordination tasks. There are many such algorithms in the literature, but combining them into a cohesive system is a major challenge, as the algorithms must usually be modified in order to interact properly in a real-world system. In addition, we have found it necessary to invent algorithms of our own. We work hard to avoid unnecessary complexity, but the essential complexity of the task remains high. High complexity increases the probability of human error in design, code, and operations. Errors in the core of the system could cause loss or corruption of data, or violate other interface contracts on which our customers depend. So, before launching such a service, we need to reach extremely high confidence that the core of the system is correct. We have found that the standard verification techniques in industry are necessary but not sufficient. We use deep design reviews, code reviews, static code analysis, stress testing, fault-injection testing, and many other techniques, but we still find that subtle bugs can hide in complex concurrent fault-tolerant systems. One reason for this problem is that human intuition is poor at estimating the true probability of supposedly ‘extremely rare’ combinations of events in systems operating at a scale of millions of requests per second. “To a first approximation, we can say that accidents are almost always the result of incorrect estimates of the likelihood of one or more things.” - C. Michael Holloway, NASA [3] That human fallibility means that some of the more subtle, dangerous bugs turn out to be errors in design; the code faithfully implements the intended design, but the design fails to correctly handle a particular ‘rare’ scenario. We have found that testing the code is inadequate as a method to find subtle errors in design, as the number of reachable states of the code is astronomical. So we looked for a better approach. **Precise Designs** In order to find subtle bugs in a system design, it is necessary to have a precise description of that design. There are at least two major benefits to writing a precise design; the author is forced to think more clearly, which helps eliminate ‘plausible hand-waving’, and tools can be applied to check for errors in the design, even while it is being written. In contrast, conventional design documents consist of prose, static diagrams, and perhaps pseudo-code in an ad hoc untestable language. Such descriptions are far from precise; they are often ambiguous, or omit critical aspects such as partial failure or the granularity of concurrency (i.e. which constructs are assumed to be atomic). At the other end of the spectrum, the final executable code is unambiguous, but contains an overwhelming amount of detail. We needed to be able to capture the essence of a design in a few hundred lines of precise description. As our designs are unavoidably complex, we needed a highly expressive language, far above the level of code, but with precise semantics. That expressivity must cover real-world concurrency and fault-tolerance. And, as we wish to build services quickly, we wanted a language that is simple to learn and apply, avoiding esoteric concepts. We also very much wanted an existing ecosystem of tools. In summary, we were looking for an off-the-shelf method with high return on investment. We found what we were looking for in TLA+ [4], a formal specification language. TLA+ is based on simple discrete math, i.e. basic set theory and predicates, with which all engineers are familiar. A TLA+ specification describes the set of all possible legal behaviors (execution traces) of a system. We found it helpful that the same language is used to describe both the desired correctness properties of the system (the ‘what’), and the design of the system (the ‘how’). In TLA+, correctness properties and system designs are just steps on a ladder of abstraction, with correctness properties occupying higher levels, systems designs and algorithms in the middle, and executable code and hardware at the lower levels. TLA+ is intended to make it as easy as possible to show that a system design correctly implements the desired correctness properties, either via conventional mathematical reasoning, or more easily and quickly by using tools such as the TLC model checker [5], a tool which takes a TLA+ specification and exhaustively checks the desired correctness properties across all of the possible execution traces. The ladder of abstraction also helps designers to manage the complexity of real-world systems; the designer may choose to describe the system at several ‘middle’ levels of abstraction, with each lower level serving a different purpose, such as understanding the consequences of finer-grain concurrency, or more detailed behavior of a communication medium. The designer can then verify that each level is correct with respect to a higher level. The freedom to easily choose and adjust levels of abstraction makes TLA+ extremely flexible. At first, the syntax and idioms of TLA+ are somewhat unfamiliar to programmers. Fortunately, TLA+ is accompanied by a second language called PlusCal which is closer to a C-style programming language, but much more expressive as it uses TLA+ for expressions and values. In fact, PlusCal is intended to be a direct replacement for pseudo-code. Several engineers at Amazon have found they are more productive in PlusCal than TLA+. However, in other cases, the additional flexibility of plain TLA+ has been very useful. For many designs the choice is a matter of taste, as PlusCal is automatically translated to TLA+ with a single key press. PlusCal users do need to be familiar with TLA+ in order to write rich expressions, and because it is often helpful to read the TLA+ translation to understand the precise semantics of a piece of code. Also, tools such as the TLC model checker work at the TLA+ level. The Value of Formal Methods for ‘Real-world Systems’ In industry, formal methods have a reputation of requiring a huge amount of training and effort to verify a tiny piece of relatively straightforward code, so the return on investment is only justified in safety-critical domains such as medical systems and avionics. Our experience with TLA+ has shown that perception to be quite wrong. So far we have used TLA+ on 10 large complex real-world systems. In every case TLA+ has added significant value, either finding subtle bugs that we are sure we would not have found by other means, or giving us enough understanding and confidence to make aggressive performance optimizations without sacrificing correctness. We now have 7 teams using TLA+, with encouragement from senior management and technical leadership. Engineers from entry level to Principal have been able to learn TLA+ from scratch and get useful results in 2 to 3 weeks, in some cases just in their personal time on weekends and evenings, and without help or training. We lack space here to explain the TLA+ language or show any real-world specifications. We have not included any snippets of specifications because their unfamiliar syntax can be off-putting to potential new users. We’ve found that potential new users benefit from hearing about the value of formal methods in industry before tackling tutorials and examples. We refer readers to [4] for tutorials, and [12] for an example of a TLA+ specification from industry that is similar in size and complexity to some of the larger specifications at Amazon. Applying TLA+ to some of our more complex systems <table> <thead> <tr> <th>System</th> <th>Components</th> <th>Line count (excl. comments)</th> <th>Benefit</th> </tr> </thead> <tbody> <tr> <td></td> <td>Background redistribution of data</td> <td>645 PlusCal</td> <td>Found 1 bug, and found a bug in the first proposed fix.</td> </tr> <tr> <td>DynamoDB</td> <td>Replication &amp; group-membership system</td> <td>939 TLA+</td> <td>Found 3 bugs, some requiring traces of 35 steps</td> </tr> <tr> <td>EBS</td> <td>Volume management</td> <td>102 PlusCal</td> <td>Found 3 bugs.</td> </tr> <tr> <td>Internal distributed</td> <td>Lock-free data structure</td> <td>223 PlusCal</td> <td>Improved confidence. Failed to find a liveness bug as we did not check liveness.</td> </tr> <tr> <td>lock manager</td> <td>Fault tolerant replication and reconfiguration algorithm</td> <td>318 TLA+</td> <td>Found 1 bug. Verified an aggressive optimization.</td> </tr> </tbody> </table> We have found TLA+ to be effective in our problem domain, but there are many other formal specification languages and tools. Some of those alternatives are described later. Side Benefit: A Better Way to Design Systems TLA+ has been helping us shift to a better way of designing systems. Engineers naturally focus on designing the ‘happy case’ for a system, i.e. the processing path in which no errors occur. This is understandable, as the happy case is by far the most common case. That code path must solve the customer’s problem, perform well, make efficient use of resources, and scale with the business; these are all significant challenges in their own right. Once the design for the happy case is done, the engineer then tries to think of “what might go wrong?”, based on personal experience and that of colleagues and reviewers. The engineer then adds mitigations for these classes of scenarios, prioritized by intuition and perhaps some statistics on the probability of occurrence. Almost always, the engineer stops well short of handling ‘extremely rare’ combinations of events, as there are too many such scenarios to imagine. In contrast, when using formal specification we begin by precisely stating “what needs to go right?” First we state what the system should do, by defining correctness properties. These come in two varieties: - Safety properties: “what the system is allowed to do” Example: at all times, all committed data is present and correct. Or equivalently: at no time can the system have lost or corrupted any committed data. - Liveness properties: “what the system must eventually do” Example: whenever the system receives a request, it must eventually respond to that request. After defining correctness properties, we then precisely describe an abstract version of the design along with an abstract version of its operating environment. We express “what must go right” by explicitly specifying all of the properties of the environment on which the system relies. Examples of such properties might be, “If a communication channel has not failed, then messages will be propagated along it.”, and “If a process has not restarted, then it retains its local state, modulo any intentional modifications.” Next, with the goal of confirming that our design correctly handles all of the dynamic events in the environment, we specify the effects of each of those possible events; e.g. network errors and repairs, disk errors, process crashes and restarts, data center failures and repairs, and actions by human operators. We then use the model checker to verify that the specification of the system in its environment implements the chosen correctness properties, despite any combination or interleaving of events in the operating environment. We have found this rigorous “what needs to go right?” approach to be significantly less error prone than the ad hoc “what might go wrong?” approach. More Side Benefits: Improved Understanding, Productivity and Innovation We have found that writing a formal specification pays several dividends over the lifetime of the system. All production services at Amazon are under constant development, even those released years ago; we add new features that customers have requested, we re-design components to handle massive increases in scale, and we improve performance by removing bottlenecks. Many of these changes are complex, and they must be made to the running system with no downtime. Our first priority is always to avoid causing bugs in a production system, so we often need to answer the question, “is this change safe?” We have found that a major benefit of having a precise, testable model of the core system is that we can rapidly verify that even deep changes are safe, or learn that they are unsafe without doing any harm. In several cases we have prevented subtle, serious bugs from reaching production. In other cases we have been able to make innovative performance optimizations – e.g. removing or narrowing locks, or weakening constraints on message ordering – which we would not have dared to do without having model checked those changes. A precise, testable description of a system becomes a “what if …” tool for designs, analogous to how spread sheets are a “what if …” tool for financial models. We have found that using such a tool to explore the behavior of the system can give the designer an improved understanding of the system. In addition, a precise, testable, well commented description of a design is an excellent form of documentation. Documentation is very important as our systems have unbounded lifetime. Over time, teams grow as the business grows, so we regularly have to bring new people up to speed on systems. We need this education to be effective. To avoid creating subtle bugs, we need all of the engineers to have the same mental model of the system, and for that shared model to be accurate, precise and complete. Engineers form mental models in a variety of ways; talking to each other, reading design documents, reading code, and implementing bug fixes or small features. But talk and design documents can be ambiguous or incomplete, and the executable code is far too large to absorb quickly and might not precisely reflect the intended design. In contrast, a formal specification is precise, short, and can be explored and experimented upon with tools. **What Formal Specification Is Not Good For** We are concerned with two major classes of problems with large distributed systems: 1) bugs and operator errors that cause a departure from the logical intent of the system, and 2) surprising ‘sustained emergent performance degradation’ of complex systems that inevitably contain feedback loops. We know how to use formal specification to find the first class of problems. However, problems in the second category can cripple a system even though no logic bug is involved. A common example is when a momentary slowdown in a server (perhaps due to Java garbage collection) causes timeouts to be breached on clients, which causes the clients to retry requests, which adds more load to the server, which causes further slowdown. In such scenarios the system will eventually make progress; it is not stuck in a logical deadlock, livelock, or other cycle. But from the customer’s perspective it is effectively unavailable due to sustained unacceptable response times. TLA+ could be used to specify an upper bound on response time, as a real-time safety property. However, our systems are built on infrastructure (disks, operating systems, network) that do not support hard real-time scheduling or guarantees, so real-time safety properties would not be realistic. We build soft real-time systems in which very short periods of slow responses are not considered errors. However, prolonged severe slowdowns are considered errors. We don’t yet know of a feasible way to model a real system that would enable tools to predict such emergent behavior. We use other techniques to mitigate those risks. **First Steps To Formal Methods** With hindsight, our path to formal methods seems clear and straightforward; we had an engineering problem and we found a solution. The reality was somewhat different. The effort began with author C.N.‘s dissatisfaction with the quality of several distributed systems he had designed and reviewed, and with the development process and tools that had been used to construct those systems. The systems were considered very successful, and yet bugs and operational problems still remained. To mitigate those problems, the systems used well proven methods (pervasive contract assertions enabled in production) to detect symptoms of bugs, and mechanisms such as ‘recovery-oriented computing’ \[6\] to attempt to minimize the impact when bugs were triggered. However, reactive mechanisms cannot recover from the class of bugs that cause permanent damage to customer data; instead, we must prevent such bugs. When looking for techniques to prevent bugs, C.N. did not initially consider formal methods, due to the strong pervasive view that they are only suitable for tiny problems and give very low return on investment. Overcoming the bias against formal methods required evidence that they work on real-world systems. This evidence was provided in a paper by Pamela Zave \[7\]. Zave used a language called Alloy to find serious bugs in the membership protocol of a distributed system called Chord. Chord was designed by a strong group at MIT and is certainly successful; it won a ’10-year test of time’ award at SIGCOMM 2011, and has influenced several systems in industry. Zave’s success motivated C.N. to perform an evaluation of Alloy, by writing and model checking a moderately large Alloy specification of a non-trivial concurrent algorithm \[8\]. We liked many characteristics of the Alloy language; e.g. the emphasis on ‘execution traces’ of abstract system states composed of sets and relations. However, we found that Alloy is not expressive enough for many of our use cases. For instance, we could not find a practical way in Alloy to represent rich data structures such as dynamic sequences containing nested records with multiple fields. Alloy’s limited expressivity appears to be a consequence of the particular approach to analysis taken by the Alloy Analyzer tool. The limitations do not seem to be caused by Alloy’s conceptual model (‘execution traces’ over system states). This hypothesis motivated C.N. to look for a language with a similar conceptual model but with richer constructs for describing system states. Eventually C.N. stumbled across a language with those properties when he found a TLA+ specification in the appendix of a paper on a canonical algorithm in our problem domain: the Paxos consensus algorithm \[9\]. The fact that TLA+ was created by the designer of such a widely used algorithm gave us some confidence that TLA+ worked for real-world systems. We became more confident when we learned that a team of engineers at DEC/Compaq had used TLA+ to specify and verify some intricate cache-coherency protocols for the Alpha series of multi-core CPUs \[10\]\[11\]. We read one of the specifications \[12\] and found that these were sophisticated distributed algorithms, involving rich message passing, fine-grain concurrency, and complex correctness properties. That only left the question of whether TLA+ could handle ‘real world’ failure modes. (The Alpha cache-coherency algorithm does not consider failure.) We knew from the Fast Paxos paper \[9\] that TLA+ could model fault tolerance at a high level of abstraction, but we were further convinced when we found other papers that showed that TLA+ could model lower-level failures \[13\]. C.N. evaluated TLA+ by writing a specification of the same non-trivial concurrent algorithm that he had written in Alloy\textsuperscript{[8]}. Both Alloy and TLA+ were able to handle that problem, but this comparison revealed that TLA+ is much more expressive than Alloy. This difference has been important in practice; several of the real-world specifications we have written in TLA+ would have been infeasible or impossible in Alloy. We initially had the opposite concern about TLA+; it is so expressive that no model checker can hope to evaluate everything that can be expressed in the language. But so far we have always been able to find a way to express our intent in a way that is clear, direct, and can be model checked. After evaluating Alloy and TLA+, C.N. tried to persuade colleagues to adopt TLA+. However, engineers have almost no spare time for such things, unless compelled by need. Fortunately, a need was about to arise. **First Big Success at Amazon** In January 2012 Amazon launched DynamoDB, a scalable high-performance ‘No SQL’ data store, which replicates customer data across multiple data centers while promising strong consistency\textsuperscript{[14]}. This combination of requirements leads to a large, complex system. The replication and fault-tolerance mechanisms in DynamoDB were created by author T.R. To verify correctness of the production code, T.R. performed extensive fault-injection testing using a simulated network layer to control message loss, duplication, and re-ordering. The system was also stress tested for long periods on real hardware under many different workloads. We know that such testing is absolutely necessary, but can still fail to uncover subtle flaws in design. To verify the design, T.R. wrote detailed informal proofs of correctness. Those proofs did indeed find several bugs in early versions of the design. However, we have also learned that conventional informal proofs can miss very subtle problems\textsuperscript{[15]}. To achieve the highest level of confidence in the design, T.R. chose to apply TLA+. T.R. learned TLA+ and wrote a detailed specification of these components in a couple of weeks. To model check the specification we used the distributed version of the TLC model checker, running on a cluster of ten cc1.4xlarge EC2 instances, each with 8 cores plus hyperthreads, and 23 GB of RAM. The model checker verified that a small complicated part of the algorithm worked as expected, for a sufficiently large instance of the system to give very high confidence that it is correct. T.R. then moved on to checking the broader fault-tolerant algorithm. This time the model checker found a bug that could lead to losing data if a particular sequence of failures and recovery steps was interleaved with other processing. This was a very subtle bug; the shortest error trace exhibiting the bug contained 35 high level steps. The improbability of such compound events is not a defense against such bugs; historically, AWS has observed many combinations of events at least as complicated as those that could trigger this bug. The bug had passed unnoticed through extensive design reviews, code reviews, and testing, and T.R. is convinced that we would not have found it by doing more work in those conventional areas. The model checker later found two bugs in other algorithms, again both serious and subtle. T.R. fixed all of these bugs, and the model checker verified the resulting algorithms to a very high degree of confidence. T.R. says that, had he known about TLA+ before starting work on DynamoDB, he would have used it from the start. He believes that the investment he made in writing and checking the formal TLA+ specifications was both more reliable, and also less time consuming than the work he put into writing and checking his informal proofs. Therefore, using TLA+ in place of traditional proof writing would likely have improved time-to-market in addition to achieving higher confidence on system correctness. After DynamoDB was launched, T.R. worked on a new feature to allow data to be migrated between data centers. As he already had the specification for the existing replication algorithm, T.R. was able to quickly incorporate this new feature into the specification. The model checker found that the initial design would have introduced a subtle bug, but this was easy to fix, and the model checker verified the resulting algorithm to the necessary level of confidence. T.R. continues to use TLA+ and model checking to verify changes to the design, both for optimizations and new features. **Persuading More Engineers Leads to Further Successes** The success with DynamoDB gave us enough evidence to present TLA+ to the broader engineering community at Amazon. This raised a challenge; how to convey the purpose and benefits of formal methods to an audience of software engineers? Engineers think in terms of debugging rather than ‘verification’, so we called the presentation “Debugging Designs” [8]. Continuing that metaphor, we have found that software engineers more readily grasp the concept and practical value of TLA+ if we dub it: *Exhaustively testable pseudo-code* We initially avoid the words ‘formal’, ‘verification’, and ‘proof’, due to the widespread view that formal methods are impractical. We also initially avoid mentioning what the acronym ‘TLA’ stands for, as doing so would give an incorrect impression of complexity. Immediately after seeing the presentation, a team working on S3 asked for help to use TLA+ to verify a new fault-tolerant network algorithm. The documentation for the algorithm consisted of many large, complicated state machine diagrams. To check the state machine, the team had been considering writing a Java program to brute-force explore possible executions--essentially a hard-wired form of model checking. They were able to avoid that effort by using TLA+ instead. Author F.Z. wrote two versions of the spec over a couple of weeks. For this particular problem F.Z. found that she was more productive in PlusCal than TLA+, and in general we have observed that engineers often find it easier to begin with PlusCal. Model checking revealed two subtle bugs in the algorithm, and allowed F.Z. to verify fixes for both bugs. F.Z. then used the spec to experiment with the design, adding new features and optimizations. The model checker quickly revealed that some of these changes would have introduced bugs. This success led to management advocating TLA+ to other teams working on S3. Engineers from those teams wrote specs for two additional critical algorithms, and one new feature. F.Z. helped teach the engineers how to write their first specs. We find it encouraging that TLA+ can be successfully taught by engineers who are still quite new to it themselves; this is important for quickly scaling adoption to an organization as large as Amazon. Author B.M. was one of the engineers mentioned. B.M.’s first spec was for an algorithm that had a known subtle bug. The bug had passed unnoticed through multiple design reviews and code reviews, and had only surfaced after months of testing. B.M. spent two weeks learning TLA+ and writing the spec. Using this spec, the TLC model checker found the bug in a few seconds. The team had already designed and reviewed a fix for this bug, so B.M. changed the spec to include the proposed fix. The model checker found that the problem still occurred, but via a different execution trace. A stronger fix was proposed, and the model checker verified the second fix. Later, B.M. wrote another spec for a different algorithm. That spec did not uncover any bugs, but did uncover several important ambiguities in the documentation for the algorithm, which the spec helped to resolve. Somewhat independently, after seeing internal presentations about TLA+, authors M.B and M.D. taught themselves PlusCal and TLA+ and started using them on their respective projects without further persuasion or assistance. M.B. used PlusCal to find three bugs, and also wrote a public blog about his personal experiments with TLA+ outside of Amazon. M.D. used PlusCal to check a lock-free concurrent algorithm. He then used TLA+ to find a critical bug in one of our most important new algorithms. M.D. also came up with a fix for the bug, and verified the fix. C.N. independently wrote a spec for the same algorithm; C.N.’s spec was quite different in style to that written by M.D., but both found the same bug in the algorithm. This suggests that the benefits of using TLA+ are quite robust to variations between engineers. Both specs were later used to verify that a crucial optimization to the algorithm did not introduce any bugs. We continue to use TLA+ in our work. We have adopted the practice of first writing a conventional prose design document, then incrementally refining parts of it into PlusCal or TLA+. Often this gives important insights without ever going as far as a full specification or model checking. In one case, C.N. refined a prose design of a fault-tolerant replication system that had been designed by another Amazon engineer; C.N. wrote and model checked specifications at two levels of concurrency, and these specifications helped him understand the design well enough to propose a major optimization that radically reduced write latency in that system. Most recently we discovered that TLA+ is an excellent tool for data modeling, e.g. designing the schema for a relational or ‘No SQL’ database. We used TLA+ to design a non-trivial schema, with semantic invariants over the data that were much richer than standard multiplicity constraints and foreign key constraints. We then added high-level specifications of some of the main operations on the data, which helped us to correct and refine the schema. This suggests that a data model might best be viewed as just another level of abstraction of the entire system. This work also suggests that TLA+ may help designers improve the scalability of a system; in order to remove scalability bottlenecks, designers often need to break atomic transactions into finer-grain operations chained together via asynchronous workflows, and TLA+ can help explore the consequences of such changes with respect to isolation and consistency. The Most Frequently Asked Question On learning about TLA+, engineers usually ask, “How do we know that the executable code correctly implements the verified design?” The answer is that we don’t. Despite this, formal methods help in multiple ways: Formal methods help engineers to get the design right, which is a necessary first step toward getting the code right. If the design is broken then the code is almost certainly broken, as mistakes during coding are extremely unlikely to compensate for mistakes in design. Worse, engineers will probably be deceived into believing that the code is ‘correct’ because it appears to correctly implement the (broken) design. Engineers are unlikely to realize that the design is incorrect while they are focusing on coding. Formal methods help engineers gain a better understanding of the design. Improved understanding can only increase the chances that that the engineers will get the code right. Formal methods can help engineers write better “self-diagnosing code”, in the form of assertions. Evidence [17] and our own experience suggest that pervasive use of assertions is a good way to reduce errors in code. An assertion checks a small, local part of an overall system invariant. A good system invariant captures the fundamental reason why the system works; the system won’t do anything wrong that could violate a safety property as long as it continuously maintains the system invariant. The challenge is to find a good system invariant, one that is strong enough to ensure that no safety properties are violated. Formal methods help engineers to find strong invariants, so formal methods can help to improve assertions, which help improve the quality of code. While we would like to verify that the executable code correctly implements the high-level specification, or even generate the code from the specification, we are not aware of any such tools that can handle distributed systems as large and complex as those we are building. We do routinely use conventional static analysis tools, but these are largely limited to finding ‘local’ issues in the code, and cannot verify compliance with a high-level specification. We have seen research on using the TLC model checker to find ‘edge cases’ in the design on which to test the code [18]. This approach seems promising. However the cited paper is about hardware designs, and we have not yet tried to apply that method to software. Alternatives to TLA+ There are many formal specification methods. We evaluated several, and published our findings in a paper [19]. That paper lists the requirements that we think are important for a formal method to be successful in our industry segment. When we found that TLA+ met those requirements, we stopped evaluating methods, as our goal was always practical engineering rather than an exhaustive survey. Related Work We have found relatively little published literature on using high-level formal specification to verify the design of complex distributed systems in industry. The Farsite project [20] is complex, but is somewhat different to the types of system we describe, and apparently was not launched commercially. Abrial [21] lists applications to commercial safety-critical control systems, but which seem less complex, and are quite far from our problem domain. Lu et al. [22] describe post-facto verification of a well-known algorithm for a fault-tolerant distributed hash table, and Zave [7] describes another such algorithm, but we don’t know if these algorithms have been used in commercial products. Conclusion At AWS, formal methods have been a big success. They have helped us prevent subtle, serious bugs from reaching production, bugs that we would not have found via any other technique. They have helped us to make aggressive optimizations to complex algorithms without sacrificing quality. So far, seven teams have used TLA+, and all have found high value in doing so. At the time of writing, more teams are starting to use TLA+. We believe that use of TLA+ will accelerate both time-to-market and quality of these projects. Executive management is now proactively encouraging teams to write TLA+ specs for new features and other significant design changes. In annual planning, managers are now allocating engineering time to use TLA+. While our results are very encouraging, some important caveats remain. Formal methods deal with models of systems, not the systems themselves, so the adage applies; “All models are wrong, some are useful.” The designer must ensure that the model captures the significant aspects of the real system. Achieving this is a difficult skill, the acquisition of which requires thoughtful practice. Also, we were solely concerned with obtaining practical benefits in our particular problem domain, and have not attempted a comprehensive survey. Therefore, mileage may vary with other tools or in other problem domains. References [16] Brooker, M. Exploring TLA+ With Two-Phase Commit; http://brooker.co.za/blog/2013/01/20/two-phase.html
{"Source-Url": "http://lamport.azurewebsites.net/tla/formal-methods-amazon.pdf", "len_cl100k_base": 7245, "olmocr-version": "0.1.50", "pdf-total-pages": 12, "total-fallback-pages": 0, "total-input-tokens": 47808, "total-output-tokens": 8914, "length": "2e12", "weborganizer": {"__label__adult": 0.00040221214294433594, "__label__art_design": 0.0004470348358154297, "__label__crime_law": 0.0003790855407714844, "__label__education_jobs": 0.000812530517578125, "__label__entertainment": 9.065866470336914e-05, "__label__fashion_beauty": 0.00019669532775878904, "__label__finance_business": 0.0005488395690917969, "__label__food_dining": 0.0003948211669921875, "__label__games": 0.0004267692565917969, "__label__hardware": 0.001209259033203125, "__label__health": 0.0006570816040039062, "__label__history": 0.00031065940856933594, "__label__home_hobbies": 0.00011676549911499023, "__label__industrial": 0.000640869140625, "__label__literature": 0.0003705024719238281, "__label__politics": 0.0003197193145751953, "__label__religion": 0.0005807876586914062, "__label__science_tech": 0.061126708984375, "__label__social_life": 0.00012481212615966797, "__label__software": 0.006317138671875, "__label__software_dev": 0.92333984375, "__label__sports_fitness": 0.0003337860107421875, "__label__transportation": 0.000804901123046875, "__label__travel": 0.0002290010452270508}, "weborganizer_max": "__label__software_dev", "avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_ratio": [[0, 40183, 0.01716]], "fineweb_edu_fasttext_gt2__fineweb_edu_fasttext_gt2__score": [[0, 40183, 0.33425]], "ft_lang_id_en_doc_v2__ft_lang_id_en_doc_v2__en": [[0, 40183, 0.94547]], "google_gemma-3-12b-it_contains_pii": [[0, 3213, false], [3213, 6925, null], [6925, 10458, null], [10458, 13780, null], [13780, 17335, null], [17335, 21009, null], [21009, 24708, null], [24708, 27906, null], [27906, 31532, null], [31532, 34849, null], [34849, 39053, null], [39053, 40183, null]], "google_gemma-3-12b-it_is_public_document": [[0, 3213, true], [3213, 6925, null], [6925, 10458, null], [10458, 13780, null], [13780, 17335, null], [17335, 21009, null], [21009, 24708, null], [24708, 27906, null], [27906, 31532, null], [31532, 34849, null], [34849, 39053, null], [39053, 40183, null]], "google_gemma-3-4b-it_v2tag__is_academic_paper": [[0, 5000, true], [5000, 40183, null]], "google_gemma-3-4b-it_v2tag__is_class_syllabus": [[0, 5000, false], [5000, 40183, null]], "google_gemma-3-4b-it_v2tag__is_completion_certificate": [[0, 5000, false], [5000, 40183, null]], "google_gemma-3-4b-it_v2tag__is_court_notice": [[0, 5000, false], [5000, 40183, null]], "google_gemma-3-4b-it_v2tag__is_homework_assignment": [[0, 5000, false], [5000, 40183, null]], "google_gemma-3-4b-it_v2tag__is_news_article": [[0, 5000, false], [5000, 40183, null]], "google_gemma-3-4b-it_v2tag__is_public_order": [[0, 5000, false], [5000, 40183, null]], "google_gemma-3-4b-it_v2tag__is_resume_cv": [[0, 5000, false], [5000, 40183, null]], "google_gemma-3-4b-it_v2tag__is_test_or_quiz": [[0, 5000, false], [5000, 40183, null]], "google_gemma-3-4b-it_v2tag__is_textbook": [[0, 5000, false], [5000, 40183, null]], "pdf_page_numbers": [[0, 3213, 1], [3213, 6925, 2], [6925, 10458, 3], [10458, 13780, 4], [13780, 17335, 5], [17335, 21009, 6], [21009, 24708, 7], [24708, 27906, 8], [27906, 31532, 9], [31532, 34849, 10], [34849, 39053, 11], [39053, 40183, 12]], "pipe_delimited_lines_v1__pipe_delimited_lines_v1__pipe_delimited_lines_ratio": [[0, 40183, 0.07619]]}
olmocr_science_pdfs
2024-11-30
2024-11-30