Skip to content

Commit

Permalink
wor on madnlp
Browse files Browse the repository at this point in the history
  • Loading branch information
jgillis committed Jul 13, 2024
1 parent 98bfd7f commit 5ce3d45
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 35 deletions.
2 changes: 1 addition & 1 deletion madnlp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ endif()

set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)

add_library(madnlp SHARED src/madnlp.cpp include/MadnlpCInterface.h)
add_library(madnlp SHARED src/madnlp.cpp include/madnlp_c.h)

if(WIN32)
set_target_properties(madnlp PROPERTIES PREFIX "" IMPORT_PREFIX "")
Expand Down
55 changes: 27 additions & 28 deletions madnlp/include/MadnlpCInterface.h → madnlp/include/madnlp_c.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#ifndef _MADNLPCINTERFACE_H
#define _MADNLPCINTERFACE_H
#ifndef _MADNLP_C_H
#define _MADNLP_C_H

#ifdef __cplusplus
extern "C" {
Expand Down Expand Up @@ -53,44 +53,44 @@ struct MadnlpCInterface {
MadnlpCEvalLagHess eval_lag_hess;

/// @brief number of variables
size_t nw;
madnlp_int nw;
/// @brief number of equality constraints
size_t nc;
madnlp_int nc;

size_t* nzj_i; // 1-based
size_t* nzj_j;
size_t* nzh_i;
size_t* nzh_j;
madnlp_int* nzj_i; // 1-based
madnlp_int* nzj_j;
madnlp_int* nzh_i;
madnlp_int* nzh_j;

size_t nnzj;
size_t nnzh;
size_t nnzo;
madnlp_int nnzj;
madnlp_int nnzh;
madnlp_int nnzo;

void* user_data;
};

struct MadnlpCNumericIn {
const double* x0;
const double* l0;
const double* ubx;
const double* lbx;
const double* ubg;
const double* lbg;
double* x0;
double* l0;
double* lbx;
double* ubx;
double* lbg;
double* ubg;
};

struct MadnlpCNumericOut {
double* sol;
double* con;
double* obj;
double* mul;
double* mul_L;
double* mul_U;

const double* sol;
const double* con;
const double* obj;
const double* mul;
const double* mul_L;
const double* mul_U;
};

MADNLP_SYMBOL_EXPORT void madnlp_c_startup(int, char**);
MADNLP_SYMBOL_EXPORT struct MadnlpCSolver* madnlp_c_create(struct MadnlpCInterface* nlp_interface);
MADNLP_SYMBOL_EXPORT madnlp_int madnlp_c_solve(struct MadnlpCSolver*, struct MadnlpCNumericIn* in, struct MadnlpCNumericOut* out);
MADNLP_SYMBOL_EXPORT const struct MadnlpCNumericIn* madnlp_c_input(struct MadnlpCSolver*);
MADNLP_SYMBOL_EXPORT const struct MadnlpCNumericOut* madnlp_c_output(struct MadnlpCSolver*);
MADNLP_SYMBOL_EXPORT madnlp_int madnlp_c_solve(struct MadnlpCSolver*);

/* -1 for not found, 0 for double, 1 for int, 2 for bool, 3 for string */
MADNLP_SYMBOL_EXPORT int madnlp_c_option_type(const char* name);
Expand All @@ -101,10 +101,9 @@ MADNLP_SYMBOL_EXPORT int madnlp_c_set_option_string(struct MadnlpCSolver* s, con

MADNLP_SYMBOL_EXPORT const struct MadnlpCStats* madnlp_c_get_stats(struct MadnlpCSolver* s);
MADNLP_SYMBOL_EXPORT void madnlp_c_destroy(struct MadnlpCSolver*);
MADNLP_SYMBOL_EXPORT void madnlp_c_shutdown(void);

#ifdef __cplusplus
}
#endif

#endif // _MADNLPCINTERFACE_H
#endif // _MADNLP_C_H
10 changes: 4 additions & 6 deletions madnlp/src/madnlp.cpp
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
#include "MadnlpCInterface.h"
#include "madnlp_c.h"

MADNLP_SYMBOL_EXPORT void madnlp_c_startup(int, char**) { }
MADNLP_SYMBOL_EXPORT struct MadnlpCSolver* madnlp_c_create(struct MadnlpCInterface* nlp_interface) { return 0; }
MADNLP_SYMBOL_EXPORT void madnlp_c_init(struct MadnlpCSolver* s) { }
MADNLP_SYMBOL_EXPORT void madnlp_c_update_cco_indexes(struct MadnlpCSolver* s) { }
MADNLP_SYMBOL_EXPORT madnlp_int madnlp_c_solve(struct MadnlpCSolver*) { return 0; }
MADNLP_SYMBOL_EXPORT madnlp_int madnlp_c_solve(struct MadnlpCSolver* s) { return 0; }
MADNLP_SYMBOL_EXPORT struct MadnlpCNumericIn* madnlp_c_input(struct MadnlpCSolver* s) { return 0; }
MADNLP_SYMBOL_EXPORT struct MadnlpCNumericOut* madnlp_c_output(struct MadnlpCSolver* s) { return 0; }

/* -1 for not found, 0 for double, 1 for int, 2 for bool, 3 for string */
MADNLP_SYMBOL_EXPORT int madnlp_c_option_type(const char* name) { return 0; }
Expand All @@ -13,7 +13,5 @@ MADNLP_SYMBOL_EXPORT int madnlp_c_set_option_bool(struct MadnlpCSolver* s, const
MADNLP_SYMBOL_EXPORT int madnlp_c_set_option_int(struct MadnlpCSolver* s, const char* name, int val) { return 0; }
MADNLP_SYMBOL_EXPORT int madnlp_c_set_option_string(struct MadnlpCSolver* s, const char* name, const char* val) { return 0; }

MADNLP_SYMBOL_EXPORT const struct MadnlpCDims* madnlp_c_get_dims(struct MadnlpCSolver* s) { return 0; }
MADNLP_SYMBOL_EXPORT const struct MadnlpCStats* madnlp_c_get_stats(struct MadnlpCSolver* s) { return 0; }
MADNLP_SYMBOL_EXPORT void madnlp_c_destroy(struct MadnlpCSolver*) { }
MADNLP_SYMBOL_EXPORT void madnlp_c_shutdown(void) { }

0 comments on commit 5ce3d45

Please sign in to comment.