/***********************************************************************/ /* // This is an example call of MIDACO 6.0 // ------------------------------------- // // MIDACO solves Multi-Objective Mixed-Integer Non-Linear Problems: // // // Minimize F_1(X),... F_O(X) where X(1,...N-NI) is CONTINUOUS // and X(N-NI+1,...N) is DISCRETE // // subject to G_j(X) = 0 (j=1,...ME) equality constraints // G_j(X) >= 0 (j=ME+1,...M) inequality constraints // // and bounds XL <= X <= XU // // // The problem statement of this example is given below. You can use // this example as template to run your own problem. To do so: Replace // the objective functions 'F' (and in case the constraints 'G') given // here with your own problem and follow the below instruction steps. */ /***********************************************************************/ #include "mpi.h" #include #include /***********************************************************************/ void problem_function( double *F, double *G, double *X ); /***********************************************************************/ int midaco(long int*,long int*,long int*,long int*,long int*,long int*,double*, double*,double*,double*,double*,long int*,long int*,double*,double*, long int*,long int*,long int*,double*,long int*,char*); /***********************************************************************/ int midaco_print(int,long int,long int,long int*,long int*,double*,double*,double*, double*,double*,long int,long int,long int,long int,long int, double*,double*,long int,long int,double*,long int,char*); /***********************************************************************/ /************************ MAIN PROGRAM *****************************/ /***********************************************************************/ int main( int argc, char **argv) { /* Prepare MPI parallelization */ int thread, nthreads; MPI_Status status; MPI_Init( &argc, &argv ); MPI_Comm_rank( MPI_COMM_WORLD, &thread ); MPI_Comm_size( MPI_COMM_WORLD, &nthreads ); /* Variable and Workspace Declarations */ long int o,n,ni,m,me,maxeval,maxtime,printeval,save2file,iflag,istop; long int liw,lrw,lpf,i,iw[5000],p=1; double rw[20000],pf[20000]; double f[10],g[1000],x[1000],xl[1000],xu[1000],param[13]; char key[] = "MIDACO_LIMITED_VERSION___[CREATIVE_COMMONS_BY-NC-ND_LICENSE]"; /*****************************************************************/ /*** Step 1: Problem definition ********************************/ /*****************************************************************/ /* STEP 1.A: Problem dimensions ******************************/ o = 1; /* Number of objectives */ n = 4; /* Number of variables (in total) */ ni = 2; /* Number of integer variables (0 <= ni <= n) */ m = 3; /* Number of constraints (in total) */ me = 1; /* Number of equality constraints (0 <= me <= m) */ /* STEP 1.B: Lower and upper bounds 'xl' & 'xu' **********************************************/ for( i=0; i= 1 ){ MPI_Finalize(); } /*****************************************************************/ // printf("\n Solution f[0] = %f ", f[0]); // printf("\n Solution g[0] = %f ", g[0]); // printf("\n Solution x[0] = %f ", x[0]); /*****************************************************************/ return 0; /*****************************************************************/ /*********************** END OF MAIN ***************************/ /*****************************************************************/ } /***********************************************************************/ /********************* OPTIMIZATION PROBLEM ************************/ /***********************************************************************/ void problem_function( double *f, double *g, double *x ) { /* Objective functions F(X) */ f[0] = (x[0]-1.0)*(x[0]-1.0) + (x[1]-2.0)*(x[1]-2.0) + (x[2]-3.0)*(x[2]-3.0) + (x[3]-4.0)*(x[3]-4.0) + 1.23456789; /* Equality constraints G(X) = 0 MUST COME FIRST in g[0:me-1] */ g[0] = x[0] - 1.0; /* Inequality constraints G(X) >= 0 MUST COME SECOND in g[me:m-1] */ g[1] = x[1] - 1.333333333; g[2] = x[2] - 2.666666666; /******************************************************************/ /* Dummy calculation to simulate cpu-time intensive F calculation */ /******************************************************************/ double dummy = 0.01; while( dummy > 1.0e-8 ) { dummy = dummy - (1.0e-8*x[0]); } f[0] = f[0] + dummy; } /***********************************************************************/ /*************************** END OF FILE *******************************/ /***********************************************************************/