0

This might be a simple question but I have been struggling with this for a while.

I am using flow control to introduce lazy constraints when solving a problem that is very similar to a TSP. I found the CPLEX TSP example which I can follow well and use as a starting point to solve my problem.

Is there a way to export the solution of the CPLEX TSP example to a csv/excel sheet?

1 Answers1

0

In Excel, Rocket science and optimization I shared an example

Traveling salesman with Excel

.mod

{int} solution=...;

.dat

SheetConnection s("travelingsalesman.xlsx");

solution to  SheetWrite(s,"output!B2:B1000");

In the CPLEX IDE

Alex Fleischer
  • 9,276
  • 2
  • 12
  • 15
  • Hi Alex, thanks for your answer. I have tried to follow this example but all I can seem to do is write the solution to the .dat file which then overwrites any of the code that was previously there. Is there something that I am missing here? Is there a way to maybe call another .dat file before the opl.end command that can handle writing to excel? – Kit Searle Apr 19 '22 at 10:33
  • First you need to run the configuration TSP which builds tspresult.dat – Alex Fleischer Apr 19 '22 at 10:47
  • This works now, thank you so much! I have one last question, is it possible to do the same for some other data type? So if for example I have an array which I write to tspresult.dat? – Kit Searle Apr 19 '22 at 14:46
  • I have figured this out, and you can. You would just need to correctly define the data structure in the tspexport.mod. You really were very helpful, thansk Alex! – Kit Searle Apr 19 '22 at 15:48