Skip to content

Commit

Permalink
ticket #41: new signature for evaluate(*,*). Note: not backward compa…
Browse files Browse the repository at this point in the history
…tible for multiple derivative directions
  • Loading branch information
jaeandersson committed Mar 20, 2011
1 parent 16d8259 commit ac01e4b
Show file tree
Hide file tree
Showing 40 changed files with 51 additions and 52 deletions.
2 changes: 1 addition & 1 deletion casadi/fx/c_function_internal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ void CFunctionInternal::setUserData(void* user_data){
user_data_ = user_data;
}

void CFunctionInternal::evaluate_new(int nfdir, int nadir){
void CFunctionInternal::evaluate(int nfdir, int nadir){
casadi_assert_message(evaluate_!=0, "CFunctionInternal::evaluate: pointer is null");
evaluate_(ref_,nfdir,nadir,user_data_);
}
Expand Down
2 changes: 1 addition & 1 deletion casadi/fx/c_function_internal.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class CFunctionInternal : public FXInternal{
void setUserData(void* user_data);

/** \brief Evaluate */
virtual void evaluate_new(int nfdir, int nadir);
virtual void evaluate(int nfdir, int nadir);

/** \brief Initialize */
virtual void init();
Expand Down
2 changes: 1 addition & 1 deletion casadi/fx/external_function_internal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ ExternalFunctionInternal::~ExternalFunctionInternal(){
#endif // WITH_JIT
}

void ExternalFunctionInternal::evaluate_new(int nfdir, int nadir){
void ExternalFunctionInternal::evaluate(int nfdir, int nadir){
#ifdef WITH_JIT
int flag = evaluate_(&input_array_[0],&output_array_[0]);
if(flag) throw CasadiException("ExternalFunctionInternal: \"evaluate\" failed");
Expand Down
2 changes: 1 addition & 1 deletion casadi/fx/external_function_internal.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class ExternalFunctionInternal : public FXInternal{
virtual ~ExternalFunctionInternal();

/** \brief Evaluate */
virtual void evaluate_new(int nfdir, int nadir);
virtual void evaluate(int nfdir, int nadir);

/** \brief Initialize */
virtual void init();
Expand Down
12 changes: 6 additions & 6 deletions casadi/fx/fx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,20 +106,20 @@ MX FX::operator()(const vector<MX> &x, int ind) const{
}
#endif // USE_FUNCTORS

void FX::evaluate_new(int nfdir, int nadir){
void FX::evaluate(int nfdir, int nadir){
casadi_assert(isInit());
casadi_assert(nfdir<=(*this)->nfdir_);
casadi_assert(nadir<=(*this)->nadir_);
(*this)->evaluate_new(nfdir,nadir);
(*this)->evaluate(nfdir,nadir);
}

void FX::evaluate(int fsens_order, int asens_order){
evaluate_new(fsens_order * (*this)->nfdir_,
asens_order * (*this)->nadir_);
void FX::evaluate_old(int fsens_order, int asens_order){
evaluate(fsens_order * (*this)->nfdir_,
asens_order * (*this)->nadir_);
}

void FX::solve(){
evaluate_new(0,0);
evaluate(0,0);
}

int FX::getNumInputs() const{
Expand Down
6 changes: 3 additions & 3 deletions casadi/fx/fx.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,10 +107,10 @@ class FX : public OptionsFunctionality{
void setNumOutputs(int num_out);

/** \brief Evaluate (old style) */
void evaluate(int fsens_order=0, int asens_order=0);
void evaluate_old(int fsens_order=0, int asens_order=0);

/** \brief Evaluate (new style) */
void evaluate_new(int nfdir=0, int nadir=0);
/** \brief Evaluate */
void evaluate(int nfdir=0, int nadir=0);

/// the same as evaluate(0,0)
void solve();
Expand Down
2 changes: 1 addition & 1 deletion casadi/fx/fx_internal.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class FXInternal : public OptionsFunctionalityNode{
virtual ~FXInternal() = 0;

/** \brief Evaluate */
virtual void evaluate_new(int nfdir, int nadir) = 0;
virtual void evaluate(int nfdir, int nadir) = 0;

/** Initialize and make the object ready for setting arguments and evaluation. This method is typically called after setting options but before evaluating.
If passed to another class (in the constructor), this class should invoke this function when initialized. */
Expand Down
2 changes: 1 addition & 1 deletion casadi/fx/implicit_function_internal.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class ImplicitFunctionInternal : public FXInternal{
virtual void init();

/// Solve the system of equations
virtual void evaluate_new(int nfdir, int nadir) = 0;
virtual void evaluate(int nfdir, int nadir) = 0;

/// Sparsity in CRS format
FX f_;
Expand Down
2 changes: 1 addition & 1 deletion casadi/fx/integrator_internal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ void IntegratorInternal::setDimensions(int nx, int np, int nz){
output(INTEGRATOR_ZF) = DMatrix(nz_,1,0);
}

void IntegratorInternal::evaluate_new(int nfdir, int nadir){
void IntegratorInternal::evaluate(int nfdir, int nadir){
double t0 = input(INTEGRATOR_T0)[0];
double tf = input(INTEGRATOR_TF)[0];

Expand Down
2 changes: 1 addition & 1 deletion casadi/fx/integrator_internal.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ class IntegratorInternal : public FXInternal{
virtual void setStopTime(double tf) = 0;

/** \brief evaluate */
virtual void evaluate_new(int nfdir, int nadir);
virtual void evaluate(int nfdir, int nadir);

/** \brief Initialize */
virtual void init();
Expand Down
2 changes: 1 addition & 1 deletion casadi/fx/integrator_jacobian_internal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ void IntegratorJacobianInternal::init(){
FXInternal::init();
}

void IntegratorJacobianInternal::evaluate_new(int nfdir, int nadir){
void IntegratorJacobianInternal::evaluate(int nfdir, int nadir){

// Pass arguments to the integrator
integrator_.setInput(input(INTEGRATOR_T0),INTEGRATOR_T0);
Expand Down
2 changes: 1 addition & 1 deletion casadi/fx/integrator_jacobian_internal.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class IntegratorJacobianInternal : public FXInternal{
virtual IntegratorJacobianInternal* clone() const;

/** \brief evaluate */
virtual void evaluate_new(int nfdir, int nadir);
virtual void evaluate(int nfdir, int nadir);

/** \brief Initialize */
virtual void init();
Expand Down
6 changes: 3 additions & 3 deletions casadi/fx/jacobian_internal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ void JacobianInternal::init(){
}
}

void JacobianInternal::evaluate_new(int nfdir, int nadir){
void JacobianInternal::evaluate(int nfdir, int nadir){
// Pass the argument to the function
for(int i=0; i<input_.size(); ++i)
fcn_.setInput(input(i),i);
Expand All @@ -120,7 +120,7 @@ void JacobianInternal::evaluate_new(int nfdir, int nadir){
}

// Evaluate the AD forward algorithm
fcn_.evaluate(1,0);
fcn_.evaluate(nfdir_fcn_,0);

// Get the output seeds
for(int dir=0; dir<nfdir_fcn_ && ofs+dir<n_; ++dir){
Expand All @@ -143,7 +143,7 @@ void JacobianInternal::evaluate_new(int nfdir, int nadir){
}

// Evaluate the AD forward algorithm
fcn_.evaluate(0,1);
fcn_.evaluate(0,nadir_fcn_);

// Get the output seeds
for(int dir=0; dir<nadir_fcn_ && ofs+dir<m_; ++dir){
Expand Down
2 changes: 1 addition & 1 deletion casadi/fx/jacobian_internal.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class JacobianInternal : public FXInternal{
virtual ~JacobianInternal();

/// Evaluate the jacobian
virtual void evaluate_new(int nfdir, int nadir);
virtual void evaluate(int nfdir, int nadir);

/// Initialize
virtual void init();
Expand Down
2 changes: 1 addition & 1 deletion casadi/fx/linear_solver_internal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ void LinearSolverInternal::init(){
LinearSolverInternal::~LinearSolverInternal(){
}

void LinearSolverInternal::evaluate_new(int nfdir, int nadir){
void LinearSolverInternal::evaluate(int nfdir, int nadir){
/* Factorization fact;
if(called_once){
// Check if any element has changed
Expand Down
2 changes: 1 addition & 1 deletion casadi/fx/linear_solver_internal.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class LinearSolverInternal : public FXInternal{
virtual void init();

// Solve the system of equations
virtual void evaluate_new(int nfdir, int nadir);
virtual void evaluate(int nfdir, int nadir);

// Prepare the factorization
virtual void prepare() = 0;
Expand Down
2 changes: 1 addition & 1 deletion casadi/fx/mx_function_internal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ void MXFunctionInternal::setLiftingFunction(LiftingFunction liftfun, void* user_
liftfun_ud_ = user_data;
}

void MXFunctionInternal::evaluate_new(int nfdir, int nadir){
void MXFunctionInternal::evaluate(int nfdir, int nadir){
log("MXFunctionInternal::evaluate begin");
casadi_assert(nfdir<=nfdir_);
casadi_assert(nadir<=nadir_);
Expand Down
2 changes: 1 addition & 1 deletion casadi/fx/mx_function_internal.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ class MXFunctionInternal : public XFunctionInternal{
int findEl(const MX& mx) const;

/** \brief Evaluate the algorithm */
virtual void evaluate_new(int nfdir, int nadir);
virtual void evaluate(int nfdir, int nadir);

/** \brief Print description */
virtual void print(std::ostream &stream) const;
Expand Down
4 changes: 2 additions & 2 deletions casadi/fx/parallelizer_internal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ void ParallelizerInternal::init(){
save_corrected_input_ = getOption("save_corrected_input").toInt();
}

void ParallelizerInternal::evaluate_new(int nfdir, int nadir){
void ParallelizerInternal::evaluate(int nfdir, int nadir){
switch(mode_){
case SERIAL:
{
Expand Down Expand Up @@ -131,7 +131,7 @@ void ParallelizerInternal::evaluateTask(int task, int nfdir, int nadir){
}

// Evaluate
fcn.evaluate_new(nfdir, nadir);
fcn.evaluate(nfdir, nadir);

// Get the results
for(int j=outind_[task]; j<outind_[task+1]; ++j){
Expand Down
2 changes: 1 addition & 1 deletion casadi/fx/parallelizer_internal.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class ParallelizerInternal : public FXInternal{
virtual ~ParallelizerInternal();

/// Evaluate the all the tasks
virtual void evaluate_new(int nfdir, int nadir);
virtual void evaluate(int nfdir, int nadir);

/// Evaluate a single task
virtual void evaluateTask(int task, int nfdir, int nadir);
Expand Down
4 changes: 2 additions & 2 deletions casadi/fx/simulator_internal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ void SimulatorInternal::init(){
output_fcn_.init();
}

void SimulatorInternal::evaluate_new(int nfdir, int nadir){
void SimulatorInternal::evaluate(int nfdir, int nadir){

// Pass the parameters and initial state
integrator_.setInput(input(SIMULATOR_X0),INTEGRATOR_X0);
Expand Down Expand Up @@ -97,7 +97,7 @@ void SimulatorInternal::evaluate_new(int nfdir, int nadir){
output_fcn_.setFwdSeed(fwdSeed(SIMULATOR_P),OUTPUT_P);

// Evaluate output function
output_fcn_.evaluate(1,0);
output_fcn_.evaluate(nfdir,0);

// Save the output of the function
for(int i=0; i<output_.size(); ++i){
Expand Down
2 changes: 1 addition & 1 deletion casadi/fx/simulator_internal.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class SimulatorInternal : public FXInternal{
virtual void init();

/** \brief Integrate */
virtual void evaluate_new(int nfdir, int nadir);
virtual void evaluate(int nfdir, int nadir);

Integrator integrator_;
FX output_fcn_;
Expand Down
2 changes: 1 addition & 1 deletion casadi/fx/sx_function_internal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ SXFunctionInternal::~SXFunctionInternal(){
}


void SXFunctionInternal::evaluate_new(int nfdir, int nadir){
void SXFunctionInternal::evaluate(int nfdir, int nadir){

// Copy the function arguments to the work vector
for(int ind=0; ind<getNumInputs(); ++ind){
Expand Down
2 changes: 1 addition & 1 deletion casadi/fx/sx_function_internal.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class SXFunctionInternal : public XFunctionInternal{
virtual ~SXFunctionInternal();

/** \brief Evaluate the function with partial derivatives up to order ord */
virtual void evaluate_new(int nfdir, int nadir);
virtual void evaluate(int nfdir, int nadir);

/** \brief evaluate symbolically */
void evaluateSX(const std::vector<Matrix<SX> >& input_s, std::vector<Matrix<SX> >& output_s);
Expand Down
2 changes: 1 addition & 1 deletion casadi/mx/evaluation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ void Evaluation::evaluate(const VDptr& input, Dptr& output, const VVDptr& fwdSee
}

// Evaluate
fcn_.evaluate(nfwd>0, nadj>0);
fcn_.evaluate(nfwd, nadj);

// Get the adjoint sensitivities
for(int i=0; i<ndep(); ++i){
Expand Down
2 changes: 1 addition & 1 deletion interfaces/acado/acado_integrator_backend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ ACADO::returnValue AcadoIntegratorBackend::evaluate( const Vector &x0 ,
}
}

integrator_.evaluate(with_sens,0);
integrator_.evaluate(mu+mp,0);


Integrator::initializeOptions();
Expand Down
2 changes: 1 addition & 1 deletion interfaces/acado/acado_internal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ void AcadoInternal::init(){

}

void AcadoInternal::evaluate_new(int nfdir, int nadir){
void AcadoInternal::evaluate(int nfdir, int nadir){
// Initial constraint function
if(!rfcn_.f_.isNull()){
const Matrix<double>& lbr = input(ACADO_LBR);
Expand Down
2 changes: 1 addition & 1 deletion interfaces/acado/acado_internal.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ class AcadoInternal : public FXInternal{
virtual void init();

/** \brief Solve the problem */
virtual void evaluate_new(int nfdir, int nadir);
virtual void evaluate(int nfdir, int nadir);

// Dimensions
int nt_, nxd_, nxa_, nu_, np_, nxdot_;
Expand Down
2 changes: 1 addition & 1 deletion interfaces/ipopt/ipopt_internal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ void IpoptInternal::init(){
}
}

void IpoptInternal::evaluate_new(int nfdir, int nadir){
void IpoptInternal::evaluate(int nfdir, int nadir){
casadi_assert(nfdir==0 && nadir==0);

// Reset the counters
Expand Down
2 changes: 1 addition & 1 deletion interfaces/ipopt/ipopt_internal.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ friend class IpoptUserClass;
virtual ~IpoptInternal();

virtual void init();
virtual void evaluate_new(int nfdir, int nadir);
virtual void evaluate(int nfdir, int nadir);

protected:

Expand Down
2 changes: 1 addition & 1 deletion interfaces/liftopt/casadi_lifter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ long CasadiLifter::evalUserFcn ( liftopt::TLifterArgs<double>& args )
MXFunction& F = interface_->fcn_;
if(m_activeProblemFormulation == Problem_Residual ){
F.setInput(args.u,LO_U);
F.evaluate(0,0);
F.evaluate();
F.getOutput(args.objRes,LO_OBJRES);
F.getOutput(args.eq,LO_EQ);
}
Expand Down
2 changes: 1 addition & 1 deletion interfaces/liftopt/liftopt_internal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ void LiftoptInternal::init(){
fcn_.setLiftingFunction(CasadiLifter::liftfun, problem_);
}

void LiftoptInternal::evaluate_new(int nfdir, int nadir){
void LiftoptInternal::evaluate(int nfdir, int nadir){
// Evaluate
opt_->setStartControls ( uInit_ );
opt_->setStartEqMult( lambdaInit_ );
Expand Down
2 changes: 1 addition & 1 deletion interfaces/liftopt/liftopt_internal.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class LiftoptInternal : public NLPSolverInternal{
LiftoptInternal(const MXFunction& fcn);
virtual ~LiftoptInternal();
virtual void init();
virtual void evaluate_new(int nfdir, int nadir);
virtual void evaluate(int nfdir, int nadir);

std::vector<double> nodeInit;

Expand Down
2 changes: 1 addition & 1 deletion interfaces/sundials/cvodes_internal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -774,7 +774,7 @@ void CVodesInternal::rhsS(int Ns, double t, N_Vector y, N_Vector ydot, N_Vector
}

// Evaluate the AD forward algorithm
f_.evaluate(1,0);
f_.evaluate(nfdir_f_,0);

// Get the output seeds
for(int dir=0; dir<nfdir_f_ && j+dir<nfdir_; ++dir){
Expand Down
2 changes: 1 addition & 1 deletion interfaces/sundials/idas_internal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -675,7 +675,7 @@ void IdasInternal::resS(int Ns, double t, const double* yz, const double* yp, co
}

// Evaluate the AD forward algorithm
f_.evaluate(1,0);
f_.evaluate(nfdir_f_,0);

// Get the output seeds
for(int dir=0; dir<nfdir_f_ && j+dir<nfdir_; ++dir){
Expand Down
4 changes: 2 additions & 2 deletions interfaces/sundials/kinsol_internal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ void KinsolInternal::init(){
}
}

void KinsolInternal::evaluate_new(int nfdir, int nadir){
void KinsolInternal::evaluate(int nfdir, int nadir){
casadi_assert(nfdir<=nfdir_fcn_);
casadi_assert(nadir<=nadir_fcn_);

Expand Down Expand Up @@ -290,7 +290,7 @@ void KinsolInternal::evaluate_new(int nfdir, int nadir){
}

// Evaluate
f_.evaluate(nfdir>0,nadir>0); // FIXME: when evaluate is updated
f_.evaluate(nfdir,nadir);

// Solve for the forward sensitivities
for(int dir=0; dir<nfdir; ++dir){
Expand Down
Loading

0 comments on commit ac01e4b

Please sign in to comment.