04/11/2022 is added

This commit is contained in:
Marco Realacci 2022-11-06 17:27:39 +01:00
parent 5c00a2f16a
commit 01c9360b01
207 changed files with 2082 additions and 245 deletions

View file

@ -1,3 +0,0 @@
Si consideri il seguente requisito:
RQ: Durante l'esecuzione del programma (cioè per tutti gli istanti di tempo positivi) la variabile x è sempre nell'intervallo [0, 5].
Quale dei seguenti monitor meglio descrive il requisito RQ?

View file

@ -0,0 +1,44 @@
<pre>
block FSA // Finite State Automaton
/* connector declarations outside this block:
connector InputInteger = input Integer;
connector OutputInteger = output Integer;
*/
InputInteger u; // external input
OutputInteger x; // state
parameter Real T = 1;
algorithm
when initial() then
x := 0;
elsewhen sample(0,T) then
if (pre(x) == 0) and (pre(u) == 1) then x := 1;
elseif (pre(x) == 0) and (pre(u) == 2) then x := 1;
elseif (pre(x) == 1) and (pre(u) == 0) then x := 2;
elseif (pre(x) == 1) and (pre(u) == 1) then x := 4;
elseif (pre(x) == 1) and (pre(u) == 2) then x := 3;
elseif (pre(x) == 2) and (pre(u) == 0) then x := 0;
elseif (pre(x) == 2) and (pre(u) == 2) then x := 4;
elseif (pre(x) == 3) and (pre(u) == 0) then x := 0;
elseif (pre(x) == 3) and (pre(u) == 1) then x := 2;
elseif (pre(x) == 3) and (pre(u) == 2) then x := 4;
elseif (pre(x) == 4) and (pre(u) == 0) then x := 3;
elseif (pre(x) == 4) and (pre(u) == 1) then x := 1;
elseif (pre(x) == 4) and (pre(u) == 2) then x := 1;
else x := pre(x); // default
end if;
end when;
end FSA;
</pre>

View file

@ -0,0 +1,2 @@
img=https://i.imgur.com/jS97TUd.png
Quale dei seguenti modelli Modelica rappresenta lo state diagram in figura?

View file

@ -0,0 +1,77 @@
<pre>
block FSA // Finite State Automaton
/* connector declarations outside this block:
connector InputInteger = input Integer;
connector OutputInteger = output Integer;
*/
InputInteger u; // external input
OutputInteger x; // state
parameter Real T = 1;
algorithm
when initial() then
x := 0;
elsewhen sample(0,T) then
if (pre(x) == 0) and (pre(u) == 0) then x := 1;
elseif (pre(x) == 0) and (pre(u) == 1) then x := 1;
elseif (pre(x) == 0) and (pre(u) == 2) then x := 1;
elseif (pre(x) == 1) and (pre(u) == 0) then x := 2;
elseif (pre(x) == 1) and (pre(u) == 1) then x := 3;
elseif (pre(x) == 1) and (pre(u) == 2) then x := 0;
elseif (pre(x) == 2) and (pre(u) == 0) then x := 0;
elseif (pre(x) == 2) and (pre(u) == 1) then x := 3;
elseif (pre(x) == 2) and (pre(u) == 2) then x := 3;
elseif (pre(x) == 3) and (pre(u) == 0) then x := 4;
elseif (pre(x) == 3) and (pre(u) == 1) then x := 4;
elseif (pre(x) == 3) and (pre(u) == 2) then x := 0;
elseif (pre(x) == 4) and (pre(u) == 0) then x := 3;
elseif (pre(x) == 4) and (pre(u) == 1) then x := 3;
elseif (pre(x) == 4) and (pre(u) == 2) then x := 1;
else x := pre(x); // default
end if;
end when;
end FSA;
</pre>

View file

@ -0,0 +1,67 @@
<pre>
block FSA // Finite State Automaton
/* connector declarations outside this block:
connector InputInteger = input Integer;
connector OutputInteger = output Integer;
*/
InputInteger u; // external input
OutputInteger x; // state
parameter Real T = 1;
algorithm
when initial() then
x := 0;
elsewhen sample(0,T) then
if (pre(x) == 0) and (pre(u) == 0) then x := 2;
elseif (pre(x) == 0) and (pre(u) == 1) then x := 3;
elseif (pre(x) == 1) and (pre(u) == 0) then x := 2;
elseif (pre(x) == 1) and (pre(u) == 1) then x := 4;
elseif (pre(x) == 2) and (pre(u) == 0) then x := 3;
elseif (pre(x) == 2) and (pre(u) == 1) then x := 1;
elseif (pre(x) == 2) and (pre(u) == 2) then x := 0;
elseif (pre(x) == 3) and (pre(u) == 1) then x := 2;
elseif (pre(x) == 4) and (pre(u) == 0) then x := 1;
elseif (pre(x) == 4) and (pre(u) == 1) then x := 1;
else x := pre(x); // default
end if;
end when;
end FSA;
</pre>

View file

@ -0,0 +1,5 @@
int f(in x, int y)
{
assert( (x >= 0) && (y >= 0) && ((x > 3) || (y > 3)) );
.....
}

View file

@ -0,0 +1,7 @@
Pre-condizioni, invarianti e post-condizioni di un programma possono essere definiti usando la macro del C assert() (in <assert.h>). In particolare, assert(expre) non fa nulla se l'espressione expre vale TRUE (cioè non è 0), stampa un messaggio di errore su stderr e abortisce l'esecuzione del programma altrimenti.
Si consideri la funzione C
int f(int x, int y) { ..... }
Quale delle seguenti assert esprime la pre-condizione che entrambi gli argomenti di f sono non-negativi ed almeno uno di loro è maggiore di 3?

View file

@ -0,0 +1,10 @@
int f(in x, int y)
{
assert( (x >= 0) && (y >= 0) && ((x >= 3) || (y >= 3)) );
.....
}

View file

@ -0,0 +1,9 @@
int f(in x, int y)
{
assert( (x > 0) && (y > 0) && ((x >= 3) || (y > 3)) );
.....
}

View file

@ -0,0 +1 @@
F(x, y, z) = if (x > y) then (z == x) else (z == y + 1)

View file

@ -0,0 +1,17 @@
Un test oracle per un programma P è una funzione booleana che ha come inputs gli inputs ed outputs di P e ritorna true se e solo se il valore di output di P (con i dati inputs) è quello atteso dalle specifiche.
Si consideri la seguente funzione C:
-----------
int f(int x, int y) {
int z = x;
while ( (x <= z) && (z <= y) ) { z = z + 1; }
return (z);
}
Siano x, y, gli inputs del programma (f nel nostro caso) e z l'output. Assumendo il programma corretto, quale delle seguenti funzioni booleane F(x, y, z) è un test oracle per la funzione f.

View file

@ -0,0 +1 @@
F(x, y, z) = if (x > y) then (z == x + 1) else (z == y + 1)

View file

@ -0,0 +1 @@
F(x, y, z) = (z == y + 1)

View file

@ -0,0 +1 @@
img=https://i.imgur.com/toYPiWs.png

View file

@ -0,0 +1,76 @@
Si consideri il seguente modello Modelica. Quale dei seguenti state diagram lo rappresenta correttamente?
<pre>
block FSA // Finite State Automaton
/* connector declarations outside this block:
connector InputInteger = input Integer;
connector OutputInteger = output Integer;
*/
InputInteger u; // external input
OutputInteger x; // state
parameter Real T = 1;
algorithm
when initial() then
x := 0;
elsewhen sample(0,T) then
if (pre(x) == 0) and (pre(u) == 0) then x := 1;
elseif (pre(x) == 0) and (pre(u) == 1) then x := 1;
elseif (pre(x) == 0) and (pre(u) == 2) then x := 2;
elseif (pre(x) == 1) and (pre(u) == 0) then x := 0;
elseif (pre(x) == 1) and (pre(u) == 2) then x := 0;
elseif (pre(x) == 2) and (pre(u) == 0) then x := 3;
elseif (pre(x) == 2) and (pre(u) == 1) then x := 1;
elseif (pre(x) == 2) and (pre(u) == 2) then x := 3;
elseif (pre(x) == 3) and (pre(u) == 0) then x := 1;
elseif (pre(x) == 3) and (pre(u) == 1) then x := 4;
elseif (pre(x) == 3) and (pre(u) == 2) then x := 0;
elseif (pre(x) == 4) and (pre(u) == 1) then x := 2;
elseif (pre(x) == 4) and (pre(u) == 2) then x := 0;
else x := pre(x); // default
end if;
end when;
end FSA;
</pre>

View file

@ -0,0 +1 @@
img=https://i.imgur.com/0yWuing.png

View file

@ -0,0 +1 @@
img=https://i.imgur.com/AmIbYTU.png

View file

@ -0,0 +1 @@
0.12

View file

@ -0,0 +1,8 @@
img=https://i.imgur.com/pBLLwD1.png
Un processo software può essere rappesentato con uno state diagram in cui gli stati rappresentano le fasi (e loro iterazioni) del prcoesso software e gli archi le transizioni da una fase all'altra. Gli archi sono etichettati con le probabilità della transizione e gli stati sono etichettati con il costo per lasciare lo stato.
Ad esempio lo state diagram in figura rappresenta un processo software con 2 fasi F1 ed F2. F1 ha costo 10000 EUR ed F2 ha costo 1000 EUR. F1 ha una probabilita dello 0.4 di dover essere ripetuta (a causa di errori) ed F2 ha una probabilità 0.2 di dover essere ripetuta (a causa di errori).
Uno scenario è una sequenza di stati.
Qual è la probabilità dello scenario: 1, 3, 4? In altri terminti, qual è la probabilità che non sia necessario ripetere la seconda fase (ma non la prima)?

View file

@ -0,0 +1 @@
0.32

View file

@ -0,0 +1 @@
0.08

View file

@ -0,0 +1,19 @@
<pre>
#define n 1000
int TestOracle1(int *A, int *B)
{
int i, j, D[n];
//init
for (i = 0; i < n; i++) D[i] = -1;
// B is ordered
for (i = 0; i < n; i++) { for (j = i+1; j < n; j++) {if (B[j] < B[i]) {retun (0);}}}
// B is a permutation of A
for (i = 0; i < n; i++) { for (j = 0; j < n; j++) {if ((A[i] == B[j]) && (D[j] == -1)) {C[i][j] = 1; D[j] = 1; break;}
for (i = 0; i < n; i++) {if (D[i] == -1) return (0);}
// B ok
return (1);
}
</pre>

View file

@ -0,0 +1,7 @@
Un test oracle per un programma P è una funzione booleana che ha come inputs gli inputs ed outputs di P e ritorna true se e solo se il valore di output di P (con i dati inputs) è quello atteso dalle specifiche.
Si consideri la seguente specifica funzionale per la funzione f.
La funzione f(int *A, int *B) prende come input un vettore A di dimensione n ritorna come output un vettore B ottenuto ordinando gli elementi di A in ordine crescente.
Quale delle seguenti funzioni è un test oracle per la funzione f?

View file

@ -0,0 +1,29 @@
<pre>
#define n 1000
int TestOracle2(int *A, int *B)
{
int i, j, D[n];
//init
for (i = 0; i < n; i++) D[i] = -1;
// B is ordered
for (i = 0; i < n; i++) { for (j = i+1; j < n; j++) {if (B[j] < B[i]) {retun (0);}}}
// B is a permutation of A
for (i = 0; i < n; i++) { for (j = 0; j < n; j++) {if ((A[i] == B[j]) && (D[j] == -1)) {C[i][j] = 1; break;}
for (i = 0; i < n; i++) {if (D[i] == -1) return (0);}
// B ok
return (1);
}
</pre>

View file

@ -0,0 +1,29 @@
<pre>
#define n 1000
int TestOracle3(int *A, int *B)
{
int i, j, D[n];
//init
for (i = 0; i < n; i++) D[i] = -1;
// B is ordered
for (i = 0; i < n; i++) { for (j = i+1; j < n; j++) {if (B[j] < B[i]) {retun (0);}}}
// B is a permutation of A
for (i = 0; i < n; i++) { for (j = 0; j < n; j++) {if (A[i] == B[j]) {C[i][j] = 1; D[j] = 1; break;}
for (i = 0; i < n; i++) {if (D[i] == -1) return (0);}
// B ok
return (1);
}
</pre>

View file

@ -0,0 +1 @@
State coverage: 50%

View file

@ -0,0 +1,12 @@
img=https://i.imgur.com/mMq2O4x.png
La state coverage di un insieme di test cases (cioè sequenze di inputs) per uno state diagram è la percentuale di stati (inclusi START ed END) raggiunti almeno una volta.
Si consideri lo state diagram in figura
Si consideri il seguente insieme di test cases:
Test case 1: act1 act2 act0
Test case 2: act0 act1 act0 act0
Test case 3: act1 act0 act2 act2 act0
Quale delle seguenti è la migliore stima della state coverage per i test cases di cui sopra?

View file

@ -0,0 +1 @@
State coverage: 100%

View file

@ -0,0 +1 @@
State coverage: 75%

View file

@ -0,0 +1 @@
300000 EUR

View file

@ -0,0 +1,7 @@
Il rischio R può essere calcolato come R = P*C, dove P è la probabilità dell'evento avverso (software failure nel nostro contesto) e C è il costo dell'occorrenza dell'evento avverso.
Assumiamo che la probabilità P sia legata al costo di sviluppo S dalla formula
P = 10^{(-b*S)} (cioè 10 elevato alla (-b*S))
dove b è una opportuna costante note da dati storici aziendali. Si assuma che b = 0.0001, C = 1000000, ed il rischio ammesso è R = 1000. Quale dei seguenti valori meglio approssima il costo S per lo sviluppo del software in questione.

View file

@ -0,0 +1 @@
500000 EUR

View file

@ -0,0 +1 @@
700000 EUR

View file

@ -5,9 +5,7 @@ InputReal x; // plant output
OutputBoolean y;
Boolean z;
initial equation
y = false;
equation
z = (time > 0) and ((x > 5) or (x < 0));

View file

@ -0,0 +1,5 @@
Si consideri il seguente requisito:
RQ: Durante l'esecuzione del programma (cioè per tutti gli istanti di tempo positivi) la variabile x è sempre nell'intervallo [0, 5].
Quale dei seguenti monitor meglio descrive il requisito RQ?

View file

@ -1,15 +1,17 @@
<pre>
class Monitor
InputReal x, y;
OutputBoolean wy;
Boolean wz;
initial equation
wy = false;
equation
wz = (time > 60) and (delay(x, 10) > 0) and (y <= 0);
algorithm
when edge(wz) then
wy := true;
end when;
end Monitor;
<pre>
class Monitor
InputReal x, y;
OutputBoolean wy;
Boolean wz;
initial equation
wy = false;
equation
wz = (time > 60) and (delay(x, 10) > 0) and (y <= 0);
algorithm
when edge(wz) then
wy := true;
end when;
end Monitor;
</pre>

View file

@ -1,7 +1,9 @@
Si consideri il seguente requisito:
RQ: Dopo 60 unità di tempo dall'inizio dell'esecuzione vale la seguente proprietà:
se 10 unità di tempo nel passato era stata richiesta una risorsa (variabile x positiva) allora ora è concesso l'accesso alla
risorsa (variabile y positiva)
Tenendo presente che, al tempo time, delay(z, w) ritorna 0 se time < w e ritorna il valore che z aveva al tempo (time - w), se time
>= w.
Quale dei seguenti monitor meglio descrive il requisito RQ ?
Si consideri il seguente requisito:
RQ: Dopo 60 unità di tempo dall'inizio dell'esecuzione vale la seguente proprietà:
se 10 unità di tempo nel passato era stata richiesta una risorsa (variabile x positiva) allora ora è concesso l'accesso alla risorsa (variabile y positiva)
Tenendo presente che, al tempo time, delay(z, w) ritorna 0 se time < w e ritorna il valore che z aveva al tempo (time - w), se time >= w.
Quale dei seguenti monitor meglio descrive il requisito RQ?

View file

@ -1,15 +1,19 @@
<pre>
class Monitor
InputReal x, y;
OutputBoolean wy;
Boolean wz;
initial equation
wy = false;
equation
wz = (time > 60) and (delay(x, 10) > 0) and (y > 0);
algorithm
when edge(wz) then
wy := true;
end when;
end Monitor;
<pre>
class Monitor
InputReal x, y;
OutputBoolean wy;
Boolean wz;
initial equation
wy = false;
equation
wz = (time > 60) and (delay(x, 10) > 0) and (y > 0);
algorithm
when edge(wz) then
wy := true;
end when;
end Monitor;
</pre>

View file

@ -0,0 +1,20 @@
<pre>
class Monitor
InputReal x, y;
OutputBoolean wy;
Boolean wz;
initial equation
wy = false;
equation
wz = (time > 60) or (delay(x, 10) > 0) or (y <= 0);
algorithm
when edge(wz) then
wy := true;
end when;
end Monitor;
</pre>

View file

@ -0,0 +1 @@
img=https://i.imgur.com/EDqWXLf.png

View file

@ -0,0 +1,75 @@
Si consideri il seguente modello Modelica. Quale dei seguenti state diagram lo rappresenta correttamente?
<pre>
block FSA // Finite State Automaton
/* connector declarations outside this block:
connector InputInteger = input Integer;
connector OutputInteger = output Integer;
*/
InputInteger u; // external input
OutputInteger x; // state
parameter Real T = 1;
algorithm
when initial() then
x := 0;
elsewhen sample(0,T) then
if (pre(x) == 0) and (pre(u) == 0) then x := 1;
elseif (pre(x) == 0) and (pre(u) == 1) then x := 1;
elseif (pre(x) == 0) and (pre(u) == 2) then x := 3;
elseif (pre(x) == 1) and (pre(u) == 0) then x := 4;
elseif (pre(x) == 1) and (pre(u) == 1) then x := 2;
elseif (pre(x) == 2) and (pre(u) == 0) then x := 4;
elseif (pre(x) == 2) and (pre(u) == 1) then x := 0;
elseif (pre(x) == 2) and (pre(u) == 2) then x := 0;
elseif (pre(x) == 3) and (pre(u) == 0) then x := 0;
elseif (pre(x) == 3) and (pre(u) == 1) then x := 2;
elseif (pre(x) == 3) and (pre(u) == 2) then x := 2;
elseif (pre(x) == 4) and (pre(u) == 0) then x := 0;
elseif (pre(x) == 4) and (pre(u) == 2) then x := 3;
else x := pre(x); // default
end if;
end when;
end FSA;
</pre>

View file

@ -0,0 +1 @@
img=https://i.imgur.com/u6No1XI.png

View file

@ -0,0 +1 @@
img=https://i.imgur.com/SLOrqrl.png

View file

@ -1,15 +1,15 @@
<pre>
class Monitor
InputReal x, y;
OutputBoolean wy;
Boolean wz;
initial equation
wy = false;
equation
wz = (time > 60) or (delay(x, 10) > 0) or (y <= 0);
algorithm
when edge(wz) then
wy := true;
end when;
end Monitor;
<pre>
class Monitor
InputReal x, y;
OutputBoolean wy;
Boolean wz;
initial equation
wy = false;
equation
wz = (time > 40) and (delay(x, 10) > 1) and (y < 0);
algorithm
when edge(wz) then
wy := true;
end when;
end Monitor;
</pre>

View file

@ -0,0 +1,9 @@
Si consideri il seguente requisito:
RQ: Dopo 40 unità di tempo dall'inizio dell'esecuzione vale la seguente proprietà:
se 10 unità di tempo nel passato x era maggiore di 1 allora ora y è nonegativa.
Tenendo presente che, al tempo time, delay(z, w) ritorna 0 se time <= w e ritorna il valore che z aveva al tempo (time - w), se time = w.
Quale dei seguenti monitor meglio descrive il requisito RQ?

View file

@ -0,0 +1,17 @@
<pre>
class Monitor
InputReal x, y;
OutputBoolean wy;
Boolean wz;
initial equation
wy = false;
equation
wz = (time > 40) and (delay(x, 10) > 1) and (y >= 0);
algorithm
when edge(wz) then
wy := true;
end when;
end Monitor;
</pre>

View file

@ -0,0 +1,17 @@
<pre>
class Monitor
InputReal x, y;
OutputBoolean wy;
Boolean wz;
initial equation
wy = false;
equation
wz = (time > 40) or (delay(x, 10) > 1) or (y < 0);
algorithm
when edge(wz) then
wy := true;
end when;
end Monitor;
</pre>

View file

@ -0,0 +1 @@
F(x, y, z) = if (x >= 0) then (z == pow(y, x)) else (z == 1)

View file

@ -0,0 +1,19 @@
Un test oracle per un programma P è una funzione booleana che ha come inputs gli inputs ed outputs di P e ritorna true se e solo se il valore di output di P (con i dati inputs) è quello atteso dalle specifiche.
Si consideri la seguente funzione C:
-----------
<pre>
int f(int x, int y) {
int z, k;
z = 1; k = 0;
while (k < x) { z = y*z; k = k + 1; }
return (z);
}
</pre>
Siano x, y, gli inputs del programma (f nel nostro caso) e z l'output. Assumendo il programma corretto, quale delle seguenti funzioni booleane F(x, y, z) è un test oracle per la funzione f.

View file

@ -0,0 +1 @@
F(x, y, z) = if (x >= 0) then (z == pow(y, x)) else (z == y)

View file

@ -0,0 +1 @@
F(x, y, z) = if (x >= 0) then (z == pow(y, x)) else (z == 0)

View file

@ -1,15 +1,17 @@
<pre>
class Monitor
InputReal x; // plant output
OutputBoolean y;
Boolean z;
initial equation
y = false;
equation
z = (time > 0) and ((x >= 5) or (x <= 0)) and ((x >= 15) or (x <= 10)) ;
algorithm
when edge(z) then
y := true;
end when;
end Monitor;
<pre>
class Monitor
InputReal x; // plant output
OutputBoolean y;
Boolean z;
initial equation
y = false;
equation
z = (time > 0) and ((x >= 5) or (x <= 0)) and ((x >= 15) or (x <= 10)) ;
algorithm
when edge(z) then
y := true;
end when;
end Monitor;
</pre>

View file

@ -0,0 +1,5 @@
Si consideri il seguente requisito:
RQ1: Durante l'esecuzione del programma (cioè per tutti gli istanti di tempo positivi) la variabile x è sempre nell'intervallo [0, 5] oppure [10, 15]
Quale dei seguenti monitor meglio descrive il requisito RQ1 ?

View file

@ -1,15 +1,19 @@
<pre>
class Monitor
InputReal x; // plant output
OutputBoolean y;
Boolean z;
initial equation
y = false;
equation
z = (time > 0) and ((x >= 0) or (x <= 5)) and ((x >= 10) or (x <= 15)) );
algorithm
when edge(z) then
y := true;
end when;
end Monitor;
<pre>
class Monitor
InputReal x; // plant output
OutputBoolean y;
Boolean z;
initial equation
y = false;
equation
z = (time > 0) and ( ((x >= 0) and (x <= 5)) or ((x >= 10) and (x <= 15)) );
algorithm
when edge(z) then
y := true;
end when;
end Monitor;
</pre>

View file

@ -1,15 +1,19 @@
<pre>
class Monitor
InputReal x; // plant output
OutputBoolean y;
Boolean z;
initial equation
y = false;
equation
z = (time > 0) and ( ((x >= 0) and (x <= 5)) or ((x >= 10) and (x <= 15)) );
algorithm
when edge(z) then
y := true;
end when;
end Monitor;
<pre>
class Monitor
InputReal x; // plant output
OutputBoolean y;
Boolean z;
initial equation
y = false;
equation
z = (time > 0) and ((x >= 0) or (x <= 5)) and ((x >= 10) or (x <= 15)) );
algorithm
when edge(z) then
y := true;
end when;
end Monitor;
</pre>

View file

@ -0,0 +1 @@
Transition coverage: 40%

View file

@ -0,0 +1,14 @@
img=https://i.imgur.com/VZQnGCY.png
La transition coverage di un insieme di test cases (cioè sequenze di inputs) per uno state diagram è la percentuale di transizioni (archi nel grafo dello state diagram) percorsi almeno una volta.
Si consideri lo state diagram in figura
ed il seguente insieme di test cases:
Test case 1: act1 act2 act0 act1
Test case 2: act1 act0 act1 act1 act2 act2 act0
Test case 3: act1 act2 act0 act0
Quale delle seguenti è la migliore stima della transition coverage per i test cases di cui sopra?

View file

@ -0,0 +1 @@
Transition coverage: 70%

View file

@ -0,0 +1 @@
Transition coverage: 100%

View file

@ -0,0 +1 @@
La variabile x è nell'intervallo [0, 5]

View file

@ -0,0 +1,29 @@
Si consideri il monitor seguente che ritorna true appena i requisiti per il sistema monitorato sono violati.
<pre>
block Monitor
input Real x;
output Boolean y;
Boolean w;
initial equation
y = false;
equation
w = ((x < 0) or (x > 5));
algorithm
when edge(w) then
y := true;
end when;
end Monitor;
</pre>
Quale delle seguenti affermazioni meglio descrive il requisito monitorato.

View file

@ -0,0 +1 @@
La variabile x è fuori dall'intervallo [0, 5]

View file

@ -0,0 +1 @@
La variable x è minore di 0

View file

@ -1,15 +1,17 @@
<pre>
class Monitor
InputReal x, y; // plant output
OutputBoolean wy;
Boolean wz;
initial equation
wy = false;
equation
wz = (time > 10) and (x >= 10) and (x <= 20) and ((y < 0.5*x) or (y > 0.7*x)) ;
algorithm
when edge(wz) then
wy := true;
end when;
end Monitor;
<pre>
class Monitor
InputReal x, y; // plant output
OutputBoolean wy;
Boolean wz;
initial equation
wy = false;
equation
wz = (time > 10) and (x >= 10) and (x <= 20) and ((y < 0.5*x) or (y > 0.7*x)) ;
algorithm
when edge(wz) then
wy := true;
end when;
end Monitor;
</pre>

View file

@ -0,0 +1,5 @@
Si consideri il seguente requisito:
RQ: Dopo 10 unità di tempo dall'inizio dell'esecuzione vale la seguente proprietà: se la variabile x è nell'intervallo [10, 20] allora la variabile y è compresa tra il 50% di x ed il 70% di x.
Quale dei seguenti monitor meglio descrive il requisito RQ ?

View file

@ -1,15 +1,19 @@
<pre>
class Monitor
InputReal x, y; // plant output
OutputBoolean wy;
Boolean wz;
initial equation
wy = false;
equation
wz = (time > 10) and (x >= 10) and (x <= 20) and (y >= 0.5*x) and (y <= 0.7*x) ;
algorithm
when edge(wz) then
wy := true;
end when;
end Monitor;
<pre>
class Monitor
InputReal x, y; // plant output
OutputBoolean wy;
Boolean wz;
initial equation
wy = false;
equation
wz = (time > 10) and (x >= 10) and (x <= 20) and (y >= 0.5*x) and (y <= 0.7*x) ;
algorithm
when edge(wz) then
wy := true;
end when;
end Monitor;
</pre>

View file

@ -1,15 +1,19 @@
<pre>
class Monitor
InputReal x, y; // plant output
OutputBoolean wy;
Boolean wz;
initial equation
wy = false;
equation
wz = (time > 10) and ((x < 10) or (x > 20)) and ((y < 0.5*x) or (y > 0.7*x)) ;
algorithm
when edge(wz) then
wy := true;
end when;
end Monitor;
<pre>
class Monitor
InputReal x, y; // plant output
OutputBoolean wy;
Boolean wz;
initial equation
wy = false;
equation
wz = (time > 10) and ((x < 10) or (x > 20)) and ((y < 0.5*x) or (y > 0.7*x)) ;
algorithm
when edge(wz) then
wy := true;
end when;
end Monitor;
</pre>

View file

@ -0,0 +1 @@
c(0)/(1 - p)

View file

@ -0,0 +1,10 @@
img=https://i.imgur.com/jQT3J83.png
Si consideri il processo software con due fasi (0 ed 1) rappresentato con la Markov chain in figura. Lo stato iniziale 0 e p è in (0, 1). Il costo dello stato (fase) x è c(x). La fase 0 è la fase di design, che ha probabilità p di dover essere ripetuta causa errori. La fase 1 rappreenta il completamento del processo software, e quindi c(1) = 0.
Il costo di una istanza del processo software descritto sopra è la somma dei costi degli stati attraversati (tenendo presente che si parte sempre dallo stato 0.
Quindi il costo C(X) della sequenza di stati X = x(0), x(1), x(2), .... è C(X) = c(x(0)) + c(x(1)) + c(x(2)) + ...
Ad esempio se X = 0, 1 abbiamo C(X) = c(0) + c(1) = c(0) (poichè c(1) = 0).
Quale delle seguenti formule calcola il valore atteso del costo per completare il processo software di cui sopra

View file

@ -0,0 +1 @@
c(0)/(p*(1 - p))

View file

@ -0,0 +1 @@
c(0)/(1 - p)

View file

@ -0,0 +1 @@
Test set: {x=3, y=6}, {x=0, y=0}, {x=15, y=0}, {x=9, y=0}

View file

@ -0,0 +1,15 @@
Il branch coverage di un insieme di test cases è la percentuale di branch del programma che sono attraversati da almeno un test case.
Si consideri la seguente funzione C:
-----------
<pre>
int f(int x, int y) {
if (x - y - 6 <= 0) { if (x + y - 3 >= 0) return (1); else return (2); }
else {if (x + 2*y -15 >= 0) return (3); else return (4); }
} /* f() */
</pre>
Quale dei seguenti test sets consegue una branch coverage del 100% ?

View file

@ -0,0 +1 @@
Test set: {x=3, y=6}, {x=2, y=1}, {x=15, y=0}, {x=9, y=0}

View file

@ -0,0 +1 @@
Test set: {x=3, y=6}, {x=0, y=0}, {x=15, y=0}, {x=10, y=3}

View file

@ -0,0 +1 @@
Transition coverage: 50%

View file

@ -0,0 +1,13 @@
img=https://i.imgur.com/TXCFgeI.png
La transition coverage di un insieme di test cases (cioè sequenze di inputs) per uno state diagram è la percentuale di transizioni (archi nel grafo dello state diagram) percorsi almeno una volta.
Si consideri lo state diagram in figura
ed il seguente insieme di test cases:
Test case 1: act1 act2 act0
Test case 2: act2 act2 act2 act2 act2 act2 act0
Test case 3: act2 act0 act2 act0 act1 act2 act2 act2 act2 act2 act1 act0 act0 act2 act2 act2 act1 act2 act2 act2 act2 act2 act1 act2 act2 act2 act0
Quale delle seguenti è la migliore stima della transition coverage per i test cases di cui sopra?

View file

@ -0,0 +1 @@
Transition coverage: 35%

View file

@ -0,0 +1 @@
Transition coverage: 90%

View file

@ -0,0 +1,9 @@
<pre>
int f(in x, int y)
{
int z, w;
assert( (z + w < 1) || (z + w > 7));
.....
}
</pre>

View file

@ -0,0 +1,7 @@
Pre-condizioni, invarianti e post-condizioni di un programma possono essere definiti usando la macro del C assert() (in <assert.h>). In particolare, assert(expre) non fa nulla se l'espressione expre vale TRUE (cioè non è 0), stampa un messaggio di errore su stderr e abortisce l'esecuzione del programma altrimenti.
Si consideri la funzione C
int f(int x, int y) { ..... }
Quale delle seguenti assert esprime l'invariante che le variabili locali z e w di f() hanno somma minore di 1 oppure maggiore di 7 ?

View file

@ -0,0 +1,13 @@
<pre>
int f(in x, int y)
{
int z, w;
assert( (z + w <= 1) || (z + w >= 7));
.....
}
</pre>

View file

@ -0,0 +1,13 @@
<pre>
int f(in x, int y)
{
int z, w;
assert( (z + w > 1) || (z + w < 7));
.....
}
</pre>

View file

@ -0,0 +1 @@
img=https://i.imgur.com/SXM3yWp.png

View file

@ -0,0 +1,70 @@
Si consideri il seguente modello Modelica. Quale dei seguenti state diagram lo rappresenta correttamente ?
<pre>
block FSA // Finite State Automaton
/* connector declarations outside this block:
connector InputInteger = input Integer;
connector OutputInteger = output Integer;
*/
InputInteger u; // external input
OutputInteger x; // state
parameter Real T = 1;
algorithm
when initial() then
x := 0;
elsewhen sample(0,T) then
if (pre(x) == 0) and (pre(u) == 0) then x := 1;
elseif (pre(x) == 0) and (pre(u) == 1) then x := 2;
elseif (pre(x) == 1) and (pre(u) == 0) then x := 0;
elseif (pre(x) == 1) and (pre(u) == 1) then x := 0;
elseif (pre(x) == 1) and (pre(u) == 2) then x := 2;
elseif (pre(x) == 2) and (pre(u) == 0) then x := 4;
elseif (pre(x) == 2) and (pre(u) == 2) then x := 1;
elseif (pre(x) == 3) and (pre(u) == 1) then x := 0;
elseif (pre(x) == 4) and (pre(u) == 0) then x := 0;
elseif (pre(x) == 4) and (pre(u) == 1) then x := 1;
elseif (pre(x) == 4) and (pre(u) == 2) then x := 0;
else x := pre(x); // default
end if;
end when;
end FSA;
</pre>

View file

@ -0,0 +1 @@
img=https://i.imgur.com/CeDe2lF.png

View file

@ -0,0 +1 @@
img=https://i.imgur.com/HBR1EoE.png

View file

@ -0,0 +1 @@
Requisito funzionale

View file

@ -1,2 +1,3 @@
"Ogni giorno, per ciascuna clinica, il sistema genererà una lista dei pazienti che hanno un appuntamento quel giorno."
"Ogni giorno, per ciascuna clinica, il sistema genererà una lista dei pazienti che hanno un appuntamento quel giorno."
La frase precedente è un esempio di:

View file

@ -0,0 +1 @@
Requisito di performance

View file

@ -0,0 +1 @@
time(0)/(1 - p)

View file

@ -0,0 +1,10 @@
img=https://i.imgur.com/jQT3J83.png
Si consideri il processo software con due fasi (0 ed 1) rappresentato con la Markov chain in figura. Lo stato iniziale 0 e p è in (0, 1). Il tempo necessario per completare la fase x è time(x). La fase 0 è la fase di design, che ha probabilità p di dover essere ripetuta causa errori. La fase 1 rappreenta il completamento del processo software, e quindi time(1) = 0.
Il tempo di una istanza del processo software descritto sopra è la somma dei tempi degli stati (fasi) attraversati (tenendo presente che si parte sempre dallo stato 0.
Quindi il costo Time(X) della sequenza di stati X = x(0), x(1), x(2), .... è Time(X) = time(x(0)) + time(x(1)) + time(x(2)) + ...
Ad esempio se X = 0, 1 abbiamo Time(X) = time(0) + time(1) = time(0) (poichè time(1) = 0).
Quale delle seguenti formule calcola il valore atteso del costo per completare il processo software di cui sopra

View file

@ -0,0 +1 @@
time(0)/(p*(1 - p))

View file

@ -0,0 +1 @@
time(0)*(1 - p)/p

View file

@ -1,15 +1,17 @@
<pre>
class Monitor
InputReal x; // plant output
OutputBoolean y;
Boolean z;
initial equation
y = false;
equation
z = (time > 20) and ((x >= 30) or (x <= 20)) ;
algorithm
when edge(z) then
y := true;
end when;
end Monitor;
<pre>
class Monitor
InputReal x; // plant output
OutputBoolean y;
Boolean z;
initial equation
y = false;
equation
z = (time > 20) and ((x >= 30) or (x <= 20)) ;
algorithm
when edge(z) then
y := true;
end when;
end Monitor;
</pre>

View file

@ -0,0 +1,5 @@
Si consideri il seguente requisito:
RQ1: Dopo 20 unità di tempo dall'inizio dell'esecuzione la variabile x è sempre nell'intervallo [20, 30] .
Quale dei seguenti monitor meglio descrive il requisito RQ1 ?

View file

@ -1,15 +1,19 @@
<pre>
class Monitor
InputReal x; // plant output
OutputBoolean y;
Boolean z;
initial equation
y = false;
equation
z = (time > 20) and (x >= 20) and (x <= 30) ;
algorithm
when edge(z) then
y := true;
end when;
end Monitor;
<pre>
class Monitor
InputReal x; // plant output
OutputBoolean y;
Boolean z;
initial equation
y = false;
equation
z = (time > 20) and (x >= 20) and (x <= 30) ;
algorithm
when edge(z) then
y := true;
end when;
end Monitor;
</pre>

Some files were not shown because too many files have changed in this diff Show more