Repository navigation
fix(us-bf-031): resolve optimizer type conversion errors - #205
Merged
ooples merged 1 commit intoOct 24, 2025
Merged
Conversation
…er constructors Critical API changes to support model-centric optimization: **OptimizerBase.cs**: - Added InitializeRandomSolution(TInput) overload that returns IFullModel - This method calls CreateSolution(xTrain) to create model from stored _model field - Resolves CS7036 and CS1503 errors across all optimizers **Optimizer Constructor Fixes**: - ProximalGradientDescentOptimizer: Added model parameter to constructor - GradientDescentOptimizer: Added model parameter to constructor - StochasticGradientDescentOptimizer: Added model parameter to constructor - RootMeanSquarePropagationOptimizer: Added model parameter to constructor - PowellOptimizer: Added model parameter to constructor - TrustRegionOptimizer: Added model parameter to constructor - ADMMOptimizer: Added model parameter to constructor - AMSGradOptimizer: Added model parameter to constructor All constructors now pass model to base class as required by new API. **Impact**: - Resolves type conversion errors where Vector<T> was being passed to methods expecting IFullModel - Provides foundation for fixing remaining optimizer constructors - Maintains backward compatibility through optional parameters **Remaining Work**: - 10+ additional optimizers need similar constructor fixes - Non-optimizer files (VectorModel, AutoMLModelBase, etc.) need separate fixes References: US-BF-031 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR resolves type conversion errors in optimizer classes by adding a missing API method and updating constructors to align with the new model-centric architecture. The changes address CS1503 and CS7036 compilation errors by ensuring optimizers properly accept and pass the required model parameter to their base class.
Key Changes:
- Added
InitializeRandomSolution(TInput)overload to OptimizerBase to resolve type mismatches - Updated 8 optimizer constructors to accept
IFullModel<T, TInput, TOutput> modelparameter - Standardized constructor patterns across affected optimizers
Reviewed Changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| OptimizerBase.cs | Adds missing InitializeRandomSolution(TInput) method that returns IFullModel instead of Vector<T> |
| GradientDescentOptimizer.cs | Updates constructor to accept and pass model parameter to base class |
| StochasticGradientDescentOptimizer.cs | Updates constructor to accept and pass model parameter to base class |
| RootMeanSquarePropagationOptimizer.cs | Updates constructor to accept and pass model parameter to base class |
| ProximalGradientDescentOptimizer.cs | Updates constructor to accept and pass model parameter to base class |
| PowellOptimizer.cs | Updates constructor to accept and pass model parameter to base class |
| TrustRegionOptimizer.cs | Updates constructor to accept and pass model parameter to base class |
| ADMMOptimizer.cs | Updates constructor to accept and pass model parameter to base class |
| AMSGradOptimizer.cs | Updates constructor to accept and pass model parameter to base class |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
User Story
References: US-BF-031
Summary
This PR addresses critical type conversion errors in optimizer classes by adding a missing API method and updating constructors to match the new model-centric architecture.
Key Changes
1. OptimizerBase.cs - Critical API Addition
Added missing
InitializeRandomSolution(TInput)overload:Impact: This resolves CS1503 errors where
Vector<T>was being passed to methods expectingIFullModel<T, TInput, TOutput>across all 31+ optimizers that call this method.2. Optimizer Constructor Updates
Fixed constructors to accept
modelparameter as required by base class:Fixed Optimizers:
All now follow pattern:
Error Reduction
Technical Details
The root cause was an API evolution:
modelin its constructor_modelfieldInitializeRandomSolution(xTrain)expecting a model backThis PR provides the foundation fix that will cascade to resolve errors across the entire optimizer hierarchy.
Testing
Vector<T>toIFullModelimplicit conversions)Remaining Work
The following optimizers still need constructor updates (tracked separately):
Additionally, non-optimizer files have separate issues:
Acceptance Criteria Met
🤖 Generated with Claude Code