#include <assert.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include "place_qpsolver.h"
Go to the source code of this file.
#define QPS_DEC_CHANGE 0.01 |
#define QPS_LOOP_TOL 1.0e-3 |
#define QPS_MINSTEP 1.0e-6 |
#define QPS_PRECON_EPS 1.0e-9 |
#define QPS_RELAX_ITER 180 |
#define QPS_STEPSIZE_RETRIES 2 |
Definition at line 459 of file place_qpsolver.c.
482 #if defined(QPS_PRECON)
488 for (i = 0; i < 2 * n; i++) {
491 fprintf(p->
priv_fp,
"### qps_cgmin() top\n");
492 for (j = 0; j < p->
priv_n; j++) {
503 if (fabs((p->
priv_f) - fp) <=
513 #if defined(QPS_PRECON)
522 #if defined(QPS_PRECON)
525 h[j] = t + gam * h[j];
532 fprintf(stderr,
"### Too many iterations in qps_cgmin()\n");
533 #if defined(QPS_DEBUG)
534 fprintf(p->
priv_fp,
"### Too many iterations in qps_cgmin()\n");
ABC_NAMESPACE_HEADER_START typedef float qps_float_t
static void qps_settp(qps_problem_t *p)
static void qps_linmin(qps_problem_t *p, qps_float_t dgg, qps_float_t *h)
static void qps_dfunc(qps_problem_t *p, qps_float_t *d)
static qps_float_t qps_func(qps_problem_t *p)
Definition at line 216 of file place_qpsolver.c.
228 #if !defined(QPS_HOIST)
239 tp2[i * 2 + 1] = 0.0;
244 while ((k = p->
priv_cc[pr]) >= 0) {
252 tp2[j * 2 + 1] += ty;
253 tp2[k * 2 + 1] -= ty;
259 #if !defined(QPS_HOIST)
265 jy = sy = tp[j * 2 + 1];
274 tp2[j * 2 + 1] += ty;
275 tp2[k * 2 + 1] -= ty;
285 tp2[j * 2 + 1] += ty;
286 tp2[st * 2 + 1] -= ty;
299 fprintf(p->
priv_fp,
"### qps_dfunc() partials\n");
301 fprintf(p->
priv_fp,
"%f %f\n", tp2[j * 2], tp2[j * 2 + 1]);
306 for (j = p->
priv_n; j--;) {
313 d[ji + 1] += tp2[j * 2 + 1];
318 while ((k = p->
cog_list[pr]) >= 0) {
325 d[ki] -= tp2[j * 2] * w;
326 d[ki + 1] -= tp2[j * 2 + 1] * w;
334 fprintf(p->
priv_fp,
"### qps_dfunc() gradient\n");
335 for (j = 0; j < p->
priv_n; j++) {
336 fprintf(p->
priv_fp,
"%f\n", d[j]);
ABC_NAMESPACE_HEADER_START typedef float qps_float_t
qps_float_t * loop_penalty
Definition at line 651 of file place_qpsolver.c.
668 for (i = 0; i < p->
cog_num; i++) {
669 while ((cell = p->
cog_list[j]) >= 0) {
670 t1[cell * 2] = p->
cog_x[i];
671 t1[cell * 2 + 1] = p->
cog_y[i];
ABC_NAMESPACE_HEADER_START typedef float qps_float_t
static qps_float_t qps_func(qps_problem_t *p)
Definition at line 129 of file place_qpsolver.c.
140 #if !defined(QPS_HOIST)
154 while ((k = p->
priv_cc[pr]) >= 0) {
157 ty = tp[k * 2 + 1] - jy;
158 f += w * (tx * tx + ty * ty);
165 #if !defined(QPS_HOIST)
172 jy = sy = tp[j * 2 + 1];
178 t += tx * tx + ty * ty;
186 t += tx * tx + ty * ty;
189 fprintf(p->
priv_fp,
"### qps_penalty() %d %f %f\n",
202 f += p->
priv_myl[j] * (-tp[j * 2 + 1]);
208 fprintf(p->
priv_fp,
"### qps_func() %f %f\n", f, p->
f);
ABC_NAMESPACE_HEADER_START typedef float qps_float_t
qps_float_t * loop_penalty
Definition at line 542 of file place_qpsolver.c.
547 #if defined(QPS_DEBUG)
548 p->
priv_fp = fopen(QPS_DEBUG_FILE,
"a");
556 fprintf(p->
priv_fp,
"### (c w) values\n");
558 fprintf(p->
priv_fp,
"net %d: ", i);
563 fprintf(p->
priv_fp,
"(-1 -1.0)\n");
566 fprintf(p->
priv_fp,
"### (x y f) values\n");
568 fprintf(p->
priv_fp,
"cell %d: (%f %f %d)\n", i, p->
x[i], p->
y[i],
573 fprintf(p->
priv_fp,
"### ga values\n");
575 fprintf(p->
priv_fp,
"cell %d: (%f)\n", i, p->
area[i]);
579 fprintf(p->
priv_fp,
"### gl values\n");
580 for (i = 0; i < p->
cog_num; i++) {
581 fprintf(p->
priv_fp,
"cog %d: ", i);
589 fprintf(p->
priv_fp,
"### (gx gy) values\n");
590 for (i = 0; i < p->
cog_num; i++) {
606 while ((j = p->
connect[pr]) >= 0) {
627 while ((j = p->
connect[pr]) >= 0) {
ABC_NAMESPACE_HEADER_START typedef float qps_float_t
qps_float_t * edge_weight
Definition at line 344 of file place_qpsolver.c.
360 #if !defined(QPS_HOIST)
377 tp[j * 2 + 1] = h[ji + 1];
382 while ((k = p->
cog_list[pr]) >= 0) {
389 tp[j * 2] -= h[ki] * w;
390 tp[j * 2 + 1] -= h[ki + 1] * w;
402 while ((k = p->
priv_cc[pr]) >= 0) {
405 ky = tp[k * 2 + 1] - jy;
406 f += w * (kx * kx + ky * ky);
412 #if !defined(QPS_HOIST)
419 jy = sy = tp[j * 2 + 1];
425 t += tx * tx + ty * ty;
433 t += tx * tx + ty * ty;
445 for (j = p->
priv_n; j--;) {
449 fprintf(p->
priv_fp,
"### qps_linmin() step %f\n", f);
450 for (j = 0; j < p->
priv_n; j++) {
ABC_NAMESPACE_HEADER_START typedef float qps_float_t
qps_float_t * loop_penalty
Definition at line 69 of file place_qpsolver.c.
89 tp[i * 2 + 1] = cp[t + 1];
93 tp[i * 2 + 1] = p->
y[i];
104 while ((u = p->
cog_list[pr++]) >= 0) {
107 rx -= p->
area[u] * tp[u * 2];
108 ry -= p->
area[u] * tp[u * 2 + 1];
111 rx += p->
cog_x[t] * ta;
112 ry += p->
cog_y[t] * ta;
113 tp[i * 2] = rx / p->
area[i];
114 tp[i * 2 + 1] = ry / p->
area[i];
119 fprintf(p->
priv_fp,
"### qps_settp()\n");
121 fprintf(p->
priv_fp,
"%f %f\n", tp[i * 2], tp[i * 2 + 1]);
ABC_NAMESPACE_HEADER_START typedef float qps_float_t
Definition at line 981 of file place_qpsolver.c.
988 #if defined(QPS_PRECON)
993 #if defined(QPS_HOIST)
1023 for (i = 0; i < p->
cog_num; i++) {
1027 while ((j = p->
cog_list[pr++]) >= 0) {
1030 if (p->
area[j] > bk) {
1045 for (i = 0; i < p->
cog_num; i++) {
1046 while ((j = p->
cog_list[pr]) >= 0) {
1070 #if defined(QPS_PRECON)
1080 while ((c = p->
priv_cc[pr]) >= 0) {
1089 for (i = 0; i < p->
loop_num; i++) {
1101 for (i = p->
priv_n; i--;) {
1114 while ((j = p->
cog_list[pr++]) >= 0) {
1126 for (i = 0; i < p->
priv_n; i++) {
1157 #if defined(QPS_HOIST)
1168 for (i = 0; i < p->
loop_num; i++) {
1181 while (p->
priv_cc[pw] != m2) {
1203 while (p->
priv_cc[pw] != m2) {
1230 fprintf(p->
priv_fp,
"### cloc %d %f %f\n", i, p->
x[i], p->
y[i]);
1245 #if defined(QPS_HOIST)
1250 #if defined(QPS_PRECON)
static void qps_solve_inner(qps_problem_t *p)
ABC_NAMESPACE_HEADER_START typedef float qps_float_t
qps_float_t * loop_penalty
Definition at line 702 of file place_qpsolver.c.
709 #if defined(QPS_HOIST)
716 #if defined(QPS_HOIST)
727 while ((j = p->
priv_la[pr++]) != -1) {
767 fprintf(p->
priv_fp,
"### warning: changing fopt\n");
772 fprintf(p->
priv_fp,
"### max_stat %.2e %.2e %.2e %.2e\n",
785 #if defined(QPS_HOIST)
792 jy = sy = p->
priv_tp[j * 2 + 1];
798 t += tx * tx + ty * ty;
806 t += tx * tx + ty * ty;
836 fprintf(p->
priv_fp,
"### not_done %d %f %f %f %f\n", i,
842 fprintf(p->
priv_fp,
"### done %d %f %f %f %f\n", i,
854 fprintf(p->
priv_fp,
"### update %d %.2e %.2e %.2e %.2e %.2e\n", i,
862 tp += fabs(pm1 - pm2);
865 fprintf(p->
priv_fp,
"### penalty mag %f\n", tp);
928 tp += fabs(pm1 - pm2);
937 tp += fabs(pm1 - pm2);
946 tp += fabs(pm1 - pm2);
955 tp += fabs(pm1 - pm2);
960 fprintf(p->
priv_fp,
"### max_penalty %d %f %f %f %f\n", i,
static void qps_cgmin(qps_problem_t *p)
ABC_NAMESPACE_HEADER_START typedef float qps_float_t
#define QPS_STEPSIZE_RETRIES
qps_float_t * loop_penalty
static qps_float_t qps_estopt(qps_problem_t *p)