summaryrefslogtreecommitdiff
path: root/glpk-5.0/examples/sql/transp_odbc.mod
diff options
context:
space:
mode:
authorPasha <pasha@member.fsf.org>2023-01-27 00:54:07 +0000
committerPasha <pasha@member.fsf.org>2023-01-27 00:54:07 +0000
commitef800d4ffafdbde7d7a172ad73bd984b1695c138 (patch)
tree920cc189130f1e98f252283fce94851443641a6d /glpk-5.0/examples/sql/transp_odbc.mod
parentec4ae3c2b5cb0e83fb667f14f832ea94f68ef075 (diff)
downloadoneapi-ef800d4ffafdbde7d7a172ad73bd984b1695c138.tar.gz
oneapi-ef800d4ffafdbde7d7a172ad73bd984b1695c138.tar.bz2
simplex-glpk with modified glpk for fpgaHEADmaster
Diffstat (limited to 'glpk-5.0/examples/sql/transp_odbc.mod')
-rw-r--r--glpk-5.0/examples/sql/transp_odbc.mod72
1 files changed, 72 insertions, 0 deletions
diff --git a/glpk-5.0/examples/sql/transp_odbc.mod b/glpk-5.0/examples/sql/transp_odbc.mod
new file mode 100644
index 0000000..36d807e
--- /dev/null
+++ b/glpk-5.0/examples/sql/transp_odbc.mod
@@ -0,0 +1,72 @@
+# A TRANSPORTATION PROBLEM
+#
+# This problem finds a least cost shipping schedule that meets
+# requirements at markets and supplies at factories.
+#
+# References:
+# Dantzig G B, "Linear Programming and Extensions."
+# Princeton University Press, Princeton, New Jersey, 1963,
+# Chapter 3-3.
+
+set I;
+/* canning plants */
+
+param a{i in I};
+/* capacity of plant i in cases */
+
+table plants IN "iODBC"
+ 'DSN=glpk;UID=glpk;PWD=gnu'
+ 'SELECT PLANT, CAPA AS CAPACITY'
+ 'FROM transp_capa' :
+ I <- [ PLANT ], a ~ CAPACITY;
+
+set J;
+/* markets */
+
+param b{j in J};
+/* demand at market j in cases */
+
+table markets IN "iODBC"
+ 'DSN=glpk;UID=glpk;PWD=gnu'
+ 'transp_demand' :
+ J <- [ MARKET ], b ~ DEMAND;
+
+param d{i in I, j in J};
+/* distance in thousands of miles */
+
+table dist IN "iODBC"
+ 'DSN=glpk;UID=glpk;PWD=gnu'
+ 'transp_dist' :
+ [ LOC1, LOC2 ], d ~ DIST;
+
+param f;
+/* freight in dollars per case per thousand miles */
+
+param c{i in I, j in J} := f * d[i,j] / 1000;
+/* transport cost in thousands of dollars per case */
+
+var x{i in I, j in J} >= 0;
+/* shipment quantities in cases */
+
+minimize cost: sum{i in I, j in J} c[i,j] * x[i,j];
+/* total transportation costs in thousands of dollars */
+
+s.t. supply{i in I}: sum{j in J} x[i,j] <= a[i];
+/* observe supply limit at plant i */
+
+s.t. demand{j in J}: sum{i in I} x[i,j] >= b[j];
+/* satisfy demand at market j */
+
+solve;
+
+table result{i in I, j in J: x[i,j]} OUT "iODBC"
+ 'DSN=glpk;UID=glpk;PWD=gnu'
+ 'DELETE FROM transp_result;'
+ 'INSERT INTO transp_result VALUES (?,?,?)' :
+ i ~ LOC1, j ~ LOC2, x[i,j] ~ QUANTITY;
+
+data;
+
+param f := 90;
+
+end;