help-glpk
[Top][All Lists]
Advanced

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

Re: [Help-glpk] [Fwd: Ceil in minimize function -- invalid type error (m


From: Andrew Makhorin
Subject: Re: [Help-glpk] [Fwd: Ceil in minimize function -- invalid type error (mod file in attachment)]
Date: Wed, 18 Jan 2017 12:08:49 +0300

> I'm using stand-alone solver, version 4.54. Running by 
> glpsol -m supp.mod
> In attachment the whole file with model and data.
> 
> 
> I'm trying to solve problem to pick suppliers for articles with minimum
> global order value. 
> Each article can be bought from different suppliers with different
> price. When supplier don't have some article - the price is set to -1,
> but there is constraint s.t. CorrectSupplier, which blocked order that
> article from that supplier.
> Each supplier have some maximum value (we can't order from him more than
> the value).
> Till here I have done it, and it works OK by the goal function:
> 
> minimize goal: sum{a in Art,s in Supp} OrdQty[a,s] * Prices[a,s];
> 
> 
> 
> 
> The problem I have when I'm trying to add a delivery cost.
> Delivery cost is defined by article package quantity (for example from
> supplier X delivery cost for article A is 3$ for each 10 peaces). When I
> define package quantity for each article (same for all suppliers), and
> when I define delivery cost for each article package for each supplier
> (different for each supplier), I have problem with calculating the goal
> function.
> 
> 
> When I define it like:
> 
> minimize goal: sum{a in Art,s in Supp} ((OrdQty[a,s] * Prices[a,s]) +
> (ceil(OrdQty[a,s]/ArtPackQty[a])*DeliveryCost[a,s]);
> 
> 
> 
> the solver gives me error:
> supp.mod:18: argument for ceil has invalid type
> Context: ...[ a , s ] ) + ( ceil ( OrdQty [ a , s ] / ArtPackQty [ a ] )
> MathProg model processing error
> 
> 
> I'm not sure, if I can use function (ceil) with my var (OrdQty), but I
> don't know, how to calculate it in another way.
> I'd be very greatful for any help.
> 

In constraints you cannot use variables as arguments to ceil function,
because this leads to non-linear constraints not allowed by glpk.

There are two ways to model fixed costs:

1. Use approximate delivery cost, i.e. use just y rather than ceil(y).
   If y is expected to be quite large in the optimal solution, the
   approximation error will be insignificant.

2. Introduce auxiliary *integer* variables. For example,

      z >= y;

   allows modeling z = ceil(y), where z >= 0 is an auxiliary integer
   variable (assuming that you minimize the overall delivery cost).





reply via email to

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