[AMPL 2622] Help with a constraint!

View: New views
4 Messages — Rating Filter:   Alert me  

[AMPL 2622] Help with a constraint!

by plozmar :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Hi,

I have a big problem trying to find a good constraint for the
following case:

---------------------------------------
param DEMANDS{NODES};

var DEMANDS_pd {NODES, NODES, NODES, NODES};


subject to demands_per_node_per_demand {i in NODES, j in NODES}:

        DEMANDS_pd [i,j,j,i] = DEMANDS [i,j];

subject to demands_per_node_per_demand_2 {i in NODES, j in NODES}:

        DEMANDS_pd [i,j,i,i] = -DEMANDS[i,j];
-------------------------------------------

The result variable DEMANDS_pd has the following apparence,  for
example, for  DEMANDS_pd[1,2,*,*]

    1       2  3  4
1   0.5   0  0  0
2  -0.5   0  0  0
3   0     0  0  0
4   0    0  0  0

this table MUST have only two elements different from zero (the same
but opposite). I need a constraint that fixes the values of all the
elements a zero because with another contraints, the values can
change, and change all the result...

Thank you very much in advance,

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "AMPL Modeling Language" group.
To post to this group, send email to ampl@...
To unsubscribe from this group, send email to ampl+unsubscribe@...
For more options, visit this group at http://groups.google.com/group/ampl?hl=en
-~----------~----~----~----~------~----~------~--~---


[AMPL 2623] Re: Help with a constraint!

by Paul A. Rubin :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


I'm not entirely sure I understand this, but if you are saying that
you want to fix DEMANDS_pd at zero for all cells not covered by the
other two constraints, what about the following?

subject to fix_zero {i in NODES, j in NODES, k in NODES, m in NODES :
m <> i || (k <> i && k <> j)}:
DEMANDS_pd[i,j,k,m] = 0;

On Jul 2, 7:11 am, plozmar <lozano_pal...@...> wrote:

> Hi,
>
> I have a big problem trying to find a good constraint for the
> following case:
>
> ---------------------------------------
> param DEMANDS{NODES};
>
> var DEMANDS_pd {NODES, NODES, NODES, NODES};
>
> subject to demands_per_node_per_demand {i in NODES, j in NODES}:
>
>         DEMANDS_pd [i,j,j,i] = DEMANDS [i,j];
>
> subject to demands_per_node_per_demand_2 {i in NODES, j in NODES}:
>
>         DEMANDS_pd [i,j,i,i] = -DEMANDS[i,j];
> -------------------------------------------
>
> The result variable DEMANDS_pd has the following apparence,  for
> example, for  DEMANDS_pd[1,2,*,*]
>
>     1       2  3  4
> 1   0.5   0  0  0
> 2  -0.5   0  0  0
> 3   0     0  0  0
> 4   0    0  0  0
>
> this table MUST have only two elements different from zero (the same
> but opposite). I need a constraint that fixes the values of all the
> elements a zero because with another contraints, the values can
> change, and change all the result...
>
> Thank you very much in advance,
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "AMPL Modeling Language" group.
To post to this group, send email to ampl@...
To unsubscribe from this group, send email to ampl+unsubscribe@...
For more options, visit this group at http://groups.google.com/group/ampl?hl=en
-~----------~----~----~----~------~----~------~--~---


[AMPL 2628] Re: Help with a constraint!

by plozmar :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


It´s perfect! It works and it´s the constraint I was looking for,
thank you. But one more question: what´s the meaning of the operator
<> ? I haven´t seen before.

Thanks in advance,

On 4 jul, 16:43, Paul <ru...@...> wrote:

> I'm not entirely sure I understand this, but if you are saying that
> you want to fix DEMANDS_pd at zero for all cells not covered by the
> other two constraints, what about the following?
>
> subject to fix_zero {i in NODES, j in NODES, k in NODES, m in NODES :
> m <> i || (k <> i && k <> j)}:
> DEMANDS_pd[i,j,k,m] = 0;
>
> On Jul 2, 7:11 am, plozmar <lozano_pal...@...> wrote:
>
>
>
> > Hi,
>
> > I have a big problem trying to find a good constraint for the
> > following case:
>
> > ---------------------------------------
> > param DEMANDS{NODES};
>
> > var DEMANDS_pd {NODES, NODES, NODES, NODES};
>
> > subject to demands_per_node_per_demand {i in NODES, j in NODES}:
>
> >         DEMANDS_pd [i,j,j,i] = DEMANDS [i,j];
>
> > subject to demands_per_node_per_demand_2 {i in NODES, j in NODES}:
>
> >         DEMANDS_pd [i,j,i,i] = -DEMANDS[i,j];
> > -------------------------------------------
>
> > The result variable DEMANDS_pd has the following apparence,  for
> > example, for  DEMANDS_pd[1,2,*,*]
>
> >     1       2  3  4
> > 1   0.5   0  0  0
> > 2  -0.5   0  0  0
> > 3   0     0  0  0
> > 4   0    0  0  0
>
> > this table MUST have only two elements different from zero (the same
> > but opposite). I need a constraint that fixes the values of all the
> > elements a zero because with another contraints, the values can
> > change, and change all the result...
>
> > Thank you very much in advance,- Ocultar texto de la cita -
>
> - Mostrar texto de la cita -

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "AMPL Modeling Language" group.
To post to this group, send email to ampl@...
To unsubscribe from this group, send email to ampl+unsubscribe@...
For more options, visit this group at http://groups.google.com/group/ampl?hl=en
-~----------~----~----~----~------~----~------~--~---


[AMPL 2629] Re: Help with a constraint!

by Paul A. Rubin :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message




On Jul 6, 12:55 pm, plozmar <lozano_pal...@...> wrote:
> It´s perfect! It works and it´s the constraint I was looking for,
> thank you. But one more question: what´s the meaning of the operator
> <> ? I haven´t seen before.
>

not-equal-to

It can be used freely in logical expressions, but not as the relation
in a constraint (in a mathematical program -- it would be perfectly
valid in a constraint in a Constraint Programming model).
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "AMPL Modeling Language" group.
To post to this group, send email to ampl@...
To unsubscribe from this group, send email to ampl+unsubscribe@...
For more options, visit this group at http://groups.google.com/group/ampl?hl=en
-~----------~----~----~----~------~----~------~--~---