






Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
The process of modeling a library borrowing system using devsjava, including the creation of atomic models for borrowers and observers, a librarybook model, and a booktest template for testing the librarybook implementation. The document also includes an example of a skier model and the use of observers to capture speed and distance. The goal is to create a test suite for any model that claims to correctly represent the required behavior.
Typology: Exams
1 / 10
This page cannot be seen from the preview
Don't miss anything!







ECE 575 Final Exam Solutions The exam consists of three problems, each worth 33 points. You may work in pairs. There is no penalty for doing so. Each member of a team will receive the score of the team. Solutions are due December 5, 2003.
Your task is not to construct this model, but to construct a test suite to test any model that claims to correctly represent the required behavior. The test suite is a collection of borrower models, each one able to interface with the book model and representing a different borrower behavior. Recall that ability to interface means that a borrower model has output ports that can be meaningfully coupled to input ports of the libraryBook model likewise, input ports that can receive inputs from libraryBook outputs (as shown below). request return pay libraryBook bookDue denied thankU payDue privilegeRevoked borrower request return pay bookDue denied thankU payDue privilegeRevoked For example, a punctualBorrower requests a borrowed book .and then returns it before the 30 day due date. At the other extreme, an inconsiderateBorrower never returns a borrowed book, never pays the fine, and even tries to borrow the book again. a) Define a ViewableAtomic model class, borrower , that has that has no features other than the input and output ports shown in the above figure. Each specific borrower class will extend this class and thus have the right interface. b) Define a ViewableDigraph model class, libraryBook , that has no features other than the input and output ports shown in the figure. A specific libraryBook class (e.g., that I might insert), will extend this class and thus have the right interface. c) Define a ViewableDigraph model class, bookTest , that has a constructor with no arguments, as well as a constructor that has two arguments, taking instances of libraryBook , and borrower , classes (or their extensions), respectively. Define the coupling shown in the above figure, between the pair of model instances added into bookTest from the constructor arguments. In the zero-argument constructor, set the arguments of the two-argument constructor to instances of the base clases, libraryBook and borrower. You should be able to see the models and couplings in SimView. The two-argument constructor of bookTest can be used to test a libraryBook implementation with any specific borrower atomic model.
public bookTest(libraryBook book, borrower bor){ super("bookTest: " + book.getName() + " and " + bor.getName()); this.add(book); this.add(bor); addCoupling(book, libraryBook.DENIED_PT, bor, borrower.DENIED_PT); addCoupling(book, libraryBook.BOOK_DUE_PT, bor, borrower.BOOK_DUE_PT); addCoupling(book, libraryBook.THANK_YOU_PT, bor, borrower.THANK_YOU_PT); addCoupling(book, libraryBook.PAY_DUE_PT, bor, borrower.PAY_DUE_PT); addCoupling(book, libraryBook.PRIVILEGE_REVOKED_PT, bor, borrower.PRIVILEGE_REVOKED_PT); addCoupling(bor, borrower.REQUEST_PT, book, libraryBook.REQUEST_PT); addCoupling(bor, borrower.RETURN_PT, book, libraryBook.RETURN_PT); addCoupling(bor, borrower.PAY_PT, book, libraryBook.PAY_PT); } } This template is instantiated by actual examples of libraryBook and borrower subclasses.
dv/dt = f(p,v) p^ dp/dt = v f(p,v) v The instantaneous function, f in the above figure, is described as follows. f(p,v) = 0, if v < 0 (the acceleration is turned off as soon as the skier stops). For v>= 0, f(p,v) is only a function of p and it gives the acceleration that the skier experiences in each segment of the course. Segments are the regions between successive flags and are assumed to be straight lines of length, q, with specified slopes. This means that the acceleration can be assumed to be constant in each segment. In the first segment the slope is 0 and the acceleration is due to the skier’s use of his poles to start off. In the last segment that stretches to infinity, the acceleration is negative as the skier uses a constant friction force to stop. In each interior segment, the acceleration is positive (it depending on its slope, but we will not need to say how). a) If, as in the figure, the hill is represented by 7 segments, and the corresponding accelerations are a1, a2,…, a7, write the mathematical description of f(p,v): f(p,v) = 0 if v < 0 // this is needed to all the skier to stop without then reversing direction =a1 if 0 < p< q and v >= = a2 if q <= p< 2q and v >= = a3 if 2q <= p< 3q and v >= = a4 if 3q <= p< 4q and v >= = a5 if 4q <= p< 5q and v >= = a6 if 5q <= p< 6q and v >= = a7 if p >= 6q and v >=
b) Modify secondOrderSys and associated class files to model the skier using the above description, where the parameters, L (total length between first and last flags) and a1, a2, …, a7, are given through a constructor. c) Form a model-frame pair by coupling the obsExp of problem 2 with the coupled model in 3 b). Simulate the model with parameters L = 70, and a1 = 1, a2 = 3, a3 = 2, a4 = 3, a = 2, a6 = 1, a7 = -3. Then simulate again with the same parameters except for switching the values of a1 and a3 – this corresponds to the skier making a faster start and then using less acceleration later on so that his total energy input is the same. Do both simulations produce the same finish times as measured by the obsExp? If so, explain why. If not, which is faster and why? (Hint: look at the output of the speed observer.) p f(p,v) v pin vin (^) speed observer time observer vout tout pin vin (^) distance observer pout pin L vout pout vin pin L tout pout vout From Robinson Cruso Marri and Deepak Bharadwaj: The model-frame pair is a coupling between exp frame expObs (prob 2) and the model coupledskier (prob 3b). This model was simulated with the given parameters with L= 70, a1=1, a2=3, a3=2, a4=3, a5=2, a6=1, a7=-3. The finish time observed with these parameters was t = 9.8s. The total distance measured by Dobs was 100.296. The model was again simulated with the new parameters where a1 and a3 were exchanged with L= 70, a1=2, a2=3, a3=1, a4=3, a5=2, a6=1, a7=-3. The finish time observed with these parameters was t = 8.2s. The total distance measured by Dobs was 100.326. The outputs of the Sobs in both cases are given below for analysis Distance Speed(a1=1,a3=2) Speed(a1=2,a3=1) 10 4.511 6. 20 8.976 10. 30 10.982 10.
Let’s use vT as the speed threshold. Assume that the skier reduces his accelerations so that his speed is always less than or equal to vT and he doesn’t fall. Then his finish time must equal or exceed L/ vT. We can first look at an ideal (but impossible case) and then look at an optimal strategy. If we assume that the skier is capable of instantaneously reaching speed vT, then we could construct a flat slope (0 acceleration) and the skier would travel the entire slope at speed vT and would complete the course in L/ vT seconds. In fact, we cannot instantaneously speed up. Assume that we must employ constant accelerations within segments as above. Consider the following strategy: We use a constant acceleration in the first segment to reach vT at the end of it. The average speed on this stretch will be vT /2 and the time to travel that distance will be (L/6)/( vT /2) or 2L/6 vT. The other 5 segments will use zero acceleration to keep the speed from exceeding vT /2 and they will each be traveled in time (L/6)/ vT or L/6 vT. The total time to travel all 6 segments would then be 7L/6 vT or (7/6)(L/ vT). This is the fastest travel time possible without a fall being detected. If we try to use a higher acceleration in the first segment, the velocity will reach the threshold and there is no way of keeping it from exceeding the threshold. This is only possible by reaching the threshold at the end of the first segment and then reducing the acceleration to zero at the beginning of the next segment. So we can call this the “push as hard as you can and then coast” strategy – and it corresponds to what skiers and bob-sleders do.