Ticket #7024: test_libs_linprogram.patch
File test_libs_linprogram.patch, 2.2 KB (added by , 13 years ago) |
---|
-
src/tests/libs/linprog/Jamfile
2 2 3 3 SetSubDirSupportedPlatformsBeOSCompatible ; 4 4 5 UsePrivateHeaders shared ; 6 5 7 UseLibraryHeaders lp_solve linprog ; 6 8 7 9 SimpleTest linprog_test : 8 10 Program.cpp 9 11 : 10 be liblpsolve55.so liblinprog. so$(TARGET_LIBSUPC++)12 be liblpsolve55.so liblinprog.a $(TARGET_LIBSUPC++) 11 13 ; -
src/tests/libs/linprog/Program.cpp
4 4 * Distributed under the terms of the MIT License. 5 5 */ 6 6 7 #include < List.h>7 #include <ObjectList.h> 8 8 #include <SupportDefs.h> 9 9 10 10 #include "LinearSpec.h" 11 11 12 12 #include <stdio.h> 13 13 14 using namespace LinearProgramming; 14 15 15 16 void 16 17 PrintVars(LinearSpec* ls) 17 18 { 18 int32 size = ls->Variables() ->CountItems();19 int32 size = ls->Variables().CountItems(); 19 20 Variable* variable; 20 for (int i = 0; i < size; i++) {21 variable = (Variable*)ls->Variables() ->ItemAt(i);21 for (int32 i = 0; i < size; i++) { 22 variable = (Variable*)ls->Variables().ItemAt(i); 22 23 printf("%f ", variable->Value()); 23 24 } 24 25 printf("%d\n", ls->Result()); … … 32 33 Variable* x1 = ls->AddVariable(); 33 34 Variable* x2 = ls->AddVariable(); 34 35 35 Constraint* c1 = ls->AddConstraint(1.0, x1, OperatorType( LE), 108);36 Constraint* c2 = ls->AddConstraint(1.0, x2, OperatorType( GE), 113);36 Constraint* c1 = ls->AddConstraint(1.0, x1, OperatorType(kLE), 108); 37 Constraint* c2 = ls->AddConstraint(1.0, x2, OperatorType(kGE), 113); 37 38 38 BList* summands = new BList(2);39 SummandList* summands = new SummandList(2); 39 40 summands->AddItem(new Summand(1.0, x1)); 40 41 summands->AddItem(new Summand(1.0, x2)); 41 ls->SetObj Function(summands);42 42 ls->SetObjectiveFunction(summands); 43 43 44 ls->Solve(); 44 45 PrintVars(ls); 45 46 47 delete c1; 46 48 delete c2; 47 49 ls->Solve(); 48 50 PrintVars(ls); 49 51 50 c2 = ls->AddConstraint(1.0, x2, OperatorType( GE), 113);52 c2 = ls->AddConstraint(1.0, x2, OperatorType(kGE), 113); 51 53 ls->Solve(); 52 54 PrintVars(ls); 53 55 }