COIN-OR::LEMON - Graph Library

Changeset 1473:876c7b7f4dae in lemon-0.x


Ignore:
Timestamp:
06/10/05 14:50:43 (19 years ago)
Author:
athos
Branch:
default
Phase:
public
Convert:
svn:c9d7d8f5-90d6-0310-b91f-818b3a526b0e/lemon/trunk@1953
Message:

Some tests have been developed, bugs got fixed.

Files:
3 edited

Legend:

Unmodified
Added
Removed
  • lemon/lp_cplex.cc

    r1460 r1473  
    392392      //FIXME error
    393393    }
    394 
    395  
     394  }
     395
    396396  LpCplex::ProblemTypes LpCplex::_getProblemType()
    397397  {
     
    411411      //FIXME error
    412412    }
    413 
     413  }
    414414
    415415  void LpCplex::_setMax()
  • lemon/lp_glpk.cc

    r1466 r1473  
    2222
    2323#include <lemon/lp_glpk.h>
    24 
     24//#include <iostream>
    2525namespace lemon {
    2626
     
    440440  LpGlpk::SolutionStatus LpGlpk::_getDualStatus()
    441441  {
     442//     std::cout<<"Itt megy: "<<lpx_get_dual_stat(lp)<<std::endl;
     443//     std::cout<<"Itt a primal: "<<lpx_get_prim_stat(lp)<<std::endl;
     444
    442445    switch (lpx_get_dual_stat(lp)) {
    443446    case LPX_D_UNDEF://Undefined (no solve has been run yet)
     
    446449//    case LPX_D_INFEAS://Infeasible
    447450      return INFEASIBLE;
    448     case LPX_FEAS://Feasible   
    449       switch (lpx_get_prim_stat(lp)) {
    450       case LPX_P_NOFEAS:
     451    case LPX_D_FEAS://Feasible   
     452      switch (lpx_get_status(lp)) {
     453      case LPX_NOFEAS:
    451454        return INFINITE;
    452455      case LPX_OPT:
  • test/lp_test.cc

    r1445 r1473  
    11#include<lemon/lp_skeleton.h>
     2#include "test_tools.h"
    23
    34#ifdef HAVE_CONFIG_H
     
    171172}
    172173
     174void aTest(LpSolverBase & lp)
     175{
     176  typedef LpSolverBase LP;
     177
     178 //The following example is taken from the book by Gáspár and Temesi, page 39.
     179
     180  typedef LpSolverBase::Row Row;
     181  typedef LpSolverBase::Col Col;
     182
     183
     184  Col x1 = lp.addCol();
     185  Col x2 = lp.addCol();
     186
     187
     188  //Constraints
     189  lp.addRow(3*x1+2*x2 >=6); 
     190  lp.addRow(-1*x1+x2<=4); 
     191  lp.addRow(5*x1+8*x2<=40); 
     192  lp.addRow(x1-2*x2<=4); 
     193  //Nonnegativity of the variables
     194  lp.colLowerBound(x1, 0);
     195  lp.colLowerBound(x2, 0);
     196  //Objective function
     197  lp.setObj(2*x1+x2);
     198
     199  lp.max();
     200  lp.solve();
     201
     202
     203  if (lp.primalStatus()==LpSolverBase::OPTIMAL){
     204    printf("Z = %g; x1 = %g; x2 = %g\n",
     205           lp.primalValue(),
     206           lp.primal(x1), lp.primal(x2));
     207  }
     208  else{
     209    std::cout<<"Optimal solution not found!"<<std::endl;
     210  }
     211
     212  check(lp.primalStatus()==LpSolverBase::OPTIMAL,"Primalstatus should be OPTIMAL");
     213
     214  double opt=123/9;
     215  check(lp.primalValue()==opt,"The optimum value is 122/9");
     216
     217
     218}
     219
     220
    173221int main()
    174222{
     
    179227  LpGlpk lp_glpk;
    180228  lpTest(lp_glpk);
     229  aTest(lp_glpk);
    181230#endif
    182231
    183232#ifdef HAVE_CPLEX
    184 //  LpCplex lp_cplex;
    185 //  lpTest(lp_cplex);
     233  LpCplex lp_cplex;
     234  lpTest(lp_cplex);
    186235#endif
    187236
Note: See TracChangeset for help on using the changeset viewer.