RE: diet problem disregarding cost

2024-03-20 Thread Meketon, Marc
If a_ij is the amount of nutrient i in food j, and b_i is the desired amount of 
nutrients, and x_j is the amount of food to purchase, then

sum{x_j * a_ij : j in FOODS} – b_i = b_i*(rpos_i – rneg_i)

would then have rpos_i + rneg_i be the absolute value of the deviation of the 
fraction needed

From: Bjørnar Ness 
Sent: Wednesday, March 20, 2024 10:26 AM
To: Meketon, Marc 
Cc: Dušan Plavák ; help-glpk@gnu.org
Subject: Re: diet problem disregarding cost


CAUTION: This email originated outside the company. Do not click links or open 
attachments unless you are expecting them from the sender.


Thanks a lot. But do you have a small example I can continue on? It important 
that the values are not absolute, but fractions of the needed quantities

ons. 20. mars 2024 kl. 15:21 skrev Meketon, Marc 
mailto:marc.meke...@oliverwyman.com>>:
In general, if you have variables rpos_i and rneg_i (the ith constraint), and 
you have:

[linear equation i] = rpos_i – rneg_i

Then (rpos_i + rneg_i) is the absolute value

If you then have
rpos_i + rneg_i <= z

z would be the maximum absolute value, and then you just minimize  z.

From: 
help-glpk-bounces+marc.meketon=oliverwyman@gnu.org<mailto:oliverwyman@gnu.org>
 
mailto:oliverwyman@gnu.org>>
 On Behalf Of Dušan Plavák
Sent: Wednesday, March 20, 2024 7:02 AM
To: Bjørnar Ness mailto:bjornar.n...@gmail.com>>
Cc: help-glpk@gnu.org<mailto:help-glpk@gnu.org>
Subject: Re: diet problem disregarding cost


CAUTION: This email originated outside the company. Do not click links or open 
attachments unless you are expecting them from the sender.


Hi, feel free to send me an email. I did this ~ 9-10 years ago for our startup 
where we generate personalized nutrition plans for our clients using glpk.

Basically you want to build bunch of inequalities and most probably you want to 
have more variables not only nutrients... Depend on your exact use case.

On Wed, Mar 20, 2024 at 4:34 PM Bjørnar Ness 
mailto:bjornar.n...@gmail.com>> wrote:
Can anyone point me to an diet problem example that tries to minimize
max deviation in percentage for each nutrient, disregarding cost?

--
Bj(/)rnar


--
S pozdravom Dušan Plavák


This e-mail and any attachments may be confidential or legally privileged. If 
you received this message in error or are not the intended recipient, you 
should destroy the e-mail message and any attachments or copies, and you are 
prohibited from retaining, distributing, disclosing or using any information 
contained herein. Please inform us of the erroneous delivery by return e-mail. 
Thank you for your cooperation. For more information on how we use your 
personal data please see our Privacy 
Notice<https://www.oliverwyman.com/policies/privacy-notice.html>.


--
Bj(/)rnar


This e-mail and any attachments may be confidential or legally privileged. If 
you received this message in error or are not the intended recipient, you 
should destroy the e-mail message and any attachments or copies, and you are 
prohibited from retaining, distributing, disclosing or using any information 
contained herein. Please inform us of the erroneous delivery by return e-mail. 
Thank you for your cooperation. For more information on how we use your 
personal data please see our Privacy 
Notice<https://www.oliverwyman.com/policies/privacy-notice.html>.


Re: diet problem disregarding cost

2024-03-20 Thread Bjørnar Ness
Thanks a lot. But do you have a small example I can continue on? It
important that the values are not absolute, but fractions of the needed
quantities

ons. 20. mars 2024 kl. 15:21 skrev Meketon, Marc <
marc.meke...@oliverwyman.com>:

> In general, if you have variables rpos_i and rneg_i (the ith constraint),
> and you have:
>
>
>
> [linear equation i] = rpos_i – rneg_i
>
>
>
> Then (rpos_i + rneg_i) is the absolute value
>
>
>
> If you then have
>
> rpos_i + rneg_i <= z
>
>
>
> z would be the maximum absolute value, and then you just minimize  z.
>
>
>
> *From:* help-glpk-bounces+marc.meketon=oliverwyman@gnu.org
>  *On Behalf Of *Dušan
> Plavák
> *Sent:* Wednesday, March 20, 2024 7:02 AM
> *To:* Bjørnar Ness 
> *Cc:* help-glpk@gnu.org
> *Subject:* Re: diet problem disregarding cost
>
>
>
>
>
> *CAUTION:* This email originated outside the company. Do not click links
> or open attachments unless you are expecting them from the sender.
>
>
>
> Hi, feel free to send me an email. I did this ~ 9-10 years ago for our
> startup where we generate personalized nutrition plans for our clients
> using glpk.
>
>
>
> Basically you want to build bunch of inequalities and most probably you
> want to have more variables not only nutrients... Depend on your exact use
> case.
>
>
>
> On Wed, Mar 20, 2024 at 4:34 PM Bjørnar Ness 
> wrote:
>
> Can anyone point me to an diet problem example that tries to minimize
> max deviation in percentage for each nutrient, disregarding cost?
>
> --
> Bj(/)rnar
>
>
>
>
> --
>
> S pozdravom Dušan Plavák
>
> --
> This e-mail and any attachments may be confidential or legally privileged.
> If you received this message in error or are not the intended recipient,
> you should destroy the e-mail message and any attachments or copies, and
> you are prohibited from retaining, distributing, disclosing or using any
> information contained herein. Please inform us of the erroneous delivery by
> return e-mail. Thank you for your cooperation. For more information on how
> we use your personal data please see our Privacy Notice
> <https://www.oliverwyman.com/policies/privacy-notice.html>.
>


-- 
Bj(/)rnar


RE: diet problem disregarding cost

2024-03-20 Thread Meketon, Marc
In general, if you have variables rpos_i and rneg_i (the ith constraint), and 
you have:

[linear equation i] = rpos_i – rneg_i

Then (rpos_i + rneg_i) is the absolute value

If you then have
rpos_i + rneg_i <= z

z would be the maximum absolute value, and then you just minimize  z.

From: help-glpk-bounces+marc.meketon=oliverwyman@gnu.org 
 On Behalf Of Dušan 
Plavák
Sent: Wednesday, March 20, 2024 7:02 AM
To: Bjørnar Ness 
Cc: help-glpk@gnu.org
Subject: Re: diet problem disregarding cost


CAUTION: This email originated outside the company. Do not click links or open 
attachments unless you are expecting them from the sender.


Hi, feel free to send me an email. I did this ~ 9-10 years ago for our startup 
where we generate personalized nutrition plans for our clients using glpk.

Basically you want to build bunch of inequalities and most probably you want to 
have more variables not only nutrients... Depend on your exact use case.

On Wed, Mar 20, 2024 at 4:34 PM Bjørnar Ness 
mailto:bjornar.n...@gmail.com>> wrote:
Can anyone point me to an diet problem example that tries to minimize
max deviation in percentage for each nutrient, disregarding cost?

--
Bj(/)rnar


--
S pozdravom Dušan Plavák


This e-mail and any attachments may be confidential or legally privileged. If 
you received this message in error or are not the intended recipient, you 
should destroy the e-mail message and any attachments or copies, and you are 
prohibited from retaining, distributing, disclosing or using any information 
contained herein. Please inform us of the erroneous delivery by return e-mail. 
Thank you for your cooperation. For more information on how we use your 
personal data please see our Privacy 
Notice<https://www.oliverwyman.com/policies/privacy-notice.html>.


Re: diet problem disregarding cost

2024-03-20 Thread Dušan Plavák
Hi, feel free to send me an email. I did this ~ 9-10 years ago for our
startup where we generate personalized nutrition plans for our clients
using glpk.

Basically you want to build bunch of inequalities and most probably you
want to have more variables not only nutrients... Depend on your exact use
case.

On Wed, Mar 20, 2024 at 4:34 PM Bjørnar Ness  wrote:

> Can anyone point me to an diet problem example that tries to minimize
> max deviation in percentage for each nutrient, disregarding cost?
>
> --
> Bj(/)rnar
>
>

-- 
S pozdravom Dušan Plavák


diet problem disregarding cost

2024-03-20 Thread Bjørnar Ness
Can anyone point me to an diet problem example that tries to minimize
max deviation in percentage for each nutrient, disregarding cost?

-- 
Bj(/)rnar