MeshKit
1.0
|
00001 // IAData.hpp 00002 // Interval Assignment Data for Meshkit 00003 // 00004 // This is the underlying data representation for the constraints needed by Meshkit 00005 // and the solver interface classes. 00006 // Only the IA family of classes should be using this. 00007 // 00008 // Ipopt appears to use Number for double. 00009 // 00010 00011 #ifndef MESHKIT_IA_IADATA_HP 00012 #define MESHKIT_IA_IADATA_HP 00013 00014 #include <vector> 00015 #include <cstddef> 00016 #include <assert.h> 00017 00018 namespace MeshKit 00019 { 00020 00021 const double MESHKIT_IA_upperUnbound = 2e19; // above 1e19, ipopt specific 00022 const double MESHKIT_IA_lowerUnbound = -2e19; // below -1e19, ipopt specific 00023 00024 00025 class IAData 00026 { 00027 public: 00029 IAData() {} 00030 00032 virtual ~IAData() {} 00033 00034 // ipopt solver forces the use of smartpointers which causes uncontrollable memory management and 00035 // hard to track memory bugs, so we have IANlp point to our data instead of inheriting this as a base class 00036 00037 // number of goals 00038 // number of constraints 00039 // goals 00040 // variables 00041 // constraints 00042 // vector of constraints 00043 // each constraint are the coefficients of the linear program, in sparse format 00044 00045 // choice of numeric type and index type matters. 00046 // Ipopt uses typedef Number double and typdef Index int, so 00047 // lets use double and int for now 00048 00049 // size_t numVariables, numConstraints; implicit, use x.size() 00050 00051 std::vector<double> I; // intervalGoals; 00052 int num_variables() const { return (int) I.size(); } 00053 00054 struct sparseEntry 00055 { 00056 // int row; // defined implicitly by index of contraint in constraints vector 00057 int col; 00058 double val; 00059 sparseEntry(const int c, const double v) : col(c), val(v) {} 00060 sparseEntry() : col(-1), val(0.) {} // bad values if unspecified 00061 }; 00062 00063 struct constraintRow 00064 { 00065 std::vector<sparseEntry> M; // non-zeros in the constraint row 00066 // double rhs; // righthand side constant incorporated into upper and lower bound 00067 double upperBound, lowerBound; // upper and lower bounds. equality for equal 00068 constraintRow() : upperBound(0.), lowerBound(0.) {} 00069 // or upperBound( MESHKIT_IA_upperUnbound), lowerBound(MESHKIT_IA_lowerUnbound) {} 00070 }; 00071 00072 struct sumEvenConstraintRow 00073 { 00074 std::vector<sparseEntry> M; 00075 int rhs; // right-hand-side constant 00076 sumEvenConstraintRow(): rhs(0) {} 00077 }; 00078 00079 std::vector<constraintRow> constraints; 00080 00081 std::vector<sumEvenConstraintRow> sumEvenConstraints; 00082 00083 }; 00084 00085 // default constructors for object and its members OK 00086 // inline IAData::IAData() {} 00087 00088 } // namespace MeshKit 00089 00090 #endif