Changeset 518


Ignore:
Timestamp:
Sep 13, 2005 9:20:27 PM (15 years ago)
Author:
andreasw
Message:

changed dependencies, so that the new modifications also work on AIX

Location:
branches/dev/Interfaces
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/dev/Interfaces/IpIpoptApplication.cpp

    r517 r518  
    314314      }
    315315
    316       ip_nlp_ =  new OrigIpoptNLP(ConstPtr(jnlst_), GetRawPtr(nlp), nlp_scaling);
     316      SmartPtr<IpoptNLP> ip_nlp =
     317        new OrigIpoptNLP(ConstPtr(jnlst_), GetRawPtr(nlp), nlp_scaling);
     318      ip_nlp_ = GetRawPtr(ip_nlp);
    317319
    318320      // Create the IpoptData
    319       ip_data_ = new IpoptData();
     321      SmartPtr<IpoptData> ip_data = new IpoptData();
     322      ip_data_ = GetRawPtr(ip_data);
    320323
    321324      // Create the IpoptCalculators
    322       ip_cq_ = new IpoptCalculatedQuantities(ip_nlp_, ip_data_);
     325      SmartPtr<IpoptCalculatedQuantities> ip_cq =
     326        new IpoptCalculatedQuantities(ip_nlp, ip_data);
     327      ip_cq_ = GetRawPtr(ip_cq);
    323328
    324329      // Create the Algorithm object
    325       alg_ = AlgorithmBuilder::BuildBasicAlgorithm(*jnlst_, *options_, "");
     330      alg_ = GetRawPtr(AlgorithmBuilder::BuildBasicAlgorithm(*jnlst_, *options_, ""));
    326331
    327332      // finally call the optimization
     
    386391    ApplicationReturnStatus retValue = Internal_Error;
    387392    try {
     393      // Get the pointers to the real objects (need to do it that
     394      // awkwardly since otherwise we would have to include so many
     395      // things in IpoptApplication, which a user would have to
     396      // include, too (SmartPtr doesn't work otherwise on AIX)
     397      IpoptAlgorithm* p2alg = dynamic_cast<IpoptAlgorithm*> (GetRawPtr(alg_));
     398      IpoptData* p2ip_data = dynamic_cast<IpoptData*> (GetRawPtr(ip_data_));
     399      IpoptNLP* p2ip_nlp = dynamic_cast<IpoptNLP*> (GetRawPtr(ip_nlp_));
     400      IpoptCalculatedQuantities* p2ip_cq = dynamic_cast<IpoptCalculatedQuantities*> (GetRawPtr(ip_cq_));
    388401      // Set up the algorithm
    389       alg_->Initialize(*jnlst_, *ip_nlp_, *ip_data_, *ip_cq_, *options_, "");
     402      p2alg->Initialize(*jnlst_, *p2ip_nlp, *p2ip_data, *p2ip_cq,
     403                        *options_, "");
    390404
    391405      if( jnlst_->ProduceOutput(J_DETAILED, J_MAIN) ) {
     
    397411
    398412      // Run the algorithm
    399       SolverReturn status = alg_->Optimize();
     413      SolverReturn status = p2alg->Optimize();
    400414
    401415      jnlst_->Printf(J_SUMMARY, J_SOLUTION,
    402416                     "\nNumber of Iterations....: %d\n",
    403                      ip_data_->iter_count());
     417                     p2ip_data->iter_count());
    404418
    405419      jnlst_->Printf(J_SUMMARY, J_SOLUTION,
     
    407421      jnlst_->Printf(J_SUMMARY, J_SOLUTION,
    408422                     "Objective...............: %24.16e  %24.16e\n",
    409                      ip_cq_->curr_f(),
    410                      ip_cq_->unscaled_curr_f());
     423                     p2ip_cq->curr_f(),
     424                     p2ip_cq->unscaled_curr_f());
    411425      jnlst_->Printf(J_SUMMARY, J_SOLUTION,
    412426                     "Dual infeasibility......: %24.16e  %24.16e\n",
    413                      ip_cq_->curr_dual_infeasibility(NORM_MAX),
    414                      ip_cq_->unscaled_curr_dual_infeasibility(NORM_MAX));
     427                     p2ip_cq->curr_dual_infeasibility(NORM_MAX),
     428                     p2ip_cq->unscaled_curr_dual_infeasibility(NORM_MAX));
    415429      jnlst_->Printf(J_SUMMARY, J_SOLUTION,
    416430                     "Constraint violation....: %24.16e  %24.16e\n",
    417                      ip_cq_->curr_nlp_constraint_violation(NORM_MAX),
    418                      ip_cq_->unscaled_curr_nlp_constraint_violation(NORM_MAX));
     431                     p2ip_cq->curr_nlp_constraint_violation(NORM_MAX),
     432                     p2ip_cq->unscaled_curr_nlp_constraint_violation(NORM_MAX));
    419433      jnlst_->Printf(J_SUMMARY, J_SOLUTION,
    420434                     "Complementarity.........: %24.16e  %24.16e\n",
    421                      ip_cq_->curr_complementarity(0., NORM_MAX),
    422                      ip_cq_->unscaled_curr_complementarity(0., NORM_MAX));
     435                     p2ip_cq->curr_complementarity(0., NORM_MAX),
     436                     p2ip_cq->unscaled_curr_complementarity(0., NORM_MAX));
    423437      jnlst_->Printf(J_SUMMARY, J_SOLUTION,
    424438                     "Overall NLP error.......: %24.16e  %24.16e\n\n",
    425                      ip_cq_->curr_nlp_error(),
    426                      ip_cq_->unscaled_curr_nlp_error());
    427 
    428       ip_data_->curr()->x()->Print(*jnlst_, J_VECTOR, J_SOLUTION, "x");
    429       ip_data_->curr()->y_c()->Print(*jnlst_, J_VECTOR, J_SOLUTION, "y_c");
    430       ip_data_->curr()->y_d()->Print(*jnlst_, J_VECTOR, J_SOLUTION, "y_d");
    431       ip_data_->curr()->z_L()->Print(*jnlst_, J_VECTOR, J_SOLUTION, "z_L");
    432       ip_data_->curr()->z_U()->Print(*jnlst_, J_VECTOR, J_SOLUTION, "z_U");
    433       ip_data_->curr()->v_L()->Print(*jnlst_, J_VECTOR, J_SOLUTION, "v_L");
    434       ip_data_->curr()->v_U()->Print(*jnlst_, J_VECTOR, J_SOLUTION, "v_U");
     439                     p2ip_cq->curr_nlp_error(),
     440                     p2ip_cq->unscaled_curr_nlp_error());
     441
     442      p2ip_data->curr()->x()->Print(*jnlst_, J_VECTOR, J_SOLUTION, "x");
     443      p2ip_data->curr()->y_c()->Print(*jnlst_, J_VECTOR, J_SOLUTION, "y_c");
     444      p2ip_data->curr()->y_d()->Print(*jnlst_, J_VECTOR, J_SOLUTION, "y_d");
     445      p2ip_data->curr()->z_L()->Print(*jnlst_, J_VECTOR, J_SOLUTION, "z_L");
     446      p2ip_data->curr()->z_U()->Print(*jnlst_, J_VECTOR, J_SOLUTION, "z_U");
     447      p2ip_data->curr()->v_L()->Print(*jnlst_, J_VECTOR, J_SOLUTION, "v_L");
     448      p2ip_data->curr()->v_U()->Print(*jnlst_, J_VECTOR, J_SOLUTION, "v_U");
    435449
    436450      jnlst_->Printf(J_SUMMARY, J_STATISTICS,
    437451                     "\nNumber of objective function evaluations             = %d\n",
    438                      ip_nlp_->f_evals());
     452                     p2ip_nlp->f_evals());
    439453      jnlst_->Printf(J_SUMMARY, J_STATISTICS,
    440454                     "Number of objective gradient evaluations             = %d\n",
    441                      ip_nlp_->grad_f_evals());
     455                     p2ip_nlp->grad_f_evals());
    442456      jnlst_->Printf(J_SUMMARY, J_STATISTICS,
    443457                     "Number of equality constraint evaluations            = %d\n",
    444                      ip_nlp_->c_evals());
     458                     p2ip_nlp->c_evals());
    445459      jnlst_->Printf(J_SUMMARY, J_STATISTICS,
    446460                     "Number of inequality constraint evaluations          = %d\n",
    447                      ip_nlp_->d_evals());
     461                     p2ip_nlp->d_evals());
    448462      jnlst_->Printf(J_SUMMARY, J_STATISTICS,
    449463                     "Number of equality constraint Jacobian evaluations   = %d\n",
    450                      ip_nlp_->jac_c_evals());
     464                     p2ip_nlp->jac_c_evals());
    451465      jnlst_->Printf(J_SUMMARY, J_STATISTICS,
    452466                     "Number of inequality constraint Jacobian evaluations = %d\n",
    453                      ip_nlp_->jac_d_evals());
     467                     p2ip_nlp->jac_d_evals());
    454468      jnlst_->Printf(J_SUMMARY, J_STATISTICS,
    455469                     "Number of Lagrangian Hessian evaluations             = %d\n",
    456                      ip_nlp_->h_evals());
     470                     p2ip_nlp->h_evals());
    457471
    458472      // Write EXIT message
     
    486500        return retValue;
    487501      }
    488       ip_nlp_->FinalizeSolution(status,
    489                                 *ip_data_->curr()->x(),
    490                                 *ip_data_->curr()->z_L(),
    491                                 *ip_data_->curr()->z_U(),
    492                                 *ip_cq_->curr_c(), *ip_cq_->curr_d(),
    493                                 *ip_data_->curr()->y_c(),
    494                                 *ip_data_->curr()->y_d(),
    495                                 ip_cq_->curr_f());
     502      p2ip_nlp->FinalizeSolution(status,
     503                                 *p2ip_data->curr()->x(),
     504                                 *p2ip_data->curr()->z_L(),
     505                                 *p2ip_data->curr()->z_U(),
     506                                 *p2ip_cq->curr_c(), *p2ip_cq->curr_d(),
     507                                 *p2ip_data->curr()->y_c(),
     508                                 *p2ip_data->curr()->y_d(),
     509                                 p2ip_cq->curr_f());
    496510      // Create a SolveStatistics object
    497       statistics_ = new SolveStatistics(ip_nlp_, ip_data_, ip_cq_);
     511      statistics_ = new SolveStatistics(p2ip_nlp, p2ip_data, p2ip_cq);
    498512    }
    499513    catch(TOO_FEW_DOF& exc) {
  • branches/dev/Interfaces/IpIpoptApplication.hpp

    r517 r518  
    1212#include "IpJournalist.hpp"
    1313#include "IpTNLP.hpp"
     14#include "IpNLP.hpp"
    1415#include "IpRegOptions.hpp"
    1516#include "IpOptionsList.hpp"
     
    1819namespace Ipopt
    1920{
    20   /* Forward declarations */
    21   class NLP;
    22   class IpoptAlgorithm;
    23 
    2421  /* Return codes for the Optimize call for an application */
    2522#include "IpReturnCodes_inc.h"
     
    129126    SmartPtr<SolveStatistics> statistics_;
    130127
    131     /** Object with the algorithm sceleton */
    132     SmartPtr<IpoptAlgorithm> alg_;
     128    /** Object with the algorithm sceleton.  We need to use a SmartPtr
     129     *  to ReferencedObject, since otherwise we would have to include
     130     *  too many header files. */
     131    SmartPtr<ReferencedObject> alg_;
    133132
    134133    /** IpoptNLP Object for the NLP.  We keep this around for a
    135      *  ReOptimize warm start */
    136     SmartPtr<IpoptNLP> ip_nlp_;
     134     *  ReOptimize warm start.  We need to use a SmartPtr
     135     *  to ReferencedObject, since otherwise we would have to include
     136     *  too many header files. */
     137    SmartPtr<ReferencedObject> ip_nlp_;
    137138
    138139    /** IpoptData Object for the NLP.  We keep this around for a
    139      *  ReOptimize warm start */
    140     SmartPtr<IpoptData> ip_data_;
     140     *  ReOptimize warm start.  We need to use a SmartPtr
     141     *  to ReferencedObject, since otherwise we would have to include
     142     *  too many header files. */
     143    SmartPtr<ReferencedObject> ip_data_;
    141144
    142145    /** IpoptCalculatedQuantities Object for the NLP.  We keep this
    143      *  around for a ReOptimize warm start */
    144     SmartPtr<IpoptCalculatedQuantities> ip_cq_;
     146     *  around for a ReOptimize warm start.  We need to use a SmartPtr
     147     *  to ReferencedObject, since otherwise we would have to include
     148     *  too many header files. */
     149    SmartPtr<ReferencedObject> ip_cq_;
    145150
    146151    /** Pointer for journals (which are also in the Journalist) so
Note: See TracChangeset for help on using the changeset viewer.