From 04a55c8b7d8b660c6917f6c01cda9d5a2e65188e Mon Sep 17 00:00:00 2001 From: Anatoliy-Litvinenko Date: Wed, 10 Mar 2021 16:05:38 -0600 Subject: [PATCH 01/12] Changed type of iterations to have them more. --- anneal.hpp | 2 +- hill_climbing.cpp | 14 +++++++------- hill_climbing.hpp | 4 ++-- marxan.cpp | 2 +- output.cpp | 2 +- quantum_annealing.cpp | 14 ++++++++------ thermal_annealing.cpp | 6 ++++-- 7 files changed, 24 insertions(+), 20 deletions(-) diff --git a/anneal.hpp b/anneal.hpp index b4e984b..a2878f1 100644 --- a/anneal.hpp +++ b/anneal.hpp @@ -5,7 +5,7 @@ namespace marxan { typedef struct sanneal { long int Titns; - long int iterations; + long long iterations; long int Tlen; double Tinit; /* Initial Temperature */ double Tcool; /* Cooling Factor */ diff --git a/hill_climbing.cpp b/hill_climbing.cpp index f2214ea..2658b41 100644 --- a/hill_climbing.cpp +++ b/hill_climbing.cpp @@ -67,7 +67,7 @@ namespace marxan { } - void append(int i, int puno, const scost& reserve, const scost& change, const vector& R) + void append(long long i, int puno, const scost& reserve, const scost& change, const vector& R) { iRowCounter++; if (iRowCounter > iRowLimit) @@ -75,9 +75,9 @@ namespace marxan { if (iRowCounter == 1) { - fprintf(Rfp, "%i", i); + fprintf(Rfp, "%lli", i); - fprintf(ttfp, "%i,%f,%i,%f,%f,%f,%f\n" + fprintf(ttfp, "%lli,%f,%i,%f,%f,%f,%f\n" , i, reserve.total , reserve.pus, reserve.cost, reserve.connection, reserve.penalty, change.total); // i,costthresh,pus,cost,connection,penalty @@ -121,7 +121,7 @@ namespace marxan { void hill_climbing(int puno, int spno, const vector& pu, const vector& connections, vector& spec, const vector& SM, vector& SM_out, vector& R, double cm, scost& reserve, double costthresh, double tpf1, double tpf2, - int clumptype, int irun, int iterations, string savename, stringstream& logBuffer, rng_engine& rngEngine) + int clumptype, int irun, long long iterations, string savename, stringstream& logBuffer, rng_engine& rngEngine) { scost change = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; int puvalid = 0, ipu = 0, imode, ichoice; @@ -156,7 +156,7 @@ namespace marxan { logBuffer << "Hill climbing after array init\n"; displayProgress2(" Main Hillclimbing Section.\n"); - for(int itime = 1; itime <= iterations; ) + for(long long itime = 1; itime <= iterations; ) { // shuffle iimp array std::shuffle(iimparray.begin(), iimparray.end(), rngEngine); @@ -196,7 +196,7 @@ namespace marxan { void hill_climbing_two_steps(int puno, int spno, const vector& pu, const vector& connections, vector& spec, const vector& SM, vector& SM_out, vector& R, double cm, scost& reserve, double costthresh, double tpf1, double tpf2, - int clumptype, int irun, int iterations, string savename, stringstream& logBuffer, rng_engine& rngEngine) + int clumptype, int irun, long long iterations, string savename, stringstream& logBuffer, rng_engine& rngEngine) { int puvalid = 0, ipu = 0; vector iimparray; @@ -231,7 +231,7 @@ namespace marxan { displayProgress2(" Main two step hillclimbing section.\n"); - for(int itime = 1; itime <= iterations; ) + for(long long itime = 1; itime <= iterations; ) { // shuffle iimp array std::shuffle(iimparray.begin(), iimparray.end(), rngEngine); diff --git a/hill_climbing.hpp b/hill_climbing.hpp index 60a7a61..4988021 100644 --- a/hill_climbing.hpp +++ b/hill_climbing.hpp @@ -27,11 +27,11 @@ namespace marxan { void hill_climbing(int puno, int spno, const vector& pu, const vector& connections, vector& spec, const vector& SM, vector& SM_out, vector& R, double cm, scost& reserve, double costthresh, double tpf1, double tpf2, - int clumptype, int irun, int iterations, string savename, stringstream& logBuffer, rng_engine& rngEngine); + int clumptype, int irun, long long iterations, string savename, stringstream& logBuffer, rng_engine& rngEngine); //consider two steps in a time, move if we found two steps which generates better solution void hill_climbing_two_steps(int puno, int spno, const vector& pu, const vector& connections, vector& spec, const vector& SM, vector& SM_out, vector& R, double cm, scost& reserve, double costthresh, double tpf1, double tpf2, - int clumptype, int irun, int iterations, string savename, stringstream& logBuffer, rng_engine& rngEngine); + int clumptype, int irun, long long iterations, string savename, stringstream& logBuffer, rng_engine& rngEngine); } // namespace marxan \ No newline at end of file diff --git a/marxan.cpp b/marxan.cpp index 2265f99..a2cd898 100644 --- a/marxan.cpp +++ b/marxan.cpp @@ -690,7 +690,7 @@ namespace marxan { anneal_global.Tlen = anneal_global.iterations / anneal_global.Titns; displayProgress2(" Temperature length %ld \n", anneal_global.Tlen); - displayProgress2(" iterations %ld, repeats %ld \n", anneal_global.iterations, repeats); + displayProgress2(" iterations %lld, repeats %ld \n", anneal_global.iterations, repeats); } // Annealing Preprocessing. Should be moved to SetAnnealingOptions if (fnames.savepenalty) diff --git a/output.cpp b/output.cpp index 6f27322..cfe6cd8 100644 --- a/output.cpp +++ b/output.cpp @@ -789,7 +789,7 @@ namespace marxan { if (runoptions.ThermalAnnealingOn) { - fprintf(fp, "Number of iterations %ld\n", anneal.iterations); + fprintf(fp, "Number of iterations %lld\n", anneal.iterations); if (anneal.Tinit >= 0) { fprintf(fp, "Initial temperature %.2f\n", anneal.Tinit); diff --git a/quantum_annealing.cpp b/quantum_annealing.cpp index 447d4ff..df565b1 100644 --- a/quantum_annealing.cpp +++ b/quantum_annealing.cpp @@ -271,7 +271,8 @@ namespace marxan { long int repeats, int irun, string savename, double misslevel, int aggexist, double costthresh, double tpf1, double tpf2, int clumptype, sanneal& anneal, rng_engine& rngEngine) { - long int itime, i, j, itemp = 0, snapcount, ichanges = 0, iGoodChange; + long long itime; + long int i, j, itemp = 0, snapcount, ichanges = 0, iGoodChange; long int iRowCounter, iRowLimit, iFluctuationCount; double rFluctuationMagnitude, rThreshold, rThresholdMultiplier, rAcceptanceProbability; @@ -279,7 +280,8 @@ namespace marxan { FILE* fp = nullptr, * ttfp = nullptr, * Rfp = nullptr; string writename, sDecayType; vector PUChosen; - long int iTests = 0, iIterations; + long int iTests = 0; + long long iIterations; uniform_real_distribution float_range(0.0, 1.0); if (iQADECAYTYPE == 0) @@ -287,7 +289,7 @@ namespace marxan { else sDecayType = "SIGMOIDAL"; - appendTraceFile("quantumAnnealing start iterations %ld decay type %s proportion %f decay A %f decay B %f acceptance probability %f saveannealingtrace %i\n", + appendTraceFile("quantumAnnealing start iterations %lld decay type %s proportion %f decay A %f decay B %f acceptance probability %f saveannealingtrace %i\n", anneal.iterations, sDecayType.c_str(), rQAPROP, rQADECAY, rQADECAYB, rQAACCPR, fnames.saveannealingtrace); if (verbosity > 4) { @@ -416,7 +418,7 @@ namespace marxan { } if (verbosity > 4) - fprintf(fp, "%li,%li,%li,%f,%f,%f,%f,%f\n", + fprintf(fp, "%lli,%li,%li,%f,%f,%f,%f,%f\n", itime, itemp, iGoodChange, change.total, change.cost, change.connection, change.penalty, anneal.temp); if (fnames.saveannealingtrace) @@ -427,9 +429,9 @@ namespace marxan { if (iRowCounter == 1) { - fprintf(Rfp, "%li", itime); + fprintf(Rfp, "%lli", itime); - fprintf(ttfp, "%li,%f,%li,%f,%i,%f,%f,%f\n", + fprintf(ttfp, "%lli,%f,%li,%f,%i,%f,%f,%f\n", itime, costthresh, iGoodChange, reserve.total, reserve.pus, reserve.cost, reserve.connection, reserve.penalty); if (fProb1D == 1) diff --git a/thermal_annealing.cpp b/thermal_annealing.cpp index 1d1df33..107a50f 100644 --- a/thermal_annealing.cpp +++ b/thermal_annealing.cpp @@ -39,7 +39,8 @@ namespace marxan { const vector& SM, vector& SM_out, double cm, sanneal& anneal, int aggexist, vector& R, double prop, int clumptype, int irun, stringstream& logBuffer, rng_engine& rngEngine) { - long int i, ipu, imode, iOldR; + long long i; + long int ipu, imode, iOldR; double deltamin = 0, deltamax = 0; double localdelta = 1E-10; scost change = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; @@ -165,7 +166,8 @@ namespace marxan { int aggexist, double costthresh, double tpf1, double tpf2, int clumptype, sanneal& anneal, stringstream& logBuffer, rng_engine& rngEngine) { scost change = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; - long int itime = 0, ipu = -1, i, itemp, snapcount = 0, ichanges = 0, iPreviousR, iGoodChange = 0; + long long itime = 0; + long int ipu = -1, i, itemp, snapcount = 0, ichanges = 0, iPreviousR, iGoodChange = 0; long int iRowCounter, iRowLimit; double rTemperature, rThreshold, rThresholdMultiplier; string tempname1, tempname2, sRun = to_string(irun), paddedRun = utils::intToPaddedString(irun, 5); From 2c760bea07fd5c07ee1d4b6f38c9fdcbc8bdfef4 Mon Sep 17 00:00:00 2001 From: Anatoliy-Litvinenko Date: Thu, 11 Mar 2021 09:25:36 -0600 Subject: [PATCH 02/12] Fixed methods description.. --- options.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/options.hpp b/options.hpp index 2d7394e..9e2e971 100644 --- a/options.hpp +++ b/options.hpp @@ -46,7 +46,7 @@ namespace marxan { //repace last comma with "and" auto pos = res.find_last_of(','); if(pos != string::npos) - res.replace(pos, pos+1, " and"); + res.replace(pos, 1, " and"); return res; } From 967f21fbaef8972a97e69eace8cd064eac072e5d Mon Sep 17 00:00:00 2001 From: Anatoliy-Litvinenko Date: Fri, 12 Mar 2021 11:19:04 -0600 Subject: [PATCH 03/12] Made preference to cosider swaps and removal existing pu units. --- connections.hpp | 12 ++++++++++++ hill_climbing.cpp | 29 +++++++++++++++++++++++------ marxan.cpp | 4 ++-- thermal_annealing.cpp | 6 +++--- 4 files changed, 40 insertions(+), 11 deletions(-) diff --git a/connections.hpp b/connections.hpp index 7ed5956..cd050ee 100644 --- a/connections.hpp +++ b/connections.hpp @@ -16,6 +16,18 @@ namespace marxan { double shortfall; double probability1D; double probability2D; + scost(): + total(0.0), + pus(0), + connection(0.0), + missing(0), + penalty(0.0), + cost(0.0), + threshpen(0.0), + shortfall(0.0), + probability1D(0.0), + probability2D(0.0) + {} } scost; /* Connectivity Structure. Fixed connectivity number.*/ diff --git a/hill_climbing.cpp b/hill_climbing.cpp index 2658b41..b0b70af 100644 --- a/hill_climbing.cpp +++ b/hill_climbing.cpp @@ -104,7 +104,7 @@ namespace marxan { const vector& SM, vector& SM_out, double cm, int aggexist, vector& R, double prop, int clumptype, int irun, stringstream& logBuffer, rng_engine& rngEngine) { - scost reserve = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; + scost reserve; initialiseReserve(prop, pu, R, rngEngine); @@ -123,7 +123,7 @@ namespace marxan { scost& reserve, double costthresh, double tpf1, double tpf2, int clumptype, int irun, long long iterations, string savename, stringstream& logBuffer, rng_engine& rngEngine) { - scost change = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; + scost change; int puvalid = 0, ipu = 0, imode, ichoice; vector iimparray; @@ -237,13 +237,14 @@ namespace marxan { std::shuffle(iimparray.begin(), iimparray.end(), rngEngine); // ***** Doing the improvements **** bool was_change_per_total_loop = false; + bool skip_add_two_units = true; for (int i0 = 0; i0 < puvalid && itime <= iterations; i0++) { - scost change0 = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; + scost change0; bool was_change = false; int ichoice0 = iimparray[i0]; - //remenber old score + //remember old score int imode0 = R[ichoice0] == 1 ? -1 : 1; computeChangeScore(-1, ichoice0, spno, puno, pu, connections, spec, SM, SM_out, R, cm, imode0, change0, reserve, costthresh, tpf1, tpf2, 1, clumptype); @@ -258,10 +259,21 @@ namespace marxan { for (int i1 = i0+1; i1 < puvalid && itime <= iterations; i1++, itime++) { - scost change1 = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; + scost change1; int ichoice1 = iimparray[i1]; int imode1 = R[ichoice1] == 1 ? -1 : 1; + + if(skip_add_two_units && (imode1 == imode0 && imode0 == 1)) + { + //If there is not enough iterations for complete coverage, + //for cases where result amount of units is small part of total units, + //concentration of search on swap or remove pair + //may improve chance of success + itime--; + continue; + } + computeChangeScore(-1, ichoice1, spno, puno, pu, connections, spec, SM, SM_out, R, cm, imode1, change1, reserve, costthresh, tpf1, tpf2, 1, clumptype); @@ -295,7 +307,12 @@ namespace marxan { } if (!was_change_per_total_loop) - break; + { + if(skip_add_two_units) + skip_add_two_units = false; + else + break; + } } } diff --git a/marxan.cpp b/marxan.cpp index a2cd898..79b1c24 100644 --- a/marxan.cpp +++ b/marxan.cpp @@ -129,8 +129,8 @@ namespace marxan { stringstream appendLogBuffer; // stores the trace file log stringstream runConsoleOutput; // stores the console message for the run. This is needed for more organized printing output due to multithreading. sanneal anneal = anneal_global; - scost reserve = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; - scost change = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; + scost reserve; + scost change; vector R(puno); diff --git a/thermal_annealing.cpp b/thermal_annealing.cpp index 107a50f..31e771c 100644 --- a/thermal_annealing.cpp +++ b/thermal_annealing.cpp @@ -43,8 +43,8 @@ namespace marxan { long int ipu, imode, iOldR; double deltamin = 0, deltamax = 0; double localdelta = 1E-10; - scost change = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; - scost reserve = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; + scost change; + scost reserve; #ifdef DEBUGTRACEFILE FILE* fp = nullptr; @@ -165,7 +165,7 @@ namespace marxan { long int repeats, int irun, string savename, double misslevel, int aggexist, double costthresh, double tpf1, double tpf2, int clumptype, sanneal& anneal, stringstream& logBuffer, rng_engine& rngEngine) { - scost change = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; + scost change; long long itime = 0; long int ipu = -1, i, itemp, snapcount = 0, ichanges = 0, iPreviousR, iGoodChange = 0; long int iRowCounter, iRowLimit; From 8bf3f8de8ed21173ebf9b98ac3dbfb9d9ba81262 Mon Sep 17 00:00:00 2001 From: Anatoliy-Litvinenko Date: Fri, 12 Mar 2021 11:39:11 -0600 Subject: [PATCH 04/12] Update logic --- hill_climbing.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/hill_climbing.cpp b/hill_climbing.cpp index b0b70af..810860a 100644 --- a/hill_climbing.cpp +++ b/hill_climbing.cpp @@ -229,15 +229,13 @@ namespace marxan { logBuffer << "Two step hillclimbing after array init\n"; displayProgress2(" Main two step hillclimbing section.\n"); - - + bool skip_add_two_units = true; for(long long itime = 1; itime <= iterations; ) { // shuffle iimp array std::shuffle(iimparray.begin(), iimparray.end(), rngEngine); // ***** Doing the improvements **** bool was_change_per_total_loop = false; - bool skip_add_two_units = true; for (int i0 = 0; i0 < puvalid && itime <= iterations; i0++) { From ebb0d1dd3ee3f5ade912aee456f6b2c188822bfc Mon Sep 17 00:00:00 2001 From: Anatoliy-Litvinenko Date: Tue, 16 Mar 2021 11:22:53 -0500 Subject: [PATCH 05/12] Fix imput options. --- marxan.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/marxan.cpp b/marxan.cpp index 79b1c24..3e8aef8 100644 --- a/marxan.cpp +++ b/marxan.cpp @@ -241,6 +241,8 @@ namespace marxan { appendLogBuffer << "after hill climbing run " << run_id << endl; } + cout<<"\nHeuristic on = " < 1 && runoptions.ItImpOn) + if (verbosity > 1) { computeReserveValue(puno, spno, R, pu, connections, SMGlobal, SM_out, cm, spec, aggexist, reserve, clumptype, appendLogBuffer); runConsoleOutput << "Run " << run_id << " Heuristic: " << displayValueForPUs(puno, spno, R, reserve, spec, misslevel).str(); @@ -812,7 +814,7 @@ namespace marxan { // handle command line parameters for the marxan executable - void handleOptions(int argc, char* argv[], string sInputFileName) + void handleOptions(int argc, char* argv[], string& sInputFileName) { if (argc > 4) { // if more than one commandline argument then exit From 00e4d330444f7f7f4284841c1ec3e2e30aba8f96 Mon Sep 17 00:00:00 2001 From: Anatoliy-Litvinenko Date: Tue, 16 Mar 2021 13:09:44 -0500 Subject: [PATCH 06/12] Update handle options. --- marxan.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/marxan.cpp b/marxan.cpp index 3e8aef8..4ff76b2 100644 --- a/marxan.cpp +++ b/marxan.cpp @@ -814,7 +814,7 @@ namespace marxan { // handle command line parameters for the marxan executable - void handleOptions(int argc, char* argv[], string& sInputFileName) + void handleOptions(int argc, char* argv[], string& sInputFileName, int& marxanIsSecondary) { if (argc > 4) { // if more than one commandline argument then exit From d2ac921dae641f1bc35bd8340b1a0c7be37fb184 Mon Sep 17 00:00:00 2001 From: Anatoliy-Litvinenko Date: Tue, 16 Mar 2021 17:24:06 -0500 Subject: [PATCH 07/12] Added usage --- marxan.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/marxan.cpp b/marxan.cpp index 4ff76b2..d13e545 100644 --- a/marxan.cpp +++ b/marxan.cpp @@ -866,7 +866,7 @@ int main(int argc, char* argv[]) { if (argc > 1) { // handle the program options - marxan::handleOptions(argc, argv, sInputFileName); + marxan::handleOptions(argc, argv, sInputFileName, marxan::marxanIsSecondary); } try From afd6bfdc47446bfd0b6657978571ef1266cabc8a Mon Sep 17 00:00:00 2001 From: Adele Bai Date: Wed, 17 Mar 2021 12:04:16 -0700 Subject: [PATCH 08/12] fixing marxan command line issue, also enabling total areas file for all verbosities --- marxan.cpp | 2 +- output.cpp | 31 +++++++++++++------------------ 2 files changed, 14 insertions(+), 19 deletions(-) diff --git a/marxan.cpp b/marxan.cpp index 2265f99..5b9e853 100644 --- a/marxan.cpp +++ b/marxan.cpp @@ -812,7 +812,7 @@ namespace marxan { // handle command line parameters for the marxan executable - void handleOptions(int argc, char* argv[], string sInputFileName) + void handleOptions(int argc, char* argv[], string& sInputFileName) { if (argc > 4) { // if more than one commandline argument then exit diff --git a/output.cpp b/output.cpp index 6f27322..d1bcc10 100644 --- a/output.cpp +++ b/output.cpp @@ -958,24 +958,19 @@ namespace marxan { // compute total area available, reserved, excluded. write it to a file if verbosity > 3. void computeTotalAreas(int puno, int spno, const vector& pu, const vector& spec, const vector& SM) { - if (verbosity > 3) - { - vector TotalOccurrences(spno, 0), TO_2(spno, 0), TO_3(spno, 0); - vector TotalAreas(spno, 0), TA_2(spno, 0), TA_3(spno, 0); - FILE* TotalAreasFile; - - computeOccurrencesAndAreas(puno, pu, SM, - TotalOccurrences, TO_2, TO_3, - TotalAreas, TA_2, TA_3); - - TotalAreasFile = fopen("MarOptTotalAreas.csv", "w"); - fprintf(TotalAreasFile, "spname,spindex,totalarea,reservedarea,excludedarea,targetarea,totalocc,reservedocc,excludedocc,targetocc\n"); - for (int i = 0; i < spno; i++) - fprintf(TotalAreasFile, "%i,%i,%g,%g,%g,%g,%i,%i,%i,%i\n" - , spec[i].name, i, TotalAreas[i], TA_2[i], TA_3[i], spec[i].target - , TotalOccurrences[i], TO_2[i], TO_3[i], spec[i].targetocc); - fclose(TotalAreasFile); - } + vector TotalOccurrences(spno, 0), TO_2(spno, 0), TO_3(spno, 0); + vector TotalAreas(spno, 0), TA_2(spno, 0), TA_3(spno, 0); + FILE *TotalAreasFile; + + computeOccurrencesAndAreas(puno, pu, SM, + TotalOccurrences, TO_2, TO_3, + TotalAreas, TA_2, TA_3); + + TotalAreasFile = fopen("MarOptTotalAreas.csv", "w"); + fprintf(TotalAreasFile, "spname,spindex,totalarea,reservedarea,excludedarea,targetarea,totalocc,reservedocc,excludedocc,targetocc\n"); + for (int i = 0; i < spno; i++) + fprintf(TotalAreasFile, "%i,%i,%g,%g,%g,%g,%i,%i,%i,%i\n", spec[i].name, i, TotalAreas[i], TA_2[i], TA_3[i], spec[i].target, TotalOccurrences[i], TO_2[i], TO_3[i], spec[i].targetocc); + fclose(TotalAreasFile); } // compute total area available, reserved, excluded. write it to a file output_totalareas.csv From c4607f8929d519152992f1c697f8ea479e63f021 Mon Sep 17 00:00:00 2001 From: Anatoliy-Litvinenko Date: Thu, 18 Mar 2021 17:45:00 -0500 Subject: [PATCH 09/12] Fixed output order to be same as Marxan2 --- output.cpp | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/output.cpp b/output.cpp index 5c2662b..cd0f536 100644 --- a/output.cpp +++ b/output.cpp @@ -679,7 +679,7 @@ namespace marxan { { fprintf(fp, "SolutionsMatrix"); - for (int i = (puno - 1); i > (-1); i--) + for (int i = 0; i < puno; i++) fprintf(fp, "%cP%i", sDelimiter, pu[i].id); fprintf(fp, "\n"); @@ -698,21 +698,18 @@ namespace marxan { if (iIncludeHeaders == 1) { - fprintf(fp, "S%i%c", iRun, sDelimiter); + fprintf(fp, "S%i", iRun); } - for (i = (puno - 1); i > (-1); i--) + for (i = 0; i < puno; i++) { - if (i < (puno - 1)) - fprintf(fp, "%c", sDelimiter); - iStatus = R[i]; if (R[i] == 3) iStatus = 0; if (R[i] == 2) iStatus = 1; - fprintf(fp, "%i", iStatus); + fprintf(fp, "%c%i", sDelimiter, iStatus); } fprintf(fp, "\n"); @@ -734,7 +731,7 @@ namespace marxan { fprintf(fp, "\"planning_unit\",\"solution\"\n"); } - for (i = puno - 1; i > -1; i--) + for (i = 0; i < puno; i++) { if (R[i] == 1 || R[i] == 2) { @@ -934,7 +931,7 @@ namespace marxan { fprintf(fp, "\"planning_unit\",\"number\"\n"); } - for (int i = 0; i < puno; i++) + for (int i = puno -1 ; i >= 0; i--) fprintf(fp, "%i%c%i\n", pu[i].id, sDelimiter, sumsoln[i]); fclose(fp); From 7d11eb65f3d038ec6baa31be3495ccb276176f2c Mon Sep 17 00:00:00 2001 From: Anatoliy-Litvinenko Date: Thu, 18 Mar 2021 23:46:33 -0500 Subject: [PATCH 10/12] Make output order same as Marxan 2. --- marxan.cpp | 2 +- output.cpp | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/marxan.cpp b/marxan.cpp index 43d403b..0605e41 100644 --- a/marxan.cpp +++ b/marxan.cpp @@ -46,7 +46,7 @@ namespace marxan { int savelog; int verbosity = 0; int asymmetricconnectivity = 0; - string sVersionString = "Marxan v 4.0.5"; + string sVersionString = "Marxan v 4.0.6"; string sMarxanWebSite = "https://marxansolutions.org/"; string sTraceFileName; string sApplicationPathName; diff --git a/output.cpp b/output.cpp index cd0f536..3e35450 100644 --- a/output.cpp +++ b/output.cpp @@ -767,7 +767,7 @@ namespace marxan { // print clump type fprintf(fp, "%s\n", clumptypeMap[clumptype].c_str()); - fprintf(fp, "Algorithm Used :%s\n", runoptions.algorithm_description().c_str()); + fprintf(fp, "Algorithm Used: %s\n", runoptions.algorithm_description().c_str()); if (runoptions.HeuristicOn) { @@ -842,7 +842,7 @@ namespace marxan { fprintf(fp, "\n"); - for (isp = 0; isp < spno; isp++) + for (isp = spno - 1 ; isp >= 0; isp--) { rMPM = 1; @@ -931,7 +931,7 @@ namespace marxan { fprintf(fp, "\"planning_unit\",\"number\"\n"); } - for (int i = puno -1 ; i >= 0; i--) + for (int i = puno - 1 ; i >= 0; i--) fprintf(fp, "%i%c%i\n", pu[i].id, sDelimiter, sumsoln[i]); fclose(fp); From 31ccc93bd42e844f6e5296ce186070bbe2b88453 Mon Sep 17 00:00:00 2001 From: Anatoliy-Litvinenko Date: Thu, 18 Mar 2021 23:58:55 -0500 Subject: [PATCH 11/12] Removed debug message... --- marxan.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/marxan.cpp b/marxan.cpp index 0605e41..782734a 100644 --- a/marxan.cpp +++ b/marxan.cpp @@ -241,8 +241,6 @@ namespace marxan { appendLogBuffer << "after hill climbing run " << run_id << endl; } - cout<<"\nHeuristic on = " < Date: Fri, 19 Mar 2021 14:26:31 -0500 Subject: [PATCH 12/12] Update marxan.bat --- scripts/marxan.bat | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/marxan.bat b/scripts/marxan.bat index 51b9e52..bac3a9c 100644 --- a/scripts/marxan.bat +++ b/scripts/marxan.bat @@ -1,3 +1,3 @@ @echo off -marxan.exe -pause \ No newline at end of file +Marxan_x64.exe +pause