File auction.c changed (mode: 100644) (index 0f5644c..e60143f) |
... |
... |
auction_toabsint (const struct spcsr_t *A, double *absent_in) |
127 |
127 |
absent[k] = floor(fabs(entry[k])); |
absent[k] = floor(fabs(entry[k])); |
128 |
128 |
} |
} |
129 |
129 |
|
|
130 |
|
void |
|
|
130 |
|
double |
131 |
131 |
auction_shift (const struct spcsr_t *A, double *b_in) |
auction_shift (const struct spcsr_t *A, double *b_in) |
132 |
132 |
{ |
{ |
133 |
133 |
int k; |
int k; |
|
... |
... |
auction_shift (const struct spcsr_t *A, double *b_in) |
147 |
147 |
b[k] -= mn; |
b[k] -= mn; |
148 |
148 |
} |
} |
149 |
149 |
/*fprintf (stderr, "shifting by %d\n", mn);*/ |
/*fprintf (stderr, "shifting by %d\n", mn);*/ |
|
150 |
|
return mn; |
150 |
151 |
} |
} |
151 |
152 |
|
|
152 |
153 |
void |
void |
File auction.h changed (mode: 100644) (index a1c1b2d..9cb7e52) |
... |
... |
void auction_tounitall (const struct spcsr_t*, double*); |
8 |
8 |
void auction_toabsint (const struct spcsr_t*, double *); |
void auction_toabsint (const struct spcsr_t*, double *); |
9 |
9 |
void auction_toabs (const struct spcsr_t*, double *); |
void auction_toabs (const struct spcsr_t*, double *); |
10 |
10 |
|
|
11 |
|
void auction_shift (const struct spcsr_t*, double *); |
|
|
11 |
|
double auction_shift (const struct spcsr_t*, double *); |
12 |
12 |
void auction_scaleshift (const struct spcsr_t*, double *); |
void auction_scaleshift (const struct spcsr_t*, double *); |
13 |
13 |
|
|
14 |
14 |
|
|
File matchmtx.c changed (mode: 100644) (index 99e70a4..66d5b67) |
... |
... |
main (int argc, char **argv) |
35 |
35 |
double mu_min; |
double mu_min; |
36 |
36 |
int relgap = 0; |
int relgap = 0; |
37 |
37 |
|
|
|
38 |
|
double shiftamount; |
|
39 |
|
|
38 |
40 |
double *R, *C; |
double *R, *C; |
39 |
41 |
double *expint; |
double *expint; |
40 |
42 |
|
|
41 |
43 |
int *match, *invmatch; |
int *match, *invmatch; |
42 |
|
double *price; |
|
|
44 |
|
double *price, *profit = NULL; |
43 |
45 |
|
|
44 |
46 |
int errflg, i, j; |
int errflg, i, j; |
45 |
47 |
double p, d; |
double p, d; |
|
... |
... |
main (int argc, char **argv) |
87 |
89 |
memset (invmatch, -1, A.nr * sizeof(int)); |
memset (invmatch, -1, A.nr * sizeof(int)); |
88 |
90 |
price = calloc (A.nc, sizeof(double)); |
price = calloc (A.nc, sizeof(double)); |
89 |
91 |
|
|
|
92 |
|
spcsr_copy (&A, &Acopy); |
|
93 |
|
|
90 |
94 |
printf ("nr = %d nc = %d nent = %d\n", A.nr, A.nc, A.nent); |
printf ("nr = %d nc = %d nent = %d\n", A.nr, A.nc, A.nent); |
91 |
95 |
|
|
92 |
96 |
#if 0 |
#if 0 |
|
... |
... |
main (int argc, char **argv) |
101 |
105 |
#else |
#else |
102 |
106 |
auction_toexp (&A, expint); |
auction_toexp (&A, expint); |
103 |
107 |
#endif |
#endif |
104 |
|
auction_shift (&A, expint); |
|
|
108 |
|
shiftamount = auction_shift (&A, expint); |
105 |
109 |
|
|
106 |
110 |
{ |
{ |
107 |
111 |
int k; |
int k; |
|
... |
... |
main (int argc, char **argv) |
156 |
160 |
} |
} |
157 |
161 |
|
|
158 |
162 |
if (fout) { |
if (fout) { |
159 |
|
int k; |
|
160 |
|
smut_write_bin_vectors (1, A.nc, price, fout); |
|
161 |
|
for (k = 0; k < A.nc; ++k) { |
|
162 |
|
price[k] = match[k]; |
|
163 |
|
} |
|
164 |
|
smut_write_bin_vectors (1, A.nc, price, fout); |
|
|
163 |
|
int bo_tag = 1; |
|
164 |
|
int i, j, k; |
|
165 |
|
|
|
166 |
|
fwrite (&bo_tag, sizeof(int), 1, fout); |
|
167 |
|
fwrite (&mu_min, sizeof(double), 1, fout); |
|
168 |
|
fwrite (&relgap, sizeof(int), 1, fout); |
|
169 |
|
fwrite (match, sizeof(int), A.nc, fout); |
|
170 |
|
|
|
171 |
|
profit = malloc (A.nr * sizeof(double)); |
|
172 |
|
for (i = 0; i < A.nr; ++i) { |
|
173 |
|
profit[i] = -HUGE_VAL; |
|
174 |
|
for (k = A.rowoff[i]; k < A.rowoff[i+1]; ++k) { |
|
175 |
|
const int j = A.colind[k]; |
|
176 |
|
const double e = expint[k]; |
|
177 |
|
if (isinf(price[j])) { |
|
178 |
|
price[j] = e; |
|
179 |
|
} |
|
180 |
|
else { |
|
181 |
|
profit[i] = fmax(profit[i], price[j] - e); |
|
182 |
|
} |
|
183 |
|
} |
|
184 |
|
if (profit[i] == -HUGE_VAL) profit[i] = 0.0; |
|
185 |
|
} |
|
186 |
|
|
|
187 |
|
for (j = 0; j < A.nc; ++j) { |
|
188 |
|
price[j] += shiftamount; |
|
189 |
|
price[j] = R[i] * scalbn(1.0, (int)price[j]); |
|
190 |
|
} |
|
191 |
|
for (i = 0; i < A.nc; ++i) { |
|
192 |
|
profit[i] = C[j] * scalbn(1.0, (int)profit[i]); |
|
193 |
|
} |
|
194 |
|
fwrite(price, sizeof(double), A.nc, fout); |
|
195 |
|
fwrite(profit, sizeof(double), A.nr, fout); |
165 |
196 |
} |
} |
166 |
197 |
|
|
|
198 |
|
if (profit) free(profit); |
167 |
199 |
free (price); |
free (price); |
168 |
200 |
free (invmatch); |
free (invmatch); |
169 |
201 |
free (match); |
free (match); |