Can A* be used to generate algorithm sourcecode?

0  

I thought of an idea to use a* algorithm to "walk" toward a solution that solves a programming problem. Each neighbour can be a weighted list of programming tasks such as if statement, for each, assignment, recursive call. How do you map example data structures transformations to code that fulfils the changes to the data structure? You need a cost function that decreases when the output gets nearer to the solution. What does the cost function for code solving a problem look similar to?

YAML 想法

If you project the desired code variables onto a multidimensional space and with a time dimension, where each variable has a assignment algebra you can imagine the input code causing movements to the output algebra for each variable

How do you measure that a solution gets nearer to the solution when you haven't planned what you could do

It should be a multidimensional walk toward a solution that solves the programming problem.

I want to generate the btree algorithm and other algorithms with this approach

I should provide example inputs to output mappings and join the Data between the input and output and try recalculate the processing steps to go from one to the other but I am having problems deciding what the cost function looks like.

chronological,


(别通知) (可选) 请,登录

我有一个想法。如果您将输出生成的代码想象为超集,那么每一行代码都是输出代码子集的一部分。

因此,您需要某种方式来生成输出集的子集。

每个集合都是生成答案的有序指令集。我想避免暴力搜索,每次生成一行代码的尝试都应该更接近输出。

我认为我们必须提供代码应该做什么的启发式方法。

I had a thought. If you imagine the output generated code as a superset then every line of code is part of a subset of the output code.

So you need some way of generating subsets of the output set.

Each set is an ordered set of instructions that generate the answer. I want to avoid brute force search, every attempt of generating a line of code should get nearer to the output.

I think we have to provide heuristics of approximately what the code should do.


我们可以扫描输出结构并生成每个数据关系的事实。

我们可以根据源数据到目标数据的路径遍历来比较数据移动的位置。生成补丁。

这有一个指向这个对象的指针,指向这条数据。

输入数据

Node1 是根

节点 1 子节点 2

节点 1 子节点 3

示例 1

插入一个节点node4

所需的输出数据

Node1 是根

节点 1 子节点 2

节点 1 子节点 3

节点 1 子节点 4

修补

Node4 插入到 node1 子节点中

为什么是节点1?理论。

Node1 是根

针对 node1、node4 运行算子

Len(node1.children) <= Maxsize

示例 2

节点拆分 - 插入 node5

输入数据

根节点是node1

节点 1 子节点 2

节点 1 子节点 3

节点 1 子节点 4

所需的目标数据

根节点是node3

节点 3 子节点 1

节点 3 子节点 2

节点 3 子节点 4

节点 4 子节点 5

这表示一个节点拆分,因为每个节点里面只能有 3 个项目。

我们如何学习一个节点只能有 3 个节点的规则?

在事实系统中插入一个常数

最大尺寸为 3 在系统中插入运算符 Len(node.children) 最大尺寸 == 等于 >= 大于或等于 <= 小于或等于 > 大于 < 小于

运行每个运算符的每个排列以决定执行补丁命令步骤。

补丁说明 Node1 不再是根节点 Node3 是根节点 Node2 的子节点是 node1 从 node1 中删除 node4 为什么从 node1 中删除 node4 为什么node4被添加到node3

理论。什么事实是真的。 将 node1 属性与 node4 进行比较 最终.... Len(node1.children) == MaxSize 将node4添加到node3 为什么? 理论。什么事实是真的 节点 4 >= 节点 3 真 >= 是否适用于所有示例?还是更复杂 扭动操作。一个下降,一个上升,下降连接一个下降。 根 = A 节点 1 是 A 新根 = B

扭曲操作是 - 根 = B B.儿童 = A

并查看数据移动到哪里。我们需要生成确定性地在正确位置创建具有相同数据的相同结构的步骤。

应该有图案。因此,对象中通常有一个属性可以进行比较以进行 btree 拆分。

因此,在 btree 中最多有一个字段或一个比较来确定对象的目的地。

我认为我们可以为每个输入对象随机生成条件语句。

走补丁并插入条件对象。

这是一个图形转换问题

We can scan the output structure and generate facts of each relationship of data.

We can compare where the data moved through based on a path traversal of source data to destination data. Generate a patch.

This has a pointer to this object to this piece of data.

Input data

Node1 is root

Node1 children node2

Node1 children node3

Example 1

Insert a node node4

Desired Output data

Node1 is root

Node1 children node2

Node1 children node3

Node1 children node4

Patch

Node4 inserted into node1 children

Why node1? Theorise.

Node1 is root

Run operators against node1, node4

Len(node1.children) <= Maxsize

Example 2

Node split - insert node5

Input data

Root node is node1

Node1 children node2

Node1 children node3

Node1 children node4

Desired target data

Root node is node3

Node3 children node1

Node3 children node2

Node3 children node4

Node4 children node5

This represents a node split as each node can only have 3 items inside it.

How do we learn the rule that a node can only have 3 nodes?

Insert a constant into the system of facts

MaxSize is 3 Insert operators in system Len(node.children) MaxSize == Equal to

= Greater than or equal to <= Less than or equal to Greater than < Less than

Run every permutation of each operator to decide to do patch command steps.

Patch instructions Node1 is no longer root node Node3 is root node Node2 children is node1 Remove node4 from node1 Why was node4 removed from node1 Why was node4 added to node3

Theorise. What fact was true. Compare node1 properties to node4 Eventually.... Len(node1.children) == MaxSize Add node4 to node3 Why? Theorise. What fact is true Node4 >= Node3 true Does >= hold for all examples? Or is it more complicated Twist operation. One goes down, one goes up and going down joins one going down. Root = A Node1 is A New root = B

Twist operation is - Root = B B.children = A

And see where the data moves. We need to generate the steps that deterministically creates the same structure with the same data in the right places.

There shall be patterns. So there is usually a property in the object that is compared against to do a btree split.

So there is at most one field or a comparison that determines the destination of the object in the btree.

I thought we can randomly generate condition statements for each input object.

Walk the patch and insert condition objects.

It's a graph transformation problem