User Tools

Site Tools


howtos:toolcoding:projecting_a_share_into_simulation_time

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
Last revision Both sides next revision
howtos:toolcoding:projecting_a_share_into_simulation_time [2010/12/21 17:56]
shona.weldon
howtos:toolcoding:projecting_a_share_into_simulation_time [2011/01/31 16:52]
shona.weldon
Line 3: Line 3:
 Projecting share variables from history into the simulation time using a saturating projection is a common way to create the business as usual data for these variables.  ​ Projecting share variables from history into the simulation time using a saturating projection is a common way to create the business as usual data for these variables.  ​
  
-There is a subroutine which can be hooked into your model and then called from views which does saturated projections with several parameters.+To find the sub-routine related files look in: 
 +\\maxwell\whatif\whatifdocs\toolSubroutines\satProj
  
-Here's some reference code you would put in your view to call the sub routine and below that is the code for the sub routine itself 
  
 +===== Example call to the sub-routine =====
 <​code>​ <​code>​
- localinformant yearInfoSet[] = create (; object=set, \ +! NOTE these informants should be put into your model then these lines should not be included when calling the sub routine 
- desc="​defaults wrt projection year", \ +skipto afterInformants 
- elemName1 = "​min",​ \ +localinformant yearInfoSet[] = create (; object=set, \ 
- elemName2 = "​max",​ \ + desc="​defaults wrt projection year", \ 
- elemName3 = "​default",​ \ + elemName1 = "​min",​ \ 
- elemName4 = "​timeDimNum"​) + elemName2 = "​max",​ \ 
- localinformant boundsInfoSet[] = create (; object=set, \ + elemName3 = "​default",​ \ 
- desc="​defaults wrt bounds checking",​ \ + elemName4 = "​timeDimNum"​) 
- elemName1 = "​setMax",​ \ +localinformant boundsInfoSet[] = create (; object=set, \ 
- elemName2 = "​maxVal",​ \ + desc="​defaults wrt bounds checking",​ \ 
- elemName3 = "​setMin",​ \ + elemName1 = "​setMax",​ \ 
- elemName4 = "​minVal"​) + elemName2 = "​maxVal",​ \ 
- localinformant normInfoSet[] = create (; object=set, \ + elemName3 = "​setMin",​ \ 
- desc="​defaults wrt normalizing",​ \ + elemName4 = "​minVal"​) 
- elemName1 = "​doRenorm",​ \ +localinformant normInfoSet[] = create (; object=set, \ 
- elemName2 = "dimNumInMainVar") + desc="​defaults wrt normalizing",​ \ 
 + elemName1 = "​doRenorm",​ \ 
 + elemName2 = "normDimNum")  
 +afterInformants:​
  
- local varNameHis[upperdims,​timeseq] = newSizeShrPU[cr,​vcld,​t][1] +local varHis[upperdims,​timeseq] = newSizeShrPU[cr,​vcld,​t][1] 
- local varNameResult[upperdims,​timeseq] = newSizeShrPU[cr,​vcld,​t][3]+local varResult[upperdims,​timeseq] = newSizeShrPU[cr,​vcld,​t][3]
  
- local yearInfoForProj[yearInfoSet] = create (; dim=yearInfoSet,​ dataType=integer) +local yearInfoForProj[yearInfoSet] = create (; dim=yearInfoSet,​ dataType=integer) 
- yearInfoForProj[yearInfoSet] = insert (1982; yearInfoSet:​min) +yearInfoForProj[yearInfoSet] = insert (1982; yearInfoSet:​min) 
- yearInfoForProj[yearInfoSet] = insert (2000; yearInfoSet:​max) +yearInfoForProj[yearInfoSet] = insert (2000; yearInfoSet:​max) 
- yearInfoForProj[yearInfoSet] = insert (1982; yearInfoSet:​default) +yearInfoForProj[yearInfoSet] = insert (1982; yearInfoSet:​default) 
- yearInfoForProj[yearInfoSet] = insert (3; yearInfoSet:​timeDimNum) +yearInfoForProj[yearInfoSet] = insert (3; yearInfoSet:​timeDimNum)
-  +
- local boundsChecking[boundsInfoSet] = create (; dim=boundsInfoSet) +
- boundsChecking[boundsInfoSet] = insert (1.0; boundsInfoSet:​setMax) +
- boundsChecking[boundsInfoSet] = insert (1.0; boundsInfoSet:​maxVal) +
- boundsChecking[boundsInfoSet] = insert (1.0; boundsInfoSet:​setMin) +
- boundsChecking[boundsInfoSet] = insert (0.0; boundsInfoSet:​minVal) +
-  +
- local normInfo[normInfoSet] = create (; dim=normInfoSet,​ dataType=integer) +
- normInfo[yearInfoSet] = insert (1; normInfoSet:​doRenorm) +
- normInfo[yearInfoSet] = insert (2; normInfoSet:​dimNumInMainVar) +
-  +
- local percentChgFromLYHis[] = create (; data=50.0) +
-  +
- local defaultJoin[] = create (; data=2) ! join history+
  
- tool $informPath/​satProjFromHist.t \ +local boundsChecking[boundsInfoSet= create (; dim=boundsInfoSet) 
- yearInfoForProj[yearInfoSet\ +boundsChecking[boundsInfoSet] ​= insert (1.0; boundsInfoSet:​setMax) 
- boundsChecking[boundsInfoSet] ​\ +boundsChecking[boundsInfoSet= insert (1.0; boundsInfoSet:​maxVal) 
- normInfo[normInfoSet\ +boundsChecking[boundsInfoSet= insert (1.0; boundsInfoSet:​setMin) 
- percentChgFromLYHis[] \ +boundsChecking[boundsInfoSet= insert (0.0; boundsInfoSet:​minVal)
- defaultJoin[] +
- varNameHis[upperdims,​timeseq] \ +
- varNameResult[upperdims,​timeseq] ​+
  
- newSizeShrPU[cr,​vcld,​t][3] = varNameResult[upperdims,​timeseq] +local normInfo[normInfoSet] = create ​(; dim=normInfoSetdataType=integer
-  +normInfo[yearInfoSet] = insert (1; normInfoSet:​doRenorm) 
- newPUVehShr[cr,​vcld->​vpsld,​ts][3] = mapcat ​(newSizeShrPU[cr,​vcld,​t][3] * \ +normInfo[yearInfoSet] = insert (2; normInfoSet:​normDimNum)
- newEngineShrPU[cr,​vcld,​vpsld,​th][2]category=vcldCOvpsld+
-   desc=$viewMenuChoices+
-  +
- ! CU vehicles +
- varNameHis[upperdims,​timeseq] = newSizeShrCU[cr,​vcld,​t][1] +
- varNameResult[upperdims,​timeseq] = newSizeShrCU[cr,​vcld,​t][3]+
  
-  tool $informPath/​satProjFromHist.t \ +local percentChgFromLYHis[] = create (; data=50.0) 
- yearInfoForProj[yearInfoSet] \ + 
- boundsChecking[boundsInfoSet] \ +local defaultJoin[] = create (; data=2) ! join trend  
- normInfo[normInfoSet] \ + 
- percentChgFromLYHis[] \ +local firstHisYearForProjection[],​ asymtoticPercentChange[],​ joinMethod[] 
- defaultJoin[] \ + 
- varNameHis[upperdims,​timeseq] \ +tool $informPath/​satProjFromHist.t \ 
- varNameResult[upperdims,​timeseq] ​+ yearInfoForProj[yearInfoSet] \ 
 + boundsChecking[boundsInfoSet] \ 
 + normInfo[normInfoSet] \ 
 + percentChgFromLYHis[] \ 
 + defaultJoin[] \ 
 + varHis[upperdims,​timeseq] \ 
 + varResult[upperdims,​timeseq] \ 
 + firstHisYearForProjection[] \ 
 + asymtoticPercentChange[] \ 
 + joinMethod[]
   
- newSizeShrCU[cr,​vcld,​t][3] = varNameResult[upperdims,​timeseq] ​ + 
-  +integer $firstHisYearForProjection 
- newLDVShr[cr,​vcld->​vpsld,​ts][3] = mapcat (newSizeShrCU[cr,​vcld,​t][3] * \ +getobjinfo (firstHisYearForProjection[],​ $firstHisYearForProjection;​ info=dataElement) 
- newEngineShrCU[cr,​vcld,​vpsld,​th][2];​ category=vcldCOvpsld,​ \ +buildstring ($viewDesc,​$viewDesc,"​first year of history for projection = ",​$firstHisYearForProjection,":​ ") 
- desc=$viewMenuChoices) + 
-  endif+string $asymtoticPercentChange 
 +getobjinfo (asymtoticPercentChange[],​ $asymtoticPercentChange;​ info=dataElement) 
 +buildstring ($viewDesc,​$viewDesc,"​asymtotic percent change = ",​$asymtoticPercentChange,":​ ") 
 + 
 +integer $joinMethod 
 +getobjinfo (joinMethod[],​ $joinMethod;​ info=dataElement) 
 +if $joinMethod = 1 
 + buildstring ($viewDesc,​$viewDesc,"​join to projection of last 2 years of history"​) 
 +endif 
 +if $joinMethod = 2 
 + buildstring ($viewDesc,​$viewDesc,"​join to trend line"​) 
 +endif 
 +if $joinMethod = 3 
 + buildstring ($viewDesc,​$viewDesc,"​join to trend projection of last history year"​) 
 +endif 
 + 
 +newSizeShrPU[cr,​vcld,​t][3] = assign (varResult[upperdims,​timeseq] desc=$viewDesc) 
 + 
 +newPUVehShr[cr,​vcld->​vpsld,​ts][3] = mapcat (newSizeShrPU[cr,​vcld,​t][3] * \ 
 + newEngineShrPU[cr,​vcld,​vpsld,​th][2];​ category=vcldCOvpsld,​ \ 
 +desc=$viewMenuChoices) 
 + 
 + 
 </​code>​ </​code>​
 +
 +===== How to load =====
 +Go to your informants window in SAMM and load the informs.samm file from your sub-routine directory
 +
 +
howtos/toolcoding/projecting_a_share_into_simulation_time.txt · Last modified: 2011/02/15 21:36 by marcus.williams