Originally posted by: null
I come across some encoding difficulties when I do ILP using CPLEX, hope you can do me a favour.
Here is some background info. A graph has n (say 15) nodes and m (say 17) directed edges. Each directed edge represents a reaction that if a node upstream is on (1 for on and 0 for off), it can activate the node downstream (1) or bock it (0).
Then I select four from 15 nodes (5, 8, 12, 13) as input and five (1, 3, 4, 5, 6) as output. I do some treatments, either activate 12, 13 or block 5, 8, to predict the output is on or off.
Then I measure the output nodes in each treatments to see if they are on or off.
The objective is to minimize the error between predictions and measurements.
Here is my code, but it has many problems.
range Species = 1..15;
tuple Reaction {
int SignalNode;
int InhibitorNode;
int ProductNode;
};
/*Each reaction has two compoments,one is SignalNode which activates downstream node or
InhibitorNode which block downstream node, another is ProductNode which is the downstream node */
{Reaction} Reactions = {
< , 1, 7>,
<2, , 8>,
<2, , 11>,
<5, , 3>,
<7, , 5>,
<8, , 1>,
<8, , 9>,
<9, , 4>,
<9, , 7>,
<10, , 5>,
<11, , 10>,
<12, , 2>,
<13, , 14>,
<14, , 8>,
<14, , 15>,
<15, , 4>,
<15, , 6>
};
range Experiments = 1..6;
{int} InputNode = {5, 8, 12, 13};
{int} OutputNode = {1, 3, 4, 5, 6};
int M
ExperimentsInputNode = [
0, 0, 1, 0,
0, 0, 0, 1,
1, 0, 1, 0,
1, 0, 0, 1,
0, 1, 1, 0,
0, 1, 0, 1] ;
int XMeasurement
ExperimentsOutputNode = [
1,1,0,0,0,
1,1,1,1,1,
0,0,0,0,0,
0,0,1,1,1,
1,1,0,0,0,
0,0,0,0,1] ;
//X[k][j] is 1 means it is on and 0 otherwise
dvar int X
ExperimentsSpecies in 0..1;
//Z[k][i] is 1 means Reaction i happens in Experiment k and 0 otherwise
dvar int Z
ExperimentsReactions in 0..1;
minimize
//use this function as the error between predictions and mesurements
sum(k in Experiments, j in OutputNode)
(XM[k][j] - (1 - 2 * XM[k][j]) * X[k][j]);
subject to{
//here I want the X[k][j] takes the value from M
forall(k in Experiments, j in InputNode)
X[k][j] <= M[k][j];
forall(k in Experiments, j in InputNode)
M[k][j] <= X[k][j];
//SignalNode is on then Reaction i will happen
forall(k in Experiments, i in Reactions, j in SignalNode)
Z[k][i] <= X[k][j];
//InhibitorNode is on then Reaction i will not happen
forall(k in Experiments, i in Reactions, j in InhibitorNode)
Z[k][i] <= 1 - X[k][j];
//Reaction i will take place when SignalNode is there and InhibitorNode is not
forall(k in Experiments, i in Reactions)
sum(j in SignalNode) (X[k][j] - 1) + sum(r in InhibitorNode) X[k][r] <= Z[k][i];
//ProductNode will be formed if Reaction i happens
forall(k in Experiments)
forall(i in Reactions, j in ProductNode)
Z[k][i] <= X[k][j];
}
#DecisionOptimization#MathematicalProgramming-General