From: yu.dongliang <18588496441@163.com> Date: Fri, 15 Sep 2023 08:43:22 +0000 (+0800) Subject: ses_flow_jr() X-Git-Url: http://baseworks.info/?a=commitdiff_plain;h=d39b9929376a4d483efcdfd057a6612b4baf9075;p=ses.git ses_flow_jr() --- diff --git a/ses_core.h b/ses_core.h index 35a095b..0331127 100644 --- a/ses_core.h +++ b/ses_core.h @@ -24,13 +24,13 @@ struct ses_flow_s { scf_vector_t* paths; - scf_vector_t* ppins; - scf_vector_t* npins; - ScfEpin* vip; - double r; - double jr; + double pr; + double jpr; + + double nr; + double jnr; double v; double jv; @@ -87,6 +87,7 @@ void ses_path_print(ses_path_t* path); ses_flow_t* ses_flow_alloc(); void ses_flow_free (ses_flow_t* flow); void ses_flow_print(ses_flow_t* flow); +void ses_flow_jr (ses_flow_t* flow); ses_ctx_t* ses_ctx_alloc(); void ses_ctx_free (ses_ctx_t* ctx); diff --git a/ses_step_va_balance.c b/ses_step_va_balance.c index 208ecd1..fe04f78 100644 --- a/ses_step_va_balance.c +++ b/ses_step_va_balance.c @@ -169,11 +169,16 @@ static int _va_balance_handler(ScfEfunction* f, int64_t ns, int64_t count, ses_c ses_flow_print(flow0); printf("\n"); + ses_flow_jr(flow0); + printf("-------------\n"); ses_flow_print(flow1); printf("\n"); + ses_flow_jr(flow1); + printf("-------------\n"); + ret = __ses_path_va_balance(f, bridge, flow0, flow1); if (ret < 0) return ret; diff --git a/ses_steps.c b/ses_steps.c index 9867497..3ed7fcc 100644 --- a/ses_steps.c +++ b/ses_steps.c @@ -52,26 +52,12 @@ ses_flow_t* ses_flow_alloc() return NULL; flow->paths = scf_vector_alloc(); - if (!flow->paths) - goto _paths_error; - - flow->ppins = scf_vector_alloc(); - if (!flow->ppins) - goto _ppins_error; - - flow->npins = scf_vector_alloc(); - if (!flow->npins) - goto _npins_error; + if (!flow->paths) { + ses_flow_free(flow); + return NULL; + } return flow; - -_npins_error: - scf_vector_free(flow->ppins); -_ppins_error: - scf_vector_free(flow->paths); -_paths_error: - free(flow); - return NULL; } void ses_flow_free(ses_flow_t* flow) @@ -80,13 +66,71 @@ void ses_flow_free(ses_flow_t* flow) if (flow->paths) scf_vector_free(flow->paths); - if (flow->ppins) - scf_vector_free(flow->ppins); + free(flow); + } +} + +void ses_flow_jr(ses_flow_t* flow) +{ + if (!flow) + return; - if (flow->npins) - scf_vector_free(flow->npins); + flow->pr = 0; + flow->jpr = 0; - free(flow); + flow->nr = 0; + flow->jnr = 0; + + if (!flow->paths || !flow->vip) + return; + + ses_path_t* path; + ScfEpin* p; + ScfEpin* vip = flow->vip; + + int i; + int j; + + for (i = 0; i < flow->paths->size; i++) { + path = flow->paths->data[i]; + + for (j = 0; j < path->pins->size; j++) { + p = path->pins->data[j]; + + if (p->lid == vip->lid) { + + vip = path->pins->data[0]; + + flow->pr += p->pr; + flow->jpr += p->jpr; + + scf_loge("flow->pr: %lg + j%lg, c%ldp%ld->pr: %lg + j%lg, vip c%ldp%ld->pr: %lg + j%lg\n", + flow->pr, flow->jpr, p->cid, p->id, p->pr, p->jpr, vip->cid, vip->id, vip->pr, vip->jpr); + break; + } + } + } + + vip = flow->vip; + + for (i = 0; i < flow->paths->size; i++) { + path = flow->paths->data[i]; + + for (j = 0; j < path->pins->size; j++) { + p = path->pins->data[j]; + + if (p->lid == vip->lid) { + + vip = path->pins->data[path->pins->size - 1]; + + flow->nr += vip->pr - p->pr; + flow->jnr += vip->jpr - p->jpr; + + scf_loge("flow->nr: %lg + j%lg, c%ldp%ld->pr: %lg + j%lg, vip c%ldp%ld->pr: %lg + j%lg\n", + flow->nr, flow->jnr, p->cid, p->id, p->pr, p->jpr, vip->cid, vip->id, vip->pr, vip->jpr); + break; + } + } } }