Question
i have f function which have 10 optical numbers and 10 random numbers, this function is going to calculate the sum of these numbers. and
i have f function which have 10 optical numbers and 10 random numbers, this function is going to calculate the sum of these numbers. and i have the mutation function which is going to take the 10 random numbers from the first function and choose 3 of these numbers randomly and change it a bit randomly also between 0 and 1. and i have GDA function which is going to generate a new 10 random numbers and display it, then is going to call the mutation function to change 3 of these numbers randomly. my question is that how i am going to print the random numbers after the change of the mutation function?? my code is written by Java language
/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ package optimize_project;
import java.io.PrintStream; import static java.lang.Double.min; import static java.lang.Double.sum; import java.util.Arrays; import java.util.Random; import jdk.nashorn.internal.objects.Global;
public class Optimize_project { /** * @param args the command line arguments */ public static double[] o={35.6267,-82.9123,-10.6423,-83.5815,83.1552,47.048,-89.4359,-27.4219,76.1448,-39.0595}; public static double[] x = new double[10];
// public double[] x = new double[10]; public static void main(String[] args) { double min=-100; double max=100;
Random rd = new Random(); // creating Random object //double[] x = new double[10]; for (int i = 0; i } System.out.println(" "); //dis(o,x[i]); System.out.println(f(o,x)); System.out.println(" "); mutation(x); GDA(); } public static double f(double[] opt,double[] ran){ for(int p=0;p<10;p++){ System.out.println("optimal number: "+opt[p]); System.out.println("x: "+ ran[p]); System.out.println("______"); } double totalSum =0; // double sum = 0; for(int i=0;i<10;i++){ double p=0; for(int j=0;j for(int i=0;i<3;i++){ Random rand=new Random(); double nn= rand.nextDouble()*1; Random ran=new Random(); randomNumber=ran.nextInt(xx.length); ind=xx[randomNumber]+nn; System.out.println("index "+randomNumber); System.out.println("Change: "+nn); System.out.println("index num "+randomNumber+": "+ xx[randomNumber]); System.out.println("index "+randomNumber+" AFTER: "+ind); System.out.println(" "); } } public static void GDA(){ System.out.println("NEW RANDOM NUMBERS"); double min=-100; double max=100; double[] sol = new double[10]; Random rd = new Random(); // creating Random object for (int i = 0; i } // System.out.println(f(o,sol)); // generate new solutions System.out.println("--------------sol-------------"); // printing each array element double[] temp=sol; mutation(temp);//generate 3 numbers and change them a bit //here how can i display the f function with the change of 3 numbers are happend?? System.out.println(f(o,temp)); } }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started