[AMPL 16106] AMPL and logical constraints

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

[AMPL 16106] AMPL and logical constraints

Danish
Hi,
I am trying to run a logical constraints example from the AMPL web site. https://ampl.com/resources/logic-and-constraint-programming-extensions/
However, I am getting following error: using ilogcp

ilogcp 12.7.1: Error: CP Optimizer doesn't support continuous variables

Here is the complete example.

set ORIG;   # origins
set DEST;   # destinations
set PROD;   # products


param supply 
{ORIG,PROD} >= 0;  # amounts available at origins
param demand 
{DEST,PROD} >= 0;  # amounts required at destinations


   check 
{in PROD}:
      sum 
{in ORIG} supply[i,p] = sum {in DEST} demand[j,p];


param limit 
{ORIG,DEST} >= 0;   # maximum shipments on routes
param minload 
>= 0;             # minimum nonzero shipment
param maxserve integer 
> 0;     # maximum destinations served


param vcost 
{ORIG,DEST,PROD} >= 0; # variable shipment cost on routes
var Trans {ORIG,DEST,PROD} >= 0;   # units to be shipped


param fcost 
{ORIG,DEST} >= 0;      # fixed cost for using a route
var Use {ORIG,DEST} binary;        # = 1 only for routes used


minimize 
Total_Cost:
   sum 
{in ORIG, j in DEST, p in PROD} vcost[i,j,p] * Trans[i,j,p]
 
+ sum {in ORIG, j in DEST} fcost[i,j] * Use[i,j];


subject to 
Supply {in ORIG, p in PROD}:
   sum 
{in DEST} Trans[i,j,p] = supply[i,p];


subject to 
Max_Serve {in ORIG}:
   sum 
{in DEST} Use[i,j] <= maxserve;


subject to 
Demand {in DEST, p in PROD}:
   sum 
{in ORIG} Trans[i,j,p] = demand[j,p];


subject to Multi_Min_Ship {in ORIG, in DEST}:
   sum 
{in PROD} Trans[i,j,p] = 0 or
   minload 
<= sum {in PROD} Trans[i,j,p] <= limit[i,j];

   

   data;


set ORIG := GARY CLEV PITT ;
set DEST := FRA DET LAN WIN STL FRE LAF ;
set PROD := bands coils plate ;


param supply 
(tr):  GARY   CLEV   PITT :=
            bands    
400    700    800
            coils    
800   1600   1800
            plate    
200    300    300 ;


param demand 
(tr):
               FRA  DET  LAN  WIN  STL  FRE  LAF 
:=
       bands   
300  300  100   75  650  225  250
       coils   
500  750  400  250  950  850  500
       plate   
100  100    0   50  200  100  250 ;


param limit 
default 625 ;


param vcost 
:=


 
[*,*,bands]:  FRA  DET  LAN  WIN  STL  FRE  LAF :=
        GARY    
30   10    8   10   11   71    6
        CLEV    
22    7   10    7   21   82   13
        PITT    
19   11   12   10   25   83   15


 
[*,*,coils]:  FRA  DET  LAN  WIN  STL  FRE  LAF :=
        GARY    
39   14   11   14   16   82    8
        CLEV    
27    9   12    9   26   95   17
        PITT    
24   14   17   13   28   99   20


 
[*,*,plate]:  FRA  DET  LAN  WIN  STL  FRE  LAF :=
        GARY    
41   15   12   16   17   86    8
        CLEV    
29    9   13    9   28   99   18
        PITT    
26   14   17   13   31  104   20 ;


param fcost
:   FRA  DET  LAN  WIN  STL  FRE  LAF :=
        GARY  
3000 1200 1200 1200 2500 3500 2500
        CLEV  
2000 1000 1500 1200 2500 3000 2200
        PITT  
2000 1200 1500 1500 2500 3500 2200 ;


param minload 
:= 375 ;


param maxserve 
:= 5 ;



What could be the issue? I have done no modifications to the code or data.

Can someone please help me identify the problem.
Thanks in advance

--
You received this message because you are subscribed to the Google Groups "AMPL Modeling Language" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/ampl.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: [AMPL 16108] AMPL and logical constraints

AMPL mailing list
You should set cplex optimizer for ilogcp using following options:

option ilogcp_options 'optimizer=cplex';

--
Paras Tiwari
[hidden email]
{#HS:556233979-4651#}
On Fri, Apr 6, 2018 at 7:04 PM UTC, <[hidden email]> wrote:
Hi,
I am trying to run a logical constraints example from the AMPL web site. https://ampl.com/resources/logic-and-constraint-programming-extensions/
However, I am getting following error: using ilogcp

ilogcp 12.7.1: Error: CP Optimizer doesn't support continuous variables

Here is the complete example.

set ORIG; # origins
set DEST; # destinations
set PROD; # products


param supply
{ORIG,PROD} >= 0; # amounts available at origins
param demand
{DEST,PROD} >= 0; # amounts required at destinations


check
{p in PROD}:
sum
{i in ORIG} supply[i,p] = sum {j in DEST} demand[j,p];


param limit
{ORIG,DEST} >= 0; # maximum shipments on routes
param minload
>= 0; # minimum nonzero shipment
param maxserve integer
> 0; # maximum destinations served


param vcost
{ORIG,DEST,PROD} >= 0; # variable shipment cost on routes
var Trans {ORIG,DEST,PROD} >= 0; # units to be shipped


param fcost
{ORIG,DEST} >= 0; # fixed cost for using a route
var Use {ORIG,DEST} binary; # = 1 only for routes used


minimize
Total_Cost:
sum
{i in ORIG, j in DEST, p in PROD} vcost[i,j,p] * Trans[i,j,p]
+ sum {i in ORIG, j in DEST} fcost[i,j] * Use[i,j];


subject to
Supply {i in ORIG, p in PROD}:
sum
{j in DEST} Trans[i,j,p] = supply[i,p];


subject to
Max_Serve {i in ORIG}:
sum
{j in DEST} Use[i,j] <= maxserve;


subject to
Demand {j in DEST, p in PROD}:
sum
{i in ORIG} Trans[i,j,p] = demand[j,p];


subject to Multi_Min_Ship {i in ORIG, j in DEST}:
sum
{p in PROD} Trans[i,j,p] = 0 or
minload
<= sum {p in PROD} Trans[i,j,p] <= limit[i,j];


data;


set ORIG := GARY CLEV PITT ;
set DEST := FRA DET LAN WIN STL FRE LAF ;
set PROD := bands coils plate ;


param supply
(tr): GARY CLEV PITT :=
bands
400 700 800
coils
800 1600 1800
plate
200 300 300 ;


param demand
(tr):
FRA DET LAN WIN STL FRE LAF
:=
bands
300 300 100 75 650 225250
coils
500 750 400 250 950 850500
plate
100 100 0 50 200 100 250 ;


param limit
default 625 ;


param vcost
:=


[*,*,bands]: FRA DET LAN WIN STL FRE LAF :=
GARY
30 10 8 10 11 71 6
CLEV
22 7 10 7 21 82 13
PITT
19 11 12 10 25 83 15


[*,*,coils]: FRA DET LAN WIN STL FRE LAF :=
GARY
39 14 11 14 16 82 8
CLEV
27 9 12 9 26 95 17
PITT
24 14 17 13 28 99 20


[*,*,plate]: FRA DET LAN WIN STL FRE LAF :=
GARY
41 15 12 16 17 86 8
CLEV
29 9 13 9 28 99 18
PITT
26 14 17 13 31 104 20 ;


param fcost
: FRA DET LAN WIN STL FRE LAF :=
GARY
3000 1200 1200 1200 2500 35002500
CLEV
2000 1000 1500 1200 2500 30002200
PITT
2000 1200 1500 1500 2500 35002200 ;


param minload
:= 375 ;


param maxserve
:= 5 ;



What could be the issue? I have done no modifications to the code or data.

Can someone please help me identify the problem.
Thanks in advance
--
You received this message because you are subscribed to the Google Groups "AMPL Modeling Language" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/ampl.
For more options, visit https://groups.google.com/d/optout.



--
You received this message because you are subscribed to the Google Groups "AMPL Modeling Language" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/ampl.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: [AMPL 16111] AMPL and logical constraints

Danish
Thank you very much that solved the issue.
Here is the complete command for anyone who might need it in future:

 model model.mod; data data.dat;option ilogcp_options 'optimizer=cplex'; option solver ilogcp;

On Friday, 6 April 2018 20:57:37 UTC-4, AMPL Google Group wrote:
You should set cplex optimizer for ilogcp using following options:

option ilogcp_options 'optimizer=cplex';

--
Paras Tiwari
<a href="javascript:" target="_blank" gdf-obfuscated-mailto="azdEqbR1BgAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">am...@...
{#HS:556233979-4651#}
On Fri, Apr 6, 2018 at 7:04 PM UTC, <<a href="javascript:" target="_blank" gdf-obfuscated-mailto="azdEqbR1BgAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">am...@...> wrote:
Hi,
I am trying to run a logical constraints example from the AMPL web site. <a href="https://ampl.com/resources/logic-and-constraint-programming-extensions/" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fampl.com%2Fresources%2Flogic-and-constraint-programming-extensions%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGGWWUZ53UvzX-cpll3a0CR2kYmXA&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fampl.com%2Fresources%2Flogic-and-constraint-programming-extensions%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGGWWUZ53UvzX-cpll3a0CR2kYmXA&#39;;return true;">https://ampl.com/resources/logic-and-constraint-programming-extensions/
However, I am getting following error: using ilogcp

ilogcp 12.7.1: Error: CP Optimizer doesn't support continuous variables

Here is the complete example.

set ORIG; # origins
set DEST; # destinations
set PROD; # products


param supply
{ORIG,PROD} >= 0; # amounts available at origins
param demand
{DEST,PROD} >= 0; # amounts required at destinations


check
{p in PROD}:
sum
{i in ORIG} supply[i,p] = sum {j in DEST} demand[j,p];


param limit
{ORIG,DEST} >= 0; # maximum shipments on routes
param minload
>= 0; # minimum nonzero shipment
param maxserve integer
> 0; # maximum destinations served


param vcost
{ORIG,DEST,PROD} >= 0; # variable shipment cost on routes
var Trans {ORIG,DEST,PROD} >= 0; # units to be shipped


param fcost
{ORIG,DEST} >= 0; # fixed cost for using a route
var Use {ORIG,DEST} binary; # = 1 only for routes used


minimize
Total_Cost:
sum
{i in ORIG, j in DEST, p in PROD} vcost[i,j,p] * Trans[i,j,p]
+ sum {i in ORIG, j in DEST} fcost[i,j] * Use[i,j];


subject to
Supply {i in ORIG, p in PROD}:
sum
{j in DEST} Trans[i,j,p] = supply[i,p];


subject to
Max_Serve {i in ORIG}:
sum
{j in DEST} Use[i,j] <= maxserve;


subject to
Demand {j in DEST, p in PROD}:
sum
{i in ORIG} Trans[i,j,p] = demand[j,p];


subject to Multi_Min_Ship {i in ORIG, j in DEST}:
sum
{p in PROD} Trans[i,j,p] = 0 or
minload
<= sum {p in PROD} Trans[i,j,p] <= limit[i,j];


data;


set ORIG := GARY CLEV PITT ;
set DEST := FRA DET LAN WIN STL FRE LAF ;
set PROD := bands coils plate ;


param supply
(tr): GARY CLEV PITT :=
bands
400 700 800
coils
800 1600 1800
plate
200 300 300 ;


param demand
(tr):
FRA DET LAN WIN STL FRE LAF
:=
bands
300 300 100 75 650 225250
coils
500 750 400 250 950 850500
plate
100 100 0 50 200 100 250 ;


param limit
default 625 ;


param vcost
:=


[*,*,bands]: FRA DET LAN WIN STL FRE LAF :=
GARY
30 10 8 10 11 71 6
CLEV
22 7 10 7 21 82 13
PITT
19 11 12 10 25 83 15


[*,*,coils]: FRA DET LAN WIN STL FRE LAF :=
GARY
39 14 11 14 16 82 8
CLEV
27 9 12 9 26 95 17
PITT
24 14 17 13 28 99 20


[*,*,plate]: FRA DET LAN WIN STL FRE LAF :=
GARY
41 15 12 16 17 86 8
CLEV
29 9 13 9 28 99 18
PITT
26 14 17 13 31 104 20 ;


param fcost
: FRA DET LAN WIN STL FRE LAF :=
GARY
3000 1200 1200 1200 2500 35002500
CLEV
2000 1000 1500 1200 2500 30002200
PITT
2000 1200 1500 1500 2500 35002200 ;


param minload
:= 375 ;


param maxserve
:= 5 ;



What could be the issue? I have done no modifications to the code or data.

Can someone please help me identify the problem.
Thanks in advance
--
You received this message because you are subscribed to the Google Groups "AMPL Modeling Language" group.
To unsubscribe from this group and stop receiving emails from it, send an email to <a href="javascript:" target="_blank" gdf-obfuscated-mailto="azdEqbR1BgAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">ampl+uns...@googlegroups.com.
To post to this group, send email to <a href="javascript:" target="_blank" gdf-obfuscated-mailto="azdEqbR1BgAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">am...@....
Visit this group at <a href="https://groups.google.com/group/ampl" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://groups.google.com/group/ampl&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/group/ampl&#39;;return true;">https://groups.google.com/group/ampl.
For more options, visit <a href="https://groups.google.com/d/optout" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;">https://groups.google.com/d/optout.



--
You received this message because you are subscribed to the Google Groups "AMPL Modeling Language" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/ampl.
For more options, visit https://groups.google.com/d/optout.