summaryrefslogtreecommitdiff
path: root/src/instance.c
diff options
context:
space:
mode:
authorpants <jaron@kent-dobias.com>2016-09-06 15:05:27 -0400
committerpants <jaron@kent-dobias.com>2016-09-06 15:05:27 -0400
commit4c4ebb87ead363d6d6e11a8b95b07a0f93af5c88 (patch)
tree9cdaaf27917c2b1562740dec501d013e47a25dd1 /src/instance.c
parentfd14c5e39d962be94a1f68b0d4cacb7a4aa9c3e7 (diff)
downloadfuse_networks-4c4ebb87ead363d6d6e11a8b95b07a0f93af5c88.tar.gz
fuse_networks-4c4ebb87ead363d6d6e11a8b95b07a0f93af5c88.tar.bz2
fuse_networks-4c4ebb87ead363d6d6e11a8b95b07a0f93af5c88.zip
finished implementing embedded systems, refactored a bunch
Diffstat (limited to 'src/instance.c')
-rw-r--r--src/instance.c42
1 files changed, 21 insertions, 21 deletions
diff --git a/src/instance.c b/src/instance.c
index cc33591..bb1ac8c 100644
--- a/src/instance.c
+++ b/src/instance.c
@@ -1,14 +1,14 @@
#include "fracture.h"
-finst *create_instance(fnet *network, double inf, bool voltage_bound,
+net_t *create_instance(graph_t *network, double inf, bool voltage_bound,
bool startnow, cholmod_common *c) {
- finst *instance = (finst *)calloc(1, sizeof(finst));
+ net_t *instance = (net_t *)calloc(1, sizeof(net_t));
assert(instance != NULL);
- instance->network = network;
- instance->num_remaining_edges = network->num_edges;
- instance->fuses = (bool *)calloc(network->num_edges, sizeof(bool));
+ instance->graph = network;
+ instance->num_remaining_edges = network->ne;
+ instance->fuses = (bool *)calloc(network->ne, sizeof(bool));
assert(instance->fuses != NULL);
instance->inf = inf;
instance->voltage_bound = voltage_bound;
@@ -17,7 +17,7 @@ finst *create_instance(fnet *network, double inf, bool voltage_bound,
if (network->boundary == TORUS_BOUND) {
for (unsigned int i = 0; i < network->bound_inds[1]; i++) {
((double *)instance->boundary_cond->x)[network->bound_verts[i]] = 1;
- ((double *)instance->boundary_cond->x)[network->num_verts + i] = -1;
+ ((double *)instance->boundary_cond->x)[network->nv + i] = -1;
}
((double *)instance->boundary_cond->x)[network->bound_verts[0]] = 1;
} else if (network->boundary == EMBEDDED_BOUND) {
@@ -32,8 +32,8 @@ finst *create_instance(fnet *network, double inf, bool voltage_bound,
}
} else {
((double *)instance->boundary_cond->x)[0] = 1;
- ((double *)instance->boundary_cond->x)[network->num_verts] = 1;
- ((double *)instance->boundary_cond->x)[network->num_verts + 1] = -1;
+ ((double *)instance->boundary_cond->x)[network->nv] = 1;
+ ((double *)instance->boundary_cond->x)[network->nv + 1] = -1;
}
}
@@ -48,20 +48,20 @@ finst *create_instance(fnet *network, double inf, bool voltage_bound,
}
instance->marks = (unsigned int *)malloc(
- (instance->network->break_dim) *
+ (instance->graph->break_dim) *
sizeof(unsigned int));
instance->dual_marks = (unsigned int *)malloc(
- (instance->network->num_dual_verts) *
+ (instance->graph->dnv) *
sizeof(unsigned int));
assert(instance->marks != NULL);
for (unsigned int i = 0;
- i < (instance->network->break_dim);
+ i < (instance->graph->break_dim);
i++) {
instance->marks[i] = 1;
}
for (unsigned int i = 0;
- i < (instance->network->num_dual_verts);
+ i < (instance->graph->dnv);
i++) {
instance->dual_marks[i] = i+1;
}
@@ -70,29 +70,29 @@ finst *create_instance(fnet *network, double inf, bool voltage_bound,
return instance;
}
-void finish_instance(finst *instance, cholmod_common *c) {
+void finish_instance(net_t *instance, cholmod_common *c) {
cholmod_sparse *laplacian = gen_laplacian(instance, c, true);
instance->factor = CHOL_F(analyze)(laplacian, c);
CHOL_F(factorize)(laplacian, instance->factor, c);
CHOL_F(free_sparse)(&laplacian, c);
}
-finst *copy_instance(const finst *instance, cholmod_common *c) {
- finst *instance_copy = (finst *)calloc(1, sizeof(finst));
- memcpy(instance_copy, instance, sizeof(finst));
+net_t *copy_instance(const net_t *instance, cholmod_common *c) {
+ net_t *instance_copy = (net_t *)calloc(1, sizeof(net_t));
+ memcpy(instance_copy, instance, sizeof(net_t));
- size_t fuses_size = (instance->network)->num_edges * sizeof(bool);
+ size_t fuses_size = (instance->graph)->ne * sizeof(bool);
instance_copy->fuses = (bool *)malloc(fuses_size);
memcpy(instance_copy->fuses, instance->fuses, fuses_size);
size_t marks_size =
- (instance->network->break_dim) *
+ (instance->graph->break_dim) *
sizeof(unsigned int);
instance_copy->marks = (unsigned int *)malloc(marks_size);
memcpy(instance_copy->marks, instance->marks, marks_size);
size_t dual_marks_size =
- (instance->network->num_dual_verts) *
+ (instance->graph->dnv) *
sizeof(unsigned int);
instance_copy->dual_marks = (unsigned int *)malloc(dual_marks_size);
memcpy(instance_copy->dual_marks, instance->dual_marks, dual_marks_size);
@@ -104,7 +104,7 @@ finst *copy_instance(const finst *instance, cholmod_common *c) {
return instance_copy;
}
-void free_instance(finst *instance, cholmod_common *c) {
+void free_instance(net_t *instance, cholmod_common *c) {
free(instance->fuses);
CHOL_F(free_dense)(&(instance->boundary_cond), c);
CHOL_F(free_sparse)(&(instance->adjacency), c);
@@ -114,7 +114,7 @@ void free_instance(finst *instance, cholmod_common *c) {
free(instance);
}
-bool check_instance(const finst *instance, cholmod_common *c) {
+bool check_instance(const net_t *instance, cholmod_common *c) {
assert(instance != NULL);
assert(instance->fuses != NULL);
assert(CHOL_F(check_dense)(instance->boundary_cond, c));