Showing posts with label Parallel Algorithms. Show all posts
Showing posts with label Parallel Algorithms. Show all posts

Threads profile for Darrell Ulm

I've recently taken the step of joining 

Threads, Computer Science, Computing: Darrell Ulm (https://www.threads.com/@darrell_r_ulm ),  

as I embark on a journey to relearn and expand my existing knowledge in areas like artificial intelligence. My current focus involves delving deeper into the intricacies of AI, particularly exploring the fascinating world of Large Language Models (LLMs) and understanding how these sophisticated models are developed and utilized. I'm also revisiting the fundamentals of Neural Networks, the core building blocks that enable AI systems to learn and make predictions. Given the computational demands of these fields, I'm also keen on extending the principles and applications I previously learned in parallel processing, which plays a crucial role in efficiently handling the complex computations involved in AI.

Darrell R. Ulm

ResearcherID for Darrell Ulm Site

Okay, so I was checking out this website, ResearcherID, and I created this page for Darrell Ulm: http://www.researcherid.com/rid/Y-5083-2018. It seems like another really useful site for listing research work, much like ORCID, which you can see here for Darrell Ulm as well: https://orcid.org/0000-0002-0513-0416 . I'm still trying to fully understand the nuances between ResearcherID and ORCID, as they appear to be quite similar in their aim – providing a unique identifier for researchers and their publications. However, looking at Darrell Ulm's ResearcherID page, it seems to have some interesting connections to other resources, specifically mentioning reviewing efforts. It's fascinating to see how these platforms are interconnected and how they contribute to the broader ecosystem of scholarly communication and recognition. I need to explore further how these different systems integrate and what unique benefits each offers to researchers like Darrell. It’s all part of navigating the evolving landscape of research visibility.

Apache Spark Knapsack Approximation Algorithm in Python

The code shown below computes an approximation algorithm, greedy heuristic, for the 0-1 knapsack problem in Apache Spark. Having worked with parallel dynamic programming algorithms a good amount, wanted to see what this would look like in Spark.

The Github code repo. for the Knapsack approximation algorithms is here, and it includes a Scala solution. The work on a Java version is in progress at time of this writing.

Below we have the code that computes the solution that fits within the knapsack W for a set of items each with it's own weight and profit value. We look to maximize the final sum of selected items profits while not exceeding the total possible weight, W.

First we import some spark libraries into Python.

# Knapsack 0-1 function weights, values and size-capacity.
from pyspark.sql import SparkSession
from pyspark.sql.functions import lit
from pyspark.sql.functions import col
from pyspark.sql.functions import sum


Now define the function, which will take a Spark Dataframe with all the items, each with a name, weight and profit, and the global total weight.

def knapsackApprox(knapsackDF, W):
    '''
    A simple greedy parallel implementation of 0-1 Knapsack algorithm.

    Parameters
    ----------
    knapsackDF : Spark Dataframe with knapsack data
        sqlContext.createDataFrame(knapsackData, ['item', 'weights', 'values'])

    W : float
        Total weight allowed for knapsack.

    Returns
    -------
    Dataframe
        Dataframe with results.
    '''


Create a DataFrame for each item, that is the ratio of profit over weight. Disregard all items weights that are larger than the global knapsack Weight W since they will not fit regardless. Sort, in Spark, all item rows by the ratio value, high to low.

    # Add ratio of values / weights column.
    ratioDF = (knapsackDF.withColumn("ratio", lit(knapsackDF.values / knapsackDF.weights))
               .filter(col("weights") <= W)
               .sort(col("ratio").desc())
               )




Get a current Spark Session to feed to the sql command.

    # Get the current Spark Session.
    sc = SparkSession.builder.getOrCreate()




Now we take the sorted list of filtered items, with profit ratio, and compute a partial sums of weight. This adds each element's weight to the prior sum of weight, which will be how to select the items that are less than W. There are other ways to do this, used the sql with sum() below.

    # An sql method to calculate the partial sums of the ratios.
    ratioDF.registerTempTable("tempTable")
    partialSumWeightsDF = sc.sql("""
        SELECT
            item,
            weights,
            values,
            ratio,
            sum(weights) OVER (ORDER BY ratio desc) as partSumWeights
        FROM
        tempTable
        """)




Now that we have the partial sums of weights when the DataFrame of elements is sorted by profit weight ratio, we get only the items that have a partial sum of weights less than the knapsack size W, and this is the final solution set.

    # Get the max number of items, less than or equal to W in Spark.
    partialSumWeightsFilteredDF = (
                                    partialSumWeightsDF.sort(col("ratio").desc())
                                    .filter(col("partSumWeights") <= W)
                                   )



Return the partialSumWeightsFilteredDF as the solution set.

    # Return the solution elements with total values, weights and count.
    return partialSumWeightsFilteredDF


For a non-approximate, optimal, solution's algorithm would need to be much differently, and Bulk Synchronous Parallel (BSP) solutions would be a good place to start looking.

Testing:

Now to use this function, below is some code to plug in values and test the knapsack approximation solution.

# --------------------------------------------
# Test the Approximate Knapsack function test
# --------------------------------------------

# Pull in the knapsack library.

import random
from pyspark.sql import SparkSession

from knapsack import knapsack

# Create the SparkContext.
sc = SparkSession \
    .builder \
    .appName("Knapsack Approximation Algorithm Test") \
    .getOrCreate()


Set the problem size to 10.

# Knapsack problem size.
N = 10


Setup a Python list with some uniform random data for N items in

# Setup sample data for knapsack.
knapsackData = [('item_' + str(k), random.uniform(1.0, 10.0), random.uniform(1.0, 10.0)) for k in range(N)]


Now create the knapsack items, with column names, item, weights and values, using the list KnapsackData.

# Make a Dataframe with item(s), weight(s), and value(s) for the knapsack.
knapsackData = sc.createDataFrame(knapsackData, ['item', 'weights', 'values'])

# Display the original data
print "Original Data:"
print knapsackData.show()
print "\n"


The weight is random based on a range of the number of items N, and we could set it in a number of ways.

# Create a random maximum weight
W = random.uniform(N * 1.3, N * 1.6)

# Show the weight.
print "W: "
print W
print "\n"


Now we just call the knapsack approximation method passing the knapsackData and total knapsack size W.

# Call the knapsack greedy approximation function, with data and size 5.
k = knapsack.knapsackApprox(knapsackData, W)


That's it, so we show the results of the selected elements:

# Show the results Dataframe.
print "Selected Elements:"
print k.show()
print "\n"


And add up the totals via RDD lambda function map() method to get the sum of values and weights. The sum of values is the total knapsack profit.

# Show totals for selected elements of knapsack.
sumValues = k.rdd.map(lambda x: x["values"]).reduce(lambda x, y: x+y)
sumWeights = k.rdd.map(lambda x: x["weights"]).reduce(lambda x, y: x+y)
numResults = k.count()
print "Totals:"
print "Sum Values: ",  sumValues
print "Sum Weights: ",  sumWeights
print numResults
print "\n"

# ------------------------------------------
# End of Approximate Knapsack function test
# ------------------------------------------


That is all. The Scala version is very similar to this, and I did not yet test this for very large N to see how long it takes. The sorts may have performance implications as well as the method to take the partial sums. Tests showed it to work correctly.

The code here can also be found at: Spark.Packages.Org for the knapsack approximation.


Stream PRAM: The Streaming Parallel Random Access Machine Model: Research: Darrell Ulm

Stream PRAM is a research paper co‑written by Darrell Ulm, focusing on a multiple‑instruction‑stream extension of the Parallel Random Access Memory (PRAM) model. The work is accessible through several major academic platforms:

A Multiple‑Instruction‑Stream PRAM Model

The Stream PRAM paper explores a PRAM‑style computational model that incorporates multiple instruction streams, extending the traditional PRAM framework. This approach examines how parallel computation behaves when instruction streams operate in a coordinated yet distinct manner within a shared‑memory environment.

The model remains firmly rooted in theoretical parallel computation, emphasizing conceptual analysis rather than applied system design or hardware implementation. Its focus is on understanding the computational structure, algorithmic implications, and theoretical behavior of PRAM‑based systems when enhanced with streaming or multi‑stream capabilities.

Emphasis on Theory Over Application

The paper’s contributions lie primarily in:

  • analyzing theoretical aspects of parallel computation

  • examining PRAM variants and their computational properties

  • exploring how multiple instruction streams interact within a PRAM model

  • contributing to foundational research in parallel algorithm theory

Because the work is theoretical, it is especially relevant to researchers studying abstract models of parallelism, PRAM extensions, and the limits and capabilities of parallel algorithms.

Additional References

Other academic links and citation platforms also index or reference the Stream PRAM paper, helping situate it within the broader landscape of theoretical parallel computing research.

Profile. Wordpress, Tumblr

Darrell Ulm: A Data Parallel Compiler Optimizer: C Source Code

Below is a link to the GitHub Page for a data-parallel compiler optimizer, coded in C for Unix / Linux for a compiler optimizer for a data-parallel language.

Darrell Ulm's GitHub IO Page for a Data Parallel Compiler Optimizer Source Code

Research Papers by Darrell Ulm, Associative Computing, The Computer Science Department at Kent State University


Has comp. sci. papers of Darrell Ulm, and others which were written in collaboration with other Computer Scientists at Kent State University.

Papers, links to PDF files, which were co-written by Darrell Ulm on Parallel Computation

Tumblr, Wordpress

Darrell Ulm: Google Scholar Search, Academic Research Papers


Computer Science research papers written and also references to research papers concerning parallel computation, data-parallel algorithms, and operations research.

Research Paper, Darrell Ulm: "Solving a Two-Dimensional Knapsack Problem on SIMD Computers"

Paper concerning a SIMD solution to a 2D cutting stock - operations research problem.

Darrell Ulm, Stream PRAM a Computer Science Research Paper @ PubZone



Stream PRAM a Comp. Sci. research paper by Darrell Ulm @ PubZone

Pubzone reference for Comp. Sci. paper by Darrell Ulm "Stream PRAM," at the International Parallel and Distributed Processing Symposium.

Darrell Ulm: ResearchGate Profile in Computer Science



Darrell Ulm: ResearchGate.net  profile highlights his background in computer science, showcasing his technical skills and involvement in computer and technology research. The page includes references to his computer science papers, along with details about his academic interests and contributions to the field.

Research Papers, Darrell Ulm on Microsoft Academic Site

Microsoft used to host a link to its Academic Search platform, but that site has since been taken offline. The link originally pointed to Darrell Ulm’s research on parallel algorithms, data‑parallelism, and high‑performance computing. It’s a bit surprising that Microsoft retired the publication portal, because it was a genuinely valuable hub for technical papers and academic references.

Comp. Sci Paper by Darrell Ulm: "Solving a 2D Knapsack Problem Using a Hybrid Data-Parallel/Control Style of Computing"


“Solving a 2D Knapsack Problem Using a Hybrid Data-Parallel/Control Style of Computing” reference to parallel algorithms computer science research paper, (IEEE Computer Society reference to) Santa Fe, NM, USA, by Darrell Ulm.

Reference to the IEEE Computer Society entry: for Paper by Darrell Ulm called “Solving a 2D Knapsack Problem Using a Hybrid Data-Parallel/Control Style of Computing"

Tumblr, Wordpress

Parallel Computational Model by Darrell Ulm, "Stream PRAM"

A new parallel computational model, research paper called "Stream PRAM," by Darrell Ulm.

The IEEE Computer Society reference to Stream PRAM paper

Tumblr, Wordpress

Darrell Ulm: Research Paper "Solving a 2D knapsack problem using a hybrid data-parallel/control style of computing"

Computer science research paper by Darrell Ulm: “Solving a 2D knapsack problem using a hybrid data-parallel/control style of computing,” on IEEE Xplore, concerning operations research, parallel computation, parallel algorithms.

Here is the Link to IEEE Xplore entry for this paper, by Darrell Ulm.

Simulating PRAM with a MSIMD model (ASC), Article in IEEE Xplore



Simulating PRAM with a MSIMD model (ASC), Darrell Ulm

An IEEE Xplore article reference for computer science paper about algorithmic computational simulation and complexities involved.

Tumblr, Wordpress

Comp. Sci. Paper, Darrell Ulm: "Virtual Parallelism by Self Simulation of the Multiple Instruction Stream Associative Model" as PDF


Computer Science Paper about Parallel Processing Algorithms by Darrell Ulm: “Virtual Parallelism by Self Simulation of the Multiple Instruction Stream Associative Model."
http://www.cs.kent.edu/~parallel/papers/ulm96vp.pdf

Tumblr, Wordpress

Darrell Ulm Paper, PDF: "Solving a 2D Knapsack Problem Using a Hybrid Data-Parallel/Control Style of Computing"



A computer science research paper, parallel algorithms, in PDF, by Darrell Ulm, “Solving a 2D Knapsack Problem Using a Hybrid Data-Parallel/Control Style of Computing."

http://www.cs.kent.edu/~parallel/papers/ulm_wmpp04.pdf

Tumblr, Wordpress

Pdf of Comp. Sci. Paper by Darrell Ulm: "Solving a 2D Knapsack Problem on an Associative Computer Augmented with a Linear Network"


A link is to a PDF paper by Darrell Ulm, http://www.cs.kent.edu/~parallel/papers/ulm962dk.pdf, “Solving a 2D Knapsack Problem on an Associative Computer Augmented with a Linear Network"

Tumblr, Wordpress

Darrell Ulm Computer Science Paper: "Solving a 2D Knapsack Problem on an Associative Computer Augmented with a Linear Network"


Computer Science Paper by Darrell Ulm and reference to “Solving a 2D Knapsack Problem on an Associative Computer Augmented with a Linear Network."

The Parallel Computation Paper on CiteSeer, by Darrell Ulm.

Tumblr, Wordpress