User Tools

Site Tools


howtos:toolcoding:projecting_a_share_into_simulation_time

This is an old revision of the document!


Projecting Share Variables into Simulation Time

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.

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

			localinformant yearInfoSet[] = create (; object=set, \
				desc="defaults wrt projection year", \
				elemName1 = "min", \
				elemName2 = "max", \
				elemName3 = "default", \
				elemName4 = "timeDimNum")
			localinformant boundsInfoSet[] = create (; object=set, \
				desc="defaults wrt bounds checking", \
				elemName1 = "setMax", \
				elemName2 = "maxVal", \
				elemName3 = "setMin", \
				elemName4 = "minVal")
			localinformant normInfoSet[] = create (; object=set, \
				desc="defaults wrt normalizing", \
				elemName1 = "doRenorm", \
				elemName2 = "dimNumInMainVar") 		

			local varNameHis[upperdims,timeseq] = newSizeShrPU[cr,vcld,t][1]
			local varNameResult[upperdims,timeseq] = newSizeShrPU[cr,vcld,t][3]

			local yearInfoForProj[yearInfoSet] = create (; dim=yearInfoSet, dataType=integer)
			yearInfoForProj[yearInfoSet] = insert (1982; yearInfoSet:min)
			yearInfoForProj[yearInfoSet] = insert (2000; yearInfoSet:max)
			yearInfoForProj[yearInfoSet] = insert (1982; yearInfoSet:default)
			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 \
					yearInfoForProj[yearInfoSet] \
					boundsChecking[boundsInfoSet] \
					normInfo[normInfoSet] \
					percentChgFromLYHis[] \
					defaultJoin[] \
					varNameHis[upperdims,timeseq] \
					varNameResult[upperdims,timeseq] 

			newSizeShrPU[cr,vcld,t][3] = varNameResult[upperdims,timeseq]
		
			newPUVehShr[cr,vcld->vpsld,ts][3] = mapcat (newSizeShrPU[cr,vcld,t][3] * \
				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 \
					yearInfoForProj[yearInfoSet] \
					boundsChecking[boundsInfoSet] \
					normInfo[normInfoSet] \
					percentChgFromLYHis[] \
					defaultJoin[] \
					varNameHis[upperdims,timeseq] \
					varNameResult[upperdims,timeseq] 
		
			newSizeShrCU[cr,vcld,t][3] = varNameResult[upperdims,timeseq] 
		
			newLDVShr[cr,vcld->vpsld,ts][3] = mapcat (newSizeShrCU[cr,vcld,t][3] * \
				newEngineShrCU[cr,vcld,vpsld,th][2]; category=vcldCOvpsld, \
				desc=$viewMenuChoices)
 		endif
howtos/toolcoding/projecting_a_share_into_simulation_time.1292954197.txt.gz · Last modified: 2010/12/21 17:56 by shona.weldon