[Top][All Lists]

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

Re: [Help-glpk] Subject to two conditions

From: Suleyman Demirel
Subject: Re: [Help-glpk] Subject to two conditions
Date: Wed, 10 Nov 2010 10:22:27 -0500

You have an either/or constraint, and I do not think you can use a direct or statement (unless developers made something like that).

Usually, if you have an either/or constraint, you should define a binary variable, say y, taking only 0-1 value. If y=0, the sum is less than zero, if y=1, the sum is greater than two.

Let M be a very large number (M=100000000000).Then, you should have two constraints as follows.

s.t. condition1{(i,j) in E}: (sum{(i,j,i1,j1) in L} x2[i1,j1] <=M *y;
s.t. condition1{(i,j) in E}: (sum{(i,j,i1,j1) in L} x2[i1,j1] >=2*y - M *(1-y)

Hope this helps.

On Wed, Nov 10, 2010 at 9:18 AM, João Vilela <address@hidden> wrote:
Dear all,

I'm solving a variation of a max flow problem in a graph, where:

set V, default {1..n};        /* is a set of nodes */
set E, within V cross V;     /* is a set of arcs */
set L, within E cross E;      /* is a set to map edges to edges */
var x2{(i,j) in E}, binary;    /* x2[i,j] indicates whether there is any flow going through link (i,j) */

And I have the following condition:

> s.t. condition{(i,j) in E}: (sum{(i,j,i1,j1) in L} x2[i1,j1] <=0) or (sum{(i,j,i1,j1) in L} x2[i1,j1] >= 2);

Basically, this means that I need the sum of those x2[i1,j1] to be different from 1 (i.e. less or equal to 0 *or* bigger or equal than 2). Although, this code gives me the following error:

"operand preceding <= has invalid type"

Any idea?

Thank you,

Help-glpk mailing list

Suleyman Demirel - Office: (734) 647-3167

PhD Candidate in Operations Management
Stephen M. Ross School of Business
University of Michigan, Ann Arbor

reply via email to

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