diff test-data/input/ALIEN-demo/farmer-plan_ALIEN-demo.txt @ 3:3fe3e1e6a40b draft

"planemo upload for repository https://forgemia.inra.fr/insilicow/insilicow-tool commit b530a8209615f225696abe3e0ba49093ff3dc4ad"
author siwaa
date Mon, 25 Aug 2025 16:37:43 +0000
parents
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test-data/input/ALIEN-demo/farmer-plan_ALIEN-demo.txt	Mon Aug 25 16:37:43 2025 +0000
@@ -0,0 +1,1032 @@
+#################################################################################################################
+#                                                                                                               #
+#	InSiliCow                                                                                               #
+#	Virtual farm specification                                                                              #
+#                                                                                                               #
+#################################################################################################################
+
+#################################################################################################################
+#====== GENERAL SETTINGS                                                                                        #
+#################################################################################################################
+
+#______ Include files  
+@include farmer-log.txt		# providing log action and trigger
+@include farmer-base.txt	# providing basic components
+
+#______ Models: specify models for individual cows
+param_general{
+	garuns_type   = garuns_olivier
+	rpm_type      = rpm_lite
+	abortion_type = abortion_olivier	
+}
+
+#______ Simulation: provide time range, output database and code name
+init{
+	begin_date  = $start_date$ 00:00:00
+	end_date    = $stop_date$ 23:59:59
+ 	output_db   = db_events.sqlite
+ 	output_config = config.txt
+ 	name        = $sim_id$
+}
+
+#______ Log Farm information
+link{
+  trigger = init
+  action = log_db farm_tag $farm_tag$
+  action = log_db start_date $start_date$
+  action = log_db stop_date $stop_date$
+  action = log_db now_date $now_date$
+  action = log_db latitude $latitude$
+  action = log_db longitude $longitude$
+}  
+
+#______ End of simulation
+trigger{
+  type   = chron
+  name   = tr_end_simu
+  scheme = $stop_date$ 23:59:58 
+}
+
+#______ Past and future
+condition{
+  type = chron_range
+  name = past
+  from = $start_date$ 00:00:00
+  to   = $now_date$ 00:00:01
+}
+
+condition{
+  type = chron_range
+  name = future
+  from = $now_date$ 00:00:00
+  to   = $stop_date$ 23:59:59
+}
+
+#______ Day one
+trigger{
+    type   = chron
+    name   = day_one_herd
+    scheme = $start_date$ 23:59:59
+}
+trigger{
+    type = custom
+    name = day_one
+}
+link{
+    trigger = day_one_herd
+    action  = broadcast_now day_one
+}
+
+#______ Calving tag
+link{
+    trigger = calving
+    condition = calf_sex male
+    condition = future
+    action = log_db birth_of_male no_tag
+}
+link{
+    trigger = calving
+    condition = calf_sex female
+    condition = future
+    action = log_db birth_of_female no_tag
+}
+
+#______ Manage initial dam
+state{
+  state = INITIAL-DAM
+}
+
+link{
+    trigger = day_one
+    action = state_add INITIAL-DAM
+}
+link{
+    trigger = parturition
+    condition = is_in INITIAL-DAM
+    condition = not is_in IN_WILD
+    action = trigger_later tr_delete_cow 1
+}
+trigger{
+  type     = custom
+  name     = tr_delete_cow
+}
+link{
+  trigger = tr_delete_cow
+  action  = delete_cow remove_initial_dam
+}
+
+#______ Stoechio
+stoechio{
+
+}
+
+#################################################################################################################
+#====== FARMING 												#
+#################################################################################################################
+
+#______ Keep cows and calves in farm: no natural mating
+
+link{
+  trigger    = enter IN_WILD
+  action     = state_move IN_WILD IN_FARM
+}
+
+link{
+  trigger    = enter WILD_COW
+  action     = state_move WILD_COW DRY_COW
+}
+
+#______ Remove calf from dam: no natural weaning
+
+link{
+  trigger    = enter SUCKLING_CALF
+  action     = state_move SUCKLING_CALF NURSED_CALF
+}
+
+#______ Milk cows: no natural drying-off at calf weaning
+
+link{
+  trigger    = enter NURSING_COW
+  action     = state_move NURSING_COW LACTATING_COW
+}
+
+#______ Optimal feeding
+
+link{
+  trigger    = enter IN_FARM
+  action  = trigger_later tr_optimal_feeding 0
+}
+trigger{
+   type = custom
+   name = tr_optimal_feeding
+}
+link{
+   trigger = tr_optimal_feeding
+   action = change_food optimal
+}
+
+
+#################################################################################################################
+#====== FARM COMPONENTS: genotype										#
+#################################################################################################################
+
+#______ Genetic_sD: provide Mendelian sampling std dev for transmission of Genetic Scaling Parameters (GSP)
+#	GSP_newborn ~ Normal [ (GSP_mother + GSP_father)/2 , GSP_sd ] | within (min, max)
+
+genetic_sd{
+	garuns_olivier.WM{   
+	  sd  = 50
+	  min = 200
+	  max = 800
+	}
+	
+	garuns_olivier.khi_M {
+	  sd  = 0.06
+	  min = 0.1 
+	  max = 0.6
+	}
+	
+	garuns_olivier.b0{
+	  sd  = 0
+	  min = 0.80
+	  max = 2.40
+	}
+	
+	garuns_olivier.nu_X{
+      	  sd  = 0
+	  min = 0.2
+	  max = 1.8
+	}
+	
+	garuns_olivier.nu_Y{
+	  sd  = 0.1
+	  min = 0.2
+	  max = 1.8
+	}
+	
+	garuns_olivier.nu_F{
+          sd  = 0
+	  min = 0.50
+	  max = 1.50
+	}
+	
+	garuns_olivier.nu_P{
+	  sd  = 0
+	  min = 0.50
+	  max = 1.50
+	}
+
+	garuns_olivier.eD_star{
+	  sd  =  0
+	  min =  9.0
+	  max = 15.0
+	}
+
+	garuns_olivier.NDF_star{
+	  sd  =  0
+	  min =  0.10
+	  max =  0.90
+	}
+
+	garuns_olivier.psi{
+	  sd  =  0
+	  min =  0
+	  max =  1
+	}
+
+	rpm_lite.nu_I{
+	  sd  =  0.007
+	  min =  0.00
+	  max =  0.20
+	}
+
+	rpm_lite.nu_B{
+	  sd  =  0.07
+	  min =  1.20
+	  max =  2.20
+	}
+
+	rpm_lite.nu_Z{
+	  sd  =  0.02
+	  min =  0.90
+	  max =  1.10
+	}
+}
+
+#################################################################################################################
+#====== FARM COMPONENTS: herd (genotype-based initialization of individual cows)				#
+#################################################################################################################
+
+#______ INITIALIZATION of ALIEN farm
+
+#______ Initial dam
+init_cow{
+    name=initial_dam
+    
+    ### ABORTION rules according to days in pregnancy (dip)
+    abortion_olivier.delta   = constant 3.0
+    abortion_olivier.enabled = never
+    abortion_olivier.dip =  vector constant 17 ; constant 64 
+    abortion_olivier.abo = vector constant 0.02  ;  constant 0.005 ; constant 0.0004
+    garuns_olivier.WM       =  norm99 450 	50	#450 	 ± 25
+    garuns_olivier.khi_M    =  norm99 0.30	0.03	#  0.33  ±  0.03
+    garuns_olivier.b0       =  norm99 1.6 	0	#  1.6   ±  0.16
+    garuns_olivier.nu_X     =  norm99 1		0	#  1.0   ±  0.10
+    garuns_olivier.nu_Y     =  norm99 1.1 	0.1	#  1.0   ±  0.10
+    garuns_olivier.nu_F     =  norm99 1		0	#  1.0   ±  0.02
+    garuns_olivier.nu_P     =  norm99 1		0	#  1.0   ±  0.02 
+    garuns_olivier.eD_star  =  norm99 10.7 	0	# 10.7   ±  0.5
+    garuns_olivier.NDF_star =  norm99 0.5	0	#  0.5   ±  0.02 
+    garuns_olivier.psi      =  norm99 0.5 0	
+              rpm_lite.nu_B =  norm99 1.7	0.07	#  1.7	 ±  0.07
+    	      rpm_lite.nu_Z =  norm99 1		0.02	#  1.0	 ±  0.02
+              rpm_lite.nu_I =  norm99 0.025	0.007	#  0.026 ±  0.007
+}
+
+#______ Initial sire
+init_bull{
+    name=semen_initial_sire
+    bull.breed_name     = dairy
+    bull.semens_quality = constant 1.0
+    bull.female_ratio   = constant 1.0   
+    garuns_olivier.WM       =  norm99 450 	50	#450 	 ± 25
+    garuns_olivier.khi_M    =  norm99 0.30	0.03	#  0.33  ±  0.03
+    garuns_olivier.b0       =  norm99 1.6 	0	#  1.6   ±  0.16
+    garuns_olivier.nu_X     =  norm99 1		0	#  1.0   ±  0.10
+    garuns_olivier.nu_Y     =  norm99 1.1 	0.1	#  1.0   ±  0.10
+    garuns_olivier.nu_F     =  norm99 1		0	#  1.0   ±  0.02
+    garuns_olivier.nu_P     =  norm99 1		0	#  1.0   ±  0.02 
+    garuns_olivier.eD_star  =  norm99 10.7 	0	# 10.7   ±  0.5
+    garuns_olivier.NDF_star =  norm99 0.5	0	#  0.5   ±  0.02 
+    garuns_olivier.psi      =  norm99 0.5 0	
+    rpm_lite.nu_B =  norm99 1.7	0.07	#  1.7	 ±  0.07
+    	      rpm_lite.nu_Z =  norm99 1		0.02	#  1.0	 ±  0.02
+              rpm_lite.nu_I =  norm99 0.025	0.007	#  0.026 ±  0.007
+}
+
+
+#______ Generate dams of each individual cow to create
+
+action{
+    type = buy_cow
+    name = buy_dam_of_id0001
+    init_cow = initial_dam 
+    init_bull = semen_initial_sire
+    age = 600
+    days_after_conception = -1
+    number = 1
+}
+
+action{
+    type = buy_cow
+    name = buy_dam_of_id0002
+    init_cow = initial_dam 
+    init_bull = semen_initial_sire
+    age = 600
+    days_after_conception = -30
+    number = 1
+}
+
+action{
+    type = buy_cow
+    name = buy_dam_of_id0003
+    init_cow = initial_dam 
+    init_bull = semen_initial_sire
+    age = 600
+    days_after_conception = -600
+    number = 1
+}
+
+link{
+    trigger = init
+    action = buy_dam_of_id0001
+    action = buy_dam_of_id0002
+    action = buy_dam_of_id0003
+}
+
+
+#################################################################################################################
+#====== FARM COMPONENTS: semen (genotype-based initialization of semen from individual bulls)			#
+#################################################################################################################
+
+# Only the semen of individual bulls is generated and used for insemination 
+
+breed{
+  breed = dairy
+  breed = beef
+}
+
+init_bull{
+    name=semen_dairy_standard
+    bull.breed_name     = dairy
+
+    ### QUALITY & SEX RATIO
+    bull.semens_quality = norm99 0.95 0.05      # a number between 0.0 (=never works) and 1.0 (=perfect)
+    bull.female_ratio   = constant 0.5  	# offspring sex ratio. 1.0 = 100%female,  0.0=0%female   
+
+    ### GARUNS & RPM_lite Genetic Scaling Parameters
+    #	Genotype sub-block (see genotype_generic.txt) 
+
+    garuns_olivier.WM       =  constant 450	#450 
+    garuns_olivier.khi_M    =  constant 0.30	#  0.33
+    garuns_olivier.b0       =  constant 1.6	#  1.6
+    garuns_olivier.nu_X     =  constant 1	#  1.0
+    garuns_olivier.nu_Y     =  constant 1.1	#  1.0
+    garuns_olivier.nu_F     =  constant 1	#  1.0
+    garuns_olivier.nu_P     =  constant 1	#  1.0
+    garuns_olivier.eD_star  =  constant 10.7	# 10.7
+    garuns_olivier.NDF_star =  constant 0.5	#  0.5   
+    garuns_olivier.psi      =  constant 0.5	
+    rpm_lite.nu_B =  constant 1.7	#  1.7
+    	      rpm_lite.nu_Z =  constant 1	#  1.0	
+              rpm_lite.nu_I =  constant 0.025	#  0.026
+}
+
+
+
+#################################################################################################################
+#====== FARM COMPONENTS: heat detection 									#
+#################################################################################################################
+
+#______ Estrous detection method
+estrous_detection_method{
+  name=estrous_detection_default
+
+  #When do we observe oestruses
+  time_slice = 06:00:00 18:00:00 #00:00:01 23:59:59 
+
+  #estrogene is transformed to an expression using a Hill function
+  expression_threshold=0.75 #default 0.75
+  expression_stiffness=7    #default 7
+
+  #the oestrus worth an insemination if the memory function is above this threshold
+  #THIS threshold is scaled for an observation all the day long
+  #if you observe half a day multiply this threshold by 0.5
+  #1.0 is a reasonable base value for all day observations
+  detection_threshold=0.05  # 0.1
+
+  #then, the oestrus is truely detected with a chance of
+  sensitivity = 0.75 #0.7
+
+  #then an average of wrong_oestrus_per_day are generated
+  wrong_oestrus_per_day = 0 #0.00
+}
+
+#################################################################################################################
+#====== FARM COMPONENTS: feedstuffs	 									#
+#################################################################################################################
+
+
+#################################################################################################################
+#====== FARM COMPONENTS: diets		 									#
+#################################################################################################################
+
+feed{
+   name = calf_diet
+   type = mix
+
+   feed = CPL.MLK
+   proportion = 1.00
+}
+
+feed{
+   name = heifer_diet
+   type = mix
+
+   feed = FO.STR
+   proportion = 0.02
+   feed = FO.HAP
+   proportion = 0.60
+   feed = FO.GSI
+   proportion = 0.32
+   feed = CO.CER
+   proportion = 0.05
+   feed = CPL.CMV
+   proportion = 0.01
+}
+
+feed{
+   name = lactation_diet
+   type = mix
+
+   feed = FO.STR
+   proportion = 0.01
+   feed = FO.HAP
+   proportion = 0.03
+   feed = FO.GSI
+   proportion = 0.04
+   feed = FO.CSI
+   proportion = 0.70
+   feed = CO.CER
+   proportion = 0.05
+   feed = CO.OSC
+   proportion = 0.13
+   feed = CO.ROO
+   proportion = 0.03
+   feed = CPL.CMV
+   proportion = 0.01
+}
+
+feed{
+   name = drycow_diet
+   type = mix
+
+   feed = FO.STR
+   proportion = 0.02
+   feed = FO.HAP
+   proportion = 0.68
+   feed = FO.CSI
+   proportion = 0.08
+   feed = CO.CER
+   proportion = 0.05
+   feed = CO.OSC
+   proportion = 0.13
+   feed = CO.ROO
+   proportion = 0.03
+   feed = CPL.CMV
+   proportion = 0.01
+}
+
+feed{
+   name = pasture_diet
+   type = mix
+
+   feed = FO.FGX
+   proportion = 0.778
+   feed = CO.CER
+   proportion = 0.050
+   feed = CO.OSC
+   proportion = 0.130
+   feed = CO.TUB
+   proportion = 0.002
+   feed = CO.ROO
+   proportion = 0.030
+   feed = CPL.CMV
+   proportion = 0.010
+}
+
+
+
+
+#################################################################################################################
+#====== FARM COMPONENTS: time schemes	 									#
+#################################################################################################################
+
+
+
+#_______Breeding season: every year from *-03-21 00:00:00 to *-06-21 23:59:59
+
+condition{
+  type = chron_range
+  name = breeding_season
+  from = *-03-21 00:00:00	#date_breeding_start
+  to   = *-06-21 23:59:59	#date_breeding_stop
+}
+
+trigger{
+  type = chron
+  name = breeding_start
+  scheme = *-03-21 00:00:00	#date_breeding_start
+}
+
+trigger{
+  type = chron
+  name = breeding_stop
+  scheme = *-06-21 23:59:59	#date_breeding_stop
+}
+
+#_______Outdoor date
+
+trigger{
+  type      = chron
+  name      = outdoor_herd
+  scheme    = *-04-01 00:00:00 
+}
+trigger{
+  type = custom
+  name = outdoor
+}
+link{
+  trigger = outdoor_herd
+  action  = broadcast_now outdoor
+}
+
+#_______Indoor date
+
+trigger{
+  type      = chron
+  name      = indoor_herd
+  scheme    = *-10-01 00:00:00 
+}
+trigger{
+  type = custom
+  name = indoor
+}
+link{
+  trigger = indoor_herd
+  action  = broadcast_now indoor
+}
+
+
+
+
+#################################################################################################################
+#====== FARM COMPONENTS: groups		 									#
+#################################################################################################################
+
+state{
+  state = REARED_CALF
+  state = WEANED_HEIFER
+  state = UNEXPECTED_PREGNANT
+  state = INSEMINATED
+  state = EXPECTED_PREGNANT
+  state = EXPECTED_TO_CALVE
+  state = CALVED
+  state = TO_BREED
+  state = TO_CULL
+}
+
+action{
+  type = genericlog
+  name = log_states_user
+  
+  log_type     = sqlite
+  sqlite_path  = db_states.sqlite
+  sqlite_table = user_states 
+  
+  #log_type    = file
+  #file_path   = states-user.txt
+  #sep_col     = \t
+  #file_line_flush=no
+
+
+  #--- from cow and simulator ---
+  column{
+     value       = time
+     name        = time
+     sqlite_type = numeric
+  }
+  
+  column{
+     value       = state.count.REARED_CALF
+     name        = REARED_CALF
+     sqlite_type = numeric
+  }
+
+  column{
+     value       = state.count.WEANED_HEIFER
+     name        = WEANED_HEIFER
+     sqlite_type = numeric
+  }
+
+  column{
+     value       = state.count.UNEXPECTED_PREGNANT
+     name        = UNEXPECTED_PREGNANT
+     sqlite_type = numeric
+  }
+
+  column{
+     value       = state.count.INSEMINATED
+     name        = INSEMINATED
+     sqlite_type = numeric
+  }
+
+  column{
+     value       = state.count.EXPECTED_PREGNANT
+     name        = EXPECTED_PREGNANT
+     sqlite_type = numeric
+  }
+
+  column{
+     value       = state.count.EXPECTED_TO_CALVE
+     name        = EXPECTED_TO_CALVE
+     sqlite_type = numeric
+  }
+
+  column{
+     value       = state.count.CALVED
+     name        = CALVED
+     sqlite_type = numeric
+  }
+
+  column{
+     value       = state.count.TO_BREED
+     name        = TO_BREED
+     sqlite_type = numeric
+  }
+
+  column{
+     value       = state.count.TO_CULL
+     name        = TO_CULL
+     sqlite_type = numeric
+  }
+
+}
+
+link{
+  trigger = every_day_herd
+  action = log_states_user
+}
+
+#################################################################################################################
+#====== FARM COMPONENTS: operations	 									#
+#################################################################################################################
+
+
+#______ Rear calves at 6 d
+
+trigger{
+  type = custom
+  name = tr_rear_calf
+}
+
+link{
+   trigger = enter NURSED_CALF
+   action  = trigger_later tr_rear_calf 6 
+}
+
+link{
+  trigger = tr_rear_calf
+  action  = state_add REARED_CALF
+}
+
+#______ Sell calves according to calf pen capacity
+
+link{
+  trigger    = every_day
+  condition  = state_size REARED_CALF > 25	#calf_pen_capacity
+  action     = sell_calves
+}
+
+trigger{
+  type = custom
+  name = tr_sell_calves
+}
+
+action{
+  type      = broadcast_now
+  name      = sell_calves
+  condition = is_in REARED_CALF
+  sortby    = age
+  reverse   = no
+  limit     = 1
+  trigger   = tr_sell_calves
+}
+
+link{
+  trigger = tr_sell_calves
+  action = state_delete REARED_CALF
+  action  = delete_cow sale of calves
+}
+
+#______ Wean calves at 100 days
+
+link{
+  trigger    = every_day
+  condition  = age >= 100
+  action     = state_move REARED_CALF WEANED_HEIFER
+}
+
+#______ Open breeding
+link{
+  trigger    = every_day
+  condition  = age > 450				#breeding_age
+  condition  = breeding_season
+  action     = state_move WEANED_HEIFER UNEXPECTED_PREGNANT
+  action     = state_move TO_BREED UNEXPECTED_PREGNANT
+  action     = state_move EXPECTED_TO_CALVE UNEXPECTED_PREGNANT
+}
+
+#______ Start estrous detection
+
+link{
+  trigger    = enter UNEXPECTED_PREGNANT
+  action     = estrous_start estrous_detection_default
+}
+
+#______ Detect estrous
+
+link{
+  trigger   = estrous
+  condition = is_in IN_FARM
+  action    = state_move EXPECTED_PREGNANT UNEXPECTED_PREGNANT
+}
+
+#______ Inseminate once a day when estrous is detected
+
+trigger{
+  type = custom
+  name = tr_move_to_EXPECTED_PREGNANT
+}
+
+link{
+  trigger = tr_move_to_EXPECTED_PREGNANT
+  action = state_move INSEMINATED EXPECTED_PREGNANT
+}
+
+link{
+  trigger   = estrous
+  condition = is_in IN_FARM
+  condition  = future
+  condition = is_in UNEXPECTED_PREGNANT
+  action    = state_move UNEXPECTED_PREGNANT INSEMINATED
+  action    = trigger_later tr_move_to_EXPECTED_PREGNANT 1
+  action    = log_db 01_INSEMINATION
+  action    = inseminate semen_dairy_standard
+}
+
+#______ Close breeding
+link{
+  trigger    = every_day
+  condition = is_in IN_FARM
+  condition  = not breeding_season
+  action     = state_move EXPECTED_PREGNANT EXPECTED_TO_CALVE
+  action     = state_move INSEMINATED EXPECTED_TO_CALVE
+  action     = estrous_stop
+}
+
+link{
+  trigger   = every_day
+  condition = is_in IN_FARM
+  condition = is_in UNEXPECTED_PREGNANT
+  condition = not breeding_season
+  action    = state_move UNEXPECTED_PREGNANT TO_CULL
+  action    = log_db delete_cow: unexpected pregnant at the end of breeding season  
+  action    = estrous_stop
+}
+
+
+
+
+
+
+
+#_______ Postpartum management
+
+trigger{
+  type = custom
+  name = tr_postpartum
+}
+
+link{
+  trigger    = parturition
+  action     = state_move EXPECTED_TO_CALVE CALVED
+  action     = trigger_later tr_postpartum 40			# VWP
+ }
+
+link{
+  trigger = tr_postpartum
+  action  = state_move CALVED TO_BREED
+}
+
+#_______ Late abortion  management
+
+#Abortions after 210 days in pregnancy are managed by culling   
+link{
+  trigger    = abortion
+  condition  = days_after_conception > 210
+  #action     = log_db TO_CULL_from_PREGNANT_after_late_fetal_death
+  action      = log_db delete_cow: after fetal death > 210 days
+  action     = state_move EXPECTED_PREGNANT TO_CULL  
+  action     = state_move EXPECTED_TO_CALVE TO_CULL
+}
+
+#_______ Drying-off after 305 days in milk if cow is expected to calve
+
+link{
+  trigger   = every_day
+  condition = is_in IN_FARM
+  condition = is_milking
+  condition = is_in EXPECTED_TO_CALVE 
+  condition = days_after_calving >= 305
+  action    = stop_milking
+  action    = log_db stop_milking: pregnant & days_after_calving >= 305 days
+
+}
+
+#_______ Drying-off if milk yield < 5 kg/d
+
+link{
+  trigger   = every_day
+  condition = is_in IN_FARM
+  condition = is_milking
+  condition = milk_yield < 5
+  action    = stop_milking
+  action    = log_db stop_milking: milk_yield < 5 kg/d
+
+}
+
+#_______ Remove non-milking cows to cull
+
+link{
+  trigger   = every_week
+  condition = is_in TO_CULL
+  condition = not is_milking
+##  				#condition = not is_pregnant
+  #action     = log_db Remove_ojm
+  action    = delete_cow every week
+}
+
+#_______ Individual pregnancy diagnosis 28 days after insemination
+
+trigger{
+  type = custom
+  name = tr_cow_pregnancy_diagnosis
+}
+
+link{
+  trigger   = insemination
+  condition = is_in IN_FARM
+  action    = trigger_later tr_cow_pregnancy_diagnosis 28
+}
+
+link{
+  trigger    = tr_cow_pregnancy_diagnosis
+  condition = is_in IN_FARM
+  condition = is_in EXPECTED_PREGNANT
+  condition = not is_pregnant
+  action    = state_move EXPECTED_PREGNANT UNEXPECTED_PREGNANT
+}
+
+link{
+  trigger    = tr_cow_pregnancy_diagnosis
+  condition = is_in IN_FARM
+  condition = is_in EXPECTED_TO_CALVE
+  condition = not is_pregnant
+  action    = state_move EXPECTED_TO_CALVE TO_CULL
+  action     = log_db delete_cow: Negative cow pregnancy diagnosis
+}
+
+
+#_______ Herd pregnancy diagnosis 45 days after end of breeding season
+
+trigger{
+  type = custom
+  name = tr_herd_pregnancy_diagnosis
+}
+
+link{
+  trigger = breeding_stop 
+  action  = trigger_later tr_herd_pregnancy_diagnosis 45
+}
+
+link{
+  trigger = tr_herd_pregnancy_diagnosis
+#  action     = log_db Herd_pregnancy_diagnosis
+  action  = broadcast_now tr_cow_pregnancy_diagnosis
+}
+
+#______ Culling rules during breeding season: Cull unexpected pregnant nulliparous at age > 800 days
+
+link{
+  trigger    = enter UNEXPECTED_PREGNANT
+  condition  = parity = 0
+  condition  = age > 800				          #nulliparous_max_breeding_age
+  #action    = log_db TO_CULL_from_CYCLING_because_too_old_heifer
+  action     = state_move UNEXPECTED_PREGNANT TO_CULL
+  action     = log_db delete_cow: heifer of age > 800 days 
+}
+
+#______ Culling rules during breeding season: Cull unexpected pregnant 320 days_after_calving
+link{
+  trigger    = enter UNEXPECTED_PREGNANT
+  condition  = days_after_calving > 320
+  #action    = log_db TO_CULL_from_CYCLING_because_too_late_after_calving
+  action     = log_db delete_cow: days after calving > 320 days
+  action     = state_move UNEXPECTED_PREGNANT TO_CULL
+}
+
+#______ Culling rules during breeding season: Cull unexpected pregnant after 5 inseminations
+link{
+  trigger    = enter UNEXPECTED_PREGNANT
+  condition  = parity > 0
+  condition  = num_insemination_lactation >= 5
+  #action     = log_db TO_CULL_from_BREEDING_max_nb_ins
+  action     = log_db delete_cow: nb of insemination >= 5
+  action     = state_move UNEXPECTED_PREGNANT TO_CULL
+}
+
+#______ Stop estrous detection of cows to cull
+
+link{
+  trigger    = enter TO_CULL
+  action     = estrous_stop
+}
+
+
+#______ Feeding plan according to groups # > at rearing: on calf diet
+link{
+    trigger   = enter REARED_CALF
+    action    = change_food calf_diet
+}
+
+# > at weaning: on heifer diet
+link{
+  trigger   = enter WEANED_HEIFER
+    action    = change_food heifer_diet
+}
+
+# > at parturition: on lactation diet
+link{
+  trigger   = parturition
+  action    = change_food lactation_diet
+}
+
+# > at drying-off: on drycow_diet
+link{
+  trigger   = stop_milking
+  action    = change_food drycow_diet
+}
+
+# > OUTDOOR: on pasture diet
+link{
+  trigger   = outdoor
+  condition = not is_in REARED_CALF
+  action    = change_food pasture_diet
+}
+
+# > INDOOR: back to diet according to state
+
+link{
+  trigger   = indoor
+  condition = is_in WEANED_HEIFER
+  action    = change_food heifer_diet
+}
+
+link{
+  trigger   = indoor
+  condition = not is_milking
+  action    = change_food drycow_diet
+}
+
+link{
+  trigger   = indoor
+  condition = is_milking
+  action    = change_food lactation_diet
+}
+
+
+#______ Veal production / use semen from meat breed if expected pregnant > calf_pen_capacity
+
+#______ Detect high producing cows > use high-grade semen > rear preferentially high-grade calves  (=Renewal)
+
+#______ Use extended lactation
+
+#______ Cull oldest cow 
+
+
+#################################################################################################################
+#====== FARM COMPONENTS: transfers	 									#
+#################################################################################################################
+
+
+#################################################################################################################
+#====== FARM COMPONENTS: perturbations	 									#
+#################################################################################################################
+
+
+#################################################################################################################
+#====== FARM COMPONENTS: parcels	 									#
+#################################################################################################################
+
+