You are on page 1of 79

P1 - Optimizing pathfinding and

terrain maneuverability through


minefields
- Optimizing clearance and moveability in minefields -

Project Report
cs-23-dat-1-p1-05

Aalborg University
Institute for Computer Science
Computer Science
Aalborg University
http://www.aau.dk

Title: Abstract:
P1 - Optimizing pathfinding
and terrain maneuverability Through an analysis of the problem of mine-
through minefields fields, the study concludes that the cost-
effectiveness of landmines for military use
Theme: presents a global challenge. This paper
Optimizing clearance and presents a proposal for a software solution in-
moveability in minefields tended to reduce the efficiency of landmines
by using Dijkstra’s pathfinding algorithm to
Project Period: find the optimal path through a minefield,
Fall Semester 2023 given certain conditions. The program devel-
oped includes dynamic world data in the form
Project Group: of bitmaps, such as mine probabilities, water
cs-23-dat-1-p1-05 depth and vegetation densities among other
factors, and produces a layered and config-
Participant(s): ured matrix to be used by the pathfinding al-
Andreas Lynnerup gorithm. The accuracy and reliability of our
Jesper Dahl Andersen proposed solution in the real world depend
Lukas Saltenis on the quantity and quality of data available.
Patrick Kaas Reiffenstein, Based on the assumption that a computer pro-
Rasmus Hende Svenson gram is more capable of consistently analyzing
Thomas Høy Bowman multiple data sources and thereby can predict
the location of mines and improve pathfinding
Supervisor(s):
faster than humans, we posit that our solution
Dennis Juhl Østergaard
mitigates the effectiveness of landmines, thus
Copies: 1 decreasing the consequences of their use.

Page Numbers: 75

Date of Completion:
December 20, 2023

The content of this report is freely available, but publication (with reference) may only be pursued due to
agreement with the author.
Contents

1 Introduction 1

2 Problem Analysis 2
2.1 Mines . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
2.1.1 Types of Mines . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
2.1.2 The Purpose of Mines . . . . . . . . . . . . . . . . . . . . . . . 4
2.2 Consequences of landmine usage . . . . . . . . . . . . . . . . . . . . . 5
2.2.1 Environmental consequences . . . . . . . . . . . . . . . . . . . 5
2.2.2 Humanitarian consequences . . . . . . . . . . . . . . . . . . . 7
2.2.3 Military consequences . . . . . . . . . . . . . . . . . . . . . . . 9
2.2.4 Ethics and priorities . . . . . . . . . . . . . . . . . . . . . . . . 10
2.3 Possible solutions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
2.3.1 Demining . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
2.3.2 Detection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
2.3.3 Maneuvering . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
2.4 Problem Formulation . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15

3 Terrain Analysis 16

4 Technology Analysis 20
4.1 Data Collection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
4.2 Compilation of Accumulated Data . . . . . . . . . . . . . . . . . . . . 21
4.2.1 The problematic low reliability of detection methods . . . . . 22
4.2.2 Combining data to increase accuracy . . . . . . . . . . . . . . 22
4.2.3 The design of Matrices . . . . . . . . . . . . . . . . . . . . . . . 23
4.3 Pathfinding Algorithms . . . . . . . . . . . . . . . . . . . . . . . . . . 24
4.3.1 BFS and DFS . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
4.3.2 Dijkstra’s algorithm and A* . . . . . . . . . . . . . . . . . . . . 25

5 Program design 28
5.1 Matrix Initialization Overview . . . . . . . . . . . . . . . . . . . . . . 30
5.1.1 Specification of expected format . . . . . . . . . . . . . . . . . 30
5.1.2 Import of Expected Format into C Matrix . . . . . . . . . . . . 30
5.2 Data Pre-processing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
5.2.1 User Settings . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31

iii
iv Contents

5.2.2 Pre-defined Settings . . . . . . . . . . . . . . . . . . . . . . . . 31


5.2.3 Matrix Configurations . . . . . . . . . . . . . . . . . . . . . . . 32
5.2.4 Combining Matrices . . . . . . . . . . . . . . . . . . . . . . . . 32
5.3 Pathfinding Algortihm . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
5.3.1 Choice of Algorithm . . . . . . . . . . . . . . . . . . . . . . . . 33
5.3.2 Design of Algorithm . . . . . . . . . . . . . . . . . . . . . . . . 34
5.4 Visualization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38
5.4.1 Understanding the rationale for visualization . . . . . . . . . 38
5.4.2 Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38

6 Implementation 41
6.1 User Settings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41
6.2 Import of Mock Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45
6.3 Matrix Configurations . . . . . . . . . . . . . . . . . . . . . . . . . . . 50
6.4 Data Processing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52
6.5 Dijkstra’s algorithm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53
6.6 Visualization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57

7 Example of a Full Program Run 63

8 Conclusion 66

9 Discussion 67
9.1 Regarding the use of mock data . . . . . . . . . . . . . . . . . . . . . 68
9.2 Regarding lack of functionality . . . . . . . . . . . . . . . . . . . . . . 69
9.3 Regarding reliability and usefulness . . . . . . . . . . . . . . . . . . . 69

Bibliography 71
Chapter 1

Introduction

Warfare has been commonplace throughout history. Efforts to prevent and stop
wars have been made continuously, yet wars are still being fought. Currently,
wars are being waged between Russia and Ukraine, who both have seen a signif-
icant loss of lives, similar to the conflict between Hamas and Israel in the Gaza
strip[40][30]. In turn countries have tried to discourage the conflict.

Apart from the obvious safety risk for civilians vulnerable to being caught in
the crossfire during confrontations, other weapons, such as landmines, present
a passive but equally dangerous situation for both military personnel and civil-
ians. The use of such weapons has seen a surge since the invasion by Russia in
Ukraine[53], which is a tragic occurrence since landmines annually claim thou-
sands of casualties including the lives of civilians and children. Furthermore,
landmines result in the desertion of otherwise habitable areas and can cause the
permanent migration of refugees unable or unwilling to return to their homelands.

While the attempt to prevent the use of firearms during wars is difficult, this
report investigates the possibility of decreasing the use of landmines, to reduce
their negative consequences both during and after conflicts. Efforts to ban and de-
crease the use of landmines are prevalent, including international agreements such
as the Ottawa convention, which has been signed by the majority of states globally,
even though not all have ratified it[36]. Organisations such as the ICBL (Interna-
tional Campaign to Ban Landmines), also fight to mitigate the consequences of
landmines. Still, the cost-effectiveness of landmines result in little to no incentive
for major military powers to withhold from utilizing landmines.

This project will examine the potential for a software solution to contribute to
a reduction in the prevalence of landmines. Through an assessment of landmines
in a global context, as well as the efforts made by international agreements and
organizations like the ICBL, the aim is to objectively evaluate the role of technol-
ogy, specifically a software solution, in mitigating the adverse consequences of
landmines during and after conflicts.

1
Chapter 2

Problem Analysis

2.1 Mines
The term ’mine’ stems from the latin word ’mina’, which originally meant ’vein of
ore’. Essentially, it stems from the act of digging ores and minerals up from the
ground. Later, mines were adopted by the military branch as a tool and strategy to
aid in sieges of strongholds and fortresses, where armies would mine underneath
buildings and fortresses to make them collapse[39]. Our modern and current
understanding of mines, however, are of hidden stationary devices with explosive
capabilities, and the implications of this technology has resulted in further uses
for mines, outside merely the collapsing of buildings [14].
An important distinction to make is that mines are stationary explosive devices
that are positioned and thereafter await a signal to explode, compared to bombs
which are containers for explosive charges that often detonate upon contact, such
as when it hits the surface after being dropped from an airplane[13]. Grenades are
a hybrid of the two, whereby a soldier activates a fuse thus awaiting explosion,
but it can still be thrown and is therefore not stationary.

’Mine’ is a general term for a variety of stationary explosives There are, how-
ever, several subcategories of mines each with their own purpose and function
and each with their own intended targets.

2
2.1. Mines 3

2.1.1 Types of Mines


Mines can at the most general level be categorized into 2 types: Land mines and
naval mines (or submarine mines). Furthermore, land mines can either be anti-
tank or anti-personnel with regards to their intended target[14]. Our report fo-
cuses on landmines specifically.

Naval mines, also known as submarine mines, are sphere-shaped containers


filled with both air and explosives, as well as a type of sensor that activates the
explosives. The air inside the container is necessary to make the sphere float in
the water, albeit the sphere is anchored to the floor. There are different types of
sensors used for naval mines, however the most common sensors are contact rods
sticking out, awaiting the touch of an underwater vessel before exploding[14].
Other types of sensors include magnetic, pressure and acoustic/sound sensors.
In general, naval mines have been highly effective in both the first and second
World War. In the second, the Allies lost 1118 vessels or ships to mines, and the
Allies themselves laid out more than 550.000 naval mines[14]. Naval mines were
predominantly used to block off waters either offensively or defensively. More on
this in section 2.1.2. Mines were the most effective submarine weapon available
during the World Wars[14].

With more than 110 million active landmines worldwide [28], the global issue
of landmines becomes apparent. The most affected countries are especially Middle
Eastern countries. Egypt has an estimated 23 million active mines mostly leading
up to its borders [28]. Furthermore, Angola has 15 million active mines, Iran has
16 million mines, Afghanistan, Iraq and China have 10 million active landmines
respectively. These are the countries that have the largest estimated amount of
mines.[28] Some of these mines only target vehicles or tanks crossing a terrain
and these are called anti-tank mines, while other mines are intended to harm
individual military soldiers when stepped on - anti-personnel. The threshold for
activation is obviously different for each of these mines, as well as the impact of
the explosion.
Anti-personnel mines were used significantly during guerilla wars, such as the
Vietnam war and the war in Afghanistan, especially by the guerilla and uncon-
ventional military forces forces[14]. Unfortunately, a large amount of these mines
that were placed during the wars are still stationed and hidden in the ground in
the affected areas. Although efforts have been made to clear these mines, several
thousand civilians die each year from mines left behind from conflicts and wars.
More detailed information on this under the section 2.2.2
In 1997, an international agreement named "The 1997 Convention on the Prohibi-
tion of the Use, Stockpiling, Production and Transfer of Anti-Personnel Mines and on their
Destruction"[36] was an international complete ban on the production and use of
anti-personnel mines, also known as the Ottawa Convention. All but 31 countries
have signed and ratified this agreement in their respective legislation, however
countries such as Iran, Russia, Syria, Vietnam, Israel, Saudi Arabia, China, and
4 Chapter 2. Problem Analysis

even the United States have not yet signed or ratified the agreement[33]. The rea-
son for banning anti-personnel landmines is due to the large amounts of areas
that are both restricted due to conflicts of the past, as well as being a danger zone
for civilians who may risk activating these mines. Anti-tank mines, however, are
not targeted towards individual civilians, thus they do not pose as significant a
danger for these persons, and these are and have been produced in much smaller
numbers due to the amount of explosives within them and the cost of producing
them.
With the ongoing conflicts between Ukraine and Russia, as well Hamas and Is-
rael at the time of this reports writing, the discussion on the use of anti-personnel
landmines is very much relevant, since both Russia and Israel have yet to agree
to the Ottawa convention. Safe to say the use and application of anti-personnel
mines is a controversial issue even in the world today.

2.1.2 The Purpose of Mines


The use of mines, at the surface level, serves the same purpose as many other
weapons during war. The aim is to drain or remove resources from the countries
one would be at war with. As stated earlier the use of mines can take many forms,
be that naval mines or landmines, and they can either be used in a defensive
setting, an offensive setting or a combination of the two.
Defensively the purpose of a mine takes on the role of restricting movement
and protecting important areas including military structures, borders, bridges and
harbours from opposing forces.[29] A defensive use of mines could be to block
off an entrance to the harbor from one side, so as to deter the opposition from
entering.
Offensively, mines have the purpose of harming forces, such as anti-personnel
and anti-vehicle mines, as discussed in section 2.1.1. These mines also restrict the
movement of enemy forces, and are also used to funnel said forces to preferred
areas that may be under their control.[29] Placing mines outside an enemy harbor
would be an offensive placement of mines to target the ships and vessels leaving
the harbor.
It is important to note that mines both defensively and offensively are specifi-
cally designed to maim a soldier as opposed to killing them. The reason for this is
that it is assumed more resources will be spent caring for an injured soldier, rather
than dealing with one who has been killed[29]. Mines used in modern wars are
generally intended to force the opponents to drain their resources in order to get
through a minefield, or force them to take a detour. On the same matter, it is in fact
illegal to use expanding or explosive bullets in firearms during wars, or at least
goes against the Hague convention and agreement from 1899-1907[15]. Projectiles
that expand upon impact create a much greater and vile wound, thus it would
kill much more effectively. This is why expanding projectiles are used for hunting
and not war, and vice versa, since the kill rate for ordinary projectiles is lower
than for expanding projectiles. Using projectiles that do not explode or expand
2.2. Consequences of landmine usage 5

means that soldiers will more often be severely injured as opposed to dead, thus
requiring more resources trying to save said soldier. But of course, from a hu-
mane perspective, it is preferable to make enemy soldiers functionally incapable
of fighting, instead of killing them, hence the existence of the Hague convention.
Landmines do not only target military but also civilians, both unintentionally
and intentionally. Unintentionally because civilians have the possibility to find
themselves in the middle of a minefield stemming from warfare, either present or
past, and as a consequence can step on such mines. Intentionally they are used to
limit access to farmland or in general terrorize populations[29]. Removing mines is
time consuming and costly, as removing a mine drains the rival nation’s resources,
costing about 100 to 333 times as much as is spent on producing a mine[11].

A significant problem caused by the use of mines is that said military and
country in a given war tend to stop marking and mapping minefields during long
conflicts. Combatants even stop laying mines in specific patterns leaving leftover
mines after the war, with no method of efficiently locating these weapons[29]. This
has consequences for the generations to come, consequences that are explored in
the next section.

2.2 Consequences of landmine usage


2.2.1 Environmental consequences
Mines result in consequences for the environment in both the short and long term.
Mines can unfortunately kill both wild animals and the plants nearby the explo-
sion. These consequences are generally short term, although the death of certain
animal populations can give unforeseen consequences for other animals, since the
animal kingdom is interconnected. Furthermore, the mines also damage the soil in
the long term. This happens because of the metals that are used in the production
of the mines, particularly older models, which will then make their way into the
soil where the mines are planted, when the mines are either left or explode. When
heavy metals are distributed in nature, the metals can make its way into the food
for many animals, including humans[34].

Another issue of minefields are the substantial areas made functionally un-
inhabitable for years, depending on the budget available to clear said areas. In
countries like Bosnia, mines from the Yugoslav Wars in the 90’s continue to be
found to this day, forming a minefield totalling 956.36 km²[5] across the country’s
three sub-republics 30 years after the end of hostilities. These mines result in ca-
sualties every year even after the end of the conflict, a situation mirrored in other
former war-zones like Afghanistan and Kosovo.
In 2021 a report on anti-personnel mine clearance has shown that 132,5km2 of
land has been cleared from anti-personnel mines out of a total 280km2 of land.
This means less than 50 percent of the examined land for investigation has been
6 Chapter 2. Problem Analysis

cleared. A total of 9 percent equivalent to 26,15km2 of land has been successfully


reduced in terms of the overall number of mines. An additional 43 percent, equal
to 117,33km2 of land, has been canceled due to complications encountered during
the clearance process (See figure 2). The country with the highest clearance rate is
Cambodia with an extensive area of 43,73km2 of land cleared, followed by Croatia
with 34,49km2 . Afghanistan, with one of the highest amount of mines registered
in the world, has cleared 14,29km2 of land and in total 352 antipersonnel mines.
Compared to the relatively small area of Croatia, with a total of 959.36km² of mine-
fields, the amount of land cleared in 2021 can be viewed as modest compared to
the size of the problem globally. [33]

Figure 2.1: Land Release by States Parties in 2021 [33]

While the lives lost are a tragedy on their own, one should also not under-
estimate the long-lasting damage this can do to the host nation as a whole. In
a report made by the United States Institute of Peace, property destruction is an
important factor refraining refugees from returning home[16]. While the obvious
way to cause property destruction is the direct demolition of property, via bom-
bardment or such, other means such as a minefield placed in the vicinity of a rural
dwelling can make it risky to move back into the area, and countrysides can be
rendered uninhabitable by said minefields, due to the difficulty of getting the old
inhabitants to move back into such risky territory from their relative comfort in
other countries. This is explored further in 2.2.2 on Human Costs.
Landmines therefore present the issue of long-term desertion of affected areas
after the end of the conflict, making it vulnerable to future instability. In addition,
they also increase the burden on neighbouring countries, whose capacity for hu-
manitarian action become occupied for years more than the duration of hostilities.
2.2. Consequences of landmine usage 7

2.2.2 Humanitarian consequences


The value of human life, while quantifiable to some degree, is not something that is
easily defined. Attempts are made through a metric known as the ’statistical value
of life’, which places the value of a life at anywhere from around a million dollars,
to almost ten million dollars, depending on where the person was born[11]. From
a more humane viewpoint however, the question becomes more nuanced. Every
life is connected to dozen others, and the loss of one will lead to the worsening
of the quality of another. A solid understanding of the statistics regarding the
human costs of landmines globally is relevant in this context.
Figure 2.2 depicts the number of casualties recorded form 2001 to 2021. The
high number of casualties are closely tied to conflicts and warfare around the
world. The 9/11 attack in 2001 resulted in military action from the US in the
Middle East. Consequentially, mine and ERW casualties had a substantial spike
in 2001. Casualties were decreasing from from 2003 to 2023, however in 2011, the
Syrian civil war led to a new and significant increase in the number of casualties.

Figure 2.2: Annual mine/ERW casualties (2001–2021) [33]

Mines negatively impact the safety and prosperity of affected regions. A report
from The Landmine and Cluster Munition Monitor states that, in 2021, casualties
resulting from abandoned mines were recorded in 47 different countries, and a
total of 2.182 people were killed. Another 3.355 people were injured as a result of
ERW’ (Explosive Remnants of War) [33]. This number is only related to landmines
specifically. Around 80 percent of all landmine casualties are civilians, and some
of these casualties also include children. It is estimated that 15,000 - 20,000 injuries
occur each year due to all types of landmines combined.[33] These injuries often
have lifelong ramifications, including both physical and psychological disabilities
and traumas.

Due to conflicts in the past, landmines remain a significant problem in many


regions. The most affected country with regards to casualties from ERW (Explo-
sive Remnants of War) in the last decade is Afghanistan, followed by Syria, Yemen,
Libya and Ukraine as shown in table 2.1. From 2014, Syria has been the second
highest ranking in terms of casualties to mine and ERWs. Afghanistan has had
8 Chapter 2. Problem Analysis

the the most casualties, accounting for over a quarter of the global mine and ERW
casualties between 2011 and 2021.[33]

State Number of Casualties % of Total Casualties


Afghanistan 17,057 26%
Syria 11,104 17%
Yemen 5,339 8%
Libya 3,457 5%
Ukraine 3,108 5%

Table 2.1: The 5 states with the most ERW-related casualties in 2011-2021[33]

Table 2.2 displays the total casualties for different groups of people in 2021,
which include civilians, military personnel, ’deminers’ (people tasked with re-
moving mines, NGO’ ect.), and individuals with unknown status. In 2021, Civil-
ian casualties of 4.200 accounted for 76 percent of all casualties. Notably, 1.696 of
the civilian casualties were children. Afghanistan was recorded with the highest
number of civilian casualties at 1073, whereby 40 percent of their civilian casual-
ties were children. Specifically, mines and ERW’ caused the death of 636 children
and injured 1.057 children, in Afghanistan. With regards to military personnel
casualties, Syria had the highest number of casualties, namely 465 people.

Group of victims Total Casualties


Civilian 4200
Military 1298
Deminer 27
Unknown 19

Table 2.2: Civilian status of casualties in 2021[33]

The data suggests that mines and minefields continue to pose significant chal-
lenges for the affected countries, several years after a conflict has ended. Civilians
remain the most vulnerable group of victims and children account for a significant
amount of these unnecessary deaths.

Similarly, the value of a civilian life also increases as the war-torn country it-
self worsens in terms of quality of life. This becomes apparent through a scarcity
analysis, as millions flee nations like Ukraine[38], leaving whichever experts re-
maining in higher demand than otherwise. When the war ends, attracting these
experts back from their new homes in Western Europe, to their old homeland,
which is affected by the existence of landmines, will likely be met with at least
some degree of difficulty based on prior experiences with refugee crises. [6].

In conclusion, mines contribute to a long-term, and often permanent, drop in


2.2. Consequences of landmine usage 9

quality of life in entire countries both during warfare but also after it. However,
while the irreplaceable loss of lives and the environmental costs and concerns are
tragic consequences of minefields, there are also other consequences, such as the
economic cost of military units, equipment and vehicles.

2.2.3 Military consequences


Landmines are not only costly in regards to the high numbers of fatal casualties,
but also economically. As of 2022, 164 countries worldwide have signed the Ottawa
Treaty of 1997, with the aim of minimizing human deaths and areas of uninhab-
itable land due to unexploded ordnance, by prohibiting the use, stockpiling, pro-
duction and transfer of Anti-Personnel Mines. However, among the non-parties
are nations such as Russia, a country that has been using at least seven types of
antipersonnel mines in Ukraine since the invasion on 24th of February 2022[33].
In connection to the clearance of landmines in the ongoing war in Ukraine, the
mine-clearing vehicle Armtrac 400 was bought by Ukraine for $500,000 USD from
the British company “Armtrac” in 2022[51]. Furthermore, research conducted by
ICBL’s monitoring regime “Landmine and Cluster Munition Monitor” reports that
Anti personal mines have been used by non-state armed groups (NSAGs) in at
least three States Parties, namely Central African Republic, Colombia and DRC,
from mid-2021 through October 2022[33]. Thus, the use of such types of land-
mines is still a problem today, despite the Mine Ban Treaty.

From a military standpoint, the detection and clearance of landmines are of


significant importance, especially during wartime when prioritizing progression
on the battlefield. Consequently, large amounts of resources and finances are spent
on heavy and costly equipment to detect and clear landmines emplaced by the en-
emy. Depending on the minefield density and the type of minefield encountered
by a military force, different equipment and methods are used. The estimated cost
of clearing a mined area of one square kilometre is approximately $1,000,000 USD
[8]. This expense, of course, varies depending on the specific area and whether
the demining is military or humanitarian. When demining for humanitarian pur-
poses the aim is to remove all landmines while military breaching focuses on path
clearing and only clearing a sufficient number of mines to achieve the objective[50].

Common to the majority of ground-engaging mine-breaching vehicles is their


high initial cost and expensive maintenance. Among the main types of vehicles
are rollers and flails, whose purposes are detecting and clearing the minefields,
respectively. Although mine flails are still used by armies around the world, un-
like the use of mine flails during WW2, the modern versions are unsuited for
battlefields. Aardwak’s AMCS Mk4 is commonly found around the world and
mine flails of such size are usually costly to acquire and maintain (purchase cost
around $1.5 million USD)[50].

While mine flails are separate vehicles, in today’s age both rollers and plows
10 Chapter 2. Problem Analysis

exist as attachments and can be equipped onto the fronts of modern tanks. These
attachments however, are both expensive and far from optimal, as the rollers can
only detonate a limited amount of landmines before they need to be replaced
and generally the attachments reduce the mobility of the tank and increase its
fuel consumption. Due to the disadvantages of these attachments, specialized
equipment is more commonly used. This includes the Assault Breacher Vehicles
(ABV) such as M1150 used by the United States, which is equipped with a plow
as well as an M58 Mine Clearing Line Charge (M58 MICLIC), which can clear an

8 ∗ 100m2

path per launch. Due to the cost of around $85.000 USD per system, the M58
MICLIC is only used when absolutely necessary[42]. As with other alternative
mine-clearing vehicles, the M11150 can cost up to $3.7 million USD per vehicle
[35].
It is worth noting that situations with no alternative to expensive clearing
methods regularly occur. The French equivalent of the MICLIC is the only uti-
lized tool during live combat operations, due to the speed required to maintain
offensive momentum[3].

The process of removing a single mine is estimated to cost around 300 dollars
to 1000 dollars.[33] This covers the necessary equipment and specialized personnel
required to remove the mine. The variation of the cost can be attributed to factors
such as what type of mine is stationed, the location and what techniques are
required for removing the mine. The comprehensive task of removing all existing
mines would require a large financial commitment ranging from between 50-100
billion dollars. [28]
From a military standpoint, the loss of a soldier is also significant. Aside
from the value of the equipment granted to them, a soldier can have anywhere
from a few months, to decades of training. In a high-casualty war-zone like
Ukraine[17] for example, the life expectancy of a front line soldier can be as low
as four hours[27]. The value of a veteran therefore increases as their experience
becomes scarce.
Ultimately, the relatively high cost of purchase and maintenance of military
equipment used for mine breaching in warfare is a problem with no definitive
solution. For this reason, minefields are only breached or demined if other options,
such as bypassing, are too risky or simply unattainable. The problems associated
with bypassing minefields will be examined in section 3.3.3.

2.2.4 Ethics and priorities


In international circles, the discussion on the use of landmines often focuses on
the humanitarian aspect, and international attempts at banning mines frequently
make use of said aspect. The most notable example of this can be seen with
the Ottawa Treaty, a UN anti-mine ban treaty with 164 parties at the time of this
document’ writing[37].
2.2. Consequences of landmine usage 11

From the data presented in the previous section on military costs, it is also
made clear that pragmatic military powers will go to great economic lengths to
spare human resources. It is therefore clear that human lives are a significant
factor regarding the nature of mine discussions internationally.
This report, however, would like the reader to observe the international com-
munity’s attention to the inherent relationship between the military costs and hu-
man costs respectively.
Returning to the section on military expenditures, the cost of clearing a square
kilometre minefield was set at approximately $1,000,000 USD. While the problems
this causes have already been highlighted, it is also relevant to focus on the ratio-
nale behind stationing mines in the first place. The cost of a single anti-personnel
mine can be as low as $ 3 USD[10], while training and equipping a single Ameri-
can Marine can range upwards of $ 45.000 USD[43]. That is a significant potential
return on investment from a material perspective, and with mines being expen-
sive and difficult to clear, the cost-effectiveness of laying mines is attractive in a
military sense. The $ 45.000 USD do not include the productive value of a human
being in a society, thus the long-term effect of disabling an opponent using mines
is worth much more than $ 45.000 USD. A probable salary for an ordinary Amer-
ican soldier with a couple of years of experience is about $ 30.000 USD annually
[2], thus depriving a society of such yearly productivity due to the death of said
soldier following a landmine detonation is upwards of $ 1.8 million USD given a
40 year working life, taking inflation and salary raises into account.
Attempts at outlawing mines are therefore going to be troublesome to enforce,
simply due to their effectiveness from a military standpoint. Such international
law is the primary preventative weapon against the use of land-mines, for exam-
ple the Ottawa Treaty. Landmines are effective and viable, and therefore remain in
use despite the international opposition to them. 164 states have agreed to follow
the principles of the treaty, but the major military powers globally are less inter-
ested in abandoning the use of mines and have not signed the treaty. The United
States particularly has had a difficult time deciding which position to hold on the
matter. In 2014, under the Obama administration, the White House announced a
new policy declaring the intent to uphold and follow the contents and philosophy
of the Ottawa Treaty[23], while never actually signing it. When Trump won the
election in 2016, he reversed the policy change from 2014 in 2020[54]. After Joe
Biden won the election in 2020, he has since introduced a new policy reminis-
cent of Obama’ policy in 2014, reestablishing the US’ intent to follow the Ottawa
Treaty’ commandments. [21]. Yet still, the United States has not signed the Ottawa
treaty officially. While the US outwardly would like to show their responsibility
on the matter, they clearly do not wish to give up control of their production and
use of landmines, apparent in their choice to introduce a ’policy change’ instead
of signing and ratifying the treaty. [21][44]. Other countries with less implica-
tions in military affairs and conflicts have little to no reason to use landmines, say
countries like Japan, Spain or Denmark. For such countries, there is virtually no
incentive to use landmines in the first place, compared to countries like Russia,
United States and China, who must have significant military power.
12 Chapter 2. Problem Analysis

In conclusion, the humanitarian and civilian consequences of landmine use


is inseparable from the military applications and effectiveness of landmines. It
has been showcased that a problem exists with the effectiveness of landmines,
consequentially making it difficult to abandon their use entirely. A theoretical tool,
weapon or strategy that could nullify or minimize the effectiveness of landmines
would also eliminate or minimize the intended purpose of their use, and therefore
prevent them from being stationed in the first place. This means that minimizing
the effectiveness of their use could reduce the number of casualties both from a
military and humanitarian/civilian perspective.

2.3 Possible solutions


2.3.1 Demining
Demining is defined as "...to remove explosive mines from (...)" in the Oxford
dictionary. This explanation is too broad for this problem analysis, as this report
mainly targets landmines specifically. Demining will instead be defined as "to
remove explosive mines from the ground".
There are two main techniques used in demining operations. The first one
is carefully defusing the mine, the second one is actively blowing up the mines.
Using the first method is time consuming and often not the first choice on an
active battlefield[22]. Methods of blowing up mines were briefly discussed in
section 2.2.3, but to reiterate, the methods included vehicles built for the occasion,
including rollers and flails, and as mentioned such vehicles are expensive both in
initial purchase and in reparation costs.
Demining takes on two forms, humanitarian demining and military demining.
Military demining requires speed and reliability during warfare with the main
goal being safe and fast traversal, meaning it is acceptable to miss some mines
in the process. Humanitarian demining instead aims to save as many lives in
the process, by reducing risks for both civilians and deminers. With less time
constraints, humanitarian demining can take as much time as is needed.[52].
Time is still an issue. In 2003 a RAND Corporation estimated that around 45-
50 million mines still lay beneath the ground[31]. Furthermore it is estimated that
roughly 100.000 mines are removed each year, meaning it would take 500 years to
remove the mines at that given rate, and with another 1.9 million (19 years) mines
added each year, it is not a positive outlook. Clearing mines is time consuming
and this is a big part of the problem, as it makes landmines worthwhile to use. For
reference the number of landmines in the ground now is estimated to be around
110 million. [28]
2.3. Possible solutions 13

2.3.2 Detection
The standard way of detecting mines is by scanning with metal detectors by hand
to find the metal in the ground and then poke at the metal at a 30 degree angle
in order to figure out whether or not the metal object is a landmine[7]. This is a
problematic way of detection given that modern mines can be made without the
use of metal, which makes it dangerous. Furthermore, there exists anti-tampering
devices that will explode upon being met with the frequencies used by common
metal detectors[3]. This method also takes a lot of time, given you need people to
manually scan an entire area plus it puts these people at risk.
There are also other more modern approaches to the detection of landmines.
There are methods such as passive millimeter wave detection, which revolves
around analyzing the small amount of radiation difference in the ground due to
the effect metal has in this regard. This method works most ideally if the ground
is not moist and is not that great if the objects buried are buried deeper than a
couple of centimeters. Another method is using infrared imaging, analyzing the
temperature difference between the mine and the surrounding ground.[7]
The technology for detecting landmines is generally viable, meaning it is pos-
sible to somewhat generate a map of where mines are located in a given area.
However, there are certain problems that can make the use of these methods less
effective, such as mines stationed within forests or vegetation, or mines specifically
designed to evade such analytical instruments. More information on the available
methods for detection in 4.1 on data collection.

2.3.3 Maneuvering
In regards to different ways of solving the problems related to landmines, the re-
port has so far analysed the process of demining and mine detection, as well as
the underlying challenges and limitations of both procedures. Although the de-
tection and clearance of landmines are possible options for handling hazardous
minefields, the utility of these methods is susceptible to multiple factors. In other
words, depending on factors such as time, economics, terrain and purpose, one
method of dealing with minefields might be superior to other solutions. As men-
tioned in section 2.3.1, human lives are highly prioritized in humanitarian demi-
ning, while time plays a crucial role in military demining. Thus, during warfare,
rather than breaching through mines, which is both costly and time-consuming,
finding safe paths through minefields might be a better solution in some instances.
Besides helping to maintain the momentum, minefields are also bypassed to
conserve critical counter-mobility assets[1]. Therefore, when possible, bypassing is
generally the preferred method to advance through minefields[46]. The planning
and execution of such maneuvers, however, comes with its own set of problems.
As mentioned previously, landmines have various purposes, one of which is to
control the movement of opponent forces by tricking them into following a specific
bypass. Hence, when making the decision to bypass rather than breach, it is
important to consider the likelihood of friendly units being channelized into kill
zones or traps[1].
14 Chapter 2. Problem Analysis

Another aspect affecting the mobility of a military unit is the terrain within
and around minefields. Defensively, when planning the emplacement of tactical
minefields, terrain visualization plays a vital role[1]. Due to natural elevations,
slopes and terrain features such as lakes, streams and valleys, the topography in
a given area naturally restricts the mobility of an attacking force. For this reason,
an IPB process is executed, in which the terrain in a specific geographic area is
analyzed to predict the manoeuvrability of enemy forces[9]. This way, landmines
can be placed on land areas of strategic importance and so-called AAs (avenues of
approach).
Contrary, an attacking force intending to pass through minefields must also
have insight into the terrain as well as different types of minefields in order to
estimate the likelihood of landmines in a given area.
Minefields are usually categorised into 4 groups, namely protective, tactic, nu-
ance and phony minefields, each of which has its own purpose and emplacement
method. The purpose of phony minefields is to deceive the enemy about the exact
location of real minefields by employing fake mines[1]. In connection to bypass-
ing possibilities, minefields of such type are particularly relevant, as these might
be exploited with sophisticated detection methods or if the opponent force acci-
dentally reveals the deception of the field, for example by driving through the
minefield[1].
Besides topography and different types of landmines, there are numerous
other factors to be analyzed when planning bypassing manoeuvres. On the one
hand, it is risky to bypass a minefield through seemingly mine-free and clear
routes, as these most likely lead into kill zones, but on the other hand, it might be
too challenging to cross through rough terrain with minimal probability of placed
landmines. Thus, the aim is to find an optimal bypass where both the terrain is
cross-able and the probability of landmines is as minimal as possible.
2.4. Problem Formulation 15

2.4 Problem Formulation


This report has examined the issue of minefields, especially in relation to land-
mines. The problem analysis has highlighted considerable negative consequences
regarding the use of mines. Landmines are the cause of thousands of deaths every
year of which civilians are the predominant victim. The majority of casualties stem
from landmines characterized as ’remnants of war’. This is obviously a tragic and
unsatisfying situation.
Major resources are also expended in an attempt to ’clean up’ areas ridden
with mines. In regards to military costs, many resources are spent both on the
training of soldiers and their equipment. Military vehicles and tanks are likewise
damaged, and lots of resources are expended especially in trying to clear and
demine certain areas.
Demining is a slow and resource intensive method of dealing with landmines.
Thus, a military unit has two other options; either avoid a minefield, or maneuver
through it. Maneuvering through minefields requires an understanding of both
the terrain as well as the possible locations of mines. Maneuvering poses an ob-
vious safety risk to the military unit, hence any plan or strategy for maneuvering
ought to be thoroughly planned. Modern and advanced technologies can aid in
the detection of landmines, albeit the reliability and effectiveness of these methods
varies depending on specific factors.

We have found through thorough analysis that the main problem with land-
mines lie in the effectiveness of their use. One way of minimizing the deployment
and impact of landmines globally is to reduce the reliance on landmines in military
conflicts. If landmines were not effective at harming and affecting the maneuver-
ability of military units, they would be less attractive. Our proposed solution has
the potential to decrease the use of landmines and, consequently, the unnecessary
casualties stemming from abandoned landmines in the future.

For the reasons above, the following problem statement has been formed:

How can a software solution efficiently analyze terrain and optimize pathfinding through
a minefield, to enhance and improve the maneuverability, safety and efficiency of traversal
operations, thereby decreasing the effectiveness of landmines
Chapter 3

Terrain Analysis

An understanding of the surrounding terrain is paramount when analyzing mine


placement and desired pathfinding. One of the most prevalent locations for the
placement of mines is along access routes, roads, paths and transport routes. These
places are often prime locations for mine placement as they are likely manoeu-
vring areas for opponent forces. This example highlights that where terrain is
easily manoeuvrable, mine placement is also desirable.
On the same note, different types of terrain can affect the ability and desir-
ability to station mines. For example, it is harder to bury mines in hard rocky
terrain than it is in loose soil, and it is more difficult for opposing forces to de-
tect mines in dense vegetation. If it is more difficult to place mines in rough,
rocky terrain and doing so will make the placement of mines much more visible
in relation to the surrounding terrain, it can be inferred that there is a reduced
likelihood of mines being placed in rocky terrain, thus becoming more attractive
for maneuvering forces[19]. Furthermore there is an increased likelihood of mines
being stationed in dense vegetation, since the detection capabilities are reduced
when mines are covered by vegetation, thus becoming less attractive for maneu-
vering forces[41]. Although the rationalization behind real world placement of
mines is much more nuanced and complex than these aforementioned examples,
terrain is undoubtedly a significant factor for predicting the location of landmines.

For this reason, terrain can both be understood in regards to the difficulty of
maneuvering through a specific type of terrain, but also from a perspective of
optimal mine placement. These two factors are in a relation with one another, and
the optimal route through a minefield relies on a balanced understanding of the
risks and opportunities associated with a given terrain. The best path through a
minefield is thus a path that not only takes the probable location of mines into
account, but also the friction and difficulty associated with maneuvering through
a certain terrain.
This section will both investigate the likelihood and probability for a given
mine to be placed as well as the effect a given terrain has on maneuvering, as
these two factors are two sides of the same coin.

16
17

The steepness of the terrain is an important factor. If given a route has a slope
that is too steep, then it is no longer possible to cross it. If the angle is more than
30 degrees, then we can assume that we won’t be able to pass it.[49] Although you
probably could walk on some steeper terrain than 30 degrees, it would require a
favorable ground type in order to keep the possibility of slipping low. Even if a
sloped terrain is walkable, the slope will also make it more energy consuming to
traverse, which then will lower the speed of which you can move through.[32].
When discussing roads and similar infrastructure, it is important to mention
the concept of ’Avenues of Approach’, abbreviated AA’s. Avenues of approach
are certain routes a given military unit can follow, in order to reach an objective
or a key terrain[49]. When searching for the optimal path through a minefield, it
is essential to have viable AA’s present. The most obvious example of an AA is a
simple road leading straight to the desired objective, however in real situations it
is often not desirable to use such an obvious AA, since the enemy is also aware of
the possible entries to their territory. Thus, the best AA is one that is sufficiently
fast and direct in relation to the unit’s mission, while not being obvious or vulner-
able to enemy attacks. Roads, clearings and similar pathways are usually faster
and more comfortable to traverse compared to irregular traversal over rough ter-
rain without any roads. For tank and vehicle maneuverability, roads are indeed
essential if the surrounding terrain is difficult to navigate.
For a certain area, it may be the case that roads are not viable to be used, since
their usage will obviously be useful, thus countermeasures are sure to have been
established to prevent such usage. This could either be in the form of entering
line of sight and fire of enemy positions, encountering landmines or an enemy
blockade awaiting the arrival of their victims. In other occasions, the use of a
road may be fully or partly desirable in relation to the optimal path through a
minefield, given the probable safety of travellers.
Furthermore, it may also be the case that natural clearings and paths through,
for example, dense vegetation, forests or cliffs, can be considered AA’s. For this
reason, the use of such clearings and natural pathways become desirable to use,
as the surrounding alternative terrain is generally undesirable. Because of such
a natural clearing being an AA, it must also be important for the enemy to deal
with such an opening, by taking countermeasures.
In conclusion, roads, pathways and clearings provide a more direct, clear and
faster approach to a military units objective, however this also makes them prime
targets for the enemy to lead into traps, minefields or blockades. Thus, depending
on the other factors of the terrain, roads can be useful for traversal, but must be
used cautiously.

Water levels in the terrain will slow the speed of which it is possible to move
through. The deeper the water is, the slower you will move through it.[25] At some
point the depth will no longer be possible to simply walk through, and you would
then need to start swimming in order to keep moving. The process of swimming is
quite slow and requires a greater amount of effort, than if you could simply walk
past. [56] This would also probably increase even further if you were a military
18 Chapter 3. Terrain Analysis

troop with a lot of gear that needs to be dragged with through the water, not to
mention making sure the gear does not get soaked in the journey.
Water is generally something to steer away from when maneuvering, unless
you have a lot of time. Although, if you do have the time to move through water,
it will probably reduce the risk of getting into contact with any mines, given mines
do not do well with extensive water damage.[1] This does however not keep you
safe from contact with enemy forces.

Given the existence of available landmine detection systems, covered in section


2.3.2 and 4.1, the ability to hide the location of minefields becomes increasingly
attractive for opponent forces. When stationing mines in dense vegetation or areas
with natural cover such as forests, the effectiveness of detection technology is
decreased. Furthermore, it can be more difficult to spot mine placements due
to the natural vegetation and covering of the ground inside of a forest. For this
reason, areas categorized as forests or dense vegetation must be considered more
dangerous than cleared areas, since there is a higher likelihood of landmines not
being detected in said areas.
A forest, however, does present more cover from line of fires from the enemy,
meaning that a military unit is generally safer from enemy engagement when in-
side of a forest. This point makes forests quite attractive for maneuvering forces.
However, because forests provide more cover from line of fires, and the maneu-
vering forces have trouble detecting mines, it can be inferred that opposing forces
are presented with a great opportunity to emplace mines, such that the traversal
through forests and dense vegetation are slowed down or avoided entirely, due to
the risk of encountering mines.
Depending on the type of dense vegetation, it is also generally slower to ma-
neuver through vegetated terrain. Be it a forest or an area with shrubs, bushes
and or thickets.
For the above mentioned reasons, it is generally not a good idea to traverse
through densely vegetated areas when there are other opportunities, since the
likelihood of mine placement is high, and the ability to detect such mines is low.

The ability of opposing forces to detect mines is affected by the type of soil
covering them. In loose soil for example, mines may be more challenging to detect
visually, hence loose soil is generally more attractive for mine placement. On rocky
terrain, mines are more visible. In rocky terrain, mines can more easily disrupt the
natural appearance of the surface, which will gather attention when passing. Due
to the reflective nature metal, if the soil is too hard to bury the mines properly,
the metallic components of the mine will reflect more clearly and distinctly than
its surroundings , making it more likely to be detected. However, in the case
that a landmine contains very little metal, it can be harder to detect. Thus, an
analysis of the opponents available resources and equipment could be valuable.
The concealment aspect of burying mines in rough terrain is more challenging
and it can result in noticeable disturbances in the surrounding terrain compared
to loose soil for example sand, that will leave no noticeable disturbances and tracks
19

after burying the mine.


The maneuverability of military units in loose soil does impede movement,
particularly for vehicles, tanks and so on. This will make the vehicles more likely
to find a pathway with a sturdier surface, hence anti-tank and anti-vehicle mines
are more likely to be found in rocky, rough or smooth terrain than the soft terrain
where anti-personnel mines are more common. Therefore, planning paths through
minefields necessitates an understanding of the soil’s characteristics, in order to
and the potential risks that can be associated with the mine placement.
Chapter 4

Technology Analysis

4.1 Data Collection


We have already discussed the various method of clearing mines, but inherently
clearing said mine relies on the ability correctly detect them. For every 1000 to 2000
mines cleared, a deminer is either maimed or killed. Furthermore, a survey found
that injuries and fatalities most commonly occur from excavation, accounting for
35% of all demining accidents, wherein 24% of the accidents are caused by missed
mines.[31] There is clearly an underlying problem when it comes to detecting and
then demining or traversing minefields.
Knowing this, what kind of data can we actually assume to be available either
on the battlefield or as a part of humanitarian demining? Since we know that
accidents do occur, we can not assume that we will be able to get data which
predicts a mines position 100% of the time, but having an accident every 1000 -
2000 mines is very broad. There is a big difference between an accident every 1000
mines and every 2000 mines. Rather we need to take a look at the efficiency of
different methods found today, it is important to note that based on conditions
almost all methods have varying effectiveness, instead we assume an average rate
of detection between 70% to 95% and try to explain when certain methods work
better than others. Having a method of detecting mines can aid in planning the
optimal route for maneuvering through a minefield.

Ground-penetrating Radar

Ground-penetrating radar, GPR for short, this type of radar can detect non metal
casings, but it is prone to bounce of small plastics, making it ideal to spot clutter,
and wet soil makes it difficult to find mines bellow 4 centimetres.[31][26] In terms
of efficiency, depending on the frequency, environmental conditions and the types
of mines, we can expect ground penetrating radar to have a higher success rate
when conditions are homogeneous, and penetrate deeper in dry conditions (at
most 20 cm).[12]

20
4.2. Compilation of Accumulated Data 21

Infrared Imaging

Infrared imaging is again a technique which has trouble when the area is non-
homogeneous and even if there is vegetation growing, such as grass. This type
of method for finding mines is rarely used as it only has some pretty specific
conditions in which the data is reliable and will not be assumed as available data,
as determining the false positive and false negative rates is especially difficult.[26]

Metal Detectors

Metal detectors are one of the most commonly used methods, the best detectors
had an efficiency at 91% though less if the area was iron rich.[31] Metal detectors
have a hard time knowing when something is clutter or when it is a mine, and
they are therefore often used together with another technique.

Electromagnetic Induction

When using electromagnetic induction you induct an electric field on the object
in order to have it create its own magnetic field, which in turn can be analysed to
define the object. This detection method can penetrate sufficiently deep, at most
7 - 12.5 centimetres depending on the metal contents, but when an object contains
little metal it can be really hard to identify, meaning it has a lot of false alarms.[26]

Artificial Intelligence

AI has become a part of almost everything we do and has also become an impor-
tant part of mine detection. AI can compliment an observational drone by aid-
ing in the analysis of data from large areas with multiple techniques all at once,
namely computer vision (imaging), metal detection, GPR and many more. Some
drones claim to have an efficiency at around 90% when utilizing AI technology.[55]

Conclusion on data collection

As mentioned previously, we can expect to see detection technologies with ac-


curacy rates varying between 70% - 95%, with lower accuracy in wet and non-
homogeneous terrain. We can often expect to see more false positives as the de-
tection rates increase, though through the use of multiple sources of data a more
accurate picture should present itself. In some case like with drones and artificial
intelligence working in unison, they seem to be particularly useful, both in terms
of safety, accuracy and time. With a fair degree of confidence we can expect to get
fairly accurate data through a thoughtful approach and balance with regards to
our data sources.

4.2 Compilation of Accumulated Data


Based on the data presented in section 4.1 we draw the conclusion that the factors
affecting accurate detection are plentiful and varied. Common among all of the
22 Chapter 4. Technology Analysis

methods presented in said section is that none of them have complete reliability.
From the soil type to the experience of the operator, different factors can affect the
reliability of the final set of data.
Modern militaries already expend considerable effort regarding the predictable
location of enemy minefields[3], something that is done by experts behind enemy
lines based on doctrine made from careful study of prior minefields in other the-
atres of war[3]. The doctrines that form the basis of these conclusions are classified
and therefore inaccessible to the writers of this report unless a military contract can
be acquired. However, it is worth noting that especially in high-mobility theatres
of operation, where the front-lines move rapidly and unpredictably, it is worth
questioning the capabilities of a human-based team in regards to their ability to
perform the analytical work required to increase the odds of evading landmines.
Assistance from an algorithm, one that can run on a computer, would all else
equal be beneficial in helping this personnel in making significant decisions that
could end up saving lives. As such an algorithm would be immune to the faults
of typical combat issues like fatigue and tiredness, as well as have the advantage
of computing capabilities in regards to handling significant amounts of data.

4.2.1 The problematic low reliability of detection methods


It is important to address a prevalent issue for this report, namely unreliability.
Whenever data is received from data collection methods, it will present itself as a
probability rather than as a fact.
Probabilities are less useful from a military standpoint, based on the conclu-
sions reached in the aforementioned section 2.2.2 on the Human Costs of mine-
laying. The threat of a minefield being present is enough to discourage military
manoeuvres through an area, and a general probability is therefore not useful in
a military context other than mandating a detour.
While this report acknowledges the current limitations in the reliability of ex-
isting detection technologies for military use, we posit the possibility of improving
and increasing the accuracy by integrating and combining data in a multivariate
analysis and algorithm. It would involve the merging of various data sources, such
as satellite imagery, weather reports, enemy engineer regiment traces, ground pen-
etrating radars and topographical data to name a few.
Through an aggregate relational analysis, a quantitative statistical conclusion
can be drawn, and what was formerly multiple sets of individually unreliable data
can unite to form a more reliable conclusion compared to its parts.

4.2.2 Combining data to increase accuracy


Similar to how fibres unite to form a stronger rope, data can combined and unite to
provide a more reliable probability regarding landmine placement. In essence, the
conclusions drawn from individual data sources considered not useful or sufficient
can, when combined, produce a more reliable estimation for landmine placement.
The rationale behind this concept lies in the fact that humans attempt to logically
and rationally analyze situations based on the data that we have, except we are
4.2. Compilation of Accumulated Data 23

only able to effectively do so when we have enough data. We believe that in the
case that we are lacking information, the probability of humans making wrong
decisions increase, since there are factors affecting reality that are not taken into
account. In the same way a detective or police investigation attempts to draw a
conclusion by accumulating relevant data and evidence, our solution will take rel-
evant data into account, analyze the data and provide a more probable conclusion
regarding landmine placement, than otherwise would have been. In essence, we
do not assume that our tool is a 100% accurate, but we do believe that it has to
potential to be more accurate than the conclusions drawn by humans, due to the
programs ability to utilize and compute much more data than humans are able to.
For this to work it is necessary to first compile said data into a format that can
be interfaced with by our software. The data we collect have the shared attribute
of being relative to a physical location, hence it is possible to project the data onto
a grid or grid-like structure. In other words, the data we collect can be assimilated
into the data-form known as a matrix; in this case, a 2D matrix.
The difficult part lies in how these matrices interact with one another, espe-
cially when it comes to the soft data sets such as those presented in mine-laying
doctrines. The calculations between them would have to be made based off of
trial-and-error experience, potentially AI-assisted as well, but several reasonable
assumptions can be made from the sources laid out in section 3. An example of
such an assumption is the fact that mines are rarely laid in rocky terrain, so even
if one of our data collection devices gets a result from such a place, we can, with
less certainty, assume that it is true unless corroborated by another source. In any
case, it is less likely for a mine to be deployed in such a location, compared to a
detection device indicating mines located in dense vegetation, as explained in the
Terrain Analysis.

4.2.3 The design of Matrices


Aside from allowing us to make complex relational analyses on our data, matrices
have a variety of advantages that are relevant to the development of our end-
product. Most importantly, a 2D matrix based off of percentage values would
would likely find itself either immediately, or easily convertible to probabilities.
The simplest example of this would be using ’zero to one’ percentile values in
a probability matrix to generate a grey-scale height-map, where the value of the
matrix cell corresponds with a shade of gray, from black to white. In our case,
such a percentage map can both be analyzed by pathfinding algorithms, as well
as colourized, for example using values from green to red to signify danger, and
be overlaid on a map of the terrain.
Lastly, the design of our matrices allow for a simple process regarding visu-
alization, such that a user of the software can easily understand the output, that
is the optimal route through a given area. However, the visualization aspect of
our software is not related to finding the optimal route through a minefield, but
merely the showcasing of our solution. The technical details of this visualization
is explained in section 5.4.
24 Chapter 4. Technology Analysis

4.3 Pathfinding Algorithms


Having found a way of storing and modelling data regarding mine locations and
topography, the data will be used in a pathfinding algorithm to find the optimal
path through minefields in a given terrain, depending on various factors and their
priorities.
An algorithm is a systematic procedure that produces a solution to a problem
in a finite number of steps. Furthermore, a pathfinding algorithm is a specific type
of algorithm which, given a graph, finds a path between two nodes, if such a path
exists. Among the most well-known and commonly used pathfinding algorithms
are Breadth-first (BFS) and Depth-first (DFS) searches as well as A* and Dijkstra’s
algorithm.
In this section, the above mentioned algorithms will be examined in order to
lay the theoretical foundation for section 5.3.1, where the most suitable pathfinding
algorithm will be chosen.

4.3.1 BFS and DFS


In simple terms, the BFS algorithm traverses through a graph, by storing the neigh-
bouring nodes of a given vertex in a queue that operates on a first-in, first-out
(FIFO) principle, that is, the first vertex to be stored in the queue will be visited
firstly [48]. Whenever a node from the queue has been visited, the algorithm stores
the visited nodes separately and adds their neighbouring nodes to the queue. This
process is repeated until the desired node is found, at this point, the route is ob-
tained by backtracking the visited nodes, that were stored by the algorithm. The
first-in, first-out nature of the queue secures that the acquired path is indeed the
shortest, whenever the algorithm is applied to unweighted graphs. However, since
BFS does not take into account the weights of the edges in the graph, this type of
algorithm will not necessarily find the “best” route. In other words, if multiple
routes exist, the algorithm finds the path containing the smallest number of ver-
tices, yet, the overall weight of an alternative path might be smaller, making it a
better path than the one found by the algorithm.
The DFS algorithm is in many ways similar to BFS, nevertheless, there is a
significant difference between the two algorithms, namely the data structure used
to store adjacent nodes. Whereas BFS uses a queue, DFS, on the other hand,
utilizes a stack [48]. As mentioned above, a queue works by the principle of first-
in-first-out, whereas elements in a stack are added and removed according to the
last-in-first-out principle. This implies that BFS always visits the nodes closest to
the root node, whereas DFS picks an arbitrary adjacent node and searches its entire
branch before backtracking and repeating the process for the other neighbouring
nodes. Due to the last-in-first-out principle of a stack, there is no guarantee, that
DFS finds the “best” path.
As neither BFS nor DFS utilize the weights of the edges, they do not find the
optimal path, defined by the weighted sum of different factors such as terrain
difficulty and probability of landmines. For this reason, both algorithms are inad-
4.3. Pathfinding Algorithms 25

equate solutions to the pathfinding problem.

4.3.2 Dijkstra’s algorithm and A*


As opposed to BFS and DFS, both Dijkstra’s algorithm and A* utilize the weight
of each edge connected to a given node when choosing which adjacent node to
search. Thus, if implemented correctly they will be able to find the optimal path,
i.e. the path whose weighted sum of its constituent edges is the smallest.
More precisely, Dijkstra’s algorithm can be split into two steps. Firstly, the
algorithm searches all the adjacent nodes of an explored node A, while assigning
to each node the overall cost of getting to that particular node as well as the
previous node, in this case, node A. Secondly, the algorithm explores the node
with the smallest total cost and marks the given node as explored.
Figure 4.1 provides a step-by-step visualization of Dijkstra’s algorithm applied
to a weighted graph, where the purpose is to find the optimal path between ver-
tices x1 and x5 . As illustrated in (a), every node, except the root node x1 , is initially
assigned the value of infinity, indicating that none of the vertices has been visited
yet. The algorithm starts at x1 , marks it as explored and executes the first step,
as shown in (b). Now the algorithm executes the second step, i.e. it explores the
node with the smallest total cost, in this case node x4 , and marks it as explored.
Whenever a vertex xn is visited more than once, the algorithm compares the costs
of the two possible paths to xn and assigns to xn the total weight of the "cheaper"
path. An example of this is found in Figure 4.1 (c), where x3 can be reached either
directly from x1 or through x4 . In this case, the algorithm picks the path through
x4 as it has a lower cost.
The algorithm proceeds to explore new vertices until the desired node, x5 is
explored. The optimal route can then be back-traced by following the assigned
node to each of the explored nodes along the path. In other words, the optimal
path between x1 and x5 is (x5 , x3 , x4 , x1 ).
We have so far examined Dijkstra’s algorithm as a possible solution method for
the shortest path problem of a weighted graph. Alternatively, the solution to the
same pathfinding problem might also be found using the A* searching algorithm.
The two algorithms are practically identical, the only difference being the use of
a heuristic function in A* to prioritise supposedly better paths, while Dijkstra’s
algorithm searches by expanding out equally in every direction [45]. Thus, when
A* chooses which node to explore, it does not only look at the overall cost of
reaching the node but also takes into account the estimated cost of the cheapest
path from the given vertex to the end node. That is, the algorithm explores the
node which minimizes the following equation:

f (n) = g(n) + h(n)

g(n) denotes the currently best path to node n, and h(n) is a heuristic function that
estimates the cost of the cheapest path from node n to the goal [48]. Furthermore,
to ensure that A* finds the optimal path, the heuristic function h(n) must satisfy
two criteria, namely admissibility and consistency. h(n) is admissible if it never
26 Chapter 4. Technology Analysis

(∞) (∞)
x5 x5

4 11 4 11
5 5
(∞) (∞) (∞) (9,x1 ) (7,x1 ) (3,x1 )
2 2
x2 x3 x4 x2 x3 x4
1 1

7 7
9 3 9 3

x1 x1

(a) (b)
(14,x4 ) (9,x3 )
x5 x5

4 11 4 11
5 5
(9,x1 ) (4,x4 ) (3,x1 ) (6,x3 ) (4,x4 ) (3,x1 )
2 2
x2 x3 x4 x2 x3 x4
1 1

7 7
9 3 9 3

x1 x1

(c) (d)
(9,x3 ) (9,x3 )
x5 x5

4 11 4 11
5 5
(6,x3 ) (4,x4 ) (3,x1 ) (6,x3 ) (4,x4 ) (3,x1 )
2 2
x2 x3 x4 x2 x3 x4
1 1

7 7
9 3 9 3

x1 x1

(e) (f)

Figure 4.1: Visualization of Dijkstra’s algorithm


4.3. Pathfinding Algorithms 27

overestimates the cost of reaching the end node, while consistency implies that
h(n) satisfies the triangle inequality[48].
Chapter 5

Program design

The following chapter will provide an examination of our program design in order
of execution. The chapter is split into four sections, each focusing on a separate
component of our program.

1. Matrix Initialization

2. Data Pre-processing

3. Pathfinding Algorithm

4. Visualization

The first two sections explain the process of importing and normalizing input
data as well as how this data is configured with regards to user-defined settings
and lastly processed into a single matrix. The last two sections delve deeper into
the application of the pathfinding algorithm and the visualization of our found
path. To help with the mediation of the design, we have created a diagram to
explain the flow of the program, see figure 5.1.

28
29

Figure 5.1: A flow diagram of the entire program process.


30 Chapter 5. Program design

5.1 Matrix Initialization Overview


As was discussed in section 4.2.2 of the technology analysis, structuring the avail-
able data as C matrices has several benefits, which is why the first part of our
program is a set of functions designed to convert the data that we’re expecting to
receive into said matrices.

At its core, this is a process composed of two steps:

1. Specification of expected format

2. Import of expected format

5.1.1 Specification of expected format


It’s important that the data we receive is in a format that is easily identifiable and
easily importable into a C program. A report written in a .docx encoded file is dif-
ficult to extract data natively from within the C language, as its native file handling
function, fopen, is made to handle raw text strings[18], not formatted data such as
that found in .docx or other contemporaries. Examples of such raw text strings are
standard UTF-8 encoded text files (.txt), or data exchange formats such as JSON,
YAML or XML. Unfortunately, much of the data that we need to make our algo-
rithm function is not publicly available[3]. Examples of this include coordinate sets
for previously encountered mines, as well as military satellite maps. As such, we
are unable to determine the format that these exist in currently, and would only be
able to do so by collaborating with specific military organizations. It is difficult to
establish without further interviews with members of militaries outside of NATO,
that such data would differ regarding the format. Ideally, our program should
therefore have specific functions designed to handle data of varying formats and
convert this data into a two-dimensional array. Any potential later formats will,
instead of having new import functions added for them, be externally converted
to a format usable by our program. This ensures cross-compatibility between data
sets and also ensures that multiple forks of the project need to be simultaneously
maintained for each prospective customer. However, due to time constraints, the
scope of our project and the limited amount of available data for our group, we
assume that all data is received in the same format, namely as .bmp files. We have
chosen the .bmp file type, because it will be able to give a good visualization of
the data and it is a relatively simple datatype which most painting software can
create, which will make the process of generating easier for both us and a user.

5.1.2 Import of Expected Format into C Matrix


In our program, each expected input is located in an input directory. If the file
exists, it is loaded by an import function, and if it doesn’t, its lack will be handled
by said function. Since the types of data that is possible to make compatible
with our program are endless, we have chosen to focus on just making it able
5.2. Data Pre-processing 31

to import the bitmap file type. This datatype will allow us to make mock data
for our program with external paint software, which allows us to have a visual
overview of the mock terrain. Even though we only import this one data type,
there is however space for scaling the program further with more file types. The
bitmaps that we draw as mock data will be in black and white, so we will be able
to get the values from each pixel as a scale from zero to one that we then can use
for further processing of the data.

5.2 Data Pre-processing


5.2.1 User Settings
User settings play an important role in customizing the found path so that it
matches the user’s preferences. Before the program executes the pathfinding algo-
rithm, the user is prompted to choose between different settings. Firstly, the user
is asked to choose which troop type intends to navigate through the minefield.
Here the user can choose between "squad", "company", "logistic unit", and "armor
unit". Depending on the selected troop type, the program will take into considera-
tion the pre-defined settings of the given troop type. These provide boundaries for
factors such as acceptable mine risk, water levels, road quality, etc. An in-depth
examination of the pre-defined settings is provided in the following section.
After having selected a troop type the user is prompted to consider a risk factor
between 0 and 2, 0 being low risk, 1 - medium risk and 2 - high risk. This setting
is later used to determine the weight of the matrix containing the probability of
a mine in a given area. The weighting of the different factors will be further
discussed in section 5.2.4. Put differently, the higher the risk level, the lower the
weight of the mine matrix and vice versa. If the user chooses the high-risk setting
the pathfinding algorithm will find a less safe, but faster route, whereas if the user
chooses the low-risk option, a safer path is found.
Lastly, the user is prompted to determine the size of the input matrices, this
step allows the user to define the dimensions of the matrices that the program will
operate on, thus providing a customised level of detail for the analysis. Among
other places, this setting is used in the matrix initialization process, data configu-
ration and the pathfinding algorithm.

5.2.2 Pre-defined Settings


Predefined user settings refer to the settings that are related to the chosen troop
type. As mentioned in the previous section, the user must select one of the fol-
lowing types: "Squad", "Company", "Logistic Unit" and "Armor unit". Depending
on the chosen troop type, the input data is adjusted accordingly, to ensure that the
found path satisfies the criteria of the chosen troop type. Each troop type has a
distinct set of upper and lower bounds, encompassing factors such as maximum
water depth, the maximum mine risk tolerance, slope tolerance, minimum road
quality and vegetation criteria.
32 Chapter 5. Program design

5.2.3 Matrix Configurations


After having imported the data and stored it in 2D arrays, the data will now be
further processed. We have chosen to label this part of the pre-processing process
as the matrix configuration functions. The purpose of these functions is to take the
raw matrices as inputs and output configured matrices, that satisfy the boundaries
of each factor defined in user settings. In other words, the functions loop through
the matrices and mark certain values as impassable if these lie outside the accept-
able range. This means that we do not want to cross land areas with these values
under any circumstances. The following maps are configured:

1. Slope map

2. Water map

3. Mine map

4. Soil map

5. Vegetation map

6. Road quality map

All maps have been min-max normalized when imported, meaning that values
are in the range of 0-1. The slope maps depict the slope of the terrain, where a
slope of 1 is equivalent to 90 degrees. This can occur if the terrain has a cliff
side. Mines are less likely to be laid at cliff faces or on mountainous terrain,
see section Terrain Analysis, so this data is relevant. The water map indicates
the water depth, 0 meaning no water and 1 indicating that the entity will have
to either swim or be submerged. The mine map is constructed based on output
from detection equipment and has values depicting the probability of a mine in
a certain location. The soil map depicts how easily a mine can be laid in the
terrain in terms of the hardness of the soil. Vegetation maps indicate how much
vegetation has grown at a certain spot. This might be relevant data, as mines tend
to be laid in vegetation in order to conceal them. Road quality maps depict the
quality of the road, also an important factor when choosing where to go, since
higher quality roads make traversal easier and faster, as well as allowing vehicle
advancement.

5.2.4 Combining Matrices


Having configured every map as described in section 5.2.3 the next step in the
pre-processing phase involves the selection of a weight for each map in order to
produce a processed 2D-array containing the weighted sum of each map. This
matrix is then passed as an input to our pathfinding algorithm, which will find
the optimal path based on the user settings and the weights of each map.
When imported, the data corresponding to each map type is max-min normal-
ized, meaning that the values range from 0 to 1. To maintain this range in the
entries of the processed matrix, every map is assigned a weight in the same range,
5.3. Pathfinding Algortihm 33

such that the sum of all weights adds up to 1. Mathematically, every entry of the
processed matrix can be expressed the following way:
k
Pij = ∑ an ∗ ( Mn )ij (5.1)
n =1

Given a set of k available map types, ( Mn )ij is the i, jth element of the nth
map type, while an is the corresponding weight of the map. Lastly, Pij is the i, jth
element in the processed matrix.
If weighted equally, every map type is assigned a weight of an = 1/k. This
is only the case if the user chooses the "high risk" setting when asked to pick an
acceptable risk level. Otherwise, if "medium" or "low" risk has been chosen, the
modified weight of the mine map is a1 = 0.5 and a1 = 0.75, respectively. There
is no particular reason why these exact values have been chosen. Depending on
the number of available input matrices and their importance, an alternative set
of weights might work better. More precisely, values must be chosen such that
decreasing the risk level increases the weight of the mine map. This means that
even if a path designed for a given troop type is allowed to pass an area where
the mine probability is less than the maximum threshold, the likelihood of this is
decreased when selecting a lower risk level. Furthermore, by choosing a "medium"
or "low" risk level, the weights of the remaining map must be adjusted accordingly
in order to maintain a total weight of 1. Hence, given that the remaining factors
are equally weighted, the modified weight is an = 1k−−a11 , where a1 denotes the
weight of the mine map and k is the number of available map types.

5.3 Pathfinding Algortihm


The following section is divided into two subsections. In subsection 5.3.1 an ap-
propriate pathfinding algorithm will be chosen based on the aim of our proposed
solution and the extent of our problem formulation. In the second subsection,
an emphasis will be put upon the deliberate choices we have made in order to
adapt our chosen algorithm to solve a problem type matching that of our problem
formulation.

5.3.1 Choice of Algorithm


In order to find and design the best-suited algorithm for solving the problem state-
ment one must understand the nature and extent of the problem. In a nutshell,
our proposed solution aims to minimize the effectiveness of landmines by ma-
noeuvring through a minefield using an optimal path, that satisfies a given set of
criteria. The optimal path will be found using a pathfinding algorithm whose in-
put is a 2D-array. Each element of the array indicates the "cost" of a geographical
area as a weighted sum of numerous factors (as was discussed in section 5.2.4).
The goal of the algorithm is to return the path whose overall cost is the smallest.
In section 4.3 four different path algorithms were examined. Two of these
algorithms, namely BFS and DFS were dismissed in the same section as neither
34 Chapter 5. Program design

algorithm utilizes the cost of a geographical area and hence, does not return the
optimal path.
One drawback of Dijkstra’s algorithm is its relatively high time complexity for
large graphs. More precisely, Dijkstra’s algorithm uses O(n2 ) operations to find
the length of the shortest path between two vertices in an undirected weighted
graph with n vertices [47]. It is difficult to precisely determine the time complexity
of A*, as it depends on the quality of the heuristic function. Although its worst-
case complexity is the same as Dijkstra’s algorithm, in practice A* will be faster
on larger graphs [45].
Despite being slower than A*, Dijkstra’s algorithm will always find the opti-
mal path if such exists. However, the same is only true for A* if the heuristic
function h(n) is both admissible and consistent [48]. As the optimal route in our
pathfinding problem is found by optimizing a weighted sum of multiple variables,
the admissibility condition would be difficult to satisfy. In other words, there is
no specific method of finding a lower bound for estimating h(n), so that it would
never overestimate the real cost. Even if an admissible heuristic is found, such a
heuristic would most likely be poor and result in a slower algorithm.
Because we prioritize the optimality of the found path rather than the time
taken to find such a path, we have chosen Dijkstra’s algorithm as our pathfinding
algorithm.

5.3.2 Design of Algorithm


In broad terms, our design will follow the step-by-step procedure of Dijkstra’s
algorithm described in section 4.3. This has visually been depicted as a flow chart
in figure 5.3.
The first step of designing an implementation of Dijkstra’s algorithm is to
choose an appropriate data structure for modelling the graph on which the al-
gorithm will be applied. There are two data structures that people often use for
this purpose, the adjacency list and the adjacency matrix [20]. Among other fac-
tors, the sparsity of the graph is important to take into account when choosing the
data structure. In our problem, a minefield can be modelled as a grid-like graph
of uniformly spaced vertices, each representing a small area of the minefield. This
representation results in a sparse graph as every vertex is only connected to four
adjacent vertices. Moreover, to account for the "cost" of each geographical area, all
edges are directed and weighted. The weight of an edge corresponds to the "cost"
of the vertex at which it is directed. The weighted directed graph is represented
in Figure 5.2.
5.3. Pathfinding Algortihm 35

c0 c1
x0 c1 x1 c2 x2

c3 c0 c4 c1 c5 c2
c3 c4
x3 c4 x4 c5 x5

c6 c3 c7 c4 c8 c5
c6 c7
x6 c7 x7 c8 x8

Figure 5.2: Weighted and directed graph modelling a minefield

Due to the sparse and uniform nature of the graph, it makes sense to model
it as a 2D array of structs, where each item of the array contains, among other
variables, the coordinates of the vertex and its "cost", i.e. the identical weight of
every edge directed at the vertex.
Although both an adjacency list and an adjacency matrix can be used to depict
the same graph type, the implementation of either data structure would require a
substantial conversion of the input data. On the other hand, a 2D array is better
suited for this problem type as the value in an entry of the input matrix can be
directly copied to the struct of the same index in the 2D array.
Having found an appropriate data structure to represent the graph, the next
step is to select a data structure for the implementation of a priority queue. A
priority queue is a container of elements, each having an associated key by which
the elements are ordered [20]. In this case, the purpose of the queue is to keep
track of unexplored nodes and the currently cheapest path to each such node.
Because the algorithm uses the queue to find the currently cheapest path, every
unexplored node is prioritized based on the currently cheapest path to the node.
This property makes it a minimum priority queue. In addition to this, a queue
of such type supports two fundamental operations: insert(k, e) and remove_min().
Insert(k, e) inserts an element e with key k into the queue, while remove_min()
returns and removes the element with the highest priority from the queue. Addi-
tionally, in our design, a third operation decrease_entry(k, e) is necessary in order
to update the priority queue whenever the algorithm finds an alternative path
with a cheaper cost k to a given node e. An examination of decrease_entry(k, e)
and remove_min() is provided in section 6.5 where the implementations of both
functions are exemplified.
There are several ways of implementing a priority queue. Naively, one could
use a sorted or unsorted array. However, in such implementation, the two fun-
damental operations will have time complexities O(n) and O(1) or vice versa.
Alternatively, one might use a min binary heap for the same purpose. In this case,
both insert(k, e) and remove_min() have the same complexity, namely O(log(n))
36 Chapter 5. Program design

[20], which is preferable when working with larger queues. For this reason, we
use a min binary heap to implement our priority queue.
A min binary heap satisfies two criteria. Firstly, it must be complete, that is,
every level of the tree except the last must contain the maximum number of nodes
possible, and nodes in the last level are as far left as possible [20]. Secondly, it
must satisfy the Heap-Order Property, which states that for every node v other
than the root, the key stored at v is greater than or equal to the key stored at v′ s
parent [20].
In our design, we have modelled the binary heap as an array A. The root of the
tree is stored in A[0], and the left child and right child of a node A[i ] are stored
in A[2i + 1] and A[2(i + 1)], respectively. From this follows that the parent of a
node A[i ] is located in A[⌊ i−2 1 ⌋]. Because a binary heap is a complete binary tree,
the array implementation is more space-efficient as opposed to a linked structure
implementation [24].
In conclusion, the algorithm uses the input data to initialize a 2D-array of node
structs. A min priority queue is implemented using a min binary heap and every
node of the graph is added to the queue. The algorithm explores the first node
in the priority in the queue, visits its adjacent nodes and updates their position in
the priority queue. The algorithm keeps exploring new nodes until the destination
has been explored. The path is then backtracked and returned as an array of
coordinates.
5.3. Pathfinding Algortihm 37

Start

Input: 2D-array containing the


"cost" of every grid cell of a mine-
field, start and end positions

Implement priority queue

Add each entry of input


array to priority queue

Has end node yes


Backtrace path
been explored?

no Output: Array contain-


ing the coordinates of
Extract entry from priority every path segment
queue with lowest path cost.
Mark the entry as explored

Stop
For each adjacent entry
of the explored entry
update its path cost

Update the priority queue

Figure 5.3: Flow chart of Dijkstra’s algorithm


38 Chapter 5. Program design

5.4 Visualization
5.4.1 Understanding the rationale for visualization
The solution for our software program is the determining of the optimal route
based on the conditions given to the program, for a certain area. Thus the solution
does not directly relate to a visualization. Instead, the route is the solution/result.
The format of the optimal route in our program is a 2D array, containing the co-
ordinates in specific order, such as [ [1,0], [1,1], [1,2], (...)]. This format, however,
is difficult to interpret and understand. Therefore, visualizing the outcome of our
program is helpful insofar as understanding the outcome and the result. Yet, it is
not necessary or integral to the solving of the underlying problem, that is, maneu-
vering through a minefield.

The visualization of the optimal path through a minefield would be dependent


on the modelling of the real world in our software application. In our case and
for our project, we have decided to model the world in a matrix, thus we will
visualize a matrix with an accompanied optimal route. Presenting the optimal
route through a minefield is achieved by overwriting the cells belonging to the
optimal route, with a distinct color. While a simple console visualization written
in C theoretically could show the optimal route, we have determined that it is quite
difficult to extract the information regarding the terrain and the area that has been
analyzed, due to the lack of customization and visualization tools available.

5.4.2 Method
In order to visualize an area, we must first understand how terrain is viewed.
When looking at an area from a two dimensional perspective, we look from above,
towards the ground. This means that what we see is the last element not obscured
by anything else. In a given terrain we may have water, rocks, soil, grass, bushes,
trees and so on. Looking from above, we only see water if there is no land covering
it. We only see land, soil and grass if there are no bushes or trees covering it.
This can be seen in the satelite image below. In order to visualize the area being
analyzed in our program, the same concept of layering is applied.

Figure 5.4: Example of terrain from two dimensional perspective, Google Maps ©
5.4. Visualization 39

This entails that when coloring and visualizing, a decision has to be made re-
garding the overlapping of different data sources. For example, any forest, water
or road cells should be prioritized more than the underlying soil type, thus replac-
ing the individual cell. Similarly, in a cell with both water and vegetation present,
a blended color of blue and green would be teal, presenting a swampy area. Fi-
nally, for all cells in the optimal route, their color will overwrite all else, thereby
making the optimal route clear in relation to the area. This pre-processing func-
tionality will still be programmed in C, and the final matrix ready to be visualized
will be exported to an external file, ready to be visualized.
Regarding the pre-processing of the matrix before it is ready for initialization,
the following hierarchy can be used:

Priority Terrain
1 Optimal route
2 Mines
3 Roads
4 Vegetation
5 Water
6 Soil

Table 5.1: Civilian status of casualties in 2021[33]

In the structure above, the soil matrix will be the baseline matrix to be visual-
ized, which means that it will be ’drawn’ first across the entire matrix. Then, the
water matrix, more precisely the cells containing water, will overwrite said cells
previously holding soil. Afterwards, the cells containing vegetation will overwrite
cells containing soil but merge with cells containing water, creating a swamp.
Next, cells with roads will overwrite any other cell. After that, mines will be plot-
ted on top of any other terrain previously occupying the cells containing mine
data. Lastly, all the cells in the optimal route will be plotted and the optimal route
thus becomes visible.
The resulting matrix contains cells with values between 0 to 1. However, the
meaning of these values is not regarding the cost/weight of the individual cell in
relation to the optimal route, but solely signifies the color to be drawn. For exam-
ple, the cells containing soil will have a value of either 0.0 or 0.1, depending on
the hardness of the soil and the cells containing water will have a value of 0.2 or
0.3 depending on the water depth. Lastly, the cells contained in the optimal route
will have a value of 1. The tool used for visualization will match each value to a
color.The complete color-map can be viewed on the next page.

As previously mentioned, we have determined that a console visualization is


inadequate for a viewer to fully understand the optimal route within the context
of the area being analyzed. For this reason, we believe it is more fruitful to use
libraries outside of C, namely the libraries ’NumPy’ and ’Matplotlib’, available
40 Chapter 5. Program design

with the programming language Python, a high level and interpreted, general
purpose language. A lot of tools and libraries related to data formatting, data
science and visualization are created in the programming language Python, due
to its effectiveness and capabilities within data science and statistics.
We must emphasize that the pre-processing functions and calculations being
made to create the matrix to be visualized are written in C, as well as the exporting
of the matrix to a txt. file. Essentially, the purpose of using Matplotlib is to read
the values from the txt. file, and paint a color corresponding to said value. We do
not use Python or any Python library to perform calculations or affect values in
any way. The Python script is solely used for drawing a color in a cell, based on
the values we have calculated and exported in C.
Since our program is written in C, we are working with two-dimensional arrays
of type double when we work with matrices. However, the Python visualization
tool known as ’Matplotlib’ does not accept C matrices as input, hence a conver-
sion is necessary before visualization is possible. In order to pass a 2D array into
Matplotlib, we will have need to convert it into a Python array or a ’NumPy’ two-
dimensional array. NumPy is a tool for working with arrays, introducing features
and functionality that extend the capabilities of ordinary Python code. Thus, we
can use NumPy collaboratively with Matplotlib, to aid in the visualization of the
terrain and the optimal route.

Below is an example of how a given colormap can help visualize the terrain
as well as the optimal route determined by Dijkstra’s algorithm, see table 5.2 and
figure 6.1. In the example, the optimal route from the bottom left corner to the
upper right corner is found, and revolves around crossing the river by using the
bridge, while simultaneously avoiding landmine hotspots. The route is clearly
utilizing the roads for faster maneuvering, but taking the dangerous landmine
zones into account. A thorough explanation on the pre-processing functions as
well as the settings used when determining the optimal route below will be given
in the implementation section for our project.

Cell Value Meaning Color


0.0 Soft soil
0.1 Hard soil
0.2 Shallow Water
0.3 Water
0.4 Swamp
0.5 Low Vegetation
0.6 High Vegetation
0.7 Poor road
0.8 Solid road
0.9 Low mine %
1.0 Very high mine %
1.1 Optimal Route

Table 5.2: Colormap used for visu- Figure 5.5: Visualized terrain and opti-
alization mal route
Chapter 6

Implementation

6.1 User Settings


The first part of the program revolves around the user deciding on certain prefer-
ences to be taken into account when analyzing the optimal route.
As explained in section 5.2.1 on the design of user settings, the user is prompted
to decided on 3 settings, namely the troop type, risk factor and matrix size. In a
finished version, the number of different settings would be substantially larger
compared to the current version, but for the current version, these are the set-
tings that have been implemented thus far. The data structure chosen for the user
settings is the struct datatype in C, allowing for distinct settings of primitive or
custom data types such as enumerations.
The User Settings struct is designed as shown below:
1 typedef struct {
2 troop_settings troopSettings;
3 priorities priorityLevel;
4 additional_settings additionalSettings;
5 } userSettings;

The abovementioned user settings is a struct, type-defined to userSettings,


and consists of 3 simple settings. These 3 settings are structs themselves, namely
troop_settings, priorities and additional_settings, as shown below:
1 typedef struct {
2 double maxWaterDepth;
3 double maxMineRisk;
4 double maxSlope;
5 double maxRoad;
6 double maxTerrainDifficulty;
7 } troop_settings;
8
9 typedef struct {
10 // other settings

41
42 Chapter 6. Implementation

11 int size;
12 } additional_settings;
13
14 typedef struct {
15 // risk road_weight;
16 risk mineRisk;
17 // risk vegetation_weight;
18 } priorities;

The troop_settings struct consists of 5 different double values that will be used
when configuring the matrices. They are defined as double values, since their
values will be used comparatively when deciding whether or not to manipulate
or change individuals cells in the configuration process of our program, so they
ought to be the same data type as individual cells of the matrices.
The additional_settings struct consists of only an integer value, named size,
which will be used when creating the size of the matrix to be analyzed.
The priorities reflect the risk level or priorities associated with differing factors,
such as the use of roads, the acceptable mine risk and the desire to avoid dense
vegetation, to name a few examples that we have given. The only risk factor cur-
rently used by our software is the mine risk, but further implementations would
make sense given more time. The risk/priority type used is an enum shown be-
low:
1 typedef enum {
2 Low,
3 Medium,
4 High
5 } risk;

The last data structure created is the enum for troop type selected by the user:
1 typedef enum {
2 SquadUnit, // 7−14 soldiers
3 CompanyUnit, // 100−250 soldiers
4 LogisticUnit, // Vehicles transporting troops, supplies and equipment
5 ArmorUnit, // Armored vehicles such as tanks
6 } troop;

The troop enum is used when setting the troop_settings during the initial-
ization phase of the program. Our program works in such a way that there are
predefined settings for the specific troop types, such that the settings used when
running the program are already decided, depending on the choice of troops by
the user. The settings are initialized in the main function of the program in the
following line:
1 int main() {
2
3 // Initialize user settings
6.1. User Settings 43

4 userSettings userSettings = obtain_user_settings();

Before showcasing the function, the following variables are created:


1 // Strings matching to enum values
2 const char* stringIsWaterPassable[] = {"False", "True"};
3 const char* stringTroopType[] = {"Squad unit", "Company unit", "Logistic unit",
"Armor unit"};
4 const char* stringRiskLevel[] = {"Low", "Medium", "High"};
5 const char* stringPrioritizeCover[] = {"False", "True"};
6 const char* stringClearanceType[] = {"none","MICLIC","Plow","Rafael"};
7
8 // Predefined settings for different troop sizes
9 double squadUnitSettings[NUMBER_OF_TROOP_SETTINGS] = {0.6, 1, 1, 1, 1};
10 double companyUnitSettings[NUMBER_OF_TROOP_SETTINGS] = {0.95, 0.2, 0.9,
1, 0.9};
11 double logisticUnitSettings[NUMBER_OF_TROOP_SETTINGS] = {1, 1, 1, 1, 1};
12 double armorUnitSettings[NUMBER_OF_TROOP_SETTINGS] = {1, 1, 1, 1, 1};

The variables stringIsWaterPassable and similar arrays of strings are used to


write the actual value of the beforementioned enums in text, which can be seen
in the function obtain_user_settings below. They serve no actual purpose other
than providing information to the user. The arrays of double values following
the arrays of strings are used to define the settings later on. Here is the function
obtain_user_settings:
1 // Ask user to decide settings, then return the settings.
2 userSettings obtain_user_settings() {
3 userSettings chosenSettings;
4
5 printf("\nPlease decide setup parameters");
6 printf("\nDecide the following 3 settings:\n");
7 printf("\n1. Which troop type should maneuver?");
8 printf("\n2. How much risk is acceptable?");
9 printf("\n3. Size of matrices?\n");
10
11 //1st setting
12 printf("\n1. Which troop type should maneuver? ('0' = Squad | '1'
= Company | '2' = Logistic unit | '3' = Armor unit )\n");
13 int troopType;
14 scanf("%d", &troopType);
15 add_troop_settings(&chosenSettings, troopType);
16 printf("You have choosen %s as the troop type", stringTroopType[
troopType]);
17
18 //2nd setting
19 printf("\n2. How much risk is acceptable? ('0' = Low risk | '1' =
44 Chapter 6. Implementation

Medium risk | '2' = High risk )\n");


20 scanf("%d", &chosenSettings.priorityLevel.mineRisk);
21 printf("You have chosen a %s risk level", stringRiskLevel[chosenSettings.
priorityLevel.mineRisk]);
22
23 // 3rd setting
24 printf("\n3. What is the size of the input matrices?\n");
25 scanf("%d",&chosenSettings.additionalSettings.size);
26
27 printf("\nYour chosen settings are: \n");
28 printf("1. Troop type: %s\n", stringTroopType[troopType]);
29 printf("2. Risk level: %s\n", stringRiskLevel[chosenSettings.
priorityLevel.mineRisk]);
30 printf("7. Size of matrices: %dx%d\n", chosenSettings.
additionalSettings.size,chosenSettings.additionalSettings.size);
31 return (chosenSettings);
32 }

The function initializes a userSettings variable named chosenSettings. The


user prompted with the entering of values whereafter they are inserted into the
chosenSettings variables with the scanf function. To provide information on the
selected options, the arrays of strings are used to print the string value of the enum
variable chosen by the user.
The last function in this segment is the add_troop_settings, which takes the
chosenSettings as input and changes the currentTroopSettings to the settings dic-
tated by the trooptype as shown before:
1 void add_troop_settings(userSettings *settings, int troopType){
2 double *currentTroopSettings = NULL;
3 if(troopType == SquadUnit){
4 currentTroopSettings = squadUnitSettings;
5 } else if(troopType == CompanyUnit){
6 currentTroopSettings = companyUnitSettings;
7 } else if(troopType == LogisticUnit){
8 currentTroopSettings = logisticUnitSettings;
9 } else if(troopType == ArmorUnit){
10 currentTroopSettings = armorUnitSettings;
11 } else printf("Invalid troop type!");
12
13 settings−>troopSettings.maxWaterDepth = currentTroopSettings[0];
14 settings−>troopSettings.maxMineRisk = currentTroopSettings[1];
15 settings−>troopSettings.maxRoad = currentTroopSettings[2];
16 settings−>troopSettings.maxSlope = currentTroopSettings[3];
17 settings−>troopSettings.maxTerrainDifficulty = currentTroopSettings[4];
18 }
6.2. Import of Mock Data 45

the function changes the values of the chosenSettings as opposed to returning


a new variable/instance of userSettings.

6.2 Import of Mock Data


The mock data that we have consist of bitmap(BMP) files. These images are made
up of an overview of a given terrain, where each pixel indicates the severity of a
point in the terrain. This is given by the value of the color, which goes from white
to black. This mock data is supposed to imitate real data that someone would
want to feed our program. The bitmap file type itself is designed in a standardized
way by Microsoft, which makes it possible to know what the different values at
different points in the file mean.[4]
In order for us to be able to use this data, we need to process it. This is
done with the following 3 functions whose prototypes are defined in the header
(bmp_import.h):
1 #include "stdio.h"
2 #include "stdlib.h"
3 #include "math.h"
4 #include "../Configuration Of Matrices/RelationshipMethods.h"
5
6 //The offset of values in the bitmap file type
7 #define OFFSET_OF_FILETYPE_VALUE 0
8 #define OFFSET_OF_PIXEL_DATA 10
9 #define OFFSET_OF_HEADER_SIZE 14
10 #define OFFSET_OF_WIDTH 18
11 #define OFFSET_OF_HEIGHT 22
12 #define OFFSET_OF_BITS_PER_PIXEL 28
13 #define OFFSET_OF_COMPRESSION 30
14 #define OFFSET_OF_COLOR_TABLE_SIZE 46
15 #define OFFSET_OF_COLOR_TABLE 54
16
17 //Values we support
18 #define SUPPORTED_FILETYPE_VALUE 0x424D
19 #define SUPPORTED_HEADER_SIZE 40
20 #define SUPPORTED_BITS_PER_PIXEL 4
21 #define SUPPORTED_COMPRESSION_TYPE 0
22
23 //Mask
24 #define NIBBLE_MASK 0x0F
25
26 //Prototypes
27 double** import_bmp(char* path);
28 int get_file_size(FILE* file_pointer);
29 void check_bmp_supported(const char* bmp);
46 Chapter 6. Implementation

The header file also contains all of the offsets of data in the file type, the values
we support, a mask value and the libraries that bmp_import.c uses.

The import_bmp() function takes a path to a file as a parameter and returns


a (double**) two-dimensional floating point number array, which is our standard
way of storing matrices.
The get_file_size() function takes a file pointer and just returns the total size
of the file size. It also returns the reading point back to the beginning of the file
again.
The check_bmp_supported() uses a char pointer as a parameter, which is an
array of all the bytes in the bmp that needs to be checked whether it is a supported
BMP file type or not, since there are multiple ways of writing up the data of the
BMP’s. It does these checks by looking at the values at different places in the file
in order to get specific information about the bitmap, such as whether or not it
actually is a bitmap. It doesn’t return any values, because the function itself exits
the program with an exit failure code, if the BMP is unsupported. The functions
checks that:

• It is indeed a BMP

• Header size is correct

• The BMP is 4 bits per pixel

• The BMP is stored uncompressed

The import_bmp() is in a way the primary function of the script, since it is the
one which gets called by other scripts and uses the other to functions of the script.
Which can be seen in the code:
1 //The specific locations of values in the bitmap can be found at: (https://en.
wikipedia.org/wiki/BMP_file_format)
2 double** import_bmp(char* path) {
3 //Opens the file, with read binary parameter
4 FILE* filePointer = fopen(path, "rb");
5
6 //Exit with failure if the file opening failed
7 if (filePointer == NULL) {
8 exit(EXIT_FAILURE);
9 }
10
11 //Get the size of the file
12 int fileSize = get_file_size(filePointer);
13
14 //Make char(size of 1 byte) array to store the file and write the file into the
array
15 char bmp[fileSize];
16 fread(&bmp, fileSize, 1, filePointer);
6.2. Import of Mock Data 47

17
18 //Checks that the bitmap is supported for the function
19 check_bmp_supported(bmp);

The import_bmp() function starts by getting a file pointer from the path and
reads with binary mode since we are reading a bitmap. Then it makes sure that the
path is correct and then uses get_file_size() in order to get the size of the bitmap so
it can make a char array containing the bytes of the bitmap. When it then have the
whole file in the array, it then calls the check_bmp_supported() function to ensure
that the bitmap is correctly formatted.
20 //Get the pixel data offset from the 10−14 bytes in the bmp and the width,
height and bits per pixel from the different locations in the bmp
21 int pixelDataOffset = (int)bmp[OFFSET_OF_PIXEL_DATA];
22 int width = (int)bmp[OFFSET_OF_WIDTH];
23 int height = (int)bmp[OFFSET_OF_HEIGHT];
24 int bitsPerPixel = (short)bmp[OFFSET_OF_BITS_PER_PIXEL];
25 int colorTableSize = (int)bmp[OFFSET_OF_COLOR_TABLE_SIZE];
26
27 //Uses other function to create a matrix that follows the standard for this
project, which will store the 0−1 values
28 //given the strength of the color for each pixel in the bitmap
29 double** pixelColorStrengthNormalizedArray = create_dynamic_matrix(
width);
30
31 //Calculates the size of the rows in the pixel storage part of the bitmap,
there is often padding at the end of rows
32 int rowSize = (int)ceil(((double)(bitsPerPixel * width) / 32)) * 4;
33
34 //Get color table
35 unsigned char colorTable[colorTableSize]; //16 times 4 bytes for RGBA
36 for (int i = 0; i < colorTableSize; ++i) {
37 colorTable[i] = bmp[OFFSET_OF_COLOR_TABLE + i]; //Byte 54 is the
start of color table
38 }

After that it gets some different values from different places in the bitmap file
and then uses the CreateDynamicMatrix() function, which comes from another
script in the project called RelationshipMethods, in order to create a matrix in a
standardized way throughout the project. The specific locations of different values
such as the width and height of the pixel array in the bitmap and other specific
things about the bitmap can be found in the sources.[4] The pixels of the bitmap
is stored so padding gets added so each row is a multiple of 4. And we then use
some math to get the correct row size. Then another byte array gets declared and
filled in order for us to be able to easily access the color table of the bitmap.
39 //Loop over each pixel
48 Chapter 6. Implementation

40 for (int i = 0; i < height; ++i) {


41 for (int j = 0; j < width; ++j) {
42 //Gets a byte from the specific pixel location
43 char indexValue = bmp[pixelDataOffset + i * rowSize + j/2];
44
45 //Gets the index of the pixel, so we can map it to the correct color
46 int maskedIndexValue = indexValue & NIBBLE_MASK;
47
48 //Calculate normalised value from one of the color chanels of the
pixel, given by the index
49 //(only one chanel is needed since input is black and white so RGB
are all the same)
50 double finalValue = (double)colorTable[maskedIndexValue * 4] /
UCHAR_MAX;
51
52 //Save the value in the array
53 pixelColorStrengthNormalizedArray[j][i] = finalValue;
54 }
55 }
56
57 //Returns the extracted matrix from the bitmap
58 return pixelColorStrengthNormalizedArray;
59 }

The color table and row size is then used in some for loops in order to iterate
over the pixel array and then save a normalized 0 to 1 value from each pixel in
the standardized matrix that was made at line 30. It does this by firstly getting
the index of the current pixel, which is calculated by using the offset of the pixel
array, the size of the row and the current column and row it has gotten to. But
since the bitmaps we support are 4 bits per pixel, the index byte(char) we have has
other values that we don’t want. Therefore we mask it with 0x0F(NIBBLE_MASK),
which just gives us the 4 bits of the byte that we need. We can then use this index
to the the color of the pixel from the color table. This value then directly gets
normalized and saved and then get put in the final array that, when the whole
pixel array have been run through, gets returned.
1 //Checks whether the bitmap is supported or not
2 void check_bmp_supported(const char* bmp) {
3 //Exit with failure if not a bitmap file
4 if ((short)bmp[OFFSET_OF_FILETYPE_VALUE] ==
SUPPORTED_FILETYPE_VALUE) {
5 printf("\nUnsupported filetype");
6 exit(EXIT_FAILURE);
7 }
8
9 //Exit with failure if bitmap header is not 40 bytes and therefore a bmp we
6.2. Import of Mock Data 49

don't support
10 if (bmp[OFFSET_OF_HEADER_SIZE] != SUPPORTED_HEADER_SIZE) {
11 printf("\nUnsupported header size");
12 exit(EXIT_FAILURE);
13 }
14
15 //Exit with failure if bitmap is not stored with 4 bits per pixel, because we
don't support that
16 if ((short)bmp[OFFSET_OF_BITS_PER_PIXEL] !=
SUPPORTED_BITS_PER_PIXEL) {
17 printf("\nUnsupported bpp");
18 exit(EXIT_FAILURE);
19 }
20
21 //Exit with failure if bitmap is not uncompressed, because we don't support
that
22 if (bmp[OFFSET_OF_COMPRESSION] !=
SUPPORTED_COMPRESSION_TYPE) {
23 printf("\nUnsupported compression");
24 exit(EXIT_FAILURE);
25 }
26 }

In the code above you can see the check_bmp_supported() function. It starts
by checking the 2 first bytes of the file in order to see whether or not the have
the "magic numbers" which shows it is indeed a bitmap. Then it makes sure
that the header size is correct, that the bitmap is stored with 4 bits per pixel and
uncompressed. If any of these checks fail then it runs the exit function with the
exit code EXIT_FAILURE, which stops the program.
1 //Get the size of a file and reset the file pointer to the beginning of the file
2 int get_file_size(FILE* file_pointer) {
3 //Sets the positions to the end of the file
4 fseek(file_pointer, 0, SEEK_END);
5
6 //Gets the position of the end of the file, which also is the total size
7 int size = ftell(file_pointer);
8
9 //Sets the reading position back to the beginning of the file
10 fseek(file_pointer, 0, SEEK_SET);
11
12 //Returns the size of the file
13 return size;
14 }

And lastly in the code above the get_file_size() function is. Which starts by
moving the position of the file pointer to the end of the file with the fseek function.
50 Chapter 6. Implementation

Then it uses the ftell to get the position of the file pointer, which when at the end
of the file is equal to the size of the file, and saves it. Then it moves the position
of the file pointer back to the beginning of the file and returns the size of the file
which were saved earlier. It does this in order to not interfere with the reading of
the file, which would fail if you tried to read, but was at the end of the file.

6.3 Matrix Configurations


We discussed the purpose and intention of implementing a matrix configuration
in the pre-processing section (5.2.3), but how did it end being implemented? Each
of the different matrices has their own configuration function:
1 void ConfigureDepthMap(double** waterMap, double** road_map, userSettings
*settings);
2
3 void ConfigureMineMap(double** mineMap, userSettings *settings);
4
5 void ConfigureSoilMap(double** soilMap, userSettings *settings);
6
7 void ConfigureVegetationMap(double** vegetationMap, userSettings *settings);
8
9 void ConfigureRoadQualityMap(double** roadQualityMap, userSettings *
settings);

All the function share commonalities, they take their own double** map and
userSettings *settings as an input. This is because the configuration takes into
account the settings that have something to do with the matrix in question, namely
the troop settings:
10 typedef struct {
11 troop_settings troop_settings;
12 priorities priority_level;
13 additional_settings additional_settings;
14 } userSettings;
15
16 typedef struct {
17 double max_water_depth;
18 double max_mine_risk;
19 double max_slope;
20 double max_road;
21 double max_terrain_difficulty;
22 }troop_settings;

Containing max_water_depth, max_mine_risk, max_slope, max_road, max_terrain_difficulty,


which all determines whether a certain cell on the map is at all passable, meaning
whether the troop would be able to traverse that part of the terrain. If the case is
6.3. Matrix Configurations 51

that the troop cannot pass that cell, it is then given a value of -1 to signify that it
is impassable to the path finding algorithm, here are two examples:
23 void ConfigureVegetationMap(double** vegetationMap, userSettings *settings){
24 for (int i = 0; i < settings−>additional_settings.size; ++i) {
25 for (int j = 0; j < settings−>additional_settings.size; ++j) {
26 if (vegetationMap[i][j] > settings−>troop_settings.
max_terrain_difficulty){
27 vegetationMap[i][j] = −1;
28 }
29 }
30 }
31 }
32
33 void ConfigureRoadQualityMap(double** roadQualityMap, userSettings *
settings){
34 for (int i = 0; i < settings−>additional_settings.size; ++i) {
35 for (int j = 0; j < settings−>additional_settings.size; ++j) {
36 if (roadQualityMap[i][j] > settings−>troop_settings.max_road){
37 roadQualityMap[i][j] = −1;
38 }
39 }
40 }
41 }

They use a double for-loop to iterate through all the cells in the 2-dimensional
array, which is the terrain map, then an if-statement checks whether the cell is
impassable in regards to the settings. Like having too much vegetation, or having
too bad quality in the roads. There is a certain map that involves a little more than
the rest and that is the water map.
42 void ConfigureDepthMap(double** waterMap, double** road_map, userSettings
*settings){
43 for (int i = 0; i < settings−>additional_settings.size; ++i) {
44 for (int j = 0; j < settings−>additional_settings.size; ++j) {
45 if (road_map[i][j] != −1 && road_map[i][j] < 1){
46 waterMap[i][j] = 0;
47 } else if (waterMap[i][j] > settings−>troop_settings.max_water_depth)
{
48 waterMap[i][j] = −1;
49 } else {
50 waterMap[i][j] = waterMap[i][j] / settings−>troop_settings.
max_water_depth ;
51 }
52 }
53 }
54 }
52 Chapter 6. Implementation

This map takes into account whether a road exists as impassable water does
not matter if a bridge exists.

6.4 Data Processing


At this stage of the program, each of the configured matrices from section 5.2.3 is
assigned a weight. These will later be used to combine every map into a processed
matrix that stores the weighted sum of the configured matrices.
1 void determine_weights(weightedMatrix matrix_array [], int array_length,
userSettings *settings){
2 double base_weight = (double)1/array_length;
3
4 if(matrix_array−>type == mine) {
5 switch (settings−>priorityLevel.mineRisk) {
6 case High:
7 matrix_array−>weight = base_weight;
8 case Medium:
9 matrix_array−>weight = 0.5;
10 case Low:
11 matrix_array−>weight = 0.75;
12 }
13 base_weight = (1−matrix_array−>weight)/(array_length−1);
14 } else matrix_array−>weight = base_weight;
15
16 for (int i = 1; i < array_length; ++i) {
17 matrix_array[i].weight = base_weight;
18 }
19 }

When selecting the settings the user is prompted to enter the acceptable risk
level of the path. This setting is used by the function determine_weights() when
assigning a weight to the mine map. As mentioned in section 5.2.4, a lower risk
implies a higher weight. A switch statement is used to handle the three cases, after
which the base_weight is modified in case medium or low risk has been chosen.
The base_weight is modified to ensure that the overall weight remains 1.
For the function to work as intended, the mine map must be stored at index 0
in the matrix_array when passed to the function. Otherwise, every element in the
matrix array will be assigned the same weight.
Subsequently, the function process_matrix() is called. The purpose of the func-
tion is to allocate and return a 2D array that stores the weighted sum of the con-
figured matrices.
1 double **process_matrix(weightedMatrix matrix_array[], int array_length, int
matrixSize){
6.5. Dijkstra’s algorithm 53

2 double **processed_matrix = create_dynamic_matrix(matrixSize);


3 double **current_matrix = NULL;
4 for (int i = 0; i < array_length; ++i) {
5 current_matrix = matrix_array[i].matrix;
6 for (int j = 0; j < matrixSize; ++j) {
7 for (int k = 0; k < matrixSize; ++k) {
8 if (processed_matrix[j][k] == −1){
9 } else if (current_matrix[j][k] == −1){
10 processed_matrix[j][k] = −1;
11 } else processed_matrix[j][k] += matrix_array[i].weight *
matrix_array[i].matrix[j][k];
12 }
13 }
14 }
15 return processed_matrix;
16 }

The first for-loop runs through every configured matrix while the following
double for-loop is used to iterate through every entry of a given matrix. For
every entry of a matrix, there are three cases to handle. These are handled using
an if-else ladder. Essentially, the control statements ensure that a given entry in
processed_matrix stores the weighted sum unless at least one configured matrix
stores the value -1 in the same entry. In this case, -1 is stored in proccesed_matrix.
This way, impassable areas remain impassable.

6.5 Dijkstra’s algorithm


The implementation of Dijkstra’s algorithm can be split into 3 parts:

1. Setup and initialization - implementation of the graph and priority queue

2. Main loop - nodes are visited, updated and explored until the optimal path
to the destination is found

3. Backtracking path

The algorithm is implemented in the following function:


1 typedef struct{
2 int **path; // array containing coordinates of path segments
3 int path_length; // number of nodes in path
4 }result;
5
6 result *dijkstra(double **input, int size, const int start_pos[], const int end_pos[]);

In line 6, the parameter double **input is the processed 2D-array returned by


process_matrix() in section 6.4. The function returns a pointer to a result struct
54 Chapter 6. Implementation

which contains the found path and its length. If no path is found NULL is re-
turned.
Before the path can be found a graph and a min priority queue must be de-
clared. The graph is implemented as a 2D-array of entry structs. An entry can be
though off as a node with a set of proterties. The declaration of the entry struct is
shown below:
7 typedef struct{
8 int pos[2]; // position in matrix
9 double weight; // weight of edges directed to node
10 double current_cost; // cost of currently cheapest path to node
11 struct entry *previous; // Every node keeps track of the previous node in
the path. This makes it possible to backtrack the final path
12 int priority_status; // Keeps track of index in priority queue
13 }entry;

Having declared the graph and the priority queue, both are passed as argu-
ments to the initialization() where they are initialized. In this connection, it is
worth noting that the member current_cost of every entry is assigned INFINITY
(a macro constant from the library math.h) and that NULL is assigned to the (en-
try*)previous member.
The only node that initially differs from the rest is the starting node, declared
as root_entry in line 12. Since the cost of the shortest path to this node is simply
its weight, the node is prioritized above every other node. This is handled by the
function decrease_entry(), by updating the node whose current index, is passed as
an argument to the function.
14 result *dijkstra(double **input, int size, const int start_pos[], const int end_pos[]){
15 entry **matrix = declare_graph(size); // remember to free memory
16 int queue_size = size*size;
17 entry *priority_queue[queue_size]; // Declaration of priority queue
18 entry *root_entry = &matrix[start_pos[0]][start_pos[1]];
19 entry *goal = &matrix[end_pos[0]][end_pos[1]];
20
21 //Initialization of graph and priority queue
22 initialization(size, priority_queue, matrix, input);
23
24 // The starting node is initialized separately, as it differs from the rest
25 root_entry−>current_cost = root_entry−>weight;
26 decrease_entry(priority_queue, root_entry−>priority_status);

As mentioned in section 5.3 the priority queue is implemented as a min binary


heap and every element in the queue is assigned a key, by which the elements are
prioritized. Thus, the index of a node is updated whenever the key of the node’s
parent is less than that of the node. This is implemented in decrease_entry()
utilizing a while-loop to swap the indices of a given node with its parent until the
above-mentioned criterion is satisfied.
6.5. Dijkstra’s algorithm 55

28 void decrease_entry(entry *queue[], int child_index){


29 int parent_index = (child_index−1)/2;
30 while (queue[child_index]−>current_cost < queue[parent_index]−>
current_cost){
31 swap_entries(&queue[child_index], &queue[parent_index]); //function
does not swap priority_status
32
33 //Update indices
34 child_index = parent_index;
35 parent_index = (child_index−1)/2;
36 }
37 }

At this point, the program proceeds to traverse the graph using a while-loop.
At the beginning of every iteration, the function extract_min() is called to extract,
remove and return the first entry of the priority queue. To maintain the structure
of the binary heap, the last element in the priority queue temporally becomes the
root node and the queue length shrinks by one. Lastly, the index of the root node
is updated by swapping the node with its highest prioritized child. This process
is repeated until the min-heap property is restored.
1 entry *extract_min(entry *queue[], int *queue_size){
2 entry *entry_to_return = queue[0];
3 entry_to_return −> priority_status = −1; // −1 signifies that the entry is no
longer in the queue
4 queue[0] = queue[*queue_size−1]; // last element becomes first element
5 queue[0] −> priority_status = 0; // status for the currently new first element
is updated.
6 *queue_size −= 1;
7
8 int index = 0;
9 int left_index = left_child_index(index, queue, queue_size);
10 int right_index = right_child_index(index, queue, queue_size);
11
12 while (left_index != −1 || right_index != −1){ // −1 indicates that child does
not exist or that it is correctly located
13 int min_index;
14
15 if (left_index != −1 && right_index != −1) {
16 min_index = (queue[left_index]−>current_cost < queue[right_index
]−>current_cost) ? left_index : right_index;
17 } else if (left_index != −1){
18 min_index = left_index;
19 } else{
20 min_index = right_index;
56 Chapter 6. Implementation

21 }
22 swap_entries(&queue[index], &queue[min_index]);
23 index = min_index;
24
25 left_index = left_child_index(index, queue, queue_size);
26 right_index = right_child_index(index, queue, queue_size);
27 }
28
29 return entry_to_return;
30 }

Whenever a node is no longer in the priority queue it is said to be explored,


meaning that the cheapest path to the given node has been found. Line 26 checks
if a valid path exists, if not, NULL is returned.
31 // Loop keeps running until the end node is explored
32 while (goal−>priority_status != 0){
33 entry *current_entry = extract_min(priority_queue, &queue_size); //
current_entry is the node with the highest priority in the priority
queue
34
35 if (current_entry != root_entry && current_entry−>previous == NULL){
36 return NULL;
37 }
38
39 int *current_pos = current_entry−>pos;
40 int neighbor_index = 0; // keeps track of number of valid neighbors
41 entry *neighbors[4];
42
43 find_valid_neighbors(current_pos, matrix, &neighbor_index, neighbors,
size);
44 visit_valid_neighbors(neighbor_index, current_entry,neighbors,
priority_queue);
45 }

When a node has been explored its adjacent unexplored nodes are visited by
the function visit_valid_neighbors(). For every unexplored neighbor the function
checks if a cheaper alternative path passing through current_entry has been found.
If this is the case, the new path and its cost are updated as well as the index in the
priority queue of the visited node.
46 void visit_valid_neighbors(int neighbor_index, entry *current_entry, entry *
neighbors[4], entry **priority_queue){
47 // Loops through every neighbor
48 for (int i = 0; i < neighbor_index; i++){
49 double path_cost = current_entry−>current_cost + neighbors[i]−>weight;
50 if(path_cost < neighbors[i]−>current_cost){ // Checks if a better
6.6. Visualization 57

alternative path has been found


51 neighbors[i]−>current_cost = path_cost;
52 neighbors[i]−>previous = current_entry;
53 decrease_entry(priority_queue, neighbors[i]−>priority_status); //
Updates placement of neighbor in priority queue
54 }
55 }
56 }

In case a path exists between the starting and ending nodes, the program exits
the main loop and the function backtrace_path() is called. The essence of the
function is a while loop which backtracks the path.
57 while (path_section−>previous != NULL) {
58 add_to_path(path_array,current_index,path_section);
59 path_section = path_section−>previous;
60 current_index++;
61 }

Starting at the end node, the consecutive node of the path is backtracked by
accessing the member entry previous and storing it in an array. The process is
repeated for every consecutive node of the path until the starting node has been
reached. At this point the program exits the loop, adds the starting node to the
path and returns the path along with the size of the array in which it is stored.

6.6 Visualization
The process of visualizing the terrain as well as the optimal route is split into 3
parts:

1. Preprocessing - Creating a matrix of values corresponding to colors

2. Exporting - Exporting the values in the matrix to a txt. file.

3. Visualizing - Using Python and Matplotlib, visualize the matrix.

Any individual terrain matrix only contains values with relation to the specific
terrain, so it is insufficient for providing an understanding of the entire area being
analyzed. The processed matrix contains values that do not relate to the specific
terrain but instead the cost/weight associated with passing through a given cell.
For this reason, another matrix must be created containing information for the
entire area, as well as the optimal route. Creating this matrix is the pre-processing
aspect of visualizing the area. As explained earlier, we layer the individual terrains
based on their priority. We have written the function create_matrix_painting() in
our program to accomplish this, taking the size and list of matrices generated by
generate_list_of_matrices() as input :
58 Chapter 6. Implementation

1 double** create_matrix_painting(int size, double*** listOfMatrices) {


2
3 // Allocate arrays of type double, size times
4 double** matrixPainting = malloc(size * sizeof(double*));
5
6 // For each row, allocate a double for each member of the row array.
7 for (int i = 0; i < size; ++i) {
8 matrixPainting[i] = malloc(size * sizeof(double));
9 }
10
11 // For each terrain matrix, "paint" the matrix painting
12 add_listOfMatrices_to_matrixPainting(size, matrixPainting, listOfMatrices);
13
14 return matrixPainting;
15 }

The function create_matrix_painting() allocates memory for a two-dimensional


matrix on line 4. On line 7-8, for each row, the function allocates space for size
number of doubles. On line 12, the function add_listOfMatrices_to_matrixPainting()
is called. This function can be seen below:

1 void add_listOfMatrices_to_matrixPainting(int size, double** matrix, double***


listOfMatrices){
2 add_soil_to_matrix(size, matrix, listOfMatrices[0]);
3 add_water_to_matrix(size, matrix, listOfMatrices[1]);
4 add_vegetation_or_swampland_to_matrix(size, matrix, listOfMatrices[2]);
5 add_road_to_matrix(size, matrix, listOfMatrices[3]);
6 add_mine_to_matrix(size, matrix, listOfMatrices[5]);
7 }

The function add_listOfMatrices_to_matrixPainting() overwrites the cells in


the matrixPainting with the values of each terrain matrix, starting with the soil
matrix, then the water, vegetation, road and lastly mine matrix. The implemen-
tation for each function adding a given terrain to the matrix painting is slightly
different, hence several examples of these are given below. Please reference back
to figure 5.2 under Program design, showcasing the color-map used in our pro-
gram, for a better understanding of the code below:

1 void add_soil_to_matrix(int size, double** matrixPainting, double** terrainMatrix


){
2 for (int i = 0; i < size; i++){
3 for (int j = 0; j < size; j++){
4
5 // If value of cell in soil matrix is less than 0.5, replace cell in
matrixPainting with 0.1 (hard soil)
6.6. Visualization 59

6 if (terrainMatrix[i][j] < 0.5) {


7 matrixPainting[i][j] = 0.1;
8 } else {
9 matrixPainting[i][j] = 0.0;
10 }
11
12 }
13 }
14 }

The function add_listOfMatrices_to_matrixPainting() loops over every element


in the terrain matrix, and checks if the value of the individual cell is below 0.5. If
that is the case, replace the cell in the same position in the matrix painting with
0.1, else 0.0 (signifying hard and soft soil). The functions adding the water matrix,
road matrix and mine matrix are structured virtually the same, except the values
are different. Hence these will not be showcased here but will be available in the
appendix.
1 void add_vegetation_or_swampland_to_matrix(int size, double** matrixPainting,
double** terrainMatrix){
2 // For each cell
3 int lastCellWasSwamp = 1;
4 for (int i = 0; i < size; i++){
5 for (int j = 0; j < size; j++){
6 int isVegetation = 0;
7 int isWater = 0;
8
9 double terrainCell = terrainMatrix[i][j];
10 double* matrixCell = &matrixPainting[i][j];
11
12 if (*matrixCell == 0.2 || *matrixCell == 0.3) {
13 isWater = 1;
14 }
15 if (terrainCell > 0.3) {
16 isVegetation = 1;
17 }
18
19 if (isWater && isVegetation){ // Water has value of 0.3
20 add_swamp_to_matrix(&lastCellWasSwamp, terrainCell,
matrixCell);
21 }
22
23 else if (!isWater && isVegetation) {
24 add_vegetation_to_matrix(terrainCell, matrixCell);
25 }
26
60 Chapter 6. Implementation

27 }
28 }
29 }

The function add_vegetation_or_swampland_to_matrix() is structured slightly


different. The function is designed to paint a color for respectively low vegetation
and high vegetation depending on the value of the cell in the vegetation matrix.
However it is also designed to create a swamp color if there is both water and
vegetation in the same position. For this reason, a boolean (int) variable lastCell-
WasSwamp is created, which value is reversed every time a swamp cell is created.
In a larger area with both water and vegetation, this logic results in a pattern
emerging, as can be seen below:

Figure 6.1: Swamp terrain

The two functions responsible for the actual changing of the cell in the matrix
painting can be seen below. the function add_swamp_to_matrix() checks if the
last cell with water and vegetation was painted as a swamp cell, and changes the
value of the matrix painting thereafter. The function add_vegetation_to_matrix()
checks the value of the cell in the vegetation matrix in the same way as with the
soil matrix, and inserts the correct color values thereafter.

1 void add_swamp_to_matrix(int* lastCellWasSwamp, double terrainCell, double*


matrixCell){
2 if (*lastCellWasSwamp) {
3 if(terrainCell < 0.75) { // low veg
4 *matrixCell = 0.5;
5 }
6 else if (terrainCell > 0.75) { // high veg
7 *matrixCell = 0.6;
8 }
9 *lastCellWasSwamp = 0;
10 } else {
11 *matrixCell = 0.4; // swamp cell
12 *lastCellWasSwamp = 1;
13 }
14 }

1 void add_vegetation_to_matrix(double terrainCell, double* matrixCell){


6.6. Visualization 61

2 if(terrainCell < 0.75) { // low veg


3 *matrixCell = 0.5;
4 }
5 else if (terrainCell > 0.75) { // high veg
6 *matrixCell = 0.6;
7 }
8 }

The last function to be showcased is add_optimal_route_to_matrix(). It loops


over every element in the two-dimensional array optimalRoute, and for the spe-
cific x,y values, those cells are inserted into the matrix painting. It uses the amount
of steps taken in the route to determine the amount of iterations necessary in the
for-loop. This function however is not used until later in the program, after Djik-
stra’s algorithm has determined the optimal route, obviously.

1 void add_optimal_route_to_matrix(int size, double** matrixPainting, int**


optimalRoute, int numberOfSteps){
2 for (int i = 0; i < numberOfSteps; i++) {
3 int x = optimalRoute[i][0];
4 int y = optimalRoute[i][1];
5 matrixPainting[x][y] = 1.1;
6 }
7 }

Once the optimal route has been added to the matrix painting, the matrix has to
be exported to be used by a Python script generating the visualization. For this to
work, the matrix is exported to a txt. file with the function export_matrix_to_file():
1 void export_matrix_to_file(int rows, int cols, double** matrix) {
2
3 FILE *file = fopen("../OutputMatrices/outputMatrix.txt", "w");
4
5 if (file == NULL) {
6 printf("Error opening file for writing. Aborting...\n");
7 exit(0);
8 }
9
10 for (int i = 0; i < rows; ++i) {
11 for (int j = 0; j < cols; ++j) {
12 fprintf(file, "%lf ", matrix[i][j]);
13 }
14 fprintf(file, "\n");
15 }
16
17 fclose(file);
18
62 Chapter 6. Implementation

19 }

The function export_matrix_to_file() opens the txt. file outputMatrix in write


mode. Then it checks if the file pointer is null, meaning that the opening of the
file failed. If that is not the case, it continues to print the value of each cell of the
matrix as a double, creating a newline for each row. Afterwards it closes the file.
The txt. file now has contents as such:

Figure 6.2: Contents of outputMatrix.txt


Chapter 7

Example of a Full Program Run

To more easily mediate how the program behaves, we have prepared an example
showing the input and output when using the program.
The only input required by this software are bitmaps. These bitmaps have
to represent some specific real world data, namely a slope-, water-, mine-, soil-,
vegetation- and road quality map, see figure 7.1.
These bitmaps are then configured based on settings chosen when running the
program and it will then produce the output, being the optimal path in regards
to the settings and data. The color scale goes from 0 to 1, from black to white. A
higher value signifies a high intensity of the given terrain, meaning that a white
color in the water bitmap refers to deep water levels, and black colors reflect no
water being present. Similarly, with the mine matrix, the white dots refer to an
intense/high probability of mines, and the white areas for the vegetation matrix
refers to dense vegetation. The higher the value of a given cell, the more weight is
associated with passing through the given cell.

Upon running the program you will be prompted with deciding on three dif-
ferent settings, which kind of troop that is maneuvering and how much risk you
allow, the size of the area. In this example run we choose 0 (Squad) for troop type,
0 (Low risk) for the risk factor and 100 (100x100) for the size of the area.

The program then finds the optimal path, paints the terrain and paints the path
on top of the terrain. Figure 7.2 depicts the found path from coordinates (0; 0) to
(99; 99).

63
64 Chapter 7. Example of a Full Program Run

(a) Bitmap of the steepness of the given (b) Bitmap of the water depth of the
terrain. given terrain.

(c) Bitmap of areas with possibilities of (d) Bitmap of the soils ability to have
mines. mines planted.

(e) Bitmap of the amount of vegetation (f) Bitmap of the road layout and road
of the given terrain. quality of the given terrain.

Figure 7.1: Bitmap inputs for the example run.


65

Figure 7.2: Example run from coordinates (0; 0) to (99; 99)


Chapter 8

Conclusion

This project aimed to optimize pathfinding and maneuverability in minefields, to


decrease the effectiveness and attractiveness of landmine usage. Due to the cost
effectiveness of producing and deploying landmines, the consequences of their
use are largely ignored by significant military powers in the world today. Con-
sequences such as most of the thousands of casualties each year being innocent
civilians, the desertion of major areas no longer suited for residence and the sub-
stantial costs associated with clearing said minefields.

The proposed software solution is intended to analyze terrain and optimize


pathfinding through a given area, to provide an optimal route, thus decreasing
the effectiveness of landmines. The group behind this project has successfully cre-
ated a software addressing the multifaceted challenge of minefield navigation. By
importing varied relevant data in a bitmap format to matrices, adjust and con-
figure said data in matrices based on user preferences and combine the multiple
matrices using specific weights to produce an aggregate matrix to be analyzed
via Dijkstra’s algorithm, the program finds the optimal route through the given
terrain. Functionally, the software does provide the optimal route under the con-
ditions given, meaning that the accuracy of the result depends specifically on the
accuracy and quantity of available relevant data.

66
Chapter 9

Discussion

The purpose of decreasing the effectiveness of landmines is to hopefully reduce


the number of landmines being used in general. If the enemy forces can maneuver
through landmines, what useful purpose do they serve? In the end, decreasing
their effectiveness ought to reduce the consequences of their use as well, resulting
in less casualties, of which many are civilian and children, as well as avoiding the
desertion of land that could otherwise be used as farmland or civilian residence,
not to mention the departure of citizens no longer wishing to return to their home-
land.

Our solution is intended to collect data from various existing technologies and
combine their value when predicting landmine locations and optimize pathfind-
ing. Advanced drones capable of detecting the location of certain mines combined
with satellite imagery and internal correspondence of military forces create a more
sophisticated and refined understanding of the real world. Utilizing all the avail-
able data can be difficult for a single person to do, and while large teams are
utilized to compute this data in real-world settings[3], such teams are expensive
and can be hard-pressed to perform difficult calculations on multiple front lines
thus delaying offensive operations;
A software program, that can compute all of the available data, would be
capable of hastening decision-making, and would even be able to make decent
decisions independently of aforementioned experts. This is the core argument for
why our software program is useful and valuable in a finished version, and it is
the foundation for the conclusions we draw.
While our program does analyze terrain and optimize pathfinding under the
conditions given, there are a few considerations and points to reflect upon regard-
ing the accuracy and effectiveness of our software program.

1. The input data for our test run consists of only 6 bitmaps. The program thus
has limited data available on which to generate an optimal route.

2. The input data may not be in the form of a bitmap in the real world, and our
program does not accept other inputs.

67
68 Chapter 9. Discussion

3. A lot of necessary and important data to be used is classified and inaccessible


to the public, such as military intelligence and knowledge.

4. Currently, the program configures matrices based on both user settings and
predefined settings. There is however a lack of relational analyses comparing
several data sources to find patterns and conditions relevant in the prediction
of minefield locations.

5. The weights used when configuring and creating our matrices are subjec-
tively decided upon, based on our own understanding of landmine place-
ment, and a more thorough examination in collaboration with military in-
telligence is necessary for optimal accuracy when calculating the optimal
route.

6. Testing and verifying the accuracy and effectiveness of our proposed solution
presents substantial challenges. (mangler en lille sektion)

7. The role of our proposed solution may be assistive rather than dictating in
real life situations (mangler en lille sektion)

Due to time constraints and the scope of this project, there is naturally a lack
of the functionality required for the program to be useful and reliable in real life
situations, especially considering the nature of the problem the group is trying
to solve, involving sending soldiers and troops into a possibly hazardous and
dangerous location. However, while there are issues as mentioned above, our
software program functionally works and analyzes the data available correctly as
it is programmed to do.

9.1 Regarding the use of mock data


Obtaining the relevant and necessary data is an important part of building a re-
liable and useful software program. However, to develop a working version of
our program within the time frame given it was decided that trying to correctly
setup the scraping, collecting and importing of not just varied data sources but
also varied data formats would be too costly with regards to our available time
for this project. Hence, the group behind the project decided to create mock data
consisting of several bitmaps relating to specific data types, whereafter a bitmap
import function was written to showcase how external data may be collected and
formatted for use in our program. Furthermore, one of the sources for our project
confirmed in an interview, that much of the relevant data is classified and unob-
tainable by the public, thus collaboration with real life militaries is essential for an
optimal version of our program. On the same matter, scaling the program with
regards to the amount of data can be done as showcased with the bitmap importer,
by writing additional and more comprehensive functions, able to correctly import
additional data formats.
9.2. Regarding lack of functionality 69

9.2 Regarding lack of functionality


One of the most important aspects of accurately providing the optimal route is
using the available data to not just calculate the route with the least hindrance
but to use the available data to predict the location of mines, thus increasing the
safety of the traversal through a minefield. On the same matter, adjusting the
weights and detailed logic used in our code would necessarily have to be made
in collaboration with military intelligence, to have the most accurate result. Time
and effort regarding the implementation of such functionality and logic is very
time consuming, hence outside the scope of this project, yet it is essential for
the finished version of the software. Related to the lack of data from classified
military information is also the lack of variables. As is presented in section 6.1 on
the implementation of the matrices, only a few obvious (to the writers) variables
were included, such as slope steepness, water depth and vegetation. This is also
represented in the limited number of settings. A fully developed version of this
software would include more variables, including ones that are inaccessible to the
group behind the project. On the same matter, implementing these variables is
a significant challenge. Decisions regarding how they should interact with each
other, what weights they should have in correlation with each other and such, were
all difficult to determine without military intelligence available. These weights and
the logic used would be developed in collaboration with military officials with the
required knowledge and expertise regarding landmine placement.
Apart from obtaining relevant data for the determining of the optimal route,
there are opportunities to draw new conclusions by using already available data
comparatively, making the resulting optimal route much more accurate. We refer
to this functionality as relational functions, due to the process of comparing dif-
ferent data to draw new conclusions otherwise unavailable. An example of this
could be to compare a matrix containing the slope or topography of the terrain
and compare it with the data on the location of detected mines. A conclusion from
such a comparison could be that some positive detections are more probable than
others, since the slope of a terrain is related to landmine emplacing, as explained
in the Terrain Analysis.

9.3 Regarding reliability and usefulness


As was laid out in the problem analysis, mines are notoriously hard to clear, and
this is true for militaries as well. The group realized through an interview that
many militaries, in fact, do not clear mines in a tactical (that is, within the con-
fines of a combat operation) setting, but instead opt to utilize explosive ordinance
launcher to blow up suspected minefields[3]. As such, one could question the ap-
plicability of our program in a real life situation. However, this example also high-
lighted the practicality of a strategic analysis tool. Essentially, since most modern
militaries utilize constant battlefield analysis, performed by rear analysers[3], a
tool to strengthen said analyses could be highly useful. A balanced approach
70 Chapter 9. Discussion

wherein our proposed solution would partake the role of an assistive technology
instead of a stand-alone, dictating tool would likely be the most suitable use of
our program.
Furthermore, although we speculate and presume that our program could be
effective in a finalized version, it is nearly impossible to verify and test our solu-
tion in the current scope for several reasons. Firstly, virtually no traversal through
a real life minefield can be replicated or simulated accurately. For this reason,
there is a lack of comparison when using our program. Secondly, a lot of data is
lacking, specifically classified data, regarding the specific challenges for individ-
ual traversals by military groups through minefields, that could’ve been evaluated
with regards to the usefulness of our program in said operation. The group be-
hind the project simply has no access to such information, unless access to military
intelligence was permitted. Consequentially, this means that the usefulness and
value of program is subject to individual interpretation and assumptions, since its
efficacy is untested in real-life minefield scenarios, and the unavailable essential
data further complicates the drawing of any definitive conclusion. However, if
one is to assume that militaries deploy landmines in a relatively rational context,
it ought to be be assumed that their location is dependant on factors and data
attainable by our program. The accuracy of our program thus depends on the cor-
rect interpretation of said data, to accurately predict the opposing forces intention
regarding their landmine placement.

The focus for this project was to build a functioning software solution capa-
ble of analyzing terrain and optimizing pathfinding through a given area. In
general, the program lacks functionality, however, the functionality that is im-
plemented works correctly. This is in accordance with our problem statement,
wherein we ask how a software solution could effectively analyze terrain and op-
timize pathfinding. We believe that it has been sufficiently showcased how such
a software solution can be developed, and a functioning, albeit unfinished version
of the software solution, has been created.
Bibliography

[1] Headquarters Department of the Army. Mine/Countermine Operations. 2004.


url: https : / / www . marines . mil / Portals / 1 / Publications / FM % 2020 -
32%20W%20CH%201-4.pdf.
[2] US Army. “ACTIVE DUTY PAY CHARTS - FULL-TIME ENLISTED SOL-
DIER PAY”. In: (2023). url: https://www.goarmy.com/benefits/while-
you-serve/money-pay.html#full-time-pay-charts.
[3] SSgt. Aurélien, C., and Rasmus Hende Svenson. “Interview with Staff Sergeant
Aurélien, Combat Engineer / Minesweeper / EOR / EOC, French Army”.
Interview is unpublished by the SSgt.’s request, but can be acquired via mail
by request.
[4] “BMP file format”. In: (). url: https://en.wikipedia.org/wiki/BMP_file_
format.
[5] Bosnia and Herzegovina Center for Mine Removal. “Demining Report for
2020”. Bosnian. In: (2020). url: http://bhmac.org/wp- content/uploads/
2021/08/izvje%C5%A1taj-PMA-za-2020.-godinu-2.pdf.
[6] Malte Bruhn. “Regeringen bruger konsulenthjælp til at få flere syrere til at
rejse hjem”. Danish. In: Altinget (2020). url: https://www.altinget.dk/
artikel / konsulenter - undersoeger - hvordan - flere - flygtninge - kan -
rejse-hjem-lemfaeldig-omgang-med-skatteborgernes-penge.
[7] Bruschini et al. “A survey of current sensor technology research for the de-
tection of landmines”. In: International Workshop on Sustainable Humanitarian
Demining (SusDem’97). 1997. url: https://infoscience.epfl.ch/record/
257016 / files / 1997 _ Bruschini _ LandmineDetTechSurvey _ ProcSusDem97 .
pdf.
[8] Tan Chun. “Introduction to Mine Clearing Technology”. In: (). url: https:
//web.archive.org/web/20211130123837/https://www.dsta.gov.sg/
docs / default - source / dsta - about / introduction - to - mine - clearing -
technology.pdf?sfvrsn=2.
[9] Brandon Colas. The Platoon Leader’s guide to IPB. 2011. url: https://www.
moore . army . mil / armor / 316thcav / SLC / content / PDF / The % 20Platoon %
20Leader’s%20Guide%20to%20IPB.pdf.

71
72 Bibliography

[10] Louise Doswald-Beck, Peter Herby, and Johanne Dorais-Slakmon. “Basic


Facts: the human cost of landmines”. In: International Committee of the Red
Cross (1995).
[11] Louise Doswald-Beck, Peter Herby, and Johanne Dorais-Slakmon. “Basic
Facts: the human cost of landmines”. In: (2022). url: https://web.archive.
org / web / 20220804091913 / https : / / www . icrc . org / en / doc / resources /
documents/misc/57jmcy.htm.
[12] Yavuz Ege et al. “Performance Analysis of Techniques Used for Determining
Land Mines”. In: International Journal of Geosciences (2014). url: https : / /
www.scirp.org/html/9-2800807_50164.htm.
[13] The Editors of Encyclopaedia Britannica / J.E. Luebering. “bomb”. In: (2023).
url: https://www.britannica.com/technology/bomb-weapon.
[14] The Editors of Encyclopaedia Britannica / Letricia Dixon. “mine”. In: (2023).
url: https://www.britannica.com/technology/mine-weapon.
[15] The Editors of Encyclopaedia Britannica / Melissa Albert. “Hague Con-
ventions”. In: (2013). url: https : / / www . britannica . com / event / Hague -
Conventions.
[16] Patricia Weiss Fagen. “Refugees and IDPs after Conflict: Why They Do Not
Go Home”. In: United States Insitute of Peace (2011). url: https://www.usip.
org/sites/default/files/resources/SR268Fagen.pdf.
[17] Guy Faulconbridge. “Ukraine war, already with up to 354,000 casualties,
likely to last past 2023 - U.S. documents”. In: Reuters (2023). url: https :
/ / www . reuters . com / world / europe / ukraine - war - already - with - up -
354000-casualties-likely-drag-us-documents-2023-04-12/.
[18] FOpen Documentation. url: https://en.cppreference.com/w/c/io/fopen.
[19] Arsenii Golovin, Evgenii Sechak, and Anatolii Demin. “Landmine detection
and minefield mapping with the help of multi-angle long-wave infrared hy-
perspectral data fused with the 3D terrain reconstruction”. In: (2020). url:
https://ceur-ws.org/Vol-2665/paper34.pdf.
[20] Michael T. Goodrich and Roberto Tamassia. Algorithm Design and Applica-
tions. Wiley, 2015.
[21] US Gov. “FACT SHEET: Changes to U.S. Anti-Personnel Landmine Policy”.
In: (2022). url: https://www.whitehouse.gov/briefing-room/statements-
releases/2022/06/21/fact- sheet- changes- to- u- s- anti- personnel-
landmine-policy/.
[22] M Habib. “Mine Clearance Techniques and Technologies for Effective Hu-
manitarian Demining”. In: (2023). url: https : / / commons . lib . jmu . edu /
cgi/viewcontent.cgi?article=2259&context=cisr-journal.
[23] The White House. “FACT SHEET: Changes to U.S. Anti-Personnel Landmine
Policy”. In: (2014). url: https : / / obamawhitehouse . archives . gov / the -
press- office/2014/09/23/fact- sheet- changes- us- anti- personnel-
landmine-policy.
Bibliography 73

[24] Sam Itskin. CSI 3334, Data Structures. 2012. url: https : / / piazza . com /
class_profile/get_resource/h63tokvn98219n/h7btvlhumtn6gc.
[25] Kaneda et al. “Walking and running kinesiology in water: A review of the
literature”. In: Journal of Fitness Research 1.1 (2012), pp. 1–11.
[26] H. Kasban et al. “A Comparative Study of Landmine Detection Techniques”.
In: Sensing and Imaging (2010). url: https : / / www . researchgate . net /
profile/Fathi- Abd- El- Samie/publication/225752842_A_Comparative_
Study_of_Landmine_Detection_Techniques/links/0f3175361dfa5911f0000000/
A-Comparative-Study-of-Landmine-Detection-Techniques.pdf.
[27] Isabel Keane. “Frontline Ukrainian soldiers’ life expectancy just ‘four hours,’
US Marine claims”. In: New York Post (2023). url: https : / / nypost . com /
2023 / 02 / 23 / life - expectancy - on - frontline - in - ukraine - 4 - hours -
soldier/.
[28] Landminefree. “Facts About Landmines”. In: (2013). url: https://landminefree.
org / facts - about - landmines / # : ~ : text = Mines % 20kill % 20or % 20maim %
20more,15%2C000%20%E2%80%93%2020%2C000%20injuries%20each%20year.
[29] The International Compaign to ban Landmines. “A History of Landmines”.
In: (2023). url: http://www.icbl.org/en- gb/problem/a- history- of-
landmines.aspx.
[30] Ephrat Livni and Gaya Gupta. “What We Know About the War Between
Israel and Hamas”. In: New York Times (2023). url: https://www.nytimes.
com/article/israel-gaza-hamas-what-we-know.html.
[31] Jacqueline MacDonald et al. “Alternatives for Landmine Detection”. In: (2022).
url: https://web.archive.org/web/20220720001303/https://www.rand.
org/content/dam/rand/pubs/monograph_reports/MR1608/RAND_MR1608.
pdf.
[32] Minetti et al. “Energy cost of walking and running at extreme uphill and
downhill slopes”. In: Journal of Applied Physiology 93.3 (2002). PMID: 12183501,
pp. 1039–1046. doi: 10.1152/japplphysiol.01177.2001. url: https://doi.
org/10.1152/japplphysiol.01177.2001.
[33] The Landmine Monitor. Landmine Monitor 2022. 2022. url: http://www.the-
monitor.org/media/3352351/2022_Landmine_Monitor_web.pdf.
[34] Nachon and Claudio Torres. “The environmental impacts of landmines”.
In: Landmines and human security: International politics and war’s hidden legacy
(2004), pp. 191–207. url: https://www.researchgate.net/profile/Claudio-
Torres - Nachon / publication / 292482972 _ The _ environmental _ impacts _
of _ landmines / links / 626c3ac6dc014b4379738740 / The - environmental -
impacts-of-landmines.pdf.
[35] Mark Nash. “M1150 Assault Breacher Vehicle (ABV)”. In: (2018). url: https:
/ / tanks - encyclopedia . com / modern - us - m1150 - assault - breacher -
vehicle-abv/.
74 Bibliography

[36] United Nations. “Anti-Personnel Landmines Convention”. In: (2019). url:


https://disarmament.unoda.org/anti-personnel-landmines-convention/
# : ~ : text = The % 201997 % 20Convention % 20on % 20the , Anti % 2DPersonnel %
20Mine%20Ban%20Treaty..
[37] United Nations. “Convention on the Prohibition of the Use, Stockpiling, Pro-
duction and Transfer of Anti-Personnel Mines and on their Destruction”. In:
(2023). url: https : / / treaties . un . org / Pages / ViewDetails . aspx ? src =
TREATY&mtdsg_no=XXVI-5&chapter=26&clang=_en.
[38] United Nations. “Ukrainian refugees arrive in Poland ‘in a state of distress
and anxiety’”. In: (2023). url: https://news.un.org/en/story/2022/05/
1119172.
[39] United Nations. United Nations Landmines, Explosive Remnants Of War And
Improvised Explosive Devices Safety Handbook. 2015. url: https://unmas.org/
sites/default/files/handbook_english.pdf.
[40] The Visual Journalism Team BBC News. “Ukraine in maps: Tracking the war
with Russia”. In: (2023). url: https://www.bbc.com/news/world-europe-
60506682.
[41] Alex Nikulin et al. “Detection and Identification of Remnant PFM-1 ‘But-
terfly Mines’ with a UAV-Based Thermal-Imaging Protocol”. In: (2018). url:
https://www.mdpi.com/2072-4292/10/11/1672.
[42] U.S. Government Publishing Office. National Defense Authorization Act For
Fiscal Year 2019. 2019. url: https://www.govinfo.gov/content/pkg/CRPT-
115hrpt676/html/CRPT-115hrpt676.htm.
[43] Diana Olick. “An army of one carries a high price”. In: NBC News (2022).
url: https://www.nbcnews.com/id/wbna3072945.
[44] Cambridge University Press. “New U.S. Anti-Personnel Landmine Policy
Adopted”. In: (2022). url: https://www.cambridge.org/core/journals/
american-journal-of-international-law/article/new-us-antipersonnel-
landmine-policy-adopted/542A4BD0AB662ADF6BA5EF60DDDEF83C.
[45] Dian Rachmawati and Lysander Gustin. “Analysis of Dijkstra’s Algorithm
and A* Algorithm in Shortest Path Problem”. In: Journal of Physics: Conference
Series (2020).
[46] Michael K. Robel. “Breaching 101”. In: (1999). url: http://www.prosimco.
com/online_help/sosr.htm.
[47] Kenneth H. Rosen. Discrete Mathematics Applications. Mc Graw Hill Educa-
tion, 2019.
[48] Stuart J. Russell and Peter Norvig. Artificial Intelligence A Modern Approach
Third Edition. Pearson Education, 2010.
[49] Severson and Peter. “Advanced Terrain Reasoning and Automated Maneu-
ver Planning”. PhD thesis. Monterey, CA; Naval Postgraduate School, 2019.
url: https://apps.dtic.mil/sti/pdfs/AD1080401.pdf.
Bibliography 75

[50] Andrew Vian Smith. “Ground-engaging machines”. In: (2021). url: https:
//nolandmines.com/machinespart2.html.
[51] Sam Tabahriti. “Ukraine has taken delivery of its first mine-clearing ma-
chine, which was made by a British company and cost almost $500,000”.
In: (2022). url: https://www.businessinsider.com/ukraine-got-first-
armtrac-400-mine-clearing-machine-british-made-2022-10?r=US&IR=T.
[52] James Trevelyan. “Research Challenges”. In: (2022). url: https : / / web .
archive.org/web/20220920163254/https://cdn.intechopen.com/pdfs/
806/InTech-Humanitarian_demining_research_challenges.pdf.
[53] Human Rights Watch. “Landmine Use in Ukraine”. In: (2023). url: https:
//www.hrw.org/news/2023/06/13/landmine-use-ukraine.
[54] Human Rights Watch. “Questions and Answers on the New US Landmine
Policy”. In: (2020). url: https : / / www . hrw . org / news / 2020 / 02 / 27 /
questions-and-answers-new-us-landmine-policy.
[55] Emma Woollacott. “Data-Mining For The Land Mines”. In: (2023). url: https:
//ssir.org/articles/entry/data_mining_for_the_land_mines.
[56] Paola Zamparo, Matteo Cortesi, and Giorgio Gatta. “The energy cost of
swimming and its determinants”. In: European journal of applied physiology
120 (2020), pp. 41–66.

You might also like