scripts/icm_scenario_generator/scenario_generator.rb
# create_scenario generates a single new scenario and applies parameter changes
# based an array of modifications passed into the function. This method is called
# in a loop to create many scenarios.
# 
# Example:
#   modifications = [
#       {"param"=>"p_area_1", "name"=>"p1", "table"=>"hw_land_use", "id"=>"12430", "value"=>0.3}, 
#       {"param"=>"p_area_2", "name"=>"p2", "table"=>"hw_land_use", "id"=>"12430", "value"=>10}, 
#       {"param"=>"percolation_coefficient", "name"=>"pc", "table"=>"hw_ground_infiltration", "value"=>10},
#   ]
#
#  Will create a scenario with the name:
#   p1=0.3_p2=10_pc=10
#
#  With the following modifications on the scenario
#   p_area_1 = 0.3     percolation_coefficient = 10 
#   p_area_2 = 10 
#
create_scenario generates a single new scenario and applies parameter changes
based an array of modifications passed into the function. This method is called
in a loop to create many scenarios.



Will create a scenario with the name:
p1=0.3_p2=10_pc=10

With the following modifications on the scenario
p_area_1 = 0.3     percolation_coefficient = 10
p_area_2 = 10
create_scenario generates a single new scenario and applies parameter changes based an array of modifications passed into the function . This method is called in a loop to create many scenarios . Will create a scenario with the name : p1 = 0 . 3_p2 = 10_pc = 10 With the following modifications on the scenario p_area_1 = 0 . 3 percolation_coefficient = 10 p_area_2 = 10
def create_scenario(modifications, net)
    scenario_name = create_scenario_name(modifications)
    net.add_scenario(scenario_name,nil,'') 
    puts " *** Creating scenario #{scenario_name}"
    net.current_scenario=scenario_name
	net.clear_selection
	net.transaction_begin
    modifications.each do |mod|
        param, name, table, id, value = mod.values_at("param", "name", "table", "id", "value")
        puts "    -  id: #{id}, table: #{table}, param: #{param}, value: #{value}"
        row_obj = net.row_object(table,id)
        row_obj[param] = value
        row_obj.write
    end
    net.transaction_commit
	net.validate(scenario_name)
end
def create_scenario ( modifications , net ) scenario_name = create_scenario_name ( modifications ) net . add_scenario ( scenario_name , nil , '' ) puts " *** Creating scenario #{scenario_name}" net . current_scenario = scenario_name net . clear_selection net . transaction_begin modifications . each do | mod | param , name , table , id , value = mod . values_at ( "param" , "name" , "table" , "id" , "value" ) puts "    -  id: #{id}, table: #{table}, param: #{param}, value: #{value}" row_obj = net . row_object ( table , id ) row_obj [ param ] = value row_obj . write end net . transaction_commit net . validate ( scenario_name ) end
create_scenario generates a single new scenario and applies parameter changes
based an array of modifications passed into the function.
create_scenario generates a single new scenario and applies parameter changes based an array of modifications passed into the function .
# Loop through each of the modifications and update the row object in the database
modifications
<not_specific>
net
<not_specific>