/usr/share/doc/coinor-libsymphony-doc/examples/FLOPC++/tap.cpp is in coinor-libsymphony-doc 5.5.6-1ubuntu2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 | #include "flopc.hpp"
using namespace flopc;
#include "OsiSymSolverInterface.hpp"
/* Teacher Assignment Problem
T. H. Hultberg and D. M. Cardoso, "The teacher assignment problem: A special
case of the fixed charge transportation problem", European Journal of
Operational Research, 101(3):463-474,1997.
*/
class Tap : public MP_model {
public:
MP_set S,D;
MP_data s;
MP_data d;
MP_variable x;
MP_variable y;
MP_constraint supply, demand, def_y;
Tap(int numS, int numD) : MP_model(new OsiSymSolverInterface),
S(numS), D(numD),
s(S), d(D),
x(S,D), y(S,D),
supply(S), demand(D), def_y(S,D) {
y.binary();
supply(S) = sum(D, x(S,D)) <= s(S);
demand(D) = sum(S, x(S,D)) >= d(D) ;
def_y(S,D) = d(D)*y(S,D) >= x(S,D);
add(supply); add(demand); add(def_y);
setObjective( sum(S*D, y(S,D)) );
}
};
main() {
double stab_1[6] = {5,5,6,6,6,6};
double dtab_1[4] = {4, 7, 10, 11};
double stab_2[7] = {9,9,10,12,12,12,16};
double dtab_2[5] = {6, 14, 17, 21, 22};
Tap first_instance(6,4);
Tap second_instance(7,5);
first_instance.s.value(stab_1);
first_instance.d.value(dtab_1);
second_instance.s.value(stab_2);
second_instance.d.value(dtab_2);
first_instance.minimize();
first_instance.x.display("Solution of first instance (x)");
first_instance.y.display("Solution of first instance (y)");
second_instance.minimize();
second_instance.x.display("Solution of second instance");
}
|