Answers.Body: <p>The "objective function" is the function that you want to minimise or maximise in your problem.</p>
  
  <p>The expression "objective function" is used in several different contexts (e.g. <a href="https://stats.stackexchange.com/q/179026/82135">machine learning</a> or <a href="https://www.courses.psu.edu/for/for466w_mem14/Ch11/HTML/Sec1/ch11sec1_ObjFn.htm" rel="noreferrer">linear programming</a>), but it always refers to the function to be maximised or minimised in the specific (optimisation) problem. Hence, this expression is used in the context of <a href="https://en.wikipedia.org/wiki/Mathematical_optimization" rel="noreferrer">mathematical optimisation</a>. </p>
  
  <p>For example, in machine learning, you define a model, <span class="math-container">$\mathcal{M}$</span>. To train <span class="math-container">$\mathcal{M}$</span>, you usually define a loss function <span class="math-container">$\mathcal{L}$</span> (e.g., a <a href="https://en.wikipedia.org/wiki/Mean_squared_error" rel="noreferrer">mean squared error</a>), which you want to minimise. <span class="math-container">$\mathcal{L}$</span> is the "objective function" of your problem (which in this case is to be minimised).</p>
  
  <p>In the context of search algorithms, the objective function could represent e.g. the cost of the solution. For example, in the case of the <a href="https://en.wikipedia.org/wiki/Travelling_salesman_problem" rel="noreferrer">travelling salesman problem</a> (TSP), you define a function, call it <span class="math-container">$C$</span>, which represents the "cost" of the tour or <a href="http://mathworld.wolfram.com/HamiltonianCycle.html" rel="noreferrer">Hamiltonian cycle</a>, that is, a function which sums up the weights of all edges in the tour. In this case, the "objective" of your problem is to minimise this function <span class="math-container">$C$</span>, because, essentially, you want to find an inexpensive tour, which is associated with either a local (or global) minimum of <span class="math-container">$C$</span>. This function <span class="math-container">$C$</span> is the "objective function".</p>
  
  <p>It should now be easy to memorise the expression "objective function", as it contains the term "objective", and the "objective" (or goal) in your (optimisation) problem is to minimise (or maximise) the corresponding function.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-11-16T22:28:16.243Z
Answers.LastActivityDate: 2018-11-16T22:52:38.427Z
Answers.LastEditDate: 2018-11-16T22:52:38.427Z
Answers.UserDisplayName: nbro
Body: <p>Local search algorithms are useful for solving pure optimization problems, in which the aim is to find the best state according to an objective function.</p>
  <p>My question is what is the objective function?</p>
  <p><img src="https://i.sstatic.net/y459H.jpg" alt="Hill Climbing" /></p>
  
Tags: <terminology><objective-functions><optimization><local-search><meta-heuristics>
Title: What is an objective function?
UserDisplayName: Abbas Ali
ThreadText: # What is an objective function?
  
  (Asked by: username_0 on 2018-11-16)
  
  Local search algorithms are useful for solving pure optimization problems, in which the aim is to find the best state according to an objective function.
  
  My question is what is the objective function?
  
  ![Hill Climbing](https://i.sstatic.net/y459H.jpg)
  
  **Tags:** terminology, objective-functions, optimization, local-search, meta-heuristics
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2018-11-16. Score: 8 | Accepted answer
  
  The "objective function" is the function that you want to minimise or maximise in your problem.
  
  The expression "objective function" is used in several different contexts (e.g. [machine learning](https://stats.stackexchange.com/q/179026/82135) or [linear programming](https://www.courses.psu.edu/for/for466w_mem14/Ch11/HTML/Sec1/ch11sec1_ObjFn.htm)), but it always refers to the function to be maximised or minimised in the specific (optimisation) problem. Hence, this expression is used in the context of [mathematical optimisation](https://en.wikipedia.org/wiki/Mathematical_optimization).
  
  For example, in machine learning, you define a model, $\mathcal{M}$. To train $\mathcal{M}$, you usually define a loss function $\mathcal{L}$ (e.g., a [mean squared error](https://en.wikipedia.org/wiki/Mean_squared_error)), which you want to minimise. $\mathcal{L}$ is the "objective function" of your problem (which in this case is to be minimised).
  
  In the context of search algorithms, the objective function could represent e.g. the cost of the solution. For example, in the case of the [travelling salesman problem](https://en.wikipedia.org/wiki/Travelling_salesman_problem) (TSP), you define a function, call it $C$, which represents the "cost" of the tour or [Hamiltonian cycle](http://mathworld.wolfram.com/HamiltonianCycle.html), that is, a function which sums up the weights of all edges in the tour. In this case, the "objective" of your problem is to minimise this function $C$, because, essentially, you want to find an inexpensive tour, which is associated with either a local (or global) minimum of $C$. This function $C$ is the "objective function".
  
  It should now be easy to memorise the expression "objective function", as it contains the term "objective", and the "objective" (or goal) in your (optimisation) problem is to minimise (or maximise) the corresponding function.
  
  
  ---
  
  