1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184
|
#include <conio.h>
#include<math.h>
#include<conio.h>
#include<string.h>
#include<time.h>
#include<cmath>
//#include<stdlib.h>
#include<string>
#include<iostream>
#include<fstream>
int *sort_cost;
int *sort_sl;
#define POP_S 60
using namespace std;
//*******************************************************
float alpha_final=0.95;
int s2_leng;
int s1_leng;
int N_pro;
int simu_iteration=30;
int total_simu_time=3;
float order_cost_init=50;
float unit_order_cost=5;
float unit_hcost=2;
float unit_shcost=1;
float rec_time_l=1;
float rec_time_u=2;
float *dem_prob;
float lambda=0.1;
float slittle_l=20;
float slittle_u=115;
float scap_l=45;
float scap_u=235;
float differ_l=25;
int mult=5;
// These are some variables related to optimization algorithm.
//*******************************************************
float mprob=0.1;
int *pop_ind;
int *pop_ind2;
int INF=10000000000;
float alpha;
float *f1,*s2,*f2,*s3;
int **Sp;
int *zero_2p;
int *d;//due dates
int *pt;//zamane hamlo naghl
int *pa;
int *w1;
int *w2;
int *w3;
int ***s;
int **s0;
int **t;
int **SOH;
int **FOH;
int *np;
int rank_max;
float *st;//start time of the job
float **ost;// start time of the operations in a job
float **oft;// finish time of the operations in a job
float *ft;// finish time of the job
float *c;
int P=200;//population size;
//***************structures:*******************
//*********************************************
typedef struct sol {
int *slittle;
int s;
int S;
int *scap;
int rank1;
int rank2;
float cost;
float sl;
double *scost;
double *ssl;
int *bit;
int rank;
float fit;
float f1;//flow time
float f2;//lateness and earliness
float distance;
float pen;
};
struct front {
int *F;
int num;
};
struct front *FR;
struct front Q;
//**********************************************
//**********************************************
sol *popcurrent, *popnext;
sol temp;
sol *pareto;
//***************prototypes:*******************
//*********************************************
void sort22(sol *x,int z,int z2);
void OX(int *p1,int *p2,int *c1, int *c2, int z);
void y0(sol *xx);
void set_value(sol *x);
void chromcpy(sol*x,sol*y);
void y1(sol*x);
void shift(int*x,int z);
void mutation(sol*x);
void PMX(int *p1,int *p2,int *c1, int *c2, int z);
int selection(int *p1,int *p2,sol*x);
void sort3(sol *x,int z,int z2);
void sort2(sol *x,int z,int z2);
void sort1(sol *x,int z,int z2);
int check_dom(float w,float x,float y,float z);
void preprocess();
void mem_aloc();
void init(sol*);
void init_perm(int*x,int y);
void y(sol*);
void fast_nd_sort(sol *x,int ind);
void crowd_distance_assignment2(sol *x,int);
void fast_nd_sort_2(sol *x,int ind);
//**********************************************
//**********************************************
int main(){srand(time(NULL));
int len;
clock_t msec3,msec4,dur2;
int iter;
int par1,par2;
int lll;
preprocess();
mem_aloc();
FR=(struct front *)malloc(sizeof(struct front)*2*P);
for (int i=0;i<2*P;i++)
{
FR[i].F=(int *)malloc(sizeof(int)*2*P);
}
//ifstream ifs("1.txt");
//for (int i=0;i<Njobs;i++)
//{
// ifs>>popcurrent[0].bit[i];
//}
// y(popcurrent);
//cout<<popcurrent[0].f1<<" "<<popcurrent[0].f2<<" "<<popcurrent[0].f1+popcurrent[0].f2<<"\n";
//getch();
iter=0;
msec3=clock();
init(popcurrent);
fast_nd_sort_2(popcurrent,P);
if (iter==0)
{
//cout<<"\nare hast\n";
//getch();
ofstream ofsss("outtt.txt");
for (int i=0;i<P;i++) if(popcurrent[i].rank==1)
{
ofsss<<popcurrent[i].cost<<" "<<popcurrent[i].sl<<"\n";
}
ofsss.close();
}
//cout<<"\n**fndsrt ended\n";
|