Below is an all-in-one HTML file that implements a very basic portfolio simulation for pharmaceutical projects. In this example, each project starts in the “Preclinical” stage. At each stage (Preclinical, Phase I, Phase II, and Phase III) the user may decide to “Go” (advance the project to the next stage) or “Kill” (terminate the project). When a project successfully advances from Phase III, it “reaches the market” and a random payoff is generated. You can also see a log of decisions for each project and review the outcome of projects that were killed.
You can copy the entire code into a file (e.g. simulation.html) and open it in your browser:
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Pharmaceutical Portfolio Simulation</title>
<style>
body {
font-family: Arial, sans-serif;
margin: 20px;
}
h2 {
border-bottom: 1px solid #ccc;
padding-bottom: 5px;
}
table {
width: 100%;
margin-bottom: 20px;
border-collapse: collapse;
}
table, th, td {
border: 1px solid #333;
}
th, td {
padding: 8px;
text-align: left;
}
button {
margin-right: 5px;
}
</style>
</head>
<body>
<h1>Pharmaceutical Portfolio Simulation</h1>
<p>
In this simulation you will manage several pharmaceutical projects through a sequence of stage‐gates.
At each stage, click “Go” to continue the project or “Kill” to terminate it.
Projects that successfully make it from Preclinical, Phase I, Phase II, and Phase III reach the market and generate a payoff.
</p>
<button onclick="startSimulation()">Start Simulation</button>
<h2>Active Projects</h2>
<div id="activeProjects">
<!-- Active projects table will appear here -->
</div>
<h2>Projects Reached Market</h2>
<div id="marketProjects">
<!-- Successful projects table will appear here -->
</div>
<h2>Killed Projects</h2>
<div id="killedProjects">
<!-- Killed projects table will appear here -->
</div>
<script>
// Define the stage names for clarity.
const stages = ["Preclinical", "Phase I", "Phase II", "Phase III", "Market"];
// Define the Project "class" (using a simple constructor function)
function Project(id) {
this.id = id;
this.stage = 0; // start at Preclinical
this.status = "active"; // possible values: "active", "killed", "market"
this.logs = [];
this.payoff = 0; // will only be used if the project reaches market
}
// Store all projects in a global array.
let projects = [];
// Initialize the simulation by creating some projects.
function startSimulation() {
// Reset the projects array.
projects = [];
// For example, create 5 projects.
for (let i = 1; i <= 5; i++) {
projects.push(new Project(i));
}
renderProjects();
}
// Called when the user clicks "Go" for a project.
function goProject(id) {
let p = projects.find(proj => proj.id === id);
if (!p || p.status !== "active") return;
// Log the approval for the current stage.
p.logs.push("Approved at " + stages[p.stage]);
// If not yet at the last stage of development, advance to next stage.
if (p.stage < 3) {
p.stage++;
p.logs.push("Advanced to " + stages[p.stage]);
}
// If the project is in Phase III, a "Go" completes development.
else if (p.stage === 3) {
// Advance to market.
p.stage++;
p.status = "market";
// Generate a random payoff (for instance, between $100M and $300M).
p.payoff = Math.round(Math.random() * 200 + 100);
p.logs.push("Reached Market with a payoff of $" + p.payoff + " million");
}
renderProjects();
}
// Called when the user clicks "Kill" for a project.
function killProject(id) {
let p = projects.find(proj => proj.id === id);
if (!p || p.status !== "active") return;
p.status = "killed";
p.logs.push("Killed at " + stages[p.stage]);
renderProjects();
}
// Render the projects and logs for each category.
function renderProjects() {
let activeDiv = document.getElementById("activeProjects");
let marketDiv = document.getElementById("marketProjects");
let killedDiv = document.getElementById("killedProjects");
// Render active projects.
let activeHTML = "<table><tr><th>Project ID</th><th>Current Stage</th><th>Decision</th><th>Logs</th></tr>";
projects.filter(p => p.status === "active").forEach(p => {
activeHTML += "<tr>";
activeHTML += "<td>" + p.id + "</td>";
activeHTML += "<td>" + stages[p.stage] + "</td>";
activeHTML += "<td>"
+ "<button onclick='goProject(" + p.id + ")'>Go</button>"
+ "<button onclick='killProject(" + p.id + ")'>Kill</button>"
+ "</td>";
activeHTML += "<td>" + p.logs.join("<br>") + "</td>";
activeHTML += "</tr>";
});
activeHTML += "</table>";
activeDiv.innerHTML = activeHTML;
// Render market (successful) projects.
let marketHTML = "<table><tr><th>Project ID</th><th>Payoff</th><th>Logs</th></tr>";
projects.filter(p => p.status === "market").forEach(p => {
marketHTML += "<tr>";
marketHTML += "<td>" + p.id + "</td>";
marketHTML += "<td>$" + p.payoff + " million</td>";
marketHTML += "<td>" + p.logs.join("<br>") + "</td>";
marketHTML += "</tr>";
});
marketHTML += "</table>";
marketDiv.innerHTML = marketHTML;
// Render killed projects.
let killedHTML = "<table><tr><th>Project ID</th><th>Stage Killed</th><th>Logs</th></tr>";
projects.filter(p => p.status === "killed").forEach(p => {
killedHTML += "<tr>";
killedHTML += "<td>" + p.id + "</td>";
killedHTML += "<td>" + stages[p.stage] + "</td>";
killedHTML += "<td>" + p.logs.join("<br>") + "</td>";
killedHTML += "</tr>";
});
killedHTML += "</table>";
killedDiv.innerHTML = killedHTML;
}
</script>
</body>
</html>
How It Works
-
Starting the Simulation:
Click the Start Simulation button. This creates 5 projects, each beginning at the “Preclinical” stage.
-
Making Decisions:
For each active project, you see its current stage. Click Go to advance the project to the next stage or Kill to terminate it.
- When a project is advanced from Phase III (the 4th stage in the sequence), it automatically reaches the market. A random payoff (between 100Mand300M) is generated.
- When a project is killed at any stage, its logs record the stage at which it was terminated.
-
Viewing Outcomes:
The simulation displays three tables:
- Active Projects: Projects still in development with decision buttons.
- Projects Reached Market: Successful projects that made it all the way, along with their payoff.
- Killed Projects: Projects terminated along the way and the stage at which they were killed.
Feel free to modify the simulation (e.g., add more projects, change the stage names, or customize the payoff range) to suit your needs. Enjoy managing your portfolio!