@kortexya/reasoninglayer 0.2.2 → 0.2.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -1,7 +1,7 @@
1
1
  'use strict';
2
2
 
3
3
  // src/config.ts
4
- var SDK_VERSION = "0.2.2";
4
+ var SDK_VERSION = "0.2.3";
5
5
  function resolveConfig(config) {
6
6
  if (!config.baseUrl) {
7
7
  throw new Error("ClientConfig.baseUrl is required");
@@ -12549,6 +12549,12 @@ var RagClient = class {
12549
12549
  };
12550
12550
 
12551
12551
  // src/builders/lp.ts
12552
+ function numericTerm(n) {
12553
+ return {
12554
+ sort_name: Number.isInteger(n) ? "integer_type" : "real_type",
12555
+ features: { value: n }
12556
+ };
12557
+ }
12552
12558
  var LP = {
12553
12559
  /**
12554
12560
  * Create a maximization objective.
@@ -12668,8 +12674,8 @@ function compileLP(problem, solutionSortName) {
12668
12674
  sort_name: "real_between_constraint",
12669
12675
  features: {
12670
12676
  var: ref,
12671
- lower: bounds.min,
12672
- upper: bounds.max
12677
+ lower: numericTerm(bounds.min),
12678
+ upper: numericTerm(bounds.max)
12673
12679
  }
12674
12680
  });
12675
12681
  } else {
@@ -12678,7 +12684,7 @@ function compileLP(problem, solutionSortName) {
12678
12684
  sort_name: "real_ge_constraint",
12679
12685
  features: {
12680
12686
  left: ref,
12681
- right: bounds.min
12687
+ right: numericTerm(bounds.min)
12682
12688
  }
12683
12689
  });
12684
12690
  }
@@ -12687,7 +12693,7 @@ function compileLP(problem, solutionSortName) {
12687
12693
  sort_name: "real_le_constraint",
12688
12694
  features: {
12689
12695
  left: ref,
12690
- right: bounds.max
12696
+ right: numericTerm(bounds.max)
12691
12697
  }
12692
12698
  });
12693
12699
  }
@@ -12702,7 +12708,7 @@ function compileLP(problem, solutionSortName) {
12702
12708
  sort_name: sortName,
12703
12709
  features: {
12704
12710
  left: compiled.resultRef,
12705
- right: constraint.rhs
12711
+ right: numericTerm(constraint.rhs)
12706
12712
  }
12707
12713
  });
12708
12714
  }
@@ -12719,7 +12725,7 @@ function compileLP(problem, solutionSortName) {
12719
12725
  sort_name: "real_eq_constraint",
12720
12726
  features: {
12721
12727
  left: objVar,
12722
- right: objectiveRef
12728
+ right: numericTerm(objectiveRef)
12723
12729
  }
12724
12730
  });
12725
12731
  objectiveRef = objVar;
@@ -12783,7 +12789,7 @@ function compileLinearExpression(expression, varRefs, nextVar) {
12783
12789
  antecedents.push({
12784
12790
  sort_name: "real_times_constraint",
12785
12791
  features: {
12786
- coefficient,
12792
+ coefficient: numericTerm(coefficient),
12787
12793
  variable: varRef,
12788
12794
  result: resultVar
12789
12795
  }
@@ -12792,7 +12798,7 @@ function compileLinearExpression(expression, varRefs, nextVar) {
12792
12798
  }
12793
12799
  }
12794
12800
  if (termResults.length === 0) {
12795
- return { antecedents, resultRef: 0 };
12801
+ return { antecedents, resultRef: numericTerm(0) };
12796
12802
  }
12797
12803
  if (termResults.length === 1) {
12798
12804
  return { antecedents, resultRef: termResults[0] };
@@ -12909,18 +12915,19 @@ var OptimizeClient = class {
12909
12915
  }
12910
12916
  const solution = bcResponse.data.solutions[0];
12911
12917
  const variables = {};
12912
- let objectiveValue = 0;
12913
12918
  for (const binding of solution.substitution.bindings) {
12914
12919
  const varName = binding.variable_name;
12915
12920
  if (!varName) continue;
12916
12921
  const value = parseFloat(binding.bound_to_display);
12917
12922
  if (isNaN(value)) continue;
12918
- if (varName === "?_lp_objective") {
12919
- objectiveValue = value;
12920
- } else if (varName.startsWith("?") && !varName.startsWith("?_lp_")) {
12923
+ if (varName.startsWith("?") && !varName.startsWith("?_lp_")) {
12921
12924
  variables[varName.slice(1)] = value;
12922
12925
  }
12923
12926
  }
12927
+ let objectiveValue = 0;
12928
+ for (const [varName, coeff] of Object.entries(problem.objective.coefficients)) {
12929
+ objectiveValue += coeff * (variables[varName] ?? 0);
12930
+ }
12924
12931
  return {
12925
12932
  status: "optimal",
12926
12933
  variables,