Answers.Body: <p>Sounds more like a optimization problem than a deep learning / machine learning problem to me.  </p>
  
  <p>For machine learning you would have the features of every child / vehicle <em>and</em> the optimal amount of pizza / fuel already given, but you don't know <em>how</em> exactly the optimal amount is computed. So the target is to find a function which maps features to target.</p>
  
  <p>However in your case you don't know the optimal value, you just have a number of constraints. So my suggestion would be to use <a href="https://en.wikipedia.org/wiki/Linear_programming" rel="nofollow noreferrer">linear programming</a>.  </p>
  
  <p>Here is an simple example: drive the maximum distance with a given amount of fuel</p>
  
  <p><span class="math-container">$$\text{max }\ m_1 \cdot x_1 + ... + m_n \cdot x_n$$</span>
  <span class="math-container">$$\text{s.t. }\ x_1 + ... + x_n \leq F$$</span>
  <span class="math-container">$$m_i \cdot x_i \geq T_i\  \forall\  1 \leq i \leq n$$</span></p>
  
  <p><span class="math-container">$x_i$</span> is the amount of fuel (in gallons) given to car <span class="math-container">$i$</span>, <span class="math-container">$m_i$</span>'s are miles-per-gallon for car <span class="math-container">$i$</span>. <span class="math-container">$F$</span> is the total amount of fuel available, this is our first constraint, we cannot distribute more fuel than we have. The second constraint say's that we like to drive at least <span class="math-container">$T_i$</span> miles with car <span class="math-container">$i$</span>. This ensures we do not just give all the fuel to the most efficient car.</p>
  
  <p>You can come up with more constraints for drivers competency, engine horse power etc. In order so solve your problem with linear programming, you just have to make sure it is still linear and convex. Problems of this kind can be solved using the <a href="https://en.wikipedia.org/wiki/Simplex_algorithm" rel="nofollow noreferrer">Simplex algorithm</a> (<a href="https://docs.scipy.org/doc/scipy/reference/generated/scipy.optimize.linprog.html" rel="nofollow noreferrer">scipy.optimize.linprog</a>).<br>
  If your objective or your constraints are more complex you can use numerical methods for non-linear <a href="https://en.wikipedia.org/wiki/Constrained_optimization" rel="nofollow noreferrer">constrained optimization</a> problems (see <a href="https://docs.scipy.org/doc/scipy/reference/tutorial/optimize.html" rel="nofollow noreferrer">scipy.optimize</a> for algorithms).</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-06-15T10:46:38.407Z
Answers.Text: So @Tinu it means this type of problems cannot be solved by machine learning approaches even though total amount is given?
Answers.UserDisplayName: Hamza
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-06-15T10:06:13.400Z
Answers.LastActivityDate: 2020-06-15T10:47:39.710Z
Answers.LastEditDate: 2020-06-15T10:47:39.710Z
Answers.UserDisplayName: Tinu
Body: <p>I had done with different classification, regression and clustering approaches for predictions of values, etc. I was wondering if there is a machine learning approach for distribution of a whole based on some features (I do not know if there is an approach for that I just could not find one with my research).</p>
  
  <p>An easy example might be lets consider we have height and weight data of many children and we have to distribute a given number of pizza slices amongst them so that skinny children get more pizza as compared to obese ones because pizza is more beneficial for skinny as compared to obese. So might have to find out the optimum number of slices for each child out of the total number of slices so that each child gets maximum possible nutrients. A more complex version could incorporate more features like age, overall health, blood sugar content, physical activity index, daily calorie consumption, and others.</p>
  
  <p>A similar example might be to find out the optimal value of fuel to be allocated to each vehicle if we have a total of 100 gallons. Features might be distance they have to travel, mpg, driver competency, engine horsepower, etc., so that all of them might travel the maximum distance possible.</p>
  
  <p>So, can we achieve a task like this with machine learning/deep learning approaches? If not what are the hurdles achieving this?</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2020-06-15T10:22:09.407Z
Comments.Text: Hi. What do you mean by "for distribution of a whole"? I don't understand why you're using this expression. Your problem is about allocating resources given some constraints .
Comments.UserDisplayName: nbro
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2020-06-15T10:47:49.993Z
Comments.Text: Hi @nbro! I used that because I could not think of any term more explaining than this . Thanks for the edit though it makes it more clear!
Comments.UserDisplayName: Hamza
Tags: <machine-learning><deep-learning><optimization>
Title: Can a machine learning approach solve this constrained optimisation problem?
UserDisplayName: Hamza
ThreadText: # Can a machine learning approach solve this constrained optimisation problem?
  
  (Asked by: username_0 on 2020-06-14)
  
  I had done with different classification, regression and clustering approaches for predictions of values, etc. I was wondering if there is a machine learning approach for distribution of a whole based on some features (I do not know if there is an approach for that I just could not find one with my research).
  
  An easy example might be lets consider we have height and weight data of many children and we have to distribute a given number of pizza slices amongst them so that skinny children get more pizza as compared to obese ones because pizza is more beneficial for skinny as compared to obese. So might have to find out the optimum number of slices for each child out of the total number of slices so that each child gets maximum possible nutrients. A more complex version could incorporate more features like age, overall health, blood sugar content, physical activity index, daily calorie consumption, and others.
  
  A similar example might be to find out the optimal value of fuel to be allocated to each vehicle if we have a total of 100 gallons. Features might be distance they have to travel, mpg, driver competency, engine horsepower, etc., so that all of them might travel the maximum distance possible.
  
  So, can we achieve a task like this with machine learning/deep learning approaches? If not what are the hurdles achieving this?
  
  **Tags:** machine-learning, deep-learning, optimization
  > **Comments:**
  > **username_1**: Hi. What do you mean by "for distribution of a whole"? I don't understand why you're using this expression. Your problem is about allocating resources given some constraints .  
  > **username_0**: Hi @nbro! I used that because I could not think of any term more explaining than this . Thanks for the edit though it makes it more clear!  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_2 on 2020-06-15. Score: 1
  
  Sounds more like a optimization problem than a deep learning / machine learning problem to me.
  
  For machine learning you would have the features of every child / vehicle *and* the optimal amount of pizza / fuel already given, but you don't know *how* exactly the optimal amount is computed. So the target is to find a function which maps features to target.
  
  However in your case you don't know the optimal value, you just have a number of constraints. So my suggestion would be to use [linear programming](https://en.wikipedia.org/wiki/Linear_programming).
  
  Here is an simple example: drive the maximum distance with a given amount of fuel
  
  $$\text{max }\ m\_1 \cdot x\_1 + ... + m\_n \cdot x\_n$$
  $$\text{s.t. }\ x\_1 + ... + x\_n \leq F$$
  $$m\_i \cdot x\_i \geq T\_i\ \forall\ 1 \leq i \leq n$$
  
  $x\_i$ is the amount of fuel (in gallons) given to car $i$, $m\_i$'s are miles-per-gallon for car $i$. $F$ is the total amount of fuel available, this is our first constraint, we cannot distribute more fuel than we have. The second constraint say's that we like to drive at least $T\_i$ miles with car $i$. This ensures we do not just give all the fuel to the most efficient car.
  
  You can come up with more constraints for drivers competency, engine horse power etc. In order so solve your problem with linear programming, you just have to make sure it is still linear and convex. Problems of this kind can be solved using the [Simplex algorithm](https://en.wikipedia.org/wiki/Simplex_algorithm) ([scipy.optimize.linprog](https://docs.scipy.org/doc/scipy/reference/generated/scipy.optimize.linprog.html)).  
  If your objective or your constraints are more complex you can use numerical methods for non-linear [constrained optimization](https://en.wikipedia.org/wiki/Constrained_optimization) problems (see [scipy.optimize](https://docs.scipy.org/doc/scipy/reference/tutorial/optimize.html) for algorithms).
  
  > **Comments:**
  > **username_0**: So @Tinu it means this type of problems cannot be solved by machine learning approaches even though total amount is given?  
  
  ---
  
  