[Top][All Lists]

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

Re: [Help-glpk] Complex constraint definition

From: Thomas Pfau
Subject: Re: [Help-glpk] Complex constraint definition
Date: Mon, 5 Dec 2016 06:45:58 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.4.0

Your formulation makes a multiplication of f and P.
Thus this is only a linear constraint if only one of f and P are variables.

If both are variables, this would create a non linear constraint. Thus, if you want to optimize this you would need a non linear solver (in this instance a quadratic programming solver would do the job, if your constraints are not sticking to certain conditions), and glpk does not offer this functionality (for all I know).

As for the binary variable:
If I'm not mistaken, the idea would be to add a binary variable in a way that you add it to both constraints.

{j in T, i in B}: sum{k in S} f[i,k]*P[j,k] >=Min[j] - (1-B[k]) * X
{j in T, i in B}: - B[k] * X <= sum{k in S} f[i,k]*P[j,k] <= B[k] * X

Where X is a very large number (something that for your problem is almost the same as infinity).
Now, if B[k] = 0, the lower constraint is equal to your second constraint, while the upper constraint is almost always true, due to the large X which is subtracted from the right hand side.
If B[k] = 1, the lower constraint is almost certainly true because -inf <= something <= inf is certain to be true (if your X was big enough), and the upper constraint become the constraint you want.
Thus you ensure, that either the one or the other (or both) constraints are respected.

Hope this helps,


On 2016-12-04 18:33, Tiago Santos wrote:
Hello Heinrich,

Thank you for the answer.
But I'm new in using GLPK and I didn't get completely your point here.

How can I use a binary variable to help there?
And what do you mean by "only one of f, P can be a variable"?.

Thank you,

On Sat, Dec 3, 2016 at 11:14 PM, Heinrich Schuchardt <address@hidden> wrote:
Hello Tiago,

you will need to add a binary variable.

Only one of f, P can be a variable.


Am 03.12.16, 22:42, Tiago Santos <address@hidden> schrieb:

I'm trying to model a constraint and that is being so complex to me.

Is there any way to model a constraint like the follwing in GLPK?

I need to restrict that the sum must be equal or greater than Min[j] otherwise 0.

{j in T, i in B}: sum{k in S} f[i,k]*P[j,k] >=Min[j]
{j in T, i in B}: sum{k in S} f[i,k]*P[j,k] =0

Thank you,
_______________________________________________ Help-glpk mailing list address@hidden

Help-glpk mailing list

The University of Aberdeen is a charity registered in Scotland, No SC013683.
Tha Oilthigh Obar Dheathain na charthannas clàraichte ann an Alba, Àir. SC013683.

reply via email to

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