-
Notifications
You must be signed in to change notification settings - Fork 3
Multiple ignition points #89
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 5 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -18,6 +18,7 @@ __maintainer__ = "Jaime Carrasco, Cristobal Pais, David Woodruff, David Palacios | |
|
|
||
| // Include libraries | ||
| #include <omp.h> | ||
| #include <typeinfo> | ||
| #include <stdio.h> | ||
| #include <stdlib.h> | ||
| #include <string> | ||
|
|
@@ -48,6 +49,7 @@ std::unordered_map<int, std::vector<float>> BBOFactors; | |
| std::unordered_map<int, std::vector<int>> HarvestedCells; | ||
| std::vector<int> NFTypesCells; | ||
| std::unordered_map<int,int> IgnitionHistory; | ||
| std::vector<int> initialPoints; | ||
|
|
||
| /****************************************************************************** | ||
| Utils | ||
|
|
@@ -289,7 +291,7 @@ Cell2Fire::Cell2Fire(arguments _args) : CSVWeather(_args.InFolder + "Weather.csv | |
| std::vector<int> IgnitionPoints; | ||
|
|
||
| if(this->args.Ignitions){ | ||
| //DEBUGstd::cout << "\nWe have specific ignition points:" << std::endl; | ||
| //DEBUG std::cout << "\nWe have specific ignition points:" << std::endl; | ||
|
|
||
| /* Ignition points */ | ||
| std::string ignitionFile = args.InFolder + "Ignitions.csv"; | ||
|
|
@@ -310,9 +312,11 @@ Cell2Fire::Cell2Fire(arguments _args) : CSVWeather(_args.InFolder + "Weather.csv | |
|
|
||
| // Ignition points | ||
| this->IgnitionPoints = std::vector<int>(IgnitionYears, 0); | ||
| //std::cout << this->IgnitionPoints[1] << std::endl; | ||
|
|
||
| CSVIgnitions.parseIgnitionDF(this->IgnitionPoints, IgnitionsDF, IgnitionYears); | ||
| //this->IgnitionSets = std::vector<unordered_set<int>>(this->IgnitionPoints.size()); | ||
| this->IgnitionSets = std::vector<std::vector<int>>(this->args.TotalYears); | ||
| this->IgnitionSets = std::vector<std::vector<int>>(args.TotalYears); | ||
|
|
||
|
|
||
| // Ignition radius | ||
|
|
@@ -780,7 +784,7 @@ bool Cell2Fire::RunIgnition(std::default_random_engine generator, int ep){ | |
| std::uniform_int_distribution<int> distribution(1, this->nCells); | ||
|
|
||
| // No Ignitions provided | ||
| if (this->args.Ignitions == 0) { | ||
| if (this->args.Ignitions == "random" || this->args.Ignitions == 0) { | ||
| while (true) { | ||
| microloops = 0; | ||
| while (true) { | ||
|
|
@@ -849,8 +853,19 @@ bool Cell2Fire::RunIgnition(std::default_random_engine generator, int ep){ | |
| } | ||
|
|
||
| // Ignitions with provided points from CSV | ||
| else { | ||
| int temp = IgnitionPoints[this->year-1]; | ||
| else if (args.Ignitions == "raster") { | ||
|
|
||
| if (initialPoints.empty()) { | ||
| initialPoints = this->IgnitionPoints; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. agregar identación |
||
| } | ||
|
|
||
| std::random_device dev; | ||
| std::mt19937 rng(dev()); | ||
| std::uniform_int_distribution<std::mt19937::result_type> dist(1,initialPoints.size()); | ||
| int rd = dist(rng); | ||
|
|
||
| int temp = initialPoints[rd-1]; | ||
| initialPoints.erase(initialPoints.begin() + rd-1); | ||
|
|
||
| // If ignition Radius != 0, sample from the Radius set | ||
| if (this->args.IgnitionRadius > 0){ | ||
|
|
@@ -908,7 +923,10 @@ bool Cell2Fire::RunIgnition(std::default_random_engine generator, int ep){ | |
|
|
||
| } | ||
|
|
||
|
|
||
| else { | ||
| std::cerr << "Error: ignition mode not found" << std::endl; | ||
| return; | ||
| } | ||
|
|
||
|
|
||
| // If ignition occurs, we update the forest status | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,5 @@ | ||
| Year,Ncell | ||
| 1,205 | ||
| 1,305 | ||
| 2,350 | ||
| 3,100 | ||
| 4,380 |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -18,21 +18,22 @@ set -x # enable debug tracing | |
| # run | ||
| for format in asc tif; do | ||
| for model in fbp kitral sb; do | ||
| echo running $model-$format | ||
| output_folder=test_results/$model-$format | ||
| mkdir -p $output_folder | ||
| rm -rf $output_folder/* | ||
| if [ "$model" == "fbp" ]; then | ||
| additional_args="--cros" | ||
| sim_code="C" | ||
| elif [ "$model" == "sb" ]; then | ||
| additional_args="--scenario 1" | ||
| sim_code="S" | ||
| elif [ "$model" == "kitral" ]; then | ||
| additional_args="" | ||
| sim_code="K" | ||
| fi | ||
| Cell2Fire$1 --input-instance-folder model/$model-$format --output-folder $output_folder --nsims 113 --output-messages --grids --out-ros --out-intensity --sim ${sim_code} --seed 123 --ignitionsLog $additional_args > test_results/$model-$format/log.txt | ||
| for ignition_mode in random raster; do | ||
| echo running $model-$format | ||
| output_folder=test_results/$model-$format | ||
| mkdir -p $output_folder | ||
| rm -rf $output_folder/* | ||
| if [ "$model" == "fbp" ]; then | ||
| additional_args="--cros" | ||
| sim_code="C" | ||
| elif [ "$model" == "sb" ]; then | ||
| additional_args="--scenario 1" | ||
| sim_code="S" | ||
| elif [ "$model" == "kitral" ]; then | ||
| additional_args="" | ||
| sim_code="K" | ||
| fi | ||
| Cell2Fire$1 --input-instance-folder model/$model-$format --output-folder $output_folder --nsims 113 --ignitions-$ignition_mode --output-messages --grids --out-ros --out-intensity --sim ${sim_code} --seed 123 --ignitionsLog $additional_args > test_results/$model-$format-$ignition_mode/log.txt | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. El ignition mode tiene que ser el adecuado para que funcione el test. Aparte hay que hacer un chequeo del funcionamiento de los puntos múltiples. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @matiasuno Resolviste esto? |
||
| done | ||
| done | ||
| set +x # disable debug tracing | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
El tipo de Ignition actualmente es Bool, tiene que pasarse a string.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@matiasuno hiciste este cambio?