Prechádzať zdrojové kódy

Added Artificial Intelligence folder and Operations Reserch and modified FlC lesson 1

Federico Amedeo Izzo 9 rokov pred
rodič
commit
09e2948c6a

+ 77 - 0
artificial_intelligence/lesson_01.md

@@ -0,0 +1,77 @@
+# Artificial Intelligence - AI
+###### http://home.deib.polimi.it/arrigoni/ArtificialIntelligence.html
+#### Francesco Arrigoni
+###### francesco.arrigoni@polimi.it - 02 23993475
+###### Wed 14:00 - 16:00 send email first
+##### 7 October 2015
+### 1. Introduction
+During the course we will see methods to develop __intelligent agents__.
+In particular we will see various methods in order of complexity but not necessarily in chronological order.
+
+The algorithms will be presented in pseudocode, no real implementations will be shown, for implementations examples go to aima.cs.berkeley.edu
+
+####Relation between AI and other courses:
+Relating to *Soft Computing*, in AI are shown general method for creating intelligent agents, in SC are shown some recent techniques in particular, in *Autonomous Agents and MultiAgent Systems* are shown methods to connect different intelligent agents.
+In *Machine Learning / Data Mining* the topic is how to improve an intelligent agent by making it learn.
+There are also some philosophical questions which are faced in *Computer Ethics*.
+---
+### Artificial Intellicence
+
+####1. Act as humans
+Create machines or entities who can act as humans.
+```
+Alan Turing in 1950 defined the imitation game, later being known as the turing test.
+```
+#### The __original formulation__ is the following
+Man|Interrogator|Human
+---|---|---
+The interrogator can interact with the two subject using a typewriter
+The goal of the man is to try to let the interrogator think he is a woman.
+The role of the woman is to try to let the interrogator know she is really a woman.
+
+Now, let's change the man with a computer, and let him try to act like the man in the precedent case.
+
+The computer is defined __intelligent__ if the success rate is the same to the experiment with Man/Interrogator/Woman.
+##### The most famous variant
+Is the one in which a computer can trick an interrogator to think he is human in more than 50% of the case.
+
+This is an __operational__ definiton of intelligence, not an __analytical__ one
+
+The computer is considered as a __black box__, the internal working of the computer is not relevant, only the external interaction is.
+
+A problem related to this test is that the decision may depend on one interogator or another.
+
+####2. Think as humans
+The goal of Artificial Intelligence is to build machines that work exactly as a human brain, in other words to create machines that think as humans.
+
+The problem with this approach is that our scientific knowledge is not sufficiend to reproduce a human mind.
+
+####3. Think rationally
+Artificial Intellicence is building machines that think rationally.
+Like building machines that think logically and are able to solve problems.
+
+The fact is that human being are not *completely rational*, our intelligence doesn't stop to proving theorem or *modus ponens*
+
+####4. Act rationally <- the one adopted during the course
+To be considered intelligent, a machine must be able to not only think rationally but in general to __do the right thing__.
+Act rationally can be seen as a way of maximising the results.
+This is the most *scientifically* and *engineering* oriented definition.
+
+```
+John McCarty, the inventor of Lisp organized in 1956 a summer camp to solve all major computational problems like computer translation, in this occasion the term Artificial Intelligence was created (after the introduction of the imitation game).
+```
+
+Some extraordinary milestones of Artificial Intelligence are:
+- __Google Car__, formerly Stanford University's Stanley
+- __Deep Blue__ who managed to win againts the human chess champion
+- __IBM Watson__ who won a Jeopardy game against the two biggest champions
+
+__Ubiquitous AI__ are small systems integrated in cars or electrodomestics
+
+Also in __videogames__ AI acts a big role, for example the opponents behaviour.
+
+Experts in Artificial Intelligence are not so required in job market because AI is defined as __smart__ things in marketing.
+
+|agent
+|---
+|Environment

+ 81 - 0
data_bases_2/lesson_01.md

@@ -0,0 +1,81 @@
+# Data Bases 2
+#### Paraboschi
+##### 6 October 2015
+### 1. Transaction Model
+#### Transaction Properties and Mechanisms
+- ##### Atomicity
+    - Abort-rollback-restart
+    - Commit protocols
+- ##### Consistency
+    - Integrity checking of the DBMS
+- ##### Isolation
+    - Concurrency control
+- ##### Durability
+    - Recovery management
+
+#### Corresponding modules
+- ##### Atomicity and Durability
+    - Reliability Manager
+- ##### Isolation
+    - Concurrency Control System
+- ##### Consistency
+    - Integrity Control System at query execution time (with DDL Compilers support)
+-------
+### 2. Concurrency
+#### Advantages of Concurrency
+
+Modern computers are capable of executing different processes in a concurrent way,
+Concurrency is also important in DBMS because it allows multiple Transactions at the same time
+
+ex: Two students enroll contemporarily on the Politecnico site.
+
+Concurrency is made by
+- time sharing on a single processor
+- or sharing the processes on multiple CPU cores.
+
+#### Concurrenct executions
+A problem may rise when we heve two or more concurrent operations modifying the same data.
+
+There are several ways of managing the problem:
+
+- ##### Serial executions
+The two operations are queued and executed separately in time.
+- ##### Interleaved execution
+
+- ##### Nested execution
+###Concurrency Problems
+####Lost update
+```
+T1: R(D,V1)
+V1 = V1 + 3
+T2: R(D,V2)
+V2 = V2 + 6
+T1: W(V1,D)     D=103
+T2: W(V2,D)     D=106!
+```
+####Dirty read
+```
+T1: R(X,V1)
+T1: V1 = V1+3
+T1: W(V1,X)     D=103
+T2:R(X,V2)
+T1: ROLLBACK
+T2: V2 = V2+6
+T2: W(V2,D)     D=109
+```
+####Non-repeatable read
+```
+T1: R(D,V1)
+T2: R(D,V2)
+T2: V2 = V2 + 6
+T2: W(V2,D)      D=106
+T1: R(D,V3)     V3<>V1!
+```
+####Ghost update
+```
+T1: R(D,V1)
+T2: R(D,V2)
+T2: V2 = V2 + 6
+T2: W(V2,D)      D=106
+T1: R(D,V3)     V3<>V1!
+```

+ 18 - 2
formal_languages_and_compilers/lesson_01.md

@@ -28,7 +28,7 @@ There is an effective procedure to verify the grammatical *correctness* of a phr
 ##### Years '70-'80
 - Formal language theory becomes a standard university discipline
 - Introduction of SDKs like Flex or Bison
-
+---
 ## Lesson 1
 ### Definition of a language
 - __Alphabet__: finite set of elements
@@ -42,13 +42,21 @@ The __cardinality__ of a *language* determines the number of elements contained,
 It can be 0 for the __empty language__ or *infinite* for __infinite languages__.
 
 ### Operations on strings
+####Lenght of a string
+Is the number of elements contained
+$$|bbc|=3$$
+
+####Equality of two strings
+Two strings are equal if and only if
+- They have the same length
+- Their elements coincide
 
 #### Concatenation (product of strings)
 - Is a basic operation,
 - Is associative,
 - Changes the length.
 
-##### Empty string (or null string) Ɛ:
+##### Empty string (or null string) $\varepsilon$:
  is the neutral element respective to concatenation
 ##### Substring:
 Given a string x = u y v
@@ -58,5 +66,13 @@ Given a string x = u y v
 
 if u,v ≠ Ɛ,  y is a proper substring
 ##### Mirroring or Reflection
+$x=atri$
+$x^r=irta$
 ##### Repetition or iteration
+The m-th power of a string concatenates the string to itself for m-1 times
+
+$x= ab$
+$x^n=\varepsilon$
+$x^1=x=ab$
+$x^2=(ab)^
 ##### Concatenation

+ 34 - 0
operations_research/lesson_01.md

@@ -0,0 +1,34 @@
+# Operations Research
+#### Enrico Malucelli
+##### 6 October 2015
+## Introduction
+### What is Operations Research?
+Is a method of taking decisions using math
+
+Typically we solve optimization problems daily withoud being conscious
+
+        Confucius
+
+        I hear and forget,
+        I see and remember,
+        I do and understand.
+####Interesting sites:
+
+
+### What kind of decisions?
+- __Strategic__ Level: design a railroad
+- __Tactical__ level: how many trains to use
+- __Operational__ level: schedule the trains
+
+### How OR approaches the problems
+- __Decisions__
+- __Rules__ Mathematical constraints
+- __Objective__ Maximize the income
+#### Solution to phone building example:
+- plot the constraints in a 2D graph
+- select the region below all the constraints
+- Find the optimal solution analyzing the vertexes of the polygon.
+
+(In this case the vertex were integers but they may be real numbers and the solution is required to be integer.)
+### Challenges
+http://challenge.roadef.org/2016/en/index.php

+ 97 - 0
operations_research/lesson_02.md

@@ -0,0 +1,97 @@
+# Operations Research
+#### Enrico Malucelli
+##### 6 October 2015
+## Introduction
+### Exercise: How to invest a budget
+
+###Steps
+#### 1. decisions
+#### 2. constraints
+
+####Solution
+#####Variables
+$x_i$= amount of money invested
+(i=1...5), $x_i \ge 0$
+#####constraints
+$\sum x_i \le 137$
+
+$x_1 \le 40$
+
+$x_2 \le 12$
+
+$x_3 \le 130$
+
+$x_4 \le 5$
+
+$x_5 \le 400$
+#####target
+$x_1/40*3.2+x_2/12*1.5+x_3/130*4.2+x_4/5*0.7+x_5/400*17$
+
+####Alternative solution
+$y_1$=share of bond
+$y_1=x_1/availability$
+$0 \le y_1\le1$
+$i=1$
+
+$$40y_1+12y_2+130y_3+5y_4+400y_5\le137$$
+$$max32y_1+15y_2+4.2y_3+0.7y_4+17y_5$$
+
+We can divide each bonus for the total of the earning so we can get an index of the best investment.
+$$8\%y_1+125\%y_2+3.2\%y_3+14\%y_4+4.25\%y_5$$
+
+We notice that the $y_2$ is the best investment, and we should buy as much as we can of that kind.
+
+example:
+$y_4=1$
+$y_2=1$
+$y_1=1$
+$y_5=...$
+####Algorithm generalization
+$$\sum c_i y_i$$
+$$\sum a_i y_i \le b$$
+$$0\le y_i \le 1 i=1 \mu$$
+Sort indicates by non decreasing $C_i/a_i$ cosider the variables in the Order:
+$$y_i=\begin{cases} 1,& if &b \ge a_i\\
+b/a_i,& if &b < a_i
+\end{cases}$$
+$$b-y_ia_i$$
+
+###Logical variables
+Can assume only the values $\{0,1\}$
+####example:
+A burglar sneaks into a jewelry and his bag can hold 8kg, what must he steal?
+
+|| object | 1 | 2 | 3 | 4 | 5 | 6 |
+|-------|--------|---|---|---|---|---|---|
+| value | $v_i$  | 7 | 2 | 4 | 5 | 4 | 1 |
+|weight|$w_i$|5|3|2|3|1|1|
+####solution
+Contrary to the previous problem (in which we had infinite solutions, like any fraction), in this problem we have at most $2^6$ solutions, maybe not all of them are feasible.
+
+x_i = 1 if the burglar has taken, 0 otherwise
+
+$$max \sum v_i x_i$$
+$$\sum w_i x_i \le b(=8)$$
+
+If we apply the same algorithm as before, we can calculate the value_for_weight factor of every object and choose the best ones.
+#####However this is not the best solution
+####Logical variable, __Complement__
+$$x'_i=1-x_i$$
+####Other types of variables
+####Integer Variables
+####Discrete value variables
+In most cases we select the value of a variable within a __finite set__
+e.g.: the memory size of a computer, the capacity of a telecommunication link.
+$$x\in \{ v_1,v_2,...,v_r\}$$
+#####formulas
+$$s_i=\begin{cases}
+1,& x=v_i\\
+0,& \end{cases}$$
+###example: diet
+|food|pasta|rice|steak|carrots|potatoes|pear|
+|----|-----|----|-----|-------|--------|----|
+|calories per hg|300|250|200|70|180|100
+####Minimum required calories: __700__
+We can transform all the inequalities to be less or equal
+
+And later we need to transform our inequalities into equalities