how to control the number of variables

Problems with modeling
yanzhiping
User
User
Posts: 36
Joined: 1 month ago

how to control the number of variables

Postby yanzhiping » 1 month ago

I have a problem as following:

Code: Select all

set A
A1(A)
A2(A)

B
B1(B)
B2(B)
B3(B)
variable
P(A,B)


In this case, variable p is related to all the combination of A and B. but actually only P(A1,B1) and P(A2,B2), P(A,B3) are nonzero.
there are a lot of fixed zero variables for P(A1,B2), P(A2,B1).

How may I define a variable with only non-zero values?

Manassaldi
User
User
Posts: 10
Joined: 2 months ago
Location: Rosario - Argentina

Re: how to control the number of variables

Postby Manassaldi » 1 month ago

Hi, the final number of variables depends on the constraints.

cladelpino
User
User
Posts: 21
Joined: 2 months ago

Re: how to control the number of variables

Postby cladelpino » 1 month ago

For more detail: You don't need to declare the domain of the variable (as in variable P(A,B)). You can just write variable p;

Then, if the variable appears in the constraints, it will be part of the model. Check out this example:

Code: Select all

sets A /1*5/
     A1(A) /2,3/

variable d,t;

equation Q,dummy;

Q(A1).. d(a1) =E= 0;
dummy.. t=l=2;

model p /all/;

solve p using lp maximizing t

yanzhiping
User
User
Posts: 36
Joined: 1 month ago

Re: how to control the number of variables

Postby yanzhiping » 1 month ago

this works well. thanks a lot.


Return to “Modeling”

Who is online

Users browsing this forum: No registered users and 1 guest