colorings – Triangles covering all vertices of a tri-partite graph

This question is an extension of this one: Min path cover for a three-layer graph with all paths traversing all layers.

I’m designing fictional fruits. Each fruit has three attributes; color, taste and smell. Also, each of the values of the attributes have some compatibility with the values of the other attributes. So, we get a tri-partite graph. An example is shown below. Here, 1 and 2 are color attributes, 3,4 and 5 are taste attributes and 6 and 7 are smell attributes. Also, color-1 is compatible with taste-3 and smell-6 and so on.

Fig 1: fruit graph

I want to design a minimal number of fruits while still covering all attributes (all 2 colors, all 3 tastes and all 2 smells in this case). For example, the example graph above has the following solution (shown with pink lines, fruit-1 has color-1, taste-3 and smell-6; fruit-2 has color-1, taste-4 and smell-7 while fruit-3 has color-2, taste-5 and smell-6; hence covering all levels of all attributes with 3 fruits):

enter image description here

We know this is optimal since there are three tastes and we couldn’t have used less than 3 fruits in this case.

Note that it might not have been possible to cover all attributes even if the graph has no isolated vertices and I asked a question on feasibility here: https://math.stackexchange.com/questions/3998648/possible-to-cover-all-vertices-of-a-tri-partite-graph-with-triangles

artificial intelligence – Reinforcement learning and Graph Neural Networks: Issue with entropy

I am currently working on an experiment to link reinforcement learning with graph neural networks.
This is my architecture:

Feature Extraction with GCN:

  • there is a fully meshed topology with 23 nodes. Therefore there are 23*22=506 edges.
  • the original feature vector comprises 43 features that range from about -1 to 1.
  • First, a neuronal network f takes calculates a vector per edge, given the source node and target node features.
  • After we have calculated 506 edge vectors, function u aggregates the results from f per node (aggregation over 22 edges)
  • A function g takes the original target feature vector and concatenates the aggregated results from u. Finally, the output dimension of g determines the new feature vector size for each node.
  • At last, the function agg decides which information is returned from the feature extraction, e.g. just flatten the 23xg_output_dim feature vectors or building the average

After that:

  • The output of the feature extractor is passed to the OpenAi Baseline PPO2 Implementation. The frameworks adds a flatten layer to the output and maps it to 19 action values and 1 value-function value.

I have made some observations in the experiments and do not manage to explain them. Hyperparameter are: an output dimension for f and g of 512. U=sum, aggr=flatten. A tanh activation is applied on the outputs of f and g. For PPO2: lr=0.000343, stepsize=512.

This gives me the following weight matrices:

<tf.Variable 'ppo2_model/pi/f_w_0:0' shape=(86, 512) dtype=float32_ref>    
<tf.Variable 'ppo2_model/pi/g_w:0' shape=(555, 512) dtype=float32_ref>   
<tf.Variable 'ppo2_model/pi/w:0' shape=(11776, 19) dtype=float32_ref>    
<tf.Variable 'ppo2_model/vf/w:0' shape=(11776, 1) dtype=float32_ref>

The following problem occurs. Normally you wait for the entropy in the PPO2 to decrease during the training, because the algorithm learns which actions lead to more reward.
With the described hyperparameters, the entropy drops abruptly to 0 within 100 update steps and stays zero even after >15.000 updates (=150M steps in the game). This means that the same action is always selected.

What I found out: the problem is that by making the sum over 22 edges, very large values are created (maximum 221 and 22-1). The values are then given to the function g and thus ends up in the saturation region of the tanh. As a result, the new features of the 23 nodes contain many 1‘s and -1‘s. Because we flatten, the weighted sum of 11776 input neurons flows into each of the 19 action neurons, resulting in very large values in the policy. An action is then calculated from the policy with the following formula:

u = tf.random_uniform(tf.shape(logits), dtype=logits.dtype)
action = tf.argmax(logits - tf.log(-tf.log(u)), axis=-1), 

Most of the time tf.log(-tf.log(u) gives sommething between 2 and -2 (in my opinion). This means that as soon as a very large value appears in the policy, the corresponding action is always selected and not the second or third most probable one, which might lead to more exploration.

What I don’t understand 1): As soon as negative reward occurs, shouldn’t the likelihood decrease again, so that in the end I choose other actions again?

I did some experiments with relu and elu activations:
These are the value histogram of the output of g after the using relu, tanh and elu:
enter image description here
These are the value histograms of the policy, when using relu, tanh and elu:
enter image description here
Histogram over resulting actions:

What I don’t understand 2:Using Relu you see that in the first steps in the policy were large values, but then the model learns to reduce the range, which is why in this example also the entropy does not drop. Why does this not work when using tanh or elu?
enter image description here

We have found out 3 things with which the problem does not occur or is delayed. These are my assumptions. Are the correct in your opinion?:

  • using smaller output dimension of f and g, like 6 or using aggr=mean -> For each of the 19 action neurons, less input neurons are averaged -> smaller values in the policy –> more exploration
  • Using u=mean and not sum, averages the outputs of f, therefore the aggregated values are not only 1 and -1
  • Smaller learning rate -> Making the weights too big, increases the chance of the 19 action values to be big. If there is no negativ reward, there is no need for the algorithm to make the weights smaller.

I know this is a lot of information, so I would be grateful for any small tip.!

A graph database suitable for analyzing a heap snapshot?

It looks like recommendation questions aren’t explicitly OT, so here goes:

I’m working on some tooling for analyzing a dump of the heap of a running program. The dump is just a list of nodes with associated metadata and references to other nodes (possibly-cyclical).

I don’t have any experience with graph databases, and I’m wondering if I would save myself a lot of time by building tooling around a graph DB. So I’m looking for recommendations and pointers to resources, and advice.

Some specific questions:

  • are there any graph databases that have functionality built in for computing a dominator tree? (googling this didn’t seem to get any results)
  • are there any DBs that have tooling for visualizing a huge graph?

graph theory – Generating triangulations with given topology

I am looking for information about the problem of identifying the heaviest minimal subset $Fsubset E$ of the edgeset $E$ of a complete symmetric graph $G(V,E)$ with randomly weighted edges such that $Gsetminus F$ has a given topology, e.g. is planar, and a triangulation, i.e. every remaining edge is an edge of a 3-cycle.

An exemplary problem would be to find a triangulation of a complete graph, whose vertices resemble points on a torus and edge weigths equal to euclidean distance, that allows for a planar embedding.

Being able to calculate the lightest planar triangulation of graphs with arbitrarily weighted edges would e.g. yield a meaningful definition of the planar convex hull of such graphs and thus yield an initial tour that can be expanded to a lightest Hamilton cycle by successive integration of vertices.

algorithms – Optimization problem over bidirectional connected graph

A company has several automatic vertical warehouses (called elevators). Each elevator have several trays and each tray has several slots. A slot contains a given quantity of a given article. Elevators, trays and slots are identified by unique IDs and slot also have access to the ID of their own article. In the same tray there can be multiple slots with the same article.

I have to design an algorithm which, given an order list (we can model it as a dictionary with articles’ IDs as key and quantity needed as values), returns the minimum list of trays needed to satisfy the order.

This is quite different from a standard warehouse optimization problem because we are not considering the physical distances between each tray, since the elevators are automatic and they give us the tray, while in the classical problem is the human who moves toward the tray to pick the item from it.

A distance function is given: d(a, b) which returns 1 if tray a and b are on different elevators and returns 2 if they’re on the same one. That could be counter-intuitive, but remember that these are vertical elevators, so the time needed to change tray on the same elevator is greater than the time to move to a different elevator with the tray already in bay. Furthermore, if we use more elevators at the same time, we can “parallelize” the picking process (man A pick from elevator 1 while man B picks from elevator 2…) Anyway, this function is given and I cannot change it.

After reading through articles about warehouse optimization, I’ve decided to take an heuristic approach.
I’ve modeled a sort of euclidean space, with an axes for each article contained in the order. Then we can consider a tray as a point on that space, with coordinates for each axes equal to the quantity that tray has of the article corresponding to that axes. In the same way we can imagine our order as a point.
Then I’ve create a heuristic function, f(order o, tray t), which returns the “euclidean distance” from point-tray t to the point-order o. The idea is that the more a tray is “near” the order, the more article we can pick out of it.

So, to satisfy the order, I simply compute f(order o, tray t) for each tray in every elevator. Then I order it by descending value and finally I greedily take a tray with the minimum distance from the order. This will be repeated until we collect enough articles to satisfy the order.

Now I `d like to find a better solution, taking into account also the physical distances from tray returned by function d.

I`ve tried to build a graph in which each node is a tray and is connected to each of the others by a directed edge. The weights of the edge from node i to node j will be equal to the physical distance from tray i to tray j, plus the heuristic function computed on tray j

--> w(i, j) = d(i, j) + f(order, j)

This results in a fully-connected, bidirectional graph (each node linked with each other node by both an incoming and an outgoing edge).
I want to apply some algorithm of shortest path (or any other useful algorithm) taken from graph theory on this graph but I couldnt find anything really helpful. Ive tried to apply the A* search algorithm (using function d as gScore and my function f as heuristic) but it gives me no result. I think A* can`t be applied in such a graph (bidirectional and fully connected).

Is there any algorithm I can apply on such a graph? Or maybe the graph is not the right structure to represent my problem. I`m open to new solutions.

Sudoku Graph in Julia – Code Review Stack Exchange

I’m building a graph coloring sudoku solver in Julia, so the first thing i’m tackling is the graph implementation. I have the bare structure completed, meaning I can create the graph with all of the right edges.

In terms of efficiency, it’s currently at

@timev s = SudokuGraph(3);

> 0.001573 seconds (16.05 k allocations: 1013.641 KiB)
> elapsed time (ns): 1573000
> bytes allocated:   1037968
> pool allocs:       16050
> non-pool GC allocs:1
> malloc() calls:    3
> realloc() calls:   1

But to be honest I’m not sure if this is good or bad.

After the initial writing and refactoring, this is what it looks like. I’d appreciate tips on making it more idiomatic/proper Julia or efficient.

(Note, in set_cell! I changed // to / for the sake of not breaking the syntax highlighting here)

#Pkg.add("Combinatorics")
using Combinatorics

mutable struct Node
    row::Int
    col::Int
    cell::Int
    value::Int

    function Node(coords::Tuple{Int,Int})
        row, col = coords
        return new(row, col, 0, 0)
    end
end

function set_cell!(node::Node, size::Int)
    col = node.col - 1
    row = node.row - 1
    node.cell = 1 + floor(((col / size) + row) - (row % size))
end

function get_coordinates(node::Node)::Tuple{Int,Int,Int}
    return (node.row, node.col, node.cell)
end

function are_adjacent(nodes::Tuple{Node,Node})::Bool
    a, b = get_coordinates.(nodes)
    return any(a .== b)
end

struct Edge
    nodes::Tuple{Node,Node}

    function Edge(nodes::Tuple{Node,Node})
        return new(nodes)
    end
end

function nodes_to_edges(nodes::Vector{Node})::Vector{Edge}
    return Edge.(Tuple.(filter(are_adjacent, Tuple.(combinations(nodes, 2)))))
end

mutable struct SudokuGraph
    nodes::Vector{Node}
    edges::Vector{Edge}

    function SudokuGraph(size::Int)
        cols = size^2
        space = Iterators.product(1:cols, 1:cols)
        nodes = Node.(reshape((space...), cols^2))
        set_cell!.(nodes, fill(size))
        edges = nodes_to_edges(nodes)

        return new(nodes, edges)
    end
end

Thank you!

graph colorings – Smallest known counterexamples to Hedetniemi’s conjecture

In 2019, Shitov has shown a counterexample to Hedetniemi’s conjecture,

$$chi(G times H)=min(chi(G),chi(H))$$
where $chi(G)$ is the chromatic number of the undirected finite graph $G$.

Shitov counterexample is estimated to have $|V(G)|approx4^{100}$ and $|V(H)|approx4^{10000}$. Has there been some effort or progress to reduce the size of the counterexample?

Graph theory connected graph – Mathematics Stack Exchange

I am studying graph thoery and come up with a thought that,

if $G$ is acyclic graph with valency of every vertex is at least two then $G$ is connected!

Is this true! if it is then how can i prove that?

All i can imagine is infinite graph which is tree.

(Valency of vertex of graph is number of vertices adjacent to vertex and acyclic means graph without cycle).