00001
00018 #ifndef OSGENERAL_H
00019 #define OSGENERAL_H
00020
00021
00022 #ifdef HAVE_CSTDLIB
00023 # include <cstdlib>
00024 #else
00025 # ifdef HAVE_STDLIB_H
00026 # include <stdlib.h>
00027 # endif
00028 #endif
00029
00030 #include "OSConfig.h"
00031
00032 #include <string>
00033 #include <vector>
00034
00035
00036
00040 class SparseMatrix {
00041 public:
00042
00047 bool bDeleteArrays;
00048
00053 bool isColumnMajor;
00054
00058 int startSize;
00059
00063 int valueSize;
00064
00069 int* starts;
00070
00075 int* indexes;
00076
00081 double* values;
00082
00087 SparseMatrix();
00088
00097 SparseMatrix(bool isColumnMajor_, int startSize, int valueSize);
00102 ~SparseMatrix();
00103
00109 bool display(int secondaryDim);
00110
00111 };
00112
00113
00117 class SparseVector{
00118 public:
00119
00125 SparseVector(int number);
00126
00131 SparseVector();
00132
00137 ~SparseVector();
00138
00143 bool bDeleteArrays;
00144
00148 int number;
00149
00153 int* indexes;
00154
00158 double* values;
00159
00160 };
00161
00162
00166 class SparseJacobianMatrix {
00167 public:
00168
00173 bool bDeleteArrays;
00174
00178 int startSize;
00179
00183 int valueSize;
00184
00189 int* starts;
00190
00195 int* conVals;
00196
00200 int* indexes;
00201
00205 double* values;
00206
00211 SparseJacobianMatrix();
00212
00219 SparseJacobianMatrix(int startSize, int valueSize);
00220
00225 ~SparseJacobianMatrix();
00226
00227 };
00228
00229
00230
00231
00232
00243 class SparseHessianMatrix {
00244 public:
00245
00250 bool bDeleteArrays;
00251
00255 int hessDimension;
00256
00260 int* hessRowIdx;
00261
00265 int* hessColIdx;
00266
00270 double* hessValues;
00271
00276 SparseHessianMatrix();
00277
00284 SparseHessianMatrix(int startSize, int valueSize);
00285
00290 ~SparseHessianMatrix();
00291
00292 };
00293
00297 class QuadraticTerms {
00298
00299 public:
00300
00305 int* rowIndexes;
00306
00310 int* varOneIndexes;
00311
00315 int* varTwoIndexes;
00316
00320 double* coefficients;
00321
00326 QuadraticTerms();
00327 ~QuadraticTerms();
00328 };
00329
00330
00331
00335 class IntVector{
00336 public:
00337 IntVector();
00338 ~IntVector();
00339
00340
00341 IntVector(int n);
00342
00347 bool bDeleteArrays;
00348 int numberOfEl;
00349 int *el;
00350
00351 bool IsEqual(IntVector *that);
00352 };
00353
00354
00360 class OtherOptionEnumeration : public IntVector{
00361 public:
00362 std::string value;
00363 std::string description;
00364
00365 OtherOptionEnumeration();
00366 ~OtherOptionEnumeration();
00367
00368
00369 OtherOptionEnumeration(int n);
00370
00371 bool IsEqual(OtherOptionEnumeration *that);
00372
00380 bool setOtherOptionEnumeration(std::string value, std::string description, int *i, int ni);
00381 };
00382
00383
00384
00388 class DoubleVector{
00389 public:
00390 DoubleVector();
00391 ~DoubleVector();
00396 bool bDeleteArrays;
00397 int numberOfEl;
00398 double *el;
00399
00400 bool IsEqual(DoubleVector *that);
00401 };
00402
00403
00407 struct IndexValuePair{
00411 int idx;
00412
00415 double value;
00416
00417 };
00418
00423 class BasisStatus{
00424 public:
00425 BasisStatus();
00426 ~BasisStatus();
00427
00428 IntVector* basic;
00429 IntVector* atLower;
00430 IntVector* atUpper;
00431 IntVector* isFree;
00432 IntVector* superbasic;
00433 IntVector* unknown;
00434 bool IsEqual(BasisStatus *that);
00435
00443 bool setBasisStatusIntVector(int status, int *i, int ni);
00444
00445 };
00446
00447 class OSGeneral{
00448
00449 };
00450
00451
00452
00453
00454
00455
00456
00457
00458
00459
00460
00461 enum ENUM_CPUSPEEDUNIT
00462 {
00463 ENUM_CPUSPEEDUNIT_hertz = 1,
00464 ENUM_CPUSPEEDUNIT_kilohertz,
00465 ENUM_CPUSPEEDUNIT_megahertz,
00466 ENUM_CPUSPEEDUNIT_gigahertz,
00467 ENUM_CPUSPEEDUNIT_terahertz,
00468 ENUM_CPUSPEEDUNIT_flops,
00469 ENUM_CPUSPEEDUNIT_kiloflops,
00470 ENUM_CPUSPEEDUNIT_megaflops,
00471 ENUM_CPUSPEEDUNIT_gigaflops,
00472 ENUM_CPUSPEEDUNIT_teraflops,
00473 ENUM_CPUSPEEDUNIT_petaflops
00474 };
00475
00476 inline int returnCPUSpeedUnit(std::string unit)
00477 {
00478 if (unit == "hertz" ) return ENUM_CPUSPEEDUNIT_hertz;
00479 if (unit == "kilohertz") return ENUM_CPUSPEEDUNIT_kilohertz;
00480 if (unit == "megahertz") return ENUM_CPUSPEEDUNIT_megahertz;
00481 if (unit == "gigahertz") return ENUM_CPUSPEEDUNIT_gigahertz;
00482 if (unit == "terahertz") return ENUM_CPUSPEEDUNIT_terahertz;
00483 if (unit == "flops" ) return ENUM_CPUSPEEDUNIT_flops;
00484 if (unit == "kiloflops") return ENUM_CPUSPEEDUNIT_kiloflops;
00485 if (unit == "megaflops") return ENUM_CPUSPEEDUNIT_megaflops;
00486 if (unit == "gigaflops") return ENUM_CPUSPEEDUNIT_gigaflops;
00487 if (unit == "teraflops") return ENUM_CPUSPEEDUNIT_teraflops;
00488 if (unit == "petaflops") return ENUM_CPUSPEEDUNIT_petaflops;
00489 return 0;
00490 }
00491
00492 inline bool verifyCPUSpeedUnit(std::string unit)
00493 {
00494 return (returnCPUSpeedUnit(unit) > 0);
00495 }
00496
00497 enum ENUM_STORAGEUNIT
00498 {
00499 ENUM_STORAGEUNIT_byte = 1,
00500 ENUM_STORAGEUNIT_kilobyte,
00501 ENUM_STORAGEUNIT_megabyte,
00502 ENUM_STORAGEUNIT_gigabyte,
00503 ENUM_STORAGEUNIT_terabyte,
00504 ENUM_STORAGEUNIT_petabyte,
00505 ENUM_STORAGEUNIT_exabyte,
00506 ENUM_STORAGEUNIT_zettabyte,
00507 ENUM_STORAGEUNIT_yottabyte
00508 };
00509
00510 inline int returnStorageUnit(std::string unit)
00511 {
00512 if (unit == "byte" ) return ENUM_STORAGEUNIT_byte;
00513 if (unit == "kilobyte" ) return ENUM_STORAGEUNIT_kilobyte;
00514 if (unit == "megabyte" ) return ENUM_STORAGEUNIT_megabyte;
00515 if (unit == "gigabyte" ) return ENUM_STORAGEUNIT_gigabyte;
00516 if (unit == "terabyte" ) return ENUM_STORAGEUNIT_terabyte;
00517 if (unit == "petabyte" ) return ENUM_STORAGEUNIT_petabyte;
00518 if (unit == "exabyte" ) return ENUM_STORAGEUNIT_exabyte;
00519 if (unit == "zettabyte") return ENUM_STORAGEUNIT_zettabyte;
00520 if (unit == "yottabyte") return ENUM_STORAGEUNIT_yottabyte;
00521 return 0;
00522 }
00523
00524 inline bool verifyStorageUnit(std::string unit)
00525 {
00526 return (returnStorageUnit(unit) > 0);
00527 }
00528
00529 enum ENUM_TIMEUNIT
00530 {
00531 ENUM_TIMEUNIT_tick = 1,
00532 ENUM_TIMEUNIT_millisecond,
00533 ENUM_TIMEUNIT_second,
00534 ENUM_TIMEUNIT_minute,
00535 ENUM_TIMEUNIT_hour,
00536 ENUM_TIMEUNIT_day,
00537 ENUM_TIMEUNIT_week,
00538 ENUM_TIMEUNIT_month,
00539 ENUM_TIMEUNIT_year
00540 };
00541
00542 inline int returnTimeUnit(std::string unit)
00543 {
00544 if (unit == "tick" ) return ENUM_TIMEUNIT_tick;
00545 if (unit == "millisecond") return ENUM_TIMEUNIT_millisecond;
00546 if (unit == "second" ) return ENUM_TIMEUNIT_second;
00547 if (unit == "minute" ) return ENUM_TIMEUNIT_minute;
00548 if (unit == "hour" ) return ENUM_TIMEUNIT_hour;
00549 if (unit == "day" ) return ENUM_TIMEUNIT_day;
00550 if (unit == "week" ) return ENUM_TIMEUNIT_week;
00551 if (unit == "month" ) return ENUM_TIMEUNIT_month;
00552 if (unit == "year" ) return ENUM_TIMEUNIT_year;
00553 return 0;
00554 }
00555
00556 inline bool verifyTimeUnit(std::string unit)
00557 {
00558 return (returnTimeUnit(unit) > 0);
00559 }
00560
00561 enum ENUM_TIMETYPE
00562 {
00563 ENUM_TIMETYPE_cpuTime = 1,
00564 ENUM_TIMETYPE_elapsedTime,
00565 ENUM_TIMETYPE_other
00566 };
00567
00568 inline int returnTimeType(std::string type)
00569 {
00570 if (type == "cpuTime" ) return ENUM_TIMETYPE_cpuTime;
00571 if (type == "elapsedTime") return ENUM_TIMETYPE_elapsedTime;
00572 if (type == "other" ) return ENUM_TIMETYPE_other;
00573 return 0;
00574 }
00575
00576 inline bool verifyTimeType(std::string type)
00577 {
00578 return (returnTimeType(type) > 0);
00579 }
00580
00581 enum ENUM_TIMECATEGORY
00582 {
00583 ENUM_TIMECATEGORY_total = 1,
00584 ENUM_TIMECATEGORY_input,
00585 ENUM_TIMECATEGORY_preprocessing,
00586 ENUM_TIMECATEGORY_optimization,
00587 ENUM_TIMECATEGORY_postprocessing,
00588 ENUM_TIMECATEGORY_output,
00589 ENUM_TIMECATEGORY_other
00590 };
00591
00592 inline int returnTimeCategory(std::string category)
00593 {
00594 if (category == "total" ) return ENUM_TIMECATEGORY_total;
00595 if (category == "input" ) return ENUM_TIMECATEGORY_input;
00596 if (category == "preprocessing" ) return ENUM_TIMECATEGORY_preprocessing;
00597 if (category == "optimization" ) return ENUM_TIMECATEGORY_optimization;
00598 if (category == "postprocessing") return ENUM_TIMECATEGORY_postprocessing;
00599 if (category == "output" ) return ENUM_TIMECATEGORY_output;
00600 if (category == "other" ) return ENUM_TIMECATEGORY_other;
00601 return 0;
00602 }
00603
00604 inline bool verifyTimeCategory(std::string category)
00605 {
00606 return (returnTimeCategory(category) > 0);
00607 }
00608
00609 enum ENUM_LOCATIONTYPE
00610 {
00611 ENUM_LOCATIONTYPE_local = 1,
00612 ENUM_LOCATIONTYPE_http,
00613 ENUM_LOCATIONTYPE_ftp
00614 };
00615
00616 inline int returnLocationType(std::string type)
00617 {
00618 if (type == "local") return ENUM_LOCATIONTYPE_local;
00619 if (type == "http" ) return ENUM_LOCATIONTYPE_http;
00620 if (type == "ftp" ) return ENUM_LOCATIONTYPE_ftp;
00621 return 0;
00622 }
00623
00624 inline bool verifyLocationType(std::string type)
00625 {
00626 return (returnLocationType(type) > 0);
00627 }
00628
00629 enum ENUM_TRANSPORT_TYPE
00630 {
00631 ENUM_TRANSPORT_TYPE_osp = 1,
00632 ENUM_TRANSPORT_TYPE_http,
00633 ENUM_TRANSPORT_TYPE_smtp,
00634 ENUM_TRANSPORT_TYPE_ftp,
00635 ENUM_TRANSPORT_TYPE_other
00636 };
00637
00638 inline int returnTransportType(std::string type)
00639 {
00640 if (type == "osp" ) return ENUM_TRANSPORT_TYPE_osp;
00641 if (type == "http" ) return ENUM_TRANSPORT_TYPE_http;
00642 if (type == "smtp" ) return ENUM_TRANSPORT_TYPE_smtp;
00643 if (type == "ftp" ) return ENUM_TRANSPORT_TYPE_ftp;
00644 if (type == "other") return ENUM_TRANSPORT_TYPE_other;
00645 return 0;
00646 }
00647
00648 inline bool verifyTransportType(std::string type)
00649 {
00650 return (returnTransportType(type) > 0);
00651 }
00652
00653 enum ENUM_SERVICE_TYPE
00654 {
00655 ENUM_SERVICE_TYPE_analyzer = 1,
00656 ENUM_SERVICE_TYPE_solver,
00657 ENUM_SERVICE_TYPE_scheduler,
00658 ENUM_SERVICE_TYPE_modeler,
00659 ENUM_SERVICE_TYPE_registry,
00660 ENUM_SERVICE_TYPE_agent,
00661 ENUM_SERVICE_TYPE_simulations
00662 };
00663
00664 inline int returnServiceType(std::string type)
00665 {
00666 if (type == "analyzer" ) return ENUM_SERVICE_TYPE_analyzer;
00667 if (type == "solver" ) return ENUM_SERVICE_TYPE_solver;
00668 if (type == "scheduler" ) return ENUM_SERVICE_TYPE_scheduler;
00669 if (type == "modeler" ) return ENUM_SERVICE_TYPE_modeler;
00670 if (type == "registry" ) return ENUM_SERVICE_TYPE_registry;
00671 if (type == "agent" ) return ENUM_SERVICE_TYPE_agent;
00672 if (type == "simulations") return ENUM_SERVICE_TYPE_simulations;
00673 return 0;
00674 }
00675
00676 inline bool verifyServiceType(std::string type)
00677 {
00678 return (returnServiceType(type) > 0);
00679 }
00680
00681 enum ENUM_GENERAL_RESULT_STATUS
00682 {
00683 ENUM_GENERAL_RESULT_STATUS_error = 1,
00684 ENUM_GENERAL_RESULT_STATUS_warning,
00685 ENUM_GENERAL_RESULT_STATUS_normal
00686 };
00687
00688 inline int returnGeneralResultStatus(std::string status)
00689 {
00690 if (status == "error" ) return ENUM_GENERAL_RESULT_STATUS_error;
00691 if (status == "warning") return ENUM_GENERAL_RESULT_STATUS_warning;
00692 if (status == "normal" ) return ENUM_GENERAL_RESULT_STATUS_normal;
00693 return 0;
00694 }
00695
00696 inline bool verifyGeneralResultStatus(std::string status)
00697 {
00698 return (returnGeneralResultStatus(status) > 0);
00699 }
00700
00701 enum ENUM_SYSTEM_CURRENT_STATE
00702 {
00703 ENUM_SYSTEM_CURRENT_STATE_busy = 1,
00704 ENUM_SYSTEM_CURRENT_STATE_busyButAccepting,
00705 ENUM_SYSTEM_CURRENT_STATE_idle,
00706 ENUM_SYSTEM_CURRENT_STATE_idleButNotAccepting,
00707 ENUM_SYSTEM_CURRENT_STATE_noResponse
00708 };
00709
00710 inline int returnSystemCurrentState(std::string status)
00711 {
00712 if (status == "busy" ) return ENUM_SYSTEM_CURRENT_STATE_busy;
00713 if (status == "busyButAccepting" ) return ENUM_SYSTEM_CURRENT_STATE_busyButAccepting;
00714 if (status == "idle" ) return ENUM_SYSTEM_CURRENT_STATE_idle;
00715 if (status == "idleButNotAccepting") return ENUM_SYSTEM_CURRENT_STATE_idleButNotAccepting;
00716 if (status == "noResponse" ) return ENUM_SYSTEM_CURRENT_STATE_noResponse;
00717 return 0;
00718 }
00719
00720 inline bool verifySystemCurrentState(std::string status)
00721 {
00722 return (returnSystemCurrentState(status) > 0);
00723 }
00724
00725 enum ENUM_JOB_STATUS
00726 {
00727 ENUM_JOB_STATUS_waiting = 1,
00728 ENUM_JOB_STATUS_running,
00729 ENUM_JOB_STATUS_killed,
00730 ENUM_JOB_STATUS_finished,
00731 ENUM_JOB_STATUS_unknown
00732 };
00733
00734 inline int returnJobStatus(std::string status)
00735 {
00736 if (status == "waiting" ) return ENUM_JOB_STATUS_waiting;
00737 if (status == "running" ) return ENUM_JOB_STATUS_running;
00738 if (status == "killed" ) return ENUM_JOB_STATUS_killed;
00739 if (status == "finished") return ENUM_JOB_STATUS_finished;
00740 if (status == "unknown" ) return ENUM_JOB_STATUS_unknown;
00741 return 0;
00742 }
00743
00744 inline bool verifyJobStatus(std::string status)
00745 {
00746 return (returnJobStatus(status) > 0);
00747 }
00748
00749
00750 enum ENUM_BASIS_STATUS
00751 {
00752 ENUM_BASIS_STATUS_basic = 1,
00753 ENUM_BASIS_STATUS_atLower,
00754 ENUM_BASIS_STATUS_atUpper,
00755 ENUM_BASIS_STATUS_isFree,
00756 ENUM_BASIS_STATUS_superbasic,
00757 ENUM_BASIS_STATUS_unknown
00758 };
00759
00760 inline int returnBasisStatus(std::string status)
00761 {
00762 if (status == "basic" ) return ENUM_BASIS_STATUS_basic;
00763 if (status == "atLower" ) return ENUM_BASIS_STATUS_atLower;
00764 if (status == "atUpper" ) return ENUM_BASIS_STATUS_atUpper;
00765 if (status == "isFree" ) return ENUM_BASIS_STATUS_isFree;
00766 if (status == "superBasic") return ENUM_BASIS_STATUS_superbasic;
00767 if (status == "unknown" ) return ENUM_BASIS_STATUS_unknown;
00768 return 0;
00769 }
00770
00771 inline bool verifyBasisStatus(std::string status)
00772 {
00773 return (returnBasisStatus(status) > 0);
00774 }
00775
00776 enum ENUM_SOLUTION_STATUS
00777 {
00778 ENUM_SOLUTION_STATUS_unbounded = 1,
00779 ENUM_SOLUTION_STATUS_globallyOptimal,
00780 ENUM_SOLUTION_STATUS_locallyOptimal,
00781 ENUM_SOLUTION_STATUS_optimal,
00782 ENUM_SOLUTION_STATUS_bestSoFar,
00783 ENUM_SOLUTION_STATUS_feasible,
00784 ENUM_SOLUTION_STATUS_infeasible,
00785 ENUM_SOLUTION_STATUS_unsure,
00786 ENUM_SOLUTION_STATUS_error,
00787 ENUM_SOLUTION_STATUS_other
00788 };
00789
00790 inline int returnSolutionStatus(std::string status)
00791 {
00792 if (status == "unbounded" ) return ENUM_SOLUTION_STATUS_unbounded;
00793 if (status == "globallyOptimal") return ENUM_SOLUTION_STATUS_globallyOptimal;
00794 if (status == "locallyOptimal" ) return ENUM_SOLUTION_STATUS_locallyOptimal;
00795 if (status == "optimal" ) return ENUM_SOLUTION_STATUS_optimal;
00796 if (status == "bestSoFar" ) return ENUM_SOLUTION_STATUS_bestSoFar;
00797 if (status == "feasible" ) return ENUM_SOLUTION_STATUS_feasible;
00798 if (status == "infeasible" ) return ENUM_SOLUTION_STATUS_infeasible;
00799 if (status == "unsure" ) return ENUM_SOLUTION_STATUS_unsure;
00800 if (status == "error" ) return ENUM_SOLUTION_STATUS_error;
00801 if (status == "other" ) return ENUM_SOLUTION_STATUS_other;
00802 return 0;
00803 }
00804
00805 inline bool verifySolutionStatus(std::string status)
00806 {
00807 return (returnSolutionStatus(status) > 0);
00808 }
00809
00810 enum ENUM_SOLUTION_SUBSTATUSTYPE
00811 {
00812 ENUM_SOLUTION_SUBSTATUSTYPE_stoppedByLimit = 1,
00813 ENUM_SOLUTION_SUBSTATUSTYPE_stoppedByBounds,
00814 ENUM_SOLUTION_SUBSTATUSTYPE_other
00815 };
00816
00817 inline int returnSolutionSubstatusType(std::string type)
00818 {
00819 if (type == "stoppedByLimit" ) return ENUM_SOLUTION_SUBSTATUSTYPE_stoppedByLimit;
00820 if (type == "stoppedByBounds") return ENUM_SOLUTION_SUBSTATUSTYPE_stoppedByBounds;
00821 if (type == "other" ) return ENUM_SOLUTION_SUBSTATUSTYPE_other;
00822 return 0;
00823 }
00824
00825 inline bool verifySolutionSubstatusType(std::string type)
00826 {
00827 return (returnSolutionSubstatusType(type) > 0);
00828 }
00829
00830 enum ENUM_VARTYPE
00831 {
00832 ENUM_VARTYPE_CONTINUOUS = 1,
00833 ENUM_VARTYPE_INTEGER,
00834 ENUM_VARTYPE_BINARY,
00835 ENUM_VARTYPE_SEMICONTINUOUS,
00836 ENUM_VARTYPE_SEMIINTEGER,
00837 ENUM_VARTYPE_STRING
00838 };
00839
00840 inline int returnVarType(char vt)
00841 {
00842 if (vt == 'C') return ENUM_VARTYPE_CONTINUOUS;
00843 if (vt == 'B') return ENUM_VARTYPE_BINARY;
00844 if (vt == 'I') return ENUM_VARTYPE_INTEGER;
00845 if (vt == 'S') return ENUM_VARTYPE_STRING;
00846 if (vt == 'D') return ENUM_VARTYPE_SEMICONTINUOUS;
00847 if (vt == 'J') return ENUM_VARTYPE_SEMIINTEGER;
00848 return 0;
00849 }
00850
00851 inline bool verifyVarType(char vt)
00852 {
00853 return (returnVarType(vt) > 0);
00854 }
00855
00856 #endif