[Lemon-commits] [lemon_svn] athos: r1989 - in hugo/trunk: lemon test
Lemon SVN
svn at lemon.cs.elte.hu
Mon Nov 6 20:49:18 CET 2006
Author: athos
Date: Tue Jun 21 17:58:57 2005
New Revision: 1989
Modified:
hugo/trunk/lemon/lp_base.h
hugo/trunk/lemon/lp_cplex.cc
hugo/trunk/lemon/lp_skeleton.h
hugo/trunk/test/lp_test.cc
Log:
cplex test included
Modified: hugo/trunk/lemon/lp_base.h
==============================================================================
--- hugo/trunk/lemon/lp_base.h (original)
+++ hugo/trunk/lemon/lp_base.h Tue Jun 21 17:58:57 2005
@@ -151,7 +151,7 @@
///Could not determine so far
UNKNOWN = 4
};
-
+
///The floating point type used by the solver
typedef double Value;
///The infinity constant
Modified: hugo/trunk/lemon/lp_cplex.cc
==============================================================================
--- hugo/trunk/lemon/lp_cplex.cc (original)
+++ hugo/trunk/lemon/lp_cplex.cc Tue Jun 21 17:58:57 2005
@@ -45,17 +45,17 @@
//The routine CPXcloneprob can be used to create a new CPLEX problem
//object and copy all the problem data from an existing problem
//object to it. Solution and starting information is not copied.
- newlp->lp = CPXcloneprob (env, lp, &status);
+ newlp->lp = CPXcloneprob(env, lp, &status);
return *newlp;
}
int LpCplex::_addCol()
{
- int i = CPXgetnumcols (env, lp);
+ int i = CPXgetnumcols(env, lp);
Value lb[1],ub[1];
lb[0]=-INF;//-CPX_INFBOUND;
ub[0]=INF;//CPX_INFBOUND;
- status = CPXnewcols (env, lp, 1, NULL, lb, ub, NULL, NULL);
+ status = CPXnewcols(env, lp, 1, NULL, lb, ub, NULL, NULL);
return i;
}
@@ -67,18 +67,18 @@
sense[0]='L';//<= constraint
Value rhs[1];
rhs[0]=INF;
- int i = CPXgetnumrows (env, lp);
- status = CPXnewrows (env, lp, 1, rhs, sense, NULL, NULL);
+ int i = CPXgetnumrows(env, lp);
+ status = CPXnewrows(env, lp, 1, rhs, sense, NULL, NULL);
return i;
}
void LpCplex::_eraseCol(int i) {
- CPXdelcols (env, lp, i, i);
+ CPXdelcols(env, lp, i, i);
}
void LpCplex::_eraseRow(int i) {
- CPXdelrows (env, lp, i, i);
+ CPXdelrows(env, lp, i, i);
}
@@ -119,7 +119,7 @@
void LpCplex::_setCoeff(int row, int col, Value value)
{
- CPXchgcoef (env, lp, row, col, value);
+ CPXchgcoef(env, lp, row, col, value);
}
void LpCplex::_setColLowerBound(int i, Value value)
@@ -130,7 +130,7 @@
lu[0]='L';
Value bd[1];
bd[0]=value;
- status = CPXchgbds (env, lp, 1, indices, lu, bd);
+ status = CPXchgbds(env, lp, 1, indices, lu, bd);
}
@@ -142,7 +142,7 @@
lu[0]='U';
Value bd[1];
bd[0]=value;
- status = CPXchgbds (env, lp, 1, indices, lu, bd);
+ status = CPXchgbds(env, lp, 1, indices, lu, bd);
}
//This will be easier to implement
@@ -160,27 +160,27 @@
if (lb==-INF){
sense[0]='L';
- CPXchgsense (env, lp, cnt, indices, sense);
- CPXchgcoef (env, lp, i, -1, ub);
+ CPXchgsense(env, lp, cnt, indices, sense);
+ CPXchgcoef(env, lp, i, -1, ub);
}
else{
if (ub==INF){
sense[0]='G';
- CPXchgsense (env, lp, cnt, indices, sense);
- CPXchgcoef (env, lp, i, -1, lb);
+ CPXchgsense(env, lp, cnt, indices, sense);
+ CPXchgcoef(env, lp, i, -1, lb);
}
else{
if (lb == ub){
sense[0]='E';
- CPXchgsense (env, lp, cnt, indices, sense);
- CPXchgcoef (env, lp, i, -1, lb);
+ CPXchgsense(env, lp, cnt, indices, sense);
+ CPXchgcoef(env, lp, i, -1, lb);
}
else{
sense[0]='R';
- CPXchgsense (env, lp, cnt, indices, sense);
- CPXchgcoef (env, lp, i, -1, lb);
- CPXchgcoef (env, lp, i, -2, ub-lb);
+ CPXchgsense(env, lp, cnt, indices, sense);
+ CPXchgcoef(env, lp, i, -1, lb);
+ CPXchgcoef(env, lp, i, -2, ub-lb);
}
}
}
@@ -197,9 +197,9 @@
// // //TODO Ezt kell meg megirni
// // //type of the problem
// // char sense[1];
-// // status = CPXgetsense (env, lp, sense, i, i);
+// // status = CPXgetsense(env, lp, sense, i, i);
// // Value rhs[1];
-// // status = CPXgetrhs (env, lp, rhs, i, i);
+// // status = CPXgetrhs(env, lp, rhs, i, i);
// // switch (sense[0]) {
// // case 'L'://<= constraint
@@ -214,18 +214,18 @@
// // //FIXME error
// // }
-// // status = CPXchgcoef (env, lp, i, -2, value_rng);
+// // status = CPXchgcoef(env, lp, i, -2, value_rng);
// }
void LpCplex::_setObjCoeff(int i, Value obj_coef)
{
- CPXchgcoef (env, lp, -1, i, obj_coef);
+ CPXchgcoef(env, lp, -1, i, obj_coef);
}
void LpCplex::_clearObj()
{
- for (int i=0;i< CPXgetnumcols (env, lp);++i){
- CPXchgcoef (env, lp, -1, i, 0);
+ for (int i=0;i< CPXgetnumcols(env, lp);++i){
+ CPXchgcoef(env, lp, -1, i, 0);
}
}
@@ -241,10 +241,10 @@
LpCplex::SolveExitStatus LpCplex::_solve()
{
//CPX_PARAM_LPMETHOD
- status = CPXlpopt (env, lp);
+ status = CPXlpopt(env, lp);
if (status == 0){
//We want to exclude some cases
- switch (CPXgetstat (env, lp)){
+ switch (CPXgetstat(env, lp)){
case CPX_OBJ_LIM:
case CPX_IT_LIM_FEAS:
case CPX_IT_LIM_INFEAS:
@@ -263,7 +263,7 @@
LpCplex::Value LpCplex::_getPrimal(int i)
{
Value x;
- CPXgetx (env, lp, &x, i, i);
+ CPXgetx(env, lp, &x, i, i);
return x;
}
@@ -271,7 +271,9 @@
{
Value objval;
//method = CPXgetmethod (env, lp);
- status = CPXgetobjval (env, lp, &objval);
+ //printf("CPXgetprobtype %d \n",CPXgetprobtype(env,lp));
+ status = CPXgetobjval(env, lp, &objval);
+ //printf("Objective value: %g \n",objval);
return objval;
}
@@ -329,7 +331,8 @@
LpCplex::SolutionStatus LpCplex::_getPrimalStatus()
{
- int stat = CPXgetstat (env, lp);
+ int stat = CPXgetstat(env, lp);
+ //printf("A primal status: %d, CPX_OPTIMAL=%d \n",stat,CPX_OPTIMAL);
switch (stat) {
case 0:
return UNDEFINED; //Undefined
@@ -379,7 +382,7 @@
LpCplex::SolutionStatus LpCplex::_getDualStatus()
{
- int stat = CPXgetstat (env, lp);
+ int stat = CPXgetstat(env, lp);
switch (stat) {
case 0:
return UNDEFINED; //Undefined
@@ -395,7 +398,7 @@
LpCplex::ProblemTypes LpCplex::_getProblemType()
{
- int stat = CPXgetstat (env, lp);
+ int stat = CPXgetstat(env, lp);
switch (stat) {
case CPX_OPTIMAL://Optimal
return PRIMAL_DUAL_FEASIBLE;
@@ -414,11 +417,11 @@
void LpCplex::_setMax()
{
- CPXchgobjsen (env, lp, CPX_MAX);
+ CPXchgobjsen(env, lp, CPX_MAX);
}
void LpCplex::_setMin()
{
- CPXchgobjsen (env, lp, CPX_MIN);
+ CPXchgobjsen(env, lp, CPX_MIN);
}
} //namespace lemon
Modified: hugo/trunk/lemon/lp_skeleton.h
==============================================================================
--- hugo/trunk/lemon/lp_skeleton.h (original)
+++ hugo/trunk/lemon/lp_skeleton.h Tue Jun 21 17:58:57 2005
@@ -22,7 +22,7 @@
///\file
///\brief A skeleton file to implement LP solver interfaces
namespace lemon {
-
+
///A skeleton class to implement LP solver interfaces
class LpSkeleton :public LpSolverBase {
int col_num,row_num;
Modified: hugo/trunk/test/lp_test.cc
==============================================================================
--- hugo/trunk/test/lp_test.cc (original)
+++ hugo/trunk/test/lp_test.cc Tue Jun 21 17:58:57 2005
@@ -17,12 +17,17 @@
void lpTest(LpSolverBase & lp)
{
+
+
+
typedef LpSolverBase LP;
std::vector<LP::Col> x(10);
// for(int i=0;i<10;i++) x.push_back(lp.addCol());
lp.addColSet(x);
+#ifndef GYORSITAS
+
std::vector<LP::Col> y(10);
lp.addColSet(y);
@@ -174,7 +179,7 @@
);
}
-
+#endif
}
void aTest(LpSolverBase & lp)
@@ -240,8 +245,9 @@
#endif
#ifdef HAVE_CPLEX
-// LpCplex lp_cplex;
-// lpTest(lp_cplex);
+ LpCplex lp_cplex;
+ lpTest(lp_cplex);
+ aTest(lp_cplex);
#endif
return 0;
More information about the Lemon-commits
mailing list