Alternaria
fit cylinders and ellipsoids to fungus
|
00001 /* 00002 * This work is licensed under a Creative Commons 00003 * Attribution-Noncommercial-Share Alike 3.0 United States License. 00004 * 00005 * http://creativecommons.org/licenses/by-nc-sa/3.0/us/ 00006 * 00007 * You are free: 00008 * 00009 * to Share - to copy, distribute, display, and perform the work 00010 * to Remix - to make derivative works 00011 * 00012 * Under the following conditions: 00013 * 00014 * Attribution. You must attribute the work in the manner specified by the 00015 * author or licensor (but not in any way that suggests that they endorse you 00016 * or your use of the work). 00017 * 00018 * Noncommercial. You may not use this work for commercial purposes. 00019 * 00020 * Share Alike. If you alter, transform, or build upon this work, you may 00021 * distribute the resulting work only under the same or similar license to 00022 * this one. 00023 * 00024 * For any reuse or distribution, you must make clear to others the license 00025 * terms of this work. The best way to do this is by including this header. 00026 * 00027 * Any of the above conditions can be waived if you get permission from the 00028 * copyright holder. 00029 * 00030 * Apart from the remix rights granted under this license, nothing in this 00031 * license impairs or restricts the author's moral rights. 00032 */ 00033 00034 00046 #ifndef ALTERNARIA_MOVES_H 00047 #define ALTERNARIA_MOVES_H 00048 00049 00050 #include <config.h> 00051 00052 #include <inttypes.h> 00053 00054 #include <jwsc++/base/exception.h> 00055 00056 #include "sampler.h" 00057 00058 00065 class Apical_hypha_birth_death_move : public Sampler_jump_move 00066 { 00067 public: 00068 00070 Apical_hypha_birth_death_move 00071 ( 00072 const char* birth_name, 00073 const char* death_name, 00074 double birth_prob=1.0, 00075 double death_prob=1.0 00076 ) 00077 throw (jwscxx::base::Arg_error) 00078 : Sampler_jump_move(birth_name, death_name, birth_prob, death_prob) { } 00079 00080 00082 bool run_1(Sampler_move_parameters* params) 00083 throw (jwscxx::base::Exception); 00084 00085 00087 bool run_2(Sampler_move_parameters* params) 00088 throw (jwscxx::base::Exception); 00089 }; 00090 00091 00098 class Lateral_hypha_birth_death_move : public Sampler_jump_move 00099 { 00100 public: 00101 00103 Lateral_hypha_birth_death_move 00104 ( 00105 const char* birth_name, 00106 const char* death_name, 00107 double birth_prob=1.0, 00108 double death_prob=1.0 00109 ) 00110 throw (jwscxx::base::Arg_error) 00111 : Sampler_jump_move(birth_name, death_name, birth_prob, death_prob) { } 00112 00113 00115 bool run_1(Sampler_move_parameters* params) 00116 throw (jwscxx::base::Exception); 00117 00118 00120 bool run_2(Sampler_move_parameters* params) 00121 throw (jwscxx::base::Exception); 00122 }; 00123 00124 00131 class Spore_birth_death_move : public Sampler_jump_move 00132 { 00133 public: 00134 00136 Spore_birth_death_move 00137 ( 00138 const char* birth_name, 00139 const char* death_name, 00140 double birth_prob=1.0, 00141 double death_prob=1.0 00142 ) 00143 throw (jwscxx::base::Arg_error) 00144 : Sampler_jump_move(birth_name, death_name, birth_prob, death_prob) { } 00145 00146 00148 bool run_1(Sampler_move_parameters* params) 00149 throw (jwscxx::base::Exception); 00150 00151 00153 bool run_2(Sampler_move_parameters* params) 00154 throw (jwscxx::base::Exception); 00155 }; 00156 00157 00164 class Spore_transition_apical_move : public Sampler_jump_move 00165 { 00166 public: 00167 00169 Spore_transition_apical_move 00170 ( 00171 const char* apical_to_spore_name, 00172 const char* spore_to_apical_name, 00173 double apical_to_spore_prob=1.0, 00174 double spore_to_apical_prob=1.0 00175 ) 00176 throw (jwscxx::base::Arg_error) 00177 : Sampler_jump_move(apical_to_spore_name, spore_to_apical_name, 00178 apical_to_spore_prob, spore_to_apical_prob) { } 00179 00180 00185 bool run_1(Sampler_move_parameters* params) 00186 throw (jwscxx::base::Exception); 00187 00188 00193 bool run_2(Sampler_move_parameters* params) 00194 throw (jwscxx::base::Exception); 00195 }; 00196 00197 00204 class Spore_split_merge_2_apical_move : public Sampler_jump_move 00205 { 00206 public: 00207 00209 Spore_split_merge_2_apical_move 00210 ( 00211 const char* split_name, 00212 const char* merge_name, 00213 double split_prob=1.0, 00214 double merge_prob=1.0 00215 ) 00216 throw (jwscxx::base::Arg_error) 00217 : Sampler_jump_move(split_name, merge_name, split_prob, merge_prob) { } 00218 00219 00224 bool run_1(Sampler_move_parameters* params) 00225 throw (jwscxx::base::Exception); 00226 00227 00232 bool run_2(Sampler_move_parameters* params) 00233 throw (jwscxx::base::Exception); 00234 00235 00236 protected: 00237 00239 static void propose_1st_split 00240 ( 00241 Apical_hypha** proposal_out, 00242 double* log_prob_out, 00243 const Apical_hypha_density* density, 00244 const Spore* spore 00245 ) 00246 throw (jwscxx::base::Arg_error); 00247 00248 00250 static void propose_2nd_split 00251 ( 00252 Apical_hypha** proposal_out, 00253 double* log_prob_out, 00254 const Apical_hypha* split_1 00255 ) 00256 throw (jwscxx::base::Arg_error); 00257 00259 static void propose_merge 00260 ( 00261 Spore** proposal_out, 00262 double* log_prob_out, 00263 const Structure* parent, 00264 const Spore_density* density, 00265 const Apical_hypha* hypha_1, 00266 const Apical_hypha* hypha_2 00267 ) 00268 throw (jwscxx::base::Arg_error); 00269 }; 00270 00271 00272 00273 00280 class Spore_split_merge_spore_move : public Sampler_jump_move 00281 { 00282 public: 00283 00285 Spore_split_merge_spore_move 00286 ( 00287 const char* split_name, 00288 const char* merge_name, 00289 double split_prob=1.0, 00290 double merge_prob=1.0 00291 ) 00292 throw (jwscxx::base::Arg_error) 00293 : Sampler_jump_move(split_name, merge_name, split_prob, merge_prob) { } 00294 00295 00297 bool run_1(Sampler_move_parameters* params) 00298 throw (jwscxx::base::Exception); 00299 00300 00302 bool run_2(Sampler_move_parameters* params) 00303 throw (jwscxx::base::Exception); 00304 00305 00306 protected: 00307 00309 static void propose_1st_split 00310 ( 00311 Spore** proposal_out, 00312 double* log_prob_out, 00313 const Spore* spore 00314 ) 00315 throw (jwscxx::base::Arg_error); 00316 00317 00319 static void propose_2nd_split 00320 ( 00321 Spore** proposal_out, 00322 double* log_prob_out, 00323 const Spore* split_1 00324 ) 00325 throw (jwscxx::base::Arg_error); 00326 00328 static void propose_merge 00329 ( 00330 Spore** proposal_out, 00331 double* log_prob_out, 00332 const Structure* parent, 00333 const Spore* hypha_1, 00334 const Spore* hypha_2 00335 ) 00336 throw (jwscxx::base::Arg_error); 00337 }; 00338 00339 00340 00341 00342 // TODO Spore_split_merge_apical_move 00343 00344 00345 // TODO Apical_hypha_split_merge_spore_move 00346 00347 00354 class Apical_hypha_split_merge_apical_move : public Sampler_jump_move 00355 { 00356 public: 00357 00359 Apical_hypha_split_merge_apical_move 00360 ( 00361 const char* split_name, 00362 const char* merge_name, 00363 double split_prob=1.0, 00364 double merge_prob=1.0 00365 ) 00366 throw (jwscxx::base::Arg_error) 00367 : Sampler_jump_move(split_name, merge_name, split_prob, merge_prob) { } 00368 00369 00371 bool run_1(Sampler_move_parameters* params) 00372 throw (jwscxx::base::Exception); 00373 00374 00376 bool run_2(Sampler_move_parameters* params) 00377 throw (jwscxx::base::Exception); 00378 00379 00380 protected: 00381 00383 static void propose_1st_split 00384 ( 00385 Apical_hypha** proposal_out, 00386 double* log_prob_out, 00387 const Apical_hypha* hypha 00388 ) 00389 throw (jwscxx::base::Arg_error); 00390 00391 00393 static void propose_2nd_split 00394 ( 00395 Apical_hypha** proposal_out, 00396 double* log_prob_out, 00397 const Apical_hypha* split_1 00398 ) 00399 throw (jwscxx::base::Arg_error); 00400 00402 static void propose_merge 00403 ( 00404 Apical_hypha** proposal_out, 00405 double* log_prob_out, 00406 const Structure* parent, 00407 const Apical_hypha* hypha_1, 00408 const Apical_hypha* hypha_2 00409 ) 00410 throw (jwscxx::base::Arg_error); 00411 }; 00412 00413 00420 class Apical_hypha_split_merge_lateral_move : public Sampler_jump_move 00421 { 00422 public: 00423 00425 Apical_hypha_split_merge_lateral_move 00426 ( 00427 const char* split_name, 00428 const char* merge_name, 00429 double split_prob=1.0, 00430 double merge_prob=1.0 00431 ) 00432 throw (jwscxx::base::Arg_error) 00433 : Sampler_jump_move(split_name, merge_name, split_prob, merge_prob) { } 00434 00435 00437 bool run_1(Sampler_move_parameters* params) 00438 throw (jwscxx::base::Exception); 00439 00440 00442 bool run_2(Sampler_move_parameters* params) 00443 throw (jwscxx::base::Exception); 00444 00445 00446 protected: 00447 00449 static void propose_1st_split 00450 ( 00451 Apical_hypha** proposal_out, 00452 double* log_prob_out, 00453 const Apical_hypha* hypha 00454 ) 00455 throw (jwscxx::base::Arg_error); 00456 00457 00459 static void propose_2nd_split 00460 ( 00461 Lateral_hypha** proposal_out, 00462 double* log_prob_out, 00463 const Apical_hypha* split_1, 00464 const Lateral_hypha_density* density 00465 ); 00466 00468 static void propose_merge 00469 ( 00470 Apical_hypha** proposal_out, 00471 double* log_prob_out, 00472 const Structure* parent, 00473 const Apical_hypha* hypha_1, 00474 const Lateral_hypha* hypha_2 00475 ) 00476 throw (jwscxx::base::Arg_error); 00477 }; 00478 00479 00485 class Structure_resize_move : public Sampler_diffusion_move 00486 { 00487 public: 00488 00490 Structure_resize_move(const char* name, double prob=1.0) 00491 throw (jwscxx::base::Arg_error) 00492 : Sampler_diffusion_move(name, prob) { } 00493 00494 00496 bool run(Sampler_move_parameters* params) 00497 throw (jwscxx::base::Exception); 00498 00499 00504 const std::ostringstream& get_info(Sampler_move_parameters* params); 00505 00506 00511 const std::ostringstream& get_proposal_info 00512 ( 00513 Sampler_move_parameters* params 00514 ); 00515 }; 00516 00517 00523 class Structure_rotate_move : public Sampler_diffusion_move 00524 { 00525 public: 00526 00528 Structure_rotate_move(const char* name, double prob=1.0) 00529 throw (jwscxx::base::Arg_error) 00530 : Sampler_diffusion_move(name, prob) { } 00531 00532 00534 bool run(Sampler_move_parameters* params) 00535 throw (jwscxx::base::Exception); 00536 00537 00542 const std::ostringstream& get_info(Sampler_move_parameters* params); 00543 00544 00549 const std::ostringstream& get_proposal_info 00550 ( 00551 Sampler_move_parameters* params 00552 ); 00553 }; 00554 00555 00561 class Structure_opacity_move : public Sampler_diffusion_move 00562 { 00563 public: 00564 00566 Structure_opacity_move(const char* name, double prob=1.0) 00567 throw (jwscxx::base::Arg_error) 00568 : Sampler_diffusion_move(name, prob) { } 00569 00570 00572 bool run(Sampler_move_parameters* params) 00573 throw (jwscxx::base::Exception); 00574 00575 00580 const std::ostringstream& get_info(Sampler_move_parameters* params); 00581 00582 00587 const std::ostringstream& get_proposal_info 00588 ( 00589 Sampler_move_parameters* params 00590 ); 00591 }; 00592 00593 00599 class Apical_structure_position_move : public Sampler_diffusion_move 00600 { 00601 public: 00602 00604 Apical_structure_position_move(const char* name, double prob=1.0) 00605 throw (jwscxx::base::Arg_error) 00606 : Sampler_diffusion_move(name, prob) { } 00607 00608 00610 bool run(Sampler_move_parameters* params) 00611 throw (jwscxx::base::Exception); 00612 00613 00618 const std::ostringstream& get_info(Sampler_move_parameters* params); 00619 00620 00625 const std::ostringstream& get_proposal_info 00626 ( 00627 Sampler_move_parameters* params 00628 ); 00629 }; 00630 00631 00638 class Lateral_structure_lat_dist_move : public Sampler_diffusion_move 00639 { 00640 public: 00641 00643 Lateral_structure_lat_dist_move(const char* name, double prob=1.0) 00644 throw (jwscxx::base::Arg_error) 00645 : Sampler_diffusion_move(name, prob) { } 00646 00647 00649 bool run(Sampler_move_parameters* params) 00650 throw (jwscxx::base::Exception); 00651 00652 00657 const std::ostringstream& get_info(Sampler_move_parameters* params); 00658 00659 00664 const std::ostringstream& get_proposal_info 00665 ( 00666 Sampler_move_parameters* params 00667 ); 00668 }; 00669 00670 00671 #endif