1
0

3 Коммитууд c803527c07 ... 50bedeb22b

Эзэн SHA1 Мессеж Огноо
  Federico Amedeo Izzo 50bedeb22b Added AI, SE2 and FLC notes 9 жил өмнө
  Federico Amedeo Izzo 677869c040 Merge branch 'master' of ssh://5.135.184.4:10022/nimayer/polimd 9 жил өмнө
  Federico Amedeo Izzo efba1cc2fd Added third lesson of SE2 and AI 9 жил өмнө

+ 104 - 0
Artificial Intelligence/lesson_03.md

@@ -0,0 +1,104 @@
+# AI - lesson 03
+#### Francesco Arrigoni
+###### 14 October 2015
+## Goal Oriented agents
+Historically called __problem-solving agents__
+
+Steps involved:
+1. __Formulate a problem__  
+    Usually performed by the designer
+2. __Search for a solution__  
+    Usually performed by the agent itself
+3. __Execute the actions__ that compose the solution.  
+    Performed by the agent
+
+This is different from usual systems in which step 2 (formulate the algorithm) is performed by a human.
+
+The types of algorithms created by the agents are usually simple, without IF statements.
+
+### Formulating the problem:
+The __environment__ we have to interact with is:
+- static
+- deterministic
+- fully observable
+- known
+- discrete
+
+The problem can be formulated defining the following five elements:  
+(example problem is the reduced version of 15 puzzle: 8 puzzle)
+1. The __initial state__: a description of the initial situation of the problem
+2. __Actions__ (s) = {actions that are applicable is s} Return the legal moves from the state s.
+
+ The state s<sub>0</sub> is
+ 7|2|3
+ ---|---|---
+ 1|4|8
+6|5|
+
+Actions(s<sub>0</sub>)={$\leftarrow,\uparrow$}
+3. __Result__ (s,a) = s' have the chosen move as argument and returns the new state.  
+$a \in Action(s)$  
+The __result__ function is also called transition function (model)
+
+We are considering a deterministic model, so that the result of a given action is *fixed*
+
+I can state that __initial state__, __actions__ and __result__ are elements of a *graph* named __state space__
+
+In our __state space__ graph:
+- *vertices* correspond to *states*  
+- *arcs* correspond to *actions*.
+
+The graph is *implicitly defined*, it's not represented with an incidence matrix.  
+For example the state space of chess game is estimated to be $10^{120}$.  
+It is almost impossible to represent, but we can build algorithm that can win a game exploring only a very small portion of the graph.
+
+The agents viewed at lesson are in a sense less powerful than Operating Research algoritms, but they don't require knowing the totality of the graph, and this is an advantage.
+
+A __path__ on a graph is a *sequence of states* that are connected on the graph.
+
+4. __Goal test__: returns true or false, it is a test to check if the case is final or not.
+    - __explicit__ goal test: list of all the final states ex: 8 puzzle
+    - __implicit__ goal test: condition that characterizes final states ex: chess
+
+Every path in the state space should be associate to a *cost* (number), that is the sum of the costs of the action composing the path.
+5. __Path cost__: is the sum of the costs of the action composing the path.
+
+The __solution__ of the problem is defined as
+> The path in the state space that brings from the initial state to any state satisfying the goal test
+
+The __optimal solution__ is the solution with *minimum* path cost.
+
+Our model is limited to the relevant aspects of the problem, for example it doesn't comprehend the color of the tiles in the 8 puzzle.
+
+### The 8 queens problem  
+-|1|2|3|4|5|6|7|8
+---|---|---|---|---|---|---|---|---
+1|Q
+2|
+3|
+4|||||||Q
+5|
+6|
+7|
+8|
+We have to place the 8 queens so that no two queens are in the same row, column or diagonal.
+#### first problem formulation:
+1. initial state:   empty board
+2. actions(s)= {add a queen in an empty cell}
+3. result(s,a)=  
+4. goal test:  are there 8 queens on the board and no one is attacked?
+5. step cost  
+
+state space: $64\times63\times...\times57=1.8\times10^{44}$
+#### second formulation:
+1. initial state:   empty board
+2. actions(s)= {add a queen in the left most empty column such that the queen is not attacked}
+3. result(s,a)=  
+4. goal test:  are there 8 queens on the board?
+5. step cost
+state space: $2057$
+
+In the first formulation all the rules of the game were embedded in the goal test,  
+In the second formulation, all the knowledge is embedded in the action function,  
+so the check of a legal step is made every action and not in the end.
+> In general is smarter to embed as much knowledge as possible in the action function, and leave as little as possible to the goal test, doing this we reduce the size of the state space, which can make difference between practically solving a problem and impossible to solve problems.  

+ 90 - 0
Artificial Intelligence/lesson_04.md

@@ -0,0 +1,90 @@
+# AI - lesson 04
+#### Francesco Arrigoni
+###### 16 October 2015
+## Searching for solutions
+#### Steps:
+1. select the __root node__
+2. select the __next node__
+3. apply the __goal function__ to the selected node
+    - If function is true: end
+    - if function is false, 4. generate the __successor nodes__
+
+#### Steps in detail
+- First, The root is created
+- After chosing the first node, i have to choose another node, different than the root,  
+for doing this we define a __frontier__ containing the nodes that are reachable but are not yet analized.
+- Next, i chose a node from the frontier, eliminating it from the latter, i applicate the goal function, and if the function is false, i expand the node, creating the next nodes and add them to the frontier.
+
+> The frontier contains only leaf nodes of the tree (but not all leafs, see next def.)  
+
+> There can be leaf nodes that are not in the frontier, for example already analized nodes with no childrens
+
+*Search tree* __nodes__ and *State space* __states__ are __different!__
+
+For example the same state in the state space can be represented by multiple nodes in the search tree.
+
+__nodes__ in the search tree correspond to __paths__ in the *state space*, the state space __path__ is composed by nodes from the root to the node in the __search tree__
+
+#### Informations contained in a node data structure:
+- The corresponding __state__  
+ex: 1, 1
+- The pointer to the __father__  
+ex: null, node 4
+- The __action__ that has brought to that node  
+ex: null, action a
+- The __path cost__ $g(n)$ to reach that node  
+ex: 0, 3
+
+As we have seen both nodes correspond to state 1 but they are different entities.
+
+#### Choosing the next node from the frontier
+- I can choose the node corresponding to the smallest state (not clever)
+- It is better to keep the frontier ordered to some criteria and select the first node in that order (no need to implement policies)
+- For example the frontier can be implemented as a __priority queue__
+
+#### Is it necessary to keep different path to the same states?
+No, it is not but we have some constraints.
+
+#### How can i do to eliminate multiple paths to the same state in the search tree
+I can use a data structure historically called __closed list__ (or explored set)
+
+In the __closed list__ you keep the __states__ for with you have already selected a node.  
+For example:
+- When i select the node 1, the goal test fails, i will expand it and add to the closed list.
+- Next i select node 2 from the frontier, the goal test fails and __before expanding__ i will __check if node 2 is already in closed list__, otherwise i expand it and add to the closed list.
+- If i find a node that is __already on the closed__ list i will __not expand it__ and select another node from the frontier.
+
+To be sure to find an __optimal solution__ i need to be sure that the first path that i find to the state is the __minimum cost path__.
+
+#### The use of closed list ensures:
+- Every time you expand a node, you add to the closed list
+- Before expanding a node, you check first if it is on the closed list.
+
+#### Versions of the tree search algorithm
+- __With closed list__ (with elimination of repeated states) in book is called GRAPH-SEARCH
+- __Without closed list__ (without elimination of repeated states) in book is called TREE-SEARCH
+
+The definitions in parenthesis are wrong because states are not repeated, we eliminate nodes that lead to the same states.  
+The upcase names indicates that the second algorithm is optimal for states spaces that are trees (quite twisted naming convention from the book).
+
+#### When I can say that i have no solutions?
+If the frontier is empty.
+In the *closed list version* of the algorith i can detect that the problem has no solutions, while with the version *without closed list* i can not detect that the problem has no solutions before exploring all the different paths.
+
+#### Why is the version without closed list used?
+Because the closed list can take a lot of space in memory, while the version without it uses way less memory.
+
+#### Search strategies
+Ways of selecting nodes from the frontier, can be:
+- __completeness__: when i can guarantee that if the solution exists, i will find it.
+- __optimality__: when i can guarantee that i can find the minimum cost solution.
+- __complexity__: can be measured as
+    - __space complexity__: number of nodes generated in the search tree
+    - __time complexity__:
+
+These properties can be evaluated according to four parameters:
+- __Branching factor__ $b$: the maximum number of children that a node can have
+- __Depth of the less deep solution__ $d$: solutiuon which is closest to the root
+- __Maximum path length in state space__ $m$: can be infinite
+- __Cost of the optimal solution__ $c^*$
+If all the costs are 1 i can claim that $d$ and $c^*$ are the same

+ 7 - 7
Formal Languages and Compilers/lesson_01.md

@@ -29,7 +29,7 @@ There is an effective procedure to verify the grammatical *correctness* of a phr
 - Formal language theory becomes a standard university discipline
 - Introduction of SDKs like Flex or Bison
 ---
-## Lesson 1
+## Formal Languages, Basic Notions
 ### Definition of a language
 - __Alphabet__: finite set of elements
 - __String__: Ordered set of atomic elements, possibly repeated
@@ -44,12 +44,12 @@ It can be 0 for the __empty language__ or *infinite* for __infinite languages__.
 ---
 ### Operations on strings
 
-####Lenght of a string
+#### Lenght of a string
 Is the number of elements contained
 
 $|bbc|=3\;\;\;\;|abbc|=4$
 
-####Equality of two strings
+#### Equality of two strings
 Two strings are equal if and only if
 - They have the same length
 - Their elements coincide in the same order
@@ -63,10 +63,10 @@ es: $x=a_1a_2 \;\;\;\;\;y=b_1b_2b_3$
 
    $x.y=a_1a_2b_1b_2b_3=xy$
 
-##### Empty string (or null string) $\varepsilon$:
+#### Empty string (or null string) $\varepsilon$:
  is the neutral element respective to concatenation
 
-##### Substring:
+#### Substring:
 Given a string x = u y v
 - x is a prefix
 - y is a substring
@@ -74,10 +74,10 @@ Given a string x = u y v
 
 if u,v ≠ Ɛ,  y is a proper substring
 
-##### Mirroring or Reflection
+#### Mirroring or Reflection
 $x=atri\;\;\;\;x^r=irta$
 
-##### Repetition or iteration
+#### Repetition or iteration
 The m-th power of a string concatenates the string to itself for m-1 times
 
 $x=ab\;\;x^0=\varepsilon$

+ 20 - 11
Formal Languages and Compilers/lesson_02.md

@@ -3,43 +3,52 @@
 ###### 8 october 2015
 
 ## Operations on languages
-Applies (and is defined) to each string in the language
+An operation defined on a language, applies to (and is definable over) each string in the language.
 $$L^R=\{|x=y^R\wedge y\in L\}$$
 #### Prefix-free language
 $$\text{prefix}(L)=\{y|x=yz\wedge x\in L\wedge y,z\neq\varepsilon\}$$
-There isn't any string that is prefix of another.
+In the language there is not any string that is prefix of another.
 $$\text{prefix(L)} \cap L=\Phi$$
 
 #### Concatenation
 $$L'L''=\{xy|x\in L' \wedge y \in L''\}$$
 #### m-th power (m≥0)
 $$L^m=L^{m-1}L,m>0\;\;L^0=\{\varepsilon\}$$
+#### Strings of finite length
+The language of the strings that have a length not greater than an integer k
+$$L=\{\varepsilon,a,b\}^3 \;k=3$$
+$$L=\{\varepsilon,a,b,aa,ab,ba,bb,aaa,...,bbb\}$$
+The $\varepsilon$ is useful to obtain the strings of length 0,1,2  
+We can exclude the empty string $\varepsilon$ in the following way.
+$$L\{a,b\}\{\varepsilon,a,b\}^2$$
 ---
 ### Set-theoretic Operations
+Are traditional operators of set theory, like __union__ $\cup$, __intersection__ $\cap$, __complement__ $\lnot$, also __strict inclusion__, __inclusion__, __equality__, __inequality__...
 #### Universal language
 The set of all strings defined over the alphabet $\Sigma$, also called __free monoid__.
 #### Complement of a language
-Set-theoretic difference between the universal language and the given language
+over the alphabet $\Sigma$ is the set-theoretic difference between the universal language and the given language
 $$\lnot L =L_{universal} \setminus L$$
+>The complement of a finite language is always an infinite language  
+The complement of ain infinite language may be infinite or finite.
 #### Set-theoretic difference
+$$L_1\setminus L_2$$
+Is the language containing all the strings of $L_1$ that __are not part__ of $L_2$
 
 ---
 ### Star Operator
-Also called Kleene star or Concatenation closure.  
-Is the union of all powers of a language
+Also called __Kleene star__ or __concatenation closure__.  
+Is the union of all powers of a language, for every positive or null exponent.
+$$L^*=\bigcup_{h=0...\infty}L^h=L^0\cup L^1\cup L^2...=\varepsilon\cup L^1\cup L^2...$$
 $$L=\{ab,ba\}\;L^*=\{\varepsilon,ab,ba,abab,abba,baab,baba,...\}$$
-<!--*-->
 #### Properties:
 - monotonic
 - closed w.r.t. Concatenation
 - idempotent
 - commutes with mirroring
 
-##### example
-$$\sum_A=\{A,B,...,Z\} \; \sum_N=\{0,1,2,...,9\}$$
-
-#### Cross Operator
-Also called Kleene cross, or $\varepsilon$-free concatenation closure
+### Cross Operator
+Also called __Kleene cross__, or __$\varepsilon$-free concatenation closure__
 $$\{ab,bb\}^+ =\{ab,bb,ab^3,b^2ab,abab,b^4,...\}$$
 
 #### Quotient Operator

+ 1 - 1
Formal Languages and Compilers/lesson_04.md

@@ -1,7 +1,7 @@
 # FLC - lesson 04
 ##### Luca Oddone Breveglieri
 ###### 12 october 2015
-##Lists
+## Grammars pt.I
 
 #### Linguistic Abstraction //Optional
 Transforms the phrases of a real language and gives them an __abstract representation__  

+ 40 - 0
Formal Languages and Compilers/lesson_05.md

@@ -0,0 +1,40 @@
+# FLC - lesson 04
+##### Luca Oddone Breveglieri
+###### 15 october 2015
+## Grammars pt.II
+
+In writing a grammar one needs to pay attention that every non-terminal is defined, and it is useful, to avoid __useless rules__
+
+A grammar is in its __reduced form__ if:
+
+- Every non-terminal A is reachable from the axiom
+- Every non-terminal A generates a non-empty set of strings.
+
+### Reduction of the grammar
+There is an algorithm in two phases:
+- Identifying the non-terminal symbols that are undefined
+- Identifying the non-terminal symbold that are unreachable
+
+The resulting grammar can be reduced but is not *guaranteed to be minimal*
+#### Phase 1
+Construct the complement set DEF and the defined non-term symbols
+$$DEF=V\setminus UNDEF$$
+
+#### Phase 2
+
+A *third rule* is required for a grammar to be in the reduced form,
+> The grammar G must not have circular derivations, which are inessential and lead to ambiguity
+
+To obtain a non-circular grammar we have to:
+- Remove the copy rules
+- Remove the null rules
+
+__Recursion__ is also common in grammars,  
+It is a required and sufficient condition *for a reduced grammar* to generate __infinite languages__
+
+$A\overset{n}{\Rightarrow} xAy\;\;n\ge 1$ is recursive
+
+
+### ambiguity
+
+#### Syntax tree derivation

+ 0 - 1
Software Engineering 2/lesson_01.md

@@ -1,5 +1,4 @@
 # SE2 - lesson 01
-###### http://home.deib.polimi.it/arrigoni/ArtificialIntelligence.html
 #### Elisabeta di Nitto
 ##### 8 October 2015
 ### Course Informations

+ 12 - 0
Software Engineering 2/lesson_02.md

@@ -0,0 +1,12 @@
+# SE2 - lesson 02
+#### Elisabeta di Nitto
+##### 14 October 2015
+###Software Engineering: a bit of history
+
+With the introduction of first computers, software was built by software engineers for themselves, they were both designer and users, the computers used had very limited storage, memory and computation resources,
+
+#### From art to craft
+
+Later the roles of developer and user began differentiating
+
+#### From craft to industrial development

+ 38 - 0
Software Engineering 2/lesson_03.md

@@ -0,0 +1,38 @@
+# SE2 - lesson 03
+#### Elisabeta di Nitto
+##### 14 October 2015
+## Requirement Engineering
+
+#### Late error correction is costly
+According to an EU survey,  
+Problems in software development are divided into:
+- \> 50% requirement specification
+- 50% requirement management
+
+#### What makes RE so complex?
+
+- __Multiple concerns__
+    - functional, quality, development
+    - hard and soft concerns
+- __Multiple stakeholders__ with different backgrounds
+    - clients
+    - users
+    - domain experts
+    - developers
+
+#### What do requirements engineers do?
+
+- Eliciting information
+- Modelling and analisys
+- Communicating requirements
+- Negotiating and agreeing requirements
+- Managing and evolving requirements
+
+### The world and the machine
+
+- The __machine__: the portion of system to be developed
+- The __world__: Portion of the real world affected by the machine  
+
+The *purpose* of the machine is always in the world
+
+#### World phenomena

+ 86 - 0
Software Engineering 2/lesson_04.md

@@ -0,0 +1,86 @@
+# SE2 - lesson 04
+#### Elisabeta di Nitto
+##### 15 October 2015
+## Requirement analisys pt.II
+
+The boundary between the world and the machine may vary
+
+The purpose of a RE activity is:
+- Identify the __goals__ of the project
+- Explore alternative ways of satisfying the goals
+- Evaluate strenght and risks of each alternative, to select the most appropriate
+
+### Requirement Analisys and Specification Document - RASD
+
+- It is used as a *baseline* for __software evaluation__
+
+#### Stakeholders of the RASD
+- Customers & users
+- System analysts, requirements analysts
+- Developers, Programmers
+- Testers
+- Project managers
+
+It tipically has a __multilevel structure__, and it's defined by IEEE standard
+1. __Introduction__
+    - Purpose
+    - Scope: Identifies the product and the application domain
+    - Definitions, acronyms, abbreviations
+    - Reference documents
+    - Overview
+2. __Overall Description__
+    - Product perspecive: Describes all esxternal interfaces (system, user, hardware, ...)
+    - Produt functions
+3. __Specific Requirements__: the body of the document
+
+### section 3: Specific Requirements
+
+3.1 __External interface requirements__  
+- 3.1.1 User interfaces
+- 3.1.2 H
+
+3.2 __Functional Requirements__  
+3.3 __Performance Requirements__  
+3.4 __Design Constraints__  
+3.5 __Software System Attributes__  
+3.6 __Other Requirements__
+
+### Target qualities for a RASD
+
+- __Completeness__
+- __Pertinence__
+- __Consistency__
+- __Unambiguity__
+- __Feasibility__
+- __Comprehensibility__
+- __Good Structuring__
+- __Modifiability__
+- __Traceability__
+
+### Functional Requirements bad examples
+
+> The system shall validate and accept credit cards and cashier's checks. High priority.
+
+Two requirements are expressed together.
+
+> The system shall process all mouse clicks very fast to ensure users do not have to wait
+
+This requirement is not specific, it doesn't give a measure of "fast"
+
+> The user must have Adobe Acrobat installed
+
+It is a constraint, not a requirement.
+
+### Types of requirements
+
+- __Functional requirements__
+- __Nonfunctional requirements__
+- __Constraints__
+
+While functional requirements have to be provided by the end user, Nonfunctional requirements are __independend of the application domain__
+
+Nonfunctional requirements are also calles __QoS requirements__
+
+### Project initiation
+
+An important step is making an __Interview__ with the customers