Hulp gezocht mbt Visual C++ 2010

Status
Niet open voor verdere reacties.

sd1987

Nieuwe gebruiker
Lid geworden
12 mrt 2013
Berichten
2
Code:
// Routing methods in warehouses with integrated pickup and delivery
#include <iostream>
#include <fstream>
#include <sstream>
#include <string>
#include <ctime>
#include <cstdlib>
#include <algorithm>
#include <math.h>
#include <random>
#include <stdio.h>

using namespace std;

string input_file = "1-250_orders.csv";	//  four instance sets are available, one containing the first 250 instances
const int batchsize =10;				//  look into the manual to find how to adjust the parameters appropriately 
double num_aisles = 7;
double aisle_length = 12;
double aisle_width = 2.5;
int capacity = 15;

double original_batch[batchsize][4];	// this array contains the batch, as it is read in (do not alter this array!)
double sequence[batchsize][4];			// contains initially the same values as the array original_batch, but this one you can alter	
/* The array 'sequence' is a table consisting of batchsize rows (locations to be visited) and 4 columns
column 0 = name of the location (#)
column 1 = x-coordinate of the location
column 2 = y-coordinate of the location (i.e. aisle number)
column 3 = type of job (pickup or delivery)							*/
										

#include "readin.h"
#include "functions.h"

/*
You have the following functions available:
distance_depot(double)
distance_pair(double,double)
// the following functions are available for the sequence only
objective1(); 
objective2();
capacity_check();
swap(int,int)
remove_reinsert(int,int)
*/

int main () {
	
	read_file(1);
	
for (int j=1; j<batchsize; j++) {
		for (int g=j; g>=0; g--) {
			if (sequence[g][2] < sequence[g-1][2]) {
				swap(g,g-1);
			}
		}
	}

	cout << "The sequence by aisles is: " << endl;
	for (int j=0; j<batchsize; j++) {
		for (int cont=0; cont<4; cont++) {
			cout << sequence[j][cont] << " ";
		}
		cout << endl;
	}
	
	int last_aisle = sequence[batchsize-1][2]; // the variable last_aisle now contains the highest aisle number which has to be visited
cout << "The last aisle to be visited is " << last_aisle << endl;
double distance_shape = last_aisle * aisle_width * 2; // initialize the total distance and add the vertical distance travelled already to it

int n_aisles = 1; // variable to count the number of parallel aisles visited (initialize with 1, because for the first location in the sequence you definitely have to visit at least one aisle)
for (int r=1; r<batchsize; r++) { // go through all rows beginning at row 1 and test…
if (sequence[r][2] != sequence[r-1][2]) { // if the aisle number in row 1 is not equal to the one in row 0, you have to visit another aisle, otherwise not. The same for r=2, r=3,…
n_aisles++;
}
}
cout << "the number of aisles to be visited is "
<< n_aisles << endl;
distance_shape= distance_shape + (n_aisles * aisle_length); // add the horizontally travelled distance to the total travel distance

// now it only remains a test whether n_aisles is even or odd, and add one aisle_length if it is odd:

if (n_aisles % 2 == 1 ) { // n_aisles leaves a rest of 1 when divided by 2 -> n_aisles is odd
distance_shape = distance_shape + aisle_length;
}

cout << "the total travelled distance using S-shape routing is " << distance_shape << endl;
	system ("pause > nal");
	return 0;
}
 
Laatst bewerkt:
Voorbeeld:
Code:
int main(int a, int b){
    mijnCode();
}
 
In de eerste post heb ik nu mijn oplossing staan, nu kom ik bij het laatste probleem die ik graag opgelost zou zien mits een van jullie weet hoe dit werkt. Ik moet nu een while loop maken (deze uitwerking is voor 1 regel en het moet voor 250 stuks) en vervolgens moet elke value met distance_s-shape worden geschreven in een csv file.


Iemand hier die mij hiervoor van handige tips kan voorzien?
 
Status
Niet open voor verdere reacties.
Terug
Bovenaan Onderaan