izhammulya

50 Reputation

5 Badges

6 years, 149 days

MaplePrimes Activity


These are replies submitted by izhammulya

@Carl Love 

Thank you. It is solved.

Thank you @Carl Love
Now, it is clear and thank you for the explanation. it is very helpful.
One more question. Is it possible to give the different color for the edges?


Yes, this what I want, thank you very much @tomleslie
One more question. Is it possible to give the different color for the edges?

Yes that one of what I want to achieve. Thank you. It is working @tomleslie
The other target what I want to achieve is the value of x. When I type of any variable of x, let say x[1,4], the output is should be taken from LPSolve. For example, Since in LPSolve, x[1,4]=1, when I type x[1,4], the output is should be 1.

@tomleslie 
Thank you @tomleslie, It is working, but I could not get the value of x. I need the x's for my following constraints.

constr:= seq(y[j]+v[j] = d[j]*(x[i,j],i=N), j = N) for any i,j.

For example
x[1,7]=0, then I have y[7]+v[7] =0.

And anyway, for this part
"ans:=[convert(select( i->has(i,x),[Sol[1][2][],Sol[2][2][]] ),set)[]];"

Assume we have n solution lpsolve, Is there any looping procedure to combine all of them ?.
Of course I can use that code (ans) from your suggestion, but it is manual.
 

Thank you @tomleslie. you are right. I have to use list.

Now I have new problm

Is it possible to combine more than 1 list array? Like the following example

given A:= [1,5,7]

B:[23,56,12]

C:=[1,3]

Then I have

[1,56,1]

[5,12,3]

[7,23,1] and so on.

I have tried to use combinate. But I still have problem.

I am sorry i am not so expert in maple, But I am learning to be expert

@tomleslie 

Thank you for helping @tomleslie. I have tried those ways (your seggestion) but still doesn't work if I generate it for more nodes.
Actually, what I want to achieve is take an order of the solution. As you see in my code, I try to solve TSP by using linear programming nested in loop. I can solve it, but I was stuck in how to bring the solution into a matrix and then take an order from it.

Now, I used another way. I modified code from thread "https://www.mapleprimes.com/questions/220689-How-To-Solve-A-VRP-" and put it in the loop.
But, Honestly, I still curious about how to bring the solution of LPSolve (like in my case) into a matrix and then take an order from it.

So, is it possible to rewrite solution from LPSolve in matrix form in this case?

 

Dear @tomleslie

Try to rerun it. 

It is error since in the clustering part, you get A:=(2, 2,2, 2,p). 

If this happen, try to rerun it the program until There is no variable in A.

If in the part A (for example) you get A=(1,1,2,2,2) the program will be okay and the error only in the looping Matrix X

@Carl Love This one is my code.

Honestly, I am working in CVRP. After clustering by using FCM (Fuzzy Clustering) (using your code), i am going to solve it in TSP way, 1 by 1. In other word, I have to involve looping statement.

And that one is the output.
Hopefully you can help me to fix it in that error

Thank you @Carl Love

Fuzzy_clusters_subtour.mw

Hi @Carl Love 

I need your help again. How to solve the order in the following picture. I got repetition only 1 5 15
Actually, I want to compute the total of capacity of every vertice. Before that, I have to get the vertice. How to get the vertice from r?

Thank you anywayVRPSD2.mw

@Carl Love Thank you anyway for the solution, I have retyped it.

Now I got new problem, the problem is how to force x[i,j] when i=j such that the value = 0.

I have added the constraints for x[2,1],x[3,1],...,x[5,1].

The result is so strange. I get value 1 for x[i,j] when i=j.

 

This is the worksheet @Carl Love VRPSD1.mw
 

restart:

city :=  [[40,40], [22,22], [36,26], [21, 45], [45,35], [55,20]]; N:=nops(city):

[[40, 40], [22, 22], [36, 26], [21, 45], [45, 35], [55, 20]]

(1)

#c := array(1..N,1..N,[evalf(seq([seq(((city[i][1]-city[j][1])^2 + (city[i][2]-city[j][2])^2)^(1/2)                                     ,j=1..N)],i=1..N))]);

N:=5:

c:= Matrix(
   N$2, shape= symmetric, scan= triangular,
   [0, op]~([[2,6,4,1],
               [3,7,3],
                 [5,2],
                   [1]]
                        
)):

d:=<0, 20,5,5,5>:

P:=plots[pointplot](city, color=red, thickness=2, connect=false):
T:=plots[textplot]([seq([op(city[i]),i],i=1..5)],align=right, font=[TIMES,ROMAN,15]):
S:=plots[textplot]([40,40,"Depot"]):
plots[display](T,P,S);

 

K:=30: n := sqrt(numelems(c)): N:={seq(1..n)};

{1, 2, 3, 4, 5}

(2)

z := add(add(c[i, j]*x[i, j], j = N), i = N)

2*x[1, 2]+6*x[1, 3]+4*x[1, 4]+x[1, 5]+2*x[2, 1]+3*x[2, 3]+7*x[2, 4]+3*x[2, 5]+6*x[3, 1]+3*x[3, 2]+5*x[3, 4]+2*x[3, 5]+4*x[4, 1]+7*x[4, 2]+5*x[4, 3]+x[4, 5]+x[5, 1]+3*x[5, 2]+2*x[5, 3]+x[5, 4]

(3)

conv := seq(add(x[i, j], j = `minus`(N, {i})) = 4, i = 1)

x[1, 2]+x[1, 3]+x[1, 4]+x[1, 5] = 4

(4)

H := numelems(N); consC := seq(add(x[i, k], i = N) = 2, k = 2 .. H)

x[1, 2]+x[2, 2]+x[3, 2]+x[4, 2]+x[5, 2] = 2, x[1, 3]+x[2, 3]+x[3, 3]+x[4, 3]+x[5, 3] = 2, x[1, 4]+x[2, 4]+x[3, 4]+x[4, 4]+x[5, 4] = 2, x[1, 5]+x[2, 5]+x[3, 5]+x[4, 5]+x[5, 5] = 2

(5)

consd2 := seq(seq(x[i, j] >= 0, j = `minus`(N, {1})), i = 1)
  consd1 := seq(seq(x[i, j]<=2, j = N minus {i}), i = 1); 

x[1, 2] <= 2, x[1, 3] <= 2, x[1, 4] <= 2, x[1, 5] <= 2

(6)

0 <= x[1, 2], 0 <= x[1, 3], 0 <= x[1, 4], 0 <= x[1, 5]

(7)

consint1 := seq(seq(x[i, j] >= 0, j = `minus`(N, {1})), i = `minus`(N, {1}))

0 <= x[2, 2], 0 <= x[2, 3], 0 <= x[2, 4], 0 <= x[2, 5], 0 <= x[3, 2], 0 <= x[3, 3], 0 <= x[3, 4], 0 <= x[3, 5], 0 <= x[4, 2], 0 <= x[4, 3], 0 <= x[4, 4], 0 <= x[4, 5], 0 <= x[5, 2], 0 <= x[5, 3], 0 <= x[5, 4], 0 <= x[5, 5]

(8)

consint2 := seq(seq(x[i, j] <= 1, j = `minus`(N, {1})), i = `minus`(N, {1})); r := Optimization[LPSolve](z, {consC, consd1, consd2, conv, consint1, consint2}, assume = integer)

[27, [x[1, 2] = 0, x[1, 3] = 0, x[1, 4] = 2, x[1, 5] = 2, x[2, 1] = 0, x[2, 2] = 0, x[2, 3] = 0, x[2, 4] = 0, x[2, 5] = 0, x[3, 1] = 0, x[3, 2] = 0, x[3, 3] = 0, x[3, 4] = 0, x[3, 5] = 0, x[4, 1] = 0, x[4, 2] = 1, x[4, 3] = 1, x[4, 4] = 0, x[4, 5] = 0, x[5, 1] = 0, x[5, 2] = 1, x[5, 3] = 1, x[5, 4] = 0, x[5, 5] = 0]]

(9)

 

NULL

 

 

NULL


 

Download VRPSD1.mw

 

I got problem again, the result is following, to be unbounded. I want to solve system  with 3,4,6,7 and 8 constraints as my master problem for L integer method. Is there any mistake in my code?Hopefully you could help me.

Thank you

Page 1 of 1