\chapter{Introduction}
\label{cha:introduction}

For a machine to interact in an intelligent manner with its outside world, it needs to be
equipped with suitable knowledge.  The very same is true for humans, and acquiring this
knowledge is a highly complex task which up to today is not completely understood.  To
help within this process, previously acquired knowledge is \emph{represented} in different
ways, \eg as books or films, to help others learning it.

However, the way knowledge is represented for human consumption is almost always not
suitable for machines.  While humans can extract knowledge from natural language, which
may be full of ambiguity, machines require precise formulations of knowledge.  The
representation of knowledge in a machine-understandable way is the main focus of the area
of \emph{knowledge representation}~\cite{KRhandbook}.

One of the most successful approaches to knowledge representations are description
logics~\cite{DLhandbook}, a family of logic-based knowledge representation formalisms
with varying expressivity and reasoning complexity.  Description logics allow to represent
knowledge as \emph{knowledge bases}, or \emph{ontologies}.  Essentially, these are
collections of axioms, which may be either \emph{assertional} or \emph{terminological}.
For example, to represent the fact (the \emph{assertion}) that an individual \textsf{tom}
is a cat, one can use the assertional axiom
\begin{equation}
  \label{eq:14}
  \mathsf{Cat}(\mathsf{tom}).
\end{equation}
On the other hand, to state the terminological knowledge that every cat hunts mice, one
can use so-called \emph{general concept inclusions} (GCIs) and write
\begin{equation}
  \label{eq:15}
  \mathsf{Cat} \sqsubseteq \exists \mathsf{hunts}. \mathsf{Mouse}.
\end{equation}
As soon as a knowledge base is available, it is possible to \emph{reason} with it, \ie to
extract knowledge from it that is implicitly contained.  For example, from the two axioms
stated above, we can infer that the individual \textsf{tom} hunts mice, although this has
never been stated explicitly.

Knowledge bases can be used to represent knowledge in a machine-consumable way.  However,
the question arises how such knowledge bases can be obtained.  One way or the other,
knowledge which is available to humans has to be translated into the form of a description
logic knowledge base.  Of course, this could be done by humans, but this approach would
not only be very time-consuming, but also prone to errors.  An automatic translation would
thus be highly welcomed.  On the other hand, a completely automatic translation would just
mean that machines can consume knowledge in the way humans represent it, an assumption
which is not reasonable.

However, one can still think about approaches which are \emph{semi-automatic} in the sense
that the results obtained from such a translation are preliminary, requiring further
refinement, or that the translation procedure requires additional \emph{assistance} by
means of human experts.

An approach to achieve such a semi-automatic translation procedure, or \emph{learning
  procedure}, has been made in~\cite{Diss-Felix}.  There, the focus lies on extracting
terminological knowledge of the form as shown in \Cref{eq:15} from some given \emph{finite
  interpretation} $\mathcal{I}$.  More precisely, the procedures described
in~\cite{Diss-Felix} would automatically learn all GCIs which are \emph{valid} in the data
set $\mathcal{I}$.  This approach makes use of the mathematical theory of \emph{formal
  concept analysis}, a subfield of mathematical order theory, which has very close
connections to description logics.

Of course, the GCIs learned this way may not be correct, in the sense that the GCI may
hold in $\mathcal{I}$, but this data missed to contain some relevant counterexamples.  In
this case, we say that $\mathcal{I}$ is \emph{incomplete}.  One way to remedy this is to
use an algorithm from formal concept analysis called \emph{attribute exploration}, and
generalize it to the setting of GCIs.  Such a generalization, called \emph{model
  exploration}, has been discussed in~\cite{Diss-Felix}.  Within this algorithm, an expert
(possibly human) is asked for the correctness of extracted GCIs, and if such a GCI is not
correct, the expert has to provide \emph{counterexamples} for it.  This way, the problem
of $\mathcal{I}$ being incomplete can be solved.

However, there are still problems with the original approach of~\cite{Diss-Felix}, in
particular concerning the \emph{quality} of the data $\mathcal{I}$ from which GCIs are
learned.  The main problem here is that the data may contain \emph{errors}.  These errors
may either cause otherwise valid GCIs not to be found, because these errors act as
\emph{false counterexamples}, or GCIs to be found which are not correct, because errors
cause positive counterexamples to vanish.  While the latter approach can in theory be
handled by the attribute exploration approach sketched above, the former cannot, because
the approach discussed in~\cite{Diss-Felix} will not even extract GCIs for which there may
be false counterexamples in $\mathcal{I}$.

In this work, we want to extent the results obtained in~\cite{Diss-Felix} to this new
setting of where the data $\mathcal{I}$ may contain errors.  The main approach for this is
to transfer the notion of \emph{confidence}~\cite{arules:agrawal:association-rules} from
the area of data-mining to GCIs.  Intuitively, this means that GCIs may have \emph{few}
errors in the data, as opposed to having none in the original approach
of~\cite{Diss-Felix}.  The notion of \enquote{few} is quantified by means of the
confidence of the GCIs in the data.

In the following, we shall give a more in-depth discussion of what we want to do in this
work.  To this end, we first shall introduce description logics and formal concept
analysis, in an exemplary and historic manner.  Thereafter, we shall discuss the main
results of~\cite{Diss-Felix} in more detail, and also briefly mention some other related
work.  Finally, we present the main contributions of this work.

\section{Description Logics}
\label{sec:repr-knowl-using}

Description logics~\cite{DLhandbook} are a family of logic-based knowledge representation
formalisms, with a strong emphasis on well-defined semantics and practical reasoning
procedures.  The family of description logics contains various kinds of logical
formalisms, varying in expressiveness and reasoning complexity, allowing users to choose
the expressiveness they need, or the complexity they can afford in their respective
applications.

The development of description logics~\cite{journals/sLogica/BaaderS01} was motivated by
earlier knowledge representation formalisms like \emph{semantic
  networks}~\cite{SemanticNetworks} or \emph{frame}~\cite{Minsky-Frames}, whose semantics
were highly ambiguous, and mostly depended on human interpretation or implementation
details.  The need for well-defined and predictable knowledge representation formalisms
then led to the first logic-based systems~\cite{journals/cogsci/BrachmanS85}, which
however were incomplete~\cite{conf/kr/Schmidt-Schauss89}.

The first description logics considered were relatively small fragments of first order
logic, and already for them it could be shown that reasoning is
intractable~\cite{conf/aaai/BrachmanL84,journals/ai/Nebel88}.  One approach to remedy this
was to investigate highly optimized reasoning algorithms, which behave well in practice.
The most prominent class of such algorithms are \emph{tableau algorithms}.  These
algorithms were first invented for the description logic
$\ALC$~\cite{journals/ai/Schmidt-SchaussS91,conf/ecai/HollunderNS90} for the subsumption
problem, and were thereafter extended to other, even more expressive logics.  After a
connection of $\ALC$ to multimodal logic $\mathsf{K}_{(\mathsf{m})}$ was
discovered~\cite{DBLP:conf/ijcai/Schild91}, it was seen that this tableau algorithm is
actually a re-invention of the tableau algorithms used in modal logics.  The development
of description logics continued to investigate highly expressive description logics, whose
expressiveness exceeds that of $\ALC$, but which still behave well in
practice~\cite{journals/igpl/HorrocksST00}, and for which highly-optimized implementations
exist~\cite{sirin_pellet:practical_2007,Haarslev:2001,DBLP:conf/cade/TsarkovH06}.  This
finally led to the adoption of the \emph{Web Ontology Language OWL} by the W3C, which is
based on the highly expressive description logic
$\mathcal{S}\mathcal{H}\mathcal{O}\mathcal{I}\mathcal{N}$~\cite{horrocks03fromshiqrdftoowl}.

The focus of description logics research departed from the sole focus on expressive
description logics when, at the beginning of this millennium, it was discovered that for
the inexpressive description logic $\EL$ reasoning is
tractable~\cite{DBLP:conf/ijcai/Baader03a,DBLP:conf/ecai/Brandt04}, and stays so when the
expressiveness of $\EL$ is extended
slightly~\cite{DBLP:conf/ijcai/BaaderBL05,BaaderEtAl-OWLED08DC}.  A practical relevance of
these results is given by the fact that large biomedical ontologies can be reformulated as
\emph{description logic knowledge bases} (or \emph{description logic ontologies}) using
$\EL$ or such slight extensions of it.  Examples for this are the \emph{Systematized
  Nomenclature of Medicine--Clinical Terms}, the Gene Ontology~\cite{gene-ontology}, and
large parts of the GALEN ontology~\cite{Rector199475}.

The term \enquote{description} in \enquote{description logics} is motivated by the
intention to use description logics to express knowledge about \emph{concept
  descriptions}.  For this, description logics provide a number of constructors, which can
then be used to build concept descriptions from atomic \emph{concept names} and binary
\emph{role names}.  For example, the description logic $\EL$ provides the constructors
\emph{conjunction} ($\sqcap$) and \emph{existential restriction} ($\exists$).  Examples of
$\EL$ concept descriptions are
\begin{equation*}
  \mathsf{Cat},\, \mathsf{Cat} \sqcap \mathsf{Mouse},\, \exists \mathsf{hunts}. \mathsf{Mouse},
\end{equation*}
where \textsf{Cat}, \textsf{Mouse} are concept names, and \textsf{hunts} is a role name.

A description logic knowledge base formulated in $\EL$ consists, like most description
logic knowledge bases, of two parts, namely an \emph{ABox}, holding assertional knowledge,
and a \emph{TBox}, containing terminological knowledge.  An example knowledge base is
\begin{equation*}
  \mathcal{K} = (\set{ \mathsf{Cat} \sqsubseteq \exists \mathsf{hunts}. \mathsf{Mouse} },
  \set{ \mathsf{Cat}(\mathsf{tom}) }),
\end{equation*}
where the first entry denotes the TBox, and the second denotes the ABox.  The semantics of
knowledge bases is defined using \emph{interpretations} $\mathcal{I}$, which can be
thought of as directed edge- and vertex-labeled graphs.  The labels of the vertices, which
we shall call \emph{elements} or \emph{individuals}, are concept names, and the labels of
the edges are role names.  An interpretation is a model of a knowledge base if all
elements \emph{satisfy} the axioms contained in this knowledge base.  For example, the
interpretation
\begin{center}
  \begin{tikzpicture}
    \begin{scope}[
      every node/.style = { draw, circle },
      every label/.style = { draw = none, rectangle }
      ]
      \node[label=above:{\textsf{Cat}}] (Tom) {\textsf{tom}};
      \node[label=above:{\textsf{Mouse}}, right=2cm of Tom, inner sep = .1cm] (Jerry)
      {\textsf{jerry}};
    \end{scope}
    \path (Tom) edge[->, bend left=30] node[midway, above] {\textsf{hunts}} (Jerry);
    \path (Jerry) edge[->, bend left=30] node[midway, below] {\textsf{hunts}} (Tom);
  \end{tikzpicture}
\end{center}
is a model of the knowledge base $\mathcal{K}$, since the element \textsf{tom} is labeled
\textsf{Cat}, and every element which is labeled with \textsf{Cat} is connected to some
element labeled \textsf{Mouse} via an edge labeled with \textsf{hunts}.

As soon as one has a description logic knowledge base, one can conduct \emph{reasoning}
with it, \ie one can extract knowledge from the knowledge base that may be only contained
in it implicitly.  Two classical reasoning problems are \emph{instance checking} and
\emph{subsumption}: given an \emph{individual name} $a$ and a concept description $C$, the
instance checking problem is to ask whether $a$ is an \emph{instance} of $C$, \ie whether
$a$ satisfies the concept description $C$ in every interpretation.  The subsumption
problem is to ask, given two concept descriptions $C$ and $D$, whether it is true that $C$
is a \emph{subconcept} of $D$, \ie whether it is true in every interpretation that every
element that satisfies $C$ also satisfies $D$.  Other reasoning problems are
\emph{knowledge base consistency} and \emph{concept satisfiability}: a knowledge base is
consistent if it has a model, and a concept description $C$ is satisfiable with respect to
a given knowledge base $\mathcal{K}$ if there exists a model of $\mathcal{K}$ containing
elements that satisfy $C$.  Deciding knowledge base consistency and concept satisfiability
can help to ensure the correctness of the given knowledge base.

\section{Formal Concept Analysis}
\label{sec:learn-impl-using}

Formal concept analysis~\cite{fca-book} is a subfield of mathematical order theory,
originally concerned with the study of properties of ordered structures called
\emph{complete lattices} by representing them in terms of so-called \emph{formal
  contexts}.  Since then, formal concept analysis has considerably broadened its scope,
with connections to previously unrelated subjects such as
logics~\cite{books/math/Prediger00,conf/iccs/FerreR00}, data
mining~\cite{arules:Zaki:1998}, machine learning~\cite{conf/icfca/Kuznetsov04}, and
artificial intelligence~\cite{phd/de/Rudolph2006,Diss-Felix}.  Because of this, formal
concept analysis today can be considered as a part of theoretical computer science, and
thus it provides another link between computer science and mathematics.

The origin of formal concept analysis as it is used in this work can clearly be marked by
the work of Wille~\cite{fca:Wille:1982}, which introduced formal concept analysis as an
approach to impose meaning on complete lattices by considering them as \emph{hierarchies
  of concepts}.  This work was motivated by previous results from
Birkhoff~\cite{books/math/Birkhoff67}, but also has a strong philosophical
background~\cite{books/phil/Hentig72,Wille:Begriffsdenken}.  Another early work that
included some of the ideas of formal concept analysis is~\cite{OrdreEtClassification}.

\begin{figure}[tp]
  \centering
  \begin{math}
    \begin{array}[c]{c|*{7}{c}}
      \toprule
      ~       & \mathsf{small} & \mathsf{medium} & \mathsf{large} & \mathsf{inner} &
      \mathsf{outer} & \mathsf{moon} & \mathsf{no moon} \\
      \midrule
      \mathsf{Mercury} & \times &   &   & \times &   &   & \times  \\
      \mathsf{Venus}   & \times &   &   & \times &   &   & \times  \\
      \mathsf{Earth}   & \times &   &   & \times &   & \times &    \\
      \mathsf{Mars}    & \times &   &   & \times &   & \times &    \\
      \mathsf{Jupiter} &   &   & \times &   & \times & \times &    \\
      \mathsf{Saturn}  &   &   & \times &   & \times & \times &    \\
      \mathsf{Uranus}  &   & \times &   &   & \times & \times &    \\
      \mathsf{Neptune} &   & \times &   &   & \times & \times &    \\
      \mathsf{Pluto}   & \times &   &   &   & \times & \times &    \\
      \bottomrule
    \end{array}
  \end{math}
  \caption{Example Formal Context (taken from~\cite{fca:Wille:1982})}
  \label{fig:example-formal-context}
\end{figure}

The fundamental idea of formal concept analysis is to represent complete lattices by an
\emph{object-attribute-relationship}, which is expressed using \emph{formal contexts}.
These structures can be thought of as \emph{tables of crosses}.  An example of a formal
context is depicted in \Cref{fig:example-formal-context}.  This example formal context
expresses an object-attribute-relationship between the \emph{objects} being the known
planets of the solar system (including Pluto), and the \emph{attributes} being certain
properties of these planets, like their size (\textsf{small}, \textsf{medium}, or
\textsf{large}), their distance from the sun (being an \textsf{inner} or \textsf{outer}
planet, \ie having an orbit which is closer to the sun than the asteroid belt or not), and
if they do or do not have a \textsf{moon}.  A cross in this table then means that the
object on the corresponding row \emph{has} the attribute on the corresponding column.
Thus, for example, \textsf{Mercury} is a \textsf{small} planet, and \textsf{Pluto} is an
\textsf{outer} planet.  The set of all pairs of objects $g$ and attributes $m$ where $g$
has the attribute $m$ is called the \emph{incidence relation} of the formal context.

Formally, a \emph{formal context} $\con K$ can be defined as a triple $\con K = (G, M,
I)$, where $G$ and $M$ are sets and $I \subseteq G \times M$.  $G$ is then called the set
of \emph{objects}, $M$ is called the set of \emph{attributes}, and the set $I$ is called
the \emph{incidence}.  An object $g \in G$ \emph{has} an attribute $m \in M$ in $\con K$
if and only if $(g, m) \in I$.

From such a formal context one can then extract \emph{formal concepts}, which can be
ordered in a natural way to yield the \emph{concept lattice} of the formal context.  In
our example above, a formal concept which corresponds to the concept of a
\emph{medium-sized planet in our known solar system} would be the tuple
\begin{equation}
  \label{eq:60}
  ( \set{ \mathsf{Uranus}, \mathsf{Neptune} }, \set{ \mathsf{medium}, \mathsf{moon},
    \mathsf{outer} } ),
\end{equation}
where the first set is called the \emph{extent}, and the second set is called the
\emph{intent} of the formal concept.

Formal concepts can then be ordered by set-inclusion of their extents, and it can be shown
that the thus-obtained ordered set is a complete lattice, the \emph{concept lattice} of
the formal context.  The concept lattice that corresponds to our small example above is
shown in \Cref{fig:example-concept-lattice}.  This diagram also uses the usual, abridged
annotation of concept lattices: a node $v$ in the lattice diagram represents the formal
concept whose extent consists of all objects which can be reached by an \emph{descending
  path} in the diagram, starting from $v$.  Likewise, the intent of $v$ is the set of all
attributes that can be reached by an \emph{ascending path} in the diagram, starting from
$v$.  Thus, the gray-shaded node in \Cref{fig:example-concept-lattice} is the formal
concept of \Cref{eq:60}.

\begin{figure}[tp]
  \tikzset{vertexbase/.style={semithick, shape=circle, inner sep=2pt, outer sep=0pt, draw},%
    vertex/.style={vertexbase},%
    mivertex/.style={vertexbase},%
    jivertex/.style={vertexbase},%
    divertex/.style={vertexbase},%
    conn/.style={-, thick}%
  }
  \begin{center}
    \begin{tikzpicture}
      \begin{scope}[xscale=.7] %for scaling and the like
        \begin{scope} %draw vertices
          \foreach \nodename/\nodetype/\xpos/\ypos in {%
            0/vertex/2/4,
            1/divertex/-4/7,
            2/jivertex/0/7,
            3/divertex/8/7,
            5/jivertex/4/7,
            6/mivertex/-2/8,
            7/vertex/2/8,
            8/mivertex/6/8,
            9/mivertex/0/9,
            10/mivertex/4/9,
            11/vertex/2/10
          } \node[\nodetype] (\nodename) at (\xpos, \ypos) {};
          \node[divertex,fill=black!30] (4) at (6,7) {};
        \end{scope}
        \begin{scope} %draw connections
          \path (7) edge[conn] (10);
          \path (9) edge[conn] (11);
          \path (5) edge[conn] (8);
          \path (1) edge[conn] (6);
          \path (0) edge[conn] (4);
          \path (0) edge[conn] (3);
          \path (8) edge[conn] (10);
          \path (5) edge[conn] (7);
          \path (6) edge[conn] (9);
          \path (2) edge[conn] (7);
          \path (0) edge[conn] (1);
          \path (3) edge[conn] (8);
          \path (2) edge[conn] (6);
          \path (10) edge[conn] (11);
          \path (7) edge[conn] (9);
          \path (4) edge[conn] (8);
          \path (0) edge[conn] (2);
          \path (0) edge[conn] (5);
        \end{scope}
        \begin{scope}[every label/.style={font=\sffamily, inner sep=1pt, fill opacity=.9,
            text opacity=1, fill=white, label distance=4pt}] %add labels
          \foreach \nodename/\labelpos/\labelopts/\labelcontent in {%
            1/below left//{\parbox{1.4cm}{Mercury\\ Venus}},
            1/above left//{no-moon},
            2/below//{\parbox{2cm}{\centering Mars\\ Earth}},
            3/below right//{\parbox{2cm}{Jupiter\\ Saturn}},
            3/above right//{large},
            4/below//{\parbox{1.4cm}{\centering Uranus\\ Neptune}},
            5/below//{Pluto},
            6/above left//{inner},
            8/above right//{outer},
            9/above left//{small},
            10/above right//{moon}
          } \node[draw=none,label={[\labelopts]\labelpos:{\labelcontent}}] at (\nodename) {};
          \node[draw=none,label={[label distance=1pt]above:medium}] at (4) {};
        \end{scope}
      \end{scope}
    \end{tikzpicture}
  \end{center}
  \caption{Example Concept Lattice}
  \label{fig:example-concept-lattice}
\end{figure}

One of the key results of formal concept analysis is that every complete lattice can be
represented as a concept lattice of a suitably chosen formal context (this is the
so-called \emph{fundamental theorem of formal concept analysis}).  A major direction of
formal concept analysis research is to consider properties and operations of lattices,
such as \emph{distributivity}, \emph{modularity}, \emph{direct} and \emph{semi-direct
  products}, and transfer them to corresponding properties and operations on the level of
formal contexts.  See~\cite{fca-book} for more details on this.

Another very prominent research direction in formal concept analysis is the study of
\emph{implications} in formal contexts, which has been discussed as early
as~\cite{fca:Wille:1982}.  Observe that in our example formal context above, all outer
planets have a moon.  We can express this fact as saying that the implication
\begin{equation*}
  \set{ \mathsf{outer} } \to \set{ \mathsf{moon} }
\end{equation*}
\emph{holds} in our formal context.  Implications are similar to \emph{functional
  dependencies} from the theory of databases~\cite{DBLP:books/cs/Maier83}, and also play a
certain role in classical order theory~\cite{Wild1994118}.

One task is to compute the set of all valid implications of a given formal context.  Since
this set can be quite large, one usually wants to compute \enquote{small} sets of
implications which are sufficient, called \emph{bases}.  One very prominent base is the
so-called \emph{canonical base}~\cite{fca:DuquenneGuigues:1986} (also \emph{stem base},
\emph{Duquenne-Guigues base}), which is a \emph{minimal} base, \ie a base with minimal
cardinality.  This base can be computed
effectively~\cite{DBLP:conf/icfca/Ganter10,DBLP:journals/amai/ObiedkovD07}, however these
algorithms are not efficient~\cite{DBLP:conf/icfca/Distel10} with respect to the size of
the input and the output.  Certain complexity results suggest that efficiently computing
the canonical base is not possible in general~\cite{DBLP:journals/dam/BabinK13}.  However,
if this is really the case is an open research question.  Therefore, other bases have been
investigated, whose computation is algorithmically easier.  An example is the base of
\emph{proper premises}~\cite{fca-book}, for which fast algorithms
exist~\cite{RyDiBo-AMAI13}.

An algorithm that is related to the study of valid implications of formal contexts is
\emph{attribute exploration}~\cite{fca-book,GORS-book}, which is an interactive process
which extracts valid implications from \emph{incomplete} data utilizing \emph{expert
  interaction} to obtain missing facts.  Within this process, an external expert is asked
questions of the form
\begin{equation*}
  \text{Is the implication } A \to B \text{ valid?}
\end{equation*}
The expert then can either accept this implication, or decline it by providing a
\emph{counterexample}.  In this way, the expert enriches the currently known formal
context by missing objects and their attributes.  As soon as the process finishes, the set
of confirmed implications represents the whole implicational knowledge represented by the
expert.  Moreover, it can be shown that the set of confirmed implications is the canonical
base of the formal context which consists of the initially known objects together with all
counterexamples provided by the expert.  In this way, attribute exploration can be seen as
a semi-automatic knowledge acquisition algorithm.

Attribute exploration has been a major focus of formal concept analysis research, and many
extensions of this algorithm have been developed and discussed.  Examples for this are the
inclusion of \emph{background
  knowledge}~\cite{stumme96attribute,DBLP:journals/tcs/Ganter99}, \emph{concept
  exploration}~\cite{conf/iccs/Stumme97}, \emph{rule
  exploration}~\cite{phd/de/Zickwolff1991}, \emph{relational
  exploration}~\cite{phd/de/Rudolph2006}, exploration in the presence of \emph{partial
  knowledge}~\cite{book/fca/BurmeisterH05,conf/ijcai/BaaderGSS07}, and \emph{model
  exploration}~\cite{Diss-Felix}.

\section{Extracting Terminological Knowledge from Relational Data}
\label{sec:extr-term-knowl}

The main purpose of this work is to discuss a way to extract general concept inclusions
from interpretations which are allowed to contain errors.  The basis for our
considerations are the results obtained by Baader and
Distel~\cite{Diss-Felix,BaDi09,BaaderDistel08} on computing \emph{finite bases} of
\emph{valid} GCIs from finite interpretations.  In the following, we shall briefly
summarize the main results of this approach.

The goal of the work by Baader and Distel is to learn terminological knowledge about a
certain \emph{domain} of interest.  For this we assume that we can represent this domain
as a finite interpretation $\mathcal{I}$, \ie our domain is representable as relational
data.  The terminological knowledge we are then interested in is the set
$\Th(\mathcal{I})$ of valid GCIs of $\mathcal{I}$, using the description logic $\ELbot$.

A first problem here is that the set $\Th(\mathcal{I})$ is infinite in general: if $C
\sqsubseteq D$ is valid in $\mathcal{I}$, and if $r$ is a role name, then the GCI $\exists
r. C \sqsubseteq \exists r. D$ is also valid in $\mathcal{I}$.  To remedy this, Baader and
Distel compute \emph{finite bases} of $\Th(\mathcal{I})$, \ie finite subsets $\mathcal{B}$
of $\Th(\mathcal{I})$ which are already \emph{complete} for $\mathcal{I}$.  In other
words, finite bases $\mathcal{B}$ are finite sets of valid GCIs of $\mathcal{I}$, such
that every GCI valid in $\mathcal{I}$ is already entailed by $\mathcal{B}$.  One of the
main results of their approach is that such finite bases always exist, and that they can
be computed effectively.

To provide these results, Baader and Distel exploit the tight connection between the
description logic $\ELbot$ and formal concept analysis, established by \emph{model based
  most specific concept descriptions} and \emph{induced formal contexts} of finite
interpretations and sets of concept descriptions.  More precisely, it can be shown that if
$\con K_{\mathcal{I}}$ denotes the induced formal context of $\mathcal{I}$, then every
base of $\con K_{\mathcal{I}}$ gives rise to a finite base of $\mathcal{I}$.  A technical
problem that arises here is that model-based most-specific concept descriptions are not
necessarily expressible in the description logic \ELbot.  Because of this, Baader and
Distel consider the description logic \ELgfpbot, an extension of \ELbot by \emph{cyclic
  concept descriptions} using \emph{greatest fixpoint semantics}.

The resulting algorithms for computing bases of finite interpretations are all effective.
A preliminary implementation with applications to linked data has been presented
in~\cite{DBLP:conf/icdm/BorchmannD11}.

An additional issue addressed by Baader and Distel is the fact that the interpretation
$\mathcal{I}$ may be \emph{incomplete}, \ie certain facts from the domain of interest may
not be represented in it.  The GCIs which are valid in $\mathcal{I}$ may not necessarily
be valid in the domain of interest.  This problem is very similar to the problem solved by
attribute exploration, and indeed it can be shown that attribute exploration applied to
the context $\con K_{\mathcal{I}}$ can be transferred into an algorithm for \emph{model
  exploration} of $\mathcal{I}$.  This algorithm then allows to interactively compute
bases of $\mathcal{I}$, allowing an expert to provide missing facts when required.  In
this way, learning GCIs which are invalid in the domain of interest can be avoided.

\section{Other Related Work}
\label{sec:related-work}

The work of Baader and Distel is not the first attempt to bring together the worlds of
description logics and formal concept analysis.  Indeed, there have been several previous
attempts to utilize formal concept analysis for description logic applications, and to add
ideas from description logics to notions of formal concepts analysis.

One of the first results in description logics that utilizes formal concept analysis is
the work of Baader~\cite{Baader-KRUSE-95}.  In this work, Baader uses the attribute
exploration algorithm on a special formal context to compute a minimal representation of
the subsumption hierarchy between all conjunctions of the defined concept names of a given
acyclic TBox $\mathcal{T}$ formulated in the logic $\ALC$.  To this end, Baader extends
the classical tableau algorithm for \ALC to decide subsumption between \emph{single}
defined concept names~\cite{journals/ai/Schmidt-SchaussS91}, and extends it in such a way
that it provides counterexamples to instances of the subsumption problem.  These
counterexamples are then collected into a suitable formal context, and from this context
the attribute exploration algorithm eventually computes the canonical base.  These
implications give rise to a set of GCIs, which can then be used to decide subsumption
between conjunctions of defined concept names of $\mathcal{T}$.

The results obtained by Baader have been further generalized by
Stumme~\cite{stumme96concept} to also include disjunction.  For this, a generalization of
attribute exploration called \emph{distributive concept
  exploration}~\cite{conf/ki/Stumme98} has been used.

Another use of formal concept analysis for description logic applications is in
\emph{knowledge base completion}~\cite{Sert07,conf/ijcai/BaaderGSS07}, for which again
attribute exploration was used.  For this, the expert is asked GCIs of the form
\begin{equation*}
  \bigsqcap U \sqsubseteq \bigsqcap V,
\end{equation*}
where $U, V \subseteq M$ for some previously chosen set $M$ of \emph{interesting
  concepts}.  The goal is then to ensure the given knowledge base is complete with respect
to all these GCIs, \ie the knowledge base should entail all such GCIs which are confirmed
by the expert, and should contain counterexamples for all other GCIs of the above type.
The greatest challenge for transferring attribute exploration to this setting is to deal
with the \emph{open world semantics} of description logic knowledge bases: if a fact is
not entailed by the knowledge base, then this does not mean that the negated fact holds.
For this, attribute exploration is generalized to work on \emph{partial contexts}, \ie
formal contexts in which certain crosses are unknown.  The resulting algorithm has been
implemented as a plugin named \emph{OntoComp} for the ontology editor
\emph{Protégé}~\cite{conf/esws/Sertkaya09}.

A third prominent application of ideas of formal concept analysis in description logics is
the work of Rudolph on \emph{relational
  exploration}~\cite{phd/de/Rudolph2006,conf/iccs/Rudolph04}.  In this approach the target
description logic is \FLE, the extension of \EL by value restriction ($\forall$).  The
domain of interest is not represented as an interpretation, but by means of \emph{binary
  power context families}~\cite{DBLP:conf/iccs/PredigerW99}, which however can easily be
considered as an interpretation.  Then the exploration process is conducted in several
phases: in phase $k$, concept descriptions with \emph{role depth} at most $k$ are
considered as attributes of the current formal context, and on this formal context
attribute exploration is performed.  Rudolph then shows that this process has to be
considered only up to a certain maximal role depth, and that the resulting set of
implications can be used to decide whether an arbitrary GCI $C \sqsubseteq D$ is valid or
not in the domain represented by the expert.  However, it is not shown whether and how
this set of implications can be transferred into a base of the domain.  Indeed, the
decision procedure for checking whether $C \sqsubseteq D$ holds in the domain or not is
rather complicated.  Thus, no GCIs are learned from this approach, and thus it cannot be
used to obtain terminological knowledge from relational data.

The aforementioned approach of \emph{power context families} is an attempt to add
description logic expressibility to the world of formal concept analysis.  In its easiest
form a formal context is equipped with a family of relations $\mathcal{R}$ on the object
set to obtain a \emph{relational context}.  Based on this notion, \emph{terminological
  attribute logic}~\cite{books/math/Prediger00} has been introduced that allows to define
new attributes in terms of old ones, using the relational context to extend the incidence
relation to the newly defined attributes.  With this semantics, terminological attribute
logic can be seen as a syntactic variant of \ALC extended by inverse roles, negated roles
and the identity role.  Terminological attribute logic can also be defined for
\emph{many-valued contexts} to provide a method for \emph{logical
  scaling}~\cite{conf/krdb/PredigerS99}, which transforms many-valued contexts into the
usual (two-valued) formal contexts in another way as the usual scaling approach of formal
concept analysis.

Another approach to bring a flavor of description logics to formal concept analysis is
\emph{relational concept analysis}~\cite{conf/icfca/RouaneHNV07,
  journals/amai/HaceneHNV13}.  The basic structure in this approach is a \emph{relational
  context family}, which consists of a family of formal contexts and a set of relations
between objects of possibly different contexts of this family.  Using a method called
\emph{relational scaling} new attributes $r : C$ are added to the formal contexts, which
roughly correspond to concept descriptions of the form $\forall r. C$ or $\exists r. C$,
where however $C$ is now a formal concept of a formal context of the family.  In an
iterative process, relational scaling is used to construct lattices from all formal
contexts of the relational context family.  These lattices can then be used to derive
assertional and terminological knowledge formulated in the description logic \FLE.

Other research that is related to this work are approaches in formal concept analysis and
description logics to tackle the problem of \emph{uncertainty} and \emph{vagueness}.  In
the area of formal concept analysis, the most notable and relevant work is the one by
Luxenburger~\cite{diss:Luxenburger,Luxenburger91}, who considers implications in formal
contexts together with an \emph{accuracy} (confidence).  Luxenburger then studies the
problem of \emph{realizations} of partial implications, which in terms of logic is just
the question whether a set of partial implications is satisfiable.  The results obtained
here give a characterization in terms of \emph{linear programs}.  Furthermore, he studies
the problem of finding \emph{bases} of partial implications, and we shall use the main
ideas in our later considerations.  Luxenburger's ideas have been used in the area of data
mining, for instance to obtain smaller representations of \emph{association
  rules}~\cite{DBLP:conf/ki/StummeTBPL01}.

Another prominent approach to handle knowledge that may not be completely correct is to
consider fuzzy extensions of the respective formalisms.  Those exist for both description
logics~\cite{journals/fss/BobilloS09,journals/ws/LukasiewiczS08} and formal concept
analysis~\cite{Pollandt97b,conf/cla/BelohlavekV05}, and are either based on Zadeh's
original approach to fuzzy logics~\cite{journals/iandc/Zadeh65}, or on the approach by
Hájek~\cite{hajek1998metamathematics}, in which the semantics is defined using
\emph{t-norms} on lattices.  In both cases, logical facts (implications, assertional
knowledge, terminological knowledge) are annotated with \emph{truth values} from an
underlying lattice, and the semantics then allows to infer truth values for previously
unknown facts, or at least bounds thereof.

Finally, a completely different approach to learning terminological knowledge has been
developed recently~\cite{conf/dlog/KonevLW13}, based on a general framework of \emph{query
  learning} proposed by~\cite{journals/ml/Angluin87}.  In contrast to the work by Baader
and Distel, this approach tries to learn TBoxes $\mathcal{T}$ by posing queries to an
\emph{oracle}.  These queries are either \emph{entailment queries}, in which the oracle
has to decide whether a proposed GCI is entailed by the TBox $\mathcal{T}$ to be learned,
or \emph{equivalence queries}, where the oracle has to decide whether a given TBox is
equivalent to $\mathcal{T}$.  The work~\cite{conf/dlog/KonevLW13} then considers
the question for which description logic the TBox $\mathcal{T}$ can be learned in
polynomial time.  In particular, it is shown that if $\mathcal{T}$ is an \emph{acyclic
  \EL-TBox}, then it cannot be learned in polynomial time.

Note that entailment queries are similar to the questions proposed to an expert during
attribute exploration.  In fact, it is possible to show that a certain special case of
query learning~\cite{journals/ml/AngluinFP92} can be used to obtain an alternative
computation of the canonical base~\cite{journals/ml/AriasB11}.

\section{Contributions}
\label{sec:contributions}

The main contributions of this thesis are the following.

\subsection{Experiments with Extracting Valid GCIs}
\label{sec:exper-with-extr}

All results obtained by Baader and Distel are \emph{effective}, meaning that the resulting
algorithms can be implemented and applied to relational data.  As a first contribution of
this work, we shall present an implementation of these algorithms in
\Cref{sec:computing-bases-from}.  We then apply this implementation to relational data
from the \emph{DBpedia project}~\cite{DBpedia}, which obtains its data by crawling
\emph{infoboxes} of Wikipedia articles.  We shall see that the approach by Baader and
Distel indeed is able to extract terminological knowledge from this data, and we shall
discuss the corresponding outcome in detail.

The main observation of these experiments however is that the errors in the DBpedia data
set inhibit GCIs from being found which otherwise would be relevant for the domain of the
chosen data.  The main example is that the GCI
\begin{equation*}
  \exists \mathsf{child}. \top \sqsubseteq \mathsf{Person}
\end{equation*}
stating the fact that every individual which has a child is a person, was not found during
our experiments.  The reason for this is that input data contained four counterexamples
for this GCI, which however were all erroneous.  On the other hand, the input data
contained 2547 \emph{positive examples} for this GCI.  This shows that the original
approach of Baader and Distel is very sensitive to errors in the input data, even if they
are comparably rare.

\subsection{Extracting GCIs with High Confidence from Erroneous Data}
\label{sec:extracting-gcis-from}

A main result from our experiments is that errors in the input data can inhibit otherwise
valid GCIs from being extracted.  On the other hand, we can assume that the input data
must be of sufficient \emph{quality} to reasonably extract terminological knowledge from
it, \ie must not contain too many errors which are relevant for our computations.  Based
on this assumption we generalize the approach by Baader and Distel from computing bases of
valid GCIs to computing bases of GCIs which are \emph{almost valid} in the input data.  To
formalize the notion of being \emph{almost valid}, we make use of the notion of
\emph{confidence} as it is used in data-mining, and transfer it to the setting of GCIs.
Instead of computing bases of valid GCIs, we then want to compute bases of GCIs whose
confidence is above a certain threshold $c$, for some chosen value $c \in [0,1]$.  Those
GCIs we shall call GCIs \emph{with high confidence}.  We shall see that we can generalize
most of the results of Baader and Distel accordingly, using Luxenburger's ideas on his
investigation of partial implications in formal contexts.  An example for such a result is
the fact that bases of the induced context of a finite interpretation give rise to a base
of the finite interpretation itself.  We shall see that we can generalize this result to
obtain that bases of implications with high confidence in the induced context give rise to
bases of GCIs with high confidence in the finite interpretation.  Finally, we shall apply
our results to the data sets we used for our experiments, to show that our approach is
able to handle certain errors in the input data.

\subsection{Exploration by Confidence}
\label{sec:expl-conf-2}

The approach of considering GCIs with high confidence is a purely heuristic one: by
considering GCIs with high confidence, we can ignore rare errors in the input data.
However, our approach ignores \emph{rare counterexamples} as well, \ie counterexamples
which are actually valid, but occur so infrequently that the confidence measures ignores
them.  In this case, an external source of information is needed that can distinguish
between errors and rare counterexamples in the data.  An example for such an external
source of information could be a human expert, who then considers all such counterexamples
manually, and decides whether they are valid or not.

Expert interaction can also be used to tackle another problem with data, namely its
\emph{incompleteness}: for certain GCIs relevant counterexamples may exist in the domain
of interest, but may not be present in the given data set.  In other words, we still
assume that our domain is represented by an interpretation, the so-called \emph{background
  interpretation}, but we only have access to some part of it.  In this case, both the
original approach by Baader and Distel, as well as our extension to GCIs with high
confidence would extract those GCIs for which relevant counterexamples are missing.  We
could use the external expert to avoid this issue, by querying this expert for possible
counterexamples from the background interpretation for all GCIs we would extract.

This expert interaction may be expensive, however, and an algorithm that keeps this
interaction to a minimum would be highly desirable.  In the case of valid implications of
a formal context, the attribute exploration algorithm would be such an algorithm, as it
asks the expert a minimal number of different questions.  Therefore, we want to generalize
attribute exploration to the setting of GCIs with high confidence to obtain an algorithm
that allows the use of an expert to distinguish between errors and rare counterexamples.

As a first step, we shall consider the easier problem of exploring \emph{implications with
  high confidence} instead of GCIs.  In this step, we shall generalize attribute
exploration to \emph{exploration by confidence}, where the algorithm not only asks the
expert after implications which are valid in the current context, but also after those
which only have high confidence.  For this, we first investigate generalizations of
attribute exploration which allow us to explore \emph{sets of implications}.  In these
generalizations, a set $\mathcal{L}$ of implications can be specified for which the expert
should decide which elements of $\mathcal{L}$ are valid.  In attribute exploration, the
set $\mathcal{L}$ is just the set of all valid implications of a given formal context.
For the case of implications with high confidence, the set $\mathcal{L}$ is then just the
set of all implications whose confidence is above a certain threshold $c$.

\subsection{Model-Exploration by Confidence}
\label{sec:model-expl-conf}

The problem of incomplete data already arises in the case of valid GCIs, and to approach
this problem Baader and Distel propose extensions of attribute exploration which also work
with valid GCIs.  One of these extensions, called \emph{model exploration}, works mostly
in the same way as attribute exploration does, with the difference that the expert now
gets asked GCIs for confirmation instead of implications.  Model exploration is
essentially attribute exploration of the induced context of the given interpretation,
although several technical problems have to be dealt with.

One of these problems it that the attribute set of the induced context depends on the
background interpretation.  Clearly, the background interpretation is not available during
the exploration process.  Model exploration solves this problem by computing the set of
attributes of the induced context incrementally during the computation.  Another problem
is the way counterexamples have to be specified: because of the \emph{closed world
  semantics} of interpretations, every counterexample provided by the expert has to be
\emph{complete}.  This means that as soon as the expert wants to provide an element as a
counterexample, all element which can be reached via directed edges from this elements in
the background interpretation have to be provided as well.  In other words, the
counterexamples provided by the expert have to be \emph{connected subinterpretations} of
the background interpretation.

To generalize model exploration to GCIs with high confidence, we essentially follow the
argumentation of model exploration.  More precisely, we shall consider exploration by
confidence of the induced context of the given interpretation, and transform it to
\emph{model exploration by confidence}, in a very similar way as model exploration arises
from attribute exploration of the induced context.

A notable difference to the argumentation of Baader and Distel is that we first have to
generalize our results about computing bases of GCIs with high confidence to include the
possibility that certain elements of the interpretation are \emph{trusted}, in the sense
that as soon as a trusted element is a counterexample for some GCI, this GCI is not
considered any further, even if its confidence is high enough.  The motivation for this
generalization stems from the fact that we consider all counterexamples provided by the
expert as valid.

%%% Local Variables:
%%% mode: latex
%%% TeX-master: "../main"
%%% End:

%  LocalWords:  Protégé OntoComp


\subsection{Random Two Peasants}
\subsubsection{Description of the Algorithm}
The main idea for the random two peasants algorithm is to sort the points along
a axis. The algorithm start from a random 2d point cloud \fref{rtp:base}

\begin{enumerate}
  \item sort all points along the x-axis.
  \item use the line \fref{rtp:line} from lowest point to greatest point
    on x-axis to divide the points in a upper \fref{rtp:upper} and a lower
    \fref{rtp:lower} point cloud.
  \item add sequential all points from the upper list to the polygon
    \fref{rtp:polygon-upper}
  \item add in reverse order all points from the lower list to the
    polygon \fref{rtp:polygon}
\end{enumerate}

\subsubsection{Implementation description}

\begin{enumerate}
  \item the function std::sort from the std lib does the sorting
  \item iterate over all points and perform the CGAL::orientation function to
    get the orientation of all points aligned at the line between the lowest
    point and the highest point.
  \item iterate over all points from the upper list and add it to the polygon
  \item iterate over all points from the lower list in reverse direction and add
    it to the polygon.
\end{enumerate}

\subsubsection{Complexitiy}

\begin{enumerate}
  \item sort all points along the x-axis. $\bigO(nlogn)$
  \item use the line from lowest point to greatest point on x-axis to divide the
    points in a upper and a lower point cloud. $\bigO(n)$
  \item add sequential all points from the upper list to the polygon $\bigO(n)$
  \item add in reverse order all points from the lower list to the polygon $\bigO(n)$
\end{enumerate}

This leads to $max(\bigO(nlogn) + \bigO(n) + \bigO(n) + \bigO(n) \Rightarrow \bigO(nlogn))$.

\subsubsection{Parameters}
\begin{description}
  \item [--nodes] how many nodes the polygon has to have. [default: 100]
  \item [--sampling-grid] the area within the polygon could grow. [default: 1500x800]
\end{description}

\subsubsection{Examples}

\begin{figure}[ht]
  \centering

  \begin{minipage}[t]{0.4\textwidth}
    \begin{tikzpicture}[yscale=0.05,xscale=0.05]
      \setcounter{i}{1}

      \draw[->] (0,0) -- (80,0) node[below] {$x$};
      \draw[->] (0,0) -- (0,70) node[left] {$y$};

      \foreach \p in {(1,11),(5,40),(10,20),(21,10),(20,18),(20,41),(33,15),(39,22),(48,9),(55,17),(60,50),(68,19)} {
        \node[point] (\arabic{i}) at \p {};
        \stepcounter{i}
      }
    \end{tikzpicture}
    \caption{Base random point cloud}
    \label{fig:rtp:base}
  \end{minipage}\hfill
  \begin{minipage}[t]{0.4\textwidth}
    \begin{tikzpicture}[yscale=0.05,xscale=0.05]
      \setcounter{i}{1}

      \draw[->] (0,0) -- (80,0) node[below] {$x$};
      \draw[->] (0,0) -- (0,70) node[left] {$y$};

      \foreach \p in {(1,11),(5,40),(10,20),(21,10),(20,18),(20,41),(33,15),(39,22),(48,9),(55,17),(60,50),(68,19)} {
        \node[point] (\arabic{i}) at \p {};
        \stepcounter{i}
      }

      \draw[blue] (1) -- (12);
    \end{tikzpicture}
    \caption{Dividing Line}
    \label{fig:rtp:line}
  \end{minipage}
\end{figure}

\begin{figure}[ht]
  \centering

  \begin{minipage}[t]{0.4\textwidth}
    \begin{tikzpicture}[yscale=0.05,xscale=0.05]
      \setcounter{i}{1}

      \draw[->] (0,0) -- (80,0) node[below] {$x$};
      \draw[->] (0,0) -- (0,70) node[left] {$y$};

      \foreach \p in {(1,11),(5,40),(10,20),(20,18),(20,41),(33,15),(39,22),(60,50),(68,19)} {
        \node[point] (\arabic{i}) at \p {};
        \stepcounter{i}
      }

      \foreach \p in {(21,10),(48,9),(55,17)} {
        \node[point, fill=red] (\arabic{i}) at \p {};
        \stepcounter{i}
      }

      \draw[blue] (1) -- (9);
    \end{tikzpicture}
    \caption{Lower List}
    \label{fig:rtp:lower}
  \end{minipage}\hfill
  \begin{minipage}[t]{0.4\textwidth}
    \begin{tikzpicture}[yscale=0.05,xscale=0.05]
      \setcounter{i}{1}

      \draw[->] (0,0) -- (80,0) node[below] {$x$};
      \draw[->] (0,0) -- (0,70) node[left] {$y$};

      \foreach \p in {(1,11),(21,10),(48,9),(55,17),(68,19)} {
        \node[point] (\arabic{i}) at \p {};
        \stepcounter{i}
      }

      \foreach \p in {(5,40),(10,20),(20,18),(20,41),(33,15),(39,22),(60,50)} {
        \node[point, fill=red] (\arabic{i}) at \p {};
        \stepcounter{i}
      }

      \draw[blue] (1) -- (5);
    \end{tikzpicture}
    \caption{Upper list}
    \label{fig:rtp:upper}
  \end{minipage}
\end{figure}

\begin{figure}[ht]
  \centering

  \begin{minipage}[t]{0.4\textwidth}
    \begin{tikzpicture}[yscale=0.05,xscale=0.05]
      \setcounter{i}{1}

      \draw[->] (0,0) -- (80,0) node[below] {$x$};
      \draw[->] (0,0) -- (0,70) node[left] {$y$};

      \foreach \p in {(1,11),(5,40),(10,20),(21,10),(20,18),(20,41),(33,15),(39,22),(48,9),(55,17),(60,50),(68,19)} {
        \node[point] (\arabic{i}) at \p {};
        \stepcounter{i}
      }
      \draw (1) -- (2) -- (3) -- (5) -- (6) -- (7) -- (8) -- (11) -- (12);
    \end{tikzpicture}
    \caption{The Upper polygon}
    \label{fig:rtp:polygon-upper}
  \end{minipage}\hfill
  \begin{minipage}[t]{0.4\textwidth}
    \begin{tikzpicture}[yscale=0.05,xscale=0.05]
      \setcounter{i}{1}

      \draw[->] (0,0) -- (80,0) node[below] {$x$};
      \draw[->] (0,0) -- (0,70) node[left] {$y$};

      \foreach \p in {(1,11),(5,40),(10,20),(21,10),(20,18),(20,41),(33,15),(39,22),(48,9),(55,17),(60,50),(68,19)} {
        \node[point] (\arabic{i}) at \p {};
        \stepcounter{i}
      }

      \draw (1) -- (2) -- (3) -- (5) -- (6) -- (7) -- (8) -- (11) -- (12) -- (10) -- (9) -- (4) -- (1);
    \end{tikzpicture}
    \caption{Final polygon}
    \label{fig:rtp:polygon}
  \end{minipage}
\end{figure}

\FloatBarrier


\newpage
\section{Proposed solution} \label{solution}

In this section we propose the approaches with centralized coordination.
In a warehouse the connection between robots is efficient and has no big limitations.
\begin{enumerate}
  \item The first strategy, mentioned above, is the \srst which consider only
  one task allocated for one robot.

  \item The second strategy \sps using an optimal approach
  to compose tasks. Precisely resolve the set partition problem of set tasks $\mathcal{T}$ .

  \item The last strategy (\gsp) extends the first algorithm,
  the main concept of this strategy is composing the tasks in a single travel with greedy coalition formation approach.

\end{enumerate}

In section \ref{chap:conclusions} as a future development we want to explore a distributed
method because in this thesis we  only focused in centralized method.

\subsection{Single robot : Single task (\srst)}

This method is a baseline for our logistic scenario.
The important constraint of this approach is to consider only one task allocated for
one robot at time.
\\
The set of tasks is ordered by the function mentioned below.
\begin{algorithm}
  \caption{Pop minimum element} \label{SP}
  \begin{algorithmic}[1]

    \Procedure{PME}{$T_i, T_j \in \mathcal{T}$}
    \If{$(demand(T_i) < demand(T_j)) \wedge (dst(T_i) < dst(T_j))$}
    \State {\bf return} true
    \Else
    \If{$dst(T_i) = dst(T_j)$}
    \State {\bf return} true
    \EndIf
    \State {\bf return} false
    \EndIf
    \EndProcedure
  \end{algorithmic}
\end{algorithm}
\newpage
Such function sorts the tasks based on the distance of the unloading bays and the demand of a specific task.
For distance we consider the euclidean distance between loading bay $L$ and unloading bays $U_j$.
Instead for demand is the weight of the item.

After the choose of the task to allocate by using the function $f(P)$ return the path distance, precisely the cost of the trail.

For this method we do not use the function $p(\cdot)$ because we have only one task for robot
then the task already has the path. As mentioned above, we do not combine routes.

For completeness in this method we do not consider the heuristic function $v(\cdot)$ because the demand for all
task is always 1. Because we allocate only one task for one robot at time.

This algorithm take linear time or $O(n)$ time, its time complexity is $O(n)$.
This means that the running time increases at most linearly with the size of the input.
More precisely, this means that there is a constant $c$ such that the running time is
at most $cn$ for every input of size $n$.

\begin{figure} [hbt]
  \centering
  \includegraphics[width=\textwidth]{img/cycle1.png}
  \caption{Example of execution \srst with 4 agents with capacity 4 and 9 tasks.}
  \label{fig:srst}
\end{figure}

\subsection{Set Partition Strategy - Single robot : Multiple task (\sps)}

This method consists to compute all possible patitions of the task set
using Set Partition algorithm \cite{partition} and use only
the best partition which is based on the previously mentioned heuristic $v(\cdot)$.

After initialzation phase which all agents send their capacity and identifier,
start the partition algorithm \cite{partition} that return all possible patitions of subsets combination
of tasks $P^N$.

Then foreach partitions the heuristic $v(\cdot)$ has been used to calculate the loss.
For calculate the loss $L$ of a partition we have to calculate the $v(\cdot)$ for all elements in
the subsets partition and finally sum all values for all subsets.
Furthermore the combination with the lowest loss has been choose.
So a subset of combination as been sort in a increasing order.
Then the first subset of combination has the lowest value of heuristic function
is the first task assigned at the first request from a robot.

\begin{algorithm}
  \caption{Set Partition Strategy} \label{SP}
  \begin{algorithmic}[1]
  \Procedure{SPS}{$P^N$}\Comment{$P^N$= \texttt{partition(}$\mathcal{T}$\texttt{)}}
  \State \Comment{define $C$ the maximum capacity of the robots}
  \For{$P_i \in P^N$}
  \If{$demand(P_i) > C$}
  $P^N \setminus P_i$
  \EndIf
    \For{$S_j \in P_i$}
      $v(S_j)$
    \EndFor
  \EndFor
  \Comment{sort all $P_i$ for lowest $v(\cdot)$}
  \State {\bf return} the first $P_i$
  \EndProcedure
  \end{algorithmic}
\end{algorithm}

The function \texttt{partition($\cdot$)} take exponential time.

More formally, this algorithm is exponential time because $T(n)$ is bounded by $O(2^{n^{k}})$
for some constant $k$.

\newpage

An example of solution with set $|\mathcal{T}| = 4$:
\begin{center}
  \begin{tabular}{|c|r|c|} \hline
  \textbf{iteration} & \textbf{partition size} & \textbf{partition} \\ \hline
  1    & 1    & \{\{a, b, c, d\}\}   \\
  2    & 2    & \{\{a, b, c\}, \{d\}\}   \\
  3    & 2    & \{\{a, b, d\}, \{c\}\}   \\
  4    & 2    & \{\{a, b\}, \{c, d\}\}   \\
  5    & 3    & \{\{a, b\}, \{c\}, \{d\}\}   \\
  6    & 2    & \{\{a, c, d\}, \{b\}\}   \\
  7    & 2    & \{\{a, c\}, \{b, d\}\}   \\
  8    & 3    & \{\{a, c\}, \{b\},\{d\}\}   \\
  9    & 2    & \{\{a, d\}, \{b, c\}\}   \\
  10   & 2    & \{\{a\}, \{b, c, d\}\}   \\
  11   & 3    & \{\{a\}, \{b, c\}, \{d\}\}   \\
  12   & 3    & \{\{a, d\}, \{b\}, \{c\}\}   \\
  13   & 3    & \{\{a\}, \{b, d\}, \{c\}\}   \\
  14   & 3    & \{\{a\}, \{b\}, \{c, d\}\}   \\
  15   & 4    & \{\{a\}, \{b\}, \{c\},\{d\}\}   \\ \hline
  \end{tabular}
\end{center}

For $|\mathcal{T}| = 4$ takes 0.000043 seconds. If we increase the set, time increases exponentially.
An example of $|\mathcal{T}| = 12$ takes 2.8 seconds and $|\mathcal{T}| = 13$ takes 21.2 seconds.

For this reason in our experiment we limited the size of the task set at most 9 tasks.

\begin{figure} [hbt]
  \centering
  \includegraphics[width=\textwidth]{img/opt.png}
  \caption{Example of execution \sps with 4 agents with capacity 4 and 9 tasks. See example \ref{example}}
  \label{fig:srst}
\end{figure}

\subsection{Greedy Set Partition Strategy - Single robot : Multiple task (\gsp)}
The main concept of this approach is composing tasks using Greedy Coalition Formation
based on \cite{cf_greedy} and \cite{cf_farinelli}. Where one wants to minimize the
team cost subject to the constraint that each task must be executed by a given
number of cooperative agents simultaneosly. Each task requires a number of different
demands, and each coalition for the task needs to provide the requered capabilities.

Later initialzation phase which all agents send their capacity and identifier,
start the Coalition Formation algorithm \cite{cf_greedy}.
When compute new one possible coalition the heuristic  $v(\cdot)$ has been used to calculate
the loss $L(T_{i,j})$ and if is negative that coalition is insered into the formation and the
$T_i$ , $T_j$ are deleted from the task set $\mathcal{T}$.

\begin{algorithm}
\caption{Greedy Coalition Formation} \label{GCF}
\begin{algorithmic}[1]
  \Procedure{GCF}{$\mathcal{T}$}\Comment{$\mathcal{T}$ = set of tasks}
  \State \Comment{define $C$ the maximum capacity of the robots}
  \For{$T_i \in \mathcal{T}$}
  \For{$T_j \in \mathcal{T}$}
\Comment{define $T_{i,j} = T_i \cup T_j$}
\If{$(T_i \neq T_j) \wedge (demand(T_{i,j}) \leq C)$}
\If{$v(T_{i,j})-v(T_i)-v(T_j) < 0$}
       \State $\mathcal{T} \setminus \{ T_i\} \setminus \{T_j\}$ $\mathcal{T} \cup \{T_{i,j}\}$
  \EndIf
  \EndIf
\EndFor
\EndFor
\State {\bf return} $\mathcal{T}$
\EndProcedure
\end{algorithmic}
\end{algorithm}

This algorithm take polynomial time, its running time is upper bounded by a polynomial expression
in the size of the input for the algorithm.

More precisely, this algorithm take $O(n^k)$ for some positive constant $k$.

\begin{figure} [hbt]
  \centering
  \includegraphics[width=\textwidth]{img/cf.png}
  \caption{Example of execution \gsp with 4 agents with capacity 4 and 9 tasks. See example \ref{example}}
  \label{fig:srst}
\end{figure}

\newpage
\subsection*{Example with 9 tasks and 4 robots} \label{example}
Given a set of tasks $\mathcal{T}= \{  \{T_0\}, \{T_1\}, \cdots, \{T_8\} \}$ defined like:

${T_i=(item, demand, unloading\_bay)}$.

The agents have the same capacity $C_{0,1,2,3} = 4$.
\begin{table}[hbt]
\begin{center}
  % \centering
  \begin{tabular}{|c|c|c|c|} \hline
    \textbf{task} & \textbf{item} & \textbf{demand} & \textbf{unloading bay} \\ \hline
    0    & A    & 1      & 0             \\
    1    & B    & 2      & 1             \\
    2    & C    & 3      & 2             \\
    3    & A    & 1      & 0             \\
    4    & B    & 2      & 1             \\
    5    & C    & 3      & 2             \\
    6    & A    & 1      & 0             \\
    7    & B    & 2      & 1             \\
    8    & C    & 3      & 2             \\ \hline
  \end{tabular}
  \caption{The task set $\mathcal{T}$ for 9 tasks}
  \label{tab:t4}
\end{center}
\end{table}

Given a finite task set $\mathcal{T}$ we can see how our strategies works.
For this example we have created a video of the simulations execution, in ROS and stage, which are available on YouTube \footnote{YouTube site https://youtu.be/XbdBklu98HE}.
\newpage
The \sps created 5 orders to perform all elements in the tasks set.

In the table \ref{tab:sps} we can see the partition composed by subsets of tasks.
\begin{table}[hbt]
  \begin{center}
    \begin{tabular}{|c|c|c|c|} \hline
    \textbf{task} & \textbf{item} & \textbf{demand} & \textbf{unloading bay} \\ \hline
    \{4,7\}    & B    & 4     & \{1\}             \\
    \{0,1,3\}  & \{A,B\}& 4    & \{0,1\}             \\
    \{2,6\}    & \{C,A\}    & 4  & \{0,2\}             \\
    5    & C    & 3      & 2             \\
    8    & C    & 3      & 2             \\ \hline
    \end{tabular}
    \caption{The result of the Set Partition Strategy (\sps)}
    \label{tab:sps}
  \end{center}
\end{table}

The \gsp creted 6 orders, one more than \sps, to perform all elements in the tasks set.

In table \ref{tab:gsp} we can see the partition composed by subsets of tasks.
\begin{table}[hbt]
\begin{center}
  \begin{tabular}{|c|c|c|c|} \hline
  \textbf{task} & \textbf{item} & \textbf{demand} & \textbf{unloading bay} \\ \hline
  \{3,2\}    & \{A,C\}    & 4     & \{0,2\}             \\
  \{0,1\}    & \{A,B\}    & 3     & \{0,1\}             \\
  \{6,4\}    & \{A,B\}    & 3     & \{0,1\}             \\
  5    & C    & 3      & 2             \\
  8    & C    & 3      & 2             \\
  7    & B    & 2      & 1             \\\hline
  \end{tabular}
  \caption{The result of the Greedy Set Partition (\gsp)}
  \label{tab:gsp}
\end{center}
\end{table}

\newpage
In this Figure \ref{fig:CF_graph} we can see because the Greedy approach is less
complex than \sps. On the execution before to create a coalition is checked if its can
be allocated. This check is the value of the loss of the coalition, if is less than zero
the colaition is insered in the solution else break the cycle for and pass another coalition.

\begin{figure} [hbt]
    \centering
    \includegraphics[width=\textwidth]{img/CF.png}
    \caption{The horizontal line represents a cut on executin defines the coalition structure.}
    \label{fig:CF_graph}
\end{figure}


% !TeX root = ../../main.tex

\chapter{Background}

\lipsum[1]

\begin{equation}
    E = mc^2
\end{equation}

\lipsum[2]

\section{Celestial Bodies in the Solar System}

\lipsum[3]

\begin{figure}[ht]
	% Figures and tables are centred by default
	\includegraphics[width=0.6\textwidth]{pale-blue-dot}
	\caption[Pale Blue Dot]{{\bf Pale Blue Dot.} The \emph{Voyager 1} spacecraft took this photograph of planet Earth on February 14, 1990 when she was more than six billion kilometers away from our home.}
\end{figure}

\subsection{Inner Planets}

\lipsum[4]

\begin{table}[ht]
    \begin{tabular}{lcccc}
        \toprule
                & \textbf{Mass} & \textbf{Diameter} & \textbf{Density}  & \textbf{Gravity} \\
                & $10^{24}$ kg  & km                & kg/m$^3$          & m/s$^2$ \\
        \midrule
        Mercury & 0.33          & 4,879             & 5,427             & 3.7 \\
        Venus   & 4.87          & 12,104            & 5,243             & 8.9 \\
        Earth   & 5.97          & 12,756            & 5,514             & 9.8 \\
        Mars    & 0.64          & 6,792             & 3,933             & 3.7 \\
        \bottomrule
    \end{tabular}
    \caption[Comparison of Inner Planets of the Solar System]{{\bf Comparison of Inner Planets of the Solar System.} Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus pellentesque dictum neque, sollicitudin accumsan purus porttitor vitae. Phasellus faucibus enim.}
\end{table}

\lipsum[5]

\begin{figure}[p]
    \caption[Inner Planets of the Solar System]{{\bf Inner Planets of the Solar System}}
    \begin{subfigure}[b]{0.5\textwidth}
        % While figures and tables are centred by default, subfigures and subtables are not
        \centering
        \includegraphics[height=2in]{mercury}
        \caption{Mercury}
    \end{subfigure}%
    \begin{subfigure}[b]{0.5\textwidth}
        \centering
        \includegraphics[height=2in]{venus}
        \caption{Venus}
    \end{subfigure}
    % Add space between rows
    \subfigurerow
    \begin{subfigure}[b]{0.5\textwidth}
        \centering
        \includegraphics[height=2in]{earth}
        \caption{Earth}
    \end{subfigure}%
    \begin{subfigure}[b]{0.5\textwidth}
        \centering
        \includegraphics[height=2in]{mars}
        \caption{Mars}
    \end{subfigure}
\end{figure}

\subsection{Asteroid Belt}

\lipsum[6]

\subsection{Outer Planets}

\lipsum[7]

\subsection{Kuiper Belt}

\lipsum[8]

\section{Artificial Objects in Heliocentric Orbits}

\lipsum[9]

\subsection{Tesla Roadster and Starman}

\lipsum[10]

\begin{figure}[ht]
    \includegraphics[width=0.8\textwidth]{starman}
    \caption[Don't Panic]{{\bf Don't Panic.} During the maiden flight of SpaceX's Falcon Heavy launch vehicle on February 6, 2018, a Tesla Roadster electric car with the ``Starman'' mannequin in spacesuit is launched into a heliocentric orbit.}
\end{figure}

\lipsum[11]

\begin{equation}
    \Delta v = v_\text{e} \ln \frac{m_0}{m_f}
\end{equation}

\lipsum[12]


\section{Histogram}
\label{sec:histogram}

\subsection{Purpose}
This program performs a multi-dimensional histogram of photon correlation events. These are defined by the program \program{correlate}, though it is also possible to histogram T3 photons directly. The output is a set of histogram bins and the number of events which fall into each. This output is \textit{not} normalized by bin width or any other factor, and represents the raw number of counts falling into each bin.

For T3 photons, \program{histogram} can be used to build a histogram of events as would be done in interactive mode. To do this, set the mode to T3, and order to 1.

For \gn{n>2}, all time dimensions are defined identically, and all pulse dimensions are defined identically. If distinct time dimensions are required, the modification can be achieved at the stage where bins are defined, without any modification later in the code.

\subsection{Command-line syntax}
%\input{programs/histogram.usage}

\subsubsection{Input}
\paragraph{\gn{1} of T3 data}
The expected input is a stream of T3 photons.

\paragraph{\gn{n\ge 2}}
The expected input is the output of \program{correlate}.

\paragraph{General options}
The main options specified for \program{histogram} define the axes for pulse and time. These are treated equivalently, so we will focus on the time axes.

For \texttt{--time}, the parameters specify the lower and upper bounds of the time axis, as well as the number of bins $n$ to create along that axis. For a linear spacing, the bin width $\Delta t$ is $(t_{\max}-t_{\min})/n$, such that the bins are defined by the ranges
\begin{equation}
\begin{aligned}
&[\time_{\min},\time_{\min}+\Delta\time),\\
&[\time_{\min}+\Delta\time,\time_{\min}+2\Delta\time),\\
&\ldots\\
&[\time_{\min}+(n-1)\Delta\time,\time_{\min}+n\Delta\time)
\end{aligned}
\end{equation}
This linear spacing is the default behavior, but the flag \texttt{--time-scale} can produce two other scales: log, and log-zero. The log scale creates bins with fixed width over the span of $[\log(\time_{\min}),\log(\time_{\max}))$, as if often desired for measurements requiring long and short time correlations. The log-zero scale has identical behavior, except that any zero-time correlations ($\timedelay=0$) are placed into the first bin. Note that the log scale cannot handle zero-time correlations, and neither log not log-zero can handle negative-time correlations. These values will be dropped from the histogram, with an error message indicating this has happened.

\subsubsection{Output}
After the input stream terminates, \program{histogram} outputs the bin definitions and the number of counts associated with that bin. Generically, this format is:
\begin{verbatim}
channel 0, channel 1, bin (1,1) lower, bin (1,1) upper, ...,
    channel 2, ... ,
    counts \n
\end{verbatim}
where the channels are integers, bin edges are floats, and the counts are integers. For every bin in the histogram, one line will be output. For T2 mode, the bin definition has only one dimension (time), so the format is:
\begin{verbatim}
channel 0, channel 1, time 1 lower, time 1 upper,
           channel 2, time 2 lower, ...,
           counts \n
\end{verbatim}
T3 data have an additional dimension (pulse):
\begin{verbatim}
channel 0, channel 1, pulse 1 lower, pulse 1 upper,
                      time 1 lower, time 1 uppper,
           channel 2, ...
           counts \n
\end{verbatim}
See section~\ref{sec:histogram_examples} for specific examples of output in these formats.

\subsection{Examples of usage}
\label{sec:histogram_examples}
\subsubsection{Time-averaged photoluminescence lifetime from T3 data}
In T3 mode, a correlation order \gn{1} is code for interactive-like behavior. Formally this is a correlation of the laser pulse and the system response, but this language is not often used.
\begin{verbatim}
> picoquant --file-in data.pt3 |  \
  histogram --mode t3 --order 1 --channels 2 \
            --time 0,10,500000
0,0.00,50000.00,0
0,50000.00,100000.00,0
...
1,0.00,50000.00,11267838
1,50000.00,100000.00,14947845
1,100000.00,150000.00,1512803
1,150000.00,200000.00,1152498
1,200000.00,250000.00,1037717
1,250000.00,300000.00,973572
1,300000.00,350000.00,932802
1,350000.00,400000.00,899615
1,400000.00,450000.00,12278
1,450000.00,500000.00,0
\end{verbatim}
Note that \texttt{histogram} will operate on channel 0 as well, even though channel 1 is the only channel with any signal. This costs extra memory and some computational overhead at startup, but ultimately the cost is insignificant compared to the cost of processing the data stream.

\subsubsection{\gn{2} from T2 data}
This data represents an electronic sync source (channel 4) and the detection of the laser itself.
\begin{verbatim}
> picoquant --file-in data.ht2 | \
  correlate --mode t2 --order 2 \
            --channels 5 \
            --max-time-distance 1000 | \
  histogram --mode t2 --order 2 \
            --channels 5 \
            --time 0,10,1000
0,0,0.00,100.00,0
...
0,4,0.00,100.00,43
0,4,100.00,200.00,24
0,4,200.00,300.00,38
0,4,300.00,400.00,43
0,4,400.00,500.00,44
...
4,4,900.00,1000.00,0
\end{verbatim}

\subsubsection{\gn{2} from T3 data}
\begin{verbatim}
> picoquant --file-in data.pt3 | \
  correlate --mode t3 --channels 2 \
            --order 2 \
            --max-pulse-distance 3 \
  histogram --mode t3 --channels 2 \
            --order 2 --pulse 0,3,3 \
            --time -500000,2,500000
0,0,0.00,1.00,-500000.00,0.00,0
...
1,1,0.00,1.00,-500000.00,0.00,0
1,1,0.00,1.00,0.00,500000.00,104640
1,1,1.00,2.00,-500000.00,0.00,123289
1,1,1.00,2.00,0.00,500000.00,124676
1,1,2.00,3.00,-500000.00,0.00,231962
1,1,2.00,3.00,0.00,500000.00,231694
\end{verbatim}
As a rough benchmark, on a computer with a dual-core 3\giga\hertz{} processor running 32-bit Linux, this command required 25\second{} of wall time, for \texttt{data.ht3} containing 32.7 million photon records (18.1\kilo\cps) for a total of 0.8 million correlation events.

\subsubsection{\gn{3} from T2 data}
This T2 data is the same as the laser data from before:
\begin{verbatim}
> picoquant --file-in data.ht2 | \
  correlate --mode t2 --order 2 \
            --channels 5 \
            --max-time-distance 1000000 | \
  histogram --mode t2 --order 2 \
            --channels 5 \
            --time 0,1,1000000
0,0,0.00,1000000.00,0,0.00,1000000.00,31
0,0,0.00,1000000.00,1,0.00,1000000.00,55
0,0,0.00,1000000.00,2,0.00,1000000.00,57
...
4,0,0.00,1000000.00,2,0.00,1000000.00,2710
4,0,0.00,1000000.00,3,0.00,1000000.00,2235
4,0,0.00,1000000.00,4,0.00,1000000.00,0
...
\end{verbatim}
Note how much larger the time window must be to catch significant numbers of higher-order events.

\subsection{Implementation details}
The problem of populating and returning histograms for all possible correlations can be broken into a few distinct steps:
\begin{enumerate}
\item Construct a histogram for every permutation of channels.
\item For each correlation event:
  \begin{enumerate}
  \item Identify the histogram corresponding to the permutation of channels.
  \item Identify the bin associated with the parameters of the correlation.
  \item Increment that bin in that histogram.
  \end{enumerate}
\item For every bin of every histogram, print the bin definition and associated counts
\end{enumerate}
As such, each of these will be discussed separately. The discussion will focus on T2 data, but T3 data are handled identically for twice the order of equivalent T2 data.

\subsubsection{The cross-correlations can be enumerated as base-$\abs{\channels}$ numbers}
Each histogram corresponds to a single cross-correlation, as identified by the tuple $\vec{\channel}\in\channels^{n}$, for $\channels$ the set of all channels and correlation order $n$. As such, if we enumerate the channels as whole numbers ($0, 1, \ldots$), it is evident that each element of the tuple can be treated as the coefficient of an $n$-digit number in base $\abs{\channels}$. Mapping these tuples onto the set of whole numbers can thus be achieved by the following formula:
\begin{equation}
\Index(\vec{\channel}) = \sum_{j=0}^{n-1}{\channel_{j}\abs{\channels}^{n-1-j}}
\end{equation}
where the elements $\channel$ refer implicitly to the index of that channel in our enumeration.
If $\abs{\channels}=2$, this is identical to the expression of an $n$-digit binary number.

In the software, all possible cross-correlations are enumerated and the corresponding histograms allocated before beginning the calculation. This requires some computational overhead at instantiation, and if an application requires the calculation of large numbers of histograms it may be more efficient to modify the code to output and reset upon receiving particular signals.

The implementation of these methods can be found in \texttt{histogram\_gn.c} and \texttt{combinations.c}.

\subsubsection{A histogram is function of $n$-dimensional vectors mapping mapping onto integers}
Once the particular cross-correlation has been identified, the task falls to that of incrementing a counter corresponding to the appropriate histogram bin. The purpose of a histogram is to divide some phase space into well-defined smaller blocks, and then to count the number of events which fall into those blocks. We will restrict ourselves to rectangular volumes, so the task of identifying the correct volume of phase space can be reduced to determining the correct index along all axes, and thus each indexing step is identical to that for a single-dimensional histogram.

In one dimension, we first define a range of values into which the events can fall, for example $\timewindow=\left[\timewindow\upminus,\timewindow\upplus\right)\subset\integers$. Next, we define some number $N$ of ranges $\resolution$ whose members collectively span $\timewindow$. These $\resolution$ can be enumerated $0,1,\ldots N-1$, so assign these indices in order to the sorted $\resolution$. Now this one dimension is represented by an $N$-dimensional vector whose dimensions represent some $\resolution$. The task then turns to mapping any value $z\in\integers$ to the appropriate $\resolution$.

For linearly-spaced sub-ranges, this identification can be achieved in O(1) time by:
\begin{equation}
\Index(x) = \timewindow\upminus + x\parens{\frac{\timewindow\upplus-\timewindow\upminus}{N}}
\end{equation}
However, in the code this is not used, and instead a more general binary search algorithm (costing O($\log(N)$)) is implemented to permit arbitrary spacings of these ranges. The binary algorithm determines the placement of an element into a sorted list by iterative division of the list into upper and lower halves, until the appropriate element is define. This is implemented as:
\lstset{language=Python}
\begin{lstlisting}
def binary_search(value, bins):
    upper = len(bins)
    lower = 0

    if value < bins[0] or values > bins[-1]:
        # Not in the bounds
        return(False)

    while True:
        middle = (upper - lower)/2
        if value in bins[middle]:
            # Just right
            return(middle)
        elif value < bins[middle]:
            # Too high
            upper = middle
        else:
            # Too low
            lower = middle
\end{lstlisting}
Because this must be performed for each dimension of the correlation, the search costs O($n\log{(N)}$) time, compared to the O($n$) for the complete linear search.

To see how this is implemented in \program{histogram}, see \texttt{histogram\_gn.c} and \texttt{histogram\_t*.c}.

\subsubsection{Printing the histogram}
Having exhausted the stream of correlation events, the final task is to print all of the histogram bins in a readable format. This is done by iterating over the histograms, then iterating over the bins, printing the counts associated with each bin. How this process is performed should be evident from the preceding discussion, and for the details refer to the routine \texttt{print\_gn\_histogram} in \texttt{histogram\_gn.c}.

Note that the output of $\program{histogram}$ is not normalized in any way: only the number of counts is reported for each bin.


\documentclass{article}

%----------------------------------------------------------------------------------------

\usepackage{listings} % Required for inserting code snippets
\usepackage{geometry}
\geometry{margin=0.7in}
\usepackage[usenames,dvipsnames]{color} % Required for specifying custom colors and referring to colors by name
\usepackage{amssymb}
\usepackage{amsmath}
\usepackage{mathtools}
\usepackage{tikz}
\usepackage{enumerate}

\delimitershortfall-1sp
\newcommand\abs[1]{\left|#1\right|}

\definecolor{DarkGreen}{rgb}{0.0,0.4,0.0} % Comment color
\definecolor{highlight}{RGB}{255,251,204} % Code highlight color

%----------------------------------------------------------------------------------------

\begin{document}

%----------------------------------------------------------------------------------------

\begin{flushleft}
\begin{center}
$\displaystyle \lim_{x \to 2} (x^2 - x) = 2$
\end{center}

We know that $c=2$, $L=2$, $f(x) = x^2 - x$. \\

\vspace{.4cm}
\begin{center}
$\abs{f(x) - L} = \abs{x^2-x-2} < \epsilon \implies \abs{\abs{x-2} \abs{x+1}} < \epsilon$ \\
\end{center}
\vspace{.4cm}

We cannot define $\delta_\epsilon$ in terms of $x$, but $\abs{x-2} = \frac{\epsilon}{\abs{x+1}}$ leaves $\delta_\epsilon$ in terms of $x$. We need to find a fixed $M$ such that $\frac{\epsilon}{M} < \frac{\epsilon}{\abs{x+1}}$. We only care about $x$ \textit{around} $2$, so we can restrict $x$ to the open interval $(1,3)$.

\begin{center}
\begin{tabular}{c c}
$1<x<3$ & $1<x<3$ \\
$-1<x-2<1$ & $2<x+1<4$ \\
$\abs{x-2}<1$ & $\frac{1}{2}<\frac{1}{\abs{x+1}}<\frac{1}{4}$ \\
\end{tabular}
\end{center}

\subsection*{Proof}
Let $\epsilon > 0$ be given. Let $\delta_\epsilon=min\{1, \frac{\epsilon}{4}\}$. Then $0<\abs{x-2}<\delta_\epsilon$ implies
\begin{center}
\begin{tabular}{l}
(1) $\abs{x-2} < 1 \implies 2<\abs{x+1}<4$ \\
(2) $\abs{f(x) - L} =\abs{x^2-x-2} = \abs{x-2}\abs{x+1} < \frac{\epsilon}{4}\cdot4 = \epsilon$ \\
\end{tabular}
\end{center}

This completes the proof.
\end{flushleft}

\vspace{.75cm}

\begin{flushleft}
\begin{center}
$\displaystyle \lim_{x \to 0} x^2(sin(x) + cos(x)) = 0$
\end{center}
\vspace{.4cm}
We know that $c=0$, $L=0$, $f(x) = x^2(sin(x) + cos(x))$. \\
\vspace{.4cm}
From the combination of the transcendental functions $\abs{sin(x) + cos(x)}$, we know the maximum value that the functions can reach is $\sqrt{2}$. Therefore, we can modify $f(x)$ to be $\sqrt{2} x^2$ since we know that the $\abs{sin(x) + cos(x)}$ part of the function is bounded above. Thus, we have
\begin{center}
\begin{tabular}{r}
$\abs{\sqrt{2} x^2 - 0} < \epsilon$ \\
$\abs{\sqrt{2} x^2} < \epsilon$ \\
$\sqrt{2} x^2 < \epsilon$ \\
$x < \frac{\sqrt{\epsilon}}{\sqrt[4]{2}}$ \\
\end{tabular}
\end{center}

\subsection*{Proof}

Let $\epsilon > 0$ and $\delta_\epsilon=\frac{\sqrt{\epsilon}}{\sqrt[4]{2}}$. Then, $0 < x < \frac{\sqrt{\epsilon}}{\sqrt[4]{2}}$ implies
\begin{center}
$-\frac{\sqrt{\epsilon}}{\sqrt[4]{2}} < x < \frac{\sqrt{\epsilon}}{\sqrt[4]{2}}$ \\
$x^2 < \frac{\epsilon}{\sqrt{2}}$ \\
$\sqrt{2}x^2 < \epsilon$ \\
\end{center}
Thus, $\abs{\sqrt{2}x^2} < \epsilon$. This satisfies the proof because we stated that $sin(x) + cos(x)$ is bounded above by $\sqrt{2}$. By definition of an upper bound, there can never exist a value that exceeds $\abs{sin(x) + cos(x)x^2}$. Then, $\abs{sin(x) + cos(x)x^2} < \abs{x^2\sqrt{2}} < \epsilon$.
\end{flushleft}

%----------------------------------------------------------------------------------------

\end{document}


\documentclass{article}
\begin{document}
  \section{Block}

  \begin{equation}
    e^{i\pi}=-1
    \label{eq:euler}
  \end{equation}
  Equation~\ref{eq:euler} is some good math.

  \section{Inline}

  some lovely maths \(x^2 + y^2 = z^2\)
\end{document}


\subsection{The EXAFS Equation}
\begin{frame}
  \frametitle{The EXAFS Equation} %% Analysis with {\feff} \&  {\arch} or {\ifeffit} }

  The XAFS Equation used with {\feff} and {\larch}:

  \[
  \chi(k) = \sum_j {{ S_0^2 {\Blue{N_j}} {\Red{f_j(k)}}  e^{-2R_j/\lambda(k)}
      e^{-2k^2{\Blue{\sigma_j^2}}}}\over{k{\Blue{R_j}}^2}}
  {\sin[{2k{\Blue{R_j}} + {\Red{\delta_j(k)}}} ]}
   \]

\begin{itemize}
   \pause
     \item  The sum is over  {\RedEmph{Scattering Paths}} of the
       photo-electron.   Both:

       \begin{description}

       \item[Single Scattering] {\tiny{ absorbing atom $\Rightarrow$ neighbor atom
             $\Rightarrow$ absorbing atom}}

       \item[Multiple Scattering] {\tiny{absorbing atom $\Rightarrow$ neighbor
             atom  $\Rightarrow$ neighbor atom $\Rightarrow$ \ldots  $\Rightarrow$
             absorbing atom}}

       \end{description}

       \pause\item $\Red{f(k)}$ and $\Red{\delta(k)}$ are
       {{photo-electron scattering amplitude and phases}}:

   \begin{itemize}
   \item Energy ($k$) dependent.
   \item $Z$ dependent -- $Z$ of the scattering atoms(s).
   \item non-trivial: must be calculated (or extracted from measured spectra).

   \end{itemize}
 \end{itemize}

   \vmm \hrule \vmm

   \onslide+<4->

   Knowing  $\Red{f(k)}$ and $\Red{\delta(k)}$, we can determine structural information:

     \begin{itemize}
     \item ${\Blue{R}}$ --  near neighbor distance.
     \item ${\Blue{N}}$ -- coordination number.
     \item ${\Blue{\sigma^2}}$ -- mean-square  disorder in ${\Blue{R}}$.
     \end{itemize}

   \vmm

\end{frame}


\documentclass{article}

%%%%%%%%%%%%%%%% 2020 - 11 - 28 %%%%%%%%%%%%%%%%%%
\usepackage{tikz}
\usetikzlibrary{calc}
\usepackage{pgfplots}
\usepackage{graphicx}
\usepackage{url}

\usepackage{amsmath}
\usepackage{algorithm, algpseudocode}
\renewcommand{\algorithmicrequire}{\textbf{Input:}}
\renewcommand{\algorithmicensure}{\textbf{Output:}}
\algnewcommand{\LeftComment}[1]{\Statex \(\triangleright\) #1}
\usepackage{amsfonts}  % \mathbb{R}
\makeatletter
\newlength{\trianglerightwidth}
\settowidth{\trianglerightwidth}{$\triangleright$~}
\algnewcommand{\LineComment}[1]{\Statex \hskip\ALG@thistlm $\triangleright$ #1}
\algnewcommand{\LineCommentCont}[1]{\Statex \hskip\ALG@thistlm%
  \parbox[t]{\dimexpr\linewidth-\ALG@thistlm}{\hangindent=\trianglerightwidth \hangafter=1 \strut$\triangleright$ #1\strut}}

\algnewcommand{\LeftLineCommentCont}[1]{\Statex \hskip\ALG@thistlm%
  \parbox[t]{\dimexpr\linewidth-\ALG@thistlm}{\leftskip=\algorithmicindent \hangindent=\trianglerightwidth \hangafter=1 \strut$\triangleright$ #1\strut}}

\usepackage[utf8]{inputenc}
\usepackage[english]{babel}
\usepackage{amsthm}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\newtheorem{theorem}{Theorem}[section]
\newtheorem{corollary}{Corollary}[theorem]
\newtheorem{lemma}[theorem]{Lemma}
\theoremstyle{definition}
\newtheorem{definition}{Definition}[section]
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\usepackage{minted}

\usepackage{subfig}
\usepackage[export]{adjustbox}% in preamble
%\subfloat[hlof entryi][hsub-captioni]{%
%hfigurei}
%\subfloat[hlot entryi][hsub-captioni]{%
%htablei}

\usepackage{hhline}
\usepackage{makecell, caption, booktabs}
\usepackage{siunitx}

%%The second way (hacky, and depends on an implementation detail of els-cas)
\makeatletter
\def\redefparbox{\def\@parboxrestore{\@arrayparboxrestore\let\\\@normalcr
  \if@minipage\expandafter\@gobbletwo\fi
  \@firstofone{\centering\casscparboxtest}}}
\def\casscparboxtest#1{%
  \ifx\rightskip#1\relax\expandafter\dimen@\else
    \expandafter\@secondoftwo
  \fi\@gobble{#1}}
\makeatother
%%The second way (hacky, and depends on an implementation detail of els-cas)

%%%%%%%%%%%%%%%% 2020 - 11 - 28 %%%%%%%%%%%%%%%%%%

\usepackage{PRIMEarxiv}

\usepackage[utf8]{inputenc} % allow utf-8 input
\usepackage[T1]{fontenc}    % use 8-bit T1 fonts
\usepackage{hyperref}       % hyperlinks
\usepackage{url}            % simple URL typesetting
\usepackage{booktabs}       % professional-quality tables
\usepackage{amsfonts}       % blackboard math symbols
\usepackage{nicefrac}       % compact symbols for 1/2, etc.
\usepackage{microtype}      % microtypography
\usepackage{lipsum}
\usepackage{graphicx}
\graphicspath{{media/}}     % organize your images and other figures under media/ folder

%% Title
\title{ on Polynomial Approximation of Activation Function
%%%% Cite as
%%%% Update your official citation here when published
%\thanks{\textit{\underline{Citation}}:
%\textbf{Authors. Title. Pages.... DOI:000000/11111.}}
}

\author{ \href{https://orcid.org/0000-0003-0378-0607}{\includegraphics[scale=0.06]{orcid.pdf}\hspace{1mm}John Chiang} \\
	\texttt{liyue.sun@mail.nankai.edu.cn, john.chiang.smith@gmail.com} \\
}

\begin{document}
\maketitle

\section{Introduction}
When it comes to applying homomoiphic encryption techqiue to machine learning such as neural network, there is a techquice problem that non-polynomial of activation function  could not be calculated directly in the HE domain. The common way to deal with it is to approximate the activation function using the least-square method, to a polynomial that can be calculated in a HE-based environmental\cite{hadash2018estimate}. Being widely adapted in recent work related to HE\cite{kour2014real}, however, the least-square method maight not be ideal for this task. In this essay, we propose an neat method to approximate the activation function based on the the least squared method.

Note that the idea of this essay did come to the present author, but we can not garnteen that other researches haven't found it (we should give some time to read the book carefully before trying to develope some own method). In conclude, this is a simple idea that can propaply work for approximating activation function of HE. // %比最小二次乘更容易符合同态加密下的要求

\section{Least Square Method}
\label{sec:headings}
For a continuous real-value function $f(x)$, a simple version of least square method to approximate $f(x)$ over range $[a, b]$ by a polynomial of a given degree $n$ is to find a polynomial of at most degree $n$, $p_n(x)$, such that  minimise the $$\int_{a}^{b} (f(x) - p_n(x))^2 dx. $$

For approximating a continuous real-value function $f(x)$ over the range $[a, b]$ by a polynomial of a given degree $n$, a simple version of least square method  is to find a polynomial of at most degree $n$, $p_n(x)$, such that  maximise the $$\int_{a}^{b} (f(x) - p_n(x))^2 dx, $$ which has a unique solution (the best approximation). Least square method is such a common method that many softwares implement this method, such as the function  $polyfit( \cdot )$ in Python, Matlab or Octave. For example, only 3 lines of Octave codes is all it needs to fit the activation function $ReLU(x) = max(0, x) $ over the range $[-8, +8]$ by a polynomial of degree 2, resulting in the figure 1:
\begin{minted}
{octave}
x = [-8:0.000001:+8];
y = max(0,x);
polyfit(x,y,2)
\end{minted}
and we get the polynomial approximation $p_2^{ls}(x) = 0.058594 +  0.500000 \cdot x +  0.750000 \cdot x^2 $

Even through least square method has many advantages, it maight not be the best choice in the sense of a HE-based environment. In the sense of a HE-based environment, we would like to choice a low-degree polynomial due to the expensive HE operations, and also perfer the similiar curve shape between the apprximation polynomial and the function to approximate, even at the cost of losing best appxiromation. Thus, we propose a simple method to conside the gradient(the slope) into the optimal function.

and its limition in the polynomial approximation of activation function
To minimise the gray area of the is not enough, we perhaps would like a polynomial approximation that has a similiar shape to the activation function, even at the cost of some larger gray area.

\section{Our Method}
\label{sec:others}

In this section, we present  a simple method based on the least-square method, which  includes  the graduals (shape) of the Polynomial and the activation into  the least-square method, in order to get the desired polynomial approximation that we describled above.
such that  minimise the
$$\int_{a}^{b} (f(x) - p_n(x))^2 + (f'(x) - p_n'(x))^2 dx. $$

For a toy example, we use this method for the same task above, that is to fit the activation function $ReLU$ over the range $[-8, +8]$ by a polynomial of degree 2 denoted by $p_2^{lg}(x) = c +  b \cdot x +  a \cdot x^2 . $ The question is to minimise the observation loss function
\begin{equation*}
  \begin{aligned}
F(a, b, c)  = & \int_{-8}^{0} (f(x) - p_2^{lg}(x))^2  dx
                +\int_{0}^{+8} (f(x) - p_2^{lg}(x))^2  dx
                +\int_{-8}^{0} (f'(x) - p_2^{lg}{'}(x))^2 dx
                +\int_{0}^{+8} (f'(x) - p_2^{lg}{'}(x))^2 dx   \\
            = & [\frac{4}{3}a^2x^3 + (b^2 + 1 - 2b)x + 2a(b - 1)x^2  ]|_{0}^{+8}  + \\
            &[\frac{1}{5}a^2x^5 + \frac{1}{3}b^2x^3 + bcx^2 - \frac{2}{3}bx^3 + c^2x + \frac{1}{3}x^3 - cx^2 + \frac{1}{2}abx^4 - \frac{1}{2}ax^4 + \frac{2}{3}acx^3 ]|_{0}^{+8} + \\
            & [\frac{4}{3}a^2x^3 + b^2x + 2abx^2  ]|_{-8}^0 + \\
            &[\frac{1}{5}a^2x^5 + \frac{1}{3}b^2x^3 + c^2x + bcx^2  + \frac{1}{2}abx^4 + \frac{2}{3}acx^3 ]|_{-8}^{0} + \\
            = & 14472.5\dot{3}a^2 + 357.\dot{3}b^2 + 16c^2  + 682.\dot{6}ac - 357.\dot{3}b + 178.\dot{6} - 64c - 2176a
 \end{aligned}
\end{equation*}
Minimising $F(a,b,c)$ is a problem of unconstrained optimization. To do that, we need to calcuate  the first-order partial derivatives of $F(a,b,c)$ and have them equal to $0$ :
\begin{equation*}
  \begin{aligned}
F_a(a, b, c) & = 28945.0\dot{6}a +  682.\dot{6}c - 2176 &= 0  \\
F_b(a, b, c) & =  714.\dot{6}b  - 357.\dot{3}  &= 0  \\
F_c(a, b, c) & = 32c  + 682.\dot{6}a - 64 &= 0
 \end{aligned}
\end{equation*}
Solving these equations, we obtain the unique solution and the polynomial approximation, respectly:
\begin{equation*}
  \begin{aligned}
a = 0.0563686709, b = 0.5, c = 0.7974683544, \\
p_n^{lg}(x) = 0.797468 +  0.500000 \cdot x +  0.056369 \cdot x^2
 \end{aligned}
\end{equation*}
We compare the polynomial generated by least square,  $p_n^{ls}(x)$, with that of our method $p_n^{lg}(x)$.
\begin{figure}[ht]
\centering

\begin{tikzpicture}[remember picture]
\begin{axis}[
%legend pos=south east,
%legend style={at={(0.5,-0.17)},anchor=north,legend cell align=left},
legend style={at={(0.5,+0.9)},anchor=north,},
width=0.45\linewidth,
xtick={-8, -6, -4, -2, 0, 2,  4, 6, 8 },
yticklabels={},
at={(0.66\linewidth,0)},
]
%Below the red parabola is defined
\addplot [
    domain=-8:8,
    samples=100,
    color=red,
]
{0.797468 +  0.500000*x +  0.056369*x^2 };
\addlegendentry{$p_2^{lg}(x)$}
%Here the blue parabola is defined
\addplot [
    domain=-8:8,
    samples=100,
    color=blue,
    ]
    {0.058594 +  0.500000*x +  0.750000*x^2 };
\addlegendentry{$p_2^{ls}(x)$};
%ReLU
\addplot [
    domain=-8:8,
    samples=100,
    color=gray,
    ]
    {max(0, x) };
\addlegendentry{$\texttt{ReLU}$};
\end{axis}
\end{tikzpicture}

\iffalse
\begin{tikzpicture}[overlay, remember picture, scale=.5]
\begin{axis}[
hide axis,
%xtick=\empty, ytick=\empty,
width=0.45\linewidth,
%width=3cm,
%height=2.1cm,
%scale only axis,
%xmin=-0.6235,
%xmax=-0.6186,
%xtick={-0.623, -0.621, -0.619},
%ymin=0.1651,
%ymax=0.1655,
%ytick={0.1651, 0.1653, 0.1655},
xshift=2.25cm,yshift=5.75cm,
]
%Below the red parabola is defined
\addplot [
    domain=-2:2,
    samples=20,
    color=red,
]
{0.797468 +  0.500000*x +  0.056369*x^2 };
%Here the blue parabola is defined
\addplot [
    domain=-2:2,
    samples=20,
    color=blue,
    ]
    {0.058594 +  0.500000*x +  0.750000*x^2 };
%ReLU
\addplot [
    domain=-2:2,
    samples=20,
    color=black,
    ]
    {max(0, x) };
\end{axis}
\end{tikzpicture}
\fi

\caption{ Results in the }
\label{fig1}
\end{figure}

\begin{figure}[ht]
\centering

\begin{tikzpicture}[remember picture]
\begin{axis}[
%legend pos=south east,
%legend style={at={(0.5,-0.17)},anchor=north,legend cell align=left},
legend style={at={(0.5,+0.9)},anchor=north,},
width=0.45\linewidth,
xtick={ -6, -4, -2, 0, 2,  4, 6 },
yticklabels={},
at={(0.66\linewidth,0)},
]
%Below the red parabola is defined
\addplot [
    domain=-6:6,
    samples=100,
    color=red,
]
{1.1110537229 + 0.5*x + 0.054235537*x^2 };
\addlegendentry{$p_2^{lg}(x)$}
%ReLU
\addplot [
    domain=-6:6,
    samples=100,
    color=gray,
    ]
    { max(0, x) };
\addlegendentry{$\texttt{ReLU}$};
\end{axis}
\end{tikzpicture}

\caption{ Results in the }
\label{fig2}
\end{figure}
From the figure \ref{fig1}, we can see that our polynomial are much the same as ReLU in the term of shape(slope), and that the least square polynomial doesn't even look like the ReLU funtion.

A more flexiable way to generate teh polynomial approximation is to set add more  parameters to control the weight or propotion of the least square to slope gradial resulting polynomial. To take the $ReLU$  within the domain $[-L, +L]$ as a example, we could optimise the following function:
\begin{equation*}
  \begin{aligned}
F(a, b, c)  =  \lambda_0 \cdot \int_{-L}^{0} (0 - p_2^{lg}(x))^2  dx
             + \lambda_1 \cdot \int_{0}^{+L} (x - p_2^{lg}(x))^2  dx  \\
             + \lambda_2 \cdot \int_{-L}^{0} (0 - p_2^{lg}{'}(x))^2 dx
             + \lambda_3 \cdot \int_{0}^{+L} (1 - p_2^{lg}{'}(x))^2 dx ,
 \end{aligned}
\end{equation*}
where $\lambda_0$, $\lambda_1$, $\lambda_2$ and $\lambda_3$ are four real number greater than zero to control the various weight propotion.

Another example is, supposing that we want to find a polynomial to approximate the relu over the domain $[-6, +6]$ such that it fit the ReLU very well at the both ends at the expense of losing some precsion round the center. In this case, we need to minimise the function (we just set $\lambda_0 = \lambda_1 = \lambda_2 = \lambda_3 = 1$ ):
\begin{equation*}
  \begin{aligned}
F(a, b, c)  =&   \int_{-6}^{-3} (0 - p_2^{lg}(x))^2  dx
             +  \int_{+3}^{+6} (x - p_2^{lg}(x))^2  dx
             +  \int_{-6}^{-3} (0 - p_2^{lg}{'}(x))^2 dx
             +  \int_{+3}^{+6} (1 - p_2^{lg}{'}(x))^2 dx   \\
            =& 3517.2a^2 + 132b^2 + 6c^2  + 54bc + 1917ab + 252ac - 607.5a - 78b - 27c + 12.
 \end{aligned}
\end{equation*}
Solving this  unconstrained optimization, we get the polynomial $p_2^{(1)} = 1.1110537229 + 0.5 \cdot x + 0.054235537 \cdot x^2 $. Figure \ref{fig2} shows that $p_2^{(1)}$ is exactly what polynomial we want.

\section{Conclusion}
Your conclusion here
Our method to approximate activation function is much flexiable compared to least square method in the sense of ml.
Vouriac setting of parmpaters should result in polynomials of different shapes.
%Bibliography
\bibliographystyle{unsrt}
\bibliography{references}

\end{document}

on Polynomial Approximation of Activation Function/templatePRIME.tex