cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Have a PTC product question you need answered fast? Chances are someone has asked it before. Learn about the community search. X

Anneal application in optimization

CarlosRomero
14-Alexandrite

Anneal application in optimization

Hello everyone,

I am attempting to perform the optimal transportation problema with simulated annealing, but I cannot do the initial approach correctly.

Can anybody shed light on this procedure?

CarlosRomero

 

ACCEPTED SOLUTION

Accepted Solutions

I can't be bothered implementing the annealing algorithm in Mathcad, but here is how I would do it using a solve block with minimize().

Werner_E_2-1698264911440.png

 

View solution in original post

10 REPLIES 10

I am not sure what the exact question/problem is.

Haven't looked i n detail at your sheet.

Maybe the sheet posted by Richard Jackson can be of help -> Minimizing a Function using Simulated Annealing - PTC Community

CarlosRomero
14-Alexandrite
(To:Werner_E)

Hola Werner,

I am attempting to determine optimal transport program, so that total transport expenses would be minimal.

I want to use simulated annealing to minimize. The theory of the optimal transportation program is attached in the pdf document.

The data being applied is presented in the image.

 

Data table.png

Any help you can give me will be greatly appreciated.

CarlosRomero

I can't be bothered implementing the annealing algorithm in Mathcad, but here is how I would do it using a solve block with minimize().

Werner_E_2-1698264911440.png

 

CarlosRomero
14-Alexandrite
(To:Werner_E)

Good work Werner.

 

If you get a minute please, could you implement the development of this problem with simulated annealing?

Thanks.

 

CarlosRomero


@CarlosRomero wrote:

Good work Werner.

 

If you get a minute please, could you implement the development of this problem with simulated annealing?

Thanks.

 

CarlosRomero


Unfortunately no, because it sure would take me much more than just a minute to make me acquainted with the algorithm and implement it.

I had never dealt with that algorithm and also did not dig into Richards worksheet, so I can't advice what you would have to modify to make it work for your problem. Especially how to add the additional constraints for the row and column sums. Without these constraints the algorithm will approach an all zero matrix as it seems to be in your sheet where you tried to use Richards implementation of the algorithm.

You would have to ensure by some means that each new candidate fulfills these additional constraints and maybe it would be a good idea to ensure that all values are integers (not sure about this, though).

Looks like you have quite some work to do ...

Werner_E
25-Diamond I
(To:Werner_E)

Couldn't resist and played around with Richards annealing function.

I used this objective function

Werner_E_0-1698318912285.png

vec2mat is a function which converts a 9x1 vector as used in Richards routine to the 3x3 matrix used in my already written functions.

The results are not overwhelming

Werner_E_1-1698319018864.png

or

Werner_E_2-1698319067945.png

Guess that if you insist on using the annealing algorithm, you will have to write your own implementation of it specifically trimmed to tasks like the one you try to solve.

 

CarlosRomero
14-Alexandrite
(To:Werner_E)

Thank you Werner.

Good work and extremely useful and informative.

CarlosRomero

Hello Werner

I have implemented the codes from your answers into the annealed simulated algorithm.

I used StuartBruff's vec2mat program and it doesn't seem to work.

Could you help me where the error is?

Thank you.

CarlosRomero

you typed vex2mat instead of vec2mat

 

and you typed totalCost when you defined the function,   but totalCosts when you used it at the end.

 

Furthermore you must increase the vector with the max values as otherwise the constraint with the columns and rows sums can't be fulfilled.

A vector with the theretically max values is

Werner_E_0-1698435303189.png

The vector I used in my sheet was less sophisticated and consisted of all values being 850, the max of the row and column sums vectors s and d.

Furthermore you should add a check if the constraints with the row and column sums being s and d is fulfilled. As I added these constraints a part of the objective function, there is no guarantee that these constraints are perfectly fulfilled even though I weighted them with 10^3 to get a value around the magnitude of the totalCosts. Play around with decreasing and increasing the weight value. If you decrease it, chances are higher that the row and column sums don't match, if you increase it, the total Costs are less considered.

 

I attach the file I used.

 

CarlosRomero
14-Alexandrite
(To:Werner_E)

Thanks again Werner, and I will so happy to see your posts for the future concerns with Mathcad.

Best Regards,

CarlosRomero.

Announcements

Top Tags