Skip to content

Commit

Permalink
Merge branch 'main' of https://github.com/meco-group/fatrop
Browse files Browse the repository at this point in the history
  • Loading branch information
maximvochten committed Dec 11, 2024
2 parents 0136e40 + 5aaa5ee commit ff47184
Show file tree
Hide file tree
Showing 57 changed files with 1,078 additions and 779 deletions.
10 changes: 10 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -146,3 +146,13 @@ INSTALL(TARGETS ${INSTALL_TARGETS}
RUNTIME DESTINATION ${RUNTIME_INSTALL_DIR}
)
INSTALL(EXPORT fatropConfig NAMESPACE fatrop:: DESTINATION cmake)

# create an option for compiling the tests
option(BUILD_TESTS "Build tests" OFF)
# if the option is set to ON, add the tests directory
if(BUILD_TESTS)
enable_testing()
add_subdirectory(unittest)
endif()


2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ The main features of the solver are:

## Disclaimer

At this moment the easiest way to get specify fatrop problems is by using the [rockit](https://gitlab.kuleuven.be/meco-software/rockit) interface. See [Install rockit with Fatropy interface](#install-rockit-with-fatropy-interface) for installation instructions. The fatrop-rockit-plugin is not very stable yet, and still under development. Apart form the rockit interface, we are working on a ocp specification framework, especially developed for specifying Fatrop problems. An example is available in the **specification** branch, spectool/example.cpp.
At this moment the easiest way to get specify fatrop problems is by using the [rockit](https://gitlab.kuleuven.be/meco-software/rockit) interface. See [Install rockit with Fatropy interface](#install-rockit-with-fatropy-interface) for installation instructions. The fatrop-rockit-plugin is not very stable yet, and still under development. Apart form the rockit interface, we are working on a ocp specification framework, especially developed for specifying Fatrop problems.

The spectool has several advantages over the rockit interface:
- it supports fatrop problems in all its generality. For example: multi-stage problems are not supported by the fatrop-rockit-interface
Expand Down
1 change: 1 addition & 0 deletions fatrop/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ auxiliary/FatropVector.hpp auxiliary/FatropVector.cpp
auxiliary/LinearAlgebra.hpp auxiliary/LinearAlgebra.cpp
function_evaluation/FunctionEvaluation.hpp function_evaluation/FunctionEvaluation.cpp
ocp/OCPAbstract.hpp ocp/OCPAbstract.cpp
ocp/OCPApplication.hpp ocp/OCPApplication.cpp
ocp/StageOCPApplication.hpp ocp/StageOCPApplication.cpp
ocp/OCPAdapter.hpp ocp/OCPAdapter.cpp
ocp/StageOCP.hpp ocp/StageOCP.cpp
Expand Down
6 changes: 3 additions & 3 deletions fatrop/auxiliary/Common.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
*
* You should have received a copy of the GNU Lesser General Public License
* along with Fatrop. If not, see <http://www.gnu.org/licenses/>. */
#ifndef COMMONINCLUDED
#define COMMONINCLUDED
#ifndef __fatrop_auxiliary_common_hpp__
#define __fatrop_auxiliary_common_hpp__
#include <cassert>
#if DEBUG
#define DBGASSERT(assertion) assert(assertion);
Expand All @@ -31,4 +31,4 @@ namespace fatrop
bool CompareLessEqual(double lhs, double rhs);
bool CompareLessEqual(double lhs, double rhs, double ref);
} // namespace fatrop
#endif // COMMONINCLUDED
#endif // __fatrop_auxiliary_common_hpp__
6 changes: 3 additions & 3 deletions fatrop/auxiliary/DynamicLib.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
*
* You should have received a copy of the GNU Lesser General Public License
* along with Fatrop. If not, see <http://www.gnu.org/licenses/>. */
#ifndef DYNAMICLIBINCLUDED
#define DYNAMICLIBINCLUDED
#ifndef __fatrop_auxiliary_DynamicLib_hpp__
#define __fatrop_auxiliary_DynamicLib_hpp__
#include <dlfcn.h>
#include <string>
namespace fatrop
Expand All @@ -31,4 +31,4 @@ namespace fatrop
};

}; // namespace fatrop
#endif // DYNAMICLIBINCLUDED
#endif // __fatrop_auxiliary_DynamicLib_hpp__
6 changes: 3 additions & 3 deletions fatrop/auxiliary/FatropOptions.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
*
* You should have received a copy of the GNU Lesser General Public License
* along with Fatrop. If not, see <http://www.gnu.org/licenses/>. */
#ifndef FATROPOPTIONSINCLUDED
#define FATROPOPTIONSINCLUDED
#ifndef __fatrop_auxiliary_fatropoptions_hpp__
#define __fatrop_auxiliary_fatropoptions_hpp__
#include <string>
namespace fatrop
{
Expand Down Expand Up @@ -65,4 +65,4 @@ namespace fatrop
double upper_bound_;
};
} // namespace fatrop
#endif
#endif // __fatrop_auxiliary_fatropoptions_hpp__
6 changes: 3 additions & 3 deletions fatrop/auxiliary/FatropVector.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
*
* You should have received a copy of the GNU Lesser General Public License
* along with Fatrop. If not, see <http://www.gnu.org/licenses/>. */
#ifndef FATROP_VECTOR_INCLUDED
#define FATROP_VECTOR_INCLUDED
#ifndef __fatrop_auxiliary_FatropVector_hpp__
#define __fatrop_auxiliary_FatropVector_hpp__
#include <vector>
#include <assert.h>
#include <utility>
Expand Down Expand Up @@ -140,4 +140,4 @@ namespace fatrop
}
} // namespace fatrop

#endif // FATROP_VECTOR_INCLUDED
#endif // __fatrop_auxiliary_FatropVector_hpp__
6 changes: 3 additions & 3 deletions fatrop/auxiliary/LinearAlgebra.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@
* This file contains some interface classes for use in linear algebra.
*
*/
#ifndef FATROP_LA_INCLUDED
#define FATROP_LA_INCLUDED
#ifndef __fatrop_auxiliary_LinearAlgebra_hpp__
#define __fatrop_auxiliary_LinearAlgebra_hpp__
#include <iostream>
#include "fatrop/auxiliary/Common.hpp"

Expand Down Expand Up @@ -85,4 +85,4 @@ namespace fatrop
};
} // namespace fatrop

#endif // FATROP_LA_INCLUDED
#endif // __fatrop_auxiliary_LinearAlgebra_hpp__
6 changes: 3 additions & 3 deletions fatrop/auxiliary/VectorUtils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
*
* You should have received a copy of the GNU Lesser General Public License
* along with Fatrop. If not, see <http://www.gnu.org/licenses/>. */
#ifndef FATROPAUXILIARYINCLUDED
#define FATROPAUXILIARYINCLUDED
#ifndef __fatrop_auxiliary_VectorUtils_hpp__
#define __fatrop_auxiliary_VectorUtils_hpp__
#include <vector>
#include "FatropVector.hpp"
#include "fatrop/auxiliary/Common.hpp"
Expand Down Expand Up @@ -51,4 +51,4 @@ namespace fatrop
return res;
}
}; // namespace fatrop
#endif // FATROPAUXINCLUDED
#endif // __fatrop_auxiliary_VectorUtils_hpp__
8 changes: 5 additions & 3 deletions fatrop/blasfeo_wrapper/LinearAlgebraBlasfeo.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
*
* You should have received a copy of the GNU Lesser General Public License
* along with Fatrop. If not, see <http://www.gnu.org/licenses/>. */
#ifndef FATROP_BLASFEO_INCLUDED
#define FATROP_BLASFEO_INCLUDED
#ifndef __fatrop_blasfeo_wrapper_LinearAlgebraBlasfeo_hpp__
#define __fatrop_blasfeo_wrapper_LinearAlgebraBlasfeo_hpp__

// macros
extern "C"
Expand Down Expand Up @@ -124,7 +124,9 @@ void blasfeo_ref_dtrsm_rlnn_copy(int m, int n, double alpha, struct MAT *sA, int
#include <iostream>
extern "C"
{
#ifndef NOMINMAX
#define NOMINMAX
#endif
#include <blasfeo.h>
}
#include "fatrop/auxiliary/LinearAlgebra.hpp"
Expand Down Expand Up @@ -491,4 +493,4 @@ namespace fatrop
void fatrop_dtrsv_unu(const fatrop_int m, const fatrop_int n, blasfeo_dmat *sA, const fatrop_int ai, const fatrop_int aj, blasfeo_dvec *sx, const fatrop_int xi, blasfeo_dvec *sz, const fatrop_int zi);
void fatrop_dtrsv_utu(const fatrop_int m, blasfeo_dmat *sA, const fatrop_int ai, const fatrop_int aj, blasfeo_dvec *sx, const fatrop_int xi, blasfeo_dvec *sz, const fatrop_int zi);
} // namespace fatrop
#endif // FATROP_BLASFEO_INCLUDED
#endif // __fatrop_blasfeo_wrapper_LinearAlgebraBlasfeo_hpp__
6 changes: 3 additions & 3 deletions fatrop/fatrop.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
*
* You should have received a copy of the GNU Lesser General Public License
* along with Fatrop. If not, see <http://www.gnu.org/licenses/>. */
#ifndef FATROP_INCLUDED
#define FATROP_INCLUDED
#ifndef __fatrop_fatrop_hpp__
#define __fatrop_fatrop_hpp__
#include "fatrop/ocp/StageOCPApplication.hpp"
// #include "fatrop/blasfeo_wrapper/LinearAlgebraBlasfeo.hpp"
// #include "fatrop/ocp/OCPKKT.hpp"
Expand All @@ -36,4 +36,4 @@
// #include "fatrop/ocp/FatropOCPBuilder.hpp"

// #include "SparseSolvers/InterfaceMUMPS.hpp"
#endif //FATROP_INCLUDED
#endif //__fatrop_fatrop_hpp__
6 changes: 3 additions & 3 deletions fatrop/function_evaluation/CasadiCodegen.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
*
* You should have received a copy of the GNU Lesser General Public License
* along with Fatrop. If not, see <http://www.gnu.org/licenses/>. */
#ifndef CASADICODEGENINCLUDED
#define CASADICODEGENINCLUDED
#ifndef __fatrop_function_evaluation_CasadiCodegen_hpp__
#define __fatrop_function_evaluation_CasadiCodegen_hpp__
#include <vector>
#include <string>
#include <memory>
Expand Down Expand Up @@ -101,4 +101,4 @@ namespace fatrop

} // fatrop

#endif // CASADICODEGENINCLUDED
#endif // __fatrop_function_evaluation_CasadiCodegen_hpp__
6 changes: 3 additions & 3 deletions fatrop/function_evaluation/FunctionEvaluation.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
*
* You should have received a copy of the GNU Lesser General Public License
* along with Fatrop. If not, see <http://www.gnu.org/licenses/>. */
#ifndef FUNCTIONEVALUATIONINCLUDED
#define FUNCTIONEVALUATIONINCLUDED
#ifndef __fatrop_function_evaluation_FunctionEvaluation_hpp__
#define __fatrop_function_evaluation_FunctionEvaluation_hpp__
#include <vector>
#include <cstring>
#include "fatrop/blasfeo_wrapper/LinearAlgebraBlasfeo.hpp"
Expand Down Expand Up @@ -57,4 +57,4 @@ namespace fatrop
~EvalBase(){};
};
}; // namespace fatrop
#endif // FUNCTIONEVALUATIONINCLUDED
#endif // __fatrop_function_evaluation_FunctionEvaluation_hpp__
1 change: 1 addition & 0 deletions fatrop/ocp/CasadiCApiUserdataWrap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#include <math.h>
#include "fatrop/ocp/StageOCPApplication.hpp"
#include "fatrop/ocp/OCPDims.hpp"
#include "fatrop/blasfeo_wrapper/LinearAlgebraBlasfeo.hpp"
// c++ stuff here
namespace fatrop
{
Expand Down
6 changes: 3 additions & 3 deletions fatrop/ocp/DuInfEvaluator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
*
* You should have received a copy of the GNU Lesser General Public License
* along with Fatrop. If not, see <http://www.gnu.org/licenses/>. */
#ifndef DUINFEVALINCLUDED
#define DUINFEVALINCLUDED
#ifndef __fatrop_function_evaluation_DuInfEvaluator_hpp__
#define __fatrop_function_evaluation_DuInfEvaluator_hpp__
#include "fatrop/blasfeo_wrapper/LinearAlgebraBlasfeo.hpp"
#include "OCPKKT.hpp"
#include "fatrop/auxiliary/Common.hpp"
Expand All @@ -35,4 +35,4 @@ namespace fatrop
FatropVecBF &du_inf);
};
}
#endif // DUINFEVALINCLUDED
#endif // __fatrop_function_evaluation_DuInfEvaluator_hpp__
10 changes: 7 additions & 3 deletions fatrop/ocp/FatropOCP.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,6 @@ FatropOCP::FatropOCP(
lam_test(nlpdims_.neqs, 1),
delta_s_test(nlpdims_.nineqs, 1), lsscaler_(dims_)
{
options_->register_option(BooleanOption("iterative_refinement_SOC", "Use iterative refinement for SOC", &it_ref, true));
options_->register_option(BooleanOption("ls_scaling", "Use automatic scaling for linear system", &ls_scaling, true));
}
int FatropOCP::eval_lag_hess(
double obj_scale,
Expand Down Expand Up @@ -358,4 +356,10 @@ void FatropOCP::finalize()
void FatropOCP::reset()
{
ocp_->reset();
}
}
void FatropOCP::update_options(const FatropOptions &options)
{
it_ref = options.iterative_refinement_SOC.get();
ls_scaling = options.ls_scaling.get();
ls_ -> update_options(options);
};
7 changes: 4 additions & 3 deletions fatrop/ocp/FatropOCP.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
*
* You should have received a copy of the GNU Lesser General Public License
* along with Fatrop. If not, see <http://www.gnu.org/licenses/>. */
#ifndef OCPALGINCLUDED
#define OCPALGINCLUDED
#ifndef __fatrop_ocp_FatropOCP_hpp__
#define __fatrop_ocp_FatropOCP_hpp__
#include "fatrop/blasfeo_wrapper/LinearAlgebraBlasfeo.hpp"
#include "fatrop/templates/NLPAlg.hpp"
#include "OCPKKT.hpp"
Expand Down Expand Up @@ -117,6 +117,7 @@ namespace fatrop
NLPDims get_nlp_dims() const override;
void finalize() override;
void reset() override;
void update_options(const FatropOptions& options) override;

public:
std::shared_ptr<OCP> ocp_;
Expand Down Expand Up @@ -158,4 +159,4 @@ namespace fatrop
OCPLSScaler lsscaler_;
};
} // namespace fatrop
#endif // OCPALGINCLUDED
#endif // __fatrop_ocp_FatropOCP_hpp__
6 changes: 3 additions & 3 deletions fatrop/ocp/FatropOCPBuilder.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
*
* You should have received a copy of the GNU Lesser General Public License
* along with Fatrop. If not, see <http://www.gnu.org/licenses/>. */
#ifndef FATROPOCPBUILDERINCLUDED
#define FATROPOCPBUILDERINCLUDED
#ifndef __fatrop_ocp_FatropOCPBuilder_hpp__
#define __fatrop_ocp_FatropOCPBuilder_hpp__
#include "fatrop/ocp/OCP.hpp"
#include "fatrop/ocp/FatropOCP.hpp"
#include "fatrop/ocp/OCPAbstract.hpp"
Expand Down Expand Up @@ -49,4 +49,4 @@ namespace fatrop
};
}

#endif // !OCPALGBUILDERINCLUDED
#endif // __fatrop_ocp_FatropOCPBuilder_hpp__
7 changes: 5 additions & 2 deletions fatrop/ocp/FatropOCPResto.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ namespace fatrop
public:
FatropOCPResto(const std::shared_ptr<FatropOCP> &orig, const std::shared_ptr<FatropOptions> &opts) : orig_(orig), orig_dims_(orig->get_nlp_dims()), lower_(orig_dims_.nineqs), upper_(orig_dims_.nineqs), x_start_(orig_dims_.nvars), s_start_(orig_dims_.nineqs), x_tmp_(orig_dims_.nvars), s_tmp_(orig_dims_.nineqs), upper_bounded_(orig_dims_.nineqs), lower_bounded_(orig_dims_.nineqs), slack_dummy_(orig_dims_.nineqs), sigma_dummy_(orig_dims_.nineqs), gradb_dummy_(orig_dims_.nineqs), zl_dummy_(orig_dims_.nineqs), zu_dummy_(orig_dims_.nineqs), sigma_cache_(orig_dims_.nineqs * 3), gradb_cache_(orig_dims_.nineqs * 3)
{
opts->register_option(DoubleOption::lower_bounded("resto_rho", "Resto L1 penalty parameter", &rho, 1000., 0.0));
opts->register_option(DoubleOption::lower_bounded("resto_xi", "Resto xi parameter", &xi, 1., 0.0));
auto lower_v = lower_[0];
auto upper_v = upper_[0];
orig_->get_bounds(lower_v, upper_v);
Expand Down Expand Up @@ -275,6 +273,11 @@ namespace fatrop
{
orig_->reset();
};
void update_options(const FatropOptions &options) override
{
rho = options.resto_rho.get();
xi = options.resto_xi.get();
};
std::shared_ptr<FatropOCP> orig_;
NLPDims orig_dims_;
NLPDims this_dims_;
Expand Down
6 changes: 3 additions & 3 deletions fatrop/ocp/OCP.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
*
* You should have received a copy of the GNU Lesser General Public License
* along with Fatrop. If not, see <http://www.gnu.org/licenses/>. */
#ifndef OCPINCLUDED
#define OCPINCLUDED
#ifndef __fatrop_ocp_OCP_hpp__
#define __fatrop_ocp_OCP_hpp__
#include "fatrop/blasfeo_wrapper/LinearAlgebraBlasfeo.hpp"
#include "OCPDims.hpp"
#include "fatrop/ocp/OCPKKT.hpp"
Expand Down Expand Up @@ -79,4 +79,4 @@ namespace fatrop
virtual void get_solution(const std::shared_ptr<FatropData> &fatropdata, std::vector<double> &u, std::vector<double> &x) = 0;
};
} // namespace fatrop
#endif // OCPINCLUDED
#endif // __fatrop_ocp_OCP_hpp__
6 changes: 3 additions & 3 deletions fatrop/ocp/OCPAbstract.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
*
* You should have received a copy of the GNU Lesser General Public License
* along with Fatrop. If not, see <http://www.gnu.org/licenses/>. */
#ifndef OCPTEMPLATEINCLUDED
#define OCPTEMPLATEINCLUDED
#ifndef __fatrop_ocp_OCPAbstract_hpp__
#define __fatrop_ocp_OCPAbstract_hpp__
#include "fatrop/ocp/OCPKKT.hpp"
#include "fatrop/blasfeo_wrapper/LinearAlgebraBlasfeo.hpp"
#include "fatrop/auxiliary/FatropVector.hpp"
Expand Down Expand Up @@ -251,4 +251,4 @@ namespace fatrop
}
};
}; // namespace fatrop
#endif // OCPTEMPLATEINCLUDED
#endif // __fatrop_ocp_OCPAbstract_hpp__
6 changes: 3 additions & 3 deletions fatrop/ocp/OCPAdapter.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
*
* You should have received a copy of the GNU Lesser General Public License
* along with Fatrop. If not, see <http://www.gnu.org/licenses/>. */
#ifndef OCPEVALUATORINCLUDED
#define OCPEVALUATORINCLUDED
#ifndef __fatrop_ocp_OCPAdapter_hpp__
#define __fatrop_ocp_OCPAdapter_hpp__
#include "OCPKKT.hpp"
#include "OCPAbstract.hpp"
#include "fatrop/solver/FatropData.hpp"
Expand Down Expand Up @@ -194,4 +194,4 @@ namespace fatrop
};
} // namespace fatrop

#endif // OCPEVALUATORINCLUDED
#endif // __fatrop_ocp_OCPAdapter_hpp__
Loading

0 comments on commit ff47184

Please sign in to comment.