Beispiel #1
0
void CONSTR_FIX_allocate(Constr* c) {

  // Local variables
  int num_constr;
  int num_vars;
  int A_nnz;

  // Constr data
  num_vars = NET_get_num_vars(CONSTR_get_network(c));
  num_constr = CONSTR_get_A_row(c);
  A_nnz = CONSTR_get_A_nnz(c);

  // J f
  CONSTR_set_J(c,MAT_new(0,num_vars,0));
  CONSTR_set_f(c,VEC_new(0));

  // G l u
  CONSTR_set_G(c,MAT_new(0,num_vars,0));
  CONSTR_set_l(c,VEC_new(0));
  CONSTR_set_u(c,VEC_new(0));

  // b
  CONSTR_set_b(c,VEC_new(num_constr));

  // A
  CONSTR_set_A(c,MAT_new(num_constr, // size1 (rows)
			 num_vars,   // size2 (cols)
			 A_nnz)); // nnz
}
Beispiel #2
0
void CONSTR_LOAD_PF_allocate(Constr* c) {

  // Local variables
  int num_constr;
  int num_vars;
  int A_nnz;

  num_vars = NET_get_num_vars(CONSTR_get_network(c));
  num_constr = CONSTR_get_A_row(c);
  A_nnz = CONSTR_get_A_nnz(c);

  // J f
  CONSTR_set_J(c,MAT_new(0,num_vars,0));
  CONSTR_set_f(c,VEC_new(0));

  // A b
  CONSTR_set_A(c,MAT_new(num_constr, // rows
			 num_vars,   // cols
			 A_nnz));    // nnz
  CONSTR_set_b(c,VEC_new(num_constr));

  // G l u
  CONSTR_set_l(c,VEC_new(0));
  CONSTR_set_u(c,VEC_new(0));
  CONSTR_set_G(c,MAT_new(0,        // rows
			 num_vars, // cols
			 0));      // nnz
}
Beispiel #3
0
void CONSTR_DC_FLOW_LIM_allocate(Constr* c) {
  
  // Local variables
  Net* net;
  int num_br;
  int num_vars;
  int Gcounter;

  net = CONSTR_get_network(c);
  num_br = NET_get_num_branches(net);
  num_vars = NET_get_num_vars(net);
  Gcounter = CONSTR_get_Gcounter(c);
  
  // J f
  CONSTR_set_J(c,MAT_new(0,num_vars,0));
  CONSTR_set_f(c,VEC_new(0));
  
  // A b
  CONSTR_set_A(c,MAT_new(0,num_vars,0));
  CONSTR_set_b(c,VEC_new(0));
  
  // h
  CONSTR_set_l(c,VEC_new(num_br));
  CONSTR_set_u(c,VEC_new(num_br));

  // G
  CONSTR_set_G(c,MAT_new(num_br,      // size1 (rows)
			 num_vars,    // size2 (cols)
			 Gcounter));  // nnz
}
Beispiel #4
0
Vec* BUS_get_var_indices(void* vbus, unsigned char var, int t_start, int t_end) {

  // Local vars
  Bus* bus = (Bus*)vbus;
  Vec* indices;
  int offset = 0;
  int t;

  // Checks
  if (!bus)
    return NULL;
  if (t_start < 0)
    t_start = 0;
  if (t_end > bus->num_periods-1)
    t_end = bus->num_periods-1;

  // Indices
  indices = VEC_new(BUS_get_num_vars(vbus,var,t_start,t_end));
  if ((var & BUS_VAR_VMAG) && (bus->vars & BUS_VAR_VMAG)) { // v mag
    for (t = t_start; t <= t_end; t++) {
      VEC_set(indices,offset,bus->index_v_mag[t]);
      offset++;
    }
  }
  if ((var & BUS_VAR_VANG) && (bus->vars & BUS_VAR_VANG)) { // v ang
    for (t = t_start; t <= t_end; t++) {
      VEC_set(indices,offset,bus->index_v_ang[t]);
      offset++;
    }
  }
  return indices;
}
Beispiel #5
0
void CONSTR_BOUND_allocate(Constr* c) {

  // Local variables
  int Jcounter;
  Mat* H_array;
  Mat* H;
  int num_vars;
  int i;
  
  Jcounter = CONSTR_get_Jcounter(c);
  num_vars = NET_get_num_vars(CONSTR_get_network(c));

  // A b
  CONSTR_set_A(c,MAT_new(0,num_vars,0));
  CONSTR_set_b(c,VEC_new(0));
  
  // f
  CONSTR_set_f(c,VEC_new(Jcounter));

  // J
  CONSTR_set_J(c,MAT_new(Jcounter,   // size1 (rows)
			 num_vars,   // size2 (cols)
			 Jcounter)); // nnz
  
  // H
  H_array = MAT_array_new(Jcounter);
  CONSTR_set_H_array(c,H_array,Jcounter);
  for (i = 0; i < Jcounter; i++) {
    H = MAT_array_get(H_array,i);
    MAT_set_nnz(H,1);
    MAT_set_size1(H,num_vars);
    MAT_set_size2(H,num_vars);
    MAT_set_row_array(H,(int*)calloc(1,sizeof(int)));
    MAT_set_col_array(H,(int*)calloc(1,sizeof(int)));
    MAT_set_data_array(H,(REAL*)malloc(1*sizeof(REAL)));
  }

  // H combined
  CONSTR_set_H_combined(c,MAT_new(num_vars,   // size1 (rows)
				  num_vars,   // size2 (cols)
				  Jcounter)); // nnz
}
Beispiel #6
0
void CONSTR_PAR_GEN_Q_allocate(Constr *c) {
  
  // Local variables
  int num_constr;
  int num_vars;
  int Acounter;
  
  num_vars = NET_get_num_vars(CONSTR_get_network(c));
  num_constr = CONSTR_get_Aconstr_index(c);
  Acounter = CONSTR_get_Acounter(c);

  // J f
  CONSTR_set_J(c,MAT_new(0,num_vars,0));
  CONSTR_set_f(c,VEC_new(0));

  // b
  CONSTR_set_b(c,VEC_new(num_constr));

  // A
  CONSTR_set_A(c,MAT_new(num_constr, // size1 (rows)
			 num_vars,   // size2 (rows)
			 Acounter)); // nnz
}
Beispiel #7
0
void FUNC_REG_PQ_allocate(Func* f) {
  
  // Local variables
  int num_vars;
  int Hcounter;
  
  num_vars = NET_get_num_vars(FUNC_get_network(f));
  Hcounter = FUNC_get_Hcounter(f);

  // gphi
  FUNC_set_gphi(f,VEC_new(num_vars));

  // Hphi
  FUNC_set_Hphi(f,MAT_new(num_vars,
			  num_vars,
			  Hcounter));
}
Beispiel #8
0
void FUNC_GEN_COST_allocate(Func* f) {

  // Local variables
  int num_vars;
  int Hphi_nnz;

  num_vars = NET_get_num_vars(FUNC_get_network(f));
  Hphi_nnz = FUNC_get_Hphi_nnz(f);

  // gphi
  FUNC_set_gphi(f,VEC_new(num_vars));

  // Hphi
  FUNC_set_Hphi(f,MAT_new(num_vars,
			  num_vars,
			  Hphi_nnz));
}