Main Page | Class Hierarchy | Alphabetical List | Class List | File List | Class Members

Clp_C_Interface.cpp

00001 // Copyright (C) 2003, International Business Machines
00002 // Corporation and others.  All Rights Reserved.
00003 
00004 
00005 
00006 
00007 #include "CoinPragma.hpp"
00008 
00009 #include <math.h>
00010 
00011 #include "CoinHelperFunctions.hpp"
00012 #include "ClpSimplex.hpp"
00013 #include <cfloat>
00014 // This sections needs to match Clp_C_defines.h but with extern C
00015 #define ClpSimplexCDefine_H
00016 
00021 /* Plus infinity */
00022 #ifndef COIN_DBL_MAX
00023 #define COIN_DBL_MAX DBL_MAX
00024 #endif
00025 
00026 /* We need to allow for Microsoft */
00027 #ifndef CLPLIBAPI
00028 
00029 #if defined (CLPMSDLL)
00030 #   define CLPLIBAPI __declspec(dllexport) extern "C"
00031 #   define CLPLINKAGE  __stdcall
00032 #   define CLPLINKAGE_CB  __cdecl
00033 #else
00034 #   define CLPLIBAPI extern "C"
00035 #   define CLPLINKAGE
00036 #   define CLPLINKAGE_CB 
00037 #endif
00038 
00039 #endif
00040 class CMessageHandler;
00041 // Real typedef for structure
00042 typedef struct {
00043   ClpSimplex * model_;
00044   CMessageHandler * handler_;
00045 } Clp_Simplex;
00047 typedef  void (CLPLINKAGE_CB *clp_callback) (Clp_Simplex * model,int  msgno, int ndouble,
00048                             const double * dvec, int nint, const int * ivec,
00049                             int nchar,  char ** cvec);
00050 
00051 // To allow call backs
00052 class CMessageHandler : public CoinMessageHandler {
00053   
00054 public:
00057   virtual int print();
00059 
00061 
00062   const Clp_Simplex * model() const;
00063   void setModel(Clp_Simplex * model);
00065   void setCallBack(clp_callback callback);
00067 
00071   CMessageHandler();
00073   CMessageHandler(Clp_Simplex * model,
00074                            FILE * userPointer=NULL);
00076   virtual ~CMessageHandler();
00078 
00082   CMessageHandler(const CMessageHandler&);
00084   CMessageHandler(const CoinMessageHandler&);
00085   
00086   CMessageHandler& operator=(const CMessageHandler&);
00088   virtual CoinMessageHandler * clone() const ;
00090    
00091     
00092 protected:
00096 
00097   Clp_Simplex * model_;
00099   clp_callback callback_;
00101 };
00102 
00103 
00104 //-------------------------------------------------------------------
00105 // Default Constructor 
00106 //-------------------------------------------------------------------
00107 CMessageHandler::CMessageHandler () 
00108   : CoinMessageHandler(),
00109     model_(NULL),
00110     callback_(NULL)
00111 {
00112 }
00113 
00114 //-------------------------------------------------------------------
00115 // Copy constructor 
00116 //-------------------------------------------------------------------
00117 CMessageHandler::CMessageHandler (const CMessageHandler & rhs) 
00118 : CoinMessageHandler(rhs),
00119     model_(rhs.model_),
00120     callback_(rhs.callback_)
00121 {  
00122 }
00123 
00124 CMessageHandler::CMessageHandler (const CoinMessageHandler & rhs) 
00125   : CoinMessageHandler(),
00126     model_(NULL),
00127     callback_(NULL)
00128 {  
00129 }
00130 
00131 // Constructor with pointer to model
00132 CMessageHandler::CMessageHandler(Clp_Simplex * model,
00133                FILE * userPointer)
00134   : CoinMessageHandler(),
00135     model_(model),
00136     callback_(NULL)
00137 {
00138 }
00139 
00140 //-------------------------------------------------------------------
00141 // Destructor 
00142 //-------------------------------------------------------------------
00143 CMessageHandler::~CMessageHandler ()
00144 {
00145 }
00146 
00147 //----------------------------------------------------------------
00148 // Assignment operator 
00149 //-------------------------------------------------------------------
00150 CMessageHandler &
00151 CMessageHandler::operator=(const CMessageHandler& rhs)
00152 {
00153   if (this != &rhs) {
00154     CoinMessageHandler::operator=(rhs);
00155     model_ = rhs.model_;
00156     callback_ = rhs.callback_;
00157   }
00158   return *this;
00159 }
00160 //-------------------------------------------------------------------
00161 // Clone
00162 //-------------------------------------------------------------------
00163 CoinMessageHandler * CMessageHandler::clone() const
00164 {
00165   return new CMessageHandler(*this);
00166 }
00167 
00168 int 
00169 CMessageHandler::print()
00170 {
00171   if (callback_) {
00172     int messageNumber = currentMessage().externalNumber();
00173     if (currentSource()!="Clp")
00174       messageNumber += 1000000;
00175     int i;
00176     int nDouble=numberDoubleFields();
00177     assert (nDouble<=10);
00178     double vDouble[10];
00179     for (i=0;i<nDouble;i++)
00180       vDouble[i]=doubleValue(i);
00181     int nInt=numberIntFields();
00182     assert (nInt<=10);
00183     int vInt[10];
00184     for (i=0;i<nInt;i++)
00185       vInt[i]=intValue(i);
00186     int nString=numberStringFields();
00187     assert (nString<=10);
00188     char * vString[10];
00189     for (i=0;i<nString;i++) {
00190       std::string value = stringValue(i);
00191       vString[i]=strdup(value.c_str());
00192     }
00193     callback_(model_,messageNumber,
00194               nDouble,vDouble,
00195               nInt,vInt,
00196               nString,vString);
00197     for (i=0;i<nString;i++) 
00198       free(vString[i]);
00199     
00200   }
00201   return CoinMessageHandler::print();
00202 }
00203 const Clp_Simplex *
00204 CMessageHandler::model() const
00205 {
00206   return model_;
00207 }
00208 void 
00209 CMessageHandler::setModel(Clp_Simplex * model)
00210 {
00211   model_ = model;
00212 }
00213 // Call back
00214 void 
00215 CMessageHandler::setCallBack(clp_callback callback)
00216 {
00217   callback_ = callback;
00218 }
00219 
00220 #include "Clp_C_Interface.h"
00221 #include <string>
00222 #include <stdio.h>
00223 #include <iostream>
00224 
00225 /* Default constructor */
00226 CLPLIBAPI Clp_Simplex *  CLPLINKAGE 
00227 Clp_newModel()
00228 {
00229   Clp_Simplex * model = new Clp_Simplex;
00230   model->model_ = new ClpSimplex();
00231   model->handler_=NULL;
00232   return model;
00233 }
00234 /* Destructor */
00235 CLPLIBAPI void CLPLINKAGE 
00236 Clp_deleteModel(Clp_Simplex * model)
00237 {
00238   delete model->model_;
00239   delete model->handler_;
00240   delete model;
00241 }
00242 
00243 /* Loads a problem (the constraints on the
00244     rows are given by lower and upper bounds). If a pointer is NULL then the
00245     following values are the default:
00246     <ul>
00247     <li> <code>colub</code>: all columns have upper bound infinity
00248     <li> <code>collb</code>: all columns have lower bound 0 
00249     <li> <code>rowub</code>: all rows have upper bound infinity
00250     <li> <code>rowlb</code>: all rows have lower bound -infinity
00251     <li> <code>obj</code>: all variables have 0 objective coefficient
00252     </ul>
00253 */
00254 /* Just like the other loadProblem() method except that the matrix is
00255    given in a standard column major ordered format (without gaps). */
00256 CLPLIBAPI void CLPLINKAGE 
00257 Clp_loadProblem (Clp_Simplex * model,  const int numcols, const int numrows,
00258                  const int* start, const int* index,
00259                  const double* value,
00260                  const double* collb, const double* colub,   
00261                  const double* obj,
00262                  const double* rowlb, const double* rowub)
00263 {
00264   model->model_->loadProblem(numcols,numrows,start,index,value,
00265                              collb,colub,obj,rowlb,rowub);
00266 }
00267 /* Read an mps file from the given filename */
00268 CLPLIBAPI int CLPLINKAGE 
00269 Clp_readMps(Clp_Simplex * model,const char *filename,
00270             int keepNames,
00271             int ignoreErrors)
00272 {
00273   return model->model_->readMps(filename,keepNames!=0,ignoreErrors!=0);
00274 }
00275 /* Copy in integer informations */
00276 CLPLIBAPI void CLPLINKAGE 
00277 Clp_copyInIntegerInformation(Clp_Simplex * model,const char * information)
00278 {
00279   model->model_->copyInIntegerInformation(information);
00280 }
00281 /* Drop integer informations */
00282 CLPLIBAPI void CLPLINKAGE 
00283 Clp_deleteIntegerInformation(Clp_Simplex * model)
00284 {
00285   model->model_->deleteIntegerInformation();
00286 }
00287 /* Resizes rim part of model  */
00288 CLPLIBAPI void CLPLINKAGE 
00289 Clp_resize (Clp_Simplex * model, int newNumberRows, int newNumberColumns)
00290 {
00291   model->model_->resize(newNumberRows,newNumberColumns);
00292 }
00293 /* Deletes rows */
00294 CLPLIBAPI void CLPLINKAGE 
00295 Clp_deleteRows(Clp_Simplex * model, int number, const int * which)
00296 {
00297   model->model_->deleteRows(number,which);
00298 }
00299 /* Add rows */
00300 CLPLIBAPI void CLPLINKAGE 
00301 Clp_addRows(Clp_Simplex * model, int number, const double * rowLower, 
00302                const double * rowUpper,
00303                const int * rowStarts, const int * columns,
00304                const double * elements)
00305 {
00306   model->model_->addRows(number,rowLower,rowUpper,rowStarts,columns,elements);
00307 }
00308 
00309 /* Deletes columns */
00310 CLPLIBAPI void CLPLINKAGE 
00311 Clp_deleteColumns(Clp_Simplex * model, int number, const int * which)
00312 {
00313   model->model_->deleteColumns(number,which);
00314 }
00315 /* Add columns */
00316 CLPLIBAPI void CLPLINKAGE 
00317 Clp_addColumns(Clp_Simplex * model, int number, const double * columnLower, 
00318                   const double * columnUpper,
00319                   const double * objective,
00320                   const int * columnStarts, const int * rows,
00321                   const double * elements)
00322 {
00323   model->model_->addColumns(number,columnLower,columnUpper,objective,
00324                             columnStarts,rows,elements);
00325 }
00326 /* Drops names - makes lengthnames 0 and names empty */
00327 CLPLIBAPI void CLPLINKAGE 
00328 Clp_dropNames(Clp_Simplex * model)
00329 {
00330   model->model_->dropNames();
00331 }
00332 /* Copies in names */
00333 CLPLIBAPI void CLPLINKAGE 
00334 Clp_copyNames(Clp_Simplex * model, const char * const * rowNamesIn,
00335               const char * const * columnNamesIn)
00336 {
00337   int iRow;
00338   std::vector<std::string> rowNames;
00339   int numberRows = model->model_->numberRows();
00340   rowNames.reserve(numberRows);
00341   for (iRow=0;iRow<numberRows;iRow++) {
00342     rowNames.push_back(rowNamesIn[iRow]);
00343   }
00344   
00345   int iColumn;
00346   std::vector<std::string> columnNames;
00347   int numberColumns = model->model_->numberColumns();
00348   columnNames.reserve(numberColumns);
00349   for (iColumn=0;iColumn<numberColumns;iColumn++) {
00350     columnNames.push_back(columnNamesIn[iColumn]);
00351   }
00352   model->model_->copyNames(rowNames,columnNames);
00353 }
00354 
00355 /* Number of rows */
00356 CLPLIBAPI int CLPLINKAGE 
00357 Clp_numberRows(Clp_Simplex * model)
00358 {
00359   return model->model_->numberRows();
00360 }
00361 /* Number of columns */
00362 CLPLIBAPI int CLPLINKAGE 
00363 Clp_numberColumns(Clp_Simplex * model)
00364 {
00365   return model->model_->numberColumns();
00366 }
00367 /* Primal tolerance to use */
00368 CLPLIBAPI double CLPLINKAGE 
00369 Clp_primalTolerance(Clp_Simplex * model)
00370 {
00371   return model->model_->primalTolerance();
00372 }
00373 CLPLIBAPI void CLPLINKAGE 
00374 Clp_setPrimalTolerance(Clp_Simplex * model,  double value) 
00375 {
00376   model->model_->setPrimalTolerance(value);
00377 }
00378 /* Dual tolerance to use */
00379 CLPLIBAPI double CLPLINKAGE 
00380 Clp_dualTolerance(Clp_Simplex * model)
00381 {
00382   return model->model_->dualTolerance();
00383 }
00384 CLPLIBAPI void CLPLINKAGE 
00385 Clp_setDualTolerance(Clp_Simplex * model,  double value) 
00386 {
00387   model->model_->setDualTolerance(value);
00388 }
00389 /* Dual objective limit */
00390 CLPLIBAPI double CLPLINKAGE 
00391 Clp_dualObjectiveLimit(Clp_Simplex * model)
00392 {
00393   return model->model_->dualObjectiveLimit();
00394 }
00395 CLPLIBAPI void CLPLINKAGE 
00396 Clp_setDualObjectiveLimit(Clp_Simplex * model, double value)
00397 {
00398   model->model_->setDualObjectiveLimit(value);
00399 }
00400 /* Objective offset */
00401 CLPLIBAPI double CLPLINKAGE 
00402 Clp_objectiveOffset(Clp_Simplex * model)
00403 {
00404   return model->model_->objectiveOffset();
00405 }
00406 CLPLIBAPI void CLPLINKAGE 
00407 Clp_setObjectiveOffset(Clp_Simplex * model, double value)
00408 {
00409   model->model_->setObjectiveOffset(value);
00410 }
00411 /* Fills in array with problem name  */
00412 CLPLIBAPI void CLPLINKAGE 
00413 Clp_problemName(Clp_Simplex * model, int maxNumberCharacters, char * array)
00414 {
00415   std::string name = model->model_->problemName();
00416   maxNumberCharacters = min(maxNumberCharacters,(int)strlen(name.c_str()));
00417   strncpy(array,name.c_str(),maxNumberCharacters-1);
00418   array[maxNumberCharacters-1]='\0';
00419 }
00420 /* Number of iterations */
00421 CLPLIBAPI int CLPLINKAGE 
00422 Clp_numberIterations(Clp_Simplex * model)
00423 {
00424   return model->model_->numberIterations();
00425 }
00426 CLPLIBAPI void CLPLINKAGE 
00427 Clp_setNumberIterations(Clp_Simplex * model, int numberIterations)
00428 {
00429   model->model_->setNumberIterations(numberIterations);
00430 }
00431 /* Maximum number of iterations */
00432 CLPLIBAPI int maximumIterations(Clp_Simplex * model)
00433 {
00434   return model->model_->maximumIterations();
00435 }
00436 CLPLIBAPI void CLPLINKAGE 
00437 Clp_setMaximumIterations(Clp_Simplex * model, int value)
00438 {
00439   model->model_->setMaximumIterations(value);
00440 }
00441 /* Maximum time in seconds (from when set called) */
00442 CLPLIBAPI double CLPLINKAGE 
00443 Clp_maximumSeconds(Clp_Simplex * model)
00444 {
00445   return model->model_->maximumSeconds();
00446 }
00447 CLPLIBAPI void CLPLINKAGE 
00448 Clp_setMaximumSeconds(Clp_Simplex * model, double value)
00449 {
00450   model->model_->setMaximumSeconds(value);
00451 }
00452 /* Returns true if hit maximum iteratio`ns (or time) */
00453 CLPLIBAPI int CLPLINKAGE 
00454 Clp_hitMaximumIterations(Clp_Simplex * model)
00455 {
00456   return model->model_->hitMaximumIterations() ? 1 : 0;
00457 }
00458 /* Status of problem:
00459    0 - optimal
00460    1 - primal infeasible
00461    2 - dual infeasible
00462    3 - stopped on iterations etc
00463    4 - stopped due to errors
00464 */
00465 CLPLIBAPI int CLPLINKAGE 
00466 Clp_status(Clp_Simplex * model)
00467 {
00468   return model->model_->status();
00469 }
00470 /* Set problem status */
00471 CLPLIBAPI void CLPLINKAGE 
00472 Clp_setProblemStatus(Clp_Simplex * model, int problemStatus)
00473 {
00474   model->model_->setProblemStatus(problemStatus);
00475 }
00476 /* Secondary status of problem - may get extended
00477    0 - none
00478    1 - primal infeasible because dual limit reached
00479    2 - scaled problem optimal - unscaled has primal infeasibilities
00480    3 - scaled problem optimal - unscaled has dual infeasibilities
00481    4 - scaled problem optimal - unscaled has both dual and primal infeasibilities
00482 */
00483 CLPLIBAPI int CLPLINKAGE 
00484 Clp_secondaryStatus(Clp_Simplex * model)
00485 {
00486   return model->model_->secondaryStatus();
00487 }
00488 CLPLIBAPI void CLPLINKAGE 
00489 Clp_setSecondaryStatus(Clp_Simplex * model, int status)
00490 {
00491   model->model_->setSecondaryStatus(status);
00492 }
00493 /* Direction of optimization (1 - minimize, -1 - maximize, 0 - ignore */
00494 CLPLIBAPI double CLPLINKAGE 
00495 Clp_optimizationDirection(Clp_Simplex * model)
00496 {
00497   return model->model_->optimizationDirection();
00498 }
00499 CLPLIBAPI void CLPLINKAGE 
00500 Clp_setOptimizationDirection(Clp_Simplex * model, double value)
00501 {
00502   model->model_->setOptimizationDirection(value);
00503 }
00504 /* Primal row solution */
00505 CLPLIBAPI double * CLPLINKAGE 
00506 Clp_primalRowSolution(Clp_Simplex * model)
00507 {
00508   return model->model_->primalRowSolution();
00509 }
00510 /* Primal column solution */
00511 CLPLIBAPI double * CLPLINKAGE 
00512 Clp_primalColumnSolution(Clp_Simplex * model)
00513 {
00514   return model->model_->primalColumnSolution();
00515 }
00516 /* Dual row solution */
00517 CLPLIBAPI double * CLPLINKAGE 
00518 Clp_dualRowSolution(Clp_Simplex * model)
00519 {
00520   return model->model_->dualRowSolution();
00521 }
00522 /* Reduced costs */
00523 CLPLIBAPI double * CLPLINKAGE 
00524 Clp_dualColumnSolution(Clp_Simplex * model)
00525 {
00526   return model->model_->dualColumnSolution();
00527 }
00528 /* Row lower */
00529 CLPLIBAPI double* CLPLINKAGE 
00530 Clp_rowLower(Clp_Simplex * model)
00531 {
00532   return model->model_->rowLower();
00533 }
00534 /* Row upper  */
00535 CLPLIBAPI double* CLPLINKAGE 
00536 Clp_rowUpper(Clp_Simplex * model)
00537 {
00538   return model->model_->rowUpper();
00539 }
00540 /* Objective */
00541 CLPLIBAPI double * CLPLINKAGE 
00542 Clp_objective(Clp_Simplex * model)
00543 {
00544   return model->model_->objective();
00545 }
00546 /* Column Lower */
00547 CLPLIBAPI double * CLPLINKAGE 
00548 Clp_columnLower(Clp_Simplex * model)
00549 {
00550   return model->model_->columnLower();
00551 }
00552 /* Column Upper */
00553 CLPLIBAPI double * CLPLINKAGE 
00554 Clp_columnUpper(Clp_Simplex * model)
00555 {
00556   return model->model_->columnUpper();
00557 }
00558 /* Number of elements in matrix */
00559 CLPLIBAPI int CLPLINKAGE 
00560 Clp_getNumElements(Clp_Simplex * model)
00561 {
00562   return model->model_->getNumElements();
00563 }
00564 /* Objective value */
00565 CLPLIBAPI double CLPLINKAGE 
00566 Clp_objectiveValue(Clp_Simplex * model)
00567 {
00568   return model->model_->objectiveValue();
00569 }
00570 /* Integer information */
00571 CLPLIBAPI char * CLPLINKAGE 
00572 Clp_integerInformation(Clp_Simplex * model)
00573 {
00574   return model->model_->integerInformation();
00575 }
00576 /* Infeasibility/unbounded ray (NULL returned if none/wrong)
00577    Up to user to use delete [] on these arrays.  */
00578 CLPLIBAPI double * CLPLINKAGE 
00579 Clp_infeasibilityRay(Clp_Simplex * model)
00580 {
00581   return model->model_->infeasibilityRay();
00582 }
00583 CLPLIBAPI double * CLPLINKAGE 
00584 Clp_unboundedRay(Clp_Simplex * model)
00585 {
00586   return model->model_->unboundedRay();
00587 }
00588 /* See if status array exists (partly for OsiClp) */
00589 CLPLIBAPI int CLPLINKAGE 
00590 Clp_statusExists(Clp_Simplex * model)
00591 {
00592   return model->model_->statusExists() ? 1 : 0;
00593 }
00594 /* Return address of status array (char[numberRows+numberColumns]) */
00595 CLPLIBAPI unsigned char *  CLPLINKAGE 
00596 Clp_statusArray(Clp_Simplex * model)
00597 {
00598   return model->model_->statusArray();
00599 }
00600 /* Copy in status vector */
00601 CLPLIBAPI void CLPLINKAGE 
00602 Clp_copyinStatus(Clp_Simplex * model, const unsigned char * statusArray)
00603 {
00604   model->model_->copyinStatus(statusArray);
00605 }
00606 
00607 /* User pointer for whatever reason */
00608 CLPLIBAPI void CLPLINKAGE 
00609 Clp_setUserPointer (Clp_Simplex * model, void * pointer)
00610 {
00611   model->model_->setUserPointer(pointer);
00612 }
00613 CLPLIBAPI void * CLPLINKAGE 
00614 Clp_getUserPointer (Clp_Simplex * model)
00615 {
00616   return model->model_->getUserPointer();
00617 }
00618 /* Pass in Callback function */
00619 CLPLIBAPI void CLPLINKAGE 
00620 Clp_registerCallBack(Clp_Simplex * model, 
00621                      clp_callback userCallBack)
00622 {
00623   // Will be copy of users one
00624   delete model->handler_;
00625   model->handler_ = new CMessageHandler(*(model->model_->messageHandler()));
00626   model->handler_->setCallBack(userCallBack);
00627   model->handler_->setModel(model);
00628   model->model_->passInMessageHandler(model->handler_);
00629 }
00630 /* Unset Callback function */
00631 CLPLIBAPI void CLPLINKAGE 
00632 Clp_clearCallBack(Clp_Simplex * model)
00633 {
00634   delete model->handler_;
00635   model->handler_=NULL;
00636 }
00637 /* Amount of print out:
00638    0 - none
00639    1 - just final
00640    2 - just factorizations
00641    3 - as 2 plus a bit more
00642    4 - verbose
00643    above that 8,16,32 etc just for selective debug
00644 */
00645 CLPLIBAPI void CLPLINKAGE 
00646 Clp_setLogLevel(Clp_Simplex * model, int value)
00647 {
00648   model->model_->setLogLevel(value);
00649 }
00650 CLPLIBAPI int CLPLINKAGE 
00651 Clp_logLevel(Clp_Simplex * model)
00652 {
00653   return model->model_->logLevel();
00654 }
00655 /* length of names (0 means no names0 */
00656 CLPLIBAPI int CLPLINKAGE 
00657 Clp_lengthNames(Clp_Simplex * model)
00658 {
00659   return model->model_->lengthNames();
00660 }
00661 /* Fill in array (at least lengthNames+1 long) with a row name */
00662 CLPLIBAPI void CLPLINKAGE 
00663 Clp_rowName(Clp_Simplex * model, int iRow, char * name)
00664 {
00665   std::string rowName=model->model_->rowName(iRow);
00666   strcpy(name,rowName.c_str());
00667 }
00668 /* Fill in array (at least lengthNames+1 long) with a column name */
00669 CLPLIBAPI void CLPLINKAGE 
00670 Clp_columnName(Clp_Simplex * model, int iColumn, char * name)
00671 {
00672   std::string columnName= model->model_->columnName(iColumn);
00673   strcpy(name,columnName.c_str());
00674 }
00675 
00676 /* General solve algorithm which can do presolve.
00677    See  ClpSolve.hpp for options
00678 */
00679 CLPLIBAPI int CLPLINKAGE 
00680 Clp_initialSolve(Clp_Simplex * model)
00681 {
00682   return model->model_->initialSolve();
00683 }
00684 /* Dual initial solve */
00685 CLPLIBAPI int CLPLINKAGE 
00686 Clp_initialDualSolve(Clp_Simplex * model)
00687 {
00688   return model->model_->initialDualSolve();
00689 }
00690 /* Primal initial solve */
00691 CLPLIBAPI int CLPLINKAGE 
00692 Clp_initialPrimalSolve(Clp_Simplex * model)
00693 {
00694   return model->model_->initialPrimalSolve();
00695 }
00696 /* Dual algorithm - see ClpSimplexDual.hpp for method */
00697 CLPLIBAPI int CLPLINKAGE 
00698 Clp_dual(Clp_Simplex * model, int ifValuesPass)
00699 {
00700   return model->model_->dual(ifValuesPass);
00701 }
00702 /* Primal algorithm - see ClpSimplexPrimal.hpp for method */
00703 CLPLIBAPI int CLPLINKAGE 
00704 Clp_primal(Clp_Simplex * model, int ifValuesPass)
00705 {
00706   return model->model_->primal(ifValuesPass);
00707 }
00708 /* Sets or unsets scaling, 0 -off, 1 equilibrium, 2 geometric, 3, auto, 4 dynamic(later) */
00709 CLPLIBAPI void CLPLINKAGE 
00710 Clp_scaling(Clp_Simplex * model, int mode)
00711 {
00712   model->model_->scaling(mode);
00713 }
00714 /* Gets scalingFlag */
00715 CLPLIBAPI int CLPLINKAGE 
00716 Clp_scalingFlag(Clp_Simplex * model)
00717 {
00718   return model->model_->scalingFlag();
00719 }
00720 /* Crash - at present just aimed at dual, returns
00721    -2 if dual preferred and crash basis created
00722    -1 if dual preferred and all slack basis preferred
00723    0 if basis going in was not all slack
00724    1 if primal preferred and all slack basis preferred
00725    2 if primal preferred and crash basis created.
00726    
00727    if gap between bounds <="gap" variables can be flipped
00728    
00729    If "pivot" is
00730    0 No pivoting (so will just be choice of algorithm)
00731    1 Simple pivoting e.g. gub
00732    2 Mini iterations
00733 */
00734 CLPLIBAPI int CLPLINKAGE 
00735 Clp_crash(Clp_Simplex * model, double gap,int pivot)
00736 {
00737   return model->model_->crash(gap,pivot);
00738 }
00739 /* If problem is primal feasible */
00740 CLPLIBAPI int CLPLINKAGE 
00741 Clp_primalFeasible(Clp_Simplex * model)
00742 {
00743   return model->model_->primalFeasible() ? 1 : 0;
00744 }
00745 /* If problem is dual feasible */
00746 CLPLIBAPI int CLPLINKAGE 
00747 Clp_dualFeasible(Clp_Simplex * model)
00748 {
00749   return model->model_->dualFeasible() ? 1 : 0;
00750 }
00751 /* Dual bound */
00752 CLPLIBAPI double CLPLINKAGE 
00753 Clp_dualBound(Clp_Simplex * model)
00754 {
00755   return model->model_->dualBound();
00756 }
00757 CLPLIBAPI void CLPLINKAGE 
00758 Clp_setDualBound(Clp_Simplex * model, double value)
00759 {
00760   model->model_->setDualBound(value);
00761 }
00762 /* Infeasibility cost */
00763 CLPLIBAPI double CLPLINKAGE 
00764 Clp_infeasibilityCost(Clp_Simplex * model)
00765 {
00766   return model->model_->infeasibilityCost();
00767 }
00768 CLPLIBAPI void CLPLINKAGE 
00769 Clp_setInfeasibilityCost(Clp_Simplex * model, double value)
00770 {
00771   model->model_->setInfeasibilityCost(value);
00772 }
00773 /* Perturbation:
00774    50  - switch on perturbation
00775    100 - auto perturb if takes too long (1.0e-6 largest nonzero)
00776    101 - we are perturbed
00777    102 - don't try perturbing again
00778    default is 100
00779    others are for playing
00780 */
00781 CLPLIBAPI int CLPLINKAGE 
00782 Clp_perturbation(Clp_Simplex * model)
00783 {
00784   return model->model_->perturbation();
00785 }
00786 CLPLIBAPI void CLPLINKAGE 
00787 Clp_setPerturbation(Clp_Simplex * model, int value)
00788 {
00789   model->model_->setPerturbation(value);
00790 }
00791 /* Current (or last) algorithm */
00792 CLPLIBAPI int CLPLINKAGE 
00793 Clp_algorithm(Clp_Simplex * model)
00794 {
00795   return model->model_->algorithm();
00796 }
00797 /* Set algorithm */
00798 CLPLIBAPI void CLPLINKAGE 
00799 Clp_setAlgorithm(Clp_Simplex * model, int value)
00800 {
00801   model->model_->setAlgorithm(value);
00802 }
00803 /* Sum of dual infeasibilities */
00804 CLPLIBAPI double CLPLINKAGE 
00805 Clp_sumDualInfeasibilities(Clp_Simplex * model)
00806 {
00807   return model->model_->sumDualInfeasibilities();
00808 }
00809 /* Number of dual infeasibilities */
00810 CLPLIBAPI int CLPLINKAGE 
00811 Clp_numberDualInfeasibilities(Clp_Simplex * model)
00812 {
00813   return model->model_->numberDualInfeasibilities();
00814 }
00815 /* Sum of primal infeasibilities */
00816 CLPLIBAPI double CLPLINKAGE 
00817 Clp_sumPrimalInfeasibilities(Clp_Simplex * model)
00818 {
00819   return model->model_->sumPrimalInfeasibilities();
00820 }
00821 /* Number of primal infeasibilities */
00822 CLPLIBAPI int CLPLINKAGE 
00823 Clp_numberPrimalInfeasibilities(Clp_Simplex * model)
00824 {
00825   return model->model_->numberPrimalInfeasibilities();
00826 }
00827 /* Save model to file, returns 0 if success.  This is designed for
00828    use outside algorithms so does not save iterating arrays etc.
00829    It does not save any messaging information. 
00830    Does not save scaling values.
00831    It does not know about all types of virtual functions.
00832 */
00833 CLPLIBAPI int CLPLINKAGE 
00834 Clp_saveModel(Clp_Simplex * model, const char * fileName)
00835 {
00836   return model->model_->saveModel(fileName);
00837 }
00838 /* Restore model from file, returns 0 if success,
00839    deletes current model */
00840 CLPLIBAPI int CLPLINKAGE 
00841 Clp_restoreModel(Clp_Simplex * model, const char * fileName)
00842 {
00843   return model->model_->restoreModel(fileName);
00844 }
00845   
00846 /* Just check solution (for external use) - sets sum of
00847    infeasibilities etc */
00848 CLPLIBAPI void CLPLINKAGE 
00849 Clp_checkSolution(Clp_Simplex * model)
00850 {
00851   model->model_->checkSolution();
00852 }
00853 /* Number of rows */
00854 CLPLIBAPI int CLPLINKAGE 
00855 Clp_getNumRows(Clp_Simplex * model)
00856 {
00857   return model->model_->getNumRows();
00858 }
00859 /* Number of columns */
00860 CLPLIBAPI int CLPLINKAGE 
00861 Clp_getNumCols(Clp_Simplex * model)
00862 {
00863   return model->model_->getNumCols();
00864 }
00865 /* Number of iterations */
00866 CLPLIBAPI int CLPLINKAGE 
00867 Clp_getIterationCount(Clp_Simplex * model)
00868 {
00869   return model->model_->getIterationCount();
00870 }
00871 /* Are there a numerical difficulties? */
00872 CLPLIBAPI int CLPLINKAGE 
00873 Clp_isAbandoned(Clp_Simplex * model)
00874 {
00875   return model->model_->isAbandoned() ? 1 : 0;
00876 }
00877 /* Is optimality proven? */
00878 CLPLIBAPI int CLPLINKAGE 
00879 Clp_isProvenOptimal(Clp_Simplex * model)
00880 {
00881   return model->model_->isProvenOptimal() ? 1 : 0;
00882 }
00883 /* Is primal infeasiblity proven? */
00884 CLPLIBAPI int CLPLINKAGE 
00885 Clp_isProvenPrimalInfeasible(Clp_Simplex * model)
00886 {
00887   return model->model_->isProvenPrimalInfeasible() ? 1 : 0;
00888 }
00889 /* Is dual infeasiblity proven? */
00890 CLPLIBAPI int CLPLINKAGE 
00891 Clp_isProvenDualInfeasible(Clp_Simplex * model)
00892 {
00893   return model->model_->isProvenDualInfeasible() ? 1 : 0;
00894 }
00895 /* Is the given primal objective limit reached? */
00896 CLPLIBAPI int CLPLINKAGE 
00897 Clp_isPrimalObjectiveLimitReached(Clp_Simplex * model) 
00898 {
00899   return model->model_->isPrimalObjectiveLimitReached() ? 1 : 0;
00900 }
00901 /* Is the given dual objective limit reached? */
00902 CLPLIBAPI int CLPLINKAGE 
00903 Clp_isDualObjectiveLimitReached(Clp_Simplex * model) 
00904 {
00905   return model->model_->isDualObjectiveLimitReached() ? 1 : 0;
00906 }
00907 /* Iteration limit reached? */
00908 CLPLIBAPI int CLPLINKAGE 
00909 Clp_isIterationLimitReached(Clp_Simplex * model)
00910 {
00911   return model->model_->isIterationLimitReached() ? 1 : 0;
00912 }
00913 /* Direction of optimization (1 - minimize, -1 - maximize, 0 - ignore */
00914 CLPLIBAPI double CLPLINKAGE 
00915 Clp_getObjSense(Clp_Simplex * model)
00916 {
00917   return model->model_->getObjSense();
00918 }
00919 /* Primal row solution */
00920 CLPLIBAPI const double * CLPLINKAGE 
00921 Clp_getRowActivity(Clp_Simplex * model)
00922 {
00923   return model->model_->getRowActivity();
00924 }
00925 /* Primal column solution */
00926 CLPLIBAPI const double * CLPLINKAGE 
00927 Clp_getColSolution(Clp_Simplex * model)
00928 {
00929   return model->model_->getColSolution();
00930 }
00931 CLPLIBAPI void CLPLINKAGE 
00932 Clp_setColSolution(Clp_Simplex * model, const double * input)
00933 {
00934   model->model_->setColSolution(input);
00935 }
00936 /* Dual row solution */
00937 CLPLIBAPI const double * CLPLINKAGE 
00938 Clp_getRowPrice(Clp_Simplex * model)
00939 {
00940   return model->model_->getRowPrice();
00941 }
00942 /* Reduced costs */
00943 CLPLIBAPI const double * CLPLINKAGE 
00944 Clp_getReducedCost(Clp_Simplex * model)
00945 {
00946   return model->model_->getReducedCost();
00947 }
00948 /* Row lower */
00949 CLPLIBAPI const double* CLPLINKAGE 
00950 Clp_getRowLower(Clp_Simplex * model)
00951 {
00952   return model->model_->getRowLower();
00953 }
00954 /* Row upper  */
00955 CLPLIBAPI const double* CLPLINKAGE 
00956 Clp_getRowUpper(Clp_Simplex * model)
00957 {
00958   return model->model_->getRowUpper();
00959 }
00960 /* Objective */
00961 CLPLIBAPI const double * CLPLINKAGE 
00962 Clp_getObjCoefficients(Clp_Simplex * model)
00963 {
00964   return model->model_->getObjCoefficients();
00965 }
00966 /* Column Lower */
00967 CLPLIBAPI const double * CLPLINKAGE 
00968 Clp_getColLower(Clp_Simplex * model)
00969 {
00970   return model->model_->getColLower();
00971 }
00972 /* Column Upper */
00973 CLPLIBAPI const double * CLPLINKAGE 
00974 Clp_getColUpper(Clp_Simplex * model)
00975 {
00976   return model->model_->getColUpper();
00977 }
00978 /* Objective value */
00979 CLPLIBAPI double CLPLINKAGE 
00980 Clp_getObjValue(Clp_Simplex * model)
00981 {
00982   return model->model_->getObjValue();
00983 }
00984 

Generated on Wed Dec 3 14:37:24 2003 for CLP by doxygen 1.3.5