Category Archives: #AI

Source Code for my UVI senior research project – Back in 2000 !!

Here is the source code for my senior research project on Genetic Algorithms from back in 2000. Amazing !!

 

/*
Copyright 2000 Stanford Mings

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.

2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.

3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include
*/

#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include <time.h>

struct generation
{
int string[5][10];
int fitness[5];
};

void showgeneration(struct generation gp);
void updatefitness(struct generation *gp);
void makepopulation(struct generation *gp);
void reproduce(struct generation *gp);
void savebest(struct generation *gp, int best[10]);
void replacebest(struct generation *gp, int best[10]);

void mutategeneration(struct generation *gp)
{
int or,rm,m,v=2,p=0,mod=0;
/*
for(m=0;m<5;m++)
{
for(v=0;v<10;v++)
{
rm=rand()%55;
// rm=1;
if ((rm==p)&&(mod<10))
{
(*gp).string[m][v]=(rm)%3;
printf(“Mutation at string #%d”,m);
printf(” and element #%d”,v);
printf(” with it being changed to %d”,rm%3);
printf(” !!\n”);
mod++;
}
p++;
}
}
*/
// srand(time(NULL));
for (p=0;p<v;p++)
{
rm=rand()%50;
mod=rand()%3;
or=(*gp).string[rm/10][rm%10];
(*gp).string[rm/10][rm%10]=mod;
// printf(“\n Printing sting %d at point %d from %d to %d”,rm/11,rm%11,or,mod);
}
// printf(“\n”);

}

void reproduce(struct generation *gp)
{
int m,v,f,g,k;
int val[5];
struct generation newgp;
val[0]=(*gp).fitness[0];
k=(*gp).fitness[0];

for(m=1;m<5;m++)
{
k+=(*gp).fitness[m];
val[m]=(*gp).fitness[m]+val[m-1];
}

for (m=0;m<5;m++)
{
g=rand()%k;
f=0;
while(val[f]<g)
f++;
for(v=0;v<10;v++)
newgp.string[m][v]=(*gp).string[f][v];
}

(*gp)=newgp;
}

void savebest(struct generation *gp,int best[10])
{
int bst,v,m,k;
bst=(*gp).fitness[0];
v=0;
for(m=1;m<5;m++)
if (bst<(*gp).fitness[m])
{
v=m;
bst=(*gp).fitness[m];
}
for (k=0;k<10;k++)
best[k]=(*gp).string[v][k];
}

void replacebest(struct generation *gp,int best[10])
{
int v,m,k,d;
v=rand()%5;
// printf(“\n Replacing %d \n”,v);
for (k=0;k<10;k++)
(*gp).string[v][k]=best[k];
}

void makepopulation(struct generation *gp)
{

int d,v,j,sum=0,m,s,p=0,rpick[5],st[5],fn[5];
struct generation gtemp=(*gp);
int newpop[5];

for(m=0;m<5;m++)
sum=sum+(*gp).fitness[m];
d=0;
j=0;
while (d<5)
{
st[d]=j;
fn[d]=j+(*gp).fitness[d];
j=(*gp).fitness[d]+j;
d++;
}

for(m=0;m<5;m++)
rpick[m]=rand()%sum;

for (m=0;m<5;m++)
for(p=0;p<5;p++)
if((rpick[m]>=st[p])&&(rpick[m]<fn[p]))
newpop[m]=p;

for (p=0;p<5;p++)
for(v=0;v<10;v++)
(*gp).string[p][v]=gtemp.string[newpop[p]][v];

/*
for(p=0;p<5;p++)
{
printf(“\n String #%d”,p);
printf(” New String #%d”,newpop[p]);

}
printf(“\n”);
scanf(“%d”,&p);
*/
updatefitness(gp);
}

void xovergeneration(struct generation *gp)
{
int stg1,stg2,xpoint,xlen,m,xver[10];
stg1=rand()%5;
stg2=rand()%5;
while (stg2==stg1)
stg2=rand()%5;
xpoint=rand()%8;
// printf(“\n Xpoint =%d and Xlen= %d”,xpoint, xlen);
xlen=1+(rand()%8);
// printf(“\n Xpoint =%d and Xlen= %d”,xpoint, xlen);
while((xlen+xpoint)>=10)
xlen=1+rand()%8;
// printf(“\n Xpoint =%d and Xlen= %d”,xpoint, xlen);
// xpoint=2;
m=xpoint;
while(m<(xpoint+xlen))
{
xver[m]=(*gp).string[stg1][m];
m++;
}

m=xpoint;

// showgeneration(*gp);
while(m<(xlen+xpoint))
{
(*gp).string[stg1][m]=(*gp).string[stg2][m];
(*gp).string[stg2][m]=xver[m];
m++;
}

/* printf(“\n The xchange points are from element #%d”,xpoint);
printf(” to #%d”,xlen+xpoint);
printf(” for strings %d”,stg1);
printf(” and %d”,stg2);
printf(“\n\n”); */
// scanf(“%d”,stg2);

// updatefitness(gp);
// showgeneration(*gp);
}

void reproducegeneration(struct generation *gp)
{
int xpoint,m,v,hfit1,hfit2,lfit,lstring,stg1,stg2,xver[10];
hfit1=0;
hfit2=0;
lfit=22;
lstring=0;
for (m=0;m<5;m++)
{
if (hfit1<(*gp).fitness[m])
{
hfit1=(*gp).fitness[m];
stg1=m;
}
// srand(stg1);
}

stg1=rand()%5;
while(stg2==stg1)
stg2=rand()%5;

for(m=0;m<5;m++)
if (lfit>(*gp).fitness[m])
{
lfit=(*gp).fitness[m];
lstring=m;
}

/* This code here needs to be updated so that it will set the fitness to the
strings of the highest values(2) including those strings that have the
same value
*/
/* for(m=0;m<5;m++)
{
if ((hfit2<(*gp).fitness[m])&&((*gp).fitness[m]!=hfit1))
{
hfit2=(*gp).fitness[m];
stg2=m;
}
}
*/

// xpoint=rand()%10;
xpoint=5;
// printf(“\nS1 =%d”,lstring);
// printf(“\nL =%d”,lfit);
// printf(“\nXpoint=%d”,xpoint);

// printf(“Bad string = %d”,lstring);
// printf(“\n first string = %d”,stg1);
// printf(“\n second string = %d”,stg2);
//

// showgeneration((*gp));
m=0;
while(m<10)
{
if (m>xpoint)
(*gp).string[lstring][m]=(*gp).string[stg2][m];
else
(*gp).string[lstring][m]=(*gp).string[stg1][m];
m++;
}

updatefitness(gp);

// printf(“Bad string = %d”,lstring);
// printf(“\n first string = %d”,stg1);
// printf(“\n second string = %d”,stg2);
// showgeneration((*gp));

}

void showgeneration(struct generation gen)
{
int m,v;
for(m=0;m<5;m++)
// printf(“\n—————-\n”);
{
for(v=0;v<10;v++)
{
printf(“%d”,gen.string[m][v]);
printf(” “);
}
printf(“|=%d”,gen.fitness[m]);
printf(“\n”);
}
printf(“\n”);
// scanf(“%d”,&v);
}

void findgoal(struct generation gen,int s)
{
int p,m;
for(m=0;m<5;m++)
if (gen.fitness[m]>=20)
{
printf(“\n\nFINISH !!!!\n Generation =%d”,s);
printf(“\n”);
showgeneration(gen);
scanf(“%d”,&p);
}
}

void updatefitness(struct generation *gp)
{

int f,m,v;
for (m=0;m<5;m++)
{
f=0;
for (v=0;v<10;v++)
f=f+(*gp).string[m][v];
(*gp).fitness[m]=f;
}
}

struct generation populate()
{
int m,v;
struct generation popg;
for (m=0;m<5;m++)
for (v=0;v<10;v++)
// popg.string[m][v]=rand();
popg.string[m][v]=rand()%3;
return popg;
}

void main()
{
struct generation gen[5000000],geno;
int s,m,rm,in,g;
int best[10];
struct tm tim;
time_t timet;
unsigned seed;
timet=time(NULL);
// printf(“Please enter seed :%d”,timet);
// scanf(“%u”,&seed);
// seed=904;
seed=timet;
srand(seed);
gen[0]=populate();
updatefitness(&gen[0]);
// printf(“Please enter mutation factor : %d”,tim.tm_min);
// scanf(“%d”,&rm);
// rm=10;
printf(“\nEnter the # of generations (1-5000000) :”);
scanf(“%d”,&g);
// g=5000000;
printf(“\nShow generations ?(1 for yes, 0 for no) :”);
scanf(“%d”,&s);
// s=0;
printf(“\n\n Searching…….\n”);
for(m=0;m<g;m++)
{
// printf(“Generation %d”,m);
// printf(“\n”);
// showgeneration(gen[m]);
// seed=time(NULL);
// srand(seed);
// showgeneration(gen[m]);
savebest(&gen[m],best);
reproduce(&gen[m]);
updatefitness(&gen[m]);
// showgeneration(gen[m]);
// makepopulation(&gen[m]);
// updatefitness(&gen[m]);
mutategeneration(&gen[m]);
updatefitness(&gen[m]);
xovergeneration(&gen[m]);
updatefitness(&gen[m]);
replacebest(&gen[m],best);
updatefitness(&gen[m]);
// reproducegeneration(&gen[m]);
// updatefitness(&gen[m]);
if (s==1)
showgeneration(gen[m]);
// printf(“\n”);
// reproducegeneration(&gen[m]);
// makepopulation(&gen[m]);
findgoal(gen[m],m);
// printf(“\n”);
// scanf(“%d”,&in);
// printf(“\n”);
if ((m+1)!=g)
gen[m+1]=gen[m];
}
}

Automata

Automata theory is the study of abstract machines and automata, as well as the computational problems that can be solved using them. It is a theory in theoretical computer science and discrete mathematics (a subject of study in both mathematics and computer science). The word automata (the plural of automaton) comes from the Greek word αὐτόματα, which means “self-acting”.

wikipedia

Still interested in College ? Study either liberal arts, biotech or a robotic engineering.

if you you still interested in college for yourself or advising someone else, then take

  • Liberal arts where you study human nature
  • Biotech as we are still carbon based entities
  • Engineering involving robotics  –  techproresearch.com

Unmanned U.S. Air Force space plane lands after secret, two-year mission

Very Impressive……Very impressive !!

The U.S. military’s experimental X-37B space plane landed on Sunday at NASA’s Kennedy Space Center in Florida, completing a classified mission that lasted nearly two years, the Air Force said.

The unmanned X-37B, which resembles a miniature space shuttle, touched down at 7:47 a.m. EDT (1147 GMT) on a runway formerly used for landings of the now-mothballed space shuttles, the Air Force said in an email.

[via Reuters]

General Motors acquires OSVehicle to build EDIT, a new modular self-driving car, in white-label

Not sure how I feel about this.

Today, OSVehicle is announcing its acquisition by General Motors Company. GM already bought another Y Combinator backed company Cruise Automation in March last year to focus on key long-term technologies such as autonomous driving technology and vehicle safety.

GM will now utilize OSVehicle’s open source hardware expertise to develop EDIT, a self-driving car, based on modular version of Chevy Bolt M1 platform. This modular technology was developed jointly with OSVehicle, to enable the easy replacement of key components such as electric motor and battery pack, which will allow vehicles to last 10X longer than traditional cars.

Modularity also allows the hardware upgrade of hardware stacks for self-driving and connected-cars, helping services like ride sharing. This is another strategic move made by GM towards “mobility as-a-service” after investing 500M $ in Lyft and launching Maven, GM’s own car sharing service in January 2016.

 

[via osvehicle]

How to Become Relevant when a Robot Takes Your Job | Pablos Holman | TEDxLA

The Future Doesn’t Need You – How to Become Relevant when a Robot Takes Your Job
In this talk, Pablos dares you to imagine the possibilities in what once seemed impossible: a harmonious co-existence of humans and robots: Robots taking over your jobs and why they should; how this can trigger fear in humans and why it shouldn’t; redefining happiness; solving world problems like eliminating disease; a personal narrative of parenting that will bring you to your knees; and the responsibility of humans in all of this.

Cassie – Next Gen bipedal robotics…

Since then, robots have fascinated the minds of sci-fi writers and engineers alike. Which brings us to Cassie – the next generation of bipedal robots devised by Oregon State University’s Agility Robotics. Cassie originates from its predecessor ATRIAS. The problem that researchers kept stumbling over when developing ATRIAS was that it contained motors which worked against each other. As a result, this left the robot in being completely inefficient. Cassie, on the other hand, contains steering, feet, and a sealed system, allowing it be both agile and robust.

[via serious wonder]

Leaked Video Reveals New Boston Dynamics Robot That Can Perform Amazing Stunts on Two Wheels

If this new leaked footage is any indication, it seems like the robot creators at Boston Dynamics finally found a way to improve on humanity’s primitive two-legged design: By adding a pair of wheels to their new self-balancing robot, giving the bot some impressive new capabilities.

Jump to 3:45 for the wheeled bot.

[via gizmodo]