Re: need some help (basics)

77 views
Skip to first unread message

Mohamad Dehghani

unread,
Apr 29, 2013, 1:23:17 PM4/29/13
to gams...@googlegroups.com
maybe u can add this equation to the model.

x.fx('A','a1')=0 ;



see what happens

hope this helps





On Apr 30, 2013, at 12:05 AM, Mátyás Lember <lember...@gmail.com> wrote:

Hello,

i have searching for the solution for a days, but i can't find it.
Please help me!
So, my problem is that:
I need to prohibit to use D-a1 combination, when minimizing. (D is a city, a1 is a worker, so a1 worker can not go to city D)
Cant change the number 5 to a greater number. :)
Thank you in advance!!

SETS
i /a1, a2, a3, a4/
j /A, B, C, D/;

Table T(i,j) ido
   A B C D
a1 6 7 5 5
a2 7 4 8 6
a3 3 4 2 6
a4 5 7 7 5;

VARIABLES
X(I,J)
Z;
POSITIVE VARIABLES X(I,J);
EQUATIONS
OBJ
KORL1 (I)
KORL2 (J)
;
OBJ.. Z =E= SUM((I,J), T(I,J)*X(I,J));
KORL1(I).. SUM(J, X(I,J)) =E= 1;
KORL2(J).. SUM(I, X(I,J)) =E= 1;

MODEL HOZZAR/ALL/;
SOLVE HOZZAR USING LP MINIMIZING Z;
DISPLAY X.L, Z.L;

--
You received this message because you are subscribed to the Google Groups "gamsworld" group.
To unsubscribe from this group and stop receiving emails from it, send an email to gamsworld+...@googlegroups.com.
To post to this group, send email to gams...@googlegroups.com.
Visit this group at http://groups.google.com/group/gamsworld?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Message has been deleted

Mohamad Dehghani

unread,
Apr 29, 2013, 11:00:45 PM4/29/13
to gams...@googlegroups.com
im not sure either but maybe if u introduce a binary variable and gives the data for ('A','a1')=0 and for the rest equal to 1 it works :

binary variable 
S(i,j) ;

S('A','a1')=0 ;

equation..
sum((i,j),s(i,j)=e=15 ;   (so the rest be equal to 1)

the multiply s(i,j) to x(i,j) in obj function.


hope it helps




On Apr 30, 2013, at 3:56 AM, Mátyás Lember <lember...@gmail.com> wrote:

Dear Mohamad!

Thanksfor your answer, but unfortunately i get errors. (domain violation for element)
Put to the equations like this:

POSITIVE VARIABLES X(I,J);
EQUATIONS
OBJ
KORL1 (I)
KORL2 (J)
korl4
;
OBJ.. Z =E= SUM((I,J), T(I,J)*X(I,J));
KORL1(I).. SUM(J, X(I,J)) =E= 1;
KORL2(J).. SUM(I, X(I,J)) =E= 1;
korl4 .. x.fx('A','a1')=0 ;

MODEL HOZZAR/ALL/;

Mátyás Lember

unread,
May 3, 2013, 3:46:35 AM5/3/13
to gams...@googlegroups.com
:), but its still do the D.a1
The task is to prohibit that connection, and find another one. like a1.C and a2.D.......

(a1,a2... the workers; A,B... the cities; and "a1" worker doesn't want to go to the city "D")

I have using this program for a few weeks, and i get this task :(.
I'm unable to find the solution.

I am really grateful to all of you!


2013/5/2 Maxwell Brown <maxwell...@gmail.com>
Here ya go, Lember (see attached).

Main changes here:
OBJ.. Z =E= SUM((I,J)$FEAS(I,J), T(I,J)*X(I,J));
KORL1(I).. SUM(J$FEAS(I,J), X(I,J)) =E= 1;
KORL2(J).. SUM(I$FEAS(I,J), X(I,J)) =E= 1;


Results:

----     46 VARIABLE X.L  

             A           B           C           D

a1                                           1.000
a2                   1.000
a3                               1.000
a4       1.000


----     46 VARIABLE Z.L                   =       16.000  


On Wednesday, May 1, 2013 3:49:25 PM UTC-4, Mátyás Lember wrote:
Hi!

Unfortunately it skips the step, and the result is only 11. Counts only 3 worker - city connections, and the matrix is also looks bad.
Thank you very much guys for the trying!

----     43 VARIABLE X.L  

             A           B           C           D

a1       1.000
a2                   1.000
a3                               1.000
a4                                           1.000


----     43 VARIABLE Z.L                   =       11.000





2013. április 30., kedd 16:55:09 UTC+2 időpontban Maxwell Brown a következőt írta:
OBJ.. Z =E= SUM((I,J), T(I,J)*X(I,J));

SHOULD BE:

OBJ.. Z =E= SUM((I,J)$FEAS(I,J), T(I,J)*X(I,J));

On Monday, April 29, 2013 5:01:24 PM UTC-4, Maxwell Brown wrote:
The table bin(i,j) below should work for your purposes. If the value is '1' then it should be an allowed relationship, otherwise not. Let me know if it does what you would like:

SETS
i /a1, a2, a3, a4/
j /A, B, C, D/;

Table T(i,j) ido
   A B C D
a1 6 7 5 5
a2 7 4 8 6
a3 3 4 2 6
a4 5 7 7 5;

parameters
k/1/
l/4/;

Table bin(i,j)
   A B C D
a1 0 1 1 1
a2 1 1 1 1
a3 1 1 1 1
a4 1 1 1 1
;

SET FEAS(I,J);
FEAS(I,J)=YES$(bin(I,J)=1);

VARIABLES
X(I,J)
Z;
POSITIVE VARIABLES X(I,J);
EQUATIONS
OBJ
KORL1 (I)
KORL2 (J)

;
OBJ.. Z =E= SUM((I,J), T(I,J)*X(I,J));
KORL1(I).. SUM(J, X(I,J)) =E= 1;
KORL2(J).. SUM(I, X(I,J)) =E= 1;


MODEL HOZZAR/ALL/;
SOLVE HOZZAR USING LP MINIMIZING Z;

DISPLAY X.L, Z.L;


On Monday, April 29, 2013 3:56:18 PM UTC-4, Mátyás Lember wrote:
Dear Mohamad!

Thanksfor your answer, but unfortunately i get errors. (domain violation for element)
Put to the equations like this:

POSITIVE VARIABLES X(I,J);
EQUATIONS
OBJ
KORL1 (I)
KORL2 (J)
korl4
;
OBJ.. Z =E= SUM((I,J), T(I,J)*X(I,J));
KORL1(I).. SUM(J, X(I,J)) =E= 1;
KORL2(J).. SUM(I, X(I,J)) =E= 1;
korl4 .. x.fx('A','a1')=0 ;

MODEL HOZZAR/ALL/;


2013. április 29., hétfő 19:23:17 UTC+2 időpontban Mohamad Dehghani a következőt írta:

--
You received this message because you are subscribed to a topic in the Google Groups "gamsworld" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/gamsworld/GftgcCJCn6A/unsubscribe?hl=en.
To unsubscribe from this group and all its topics, send an email to gamsworld+...@googlegroups.com.

Mátyás Lember

unread,
May 4, 2013, 5:40:59 PM5/4/13
to gams...@googlegroups.com
Ooh, sorry, i was too tired maybe to recognize the change in the matrix :)
This works perfectly!

Thank you for your help, hope i can return the favor!



2013/5/3 Maxwell Brown <maxwell...@gmail.com>
Any relationship defined in the table BIN(I,J) is either allowed [1] or forbidden [0]. It is up to the user to set feasible correlations - I put in one zero @ [a1, A] as an example but  you can put in as many or as few as you would like.

--

You are very welcome, happy to help.

Best,
Max
Reply all
Reply to author
Forward
0 new messages