[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
## Re: [Help-glpk] How to get a variable's absolute value with GNU mathprog

**From**: |
hhb83 |

**Subject**: |
Re: [Help-glpk] How to get a variable's absolute value with GNU mathprog |

**Date**: |
Fri, 27 Feb 2009 02:56:29 -0800 (PST) |

It works, thank you very much!
Haibin
Andrew Makhorin wrote:
>* *
>*> Would anyone tell me how to get a variable's absolute value with GNU*
>*> mathprog? *
>*> var X;*
>*> var Xabs;*
>*> s.t. absolte: Xabs = abs(X);*
>*> It always says: argument for abs has invalid type.*
>* *
>* You cannot use variables in abs(), because this leads to a non-linear*
>* constraint not allowed in glpk.*
>* *
>*> If I write this:*
>*> s.t absolte: Xabs = if X<=0 then (-1)*X else X;*
>*> It says: operand proceding <= has invalid type.*
>* *
>* Analogously.*
>* *
>*> Then what should I do?*
>* *
>* It depends on the context where you need to use absolute value.*
>* In general case you can model abs with binary variables. However,*
>* sometimes this is not needed, for example, if abs is part of the*
>* objective function which should be minimized; see:*
>* http://lists.gnu.org/archive/html/help-glpk/2007-08/msg00036.html*
>* *
>* *
>* *
>* _______________________________________________*
>* Help-glpk mailing list*
>* address@hidden*
>* http://lists.gnu.org/mailman/listinfo/help-glpk*
>* *
>* *
--
View this message in context:
http://www.nabble.com/How-to-get-a-variable%27s-absolute-value-with-GNU-mathprog-tp22241565p22243580.html
Sent from the Gnu - GLPK - Help mailing list archive at Nabble.com.