test/lp_test.cc
changeset 1450 11a35ece69c7
parent 1437 2a3f3448ced1
child 1473 876c7b7f4dae
equal deleted inserted replaced
1:a594b9537a21 2:955b1d25f62b
    32   z.insert(std::make_pair(7,INVALID));
    32   z.insert(std::make_pair(7,INVALID));
    33   z.insert(std::make_pair(5,INVALID));
    33   z.insert(std::make_pair(5,INVALID));
    34   
    34   
    35   lp.addColSet(z);
    35   lp.addColSet(z);
    36 
    36 
       
    37   {
       
    38     LP::Expr e,f,g;
       
    39     LP::Col p1,p2,p3,p4,p5;
       
    40     LP::Constr c;
       
    41     
       
    42     e[p1]=2;
       
    43     e.constComp()=12;
       
    44     e[p1]+=2;
       
    45     e.constComp()+=12;
       
    46     e[p1]-=2;
       
    47     e.constComp()-=12;
       
    48     
       
    49     e=2;
       
    50     e=2.2;
       
    51     e=p1;
       
    52     e=f;
       
    53     
       
    54     e+=2;
       
    55     e+=2.2;
       
    56     e+=p1;
       
    57     e+=f;
       
    58     
       
    59     e-=2;
       
    60     e-=2.2;
       
    61     e-=p1;
       
    62     e-=f;
       
    63     
       
    64     e*=2;
       
    65     e*=2.2;
       
    66     e/=2;
       
    67     e/=2.2;
       
    68     
       
    69     e=((p1+p2)+(p1-p2)+(p1+12)+(12+p1)+(p1-12)+(12-p1)+
       
    70        (f+12)+(12+f)+(p1+f)+(f+p1)+(f+g)+
       
    71        (f-12)+(12-f)+(p1-f)+(f-p1)+(f-g)+
       
    72        2.2*f+f*2.2+f/2.2+
       
    73        2*f+f*2+f/2+
       
    74        2.2*p1+p1*2.2+p1/2.2+
       
    75        2*p1+p1*2+p1/2
       
    76        );
    37 
    77 
    38   LP::Expr e,f,g;
    78 
    39   LP::Col p1,p2,p3,p4,p5;
    79     c = (e  <= f  );
    40   LP::Constr c;
    80     c = (e  <= 2.2);
       
    81     c = (e  <= 2  );
       
    82     c = (e  <= p1 );
       
    83     c = (2.2<= f  );
       
    84     c = (2  <= f  );
       
    85     c = (p1 <= f  );
       
    86     c = (p1 <= p2 );
       
    87     c = (p1 <= 2.2);
       
    88     c = (p1 <= 2  );
       
    89     c = (2.2<= p2 );
       
    90     c = (2  <= p2 );
       
    91     
       
    92     c = (e  >= f  );
       
    93     c = (e  >= 2.2);
       
    94     c = (e  >= 2  );
       
    95     c = (e  >= p1 );
       
    96     c = (2.2>= f  );
       
    97     c = (2  >= f  );
       
    98     c = (p1 >= f  );
       
    99     c = (p1 >= p2 );
       
   100     c = (p1 >= 2.2);
       
   101     c = (p1 >= 2  );
       
   102     c = (2.2>= p2 );
       
   103     c = (2  >= p2 );
       
   104     
       
   105     c = (e  == f  );
       
   106     c = (e  == 2.2);
       
   107     c = (e  == 2  );
       
   108     c = (e  == p1 );
       
   109     c = (2.2== f  );
       
   110     c = (2  == f  );
       
   111     c = (p1 == f  );
       
   112     //c = (p1 == p2 );
       
   113     c = (p1 == 2.2);
       
   114     c = (p1 == 2  );
       
   115     c = (2.2== p2 );
       
   116     c = (2  == p2 );
       
   117     
       
   118     c = (2 <= e <= 3);
       
   119     c = (2 <= p1<= 3);
       
   120     
       
   121     c = (2 >= e >= 3);
       
   122     c = (2 >= p1>= 3);
       
   123     
       
   124     e[x[3]]=2;
       
   125     e[x[3]]=4;
       
   126     e[x[3]]=1;
       
   127     e.constComp()=12;
       
   128     
       
   129     lp.addRow(LP::INF,e,23);
       
   130     lp.addRow(LP::INF,3.0*(x[1]+x[2]/2)-x[3],23);
       
   131     lp.addRow(LP::INF,3.0*(x[1]+x[2]*2-5*x[3]+12-x[4]/3)+2*x[4]-4,23);
       
   132     
       
   133     lp.addRow(x[1]+x[3]<=x[5]-3);
       
   134     lp.addRow(-7<=x[1]+x[3]-12<=3);
       
   135     lp.addRow(x[1]<=x[5]);
       
   136   }
    41   
   137   
    42   e[p1]=2;
   138   {
    43   e.constComp()=12;
   139     LP::DualExpr e,f,g;
    44   e[p1]+=2;
   140     LP::Row p1,p2,p3,p4,p5;
    45   e.constComp()+=12;
   141     
    46   e[p1]-=2;
   142     e[p1]=2;
    47   e.constComp()-=12;
   143     e[p1]+=2;
    48   
   144     e[p1]-=2;
    49   e=2;
   145     
    50   e=2.2;
   146     e=p1;
    51   e=p1;
   147     e=f;
    52   e=f;
   148     
    53 
   149     e+=p1;
    54   e+=2;
   150     e+=f;
    55   e+=2.2;
   151     
    56   e+=p1;
   152     e-=p1;
    57   e+=f;
   153     e-=f;
    58 
   154     
    59   e-=2;
   155     e*=2;
    60   e-=2.2;
   156     e*=2.2;
    61   e-=p1;
   157     e/=2;
    62   e-=f;
   158     e/=2.2;
    63 
   159     
    64   e*=2;
   160     e=((p1+p2)+(p1-p2)+(p1+12)+(12+p1)+(p1-12)+(12-p1)+
    65   e*=2.2;
   161        (p1+f)+(f+p1)+(f+g)+
    66   e/=2;
   162        (p1-f)+(f-p1)+(f-g)+
    67   e/=2.2;
   163        2.2*f+f*2.2+f/2.2+
    68 
   164        2*f+f*2+f/2+
    69   e=((p1+p2)+(p1-p2)+(p1+12)+(12+p1)+(p1-12)+(12-p1)+
   165        2.2*p1+p1*2.2+p1/2.2+
    70       (f+12)+(12+f)+(p1+f)+(f+p1)+(f+g)+
   166        2*p1+p1*2+p1/2
    71       (f-12)+(12-f)+(p1-f)+(f-p1)+(f-g)+
   167        );
    72       2.2*f+f*2.2+f/2.2+
   168   }
    73       2*f+f*2+f/2+
       
    74       2.2*p1+p1*2.2+p1/2.2+
       
    75       2*p1+p1*2+p1/2
       
    76      );
       
    77   
   169   
    78 
   170 
    79   c = (e  <= f  );
       
    80   c = (e  <= 2.2);
       
    81   c = (e  <= 2  );
       
    82   c = (e  <= p1 );
       
    83   c = (2.2<= f  );
       
    84   c = (2  <= f  );
       
    85   c = (p1 <= f  );
       
    86   c = (p1 <= p2 );
       
    87   c = (p1 <= 2.2);
       
    88   c = (p1 <= 2  );
       
    89   c = (2.2<= p2 );
       
    90   c = (2  <= p2 );
       
    91 
       
    92   c = (e  >= f  );
       
    93   c = (e  >= 2.2);
       
    94   c = (e  >= 2  );
       
    95   c = (e  >= p1 );
       
    96   c = (2.2>= f  );
       
    97   c = (2  >= f  );
       
    98   c = (p1 >= f  );
       
    99   c = (p1 >= p2 );
       
   100   c = (p1 >= 2.2);
       
   101   c = (p1 >= 2  );
       
   102   c = (2.2>= p2 );
       
   103   c = (2  >= p2 );
       
   104 
       
   105   c = (e  == f  );
       
   106   c = (e  == 2.2);
       
   107   c = (e  == 2  );
       
   108   c = (e  == p1 );
       
   109   c = (2.2== f  );
       
   110   c = (2  == f  );
       
   111   c = (p1 == f  );
       
   112   //c = (p1 == p2 );
       
   113   c = (p1 == 2.2);
       
   114   c = (p1 == 2  );
       
   115   c = (2.2== p2 );
       
   116   c = (2  == p2 );
       
   117 
       
   118   c = (2 <= e <= 3);
       
   119   c = (2 <= p1<= 3);
       
   120 
       
   121   c = (2 >= e >= 3);
       
   122   c = (2 >= p1>= 3);
       
   123 
       
   124   e[x[3]]=2;
       
   125   e[x[3]]=4;
       
   126   e[x[3]]=1;
       
   127   e.constComp()=12;
       
   128   
       
   129   lp.addRow(LP::INF,e,23);
       
   130   lp.addRow(LP::INF,3.0*(x[1]+x[2]/2)-x[3],23);
       
   131   lp.addRow(LP::INF,3.0*(x[1]+x[2]*2-5*x[3]+12-x[4]/3)+2*x[4]-4,23);
       
   132 
       
   133   lp.addRow(x[1]+x[3]<=x[5]-3);
       
   134   lp.addRow(-7<=x[1]+x[3]-12<=3);
       
   135   lp.addRow(x[1]<=x[5]);
       
   136 
       
   137 
       
   138   
       
   139 }
   171 }
   140 
   172 
   141 int main() 
   173 int main() 
   142 {
   174 {
   143   LpSkeleton lp_skel;
   175   LpSkeleton lp_skel;