Skip to content

Commit

Permalink
Add nS, nInf, sInf to solve.
Browse files Browse the repository at this point in the history
Added nS, nInf, sInf as output from solve calls in C interface for
SNOPTB/C.
  • Loading branch information
Elizabeth Wong committed Jan 10, 2017
1 parent 886623d commit 2ca240f
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 27 deletions.
8 changes: 6 additions & 2 deletions cexamples/toyB.c
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,9 @@ int main( int argc , char* argv[] )
int nnJac = 2;
int iObj = 2;
double ObjAdd = 0;
double objective;

int nS, nInf;
double objective, sInf;

// snInit must be called first.
// 9, 6 are print and summary unit numbers (for Fortran).
Expand Down Expand Up @@ -131,7 +133,9 @@ int main( int argc , char* argv[] )
setIntParameter( &toy, "Verify level", 3 );
setIntParameter( &toy, "Derivative option", 3 );

info = solveB( &toy, Cold, &objective );
nS = 0;

info = solveB( &toy, Cold, &objective, &nS, &nInf, &sInf );

// Deallocate space.
free ( toy.iu );
Expand Down
8 changes: 6 additions & 2 deletions cexamples/toyC.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,9 @@ int main( int argc , char* argv[] )
int nnJac = 2;
int iObj = 2;
double ObjAdd = 0;
double objective;

int nS, nInf;
double objective, sInf;


// snInit must be called first.
Expand Down Expand Up @@ -118,7 +120,9 @@ int main( int argc , char* argv[] )
setIntParameter( &toy, "Verify level", 3 );
setIntParameter( &toy, "Derivative option", 3 );

info = solveC( &toy, Cold, &objective );
nS = 0;

info = solveC( &toy, Cold, &objective, &nS, &nInf, &sInf );
printf ("SNOPT Exit, INFO = %d\n", info );
printf ("Final nonlinear objective = %16.8f\n", objective );

Expand Down
12 changes: 6 additions & 6 deletions include/snopt_cwrap.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,8 @@
#include <assert.h>
#include "snopt.h"

/* File: snopt_c.h
* C interface for SNOPT.
*
* 10 Jul 2014: First version (based on cwrap).
/* File: snopt_cwrap.h
* C interface for SNOPTB and SNOPTC.
*/
typedef struct {
char *name;
Expand Down Expand Up @@ -99,8 +97,10 @@ void setUserfun ( snProblem* prob, snFunC func );
void setFuncon ( snProblem* prob, snConB func );
void setFunobj ( snProblem* prob, snObjB func );

int solveB ( snProblem* prob, int start, double *objective );
int solveC ( snProblem* prob, int start, double *objective );
int solveB ( snProblem* prob, int start, double *objective,
int *nS, int *nInf, double *sInf);
int solveC ( snProblem* prob, int start, double *objective,
int *nS, int *nInf, double *sInf);

void deleteSNOPT ( snProblem* prob );

Expand Down
34 changes: 17 additions & 17 deletions src/snopt_cwrap.c
Original file line number Diff line number Diff line change
Expand Up @@ -351,9 +351,9 @@ void setSTOP(snProblem* prob, isnSTOP snSTOP) {

/* ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ */

int solveB(snProblem* prob, int start, double* objective) {
int i, inform, iObj, miniw, minrw, nInf, nS;
double sInf;
int solveB(snProblem* prob, int start, double* objective,
int* nS, int* nInf, double* sInf) {
int i, inform, iObj, miniw, minrw;

assert(prob->initCalled == 1);
assert(prob->sizeCalled == 1);
Expand All @@ -378,7 +378,7 @@ int solveB(snProblem* prob, int start, double* objective) {
prob->snLog, prob->snLog2, prob->sqLog, prob->snSTOP,
prob->valJ, prob->indJ, prob->locJ,
prob->bl, prob->bu, prob->hs, prob->x, prob->pi, prob->rc,
&inform, &nS, &nInf, &sInf, objective,
&inform, nS, nInf, sInf, objective,
&miniw, &minrw,
prob->iu, prob->leniu, prob->ru, prob->lenru,
prob->iw, prob->leniw, prob->rw, prob->lenrw);
Expand All @@ -395,9 +395,9 @@ int solveB(snProblem* prob, int start, double* objective) {

/* ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ */

int solveC(snProblem* prob, int start, double* objective) {
int i, inform, iObj, miniw, minrw, nInf, nS;
double sInf;
int solveC(snProblem* prob, int start, double* objective,
int* nS, int* nInf, double* sInf) {
int i, inform, iObj, miniw, minrw;

assert(prob->initCalled == 1);
assert(prob->sizeCalled == 1);
Expand All @@ -415,16 +415,16 @@ int solveC(snProblem* prob, int start, double* objective) {
iObj = prob->iObj+1;

f_snkerc(start, prob->name, prob->m, prob->n, prob->ne,
prob->nnCon, prob->nnObj, prob->nnJac, iObj,
prob->ObjAdd,
prob->usrfun,
prob->snLog, prob->snLog2, prob->sqLog, prob->snSTOP,
prob->valJ, prob->indJ, prob->locJ,
prob->bl, prob->bu, prob->hs, prob->x, prob->pi, prob->rc,
&inform, &nS, &nInf, &sInf, objective,
&miniw, &minrw,
prob->iu, prob->leniu, prob->ru, prob->lenru,
prob->iw, prob->leniw, prob->rw, prob->lenrw);
prob->nnCon, prob->nnObj, prob->nnJac, iObj,
prob->ObjAdd,
prob->usrfun,
prob->snLog, prob->snLog2, prob->sqLog, prob->snSTOP,
prob->valJ, prob->indJ, prob->locJ,
prob->bl, prob->bu, prob->hs, prob->x, prob->pi, prob->rc,
&inform, nS, nInf, sInf, objective,
&miniw, &minrw,
prob->iu, prob->leniu, prob->ru, prob->lenru,
prob->iw, prob->leniw, prob->rw, prob->lenrw);

for (i = 0; i < prob->ne; i++) {
prob->indJ[i]--;
Expand Down

0 comments on commit 2ca240f

Please sign in to comment.