00001
00029 #ifndef OSINSTANCE_H
00030 #define OSINSTANCE_H
00031 #include "OSConfig.h"
00032 #include "OSParameters.h"
00033 #include "OSGeneral.h"
00034 #include "OSMatrix.h"
00035 #include "OSnLNode.h"
00036 #include "OSExpressionTree.h"
00037 #include <string>
00038 #include <map>
00039
00040
00044 class Variable
00045 {
00046 public:
00048 Variable();
00049
00051 ~Variable();
00052
00056 double lb;
00057
00061 double ub;
00062
00066 char type;
00067
00071 std::string name;
00072
00076 bool IsEqual(Variable *that);
00077 };
00078
00079
00083 class Variables
00084 {
00085 public:
00086
00088 Variables();
00089
00091 ~Variables();
00092
00094 int numberOfVariables;
00095
00097 Variable **var;
00098
00102 bool IsEqual(Variables *that);
00103 };
00104
00105
00110 class ObjCoef
00111 {
00112 public:
00113
00115 ObjCoef();
00116
00118 ~ObjCoef();
00119
00123 int idx;
00124
00128 double value;
00129
00133 bool IsEqual(ObjCoef *that);
00134 };
00135
00136
00141 class Objective
00142 {
00143 public:
00144
00146 Objective();
00147
00149 ~Objective();
00150
00152 std::string name;
00153
00157 std::string maxOrMin;
00158
00162 double constant;
00163
00167 double weight;
00168
00172 int numberOfObjCoef;
00173
00176 ObjCoef **coef;
00177
00181 bool IsEqual(Objective *that);
00182 };
00183
00188 class Objectives
00189 {
00190 public:
00191
00193 Objectives();
00194
00196 ~Objectives();
00197
00201 int numberOfObjectives;
00202
00205 Objective **obj;
00206
00210 bool IsEqual(Objectives *that);
00211 };
00212
00213
00218 class Constraint
00219 {
00220 public:
00221
00223 Constraint();
00224
00226 ~Constraint();
00227
00229 std::string name;
00230
00232 double constant;
00233
00235 double lb;
00236
00238 double ub;
00239
00243 bool IsEqual(Constraint *that);
00244 };
00245
00246
00251 class Constraints
00252 {
00253 public:
00254
00256 Constraints();
00257
00259 ~Constraints();
00260
00264 int numberOfConstraints;
00265
00268 Constraint **con;
00269
00273 bool IsEqual(Constraints *that);
00274 };
00275
00276
00288 class LinearConstraintCoefficients
00289 {
00290 public:
00291
00293 LinearConstraintCoefficients();
00294
00296 ~LinearConstraintCoefficients();
00297
00301 int numberOfValues;
00302
00306 IntVector *start;
00307
00309 IntVector *rowIdx;
00310
00312 IntVector *colIdx;
00313
00315 DoubleVector *value;
00322 int iNumberOfStartElements;
00323
00327 bool IsEqual(LinearConstraintCoefficients *that);
00328 };
00329
00330
00340 class QuadraticTerm
00341 {
00342 public:
00343
00345 QuadraticTerm();
00346
00348 ~QuadraticTerm();
00349
00353 int idx;
00354
00358 int idxOne;
00359
00363 int idxTwo;
00364
00366 double coef;
00367
00371 bool IsEqual(QuadraticTerm *that);
00372 };
00373
00374
00380 class QuadraticCoefficients
00381 {
00382 public:
00383
00385 QuadraticCoefficients();
00386
00388 ~QuadraticCoefficients();
00389
00393 int numberOfQuadraticTerms;
00394
00397 QuadraticTerm** qTerm;
00398
00402 bool IsEqual(QuadraticCoefficients *that);
00403 };
00404
00405
00410 class Nl
00411 {
00412 public:
00414 int idx;
00415
00420 ENUM_NL_EXPR_SHAPE shape;
00421
00427 bool m_bDeleteExpressionTree;
00428
00430 ScalarExpressionTree *osExpressionTree;
00431
00435 Nl();
00436
00440 ~Nl();
00441
00445 bool IsEqual(Nl *that);
00446 };
00447
00452 class NonlinearExpressions
00453 {
00454 public:
00455
00457 NonlinearExpressions();
00458
00460 ~NonlinearExpressions();
00461
00466 int numberOfNonlinearExpressions;
00467
00469 Nl **nl;
00470
00474 bool IsEqual(NonlinearExpressions *that);
00475 };
00476
00477
00482 class Matrices
00483 {
00484 public:
00485
00487 Matrices();
00488
00490 ~Matrices();
00491
00496 int numberOfMatrices;
00497
00499 OSMatrix **matrix;
00500
00504 bool IsEqual(Matrices *that);
00505
00515 bool setRandom(double density, bool conformant, int iMin, int iMax);
00516
00522 bool deepCopyFrom(Matrices *that);
00523 };
00524
00525
00530 class Cone
00531 {
00532 public:
00533
00535 Cone();
00536
00538 virtual ~Cone();
00539
00543 int numberOfRows;
00544 int numberOfColumns;
00545
00552 int numberOfOtherIndexes;
00553 int* otherIndexes;
00554
00556 ENUM_CONE_TYPE coneType;
00557
00559 std::string name;
00560
00562 int idx;
00563
00567 virtual std::string getConeName();
00568
00575 virtual std::string getConeInXML() = 0;
00576
00577
00581 bool IsEqual(Cone *that);
00582
00592 bool setRandom(double density, bool conformant, int iMin, int iMax);
00593
00599 bool deepCopyFrom(Cone *that);
00600 };
00601
00609 class NonnegativeCone : public Cone
00610 {
00611 public:
00615 NonnegativeCone();
00616
00620 ~NonnegativeCone();
00621
00625 virtual std::string getConeName();
00626
00633 virtual std::string getConeInXML();
00634
00638 bool IsEqual(NonnegativeCone *that);
00639
00649 bool setRandom(double density, bool conformant, int iMin, int iMax);
00650
00656 bool deepCopyFrom(NonnegativeCone *that);
00657
00658 };
00659
00667 class NonpositiveCone : public Cone
00668 {
00669 public:
00673 NonpositiveCone();
00674
00678 ~NonpositiveCone();
00679
00683 virtual std::string getConeName();
00684
00691 virtual std::string getConeInXML();
00692
00696 bool IsEqual(NonpositiveCone *that);
00697
00707 bool setRandom(double density, bool conformant, int iMin, int iMax);
00708
00714 bool deepCopyFrom(NonpositiveCone *that);
00715
00716 };
00717
00718
00726 class OrthantCone : public Cone
00727 {
00728 public:
00733 double* ub;
00734 double* lb;
00735
00739 OrthantCone();
00740
00744 ~OrthantCone();
00745
00749 virtual std::string getConeName();
00750
00757 virtual std::string getConeInXML();
00758
00762 bool IsEqual(OrthantCone *that);
00763
00773 bool setRandom(double density, bool conformant, int iMin, int iMax);
00774
00780 bool deepCopyFrom(OrthantCone *that);
00781 };
00782
00786 class PolyhedralCone : public Cone
00787 {
00788 public:
00789
00791 PolyhedralCone();
00792
00794 ~PolyhedralCone();
00795
00799 int numberOfRows;
00800 int numberOfColumns;
00801
00807 int numberOfOtherIndexes;
00808 int* otherIndexes;
00809
00811 int coneType;
00812
00814 int idx;
00815
00817 int referenceMatrixIdx;
00818
00822 virtual std::string getConeName();
00823
00830 virtual std::string getConeInXML();
00831
00835 bool IsEqual(PolyhedralCone *that);
00836
00846 bool setRandom(double density, bool conformant, int iMin, int iMax);
00847
00853 bool deepCopyFrom(PolyhedralCone *that);
00854 };
00855
00856
00860 class QuadraticCone : public Cone
00861 {
00862 public:
00863
00865 QuadraticCone();
00866
00868 ~QuadraticCone();
00869
00873 int numberOfRows;
00874 int numberOfColumns;
00875
00881 int numberOfOtherIndexes;
00882 int* otherIndexes;
00883
00885 int coneType;
00886
00888 int idx;
00889
00896 double normScaleFactor;
00897 int distortionMatrixIdx;
00898
00908 int axisDirection;
00909
00913 virtual std::string getConeName();
00914
00921 virtual std::string getConeInXML();
00922
00926 bool IsEqual(QuadraticCone *that);
00927
00937 bool setRandom(double density, bool conformant, int iMin, int iMax);
00938
00944 bool deepCopyFrom(QuadraticCone *that);
00945 };
00946
00947
00951 class RotatedQuadraticCone : public Cone
00952 {
00953 public:
00954
00956 RotatedQuadraticCone();
00957
00959 ~RotatedQuadraticCone();
00960
00964 int numberOfRows;
00965 int numberOfColumns;
00966
00972 int numberOfOtherIndexes;
00973 int* otherIndexes;
00974
00976 int coneType;
00977
00979 int idx;
00980
00987 double normScaleFactor;
00988 int distortionMatrixIdx;
00989
00999 int firstAxisDirection;
01000 int secondAxisDirection;
01001
01005 virtual std::string getConeName();
01006
01013 virtual std::string getConeInXML();
01014
01018 bool IsEqual(RotatedQuadraticCone *that);
01019
01029 bool setRandom(double density, bool conformant, int iMin, int iMax);
01030
01036 bool deepCopyFrom(RotatedQuadraticCone *that);
01037 };
01038
01039
01040
01041
01042
01046 class SemidefiniteCone : public Cone
01047 {
01048 public:
01049
01051 SemidefiniteCone();
01052
01054 ~SemidefiniteCone();
01055
01059 int numberOfRows;
01060 int numberOfColumns;
01061
01067 int numberOfOtherIndexes;
01068 int* otherIndexes;
01069
01071 int coneType;
01072
01074 int idx;
01075
01077 std::string semidefiniteness;
01078
01080 bool isPositiveSemiDefinite;
01081
01085 virtual std::string getConeName();
01086
01093 virtual std::string getConeInXML();
01094
01098 bool IsEqual(SemidefiniteCone *that);
01099
01109 bool setRandom(double density, bool conformant, int iMin, int iMax);
01110
01116 bool deepCopyFrom(SemidefiniteCone *that);
01117 };
01118
01119
01127 class CopositiveMatricesCone : public Cone
01128 {
01129 public:
01133 CopositiveMatricesCone();
01134
01138 ~CopositiveMatricesCone();
01139
01143 virtual std::string getConeName();
01144
01151 virtual std::string getConeInXML();
01152
01156 bool IsEqual(CopositiveMatricesCone *that);
01157
01167 bool setRandom(double density, bool conformant, int iMin, int iMax);
01168
01174 bool deepCopyFrom(CopositiveMatricesCone *that);
01175
01176 };
01177
01178
01186 class CompletelyPositiveMatricesCone : public Cone
01187 {
01188 public:
01193 CompletelyPositiveMatricesCone();
01194
01198 ~CompletelyPositiveMatricesCone();
01199
01203 virtual std::string getConeName();
01204
01212 virtual std::string getConeInXML();
01213
01217 bool IsEqual(CompletelyPositiveMatricesCone *that);
01218
01228 bool setRandom(double density, bool conformant, int iMin, int iMax);
01229
01235 bool deepCopyFrom(CompletelyPositiveMatricesCone *that);
01236
01237 };
01238
01239
01240
01241
01242
01243
01244
01248 class ProductCone : public Cone
01249 {
01250 public:
01251
01253 ProductCone();
01254
01256 ~ProductCone();
01257
01261 int numberOfRows;
01262 int numberOfColumns;
01263
01269 int numberOfOtherIndexes;
01270 int* otherIndexes;
01271
01273 int coneType;
01274
01276 int idx;
01277
01281 IntVector* factors;
01282
01286 virtual std::string getConeName();
01287
01294 virtual std::string getConeInXML();
01295
01299 bool IsEqual(ProductCone *that);
01300
01310 bool setRandom(double density, bool conformant, int iMin, int iMax);
01311
01312
01318 bool deepCopyFrom(ProductCone *that);
01319 };
01320
01324 class IntersectionCone : public Cone
01325 {
01326 public:
01327
01329 IntersectionCone();
01330
01332 ~IntersectionCone();
01333
01337 int numberOfRows;
01338 int numberOfColumns;
01339
01345 int numberOfOtherIndexes;
01346 int* otherIndexes;
01347
01349 int coneType;
01350
01352 int idx;
01353
01357 IntVector* components;
01358
01362 virtual std::string getConeName();
01363
01370 virtual std::string getConeInXML();
01371
01375 bool IsEqual(IntersectionCone *that);
01376
01386 bool setRandom(double density, bool conformant, int iMin, int iMax);
01387
01393 bool deepCopyFrom(IntersectionCone *that);
01394 };
01395
01396
01400 class DualCone : public Cone
01401 {
01402 public:
01403
01405 DualCone();
01406
01408 ~DualCone();
01409
01413 int numberOfRows;
01414 int numberOfColumns;
01415
01421 int numberOfOtherIndexes;
01422 int* otherIndexes;
01423
01425 int coneType;
01426
01428 int idx;
01429
01431 int referenceConeIdx;
01432
01436 virtual std::string getConeName();
01437
01441 bool IsEqual(DualCone *that);
01442
01452 bool setRandom(double density, bool conformant, int iMin, int iMax);
01453
01459 bool deepCopyFrom(DualCone *that);
01460 };
01461
01465 class PolarCone : public Cone
01466 {
01467 public:
01468
01470 PolarCone();
01471
01473 ~PolarCone();
01474
01478 int numberOfRows;
01479 int numberOfColumns;
01480
01486 int numberOfOtherIndexes;
01487 int* otherIndexes;
01488
01490 int coneType;
01491
01493 int idx;
01494
01496 int referenceConeIdx;
01497
01501 virtual std::string getConeName();
01502
01506 bool IsEqual(PolarCone *that);
01507
01517 bool setRandom(double density, bool conformant, int iMin, int iMax);
01518
01524 bool deepCopyFrom(PolarCone *that);
01525 };
01526
01527
01532 class Cones
01533 {
01534 public:
01535
01537 Cones();
01538
01540 ~Cones();
01541
01546 int numberOfCones;
01547
01549 Cone **cone;
01550
01554 bool IsEqual(Cones *that);
01555
01564 bool setRandom(double density, bool conformant, int iMin, int iMax);
01565
01571 bool deepCopyFrom(Cones *that);
01572 };
01573
01574
01579 class MatrixVar
01580 {
01581 public:
01583 int numberOfRows;
01584
01586 int numberOfColumns;
01587
01591 int templateMatrixIdx;
01592
01596 int varReferenceMatrixIdx;
01597
01599 int lbMatrixIdx;
01600
01602 int lbConeIdx;
01603
01605 int ubMatrixIdx;
01606
01608 int ubConeIdx;
01609
01611 std::string name;
01612
01616 char varType;
01617
01619 MatrixVar();
01620
01622 ~MatrixVar();
01623
01627 bool IsEqual(MatrixVar *that);
01628 };
01629
01630
01635 class MatrixVariables
01636 {
01637 public:
01639 int numberOfMatrixVar;
01640
01642 MatrixVar** matrixVar;
01643
01645 MatrixVariables();
01646
01648 ~MatrixVariables();
01649
01653 bool IsEqual(MatrixVariables *that);
01654 };
01655
01656
01661 class MatrixObj
01662 {
01663 public:
01665 int numberOfRows;
01666
01668 int numberOfColumns;
01669
01673 int templateMatrixIdx;
01674
01678 int objReferenceMatrixIdx;
01679
01683 int orderConeIdx;
01684
01686 int constantMatrixIdx;
01687
01689 std::string name;
01690
01692 MatrixObj();
01693
01695 ~MatrixObj();
01696
01700 bool IsEqual(MatrixObj *that);
01701 };
01702
01703
01708 class MatrixObjectives
01709 {
01710 public:
01711
01713 MatrixObjectives();
01714
01716 ~MatrixObjectives();
01717
01719 int numberOfMatrixObj;
01720
01722 MatrixObj** matrixObj;
01723
01724
01728 bool IsEqual(MatrixObjectives *that);
01729 };
01730
01731
01736 class MatrixCon
01737 {
01738 public:
01740 int numberOfRows;
01741
01743 int numberOfColumns;
01744
01748 int templateMatrixIdx;
01749
01753 int conReferenceMatrixIdx;
01754
01756 int lbMatrixIdx;
01757
01759 int lbConeIdx;
01760
01762 int ubMatrixIdx;
01763
01765 int ubConeIdx;
01766
01768 std::string name;
01769
01771 MatrixCon();
01772
01774 ~MatrixCon();
01775
01779 bool IsEqual(MatrixCon *that);
01780 };
01781
01782
01787 class MatrixConstraints
01788 {
01789 public:
01790
01792 MatrixConstraints();
01793
01795 ~MatrixConstraints();
01796
01798 int numberOfMatrixCon;
01799
01801 MatrixCon** matrixCon;
01802
01803
01807 bool IsEqual(MatrixConstraints *that);
01808 };
01809
01816 class MatrixExpression
01817 {
01818 public:
01820 int idx;
01821
01826 ENUM_NL_EXPR_SHAPE shape;
01827
01829 MatrixExpressionTree *matrixExpressionTree;
01830
01836 bool m_bDeleteExpressionTree;
01837
01839 MatrixExpression();
01840
01842 ~MatrixExpression();
01843
01847 bool IsEqual(MatrixExpression *that);
01848 };
01849
01850
01855 class MatrixExpressions
01856 {
01857 public:
01859 int numberOfExpr;
01860
01864 MatrixExpression **expr;
01865
01867 MatrixExpressions();
01868
01870 ~MatrixExpressions();
01871
01875 bool IsEqual(MatrixExpressions *that);
01876 };
01877
01882 class MatrixProgramming
01883 {
01884 public:
01886 MatrixProgramming();
01887
01889 ~MatrixProgramming();
01890
01892 MatrixVariables* matrixVariables;
01893
01895 MatrixObjectives* matrixObjectives;
01896
01898 MatrixConstraints* matrixConstraints;
01899
01901 MatrixExpressions* matrixExpressions;
01902
01903
01907 bool IsEqual(MatrixProgramming *that);
01908
01918 bool setRandom(double density, bool conformant, int iMin, int iMax);
01919
01925 bool deepCopyFrom(MatrixProgramming *that);
01926 };
01927
01928
01933 class TimeDomainStageVar
01934 {
01935 public:
01936
01938 TimeDomainStageVar();
01939
01941 ~TimeDomainStageVar();
01942
01944 int idx;
01945 };
01946
01951 class TimeDomainStageVariables
01952 {
01953 public:
01954
01956 TimeDomainStageVariables();
01957
01959 ~TimeDomainStageVariables();
01960
01962 int numberOfVariables;
01963
01965 int startIdx;
01966
01968 TimeDomainStageVar** var;
01969 };
01970
01971
01976 class TimeDomainStageCon
01977 {
01978 public:
01979
01981 TimeDomainStageCon();
01982
01984 ~TimeDomainStageCon();
01985
01987 int idx;
01988 };
01989
01994 class TimeDomainStageConstraints
01995 {
01996 public:
01997
01999 TimeDomainStageConstraints();
02000
02002 ~TimeDomainStageConstraints();
02003
02005 int numberOfConstraints;
02006
02008 int startIdx;
02009
02011 TimeDomainStageCon** con;
02012 };
02013
02014
02019 class TimeDomainStageObj
02020 {
02021 public:
02022
02024 TimeDomainStageObj();
02025
02027 ~TimeDomainStageObj();
02028
02030 int idx;
02031 };
02032
02037 class TimeDomainStageObjectives
02038 {
02039 public:
02040
02042 TimeDomainStageObjectives();
02043
02045 ~TimeDomainStageObjectives();
02046
02048 int numberOfObjectives;
02049
02051 int startIdx;
02052
02054 TimeDomainStageObj** obj;
02055 };
02056
02057
02062 class TimeDomainStage
02063 {
02064 public:
02065
02067 TimeDomainStage();
02068
02070 ~TimeDomainStage();
02071
02075 std::string name;
02076
02078 TimeDomainStageVariables *variables;
02079
02081 TimeDomainStageConstraints *constraints;
02082
02084 TimeDomainStageObjectives *objectives;
02085 };
02086
02091 class TimeDomainStages
02092 {
02093 public:
02094
02096 TimeDomainStages();
02097
02099 ~TimeDomainStages();
02100
02104 int numberOfStages;
02105
02107 TimeDomainStage **stage;
02108 };
02109
02114 class TimeDomainInterval
02115 {
02116 public:
02117
02119 TimeDomainInterval();
02120
02122 ~TimeDomainInterval();
02123
02127 double start;
02128
02132 double horizon;
02133 };
02134
02139 class TimeDomain
02140 {
02141 public:
02142
02144 TimeDomain();
02145
02147 ~TimeDomain();
02148
02151 TimeDomainStages *stages;
02152
02155 TimeDomainInterval *interval;
02156 };
02157
02174 class InstanceData
02175 {
02176 public:
02177
02179 InstanceData();
02180
02182 ~InstanceData();
02183
02185 Variables *variables;
02186
02188 Objectives *objectives;
02189
02191 Constraints *constraints;
02192
02196 LinearConstraintCoefficients *linearConstraintCoefficients;
02197
02201 QuadraticCoefficients* quadraticCoefficients;
02202
02206 NonlinearExpressions* nonlinearExpressions;
02207
02211 Matrices* matrices;
02212
02216 Cones* cones;
02217
02221 MatrixProgramming* matrixProgramming;
02222
02226 TimeDomain* timeDomain;
02227
02231 bool IsEqual(InstanceData *that);
02232 };
02233
02234
02262 class OSInstance
02263 {
02264 public:
02265
02267 OSInstance();
02268
02270 ~OSInstance();
02271
02275 GeneralFileHeader *instanceHeader;
02276
02278 InstanceData *instanceData;
02279
02283 bool IsEqual(OSInstance *that);
02284
02288 bool bVariablesModified;
02289
02293 bool bObjectivesModified;
02294
02298 bool bConstraintsModified;
02299
02303 bool bAMatrixModified;
02304
02305 private:
02310 std::string m_sInstanceName;
02314 std::string m_sInstanceSource;
02318 std::string m_sInstanceDescription;
02322 std::string m_sInstanceCreator;
02326 std::string m_sInstanceLicence;
02327
02328
02333 bool m_bProcessVariables;
02334
02338 int m_iVariableNumber;
02339
02343 int m_iNumberOfIntegerVariables;
02344
02348 int m_iNumberOfBinaryVariables;
02349
02353 int m_iNumberOfSemiContinuousVariables;
02354
02358 int m_iNumberOfSemiIntegerVariables;
02359
02363 int m_iNumberOfStringVariables;
02364
02368 std::string* m_msVariableNames;
02369
02374 char* m_mcVariableTypes;
02375
02379 double* m_mdVariableLowerBounds;
02380
02384 double* m_mdVariableUpperBounds;
02385
02386
02391 bool m_bProcessObjectives;
02392
02396 int m_iObjectiveNumber;
02397
02401 int m_iObjectiveNumberNonlinear;
02402
02406 std::string* m_msObjectiveNames;
02407
02411 std::string* m_msMaxOrMins;
02412
02416 int* m_miNumberOfObjCoef;
02417
02421 double* m_mdObjectiveConstants;
02422
02426 double* m_mdObjectiveWeights;
02427
02432 SparseVector** m_mObjectiveCoefficients;
02433
02437 bool m_bGetDenseObjectives;
02438
02443 double** m_mmdDenseObjectiveCoefficients;
02444
02445
02450 bool m_bProcessConstraints;
02451
02455 int m_iConstraintNumber;
02456
02460 int m_iConstraintNumberNonlinear;
02461
02465 std::string* m_msConstraintNames;
02466
02470 double* m_mdConstraintLowerBounds;
02471
02475 double* m_mdConstraintUpperBounds;
02476
02481 double* m_mdConstraintConstants;
02482
02487 char* m_mcConstraintTypes;
02488
02489
02495 bool m_bProcessLinearConstraintCoefficients;
02496
02501 int m_iLinearConstraintCoefficientNumber;
02502
02507 bool m_bColumnMajor;
02508
02514 SparseMatrix* m_linearConstraintCoefficientsInColumnMajor;
02515
02521 SparseMatrix* m_linearConstraintCoefficientsInRowMajor;
02522
02523
02528 int m_iNumberOfQuadraticRowIndexes;
02529
02533 bool m_bQuadraticRowIndexesProcessed;
02534
02538 int *m_miQuadRowIndexes;
02539
02543 bool m_bProcessQuadraticTerms;
02544
02549 int m_iQuadraticTermNumber;
02550
02555 QuadraticTerms* m_quadraticTerms;
02556
02559 bool m_bQTermsAdded;
02560
02561
02567 int m_iNumberOfNonlinearExpressionTreeIndexes;
02568
02573 bool m_bNonlinearExpressionTreeIndexesProcessed;
02574
02580 int *m_miNonlinearExpressionTreeIndexes;
02581
02587 int m_iNumberOfNonlinearExpressionTreeModIndexes;
02588
02593 bool m_bNonlinearExpressionTreeModIndexesProcessed;
02594
02599 int *m_miNonlinearExpressionTreeModIndexes;
02600
02601
02606 bool m_binitForAlgDiff;
02607
02612 unsigned int m_iNumberOfNonlinearVariables;
02613
02617 bool m_bProcessNonlinearExpressions;
02618
02622 int m_iNonlinearExpressionNumber;
02623
02628 int* m_miNonlinearExpressionIndexes;
02629
02633 bool m_bProcessExpressionTrees;
02634
02638 bool m_bProcessExpressionTreesMod;
02639
02644 double *m_mdConstraintFunctionValues;
02645
02650 double *m_mdObjectiveFunctionValues;
02651
02655 int m_iJacValueSize;
02656
02660 int *m_miJacStart;
02661
02665 int *m_miJacIndex;
02666
02670 double *m_mdJacValue;
02671
02676 int *m_miJacNumConTerms;
02677
02681 SparseJacobianMatrix *m_sparseJacMatrix;
02682
02687 int m_iHighestTaylorCoeffOrder;
02688
02697 std::map<int, ScalarExpressionTree*> m_mapExpressionTrees;
02698
02703 std::map<int, int> m_mapOSADFunRangeIndex;
02704
02713 std::map<int, MatrixExpressionTree*> m_mapMatrixExpressionTrees;
02714
02719 ScalarExpressionTree *m_LagrangianExpTree;
02720
02724 bool m_bLagrangianExpTreeCreated;
02725
02729 SparseHessianMatrix* m_LagrangianSparseHessian;
02730
02735 bool m_bLagrangianSparseHessianCreated;
02736
02740 std::map<int, int> m_mapAllNonlinearVariablesIndex;
02741
02746 int *m_miNonLinearVarsReverseMap;
02747
02752 bool m_bAllNonlinearVariablesIndex;
02753
02761 std::map<int, ScalarExpressionTree*> m_mapExpressionTreesMod ;
02762
02768 bool m_bOSADFunIsCreated;
02769
02774 bool m_bCppADTapesBuilt;
02775
02780 bool m_bCppADMustReTape;
02781
02785 bool m_bDuplicateExpressionTreesMap;
02786
02790 bool m_bNonLinearStructuresInitialized;
02791
02795 bool m_bSparseJacobianCalculated;
02796
02802 std::map<int, std::vector<OSnLNode*> > m_mapExpressionTreesInPostfix ;
02803
02808 int m_iHighestOrderEvaluated;
02809
02814 double **m_mmdObjGradient;
02815
02816
02821 std::vector<double> m_vdX;
02822
02826 std::vector<double> m_vdYval;
02827
02832 std::vector<bool> m_vbLagHessNonz;
02833
02837 std::vector<double> m_vdYjacval;
02838
02842 std::vector<double> m_vdw;
02843
02847 std::vector<double> m_vdLambda;
02848
02852 std::vector<double> m_vdDomainUnitVec;
02853
02857 std::vector<double> m_vdRangeUnitVec;
02858
02859
02864 bool m_bProcessMatrices;
02865
02869 int m_iMatrixNumber;
02870
02875 ENUM_MATRIX_SYMMETRY* m_miMatrixSymmetry;
02876
02881 ENUM_MATRIX_TYPE* m_miMatrixType;
02882
02886 int* m_miMatrixNumberOfColumns;
02887
02891 int* m_miMatrixNumberOfRows;
02892
02896 std::string* m_msMatrixNames;
02897
02905 OSMatrix** m_mMatrix;
02906
02907 #if 0
02908
02930 GeneralSparseMatrix** m_mExpandedMatricesInColumnMajor;
02931
02935 GeneralSparseMatrix** m_mExpandedMatricesInRowMajor;
02936
02942 ExpandedMatrixBlocks** m_mMatrixBlocksInColumnMajor;
02943
02949 OSnLMNode *m_mMatrixTransformation;
02950 #endif
02951
02956 int m_iMatrixVarNumber;
02957
02961 int m_iMatrixObjNumber;
02962
02966 int m_iMatrixConNumber;
02967
02971 int m_iMatrixExpressionNumber;
02972
02973
02978 bool m_bProcessTimeDomain;
02979
02983 bool m_bProcessTimeStages;
02984
02988 bool m_bProcessTimeInterval;
02989
02993 bool m_bFiniteTimeStages;
02994
02998 int m_iNumberOfTimeStages;
02999
03003 std::string m_sTimeDomainFormat;
03004
03008 std::string* m_msTimeDomainStageNames;
03009
03010
03011
03012
03016 int* m_miTimeDomainStageVariableNumber;
03017
03021 int** m_mmiTimeDomainStageVarList;
03022
03026 int* m_miTimeDomainStageConstraintNumber;
03027
03031 int** m_mmiTimeDomainStageConList;
03032
03036 int* m_miTimeDomainStageObjectiveNumber;
03037
03041 int** m_mmiTimeDomainStageObjList;
03042
03043
03050 bool processVariables();
03051
03058 bool processObjectives();
03059
03066 bool processConstraints();
03067
03074 bool processLinearConstraintCoefficients();
03075
03082 bool processMatrices();
03083
03084 public:
03085
03090 std::string getInstanceName();
03091
03096 std::string getInstanceSource();
03097
03103 std::string getInstanceDescription();
03104
03109 std::string getInstanceCreator();
03110
03116 std::string getInstanceLicence();
03117
03118
03124 int getVariableNumber();
03125
03132 std::string* getVariableNames();
03133
03141
03142
03150
03151
03163 char* getVariableTypes();
03164
03169 int getNumberOfIntegerVariables();
03170
03175 int getNumberOfBinaryVariables();
03176
03181 int getNumberOfSemiContinuousVariables();
03182
03187 int getNumberOfSemiIntegerVariables();
03188
03193 int getNumberOfStringVariables();
03194
03201 double* getVariableLowerBounds();
03202
03209 double* getVariableUpperBounds();
03210
03216 int getObjectiveNumber();
03217
03218
03225 std::string* getObjectiveNames();
03226
03233 std::string* getObjectiveMaxOrMins();
03234
03235
03244 int* getObjectiveCoefficientNumbers();
03245
03252 double* getObjectiveConstants();
03253
03260 double* getObjectiveWeights();
03261
03272 SparseVector** getObjectiveCoefficients();
03273
03280 double** getDenseObjectiveCoefficients();
03281
03287 int getConstraintNumber();
03288
03295 std::string* getConstraintNames();
03296
03303 double* getConstraintLowerBounds();
03304
03311 double *getConstraintUpperBounds();
03312
03319 double *getConstraintConstants();
03320
03334 char* getConstraintTypes();
03335
03341 int getLinearConstraintCoefficientNumber();
03342
03343
03350 bool getLinearConstraintCoefficientMajor();
03351
03352
03359 SparseMatrix* getLinearConstraintCoefficientsInColumnMajor();
03360
03367 SparseMatrix* getLinearConstraintCoefficientsInRowMajor();
03368
03374 int getNumberOfQuadraticTerms();
03375
03384 QuadraticTerms* getQuadraticTerms();
03385
03393 int* getQuadraticRowIndexes();
03394
03400 int getNumberOfQuadraticRowIndexes();
03401
03402
03403
03404
03405
03406
03407
03408
03409
03410
03411
03417 int getNumberOfNonlinearExpressions();
03418
03424 Nl** getNonlinearExpressions();
03425
03431 ScalarExpressionTree* getNonlinearExpressionTree(int rowIdx);
03432
03439 ScalarExpressionTree* getNonlinearExpressionTreeMod(int rowIdx);
03440
03449 std::vector<ExprNode*> getNonlinearExpressionTreeInPostfix( int rowIdx);
03450
03458 std::vector<ExprNode*> getNonlinearExpressionTreeModInPostfix( int rowIdx);
03459
03466 std::vector<ExprNode*> getNonlinearExpressionTreeInPrefix( int rowIdx);
03467
03475 std::string getNonlinearExpressionTreeInInfix( int rowIdx);
03476
03477
03485 std::vector<ExprNode*> getNonlinearExpressionTreeModInPrefix( int rowIdx);
03486
03487
03491 int getNumberOfNonlinearObjectives();
03492
03496 int getNumberOfNonlinearConstraints();
03497
03503 std::map<int, ScalarExpressionTree* > getAllNonlinearExpressionTrees();
03504
03508 std::map<int, ScalarExpressionTree* > getAllNonlinearExpressionTreesMod();
03509
03516 int* getNonlinearExpressionTreeIndexes();
03517
03518
03524 int getNumberOfNonlinearExpressionTreeIndexes();
03525
03526
03534 int* getNonlinearExpressionTreeModIndexes();
03535
03542 int getNumberOfNonlinearExpressionTreeModIndexes();
03543
03549 int getMatrixNumber();
03550
03563 ENUM_MATRIX_TYPE getMatrixType(int n);
03564
03574 ENUM_MATRIX_SYMMETRY getMatrixSymmetry(int n);
03575
03583
03584
03592 int getNumberOfColumnsForMatrix(int n);
03593
03601 int getNumberOfRowsForMatrix(int n);
03602
03610 int getNumberOfValuesForMatrix(int n);
03611
03619 std::string getMatrixName(int n);
03620
03627 bool matrixHasBase(int n);
03628 bool matrixHasElements(int n);
03629 bool matrixHasTransformations(int n);
03630 bool matrixHasBlocks(int n);
03631 int getNumberOfElementConstructors(int n);
03632 int getNumberOfTransformationConstructors(int n);
03633 int getNumberOfBlocksConstructors(int n);
03634
03642 OSMatrix* getMatrix(int n);
03643
03651 GeneralSparseMatrix* getMatrixCoefficientsInColumnMajor(int n);
03652
03660 GeneralSparseMatrix* getMatrixCoefficientsInRowMajor(int n);
03661
03669
03670
03682 GeneralSparseMatrix* getMatrixBlockInColumnMajorForm(int n, int columnIdx, int rowIdx);
03683
03684
03685
03686
03687
03688
03689
03690
03691
03692
03693
03699 int getNumberOfMatrixVariables();
03700
03706 int getNumberOfMatrixObjectives();
03707
03713 int getNumberOfMatrixConstraints();
03714
03720 int getNumberOfMatrixExpressions();
03721
03727 MatrixExpression** getMatrixExpressions();
03728
03734 MatrixExpressionTree* getMatrixExpressionTree(int rowIdx);
03735
03742 std::vector<ExprNode*> getMatrixExpressionTreeInPostfix( int rowIdx);
03743
03751 std::vector<ExprNode*> getMatrixExpressionTreeModInPostfix( int rowIdx);
03752
03759 std::vector<ExprNode*> getMatrixExpressionTreeInPrefix( int rowIdx);
03760
03768 std::string getMatrixExpressionTreeInInfix( int rowIdx);
03769
03770
03774 std::map<int, MatrixExpressionTree* > getAllMatrixExpressionTrees();
03775
03776
03780 std::map<int, MatrixExpressionTree* > getAllMatrixExpressionTreesMod();
03781
03788 int* getMatrixExpressionTreeIndexes();
03789
03790
03796 int getNumberOfMatrixExpressionTreeIndexes();
03797
03798
03799
03805 std::string getTimeDomainFormat();
03806
03812 int getTimeDomainStageNumber();
03813
03819 std::string* getTimeDomainStageNames();
03820
03826 int* getTimeDomainStageNumberOfVariables();
03827
03828
03834 int* getTimeDomainStageNumberOfConstraints();
03835
03841 int* getTimeDomainStageNumberOfObjectives();
03842
03848 int** getTimeDomainStageVarList();
03849
03855 int** getTimeDomainStageConList();
03856
03862 int** getTimeDomainStageObjList();
03863
03869 double getTimeDomainIntervalStart();
03870
03876 double getTimeDomainIntervalHorizon();
03877
03878
03879
03880
03881
03882
03889 bool setInstanceName(std::string name);
03890
03897 bool setInstanceSource(std::string source);
03898
03905 bool setInstanceDescription(std::string description);
03906
03913 bool setInstanceCreator(std::string fileCreator);
03914
03921 bool setInstanceLicence(std::string licence);
03922
03923
03930 bool setVariableNumber(int number);
03931
03947 bool addVariable(int index, std::string name, double lowerBound, double upperBound, char type);
03948
03968 bool setVariables(int number, std::string* names, double* lowerBounds,
03969 double* upperBounds, char* types);
03970
03971
03978 bool setObjectiveNumber(int number);
03979
03997 bool addObjective(int index, std::string name, std::string maxOrMin, double constant, double weight, SparseVector* objectiveCoefficients);
03998
04014 bool setObjectives(int number, std::string *names, std::string *maxOrMins, double *constants, double *weights, SparseVector **objectitiveCoefficients);
04015
04022 bool setConstraintNumber(int number);
04023
04037 bool addConstraint(int index, std::string name, double lowerBound, double upperBound, double constant);
04038
04052 bool setConstraints(int number, std::string* names, double* lowerBounds, double* upperBounds, double* constants);
04053
04072 bool setLinearConstraintCoefficients(int numberOfValues, bool isColumnMajor,
04073 double* values, int valuesBegin, int valuesEnd,
04074 int* indexes, int indexesBegin, int indexesEnd,
04075 int* starts, int startsBegin, int startsEnd);
04076
04095 bool copyLinearConstraintCoefficients(int numberOfValues, bool isColumnMajor,
04096 double* values, int valuesBegin, int valuesEnd,
04097 int* indexes, int indexesBegin, int indexesEnd,
04098 int* starts, int startsBegin, int startsEnd);
04099
04108 bool setNumberOfQuadraticTerms(int nq);
04109
04126 bool setQuadraticCoefficients(int number,
04127 int* rowIndexes, int* varOneIndexes, int* varTwoIndexes,
04128 double* coefficients, int begin, int end);
04129
04130
04144 bool setQuadraticTermsInNonlinearExpressions(int number,
04145 int* rowIndexes, int* varOneIndexes, int* varTwoIndexes, double* coefficients);
04146
04156 bool setNonlinearExpressions(int nexpr, Nl** root);
04157
04164 bool setMatrixNumber(int number);
04165
04188 bool addMatrix(int index, std::string name, int numberOfRows, int numberOfColumns,
04189 ENUM_MATRIX_SYMMETRY symmetry, ENUM_MATRIX_TYPE matrixType,
04190 unsigned int inumberOfChildren, MatrixNode **m_mChildren);
04191
04192
04199 bool setConeNumber(int number);
04200
04227 bool addCone(int index, int numberOfRows, int numberOfColumns, ENUM_CONE_TYPE coneType,
04228 std::string name, int numberOfOtherIndexes = 0, int* otherIndexes = NULL);
04229
04256 bool addCone(int index, int numberOfRows, int numberOfColumns, ENUM_CONE_TYPE coneType,
04257 std::string name, int numberOfComponents, int* components,
04258 int numberOfOtherIndexes = 0, int* otherIndexes = NULL);
04259
04286 bool addCone(int index, int numberOfRows, int numberOfColumns, ENUM_CONE_TYPE coneType,
04287 std::string name, int referenceIdx, int numberOfOtherIndexes = 0, int* otherIndexes = NULL);
04288
04314 bool addCone(int index, int numberOfRows, int numberOfColumns, ENUM_CONE_TYPE coneType,
04315 std::string name, std::string semidefiniteness, int numberOfOtherIndexes = 0, int* otherIndexes = NULL);
04316
04343 bool addCone(int index, int numberOfRows, int numberOfColumns, ENUM_CONE_TYPE coneType,
04344 std::string name, int distortionMatrixIdx, double normFactor, int axisDirection,
04345 int numberOfOtherIndexes = 0, int* otherIndexes = NULL);
04346
04374 bool addCone(int index, int numberOfRows, int numberOfColumns, ENUM_CONE_TYPE coneType,
04375 std::string name, int distortionMatrixIdx, double normFactor, int firstAxisDirection,
04376 int secondAxisDirection, int numberOfOtherIndexes = 0, int* otherIndexes = NULL);
04377
04404 bool addCone(int index, int numberOfRows, int numberOfColumns, ENUM_CONE_TYPE coneType,
04405 std::string name, int distortionMatrixIdx, double normFactor, int axisDirection, double pNorm,
04406 int numberOfOtherIndexes = 0, int* otherIndexes = NULL);
04407
04438 bool addCone(int index, int numberOfRows, int numberOfColumns, ENUM_CONE_TYPE coneType,
04439 std::string name, int maxDegree, int numberOfUB, double* ub, int numberOfLB, double* lb,
04440 int numberOfOtherIndexes = 0, int* otherIndexes = NULL);
04441
04442
04443
04444
04449 std::string printModel( );
04450
04458 std::string printModel( int rowIdx);
04459
04460
04461
04462
04463
04464
04470 bool initializeNonLinearStructures( );
04471
04485 double calculateFunctionValue(int idx, double* x, bool new_x);
04486
04501 double *calculateAllConstraintFunctionValues(double* x, double *objLambda, double *conLambda,
04502 bool new_x, int highestOrder);
04503
04517 double *calculateAllConstraintFunctionValues(double* x, bool new_x);
04518
04534 double *calculateAllObjectiveFunctionValues(double* x, double *objLambda, double *conLambda,
04535 bool new_x, int highestOrder);
04536
04550 double *calculateAllObjectiveFunctionValues(double* x, bool new_x);
04551
04552
04567 SparseJacobianMatrix *calculateAllConstraintFunctionGradients(double* x, double *objLambda,
04568 double *conLambda, bool new_x, int highestOrder);
04569
04570
04586 SparseVector *calculateConstraintFunctionGradient(double* x, double *objLambda, double *conLambda,
04587 int idx, bool new_x, int highestOrder);
04588
04602 SparseVector *calculateConstraintFunctionGradient(double* x, int idx, bool new_x );
04603
04618 double **calculateAllObjectiveFunctionGradients(double* x, double *objLambda, double *conLambda,
04619 bool new_x, int highestOrder);
04620
04636 double *calculateObjectiveFunctionGradient(double* x, double *objLambda, double *conLambda,
04637 int objIdx, bool new_x, int highestOrder);
04638
04652 double *calculateObjectiveFunctionGradient(double* x, int objIdx, bool new_x );
04653
04671 SparseHessianMatrix *calculateLagrangianHessian( double* x, double *objLambda, double *conLambda,
04672 bool new_x, int highestOrder);
04673
04686 SparseHessianMatrix *calculateHessian( double* x, int idx, bool new_x);
04687
04688
04693 bool getSparseJacobianFromColumnMajor();
04694
04699 bool getSparseJacobianFromRowMajor();
04700
04705 ScalarExpressionTree* getLagrangianExpTree( );
04706
04711 std::map<int, int> getAllNonlinearVariablesIndexMap( );
04712
04717 SparseHessianMatrix* getLagrangianHessianSparsityPattern();
04718
04725 bool addQTermsToExressionTree();
04726
04733 bool addQTermsToExpressionTree();
04734
04739 SparseJacobianMatrix *getJacobianSparsityPattern();
04740
04745 void duplicateExpressionTreesMap();
04746
04747 #ifdef OS_HAS_CPPAD
04748
04752 CppAD::ADFun<double> *Fad;
04753 #endif
04754
04765 bool createOSADFun(std::vector<double> vdX );
04766
04777 std::vector<double> forwardAD(int p, std::vector<double> vdX);
04778
04789 std::vector<double> reverseAD(int p, std::vector<double> vdlambda);
04790
04803 int getADSparsityHessian();
04804
04824 bool getIterateResults(double *x, double *objLambda, double *conLambda,
04825 bool new_x, int highestOrder);
04826
04827
04828
04841 bool getZeroOrderResults(double *x, double *objLambda, double *conLambda);
04842
04855 bool getFirstOrderResults(double *x, double *objLambda, double *conLambda );
04856
04869 bool getSecondOrderResults(double *x, double *objLambda, double *conLambda );
04870
04871
04881 bool initForAlgDiff();
04882
04892 bool initObjGradients();
04893
04894
04899 bool bUseExpTreeForFunEval;
04900
04901
04905 bool setTimeDomain(std::string format);
04906
04910 bool setTimeDomainStages(int number, std::string *names);
04911
04918 bool setTimeDomainStageVariablesOrdered(int numberOfStages, int *numberOfVariables, int *startIdx);
04919
04926 bool setTimeDomainStageVariablesUnordered(int numberOfStages, int *numberOfVariables, int **varIndex);
04927
04933 bool setTimeDomainStageConstraintsOrdered(int numberOfStages, int *numberOfConstraints, int *startIdx);
04934
04940 bool setTimeDomainStageConstraintsUnordered(int numberOfStages, int *numberOfConstraints, int **conIndex);
04941
04947 bool setTimeDomainStageObjectivesOrdered(int numberOfStages, int *numberOfObjectives, int *startIdx);
04948
04954 bool setTimeDomainStageObjectivesUnordered(int numberOfStages, int *numberOfObjectives, int **varIndex);
04955
04959 bool setTimeDomainInterval(double start, double horizon);
04960
04961
04962 };
04963
04964 #endif
04965