dataesr/scientific-paragraphs-categorization huggingface dataset:
Then, a thread is started to receive messages which polls the client object for new messages and prints any received messages to the console. After the message receiving thread is started, the client sends a message notifying the server that the client has joined the chat. Finally, the client enters an infinite loop that listens to the console for messages and sends any messages to the server. The server is implemented in a similar way using the generated Server class as the server-side WebSocket API. Listing 1. 6 demonstrates that our approach is upwards compatible, i. e. , that the services of the generated code can easily be used by third party software. A key feature that provides this is that we include the API in the model as the services at the principal level of the CPN model. Figure  5  shows the chat client (upper right) and server (lower right) running together with the web-based chat client from  [1].
In this paper we have shown that the PetriCode code generation approach can be applied to industrial sized protocols as exemplified by the WebSocket protocol. Obtaining the implementation was achieved with limited effort even though quite a few new templates were created. We have found that the template provides an effective way to force the code to be modular. This means that the templates can be developed in a certain degree of isolation, giving the developer the opportunity to concentrate on getting a single template right at a time. Therefore, even though many templates are created for only a single protocol, this is an efficient way to prototype protocols based on a CPN model. Compared to previous examples, the WebSocket model had many more services. This makes the principal level somewhat harder to read and suggests that some kind of mechanism of grouping the services in several layers might be advantageous.
At the service level, the models are approximately the same size as in previous examples. The readability of the service level modules can also be controlled by offloading behaviour to pragmatics such as we do for the receive pragmatic in the message broker. All in all, the WebSocket model shows that we can make code generation models for real protocols without necessarily losing descriptiveness. We have also showed that the code generation model can be verified by state space exploration. This highlights a major advantage of using CPN models which are directly executable. This allows us to perform analysis on high-level models and thereby keep the state spaces small. Although the verification presented only considers basic connection establishment and termination properties, other more elaborate properties including liveness properties can be checked using similar techniques.
We are also working on using the sweep-line method, and advanced state space exploration method, to alleviate the state space explosion problem. Finally, we have validated the automatically generated WebSocket implementation both by applying it to a well-known example in the form of the example chat application which is distributed with the GlassFish Application server and also by using the Autobahn test-suite which thoroughly tests most aspects of WebSocket protocol implementations. To the best of our knowledge there does not exist any examples of using model-based techniques for generating an implementation of the WebSocket protocol in the literature. However, there exists a few examples for other industrial sized protocols. In  [12]  PP-CPNs, another class of Petri Nets, was used to generate code for the DYMO routing protocol for the Erlang platform.
Our approach also allows us to model the service interface, which is not available to the same degree in PP-CPNs and Renew. Another approach to generating software for reactive systems from UML models is the SPACE method  [10]  and its tool Arctis. This approach employs collaborations to compose services. The collaborations are then transformed into state machines that are executed together with Java snippets which are bound to actions of the collaborations. This approach relies on the state machines to either be translated to code or executed directly by some other tool. This is in contrast to our approach where we generate code directly instead of going through other formalisms and tools. MACE  [9]  is a textual state-transition language that is used to create distributes systems. It uses a compiler to compile the textual statetransition language into C++ code.
This means that MACE is not as platform independent as our template-based approach is. In MetaEdit+  [19] , models are mapped to some underlying formalism on which analysis is then performed. This tends to produce larger state space sizes compared with our approaches where the model is executable and allows verification at a high level of abstraction. In the future we will apply more advanced state-space techniques, such as the sweep-line method, in order to do a more through verification of the model with larger and more complex configurations. Furthermore, we will investigate how errors in code generated by PetriCode can be traced back to the relevant pragmatics and model elements.
In Luxembourg, water meters are not directly Fig. 1. Schematic representation of the smart grid communication topology connected to a data concentrator but connected (and controlled) via a smart meter. The communication between water meters and the electricity smart meters is encrypted. In other countries water meters are directly connected to a concentrator via wireless communication. In Luxembourg this solution is not considered for now but technically it would be feasible. Gas or heat meters are used to measure gas consumption of customers. Similar to water meters they are usually limited devices and are connected (and controlled) via a smart meter. Data concentrators collect and store (for several months) consumption data from a number of associated meters. In regular intervals (typically several times a day, in some settings immediately) they send this data (usually via IP connections) to a central control system.
This characteristic leads to the tree structure of the communication topology. We analyzed three different regions (each with one data concentrator) in Luxembourg in detail. Therefore, we evaluated -together with our industrial partner Creos Luxembourg S. A. -a set of real-world data that contains: the above described communication topology of smart meters, concentrators, and the central system; how the topology changes over time; complete consumption and production data over a period of several days (one value each 15 minutes); GPS locations of entities; location and characteristics of physical electricity cables used for the PLC network; the success rates of meter readings (over a period of time); and duration of meter readings. We evaluate this data and present the key characteristics of the outcome in the following sections.
6. Besides the number of hops we also analyzed the actual physical distance di from the smart meters to data concentrators. Our study showed that this distance is between 7 and 501 meters. In average (over all three regions) the distance between a smart meter and a concentrator is 317. 6 meters. Next let's consider the degree of a node in the communication topology tree. In this context with degree of a node we mean the number of edges (communication connections) going in or coming out of a node. As can be seen in fig. 1  a concentrator has one connection (wireless, optical fibre, copper line) to the central system. In addition, each concentrator has one connection to each directly connected smart meter. This leads to a degree of N + 1 per concentrator, where N again is the number of directly connected smart meters.
Background: Despite the increasing number of bug analysis tools for exploring bugs in software systems, there are no tools supporting the investigation of causality relationships between internal quality metrics and bugs. In this paper, we propose an extension of the BugMaps tool called BugMaps-Granger that allows the analysis of source code properties that are more likely to cause bugs. For this purpose, we relied on the Granger Causality Test to evaluate whether past changes to a given time series of source code metrics can be used to forecast changes in a time series of defects. Our tool extracts source code versions from version control platforms, calculates source code metrics and defects time series, computes Granger Test results, and provides interactive visualizations for causal analysis of bugs.
Results: We provide an example of use of BugMaps-Granger involving data from the Equinox Framework and Eclipse JDT Core systems collected during three years. For these systems, the tool was able to identify the modules with more bugs, the average lifetime and complexity of the bugs, and the source code properties that are more likely to cause bugs. Conclusions: With the results provided by the tool in hand, a maintainer can perform at least two main software quality assurance activities: (a) refactoring the source code properties that Granger-caused bugs and (b) improving unit tests coverage in classes with more bugs.
More recently, the tool in*Bug (Dal Sassc and Lanza 2013) was proposed to allow users navigating and inspecting the information stored in bug tracking platforms, with the specific purpose to support the comprehension of bug reports. Despite the increasing number of bug analysis tools, they typically do not provide mechanisms for assessing the existence of correlations between the internal quality of a software system and the occurrence of bugs. To the best of our knowledge, there are no bug analysis tools that highlight the possible causes of bugs in the source code. More specifically, there are no tools designed to infer eventual causal relations between changes in the values of source code metrics and the occurrence of defects in object-oriented classes. In this paper, we propose and describe the BugMaps-Granger tool-an extension of the BugMaps tool  (Hora et al.
2012 )-that supports detection of causal relations between source code metrics and bugs. The tool provides mechanisms to retrieve data from software repositories, to compute source code metrics, to generate time series of source code metrics and defects, and to infer causal relations between source code properties and defects. Moreover, BugMaps-Granger provides visualizations for identifying the modules with more bugs, the average lifetime and complexity of bugs, and the source code properties that are more likely to cause bugs. More specifically, our tool relies on the Granger Causality Test  (Granger 1981)  to identify causal relations between time series of source code metrics and defects. This test evaluates whether past changes to a given time series of source code metrics can be used to forecast changes in a time series of defects.
jserd. com/content/2/1/1 The ultimate goal of BugMaps-Granger is to predict the changes in the source code that are more likely to cause defects. For example, with our tool in hand, a maintainer (before making a commit with changes to a given class) can verify whether such changes affect the values of source code metrics that, in the past, Granger-caused defects. If the changes significantly affect these metrics values, the maintainer can, for example, perform extra software quality assurance activities (e. g. , she can conduct more unit testing or perform a detailed code inspection) before executing the commit. In a previous conference paper, we described an exploratory study on using Granger to predict bugs  (Couto et al. 2012). Recently, this paper was extended with a concrete approach that relies on Granger Tests to trigger alarms whenever risky changes are applied in the source code  (Couto et al.
Implementation The execution of the BugMaps-Granger tool is divided into two phases: preprocessing and visualization. The preprocessing phase is responsible for extracting source code models, creating time series, and applying the Granger Test to compute possible causal relations between source code metrics and bugs. In the visualization phase, the user interacts with the tool. For example, he can retrieve the most defective classes of the system and visualize the source code properties that Granger-caused bugs in such classes. BugMaps-Granger is implemented in Moose (Moose platform 2014), which is a platform for software and data analysis  (Nierstrasz et al. 2005). Figure  1  shows BugMaps-Granger's architecture, which includes four modules: model extraction, time series creation, Granger Test module, and visualization module.
Model extraction This module receives as input the URL associated to the version control platform of the target system (SVN or Git) and a time interval to be used in the analysis of the bugs. To extract the source code models, the module performs the following tasks: the source code versions from the version control platforms in intervals of bi-weeks; (b) it removes test classes, assuming that such classes are implemented in directories and subdirectories whose name starts with the words "Test" or "test"; and (c) it parses the source code versions and generates MSE files using the VerveineJ tool  (Ducasse et al. 2011; VerveineJ parser 2014). MSE is the default file format supported by the Moose platform to persist source code models.
• P5: The time series of source code metrics must be stationary, as defined for the defects series. Finally, for the time series m (source code metrics) and d (defects) that passed preconditions P1 to P5, function granger(m,d) checks whether m Granger-causes d (line 7). In practice, to apply the test, BugMaps-Granger relies on the function granger. test() provided by the msbvar (MSBVAR package 2012) package of the R system. It is worth mentioning that we previously performed an extensive study to evaluate the application of Granger Causality Test on software defects prediction  (Couto et al. 2014). Basically, we focus on answering questions such as: (a) How many time series pass the preconditions related to defects (preconditions P1, P2, P3)? (b) How many time series pass the preconditions related to source code metrics (preconditions P4 and P5)? (c) www.
jserd. com/content/2/1/1 How many classes present positive results on the Granger Test? (d) What is the number of defects potentially covered by Granger? To answer these questions, we used a dataset including time series of source code metrics and defects for four real-world systems (Eclipse JDT Core, Eclipse PDE UI, Equinox Framework, and Lucene)  (Couto et al. 2013b ).
Results and discussion In this section, we provide an example of use considering data from the Equinox Framework and Eclipse JDT Core systems collected during three years. For Equinox Framework, the tool extracted 79 source code versions in intervals of bi-weeks, including 417 classes, from 2010-01-01 to 2012-12-28. For Eclipse JDT Core, the tool extracted 78 source code versions in intervals of bi-weeks, including 2,467 classes, from 2005-01-01 to 2007-12-15. In a second step, for each class, the tool created eleven time series of source code metrics (for each metric in Table  1 ) and one time series of defects. Finally, for each pair of time series (source code metrics and defects), the tool applied the Granger Test to identify causal relations. We analyzed the Granger results for both systems according to the proposed visualizations, as discussed next.
Granger In this map, the rectangles are the classes of the target system, as illustrated in Figure  4. The color of a class represents the number of bugs detected through its history ranging from green to red (the closer to red, more bugs the class had in its history). By selecting a defective class, the bottom pane is updated showing the source code metrics that Granger-caused bugs in this class. Particularly, Figure  4  provides an overview of the distribution of the bugs in the Equinox Framework system. We can observe that the resolver package contains a significant number of classes with bugs. Moreover, for the class org. eclipse. osgi. internal. resolver. StateImpl, we can observe that the source code metrics that Granger-caused bugs were CBO (Coupling Between Object), WMC (Weighted Methods per Class), and RFC (Response for Class).
The Granger browser can also be used to avoid future defects. For example, with this result in hand, a maintainer (before making a commit with changes to the StateImpl class) can verify whether such changes heavily affect the values of source code metrics that Granger-caused defects in the past (in our example, the metrics that Granger-caused defects were CBO, WMC, and RFC). If the change affects these metrics, the maintainer can for example perform extra software quality assurance activities in this class (like unit testing or code inspection).
Bug ranking Figure  6  shows examples of the Bug Ranking browser which is composed by one grid with two columns: class names (first column) and number of defects during the time frame considered in the analysis (second column). The figure shows the classes ranked by the defects for the Equinox Framework and Eclipse JDT Core systems during the period of three years. For the Equinox Framework, the two classes with more defects are osgi. internal. module. ResolverImpl and osgi. framework. internal. core. Framework. The ResolverImpl class-which has more than 2,000 lines of code-is an important class responsible for resolving the constraints of the bundles (JAR components) in a system that follows the OSGi standard  (Tavares and Valente 2008). The Framework class also has more than 2,000 lines of code and represents the core OSGi Framework class.
Granger ranking For each valid time series of source code metrics, Figure  7  shows the number of Granger tests that returned a positive result. For example, the number of CBO time series with a Granger-causality with defects was 108 and 138 series for Equinox Framework and Eclipse JDT Core, respectively. As can be observed, the metrics with the highest number of positive Granger tests were CBO, FAN-OUT, LOC, RFC, and WMC for Equinox Framework; and RFC, LOC, WMC, and CBO for Eclipse JDT Core. On the other hand, the metrics with the lowest number of positive results were DIT and NOC for both systems. Based on these results, we can conclude that metrics related to complexity (WMC), coupling (CBO, RFC, and FAN-OUT), and LOC tend to impact in the occurrence of defects in the Equinox Framework and Eclipse JDT Core systems, at least according to Granger.
Conclusion In this paper, we described a tool that infers and provides visualizations about causality relations between source code metrics and bugs. The BugMaps-Granger tool extracts time series of defects from such systems and allows the visualization of different bug measures, including the source code properties that Granger-caused bugs. The ultimate goal of BugMaps-Granger is to highlight changes in the source code that are more subjected to bugs, and the source code metrics that can be used to anticipate the occurrence of bugs in the changed classes. With this tool in hand, maintainers can perform at least two main actions for improving software quality: (a) refactoring the source code properties that Granger-caused bugs and (b) improving unit tests coverage in classes with more bugs.
As future work, we intend to extend BugMaps-Granger with other internal software quality metrics, including metrics associated to violations in the static architecture of software systems, as revealed by the DCL language  (Terra and Valente 2009)  or the ArchLint tool  (Maffort et al. 2013 ), for example. Another possible research thread concerns the relations between defects and code smells. In this case, we intend to start by investigating the relations between defects and methods located in inappropriate classes (i. e. , feature envy instances), as revealed by the JMove recommendation system  (Sales et al. 2013). In addition, we plan to extend BugMaps-Granger with a new functionality for alerting maintainers about the future occurrence of defects. We intend to implement this tool as a plug-in for version control platforms, like SVN and Git.
The method incorporates a statistical model of the contact counts, assuming that the counts between two loci follow a Poisson distribution whose intensity decreases with the physical distances between the loci. The method can automatically adjust the transfer function relating the spatial distance to the Poisson intensity and infer a genome structure that best explains the observed data. Results: We compare two variants of our Poisson method, with or without optimization of the transfer function, to four different MDSbased algorithms-two metric MDS methods using different stress functions, a non-metric version of MDS and ChromSDE, a recently described, advanced MDS method-on a wide range of simulated datasets. We demonstrate that the Poisson models reconstruct better structures than all MDS-based methods, particularly at low coverage and high resolution, and we highlight the importance of optimizing the transfer function.
To solve this problem, we propose two variant methods. The first method (PM1) uses a default transfer function motivated by a biophysical model, whereas the second method (PM2) uses a parametric family of transfer functions, the parameters of which are automatically optimized together with the 3D structure to best explain the observed data. We compare both PM variants to four MDS-based methods, including metric MDS with two stress functions, NMDS and ChromSDE. We demonstrate on simulated data that the new models reconstruct more accurate 3D structures than all MDSbased methods, especially at low coverage and high resolution. We also assess the negative effect of using an incorrect transfer function, and we show that PM2 is able to overcome this difficulty. On real data, we show that, compared with MDS-based methods, PM1 and PM2 generate more similar models when applied to replicate experiments performed with different restriction enzymes or when applied to the same data at varying resolutions.
Poisson model Instead of metric or NMDS-based methods, which attempt to minimize a stress function that measures a discrepancy between the wish distances and the 3D distances of the structure, we propose to cast the problem of structure inference as a maximum likelihood problem. For that purpose, we need to define a probabilistic model of contact counts parametrized by the 3D structure that we want to infer from contact count observations. For that purpose, we take a model similar to the one used in the BACH algorithm  (Hu et al. , 2013)  and model the contact frequencies ðc ij Þ ði;jÞ2D as independent Poisson random variables, where the Poisson parameter of c ij is a decreasing function of d ij ðXÞ of the form d ij ðXÞ , for some parameters 40 and 50. We can then express the likelihood as 'ðX; ; Þ= Y i;j ðd ij Þ cij c ij ! expðÀd ij Þ By maximizing the log likelihood, a new optimization problem naturally emerges from this formulation: max ;;X LðX; ; Þ= X i5j n c ij log d ij +c ij log À d ij ð5Þ With this new formulation, we can either provide the parameter , using prior knowledge, and only optimize the structure and (which depends on the dataset), or we can use a non-metric approach, by inferring.
We refer to the former as PM1 and to the latter as PM2. PM2 is solved using a coordinate-descent algorithm: first choose randomly an X configuration, then iterate between maximizing L with respect to and and, fixing and and maximizing L with respect to X. In this work, we try to initialize X with a good approximation of the solution by first evaluating the parameters and using some prior knowledge and initialize X with the inferred structure from the MDS. All optimization problems (MDS1, MDS2, NMDS, PM1 and PM2) were solved using IPOPT, an interior point filter algorithm  (W€ achter and Biegler, 2006)  and the isotonic regression implementation from the Python toolbox Scikit-Learn for NMDS  (Pedregosa et al. , 2011).