Transportation problem with extra restrictions (provinces of origin of transported goods)

Dear all,

I am trying to solve a transportation problem, in which farmers of a country allocate their grain harvest to some ports for exportation. There
is no problem in optimizing this, except when I introduce some special restrictions.

These restrictions are related with me knowing (for some ports only) the province of origin of the grain they purchase.

Probably it is easier to understand this with the following example:


SETS

farm producers / 1,2,3,4,5,6

/
port demand / 7,8,9,10
/

;

PARAMETERS

yields(farm) production farm in cases
/

1 330
2 540
3 2160
4 1620
5 500
6 250
/

export(port) exportation port in cases
/
7 2000
8 1800
9 1400
10 200
/

;

table d(farm,port) ‘distance of routes’

7 8 9 10
1 2.1 7.0 3.0 3.2
2 0.5 1.1 1.4 1.5
3 1.5 1.7 2.8 0.3
4 3.5 1.3 3.4 0.5
5 2.0 1.0 7.8 5.2
6 2.5 2.8 0.4 3.2
;

VARIABLES

x(farm,port) traded quantities
cost transportation costs
;

positive variable x
;



EQUATIONS

total define objective function
supply(farm) observe supply limit at farm
demand(port) satisfy demand at port
;

total … cost =e= sum((farm,port), d(farm,port) * x(farm,port))
;

supply(farm) … sum(port, x(farm,port)) =l= yields(farm) ;
demand(port) … sum(farm, x(farm,port)) =e= export(port) ;

MODEL transport /all/ ;
SOLVE transport USING lp MINIMIZING cost ;
DISPLAY x.l, x.m


This simple transportation problem (minimize cost) has the following
solution

Optimal solution found.
Objective : 7992.000000

61 VARIABLE x.L traded quantities


7 8 9 10

1 330
2 540
3 2000 160
4 1300 120 200
5 500
6 250

However I am not capable of including some special restrictions that come up from the fact that I know the province of origin of the grain arriving
at some ports.

For example I know the amount that some ports purchase per province:

“Province in which the farms are situated”

farm, province

1 A
2 B
3 A
4 A
5 B
6 A

“Province of origin of purchased goods at port”


port, province, Tn

7 A 1800
7 B 200
8 A 1600
8 B 200

(For 9 and 10 I know nothing on grains´ origin)

I thought it would be trivial, but I don´t see how to write these restrictions, the format of an eventual matrix of restrictions etc…I would very much appreciate your help or guidance on how to proceed.

Thanks!

Javier Godar


To unsubscribe from this group and stop receiving emails from it, send an email to gamsworld+unsubscribe@googlegroups.com.
To post to this group, send email to gamsworld@googlegroups.com.
Visit this group at http://groups.google.com/group/gamsworld.
For more options, visit https://groups.google.com/groups/opt_out.

Hi Javier, you never explicitly mentioned what kind of restrictions
you want to apply. If you would give an example I’m sure it’s
something that can be easily written.

Regards!
Claudio



On Mon, Feb 17, 2014 at 1:06 PM, Javier Godar wrote:

Dear all,

I am trying to solve a transportation problem, in which farmers of a country
allocate their grain harvest to some ports for exportation. There
is no problem in optimizing this, except when I introduce some special
restrictions.

These restrictions are related with me knowing (for some ports only) the
province of origin of the grain they purchase.

Probably it is easier to understand this with the following example:


SETS

farm producers / 1,2,3,4,5,6

/
port demand / 7,8,9,10
/

;

PARAMETERS

yields(farm) production farm in cases
/

1  330
2  540
3  2160
4  1620
5  500
6  250

/

export(port) exportation port in cases
/
7 2000
8 1800
9 1400
10 200
/

;

table d(farm,port) ‘distance of routes’

           7             8            9            10
  1        2.1           7.0          3.0          3.2
  2        0.5           1.1          1.4          1.5
  3        1.5           1.7          2.8          0.3
  4        3.5           1.3          3.4          0.5
  5        2.0           1.0          7.8          5.2
  6        2.5           2.8          0.4          3.2

;

VARIABLES

x(farm,port)  traded quantities
cost          transportation costs
;

positive variable x
;

EQUATIONS

total          define objective function
supply(farm)   observe supply limit at farm
demand(port)   satisfy demand at port
;

total ..        cost  =e=  sum((farm,port), d(farm,port) * x(farm,port))
;

supply(farm) .. sum(port, x(farm,port))  =l=  yields(farm) ;
demand(port) .. sum(farm, x(farm,port))  =e=  export(port) ;

MODEL transport /all/ ;
SOLVE transport USING lp MINIMIZING cost ;
DISPLAY x.l, x.m


This simple transportation problem (minimize cost) has the following
solution

Optimal solution found.
Objective : 7992.000000

61 VARIABLE x.L traded quantities

       7           8           9          10

1 330
2 540
3 2000 160
4 1300 120 200
5 500
6 250

However I am not capable of including some special restrictions that come up
from the fact that I know the province of origin of the grain arriving
at some ports.

For example I know the amount that some ports purchase per province:

“Province in which the farms are situated”

farm, province

1 A
2 B
3 A
4 A
5 B
6 A

“Province of origin of purchased goods at port”

port, province, Tn

7 A 1800
7 B 200
8 A 1600
8 B 200

(For 9 and 10 I know nothing on grains´ origin)

I thought it would be trivial, but I don´t see how to write these
restrictions, the format of an eventual matrix of restrictions etc…I
would very much appreciate your help or guidance on how to proceed.

Thanks!

Javier Godar


“gamsworld” group.
To unsubscribe from this group and stop receiving emails from it, send an
email to gamsworld+unsubscribe@googlegroups.com.
To post to this group, send email to gamsworld@googlegroups.com.
Visit this group at http://groups.google.com/group/gamsworld.
For more options, visit https://groups.google.com/groups/opt_out.

\

Hi Claudio,sorry for the lack of clarity. The restriction refers to the last part of the message:

“Province in which the farms are situated”

farm, province

1 A
2 B
3 A
4 A
5 B
6 A

“Province of origin of purchased goods at port”

port, province, Tn

7 A 1800
7 B 200
8 A 1600
8 B 200

In other words, certain ports source their trade goods from farmers belonging to specific provinces (not just from farmers with the minimum transportation costs). For example port 7 must purchase 1800 Tn coming from farmers of province A and 200 Tn from farmers of province B. Thus the LP must minimize transportation costs in the allocation but subjected to those conditions.

Please let me know if I am still not clear, thanks a lot for your help.

Best

Javier Godar

Research Fellow

Stockholm Environment Institute






On Monday, February 17, 2014 7:33:43 PM UTC+1, Claudio Delpino wrote:

Hi Javier, you never explicitly mentioned what kind of restrictions
you want to apply. If you would give an example I’m sure it’s
something that can be easily written.

Regards!
Claudio



On Mon, Feb 17, 2014 at 1:06 PM, Javier Godar wrote:

Dear all,

I am trying to solve a transportation problem, in which farmers of a country
allocate their grain harvest to some ports for exportation. There
is no problem in optimizing this, except when I introduce some special
restrictions.

These restrictions are related with me knowing (for some ports only) the
province of origin of the grain they purchase.

Probably it is easier to understand this with the following example:


SETS

farm producers / 1,2,3,4,5,6

/
port demand / 7,8,9,10
/

;

PARAMETERS

yields(farm) production farm in cases
/

1  330
2  540
3  2160
4  1620
5  500
6  250

/

export(port) exportation port in cases
/
7 2000
8 1800
9 1400
10 200
/

;

table d(farm,port) ‘distance of routes’

           7             8            9            10
  1        2.1           7.0          3.0          3.2
  2        0.5           1.1          1.4          1.5
  3        1.5           1.7          2.8          0.3
  4        3.5           1.3          3.4          0.5
  5        2.0           1.0          7.8          5.2
  6        2.5           2.8          0.4          3.2

;

VARIABLES

x(farm,port)  traded quantities
cost          transportation costs
;

positive variable x
;

EQUATIONS

total          define objective function
supply(farm)   observe supply limit at farm
demand(port)   satisfy demand at port
;

total ..        cost  =e=  sum((farm,port), d(farm,port) * x(farm,port))
;

supply(farm) .. sum(port, x(farm,port))  =l=  yields(farm) ;
demand(port) .. sum(farm, x(farm,port))  =e=  export(port) ;

MODEL transport /all/ ;
SOLVE transport USING lp MINIMIZING cost ;
DISPLAY x.l, x.m


This simple transportation problem (minimize cost) has the following
solution

Optimal solution found.
Objective : 7992.000000

61 VARIABLE x.L traded quantities

       7           8           9          10

1 330
2 540
3 2000 160
4 1300 120 200
5 500
6 250

However I am not capable of including some special restrictions that come up
from the fact that I know the province of origin of the grain arriving
at some ports.

For example I know the amount that some ports purchase per province:

“Province in which the farms are situated”

farm, province

1 A
2 B
3 A
4 A
5 B
6 A

“Province of origin of purchased goods at port”

port, province, Tn

7 A 1800
7 B 200
8 A 1600
8 B 200

(For 9 and 10 I know nothing on grains´ origin)

I thought it would be trivial, but I don´t see how to write these
restrictions, the format of an eventual matrix of restrictions etc…I
would very much appreciate your help or guidance on how to proceed.

Thanks!

Javier Godar


“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.
For more options, visit https://groups.google.com/groups/opt_out.


To unsubscribe from this group and stop receiving emails from it, send an email to gamsworld+unsubscribe@googlegroups.com.
To post to this group, send email to gamsworld@googlegroups.com.
Visit this group at http://groups.google.com/group/gamsworld.
For more options, visit https://groups.google.com/groups/opt_out.

Javier:

A way I figure (changes province to numerical code for parameter
usage) (see attached model :slight_smile:):

New Sets:

provinces / A, B/

New Parameters:

province_of_farm(farm) /1 A,
2 B
3 A
4 A
5 B
6 A/

minimum(provinces,port) /

New Equations:

provinces_check_eq(provinces,port)

provinces_check_eq(provinces,port)…
sum(farm$(sameas(province_of_farm(farm),provinces)),x(farm,port))=g=minimum(provinces,port)

Hope this helps !
Regards
Claudio




On Tue, Feb 18, 2014 at 5:13 AM, Javier Godar wrote:

Hi Claudio,sorry for the lack of clarity. The restriction refers to the last
part of the message:

“Province in which the farms are situated”

farm, province

1 A
2 B
3 A
4 A
5 B
6 A

“Province of origin of purchased goods at port”

port, province, Tn

7 A 1800
7 B 200
8 A 1600
8 B 200

In other words, certain ports source their trade goods from farmers
belonging to specific provinces (not just from farmers with the minimum
transportation costs). For example port 7 must purchase 1800 Tn coming from
farmers of province A and 200 Tn from farmers of province B. Thus the LP
must minimize transportation costs in the allocation but subjected to those
conditions.

Please let me know if I am still not clear, thanks a lot for your help.

Best

Javier Godar

Research Fellow

Stockholm Environment Institute

On Monday, February 17, 2014 7:33:43 PM UTC+1, Claudio Delpino wrote:

Hi Javier, you never explicitly mentioned what kind of restrictions
you want to apply. If you would give an example I’m sure it’s
something that can be easily written.

Regards!
Claudio

On Mon, Feb 17, 2014 at 1:06 PM, Javier Godar wrote:

Dear all,

I am trying to solve a transportation problem, in which farmers of a
country
allocate their grain harvest to some ports for exportation. There
is no problem in optimizing this, except when I introduce some special
restrictions.

These restrictions are related with me knowing (for some ports only)
the
province of origin of the grain they purchase.

Probably it is easier to understand this with the following example:


SETS

farm producers / 1,2,3,4,5,6

/
port demand / 7,8,9,10
/

;

PARAMETERS

yields(farm) production farm in cases
/

1  330
2  540
3  2160
4  1620
5  500
6  250

/

export(port) exportation port in cases
/
7 2000
8 1800
9 1400
10 200
/

;

table d(farm,port) ‘distance of routes’

           7             8            9            10
  1        2.1           7.0          3.0          3.2
  2        0.5           1.1          1.4          1.5
  3        1.5           1.7          2.8          0.3
  4        3.5           1.3          3.4          0.5
  5        2.0           1.0          7.8          5.2
  6        2.5           2.8          0.4          3.2

;

VARIABLES

x(farm,port)  traded quantities
cost          transportation costs
;

positive variable x
;

EQUATIONS

total          define objective function
supply(farm)   observe supply limit at farm
demand(port)   satisfy demand at port
;

total ..        cost  =e=  sum((farm,port), d(farm,port) *

x(farm,port))
;

supply(farm) .. sum(port, x(farm,port))  =l=  yields(farm) ;
demand(port) .. sum(farm, x(farm,port))  =e=  export(port) ;

MODEL transport /all/ ;
SOLVE transport USING lp MINIMIZING cost ;
DISPLAY x.l, x.m


This simple transportation problem (minimize cost) has the following
solution

Optimal solution found.
Objective : 7992.000000

61 VARIABLE x.L traded quantities

       7           8           9          10

1 330
2 540
3 2000 160
4 1300 120 200
5 500
6 250

However I am not capable of including some special restrictions that
come up
from the fact that I know the province of origin of the grain arriving
at some ports.

For example I know the amount that some ports purchase per province:

“Province in which the farms are situated”

farm, province

1 A
2 B
3 A
4 A
5 B
6 A

“Province of origin of purchased goods at port”

port, province, Tn

7 A 1800
7 B 200
8 A 1600
8 B 200

(For 9 and 10 I know nothing on grains´ origin)

I thought it would be trivial, but I don´t see how to write these
restrictions, the format of an eventual matrix of restrictions etc…I
would very much appreciate your help or guidance on how to proceed.

Thanks!

Javier Godar


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.
For more options, visit https://groups.google.com/groups/opt_out.


transportation_problem_w_origin_restriction.gms (1.75 KB)

In the last email I wrongly left provinces as a letter set, and the
conditional condition will not work. See attached working file for
the correct version !

Really Sorry !
Claudio

On Tue, Feb 18, 2014 at 1:29 PM, Claudio Delpino wrote:

Javier:

A way I figure (changes province to numerical code for parameter
usage) (see attached model :slight_smile:):

New Sets:

provinces / A, B/

New Parameters:

province_of_farm(farm) /1 A,
2 B
3 A
4 A
5 B
6 A/

minimum(provinces,port) /

New Equations:

provinces_check_eq(provinces,port)

provinces_check_eq(provinces,port)…
sum(farm$(sameas(province_of_farm(farm),provinces)),x(farm,port))=g=minimum(provinces,port)

Hope this helps !
Regards
Claudio

On Tue, Feb 18, 2014 at 5:13 AM, Javier Godar wrote:

Hi Claudio,sorry for the lack of clarity. The restriction refers to the last
part of the message:

“Province in which the farms are situated”

farm, province

1 A
2 B
3 A
4 A
5 B
6 A

“Province of origin of purchased goods at port”

port, province, Tn

7 A 1800
7 B 200
8 A 1600
8 B 200

In other words, certain ports source their trade goods from farmers
belonging to specific provinces (not just from farmers with the minimum
transportation costs). For example port 7 must purchase 1800 Tn coming from
farmers of province A and 200 Tn from farmers of province B. Thus the LP
must minimize transportation costs in the allocation but subjected to those
conditions.

Please let me know if I am still not clear, thanks a lot for your help.

Best

Javier Godar

Research Fellow

Stockholm Environment Institute

On Monday, February 17, 2014 7:33:43 PM UTC+1, Claudio Delpino wrote:

Hi Javier, you never explicitly mentioned what kind of restrictions
you want to apply. If you would give an example I’m sure it’s
something that can be easily written.

Regards!
Claudio

On Mon, Feb 17, 2014 at 1:06 PM, Javier Godar wrote:

Dear all,

I am trying to solve a transportation problem, in which farmers of a
country
allocate their grain harvest to some ports for exportation. There
is no problem in optimizing this, except when I introduce some special
restrictions.

These restrictions are related with me knowing (for some ports only)
the
province of origin of the grain they purchase.

Probably it is easier to understand this with the following example:


SETS

farm producers / 1,2,3,4,5,6

/
port demand / 7,8,9,10
/

;

PARAMETERS

yields(farm) production farm in cases
/

1  330
2  540
3  2160
4  1620
5  500
6  250

/

export(port) exportation port in cases
/
7 2000
8 1800
9 1400
10 200
/

;

table d(farm,port) ‘distance of routes’

           7             8            9            10
  1        2.1           7.0          3.0          3.2
  2        0.5           1.1          1.4          1.5
  3        1.5           1.7          2.8          0.3
  4        3.5           1.3          3.4          0.5
  5        2.0           1.0          7.8          5.2
  6        2.5           2.8          0.4          3.2

;

VARIABLES

x(farm,port)  traded quantities
cost          transportation costs
;

positive variable x
;

EQUATIONS

total          define objective function
supply(farm)   observe supply limit at farm
demand(port)   satisfy demand at port
;

total ..        cost  =e=  sum((farm,port), d(farm,port) *

x(farm,port))
;

supply(farm) .. sum(port, x(farm,port))  =l=  yields(farm) ;
demand(port) .. sum(farm, x(farm,port))  =e=  export(port) ;

MODEL transport /all/ ;
SOLVE transport USING lp MINIMIZING cost ;
DISPLAY x.l, x.m


This simple transportation problem (minimize cost) has the following
solution

Optimal solution found.
Objective : 7992.000000

61 VARIABLE x.L traded quantities

       7           8           9          10

1 330
2 540
3 2000 160
4 1300 120 200
5 500
6 250

However I am not capable of including some special restrictions that
come up
from the fact that I know the province of origin of the grain arriving
at some ports.

For example I know the amount that some ports purchase per province:

“Province in which the farms are situated”

farm, province

1 A
2 B
3 A
4 A
5 B
6 A

“Province of origin of purchased goods at port”

port, province, Tn

7 A 1800
7 B 200
8 A 1600
8 B 200

(For 9 and 10 I know nothing on grains´ origin)

I thought it would be trivial, but I don´t see how to write these
restrictions, the format of an eventual matrix of restrictions etc…I
would very much appreciate your help or guidance on how to proceed.

Thanks!

Javier Godar


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.
For more options, visit https://groups.google.com/groups/opt_out.


“gamsworld” group.
To unsubscribe from this group and stop receiving emails from it, send an
email to gamsworld+unsubscribe@googlegroups.com.
To post to this group, send email to gamsworld@googlegroups.com.
Visit this group at http://groups.google.com/group/gamsworld.
For more options, visit https://groups.google.com/groups/opt_out.

\

Dear Claudio,

Thanks a lot, it is precisely what I needed to understand why I was having difficulties. Great job!

Best

Javier Godar

On Tuesday, February 18, 2014 5:29:49 PM UTC+1, Claudio Delpino wrote:

Javier:

A way I figure (changes province to numerical code for parameter
usage) (see attached model :slight_smile:):

New Sets:

provinces / A, B/

New Parameters:

province_of_farm(farm) /1 A,
2 B
3 A
4 A
5 B
6 A/

minimum(provinces,port) /

New Equations:

provinces_check_eq(provinces,port)

provinces_check_eq(provinces,port)…
sum(farm$(sameas(province_of_farm(farm),provinces)),x(farm,port))=g=minimum(provinces,port)

Hope this helps !
Regards
Claudio




On Tue, Feb 18, 2014 at 5:13 AM, Javier Godar wrote:

Hi Claudio,sorry for the lack of clarity. The restriction refers to the last
part of the message:

“Province in which the farms are situated”

farm, province

1 A
2 B
3 A
4 A
5 B
6 A

“Province of origin of purchased goods at port”

port, province, Tn

7 A 1800
7 B 200
8 A 1600
8 B 200

In other words, certain ports source their trade goods from farmers
belonging to specific provinces (not just from farmers with the minimum
transportation costs). For example port 7 must purchase 1800 Tn coming from
farmers of province A and 200 Tn from farmers of province B. Thus the LP
must minimize transportation costs in the allocation but subjected to those
conditions.

Please let me know if I am still not clear, thanks a lot for your help.

Best

Javier Godar

Research Fellow

Stockholm Environment Institute

On Monday, February 17, 2014 7:33:43 PM UTC+1, Claudio Delpino wrote:

Hi Javier, you never explicitly mentioned what kind of restrictions
you want to apply. If you would give an example I’m sure it’s
something that can be easily written.

Regards!
Claudio

On Mon, Feb 17, 2014 at 1:06 PM, Javier Godar wrote:

Dear all,

I am trying to solve a transportation problem, in which farmers of a
country
allocate their grain harvest to some ports for exportation. There
is no problem in optimizing this, except when I introduce some special
restrictions.

These restrictions are related with me knowing (for some ports only)
the
province of origin of the grain they purchase.

Probably it is easier to understand this with the following example:


SETS

farm producers / 1,2,3,4,5,6

/
port demand / 7,8,9,10
/

;

PARAMETERS

yields(farm) production farm in cases
/

1  330
2  540
3  2160
4  1620
5  500
6  250

/

export(port) exportation port in cases
/
7 2000
8 1800
9 1400
10 200
/

;

table d(farm,port) ‘distance of routes’

           7             8            9            10
  1        2.1           7.0          3.0          3.2
  2        0.5           1.1          1.4          1.5
  3        1.5           1.7          2.8          0.3
  4        3.5           1.3          3.4          0.5
  5        2.0           1.0          7.8          5.2
  6        2.5           2.8          0.4          3.2

;

VARIABLES

x(farm,port)  traded quantities
cost          transportation costs
;

positive variable x
;

EQUATIONS

total          define objective function
supply(farm)   observe supply limit at farm
demand(port)   satisfy demand at port
;

total ..        cost  =e=  sum((farm,port), d(farm,port) *

x(farm,port))
;

supply(farm) .. sum(port, x(farm,port))  =l=  yields(farm) ;
demand(port) .. sum(farm, x(farm,port))  =e=  export(port) ;

MODEL transport /all/ ;
SOLVE transport USING lp MINIMIZING cost ;
DISPLAY x.l, x.m


This simple transportation problem (minimize cost) has the following
solution

Optimal solution found.
Objective : 7992.000000

61 VARIABLE x.L traded quantities

       7           8           9          10

1 330
2 540
3 2000 160
4 1300 120 200
5 500
6 250

However I am not capable of including some special restrictions that
come up
from the fact that I know the province of origin of the grain arriving
at some ports.

For example I know the amount that some ports purchase per province:

“Province in which the farms are situated”

farm, province

1 A
2 B
3 A
4 A
5 B
6 A

“Province of origin of purchased goods at port”

port, province, Tn

7 A 1800
7 B 200
8 A 1600
8 B 200

(For 9 and 10 I know nothing on grains´ origin)

I thought it would be trivial, but I don´t see how to write these
restrictions, the format of an eventual matrix of restrictions etc…I
would very much appreciate your help or guidance on how to proceed.

Thanks!

Javier Godar


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.
For more options, visit https://groups.google.com/groups/opt_out.


“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.
For more options, visit https://groups.google.com/groups/opt_out.


To unsubscribe from this group and stop receiving emails from it, send an email to gamsworld+unsubscribe@googlegroups.com.
To post to this group, send email to gamsworld@googlegroups.com.
Visit this group at http://groups.google.com/group/gamsworld.
For more options, visit https://groups.google.com/groups/opt_out.