diff --git a/Hopfield Net TSP solver.prj b/Hopfield Net TSP solver.prj index b30b19e..cf29f1b 100644 --- a/Hopfield Net TSP solver.prj +++ b/Hopfield Net TSP solver.prj @@ -1,5 +1,5 @@ - + Hopfield Net TSP solver Lucas García Rodríguez lucasgarciarodriguez@ucm.es @@ -12,11 +12,13 @@ The Hopfield Network TSP Solver App allows to solve the Traveling Salesman Problem using Continuous Hopfield Networks <b>The Hopfield Network TSP Solver App</b> allows to solve the Traveling Salesman Problem using Continuous Hopfield Networks by using several of the solver algorithms available in Hopfield Network Toolbox: -<ul><li>euler</li><li>talavan-yanez</li><li>divide-conquer</li></ul> +<ul><li>euler</li><li>runge-kutta</li><li>talavan-yanez</li></ul> +The Toolbox allows to create several network models or architectures, including: +<ul><li>classic</li><li>classic&2opt</li><li>divide-conquer</li><li>divide-conquer&2opt</li></ul> Find more information in the documentation of the toolbox or in the <a href="https://github.com/mathinking/HopfieldNetworkToolbox">GitHub repository</a> ${PROJECT_ROOT}\help\html\network.png - 1.1.1 + 2.0 MATLAB Statistics and Machine Learning Toolbox @@ -37,304 +39,90 @@ Find more information in the documentation of the toolbox or in the <a href=" - ${PROJECT_ROOT}\@tsphopfieldnetApp\tsphopfieldnetApp.m + ${PROJECT_ROOT}\chn\hopfieldNetworkTSPApp.m - ${PROJECT_ROOT}\@hopfieldnetwork\addDefaultOptionValues.m - ${PROJECT_ROOT}\@hopfieldnetwork\createOptions.m - ${PROJECT_ROOT}\@hopfieldnetwork\getResults.m - ${PROJECT_ROOT}\@hopfieldnetwork\getSetting.m - ${PROJECT_ROOT}\@hopfieldnetwork\getSimFcn.m - ${PROJECT_ROOT}\@hopfieldnetwork\getTrainFcn.m - ${PROJECT_ROOT}\@hopfieldnetwork\getTrainParam.m - ${PROJECT_ROOT}\@hopfieldnetwork\hopfieldnetwork.m - ${PROJECT_ROOT}\@hopfieldnetwork\init.m - ${PROJECT_ROOT}\@hopfieldnetwork\invsatlin.m - ${PROJECT_ROOT}\@hopfieldnetwork\isValidSetting.m - ${PROJECT_ROOT}\@hopfieldnetwork\satlin.m - ${PROJECT_ROOT}\@hopfieldnetwork\setOptions.m - ${PROJECT_ROOT}\@hopfieldnetwork\setResults.m - ${PROJECT_ROOT}\@hopfieldnetwork\setSetting.m - ${PROJECT_ROOT}\@hopfieldnetwork\setTrainParam.m - ${PROJECT_ROOT}\@tsphopfieldnet\addDefaultOptionValues.m - ${PROJECT_ROOT}\@tsphopfieldnet\city.m - ${PROJECT_ROOT}\@tsphopfieldnet\cityTextGeneration.m - ${PROJECT_ROOT}\@tsphopfieldnet\computeDistance.m - ${PROJECT_ROOT}\@tsphopfieldnet\createChain.m - ${PROJECT_ROOT}\@tsphopfieldnet\createOptions.m - ${PROJECT_ROOT}\@tsphopfieldnet\disp.m - ${PROJECT_ROOT}\@tsphopfieldnet\energyplot.m - ${PROJECT_ROOT}\@tsphopfieldnet\fixedCities.m - ${PROJECT_ROOT}\@tsphopfieldnet\getCities.m - ${PROJECT_ROOT}\@tsphopfieldnet\getName.m - ${PROJECT_ROOT}\@tsphopfieldnet\init.m - ${PROJECT_ROOT}\@tsphopfieldnet\isValidSetting.m - ${PROJECT_ROOT}\@tsphopfieldnet\loggingV.m - ${PROJECT_ROOT}\@tsphopfieldnet\modulo.m - ${PROJECT_ROOT}\@tsphopfieldnet\neighbourDistance.m - ${PROJECT_ROOT}\@tsphopfieldnet\plot.m - ${PROJECT_ROOT}\@tsphopfieldnet\polygonCoords.m - ${PROJECT_ROOT}\@tsphopfieldnet\reinit.m - ${PROJECT_ROOT}\@tsphopfieldnet\saddle.m - ${PROJECT_ROOT}\@tsphopfieldnet\setCities.m - ${PROJECT_ROOT}\@tsphopfieldnet\setOptions.m - ${PROJECT_ROOT}\@tsphopfieldnet\setSimFcn.m - ${PROJECT_ROOT}\@tsphopfieldnet\setTrainFcn.m - ${PROJECT_ROOT}\@tsphopfieldnet\sim.m - ${PROJECT_ROOT}\@tsphopfieldnet\storeResultsinPDF.m - ${PROJECT_ROOT}\@tsphopfieldnet\train.m - ${PROJECT_ROOT}\@tsphopfieldnet\tsphopfieldnet.m - ${PROJECT_ROOT}\@tsphopfieldnet\verifyIfValidSubtours.m - ${PROJECT_ROOT}\@tsphopfieldnet\viewConvergence.m - ${PROJECT_ROOT}\@tsphopfieldnetApp\cb_findTour.m - ${PROJECT_ROOT}\@tsphopfieldnetApp\cb_parameterCEdit.m - ${PROJECT_ROOT}\@tsphopfieldnetApp\cb_seedFixed.m - ${PROJECT_ROOT}\@tsphopfieldnetApp\cb_seedShuffle.m - ${PROJECT_ROOT}\@tsphopfieldnetApp\cb_simFcn.m - ${PROJECT_ROOT}\@tsphopfieldnetApp\cb_tabOtherChooseFromWs.m - ${PROJECT_ROOT}\@tsphopfieldnetApp\cb_tabOtherCoordsDist.m - ${PROJECT_ROOT}\@tsphopfieldnetApp\cb_tabPolygonNcities.m - ${PROJECT_ROOT}\@tsphopfieldnetApp\cb_tabTSPLIBmenu.m - ${PROJECT_ROOT}\@tsphopfieldnetApp\cleanState.m - ${PROJECT_ROOT}\@tsphopfieldnetApp\createFigure.m - ${PROJECT_ROOT}\@tsphopfieldnetApp\createTspHopfieldNet.m - ${PROJECT_ROOT}\@tsphopfieldnetApp\defaultSettings.m - ${PROJECT_ROOT}\@tsphopfieldnetApp\getScreenSize.m - ${PROJECT_ROOT}\@tsphopfieldnetApp\timeElapsed.m - ${PROJECT_ROOT}\@tsphopfieldnetApp\updateTspHopfieldNet.m - ${PROJECT_ROOT}\@tsplib\computeTour.m - ${PROJECT_ROOT}\@tsplib\convert2LatLon.m - ${PROJECT_ROOT}\@tsplib\findOptimumTour.m - ${PROJECT_ROOT}\@tsplib\plot.m - ${PROJECT_ROOT}\@tsplib\problemNames.m - ${PROJECT_ROOT}\@tsplib\tsplib.m - ${PROJECT_ROOT}\TSPFiles\a280.tsp - ${PROJECT_ROOT}\TSPFiles\ali535.tsp - ${PROJECT_ROOT}\TSPFiles\att48.tsp - ${PROJECT_ROOT}\TSPFiles\att532.tsp - ${PROJECT_ROOT}\TSPFiles\bayg29.tsp - ${PROJECT_ROOT}\TSPFiles\bays29.tsp - ${PROJECT_ROOT}\TSPFiles\berlin52.tsp - ${PROJECT_ROOT}\TSPFiles\bier127.tsp - ${PROJECT_ROOT}\TSPFiles\brazil58.tsp - ${PROJECT_ROOT}\TSPFiles\brd14051.tsp - ${PROJECT_ROOT}\TSPFiles\brg180.tsp - ${PROJECT_ROOT}\TSPFiles\burma14.tsp - ${PROJECT_ROOT}\TSPFiles\ch130.tsp - ${PROJECT_ROOT}\TSPFiles\ch150.tsp - ${PROJECT_ROOT}\TSPFiles\d1291.tsp - ${PROJECT_ROOT}\TSPFiles\d15112.tsp - ${PROJECT_ROOT}\TSPFiles\d1655.tsp - ${PROJECT_ROOT}\TSPFiles\d18512.tsp - ${PROJECT_ROOT}\TSPFiles\d198.tsp - ${PROJECT_ROOT}\TSPFiles\d2103.tsp - ${PROJECT_ROOT}\TSPFiles\d493.tsp - ${PROJECT_ROOT}\TSPFiles\d657.tsp - ${PROJECT_ROOT}\TSPFiles\dantzig42.tsp - ${PROJECT_ROOT}\TSPFiles\dsj1000.tsp - ${PROJECT_ROOT}\TSPFiles\eil101.tsp - ${PROJECT_ROOT}\TSPFiles\eil51.tsp - ${PROJECT_ROOT}\TSPFiles\eil76.tsp - ${PROJECT_ROOT}\TSPFiles\fl1400.tsp - ${PROJECT_ROOT}\TSPFiles\fl1577.tsp - ${PROJECT_ROOT}\TSPFiles\fl3795.tsp - ${PROJECT_ROOT}\TSPFiles\fl417.tsp - ${PROJECT_ROOT}\TSPFiles\fnl4461.tsp - ${PROJECT_ROOT}\TSPFiles\fri26.tsp - ${PROJECT_ROOT}\TSPFiles\gil262.tsp - ${PROJECT_ROOT}\TSPFiles\gr120.tsp - ${PROJECT_ROOT}\TSPFiles\gr137.tsp - ${PROJECT_ROOT}\TSPFiles\gr17.tsp - ${PROJECT_ROOT}\TSPFiles\gr202.tsp - ${PROJECT_ROOT}\TSPFiles\gr21.tsp - ${PROJECT_ROOT}\TSPFiles\gr229.tsp - ${PROJECT_ROOT}\TSPFiles\gr24.tsp - ${PROJECT_ROOT}\TSPFiles\gr431.tsp - ${PROJECT_ROOT}\TSPFiles\gr48.tsp - ${PROJECT_ROOT}\TSPFiles\gr666.tsp - ${PROJECT_ROOT}\TSPFiles\gr96.tsp - ${PROJECT_ROOT}\TSPFiles\hk48.tsp - ${PROJECT_ROOT}\TSPFiles\kroA100.tsp - ${PROJECT_ROOT}\TSPFiles\kroA150.tsp - ${PROJECT_ROOT}\TSPFiles\kroA200.tsp - ${PROJECT_ROOT}\TSPFiles\kroB100.tsp - ${PROJECT_ROOT}\TSPFiles\kroB150.tsp - ${PROJECT_ROOT}\TSPFiles\kroB200.tsp - ${PROJECT_ROOT}\TSPFiles\kroC100.tsp - ${PROJECT_ROOT}\TSPFiles\kroD100.tsp - ${PROJECT_ROOT}\TSPFiles\kroE100.tsp - ${PROJECT_ROOT}\TSPFiles\lin105.tsp - ${PROJECT_ROOT}\TSPFiles\lin318.tsp - ${PROJECT_ROOT}\TSPFiles\linhp318.tsp - ${PROJECT_ROOT}\TSPFiles\nrw1379.tsp - ${PROJECT_ROOT}\TSPFiles\p654.tsp - ${PROJECT_ROOT}\TSPFiles\pa561.tsp - ${PROJECT_ROOT}\TSPFiles\pcb1173.tsp - ${PROJECT_ROOT}\TSPFiles\pcb3038.tsp - ${PROJECT_ROOT}\TSPFiles\pcb442.tsp - ${PROJECT_ROOT}\TSPFiles\pla33810.tsp - ${PROJECT_ROOT}\TSPFiles\pla7397.tsp - ${PROJECT_ROOT}\TSPFiles\pla85900.tsp - ${PROJECT_ROOT}\TSPFiles\pr1002.tsp - ${PROJECT_ROOT}\TSPFiles\pr107.tsp - ${PROJECT_ROOT}\TSPFiles\pr124.tsp - ${PROJECT_ROOT}\TSPFiles\pr136.tsp - ${PROJECT_ROOT}\TSPFiles\pr144.tsp - ${PROJECT_ROOT}\TSPFiles\pr152.tsp - ${PROJECT_ROOT}\TSPFiles\pr226.tsp - ${PROJECT_ROOT}\TSPFiles\pr2392.tsp - ${PROJECT_ROOT}\TSPFiles\pr264.tsp - ${PROJECT_ROOT}\TSPFiles\pr299.tsp - ${PROJECT_ROOT}\TSPFiles\pr439.tsp - ${PROJECT_ROOT}\TSPFiles\pr76.tsp - ${PROJECT_ROOT}\TSPFiles\rat195.tsp - ${PROJECT_ROOT}\TSPFiles\rat575.tsp - ${PROJECT_ROOT}\TSPFiles\rat783.tsp - ${PROJECT_ROOT}\TSPFiles\rat99.tsp - ${PROJECT_ROOT}\TSPFiles\rd100.tsp - ${PROJECT_ROOT}\TSPFiles\rd400.tsp - ${PROJECT_ROOT}\TSPFiles\rl11849.tsp - ${PROJECT_ROOT}\TSPFiles\rl1304.tsp - ${PROJECT_ROOT}\TSPFiles\rl1323.tsp - ${PROJECT_ROOT}\TSPFiles\rl1889.tsp - ${PROJECT_ROOT}\TSPFiles\rl5915.tsp - ${PROJECT_ROOT}\TSPFiles\rl5934.tsp - ${PROJECT_ROOT}\TSPFiles\si1032.tsp - ${PROJECT_ROOT}\TSPFiles\si175.tsp - ${PROJECT_ROOT}\TSPFiles\si535.tsp - ${PROJECT_ROOT}\TSPFiles\st70.tsp - ${PROJECT_ROOT}\TSPFiles\swiss42.tsp - ${PROJECT_ROOT}\TSPFiles\ts225.tsp - ${PROJECT_ROOT}\TSPFiles\tsp225.tsp - ${PROJECT_ROOT}\TSPFiles\TSPLIBproblems.mat - ${PROJECT_ROOT}\TSPFiles\TSPTours\a280.opt.tour - ${PROJECT_ROOT}\TSPFiles\TSPTours\ali535.opt.tour - ${PROJECT_ROOT}\TSPFiles\TSPTours\att48.opt.tour - ${PROJECT_ROOT}\TSPFiles\TSPTours\att532.opt.tour - ${PROJECT_ROOT}\TSPFiles\TSPTours\bayg29.opt.tour - ${PROJECT_ROOT}\TSPFiles\TSPTours\bays29.opt.tour - ${PROJECT_ROOT}\TSPFiles\TSPTours\berlin52.opt.tour - ${PROJECT_ROOT}\TSPFiles\TSPTours\bier127.opt.tour - ${PROJECT_ROOT}\TSPFiles\TSPTours\brazil58.opt.tour - ${PROJECT_ROOT}\TSPFiles\TSPTours\brd14051.469388.tour - ${PROJECT_ROOT}\TSPFiles\TSPTours\brg180.opt.tour - ${PROJECT_ROOT}\TSPFiles\TSPTours\burma14.opt.tour - ${PROJECT_ROOT}\TSPFiles\TSPTours\ch130.opt.tour - ${PROJECT_ROOT}\TSPFiles\TSPTours\ch150.opt.tour - ${PROJECT_ROOT}\TSPFiles\TSPTours\d1291.opt.tour - ${PROJECT_ROOT}\TSPFiles\TSPTours\d15112.opt.tour - ${PROJECT_ROOT}\TSPFiles\TSPTours\d1655.opt.tour - ${PROJECT_ROOT}\TSPFiles\TSPTours\d18512.645244.tour - ${PROJECT_ROOT}\TSPFiles\TSPTours\d198.opt.tour - ${PROJECT_ROOT}\TSPFiles\TSPTours\d2103.opt.tour - ${PROJECT_ROOT}\TSPFiles\TSPTours\d493.opt.tour - ${PROJECT_ROOT}\TSPFiles\TSPTours\d657.opt.tour - ${PROJECT_ROOT}\TSPFiles\TSPTours\dantzig42.opt.tour - ${PROJECT_ROOT}\TSPFiles\TSPTours\dsj1000.opt.tour - ${PROJECT_ROOT}\TSPFiles\TSPTours\eil101.opt.tour - ${PROJECT_ROOT}\TSPFiles\TSPTours\eil51.opt.tour - ${PROJECT_ROOT}\TSPFiles\TSPTours\eil76.opt.tour - ${PROJECT_ROOT}\TSPFiles\TSPTours\fl1400.opt.tour - ${PROJECT_ROOT}\TSPFiles\TSPTours\fl1577.opt.tour - ${PROJECT_ROOT}\TSPFiles\TSPTours\fl3795.opt.tour - ${PROJECT_ROOT}\TSPFiles\TSPTours\fl417.opt.tour - ${PROJECT_ROOT}\TSPFiles\TSPTours\fnl4461.opt.tour - ${PROJECT_ROOT}\TSPFiles\TSPTours\fri26.opt.tour - ${PROJECT_ROOT}\TSPFiles\TSPTours\gil262.opt.tour - ${PROJECT_ROOT}\TSPFiles\TSPTours\gr120.opt.tour - ${PROJECT_ROOT}\TSPFiles\TSPTours\gr137.opt.tour - ${PROJECT_ROOT}\TSPFiles\TSPTours\gr17.opt.tour - ${PROJECT_ROOT}\TSPFiles\TSPTours\gr202.opt.tour - ${PROJECT_ROOT}\TSPFiles\TSPTours\gr21.opt.tour - ${PROJECT_ROOT}\TSPFiles\TSPTours\gr229.opt.tour - ${PROJECT_ROOT}\TSPFiles\TSPTours\gr24.opt.tour - ${PROJECT_ROOT}\TSPFiles\TSPTours\gr431.opt.tour - ${PROJECT_ROOT}\TSPFiles\TSPTours\gr48.opt.tour - ${PROJECT_ROOT}\TSPFiles\TSPTours\gr666.opt.tour - ${PROJECT_ROOT}\TSPFiles\TSPTours\gr96.opt.tour - ${PROJECT_ROOT}\TSPFiles\TSPTours\hk48.opt.tour - ${PROJECT_ROOT}\TSPFiles\TSPTours\kroA100.opt.tour - ${PROJECT_ROOT}\TSPFiles\TSPTours\kroA150.opt.tour - ${PROJECT_ROOT}\TSPFiles\TSPTours\kroA200.opt.tour - ${PROJECT_ROOT}\TSPFiles\TSPTours\kroB100.opt.tour - ${PROJECT_ROOT}\TSPFiles\TSPTours\kroB150.opt.tour - ${PROJECT_ROOT}\TSPFiles\TSPTours\kroB200.opt.tour - ${PROJECT_ROOT}\TSPFiles\TSPTours\kroC100.opt.tour - ${PROJECT_ROOT}\TSPFiles\TSPTours\kroD100.opt.tour - ${PROJECT_ROOT}\TSPFiles\TSPTours\kroE100.opt.tour - ${PROJECT_ROOT}\TSPFiles\TSPTours\lin105.opt.tour - ${PROJECT_ROOT}\TSPFiles\TSPTours\lin318.opt.tour - ${PROJECT_ROOT}\TSPFiles\TSPTours\linhp318.opt.tour - ${PROJECT_ROOT}\TSPFiles\TSPTours\nrw1379.opt.tour - ${PROJECT_ROOT}\TSPFiles\TSPTours\p654.opt.tour - ${PROJECT_ROOT}\TSPFiles\TSPTours\pa561.opt.tour - ${PROJECT_ROOT}\TSPFiles\TSPTours\pcb1173.opt.tour - ${PROJECT_ROOT}\TSPFiles\TSPTours\pcb3038.opt.tour - ${PROJECT_ROOT}\TSPFiles\TSPTours\pcb442.opt.tour - ${PROJECT_ROOT}\TSPFiles\TSPTours\pla33810.66050599.tour - ${PROJECT_ROOT}\TSPFiles\TSPTours\pla7397.opt.tour - ${PROJECT_ROOT}\TSPFiles\TSPTours\pla85900.142393738.tour - ${PROJECT_ROOT}\TSPFiles\TSPTours\pr1002.opt.tour - ${PROJECT_ROOT}\TSPFiles\TSPTours\pr107.opt.tour - ${PROJECT_ROOT}\TSPFiles\TSPTours\pr124.opt.tour - ${PROJECT_ROOT}\TSPFiles\TSPTours\pr136.opt.tour - ${PROJECT_ROOT}\TSPFiles\TSPTours\pr144.opt.tour - ${PROJECT_ROOT}\TSPFiles\TSPTours\pr152.opt.tour - ${PROJECT_ROOT}\TSPFiles\TSPTours\pr226.opt.tour - ${PROJECT_ROOT}\TSPFiles\TSPTours\pr2392.opt.tour - ${PROJECT_ROOT}\TSPFiles\TSPTours\pr264.opt.tour - ${PROJECT_ROOT}\TSPFiles\TSPTours\pr299.opt.tour - ${PROJECT_ROOT}\TSPFiles\TSPTours\pr439.opt.tour - ${PROJECT_ROOT}\TSPFiles\TSPTours\pr76.opt.tour - ${PROJECT_ROOT}\TSPFiles\TSPTours\rat195.opt.tour - ${PROJECT_ROOT}\TSPFiles\TSPTours\rat575.opt.tour - ${PROJECT_ROOT}\TSPFiles\TSPTours\rat783.opt.tour - ${PROJECT_ROOT}\TSPFiles\TSPTours\rat99.opt.tour - ${PROJECT_ROOT}\TSPFiles\TSPTours\rd100.opt.tour - ${PROJECT_ROOT}\TSPFiles\TSPTours\rd400.opt.tour - ${PROJECT_ROOT}\TSPFiles\TSPTours\rl11849.opt.tour - ${PROJECT_ROOT}\TSPFiles\TSPTours\rl1304.opt.tour - ${PROJECT_ROOT}\TSPFiles\TSPTours\rl1323.opt.tour - ${PROJECT_ROOT}\TSPFiles\TSPTours\rl1889.opt.tour - ${PROJECT_ROOT}\TSPFiles\TSPTours\rl5915.opt.tour - ${PROJECT_ROOT}\TSPFiles\TSPTours\rl5934.opt.tour - ${PROJECT_ROOT}\TSPFiles\TSPTours\si1032.opt.tour - ${PROJECT_ROOT}\TSPFiles\TSPTours\si175.opt.tour - ${PROJECT_ROOT}\TSPFiles\TSPTours\si535.opt.tour - ${PROJECT_ROOT}\TSPFiles\TSPTours\st70.opt.tour - ${PROJECT_ROOT}\TSPFiles\TSPTours\swiss42.opt.tour - ${PROJECT_ROOT}\TSPFiles\TSPTours\ts225.opt.tour - ${PROJECT_ROOT}\TSPFiles\TSPTours\tsp225.opt.tour - ${PROJECT_ROOT}\TSPFiles\TSPTours\u1060.opt.tour - ${PROJECT_ROOT}\TSPFiles\TSPTours\u1432.opt.tour - ${PROJECT_ROOT}\TSPFiles\TSPTours\u159.opt.tour - ${PROJECT_ROOT}\TSPFiles\TSPTours\u1817.opt.tour - ${PROJECT_ROOT}\TSPFiles\TSPTours\u2152.opt.tour - ${PROJECT_ROOT}\TSPFiles\TSPTours\u2319.opt.tour - ${PROJECT_ROOT}\TSPFiles\TSPTours\u574.opt.tour - ${PROJECT_ROOT}\TSPFiles\TSPTours\u724.opt.tour - ${PROJECT_ROOT}\TSPFiles\TSPTours\ulysses16.opt.tour - ${PROJECT_ROOT}\TSPFiles\TSPTours\ulysses22.opt.tour - ${PROJECT_ROOT}\TSPFiles\TSPTours\usa13509.opt.tour - ${PROJECT_ROOT}\TSPFiles\TSPTours\vm1084.opt.tour - ${PROJECT_ROOT}\TSPFiles\TSPTours\vm1748.opt.tour - ${PROJECT_ROOT}\TSPFiles\u1060.tsp - ${PROJECT_ROOT}\TSPFiles\u1432.tsp - ${PROJECT_ROOT}\TSPFiles\u159.tsp - ${PROJECT_ROOT}\TSPFiles\u1817.tsp - ${PROJECT_ROOT}\TSPFiles\u2152.tsp - ${PROJECT_ROOT}\TSPFiles\u2319.tsp - ${PROJECT_ROOT}\TSPFiles\u574.tsp - ${PROJECT_ROOT}\TSPFiles\u724.tsp - ${PROJECT_ROOT}\TSPFiles\ulysses16.tsp - ${PROJECT_ROOT}\TSPFiles\ulysses22.tsp - ${PROJECT_ROOT}\TSPFiles\usa13509.tsp - ${PROJECT_ROOT}\TSPFiles\vm1084.tsp - ${PROJECT_ROOT}\TSPFiles\vm1748.tsp - ${PROJECT_ROOT}\TSPFiles\xray.problems + ${PROJECT_ROOT}\chn\+apps\@HopfieldNetworkTSPApp\cb_closeApp.m + ${PROJECT_ROOT}\chn\+apps\@HopfieldNetworkTSPApp\cb_findTour.m + ${PROJECT_ROOT}\chn\+apps\@HopfieldNetworkTSPApp\cb_parameterCEdit.m + ${PROJECT_ROOT}\chn\+apps\@HopfieldNetworkTSPApp\cb_scheme.m + ${PROJECT_ROOT}\chn\+apps\@HopfieldNetworkTSPApp\cb_seedFixed.m + ${PROJECT_ROOT}\chn\+apps\@HopfieldNetworkTSPApp\cb_seedShuffle.m + ${PROJECT_ROOT}\chn\+apps\@HopfieldNetworkTSPApp\cb_simFcn.m + ${PROJECT_ROOT}\chn\+apps\@HopfieldNetworkTSPApp\cb_tabOtherChooseFromWs.m + ${PROJECT_ROOT}\chn\+apps\@HopfieldNetworkTSPApp\cb_tabOtherCoordsDist.m + ${PROJECT_ROOT}\chn\+apps\@HopfieldNetworkTSPApp\cb_tabPolygonNcities.m + ${PROJECT_ROOT}\chn\+apps\@HopfieldNetworkTSPApp\cb_tabTSPLIBmenu.m + ${PROJECT_ROOT}\chn\+apps\@HopfieldNetworkTSPApp\cleanState.m + ${PROJECT_ROOT}\chn\+apps\@HopfieldNetworkTSPApp\createFigure.m + ${PROJECT_ROOT}\chn\+apps\@HopfieldNetworkTSPApp\createTspHopfieldNet.m + ${PROJECT_ROOT}\chn\+apps\@HopfieldNetworkTSPApp\defaultSettings.m + ${PROJECT_ROOT}\chn\+apps\@HopfieldNetworkTSPApp\getScreenSize.m + ${PROJECT_ROOT}\chn\+apps\@HopfieldNetworkTSPApp\HopfieldNetworkTSPApp.m + ${PROJECT_ROOT}\chn\+apps\@HopfieldNetworkTSPApp\timeElapsed.m + ${PROJECT_ROOT}\chn\+apps\@HopfieldNetworkTSPApp\updateTspHopfieldNet.m + ${PROJECT_ROOT}\chn\+apps\@HopfieldNetworkTSPApp\verifyProblemIsSelected.m + ${PROJECT_ROOT}\chn\+network\@HopfieldNetwork\getResults.m + ${PROJECT_ROOT}\chn\+network\@HopfieldNetwork\getScheme.m + ${PROJECT_ROOT}\chn\+network\@HopfieldNetwork\getSetting.m + ${PROJECT_ROOT}\chn\+network\@HopfieldNetwork\getSimFcn.m + ${PROJECT_ROOT}\chn\+network\@HopfieldNetwork\getTrainFcn.m + ${PROJECT_ROOT}\chn\+network\@HopfieldNetwork\getTrainParam.m + ${PROJECT_ROOT}\chn\+network\@HopfieldNetwork\HopfieldNetwork.m + ${PROJECT_ROOT}\chn\+network\@HopfieldNetwork\init.m + ${PROJECT_ROOT}\chn\+network\@HopfieldNetwork\invsatlin.m + ${PROJECT_ROOT}\chn\+network\@HopfieldNetwork\satlin.m + ${PROJECT_ROOT}\chn\+network\@HopfieldNetwork\setOptions.m + ${PROJECT_ROOT}\chn\+network\@HopfieldNetwork\setResults.m + ${PROJECT_ROOT}\chn\+network\@HopfieldNetwork\setSetting.m + ${PROJECT_ROOT}\chn\+network\@HopfieldNetworkTSP\city.m + ${PROJECT_ROOT}\chn\+network\@HopfieldNetworkTSP\cityTextGeneration.m + ${PROJECT_ROOT}\chn\+network\@HopfieldNetworkTSP\computeDistance.m + ${PROJECT_ROOT}\chn\+network\@HopfieldNetworkTSP\createChain.m + ${PROJECT_ROOT}\chn\+network\@HopfieldNetworkTSP\disp.m + ${PROJECT_ROOT}\chn\+network\@HopfieldNetworkTSP\energyplot.m + ${PROJECT_ROOT}\chn\+network\@HopfieldNetworkTSP\fixedCities.m + ${PROJECT_ROOT}\chn\+network\@HopfieldNetworkTSP\getCities.m + ${PROJECT_ROOT}\chn\+network\@HopfieldNetworkTSP\getName.m + ${PROJECT_ROOT}\chn\+network\@HopfieldNetworkTSP\HopfieldNetworkTSP.m + ${PROJECT_ROOT}\chn\+network\@HopfieldNetworkTSP\init.m + ${PROJECT_ROOT}\chn\+network\@HopfieldNetworkTSP\loggingV.m + ${PROJECT_ROOT}\chn\+network\@HopfieldNetworkTSP\modulo.m + ${PROJECT_ROOT}\chn\+network\@HopfieldNetworkTSP\neighbourDistance.m + ${PROJECT_ROOT}\chn\+network\@HopfieldNetworkTSP\plot.m + ${PROJECT_ROOT}\chn\+network\@HopfieldNetworkTSP\polygonCoords.m + ${PROJECT_ROOT}\chn\+network\@HopfieldNetworkTSP\reinit.m + ${PROJECT_ROOT}\chn\+network\@HopfieldNetworkTSP\saddle.m + ${PROJECT_ROOT}\chn\+network\@HopfieldNetworkTSP\setCities.m + ${PROJECT_ROOT}\chn\+network\@HopfieldNetworkTSP\setOptions.m + ${PROJECT_ROOT}\chn\+network\@HopfieldNetworkTSP\setScheme.m + ${PROJECT_ROOT}\chn\+network\@HopfieldNetworkTSP\setSimFcn.m + ${PROJECT_ROOT}\chn\+network\@HopfieldNetworkTSP\setTrainFcn.m + ${PROJECT_ROOT}\chn\+network\@HopfieldNetworkTSP\setTrainParam.m + ${PROJECT_ROOT}\chn\+network\@HopfieldNetworkTSP\sim.m + ${PROJECT_ROOT}\chn\+network\@HopfieldNetworkTSP\storeResultsinPDF.m + ${PROJECT_ROOT}\chn\+network\@HopfieldNetworkTSP\train.m + ${PROJECT_ROOT}\chn\+network\@HopfieldNetworkTSP\verifyIfValidSubtours.m + ${PROJECT_ROOT}\chn\+network\@HopfieldNetworkTSP\viewConvergence.m + ${PROJECT_ROOT}\chn\+options\HopfieldNetworkGQKPOptions.m + ${PROJECT_ROOT}\chn\+options\HopfieldNetworkOptions.m + ${PROJECT_ROOT}\chn\+options\HopfieldNetworkTSPOptions.m + ${PROJECT_ROOT}\chn\+utils\+checkpoint\createFilename.m + ${PROJECT_ROOT}\chn\+utils\+checkpoint\loggingData.m + ${PROJECT_ROOT}\chn\+utils\+checkpoint\trimToSimulatedData.m + ${PROJECT_ROOT}\chn\+utils\@TSPLIB\computeTour.m + ${PROJECT_ROOT}\chn\+utils\@TSPLIB\convert2LatLon.m + ${PROJECT_ROOT}\chn\+utils\@TSPLIB\findOptimumTourLength.m + ${PROJECT_ROOT}\chn\+utils\@TSPLIB\plot.m + ${PROJECT_ROOT}\chn\+utils\@TSPLIB\problemNames.m + ${PROJECT_ROOT}\chn\+utils\@TSPLIB\TSPLIB.m + ${PROJECT_ROOT}\chn\hopfieldnetOptions.m + ${PROJECT_ROOT}\chn\tsphopfieldnet.m + ${PROJECT_ROOT}\chn\tsphopfieldnetOptions.m + ${PROJECT_ROOT}\chn\tsplib.m - ${PROJECT_ROOT}\TSPFiles + ${PROJECT_ROOT}\data\TSPFiles diff --git a/Hopfield Network Toolbox.prj b/Hopfield Network Toolbox.prj index 6582833..edf2f63 100644 --- a/Hopfield Network Toolbox.prj +++ b/Hopfield Network Toolbox.prj @@ -5,20 +5,23 @@ lucasgarciarodriguez@ucm.es mathinking.github.com A Hopfield Network Toolbox for MATLAB - The Hopfield Network Toolbox can solve combinatorial optimization problems by using Hopfield Neural Networks. The Hopfield Network Toolbox is focused in Continuous Hopfield Networks. + The Hopfield Network Toolbox can solve combinatorial optimization problems by using Hopfield Neural Networks. The Hopfield Network Toolbox is mainly focused in Continuous Hopfield Networks. ${PROJECT_ROOT}\help\html\hopfieldnet.png - 1.1.2 + 2.0 ${PROJECT_ROOT}\Hopfield Network Toolbox.mltbx MATLAB + Simulink Statistics and Machine Learning Toolbox 1 + 2 19 9.2 + 8.9 11.1 @@ -48,10 +51,16 @@ help_source/ Hopfield Net TSP solver_resources/ README.md setup_hopfieldNetwork.m -BuildInstructions.m +BuildInstructions.m +automateTests.m +slprj +tau +Simulations +runMultipleTSPLIBproblems.m +script_runMultipleTSPLIBproblems.m <?xml version="1.0" encoding="utf-8"?> <examples> - <exampleCategory name="Solving the Traveling Salesman Problem using Hopfield Networks"> + <exampleCategory name="Solving the Optimization problems using Hopfield Networks"> <example name="Solving the TSP with cities in Polygon Vertices" type="html"> <file type="source">/help/html/Example_tspUsingRegularPolygons.html</file> <file type="main">/help/Example_tspUsingRegularPolygons.m</file> @@ -78,6 +87,27 @@ BuildInstructions.m <file type="main">/help/Example_tspUsingDistance.m</file> <file type="thumbnail"/> </example> + <example name="Solving a GQKP problem using a Hopfield Network" type="html"> + <file type="source">/help/html/Example_GQKPusingCHN.html</file> + <file type="main">/help/Example_GQKPusingCHN.m</file> + <file type="thumbnail">/help/html/Example_GQKPusingCHN.png</file> + <file type="image">/help/html/Example_GQKPusingCHN_01.png</file> + </example> + </exampleCategory> + <exampleCategory name="Solving Hopfield Networks using Simulink"> + <example name="Solving Discrete Hopfield Networks using Simulink" type="html"> + <file type="source">/help/html/Example_SimulinkDiscrete.html</file> + <file type="main">/help/Example_SimulinkDiscrete.m</file> + <file type="thumbnail">/help/html/Example_SimulinkDiscrete.png</file> + <file type="image">/help/html/Example_SimulinkDiscrete_01.png</file> + <file type="image">/help/html/Example_SimulinkDiscrete_02.png</file> + </example> + <example name="Solving Continuous Hopfield Networks using Simulink" type="html"> + <file type="source">/help/html/Example_SimulinkContinuous.html</file> + <file type="main">/help/Example_SimulinkContinuous.m</file> + <file type="thumbnail">/help/html/Example_SimulinkContinuous.png</file> + <file type="image">/help/html/Example_SimulinkContinuous_01.png</file> + </example> </exampleCategory> <exampleCategory name="Improving Hopfield Network performance when applied to the TSP"> <example name="Reduce the free parameter C" type="html"> @@ -99,6 +129,12 @@ BuildInstructions.m <file type="thumbnail">/help/html/Example_tspDivideConquer.png</file> <file type="image">/help/html/Example_tspDivideConquer_01.png</file> </example> + <example name="CHN as a 2-opt Algorithm" type="html"> + <file type="source">/help/html/Example_tsp2opt.html</file> + <file type="main">/help/Example_tsp2opt.m</file> + <file type="thumbnail">/help/html/Example_tsp2opt.png</file> + <file type="image">/help/html/Example_tsp2opt_01.png</file> + </example> </exampleCategory> </examples> @@ -119,16 +155,12 @@ BuildInstructions.m E:\Users\Lucas\Documents\GitHub\HopfieldNetworkToolbox - ${PROJECT_ROOT}\@hopfieldnet - ${PROJECT_ROOT}\@hopfieldnetwork - ${PROJECT_ROOT}\@tsphopfieldnet - ${PROJECT_ROOT}\@tsphopfieldnetApp - ${PROJECT_ROOT}\@tsplib + ${PROJECT_ROOT}\chn + ${PROJECT_ROOT}\data ${PROJECT_ROOT}\help ${PROJECT_ROOT}\Hopfield Net TSP solver.mlappinstall ${PROJECT_ROOT}\LICENSE ${PROJECT_ROOT}\setup_TSPLIB.m - ${PROJECT_ROOT}\TSPFiles diff --git a/README.md b/README.md index b7fad71..b353e96 100644 --- a/README.md +++ b/README.md @@ -5,13 +5,13 @@ The Continuous Hopfield Network (CHN) is a **recurrent neural network** with an As the Lyapunov function is associated with an objective function of the optimization problem (i.e. the mapping process), the equilibrium, or stable point, helps identify a local optimum for the optimization problem. The dynamics of the CHN is described by a **differential equation**: -![\frac{du}{dt} = - \frac{u}{\Lambda} + T v + i^b](http://mathurl.com/hzhnzj5.png) +![\frac{du}{dt} = - \frac{u}{\lambda} + T v + i^b](http://mathurl.com/ycfv6hhd.png) and the output function is a hyperbolic tangent: ![v_i = g(u_i) = \frac{1}{2} \left( 1 + \tanh \left( \frac{u_i}{u_0} \right) \right), \qquad u_0 > 0](http://mathurl.com/zdeg52h.png) -The existence of an equilibrium point is guaranteed if a Lyapunov or energy function exists. The idea is that the network's Lyapunov function, when ![\Lambda \rightarrow{} \infty](http://mathurl.com/hl2t4by.png), is associated with the cost function to be minimized in the combinatorial problem. +The existence of an equilibrium point is guaranteed if a Lyapunov or energy function exists. The idea is that the network's Lyapunov function, when ![\lambda \rightarrow{} \infty](http://mathurl.com/ydye9fha.png), is associated with the cost function to be minimized in the combinatorial problem. The CHN will solve those combinatorial problems which can be expressed as the constrained minimization of: @@ -37,11 +37,12 @@ Want to contribute? Great! Feel free to fork the repository and contact us for i ## Questions? Open a new Issue and label it as a question. We will get back to you. -## References +## Major References - [Neural computation of decisions in optimization problems](http://www.ams.org/mathscinet-getitem?mr=824597) - [A continuous Hopfield network equilibrium points algorithm](http://www.sciencedirect.com/science/article/pii/S0305054804000243) - [Parameter setting of the Hopfield network applied to TSP](http://www.sciencedirect.com/science/article/pii/S0893608002000217) - [Improving the Hopfield model performance when applied to the traveling salesman problem: A divide-and-conquer scheme](http://link.springer.com/article/10.1007/s00500-016-2039-8) + - [Attractor basin analysis of the Hopfield model: The Generalized Quadratic Knapsack Problem. In International Work-Conference on Artificial Neural Networks (2017)](https://link.springer.com/chapter/10.1007%2F978-3-319-59153-7_37) ## Contact us Send us an [Email](mailto:lucasgarciarodriguez@ucm.es) with your comments/suggestions. diff --git a/chn/+apps/@HopfieldNetworkTSPApp/HopfieldNetworkTSPApp.m b/chn/+apps/@HopfieldNetworkTSPApp/HopfieldNetworkTSPApp.m index fb584d9..e996dce 100644 --- a/chn/+apps/@HopfieldNetworkTSPApp/HopfieldNetworkTSPApp.m +++ b/chn/+apps/@HopfieldNetworkTSPApp/HopfieldNetworkTSPApp.m @@ -26,7 +26,8 @@ tabOtherCoordinates; tabOtherDistance; - simulation; + simulation; + schemeMenu; simFcnMenu; ExecutionEnvironment; @@ -83,7 +84,7 @@ function app = HopfieldNetworkTSPApp() createFigure(app); defaultSettings(app); - drawnow nocallbacks; +% drawnow; app.figure.Visible = 'on'; end end @@ -100,9 +101,13 @@ cb_parameterCEdit(app); cb_findTour(app); cb_simFcn(app); + cb_scheme(app); timeElapsed(app,obj,event); cleanState(app); createTspHopfieldNet(app,varargin); updateTspHopfieldNet(app,C); + problemIsSelected = verifyProblemIsSelected(app); + cb_closeApp(app); end + end diff --git a/chn/+apps/@HopfieldNetworkTSPApp/cb_closeApp.m b/chn/+apps/@HopfieldNetworkTSPApp/cb_closeApp.m new file mode 100644 index 0000000..7866e01 --- /dev/null +++ b/chn/+apps/@HopfieldNetworkTSPApp/cb_closeApp.m @@ -0,0 +1,14 @@ +function cb_closeApp(app,~) + + selection = questdlg('Close Hopfield Net TSP solver App?',... + 'Close App?',... + 'Yes','No','Yes'); + switch selection + case 'Yes' + warning('on','tsphopfieldnet:NotSimulated'); + warning('on','MATLAB:MKDIR:DirectoryExists'); + delete(app.figure); + case 'No' + return; + end +end \ No newline at end of file diff --git a/chn/+apps/@HopfieldNetworkTSPApp/cb_findTour.m b/chn/+apps/@HopfieldNetworkTSPApp/cb_findTour.m index f50efd3..a51b00b 100644 --- a/chn/+apps/@HopfieldNetworkTSPApp/cb_findTour.m +++ b/chn/+apps/@HopfieldNetworkTSPApp/cb_findTour.m @@ -18,15 +18,9 @@ function cb_findTour(app,~) end end -if app.simFcnMenu.Value == 1 - msgbox('Please choose an algorithm for the Hopfield Network simulation', 'Error', 'error'); +if app.schemeMenu.Value == 1 + msgbox('Please choose a scheme for the Hopfield Network simulation', 'Error', 'error'); return; -else - algorithms = app.simFcnMenu.String; - setSimFcn(app.net,algorithms{app.simFcnMenu.Value}); - if strcmp(algorithms{app.simFcnMenu.Value},'divide-conquer') - setCities(app.net,'Tau',max(3,round(getTrainParam(app.net,'N')/10))); %#TODO Bring to APP - end end u0 = str2double(app.settings_u0Edit.String); @@ -35,6 +29,7 @@ function cb_findTour(app,~) dt = str2double(app.settings_dtEdit.String); e = str2double(app.settings_eEdit.String); q = str2double(app.settings_qEdit.String); +tau = str2double(app.cities_tauEdit.String); try setSetting(app.net,'U0',u0) @@ -43,6 +38,7 @@ function cb_findTour(app,~) setSetting(app.net,'Dt',dt) setSetting(app.net,'E',e) setSetting(app.net,'Q',q) + setCities(app.net,'Tau',tau) catch me msgbox(me.message) return; diff --git a/chn/+apps/@HopfieldNetworkTSPApp/cb_scheme.m b/chn/+apps/@HopfieldNetworkTSPApp/cb_scheme.m new file mode 100644 index 0000000..78c2b41 --- /dev/null +++ b/chn/+apps/@HopfieldNetworkTSPApp/cb_scheme.m @@ -0,0 +1,37 @@ +function cb_scheme(app,~) + + problemIsSelected = verifyProblemIsSelected(app); + if ~problemIsSelected + msgbox('Please select first the problem to solve', 'Error', 'error'); + app.schemeMenu.Value = 1; + return; + end + schemes = app.schemeMenu.String; + + chosenScheme = schemes{app.schemeMenu.Value}; + + if strncmp(chosenScheme,'divide-conquer',14) + app.cities_tauEdit.Enable = 'on'; + tau = max(3,round(getTrainParam(app.net,'N')/10)); + setCities(app.net,'Tau',tau); + app.cities_tauEdit.String = num2str(tau); + + train(app.net); + trainParams = getTrainParam(app.net); + + app.parameterAEdit.String = num2str(trainParams.A); + app.parameterBEdit.String = num2str(trainParams.B); + app.parameterDEdit.String = num2str(1/trainParams.dUaux); + + app.parameterNEdit.String = num2str(trainParams.N); + app.parameterNpEdit.String = num2str(trainParams.Np); + app.cities_tauEdit.String = num2str(getCities(app.net,'Tau')); + else + app.cities_tauEdit.Enable = 'off'; + end + + if ~isempty(app.net) && ~strcmp(chosenScheme,'Scheme') + setScheme(app.net, chosenScheme) + end + +end diff --git a/chn/+apps/@HopfieldNetworkTSPApp/cb_simFcn.m b/chn/+apps/@HopfieldNetworkTSPApp/cb_simFcn.m index b36bbb7..91f9595 100644 --- a/chn/+apps/@HopfieldNetworkTSPApp/cb_simFcn.m +++ b/chn/+apps/@HopfieldNetworkTSPApp/cb_simFcn.m @@ -1,21 +1,32 @@ function cb_simFcn(app,~) + problemIsSelected = verifyProblemIsSelected(app); + if ~problemIsSelected + msgbox('Please select first the problem to solve', 'Error', 'error'); + app.simFcnMenu.Value = 1; + return; + end + if app.schemeMenu.Value == 1 + msgbox('Please select first the Hopfield Network scheme to solve the problem', 'Error', 'error'); + app.simFcnMenu.Value = 1; + return; + end + algorithms = app.simFcnMenu.String; - chosenAlgorithm = algorithms(app.simFcnMenu.Value); + chosenAlgorithm = algorithms{app.simFcnMenu.Value}; app.elapsedTime.String = ''; - - if strcmp(chosenAlgorithm,'euler') + + if strcmp(chosenAlgorithm,'euler') || strcmp(chosenAlgorithm,'runge-kutta') app.settings_u0Edit.Enable = 'on'; app.settings_dtEdit.Enable = 'on'; app.settings_maxIterEdit.Enable = 'on'; app.settings_eEdit.Enable = 'on'; app.settings_R_ITEREdit.Enable = 'on'; app.settings_qEdit.Enable = 'on'; - app.cities_tauEdit.Enable = 'off'; if ~isempty(app.net) - setSimFcn(app.net,'euler') + setSimFcn(app.net,chosenAlgorithm) end elseif strcmp(chosenAlgorithm,'talavan-yanez') @@ -25,23 +36,9 @@ function cb_simFcn(app,~) app.settings_eEdit.Enable = 'on'; app.settings_R_ITEREdit.Enable = 'on'; app.settings_qEdit.Enable = 'on'; - app.cities_tauEdit.Enable = 'off'; if ~isempty(app.net) setSimFcn(app.net,'talavan-yanez') - end - - elseif strcmp(chosenAlgorithm,'divide-conquer') - app.settings_u0Edit.Enable = 'on'; - app.settings_dtEdit.Enable = 'off'; - app.settings_maxIterEdit.Enable = 'on'; - app.settings_eEdit.Enable = 'on'; - app.settings_R_ITEREdit.Enable = 'on'; - app.settings_qEdit.Enable = 'on'; - app.cities_tauEdit.Enable = 'on'; - if ~isempty(app.net) - setSimFcn(app.net,'divide-conquer') - end - + end else app.settings_u0Edit.Enable = 'off'; app.settings_dtEdit.Enable = 'off'; @@ -49,7 +46,6 @@ function cb_simFcn(app,~) app.settings_eEdit.Enable = 'off'; app.settings_R_ITEREdit.Enable = 'off'; app.settings_qEdit.Enable = 'off'; - app.cities_tauEdit.Enable = 'off'; end - + end diff --git a/chn/+apps/@HopfieldNetworkTSPApp/cb_tabPolygonNcities.m b/chn/+apps/@HopfieldNetworkTSPApp/cb_tabPolygonNcities.m index 7511ba3..4ef620d 100644 --- a/chn/+apps/@HopfieldNetworkTSPApp/cb_tabPolygonNcities.m +++ b/chn/+apps/@HopfieldNetworkTSPApp/cb_tabPolygonNcities.m @@ -1,5 +1,5 @@ function cb_tabPolygonNcities(app) - + N = str2double(app.tabPolygonnCitiesEdit.String); if isnan(N) || N < 2 msgbox('You must provide a value for number of cities greater than 2', 'Error', 'error'); diff --git a/chn/+apps/@HopfieldNetworkTSPApp/cb_tabTSPLIBmenu.m b/chn/+apps/@HopfieldNetworkTSPApp/cb_tabTSPLIBmenu.m index 48979b2..eeebe60 100644 --- a/chn/+apps/@HopfieldNetworkTSPApp/cb_tabTSPLIBmenu.m +++ b/chn/+apps/@HopfieldNetworkTSPApp/cb_tabTSPLIBmenu.m @@ -3,6 +3,10 @@ function cb_tabTSPLIBmenu(app) problems = app.tabTSPLIBmenu.String; problemSelected = app.tabTSPLIBmenu.Value; +app.schemeMenu.Value = 1; +app.simFcnMenu.Value = 1; +app.cities_tauEdit.Enable = 'off'; + % Useful for problems that take longer to compute tsplib % and training app.tabTSPLIBnCitiesEdit.String = '- - - '; diff --git a/chn/+apps/@HopfieldNetworkTSPApp/cleanState.m b/chn/+apps/@HopfieldNetworkTSPApp/cleanState.m index 0703e46..dc97d9a 100644 --- a/chn/+apps/@HopfieldNetworkTSPApp/cleanState.m +++ b/chn/+apps/@HopfieldNetworkTSPApp/cleanState.m @@ -8,6 +8,9 @@ function cleanState(app) defaultSettings(app); + app.simFcnMenu.Value = 1; + app.schemeMenu.Value = 1; + app.settings_u0Edit.Enable = 'off'; app.settings_dtEdit.Enable = 'off'; app.settings_maxIterEdit.Enable = 'off'; diff --git a/chn/+apps/@HopfieldNetworkTSPApp/createFigure.m b/chn/+apps/@HopfieldNetworkTSPApp/createFigure.m index 2c697a4..3682081 100644 --- a/chn/+apps/@HopfieldNetworkTSPApp/createFigure.m +++ b/chn/+apps/@HopfieldNetworkTSPApp/createFigure.m @@ -1,7 +1,9 @@ function createFigure(app) - app.figure = figure; - app.figure.Visible = 'off'; + warning('off','tsphopfieldnet:NotSimulated'); + warning('off','MATLAB:MKDIR:DirectoryExists'); + + app.figure = figure('Visible','off'); app.figure.ToolBar = 'None'; app.figure.MenuBar = 'None'; app.figure.Units = 'normalized'; @@ -11,6 +13,7 @@ function createFigure(app) app.figure.Resize = 'on'; app.figure.HandleVisibility = 'off'; app.figure.Name = 'Hopfield Net TSP solver App'; + app.figure.CloseRequestFcn = @(src,evt)cb_closeApp(app); problems = utils.TSPLIB.problemNames(true,false); @@ -131,7 +134,7 @@ function createFigure(app) app.tabOtherChooseFromWs.FontUnits = 'normalized'; app.tabOtherChooseFromWs.FontSize = 0.15; app.tabOtherChooseFromWs.Callback = @(~,~) cb_tabOtherChooseFromWs(app); - app.tabOtherChooseFromWs.String = 'Choose from workspace'; + app.tabOtherChooseFromWs.String = {'Choose from workspace'}; % ---- Simulation ---- % app.simulation = uibuttongroup(app.figure); @@ -142,14 +145,23 @@ function createFigure(app) app.simulation.FontAngle = 'italic'; app.simulation.FontWeight = 'bold'; + app.schemeMenu = uicontrol(app.simulation,'Style','popupmenu'); + app.schemeMenu.Units = 'normalized'; + app.schemeMenu.Position = [0.1,0.85,0.45,0.1]; + app.schemeMenu.FontSize = 8; + app.schemeMenu.FontUnits = 'normalized'; + app.schemeMenu.String = ' '; + app.schemeMenu.Callback = @(~,~)cb_scheme(app); + app.schemeMenu.String = {'Scheme';'classic';'classic&2opt';'divide-conquer';'divide-conquer&2opt'}; + app.simFcnMenu = uicontrol(app.simulation,'Style','popupmenu'); app.simFcnMenu.Units = 'normalized'; - app.simFcnMenu.Position = [0.1,0.85,0.8,0.1]; - app.simFcnMenu.FontSize = 9; + app.simFcnMenu.Position = [0.575,0.85,0.325,0.1]; + app.simFcnMenu.FontSize = 8; app.simFcnMenu.FontUnits = 'normalized'; app.simFcnMenu.String = ' '; app.simFcnMenu.Callback = @(~,~)cb_simFcn(app); - app.simFcnMenu.String = {'Algorithm';'euler';'talavan-yanez';'divide-conquer'}; + app.simFcnMenu.String = {'Algorithm';'euler';'runge-kutta';'talavan-yanez'}; app.ExecutionEnvironment = uibuttongroup(app.simulation); app.ExecutionEnvironment.Units = 'normalized'; @@ -228,7 +240,7 @@ function createFigure(app) app.settings_maxIter.Units = 'normalized'; app.settings_maxIter.Position = [0.05,0.52,0.25,0.15]; app.settings_maxIter.FontUnits = 'normalized'; - app.settings_maxIter.String = 'maxIter'; + app.settings_maxIter.String = 'MaxIter'; app.settings_maxIter.HorizontalAlignment = 'right'; app.settings_maxIterEdit = uicontrol(app.settings,'Style','edit'); diff --git a/chn/+apps/@HopfieldNetworkTSPApp/createTspHopfieldNet.m b/chn/+apps/@HopfieldNetworkTSPApp/createTspHopfieldNet.m index d3b370c..8659085 100644 --- a/chn/+apps/@HopfieldNetworkTSPApp/createTspHopfieldNet.m +++ b/chn/+apps/@HopfieldNetworkTSPApp/createTspHopfieldNet.m @@ -43,7 +43,7 @@ function createTspHopfieldNet(app,varargin) end app.parameterNEdit.String = num2str(trainParams.N); app.parameterNpEdit.String = num2str(trainParams.Np); - app.cities_tauEdit.String = num2str(round(getTrainParam(app.net,'N')/10)); + app.cities_tauEdit.String = num2str(getCities(app.net,'Tau')); plot(app.net,'empty',[],app.plot); diff --git a/chn/+apps/@HopfieldNetworkTSPApp/verifyProblemIsSelected.m b/chn/+apps/@HopfieldNetworkTSPApp/verifyProblemIsSelected.m new file mode 100644 index 0000000..29b2d1b --- /dev/null +++ b/chn/+apps/@HopfieldNetworkTSPApp/verifyProblemIsSelected.m @@ -0,0 +1,12 @@ +function problemIsSelected = verifyProblemIsSelected(app) + + problemIsSelected = true; + if isequal(app.tabgroup.SelectedTab,app.tabTSPLIB) && app.tabTSPLIBmenu.Value == 1 + problemIsSelected = false; + elseif isequal(app.tabgroup.SelectedTab,app.tabPolygon) && isnan(str2double(app.tabPolygonnCitiesEdit.String)) + problemIsSelected = false; + elseif isequal(app.tabgroup.SelectedTab,app.tabOther) && strcmp(app.tabOtherChooseFromWs.String{app.tabOtherChooseFromWs.Value},'Choose from workspace') + problemIsSelected = false; + end + +end \ No newline at end of file diff --git a/chn/+network/@HopfieldNetworkGQKP/HopfieldNetworkGQKP.m b/chn/+network/@HopfieldNetworkGQKP/HopfieldNetworkGQKP.m index 183e896..932672e 100644 --- a/chn/+network/@HopfieldNetworkGQKP/HopfieldNetworkGQKP.m +++ b/chn/+network/@HopfieldNetworkGQKP/HopfieldNetworkGQKP.m @@ -129,4 +129,8 @@ methods (Hidden = false, Access = protected) net = init(net); end + methods (Hidden = false, Access = public) + energyplot(net,varargin) + end + end diff --git a/chn/+network/@HopfieldNetworkGQKP/energyplot.m b/chn/+network/@HopfieldNetworkGQKP/energyplot.m new file mode 100644 index 0000000..e9b03d4 --- /dev/null +++ b/chn/+network/@HopfieldNetworkGQKP/energyplot.m @@ -0,0 +1,22 @@ +function energyplot(net,varargin) + if nargin > 1 + ax = varargin{1}; + else + ax = []; + end + if net.Results.ValidSolution + if isempty(ax) + ax = gca; + end + toBePlotted = 1:net.Results.ItersReached-1; + plot(ax,net.Results.Time(toBePlotted), net.Results.Energy(toBePlotted), '.b-'); + title(ax,'Energy Function'); + if nargin == 1 + xlabel(ax,'Time'); + end + axis(ax,'tight') + ylim([min(net.Results.Energy(toBePlotted)), max(net.Results.Energy(toBePlotted))]) + else + error('tsphopfieldnet:energyplot','Unvalid energy results. Possibly no path has been found or training has not taken place yet.'); + end +end diff --git a/chn/+network/@HopfieldNetworkGQKP/sim.m b/chn/+network/@HopfieldNetworkGQKP/sim.m index 713181b..1100928 100644 --- a/chn/+network/@HopfieldNetworkGQKP/sim.m +++ b/chn/+network/@HopfieldNetworkGQKP/sim.m @@ -22,7 +22,7 @@ if ~isempty(net.Setting.CheckpointPath) net.Results.CheckpointFilename = ... - utils.checkpoint.createFilename(net.Setting.CheckpointPath,net.SimFcn); + utils.checkpoint.createFilename(net.Setting.CheckpointPath,net.Scheme,net.SimFcn); else net.Results.CheckpointFilename = ''; end @@ -35,20 +35,35 @@ end % Classic Scheme support only - if strcmp(net.SimFcn,'euler') - [net,V,~,iter] = simEuler(net,V,U,isSaddle); - - elseif strcmp(net.SimFcn,'talavan-yanez') - [net,V,~,iter] = simTalavanYanez(net,V,U,isSaddle); + switch net.SimFcn + case 'euler' + [net,V,~,iter] = simEuler(net,V,U,isSaddle); + case 'runge-kutta' + [net,V,~,iter] = simRungeKutta(net,V,U,isSaddle); + case 'talavan-yanez' + [net,V,~,iter] = simTalavanYanez(net,V,U,isSaddle); + otherwise % Shouldn't be reached by users + error('HopfieldNetworkGQKP:InvalidSimFcn', ... + 'Make sure you provide a valid SimFcn function by using ''hopfieldnetOptions'' or ''options.HopfieldNetworkGQKPOptions''.'); end - net = computeSolution(net,V,iter); + + [net,V] = computeSolution(net,V,iter); net.Results.CompTime = toc(timeID); end +% Euler Simulation Algorithm +function [net,V,U,iter] = simEuler(net, V, U, isSaddle) + [net,V,U,iter] = simODE(net,V,U,isSaddle); +end -% Euler Algorithm -function [net,V,U,iter] = simEuler(net,V,U,isSaddle) +% Runge-Kutta Simulation Algorithm +function [net,V,U,iter] = simRungeKutta(net,V,U,isSaddle) + [net,V,U,iter] = simODE(net,V,U,isSaddle); +end + +% ODE Simulation Algorithm (used by Euler and Runge-Kutta) +function [net,V,U,iter] = simODE(net,V,U,isSaddle) % Stopping criteria stopC1 = power(10, -1 * net.Setting.E); @@ -83,22 +98,42 @@ end dt = net.Setting.Dt; - net.Results.Time(iter) = dt; + net.Results.Energy(iter) = NaN; maxDiffV = 1; while iter <= net.Setting.MaxIter && (maxDiffV > stopC1 || ... (maxDiffV > stopC2 && unstable)) unstable = false; - net.Results.Energy(iter+1) = 0; - dU = T*V + ib; + if strcmp(net.SimFcn,'euler') + dU = (T*V + ib)*net.Setting.Dt; + elseif strcmp(net.SimFcn,'runge-kutta') + S1 = computeSi(V,T,ib,net.Setting.Dt); + S2 = computeSi(net.Setting.TransferFcn(U + S1/2),T,ib,net.Setting.Dt/2); + S3 = computeSi(net.Setting.TransferFcn(U + S2/2),T,ib,net.Setting.Dt/2); + S4 = computeSi(net.Setting.TransferFcn(U + S3),T,ib,net.Setting.Dt); + + dU = 1/6*S1 + 1/3*S2 + 1/3*S3 + 1/6*S4; + else + error('HopfieldNetworkGQKP:sim:simODE:UnknownSimFcn',... + 'Unknown simulation method') + end + Vprev = V; - U = U + dU * net.Setting.Dt; + U = U + dU; %Dt already included in dU V = net.Setting.TransferFcn(U); maxDiffV = max(abs(Vprev-V)); + % Energy update + if strcmp(net.Setting.ExecutionEnvironment,'gpu') + net.Results.Energy(iter+1) = gather(-0.5 * sum(sum(V'.*T*V)) - sum(sum((V'*ib)))); + else + net.Results.Energy(iter+1) = -0.5 * sum(sum(V'.*T*V)) - sum(sum((V'*ib))); + end + net.Results.Time(iter+1) = net.Results.Time(iter) + ... + net.Setting.Dt; iter = iter + 1; if ~isSaddle % Logging Checkpoint and plotting Simulation process @@ -323,11 +358,21 @@ end -function net = computeSolution(net,V,iter) +% --- Auxiliar Functions for Simulation Algorithms --- % +function Si = computeSi(S,T,ib,Dt) + Si = (T*S + ib) * Dt; +end + +function [net,V] = computeSolution(net,V,iter) V(V > 1 - power(10, -1 * net.Setting.E)) = 1; V(V < power(10, -1 * net.Setting.E)) = 0; + if strcmp(net.SimFcn,'euler') || strcmp(net.SimFcn,'runge-kutta')% More relaxed criteria + V(V > 0.99) = 1; + V(V < 0.01) = 0; + end + if isequal(net.ProblemParameters.R*V,net.ProblemParameters.b) net.Results.ValidSolution = true; net.Results.ExitFlag = 1; diff --git a/chn/+network/@HopfieldNetworkGQKP/train.m b/chn/+network/@HopfieldNetworkGQKP/train.m index 1c7b7b8..2bb715f 100644 --- a/chn/+network/@HopfieldNetworkGQKP/train.m +++ b/chn/+network/@HopfieldNetworkGQKP/train.m @@ -33,7 +33,7 @@ % T = -(alpha * P + R'*Phi*R - 2*diag(gamma)); net.TrainParam.T = -(net.TrainParam.alpha * net.ProblemParameters.P + net.ProblemParameters.R'*net.TrainParam.Phi*net.ProblemParameters.R - 2*net.TrainParam.gamma); - % ib = -(alpha * q + R'*beta + gamma); + % ib = -(alpha * q + R'*beta + diag(gamma)); net.TrainParam.ib = -(net.TrainParam.alpha * net.ProblemParameters.q + net.ProblemParameters.R'*net.TrainParam.beta + diag(net.TrainParam.gamma)); end diff --git a/chn/+network/@HopfieldNetworkTSP/HopfieldNetworkTSP.m b/chn/+network/@HopfieldNetworkTSP/HopfieldNetworkTSP.m index 5af3db4..3c75b4d 100644 --- a/chn/+network/@HopfieldNetworkTSP/HopfieldNetworkTSP.m +++ b/chn/+network/@HopfieldNetworkTSP/HopfieldNetworkTSP.m @@ -63,7 +63,6 @@ methods (Hidden = true, Access = private) net = setOptions(net,options); [net,V,U] = fixedCities(net); - thisCity = city(net,cityPosition); [modifiedDistance,Ng] = neighbourDistance(net, tau_or_p); end @@ -73,6 +72,7 @@ methods (Hidden = true, Access = public) net = reinit(net); + thisCity = city(net,cityPosition); end methods (Static = true, Hidden = true, Access = private) diff --git a/chn/+network/@HopfieldNetworkTSP/energyplot.m b/chn/+network/@HopfieldNetworkTSP/energyplot.m index 5c348a4..970593a 100644 --- a/chn/+network/@HopfieldNetworkTSP/energyplot.m +++ b/chn/+network/@HopfieldNetworkTSP/energyplot.m @@ -6,20 +6,19 @@ function energyplot(net,varargin) end if net.Results.ValidPath if isempty(ax) - figure; + ax = axes; end - toBePlotted = ~isnan(net.Results.Energy) & net.Results.Time < 10^100; - if isempty(ax) - semilogy(net.Results.Time(toBePlotted), net.Results.Energy(toBePlotted), '.b-'); - title('Energy Function'); - xlabel('Time'); - axis tight; - else - semilogy(ax,net.Results.Time(toBePlotted), net.Results.Energy(toBePlotted), '.b-'); - title(ax,'Energy Function'); - % xlabel(ax,'Time'); - axis(ax,'tight') - end + toBePlotted = ~isnan(net.Results.Energy) & net.Results.Time < 10^5; + if ~isempty(varargin) + toBePlotted(1) = 0; % Not plotting t = 0 + end + plot(ax,net.Results.Time(toBePlotted), net.Results.Energy(toBePlotted), '.b-'); + title(ax,'Energy Function'); + if nargin == 1 + xlabel(ax,'Time'); + end + axis(ax,'tight') + ylim(ax, [min(net.Results.Energy(toBePlotted)), max(net.Results.Energy(toBePlotted))]) else error('tsphopfieldnet:energyplot','Unvalid energy results. Possibly no path has been found or training has not taken place yet.'); end diff --git a/chn/+network/@HopfieldNetworkTSP/plot.m b/chn/+network/@HopfieldNetworkTSP/plot.m index 30002bb..5fadf0b 100644 --- a/chn/+network/@HopfieldNetworkTSP/plot.m +++ b/chn/+network/@HopfieldNetworkTSP/plot.m @@ -97,13 +97,14 @@ function plot(net, type, chains, ax, varargin) error('tsphopfieldnet:UnvalidPath','Unvalid TSP Path'); end if ~isempty(myTitle) - title(ax,['\bf', myTitle]); + title(ax, myTitle, 'Interpreter', 'latex'); else title(ax,['\bf Tour length: ', num2str(net.Results.TourLength)]); end end adjustPlot(h,coords); + axis(ax,'equal'); end function adjustPlot(h,coords) diff --git a/chn/+network/@HopfieldNetworkTSP/saddle.m b/chn/+network/@HopfieldNetworkTSP/saddle.m index efa575f..c883ce3 100644 --- a/chn/+network/@HopfieldNetworkTSP/saddle.m +++ b/chn/+network/@HopfieldNetworkTSP/saddle.m @@ -22,7 +22,7 @@ for i = 1:net.TrainParam.K JK(2*i-1:2*i,2*i-1:2*i) = ones(2) - eye(2); end - DK = net.Cities.DistanceMatrix * JK; + DK = JK * net.Cities.DistanceMatrix; DK(logical(I)) = 0; IK = (net.TrainParam.K > 0) * JK + I; diff --git a/chn/+network/@HopfieldNetworkTSP/setOptions.m b/chn/+network/@HopfieldNetworkTSP/setOptions.m index 637b576..9f91e85 100644 --- a/chn/+network/@HopfieldNetworkTSP/setOptions.m +++ b/chn/+network/@HopfieldNetworkTSP/setOptions.m @@ -95,7 +95,8 @@ if isempty(opts.Cities.Tau) && ~strcmp(opts.SimFcn,'divide-conquer') net.Cities.Tau = net.TrainParam.N - 1; end - + net.Cities.PlotPhases = opts.Cities.PlotPhases; + net.Cities = orderfields(net.Cities); end diff --git a/chn/+network/@HopfieldNetworkTSP/sim.m b/chn/+network/@HopfieldNetworkTSP/sim.m index 83b4d3d..467c225 100644 --- a/chn/+network/@HopfieldNetworkTSP/sim.m +++ b/chn/+network/@HopfieldNetworkTSP/sim.m @@ -1,6 +1,6 @@ function V = sim(net,V,U,isSaddle) - if nargin == 1 % Start in the center of the Hypercube. Replace for saddle? + if nargin == 1 % Start in the center of the Hypercube. Replace for saddle in a future release U = rand(net.TrainParam.N,net.TrainParam.N-net.TrainParam.K)-.5; V = 0.5 + 1e-7*U; elseif nargin == 2 @@ -22,7 +22,7 @@ if ~isempty(net.Setting.CheckpointPath) net.Results.CheckpointFilename = ... - utils.checkpoint.createFilename(net.Setting.CheckpointPath,net.SimFcn); + utils.checkpoint.createFilename(net.Setting.CheckpointPath,net.Scheme,net.SimFcn); else net.Results.CheckpointFilename = ''; @@ -98,23 +98,22 @@ otherwise % Shouldn't be reached by users error('HopfieldNetworkTSP:InvalidSimFcn', ... - 'Make sure you provide a valid SimFcn function by using ''tsphopfieldnet'' or ''options.HopfieldNetworkOptionsTSP''.'); + 'Make sure you provide a valid SimFcn function by using ''tsphopfieldnet'' or ''options.HopfieldNetworkTSPOptions''.'); end end function [net,V,U,iter] = schemeDivideConquer(net,V,U) % Determine weather to plot the two phases of the problem. Consider % bringing this to createOptions - plotPhases = false; myPlot.myCitiesColorP1 = [0.8,0.8,0.8]; myPlot.myCitiesTextColor = [0,0,0]; myPlot.myInsideColorP1 = [0,0,0.8]; - myPlot.myTitleP1 = 'Divide and Conquer. Phase 1 problem (TSP_1^{\tau})'; + myPlot.myTitleP1 = 'Divide and Conquer. Phase 1 problem $(TSP_1^{\tau})$'; myPlot.myCitiesColorP2 = [1,0,0]; myPlot.myInsideColorP2 = [0.8,0.8,0.8]; myPlot.myCitiesTextColor = [0,0,0]; - myPlot.myTitleP2 = 'Divide and Conquer. Phase 2 problem (TSP_2^{*})'; - myPlot.myTitle = 'Divide and Conquer. TSP_1^{\tau} + TSP_2^{*}'; + myPlot.myTitleP2 = 'Divide and Conquer. Phase 2 problem $(TSP_2^{k})$'; + myPlot.myTitle = 'Divide and Conquer. $TSP_1^{\tau} + TSP_2^{k}$'; % The Phase 1 problem. TSP^tau_1 % 2 possible methods: @@ -126,16 +125,16 @@ V = saddle(net) + (rand(net.TrainParam.N) - 0.5) * 1e-5; U = net.Setting.InvTransferFcn(V); end - [chains,V] = simDivideConquerPhase1(net,V,U,plotPhases,myPlot); + [chains,V] = simDivideConquerPhase1(net,V,U,myPlot); % Reached max number of iterations if net.Results.ExitFlag == 0 mkdir('Phase1_InsuficientIterations'); save(fullfile(pwd,'Phase1_InsuficientIterations',regexprep(datestr(datetime),{':',' ','-'},'_'))) while net.Results.ExitFlag <= 0 - V = V + (rand(net.TrainParam.N) - 0.5) * 1e-5; + V = max(0,V + (rand(net.TrainParam.N) - 0.5) * 1e-5); U = net.Setting.InvTransferFcn(V); - [chains,V] = simDivideConquerPhase1(net,V,U,plotPhases,myPlot); + [chains,V] = simDivideConquerPhase1(net,V,U,myPlot); end % Possible saddle point reached @@ -143,9 +142,9 @@ mkdir('Phase1_PossibleSaddlePoint'); save(fullfile(pwd,'Phase1_PossibleSaddlePoint',regexprep(datestr(datetime),{':',' ','-'},'_'))) while net.Results.ExitFlag <= 0 - V = V + (rand(net.TrainParam.N) - 0.5) * 1e-5; + V = max(0,V + (rand(net.TrainParam.N) - 0.5) * 1e-5); U = net.Setting.InvTransferFcn(V); - [chains,V] = simDivideConquerPhase1(net,V,U,plotPhases,myPlot); + [chains,V] = simDivideConquerPhase1(net,V,U,myPlot); end end % TODO Add correct number of iterations @@ -163,7 +162,7 @@ % a. fixing cities % b. using new distance % c. connecting subtours with greedy - [netPhase2,V2] = simDivideConquerPhase2(net,chains,plotPhases,myPlot); + [netPhase2,V2] = simDivideConquerPhase2(net,chains,myPlot); % Building final V V = zeros(net.TrainParam.N); iNew = 1; @@ -172,9 +171,9 @@ % Reached max number of iterations if netPhase2.Results.ExitFlag == 0 mkdir('Phase2_InsuficientIterations'); - save(fullfile(pwd,'Phase2_InsuficientIterations',regexprep(datestr(datetime),{':',' ','-'},'_'))) + save(fullfile(pwd,'Phase2_InsuficientIterations',['tau_',num2str(net.Cities.Tau),'_',regexprep(datestr(datetime),{':',' ','-'},'_'),'_rand',num2str(randi(net.TrainParam.N))])) while netPhase2.Results.ExitFlag <= 0 - V2 = V2 + (rand(netPhase2.TrainParam.N,netPhase2.TrainParam.N-netPhase2.TrainParam.K) - 0.5) * 1e-5; + V2 = max(0,V2 + (rand(netPhase2.TrainParam.N,netPhase2.TrainParam.N-netPhase2.TrainParam.K) - 0.5) * 1e-5); U = netPhase2.Setting.InvTransferFcn(V2); V2 = sim(netPhase2, V2, U); end @@ -182,10 +181,10 @@ % Possible saddle point reached elseif netPhase2.Results.ExitFlag == -1 mkdir('Phase2_PossibleSaddlePoint'); - save(fullfile(pwd,'Phase2_PossibleSaddlePoint',regexprep(datestr(datetime),{':',' ','-'},'_'))) + save(fullfile(pwd,'Phase2_PossibleSaddlePoint',['tau_',num2str(net.Cities.Tau),'_',regexprep(datestr(datetime),{':',' ','-'},'_'),'_rand',num2str(randi(net.TrainParam.N))])) % Stuck in a saddle point. Perturbation required. while netPhase2.Results.ExitFlag <= 0 - V2 = V2 + (rand(netPhase2.TrainParam.N,netPhase2.TrainParam.N-netPhase2.TrainParam.K) - 0.5) * 1e-5; + V2 = max(0,V2 + (rand(netPhase2.TrainParam.N,netPhase2.TrainParam.N-netPhase2.TrainParam.K) - 0.5) * 1e-5); U = netPhase2.Setting.InvTransferFcn(V2); V2 = sim(netPhase2, V2, U); end @@ -222,7 +221,7 @@ U = net.Setting.InvTransferFcn(V); iter = net.Results.ItersReached + netPhase2.Results.ItersReached - 1; - if plotPhases + if net.Cities.PlotPhases if isempty(net.Results.TourLength) %#ok init(net); net = computeTour(net,V,iter); % Needed for plot phase1 + phase2 to output correctly @@ -274,6 +273,26 @@ [net,V,U,iter] = simODE(net,V,U,isSaddle); end +% Runge-Kutta Simulation Algorithm +function [net,V,U,iter] = simRungeKutta(net,V,U,isSaddle) + [net,V,U,iter] = simODE(net,V,U,isSaddle); + +% U = U(:); +% [t,U]=ode45(@(t,u)func(t,U,net.TrainParam.C*net.TrainParam.Np),[0,0.1],U); +% V = net.Setting.TransferFcn(U(end,:)); +% V = reshape(V,net.TrainParam.N,net.TrainParam.N-net.TrainParam.K); +% function dU = func(t,U,ib) +% V = net.Setting.TransferFcn(U); +% V = reshape(V,net.TrainParam.N,net.TrainParam.N-net.TrainParam.K); +% sumVcol = sum(V); +% sumVrow = sum(V,2); +% sumV = sum(sumVcol); +% dU = weightMatrixTimesVvectorized(net, V, sumVrow, sumVcol, sumV) + ib; +% dU = dU(:); +% end + +end + % ODE Simulation Algorithm (used by Euler and Runge-Kutta) function [net,V,U,iter] = simODE(net,V,U,isSaddle) @@ -328,7 +347,7 @@ dU = 1/6*S1 + 1/3*S2 + 1/3*S3 + 1/6*S4; else - error('HopfieldNetTSP:sim:simODE:UnknownSimFcn',... + error('HopfieldNetworkTSP:sim:simODE:UnknownSimFcn',... 'Unknown simulation method') end @@ -347,7 +366,11 @@ sumV = sum(sumVcol); % Energy update - net.Results.Energy(iter+1) = -0.5 * sum(sum(V.*TV)) - sum(sum((V*ib))); + if strcmp(net.Setting.ExecutionEnvironment,'gpu') + net.Results.Energy(iter+1) = gather(-0.5 * sum(sum(V.*TV)) - sum(sum((V*ib)))); + else + net.Results.Energy(iter+1) = -0.5 * sum(sum(V.*TV)) - sum(sum((V*ib))); + end net.Results.Time(iter+1) = net.Results.Time(iter) + ... net.Setting.Dt; iter = iter + 1; @@ -380,25 +403,6 @@ end -% Runge-Kutta Simulation Algorithm -function [net,V,U,iter] = simRungeKutta(net,V,U,isSaddle) - [net,V,U,iter] = simODE(net,V,U,isSaddle); - -% U = U(:); -% [t,U]=ode45(@(t,u)func(t,U,net.TrainParam.C*net.TrainParam.Np),[0,0.1],U); -% V = net.Setting.TransferFcn(U(end,:)); -% V = reshape(V,net.TrainParam.N,net.TrainParam.N-net.TrainParam.K); -% function dU = func(t,U,ib) -% V = net.Setting.TransferFcn(U); -% V = reshape(V,net.TrainParam.N,net.TrainParam.N-net.TrainParam.K); -% sumVcol = sum(V); -% sumVrow = sum(V,2); -% sumV = sum(sumVcol); -% dU = weightMatrixTimesVvectorized(net, V, sumVrow, sumVcol, sumV) + ib; -% dU = dU(:); -% end - -end % Talavn-Yez Simulation Algorithm function [net,V,U,iter] = simTalavanYanez(net,V,U,isSaddle) @@ -605,7 +609,7 @@ end % Divide and Conquer algorithm -function [chains,V] = simDivideConquerPhase1(net,V,U,plotPhases,myPlot) +function [chains,V] = simDivideConquerPhase1(net,V,U,myPlot) p_or_tau = net.Cities.Tau; % Backing up distances @@ -691,8 +695,8 @@ end if ~isempty(chains) - if plotPhases - h = plot(net); + if net.Cities.PlotPhases + plot(net); hold on; end if length(chains) == 1 && length(chains{1}) > net.TrainParam.N @@ -708,13 +712,13 @@ % Consider case with unique chain and all cities included % Visualize Chains - if plotPhases + if net.Cities.PlotPhases plot(net,'phase1',chains,[],myPlot.myCitiesColorP1,myPlot.myCitiesTextColor,myPlot.myInsideColorP1,myPlot.myTitleP1); end end end -function [netPhase2,V] = simDivideConquerPhase2(net,chains,plotPhases,myPlot) +function [netPhase2,V] = simDivideConquerPhase2(net,chains,myPlot) noChains = length(chains); method = 'phase2'; @@ -777,7 +781,7 @@ return; end - if plotPhases + if net.Cities.PlotPhases fixedChainsFromPhase1 = cell(size(chains)); for i = 1:length(fixedChainsFromPhase1) fixedChainsFromPhase1{i} = [2*i-1,2*i]; diff --git a/chn/+options/HopfieldNetworkOptions.m b/chn/+options/HopfieldNetworkOptions.m index d02e437..6099031 100644 --- a/chn/+options/HopfieldNetworkOptions.m +++ b/chn/+options/HopfieldNetworkOptions.m @@ -78,7 +78,7 @@ defaultSettingU0 = 0.3; defaultSettingTransferFcn = 'tanh'; defaultSettingVerbose = false; - defaultSettingVerboseFrequency = NaN; + defaultSettingVerboseFrequency = 25; defaultSettingExecutionEnvironment = 'CPU'; defaultSettingMaxIter = 2000; defaultSettingE = 13; diff --git a/chn/+options/HopfieldNetworkTSPOptions.m b/chn/+options/HopfieldNetworkTSPOptions.m index 8b82290..f29b441 100644 --- a/chn/+options/HopfieldNetworkTSPOptions.m +++ b/chn/+options/HopfieldNetworkTSPOptions.m @@ -91,6 +91,7 @@ defaultCitiesSubtours = ''; defaultCitieSubtoursPositions = []; defaultCitiesTau = []; + defaultCitiesPlotPhases = false; parser.addParameter('TrainFcn', defaultTrainFcn, @opts.iIsChar); parser.addParameter('SimFcn', defaultSimFcn, @opts.iIsChar); @@ -103,6 +104,7 @@ parser.addParameter('Subtours', defaultCitiesSubtours, @opts.iIsCellStr) parser.addParameter('SubtoursPositions', defaultCitieSubtoursPositions, @opts.iIsInteger) parser.addParameter('Tau', defaultCitiesTau, @opts.iIsIntegerScalarGreaterOrEqualThanZero) + parser.addParameter('PlotPhases', defaultCitiesPlotPhases, @opts.iIsScalarAndLogicalOneOrZero); % Parsing remaining options parser.parse(opts.Unmatched); @@ -122,7 +124,8 @@ opts.Cities.Subtours = parser.Results.Subtours; opts.Cities.SubtoursPositions = opts.iMatchWithSubtoursLength(parser.Results.SubtoursPositions, opts.Cities.Subtours); opts.Cities.Tau = parser.Results.Tau; - + opts.Cities.PlotPhases = parser.Results.PlotPhases; + opts.Cities = orderfields(opts.Cities); end end @@ -148,6 +151,12 @@ function tf = iIsRealNumericSquareMatrix(x) tf = options.HopfieldNetworkTSPOptions.iIsRealNumeric(x) && (size(x,1) == size(x,2)); end + function tf = iIsScalarAndLogicalOneOrZero(x) + tf = isscalar(x) && options.HopfieldNetworkTSPOptions.iIsLogicalOneOrZero(x); + end + function tf = iIsLogicalOneOrZero(x) + tf = islogical(x) || (x == 1) || (x == 0); + end function chosenTrainFcn = iMatchWithValidTrainFcn(inputTrainFcn) validTrainFcn = {'trainty'}; diff --git a/chn/+utils/+checkpoint/createFilename.m b/chn/+utils/+checkpoint/createFilename.m index 4c81388..c3b0326 100644 --- a/chn/+utils/+checkpoint/createFilename.m +++ b/chn/+utils/+checkpoint/createFilename.m @@ -1,9 +1,9 @@ -function checkpointFilename = createFilename(checkpointPath,simFcn) +function checkpointFilename = createFilename(checkpointPath,scheme,simFcn) warning('off','MATLAB:MKDIR:DirectoryExists'); mkdir(checkpointPath); warning('on','MATLAB:MKDIR:DirectoryExists'); - checkpointFilename = ['checkpoint_',simFcn,'_',... + checkpointFilename = ['checkpoint_',scheme,'_',simFcn,'_',... datestr(datetime(now,'ConvertFrom','datenum'),... 'yyyy_mm_dd_HH_MM_SS'),'.mat']; diff --git a/chn/+utils/+checkpoint/loggingData.m b/chn/+utils/+checkpoint/loggingData.m index 191683e..13c3d0a 100644 --- a/chn/+utils/+checkpoint/loggingData.m +++ b/chn/+utils/+checkpoint/loggingData.m @@ -5,8 +5,8 @@ function loggingData(checkpointFilename,maxIter,iter,V,dU) Vlog = nan([N,maxIter]); %#ok dUlog = nan([N,maxIter]); %#ok save(checkpointFilename,'Vlog','dUlog','-v7.3'); - V = zeros(N); - dU = zeros(N); +% V = zeros(N); +% dU = zeros(N); end data = matfile(checkpointFilename,'Writable',true); if isa(V,'gpuArray') @@ -16,4 +16,4 @@ function loggingData(checkpointFilename,maxIter,iter,V,dU) data.Vlog(:,:,iter) = V; data.dUlog(:,:,iter) = dU; -end \ No newline at end of file +end diff --git a/chn/+utils/@TSPLIB/tsplib.m b/chn/+utils/@TSPLIB/TSPLIB.m similarity index 99% rename from chn/+utils/@TSPLIB/tsplib.m rename to chn/+utils/@TSPLIB/TSPLIB.m index d57c41c..e3220b7 100644 --- a/chn/+utils/@TSPLIB/tsplib.m +++ b/chn/+utils/@TSPLIB/TSPLIB.m @@ -121,7 +121,7 @@ % --- Methods definitions --- % methods (Hidden = false, Access = public) plot(problem); - [tourLength,optimumTour] = findOptimumTour(problem); + [tourLength,optimumTour] = findOptimumTourLength(problem); end methods (Static = true, Hidden = false, Access = public) diff --git a/chn/+utils/@TSPLIB/findOptimumTour.m b/chn/+utils/@TSPLIB/findOptimumTourLength.m similarity index 90% rename from chn/+utils/@TSPLIB/findOptimumTour.m rename to chn/+utils/@TSPLIB/findOptimumTourLength.m index cd7c78b..d2d4fec 100644 --- a/chn/+utils/@TSPLIB/findOptimumTour.m +++ b/chn/+utils/@TSPLIB/findOptimumTourLength.m @@ -1,4 +1,4 @@ -function [tourLength,optimumTour] = findOptimumTour(problem) +function [tourLength,optimumTour] = findOptimumTourLength(problem) fid = fopen([problem.Name,'.opt.tour'],'rt'); if fid < 0 diff --git a/chn/+utils/@TSPLIB/plot.m b/chn/+utils/@TSPLIB/plot.m index 3051a60..cbc0ed0 100644 --- a/chn/+utils/@TSPLIB/plot.m +++ b/chn/+utils/@TSPLIB/plot.m @@ -31,7 +31,7 @@ function plot(problem) problem.Coordinates(optimTour,2),... dispText,'fontsize',10,... 'color',[0.5,0.5,0.5],'margin',20,'Clipping','on'); - title(['\bf Optimum our length: ',... + title(['\bf Optimum tour length: ',... num2str(optimTourLength)]); hold off; else diff --git a/chn/+utils/@TSPLIB/problemNames.m b/chn/+utils/@TSPLIB/problemNames.m index f5e75b3..1fe9bf7 100644 --- a/chn/+utils/@TSPLIB/problemNames.m +++ b/chn/+utils/@TSPLIB/problemNames.m @@ -1,5 +1,9 @@ function problems = problemNames(hasOptimumTourFile, saveMATfile) +if nargin < 2 + saveMATfile = false; +end + filedir = fileparts(fileparts(which('tsphopfieldnet.m'))); TSPFilesDir = 'TSPFiles'; TSPToursDir = 'TSPTours'; diff --git a/chn/continuousHopfieldNetwork.slx b/chn/continuousHopfieldNetwork.slx new file mode 100644 index 0000000..90ba0d5 Binary files /dev/null and b/chn/continuousHopfieldNetwork.slx differ diff --git a/chn/discreteHopfieldNetwork.slx b/chn/discreteHopfieldNetwork.slx new file mode 100644 index 0000000..7a83b41 Binary files /dev/null and b/chn/discreteHopfieldNetwork.slx differ diff --git a/chn/hopfieldNetworkTSPApp.m b/chn/hopfieldNetworkTSPApp.m new file mode 100644 index 0000000..c2941b3 --- /dev/null +++ b/chn/hopfieldNetworkTSPApp.m @@ -0,0 +1,5 @@ +function hopfieldNetworkTSPApp + +%TODO use verLessThan at some point when redesignign App to use AppDesigner + +app = apps.HopfieldNetworkTSPApp; \ No newline at end of file diff --git a/help/Example_GQKPusingCHN.m b/help/Example_GQKPusingCHN.m new file mode 100644 index 0000000..21136ee --- /dev/null +++ b/help/Example_GQKPusingCHN.m @@ -0,0 +1,63 @@ +%% How to solve a GQKP problem using a Hopfield Network +% The following optimization problem is proposed: +% +% $$\min\{\frac{1}{2}(4v_1^2 - 2v_2^2)\}$$ +% +% subject to: +% +% $$v_1 + v_2 = 1$$ + +%% Writing the problem in matrix form +% The optimization problem can be writen as: +% +% $$\min\{\frac{1}{2} \mathbf{v}^t \mathbf{P} \mathbf{v} + \mathbf{q}^t \mathbf{v}\}$$ +% +% subject to +% +% $$\left\{\begin{array}{ll} \displaystyle \mathbf{R} \mathbf{v} = \mathbf{b} & \\ v_i \in \{0,1\} & \quad i = 1, \dots, n\\ v_{n+k} \in \big[0,1\big] & \quad k = 1, \dots, m_{1} \end{array} \right\}$$ +% +% Shall there be inequalities, slack variables can be introduced to turn +% them into equalities + +%% The GQKP problem to solve +% From the matrix representation above, the problem can be written as: + +P = [4,0;0,-2]; +q = [0;0]; +Aeq = [1,1]; +beq = [1]; +A = []; +b = []; + +%% Creating the network object +% A set of options can be defined with the |HopfieldNetworkGQKPOptions| +% class using the |hopfieldnetOptions| function: +% +options = hopfieldnetOptions('SimFcn','talavan-yanez','TransferFcn','tanh'); + +%% +% From here, the Hopfield network can be created +net = hopfieldnet(P, q, A, b, Aeq, beq, options); + +%% Training the network +% This process is automatic from the following parametrization (see paper 9 +% in the section). + +alpha = 1; +Phi = 2; +eps = 3*alpha/2 + Phi/2; +beta = -alpha/2 - Phi; +Gamma(1,1) = (2*alpha + Phi/2); +Gamma(2,2) = Phi/2 - alpha; +net = train(net,Phi,alpha,beta,eps,Gamma); + +%% Simulating the Hopfield Network +% Starting point +V0 = [0.6;0.2]; +V = sim(net, V0) + +%% +% The obtained solution is in fact the global optimum. + +%% Energy plot +energyplot(net) \ No newline at end of file diff --git a/help/Example_SimulinkContinuous.m b/help/Example_SimulinkContinuous.m new file mode 100644 index 0000000..9dded62 --- /dev/null +++ b/help/Example_SimulinkContinuous.m @@ -0,0 +1,40 @@ +%% Solving Continuous Hopfield Networks using Simulink + +%% Opening the model +% To open the Continuous Hopfield Model in Simulink simply type in MATLAB: + +open_system('continuousHopfieldNetwork') + +%% +% The following example will solve the same GQKP proposed in a +% . + +%% Setting-up the problem +P = [4,0;0,-2]; +q = [0;0]; +R = [1,1]; +b = 1; + +%% Building the weight matrix and bias vector from the obtained parametrization + +%% +% Parametrization +alpha = 1; +Phi = 3; +eps = 3*alpha/2 + Phi/2; +beta = -alpha/2 - Phi; +Gamma(1,1) = (2*alpha + Phi/2); +Gamma(2,2) = Phi/2 - alpha; + +T = -(alpha * P + R'*Phi*R - 2*Gamma); +ib = -(alpha * q + R'*beta + diag(Gamma)); + +%% Simulating the network +v0 = [0.6;0.2]; +lambda = 1e5; +dt = 0.001; +output = sim('continuousHopfieldNetwork','StopTime','10'); +output.yout(end,:)' + +%% +% The obtained solution is in fact the global optimum. diff --git a/help/Example_SimulinkDiscrete.m b/help/Example_SimulinkDiscrete.m new file mode 100644 index 0000000..53621c0 --- /dev/null +++ b/help/Example_SimulinkDiscrete.m @@ -0,0 +1,37 @@ +%% Solving Discrete Hopfield Networks using Simulink + +%% Opening the model +% To open the Discrete Hopfield Model in Simulink simply type in MATLAB: + +open_system('discreteHopfieldNetwork') + +%% Associative memory +% The discrete Hopfield model can be used a an associative memory network, +% storing patterns in the network and retrieve (or reconstruct) them from a +% similar pattern. + +%% +% The patterns to be stored are patterns from 0 to 3 +q0 = [0;1;1;1;1;0;1;0;0;0;0;1;1;0;0;0;0;1;1;0;0;0;0;1;0;1;1;1;1;0]; +q1 = [0;0;0;0;0;0;1;0;0;0;0;0;1;1;1;1;1;1;0;0;0;0;0;0;0;0;0;0;0;0]; +q2 = [1;0;0;0;0;0;1;0;0;1;1;1;1;0;0;1;0;1;1;0;0;1;0;1;0;1;1;0;0;1]; +q3 = [0;0;0;0;0;0;1;0;1;0;0;1;1;0;1;0;0;1;1;1;1;1;1;1;0;0;0;0;0;0]; +patterns = [q0,q1,q2,q3]; + +%% +% The network weights (which will store the patterns) can be obtained using +% the following synthax: + +n = length(q0); +T = (2*q0 - 1)*(2*q0 - 1)' + (2*q1 - 1)*(2*q1 - 1)' + ... + (2*q2 - 1)*(2*q2 - 1)' + (2*q3 - 1)*(2*q3 - 1)' - eye(n); +ib = zeros(n,1); + +%% Starting point +v0 = [0;0;1;0;0;0;1;0;0;0;0;1;1;0;0;1;0;1;1;0;0;1;0;1;0;1;1;0;0;0]; + +%% Simulating the network +[t,y] = sim('discreteHopfieldNetwork'); + +%% Pattern found by the network +patternFound = find(all(patterns - y(end,:)' == 0))-1 \ No newline at end of file diff --git a/help/Example_tsp2opt.m b/help/Example_tsp2opt.m new file mode 100644 index 0000000..ee6c7bf --- /dev/null +++ b/help/Example_tsp2opt.m @@ -0,0 +1,42 @@ +%% Improving Hopfield Networks performance using the CHN as a 2-opt +% In order to improve the performance of this heuristic technique, +% consecutive second phases of the Divide-and-Conquer scheme using 4 cities +% and 2 chains can be used, starting with an initial solution. This process +% behaves like a 2-opt algorithm (in particular Lin-Kernighan's algorithm). + +%% TSPLIB problem and network parameters +rng(6); % For reproducibility + +%% +% TSPLIB Problem: +problem = tsplib({'berlin52'}); + +%% +% Number of cities: +N = problem.NumberOfCities; + +%% +% Free parameter C: +C = 1e-5; + +%% Creating the |HopfieldNetworkTSP| object using the Divide-and-Conquer simulation method +% Providing problem coordinates cities and distance matrix to the +% |HopfieldNetworkTSP| network by creating a |HopfieldNetworkTSPObject| +% object of options +options = tsphopfieldnetOptions('Coordinates',problem.Coordinates,... + 'DistanceMatrix',problem.DistanceMatrix,... + 'DistanceType',problem.DistanceType,... + 'Scheme','classic&2opt'); +net = tsphopfieldnet(N,C,options); + +%% Training the network +% The default training algorithm is |trainty| +train(net); + +%% Simulating the network +% The simulation is using the algorithm is |talavan-yanez| +sim(net); + +%% Visualizing results +getResults(net) +plot(net); diff --git a/help/Example_tspDivideConquer.m b/help/Example_tspDivideConquer.m index 347283d..7f0074e 100644 --- a/help/Example_tspDivideConquer.m +++ b/help/Example_tspDivideConquer.m @@ -1,5 +1,5 @@ -%% Improving Hopfield Network performance using a Divide-and-Conquer scheme -% In order to imprthe performance of this heuristic technique, a +%% Improving Hopfield Networks performance using a Divide-and-Conquer scheme +% In order to improve the performance of this heuristic technique, a % Divide-and-Conquer strategy based on two phases is proposed. The first % phase involves linking cities with the most neighbors to define a set of % chains of cities and, secondly, to join these with isolated cities to @@ -7,7 +7,7 @@ % onto their respective CHNs. %% TSPLIB problem and network parameters -rng(6); % For reproducibility +rng(3); % For reproducibility %% % TSPLIB Problem: @@ -19,7 +19,7 @@ %% % Free parameter C: -C = 0.00001; +C = 1e-5; %% Creating the |HopfieldNetworkTSP| object using the Divide-and-Conquer simulation method % Providing problem coordinates cities and distance matrix to the @@ -27,8 +27,8 @@ % object of options options = tsphopfieldnetOptions('Coordinates',problem.Coordinates,... 'DistanceMatrix',problem.DistanceMatrix,... - 'DistanceType',problem.DistanceType,... - 'SimFcn','divide-conquer',... + 'DistanceType',problem.DistanceType,... + 'Scheme','divide-conquer',... 'Tau',2); net = tsphopfieldnet(N,C,options); @@ -37,7 +37,7 @@ train(net); %% Simulating the network -% The simulation is using the algorithm is |divide-conquer| +% The simulation is using the algorithm is |talavan-yanez| sim(net); %% Visualizing results diff --git a/help/Example_tspUsingCoords.m b/help/Example_tspUsingCoords.m index 87a6b1c..ce40578 100644 --- a/help/Example_tspUsingCoords.m +++ b/help/Example_tspUsingCoords.m @@ -7,7 +7,7 @@ %% % Free parameter C: -C = 0.00001; +C = 1e-5; %% Creating the |tsphopfieldnetwork| object % Providing problem coordinates diff --git a/help/Example_tspUsingDistance.m b/help/Example_tspUsingDistance.m index 6b31126..3a6a6bc 100644 --- a/help/Example_tspUsingDistance.m +++ b/help/Example_tspUsingDistance.m @@ -7,7 +7,7 @@ %% % Free parameter C: -C = 0.00001; +C = 1e-5; %% Creating the |HopfieldNetworkTSPOptions| object % Providing the distance matrix diff --git a/help/Example_tspUsingRegularPolygons.m b/help/Example_tspUsingRegularPolygons.m index da56260..54d0d03 100644 --- a/help/Example_tspUsingRegularPolygons.m +++ b/help/Example_tspUsingRegularPolygons.m @@ -40,4 +40,8 @@ %% Visualizing results getResults(net) + +%% +% The obtained tour is: +city(net, getResults(net,'VisitOrder')) plot(net); diff --git a/help/Example_tspUsingTSPLIB.m b/help/Example_tspUsingTSPLIB.m index f5c139d..eab3c3e 100644 --- a/help/Example_tspUsingTSPLIB.m +++ b/help/Example_tspUsingTSPLIB.m @@ -7,7 +7,7 @@ % %% TSPLIB problem and network parameters -rng(6); % For reproducibility +rng(3); % For reproducibility %% % TSPLIB Problem: @@ -19,7 +19,7 @@ %% % Free parameter C: -C = 0.00001; +C = 1e-5; %% Creating the |HopfieldNetworkTSP| object % Providing problem cities' coordinates and distance matrix to the @@ -42,8 +42,8 @@ getTrainParam(net) %% Simulating the network -% The default simulation algorithm is |talavan-yanez| -sim(net); +% The default simulation algorithm is |talavan-yanez|. +V = sim(net); %% Visualizing results getResults(net) diff --git a/help/demos.xml b/help/demos.xml index 611bed2..abdb31f 100644 --- a/help/demos.xml +++ b/help/demos.xml @@ -7,7 +7,7 @@ GitHub Repository - + M-file @@ -31,7 +31,13 @@ M-file Example_tspUsingDistance html/Example_tspUsingDistance.html - + + + + M-file + Example_GQKPusingCHN + html/Example_GQKPusingCHN.html + @@ -54,5 +60,26 @@ Example_tspDivideConquer html/Example_tspDivideConquer.html + + + M-file + Example_tsp2opt + html/Example_tsp2opt.html + + + + + + + M-file + Example_SimulinkDiscrete + html/Example_SimulinkDiscrete.html + + + + M-file + Example_SimulinkContinuous + html/Example_SimulinkContinuous.html + diff --git a/help/html/CHN_TSP_APP_Tabs.png b/help/html/CHN_TSP_APP_Tabs.png index 66c6e16..8654d1a 100644 Binary files a/help/html/CHN_TSP_APP_Tabs.png and b/help/html/CHN_TSP_APP_Tabs.png differ diff --git a/help/html/Example_GQKPusingCHN.html b/help/html/Example_GQKPusingCHN.html new file mode 100644 index 0000000..2e52a09 --- /dev/null +++ b/help/html/Example_GQKPusingCHN.html @@ -0,0 +1,159 @@ + + + + + How to solve a GQKP problem using a Hopfield Network

How to solve a GQKP problem using a Hopfield Network

The following optimization problem is proposed:

$$\min\{\frac{1}{2}(4v_1^2 - 2v_2^2)\}$$

subject to:

$$v_1 + v_2 = 1$$

Contents

Writing the problem in matrix form

The optimization problem can be writen as:

$$\min\{\frac{1}{2} \mathbf{v}^t \mathbf{P} \mathbf{v} + \mathbf{q}^t \mathbf{v}\}$$

subject to

$$\left\{\begin{array}{ll} \displaystyle \mathbf{R} \mathbf{v} = \mathbf{b} & \\ v_i \in \{0,1\} & \quad i = 1, \dots, n\\ v_{n+k} \in \big[0,1\big] & \quad k = 1, \dots, m_{1} \end{array} \right\}$$

Shall there be inequalities, slack variables can be introduced to turn them into equalities

The GQKP problem to solve

From the matrix representation above, the problem can be written as:

P = [4,0;0,-2];
+q = [0;0];
+Aeq = [1,1];
+beq = [1];
+A = [];
+b = [];
+

Creating the network object

A set of options can be defined with the HopfieldNetworkGQKPOptions class using the hopfieldnetOptions function:

options = hopfieldnetOptions('SimFcn','talavan-yanez','TransferFcn','tanh');
+

From here, the Hopfield network can be created

net = hopfieldnet(P, q, A, b, Aeq, beq, options);
+

Training the network

This process is automatic from the following parametrization (see paper 9 in the references section).

alpha = 1;
+Phi = 2;
+eps = 3*alpha/2 + Phi/2;
+beta = -alpha/2 - Phi;
+Gamma(1,1) = (2*alpha + Phi/2);
+Gamma(2,2) = Phi/2 - alpha;
+net = train(net,Phi,alpha,beta,eps,Gamma);
+

Simulating the Hopfield Network

Starting point

V0 = [0.6;0.2];
+V = sim(net, V0)
+
+V =
+
+     0
+     1
+
+

The obtained solution is in fact the global optimum.

Energy plot

energyplot(net)
+
\ No newline at end of file diff --git a/help/html/Example_GQKPusingCHN.png b/help/html/Example_GQKPusingCHN.png new file mode 100644 index 0000000..16a10e3 Binary files /dev/null and b/help/html/Example_GQKPusingCHN.png differ diff --git a/help/html/Example_GQKPusingCHN_01.png b/help/html/Example_GQKPusingCHN_01.png new file mode 100644 index 0000000..ba1e960 Binary files /dev/null and b/help/html/Example_GQKPusingCHN_01.png differ diff --git a/help/html/Example_GQKPusingCHN_eq00402117310426221833.png b/help/html/Example_GQKPusingCHN_eq00402117310426221833.png new file mode 100644 index 0000000..a29c335 Binary files /dev/null and b/help/html/Example_GQKPusingCHN_eq00402117310426221833.png differ diff --git a/help/html/Example_GQKPusingCHN_eq01573304657958675695.png b/help/html/Example_GQKPusingCHN_eq01573304657958675695.png new file mode 100644 index 0000000..94b5c52 Binary files /dev/null and b/help/html/Example_GQKPusingCHN_eq01573304657958675695.png differ diff --git a/help/html/Example_GQKPusingCHN_eq04048434318454198067.png b/help/html/Example_GQKPusingCHN_eq04048434318454198067.png new file mode 100644 index 0000000..d4c5626 Binary files /dev/null and b/help/html/Example_GQKPusingCHN_eq04048434318454198067.png differ diff --git a/help/html/Example_GQKPusingCHN_eq06393315845928486594.png b/help/html/Example_GQKPusingCHN_eq06393315845928486594.png new file mode 100644 index 0000000..31d5850 Binary files /dev/null and b/help/html/Example_GQKPusingCHN_eq06393315845928486594.png differ diff --git a/help/html/Example_GQKPusingCHN_eq07602426813975653007.png b/help/html/Example_GQKPusingCHN_eq07602426813975653007.png new file mode 100644 index 0000000..a1da226 Binary files /dev/null and b/help/html/Example_GQKPusingCHN_eq07602426813975653007.png differ diff --git a/help/html/Example_GQKPusingCHN_eq07876467921963818138.png b/help/html/Example_GQKPusingCHN_eq07876467921963818138.png new file mode 100644 index 0000000..0444a7e Binary files /dev/null and b/help/html/Example_GQKPusingCHN_eq07876467921963818138.png differ diff --git a/help/html/Example_GQKPusingCHN_eq14361763071227683630.png b/help/html/Example_GQKPusingCHN_eq14361763071227683630.png new file mode 100644 index 0000000..532084c Binary files /dev/null and b/help/html/Example_GQKPusingCHN_eq14361763071227683630.png differ diff --git a/help/html/Example_GQKPusingCHN_eq15343366408291104280.png b/help/html/Example_GQKPusingCHN_eq15343366408291104280.png new file mode 100644 index 0000000..1a821cd Binary files /dev/null and b/help/html/Example_GQKPusingCHN_eq15343366408291104280.png differ diff --git a/help/html/Example_GQKPusingCHN_eq16350391703841992777.png b/help/html/Example_GQKPusingCHN_eq16350391703841992777.png new file mode 100644 index 0000000..490e9a0 Binary files /dev/null and b/help/html/Example_GQKPusingCHN_eq16350391703841992777.png differ diff --git a/help/html/Example_SimulinkContinuous.html b/help/html/Example_SimulinkContinuous.html new file mode 100644 index 0000000..545cf41 --- /dev/null +++ b/help/html/Example_SimulinkContinuous.html @@ -0,0 +1,138 @@ + + + + + Solving Continuous Hopfield Networks using Simulink

Solving Continuous Hopfield Networks using Simulink

Contents

Opening the model

To open the Continuous Hopfield Model in Simulink simply type in MATLAB:

open_system('continuousHopfieldNetwork')
+

The following example will solve the same GQKP proposed in a previous example.

Setting-up the problem

P = [4,0;0,-2];
+q = [0;0];
+R = [1,1];
+b = 1;
+

Building the weight matrix and bias vector from the obtained parametrization

Parametrization

alpha = 1;
+Phi = 3;
+eps = 3*alpha/2 + Phi/2;
+beta = -alpha/2 - Phi;
+Gamma(1,1) = (2*alpha + Phi/2);
+Gamma(2,2) = Phi/2 - alpha;
+
+T = -(alpha * P + R'*Phi*R - 2*Gamma);
+ib = -(alpha * q + R'*beta + diag(Gamma));
+

Simulating the network

v0 = [0.6;0.2];
+lambda = 1e5;
+dt = 0.001;
+output = sim('continuousHopfieldNetwork','StopTime','10');
+output.yout(end,:)'
+
+ans =
+
+     0
+     1
+
+

The obtained solution is in fact the global optimum.

\ No newline at end of file diff --git a/help/html/Example_SimulinkContinuous.png b/help/html/Example_SimulinkContinuous.png new file mode 100644 index 0000000..1d7e916 Binary files /dev/null and b/help/html/Example_SimulinkContinuous.png differ diff --git a/help/html/Example_SimulinkContinuous_01.png b/help/html/Example_SimulinkContinuous_01.png new file mode 100644 index 0000000..b8ed49c Binary files /dev/null and b/help/html/Example_SimulinkContinuous_01.png differ diff --git a/help/html/Example_SimulinkDiscrete.html b/help/html/Example_SimulinkDiscrete.html new file mode 100644 index 0000000..b4507cb --- /dev/null +++ b/help/html/Example_SimulinkDiscrete.html @@ -0,0 +1,127 @@ + + + + + Solving Discrete Hopfield Networks using Simulink

Solving Discrete Hopfield Networks using Simulink

Contents

Opening the model

To open the Discrete Hopfield Model in Simulink simply type in MATLAB:

open_system('discreteHopfieldNetwork')
+

Associative memory

The discrete Hopfield model can be used a an associative memory network, storing patterns in the network and retrieve (or reconstruct) them from a similar pattern.

The patterns to be stored are patterns from 0 to 3

q0 = [0;1;1;1;1;0;1;0;0;0;0;1;1;0;0;0;0;1;1;0;0;0;0;1;0;1;1;1;1;0];
+q1 = [0;0;0;0;0;0;1;0;0;0;0;0;1;1;1;1;1;1;0;0;0;0;0;0;0;0;0;0;0;0];
+q2 = [1;0;0;0;0;0;1;0;0;1;1;1;1;0;0;1;0;1;1;0;0;1;0;1;0;1;1;0;0;1];
+q3 = [0;0;0;0;0;0;1;0;1;0;0;1;1;0;1;0;0;1;1;1;1;1;1;1;0;0;0;0;0;0];
+patterns = [q0,q1,q2,q3];
+

The network weights (which will store the patterns) can be obtained using the following synthax:

n = length(q0);
+T = (2*q0 - 1)*(2*q0 - 1)' + (2*q1 - 1)*(2*q1 - 1)' + ...
+    (2*q2 - 1)*(2*q2 - 1)' + (2*q3 - 1)*(2*q3 - 1)' - eye(n);
+ib = zeros(n,1);
+

Starting point

v0 = [0;0;1;0;0;0;1;0;0;0;0;1;1;0;0;1;0;1;1;0;0;1;0;1;0;1;1;0;0;0];
+

Simulating the network

[t,y] = sim('discreteHopfieldNetwork');
+

Pattern found by the network

patternFound = find(all(patterns - y(end,:)' == 0))-1
+
+patternFound =
+
+     2
+
+
\ No newline at end of file diff --git a/help/html/Example_SimulinkDiscrete.png b/help/html/Example_SimulinkDiscrete.png new file mode 100644 index 0000000..d34aa99 Binary files /dev/null and b/help/html/Example_SimulinkDiscrete.png differ diff --git a/help/html/Example_SimulinkDiscrete_01.png b/help/html/Example_SimulinkDiscrete_01.png new file mode 100644 index 0000000..90f56ad Binary files /dev/null and b/help/html/Example_SimulinkDiscrete_01.png differ diff --git a/help/html/Example_SimulinkDiscrete_02.png b/help/html/Example_SimulinkDiscrete_02.png new file mode 100644 index 0000000..0a327d1 Binary files /dev/null and b/help/html/Example_SimulinkDiscrete_02.png differ diff --git a/help/html/Example_tsp2opt.html b/help/html/Example_tsp2opt.html new file mode 100644 index 0000000..5aaa455 --- /dev/null +++ b/help/html/Example_tsp2opt.html @@ -0,0 +1,143 @@ + + + + + Improving Hopfield Networks performance using the CHN as a 2-opt

Improving Hopfield Networks performance using the CHN as a 2-opt

In order to improve the performance of this heuristic technique, consecutive second phases of the Divide-and-Conquer scheme using 4 cities and 2 chains can be used, starting with an initial solution. This process behaves like a 2-opt algorithm (in particular Lin-Kernighan's algorithm).

Contents

TSPLIB problem and network parameters

rng(6); % For reproducibility
+

TSPLIB Problem:

problem = tsplib({'berlin52'});
+

Number of cities:

N = problem.NumberOfCities;
+

Free parameter C:

C = 1e-5;
+

Creating the HopfieldNetworkTSP object using the Divide-and-Conquer simulation method

Providing problem coordinates cities and distance matrix to the HopfieldNetworkTSP network by creating a HopfieldNetworkTSPObject object of options

options = tsphopfieldnetOptions('Coordinates',problem.Coordinates,...
+                                'DistanceMatrix',problem.DistanceMatrix,...
+                                'DistanceType',problem.DistanceType,...
+                                'Scheme','classic&2opt');
+net = tsphopfieldnet(N,C,options);
+

Training the network

The default training algorithm is trainty

train(net);
+

Simulating the network

The simulation is using the algorithm is talavan-yanez

sim(net);
+

Visualizing results

getResults(net)
+plot(net);
+
+ans = 
+
+  struct with fields:
+
+    CheckpointFilename: ''
+              CompTime: 0.1923
+                Energy: [1×216 double]
+              ExitFlag: 1
+          ItersReached: 216
+                  Time: [1×216 double]
+            TourLength: 7909
+             ValidPath: 1
+            VisitOrder: [1×52 double]
+
+
\ No newline at end of file diff --git a/help/html/Example_tsp2opt.png b/help/html/Example_tsp2opt.png new file mode 100644 index 0000000..9de4bd3 Binary files /dev/null and b/help/html/Example_tsp2opt.png differ diff --git a/help/html/Example_tsp2opt_01.png b/help/html/Example_tsp2opt_01.png new file mode 100644 index 0000000..6c393c3 Binary files /dev/null and b/help/html/Example_tsp2opt_01.png differ diff --git a/help/html/Example_tspDivideConquer.html b/help/html/Example_tspDivideConquer.html index bbcb5f8..3b53df0 100644 --- a/help/html/Example_tspDivideConquer.html +++ b/help/html/Example_tspDivideConquer.html @@ -6,7 +6,7 @@ Improving Hopfield Network performance using a Divide-and-Conquer scheme

Improving Hopfield Network performance using a Divide-and-Conquer scheme

In order to imprthe performance of this heuristic technique, a Divide-and-Conquer strategy based on two phases is proposed. The first phase involves linking cities with the most neighbors to define a set of chains of cities and, secondly, to join these with isolated cities to define the final tour. Both problems are solved by mapping the two TSPs onto their respective CHNs.

Contents

TSPLIB problem and network parameters

rng(6); % For reproducibility
+  

Improving Hopfield Networks performance using a Divide-and-Conquer scheme

In order to improve the performance of this heuristic technique, a Divide-and-Conquer strategy based on two phases is proposed. The first phase involves linking cities with the most neighbors to define a set of chains of cities and, secondly, to join these with isolated cities to define the final tour. Both problems are solved by mapping the two TSPs onto their respective CHNs.

Contents

TSPLIB problem and network parameters

rng(3); % For reproducibility
 

TSPLIB Problem:

problem = tsplib({'berlin52'});
 

Number of cities:

N = problem.NumberOfCities;
-

Free parameter C:

C = 0.00001;
+

Free parameter C:

C = 1e-5;
 

Creating the HopfieldNetworkTSP object using the Divide-and-Conquer simulation method

Providing problem coordinates cities and distance matrix to the HopfieldNetworkTSP network by creating a HopfieldNetworkTSPObject object of options

options = tsphopfieldnetOptions('Coordinates',problem.Coordinates,...
                                 'DistanceMatrix',problem.DistanceMatrix,...
                                 'DistanceType',problem.DistanceType,...
-                                'SimFcn','divide-conquer',...
+                                'Scheme','divide-conquer',...
                                 'Tau',2);
 net = tsphopfieldnet(N,C,options);
 

Training the network

The default training algorithm is trainty

train(net);
-

Simulating the network

The simulation is using the algorithm is divide-conquer

sim(net);
+

Simulating the network

The simulation is using the algorithm is talavan-yanez

sim(net);
 

Visualizing results

getResults(net)
 plot(net);
 
@@ -86,19 +86,19 @@
   struct with fields:
 
     CheckpointFilename: ''
-              CompTime: 0.5670
-                Energy: [1×590 double]
+              CompTime: 0.5058
+                Energy: [1×571 double]
               ExitFlag: 1
-          ItersReached: 590
-                  Time: [1×590 double]
-            TourLength: 11393
+          ItersReached: 571
+                  Time: [1×571 double]
+            TourLength: 12462
              ValidPath: 1
             VisitOrder: [1×52 double]
 
 
Improving the convergence of the Hopfield Network applied to the TSP by reducing the parameter C

Solving the TSP provided the problem's coordinates using Hopfield Network

The following example shows how to solve any TSP problem, provided the problem coordinates

Contents

Network parameters

rng(22); % For reproducibility
-

Free parameter C:

C = 0.00001;
+

Free parameter C:

C = 1e-5;
 

Creating the tsphopfieldnetwork object

Providing problem coordinates

coords = [0.4000 0.4439;...
           0.2439 0.1463;...
           0.1707 0.2293;...
@@ -113,7 +113,7 @@
   struct with fields:
 
     CheckpointFilename: ''
-              CompTime: 0.0322
+              CompTime: 0.0310
                 Energy: [1×93 double]
               ExitFlag: 1
           ItersReached: 93
@@ -133,7 +133,7 @@
 
 %%
 % Free parameter C:
-C = 0.00001;
+C = 1e-5;
  
 %% Creating the |tsphopfieldnetwork| object
 % Providing problem coordinates
diff --git a/help/html/Example_tspUsingCoords.png b/help/html/Example_tspUsingCoords.png
index 8dfc0f2..b48844c 100644
Binary files a/help/html/Example_tspUsingCoords.png and b/help/html/Example_tspUsingCoords.png differ
diff --git a/help/html/Example_tspUsingCoords_01.png b/help/html/Example_tspUsingCoords_01.png
index 6a27c7f..4107d48 100644
Binary files a/help/html/Example_tspUsingCoords_01.png and b/help/html/Example_tspUsingCoords_01.png differ
diff --git a/help/html/Example_tspUsingCoords_02.png b/help/html/Example_tspUsingCoords_02.png
index 9018c78..a16c012 100644
Binary files a/help/html/Example_tspUsingCoords_02.png and b/help/html/Example_tspUsingCoords_02.png differ
diff --git a/help/html/Example_tspUsingDistance.html b/help/html/Example_tspUsingDistance.html
index 9a391b0..f4999f9 100644
--- a/help/html/Example_tspUsingDistance.html
+++ b/help/html/Example_tspUsingDistance.html
@@ -6,7 +6,7 @@
    Solving the TSP provided the distance matrix using Hopfield Network

Solving the TSP provided the distance matrix using Hopfield Network

The following example shows how to solve any TSP problem, provided the distance matrix between cities.

Contents

Network parameters

rng(22); % For reproducibility
-

Free parameter C:

C = 0.00001;
+

Free parameter C:

C = 1e-5;
 

Creating the HopfieldNetworkTSPOptions object

Providing the distance matrix

d = [.0000 .3361 .3141 .3601 .5111 .5176 .2982 .4564 .3289 .2842;...
      .3361 .0000 .1107 .6149 .8407 .8083 .5815 .6418 .4378 .3934;...
      .3141 .1107 .0000 .5349 .7919 .8207 .5941 .6908 .4982 .4501;...
@@ -119,7 +119,7 @@
 
 %%
 % Free parameter C:
-C = 0.00001;
+C = 1e-5;
  
 %% Creating the |HopfieldNetworkTSPOptions| object
 % Providing the distance matrix
diff --git a/help/html/Example_tspUsingRegularPolygons.html b/help/html/Example_tspUsingRegularPolygons.html
index 3e9c398..d9acc60 100644
--- a/help/html/Example_tspUsingRegularPolygons.html
+++ b/help/html/Example_tspUsingRegularPolygons.html
@@ -6,7 +6,7 @@
    Solving the TSP with cities in Polygon Vertices using a Hopfield Network

Solving the TSP with TSPLIB cities using a Hopfield Network

TSPLIB is an extensive set of problems frequently used for solving the TSP (and related problems) and used as a powerful reference for benchmarking different algorithms. In this section, tsphopfieldnet is used for solving the TSP when the problem coordinates are given by one of the library problems from TSPLIB.

Contents

TSPLIB problem and network parameters

rng(6); % For reproducibility
+  

Solving the TSP with TSPLIB cities using a Hopfield Network

TSPLIB is an extensive set of problems frequently used for solving the TSP (and related problems) and used as a powerful reference for benchmarking different algorithms. In this section, tsphopfieldnet is used for solving the TSP when the problem coordinates are given by one of the library problems from TSPLIB.

Contents

TSPLIB problem and network parameters

rng(3); % For reproducibility
 

TSPLIB Problem:

problem = tsplib({'berlin52'});
 

Number of cities:

N = problem.NumberOfCities;
-

Free parameter C:

C = 0.00001;
+

Free parameter C:

C = 1e-5;
 

Creating the HopfieldNetworkTSP object

Providing problem cities' coordinates and distance matrix to the HopfieldNetworkTSP network by creating a HopfieldNetworkTSPOptions object of options

options = tsphopfieldnetOptions('Coordinates',problem.Coordinates,...
                                 'DistanceMatrix',problem.DistanceMatrix,...
                                 'DistanceType',problem.DistanceType);
@@ -96,7 +96,7 @@
     dUaux: 1716
       rho: 0.0087
 
-

Simulating the network

The default simulation algorithm is talavan-yanez

sim(net);
+

Simulating the network

The default simulation algorithm is talavan-yanez.

V = sim(net);
 

Visualizing results

getResults(net)
 plot(net);
 
@@ -105,12 +105,12 @@
   struct with fields:
 
     CheckpointFilename: ''
-              CompTime: 0.1781
-                Energy: [1×216 double]
+              CompTime: 0.2247
+                Energy: [1×247 double]
               ExitFlag: 1
-          ItersReached: 216
-                  Time: [1×216 double]
-            TourLength: 12583
+          ItersReached: 247
+                  Time: [1×247 double]
+            TourLength: 14852
              ValidPath: 1
             VisitOrder: [1×52 double]
 
@@ -125,7 +125,7 @@
 % 
 
 %% TSPLIB problem and network parameters
-rng(6); % For reproducibility
+rng(3); % For reproducibility
 
 %%
 % TSPLIB Problem:
@@ -137,7 +137,7 @@
 
 %%
 % Free parameter C:
-C = 0.00001;
+C = 1e-5;
  
 %% Creating the |HopfieldNetworkTSP| object
 % Providing problem cities' coordinates and distance matrix to the
@@ -160,8 +160,8 @@
 getTrainParam(net)
 
 %% Simulating the network
-% The default simulation algorithm is |talavan-yanez|
-sim(net);
+% The default simulation algorithm is |talavan-yanez|. 
+V = sim(net);
 
 %% Visualizing results
 getResults(net)
diff --git a/help/html/Example_tspUsingTSPLIB.png b/help/html/Example_tspUsingTSPLIB.png
index 722a795..4dbba6b 100644
Binary files a/help/html/Example_tspUsingTSPLIB.png and b/help/html/Example_tspUsingTSPLIB.png differ
diff --git a/help/html/Example_tspUsingTSPLIB_01.png b/help/html/Example_tspUsingTSPLIB_01.png
index 4323d37..c757657 100644
Binary files a/help/html/Example_tspUsingTSPLIB_01.png and b/help/html/Example_tspUsingTSPLIB_01.png differ
diff --git a/help/html/Example_tspUsingTSPLIB_02.png b/help/html/Example_tspUsingTSPLIB_02.png
index 84c6488..f37ecbe 100644
Binary files a/help/html/Example_tspUsingTSPLIB_02.png and b/help/html/Example_tspUsingTSPLIB_02.png differ
diff --git a/help/html/chn_TSP_APP.html b/help/html/chn_TSP_APP.html
index 3743aa3..cd18e49 100644
--- a/help/html/chn_TSP_APP.html
+++ b/help/html/chn_TSP_APP.html
@@ -6,7 +6,7 @@
    Hopfield Network TSP Solver App

Hopfield Network TSP Solver App

The Hopfield Network TSP Solver App allows to solve the Traveling Salesman Problem using Continuous Hopfield Networks by using several of the solver algorithms available in Hopfield Network Toolbox (euler, talavan-yanez and divide-conquer.

You will find the Hopfield Network TSP Solver App from the APPS section in your MATLAB Desktop.

The Hopfield Network TSP Solver App can solve TSPLIB problems, TSPs where its cities are located at the vertices of regular polygons, and any TSP problem defined by its coordinates or distance matrix.

About Hopfield Network Toolbox

About Hopfield Network Toolbox

Contents

Acknowledgements

The authors would like to thank:

  • Javier Yáñez of Universidad Complutense de Madrid (Spain)
  • Pedro M. Talaván of Instituto Nacional de Estadística (Spain)

for their sound contributions and recommendations.

What problems can Hopfield Network Toolbox solve?

Hopfield Networks may solve any combinatorial optimization problem, given it is properly mapped to the network. However, at this point, Hopfield Network Toolbox is mainly designed to solve The Traveling Salesman Problem.

The Toolbox has been designed though to be easily expanded to solve any combinatorial optimization problem.

This Toolbox is supporting material to the PhD Thesis by Lucas García Rodríguez titled "Algunas cuestiones notables sobre el modelo de Hopfield en optimización".

Contents

Acknowledgements

The author would like to thank:

  • Francisco Javier Yáñez Gestoso of Universidad Complutense de Madrid (Spain)
  • Pedro Martínez Talaván of Instituto Nacional de Estadística (Spain)

for their sound contributions and recommendations.

What problems can Hopfield Network Toolbox solve?

Hopfield Networks may solve any combinatorial optimization problem, given it is properly mapped to the network. At this point, Hopfield Network Toolbox major focus is to solve The Traveling Salesman Problem, though the Toolbox may also solve the Generalized Quadratic Knapsack Problem if an appropriate mapping is provided.

Concepts

Concepts

Contents

What is a Neural Network?

Artificial Neural Networks (ANN), or commonly Neural Networks, are a family of Machine Learning models, inspired by biological neural networks. ANNs were defined by Dr. Robert Hecht-Nielsen as:

"A computing system made up of a number of simple, highly interconnected processing elements, which process information by their dynamic state response to external inputs."

You can find more information about Neural Networks online. One great introductory book is Neural Network Design, by Martin T. Hagan, Howard B. Demuth and Mark H. Beale (original authors of Neural Network Toolbox). An ebook version is available from Martin T. Hagan's site.

What is a Hopfield Neural Network?

The Continuous Hopfield Network (CHN) is a recurrent neural network with an associated differential equation, whose state evolves from an initial condition to an equilibrium point by minimizing a Lyapunov function. As the Lyapunov function is associated with an objective function of the optimization problem (i.e. the mapping process), the equilibrium, or stable point, helps identify a local optimum for the optimization problem.

The dynamics of the CHN is described by a differential equation:

$$\frac{du}{dt} = - \frac{u}{\Lambda} + T v + i^b$$

and the output function $v_i = g(u_i)$ is a hyperbolic tangent:

$$g(u_i) = \frac{1}{2} \left( 1 + \tanh \left( \frac{u_i}{u_0} \right) \right), \qquad u_0 > 0$$

The existence of an equilibrium point ($u^e$ such that $u(t)=u^e \ \forall t \geq t_e$ for some $t_e \geq 0$) is guaranteed if a Lyapunov or energy function exists. The idea is that the network's Lyapunov function, when $\Lambda \rightarrow{} \infty$, is associated with the cost function to be minimized in the combinatorial problem.

The CHN will solve those combinatorial problems which can be expressed as the constrained minimization of:

$$E(v) = -  \frac{1}{2} v^t T v - (i^b)^t v$$

The Traveling Salesman Problem

Let $N$ be the number of cities in the TSP, and let $d_{xy}$ be the distance between cities $x,y \in \{ 1,2,\ldots, N \}$. Next, let $V$ be the $N \times N$ matrix of the state variable:

$$v_{x,i} = \{ 1 \, \mbox{if the city} \, x \, \mbox{is visited in the
order} \, i \mbox{,} \, 0 \, \mbox{otherwise} \} $$

$V$ identifies a valid tour for the $TSP$ if the following constraints are satisfied:

  • Every city must be visited only once: $S_x = \sum_{i=1}^N v_{x,i} = 1, \quad \forall x \in \{1,2,\ldots,N \}$
  • Every position is associated with a unique city: $S_i = \sum_{x=1}^N v_{x,i} = 1, \quad \forall i \in \{ 1,2,\ldots,N \}$

The objective function is:

$$ \min  \{ \frac{1}{2} \sum_{x=1}^N \sum_{y \neq x} \sum_{i=1}^N
d_{xy} v_{xi}(v_{y(i+1)} + v_{y(i-1)}) \}, \mbox{(the $i+1$
and $i-1$ subscripts are given modulo $N$)} $$

and the output function $v_i = g(u_i)$ is a hyperbolic tangent:

$$g(u_i) = \frac{1}{2} \left( 1 + \tanh \left( \frac{u_i}{u_0} \right) \right), \qquad u_0 > 0$$

The existence of an equilibrium point ($u^e$ such that $\mathbf{u}(t)=u^e \ \forall t \geq t_e$ for some $t_e \geq 0$) is guaranteed if a Lyapunov or energy function exists. The idea is that the network's Lyapunov function, when $\lambda \rightarrow{} \infty$, is associated with the cost function to be minimized in the combinatorial problem.

The CHN will solve those combinatorial problems which can be expressed as the constrained minimization of:

$$E(\mathbf{v}) = -  \frac{1}{2} \mathbf{v}^t \mathbf{T} \mathbf{v} - (\mathbf{i^b})^t \mathbf{v}$$

The Traveling Salesman Problem

Let $N$ be the number of cities in the TSP, and let $d_{xy}$ be the distance between cities $x,y \in \{ 1,2,\ldots, N \}$. Next, let $\mathbf{V}$ be the $N \times N$ matrix of the state variable:

$$v_{x,i} = \{ 1 \, \mbox{if the city} \, x \, \mbox{is visited in the
order} \, i \mbox{,} \, 0 \, \mbox{otherwise} \} $$

$\mathbf{V}$ identifies a valid tour for the $TSP$ if the following constraints are satisfied:

  • Every city must be visited only once: $S_x = \sum_{i=1}^N v_{x,i} = 1, \quad \forall x \in \{1,2,\ldots,N \}$
  • Every position is associated with a unique city: $S_i = \sum_{x=1}^N v_{x,i} = 1, \quad \forall i \in \{ 1,2,\ldots,N \}$

The objective function is:

$$ \min  \{ \frac{1}{2} \sum_{x=1}^N \sum_{y \neq x} \sum_{i=1}^N
d_{xy} v_{xi}(v_{y(i+1)} + v_{y(i-1)}) \}, \mbox{(the $i+1$
and $i-1$ subscripts are given modulo $N$)} $$

The Mapping Process

Given the state variable is $V\in [0,1]^{N\times N}$ for the TSP, the energy function of the CHN is:

$$ E(V) = \frac{A}{2} \sum_x^N \sum_i^{N} \sum_{j \neq i}^{N} v_{x,i}
v_{x,j} + \frac{B}{2} \sum_i^{N} \sum_x^N \sum_{y \neq x}^N v_{x,i}
v_{y,i} + \frac{C}{2} ( \sum_x^N \sum_i^N v_{x,i} - N )^2 + \frac{D}{2}
\sum_x^N \sum_{y \neq x}^N \sum_i^N d_{x,y} v_{x,i} (v_{y,i-1} +
v_{y,i+1}) $$

The Mapping Process

Given the state variable is $\mathbf{V}\in [0,1]^{N\times N}$ for the TSP, the energy function of the CHN is:

$$ E(\mathbf{v}) = \frac{A}{2} \sum_x^N \sum_i^{N} \sum_{j \neq i}^{N} v_{x,i}
v_{x,j} + \frac{B}{2} \sum_i^{N} \sum_x^N \sum_{y \neq x}^N v_{x,i}
v_{y,i} + \frac{C}{2} ( \sum_x^N \sum_i^N v_{x,i} - N )^2 + \frac{D}{2}
\sum_x^N \sum_{y \neq x}^N \sum_i^N d_{x,y} v_{x,i} (v_{y,i-1} +
v_{y,i+1}) $$Hopfield Network Toolbox

Hopfield Network Toolbox

The Hopfield Network Toolbox can solve combinatorial optimization problems by using Hopfield Neural Networks. The Hopfield Network Toolbox is focused in Continuous Hopfield Networks.

If you are interested in using Discrete Hopfield Networks, see the documentation for newhop in Neural Network Toolbox™.

The Continuous Hopfield Network (CHN) is a recurrent neural network with an associated differential equation, whose state evolves from an initial condition to an equilibrium point by minimizing a Lyapunov function. As the Lyapunov function is associated with an objective function of the optimization problem (i.e. the mapping process), the equilibrium, or stable point, helps identify a local optimum for the optimization problem.

You can find more information about Continuous Hopfield Networks in the Concepts Section of the documentation.

Available Documentation

See also the GitHub repository Hopfield Network Toolbox for the latest release of the software.

References

References

The following references have been relevant in the development of the PhD Thesis and this Toolbox.

  1. Abe, S. Global convergence and suppression of spurious states of the Hopfield neural networks. IEEE Transactions on Circuits and Systems I: Fundamental Theory and Applications 40, 4 (1993), 246-257.
  2. Aiyer, S. V., Niranjan, M., and Fallside, F. A theoretical investigation into the performance of the Hopfield model. IEEE Transactions on Neural Networks 1, 2 (1990), 204-215.
  3. Anderson, J. A. A simple neural network generating an interactive memory. Mathematical biosciences 14, 3-4 (1972), 197-220.
  4. Cortes, C., and Vapnik, V. Support-vector networks. Machine learning 20, 3 (1995), 273-297.
  5. Croes, G. A. A method for solving traveling-salesman problems. Operations research 6, 6 (1958), 791-812.
  6. Cuykendall, R., and Reese, R. Scaling the neural TSP algorithm. Biological Cybernetics 60, 5 (1989), 365-371.
  7. De Mazancourt, T., and Gerlic, D. The inverse of a block-circulant matrix. IEEE transactions on antennas and propagation 31, 5 (1983), 808-810.
  8. Di Marco, M., Forti, M., Grazzini, M., and Pancioni, L. Necessary and suficient condition for multistability of neural networks evolving on a closed hypercube. Neural Networks 54 (2014), 38-48.
  9. García, L., Talaván, P. M., and Yáñez, J. Attractor basin analysis of the Hopfield model: The Generalized Quadratic Knapsack Problem. In International Work-Conference on Artificial Neural Networks (2017), Springer, pp. 420-431.
  10. García, L., Talaván, P. M., and Yáñez, J. Improving the Hopfield model performance when applied to the traveling salesman problem. Soft Computing 21, 14 (2017), 3891-3905.
  11. Gopal, M. Modern control system theory. New Age International, 1993.
  12. Grossberg, S. Adaptive pattern classification and universal recoding: I. parallel development and coding of neural feature detectors. Biological cybernetics 23, 3 (1976), 121-134.
  13. Hagan, M. T., Demuth, H. B., Beale, M. H., and De Jesús, O. Neural network design, vol. 20. PWS publishing company Boston, 1996.
  14. Hebb, D. O. The organization of behavior: A neuropsychological theory. John Wiley & Sons Inc., 1949.
  15. Hedge, S. U., Sweet, J. L., and Levy, W. B. Determination of parameters in a Hopfield/Tank computational network. In Neural Networks, 1988., IEEE International Conference on (1988), IEEE, pp. 291-298.
  16. Hernández-Solano, Y., Atencia, M., Joya, G., and Sandoval, F. A discrete gradient method to enhance the numerical behaviour of Hopfield networks. Neurocomputing 164 (2015), 45-55.
  17. Hopfield, J. J. Neural networks and physical systems with emergent collective computational abilities. Proceedings of the national academy of sciences 79, 8 (1982), 2554-2558.
  18. Hopfield, J. J. Neurons with graded response have collective computational properties like those of two-state neurons. Proceedings of the national academy of sciences 81, 10 (1984), 3088-3092.
  19. Hopfield, J. J., and Tank, D. W. "Neural" computation of decisions in optimization problems. Biological cybernetics 52, 3 (1985), 141-152.
  20. Jolai, F., and Ghanbari, A. Integrating data transformation techniques with Hopfield neural networks for solving travelling salesman problem. Expert Systems with Applications 37, 7 (2010), 5331-5335.
  21. Joya, G., Atencia, M., and Sandoval, F. Hopfield neural networks for optimization: study of the dierent dynamics. Neurocomputing 43, 1-4 (2002), 219-237.
  22. Kamgar-Parsi, B., and Kamgar-Parsi, B. On problem solving with Hopfield neural networks. Biological Cybernetics 62, 5 (1990), 415-423.
  23. Kohonen, T. Correlation matrix memories. IEEE transactions on computers 100, 4 (1972), 353-359.
  24. Kohonen, T. Self-organized formation of topologically correct feature maps. Biological cybernetics 43, 1 (1982), 59-69.
  25. Koopmans, T. C., and Beckmann, M. Assignment problems and the location of economic activities. Econometrica: journal of the Econometric Society (1957), 53-76.
  26. Krizhevsky, A., Sutskever, I., and Hinton, G. E. Imagenet classification with deep convolutional neural networks. In Advances in neural information processing systems (2012), pp. 1097-1105.
  27. LeCun, Y., Bottou, L., Bengio, Y., and Haffner, P. Gradient-based learning applied to document recognition. Proceedings of the IEEE 86, 11 (1998), 2278-2324.
  28. Lin, S., and Kernighan, B. W. An eective heuristic algorithm for the traveling-salesman problem. Operations research 21, 2 (1973), 498-516.
  29. McCulloch, W. S., and Pitts, W. A logical calculus of the ideas immanent in nervous activity. The bulletin of mathematical biophysics 5, 4 (1943), 115-133.
  30. Mérida-Casermeiro, E., Galán-Marín, G., and Munoz-Perez, J. An ecient multivalued Hopfield network for the traveling salesman problem. Neural Processing Letters 14, 3 (2001), 203-216.
  31. Minsky, M., and Papert, S. Perceptrons. Oxford, England: MIT Press, 1969.
  32. Papadimitriou, C. H. The Euclidean travelling salesman problem is NP-complete. Theoretical Computer Science 4, 3 (1977), 237-244.
  33. Park, S. Signal space interpretations of Hopfield neural network for optimization. In IEEE International Symposium on Circuits and Systems, 1989. (1989), IEEE, pp. 2181-2184.
  34. Pavlov, I. P., and ANREP, G. V. Conditioned Reexes. An Investigation of the Physiological Activity of the Cerebral Cortex. Translated and Edited by GV Anrep. London, 1927.
  35. Platt, J. C., and Barr, A. H. Constrained dierential optimization for neural networks.
  36. Qin, K. On chaotic neural network design: A new framework. Neural Processing Letters (2016), 1-19.
  37. Ramón y Cajal, S. Sur la structure de l'écorce cérébrale de quelques mammifères. Typ. de Joseph van In & Cie.; Aug. Peeters, lib, 1891.
  38. Reinelt, G. TSPLIB. A traveling salesman problem library. ORSA journal on computing 3, 4 (1991), 376-384.
  39. Rojas, R. Neural networks: a systematic introduction. Springer Science & Business Media, 2013.
  40. Rosenblatt, F. The perceptron: A probabilistic model for information storage and organization in the brain. Psychological review 65, 6 (1958), 386.
  41. Rumelhart, D. E., Hinton, G. E., and Williams, R. J. Learning representations by backpropagating errors. Cognitive modeling 5, 3 (1988), 1.
  42. Rumelhart, D. E., McClelland, J. L., Group, P. R., et al. Parallel distributed processing: Explorations in the microstructures of cognition. volume 1: Foundations, 1986.
  43. Salcedo-Sanz, S., Ortiz-García, E. G., Pérez-Bellido, Á. M., Portilla-Figueras, A., and López-Ferreras, F. On the performance of the LP-guided Hopfield network-genetic algorithm. Computers & Operations Research 36, 7 (2009), 2210-2216.
  44. Serpen, G. Adaptive Hopfield Network. Springer Berlin Heidelberg, Berlin, Heidelberg, 2003, pp. 3-10.
  45. Shepherd, G. M. The synaptic organization of the brain. Oxford University Press, 2003.
  46. Suh, T., and Esat, I. I. Solving large scale combinatorial optimisation problems based on a divide and conquer strategy. Neural Computing & Applications 7, 2 (1998), 166-179.
  47. Sun, Y., Wang, Z., and Van Wyk, B. J. Chaotic Hopfield neural network swarm optimization and its application. Journal of Applied Mathematics 2013 (2013).
  48. Talaván, P. M. El modelo de Hopfield aplicado a problemas de optimización combinatoria. PhD thesis, Universidad Complutense de Madrid, 2003.
  49. Talaván, P. M., and Yáñez, J. Parameter setting of the Hopfield network applied to TSP. Neural Networks 15, 3 (2002), 363-373.
  50. Talaván, P. M., and Yáñez, J. A continuous Hopfield network equilibrium points algorithm. Computers & operations research 32, 8 (2005), 2179-2196.
  51. Talaván, P. M., and Yáñez, J. The Generalized Quadratick Knapsack Problem. A neuronal network approach. Neural networks 19, 4 (2006), 416-428.
  52. Tan, K. C., Tang, H., and Ge, S. S. On parameter settings of Hopfield networks applied to traveling salesman problems. IEEE Transactions on Circuits and Systems I: Regular Papers 52, 5 (2005), 994-1002.
  53. Tang, H., Tan, K. C., and Yi, Z. A columnar competitive model for solving combinatorial optimization problems. IEEE Transactions on Neural Networks 15, 6 (2004), 1568-1574.
  54. Wang, R. L., Tang, Z., and Cao, Q. P. A learning method in Hopfield neural network for combinatorial optimization problem. Neurocomputing 48, 1 (2002), 1021-1024.
  55. Wasserman, P. D., and Meyer-Arendt, J. R. Neural computing, theory and practice. Applied Optics 29 (1990), 2503.
  56. Wen, U.-P., Lan, K.-M., and Shih, H.-S. A review of Hopfield neural networks for solving mathematical programming problems. European Journal of Operational Research 198, 3 (2009), 675-687.
  57. Widrow, B., Hoff, M. E., et al. Adaptive switching circuits. In IRE WESCON convention record (1960), vol. 4, New York, pp. 96-104.
  58. Wilson, G., and Pawley, G. On the stability of the travelling salesman problem algorithm of Hopfield and Tank. Biological Cybernetics 58, 1 (1988), 63-70.
  59. Woeginger, G. J. Exact algorithms for NP-hard problems: A survey. In Combinatorial Optimization - Eureka, You Shrink! Springer, 2003, pp. 185-207.
\ No newline at end of file diff --git a/help/html/chn_release_notes.html b/help/html/chn_release_notes.html index 5dc2c59..92592d1 100644 --- a/help/html/chn_release_notes.html +++ b/help/html/chn_release_notes.html @@ -6,7 +6,7 @@ Hopfield Network Toolbox Release Notes

Hopfield Network Toolbox Release Notes

This toolbox is solves combinatorial optimization problems by using Continuous Hopfield Networks (CHN).

The Hopfield Network Toolbox requires the following products: MATLAB® and Statistics and Machine Learning Toolbox™

Contents

Version 1.1.2, 09-Apr-2017

Minor Bugs

List of Bugs fixed and Enhancements in this release.

Version 1.1.2 on GitHub

Version 1.1.1, 21-Feb-2016

Bug fixing for Unix platforms

List of Bugs fixed in this release.

Version 1.1.1 on GitHub

Version 1.1, 21-Feb-2016

New App, Toolbox Documentation and Examples.

New Features:

  • Hopfield Net TSP solver App
  • Toolbox documentation
  • Step-by-step examples
  • TSPLIB automatic download

List of Bugs fixed in this release.

Version 1.1 on GitHub

Version 1.0, 02-Nov-2015

Initial release of Hopfield Network Toolbox.

This release is mainly focused in solving the Traveling Salesman Problem using the Continuous Hopfield Network (CHN). However, the release also provides a class structure to solve generic combinatorial optimization problems. Development in this area is undergoing.

The class to solve the TSP problems using CHNs is tsphopfieldnet. This network can solve any TSP problem, provided its coordinates or distance matrix. The Toolbox also includes the library TSPLIB, a de facto library for TSP benchmarks. Instances with up to 13509 cities have been tested using the tsphopfieldnet network. Note that solving such instances might require a large amount of memory.

Two main algorithms can be tested in this release:

  • talavan-yanez: based on the paper Parameter setting of the Hopfield network applied to TSP by Pedro M. Talaván and Javier Yáñez.
  • divide-conquer: based on the paper (pending publishing at the time of this release) Improving the Hopfield model performance when applied to the traveling salesman problem: A divide-and-conquer scheme by Lucas García, Pedro M. Talaván and Javier Yáñez.

Version 1.0 on GitHub

References

The latest version of this toolbox is available on GitHub.

This toolbox is solves combinatorial optimization problems by using Continuous Hopfield Networks (CHN).

The Hopfield Network Toolbox requires the following products: MATLAB® and Statistics and Machine Learning Toolbox™

Contents

Version 2.0, 21-Sep-2017

New App, Simulink Models, Runge-Kutta simulation method for TSP and GQKP, improved documentation, new examples, minor bugs and enhancements

List of Bugs fixed and Enhancements in this release.

Version 2.0 on GitHub

Version 1.2, 30-Jun-2017

Interface redesign to include schemes. Minor bugs and enhancements

List of Bugs fixed and Enhancements in this release.

Version 1.2 on GitHub

Version 1.1.2, 09-Apr-2017

Minor Bugs

List of Bugs fixed and Enhancements in this release.

Version 1.1.2 on GitHub

Version 1.1.1, 21-Feb-2016

Bug fixing for Unix platforms

List of Bugs fixed in this release.

Version 1.1.1 on GitHub

Version 1.1, 21-Feb-2016

New App, Toolbox Documentation and Examples.

New Features:

  • Hopfield Net TSP solver App
  • Toolbox documentation
  • Step-by-step examples
  • TSPLIB automatic download

List of Bugs fixed in this release.

Version 1.1 on GitHub

Version 1.0, 02-Nov-2015

Initial release of Hopfield Network Toolbox.

This release is mainly focused in solving the Traveling Salesman Problem using the Continuous Hopfield Network (CHN). However, the release also provides a class structure to solve generic combinatorial optimization problems. Development in this area is undergoing.

The class to solve the TSP problems using CHNs is tsphopfieldnet. This network can solve any TSP problem, provided its coordinates or distance matrix. The Toolbox also includes the library TSPLIB, a de facto library for TSP benchmarks. Instances with up to 13509 cities have been tested using the tsphopfieldnet network. Note that solving such instances might require a large amount of memory.

Two main algorithms can be tested in this release:

  • talavan-yanez: based on the paper Parameter setting of the Hopfield network applied to TSP by Pedro M. Talaván and Javier Yáñez.
  • divide-conquer: based on the paper (pending publishing at the time of this release) Improving the Hopfield model performance when applied to the traveling salesman problem: A divide-and-conquer scheme by Lucas García, Pedro M. Talaván and Javier Yáñez.

Version 1.0 on GitHub

References

The latest version of this toolbox is available on GitHub.

Hopfield Network Toolbox System Requirements

Hopfield Network Toolbox System Requirements

Hopfield Network Toolbox requires MATLAB® and Statistics and Machine Learning Toolbox™

Hopfield Network Toolbox User's Guidechn_users_guide_howToUse \ No newline at end of file diff --git a/help/html/chn_users_guide_TSP.html b/help/html/chn_users_guide_TSP.html index 7e9d92f..b6b71a1 100644 --- a/help/html/chn_users_guide_TSP.html +++ b/help/html/chn_users_guide_TSP.html @@ -6,7 +6,7 @@ How to solve the Traveling Salesman Problem using Hopfield Networks

How to solve the Traveling Salesman Problem using Hopfield Networks

The Continuous Hopfield Network has been extensively used to solve the Travelling Salesman Problem. However, only after Talaván and Yáñez's approach with an appropriate problem parametrization, it is reasonable to solve the TSP using a Hopfield Network, as obtaining a feasible solution is guaranteed.

The Hopfield Network tsphopfieldnet can solve the following types of problems:

What is hopfieldnet?

What is hopfieldnet?

hopfieldnet is a MATLAB class that has been developed to solve the Continuous Hopfield Network using MATLAB.

hopfieldnet has been programmed in a similiar way to other Artificial Neural Networks available in Neural Network Toolbox™, using classdef to create and design the class.

hopfielnet is a generic class which can be used to solve any kind of combinatorial optimization problem.

A child class from hopfielnet, tsphopfieldnet, is specially focused in solving the Traveling Salesman Problem using Continuous Hopfield Networks. See the examples using tsphopfieldnet to learn more.

\ No newline at end of file diff --git a/help/html/chn_users_guide_howToUseCreateOptions.html b/help/html/chn_users_guide_howToUseCreateOptions.html deleted file mode 100644 index 826d2c9..0000000 --- a/help/html/chn_users_guide_howToUseCreateOptions.html +++ /dev/null @@ -1,379 +0,0 @@ - - - - - How to use tsphopfieldnet and createOptions

How to use tsphopfieldnet and createOptions

tsphopfieldnet is the class that creates Continuous Hopfield Networks for solving the Traveling Salesman Problem.

Contents

How tsphopfieldnet works

tsphopfieldnet's default behavior is to take only 2 input arguments:

  • N: number of cities
  • C: free parameter (greater than 0)

In this case, the cities are place in the vertices of regular polygons (see Example).

Optionally, tsphopfieldnet may receive a third input argument that gives further information of the TSP problem considered. This should be the case for most of the TSP problems you may want to solve.

Syntax

    net = tsphopfieldnet(N,C)
-    net = tsphopfieldnet(N,C,options)

How tsphopfieldnetOptions work

tsphopfieldnetOptions is a class for tsphopfieldnet that allows to specify the details of each TSP problem.

Syntax

    options = tsphopfieldnetOptions('param1','value1','param2','value2',...)

The following table lists the available options for tsphopfieldnet.

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
OptionValueDescription
'Coordinates'Nx2 real numeric matrixTSP coordinates
'DistanceMatrix'NxN real numeric matrixTSP distance matrix
'DistanceType''EUC'
'EUC_2D'
'GEO'
'ATT'
'CEIL_2D'
'EXPLICIT'
Distance type
'Names'1xN cellTSP city names
'Subtours'1xN cellTSP fixed subtours
'SubtoursPositions'1xN matrixTSP fixed subtours starting positions
'Tau'1x1 doubleNumber of neighboring cities
'SimFcn''euler'
'talavan-yanez'
'divide-conquer'
Simulation method
'TrainFcn''trainty'Training method
'K'1x1 doubleNumber of chains
'CheckpointPath'charValid writable path to store simulation
'Dt'1x1 doubleStep for Euler method
'E'1x1 doubleTolerance exponent
'ExecutionEnvironment''CPU'
'GPU'
Hardware resources
'MaxIter'1x1 doubleMaximum number of iterations
'Q'1x1 doubleParameter factor for reducing
integration step
'R_Iter'1x1 doubleNumber of iterations for reducing
integration step
'SimulationPlot'1x1 logicalShow simulation process plot
'SimulationPlotPauseTime'1x1 doublePause time during simulation
process plot
'TransferFcn''satlin'
'tanh'
Transfer function
'U0'1x1 doubleInitial potential
'Verbose'1x1 logicalDisplay information of
simulation process
'VerboseFrequency'1x1 integer valueFrequency of verbose printing
-

See Examples using TSPLIB or when city coordinates or distance matrix are provided.

\ No newline at end of file diff --git a/help/html/chn_users_guide_howToUseTsphopfieldnetOptions.html b/help/html/chn_users_guide_howToUseTsphopfieldnetOptions.html new file mode 100644 index 0000000..af56928 --- /dev/null +++ b/help/html/chn_users_guide_howToUseTsphopfieldnetOptions.html @@ -0,0 +1,407 @@ + + + + + How to use tsphopfieldnet and tsphopfieldnetOptions

How to use tsphopfieldnet and tsphopfieldnetOptions

tsphopfieldnet is a function that returns an object of the class HopfieldNetworkTSP. This object is a Continuous Hopfield Network designed to solve the Traveling Salesman Problem.

At the same time, tsphopfieldnetOptions returns an object of the class HopfieldNetworkTSPOptions. Such object may be used to customize the Hopfield network object from HopfieldNetworkTSP.

Contents

How tsphopfieldnet works

tsphopfieldnet's default behavior is to take only 2 input arguments:

  • N: number of cities
  • C: free parameter (greater than 0)

In this case, the cities are place in the vertices of regular polygons (see Example).

Optionally, tsphopfieldnet may receive a third input argument (of the class HopfieldNetworkTSPOptions using the function tsphopfieldnetOptions) which gives further information of the TSP problem considered. This way an arbitrary TSP problem can be created.

Syntax

    net = tsphopfieldnet(N,C)
+    net = tsphopfieldnet(N,C,options)

How tsphopfieldnetOptions works

tsphopfieldnetOptions is a function returning an object of the class HopfieldNetworkTSPOptions which allows to specify all the settings and details of the TSP problem.

Syntax

    options = tsphopfieldnetOptions('param1','value1','param2','value2',...)

The following table lists the available options for HopfieldNetworkTSPOptions.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
OptionValueDescription
'Scheme''classic' (default) | 'divide-conquer' | '2opt' | 'classic&2opt' | 'divide-conquer&2opt'Architecture or scheme of the Hopfield model
'SimFcn''euler' | 'runge-kutta' | 'talavan-yanez' (default)CHN Simulation method
'TrainFcn''trainty'Training method for the CHN applied to the TSP
'K'0 (default) | scalar integer value greater or equal than 0Number of fixed chains
'Coordinates'[] (default) | real-value 2-column matrixTSP Cities' coordinates
'DistanceMatrix'[] (default) | real-value square matrixTSP Distance Matrix
'DistanceType''geo' | 'euc_2d' | 'euc' (default) | 'att' | 'ceil_2d' | 'explicit'Distance type between TSP cities
'Names''' (default) | cell array of stringsTSP city names
'PlotPhase'false (default) | trueIndicator to display the result of the phases in 'divide-conquer'
'Subtours''' (default) | cell array of stringsChains of cities separated by hyphens
'SubtoursPositions'[] (default) | vector of integer values with as many columns as elements in 'Subtours'Location of the first city in each pre-fixed chains of cities in 'Subtours'
'Tau'[] (default) | scalar integer valueNumber of neighboring cities considered in the first phase of 'divide-conquer'
'CheckpointPath''' (default) | character vectorPath to store the simulation trayectory
'Dt'0.01 (default) | scalar positive valueIntegration step for 'euler' and 'runge-kutta' methods
'E'13 (default) | scalar positive integer valueExponent for the stopping criteria tolerance, 1e-E
'ExecutionEnvironment''cpu' (default) | 'gpu'Execution environment of the CHN
'MaxIter'2000 (default) | scalar positive integer valueMaximum number of iterations
'Q'0.8 (default) | scalar positive valueIntegration step reduction in 'talavan-yanez' during the first 'R_Iter' iterations
'R_Iter'20 (default) | scalar positive integer valueNumber of iterations in 'talavan-yanez' where the integration step is reduced
'SimulationPlot'false (default) | trueIndicator to visualize the simulation
'SimulationPlotPauseTime'0.8 (default) | scalar positive valuePause time in between iterations in the visualization of the simulation
'TransferFcn''satlin' | 'tanh' (default)Activation or Transfer function
'U0'0.3 (default) | scalar positive valueSlope of the transfer function
'Verbose'false (default) | trueIndicator to show information on the simulation of the CHN
'VerboseFrequency'25 (default) | scalar positive integer valueFrequency of verbose printing
+

See Examples using TSPLIB or when city coordinates or distance matrix are provided.

\ No newline at end of file diff --git a/help/html/chn_users_guide_howToUsehopfieldnetOptions.html b/help/html/chn_users_guide_howToUsehopfieldnetOptions.html new file mode 100644 index 0000000..6ff8db6 --- /dev/null +++ b/help/html/chn_users_guide_howToUsehopfieldnetOptions.html @@ -0,0 +1,315 @@ + + + + + How to use hopfieldnet and hopfieldnetOptions

How to use hopfieldnet and hopfieldnetOptions

hopfieldnet is a function that returns an object of the class HopfieldNetworkGQKP. This object is a Continuous Hopfield Network designed to solve the Generalized Quadratic Knapsack Problem.

At the same time, hopfieldnetOptions returns an object of the class HopfieldNetworkGQKPOptions. Such object may be used to customize the Hopfield network object from HopfieldNetworkGQKP.

Contents

How hopfieldnet works

hopfieldnet's default behavior is to take 6 input arguments:

  • P: Square matrix defining the quadratic term of the optimization problem
  • q: Vector defining the linear term of the optimization problem
  • Aeq: Matrix defining the linear equality constraints. Aeq*x = beq
  • beq: Vector defining the linear equality constraints. Aeq*x = beq
  • A: Matrix defining the linear inequality constraints. A*x <= b
  • b: Vector defining the linear inequality constraints. A*x <= b

Optionally, hopfieldnet may receive a seven input argument (of the class HopfieldNetworkGQKPOptions using the function hopfieldnetOptions) which gives further information of the GQKP problem considered. This way an arbitrary GQKP problem can be created.

Syntax

    net = hopfieldnet(P,q,Aeq,beq,A,b)
+    net = hopfieldnet(P,q,Aeq,beq,A,b,options)

How hopfieldnetOptions works

hopfieldnetOptions is a function returning an object of the class HopfieldNetworkGQKPOptions which allows to specify all the settings and details of the GQKP problem.

Syntax

    options = hopfieldnetOptions('param1','value1','param2','value2',...)

The following table lists the available options for HopfieldNetworkGQKPOptions.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
OptionValueDescription
'Scheme''classic'Architecture or scheme of the Hopfield model
'SimFcn''euler' | 'runge-kutta' | 'talavan-yanez' (default)CHN Simulation method
'TrainFcn''traingty'Training method for the CHN applied to the GQKP
'CheckpointPath''' (default) | character vectorPath to store the simulation trayectory
'Dt'0.01 (default) | scalar positive valueIntegration step for 'euler' and 'runge-kutta' methods
'E'13 (default) | scalar positive integer valueExponent for the stopping criteria tolerance, 1e-E
'ExecutionEnvironment''cpu' (default) | 'gpu'Execution environment of the CHN
'MaxIter'2000 (default) | scalar positive integer valueMaximum number of iterations
'Q'0.8 (default) | scalar positive valueIntegration step reduction in 'talavan-yanez' during the first 'R_Iter' iterations
'R_Iter'20 (default) | scalar positive integer valueNumber of iterations in 'talavan-yanez' where the integration step is reduced
'SimulationPlot'false (default) | trueIndicator to visualize the simulation
'SimulationPlotPauseTime'0.8 (default) | scalar positive valuePause time in between iterations in the visualization of the simulation
'TransferFcn''satlin' | 'tanh' (default)Activation or Transfer function
'U0'0.3 (default) | scalar positive valueSlope of the transfer function
'Verbose'false (default) | trueIndicator to show information on the simulation of the CHN
'VerboseFrequency'25 (default) | scalar positive integer valueFrequency of verbose printing
+

See example to solve a GQKP using a CHN.

\ No newline at end of file diff --git a/help/html/chn_users_guide_improve.html b/help/html/chn_users_guide_improve.html index 07ce564..bac52e2 100644 --- a/help/html/chn_users_guide_improve.html +++ b/help/html/chn_users_guide_improve.html @@ -6,7 +6,7 @@ How to solve improve the performance of the Hopfield Network for the TSP

How to solve improve the performance of the Hopfield Network for the TSP using Hybrid methods

\ No newline at end of file diff --git a/help/html/chn_users_guide_tsplib.html b/help/html/chn_users_guide_tsplib.html index b436504..a1d004c 100644 --- a/help/html/chn_users_guide_tsplib.html +++ b/help/html/chn_users_guide_tsplib.html @@ -6,7 +6,7 @@ TSPLIB - A library for Traveling Salesman Problems -% -% -% -% -% -% -% -% -% -% -% -% -% -% -% -% -% -% -% -% -% -% -% -% -% -% -% -% -% -% -% -% -% -% -% -% -% -% -% -% -% -% -% -% -% -% -% -% -% -% -% -% -% -% -% -% -% -% -% -% -% -% -% -% -% -% -% -% -% -% -% -% -% -% -% -% -% -% -% -% -% -% -% -% -% -% -% -% -% -% -% -% -% -% -% -% -% -% -% -% -% -% -% -% -% -% -% -% -% -% -% -% -% -% -% -% -% -% -% -% -% -%
OptionValueDescription
'Coordinates'Nx2 real numeric matrixTSP coordinates
'DistanceMatrix'NxN real numeric matrixTSP distance matrix
'DistanceType''EUC'
'EUC_2D'
'GEO'
'ATT'
'CEIL_2D'
'EXPLICIT'
Distance type
'Names'1xN cellTSP city names
'Subtours'1xN cellTSP fixed subtours
'SubtoursPositions'1xN matrixTSP fixed subtours starting positions
'Tau'1x1 doubleNumber of neighboring cities
'SimFcn''euler'
'talavan-yanez'
'divide-conquer'
Simulation method
'TrainFcn''trainty'Training method
'K'1x1 doubleNumber of chains
'CheckpointPath'charValid writable path to store simulation
'Dt'1x1 doubleStep for Euler method
'E'1x1 doubleTolerance exponent
'ExecutionEnvironment''CPU'
'GPU'
Hardware resources
'MaxIter'1x1 doubleMaximum number of iterations
'Q'1x1 doubleParameter factor for reducing
integration step
'R_Iter'1x1 doubleNumber of iterations for reducing
integration step
'SimulationPlot'1x1 logicalShow simulation process plot
'SimulationPlotPauseTime'1x1 doublePause time during simulation
process plot
'TransferFcn''satlin'
'tanh'
Transfer function
'U0'1x1 doubleInitial potential
'Verbose'1x1 logicalDisplay information of
simulation process
'VerboseFrequency'1x1 integer valueFrequency of verbose printing
-% -% -%% -% See Examples using or when -% or -% are provided. diff --git a/help_source/chn_users_guide_howToUseTsphopfieldnetOptions.m b/help_source/chn_users_guide_howToUseTsphopfieldnetOptions.m new file mode 100644 index 0000000..a92e223 --- /dev/null +++ b/help_source/chn_users_guide_howToUseTsphopfieldnetOptions.m @@ -0,0 +1,191 @@ +%% How to use tsphopfieldnet and tsphopfieldnetOptions +% |tsphopfieldnet| is a function that returns an object of the class +% |HopfieldNetworkTSP|. This object is a Continuous Hopfield Network +% designed to solve the Traveling Salesman Problem. +% +% At the same time, |tsphopfieldnetOptions| returns an object of the class +% |HopfieldNetworkTSPOptions|. Such object may be used to customize the +% Hopfield network object from |HopfieldNetworkTSP|. +% +%% How |tsphopfieldnet| works +% |tsphopfieldnet|'s default behavior is to take only 2 input arguments: +%% +% * N: number of cities +% * C: free parameter (greater than 0) +% +% In this case, the cities are place in the vertices of regular polygons +% (see ). +% +% Optionally, |tsphopfieldnet| may receive a third input argument (of the +% class |HopfieldNetworkTSPOptions| using the function +% |tsphopfieldnetOptions|) which gives further information of the TSP +% problem considered. This way an arbitrary TSP problem can be created. +% +%% +% *Syntax* +% +% net = tsphopfieldnet(N,C) +% net = tsphopfieldnet(N,C,options) +% +%% How |tsphopfieldnetOptions| works +% |tsphopfieldnetOptions| is a function returning an object of the class +% |HopfieldNetworkTSPOptions| which allows to specify all the settings and +% details of the TSP problem. +% +%% +% *Syntax* +% +% options = tsphopfieldnetOptions('param1','value1','param2','value2',...) + +%% +% The following table lists the available options for +% |HopfieldNetworkTSPOptions|. +% +% +% +% +% +% +% +% +% +% +% +% +% +% +% +% +% +% +% +% +% +% +% +% +% +% +% +% +% +% +% +% +% +% +% +% +% +% +% +% +% +% +% +% +% +% +% +% +% +% +% +% +% +% +% +% +% +% +% +% +% +% +% +% +% +% +% +% +% +% +% +% +% +% +% +% +% +% +% +% +% +% +% +% +% +% +% +% +% +% +% +% +% +% +% +% +% +% +% +% +% +% +% +% +% +% +% +% +% +% +% +% +% +% +% +% +% +% +% +% +% +% +% +% +% +% +% +% +% +% +% +% +% +% +%
OptionValueDescription
'Scheme''classic' (default) | 'divide-conquer' | '2opt' | 'classic&2opt' | 'divide-conquer&2opt'Architecture or scheme of the Hopfield model
'SimFcn''euler' | 'runge-kutta' | 'talavan-yanez' (default)CHN Simulation method
'TrainFcn''trainty'Training method for the CHN applied to the TSP
'K'0 (default) | scalar integer value greater or equal than 0Number of fixed chains
'Coordinates'[] (default) | real-value 2-column matrixTSP Cities' coordinates
'DistanceMatrix'[] (default) | real-value square matrixTSP Distance Matrix
'DistanceType''geo' | 'euc_2d' | 'euc' (default) | 'att' | 'ceil_2d' | 'explicit'Distance type between TSP cities
'Names''' (default) | cell array of stringsTSP city names
'PlotPhase'false (default) | trueIndicator to display the result of the phases in 'divide-conquer'
'Subtours''' (default) | cell array of stringsChains of cities separated by hyphens
'SubtoursPositions'[] (default) | vector of integer values with as many columns as elements in 'Subtours'Location of the first city in each pre-fixed chains of cities in 'Subtours'
'Tau'[] (default) | scalar integer valueNumber of neighboring cities considered in the first phase of 'divide-conquer'
'CheckpointPath''' (default) | character vectorPath to store the simulation trayectory
'Dt'0.01 (default) | scalar positive valueIntegration step for 'euler' and 'runge-kutta' methods
'E'13 (default) | scalar positive integer valueExponent for the stopping criteria tolerance, 1e-E
'ExecutionEnvironment''cpu' (default) | 'gpu'Execution environment of the CHN
'MaxIter'2000 (default) | scalar positive integer valueMaximum number of iterations
'Q'0.8 (default) | scalar positive valueIntegration step reduction in 'talavan-yanez' during the first 'R_Iter' iterations
'R_Iter'20 (default) | scalar positive integer valueNumber of iterations in 'talavan-yanez' where the integration step is reduced
'SimulationPlot'false (default) | trueIndicator to visualize the simulation
'SimulationPlotPauseTime'0.8 (default) | scalar positive valuePause time in between iterations in the visualization of the simulation
'TransferFcn''satlin' | 'tanh' (default)Activation or Transfer function
'U0'0.3 (default) | scalar positive valueSlope of the transfer function
'Verbose'false (default) | trueIndicator to show information on the simulation of the CHN
'VerboseFrequency'25 (default) | scalar positive integer valueFrequency of verbose printing
+% +% +%% +% See Examples using or when +% or +% are provided. diff --git a/help_source/chn_users_guide_howToUsehopfieldnetOptions.m b/help_source/chn_users_guide_howToUsehopfieldnetOptions.m new file mode 100644 index 0000000..3cf9e82 --- /dev/null +++ b/help_source/chn_users_guide_howToUsehopfieldnetOptions.m @@ -0,0 +1,145 @@ +%% How to use hopfieldnet and hopfieldnetOptions +% |hopfieldnet| is a function that returns an object of the class +% |HopfieldNetworkGQKP|. This object is a Continuous Hopfield Network +% designed to solve the Generalized Quadratic Knapsack Problem. +% +% At the same time, |hopfieldnetOptions| returns an object of the class +% |HopfieldNetworkGQKPOptions|. Such object may be used to customize the +% Hopfield network object from |HopfieldNetworkGQKP|. +% +%% How |hopfieldnet| works +% |hopfieldnet|'s default behavior is to take 6 input arguments: +%% +% * P: Square matrix defining the quadratic term of the optimization problem +% * q: Vector defining the linear term of the optimization problem +% * Aeq: Matrix defining the linear equality constraints. Aeq*x = beq +% * beq: Vector defining the linear equality constraints. Aeq*x = beq +% * A: Matrix defining the linear inequality constraints. A*x <= b +% * b: Vector defining the linear inequality constraints. A*x <= b +% +% Optionally, |hopfieldnet| may receive a seven input argument (of the +% class |HopfieldNetworkGQKPOptions| using the function +% |hopfieldnetOptions|) which gives further information of the GQKP +% problem considered. This way an arbitrary GQKP problem can be created. +% +%% +% *Syntax* +% +% net = hopfieldnet(P,q,Aeq,beq,A,b) +% net = hopfieldnet(P,q,Aeq,beq,A,b,options) +% +%% How |hopfieldnetOptions| works +% |hopfieldnetOptions| is a function returning an object of the class +% |HopfieldNetworkGQKPOptions| which allows to specify all the settings and +% details of the GQKP problem. +% +%% +% *Syntax* +% +% options = hopfieldnetOptions('param1','value1','param2','value2',...) + +%% +% The following table lists the available options for +% |HopfieldNetworkGQKPOptions|. +% +% +% +% +% +% +% +% +% +% +% +% +% +% +% +% +% +% +% +% +% +% +% +% +% +% +% +% +% +% +% +% +% +% +% +% +% +% +% +% +% +% +% +% +% +% +% +% +% +% +% +% +% +% +% +% +% +% +% +% +% +% +% +% +% +% +% +% +% +% +% +% +% +% +% +% +% +% +% +% +% +% +% +% +% +% +% +% +% +%
OptionValueDescription
'Scheme''classic'Architecture or scheme of the Hopfield model
'SimFcn''euler' | 'runge-kutta' | 'talavan-yanez' (default)CHN Simulation method
'TrainFcn''traingty'Training method for the CHN applied to the GQKP
'CheckpointPath''' (default) | character vectorPath to store the simulation trayectory
'Dt'0.01 (default) | scalar positive valueIntegration step for 'euler' and 'runge-kutta' methods
'E'13 (default) | scalar positive integer valueExponent for the stopping criteria tolerance, 1e-E
'ExecutionEnvironment''cpu' (default) | 'gpu'Execution environment of the CHN
'MaxIter'2000 (default) | scalar positive integer valueMaximum number of iterations
'Q'0.8 (default) | scalar positive valueIntegration step reduction in 'talavan-yanez' during the first 'R_Iter' iterations
'R_Iter'20 (default) | scalar positive integer valueNumber of iterations in 'talavan-yanez' where the integration step is reduced
'SimulationPlot'false (default) | trueIndicator to visualize the simulation
'SimulationPlotPauseTime'0.8 (default) | scalar positive valuePause time in between iterations in the visualization of the simulation
'TransferFcn''satlin' | 'tanh' (default)Activation or Transfer function
'U0'0.3 (default) | scalar positive valueSlope of the transfer function
'Verbose'false (default) | trueIndicator to show information on the simulation of the CHN
'VerboseFrequency'25 (default) | scalar positive integer valueFrequency of verbose printing
+% +% +%% +% See to solve a GQKP using a CHN. \ No newline at end of file diff --git a/help_source/chn_users_guide_improveHybrid.m b/help_source/chn_users_guide_improveHybrid.m index 23048a6..6707a4a 100644 --- a/help_source/chn_users_guide_improveHybrid.m +++ b/help_source/chn_users_guide_improveHybrid.m @@ -1,4 +1,4 @@ %% How to solve improve the performance of the Hopfield Network for the TSP using Hybrid methods % -% * -% +% * +% * diff --git a/help_source/publishingHelpFiles.m b/help_source/publishingHelpFiles.m index 7f302af..2a5e266 100644 --- a/help_source/publishingHelpFiles.m +++ b/help_source/publishingHelpFiles.m @@ -2,7 +2,8 @@ customXsl = fullfile(mainFolder,'help_source','mxdom2mathjax.xsl'); addpath(mainFolder) -addpath(genpath(fullfile(mainFolder,'TSPFiles'))); +addpath(fullfile(mainFolder,'chn')); +addpath(genpath(fullfile(mainFolder,'data','TSPFiles'))); helpFolder = fullfile(mainFolder,'help'); helpSourceFilesLocation = fullfile(mainFolder,'help_source'); @@ -20,8 +21,11 @@ publish(fullfile(helpSourceFilesLocation,'chn_users_guide'),optionsPublish); publish(fullfile(helpSourceFilesLocation,'chn_users_guide_hopfieldnet'),optionsPublish); publish(fullfile(helpSourceFilesLocation,'chn_users_guide_tsplib'),optionsPublish); -publish(fullfile(helpSourceFilesLocation,'chn_users_guide_howToUseCreateOptions'),optionsPublish); +publish(fullfile(helpSourceFilesLocation,'chn_users_guide_howToUseTsphopfieldnetOptions'),optionsPublish); +publish(fullfile(helpSourceFilesLocation,'chn_users_guide_howToUsehopfieldnetOptions'),optionsPublish); publish(fullfile(helpSourceFilesLocation,'chn_users_guide_TSP'),optionsPublish); +publish(fullfile(helpSourceFilesLocation,'chn_users_guide_SimulinkModels'),optionsPublish); +publish(fullfile(helpSourceFilesLocation,'chn_references'),optionsPublish); publish(fullfile(helpFolder,'Example_tspUsingRegularPolygons')); publish(fullfile(helpFolder,'Example_tspUsingTSPLIB')); publish(fullfile(helpFolder,'Example_tspUsingCoords')); @@ -31,10 +35,14 @@ publish(fullfile(helpFolder,'Example_tspSaddlePoint')); publish(fullfile(helpSourceFilesLocation,'chn_users_guide_improveHybrid'),optionsPublish); publish(fullfile(helpFolder,'Example_tspDivideConquer')); +publish(fullfile(helpFolder,'Example_tsp2opt')); publish(fullfile(helpSourceFilesLocation,'chn_TSP_APP'),optionsPublish); +publish(fullfile(helpFolder,'Example_GQKPusingCHN')); +publish(fullfile(helpFolder,'Example_SimulinkDiscrete')); +publish(fullfile(helpFolder,'Example_SimulinkContinuous')); builddocsearchdb(fullfile(pwd,helpFolder,'html')); -rmpath(genpath(fullfile(helpSourceFilesLocation))) +rmpath(fullfile(helpSourceFilesLocation)) close all;