MIT6 0002F16 Lecture 1 - MIT OpenCourseWare

2y ago
2 Views
1 Downloads
610.07 KB
31 Pages
Last View : 1m ago
Last Download : 3m ago
Upload by : Sasha Niles
Transcription

*(% * % &* # 0 * % (% " #)% ** & (*# * % " *( " ( %#& * ( D2 @ 1?

;3888: ( ( ' ) * ) , & " & ( " # (8#& "( &# & !' " -( #"J & & - " -( #" A2C ! & (- ( #" (' # #! )( ( #" #! , ( ! & (- ( '#! ' ! #& ( !' D2 ? ') "( D2 @ ?@

%# # )*( * , ) &# ! ' ('J &# & !! " &# !' ' " (#J ! &#* -#)& &# & !! " ' 'J -#) &" ( #" () ! ( & " & , & ' 'J &- '! &# & !! " &# !' ' " (# -#) &" ' " &# & !! " #" ( " '' "! "(' " ( ,( ##J "#( & ( #" " !#& ( ' #)( ! ( & #* & - ()& ' " &# ! ' (' , !1 ' #" #* D2 @ ?A

%- % ) * %#& ( *% ;388891 &# & !! " '' "! "(' ( ' &J # )' !#& #" ( &# ! (# '# * ( " #" &# & !! " ()& #"( "( !#& '(& ( ()& ' ( '( & '' #)( &" " (# &# & !0 !#& #)( " -#)& (# "(# ( ' " D2 @ ?B

% % ( (% ( ## ! "") ( #" (' # -( #" # ( & " " & " ' " ' # # -#) ( (# &" /D2 @ ?C

%#& * * % " % ") ' " #! )( ( #" (# )" &'( " ( #& " * Experimental devices that help us to understandsomething that has happened or to predict the future ( ! . ( #" !# 'Images sources unknown. All rights reserved. This content is excluded from our CreativeCommons license. For more information, see https://ocw.mit.edu/help/faq-fair-use. ( ( '( !# ' !) ( #" !# 'D2 @ ?D

" , * %( % /4) * ( ( #" ?@2? ( #" C2B : ! )" ( #"';D2 @ ?E

%#& * * % " % ") ' " #! )( ( #" (# )" &'( " ( #& " * Experimental devices that help us to understandsomething that has happened or to predict the future Images sources unknown. All rights reserved. This content is excluded from our CreativeCommons license. For more information, see https://ocw.mit.edu/help/faq-fair-use. ( ( '( !# ' !) ( #" !# 'D2 @ ?F

* ) &* # 0 * % % "1 An objective function that is to be maximized orminimized, e.g.,J Minimize time spent traveling from New York to Boston A set of constraints (possibly empty) that must behonored, e.g.,J Cannot spend more than 100J Must be in Boston before 5:00PMImages sources unknown. All rights reserved. This content is excluded from our CreativeCommons license. For more information, see https://ocw.mit.edu/help/faq-fair-use.D2 @ ?G

&) ! (% " #)Images sources unknown. All rights reserved. This content is excluded from our CreativeCommons license. For more information, see https://ocw.mit.edu/help/faq-fair-use.D2 @ ?

&) ! (% " # #) * ! ( '(& " ( 0 '# ( & ' ! , !)! ( " ' ( ( -#) " && #) #) (# ( !#& '() ( " -#) " && # # -#) ##' '() (# ( " (# * " / # * & "('J 7? " ' &# !J #"( ")#)' #& & ( #" " ' &# !Images sources unknown. All rights reserved. This content is excluded from our CreativeCommons license. For more information, see https://ocw.mit.edu/help/faq-fair-use.D2 @ ?

/ )*6 ,%( * &) ! (% " #Images sources unknown. All rights reserved. This content is excluded from our CreativeCommons license. For more information, see https://ocw.mit.edu/help/faq-fair-use.D2 @ ?@

859 &) ! (% " #2 %(# " 0 ( ! ' & & ' "( - &0 " ' " #!!# ( ( !' ( (#( ( # "# !#& ( " * (#&0 0 # " ( 0 & & ' "(' ( ' ( # * ( !'2 ! "( # ( * (#& ' " ( ! * (#&0 0 # " ( 0 ' )' (# " ( ( & #& "#( ( !' & ( "2 0 ( ! ' ( "2 0 ( ! ' "#( ( " D2 @ ?A

859 &) ! (% " #2 %(# " 0 D2 @ ?B

( * %( " %( * # ?2 ")! & ( #'' #! " ( #"' # ( !'2 ( ' (# ' -0 " & ( ') ' (' # ( ' ( # ( !'2 ' ' ( # & ' (2 @2 !#* # ( #! " ( #"' #' (#( )" (' , ' ( # (2 A2 &#! ( & ! " " #! " ( #"' ##' "- #" #' * ) ' ( & '(2D2 @ ?C

* %* ( * " # ' # & ' (/ J * (#&0 0 # " ( 0 ' )' (# " ( ( & #& "#( ( !' & ( "2 0 ( ! ' ( "2 0 ( ! ' "#( ( " # ! "- #'' & "( * ) ' " * /J ' ! "- & "( " &- ")! &' ' " & & ' "( " (' #& , ! 0 ( & & ? ( !' (# ##' &#!0 ( # & ' ( ' # ' . /J ?0@DE0DC 0D 0@@F0@@G0B ?0BGD0E A0@ C0AED D2 @ ?D

( )* * & 1 '0 "# 7? " ' &# ! ' " & "( - , #" "( )( #"4( ' &D2 @ ?E

( / " %( * # ( * " "* ( * , while knapsack not fullput “best” available item in knapsack )( ( # ' '( ! "/J #'( * ) J '( , "' * J '( * ) 7)" ('D2 @ ?F

. #&" #) & #)( (# ' ( # " (# ! #) "# # !) -#) * ) & "( ## '0 2 20 -#) #")(' !#& ( " ' )( -#) * #& ) (0 2 20 -#) #"4( "( (# #"')! !#& ( " EC #& ' ##' " ( (# ( ' " ' &# !D2 @ ?G

) FGG A C #& '?@A?CB@CFACB G EGG ? ADC?C GC?GC (4' ## ( &# & ! ( ( " )' (# ( (# #& &D2 @ ?@

" )) %% class Food(object):def init (self, n, v, w):self.name nself.value vself.calories wdef getValue(self):return self.valuedef getCost(self):return self.caloriesdef density(self):return self.getValue()/self.getCost()def str (self):return self.name ': ' str(self.value)\ ', ' str(self.calories) ' 'D2 @ ?@?

" % %% )def buildMenu(names, values, calories):"""names, values, calories lists of same length.name a list of stringsvalues and calories lists of numbersreturns list of Foods"""menu []for i in range(len(values)):menu.append(Food(names[i], values[i],calories[i]))return menuD2 @ ?@@

#&" # * * % % " . " ( /def greedy(items, maxCost, keyFunction):"""Assumes items a list, maxCost 0,keyFunction maps elements of items to numbers"""itemsCopy sorted(items, key keyFunction,reverse True)result []totalValue, totalCost 0.0, 0.0for i in range(len(itemsCopy)):if (totalCost itemsCopy[i].getCost()) maxCost:result.append(itemsCopy[i])totalCost itemsCopy[i].getCost()totalValue itemsCopy[i].getValue()return (result, totalValue)D2 @ ?@A

" %( * # /def greedy(items, maxCost, keyFunction):itemsCopy sorted(items, key keyFunction,reverse True)result []totalValue, totalCost 0.0, 0.0for i in range(len(itemsCopy)):if (totalCost itemsCopy[i].getCost()) maxCost:result.append(itemsCopy[i])totalCost itemsCopy[i].getCost()totalValue itemsCopy[i].getValue()return (result, totalValue) D2 @ ?@B

) ( /def testGreedy(items, constraint, keyFunction):taken, val greedy(items, constraint, keyFunction)print('Total value of items taken ', val)for item in taken:print('', item)D2 @ ?@C

) ( /def testGreedys(maxUnits):print('Use greedy by value to allocate', maxUnits,'calories')testGreedy(foods, maxUnits, Food.getValue)print('\nUse greedy by cost to allocate', maxUnits,'calories')testGreedy(foods, maxUnits,lambda x: 1/Food.getCost(x))print('\nUse greedy by density to allocate', maxUnits,'calories')testGreedy(foods, maxUnits, Food.density)/testGreedys(800)D2 @ ?@D

" # ! )' (# & ( "#"-!#)' )" ( #"'J lambda H ?0 @0 3 "I1 H , & '' #"IJ ()&"' )" ( #" # " & )! "(' " * &- " -0 ' & #'' (# & ( ! . " #! ( ! , & '' #"' #"4(9)' def "'( D2 @ ?@E

) ( /def testGreedys(foods, maxUnits):print('Use greedy by value to allocate', maxUnits,'calories')testGreedy(foods, maxUnits, Food.getValue)print('\nUse greedy by cost to allocate', maxUnits,'calories')testGreedy(foods, maxUnits,lambda x: 1/Food.getCost(x))print('\nUse greedy by density to allocate', maxUnits,'calories')testGreedy(foods, maxUnits, Food.density)names ['wine', 'beer', 'pizza', 'burger', 'fries','cola', 'apple', 'donut', 'cake']values [89,90,95,100,90,79,50,10]calories [123,154,258,354,365,150,95,195]foods buildMenu(names, values, calories)testGreedys(foods, 750) )" # D2 @ ?@F

/ ( * )- ()1 %) " # # - 5# ( ! 6 # ' #"4( -' - # - # ( ! '# )( #" ' & - - "' (- -' "" &/J &- ( '( & -': ## '0 ? ;D2 @ ?@G

(%) % ) % ( / '- (# ! ! "( #! )( ( #" - "( )( # ' "#( -' - ( '( '# )( #"J #"4( * " "# # ## ( &#, ! ( #" ' " ( " ,( ()& 4 ## ( " " (&) - # ( ! '# )( #"'D2 @ ?A

MIT OpenCourseWarehttps://ocw.mit.edu6.0002 Introduction to Computational Thinking and Data ScienceFall 2016For information about citing these materials or our Terms of Use, visit: https://ocw.mit.edu/terms.

An objective function that is to be maximized or minimized, e.g., #Minimize time spent traveling from New York to

Related Documents:

Introduction of Chemical Reaction Engineering Introduction about Chemical Engineering 0:31:15 0:31:09. Lecture 14 Lecture 15 Lecture 16 Lecture 17 Lecture 18 Lecture 19 Lecture 20 Lecture 21 Lecture 22 Lecture 23 Lecture 24 Lecture 25 Lecture 26 Lecture 27 Lecture 28 Lecture

Lecture 1: A Beginner's Guide Lecture 2: Introduction to Programming Lecture 3: Introduction to C, structure of C programming Lecture 4: Elements of C Lecture 5: Variables, Statements, Expressions Lecture 6: Input-Output in C Lecture 7: Formatted Input-Output Lecture 8: Operators Lecture 9: Operators continued

DICTIONARIES (download slides and .py files and follow along!) 6.0001 LECTURE 6. 6.0001 LECTURE 6 1 QUIZ PREP § a paper and an online component § open book/notes § not open Internet, not open computer § start prinng out whatever you may want to bring 6.0001 LECTURE 6 2. LAST TIME

TODAY course info what is computation python basics mathematical operations python variables and types NOTE: slides and code files up before each lecture o highly encourage you to download them before lecture o take notes and run code files when I do o bring computers to answer in-class practice exercises! 6.0001 LECTURE 1 2

Lecture 1: Introduction and Orientation. Lecture 2: Overview of Electronic Materials . Lecture 3: Free electron Fermi gas . Lecture 4: Energy bands . Lecture 5: Carrier Concentration in Semiconductors . Lecture 6: Shallow dopants and Deep -level traps . Lecture 7: Silicon Materials . Lecture 8: Oxidation. Lecture

TOEFL Listening Lecture 35 184 TOEFL Listening Lecture 36 189 TOEFL Listening Lecture 37 194 TOEFL Listening Lecture 38 199 TOEFL Listening Lecture 39 204 TOEFL Listening Lecture 40 209 TOEFL Listening Lecture 41 214 TOEFL Listening Lecture 42 219 TOEFL Listening Lecture 43 225 COPYRIGHT 2016

Partial Di erential Equations MSO-203-B T. Muthukumar tmk@iitk.ac.in November 14, 2019 T. Muthukumar tmk@iitk.ac.in Partial Di erential EquationsMSO-203-B November 14, 2019 1/193 1 First Week Lecture One Lecture Two Lecture Three Lecture Four 2 Second Week Lecture Five Lecture Six 3 Third Week Lecture Seven Lecture Eight 4 Fourth Week Lecture .

ALEX RIDER SERIES POINT BLANK GOING DOWN MICHAEL J. ROSCOE was a careful man. The car that drove him to work at quarter past seven each morning was a custom-made Mercedes with reinforced steel plates and bulletproof windows. His driver, a retired FBI agent, carried a Beretta subcompact automatic pistol and knew how to use it. There were just .