28 times =
seed / 1048576;
31 result = result / 1048576;
43 for ( i = 0; i <
nobs; i++ ) {
45 for ( j = 0; j <
dimx; j++ ) {
48 O = O +
A[k] * Xtarg +
B[k] * pow(Xtarg,2);
60int COI_CALLCONV
Leastsq_ReadMatrix(
double LOWER[],
double CURR[],
double UPPER[],
int VSTA[],
int TYPE[],
double RHS[],
61 int ESTA[],
int COLSTA[],
int ROWNO[],
double VALUE[],
62 int NLFLAG[],
int NUMVAR,
int NUMCON,
int NUMNZ,
void* USRMEM )
70 for ( i=0; i<
dimx; i++ )
82 for ( i=0; i<
nobs; i++ ) {
108 for ( j=0; j<
dimx; j++ ) {
110 for (i=0; i<
nobs; i++ ) {
116 for (i=0; i<
nobs; i++ ) {
135int COI_CALLCONV
Leastsq_FDEval(
const double X[],
double* G,
double JAC[],
int ROWNO,
const int JACNUM[],
int MODE,
136 int IGNERR,
int* ERRCNT,
int NUMVAR,
int NUMJAC,
int THREAD,
void* USRMEM )
144 if ( ROWNO ==
nobs ) {
148 if ( MODE == 1 || MODE == 3 ) {
150 for (i=0; i<
nobs; i++ ) {
151 sum += pow(X[
dimx+i],2);
158 if ( MODE == 2 || MODE == 3 ) {
159 for (i=0; i<
nobs; i++ ) {
170 if ( MODE == 1 || MODE == 3 ) {
173 for ( j=0; j<
dimx; j++ ) {
174 sum +=
A[k]*X[j] +
B[k]*pow(X[j],2);
182 if ( MODE == 2 || MODE == 3 ) {
184 for ( j=0; j<
dimx; j++ ) {
185 JAC[j] =
A[k] + 2*
B[k]*X[j];
223#if defined(LICENSE_INT_1) && defined(LICENSE_INT_2) && defined(LICENSE_INT_3) && defined(LICENSE_TEXT)
228 printf(
"Skipping COI_Solve due to setup errors. COI_Error = %d\n",
COI_Error);
231 printf(
"1 Thread: End of Least Squares Example 1. Return code =%d\n",
COI_Error);
233 c_log(
"1 Thread: Errors encountered during first solve",
COI_Error); }
235 c_log(
"1 Thread: Status or Solution routine was not during first solve called", -1); }
237 c_log(
"1 Thread: Solver or Model status was not as expected (1,2)", -1); }
238 else if ( fabs(
OBJ-19.4443 ) > 0.001 ) {
239 c_log(
"1 Thread: Incorrect objective returned from first solve", -1); };
245 printf(
"Multi Thread: End of Least Squares Example 1. Return code =%d\n",
COI_Error);
247 c_log(
"Multi Thread: Errors encountered during first solve",
COI_Error); }
249 c_log(
"Multi Thread: Status or Solution routine was not during first solve called", -1); }
251 c_log(
"Multi Thread: Solver or Model status was not as expected (1,2)", -1); }
252 else if ( fabs(
OBJ-19.4443 ) > 0.001 ) {
253 c_log(
"Multi Thread: Incorrect objective returned from first solve", -1); };
255 c_log(
"Successful Solve",
OK );
int COI_CALLCONV COIDEF_ReadMatrix(coiHandle_t cntvect, COI_READMATRIX_t coi_readmatrix)
define callback routine for providing the matrix data to CONOPT.
int COI_CALLCONV COIDEF_Message(coiHandle_t cntvect, COI_MESSAGE_t coi_message)
define callback routine for handling messages returned during the solution process.
int COI_CALLCONV COIDEF_Solution(coiHandle_t cntvect, COI_SOLUTION_t coi_solution)
define callback routine for returning the final solution values.
int COI_CALLCONV COIDEF_Status(coiHandle_t cntvect, COI_STATUS_t coi_status)
define callback routine for returning the completion status.
int COI_CALLCONV COIDEF_ErrMsg(coiHandle_t cntvect, COI_ERRMSG_t coi_errmsg)
define callback routine for returning error messages for row, column or Jacobian elements.
int COI_CALLCONV COIDEF_FDEval(coiHandle_t cntvect, COI_FDEVAL_t coi_fdeval)
define callback routine for performing function and derivative evaluations.
int COI_CALLCONV COIDEF_DebugFV(coiHandle_t cntvect, int debugfv)
turn Debugging of FDEval on and off.
int COI_CALLCONV COIDEF_License(coiHandle_t cntvect, int licint1, int licint2, int licint3, const char *licstring)
define the License Information.
int COI_CALLCONV COIDEF_StdOut(coiHandle_t cntvect, int tostdout)
allow output to StdOut.
int COI_CALLCONV COIDEF_ThreadS(coiHandle_t cntvect, int threads)
number of threads allowed internally in CONOPT.
int COI_CALLCONV COIDEF_ObjCon(coiHandle_t cntvect, int objcon)
defines the Objective Constraint.
int COI_CALLCONV COIDEF_NumVar(coiHandle_t cntvect, int numvar)
defines the number of variables in the model.
int COI_CALLCONV COIDEF_NumNz(coiHandle_t cntvect, int numnz)
defines the number of nonzero elements in the Jacobian.
int COI_CALLCONV COIDEF_NumCon(coiHandle_t cntvect, int numcon)
defines the number of constraints in the model.
int COI_CALLCONV COIDEF_OptDir(coiHandle_t cntvect, int optdir)
defines the Optimization Direction.
int COI_CALLCONV COIDEF_NumNlNz(coiHandle_t cntvect, int numnlnz)
defines the Number of Nonlinear Nonzeros.
int COI_CALLCONV COI_Solve(coiHandle_t cntvect)
method for starting the solving process of CONOPT.
int COI_CALLCONV Leastsq_ReadMatrix(double LOWER[], double CURR[], double UPPER[], int VSTA[], int TYPE[], double RHS[], int ESTA[], int COLSTA[], int ROWNO[], double VALUE[], int NLFLAG[], int NUMVAR, int NUMCON, int NUMNZ, void *USRMEM)
Define information about the model.
int COI_CALLCONV Leastsq_FDEval(const double X[], double *G, double JAC[], int ROWNO, const int JACNUM[], int MODE, int IGNERR, int *ERRCNT, int NUMVAR, int NUMJAC, int THREAD, void *USRMEM)
Compute nonlinear terms and non-constant Jacobian elements.
int main(int argc, char **argv)
Main program. A simple setup and call of CONOPT.
int COI_CALLCONV Leastsq_ReadMatrix(double LOWER[], double CURR[], double UPPER[], int VSTA[], int TYPE[], double RHS[], int ESTA[], int COLSTA[], int ROWNO[], double VALUE[], int NLFLAG[], int NUMVAR, int NUMCON, int NUMNZ, void *USRMEM)
Define information about the model.
int COI_CALLCONV Leastsq_FDEval(const double X[], double *G, double JAC[], int ROWNO, const int JACNUM[], int MODE, int IGNERR, int *ERRCNT, int NUMVAR, int NUMJAC, int THREAD, void *USRMEM)
Compute nonlinear terms and non-constant Jacobian elements.
int COI_CALLCONV Std_Status(int MODSTA, int SOLSTA, int ITER, double OBJVAL, void *USRMEM)
int COI_CALLCONV Std_Message(int SMSG, int DMSG, int NMSG, char *MSGV[], void *USRMEM)
void c_log(char *msgt, int code)
int COI_CALLCONV Std_ErrMsg(int ROWNO, int COLNO, int POSNO, const char *MSG, void *USRMEM)
int COI_CALLCONV Std_Solution(const double XVAL[], const double XMAR[], const int XBAS[], const int XSTA[], const double YVAL[], const double YMAR[], const int YBAS[], const int YSTA[], int NUMVAR, int NUMCON, void *USRMEM)