help-glpk
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Help-glpk] abs() function


From: Brady Hunsaker
Subject: Re: [Help-glpk] abs() function
Date: Thu, 16 Jun 2005 11:46:54 -0400
User-agent: Debian Thunderbird 1.0.2 (X11/20050331)

Ajay Joshi wrote:
> Hi,
>     I have the following code
> 
> var x{NODES} integer;
> var y{NODES} integer;
> .
> .
> .
> .
> .
> s.t. dist{i in NODES, j in NODES}: dis[i,j] = abs(x[i] - x[j]) +
> abs(y[i] -y[j]);
> 
> When I ran this code using glpsol, it gave me an error
> 
> wpm.mod:75: argument for abs has invalid type
> Context:  , j ] == 1 ) then dis [ i , j ] = abs ( x [ i ] - x [ j ] )
> Model processing error
> 
> 
> How do I correct this error?
> 
> Thanks,
> Ajay
> 

The abs() function cannot be used on variables since it introduces
nonlinearity.  It is available for expressions that involve parameters only.

To do what you are trying with GLPK, you will probably need to use
integer variables.  Exactly how to do it depends a bit on the rest of
your model.

Brady

-- 
Brady Hunsaker
Assistant Professor
Industrial Engineering
University of Pittsburgh
http://www.engr.pitt.edu/hunsaker/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]