Skip to content

Commit b504275

Browse files
committed
Update polynomail weights
1 parent bc6cb74 commit b504275

File tree

1 file changed

+36
-15
lines changed

1 file changed

+36
-15
lines changed

html/index.html

Lines changed: 36 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -79,24 +79,31 @@
7979
<body>
8080
<div class="container">
8181
<h1>Ganak Model Counter in Your Browser</h1>
82-
<div>Copy your CNF formula in the input box below and click "Run ganak.js" to run the counter in your browser. The output will be displayed below the input box. Example is from <a href="https://www.msoos.org/">article on model counting</a>. Format description is available <a href="https://mccompetition.org/assets/files/mccomp_format_24.pdf">here</a></div>
82+
<div>Copy your CNF formula in the input box below and click "Run
83+
ganak.js" to run the counter in your browser. The output will be
84+
displayed below the input box. Example is from <a
85+
href="https://www.msoos.org/">article on model counting</a>. Format
86+
description is available <a
87+
href="https://mccompetition.org/assets/files/mccomp_format_24.pdf">here</a>.
88+
For polynomial weights, try "x1" or "x0+1/2*x1-x3"</div>
8389

8490
<div>
8591
<label for="input-content">CNF:</label>
8692
<textarea id="input-content">c t pwmc
8793
p cnf 3 2
8894
c comment X = 1, Y = 2, H1 = 3
89-
c p weight 1 0.4 0
90-
c p weight 2 0.6 0
91-
c p weight 3 0.8 0
95+
c p weight 1 4/10 0
96+
c p weight 2 6/10 0
97+
c p weight 3 8/10 0
9298
1 2 0
9399
-3 -1 -2 0
94100
c p show 1 2 3 0
95101
</textarea>
96102
</div>
97103

98104
<div>
99-
<button id="run-button">Run ganak.js</button>
105+
<button id="run-button-w">Count weighted</button>
106+
<button id="run-button-poly">Count polynomial (100 vars)</button>
100107
<button id="cancel-button">Cancel</button>
101108
<span id="status" class="status">Loading WebAssembly module...</span>
102109
<div class="progress-container">
@@ -117,7 +124,8 @@ <h1>Ganak Model Counter in Your Browser</h1>
117124
stdin: function() { return null; },
118125
onRuntimeInitialized: function() {
119126
document.getElementById('status').textContent = 'Ready';
120-
document.getElementById('run-button').disabled = false;
127+
document.getElementById('run-button-w').disabled = false;
128+
document.getElementById('run-button-poly').disabled = false;
121129
}
122130
};
123131

@@ -132,7 +140,9 @@ <h1>Ganak Model Counter in Your Browser</h1>
132140
},
133141
printErr: function(text) {
134142
console.error('Error:', text);
135-
//postMessage({ type: 'output', content: 'ERROR: ' + text });
143+
if (!text.includes('__syscall_getrusage')) {
144+
postMessage({ type: 'output', content: 'ERROR: ' + text });
145+
}
136146
},
137147
onRuntimeInitialized: function() {
138148
postMessage({ type: 'ready' });
@@ -158,9 +168,9 @@ <h1>Ganak Model Counter in Your Browser</h1>
158168
}
159169
else if (e.data.type === 'run') {
160170
try {
161-
console.log('Running with args:', e.data.args);
162171
Module.FS.writeFile('/input.cnf', e.data.input);
163-
Module.callMain(['--arjunverb', '1', '--verb', '1', '--mode', '1', '/input.cnf']);
172+
console.log('running with mode:', e.data.mode);
173+
Module.callMain(['--arjunverb', '1', '--verb', '1', '--mode', e.data.mode, '--npolyvars', '100', '/input.cnf']);
164174
postMessage({ type: 'done' });
165175
} catch (e) {
166176
postMessage({ type: 'error', content: e.toString() });
@@ -173,8 +183,7 @@ <h1>Ganak Model Counter in Your Browser</h1>
173183
return URL.createObjectURL(blob);
174184
}
175185

176-
// Main execution logic
177-
document.getElementById('run-button').addEventListener('click', async function() {
186+
const fun = function(mode) {
178187
const inputContent = document.getElementById('input-content').value;
179188
const outputDiv = document.getElementById('output');
180189

@@ -184,7 +193,8 @@ <h1>Ganak Model Counter in Your Browser</h1>
184193
}
185194

186195
outputDiv.textContent = 'Initializing...\n';
187-
document.getElementById('run-button').disabled = true;
196+
document.getElementById('run-button-w').disabled = true;
197+
document.getElementById('run-button-poly').disabled = true;
188198
document.getElementById('status').textContent = 'Running...';
189199

190200
// Get absolute URL for WASM file
@@ -204,19 +214,22 @@ <h1>Ganak Model Counter in Your Browser</h1>
204214
//console.log('ready. Sending input:', inputContent);
205215
worker.postMessage({
206216
type: 'run',
207-
input: inputContent
217+
input: inputContent,
218+
mode : mode,
208219
});
209220
break;
210221
case 'done':
211222
document.getElementById('status').textContent = 'Completed';
212-
document.getElementById('run-button').disabled = false;
223+
document.getElementById('run-button-w').disabled = false;
224+
document.getElementById('run-button-poly').disabled = false;
213225
worker.terminate();
214226
URL.revokeObjectURL(workerUrl);
215227
break;
216228
case 'error':
217229
outputDiv.textContent += 'Error: ' + e.data.content + '\n';
218230
document.getElementById('status').textContent = 'Failed';
219-
document.getElementById('run-button').disabled = false;
231+
document.getElementById('run-button-w').disabled = false;
232+
document.getElementById('run-button-poly').disabled = false;
220233
worker.terminate();
221234
URL.revokeObjectURL(workerUrl);
222235
break;
@@ -231,6 +244,14 @@ <h1>Ganak Model Counter in Your Browser</h1>
231244
wasmPath: wasmPath
232245
}
233246
});
247+
};
248+
249+
// Main execution logic
250+
document.getElementById('run-button-w').addEventListener('click', async function() {
251+
fun("1");
252+
});
253+
document.getElementById('run-button-poly').addEventListener('click', async function() {
254+
fun("3");
234255
});
235256

236257
// Load ganak.js in main thread

0 commit comments

Comments
 (0)