bug-glpk
[Top][All Lists]
Advanced

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

Re: [Bug-glpk] expression following = has invalid type


From: Chris Matrakidis
Subject: Re: [Bug-glpk] expression following = has invalid type
Date: Sun, 11 Jun 2017 10:34:50 +0300

>> Do you have any suggestion(s) to overcome this issue?
>
> You may replace the statement
>
> var R {o in OMEGA} = r[0] + sum{k in 1..n-1} 2*r[k]*cos(k*o);
>
> which is incorrect in MathProg, with the following ones:
>
> var R {o in OMEGA};
> s.t. foo{o in OMEGA}: R[o] = r[0] + sum{k in 1..n-1} 2*r[k]*cos(k*o);

In addition to this, it is a good idea to replace cos(k*o) with something like:

if abs(cos(k*o)) < 1e-9 then 0 else cos(k*o)

otherwise you will get lots of small values that will mess the scaling
of the model. In the example you posted, this leads to a result that
is off by a few orders of magnitude.


Best Regards,

Chris Matrakidis



reply via email to

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