ampl: include "C:\files\inti.run";
C:\files\inti.run, line 19 (offset 431):
left-hand side has dimen 1 but
right-hand side has dimen 2
context: ((i,j) in E and (x[i,j,m] + y[i,j,m]) = 1 or (j,i) in E and ( x[j,i,m] + y[j,i,m]) = >>> 1)}; <<<
****************************************************************************************************************************
I have attached the model files - formulation.mod ( where sub tour constraints are computed) and new.mod, new.run ( where constraints are generated). The data file is 2.dat.
I use the following subtour constraint:
subject to Cutsubtours {m in trip, k in S: card(POW[k]) >= 2 and card(POW[k]) <= N/2}:
sum {(i,j) in E: (i in POW[k]) and (j not in POW[k])} (x[i,j,m] + y[i,j,m])
+ sum {(j,i) in E: (i not in POW[k]) and (j in POW[k])} (x[i,j,m] + y[i,j,m] )>= 2];
This constraint is giving me the desired result and I would like to use the same for the sub tour constraint generation.
It would be of great help if you can suggest me where I am doing wrong in my current formulation ( in script file or mod file) and also explain me the following in the TSP.run file you have send me earlier ?
**********************************************************************************************************************************
let NEWSUB := {};
let EXTEND := {member(ceil(Uniform(0,card(NODES))),NODES)};
repeat {
let NEWSUB := NEWSUB union EXTEND;
let EXTEND := {j in NODES diff NEWSUB: exists {i in NEWSUB}
((i,j) in PAIRS and X[i,j] = 1 or (j,i) in PAIRS and X[j,i] = 1)};
} until card(EXTEND) = 0;
************************************************************************************************************************************
I look forward to hearing from you.
Thanks,
Atri
The problem here is that EXTEND is defined as a one-dimensional set, but you are using the "let" command to assign a two-dimensional set to it. Specifically if EXTEND is initialized as a set of vertices, then you can't write
let EXTEND := {m in trip, j in V diff NEWSUB: ...
which makes EXTEND into a set of (m,j) pairs where m is a trip and j a vertex.
Bob Fourer
From: am...@googlegroups.com [mailto:am...@googlegroups.com]
On Behalf Of Atri Mahapatra
Sent: Thursday, August 1, 2013 6:10 PM
To: Robert Fourer; am...@googlegroups.com
Subject: [AMPL 7315] need some clarification in ampl error
--
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 ampl+uns...@googlegroups.com.
To post to this group, send email to am...@googlegroups.com.
Visit this group at https://groups.google.com/group/ampl.
For more options, visit https://groups.google.com/d/optout.
Hi again Paras,
I am thinking that my subtour constraint in the model file should contain something like.
"the subtour constraint ... >=2 * StationVisited[p, v, t];"
In order for the constraint to only bind on the stations used by the vehicles in a given time period. However, I am still unable to get the dynamic subtour elimination to work.
Best,
Kristian
tirsdag den 9. oktober 2018 kl. 03.50.30 UTC+2 skrev AMPL Google Group:
On Tue, Oct 9, 2018 at 2:47 AM UTC, Ampl Modeling Language <am...@googlegroups.com> wrote:This:
let EXTEND := {j in P diff NEWSUB, v in 1..V, t in 1..T: exists {p in NEWSUB}
gives me same error message as Atri in the first post of this thread:
left-hand side has dimen 1 but
right-hand side has dimen 3
I can only get it to run with this input:
let EXTEND := {j in P diff NEWSUB: exists {p in NEWSUB, v in 1..V, t in 1..T}
But this still creates subtours.
My binary variable 'H' first two dimensions represents the tour from station p to station j. The last two are which vehicle v in which time period t, as my model is quite similar to a Periodic Vehicle Routing Problem. I see from your explanation, that this constraint formulation might be problematic for my model, as I dont necessarily want my vehicles to visit every station in every time period, which they are forced to do if I understand it correctly.
I would love to hear your inputs on an alternativ formulation or other thoughts.
Thanks,
Kristian
tirsdag den 9. oktober 2018 kl. 03.50.30 UTC+2 skrev AMPL Google Group:
On Tue, Oct 9, 2018 at 1:50 AM UTC, AMPL Google Group <am...@googlegroups.com> wrote:
Rewrite your statement as follows:
let EXTEND := {j in P diff NEWSUB, v in 1..V, t in 1..T: exists {p in NEWSUB}
((p,j) in E and H[p,j,v,t] = 1 or (j,p) in E and H[j,p,v,t] = 1)};
So, move v and t index before colon. Let me know if this removes subtour.
Your problem seems different than the other problems discussed in subtour elimination. As mentioned at http://www.math.uwaterloo.ca/tsp/methods/opt/subtour.htm, the subtour constraint ... >=2 indicates that for each city i we must select two of the roads that start or end at i (since we need to arrive at city i and then leave again). You have a binary variable 'H' of four dimension, so I don't think you have formulated your problem as a graph problem. If the above change doesn't remove subtour, please let us know. I need to look into how can we extend the subtour elimination of the graph problem to something like your problem.
Thanks,
Paras
--
Dr. Paras Tiwari
am...@googlegroups.com
Hi Bob,
I tried to formulate the subtour constraints like this:
param nSubtours >= 0 integer;
set SUB {1..nSubtours} within P;
subject to Subtour_Elimination {k in 1..nSubtours, m in SUB[k], v in 1..V, t in 1..T, f in 1..F}:
sum {p in SUB[k], j in P diff SUB[k]}
if (p,j) in PAIRS then H[p,j,v,t] else H[j,p,v,t] >=2 * StationUsed[m,f,v,t]; #f is indexing different commodities
This way I think I am formulating the subtour elimination constraint for every vehicle and time-period. Does this make sense to you?
Thanks,
Kristian
torsdag den 11. oktober 2018 kl. 05.07.01 UTC+2 skrev AMPL Google Group:
On Thu, Oct 11, 2018 at 3:06 AM UTC, AMPL Google Group <am...@googlegroups.com> wrote:
It appears that you need to focus first on defining the subtour elimination constraints correctly. In your formulations it appears that you have one subtour elimination constraint for every subset of the stations. But each vehicle may separately have subtours in the solution, so you may need to have subtour elimination constraints for each combination of a vehicle and a subset of stations. The presence of time periods in your application will further complicate the formulation; to get the correct formulation of your subtour elimination constraints, you will need to closely study the particular variant of the vehicle routing problem that you are trying to solve.
After you have what you believe is a correct formulation, you can proceed to write the script to dynamically generate the subtour elimination constraints. Then if the solution found at the end of your script still has subtours, you can study the subtours to understand why they were not eliminated by the constraints that you defined. It may also help to use AMPL's "expand" command to look at the subtour elimination constraints that were actually generated.
--
Robert Fourer
am...@googlegroups.com
Error at _cmdno 43 executing "if" command (file amplin, line 229, offset 5372): error processing set COMPONENT: invalid subscript COMPONENT[4] discarded.
Error at _cmdno 63 executing "for" command (file amplin, line 245, offset 5951): error processing set COMPONENT: invalid subscript COMPONENT[3] discarded.
(...)
Bailing out after 10 warnings.I think the script is doing what I am looking for, but it stops, when it has discarded 10 invalid subscripts.When trying to debug I tested the second for loop.for {p in P_TEMP} { let component_id[p] := p; let COMPONENT[p] := {p}; display component_id[p]; display COMPONENT[p]; };
How do I avoid this?