This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def build_report_data | |
@counts_audience = Array.new(UPPER_FREQUENCY_LIMIT, 0) | |
@reaches = Array.new(UPPER_FREQUENCY_LIMIT, 0) | |
@cumulative_counts = Array.new(UPPER_FREQUENCY_LIMIT, 0) | |
@cumulative_reaches = Array.new(UPPER_FREQUENCY_LIMIT, 0) | |
@reaches_market_discrete = Array.new(UPPER_FREQUENCY_LIMIT, 0) | |
@total_contacts = 0 | |
position = self.counts.length - 1 | |
total_counts = 0 | |
cached_potentials = potentials |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// SETUP CODE | |
// ALPHA < 0, BETA > 0? | |
bool has_min_deterrence = (alpha < 0 && beta > 0); | |
float turn_cost, min_utility = 0.0; | |
if (has_min_deterrence) | |
{ | |
turn_cost = -alpha / beta; | |
min_utility = beta * turn_cost + alpha * log(turn_cost); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
for (int col = 0; col < numCentroids; ++col) | |
{ | |
float skim_value = skim_row[col]; | |
if (attractions.at(col) == 0 || skim_value == 99999) | |
{ | |
utilities.at(col) = 99999; | |
continue; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def get_link_loads(data_hash, pmturis) | |
Logger.showProgress('Getting link loads', data_hash){|(linknr, direction), _| | |
pmturis.each{|pmturi| | |
load = $Ot.network.get_load(pmturi, linknr, direction) | |
data_hash[[linknr, direction]][pmturi] = load | |
} | |
} | |
data_hash | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'utils/gis/link_to_polygon_converter' | |
require 'utils/gis/tab_file_writer' | |
def kml_output | |
links_to_export = get_links_to_export('LinkType', [15,16,17,19]) # [linknr1, linknr2, ...] | |
links = OtSpatialReader.new.readLinks.reject { |linknr, _| !links_to_export.include?(linknr) } | |
polygons_by_linknr = links.map_values { |line| LinkToPolygonConverter.translate(line, $Ot.project.city) } | |
polygons_by_linknr_dirn = polygons_by_linknr.each_with_object({}) { |(linknr, (poly1,poly2)), memo| | |
memo[[linknr, 1]] = poly1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ULONG_MAX = 4294967295 | |
zones = (1..5).to_a | |
times = [1212, 1213, 1214, 1215, | |
1312, 1313, 1314, 1315, | |
1412, 1413, 1414, 1415, | |
1512, 1513, 1514, 1515] | |
purposes = (1001..1060).to_a | |
num_cars = [0,1,2,3] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Note that if any data required to determine the type of person is missing then person type = :missing | |
if [study_type, employment_status, other_activity].all? { |e| e == :missing } | |
:missing | |
elsif study_type == :primary_school | |
:primary_school | |
elsif study_type == :secondary_school | |
:secondary_school | |
elsif employment_status == :full_time | |
if study_type == :no_study || study_type == :missing | |
white_or_blue == :white ? :full_time_white_collar_worker : :full_time_blue_collar_worker |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
changes = {# Authorised Kahuna Data Kahuna_valid Archived | |
Selection.status_pending => [SiteAuthorisation::ALTERED, true, false, false], | |
Selection.status_null_no_data_ => [SiteAuthorisation::AUTHORISED, false, false, false], | |
Selection.status_reject_new_ => [SiteAuthorisation::REJECTED, false, false, false], | |
Selection.status_reject_change_ => [SiteAuthorisation::REJECTED, true, false, false], | |
Selection.status_current => [SiteAuthorisation::AUTHORISED, true, true, false], | |
Selection.status_archived_has_data_ => [SiteAuthorisation::AUTHORISED, true, true, true], | |
Selection.status_archived_no_data_ => [SiteAuthorisation::ALTERED, false, false, true], | |
Selection.status_new => [SiteAuthorisation::ALTERED, false, false, false], | |
Selection.status_altered => [SiteAuthorisation::ALTERED, false, false, false], |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require 'date' | |
warn,crit=30.0,35.0 | |
while a = ARGV.shift | |
if a == "-w" | |
warn = ARGV.shift.to_f | |
elsif a == "-c" | |
crit = ARGV.shift.to_f | |
end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
" Ruby | |
autocmd FileType ruby noremap <leader>r :w<cr>:!ruby % <cr> | |
" Functional tests | |
autocmd FileType scala noremap <leader>t :w<cr>:!sbt test<cr> | |
autocmd FileType haskell noremap <leader>r :w<cr>:!ghc % -o run_me<cr>:!./run_me<cr> | |
autocmd FileType haskell noremap <leader>t :w<cr>:!doctest %<cr> | |
autocmd FileType haskell noremap <buffer> <F2> :GhcModType<CR> | |
autocmd FileType haskell noremap <buffer> <silent> <F3> :GhcModTypeClear<CR> | |
autocmd FileType haskell noremap <leader>T :w<CR>:GhcModTypeInsert<CR> |