├── .gitattributes
├── .gitignore
├── EmmeConfig.bat
├── README.md
├── accessibilities
├── README.TXT
├── cmapaccess.py
├── inputs
│ ├── Accessibility_impedance_UEC.csv
│ ├── Accessibility_measures_UEC.csv
│ ├── Accessibility_mode_UEC.csv
│ └── Accessibility_size_variables_UEC.CSV
└── runAccessibilities.bat
├── cmap.properties
├── cmap
├── .classpath
├── .project
├── build.jardesc
└── src
│ └── java
│ └── com
│ └── pb
│ └── cmap
│ ├── ctramp
│ ├── Household.java
│ ├── Person.java
│ ├── Stop.java
│ └── Tour.java
│ ├── synpop
│ ├── ARCPopulationSynthesizer.java
│ ├── Aggregator.java
│ ├── DerivedHHARC.java
│ ├── DerivedHHARCFactory.java
│ └── MasterDataDictionary.java
│ ├── tourBased
│ ├── CmapAtWorkSubtourFrequencyDMU.java
│ ├── CmapAutoOwnershipChoiceDMU.java
│ ├── CmapCoordinatedDailyActivityPatternDMU.java
│ ├── CmapCtrampApplication.java
│ ├── CmapCtrampDmuFactory.java
│ ├── CmapDcSoaDMU.java
│ ├── CmapDestChoiceDMU.java
│ ├── CmapFreeParkingChoiceDMU.java
│ ├── CmapHouseholdDataManager.java
│ ├── CmapIndividualMandatoryTourFrequencyDMU.java
│ ├── CmapIndividualNonMandatoryTourFrequencyDMU.java
│ ├── CmapJointTourFrequencyDMU.java
│ ├── CmapModelStructure.java
│ ├── CmapParkingChoiceDMU.java
│ ├── CmapStopDCSoaDMU.java
│ ├── CmapStopFrequencyDMU.java
│ ├── CmapStopLocationDMU.java
│ ├── CmapTazDataHandler.java
│ ├── CmapTourBasedModel.java
│ ├── CmapTourDepartureTimeAndDurationDMU.java
│ ├── CmapTourModeChoiceDMU.java
│ ├── CmapTripMatrixWriter.java
│ └── CmapTripModeChoiceDMU.java
│ └── tvpb
│ ├── BestTransitPathCalculator.java
│ ├── MazTapTazData.java
│ ├── StoredUtilityData.java
│ ├── TransitDriveAccessDMU.java
│ ├── TransitPath.java
│ ├── TransitWalkAccessDMU.java
│ └── Util.java
├── config
├── jppf-driver.properties
├── jppf-guiDistributed.properties
├── jppf-guiLocal.properties
├── jppf-node0.properties
├── jppf-node1.properties
├── jppf-node2.properties
├── jppf-node3.properties
├── jppf.properties
├── killjava.cmd
├── log4j-driver.properties
├── log4j-node0.xml
├── log4j-node1.xml
├── log4j-node2.xml
├── log4j-node3.xml
├── log4j.xml
├── log4j_hh.xml
├── log4j_mtx.xml
├── runJConsole.cmd
├── runMain-SingleProcess.cmd
├── runMain.cmd
├── runNode0.cmd
├── runNode1.cmd
├── runNode2.cmd
└── runNode3.cmd
├── ctrampIf
├── .classpath
├── .project
├── build.jardesc
└── src
│ └── java
│ └── com
│ └── pb
│ └── models
│ └── ctrampIf
│ ├── AtWorkSubtourFrequencyDMU.java
│ ├── AutoOwnershipChoiceDMU.java
│ ├── CoordinatedDailyActivityPatternDMU.java
│ ├── CoordinatedDailyActivityPatternModel.java
│ ├── CtrampDmuFactoryIf.java
│ ├── DcSoaDMU.java
│ ├── Definitions.java
│ ├── DestChoiceDMU.java
│ ├── DestChoiceSize.java
│ ├── FreeParkingChoiceDMU.java
│ ├── HouseholdDataManager.java
│ ├── HouseholdDataManagerIf.java
│ ├── HouseholdDataManagerRmi.java
│ ├── HouseholdDataWriter.java
│ ├── HouseholdIf.java
│ ├── IndividualMandatoryTourFrequencyDMU.java
│ ├── IndividualNonMandatoryTourFrequencyDMU.java
│ ├── JointTourFrequencyDMU.java
│ ├── JointTourFrequencyModel.java
│ ├── MatrixDataServer.java
│ ├── MatrixDataServerRmi.java
│ ├── ModelStructure.java
│ ├── MyLogit.java
│ ├── ParkingChoiceDMU.java
│ ├── PersonIf.java
│ ├── SoaDMU.java
│ ├── StopDCSoaDMU.java
│ ├── StopDestChoiceSize.java
│ ├── StopFrequencyDMU.java
│ ├── StopIf.java
│ ├── StopLocationDMU.java
│ ├── TazDataHandler.java
│ ├── TazDataHandlerRmi.java
│ ├── TazDataIf.java
│ ├── TimeDMU.java
│ ├── TourDepartureTimeAndDurationDMU.java
│ ├── TourIf.java
│ ├── TourModeChoiceDMU.java
│ ├── TravelTimeModel.java
│ ├── TripMatrixWriterIf.java
│ ├── TripModeChoiceDMU.java
│ ├── Util.java
│ ├── UtilRmi.java
│ ├── jppf
│ ├── AutoDependencyModel.java
│ ├── ControlFileReader.java
│ ├── CtrampApplication.java
│ ├── DestChoiceModelManager.java
│ ├── DestinationSampleOfAlternativesModel.java
│ ├── HouseholdAtWorkSubtourDepartureAndDurationTime.java
│ ├── HouseholdAtWorkSubtourFrequencyModel.java
│ ├── HouseholdAutoOwnershipModel.java
│ ├── HouseholdChoiceModelRunner.java
│ ├── HouseholdChoiceModels.java
│ ├── HouseholdChoiceModelsManager.java
│ ├── HouseholdChoiceModelsTaskJppf.java
│ ├── HouseholdCoordinatedDailyActivityPatternModel.java
│ ├── HouseholdFreeParkingModel.java
│ ├── HouseholdIndNonManDestChoiceModel.java
│ ├── HouseholdIndividualMandatoryTourDepartureAndDurationTime.java
│ ├── HouseholdIndividualMandatoryTourFrequencyModel.java
│ ├── HouseholdIndividualNonMandatoryTourFrequencyModel.java
│ ├── HouseholdJointDestChoiceModel.java
│ ├── HouseholdSubTourDestChoiceModel.java
│ ├── JointTourModels.java
│ ├── LocationChoiceTaskJppf.java
│ ├── MandatoryDestChoiceModel.java
│ ├── ModeChoiceModel.java
│ ├── NonMandatoryTourDepartureAndDurationTime.java
│ ├── SampleOfAlternatives.java
│ ├── StopDepartArrivePeriodModel.java
│ ├── StopDestinationSampleOfAlternativesModel.java
│ ├── StopFrequencyModel.java
│ ├── StopLocationModeChoiceModel.java
│ └── UsualWorkSchoolLocationChoiceModel.java
│ └── sqlite
│ ├── ConnectionHelper.java
│ ├── DAOException.java
│ └── SqliteService.java
├── exec
├── common-base.jar
├── jppf-5.0.4-lib
│ ├── collections-generic-4.01.jar
│ ├── colt-1.2.0.jar
│ ├── commons-io-2.4.jar
│ ├── concurrent-1.3.4.jar
│ ├── groovy-all-1.6.5.jar
│ ├── jcommon-1.0.15.jar
│ ├── jfreechart-1.0.12.jar
│ ├── jna-4.1.0.jar
│ ├── jna-platform-4.1.0.jar
│ ├── jppf-admin.jar
│ ├── jppf-client.jar
│ ├── jppf-common.jar
│ ├── jppf-jmxremote_optional-1.1.1.jar
│ ├── jppf-node.jar
│ ├── jppf-server.jar
│ ├── jung-algorithms-2.0.1.jar
│ ├── jung-api-2.0.1.jar
│ ├── jung-graph-impl-2.0.1.jar
│ ├── jung-visualization-2.0.1.jar
│ ├── log4j-1.2.15.jar
│ ├── looks-2.2.2.jar
│ ├── miglayout-3.7-swing.jar
│ ├── slf4j-api-1.6.1.jar
│ └── slf4j-log4j12-1.6.1.jar
├── jxl.jar
├── log4j-1.2.9.jar
├── sawdust-util-1.0.jar
├── ssj.jar
└── synpop.jar
├── population_synthesis
├── 1__control_files
│ ├── createNewControls.R
│ ├── ipf_AB20080429.R
│ ├── original_controls_script
│ │ └── cmap-synpop.R
│ └── update_controls.bat
├── 2__synpop
│ └── model
│ │ ├── RunCMAPPopSynBase.bat
│ │ ├── RunCMAPPopSynForecast.bat
│ │ ├── cmap.base.properties
│ │ ├── cmap.forecast.properties
│ │ ├── cmap.jar
│ │ ├── cmap.properties
│ │ ├── common-base.jar
│ │ ├── jxl.jar
│ │ ├── log4j-1.2.9.jar
│ │ ├── log4j.xml
│ │ ├── synpop.jar
│ │ └── synpop_source_code
│ │ ├── .classpath
│ │ ├── .project
│ │ ├── build.xml
│ │ ├── module_synpop.xml
│ │ ├── src
│ │ └── java
│ │ │ └── com
│ │ │ └── pb
│ │ │ └── models
│ │ │ ├── morpc_synpop
│ │ │ └── PercentageCurve.java
│ │ │ ├── synpop
│ │ │ ├── PumsToSplitIndustry.java
│ │ │ ├── SPG.java
│ │ │ ├── SpgAcsData.java
│ │ │ ├── SpgPumsData.java
│ │ │ ├── ZonalData2DBalancer.java
│ │ │ ├── daf
│ │ │ │ ├── HHAssignerResultsProcessorTask.java
│ │ │ │ ├── HHAssignerTask.java
│ │ │ │ ├── MESSAGE_IDS.java
│ │ │ │ └── SPGMasterTask.java
│ │ │ └── test
│ │ │ │ ├── TestGetSelectionFromCumProbabilities.java
│ │ │ │ └── TestZonalData2DBalancer.java
│ │ │ └── synpopV3
│ │ │ ├── BaseSeedDistributionGenerator.java
│ │ │ ├── BaseTargetGenerator.java
│ │ │ ├── BasicTazData.java
│ │ │ ├── CensusValidationStatistics.java
│ │ │ ├── ControlTable.java
│ │ │ ├── ControlTableBalancer.java
│ │ │ ├── ControlVarIndex.java
│ │ │ ├── ConversionManager.java
│ │ │ ├── DataDictionary.java
│ │ │ ├── DerivedHH.java
│ │ │ ├── DerivedHHFactory.java
│ │ │ ├── DerivedPerson.java
│ │ │ ├── DrawnHH.java
│ │ │ ├── ExtTAZtoIntTAZIndex.java
│ │ │ ├── ForecastTazData.java
│ │ │ ├── FutureSeedDistribution.java
│ │ │ ├── HHCat.java
│ │ │ ├── HHCatTable.java
│ │ │ ├── HHDrawer.java
│ │ │ ├── LookUpTable.java
│ │ │ ├── MetaTargetGenerator.java
│ │ │ ├── MetaTargetSourceGroup.java
│ │ │ ├── NDimensionalMatrixReader.java
│ │ │ ├── NDimensionalMatrixWriter.java
│ │ │ ├── PUMASimilarityTable.java
│ │ │ ├── PUMSAttrs.java
│ │ │ ├── PUMSBucket.java
│ │ │ ├── PUMSBucketBin.java
│ │ │ ├── PUMSBucketGroup.java
│ │ │ ├── PUMSData.java
│ │ │ ├── PUMSHH.java
│ │ │ ├── PUMSPerson.java
│ │ │ ├── PUMSRecordParser.java
│ │ │ ├── PopulationSynthesizer.java
│ │ │ ├── PropertyParser.java
│ │ │ ├── RandomSeedMatrix.java
│ │ │ ├── SynPopPrinter.java
│ │ │ ├── SynPopValidationStatistics.java
│ │ │ ├── TAZBinAssigner.java
│ │ │ ├── TAZtoPUMAIndex.java
│ │ │ ├── TableDataManager.java
│ │ │ ├── TableDataReader.java
│ │ │ ├── TazData.java
│ │ │ └── Validator.java
│ │ └── synpop.iml
├── 3__hh_taz_to_maz
│ ├── cmap_hh_maz.R
│ └── distribute_hh_to_maz.bat
├── README.TXT
└── get_dir.R
├── results_analysis
├── abm
│ ├── __init__.py
│ ├── abm.py
│ ├── comparison.py
│ ├── print_summary.py
│ └── to_csv.py
├── group_calcs.py
├── quantile_calcs.py
└── results_analysis.py
├── runBuildNetworks.py
├── runCTRAMP-SingleProcess.bat
├── runCTRAMP.bat
├── runFinalAssignments.py
├── runInitialSkims.py
├── runMAZSkimsInitial.py
├── runModel.bat
├── runTVPB.bat
├── runTapLines.py
├── scripts
├── Build_TOD_Transit_CT_RAMP3.mac
├── CT_RAMP_skim3.mac
├── EMXtoZMX.py
├── HwayMatIn.mac
├── SPwrapper.py
├── TOD_tables3.mac
├── TranMatIn.mac
├── Transit_assignment_skimming_CT_RAMP3.mac
├── __init__.py
├── abm_extended_transit.py
├── cmapCentroidsConnectors.py
├── cmapInputFileGen.py
├── cmapMAZLUShare.py
├── cmapParallelPP.py
├── cmapPostProcess.py
├── cmapRStoSubZone.py
├── cmapRStoSubZone_future.py
├── cmapShortestPath_NX.py
├── cmapShortestPath_NX_future.py
├── cmapTapConnector.py
├── cmapTransportationNetwork.py
├── extraclass.mac
├── hwySetup.mac
└── parameters.py
├── set_model_paths.bat
├── set_model_paths.py
├── uecs
├── AtWorkSubtourFrequency.xls
├── AutoDependency.xls
├── AutoOwnership.xls
├── BestTransitPathUtility.xls
├── CoordinatedDailyActivityPattern.xls
├── DepartureTimeAndDurationAlternatives.csv
├── DestinationChoice.xls
├── DestinationChoiceAlternativeSample.xls
├── DestinationChoiceAlternatives.csv
├── DestinationChoiceSizeCoefficients.csv
├── DestinationChoice_Orig.xls
├── FreeParkingEligibility.xls
├── IndividualMandatoryTourFrequency.xls
├── IndividualNonMandatoryTourFrequency.xls
├── IndividualNonMandatoryTourFrequencyAlternatives.csv
├── IndividualNonMandatoryTourFrequencyExtensionProbabilities.csv
├── JointTours.xls
├── ModeChoice.xls
├── Parklocation.xls
├── StopDestinationChoice.xls
├── StopDestinationChoiceAlternativeSample.xls
├── StopDestinationChoiceCoefficients.csv
├── StopFrequency.xls
├── StopPurposeLookup.csv
├── TourDepartureAndDuration.xls
├── TourDepartureAndDuration_.xls
├── TripModeChoice.xls
├── cbd_parking_zones.csv
└── stopDepartArriveProportions.csv
└── update_ip_references.py
/.gitattributes:
--------------------------------------------------------------------------------
1 | # Auto detect text files and perform LF normalization
2 | * text=auto
3 |
4 | # Custom for Visual Studio
5 | *.cs diff=csharp
6 | *.sln merge=union
7 | *.csproj merge=union
8 | *.vbproj merge=union
9 | *.fsproj merge=union
10 | *.dbproj merge=union
11 |
12 | # Standard to msysgit
13 | *.doc diff=astextplain
14 | *.DOC diff=astextplain
15 | *.docx diff=astextplain
16 | *.DOCX diff=astextplain
17 | *.dot diff=astextplain
18 | *.DOT diff=astextplain
19 | *.pdf diff=astextplain
20 | *.PDF diff=astextplain
21 | *.rtf diff=astextplain
22 | *.RTF diff=astextplain
23 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # Compiled source #
2 | ###################
3 | *.com
4 | *.class
5 | *.dll
6 | *.exe
7 | *.o
8 | *.pyc
9 | *.so
10 |
11 | # Packages #
12 | ############
13 | # it's better to unpack these files and commit the raw source
14 | # git has its own built in compression methods
15 | *.7z
16 | *.dmg
17 | *.gz
18 | *.iso
19 | *.rar
20 | *.tar
21 | *.zip
22 |
23 | # Logs and databases #
24 | ######################
25 | *.log
26 | *.sql
27 | *.sqlite
28 |
29 | # OS generated files #
30 | ######################
31 | .DS_Store
32 | .DS_Store?
33 | ._*
34 | .Spotlight-V100
35 | .Trashes
36 | Icon?
37 | ehthumbs.db
38 | Thumbs.db
39 |
40 | # Misc filetypes #
41 | ##################
42 | *.url
43 | *.doc
44 | *.docx
45 |
46 | # Excluded folders #
47 | ####################
48 | /CMAP-ABM/
49 | /inputs/
50 | /installers/
51 | /logFiles/
52 | /outputs/
53 | /cmap/build/
54 | /ctrampIf/build/
55 | /population_synthesis/1__control_files/inputs/
56 | /population_synthesis/2__synpop/inputs/
57 | /population_synthesis/2__synpop/outputs/
58 | /population_synthesis/2__synpop/model/synpop_source_code/build/
59 | /population_synthesis/2__synpop/model/synpop_source_code/release/
60 | /population_synthesis/3__hh_taz_to_maz/inputs/
61 | /population_synthesis/3__hh_taz_to_maz/outputs/
62 | .svn/
63 |
64 | # Excluded files #
65 | ####################
66 | /exec/cmap.jar
67 | /exec/ctrampIf.jar
--------------------------------------------------------------------------------
/EmmeConfig.bat:
--------------------------------------------------------------------------------
1 | :: The following code is taken directly from %EMMEPATH%\programs\Emme-cmd.bat
2 | :: (only code after "@echo off", up to and including the "@set path" command
3 | :: was copied). The alternative, according to INRO, is to reinstall Emme and
4 | :: check the box to make its Python the system/default Python.
5 | @set DYNAMEQ=
6 | @for /F "tokens=2* usebackq" %%a in (
7 | `%comspec% /C reg QUERY "HKEY_LOCAL_MACHINE\SOFTWARE\INRO\Dynameq" /v CurrentPath 2^>nul`
8 | ) do (
9 | if %errorlevel%==1 set DYNAMEQ=
10 | if %errorlevel%==0 set DYNAMEQ=%%b
11 | )
12 | IF NOT EXIST "%DYNAMEQ%" set DYNAMEQ=
13 | @set EMMEPATH=C:\Program Files\INRO\Emme\Emme 4\Emme-4.3.6
14 | @set INRO_HOST=EMMEPATH
15 | @set TOOLBOX_PATH=%EMMEPATH%
16 | @set MODELLER_PYTHON=%EMMEPATH%\Python27\
17 | @set currentdir=%CD%
18 | @IF NOT EXIST "%APPDATA%\INRO\Emme" @goto endloop
19 | @cd "%APPDATA%\INRO\Emme\"
20 | @IF EXIST lastworkspace_4.3.6-64bit (
21 | @For /F "tokens=1* delims==" %%A IN (lastworkspace_4.3.6-64bit) DO ( @IF /I "%%A"=="ModellerPython " @set MODELLER_PYTHON=%%B ) )
22 | @cd "%currentdir%"
23 | @IF "X%MODELLER_PYTHON: =%"=="X" @set MODELLER_PYTHON=%EMMEPATH%\Python27\
24 | @For /f "tokens=* delims= " %%a in ("%MODELLER_PYTHON%") do @set MODELLER_PYTHON=%%a
25 | @IF /I "%MODELLER_PYTHON:~0,13%"=="%%<$EmmePath>%%" @set MODELLER_PYTHON=%EMMEPATH%%MODELLER_PYTHON:~13%
26 | @IF NOT "x%MODELLER_PYTHON:<=%"=="x%MODELLER_PYTHON%" @set MODELLER_PYTHON=%EMMEPATH%\Python27\
27 | @IF NOT "x%MODELLER_PYTHON:>=%"=="x%MODELLER_PYTHON%" @set MODELLER_PYTHON=%EMMEPATH%\Python27\
28 | @set MODELLER_PYTHON=%MODELLER_PYTHON%##
29 | @set MODELLER_PYTHON=%MODELLER_PYTHON: ##=##%
30 | @set MODELLER_PYTHON=%MODELLER_PYTHON: ##=##%
31 | @set MODELLER_PYTHON=%MODELLER_PYTHON: ##=##%
32 | @set MODELLER_PYTHON=%MODELLER_PYTHON: ##=##%
33 | @set MODELLER_PYTHON=%MODELLER_PYTHON: ##=##%
34 | @set MODELLER_PYTHON=%MODELLER_PYTHON:##=%
35 | @IF NOT "%MODELLER_PYTHON:~-4%"==".exe" @goto endloop
36 | @set var1=%MODELLER_PYTHON%
37 | @set var2=%var1%
38 | @set i=0
39 | @set j=1
40 | :loopprocess
41 | @for /F "tokens=1* delims=\" %%A in ( "%var1%" ) do (
42 | @set /A i+=1
43 | @set var1=%%B
44 | @goto loopprocess )
45 | :loopprocess2
46 | @for /F "tokens=%j% delims=\" %%G in ( "%var2%" ) do (
47 | @set /A j+=1
48 | @IF %i%==%j% @goto endloop
49 | @IF %j%==1 @set MODELLER_PYTHON=%%G\
50 | @IF NOT %j%==1 @set "MODELLER_PYTHON=%MODELLER_PYTHON%%%G\"
51 | @goto loopprocess2 )
52 | :endloop
53 | @IF NOT EXIST "%MODELLER_PYTHON%" @set MODELLER_PYTHON=%EMMEPATH%\Python27\
54 | @IF NOT "%MODELLER_PYTHON:~-1%"=="\" @set MODELLER_PYTHON=%MODELLER_PYTHON%\
55 | @set path=%EMMEPATH%\programs;%MODELLER_PYTHON%;%PATH%
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # cmap_abm
2 | CMAP's Activity Based Model
3 |
4 | # How To Build
5 | 1. Download Eclipse Luna
6 | 2. Import cmap_abm\cmap as an Eclipse project
7 | 3. Import cmap_abm\ctrampIf as an Eclipse project
8 | 4. Update cmap\.classpath references to external required jars
9 | 5. Update ctrampIf\.classpath references to external required jars
10 | 6. Make sure jxl jar referenced before common-base jar in the .classpath files (in order to avoid Worksheet GC disabled inconsistency error)
11 | 7. Change circular dependencies from errors to warnings: Window -> Preferences -> Java -> Compiler -> Building -> Circular Dependencies
12 | 8. Export ctrampIf.jar via File -> Export and use the ctrampIf\build.jardesc
13 | 9. Export cmap.jar via File -> Export and use the cmap\build.jardesc
14 | 10. Copy ctrampIf.jar and cmap.jar into the EXEC folder when running the model
15 |
--------------------------------------------------------------------------------
/accessibilities/README.TXT:
--------------------------------------------------------------------------------
1 | HOW TO RUN TAP ACCESSIBILITIES CALCULATIONS FROM A *COMPLETED* MODEL RUN
2 | ------------------------------------------------------------------------
3 |
4 | 1. Copy the following files from ..\inputs to inputs:
5 |
6 | - CMAP_MAZ_cents.txt
7 | - SubzoneData.csv
8 | - tap_attributes.csv
9 |
10 |
11 | 2. Connect to an Emme license and launch Emme Shell. From Emme Shell, navigate
12 | to ..\CMAP-ABM\Database\emmemat and submit the following commands to create
13 | the necessary ZMX-formatted input matrices:
14 |
15 | > python ../../../scripts/EMXtoZMX.py ../../CMAP-ABM.emp 103 mf3431 mf3432 mf3433 mf3434 mf3461
16 | > python ../../../scripts/EMXtoZMX.py ../../CMAP-ABM.emp 105 mf5431 mf5432 mf5433 mf5434 mf5461
17 |
18 | Disconnect from the Emme license.
19 |
20 |
21 | 3. Copy the following files from ..\CMAP-ABM\Database\emmemat to inputs:
22 |
23 | - mf3181.zmx
24 | - mf3182.zmx
25 | - mf3183.zmx
26 | - mf3431.zmx
27 | - mf3432.zmx
28 | - mf3433.zmx
29 | - mf3434.zmx
30 | - mf3461.zmx
31 | - mf5181.zmx
32 | - mf5182.zmx
33 | - mf5183.zmx
34 | - mf5431.zmx
35 | - mf5432.zmx
36 | - mf5433.zmx
37 | - mf5434.zmx
38 | - mf5461.zmx
39 |
40 | Note: be sure to copy the ZMX files, instead of the EMX files.
41 |
42 |
43 | 4. Launch runAccessibilities.bat. Python scripts will run automatically,
44 | and will take approximately 20 minutes and 100+ GB RAM.
--------------------------------------------------------------------------------
/accessibilities/inputs/Accessibility_impedance_UEC.csv:
--------------------------------------------------------------------------------
1 | Impedance,Description,Purpose,Period,Offpeak,SOV,WT,NM
2 | 22,AM SOV Time,20,peak,,1,,
3 | 23,OP SOV Time,20,offpeak,,1,,
4 | 24,OP SOV Distance for Non-Motorized Modes,21,offpeak,,,,1
5 | 25,Walk to AM Transit Time,22,peak,,,1,
6 | 26,Walk to OP Transit Time,22,offpeak,,,1,
7 | 5,Non-work accessibility by WT ,4,daily,0.5,,1,
8 | 6,Non-work accessibility by NM ,4,daily,0.5,,,1
9 |
--------------------------------------------------------------------------------
/accessibilities/inputs/Accessibility_measures_UEC.csv:
--------------------------------------------------------------------------------
1 | measure,size,impedance,period,model
2 | 60,27,22,peak,autoPeakRetail
3 | 61,28,22,peak,autoPeakTotal
4 | 62,27,23,offpeak,autoOffPeakRetail
5 | 63,28,23,offpeak,autoOffPeakTotal
6 | 64,27,24,offpeak,nonMotorizedRetail
7 | 65,28,24,offpeak,nonMotorizedTotal
8 | 66,27,25,peak,transitPeakRetail
9 | 67,28,25,peak,transitPeakTotal
10 | 68,27,26,offpeak,transitOffPeakRetail
11 | 69,28,26,offpeak,transitOffPeakTotal
12 | 17,11,5,daily,access17
13 | 18,11,6,daily,access18
14 |
--------------------------------------------------------------------------------
/accessibilities/inputs/Accessibility_mode_UEC.csv:
--------------------------------------------------------------------------------
1 | Purpose,Period,Files,Expressions,Description,SOV,WT,NM
2 | 4,offpeak,mf5181.zmx,"db['mf5181'][o_t,d_t]",SOV time off-peak,-0.03,,
3 | 4,offpeak,mf5182.zmx,"db['mf5182'][o_t,d_t]*100",Toll off-peak,-0.004,,
4 | 4,offpeak,mf5183.zmx,"db['mf5183'][o_t,d_t]",Highway distance off-peak,-0.03,,-1.5
5 | 4,offpeak,mf5183.zmx,"(db['mf5183'][o_t,d_t] > 3) * 1 + (db['mf5183'][o_t,d_t] <= 3) * 0",NM unavailable,,,-999
6 | 4,offpeak,mf5431.zmx,"(db['mf5431'][o_wt,d_wt] <= 1) * 1 + (db['mf5431'][o_wt,d_wt] > 1) * 0",WTransit unavailable,,-999,
7 | 4,offpeak,"mf5431.zmx,mf5432.zmx,mf5433.zmx,mf5434.zmx,taps_near.csv","db['mf5431'][o_wt,d_wt] + 2.5*(db['mf5432'][o_wt,d_wt] + db['mf5433'][o_wt,d_wt] + db['mf5434'][o_wt,d_wt] + db['taps_near']['wt_time'].as_matrix()[o_m] + db['taps_near']['wt_time'].as_matrix()[d_m])",WTransit weighted time off-peak,,-0.03,
8 | 4,offpeak,mf5461.zmx,"db['mf5461'][o_t,d_t]",WTransit fare in cents,,-0.004,
9 | 4,offpeak,,1,Constant,-1.5,,
10 | 4,peak,mf3181.zmx,"db['mf3181'][o_t,d_t]",SOV time peak,-0.03,,
11 | 4,peak,mf3182.zmx,"db['mf3182'][o_t,d_t]*100",Toll peak,-0.004,,
12 | 4,peak,mf3183.zmx,"db['mf3183'][o_t,d_t]",Highway distance peak,-0.03,,-1.5
13 | 4,peak,mf3183.zmx,"(db['mf3183'][o_t,d_t] > 3) * 1 + (db['mf3183'][o_t,d_t] <= 3) * 0",NM unavailable,,,-999
14 | 4,peak,mf3431.zmx,"(db['mf3431'][o_wt,d_wt] <= 1) * 1 + (db['mf3431'][o_wt,d_wt] > 1) * 0",WTransit unavailable,,-999,
15 | 4,peak,"mf3431.zmx,mf3432.zmx,mf3433.zmx,mf3434.zmx,taps_near.csv","db['mf3431'][o_wt,d_wt] + 2.5*(db['mf3432'][o_wt,d_wt] + db['mf3433'][o_wt,d_wt] + db['mf3434'][o_wt,d_wt] + db['taps_near']['wt_time'].as_matrix()[o_m] + db['taps_near']['wt_time'].as_matrix()[d_m])",WTransit weighted time peak,,-0.03,
16 | 4,peak,mf3461.zmx,"db['mf3461'][o_t,d_t]",WTransit fare in cents,,-0.004,
17 | 4,peak,,1,Constant,-1.5,,
18 | 20,offpeak,mf5181.zmx,"db['mf5181'][o_t,d_t]",SOV time off-peak,-0.05,,
19 | 20,peak,mf3181.zmx,"db['mf3181'][o_t,d_t]",SOV time peak,-0.05,,
20 | 21,offpeak,mf5183.zmx,"db['mf5183'][o_t,d_t]",Highway distance off-peak,,,-1
21 | 21,offpeak,mf5183.zmx,"(db['mf5183'][o_t,d_t] > 3) * 1 + (db['mf5183'][o_t,d_t] <= 3) * 0",NM unavailable,,,-999
22 | 21,peak,mf3183.zmx,"db['mf3183'][o_t,d_t]",Highway distance peak,,,-1
23 | 21,peak,mf3183.zmx,"(db['mf3183'][o_t,d_t] > 3) * 1 + (db['mf3183'][o_t,d_t] <= 3) * 0",NM unavailable,,,-999
24 | 22,offpeak,"mf5431.zmx,mf5432.zmx,mf5433.zmx,mf5434.zmx,taps_near.csv","db['mf5431'][o_wt,d_wt] + 2.5*(db['mf5432'][o_wt,d_wt] + db['mf5433'][o_wt,d_wt] + db['mf5434'][o_wt,d_wt] + db['taps_near']['wt_time'].as_matrix()[o_m] + db['taps_near']['wt_time'].as_matrix()[d_m])",WTransit weighted time off-peak,,-0.05,
25 | 22,offpeak,mf5431.zmx,"(db['mf5431'][o_wt,d_wt] <= 1) * 1 + (db['mf5431'][o_wt,d_wt] > 1) * 0",WTransit unavailable,,-999,
26 | 22,peak,"mf3431.zmx,mf3432.zmx,mf3433.zmx,mf3434.zmx,taps_near.csv","db['mf3431'][o_wt,d_wt] + 2.5*(db['mf3432'][o_wt,d_wt] + db['mf3433'][o_wt,d_wt] + db['mf3434'][o_wt,d_wt] + db['taps_near']['wt_time'].as_matrix()[o_m] + db['taps_near']['wt_time'].as_matrix()[d_m])",WTransit weighted time peak,,-0.05,
27 | 22,peak,mf3431.zmx,"(db['mf3431'][o_wt,d_wt] <= 1) * 1 + (db['mf3431'][o_wt,d_wt] > 1) * 0",WTransit unavailable,,-999,
28 |
--------------------------------------------------------------------------------
/accessibilities/inputs/Accessibility_size_variables_UEC.CSV:
--------------------------------------------------------------------------------
1 | Variable,Description,p11,p27,p28
2 | emp,Total employment,,,1
3 | hshld,Total number of households,0.766913944,,
4 | naics44_45,NAICS sector 44-45 (Retail Trade),14.59074254,1,
5 | naics53,NAICS sector 53 (Real Estate and Rental and Leasing),0.331604909,,
6 | naics62,NAICS sector 62 (Health Care and Social Assistance),2.315486906,,
7 | naics71,"NAICS sector 71 (Arts, Entertainment, and Recreation)",4.849649961,,
8 | naics72,NAICS sector 72 (Accommodation and Food Services),1.148980647,,
9 | naics81,NAICS sector 81 (Other Services [except Public Administration]),3.115443779,,
10 | naics92,NAICS sector 92 (Public Administration),0.233896005,,
11 |
--------------------------------------------------------------------------------
/accessibilities/runAccessibilities.bat:
--------------------------------------------------------------------------------
1 | :: Requires 64-bit Anaconda from www.continuum.io/downloads in C:\Anaconda
2 | SET conda=C:\Anaconda\python.exe
3 | CALL ..\EmmeConfig.bat
4 | SET emmepy="%EMMEPATH%\Python27\python.exe"
5 |
6 | :: Copy required non-skim inputs
7 | cd ..\inputs
8 | copy CMAP_MAZ_cents.txt ..\accessibilities\inputs
9 | copy SubzoneData.csv ..\accessibilities\inputs
10 | copy tap_attributes.csv ..\accessibilities\inputs
11 |
12 | :: Set transit AM Peak and Midday scenario IDs
13 | SET scen=%1
14 | SET /a scen3=%scen%+3
15 | SET /a scen5=%scen%+5
16 |
17 | :: Create/copy all necessary skim ZMXs
18 | :: (mfX181-83 already created by ..\runInitialSkims.py)
19 | cd ..\CMAP-ABM\Database\emmemat
20 | %emmepy% ../../../scripts/EMXtoZMX.py ../../CMAP-ABM.emp %scen3% mf3431 mf3432 mf3433 mf3434 mf3461
21 | %emmepy% ../../../scripts/EMXtoZMX.py ../../CMAP-ABM.emp %scen5% mf5431 mf5432 mf5433 mf5434 mf5461
22 | copy mf3181.zmx ..\..\..\accessibilities\inputs
23 | copy mf3182.zmx ..\..\..\accessibilities\inputs
24 | copy mf3183.zmx ..\..\..\accessibilities\inputs
25 | copy mf3431.zmx ..\..\..\accessibilities\inputs
26 | copy mf3432.zmx ..\..\..\accessibilities\inputs
27 | copy mf3433.zmx ..\..\..\accessibilities\inputs
28 | copy mf3434.zmx ..\..\..\accessibilities\inputs
29 | copy mf3461.zmx ..\..\..\accessibilities\inputs
30 | copy mf5181.zmx ..\..\..\accessibilities\inputs
31 | copy mf5182.zmx ..\..\..\accessibilities\inputs
32 | copy mf5183.zmx ..\..\..\accessibilities\inputs
33 | copy mf5431.zmx ..\..\..\accessibilities\inputs
34 | copy mf5432.zmx ..\..\..\accessibilities\inputs
35 | copy mf5433.zmx ..\..\..\accessibilities\inputs
36 | copy mf5434.zmx ..\..\..\accessibilities\inputs
37 | copy mf5461.zmx ..\..\..\accessibilities\inputs
38 |
39 | :: Return to accessibilities dir and run processing scripts
40 | cd ..\..\..\accessibilities
41 | %conda% cmapaccess.py near_taps
42 | %conda% cmapaccess.py accessibilities
43 |
--------------------------------------------------------------------------------
/cmap/.classpath:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
--------------------------------------------------------------------------------
/cmap/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | cmap
4 |
5 |
6 |
7 |
8 |
9 | org.eclipse.jdt.core.javabuilder
10 |
11 |
12 |
13 |
14 |
15 | org.eclipse.jdt.core.javanature
16 |
17 |
18 |
--------------------------------------------------------------------------------
/cmap/build.jardesc:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/cmap/src/java/com/pb/cmap/synpop/ARCPopulationSynthesizer.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2007 PB Americas, Inc.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | */
17 | package com.pb.cmap.synpop;
18 |
19 | import java.util.ResourceBundle;
20 | import java.util.Vector;
21 |
22 | import com.pb.common.util.ResourceUtil;
23 | import com.pb.models.synpopV3.PopulationSynthesizer;
24 |
25 | /**
26 | * Calls the synpopV3 model for use with the ARC project. Also calls John Bowman's Aggregator
27 | * class to produce trip-based model input.
28 | *
29 | * @author D. Ory
30 | *
31 | */
32 |
33 | public class ARCPopulationSynthesizer extends PopulationSynthesizer {
34 |
35 | public ARCPopulationSynthesizer() {
36 | super("cmap", new DerivedHHARCFactory());
37 | }
38 |
39 | public ARCPopulationSynthesizer(String propertiesRoot){
40 | super(propertiesRoot, new DerivedHHARCFactory());
41 | }
42 |
43 | // public void createDerivedHHFactory(){
44 | // hhFactory = new DerivedHHARCFactory();
45 | // }
46 |
47 | public static void main(String[] args) {
48 |
49 | // use the MTC-version of the resource bundle, and inherited derived household class
50 | Vector[][] synPop;
51 | PopulationSynthesizer arcPopulationSynthesizer = new ARCPopulationSynthesizer();
52 | synPop = arcPopulationSynthesizer.runPopulationSynthesizer();
53 |
54 | // run the aggregator if requested
55 | ResourceBundle resourceBundle = ResourceUtil.getResourceBundle("cmap");
56 | boolean runAggregator = ResourceUtil.getBooleanProperty(resourceBundle, "RunAggregator");
57 | if(runAggregator){
58 |
59 | // user feedback
60 | logger.info("Running Aggregator post process...");
61 |
62 | // create Bowman's master data dictionary object
63 | String pumsDirectory = ResourceUtil.getProperty(resourceBundle, "pums.directory");
64 | String pumsDictionary = ResourceUtil.getProperty(resourceBundle, "pums.dictionary");
65 | pumsDictionary = pumsDirectory+pumsDictionary;
66 |
67 | String masterDictonaryFile = ResourceUtil.getProperty(resourceBundle, "MasterDataDictionaryInputFile");
68 |
69 | MasterDataDictionary masterDataDictionary = new MasterDataDictionary(pumsDictionary,masterDictonaryFile);
70 | logger.info("Number of Master Data Dictionary entries: "+masterDataDictionary.entries.size());
71 |
72 | // create Bowman's aggregator to read from control file and set up aggregationSpecs
73 | Aggregator aggregator=new Aggregator(masterDataDictionary);
74 | int n = aggregator.getNumberOfAggregations();
75 |
76 | // loop to produce aggregations
77 | for(int i=1; i<=n; i++){
78 | aggregator.aggregate(synPop, aggregator.getAggregationSpec(i));
79 | //note: aggregate produces output and returns aggregation object, but the object is not here used.
80 | }
81 |
82 | }
83 |
84 | logger.info(" ");
85 | logger.info("End: ARC Population Synthesizer");
86 |
87 |
88 | }
89 |
90 | }
91 |
--------------------------------------------------------------------------------
/cmap/src/java/com/pb/cmap/synpop/DerivedHHARCFactory.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2007 PB Americas
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | */
17 | package com.pb.cmap.synpop;
18 |
19 | import java.util.Vector;
20 |
21 | import com.pb.models.synpopV3.DataDictionary;
22 | import com.pb.models.synpopV3.DerivedHHFactory;
23 |
24 | /**
25 | * A class that creates DerivedHH objects
26 | *
27 | * @author D. Ory (same as Erhardt DerivedHHSFFactory)
28 | * @version 1.0 Oct 19, 2007
29 | *
30 | */
31 | public class DerivedHHARCFactory extends DerivedHHFactory {
32 |
33 |
34 | public DerivedHHARCFactory() {
35 | super();
36 | }
37 |
38 | public DerivedHHARC createDerivedHH(String record_raw, Vector pRecords_raw, DataDictionary dd) {
39 | DerivedHHARC hh = new DerivedHHARC(record_raw, pRecords_raw, dd);
40 | return hh;
41 | }
42 |
43 | }
44 |
--------------------------------------------------------------------------------
/cmap/src/java/com/pb/cmap/tourBased/CmapAtWorkSubtourFrequencyDMU.java:
--------------------------------------------------------------------------------
1 | package com.pb.cmap.tourBased;
2 |
3 | import java.util.HashMap;
4 |
5 | import com.pb.common.calculator.VariableTable;
6 | import com.pb.models.ctrampIf.AtWorkSubtourFrequencyDMU;
7 | import com.pb.models.ctrampIf.ModelStructure;
8 |
9 | public class CmapAtWorkSubtourFrequencyDMU extends AtWorkSubtourFrequencyDMU implements VariableTable {
10 |
11 |
12 | public CmapAtWorkSubtourFrequencyDMU( ModelStructure modelStructure ){
13 | super( modelStructure );
14 | this.modelStructure = modelStructure;
15 | setupMethodIndexMap();
16 | }
17 |
18 |
19 |
20 | /**
21 | * @return household income category
22 | */
23 | public int getHhIncomeCategory() {
24 | return hh.getIncomeSegment();
25 | }
26 |
27 |
28 |
29 | private void setupMethodIndexMap() {
30 | methodIndexMap = new HashMap();
31 |
32 | methodIndexMap.put( "getHhIncomeCategory", 0 );
33 | methodIndexMap.put( "getNumAutos", 1 );
34 | methodIndexMap.put( "getPersonIsFullTimeWorker", 2 );
35 | methodIndexMap.put( "getPersonIsNonworker", 3 );
36 | methodIndexMap.put( "getWorkTazAreaType", 4 );
37 | methodIndexMap.put( "getWorkTourDuration", 5 );
38 | methodIndexMap.put( "getJointMaintShopEatPerson", 6 );
39 | methodIndexMap.put( "getJointDiscrPerson", 7 );
40 | methodIndexMap.put( "getIndivMaintShopEscortFt", 8 );
41 | methodIndexMap.put( "getIndivMaintShopEscortPt", 9 );
42 | methodIndexMap.put( "getIndivDiscrFt", 10 );
43 | methodIndexMap.put( "getIndivDiscrPt", 11 );
44 | methodIndexMap.put( "getIndivEatOut", 12 );
45 | methodIndexMap.put( "getWorkTourModeIsSOV", 13 );
46 | methodIndexMap.put( "getNumPersonWorkTours", 14 );
47 | methodIndexMap.put( "getWorkStudNonMandatoryTours", 15 );
48 | }
49 |
50 |
51 |
52 | public double getValueForIndex(int variableIndex, int arrayIndex) {
53 |
54 | switch ( variableIndex ){
55 | case 0: return getHhIncomeCategory();
56 | case 1: return getNumAutos();
57 | case 2: return getPersonIsFullTimeWorker();
58 | case 3: return getPersonIsNonworker();
59 | case 4: return getWorkTazAreaType();
60 | case 5: return getWorkTourDuration();
61 | case 6: return getJointMaintShopEatPerson();
62 | case 7: return getJointDiscrPerson();
63 | case 8: return getIndivMaintShopEscortFt();
64 | case 9: return getIndivMaintShopEscortPt();
65 | case 10: return getIndivDiscrFt();
66 | case 11: return getIndivDiscrPt();
67 | case 12: return getIndivEatOut();
68 | case 13: return getWorkTourModeIsSOV();
69 | case 14: return getNumPersonWorkTours();
70 | case 15: return getWorkStudNonMandatoryTours();
71 |
72 | default:
73 | logger.error("method number = "+variableIndex+" not found");
74 | throw new RuntimeException("method number = "+variableIndex+" not found");
75 |
76 | }
77 |
78 | }
79 |
80 |
81 | }
82 |
--------------------------------------------------------------------------------
/cmap/src/java/com/pb/cmap/tourBased/CmapAutoOwnershipChoiceDMU.java:
--------------------------------------------------------------------------------
1 | package com.pb.cmap.tourBased;
2 |
3 | import java.util.HashMap;
4 |
5 | import com.pb.models.ctrampIf.AutoOwnershipChoiceDMU;
6 |
7 |
8 | public class CmapAutoOwnershipChoiceDMU extends AutoOwnershipChoiceDMU {
9 |
10 |
11 | public CmapAutoOwnershipChoiceDMU() {
12 | super ();
13 | setupMethodIndexMap();
14 | }
15 |
16 | public int getHhIncome() {
17 | return hh.getIncomeSegment();
18 | }
19 |
20 | private void setupMethodIndexMap() {
21 | methodIndexMap = new HashMap();
22 |
23 | methodIndexMap.put( "getSize", 0 );
24 | methodIndexMap.put( "getNumChildrenUnder16", 1 );
25 | methodIndexMap.put( "getDrivers", 2 );
26 | methodIndexMap.put( "getWorkers", 3 );
27 | methodIndexMap.put( "getStudents", 4 );
28 | methodIndexMap.put( "getNumPersons16to17", 5 );
29 | methodIndexMap.put( "getNumPersons18to24", 6 );
30 | methodIndexMap.put( "getHhIncome", 7 );
31 | methodIndexMap.put( "getWorkAutoDependency", 8 );
32 | methodIndexMap.put( "getSchoolAutoDependency", 9 );
33 | methodIndexMap.put( "getHhBldgsz", 10 );
34 | methodIndexMap.put( "getAccess17", 11 );
35 | methodIndexMap.put( "getAccess18", 12 );
36 | methodIndexMap.put( "getNumPersons65to79", 13 );
37 | methodIndexMap.put( "getNumPersons80plus", 14 );
38 |
39 | }
40 |
41 |
42 |
43 | public double getValueForIndex(int variableIndex, int arrayIndex) {
44 |
45 | switch ( variableIndex ){
46 | case 0: return getSize();
47 | case 1: return getNumChildrenUnder16();
48 | case 2: return getDrivers();
49 | case 3: return getWorkers();
50 | case 4: return getStudents();
51 | case 5: return getNumPersons16to17();
52 | case 6: return getNumPersons18to24();
53 | case 7: return getHhIncome();
54 | case 8: return getWorkAutoDependency();
55 | case 9: return getSchoolAutoDependency();
56 | case 10: return getHhBldgsz();
57 | case 11: return getAccess17();
58 | case 12: return getAccess18();
59 | case 13: return getNumPersons65to79();
60 | case 14: return getNumPersons80plus();
61 |
62 | default:
63 | logger.error("method number = "+variableIndex+" not found");
64 | throw new RuntimeException("method number = "+variableIndex+" not found");
65 |
66 | }
67 | }
68 |
69 | }
--------------------------------------------------------------------------------
/cmap/src/java/com/pb/cmap/tourBased/CmapCtrampApplication.java:
--------------------------------------------------------------------------------
1 | package com.pb.cmap.tourBased;
2 |
3 | import java.util.ResourceBundle;
4 |
5 |
6 | import com.pb.common.util.ResourceUtil;
7 | import com.pb.models.ctrampIf.jppf.CtrampApplication;
8 |
9 |
10 | public class CmapCtrampApplication extends CtrampApplication{
11 |
12 | public static final String PROGRAM_VERSION = "09June2008";
13 | public static final String PROPERTIES_PROJECT_DIRECTORY = "Project.Directory";
14 |
15 |
16 |
17 | public CmapCtrampApplication( ResourceBundle rb ){
18 | super( rb );
19 |
20 | projectDirectory = ResourceUtil.getProperty(rb, PROPERTIES_PROJECT_DIRECTORY);
21 |
22 | }
23 |
24 | }
--------------------------------------------------------------------------------
/cmap/src/java/com/pb/cmap/tourBased/CmapFreeParkingChoiceDMU.java:
--------------------------------------------------------------------------------
1 | package com.pb.cmap.tourBased;
2 |
3 | import java.util.HashMap;
4 |
5 | import com.pb.models.ctrampIf.FreeParkingChoiceDMU;
6 |
7 |
8 | public class CmapFreeParkingChoiceDMU extends FreeParkingChoiceDMU {
9 |
10 |
11 |
12 | public CmapFreeParkingChoiceDMU() {
13 | super();
14 | setupMethodIndexMap();
15 | }
16 |
17 |
18 |
19 | private void setupMethodIndexMap() {
20 | methodIndexMap = new HashMap();
21 |
22 | methodIndexMap.put( "getHHIncome", 0 );
23 | methodIndexMap.put( "getAutoOwnership", 1 );
24 | methodIndexMap.put( "getFtwkPersons", 2 );
25 | methodIndexMap.put( "getPtwkPersons", 3 );
26 | methodIndexMap.put( "getSize", 4 );
27 | }
28 |
29 |
30 |
31 | public int getHHIncome() {
32 | return hh.getIncomeSegment();
33 | }
34 |
35 |
36 | public double getValueForIndex(int variableIndex, int arrayIndex) {
37 |
38 | switch ( variableIndex ){
39 | case 0: return getHHIncome();
40 | case 1: return getAutoOwnership();
41 | case 2: return getFtwkPersons();
42 | case 3: return getPtwkPersons();
43 | case 4: return getSize();
44 |
45 | default:
46 | logger.error("method number = "+variableIndex+" not found");
47 | throw new RuntimeException("method number = "+variableIndex+" not found");
48 |
49 | }
50 | }
51 |
52 | }
--------------------------------------------------------------------------------
/cmap/src/java/com/pb/cmap/tourBased/CmapParkingChoiceDMU.java:
--------------------------------------------------------------------------------
1 | package com.pb.cmap.tourBased;
2 |
3 | import java.util.HashMap;
4 |
5 | import com.pb.models.ctrampIf.ModelStructure;
6 | import com.pb.models.ctrampIf.ParkingChoiceDMU;
7 | import com.pb.models.ctrampIf.TazDataIf;
8 |
9 |
10 |
11 | public class CmapParkingChoiceDMU extends ParkingChoiceDMU {
12 |
13 |
14 | TazDataIf tazDataManager;
15 |
16 | public CmapParkingChoiceDMU( TazDataIf tazDataManager, ModelStructure modelStructure ){
17 | super( tazDataManager );
18 | setupMethodIndexMap( modelStructure );
19 |
20 | this.tazDataManager = tazDataManager;
21 | }
22 |
23 | public double getOMazDMazDistanceAlt ( int alt ) {
24 | int destZone = parkTazs[alt-1];
25 | return tazDataManager.getOMazDMazDistance(dmuIndex.getOriginZone(), destZone);
26 | }
27 |
28 | public double getAltDMazDistanceAlt ( int alt ) {
29 | int altZone = parkTazs[alt-1];
30 | return tazDataManager.getOMazDMazDistance(altZone, dmuIndex.getDestZone());
31 | }
32 |
33 | private void setupMethodIndexMap( ModelStructure modelStructure ) {
34 |
35 | methodIndexMap = new HashMap();
36 |
37 | methodIndexMap.put( "getParkTazCbdAreaTypeAlt", 0 );
38 | methodIndexMap.put( "getTourIsJoint", 1 );
39 | methodIndexMap.put( "getParkingCostAlt", 2 );
40 | methodIndexMap.put( "getParkTot", 3 );
41 | methodIndexMap.put( "getParkTotAlt", 4 );
42 |
43 | methodIndexMap.put( "getOMazDMazDistanceAlt", 20 );
44 | methodIndexMap.put( "getAltDMazDistanceAlt", 21 );
45 |
46 | // populate map of hours parked per day by purpose name
47 | averageDailyHoursParkedMap = new HashMap();
48 | averageDailyHoursParkedMap.put( modelStructure.WORK_PURPOSE_NAME, 7.9f );
49 | averageDailyHoursParkedMap.put( modelStructure.UNIVERSITY_PURPOSE_NAME, 6.2f );
50 | averageDailyHoursParkedMap.put( modelStructure.SCHOOL_PURPOSE_NAME, 7.9f );
51 | averageDailyHoursParkedMap.put( modelStructure.ESCORT_PURPOSE_NAME, 1.1f );
52 | averageDailyHoursParkedMap.put( modelStructure.SHOPPING_PURPOSE_NAME, 1.7f );
53 | averageDailyHoursParkedMap.put( modelStructure.OTH_MAINT_PURPOSE_NAME, 2.8f );
54 | averageDailyHoursParkedMap.put( modelStructure.EAT_OUT_PURPOSE_NAME, 2.2f );
55 | averageDailyHoursParkedMap.put( modelStructure.SOCIAL_PURPOSE_NAME, 3.0f );
56 | averageDailyHoursParkedMap.put( modelStructure.OTH_DISCR_PURPOSE_NAME, 2.7f );
57 | averageDailyHoursParkedMap.put( modelStructure.AT_WORK_PURPOSE_NAME, 0.6f );
58 |
59 | }
60 |
61 | public double getValueForIndex(int variableIndex, int arrayIndex) {
62 |
63 | switch ( variableIndex ){
64 | case 0: return getParkTazCbdAreaTypeAlt( arrayIndex );
65 | case 1: return getTourIsJoint();
66 | case 2: return getParkingCostAlt( arrayIndex );
67 | case 3: return getParkTot();
68 | case 4: return getParkTotAlt( arrayIndex );
69 |
70 | case 20: return getOMazDMazDistanceAlt( arrayIndex );
71 | case 21: return getAltDMazDistanceAlt( arrayIndex );
72 |
73 | default:
74 | logger.error("method number = "+variableIndex+" not found");
75 | throw new RuntimeException("method number = "+variableIndex+" not found");
76 |
77 | }
78 |
79 | }
80 |
81 | }
--------------------------------------------------------------------------------
/cmap/src/java/com/pb/cmap/tourBased/CmapStopDCSoaDMU.java:
--------------------------------------------------------------------------------
1 | package com.pb.cmap.tourBased;
2 |
3 | import java.util.HashMap;
4 |
5 | import com.pb.cmap.tourBased.CmapModelStructure;
6 | import com.pb.models.ctrampIf.ModelStructure;
7 | import com.pb.models.ctrampIf.TazDataIf;
8 | import com.pb.models.ctrampIf.StopDCSoaDMU;
9 |
10 |
11 | public class CmapStopDCSoaDMU extends StopDCSoaDMU {
12 |
13 | CmapModelStructure modelStructure;
14 |
15 | TazDataIf tazDataManager;
16 |
17 | public CmapStopDCSoaDMU( TazDataIf tazDataManager, CmapModelStructure modelStructure ) {
18 | super ( tazDataManager, modelStructure );
19 | this.modelStructure = modelStructure;
20 | setupMethodIndexMap();
21 |
22 | this.tazDataManager = tazDataManager;
23 | }
24 |
25 | public double getOMazDMazDistanceAlt ( int alt ) {
26 | int destZone = altToZone[alt];
27 | return tazDataManager.getOMazDMazDistance(dmuIndex.getOriginZone(), destZone);
28 | }
29 |
30 | public double getAltDMazDistanceAlt ( int alt ) {
31 | int altZone = altToZone[alt];
32 | return tazDataManager.getOMazDMazDistance(altZone, dmuIndex.getDestZone());
33 | }
34 |
35 | public int getHasTransitAccessAlt ( int alt ) {
36 | int altZone = altToZone[alt];
37 | return tazDataManager.getHasTransitAccess(altZone);
38 | }
39 |
40 | public int getTourTodOut() {
41 | return modelStructure.getTod( tour.getTourDepartPeriod() );
42 | }
43 |
44 | public int getTourTodIn() {
45 | return modelStructure.getTod( tour.getTourArrivePeriod() );
46 | }
47 |
48 | private void setupMethodIndexMap() {
49 | methodIndexMap = new HashMap();
50 |
51 | methodIndexMap.put( "getInbound", 0 );
52 | methodIndexMap.put( "getKidsPresent", 1 );
53 | methodIndexMap.put( "getTourModeIsWalk", 2 );
54 | methodIndexMap.put( "getTourModeIsBike", 3 );
55 | methodIndexMap.put( "getTourModeIsWalkLocal", 4 );
56 | methodIndexMap.put( "getTourModeIsWalkPremium", 5 );
57 | methodIndexMap.put( "getTourTodOut", 6 );
58 | methodIndexMap.put( "getTourTodIn", 7 );
59 | methodIndexMap.put( "getLnStopDcSizeAlt", 8 );
60 |
61 |
62 | methodIndexMap.put( "getTourModeIsDriveTransit", 9 );
63 |
64 |
65 | methodIndexMap.put( "getOMazDMazDistanceAlt", 20 );
66 | methodIndexMap.put( "getAltDMazDistanceAlt", 21 );
67 |
68 | methodIndexMap.put( "getHasTransitAccessAlt", 22 );
69 |
70 | }
71 |
72 |
73 |
74 |
75 | public double getValueForIndex(int variableIndex, int arrayIndex) {
76 |
77 | switch ( variableIndex ){
78 | case 0: return getInbound();
79 | case 1: return getKidsPresent();
80 | case 2: return getTourModeIsWalk();
81 | case 3: return getTourModeIsBike();
82 | case 4: return getTourModeIsWalkLocal();
83 | case 5: return getTourModeIsWalkPremium();
84 | case 6: return getTourTodOut();
85 | case 7: return getTourTodIn();
86 | case 8: return getLnStopDcSizeAlt( arrayIndex );
87 |
88 | case 9: return getTourModeIsDriveTransit();
89 |
90 | case 20: return getOMazDMazDistanceAlt( arrayIndex );
91 | case 21: return getAltDMazDistanceAlt( arrayIndex );
92 |
93 | case 22: return getHasTransitAccessAlt( arrayIndex );
94 |
95 | default:
96 | logger.error("method number = "+variableIndex+" not found");
97 | throw new RuntimeException("method number = "+variableIndex+" not found");
98 |
99 | }
100 | }
101 |
102 | }
--------------------------------------------------------------------------------
/cmap/src/java/com/pb/cmap/tourBased/CmapStopLocationDMU.java:
--------------------------------------------------------------------------------
1 | package com.pb.cmap.tourBased;
2 |
3 | import java.util.HashMap;
4 |
5 | import com.pb.models.ctrampIf.ModelStructure;
6 | import com.pb.models.ctrampIf.StopLocationDMU;
7 | import com.pb.models.ctrampIf.TazDataIf;
8 |
9 |
10 | public class CmapStopLocationDMU extends StopLocationDMU {
11 |
12 | TazDataIf tazDataManager;
13 |
14 | public CmapStopLocationDMU( TazDataIf tazDataManager, ModelStructure modelStructure ) {
15 | super ( tazDataManager, modelStructure );
16 | setupMethodIndexMap();
17 |
18 | this.tazDataManager = tazDataManager;
19 | }
20 |
21 | public double getOMazDMazDistanceAlt ( int alt ) {
22 | int destZone = altToZone[alt];
23 | return tazDataManager.getOMazDMazDistance(dmuIndex.getOriginZone(), destZone);
24 | }
25 |
26 | public double getAltDMazDistanceAlt ( int alt ) {
27 | int altZone = altToZone[alt];
28 | return tazDataManager.getOMazDMazDistance(altZone, dmuIndex.getDestZone());
29 | }
30 |
31 | private void setupMethodIndexMap() {
32 | methodIndexMap = new HashMap();
33 |
34 | methodIndexMap.put( "getDcSoaCorrectionsAlt", 0 );
35 | methodIndexMap.put( "getTripModeChoiceLogsumOrigToStopAlt", 1 );
36 | methodIndexMap.put( "getTripModeChoiceLogsumStopAltToDest", 2 );
37 | methodIndexMap.put( "getStopDestAreaTypeAlt", 3 );
38 | methodIndexMap.put( "getStopPurposeIsWork", 4 );
39 | methodIndexMap.put( "getStopPurposeIsEscort", 5 );
40 | methodIndexMap.put( "getStopPurposeIsShopping", 6 );
41 | methodIndexMap.put( "getStopPurposeIsEatOut", 7 );
42 | methodIndexMap.put( "getStopPurposeIsOthMaint", 8 );
43 | methodIndexMap.put( "getStopPurposeIsSocial", 9 );
44 | methodIndexMap.put( "getStopPurposeIsOthDiscr", 10 );
45 | methodIndexMap.put( "getTourOriginZone", 11 );
46 | methodIndexMap.put( "getTourDestZone", 12 );
47 | methodIndexMap.put( "getTourMode", 13 );
48 | methodIndexMap.put( "getStopNumber", 14 );
49 | methodIndexMap.put( "getInboundStop", 15 );
50 | methodIndexMap.put( "getTourIsJoint", 16 );
51 | methodIndexMap.put( "getLnStopDcSizeAlt", 17 );
52 |
53 | methodIndexMap.put( "getOMazDMazDistanceAlt", 20 );
54 | methodIndexMap.put( "getAltDMazDistanceAlt", 21 );
55 | }
56 |
57 |
58 |
59 |
60 |
61 | public double getValueForIndex(int variableIndex, int arrayIndex) {
62 |
63 | switch ( variableIndex ){
64 | case 0: return getDcSoaCorrectionsAlt( arrayIndex );
65 | case 1: return getTripModeChoiceLogsumOrigToStopAlt( arrayIndex );
66 | case 2: return getTripModeChoiceLogsumStopAltToDest( arrayIndex );
67 | case 3: return getStopDestAreaTypeAlt( arrayIndex );
68 | case 4: return getStopPurposeIsWork();
69 | case 5: return getStopPurposeIsEscort();
70 | case 6: return getStopPurposeIsShopping();
71 | case 7: return getStopPurposeIsEatOut();
72 | case 8: return getStopPurposeIsOthMaint();
73 | case 9: return getStopPurposeIsSocial();
74 | case 10: return getStopPurposeIsOthDiscr();
75 | case 11: return getTourOriginZone();
76 | case 12: return getTourDestZone();
77 | case 13: return getTourMode();
78 | case 14: return getStopNumber();
79 | case 15: return getInboundStop();
80 | case 16: return getTourIsJoint();
81 | case 17: return getLnStopDcSizeAlt( arrayIndex );
82 |
83 | case 20: return getOMazDMazDistanceAlt( arrayIndex );
84 | case 21: return getAltDMazDistanceAlt( arrayIndex );
85 |
86 | default:
87 | logger.error("method number = "+variableIndex+" not found");
88 | throw new RuntimeException("method number = "+variableIndex+" not found");
89 |
90 | }
91 | }
92 |
93 | }
--------------------------------------------------------------------------------
/cmap/src/java/com/pb/cmap/tourBased/CmapTazDataHandler.java:
--------------------------------------------------------------------------------
1 | package com.pb.cmap.tourBased;
2 |
3 |
4 | import com.pb.models.ctrampIf.TazDataHandler;
5 | import com.pb.common.util.ResourceUtil;
6 |
7 | import java.util.ResourceBundle;
8 |
9 | import gnu.cajo.invoke.Remote;
10 | import gnu.cajo.utils.ItemServer;
11 | import com.pb.cmap.tvpb.MazTapTazData;
12 |
13 | public class CmapTazDataHandler extends TazDataHandler {
14 |
15 | private static final String ZONE_DATA_AREATYPE_FIELD_NAME = "areatype";
16 | private static final String ZONE_DATA_DISTRICT_FIELD_NAME = "district";
17 | private static final String ZONE_DATA_GRADESCHOOL_DISTRICT_FIELD_NAME = "gradeschool";
18 | private static final String ZONE_DATA_HIGHSCHOOL_DISTRICT__FIELD_NAME = "highschool";
19 |
20 | private static final int CBD_AREA_TYPE = 0;
21 | private static final int URBAN_AREA_TYPE = 1;
22 | private static final int SUBURBAN_AREA_TYPE = 2;
23 | private static final int RURAL_AREA_TYPE = 3;
24 | private static final int[][] AREA_TYPES = { {1}, {2, 3}, {4, 5, 6}, {7} };
25 |
26 | public static final String ZONAL_DATA_SERVER_NAME = CmapTazDataHandler.class.getCanonicalName();
27 | public static final String ZONAL_DATA_SERVER_ADDRESS = "192.168.1.212";
28 | public static final int ZONAL_DATA_SERVER_PORT = 1138;
29 |
30 | private MazTapTazData mttData;
31 |
32 |
33 | public CmapTazDataHandler( ResourceBundle rb, String projectDirectory, MazTapTazData mttData){
34 | super( rb, projectDirectory );
35 |
36 | tazDataAtFieldName = ZONE_DATA_AREATYPE_FIELD_NAME;
37 | tazDataDistFieldName = ZONE_DATA_DISTRICT_FIELD_NAME;
38 | tazDataGradeSchoolFieldName = ZONE_DATA_GRADESCHOOL_DISTRICT_FIELD_NAME;
39 | tazDataHighSchoolFieldName = ZONE_DATA_HIGHSCHOOL_DISTRICT__FIELD_NAME;
40 |
41 | cbdAreaTypesArrayIndex = CBD_AREA_TYPE;
42 | urbanAreaTypesArrayIndex = URBAN_AREA_TYPE;
43 | suburbanAreaTypesArrayIndex = SUBURBAN_AREA_TYPE;
44 | ruralAreaTypesArrayIndex = RURAL_AREA_TYPE;
45 | areaTypes = AREA_TYPES;
46 |
47 | setupTazDataManager();
48 |
49 | //set mttData
50 | this.mttData = mttData;
51 |
52 | }
53 |
54 | private static void usage( String[] args ) {
55 | System.out.println( String.format( "improper arguments." ) );
56 | if (args.length == 0 ) {
57 | System.out.println ( String.format( "no properties file specified." ) );
58 | System.out.println ( String.format( "a properties file base name (without .properties extension) must be specified as the first argument." ) );
59 | }
60 | else if (args.length >= 1 ) {
61 | System.out.println ( String.format( "improper properties file specified." ) );
62 | System.out.println ( String.format( "a properties file base name (without .properties extension) must be specified as the first argument." ) );
63 | }
64 | }
65 |
66 |
67 | public float getOMazDMazDistance(int omaz, int dmaz) {
68 | return(mttData.getOMazDMazDistance(omaz, dmaz));
69 | }
70 |
71 | public float[] getOMazDistances(int omaz) {
72 | return(mttData.getOMazDistances(omaz));
73 | }
74 |
75 | public float[] getAltDistances(int alt) {
76 | return(mttData.getDMazDistances(alt));
77 | }
78 |
79 | public int getHasTransitAccess(int maz) {
80 | return(mttData.getHasTransitAccess(maz));
81 | }
82 |
83 | public int[] getTazsForMazs() {
84 | return (mttData.getTazsForMazs());
85 | }
86 |
87 | public MazTapTazData getMttData() {
88 | return mttData;
89 | }
90 | }
91 |
--------------------------------------------------------------------------------
/cmap/src/java/com/pb/cmap/tvpb/TransitDriveAccessDMU.java:
--------------------------------------------------------------------------------
1 | package com.pb.cmap.tvpb;
2 |
3 | public class TransitDriveAccessDMU extends TransitWalkAccessDMU
4 | {
5 | public TransitDriveAccessDMU() {
6 | super();
7 | }
8 | }
9 |
--------------------------------------------------------------------------------
/cmap/src/java/com/pb/cmap/tvpb/TransitPath.java:
--------------------------------------------------------------------------------
1 | package com.pb.cmap.tvpb;
2 |
3 | import java.io.Serializable;
4 |
5 | public class TransitPath implements Comparable, Serializable{
6 |
7 | public int oMaz;
8 | public int dMaz;
9 | public int pTap;
10 | public int aTap;
11 | public int set;
12 | public int accEgr;
13 | public float accUtil;
14 | public float tapTapUtil;
15 | public float egrUtil;
16 |
17 | public TransitPath(int oMaz, int dMaz, int pTap, int aTap, int set, int accEgr, float accUtil, float tapTapUtil, float egrUtil) {
18 | this.oMaz = oMaz;
19 | this.dMaz = dMaz;
20 | this.pTap = pTap;
21 | this.aTap = aTap;
22 | this.set = set;
23 | this.accEgr = accEgr;
24 | this.accUtil = accUtil;
25 | this.tapTapUtil = tapTapUtil;
26 | this.egrUtil = egrUtil;
27 | }
28 |
29 | public float getTotalUtility() {
30 | return(accUtil + tapTapUtil + egrUtil);
31 | }
32 |
33 | @Override
34 | public int compareTo(TransitPath o) {
35 |
36 | //return compareTo value
37 | if ( getTotalUtility() < o.getTotalUtility() ) {
38 | return -1;
39 | } else if (getTotalUtility() == o.getTotalUtility()) {
40 | return 0;
41 | } else {
42 | return 1;
43 | }
44 | }
45 |
46 | }
--------------------------------------------------------------------------------
/config/killjava.cmd:
--------------------------------------------------------------------------------
1 | taskkill /im "java.exe" /F
--------------------------------------------------------------------------------
/config/log4j-driver.properties:
--------------------------------------------------------------------------------
1 | #------------------------------------------------------------------------------#
2 | # Java Parallel Processing Framework. #
3 | # Copyright (C) 2005-2008 JPPF Team. #
4 | # http://www.jppf.org #
5 | # #
6 | # Licensed under the Apache License, Version 2.0 (the "License"); #
7 | # you may not use this file except in compliance with the License. #
8 | # You may obtain a copy of the License at #
9 | # #
10 | # http://www.apache.org/licenses/LICENSE-2.0 #
11 | # #
12 | # Unless required by applicable law or agreed to in writing, software #
13 | # distributed under the License is distributed on an "AS IS" BASIS, #
14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
15 | # See the License for the specific language governing permissions and #
16 | # limitations under the License. #
17 | #------------------------------------------------------------------------------#
18 |
19 | ### direct log messages to stdout ###
20 | #log4j.appender.stdout=org.apache.log4j.ConsoleAppender
21 | #log4j.appender.stdout.Target=System.out
22 | #log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
23 | #log4j.appender.stdout.layout.ConversionPattern=%d{ABSOLUTE} %5p %c{1}:%L - %m%n
24 |
25 | ### direct messages to file jppf-driver.log ###
26 | log4j.appender.JPPF=org.apache.log4j.FileAppender
27 | log4j.appender.JPPF.File=./logFiles/jppf-driver.log
28 | log4j.appender.JPPF.Append=false
29 | log4j.appender.JPPF.layout=org.apache.log4j.PatternLayout
30 | #log4j.appender.JPPF.layout.ConversionPattern=%d{ABSOLUTE} [%-5p][%c.%M(%L)]: %m\n
31 | log4j.appender.JPPF.layout.ConversionPattern=%d [%-5p][%c.%M(%L)]: %m\n
32 |
33 | ### set log levels - for more verbose logging change 'info' to 'debug' ###
34 |
35 | log4j.rootLogger=INFO, JPPF
36 | #log4j.rootLogger=DEBUG, JPPF
37 |
--------------------------------------------------------------------------------
/config/log4j_hh.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
--------------------------------------------------------------------------------
/config/log4j_mtx.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
--------------------------------------------------------------------------------
/config/runJConsole.cmd:
--------------------------------------------------------------------------------
1 | start jconsole
--------------------------------------------------------------------------------
/config/runMain-SingleProcess.cmd:
--------------------------------------------------------------------------------
1 |
2 | rem ############ PARAMETERS ############
3 | set RUNTIME=Y:/{{{TEMPLATE}}}/cmap_abm
4 | set JAVA_PATH=C:/Program Files/Java/jdk1.7.0_13
5 | set HOST_IP=10.10.1.52
6 |
7 | rem ############ JPPF DRIVER ############
8 | cd..
9 | mkdir logFiles
10 |
11 | rem ############ HH MANAGER in memory ############
12 | start java -Xmx196000m -cp "%RUNTIME%;config;exec/*" -Dlog4j.configuration=log4j_hh.xml com.pb.cmap.tourBased.CmapHouseholdDataManager -hostname %HOST_IP%
13 |
14 | rem ############ MATRIX MANAGER #########
15 | start java -Xmx12000m -cp "%RUNTIME%;config;exec/*" -Dlog4j.configuration=log4j_mtx.xml -Djava.library.path="%RUNTIME%" com.pb.models.ctrampIf.MatrixDataServer -hostname %HOST_IP%
16 |
--------------------------------------------------------------------------------
/config/runMain.cmd:
--------------------------------------------------------------------------------
1 |
2 | rem ############ PARAMETERS ############
3 | set RUNTIME=Y:/{{{TEMPLATE}}}/cmap_abm
4 | set JAVA_PATH=C:/Program Files/Java/jdk1.7.0_13
5 | set HOST_IP=10.10.1.52
6 |
7 | rem ############ JPPF DRIVER ############
8 | cd..
9 | mkdir logFiles
10 | start java -server -Xmx16m -cp "%RUNTIME%/exec/jppf-5.0.4-lib/*;config;exec/*" -Dlog4j.configuration=log4j-driver.properties -Djppf.config=jppf-driver.properties org.jppf.server.DriverLauncher
11 |
12 | rem ############ HH MANAGER in memory ############
13 | start java -Xmx128000m -cp "%RUNTIME%;config;exec/*" -Dlog4j.configuration=log4j_hh.xml com.pb.cmap.tourBased.CmapHouseholdDataManager -hostname %HOST_IP%
14 |
15 | rem ############ MATRIX MANAGER #########
16 | start java -Xmx12000m -cp "%RUNTIME%;config;exec/*" -Dlog4j.configuration=log4j_mtx.xml -Djava.library.path="%RUNTIME%" com.pb.models.ctrampIf.MatrixDataServer -hostname %HOST_IP%
17 |
--------------------------------------------------------------------------------
/config/runNode0.cmd:
--------------------------------------------------------------------------------
1 |
2 | rem ############ PARAMETERS ############
3 | set RUNTIME=Y:/{{{TEMPLATE}}}/cmap_abm
4 | set JAVA_PATH=C:/Program Files/Java/jdk1.7.0_13
5 | rem ############ NODE 1 ############
6 | cd..
7 | java -server -Xmx128m -cp "%RUNTIME%;%RUNTIME%/exec/jxl.jar;%RUNTIME%/exec/jppf-5.0.4-lib/*;%RUNTIME%/exec/*;config" -Dlog4j.configuration=log4j-node0.xml -Djppf.config=jppf-node0.properties org.jppf.node.NodeLauncher
8 |
--------------------------------------------------------------------------------
/config/runNode1.cmd:
--------------------------------------------------------------------------------
1 |
2 | rem ############ PARAMETERS ############
3 | set RUNTIME=Y:/{{{TEMPLATE}}}/cmap_abm
4 | set JAVA_PATH=C:/Program Files/Java/jdk1.7.0_13
5 | rem ############ NODE 1 ############
6 | cd..
7 | java -server -Xmx128m -cp "%RUNTIME%;%RUNTIME%/exec/jxl.jar;%RUNTIME%/exec/jppf-5.0.4-lib/*;%RUNTIME%/exec/*;config" -Dlog4j.configuration=log4j-node1.xml -Djppf.config=jppf-node1.properties org.jppf.node.NodeLauncher
8 |
--------------------------------------------------------------------------------
/config/runNode2.cmd:
--------------------------------------------------------------------------------
1 |
2 | rem ############ PARAMETERS ############
3 | set RUNTIME=Y:/{{{TEMPLATE}}}/cmap_abm
4 | set JAVA_PATH=C:/Program Files/Java/jdk1.7.0_13
5 | rem ############ NODE 1 ############
6 | cd..
7 | java -server -Xmx128m -cp "%RUNTIME%;%RUNTIME%/exec/jxl.jar;%RUNTIME%/exec/jppf-5.0.4-lib/*;%RUNTIME%/exec/*;config" -Dlog4j.configuration=log4j-node2.xml -Djppf.config=jppf-node2.properties org.jppf.node.NodeLauncher
8 |
--------------------------------------------------------------------------------
/config/runNode3.cmd:
--------------------------------------------------------------------------------
1 |
2 | rem ############ PARAMETERS ############
3 | set RUNTIME=Y:/{{{TEMPLATE}}}/cmap_abm
4 | set JAVA_PATH=C:/Program Files/Java/jdk1.7.0_13
5 | rem ############ NODE 1 ############
6 | cd..
7 | java -server -Xmx128m -cp "%RUNTIME%;%RUNTIME%/exec/jxl.jar;%RUNTIME%/exec/jppf-5.0.4-lib/*;%RUNTIME%/exec/*;config" -Dlog4j.configuration=log4j-node3.xml -Djppf.config=jppf-node3.properties org.jppf.node.NodeLauncher
8 |
--------------------------------------------------------------------------------
/ctrampIf/.classpath:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
--------------------------------------------------------------------------------
/ctrampIf/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | ctrampIf
4 |
5 |
6 |
7 |
8 |
9 | org.eclipse.jdt.core.javabuilder
10 |
11 |
12 |
13 |
14 |
15 | org.eclipse.jdt.core.javanature
16 |
17 |
18 |
--------------------------------------------------------------------------------
/ctrampIf/build.jardesc:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/ctrampIf/src/java/com/pb/models/ctrampIf/CtrampDmuFactoryIf.java:
--------------------------------------------------------------------------------
1 | package com.pb.models.ctrampIf;
2 |
3 |
4 | /**
5 | * Created by IntelliJ IDEA.
6 | * User: Jim
7 | * Date: Jul 9, 2008
8 | * Time: 3:13:17 PM
9 | * To change this template use File | Settings | File Templates.
10 | */
11 | public interface CtrampDmuFactoryIf {
12 |
13 | public AutoOwnershipChoiceDMU getAutoOwnershipDMU();
14 |
15 | public FreeParkingChoiceDMU getFreeParkingChoiceDMU();
16 |
17 | public CoordinatedDailyActivityPatternDMU getCoordinatedDailyActivityPatternDMU();
18 |
19 | public DcSoaDMU getDcSoaDMU();
20 |
21 | public DestChoiceDMU getDestChoiceDMU();
22 |
23 | public TourModeChoiceDMU getModeChoiceDMU();
24 |
25 | public IndividualMandatoryTourFrequencyDMU getIndividualMandatoryTourFrequencyDMU();
26 |
27 | public TourDepartureTimeAndDurationDMU getTourDepartureTimeAndDurationDMU();
28 |
29 | public AtWorkSubtourFrequencyDMU getAtWorkSubtourFrequencyDMU();
30 |
31 | public JointTourFrequencyDMU getJointTourFrequencyDMU();
32 |
33 | public IndividualNonMandatoryTourFrequencyDMU getIndividualNonMandatoryTourFrequencyDMU();
34 |
35 | public StopFrequencyDMU getStopFrequencyDMU();
36 |
37 | public StopDCSoaDMU getStopDCSoaDMU();
38 |
39 | public StopLocationDMU getStopLocationDMU();
40 |
41 | public TripModeChoiceDMU getTripModeChoiceDMU();
42 |
43 | public ParkingChoiceDMU getParkingChoiceDMU();
44 |
45 | }
46 |
--------------------------------------------------------------------------------
/ctrampIf/src/java/com/pb/models/ctrampIf/DcSoaDMU.java:
--------------------------------------------------------------------------------
1 | package com.pb.models.ctrampIf;
2 |
3 | import java.io.Serializable;
4 | import java.util.HashMap;
5 |
6 | import org.apache.log4j.Logger;
7 |
8 | import com.pb.common.calculator.IndexValues;
9 | import com.pb.common.calculator.VariableTable;
10 |
11 | public class DcSoaDMU implements SoaDMU, Serializable, VariableTable {
12 |
13 | protected transient Logger logger = Logger.getLogger(DcSoaDMU.class);
14 |
15 | protected HashMap methodIndexMap;
16 |
17 |
18 | protected HouseholdIf hh;
19 | protected PersonIf person;
20 | protected IndexValues dmuIndex = null;
21 | protected String dmuLabel = "Origin Location";
22 |
23 | protected DestChoiceSize dcSizeObj;
24 |
25 | protected int[] altToZone;
26 | protected int[] altToSubZone;
27 |
28 |
29 | public DcSoaDMU( TazDataIf tazDataManager ){
30 | altToZone = tazDataManager.getAltToZoneArray();
31 | altToSubZone = tazDataManager.getAltToSubZoneArray();
32 |
33 | dmuIndex = new IndexValues();
34 | }
35 |
36 |
37 |
38 | public void setDmuIndexValues( int hhId, int zoneId, int origTaz, int destTaz ) {
39 | dmuIndex.setHHIndex( hhId );
40 | dmuIndex.setZoneIndex( zoneId );
41 | dmuIndex.setOriginZone( origTaz );
42 | dmuIndex.setDestZone( destTaz );
43 |
44 | dmuIndex.setDebug(false);
45 | dmuIndex.setDebugLabel ( "" );
46 | if ( hh.getDebugChoiceModels() ) {
47 | dmuIndex.setDebug(true);
48 | dmuIndex.setDebugLabel ( "Debug DC SOA UEC" );
49 | }
50 |
51 | }
52 |
53 | public void setHouseholdObject ( HouseholdIf hhObject ) {
54 | hh = hhObject;
55 | }
56 |
57 | public void setPersonObject ( PersonIf personObject ) {
58 | person = personObject;
59 | }
60 |
61 | public void setDestChoiceSizeObject ( DestChoiceSize dcSizeObj ) {
62 | this.dcSizeObj = dcSizeObj;
63 | }
64 |
65 | public IndexValues getDmuIndexValues() {
66 | return dmuIndex;
67 | }
68 |
69 | public HouseholdIf getHouseholdObject() {
70 | return hh;
71 | }
72 |
73 | protected double getLnDcSizeForPurpSegAlt( int alt, String purposeString ){
74 |
75 | int zone = altToZone[alt];
76 | int subzone = altToSubZone[alt];
77 |
78 | int purposeIndex = dcSizeObj.getDcSizeArrayPurposeIndex(purposeString);
79 | double size = dcSizeObj.getDcSize(purposeIndex, zone, subzone);
80 |
81 | double logSize = 0.0;
82 | if ( size > 0 )
83 | logSize = Math.log(size + 1);
84 |
85 | return logSize;
86 |
87 | }
88 |
89 | public String getDmuLabel() {
90 | return dmuLabel;
91 | }
92 |
93 |
94 |
95 | public int getIndexValue(String variableName) {
96 | return methodIndexMap.get(variableName);
97 | }
98 |
99 |
100 |
101 |
102 | public int getAssignmentIndexValue(String variableName) {
103 | throw new UnsupportedOperationException();
104 | }
105 |
106 | public double getValueForIndex(int variableIndex) {
107 | throw new UnsupportedOperationException();
108 | }
109 |
110 | public double getValueForIndex(int variableIndex, int arrayIndex) {
111 | throw new UnsupportedOperationException();
112 | }
113 |
114 | public void setValue(String variableName, double variableValue) {
115 | throw new UnsupportedOperationException();
116 | }
117 |
118 | public void setValue(int variableIndex, double variableValue) {
119 | throw new UnsupportedOperationException();
120 | }
121 |
122 | }
123 |
124 |
125 |
--------------------------------------------------------------------------------
/ctrampIf/src/java/com/pb/models/ctrampIf/Definitions.java:
--------------------------------------------------------------------------------
1 | package com.pb.models.ctrampIf;
2 |
3 | /**
4 | * This class holds definitions that are inherant in CT-RAMP based models including:
5 | * person types
6 | * tour category types
7 | * purposes
8 | * activity types
9 | *
10 | * @author Jim
11 | *
12 | */
13 | public class Definitions {
14 |
15 | // Coordinated daily activity pattern type definitions
16 | public static final String MANDATORY_PATTERN = "M";
17 | public static final String NONMANDATORY_PATTERN = "N";
18 | public static final String HOME_PATTERN = "H";
19 |
20 | }
21 |
--------------------------------------------------------------------------------
/ctrampIf/src/java/com/pb/models/ctrampIf/FreeParkingChoiceDMU.java:
--------------------------------------------------------------------------------
1 | package com.pb.models.ctrampIf;
2 |
3 | import java.io.Serializable;
4 | import java.util.HashMap;
5 |
6 | import org.apache.log4j.Logger;
7 |
8 | import com.pb.common.calculator.IndexValues;
9 | import com.pb.common.calculator.VariableTable;
10 |
11 | /**
12 | * @author crf
13 | * Started: Apr 14, 2009 11:09:58 AM
14 | */
15 | public class FreeParkingChoiceDMU implements Serializable, VariableTable {
16 |
17 | protected transient Logger logger = Logger.getLogger(FreeParkingChoiceDMU.class);
18 |
19 | protected HashMap methodIndexMap;
20 |
21 | protected HouseholdIf hh;
22 | protected PersonIf person;
23 | private IndexValues dmuIndex;
24 |
25 |
26 | public FreeParkingChoiceDMU() {
27 | dmuIndex = new IndexValues();
28 | }
29 |
30 | /** need to set hh and home taz before using**/
31 | public void setPersonObject (PersonIf personObject) {
32 | person = personObject;
33 | hh = personObject.getHouseholdObject();
34 | }
35 |
36 | public void setDmuIndexValues( int hhId, int zoneId, int origTaz, int destTaz ) {
37 | dmuIndex.setHHIndex( hhId );
38 | dmuIndex.setZoneIndex( zoneId );
39 | dmuIndex.setOriginZone( origTaz );
40 | dmuIndex.setDestZone( destTaz );
41 |
42 | dmuIndex.setDebug(false);
43 | dmuIndex.setDebugLabel ( "" );
44 | if ( hh.getDebugChoiceModels() ) {
45 | dmuIndex.setDebug(true);
46 | dmuIndex.setDebugLabel ( "Debug Free Parking UEC" );
47 | }
48 | }
49 |
50 | public IndexValues getDmuIndexValues() {
51 | return dmuIndex;
52 | }
53 |
54 | /*dmu @ functions*/
55 |
56 | public int getAutoOwnership() {
57 | return hh.getAutoOwnershipModelResult();
58 | }
59 |
60 | public int getFtwkPersons() {
61 | return hh.getNumFtWorkers();
62 | }
63 |
64 | public int getPtwkPersons() {
65 | return hh.getNumPtWorkers();
66 | }
67 |
68 | public int getSize() {
69 | return hh.getSize();
70 | }
71 |
72 |
73 |
74 | public int getIndexValue(String variableName) {
75 | return methodIndexMap.get(variableName);
76 | }
77 |
78 | public int getWorkLocation() {
79 | return person.getUsualWorkLocation();
80 | }
81 |
82 |
83 | public int getAssignmentIndexValue(String variableName) {
84 | throw new UnsupportedOperationException();
85 | }
86 |
87 | public double getValueForIndex(int variableIndex) {
88 | throw new UnsupportedOperationException();
89 | }
90 |
91 | public double getValueForIndex(int variableIndex, int arrayIndex) {
92 | throw new UnsupportedOperationException();
93 | }
94 |
95 | public void setValue(String variableName, double variableValue) {
96 | throw new UnsupportedOperationException();
97 | }
98 |
99 | public void setValue(int variableIndex, double variableValue) {
100 | throw new UnsupportedOperationException();
101 | }
102 |
103 | }
104 |
--------------------------------------------------------------------------------
/ctrampIf/src/java/com/pb/models/ctrampIf/MatrixDataServerRmi.java:
--------------------------------------------------------------------------------
1 | package com.pb.models.ctrampIf;
2 |
3 | import java.io.Serializable;
4 |
5 | import com.pb.common.calculator.DataEntry;
6 | import com.pb.common.calculator.MatrixDataServerIf;
7 | import com.pb.common.matrix.Matrix;
8 | import com.pb.common.matrix.MatrixType;
9 | import com.pb.models.ctrampIf.UtilRmi;
10 |
11 | //import org.apache.log4j.Logger;
12 |
13 |
14 | /**
15 | * @author Jim Hicks
16 | *
17 | * Class for managing matrix data in a remote process and accessed by UECs using RMI.
18 | */
19 | public class MatrixDataServerRmi implements MatrixDataServerIf, Serializable {
20 |
21 | //protected static Logger logger = Logger.getLogger(MatrixDataServerRmi.class);
22 |
23 | UtilRmi remote;
24 | String connectString;
25 |
26 |
27 | public MatrixDataServerRmi( String hostname, int port, String className ) {
28 |
29 | connectString = String.format("//%s:%d/%s", hostname, port, className );
30 | remote = new UtilRmi(connectString);
31 |
32 | }
33 |
34 | public void writeMatrixFile(String fileName, Matrix[] m){
35 | Object[] objArray = { fileName, m };
36 | remote.method("writeMatrixFile", objArray);
37 | }
38 |
39 | public String testRemote() {
40 | Object[] objArray = {};
41 | return (String)remote.method( "testRemote", objArray);
42 | }
43 |
44 | public String testRemote( String remoteObjectName )
45 | {
46 | Object[] objArray = { remoteObjectName };
47 | return (String) remote.method("testRemote", objArray);
48 | }
49 |
50 | public void clear() {
51 | Object[] objArray = {};
52 | remote.method( "clear", objArray);
53 | }
54 |
55 | public Matrix getMatrix( DataEntry dataEntry ) {
56 | Object[] objArray = { dataEntry };
57 | return (Matrix)remote.method( "getMatrix", objArray);
58 | }
59 |
60 | public void start32BitMatrixIoServer( MatrixType mType ) {
61 | Object[] objArray = { mType };
62 | remote.method( "start32BitMatrixIoServer", objArray);
63 | }
64 |
65 | public void stop32BitMatrixIoServer() {
66 | Object[] objArray = {};
67 | remote.method( "stop32BitMatrixIoServer", objArray);
68 | }
69 |
70 | }
--------------------------------------------------------------------------------
/ctrampIf/src/java/com/pb/models/ctrampIf/MyLogit.java:
--------------------------------------------------------------------------------
1 | package com.pb.models.ctrampIf;
2 |
3 | import com.pb.common.math.MathUtil;
4 | import com.pb.common.model.Alternative;
5 | import com.pb.common.model.LogitModel;
6 | import com.pb.common.model.ModelException;
7 |
8 | public class MyLogit
9 | extends LogitModel
10 | {
11 |
12 | private static final int MAX_EXP_ARGUMENT = 400;
13 |
14 | private double[] utilities;
15 | private double[] util;
16 | private double[] constant;
17 | private String[] altName;
18 |
19 | public MyLogit(String n, int numberOfAlternatives)
20 | {
21 | super(n, numberOfAlternatives);
22 |
23 | utilities = new double[numberOfAlternatives];
24 | util = new double[numberOfAlternatives];
25 | constant = new double[numberOfAlternatives];
26 | altName = new String[numberOfAlternatives];
27 | }
28 |
29 | /**
30 | * Overrides the base class getUtility() method to call a method to return the
31 | * array of exponentiated utilities, having passed to it an array of utilities.
32 | *
33 | * @return The composite utility (logsum value) of all the alternatives.
34 | */
35 | public double getUtility() throws ModelException
36 | {
37 |
38 | double sum = 0;
39 | double base = 0;
40 |
41 | // get the array of utility values to be exponentiated from the alternatives
42 | // objects.
43 | int i = 0;
44 | for (int alt = 0; alt < alternatives.size(); ++alt)
45 | {
46 | Alternative thisAlt = (Alternative) alternatives.get(alt);
47 | if (thisAlt.isAvailable())
48 | {
49 |
50 | // assign attributes of the alternatives
51 | util[i] = thisAlt.getUtility();
52 | constant[i] = thisAlt.getConstant();
53 | altName[i] = thisAlt.getName();
54 |
55 | // if alternative has a very large negative utility, it isn't
56 | // available
57 | if (util[i] + constant[i] < -MAX_EXP_ARGUMENT)
58 | {
59 | utilities[i] = -MAX_EXP_ARGUMENT;
60 | } else
61 | {
62 | utilities[i] = dispersionParameter * (util[i] + constant[i]);
63 | setAvailability(true);
64 | }
65 |
66 | i++;
67 | } else
68 | {
69 | utilities[i++] = -MAX_EXP_ARGUMENT;
70 | }
71 | }
72 |
73 | // exponentiate the utilities array and save result in expUtilities.
74 | MathUtil.expArray( utilities, expUtilities );
75 |
76 | // sum the exponentiated utilities
77 | for (i = 0; i < expUtilities.length; i++)
78 | sum += expUtilities[i];
79 |
80 | if (isAvailable())
81 | {
82 | base = (1 / dispersionParameter) * MathUtil.log(sum);
83 |
84 | if (Double.isNaN(base)) {
85 | throw new ModelException(ModelException.INVALID_UTILITY);
86 | }
87 |
88 | return base;
89 | }
90 |
91 | // if nothing avaiable, return a bad utilty
92 | return -999;
93 | }
94 |
95 | }
96 |
--------------------------------------------------------------------------------
/ctrampIf/src/java/com/pb/models/ctrampIf/SoaDMU.java:
--------------------------------------------------------------------------------
1 | package com.pb.models.ctrampIf;
2 |
3 | /**
4 | * @author crf
5 | * Started: Nov 15, 2008 3:25:49 PM
6 | */
7 | public interface SoaDMU {
8 | HouseholdIf getHouseholdObject();
9 | }
10 |
--------------------------------------------------------------------------------
/ctrampIf/src/java/com/pb/models/ctrampIf/StopIf.java:
--------------------------------------------------------------------------------
1 | package com.pb.models.ctrampIf;
2 |
3 | import org.apache.log4j.Logger;
4 |
5 | public interface StopIf
6 | {
7 |
8 | public abstract void setOrig(int orig);
9 |
10 | public abstract void setDest(int dest);
11 |
12 | public abstract void setPark(int park);
13 |
14 | public abstract void setMode(int mode);
15 |
16 | public abstract void setStopPeriod(int period);
17 |
18 | public abstract int getOrig();
19 |
20 | public abstract int getDest();
21 |
22 | public abstract int getPark();
23 |
24 | public abstract int getOrigWalkSegment();
25 |
26 | public abstract void setOrigWalkSegment(int origWalkSegment);
27 |
28 | public abstract int getDestWalkSegment();
29 |
30 | public abstract void setDestWalkSegment(int destWalkSegment);
31 |
32 | public abstract String getOrigPurpose();
33 |
34 | public abstract String getDestPurpose();
35 |
36 | public abstract int getDestPurposeIndex();
37 |
38 | public abstract int getMode();
39 |
40 | public abstract int getTourDepartPeriod();
41 |
42 | public abstract int getStopPeriod();
43 |
44 | public abstract TourIf getTour();
45 |
46 | public abstract boolean isInboundStop();
47 |
48 | public abstract int getStopId();
49 |
50 | public abstract void logStopObject( Logger logger, int numChars );
51 |
52 | public abstract void setBTap(int tap);
53 |
54 | public abstract void setATap(int tap);
55 |
56 | public abstract int getBTap();
57 |
58 | public abstract int getATap();
59 |
60 | }
--------------------------------------------------------------------------------
/ctrampIf/src/java/com/pb/models/ctrampIf/TimeDMU.java:
--------------------------------------------------------------------------------
1 | package com.pb.models.ctrampIf;
2 |
3 | import java.io.Serializable;
4 |
5 | import com.pb.common.calculator.IndexValues;
6 | import com.pb.common.calculator.VariableTable;
7 |
8 |
9 | public class TimeDMU implements Serializable, VariableTable {
10 |
11 | IndexValues dmuIndex = null;
12 |
13 | // switches used in the Individual Mandatory Tour Frequency Model
14 | int imtfWorkSwitch, imtfSchoolSwitch;
15 |
16 | public TimeDMU () {
17 | dmuIndex = new IndexValues();
18 | }
19 |
20 |
21 | public void setDmuIndexValues( int hhId, int zoneId, int origTaz, int destTaz, boolean debugUec ) {
22 | dmuIndex.setHHIndex( hhId );
23 | dmuIndex.setZoneIndex( zoneId );
24 | dmuIndex.setOriginZone( origTaz );
25 | dmuIndex.setDestZone( destTaz );
26 |
27 | dmuIndex.setDebug(false);
28 | dmuIndex.setDebugLabel ( "" );
29 | if ( debugUec ) {
30 | dmuIndex.setDebug(true);
31 | // dmuIndex.setDebugLabel ( "Debug IMTF Time UEC" );
32 | dmuIndex.setDebugLabel ( "Debug AO Time UEC" );
33 | }
34 |
35 | }
36 |
37 | public IndexValues getDmuIndexValues() {
38 | return dmuIndex;
39 | }
40 |
41 |
42 |
43 |
44 | // /**
45 | // * Used in the Individual Mandatory Tour Frequency model; set to true
46 | // * when the model is applied for a worker (to get round trip time to work,
47 | // * which uses peak skims)
48 | // * @param workOn
49 | // */
50 | // public void setImtfWorkSwitch(int workOn){
51 | // imtfWorkSwitch = workOn;
52 | // }
53 | //
54 | // /**
55 | // * Used in the Individual Mandatory Tour Frequency model; set to true
56 | // * when the model is applied for a student (to get round trip time to school,
57 | // * which uses peak skims in the o/d direction and off-peak skims in the d/o
58 | // * direction)
59 | // * @param schoolOn
60 | // */
61 | // public void setImtfSchoolSwitch(int schoolOn){
62 | // imtfSchoolSwitch = schoolOn;
63 | // }
64 | //
65 | // public int getImtfWorkSwitch(){
66 | // return this.imtfWorkSwitch;
67 | // }
68 | //
69 | // public int getImtfSchoolSwitch(){
70 | // return this.imtfSchoolSwitch;
71 | // }
72 |
73 |
74 |
75 |
76 | public int getAssignmentIndexValue(String variableName) {
77 | throw new UnsupportedOperationException();
78 | }
79 |
80 | public int getIndexValue(String variableName) {
81 | throw new UnsupportedOperationException();
82 | }
83 |
84 | public double getValueForIndex(int variableIndex) {
85 | throw new UnsupportedOperationException();
86 | }
87 |
88 | public double getValueForIndex(int variableIndex, int arrayIndex) {
89 | throw new UnsupportedOperationException();
90 | }
91 |
92 | public void setValue(String variableName, double variableValue) {
93 | throw new UnsupportedOperationException();
94 | }
95 |
96 | public void setValue(int variableIndex, double variableValue) {
97 | throw new UnsupportedOperationException();
98 | }
99 |
100 | }
101 |
102 |
103 |
--------------------------------------------------------------------------------
/ctrampIf/src/java/com/pb/models/ctrampIf/TripMatrixWriterIf.java:
--------------------------------------------------------------------------------
1 | package com.pb.models.ctrampIf;
2 |
3 | /**
4 | * @author bts
5 | */
6 | public interface TripMatrixWriterIf {
7 |
8 | public abstract void writeMatrices();
9 |
10 | }
11 |
--------------------------------------------------------------------------------
/ctrampIf/src/java/com/pb/models/ctrampIf/Util.java:
--------------------------------------------------------------------------------
1 | package com.pb.models.ctrampIf;
2 |
3 | import java.io.Serializable;
4 | import java.util.HashMap;
5 | import java.util.HashSet;
6 | import java.util.StringTokenizer;
7 | import org.apache.log4j.Logger;
8 |
9 | public class Util
10 | implements Serializable
11 | {
12 |
13 | private static Logger logger = Logger.getLogger(Util.class);
14 |
15 | public static boolean getBooleanValueFromPropertyMap(HashMap rbMap, String key)
16 | {
17 | boolean returnValue;
18 | String value = rbMap.get(key);
19 | if (value.equalsIgnoreCase("true") || value.equalsIgnoreCase("false"))
20 | {
21 | returnValue = Boolean.parseBoolean(value);
22 | } else
23 | {
24 | logger.error("property file key: " + key + " = " + value
25 | + " should be either 'true' or 'false'.");
26 | throw new RuntimeException();
27 | }
28 |
29 | return returnValue;
30 | }
31 |
32 | public static String getStringValueFromPropertyMap(HashMap rbMap, String key)
33 | {
34 | String returnValue = rbMap.get(key);
35 | if (returnValue == null) returnValue = "";
36 |
37 | return returnValue;
38 | }
39 |
40 | public static int getIntegerValueFromPropertyMap(HashMap rbMap, String key)
41 | {
42 | String value = rbMap.get(key);
43 | if (value != null)
44 | {
45 | return Integer.parseInt(value);
46 | } else
47 | {
48 | logger.error("property file key: " + key
49 | + " missing. No integer value can be determined.");
50 | throw new RuntimeException();
51 | }
52 | }
53 |
54 | public static int[] getIntegerArrayFromPropertyMap(HashMap rbMap, String key)
55 | {
56 |
57 | int[] returnArray;
58 | String valueList = rbMap.get(key);
59 | if (valueList != null)
60 | {
61 |
62 | HashSet valueSet = new HashSet();
63 |
64 | if (valueSet != null)
65 | {
66 | StringTokenizer valueTokenizer = new StringTokenizer(valueList, ",");
67 | while(valueTokenizer.hasMoreTokens())
68 | {
69 | String listValue = valueTokenizer.nextToken();
70 | int intValue = Integer.parseInt(listValue.trim());
71 | valueSet.add(intValue);
72 | }
73 | }
74 |
75 | returnArray = new int[valueSet.size()];
76 | int i = 0;
77 | for (int v : valueSet)
78 | returnArray[i++] = v;
79 |
80 | } else
81 | {
82 | logger.error("property file key: " + key
83 | + " missing. No integer value can be determined.");
84 | throw new RuntimeException();
85 | }
86 |
87 | return returnArray;
88 |
89 | }
90 |
91 | }
92 |
--------------------------------------------------------------------------------
/ctrampIf/src/java/com/pb/models/ctrampIf/sqlite/ConnectionHelper.java:
--------------------------------------------------------------------------------
1 | package com.pb.models.ctrampIf.sqlite;
2 |
3 | import java.sql.Connection;
4 | import java.sql.DriverManager;
5 | import java.sql.SQLException;
6 |
7 |
8 | public class ConnectionHelper {
9 |
10 | private String url;
11 | private static ConnectionHelper instance;
12 |
13 | private ConnectionHelper( String fileName )
14 | {
15 | try {
16 | Class.forName( "org.sqlite.JDBC" );
17 | //url = "jdbc:sqlite:/c:/jim/projects/baylanta/data/status.db";
18 | url = "jdbc:sqlite:/" + fileName;
19 | } catch (Exception e) {
20 | e.printStackTrace();
21 | }
22 | }
23 |
24 | public static Connection getConnection( String fileName ) throws SQLException {
25 | if (instance == null) {
26 | instance = new ConnectionHelper( fileName );
27 | }
28 | try {
29 | return DriverManager.getConnection(instance.url);
30 | } catch (SQLException e) {
31 | throw e;
32 | }
33 | }
34 |
35 | public static void close(Connection connection)
36 | {
37 | try {
38 | if (connection != null) {
39 | connection.close();
40 | }
41 | } catch (SQLException e) {
42 | e.printStackTrace();
43 | }
44 | }
45 |
46 | }
47 |
--------------------------------------------------------------------------------
/ctrampIf/src/java/com/pb/models/ctrampIf/sqlite/DAOException.java:
--------------------------------------------------------------------------------
1 | package com.pb.models.ctrampIf.sqlite;
2 |
3 | public class DAOException extends RuntimeException
4 | {
5 | static final long serialVersionUID = -1881205326938716446L;
6 |
7 | public DAOException(String message)
8 | {
9 | super(message);
10 | }
11 |
12 | public DAOException(Throwable cause)
13 | {
14 | super(cause);
15 | }
16 |
17 | public DAOException(String message, Throwable cause)
18 | {
19 | super(message, cause);
20 | }
21 |
22 | }
23 |
--------------------------------------------------------------------------------
/ctrampIf/src/java/com/pb/models/ctrampIf/sqlite/SqliteService.java:
--------------------------------------------------------------------------------
1 | package com.pb.models.ctrampIf.sqlite;
2 |
3 | import java.sql.Connection;
4 | import java.sql.ResultSet;
5 | import java.sql.SQLException;
6 | import java.sql.Statement;
7 |
8 |
9 | public class SqliteService {
10 |
11 | Connection c = null;
12 | String databaseFile;
13 |
14 | public void connect( String fileName, String tableName ) throws DAOException {
15 |
16 | try {
17 | c = ConnectionHelper.getConnection( fileName );
18 | Statement s = c.createStatement();
19 |
20 | s.execute("CREATE TABLE IF NOT EXISTS " + tableName + " (" +
21 | " id INTEGER, " +
22 | " numProcessed INTEGER, " +
23 | " totalToProcess INTEGER, " +
24 | " startUp INTEGER, " +
25 | " runTime INTEGER, " +
26 | " shutDown INTEGER " +
27 | ")" );
28 |
29 | s.execute("DELETE FROM " + tableName);
30 |
31 |
32 | } catch (SQLException e) {
33 | e.printStackTrace();
34 | throw new DAOException(e);
35 | }
36 |
37 | }
38 |
39 |
40 | public void listRecords( String tableName ) throws DAOException {
41 |
42 | try {
43 |
44 | Statement s = c.createStatement();
45 |
46 | ResultSet rs = s.executeQuery("SELECT id, numProcessed, totalToProcess, startUp, runTime, shutDown FROM " + tableName + " ORDER BY id");
47 | while (rs.next()) {
48 | System.out.println( rs.getInt("id") + ", " + rs.getInt("numProcessed") + ", " + rs.getInt("totalToProcess") + ", " + rs.getInt("startUp") + ", " + rs.getInt("runTime") + ", " + rs.getInt("shutDown") );
49 | }
50 |
51 | } catch (SQLException e) {
52 | e.printStackTrace();
53 | throw new DAOException(e);
54 | }
55 |
56 | }
57 |
58 |
59 | public void insertRecord( String tableName, int id, int numProcessed, int totalToProcess, int startUp, int runTime, int shutDown) throws DAOException {
60 |
61 | try {
62 |
63 | Statement s = c.createStatement();
64 | String query = String.format("INSERT INTO %s (id, numProcessed, totalToProcess, startUp, runTime, shutDown) VALUES (%d, %d, %d, %d, %d, %d)", tableName, id, numProcessed, totalToProcess, startUp, runTime, shutDown);
65 | s.execute( query );
66 |
67 | } catch (SQLException e) {
68 | e.printStackTrace();
69 | throw new DAOException(e);
70 | }
71 |
72 | }
73 |
74 |
75 | public void updateRecord( String tableName, int id, int numProcessed, int totalToProcess, int startUp, int runTime, int shutDown) throws DAOException {
76 |
77 | try {
78 |
79 | Statement s = c.createStatement();
80 | String query = String.format("UPDATE %s SET numProcessed=%d, totalToProcess=%d, startUp=%d, runTime=%d, shutDown=%d WHERE id=%d", tableName, numProcessed, totalToProcess, startUp, runTime, shutDown, id);
81 | s.execute( query );
82 |
83 | } catch (SQLException e) {
84 | e.printStackTrace();
85 | throw new DAOException(e);
86 | }
87 |
88 | }
89 |
90 |
91 | public static void main(String[] args) {
92 |
93 | SqliteService s = new SqliteService();
94 | s.connect( "c:/jim/status.db", "uwsl" );
95 |
96 | s.insertRecord( "uwsl", 0, 27, 1250, 99, 102, 10 );
97 | s.insertRecord( "uwsl", 2, 29, 1250, 58, 101, 9 );
98 | s.insertRecord( "uwsl", 1, 32, 1250, 77, 99, 8 );
99 | s.listRecords( "uwsl" );
100 |
101 | }
102 |
103 | }
104 |
--------------------------------------------------------------------------------
/exec/common-base.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CMAP-REPOS/cmap_abm/e0b6bd57e34e5bd3d95ecb159feb1f4745baf0c6/exec/common-base.jar
--------------------------------------------------------------------------------
/exec/jppf-5.0.4-lib/collections-generic-4.01.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CMAP-REPOS/cmap_abm/e0b6bd57e34e5bd3d95ecb159feb1f4745baf0c6/exec/jppf-5.0.4-lib/collections-generic-4.01.jar
--------------------------------------------------------------------------------
/exec/jppf-5.0.4-lib/colt-1.2.0.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CMAP-REPOS/cmap_abm/e0b6bd57e34e5bd3d95ecb159feb1f4745baf0c6/exec/jppf-5.0.4-lib/colt-1.2.0.jar
--------------------------------------------------------------------------------
/exec/jppf-5.0.4-lib/commons-io-2.4.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CMAP-REPOS/cmap_abm/e0b6bd57e34e5bd3d95ecb159feb1f4745baf0c6/exec/jppf-5.0.4-lib/commons-io-2.4.jar
--------------------------------------------------------------------------------
/exec/jppf-5.0.4-lib/concurrent-1.3.4.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CMAP-REPOS/cmap_abm/e0b6bd57e34e5bd3d95ecb159feb1f4745baf0c6/exec/jppf-5.0.4-lib/concurrent-1.3.4.jar
--------------------------------------------------------------------------------
/exec/jppf-5.0.4-lib/groovy-all-1.6.5.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CMAP-REPOS/cmap_abm/e0b6bd57e34e5bd3d95ecb159feb1f4745baf0c6/exec/jppf-5.0.4-lib/groovy-all-1.6.5.jar
--------------------------------------------------------------------------------
/exec/jppf-5.0.4-lib/jcommon-1.0.15.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CMAP-REPOS/cmap_abm/e0b6bd57e34e5bd3d95ecb159feb1f4745baf0c6/exec/jppf-5.0.4-lib/jcommon-1.0.15.jar
--------------------------------------------------------------------------------
/exec/jppf-5.0.4-lib/jfreechart-1.0.12.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CMAP-REPOS/cmap_abm/e0b6bd57e34e5bd3d95ecb159feb1f4745baf0c6/exec/jppf-5.0.4-lib/jfreechart-1.0.12.jar
--------------------------------------------------------------------------------
/exec/jppf-5.0.4-lib/jna-4.1.0.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CMAP-REPOS/cmap_abm/e0b6bd57e34e5bd3d95ecb159feb1f4745baf0c6/exec/jppf-5.0.4-lib/jna-4.1.0.jar
--------------------------------------------------------------------------------
/exec/jppf-5.0.4-lib/jna-platform-4.1.0.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CMAP-REPOS/cmap_abm/e0b6bd57e34e5bd3d95ecb159feb1f4745baf0c6/exec/jppf-5.0.4-lib/jna-platform-4.1.0.jar
--------------------------------------------------------------------------------
/exec/jppf-5.0.4-lib/jppf-admin.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CMAP-REPOS/cmap_abm/e0b6bd57e34e5bd3d95ecb159feb1f4745baf0c6/exec/jppf-5.0.4-lib/jppf-admin.jar
--------------------------------------------------------------------------------
/exec/jppf-5.0.4-lib/jppf-client.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CMAP-REPOS/cmap_abm/e0b6bd57e34e5bd3d95ecb159feb1f4745baf0c6/exec/jppf-5.0.4-lib/jppf-client.jar
--------------------------------------------------------------------------------
/exec/jppf-5.0.4-lib/jppf-common.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CMAP-REPOS/cmap_abm/e0b6bd57e34e5bd3d95ecb159feb1f4745baf0c6/exec/jppf-5.0.4-lib/jppf-common.jar
--------------------------------------------------------------------------------
/exec/jppf-5.0.4-lib/jppf-jmxremote_optional-1.1.1.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CMAP-REPOS/cmap_abm/e0b6bd57e34e5bd3d95ecb159feb1f4745baf0c6/exec/jppf-5.0.4-lib/jppf-jmxremote_optional-1.1.1.jar
--------------------------------------------------------------------------------
/exec/jppf-5.0.4-lib/jppf-node.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CMAP-REPOS/cmap_abm/e0b6bd57e34e5bd3d95ecb159feb1f4745baf0c6/exec/jppf-5.0.4-lib/jppf-node.jar
--------------------------------------------------------------------------------
/exec/jppf-5.0.4-lib/jppf-server.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CMAP-REPOS/cmap_abm/e0b6bd57e34e5bd3d95ecb159feb1f4745baf0c6/exec/jppf-5.0.4-lib/jppf-server.jar
--------------------------------------------------------------------------------
/exec/jppf-5.0.4-lib/jung-algorithms-2.0.1.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CMAP-REPOS/cmap_abm/e0b6bd57e34e5bd3d95ecb159feb1f4745baf0c6/exec/jppf-5.0.4-lib/jung-algorithms-2.0.1.jar
--------------------------------------------------------------------------------
/exec/jppf-5.0.4-lib/jung-api-2.0.1.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CMAP-REPOS/cmap_abm/e0b6bd57e34e5bd3d95ecb159feb1f4745baf0c6/exec/jppf-5.0.4-lib/jung-api-2.0.1.jar
--------------------------------------------------------------------------------
/exec/jppf-5.0.4-lib/jung-graph-impl-2.0.1.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CMAP-REPOS/cmap_abm/e0b6bd57e34e5bd3d95ecb159feb1f4745baf0c6/exec/jppf-5.0.4-lib/jung-graph-impl-2.0.1.jar
--------------------------------------------------------------------------------
/exec/jppf-5.0.4-lib/jung-visualization-2.0.1.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CMAP-REPOS/cmap_abm/e0b6bd57e34e5bd3d95ecb159feb1f4745baf0c6/exec/jppf-5.0.4-lib/jung-visualization-2.0.1.jar
--------------------------------------------------------------------------------
/exec/jppf-5.0.4-lib/log4j-1.2.15.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CMAP-REPOS/cmap_abm/e0b6bd57e34e5bd3d95ecb159feb1f4745baf0c6/exec/jppf-5.0.4-lib/log4j-1.2.15.jar
--------------------------------------------------------------------------------
/exec/jppf-5.0.4-lib/looks-2.2.2.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CMAP-REPOS/cmap_abm/e0b6bd57e34e5bd3d95ecb159feb1f4745baf0c6/exec/jppf-5.0.4-lib/looks-2.2.2.jar
--------------------------------------------------------------------------------
/exec/jppf-5.0.4-lib/miglayout-3.7-swing.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CMAP-REPOS/cmap_abm/e0b6bd57e34e5bd3d95ecb159feb1f4745baf0c6/exec/jppf-5.0.4-lib/miglayout-3.7-swing.jar
--------------------------------------------------------------------------------
/exec/jppf-5.0.4-lib/slf4j-api-1.6.1.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CMAP-REPOS/cmap_abm/e0b6bd57e34e5bd3d95ecb159feb1f4745baf0c6/exec/jppf-5.0.4-lib/slf4j-api-1.6.1.jar
--------------------------------------------------------------------------------
/exec/jppf-5.0.4-lib/slf4j-log4j12-1.6.1.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CMAP-REPOS/cmap_abm/e0b6bd57e34e5bd3d95ecb159feb1f4745baf0c6/exec/jppf-5.0.4-lib/slf4j-log4j12-1.6.1.jar
--------------------------------------------------------------------------------
/exec/jxl.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CMAP-REPOS/cmap_abm/e0b6bd57e34e5bd3d95ecb159feb1f4745baf0c6/exec/jxl.jar
--------------------------------------------------------------------------------
/exec/log4j-1.2.9.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CMAP-REPOS/cmap_abm/e0b6bd57e34e5bd3d95ecb159feb1f4745baf0c6/exec/log4j-1.2.9.jar
--------------------------------------------------------------------------------
/exec/sawdust-util-1.0.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CMAP-REPOS/cmap_abm/e0b6bd57e34e5bd3d95ecb159feb1f4745baf0c6/exec/sawdust-util-1.0.jar
--------------------------------------------------------------------------------
/exec/ssj.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CMAP-REPOS/cmap_abm/e0b6bd57e34e5bd3d95ecb159feb1f4745baf0c6/exec/ssj.jar
--------------------------------------------------------------------------------
/exec/synpop.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CMAP-REPOS/cmap_abm/e0b6bd57e34e5bd3d95ecb159feb1f4745baf0c6/exec/synpop.jar
--------------------------------------------------------------------------------
/population_synthesis/1__control_files/ipf_AB20080429.R:
--------------------------------------------------------------------------------
1 | #ipf.R
2 | #Function to iteratively proportionally fit a multidimensional array
3 | #IPF also known as Fratar method, Furness method, raking and two/three dimensional balancing.
4 | #This method of matrix balancing is multiplicative since the margin factors (coefficients)
5 | #are multiplied by the seed array to yield the balanced array.
6 | #Ben Stabler, benjamin.stabler@odot.state.or.us, 9.30.2003
7 | #Brian Gregor, brian.j.gregor@odot.state.or.us, 2002
8 |
9 | #inputs:
10 | #1) marginsList=list(dim1=c(100,200),dim2=c(40,50,60))
11 | # List of marginals corresponding to each dimension
12 | #2) seedAry - a multi-dimensional array used as the seed for the IPF
13 | #3) iteration counter (default to 100)
14 | #4) closure criteria (default to 0.001)
15 |
16 | #For more info on IPF see:
17 | #Beckmann, R., Baggerly, K. and McKay, M. (1996). "Creating Synthetic Baseline Populations."
18 | # Transportation Research 30A(6), 415-435.
19 | #Inro. (1996). "Algorithms". EMME/2 User's Manual. Section 6.
20 | #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
21 | ipf <- function(marginsList, seedAry, maxiter=100, closure=0.001) {
22 | #Check to see if the sum of each margin is equal
23 | #if(length(unique(colSums(marginsMtx))) != 1) warning("sum of each margin not equal")
24 |
25 | #Replace margin values of zero with 0.001
26 | for(i in 1:length(marginsList)) {
27 | if(any(marginsList[[i]]==0)){
28 | marginsList[[i]][marginsList[[i]]==0] <- 0.001
29 | }
30 | }
31 |
32 | #Replace seed values of zero with 1
33 | seedAry <- ifelse(seedAry==0,1,seedAry)
34 |
35 | #Check to see if number of dimensions in seed array equals the number of
36 | #margins specified in the marginsMtx
37 | numMargins <- length(dim(seedAry))
38 | if(length(marginsList) != numMargins) {
39 | stop("number of margins in marginsMtx not equal to number of margins in seedAry")
40 | }
41 |
42 | #Set initial values
43 | resultAry <- seedAry
44 | iter <- 0
45 | marginChecks <- rep(1, numMargins)
46 | margins <- seq(1, numMargins)
47 |
48 | #Iteratively proportion margins until closure or iteration criteria are met
49 | while((any(marginChecks > closure)) & (iter < maxiter)) {
50 | for(margin in margins) {
51 | marginTotal <- apply(resultAry, margin, sum)
52 | marginCoeff <- marginsList[[margin]]/marginTotal
53 | resultAry <- sweep(resultAry, margin, marginCoeff, "*")
54 | marginChecks[margin] <- sum(abs(1 - marginCoeff))
55 | }
56 | iter <- iter + 1
57 | }
58 |
59 | #If IPF stopped due to number of iterations then output info
60 | if(iter == maxiter) cat("IPF stopped due to number of iterations\n")
61 |
62 | #Return balanced array
63 | resultAry
64 | }
65 |
66 |
--------------------------------------------------------------------------------
/population_synthesis/1__control_files/original_controls_script/cmap-synpop.R:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CMAP-REPOS/cmap_abm/e0b6bd57e34e5bd3d95ecb159feb1f4745baf0c6/population_synthesis/1__control_files/original_controls_script/cmap-synpop.R
--------------------------------------------------------------------------------
/population_synthesis/1__control_files/update_controls.bat:
--------------------------------------------------------------------------------
1 | SET Rscript="C:\Program Files\R\R-3.2.0\bin\x64\Rscript.exe"
2 | CALL %Rscript% createNewControls.R
3 | PAUSE
--------------------------------------------------------------------------------
/population_synthesis/2__synpop/model/RunCMAPPopSynBase.bat:
--------------------------------------------------------------------------------
1 | copy cmap.base.properties cmap.properties
2 | java -Xms500m -Xmx4000m -Dlog4j.configuration=log4j.xml -cp "./*;." com.pb.cmap.synpop.ARCPopulationSynthesizer
3 |
--------------------------------------------------------------------------------
/population_synthesis/2__synpop/model/RunCMAPPopSynForecast.bat:
--------------------------------------------------------------------------------
1 | copy cmap.forecast.properties cmap.properties
2 | java -Xms500m -Xmx4000m -Dlog4j.configuration=log4j.xml -cp "./*;." com.pb.cmap.synpop.ARCPopulationSynthesizer
3 | PAUSE
4 |
--------------------------------------------------------------------------------
/population_synthesis/2__synpop/model/cmap.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CMAP-REPOS/cmap_abm/e0b6bd57e34e5bd3d95ecb159feb1f4745baf0c6/population_synthesis/2__synpop/model/cmap.jar
--------------------------------------------------------------------------------
/population_synthesis/2__synpop/model/common-base.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CMAP-REPOS/cmap_abm/e0b6bd57e34e5bd3d95ecb159feb1f4745baf0c6/population_synthesis/2__synpop/model/common-base.jar
--------------------------------------------------------------------------------
/population_synthesis/2__synpop/model/jxl.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CMAP-REPOS/cmap_abm/e0b6bd57e34e5bd3d95ecb159feb1f4745baf0c6/population_synthesis/2__synpop/model/jxl.jar
--------------------------------------------------------------------------------
/population_synthesis/2__synpop/model/log4j-1.2.9.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CMAP-REPOS/cmap_abm/e0b6bd57e34e5bd3d95ecb159feb1f4745baf0c6/population_synthesis/2__synpop/model/log4j-1.2.9.jar
--------------------------------------------------------------------------------
/population_synthesis/2__synpop/model/log4j.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
--------------------------------------------------------------------------------
/population_synthesis/2__synpop/model/synpop.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CMAP-REPOS/cmap_abm/e0b6bd57e34e5bd3d95ecb159feb1f4745baf0c6/population_synthesis/2__synpop/model/synpop.jar
--------------------------------------------------------------------------------
/population_synthesis/2__synpop/model/synpop_source_code/.classpath:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/population_synthesis/2__synpop/model/synpop_source_code/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | synpop
4 |
5 |
6 |
7 |
8 |
9 | org.eclipse.jdt.core.javabuilder
10 |
11 |
12 |
13 |
14 |
15 | org.eclipse.jdt.core.javanature
16 |
17 |
18 |
--------------------------------------------------------------------------------
/population_synthesis/2__synpop/model/synpop_source_code/build.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 | ]>
6 |
7 |
8 | &properties;
9 | &targets;
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
--------------------------------------------------------------------------------
/population_synthesis/2__synpop/model/synpop_source_code/module_synpop.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
--------------------------------------------------------------------------------
/population_synthesis/2__synpop/model/synpop_source_code/src/java/com/pb/models/morpc_synpop/PercentageCurve.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2005 PB Consult Inc.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | */
17 | package com.pb.models.morpc_synpop;
18 |
19 | /**
20 | * PercentageCurve is a class that represents typically one dimensional distributions of Households
21 | * by some socioeconomic catgories (HH Size, HH Income, HH Workers, etc...)...
22 | *
23 | * @author Jim Hicks
24 | * @version 1.0, Dec 21, 2005
25 | */
26 | public abstract class PercentageCurve {
27 |
28 | public PercentageCurve () {
29 | }
30 |
31 |
32 | public abstract float[] getPercentages (float[] args);
33 |
34 |
35 | public abstract float[] extendPercentages ();
36 |
37 | }
38 |
--------------------------------------------------------------------------------
/population_synthesis/2__synpop/model/synpop_source_code/src/java/com/pb/models/synpop/daf/MESSAGE_IDS.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2005 PB Consult Inc.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | */
17 | package com.pb.models.synpop.daf;
18 |
19 | /**
20 | * MESSAGE_IDS is a class that ...
21 | *
22 | * @author Christi Willison
23 | * @version 1.0, May 14, 2009
24 | */
25 | public class MESSAGE_IDS {
26 |
27 |
28 | /* ****** MESSAGE CONENT ****** */
29 | public static final String CATEGORY = "HH Category";
30 | public static String CATEGORY_LABEL = "HH Category Label";
31 | public static final String RP_ASSIGNER_RESULTS = "assigner results";
32 |
33 | public static String REGION_DOLLARS = "Region Dollars By Job";
34 |
35 | public static final String RP_CATEGORY_COUNT = "category count";
36 | public static final String RP_ARRAY_SIZE = "hh array size";
37 | public static final String RP_SUMMARY_HHS = "totalHhsByTaz";
38 | public static final String RP_SUMMARY_HH_INCOME = "totalHhIncomeByTaz";
39 | public static final String RP_SUMMARY_PERSONS = "totalPersonsByTaz";
40 | public static final String RP_SUMMARY_WORKERS = "totalWorkersByTaz";
41 | public static final String RP_SUMMARY_HHS_BY_CATEGORY = "totalHhsByTazCategory";
42 | public static final String RP_SUMMARY_PERSON_AGES = "personAgesByTaz";
43 |
44 |
45 | /* ****** MESSAGE IDS ****** */
46 | public static final String HA_WORK_MESSAGE_ID = "assigner work message";
47 | public static final String HA_SEND_SUMMARIES_ID = "hh assigner send summaries";
48 |
49 | public static final String RP_ASSIGNER_HH_ARRAY_SIZE_ID = "assigner hh array size message";
50 | public static final String RP_ASSIGNER_RESULTS_MESSAGE_ID = "assigner results message";
51 | public static final String RP_WRITE_SPG2_OUTPUT_FILE_MESSAGE_ID = "write summary results message";
52 | public static final String RP_ASSIGNER_SUMMARY_RESULTS_ID = "assigner summary results message";
53 | public static final String RP_WRITE_ZONAL_SUMMARY_ID = "write summary results message";
54 |
55 | }
56 |
--------------------------------------------------------------------------------
/population_synthesis/2__synpop/model/synpop_source_code/src/java/com/pb/models/synpop/test/TestGetSelectionFromCumProbabilities.java:
--------------------------------------------------------------------------------
1 | package com.pb.models.synpop.test;
2 |
3 | import com.pb.common.util.SeededRandom;
4 | import com.pb.models.synpop.SPG;
5 |
6 | import org.apache.log4j.Logger;
7 |
8 | /**
9 | * Specify a cumulative probability distribution where the last element is 1.0
10 | * and test that the correct index values are determined.
11 | *
12 | */
13 | public class TestGetSelectionFromCumProbabilities {
14 |
15 | protected static Logger logger = Logger.getLogger(TestGetSelectionFromCumProbabilities.class);
16 |
17 |
18 | public TestGetSelectionFromCumProbabilities() {
19 | }
20 |
21 | private void runTest( SPG testObject, int numElements, double entry ) {
22 |
23 | // generate a random cumulative distribution of length numElements
24 | double[] cumProbDist = getCumulativeProbabilityDistribution( numElements );
25 |
26 | // replicate testObject.getSelectionFromCumProbabilities() to test binary search method in that class.
27 | double randomNumber = entry;
28 | int index = testObject.binarySearchDouble (cumProbDist, randomNumber);
29 |
30 | logger.info ( String.format("\ncumulative distribution generated:") );
31 | logger.info ( String.format("%-5s %16s", "i", "cumProbDist[i]") );
32 | for (int i=0; i < numElements; i++) {
33 | logger.info( String.format("%-5d %16.8f", i, cumProbDist[i]) );
34 | }
35 | logger.info ( String.format("search for %f returned index %d\n", randomNumber, index) );
36 |
37 | }
38 |
39 |
40 | private double[] getCumulativeProbabilityDistribution (int numElements) {
41 |
42 | double[] cumProbabilities = new double[numElements];
43 | double[] probabilities = new double[numElements];
44 | double total = 0.0;
45 |
46 | // create an array of random numbers and a total of those numbers
47 | for (int i=0; i < numElements; i++) {
48 | probabilities[i] = SeededRandom.getRandom();
49 | total += probabilities[i];
50 | }
51 |
52 | // divide each random number by total to get a set of proportions that sum to 1
53 | // also create an array of these cumulative proportions to return
54 | probabilities[0] /= total;
55 | cumProbabilities[0] = probabilities[0];
56 | for (int i=1; i < numElements-1; i++) {
57 | probabilities[i] /= total;
58 | cumProbabilities[i] = cumProbabilities[i-1] + probabilities[i];
59 | }
60 | cumProbabilities[numElements-1] = 1.0;
61 |
62 | return cumProbabilities;
63 |
64 | }
65 |
66 |
67 | // the following main() is used to test the methods implemented in this object.
68 | public static void main (String[] args) {
69 |
70 | TestGetSelectionFromCumProbabilities test = new TestGetSelectionFromCumProbabilities();
71 |
72 | // create an SPG object so we can test its getSelectionFromCumProbabilities() method.
73 | SPG testObject = new SPG();
74 |
75 | // call the runTest() method several times
76 | test.runTest( testObject, 10, 0.3333 );
77 | test.runTest( testObject, 1, 0.88 );
78 | test.runTest( testObject, 2, 0.88 );
79 | test.runTest( testObject, 3, 0.88 );
80 | test.runTest( testObject, 4, 0.0 );
81 | test.runTest( testObject, 8, 0.99999 );
82 | test.runTest( testObject, 8, 1.0 );
83 | test.runTest( testObject, 6, -0.1 );
84 |
85 | }
86 |
87 | }
88 |
89 |
90 |
91 |
--------------------------------------------------------------------------------
/population_synthesis/2__synpop/model/synpop_source_code/src/java/com/pb/models/synpop/test/TestZonalData2DBalancer.java:
--------------------------------------------------------------------------------
1 | package com.pb.models.synpop.test;
2 |
3 | import com.pb.common.matrix.NDimensionalMatrixDouble;
4 | import com.pb.models.synpop.ZonalData2DBalancer;
5 |
6 | import org.apache.log4j.Logger;
7 |
8 | /**
9 | * Calculate a joint probability distribution of HHs (hhincome x hhsize) for each zone
10 | * based on marginal distributions of hhincome and hhsize by zone and seed joint
11 | * distributions of weighted PUMS households by hhincome and hhsize from the puma
12 | * in which the zone is located.
13 | *
14 | */
15 | public class TestZonalData2DBalancer {
16 |
17 | protected static Logger logger = Logger.getLogger(TestZonalData2DBalancer.class);
18 |
19 |
20 | public TestZonalData2DBalancer(String[] args) {
21 |
22 | // String appPropFile = args[0].substring(args[0].lastIndexOf('/')+1,args[0].length());
23 | // String globalPropFile = args[1].substring(args[1].lastIndexOf('/')+1,args[1].length());
24 | // runTest( appPropFile, globalPropFile );
25 |
26 | runTest( args[0], args[1] );
27 |
28 | }
29 |
30 | private void runTest( String appPropFile, String globalPropFile ) {
31 |
32 | ZonalData2DBalancer zdb = new ZonalData2DBalancer( appPropFile, globalPropFile );
33 |
34 | zdb.init();
35 | NDimensionalMatrixDouble[] finalBalancedTable = zdb.balanceZonalData();
36 |
37 | zdb.writeOutputFiles ( finalBalancedTable );
38 |
39 | logger.info( "TestZonalData2DBalancer.runTest() is finished." );
40 |
41 | }
42 |
43 |
44 | // the following main() is used to test the methods implemented in this object.
45 | public static void main (String[] args) {
46 |
47 | TestZonalData2DBalancer test = new TestZonalData2DBalancer(args);
48 |
49 | }
50 |
51 | }
52 |
53 |
54 |
55 |
--------------------------------------------------------------------------------
/population_synthesis/2__synpop/model/synpop_source_code/src/java/com/pb/models/synpopV3/BasicTazData.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2006 PB Consult Inc.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | */
17 | package com.pb.models.synpopV3;
18 |
19 | import java.io.File;
20 | import java.io.IOException;
21 | import java.util.Hashtable;
22 |
23 | import org.apache.log4j.Logger;
24 |
25 | import com.pb.common.datafile.CSVFileReader;
26 | import com.pb.common.datafile.TableDataSet;
27 |
28 | /**
29 | * @author Erhardt
30 | * @version 1.0 Oct 13, 2006
31 | *
32 | */
33 | public class BasicTazData implements TazData {
34 |
35 | protected static Logger logger = Logger.getLogger("com.pb.models.synpopV3");
36 |
37 | TableDataSet tazTable;
38 | Hashtable indexedHouseholds;
39 |
40 | /**
41 | *
42 | * @param tazFileProperty The name of the property to read containing the file name.
43 | * @param hhColumnProperty The name of the property storing the name of the households column.
44 | */
45 | public BasicTazData(String tazFileProperty, String hhColumnProperty) {
46 |
47 | // read the properties
48 | String tazFile = PropertyParser.getPropertyByName(tazFileProperty);
49 | String hhColumn = PropertyParser.getPropertyByName(hhColumnProperty);
50 |
51 | // read the table
52 | tazTable = new TableDataSet();
53 | try{
54 | CSVFileReader CSVReader = new CSVFileReader();
55 | tazTable = CSVReader.readFile(new File(tazFile));
56 | } catch (IOException e){
57 | logger.error("Unable to read taz file:" + tazFile);
58 | }
59 |
60 | // create a hashtable with the taz id and number of households
61 | indexedHouseholds = new Hashtable();
62 | int[] tazIds = tazTable.getColumnAsInt("TAZ");
63 | int[] hh = tazTable.getColumnAsInt(hhColumn);
64 | for (int i=0; iCompany: PB Consult, Parsons Brinckerhoff
23 | * @author Wu Sun
24 | * @version 1.1, modified Nov. 15, 2004
25 | *
26 | * Control variable index.
27 | *
28 | * 6 control variables:
29 | * 1) hhagecat: household header age
30 | * 2) hsizecat: household size
31 | * 3) hfamily: family status
32 | * 4) hNOCcat: children status
33 | * 5) hwrkrcat: number of workers
34 | * 6) hinccat1: household income category
35 | *
36 | * Important: these names must match the column labels in HHCatFile.csv
37 | */
38 |
39 | public class ControlVarIndex {
40 |
41 | //raw control variables from property file
42 | protected static String ctrlVarRaw;
43 | //control variable names
44 | protected static Vector ctrlVars;
45 | //index map between indices and control variable
46 | protected static HashMap indexMap=new HashMap();
47 | //reverse of indexMap
48 | protected static HashMap reverseIndexMap=new HashMap();
49 |
50 | static{
51 |
52 | ctrlVarRaw=PropertyParser.getPropertyByName("control.variables");
53 | ctrlVars=PropertyParser.parseValues(ctrlVarRaw,",");
54 |
55 | Integer index=null;
56 | String catName=null;
57 | //make index/reverse index map
58 | //important: index starts from 0
59 | for(int i=0; i
25 | *
26 | */
27 | public class DrawnHH {
28 |
29 | protected DerivedHH dhh;
30 | //dimension 1 segment category, HHCat (316 in ARC)
31 | protected int D1SCat;
32 | protected int bucketBin;
33 | protected int originalPUMA;
34 | protected int selectedPUMA;
35 | protected int taz;
36 | protected int HHID;
37 |
38 | public DrawnHH(DerivedHH dhh){
39 | this.dhh=dhh;
40 | }
41 |
42 | public int getHHAttr(String attr){
43 | if(attr.equalsIgnoreCase("D1SCat")){
44 | return D1SCat;
45 | }else if(attr.equalsIgnoreCase("bucketBin")){
46 | return bucketBin;
47 | }else if(attr.equalsIgnoreCase("originalPUMA")){
48 | return originalPUMA;
49 | }else if(attr.equalsIgnoreCase("selectedPUMA")){
50 | return selectedPUMA;
51 | }else if(attr.equalsIgnoreCase("TAZ")){
52 | return taz;
53 | }else if(attr.equalsIgnoreCase("HHID")){
54 | return HHID;
55 | }else{
56 | return dhh.getHHAttr(attr);
57 | }
58 | }
59 |
60 | public DerivedHH getDerivedHH(){
61 | return dhh;
62 | }
63 |
64 | public int getD1SCat(){
65 | return D1SCat;
66 | }
67 |
68 | public int getBucketBin(){
69 | return bucketBin;
70 | }
71 |
72 | public int getOriginalPUMA(){
73 | return originalPUMA;
74 | }
75 |
76 | public int getSelectedPUMA(){
77 | return selectedPUMA;
78 | }
79 |
80 | public int getTAZ(){
81 | return taz;
82 | }
83 |
84 | public int getHHID(){
85 | return HHID;
86 | }
87 |
88 | public void setD1SCat(int D1SCat){
89 | this.D1SCat=D1SCat;
90 | }
91 |
92 | public void setBucketBin(int bucketBin){
93 | this.bucketBin=bucketBin;
94 | }
95 |
96 | public void setOriginalPUMA(int originalPUMA){
97 | this.originalPUMA=originalPUMA;
98 | }
99 |
100 | public void setSelectedPUMA(int selectedPUMA){
101 | this.selectedPUMA=selectedPUMA;
102 | }
103 |
104 | public void setTAZ(int taz){
105 | this.taz=taz;
106 | }
107 |
108 | public void setHHID(int HHID){
109 | this.HHID=HHID;
110 | }
111 |
112 | }
113 |
--------------------------------------------------------------------------------
/population_synthesis/2__synpop/model/synpop_source_code/src/java/com/pb/models/synpopV3/HHCat.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2006 PB Consult Inc.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.pb.models.synpopV3;
17 |
18 | import org.apache.log4j.Logger;
19 |
20 | /**
21 | * Company: PB Consult, Parsons Brinckerhoff
22 | * @author Wu Sun
23 | * @version 1.0, Jan. 8, 2004
24 | *
25 | * This class represents one HH catetory.
26 | */
27 |
28 | public class HHCat {
29 |
30 | protected Logger logger;
31 | //control variable values
32 | protected String [] ctrlVals;
33 | //number of control variables
34 | protected int NoCtrlVars;
35 |
36 | /**
37 | * Constructor.
38 | * @param ctrlVal represents control variable values.
39 | */
40 | public HHCat(String [] ctrlVals) {
41 |
42 | logger=Logger.getLogger("com.pb.models.synpopV3");
43 | this.ctrlVals=ctrlVals;
44 | NoCtrlVars=ctrlVals.length;
45 |
46 | }
47 |
48 | /**
49 | * get control variable values
50 | * @return
51 | */
52 | public String [] getCtrlVarVals(){
53 | return ctrlVals;
54 | }
55 |
56 | public void print(){
57 | for(int i=0; i
30 | */
31 | public class NDimensionalMatrixReader {
32 |
33 | protected FileInputStream in;
34 | protected ObjectInputStream s;
35 | protected NDimensionalMatrixDouble matrix;
36 | protected String fileLocation;
37 | protected Logger logger = Logger.getLogger("com.pb.models.synpopV3");
38 |
39 | public NDimensionalMatrixReader(){
40 | }
41 |
42 | public NDimensionalMatrixDouble read(String fileLocation){
43 | NDimensionalMatrixDouble result=null;
44 | try{
45 | in=new FileInputStream(fileLocation);
46 | s=new ObjectInputStream(in);
47 | result=(NDimensionalMatrixDouble)s.readObject();
48 | }catch(Exception e){
49 | logger.error("failed reading:"+fileLocation);
50 | logger.error(e.getMessage());
51 | }
52 | return result;
53 |
54 | }
55 |
56 | }
57 |
--------------------------------------------------------------------------------
/population_synthesis/2__synpop/model/synpop_source_code/src/java/com/pb/models/synpopV3/NDimensionalMatrixWriter.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2006 PB Consult Inc.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | /*
17 | * Created on Dec 2, 2004
18 | *
19 | * Use this class to write a NDimensionalMatrix to disk
20 | */
21 | package com.pb.models.synpopV3;
22 |
23 | import java.io.FileOutputStream;
24 | import java.io.ObjectOutputStream;
25 | import java.io.IOException;
26 | import org.apache.log4j.Logger;
27 | import com.pb.common.matrix.NDimensionalMatrixDouble;
28 |
29 | import com.pb.common.datafile.TableDataSet;
30 | import com.pb.common.datafile.CSVFileWriter;
31 |
32 | import java.io.File;
33 |
34 | /**
35 | * @author SunW
36 | *
37 | */
38 | public class NDimensionalMatrixWriter {
39 |
40 | protected FileOutputStream out;
41 | protected ObjectOutputStream s;
42 | protected NDimensionalMatrixDouble matrix;
43 | protected Logger logger = Logger.getLogger("com.pb.models.synpopV3");
44 |
45 | public NDimensionalMatrixWriter(NDimensionalMatrixDouble matrix){
46 | this.matrix=matrix;
47 | }
48 |
49 | public void write(String fileLocation){
50 | try{
51 | out=new FileOutputStream(fileLocation);
52 | s=new ObjectOutputStream(out);
53 | s.writeObject(matrix);
54 | s.flush();
55 | }catch(IOException e){
56 | logger.error("failed writing:"+fileLocation);
57 | }
58 | }
59 |
60 | public void writeCSVFile(String fileLocation){
61 | int [] shape=matrix.getShape();
62 | int NoRows=shape[0];
63 | int NoCols=shape[1];
64 | float [][] array=new float[NoRows][NoCols];
65 | int []position=new int[2];
66 | for(int i=0; i
29 | *
30 | */
31 | public class PUMASimilarityTable {
32 |
33 | protected static Logger logger = Logger.getLogger("com.pb.models.synpopV3");
34 | protected TableDataSet table;
35 |
36 | public PUMASimilarityTable(TableDataReader designTableReader){
37 | table=designTableReader.getTable("PUMASimilarityTable.csv");
38 | }
39 |
40 | /**
41 | * Given a PUMA get its similar PUMA of a given rank.
42 | * @param puma represents the given PUMA.
43 | * @param rank represents the desired rank of the similar PUMA. If rank=1, similar PUMA is PUMA itself.
44 | * @return
45 | */
46 | public int getSimilarPUMA(int puma, int rank) {
47 | //Initialize similar PUMA as PUMA itself.
48 | //If a similar PUMA of a desired rank is not found, then return PUMA itself as its similar PUMA.
49 | int result = puma;
50 |
51 | int NRows=table.getRowCount();
52 | int[] currentPUMA=table.getColumnAsInt("PUMA_1");
53 | int[] similarPUMA=table.getColumnAsInt("PUMA_2");
54 | int[] ranks=table.getColumnAsInt("SIMILARRAN");
55 |
56 | //find the similar PUMA
57 | for (int i = 0; i < NRows; i++) {
58 | if ((puma == currentPUMA[i]) && (rank == ranks[i])) {
59 | result = similarPUMA[i];
60 | break;
61 | }
62 | }
63 |
64 | return result;
65 | }
66 |
67 | public static void main(String [] args){
68 | TableDataReader designReader=new TableDataReader("design");
69 | PUMASimilarityTable table=new PUMASimilarityTable(designReader);
70 | logger.info("ok, I am done.");
71 | }
72 |
73 | }
74 |
--------------------------------------------------------------------------------
/population_synthesis/2__synpop/model/synpop_source_code/src/java/com/pb/models/synpopV3/PUMSAttrs.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2006 PB Consult Inc.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.pb.models.synpopV3;
17 |
18 | import java.util.Vector;
19 | import org.apache.log4j.Logger;
20 |
21 | /**
22 | * Company: PB Consult, Parsons Brinckerhoff
23 | * @author Wu Sun
24 | * @version 1.1, modified on Nov. 15, 2004
25 | *
26 | * Represents attributes of PUMSHH, DerivedHH, PUMSPerson, and DerivedPerson.
27 | * Attributes are read in from property file.
28 | *
29 | */
30 |
31 | public class PUMSAttrs {
32 |
33 | protected static Logger logger;
34 | protected static Vector HHAttrs;
35 | protected static Vector DerivedHHAttrs;
36 | protected static Vector PersonAttrs;
37 | protected static Vector DerivedPersonAttrs;
38 |
39 | static {
40 | logger= Logger.getLogger("com.pb.models.synpopV3");
41 | HHAttrs=PropertyParser.getPropertyElementsByName("pums.hhattrs",",");
42 | DerivedHHAttrs=PropertyParser.getPropertyElementsByName("pums.derivedHHAttrs",",");
43 | PersonAttrs=PropertyParser.getPropertyElementsByName("pums.pattrs",",");
44 | DerivedPersonAttrs=PropertyParser.getPropertyElementsByName("pums.derivedPersonAttrs",",");
45 | }
46 |
47 | public static Vector getHHAttrs(){
48 | return HHAttrs;
49 | }
50 |
51 | public static Vector getPersonAttrs(){
52 | return PersonAttrs;
53 | }
54 |
55 | public static Vector getDerivedHHAttrs(){
56 | return DerivedHHAttrs;
57 | }
58 |
59 | public static Vector getDerivedPersonAttrs(){
60 | return DerivedPersonAttrs;
61 | }
62 |
63 | //for testing purpose only
64 | //successfully tested on March 23, 2005
65 | public static void main(String [] args){
66 | Vector v1=PUMSAttrs.getHHAttrs();
67 | Vector v2=PUMSAttrs.getPersonAttrs();
68 | Vector v3=PUMSAttrs.getDerivedHHAttrs();
69 | System.out.println("ok, I am done");
70 | }
71 | }
--------------------------------------------------------------------------------
/population_synthesis/2__synpop/model/synpop_source_code/src/java/com/pb/models/synpopV3/PUMSBucketBin.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2006 PB Consult Inc.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.pb.models.synpopV3;
17 |
18 | import java.util.Vector;
19 |
20 | /**
21 | * Company: PB Consult, Parsons Brinckerhoff
22 | * @author Wu Sun
23 | * @version 1.0, Jan. 8, 2004
24 | */
25 |
26 | public class PUMSBucketBin {
27 |
28 | //HHs in this bin (a vector of DerivedHH objects)
29 | protected Vector hhs;
30 | //number of HHs in this bin
31 | protected int NBinMembers;
32 | //times all HHs in this been has been drawn
33 | protected int NEmptied;
34 |
35 |
36 | public PUMSBucketBin() {
37 | hhs=new Vector();
38 | }
39 |
40 | public void update(){
41 | if(getNDrawn()==NBinMembers){
42 | NEmptied++;
43 | //set drawn status of all HHs in this bin to "false"
44 | setHHsDrawnSta(false);
45 | }
46 | }
47 |
48 | public void reset(){
49 | DerivedHH hh=null;
50 | NEmptied=0;
51 | for(int i=0; iCompany: PB Consult, Parsons Brinckerhoff
24 | * @author Wu Sun
25 | * @version 1.1, modified on Nov. 15, 2004
26 | *
27 | * Create a PUMSPerson object from raw string record of a person in PUMS data.
28 | */
29 |
30 | public class PUMSPerson {
31 |
32 | //raw person record as a string
33 | protected String pRecord_raw;
34 | //PUMS person attributes
35 | protected Vector pattrs;
36 | //person attributes map, attribute name<--->value pairs
37 | protected HashMap pAttrsMap;
38 | //PUMS person record parser
39 | protected PUMSRecordParser recordParser;
40 | //data dictionary
41 | protected DataDictionary dd;
42 |
43 | /**
44 | * constructor
45 | * must be defined so that subclass DerivedPerson compiles
46 | */
47 | public PUMSPerson(){
48 | }
49 | /**
50 | * Constructor
51 | * @param pRecord_raw represents a raw string person record
52 | * @param dd represents a PUMS data dictionary
53 | */
54 | public PUMSPerson(String pRecord_raw, DataDictionary dd) {
55 | this.pRecord_raw=pRecord_raw;
56 | this.dd=dd;
57 | recordParser=new PUMSRecordParser(pRecord_raw, dd);
58 | pattrs=PUMSAttrs.getPersonAttrs();
59 | makeAttrsMap();
60 | }
61 |
62 | /**
63 | * Givan a person attribute name, return its value
64 | * @param attr represents a person attribute name
65 | * @return
66 | */
67 | public int getPAttr(String attr){
68 | int attrVal=((Integer)pAttrsMap.get(attr)).intValue();
69 | return attrVal;
70 | }
71 |
72 | /**
73 | * get all person attributes
74 | * @return
75 | */
76 | public HashMap getPAttrs(){
77 | return pAttrsMap;
78 | }
79 |
80 | private void makeAttrsMap(){
81 |
82 | String attr;
83 | int attrVal;
84 | pAttrsMap=new HashMap();
85 |
86 | for(int i=0; iCompany: PB Consult, Parsons Brinckerhoff
23 | * @author Wu Sun
24 | * @version 1.2, modified on Nov. 17, 2004
25 | *
26 | * Use this class to parse PUMS HH record.
27 | */
28 |
29 | public class PUMSRecordParser {
30 |
31 | protected String pumsDir;
32 | protected String pumsDD;
33 | protected DataDictionary dd;
34 | protected String record;
35 |
36 | /**
37 | * constructor
38 | * @param record represents a raw record string
39 | * @param dd represents a data dictionary
40 | */
41 | public PUMSRecordParser(String record, DataDictionary dd){
42 | this.record=record;
43 | this.dd=dd;
44 | pumsDir=PropertyParser.getPropertyByName("pums.directory");
45 | pumsDD=PropertyParser.getPropertyByName("pums.dictionary");
46 | }
47 |
48 | /**
49 | * Given a string PUMSHH record and a PUMSHH variable name, return value of this variable
50 | * @param PUMSVariable represents PUMSHH variable name
51 | * @return
52 | */
53 | public int getPUMSHHDataValue(String PUMSVariable) {
54 | int startCol=dd.getStartCol(dd.HHAttribs, PUMSVariable);
55 | int endCol=dd.getLastCol(dd.HHAttribs, PUMSVariable);
56 | String temp = record.substring(startCol,endCol);
57 |
58 | String emptyStr=" ";
59 | for(int i=0; iCompany: PB Consult, Parsons Brinckerhoff
24 | * @author Wu Sun
25 | * @version 1.0, Jan. 9, 2004
26 | */
27 |
28 | public class RandomSeedMatrix {
29 | protected static Logger logger = Logger.getLogger("com.pb.models.synpopV3");
30 | protected static int NTAZ;
31 | protected static int NHHCat;
32 | //randome seed matrix, 1st dimension number of HHCat, 2nd dimension number of TAZ
33 | protected static long [][] matrix;
34 | protected static long seed;
35 |
36 | static {
37 | NTAZ=PopulationSynthesizer.numberOfInternalZones;
38 | NHHCat=HHCatTable.NHHCat;
39 | matrix=new long [NHHCat][NTAZ];
40 | seed=(new Long(PropertyParser.getPropertyByName("RandomSeed"))).longValue();
41 | logger.info("Random seed set to: " + seed);
42 | setSeedMatrix();
43 | }
44 |
45 | /**
46 | * Get random seed matrix. First dimension TAZ, second dimension HHCat.
47 | * @return
48 | */
49 | public static long [][] getSeedMatrix(){
50 | return matrix;
51 | }
52 |
53 | /**
54 | * Get a random seed from one cell in the random matrix.
55 | * @param TAZ represents the internal TAZ ID (starts from 0).
56 | * @param HHCat represents the internal HHCat ID (starts from 0).
57 | * @return
58 | */
59 | public static long getSeed(int HHCat, int TAZ){
60 | return matrix[HHCat][TAZ];
61 | }
62 |
63 | /**
64 | * Populate random seed matrix.
65 | */
66 | private static void setSeedMatrix(){
67 | Random generator=new Random(seed);
68 | for(int i=0; i
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/population_synthesis/3__hh_taz_to_maz/cmap_hh_maz.R:
--------------------------------------------------------------------------------
1 | #Allocate SynPop HHs to MAZs
2 | #Ben Stabler, stabler@pbworld.com, 05/24/13
3 | #Revised to work with TG files by NMP, 5/19/16
4 |
5 | source("../get_dir.R") # Intelligently create PopSynDir variable
6 | inDir1 = file.path(PopSynDir, "2__synpop/outputs")
7 | inDir2 = file.path(PopSynDir, "3__hh_taz_to_maz/inputs")
8 | outDir = file.path(PopSynDir, "3__hh_taz_to_maz/outputs")
9 |
10 | #Read input files
11 | setwd(inDir1)
12 | hh = read.csv("ForecastHHFile.csv")
13 | setwd(inDir2)
14 | #mazs = read.csv("SubzoneData.csv")
15 | hh_in = read.table("HH_IN.TXT", header=FALSE, sep=",",
16 | col.names=c("subzone09","hshld","ahh","whh","chh",
17 | "iqi","ahi","automs","pef"))
18 | hh_in = subset(hh_in, select=c("subzone09","hshld"))
19 |
20 | geog_in = read.table(file="GEOG_IN.TXT", header=FALSE, sep=",",
21 | col.names=c("subzone09","cofips","coname","state","puma1",
22 | "puma5","zone09","chi","cbd","rowcol","sqmi"))
23 | geog_in = subset(geog_in, select=c("subzone09","zone09"))
24 |
25 | mazs = merge(geog_in, hh_in)
26 |
27 | #Get mazs (and their num hhs) by taz
28 | mazsByTaz = tapply(mazs$subzone09, mazs$zone09, function(x) x)
29 | mazHHsByTaz = tapply(mazs$hshld, mazs$zone09, function(x) x)
30 |
31 | #Randomly assign an MAZ to a TAZ using the MAZ num HHs as the probability weight
32 | assignMaz = function(taz) {
33 | mazs = mazsByTaz[taz][[1]]
34 | hhs = mazHHsByTaz[taz][[1]]
35 | ifelse(length(mazs)>1, sample(mazs, 1, T, hhs), mazs)
36 | }
37 |
38 | #Get hh tazs and assign mazs
39 | tazs = as.character(hh$TAZ)
40 | mazs = sapply(tazs, assignMaz)
41 |
42 | #Write result
43 | hh$maz = mazs
44 | setwd(outDir)
45 | write.csv(hh, "ForecastHHFile_maz.csv", quote=F, row.names=F)
46 |
--------------------------------------------------------------------------------
/population_synthesis/3__hh_taz_to_maz/distribute_hh_to_maz.bat:
--------------------------------------------------------------------------------
1 | SET Rscript="C:\Program Files\R\R-3.2.0\bin\x64\Rscript.exe"
2 | CALL %Rscript% cmap_hh_maz.R
3 | PAUSE
--------------------------------------------------------------------------------
/population_synthesis/README.TXT:
--------------------------------------------------------------------------------
1 | HOW TO RUN ABM POPULATION SYNTHESIS
2 | -----------------------------------
3 |
4 | 0. OPTIONAL: If control totals are being run updated with new PUMS data for
5 | the first time, uncomment the large section of code in 1__control_files/
6 | createNewControls.R that creates countsPUMS.csv and distPUMS.csv in
7 | 1__control_files/inputs. These new CSVs can then be reused for any future
8 | population synthesis based on the same PUMS data. (NOTE: the 2007-2011 ACS
9 | was the last one where all of the PUMAs match the 2000 PUMAs that the
10 | current model was estimated with, so it is not recommended to use newer
11 | PUMS data without first updating the PopSyn model itself.)
12 |
13 | 1. a) FOR BASE YEAR (2010) POPSYN:
14 | Update any inputs in 1__control_files (replacing oldControls.csv with the
15 | previous version of forecastControls.csv from 2__synpop/inputs/datatables),
16 | then submit update_controls.bat. The output file will be saved to
17 | 2__synpop/inputs/datatables/forecastControls.csv.
18 |
19 | b) FOR FUTURE YEAR POPSYN:
20 | Apply base year control variables' rates to future year's household counts,
21 | and save the results to 2__synpop/inputs/datatables/forecastControls.csv.
22 |
23 | 2. Submit 2__synpop/model/RunCMAPPopSynForecast.bat. This requires the Java
24 | Runtime Environment to be installed, so it is recommended that this be done
25 | from one of the modeling servers that have it already (e.g. cmap-mod04).
26 |
27 | 3. Replace the GEOG_IN.TXT and HH_IN.TXT files in 3__hh_taz_to_maz/inputs if
28 | they are out of date. These are taken directly from the 4-step Trip
29 | Generation model.
30 |
31 | 4. Submit 3__hh_taz_to_maz/distribute_hh_to_maz.bat. This will assign the
32 | zone-level households produced by ARCPopSyn to subzones.
33 |
34 | 5. Copy the following CSVs to the main ABM inputs folder for new model runs:
35 | - 2__synpop/outputs/ForecastPersonFile.csv
36 | - 3__hh_taz_to_maz/outputs/ForecastHHFile_MAZ.csv
37 |
--------------------------------------------------------------------------------
/population_synthesis/get_dir.R:
--------------------------------------------------------------------------------
1 | # When this script is called with "source()", it will save its parent directory
2 | # (i.e. the root population synthesis directory) to a variable called PopSynDir
3 | # that can subsequently be used to define other paths in a relative manner.
4 | PopSynDir <- normalizePath(dirname(parent.frame(2)$ofile))
--------------------------------------------------------------------------------
/results_analysis/abm/__init__.py:
--------------------------------------------------------------------------------
1 | from abm import *
2 | from comparison import *
3 | import to_csv
4 | import print_summary
5 |
--------------------------------------------------------------------------------
/results_analysis/abm/comparison.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python
2 | '''
3 | comparison.py
4 | Author: npeterson
5 | Revised: 3/16/16
6 | ---------------------------------------------------------------------------
7 | A class for comparing the contents of two ABM object databases.
8 |
9 | '''
10 | import copy
11 | import abm
12 |
13 |
14 | class Comparison(object):
15 | ''' A class for comparing two ABM objects. Initialized with a base and a
16 | test ABM object. All comparisons are relative to the base. '''
17 |
18 | # --- Init ---
19 | def __init__(self, base_abm, test_abm):
20 | self.base = base_abm
21 | self.test = test_abm
22 | return None
23 |
24 |
25 | def __str__(self):
26 | return '[Comparison: BASE {0}; TEST {1}]'.format(self.base, self.test)
27 |
28 |
29 | # --- Instance methods ---
30 | def _open_dbs(self):
31 | ''' Open base & test ABM database connections. '''
32 | self.base._open_db()
33 | self.test._open_db()
34 | return None
35 |
36 |
37 | def _close_dbs(self):
38 | ''' Close base & test ABM database connections. '''
39 | self.base._close_db()
40 | self.test._close_db()
41 | return None
42 |
--------------------------------------------------------------------------------
/results_analysis/results_analysis.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python
2 | '''
3 | results_analysis.py
4 | Author: npeterson
5 | Revised: 3/16/16
6 | ---------------------------------------------------------------------------
7 | A script for printing a series of summary statistics for base and test ABM
8 | objects and a Comparison object created from them.
9 |
10 | '''
11 | from abm import *
12 |
13 | # Set Base ABM parameters
14 | BASE_DIR = r'X:\new_server_tests\test_5pct'
15 | BASE_PCT = 0.05
16 |
17 | # Set Test ABM parameters
18 | TEST_DIR = r'X:\new_server_tests\test_50pct_newsocec_3sp'
19 | TEST_PCT = 0.5
20 |
21 |
22 | # Initialize Base ABM object & print summaries
23 | print '\n{0:*^50}'.format(' P R O C E S S I N G ')
24 | print '\n{0:=^50}\n'.format(' BASE NETWORK ')
25 | base = ABM(BASE_DIR, BASE_PCT)
26 | print base
27 | print_summary.mode_share(base)
28 | print_summary.transit_stats(base)
29 | print_summary.ptrips_by_class(base)
30 | print_summary.vmt_by_speed(base)
31 | print ' '
32 |
33 |
34 | # Initialize Test ABM object & print summaries
35 | print '\n{0:=^50}\n'.format(' TEST NETWORK ')
36 | test = ABM(TEST_DIR, TEST_PCT)
37 | print test
38 | print_summary.mode_share(test)
39 | print_summary.transit_stats(test)
40 | print_summary.ptrips_by_class(test)
41 | print_summary.vmt_by_speed(test)
42 | print ' '
43 |
44 |
45 | # Initialize Test vs. Base Comparison object
46 | print '\n{0:=^50}\n'.format(' COMPARISON ')
47 | comp = Comparison(base, test)
48 | print comp
49 | print ' '
50 |
51 |
52 | # Print Comparison summaries
53 | print '\n{0:*^50}'.format(' R E S U L T S ')
54 | print_summary.mode_share_change(comp)
55 | print_summary.transit_stats_change(comp)
56 | print_summary.ptrips_by_class_change(comp)
57 | print_summary.vmt_by_speed_change(comp)
58 | print_summary.new_all(comp)
59 | print_summary.new_auto(comp)
60 | print_summary.new_dtt(comp)
61 | print_summary.new_wtt(comp)
62 | print_summary.new_other(comp)
63 |
--------------------------------------------------------------------------------
/runCTRAMP-SingleProcess.bat:
--------------------------------------------------------------------------------
1 |
2 | rem ############ PARAMETERS ############
3 | set RUNTIME=Y:/{{{TEMPLATE}}}/cmap_abm
4 | set JAVA_PATH=C:/Program Files/Java/jdk1.7.0_13
5 |
6 | rem ########## Run CTRAMP ##############
7 | "%JAVA_PATH%\bin\java" -Xmx120000m -cp "%RUNTIME%;%RUNTIME%/exec/jxl.jar;%RUNTIME%/exec/jppf-5.0.4-lib/*;%RUNTIME%/exec/*;config" -Dlog4j.configuration=log4j.xml -server -Djppf.config=jppf-guiLocal.properties com.pb.cmap.tourBased.CmapTourBasedModel "cmap" -iteration 1 -sampleRate %1 -sampleSeed 0
8 |
9 | rem ########## Run CTRAMP Remote Debug ##
10 | rem "%JAVA_PATH%\bin\java" -Xdebug -Xrunjdwp:transport=dt_socket,address=1044,server=y,suspend=y -Xmx120000m -cp "%RUNTIME%;%RUNTIME%/exec/jxl.jar;%RUNTIME%/exec/jppf-5.0.4-lib/*;%RUNTIME%/exec/*;config" -Dlog4j.configuration=log4j.xml -server -Djppf.config=jppf-guiLocal.properties com.pb.cmap.tourBased.CmapTourBasedModel "cmap" -iteration 1 -sampleRate %1 -sampleSeed 0
11 |
--------------------------------------------------------------------------------
/runCTRAMP.bat:
--------------------------------------------------------------------------------
1 |
2 | rem ############ PARAMETERS ############
3 | set RUNTIME=Y:/{{{TEMPLATE}}}/cmap_abm
4 | set JAVA_PATH=C:/Program Files/Java/jdk1.7.0_13
5 |
6 | rem ########## Run CTRAMP ##############
7 | "%JAVA_PATH%\bin\java" -Xmx8000m -cp "%RUNTIME%;%RUNTIME%/exec/jxl.jar;%RUNTIME%/exec/jppf-5.0.4-lib/*;%RUNTIME%/exec/*;config" -Dlog4j.configuration=log4j.xml -server -Djppf.config=jppf-guiDistributed.properties com.pb.cmap.tourBased.CmapTourBasedModel "cmap" -iteration 1 -sampleRate %1 -sampleSeed 0
8 |
--------------------------------------------------------------------------------
/runMAZSkimsInitial.py:
--------------------------------------------------------------------------------
1 | #############################################################################
2 | # Run MAZ Skimming Initial Setup
3 | # Ben Stabler, stabler@pbworld.com, 10/29/12
4 | # Roshan Kumar, kumarr1@pbworld.com
5 | # "C:\Python26\P64\python.exe" runMAZSkimsInitial
6 | #############################################################################
7 |
8 | #inputs
9 | isBaseYear = True
10 | navteqShpFile = "inputs/Chicago_streets.shp"
11 | #SPThreshold = 15*5280 #max dist in feet
12 | SPThreshold = 5*5280 #max dist in feet
13 | maxMAZID = 70000
14 | minTAPID = 60000
15 | maxCenID = 16819
16 | rsThreshold = 9
17 | landUseTypes = 12
18 | centroidsMAZFile = "inputs/CMAP_MAZ_cents.txt"
19 | rsToSZInput = "inputs/cmapRStoSubZone.txt"
20 | tapFile = "inputs/tap_attributes.csv"
21 | spMAZ2TAP = "outputs/SP_MAZ_to_MAZ_and_TAP.txt"
22 | nodesinMAZFile = "inputs/nodes_in_MAZ_CMAP.txt"
23 |
24 | #additional parameters for future year maz skims
25 | nodeDistFromHwy = "inputs/cmapDistFromHwy.txt" #for future build MAZs
26 | mazLUFile = "inputs/cmapMAZLandUseShare.txt" #for future build MAZs
27 | spInsideRS8 = "outputs/SP_with_TAP_clean_RS8_LU_Share_Dist.txt" #for future build MAZs
28 | spOutsideRS8 = "outputs/SP_with_TAP_clean_outside_RS8_LU_Share_Dist.txt" #for future build MAZs
29 |
30 | ############################################################################
31 |
32 | #intermediate settings
33 | import os, csv, math, shutil
34 | root = os.getcwd()
35 | int_output = "outputs"
36 | connectorEDist = 2 * SPThreshold
37 | minTAPid = 2 * minTAPID
38 | SPThresholdConn = 3 * SPThreshold
39 | SPThresholdAct = SPThreshold
40 | number_of_cores = int(os.environ["NUMBER_OF_PROCESSORS"])
41 | linkFile_int = "outputs/cmap_NavTechLinks_no_freeway.txt" #without connectors
42 | nodeFile_int = "outputs/cmap_NavTechNodes_no_freeway.txt" #without centroids
43 | outputSPFile = "outputs/centToCentDist.txt"
44 | tapConnectorFile = "outputs/tapConnectors.txt"
45 | connectorFile = "outputs/CMAP_connectors.txt"
46 | linkFile = "outputs/linkFile_Final.txt" #with connectors
47 | nodeFile = "outputs/nodeFile_Final.txt" #with centroids
48 |
49 | ############################################################################
50 |
51 | def main():
52 |
53 | #copy itself to the scripts folder for other scripts to reference
54 | shutil.copyfile("runMAZSkimsInitial.py", "scripts/parameters.py")
55 |
56 | print("run initial network build procedures")
57 | from scripts import cmapTransportationNetwork
58 | from scripts import cmapTapConnector
59 | from scripts import cmapCentroidsConnectors
60 | from scripts import cmapInputFileGen
61 | if isBaseYear:
62 | from scripts import cmapShortestPath_NX
63 | else:
64 | from scripts import cmapShortestPath_NX_future
65 |
66 | print("read shapefile and generate csv file of navteq links")
67 | cmapTransportationNetwork.getLinkDirectionality()
68 | print("read shapefile and generate csv file of navteq nodes")
69 | cmapTransportationNetwork.createAllPoints()
70 | print("create MAZ centroid connectors")
71 | cmapCentroidsConnectors.createNetworkWithCentroidConnectors()
72 | print("create TAP connectors")
73 | cmapTapConnector.createNetworkWithCentroidConnectors()
74 | print("merge node and link files to one node and one link file containing all elements")
75 | cmapInputFileGen.createNetworkInput()
76 | if isBaseYear:
77 | print("pickle network for later use")
78 | cmapShortestPath_NX.pickleNetwork()
79 | else:
80 | print("pickle network for later use")
81 | cmapShortestPath_NX_future.pickleNetwork()
82 | print("initial shortest path network build complete")
83 |
84 | if __name__ == '__main__':
85 | main()
86 |
--------------------------------------------------------------------------------
/runModel.bat:
--------------------------------------------------------------------------------
1 | :: runModel.bat
2 | :: Written by BTS, 06/24/13
3 | :: Modified by NMP, 04/14/16 - run accessibilities after skimming
4 | :: 08/12/16 - supply scenario as parameter to scripts
5 | :: ----------------------------------------------------------------------------
6 | :: Run the CMAP ABM from start to finish.
7 | :: Call from command line, e.g.: runModel.bat > blog.txt
8 |
9 | :: Parameters
10 | SET projDir=Y:/{{{TEMPLATE}}}/cmap_abm
11 | SET sampleRate=0.50
12 | SET scen=100
13 |
14 | :: Set Python paths
15 | CALL EmmeConfig.bat
16 | SET emmepy="%EMMEPATH%\Python27\python.exe"
17 | SET py64="C:\Python27\python.exe"
18 |
19 | :: Optional parameters for distributed skimming/assignment.
20 | :: If enabled, call script with username and password,
21 | :: e.g.: runModel.bat npeterson P@ssw0rd > blog.txt
22 | REM @SET user=%1
23 | REM @SET pwd=%2
24 | REM SET un=cmap\%user%
25 | REM SET IP1=\\10.10.1.52
26 | REM SET IP2=\\10.10.1.63
27 |
28 | :: Initialize timestamp log
29 | if exist model_run_timestamp.txt (del model_run_timestamp.txt /Q)
30 | @ECHO ====================================================== >> model_run_timestamp.txt
31 | @ECHO BEGIN CMAP REGIONAL MODEL RUN - SAMPLE RATE %sampleRate% >> model_run_timestamp.txt
32 | @ECHO Model Run Start Time: %date% %time% >> model_run_timestamp.txt
33 | @ECHO ====================================================== >> model_run_timestamp.txt
34 |
35 | :: Create MAZ skims
36 | @ECHO Create MAZ skims: %date% %time% >> model_run_timestamp.txt
37 | %py64% runMAZSkimsInitial.py
38 | %py64% scripts/SPwrapper.py
39 | %py64% scripts/cmapPostProcess.py
40 |
41 | :: Create networks and skim
42 | @ECHO Build networks: %date% %time% >> model_run_timestamp.txt
43 | %emmepy% runBuildNetworks.py 1,1,1,1,1,1,1,1 %scen%
44 | @ECHO Run initial skims: %date% %time% >> model_run_timestamp.txt
45 | %emmepy% runInitialSkims.py 1,1,1,1,1,1,1,1 %scen%
46 |
47 | :: Run accessibilities script
48 | @ECHO Calculate accessibilities: %date% %time% >> model_run_timestamp.txt
49 | cd accessibilities
50 | CALL runAccessibilities.bat %scen%
51 | copy outputs\accessibility_maz.csv ..\inputs
52 | cd ..
53 |
54 | :: Create TAP lines file and run CT-RAMP
55 | @ECHO Create TAP lines: %date% %time% >> model_run_timestamp.txt
56 | %emmepy% runTapLines.py %scen%
57 | @ECHO Run CT-RAMP: %date% %time% >> model_run_timestamp.txt
58 | CALL runCTRAMP-SingleProcess.bat %sampleRate%
59 |
60 | :: Final skimming and assignments
61 | @ECHO Run final assignments: %date% %time% >> model_run_timestamp.txt
62 | %emmepy% runFinalAssignments.py 1,1,1,1,1,1,1,1 %scen%
63 |
64 | @ECHO ====================================================== >> model_run_timestamp.txt
65 | @ECHO END CMAP REGIONAL MODEL RUN >> model_run_timestamp.txt
66 | @ECHO Model Run End Time: %date% %time% >> model_run_timestamp.txt
67 | @ECHO ====================================================== >> model_run_timestamp.txt
--------------------------------------------------------------------------------
/runTVPB.bat:
--------------------------------------------------------------------------------
1 |
2 | rem #Run CMAP Transit Virtual Path Builder
3 | rem #Ben Stabler, stabler@pbworld.com, 02/12/13
4 |
5 | rem ########## Parameters ############
6 | set RUNTIME=%CD%
7 | set HOST_IP=localhost
8 |
9 | rem ########## Run TVPB ##############
10 | java -Xmx40000m -cp "%RUNTIME%;%RUNTIME%/exec/jxl.jar;%RUNTIME%/exec/*;exec" -Dlog4j.configuration=config/log4j.xml -server com.pb.cmap.tvpb.TransitVirtualPathBuilder "cmap"
11 |
12 | rem ########## Run TVPB Remote Debug ##
13 | rem java -Xdebug -Xrunjdwp:transport=dt_socket,address=1044,server=y,suspend=y -Xmx40000m -cp "%RUNTIME%;%RUNTIME%/exec/jxl.jar;%RUNTIME%/exec/*;exec" -Dlog4j.configuration=config/log4j.xml -server com.pb.cmap.tvpb.TransitVirtualPathBuilder "cmap"
14 |
15 |
--------------------------------------------------------------------------------
/runTapLines.py:
--------------------------------------------------------------------------------
1 | #############################################################################
2 | # Create lines by tap file for CT-RAMP
3 | # Ben Stabler, stabler@pbworld.com, 02/18/13
4 | # "C:\Program Files (x86)\INRO\Emme\Emme 4\Emme-4.0.3\Python26\python.exe" runTapLines.py
5 | #############################################################################
6 |
7 | #load libraries
8 | import inro.modeller as m
9 | import inro.emme.desktop.app as d
10 | import inro.emme.prompt as p
11 | import os, csv, math, pickle, datetime, sys
12 |
13 | #EMME project file
14 | empFile = "CMAP-ABM/CMAP-ABM.emp"
15 |
16 | #scenarios
17 | transitImport = int(sys.argv[1]) #100
18 | tods = [1,2,3,4,5,6,7,8]
19 | highwayScenarios = [i for i in tods]
20 | transitScenarios = [transitImport + i for i in tods]
21 |
22 | #settings
23 | tapFile = "inputs/tap_attributes.csv"
24 | tapLinks = "inputs/tap2node.csv"
25 | tapLinesOutFileName = "outputs/tapLines.csv"
26 |
27 | ############################################################################
28 |
29 | #start EMME desktop and attach a modeller session
30 | desktop = d.start_dedicated(True, "cmap", empFile)
31 | m = m.Modeller(desktop)
32 |
33 | ############################################################################
34 |
35 | #create tap virtual zones
36 | taps = []
37 | with open(tapFile, 'rb') as csvfile:
38 | tapreader = csv.reader(csvfile, skipinitialspace=True)
39 | for row in tapreader:
40 | taps.append(row)
41 | taps_col_names = taps.pop(0)
42 |
43 | #create access links
44 | access_links = []
45 | with open(tapLinks, 'rb') as csvfile:
46 | tapreader = csv.reader(csvfile, skipinitialspace=True)
47 | for row in tapreader:
48 | access_links.append(row)
49 | access_links_col_names = access_links.pop(0)
50 |
51 | ############################################################################
52 |
53 | #generates lines by tap file to trim tap set for use in CT-RAMP
54 |
55 | #get all transit nodes from EMME
56 | linesByNode = dict()
57 | for tranScen in transitScenarios:
58 |
59 | #get transit segments for scenario
60 | network = m.emmebank.scenario(tranScen).get_network()
61 | tsegs = network.transit_segments()
62 |
63 | for tseg in tsegs:
64 | line = tseg.line.id
65 | from_node = tseg.i_node.id
66 |
67 | if from_node not in linesByNode:
68 | linesByNode[from_node] = set()
69 | linesByNode[from_node].add(line)
70 |
71 | to_node = tseg.j_node
72 | if to_node != None:
73 | to_node = tseg.j_node.id
74 | if to_node not in linesByNode:
75 | linesByNode[to_node] = set()
76 | linesByNode[to_node].add(line)
77 |
78 | #get nodes connected to each tap
79 | nodesByTap = dict()
80 | for linkRow in access_links:
81 | tap = linkRow[0]
82 | node = linkRow[1]
83 |
84 | if tap not in nodesByTap:
85 | nodesByTap[tap] = set()
86 | nodesByTap[tap].add(node)
87 |
88 | #get lines for each tap
89 | linesByTap = dict()
90 | for tapRow in taps:
91 | tap = tapRow[0]
92 | nodes = nodesByTap[tap]
93 |
94 | if tap not in linesByTap:
95 | linesByTap[tap] = set()
96 | for node in nodes:
97 | if node in linesByNode:
98 | lines = linesByNode[node]
99 | for line in lines:
100 | linesByTap[tap].add(line)
101 |
102 | #write out tapLines file for CT-RAMP
103 | f = file(tapLinesOutFileName,"wt")
104 | f.write("TAP,LINES\n")
105 | for tap in linesByTap.keys():
106 | lines = " ".join(list(linesByTap[tap]))
107 | if lines != "":
108 | f.write("%s,%s\n" % (tap,lines))
109 | f.close()
110 |
111 | #log results
112 | print("TapLines Complete %s" % (datetime.datetime.now()))
113 |
--------------------------------------------------------------------------------
/scripts/HwayMatIn.mac:
--------------------------------------------------------------------------------
1 | ~o=295
2 | reports=nul
3 | ~/Directory where the source emmebank is in
4 | ~t1=%1%
5 | ~/Tranfer matrices from the external emmebank
6 | 1.31
7 | ~+|1|%t1%
8 | ~+|2|3|2|mf01,mf99|y|y
9 | 4
10 | 9
--------------------------------------------------------------------------------
/scripts/SPwrapper.py:
--------------------------------------------------------------------------------
1 | #############################################################################
2 | # Shortest Path code for CMAP non-motorized modes
3 | # Roshan Kumar, kumarr1@pbworld.com, 12/20/2012
4 | #############################################################################
5 |
6 | #Should always be placed in the same folder as cmapPostProcess.py
7 | #Wrapper code that distributes the shortest path computations to the different cores.
8 | #The total # of parallel processes equal to the number of processors
9 |
10 | import parameters, time
11 | from multiprocessing import Process
12 |
13 | if parameters.isBaseYear:
14 | import cmapShortestPath_NX
15 | else:
16 | import cmapShortestPath_NX_future
17 |
18 | ################################################################
19 |
20 | #parallel distribution of SP computation to different processors
21 | def runSPinParallel():
22 | #alpha = 1
23 | if __name__ == '__main__':
24 |
25 | for num in range(parameters.number_of_cores):
26 |
27 | if parameters.isBaseYear:
28 | p = Process(target=cmapShortestPath_NX.cenToCenSP, args=(num,))
29 | p.start()
30 | else:
31 | p = Process(target=cmapShortestPath_NX_future.cenToCenSP, args=(num,))
32 | p.start()
33 |
34 | ################################################################
35 |
36 | print "SP code start time: ", time.time()
37 | runSPinParallel()
38 |
--------------------------------------------------------------------------------
/scripts/TranMatIn.mac:
--------------------------------------------------------------------------------
1 | ~o=295
2 | reports=nul
3 | ~/Input transit trip tables for time period
4 | / Directory
5 | ~t1=../../inputs/
6 | ~x=%1%
7 | ~+|batchin=%t1%Conv%x%_%x%467.txt|3.11|2
8 | ~+|batchin=%t1%Prem%x%_%x%468.txt|3.11|2
9 | ~/TOD Period %x% done!
10 | batchin=
11 | reports=
12 | q
--------------------------------------------------------------------------------
/scripts/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CMAP-REPOS/cmap_abm/e0b6bd57e34e5bd3d95ecb159feb1f4745baf0c6/scripts/__init__.py
--------------------------------------------------------------------------------
/scripts/cmapInputFileGen.py:
--------------------------------------------------------------------------------
1 | #############################################################################
2 | # Shortest Path code for CMAP non-motorized modes
3 | # Roshan Kumar, kumarr1@pbworld.com, 12/20/2012
4 | #############################################################################
5 |
6 | #Should always be placed in the same folder as SPwrapper.py
7 |
8 | #Combines the CSVs generated into one node CSV and one link CSV. Both are stored in ...\SP\final_output
9 |
10 | import parameters
11 | import csv
12 |
13 | #############################################################################
14 |
15 | def createNetworkInput():
16 | linkCSV = open(parameters.linkFile,"w")
17 | linkCSV.write('"FNODE_","TNODE_","LENGTH"\n')
18 | nodeCSV = open(parameters.nodeFile,"w")
19 | nodeCSV.write('"ID","X","Y"\n')
20 |
21 | for record in csv.DictReader(open(parameters.centroidsMAZFile, "r")):
22 | maz = int(record["MAZ_ID_9"])
23 | x = float(record["X"])
24 | y = float(record["Y"])
25 | nodeCSV.write("%d,%f,%f\n" % (maz, x, y))
26 |
27 | for record in csv.DictReader(open(parameters.tapFile, "r")):
28 | tap = int(record["tap_id"])
29 | x = float(record["x"])
30 | y = float(record["y"])
31 | nodeCSV.write("%d,%f,%f\n" % (tap, x, y))
32 |
33 | for record in csv.DictReader(open(parameters.nodeFile_int, "r")):
34 | nid = int(record["ID"])
35 | x = float(record["X"])
36 | y = float(record["Y"])
37 | nodeCSV.write("%d,%f,%f\n" % (nid, x, y))
38 |
39 | for record in csv.DictReader(open(parameters.connectorFile, "r")):
40 | fnode = int(record["FNODE_"])
41 | tnode = int(record["TNODE_"])
42 | length= float(record["LENGTH"])
43 | linkCSV.write("%d,%d,%f\n" % (fnode, tnode, length))
44 |
45 | for record in csv.DictReader(open(parameters.tapConnectorFile, "r")):
46 | fnode = int(record["FNODE_"])
47 | tnode = int(record["TNODE_"])
48 | length= float(record["LENGTH"])
49 | linkCSV.write("%d,%d,%f\n" % (fnode, tnode, length))
50 |
51 | for record in csv.DictReader(open(parameters.linkFile_int, "r")):
52 | fnode = int(record["FNODE_"])
53 | tnode = int(record["TNODE_"])
54 | length= float(record["LENGTH"])
55 | linkCSV.write("%d,%d,%f\n" % (fnode, tnode, length))
56 |
57 | linkCSV.close()
58 | nodeCSV.close()
59 |
60 | #############################################################################
61 |
--------------------------------------------------------------------------------
/scripts/cmapMAZLUShare.py:
--------------------------------------------------------------------------------
1 | #############################################################################
2 | # Shortest Path code for CMAP non-motorized modes
3 | # Roshan Kumar, kumarr1@pbworld.com, 12/20/2012
4 | #############################################################################
5 |
6 | #Should always be placed in the same folder as SPwrapper.py
7 |
8 | import math
9 | #import random
10 | import sys
11 | #import pickle
12 | import csv
13 | import os
14 | #import pdb
15 | from collections import defaultdict
16 | from heapq import heapify, heappop, heappush
17 | from array import *
18 | #import numpy as np
19 | import shapefile
20 | import parameters
21 |
22 | #############################################################################
23 |
24 | def getLandUseShare():
25 |
26 | result = {}
27 | #count1 = {}
28 | for i in range(16820):
29 | result[i] = []
30 | #count1[i] = 0
31 | fileName = parameters.mazLUFile
32 | line = 0
33 | for fields in csv.DictReader(open(fileName, "r")):
34 | line += 1
35 | mazId = int(fields["MAZ_ID"])
36 | lu1 = float(fields["LU_1"])
37 | lu2 = float(fields["LU_2"])
38 | lu3 = float(fields["LU_3"])
39 | lu4 = float(fields["LU_4"])
40 | lu5 = float(fields["LU_5"])
41 | lu6 = float(fields["LU_6"])
42 | lu7 = float(fields["LU_7"])
43 | lu8 = float(fields["LU_8"])
44 | lu9 = float(fields["LU_9"])
45 | lu10 = float(fields["LU_10"])
46 | lu11 = float(fields["LU_11"])
47 | lu12 = float(fields["LU_12"])
48 |
49 |
50 | if mazId == 0:
51 | continue
52 |
53 | result[mazId].append(lu1)
54 | result[mazId].append(lu2)
55 | result[mazId].append(lu3)
56 | result[mazId].append(lu4)
57 | result[mazId].append(lu5)
58 | result[mazId].append(lu6)
59 | result[mazId].append(lu7)
60 | result[mazId].append(lu8)
61 | result[mazId].append(lu9)
62 | result[mazId].append(lu10)
63 | result[mazId].append(lu11)
64 | result[mazId].append(lu12)
65 |
66 | #count1[mazId] = count1[mazId]+1
67 |
68 | result = dict([(k,v) for k,v in result.items() if len(v)>0])
69 |
70 | #print count1[2504]
71 | #print result[2504][1]
72 |
73 | return result
74 |
75 | #############################################################################
76 |
77 | def getMAZaroundNodes():
78 |
79 | result = {}
80 | #count1 = {}
81 | #for i in range(95141329):
82 | #result[i] = []
83 | #count1[i] = 0
84 | fileName = parameters.nodesinMAZFile
85 | line = 0
86 | for fields in csv.DictReader(open(fileName, "r")):
87 |
88 | mazId = int(fields["MAZ_ID_9"])
89 | nodes = int(fields["Nodes"])
90 | result[nodes] = []
91 |
92 | for fields in csv.DictReader(open(fileName, "r")):
93 |
94 | mazId = int(fields["MAZ_ID_9"])
95 | nodes = int(fields["Nodes"])
96 |
97 |
98 |
99 | if mazId == 0:
100 | continue
101 |
102 | result[nodes].append(mazId)
103 | #count1[mazId] = count1[mazId]+1
104 |
105 | result = dict([(k,v) for k,v in result.items() if len(v)>0])
106 | #print result[904259084][1]
107 |
108 | return result
109 |
110 | getLandUseShare()
111 | getMAZaroundNodes()
112 |
--------------------------------------------------------------------------------
/scripts/cmapParallelPP.py:
--------------------------------------------------------------------------------
1 | #############################################################################
2 | # Shortest Path code for CMAP non-motorized modes
3 | # Roshan Kumar, kumarr1@pbworld.com, 12/20/2012
4 | #############################################################################
5 |
6 | #Should always be placed in the same folder as SPwrapper.py
7 |
8 | #The multiple CSVs generated by the SP script are conflated into one CSV
9 |
10 | import parameters
11 | import os
12 |
13 | #############################################################################
14 |
15 | def parallelPostProcess():
16 | try:
17 | f = open(parameters.outputSPFile, "w")
18 | #f.write('"Origin","Destin","SP","Euclid","Ratio","nearHwy","nearHwyDist","LU_1","LU_2","LU_3","LU_4","LU_5","LU_6","LU_7","LU_8","LU_9","LU_10","LU_11","LU_12"\n')
19 | f.write('"Origin","Destin","SP","Euclid","Ratio"\n')
20 |
21 | processNo = 1
22 | while processNo<=parameters.number_of_cores:
23 | fileNo = "%s_" % (processNo)
24 | fileN = fileNo+"_test_parallel_SP.txt"
25 | #print fileN
26 | inputFile = os.path.join(parameters.root, parameters.int_output, fileN)
27 | #print inputFile
28 | with open(inputFile, "r") as file1:
29 | old = file1.read()
30 | f.write(old)
31 | processNo = processNo+1
32 | f.close()
33 | except IOError:
34 | pass
35 |
--------------------------------------------------------------------------------
/scripts/cmapPostProcess.py:
--------------------------------------------------------------------------------
1 | #############################################################################
2 | # Shortest Path code for CMAP non-motorized modes
3 | # Roshan Kumar, kumarr1@pbworld.com, 12/20/2012
4 | #############################################################################
5 |
6 | #Should always be placed in the same folder as SPwrapper.py
7 |
8 | #Wrapper code that post processes the SP output
9 |
10 | import parameters
11 | import cmapParallelPP
12 | if parameters.isBaseYear:
13 | import cmapRStoSubZone
14 | else:
15 | import cmapRStoSubZone_future
16 |
17 | cmapParallelPP.parallelPostProcess()
18 | cmapRStoSubZone.rsToSubZone()
19 |
--------------------------------------------------------------------------------
/scripts/cmapRStoSubZone.py:
--------------------------------------------------------------------------------
1 | #############################################################################
2 | # Shortest Path code for CMAP non-motorized modes
3 | # Roshan Kumar, kumarr1@pbworld.com, 12/20/2012
4 | #############################################################################
5 |
6 | #Should always be placed in the same folder as SPwrapper.py
7 |
8 | #Post-processes the output to exclude all TAP-TAP paths
9 |
10 | import math
11 | #import random
12 | import sys
13 | #import pickle
14 | import csv
15 | import os
16 | #import pdb
17 | from collections import defaultdict
18 | from heapq import heapify, heappop, heappush
19 | from array import *
20 | #import numpy as np
21 | import shapefile
22 | import parameters
23 |
24 | #############################################################################
25 |
26 | def rsToSubZone():
27 | output = open(parameters.spMAZ2TAP, "w")
28 | output.write('"Origin","Destin","SP","Euclid","Ratio"\n')
29 |
30 | szForTap = {}
31 | for fields in csv.DictReader(open(parameters.tapFile, "r")):
32 | tap_id = int(fields["tap_id"])
33 | sz09 = int(fields["maz09"])
34 | szForTap[tap_id] = sz09
35 | count_ = 1
36 | for fields in csv.DictReader(open(parameters.outputSPFile, "r")):
37 | origin = int(fields["Origin"])
38 | destin = int(fields["Destin"])
39 | sp = float(fields["SP"])
40 | euclid = float(fields["Euclid"])
41 | ratio = float(fields["Ratio"])
42 | if destin > parameters.minTAPID:
43 | try:
44 | if origin == szForTap[destin]:
45 | sp = euclid
46 | count_ = count_+1
47 | except KeyError:
48 | pass
49 |
50 |
51 |
52 | if (origin+destin parameters.minTAPID:
67 | try:
68 | if origin == szForTap[destin]:
69 | sp = euclid
70 | count_ = count_+1
71 | except KeyError:
72 | pass
73 |
74 | if (origin