Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * 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 prs5;
- /**
- *
- * @author Student
- */
- class PMIN extends Thread{
- static double f(double x, double y)
- {
- return 10*Math.sin(x)+1/Math.exp(y)+x*y;
- }
- static int lx, ly;
- static double ax,bx,ay,by;
- static double minf;
- double minlok;
- int nx,ny;
- public PMIN (int nx, int ny, double le100)
- {
- this.nx=nx;
- this.ny=ny;
- this.minlok=le100;
- this.setName("W"+nx+"X"+ny+"Y");
- }
- public static void init(int lxn, int lyn, double axn, double bxn, double ayn, double byn, double le100)
- {
- lx=lxn; ly=lyn;
- ax=axn; bx=bxn;
- ay=ayn; by=byn;
- minf=le100;
- }
- public void run()
- {
- double x,y;
- double hx=(bx-ax)/lx;
- double hy=(by-ay)/ly;
- for(int i=0; i<lx; i++)
- for(int j=0; j<ly; j++)
- {
- x=ax+i*hx;
- y=ay+j*hy;
- for(int k=0; k<100; k++)
- {
- x+=Math.random()*hx;
- y+=Math.random()*hy;
- if(f(x,y)<minlok)minlok=f(x,y);
- }
- }
- if(minlok<minf)minf=minlok;
- }
- }
- public class PRS5 {
- /**
- * @param args the command line arguments
- */
- public static void main(String[] args) {
- double ax=0, ay=0, bx=10, by=5;
- int lwx=4, lwy=2;
- PMIN.init(lwx, lwy, ax, bx, ay, by);
- // TODO code application logic here
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement