Paulson MSreport

download Paulson MSreport

of 58

Transcript of Paulson MSreport

  • 7/30/2019 Paulson MSreport

    1/58

    PERSONALIZEDILLUMINANCEMODELINGUSINGINVERSE

    MODELINGANDPIECEWISELINEARREGRESSION

    By

    RyanRobertPaulson

    BS(MichiganTechnologicalUniversity)2008

    AreportsubmittedinpartialsatisfactionoftheRequirementsforthedegreeof

    MastersofScience,PlanII

    in

    MechanicalEngineering

    atthe

    UniversityofCaliforniaatBerkeley

    CommitteeinCharge:

    _______________________

    ProfessorAliceM.Agogino,Chair

    _______________________

    ProfessorDuncanCallaway

    Spring2012

  • 7/30/2019 Paulson MSreport

    2/58

    i

    Abstract

    Buildingsaccountfornearly40%ofthetotalenergyuseintheUnitedStates,morethan

    eithertransportationorindustry.Ofthis,lightingaccountsfor11%ofenergyuseinresidential

    buildings and 25% of the energy use in commercial buildings. Increased energy efficiency in

    lightingsystemscouldhaveamajorimpactonenergyusageonaglobalscale.BuddingSmart

    Grid research calls for more localized control and greater energy efficiency across multiple

    independentbuildingsystems.InordertoensureafutureinwhichtheSmartGridcoverslarge-

    scalefacilitiesandsmallresidentialandofficebuildingsalike,low-cost,easily-installedretrofit

    energyefficiencysolutionsarerequired.

    Thisreportdetailsaplug-and-playinversemodeldevelopmentpackagethattakesdatafrom

    wireless light sensors and performs multiple linear regression to build a piecewise linear

    functionthatpredictstheworkplaneilluminanceduetodaylightandasinglelinearfunction

    thatpredictsworkplaneilluminanceduetoartificiallight.Theproposedmodelis intendedfor

    useinpredictivelightingcontrollersandmayallowfortheoptimizationoflightlevelsacross

    multiple workstations. Coefficients for artificial light contribution are time-invariant, while

    differentcoefficientsareusedfordaylightcontributiondependingonsunposition.Thetests

    wereperformedinareal-lifesetting,typicalofasharedresidentialspace.

    Theartificiallightmodelwasfoundtobeverypromising,witharesidualmeanandstandard

    deviationof-0.11812.5626lux.Thedaylightmodelwasfoundtohavedifficultywithdirect

    sunlight,anerrorattributedmainlytolightsensorlimitations.Thedaylightmodelwasfound,

    formultiplesimulationsthroughoutayear,tohavearesidualmeanandstandarddeviationof-

    54.5229846.9855lux.However,byremovingtheerrorsfromhighluxdirectsunlightsensing,

  • 7/30/2019 Paulson MSreport

    3/58

    ii

    themodelsignificantlyimprovesandgivesaresidualmeanandstandarddeviationof-85.368

    174.9429.

  • 7/30/2019 Paulson MSreport

    4/58

    iii

    Contents

    Introduction.................................................................................................................................................1

    ResearchGoal..........................................................................................................................................1

    DescriptionofTechnology.......................................................................................................................3

    Methodology...............................................................................................................................................4

    Terminology.............................................................................................................................................4

    IlluminanceduetoArtificialSources.......................................................................................................4

    SolarIlluminance.....................................................................................................................................6

    Sunposition...........................................................................................................................................10

    InverseProblemTheory.........................................................................................................................11

    MultipleLinearRegressionbyOrdinaryLeastSquares.........................................................................12Hardware...................................................................................................................................................14

    LightSensor...........................................................................................................................................14

    LightSensorCalibration.........................................................................................................................15

    Software....................................................................................................................................................17

    TestsandTestResults................................................................................................................................19

    Testbeddescription...............................................................................................................................19

    TestOverview........................................................................................................................................23

    ArtificialLightSourceTest.....................................................................................................................23

    PilotDaylightTests................................................................................................................................25

    UpdatedDaylightTests..........................................................................................................................27

    RadianceDaylightSimulation................................................................................................................29

    CombinedDaylightandArtificialLightTest...........................................................................................32

    Discussion..................................................................................................................................................34

    Futurework...............................................................................................................................................35

    Acknowledgements...................................................................................................................................37References.................................................................................................................................................38

    Appendix....................................................................................................................................................42

    AppendixA SourceCode..................................................................................................................42

    AppendixB LightSensorCircuitDiagram.........................................................................................52

    AppendixC TelosBBlockDiagram....................................................................................................53

  • 7/30/2019 Paulson MSreport

    5/58

    iv

    ListofFigures

    Figure1Directsolarnormalilluminanceasafunctionofsolaraltitude[13]. 7

    Figure2Clearskydiffuseilluminanceasafunctionofsolaraltitude[13]. 8

    Figure3Predictedandsimulatedilluminancefordifferentroomscenarios.[14]. 9

    Figure4Horizontalilluminancemappedtooutdoorverticalirradianceforafixedsunpositionatvarying

    Perezskyclearnesscategories[14]. 10

    Figure5RelativespectralsensitivityofOSRAMSHF5711illuminancesensor[22]. 15

    Figure6Illuminancereadingsofmotesplottedagainstluxmeterreadings 16

    Figure7Softwareflowchart. 18

    Figure8Testbedoverview 20

    Figure9Pilotandupdatedpositionofdeskmote1. 20

    Figure10Pilotandproposedupdatedpositionofdeskmote2. 21

    Figure11Positionofartificialmote51. 21

    Figure12Positionofartificialmote52. 22

    Figure13Positionofwindowmote101. 22

    Figure14February14dataofartificiallightsourcecontributionondesktop1inabsenceofdaylight. 24

    Figure15February14Mote1dataandPredictionfordesktop1. 24

    Figure16March8DataandPredictionsfromApril3. 25Figure17March20DataandPredictionsfromApril3. 26

    Figure18April3DataandPredictionsfromApril3. 26

    Figure19April15DataandPredictionsfromApril15andMay5. 27

    Figure20April22DataandPredictionsfromApril15andMay5. 28

    Figure21April26DataandPredictionsfromApril15andMay5. 28

    Figure22May5DataandPredictionsfromApril15andMay5. 29

    Figure23RadiancemodeloftestbedforNovember10,16:00. 30

    Figure24SimulatedRadiancedataofdesktop1forJune20. 31

    Figure25SimulatedRadiancedataofdesktop1forNovember10. 32

    Figure26April7Combinedartificialanddaylighttest. 33

    Figure27April7Combinedartificialanddaylighttest,Mote1andpredictedvalue. 33

  • 7/30/2019 Paulson MSreport

    6/58

    1

    Introduction

    ResearchGoal

    Buildingsaccountfornearly40%ofthetotalenergyuseintheUnitedStates,morethan

    eithertransportationorindustry[1].Over$369billionarespentonenergyacrossthenation

    eachyear.Ofthis,lightingaccountsfor11%ofenergyuseinresidentialbuildingsand25%of

    the energy use in commercial buildings [2]. The numbers indicate that increased energy

    efficiencyinlightingsystemscouldhaveamajorimpactonenergyusageonaglobalscale.

    Withgrowingenergycostsandaspreadingawarenessofthemassiveenergyconsumption

    plaguingsocietyhereandabroad,supportforresearchintoSmartGridtechnologiesisgrowing

    rapidly.ThebuddingSmartGridcallsformorelocalizedcontrolandgreaterenergyefficiency

    acrossmultipleindependentbuildingsystems[3].Thissuggeststhatsoonbuildingsystemswill

    becommunicatingwitheachotherto balanceenergyconsumptionacrosstheentirebuilding,

    takingintoaccountpeakloadtimesandpricesaswellasuserpreferences.Thislevelofcontrol

    requiresaccurateandefficientsystems,ofcourse,buttheSmartGridwillnotjustincludelarge

    office complexes with plenty of money to spend on new systems. The Smart Grid will also

    encompasssmallofficespacesandresidentialsystems,whichwouldrequirelow-cost,easily-

    installedretrofitenergyefficiencysolutionsandthetoolstohelpbuildthem.

    Energyefficientautomatedlightingsystemsarenowcommerciallyavailable,buttheyhave

    limitations. Careful calibrations must be performed by a technician for each space. Daylight

    controlis achievedthroughsensorsthatcomparelightlevelstopredeterminedset-points[4].

  • 7/30/2019 Paulson MSreport

    7/58

    2

    Light levels are gradually adjusted to achieve the set-points. This method is convenient for

    single workstations, but does not lend itself to predictive control or to energy usage

    optimizationacrossmultipleworkstations.

    Inverse modeling packages for building systems control are not new; researchers are

    developingthemforlighting[5]andHVAC[6]control.Thesemodelsarerobust,butrequirethe

    usertoleavelightsensorsontheirdesksorneartheirworkstationsindefinitely.Manymodels

    opt instead to use simulation packages that take into account building geometry and

    reflectanceofallsurfacesintheroom[7-9].Thesecalculationsareusuallyperformedthrough

    theuseofRadiance,aspecializedlightingprogram[10].Thedownsidetotheseprogramsisthat

    theyrequiredetailedknowledgeofthebuildingstructureandfurnituredimensions,aswellas

    thetechnicalexpertisetoputtheinformationintoaCADprogram.Thislevelofaccuracyalso

    requires significant computing power that could take several minutes to several hours of

    processingtoachieveanaccuratemodel.

    Thegoalofthisprojectistoinvestigatethepotentialforaportableplug-and-playinverse

    modeling package that models light based on multiple linear regression by ordinary least

    squares. By plug-and-play we mean that the package can easily be set up with minimal

    instructionorinfrastructure.Thatis,thepackageshouldnotrequiretasksthatwouldbetaxing

    for an inexperienced user, such as modeling room geometry, complex programming, or

    expensiveandcomplicatedinstallationprocedures.Inaddition,themodelshouldbereasonably

    accuratethroughoutthedayandyear.Themodelshouldbeabletoaccommodateanygiven

    number of sensor inputs. The use of multiple linear regression decreases the required

  • 7/30/2019 Paulson MSreport

    8/58

    3

    computingpowertocreateamodel.Thephysicsofilluminationsuggeststhatalinearmodelis

    possibleandthisresearchinvestigatesthevalidityofthisassumption.

    DescriptionofTechnology

    A novel software program has been developed for the generation of a plug-and-play,

    predictive,personalizedmodelofroomlightingusingawirelesssensornetwork.Theinputsto

    the modelare illuminance levelsmeasuredateach user workstationwith both artificial and

    naturallightsources.Apiecewiselinearmodelisgeneratedforeachworkstationsuchthatthe

    illuminanceduetodaylightcanbepredictedbasedonvaluesfrommeasurementstakenata

    nearbywindow.Likewise,asinglelinearfunctionisgeneratedforeachworkstationsuchthat

    the illuminance due to artificial light sources can be predicted based on values from

    measurementstakenincloseproximitytonearbyartificiallights.Inthismodel,coefficientsfor

    artificiallightcontributionsaretime-invariant,whiledifferentcoefficientsareusedfordaylight

    contributiondependingonsunposition.Duetotheextremelyhighspeedoflight,thesystem

    canbeassumedtorequirenearlyinstantaneousresponse.Forthisreason,anopen-loopsystem

    wasimplementedtominimizeresponsetime.

    It is also important that this tool can be used in energy optimization of lighting across

    multiple users in a shared space. In this research, the predicted effect of proposed lighting

    scenarioscanbefoundandcomparedtothedesiredresults.Withthistool,anoptimallighting

    scenarioshould befound that satisfies all userswhilereducing the energy consumedby the

    luminaries.

  • 7/30/2019 Paulson MSreport

    9/58

    4

    Methodology

    Terminology

    Radiantflux is theflow rate of radiantlightenergy,measured in wattspersquaremeter.

    Luminousfluxistheperceivedpoweroflight,adjustedtoreflectthevariablesensitivityofthe

    humaneyetodifferentwavelengths.TheSIunitofluminousfluxisthelumen,whichisdefined

    intermsofluminousfluxofmonochromatic555nmradiation.Illuminanceisameasureofthe

    luminousfluxperunitarea.TheSIunitofilluminanceisthelux,whichisequivalentto1lumen

    persquaremeter[11].

    IlluminanceduetoArtificialSources

    The illuminance due to an artificial source is fairly straightforward. We assume that the

    effectoflightreflectedoffofotherobjectsontothemeasurementsurfaceisminimalandthe

    majorityoflightincidentonthemeasurementsurfaceisduetodirectirradiation.Evenso,any

    lightthatisreflectedissimilarlygovernedbythesameprincipleasdirectirradiance,withsome

    lossduetodiffusion.Forthesereasonswewillinvestigateonlydirectirradiance.Theequation

    formeasurableirradiancethathasbeenemittedfromapointsourceincidentonanarea

    withsurfacenormalangleofandsolidanglesubtendedbythemeasurementisasfollows

    [12]:

    =!

    cos Equation1 Whereis the irradiance andis the total radiant flux emitted by the source. For small

    angles,theequationsimplifiesto:

  • 7/30/2019 Paulson MSreport

    10/58

    5

    cos Equation2 If the sourceof radiant flux andtheobservation area do not change with respect to one

    anotherovertime,thetermsinthedenominatorareallconstantsandcanbecollectedintoa

    singleconstant,,whichdescribeslocationandangleoftheobservationarea.Inaddition,ifthe

    spectrum of the light does not vary then it is a linear transformation from radiant flux to

    luminousfluxandlikewiseirradiancetoilluminance.Combiningthelineartransformationinto

    thelinearconstantgivesus:

    ! = ! Equation3

    Whereis illuminance. Sinceis constant for a given location and orientation, we can

    describeasecondobservationareaassuch:

    ! = ! Equation4

    Fromherewecanusesubstitutionandsolvefor!:

    ! =!

    !

    ! Equation5

    From Equation 5, wecan see that illuminance due to a point source measured from one

    location is directly proportional to the illuminance measured at another location. This is

    important for estimating the contribution of artificial light sources to the workstation

    illuminance.Whiletheidealsetupusesdimmableluminariesthattransmittheirpowerlevelsas

    apercentageofthetotalpower,itmaynotbefeasibletoretrofitallluminariesinaspace.If

    this is the case, the contribution of artificial light to the workstation illuminance can be

    estimatedbyplacinganilluminancesensorincloseproximitytoeachluminaryandusingthis

  • 7/30/2019 Paulson MSreport

    11/58

    6

    reading in the linear regression model as a direct replacement for power level, with the

    assumptionthateachindividualluminaryisthemajorcontributortotheilluminancereadingfor

    thecorrespondingilluminance.Thismethoddoesintroducesomeerrorintothesystem,asthe

    illuminancereadingsmaybeduetoacombinationofunaccounted-forlightsources.However,

    ifthelinearityassumptionholds,theerrorshouldberelativelysmall.

    SolarIlluminance

    Solar illuminance is generally described as a linear combination of direct normal solar

    illuminance (also called beam illuminance) and diffuse illuminance, which is the illuminance

    thathasbeenscatteredbypassingthroughair.Thedirectnormalsolarilluminancehasbeen

    foundtocloselyfollowafunctionoftheform[13]:

    !" = !" 1+ 0.0333 360

    365

    !!

    !"# ! Equation6

    Where!"isthedirectnormalsolarilluminance,!"isthemeanextraterrestrial solar

    illuminance (127.5 klux),is the Julian calendar date between 1 and 365, is the optical

    atmosphericextinctioncoefficient(empiricallyestimatedtobe0.210forcleardays),and is

    thesolaraltitude.DatatakenfromseverallocationsintheUnitedStatesthroughouttheyear

    canbefoundinFigure1.

  • 7/30/2019 Paulson MSreport

    12/58

    7

    Figure1Directsolarnormalilluminanceasafunctionofsolaraltitude[13].

    Diffusesolarilluminancehasbeenfoundtobeoftheform:

    ! = + sin !

    Equation7

    Where!ishorizontaldirectilluminance,and,,andareempiricallyderivedconstants

    that vary depending on the clarity of the sky. Data for diffuse solar illuminance taken

    throughout the year at different locations around the world on clear days can be found in

    Figure2.Whiledirectsolarilluminancecanbeeasilyestimatedusingjustthetimeofday,the

    diffuse solar illuminance can be much harder to estimate without an irradiance meter and

    accesstoweatherdata.

  • 7/30/2019 Paulson MSreport

    13/58

    8

    Figure2Clearskydiffuseilluminanceasafunctionofsolaraltitude[13].

    To avoid this dependence on weather data, a different estimation can be used. A very

    accurateapproximationofilluminanceduetodaylightwithinaroomforafixedsunposition

    [14]canbedescribedas:

    !"!!" = !"#!!" + !"##!!" Equation8

    Where !"!!" is indoor horizontal illuminance, !"#!!" is outdoor horizontal directirradiance, !"##!!" is horizontal diffuse irradiance, and and are model-dependent

    coefficients.[14]utilizedRadiancesimulationstotesthisequationforsouth-facingandwest-

    facing rooms. The relationship between predicted and simulated illuminances was found to

  • 7/30/2019 Paulson MSreport

    14/58

    9

    haveverysmallresidualsandthecorrelationcurvesasshowninFigure3.Itisworthittopoint

    outthatthealgorithmrequiredmonthsofdatatoperformatthislevelofaccuracy.

    Figure3Predictedandsimulatedilluminancefordifferentroomscenarios.Thepredictionmodelwasa

    linearcombinationofdirectanddiffuseirradianceforagivensunposition[14].

    If solar irradiance is not accessible and a reasonably clear sky can be assumed, a good

    approximationcanalsobefoundusingoutdoorverticalilluminance,accordingtoboth[14]and

    [15]:

    !"!!" = !!"#$ Equation9 Where!!"#$ is the vertical faade illuminance and is a model-dependent coefficient.

    Guillemins test resulted in standard deviations of 416 lux. [14] tested this relationship and

  • 7/30/2019 Paulson MSreport

    15/58

    10

    foundapromisingnearly-linearcorrelationbetweenverticalfaadeirradianceandhorizontal

    illuminanceforarangeofPerezskyclearnessvalues,andtheresultscanbefoundinFigure4.

    Perezskyclearnessisadiscretizedmeasurementofcloudcoverandrangesfromcloudy(values

    oflessthan3)toveryclear(valuesgreaterthanorequalto8)[16].

    Figure4Horizontalilluminancemappedtooutdoorverticalirradianceforafixedsunpositionatvarying

    Perezskyclearnesscategories[14].

    Sunposition

    An accurate daylight illuminance prediction algorithm needs to take into account the

    positionofthesun.Themostaccurateofsevenreviewedby[17]istheAstronomicalAlmanacs

    algorithm,implementedby[18].Ofthesevenalgorithmsreviewed,theAstronomicalAlmanacs

    algorithmhadthesmallestaverageerrorsforzenithangle(-0.121),azimuth(-0.042)andthe

  • 7/30/2019 Paulson MSreport

    16/58

    11

    smallestaveragesunvectordeviation(0.201).Blanco-Murieletal.[17]alsodevelopedanovel

    algorithmthatismoreaccuratethanthe AstronomicalAlmanacsalgorithm,butweprefera

    computationallylightalgorithmandthustheAstronomicalAlmanacsalgorithmwasselectedto

    determinethesunposition.

    InverseProblemTheory

    Inverseproblemtheorydescribesmethodsbywhicha modelofa system isdevelopedby:

    (1) parameterizing the system in terms of a set of model parameters that adequately

    characterizethesysteminthedesiredpointofview,(2)makingpredictionsontheactualvalues

    basedonphysicallawsandgivenvaluesofthemodelparameters,and(3)usingactualresults

    frommeasurementstodeterminethemodelparameters[19].

    A model that takes into account location would require the input of accurate building

    dimensions,oratleastthemotepositionswithrespecttothelightsources.Themodelwould

    thenestimatethelightingasasummationoftheluminariesatanyoreverypositioninthe

    room. This system would be very accurate and robust, but the user input and computation

    requiredwouldbesignificant.Unlessanextremelysimplifiedinterfacewascreated,alocation-

    basedmodeldevelopmentsystemwouldrequireatechniciantosetup.

    Aninversemodelwouldnotrequireluminaryorworkstationpositionstofunction.Instead,

    thesystemwouldmeasurelightingdataatworkstationsabouttheroom.Thedatawouldbe

    mappedtothecontrollableluminarylevelsandtothelightlevelsfromthedaylightmeasured

    atthewindowsviaaregressionmodel.Themodelthereforewillbetreatedasablackboxof

    sorts,withinputsofdaylightandcontrollablelightlevelsandoutputsofthelightlevelatthe

  • 7/30/2019 Paulson MSreport

    17/58

    12

    workstations.Thissystemwouldnotbeasaccurateorasextensibleasafullsimulationmodel

    thattakesintoaccountthelocationofthemotesthesystemcannotdeterminethelightlevels

    ofeveryspaceintheroom,onlythoseattheworkstationsbutthesystemcouldberelatively

    easytosetup.Properlydesigned,thesystemwouldbeabletobedeployedwithminimaleffort

    ontheendoftheuser.Forthesereasons,aninversemodelisapromisingchoiceforaplug-

    and-playlightingsystemdesignedforease-of-use.

    MultipleLinearRegressionbyOrdinaryLeastSquares

    Multiplelinearregressionisanefficientandrelativelysimpleprocedurethatcanfindalinear

    relationship between multiple regressors anda regressand. The ordinary least squares (OLS)

    method functions tocreatea bestlinearfit toa givendata set byminimizing the sum ofthe

    squaredresiduals[20].

    For this project, a linear relationship between the illuminance measured at artificial and

    naturallightsourcesandtheilluminancemeasuredataworkstationareassumedoftheform:

    != !!! + !!! ++ !!! + !!! ++ Equation10

    Where!

    ,!

    ,and!

    areilluminancereadingsattheworkstation,anartificiallightsource,

    andanaturallightsource,respectively,whileandareconstantsdefinedbythemodeland

    israndomerror.Ifwehavesamples,theequationbecomes:

    !!

    !!

    = !!!!

    !!!

    + !

    !!!

    !!!

    ++ !

    !!!

    !!!

    + !

    !!!

    !!!

    ++ Equation11

  • 7/30/2019 Paulson MSreport

    18/58

    13

    Tosolvethisequation,themethodofordinaryleast-squaresleadsustofindthevaluesof

    andthatminimizethesumofthesquaredresiduals.Asimplewaytodothisistofirstarrange

    thedataintotheform:

    !!

    !!

    =

    !!!

    !!!

    !!!

    !!!

    ! !

    !!!

    !!!

    !!!

    !

    !

    !!

    + Equation12

    SimplifyingEquation12forclarity:

    = + Equation13

    From therewe assume strict exogeneity,or that the error hasa mean of zero and is not

    correlated to the regressors. We also assume linear independence. This assumption is valid

    because,whilethereissomeriskofmulticollinearityifthereisonlyonelightsourceandthe

    sensormotesarepositionedveryclosetogether,thisriskismediatedsimplybyensuringthe

    motes are spaced well apart at varying distances from the light source. Using these

    assumptions,wecanthenuselinearalgebratoarrangetheequationintheform:

    = ! !!Equation14

    Theequationcanalsobewrittenas:

    =1

    !

    !

    !!!

    !

    !

    !!

    1

    !!!

    !!!

    Equation15

    ThisequationistheOrdinaryLeastSquaresEstimator,andgivesusthebestfitlinearmodel

    forthedata.

  • 7/30/2019 Paulson MSreport

    19/58

    14

    Hardware

    A wireless light sensor network was utilized for inverse modeling. The network was

    comprisedofTelosBmoteplatformsrunningonAA-batteries[21].Themoteswereconfigured

    withanambientlightsensorthatwassampledatregularintervals.Themotescommunicated

    eachsamplereadingoverthe802.15.4layertoanothermoteconnectedtoabasecomputer.

    LightSensor

    ThelightsensorusedwasanOSRAMSFH5711ambientlightsensor[22].Thesensorisa

    photodiodethatoutputsacurrentthatisreadbythemoteplatform.Thesensorwaschosen

    becauseofitssensitivitytothenakedeyeandforthelogarithmiccalibrationcurveassociated

    withit.Thiscurveallowedforawiderangeofluxvaluestobesampledwhilemaintaininga

    smalldatapacketsize.Thesensorsweresensitivetoilluminancesbetween3-80kluxatnormal

    operating temperatures. The spectral sensitivity range, shown in Figure 5, was between

    wavelengthsof475and650nm,slightlywithinthespectralsensitivityrangeofthehumaneye,

    whichisbetweenwavelengthsofroughly400-700nm.Thepeaksensitivityisbetween540and

    570nanometers,dependingonthesensor.Thetypicalvalueis555nm,whichisverycloseto

    thehumaneyespeaksensitivityof550nmduringtheday.

  • 7/30/2019 Paulson MSreport

    20/58

    15

    Figure5RelativespectralsensitivityofOSRAMSHF5711illuminancesensor[22].

    LightSensorCalibration

    Thecalibrationcurveasdefinedbythemanufacturerisasfollows:

    !"# = log !!

    Equation16

    Where!"# is the output current, is a sensitivity constant of 10 A,! is a constant

    conversionfactorof1lux,and!

    istheincidentilluminance.Thisequationwastestedacross

    multiplesensorssimultaneouslyandtheresultscanbeseeninFigure6.Themotenumbering

    forthistestdoesnotreflectposition.

  • 7/30/2019 Paulson MSreport

    21/58

    16

    Figure6Illuminancereadingsofmotesplottedagainstluxmeterreadings,withoutdirectsunlight.

    Itisapparentthatthemotesarequiteaccurateuntilaround2000lux,whentheyappearto

    becomesaturated.Below2000lux,theresidualsmeansandstandarddeviationsofthedataare

    46.5759 36.4637, -9.3955 69.4646, and 11.6397 37.1833 for motes 1, 2, and 3,

    respectively. Above 2000 lux the residuals with become -442.7070 454.6512, -912.2821

    554.1084, and -744.8797 427.1665 for motes 1, 2, and 3, respectively. The motes have

    difficultymeasuringdirectsunlightwithmuchaccuracy.Therearesomedifferencesbetween

    themotemeasurementswhichmaybeduetominorcalibrationerrorsor,morelikely,dueto

    variations in illuminance throughout the test space. While the motes and lux meter were

    situated in as close proximity to each other as possible, there are variations in illuminance

    betweenthe1-2inchesthatseparatedtheminthetest.Inaddition,slightvariationsinsensor

    anglearepresentbetweenthemotesduetoassembly.Theresidualsfoundforluxlevelsbelow

  • 7/30/2019 Paulson MSreport

    22/58

    17

    2000 lux arenearor within human perception limits for differentiating between illuminance

    levels.Becausetheaveragehumancannotdistinguishbetweentwoilluminancelevelsthatare

    separatedby30luxdifferenceatlowluxlevels[23]themotesarewellcalibratedbelow2000

    lux.

    Software

    The wireless sensor network was programmed in TinyOS, an open-source platform

    developedatUCBerkeley[26].Themotesusedasimilarstructureasapreviousiterationused

    inthesamelab[23-25].AflowchartforthesoftwarestructurecanbeseeninFigure7.The

    motes,eachwiththeirownuniqueIDs,communicateddatapackagestoabasestationmote

    which forwarded its data via a serial connection a computer that ran an initial data-parsing

    programthatsavedtherawdatalocally.Thisprogramsimplytranslatedanysignalsitreceived

    intotheproperluxandinternalvoltagereadingsaccordingtothecalibrationcurveforthelight

    sensorandsavedthedataincomma-separatedvalueformatwithfilenamesthatcorrespondto

    theuniquemoteIDs.

  • 7/30/2019 Paulson MSreport

    23/58

    18

    From here,a Java-based program was developed toperformseveraltasks. First, the data

    wereparsedtofillinanygapscausedbylostpackages.Second,thedatafromeachmotewere

    thendivideddependingontheangleofthesunateachtimestep.Thenextstepdependedon

    thetypeofmodelgenerated.Ifadaylightmodelwasbeinggenerated,linearregressionwas

    performed as described above to create a piecewise linear function for each workstation,

    dividedby angleof inclinationofthe sun.In sucha case,a linear functionwasestimatedfor

    every0.5sunelevationforpilottestsor0.25forupdatedtests,whichhadahighersampling

    rate.For theseinitial tests, the effect ofthe sun azimuth changingthroughoutthe year was

    neglectedtosimplifythemodelfurther.Ifanartificiallightmodelwasbeinggenerated,asingle

    Figure7Softwareflowchart.Dashedlinesrepresentflowofdatainmodelgenerationphaseonly,

    solidlinesrepresentflowofdatainbothmodelgenerationandpredictionphases.Dash-double-dot

    linesre resentfuturework.

    Workstation

    Sensors

    External

    Database

    BaseStation(Addstimestamp)

    Natural

    Source

    Artificial

    Source

    SunPosition

    Estimator

    PredictionUsing

    RegressionModel

    Regression

    Model

    LocalStorage

  • 7/30/2019 Paulson MSreport

    24/58

    19

    linear function was estimated for the entire data set. These models were then used to

    interpolatethevaluesoftheworkplaneilluminancesforeachprevioustimestepsothatthe

    goodnessoffitcouldbedetermined.

    TestsandTestResults

    Testbeddescription

    Thetestbedwasa450sq.ft.rectangularstudioapartmentwithawest-facingfloor-to-ceiling

    window. The apartment was located on the 16th story of an apartment complex in San

    Francisco,California.Thecontrollablelightsourceswere:akitchenceilingfixtureandabedside

    lampnearthewindow.Throughoutthetest,thespacewasoccupiedbytworesidents(andtwo

    cats) on a daily basis. This testbed was chosen as a real-life setting, typical of a shared

    residentialspace.Figure8showsanoverviewoftheapartment.Figures9and10showthe

    locationofdeskmotes1and2,respectively.Figures11and12showthelocationofartificial

    sourcemotes51and52,respectively.Figure13showsthelocationofdaylightmote101.

  • 7/30/2019 Paulson MSreport

    25/58

    20

    Figure8Testbedoverview

    Figure9Pilotandupdatedpositionofdeskmote1.

  • 7/30/2019 Paulson MSreport

    26/58

    21

    Figure10Pilotandproposedupdatedpositionofdeskmote2.

    Figure11Positionofartificialmote51.

  • 7/30/2019 Paulson MSreport

    27/58

    22

    Figure12Positionofartificialmote52.

    Figure13Positionofwindowmote101.

  • 7/30/2019 Paulson MSreport

    28/58

    23

    TestOverview

    Thefollowingtestswereundertaken:

    1.

    Testoftwoartificiallightsourceswithoutdaylight

    2. Testsofdaylightwithoutartificiallightsourcesa. Pilotdaylighttestsb. Updateddaylighttestsc. Radiancedaylightsimulations

    3. TestofcombineddaylightandtwoartificiallightsourcesArtificialLightSourceTest

    Atestwasperformedtoevaluatethevalidityoftheassumptionthatthecontributionoflight

    emittedfromanartificialsourcefallingonanarbitrarypointinaroomcanbeestimatedusinga

    linear transformation. Two artificial light sources at different points in the room were

    controlledintheabsenceofdaylight.ThedatacanbefoundinFigure14.Theresultswerefed

    intothelinearregressionmodelandtheresultingpredictioncanbeseeninFigure15.

  • 7/30/2019 Paulson MSreport

    29/58

    24

    Figure14February14dataofartificiallightsourcecontributionondesktop1inabsenceofdaylight.

    Figure15February14Mote1dataandpredictionfordesktop1.Meanandstandarddeviationof

    residuals:-0.11812.5626.

    Theresultantpredictionisverypromisingandsupportstheassumptionthatthecontribution

    ofartificiallightsourcescanbemodeledasdirectilluminancethatcanbelinearlymappedtoan

    arbitrarypointinthespace.

  • 7/30/2019 Paulson MSreport

    30/58

    25

    PilotDaylightTests

    An initial series of daylight testswere undertaken. At the time the tests were taken, the

    effect of the sun position was not fully realized, therefore these data are not as full as the

    updatedtest.Thedatafromonewindowmoteweremappedtoapiecewiselinearmodelfor

    eachoftwodeskmotes.Thepredictedvalueswerecomputedusingthedatafromthesingle

    daywiththewidestrangeofsuninclinationrecorded,thatofApril3.Themeansandstandard

    deviationsoftheresidualsareshownforeachday.Figure16showsdatafromMarch8,Figure

    17showsdatafromMarch20,andFigure18showsdatafromApril3.Ineachplot,aprediction

    curveisplottedthatwascreatedusingdatafromApril3.

    Figure16March8DataandPredictionsfromApril3.Meanandstandarddeviationofresiduals:

    Desk1146.505368.0668,Desk2424.8409386.4171.

  • 7/30/2019 Paulson MSreport

    31/58

    26

    Figure17March20DataandPredictionsfromApril3.Meanandstandarddeviationofresiduals:Desk1-85.771109.8475,Desk259.1792374.1701.

    Figure18April3DataandPredictionsfromApril3.Meanandstandarddeviationofresiduals:Desk1-0.151318.5949,Desk21.377365.4952.

  • 7/30/2019 Paulson MSreport

    32/58

    27

    UpdatedDaylightTests

    A second series of testswere undertaken with anupdated workstationmote location on

    April 15, 22, and 26, and May 5. The desktop mote 1 was moved to the top of a computer

    monitor,ratherthanonthedeskitself.Thisdecreasedthelikelihoodofinadvertentshading.

    Thecomputermonitor,beingdirectlybelowthemote,didnothaveameasurableeffectonthe

    illuminancereading.Inaddition,sensorreadingsweretakenevery5seconds,ratherthanevery

    2minutesasintheprevioustest.Forthisreason,thepartitionsizeforthepiecewiselinear

    functionwaschangedto0.25toreflecttheincreasedgranularity.Forthistestthefocuswas

    onjustonedesktopmote.Twomodelsweremadetodeterminethebestfit,usingdatafrom

    April 15 and May 5. The data can be found below with the two model predictions plotted

    againsttheactualdata.Figure19showsdata for April15,Figure20showsdata for April22,

    Figure21showsdataforApril26,andFigure22showsdataforMay5.

    Figure19April15DataandPredictionsfromApril15andMay5.Meanandstandarddeviationof

    residuals:April15Model0.5924109.8859,May5Model134.9063285.4182.

  • 7/30/2019 Paulson MSreport

    33/58

    28

    Figure20April22DataandPredictionsfromApril15andMay5.Meanandstandarddeviationof

    residuals:April15Model173.8485229.5455,May5Model322.4353234.1819.

    Figure21April26DataandPredictionsfromApril15andMay5.Meanandstandarddeviationof

    residuals:April15Model58.820873.8460,May5Model31.939419.0609.

  • 7/30/2019 Paulson MSreport

    34/58

    29

    Figure22May5DataandPredictionsfromApril15andMay5.Meanandstandarddeviationof

    residuals:April15Model-84.6475169.0901,May5Model0.872463.5481.

    RadianceDaylightSimulation

    Radianceilluminancesimulationsformultipledaysthroughouttheyearwereperformedto

    testtheeffectoftimeofyearonthemodel.AnexampleRadianceimagecanbefoundinFigure

    23.TestswereperformedforFebruary10,March20,April22,May10,June20,August10,

    September22,November10,andDecember21atdiscreteintervalsof2hoursbetween06:00

    and 18:00, resulting in 56 simulations, or 7 simulations per day. Illuminance levels at the

    locationsofsensormotesweretakenandcomparedtovaluespredictedfromtheApril15data

    atthegivensuninclinationsandilluminanceatthelocationofthewindowmote.

  • 7/30/2019 Paulson MSreport

    35/58

    30

    Figure23RadiancemodeloftestbedforNovember10,16:00.

    Sample graph from the data can be found in Figures 24 and 25, which show Radiance

    simulationsofdesktop1andwindowmotesforJune20andNovember10,respectively.The

    figures also display predicted values generated by the model using daylight coefficients

    generatedbythedatacollectedonApril15andthesimulatedvaluesfordesktopmote1and

    thewindowmote101.Themeanandstandarddeviationoftheresidualsforthedatacanbe

    foundinTable1.Themodelappearstohavedifficultywhenoneormoreofthemotesare

    subjecttodirectsunlight,asdiscussedinthecalibrationsectionandthateffectisseenifthe

    corresponding residuals are neglected. It is valuable to point out that the illuminance levels

  • 7/30/2019 Paulson MSreport

    36/58

    31

    simulated for the window are at times much higher than the light sensors are capable of

    measuring accurately. The lightsensors would report a smaller lux value if experiencing the

    samelevelofilluminance,sothepredictedmodeloverestimatestheilluminanceincidenton

    thedeskwhenthesimulationreportssuchhighluxlevelsatthewindow.

    Figure24SimulatedRadiancedataofdesktop1forJune20withpredictedvaluesgeneratedusingdata

    fromApril15.

  • 7/30/2019 Paulson MSreport

    37/58

    32

    Figure25SimulatedRadiancedataofdesktop1forNovember10withpredictedvaluesgeneratedusing

    datafromApril15.

    Table1ResidualanalysisoffullRadiancedata(56teststotal)

    Fulldata Onlydiffusesunlight

    Residualmeanandstandarddeviation -54.5229846.9855 -85.368174.9429

    Relativeresidualmeanandstandarddeviation

    0.74882.3735 0.34511.7704

    CombinedDaylightandArtificialLightTest

    UsingdaylightcoefficientsfromtheApril15daylighttestandartificiallightcoefficientsfrom

    the artificial lighttest onFebruary 14, a test was performed ondata that had contributions

    frombothdaylightandartificiallight.TheresultscanbefoundinFigure26,withacloserlookat

    thedesktopmoteandthepredictedvaluesinFigure27.

  • 7/30/2019 Paulson MSreport

    38/58

    33

    Figure26April7Combinedartificialanddaylighttest.

    Figure27April7Combinedartificialanddaylighttest,Mote1andpredictedvalue.Meanandstandard

    deviationofresiduals:-93.0469254.1348.

  • 7/30/2019 Paulson MSreport

    39/58

    34

    Whiletheresultsarenotperfect,itisapparentfromthegraphthatthemajorityoferrorlies

    inthehighluxlevelsofthedaylightregime,whenartificiallightwouldnotbenecessary.Inthe

    absenceofhighluxdaylight,theresultissignificantlymoreaccurate,whichfollowsfromthe

    previoustests.

    Discussion

    Theartificiallightsourcepredictionmodelisverypromisingandappearstohaveahighlevel

    ofaccuracy.Theproposeddaylightmodelseemstohavedifficultywiththehighluxlevelsof

    direct sunlight, which could be offset by careful mote placement and/or mote enclosure

    constructiontoavoiddirectsunlightoraswitchtomorerobustlightsensorsthatcanhandlea

    wider range of illuminance levels. On the other hand, this error could easily be taken into

    accountwiththelightingcontrolalgorithm,as inmostapplicationsnoartificiallightwouldbe

    needediftheluxiswithinthehighluxrange.Ifthehurdleofdirectsunlightisovercome,then

    theresidualstandarddeviationassuggestedintheRadiancedaylighttestsdropstoabout175

    lux,lessthanhalfoftheresidualstandarddeviationof416reportedin[15].Thisvalidatesthe

    piecewise linear approach, as the model created in [15] assumed a time-invariant linear

    transformationbetweenverticalfaadeilluminanceandhorizontalindoorilluminance.

    Theimplicationsofarapidlydevelopedpredictivelightmodelonlightingcontrolsystems

    would be significant. One major advantage is that this package has the ability to evaluate

    controlschemesacrossmultipleusers.Byassigningapiecewiselinearfunctiontoeachuser,it

    is a relatively simple task to evaluate the effect of different control schemes on workplane

    illuminance throughout a large room. A simple method could be to iterate between several

  • 7/30/2019 Paulson MSreport

    40/58

    35

    proposed control schemes and evaluate each in terms of user satisfaction and energy

    efficiency.Fromtherethecontrollercanchoosetheoptimallightingscheme.

    Anotherbenefitofthismodelissuchthat,whilenottothesamelevelofaccuracyasray-

    tracingsoftware,themodelcanbedevelopedusingminimalinformation.Allofthemodelsin

    this report were generated using just a days worth of data. An additional advantage this

    package can provide to lighting control systems is accessibility and ease-of-use. Similar

    predictivemodels,whilesuperiorinaccuracy,areseriouslylimitedinease-of-use.Mostexisting

    predictivemodelsrequiresignificanthardwaresetupand/orroomgeometrymappingviaCAD

    software,whichcanonlybedonebyprofessionals.Thesebothincreasecostofinstallationand

    limitthemarketoftheproducts.Thispackageisplug-and-playtheusersimplyplacesmotesin

    strategicplacesaroundtheroom,entersinthedesirednumberofmotestobefusedintoeach

    workstation,and(optionally)inputsthenumberofinstalledlightingactuationmotes.Theuser

    thenstartsthegenerationsoftware,whichthenrecordslightdataandmapsthecontrollable

    anddaylightilluminancelevelstoeachworkstation.Althoughanelectricianwillberequiredfor

    theinitialinstallationoftheactuationmotesinordertocontrolandtapintothelinepowerof

    thelightingsystem,therestofthesystemcanbeinstalledbyanyonewithageneralknowledge

    ofcomputers.

    Futurework

    The first major hurdle to overcome is the accuracy of the daylight model and the errors

    presentinsensingdirectsunlight.Wewillnexttestwithappropriatecontrolalgorithmstoseeif

    the accuracy achieved is sufficient for a personalized lighting system. If higher accuracy is

  • 7/30/2019 Paulson MSreport

    41/58

    36

    requiredforhighluxlevels,wewillinvestigatenewlightsensorsorareconfiguredlightsensor

    circuit that allows for sensing direct sunlight. In addition, research might be needed to

    determine a set of placement rules that optimize performance of the sensors in a given

    location.

    Further testing is also required to determine the optimal partition size for the piecewise

    linear function. In addition, creating the model over multiple days of data input will be

    investigatedandcomparedtosingledayinput.

    Testingneedsto beperformedtodetermine an easy-to-understanduser interface for the

    modelgenerationpackage.Atthemoment,thesourcecodeisstrictlyformodelgenerationand

    does not have a user-friendly interface. In addition, the code needs to be streamlined for

    memorytoincreaseefficiency.

    Additional research into the inclusion ofshadingcontrol orsimple shadeposition sensing

    couldleadtoamorerobustmodel,asimplementedin[14]and[15].

  • 7/30/2019 Paulson MSreport

    42/58

    37

    Acknowledgements

    I would like to thank Alice Agogino, whose guidance and enthusiasm was crucial to the

    performance of the group. I would like to thank Chandrayee Basu, whose diligence and

    attentiontodetailwasinspiringaswellashelpful.I wouldliketothankAdrianaSeguradoand

    SarahTeplitskyfortheirassistanceinRadiancetesting,whichcouldnothavebeencompleted

    withouttheiraid.IwouldliketothanktheentireSmartLightingteamfortheirhelpandIhope

    that this project can benefit their work. I would like to thank my parents, Jay and Sharon

    Paulson,fortheirloveandsupportthroughoutmyacademiccareer.Lastbutcertainlynotleast

    I wouldliketothank mybetter half,ChelseaEdwards; withouther encouragementand care

    thisworkwouldnothavebeenpossible.

  • 7/30/2019 Paulson MSreport

    43/58

    38

    References

    1) TheInterlaboratoryWorkingGroup,"ScenariosforaCleanEnergyFuture:InterlaboratoryWorkingGrouponEnergy-EfficientandClean-EnergyTechnologies,"

    NREL/TP-620-29379;ORNL/CON-476;LBNL-44029,2000.

    2) USDepartmentofEnergy,EnergyEfficiencyTrendsinResidentialandCommercialBuildings,October2008.[Online].Available:

    http://apps1.eere.energy.gov/buildings/publications/pdfs/corporate/bt_stateindustry.pdf.

    [AccessedApril8,2012].

    3) USDepartmentofEnergy,TheSmartGrid:AnIntroduction,2008.[Online].Available:http://energy.gov/oe/downloads/smart-grid-introduction-0.[AccessedApril29,2012].

    4) C.DiLouie,LightingControlsHandbook.Lilburn,GA:TheFairmontPress,2008.5) A.Guillemin,N.Morel,AnInnovativeLightingControllerIntegratedinaSelf-Adaptive

    BuildingControlSystem,EnergyandBuildings,vol.33,pp.477-487,2001.

    6) A.Aswani,N.Master,J.Taneja,V.Smith,A.Krioukov,D.Culler,andC.Tomlin,IdentifyingModelsofHVACSystemsUsingSemiparametricRegression,inProceedings

    ofAmericanControlConference2012,toappear.

    7) A.Mahdavi,B.Spasojevi,IncorporatingSimulationintoBuildingSystemsControlLogic,Proceedingsofthe10thInternationalBuildingPerformanceSimulation

    AssociationConference,Beijing,China,2007,pp.1175-1181.

    8) A.Mahdavi,M.Schuss,G.Suter,S.Metzger,S.Camara,andS.Dervishi,RecentAdvancesinSimulation-PoweredBuildingSystemsControl,EleventhInternational

    IBPSAConference:BuildingSimulation2009,pp.760-766.

  • 7/30/2019 Paulson MSreport

    44/58

    39

    9) M.Schuss,C.Prglhf,K.Orehounig,S.Dervishi,M.Mller,H.Wascher,andA.Mahdavi.PredictiveModel-BasedControlofVentilation,Lighting,andShadingSystems

    inanOfficeBuilding,IBPSANews,2010,vol.20,pp.24-31.

    10)G.W.Larson,R.A.Shakespeare,RenderingwithRadiance:TheArtandScienceofLightingVisualization.Booksurge,Llc,2004.

    11)E.F.Taylor,LightingFundamentals.Troy,NJ:RensselaerPolytechnicInstitute,2000.12)J.P.Dakin,R.G.W.Brown,Eds.HandbookofOptoelectronics,Volume1.BocaRaton,FL:

    Taylor&FrancisGroup,2006.

    13)G.Gillette,W.Pierpoint,S.Treado,AGeneralIlluminanceModelforDaylightAvailability,JournaloftheIlluminatingEngineeringSociety,1984,vol.13(4),pp.330-

    340.

    14)D.Lindelhf,BayesianOptimizationofVisualComfort,PhDDissertation.colePolytechniqueFdraledeLausanne,2007.Web.[AccessedJuly28,2011].

    15)A.Guillemin,UsingGeneticAlgorithmstoTakeintoAccountUserWishesinanAdvancedBuildingControlSystem,PhDDissertation.colePolytechniqueFdralede

    Lausanne,2003.Web.[AccessedApril26,2012].

    16)R.Perez,R.Seals,andJ.Michalsky,All-WeatherModelforSkyLuminanceDistributionPreliminaryConfigurationandValidation,SolarEnergy,vol.50,no.3,pp.

    235-245,1993.

    17)M.Blanco-Muriel,D.C.Alarcn-Padilla,T.Lpez-Moratalla,andM.Lara-Coira,ComputingtheSolarVector,SolarEnergy,vol.70(5),pp.431-441,2001.

  • 7/30/2019 Paulson MSreport

    45/58

    40

    18)J.Michalsky,TheAstronomicalAlmanacsAlgorithmforApproximateSolarPosition(1950-2050),SolarEnergy,vol.40(3),pp.227-235,1988.

    19)A.Tarantola,InverseProblemTheoryandMethodsforModelParameterEstimation.Philadelphia,PA:TheSocietyforIndustrialandAppliedMathematics,2005.

    20)F.Hayashi,Econometrics.Princeton,NJ:PrincetonUniversityPress,2000.21)MEMSICCorporation,TelosBDatasheet,2010.[Online].Available:

    http://www.memsic.com/products/wireless-sensor-networks/wireless-modules.html.

    [AccessedSeptember14,2011].

    22)OSRAMOptoSemiconductorsGmbH,HighAccuracyAmbientLightSensor:SFH5711,April4,2007.[Online].Available:http://catalog.osram-

    os.com/catalogue/catalogue.do?favOid=0000000300037a3100ad0023&act=showBookmark.

    [AccessedJuly19,2011].

    23)Y.J.Wen,WirelessSensorandActuatorNetworksforLightingEnergyEfficiencyandUserSatisfaction,PhDDissertation,UniversityofCaliforniaatBerkeley,2008.Print.

    24)Y.J.WenandA.M.Agogino,ControlofWireless-NetworkedLightinginanOpen-planOffice,JournalofLightingResearchandTechnology,Vol.43,No.2,June2011,pp.235-

    248.

    25)Y.J.WenandA.M.Agogino,PersonalizedDynamicDesignofNetworkedLightingforEnergy-EfficiencyinOpen-PlanOffices,EnergyandBuildings,Vol.43(8),August2011,

    pp.1919-1924.

    26)P.Levis,S.Madden,J.Polastre,R.Szewczyk,A.Woo,D.Gay,J.Hill,M.Welsh,E.Brewer,andD.Culler,"Tinyos:Anoperatingsystemforsensornetworks,"inAmbient

  • 7/30/2019 Paulson MSreport

    46/58

    41

    Intelligence,W.Weber,J.M.Rabaey,andE.Aarts,Eds.NewYork:SpringerBerlin

    Heidelberg,2005,pp.115-148.

  • 7/30/2019 Paulson MSreport

    47/58

    42

    Appendix

    AppendixA SourceCode

    packagefusiontest;

    /****@authorRyanPaulson*/importJama.Matrix;importjava.io.*;importjava.util.ArrayList;importjava.util.Arrays;importjava.sql.*;importjava.util.Calendar;publicclassFusionTest{

    staticbooleanlastlineonly=false;//staticStringfileName="/home/ryan/test/";staticStringfileName="C:\\Users\\VooDoo\\Documents\\Berkeley\\Documents\\Lighting\\data\\test\\";staticintdelay=5000;//samplingrateinmilliseconds,usedforfillingingapsindatastaticStringthisLine;staticbooleanusewma=false;//booleansusedintestingvariousmethodsstaticbooleanusepreddata=false;staticbooleanlinearmodel=true;staticbooleanctrlswitching=false;staticbooleanwithconstterm=false;

    staticbooleandeskmotespresent=true;staticdoublelatitude=37.777224;//latitudeandlongitude(SanFrancisco,CA)staticdoublelongitude=-122.417361;staticinttzoffset=8;//timezoneoffsetfromGreenwichMeanTimestaticintn=1;//numberofmotes/workstationstaticintworknum=1;//numberofworkstationsstaticintctrlnum=0;//numberofcontrollableinputsstaticintwinnum=1;//numberofmotesatwindowsstaticbooleandaylightonly=false;staticdoublepartitionsize=0.5;//definepartitionsizeforpiecewiselinearmodel

    staticdoublemaxiterationang=151/partitionsize-1;staticStringampm;staticpublicvoidmain(String[]args){buildmodel();if(!daylightonly){for(intw=1;w

  • 7/30/2019 Paulson MSreport

    48/58

    43

    }catch(IOExceptione){}}}for(intang=0;ang(136/partitionsize)/2){ampm="pm";

    a=(136/partitionsize)-1/partitionsize-ang;}else{ampm="am";a=ang;}zone=0;if(a>-1000){if(a

  • 7/30/2019 Paulson MSreport

    49/58

    44

    fw.close();}catch(IOExceptionerr){}}}if(!daylightonly){System.out.println("Ctrlfilespresent");break;}}System.out.println("End\n");

    }staticpublicvoidprediction(intworkstation){Filectrlfile=newFile(fileName+"model/CtrlWinMatrix_total.csv");System.out.println("CtrlFileexists:"+ctrlfile.exists());if(!ctrlfile.exists()){return;}if(usepreddata){ctrlfile=newFile(fileName+"model/CtrlWinMatrix_"+workstation+".csv");}MatrixCtrlMatrix=newMatrix(1,1);try{BufferedReaderbr=newBufferedReader(newFileReader(ctrlfile));CtrlMatrix=Matrix.read(br);br.close();}catch(IOExceptione){System.out.println("Errorreading"+ctrlfile);}introw=CtrlMatrix.getRowDimension();intcol=CtrlMatrix.getColumnDimension();ArrayListpredlist=newArrayList();ArrayListanglist=newArrayList();ArrayListazilist=newArrayList();for(inth=0;h

  • 7/30/2019 Paulson MSreport

    50/58

    45

    }catch(IOExceptione){}FileoutFile=newFile(fileName+"data/TimeSort_"+workstation+".csv");try{FileWriterfw=newFileWriter(outFile,false);for(inti=0;i

  • 7/30/2019 Paulson MSreport

    51/58

    46

    packagefusiontest;

    importJama.Matrix;

    importJama.QRDecomposition;

    importjava.io.*;

    importjava.util.ArrayList;

    importjava.util.Arrays;

    publicclassMultRegModel{

    publicstaticbooleanmatdata(intworknum,intctrlnum,intwinnum,doubleanglemin,Stringampm,StringfileName,booleanlinearmodel,booleanusewma,booleanctrlswitching,booleanwithconstterm,booleandeskmotespresent){

    String[]linesplit=newString[4];

    int[]maxdatalength=newint[worknum+ctrlnum+winnum];

    StringthisLine;

    ArrayListMoteReadings=newArrayList();

    ArrayListControlReadings=newArrayList();

    ArrayListControlReadingssq=newArrayList();

    ArrayListWindowReadings=newArrayList();

    ArrayListWindowReadingssq=newArrayList();

    ArrayListWinTime=newArrayList();

    if(deskmotespresent){

    for(inti=0;i

  • 7/30/2019 Paulson MSreport

    52/58

    47

    br.close();

    }catch(IOExceptionerr){System.out.println("ErrorreadingControl"+(i+51)+""+anglemin+ampm);}

    }}

    for(inti=0;i

  • 7/30/2019 Paulson MSreport

    53/58

    48

    }}

    for(intk=0;k

  • 7/30/2019 Paulson MSreport

    54/58

    49

    PrintWriterpw=newPrintWriter(Ctrlfullfile);

    CtrlMatrix.print(pw,4,4);

    pw.close();

    }catch(IOExceptione){}

    }else{CtrlMatrix=CtrlMatrixstart.getMatrix(0,ctrlrow-1,0,ctrlcol-2);}

    QRDecompositionq=newQRDecomposition(CtrlMatrix);

    System.out.println("CtrlMatrixfullrank?"+q.isFullRank());

    System.out.println("WorkMatrix");

    QRDecompositionq2=newQRDecomposition(WorkMatrix);

    System.out.println("WorkMatrixfullrank?"+q2.isFullRank());

    if(WorkMatrix.getRowDimension()!=CtrlMatrix.getRowDimension()){

    System.out.println("Matrixdimensionsdonotmatch!");

    double[][]b=newdouble[1][1];

    MatrixB=newMatrix(b);

    returnB;}

    if(!q.isFullRank()||!q2.isFullRank()){

    System.out.println("Matricesnotfullrank!\nVarycontrollableinputlevelsandtryagain");

    MatrixB=newMatrix(1,1);

    returnB;}

    double[][]b=newdouble[1][CtrlMatrix.getRowDimension()];

    MatrixB=newMatrix(b);

    B=CtrlMatrix.solve(WorkMatrix);

    introw=CtrlMatrix.getRowDimension();

    intctrlcolumn=CtrlMatrix.getColumnDimension();

    ArrayListQarraylist=newArrayList();

    for(inti=0;i

  • 7/30/2019 Paulson MSreport

    55/58

    50

    Filecoeffullfile=newFile(fileName+"model\\CoefCtrl_"+modelnum+".csv");

    try{

    BufferedReaderbr=newBufferedReader(newFileReader(coefwinfile));

    CoefWin=Matrix.read(br);

    br.close();

    }catch(IOExceptione){}

    try{

    BufferedReaderbr=newBufferedReader(newFileReader(coeffullfile));

    Coef=Matrix.read(br);

    }catch(IOExceptione){}

    intwinrow=CoefWin.getRowDimension();

    intctrlrow=Coef.getRowDimension();

    MatrixCoefAdj=CoefWin;

    try{Predict=Ctrl.times(CoefAdj);

    }catch(IllegalArgumentExceptione){System.out.println("Errorwithmatrixat:"+coefwinfile);

    returnnull;}

    returnPredict;

    }

    }

  • 7/30/2019 Paulson MSreport

    56/58

    51

    packagefusiontest;importjava.lang.Math.*;importjava.sql.Timestamp;publicclassSunPos{publicstaticdouble[]getPos(longlongtime,inttzoffset,doublelatitude,doublelongitude){//sunpositionalgorithm

    (AstronomicalAlmanac)Timestamptmstp=newTimestamp(longtime);Stringstr=tmstp.toString();String[]strarray=str.split("\\D");doubleyear=Integer.parseInt(strarray[0]);doublemonth=Integer.parseInt(strarray[1]);doubleday=Integer.parseInt(strarray[2]);doublehour=Integer.parseInt(strarray[3]);doubleminute=Integer.parseInt(strarray[4]);doublesec=Integer.parseInt(strarray[5]);doubledaysum=day;doubledeg2rad=Math.PI/180;//translatedate/timeintoastronomer'salmanactimeint[]m={0,31,28,31,30,31,30,31,31,30,31,30};

    for(inti=0;i=60&&!(month==2&&day==60)){daysum+=1;}doubleh=hour+minute/60+sec/3600+tzoffset;doubledelta=year-1949;doublepastleap=Math.floor(delta/4);doublejd=2432916.5+delta*365+pastleap+daysum+h/24;doubletime=jd-2451545;

    //Eclipticcoordinatesdoublemnlong=(280.46+0.9856474*time)%360;//meanlongitudeif(mnlong

  • 7/30/2019 Paulson MSreport

    57/58

    AppendixB LightSensorCircuitDiagram

    C:100pFceramiccapacitor

    R:68k0.25Wresistor

  • 7/30/2019 Paulson MSreport

    58/58

    AppendixC TelosBBlockDiagram[21]