diff --git a/CMakeLists.txt b/CMakeLists.txt
index 3aac940c..53032785 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -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()
+
+
diff --git a/README.md b/README.md
index 248b0a03..fb3af808 100644
--- a/README.md
+++ b/README.md
@@ -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
diff --git a/fatrop/CMakeLists.txt b/fatrop/CMakeLists.txt
index d46d3cd1..65396e4c 100644
--- a/fatrop/CMakeLists.txt
+++ b/fatrop/CMakeLists.txt
@@ -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
diff --git a/fatrop/auxiliary/Common.hpp b/fatrop/auxiliary/Common.hpp
index 637eb50e..5115120d 100644
--- a/fatrop/auxiliary/Common.hpp
+++ b/fatrop/auxiliary/Common.hpp
@@ -16,8 +16,8 @@
*
* You should have received a copy of the GNU Lesser General Public License
* along with Fatrop. If not, see . */
-#ifndef COMMONINCLUDED
-#define COMMONINCLUDED
+#ifndef __fatrop_auxiliary_common_hpp__
+#define __fatrop_auxiliary_common_hpp__
#include
#if DEBUG
#define DBGASSERT(assertion) assert(assertion);
@@ -31,4 +31,4 @@ namespace fatrop
bool CompareLessEqual(double lhs, double rhs);
bool CompareLessEqual(double lhs, double rhs, double ref);
} // namespace fatrop
-#endif // COMMONINCLUDED
\ No newline at end of file
+#endif // __fatrop_auxiliary_common_hpp__
\ No newline at end of file
diff --git a/fatrop/auxiliary/DynamicLib.hpp b/fatrop/auxiliary/DynamicLib.hpp
index b7683f2e..15329027 100644
--- a/fatrop/auxiliary/DynamicLib.hpp
+++ b/fatrop/auxiliary/DynamicLib.hpp
@@ -16,8 +16,8 @@
*
* You should have received a copy of the GNU Lesser General Public License
* along with Fatrop. If not, see . */
-#ifndef DYNAMICLIBINCLUDED
-#define DYNAMICLIBINCLUDED
+#ifndef __fatrop_auxiliary_DynamicLib_hpp__
+#define __fatrop_auxiliary_DynamicLib_hpp__
#include
#include
namespace fatrop
@@ -31,4 +31,4 @@ namespace fatrop
};
}; // namespace fatrop
-#endif // DYNAMICLIBINCLUDED
\ No newline at end of file
+#endif // __fatrop_auxiliary_DynamicLib_hpp__
\ No newline at end of file
diff --git a/fatrop/auxiliary/FatropOptions.hpp b/fatrop/auxiliary/FatropOptions.hpp
index 1b1d6f61..d8ef9732 100644
--- a/fatrop/auxiliary/FatropOptions.hpp
+++ b/fatrop/auxiliary/FatropOptions.hpp
@@ -16,8 +16,8 @@
*
* You should have received a copy of the GNU Lesser General Public License
* along with Fatrop. If not, see . */
-#ifndef FATROPOPTIONSINCLUDED
-#define FATROPOPTIONSINCLUDED
+#ifndef __fatrop_auxiliary_fatropoptions_hpp__
+#define __fatrop_auxiliary_fatropoptions_hpp__
#include
namespace fatrop
{
@@ -65,4 +65,4 @@ namespace fatrop
double upper_bound_;
};
} // namespace fatrop
-#endif
\ No newline at end of file
+#endif // __fatrop_auxiliary_fatropoptions_hpp__
\ No newline at end of file
diff --git a/fatrop/auxiliary/FatropVector.hpp b/fatrop/auxiliary/FatropVector.hpp
index 69acc43e..6e281797 100644
--- a/fatrop/auxiliary/FatropVector.hpp
+++ b/fatrop/auxiliary/FatropVector.hpp
@@ -16,8 +16,8 @@
*
* You should have received a copy of the GNU Lesser General Public License
* along with Fatrop. If not, see . */
-#ifndef FATROP_VECTOR_INCLUDED
-#define FATROP_VECTOR_INCLUDED
+#ifndef __fatrop_auxiliary_FatropVector_hpp__
+#define __fatrop_auxiliary_FatropVector_hpp__
#include
#include
#include
@@ -140,4 +140,4 @@ namespace fatrop
}
} // namespace fatrop
-#endif // FATROP_VECTOR_INCLUDED
+#endif // __fatrop_auxiliary_FatropVector_hpp__
diff --git a/fatrop/auxiliary/LinearAlgebra.hpp b/fatrop/auxiliary/LinearAlgebra.hpp
index 858625c2..b781b819 100644
--- a/fatrop/auxiliary/LinearAlgebra.hpp
+++ b/fatrop/auxiliary/LinearAlgebra.hpp
@@ -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
#include "fatrop/auxiliary/Common.hpp"
@@ -85,4 +85,4 @@ namespace fatrop
};
} // namespace fatrop
-#endif // FATROP_LA_INCLUDED
\ No newline at end of file
+#endif // __fatrop_auxiliary_LinearAlgebra_hpp__
\ No newline at end of file
diff --git a/fatrop/auxiliary/VectorUtils.hpp b/fatrop/auxiliary/VectorUtils.hpp
index 3a784698..53ffcd60 100644
--- a/fatrop/auxiliary/VectorUtils.hpp
+++ b/fatrop/auxiliary/VectorUtils.hpp
@@ -16,8 +16,8 @@
*
* You should have received a copy of the GNU Lesser General Public License
* along with Fatrop. If not, see . */
-#ifndef FATROPAUXILIARYINCLUDED
-#define FATROPAUXILIARYINCLUDED
+#ifndef __fatrop_auxiliary_VectorUtils_hpp__
+#define __fatrop_auxiliary_VectorUtils_hpp__
#include
#include "FatropVector.hpp"
#include "fatrop/auxiliary/Common.hpp"
@@ -51,4 +51,4 @@ namespace fatrop
return res;
}
}; // namespace fatrop
-#endif // FATROPAUXINCLUDED
\ No newline at end of file
+#endif // __fatrop_auxiliary_VectorUtils_hpp__
\ No newline at end of file
diff --git a/fatrop/blasfeo_wrapper/LinearAlgebraBlasfeo.hpp b/fatrop/blasfeo_wrapper/LinearAlgebraBlasfeo.hpp
index 79fe4c63..11bcb228 100644
--- a/fatrop/blasfeo_wrapper/LinearAlgebraBlasfeo.hpp
+++ b/fatrop/blasfeo_wrapper/LinearAlgebraBlasfeo.hpp
@@ -16,8 +16,8 @@
*
* You should have received a copy of the GNU Lesser General Public License
* along with Fatrop. If not, see . */
-#ifndef FATROP_BLASFEO_INCLUDED
-#define FATROP_BLASFEO_INCLUDED
+#ifndef __fatrop_blasfeo_wrapper_LinearAlgebraBlasfeo_hpp__
+#define __fatrop_blasfeo_wrapper_LinearAlgebraBlasfeo_hpp__
// macros
extern "C"
@@ -124,7 +124,9 @@ void blasfeo_ref_dtrsm_rlnn_copy(int m, int n, double alpha, struct MAT *sA, int
#include
extern "C"
{
+#ifndef NOMINMAX
#define NOMINMAX
+#endif
#include
}
#include "fatrop/auxiliary/LinearAlgebra.hpp"
@@ -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__
diff --git a/fatrop/fatrop.hpp b/fatrop/fatrop.hpp
index 1e75d9a9..05956fbe 100644
--- a/fatrop/fatrop.hpp
+++ b/fatrop/fatrop.hpp
@@ -16,8 +16,8 @@
*
* You should have received a copy of the GNU Lesser General Public License
* along with Fatrop. If not, see . */
-#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"
@@ -36,4 +36,4 @@
// #include "fatrop/ocp/FatropOCPBuilder.hpp"
// #include "SparseSolvers/InterfaceMUMPS.hpp"
-#endif //FATROP_INCLUDED
\ No newline at end of file
+#endif //__fatrop_fatrop_hpp__
\ No newline at end of file
diff --git a/fatrop/function_evaluation/CasadiCodegen.hpp b/fatrop/function_evaluation/CasadiCodegen.hpp
index 4a8ea7dd..ab8b5ae8 100644
--- a/fatrop/function_evaluation/CasadiCodegen.hpp
+++ b/fatrop/function_evaluation/CasadiCodegen.hpp
@@ -16,8 +16,8 @@
*
* You should have received a copy of the GNU Lesser General Public License
* along with Fatrop. If not, see . */
-#ifndef CASADICODEGENINCLUDED
-#define CASADICODEGENINCLUDED
+#ifndef __fatrop_function_evaluation_CasadiCodegen_hpp__
+#define __fatrop_function_evaluation_CasadiCodegen_hpp__
#include
#include
#include
@@ -101,4 +101,4 @@ namespace fatrop
} // fatrop
-#endif // CASADICODEGENINCLUDED
\ No newline at end of file
+#endif // __fatrop_function_evaluation_CasadiCodegen_hpp__
\ No newline at end of file
diff --git a/fatrop/function_evaluation/FunctionEvaluation.hpp b/fatrop/function_evaluation/FunctionEvaluation.hpp
index 0abb4efc..a34c9f36 100644
--- a/fatrop/function_evaluation/FunctionEvaluation.hpp
+++ b/fatrop/function_evaluation/FunctionEvaluation.hpp
@@ -16,8 +16,8 @@
*
* You should have received a copy of the GNU Lesser General Public License
* along with Fatrop. If not, see . */
-#ifndef FUNCTIONEVALUATIONINCLUDED
-#define FUNCTIONEVALUATIONINCLUDED
+#ifndef __fatrop_function_evaluation_FunctionEvaluation_hpp__
+#define __fatrop_function_evaluation_FunctionEvaluation_hpp__
#include
#include
#include "fatrop/blasfeo_wrapper/LinearAlgebraBlasfeo.hpp"
@@ -57,4 +57,4 @@ namespace fatrop
~EvalBase(){};
};
}; // namespace fatrop
-#endif // FUNCTIONEVALUATIONINCLUDED
+#endif // __fatrop_function_evaluation_FunctionEvaluation_hpp__
diff --git a/fatrop/ocp/CasadiCApiUserdataWrap.cpp b/fatrop/ocp/CasadiCApiUserdataWrap.cpp
index 70fb9b17..d6dce254 100644
--- a/fatrop/ocp/CasadiCApiUserdataWrap.cpp
+++ b/fatrop/ocp/CasadiCApiUserdataWrap.cpp
@@ -2,6 +2,7 @@
#include
#include "fatrop/ocp/StageOCPApplication.hpp"
#include "fatrop/ocp/OCPDims.hpp"
+#include "fatrop/blasfeo_wrapper/LinearAlgebraBlasfeo.hpp"
// c++ stuff here
namespace fatrop
{
diff --git a/fatrop/ocp/DuInfEvaluator.hpp b/fatrop/ocp/DuInfEvaluator.hpp
index 96c112c5..090c3125 100644
--- a/fatrop/ocp/DuInfEvaluator.hpp
+++ b/fatrop/ocp/DuInfEvaluator.hpp
@@ -16,8 +16,8 @@
*
* You should have received a copy of the GNU Lesser General Public License
* along with Fatrop. If not, see . */
-#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"
@@ -35,4 +35,4 @@ namespace fatrop
FatropVecBF &du_inf);
};
}
-#endif // DUINFEVALINCLUDED
\ No newline at end of file
+#endif // __fatrop_function_evaluation_DuInfEvaluator_hpp__
\ No newline at end of file
diff --git a/fatrop/ocp/FatropOCP.cpp b/fatrop/ocp/FatropOCP.cpp
index 34210311..2e5e3563 100644
--- a/fatrop/ocp/FatropOCP.cpp
+++ b/fatrop/ocp/FatropOCP.cpp
@@ -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,
@@ -358,4 +356,10 @@ void FatropOCP::finalize()
void FatropOCP::reset()
{
ocp_->reset();
-}
\ No newline at end of file
+}
+void FatropOCP::update_options(const FatropOptions &options)
+{
+ it_ref = options.iterative_refinement_SOC.get();
+ ls_scaling = options.ls_scaling.get();
+ ls_ -> update_options(options);
+};
\ No newline at end of file
diff --git a/fatrop/ocp/FatropOCP.hpp b/fatrop/ocp/FatropOCP.hpp
index 280fea2d..168968da 100644
--- a/fatrop/ocp/FatropOCP.hpp
+++ b/fatrop/ocp/FatropOCP.hpp
@@ -16,8 +16,8 @@
*
* You should have received a copy of the GNU Lesser General Public License
* along with Fatrop. If not, see . */
-#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"
@@ -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_;
@@ -158,4 +159,4 @@ namespace fatrop
OCPLSScaler lsscaler_;
};
} // namespace fatrop
-#endif // OCPALGINCLUDED
\ No newline at end of file
+#endif // __fatrop_ocp_FatropOCP_hpp__
\ No newline at end of file
diff --git a/fatrop/ocp/FatropOCPBuilder.hpp b/fatrop/ocp/FatropOCPBuilder.hpp
index bbd986b1..e3f55049 100644
--- a/fatrop/ocp/FatropOCPBuilder.hpp
+++ b/fatrop/ocp/FatropOCPBuilder.hpp
@@ -16,8 +16,8 @@
*
* You should have received a copy of the GNU Lesser General Public License
* along with Fatrop. If not, see . */
-#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"
@@ -49,4 +49,4 @@ namespace fatrop
};
}
-#endif // !OCPALGBUILDERINCLUDED
\ No newline at end of file
+#endif // __fatrop_ocp_FatropOCPBuilder_hpp__
\ No newline at end of file
diff --git a/fatrop/ocp/FatropOCPResto.hpp b/fatrop/ocp/FatropOCPResto.hpp
index 3386a0af..70e30086 100644
--- a/fatrop/ocp/FatropOCPResto.hpp
+++ b/fatrop/ocp/FatropOCPResto.hpp
@@ -9,8 +9,6 @@ namespace fatrop
public:
FatropOCPResto(const std::shared_ptr &orig, const std::shared_ptr &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);
@@ -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 orig_;
NLPDims orig_dims_;
NLPDims this_dims_;
diff --git a/fatrop/ocp/OCP.hpp b/fatrop/ocp/OCP.hpp
index 5c824c2b..faa2d4cd 100644
--- a/fatrop/ocp/OCP.hpp
+++ b/fatrop/ocp/OCP.hpp
@@ -16,8 +16,8 @@
*
* You should have received a copy of the GNU Lesser General Public License
* along with Fatrop. If not, see . */
-#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"
@@ -79,4 +79,4 @@ namespace fatrop
virtual void get_solution(const std::shared_ptr &fatropdata, std::vector &u, std::vector &x) = 0;
};
} // namespace fatrop
-#endif // OCPINCLUDED
\ No newline at end of file
+#endif // __fatrop_ocp_OCP_hpp__
\ No newline at end of file
diff --git a/fatrop/ocp/OCPAbstract.hpp b/fatrop/ocp/OCPAbstract.hpp
index da4eed50..36864464 100644
--- a/fatrop/ocp/OCPAbstract.hpp
+++ b/fatrop/ocp/OCPAbstract.hpp
@@ -16,8 +16,8 @@
*
* You should have received a copy of the GNU Lesser General Public License
* along with Fatrop. If not, see . */
-#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"
@@ -251,4 +251,4 @@ namespace fatrop
}
};
}; // namespace fatrop
-#endif // OCPTEMPLATEINCLUDED
\ No newline at end of file
+#endif // __fatrop_ocp_OCPAbstract_hpp__
\ No newline at end of file
diff --git a/fatrop/ocp/OCPAdapter.hpp b/fatrop/ocp/OCPAdapter.hpp
index c54674f2..1b8391ed 100644
--- a/fatrop/ocp/OCPAdapter.hpp
+++ b/fatrop/ocp/OCPAdapter.hpp
@@ -16,8 +16,8 @@
*
* You should have received a copy of the GNU Lesser General Public License
* along with Fatrop. If not, see . */
-#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"
@@ -194,4 +194,4 @@ namespace fatrop
};
} // namespace fatrop
-#endif // OCPEVALUATORINCLUDED
\ No newline at end of file
+#endif // __fatrop_ocp_OCPAdapter_hpp__
\ No newline at end of file
diff --git a/fatrop/ocp/OCPApplication.cpp b/fatrop/ocp/OCPApplication.cpp
new file mode 100644
index 00000000..88af83e9
--- /dev/null
+++ b/fatrop/ocp/OCPApplication.cpp
@@ -0,0 +1,195 @@
+#include "fatrop/ocp/OCPApplication.hpp"
+#include "fatrop/solver/AlgBuilder.hpp"
+#include "fatrop/ocp/OCPAdapter.hpp"
+#include "fatrop/ocp/FatropOCP.hpp"
+#include "fatrop/ocp/FatropOCPResto.hpp"
+#include "fatrop/ocp/FatropOCPBuilder.hpp"
+#include "fatrop/solver/FatropAlg.hpp"
+#include "fatrop/ocp/OCPAbstract.hpp"
+#include "fatrop/json/json.h"
+#include "fatrop/auxiliary/Common.hpp"
+#include "fatrop/solver/NLPL1.hpp"
+using namespace fatrop;
+using namespace std;
+NLPApplication::NLPApplication() : fatropoptions_(make_shared()), dirty(true), options_registry(make_shared(*fatropoptions_.get()))
+{
+ if (printer_ == nullptr)
+ {
+ printer_ = std::make_shared();
+ }
+}
+
+void NLPApplication::build(const shared_ptr &nlp, const shared_ptr &nlp_resto)
+{
+ // keep nlp around for getting nlpdims
+ nlp_ = nlp;
+ // check if prebuilt option "inequality_handling" is in prebuilt options
+ if (fatropoptions_->inequality_handling.get() == "pd_ip")
+ {
+ }
+ else if(fatropoptions_->inequality_handling.get() == "L1_pen")
+ {
+ nlp_ = std::make_shared(nlp, fatropoptions_);
+ }
+ else
+ {
+ throw std::runtime_error("Unknown inequality handling method: " + fatropoptions_->inequality_handling.get());
+ }
+ std::shared_ptr fatropdata_resto;
+ algbuilder = std::make_shared();
+ algbuilder -> set_printer(printer_);
+ algbuilder -> build_fatrop_algorithm_objects(nlp_, nlp_resto, fatropoptions_, fatropdata_, fatropdata_resto, journaller_);
+ printer_ -> print_level() = fatropoptions_->print_level.get();
+ // fatropoptions_->register_option(IntegerOption::un_bounded("print_level", "prfatrop_fatrop_int level", &printer_->print_level(), 10));
+ fatropalg_ = algbuilder -> build_algorithm();
+ dirty = false;
+}
+
+fatrop_int NLPApplication::optimize() const
+{
+ assert(!dirty);
+ // update options
+ algbuilder -> update_options(*fatropoptions_);
+ // solve optimization problem
+ fatrop_int ret = fatropalg_->optimize();
+ return ret;
+}
+// TODO: make this protected and use last_solution instead and choose other name
+const FatropVecBF &NLPApplication::last_solution_primal() const
+{
+ assert(!dirty);
+ return fatropdata_->x_curr;
+}
+FatropVecBF &NLPApplication::initial_guess_primal() const
+{
+ assert(!dirty);
+ return fatropdata_->x_initial;
+}
+FatropStats NLPApplication::get_stats() const
+{
+ return fatropalg_->get_stats();
+}
+NLPDims NLPApplication::get_nlp_dims()
+{
+ return nlp_->get_nlp_dims();
+}
+const FatropVecBF &NLPApplication::last_solution_dual() const
+{
+ return fatropdata_->lam_curr;
+}
+const FatropVecBF &NLPApplication::last_solution_zL() const
+{
+ return fatropdata_->zL_curr;
+}
+const FatropVecBF &NLPApplication::last_solution_zU() const
+{
+ return fatropdata_->zU_curr;
+}
+FatropVecBF &NLPApplication::initial_guess_dual() const
+{
+ return fatropdata_->lam_init;
+}
+FatropVecBF &NLPApplication::initial_guess_zL() const
+{
+ return fatropdata_->zL_init;
+}
+FatropVecBF &NLPApplication::initial_guess_zU() const
+{
+ return fatropdata_->zU_init;
+}
+template
+void NLPApplication::set_option(const string &option_name, T value)
+{
+ options_registry->set(option_name, value);
+}
+template void NLPApplication::set_option(const string &, int);
+template void NLPApplication::set_option(const string &, double);
+template void NLPApplication::set_option(const string &, bool);
+template void NLPApplication::set_option(const string &, string);
+template void NLPApplication::set_option(const string &, const string&);
+
+void NLPApplication::set_initial(const FatropSolution &initial_guess) const
+{
+ initial_guess_primal() = initial_guess.sol_primal_;
+ initial_guess_dual() = initial_guess.sol_dual_;
+ initial_guess_zL() = initial_guess.sol_zL_;
+ initial_guess_zU() = initial_guess.sol_zU_;
+}
+void NLPApplication::set_initial(const std::vector &initial_guess_primal_) const
+{
+ initial_guess_primal() = initial_guess_primal_;
+}
+const FatropOptions &NLPApplication::get_options() const
+{
+ return *fatropoptions_;
+}
+
+// TODO move this class to a separate file
+OCPAbstractApplication::OCPAbstractApplication(const shared_ptr &ocp)
+{
+ adapter = make_shared(ocp, fatropoptions_);
+ ocp_ = adapter;
+}
+
+void OCPApplication::build()
+{
+ // keep the adapter around for accessing the parameters for samplers and parameter setters
+ shared_ptr nlp_resto(make_shared(FatropOCPBuilder(ocp_, fatropoptions_, printer_).build(ocp_), fatropoptions_));
+ shared_ptr nlp(FatropOCPBuilder(ocp_, fatropoptions_, printer_).build(ocp_));
+ NLPApplication::build(nlp, nlp_resto);
+ dirty = false;
+}
+void OCPAbstractApplication::set_params(const std::vector &global_params, const std::vector &stage_params)
+{
+ adapter->set_parameters(stage_params, global_params);
+}
+
+vector &OCPAbstractApplication::global_parameters()
+{
+ assert(!dirty);
+ return adapter->get_global_parameters_vec();
+}
+vector &OCPAbstractApplication::stage_parameters()
+{
+ assert(!dirty);
+ return adapter->get_stage_parameters_vec();
+}
+
+
+OCPApplication::OCPApplication(const std::shared_ptr &ocp):ocp_(ocp)
+{
+
+}
+OCPApplication::OCPApplication():ocp_(nullptr)
+{
+
+}
+void OCPApplication::set_initial(vector &initial_u, vector &initial_x)
+{
+ assert(!dirty);
+ ocp_->set_initial_sol_guess(fatropdata_, initial_u, initial_x);
+}
+OCPDims OCPApplication::get_ocp_dims()
+{
+ return ocp_->get_ocp_dims();
+}
+
+FatropSolution::FatropSolution(){};
+void FatropSolution::set_dims(const NLPDims &dims)
+{
+ sol_primal_.resize(dims.nvars);
+ sol_dual_.resize(dims.neqs);
+ sol_zL_.resize(dims.nineqs);
+ sol_zU_.resize(dims.nineqs);
+};
+void FatropSolution::set_solution(const FatropVecBF &sol_primal, const FatropVecBF &sol_dual, const FatropVecBF &sol_zL, const FatropVecBF &sol_zU)
+{
+ sol_primal.block(0, sol_primal_.size()).copyto(sol_primal_);
+ sol_dual.block(0, sol_dual_.size()).copyto(sol_dual_);
+ sol_zL.block(0, sol_zL_.size()).copyto(sol_zL_);
+ sol_zU.block(0,sol_zU_.size()).copyto(sol_zU_);
+};
+void FatropSolution::set_primal_solution(const FatropVecBF &sol)
+{
+ sol.block(0, sol_primal_.size()).copyto(sol_primal_);
+}
\ No newline at end of file
diff --git a/fatrop/ocp/OCPApplication.hpp b/fatrop/ocp/OCPApplication.hpp
new file mode 100644
index 00000000..b43967fd
--- /dev/null
+++ b/fatrop/ocp/OCPApplication.hpp
@@ -0,0 +1,140 @@
+/*
+ * Fatrop - A fast trajectory optimization solver
+ * Copyright (C) 2022 - 2024 Lander Vanroye, KU Leuven. All rights reserved.
+ *
+ * This file is part of Fatrop.
+ *
+ * Fatrop is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Fatrop is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with Fatrop. If not, see . */
+#ifndef __fatrop_ocp_OCPApplication_hpp__
+#define __fatrop_ocp_OCPApplication_hpp__
+#include "fatrop/solver/FatropStats.hpp"
+#include "fatrop/ocp/StageOCPExpressions.hpp"
+#include