Click here to Skip to main content
15,903,012 members
Home / Discussions / Visual Basic
   

Visual Basic

 
AnswerRe: Use a variable or text box in Sql WHERE clause Pin
Afzaal Ahmad Zeeshan23-Sep-17 10:28
professionalAfzaal Ahmad Zeeshan23-Sep-17 10:28 
QuestionVLC Player User-Agent for vb6 Pin
Member 1341240517-Sep-17 17:01
Member 1341240517-Sep-17 17:01 
QuestionVB Form Search XLSX Pin
Member 24539047-Sep-17 10:41
Member 24539047-Sep-17 10:41 
AnswerRe: VB Form Search XLSX Pin
Richard MacCutchan7-Sep-17 19:21
mveRichard MacCutchan7-Sep-17 19:21 
AnswerRe: VB Form Search XLSX Pin
Chris Quinn7-Sep-17 20:39
Chris Quinn7-Sep-17 20:39 
GeneralRe: VB Form Search XLSX Pin
Member 24539048-Sep-17 5:54
Member 24539048-Sep-17 5:54 
Questionvb 2017 : opengl project setup ? Pin
bluatigro5-Sep-17 22:25
bluatigro5-Sep-17 22:25 
Questionvb 2017 : AI : Genetic Programming Pin
bluatigro4-Sep-17 1:33
bluatigro4-Sep-17 1:33 
this is a try at GP
i have this working in liberty/just basic

GP what :
from tabel or plot to formula

GP how :
1 : write some random formula's
2 : calculate output of formula's
3 : sort formula's on error
4 : mix the best in child's
5 : mutate some child's
6 : if best.error > whised and generation < max then goto 2

i got so far as this :
[code]
'' bluatigro 4 sept 2017
'' genetic programming module

Module Module1
Public Const gp_add As String = "[ + # # ]"
Public Const gp_sub As String = "[ - # # ]"
Public Const gp_mul As String = "[ * # # ]"
Public Const gp_div As String = "[ / # # ]"
Public Const gp_sqrt As String = "[ sqrt # # ]"
Public Class GeneProg
Private genes As Collection
Private Enum numMode As Integer
OnlyInputs = 0
AsDouble = 1
AsInteger = 2
End Enum
Private gpstate As numMode
Public Sub New()
gpstate = numMode.OnlyInputs
End Sub
Public Sub use(gen As String)
genes.Add(gen)
End Sub
Public Function run(prog As String) As String
While InStr(prog, "]") <> 0
Dim eind As Int16 = InStr(prog, "]")
Dim begin As Int16 = eind
While Mid(prog, begin, 1) <> "["
begin -= 1
End While
Dim part As String = Mid(prog _
, begin, eind - begin + 1)
Dim q() As String = Split(part)
Dim a As Double = Val(q(2))
Dim b As Double = Val(q(3))
Dim ab As Double
Try
Select Case q(1)
Case "+"
ab = a + b
Case "-"
ab = a - b
Case "*"
ab = a * b
Case "/"
If b = 0 Then
Return "error"
Else
ab = a / b
End If
Case "sqrt"
ab = Math.Sqrt(a)
Case Else
Return "error"
End Select
Catch ex As Exception
Return "error"
End Try
Dim l As String = Left(prog, begin - 1)
Dim r As String = Right(prog _
, Len(prog) - eind)
prog = l + Str(ab) + r
End While
Return prog
End Function
Public Function mix(pa As String, pb As String) As String
Dim begina As Int16
Dim einda As Int16
Dim beginb As Int16
Dim eindb As Int16
Dim cola As New Collection
Dim colb As New Collection
If Rnd() < 0.5 Then
Dim q As String = pa
pa = pb
pb = q
End If
Dim i As Integer
For i = 1 To Len(pa)
If Mid(pa, i, 1) = "[" Then
cola.Add(i)
End If
Next
For i = 1 To Len(pb)
If Mid(pb, i, 1) = "[" Then
colb.Add(i)
End If
Next
begina = cola.Item(CInt(Rnd() * cola.Count()))
einda = begina
Dim fl As Int16 = 0
While fl > 0
einda += 1
If Mid(pa, einda, 1) = "]" Then fl -= 1
If Mid(pa, einda, 1) = "[" Then fl += 1
End While
beginb = colb.Item(CInt(Rnd() * colb.Count()))
fl = 0
While fl > 0
eindb += 1
If Mid(pb, eindb, 1) = "]" Then fl -= 1
If Mid(pb, eindb, 1) = "[" Then fl += 1
End While
Return Left(pa, begina)
End Function
End Class
Sub Main()
Dim proga As String = "[ + 7 [ - 2 3 ] ]"
Dim progb As String = "[ * 4 [ / 5 6 ] ]"
Dim GP As New GeneProg()
Console.WriteLine("[ test run ]")
Console.WriteLine("prog a = " & proga)
Console.WriteLine("prog b = " & progb)
Console.WriteLine("run a = " & GP.run(proga))
Console.WriteLine("check a = " _
& 7.0 + (2.0 - 3.0))
Console.WriteLine("run b = " & GP.run(progb))
Console.WriteLine("check b =" _
& 4.0 * (5.0 / 6.0))
Console.WriteLine("[ push return ]")
Console.ReadKey()
Console.WriteLine("[ test mix ]")
Dim i As Int16
For i = 0 To 5
Dim c As String = GP.mix(proga, progb)
Console.WriteLine("mix a b = c = " & c)
Console.WriteLine("run c = " & c)
Next
Console.WriteLine("[ push return ]")
Console.ReadKey()
End Sub

End Module

[/code]

error :
run b <> check b
mix frezes my pc
AnswerRe: vb 2017 : AI : Genetic Programming Pin
Arthur V. Ratz4-Sep-17 1:59
professionalArthur V. Ratz4-Sep-17 1:59 
GeneralRe: vb 2017 : AI : Genetic Programming Pin
bluatigro5-Sep-17 22:10
bluatigro5-Sep-17 22:10 
GeneralRe: vb 2017 : AI : Genetic Programming Pin
Arthur V. Ratz5-Sep-17 22:40
professionalArthur V. Ratz5-Sep-17 22:40 
GeneralRe: vb 2017 : AI : Genetic Programming Pin
Arthur V. Ratz6-Sep-17 4:49
professionalArthur V. Ratz6-Sep-17 4:49 
GeneralRe: vb 2017 : AI : Genetic Programming Pin
Arthur V. Ratz6-Sep-17 4:56
professionalArthur V. Ratz6-Sep-17 4:56 
GeneralRe: vb 2017 : AI : Genetic Programming Pin
bluatigro6-Sep-17 21:56
bluatigro6-Sep-17 21:56 
GeneralRe: vb 2017 : AI : Genetic Programming Pin
bluatigro7-Sep-17 1:21
bluatigro7-Sep-17 1:21 
GeneralRe: vb 2017 : AI : Genetic Programming Pin
Arthur V. Ratz7-Sep-17 3:15
professionalArthur V. Ratz7-Sep-17 3:15 
GeneralRe: vb 2017 : AI : Genetic Programming Pin
Arthur V. Ratz7-Sep-17 7:44
professionalArthur V. Ratz7-Sep-17 7:44 
GeneralRe: vb 2017 : AI : Genetic Programming Pin
bluatigro7-Sep-17 23:26
bluatigro7-Sep-17 23:26 
GeneralRe: vb 2017 : AI : Genetic Programming Pin
Arthur V. Ratz7-Sep-17 23:37
professionalArthur V. Ratz7-Sep-17 23:37 
QuestionImport Outlook calendar entries from Excel with VBscript? Pin
xs13x31-Aug-17 11:03
xs13x31-Aug-17 11:03 
SuggestionRe: Import Outlook calendar entries from Excel with VBscript? Pin
Ralf Meier31-Aug-17 20:47
mveRalf Meier31-Aug-17 20:47 
AnswerRe: Import Outlook calendar entries from Excel with VBscript? Pin
Chris Quinn31-Aug-17 22:20
Chris Quinn31-Aug-17 22:20 
AnswerRe: Import Outlook calendar entries from Excel with VBscript? Pin
Ralf Meier1-Sep-17 0:32
mveRalf Meier1-Sep-17 0:32 
AnswerRe: Import Outlook calendar entries from Excel with VBscript? Pin
Richard Deeming1-Sep-17 2:47
mveRichard Deeming1-Sep-17 2:47 
GeneralRe: Import Outlook calendar entries from Excel with VBscript? Pin
xs13x1-Sep-17 3:13
xs13x1-Sep-17 3:13 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.