Jellyfish generation detection algorithm

Introduction

When I snorkeled in the sea last year, the engineer I took with me was extremely afraid of jellyfish. Occasionally, poisonous jellyfish came out, and when I passed in front of me, I was terrified.

For me, who loves the sea, this feels like a terrible situation. I thought about a process that tells me when jellyfish are likely to occur.

First, personally organize the nature of the jellyfish (see wiki)

The nature of jellyfish

First I checked

・ If you do not create a stream of water, it will gradually sink to the bottom of the water. → Gradually weakens and leads to death ・ Frequently preyed on by penguins ・ The action of jellyfish poison on the human body varies greatly depending on the type of jellyfish. ・ Portuguese man-of-war, box jellyfish, and chironex flecker are dangerous ・ In Japan, if you go swimming at the beach after Obon, you will be bitten by a jellyfish. → Timing when jellyfish grow up to be adults ・ The water temperature when breeding jellyfish is about 25 ℃. → Die at 30 degrees ・ Because the water temperature is high until about October, jellyfish are likely to occur. ・ It is difficult to occur during strong winds (strong winds, typhoons, etc.) ・ It is difficult to occur in places where the tide is strong. ・ Activity period is from mid-August to October → When the sea temperature is high ・ If the water temperature is low, jellyfish are unlikely to occur. ・ Even when the seawater temperature is the highest, jellyfish will be present until around 7 am It has not reached the temperature at which it is easy to work. ・ When you hear the screw sound of the ship, there are many high-pitched sounds. It is believed to stop the movement of jellyfish ・ When 95% or more of the body of a jellyfish contains water → fresh water Sink to the bottom of the sea

I tried to organize the properties quantitatively

・ Jellyfish are vulnerable to high temperatures → The appearance rate is low when the water temperature is 27 ° C to 30 ° C.

·rainy percent → The closer it is to 100%, the less likely it is to appear → Hypothesis that it is unlikely to appear during the rainy season

・ The appearance rate is high from 8/11 to 10/1 → Timing when jellyfish become adults

・ The slower the ocean current, the lower the occurrence of jellyfish. → 1 knot ≒ 0.5m / s → 1 nautical mile (1852m) per hour → If there is no water flow, it will sink to the bottom

・ If the salinity of seawater is low, it will sink to the bottom of the sea. → Because the salinity of 34-35ppt is suitable for growth No more than 36ppt

Organize on an implementation basis

conditions

・ Temperature: 27 ≤ Current temperature ≤ 30

・ Precipitation probability: 50% ≤ current temperature ≤ 100%

・ Danger period: 8/11 ≤ current date ≤ 10/1

・ Ocean current: 1.5 ≧ Current ocean current

・ Salinity: 36ppt ≤ current concentration

・ The quality of each judgment is Boolean judgment

Judgment method

Although it is an original standard, the judgment result is output below

conditions ① Let's go to the sea with a clear feeling without worrying about jellyfish!  (true,false,false,true,true) ・ Temperature: 27 ≤ Current temperature ≤ 30 ・ Precipitation probability: 0% -40% ・ Danger period: 8/11 ≤ current date ≤ other than 10/1 ・ Ocean current: 1.5 ≧ Current ocean current ・ Salinity: 36ppt ≤ current concentration

② It will rain overcast, but no jellyfish will appear! (true,true,false,true,true) ・ Temperature: 27 ≤ Current temperature ≤ 30 ・ Probability of precipitation: 50% to 100% ・ Danger period: 8/11 ≤ current date ≤ other than 10/1 ・ Ocean current: 1.5 ≧ Current ocean current ・ Salinity: 36ppt ≤ current concentration

③ Almost all jellyfish come out. Let's mess around at home. (false,false,true,false,false) ・ 27 ≧ Current temperature ・ Precipitation probability: 0-40% ・ Danger period: 8/11 ≤ current date ≤ 10/1 ・ Ocean current: 1.5 <Current ocean current ・ Salinity <36ppt

③ The basics will come out! However, it may not appear.

★ Condition 1 (true, false, true, true, true) ・ Temperature: 27 ≤ Current temperature ≤ 30 ・ Precipitation probability: 0% -40% ・ Ocean current: 1.5 ≧ Current ocean current ・ Salinity: 36ppt ≤ current concentration     or ★ Condition 2 (true, false, true, true, true) ・ Temperature: 27 ≧ Current temperature ・ Precipitation probability: 0% -40% ・ Ocean current: 1.5 ≧ Current ocean current ・ Salinity: 36ppt ≤ current concentration     or ★ Condition 3 (true, false, true, true, true) ・ Temperature: 27 ≤ Current temperature ≤ 30 ・ Precipitation probability: 0% -40% ・ Current: Current current ≧ 1.5 ・ Salinity: 36ppt ≤ current concentration    or ★ Condition 4 (true, false, true, true, true) ・ Temperature: 27 ≤ Current temperature ≤ 30 ・ Precipitation probability: 0% -40% ・ Ocean current: 1.5 ≧ Current ocean current ・ Salinity: Current concentration <36ppt

Implemented program (finally ...)

JellyFishAlert.java


import java.time.LocalDateTime;
import java.util.Arrays;
import java.util.Calendar;
import java.util.function.Function;

public class JellyFishAlert {

	public static void main(String[] args) {
		
		//Command line arguments(temperature,rainy percent,Ocean current judgment,Salinity judgment)
		if(args.length == 4) {
			System.out.println("The value required for the calculation is OK!");
		}else {
			System.out.println("Specify the command line arguments correctly");
			System.exit(0);
		}

		//Generate judgment map(The notation of a to g is shit. .. )
		boolean a[] = {true,false,false,true,true};
		boolean b[] = {true,true,false,true,true};
		boolean c[] = {false,false,true,false,false};
		boolean d[] = {true,false,true,true,true};
		boolean e[] = {true,false,true,true,true};
		boolean f[] = {true,false,true,true,true};
		boolean g[] = {true,false,true,true,true};

		//Temperature judgment
		Function<Integer, Boolean> is_temperature = (tmperature) -> {
  			return tmperature >= 27 && tmperature <= 30 ? true : false;
		};
		
		//Precipitation probability judgment
		Function<Integer, Boolean> is_rainy_percent = (rainy_percent) -> {
  			return rainy_percent >= 50 && rainy_percent <= 100 ? true : false;
		};
		
		//Danger period judgment
		Function<LocalDateTime, Boolean> is_jellyfish_danger_date = (now) -> {
			Calendar cTime = Calendar.getInstance();
  			return now.isBefore(LocalDateTime.of(cTime.get(Calendar.YEAR), 8, 11, 0, 0)) 
  					&& now.isAfter(LocalDateTime.of(cTime.get(Calendar.YEAR), 10, 1, 23, 59)) ? true : false;
		};
		
		//Ocean current judgment
		Function<Integer, Boolean> is_ocean_current = (current_knot) -> {
  			return  current_knot <= 1.5 ? true : false;
		};

		//Salinity judgment
		Function<Integer, Boolean> is_salinity = (current_salinity) -> {
  			return  current_salinity >= 36 ? true : false;
		};
		
		//Current sea conditions (temperature)/rainy percent/dangerous day/Ocean current/Salinity)
		boolean state_of_sea[] = {is_temperature.apply(Integer.valueOf(args[0])),
				is_rainy_percent.apply(Integer.valueOf(args[1])),
				is_jellyfish_danger_date.apply(LocalDateTime.now()),
				is_ocean_current.apply(Integer.valueOf(args[2])),
				is_salinity.apply(Integer.valueOf(args[3]))
		};		
		
		//Judgment of correspondence to jellyfish
		if(Arrays.equals(a,state_of_sea)) {
			System.out.println(JellyFishDangerStatus.NODANGER.status);
		}else if (Arrays.equals(b,state_of_sea)){
			System.out.println(JellyFishDangerStatus.LOWDANGER.status);
		}else if (Arrays.equals(c,state_of_sea)) {
			System.out.println(JellyFishDangerStatus.HIGHTDANGER.status);
		}else if(Arrays.equals(d,state_of_sea) 
				|| Arrays.equals(e,state_of_sea) 
				|| Arrays.equals(f,state_of_sea)
				|| Arrays.equals(g,state_of_sea)) {
			System.out.println(JellyFishDangerStatus.MIDDLEDANGER.status);
		}else {
			System.out.println(JellyFishDangerStatus.UNKNOWNDANGER.status);
		}
	}
	
	public enum JellyFishDangerStatus {
        NODANGER("Let's go to the sea with a clear feeling without worrying about jellyfish!"),
        LOWDANGER("It rains overcast, but no jellyfish will definitely appear!"),
        HIGHTDANGER("Most of the jellyfish come out. Let's mess around at home."),
        MIDDLEDANGER("The basics will come out! However, it may not appear."),
		UNKNOWNDANGER("Unpredictable. Get away from the sea promptly.");

        private final String status;

        private JellyFishDangerStatus(String status) {
        this.status = status;
        }

        public String getStatus() {
            return this.status;
        }
    }
}

At the end

I've spent most of my time looking up jellyfish information. ..

It is not possible to defeat jellyfish with such a thing, but I hope it can help create a situation where the general public is not afraid of jellyfish. I would like to do further research in the future. It would be great if it could be incorporated into an underwater drone.

Recommended Posts

Jellyfish generation detection algorithm
Poisson stepper step detection algorithm
Algorithm generation automation using genetic algorithms