Exemplo n.º 1
0
func loadDictionary() dictionary {
	dict := dictionary{}
	//read file lines
	input := file.FileLines(fileName)
	// break out first line, load its values into size
	dict.size = intSeparate(input[0])
	input = input[1:]
	// break out second line, load it into basic
	dict.basic = intSeparate(input[0])
	input = input[1:]
	// break out third line, load it into nonBasic
	dict.nonBasic = intSeparate(input[0])
	input = input[1:]
	// break out fourth line, load it into coeff
	dict.coeff = floatSeparate(input[0])
	input = input[1:]
	// for next size[0] lines, load into matrix
	dict.matrix = make([][]float64, dict.size[0])
	for i := 0; i < dict.size[0]; i++ {
		dict.matrix[i] = floatSeparate(input[0])
		input = input[1:]
	}
	// load final line into objective
	dict.objective = floatSeparate(input[0])
	return dict
}
Exemplo n.º 2
0
func loadJobs() *jobList {
	a := file.FileLines(fileName)[1:]
	jobSlice := make(jobList, 10000)

	for i, v := range a {
		jobSlice[i] = addJob(v)
	}
	return &jobSlice
}
Exemplo n.º 3
0
func loadArray() ([]item, int) {
	fileLines := file.FileLines(fileToken)
	paramLine := strings.Split(fileLines[0], "\n")
	fileLines = fileLines[1:]
	paramLine = strings.Split(paramLine[0], " ")
	knapSize, _ := strconv.Atoi(paramLine[0])

	itemList := readKnap(fileLines)
	return itemList, knapSize
}
Exemplo n.º 4
0
// () -> Graph
// Outputs a graph containing the contents of file "fileToken"
func loadGraph() Graph {

	a := file.FileLines(fileToken)
	g := make(Graph, 0)
	for i := 0; i < len(a); i++ {
		g = append(g, new(Node))
	}
	for _, l := range a {
		addNode(g, l)
	}
	return g
}
Exemplo n.º 5
0
func readNodes() [][]bool {
	lines := file.FileLines(fileToken)
	params := strings.Split(strings.Split(lines[0], "\n")[0], " ")
	lines = lines[1:]
	count, _ := strconv.Atoi(params[0])
	size, _ := strconv.Atoi(params[1])
	graph := make([][]bool, count)
	for i := 0; i < count; i++ {
		graph[i] = newNode(lines[i], size)
	}
	return graph
}
Exemplo n.º 6
0
func loadGraph() graph {
	lines := file.FileLines(fileToken)
	graphSize, _ := strconv.Atoi((strings.Split(lines[0], "\n")[0]))
	lines = lines[1:]
	vertices := make([]vertex, graphSize)
	for i, _ := range vertices {
		vertices[i] = vertex{i + 1, 0}
	}
	edges := make(edgeList, len(lines))
	for i, v := range lines {
		edges[i] = newEdge(v)
	}
	return graph{edges: edges, vertices: vertices, kvalue: len(vertices)}
}
Exemplo n.º 7
0
func loadGraph() *Graph {
	fileStrings := file.FileLines(fileName)

	countStrings := strings.Split(strings.TrimSuffix(fileStrings[0], "\n"), " ")
	nodeCount, _ := strconv.Atoi(countStrings[0])
	graphNodes := make(Graph, nodeCount)

	fileStrings = fileStrings[1:]
	initializeNodes(&graphNodes)

	for _, v := range fileStrings {
		addEdge(graphNodes, v)
	}

	return &graphNodes
}
Exemplo n.º 8
0
// () -> Graph
// Outputs a graph containing the contents of file "fileToken"
func loadGraph() graph.Graph {
	fmt.Println("Opening file...")
	rawLines := file.FileLines(fileToken)
	fmt.Println("Creating structures...")
	values := strings.Split(rawLines[0], "\n")
	values = strings.Split(values[0], " ")
	vCount, _ := strconv.Atoi(values[0])
	eCount, _ := strconv.Atoi(values[1])
	rawLines = rawLines[1:]
	vertices := make([]*graph.Node, vCount)
	edges := make([]graph.Edge, eCount)
	for i := 0; i < len(vertices); i++ {
		vertices[i] = &graph.Node{Name: i + 1}
	}
	fmt.Println("Entering data...")
	for i, v := range rawLines {
		edges[i] = addEdge(vertices, v)
	}
	return graph.Graph{Vertices: vertices, Edges: edges}
}